rev:海康对接

This commit is contained in:
2025-11-16 13:55:46 +08:00
parent a2beec4544
commit 28a81fd254
7 changed files with 182 additions and 24 deletions

View File

@@ -1,5 +1,7 @@
package org.nl.acs.device_driver.conveyor.standard_ordinary_site; package org.nl.acs.device_driver.conveyor.standard_ordinary_site;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import lombok.Data; import lombok.Data;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
@@ -8,12 +10,20 @@ import org.nl.acs.device_driver.DeviceDriver;
import org.nl.acs.device_driver.RouteableDeviceDriver; import org.nl.acs.device_driver.RouteableDeviceDriver;
import org.nl.acs.device_driver.driver.AbstractDeviceDriver; import org.nl.acs.device_driver.driver.AbstractDeviceDriver;
import org.nl.acs.device_driver.driver.ExecutableDeviceDriver; import org.nl.acs.device_driver.driver.ExecutableDeviceDriver;
import org.nl.acs.ext.enums.ApplyPassEnum;
import org.nl.acs.ext.hk.UnifiedResponse;
import org.nl.acs.ext.hk.service.AcsToHkService; import org.nl.acs.ext.hk.service.AcsToHkService;
import org.nl.acs.ext.hk.service.data.BoxApplyPassReq;
import org.nl.acs.ext.wms.service.AcsToWmsService;
import org.nl.acs.instruction.domain.Instruction;
import org.nl.acs.instruction.enums.InstTypeEnum;
import org.nl.acs.instruction.service.InstructionService; import org.nl.acs.instruction.service.InstructionService;
import org.nl.acs.monitor.DeviceStageMonitor; import org.nl.acs.monitor.DeviceStageMonitor;
import org.nl.acs.task.service.TaskService; import org.nl.acs.task.service.TaskService;
import org.nl.config.SpringContextHolder; import org.nl.config.SpringContextHolder;
import java.util.Optional;
/** /**
* 普通站点 * 普通站点
@@ -26,16 +36,85 @@ public class StandardOrdinarySiteDeviceDriver extends AbstractDeviceDriver imple
private final InstructionService instructionService = SpringContextHolder.getBean(InstructionService.class); private final InstructionService instructionService = SpringContextHolder.getBean(InstructionService.class);
private final TaskService taskService = SpringContextHolder.getBean(TaskService.class); private final TaskService taskService = SpringContextHolder.getBean(TaskService.class);
private final AcsToHkService acsToHkService = SpringContextHolder.getBean(AcsToHkService.class); private final AcsToHkService acsToHkService = SpringContextHolder.getBean(AcsToHkService.class);
private final AcsToWmsService acsToWmsService = SpringContextHolder.getBean(AcsToWmsService.class);
String device_code = null; String device_code = null;
String message; String message;
/**
* CTU请求取货标记和任务号
*/
private volatile String reqTakeInstCode = null;
private volatile Boolean reqTakeRequireSuccess = false;
/**
* 请求时间
*/
private long requireTime = System.currentTimeMillis();
/**
* 请求间隔时间
*/
private long requireTimeOut = 5000L;
@Override @Override
public void execute() { public void execute() {
device_code = this.getDevice().getDevice_code(); device_code = this.getDevice().getDevice_code();
if (this.reqTakeRequireSuccess && ObjectUtil.isNotEmpty(this.reqTakeInstCode)) {
Instruction instruction = instructionService.findByCodeFromCache(this.reqTakeInstCode);
//取货申请
if (ObjectUtil.isNotEmpty(instruction) && StrUtil.equals(instruction.getStart_device_code(), this.device_code)) {
this.boxApplyPass(ApplyPassEnum.GET_PASS.getCode());
}
//放货申请
else if (ObjectUtil.isNotEmpty(instruction) && StrUtil.equals(instruction.getNext_device_code(), this.device_code)) {
boolean putFlag = Optional.ofNullable(this.getDevice().getExtraValue().get("ignore_release_check")).map(Object::toString).map(Boolean::parseBoolean).orElse(false);
if (putFlag) {
this.applyPass(instruction);
} else {
this.boxApplyPass(ApplyPassEnum.PUT_PASS.getCode());
}
}
}
}
private boolean isTimeValid(long currentTimeMillis) {
return currentTimeMillis - this.requireTime >= this.requireTimeOut;
}
private void applyPass(Instruction instruction) {
long currentTimeMillis = System.currentTimeMillis();
if (!isTimeValid(currentTimeMillis)) {
log.trace("触发时间因为小于{}毫秒,而被无视", this.requireTimeOut);
} else {
this.requireTime = currentTimeMillis;
JSONObject reqParam = new JSONObject();
reqParam.put("task_code", instruction.getTask_code());
reqParam.put("point_code", instruction.getNext_point_code());
UnifiedResponse<JSONObject> wmsUnifiedResponse = acsToWmsService.applyPass(reqParam, JSONObject.class);
if (wmsUnifiedResponse.isSuccess() && wmsUnifiedResponse.getData() != null) {
JSONObject data = wmsUnifiedResponse.getData();
if (data != null && "1".equals(data.getString("is_confirm"))) {
this.boxApplyPass(ApplyPassEnum.PUT_PASS.getCode());
// this.reqTakeRequireSuccess = false;
// this.reqTakeInstCode = null;
}
}
}
}
private void boxApplyPass(String type) {
BoxApplyPassReq bapReq = BoxApplyPassReq.builder()
.taskCode(this.reqTakeInstCode)
.type(type)
.build();
UnifiedResponse<String> unifiedResponse = acsToHkService.boxApplyPass(bapReq, String.class);
if (unifiedResponse.isSuccess()) {
this.reqTakeRequireSuccess = false;
this.reqTakeInstCode = null;
}
} }
@Override @Override

