From 5adf84f50bf5302211a445919d04a0ee895089a3 Mon Sep 17 00:00:00 2001 From: gengby <858962040@qq.com> Date: Sun, 3 Aug 2025 07:34:10 +0800 Subject: [PATCH] =?UTF-8?q?upd:=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../acs/agv/server/impl/AgvServiceImpl.java | 170 ++++++------------ .../call_task/YqCallTaskDeviceDriver.java | 2 +- .../yu_qing/gu_rong_lu/YqGRLDeviceDriver.java | 16 +- .../shi_xiao_lu/YqSXLDeviceDriver.java | 13 +- 4 files changed, 81 insertions(+), 120 deletions(-) diff --git a/hd/nladmin-system/src/main/java/org/nl/acs/agv/server/impl/AgvServiceImpl.java b/hd/nladmin-system/src/main/java/org/nl/acs/agv/server/impl/AgvServiceImpl.java index b3dff83..b9b94d1 100644 --- a/hd/nladmin-system/src/main/java/org/nl/acs/agv/server/impl/AgvServiceImpl.java +++ b/hd/nladmin-system/src/main/java/org/nl/acs/agv/server/impl/AgvServiceImpl.java @@ -1142,120 +1142,52 @@ public class AgvServiceImpl implements AgvService { @Override public JSONObject xgAGVWaitPointRequest(JSONObject requestParam) { log.info("仙工AGV请求取放货,请求参数 - {}", requestParam); + JSONObject resp = new JSONObject(); String instCode = requestParam.getString("task_code"); Instruction inst = instructionService.findByCodeFromCache(instCode); instcode = instCode; if (ObjectUtil.isEmpty(inst)) { - throw new BadRequestException("请求失败,未找到指令!"); + resp.put("code", 400); + resp.put("status", 400); + resp.put("message", "请求失败,请求任务信息不存在!"); + log.info("仙工AGV请求取放货,响应参数 - {}", resp); + return resp; } TaskDto task = taskService.findByCodeFromCache(inst.getTask_code()); if (ObjectUtil.isEmpty(task)) { - throw new BadRequestException("请求失败,未找到指令对应任务!"); + resp.put("code", 400); + resp.put("status", 400); + resp.put("message", "请求失败,请求任务信息不存在!"); + log.info("仙工AGV请求取放货,响应参数 - {}", resp); + return resp; } String address = requestParam.getString("address"); if (StrUtil.isBlank(address)) { - throw new BadRequestException("请求失败,地址为空!"); - } - String startcode = inst.getStart_device_code(); - //请求取货 - if (address.contains("INGET")) { - JSONObject jo = new JSONObject(); - jo.put("device_code", inst.getStart_device_code()); - jo.put("task_code", inst.getTask_code()); - jo.put("status", "1"); - jo.put("vehicle_code", inst.getVehicle_code()); - JSONArray ja = new JSONArray(); - ja.add(jo); - HttpResponse result = acsToWmsService.vehicle(ja); - log.info("请求取货请求参数:{}", ja); - com.alibaba.fastjson.JSONObject response = com.alibaba.fastjson.JSONObject.parseObject(result.body()); - log.info("上位反馈请求取货请求参数:{}", response); - int responseCode = response.getInteger("status"); - if (responseCode == 200) { - JSONObject jo2 = new JSONObject(); - jo2.put("status", 200); - startPointInget = true; - log.info("上位允许取货 请求结果{}", responseCode); - return jo2; - } else { - throw new BadRequestException("上位系统不允许取货"); - } - } - //取货完成离开 - if (address.contains("OUTGET")) { - JSONObject jo = new JSONObject(); - jo.put("device_code", inst.getStart_device_code()); - jo.put("task_code", inst.getTask_code()); - jo.put("status", "2"); - jo.put("vehicle_code", inst.getVehicle_code()); - JSONArray ja = new JSONArray(); - ja.add(jo); - log.info("取货完成离开请求参数:{}", ja); - HttpResponse result = acsToWmsService.vehicle(ja); - com.alibaba.fastjson.JSONObject response = com.alibaba.fastjson.JSONObject.parseObject(result.body()); - log.info("上位反馈取货完成离开请求参数:{}", response); - int responseCode = response.getInteger("status"); - if (responseCode == 200) { - JSONObject jo2 = new JSONObject(); - jo2.put("status", 200); - startPointOutget = true; - log.info("上位允许取货离开 请求结果{}", responseCode); - return jo2; - } else { - throw new BadRequestException("上位系统不允许取货完成离开"); - } - - } - //请求放货 - if (address.contains("INPUT")) { - JSONObject jo = new JSONObject(); - jo.put("device_code", inst.getNext_device_code()); - jo.put("task_code", inst.getTask_code()); - jo.put("status", "3"); - jo.put("vehicle_code", inst.getVehicle_code()); - JSONArray ja = new JSONArray(); - ja.add(jo); - log.info("请求放货请求参数:{}", ja); - HttpResponse result = acsToWmsService.vehicle(ja); - com.alibaba.fastjson.JSONObject response = com.alibaba.fastjson.JSONObject.parseObject(result.body()); - log.info("上位反馈请求放货请求参数:{}", response); - int responseCode = response.getInteger("status"); - if (responseCode == 200) { - JSONObject jo2 = new JSONObject(); - jo2.put("status", 200); - endPointInput = true; - log.info("上位允许放货 请求结果{}", responseCode); - return jo2; - } else { - throw new BadRequestException("上位系统不允许请求放货"); - } + resp.put("code", 400); + resp.put("status", 400); + resp.put("message", "请求失败,地址为空!"); + log.info("仙工AGV请求取放货,响应参数 - {}", resp); + return resp; } - //放货完成离开 if (address.contains("OUTPUT")) { - JSONObject jo = new JSONObject(); - jo.put("device_code", inst.getNext_device_code()); - jo.put("task_code", inst.getTask_code()); - jo.put("status", "4"); - jo.put("vehicle_code", inst.getVehicle_code()); - JSONArray ja = new JSONArray(); - ja.add(jo); - log.info("放货完成离开:{}", ja); - HttpResponse result = acsToWmsService.vehicle(ja); - com.alibaba.fastjson.JSONObject response = com.alibaba.fastjson.JSONObject.parseObject(result.body()); - log.info("上位反馈放货完成离开请求参数:{}", response); - int responseCode = response.getInteger("status"); - if (responseCode == 200) { - JSONObject jo2 = new JSONObject(); - endPointOutput = true; - jo2.put("status", 200); - log.info("上位允许放货离开 请求结果{}", responseCode); - return jo2; - } else { - throw new BadRequestException("上位系统不允许放货完成离开"); + String next_device_code = inst.getNext_device_code(); + Device device = deviceAppService.findDeviceByCode(next_device_code); + if (device != null && device.getDeviceDriver() instanceof YqGRLDeviceDriver) { + YqGRLDeviceDriver grlDeviceDriver = (YqGRLDeviceDriver) device.getDeviceDriver(); + grlDeviceDriver.writing(3); + log.info("AGV放货完成给{}下发{}", next_device_code, 3); + } else if (device != null && device.getDeviceDriver() instanceof YqSXLDeviceDriver) { + YqSXLDeviceDriver sxlDeviceDriver = (YqSXLDeviceDriver) device.getDeviceDriver(); + sxlDeviceDriver.writing(3); + log.info("AGV放货完成给{}下发{}", next_device_code, 3); } } - throw new BadRequestException("请求失败,IN OUT 站点错误!"); + resp.put("code", 200); + resp.put("status", 200); + resp.put("message", "请求成功!"); + log.info("仙工AGV请求取放货,响应参数 - {}", resp); + return resp; } @Override @@ -1647,7 +1579,7 @@ public class AgvServiceImpl implements AgvService { public JSONArray createBlocksData(Instruction inst) { // String ip = paramService.findByCode("local_host").getValue(); - String addr = "http://192.168.81.251:8010"; + String addr = "http://10.186.139.24:8010"; JSONArray blocks = new JSONArray(); @@ -1714,23 +1646,23 @@ public class AgvServiceImpl implements AgvService { Device device2 = deviceAppService.findDeviceByCode(inst.getNext_device_code()); if ("true".equals(device2.getExtraValue().get("ignore_release_check"))) { //放货前等待 - block = new JSONObject(); - block.put("blockId", IdUtil.simpleUUID()); - block.put("location", inst.getNext_point_code() + "INPUT"); - block.put("operation", "script"); - block.put("id", inst.getNext_point_code() + "INPUT"); - block.put("script_name", "userpy/interact.py"); - JSONObject scriptArgs = new JSONObject(); - scriptArgs.put("addr", addr); - JSONObject data = new JSONObject(); - JSONObject reach = new JSONObject(); - reach.put("task_code", inst.getInstruction_code()); - reach.put("address", inst.getNext_point_code() + "INPUT"); - data.put("reach", reach); - scriptArgs.put("data", data); - scriptArgs.put("protocol", "HTTP"); - block.put("script_args", scriptArgs); - blocks.add(block); +// block = new JSONObject(); +// block.put("blockId", IdUtil.simpleUUID()); +// block.put("location", inst.getNext_point_code() + "INPUT"); +// block.put("operation", "script"); +// block.put("id", inst.getNext_point_code() + "INPUT"); +// block.put("script_name", "userpy/interact.py"); +// JSONObject scriptArgs = new JSONObject(); +// scriptArgs.put("addr", addr); +// JSONObject data = new JSONObject(); +// JSONObject reach = new JSONObject(); +// reach.put("task_code", inst.getInstruction_code()); +// reach.put("address", inst.getNext_point_code() + "INPUT"); +// data.put("reach", reach); +// scriptArgs.put("data", data); +// scriptArgs.put("protocol", "HTTP"); +// block.put("script_args", scriptArgs); +// blocks.add(block); } block = new JSONObject(); @@ -2163,6 +2095,7 @@ public class AgvServiceImpl implements AgvService { } else { //到达固熔炉 grlDeviceDriver.writing(1); + log.info("AGV到达{}下发{}", grlDeviceDriver.getDevice_code(), 1); //返回AGV失败 resp.put("code", 400); resp.put("message", "安全门未开到位||固熔炉门未开到位||卷扬机未到达中位"); @@ -2178,6 +2111,7 @@ public class AgvServiceImpl implements AgvService { return resp; } else { sxlDeviceDriver.writing(1); + log.info("AGV到达{}下发{}", sxlDeviceDriver.getDevice_code(), 1); resp.put("code", 400); resp.put("message", "时效炉门未开到位"); log.info("上位不允许仙工AGV请求进入自动门区域 请求结果{}", resp); @@ -2216,6 +2150,7 @@ public class AgvServiceImpl implements AgvService { YqGRLDeviceDriver grlDeviceDriver = (YqGRLDeviceDriver) device.getDeviceDriver(); //离开固熔炉 grlDeviceDriver.writing(2); + log.info("AGV离开{}下发{}", grlDeviceDriver.getDevice_code(), 2); //返回AGV失败 resp.put("code", 200); resp.put("message", "ok"); @@ -2225,6 +2160,7 @@ public class AgvServiceImpl implements AgvService { YqSXLDeviceDriver sxlDeviceDriver = (YqSXLDeviceDriver) device.getDeviceDriver(); //离开时效炉 sxlDeviceDriver.writing(2); + log.info("AGV离开{}下发{}", sxlDeviceDriver.getDevice_code(), 2); resp.put("code", 200); resp.put("message", "ok"); log.info("上位允许仙工AGV请求离开自动门区域 请求结果{}", resp); diff --git a/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/yu_qing/call_task/YqCallTaskDeviceDriver.java b/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/yu_qing/call_task/YqCallTaskDeviceDriver.java index 8531def..a5144ee 100644 --- a/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/yu_qing/call_task/YqCallTaskDeviceDriver.java +++ b/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/yu_qing/call_task/YqCallTaskDeviceDriver.java @@ -100,7 +100,7 @@ public class YqCallTaskDeviceDriver extends AbstractOpcDeviceDriver implements D this.execute_log.log("设备:" + device_code + ",last_mode -> mode:" + last_mode + "->" + mode); } } catch (Exception var17) { - return; + log.error("读取信号异常:{},{}", var17.getMessage(), Arrays.toString(var17.getStackTrace())); } if (!this.itemProtocol.getIsOnline()) { this.setIsOnline(false); diff --git a/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/yu_qing/gu_rong_lu/YqGRLDeviceDriver.java b/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/yu_qing/gu_rong_lu/YqGRLDeviceDriver.java index 3c49e93..7af44ca 100644 --- a/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/yu_qing/gu_rong_lu/YqGRLDeviceDriver.java +++ b/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/yu_qing/gu_rong_lu/YqGRLDeviceDriver.java @@ -57,6 +57,12 @@ public class YqGRLDeviceDriver extends AbstractOpcDeviceDriver implements Device private int middleStatus = 0; private int lastMiddleStatus = 0; + /** + * 下发信号 + */ + private int toCommand = 0; + private int lastToCommand = 0; + /** * 设备在线状态 */ @@ -106,6 +112,7 @@ public class YqGRLDeviceDriver extends AbstractOpcDeviceDriver implements Device gDoorStatus = this.itemProtocol.getGDoorStatus(); aDoorStatus = this.itemProtocol.getADoorStatus(); middleStatus = this.itemProtocol.getMiddleStatus(); + toCommand = this.itemProtocol.getToCommand(); if (gDoorStatus != lastGDoorStatus) { this.execute_log.setResource(this.device_code, this.device.getDevice_name()); this.execute_log.log("设备:" + device_code + ",lastGDoorStatus -> gDoorStatus:" + lastGDoorStatus + "->" + gDoorStatus); @@ -120,8 +127,14 @@ public class YqGRLDeviceDriver extends AbstractOpcDeviceDriver implements Device this.execute_log.setResource(this.device_code, this.device.getDevice_name()); this.execute_log.log("设备:" + device_code + ",lastMiddleStatus -> middleStatus:" + lastMiddleStatus + "->" + middleStatus); } + + if (toCommand != lastToCommand) { + this.execute_log.setResource(this.device_code, this.device.getDevice_name()); + this.execute_log.log("设备:" + device_code + ",lastToCommand -> toCommand:" + lastToCommand + "->" + toCommand); + } + } catch (Exception var17) { - return; + log.error("读取信号异常:{},{}", var17.getMessage(), Arrays.toString(var17.getStackTrace())); } if (!this.itemProtocol.getIsOnline()) { this.setIsOnline(false); @@ -134,6 +147,7 @@ public class YqGRLDeviceDriver extends AbstractOpcDeviceDriver implements Device lastGDoorStatus = gDoorStatus; lastADoorStatus = aDoorStatus; lastMiddleStatus = middleStatus; + lastToCommand = toCommand; } diff --git a/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/yu_qing/shi_xiao_lu/YqSXLDeviceDriver.java b/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/yu_qing/shi_xiao_lu/YqSXLDeviceDriver.java index f8c5801..bdb493e 100644 --- a/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/yu_qing/shi_xiao_lu/YqSXLDeviceDriver.java +++ b/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/yu_qing/shi_xiao_lu/YqSXLDeviceDriver.java @@ -42,6 +42,12 @@ public class YqSXLDeviceDriver extends AbstractOpcDeviceDriver implements Device private int sDoorStatus = 0; private int lastSDoorStatus = 0; + /** + * 下发信号 + */ + private int toCommand = 0; + private int lastToCommand = 0; + /** * 设备在线状态 */ @@ -93,8 +99,12 @@ public class YqSXLDeviceDriver extends AbstractOpcDeviceDriver implements Device this.execute_log.setResource(this.device_code, this.device.getDevice_name()); this.execute_log.log("设备:" + device_code + ",lastSDoorStatus -> sDoorStatus:" + lastSDoorStatus + "->" + sDoorStatus); } + if (toCommand != lastToCommand) { + this.execute_log.setResource(this.device_code, this.device.getDevice_name()); + this.execute_log.log("设备:" + device_code + ",lastToCommand -> toCommand:" + lastToCommand + "->" + toCommand); + } } catch (Exception var17) { - return; + log.error("读取信号异常:{},{}", var17.getMessage(), Arrays.toString(var17.getStackTrace())); } if (!this.itemProtocol.getIsOnline()) { this.setIsOnline(false); @@ -106,6 +116,7 @@ public class YqSXLDeviceDriver extends AbstractOpcDeviceDriver implements Device } lastSDoorStatus = sDoorStatus; + lastToCommand = toCommand; }