From 263a3a9f01f5b4264f2e56588092b64e2feb00cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=83=91=E6=97=AD=E6=98=8E=5C73939?= <739390650@QQ.COM> Date: Thu, 7 May 2026 17:45:52 +0800 Subject: [PATCH] =?UTF-8?q?opt:=E4=B8=AD=E9=BC=8E842=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../server/impl/WmsZDToAcsServiceImpl.java | 15 +- .../service/impl/DeviceServiceImpl.java | 5 +- .../agv/ndctwo/AgvNdcTwoDeviceDriver.java | 267 +++++++++++------- .../hongxiang_conveyor/CodeParserUtil.java | 2 +- .../service/impl/InstructionServiceImpl.java | 74 +---- .../task/service/impl/TaskServiceImpl.java | 138 +-------- 6 files changed, 170 insertions(+), 331 deletions(-) diff --git a/nlsso-server/src/main/java/org/nl/acs/agv/server/impl/WmsZDToAcsServiceImpl.java b/nlsso-server/src/main/java/org/nl/acs/agv/server/impl/WmsZDToAcsServiceImpl.java index db48d76..cf041c3 100644 --- a/nlsso-server/src/main/java/org/nl/acs/agv/server/impl/WmsZDToAcsServiceImpl.java +++ b/nlsso-server/src/main/java/org/nl/acs/agv/server/impl/WmsZDToAcsServiceImpl.java @@ -68,19 +68,8 @@ public class WmsZDToAcsServiceImpl implements WmsZDToAcsService { return map; } - if (start_point_code.indexOf("-") > 0) { - String str[] = start_point_code.split("-"); - start_device_code = str[0]; - } else { - start_device_code = start_point_code; - } - - if (next_point_code.indexOf("-") > 0) { - String str[] = next_point_code.split("-"); - next_device_code = str[0]; - } else { - next_device_code = next_point_code; - } + start_device_code = start_point_code; + next_device_code = next_point_code; //查询wcs传过来的起点终点路由 List list = routeLineService.getShortPathLines(start_device_code, next_device_code, "normal"); diff --git a/nlsso-server/src/main/java/org/nl/acs/device/service/impl/DeviceServiceImpl.java b/nlsso-server/src/main/java/org/nl/acs/device/service/impl/DeviceServiceImpl.java index 9fc61f9..f1b357b 100644 --- a/nlsso-server/src/main/java/org/nl/acs/device/service/impl/DeviceServiceImpl.java +++ b/nlsso-server/src/main/java/org/nl/acs/device/service/impl/DeviceServiceImpl.java @@ -895,10 +895,7 @@ public class DeviceServiceImpl extends CommonServiceImpl i @Override public void changeDeviceStatus(JSONObject form) { String device_code = form.getString("device_code"); - if (StrUtil.contains(device_code, "-") && StrUtil.count(device_code, "-") == 2) { - String[] point = device_code.split("-"); - device_code = point[0]; - } + //需要数量 String hasGoodStatus = form.getString("hasGoodStatus"); if (StrUtil.isEmpty(hasGoodStatus)) { diff --git a/nlsso-server/src/main/java/org/nl/acs/device_driver/agv/ndctwo/AgvNdcTwoDeviceDriver.java b/nlsso-server/src/main/java/org/nl/acs/device_driver/agv/ndctwo/AgvNdcTwoDeviceDriver.java index fae45a1..2dc3a92 100644 --- a/nlsso-server/src/main/java/org/nl/acs/device_driver/agv/ndctwo/AgvNdcTwoDeviceDriver.java +++ b/nlsso-server/src/main/java/org/nl/acs/device_driver/agv/ndctwo/AgvNdcTwoDeviceDriver.java @@ -117,7 +117,7 @@ public class AgvNdcTwoDeviceDriver extends AbstractDeviceDriver implements Devic public synchronized void processSocket(int[] arr) throws Exception { device_code = this.getDeviceCode(); - + // 方法入口日志:记录接收到的原始数据 LuceneLogDto entryLog = LuceneLogDto.builder() .device_code(device_code) @@ -125,7 +125,7 @@ public class AgvNdcTwoDeviceDriver extends AbstractDeviceDriver implements Devic .build(); entryLog.setLog_level(4); luceneExecuteLogService.deviceExecuteLog(entryLog); - + byte[] data = null; phase = arr[16] * 256 + arr[17]; // agv任务号 @@ -138,7 +138,7 @@ public class AgvNdcTwoDeviceDriver extends AbstractDeviceDriver implements Devic agvaddr = arr[18] * 256 + arr[19]; //车号 int carno = arr[20]; - + // 记录关键参数 LuceneLogDto paramLog = LuceneLogDto.builder() .device_code(device_code) @@ -146,7 +146,7 @@ public class AgvNdcTwoDeviceDriver extends AbstractDeviceDriver implements Devic .build(); paramLog.setLog_level(4); luceneExecuteLogService.deviceExecuteLog(paramLog); - + Instruction inst = null; Device agv_device = null; if (carno != 0) { @@ -252,12 +252,20 @@ public class AgvNdcTwoDeviceDriver extends AbstractDeviceDriver implements Devic } HongXiangLocationInfo hongXiangLocationInfo = CodeParserUtil.parseCode(device_code); - if(null != hongXiangLocationInfo){ + if(null != hongXiangLocationInfo ){ + log.info("【设备编码解析】满足三段式格式,device_code={},解析结果:{}", + device_code, hongXiangLocationInfo); device = deviceAppService.findDeviceByCode("hongxiang"); } else { + log.info("【设备编码解析】不满足三段式格式,走默认查询,device_code={}", device_code); device = deviceAppService.findDeviceByCode(device_code); } + // 必须判空,防止空指针 + if (device == null) { + log.error("【设备查询失败】未查询到设备信息,当前device_code={}", device_code); + return; + } if (ObjectUtil.isEmpty(device_code)) { log.info(agvaddr + "对应设备号为空!"); LuceneLogDto logDto = LuceneLogDto.builder() @@ -294,19 +302,19 @@ public class AgvNdcTwoDeviceDriver extends AbstractDeviceDriver implements Devic String responseBody = httpResponse2.body(); JSONObject responseJson = JSONObject.parseObject(responseBody); int responseCode = responseJson.getIntValue("responseCode"); - + LuceneLogDto logDto2 = LuceneLogDto.builder() .device_code(device_code) .content("申请取货返回参数:" + responseBody) .build(); logDto2.setLog_level(4); luceneExecuteLogService.deviceExecuteLog(logDto2); - + // 判断 responseCode 是否为 0,非 0 则返回 if (responseCode != 0) { LuceneLogDto errorLog = LuceneLogDto.builder() .device_code(device_code) - .content("WCS反馈失败, responseCode:" + responseCode + .content("WCS反馈失败, responseCode:" + responseCode + ", responseMessage:" + responseJson.getString("responseMessage")) .build(); errorLog.setLog_level(2); @@ -367,35 +375,37 @@ public class AgvNdcTwoDeviceDriver extends AbstractDeviceDriver implements Devic //烘箱 //到达取货点 else if (device.getDeviceDriver() instanceof HongXiangStationDeviceDriver) { hongXiangStationDeviceDriver = (HongXiangStationDeviceDriver) device.getDeviceDriver(); - + // 烘箱交互日志:开始处理烘箱取货 LuceneLogDto ovenLog = LuceneLogDto.builder() .device_code(device_code) - .content("[烘箱交互] 到达取货点, ovenNo:" + hongXiangLocationInfo.getOvenNo() - + ", shutterDoor:" + hongXiangLocationInfo.getShutterDoor() + .content("[烘箱交互] 到达取货点, ovenNo:" + hongXiangLocationInfo.getOvenNo() + + ", shutterDoor:" + hongXiangLocationInfo.getShutterDoor() + ", storageNo:" + hongXiangLocationInfo.getStorageNo()) .build(); ovenLog.setLog_level(4); luceneExecuteLogService.deviceExecuteLog(ovenLog); + if (hongxiangError(device_code, hongXiangStationDeviceDriver, hongXiangLocationInfo)) return; + //判断对应点位是卷帘门是否开门到位 int door_open = (int) hongXiangStationDeviceDriver.getPropertyValue("item_oven" + hongXiangLocationInfo.getOvenNo() + "_door" + hongXiangLocationInfo.getShutterDoor() + "_open"); - + // 记录门状态 LuceneLogDto doorStatusLog = LuceneLogDto.builder() .device_code(device_code) - .content("[烘箱门状态] oven" + hongXiangLocationInfo.getOvenNo() + .content("[烘箱门状态] oven" + hongXiangLocationInfo.getOvenNo() + "_door" + hongXiangLocationInfo.getShutterDoor() + "_open = " + door_open) .build(); doorStatusLog.setLog_level(4); luceneExecuteLogService.deviceExecuteLog(doorStatusLog); - + if (door_open != 1) { // 下发开门指令 - String doorOpenCmd = "to_oven" + hongXiangLocationInfo.getOvenNo() + String doorOpenCmd = "to_oven" + hongXiangLocationInfo.getOvenNo() + "_door" + hongXiangLocationInfo.getShutterDoor() + "_open"; LuceneLogDto doorOpenLog = LuceneLogDto.builder() .device_code(device_code) @@ -403,34 +413,35 @@ public class AgvNdcTwoDeviceDriver extends AbstractDeviceDriver implements Devic .build(); doorOpenLog.setLog_level(4); luceneExecuteLogService.deviceExecuteLog(doorOpenLog); - + hongXiangStationDeviceDriver.writing(doorOpenCmd, "2"); return; + } else { + //到达取货点 + //门已经开了,此时请求取料 + // to_oven1_door1_storage + String storageCmd = "to_oven" + hongXiangLocationInfo.getOvenNo() + + "_door" + hongXiangLocationInfo.getShutterDoor() + "_storage"; + LuceneLogDto storageLog = LuceneLogDto.builder() + .device_code(device_code) + .content("[烘箱指令] 下发取料指令: " + storageCmd + " = " + hongXiangLocationInfo.getStorageNo()) + .build(); + storageLog.setLog_level(4); + luceneExecuteLogService.deviceExecuteLog(storageLog); + + hongXiangStationDeviceDriver.writing(storageCmd, String.valueOf(hongXiangLocationInfo.getStorageNo())); + data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0); + + // AGV反馈日志 + LuceneLogDto agvFeedbackLog = LuceneLogDto.builder() + .device_code(device_code) + .content("[AGV反馈] 取货点处理完成, phase:" + phase + ", 反馈数据:" + Arrays.toString(data)) + .build(); + agvFeedbackLog.setLog_level(4); + luceneExecuteLogService.deviceExecuteLog(agvFeedbackLog); + + logServer.deviceExecuteLog(this.device_code, "", "", "agvphase:" + phase + "反馈:" + data); } - //到达取货点 - //门已经开了,此时请求取料 - // to_oven1_door1_storage - String storageCmd = "to_oven" + hongXiangLocationInfo.getOvenNo() - + "_door" + hongXiangLocationInfo.getShutterDoor() + "_storage"; - LuceneLogDto storageLog = LuceneLogDto.builder() - .device_code(device_code) - .content("[烘箱指令] 下发取料指令: " + storageCmd + " = " + hongXiangLocationInfo.getStorageNo()) - .build(); - storageLog.setLog_level(4); - luceneExecuteLogService.deviceExecuteLog(storageLog); - - hongXiangStationDeviceDriver.writing(storageCmd, String.valueOf(hongXiangLocationInfo.getStorageNo())); - data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0); - - // AGV反馈日志 - LuceneLogDto agvFeedbackLog = LuceneLogDto.builder() - .device_code(device_code) - .content("[AGV反馈] 取货点处理完成, phase:" + phase + ", 反馈数据:" + Arrays.toString(data)) - .build(); - agvFeedbackLog.setLog_level(4); - luceneExecuteLogService.deviceExecuteLog(agvFeedbackLog); - - logServer.deviceExecuteLog(this.device_code, "", "", "agvphase:" + phase + "反馈:" + data); } else { LuceneLogDto logDto = LuceneLogDto.builder() .device_code(this.getDeviceCode()) @@ -474,12 +485,20 @@ public class AgvNdcTwoDeviceDriver extends AbstractDeviceDriver implements Devic } HongXiangLocationInfo hongXiangLocationInfo = CodeParserUtil.parseCode(device_code); - if(null != hongXiangLocationInfo){ + if(null != hongXiangLocationInfo ){ + log.info("【设备编码解析】满足三段式格式,device_code={},解析结果:{}", + device_code, hongXiangLocationInfo); device = deviceAppService.findDeviceByCode("hongxiang"); } else { + log.info("【设备编码解析】不满足三段式格式,走默认查询,device_code={}", device_code); device = deviceAppService.findDeviceByCode(device_code); } + // 必须判空,防止空指针 + if (device == null) { + log.error("【设备查询失败】未查询到设备信息,当前device_code={}", device_code); + return; + } if (ObjectUtil.isEmpty(device_code)) { log.info(agvaddr + "对应设备号为空!"); @@ -513,27 +532,30 @@ public class AgvNdcTwoDeviceDriver extends AbstractDeviceDriver implements Devic else if (device.getDeviceDriver() instanceof HongXiangStationDeviceDriver) { hongXiangStationDeviceDriver = (HongXiangStationDeviceDriver) device.getDeviceDriver(); + if (hongxiangError(device_code, hongXiangStationDeviceDriver, hongXiangLocationInfo)) return; + + //取货完毕 // to_oven1_door1_storage String completeCmd = "to_oven" + hongXiangLocationInfo.getOvenNo() + "_door" + hongXiangLocationInfo.getShutterDoor() + "_completed"; - + // 烘箱取货完成日志 LuceneLogDto ovenCompleteLog = LuceneLogDto.builder() .device_code(device_code) - .content("[烘箱交互] 取货完成, ovenNo:" + hongXiangLocationInfo.getOvenNo() + .content("[烘箱交互] 取货完成, ovenNo:" + hongXiangLocationInfo.getOvenNo() + ", shutterDoor:" + hongXiangLocationInfo.getShutterDoor()) .build(); ovenCompleteLog.setLog_level(4); luceneExecuteLogService.deviceExecuteLog(ovenCompleteLog); - + LuceneLogDto completeCmdLog = LuceneLogDto.builder() .device_code(device_code) .content("[烘箱指令] 下发取货完成指令: " + completeCmd + " = 1") .build(); completeCmdLog.setLog_level(4); luceneExecuteLogService.deviceExecuteLog(completeCmdLog); - + hongXiangStationDeviceDriver.writing(completeCmd, "1"); } else { @@ -552,7 +574,7 @@ public class AgvNdcTwoDeviceDriver extends AbstractDeviceDriver implements Devic param3.put("carId", inst.getCarno()); param3.put("taskType", inst.getInstruction_type()); param3.put("feedbackStatus", FeedbackStatusEnum.TAKE_FINISH.getCode()); - + // WCS交互日志 LuceneLogDto wcsLog = LuceneLogDto.builder() .device_code(device_code) @@ -560,26 +582,26 @@ public class AgvNdcTwoDeviceDriver extends AbstractDeviceDriver implements Devic .build(); wcsLog.setLog_level(4); luceneExecuteLogService.deviceExecuteLog(wcsLog); - + HttpResponse httpResponse2 = acsToWcsService.feedbackTaskStatusToWcs(param3); - + if (ObjectUtil.isNotEmpty(httpResponse2)) { String responseBody = httpResponse2.body(); JSONObject responseJson = JSONObject.parseObject(responseBody); int responseCode = responseJson.getIntValue("responseCode"); - + LuceneLogDto wcsResponseLog = LuceneLogDto.builder() .device_code(device_code) .content("[WCS响应] 取货完成响应, status:" + httpResponse2.getStatus() + ", body:" + responseBody) .build(); wcsResponseLog.setLog_level(4); luceneExecuteLogService.deviceExecuteLog(wcsResponseLog); - + // 判断 responseCode 是否为 0,非 0 则返回 if (responseCode != 0) { LuceneLogDto errorLog = LuceneLogDto.builder() .device_code(device_code) - .content("[WCS响应] 取货完成失败, responseCode:" + responseCode + .content("[WCS响应] 取货完成失败, responseCode:" + responseCode + ", responseMessage:" + responseJson.getString("responseMessage")) .build(); errorLog.setLog_level(2); @@ -629,12 +651,21 @@ public class AgvNdcTwoDeviceDriver extends AbstractDeviceDriver implements Devic } } HongXiangLocationInfo hongXiangLocationInfo = CodeParserUtil.parseCode(device_code); - if(null != hongXiangLocationInfo){ - device = deviceAppService.findDeviceByCode("hongxiang"); + if(null != hongXiangLocationInfo ){ + log.info("【设备编码解析】满足三段式格式,device_code={},解析结果:{}", + device_code, hongXiangLocationInfo); + device = deviceAppService.findDeviceByCode("hongxiang"); } else { + log.info("【设备编码解析】不满足三段式格式,走默认查询,device_code={}", device_code); device = deviceAppService.findDeviceByCode(device_code); } + // 必须判空,防止空指针 + if (device == null) { + log.error("【设备查询失败】未查询到设备信息,当前device_code={}", device_code); + return; + } + if (ObjectUtil.isEmpty(device_code)) { log.info(agvaddr + "对应设备号为空!"); return; @@ -662,19 +693,19 @@ public class AgvNdcTwoDeviceDriver extends AbstractDeviceDriver implements Devic String responseBody = httpResponse2.body(); JSONObject responseJson = JSONObject.parseObject(responseBody); int responseCode = responseJson.getIntValue("responseCode"); - + LuceneLogDto logDto2 = LuceneLogDto.builder() .device_code(device_code) .content("申请放货返回参数:" + responseBody) .build(); logDto2.setLog_level(4); luceneExecuteLogService.deviceExecuteLog(logDto2); - + // 判断 responseCode 是否为 0,非 0 则返回 if (responseCode != 0) { LuceneLogDto errorLog = LuceneLogDto.builder() .device_code(device_code) - .content("WCS反馈失败, responseCode:" + responseCode + .content("WCS反馈失败, responseCode:" + responseCode + ", responseMessage:" + responseJson.getString("responseMessage")) .build(); errorLog.setLog_level(2); @@ -729,15 +760,17 @@ public class AgvNdcTwoDeviceDriver extends AbstractDeviceDriver implements Devic luceneExecuteLogService.deviceExecuteLog(logDto); standardOrdinarySiteDeviceDriver.setOption(0); - } //烘箱 + } //烘箱 //到达放货点 else if (device.getDeviceDriver() instanceof HongXiangStationDeviceDriver) { hongXiangStationDeviceDriver = (HongXiangStationDeviceDriver) device.getDeviceDriver(); - + + if (hongxiangError(device_code, hongXiangStationDeviceDriver, hongXiangLocationInfo)) return; + // 烘箱放货点日志 LuceneLogDto ovenPutLog = LuceneLogDto.builder() .device_code(device_code) - .content("[烘箱交互] 到达放货点, ovenNo:" + hongXiangLocationInfo.getOvenNo() - + ", shutterDoor:" + hongXiangLocationInfo.getShutterDoor() + .content("[烘箱交互] 到达放货点, ovenNo:" + hongXiangLocationInfo.getOvenNo() + + ", shutterDoor:" + hongXiangLocationInfo.getShutterDoor() + ", storageNo:" + hongXiangLocationInfo.getStorageNo()) .build(); ovenPutLog.setLog_level(4); @@ -748,18 +781,18 @@ public class AgvNdcTwoDeviceDriver extends AbstractDeviceDriver implements Devic + hongXiangLocationInfo.getOvenNo() + "_door" + hongXiangLocationInfo.getShutterDoor() + "_open"); - + // 门状态日志 LuceneLogDto doorStatusLog = LuceneLogDto.builder() .device_code(device_code) - .content("[烘箱门状态] oven" + hongXiangLocationInfo.getOvenNo() + .content("[烘箱门状态] oven" + hongXiangLocationInfo.getOvenNo() + "_door" + hongXiangLocationInfo.getShutterDoor() + "_open = " + door_open) .build(); doorStatusLog.setLog_level(4); luceneExecuteLogService.deviceExecuteLog(doorStatusLog); - + if (door_open != 1) { - String doorOpenCmd = "to_oven" + hongXiangLocationInfo.getOvenNo() + String doorOpenCmd = "to_oven" + hongXiangLocationInfo.getOvenNo() + "_door" + hongXiangLocationInfo.getShutterDoor() + "_open"; LuceneLogDto doorOpenLog = LuceneLogDto.builder() .device_code(device_code) @@ -767,34 +800,34 @@ public class AgvNdcTwoDeviceDriver extends AbstractDeviceDriver implements Devic .build(); doorOpenLog.setLog_level(4); luceneExecuteLogService.deviceExecuteLog(doorOpenLog); - + hongXiangStationDeviceDriver.writing(doorOpenCmd, "1"); return; + } else { + //到达放货点 + //门已经开了,此时请求放货 + String storageCmd = "to_oven" + hongXiangLocationInfo.getOvenNo() + + "_door" + hongXiangLocationInfo.getShutterDoor() + "_storage"; + LuceneLogDto storageLog = LuceneLogDto.builder() + .device_code(device_code) + .content("[烘箱指令] 下发放货指令: " + storageCmd + " = " + hongXiangLocationInfo.getStorageNo()) + .build(); + storageLog.setLog_level(4); + luceneExecuteLogService.deviceExecuteLog(storageLog); + + hongXiangStationDeviceDriver.writing(storageCmd, String.valueOf(hongXiangLocationInfo.getStorageNo())); + data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0); + + // AGV反馈日志 + LuceneLogDto agvFeedbackLog = LuceneLogDto.builder() + .device_code(device_code) + .content("[AGV反馈] 放货点处理完成, phase:" + phase + ", 反馈数据:" + Arrays.toString(data)) + .build(); + agvFeedbackLog.setLog_level(4); + luceneExecuteLogService.deviceExecuteLog(agvFeedbackLog); + + logServer.deviceExecuteLog(this.device_code, "", "", "agvphase:" + phase + "反馈:" + data); } - - //门已经开了,此时请求放货 - String storageCmd = "to_oven" + hongXiangLocationInfo.getOvenNo() - + "_door" + hongXiangLocationInfo.getShutterDoor() + "_storage"; - LuceneLogDto storageLog = LuceneLogDto.builder() - .device_code(device_code) - .content("[烘箱指令] 下发放货指令: " + storageCmd + " = " + hongXiangLocationInfo.getStorageNo()) - .build(); - storageLog.setLog_level(4); - luceneExecuteLogService.deviceExecuteLog(storageLog); - - hongXiangStationDeviceDriver.writing(storageCmd, String.valueOf(hongXiangLocationInfo.getStorageNo())); - data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0); - - // AGV反馈日志 - LuceneLogDto agvFeedbackLog = LuceneLogDto.builder() - .device_code(device_code) - .content("[AGV反馈] 放货点处理完成, phase:" + phase + ", 反馈数据:" + Arrays.toString(data)) - .build(); - agvFeedbackLog.setLog_level(4); - luceneExecuteLogService.deviceExecuteLog(agvFeedbackLog); - - logServer.deviceExecuteLog(this.device_code, "", "", "agvphase:" + phase + "反馈:" + data); - } else { LuceneLogDto logDto = LuceneLogDto.builder() .device_code(this.getDeviceCode()) @@ -840,12 +873,20 @@ public class AgvNdcTwoDeviceDriver extends AbstractDeviceDriver implements Devic } HongXiangLocationInfo hongXiangLocationInfo = CodeParserUtil.parseCode(device_code); - if(null != hongXiangLocationInfo){ + if(null != hongXiangLocationInfo ){ + log.info("【设备编码解析】满足三段式格式,device_code={},解析结果:{}", + device_code, hongXiangLocationInfo); device = deviceAppService.findDeviceByCode("hongxiang"); } else { + log.info("【设备编码解析】不满足三段式格式,走默认查询,device_code={}", device_code); device = deviceAppService.findDeviceByCode(device_code); } + // 必须判空,防止空指针 + if (device == null) { + log.error("【设备查询失败】未查询到设备信息,当前device_code={}", device_code); + return; + } if (ObjectUtil.isEmpty(device_code)) { log.info(agvaddr + "对应设备号为空!"); @@ -867,17 +908,20 @@ public class AgvNdcTwoDeviceDriver extends AbstractDeviceDriver implements Devic //烘箱 else if (device.getDeviceDriver() instanceof HongXiangStationDeviceDriver) { hongXiangStationDeviceDriver = (HongXiangStationDeviceDriver) device.getDeviceDriver(); - + + if (hongxiangError(device_code, hongXiangStationDeviceDriver, hongXiangLocationInfo)) return; + + // 烘箱放货完成日志 LuceneLogDto ovenPutCompleteLog = LuceneLogDto.builder() .device_code(device_code) - .content("[烘箱交互] 放货完成, ovenNo:" + hongXiangLocationInfo.getOvenNo() + .content("[烘箱交互] 放货完成, ovenNo:" + hongXiangLocationInfo.getOvenNo() + ", shutterDoor:" + hongXiangLocationInfo.getShutterDoor()) .build(); ovenPutCompleteLog.setLog_level(4); luceneExecuteLogService.deviceExecuteLog(ovenPutCompleteLog); - - String completeCmd = "to_oven" + hongXiangLocationInfo.getOvenNo() + + String completeCmd = "to_oven" + hongXiangLocationInfo.getOvenNo() + "_door" + hongXiangLocationInfo.getShutterDoor() + "_completed"; LuceneLogDto completeCmdLog = LuceneLogDto.builder() .device_code(device_code) @@ -885,7 +929,7 @@ public class AgvNdcTwoDeviceDriver extends AbstractDeviceDriver implements Devic .build(); completeCmdLog.setLog_level(4); luceneExecuteLogService.deviceExecuteLog(completeCmdLog); - + hongXiangStationDeviceDriver.writing(completeCmd, "1"); } @@ -905,7 +949,7 @@ public class AgvNdcTwoDeviceDriver extends AbstractDeviceDriver implements Devic param3.put("carId", inst.getCarno()); param3.put("taskType", inst.getInstruction_type()); param3.put("feedbackStatus", FeedbackStatusEnum.PUT_FINISH.getCode()); - + // WCS交互日志 LuceneLogDto wcsLog = LuceneLogDto.builder() .device_code(device_code) @@ -913,26 +957,26 @@ public class AgvNdcTwoDeviceDriver extends AbstractDeviceDriver implements Devic .build(); wcsLog.setLog_level(4); luceneExecuteLogService.deviceExecuteLog(wcsLog); - + HttpResponse httpResponse2 = acsToWcsService.feedbackTaskStatusToWcs(param3); - + if (ObjectUtil.isNotEmpty(httpResponse2)) { String responseBody = httpResponse2.body(); JSONObject responseJson = JSONObject.parseObject(responseBody); int responseCode = responseJson.getIntValue("responseCode"); - + LuceneLogDto wcsResponseLog = LuceneLogDto.builder() .device_code(device_code) .content("[WCS响应] 放货完成响应, status:" + httpResponse2.getStatus() + ", body:" + responseBody) .build(); wcsResponseLog.setLog_level(4); luceneExecuteLogService.deviceExecuteLog(wcsResponseLog); - + // 判断 responseCode 是否为 0,非 0 则返回 if (responseCode != 0) { LuceneLogDto errorLog = LuceneLogDto.builder() .device_code(device_code) - .content("[WCS响应] 放货完成失败, responseCode:" + responseCode + .content("[WCS响应] 放货完成失败, responseCode:" + responseCode + ", responseMessage:" + responseJson.getString("responseMessage")) .build(); errorLog.setLog_level(2); @@ -1079,11 +1123,11 @@ public class AgvNdcTwoDeviceDriver extends AbstractDeviceDriver implements Devic .build(); agvWriteLog.setLog_level(4); luceneExecuteLogService.deviceExecuteLog(agvWriteLog); - + TwoNDCSocketConnectionAutoRun.write(data); } } - + // 方法出口日志 LuceneLogDto exitLog = LuceneLogDto.builder() .device_code(device_code) @@ -1094,6 +1138,23 @@ public class AgvNdcTwoDeviceDriver extends AbstractDeviceDriver implements Devic } + private boolean hongxiangError(String device_code, HongXiangStationDeviceDriver hongXiangStationDeviceDriver, HongXiangLocationInfo hongXiangLocationInfo) { + int error = (int) hongXiangStationDeviceDriver.getPropertyValue("item_oven" + + hongXiangLocationInfo.getOvenNo() + + "_error"); + if(error == 1){ + LuceneLogDto doorStatusLog = LuceneLogDto.builder() + .device_code(device_code) + .content("[烘箱] oven" + hongXiangLocationInfo.getOvenNo() + + "异常") + .build(); + doorStatusLog.setLog_level(4); + luceneExecuteLogService.deviceExecuteLog(doorStatusLog); + return true; + } + return false; + } + @Override public JSONObject getDeviceStatusName() { JSONObject jo = new JSONObject(); diff --git a/nlsso-server/src/main/java/org/nl/acs/device_driver/hongxiang_conveyor/CodeParserUtil.java b/nlsso-server/src/main/java/org/nl/acs/device_driver/hongxiang_conveyor/CodeParserUtil.java index ec85a47..7b61866 100644 --- a/nlsso-server/src/main/java/org/nl/acs/device_driver/hongxiang_conveyor/CodeParserUtil.java +++ b/nlsso-server/src/main/java/org/nl/acs/device_driver/hongxiang_conveyor/CodeParserUtil.java @@ -18,7 +18,7 @@ public class CodeParserUtil { } // 解析规则:全部转整数(自动去掉前导零) - int ovenNo = Integer.parseInt(parts[0]); // 100 → 100 + int ovenNo = Integer.parseInt(parts[0].replace("0","")); // 100 → 100 int shutterDoor = Integer.parseInt(parts[1]); // 001 → 1 int storageNo = Integer.parseInt(parts[2]); // 041 → 41 diff --git a/nlsso-server/src/main/java/org/nl/acs/instruction/service/impl/InstructionServiceImpl.java b/nlsso-server/src/main/java/org/nl/acs/instruction/service/impl/InstructionServiceImpl.java index cfd292d..5704b94 100644 --- a/nlsso-server/src/main/java/org/nl/acs/instruction/service/impl/InstructionServiceImpl.java +++ b/nlsso-server/src/main/java/org/nl/acs/instruction/service/impl/InstructionServiceImpl.java @@ -463,7 +463,7 @@ public class InstructionServiceImpl extends CommonServiceImpl" + dto.getNext_device_code() + "路由不通"); } - if (StrUtil.equals(shortPathsList.get(0).getType(), CommonFinalParam.ONE)) { + if (!StrUtil.equals(shortPathsList.get(0).getType(), CommonFinalParam.ONE)) { throw new BadRequestException(dto.getStart_device_code() + "->" + dto.getNext_device_code() + "路由类型不是agv类型"); } if (StrUtil.equals(paramService.findByCode(AcsConfig.AGVTYPE).getValue(), "2")) { @@ -1514,78 +1514,6 @@ public class InstructionServiceImpl extends CommonServiceImpl impleme @Override public void create(TaskDto dto) throws Exception { - dto = foramte(dto); + //dto = foramte(dto); dto.setInteraction_json(ObjectUtil.isNotEmpty(dto.getInteractionJson()) ? dto.getInteractionJson().toJSONString() : ""); if (!StrUtil.isEmpty(dto.getVehicle_code())) { TaskDto vehicle_dto = this.findByContainer(dto.getVehicle_code()); @@ -1323,143 +1323,7 @@ public class TaskServiceImpl extends CommonServiceImpl impleme @Override public TaskDto foramte(TaskDto task) { - String start_point_code = task.getStart_point_code(); - String next_point_code = task.getNext_point_code(); - String from_y = null; - String from_z = null; - String to_y = null; - String to_z = null; - CommonFinalParam commonFinalParam = new CommonFinalParam(); - if (StrUtil.contains(start_point_code, commonFinalParam.getBARRE()) && StrUtil.count(start_point_code, commonFinalParam.getBARRE()) == 2) { - String[] start_point = start_point_code.split(commonFinalParam.getBARRE()); - Device starPoint = deviceAppService.findDeviceByCode(start_point[0]); - task.setFrom_x(starPoint.getExtraValue().get("x").toString()); - task.setStart_device_code(start_point[0]); - if (Integer.parseInt(start_point[1]) < 10 && start_point[1].length() == 1) { - from_y = "0" + start_point[1]; - task.setFrom_y(from_y); - } else { - from_y = start_point[1]; - task.setFrom_y(from_y); - } - if (Integer.parseInt(start_point[2]) < 10 && start_point[2].length() == 1) { - from_z = "0" + start_point[2]; - task.setFrom_z(from_z); - } else if (start_point[2].length() == 2) { - from_z = start_point[2]; - task.setFrom_z(start_point[2]); - } else { - from_z = start_point[2]; - } - task.setStart_point_code(task.getStart_device_code() + commonFinalParam.getBARRE() + from_y + commonFinalParam.getBARRE() + from_z); - task.setStart_device_code(task.getStart_device_code()); - - } else { - DeviceDriverDefination deviceDriverDefination = deviceAppService.findDeviceByCode(start_point_code).getDeviceDriverDefination(); - if (BeanUtil.isNotEmpty(deviceDriverDefination)) { - String start_device = - deviceDriverDefination - .getFitDeviceTypes() - .get(0) - .name(); - // 如果point_device为货架,则不包含列层信息,需要重新拼接 - if (StrUtil.equals("storage", start_device)) { - if (StrUtil.isEmpty(task.getFrom_x())) { - throw new BadRequestException(LangProcess.msg("start_point_column")); - } - if (StrUtil.isEmpty(task.getFrom_y())) { - throw new BadRequestException(LangProcess.msg("start_point_layer")); - } - if (Integer.parseInt(task.getFrom_y()) < 10 && task.getFrom_y().length() == 1) { - from_y = "0" + task.getFrom_y(); - task.setFrom_y(from_y); - } else { - from_y = task.getFrom_y(); - } - if (Integer.parseInt(task.getFrom_z()) < 10 && task.getFrom_z().length() == 1) { - from_z = "0" + task.getFrom_z(); - task.setFrom_z(from_z); - } else if (task.getFrom_z().length() == 2) { - from_z = task.getFrom_z(); - task.setFrom_z(from_z); - } else { - from_z = task.getFrom_z(); - } - Device starPoint = deviceAppService.findDeviceByCode(start_point_code); - task.setFrom_x(starPoint.getExtraValue().get("x").toString()); - task.setStart_point_code(start_point_code + commonFinalParam.getBARRE() + from_y + commonFinalParam.getBARRE() + from_z); - task.setStart_device_code(start_point_code); - } - } else { - task.setStart_device_code(start_point_code); - task.setStart_device_code(start_point_code); - } - } - if (StrUtil.contains(next_point_code, commonFinalParam.getBARRE()) && StrUtil.count(next_point_code, commonFinalParam.getBARRE()) == 2) { - String[] next_point = next_point_code.split(commonFinalParam.getBARRE()); - task.setNext_device_code(next_point[0]); - Device nextDevice = deviceAppService.findDeviceByCode(next_point[0]); - task.setTo_x(nextDevice.getExtraValue().get("x").toString()); - if (Integer.parseInt(next_point[1]) < 10 && next_point[1].length() == 1) { - to_y = "0" + next_point[1]; - task.setTo_y(to_y); - } else { - to_y = next_point[1]; - task.setTo_y(to_y); - } - if (Integer.parseInt(next_point[2]) < 10 && next_point[2].length() == 1) { - to_z = "0" + next_point[2]; - task.setTo_z(to_z); - } else if (next_point[2].length() == 2) { - to_z = next_point[2]; - task.setTo_z(to_z); - } else { - to_z = next_point[2]; - task.setTo_z(to_z); - } - task.setNext_point_code(task.getNext_device_code() + commonFinalParam.getBARRE() + to_y + commonFinalParam.getBARRE() + to_z); - task.setNext_device_code(task.getNext_device_code()); - - } else { - DeviceDriverDefination deviceDriverDefination = deviceAppService.findDeviceByCode(next_point_code).getDeviceDriverDefination(); - if (BeanUtil.isNotEmpty(deviceDriverDefination)) { - String next_device = - deviceDriverDefination - .getFitDeviceTypes() - .get(0) - .name(); - if (StrUtil.equals("storage", next_device)) { - if (StrUtil.isEmpty(task.getTo_x())) { - throw new BadRequestException(LangProcess.msg("endpoint_column")); - } - if (StrUtil.isEmpty(task.getTo_y())) { - throw new BadRequestException(LangProcess.msg("endpoint_layer")); - } - if (Integer.parseInt(task.getTo_y()) < 10 && task.getTo_y().length() == 1) { - to_y = "0" + task.getTo_y(); - task.setTo_y(to_y); - } else { - to_y = task.getTo_y(); - } - if (Integer.parseInt(task.getTo_z()) < 10 && task.getTo_z().length() == 1) { - to_z = "0" + task.getTo_z(); - task.setTo_z(to_z); - } else if (task.getTo_z().length() == 2) { - to_z = task.getTo_z(); - task.setTo_z(to_z); - } else { - to_z = task.getTo_z(); - } - task.setTo_x(next_point_code); - task.setNext_point_code(next_point_code + commonFinalParam.getBARRE() + to_y + commonFinalParam.getBARRE() + to_z); - task.setNext_device_code(next_point_code); - } - } else { - task.setNext_device_code(next_point_code); - task.setNext_device_code(next_point_code); - } - } return task; }