View File

@@ -15,6 +15,7 @@ import org.nl.acs.ext.enums.ApplyPassEnum;
import org.nl.acs.ext.hk.UnifiedResponse; import org.nl.acs.ext.hk.UnifiedResponse;
import org.nl.acs.ext.hk.service.AcsToHkService; import org.nl.acs.ext.hk.service.AcsToHkService;
import org.nl.acs.ext.hk.service.data.BoxApplyPassReq; import org.nl.acs.ext.hk.service.data.BoxApplyPassReq;
import org.nl.acs.ext.hk.service.data.ContinueTaskReq;
import org.nl.acs.ext.wms.service.AcsToWmsService; import org.nl.acs.ext.wms.service.AcsToWmsService;
import org.nl.acs.instruction.domain.Instruction; import org.nl.acs.instruction.domain.Instruction;
import org.nl.acs.instruction.enums.InstTypeEnum; import org.nl.acs.instruction.enums.InstTypeEnum;
@@ -100,8 +101,10 @@ public class StandardWeightSiteDeviceDriver extends AbstractOpcDeviceDriver impl
} else { } else {
this.boxApplyPass(ApplyPassEnum.GET_PASS.getCode()); this.boxApplyPass(ApplyPassEnum.GET_PASS.getCode());
} }
} else { } else if (StrUtil.equals(InstTypeEnum.AGV_THREE_TASK.getCode(), instruction.getInstruction_type()) ||
this.boxApplyPass(ApplyPassEnum.GET_PASS.getCode()); StrUtil.equals(InstTypeEnum.AGV_TWO_TASK.getCode(), instruction.getInstruction_type())) {
//this.boxApplyPass(ApplyPassEnum.GET_PASS.getCode());
this.continueTask();
} }
} }
//放货申请 //放货申请
@@ -110,10 +113,16 @@ public class StandardWeightSiteDeviceDriver extends AbstractOpcDeviceDriver impl
if (putFlag) { if (putFlag) {
this.applyPass(instruction); this.applyPass(instruction);
} else { } else {
// this.boxApplyPass(ApplyPassEnum.PUT_PASS.getCode());
if (StrUtil.equals(instruction.getInstruction_type(), InstTypeEnum.AGV_TWO3_TASK.getCode()) ||
StrUtil.equals(instruction.getInstruction_type(), InstTypeEnum.AGV_THREE_TASK.getCode())) {
this.continueTask();
} else if (StrUtil.equals(instruction.getInstruction_type(), InstTypeEnum.CTU_OUT_TASK.getCode())) {
this.boxApplyPass(ApplyPassEnum.PUT_PASS.getCode()); this.boxApplyPass(ApplyPassEnum.PUT_PASS.getCode());
} }
} }
} }
}
this.last_weight = this.weight; this.last_weight = this.weight;
} }
@@ -159,9 +168,12 @@ public class StandardWeightSiteDeviceDriver extends AbstractOpcDeviceDriver impl
if (wmsUnifiedResponse.isSuccess() && wmsUnifiedResponse.getData() != null) { if (wmsUnifiedResponse.isSuccess() && wmsUnifiedResponse.getData() != null) {
JSONObject data = wmsUnifiedResponse.getData(); JSONObject data = wmsUnifiedResponse.getData();
if (data != null && "1".equals(data.getString("is_confirm"))) { if (data != null && "1".equals(data.getString("is_confirm"))) {
if (StrUtil.equals(instruction.getInstruction_type(), InstTypeEnum.AGV_TWO3_TASK.getCode()) ||
StrUtil.equals(instruction.getInstruction_type(), InstTypeEnum.AGV_THREE_TASK.getCode())) {
this.continueTask();
} else if (StrUtil.equals(instruction.getInstruction_type(), InstTypeEnum.CTU_OUT_TASK.getCode())) {
this.boxApplyPass(ApplyPassEnum.PUT_PASS.getCode()); this.boxApplyPass(ApplyPassEnum.PUT_PASS.getCode());
this.reqTakeRequireSuccess = true; }
this.reqTakeInstCode = null;
} }
} }
} }
@@ -179,6 +191,17 @@ public class StandardWeightSiteDeviceDriver extends AbstractOpcDeviceDriver impl
} }
} }
private void continueTask() {
ContinueTaskReq req = ContinueTaskReq.builder()
.taskCode(this.reqTakeInstCode)
.build();
UnifiedResponse unifiedResponse = acsToHkService.continueTask(req);
if (unifiedResponse.isSuccess()) {
this.reqTakeRequireSuccess = false;
this.reqTakeInstCode = null;
}
}
@Override @Override
public JSONObject getDeviceStatusName() { public JSONObject getDeviceStatusName() {

View File

@@ -8,6 +8,7 @@ import com.alibaba.fastjson.JSONObject;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.nl.acs.device.domain.Device; import org.nl.acs.device.domain.Device;
import org.nl.acs.device_driver.conveyor.standard_ordinary_site.StandardOrdinarySiteDeviceDriver;
import org.nl.acs.device_driver.conveyor.standard_weight.StandardWeightSiteDeviceDriver; import org.nl.acs.device_driver.conveyor.standard_weight.StandardWeightSiteDeviceDriver;
import org.nl.acs.ext.hk.service.AcsToHkService; import org.nl.acs.ext.hk.service.AcsToHkService;
import org.nl.acs.ext.hk.service.HkToAcsService; import org.nl.acs.ext.hk.service.HkToAcsService;
@@ -55,7 +56,7 @@ public class HkToAcsServiceImpl implements HkToAcsService {
public JSONObject agvCallback(JSONObject requestParam) { public JSONObject agvCallback(JSONObject requestParam) {
JSONObject resp = new JSONObject(); JSONObject resp = new JSONObject();
String reqCode = requestParam.getString("reqCode"); String reqCode = requestParam.getString("reqCode");
String stgBinCode = requestParam.getString("stgBinCode"); String currentPositionCode = requestParam.getString("currentPositionCode");
String robotCode = requestParam.getString("robotCode"); String robotCode = requestParam.getString("robotCode");
String taskCode = requestParam.getString("taskCode"); String taskCode = requestParam.getString("taskCode");
String method = requestParam.getString("method"); String method = requestParam.getString("method");
@@ -66,10 +67,10 @@ public class HkToAcsServiceImpl implements HkToAcsService {
resp.put("reqCode", reqCode); resp.put("reqCode", reqCode);
return resp; return resp;
} }
StorageCellDto storageCellDto = storageCellService.getByParentCode(stgBinCode); StorageCellDto storageCellDto = storageCellService.getByParentCode(currentPositionCode);
if (ObjectUtil.isEmpty(storageCellDto)) { if (ObjectUtil.isEmpty(storageCellDto)) {
resp.put("code", "1"); resp.put("code", "1");
resp.put("message", "请求失败,外部系统编码不存在,外部系编码:" + stgBinCode); resp.put("message", "请求失败,外部系统编码不存在,外部系编码:" + currentPositionCode);
resp.put("reqCode", reqCode); resp.put("reqCode", reqCode);
return resp; return resp;
} }
@@ -113,7 +114,7 @@ public class HkToAcsServiceImpl implements HkToAcsService {
instruction.setUpdate_time(now); instruction.setUpdate_time(now);
instructionService.update(instruction); instructionService.update(instruction);
} }
//method 回调4、取料箱申请inApply //method 回调4、取料箱申请apply
else if (StrUtil.equals(method, "inApply")) { else if (StrUtil.equals(method, "inApply")) {
Device device = deviceAppService.findDeviceByCode(storageCellDto.getStorage_code()); Device device = deviceAppService.findDeviceByCode(storageCellDto.getStorage_code());
if (ObjectUtil.isEmpty(device)) { if (ObjectUtil.isEmpty(device)) {
@@ -123,6 +124,7 @@ public class HkToAcsServiceImpl implements HkToAcsService {
return resp; return resp;
} }
StandardWeightSiteDeviceDriver standardWeightSiteDeviceDriver; StandardWeightSiteDeviceDriver standardWeightSiteDeviceDriver;
StandardOrdinarySiteDeviceDriver standardOrdinarySiteDeviceDriver;
//CTU取货申请 //CTU取货申请
//如果请求位置编号与指令起点一致并且是输送线则是取货申请 //如果请求位置编号与指令起点一致并且是输送线则是取货申请
if (device.getDeviceDriver() instanceof StandardWeightSiteDeviceDriver) { if (device.getDeviceDriver() instanceof StandardWeightSiteDeviceDriver) {
@@ -130,9 +132,14 @@ public class HkToAcsServiceImpl implements HkToAcsService {
standardWeightSiteDeviceDriver.setReqTakeRequireSuccess(true); standardWeightSiteDeviceDriver.setReqTakeRequireSuccess(true);
standardWeightSiteDeviceDriver.setReqTakeInstCode(taskCode); standardWeightSiteDeviceDriver.setReqTakeInstCode(taskCode);
} }
// else if (device.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) {
// standardOrdinarySiteDeviceDriver = (StandardOrdinarySiteDeviceDriver) device.getDeviceDriver();
// standardOrdinarySiteDeviceDriver.setReqTakeInstCode(taskCode);
// standardOrdinarySiteDeviceDriver.setReqTakeRequireSuccess(true);
// }
} }
//method 回调5、取料箱申请inApply //method 回调5、inApplyOk
else if (StrUtil.equals(method, "inApplyOk")) { // else if (StrUtil.equals(method, "inApplyOk")) {
// Device device = deviceAppService.findDeviceByCode(storageCellDto.getStorage_code()); // Device device = deviceAppService.findDeviceByCode(storageCellDto.getStorage_code());
// if (ObjectUtil.isEmpty(device)) { // if (ObjectUtil.isEmpty(device)) {
// resp.put("code", "1"); // resp.put("code", "1");
@@ -140,7 +147,7 @@ public class HkToAcsServiceImpl implements HkToAcsService {
// resp.put("reqCode", reqCode); // resp.put("reqCode", reqCode);
// return resp; // return resp;
// } // }
} // }
//method 回调6、放料箱申请outApply //method 回调6、放料箱申请outApply
else if (StrUtil.equals(method, "outApply")) { else if (StrUtil.equals(method, "outApply")) {
Device device = deviceAppService.findDeviceByCode(storageCellDto.getStorage_code()); Device device = deviceAppService.findDeviceByCode(storageCellDto.getStorage_code());
@@ -151,6 +158,8 @@ public class HkToAcsServiceImpl implements HkToAcsService {
return resp; return resp;
} }
StandardWeightSiteDeviceDriver standardWeightSiteDeviceDriver; StandardWeightSiteDeviceDriver standardWeightSiteDeviceDriver;
StandardOrdinarySiteDeviceDriver standardOrdinarySiteDeviceDriver;
//CTU取货申请 //CTU取货申请
//如果请求位置编号与指令起点一致并且是输送线则是取货申请 //如果请求位置编号与指令起点一致并且是输送线则是取货申请
if (device.getDeviceDriver() instanceof StandardWeightSiteDeviceDriver) { if (device.getDeviceDriver() instanceof StandardWeightSiteDeviceDriver) {
@@ -158,6 +167,11 @@ public class HkToAcsServiceImpl implements HkToAcsService {
standardWeightSiteDeviceDriver.setReqTakeRequireSuccess(true); standardWeightSiteDeviceDriver.setReqTakeRequireSuccess(true);
standardWeightSiteDeviceDriver.setReqTakeInstCode(taskCode); standardWeightSiteDeviceDriver.setReqTakeInstCode(taskCode);
} }
// else if (device.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) {
// standardOrdinarySiteDeviceDriver = (StandardOrdinarySiteDeviceDriver) device.getDeviceDriver();
// standardOrdinarySiteDeviceDriver.setReqTakeInstCode(taskCode);
// standardOrdinarySiteDeviceDriver.setReqTakeRequireSuccess(true);
// }
} }
resp.put("code", "0"); resp.put("code", "0");
resp.put("message", "成功"); resp.put("message", "成功");

View File

@@ -254,12 +254,12 @@ public class WmsToAcsServiceImpl implements WmsToAcsService {
if (ConfirmEnum.GET_CONFIRM.getCode().equals(type)) { if (ConfirmEnum.GET_CONFIRM.getCode().equals(type)) {
Map<String, Object> nextPositionCode = null; Map<String, Object> nextPositionCode = null;
if (StrUtil.equals(inst.getInstruction_type(), InstTypeEnum.AGV_THREE_TASK.getCode())) { if (StrUtil.equals(inst.getInstruction_type(), InstTypeEnum.AGV_THREE_TASK.getCode())) {
MapOf.of("positionCode", inst.getStart_parent_code(), "type", "00"); nextPositionCode = MapOf.of("positionCode", inst.getStart_parent_code(), "type", "00");
} }
//调用AGV继续执行任务接口,如果是两点任务不需要下一站点信息,如果是三点任务,需要下一站点信息 //调用AGV继续执行任务接口,如果是两点任务不需要下一站点信息,如果是三点任务,需要下一站点信息
ContinueTaskReq req = ContinueTaskReq.builder() ContinueTaskReq req = ContinueTaskReq.builder()
.taskCode(task_code) .taskCode(inst.getInstruction_code())
.nextPositionCode(nextPositionCode) //.nextPositionCode(nextPositionCode)
.build(); .build();
UnifiedResponse unifiedResponse = acsToHkService.continueTask(req); UnifiedResponse unifiedResponse = acsToHkService.continueTask(req);
if (!unifiedResponse.isSuccess()) { if (!unifiedResponse.isSuccess()) {
@@ -270,8 +270,8 @@ public class WmsToAcsServiceImpl implements WmsToAcsService {
else if (ConfirmEnum.PUT_CONFIRM.getCode().equals(type)) { else if (ConfirmEnum.PUT_CONFIRM.getCode().equals(type)) {
//调用AGV继续执行任务接口,需要下一站点信息 //调用AGV继续执行任务接口,需要下一站点信息
ContinueTaskReq req = ContinueTaskReq.builder() ContinueTaskReq req = ContinueTaskReq.builder()
.taskCode(task_code) .taskCode(inst.getInstruction_code())
.nextPositionCode(MapOf.of("positionCode", inst.getNext_parent_code(), "type", "00")) // .nextPositionCode(MapOf.of("positionCode", inst.getNext_parent_code(), "type", "00"))
.build(); .build();
UnifiedResponse unifiedResponse = acsToHkService.continueTask(req); UnifiedResponse unifiedResponse = acsToHkService.continueTask(req);
if (!unifiedResponse.isSuccess()) { if (!unifiedResponse.isSuccess()) {

View File

@@ -15,9 +15,11 @@ public enum InstTypeEnum {
CTU_IN_TASK("1", "1", "CTU入库任务"), CTU_IN_TASK("1", "1", "CTU入库任务"),
CTU_OUT_TASK("2", "2", "CTU出库任务"), CTU_OUT_TASK("2", "2", "CTU出库任务"),
CTU_MOVE_TASK("3", "3", "CTU移库任务"), CTU_MOVE_TASK("3", "3", "CTU移库任务"),
AGV_TWO_TASK("4", "4", "AGV两点任务"), AGV_TWO_TASK("A012", "A012", "AGV两点任务(称重位到库外站点)"),
AGV_THREE_TASK("5", "5", "AGV点任务"), AGV_TWO2_TASK("A021", "A021", "AGV点任务(库外站点到库外站点)"),
OTHER_TASK("6", "6", "其他任务类型"); AGV_TWO3_TASK("A013", "A013", "AGV两点任务(库外站点到称重位)"),
AGV_THREE_TASK("A011", "A011", "AGV三点任务(称重位到库外站点到称重位)"),
OTHER_TASK("8", "9", "其他任务类型");
/** /**

View File

@@ -19,6 +19,8 @@ import org.nl.acs.auto.initial.ApplicationAutoInitial;
import org.nl.acs.common.base.CommonFinalParam; import org.nl.acs.common.base.CommonFinalParam;
import org.nl.acs.device.domain.Device; import org.nl.acs.device.domain.Device;
import org.nl.acs.device_driver.DeviceDriverDefination; import org.nl.acs.device_driver.DeviceDriverDefination;
import org.nl.acs.device_driver.conveyor.standard_ordinary_site.StandardOrdinarySiteDeviceDriver;
import org.nl.acs.device_driver.conveyor.standard_weight.StandardWeightSiteDeviceDriver;
import org.nl.acs.ext.wms.service.AcsToWmsService; import org.nl.acs.ext.wms.service.AcsToWmsService;
import org.nl.acs.instruction.domain.Instruction; import org.nl.acs.instruction.domain.Instruction;
import org.nl.acs.instruction.enums.InstTypeEnum; import org.nl.acs.instruction.enums.InstTypeEnum;
@@ -472,7 +474,23 @@ public class TaskServiceImpl extends CommonServiceImpl<TaskMapper, Task> impleme
throw new BadRequestException("CTU任务类型与起点终点不匹配"); throw new BadRequestException("CTU任务类型与起点终点不匹配");
} }
} else if (StrUtil.equals(TaskTypeEnum.AGV_TASK.getCode(), task_type)) { } else if (StrUtil.equals(TaskTypeEnum.AGV_TASK.getCode(), task_type)) {
instruction_type = "1".equals(acsTask.getIs_wait()) ? InstTypeEnum.AGV_THREE_TASK.getCode() : InstTypeEnum.AGV_TWO_TASK.getCode(); Device start_device = deviceAppService.findDeviceByCode(start_device_code);
Device next_device = deviceAppService.findDeviceByCode(next_device_code);
if (start_device != null && next_device != null) {
if ("1".equals(acsTask.getIs_wait())) {
instruction_type = InstTypeEnum.AGV_THREE_TASK.getCode();
} else if (start_device.getDeviceDriver() instanceof StandardWeightSiteDeviceDriver
&& next_device.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver){
instruction_type = InstTypeEnum.AGV_TWO_TASK.getCode();
} else if (start_device.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver
&& next_device.getDeviceDriver() instanceof StandardWeightSiteDeviceDriver){
instruction_type = InstTypeEnum.AGV_TWO3_TASK.getCode();
} else if (start_device.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver
&& next_device.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver){
instruction_type = InstTypeEnum.AGV_TWO2_TASK.getCode();
}
}
// instruction_type = "1".equals(acsTask.getIs_wait()) ? InstTypeEnum.AGV_THREE_TASK.getCode() : InstTypeEnum.AGV_TWO_TASK.getCode();
} }
if (StrUtil.equals(instruction_type, InstTypeEnum.CTU_OUT_TASK.getCode())) { if (StrUtil.equals(instruction_type, InstTypeEnum.CTU_OUT_TASK.getCode())) {

View File

@@ -7,6 +7,8 @@ import cn.hutool.core.util.StrUtil;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.ObjectUtils; import org.apache.commons.lang3.ObjectUtils;
import org.nl.acs.device.domain.Device; import org.nl.acs.device.domain.Device;
import org.nl.acs.device_driver.conveyor.standard_ordinary_site.StandardOrdinarySiteDeviceDriver;
import org.nl.acs.device_driver.conveyor.standard_weight.StandardWeightSiteDeviceDriver;
import org.nl.acs.instruction.enums.InstTypeEnum; import org.nl.acs.instruction.enums.InstTypeEnum;
import org.nl.acs.instruction.enums.InstructionStatusEnum; import org.nl.acs.instruction.enums.InstructionStatusEnum;
import org.nl.acs.instruction.service.InstructionService; import org.nl.acs.instruction.service.InstructionService;
@@ -381,8 +383,28 @@ public class AutoCreateInst {
next_point_code = next_device_code; next_point_code = next_device_code;
} }
Device start_device = deviceAppService.findDeviceByCode(start_device_code);
Device next_device = deviceAppService.findDeviceByCode(next_device_code);
String inst_type = InstTypeEnum.AGV_TWO_TASK.getCode();
if (start_device != null && next_device != null) {
if ("1".equals(is_wait)) {
inst_type = InstTypeEnum.AGV_THREE_TASK.getCode();
} else if (start_device.getDeviceDriver() instanceof StandardWeightSiteDeviceDriver
&& next_device.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver){
inst_type = InstTypeEnum.AGV_TWO_TASK.getCode();
} else if (start_device.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver
&& next_device.getDeviceDriver() instanceof StandardWeightSiteDeviceDriver){
inst_type = InstTypeEnum.AGV_TWO3_TASK.getCode();
} else if (start_device.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver
&& next_device.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver){
inst_type = InstTypeEnum.AGV_TWO2_TASK.getCode();
}
} else {
return;
}
Instruction instdto = new Instruction(); Instruction instdto = new Instruction();
instdto.setInstruction_type("1".equals(is_wait) ? InstTypeEnum.AGV_THREE_TASK.getIndex() : InstTypeEnum.AGV_TWO_TASK.getIndex()); instdto.setInstruction_type(inst_type);
instdto.setInstruction_id(IdUtil.simpleUUID()); instdto.setInstruction_id(IdUtil.simpleUUID());
instdto.setRemark(acsTask.getRemark()); instdto.setRemark(acsTask.getRemark());
instdto.setTask_id(taskId); instdto.setTask_id(taskId);