feat: 呼叫取样
This commit is contained in:
@@ -35,4 +35,9 @@ public class OtherPdaController {
|
||||
public ResponseEntity<Object> resumeMoveWasteFoil(@RequestBody JSONObject param) {
|
||||
return new ResponseEntity<>(otherPdaService.resumeMoveWasteFoil(param), HttpStatus.OK);
|
||||
}
|
||||
@PostMapping("/callAgvToSampling")
|
||||
@Log("呼叫取样")
|
||||
public ResponseEntity<Object> callAgvToSampling(@RequestBody JSONObject param) {
|
||||
return new ResponseEntity<>(otherPdaService.callAgvToSampling(param), HttpStatus.OK);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,4 +21,11 @@ public interface OtherPdaService {
|
||||
* @return /
|
||||
*/
|
||||
JSONObject resumeMoveWasteFoil(JSONObject param);
|
||||
|
||||
/**
|
||||
* 呼叫取样
|
||||
* @param param /
|
||||
* @return /
|
||||
*/
|
||||
JSONObject callAgvToSampling(JSONObject param);
|
||||
}
|
||||
|
||||
@@ -10,6 +10,8 @@ import org.nl.wms.pda.st.service.OtherPdaService;
|
||||
import org.nl.wms.sch.task.service.ISchBaseTaskService;
|
||||
import org.nl.wms.sch.task.service.dao.SchBaseTask;
|
||||
import org.nl.wms.sch.task_manage.TaskStatus;
|
||||
import org.nl.wms.sch.task_manage.core.constant.GeneralDefinition;
|
||||
import org.nl.wms.sch.task_manage.tasks.other.CallToSamplingAGVTask;
|
||||
import org.nl.wms.sch.task_manage.tasks.other.WasteFoilAGVTask;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
@@ -30,6 +32,8 @@ public class OtherPdaServiceImpl implements OtherPdaService {
|
||||
private WasteFoilAGVTask wasteFoilAGVTask;
|
||||
@Autowired
|
||||
private ISchBaseTaskService taskService;
|
||||
@Autowired
|
||||
private CallToSamplingAGVTask callToSamplingAGVTask;
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public JSONObject startMoveWasteFoil(JSONObject param) {
|
||||
@@ -62,6 +66,11 @@ public class OtherPdaServiceImpl implements OtherPdaService {
|
||||
String flag = param.getString("flag");
|
||||
// 判断是否能够搬运
|
||||
String pointCode = param.getString("point_code");
|
||||
// 校验是否二次创建任务
|
||||
List<SchBaseTask> schBaseTasks = taskService.checkHaveTask(pointCode);
|
||||
if (schBaseTasks.size() > 0) {
|
||||
throw new BadRequestException("点位[" + pointCode + "]已经存在任务!");
|
||||
}
|
||||
// 查找执行中的任务
|
||||
SchBaseTask task = taskService.getOne(new LambdaQueryWrapper<SchBaseTask>()
|
||||
.eq(SchBaseTask::getPoint_code2, pointCode)
|
||||
@@ -93,4 +102,23 @@ public class OtherPdaServiceImpl implements OtherPdaService {
|
||||
result.put("message", "废箔继续搬运请求成功!");
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JSONObject callAgvToSampling(JSONObject param) {
|
||||
log.info("手持呼叫AGV送样品检测 - {}", param);
|
||||
// point_code1, point_code2
|
||||
String pointCode1 = param.getString("point_code1");
|
||||
List<SchBaseTask> schBaseTasks = taskService.checkHaveTask(pointCode1);
|
||||
if (schBaseTasks.size() > 0) {
|
||||
throw new BadRequestException("点位[" + pointCode1 + "]已经存在任务!");
|
||||
}
|
||||
param.put("device_code", pointCode1);
|
||||
param.put("config_code", "CallToSamplingAGVTask");
|
||||
param.put("create_mode", GeneralDefinition.PDA_CREATION);
|
||||
callToSamplingAGVTask.apply(param);
|
||||
JSONObject result = new JSONObject();
|
||||
result.put("status", HttpStatus.OK.value());
|
||||
result.put("message", "取样检测任务请求成功!");
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,69 @@
|
||||
package org.nl.wms.sch.task_manage.tasks.other;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nl.common.exception.BadRequestException;
|
||||
import org.nl.wms.sch.task.service.ISchBaseTaskService;
|
||||
import org.nl.wms.sch.task.service.dao.SchBaseTask;
|
||||
import org.nl.wms.sch.task_manage.AbstractTask;
|
||||
import org.nl.wms.sch.task_manage.TaskStatus;
|
||||
import org.nl.wms.sch.task_manage.core.constant.GeneralDefinition;
|
||||
import org.nl.wms.sch.task_manage.core.enums.TaskFinishedTypeEnum;
|
||||
import org.nl.wms.util.TaskUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import static org.nl.wms.util.TaskUtils.checkTaskOptionStatus;
|
||||
import static org.nl.wms.util.TaskUtils.setUpdateByPC;
|
||||
|
||||
/**
|
||||
* @Author: lyd
|
||||
* @Description: 呼叫AGV取样送样
|
||||
* @Date: 2024/8/15
|
||||
*/
|
||||
@Slf4j
|
||||
@Component(value = "CallToSamplingAGVTask")
|
||||
public class CallToSamplingAGVTask extends AbstractTask {
|
||||
private final String THIS_CLASS = CallToSamplingAGVTask.class.getName();
|
||||
@Autowired
|
||||
private ISchBaseTaskService taskService;
|
||||
@Override
|
||||
public void create() throws BadRequestException {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createCompletion(SchBaseTask task) {
|
||||
String requestParam = task.getRequest_param();
|
||||
JSONObject requestObj = JSONObject.parseObject(requestParam);
|
||||
String pointCode2 = requestObj.getString("point_code2");
|
||||
task.setPoint_code2(pointCode2);
|
||||
// 创建任务
|
||||
task.setHandle_class(THIS_CLASS);
|
||||
task.setTask_status(TaskStatus.START_AND_POINT.getCode());
|
||||
setUpdateByPC(task);
|
||||
taskService.save(task);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void finishTask(SchBaseTask taskObj, TaskFinishedTypeEnum taskFinishedType) {
|
||||
checkTaskOptionStatus(taskObj);
|
||||
// 任务完成
|
||||
taskObj.setTask_status(TaskStatus.FINISHED.getCode());
|
||||
taskObj.setFinished_type(taskFinishedType.getCode());
|
||||
TaskUtils.setUpdateByType(taskObj, taskFinishedType);
|
||||
taskService.updateById(taskObj);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cancelTask(SchBaseTask taskObj, TaskFinishedTypeEnum taskFinishedType) {
|
||||
checkTaskOptionStatus(taskObj);
|
||||
// 取消
|
||||
taskObj.setTask_status(TaskStatus.CANCELED.getCode());
|
||||
taskObj.setRemark(GeneralDefinition.TASK_CANCEL);
|
||||
taskObj.setFinished_type(taskFinishedType.getCode());
|
||||
TaskUtils.setUpdateByType(taskObj, taskFinishedType);
|
||||
taskService.updateById(taskObj);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user