diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/indoor_manipulator/IndoorManipulatorDeviceDriver.java b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/indoor_manipulator/IndoorManipulatorDeviceDriver.java index ad89dd0c2..8617f3bec 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/indoor_manipulator/IndoorManipulatorDeviceDriver.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/indoor_manipulator/IndoorManipulatorDeviceDriver.java @@ -801,7 +801,8 @@ public class IndoorManipulatorDeviceDriver extends AbstractOpcDeviceDriver imple jo.put("task", task); jo.put("walk_y", String.valueOf(this.walk_y)); jo.put("isOnline", this.getIsonline()); - jo.put("error", this.getError()); + jo.put("error", StrUtil.isNotEmpty(ErrorUtil.getDictDetail("nbjhj_error_type", String.valueOf(this.getError()))) + ?ErrorUtil.getDictDetail("nbjhj_error_type", String.valueOf(this.getError())):this.getError()); jo.put("isError", this.getIserror()); jo.put("message", this.getMessage()); jo.put("is_click", true); diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/rgv/RgvDeviceDriver.java b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/rgv/RgvDeviceDriver.java index 7d96453aa..60dbc51f1 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/rgv/RgvDeviceDriver.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/rgv/RgvDeviceDriver.java @@ -311,6 +311,8 @@ public class RgvDeviceDriver extends AbstractOpcDeviceDriver implements DeviceDr mode = "单机"; } else if (this.getMode() == 2) { mode = "联机"; + } else if (this.getMode() == 3 && this.move2 == 1) { + mode = "等待人工吊卷"; } else if (this.getMode() == 3) { mode = "运行中"; } else if (this.getMode() == 4) { @@ -318,14 +320,14 @@ public class RgvDeviceDriver extends AbstractOpcDeviceDriver implements DeviceDr } if (this.getMove1() == 0 && this.getMove2() == 0) { - move1 = "无货"; + move1 = "吊卷位"; move2 = "无货"; jo.put("hasGoods", false); } else if (this.getMove1() == 1 || this.getMove2() == 1) { if(this.getMove1() == 1){ - move1 = "有货"; + move1 = "下卷位"; }else if(this.getMove1() == 0){ - move1 = "无货"; + move2 = "吊卷位"; } if(this.getMove2() == 1){ move2 = "有货"; diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/siemens_conveyor/SiemensConveyorDeviceDriver.java b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/siemens_conveyor/SiemensConveyorDeviceDriver.java index 68fb0a3e7..ed2173932 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/siemens_conveyor/SiemensConveyorDeviceDriver.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/siemens_conveyor/SiemensConveyorDeviceDriver.java @@ -243,6 +243,7 @@ public class SiemensConveyorDeviceDriver extends AbstractOpcDeviceDriver impleme // acsToWmsService.sendDeviceStatus(param); sendDeviceStatus(param); } + message = ""; logServer.deviceExecuteLog(this.device_code, "", "", "信号mode:" + last_mode + "->" + mode + "复位请求标记:" + requireSucess); logServer.deviceExecuteLog(this.device_code, "", "", "信号mode:" + last_mode + "->" + mode); } @@ -358,7 +359,6 @@ public class SiemensConveyorDeviceDriver extends AbstractOpcDeviceDriver impleme Instruction instruction = null; List toInstructions; if(mode > 0) { - message = ""; switch (mode) { case 1: log.debug("设备运转模式:等待工作"); @@ -1070,18 +1070,20 @@ public class SiemensConveyorDeviceDriver extends AbstractOpcDeviceDriver impleme apply.put("device_code", device_code); apply.put("type", "2"); String str = acsToWmsService.applyTaskToWms(apply); - logServer.deviceExecuteLog(this.device_code, "", "", "申请空盘入库,请求参数:" + apply); - message = "申请空盘入库任务,请求参数:" + apply; + logServer.deviceExecuteLog(this.device_code, "", "", "申请空盘入库,请求参数:" + apply + ",响应参数:" + JSON.toJSONString(str)); + message = "申请空盘入库任务,请求参数:" + apply + "响应参数: "+ str; JSONObject jo = JSON.parseObject(str); if (ObjectUtil.isEmpty(jo)) { message = "申请空盘入库接口不通"; + logServer.deviceExecuteLog(this.device_code, "", "", "申请空盘入库接口不通"); } else { if (jo.getInteger("status") == 200) { message = "申请空盘入库成功"; requireEmptyInSuccess = true; } else { message = "申请空盘入库失败," + jo.get("message").toString(); + logServer.deviceExecuteLog(this.device_code, "", "", message); } } } diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/slit_two_manipulator/SlitTwoManipulatorDeviceDriver.java b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/slit_two_manipulator/SlitTwoManipulatorDeviceDriver.java index 2b05d4067..0f318ce3e 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/slit_two_manipulator/SlitTwoManipulatorDeviceDriver.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/slit_two_manipulator/SlitTwoManipulatorDeviceDriver.java @@ -287,8 +287,8 @@ public class SlitTwoManipulatorDeviceDriver extends AbstractOpcDeviceDriver impl param.put("product_area", paramService.findByCode("productArea").getValue()); acsToWmsService.sendDeviceStatus(param); - /*logServer.deviceItemValue(this.device_code, "error", String.valueOf(error)); - logServer.deviceExecuteLog(this.device_code, "", "", "信号error:" + last_error + "->" + error);*/ + logServer.deviceItemValue(this.device_code, "error", String.valueOf(error)); + logServer.deviceExecuteLog(this.device_code, "", "", "信号error:" + last_error + "->" + error); } if (status != last_status) { logServer.deviceItemValue(this.device_code, "status", String.valueOf(status)); diff --git a/acs/nladmin-ui/src/views/system/monitor/device/index.vue b/acs/nladmin-ui/src/views/system/monitor/device/index.vue index 0aa5a9538..e5a383c6d 100644 --- a/acs/nladmin-ui/src/views/system/monitor/device/index.vue +++ b/acs/nladmin-ui/src/views/system/monitor/device/index.vue @@ -675,10 +675,10 @@ export default { const obj = { name: '重量2', value: data[val] } this.arr.push(obj) } else if (val === 'move1') { - const obj = { name: '光电信号1', value: data[val] } + const obj = { name: '设备工位', value: data[val] } this.arr.push(obj) } else if (val === 'move2') { - const obj = { name: '光电信号2', value: data[val] } + const obj = { name: '设备有无货', value: data[val] } this.arr.push(obj) } else if (val === 'material1') { const obj = { name: '物料1', value: this.dict.label.material[data[val]] } diff --git a/acs2/nladmin-system/logPath_IS_UNDEFINED/ACS请求LMS/2024-03-15.0.log b/acs2/nladmin-system/logPath_IS_UNDEFINED/ACS请求LMS/2024-03-15.0.log deleted file mode 100644 index e69de29bb..000000000 diff --git a/acs2/nladmin-system/logPath_IS_UNDEFINED/ACS请求LMS/2024-03-18.0.log b/acs2/nladmin-system/logPath_IS_UNDEFINED/ACS请求LMS/2024-03-18.0.log deleted file mode 100644 index e69de29bb..000000000 diff --git a/acs2/nladmin-system/logPath_IS_UNDEFINED/ACS请求LMS/2024-03-20.0.log b/acs2/nladmin-system/logPath_IS_UNDEFINED/ACS请求LMS/2024-03-20.0.log deleted file mode 100644 index e69de29bb..000000000 diff --git a/acs2/nladmin-system/logPath_IS_UNDEFINED/LMS下发ACS/2024-03-15.0.log b/acs2/nladmin-system/logPath_IS_UNDEFINED/LMS下发ACS/2024-03-15.0.log deleted file mode 100644 index e69de29bb..000000000 diff --git a/acs2/nladmin-system/logPath_IS_UNDEFINED/LMS下发ACS/2024-03-18.0.log b/acs2/nladmin-system/logPath_IS_UNDEFINED/LMS下发ACS/2024-03-18.0.log deleted file mode 100644 index e69de29bb..000000000 diff --git a/acs2/nladmin-system/logPath_IS_UNDEFINED/LMS下发ACS/2024-03-20.0.log b/acs2/nladmin-system/logPath_IS_UNDEFINED/LMS下发ACS/2024-03-20.0.log deleted file mode 100644 index e69de29bb..000000000 diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/agv/server/AgvService.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/agv/server/AgvService.java index 4ad0de55d..f45fa6cc5 100644 --- a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/agv/server/AgvService.java +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/agv/server/AgvService.java @@ -1,6 +1,7 @@ package org.nl.acs.agv.server; import org.nl.acs.agv.server.dto.AgvDto; +import org.nl.acs.instruction.domain.InstructionMybatis; import java.util.Map; diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device/service/mapper/DeviceExtraMapper.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device/service/mapper/DeviceExtraMapper.java index e7753a8fb..602fad8fe 100644 --- a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device/service/mapper/DeviceExtraMapper.java +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device/service/mapper/DeviceExtraMapper.java @@ -57,6 +57,6 @@ public interface DeviceExtraMapper extends CommonMapper { * @param extra_code * @return */ - @Select("select * from lzhl_two_acs.acs_device_extra where device_id=#{device_id} and extra_code=#{extra_code} order by create_time desc") + @Select("select * from acs_device_extra where device_id=#{device_id} and extra_code=#{extra_code} order by create_time desc") DeviceExtra findByDeviceId(@Param("device_id") String device_id, @Param("extra_code") String extra_code); } diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/agv/ndctwo/AgvNdcTwoDeviceDriver.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/agv/ndctwo/AgvNdcTwoDeviceDriver.java index 848bfedf6..1993d4627 100644 --- a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/agv/ndctwo/AgvNdcTwoDeviceDriver.java +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/agv/ndctwo/AgvNdcTwoDeviceDriver.java @@ -24,6 +24,9 @@ import org.nl.acs.device_driver.two_conveyor.manipulator_agv_station.Manipulator import org.nl.acs.ext.wms.service.AcsToWmsService; import org.nl.acs.ext.wms.service.impl.AcsToWmsServiceImpl; import org.nl.acs.history.ErrorUtil; +import org.nl.acs.history.service.DeviceErrorLogService; +import org.nl.acs.history.service.dto.DeviceErrorLogDto; +import org.nl.acs.history.service.impl.DeviceErrorLogServiceImpl; import org.nl.acs.instruction.domain.Instruction; import org.nl.acs.instruction.service.InstructionService; import org.nl.acs.instruction.service.impl.InstructionServiceImpl; @@ -57,6 +60,7 @@ public class AgvNdcTwoDeviceDriver extends AbstractDeviceDriver implements Devic NDCAgvService ndcAgvService = SpringContextHolder.getBean(NDCAgvService.class); DeviceExecuteLogService logServer = SpringContextHolder.getBean(DeviceExecuteLogService.class); DeviceAppService deviceAppService = SpringContextHolder.getBean(DeviceAppService.class); + DeviceErrorLogService deviceErrorLogService = SpringContextHolder.getBean(DeviceErrorLogServiceImpl.class); DeviceService deviceService = SpringContextHolder.getBean(DeviceService.class); LuceneExecuteLogService luceneExecuteLogService = SpringContextHolder.getBean(LuceneExecuteLogService.class); TwoAgvPhase twoAgvPhase = new TwoAgvPhase(); @@ -70,6 +74,7 @@ public class AgvNdcTwoDeviceDriver extends AbstractDeviceDriver implements Devic int phase = 0; int region = 0; int error = 0; + int last_error = 0; private Instruction instruction; String message = null; int x = 0; //x坐标 @@ -218,10 +223,27 @@ public class AgvNdcTwoDeviceDriver extends AbstractDeviceDriver implements Devic if (device.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) { standardOrdinarySiteDeviceDriver = (StandardOrdinarySiteDeviceDriver) device.getDeviceDriver(); - data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0); - standardOrdinarySiteDeviceDriver.setAgvphase(phase); - standardOrdinarySiteDeviceDriver.setIndex(index); - standardOrdinarySiteDeviceDriver.setInst(inst); + if (ObjectUtil.isNotEmpty(device.getExtraValue().get("wait")) + && StrUtil.equals("true", device.getExtraValue().get("wait").toString()) + && StrUtil.equals(task.getTask_type(), "1")) { + if (standardOrdinarySiteDeviceDriver.getOption() == 1) { + String task_code = standardOrdinarySiteDeviceDriver.getTask_code(); + log.info("当前任务号{},创建任务号{}", task.getTask_code(), task_code); + if (StrUtil.isEmpty(task_code) || !task_code.equals(task.getTask_code())) { + log.info("等待LMS系统进行确认允许取货,设备号{},指令号{},任务号{}", device_code, ikey, task.getTask_code()); + message = "等待LMS系统进行确认允许取货,设备号:" + device_code + ",指令号:" + ikey; + logServer.deviceExecuteLog(this.device_code, "", "", "等待LMS系统进行确认允许取货,设备号" + device.getDevice_code() + ",指令号" + ikey); + } else { + data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0); + } + }else { + log.info("等待LMS系统进行确认允许取货,设备号{},指令号{}", device_code, ikey); + message = "等待LMS系统进行确认允许取货,设备号:" + device_code + ",指令号:" + ikey; + logServer.deviceExecuteLog(this.device_code, "", "", "等待LMS系统进行确认允许取货,设备号" + device.getDevice_code() + ",指令号" + ikey); + } + }else { + data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0); + } } else if (device.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) { standardInspectSiteDeviceDriver = (StandardInspectSiteDeviceDriver) device.getDeviceDriver(); @@ -340,10 +362,15 @@ public class AgvNdcTwoDeviceDriver extends AbstractDeviceDriver implements Devic if (device.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) { standardOrdinarySiteDeviceDriver = (StandardOrdinarySiteDeviceDriver) device.getDeviceDriver(); - data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0); - standardOrdinarySiteDeviceDriver.setAgvphase(phase); - standardOrdinarySiteDeviceDriver.setIndex(index); - standardOrdinarySiteDeviceDriver.setInst(inst); + if (ObjectUtil.isNotEmpty(this.device.getExtraValue().get("wait")) + && StrUtil.equals("true", this.device.getExtraValue().get("wait").toString()) + && StrUtil.equals(task.getTask_type(), "1")) { + standardOrdinarySiteDeviceDriver.setOption(0); + data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0); + }else { + data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0); + } + this.setPhase(phase); } else if (device.getDeviceDriver() instanceof ManipulatorAgvStationDeviceDriver) { manipulatorAgvStationDeviceDriver = (ManipulatorAgvStationDeviceDriver) device.getDeviceDriver(); @@ -394,7 +421,7 @@ public class AgvNdcTwoDeviceDriver extends AbstractDeviceDriver implements Devic } catch (Exception e) { e.printStackTrace(); } - if ((standardInspectSiteDeviceDriver.getMove() == 1 && standardInspectSiteDeviceDriver.getAction() == 1 && standardInspectSiteDeviceDriver.getError() == 0)) { + if ((standardInspectSiteDeviceDriver.getMove() != 1 && standardInspectSiteDeviceDriver.getAction() == 1 && standardInspectSiteDeviceDriver.getError() == 0)) { data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0); } else { message = "设备号:" + device_code + "光电信号:" + standardInspectSiteDeviceDriver.getMove() + ",动作信号:" + standardInspectSiteDeviceDriver.getAction() + "报警信号:" + standardInspectSiteDeviceDriver.getError() + ",指令号:" + ikey + "不满足取货条件"; @@ -455,10 +482,28 @@ public class AgvNdcTwoDeviceDriver extends AbstractDeviceDriver implements Devic if (StrUtil.equals(agv_inst_type, CommonFinalParam.ONE) || StrUtil.equals(agv_inst_type, "3")) { if (device.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) { standardOrdinarySiteDeviceDriver = (StandardOrdinarySiteDeviceDriver) device.getDeviceDriver(); - data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0); standardOrdinarySiteDeviceDriver.setAgvphase(phase); - standardOrdinarySiteDeviceDriver.setIndex(index); - standardOrdinarySiteDeviceDriver.setInst(inst); + if (ObjectUtil.isNotEmpty(standardOrdinarySiteDeviceDriver.getDevice().getExtraValue().get("wait")) + && StrUtil.equals("true", standardOrdinarySiteDeviceDriver.getDevice().getExtraValue().get("wait").toString())) { + if (standardOrdinarySiteDeviceDriver.getOption() == 1) { + standardOrdinarySiteDeviceDriver.setAgvphase(0); + String task_code = standardOrdinarySiteDeviceDriver.getTask_code(); + log.info("当前任务号{},创建任务号{}", task.getTask_code(), task_code); + if (StrUtil.isEmpty(task_code) || !task_code.equals(task.getTask_code())) { + log.info("等待LMS系统进行确认允许取货,设备号{},指令号{},任务号{}", device_code, ikey, task.getTask_code()); + message = "等待LMS系统进行确认允许取货,设备号:" + device_code + ",指令号:" + ikey; + logServer.deviceExecuteLog(this.device_code, "", "", "等待LMS系统进行确认允许取货,设备号" + device.getDevice_code() + ",指令号" + ikey); + } else { + data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0); + } + } else { + log.info("等待LMS系统进行确认允许取货,设备号{},指令号{}", device_code, ikey); + message = "等待LMS系统进行确认允许取货,设备号:" + device_code + ",指令号:" + ikey; + logServer.deviceExecuteLog(this.device_code, "", "", "等待LMS系统进行确认允许取货,设备号" + device.getDevice_code()); + } + }else { + data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0); + } } else if (device.getDeviceDriver() instanceof ManipulatorAgvStationDeviceDriver) { manipulatorAgvStationDeviceDriver = (ManipulatorAgvStationDeviceDriver) device.getDeviceDriver(); @@ -568,6 +613,12 @@ public class AgvNdcTwoDeviceDriver extends AbstractDeviceDriver implements Devic if (StrUtil.equals(agv_inst_type, CommonFinalParam.ONE) || StrUtil.equals(agv_inst_type, "3")) { if (device.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) { standardOrdinarySiteDeviceDriver = (StandardOrdinarySiteDeviceDriver) device.getDeviceDriver(); + if (ObjectUtil.isNotEmpty(standardOrdinarySiteDeviceDriver.getDevice().getExtraValue().get("wait")) + && StrUtil.equals("true", standardOrdinarySiteDeviceDriver.getDevice().getExtraValue().get("wait").toString())) { + standardOrdinarySiteDeviceDriver.setOption(0); + }else { + data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0); + } data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0); standardOrdinarySiteDeviceDriver.setAgvphase(phase); standardOrdinarySiteDeviceDriver.setIndex(index); @@ -651,6 +702,14 @@ public class AgvNdcTwoDeviceDriver extends AbstractDeviceDriver implements Devic weight = agvaddr; inst.setWeight(String.valueOf(weight)); instructionService.update(inst); + + if (ObjectUtil.isNotEmpty(task)) { + logServer.deviceExecuteLog(this.device_code, "", "", "上报满卷重量,weight:" + weight); + message = "上报满卷重量,weight:" + weight + ",指令号:" + ikey; + task.setWeight(String.valueOf(weight)); + task.setCarno(this.device_code); + taskService.update(task); + } data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0); LuceneLogDto logDto = LuceneLogDto.builder() .device_code(device_code) @@ -817,9 +876,7 @@ public class AgvNdcTwoDeviceDriver extends AbstractDeviceDriver implements Devic // data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0); // } data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0); - standardOrdinarySiteDeviceDriver.setAgvphase(phase); - standardOrdinarySiteDeviceDriver.setIndex(index); - standardOrdinarySiteDeviceDriver.setInst(inst); + this.setPhase(phase); } else if (device.getDeviceDriver() instanceof ManipulatorAgvStationDeviceDriver) { manipulatorAgvStationDeviceDriver = (ManipulatorAgvStationDeviceDriver) device.getDeviceDriver(); @@ -929,9 +986,7 @@ public class AgvNdcTwoDeviceDriver extends AbstractDeviceDriver implements Devic // data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0); // } data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0); - standardOrdinarySiteDeviceDriver.setAgvphase(phase); - standardOrdinarySiteDeviceDriver.setIndex(index); - standardOrdinarySiteDeviceDriver.setInst(inst); + this.setPhase(phase); } else if (device.getDeviceDriver() instanceof ManipulatorAgvStationDeviceDriver) { manipulatorAgvStationDeviceDriver = (ManipulatorAgvStationDeviceDriver) device.getDeviceDriver(); @@ -1037,9 +1092,7 @@ public class AgvNdcTwoDeviceDriver extends AbstractDeviceDriver implements Devic // data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0); // } data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0); - standardOrdinarySiteDeviceDriver.setAgvphase(phase); - standardOrdinarySiteDeviceDriver.setIndex(index); - standardOrdinarySiteDeviceDriver.setInst(inst); + this.setPhase(phase); } else if (device.getDeviceDriver() instanceof ManipulatorAgvStationDeviceDriver) { manipulatorAgvStationDeviceDriver = (ManipulatorAgvStationDeviceDriver) device.getDeviceDriver(); @@ -1130,32 +1183,10 @@ public class AgvNdcTwoDeviceDriver extends AbstractDeviceDriver implements Devic last_status = status; } //进入区域(phase值) else if (phase == 0x50) { - if (ObjectUtil.isEmpty(inst)) { - log.info("未找到指令号{}对应的指令", ikey); - return; - } - region = agvaddr; - data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0); - LuceneLogDto logDto = LuceneLogDto.builder() - .device_code(device_code) - .content("agvphase:" + phase + "反馈:" + data) - .build(); - luceneExecuteLogService.deviceExecuteLog(logDto); } //离开区域(phase值) else if (phase == 0x51) { - if (ObjectUtil.isEmpty(inst)) { - log.info("未找到指令号{}对应的指令", ikey); - return; - } - region = agvaddr; - data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0); - LuceneLogDto logDto = LuceneLogDto.builder() - .device_code(device_code) - .content("agvphase:" + phase + "反馈:" + data) - .build(); - luceneExecuteLogService.deviceExecuteLog(logDto); } //上报异常信息 @@ -1170,11 +1201,23 @@ public class AgvNdcTwoDeviceDriver extends AbstractDeviceDriver implements Devic String info = error.get("info"); this.setErrorInfo(ikey, code, info); } - LuceneLogDto logDto = LuceneLogDto.builder() - .device_code(device_code) - .content("agvphase:" + phase + "反馈:" + data) - .build(); - luceneExecuteLogService.deviceExecuteLog(logDto); + if (error != last_error) { + DeviceErrorLogDto dto = new DeviceErrorLogDto(); + dto.setDevice_code(this.getDevice().getDevice_code()); + dto.setError_code(String.valueOf(error_code)); + dto.setError_info(error_message); + deviceErrorLogService.create(dto); + + JSONObject param = new JSONObject(); + param.put("device_code", this.device_code); + param.put("error", error); + param.put("error_msg", error == 0 ? "" : this.getError_message()); + param.put("device_name", this.getDevice().getDevice_name()); + param.put("device_type", "4"); + param.put("product_area", ISysParamService.findByCode("productArea").getValue()); + acsToWmsService.sendDeviceStatus(param); + } + last_error = error; } if (!ObjectUtil.isEmpty(data)) { LuceneLogDto logDto = LuceneLogDto.builder() @@ -1183,11 +1226,14 @@ public class AgvNdcTwoDeviceDriver extends AbstractDeviceDriver implements Devic .build(); luceneExecuteLogService.deviceExecuteLog(logDto); // if (StrUtil.equals(inst.getAgv_system_type(), "2")) { - TwoNDCSocketConnectionAutoRun.write(data); +// TwoNDCSocketConnectionAutoRun.write(data); // } // else if (StrUtil.equals(inst.getAgv_system_type(), "3")) { // TwoNDC2SocketConnectionAutoRun.write(data); // } + if (StrUtil.equals(inst.getAgv_system_type(), "2")) { + TwoNDCSocketConnectionAutoRun.write(data); + } } } diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/box_manipulator_site/BoxManipulatorSiteDeviceDriver.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/box_manipulator_site/BoxManipulatorSiteDeviceDriver.java index a2e21c0bf..2f13780ec 100644 --- a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/box_manipulator_site/BoxManipulatorSiteDeviceDriver.java +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/box_manipulator_site/BoxManipulatorSiteDeviceDriver.java @@ -357,7 +357,7 @@ public class BoxManipulatorSiteDeviceDriver extends AbstractOpcDeviceDriver impl jo.put("isError", this.getIserror()); jo.put("message", LangProcess.msg(message)); jo.put("notCreateTaskMessage", notCreateTaskMessage); - jo.put("notCreateInstMessage", notCreateInstMessage); + jo.put("notCreateInstMessage", LangProcess.msg(notCreateInstMessage)); jo.put("feedMessage", LangProcess.msg(feedMessage)); jo.put("driver_type", "siemens_conveyor"); jo.put("is_click", true); diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/belt_conveyor/BeltConveyorDeviceDriver.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/belt_conveyor/BeltConveyorDeviceDriver.java index ec02a9c3b..dbf493d14 100644 --- a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/belt_conveyor/BeltConveyorDeviceDriver.java +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/belt_conveyor/BeltConveyorDeviceDriver.java @@ -1,5 +1,6 @@ package org.nl.acs.device_driver.conveyor.belt_conveyor; +import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.date.DateUtil; import cn.hutool.core.util.IdUtil; import cn.hutool.core.util.ObjectUtil; @@ -21,6 +22,7 @@ import org.nl.acs.device_driver.DeviceDriver; import org.nl.acs.device_driver.RouteableDeviceDriver; import org.nl.acs.device_driver.driver.AbstractOpcDeviceDriver; import org.nl.acs.device_driver.driver.ExecutableDeviceDriver; +import org.nl.acs.device_driver.one_manipulator.box_package_manipulator.InteractionJsonDTO; import org.nl.acs.enums.AcsToLmsApplyTaskTypeEnum; import org.nl.acs.ext.wms.service.AcsToWmsService; import org.nl.acs.ext.wms.service.impl.AcsToWmsServiceImpl; @@ -79,7 +81,7 @@ public class BeltConveyorDeviceDriver extends AbstractOpcDeviceDriver implements @Autowired DeviceErrorLogService errorLogServer = SpringContextHolder.getBean(DeviceErrorLogServiceImpl.class); - LuceneExecuteLogService luceneExecuteLogService = SpringContextHolder.getBean("luceneExecuteLogServiceImpl"); + LuceneExecuteLogService luceneExecuteLogService = SpringContextHolder.getBean("luceneExecuteLogServiceImpl"); ISysParamService paramService = SpringContextHolder.getBean(ISysParamService.class); @@ -91,47 +93,49 @@ public class BeltConveyorDeviceDriver extends AbstractOpcDeviceDriver implements private Date instruction_apply_time = new Date(); private int instruction_require_time_out = 3000; - /** + String notCreateInstMessage = ""; + + /** * 心跳 */ int heartbeat = 0; int last_heartbeat = 0; - /** + /** * 工作模式 */ int mode = 0; int last_mode = 0; - /** + /** * 光电信号 */ int move = 0; int last_move = 0; - /** + /** * 托盘方向 */ int container_direction = 0; int last_container_direction = 0; - /** + /** * 报警 */ int error = 0; int last_error = 0; - /** + /** * 动作信号 */ int action = 0; int last_action = 0; - /** + /** * 任务号 */ int task = 0; int last_task = 0; - /** + /** * 托盘类型 */ int container_type = 0; int last_container_type = 0; - /** + /** * 纯数字托盘号 */ int container_no = 0; @@ -198,6 +202,8 @@ public class BeltConveyorDeviceDriver extends AbstractOpcDeviceDriver implements String vehicle_code; String inst_message; + String hand_barcode = null; + /** * led点阵屏信息 */ @@ -226,18 +232,17 @@ public class BeltConveyorDeviceDriver extends AbstractOpcDeviceDriver implements container_type = this.itemProtocol.getContainer_type(); error = this.itemProtocol.getError(); task = this.itemProtocol.getTask(); - container_no = this.itemProtocol.getContainer_no(); - material_barcode= this.itemProtocol.getMaterialBarcode(); to_command = this.itemProtocol.getTo_command(); to_target = this.itemProtocol.getTotarget(); to_task = this.itemProtocol.getTo_task(); to_container_no = this.itemProtocol.getContainer_direction(); - to_container_type = this.itemProtocol.getContainer_no(); if (mode != last_mode) { requireSucess = false; - + if(mode == 2){ + clearWrite(); + } } @@ -271,8 +276,28 @@ public class BeltConveyorDeviceDriver extends AbstractOpcDeviceDriver implements break; case 2: //申请任务 - if (move == 1 && !requireSucess && task==0) { + if (move == 1 && !requireSucess) { instruction_require(); + } else { + String remark = ""; + ; + if (mode != 2) { + remark = "universal_remark2"; + } + if (move != 0) { + remark = "universal_remark3"; + } + if (task != 0) { + remark = "universal_remark4"; + if (ObjectUtil.isNotEmpty(this.inst)) { + this.inst = null; + } + } + if (requireSucess) { + remark = "universal_remark5"; + } + this.setNotCreateInstMessage(remark); + //} } break; case 3: @@ -288,6 +313,12 @@ public class BeltConveyorDeviceDriver extends AbstractOpcDeviceDriver implements //申请AGV任务 if (move == 1 && !requireSucess) { applyAgvTask(); + List list1 = new ArrayList(); + Map map = new HashMap(); + map.put("code", "mode"); + map.put("value", 5); + list1.add(map); + this.writing(list1); } break; @@ -313,8 +344,30 @@ public class BeltConveyorDeviceDriver extends AbstractOpcDeviceDriver implements } + public void clearWrite() { + List list = new ArrayList<>(); + Map map = new HashMap<>(); + map.put("code","to_target"); + map.put("value","0"); + list.add(map); + Map map2 = new HashMap<>(); + map2.put("code","to_task"); + map2.put("value","0"); + list.add(map2); + Map map3 = new HashMap<>(); + map3.put("code","to_command"); + map3.put("value","0"); + list.add(map3); + Map map4 = new HashMap<>(); + map4.put("code","to_container_type"); + map4.put("value","0"); + list.add(map4); + this.writing(list); + message=null; + vehicle_code=null; + } public void writing(int command) { @@ -424,8 +477,6 @@ public class BeltConveyorDeviceDriver extends AbstractOpcDeviceDriver implements } - - /** * 申请任务 */ @@ -439,7 +490,7 @@ public class BeltConveyorDeviceDriver extends AbstractOpcDeviceDriver implements this.instruction_require_time = date; //查找有没有对应的指令 Instruction inst = instructionService.findByDeviceCodeFromCache(this.device_code); - if (ObjectUtil.isNotNull(inst) && CommonFinalParam.ONE.equals(inst.getInstruction_type())) { + if (ObjectUtil.isNotNull(inst)) { List routeLineDtos = routeLineService.selectDeviceCodeList(this.device_code); if (routeLineDtos.size() < 1) { return false; @@ -460,22 +511,83 @@ public class BeltConveyorDeviceDriver extends AbstractOpcDeviceDriver implements if (ObjectUtil.isEmpty(inst)) { return false; } + String interactionJson = taskDto.getInteraction_json(); + InteractionJsonDTO interactionJsonDTO = JSON.parseObject(interactionJson, InteractionJsonDTO.class); + String containerType = ""; + if (ObjectUtil.isNotEmpty(interactionJsonDTO)) { + containerType = interactionJsonDTO.getContainerType(); + } List list = new ArrayList(); - writeData(next_addr, list, inst); + writeData(next_addr, list, inst,containerType); // led_message = getLedMessage(inst); requireSucess = true; return true; } else { - //判断是否有相同起点的,任务状态就绪的任务 - TaskDto taskdto = taskserver.findByStartCodeAndReady(device_code); - if (ObjectUtil.isNull(taskdto)) { - return false; + //查看是否存在输送线到对接为的指令 + Instruction byNextDeviceCodeFromCache = instructionService.findByNextDeviceCodeFromCache(this.device_code); + //补码生成堆垛机对接位到货架的指令 + if (StrUtil.isNotEmpty(hand_barcode) && ObjectUtil.isEmpty(byNextDeviceCodeFromCache)) { + TaskDto taskDtoHandCode = taskserver.findByVehicleCodeCodeAndReady(hand_barcode); + if (Objects.nonNull(taskDtoHandCode)) { + String taskid = taskDtoHandCode.getTask_id(); + String taskcode = taskDtoHandCode.getTask_code(); + String priority = taskDtoHandCode.getPriority(); + String start_point_code = taskDtoHandCode.getStart_point_code(); + String start_device_code = ""; + String route_plan_code = taskDtoHandCode.getRoute_plan_code(); + String next_device_code = taskDtoHandCode.getNext_device_code(); + String interactionJson = taskDtoHandCode.getInteraction_json(); + String containerType = ""; + if (StrUtil.isNotEmpty(interactionJson)) { + InteractionJsonDTO interactionJsonDTO = JSON.parseObject(interactionJson, InteractionJsonDTO.class); + containerType = interactionJsonDTO.getContainerType(); + } + List shortPathsList = routeLineService.getShortPathLines(taskDtoHandCode.getStart_device_code(), next_device_code, route_plan_code); + RouteLineDto routeLineDto = shortPathsList.get(0); + String path = routeLineDto.getPath(); + String[] str = path.split("->"); + List pathlist = Arrays.asList(str); + int index = 0; + for (int m = 0; m < pathlist.size(); m++) { + if (pathlist.get(m).equals(start_device_code)) { + index = m + 2; + break; + } + } + start_device_code = pathlist.get(index); + //校验路由关系 + List shortPathsList2 = routeLineService.getShortPathLines(start_device_code, next_device_code, route_plan_code); + if (ObjectUtils.isEmpty(shortPathsList2) || shortPathsList2.size() < 1) { + throw new RuntimeException("路由不通!"); + } + Device nextdevice = deviceAppservice.findDeviceByCode(next_device_code); + String next_point_code; + if (StrUtil.equals(deviceAppservice.findDeviceTypeByCode(next_device_code), "storage")) { + next_point_code = next_device_code + "-" + taskDtoHandCode.getTo_y() + "-" + taskDtoHandCode.getTo_z(); + Instruction instdto = new Instruction(); + packageData(instdto, route_plan_code, taskDtoHandCode, taskid, taskcode, start_device_code, next_device_code, start_point_code, next_point_code, priority, containerType); + try { + instructionService.create(instdto); + } catch (Exception e) { + e.printStackTrace(); + log.error("指令创建失败!,{}", e.getMessage()); + return false; + } + return updateTask(taskDtoHandCode, nextdevice, instdto); + } + } else { + return false; + } } + + //入库异常口为起点的任务 + TaskDto taskdto = taskserver.findByStartCodeAndReady(device_code); if (ObjectUtil.isNotNull(taskdto)) { //判断指令的起点和当前的设备号相同 if (!taskdto.getStart_device_code().equals(device_code)) { return false; } + //判断当前任务号是否存在指令 String taskid = taskdto.getTask_id(); String taskcode = taskdto.getTask_code(); @@ -484,9 +596,13 @@ public class BeltConveyorDeviceDriver extends AbstractOpcDeviceDriver implements String start_device_code = taskdto.getStart_device_code(); String route_plan_code = taskdto.getRoute_plan_code(); String next_device_code = ""; - /** - * 开始平均分配 - */ + String containerType = ""; + String interactionJson = taskdto.getInteraction_json(); + if (StrUtil.isNotEmpty(interactionJson)) { + InteractionJsonDTO interactionJsonDTO = JSON.parseObject(interactionJson, InteractionJsonDTO.class); + containerType = interactionJsonDTO.getContainerType(); + } + String this_coevice_code = taskserver.queryAssignedByDevice(device_code, taskdto.getNext_device_code()); if (StrUtil.isEmpty(this_coevice_code)) { List shortPathsList = routeLineService.getShortPathLines(start_device_code, taskdto.getNext_device_code(), route_plan_code); @@ -521,8 +637,28 @@ public class BeltConveyorDeviceDriver extends AbstractOpcDeviceDriver implements } else { next_point_code = next_device_code; } + //判断是否存在终点到达ddj对接位的指令(包含货架到达ddj对接位的指令、输送线到对接位的指令) + Instruction byNextDeviceCodeDDJ = instructionService.findByNextDeviceCodeFromCache(next_device_code); + if (ObjectUtil.isNotEmpty(byNextDeviceCodeDDJ)) { + this.setNotCreateInstMessage("universal_notCreateInstMessage5"); + return false; + } + //判断下一个输送线点位是否有货 + BeltConveyorDeviceDriver beltConveyorDeviceDriver; + if (nextdevice.getDeviceDriver() instanceof BeltConveyorDeviceDriver) { + beltConveyorDeviceDriver = (BeltConveyorDeviceDriver) nextdevice.getDeviceDriver(); + if (beltConveyorDeviceDriver.getMode() != 2 || beltConveyorDeviceDriver.getMove() == 1) { + log.error("输送机,{}未联机或执行中", next_device_code); + this.setNotCreateInstMessage("universal_notCreateInstMessage4"); + return false; + } + }else { + //下一个设备不是输送线指令 + this.setNotCreateInstMessage("universal_notCreateInstMessage6"); + return false; + } Instruction instdto = new Instruction(); - packageData(instdto, route_plan_code, taskdto, taskid, taskcode, start_device_code, next_device_code, start_point_code, next_point_code, priority); + packageData(instdto, route_plan_code, taskdto, taskid, taskcode, start_device_code, next_device_code, start_point_code, next_point_code, priority, containerType); log.error("=================================,{}", instdto.getCreate_by()); try { instructionService.create(instdto); @@ -531,47 +667,61 @@ public class BeltConveyorDeviceDriver extends AbstractOpcDeviceDriver implements log.error("指令创建失败!,{}", e.getMessage()); return false; } - taskdto.setTask_status(TaskStatusEnum.BUSY.getIndex()); - taskserver.update(taskdto); - requireSucess = true; - String next_addr = nextdevice.getExtraValue().get("address").toString(); - List list = new ArrayList(); - writeData(next_addr, list, instdto); -// led_message = getLedMessage(instdto); - requireSucess = true; - return true; + return updateTask(taskdto, nextdevice, instdto); } + + } return false; } } - private void writeData(String next_addr, List list, Instruction inst) { + private boolean updateTask(TaskDto taskdto, Device nextdevice, Instruction instdto) { + taskdto.setTask_status(TaskStatusEnum.BUSY.getIndex()); + taskserver.update(taskdto); + requireSucess = true; + String next_addr = nextdevice.getExtraValue().get("address").toString(); + String interactionJson = taskdto.getInteraction_json(); + InteractionJsonDTO interactionJsonDTO = JSON.parseObject(interactionJson, InteractionJsonDTO.class); + String containerType = ""; + if (ObjectUtil.isNotEmpty(interactionJsonDTO)) { + containerType = interactionJsonDTO.getContainerType(); + } + List list = new ArrayList(); + writeData(next_addr, list, instdto, containerType); +// led_message = getLedMessage(instdto); + requireSucess = true; + return true; + } + + private void writeData(String next_addr, List list, Instruction inst,String containerType) { + List list1 = new ArrayList(); Map map = new HashMap(); map.put("code", "to_target"); map.put("value", next_addr); - list.add(map); + list1.add(map); + this.writing(list1); + List list2 = new ArrayList(); Map map1 = new HashMap(); map1.put("code", "to_task"); map1.put("value", inst.getInstruction_code()); - list.add(map1); + list2.add(map1); + this.writing(list2); + List list4 = new ArrayList(); + Map map3 = new HashMap(); + map3.put("code", "to_container_type"); + map3.put("value", containerType); + list4.add(map3); + this.writing(list4); + List list3 = new ArrayList(); Map map2 = new HashMap(); map2.put("code", "to_command"); map2.put("value", "1"); - list.add(map2); - Map map3 = new HashMap(); - map3.put("code", "to_container_type"); - map3.put("value", inst.getVehicle_type()); - list.add(map3); - Map map4 = new HashMap(); - map4.put("code", "to_container_no"); - map4.put("value", "1"); - list.add(map4); - - this.writing(list); + list3.add(map2); + this.writing(list3); } - private static void packageData(Instruction instdto, String route_plan_code, TaskDto taskdto, String taskid, String taskcode, String start_device_code, String next_device_code, String start_point_code, String next_point_code, String priority) { + private static void packageData(Instruction instdto, String route_plan_code, TaskDto taskdto, String taskid, String taskcode, String start_device_code, String next_device_code, String start_point_code, String next_point_code, String priority, String containerType) { instdto.setInstruction_id(IdUtil.simpleUUID()); instdto.setRoute_plan_code(route_plan_code); instdto.setRemark(taskdto.getRemark()); @@ -589,6 +739,7 @@ public class BeltConveyorDeviceDriver extends AbstractOpcDeviceDriver implements instdto.setPriority(priority); instdto.setInstruction_status("0"); instdto.setExecute_device_code(start_point_code); + instdto.setVehicle_type(containerType); } public void writeData(String next_addr, Instruction instdto, Map map) { @@ -611,12 +762,12 @@ public class BeltConveyorDeviceDriver extends AbstractOpcDeviceDriver implements itemMap.put(to_param, json.getString("value")); } } - logServer.deviceExecuteLog(device_code, "", "", "下发电气信号:" + itemMap); LuceneLogDto logDto = LuceneLogDto.builder() .device_code(device_code) .content("下发多个电气信号" + itemMap) .build(); luceneExecuteLogService.deviceExecuteLog(logDto); + logServer.deviceExecuteLog(device_code, "", "", "下发电气信号:" + itemMap); try { this.checkcontrol(itemMap); } catch (Exception e) { @@ -670,7 +821,7 @@ public class BeltConveyorDeviceDriver extends AbstractOpcDeviceDriver implements mode = LangProcess.msg("universal_standby"); } else if (this.getMode() == 3) { mode = LangProcess.msg("universal_operation"); - }else if (this.getMode() == 5) { + } else if (this.getMode() == 5) { mode = LangProcess.msg("one_mode3"); } @@ -678,32 +829,29 @@ public class BeltConveyorDeviceDriver extends AbstractOpcDeviceDriver implements jo.put("mode", mode); jo.put("message", LangProcess.msg(message)); jo.put("error", this.getError()); + String move = "无货"; + jo.put("hasGoods", false); + if (this.move == 1) { + move = "有货"; + jo.put("hasGoods", true); + } + String container_type = ""; + if (this.container_type == 1) { + container_type = "小托盘"; + } else if (this.container_type == 2) { + container_type = "大托盘"; + } jo.put("move", move); + jo.put("task", task); + jo.put("type", container_type); jo.put("is_click", true); jo.put("isOnline", this.getIsonline()); jo.put("requireSucess", requireSucess); + jo.put("hand_barcode", hand_barcode); + jo.put("notCreateInstMessage", LangProcess.msg(notCreateInstMessage)); return jo; } -// /** -// * 获取任务信息 -// */ -// public JSONObject getLedMessage(Instruction instdto) { -// JSONObject json = new JSONObject(); -// json.put("task_code", instdto.getTask_code()); -// json.put("inst_code", instdto.getInstruction_code()); -// json.put("start_device_code", instdto.getStart_device_code()); -// json.put("next_device_code", instdto.getNext_device_code()); -// json.put("material_type", instdto.getMaterial()); -// json.put("quantity", instdto.getQuantity()); -// json.put("vehicle_code", instdto.getVehicle_code()); -// json.put("instruction_status", instdto.getInstruction_status()); -// json.put("entry_time", instdto.getCreate_time()); -// String acsIp = paramService.findByCode(AcsConfig.ACSIP).getValue(); -// json.put("ip", acsIp); -// return json; -// } - /** * 更新指令状态 @@ -762,6 +910,8 @@ public class BeltConveyorDeviceDriver extends AbstractOpcDeviceDriver implements } else if (StrUtil.equals(requestSucess, "1")) { this.requireSucess = true; } + String hand_barcode = data.getString("hand_barcode"); + this.setHand_barcode(hand_barcode); } public static boolean arrayEquals(int[] a, int[] b) { @@ -777,4 +927,6 @@ public class BeltConveyorDeviceDriver extends AbstractOpcDeviceDriver implements } return true; } + + } diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/belt_conveyor/ItemProtocol.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/belt_conveyor/ItemProtocol.java index 9077fd383..f5f7081c4 100644 --- a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/belt_conveyor/ItemProtocol.java +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/belt_conveyor/ItemProtocol.java @@ -45,15 +45,6 @@ public class ItemProtocol { * 任务号 */ public static String item_task = "task"; - /** - * 出数字托盘号 - */ - public static String item_container_no = "container_no"; - - /** - * 子卷条码 - */ - public static String item_material_barcode = "material_barcode"; /** * 下发命令 @@ -63,10 +54,6 @@ public class ItemProtocol { * 下发托盘类型 */ public static String item_to_container_type = "to_container_type"; - /** - * 下发接纯数字托盘号 - */ - public static String item_to_container_no = "to_container_no"; /** * 下发任务号 */ @@ -76,11 +63,6 @@ public class ItemProtocol { */ public static String item_to_target = "to_target"; - /** - * 托盘条码 - */ - public static String item_barcode = "barcode"; - @@ -90,9 +72,6 @@ public class ItemProtocol { this.driver = driver; } - public String getMaterialBarcode() { - return this.getOpcStringValue(item_material_barcode); - } public int getHeartbeat() { return this.getOpcIntegerValue(item_heartbeat); } @@ -117,9 +96,6 @@ public class ItemProtocol { return this.getOpcIntegerValue(item_action); } - public int getContainer_no() { - return this.getOpcIntegerValue(item_container_no); - } public int getError() { return this.getOpcIntegerValue(item_error); @@ -133,9 +109,6 @@ public class ItemProtocol { return this.getOpcIntegerValue(item_to_task); } - public String getBarcode() { - return this.getOpcStringValue(item_barcode); - } @@ -151,9 +124,6 @@ public class ItemProtocol { return this.getOpcIntegerValue(item_to_container_type); } - public int getTo_container_no() { - return this.getOpcIntegerValue(item_to_container_no); - } Boolean isonline; @@ -198,12 +168,9 @@ public class ItemProtocol { list.add(new ItemDto(item_move, "光电信号", "DB101.B3")); list.add(new ItemDto(item_container_direction, "托盘方向", "DB101.B4")); list.add(new ItemDto(item_container_type, "托盘类型", "DB101.B5")); - list.add(new ItemDto(item_container_no, "纯数字托盘号", "DB101.D7")); list.add(new ItemDto(item_action, "动作类型", "DB101.B6")); list.add(new ItemDto(item_error, "报警", "DB101.B58")); list.add(new ItemDto(item_task, "任务号", "DB101.D68")); - list.add(new ItemDto(item_material_barcode, "子卷条码", "DB601.STRING1.50")); - list.add(new ItemDto(item_barcode, "托盘条码", "DB602.STRING1.50")); return list; } @@ -212,7 +179,6 @@ public class ItemProtocol { list.add(new ItemDto(item_to_target, "下发仓位号", "DB102.W2")); list.add(new ItemDto(item_to_command, "下发命令", "DB102.W4")); list.add(new ItemDto(item_to_task, "下发任务号", "DB102.D1")); - list.add(new ItemDto(item_to_container_no, "下发接纯数字托盘号", "DB102.D3")); list.add(new ItemDto(item_to_container_type, "下发托盘类型", "DB102.B5")); return list; } diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/siemens_conveyor_ckk/ItemProtocol.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/siemens_conveyor_ckk/ItemProtocol.java index a51764935..885a0eb21 100644 --- a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/siemens_conveyor_ckk/ItemProtocol.java +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/siemens_conveyor_ckk/ItemProtocol.java @@ -64,7 +64,7 @@ public class ItemProtocol { /** *木箱宽度 */ - public static String item_to_weight = "to_weight"; + public static String item_to_weight = "to_width"; /** *木箱高度 */ diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/siemens_conveyor_ckk/SiemensConveyorCkkDeviceDriver.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/siemens_conveyor_ckk/SiemensConveyorCkkDeviceDriver.java index 0b924a987..f3973c62b 100644 --- a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/siemens_conveyor_ckk/SiemensConveyorCkkDeviceDriver.java +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/siemens_conveyor_ckk/SiemensConveyorCkkDeviceDriver.java @@ -39,6 +39,8 @@ import org.nl.acs.task.enums.TaskStatusEnum; import org.nl.acs.task.service.TaskService; import org.nl.acs.task.service.dto.TaskDto; import org.nl.config.language.LangProcess; +import org.nl.config.lucene.service.LuceneExecuteLogService; +import org.nl.config.lucene.service.dto.LuceneLogDto; import org.nl.system.service.param.ISysParamService; import org.nl.config.SpringContextHolder; import org.openscada.opc.lib.da.Server; @@ -77,6 +79,9 @@ public class SiemensConveyorCkkDeviceDriver extends AbstractOpcDeviceDriver impl @Autowired StorageCellMapper storageCellMapper; + LuceneExecuteLogService luceneExecuteLogService = SpringContextHolder.getBean("luceneExecuteLogServiceImpl"); + + /** * 当前指令 */ @@ -561,7 +566,11 @@ public class SiemensConveyorCkkDeviceDriver extends AbstractOpcDeviceDriver impl if (task != Integer.parseInt(inst.getInstruction_code())) { this.writing(list); message = "重新下发电气信号"; - logServer.deviceExecuteLog(device_code, "", "", inst.getInstruction_code() + "再次下发电气信号"); + LuceneLogDto logDto = LuceneLogDto.builder() + .device_code(device_code) + .content(device_code + inst.getInstruction_code() + "再次下发电气信号") + .build(); + luceneExecuteLogService.deviceExecuteLog(logDto); } message = "下发电气任务号成功"; requireSucess = true; @@ -668,7 +677,11 @@ public class SiemensConveyorCkkDeviceDriver extends AbstractOpcDeviceDriver impl if (task != Integer.parseInt(inst.getInstruction_code())) { this.writing(list); message = "重新下发电气信号"; - logServer.deviceExecuteLog(device_code, "", "", inst.getInstruction_code() + "再次下发电气信号"); + LuceneLogDto logDto = LuceneLogDto.builder() + .device_code(device_code) + .content(device_code + inst.getInstruction_code() + "再次下发电气信号") + .build(); + luceneExecuteLogService.deviceExecuteLog(logDto); } } else { //如果不存在则直接找对应指令 @@ -696,7 +709,11 @@ public class SiemensConveyorCkkDeviceDriver extends AbstractOpcDeviceDriver impl this.writing(list); if (task != Integer.parseInt(inst.getInstruction_code())) { this.writing(list); - logServer.deviceExecuteLog(device_code, "", "", inst.getInstruction_code() + "再次下发电气信号"); + LuceneLogDto logDto = LuceneLogDto.builder() + .device_code(device_code) + .content(device_code + inst.getInstruction_code() + "再次下发电气信号") + .build(); + luceneExecuteLogService.deviceExecuteLog(logDto); } requireSucess = true; } diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/siemens_conveyor_labeling/SiemensConveyorLabelingDeviceDriver.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/siemens_conveyor_labeling/SiemensConveyorLabelingDeviceDriver.java index bea6e79d7..910efddda 100644 --- a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/siemens_conveyor_labeling/SiemensConveyorLabelingDeviceDriver.java +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/siemens_conveyor_labeling/SiemensConveyorLabelingDeviceDriver.java @@ -38,6 +38,8 @@ import org.nl.acs.task.service.TaskService; import org.nl.acs.task.service.dto.TaskDto; import org.nl.common.utils.SecurityUtils; import org.nl.config.language.LangProcess; +import org.nl.config.lucene.service.LuceneExecuteLogService; +import org.nl.config.lucene.service.dto.LuceneLogDto; import org.nl.system.service.param.ISysParamService; import org.nl.config.SpringContextHolder; import org.openscada.opc.lib.da.Server; @@ -84,6 +86,9 @@ public class SiemensConveyorLabelingDeviceDriver extends AbstractOpcDeviceDriver @Autowired StorageCellMapper storageCellMapper; + + LuceneExecuteLogService luceneExecuteLogService = SpringContextHolder.getBean("luceneExecuteLogServiceImpl"); + /** * 当前指令 */ @@ -689,7 +694,11 @@ public class SiemensConveyorLabelingDeviceDriver extends AbstractOpcDeviceDriver this.writing(list); if (task != Integer.parseInt(inst.getInstruction_code())) { this.writing(list); - logServer.deviceExecuteLog(device_code, "", "", inst.getInstruction_code() + "再次下发电气信号"); + LuceneLogDto logDto = LuceneLogDto.builder() + .device_code(device_code) + .content(device_code + inst.getInstruction_code() + "再次下发电气信号") + .build(); + luceneExecuteLogService.deviceExecuteLog(logDto); } } else { // 如果不存在则直接找对应指令 @@ -720,7 +729,11 @@ public class SiemensConveyorLabelingDeviceDriver extends AbstractOpcDeviceDriver this.writing(list); if (task != Integer.parseInt(inst.getInstruction_code())) { this.writing(list); - logServer.deviceExecuteLog(device_code, "", "", inst.getInstruction_code() + "再次下发电气信号"); + LuceneLogDto logDto = LuceneLogDto.builder() + .device_code(device_code) + .content(device_code + inst.getInstruction_code() + "再次下发电气信号") + .build(); + luceneExecuteLogService.deviceExecuteLog(logDto); } } return true; diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/standard_ordinary_site/StandardOrdinarySiteDeviceDriver.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/standard_ordinary_site/StandardOrdinarySiteDeviceDriver.java index 88a1e4c00..1e438a7fd 100644 --- a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/standard_ordinary_site/StandardOrdinarySiteDeviceDriver.java +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/standard_ordinary_site/StandardOrdinarySiteDeviceDriver.java @@ -1,6 +1,7 @@ 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 lombok.Data; import lombok.RequiredArgsConstructor; @@ -61,6 +62,9 @@ public class StandardOrdinarySiteDeviceDriver extends AbstractDeviceDriver imple Boolean iserror = false; Boolean islock = false; + // 1 上位系统允许进入 2 上位系统允许离开 + int option = 0; + int branchProtocol = 0; int last_branchProtocol = 0; /** @@ -223,6 +227,14 @@ public class StandardOrdinarySiteDeviceDriver extends AbstractDeviceDriver imple String mode = ""; String action = ""; String move = ""; + String option = ""; + if(this.getOption() == 0){ + option ="禁止进出"; + } else if(this.getOption() == 1){ + option ="允许进入"; + } else if(this.getOption() == 2){ + option ="允许离开"; + } if (this.getMode() == 0) { mode = LangProcess.msg("universal_off-line"); } else if (this.getMode() == 1) { @@ -252,13 +264,18 @@ public class StandardOrdinarySiteDeviceDriver extends AbstractDeviceDriver imple jo.put("isOnline", true); jo.put("error", this.getError()); jo.put("isError", this.getIserror()); + jo.put("option", option); + jo.put("is_click", true); return jo; } @Override public void setDeviceStatus(JSONObject data) { - + String flag = data.getString("option"); + if(StrUtil.isNotEmpty(flag)){ + option = Integer.parseInt(flag); + } } } diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/manipulator/standard_manipulator/BlankManipulatorDeviceDriver.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/manipulator/standard_manipulator/BlankManipulatorDeviceDriver.java index f3b26ae2b..d7ad1df74 100644 --- a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/manipulator/standard_manipulator/BlankManipulatorDeviceDriver.java +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/manipulator/standard_manipulator/BlankManipulatorDeviceDriver.java @@ -346,7 +346,7 @@ // jo.put("isError", this.getIserror()); // jo.put("message", LangProcess.msg(message)); // jo.put("notCreateTaskMessage", notCreateTaskMessage); -// jo.put("notCreateInstMessage", notCreateInstMessage); +// jo.put("notCreateInstMessage", LangProcess.msg(notCreateInstMessage)); // jo.put("feedMessage", LangProcess.msg(feedMessage)); // jo.put("driver_type", "siemens_conveyor"); // jo.put("is_click", true); diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/manipulator/standard_manipulator/DryManipulatorDeviceDriver.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/manipulator/standard_manipulator/DryManipulatorDeviceDriver.java index d18463010..3f92e2a9f 100644 --- a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/manipulator/standard_manipulator/DryManipulatorDeviceDriver.java +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/manipulator/standard_manipulator/DryManipulatorDeviceDriver.java @@ -345,7 +345,7 @@ // jo.put("isError", this.getIserror()); // jo.put("message", LangProcess.msg(message)); // jo.put("notCreateTaskMessage", notCreateTaskMessage); -// jo.put("notCreateInstMessage", notCreateInstMessage); +// jo.put("notCreateInstMessage", LangProcess.msg(notCreateInstMessage)); // jo.put("feedMessage", LangProcess.msg(feedMessage)); // jo.put("driver_type", "siemens_conveyor"); // jo.put("is_click", true); diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/manipulator/standard_manipulator/OvenGantryManipulatorDeviceDriver.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/manipulator/standard_manipulator/OvenGantryManipulatorDeviceDriver.java index 1adf84f54..994fadc57 100644 --- a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/manipulator/standard_manipulator/OvenGantryManipulatorDeviceDriver.java +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/manipulator/standard_manipulator/OvenGantryManipulatorDeviceDriver.java @@ -351,7 +351,7 @@ // jo.put("isError", this.getIserror()); // jo.put("message", LangProcess.msg(message)); // jo.put("notCreateTaskMessage", notCreateTaskMessage); -// jo.put("notCreateInstMessage", notCreateInstMessage); +// jo.put("notCreateInstMessage", LangProcess.msg(notCreateInstMessage)); // jo.put("feedMessage", LangProcess.msg(feedMessage)); // jo.put("driver_type", "siemens_conveyor"); // jo.put("is_click", true); diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_conveyor/box_storage_out_conveyor/BoxStorageOutConveyorDeviceDriver.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_conveyor/box_storage_out_conveyor/BoxStorageOutConveyorDeviceDriver.java index 93ce55e46..61c74d676 100644 --- a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_conveyor/box_storage_out_conveyor/BoxStorageOutConveyorDeviceDriver.java +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_conveyor/box_storage_out_conveyor/BoxStorageOutConveyorDeviceDriver.java @@ -150,6 +150,7 @@ public class BoxStorageOutConveyorDeviceDriver extends AbstractOpcDeviceDriver i boolean requireEmptyInSuccess = false; boolean requiresShipDeviceUpdate = true; private int instruction_finished_time_out; + String notCreateInstMessage = ""; int branchProtocol = 0; String inst_message; @@ -231,6 +232,26 @@ public class BoxStorageOutConveyorDeviceDriver extends AbstractOpcDeviceDriver i //申请任务 if (move > 0 && task == 0 && !requireSucess) { instruction_require(); + }else { + String remark = ""; + ; + if (mode != 2) { + remark = "universal_remark2"; + } + if (move != 0) { + remark = "universal_remark3"; + } + if (task != 0) { + remark = "universal_remark4"; + if (ObjectUtil.isNotEmpty(this.inst)) { + this.inst = null; + } + } + if (requireSucess) { + remark = "universal_remark5"; + } + this.setNotCreateInstMessage(remark); + //} } break; case 4: @@ -391,7 +412,6 @@ public class BoxStorageOutConveyorDeviceDriver extends AbstractOpcDeviceDriver i while (!StrUtil.equals(this.getOpcValueAccessor().getValue(this.getOpcServer() + "." + this.getOpcPlc() + "." + this.getDevice_code() + ".task").toString() , inst.getInstruction_code())) { this.writing(list); - logServer.deviceExecuteLog(device_code, "", "", inst.getInstruction_code() + "再次下发信号"); try { Thread.sleep(500); } catch (InterruptedException e) { @@ -503,7 +523,11 @@ public class BoxStorageOutConveyorDeviceDriver extends AbstractOpcDeviceDriver i while (!StrUtil.equals(this.getOpcValueAccessor().getValue(this.getOpcServer() + "." + this.getOpcPlc() + "." + this.getDevice_code() + ".task").toString() , instdto.getInstruction_code())) { this.writing(list); - logServer.deviceExecuteLog(device_code, "", "", inst.getInstruction_code() + "再次下发电气信号"); + LuceneLogDto logDto = LuceneLogDto.builder() + .device_code(device_code) + .content(device_code + inst.getInstruction_code() + "再次下发电气信号") + .build(); + luceneExecuteLogService.deviceExecuteLog(logDto); try { Thread.sleep(1000); } catch (InterruptedException e) { @@ -542,7 +566,11 @@ public class BoxStorageOutConveyorDeviceDriver extends AbstractOpcDeviceDriver i while (!StrUtil.equals(this.getOpcValueAccessor().getValue(this.getOpcServer() + "." + this.getOpcPlc() + "." + this.getDevice_code() + ".task").toString() , inst.getInstruction_code())) { this.writing(list); - logServer.deviceExecuteLog(device_code, "", "", inst.getInstruction_code() + "再次下发电气信号"); + LuceneLogDto logDto = LuceneLogDto.builder() + .device_code(device_code) + .content(device_code + inst.getInstruction_code() + "再次下发电气信号") + .build(); + luceneExecuteLogService.deviceExecuteLog(logDto); try { Thread.sleep(500); } catch (InterruptedException e) { @@ -613,6 +641,7 @@ public class BoxStorageOutConveyorDeviceDriver extends AbstractOpcDeviceDriver i jo.put("is_click", true); jo.put("requireSucess", requireSucess); jo.put("driver_type", "siemens_conveyor"); + jo.put("notCreateInstMessage", LangProcess.msg(notCreateInstMessage)); return jo; } @@ -652,6 +681,11 @@ public class BoxStorageOutConveyorDeviceDriver extends AbstractOpcDeviceDriver i itemMap.put(to_param, json.getString("value")); } } + LuceneLogDto logDto = LuceneLogDto.builder() + .device_code(device_code) + .content("下发多个电气信号" + itemMap) + .build(); + luceneExecuteLogService.deviceExecuteLog(logDto); logServer.deviceExecuteLog(device_code, "", "", "下发电气信号:" + itemMap); try { this.checkcontrol(itemMap); diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_conveyor/box_subvolumes_conveyor/BoxSubvolumesConveyorDeviceDriver.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_conveyor/box_subvolumes_conveyor/BoxSubvolumesConveyorDeviceDriver.java index 14c415133..51faeb6f0 100644 --- a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_conveyor/box_subvolumes_conveyor/BoxSubvolumesConveyorDeviceDriver.java +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_conveyor/box_subvolumes_conveyor/BoxSubvolumesConveyorDeviceDriver.java @@ -35,6 +35,8 @@ import org.nl.acs.task.service.dto.TaskDto; import org.nl.common.utils.SecurityUtils; import org.nl.config.SpringContextHolder; import org.nl.config.language.LangProcess; +import org.nl.config.lucene.service.LuceneExecuteLogService; +import org.nl.config.lucene.service.dto.LuceneLogDto; import org.nl.config.thread.ThreadPoolExecutorUtil; import org.openscada.opc.lib.da.Server; @@ -71,11 +73,14 @@ public class BoxSubvolumesConveyorDeviceDriver extends AbstractOpcDeviceDriver i NDCAgvService agvService = SpringContextHolder.getBean(NDCAgvService.class); DeviceErrorLogService deviceErrorLogService = SpringContextHolder.getBean(DeviceErrorLogServiceImpl.class); + LuceneExecuteLogService luceneExecuteLogService = SpringContextHolder.getBean("luceneExecuteLogServiceImpl"); //当前指令 Instruction inst = null; private String error_type = "ssx_error_type"; + String notCreateInstMessage = ""; + //工作模式 int mode = 0; int last_mode = 0; @@ -216,6 +221,26 @@ public class BoxSubvolumesConveyorDeviceDriver extends AbstractOpcDeviceDriver i //申请任务 if (move > 0 && !requireSucess) { instruction_require(); + }else { + String remark = ""; + ; + if (mode != 2) { + remark = "universal_remark2"; + } + if (move != 0) { + remark = "universal_remark3"; + } + if (task != 0) { + remark = "universal_remark4"; + if (ObjectUtil.isNotEmpty(this.inst)) { + this.inst = null; + } + } + if (requireSucess) { + remark = "universal_remark5"; + } + this.setNotCreateInstMessage(remark); + //} } break; } @@ -316,6 +341,7 @@ public class BoxSubvolumesConveyorDeviceDriver extends AbstractOpcDeviceDriver i jo.put("is_click", true); jo.put("requireSucess", requireSucess); jo.put("driver_type", "siemens_conveyor"); + jo.put("notCreateInstMessage", LangProcess.msg(notCreateInstMessage)); return jo; } @@ -355,6 +381,11 @@ public class BoxSubvolumesConveyorDeviceDriver extends AbstractOpcDeviceDriver i itemMap.put(to_param, json.getString("value")); } } + LuceneLogDto logDto = LuceneLogDto.builder() + .device_code(device_code) + .content("下发多个电气信号" + itemMap) + .build(); + luceneExecuteLogService.deviceExecuteLog(logDto); logServer.deviceExecuteLog(device_code, "", "", "下发电气信号:" + itemMap); try { this.checkcontrol(itemMap); @@ -400,7 +431,11 @@ public class BoxSubvolumesConveyorDeviceDriver extends AbstractOpcDeviceDriver i while (!StrUtil.equals(this.getOpcValueAccessor().getValue(this.getOpcServer() + "." + this.getOpcPlc() + "." + this.getDevice_code() + ".task").toString() , inst.getInstruction_code())) { this.writing(list); - logServer.deviceExecuteLog(device_code, "", "", inst.getInstruction_code() + "再次下发信号"); + LuceneLogDto logDto = LuceneLogDto.builder() + .device_code(device_code) + .content(device_code + inst.getInstruction_code() + "再次下发电气信号") + .build(); + luceneExecuteLogService.deviceExecuteLog(logDto); try { Thread.sleep(500); } catch (InterruptedException e) { @@ -512,7 +547,11 @@ public class BoxSubvolumesConveyorDeviceDriver extends AbstractOpcDeviceDriver i while (!StrUtil.equals(this.getOpcValueAccessor().getValue(this.getOpcServer() + "." + this.getOpcPlc() + "." + this.getDevice_code() + ".task").toString() , instdto.getInstruction_code())) { this.writing(list); - logServer.deviceExecuteLog(device_code, "", "", inst.getInstruction_code() + "再次下发电气信号"); + LuceneLogDto logDto = LuceneLogDto.builder() + .device_code(device_code) + .content(device_code + inst.getInstruction_code() + "再次下发电气信号") + .build(); + luceneExecuteLogService.deviceExecuteLog(logDto); try { Thread.sleep(1000); } catch (InterruptedException e) { @@ -551,7 +590,11 @@ public class BoxSubvolumesConveyorDeviceDriver extends AbstractOpcDeviceDriver i while (!StrUtil.equals(this.getOpcValueAccessor().getValue(this.getOpcServer() + "." + this.getOpcPlc() + "." + this.getDevice_code() + ".task").toString() , inst.getInstruction_code())) { this.writing(list); - logServer.deviceExecuteLog(device_code, "", "", inst.getInstruction_code() + "再次下发电气信号"); + LuceneLogDto logDto = LuceneLogDto.builder() + .device_code(device_code) + .content(device_code + inst.getInstruction_code() + "再次下发电气信号") + .build(); + luceneExecuteLogService.deviceExecuteLog(logDto); try { Thread.sleep(500); } catch (InterruptedException e) { diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_conveyor/finished_product_out_with_bind_lable_conveyor/FinishedProductOutBindLableDeviceDriver.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_conveyor/finished_product_out_with_bind_lable_conveyor/FinishedProductOutBindLableDeviceDriver.java index a2411a907..250c4a72b 100644 --- a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_conveyor/finished_product_out_with_bind_lable_conveyor/FinishedProductOutBindLableDeviceDriver.java +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_conveyor/finished_product_out_with_bind_lable_conveyor/FinishedProductOutBindLableDeviceDriver.java @@ -87,6 +87,8 @@ public class FinishedProductOutBindLableDeviceDriver extends AbstractOpcDeviceDr private String error_type = "ssx_error_type"; + String notCreateInstMessage = ""; + //工作模式 int mode = 0; int last_mode = 0; @@ -166,7 +168,6 @@ public class FinishedProductOutBindLableDeviceDriver extends AbstractOpcDeviceDr String device_code; - @Override public Device getDevice() { return this.device; @@ -237,12 +238,58 @@ public class FinishedProductOutBindLableDeviceDriver extends AbstractOpcDeviceDr //申请任务 if (move > 0 && !requireSucess) { instruction_require(); + }else { + String remark = ""; + ; + if (mode != 2) { + remark = "universal_remark2"; + } + if (move != 0) { + remark = "universal_remark3"; + } + if (task != 0) { + remark = "universal_remark4"; + if (ObjectUtil.isNotEmpty(this.inst)) { + this.inst = null; + } + } + if (requireSucess) { + remark = "universal_remark5"; + } + this.setNotCreateInstMessage(remark); + //} } break; + case 5: + //申请贴标 + applyLabeling(mode); + break; case 10: //申请捆轧贴标信息 if (move > 0 && !requireSucess) { - applyLaStrangulationAndLabeling(); + applyLaStrangulationAndLabeling(mode); + } + break; + case 12: + //申请贴标(未贴标) + applyLabeling(mode); + break; + case 13: + //申请捆轧贴标信息(未捆扎) + if (move > 0 && !requireSucess) { + applyLaStrangulationAndLabeling(mode); + } + break; + case 14: + //申请捆轧贴标信息(未贴标) + if (move > 0 && !requireSucess) { + applyLaStrangulationAndLabeling(mode); + } + break; + case 16: + //申请捆轧贴标信息(未贴标,未捆扎) + if (move > 0 && !requireSucess) { + applyLaStrangulationAndLabeling(mode); } break; } @@ -262,7 +309,7 @@ public class FinishedProductOutBindLableDeviceDriver extends AbstractOpcDeviceDr last_to_height = to_height; } - private void applyLaStrangulationAndLabeling() { + private void applyLaStrangulationAndLabeling(int mode) { Date date = new Date(); if (date.getTime() - this.require_apply_strangulation_time.getTime() < (long) this.instruction_require_time_out) { log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_require_time_out); @@ -273,37 +320,87 @@ public class FinishedProductOutBindLableDeviceDriver extends AbstractOpcDeviceDr // Instruction inst = instructionService.findByCodeFromCache(String.valueOf(task)); if (StrUtil.isEmpty(inst.getVehicle_code())) { - message = LangProcess.msg("one_message8") + ": " + task + LangProcess.msg("one_message11"); + message = LangProcess.msg("one_message8") + ": " + task + LangProcess.msg("one_message11"); return; } JSONObject param = new JSONObject(); param.put("device_code", device_code); param.put("vehicle_code", inst.getVehicle_code()); param.put("type", AcsToLmsApplyTaskTypeEnum.LABEL_BIND.getType()); - String response = acsToWmsService.deviceApplyTwo(param); + String response = acsToWmsService.deviceApplyTwo(param); JSONObject jo = JSON.parseObject(response); if (StrUtil.isNotEmpty(jo.getString("body")) || jo.getInteger("status") == 200) { - LuceneLogDto logDto2 = LuceneLogDto.builder() - .device_code(device_code) - .content("申请捆扎,参数,接口返回:" + jo) - .build(); - luceneExecuteLogService.deviceExecuteLog(logDto2); + LuceneLogDto logDto2 = LuceneLogDto.builder() + .device_code(device_code) + .content("申请捆扎,参数,接口返回:" + jo) + .build(); + luceneExecuteLogService.deviceExecuteLog(logDto2); // Map datas = applyLabelingAndBindingResponse.getData(); - packagePLCData(jo.getString("data")); - requireSucess = true; - } else { - LuceneLogDto logDto2 = LuceneLogDto.builder() - .device_code(device_code) - .content("申请捆扎失败,接口返回:" + jo.getString("body")) - .build(); - luceneExecuteLogService.deviceExecuteLog(logDto2); - } - + packagePLCData(jo.getString("data"), mode); + requireSucess = true; + } else { + LuceneLogDto logDto2 = LuceneLogDto.builder() + .device_code(device_code) + .content("申请捆扎失败,接口返回:" + jo.getString("body")) + .build(); + luceneExecuteLogService.deviceExecuteLog(logDto2); } } - private void packagePLCData(String datas) { + } + + // 申请贴标 + public synchronized void applyLabeling(int mode) { + Date date = new Date(); + if (date.getTime() - this.require_apply_strangulation_time.getTime() < (long) this.instruction_require_time_out) { + log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_require_time_out); + return; + } else { + this.require_apply_strangulation_time = date; +// String vehicle_code = ""; +// + Instruction inst = instructionService.findByCodeFromCache(String.valueOf(task)); + if (StrUtil.isEmpty(inst.getVehicle_code())) { + message = LangProcess.msg("one_message8") + ": " + task + LangProcess.msg("one_message11"); + return; + } + JSONObject param = new JSONObject(); + param.put("device_code", device_code); + param.put("vehicle_code", inst.getVehicle_code()); + param.put("type", AcsToLmsApplyTaskTypeEnum.LABEL.getType()); + String response = acsToWmsService.deviceApplyTwo(param); + JSONObject jo = JSON.parseObject(response); + if (jo.getInteger("status") == 200) { + LuceneLogDto logDto2 = LuceneLogDto.builder() + .device_code(device_code) + .content("申请贴标成功:" + jo) + .build(); + luceneExecuteLogService.deviceExecuteLog(logDto2); + List list = new ArrayList(); + Map map5 = new HashMap(); + map5.put("code", "to_command"); + map5.put("value", mode); + list.add(map5); + try { + this.writing(list); + } catch (Exception e) { + message = "universal_write_erro"; + } +// Map datas = applyLabelingAndBindingResponse.getData(); + requireSucess = true; + } else { + LuceneLogDto logDto2 = LuceneLogDto.builder() + .device_code(device_code) + .content("申请贴标失败,接口返回:" + jo.getString("body")) + .build(); + luceneExecuteLogService.deviceExecuteLog(logDto2); + } + + } + } + + private void packagePLCData(String datas, int mode) { JSONObject jo = JSON.parseObject(datas); String length = jo.get("length").toString(); @@ -318,54 +415,112 @@ public class FinishedProductOutBindLableDeviceDriver extends AbstractOpcDeviceDr String bundleTimes = jo.get("bundleTimes").toString(); List list = new ArrayList(); - Map map = new HashMap(); - map.put("code", "to_length"); - map.put("value", length); - list.add(map); - Map map2 = new HashMap(); - map2.put("code", "to_weight"); - map2.put("value", weight); - list.add(map2); - Map map3 = new HashMap(); - map3.put("code", "to_height"); - map3.put("value", height); - list.add(map3); - Map map4 = new HashMap(); - map4.put("code", "to_is_binding"); - map4.put("value", isBinding); - list.add(map4); - Map map5 = new HashMap(); - map5.put("code", "to_command"); - map5.put("value", 10); - list.add(map5); - Map map6 = new HashMap(); - map6.put("code", "to_is_labeling"); - map6.put("value", isLabeling); - list.add(map6); - Map map7 = new HashMap(); - map7.put("code", "to_print_qty"); - map7.put("value", printQty); - list.add(map7); - Map map8 = new HashMap(); - map8.put("code", "to_print_qty"); - map8.put("value", printQty); - list.add(map8); - Map map9 = new HashMap(); - map9.put("code", "to_print_device"); - map9.put("value", printDevice); - list.add(map9); - Map map10 = new HashMap(); - map10.put("code", "to_binding_template"); - map10.put("value", bindingTemplate); - list.add(map10); - Map map11 = new HashMap(); - map11.put("code", "to_binding_times"); - map11.put("value", bundleTimes); - list.add(map11); - Map map12 = new HashMap(); - map12.put("code", "to_labeling_template"); - map12.put("value", labelingTemplate); - list.add(map12); + if (mode == 10 || mode == 16) { + Map map = new HashMap(); + map.put("code", "to_length"); + map.put("value", length); + list.add(map); + Map map2 = new HashMap(); + map2.put("code", "to_weight"); + map2.put("value", weight); + list.add(map2); + Map map3 = new HashMap(); + map3.put("code", "to_height"); + map3.put("value", height); + list.add(map3); + Map map4 = new HashMap(); + map4.put("code", "to_is_binding"); + map4.put("value", isBinding); + list.add(map4); + Map map5 = new HashMap(); + map5.put("code", "to_command"); + map5.put("value", mode); + list.add(map5); + Map map6 = new HashMap(); + map6.put("code", "to_is_labeling"); + map6.put("value", isLabeling); + list.add(map6); + Map map7 = new HashMap(); + map7.put("code", "to_print_qty"); + map7.put("value", printQty); + list.add(map7); + Map map8 = new HashMap(); + map8.put("code", "to_print_qty"); + map8.put("value", printQty); + list.add(map8); + Map map9 = new HashMap(); + map9.put("code", "to_print_device"); + map9.put("value", printDevice); + list.add(map9); + Map map10 = new HashMap(); + map10.put("code", "to_binding_template"); + map10.put("value", bindingTemplate); + list.add(map10); + Map map11 = new HashMap(); + map11.put("code", "to_binding_times"); + map11.put("value", bundleTimes); + list.add(map11); + Map map12 = new HashMap(); + map12.put("code", "to_labeling_template"); + map12.put("value", labelingTemplate); + list.add(map12); + } + if (mode == 13) { + Map map = new HashMap(); + map.put("code", "to_length"); + map.put("value", length); + list.add(map); + Map map2 = new HashMap(); + map2.put("code", "to_weight"); + map2.put("value", weight); + list.add(map2); + Map map3 = new HashMap(); + map3.put("code", "to_height"); + map3.put("value", height); + list.add(map3); + Map map5 = new HashMap(); + map5.put("code", "to_command"); + map5.put("value", mode); + list.add(map5); + Map map11 = new HashMap(); + map11.put("code", "to_binding_times"); + map11.put("value", bundleTimes); + list.add(map11); + } + if (mode == 14) { + Map map4 = new HashMap(); + map4.put("code", "to_is_binding"); + map4.put("value", isBinding); + list.add(map4); + Map map5 = new HashMap(); + map5.put("code", "to_command"); + map5.put("value", mode); + list.add(map5); + Map map6 = new HashMap(); + map6.put("code", "to_is_labeling"); + map6.put("value", isLabeling); + list.add(map6); + Map map7 = new HashMap(); + map7.put("code", "to_print_qty"); + map7.put("value", printQty); + list.add(map7); + Map map8 = new HashMap(); + map8.put("code", "to_print_qty"); + map8.put("value", printQty); + list.add(map8); + Map map9 = new HashMap(); + map9.put("code", "to_print_device"); + map9.put("value", printDevice); + list.add(map9); + Map map10 = new HashMap(); + map10.put("code", "to_binding_template"); + map10.put("value", bindingTemplate); + list.add(map10); + Map map12 = new HashMap(); + map12.put("code", "to_labeling_template"); + map12.put("value", labelingTemplate); + list.add(map12); + } try { this.writing(list); } catch (Exception e) { @@ -465,6 +620,7 @@ public class FinishedProductOutBindLableDeviceDriver extends AbstractOpcDeviceDr jo.put("is_click", true); jo.put("requireSucess", requireSucess); jo.put("driver_type", "siemens_conveyor"); + jo.put("notCreateInstMessage", LangProcess.msg(notCreateInstMessage)); return jo; } @@ -504,6 +660,11 @@ public class FinishedProductOutBindLableDeviceDriver extends AbstractOpcDeviceDr itemMap.put(to_param, json.getString("value")); } } + LuceneLogDto logDto = LuceneLogDto.builder() + .device_code(device_code) + .content("下发多个电气信号" + itemMap) + .build(); + luceneExecuteLogService.deviceExecuteLog(logDto); logServer.deviceExecuteLog(device_code, "", "", "下发电气信号:" + itemMap); try { this.checkcontrol(itemMap); @@ -549,7 +710,11 @@ public class FinishedProductOutBindLableDeviceDriver extends AbstractOpcDeviceDr while (!StrUtil.equals(this.getOpcValueAccessor().getValue(this.getOpcServer() + "." + this.getOpcPlc() + "." + this.getDevice_code() + ".task").toString() , inst.getInstruction_code())) { this.writing(list); - logServer.deviceExecuteLog(device_code, "", "", inst.getInstruction_code() + "再次下发信号"); + LuceneLogDto logDto = LuceneLogDto.builder() + .device_code(device_code) + .content(device_code + inst.getInstruction_code() + "再次下发电气信号") + .build(); + luceneExecuteLogService.deviceExecuteLog(logDto); try { Thread.sleep(500); } catch (InterruptedException e) { @@ -661,7 +826,11 @@ public class FinishedProductOutBindLableDeviceDriver extends AbstractOpcDeviceDr while (!StrUtil.equals(this.getOpcValueAccessor().getValue(this.getOpcServer() + "." + this.getOpcPlc() + "." + this.getDevice_code() + ".task").toString() , instdto.getInstruction_code())) { this.writing(list); - logServer.deviceExecuteLog(device_code, "", "", inst.getInstruction_code() + "再次下发电气信号"); + LuceneLogDto logDto = LuceneLogDto.builder() + .device_code(device_code) + .content(device_code + inst.getInstruction_code() + "再次下发电气信号") + .build(); + luceneExecuteLogService.deviceExecuteLog(logDto); try { Thread.sleep(1000); } catch (InterruptedException e) { @@ -700,7 +869,11 @@ public class FinishedProductOutBindLableDeviceDriver extends AbstractOpcDeviceDr while (!StrUtil.equals(this.getOpcValueAccessor().getValue(this.getOpcServer() + "." + this.getOpcPlc() + "." + this.getDevice_code() + ".task").toString() , inst.getInstruction_code())) { this.writing(list); - logServer.deviceExecuteLog(device_code, "", "", inst.getInstruction_code() + "再次下发电气信号"); + LuceneLogDto logDto = LuceneLogDto.builder() + .device_code(device_code) + .content(device_code + inst.getInstruction_code() + "再次下发电气信号") + .build(); + luceneExecuteLogService.deviceExecuteLog(logDto); try { Thread.sleep(500); } catch (InterruptedException e) { diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_conveyor/finished_product_out_with_bind_lable_conveyor/ItemProtocol.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_conveyor/finished_product_out_with_bind_lable_conveyor/ItemProtocol.java index 1f9095e80..7193f6337 100644 --- a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_conveyor/finished_product_out_with_bind_lable_conveyor/ItemProtocol.java +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_conveyor/finished_product_out_with_bind_lable_conveyor/ItemProtocol.java @@ -121,7 +121,7 @@ public class ItemProtocol { /** *木箱宽度 */ - public static String item_to_weight = "to_weight"; + public static String item_to_weight = "to_width"; /** *木箱高度 */ diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_conveyor/fold_disc_site/FoldDiscSiteDeviceDriver.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_conveyor/fold_disc_site/FoldDiscSiteDeviceDriver.java index 49de8247c..f9bc73820 100644 --- a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_conveyor/fold_disc_site/FoldDiscSiteDeviceDriver.java +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_conveyor/fold_disc_site/FoldDiscSiteDeviceDriver.java @@ -1,5 +1,8 @@ package org.nl.acs.device_driver.one_conveyor.fold_disc_site; +import cn.hutool.core.collection.CollectionUtil; +import cn.hutool.core.date.DateUtil; +import cn.hutool.core.util.IdUtil; import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.StrUtil; import cn.hutool.http.HttpResponse; @@ -8,6 +11,7 @@ import com.alibaba.fastjson.JSONObject; import lombok.Data; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.ObjectUtils; import org.nl.acs.common.base.CommonFinalParam; import org.nl.acs.device.domain.Device; import org.nl.acs.device.service.DeviceExtraService; @@ -17,6 +21,8 @@ import org.nl.acs.device_driver.FeedLmsRealFailed; import org.nl.acs.device_driver.RouteableDeviceDriver; import org.nl.acs.device_driver.driver.AbstractOpcDeviceDriver; import org.nl.acs.device_driver.driver.ExecutableDeviceDriver; +import org.nl.acs.device_driver.led.led_screen.LedScreenDeviceDriver; +import org.nl.acs.device_driver.one_manipulator.box_package_manipulator.InteractionJsonDTO; import org.nl.acs.enums.StorageTypeEnum; import org.nl.acs.ext.wms.service.AcsToWmsService; import org.nl.acs.history.ErrorUtil; @@ -30,16 +36,21 @@ import org.nl.acs.monitor.DeviceStageMonitor; import org.nl.acs.opc.DeviceAppService; import org.nl.acs.opc.DeviceAppServiceImpl; import org.nl.acs.route.service.RouteLineService; +import org.nl.acs.route.service.dto.RouteLineDto; import org.nl.acs.route.service.impl.RouteLineServiceImpl; +import org.nl.acs.task.enums.TaskStatusEnum; +import org.nl.acs.task.enums.TaskTypeEnum; import org.nl.acs.task.service.TaskService; +import org.nl.acs.task.service.dto.TaskDto; +import org.nl.common.exception.BadRequestException; +import org.nl.common.utils.SecurityUtils; import org.nl.config.SpringContextHolder; import org.nl.config.language.LangProcess; import org.nl.config.lucene.service.LuceneExecuteLogService; import org.nl.config.lucene.service.dto.LuceneLogDto; import org.springframework.beans.factory.annotation.Autowired; -import java.util.Date; -import java.util.List; +import java.util.*; /** * 拆叠盘机 @@ -67,6 +78,9 @@ public class FoldDiscSiteDeviceDriver extends AbstractOpcDeviceDriver implements @Autowired LuceneExecuteLogService luceneExecuteLogService = SpringContextHolder.getBean("luceneExecuteLogServiceImpl"); + + DeviceAppService deviceAppservice = SpringContextHolder.getBean(DeviceAppService.class); + //工作模式 int mode = 0; int last_mode = 0; @@ -220,23 +234,36 @@ public class FoldDiscSiteDeviceDriver extends AbstractOpcDeviceDriver implements //申请空托盘入库 if (mode == 9 && move == 1 && !requireSucess){ applyEmptyTask(StorageTypeEnum.DISKS_IN.getType()); + List list1 = new ArrayList(); + Map map = new HashMap(); + map.put("code", "to_command"); + map.put("value", 9); + list1.add(map); + this.writing(list1); } //申请空托盘出库 if (mode == 8 && move == 1 && !requireSucess){ applyEmptyTask(StorageTypeEnum.DISKS_OUT.getType()); + List list1 = new ArrayList(); + Map map = new HashMap(); + map.put("code", "to_command"); + map.put("value", 8); + list1.add(map); + this.writing(list1); + } - //行架机械手申请任务 - if (mode == 2 && move == 0 && task == 0 && !requireSucess) { -// boolean res = applyTask(); -// if (res) { -// notCreateInstMessage = ""; -// notCreateTaskMessage = ""; -// feedMessage = ""; -// } + //碟盘位申请任务 + if (mode == 2 && move == 1 && !requireSucess) { + boolean res = instruction_require(); + if (res) { + notCreateInstMessage = ""; + notCreateTaskMessage = ""; + feedMessage = ""; + } } else { if (mode == 2) { //if (!requireSucess) { @@ -248,13 +275,13 @@ public class FoldDiscSiteDeviceDriver extends AbstractOpcDeviceDriver implements remark = "universal_remark3"; } if (task != 0) { - remark = remark + LangProcess.msg("universal_remark4"); + remark = LangProcess.msg("universal_remark4"); if (ObjectUtil.isNotEmpty(this.inst)) { this.inst = null; } } if (requireSucess) { - remark = remark + LangProcess.msg("universal_remark5"); + remark = LangProcess.msg("universal_remark5"); } this.setNotCreateTaskMessage(remark); //} @@ -276,6 +303,243 @@ public class FoldDiscSiteDeviceDriver extends AbstractOpcDeviceDriver implements last_carrier_direction = carrier_direction; } + + + /** + * 请求指令 + */ + public synchronized boolean instruction_require() { + Date date = new Date(); + if (date.getTime() - this.instruction_require_time.getTime() < (long) this.instruction_require_time_out) { + log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_require_time_out); + return false; + } else { + this.instruction_require_time = date; + //判断是否存在起点相同 任务状态就绪的任务 + TaskDto taskdto = taskserver.findByStartCodeAndReady(device_code); + if (!ObjectUtil.isEmpty(taskdto)) { + //需要判断当前设备是否已经存在就绪的指令 如果存在就直接下发 不存在则创建 + Instruction inst = instructionService.findByTaskcodeAndStatus(taskdto.getTask_code()); + if (ObjectUtil.isNotEmpty(inst)) { + List list = new ArrayList(); + Map map2 = new HashMap(); + map2.put("code", "to_task"); + map2.put("value", inst.getInstruction_code()); + list.add(map2); + Map map3 = new HashMap(); + map3.put("code", "to_command"); + map3.put("value", "1"); + list.add(map3); + this.writing(list); + requireSucess = true; + while (!StrUtil.equals(this.getOpcValueAccessor().getValue(this.getOpcServer() + "." + this.getOpcPlc() + "." + this.getDevice_code() + ".task").toString() + , inst.getInstruction_code())) { + this.writing(list); + try { + Thread.sleep(500); + } catch (InterruptedException e) { + e.printStackTrace(); + } + if (ObjectUtil.isEmpty(instructionService.findByTaskcodeAndStatus(taskdto.getTask_code()))) { + requireSucess = false; + return false; + } + } + message = "universal_message5"; + requireSucess = true; + return true; + } + String taskid = taskdto.getTask_id(); + String taskcode = taskdto.getTask_code(); + String vehiclecode = taskdto.getVehicle_code(); + String priority = taskdto.getPriority(); + String start_point_code = taskdto.getStart_point_code(); + String start_device_code = taskdto.getStart_device_code(); + String route_plan_code = taskdto.getRoute_plan_code(); + String next_device_code = ""; + + /** + * 开始平均分配 + */ + String this_coevice_code = taskserver.queryAssignedByDevice(device_code, taskdto.getNext_device_code()); + if (StrUtil.isEmpty(this_coevice_code)) { + List shortPathsList = routeLineService.getShortPathLines(start_device_code, taskdto.getNext_device_code(), route_plan_code); + RouteLineDto routeLineDto = shortPathsList.get(0); + + String path = routeLineDto.getPath(); + String type = routeLineDto.getType(); + String[] str = path.split("->"); + + List pathlist = Arrays.asList(str); + int index = 0; + for (int m = 0; m < pathlist.size(); m++) { + if (pathlist.get(m).equals(start_device_code)) { + index = m + 1; + break; + } + } + next_device_code = pathlist.get(index); + } else { + next_device_code = this_coevice_code; + } + //校验路由关系 + List shortPathsList = routeLineService.getShortPathLines(start_device_code, next_device_code, route_plan_code); + if (ObjectUtils.isEmpty(shortPathsList)) { + throw new RuntimeException("路由不通!"); + } + + Device startdevice = deviceAppservice.findDeviceByCode(start_device_code); + Device nextdevice = deviceAppservice.findDeviceByCode(next_device_code); + String next_point_code; + if (StrUtil.equals(deviceAppservice.findDeviceTypeByCode(next_device_code), "storage")) { + next_point_code = taskdto.getTo_x() + "-" + taskdto.getTo_y() + "-" + taskdto.getTo_z(); + } else { + next_point_code = next_device_code; + } + Instruction instdto = new Instruction(); + instdto.setInstruction_id(IdUtil.simpleUUID()); + instdto.setRoute_plan_code(route_plan_code); + instdto.setRemark(taskdto.getRemark()); + instdto.setMaterial(taskdto.getMaterial()); + instdto.setQuantity(taskdto.getQuantity()); + instdto.setTask_id(taskid); + instdto.setTask_code(taskcode); + instdto.setVehicle_code(vehiclecode); + String now = DateUtil.now(); + instdto.setCreate_time(now); + instdto.setCreate_by(SecurityUtils.getCurrentNickName()); + instdto.setStart_device_code(start_device_code); + instdto.setNext_device_code(next_device_code); + instdto.setStart_point_code(start_point_code); + instdto.setNext_point_code(next_point_code); + instdto.setPriority(priority); + instdto.setInstruction_status("0"); + instdto.setExecute_device_code(start_point_code); + try { + instructionService.create(instdto); + } catch (Exception e) { + e.printStackTrace(); + log.error("指令创建失败!", e.getMessage()); + return false; + } + //创建指令后修改任务状态 + taskdto.setTask_status(TaskStatusEnum.BUSY.getIndex()); + taskserver.update(taskdto); + requireSucess = true; + String next_addr = nextdevice.getExtraValue().get("address").toString(); + + List list = new ArrayList(); + Map map = new HashMap(); + map.put("code", "to_target"); + map.put("value", next_addr); + list.add(map); + Map map2 = new HashMap(); + map2.put("code", "to_task"); + map2.put("value", instdto.getInstruction_code()); + list.add(map2); + Map map3 = new HashMap(); + map3.put("code", "to_command"); + map3.put("value", "1"); + list.add(map3); + this.writing(list); + requireSucess = true; + while (!StrUtil.equals(this.getOpcValueAccessor().getValue(this.getOpcServer() + "." + this.getOpcPlc() + "." + this.getDevice_code() + ".task").toString() + , instdto.getInstruction_code())) { + this.writing(list); + LuceneLogDto logDto = LuceneLogDto.builder() + .device_code(device_code) + .content(device_code + inst.getInstruction_code() + "再次下发电气信号") + .build(); + luceneExecuteLogService.deviceExecuteLog(logDto); + try { + Thread.sleep(1000); + } catch (InterruptedException e) { + e.printStackTrace(); + } + if (ObjectUtil.isEmpty(taskserver.findByCode(taskdto.getTask_code()))) { + requireSucess = false; + return false; + } + } + } else { + //如果不存在则直接找对应指令 + Instruction inst = instructionService.findByDeviceCodeFromCache(this.device_code); + if (ObjectUtil.isEmpty(inst)) { + return false; + } + + Device nextdevice = deviceAppservice.findDeviceByCode(inst.getNext_device_code()); + String next_addr = nextdevice.getExtraValue().get("address").toString(); + + List list = new ArrayList(); + Map map = new HashMap(); + map.put("code", "to_target"); + map.put("value", next_addr); + list.add(map); + Map map2 = new HashMap(); + map2.put("code", "to_task"); + map2.put("value", inst.getInstruction_code()); + list.add(map2); + Map map3 = new HashMap(); + map3.put("code", "to_command"); + map3.put("value", "1"); + list.add(map3); + this.writing(list); + requireSucess = true; + while (!StrUtil.equals(this.getOpcValueAccessor().getValue(this.getOpcServer() + "." + this.getOpcPlc() + "." + this.getDevice_code() + ".task").toString() + , inst.getInstruction_code())) { + this.writing(list); + LuceneLogDto logDto = LuceneLogDto.builder() + .device_code(device_code) + .content(device_code + inst.getInstruction_code() + "再次下发电气信号") + .build(); + luceneExecuteLogService.deviceExecuteLog(logDto); + try { + Thread.sleep(500); + } catch (InterruptedException e) { + e.printStackTrace(); + } + if (ObjectUtil.isEmpty(instructionService.findByDeviceCodeFromCache(this.device_code))) { + requireSucess = false; + return false; + } + } + } + return true; + } + } + + public void writing(List list) { + + Map itemMap = new HashMap(); + for (int i = 0; i < list.size(); i++) { + Object ob = list.get(i); + JSONObject json = (JSONObject) JSONObject.toJSON(ob); + if (!StrUtil.isEmpty(json.getString("value"))) { + String to_param = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() + + "." + json.getString("code"); + itemMap.put(to_param, json.getString("value")); + } + } + LuceneLogDto logDto = LuceneLogDto.builder() + .device_code(device_code) + .content("下发多个电气信号" + itemMap) + .build(); + luceneExecuteLogService.deviceExecuteLog(logDto); + logServer.deviceExecuteLog(device_code, "", "", "下发电气信号:" + itemMap); + try { + this.checkcontrol(itemMap); + } catch (Exception e) { + e.printStackTrace(); + try { + this.checkcontrol(itemMap); + } catch (Exception e1) { + e1.printStackTrace(); + } + } + + } + private void applyEmptyTask(String type) { Date date = new Date(); if (date.getTime() - this.require_apply_strangulation_time.getTime() @@ -368,7 +632,7 @@ public class FoldDiscSiteDeviceDriver extends AbstractOpcDeviceDriver implements jo.put("isError", this.getIserror()); jo.put("message", LangProcess.msg(message)); jo.put("notCreateTaskMessage", notCreateTaskMessage); - jo.put("notCreateInstMessage", notCreateInstMessage); + jo.put("notCreateInstMessage", LangProcess.msg(notCreateInstMessage)); jo.put("feedMessage", LangProcess.msg(feedMessage)); jo.put("driver_type", "siemens_conveyor"); jo.put("is_click", true); diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_conveyor/scanner_weight_conveyor/ConveyorWithScannerWeightDeviceDriver.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_conveyor/scanner_weight_conveyor/ConveyorWithScannerWeightDeviceDriver.java index cf482826e..aea161fe8 100644 --- a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_conveyor/scanner_weight_conveyor/ConveyorWithScannerWeightDeviceDriver.java +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_conveyor/scanner_weight_conveyor/ConveyorWithScannerWeightDeviceDriver.java @@ -20,9 +20,11 @@ import org.nl.acs.device.service.impl.DeviceExtraServiceImpl; import org.nl.acs.device_driver.DeviceDriver; import org.nl.acs.device_driver.FeedLmsRealFailed; import org.nl.acs.device_driver.RouteableDeviceDriver; +import org.nl.acs.device_driver.conveyor.belt_conveyor.BeltConveyorDeviceDriver; import org.nl.acs.device_driver.driver.AbstractOpcDeviceDriver; import org.nl.acs.device_driver.driver.ExecutableDeviceDriver; import org.nl.acs.device_driver.led.led_screen.LedScreenDeviceDriver; +import org.nl.acs.device_driver.one_manipulator.box_package_manipulator.InteractionJsonDTO; import org.nl.acs.enums.StorageTypeEnum; import org.nl.acs.ext.wms.service.AcsToWmsService; import org.nl.acs.history.ErrorUtil; @@ -128,8 +130,8 @@ public class ConveyorWithScannerWeightDeviceDriver extends AbstractOpcDeviceDriv int last_hj_task = 0; //重量 - int weight = 0; - int last_weight = 0; + Float weight = 0.0F; + Float last_weight = 0.0F; //托盘条码 String barcode = null; @@ -144,9 +146,9 @@ public class ConveyorWithScannerWeightDeviceDriver extends AbstractOpcDeviceDriv String hand_material_barcode = null; - //数量 - int qty = 0; - int last_qty = 0; + //高度 + int height = 0; + int last_height = 0; //托盘方向 int carrier_direction = 0; @@ -219,7 +221,7 @@ public class ConveyorWithScannerWeightDeviceDriver extends AbstractOpcDeviceDriv to_container_type = this.itemProtocol.getTo_container_type(); container_type = this.itemProtocol.getContainer_type(); carrier_direction = this.itemProtocol.getCarrier_direction(); - qty = this.itemProtocol.getQty(); + height = this.itemProtocol.getHeight(); weight = this.itemProtocol.getWeight(); barcode = this.itemProtocol.getBarcode(); material_barcode = this.itemProtocol.getMaterialBarcode(); @@ -284,11 +286,23 @@ public class ConveyorWithScannerWeightDeviceDriver extends AbstractOpcDeviceDriv //木箱入库申请入库任务 if (mode == 6 && !requireSucess){ applyIn(StorageTypeEnum.BOX_IN.getType()); + List list1 = new ArrayList(); + Map map = new HashMap(); + map.put("code", "to_command"); + map.put("value", 6); + list1.add(map); + this.writing(list1); } //子卷入库申请入库任务 if (mode == 7 && !requireSucess){ applyIn(StorageTypeEnum.STORAGE.getType()); + List list1 = new ArrayList(); + Map map = new HashMap(); + map.put("code", "to_command"); + map.put("value", 7); + list1.add(map); + this.writing(list1); } //申请入库指令、异常位指令 @@ -300,29 +314,25 @@ public class ConveyorWithScannerWeightDeviceDriver extends AbstractOpcDeviceDriv feedMessage = ""; } } else { - if (mode == 2) { - //if (!requireSucess) { - String remark = "";; - if (mode != 2) { - remark = "universal_remark2"; - } - if (move != 0) { - remark = "universal_remark3"; - } - if (task != 0) { - remark = remark + LangProcess.msg("universal_remark4"); - - if (ObjectUtil.isNotEmpty(this.inst)) { - this.inst = null; - } - } - if (requireSucess) { - remark = remark + LangProcess.msg("universal_remark5"); - - } - this.setNotCreateTaskMessage(remark); - //} + String remark = ""; + ; + if (mode != 2) { + remark = "universal_remark2"; } + if (move != 0) { + remark = "universal_remark3"; + } + if (task != 0) { + remark = "universal_remark4"; + if (ObjectUtil.isNotEmpty(this.inst)) { + this.inst = null; + } + } + if (requireSucess) { + remark = "universal_remark5"; + } + this.setNotCreateInstMessage(remark); + //} } } @@ -338,7 +348,7 @@ public class ConveyorWithScannerWeightDeviceDriver extends AbstractOpcDeviceDriv last_hj_task = hj_task; last_container_type = container_type; last_carrier_direction = carrier_direction; - last_qty = qty; + last_height = height; last_weight = weight; last_barcode = barcode; } @@ -365,7 +375,7 @@ public class ConveyorWithScannerWeightDeviceDriver extends AbstractOpcDeviceDriv if (response == null || response.getStatus() == 200) { LuceneLogDto logDto2 = LuceneLogDto.builder() .device_code(device_code) - .content("木箱入库申请异常位任务,接口返回:" + response.body()) + .content("木箱入库申请异常位任务,接口返回:" + response) .build(); luceneExecuteLogService.deviceExecuteLog(logDto2); } @@ -466,97 +476,18 @@ public class ConveyorWithScannerWeightDeviceDriver extends AbstractOpcDeviceDriv return false; } else { this.instruction_require_time = date; - //判断是否存在起点相同 任务状态就绪的任务 - TaskDto taskdto = taskserver.findByStartCodeAndReady(device_code); - if (!ObjectUtil.isEmpty(taskdto)) { - - String taskid = taskdto.getTask_id(); - String taskcode = taskdto.getTask_code(); - String vehiclecode = taskdto.getVehicle_code(); - String priority = taskdto.getPriority(); - Instruction instdto = new Instruction(); - if (TaskTypeEnum.AGV_Task.getIndex().equals(taskdto.getTask_type())){ - String route_plan_code = taskdto.getRoute_plan_code(); - - List shortPathsList = routeLineService.getShortPathLines(taskdto.getStart_device_code(), taskdto.getNext_device_code(), route_plan_code); - if (CollectionUtil.isEmpty(shortPathsList)){ - return false; - } - RouteLineDto routeLineDto = shortPathsList.get(0); - String path = routeLineDto.getPath(); - String[] str = path.split("->"); - List pathlist = Arrays.asList(str); - Integer start = 0; - String start_device_code = pathlist.get(start); - String next_device_code = pathlist.get(start+1); - //判断有无出入库任务是相同路线 - TaskDto dto = taskserver.findByCodeAndExcute(taskdto.getNext_device_code(), taskdto.getStart_device_code()); - if (ObjectUtil.isNotEmpty(dto)){ - requireSucess = false; - return false; - } - packageInstrcutData(instdto, taskdto, taskid, taskcode, vehiclecode, priority,start_device_code,next_device_code); - }else { - - - packageInstrcutData(instdto, taskdto, taskid, taskcode, vehiclecode, priority,taskdto.getStart_device_code(),taskdto.getNext_device_code()); + //根据补码查找任务 + if (StrUtil.isNotBlank(hand_barcode)) { + TaskDto taskdto = taskserver.findByVehicleCodeCodeAndReady(hand_barcode); + if (!ObjectUtil.isEmpty(taskdto)) { + if (creatInstruction(taskdto)) return false; } - try { - instructionService.create(instdto); - } catch (Exception e) { - e.printStackTrace(); - log.error("指令创建失败!", e.getMessage()); - return false; - } - Device nextdevice = deviceAppservice.findDeviceByCode(taskdto.getNext_device_code()); - - //创建指令后修改任务状态 - taskdto.setTask_status(TaskStatusEnum.BUSY.getIndex()); - taskserver.update(taskdto); - String next_addr = nextdevice.getExtraValue().get("address").toString(); - - List list = new ArrayList(); - Map map = new HashMap(); - map.put("code", "to_target"); - map.put("value", next_addr); - list.add(map); - Map map2 = new HashMap(); - map2.put("code", "to_task"); - map2.put("value", instdto.getInstruction_code()); - list.add(map2); - Map map3 = new HashMap(); - map3.put("code", "to_command"); - map3.put("value", "1"); - list.add(map3); - this.writing(list); - led_message = getLedMessage(instdto); - List deviceCodes = this.getExtraDeviceCodes("link_device_code"); - String device = null; - if (ObjectUtil.isNotEmpty(deviceCodes)) { - for (String deviceCode : deviceCodes) { - Device linkDevice = deviceAppService.findDeviceByCode(deviceCode); - if (ObjectUtil.isEmpty(linkDevice)) { - throw new BadRequestException("设备:" + device_code + "关联设备->" + deviceCode + "为空!"); - } - if (linkDevice.getDeviceDriver() instanceof LedScreenDeviceDriver){ - device = deviceCode; - } - } - } - taskScreenService.getLedMessage(device); - requireSucess = true; - while (!StrUtil.equals(this.getOpcValueAccessor().getValue(this.getOpcServer() + "." + this.getOpcPlc() + "." + this.getDevice_code() + ".task").toString() - , instdto.getInstruction_code())) { - this.writing(list); - logServer.deviceExecuteLog(device_code, "", "", inst.getInstruction_code() + "再次下发电气信号"); - try { - Thread.sleep(1000); - } catch (InterruptedException e) { - e.printStackTrace(); - } - if (ObjectUtil.isEmpty(taskserver.findByCode(taskdto.getTask_code()))) { - requireSucess = false; - return false; + }else { + if (StrUtil.isNotBlank(barcode)) { + //根据载具号查找任务 + TaskDto taskdto = taskserver.findByVehicleCodeCodeAndReady(barcode); + if (!ObjectUtil.isEmpty(taskdto)) { + if (creatInstruction(taskdto)) return false; } } } @@ -564,6 +495,116 @@ public class ConveyorWithScannerWeightDeviceDriver extends AbstractOpcDeviceDriv } } + private boolean creatInstruction(TaskDto taskdto) { + String taskid = taskdto.getTask_id(); + String taskcode = taskdto.getTask_code(); + String vehiclecode = taskdto.getVehicle_code(); + String priority = taskdto.getPriority(); + Instruction instdto = new Instruction(); + String interactionJson = taskdto.getInteraction_json(); + InteractionJsonDTO interactionJsonDTO = JSON.parseObject(interactionJson, InteractionJsonDTO.class); + String containerType = ""; + if (ObjectUtil.isNotEmpty(interactionJsonDTO)) { + containerType = interactionJsonDTO.getContainerType(); + } + if (TaskTypeEnum.AGV_Task.getIndex().equals(taskdto.getTask_type())){ + String route_plan_code = taskdto.getRoute_plan_code(); + + List shortPathsList = routeLineService.getShortPathLines(taskdto.getStart_device_code(), taskdto.getNext_device_code(), route_plan_code); + if (CollectionUtil.isEmpty(shortPathsList)){ + return true; + } + RouteLineDto routeLineDto = shortPathsList.get(0); + String path = routeLineDto.getPath(); + String[] str = path.split("->"); + List pathlist = Arrays.asList(str); + Integer start = 0; + String start_device_code = pathlist.get(start); + String next_device_code = pathlist.get(start+1); + + //判断有无出入库任务是相同路线 + TaskDto dto = taskserver.findByCodeAndExcute(taskdto.getNext_device_code(), taskdto.getStart_device_code()); + if (ObjectUtil.isNotEmpty(dto)){ + requireSucess = false; + return true; + } + + + packageInstrcutData(instdto, taskdto, taskid, taskcode, vehiclecode, priority,start_device_code,next_device_code,containerType); + }else { + + packageInstrcutData(instdto, taskdto, taskid, taskcode, vehiclecode, priority, taskdto.getStart_device_code(), taskdto.getNext_device_code(),containerType); + } + try { + instructionService.create(instdto); + } catch (Exception e) { + e.printStackTrace(); + log.error("指令创建失败!", e.getMessage()); + return true; + } + Device nextdevice = deviceAppservice.findDeviceByCode(instdto.getNext_device_code()); + + //创建指令后修改任务状态 + taskdto.setTask_status(TaskStatusEnum.BUSY.getIndex()); + taskserver.update(taskdto); + String next_addr = nextdevice.getExtraValue().get("address").toString(); + + List list = new ArrayList(); + Map map = new HashMap(); + map.put("code", "to_target"); + map.put("value", next_addr); + list.add(map); + Map map2 = new HashMap(); + map2.put("code", "to_task"); + map2.put("value", instdto.getInstruction_code()); + list.add(map2); + Map map3 = new HashMap(); + map3.put("code", "to_container_type"); + map3.put("value", containerType); + list.add(map3); + Map map4 = new HashMap(); + map4.put("code", "to_command"); + map4.put("value", "1"); + list.add(map4); + + this.writing(list); + led_message = getLedMessage(instdto); + List deviceCodes = this.getExtraDeviceCodes("link_device_code"); + String device = null; + if (ObjectUtil.isNotEmpty(deviceCodes)) { + for (String deviceCode : deviceCodes) { + Device linkDevice = deviceAppService.findDeviceByCode(deviceCode); + if (ObjectUtil.isEmpty(linkDevice)) { + throw new BadRequestException("设备:" + device_code + "关联设备->" + deviceCode + "为空!"); + } + if (linkDevice.getDeviceDriver() instanceof LedScreenDeviceDriver){ + device = deviceCode; + } + } + } + taskScreenService.getLedMessage(device); + requireSucess = true; + while (!StrUtil.equals(this.getOpcValueAccessor().getValue(this.getOpcServer() + "." + this.getOpcPlc() + "." + this.getDevice_code() + ".task").toString() + , instdto.getInstruction_code())) { + this.writing(list); + LuceneLogDto logDto = LuceneLogDto.builder() + .device_code(device_code) + .content(device_code + inst.getInstruction_code() + "再次下发电气信号") + .build(); + luceneExecuteLogService.deviceExecuteLog(logDto); + try { + Thread.sleep(1000); + } catch (InterruptedException e) { + e.printStackTrace(); + } + if (ObjectUtil.isEmpty(taskserver.findByCode(taskdto.getTask_code()))) { + requireSucess = false; + return true; + } + } + return false; + } + /** * 获取任务信息 */ @@ -601,7 +642,7 @@ public class ConveyorWithScannerWeightDeviceDriver extends AbstractOpcDeviceDriv return json; } - private void packageInstrcutData(Instruction instdto, TaskDto taskdto, String taskid, String taskcode, String vehiclecode, String priority,String startCode, String endCode) { + private void packageInstrcutData(Instruction instdto, TaskDto taskdto, String taskid, String taskcode, String vehiclecode, String priority,String startCode, String endCode,String containerType) { instdto.setInstruction_id(IdUtil.simpleUUID()); instdto.setRoute_plan_code(taskdto.getRoute_plan_code()); instdto.setRemark(taskdto.getRemark()); @@ -621,6 +662,8 @@ public class ConveyorWithScannerWeightDeviceDriver extends AbstractOpcDeviceDriv instdto.setInstruction_status("0"); instdto.setExecute_device_code(device_code); instdto.setInstruction_type(taskdto.getTask_type()); + instdto.setVehicle_type(containerType); + } @@ -636,6 +679,11 @@ public class ConveyorWithScannerWeightDeviceDriver extends AbstractOpcDeviceDriv itemMap.put(to_param, json.getString("value")); } } + LuceneLogDto logDto = LuceneLogDto.builder() + .device_code(device_code) + .content("下发多个电气信号" + itemMap) + .build(); + luceneExecuteLogService.deviceExecuteLog(logDto); logServer.deviceExecuteLog(device_code, "", "", "下发电气信号:" + itemMap); try { this.checkcontrol(itemMap); @@ -704,7 +752,7 @@ public class ConveyorWithScannerWeightDeviceDriver extends AbstractOpcDeviceDriv jo.put("isError", this.getIserror()); jo.put("message", LangProcess.msg(message)); jo.put("notCreateTaskMessage", notCreateTaskMessage); - jo.put("notCreateInstMessage", notCreateInstMessage); + jo.put("notCreateInstMessage", LangProcess.msg(notCreateInstMessage)); jo.put("feedMessage", LangProcess.msg(feedMessage)); jo.put("driver_type", "conveyor_with_scanner_weight"); jo.put("is_click", true); diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_conveyor/scanner_weight_conveyor/ItemProtocol.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_conveyor/scanner_weight_conveyor/ItemProtocol.java index d13d403d8..9295ff0e3 100644 --- a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_conveyor/scanner_weight_conveyor/ItemProtocol.java +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_conveyor/scanner_weight_conveyor/ItemProtocol.java @@ -32,9 +32,9 @@ public class ItemProtocol { */ public static String item_error = "error"; /** - * 数量 + * 高度 */ - public static String item_qty = "qty"; + public static String item_height = "height"; /** * 任务号 */ @@ -112,8 +112,8 @@ public class ItemProtocol { return this.getOpcIntegerValue(item_task); } - public int getQty(){ - return this.getOpcIntegerValue(item_qty); + public int getHeight(){ + return this.getOpcIntegerValue(item_height); } public int getCarrier_direction(){ @@ -129,8 +129,8 @@ public class ItemProtocol { return this.getOpcStringValue(item_material_barcode); } - public int getWeight(){ - return this.getOpcIntegerValue(item_weight); + public Float getWeight(){ + return this.getOpcFloatValue(item_weight); } public int getTo_task() { return this.getOpcIntegerValue(item_to_task); @@ -179,6 +179,20 @@ public class ItemProtocol { return 0; } + + public float getOpcFloatValue(String protocol) { + Float value = this.driver.getDoubleValue(protocol); + if (value == null) { + // log.error(this.getDriver().getDeviceCode() + ":protocol " + protocol + " 信号同步异常!"); + setIsonline(false); + } else { + setIsonline(true); + return value; + } + return 0; + + } + public static List getReadableItemDtos() { ArrayList list = new ArrayList<>(); list.add(new ItemDto(item_heartbeat, "心跳", "DB1.B0")); @@ -189,7 +203,7 @@ public class ItemProtocol { list.add(new ItemDto(item_task, "任务号", "DB1.D6")); list.add(new ItemDto(item_container_type, "托盘类型", "DB1.B7")); list.add(new ItemDto(item_carrier_direction, "托盘方向", "DB1.B8")); - list.add(new ItemDto(item_qty, "数量", "DB1.B9")); + list.add(new ItemDto(item_height, "高度", "DB1.B9")); list.add(new ItemDto(item_weight, "重量", "DB1.B10")); list.add(new ItemDto(item_barcode, "托盘条码", "DB602.STRING1.50")); list.add(new ItemDto(item_material_barcode, "子卷条码", "DB601.STRING1.50")); diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_conveyor/un_box_lable_conveyor/UnBoxLableConveyorDeviceDriver.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_conveyor/un_box_lable_conveyor/UnBoxLableConveyorDeviceDriver.java index 7b8716cbb..9ad3ed248 100644 --- a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_conveyor/un_box_lable_conveyor/UnBoxLableConveyorDeviceDriver.java +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_conveyor/un_box_lable_conveyor/UnBoxLableConveyorDeviceDriver.java @@ -38,6 +38,8 @@ import org.nl.acs.task.service.dto.TaskDto; import org.nl.common.utils.SecurityUtils; import org.nl.config.SpringContextHolder; import org.nl.config.language.LangProcess; +import org.nl.config.lucene.service.LuceneExecuteLogService; +import org.nl.config.lucene.service.dto.LuceneLogDto; import org.nl.config.thread.ThreadPoolExecutorUtil; import org.openscada.opc.lib.da.Server; @@ -76,6 +78,9 @@ public class UnBoxLableConveyorDeviceDriver extends AbstractOpcDeviceDriver impl DeviceErrorLogService deviceErrorLogService = SpringContextHolder.getBean(DeviceErrorLogServiceImpl.class); DeviceAppService deviceAppService = SpringContextHolder.getBean(DeviceAppServiceImpl.class); + + LuceneExecuteLogService luceneExecuteLogService = SpringContextHolder.getBean("luceneExecuteLogServiceImpl"); + //当前指令 Instruction inst = null; @@ -208,12 +213,18 @@ public class UnBoxLableConveyorDeviceDriver extends AbstractOpcDeviceDriver impl if (!applyUnbox(instruction)){ if (ObjectUtil.isNotEmpty(instruction)) { try { - instructionService.finish(instruction); +// instructionService.finish(instruction); } catch (Exception e) { throw new RuntimeException(e); } } } + List list1 = new ArrayList(); + Map map = new HashMap(); + map.put("code", "to_command"); + map.put("value", 7); + list1.add(map); + this.writing(list1); } } @@ -495,7 +506,6 @@ public class UnBoxLableConveyorDeviceDriver extends AbstractOpcDeviceDriver impl while (!StrUtil.equals(this.getOpcValueAccessor().getValue(this.getOpcServer() + "." + this.getOpcPlc() + "." + this.getDevice_code() + ".task").toString() , inst.getInstruction_code())) { this.writing(list); - logServer.deviceExecuteLog(device_code, "", "", inst.getInstruction_code() + "再次下发信号"); try { Thread.sleep(500); } catch (InterruptedException e) { @@ -607,7 +617,11 @@ public class UnBoxLableConveyorDeviceDriver extends AbstractOpcDeviceDriver impl while (!StrUtil.equals(this.getOpcValueAccessor().getValue(this.getOpcServer() + "." + this.getOpcPlc() + "." + this.getDevice_code() + ".task").toString() , instdto.getInstruction_code())) { this.writing(list); - logServer.deviceExecuteLog(device_code, "", "", inst.getInstruction_code() + "再次下发电气信号"); + LuceneLogDto logDto = LuceneLogDto.builder() + .device_code(device_code) + .content(device_code + inst.getInstruction_code() + "再次下发电气信号") + .build(); + luceneExecuteLogService.deviceExecuteLog(logDto); try { Thread.sleep(1000); } catch (InterruptedException e) { @@ -646,7 +660,11 @@ public class UnBoxLableConveyorDeviceDriver extends AbstractOpcDeviceDriver impl while (!StrUtil.equals(this.getOpcValueAccessor().getValue(this.getOpcServer() + "." + this.getOpcPlc() + "." + this.getDevice_code() + ".task").toString() , inst.getInstruction_code())) { this.writing(list); - logServer.deviceExecuteLog(device_code, "", "", inst.getInstruction_code() + "再次下发电气信号"); + LuceneLogDto logDto = LuceneLogDto.builder() + .device_code(device_code) + .content(device_code + inst.getInstruction_code() + "再次下发电气信号") + .build(); + luceneExecuteLogService.deviceExecuteLog(logDto); try { Thread.sleep(500); } catch (InterruptedException e) { diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_manipulator/box_package_manipulator/BoxPackageManipulatorDeviceDriver.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_manipulator/box_package_manipulator/BoxPackageManipulatorDeviceDriver.java index 779c290bd..f0ac006b3 100644 --- a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_manipulator/box_package_manipulator/BoxPackageManipulatorDeviceDriver.java +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_manipulator/box_package_manipulator/BoxPackageManipulatorDeviceDriver.java @@ -40,6 +40,8 @@ import org.nl.common.exception.BadRequestException; import org.nl.common.utils.SecurityUtils; import org.nl.config.SpringContextHolder; import org.nl.config.language.LangProcess; +import org.nl.config.lucene.service.LuceneExecuteLogService; +import org.nl.config.lucene.service.dto.LuceneLogDto; import java.util.*; @@ -59,6 +61,7 @@ public class BoxPackageManipulatorDeviceDriver extends AbstractOpcDeviceDriver i RouteLineService routeLineService = SpringContextHolder.getBean(RouteLineServiceImpl.class); DeviceExtraService deviceExtraService = SpringContextHolder.getBean(DeviceExtraServiceImpl.class); DeviceErrorLogService errorLogServer = SpringContextHolder.getBean(DeviceErrorLogServiceImpl.class); + LuceneExecuteLogService luceneExecuteLogService = SpringContextHolder.getBean(LuceneExecuteLogService.class); //工作模式 int mode = 0; @@ -213,31 +216,33 @@ public class BoxPackageManipulatorDeviceDriver extends AbstractOpcDeviceDriver i List toInstructions; //行架机械手申请任务 - if (mode == 2 && move == 0 && task == 0 && !requireSucess) { + if (mode == 2 && move == 0 && !requireSucess) { boolean res = applyTask(); if (res) { notCreateInstMessage = ""; notCreateTaskMessage = ""; feedMessage = ""; } - } else { - String remark = "";; - if (mode != 2) { - remark = "universal_remark2"; + }else { + String remark = ""; + ; + if (mode != 2) { + remark = "universal_remark2"; + } + if (move != 0) { + remark = "universal_remark3"; + } + if (task != 0) { + remark = "universal_remark4"; + if (ObjectUtil.isNotEmpty(this.inst)) { + this.inst = null; } - if (move != 0) { - remark = "universal_remark3"; - } - if (task != 0) { - remark = "universal_remark4"; - if (ObjectUtil.isNotEmpty(this.inst)) { - this.inst = null; - } - } - if (requireSucess) { - remark = "universal_remark5"; - } - this.setNotCreateTaskMessage(remark); + } + if (requireSucess) { + remark = "universal_remark5"; + } + this.setNotCreateInstMessage(remark); + //} } } @@ -407,10 +412,10 @@ public class BoxPackageManipulatorDeviceDriver extends AbstractOpcDeviceDriver i ManipulatorCacheDeviceDriver manipulatorCacheDeviceDriver; if (startDevice.getDeviceDriver() instanceof ManipulatorCacheDeviceDriver) { manipulatorCacheDeviceDriver = (ManipulatorCacheDeviceDriver) startDevice.getDeviceDriver(); - if (manipulatorCacheDeviceDriver.getMode() != 2 && manipulatorCacheDeviceDriver.getAction() !=1) { - notCreateInstMessage = "universal_notCreateInstMessage3"; - return false; - } +// if (manipulatorCacheDeviceDriver.getMode() != 2) { +// notCreateInstMessage = "universal_notCreateInstMessage3"; +// return false; +// } } String taskid = taskDto.getTask_id(); @@ -425,7 +430,11 @@ public class BoxPackageManipulatorDeviceDriver extends AbstractOpcDeviceDriver i instructionService.create(instdto); } catch (Exception e) { notCreateInstMessage = e.getMessage(); - logServer.deviceExecuteLog(this.getDevice_code(), "", "", "创建指令时出现异常:" + e.getMessage()); + LuceneLogDto logDto = LuceneLogDto.builder() + .device_code(device_code) + .content(device_code+"创建指令时出现异常:" + e.getMessage()) + .build(); + luceneExecuteLogService.deviceExecuteLog(logDto); return false; } //创建指令后修改任务状态 @@ -446,9 +455,11 @@ public class BoxPackageManipulatorDeviceDriver extends AbstractOpcDeviceDriver i try { pushPLC(map1, map2, next_addr, map3, start_addr, map4, instdto.getInstruction_code(), interactionJsonDTO, map5, map6, map7, map8,map9,map10); } catch (Exception e) { - logServer.deviceExecuteLog(device_code, "", "", "当前设备:" + device_code + ",下发指令:" - + instdto.getInstruction_code() + ",指令起点:" + instdto.getStart_device_code() - + ",指令终点:" + instdto.getNext_device_code() + ",交互参数:" + interactionJsonDTO.toString() + ",指令执行失败:" + e.getMessage()); + LuceneLogDto logDto = LuceneLogDto.builder() + .device_code(device_code) + .content(device_code+"创建指令时出现异常:" + e.getMessage()) + .build(); + luceneExecuteLogService.deviceExecuteLog(logDto); } this.setRequireSucess(true); return true; @@ -544,6 +555,11 @@ public class BoxPackageManipulatorDeviceDriver extends AbstractOpcDeviceDriver i itemMap.put(to_param, json.getString("value")); } } + LuceneLogDto logDto = LuceneLogDto.builder() + .device_code(device_code) + .content("下发多个电气信号" + itemMap) + .build(); + luceneExecuteLogService.deviceExecuteLog(logDto); logServer.deviceExecuteLog(device_code, "", "", "下发电气信号:" + itemMap); try { this.checkcontrol(itemMap); @@ -616,7 +632,7 @@ public class BoxPackageManipulatorDeviceDriver extends AbstractOpcDeviceDriver i jo.put("isError", this.getIserror()); jo.put("message", LangProcess.msg(message)); jo.put("notCreateTaskMessage", notCreateTaskMessage); - jo.put("notCreateInstMessage", notCreateInstMessage); + jo.put("notCreateInstMessage", LangProcess.msg(notCreateInstMessage)); jo.put("feedMessage", LangProcess.msg(feedMessage)); jo.put("driver_type", "box_package_manipulator"); jo.put("is_click", true); diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_manipulator/box_package_manipulator/InteractionJsonDTO.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_manipulator/box_package_manipulator/InteractionJsonDTO.java index f6dbff375..5f0622542 100644 --- a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_manipulator/box_package_manipulator/InteractionJsonDTO.java +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_manipulator/box_package_manipulator/InteractionJsonDTO.java @@ -11,7 +11,7 @@ public class InteractionJsonDTO { private String maxNo; /** - *木箱最大数量 + *木箱放入数量 */ private String boxNo; @@ -31,4 +31,9 @@ public class InteractionJsonDTO { *子卷长度 */ private String len; + + /** + * 托盘类型 + */ + private String containerType; } diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_manipulator/box_storage_manipulator/BoxStorageManipulatorDeviceDriver.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_manipulator/box_storage_manipulator/BoxStorageManipulatorDeviceDriver.java index cfeaad9c6..0e176481a 100644 --- a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_manipulator/box_storage_manipulator/BoxStorageManipulatorDeviceDriver.java +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_manipulator/box_storage_manipulator/BoxStorageManipulatorDeviceDriver.java @@ -76,6 +76,7 @@ public class BoxStorageManipulatorDeviceDriver extends AbstractOpcDeviceDriver i int last_mode = 0; int move = 0; int action = 0; + int last_action = 0; int error = 0; int task = 0; int heartbeat = 0; @@ -99,6 +100,7 @@ public class BoxStorageManipulatorDeviceDriver extends AbstractOpcDeviceDriver i private int instruction_require_time_out = 3000; //行架机械手申请任务成功标识 boolean requireSucess = false; + boolean requireActionSucess = false; private int instruction_finished_time_out; @@ -149,11 +151,13 @@ public class BoxStorageManipulatorDeviceDriver extends AbstractOpcDeviceDriver i to_barcode = this.itemProtocol.getTo_barcode(); if (mode != last_mode) { - requireSucess = false; } + if(action == last_action){ + requireActionSucess = false; + } // 更新指令状态 - if (mode == 3 && task > 0) { + if (mode == 3 && task > 0 && !requireActionSucess) { updateInstructionStatus(); } @@ -191,7 +195,8 @@ public class BoxStorageManipulatorDeviceDriver extends AbstractOpcDeviceDriver i feedMessage = ""; } } else { - String remark = "";; + String remark = ""; + ; if (mode != 2) { remark = "universal_remark2"; } @@ -207,11 +212,13 @@ public class BoxStorageManipulatorDeviceDriver extends AbstractOpcDeviceDriver i if (requireSucess) { remark = "universal_remark5"; } - this.setNotCreateTaskMessage(remark); + this.setNotCreateInstMessage(remark); + //} } } last_mode =mode; + last_action = action; } @@ -233,8 +240,8 @@ public class BoxStorageManipulatorDeviceDriver extends AbstractOpcDeviceDriver i } } - //放货完成 - if (action == 4 && move == 0) { + //任务完成 + if (action == 5 && move == 0) { if (inst != null) { try { logServer.deviceExecuteLog(this.device_code, "", "", "放货完成"); @@ -245,6 +252,7 @@ public class BoxStorageManipulatorDeviceDriver extends AbstractOpcDeviceDriver i map1.put("value", 5); list.add(map1); this.writing(list); + requireActionSucess = true; message = "universal_message1"; } catch (Exception e) { message = "universal_message2"; @@ -351,7 +359,7 @@ public class BoxStorageManipulatorDeviceDriver extends AbstractOpcDeviceDriver i notCreateInstMessage = "universal_notCreateInstMessage1"; throw new BadRequestException("设备:" + nextDevice.getDevice_code() + "未设置电气调度号!"); } - //存在托盘才可以申请任务 + /*//存在托盘才可以申请任务 BeltConveyorDeviceDriver beltConveyorDeviceDriver; if (nextDevice.getDeviceDriver() instanceof BeltConveyorDeviceDriver) { beltConveyorDeviceDriver = (BeltConveyorDeviceDriver) nextDevice.getDeviceDriver(); @@ -359,7 +367,7 @@ public class BoxStorageManipulatorDeviceDriver extends AbstractOpcDeviceDriver i notCreateInstMessage = "universal_notCreateInstMessage2"; return false; } - } + }*/ String taskid = taskDto.getTask_id(); @@ -374,8 +382,11 @@ public class BoxStorageManipulatorDeviceDriver extends AbstractOpcDeviceDriver i instructionService.create(instdto); } catch (Exception e) { notCreateInstMessage = e.getMessage(); - logServer.deviceExecuteLog(this.getDevice_code(), "", "", "创建指令时出现异常:" + e.getMessage()); - return false; + LuceneLogDto logDto = LuceneLogDto.builder() + .device_code(device_code) + .content(device_code+"创建指令时出现异常:" + e.getMessage()) + .build(); + luceneExecuteLogService.deviceExecuteLog(logDto); return false; } //创建指令后修改任务状态 taskDto.setTask_status(TaskStatusEnum.BUSY.getIndex()); @@ -394,9 +405,11 @@ public class BoxStorageManipulatorDeviceDriver extends AbstractOpcDeviceDriver i try { pushPLC(map1, map2, next_addr, map3, start_addr, map4, instdto.getInstruction_code(), interactionJsonDTO, map5, map6, map7, map8, map9); } catch (Exception e) { - logServer.deviceExecuteLog(device_code, "", "", "当前设备:" + device_code + ",下发指令:" - + instdto.getInstruction_code() + ",指令起点:" + instdto.getStart_device_code() - + ",指令终点:" + instdto.getNext_device_code() + ",交互参数:" + interactionJsonDTO.toString() + ",指令执行失败:" + e.getMessage()); + LuceneLogDto logDto = LuceneLogDto.builder() + .device_code(device_code) + .content(device_code+"创建指令时出现异常:" + e.getMessage()) + .build(); + luceneExecuteLogService.deviceExecuteLog(logDto); } this.setRequireSucess(true); return true; @@ -451,6 +464,12 @@ public class BoxStorageManipulatorDeviceDriver extends AbstractOpcDeviceDriver i map9.put("value", interactionJsonDTO.getLayer()); list.add(map9); } + if (ObjectUtil.isNotEmpty(interactionJsonDTO.getContainerType())) { + Map map10 = new HashMap<>(); + map10.put("code", "to_type"); + map10.put("value", interactionJsonDTO.getContainerType()); + list.add(map10); + } } this.writing(list); } @@ -482,6 +501,11 @@ public class BoxStorageManipulatorDeviceDriver extends AbstractOpcDeviceDriver i itemMap.put(to_param, json.getString("value")); } } + LuceneLogDto logDto = LuceneLogDto.builder() + .device_code(device_code) + .content("下发多个电气信号" + itemMap) + .build(); + luceneExecuteLogService.deviceExecuteLog(logDto); logServer.deviceExecuteLog(device_code, "", "", "下发电气信号:" + itemMap); try { this.checkcontrol(itemMap); @@ -559,7 +583,7 @@ public class BoxStorageManipulatorDeviceDriver extends AbstractOpcDeviceDriver i jo.put("isError", this.getIserror()); jo.put("message", LangProcess.msg(message)); jo.put("notCreateTaskMessage", notCreateTaskMessage); - jo.put("notCreateInstMessage", notCreateInstMessage); + jo.put("notCreateInstMessage", LangProcess.msg(notCreateInstMessage)); jo.put("feedMessage", LangProcess.msg(feedMessage)); jo.put("driver_type", "box_storage_manipulator"); jo.put("is_click", true); diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_manipulator/box_storage_manipulator/InteractionJsonDTO.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_manipulator/box_storage_manipulator/InteractionJsonDTO.java index d791018fb..ff628b40b 100644 --- a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_manipulator/box_storage_manipulator/InteractionJsonDTO.java +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_manipulator/box_storage_manipulator/InteractionJsonDTO.java @@ -28,4 +28,90 @@ public class InteractionJsonDTO { */ private String layer; + /** + * 托盘类型 + */ + private String containerType; + + /** + * 是否拔轴 + */ + private String toPull; + + /** + * 是否套轴 + */ + private String isBushing; + + /** + * 气胀轴尺寸 + */ + private String toSize; + + /** + * 下发气胀轴条码 + */ + private String toBarcode; + + /** + * 套管纸管1编码 + */ + private String toMaterial1; + /** + * 套管纸管2编码 + */ + private String toMaterial2; + /** + * 套管纸管1规格 + */ + private String toSpec1; + /** + * 套管纸管2规格 + */ + private String toSpec2; + /** + * 套管纸管数量 + */ + private String toQty1; + /** + * 套管纸管1尺寸 + */ + private String toSize1; + /** + * 套管纸管2尺寸 + */ + private String toSize2; + /** + * 拔轴纸管1编码 + */ + private String toMaterial3; + /** + * 拔轴纸管2编码 + */ + private String toMaterial4; + /** + * 拔轴纸管1规格 + */ + private String toSpec3; + /** + * 拔轴纸管2规格 + */ + private String toSpec4; + /** + * 拔轴纸管数量 + */ + private String toQty2; + /** + * 拔轴纸管1尺寸 + */ + private String toSize3; + /** + * 拔轴纸管2尺寸 + */ + private String toSize4; + + + + + } diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_manipulator/return_good_manipulator/InteractionJsonDTO.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_manipulator/return_good_manipulator/InteractionJsonDTO.java index d5a90e47a..4cac17f62 100644 --- a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_manipulator/return_good_manipulator/InteractionJsonDTO.java +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_manipulator/return_good_manipulator/InteractionJsonDTO.java @@ -12,7 +12,7 @@ public class InteractionJsonDTO { /** *木箱宽度 */ - private String weight; + private String width; /** *木箱高度 */ diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_manipulator/return_good_manipulator/ItemProtocol.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_manipulator/return_good_manipulator/ItemProtocol.java index 9ee088013..2d8cd5f6b 100644 --- a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_manipulator/return_good_manipulator/ItemProtocol.java +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_manipulator/return_good_manipulator/ItemProtocol.java @@ -72,7 +72,7 @@ public class ItemProtocol { /** *木箱宽度 */ - public static String item_to_weight = "to_weight"; + public static String item_to_width = "to_width"; /** *木箱高度 */ @@ -209,7 +209,7 @@ public class ItemProtocol { list.add(new ItemDto(item_to_onset, "下发起始站", "DB2.W2")); list.add(new ItemDto(item_to_container_type, "下发托盘类型", "DB102.B8")); list.add(new ItemDto(item_to_length, "木箱长度", "DB601.W14")); - list.add(new ItemDto(item_to_weight, "木箱宽度", "DB601.W16")); + list.add(new ItemDto(item_to_width, "木箱宽度", "DB601.W16")); list.add(new ItemDto(item_to_height, "木箱高度", "DB601.W18")); list.add(new ItemDto(item_to_barcode, "下发木箱条码", "DB601.STRING1.50")); return list; diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_manipulator/return_good_manipulator/ReturnGoodManipulatorDeviceDriver.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_manipulator/return_good_manipulator/ReturnGoodManipulatorDeviceDriver.java index 5c413a60e..7379801ed 100644 --- a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_manipulator/return_good_manipulator/ReturnGoodManipulatorDeviceDriver.java +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_manipulator/return_good_manipulator/ReturnGoodManipulatorDeviceDriver.java @@ -43,6 +43,8 @@ import org.nl.common.exception.BadRequestException; import org.nl.common.utils.SecurityUtils; import org.nl.config.SpringContextHolder; import org.nl.config.language.LangProcess; +import org.nl.config.lucene.service.LuceneExecuteLogService; +import org.nl.config.lucene.service.dto.LuceneLogDto; import java.util.*; @@ -70,6 +72,8 @@ public class ReturnGoodManipulatorDeviceDriver extends AbstractOpcDeviceDriver i DeviceErrorLogService errorLogServer = SpringContextHolder.getBean(DeviceErrorLogServiceImpl.class); + LuceneExecuteLogService luceneExecuteLogService = SpringContextHolder.getBean("luceneExecuteLogServiceImpl"); + int mode = 0; int last_mode = 0; @@ -201,7 +205,8 @@ public class ReturnGoodManipulatorDeviceDriver extends AbstractOpcDeviceDriver i feedMessage = ""; } } else { - String remark = "";; + String remark = ""; + ; if (mode != 2) { remark = "universal_remark2"; } @@ -217,7 +222,8 @@ public class ReturnGoodManipulatorDeviceDriver extends AbstractOpcDeviceDriver i if (requireSucess) { remark = "universal_remark5"; } - this.setNotCreateTaskMessage(remark); + this.setNotCreateInstMessage(remark); + //} } } @@ -374,15 +380,15 @@ public class ReturnGoodManipulatorDeviceDriver extends AbstractOpcDeviceDriver i throw new BadRequestException("设备:" + nextDevice.getDevice_code() + "未设置电气调度号!"); } - //存在托盘才可以申请任务 + //存在托盘才可以申请任务 不需要这个逻辑,先下发行架任务后送空盘 BeltConveyorDeviceDriver beltConveyorDeviceDriver; - if (nextDevice.getDeviceDriver() instanceof BeltConveyorDeviceDriver) { - beltConveyorDeviceDriver = (BeltConveyorDeviceDriver) nextDevice.getDeviceDriver(); - if (beltConveyorDeviceDriver.getMove() != 1) { - notCreateInstMessage = "universal_notCreateInstMessage2"; - return false; - } - } +// if (nextDevice.getDeviceDriver() instanceof BeltConveyorDeviceDriver) { +// beltConveyorDeviceDriver = (BeltConveyorDeviceDriver) nextDevice.getDeviceDriver(); +// if (beltConveyorDeviceDriver.getMove() != 1) { +// notCreateInstMessage = "universal_notCreateInstMessage2"; +// return false; +// } +// } String taskid = taskDto.getTask_id(); String taskcode = taskDto.getTask_code(); String start_point_code = taskDto.getStart_point_code(); @@ -395,8 +401,11 @@ public class ReturnGoodManipulatorDeviceDriver extends AbstractOpcDeviceDriver i instructionService.create(instdto); } catch (Exception e) { notCreateInstMessage = e.getMessage(); - logServer.deviceExecuteLog(this.getDevice_code(), "", "", "创建指令时出现异常:" + e.getMessage()); - return false; + LuceneLogDto logDto = LuceneLogDto.builder() + .device_code(device_code) + .content(device_code+"创建指令时出现异常:" + e.getMessage()) + .build(); + luceneExecuteLogService.deviceExecuteLog(logDto); return false; } //创建指令后修改任务状态 taskDto.setTask_status(TaskStatusEnum.BUSY.getIndex()); @@ -415,9 +424,11 @@ public class ReturnGoodManipulatorDeviceDriver extends AbstractOpcDeviceDriver i try { pushPLC(map1, map2, next_addr, map3, start_addr, map4, instdto.getInstruction_code(), interactionJsonDTO, map5, map6, map7, map8, map9); } catch (Exception e) { - logServer.deviceExecuteLog(device_code, "", "", "当前设备:" + device_code + ",下发指令:" - + instdto.getInstruction_code() + ",指令起点:" + instdto.getStart_device_code() - + ",指令终点:" + instdto.getNext_device_code() + ",交互参数:" + interactionJsonDTO.toString() + ",指令执行失败:" + e.getMessage()); + LuceneLogDto logDto = LuceneLogDto.builder() + .device_code(device_code) + .content(device_code+"创建指令时出现异常:" + e.getMessage()) + .build(); + luceneExecuteLogService.deviceExecuteLog(logDto); } this.setRequireSucess(true); return true; @@ -445,13 +456,13 @@ public class ReturnGoodManipulatorDeviceDriver extends AbstractOpcDeviceDriver i map4.put("value", task); list.add(map4); if (ObjectUtil.isNotEmpty(interactionJsonDTO)) { - if (ObjectUtil.isNotEmpty(interactionJsonDTO.getWeight())) { - map5.put("code", "to_weight"); - map5.put("value", interactionJsonDTO.getWeight()); + if (ObjectUtil.isNotEmpty(interactionJsonDTO.getWidth())) { + map5.put("code", "to_width"); + map5.put("value", interactionJsonDTO.getWidth()); list.add(map5); } if (ObjectUtil.isNotEmpty(interactionJsonDTO.getLength())) { - map6.put("code", "to_lenght"); + map6.put("code", "to_length"); map6.put("value", interactionJsonDTO.getLength()); list.add(map6); } @@ -505,6 +516,11 @@ public class ReturnGoodManipulatorDeviceDriver extends AbstractOpcDeviceDriver i itemMap.put(to_param, json.getString("value")); } } + LuceneLogDto logDto = LuceneLogDto.builder() + .device_code(device_code) + .content("下发多个电气信号" + itemMap) + .build(); + luceneExecuteLogService.deviceExecuteLog(logDto); logServer.deviceExecuteLog(device_code, "", "", "下发电气信号:" + itemMap); try { this.checkcontrol(itemMap); @@ -582,7 +598,7 @@ public class ReturnGoodManipulatorDeviceDriver extends AbstractOpcDeviceDriver i jo.put("isError", this.getIserror()); jo.put("message", LangProcess.msg(message)); jo.put("notCreateTaskMessage", notCreateTaskMessage); - jo.put("notCreateInstMessage", notCreateInstMessage); + jo.put("notCreateInstMessage", LangProcess.msg(notCreateInstMessage)); jo.put("feedMessage", LangProcess.msg(feedMessage)); jo.put("driver_type", "siemens_conveyor"); jo.put("is_click", true); diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_manipulator/trapped_manipulator/InteractionJsonDTO.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_manipulator/trapped_manipulator/InteractionJsonDTO.java index bb572fea2..9150df957 100644 --- a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_manipulator/trapped_manipulator/InteractionJsonDTO.java +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_manipulator/trapped_manipulator/InteractionJsonDTO.java @@ -38,4 +38,9 @@ public class InteractionJsonDTO { */ private String isBinding; + /** + *木箱条码 + */ + private String barcode; + } diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_manipulator/trapped_manipulator/ItemProtocol.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_manipulator/trapped_manipulator/ItemProtocol.java index a128f1334..64a662e07 100644 --- a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_manipulator/trapped_manipulator/ItemProtocol.java +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_manipulator/trapped_manipulator/ItemProtocol.java @@ -102,7 +102,10 @@ public class ItemProtocol { */ public static String item_to_is_binding = "to_is_binding"; - + /** + * 下发木箱条码 + */ + public static String item_to_material = "to_material"; private TrappedManipulatorManipulatorDeviceDriver driver; @@ -223,6 +226,7 @@ public class ItemProtocol { list.add(new ItemDto(item_to_height, "木箱高度", "DB601.W14")); list.add(new ItemDto(item_to_template, "堆叠模板", "DB601.W16")); list.add(new ItemDto(item_to_is_binding, "下发是否捆轧", "DB601.D10")); + list.add(new ItemDto(item_to_material, "木箱条码", "DB601.D12")); return list; } diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_manipulator/trapped_manipulator/TrappedManipulatorManipulatorDeviceDriver.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_manipulator/trapped_manipulator/TrappedManipulatorManipulatorDeviceDriver.java index ce6240336..05972fa56 100644 --- a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_manipulator/trapped_manipulator/TrappedManipulatorManipulatorDeviceDriver.java +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_manipulator/trapped_manipulator/TrappedManipulatorManipulatorDeviceDriver.java @@ -1,7 +1,6 @@ package org.nl.acs.device_driver.one_manipulator.trapped_manipulator; import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.date.DateUtil; import cn.hutool.core.util.IdUtil; import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.StrUtil; @@ -17,9 +16,7 @@ import org.nl.acs.device.service.impl.DeviceExtraServiceImpl; import org.nl.acs.device_driver.DeviceDriver; import org.nl.acs.device_driver.FeedLmsRealFailed; import org.nl.acs.device_driver.RouteableDeviceDriver; -import org.nl.acs.device_driver.box_manipulator_site.BoxManipulatorSiteDeviceDriver; import org.nl.acs.device_driver.conveyor.belt_conveyor.BeltConveyorDeviceDriver; -import org.nl.acs.device_driver.conveyor.siemens_conveyor.SiemensConveyorDeviceDriver; import org.nl.acs.device_driver.driver.AbstractOpcDeviceDriver; import org.nl.acs.device_driver.driver.ExecutableDeviceDriver; import org.nl.acs.history.ErrorUtil; @@ -41,6 +38,8 @@ import org.nl.common.exception.BadRequestException; import org.nl.common.utils.SecurityUtils; import org.nl.config.SpringContextHolder; import org.nl.config.language.LangProcess; +import org.nl.config.lucene.service.LuceneExecuteLogService; +import org.nl.config.lucene.service.dto.LuceneLogDto; import java.util.*; @@ -67,6 +66,7 @@ public class TrappedManipulatorManipulatorDeviceDriver extends AbstractOpcDevice DeviceExtraService deviceExtraService = SpringContextHolder.getBean(DeviceExtraServiceImpl.class); DeviceErrorLogService errorLogServer = SpringContextHolder.getBean(DeviceErrorLogServiceImpl.class); + LuceneExecuteLogService luceneExecuteLogService = SpringContextHolder.getBean("luceneExecuteLogServiceImpl"); int mode = 0; @@ -199,12 +199,13 @@ public class TrappedManipulatorManipulatorDeviceDriver extends AbstractOpcDevice feedMessage = ""; } } else { - String remark = "";; + String remark = ""; + ; if (mode != 2) { - remark = remark + "工作模式(mode)不是待机状态,"; + remark = "universal_remark2"; } if (move != 0) { - remark = remark + "光电信号(move)为有货状态,"; + remark = "universal_remark3"; } if (task != 0) { remark = "universal_remark4"; @@ -215,7 +216,8 @@ public class TrappedManipulatorManipulatorDeviceDriver extends AbstractOpcDevice if (requireSucess) { remark = "universal_remark5"; } - this.setNotCreateTaskMessage(remark); + this.setNotCreateInstMessage(remark); + //} } } @@ -339,8 +341,9 @@ public class TrappedManipulatorManipulatorDeviceDriver extends AbstractOpcDevice Map map8 = new HashMap<>(); Map map9 = new HashMap<>(); Map map10 = new HashMap<>(); + Map map11 = new HashMap<>(); try { - pushPLC(map1, map2, next_addr, map3, start_addr, map4, instruction.getInstruction_code(), interactionJsonDTO, map5, map6, map7, map8, map9,map10); + pushPLC(map1, map2, next_addr, map3, start_addr, map4, instruction.getInstruction_code(), interactionJsonDTO, map5, map6, map7, map8, map9,map10,map11); } catch (Exception e) { logServer.deviceExecuteLog(device_code, "", "", "当前设备:" + device_code + ",下发指令:" + instruction.getInstruction_code() + ",指令起点:" + instruction.getStart_device_code() @@ -391,8 +394,11 @@ public class TrappedManipulatorManipulatorDeviceDriver extends AbstractOpcDevice instructionService.create(instdto); } catch (Exception e) { notCreateInstMessage = e.getMessage(); - logServer.deviceExecuteLog(this.getDevice_code(), "", "", "创建指令时出现异常:" + e.getMessage()); - return false; + LuceneLogDto logDto = LuceneLogDto.builder() + .device_code(device_code) + .content(device_code+"创建指令时出现异常:" + e.getMessage()) + .build(); + luceneExecuteLogService.deviceExecuteLog(logDto); return false; } //创建指令后修改任务状态 taskDto.setTask_status(TaskStatusEnum.BUSY.getIndex()); @@ -409,12 +415,15 @@ public class TrappedManipulatorManipulatorDeviceDriver extends AbstractOpcDevice Map map8 = new HashMap<>(); Map map9 = new HashMap<>(); Map map10 = new HashMap<>(); + Map map11 = new HashMap<>(); try { - pushPLC(map1, map2, next_addr, map3, start_addr, map4, instdto.getInstruction_code(), interactionJsonDTO, map5, map6, map7, map8, map9,map10); + pushPLC(map1, map2, next_addr, map3, start_addr, map4, instdto.getInstruction_code(), interactionJsonDTO, map5, map6, map7, map8, map9,map10, map11); } catch (Exception e) { - logServer.deviceExecuteLog(device_code, "", "", "当前设备:" + device_code + ",下发指令:" - + instdto.getInstruction_code() + ",指令起点:" + instdto.getStart_device_code() - + ",指令终点:" + instdto.getNext_device_code() + ",交互参数:" + interactionJsonDTO.toString() + ",指令执行失败:" + e.getMessage()); + LuceneLogDto logDto = LuceneLogDto.builder() + .device_code(device_code) + .content(device_code+"创建指令时出现异常:" + e.getMessage()) + .build(); + luceneExecuteLogService.deviceExecuteLog(logDto); } this.setRequireSucess(true); return true; @@ -429,7 +438,7 @@ public class TrappedManipulatorManipulatorDeviceDriver extends AbstractOpcDevice - private void pushPLC(Map map1, Map map2, String next_addr, Map map3, String start_addr, Map map4, String task, InteractionJsonDTO interactionJsonDTO, Map map5, Map map6, Map map7, Map map8, Map map9,Map map10) { + private void pushPLC(Map map1, Map map2, String next_addr, Map map3, String start_addr, Map map4, String task, InteractionJsonDTO interactionJsonDTO, Map map5, Map map6, Map map7, Map map8, Map map9, Map map10, Map map11) { List list = new ArrayList(); map1.put("code", "to_command"); @@ -475,6 +484,17 @@ public class TrappedManipulatorManipulatorDeviceDriver extends AbstractOpcDevice map10.put("value", interactionJsonDTO.getIsBinding()); list.add(map10); } + if (ObjectUtil.isNotEmpty(interactionJsonDTO.getIsBinding())) { + map11.put("code", "to_material"); + map11.put("value", interactionJsonDTO.getBarcode()); + list.add(map11); + } + Map map12 = new HashMap<>(); + if (ObjectUtil.isNotEmpty(interactionJsonDTO.getBindingTimes())) { + map12.put("code", "to_binding_times"); + map12.put("value", interactionJsonDTO.getBindingTimes()); + list.add(map12); + } } this.writing(list); @@ -521,6 +541,11 @@ public class TrappedManipulatorManipulatorDeviceDriver extends AbstractOpcDevice itemMap.put(to_param, json.getString("value")); } } + LuceneLogDto logDto = LuceneLogDto.builder() + .device_code(device_code) + .content("下发多个电气信号" + itemMap) + .build(); + luceneExecuteLogService.deviceExecuteLog(logDto); logServer.deviceExecuteLog(device_code, "", "", "下发电气信号:" + itemMap); try { this.checkcontrol(itemMap); @@ -592,7 +617,7 @@ public class TrappedManipulatorManipulatorDeviceDriver extends AbstractOpcDevice jo.put("isError", this.getIserror()); jo.put("message", LangProcess.msg(message)); jo.put("notCreateTaskMessage", notCreateTaskMessage); - jo.put("notCreateInstMessage", notCreateInstMessage); + jo.put("notCreateInstMessage", LangProcess.msg(notCreateInstMessage)); jo.put("feedMessage", LangProcess.msg(feedMessage)); jo.put("driver_type", "siemens_conveyor"); jo.put("is_click", true); diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_manipulator/volume_two_manipulator/VolumeTwoManipulatorManipulatorDeviceDriver.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_manipulator/volume_two_manipulator/VolumeTwoManipulatorManipulatorDeviceDriver.java index 3066521e8..ef6677728 100644 --- a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_manipulator/volume_two_manipulator/VolumeTwoManipulatorManipulatorDeviceDriver.java +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_manipulator/volume_two_manipulator/VolumeTwoManipulatorManipulatorDeviceDriver.java @@ -42,6 +42,8 @@ import org.nl.common.exception.BadRequestException; import org.nl.common.utils.SecurityUtils; import org.nl.config.SpringContextHolder; import org.nl.config.language.LangProcess; +import org.nl.config.lucene.service.LuceneExecuteLogService; +import org.nl.config.lucene.service.dto.LuceneLogDto; import java.util.*; @@ -69,6 +71,8 @@ public class VolumeTwoManipulatorManipulatorDeviceDriver extends AbstractOpcDevi DeviceErrorLogService errorLogServer = SpringContextHolder.getBean(DeviceErrorLogServiceImpl.class); + LuceneExecuteLogService luceneExecuteLogService = SpringContextHolder.getBean("luceneExecuteLogServiceImpl"); + int mode = 0; int last_mode = 0; @@ -217,6 +221,7 @@ public class VolumeTwoManipulatorManipulatorDeviceDriver extends AbstractOpcDevi } } else { String remark = ""; + ; if (mode != 2) { remark = "universal_remark2"; } @@ -232,7 +237,8 @@ public class VolumeTwoManipulatorManipulatorDeviceDriver extends AbstractOpcDevi if (requireSucess) { remark = "universal_remark5"; } - this.setNotCreateTaskMessage(remark); + this.setNotCreateInstMessage(remark); + //} } } @@ -294,16 +300,16 @@ public class VolumeTwoManipulatorManipulatorDeviceDriver extends AbstractOpcDevi } else { feedMessage = "universal_feedMessage5"; if (mode != 3) { - feedMessage = "universal_feedMessage1"; + feedMessage = "universal_feedMessage1"; } if (action != 8) { - feedMessage = "universal_feedMessage2"; + feedMessage = "universal_feedMessage2"; } if (move != 0) { - feedMessage = "universal_feedMessage3"; + feedMessage = "universal_feedMessage3"; } if (task == 0) { - feedMessage = "universal_feedMessage4"; + feedMessage = "universal_feedMessage4"; } } } @@ -357,16 +363,16 @@ public class VolumeTwoManipulatorManipulatorDeviceDriver extends AbstractOpcDevi Map map7 = new HashMap<>(); try { - pushPLC(map1, map2, next_addr, map3, start_addr, map4, instruction.getInstruction_code(), map5, map6,map7,taskDtoIns); + pushPLC(map1, map2, next_addr, map3, start_addr, map4, instruction.getInstruction_code(), map5, map6, map7, taskDtoIns); } catch (Exception e) { logServer.deviceExecuteLog(device_code, "", "", "当前设备:" + device_code + ",下发指令:" + instruction.getInstruction_code() + ",指令起点:" + instruction.getStart_device_code() - + ",指令终点:" + instruction.getNext_device_code() + ",指令执行失败:" + e.getMessage()); + + ",指令终点:" + instruction.getNext_device_code() + ",指令执行失败:" + e.getMessage()); } this.setRequireSucess(true); return true; } - }else { + } else { TaskDto taskDto = taskserver.findByStartCodeAndReady(startDeviceCode); if (ObjectUtil.isNotEmpty(taskDto) && TaskTypeEnum.Truss_Task.getIndex().equals(taskDto.getTask_type())) { String start_device_code = taskDto.getStart_device_code(); @@ -398,7 +404,7 @@ public class VolumeTwoManipulatorManipulatorDeviceDriver extends AbstractOpcDevi ManipulatorCacheDeviceDriver manipulatorCacheDeviceDriverStar; if (startDevice.getDeviceDriver() instanceof ManipulatorCacheDeviceDriver) { manipulatorCacheDeviceDriverStar = (ManipulatorCacheDeviceDriver) startDevice.getDeviceDriver(); - if (manipulatorCacheDeviceDriverStar.getMode() != 2 && manipulatorCacheDeviceDriverStar.getMode() !=1) { + if (manipulatorCacheDeviceDriverStar.getMode() != 2 && manipulatorCacheDeviceDriverStar.getMode() != 1) { notCreateInstMessage = "universal_notCreateInstMessage3"; return false; } @@ -407,7 +413,7 @@ public class VolumeTwoManipulatorManipulatorDeviceDriver extends AbstractOpcDevi ManipulatorCacheDeviceDriver manipulatorCacheDeviceDriverEnd; if (nextDevice.getDeviceDriver() instanceof ManipulatorCacheDeviceDriver) { manipulatorCacheDeviceDriverEnd = (ManipulatorCacheDeviceDriver) nextDevice.getDeviceDriver(); - if (manipulatorCacheDeviceDriverEnd.getMode() != 2 && manipulatorCacheDeviceDriverEnd.getMode() !=1) { + if (manipulatorCacheDeviceDriverEnd.getMode() != 2 && manipulatorCacheDeviceDriverEnd.getMode() != 1) { notCreateInstMessage = "universal_notCreateInstMessage3"; return false; } @@ -420,12 +426,16 @@ public class VolumeTwoManipulatorManipulatorDeviceDriver extends AbstractOpcDevi String next_point_code = taskDto.getNext_point_code(); String route_plan_code = taskDto.getRoute_plan_code(); Instruction instdto = new Instruction(); - packageData(instdto, route_plan_code, taskid, taskcode, start_device_code, next_device_code, start_point_code, next_point_code,start_device_code2,next_device_code2); + packageData(instdto, route_plan_code, taskid, taskcode, start_device_code, next_device_code, start_point_code, next_point_code, start_device_code2, next_device_code2); try { instructionService.create(instdto); } catch (Exception e) { notCreateInstMessage = e.getMessage(); - logServer.deviceExecuteLog(this.getDevice_code(), "", "", "创建指令时出现异常:" + e.getMessage()); + LuceneLogDto logDto = LuceneLogDto.builder() + .device_code(device_code) + .content(device_code + "创建指令时出现异常:" + e.getMessage()) + .build(); + luceneExecuteLogService.deviceExecuteLog(logDto); return false; } logServer.deviceExecuteLog(device_code, "", "", "当前设备:" + device_code + ",下发指令:" @@ -444,7 +454,7 @@ public class VolumeTwoManipulatorManipulatorDeviceDriver extends AbstractOpcDevi Map map6 = new HashMap<>(); Map map7 = new HashMap<>(); try { - pushPLC(map1, map2, next_addr, map3, start_addr, map4, instdto.getInstruction_code(), map5, map6,map7,taskDto); + pushPLC(map1, map2, next_addr, map3, start_addr, map4, instdto.getInstruction_code(), map5, map6, map7, taskDto); } catch (Exception e) { logServer.deviceExecuteLog(device_code, "", "", "当前设备:" + device_code + ",下发指令:" + instdto.getInstruction_code() + ",指令起点:" + instdto.getStart_device_code() @@ -553,6 +563,11 @@ public class VolumeTwoManipulatorManipulatorDeviceDriver extends AbstractOpcDevi itemMap.put(to_param, json.getString("value")); } } + LuceneLogDto logDto = LuceneLogDto.builder() + .device_code(device_code) + .content("下发多个电气信号" + itemMap) + .build(); + luceneExecuteLogService.deviceExecuteLog(logDto); logServer.deviceExecuteLog(device_code, "", "", "下发电气信号:" + itemMap); try { this.checkcontrol(itemMap); @@ -624,7 +639,7 @@ public class VolumeTwoManipulatorManipulatorDeviceDriver extends AbstractOpcDevi jo.put("isError", this.getIserror()); jo.put("message", LangProcess.msg(message)); jo.put("notCreateTaskMessage", notCreateTaskMessage); - jo.put("notCreateInstMessage", notCreateInstMessage); + jo.put("notCreateInstMessage", LangProcess.msg(notCreateInstMessage)); jo.put("feedMessage", LangProcess.msg(feedMessage)); jo.put("driver_type", "siemens_conveyor"); jo.put("is_click", true); diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/paper_tube_pick_site/ItemProtocol.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/paper_tube_pick_site/ItemProtocol.java index 680130d23..55d659e32 100644 --- a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/paper_tube_pick_site/ItemProtocol.java +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/paper_tube_pick_site/ItemProtocol.java @@ -25,10 +25,6 @@ public class ItemProtocol { public static String item_error = "error"; //物料 public static String item_material = "material"; - //物料直径 - public static String item_size = "size"; - //物料长度 - public static String item_len = "len"; //明细数量 public static String item_Itemized_qty = "Itemized_qty"; @@ -36,11 +32,9 @@ public class ItemProtocol { public static String item_to_command = "to_command"; //下发物料类型 public static String item_to_material = "to_material"; - //下发命令 - public static String item_to_size = "to_size"; - //下发命令 - public static String item_to_len = "to_len"; - //下发命令 + //下发物料规格 + public static String item_to_spec = "to_spec"; + //下发物料数量 public static String item_to_qty = "to_qty"; private PaperTubePickSiteDeviceDriver driver; @@ -75,13 +69,6 @@ public class ItemProtocol { return this.getOpcStringValue(item_material); } - public int getSize() { - return this.getOpcIntegerValue(item_size); - } - - public int getLen() { - return this.getOpcIntegerValue(item_len); - } public int getItemized_qty() { return this.getOpcIntegerValue(item_Itemized_qty); @@ -95,17 +82,6 @@ public class ItemProtocol { return this.getOpcStringValue(item_to_material); } - public int getTo_size() { - return this.getOpcIntegerValue(item_to_size); - } - - public int getTo_len() { - return this.getOpcIntegerValue(item_to_len); - } - - public int getTo_qty() { - return this.getOpcIntegerValue(item_to_qty); - } Boolean isonline; @@ -141,8 +117,6 @@ public class ItemProtocol { list.add(new ItemDto(item_error, "报警", "DB1001.B4")); list.add(new ItemDto(item_qty, "总数量", "DB1001.B5")); list.add(new ItemDto(item_material, "物料类型", "DB1.B6")); - list.add(new ItemDto(item_size, "物料直径", "DB1.B7")); - list.add(new ItemDto(item_len, "物料长度", "DB1.B8")); list.add(new ItemDto(item_Itemized_qty, "物料明细数量", "DB1.B9")); return list; } @@ -151,8 +125,7 @@ public class ItemProtocol { ArrayList list = new ArrayList(); list.add(new ItemDto(item_to_command, "下发命令", "DB2.W0")); list.add(new ItemDto(item_to_material, "下发物料类型", "DB2.W2")); - list.add(new ItemDto(item_to_size, "下发物料直径", "DB2.W4")); - list.add(new ItemDto(item_to_len, "下发物料长度", "DB2.W6")); + list.add(new ItemDto(item_to_spec, "下发物料规格", "DB2.W4")); list.add(new ItemDto(item_to_qty, "下发物料数量", "DB2.W8")); return list; } diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/paper_tube_pick_site/PaperTubePickSiteDeviceDriver.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/paper_tube_pick_site/PaperTubePickSiteDeviceDriver.java index 91a18ba9d..485f9f684 100644 --- a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/paper_tube_pick_site/PaperTubePickSiteDeviceDriver.java +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/paper_tube_pick_site/PaperTubePickSiteDeviceDriver.java @@ -73,12 +73,6 @@ public class PaperTubePickSiteDeviceDriver extends AbstractOpcDeviceDriver imple //物料类型 String material = null; String last_material = null; - //物料直径 - int size =0; - int last_size =0; - //物料长度 - int len = 0; - int last_len = 0; //物料明细数量 int Itemized_qty = 0; int last_Itemized_qty = 0; @@ -94,12 +88,9 @@ public class PaperTubePickSiteDeviceDriver extends AbstractOpcDeviceDriver imple //下发物料类型 String to_material =null; String last_to_material =null; - //下发物料直径 - int to_size = 0; - int last_to_size = 0; - //下发物料长度 - int to_len=0; - int last_to_len=0; + //下发物料规格 + int to_spec=0; + int last_to_spec=0; //下发物料数量 int to_qty=0; int last_to_qty=0; @@ -141,10 +132,6 @@ public class PaperTubePickSiteDeviceDriver extends AbstractOpcDeviceDriver imple this.writing(0); } } - if (move != last_move) { - } - if (error != last_error) { - } } catch (Exception var17) { return; } @@ -196,7 +183,17 @@ public class PaperTubePickSiteDeviceDriver extends AbstractOpcDeviceDriver imple } } - + last_mode = mode; + last_action = action; + last_move = move; + last_qty = qty; + last_error =error; + last_material = material; + last_Itemized_qty = Itemized_qty; + last_to_command = to_command; + last_to_spec = to_spec; + last_to_material = to_material; + last_to_qty = to_qty; } protected void thingToNothing() { diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/rgv/ItemProtocol.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/rgv/ItemProtocol.java index 50ae39e21..43faa8f6b 100644 --- a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/rgv/ItemProtocol.java +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/rgv/ItemProtocol.java @@ -1,5 +1,6 @@ package org.nl.acs.device_driver.rgv; +import cn.hutool.core.util.StrUtil; import lombok.Data; import lombok.extern.slf4j.Slf4j; import org.nl.acs.device.device_driver.standard_inspect.ItemDto; @@ -17,7 +18,7 @@ ItemProtocol { //工作模式 public static String item_mode = "mode"; //光电信号 - public static String item_move = "move"; + public static String item_move = "move1"; //动作信号 public static String item_action = "action"; //行走列 @@ -68,8 +69,8 @@ ItemProtocol { return this.getOpcIntegerValue(item_error); } - public int getBarcode() { - return this.getOpcIntegerValue(item_barcode); + public String getBarcode() { + return this.getOpcStringValue(item_barcode); } public int getTask() { @@ -90,8 +91,8 @@ ItemProtocol { } - public int getTo_sub_volume_no(){ - return this.getOpcIntegerValue(item_to_sub_volume_no); + public String getTo_sub_volume_no(){ + return this.getOpcStringValue(item_to_sub_volume_no); } Boolean isonline; @@ -108,6 +109,16 @@ ItemProtocol { return 0; } + public String getOpcStringValue(String protocol) { + String value = this.driver.getStringValue(protocol); + if (StrUtil.isBlank(value)) { + + } else { + return value; + } + return "0"; + } + public static List getReadableItemDtos() { ArrayList list = new ArrayList<>(); list.add(new ItemDto(item_heartbeat, "心跳", "DB1.B0")); diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/rgv/RgvDeviceDriver.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/rgv/RgvDeviceDriver.java index 4fec1bc98..87bee3b5c 100644 --- a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/rgv/RgvDeviceDriver.java +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/rgv/RgvDeviceDriver.java @@ -93,8 +93,8 @@ public class RgvDeviceDriver extends AbstractOpcDeviceDriver implements DeviceDr int task = 0; int last_task = 0; //气涨轴条码 - int barcode = 0; - int last_barcode = 0; + String barcode; + String last_barcode; int heartbeat = 0; @@ -109,8 +109,8 @@ public class RgvDeviceDriver extends AbstractOpcDeviceDriver implements DeviceDr int last_to_task = 0; - int to_sub_volume_no = 0; - int last_to_sub_volume_no = 0; + String to_sub_volume_no; + String last_to_sub_volume_no; Boolean isonline = true; int hasGoods = 0; @@ -218,13 +218,13 @@ public class RgvDeviceDriver extends AbstractOpcDeviceDriver implements DeviceDr remark = "universal_remark3"; } if (task != 0) { - remark = remark + LangProcess.msg("universal_remark4"); + remark = LangProcess.msg("universal_remark4"); if (ObjectUtil.isNotEmpty(this.inst)) { this.inst = null; } } if (requireSucess) { - remark = remark + LangProcess.msg("universal_remark5"); + remark = LangProcess.msg("universal_remark5"); } this.setNotCreateTaskMessage(remark); //} @@ -264,10 +264,14 @@ public class RgvDeviceDriver extends AbstractOpcDeviceDriver implements DeviceDr if (applyManipulatorActionResponse.getCode() == 200) { Map data = applyManipulatorActionResponse.getData(); String point_code2 = data.get("point_code2");//目标站点 + Device deviceByCode = deviceAppService.findDeviceByCode(point_code2); + String address = deviceByCode.getExtraValue().get("address").toString(); String material_code = data.get("material_code");//子卷号 - map.put("to_target", point_code2); + String to_is_labeling = data.get("to_is_labeling");//是否贴标 + map.put("to_target", address); map.put("to_sub_volume_no", material_code); map.put("to_command", "1"); + map.put("to_is_labeling",StrUtil.isNotEmpty(to_is_labeling)?"0":"1"); this.writing(map); logServer.deviceExecuteLog(this.device_code, "", "", "申请行架任务,返回参数:" + applyManipulatorActionResponse); message = "申请行架任务成功"; @@ -353,7 +357,7 @@ public class RgvDeviceDriver extends AbstractOpcDeviceDriver implements DeviceDr jo.put("isError", this.getIserror()); jo.put("message", LangProcess.msg(message)); jo.put("notCreateTaskMessage", notCreateTaskMessage); - jo.put("notCreateInstMessage", notCreateInstMessage); + jo.put("notCreateInstMessage", LangProcess.msg(notCreateInstMessage)); jo.put("feedMessage", LangProcess.msg(feedMessage)); jo.put("driver_type", "siemens_conveyor"); jo.put("is_click", true); diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/stacker/standard_stacker/ItemProtocol.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/stacker/standard_stacker/ItemProtocol.java index 7b40ef7ee..6ff248ff1 100644 --- a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/stacker/standard_stacker/ItemProtocol.java +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/stacker/standard_stacker/ItemProtocol.java @@ -39,7 +39,7 @@ public class ItemProtocol { /** * y轴报警(载货台) */ - public static String item_error = "error"; + public static String item_error = "Error"; /** * 行走排号 diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/stacker/standard_stacker/StandardStackerDeviceDriver.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/stacker/standard_stacker/StandardStackerDeviceDriver.java index 5de581358..976cf66ce 100644 --- a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/stacker/standard_stacker/StandardStackerDeviceDriver.java +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/stacker/standard_stacker/StandardStackerDeviceDriver.java @@ -323,7 +323,10 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme storage_cache = this.itemProtocol.getItem_storage_cache(); if (!command.equals(last_command)){ - requireSucess=false; + requireSucess=true; + if (command==0){ + clearWrite(); + } } @@ -493,7 +496,7 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme message = "universal_releasing_completed"; Map map = new HashMap<>(); map.put("code", "to_command"); - map.put("value", 5); + map.put("value", 11); list.add(map); Instruction inst = checkInst(); try { @@ -532,7 +535,7 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme requireSucess = true; break; } - if (ObjectUtil.isNotNull(list)) { + if (list.size() != 0) { this.writing(list); } @@ -666,6 +669,33 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme } } + public void clearWrite() { + List list = new ArrayList<>(); + Map map = new HashMap<>(); + map.put("code","to_x"); + map.put("value","0"); + list.add(map); + Map map2 = new HashMap<>(); + map2.put("code","to_y"); + map2.put("value","0"); + list.add(map2); + Map map3 = new HashMap<>(); + map3.put("code","to_z"); + map3.put("value","0"); + list.add(map3); + Map map4 = new HashMap<>(); + map4.put("code","to_command"); + map4.put("value","0"); + list.add(map4); + Map map5 = new HashMap<>(); + map4.put("code","to_task"); + map4.put("value","0"); + list.add(map4); + + this.writing(list); + message=null; + } + private void updateData2(String poinCode, Instruction instruction, Device point, String[] split) { Instruction instructionUpdate = checkInst(); TaskDto taskUpdate = new TaskDto(); @@ -979,8 +1009,31 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme if (this.requireSucess) { requireSucess = "1"; } + String command = ""; + if(this.command == 0){ + command = "待机"; + }else if(this.command == 1){ + command = "取货中"; + }else if(this.command == 2){ + command = "取货完成"; + }else if(this.command == 3){ + command = "放货中"; + }else if(this.command == 4){ + command = "请求卸货(申请卸货)"; + }else if(this.command == 5){ + command = "放货完成"; + }else if(this.command == 6){ + command = "取货准备(回库台)"; + }else if(this.command == 7){ + command = "召回"; + }else if(this.command == 8){ + command = "急停"; + }else if(this.command == 9){ + command = "未知"; + } jo.put("mode", mode); jo.put("move", move); + jo.put("command", command); jo.put("action", action); jo.put("task", task); jo.put("error", this.getError()); @@ -990,7 +1043,7 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme jo.put("stopReceiveTask", this.stopReceiveTask); jo.put("requireSucess", requireSucess); jo.put("driver_type", "standard_stacker"); - jo.put("notCreateInstMessage", notCreateInstMessage); + jo.put("notCreateInstMessage", notCreateInstMessage); return jo; } diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/storage/standard_storage/StandardStorageDefination.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/storage/standard_storage/StandardStorageDefination.java index f400fe9bc..1d459d91b 100644 --- a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/storage/standard_storage/StandardStorageDefination.java +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/storage/standard_storage/StandardStorageDefination.java @@ -1,9 +1,11 @@ package org.nl.acs.device_driver.storage.standard_storage; +import org.nl.acs.device.device_driver.standard_inspect.ItemDto; import org.nl.acs.device.domain.Device; import org.nl.acs.device_driver.DeviceDriver; import org.nl.acs.device_driver.DeviceDriverDefination; import org.nl.acs.device.enums.DeviceType; +import org.nl.acs.device_driver.defination.OpcDeviceDriverDefination; import org.springframework.stereotype.Service; import java.util.LinkedList; diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/storage/standard_storage/StandardStorageDeviceDriver.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/storage/standard_storage/StandardStorageDeviceDriver.java index 4311addfb..03f4e86a1 100644 --- a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/storage/standard_storage/StandardStorageDeviceDriver.java +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/storage/standard_storage/StandardStorageDeviceDriver.java @@ -1,11 +1,14 @@ package org.nl.acs.device_driver.storage.standard_storage; +import com.alibaba.fastjson.JSONObject; import lombok.Data; import lombok.extern.slf4j.Slf4j; import org.nl.acs.device_driver.DeviceDriver; import org.nl.acs.device_driver.RouteableDeviceDriver; import org.nl.acs.device_driver.StorageDeviceDriver; import org.nl.acs.device_driver.driver.AbstractDeviceDriver; +import org.nl.acs.monitor.DeviceStageMonitor; +import org.nl.config.language.LangProcess; /** @@ -13,7 +16,7 @@ import org.nl.acs.device_driver.driver.AbstractDeviceDriver; */ @Slf4j @Data -public class StandardStorageDeviceDriver extends AbstractDeviceDriver implements RouteableDeviceDriver, StorageDeviceDriver, DeviceDriver { +public class StandardStorageDeviceDriver extends AbstractDeviceDriver implements RouteableDeviceDriver, StorageDeviceDriver, DeviceDriver, DeviceStageMonitor { public StandardStorageDeviceDriver() { } @@ -29,7 +32,18 @@ public class StandardStorageDeviceDriver extends AbstractDeviceDriver implements public boolean fixTypes(Integer type) { return true; } + @Override + public JSONObject getDeviceStatusName() throws Exception { + JSONObject jo = new JSONObject(); + jo.put("mode", 2); + jo.put("isOnline", true); + return jo; + } + @Override + public void setDeviceStatus(JSONObject data) { + + } } diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/blank_manipulator/BlankManipulatorDeviceDriver.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/blank_manipulator/BlankManipulatorDeviceDriver.java index 2a05cd40d..8e76f6a72 100644 --- a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/blank_manipulator/BlankManipulatorDeviceDriver.java +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/blank_manipulator/BlankManipulatorDeviceDriver.java @@ -139,6 +139,12 @@ public class BlankManipulatorDeviceDriver extends AbstractOpcDeviceDriver implem int to_onset = 0; int last_to_onset = 0; + int to_onset2 = 0; + int last_to_onset2 = 0; + + int to_target2 = 0; + int last_to_target2 = 0; + Boolean isonline = true; int hasGoods = 0; String message = null; @@ -226,6 +232,7 @@ public class BlankManipulatorDeviceDriver extends AbstractOpcDeviceDriver implem if (StrUtil.equals(inst.getInstruction_status(), CommonFinalParam.ZERO)) { inst.setInstruction_status(CommonFinalParam.ONE); inst.setExecute_device_code(this.device_code); + inst.setUpdate_time(DateUtil.now()); instructionService.update(inst); } } @@ -387,6 +394,8 @@ public class BlankManipulatorDeviceDriver extends AbstractOpcDeviceDriver implem last_to_command = to_command; last_to_target = to_target; last_to_onset = to_onset; + last_to_target2 = to_target2; + last_to_onset2 = to_onset2; last_weight = weight; last_barcode = barcode; } @@ -417,9 +426,8 @@ public class BlankManipulatorDeviceDriver extends AbstractOpcDeviceDriver implem Instruction instruction = instructionService.findByTaskcode(taskDto.getTask_code()); String startCode = instruction.getStart_device_code(); String nextCode = instruction.getNext_device_code(); - instruction.setInstruction_status(InstructionStatusEnum.BUSY.getIndex()); - instruction.setUpdate_time(DateUtil.now()); - instructionService.update(instruction); + String startCode2 = instruction.getStart_device_code2(); + String nextCode2 = instruction.getNext_device_code2(); Device startDevice = deviceAppService.findDeviceByCode(startCode); Device nextDevice = deviceAppService.findDeviceByCode(nextCode); if (ObjectUtil.isEmpty(startDevice.getExtraValue().get("address"))) { @@ -431,10 +439,25 @@ public class BlankManipulatorDeviceDriver extends AbstractOpcDeviceDriver implem String startAddr = startDevice.getExtraValue().get("address").toString(); String nextAddr = nextDevice.getExtraValue().get("address").toString(); Map map = new LinkedHashMap<>(); - map.put("to_command", CommonFinalParam.ONE); map.put("to_onset", startAddr); map.put("to_task", instruction.getInstruction_code()); map.put("to_target", nextAddr); + map.put("to_command", CommonFinalParam.ONE); + + if (StrUtil.isNotEmpty(startCode2)){ + Device startDevice2 = deviceAppService.findDeviceByCode(startCode2); + Device nextDevice2 = deviceAppService.findDeviceByCode(nextCode2); + if (ObjectUtil.isEmpty(startDevice2.getExtraValue().get("address"))) { + throw new BadRequestException(LangProcess.msg("device_checkAdd", startDevice.getDevice_code())); + } + if (ObjectUtil.isEmpty(nextDevice2.getExtraValue().get("address"))) { + throw new BadRequestException(LangProcess.msg("device_checkAdd", nextDevice.getDevice_code())); + } + String start_addr2 = startDevice2.getExtraValue().get("address").toString(); + String next_addr2 = nextDevice2.getExtraValue().get("address").toString(); + map.put("to_onset2", start_addr2); + map.put("to_target2", next_addr2); + } this.writing(map); this.setRequireSucess(true); return true; @@ -460,6 +483,8 @@ public class BlankManipulatorDeviceDriver extends AbstractOpcDeviceDriver implem String routePlanCode = task.getRoute_plan_code(); String nextPointCode = task.getNext_point_code(); String nextDeviceCode = task.getNext_device_code(); + String startDeviceCode2 = task.getStart_device_code2(); + String nextDeviceCode2 = task.getNext_device_code2(); Instruction instdto = new Instruction(); instdto.setInstruction_id(IdUtil.simpleUUID()); @@ -481,22 +506,7 @@ public class BlankManipulatorDeviceDriver extends AbstractOpcDeviceDriver implem instdto.setInstruction_status(InstructionStatusEnum.READY.getIndex()); instdto.setExecute_device_code(startPointCode); - try { - instructionService.create(instdto); - } catch (Exception e) { - notCreateInstMessage = e.getMessage(); - LuceneLogDto logDto = LuceneLogDto.builder() - .device_code(device_code) - .content(LangProcess.msg("universal_message9") + e.getMessage()) - .build(); - luceneExecuteLogService.deviceExecuteLog(logDto); - return false; - } - //创建指令后修改任务状态 - task.setTask_status(TaskStatusEnum.BUSY.getIndex()); - task.setUpdate_time(DateUtil.now()); - taskserver.update(task); - + Map map = new LinkedHashMap<>(); Device startDevice = deviceAppService.findDeviceByCode(instdto.getStart_device_code()); Device nextDevice = deviceAppService.findDeviceByCode(instdto.getNext_device_code()); if (ObjectUtil.isEmpty(startDevice.getExtraValue().get("address"))) { @@ -520,11 +530,46 @@ public class BlankManipulatorDeviceDriver extends AbstractOpcDeviceDriver implem } String startAddr = startDevice.getExtraValue().get("address").toString(); String nextAddr = nextDevice.getExtraValue().get("address").toString(); - Map map = new LinkedHashMap<>(); map.put("to_command", CommonFinalParam.ONE); map.put("to_onset", startAddr); map.put("to_task", instdto.getInstruction_code()); map.put("to_target", nextAddr); + + if (StrUtil.isNotEmpty(startDeviceCode2)){ + //判断任务点位是否配置电气信号 + Device startDevice2 = deviceAppService.findDeviceByCode(startDeviceCode2); + Device nextDevice2 = deviceAppService.findDeviceByCode(nextDeviceCode2); + if (ObjectUtil.isEmpty(startDevice2.getExtraValue().get("address"))) { + throw new BadRequestException(LangProcess.msg("device_checkAdd", startDevice2.getDevice_code())); + } + if (ObjectUtil.isEmpty(nextDevice2.getExtraValue().get("address"))) { + throw new BadRequestException(LangProcess.msg("device_checkAdd", nextDevice2.getDevice_code())); + } + String start_addr2 = startDevice2.getExtraValue().get("address").toString(); + String next_addr2 = nextDevice2.getExtraValue().get("address").toString(); + instdto.setStart_device_code2(startDeviceCode2); + instdto.setNext_device_code2(nextDeviceCode2); + instdto.setStart_point_code2(startDeviceCode2); + instdto.setNext_point_code2(nextDeviceCode2); + map.put("to_onset2", start_addr2); + map.put("to_target2", next_addr2); + } + try { + instructionService.create(instdto); + } catch (Exception e) { + notCreateInstMessage = e.getMessage(); + LuceneLogDto logDto = LuceneLogDto.builder() + .device_code(device_code) + .content(LangProcess.msg("universal_message9") + e.getMessage()) + .build(); + luceneExecuteLogService.deviceExecuteLog(logDto); + return false; + } + //创建指令后修改任务状态 + task.setTask_status(TaskStatusEnum.BUSY.getIndex()); + task.setUpdate_time(DateUtil.now()); + taskserver.update(task); + this.writing(map); this.setRequireSucess(true); notCreateInstMessage = ""; @@ -650,7 +695,7 @@ public class BlankManipulatorDeviceDriver extends AbstractOpcDeviceDriver implem jo.put("isError", this.getIserror()); jo.put("message", LangProcess.msg(message)); jo.put("notCreateTaskMessage", notCreateTaskMessage); - jo.put("notCreateInstMessage", notCreateInstMessage); + jo.put("notCreateInstMessage", LangProcess.msg(notCreateInstMessage)); jo.put("feedMessage", LangProcess.msg(feedMessage)); jo.put("driver_type", "siemens_conveyor"); jo.put("is_click", true); diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/blank_manipulator/ItemProtocol.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/blank_manipulator/ItemProtocol.java index 1d9615135..10b818b6e 100644 --- a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/blank_manipulator/ItemProtocol.java +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/blank_manipulator/ItemProtocol.java @@ -38,6 +38,10 @@ public class ItemProtocol { public static String item_to_onset = "to_onset"; //下发目标站 public static String item_to_target = "to_target"; + //下发起始站 + public static String item_to_onset2 = "to_onset2"; + //下发目标站 + public static String item_to_target2 = "to_target2"; //下发任务号 public static String item_to_task = "to_task"; @@ -99,6 +103,14 @@ public class ItemProtocol { return this.getOpcIntegerValue(item_to_target); } + public int getTo_onset2() { + return this.getOpcIntegerValue(item_to_onset2); + } + + public int getTo_target2() { + return this.getOpcIntegerValue(item_to_target2); + } + Boolean isonline; Boolean isError; @@ -149,6 +161,8 @@ public class ItemProtocol { list.add(new ItemDto(item_to_command, "下发命令", "DB2.W0")); list.add(new ItemDto(item_to_onset, "下发起始站", "DB2.W2")); list.add(new ItemDto(item_to_target, "下发目标站", "DB2.W4")); + list.add(new ItemDto(item_to_onset2, "下发起始站2", "DB2.W3")); + list.add(new ItemDto(item_to_target2, "下发目标站2", "DB2.W5")); list.add(new ItemDto(item_to_task, "下发任务号", "DB2.D6")); return list; } diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/green_foil_machine_button/GreenFoilMachineButtonDriver.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/green_foil_machine_button/GreenFoilMachineButtonDriver.java index 8239b524c..7e8081ce0 100644 --- a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/green_foil_machine_button/GreenFoilMachineButtonDriver.java +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/green_foil_machine_button/GreenFoilMachineButtonDriver.java @@ -88,6 +88,11 @@ public class GreenFoilMachineButtonDriver extends AbstractOpcDeviceDriver implem public int lastMove = 0; public int lastAction = 0; public int lastError = 0; + int to_command = 0; + int last_to_command = 0; + + int to_error = 0; + int last_to_error = 0; Boolean isonline = true; @@ -117,6 +122,8 @@ public class GreenFoilMachineButtonDriver extends AbstractOpcDeviceDriver implem action = this.itemProtocol.getItem_action(); error = this.itemProtocol.getItem_error(); iserror = this.itemProtocol.isError; + to_command = this.itemProtocol.getItem_to_command(); + to_error = this.itemProtocol.getItem_error(); if (mode != lastMode) { requireSucess = false; @@ -134,7 +141,7 @@ public class GreenFoilMachineButtonDriver extends AbstractOpcDeviceDriver implem } else if (error != 0) { this.setIserror(true); message = "universal_message3"; - }else { + } else { this.setIsonline(true); this.setIserror(false); message = ""; @@ -175,11 +182,12 @@ public class GreenFoilMachineButtonDriver extends AbstractOpcDeviceDriver implem } - lastMode = mode; lastMove = move; lastAction = action; lastError = error; + last_to_error = to_error; + last_to_command = to_command; } @@ -203,20 +211,20 @@ public class GreenFoilMachineButtonDriver extends AbstractOpcDeviceDriver implem if (ObjectUtil.isEmpty(response)) { message = "two_message18"; } else { - if (response.getCode()== CommonFinalParam.STATUS_OPEN) { - if (mode==4){ - this.writing("to_command","4"); - }else if (mode==5){ - this.writing("to_command","5"); - }else if (mode==9){ - this.writing("to_command","9"); + if (response.getCode() == CommonFinalParam.STATUS_OPEN) { + if (mode == 4) { + this.writing("to_command", "4"); + } else if (mode == 5) { + this.writing("to_command", "5"); + } else if (mode == 9) { + this.writing("to_command", "9"); } message = "two_message19"; requireSucess = true; } else { requireSucess = false; message = "two_message20" + response.getMessage(); - this.writing("to_command","99"); + this.writing("to_command", "99"); } } } @@ -224,8 +232,6 @@ public class GreenFoilMachineButtonDriver extends AbstractOpcDeviceDriver implem } - - public void writing(String param, String value) { String to_param = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() @@ -277,14 +283,12 @@ public class GreenFoilMachineButtonDriver extends AbstractOpcDeviceDriver implem requireSucess = "1"; } jo.put("requireSucess", requireSucess); - if (this.getAction() == 1) { - action = "取货中"; + if (this.getAction() == 0) { + action = "不允许取放"; + } else if (this.getAction() == 1) { + action = "允许取放"; } else if (this.getAction() == 2) { - action = "取货完成"; - } else if (this.getAction() == 3) { - action = "放货中"; - } else if (this.getAction() == 4) { - action = "放货完成"; + action = "允许离开"; } jo.put("device_name", this.getDevice().getDevice_name()); diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/green_foil_machine_button/ItemProtocol.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/green_foil_machine_button/ItemProtocol.java index f39c57e1b..66352ac60 100644 --- a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/green_foil_machine_button/ItemProtocol.java +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/green_foil_machine_button/ItemProtocol.java @@ -20,6 +20,7 @@ public class ItemProtocol { public static String item_to_command = "to_command"; + public static String item_to_error = "to_error"; private GreenFoilMachineButtonDriver driver; @@ -42,6 +43,9 @@ public class ItemProtocol { }; public int getItem_error(){ return this.getOpcIntegerValue(item_error); + } + public int getItem_to_command(){ + return this.getOpcIntegerValue(item_to_error); } ; Boolean isonline; @@ -89,6 +93,7 @@ public class ItemProtocol { public static List getWriteableItemDtos() { ArrayList list = new ArrayList(); list.add(new ItemDto(item_to_command, "下发命令", "DB6.W0")); + list.add(new ItemDto(item_to_error, "下发故障代码", "DB6.W1")); return list; } diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/hongxiang_device/HongXiangConveyorDeviceDriver.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/hongxiang_device/HongXiangConveyorDeviceDriver.java index a9a469c36..1a560176f 100644 --- a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/hongxiang_device/HongXiangConveyorDeviceDriver.java +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/hongxiang_device/HongXiangConveyorDeviceDriver.java @@ -282,6 +282,37 @@ public class HongXiangConveyorDeviceDriver extends AbstractOpcDeviceDriver imple } } + + public void writing(List list) { + Map itemMap = new HashMap(); + for (int i = 0; i < list.size(); i++) { + Object ob = list.get(i); + JSONObject json = (JSONObject) JSONObject.toJSON(ob); + if (!StrUtil.isEmpty(json.getString("value"))) { + String to_param = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() + + "." + json.getString("code"); + itemMap.put(to_param, json.getString("value")); + } + } + LuceneLogDto logDto = LuceneLogDto.builder() + .device_code(device_code) + .content("下发电气信号:" + itemMap) + .build(); + luceneExecuteLogService.deviceExecuteLog(logDto); + logServer.deviceExecuteLog(device_code, "", "", "下发电气信号:" + itemMap); + try { + this.checkcontrol(itemMap); + } catch (Exception e) { + e.printStackTrace(); + try { + this.checkcontrol(itemMap); + } catch (Exception e1) { + e1.printStackTrace(); + } + } + + } + //将扩展表中的字符串数据转换成集合 @Override public List getExtraDeviceCodes(String extraName) { diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/inflatable_shaft_library/InflatableShaftLibraryDeviceDriver.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/inflatable_shaft_library/InflatableShaftLibraryDeviceDriver.java index 978abdc7a..75d8cbe0f 100644 --- a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/inflatable_shaft_library/InflatableShaftLibraryDeviceDriver.java +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/inflatable_shaft_library/InflatableShaftLibraryDeviceDriver.java @@ -113,6 +113,7 @@ public class InflatableShaftLibraryDeviceDriver extends AbstractOpcDeviceDriver requireSucess = false; } + lastMode = mode; lastMove = move; lastAction = action; diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/inflatable_shaft_library/ItemProtocol.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/inflatable_shaft_library/ItemProtocol.java index d628151a1..0f4496203 100644 --- a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/inflatable_shaft_library/ItemProtocol.java +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/inflatable_shaft_library/ItemProtocol.java @@ -13,11 +13,11 @@ import java.util.List; public class ItemProtocol { public static String item_heartbeat = "heartbeat"; public static String item_mode = "mode"; - public static String item_move = "move"; - public static String item_action = "action"; + public static String item_move = "move1"; + public static String item_action = "action1"; public static String item_error = "error"; public static String item_qty = "qty"; - public static String item_type = "type"; + public static String item_type = "type1"; public static String item_to_command = "to_command"; diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/oven_manipulator/OvenGantryManipulatorDeviceDriver.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/oven_manipulator/OvenGantryManipulatorDeviceDriver.java index 39343de36..a133afd82 100644 --- a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/oven_manipulator/OvenGantryManipulatorDeviceDriver.java +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/oven_manipulator/OvenGantryManipulatorDeviceDriver.java @@ -43,9 +43,11 @@ import org.nl.config.SpringContextHolder; import org.nl.config.language.LangProcess; import org.nl.config.lucene.service.LuceneExecuteLogService; import org.nl.config.lucene.service.dto.LuceneLogDto; +import org.nl.config.thread.ThreadPoolExecutorUtil; import org.springframework.beans.factory.annotation.Autowired; import java.util.*; +import java.util.concurrent.ThreadPoolExecutor; /** * 烘箱-行架机械手 @@ -76,6 +78,8 @@ public class OvenGantryManipulatorDeviceDriver extends AbstractOpcDeviceDriver i @Autowired LuceneExecuteLogService luceneExecuteLogService = SpringContextHolder.getBean(LuceneExecuteLogService.class); + final ThreadPoolExecutor EXECUTOR = ThreadPoolExecutorUtil.getPoll(); + //工作模式 int mode = 0; int last_mode = 0; @@ -128,6 +132,8 @@ public class OvenGantryManipulatorDeviceDriver extends AbstractOpcDeviceDriver i private int instruction_require_time_out = 3000; //行架机械手申请任务成功标识 boolean requireSucess = false; + //行架机械手申请动作成功标识 + boolean requireActionSucess = false; private int instruction_finished_time_out; @@ -179,12 +185,16 @@ public class OvenGantryManipulatorDeviceDriver extends AbstractOpcDeviceDriver i y_position = this.itemProtocol.getY_position(); iserror = this.itemProtocol.device_status; - if(mode != last_mode){ + if (mode != last_mode) { requireSucess = false; } + if (action != last_action) { + requireActionSucess = false; + } - - update_instruction_status(); + if (!requireActionSucess) { + update_instruction_status(); + } } catch (Exception var17) { var17.printStackTrace(); @@ -219,7 +229,7 @@ public class OvenGantryManipulatorDeviceDriver extends AbstractOpcDeviceDriver i } else { if (mode == 2) { //if (!requireSucess) { - String remark = "";; + String remark = ""; if (mode != 2) { remark = remark + "工作模式(mode)不是待机状态,"; } @@ -293,7 +303,9 @@ public class OvenGantryManipulatorDeviceDriver extends AbstractOpcDeviceDriver i if (ObjectUtil.isEmpty(putDeviceCodeList)) { putDeviceCodeList = this.getExtraDeviceCodes("put_device_code"); } - + if(CollUtil.isEmpty(getDeviceCodeList) || getDeviceCodeList.size() == 0){ + notCreateInstMessage = "未设置取货点"; + } TaskDto task = null; for (int i = 0; i < getDeviceCodeList.size(); i++) { String startDeviceCode = getDeviceCodeList.get(i); @@ -318,7 +330,7 @@ public class OvenGantryManipulatorDeviceDriver extends AbstractOpcDeviceDriver i HongXiangConveyorDeviceDriver hongXiangConveyorDeviceDriver; StandardInspectSiteDeviceDriver standardInspectSiteDeviceDriver; OvenInspectSiteDeviceDriver ovenInspectSiteDeviceDriver; - if (startdevice.getDeviceDriver() instanceof OvenInspectSiteDeviceDriver && nextdevice.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) { + /*if (startdevice.getDeviceDriver() instanceof OvenInspectSiteDeviceDriver && nextdevice.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) { ovenInspectSiteDeviceDriver = (OvenInspectSiteDeviceDriver) startdevice.getDeviceDriver(); standardInspectSiteDeviceDriver = (StandardInspectSiteDeviceDriver) nextdevice.getDeviceDriver(); if (ovenInspectSiteDeviceDriver.getMove() != 1 || standardInspectSiteDeviceDriver.getMove() == 1) { @@ -347,7 +359,7 @@ public class OvenGantryManipulatorDeviceDriver extends AbstractOpcDeviceDriver i notCreateInstMessage = "手动创建指令未下发电气信号原因->取货位:" + start_device_code + ",放货位:" + next_device_code + ",存在关联的同一列烘箱设备未关门!指令号:" + instruction.getInstruction_code(); return false; } - } + }*/ if (startdevice.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) { standardInspectSiteDeviceDriver = (StandardInspectSiteDeviceDriver) startdevice.getDeviceDriver(); if (standardInspectSiteDeviceDriver.getMove() != 1) { @@ -424,14 +436,15 @@ public class OvenGantryManipulatorDeviceDriver extends AbstractOpcDeviceDriver i list.add(map3); this.writing(list); if (startdevice.getDeviceDriver() instanceof HongXiangConveyorDeviceDriver) { - hongXiangConveyorDeviceDriver = (HongXiangConveyorDeviceDriver) startdevice.getDeviceDriver(); - hongXiangConveyorDeviceDriver.writing("to_open_door", "1"); + EXECUTOR.submit(() -> { + toOpenDoor(startdevice); + }); } if (nextdevice.getDeviceDriver() instanceof HongXiangConveyorDeviceDriver) { - hongXiangConveyorDeviceDriver = (HongXiangConveyorDeviceDriver) nextdevice.getDeviceDriver(); - hongXiangConveyorDeviceDriver.writing("to_open_door", "1"); + EXECUTOR.submit(() -> { + toOpenDoor(nextdevice); + }); } - this.setNow_steps_type(2); this.setRequireSucess(true); return true; } else { @@ -459,7 +472,7 @@ public class OvenGantryManipulatorDeviceDriver extends AbstractOpcDeviceDriver i HongXiangConveyorDeviceDriver hongXiangConveyorDeviceDriver; StandardInspectSiteDeviceDriver standardInspectSiteDeviceDriver; OvenInspectSiteDeviceDriver ovenInspectSiteDeviceDriver; - if (startdevice.getDeviceDriver() instanceof OvenInspectSiteDeviceDriver && nextdevice.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) { + /*if (startdevice.getDeviceDriver() instanceof OvenInspectSiteDeviceDriver && nextdevice.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) { ovenInspectSiteDeviceDriver = (OvenInspectSiteDeviceDriver) startdevice.getDeviceDriver(); standardInspectSiteDeviceDriver = (StandardInspectSiteDeviceDriver) nextdevice.getDeviceDriver(); if (ovenInspectSiteDeviceDriver.getMove() != 1 || standardInspectSiteDeviceDriver.getMove() == 1) { @@ -477,7 +490,7 @@ public class OvenGantryManipulatorDeviceDriver extends AbstractOpcDeviceDriver i if (nextdevice.getDeviceDriver() instanceof OvenInspectSiteDeviceDriver && startdevice.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) { ovenInspectSiteDeviceDriver = (OvenInspectSiteDeviceDriver) nextdevice.getDeviceDriver(); standardInspectSiteDeviceDriver = (StandardInspectSiteDeviceDriver) startdevice.getDeviceDriver(); - if (ovenInspectSiteDeviceDriver.getMove() != 1 || standardInspectSiteDeviceDriver.getMove() == 1) { + if (ovenInspectSiteDeviceDriver.getMove() == 1 || standardInspectSiteDeviceDriver.getMove() != 1) { notCreateInstMessage = "手动创建指令未下发电气信号原因->烘箱检测站点-普通检测站点:" + ovenInspectSiteDeviceDriver.getDevicecode() + "无货,无法下发指令或" + standardInspectSiteDeviceDriver.getDevicecode() + "有货,无法下发指令!" + "!任务号:" + task.getTask_code(); return false; @@ -488,7 +501,7 @@ public class OvenGantryManipulatorDeviceDriver extends AbstractOpcDeviceDriver i notCreateInstMessage = "手动创建指令未下发电气信号原因->取货位:" + task.getStart_device_code() + ",放货位:" + task.getNext_device_code() + ",存在关联的同一列烘箱设备未关门!任务号:" + task.getTask_code(); return false; } - } + }*/ if (startdevice.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) { standardInspectSiteDeviceDriver = (StandardInspectSiteDeviceDriver) startdevice.getDeviceDriver(); if (standardInspectSiteDeviceDriver.getMove() != 1) { @@ -593,7 +606,7 @@ public class OvenGantryManipulatorDeviceDriver extends AbstractOpcDeviceDriver i } String start_addr = startDevice.getExtraValue().get("address").toString(); String next_addr = nextDevice.getExtraValue().get("address").toString(); - if(ObjectUtil.isEmpty(start_addr) || ObjectUtil.isEmpty(next_addr)){ + if (ObjectUtil.isEmpty(start_addr) || ObjectUtil.isEmpty(next_addr)) { throw new BadRequestException("设备:" + startDevice.getDevice_code() + "或设备:" + nextDevice.getDevice_code() + "地址值!"); } String msg = "当前设备:" + device_code + ",下发指令:" @@ -622,18 +635,16 @@ public class OvenGantryManipulatorDeviceDriver extends AbstractOpcDeviceDriver i list.add(map2); list.add(map3); this.writing(list); - //HongXiangConveyorDeviceDriver hongXiangConveyorDeviceDriver; - if (nextDevice.getDeviceDriver() instanceof HongXiangConveyorDeviceDriver) { - hongXiangConveyorDeviceDriver = (HongXiangConveyorDeviceDriver) nextDevice.getDeviceDriver(); - hongXiangConveyorDeviceDriver.writing("to_open_door", "1"); - hongXiangConveyorDeviceDriver.writing("to_open_door", "1"); + if (startdevice.getDeviceDriver() instanceof HongXiangConveyorDeviceDriver) { + EXECUTOR.submit(() -> { + toOpenDoor(startdevice); + }); } - if (startDevice.getDeviceDriver() instanceof HongXiangConveyorDeviceDriver) { - hongXiangConveyorDeviceDriver = (HongXiangConveyorDeviceDriver) startDevice.getDeviceDriver(); - hongXiangConveyorDeviceDriver.writing("to_open_door", "1"); - hongXiangConveyorDeviceDriver.writing("to_open_door", "1"); + if (nextdevice.getDeviceDriver() instanceof HongXiangConveyorDeviceDriver) { + EXECUTOR.submit(() -> { + toOpenDoor(nextdevice); + }); } - this.setNow_steps_type(2); this.setRequireSucess(true); notCreateInstMessage = ""; notCreateTaskMessage = ""; @@ -644,6 +655,17 @@ public class OvenGantryManipulatorDeviceDriver extends AbstractOpcDeviceDriver i } } + private void toOpenDoor(Device nextdevice) { + HongXiangConveyorDeviceDriver hongXiangConveyorDeviceDriver; + hongXiangConveyorDeviceDriver = (HongXiangConveyorDeviceDriver) nextdevice.getDeviceDriver(); + hongXiangConveyorDeviceDriver.writing("to_open_door", "1"); + } + + private void toCloseDoor(Device nextdevice) { + HongXiangConveyorDeviceDriver hongXiangConveyorDeviceDriver; + hongXiangConveyorDeviceDriver = (HongXiangConveyorDeviceDriver) nextdevice.getDeviceDriver(); + hongXiangConveyorDeviceDriver.writing("to_close_door", "1"); + } /** * 判断经过的烘箱是否关门 */ @@ -668,7 +690,7 @@ public class OvenGantryManipulatorDeviceDriver extends AbstractOpcDeviceDriver i if (device.getDeviceDriver() instanceof HongXiangConveyorDeviceDriver) { hongXiangConveyorDeviceDriver = (HongXiangConveyorDeviceDriver) device.getDeviceDriver(); //判断关联设备是否开门 - if (hongXiangConveyorDeviceDriver.getDoor() == 1) { + if (hongXiangConveyorDeviceDriver.getDoor() != 2) { notCreateInstMessage = "关联设备->" + device + "烘箱门未关闭!"; flag = false; break; @@ -707,7 +729,7 @@ public class OvenGantryManipulatorDeviceDriver extends AbstractOpcDeviceDriver i if (linkDevice.getDeviceDriver() instanceof HongXiangConveyorDeviceDriver) { hongXiangConveyorDeviceDriver = (HongXiangConveyorDeviceDriver) linkDevice.getDeviceDriver(); //判断关联设备是否开门 - if (hongXiangConveyorDeviceDriver.getDoor() == 1 || hongXiangConveyorDeviceDriver.getError1() != 0 + if (hongXiangConveyorDeviceDriver.getDoor() != 2 || hongXiangConveyorDeviceDriver.getError1() != 0 || hongXiangConveyorDeviceDriver.getError() != 0) { isClose = true; notCreateInstMessage = start_device_code + "关联设备->" + deviceCode + "烘箱门未关闭!"; @@ -733,7 +755,7 @@ public class OvenGantryManipulatorDeviceDriver extends AbstractOpcDeviceDriver i if (linkDevice.getDeviceDriver() instanceof HongXiangConveyorDeviceDriver) { hongXiangConveyorDeviceDriver = (HongXiangConveyorDeviceDriver) linkDevice.getDeviceDriver(); //判断关联设备是否开门 - if (hongXiangConveyorDeviceDriver.getDoor() == 1 || hongXiangConveyorDeviceDriver.getError1() != 0 + if (hongXiangConveyorDeviceDriver.getDoor() != 2 || hongXiangConveyorDeviceDriver.getError1() != 0 || hongXiangConveyorDeviceDriver.getError() != 0) { isClose = true; notCreateInstMessage = next_device_code + "关联设备->" + deviceCode + "烘箱门未关闭!"; @@ -822,45 +844,38 @@ public class OvenGantryManipulatorDeviceDriver extends AbstractOpcDeviceDriver i int error = hongXiangConveyorDeviceDriver.getError(); int move = hongXiangConveyorDeviceDriver.getMove(); if (mode == 1 && door == 1 && action == 1 && error == 0 && error1 == 0 && move == 1) { - if (this.getNow_steps_type() == 2) { - map.put("code", "to_command"); - map.put("value", "2"); - list.add(map); - this.writing(list); - this.setNow_steps_type(3); - } - } else { - if (this.getNow_steps_type() == 2) { - feedMessage = "烘箱:" + hongXiangConveyorDeviceDriver.getDevice_code(); - if (mode != 1) { - feedMessage = feedMessage + "工作模式(mode)信号未联机,"; - } - if (door != 1) { - feedMessage = feedMessage + "门状态(door)信号未开门,"; - } - if (action != 1) { - feedMessage = feedMessage + "允许取放(action)信号未允许取放,"; - } - if (move != 1) { - feedMessage = feedMessage + "取货位光电信号(move)不应该为无货状态,"; - } - if (error1 != 0) { - feedMessage = feedMessage + "故障(error1)信号出现故障,故障值:" + error1 + "。"; - } - } - } - } else { - if (this.getNow_steps_type() == 2) { map.put("code", "to_command"); map.put("value", "2"); list.add(map); this.writing(list); - this.setNow_steps_type(3); + this.setRequireActionSucess(true); + } else { + feedMessage = "烘箱:" + hongXiangConveyorDeviceDriver.getDevice_code(); + if (mode != 1) { + feedMessage = feedMessage + "工作模式(mode)信号未联机,"; + } + if (door != 1) { + feedMessage = feedMessage + "门状态(door)信号未开门,"; + } + if (action != 1) { + feedMessage = feedMessage + "允许取放(action)信号未允许取放,"; + } + if (move != 1) { + feedMessage = feedMessage + "取货位光电信号(move)不应该为无货状态,"; + } + if (error1 != 0) { + feedMessage = feedMessage + "故障(error1)信号出现故障,故障值:" + error1 + "。"; + } } + } else { + map.put("code", "to_command"); + map.put("value", "2"); + list.add(map); + this.writing(list); + this.setRequireActionSucess(true); } } } else { - if (this.getNow_steps_type() == 2) { feedMessage = "行架机械手:"; if (mode != 3) { feedMessage = feedMessage + "工作模式(mode)不为运行中状态,"; @@ -874,7 +889,6 @@ public class OvenGantryManipulatorDeviceDriver extends AbstractOpcDeviceDriver i if (task == 0) { feedMessage = feedMessage + "当前上报任务号(task)不应该为0。"; } - } } //取货完成关闭烘箱门 @@ -886,32 +900,29 @@ public class OvenGantryManipulatorDeviceDriver extends AbstractOpcDeviceDriver i HongXiangConveyorDeviceDriver hongXiangConveyorDeviceDriver; if (device.getDeviceDriver() instanceof HongXiangConveyorDeviceDriver) { hongXiangConveyorDeviceDriver = (HongXiangConveyorDeviceDriver) device.getDeviceDriver(); - map.put("to_close_door", "1"); - hongXiangConveyorDeviceDriver.writing(map); - } - if (this.getNow_steps_type() == 3) { - map.put("code", "to_command"); - map.put("value", "3"); - list.add(map); - this.writing(list); - this.setNow_steps_type(4); + EXECUTOR.submit(() -> { + toCloseDoor(device); + }); } + map.put("code", "to_command"); + map.put("value", "3"); + list.add(map); + this.writing(list); + this.setRequireActionSucess(true); } } else { - if (this.getNow_steps_type() == 3) { - feedMessage = "行架机械手:"; - if (mode != 3) { - feedMessage = feedMessage + "工作模式(mode)不为运行中状态,"; - } - if (action != 2) { - feedMessage = feedMessage + "动作信号(action)不为取货完成状态,"; - } - if (move != 1) { - feedMessage = feedMessage + "光电信号(move)不为有货状态,"; - } - if (task == 0) { - feedMessage = feedMessage + "当前上报任务号(task)不应该为0。"; - } + feedMessage = "行架机械手:"; + if (mode != 3) { + feedMessage = feedMessage + "工作模式(mode)不为运行中状态,"; + } + if (action != 2) { + feedMessage = feedMessage + "动作信号(action)不为取货完成状态,"; + } + if (move != 1) { + feedMessage = feedMessage + "光电信号(move)不为有货状态,"; + } + if (task == 0) { + feedMessage = feedMessage + "当前上报任务号(task)不应该为0。"; } } @@ -931,59 +942,49 @@ public class OvenGantryManipulatorDeviceDriver extends AbstractOpcDeviceDriver i int error = hongXiangConveyorDeviceDriver.getError(); int move = hongXiangConveyorDeviceDriver.getMove(); if (mode == 1 && door == 1 && action == 1 && error == 0 && error1 == 0 && move == 0) { - if (this.getNow_steps_type() == 4) { - map.put("code", "to_command"); - map.put("value", "4"); - list.add(map); - this.writing(list); - this.setNow_steps_type(5); - } else { - feedMessage = "未反馈电气信号原因:当前步骤不为允许放货(now_steps_type!=4)"; - } - } else { - if (this.getNow_steps_type() == 4) { - feedMessage = "烘箱:" + hongXiangConveyorDeviceDriver.getDevice_code(); - if (mode != 1) { - feedMessage = feedMessage + "工作模式(mode)信号未联机,"; - } - if (door != 1) { - feedMessage = feedMessage + "门状态(door)信号未开门,"; - } - if (action != 1) { - feedMessage = feedMessage + "允许取放(action)信号未允许取放,"; - } - if (move != 0) { - feedMessage = feedMessage + "放货位光电信号不应该为有货状态"; - } - if (error1 != 0) { - feedMessage = feedMessage + "故障(error1)信号出现故障。"; - } - } - } - } else { - if (this.getNow_steps_type() == 4) { map.put("code", "to_command"); map.put("value", "4"); list.add(map); this.writing(list); - this.setNow_steps_type(5); + this.setRequireActionSucess(true); + } else { + feedMessage = "烘箱:" + hongXiangConveyorDeviceDriver.getDevice_code(); + if (mode != 1) { + feedMessage = feedMessage + "工作模式(mode)信号未联机,"; + } + if (door != 1) { + feedMessage = feedMessage + "门状态(door)信号未开门,"; + } + if (action != 1) { + feedMessage = feedMessage + "允许取放(action)信号未允许取放,"; + } + if (move != 0) { + feedMessage = feedMessage + "放货位光电信号不应该为有货状态"; + } + if (error1 != 0) { + feedMessage = feedMessage + "故障(error1)信号出现故障。"; + } } + } else { + map.put("code", "to_command"); + map.put("value", "4"); + list.add(map); + this.writing(list); + this.setRequireActionSucess(true); } } else { - if (this.getNow_steps_type() == 4) { - feedMessage = "行架机械手:"; - if (mode != 3) { - feedMessage = feedMessage + "工作模式(mode)不为运行中状态,"; - } - if (action != 3) { - feedMessage = feedMessage + "动作信号(action)不为放货中状态,"; - } - if (move != 1) { - feedMessage = feedMessage + "光电信号(move)不为有货状态,"; - } - if (task == 0) { - feedMessage = feedMessage + "当前上报任务号(task)不应该为0。"; - } + feedMessage = "行架机械手:"; + if (mode != 3) { + feedMessage = feedMessage + "工作模式(mode)不为运行中状态,"; + } + if (action != 3) { + feedMessage = feedMessage + "动作信号(action)不为放货中状态,"; + } + if (move != 1) { + feedMessage = feedMessage + "光电信号(move)不为有货状态,"; + } + if (task == 0) { + feedMessage = feedMessage + "当前上报任务号(task)不应该为0。"; } } @@ -1000,7 +1001,9 @@ public class OvenGantryManipulatorDeviceDriver extends AbstractOpcDeviceDriver i LampThreecolorDeviceDriver lampThreecolorDeviceDriver; if (nextDevice.getDeviceDriver() instanceof HongXiangConveyorDeviceDriver) { hongXiangConveyorDeviceDriver = (HongXiangConveyorDeviceDriver) nextDevice.getDeviceDriver(); - hongXiangConveyorDeviceDriver.writing("to_close_door", "1"); + EXECUTOR.submit(() -> { + toCloseDoor(nextDevice); + }); if (StrUtil.isNotEmpty(taskDto.getOven_time())) { //下发烘箱时间 int time = Integer.parseInt(taskDto.getOven_time()); @@ -1038,8 +1041,7 @@ public class OvenGantryManipulatorDeviceDriver extends AbstractOpcDeviceDriver i map.put("value", "5"); list.add(map); this.writing(list); - this.setNow_steps_type(6); - this.setNow_steps_type(0); + this.setRequireActionSucess(true); try { finish_instruction(inst2); } catch (Exception e) { @@ -1049,7 +1051,6 @@ public class OvenGantryManipulatorDeviceDriver extends AbstractOpcDeviceDriver i } } } else { - if (this.getNow_steps_type() == 5) { feedMessage = "行架机械手:"; if (mode != 3) { feedMessage = feedMessage + "工作模式(mode)不为运行中状态,"; @@ -1063,7 +1064,6 @@ public class OvenGantryManipulatorDeviceDriver extends AbstractOpcDeviceDriver i if (task == 0) { feedMessage = feedMessage + "当前上报任务号(task)不应该为0。"; } - } } } } @@ -1113,6 +1113,10 @@ public class OvenGantryManipulatorDeviceDriver extends AbstractOpcDeviceDriver i if (error == 0 && iserror) { this.setMessage(LangProcess.msg("universal_message4")); } + String requireActionSucess = "请求动作已复位"; + if(this.requireActionSucess){ + requireActionSucess = "请求动作未复位"; + } jo.put("device_name", this.getDevice().getDevice_name()); jo.put("mode", mode); jo.put("move", move); @@ -1124,8 +1128,9 @@ public class OvenGantryManipulatorDeviceDriver extends AbstractOpcDeviceDriver i jo.put("isError", this.getIserror()); jo.put("message", message); jo.put("notCreateTaskMessage", notCreateTaskMessage); - jo.put("notCreateInstMessage", notCreateInstMessage); - jo.put("feedMessage", LangProcess.msg(feedMessage)); + jo.put("notCreateInstMessage", notCreateInstMessage); + jo.put("feedMessage", feedMessage); + jo.put("requireActionSucess", requireActionSucess); jo.put("driver_type", "siemens_conveyor"); jo.put("is_click", true); jo.put("x", x_position); diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/plug_pull_device_site/ItemProtocol.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/plug_pull_device_site/ItemProtocol.java index 8c39cabf1..54f2b9f8c 100644 --- a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/plug_pull_device_site/ItemProtocol.java +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/plug_pull_device_site/ItemProtocol.java @@ -42,9 +42,9 @@ public class ItemProtocol { public static String item_to_command = "to_command"; //气涨轴类型 public static String item_to_qzz_type = "to_qzz_type"; - //套管纸管1规格 + //套管纸管1编码 public static String item_to_material1 = "to_material1"; - //套管纸管2规格 + //套管纸管2编码 public static String item_to_material2 = "to_material2"; //套管纸管数量 public static String item_to_qty1 = "to_qty1"; @@ -52,9 +52,9 @@ public class ItemProtocol { public static String item_to_size1 = "to_size1"; //套管纸管2尺寸 public static String item_to_size2 = "to_size2"; - //拔轴纸管1规格 + //拔轴纸管1编码 public static String item_to_material3 = "to_material3"; - //拔轴纸管2规格 + //拔轴纸管2编码 public static String item_to_material4 = "to_material4"; //拔轴纸管数量 public static String item_to_qty2 = "to_qty2"; @@ -62,6 +62,12 @@ public class ItemProtocol { public static String item_to_size3 = "to_size3"; //拔轴纸管2尺寸 public static String item_to_size4 = "to_size4"; + //套轴纸管1规格 + public static String item_to_spec1 = "to_spec1"; + public static String item_to_spec2 = "to_spec2"; + public static String item_to_spec3 = "to_spec3"; + public static String item_to_spec4 = "to_spec4"; + private PlugPullDeviceSiteDeviceDriver driver; @@ -95,11 +101,11 @@ public class ItemProtocol { public String getBarcode(){ return this.getOpcStringValue(item_barcode);} - public int getWeight1(){ return this.getOpcIntegerValue(item_weight1);} + public Float getWeight1(){ return this.getOpcFloatValue(item_weight1);} public String getMaterial1(){ return this.getOpcStringValue(item_material1);} - public int getWeight2(){ return this.getOpcIntegerValue(item_weight2);} + public Float getWeight2(){ return this.getOpcFloatValue(item_weight2);} public int getSize(){ return this.getOpcIntegerValue(item_size);} @@ -217,17 +223,21 @@ public class ItemProtocol { public static List getWriteableItemDtos() { ArrayList list = new ArrayList(); list.add(new ItemDto(item_to_command, "下发命令", "DB10.W0")); - list.add(new ItemDto(item_to_material1, "套管纸管1规格", "DB10.String602.60")); - list.add(new ItemDto(item_to_material2, "套管纸管2规格", "DB10.String656.60")); + list.add(new ItemDto(item_to_material1, "套管纸管1编码", "DB10.String602.60")); + list.add(new ItemDto(item_to_material2, "套管纸管2编码", "DB10.String656.60")); list.add(new ItemDto(item_to_qty1, "套管纸管数量", "DB10.W6")); list.add(new ItemDto(item_to_qzz_type, "气胀轴类型", "DB10.W8")); list.add(new ItemDto(item_to_size1, "套管纸管1尺寸", "DB10.W10")); list.add(new ItemDto(item_to_size2, "套管纸管2尺寸", "DB10.W12")); - list.add(new ItemDto(item_to_material1, "拔轴纸管1规格", "DB10.String602.60")); - list.add(new ItemDto(item_to_material2, "拔轴纸管2规格", "DB10.String656.60")); + list.add(new ItemDto(item_to_material1, "拔轴纸管1编码", "DB10.String602.60")); + list.add(new ItemDto(item_to_material2, "拔轴纸管2编码", "DB10.String656.60")); list.add(new ItemDto(item_to_qty2, "拔轴纸管数量", "DB10.W6")); - list.add(new ItemDto(item_to_size1, "拔轴纸管1尺寸", "DB10.W10")); - list.add(new ItemDto(item_to_size2, "下发纸管2尺寸", "DB10.W12")); + list.add(new ItemDto(item_to_size3, "拔轴纸管1尺寸", "DB10.W10")); + list.add(new ItemDto(item_to_size4, "拔轴纸管2尺寸", "DB10.W12")); + list.add(new ItemDto(item_to_spec1, "套轴纸管1规格", "DB10.W12")); + list.add(new ItemDto(item_to_spec2, "套轴纸管2规格", "DB10.W12")); + list.add(new ItemDto(item_to_spec3, "拔轴纸管1规格", "DB10.W12")); + list.add(new ItemDto(item_to_spec4, "拔轴纸管2规格", "DB10.W12")); return list; } diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/plug_pull_device_site/PlugPullDeviceSiteDeviceDriver.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/plug_pull_device_site/PlugPullDeviceSiteDeviceDriver.java index 9c7306fee..eae811986 100644 --- a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/plug_pull_device_site/PlugPullDeviceSiteDeviceDriver.java +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/plug_pull_device_site/PlugPullDeviceSiteDeviceDriver.java @@ -98,14 +98,14 @@ public class PlugPullDeviceSiteDeviceDriver extends AbstractOpcDeviceDriver impl String barcode = null; String lastBarcode = null; //纸管1重量 - int weight1 = 0; - int lastWeight1 = 0; + Float weight1 = 0.0F; + Float lastWeight1 = 0.0F; //纸管1规格 String material1 = null; String lastMaterial1 = null; //纸管2重量 - int weight2 = 0; - int lastWeight2 = 0; + Float weight2 = 0.0F; + Float lastWeight2 = 0.0F; //纸管2规格 String material2 = null; String lastMaterial2 = null; @@ -160,7 +160,7 @@ public class PlugPullDeviceSiteDeviceDriver extends AbstractOpcDeviceDriver impl */ int flag; - String deviceCode; + String device_code; String message = null; @@ -177,7 +177,7 @@ public class PlugPullDeviceSiteDeviceDriver extends AbstractOpcDeviceDriver impl @Override public void execute() throws Exception { - deviceCode = this.getDeviceCode(); + device_code = this.getDeviceCode(); mode = this.itemProtocol.getMode(); move = this.itemProtocol.getMove(); action = this.itemProtocol.getAction(); @@ -298,7 +298,7 @@ public class PlugPullDeviceSiteDeviceDriver extends AbstractOpcDeviceDriver impl private synchronized void apply_casing(int mode) throws Exception { ApplyPlugPullSiteRequest applyPlugPullSiteRequest = new ApplyPlugPullSiteRequest(); ApplyPlugPullSitResponse applyPlugPullSitResponse; - applyPlugPullSiteRequest.setDevice_code(deviceCode); + applyPlugPullSiteRequest.setDevice_code(device_code); applyPlugPullSiteRequest.setType(CommonFinalParam.TYPE_ONE); //气涨轴尺寸 applyPlugPullSiteRequest.setSize(String.valueOf(size)); @@ -306,24 +306,37 @@ public class PlugPullDeviceSiteDeviceDriver extends AbstractOpcDeviceDriver impl if (applyPlugPullSitResponse.getCode() == CommonFinalParam.STATUS_OPEN) { Map data = applyPlugPullSitResponse.getData(); String number = data.get("number"); - String leftSize = data.get("left_size"); - String rightSize = data.get("right_size"); + String leftSize = data.get("leftSize"); + String rightSize = data.get("rightSize"); + //套管1物料 + String to_material1 = data.get("left"); + //套管2物料 + String to_material2 = data.get("right"); + //套管1规格 + String to_spec1 = data.get("leftSpec"); + //套管2规格 + String to_spec2 = data.get("rightSpec"); Map map = new LinkedHashMap<>(); //下发纸管信息 - //todo:纸管规格待定 - map.put("to_material1", material1); - map.put("to_material2", material2); + + map.put("to_material1", to_material1); + map.put("to_material2", to_material2); + if (StrUtil.isNotEmpty(leftSize)){ map.put("to_size1", leftSize); } if (StrUtil.isNotEmpty(rightSize)){ map.put("to_size2", rightSize); } + map.put("to_spec1", to_spec1); + if (ObjectUtil.isNotEmpty(to_spec2)) { + map.put("to_spec2", to_spec2); + } map.put("to_command", mode); map.put("to_qty1", number); this.writing(map); requireSucess = true; - logServer.deviceExecuteLog(this.deviceCode, "", "", "申请套管,返回参数:" + applyPlugPullSitResponse); + logServer.deviceExecuteLog(this.device_code, "", "", "申请套管,返回参数:" + applyPlugPullSitResponse); message = "申请套管成功"; } else { message = applyPlugPullSitResponse.getMessage(); @@ -332,7 +345,7 @@ public class PlugPullDeviceSiteDeviceDriver extends AbstractOpcDeviceDriver impl this.writing(map); requireSucess = true; message = "申请套管失败"; - logServer.deviceExecuteLog(this.deviceCode, "", "", "申请套管反馈失败,返回参数:" + applyPlugPullSitResponse); + logServer.deviceExecuteLog(this.device_code, "", "", "申请套管反馈失败,返回参数:" + applyPlugPullSitResponse); } } @@ -342,7 +355,7 @@ public class PlugPullDeviceSiteDeviceDriver extends AbstractOpcDeviceDriver impl private synchronized void bushingSucess(int mode) throws Exception { ApplyPlugPullSiteRequest applyPlugPullSiteRequest = new ApplyPlugPullSiteRequest(); ApplyPlugPullSitResponse applyPlugPullSitResponse; - applyPlugPullSiteRequest.setDevice_code(deviceCode); + applyPlugPullSiteRequest.setDevice_code(device_code); //上报规格和重量 applyPlugPullSiteRequest.setWeight1(String.valueOf(weight1)); applyPlugPullSiteRequest.setMaterial1(String.valueOf(material1)); @@ -352,7 +365,7 @@ public class PlugPullDeviceSiteDeviceDriver extends AbstractOpcDeviceDriver impl applyPlugPullSitResponse = acsToWmsService.applyPlugPullSiteRequest(applyPlugPullSiteRequest); if (applyPlugPullSitResponse.getCode() == CommonFinalParam.STATUS_OPEN) { this.writeSignal(mode); - logServer.deviceExecuteLog(this.deviceCode, "", "", "反馈套管完成,返回参数:" + applyPlugPullSitResponse); + logServer.deviceExecuteLog(this.device_code, "", "", "反馈套管完成,返回参数:" + applyPlugPullSitResponse); message = "套管完成成功"; } else { message = applyPlugPullSitResponse.getMessage(); @@ -361,7 +374,7 @@ public class PlugPullDeviceSiteDeviceDriver extends AbstractOpcDeviceDriver impl this.writing(map); requireSucess = true; message = "申请套管失败"; - logServer.deviceExecuteLog(this.deviceCode, "", "", "申请套管反馈失败,返回参数:" + applyPlugPullSitResponse); + logServer.deviceExecuteLog(this.device_code, "", "", "申请套管反馈失败,返回参数:" + applyPlugPullSitResponse); } } @@ -372,7 +385,7 @@ public class PlugPullDeviceSiteDeviceDriver extends AbstractOpcDeviceDriver impl private synchronized void pullShaftSucess(int mode) throws Exception { ApplyPlugPullSiteRequest applyPlugPullSiteRequest = new ApplyPlugPullSiteRequest(); ApplyPlugPullSitResponse applyPlugPullSitResponse; - applyPlugPullSiteRequest.setDevice_code(deviceCode); + applyPlugPullSiteRequest.setDevice_code(device_code); applyPlugPullSiteRequest.setBarcode(String.valueOf(barcode)); applyPlugPullSiteRequest.setType(CommonFinalParam.TYPE_THREE); applyPlugPullSitResponse = acsToWmsService.applyPlugPullSiteRequest(applyPlugPullSiteRequest); @@ -381,7 +394,7 @@ public class PlugPullDeviceSiteDeviceDriver extends AbstractOpcDeviceDriver impl map.put("to_command", mode); this.writing(map); requireSucess = true; - logServer.deviceExecuteLog(this.deviceCode, "", "", "申请拔轴,返回参数:" + applyPlugPullSitResponse); + logServer.deviceExecuteLog(this.device_code, "", "", "申请拔轴,返回参数:" + applyPlugPullSitResponse); message = "拔轴完成成功"; } else { message = applyPlugPullSitResponse.getMessage(); @@ -390,7 +403,7 @@ public class PlugPullDeviceSiteDeviceDriver extends AbstractOpcDeviceDriver impl this.writing(map); requireSucess = true; message = "拔轴完成失败"; - logServer.deviceExecuteLog(this.deviceCode, "", "", "申请拔轴反馈失败,返回参数:" + applyPlugPullSitResponse); + logServer.deviceExecuteLog(this.device_code, "", "", "申请拔轴反馈失败,返回参数:" + applyPlugPullSitResponse); } } @@ -400,22 +413,44 @@ public class PlugPullDeviceSiteDeviceDriver extends AbstractOpcDeviceDriver impl private synchronized void applyPullShaft(int mode) throws Exception { ApplyPlugPullSiteRequest applyPlugPullSiteRequest = new ApplyPlugPullSiteRequest(); ApplyPlugPullSitResponse applyPlugPullSitResponse; - applyPlugPullSiteRequest.setDevice_code(deviceCode); - applyPlugPullSiteRequest.setBarcode(String.valueOf(barcode)); + applyPlugPullSiteRequest.setDevice_code(device_code); + applyPlugPullSiteRequest.setQzz_no(String.valueOf(barcode)); applyPlugPullSiteRequest.setType(CommonFinalParam.TYPE_FOUR); applyPlugPullSitResponse = acsToWmsService.applyPlugPullSiteRequest(applyPlugPullSiteRequest); if (applyPlugPullSitResponse.getCode() == CommonFinalParam.STATUS_OPEN) { Map data = applyPlugPullSitResponse.getData(); - String leftSize = data.get("left_size"); - String rightSzie = data.get("right_szie"); + //拔管1物料 + Object to_material3 = data.get("currentLeft"); + //拔管2物料 + Object to_material4 = data.get("currentRight"); + //拔管1尺寸 + Object to_size3 = data.get("currentLeftSize"); + //拔管2尺寸 + Object to_size4 = data.get("currentRightSize"); + //拔管1规格 + Object to_spec3 = data.get("currentLeftSpec"); + //拔管2规格 + Object to_spec4 = data.get("currentRightSpec"); + Object to_qty2 = data.get("pullCount"); Map map = new LinkedHashMap<>(); - map.put("to_size3", leftSize); - map.put("to_size4", rightSzie); + map.put("to_material3", to_material3); + if (ObjectUtil.isNotEmpty(to_material4)) { + map.put("to_material4", to_material4); + } + map.put("to_size3", to_size3); + if (ObjectUtil.isNotEmpty(to_size4)) { + map.put("to_size4", to_size4); + } + map.put("to_spec3", to_spec3); + if (ObjectUtil.isNotEmpty(to_spec4)) { + map.put("to_spec4", to_spec4); + } + map.put("to_qty2", to_qty2); map.put("to_qzz_type", size); map.put("to_command", mode); this.writing(map); requireSucess = true; - logServer.deviceExecuteLog(this.deviceCode, "", "", "申请拔轴,返回参数:" + applyPlugPullSitResponse); + logServer.deviceExecuteLog(this.device_code, "", "", "申请拔轴,返回参数:" + applyPlugPullSitResponse); message = "申请拔轴成功"; } else { message = applyPlugPullSitResponse.getMessage(); @@ -424,7 +459,7 @@ public class PlugPullDeviceSiteDeviceDriver extends AbstractOpcDeviceDriver impl this.writing(map); requireSucess = true; message = "申请拔轴失败"; - logServer.deviceExecuteLog(this.deviceCode, "", "", "申请拔轴反馈失败,返回参数:" + applyPlugPullSitResponse); + logServer.deviceExecuteLog(this.device_code, "", "", "申请拔轴反馈失败,返回参数:" + applyPlugPullSitResponse); } } @@ -434,7 +469,7 @@ public class PlugPullDeviceSiteDeviceDriver extends AbstractOpcDeviceDriver impl private synchronized void applyTask(int mode) throws Exception { ApplyPlugPullSiteRequest applyPlugPullSiteRequest = new ApplyPlugPullSiteRequest(); ApplyPlugPullSitResponse applyPlugPullSitResponse; - applyPlugPullSiteRequest.setDevice_code(deviceCode); + applyPlugPullSiteRequest.setDevice_code(device_code); applyPlugPullSiteRequest.setSize(String.valueOf(size)); applyPlugPullSiteRequest.setType(CommonFinalParam.TYPE_FIVE); applyPlugPullSitResponse = acsToWmsService.applyPlugPullSiteRequest(applyPlugPullSiteRequest); @@ -442,14 +477,14 @@ public class PlugPullDeviceSiteDeviceDriver extends AbstractOpcDeviceDriver impl Map map = new LinkedHashMap<>(); map.put("to_command", mode); this.writing(map); - logServer.deviceExecuteLog(this.deviceCode, "", "", "申请拔轴,返回参数:" + applyPlugPullSitResponse); + logServer.deviceExecuteLog(this.device_code, "", "", "申请拔轴,返回参数:" + applyPlugPullSitResponse); message = "生成行架任务成功"; requireSucess = true; } else { message = applyPlugPullSitResponse.getMessage(); requireSucess = true; message = "申请行架任务失败"; - logServer.deviceExecuteLog(this.deviceCode, "", "", "申请拔轴反馈失败,返回参数:" + applyPlugPullSitResponse); + logServer.deviceExecuteLog(this.device_code, "", "", "申请拔轴反馈失败,返回参数:" + applyPlugPullSitResponse); } } @@ -484,9 +519,9 @@ public class PlugPullDeviceSiteDeviceDriver extends AbstractOpcDeviceDriver impl itemMap.put(to_param, json.getString("value")); } } - logServer.deviceExecuteLog(deviceCode, "", "", "下发电气信号:" + itemMap); + logServer.deviceExecuteLog(device_code, "", "", "下发电气信号:" + itemMap); LuceneLogDto logDto = LuceneLogDto.builder() - .device_code(deviceCode) + .device_code(device_code) .content("下发多个电气信号" + itemMap) .build(); luceneExecuteLogService.deviceExecuteLog(logDto); @@ -505,7 +540,7 @@ public class PlugPullDeviceSiteDeviceDriver extends AbstractOpcDeviceDriver impl this.checkcontrol(itemMap); logServer.deviceExecuteLog(this.getDevice().getDevice_code(), "", "", "下发多个电气信号:" + itemMap); LuceneLogDto logDto = LuceneLogDto.builder() - .device_code(deviceCode) + .device_code(device_code) .content("下发多个电气信号" + itemMap) .build(); luceneExecuteLogService.deviceExecuteLog(logDto); @@ -599,7 +634,7 @@ public class PlugPullDeviceSiteDeviceDriver extends AbstractOpcDeviceDriver impl // itemMap.put(to_param, Integer.parseInt(value)); this.control(itemMap); LuceneLogDto logDto = LuceneLogDto.builder() - .device_code(deviceCode) + .device_code(device_code) .content("下发多个电气信号" + itemMap) .build(); luceneExecuteLogService.deviceExecuteLog(logDto); diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/pull_head_manipulator/PullHeadManipulatorDeviceDriver.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/pull_head_manipulator/PullHeadManipulatorDeviceDriver.java index a09b51cf3..8771de923 100644 --- a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/pull_head_manipulator/PullHeadManipulatorDeviceDriver.java +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/pull_head_manipulator/PullHeadManipulatorDeviceDriver.java @@ -4,10 +4,12 @@ import cn.hutool.core.date.DateUtil; import cn.hutool.core.util.IdUtil; import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.StrUtil; +import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; import lombok.Data; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; +import org.jetbrains.annotations.NotNull; import org.nl.acs.common.base.CommonFinalParam; import org.nl.acs.device.domain.Device; import org.nl.acs.device.service.DeviceExtraService; @@ -17,6 +19,7 @@ import org.nl.acs.device_driver.FeedLmsRealFailed; import org.nl.acs.device_driver.RouteableDeviceDriver; import org.nl.acs.device_driver.driver.AbstractOpcDeviceDriver; import org.nl.acs.device_driver.driver.ExecutableDeviceDriver; +import org.nl.acs.device_driver.one_manipulator.box_storage_manipulator.InteractionJsonDTO; import org.nl.acs.device_driver.two_conveyor.pull_head_manipulator.ItemProtocol; import org.nl.acs.history.ErrorUtil; import org.nl.acs.history.service.DeviceErrorLogService; @@ -222,7 +225,7 @@ public class PullHeadManipulatorDeviceDriver extends AbstractOpcDeviceDriver imp try { TaskDto dto = taskserver.findByCode(inst.getTask_code()); Map map = new LinkedHashMap<>(); - if (ObjectUtil.isNotEmpty(dto)){ + /*if (ObjectUtil.isNotEmpty(dto)){ String interaction_json = dto.getInteraction_json(); if (ObjectUtil.isNotEmpty(interaction_json)){ JSONObject jsonObject = (JSONObject) JSONObject.toJSON(interaction_json); @@ -231,7 +234,7 @@ public class PullHeadManipulatorDeviceDriver extends AbstractOpcDeviceDriver imp map.put("to_size", jsonObject.getString("qzz_size")); map.put("to_barcode", jsonObject.getString("qzz_no")); } - } + }*/ map.put("to_command", "5"); this.writing(map); finish_instruction(inst); @@ -359,30 +362,7 @@ public class PullHeadManipulatorDeviceDriver extends AbstractOpcDeviceDriver imp String startAddr = startDevice.getExtraValue().get("address").toString(); String nextAddr = nextDevice.getExtraValue().get("address").toString(); String interaction_json = taskDto.getInteraction_json(); - JSONObject jsonObject = JSONObject.parseObject(interaction_json); - //所需纸管信息(左边) - Object left = jsonObject.get("left"); - //所需纸管信息(右边) - Object right = jsonObject.get("right"); - //当前纸管信息(左边) - Object currentLeft = jsonObject.get("currentLeft"); - //当前纸管信息(右边) - Object currentRight = jsonObject.get("currentRight"); - //套管数量 - Object casingCount = jsonObject.get("casingCount"); - //拔管数量 - Object pullCount = jsonObject.get("pullCount"); - Map map = new LinkedHashMap<>(); - map.put("to_command", CommonFinalParam.ONE); - map.put("to_onset", startAddr); - map.put("to_task", instruction.getInstruction_code()); - map.put("to_target", nextAddr); - map.put("left", left); - map.put("right", right); - map.put("currentLeft", currentLeft); - map.put("currentRight", currentRight); - map.put("casingCount", casingCount); - map.put("pullCount", pullCount); + Map map = toStringObjectMap(instruction, startAddr, nextAddr, interaction_json); this.writing(map); this.setRequireSucess(true); return true; @@ -433,8 +413,11 @@ public class PullHeadManipulatorDeviceDriver extends AbstractOpcDeviceDriver imp instructionService.create(instdto); } catch (Exception e) { notCreateInstMessage = e.getMessage(); - logServer.deviceExecuteLog(this.getDevice_code(), "", "", "创建指令时出现异常:" + e.getMessage()); - return false; + LuceneLogDto logDto = LuceneLogDto.builder() + .device_code(device_code) + .content(device_code+"创建指令时出现异常:" + e.getMessage()) + .build(); + luceneExecuteLogService.deviceExecuteLog(logDto); return false; } //创建指令后修改任务状态 task.setTask_status(TaskStatusEnum.BUSY.getIndex()); @@ -456,31 +439,8 @@ public class PullHeadManipulatorDeviceDriver extends AbstractOpcDeviceDriver imp } String startAddr = startDevice.getExtraValue().get("address").toString(); String nextAddr = nextDevice.getExtraValue().get("address").toString(); - String interactionJson = task.getInteraction_json(); - JSONObject jsonObject = JSONObject.parseObject(interactionJson); - //所需纸管信息(左边) - Object left = jsonObject.get("left"); - //所需纸管信息(右边) - Object right = jsonObject.get("right"); - //当前纸管信息(左边) - Object currentLeft = jsonObject.get("currentLeft"); - //当前纸管信息(右边) - Object currentRight = jsonObject.get("currentRight"); - //套管数量 - Object casingCount = jsonObject.get("casingCount"); - //拔管数量 - Object pullCount = jsonObject.get("pullCount"); - Map map = new LinkedHashMap<>(); - map.put("to_command", CommonFinalParam.ONE); - map.put("to_onset", startAddr); - map.put("to_task", instdto.getInstruction_code()); - map.put("to_target", nextAddr); - map.put("left", left); - map.put("right", right); - map.put("currentLeft", currentLeft); - map.put("currentRight", currentRight); - map.put("casingCount", casingCount); - map.put("pullCount", pullCount); + String interaction_json = task.getInteraction_json(); + Map map = toStringObjectMap(instdto, startAddr, nextAddr, interaction_json); this.writing(map); this.setRequireSucess(true); notCreateInstMessage = ""; @@ -492,6 +452,118 @@ public class PullHeadManipulatorDeviceDriver extends AbstractOpcDeviceDriver imp } } + @NotNull + private Map toStringObjectMap(Instruction instdto, String startAddr, String nextAddr, String interaction_json) { + Map map = new LinkedHashMap<>(); + if(StrUtil.isNotEmpty(interaction_json) && !"".equals(interaction_json)){ + JSONObject jsonObject = JSONObject.parseObject(interaction_json); + //套管1物料 + Object to_material1 = jsonObject.get("left"); + //套管2物料 + Object to_material2 = jsonObject.get("right"); + //套管1规格 + Object to_spec1 = jsonObject.get("leftSpec"); + //套管2规格 + Object to_spec2 = jsonObject.get("rightSpec"); + //套管1尺寸 + Object to_size1 = jsonObject.get("leftSize"); + //套管2尺寸 + Object to_size2 = jsonObject.get("rightSize"); + //拔管1物料 + Object to_material3 = jsonObject.get("currentLeft"); + //拔管2物料 + Object to_material4 = jsonObject.get("currentRight"); + //拔管1尺寸 + Object to_size3 = jsonObject.get("currentLeftSize"); + //拔管2尺寸 + Object to_size4 = jsonObject.get("currentRightSize"); + //拔管1规格 + Object to_spec3 = jsonObject.get("currentLeftSpec"); + //拔管2规格 + Object to_spec4 = jsonObject.get("currentRightSpec"); + + //套管数量 + Object to_qty1 = jsonObject.get("casingCount"); + //拔管数量 + Object to_qty2 = jsonObject.get("pullCount"); + + map.put("to_pull", jsonObject.getString("is_pulling")); + map.put("is_bushing", jsonObject.getString("is_bushing")); + map.put("to_size", jsonObject.getString("qzz_size")); + map.put("to_barcode", jsonObject.getString("qzz_no")); + map.put("to_command", CommonFinalParam.ONE); + map.put("to_onset", startAddr); + map.put("to_task", instdto.getInstruction_code()); + map.put("to_target", nextAddr); + //toTranscription(taskDto,map); + map.put("to_material1", to_material1); + if (ObjectUtil.isNotEmpty(to_material2)) { + map.put("to_material2", to_material2); + } + map.put("to_spec1", to_spec1); + if (ObjectUtil.isNotEmpty(to_spec2)) { + map.put("to_spec2", to_spec2); + } + map.put("to_size1", to_size1); + if (ObjectUtil.isNotEmpty(to_size2)) { + map.put("to_size2", to_size2); + } + map.put("to_material3", to_material3); + if (ObjectUtil.isNotEmpty(to_material4)) { + map.put("to_material4", to_material4); + } + map.put("to_size3", to_size3); + if (ObjectUtil.isNotEmpty(to_size4)) { + map.put("to_size4", to_size4); + } + map.put("to_spec3", to_spec3); + if (ObjectUtil.isNotEmpty(to_spec4)) { + map.put("to_spec4", to_spec4); + } + map.put("to_qty1", to_qty1); + map.put("to_qty2", to_qty2); + return map; + }else{ + map.put("to_command", CommonFinalParam.ONE); + map.put("to_onset", startAddr); + map.put("to_task", instdto.getInstruction_code()); + map.put("to_target", nextAddr); + return map; + } + } + + private void toTranscription(TaskDto taskDto,Map map){ + String interactionJson = taskDto.getInteraction_json(); + InteractionJsonDTO interactionJsonDTO = JSON.parseObject(interactionJson, InteractionJsonDTO.class); + if(ObjectUtil.isNotEmpty(interactionJsonDTO)){ + toDevice(interactionJsonDTO.getToPull(),"to_pull",map); + toDevice(interactionJsonDTO.getIsBushing(),"is_bushing",map); + toDevice(interactionJsonDTO.getToSize(),"to_size",map); + toDevice(interactionJsonDTO.getToBarcode(),"to_barcode",map); + toDevice(interactionJsonDTO.getToMaterial1(),"to_material1",map); + toDevice(interactionJsonDTO.getToMaterial2(),"to_material2",map); + toDevice(interactionJsonDTO.getToSpec1(),"to_spec1",map); + toDevice(interactionJsonDTO.getToSpec2(),"to_spec2",map); + toDevice(interactionJsonDTO.getToQty1(),"to_qty1",map); + toDevice(interactionJsonDTO.getToSize1(),"to_size1",map); + toDevice(interactionJsonDTO.getToSize2(),"to_size2",map); + toDevice(interactionJsonDTO.getToMaterial3(),"to_material3",map); + toDevice(interactionJsonDTO.getToMaterial4(),"to_material4",map); + toDevice(interactionJsonDTO.getToSpec3(),"to_spec3",map); + toDevice(interactionJsonDTO.getToSpec4(),"to_spec4",map); + toDevice(interactionJsonDTO.getToQty2(),"to_qty2",map); + toDevice(interactionJsonDTO.getToSize3(),"to_size3",map); + toDevice(interactionJsonDTO.getToSize4(),"to_size4",map); + } + } + + private void toDevice(String toOrder,String signal,Map map){ + if(ObjectUtil.isNotEmpty(toOrder)){ + map.put(signal, toOrder); + } + } + + public synchronized boolean finish_instruction(Instruction inst) throws Exception { instructionService.finish(inst); return true; @@ -548,7 +620,7 @@ public class PullHeadManipulatorDeviceDriver extends AbstractOpcDeviceDriver imp String mode = ""; String move = ""; String action = ""; - String walk_y = ""; + String walkY = ""; if (this.getMode() == 0) { mode = LangProcess.msg("universal_off-line"); } else if (this.getMode() == 1) { @@ -595,7 +667,7 @@ public class PullHeadManipulatorDeviceDriver extends AbstractOpcDeviceDriver imp jo.put("isError", this.getIserror()); jo.put("message", LangProcess.msg(message)); jo.put("notCreateTaskMessage", notCreateTaskMessage); - jo.put("notCreateInstMessage", notCreateInstMessage); + jo.put("notCreateInstMessage", LangProcess.msg(notCreateInstMessage)); jo.put("feedMessage", LangProcess.msg(feedMessage)); jo.put("driver_type", "siemens_conveyor"); jo.put("is_click", true); diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/pull_tail_manipulator/ItemProtocol.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/pull_tail_manipulator/ItemProtocol.java index 9ded71d24..020d30dbe 100644 --- a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/pull_tail_manipulator/ItemProtocol.java +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/pull_tail_manipulator/ItemProtocol.java @@ -27,11 +27,15 @@ public class ItemProtocol { //报警 public static String item_error = "error"; //x轴坐标 - public static String item_x_position = "x_position"; + public static String item_x_position = "x"; //y轴坐标 - public static String item_y_position = "y_position"; + public static String item_y_position = "y"; //重量 public static String item_weight = "weight"; + /** + * 子卷号 + */ + public static String item_sub_volume_no = "sub_volume_no"; //下发命令 public static String item_to_command = "to_command"; @@ -60,6 +64,10 @@ public class ItemProtocol { return this.getOpcIntegerValue(item_move); } + public String getSub_volume_no() { + return this.getOpcStringValue(item_sub_volume_no); + } + public int getAction() { return this.getOpcIntegerValue(item_action); } @@ -156,6 +164,7 @@ public class ItemProtocol { list.add(new ItemDto(item_walk_y, "行走列", "DB13.B4")); list.add(new ItemDto(item_error, "报警信号", "DB13.B5")); list.add(new ItemDto(item_task, "任务号", "DB13.D6")); + list.add(new ItemDto(item_sub_volume_no, "子卷号", "DB13.D6")); list.add(new ItemDto(item_x_position, "x坐标", "DB13.REAL10")); list.add(new ItemDto(item_y_position, "y坐标", "DB13.REAL14")); list.add(new ItemDto(item_weight, "重量", "DB13.REAL16")); diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/pull_tail_manipulator/PullTailManipulatorDeviceDriver.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/pull_tail_manipulator/PullTailManipulatorDeviceDriver.java index 09c1e2bb5..d9a5f3e88 100644 --- a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/pull_tail_manipulator/PullTailManipulatorDeviceDriver.java +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/pull_tail_manipulator/PullTailManipulatorDeviceDriver.java @@ -4,6 +4,7 @@ import cn.hutool.core.date.DateUtil; import cn.hutool.core.util.IdUtil; import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.StrUtil; +import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; import lombok.Data; import lombok.RequiredArgsConstructor; @@ -17,6 +18,13 @@ import org.nl.acs.device_driver.FeedLmsRealFailed; import org.nl.acs.device_driver.RouteableDeviceDriver; import org.nl.acs.device_driver.driver.AbstractOpcDeviceDriver; import org.nl.acs.device_driver.driver.ExecutableDeviceDriver; +import org.nl.acs.device_driver.one_manipulator.box_storage_manipulator.InteractionJsonDTO; +import org.nl.acs.ext.wms.data.ApplyPlugPullSitResponse; +import org.nl.acs.ext.wms.data.ApplyPlugPullSiteRequest; +import org.nl.acs.ext.wms.data.ApplyfeedbackSubVolumeWeightRequest; +import org.nl.acs.ext.wms.data.ApplyfeedbackSubVolumeWeightResponse; +import org.nl.acs.ext.wms.service.AcsToWmsService; +import org.nl.acs.ext.wms.service.impl.AcsToWmsServiceImpl; import org.nl.acs.history.ErrorUtil; import org.nl.acs.history.service.DeviceErrorLogService; import org.nl.acs.history.service.impl.DeviceErrorLogServiceImpl; @@ -67,6 +75,8 @@ public class PullTailManipulatorDeviceDriver extends AbstractOpcDeviceDriver imp DeviceErrorLogService errorLogServer = SpringContextHolder.getBean(DeviceErrorLogServiceImpl.class); @Autowired LuceneExecuteLogService luceneExecuteLogService = SpringContextHolder.getBean(LuceneExecuteLogService.class); + @Autowired + AcsToWmsService acsToWmsService = SpringContextHolder.getBean(AcsToWmsServiceImpl.class); //工作模式 int mode = 0; @@ -97,6 +107,8 @@ public class PullTailManipulatorDeviceDriver extends AbstractOpcDeviceDriver imp float weight = 0; float last_weight = 0; + String sub_volume_no; + int heartbeat = 0; int last_heartbeat = 0; int to_command = 0; @@ -163,6 +175,7 @@ public class PullTailManipulatorDeviceDriver extends AbstractOpcDeviceDriver imp move = this.itemProtocol.getMove(); action = this.itemProtocol.getAction(); walk_y = this.itemProtocol.getWalk_y(); + sub_volume_no = this.itemProtocol.getSub_volume_no(); error = this.itemProtocol.getError(); task = this.itemProtocol.getTask(); heartbeat = this.itemProtocol.getHeartbeat(); @@ -201,16 +214,24 @@ public class PullTailManipulatorDeviceDriver extends AbstractOpcDeviceDriver imp } //反馈重量 - if (mode == 3 && action == 5 && move == 0 && task > 0 && !requireSucess) { - Instruction inst2 = instructionService.findByCodeFromCache(String.valueOf(task)); - if (ObjectUtil.isNotEmpty(inst2)) { + if (mode == 3 && action == 5 && move == 0 && StrUtil.isNotEmpty(sub_volume_no) && !requireSucess) { + ApplyfeedbackSubVolumeWeightRequest applyfeedbackSubVolumeWeightRequest = new ApplyfeedbackSubVolumeWeightRequest(); + ApplyfeedbackSubVolumeWeightResponse applyPlugPullSitResponse; + applyfeedbackSubVolumeWeightRequest.setSub_volume(sub_volume_no); + applyfeedbackSubVolumeWeightRequest.setWeight1(String.valueOf(weight)); + applyPlugPullSitResponse = acsToWmsService.applyfeedbackSubVolumeWeight(applyfeedbackSubVolumeWeightRequest); + if(applyPlugPullSitResponse.getCode() == CommonFinalParam.STATUS_OPEN){ Map map = new LinkedHashMap<>(); //todo:反馈重量 map.put("to_command", "5"); this.writing(map); this.requireSucess = true; - } else { - logServer.deviceExecuteLog(this.device_code, "", "", "未反馈电气信号原因:当前步骤不为允许取货(now_steps_type!=3)"); + }else{ + LuceneLogDto logDto = LuceneLogDto.builder() + .device_code(device_code) + .content("反馈LMS子卷重量失败:"+ applyPlugPullSitResponse.getMessage()) + .build(); + luceneExecuteLogService.deviceExecuteLog(logDto); } } else { feedMessage = "行架机械手:"; @@ -359,6 +380,7 @@ public class PullTailManipulatorDeviceDriver extends AbstractOpcDeviceDriver imp //抓取工位 List getDeviceCodeList = this.getExtraDeviceCodes("get_device_code"); //放货工位 + List putDeviceCodeList = this.getExtraDeviceCodes("put_device_code"); TaskDto task = null; for (int i = 0; i < getDeviceCodeList.size(); i++) { @@ -384,7 +406,29 @@ public class PullTailManipulatorDeviceDriver extends AbstractOpcDeviceDriver imp } String start_addr = startDevice.getExtraValue().get("address").toString(); String next_addr = nextDevice.getExtraValue().get("address").toString(); + String interactionJson = taskDto.getInteraction_json(); + InteractionJsonDTO interactionJsonDTO = JSON.parseObject(interactionJson, InteractionJsonDTO.class); Map map = new LinkedHashMap<>(); + /*if(ObjectUtil.isNotEmpty(interactionJsonDTO)){ + toDevice(interactionJsonDTO.getToPull(),"to_pull",map); + toDevice(interactionJsonDTO.getIsBushing(),"is_bushing",map); + toDevice(interactionJsonDTO.getToSize(),"to_size",map); + toDevice(interactionJsonDTO.getToBarcode(),"to_barcode",map); + toDevice(interactionJsonDTO.getToMaterial1(),"to_material1",map); + toDevice(interactionJsonDTO.getToMaterial2(),"to_material2",map); + toDevice(interactionJsonDTO.getToSpec1(),"to_spec1",map); + toDevice(interactionJsonDTO.getToSpec2(),"to_spec2",map); + toDevice(interactionJsonDTO.getToQty1(),"to_qty1",map); + toDevice(interactionJsonDTO.getToSize1(),"to_size1",map); + toDevice(interactionJsonDTO.getToSize2(),"to_size2",map); + toDevice(interactionJsonDTO.getToMaterial3(),"to_material3",map); + toDevice(interactionJsonDTO.getToMaterial4(),"to_material4",map); + toDevice(interactionJsonDTO.getToSpec3(),"to_spec3",map); + toDevice(interactionJsonDTO.getToSpec4(),"to_spec4",map); + toDevice(interactionJsonDTO.getToQty2(),"to_qty2",map); + toDevice(interactionJsonDTO.getToSize3(),"to_size3",map); + toDevice(interactionJsonDTO.getToSize4(),"to_size4",map); + }*/ map.put("to_command", CommonFinalParam.ONE); map.put("to_onset", start_addr); map.put("to_task", instruction.getInstruction_code()); @@ -434,13 +478,17 @@ public class PullTailManipulatorDeviceDriver extends AbstractOpcDeviceDriver imp instdto.setPriority(priority); instdto.setInstruction_status(InstructionStatusEnum.READY.getIndex()); instdto.setExecute_device_code(start_point_code); - + String interactionJson = task.getInteraction_json(); + InteractionJsonDTO interactionJsonDTO = JSON.parseObject(interactionJson, InteractionJsonDTO.class); try { instructionService.create(instdto); } catch (Exception e) { notCreateInstMessage = e.getMessage(); - logServer.deviceExecuteLog(this.getDevice_code(), "", "", "创建指令时出现异常:" + e.getMessage()); - return false; + LuceneLogDto logDto = LuceneLogDto.builder() + .device_code(device_code) + .content(device_code+"创建指令时出现异常:" + e.getMessage()) + .build(); + luceneExecuteLogService.deviceExecuteLog(logDto); return false; } //创建指令后修改任务状态 task.setTask_status(TaskStatusEnum.BUSY.getIndex()); @@ -463,6 +511,26 @@ public class PullTailManipulatorDeviceDriver extends AbstractOpcDeviceDriver imp String start_addr = startDevice.getExtraValue().get("address").toString(); String next_addr = nextDevice.getExtraValue().get("address").toString(); Map map = new LinkedHashMap<>(); + /*if(ObjectUtil.isNotEmpty(interactionJsonDTO)){ + toDevice(interactionJsonDTO.getToPull(),"to_pull",map); + toDevice(interactionJsonDTO.getIsBushing(),"is_bushing",map); + toDevice(interactionJsonDTO.getToSize(),"to_size",map); + toDevice(interactionJsonDTO.getToBarcode(),"to_barcode",map); + toDevice(interactionJsonDTO.getToMaterial1(),"to_material1",map); + toDevice(interactionJsonDTO.getToMaterial2(),"to_material2",map); + toDevice(interactionJsonDTO.getToSpec1(),"to_spec1",map); + toDevice(interactionJsonDTO.getToSpec2(),"to_spec2",map); + toDevice(interactionJsonDTO.getToQty1(),"to_qty1",map); + toDevice(interactionJsonDTO.getToSize1(),"to_size1",map); + toDevice(interactionJsonDTO.getToSize2(),"to_size2",map); + toDevice(interactionJsonDTO.getToMaterial3(),"to_material3",map); + toDevice(interactionJsonDTO.getToMaterial4(),"to_material4",map); + toDevice(interactionJsonDTO.getToSpec3(),"to_spec3",map); + toDevice(interactionJsonDTO.getToSpec4(),"to_spec4",map); + toDevice(interactionJsonDTO.getToQty2(),"to_qty2",map); + toDevice(interactionJsonDTO.getToSize3(),"to_size3",map); + toDevice(interactionJsonDTO.getToSize4(),"to_size4",map); + }*/ map.put("to_command", CommonFinalParam.ONE); map.put("to_onset", start_addr); map.put("to_task", instdto.getInstruction_code()); @@ -478,6 +546,14 @@ public class PullTailManipulatorDeviceDriver extends AbstractOpcDeviceDriver imp } } + + private void toDevice(String toOrder,String signal,Map map){ + if(ObjectUtil.isNotEmpty(toOrder)){ + map.put(signal, toOrder); + } + } + + public synchronized boolean finish_instruction(Instruction inst) throws Exception { instructionService.finish(inst); return true; @@ -501,7 +577,11 @@ public class PullTailManipulatorDeviceDriver extends AbstractOpcDeviceDriver imp } }); if (ObjectUtil.isNotEmpty(itemMap)) { - this.control(itemMap); + try { + this.checkcontrol(itemMap); + } catch (Exception e) { + e.printStackTrace(); + } logServer.deviceExecuteLog(this.getDevice().getDevice_code(), "", "", "下发多个电气信号:" + itemMap); LuceneLogDto logDto = LuceneLogDto.builder() .device_code(device_code) @@ -582,7 +662,7 @@ public class PullTailManipulatorDeviceDriver extends AbstractOpcDeviceDriver imp jo.put("isError", this.getIserror()); jo.put("message", LangProcess.msg(message)); jo.put("notCreateTaskMessage", notCreateTaskMessage); - jo.put("notCreateInstMessage", notCreateInstMessage); + jo.put("notCreateInstMessage", LangProcess.msg(notCreateInstMessage)); jo.put("feedMessage", LangProcess.msg(feedMessage)); jo.put("driver_type", "siemens_conveyor"); jo.put("is_click", true); diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/slit_two_manipulator/SlitTwoManipulatorDeviceDriver.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/slit_two_manipulator/SlitTwoManipulatorDeviceDriver.java index 5e359505e..96b1626a1 100644 --- a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/slit_two_manipulator/SlitTwoManipulatorDeviceDriver.java +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/slit_two_manipulator/SlitTwoManipulatorDeviceDriver.java @@ -762,7 +762,7 @@ public class SlitTwoManipulatorDeviceDriver extends AbstractOpcDeviceDriver impl jo.put("is_click", true); jo.put("driver_type", "slit_two_manipulator"); jo.put("notCreateTaskMessage", notCreateTaskMessage); - jo.put("notCreateInstMessage", notCreateInstMessage); + jo.put("notCreateInstMessage", LangProcess.msg(notCreateInstMessage)); jo.put("feedMessage", LangProcess.msg(feedMessage)); return jo; } diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/sub_roll_conveyor_site/SubRollConveyorSiteDeviceDriver.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/sub_roll_conveyor_site/SubRollConveyorSiteDeviceDriver.java index 0fb13996c..a80366db9 100644 --- a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/sub_roll_conveyor_site/SubRollConveyorSiteDeviceDriver.java +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/sub_roll_conveyor_site/SubRollConveyorSiteDeviceDriver.java @@ -106,6 +106,8 @@ public class SubRollConveyorSiteDeviceDriver extends AbstractOpcDeviceDriver imp //当前指令 Instruction inst = null; + String notCreateTaskMessage = ""; + /** * 1-执行任务;2-取货完成;3-放货完成; */ @@ -166,6 +168,24 @@ public class SubRollConveyorSiteDeviceDriver extends AbstractOpcDeviceDriver imp Map map = new LinkedHashMap<>(); map.put("to_command", 1); this.writing(map); + }else { + String remark = "";; + if (mode != 2) { + remark = "universal_remark2"; + } + if (move != 0) { + remark = "universal_remark3"; + } + if (task != 0) { + remark = "universal_remark4"; + if (ObjectUtil.isNotEmpty(this.inst)) { + this.inst = null; + } + } + if (requireSucess) { + remark = "universal_remark5"; + } + this.setNotCreateTaskMessage(remark); } break; default: @@ -262,6 +282,7 @@ public class SubRollConveyorSiteDeviceDriver extends AbstractOpcDeviceDriver imp jo.put("move", move); jo.put("isOnline", this.getIsonline()); jo.put("isError", this.getIserror()); + jo.put("notCreateTaskMessage", notCreateTaskMessage); return jo; } diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/enums/AcsToLmsApplyTaskTypeEnum.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/enums/AcsToLmsApplyTaskTypeEnum.java index 54f94586f..8b3504e0d 100644 --- a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/enums/AcsToLmsApplyTaskTypeEnum.java +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/enums/AcsToLmsApplyTaskTypeEnum.java @@ -6,9 +6,13 @@ import lombok.Getter; @Getter @AllArgsConstructor public enum AcsToLmsApplyTaskTypeEnum { - LABEL_BIND("1", "捆轧贴标"), + LABEL_BIND("1", "申请捆轧贴标信息"), + + AGV("2", "AGV任务"), + + LABEL("3", "申请贴标"); + - AGV("2", "AGV任务"); /** * 索引 */ diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/enums/ContainerTypeEnum.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/enums/ContainerTypeEnum.java new file mode 100644 index 000000000..f43b99199 --- /dev/null +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/enums/ContainerTypeEnum.java @@ -0,0 +1,20 @@ +package org.nl.acs.enums; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +@Getter +@AllArgsConstructor +public enum ContainerTypeEnum { + SMALL("1", "小托盘"), + + BIG("2", "大托盘"); + /** + * 索引 + */ + private String type; + /** + * 编码 + */ + private String value; +} diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/wms/data/ApplyPlugPullSiteRequest.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/wms/data/ApplyPlugPullSiteRequest.java index 7dd89696e..0ee36fc0b 100644 --- a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/wms/data/ApplyPlugPullSiteRequest.java +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/wms/data/ApplyPlugPullSiteRequest.java @@ -50,4 +50,13 @@ public class ApplyPlugPullSiteRequest extends BaseRequest { * 尺寸 3,6寸 */ private String size; + /** + * 气胀轴条码 + */ + private String qzz_no; + /** + * 子卷号 + */ + private String sub_volume; + } diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/wms/data/ApplyfeedbackSubVolumeWeightRequest.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/wms/data/ApplyfeedbackSubVolumeWeightRequest.java new file mode 100644 index 000000000..5d7568911 --- /dev/null +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/wms/data/ApplyfeedbackSubVolumeWeightRequest.java @@ -0,0 +1,18 @@ +package org.nl.acs.ext.wms.data; + +import lombok.Data; + +@Data +public class ApplyfeedbackSubVolumeWeightRequest { + + /** + * 子卷号 + */ + private String sub_volume; + + /** + * 子卷重量 + */ + private String weight1; + +} diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/wms/data/ApplyfeedbackSubVolumeWeightResponse.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/wms/data/ApplyfeedbackSubVolumeWeightResponse.java new file mode 100644 index 000000000..c4ea3a967 --- /dev/null +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/wms/data/ApplyfeedbackSubVolumeWeightResponse.java @@ -0,0 +1,13 @@ +package org.nl.acs.ext.wms.data; + +import lombok.Data; + +import java.util.HashMap; +import java.util.Map; + +@Data +public class ApplyfeedbackSubVolumeWeightResponse extends BaseResponse { + + private Map data = new HashMap(); + +} diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/wms/rest/WmsToAcsController.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/wms/rest/WmsToAcsController.java index 13b11b14b..9265ed8b0 100644 --- a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/wms/rest/WmsToAcsController.java +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/wms/rest/WmsToAcsController.java @@ -54,6 +54,13 @@ public class WmsToAcsController { return new ResponseEntity<>(wmstoacsService.updateDeviceGoodsFromWms(whereJson), HttpStatus.OK); } + @PostMapping("/updateTask") + @Log(value = "WMS更新任务点位状态") + @SaIgnore + public ResponseEntity updateTask(@RequestBody String whereJson){ + return new ResponseEntity<>(wmstoacsService.updateTask(whereJson), HttpStatus.OK); + } + @PostMapping("/areaControl") @Log(value = "区域控制") public ResponseEntity areaControl(@RequestBody JSONObject whereJson) { diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/wms/service/AcsToWmsService.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/wms/service/AcsToWmsService.java index 13097c791..f4d083aa8 100644 --- a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/wms/service/AcsToWmsService.java +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/wms/service/AcsToWmsService.java @@ -164,6 +164,13 @@ public interface AcsToWmsService { */ ApplyPlugPullSitResponse applyPlugPullSiteRequest(ApplyPlugPullSiteRequest param); + /** + * 向LMS反馈子卷重量 + * @param param + * @return + */ + ApplyfeedbackSubVolumeWeightResponse applyfeedbackSubVolumeWeight(ApplyfeedbackSubVolumeWeightRequest param); + /** * 查询站点有无货状态 diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/wms/service/WmsToAcsService.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/wms/service/WmsToAcsService.java index ec27c8d44..b684c5951 100644 --- a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/wms/service/WmsToAcsService.java +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/wms/service/WmsToAcsService.java @@ -25,6 +25,14 @@ public interface WmsToAcsService { */ CreateTaskResponse crateTask(List reqs); + /** + * 更新任务点位状态 + * + * @param whereJson 条件 + * @return Map + */ + Map updateTask(String whereJson); + /** * 取消任务 diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/wms/service/impl/AcsToWmsServiceImpl.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/wms/service/impl/AcsToWmsServiceImpl.java index be040d076..d820d2429 100644 --- a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/wms/service/impl/AcsToWmsServiceImpl.java +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/wms/service/impl/AcsToWmsServiceImpl.java @@ -485,6 +485,42 @@ public class AcsToWmsServiceImpl implements AcsToWmsService { } } + @Override + public ApplyfeedbackSubVolumeWeightResponse applyfeedbackSubVolumeWeight(ApplyfeedbackSubVolumeWeightRequest param) { + log.info("向LMS申请反馈,请求参数{}",param); + try { + MDC.put(log_file_type, log_type); + ApplyfeedbackSubVolumeWeightResponse applyfeedbackSubVolumeWeightResponse = new ApplyfeedbackSubVolumeWeightResponse(); + if (StrUtil.equals(paramService.findByCode(AcsConfig.HASWMS).getValue(), "1")) { + String wmsUrl = paramService.findByCode(AcsConfig.WMSURL).getValue(); + AddressDto addressDto = addressService.findByCode("applyfeedbackSubVolumeWeightRequest"); + String methods_url = addressDto.getMethods_url(); + String url = wmsUrl + methods_url; + log.info("applyfeedbackSubVolumeWeightRequest----请求参数:{}", JSONObject.toJSONString(param)); + try { +// String result = ""; + String result = HttpRequest.post(url) + .body(JSON.toJSONString(param)) + .execute().body(); + JSONObject jsonObject = JSONObject.parseObject(result); + log.info("applyfeedbackSubVolumeWeightRequest----返回参数{}", result); + applyfeedbackSubVolumeWeightResponse = JSONObject.toJavaObject(jsonObject, ApplyfeedbackSubVolumeWeightResponse.class); + } catch (Exception e) { + JSONObject map = new JSONObject(); + map.put("status", 400); + map.put("message", e.getMessage()); + return JSONObject.toJavaObject(map, ApplyfeedbackSubVolumeWeightResponse.class); + } + LuceneLogDto luceneLogDto = new LuceneLogDto("applyfeedbackSubVolumeWeightRequest", String.valueOf(applyfeedbackSubVolumeWeightResponse.getCode()), + JSON.toJSONString(param), String.valueOf(applyfeedbackSubVolumeWeightResponse.getMessage()), "ACS向LMS申请套管"); + luceneLogService.interfaceExecuteLog(luceneLogDto); + } + return applyfeedbackSubVolumeWeightResponse; + } finally { + MDC.remove(log_file_type); + } + } + @Override public ApplyManipulatorActionResponse applyManipulatorActionRequest(ApplyManipulatorActionRequest param) { log.info("向LMS申请反馈,请求参数{}", param); @@ -512,7 +548,7 @@ public class AcsToWmsServiceImpl implements AcsToWmsService { return JSONObject.toJavaObject(map, ApplyManipulatorActionResponse.class); } LuceneLogDto luceneLogDto = new LuceneLogDto("ApplyManipulatorActionRequest", String.valueOf(applyManipulatorActionResponse.getCode()), - JSON.toJSONString(param), String.valueOf(applyManipulatorActionResponse), "ACS向LMS申请反馈"); + JSON.toJSONString(param), String.valueOf(applyManipulatorActionResponse), "ACS向LMS申请反馈子卷重量"); luceneLogService.interfaceExecuteLog(luceneLogDto); } return applyManipulatorActionResponse; diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/wms/service/impl/WmsToAcsServiceImpl.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/wms/service/impl/WmsToAcsServiceImpl.java index f158dceb0..32d80efdc 100644 --- a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/wms/service/impl/WmsToAcsServiceImpl.java +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/wms/service/impl/WmsToAcsServiceImpl.java @@ -15,12 +15,15 @@ import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.nl.acs.AcsConfig; import org.nl.acs.device.domain.Device; +import org.nl.acs.device_driver.agv.ndctwo.AgvNdcTwoDeviceDriver; import org.nl.acs.device_driver.conveyor.siemens_conveyor.SiemensConveyorDeviceDriver; +import org.nl.acs.device_driver.conveyor.standard_ordinary_site.StandardOrdinarySiteDeviceDriver; import org.nl.acs.device_driver.one_manipulator.box_package_manipulator.BoxPackageManipulatorDeviceDriver; import org.nl.acs.device_driver.conveyor.box_palletizing_manipulator.BoxPalletizingManipulatorDeviceDriver; import org.nl.acs.device_driver.paper_tube_device2.PaperTubeConveyor2DeviceDriver; import org.nl.acs.device_driver.two_conveyor.blank_manipulator.BlankManipulatorDeviceDriver; import org.nl.acs.device_driver.two_conveyor.hongxiang_conveyor.HongXiangStationDeviceDriver; +import org.nl.acs.device_driver.two_conveyor.hongxiang_device.HongXiangConveyorDeviceDriver; import org.nl.acs.device_driver.two_conveyor.inflatable_shaft_library.InflatableShaftLibraryDeviceDriver; import org.nl.acs.device_driver.two_conveyor.lamp_three_color.LampThreecolorDeviceDriver; import org.nl.acs.device_driver.two_conveyor.oven_manipulator.OvenGantryManipulatorDeviceDriver; @@ -34,6 +37,7 @@ import org.nl.acs.ext.wms.service.AcsToLiKuService; import org.nl.acs.ext.wms.service.WmsToAcsService; import org.nl.acs.instruction.domain.Instruction; +import org.nl.acs.instruction.service.InstructionService; import org.nl.acs.opc.DeviceAppService; import org.nl.acs.storage_cell.domain.StorageCell; import org.nl.acs.storage_cell.service.mapper.StorageCellMapper; @@ -68,6 +72,9 @@ public class WmsToAcsServiceImpl implements WmsToAcsService { @Autowired private LuceneExecuteLogService luceneExecuteLogService; + @Autowired + private InstructionService instructionService; + @Autowired private AcsToLiKuService acsToLiKuService; @@ -387,6 +394,80 @@ public class WmsToAcsServiceImpl implements WmsToAcsService { return null; } + @Override + public Map updateTask(String whereJson) { + JSONArray datas = JSONArray.parseArray(whereJson); + log.info("updateTask--------------:输入参数" + datas.toString()); + JSONArray errArr = new JSONArray(); + if (datas.size() > 0) { + for (int i = 0; i < datas.size(); i++) { + JSONObject jsonObject = datas.getJSONObject(i); + String device_code = jsonObject.getString("device_code"); + String task_code = jsonObject.getString("task_code"); + //1-允许取放; 2-允许离开 + String option = jsonObject.getString("option"); + Instruction inst = instructionService.findByTaskcode(task_code); + if (ObjectUtil.isEmpty(inst)) { + JSONObject jo = new JSONObject(); + jo.put("task_code", task_code); + jo.put("message", "未找到对应任务"); + errArr.add(jo); + continue; + } else { + String carNo = inst.getCarno(); + if (ObjectUtil.isEmpty(carNo)) { + JSONObject jo = new JSONObject(); + jo.put("task_code", task_code); + jo.put("message", "未找到任务对应车号"); + errArr.add(jo); + continue; + } else { + Device device = deviceAppService.findDeviceByCode(carNo); + AgvNdcTwoDeviceDriver agvNdcTwoDeviceDriver; + if (device.getDeviceDriver() instanceof AgvNdcTwoDeviceDriver) { + agvNdcTwoDeviceDriver = (AgvNdcTwoDeviceDriver) device.getDeviceDriver(); + int phase = agvNdcTwoDeviceDriver.getPhase(); + if (phase == 0x03 || phase == 0x05 || phase == 0x08) { + StandardOrdinarySiteDeviceDriver standardOrdinarySiteDeviceDriver; + Device device_k = deviceAppService.findDeviceByCode(device_code + "_K"); + Device device_m = deviceAppService.findDeviceByCode(device_code + "_M"); + if (device_k.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) { + standardOrdinarySiteDeviceDriver = (StandardOrdinarySiteDeviceDriver) device_k.getDeviceDriver(); + standardOrdinarySiteDeviceDriver.setOption(Integer.parseInt(option)); + standardOrdinarySiteDeviceDriver.setTask_code(task_code); + } + if (device_m.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) { + standardOrdinarySiteDeviceDriver = (StandardOrdinarySiteDeviceDriver) device_m.getDeviceDriver(); + standardOrdinarySiteDeviceDriver.setOption(Integer.parseInt(option)); + standardOrdinarySiteDeviceDriver.setTask_code(task_code); + } + } else { + JSONObject jo = new JSONObject(); + jo.put("task_code", task_code); + jo.put("message", "AGV未就绪无法设置"); + errArr.add(jo); + continue; + } + } + } + + } + } + } + JSONObject resultJson = new JSONObject(); + if (ObjectUtil.isEmpty(errArr)) { + resultJson.put("status", HttpStatus.OK.value()); + resultJson.put("message", "操作成功"); + } else { + resultJson.put("status", HttpStatus.BAD_REQUEST.value()); + resultJson.put("message", "操作失败"); + if (ObjectUtil.isNotEmpty(errArr)) { + resultJson.put("errArr", errArr); + } + } + return resultJson; + } + @Override public org.nl.acs.ext.wms.data.one.CancelTaskResponse cancelFromWms(List reqs) throws Exception { return null; @@ -525,6 +606,8 @@ public class WmsToAcsServiceImpl implements WmsToAcsService { BlankManipulatorDeviceDriver blankManipulatorDeviceDriver; //烘箱行架机械手 OvenGantryManipulatorDeviceDriver ovenGantryManipulatorDeviceDriver; + //烘箱 + HongXiangConveyorDeviceDriver hongXiangConveyorDeviceDriver; //装箱行架机械手 BoxPackageManipulatorDeviceDriver boxManipulatorDeviceDriver; //木箱码垛机械手 @@ -567,6 +650,24 @@ public class WmsToAcsServiceImpl implements WmsToAcsService { jo.put("action", Math.min(3, blankManipulatorDeviceDriver.getAction())); jo.put("task", Math.min(3, blankManipulatorDeviceDriver.getTask())); jo.put("error", blankManipulatorDeviceDriver.getError()); + }else if (device.getDeviceDriver() instanceof HongXiangConveyorDeviceDriver) { + hongXiangConveyorDeviceDriver = (HongXiangConveyorDeviceDriver) device.getDeviceDriver(); + jo.put("device_code", parent_device_code); + jo.put("mode", hongXiangConveyorDeviceDriver.getMode()); + jo.put("status", Math.min(3, hongXiangConveyorDeviceDriver.getMode())); + jo.put("move", hongXiangConveyorDeviceDriver.getMove()); + jo.put("countdown_house", hongXiangConveyorDeviceDriver.getCountdown_house()); + jo.put("countdown_min", hongXiangConveyorDeviceDriver.getCountdown_min()); + jo.put("countdown_sec", hongXiangConveyorDeviceDriver.getCountdown_sec()); + //温度需要除以10 + jo.put("temperature", hongXiangConveyorDeviceDriver.getTo_temperature() / 10); + jo.put("now_temperature", hongXiangConveyorDeviceDriver.getTemperature() / 10); + + jo.put("door", hongXiangConveyorDeviceDriver.getDoor()); + jo.put("finish", hongXiangConveyorDeviceDriver.getFinish()); + jo.put("task", hongXiangConveyorDeviceDriver.getTask()); + jo.put("error", hongXiangConveyorDeviceDriver.getError()); + jo.put("isError", hongXiangConveyorDeviceDriver.getError()); } else if (device.getDeviceDriver() instanceof OvenGantryManipulatorDeviceDriver) { ovenGantryManipulatorDeviceDriver = (OvenGantryManipulatorDeviceDriver) device.getDeviceDriver(); jo.put("device_code", ovenGantryManipulatorDeviceDriver.getDevice().getDevice_code()); diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/instruction/service/InstructionService.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/instruction/service/InstructionService.java index 39346beda..7e0f8d102 100644 --- a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/instruction/service/InstructionService.java +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/instruction/service/InstructionService.java @@ -333,6 +333,14 @@ public interface InstructionService extends CommonService { */ Instruction findByDeviceCodeFromCache(String devicecode); + + /** + * 根据终点查询指令 + * @param devicecode + * @return + */ + Instruction findByNextDeviceCodeFromCache(String devicecode); + /** * 根据设备id查询 * diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/instruction/service/impl/InstructionServiceImpl.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/instruction/service/impl/InstructionServiceImpl.java index 65d5f5a41..9d60e98e9 100644 --- a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/instruction/service/impl/InstructionServiceImpl.java +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/instruction/service/impl/InstructionServiceImpl.java @@ -1163,32 +1163,7 @@ public class InstructionServiceImpl extends CommonServiceImpl instructionList = instructions; + ListUtil.sort( + instructionList, + new Comparator() { + @Override + public int compare(Instruction o1, Instruction o2) { + return o1.getCreate_time().compareTo(o2.getCreate_time()); + } + }); + Iterator it = instructions.iterator(); + while (it.hasNext()) { + Instruction inst = it.next(); + if (StrUtil.equals(devicecode, inst.getNext_device_code()) && Integer.parseInt(inst.getInstruction_status())<=Integer.parseInt(InstructionStatusEnum.BUSY.getIndex())) { + return inst; + } + } + + return null; + } + @Override public List findAllInstFromCache() { return instructions; diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/route/service/impl/RouteLineServiceImpl.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/route/service/impl/RouteLineServiceImpl.java index b9aff96da..d9c6ed52a 100644 --- a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/route/service/impl/RouteLineServiceImpl.java +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/route/service/impl/RouteLineServiceImpl.java @@ -331,6 +331,7 @@ public class RouteLineServiceImpl extends CommonServiceImpl list = new LambdaQueryChainWrapper<>(routeLineMapper) .eq(RouteLine::getDevice_code, dto.getDevice_code()) .eq(RouteLine::getNext_device_code, dto.getNext_device_code()) + .eq(RouteLine::getRoute_plan_id, dto.getRoute_plan_id()) .list(); if (list.size() == 0) { // wo.insert(json); diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/task/service/TaskService.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/task/service/TaskService.java index cc47d947a..f671b0cb9 100644 --- a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/task/service/TaskService.java +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/task/service/TaskService.java @@ -389,6 +389,15 @@ public interface TaskService extends CommonService { */ TaskDto findByStartCodeAndReady(String device_code); + + /** + * 根据起载具号查询就绪任务 + * + * @param device_code + * @return + */ + TaskDto findByVehicleCodeCodeAndReady(String device_code); + /** * 根据起点设备编号查询当前是否有执行中任务 * diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/task/service/dto/TaskDto.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/task/service/dto/TaskDto.java index 34855a6b5..b5a63553a 100644 --- a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/task/service/dto/TaskDto.java +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/task/service/dto/TaskDto.java @@ -54,6 +54,11 @@ public class TaskDto implements Serializable { */ private String task_status; + /** + * 车号 + */ + private String carno; + /** * 复合任务 */ diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/task/service/impl/TaskServiceImpl.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/task/service/impl/TaskServiceImpl.java index a4e562884..247c199da 100644 --- a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/task/service/impl/TaskServiceImpl.java +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/task/service/impl/TaskServiceImpl.java @@ -568,11 +568,14 @@ public class TaskServiceImpl extends CommonServiceImpl impleme // 判断起点终点设备类型 String startDeviceType = deviceAppService.findDeviceTypeByCode(dto.getStart_device_code()); String nextDeviceType = deviceAppService.findDeviceTypeByCode(dto.getNext_device_code()); - if (routeLineService - .getShortPathLines(dto.getStart_device_code(), dto.getNext_device_code(), plan_code) - .size() - == 0) { - throw new BadRequestException(dto.getStart_point_code() + "->" + dto.getNext_point_code() + " " + LangProcess.msg("route_isNull")); + // 同一排转库任务不做路由校验 + if (!(StrUtil.equals(DeviceType.storage.toString(), startDeviceType) && StrUtil.equals(DeviceType.storage.toString(), nextDeviceType) && StrUtil.equals(start_device_code, next_device_code))) { + if (routeLineService + .getShortPathLines(dto.getStart_device_code(), dto.getNext_device_code(), plan_code) + .size() + == 0) { + throw new BadRequestException(dto.getStart_point_code() + "->" + dto.getNext_point_code() + " " + LangProcess.msg("route_isNull")); + } } String createTaskCheck = paramService.findByCode(AcsConfig.CREATETASKCHECK).getValue(); DeviceService deviceService = SpringContextHolder.getBean(DeviceServiceImpl.class); @@ -1007,6 +1010,7 @@ public class TaskServiceImpl extends CommonServiceImpl impleme map.put("路由方案编码", acsTask.getRoute_plan_code()); map.put("是否需要反馈上位系统", acsTask.getIs_needfeedback()); map.put("备注", acsTask.getRemark()); + map.put("agv车号", acsTask.getCarno()); map.put("是否启用", acsTask.getIs_active()); map.put("是否删除", acsTask.getIs_delete()); map.put("创建者", acsTask.getCreate_by()); @@ -1076,6 +1080,15 @@ public class TaskServiceImpl extends CommonServiceImpl impleme return optionalTask.orElse(null); } + @Override + public TaskDto findByVehicleCodeCodeAndReady(String vehicleCode) { + Optional optionalTask = tasks.stream() + .filter(task -> StrUtil.equals(task.getVehicle_code(), vehicleCode) + && StrUtil.equals(task.getTask_status(), TaskStatusEnum.READY.getIndex())) + .findFirst(); + return optionalTask.orElse(null); + } + @Override public TaskDto findByCodeAndExcute(String start_code, String next_code) { Task task = this.lambdaQuery() @@ -1588,6 +1601,12 @@ public class TaskServiceImpl extends CommonServiceImpl impleme feed_jo.put("task_id", entity.getExt_task_id()); feed_jo.put("task_code", entity.getTask_code()); feed_jo.put("task_status", entity.getTask_status()); + if (ObjectUtil.isNotEmpty(entity.getWeight())) { + feed_jo.put("weight", entity.getWeight()); + } + if (ObjectUtil.isNotEmpty(entity.getCarno())) { + feed_jo.put("car_no", entity.getCarno()); + } JSONArray ja = new JSONArray(); ja.add(feed_jo); //TODO 有需要根据上位系统反馈的信息再做进一步处理 diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/taskscreen/service/impl/TaskScreenServiceImpl.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/taskscreen/service/impl/TaskScreenServiceImpl.java index c9e3ccd7d..5df32fbfb 100644 --- a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/taskscreen/service/impl/TaskScreenServiceImpl.java +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/taskscreen/service/impl/TaskScreenServiceImpl.java @@ -81,6 +81,9 @@ public class TaskScreenServiceImpl extends CommonServiceImpl extraDeviceCodes = getExtraDeviceCodes(extraValue); if (CollUtil.isEmpty(extraDeviceCodes) || extraDeviceCodes.size() < 0) { diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/utils/ReadUtil.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/utils/ReadUtil.java index 604d61376..e6b3e4714 100644 --- a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/utils/ReadUtil.java +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/utils/ReadUtil.java @@ -1,5 +1,6 @@ package org.nl.acs.utils; +import cn.hutool.core.util.StrUtil; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; @@ -46,7 +47,7 @@ public class ReadUtil { // 连接信息 ConnectionInformation ci = new ConnectionInformation(); ci.setHost(opc.getOpc_host()); - ci.setDomain(opc.getDomain()); + ci.setDomain(StrUtil.isEmpty(opc.getDomain()) ? " " : opc.getDomain()); ci.setUser(opc.getUser()); ci.setPassword(opc.getPassword()); ci.setClsid(opc.getCls_id()); diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/hand/dto/B2HeadDto.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/hand/dto/B2HeadDto.java new file mode 100644 index 000000000..2988dec90 --- /dev/null +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/hand/dto/B2HeadDto.java @@ -0,0 +1,37 @@ +package org.nl.hand.dto; + +import lombok.Data; + +import java.io.Serializable; + +/** + * @Author : TuQiang + * @create 2024/4/15 13:59 + */ +@Data +public class B2HeadDto implements Serializable { + /** + * 起始设备编码1 + */ + private String start_device_code1; + + /** + * 目标设备编码1 + */ + private String next_device_code1; + + /** + * 起始设备编码2 + */ + private String start_device_code2; + + /** + * 目标设备编码2 + */ + private String next_device_code2; + + /** + * 任务类型 + */ + private String task_type; +} diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/hand/dto/HeadDeviceDto.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/hand/dto/HeadDeviceDto.java new file mode 100644 index 000000000..7fe53c279 --- /dev/null +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/hand/dto/HeadDeviceDto.java @@ -0,0 +1,26 @@ +package org.nl.hand.dto; + +import lombok.Data; + +import java.io.Serializable; + +/** + * @Author : TuQiang + * @create 2024/4/15 15:04 + */ +@Data +public class HeadDeviceDto implements Serializable { + /** + * 设备号 + */ + private String device_code; + + /** + * 操作类型 + * 0-禁止进出; + * 1-允许取放 + * 2-允许离开 + * + */ + private String option; +} diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/hand/rest/B2HandController.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/hand/rest/B2HandController.java new file mode 100644 index 000000000..8d1c518df --- /dev/null +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/hand/rest/B2HandController.java @@ -0,0 +1,83 @@ +package org.nl.hand.rest; + +import cn.dev33.satoken.annotation.SaIgnore; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.nl.common.logging.annotation.Log; +import org.nl.hand.dto.B2HeadDto; +import org.nl.hand.dto.HeadDeviceDto; +import org.nl.hand.dto.RegionDto; +import org.nl.hand.service.B2HandService; +import org.nl.hand.service.HandService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * @Author : TuQiang + * @create 2024/4/15 13:50 + */ +@RestController +@RequiredArgsConstructor +@Api(tags = "手持接口") +@RequestMapping("api/hands") +@Slf4j +public class B2HandController { + @Autowired + private B2HandService b2HandService; + + @Autowired + private HandService handService; + + @PostMapping("/queryArea") + @Log("查询区域") + @ApiOperation("查询区域") + @SaIgnore + //@PreAuthorize("@el.check('sect:list')") + public ResponseEntity queryArea() { + return new ResponseEntity<>(handService.queryArea(), HttpStatus.OK); + } + + @PostMapping("/queryPointByArea") + @Log("根据区域编码查点位") + @ApiOperation("根据区域编码查点位") + @SaIgnore + //@PreAuthorize("@el.check('sect:list')") + public ResponseEntity queryPointByArea(@RequestBody RegionDto dto) { + String region_code = dto.getRegion_code(); + return new ResponseEntity<>(handService.queryPointByArea(region_code), HttpStatus.OK); + } + + @PostMapping("/callTask") + @Log("手持创建任务") + @ApiOperation("手持创建任务") + @SaIgnore + //@PreAuthorize("@el.check('sect:list')") + public ResponseEntity callTask(@RequestBody B2HeadDto dto) { + return new ResponseEntity<>(b2HandService.callTask(dto), HttpStatus.OK); + } + + @PostMapping("/queryDevices") + @Log("查询所有设备") + @ApiOperation("查询所有设备") + @SaIgnore + //@PreAuthorize("@el.check('sect:list')") + public ResponseEntity queryDevices() { + return new ResponseEntity<>(b2HandService.queryDevices(), HttpStatus.OK); + } + + @PostMapping("/updateDeviceStatus") + @Log("更新设备状态") + @ApiOperation("更新设备状态") + @SaIgnore + //@PreAuthorize("@el.check('sect:list')") + public ResponseEntity updateDeviceStatus(@RequestBody HeadDeviceDto dto) { + return new ResponseEntity<>(b2HandService.updateDeviceStatus(dto), HttpStatus.OK); + } +} diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/hand/service/B2HandService.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/hand/service/B2HandService.java new file mode 100644 index 000000000..f28bfaa3d --- /dev/null +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/hand/service/B2HandService.java @@ -0,0 +1,25 @@ +package org.nl.hand.service; + +import org.nl.hand.dto.B2HeadDto; +import org.nl.hand.dto.HeadDeviceDto; + +import java.util.Map; + +/** + * @Author : TuQiang + * @create 2024/4/15 13:52 + */ +public interface B2HandService { + + /** + * 手持创建任务 + * + * @param dto + * @return + */ + Map callTask(B2HeadDto dto); + + Map queryDevices(); + + Map updateDeviceStatus(HeadDeviceDto dto); +} diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/hand/service/impl/B2HandServiceImpl.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/hand/service/impl/B2HandServiceImpl.java new file mode 100644 index 000000000..9f8f92ae1 --- /dev/null +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/hand/service/impl/B2HandServiceImpl.java @@ -0,0 +1,185 @@ +package org.nl.hand.service.impl; + +import cn.hutool.core.collection.CollectionUtil; +import cn.hutool.core.util.ObjectUtil; +import cn.hutool.core.util.StrUtil; +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.nl.acs.common.base.CommonFinalParam; +import org.nl.acs.device.domain.Device; +import org.nl.acs.device.service.DeviceService; +import org.nl.acs.device_driver.conveyor.standard_ordinary_site.StandardOrdinarySiteDeviceDriver; +import org.nl.acs.instruction.domain.Instruction; +import org.nl.acs.instruction.service.InstructionService; +import org.nl.acs.opc.DeviceAppService; +import org.nl.acs.task.service.TaskService; +import org.nl.acs.task.service.dto.TaskDto; +import org.nl.common.exception.BadRequestException; +import org.nl.hand.dto.B2HeadDto; +import org.nl.hand.dto.HeadDeviceDto; +import org.nl.hand.service.B2HandService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.math.BigDecimal; +import java.util.List; +import java.util.Map; + +/** + * @Author : TuQiang + * @create 2024/4/15 13:52 + */ +@Service +@RequiredArgsConstructor +@Slf4j +public class B2HandServiceImpl implements B2HandService { + @Autowired + private TaskService taskserver; + @Autowired + private DeviceService deviceService; + @Autowired + private DeviceAppService deviceAppService; + @Autowired + private InstructionService instructionService; + + @Override + public Map callTask(B2HeadDto dto) { + JSONArray errArr = new JSONArray(); + String start_device_code = dto.getStart_device_code1(); + String next_device_code = dto.getNext_device_code1(); + String start_device_code2 = dto.getStart_device_code2(); + String next_device_code2 = dto.getNext_device_code2(); + String task_type = dto.getTask_type(); + + if (StrUtil.isEmpty(start_device_code)) { + throw new BadRequestException("起点1不能为空"); + } + if (StrUtil.isEmpty(next_device_code)) { + throw new BadRequestException("终点1不能为空"); + } + if (StrUtil.isEmpty(task_type)) { + throw new BadRequestException("任务类型不能为空"); + } + + JSONObject jo = new JSONObject(); + if (StrUtil.equals(task_type, CommonFinalParam.TYPE_ONE)) { + jo.put("start_device_code2", start_device_code2); + jo.put("next_device_code2", next_device_code2); + jo.put("start_point_code2", start_device_code2); + jo.put("next_point_code2", next_device_code2); + } else if (StrUtil.equals(task_type, CommonFinalParam.TYPE_TWO)) { + jo.put("start_device_code2", start_device_code2); + jo.put("next_device_code2", next_device_code2); + jo.put("start_point_code2", start_device_code2); + jo.put("next_point_code2", next_device_code2); + } + jo.put("start_device_code", start_device_code); + jo.put("next_device_code", next_device_code); + jo.put("start_point_code", start_device_code); + jo.put("next_point_code", next_device_code); + jo.put("task_type", task_type); + jo.put("route_plan_code","normal"); + jo.put("agv_system_type", "2"); + jo.put("priority", "1"); + + TaskDto task_dto = jo.toJavaObject(TaskDto.class); + try { + taskserver.create(task_dto); + } catch (Exception e) { +// e.printStackTrace(); + JSONObject json = new JSONObject(); + json.put("message", e.getMessage()); + errArr.add(json); + throw new RuntimeException(e.getMessage()); + } + JSONArray data = new JSONArray(); + JSONObject resultJson = new JSONObject(); + if (ObjectUtil.isEmpty(errArr)) { + resultJson.put("message", "操作成功"); + resultJson.put("data", data); + } else { + resultJson.put("message", "操作失败"); + resultJson.put("data", data); + } + return resultJson; + } + + @Override + public Map queryDevices() { + JSONArray data = new JSONArray(); + //查询所有生箔区的设备 + List list = deviceService.lambdaQuery() + .eq(Device::getRegion, "1") + .list(); + if (CollectionUtil.isEmpty(list)) { + throw new BadRequestException("未查到该区域的设备!"); + } + + StandardOrdinarySiteDeviceDriver standardOrdinarySiteDeviceDriver; + for (int i = 0; i < list.size(); i++) { + JSONObject jo = new JSONObject(); + Device device = list.get(i); + String device_id = device.getDevice_id(); + String device_code = device.getDevice_code(); + Device deviceCode = deviceAppService.findDeviceByCode(device_code); + int option = 0; + if (deviceCode.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) { + standardOrdinarySiteDeviceDriver = (StandardOrdinarySiteDeviceDriver) deviceCode.getDeviceDriver(); + option = standardOrdinarySiteDeviceDriver.getOption(); + } + String device_name = device.getDevice_name(); + BigDecimal seq_num = device.getSeq_num(); + jo.put("device_id", device_id); + jo.put("device_code", device_code); + jo.put("device_name", device_name); + jo.put("seq_num", seq_num); + jo.put("option", option); + data.add(jo); + } + JSONObject resultJson = new JSONObject(); + resultJson.put("message", "操作成功"); + resultJson.put("data", data); + return resultJson; + } + + @Override + public Map updateDeviceStatus(HeadDeviceDto dto) { + JSONArray errArr = new JSONArray(); + String device_code = dto.getDevice_code(); + String option = dto.getOption(); + if (StrUtil.isEmpty(device_code)) { + throw new BadRequestException("设备号不能为空"); + } + if (StrUtil.isEmpty(option)) { + throw new BadRequestException("操作不能为空"); + } + //满轴位允许进入,空轴位允许离开 + if (device_code.contains("M")&&(!"1".equals(option))){ + throw new BadRequestException("该设备为满轴位,不能进行该操作"); + } + if (device_code.contains("K")&&(!"2".equals(option))){ + throw new BadRequestException("该设备为空轴位,不能进行该操作"); + } + StandardOrdinarySiteDeviceDriver standardOrdinarySiteDeviceDriver; + Device device = deviceAppService.findDeviceByCode(device_code); + if (ObjectUtil.isEmpty(device)){ + JSONObject json = new JSONObject(); + json.put("message", "设备不存在!"); + errArr.add(json); + } + standardOrdinarySiteDeviceDriver = (StandardOrdinarySiteDeviceDriver) device.getDeviceDriver(); + standardOrdinarySiteDeviceDriver.setOption(Integer.parseInt(option)); + JSONArray data = new JSONArray(); + JSONObject resultJson = new JSONObject(); + if (ObjectUtil.isEmpty(errArr)) { + resultJson.put("message", "操作成功"); + resultJson.put("data", data); + } else { + resultJson.put("message", "操作失败"); + resultJson.put("data", data); + } + return resultJson; + } +} diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/hand/service/impl/HandServiceImpl.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/hand/service/impl/HandServiceImpl.java index a10743649..2ab183114 100644 --- a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/hand/service/impl/HandServiceImpl.java +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/hand/service/impl/HandServiceImpl.java @@ -24,6 +24,8 @@ import org.nl.acs.instruction.domain.Instruction; import org.nl.acs.instruction.domain.InstructionMybatis; import org.nl.acs.instruction.service.InstructionService; import org.nl.acs.instruction.service.dto.InstructionDto; +import org.nl.acs.opc.DeviceAppService; +import org.nl.acs.opc.DeviceAppServiceImpl; import org.nl.acs.task.domain.Task; import org.nl.acs.task.enums.TaskStatusEnum; import org.nl.acs.task.service.TaskService; @@ -31,6 +33,7 @@ import org.nl.acs.task.service.dto.TaskDto; import org.nl.acs.task.service.dto.TaskIdAndStatusDTO; import org.nl.common.exception.BadRequestException; import org.nl.common.utils.CodeUtil; +import org.nl.config.SpringContextHolder; import org.nl.hand.dto.HeadDto; import org.nl.hand.dto.HeadInstDto; import org.nl.hand.dto.HeadTaskDto; @@ -66,6 +69,8 @@ public class HandServiceImpl implements HandService { private InstructionService instructionService; @Autowired NDCAgvService ndcAgvService; + @Autowired + DeviceAppService deviceAppService; @@ -110,41 +115,55 @@ public class HandServiceImpl implements HandService { String task_type = dto.getTask_type(); if (StrUtil.isEmpty(start_device_code)) { - JSONObject json = new JSONObject(); - json.put("message", "起点不能为空"); - errArr.add(json); + throw new BadRequestException("起点不能为空"); } if (StrUtil.isEmpty(next_device_code)) { - JSONObject json = new JSONObject(); - json.put("message", "终点不能为空"); - errArr.add(json); + throw new BadRequestException("终点不能为空"); } if (StrUtil.isEmpty(task_type)) { - JSONObject json = new JSONObject(); - json.put("message", "任务类型不能为空"); - errArr.add(json); + throw new BadRequestException("任务类型不能为空"); } String start_device_code2 = ""; String next_device_code2 = ""; JSONObject jo = new JSONObject(); if (StrUtil.equals(task_type, CommonFinalParam.TYPE_ONE)) { - String s = start_device_code.substring(9); + String s = start_device_code.substring(start_device_code.length() - 1); if (StrUtil.equals("K", s)) { - start_device_code2 = next_device_code.substring(0, 10) + "M"; - next_device_code2 = start_device_code.substring(0, 9) + "M"; + start_device_code2 = next_device_code.substring(0, next_device_code.length() - 1) + "M"; + next_device_code2 = start_device_code.substring(0, start_device_code.length() - 1) + "M"; jo.put("start_device_code2", start_device_code2); jo.put("next_device_code2", next_device_code2); jo.put("start_point_code2", start_device_code2); jo.put("next_point_code2", next_device_code2); + }else{ + throw new BadRequestException("起点设备名称不符"); } } else if (StrUtil.equals(task_type, CommonFinalParam.TYPE_TWO)) { - start_device_code2 = next_device_code.substring(0, 9) + "K"; - next_device_code2 = start_device_code.substring(0, 9) + "K"; - jo.put("start_device_code2", start_device_code2); - jo.put("next_device_code2", next_device_code2); - jo.put("start_point_code2", start_device_code2); - jo.put("next_point_code2", next_device_code2); + String s = start_device_code.substring(start_device_code.length() - 1); + String n = next_device_code.substring(next_device_code.length() - 1); + if (StrUtil.equals("M", s) && StrUtil.equals("M", n)) { + start_device_code2 = next_device_code.substring(0, next_device_code.length() - 1) + "K"; + next_device_code2 = start_device_code.substring(0, start_device_code.length() - 1) + "K"; + jo.put("start_device_code2", start_device_code2); + jo.put("next_device_code2", next_device_code2); + jo.put("start_point_code2", start_device_code2); + jo.put("next_point_code2", next_device_code2); + }else if(StrUtil.equals("S", n) && StrUtil.equals("M", s)){ + start_device_code2 = next_device_code.substring(0, next_device_code.length() - 1) + "X"; + next_device_code2 = start_device_code.substring(0, start_device_code.length() - 1) + "K"; + jo.put("start_device_code2", start_device_code2); + jo.put("next_device_code2", next_device_code2); + jo.put("start_point_code2", start_device_code2); + jo.put("next_point_code2", next_device_code2); + }else{ + throw new BadRequestException("起点设备名称不符"); + } + } + Device startDevice = deviceAppService.findDeviceByCode(start_device_code2); + Device nextDevice = deviceAppService.findDeviceByCode(next_device_code2); + if(StrUtil.isAllNotEmpty(start_device_code2,next_device_code2) && ObjectUtil.isAllEmpty(startDevice,nextDevice)){ + throw new BadRequestException("起点终点设备不存在"); } jo.put("start_device_code", start_device_code); jo.put("next_device_code", next_device_code); @@ -162,6 +181,7 @@ public class HandServiceImpl implements HandService { JSONObject json = new JSONObject(); json.put("message", e.getMessage()); errArr.add(json); + throw new RuntimeException(e.getMessage()); } JSONArray data = new JSONArray(); JSONObject resultJson = new JSONObject(); diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/system/service/quartz/config/JobRunner.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/system/service/quartz/config/JobRunner.java index 2504f2f57..a1334e810 100644 --- a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/system/service/quartz/config/JobRunner.java +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/system/service/quartz/config/JobRunner.java @@ -17,7 +17,7 @@ import java.util.List; @Component @RequiredArgsConstructor @Order(100) -@ConditionalOnProperty(value = "spring.profiles.active",havingValue = "dev") +@ConditionalOnProperty(value = "spring.profiles.active",havingValue = "prod") public class JobRunner implements ApplicationRunner { private static final Logger log = LoggerFactory.getLogger(JobRunner.class); private final ISysQuartzJobService quartzJobService; diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/system/service/quartz/task/CreateDDJInst.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/system/service/quartz/task/CreateDDJInst.java index 63809dbb7..8fe15c654 100644 --- a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/system/service/quartz/task/CreateDDJInst.java +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/system/service/quartz/task/CreateDDJInst.java @@ -58,7 +58,7 @@ public class CreateDDJInst { Device nextDevice = appService.findDeviceByCode(next_device_code); //判断有无出入库任务是相同路线 TaskDto dto = taskserver.findByCodeAndExcute(next_device_code, start_device_code); - if (ObjectUtil.isNotEmpty(dto)){ + if (ObjectUtil.isNotEmpty(dto)) { return; } if (startDevice.getDevice_type().equals(DeviceType.storage.name()) && @@ -69,49 +69,15 @@ public class CreateDDJInst { if (CollUtil.isNotEmpty(taskDtoList)) { taskDtoList = sortInst(taskDtoList); for (TaskDto taskDto : taskDtoList) { - List list = - routeLineService.getShortPathLines( - taskDto.getStart_device_code(), taskDto.getNext_device_code(), taskDto.getRoute_plan_code()); - if (ObjectUtils.isEmpty(list)) { - throw new BadRequestException("路由不通"); - } - RouteLineDto routeLineDto = list.get(0); - String[] path = routeLineDto.getPath().split("->"); - List pathlist = Arrays.asList(path); - String deviceType = appService.findDeviceByCode(pathlist.get(1)).getDevice_type(); - if (pathlist.size() < 3 || (!deviceType.equals(DeviceType.stacker.name()))) { - return; - } - Device deviceByCode = appService.findDeviceByCode(pathlist.get(1)); - if (ObjectUtils.isEmpty(deviceByCode)) { - log.error("没有找到DDJ设备"); - return; - } - StandardStackerDeviceDriver standardStackerDeviceDriver; - if (deviceByCode.getDeviceDriver() instanceof StandardStackerDeviceDriver) { - standardStackerDeviceDriver = (StandardStackerDeviceDriver) deviceByCode.getDeviceDriver(); - if (standardStackerDeviceDriver.getMode() != 3 || standardStackerDeviceDriver.getMove() == 1 || standardStackerDeviceDriver.getCommand() != 0) { - log.error("堆垛机,{}未联机或者在执行中", deviceByCode.getDevice_code()); - return; - } - } - String next_device_code = taskDto.getNext_device_code(); - Device nextDevice = appService.findDeviceByCode(next_device_code); - BeltConveyorDeviceDriver beltConveyorDeviceDriver; - if (nextDevice.getDeviceDriver() instanceof BeltConveyorDeviceDriver) { - beltConveyorDeviceDriver = (BeltConveyorDeviceDriver) nextDevice.getDeviceDriver(); - if (beltConveyorDeviceDriver.getMode() != 2 || beltConveyorDeviceDriver.getMove() == 1) { - log.error("输送机,{}未联机或执行中", next_device_code); - return; - } - } + String next_device_code = ""; + Device nextDevice = null; + List pathlist; + Device deviceByCode = null; String taskid = taskDto.getTask_id(); String taskcode = taskDto.getTask_code(); String task_type = taskDto.getTask_type(); String vehiclecode = taskDto.getVehicle_code(); - String storage_task_type = taskDto.getStorage_task_type(); String priority = taskDto.getPriority(); - String is_send = taskDto.getIs_send(); String start_device_code = taskDto.getStart_device_code(); Device startDevice = appService.findDeviceByCode(start_device_code); @@ -134,40 +100,107 @@ public class CreateDDJInst { String start_height = taskDto.getStart_height(); String next_height = taskDto.getNext_height(); - /** - * 开始平均分配 - */ - String this_coevice_code = taskserver.queryAssignedByDeviceCode(start_device_code, next_device_code); - if (StrUtil.isEmpty(this_coevice_code)) { - List shortPathsList = routeLineService.getShortPathLines(start_device_code, next_device_code, route_plan_code); - RouteLineDto routeLineDto1 = shortPathsList.get(0); - - String path1 = routeLineDto1.getPath(); - String[] str = path1.split("->"); - - List pathlist1 = Arrays.asList(str); - int index = 0; - for (int m = 0; m < pathlist1.size(); m++) { - String deviceType1 = appService.findDeviceByCode(pathlist1.get(m)).getDevice_type(); - if(deviceType1.equals(DeviceType.stacker.name())){ - index = m + 1; - break; + //同排的货位移库任务 + if (StrUtil.equals(taskDto.getStart_device_code(), taskDto.getNext_device_code())) { + //通过起点找路由 + List list = + routeLineService.getShortPathLinesByCode( + taskDto.getStart_device_code(), taskDto.getRoute_plan_code()); + if (ObjectUtils.isEmpty(list)) { + throw new BadRequestException("路由不通"); + } + RouteLineDto routeLineDto = list.get(0); + String[] path = routeLineDto.getPath().split("->"); + pathlist = Arrays.asList(path); + deviceByCode = appService.findDeviceByCode(pathlist.get(1)); + if (ObjectUtils.isEmpty(deviceByCode)) { + log.error("没有找到DDJ设备"); + return; + } + StandardStackerDeviceDriver standardStackerDeviceDriver; + if (deviceByCode.getDeviceDriver() instanceof StandardStackerDeviceDriver) { + standardStackerDeviceDriver = (StandardStackerDeviceDriver) deviceByCode.getDeviceDriver(); + if (standardStackerDeviceDriver.getMode() != 3 || standardStackerDeviceDriver.getMove() == 1 || standardStackerDeviceDriver.getCommand() != 0) { + log.error("堆垛机,{}未联机或者在执行中", deviceByCode.getDevice_code()); + ((StandardStackerDeviceDriver) deviceByCode.getDeviceDriver()).setNotCreateInstMessage("堆垛机,{}未联机或者在执行中" + deviceByCode.getDevice_code()); + return; } + } + next_device_code = start_device_code; + nextDevice = appService.findDeviceByCode(next_device_code); + } else { + List list = + routeLineService.getShortPathLines( + taskDto.getStart_device_code(), taskDto.getNext_device_code(), taskDto.getRoute_plan_code()); + if (ObjectUtils.isEmpty(list)) { + ((StandardStackerDeviceDriver) deviceByCode.getDeviceDriver()).setNotCreateInstMessage("路由不通" + deviceByCode.getDevice_code()); + throw new BadRequestException("路由不通"); + } + RouteLineDto routeLineDto = list.get(0); + String[] path = routeLineDto.getPath().split("->"); + pathlist = Arrays.asList(path); + deviceByCode = appService.findDeviceByCode(pathlist.get(1)); + + if (ObjectUtils.isEmpty(deviceByCode)) { + log.error("没有找到DDJ设备"); + return; + } + StandardStackerDeviceDriver standardStackerDeviceDriver; + if (deviceByCode.getDeviceDriver() instanceof StandardStackerDeviceDriver) { + standardStackerDeviceDriver = (StandardStackerDeviceDriver) deviceByCode.getDeviceDriver(); + if (standardStackerDeviceDriver.getMode() != 3 || standardStackerDeviceDriver.getForkCargo() == 1 || standardStackerDeviceDriver.getCommand() != 0) { + log.error("堆垛机,{}未联机或者在执行中", deviceByCode.getDevice_code()); + ((StandardStackerDeviceDriver) deviceByCode.getDeviceDriver()).setNotCreateInstMessage("堆垛机,{}未联机或者在执行中" + deviceByCode.getDevice_code()); + return; + } + } + + next_device_code = taskDto.getNext_device_code(); + nextDevice = appService.findDeviceByCode(next_device_code); + BeltConveyorDeviceDriver beltConveyorDeviceDriver; + if (nextDevice.getDeviceDriver() instanceof BeltConveyorDeviceDriver) { + beltConveyorDeviceDriver = (BeltConveyorDeviceDriver) nextDevice.getDeviceDriver(); + if (beltConveyorDeviceDriver.getMode() != 2 || beltConveyorDeviceDriver.getMove() == 1) { + log.error("输送机,{}未联机或执行中", next_device_code); + ((BeltConveyorDeviceDriver) nextDevice.getDeviceDriver()).setNotCreateInstMessage("输送机,{}未联机或执行中" + deviceByCode.getDevice_code()); + return; + } + } + /** + * 开始平均分配 + */ + String this_coevice_code = taskserver.queryAssignedByDeviceCode(start_device_code, next_device_code); + if (StrUtil.isEmpty(this_coevice_code)) { + List shortPathsList = routeLineService.getShortPathLines(start_device_code, next_device_code, route_plan_code); + RouteLineDto routeLineDto1 = shortPathsList.get(0); + + String path1 = routeLineDto1.getPath(); + String[] str = path1.split("->"); + + List pathlist1 = Arrays.asList(str); + int index = 0; + for (int m = 0; m < pathlist1.size(); m++) { + String deviceType1 = appService.findDeviceByCode(pathlist1.get(m)).getDevice_type(); + if (deviceType1.equals(DeviceType.stacker.name())) { + index = m + 1; + break; + } /*if (pathlist1.get(m).equals(start_device_code)) { }*/ + } + next_device_code = pathlist1.get(index); + } else { + next_device_code = this_coevice_code; + } + //校验路由关系 + List shortPathsList = routeLineService.getShortPathLines(start_device_code, next_device_code, route_plan_code); + if (ObjectUtils.isEmpty(shortPathsList) || shortPathsList.size() < 1) { + throw new RuntimeException("路由不通!"); + } - next_device_code = pathlist1.get(index); - } else { - next_device_code = this_coevice_code; } - //校验路由关系 - List shortPathsList = routeLineService.getShortPathLines(start_device_code, next_device_code, route_plan_code); - if (ObjectUtils.isEmpty(shortPathsList) || shortPathsList.size()<1) { - throw new RuntimeException("路由不通!"); - } -// Device startdevice = appService.findDeviceByCode(start_device_code); -// Device nextdevice = appService.findDeviceByCode(next_device_code); + if (StrUtil.equals(appService.findDeviceTypeByCode(next_device_code), "storage")) { next_point_code = next_device_code + "-" + taskDto.getTo_y() + "-" + taskDto.getTo_z(); } else { @@ -262,33 +295,43 @@ public class CreateDDJInst { for (Instruction byDeviceCode : byDeviceCodes) { String nextDeviceCode = byDeviceCode.getNext_device_code(); Device nextdevice = appService.findDeviceByCode(nextDeviceCode); - if (startDevice.getDevice_type().equals(DeviceType.storage.name()) && + String startDeviceCode = byDeviceCode.getStart_device_code(); + Device startDevice1 = appService.findDeviceByCode(startDeviceCode); + if (startDevice1.getDevice_type().equals(DeviceType.storage.name()) && (nextdevice.getDevice_type().equals(DeviceType.conveyor.name()) || nextdevice.getDevice_type().equals(DeviceType.storage.name()))) { insts.add(byDeviceCode); } } int max = 0; + //非同排的路径 for (Instruction inst : insts) { - List shortPathLines = routeLineService.getShortPathLines(inst.getStart_device_code(), inst.getNext_device_code(), - inst.getRoute_plan_code()); - if (CollUtil.isEmpty(shortPathLines) || shortPathLines.size() < 1) { - log.error("没有此路由"); - throw new BadRequestException("路由不通"); + List shortPathLines =new ArrayList<>(); + if (!(inst.getStart_device_code().equals(inst.getNext_device_code()))) { + shortPathLines = routeLineService.getShortPathLines(inst.getStart_device_code(), inst.getNext_device_code(), + inst.getRoute_plan_code()); + if (CollUtil.isEmpty(shortPathLines) || shortPathLines.size() < 1) { + log.error("没有此路由"); + throw new BadRequestException("路由不通"); + } + }else { + //同排路径 + shortPathLines = routeLineService.getShortPathLinesByCode(inst.getStart_device_code(), inst.getRoute_plan_code()); + if (CollUtil.isEmpty(shortPathLines) || shortPathLines.size() < 1) { + log.error("没有此路由"); + throw new BadRequestException("路由不通"); + } } RouteLineDto routeLineDto1 = (RouteLineDto) shortPathLines.get(0); String[] path1 = routeLineDto1.getPath().split("->"); List pathlist1 = Arrays.asList(path1); - if (pathlist1.size() < 3 || pathlist1.get(1).equals(DeviceType.stacker.name())) { - //return; - } if (pathlist1.get(1).equals(pathlist.get(1))) { max++; } } /*List deviceExtras = deviceExtra.list(Wrappers.lambdaQuery(DeviceExtra.class). eq(DeviceExtra::getDevice_code, pathlist.get(1)).orderByDesc(DeviceExtra::getCreate_time));*/ - String count = deviceByCode.getExtraValue().get("count").toString(); - if (StrUtil.isNotEmpty(count) ) { + String count = deviceByCode.getExtraValue().get("count").toString(); + if (StrUtil.isNotEmpty(count)) { if (max <= Integer.parseInt(count)) { instdto.setInstruction_type(task_type); instdto.setInstruction_id(IdUtil.simpleUUID()); @@ -371,8 +414,6 @@ public class CreateDDJInst { continue; } } - - } } } diff --git a/acs2/nladmin-system/nlsso-server/src/main/resources/language/monitor/universal/universal.properties b/acs2/nladmin-system/nlsso-server/src/main/resources/language/monitor/universal/universal.properties index 9c3f82e55..5dd2b8e3c 100644 --- a/acs2/nladmin-system/nlsso-server/src/main/resources/language/monitor/universal/universal.properties +++ b/acs2/nladmin-system/nlsso-server/src/main/resources/language/monitor/universal/universal.properties @@ -44,6 +44,10 @@ universal_write_erro=\u5199\u5165\u4FE1\u53F7\u5931\u8D25 universal_notCreateInstMessage1=\u672A\u8BBE\u7F6E\u7535\u6C14\u8C03\u5EA6\u53F7! universal_notCreateInstMessage2=\u5149\u7535\u65E0\u8D27,\u65E0\u6CD5\u751F\u6210\u6307\u4EE4! universal_notCreateInstMessage3=\u8BBE\u5907\u5F85\u673A\u6216\u4E0D\u5141\u8BB8\u8FDB\u5165 +universal_notCreateInstMessage4=ddj\u5BF9\u63A5\u4F4D\u6709\u8D27,\u65E0\u6CD5\u751F\u6210\u6307\u4EE4! +universal_notCreateInstMessage5=\u5B58\u5728\u76F8\u540C\u8DEF\u7EBF\u7684\u6307\u4EE4! +universal_notCreateInstMessage6=\u4E0B\u4E00\u4E2A\u8BBE\u5907\u4E0D\u662F\u8F93\u9001\u7EBF\u6307\u4EE4! + diff --git a/acs2/nladmin-system/nlsso-server/src/main/resources/language/monitor/universal/universal_en_US.properties b/acs2/nladmin-system/nlsso-server/src/main/resources/language/monitor/universal/universal_en_US.properties index 0c1ab80e2..786aa8688 100644 --- a/acs2/nladmin-system/nlsso-server/src/main/resources/language/monitor/universal/universal_en_US.properties +++ b/acs2/nladmin-system/nlsso-server/src/main/resources/language/monitor/universal/universal_en_US.properties @@ -43,3 +43,6 @@ universal_notCreateInstMessage=Instructions cannot be created because the task f universal_notCreateInstMessage1=The electrical dispatch number is not set! universal_notCreateInstMessage2=Photoelectric no goods, can not generate commands! universal_notCreateInstMessage3=The device is in standby mode or is not allowed to enter +universal_notCreateInstMessage4=ddj interface bit is in stock, cannot generate command! +universal_notCreateInstMessage5=Instructions with the same route exist! +universal_notCreateInstMessage6=The next device is not a conveyor line directive! diff --git a/acs2/nladmin-system/nlsso-server/src/main/resources/language/monitor/universal/universal_in_ID.properties b/acs2/nladmin-system/nlsso-server/src/main/resources/language/monitor/universal/universal_in_ID.properties index 10fcbacb4..cc6ee070b 100644 --- a/acs2/nladmin-system/nlsso-server/src/main/resources/language/monitor/universal/universal_in_ID.properties +++ b/acs2/nladmin-system/nlsso-server/src/main/resources/language/monitor/universal/universal_in_ID.properties @@ -43,3 +43,6 @@ universal_notCreateInstMessage=Misi untuk divais yang diasosiasikan tidak ditemu universal_notCreateInstMessage1=Nomor pengiriman listrik tidak diatur! universal_notCreateInstMessage2=Photo-electric tidak tersedia dan tidak dapat menghasilkan perintah! universal_notCreateInstMessage3=Siaga perangkat atau tidak diizinkan masuk +universal_notCreateInstMessage4=DDJ mendarat di dok, tidak ada perintah yang diberikan! +universal_notCreateInstMessage5=Ada instruksi tentang rute yang sama! +universal_notCreateInstMessage6=Perangkat berikutnya bukan arahan jalur konveyor! diff --git a/acs2/nladmin-system/nlsso-server/src/main/resources/language/monitor/universal/universal_zh_CN.properties b/acs2/nladmin-system/nlsso-server/src/main/resources/language/monitor/universal/universal_zh_CN.properties index 3a88ce9d8..ee062b42c 100644 --- a/acs2/nladmin-system/nlsso-server/src/main/resources/language/monitor/universal/universal_zh_CN.properties +++ b/acs2/nladmin-system/nlsso-server/src/main/resources/language/monitor/universal/universal_zh_CN.properties @@ -43,4 +43,7 @@ universal_notCreateInstMessage=\u672A\u627E\u5230\u5173\u8054\u8BBE\u5907\u7684\ universal_notCreateInstMessage1=\u672A\u8BBE\u7F6E\u7535\u6C14\u8C03\u5EA6\u53F7! universal_notCreateInstMessage2=\u5149\u7535\u65E0\u8D27,\u65E0\u6CD5\u751F\u6210\u6307\u4EE4! universal_notCreateInstMessage3=\u8BBE\u5907\u5F85\u673A\u6216\u4E0D\u5141\u8BB8\u8FDB\u5165 +universal_notCreateInstMessage4=ddj\u5BF9\u63A5\u4F4D\u6709\u8D27,\u65E0\u6CD5\u751F\u6210\u6307\u4EE4! +universal_notCreateInstMessage5=\u5B58\u5728\u76F8\u540C\u8DEF\u7EBF\u7684\u6307\u4EE4! +universal_notCreateInstMessage6=\u4E0B\u4E00\u4E2A\u8BBE\u5907\u4E0D\u662F\u8F93\u9001\u7EBF\u6307\u4EE4! diff --git a/acs2/nladmin-ui/dist (2).zip b/acs2/nladmin-ui/dist (2).zip deleted file mode 100644 index 7431eb8e4..000000000 Binary files a/acs2/nladmin-ui/dist (2).zip and /dev/null differ diff --git a/acs2/nladmin-ui/dist.zip b/acs2/nladmin-ui/dist.zip deleted file mode 100644 index df068c6bb..000000000 Binary files a/acs2/nladmin-ui/dist.zip and /dev/null differ diff --git a/acs2/nladmin-ui/src/views/acs/device/index.vue b/acs2/nladmin-ui/src/views/acs/device/index.vue index b2b9686bc..56548d747 100644 --- a/acs2/nladmin-ui/src/views/acs/device/index.vue +++ b/acs2/nladmin-ui/src/views/acs/device/index.vue @@ -268,11 +268,7 @@ export default { ], device_type: [ { required: true, message: '设备类型不能为空', trigger: 'blur' } - ], - region: [ - { required: true, message: '所属区域不能为空', trigger: 'blur' } ] - } } }, diff --git a/acs2/nladmin-ui/src/views/acs/monitor/device/index2.vue b/acs2/nladmin-ui/src/views/acs/monitor/device/index2.vue index febabca33..381744162 100644 --- a/acs2/nladmin-ui/src/views/acs/monitor/device/index2.vue +++ b/acs2/nladmin-ui/src/views/acs/monitor/device/index2.vue @@ -350,6 +350,24 @@ export default { } else if (val === 'mode') { const obj = { name: '模式', value: data[val] } arr.push(obj) + } else if (val === 'container_type') { + const obj = { name: '托盘类型', value: data[val] } + this.arr.push(obj) + } else if (val === 'command') { + const obj = { name: '作业状态', value: data[val] } + this.arr.push(obj) + } else if (val === 'prohibitInWarehouse') { + const obj = { name: '禁止入库', value: data[val] } + this.arr.push(obj) + } else if (val === 'prohibitOutWarehouse') { + const obj = { name: '禁止出库', value: data[val] } + this.arr.push(obj) + } else if (val === 'stopReceiveTask') { + const obj = { name: '停止接收任务', value: data[val] } + this.arr.push(obj) + } else if (val === 'hand_barcode') { + const obj = { name: '条码', value: data[val] } + this.arr.push(obj) } else if (val === 'error') { const obj = { name: '报警', value: data[val] } arr.push(obj) diff --git a/acs2/nladmin-ui/src/views/screen/bigScreen.vue b/acs2/nladmin-ui/src/views/screen/bigScreen.vue index 065349377..02881081b 100644 --- a/acs2/nladmin-ui/src/views/screen/bigScreen.vue +++ b/acs2/nladmin-ui/src/views/screen/bigScreen.vue @@ -153,7 +153,7 @@ export default { const timer = setInterval(() => { this.settime()// 你所加载数据的方法 this.getMessage() - }, 10000) + }, 1000) // 销毁定时器 this.$once('hook:beforeDestroy', () => { clearInterval(timer) @@ -175,14 +175,6 @@ export default { methods: { changeDevice(val) { this.device = val - deviceCrud.getLedMessage(this.device).then(data => { - this.form = data - }) - // todo: 定时器 - this.timer = setInterval(() => { // 定时刷新设备的状态信息 - console.log('定时器启动') - this.initStatus() - }, 10000) }, getMessage() { deviceCrud.getLedMessage(this.device).then(data => { diff --git a/acs2/nladmin-ui/src/views/system/monitor/device/index.vue b/acs2/nladmin-ui/src/views/system/monitor/device/index.vue index c39409845..717b97213 100644 --- a/acs2/nladmin-ui/src/views/system/monitor/device/index.vue +++ b/acs2/nladmin-ui/src/views/system/monitor/device/index.vue @@ -252,8 +252,6 @@ import deviceCrud from '@/api/acs/device/device' import { getDeviceByCodes } from '@/api/acs/device/deviceStageMonitor' import '@logicflow/core/dist/style/index.css' import '@logicflow/extension/lib/style/index.css' -import paramCrud from '@/api/system/param' - import { LogicFlow } from '@logicflow/core' import { registerCustomElement } from '@/views/system/logicflow/editor/components/node' import i18n from '@/i18n' @@ -283,7 +281,7 @@ export default { dialogFormVisible9: false, dialogFormVisible10: false, Stages: [], - stage_code: '', + stage_code: 'stage_code', form: { device_code: '', hasGoodStatus: null, @@ -520,6 +518,9 @@ export default { } else if (val === 'last_inst_message') { const obj = { name: i18n.t('monitor.click.last_instruction_message'), value: data[val] } this.arr.push(obj) + } else if (val === 'container_type') { + const obj = { name: '托盘类型', value: data[val] } + this.arr.push(obj) } else if (val === 'barcode') { const obj = { name: i18n.t('monitor.click.barcode'), value: data[val] } this.arr.push(obj) diff --git a/lms/nladmin-system/src/main/java/org/nl/wms/basedata/st/service/impl/StructattrServiceImpl.java b/lms/nladmin-system/src/main/java/org/nl/wms/basedata/st/service/impl/StructattrServiceImpl.java index 3fe0b3eef..a87c8d153 100644 --- a/lms/nladmin-system/src/main/java/org/nl/wms/basedata/st/service/impl/StructattrServiceImpl.java +++ b/lms/nladmin-system/src/main/java/org/nl/wms/basedata/st/service/impl/StructattrServiceImpl.java @@ -60,6 +60,7 @@ public class StructattrServiceImpl implements StructattrService { map.put("lock_type", (String) whereJson.get("lock_type")); map.put("layer_num", (String) whereJson.get("layer_num")); map.put("is_used", (String) whereJson.get("is_used")); + map.put("is_have", (String) whereJson.get("is_have")); //获取人员对应的仓库 UserStorServiceImpl userStorService = new UserStorServiceImpl(); diff --git a/lms/nladmin-system/src/main/java/org/nl/wms/basedata/st/wql/QST_STRUCT_ATTR.wql b/lms/nladmin-system/src/main/java/org/nl/wms/basedata/st/wql/QST_STRUCT_ATTR.wql index 29a15aa70..28a9eea90 100644 --- a/lms/nladmin-system/src/main/java/org/nl/wms/basedata/st/wql/QST_STRUCT_ATTR.wql +++ b/lms/nladmin-system/src/main/java/org/nl/wms/basedata/st/wql/QST_STRUCT_ATTR.wql @@ -24,6 +24,7 @@ 输入.have_vehicle TYPEAS s_string 输入.layer_num TYPEAS s_string 输入.in_stor_id TYPEAS f_string + 输入.is_have TYPEAS s_string [临时表] --这边列出来的临时表就会在运行期动态创建 @@ -78,8 +79,11 @@ OPTION 输入.is_used <> "" struct.is_used = 输入.is_used ENDOPTION - OPTION 输入.lock_type = "1" - (struct.storagevehicle_code is null or struct.storagevehicle_code = '') + OPTION 输入.is_have = "1" + IFNULL(struct.storagevehicle_code, '') = '' + ENDOPTION + OPTION 输入.is_have = "2" + IFNULL(struct.storagevehicle_code, '') <> '' ENDOPTION ENDSELECT diff --git a/lms/nladmin-system/src/main/java/org/nl/wms/ext/acs/service/impl/AcsToWmsServiceImpl.java b/lms/nladmin-system/src/main/java/org/nl/wms/ext/acs/service/impl/AcsToWmsServiceImpl.java index 74efb63a3..f4e103705 100644 --- a/lms/nladmin-system/src/main/java/org/nl/wms/ext/acs/service/impl/AcsToWmsServiceImpl.java +++ b/lms/nladmin-system/src/main/java/org/nl/wms/ext/acs/service/impl/AcsToWmsServiceImpl.java @@ -22,6 +22,7 @@ import org.nl.system.service.notice.ISysNoticeService; import org.nl.system.service.notice.NoticeTypeEnum; import org.nl.system.service.param.impl.SysParamServiceImpl; import org.nl.wms.ext.acs.service.AcsToWmsService; +import org.nl.wms.pda.mps.eum.RegionTypeEnum; import org.nl.wms.pda.mps.service.CasingService; import org.nl.wms.pda.mps.service.ShippingService; import org.nl.wms.pda.mps.service.impl.BakingServiceImpl; @@ -33,6 +34,7 @@ import org.nl.wms.sch.tasks.PaperTrussTask; import org.nl.wms.sch.tasks.SendOutTask; import org.nl.wms.st.inbill.service.RawAssistIStorService; import org.nl.wms.st.inbill.service.StorPublicService; +import org.nl.wms.st.instor.service.impl.HandMoveStorServiceImpl; import org.redisson.api.RLock; import org.redisson.api.RedissonClient; import org.springframework.http.HttpStatus; @@ -42,8 +44,10 @@ import org.springframework.transaction.annotation.Transactional; import java.lang.reflect.Method; import java.util.ArrayList; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.concurrent.TimeUnit; +import java.util.stream.Collectors; @Service @RequiredArgsConstructor @@ -303,6 +307,9 @@ public class AcsToWmsServiceImpl implements AcsToWmsService { b、没有,则优先找空的巷道;按空位置顺序分配; 3、任务下发,判断巷道的任务类型,只能为空盘入库或者无任务类型; * */ + // 判断是否需要扩容 + isExpansion(); + vehicle_code = CodeUtil.getNewCode("VEHICCLE_CODE_KTP"); JSONArray emptyArr = WQL.getWO("QST_IVT_RAWASSISTISTOR").addParam("flag", "21").process().getResultJSONArray(0); @@ -1673,4 +1680,122 @@ public class AcsToWmsServiceImpl implements AcsToWmsService { } } + + /** + * 判断是否需要扩容 + */ + @Transactional + public void isExpansion() { + WQLObject attr = WQLObject.getWQLObject("st_ivt_structattr"); + WQLObject point = WQLObject.getWQLObject("sch_base_point"); + + // 查询空托盘中的空排还剩下多少 + List empList = WQL.getWO("ST_UPDATESTRUCTSECTONE_01").addParam("flag", "1") + .process().getResultJSONArray(0).toJavaList(JSONObject.class); + + if (empList.size() >= 3) { + return; + } + + // 进行扩容:找未锁定、空的一排主存区 + String block_num = ""; + String row_num = ""; + // 是否需要移库 + boolean is_move = false; + + List zcList = WQL.getWO("ST_UPDATESTRUCTSECTONE_01").addParam("flag", "2") + .process().getResultJSONArray(0).toJavaList(JSONObject.class); + + if (ObjectUtil.isNotEmpty(zcList)) { + block_num = zcList.get(0).getString("block_num"); + row_num = zcList.get(0).getString("row_num"); + } else { + // 需要进行移库:找木箱数量较少的那一排移库 + List moveList = WQL.getWO("ST_UPDATESTRUCTSECTONE_01").addParam("flag", "3") + .process().getResultJSONArray(0).toJavaList(JSONObject.class); + + if (ObjectUtil.isNotEmpty(moveList)) { + // 判断是否有锁 + String block_num_in = moveList.stream() + .map(row -> row.getString("block_num")) + .collect(Collectors.joining("','")); + + String row_num_in = moveList.stream() + .map(row -> row.getString("row_num")) + .collect(Collectors.joining("','")); + + List rowList = attr.query("block_num in ('" + block_num_in + "') AND row_num in ('" + row_num_in + "') and layer_num = '1' and sect_code = 'ZC01'") + .getResultJSONArray(0).toJavaList(JSONObject.class); + + for (int i = 0; i < moveList.size(); i++) { + JSONObject json = moveList.get(i); + + List collect = rowList.stream() + .filter(row -> row.getString("block_num").equals(json.getString("block_num")) && + row.getString("row_num").equals(json.getString("row_num")) + ) + .collect(Collectors.toList()); + + // 判断是否全部都为未锁定 + boolean isLock = collect.stream() + .allMatch(row -> row.getString("lock_type").equals("1")); + + if (isLock) { + block_num = json.getString("block_num"); + row_num = json.getString("row_num"); + is_move = true; + break; + } + } + } + } + + // 判断块、排是否为空 + if (ObjectUtil.isEmpty(block_num) && ObjectUtil.isEmpty(row_num)) { + log.info("1层空托盘区扩容失败:没有匹配到有空位的主存区!"); + return; + } + + try { + // 判断是否需要移库 + if (is_move) { + // 查询出这排需要移库的木箱 -- 默认右通(双通) + List needMoveList = attr.query("sect_code = 'ZC01' and block_num = '" + block_num + "' and row_num = '" + row_num + "' and layer_num = '1' and IFNULL(storagevehicle_code,'') <> '' order by out_order_seq ASC") + .getResultJSONArray(0).toJavaList(JSONObject.class); + + // 判断左通、右通 + if (needMoveList.get(0).getString("placement_type").equals("02")) { + // 左通 -- 根据出库顺序进行排序 + needMoveList = attr.query("sect_code = 'ZC01' and block_num = '" + block_num + "' and row_num = '" + row_num + "' and layer_num = '1' and IFNULL(storagevehicle_code,'') <> '' order by out_order_seq DESC") + .getResultJSONArray(0).toJavaList(JSONObject.class); + } + + // 调用移库方法 + JSONObject moveParam = new JSONObject(); + moveParam.put("needMoveList", needMoveList); + moveParam.put("task_group_id", IdUtil.getSnowflake(1, 1).nextId()); + + HandMoveStorServiceImpl bean = SpringContextHolder.getBean(HandMoveStorServiceImpl.class); + bean.createMoveExpansion(moveParam); + } + + } catch (Exception e) { + log.info("1层空托盘区扩容失败:"+e.getMessage()); + return; + } + + // 更新仓位为空托盘区 + JSONObject jsonParam = new JSONObject(); + jsonParam.put("sect_id", RegionTypeEnum.KTP01.getId()); + jsonParam.put("sect_code", "KTP01"); + jsonParam.put("sect_name", RegionTypeEnum.KTP01.getName()); + attr.update(jsonParam,"sect_code = 'ZC01' AND block_num = '"+block_num+"' AND row_num = '"+row_num+"' AND layer_num = '1'"); + + // 更新点位为主存区域 + jsonParam.put("region_id", RegionTypeEnum.KTP01.getId()); + jsonParam.put("region_code", "KTP01"); + jsonParam.put("region_name", RegionTypeEnum.KTP01.getName()); + point.update(jsonParam,"region_code = 'ZC01' AND block_num = '"+block_num+"' AND row_num = '"+row_num+"' AND layer_num = '1'"); + + } } diff --git a/lms/nladmin-system/src/main/java/org/nl/wms/pda/st/service/impl/ProductInstorServiceImpl.java b/lms/nladmin-system/src/main/java/org/nl/wms/pda/st/service/impl/ProductInstorServiceImpl.java index a10d56768..eeb73e662 100644 --- a/lms/nladmin-system/src/main/java/org/nl/wms/pda/st/service/impl/ProductInstorServiceImpl.java +++ b/lms/nladmin-system/src/main/java/org/nl/wms/pda/st/service/impl/ProductInstorServiceImpl.java @@ -31,6 +31,7 @@ import org.springframework.transaction.annotation.Transactional; import java.util.ArrayList; import java.util.HashMap; +import java.util.List; import java.util.concurrent.TimeUnit; /** @@ -220,6 +221,44 @@ public class ProductInstorServiceImpl implements ProductInstorService { throw new BadRequestException("无法入立体库,木箱超高;当前木箱高度为:" + box_high); } + /* + * 判断木箱高度能入第几层: + * 判断仓位是否够用 + * 1.低于650mm 三层都可以入 + * 2.650mm > 木箱 <= 800mm, 只能入二、三层 + * 3.第三层要根据实际高度分配货位 + */ + String layer_num; + // 入库木箱下限 + String in_download_box_high = SpringContextHolder.getBean(SysParamServiceImpl.class).findByCode("in_download_box_high").getValue(); + // 入库木箱上线 + String in_up_box_high = SpringContextHolder.getBean(SysParamServiceImpl.class).findByCode("in_up_box_high").getValue(); + + if (Double.parseDouble(in_download_box_high) < box_high && box_high <= Double.parseDouble(in_up_box_high)) { + // 只能入到 2/3层 + layer_num = "('2','3')"; + } else { + // 三层都可入 + layer_num = "('1','2','3')"; + } + + // 查询对应的仓位个数 + List attrList = WQL.getWO("PDA_ST_01").addParam("flag", "10") + .addParam("layer_num", layer_num).process() + .getResultJSONArray(0).toJavaList(JSONObject.class); + + // 获取系统参数 - 最低仓位数 + String download_attr_num = SpringContextHolder.getBean(SysParamServiceImpl.class).findByCode("download_attr_num").getValue(); + + // 校验仓位数是否满足 + JSONObject jsonAttr = attrList.stream() + .filter(row -> row.getDoubleValue("num") <= Double.parseDouble(download_attr_num)) + .findFirst().orElse(null); + + if (ObjectUtil.isNotEmpty(jsonAttr)) { + throw new BadRequestException(jsonAttr.getString("layer_num") + "层主存区仓位数不足" + download_attr_num +"个,不允许入库!"); + } + JSONObject point_jo = WQLObject.getWQLObject("sch_base_point").query("point_code = '" + point_code + "'").uniqueResult(0); if (ObjectUtil.isEmpty(point_jo)) { throw new BadRequestException("未查询到对应的点位!"); diff --git a/lms/nladmin-system/src/main/java/org/nl/wms/pda/st/service/impl/ThreadDemo.java b/lms/nladmin-system/src/main/java/org/nl/wms/pda/st/service/impl/ThreadDemo.java new file mode 100644 index 000000000..0a465eba2 --- /dev/null +++ b/lms/nladmin-system/src/main/java/org/nl/wms/pda/st/service/impl/ThreadDemo.java @@ -0,0 +1,83 @@ +package org.nl.wms.pda.st.service.impl; + +import cn.hutool.core.util.NumberUtil; +import org.nl.modules.common.exception.BadRequestException; + +import java.util.ArrayList; +import java.util.List; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.TimeUnit; + +public class ThreadDemo { + public static void main(String[] args) throws InterruptedException { + + // 任务数据 + List arr = createArr(); + + // 1个线程分配10个数据 + int ceil = (int) Math.ceil(NumberUtil.div(arr.size(), 10)); + + ExecutorService executorService = Executors.newFixedThreadPool(ceil); + + for (int i = 0; i < ceil; i++) { + + List integers ; + + // 分割集合 + if (i + 1 == ceil) { + integers = arr.subList( i * 10, arr.size()); + } else { + integers = arr.subList( i * 10, (i + 1) * 10); + + } + + // 提交任务 + executorService.submit(new Task1(integers)); + + } + + // 关闭线程 - 但不会立刻关闭 + executorService.shutdown(); + + /* // 等待任务完成 + boolean terminated = executorService.awaitTermination(2, TimeUnit.MINUTES); + + if (!terminated) { + throw new BadRequestException("时间过长!"); + }*/ + + + } + + private static List createArr() { + List objects = new ArrayList<>(); + + for (int i = 1; i <= 109; i++) { + objects.add(i); + } + return objects; + } +} + +class Task1 implements Runnable { + + List b ; + + public Task1(List a) { + b = a; + } + + @Override + public void run() { + + for (int i = 0; i < b.size(); i++) { + Integer integer = b.get(i); + // 任务逻辑 + System.out.println("我是任务==="+ integer +"==="+ Thread.currentThread().getName()); + + } + + + } +} diff --git a/lms/nladmin-system/src/main/java/org/nl/wms/pda/st/wql/PDA_ST_01.wql b/lms/nladmin-system/src/main/java/org/nl/wms/pda/st/wql/PDA_ST_01.wql index 1d6e7ff88..09017bf77 100644 --- a/lms/nladmin-system/src/main/java/org/nl/wms/pda/st/wql/PDA_ST_01.wql +++ b/lms/nladmin-system/src/main/java/org/nl/wms/pda/st/wql/PDA_ST_01.wql @@ -19,6 +19,7 @@ 输入.stor_id TYPEAS s_string 输入.sect_id TYPEAS s_string 输入.in_stor_id TYPEAS f_string + 输入.layer_num TYPEAS f_string @@ -248,6 +249,32 @@ order by update_time DESC + ENDSELECT + ENDQUERY + ENDIF + + IF 输入.flag = "10" + QUERY + SELECT + layer_num, + count(layer_num) AS num + FROM + st_ivt_structattr + WHERE + is_used = '1' + AND is_delete = '0' + AND lock_type = '1' + AND sect_code = 'ZC01' + AND IFNULL(storagevehicle_code,'') = '' + + OPTION 输入.layer_num <> "" + layer_num IN 输入.layer_num + ENDOPTION + + group by layer_num + + order by num ASC + ENDSELECT ENDQUERY ENDIF \ No newline at end of file diff --git a/lms/nladmin-system/src/main/java/org/nl/wms/sch/manage/AutoQueryStructattrNum.java b/lms/nladmin-system/src/main/java/org/nl/wms/sch/manage/AutoQueryStructattrNum.java new file mode 100644 index 000000000..739ee54fa --- /dev/null +++ b/lms/nladmin-system/src/main/java/org/nl/wms/sch/manage/AutoQueryStructattrNum.java @@ -0,0 +1,107 @@ +package org.nl.wms.sch.manage; + + +import cn.hutool.core.date.DateUtil; +import cn.hutool.core.util.NumberUtil; +import com.alibaba.fastjson.JSONObject; +import lombok.SneakyThrows; +import lombok.extern.slf4j.Slf4j; +import org.nl.common.utils.IdUtil; +import org.nl.modules.wql.WQL; +import org.nl.modules.wql.util.SpringContextHolder; +import org.nl.system.service.notice.ISysNoticeService; +import org.nl.system.service.notice.dao.SysNotice; +import org.nl.system.service.param.impl.SysParamServiceImpl; +import org.redisson.api.RLock; +import org.redisson.api.RedissonClient; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.ArrayList; +import java.util.List; +import java.util.concurrent.TimeUnit; + +/** + * 自动查询立库每层的可用仓位 + */ +@Slf4j +@Service +public class AutoQueryStructattrNum { + + @Autowired + private RedissonClient redissonClient; + + @Autowired + private ISysNoticeService iSysNoticeService; + + @SneakyThrows + public void run() { + RLock lock = redissonClient.getLock(this.getClass().getName()); + boolean tryLock = lock.tryLock(0, TimeUnit.SECONDS); + try { + if (tryLock){ + // 查询各个层的可用主存区空位情况 + List empList = WQL.getWO("AUTO002").addParam("flag", "1") + .process().getResultJSONArray(0).toJavaList(JSONObject.class); + + // 查询各个层的可用主存区有货情况 + List haveList = WQL.getWO("AUTO002").addParam("flag", "2") + .process().getResultJSONArray(0).toJavaList(JSONObject.class); + + // 获取系统参数 + String download_attr_num = SpringContextHolder.getBean(SysParamServiceImpl.class).findByCode("download_attr_num").getValue(); + + // 需要插入的集合 + List daoList = new ArrayList<>(); + + for (int i = 0; i < empList.size(); i++) { + JSONObject json = empList.get(i); + + if (json.getDoubleValue("num") <= Double.parseDouble(download_attr_num)) { + + // 已用仓位 + double aDouble = haveList.stream() + .filter(row -> row.getString("layer_num").equals(json.getString("layer_num"))) + .map(row -> row.getDoubleValue("num")) + .reduce(Double::sum).orElse(0.00); + + + // 计算主存区和 + double add = NumberUtil.add(json.getDoubleValue("num"), aDouble); + + // 空位占比 + double emp_pro = NumberUtil.round(NumberUtil.div(json.getDoubleValue("num"), add) * 100, 2).doubleValue(); + // 有货占比 + double have_pro = NumberUtil.round(NumberUtil.div(aDouble, add) * 100, 2).doubleValue(); + + // 内容 + String notice_title = "立库"+json.getString("layer_num")+ "层主存区仓位不足"+download_attr_num+"个!可用仓位:" + +json.getString("num")+ "个 占比:"+emp_pro+"% ,已用仓位:"+NumberUtil.round(aDouble, 0) +"个 占比:"+have_pro+"%"; + + SysNotice dao = SysNotice.builder() + .notice_id(IdUtil.getStringId()) + .notice_title(notice_title) + .notice_content(notice_title) + .notice_type("2") + .have_read("1") + .deal_status("1") + .create_time(DateUtil.now()) + .build(); + + daoList.add(dao); + } + } + + // 插入 + iSysNoticeService.saveBatch(daoList); + } + }finally { + if (tryLock) { + lock.unlock(); + } + } + + } + + +} diff --git a/lms/nladmin-system/src/main/java/org/nl/wms/sch/wql/AUTO002.wql b/lms/nladmin-system/src/main/java/org/nl/wms/sch/wql/AUTO002.wql new file mode 100644 index 000000000..7efd7026f --- /dev/null +++ b/lms/nladmin-system/src/main/java/org/nl/wms/sch/wql/AUTO002.wql @@ -0,0 +1,93 @@ +[交易说明] + 交易名: 查询仓库空位情况 + 所属模块: + 功能简述: + 版权所有: + 表引用: + 版本经历: + +[数据库] + --指定数据库,为空采用默认值,默认为db.properties中列出的第一个库 + +[IO定义] + ################################################# + ## 表字段对应输入参数 + ################################################# + 输入.flag TYPEAS s_string + +[临时表] + --这边列出来的临时表就会在运行期动态创建 + +[临时变量] + --所有中间过程变量均可在此处定义 + +[业务过程] + + ########################################## + # 1、输入输出检查 # + ########################################## + + + ########################################## + # 2、主过程前处理 # + ########################################## + + + ########################################## + # 3、业务主过程 # + ########################################## + + IF 输入.flag = "1" + QUERY + SELECT + layer_num, + count(struct_code) AS num + FROM + st_ivt_structattr + WHERE + is_delete = '0' + AND is_used = '1' + AND IFNULL(storagevehicle_code,'') = '' + AND lock_type = '1' + AND sect_code = 'ZC01' + + group by layer_num + + ENDSELECT + ENDQUERY + ENDIF + + IF 输入.flag = "2" + QUERY + SELECT + layer_num, + count(struct_code) AS num + FROM + st_ivt_structattr + WHERE + is_delete = '0' + AND is_used = '1' + AND IFNULL(storagevehicle_code,'') <> '' + AND sect_code = 'ZC01' + + group by layer_num + + UNION + + SELECT + layer_num, + count(struct_code) AS num + FROM + st_ivt_structattr + WHERE + is_delete = '0' + AND is_used = '1' + AND IFNULL(storagevehicle_code,'') = '' + AND lock_type <> '1' + AND sect_code = 'ZC01' + + group by layer_num + + ENDSELECT + ENDQUERY + ENDIF \ No newline at end of file diff --git a/lms/nladmin-system/src/main/java/org/nl/wms/st/inbill/service/CheckOutBillService.java b/lms/nladmin-system/src/main/java/org/nl/wms/st/inbill/service/CheckOutBillService.java index 207d6df7e..5280312dc 100644 --- a/lms/nladmin-system/src/main/java/org/nl/wms/st/inbill/service/CheckOutBillService.java +++ b/lms/nladmin-system/src/main/java/org/nl/wms/st/inbill/service/CheckOutBillService.java @@ -118,6 +118,13 @@ public interface CheckOutBillService { */ void allDiv(JSONObject whereJson); + /** + * 全部分配,对同一出库单明细进行分配(多线程) + * + * @param whereJson / + */ + void allDiv2(JSONObject whereJson); + /** * 对一条明细自动分配 * diff --git a/lms/nladmin-system/src/main/java/org/nl/wms/st/inbill/service/impl/RawAssistIStorServiceImpl.java b/lms/nladmin-system/src/main/java/org/nl/wms/st/inbill/service/impl/RawAssistIStorServiceImpl.java index a7645375e..aaeb2f4d7 100644 --- a/lms/nladmin-system/src/main/java/org/nl/wms/st/inbill/service/impl/RawAssistIStorServiceImpl.java +++ b/lms/nladmin-system/src/main/java/org/nl/wms/st/inbill/service/impl/RawAssistIStorServiceImpl.java @@ -24,7 +24,9 @@ import org.nl.wms.basedata.st.service.StorattrService; import org.nl.wms.basedata.st.service.StructattrService; import org.nl.wms.basedata.st.service.dto.StorattrDto; import org.nl.wms.basedata.st.service.dto.StructattrDto; +import org.nl.wms.basedata.st.service.impl.StructattrServiceImpl; import org.nl.wms.basedata.st.service.impl.UserStorServiceImpl; +import org.nl.wms.pda.mps.eum.RegionTypeEnum; import org.nl.wms.sch.manage.AbstractAcsTask; import org.nl.wms.sch.manage.TaskStatusEnum; import org.nl.wms.sch.service.PointService; @@ -37,10 +39,12 @@ import org.redisson.api.RLock; import org.redisson.api.RedissonClient; import org.springframework.data.domain.Pageable; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Propagation; import org.springframework.transaction.annotation.Transactional; import java.util.*; import java.util.concurrent.TimeUnit; +import java.util.stream.Collectors; /** * PC端出入库新增 @@ -64,7 +68,6 @@ public class RawAssistIStorServiceImpl implements RawAssistIStorService { private final RedissonClient redissonClient; - @Override public Map pageQuery(Map whereJson, Pageable page) { HashMap map = new HashMap<>(); @@ -551,6 +554,18 @@ public class RawAssistIStorServiceImpl implements RawAssistIStorService { //判断是否为主存区,主存区调用自动分配,虚拟区调用普通查询 if (StrUtil.isNotEmpty(need_sect) && !"00".equals(need_sect_jo.getString("sect_type_attr"))) { struct_jo = WQLObject.getWQLObject("st_ivt_structattr").query("sect_id = '" + need_sect + "' AND lock_type = '1' AND is_delete = '0' AND IFNULL( storagevehicle_code, '' ) = ''").uniqueResult(0); + // 如果为空则扩容 + if (ObjectUtil.isEmpty(struct_jo)) { + JSONObject jsonParam = new JSONObject(); + jsonParam.put("sect_id", whereJson.get("sect_id")); + jsonParam.put("stor_id", whereJson.get("stor_id")); + jsonParam.put("num", 50); + + StructattrServiceImpl bean = SpringContextHolder.getBean(StructattrServiceImpl.class); + bean.oneCreate(jsonParam); + + struct_jo = WQLObject.getWQLObject("st_ivt_structattr").query("sect_id = '" + need_sect + "' AND lock_type = '1' AND is_delete = '0' AND IFNULL( storagevehicle_code, '' ) = ''").uniqueResult(0); + } } else { jo_form.put("sect_id", whereJson.get("sect_id")); struct_jo = this.autoDis(jo_form); @@ -959,13 +974,13 @@ public class RawAssistIStorServiceImpl implements RawAssistIStorService { /* * 判断木箱高度能入第几层: - * 1.低于650mm 三层都可以入 + * 1.低于650mm 优先入1层 没位置在入 2/3层 * 2.650mm > 木箱 <= 800mm, 只能入二、三层 * 3.第三层要根据实际高度分配货位 */ // 入库木箱下限 String in_download_box_high = SpringContextHolder.getBean(SysParamServiceImpl.class).findByCode("in_download_box_high").getValue(); - // 入库木箱上线 + // 入库木箱上限 String in_up_box_high = SpringContextHolder.getBean(SysParamServiceImpl.class).findByCode("in_up_box_high").getValue(); double box_high = sub_jo.getDoubleValue("box_high"); @@ -984,7 +999,37 @@ public class RawAssistIStorServiceImpl implements RawAssistIStorService { row_map.put("in_layer_num", in_layer_num); //查询到当前可用的巷道 - JSONArray rowArr2 = WQL.getWO("QST_IVT_RAWASSISTISTOR").addParamMap(row_map).process().getResultJSONArray(0); + JSONArray rowArr2 = new JSONArray(); + + if (box_high <= Double.parseDouble(in_download_box_high)) { + // 优先入1层 + row_map.put("layer_num", "1"); + + rowArr2 = WQL.getWO("QST_IVT_RAWASSISTISTOR").addParamMap(row_map).process().getResultJSONArray(0); + + if (ObjectUtil.isEmpty(rowArr2)) { + // 如果1层没有相同物料订单号的则找有空位的一排 + row_map.put("flag", "1111"); + rowArr2 = WQL.getWO("QST_IVT_RAWASSISTISTOR").addParamMap(row_map).process().getResultJSONArray(0); + + // 如果为空则进行扩容 + if (ObjectUtil.isEmpty(rowArr2)) { + boolean is_expansion = updateStructSectOne(); + + if (is_expansion) { + // 如果为true则在进行查询一次 + rowArr2 = WQL.getWO("QST_IVT_RAWASSISTISTOR").addParamMap(row_map).process().getResultJSONArray(0); + } + } + } + } + + if (ObjectUtil.isEmpty(rowArr2)) { + row_map.put("layer_num", ""); + row_map.put("flag", "111"); + rowArr2 = WQL.getWO("QST_IVT_RAWASSISTISTOR").addParamMap(row_map).process().getResultJSONArray(0); + } + JSONArray rowArr = new JSONArray(); for (int i = 0; i < rowArr2.size(); i++) { JSONObject jo = rowArr2.getJSONObject(i); @@ -1038,6 +1083,29 @@ public class RawAssistIStorServiceImpl implements RawAssistIStorService { break; } else { // 双通 + // 判断这一排全部是否是空位 + List attrList = WQLObject.getWQLObject("st_ivt_structattr") + .query("block_num = '" + block_num + "' and placement_type = '" + placement_type + "' and row_num = '" + row_num + "' and is_used = '1' and is_delete = '0' order by out_order_seq DESC") + .getResultJSONArray(0).toJavaList(JSONObject.class); + + // 如果这排全部是空位 并且没有被锁定则返回一个货位 + boolean is_all = attrList.stream() + .allMatch(row -> ObjectUtil.isEmpty(row.getString("storagevehicle_code")) + && row.getString("lock_type").equals("1") + ); + + if (is_all) { + struct_jo = attrList.get(0); + + // 判断是否是第三层 且高度是否超过仓位高度 + if (StrUtil.equals(struct_jo.getString("layer_num"), "3")) { + if (box_high > struct_jo.getDoubleValue("height")) { + struct_jo = null; + continue; + } + } + break; + } // 先倒序找到第一个木箱、判断上一个是否有货位 JSONObject jsonDescBox = WQLObject.getWQLObject("st_ivt_structattr").query("lock_type = '1' AND block_num = '" + block_num + "'AND placement_type = '" + placement_type + "' AND row_num = '" + row_num + "' AND is_delete = '0' AND is_used = '1' AND IFNULL(storagevehicle_code,'') <> '' order by out_order_seq DESC").uniqueResult(0); @@ -1359,14 +1427,14 @@ public class RawAssistIStorServiceImpl implements RawAssistIStorService { * */ - JSONObject struct_jo = new JSONObject(); - String box_no = whereJson.getString("box_no"); String sect_id = whereJson.getString("sect_id"); String col_num = whereJson.getString("layer_num"); // 转库时用 + JSONObject struct_jo = new JSONObject(); + JSONObject sub_jo = WQLObject.getWQLObject("pdm_bi_subpackagerelation").query("package_box_sn = '" + box_no + "' AND status < 3").uniqueResult(0); if (ObjectUtil.isEmpty(sub_jo)) { throw new BadRequestException("子卷包装关系不存在或已出库,请检查!"); @@ -1728,7 +1796,390 @@ public class RawAssistIStorServiceImpl implements RawAssistIStorService { } if (ObjectUtil.isEmpty(struct_jo)) { - throw new BadRequestException("未查询到可用的仓位!"); + // 主存区类型更改成中转区类型:找一排主存区的更改中转区、把一排中转区的更改成主存区(只允许调用一次) + SpringContextHolder.getBean(RawAssistIStorServiceImpl.class).updateStructSect(col_num); + struct_jo = autoDisMove2(whereJson); + } + return struct_jo; + } + + public JSONObject autoDisMove2(JSONObject whereJson) { + /* + * 分配逻辑: + * 1、先查找该木箱内属于什么物料、订单,定位到具体的块、排,查看是否存在空位 + * a、存在的话,优先放在这一块这一排中(遍历) + * b、不存在则根据该订单物料大概数量、选择数量相近的一个空巷道 + * 1)存在空巷道 + * 2)不存在,则找一个双通有空位置、数量相近的巷道 + * */ + + + String box_no = whereJson.getString("box_no"); + + String sect_id = whereJson.getString("sect_id"); + + String col_num = whereJson.getString("layer_num"); // 转库时用 + + JSONObject struct_jo = new JSONObject(); + + JSONObject sub_jo = WQLObject.getWQLObject("pdm_bi_subpackagerelation").query("package_box_sn = '" + box_no + "' AND status < 3").uniqueResult(0); + if (ObjectUtil.isEmpty(sub_jo)) { + throw new BadRequestException("子卷包装关系不存在或已出库,请检查!"); + } + + String material_code = sub_jo.getString("product_name"); + + String sale_order_name = sub_jo.getString("sale_order_name"); + + double box_high = sub_jo.getDoubleValue("box_high"); + + HashMap row_map = new HashMap<>(); + row_map.put("material_code", material_code); + row_map.put("sale_order_name", sale_order_name); + row_map.put("col_num", col_num); + row_map.put("sect_id", sect_id); + row_map.put("flag", "11"); + + //查询到当前可用的巷道 + JSONArray rowArr = WQL.getWO("QST_IVT_RAWASSISTISTOR").addParamMap(row_map).process().getResultJSONArray(0); + + for (int i = 0; i < rowArr.size(); i++) { + JSONObject row_jo = rowArr.getJSONObject(i); + + String block_num = row_jo.getString("block_num"); + String row_num = row_jo.getString("row_num"); + String placement_type = row_jo.getString("placement_type"); + + // 判断此排是否有除:入库锁、移入锁以外的锁 + JSONArray isLock = WQLObject.getWQLObject("st_ivt_structattr").query("lock_type not in ('1','2','7') AND block_num = '" + block_num + "'AND placement_type = '" + placement_type + "' AND row_num = '" + row_num + "' AND is_delete = '0' AND is_used = '1'").getResultJSONArray(0); + if (ObjectUtil.isEmpty(isLock)) { + if ("02".equals(placement_type)) { + // 左通 + struct_jo = WQLObject.getWQLObject("st_ivt_structattr").query("lock_type = '1' AND block_num = '" + block_num + "'AND placement_type = '" + placement_type + "' AND row_num = '" + row_num + "' AND is_delete = '0' AND is_used = '1' AND IFNULL(storagevehicle_code,'') = '' order by out_order_seq ASC").uniqueResult(0); + + // 判断是否是第三层 且高度是否超过仓位高度 + if (StrUtil.equals(struct_jo.getString("layer_num"), "3")) { + if (box_high > struct_jo.getDoubleValue("height")) { + struct_jo = null; + continue; + } + } + break; + } else if ("03".equals(placement_type)) { + // 右通 + struct_jo = WQLObject.getWQLObject("st_ivt_structattr").query("lock_type = '1' AND block_num = '" + block_num + "'AND placement_type = '" + placement_type + "' AND row_num = '" + row_num + "' AND is_delete = '0' AND is_used = '1' AND IFNULL(storagevehicle_code,'') = '' order by out_order_seq DESC").uniqueResult(0); + + // 判断是否是第三层 且高度是否超过仓位高度 + if (StrUtil.equals(struct_jo.getString("layer_num"), "3")) { + if (box_high > struct_jo.getDoubleValue("height")) { + struct_jo = null; + continue; + } + } + break; + } else { + // 双通 + + // 先倒序找到第一个木箱、判断上一个是否有货位 + JSONObject jsonDescBox = WQLObject.getWQLObject("st_ivt_structattr").query("lock_type = '1' AND block_num = '" + block_num + "'AND placement_type = '" + placement_type + "' AND row_num = '" + row_num + "' AND is_delete = '0' AND is_used = '1' AND IFNULL(storagevehicle_code,'') <> '' order by out_order_seq DESC").uniqueResult(0); + + JSONObject jsonDescStruct = new JSONObject(); + if (ObjectUtil.isNotEmpty(jsonDescBox)) { + String out_order_seq = jsonDescBox.getString("out_order_seq"); + jsonDescStruct = WQLObject.getWQLObject("st_ivt_structattr").query("lock_type = '1' AND block_num = '" + block_num + "'AND placement_type = '" + placement_type + "' AND row_num = '" + row_num + "' AND is_delete = '0' AND is_used = '1' AND IFNULL(storagevehicle_code,'') = '' and out_order_seq > '" + out_order_seq + "' order by out_order_seq ASC").uniqueResult(0); + } else { + // 先倒序找到第一个入库锁或者移库锁、判断上一个是否有货位 + JSONObject jsonDescEmpStruct = WQLObject.getWQLObject("st_ivt_structattr").query("lock_type in ('2','7') AND block_num = '" + block_num + "'AND placement_type = '" + placement_type + "' AND row_num = '" + row_num + "' AND is_delete = '0' AND is_used = '1' AND IFNULL(storagevehicle_code,'') = '' order by out_order_seq DESC").uniqueResult(0); + + if (ObjectUtil.isNotEmpty(jsonDescEmpStruct)) { + String out_order_seq = jsonDescEmpStruct.getString("out_order_seq"); + jsonDescStruct = WQLObject.getWQLObject("st_ivt_structattr").query("lock_type = '1' AND block_num = '" + block_num + "'AND placement_type = '" + placement_type + "' AND row_num = '" + row_num + "' AND is_delete = '0' AND is_used = '1' AND IFNULL(storagevehicle_code,'') = '' and out_order_seq > '" + out_order_seq + "' order by out_order_seq ASC").uniqueResult(0); + } + } + + if (ObjectUtil.isNotEmpty(jsonDescStruct)) { + struct_jo = jsonDescStruct; + + // 判断是否是第三层 且高度是否超过仓位高度 + if (StrUtil.equals(struct_jo.getString("layer_num"), "3")) { + if (box_high > struct_jo.getDoubleValue("height")) { + struct_jo = null; + continue; + } + } + break; + } else { + // 没有就正序找到第一个物料、判断上一个是否有货位 + JSONObject jsonAscBox = WQLObject.getWQLObject("st_ivt_structattr").query("lock_type = '1' AND block_num = '" + block_num + "'AND placement_type = '" + placement_type + "' AND row_num = '" + row_num + "' AND is_delete = '0' AND is_used = '1' AND IFNULL(storagevehicle_code,'') <> '' order by out_order_seq ASC").uniqueResult(0); + + JSONObject jsonAscStruct = new JSONObject(); + if (ObjectUtil.isNotEmpty(jsonAscBox)) { + String out_order_seq2 = jsonAscBox.getString("out_order_seq"); + // 上一个货位顺序号 + jsonAscStruct = WQLObject.getWQLObject("st_ivt_structattr").query("lock_type = '1' AND block_num = '" + block_num + "'AND placement_type = '" + placement_type + "' AND row_num = '" + row_num + "' AND is_delete = '0' AND is_used = '1' AND IFNULL(storagevehicle_code,'') = '' and out_order_seq < '" + out_order_seq2 + "' order by out_order_seq DESC").uniqueResult(0); + } else { + JSONObject jsonAscEmpStruct = WQLObject.getWQLObject("st_ivt_structattr").query("lock_type in ('2','7') AND block_num = '" + block_num + "'AND placement_type = '" + placement_type + "' AND row_num = '" + row_num + "' AND is_delete = '0' AND is_used = '1' AND IFNULL(storagevehicle_code,'') = '' order by out_order_seq ASC").uniqueResult(0); + + if (ObjectUtil.isNotEmpty(jsonAscEmpStruct)) { + String out_order_seq2 = jsonAscEmpStruct.getString("out_order_seq"); + jsonAscStruct = WQLObject.getWQLObject("st_ivt_structattr").query("lock_type = '1' AND block_num = '" + block_num + "'AND placement_type = '" + placement_type + "' AND row_num = '" + row_num + "' AND is_delete = '0' AND is_used = '1' AND IFNULL(storagevehicle_code,'') = '' and out_order_seq < '" + out_order_seq2 + "' order by out_order_seq DESC").uniqueResult(0); + } + + } + if (ObjectUtil.isNotEmpty(jsonAscStruct)) { + struct_jo = jsonAscStruct; + + // 判断是否是第三层 且高度是否超过仓位高度 + if (StrUtil.equals(struct_jo.getString("layer_num"), "3")) { + if (box_high > struct_jo.getDoubleValue("height")) { + struct_jo = null; + continue; + } + } + break; + } else { + // 说明这排有任务在执行,新开一排 + //根据分切计划查询该订单物料大概还有多少未入 + row_map.put("flag", "12"); + JSONArray plan_rows = WQL.getWO("QST_IVT_RAWASSISTISTOR").addParamMap(row_map).process().getResultJSONArray(0); + if (ObjectUtil.isEmpty(plan_rows)) { + plan_rows = new JSONArray(); + } + //查询该销售订单及行号有多少个生成状态的箱子 + row_map.put("flag", "27"); + JSONArray box_rows = WQL.getWO("QST_IVT_RAWASSISTISTOR").addParamMap(row_map).process().getResultJSONArray(0); + if (ObjectUtil.isEmpty(box_rows)) { + box_rows = new JSONArray(); + } + int box_num = (int) Math.ceil(plan_rows.size() / 2) + box_rows.size(); + + //查询数量与订单物料箱子数量相近的一排 + JSONObject empty_row = WQL.getWO("QST_IVT_RAWASSISTISTOR").addParam("col_num", col_num).addParam("sect_id", sect_id).addParam("flag", "13").addParam("sql_str", " ORDER BY abs(" + box_num + "-a.struct_num),block_num,row_num").process().uniqueResult(0); + if (ObjectUtil.isNotEmpty(empty_row)) { + String block_num2 = empty_row.getString("block_num"); + String row_num2 = empty_row.getString("row_num"); + String placement_type2 = empty_row.getString("placement_type"); + + if ("02".equals(placement_type)) { + struct_jo = WQLObject.getWQLObject("st_ivt_structattr").query("lock_type = '1' AND block_num = '" + block_num2 + "' AND row_num = '" + row_num2 + "' AND placement_type = '" + placement_type2 + "' AND is_delete = '0' AND is_used = '1' AND lock_type = '1' order by out_order_seq ASC").uniqueResult(0); + + // 判断是否是第三层 且高度是否超过仓位高度 + if (StrUtil.equals(struct_jo.getString("layer_num"), "3")) { + if (box_high > struct_jo.getDoubleValue("height")) { + struct_jo = null; + continue; + } + } + break; + } else { + struct_jo = WQLObject.getWQLObject("st_ivt_structattr").query("lock_type = '1' AND block_num = '" + block_num2 + "' AND row_num = '" + row_num2 + "' AND placement_type = '" + placement_type2 + "'AND is_delete = '0' AND is_used = '1' AND lock_type = '1' order by out_order_seq DESC").uniqueResult(0); + + // 判断是否是第三层 且高度是否超过仓位高度 + if (StrUtil.equals(struct_jo.getString("layer_num"), "3")) { + if (box_high > struct_jo.getDoubleValue("height")) { + struct_jo = null; + continue; + } + } + break; + } + } else { + //如果查询不到空的一排,则查询有空位双通的一排 + JSONArray haveArr = WQL.getWO("QST_IVT_RAWASSISTISTOR").addParam("col_num", col_num).addParam("sect_id", sect_id).addParam("flag", "14").addParam("sql_str", " ORDER BY abs(" + box_num + "-a.struct_num)").process().getResultJSONArray(0); + + for (int j = 0; j < haveArr.size(); j++) { + JSONObject have_row = haveArr.getJSONObject(j); + + String block_num3 = have_row.getString("block_num"); + String row_num3 = have_row.getString("row_num"); + + JSONArray isLock2 = WQLObject.getWQLObject("st_ivt_structattr").query("lock_type not in ('1','2','7') AND block_num = '" + block_num3 + "' AND row_num = '" + row_num3 + "' AND is_delete = '0' AND is_used = '1'").getResultJSONArray(0); + + if (ObjectUtil.isEmpty(isLock2)) { + // 先倒序找到第一个木箱、判断上一个是否有货位 + JSONObject jsonDescBox2 = WQLObject.getWQLObject("st_ivt_structattr").query("lock_type = '1' AND block_num = '" + block_num3 + "' AND row_num = '" + row_num3 + "' AND is_delete = '0' AND is_used = '1' AND IFNULL(storagevehicle_code,'') <> '' order by out_order_seq DESC").uniqueResult(0); + + JSONObject jsonDescStruct2 = new JSONObject(); + if (ObjectUtil.isNotEmpty(jsonDescBox2)) { + String out_order_seq = jsonDescBox2.getString("out_order_seq"); + jsonDescStruct2 = WQLObject.getWQLObject("st_ivt_structattr").query("lock_type = '1' AND block_num = '" + block_num3 + "' AND row_num = '" + row_num3 + "' AND is_delete = '0' AND is_used = '1' AND IFNULL(storagevehicle_code,'') = '' and out_order_seq > '" + out_order_seq + "' order by out_order_seq ASC").uniqueResult(0); + } else { + // 先倒序找到第一个入库锁或者移库锁、判断上一个是否有货位 + JSONObject jsonDescEmpStruct = WQLObject.getWQLObject("st_ivt_structattr").query("lock_type in ('2','7') AND block_num = '" + block_num3 + "' AND row_num = '" + row_num3 + "' AND is_delete = '0' AND is_used = '1' AND IFNULL(storagevehicle_code,'') = '' order by out_order_seq DESC").uniqueResult(0); + + if (ObjectUtil.isNotEmpty(jsonDescEmpStruct)) { + String out_order_seq = jsonDescEmpStruct.getString("out_order_seq"); + jsonDescStruct2 = WQLObject.getWQLObject("st_ivt_structattr").query("lock_type = '1' AND block_num = '" + block_num3 + "' AND row_num = '" + row_num3 + "' AND is_delete = '0' AND is_used = '1' AND IFNULL(storagevehicle_code,'') = '' and out_order_seq > '" + out_order_seq + "' order by out_order_seq ASC").uniqueResult(0); + } + } + + if (ObjectUtil.isNotEmpty(jsonDescStruct2)) { + struct_jo = jsonDescStruct2; + + // 判断是否是第三层 且高度是否超过仓位高度 + if (StrUtil.equals(struct_jo.getString("layer_num"), "3")) { + if (box_high > struct_jo.getDoubleValue("height")) { + struct_jo = null; + continue; + } + } + break; + } else { + // 没有就正序找到第一个物料、判断上一个是否有货位 + JSONObject jsonAscBox2 = WQLObject.getWQLObject("st_ivt_structattr").query("lock_type = '1' AND block_num = '" + block_num3 + "' AND row_num = '" + row_num3 + "' AND is_delete = '0' AND is_used = '1' AND IFNULL(storagevehicle_code,'') <> '' order by out_order_seq ASC").uniqueResult(0); + + JSONObject jsonAscStruct2 = new JSONObject(); + if (ObjectUtil.isNotEmpty(jsonAscBox2)) { + String out_order_seq2 = jsonAscBox2.getString("out_order_seq"); + // 上一个货位顺序号 + jsonAscStruct2 = WQLObject.getWQLObject("st_ivt_structattr").query("lock_type = '1' AND block_num = '" + block_num3 + "' AND row_num = '" + row_num3 + "' AND is_delete = '0' AND is_used = '1' AND IFNULL(storagevehicle_code,'') = '' and out_order_seq < '" + out_order_seq2 + "' order by out_order_seq DESC").uniqueResult(0); + } else { + JSONObject jsonAscEmpStruct = WQLObject.getWQLObject("st_ivt_structattr").query("lock_type in ('2','7') AND block_num = '" + block_num3 + "' AND row_num = '" + row_num3 + "' AND is_delete = '0' AND is_used = '1' AND IFNULL(storagevehicle_code,'') = '' order by out_order_seq ASC").uniqueResult(0); + + if (ObjectUtil.isNotEmpty(jsonAscEmpStruct)) { + String out_order_seq2 = jsonAscEmpStruct.getString("out_order_seq"); + jsonAscStruct2 = WQLObject.getWQLObject("st_ivt_structattr").query("lock_type = '1' AND block_num = '" + block_num3 + "' AND row_num = '" + row_num3 + "' AND is_delete = '0' AND is_used = '1' AND IFNULL(storagevehicle_code,'') = '' and out_order_seq < '" + out_order_seq2 + "' order by out_order_seq DESC").uniqueResult(0); + } + + } + if (ObjectUtil.isNotEmpty(jsonAscStruct2)) { + struct_jo = jsonAscStruct2; + + // 判断是否是第三层 且高度是否超过仓位高度 + if (StrUtil.equals(struct_jo.getString("layer_num"), "3")) { + if (box_high > struct_jo.getDoubleValue("height")) { + struct_jo = null; + continue; + } + } + break; + } + } + } else { + continue; + } + } + } + } + } + } + } else { + continue; + } + } + + if (ObjectUtil.isEmpty(rowArr) || ObjectUtil.isEmpty(struct_jo)) { + //如果不存在相同订单物料的巷道 或者未找到相同物料订单号巷道中的货位 则 + + //根据分切计划查询该订单物料大概还有多少未入 + row_map.put("flag", "12"); + JSONArray plan_rows = WQL.getWO("QST_IVT_RAWASSISTISTOR").addParamMap(row_map).process().getResultJSONArray(0); + if (ObjectUtil.isEmpty(plan_rows)) { + plan_rows = new JSONArray(); + } + //查询该销售订单及行号有多少个生成状态的箱子 + row_map.put("flag", "27"); + JSONArray box_rows = WQL.getWO("QST_IVT_RAWASSISTISTOR").addParamMap(row_map).process().getResultJSONArray(0); + if (ObjectUtil.isEmpty(box_rows)) { + box_rows = new JSONArray(); + } + int box_num = (int) Math.ceil(plan_rows.size() / 2) + box_rows.size(); + + //查询数量与订单物料箱子数量相近的一排 + JSONObject empty_row = WQL.getWO("QST_IVT_RAWASSISTISTOR") + .addParam("col_num", col_num) + .addParam("sect_id", sect_id) + .addParam("box_height", String.valueOf(box_high)) + .addParam("flag", "13") + .addParam("sql_str", " ORDER BY abs(" + box_num + "-a.struct_num),block_num,row_num") + .process().uniqueResult(0); + if (ObjectUtil.isNotEmpty(empty_row)) { + String block_num = empty_row.getString("block_num"); + String row_num = empty_row.getString("row_num"); + String placement_type = empty_row.getString("placement_type"); + + if ("02".equals(placement_type)) { + struct_jo = WQLObject.getWQLObject("st_ivt_structattr").query("lock_type = '1' AND block_num = '" + block_num + "' AND row_num = '" + row_num + "' AND placement_type = '" + placement_type + "' AND is_delete = '0' AND is_used = '1' AND lock_type = '1' order by out_order_seq ASC").uniqueResult(0); + } else { + struct_jo = WQLObject.getWQLObject("st_ivt_structattr").query("lock_type = '1' AND block_num = '" + block_num + "' AND row_num = '" + row_num + "' AND placement_type = '" + placement_type + "'AND is_delete = '0' AND is_used = '1' AND lock_type = '1' order by out_order_seq DESC").uniqueResult(0); + } + } else { + + //如果查询不到空的一排,则查询有空位双通的一排 + JSONArray haveArr = WQL.getWO("QST_IVT_RAWASSISTISTOR").addParam("col_num", col_num).addParam("sect_id", sect_id).addParam("flag", "14").addParam("sql_str", " ORDER BY abs(" + box_num + "-a.struct_num)").process().getResultJSONArray(0); + for (int j = 0; j < haveArr.size(); j++) { + JSONObject have_row = haveArr.getJSONObject(j); + + String block_num3 = have_row.getString("block_num"); + String row_num3 = have_row.getString("row_num"); + + JSONArray isLock2 = WQLObject.getWQLObject("st_ivt_structattr").query("lock_type not in ('1','2','7') AND block_num = '" + block_num3 + "' AND row_num = '" + row_num3 + "' AND is_delete = '0' AND is_used = '1'").getResultJSONArray(0); + + if (ObjectUtil.isEmpty(isLock2)) { + // 先倒序找到第一个木箱、判断上一个是否有货位 + JSONObject jsonDescBox2 = WQLObject.getWQLObject("st_ivt_structattr").query("lock_type = '1' AND block_num = '" + block_num3 + "' AND row_num = '" + row_num3 + "' AND is_delete = '0' AND is_used = '1' AND IFNULL(storagevehicle_code,'') <> '' order by out_order_seq DESC").uniqueResult(0); + + JSONObject jsonDescStruct2 = new JSONObject(); + if (ObjectUtil.isNotEmpty(jsonDescBox2)) { + String out_order_seq = jsonDescBox2.getString("out_order_seq"); + jsonDescStruct2 = WQLObject.getWQLObject("st_ivt_structattr").query("lock_type = '1' AND block_num = '" + block_num3 + "' AND row_num = '" + row_num3 + "' AND is_delete = '0' AND is_used = '1' AND IFNULL(storagevehicle_code,'') = '' and out_order_seq > '" + out_order_seq + "' order by out_order_seq ASC").uniqueResult(0); + } else { + // 先倒序找到第一个入库锁或者移库锁、判断上一个是否有货位 + JSONObject jsonDescEmpStruct = WQLObject.getWQLObject("st_ivt_structattr").query("lock_type in ('2','7') AND block_num = '" + block_num3 + "' AND row_num = '" + row_num3 + "' AND is_delete = '0' AND is_used = '1' AND IFNULL(storagevehicle_code,'') = '' order by out_order_seq DESC").uniqueResult(0); + + if (ObjectUtil.isNotEmpty(jsonDescEmpStruct)) { + String out_order_seq = jsonDescEmpStruct.getString("out_order_seq"); + jsonDescStruct2 = WQLObject.getWQLObject("st_ivt_structattr").query("lock_type = '1' AND block_num = '" + block_num3 + "' AND row_num = '" + row_num3 + "' AND is_delete = '0' AND is_used = '1' AND IFNULL(storagevehicle_code,'') = '' and out_order_seq > '" + out_order_seq + "' order by out_order_seq ASC").uniqueResult(0); + } + } + + if (ObjectUtil.isNotEmpty(jsonDescStruct2)) { + struct_jo = jsonDescStruct2; + + // 判断是否是第三层 且高度是否超过仓位高度 + if (StrUtil.equals(struct_jo.getString("layer_num"), "3")) { + if (box_high > struct_jo.getDoubleValue("height")) { + struct_jo = null; + continue; + } + } + break; + } else { + // 没有就正序找到第一个物料、判断上一个是否有货位 + JSONObject jsonAscBox2 = WQLObject.getWQLObject("st_ivt_structattr").query("lock_type = '1' AND block_num = '" + block_num3 + "' AND row_num = '" + row_num3 + "' AND is_delete = '0' AND is_used = '1' AND IFNULL(storagevehicle_code,'') <> '' order by out_order_seq ASC").uniqueResult(0); + + JSONObject jsonAscStruct2 = new JSONObject(); + if (ObjectUtil.isNotEmpty(jsonAscBox2)) { + String out_order_seq2 = jsonAscBox2.getString("out_order_seq"); + // 上一个货位顺序号 + jsonAscStruct2 = WQLObject.getWQLObject("st_ivt_structattr").query("lock_type = '1' AND block_num = '" + block_num3 + "' AND row_num = '" + row_num3 + "' AND is_delete = '0' AND is_used = '1' AND IFNULL(storagevehicle_code,'') = '' and out_order_seq < '" + out_order_seq2 + "' order by out_order_seq DESC").uniqueResult(0); + } else { + JSONObject jsonAscEmpStruct = WQLObject.getWQLObject("st_ivt_structattr").query("lock_type in ('2','7') AND block_num = '" + block_num3 + "' AND row_num = '" + row_num3 + "' AND is_delete = '0' AND is_used = '1' AND IFNULL(storagevehicle_code,'') = '' order by out_order_seq ASC").uniqueResult(0); + + if (ObjectUtil.isNotEmpty(jsonAscEmpStruct)) { + String out_order_seq2 = jsonAscEmpStruct.getString("out_order_seq"); + jsonAscStruct2 = WQLObject.getWQLObject("st_ivt_structattr").query("lock_type = '1' AND block_num = '" + block_num3 + "' AND row_num = '" + row_num3 + "' AND is_delete = '0' AND is_used = '1' AND IFNULL(storagevehicle_code,'') = '' and out_order_seq < '" + out_order_seq2 + "' order by out_order_seq DESC").uniqueResult(0); + } + + } + if (ObjectUtil.isNotEmpty(jsonAscStruct2)) { + struct_jo = jsonAscStruct2; + + // 判断是否是第三层 且高度是否超过仓位高度 + if (StrUtil.equals(struct_jo.getString("layer_num"), "3")) { + if (box_high > struct_jo.getDoubleValue("height")) { + struct_jo = null; + continue; + } + } + break; + } + } + } else { + continue; + } + } + } } return struct_jo; } @@ -2115,4 +2566,157 @@ public class RawAssistIStorServiceImpl implements RawAssistIStorService { map.put("bill_status", "99"); dtl_wql.update(map, "iostorinv_id = '" + mst_row.get("iostorinv_id") + "'"); } + + /** + * 新开事务,把当前事务挂起,(新开事务不回滚) + */ + @Transactional(propagation=Propagation.REQUIRES_NEW) + public void updateStructSect(String layer_num) { + WQLObject attr = WQLObject.getWQLObject("st_ivt_structattr"); + WQLObject point = WQLObject.getWQLObject("sch_base_point"); + /* + * 1.将主存区的一排更改为中转区 + * 2.将中转区的一排更改为主存区 + */ + String block_num = ""; + String row_num = ""; + // 1.找主存区数量小的一排转为中转区 + // 根据块、排进行分组,优先空排 -> 有货数量少的 + List attrListAllEmp = WQL.getWO("ST_UPDATESTRUCTSECT_01").addParam("flag", "1") + .addParam("layer_num", layer_num).process().getResultJSONArray(0) + .toJavaList(JSONObject.class); + + if (ObjectUtil.isEmpty(attrListAllEmp)) { + // 如果为空则查找有空位的排 + List attrListEmp = WQL.getWO("ST_UPDATESTRUCTSECT_01").addParam("flag", "2") + .addParam("layer_num", layer_num).process().getResultJSONArray(0) + .toJavaList(JSONObject.class); + + if (ObjectUtil.isEmpty(attrListEmp)) { + throw new BadRequestException("自动扩容失败,主存区没有空位可扩容!"); + } + + // 判断是这排是否被锁住 + String block_num_in = attrListEmp.stream() + .map(row -> row.getString("block_num")) + .collect(Collectors.joining("','")); + + String row_num_in = attrListEmp.stream() + .map(row -> row.getString("row_num")) + .collect(Collectors.joining("','")); + + List rowList = attr.query("block_num in ('" + block_num_in + "') AND row_num in ('" + row_num_in + "') and layer_num = '" + layer_num + "' and sect_code = 'ZC01'") + .getResultJSONArray(0).toJavaList(JSONObject.class); + + for (int i = 0; i < attrListEmp.size(); i++) { + JSONObject json = attrListEmp.get(i); + + List collect = rowList.stream() + .filter(row -> row.getString("block_num").equals(json.getString("block_num")) && + row.getString("row_num").equals(json.getString("row_num")) + ) + .collect(Collectors.toList()); + + // 判断是否全部都为未锁定 + boolean isLock = collect.stream() + .allMatch(row -> row.getString("lock_type").equals("1")); + + if (!isLock) { + continue; + } + + block_num = json.getString("block_num"); + row_num = json.getString("row_num"); + break; + } + } else { + JSONObject json = attrListAllEmp.get(0); + block_num = json.getString("block_num"); + row_num = json.getString("row_num"); + } + + if (ObjectUtil.isEmpty(block_num) && ObjectUtil.isEmpty(row_num)) { + throw new BadRequestException(layer_num + "层没有仓位可分配为中转区!"); + } + + // 2.将中转区的一排更改为主存区 + // 查询中转区满的一排 + List attrListAllNoEmp = WQL.getWO("ST_UPDATESTRUCTSECT_01").addParam("flag", "3") + .addParam("layer_num", layer_num).process().getResultJSONArray(0) + .toJavaList(JSONObject.class); + + if (ObjectUtil.isNotEmpty(attrListAllNoEmp)) { + // 更新仓位为主存区 + JSONObject jsonParam2 = new JSONObject(); + jsonParam2.put("sect_id", RegionTypeEnum.ZC01.getId()); + jsonParam2.put("sect_code", "ZC01"); + jsonParam2.put("sect_name", RegionTypeEnum.ZC01.getName()); + + JSONObject json = attrListAllNoEmp.get(0); + // 更新仓位 + attr.update(jsonParam2,"sect_code = 'ZZ01' AND block_num = '"+json.getString("block_num")+"' AND row_num = '"+json.getString("row_num")+"' AND layer_num = '"+layer_num+"'"); + + // 更新点位 + jsonParam2.put("region_id", RegionTypeEnum.ZC01.getId()); + jsonParam2.put("region_code", "ZC01"); + jsonParam2.put("region_name", RegionTypeEnum.ZC01.getName()); + point.update(jsonParam2,"region_code = 'ZZ01' AND block_num = '"+json.getString("block_num")+"' AND row_num = '"+json.getString("row_num")+"' AND layer_num = '"+layer_num+"'"); + + } + + // 更新仓位为中转区 + JSONObject jsonParam = new JSONObject(); + jsonParam.put("sect_id", RegionTypeEnum.ZZ01.getId()); + jsonParam.put("sect_code", "ZZ01"); + jsonParam.put("sect_name", RegionTypeEnum.ZZ01.getName()); + attr.update(jsonParam,"sect_code = 'ZC01' AND block_num = '"+block_num+"' AND row_num = '"+row_num+"' AND layer_num = '"+layer_num+"'"); + + // 更新点位 + jsonParam.put("region_id", RegionTypeEnum.ZZ01.getId()); + jsonParam.put("region_code", "ZZ01"); + jsonParam.put("region_name", RegionTypeEnum.ZZ01.getName()); + point.update(jsonParam,"region_code = 'ZC01' AND block_num = '"+block_num+"' AND row_num = '"+row_num+"' AND layer_num = '"+layer_num+"'"); + } + + /** + * 1层主存区扩容:空托盘区 ==> 主存区 + */ + public boolean updateStructSectOne() { + WQLObject attr = WQLObject.getWQLObject("st_ivt_structattr"); + WQLObject point = WQLObject.getWQLObject("sch_base_point"); + /* + * 1.找空托盘区空的一排进行扩容 + * + */ + // 找空托盘区空的一排 + List rowList = WQL.getWO("ST_UPDATESTRUCTSECTONE_01").addParam("flag", "1") + .process().getResultJSONArray(0).toJavaList(JSONObject.class); + + // 如果没有空排或者空排低于2排则不允许扩容 + if (ObjectUtil.isEmpty(rowList) || rowList.size() <= 2) { + log.info("空托盘区需预留2排空位,不容许扩容!"); + return false; + } + + try { + JSONObject json = rowList.get(0); + + // 更新仓位为主存区 + JSONObject jsonParam = new JSONObject(); + jsonParam.put("sect_id", RegionTypeEnum.ZC01.getId()); + jsonParam.put("sect_code", "ZC01"); + jsonParam.put("sect_name", RegionTypeEnum.ZC01.getName()); + attr.update(jsonParam,"sect_code = 'KTP01' AND block_num = '"+json.getString("block_num")+"' AND row_num = '"+json.getString("row_num")+"' AND layer_num = '1'"); + + // 更新点位为主存区域 + jsonParam.put("region_id", RegionTypeEnum.ZC01.getId()); + jsonParam.put("region_code", "ZC01"); + jsonParam.put("region_name", RegionTypeEnum.ZC01.getName()); + point.update(jsonParam,"region_code = 'KTP01' AND block_num = '"+json.getString("block_num")+"' AND row_num = '"+json.getString("row_num")+"' AND layer_num = '1'"); + } catch (Exception e) { + System.out.println("1层主存区扩容失败:"+e.getMessage()); + return false; + } + return true; + } } diff --git a/lms/nladmin-system/src/main/java/org/nl/wms/st/inbill/service/impl/StorPublicServiceImpl.java b/lms/nladmin-system/src/main/java/org/nl/wms/st/inbill/service/impl/StorPublicServiceImpl.java index 05306e8fe..7269c4f0e 100644 --- a/lms/nladmin-system/src/main/java/org/nl/wms/st/inbill/service/impl/StorPublicServiceImpl.java +++ b/lms/nladmin-system/src/main/java/org/nl/wms/st/inbill/service/impl/StorPublicServiceImpl.java @@ -484,6 +484,12 @@ public class StorPublicServiceImpl implements StorPublicService { map.put("storagevehicle_code", storagevehicle_code); } + if (ObjectUtil.isNotEmpty(from.getString("bill_type"))) { + if (from.getString("bill_type").equals("1011")){ + map.put("storagevehicle_code", storagevehicle_code); + } + } + wo_Struct.update(map, "struct_id = '" + jo.getString("struct_id") + "'"); wo_Point.update(map, "point_id = '" + jo.getString("point_id") + "'"); } else {//锁定 diff --git a/lms/nladmin-system/src/main/java/org/nl/wms/st/inbill/wql/QST_IVT_RAWASSISTISTOR.wql b/lms/nladmin-system/src/main/java/org/nl/wms/st/inbill/wql/QST_IVT_RAWASSISTISTOR.wql index d187cda6c..f34164670 100644 --- a/lms/nladmin-system/src/main/java/org/nl/wms/st/inbill/wql/QST_IVT_RAWASSISTISTOR.wql +++ b/lms/nladmin-system/src/main/java/org/nl/wms/st/inbill/wql/QST_IVT_RAWASSISTISTOR.wql @@ -46,7 +46,7 @@ 输入.sap_pcsn_in TYPEAS f_string 输入.vbeln_in TYPEAS f_string 输入.box_no_in TYPEAS f_string - + 输入.layer_num TYPEAS s_string [临时表] --这边列出来的临时表就会在运行期动态创建 @@ -474,12 +474,49 @@ LEFT JOIN md_me_materialbase mb ON mb.material_id = ivt.material_id WHERE sa.sect_id = 输入.sect_id + AND IFNULL(sa.storagevehicle_code,"") = '' + AND sa.is_used = '1' + AND sa.is_delete = '0' + AND sa.lock_type = '1' OPTION 输入.material_code <> "" mb.material_code = 输入.material_code ENDOPTION OPTION 输入.sale_order_name <> "" sub.sale_order_name = 输入.sale_order_name ENDOPTION + + OPTION 输入.layer_num <> "" + sa.layer_num = 输入.layer_num + ENDOPTION + + GROUP BY + sa.block_num,sa.row_num,sa.placement_type + ORDER BY + sa.placement_type desc,num + ENDSELECT + ENDQUERY + ENDIF + + IF 输入.flag = "1111" + QUERY + SELECT + count(sa.struct_code) AS num, + sa.block_num, + sa.row_num, + sa.placement_type + FROM + st_ivt_structattr sa + WHERE + sa.sect_id = 输入.sect_id + and sa.is_used = '1' + and sa.is_delete = '0' + and ifnull(sa.storagevehicle_code,'') = '' + and sa.lock_type = '1' + + OPTION 输入.layer_num <> "" + sa.layer_num = 输入.layer_num + ENDOPTION + GROUP BY sa.block_num,sa.row_num,sa.placement_type ORDER BY diff --git a/lms/nladmin-system/src/main/java/org/nl/wms/st/inbill/wql/ST_UPDATESTRUCTSECTONE_01.wql b/lms/nladmin-system/src/main/java/org/nl/wms/st/inbill/wql/ST_UPDATESTRUCTSECTONE_01.wql new file mode 100644 index 000000000..8867d0063 --- /dev/null +++ b/lms/nladmin-system/src/main/java/org/nl/wms/st/inbill/wql/ST_UPDATESTRUCTSECTONE_01.wql @@ -0,0 +1,199 @@ +[交易说明] + 交易名: 更新仓位属性查询 + 所属模块: + 功能简述: + 版权所有: + 表引用: + 版本经历: + +[数据库] + --指定数据库,为空采用默认值,默认为db.properties中列出的第一个库 + +[IO定义] + ################################################# + ## 表字段对应输入参数 + ################################################# + 输入.flag TYPEAS s_string + +[临时表] + --这边列出来的临时表就会在运行期动态创建 + +[临时变量] + --所有中间过程变量均可在此处定义 + +[业务过程] + + ########################################## + # 1、输入输出检查 # + ########################################## + + + ########################################## + # 2、主过程前处理 # + ########################################## + + + ########################################## + # 3、业务主过程 # + ########################################## + + IF 输入.flag = "1" + QUERY + SELECT + * + FROM + ( + SELECT + sa.block_num, + sa.row_num, + COUNT( sa.struct_code ) AS struct_num + FROM + st_ivt_structattr sa + WHERE + sa.is_delete = '0' + AND sa.is_used = '1' + AND sa.sect_code = 'KTP01' + GROUP BY + sa.block_num, + sa.row_num + ) a + WHERE + EXISTS ( + SELECT + * + FROM + ( + SELECT + block_num, + row_num, + COUNT( sa2.struct_code ) AS struct_num + FROM + st_ivt_structattr sa2 + WHERE + sa2.lock_type = '1' + AND sa2.is_used = '1' + AND sa2.is_delete = '0' + AND sa2.sect_code = 'KTP01' + AND IFNULL( sa2.storagevehicle_code, '' ) = '' + GROUP BY + sa2.block_num, + sa2.row_num + ) b + WHERE + b.block_num = a.block_num + AND b.row_num = a.row_num + AND a.struct_num = b.struct_num + ) ORDER BY struct_num DESC + + ENDSELECT + ENDQUERY + ENDIF + + IF 输入.flag = "2" + QUERY + SELECT + * + FROM + ( + SELECT + sa.block_num, + sa.row_num, + COUNT( sa.struct_code ) AS struct_num + FROM + st_ivt_structattr sa + WHERE + sa.is_delete = '0' + AND sa.is_used = '1' + AND sa.layer_num = '1' + AND sa.sect_code = 'ZC01' + GROUP BY + sa.block_num, + sa.row_num + ) a + WHERE + EXISTS ( + SELECT + * + FROM + ( + SELECT + block_num, + row_num, + COUNT( sa2.struct_code ) AS struct_num + FROM + st_ivt_structattr sa2 + WHERE + sa2.lock_type = '1' + AND sa2.is_used = '1' + AND sa2.is_delete = '0' + AND sa2.sect_code = 'ZC01' + AND sa2.layer_num = '1' + AND IFNULL( sa2.storagevehicle_code, '' ) = '' + GROUP BY + sa2.block_num, + sa2.row_num + ) b + WHERE + b.block_num = a.block_num + AND b.row_num = a.row_num + AND a.struct_num = b.struct_num + ) ORDER BY struct_num DESC + + ENDSELECT + ENDQUERY + ENDIF + + IF 输入.flag = "3" + QUERY + SELECT + * + FROM + ( + SELECT + sa.block_num, + sa.row_num, + COUNT( sa.struct_code ) AS struct_num + FROM + st_ivt_structattr sa + WHERE + sa.is_delete = '0' + AND sa.is_used = '1' + AND sa.layer_num = '1' + AND sa.sect_code = 'ZC01' + AND IFNULL( sa.storagevehicle_code, '' ) = '' + GROUP BY + sa.block_num, + sa.row_num + ) a + WHERE + EXISTS ( + SELECT + * + FROM + ( + SELECT + block_num, + row_num, + COUNT( sa2.struct_code ) AS struct_num + FROM + st_ivt_structattr sa2 + WHERE + sa2.lock_type = '1' + AND sa2.is_used = '1' + AND sa2.is_delete = '0' + AND sa2.sect_code = 'ZC01' + AND sa2.layer_num = '1' + AND IFNULL( sa2.storagevehicle_code, '' ) <> '' + GROUP BY + sa2.block_num, + sa2.row_num + ) b + WHERE + b.block_num = a.block_num + AND b.row_num = a.row_num + + ) ORDER BY struct_num DESC + + ENDSELECT + ENDQUERY + ENDIF \ No newline at end of file diff --git a/lms/nladmin-system/src/main/java/org/nl/wms/st/inbill/wql/ST_UPDATESTRUCTSECT_01.wql b/lms/nladmin-system/src/main/java/org/nl/wms/st/inbill/wql/ST_UPDATESTRUCTSECT_01.wql new file mode 100644 index 000000000..bcda2303a --- /dev/null +++ b/lms/nladmin-system/src/main/java/org/nl/wms/st/inbill/wql/ST_UPDATESTRUCTSECT_01.wql @@ -0,0 +1,218 @@ +[交易说明] + 交易名: 更新仓位属性查询 + 所属模块: + 功能简述: + 版权所有: + 表引用: + 版本经历: + +[数据库] + --指定数据库,为空采用默认值,默认为db.properties中列出的第一个库 + +[IO定义] + ################################################# + ## 表字段对应输入参数 + ################################################# + 输入.flag TYPEAS s_string + 输入.layer_num TYPEAS s_string + +[临时表] + --这边列出来的临时表就会在运行期动态创建 + +[临时变量] + --所有中间过程变量均可在此处定义 + +[业务过程] + + ########################################## + # 1、输入输出检查 # + ########################################## + + + ########################################## + # 2、主过程前处理 # + ########################################## + + + ########################################## + # 3、业务主过程 # + ########################################## + + IF 输入.flag = "1" + QUERY + SELECT + * + FROM + ( + SELECT + sa.block_num, + sa.row_num, + COUNT( sa.struct_code ) AS struct_num + FROM + st_ivt_structattr sa + WHERE + sa.is_delete = '0' + AND sa.is_used = '1' + AND sa.sect_code = 'ZC01' + AND sa.placement_type = '01' + OPTION 输入.layer_num <> "" + sa.layer_num = 输入.layer_num + ENDOPTION + GROUP BY + sa.block_num, + sa.row_num + ) a + WHERE + EXISTS ( + SELECT + * + FROM + ( + SELECT + block_num, + row_num, + COUNT( sa2.struct_code ) AS struct_num + FROM + st_ivt_structattr sa2 + WHERE + sa2.lock_type = '1' + AND sa2.is_used = '1' + AND sa2.is_delete = '0' + AND sa2.sect_code = 'ZC01' + AND IFNULL( sa2.storagevehicle_code, '' ) = '' + AND sa2.placement_type = '01' + OPTION 输入.layer_num <> "" + sa2.layer_num = 输入.layer_num + ENDOPTION + GROUP BY + sa2.block_num, + sa2.row_num + ) b + WHERE + b.block_num = a.block_num + AND b.row_num = a.row_num + AND a.struct_num = b.struct_num + ) ORDER BY struct_num DESC + + ENDSELECT + ENDQUERY + ENDIF + + IF 输入.flag = "2" + QUERY + SELECT + * + FROM + ( + SELECT + sa.block_num, + sa.row_num, + COUNT( sa.struct_code ) AS struct_num + FROM + st_ivt_structattr sa + WHERE + sa.is_delete = '0' + AND sa.is_used = '1' + AND sa.lock_type = '1' + AND sa.sect_code = 'ZC01' + AND sa.placement_type = '01' + OPTION 输入.layer_num <> "" + sa.layer_num = 输入.layer_num + ENDOPTION + GROUP BY + sa.block_num, + sa.row_num + ) a + WHERE + EXISTS ( + SELECT + * + FROM + ( + SELECT + block_num, + row_num, + COUNT( sa2.struct_code ) AS struct_num + FROM + st_ivt_structattr sa2 + WHERE + sa2.lock_type = '1' + AND sa2.is_used = '1' + AND sa2.is_delete = '0' + AND sa2.sect_code = 'ZC01' + AND sa2.placement_type = '01' + AND IFNULL( sa2.storagevehicle_code, '' ) = '' + OPTION 输入.layer_num <> "" + sa2.layer_num = 输入.layer_num + ENDOPTION + GROUP BY + sa2.block_num, + sa2.row_num + ) b + WHERE + b.block_num = a.block_num + AND b.row_num = a.row_num + ) ORDER BY struct_num DESC + + ENDSELECT + ENDQUERY + ENDIF + + IF 输入.flag = "3" + QUERY + SELECT + * + FROM + ( + SELECT + sa.block_num, + sa.row_num, + COUNT( sa.struct_code ) AS struct_num + FROM + st_ivt_structattr sa + WHERE + sa.is_delete = '0' + AND sa.is_used = '1' + AND sa.lock_type = '1' + AND sa.sect_code = 'ZZ01' + OPTION 输入.layer_num <> "" + sa.layer_num = 输入.layer_num + ENDOPTION + GROUP BY + sa.block_num, + sa.row_num + ) a + WHERE + EXISTS ( + SELECT + * + FROM + ( + SELECT + block_num, + row_num, + COUNT( sa2.struct_code ) AS struct_num + FROM + st_ivt_structattr sa2 + WHERE + sa2.lock_type = '1' + AND sa2.is_used = '1' + AND sa2.is_delete = '0' + AND sa2.sect_code = 'ZZ01' + AND IFNULL( sa2.storagevehicle_code, '' ) <> '' + OPTION 输入.layer_num <> "" + sa2.layer_num = 输入.layer_num + ENDOPTION + GROUP BY + sa2.block_num, + sa2.row_num + ) b + WHERE + b.block_num = a.block_num + AND b.row_num = a.row_num + AND a.struct_num = b.struct_num + ) ORDER BY struct_num DESC + + ENDSELECT + ENDQUERY + ENDIF \ No newline at end of file diff --git a/lms/nladmin-system/src/main/java/org/nl/wms/st/instor/service/impl/HandMoveStorServiceImpl.java b/lms/nladmin-system/src/main/java/org/nl/wms/st/instor/service/impl/HandMoveStorServiceImpl.java index 39d0373ae..ab55d7e6c 100644 --- a/lms/nladmin-system/src/main/java/org/nl/wms/st/instor/service/impl/HandMoveStorServiceImpl.java +++ b/lms/nladmin-system/src/main/java/org/nl/wms/st/instor/service/impl/HandMoveStorServiceImpl.java @@ -20,6 +20,7 @@ import org.nl.modules.wql.util.WqlUtil; import org.nl.wms.basedata.st.service.impl.UserStorServiceImpl; import org.nl.wms.pda.mps.eum.RegionTypeEnum; import org.nl.wms.sch.manage.TaskStatusEnum; +import org.nl.wms.sch.tasks.OutTask; import org.nl.wms.st.inbill.service.RawAssistIStorService; import org.nl.wms.st.inbill.service.StorPublicService; import org.nl.wms.st.instor.service.HandMoveStorService; @@ -31,6 +32,7 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import java.util.*; +import java.util.function.Consumer; import java.util.stream.Collectors; /** @@ -43,6 +45,8 @@ public class HandMoveStorServiceImpl implements HandMoveStorService { private final StorPublicService storPublicService; private final HandMoveStorAcsTask handMoveStorAcsTask; private final EmpMoveTask empMoveTask; + private final OutTask outTask; + private final RawAssistIStorService rawAssistIStorService; @Override public Map pageQuery(Map whereJson, Pageable page) { @@ -1401,7 +1405,8 @@ public class HandMoveStorServiceImpl implements HandMoveStorService { for (int k = 0; k < numArr.size(); k++) { JSONObject json = numArr.getJSONObject(k); - error += json.getString("struct_code") + ","; + error += json.getString("struct_code") + ", 锁定单据号:"+json.getString("inv_code"); + } throw new BadRequestException("仓位:" + error + "被锁定且未下发任务,无法生成任务!"); @@ -1428,7 +1433,7 @@ public class HandMoveStorServiceImpl implements HandMoveStorService { for (int k = 0; k < numArr.size(); k++) { JSONObject json = numArr.getJSONObject(k); - error += json.getString("struct_code") + ","; + error += json.getString("struct_code") + ", 锁定单据号:"+json.getString("inv_code"); } throw new BadRequestException("仓位:" + error + "被锁定且未下发任务,无法生成任务!"); @@ -1454,7 +1459,7 @@ public class HandMoveStorServiceImpl implements HandMoveStorService { for (int k = 0; k < numArr.size(); k++) { JSONObject json = numArr.getJSONObject(k); - error += json.getString("struct_code") + ","; + error += json.getString("struct_code") + ", 锁定单据号:"+json.getString("inv_code"); } throw new BadRequestException("仓位:" + error + "被锁定且未下发任务,无法生成任务!"); @@ -1484,7 +1489,7 @@ public class HandMoveStorServiceImpl implements HandMoveStorService { for (int k = 0; k < numArr.size(); k++) { JSONObject json = numArr.getJSONObject(k); - error += json.getString("struct_code") + ","; + error += json.getString("struct_code") + ", 锁定单据号:"+json.getString("inv_code"); } throw new BadRequestException("仓位:" + error + "被锁定且未下发任务,无法生成任务!"); @@ -1515,7 +1520,7 @@ public class HandMoveStorServiceImpl implements HandMoveStorService { for (int k = 0; k < numArr.size(); k++) { JSONObject json = numArr.getJSONObject(k); - error += json.getString("struct_code") + ","; + error += json.getString("struct_code") + ", 锁定单据号:"+json.getString("inv_code"); } throw new BadRequestException("仓位:" + error + "被锁定且未下发任务,无法生成任务!"); @@ -1594,4 +1599,98 @@ public class HandMoveStorServiceImpl implements HandMoveStorService { } wo_mst.update(jo_mst); } + + /** + * 扩容移库 + * @param whereJson / + */ + public void createMoveExpansion(JSONObject whereJson) { + //任务表 + WQLObject wo_Task = WQLObject.getWQLObject("SCH_BASE_Task"); + WQLObject attrTab = WQLObject.getWQLObject("st_ivt_structattr"); + + JSONArray needMoveList = whereJson.getJSONArray("needMoveList"); + + for (int i = 0; i < needMoveList.size(); i++) { + JSONObject json = needMoveList.getJSONObject(i); + + JSONObject jsonAttr = attrTab.query("struct_code = '" + json.getString("struct_code") + "'").uniqueResult(0); + + JSONObject mapParam = new JSONObject();// 生成移库单传入参数 + JSONArray table = new JSONArray(); // 明细参数 + + mapParam.put("bill_type", "22"); + mapParam.put("buss_type", "22"); + mapParam.put("bill_status", "10"); + + mapParam.put("biz_date", DateUtil.today()); + mapParam.put("stor_code", "CP01"); + mapParam.put("stor_id", "1582991156504039424"); + mapParam.put("stor_name", "成品仓库"); + mapParam.put("is_task", "1"); + + // 查询移入货位 + JSONObject moveParam = new JSONObject(); + moveParam.put("box_no", json.getString("storagevehicle_code")); + moveParam.put("sect_id", RegionTypeEnum.ZZ01.getId()); + moveParam.put("layer_num", jsonAttr.getString("layer_num")); + JSONObject jsonMove = rawAssistIStorService.autoDisMove(moveParam); + // 查询移出货位的库存物料 + JSONObject jsonMoveIvt = WQL.getWO("ST_OUTIVT03") + .addParam("flag", "6") + .addParam("struct_id", json.getString("struct_id")) + .process().uniqueResult(0); + + // 移库单明细 + JSONObject jsonMoveDtl = new JSONObject(); + jsonMoveDtl.put("is_task", "2"); + jsonMoveDtl.put("turnout_sect_id", json.getLongValue("sect_id")); + jsonMoveDtl.put("turnout_sect_code", json.getString("sect_code")); + jsonMoveDtl.put("turnout_sect_name", json.getString("sect_name")); + jsonMoveDtl.put("turnout_struct_id", json.getLongValue("struct_id")); + jsonMoveDtl.put("turnout_struct_code", json.getString("struct_code")); + jsonMoveDtl.put("turnout_struct_name", json.getString("struct_name")); + jsonMoveDtl.put("material_id", jsonMoveIvt.getLongValue("material_id")); + jsonMoveDtl.put("pcsn", jsonMoveIvt.getString("pcsn")); + jsonMoveDtl.put("quality_scode", "01"); + jsonMoveDtl.put("qty_unit_id", jsonMoveIvt.getLongValue("qty_unit_id")); + jsonMoveDtl.put("qty_unit_name", jsonMoveIvt.getString("unit_name")); + jsonMoveDtl.put("qty", jsonMoveIvt.getDoubleValue("canuse_qty")); + jsonMoveDtl.put("storagevehicle_code", json.getString("storagevehicle_code")); + jsonMoveDtl.put("turnin_sect_id", jsonMove.getLongValue("sect_id")); + jsonMoveDtl.put("turnin_sect_code", jsonMove.getString("sect_code")); + jsonMoveDtl.put("turnin_sect_name", jsonMove.getString("sect_name")); + jsonMoveDtl.put("turnin_struct_id", jsonMove.getLongValue("struct_id")); + jsonMoveDtl.put("turnin_struct_code", jsonMove.getString("struct_code")); + jsonMoveDtl.put("turnin_struct_name", jsonMove.getString("struct_name")); + + // 生成任务 + JSONObject param2 = new JSONObject(); + param2.put("task_type", "010503"); + param2.put("vehicle_code", json.getString("storagevehicle_code")); + param2.put("point_code1", json.getString("struct_code")); + param2.put("point_code2", jsonMove.getString("struct_code")); + param2.put("task_group_id", whereJson.getLongValue("task_group_id")); // 任务组 + param2.put("sort_seq", i + 1); // 任务组顺序号 + String move_task_id = outTask.createTask(param2); + + // 回显移库明细任务id + jsonMoveDtl.put("task_id", move_task_id); + table.add(jsonMoveDtl); + // 更新任务处理类 + JSONObject jsonTaskMove = wo_Task.query("task_id = '" + move_task_id + "'").uniqueResult(0); + jsonTaskMove.put("task_type", "010505"); + jsonTaskMove.put("handle_class", HandMoveStorAcsTask.class.getName()); + jsonTaskMove.put("remark", "1层空托盘扩容移库"); + wo_Task.update(jsonTaskMove); + + mapParam.put("tableData", table); + // 调用移库单新增方法 + if (ObjectUtil.isNotEmpty(needMoveList)) { + insertDtl2(mapParam); + } + + handMoveStorAcsTask.immediateNotifyAcs(null); + } + } } diff --git a/lms/nladmin-system/src/main/java/org/nl/wms/st/outbill/service/impl/CheckOutBillServiceImpl.java b/lms/nladmin-system/src/main/java/org/nl/wms/st/outbill/service/impl/CheckOutBillServiceImpl.java index 7d31b2d3c..18bef91d5 100644 --- a/lms/nladmin-system/src/main/java/org/nl/wms/st/outbill/service/impl/CheckOutBillServiceImpl.java +++ b/lms/nladmin-system/src/main/java/org/nl/wms/st/outbill/service/impl/CheckOutBillServiceImpl.java @@ -35,6 +35,7 @@ import org.nl.wms.st.inbill.service.StorPublicService; import org.nl.wms.st.instor.service.HandMoveStorService; import org.nl.wms.st.instor.service.impl.HandMoveStorServiceImpl; import org.nl.wms.st.instor.task.HandMoveStorAcsTask; +import org.nl.wms.st.outbill.util.ThreadManage; import org.nl.wms.st.returns.service.InAndOutReturnService; import org.nl.wms.st.returns.service.impl.InAndOutRetrunServiceImpl; import org.nl.wms.util.TranUtil; @@ -397,6 +398,11 @@ public class CheckOutBillServiceImpl implements CheckOutBillService { @Override @Transactional(rollbackFor = Exception.class) public String insertDtl(JSONObject map) { + if(MapUtil.getStr(map,"bill_type").equals("1011")) { + String iostorinv_id = inserdtlPic(map); + return iostorinv_id ; + } + WQLObject ivtTab = WQLObject.getWQLObject("ST_IVT_StructIvt"); //明细另一种写法 JSONArray array = map.getJSONArray("tableData"); @@ -554,6 +560,116 @@ public class CheckOutBillServiceImpl implements CheckOutBillService { return iostorinv_id; } + /** + * 拣选出库新增 + * @param map 、 + * @return 单据标识 + */ + private String inserdtlPic(JSONObject map) { + + WQLObject ivtTab = WQLObject.getWQLObject("ST_IVT_StructIvt"); + //明细另一种写法 + JSONArray rows = map.getJSONArray("tableData"); + + map.remove("tableData"); + String currentUserId = SecurityUtils.getCurrentUserId(); + String nickName = SecurityUtils.getCurrentNickName(); + String user = map.getString("user"); + if (ObjectUtil.isNotEmpty(user)) { + if ("mes".equals(user)) { + currentUserId = "2"; + nickName = "mes用户"; + } + if ("sap".equals(user)) { + currentUserId = "3"; + nickName = "sap用户"; + } + } + String now = DateUtil.now(); + String iostorinv_id = IdUtil.getSnowflake(1, 1).nextId() + ""; + String bill_code = CodeUtil.getNewCode("IO_CODE"); + + JSONObject jsonStor = WQLObject.getWQLObject("st_ivt_bsrealstorattr").query("stor_id ='" + MapUtil.getStr(map, "stor_id") + "'").uniqueResult(0); + map.put("iostorinv_id", iostorinv_id); + map.put("bill_code", bill_code); + map.put("biz_date", map.getString("biz_date").substring(0, 10)); + String bill_type = (String) map.get("bill_type"); + map.put("buss_type", bill_type.substring(0, 4)); + map.put("io_type", "1"); + map.put("detail_count", rows.size() + ""); + map.put("create_mode", "01"); + map.put("stor_code", jsonStor.getString("stor_code")); + map.put("stor_name", jsonStor.getString("stor_name")); + map.put("input_optid", currentUserId + ""); + map.put("input_optname", nickName); + map.put("input_time", now); + map.put("update_optid", currentUserId + ""); + map.put("update_optname", nickName); + map.put("update_time", now); + map.put("is_delete", "0"); + map.put("is_upload", "0"); + map.put("out_stor_id", map.getString("out_stor_id")); + if (ObjectUtil.isNotEmpty(user)) { + if (!"mes".equals(user) || "sap".equals(user)) { + Long deptId = SecurityUtils.getDeptId(); + map.put("sysdeptid", deptId); + map.put("syscompanyid", deptId); + } + } + double qty = 0.0; // 主表重量 + int num = rows.size(); // 明细数 + for (int i = 0; i < rows.size(); i++) { + JSONObject row = rows.getJSONObject(i); + // 校验计划数量不能为零 + double plan_qty = row.getDoubleValue("plan_qty"); + if (Double.compare(plan_qty, 0.0) == 0) { + throw new BadRequestException("数量不能为0"); + } + JSONObject jsonDtl = new JSONObject(); + jsonDtl.put("iostorinvdtl_id", IdUtil.getSnowflake(1, 1).nextId() + ""); + jsonDtl.put("iostorinv_id", iostorinv_id); + jsonDtl.put("seq_no", (i + 1) + ""); + jsonDtl.put("material_id", row.getString("material_id")); + jsonDtl.put("pcsn", row.getString("pcsn")); + jsonDtl.put("box_no", row.getString("box_no")); + jsonDtl.put("quality_scode", "01"); + jsonDtl.put("bill_status", "10"); + jsonDtl.put("qty_unit_id", row.get("qty_unit_id")); + jsonDtl.put("qty_unit_name", row.getString("qty_unit_name")); + jsonDtl.put("plan_qty", row.get("plan_qty")); + jsonDtl.put("remark", row.getString("remark")); + jsonDtl.put("source_bill_code", row.getString("source_bill_code")); + jsonDtl.put("assign_qty", "0"); + jsonDtl.put("unassign_qty", row.get("plan_qty")); + jsonDtl.put("vbeln", row.getString("vbeln")); + jsonDtl.put("posnr", row.getString("posnr")); + WQLObject.getWQLObject("ST_IVT_IOStorInvDtl").insert(jsonDtl); + qty += jsonDtl.getDoubleValue("plan_qty"); + + // 判断此明细子卷是否存在,存在则将此木箱下的子卷全部生成明细 + String pcsn = row.getString("pcsn"); + String box_no = row.getString("box_no"); + //查询该箱子所在货位 + JSONObject struct_jo = WQLObject.getWQLObject("st_ivt_structattr").query("storagevehicle_code = '" + box_no + "'").uniqueResult(0); + if (ObjectUtil.isNotEmpty(pcsn)) { + if (ObjectUtil.isEmpty(struct_jo)) { + throw new BadRequestException("未查询到该批次所在货位!"); + } + String struct_code = struct_jo.getString("struct_code"); + JSONObject json = ivtTab.query("pcsn = '" + pcsn + "' AND struct_code = '" + struct_code + "'").uniqueResult(0); + if (ObjectUtil.isEmpty(json)) { + continue; + } + } + + } + map.put("total_qty", qty); + map.put("detail_count", num); + WQLObject.getWQLObject("ST_IVT_IOStorInv").insert(map); + + return iostorinv_id; + } + @Override @Transactional(rollbackFor = Exception.class) public String insertDtl2(JSONObject map) { @@ -1128,6 +1244,11 @@ public class CheckOutBillServiceImpl implements CheckOutBillService { @Override @Transactional(rollbackFor = Exception.class) public void update(JSONObject whereJson) { + + if (whereJson.getString("bill_type").equals("1011")) { + updatePic(whereJson); + return; + } String currentUserId = SecurityUtils.getCurrentUserId(); String nickName = SecurityUtils.getCurrentNickName(); @@ -1253,6 +1374,82 @@ public class CheckOutBillServiceImpl implements CheckOutBillService { } } + /** + * 分拣出库修改 + * @param whereJson、 + */ + private void updatePic(JSONObject whereJson) { + String currentUserId = SecurityUtils.getCurrentUserId(); + String nickName = SecurityUtils.getCurrentNickName(); + + String now = DateUtil.now(); + whereJson.put("update_optid", currentUserId + ""); + whereJson.put("update_optname", nickName); + whereJson.put("update_time", now); + + WQLObject wo = WQLObject.getWQLObject("ST_IVT_IOStorInv"); + WQLObject wo_dtl = WQLObject.getWQLObject("ST_IVT_IOStorInvDtl"); + WQLObject ivtTab = WQLObject.getWQLObject("ST_IVT_StructIvt"); + + wo.update(whereJson); + //先删除该单据下的所有明细 + String iostorinv_id = (String) whereJson.get("iostorinv_id"); + wo_dtl.delete("iostorinv_id = '" + iostorinv_id + "'"); + + JSONArray rows = whereJson.getJSONArray("tableData"); + + double qty = 0.0; // 主表重量 + int num = rows.size(); // 明细数 + for (int i = 0; i < rows.size(); i++) { + JSONObject row = rows.getJSONObject(i); + // 校验计划数量不能为零 + double plan_qty = row.getDoubleValue("plan_qty"); + if (Double.compare(plan_qty, 0) == 0) { + throw new BadRequestException("数量不能为0"); + } + + JSONObject jsonDtl = new JSONObject(); + jsonDtl.put("iostorinvdtl_id", IdUtil.getSnowflake(1, 1).nextId() + ""); + jsonDtl.put("iostorinv_id", iostorinv_id); + jsonDtl.put("seq_no", (i + 1) + ""); + jsonDtl.put("material_id", row.getString("material_id")); + jsonDtl.put("pcsn", row.getString("pcsn")); + jsonDtl.put("box_no", row.getString("box_no")); + jsonDtl.put("quality_scode", "01"); + jsonDtl.put("bill_status", "10"); + jsonDtl.put("qty_unit_id", row.get("qty_unit_id")); + jsonDtl.put("qty_unit_name", row.getString("qty_unit_name")); + jsonDtl.put("plan_qty", row.get("plan_qty")); + jsonDtl.put("remark", row.getString("remark")); + jsonDtl.put("source_bill_code", row.getString("source_bill_code")); + jsonDtl.put("assign_qty", "0"); + jsonDtl.put("unassign_qty", row.get("plan_qty")); + jsonDtl.put("vbeln", row.getString("vbeln")); + jsonDtl.put("posnr", row.getString("posnr")); + WQLObject.getWQLObject("ST_IVT_IOStorInvDtl").insert(jsonDtl); + qty += jsonDtl.getDoubleValue("plan_qty"); + + // 判断此明细子卷是否存在,存在则将此木箱下的子卷全部生成明细 + String pcsn = row.getString("pcsn"); + String box_no = row.getString("box_no"); + //查询该箱子所在货位 + JSONObject struct_jo = WQLObject.getWQLObject("st_ivt_structattr").query("storagevehicle_code = '" + box_no + "'").uniqueResult(0); + if (ObjectUtil.isNotEmpty(pcsn)) { + if (ObjectUtil.isEmpty(struct_jo)) { + throw new BadRequestException("未查询到该批次所在货位!"); + } + String struct_code = struct_jo.getString("struct_code"); + JSONObject json = ivtTab.query("pcsn = '" + pcsn + "' AND struct_code = '" + struct_code + "'").uniqueResult(0); + if (ObjectUtil.isEmpty(json)) { + continue; + } + } + whereJson.put("total_qty", qty); + whereJson.put("detail_count", num); + wo.update(whereJson); + } + } + @Override @Transactional(rollbackFor = Exception.class) public void allDiv(JSONObject whereJson) { @@ -1424,7 +1621,13 @@ public class CheckOutBillServiceImpl implements CheckOutBillService { throw new BadRequestException("库存不足"); } - double canuse_qty = jsonIvt.getDoubleValue("canuse_qty"); + double canuse_qty ; + if (StrUtil.equals(bill_type, "1011")) { + canuse_qty = dtl.getDoubleValue("plan_qty"); + } else { + canuse_qty = jsonIvt.getDoubleValue("canuse_qty"); + } + jsonIvt.put("change_qty", canuse_qty + ""); unassign_qty = 0; assign_qty = NumberUtil.add(assign_qty, canuse_qty); @@ -1513,6 +1716,289 @@ public class CheckOutBillServiceImpl implements CheckOutBillService { } } + @Override + @Transactional(rollbackFor = Exception.class) + public void allDiv2(JSONObject whereJson) { + //出库分配表 + WQLObject wo_dis = WQLObject.getWQLObject("ST_IVT_IOStorInvDis"); + //出库明细表 + WQLObject wo_dtl = WQLObject.getWQLObject("ST_IVT_IOStorInvDtl"); + //出库主表 + WQLObject wo_mst = WQLObject.getWQLObject("ST_IVT_IOStorInv"); + //库区表 + WQLObject wo_sect = WQLObject.getWQLObject("st_ivt_sectattr"); + + //定义需要更新的仓位集合 + HashMap Struct_map = new HashMap(); + String iostorinv_id = whereJson.getString("iostorinv_id"); + //查询主表信息 + JSONObject jo_mst = wo_mst.query("iostorinv_id = '" + iostorinv_id + "'").uniqueResult(0); + if (ObjectUtil.isEmpty(jo_mst)) { + throw new BadRequestException("查不到出库单信息"); + } + + // 如果是发货出库则判断运费和物流公司不能为空 + String bill_type = jo_mst.getString("bill_type"); + if (StrUtil.equals(bill_type, "1001")) { + String trans_code = jo_mst.getString("trans_code"); + String estimated_freight = jo_mst.getString("estimated_freight"); + + if (ObjectUtil.isEmpty(trans_code)) { + throw new BadRequestException("物流公司不能为空"); + } + if (ObjectUtil.isEmpty(estimated_freight)) { + throw new BadRequestException("预估运费不能为空"); + } + + } + + //查询生成和未分配完的明细 + JSONArray dtls = WQL.getWO("QST_IVT_CHECKOUTBILL") + .addParam("flag", "2") + .addParam("bill_status", "30") + .addParam("unassign_flag", "1") + .addParam("iostorinv_id", iostorinv_id) + .addParam("iostorinvdtl_id", whereJson.getString("iostorinvdtl_id")) + .process() + .getResultJSONArray(0); + if (ObjectUtil.isEmpty(dtls)) { + throw new BadRequestException("当前订单无可分配出库明细"); + } + + for (int i = 0; i < dtls.size(); i++) { + JSONObject dtl = dtls.getJSONObject(i); + double unassign_qty = dtl.getDoubleValue("unassign_qty"); + /* + * 分配规则: + * top1.有销售订单号:用销售订单号、物料去找这批物料最早入库的所在的巷道 + * top2.没有销售订单号,有子卷号:固定出某个木箱 + * top3.没有销售订单号,没有子卷号:找此物料最早入库的所在巷道 + */ + boolean is_top3 = false; + if (ObjectUtil.isEmpty(dtl.getString("source_bill_code")) && ObjectUtil.isEmpty(dtl.getString("pcsn"))) { + is_top3 = true; + } + JSONObject jsonMap = new JSONObject(); + // 已分配重量 + double assign_qty = dtl.getDoubleValue("assign_qty"); + + // 需要更新库存的集合 + List updateIvtList = new ArrayList<>(); + // 需要插入分配明细的集合 + List instDisList = new ArrayList<>(); + + if (ObjectUtil.isNotEmpty(dtl.getString("source_bill_code")) || is_top3) { + while (unassign_qty > 0) { + // 1.有销售订单号 + jsonMap.put("flag", "1"); + jsonMap.put("material_id", dtl.getString("material_id")); + jsonMap.put("sale_order_name", dtl.getString("source_bill_code")); + jsonMap.put("sect_id", whereJson.getString("sect_id")); + jsonMap.put("stor_id", whereJson.getString("stor_id")); + + JSONObject jsonOneIvt = WQL.getWO("ST_OUTIVT01").addParamMap(jsonMap).process().uniqueResult(0); + if (ObjectUtil.isEmpty(jsonOneIvt)) { + throw new BadRequestException("库存不足"); + } + + // 查询这一巷道所有此物料此库存此销售订单的库存 + jsonMap.put("flag", "2"); + jsonMap.put("row_num", jsonOneIvt.getString("row_num")); + jsonMap.put("block_num", jsonOneIvt.getString("block_num")); + JSONArray ivtAllArr = WQL.getWO("ST_OUTIVT01").addParamMap(jsonMap).process().getResultJSONArray(0); + + for (int j = 0; j < ivtAllArr.size(); j++) { + JSONObject ivt = ivtAllArr.getJSONObject(j); + double canuse_qty = ivt.getDoubleValue("canuse_qty"); + assign_qty = NumberUtil.add(assign_qty, canuse_qty); + + if (unassign_qty >= canuse_qty) { + unassign_qty = NumberUtil.sub(unassign_qty, canuse_qty); + } else { + unassign_qty = 0; + } + + // 查询此木箱下的所有子卷 + jsonMap.put("flag", "3"); + jsonMap.put("storagevehicle_code", ivt.getString("storagevehicle_code")); + JSONArray ivtAllArr2 = WQL.getWO("ST_OUTIVT01").addParamMap(jsonMap).process().getResultJSONArray(0); + + for (int k = 0; k < ivtAllArr2.size(); k++) { + // 更新库存 + JSONObject ivt2 = ivtAllArr2.getJSONObject(k); + ivt2.put("change_qty", ivt2.getDoubleValue("canuse_qty")); + ivt2.put("bill_type_scode", jo_mst.getString("bill_type")); + ivt2.put("inv_id", dtl.getString("iostorinv_id")); + ivt2.put("bill_code", jo_mst.getString("bill_code")); + ivt2.put("bill_table", "ST_IVT_IOStorInv"); + // 放在更新库存的集合当中 + updateIvtList.add(ivt2); + // storPublicService.IOStor(ivt2, "11"); + + + //生成分配明细 + dtl.put("iostorinvdis_id", IdUtil.getSnowflake(1, 1).nextId()); + dtl.put("sect_id", ivt2.getString("sect_id")); + dtl.put("sect_code", ivt2.getString("sect_code")); + dtl.put("sect_name", ivt2.getString("sect_name")); + dtl.put("struct_id", ivt2.getString("struct_id")); + dtl.put("struct_code", ivt2.getString("struct_code")); + dtl.put("struct_name", ivt2.getString("struct_name")); + dtl.put("pcsn", ivt2.getString("pcsn")); + dtl.put("box_no", ivt2.getString("storagevehicle_code")); + dtl.put("storagevehicle_id", ivt2.getString("storagevehicle_id")); + dtl.put("storagevehicle_code", ivt2.getString("storagevehicle_code")); + dtl.put("storagevehicle_type", ivt2.getString("storagevehicle_type")); + dtl.put("is_issued", "0"); + dtl.put("plan_qty", ivt2.getDoubleValue("change_qty")); + dtl.put("real_qty", ivt2.getDoubleValue("change_qty")); + dtl.put("is_overdue", ivt2.getString("is_overdue")); + dtl.put("instorage_time", ivt2.getString("instorage_time")); + + // 如果所属仓位是虚拟区 则将分配明细状态变为生成 + JSONObject jsonSect = wo_sect.query("sect_id = '" + ivt2.getString("sect_id") + "'").uniqueResult(0); + if (StrUtil.equals(jsonSect.getString("sect_type_attr"), "09")) { + dtl.put("work_status", "01"); + } else { + dtl.put("work_status", "00"); + } + + if (jo_mst.getString("is_overdue").equals("1")) { + // 判断是否超期 + if (ivt2.getString("is_overdue").equals("1")) { + dtl.put("work_status", "01"); + } + } + // 放在插入分配明细的集合当中 + instDisList.add(dtl); + // wo_dis.insert(dtl); + } + //记录需锁定的仓位 + Struct_map.put(ivt.getString("struct_id"), ivt); + // 为零结束 + if (unassign_qty == 0) { + break; + } + } + } + + } else { + // 确定子卷: 根据子卷找到库存出掉 + jsonMap.put("flag", "1"); + jsonMap.put("material_id", dtl.getString("material_id")); + jsonMap.put("pcsn", dtl.getString("pcsn")); + jsonMap.put("box_no", dtl.getString("box_no")); + jsonMap.put("sect_id", whereJson.getString("sect_id")); + jsonMap.put("stor_id", whereJson.getString("stor_id")); + + JSONObject jsonIvt = WQL.getWO("ST_OUTIVT01").addParamMap(jsonMap).process().uniqueResult(0); + if (ObjectUtil.isEmpty(jsonIvt)) { + throw new BadRequestException("库存不足"); + } + + double canuse_qty = jsonIvt.getDoubleValue("canuse_qty"); + jsonIvt.put("change_qty", canuse_qty + ""); + unassign_qty = 0; + assign_qty = NumberUtil.add(assign_qty, canuse_qty); + + //更新库存 + jsonIvt.put("bill_type_scode", jo_mst.getString("bill_type")); + jsonIvt.put("inv_id", dtl.getString("iostorinv_id")); + jsonIvt.put("bill_code", jo_mst.getString("bill_code")); + jsonIvt.put("bill_table", "ST_IVT_IOStorInv"); + // 放入需要更新库存的集合当中 + updateIvtList.add(jsonIvt); + // storPublicService.IOStor(jsonIvt, "11"); + + //生成分配明细 + dtl.put("iostorinvdis_id", IdUtil.getSnowflake(1, 1).nextId()); + dtl.put("sect_id", jsonIvt.getString("sect_id")); + dtl.put("sect_code", jsonIvt.getString("sect_code")); + dtl.put("sect_name", jsonIvt.getString("sect_name")); + dtl.put("struct_id", jsonIvt.getString("struct_id")); + dtl.put("struct_code", jsonIvt.getString("struct_code")); + dtl.put("struct_name", jsonIvt.getString("struct_name")); + dtl.put("pcsn", jsonIvt.getString("pcsn")); + dtl.put("box_no", jsonIvt.getString("storagevehicle_code")); + dtl.put("storagevehicle_id", jsonIvt.getString("storagevehicle_id")); + dtl.put("storagevehicle_code", jsonIvt.getString("storagevehicle_code")); + dtl.put("storagevehicle_type", jsonIvt.getString("storagevehicle_type")); + dtl.put("is_issued", "0"); + dtl.put("plan_qty", jsonIvt.getDoubleValue("change_qty")); + dtl.put("real_qty", jsonIvt.getDoubleValue("change_qty")); + dtl.put("is_overdue", jsonIvt.getString("is_overdue")); + dtl.put("instorage_time", jsonIvt.getString("instorage_time")); + // 如果所属仓位是虚拟区 则将分配明细状态变为生成 + JSONObject jsonSect = wo_sect.query("sect_id = '" + jsonIvt.getString("sect_id") + "'").uniqueResult(0); + if (StrUtil.equals(jsonSect.getString("sect_type_attr"), "09")) { + dtl.put("work_status", "01"); + } else { + dtl.put("work_status", "00"); + } + + // 判断是否超期 + if (jo_mst.getString("is_overdue").equals("1")) { + if (jsonIvt.getString("is_overdue").equals("1")) { + dtl.put("work_status", "01"); + } + } + + // 放入需要插入分配明细的集合当中 + instDisList.add(dtl); + // wo_dis.insert(dtl); + + //记录需锁定的仓位 (如果此明细有相同物料的且子卷号不能为空的则在最后一个明细分配完成后锁定仓位) + JSONObject map = new JSONObject(); + map.put("flag", "5"); + map.put("material_id", dtl.getString("material_id")); + map.put("box_no", dtl.getString("box_no")); + map.put("iostorinv_id", iostorinv_id); + map.put("iostorinvdtl_id", dtl.getString("iostorinvdtl_id")); + JSONArray dtlArr = WQL.getWO("ST_OUTIVT01").addParamMap(map).process().getResultJSONArray(0); + if (dtlArr.size() == 0) { + Struct_map.put(jsonIvt.getString("struct_id"), jsonIvt); + } + + } + HashMap map_dtl = new HashMap(); + //更新明细 + map_dtl.put("unassign_qty", unassign_qty + ""); + map_dtl.put("assign_qty", assign_qty + ""); + if (unassign_qty == 0) { + map_dtl.put("bill_status", "40"); + } else { + map_dtl.put("bill_status", "30"); + } + wo_dtl.update(map_dtl, "iostorinvdtl_id='" + dtl.getString("iostorinvdtl_id") + "'"); + + //更新主表状态 + this.updateMststatus(iostorinv_id); + + // 开启线程池 + JSONObject param = new JSONObject(); + param.put("updateIvtList", updateIvtList); + param.put("instDisList", instDisList); + param.put("struct_map", Struct_map); + + ThreadManage bean = SpringContextHolder.getBean(ThreadManage.class); + bean.startThread(param); + + /* //锁定起点点位、仓位 + Collection c = Struct_map.values(); + Iterator it = c.iterator(); + JSONObject from_start = new JSONObject(); + from_start.put("lock_type", "3"); + for (; it.hasNext(); ) { + JSONObject Struct = it.next(); + from_start.put("struct_id", Struct.getString("struct_id")); + from_start.put("inv_type", jo_mst.getString("bill_type")); + from_start.put("inv_id", jo_mst.getString("iostorinv_id")); + from_start.put("inv_code", jo_mst.getString("bill_code")); + storPublicService.updateStructAndPoint(from_start); + }*/ + } + } + @Override @Transactional(rollbackFor = Exception.class) public void allDivOne(JSONObject whereJson) { @@ -2671,7 +3157,7 @@ public class CheckOutBillServiceImpl implements CheckOutBillService { for (int k = 0; k < numArr.size(); k++) { JSONObject json = numArr.getJSONObject(k); - error += json.getString("struct_code") + ","; + error += json.getString("struct_code") + ", 锁定单据号:"+json.getString("inv_code"); } throw new BadRequestException("仓位:" + error + "被锁定且未下发任务,无法生成任务!"); @@ -2705,7 +3191,7 @@ public class CheckOutBillServiceImpl implements CheckOutBillService { for (int k = 0; k < numArr.size(); k++) { JSONObject json = numArr.getJSONObject(k); - error += json.getString("struct_code") + ","; + error += json.getString("struct_code") + ", 锁定单据号:"+json.getString("inv_code"); } throw new BadRequestException("仓位:" + error + "被锁定且未下发任务,无法生成任务!"); @@ -2739,7 +3225,7 @@ public class CheckOutBillServiceImpl implements CheckOutBillService { for (int k = 0; k < numArr.size(); k++) { JSONObject json = numArr.getJSONObject(k); - error += json.getString("struct_code") + ","; + error += json.getString("struct_code") + ", 锁定单据号:"+json.getString("inv_code"); } throw new BadRequestException("仓位:" + error + "被锁定且未下发任务,无法生成任务!"); @@ -2776,7 +3262,7 @@ public class CheckOutBillServiceImpl implements CheckOutBillService { for (int k = 0; k < numArr.size(); k++) { JSONObject json = numArr.getJSONObject(k); - error += json.getString("struct_code") + ","; + error += json.getString("struct_code") + ", 锁定单据号:"+json.getString("inv_code"); } throw new BadRequestException("仓位:" + error + "被锁定请等待下发任务并等待任务完成"); @@ -2810,7 +3296,7 @@ public class CheckOutBillServiceImpl implements CheckOutBillService { for (int k = 0; k < numArr.size(); k++) { JSONObject json = numArr.getJSONObject(k); - error += json.getString("struct_code") + ","; + error += json.getString("struct_code") + ", 锁定单据号:"+json.getString("inv_code"); } throw new BadRequestException("仓位:" + error + "被锁定请等待下发任务并等待任务完成"); @@ -3131,7 +3617,7 @@ public class CheckOutBillServiceImpl implements CheckOutBillService { for (int k = 0; k < numArr.size(); k++) { JSONObject json = numArr.getJSONObject(k); - error += json.getString("struct_code") + ","; + error += json.getString("struct_code") + ", 锁定单据号:"+json.getString("inv_code"); } throw new BadRequestException("仓位:" + error + "被锁定且未下发任务,无法生成任务!"); @@ -3163,7 +3649,7 @@ public class CheckOutBillServiceImpl implements CheckOutBillService { for (int k = 0; k < numArr.size(); k++) { JSONObject json = numArr.getJSONObject(k); - error += json.getString("struct_code") + ","; + error += json.getString("struct_code") + ", 锁定单据号:"+json.getString("inv_code"); } throw new BadRequestException("仓位:" + error + "被锁定且未下发任务,无法生成任务!"); @@ -3195,7 +3681,7 @@ public class CheckOutBillServiceImpl implements CheckOutBillService { for (int k = 0; k < numArr.size(); k++) { JSONObject json = numArr.getJSONObject(k); - error += json.getString("struct_code") + ","; + error += json.getString("struct_code") + ", 锁定单据号:"+json.getString("inv_code"); } throw new BadRequestException("仓位:" + error + "被锁定且未下发任务,无法生成任务!"); @@ -3229,7 +3715,7 @@ public class CheckOutBillServiceImpl implements CheckOutBillService { for (int k = 0; k < numArr.size(); k++) { JSONObject json = numArr.getJSONObject(k); - error += json.getString("struct_code") + ","; + error += json.getString("struct_code") + ", 锁定单据号:"+json.getString("inv_code"); } throw new BadRequestException("仓位:" + error + "被锁定请等待下发任务并等待任务完成"); @@ -3260,7 +3746,7 @@ public class CheckOutBillServiceImpl implements CheckOutBillService { for (int k = 0; k < numArr.size(); k++) { JSONObject json = numArr.getJSONObject(k); - error += json.getString("struct_code") + ","; + error += json.getString("struct_code") + ", 锁定单据号:"+json.getString("inv_code"); } throw new BadRequestException("仓位:" + error + "被锁定请等待下发任务并等待任务完成!"); @@ -4118,23 +4604,6 @@ public class CheckOutBillServiceImpl implements CheckOutBillService { storPublicService.IOStor(dis, "21"); } } - //解锁起点 - JSONObject from_start = new JSONObject(); - from_start.put("struct_id", dis.getString("struct_id")); - from_start.put("lock_type", "1"); - from_start.put("is_overdue", dis.getString("is_overdue")); - - if (jo_mst.getString("is_overdue").equals("1")) { - if (dis.getString("is_overdue").equals("1")) { - from_start.put("storagevehicle_code", dis.getString("box_no")); - } else { - from_start.put("storagevehicle_code", ""); - } - } else { - from_start.put("storagevehicle_code", ""); - } - - storPublicService.updateStructAndPoint(from_start); // 更新分配明细执行状态为 - 99 JSONObject jsonDis = wo_dis.query("iostorinvdis_id = '" + dis.getString("iostorinvdis_id") + "'").uniqueResult(0); @@ -4166,8 +4635,55 @@ public class CheckOutBillServiceImpl implements CheckOutBillService { } else { jsonSub.put("status", "3"); } + + if (jo_mst.getString("bill_type").equals("1011")) { + // 更新子卷包装净重 + double net_weight = NumberUtil.sub(jsonSub.getDoubleValue("net_weight"), plan_qty); + jsonSub.put("net_weight",net_weight); + + if (net_weight <= 0) { + jsonSub.put("status","3"); + } else { + jsonSub.put("status","2"); + } + } + subTab.update(jsonSub); + // 解锁起点 + JSONObject from_start = new JSONObject(); + from_start.put("struct_id", dis.getString("struct_id")); + from_start.put("lock_type", "1"); + from_start.put("is_overdue", dis.getString("is_overdue")); + + if (jo_mst.getString("is_overdue").equals("1")) { + if (dis.getString("is_overdue").equals("1")) { + from_start.put("storagevehicle_code", dis.getString("box_no")); + } else { + from_start.put("storagevehicle_code", ""); + } + } else { + from_start.put("storagevehicle_code", ""); + } + + if (jo_mst.getString("bill_type").equals("1011")) { + // 判断此木箱下的所有子卷净重是否为0,如果为0则清空载具 + List packageList = subTab.query("package_box_sn = '" + jsonSub.getString("package_box_sn") + "'") + .getResultJSONArray(0).toJavaList(JSONObject.class); + + boolean is_zero = packageList.stream() + .allMatch(row -> row.getDoubleValue("net_weight") <= 0); + + if (is_zero) { + from_start.put("storagevehicle_code", ""); + } else { + from_start.put("bill_type","1011"); + from_start.put("storagevehicle_code", jsonSub.getString("package_box_sn")); + } + } + + storPublicService.updateStructAndPoint(from_start); + //插入包装关系出入库记录表 jsonSub.put("bill_code", jo_mst.getString("bill_code")); jsonSub.put("bill_id", jo_mst.getString("iostorinv_id")); diff --git a/lms/nladmin-system/src/main/java/org/nl/wms/st/outbill/util/TaskInsertDisManage.java b/lms/nladmin-system/src/main/java/org/nl/wms/st/outbill/util/TaskInsertDisManage.java new file mode 100644 index 000000000..39a15c649 --- /dev/null +++ b/lms/nladmin-system/src/main/java/org/nl/wms/st/outbill/util/TaskInsertDisManage.java @@ -0,0 +1,34 @@ +package org.nl.wms.st.outbill.util; + +import com.alibaba.fastjson.JSONObject; +import org.nl.modules.wql.core.bean.WQLObject; +import org.nl.wms.st.inbill.service.StorPublicService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import java.util.List; + +@Component +public class TaskInsertDisManage implements Runnable { + + List disList ; + + public TaskInsertDisManage(List a) { + disList = a; + } + + @Override + public void run() { + + WQLObject disTab = WQLObject.getWQLObject("st_ivt_iostorinvdis"); + + // 业务处理: 更新库存 + for (int i = 0; i < disList.size(); i++) { + JSONObject json = disList.get(i); + + disTab.insert(json); + + } + + } +} diff --git a/lms/nladmin-system/src/main/java/org/nl/wms/st/outbill/util/TaskUpdateIvtManage.java b/lms/nladmin-system/src/main/java/org/nl/wms/st/outbill/util/TaskUpdateIvtManage.java new file mode 100644 index 000000000..cf15ac6c2 --- /dev/null +++ b/lms/nladmin-system/src/main/java/org/nl/wms/st/outbill/util/TaskUpdateIvtManage.java @@ -0,0 +1,33 @@ +package org.nl.wms.st.outbill.util; + +import com.alibaba.fastjson.JSONObject; +import org.nl.modules.wql.util.SpringContextHolder; +import org.nl.wms.st.inbill.service.impl.StorPublicServiceImpl; +import org.springframework.stereotype.Component; + +import java.util.List; + +@Component +public class TaskUpdateIvtManage implements Runnable { + + List ivtList ; + + public TaskUpdateIvtManage(List a) { + ivtList = a; + } + + @Override + public void run() { + + StorPublicServiceImpl bean = SpringContextHolder.getBean(StorPublicServiceImpl.class); + + // 业务处理: 更新库存 + for (int i = 0; i < ivtList.size(); i++) { + JSONObject json = ivtList.get(i); + + bean.IOStor(json,"11"); + + } + + } +} diff --git a/lms/nladmin-system/src/main/java/org/nl/wms/st/outbill/util/ThreadManage.java b/lms/nladmin-system/src/main/java/org/nl/wms/st/outbill/util/ThreadManage.java new file mode 100644 index 000000000..7407b2540 --- /dev/null +++ b/lms/nladmin-system/src/main/java/org/nl/wms/st/outbill/util/ThreadManage.java @@ -0,0 +1,147 @@ +package org.nl.wms.st.outbill.util; + +import cn.hutool.core.util.NumberUtil; +import com.alibaba.fastjson.JSONObject; +import org.nl.modules.wql.util.SpringContextHolder; +import org.nl.wms.st.inbill.service.impl.StorPublicServiceImpl; +import org.springframework.stereotype.Component; +import org.springframework.transaction.annotation.Transactional; + +import java.util.Collection; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; + +@Component +public class ThreadManage { + + /** + * 开启线程池 + * @param whereJson:{ + * updateIvtList : 需更新的库存集合 + * instDisList : 需插入的分配明细集合 + * struct_map : 需更新的仓位map + * } + */ + @Transactional + public void startThread(JSONObject whereJson) { + // 需要更新的库存集合 + List updateIvtList = whereJson.getJSONArray("updateIvtList").toJavaList(JSONObject.class); + // 需要插入的分配明细集合 + List instDisList = whereJson.getJSONArray("instDisList").toJavaList(JSONObject.class); + // 需更新的仓位map + JSONObject struct_map = whereJson.getJSONObject("struct_map"); + + // 调用库存处理 + updateIvtManage(updateIvtList); + + // 调用插入分配明细处理 + insertDisManage(instDisList); + + // 调用更新仓位处理 + updateAttrManage(struct_map); + + } + + /** + * 更新库存 + * @param updateIvtList:库存集合 + */ + private void updateIvtManage(List updateIvtList) { + + // 1个线程分配10个数据 + int ceil = (int) Math.ceil(NumberUtil.div(updateIvtList.size(), 10)); + + // 创建线程池 + ExecutorService executorService = Executors.newFixedThreadPool(ceil); + + for (int i = 0; i < ceil; i++) { + + List list ; + + // 分割集合 + if (i + 1 == ceil) { + list = updateIvtList.subList( i * 10, updateIvtList.size()); + } else { + list = updateIvtList.subList( i * 10, (i + 1) * 10); + + } + + // 提交任务 + executorService.submit(new TaskUpdateIvtManage(list)); + + } + + // 关闭线程 - 但不会立刻关闭 + executorService.shutdown(); + + } + + /** + * 插入分配明细 + * @param instDisList:分配明细集合 + */ + private void insertDisManage(List instDisList) { + + // 1个线程分配10个数据 + int ceil = (int) Math.ceil(NumberUtil.div(instDisList.size(), 10)); + + // 创建线程池 + ExecutorService executorService = Executors.newFixedThreadPool(ceil); + + for (int i = 0; i < ceil; i++) { + + List list ; + + // 分割集合 + if (i + 1 == ceil) { + list = instDisList.subList( i * 10, instDisList.size()); + } else { + list = instDisList.subList( i * 10, (i + 1) * 10); + + } + + // 提交任务 + executorService.submit(new TaskInsertDisManage(list)); + + } + + // 关闭线程 - 但不会立刻关闭 + executorService.shutdown(); + } + + + /** + * 更新仓位 + * @param Struct_map + */ + private void updateAttrManage(JSONObject Struct_map) { + + // 创建线程池 + ExecutorService executorService = Executors.newFixedThreadPool(10); + + // 业务处理 + StorPublicServiceImpl bean = SpringContextHolder.getBean(StorPublicServiceImpl.class); + + executorService.submit(() -> { + Collection c = Struct_map.values(); + Iterator it = c.iterator(); + JSONObject from_start = new JSONObject(); + from_start.put("lock_type", "3"); + for (; it.hasNext(); ) { + JSONObject Struct = (JSONObject) it.next(); + from_start.put("struct_id", Struct.getString("struct_id")); + from_start.put("inv_type", "1111"); + from_start.put("inv_id", "2222"); + from_start.put("inv_code", "3333"); + bean.updateStructAndPoint(from_start); + } + }); + + // 关闭线程 - 但不会立刻关闭 + executorService.shutdown(); + } + +} diff --git a/lms/nladmin-system/src/main/java/org/nl/wms/st/outbill/wql/QST_IVT_CHECKOUTBILL.wql b/lms/nladmin-system/src/main/java/org/nl/wms/st/outbill/wql/QST_IVT_CHECKOUTBILL.wql index 7a3c9cb0f..def387727 100644 --- a/lms/nladmin-system/src/main/java/org/nl/wms/st/outbill/wql/QST_IVT_CHECKOUTBILL.wql +++ b/lms/nladmin-system/src/main/java/org/nl/wms/st/outbill/wql/QST_IVT_CHECKOUTBILL.wql @@ -1196,7 +1196,7 @@ AND task_status IN ('07') AND is_delete = '0' AND task_type = '010503' - AND DATEDIFF( NOW(), LEFT(update_time,10) ) <= 2 + AND TIMESTAMPDIFF(HOUR,update_time,NOW()) <= 3 ENDSELECT ENDQUERY diff --git a/lms/nladmin-ui/src/views/system/notice/NoticeIcon.vue b/lms/nladmin-ui/src/views/system/notice/NoticeIcon.vue index 4ae56e9ee..4d5037190 100644 --- a/lms/nladmin-ui/src/views/system/notice/NoticeIcon.vue +++ b/lms/nladmin-ui/src/views/system/notice/NoticeIcon.vue @@ -1,21 +1,22 @@