From 47613fdbbc9fc19305e25fb6f133d5c8926625a9 Mon Sep 17 00:00:00 2001 From: lishuai <1793460677@qq.com> Date: Sat, 29 Jun 2024 15:10:35 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BB=99=E5=AE=AB=E6=97=A5=E5=BF=97?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/org/nl/acs/agv/AgvWaitUtil.java | 68 ++++++------- .../server/impl/XianGongAgvServiceImpl.java | 97 +++++++++++++++++-- acs2/nladmin-ui/src/i18n/langs/task/en.js | 1 + acs2/nladmin-ui/src/i18n/langs/task/in.js | 1 + acs2/nladmin-ui/src/i18n/langs/task/zh.js | 1 + acs2/nladmin-ui/src/views/acs/task/index.vue | 1 + 6 files changed, 127 insertions(+), 42 deletions(-) diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/agv/AgvWaitUtil.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/agv/AgvWaitUtil.java index 0207bb0cd..ce04c7aef 100644 --- a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/agv/AgvWaitUtil.java +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/agv/AgvWaitUtil.java @@ -53,28 +53,29 @@ public class AgvWaitUtil { manipulatorAgvStationDeviceDriver = (ManipulatorAgvStationDeviceDriver) startDevice.getDeviceDriver(); if (manipulatorAgvStationDeviceDriver.getTo_command() != 2) { manipulatorAgvStationDeviceDriver.writing(2); - if (manipulatorAgvStationDeviceDriver.getAction() == 1) { - LuceneLogDto logDto1 = LuceneLogDto.builder() - .device_code(inst.getCarno()) - .content("诺宝agv允许取货" + "点位" + startDeviceCode) - .build(); - logDto1.setLog_level(4); - luceneExecuteLogService.deviceExecuteLog(logDto1); - JSONObject map = new JSONObject(); - map.put("status", 200); - map.put("message", "允许取货!"); - log.info("允许仙工AGV取货,设备号 - {}", startDeviceCode); - return map; - } else { - LuceneLogDto logDto = LuceneLogDto.builder() - .device_code(inst.getCarno()) - .content("agv诺宝对接位行架不允许取货:" + inst.getCarno() + "点位号" + manipulatorAgvStationDeviceDriver.getDevice_code()) - .build(); - logDto.setLog_level(4); - luceneExecuteLogService.deviceExecuteLog(logDto); - throw new BadRequestException("行架不允许取货"); - } } + if (manipulatorAgvStationDeviceDriver.getAction() == 1) { + LuceneLogDto logDto1 = LuceneLogDto.builder() + .device_code(inst.getCarno()) + .content("诺宝agv允许取货" + "点位" + startDeviceCode) + .build(); + logDto1.setLog_level(4); + luceneExecuteLogService.deviceExecuteLog(logDto1); + JSONObject map = new JSONObject(); + map.put("status", 200); + map.put("message", "允许取货!"); + log.info("允许仙工AGV取货,设备号 - {}", startDeviceCode); + return map; + } else { + LuceneLogDto logDto = LuceneLogDto.builder() + .device_code(inst.getCarno()) + .content("agv诺宝对接位行架不允许取货:" + inst.getCarno() + "点位号" + manipulatorAgvStationDeviceDriver.getDevice_code()) + .build(); + logDto.setLog_level(4); + luceneExecuteLogService.deviceExecuteLog(logDto); + throw new BadRequestException("行架不允许取货"); + } + } //agv叉车对接位安全信号交互 @@ -103,8 +104,8 @@ public class AgvWaitUtil { } } JSONObject map = new JSONObject(); - map.put("status", 400); - map.put("message", "取货点位信息不对!"); + map.put("status", 200); + map.put("message", "允许取货!"); log.info("允许仙工AGV取货,设备号 - {}", startDeviceCode); return map; } @@ -187,17 +188,18 @@ public class AgvWaitUtil { manipulatorAgvStationDeviceDriver = (ManipulatorAgvStationDeviceDriver) endDevice.getDeviceDriver(); if (manipulatorAgvStationDeviceDriver.getTo_command() != 4) { manipulatorAgvStationDeviceDriver.writing(4); - if (manipulatorAgvStationDeviceDriver.getAction() != 1) { - LuceneLogDto logDto = LuceneLogDto.builder() - .device_code(inst.getCarno()) - .content("agv诺宝对接位行架不允许放货:" + inst.getCarno() + "点位号" + manipulatorAgvStationDeviceDriver.getDevice_code()) - .build(); - logDto.setLog_level(4); - luceneExecuteLogService.deviceExecuteLog(logDto); - log.info("不允许仙工AGV取货,对接位有报警,设备号 - {}", endDevice); - throw new BadRequestException("上位系统不允许取货"); - } } + if (manipulatorAgvStationDeviceDriver.getAction() != 1) { + LuceneLogDto logDto = LuceneLogDto.builder() + .device_code(inst.getCarno()) + .content("agv诺宝对接位行架不允许放货:" + inst.getCarno() + "点位号" + manipulatorAgvStationDeviceDriver.getDevice_code()) + .build(); + logDto.setLog_level(4); + luceneExecuteLogService.deviceExecuteLog(logDto); + log.info("不允许仙工AGV取货,对接位有报警,设备号 - {}", endDevice); + throw new BadRequestException("上位系统不允许取货"); + } + } LuceneLogDto logDto = LuceneLogDto.builder() .device_code(inst.getCarno()) diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/agv/server/impl/XianGongAgvServiceImpl.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/agv/server/impl/XianGongAgvServiceImpl.java index 9b5c3533d..c4efa45c2 100644 --- a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/agv/server/impl/XianGongAgvServiceImpl.java +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/agv/server/impl/XianGongAgvServiceImpl.java @@ -8,6 +8,7 @@ import cn.hutool.http.HttpResponse; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; +import jodd.util.StringUtil; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.nl.acs.AcsConfig; @@ -18,7 +19,6 @@ import org.nl.acs.agv.server.dto.AgvDto; import org.nl.acs.angle.service.IAcsPointAngleService; import org.nl.acs.common.base.CommonFinalParam; import org.nl.acs.device.domain.Device; -import org.nl.acs.device_driver.conveyor.belt_conveyor.BeltConveyorDeviceDriver; import org.nl.acs.device_driver.conveyor.standard_ordinary_site.StandardOrdinarySiteDeviceDriver; import org.nl.acs.ext.wms.service.AcsToWmsService; import org.nl.acs.instruction.domain.Instruction; @@ -29,8 +29,9 @@ import org.nl.acs.device.enums.DeviceType; import org.nl.acs.task.enums.ActionTypeEnum; import org.nl.acs.task.enums.AgvActionTypeEnum; import org.nl.acs.task.enums.AgvSystemTypeEnum; +import org.nl.acs.task.service.TaskService; +import org.nl.acs.task.service.dto.TaskDto; import org.nl.common.exception.BadRequestException; -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; @@ -59,6 +60,9 @@ public class XianGongAgvServiceImpl implements XianGongAgvService { @Autowired private InstructionService instructionService; + @Autowired + private TaskService taskserver; + @Autowired private LuceneExecuteLogService luceneExecuteLogService; @Autowired @@ -401,7 +405,7 @@ public class XianGongAgvServiceImpl implements XianGongAgvService { } } - private void inspectInStocckSet( String pointCode, JSONObject jo1) { + private void inspectInStocckSet(String pointCode, JSONObject jo1) { Device device = deviceAppservice.findDeviceByCode(pointCode); StandardOrdinarySiteDeviceDriver standardOrdinarySiteDeviceDriver; if (device.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) { @@ -765,14 +769,14 @@ public class XianGongAgvServiceImpl implements XianGongAgvService { if (AgvActionTypeEnum.IN_STOCK.getCode().equals(instructionDto.getAgv_action_type()) || AgvActionTypeEnum.IN_OUT_STOCK.getCode().equals(instructionDto.getAgv_action_type())) { Integer actionType = ActionTypeEnum.IN_STOCK.getCode(); String newPointCode = applyXGAgvTask(task_code, actionType, instructionDto); - return agvWaitUtil.waitInGet(newPointCode, instructionDto); + log.info("取货二次分配追加诺宝成功,新点位 - {}", newPointCode); } //如果是放货二次分配,取放货二次分配需要重新追加动作块 if (AgvActionTypeEnum.OUT_STOCK.getCode().equals(instructionDto.getAgv_action_type()) || AgvActionTypeEnum.IN_OUT_STOCK.getCode().equals(instructionDto.getAgv_action_type())) { Integer actionType = ActionTypeEnum.OUT_STOCK.getCode(); String newPointCode = applyXGAgvTask(task_code, actionType, instructionDto); // sendAddSequencesToNBAgv(instructionDto.getInstruction_code(), deviceCodeNow, instructionDto); - return agvWaitUtil.waitInPut(newPointCode, instructionDto); + log.info("放货二次分配追加诺宝成功,新点位 - {}", newPointCode); } } //一楼叉车 @@ -810,10 +814,19 @@ public class XianGongAgvServiceImpl implements XianGongAgvService { if (address.contains("GET")) { //取货完成 - return agvWaitUtil.waitOutGet(deviceCodeNow, instructionDto); + JSONObject jsonObject = agvWaitUtil.waitOutGet(deviceCodeNow, instructionDto); + if (StringUtil.equals("200",jsonObject.getString("status"))){ + log.info("允许仙工AGV取货完成后请求离开,设备号 - {}", deviceCodeNow); + return jsonObject; + } } else if (address.contains("PUT")) { //放货完成 - return agvWaitUtil.waitOutPut(deviceCodeNow, instructionDto); + JSONObject jsonObject = agvWaitUtil.waitOutPut(deviceCodeNow, instructionDto); + if (StringUtil.equals("200",jsonObject.getString("status"))){ + log.info("允许仙工AGV取货完成后请求离开,设备号 - {}", deviceCodeNow); + return jsonObject; + } + } } @@ -953,6 +966,8 @@ public class XianGongAgvServiceImpl implements XianGongAgvService { .content("二次分配请求lms,参数,接口返回:" + jo) .build(); logDto2.setLog_level(4); + //二次分配更新点位 + updataTask(instructionDto, jo.getString("data")); luceneExecuteLogService.deviceExecuteLog(logDto2); if (!ActionTypeEnum.IN_FINISHING.getCode().equals(actionType)) { //请求成功调用诺宝追加动作块 @@ -976,6 +991,26 @@ public class XianGongAgvServiceImpl implements XianGongAgvService { return null; } + private void updataTask(Instruction instructionDto, String newPoint) { + + TaskDto taskUpdate = new TaskDto(); + if (AgvActionTypeEnum.IN_STOCK.getCode().equals(instructionDto.getAgv_action_type())) { + instructionDto.setStart_point_code(newPoint); + taskUpdate.setStart_point_code(newPoint); + instructionDto.setStart_device_code(newPoint); + taskUpdate.setStart_device_code(newPoint); + } + if (AgvActionTypeEnum.OUT_STOCK.getCode().equals(instructionDto.getAgv_action_type())) { + instructionDto.setNext_point_code(newPoint); + taskUpdate.setNext_point_code(newPoint); + instructionDto.setNext_device_code(newPoint); + taskUpdate.setNext_device_code(newPoint); + } + taskUpdate.setTask_id(instructionDto.getTask_id()); + instructionService.update(instructionDto); + taskserver.update(taskUpdate); + } + @Override public HttpResponse sendOrderSequencesToForklift(Instruction inst, InteractionJsonDTO interactionJsonDTO) { @@ -1087,6 +1122,25 @@ public class XianGongAgvServiceImpl implements XianGongAgvService { } private void sendEndDeviceOrder3(JSONArray ja, String nextDeviceCode, String instructionCode, Instruction instructionDto) { + JSONObject jo3 = new JSONObject(); + jo3.put("blockId", IdUtil.simpleUUID()); + jo3.put("location", nextDeviceCode + "INPUT"); + jo3.put("operation", "script"); + jo3.put("id", nextDeviceCode + "INPUT"); + jo3.put("script_name", "userpy/interact.py"); + JSONObject script_args3 = new JSONObject(); + script_args3.put("addr", addr); + JSONObject data3 = new JSONObject(); + JSONObject reach3 = new JSONObject(); + reach3.put("task_code", instructionCode); + reach3.put("address", nextDeviceCode + "INPUT"); + data3.put("reach", reach3); + script_args3.put("data", data3); + script_args3.put("protocol", "HTTP"); + jo3.put("script_args", script_args3); + ja.add(jo3); + + //将货物放下 com.alibaba.fastjson.JSONObject jo4 = new com.alibaba.fastjson.JSONObject(); jo4.put("blockId", IdUtil.simpleUUID()); @@ -1119,7 +1173,7 @@ public class XianGongAgvServiceImpl implements XianGongAgvService { JSONArray ja = new JSONArray(); String nextDeviceCode = instructionDto.getNext_device_code(); //起点2 - sendStartDeviceOrder2(ja, startPoint, instructionCode); + sendStartDeviceOrder2(ja, startPoint, instructionCode, instructionDto); //终点2 sendEndDeviceOrder2(ja, nextDeviceCode, instructionCode, instructionDto); return ja; @@ -1173,7 +1227,32 @@ public class XianGongAgvServiceImpl implements XianGongAgvService { } } - private void sendStartDeviceOrder2(JSONArray ja, String startPoint, String instructionCode) { + private void sendStartDeviceOrder2(JSONArray ja, String startPoint, String instructionCode, Instruction instructionDto) { + //取货前等待 + JSONObject jo = new JSONObject(); + //动作块id + jo.put("blockId", IdUtil.simpleUUID()); + //目的地名称 + jo.put("location", startPoint + "INGET"); + //执行脚本 + jo.put("operation", "script"); + jo.put("id", startPoint + "INGET"); + //通信脚本,动作前后与现场设备交互的场景 + jo.put("script_name", "userpy/interact.py"); + JSONObject script_args = new JSONObject(); + //更改为现场设备IP及PORT + script_args.put("addr", addr); + JSONObject data = new JSONObject(); + JSONObject reach = new JSONObject(); + reach.put("task_code", instructionCode); + reach.put("address", startPoint + "INGET"); + data.put("reach", reach); + script_args.put("data", data); + script_args.put("protocol", "HTTP"); + jo.put("script_args", script_args); + ja.add(jo); + + //将货物顶起来,机器识别提升高度 JSONObject jo1 = new JSONObject(); jo1.put("blockId", IdUtil.simpleUUID()); diff --git a/acs2/nladmin-ui/src/i18n/langs/task/en.js b/acs2/nladmin-ui/src/i18n/langs/task/en.js index 1a450c80f..9d7584ae9 100644 --- a/acs2/nladmin-ui/src/i18n/langs/task/en.js +++ b/acs2/nladmin-ui/src/i18n/langs/task/en.js @@ -7,6 +7,7 @@ export default { 'Task_status': 'Task Status', 'Origin_or_destination': 'Origin Or Destination', 'Task_type': 'Task Type', + 'Action_type': 'Action Type', 'Warehouse_task_type': 'Warehouse Task Type', 'AGV_system': 'AGV System', 'Routing_scheme': 'Routing Scheme', diff --git a/acs2/nladmin-ui/src/i18n/langs/task/in.js b/acs2/nladmin-ui/src/i18n/langs/task/in.js index c64ecb3d2..44e14cb5b 100644 --- a/acs2/nladmin-ui/src/i18n/langs/task/in.js +++ b/acs2/nladmin-ui/src/i18n/langs/task/in.js @@ -7,6 +7,7 @@ export default { 'Task_status': 'Status Tugas', 'Origin_or_destination': 'Asal Atau Tujuan', 'Task_type': 'Jenis Tugas', + 'Action_type': 'Tipe tugas sekunder', 'Warehouse_task_type': 'Jenis Tugas Gudang', 'AGV_system': 'Sistem AGV', 'Routing_scheme': 'Skema Routing', diff --git a/acs2/nladmin-ui/src/i18n/langs/task/zh.js b/acs2/nladmin-ui/src/i18n/langs/task/zh.js index a2d04657a..7a63d004b 100644 --- a/acs2/nladmin-ui/src/i18n/langs/task/zh.js +++ b/acs2/nladmin-ui/src/i18n/langs/task/zh.js @@ -7,6 +7,7 @@ export default { 'Task_status': '任务状态', 'Origin_or_destination': '输入起点或终点', 'Task_type': '任务类型', + 'Action_type': '二次分配类型', 'Warehouse_task_type': '立库任务类型', 'AGV_system': 'agv系统', 'Routing_scheme': '路由方案', diff --git a/acs2/nladmin-ui/src/views/acs/task/index.vue b/acs2/nladmin-ui/src/views/acs/task/index.vue index 88c42db4c..591b09a86 100644 --- a/acs2/nladmin-ui/src/views/acs/task/index.vue +++ b/acs2/nladmin-ui/src/views/acs/task/index.vue @@ -505,6 +505,7 @@ +