From 6448cd9a185706dffb3c222d1145d5fc611d22ee Mon Sep 17 00:00:00 2001 From: gengby <858962040@qq.com> Date: Wed, 24 May 2023 13:29:10 +0800 Subject: [PATCH] =?UTF-8?q?rev=20=E5=8F=8D=E9=A6=88lms=20agv=E4=BF=A1?= =?UTF-8?q?=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../wms/service/impl/WmsToAcsServiceImpl.java | 95 +++++++++++-------- .../main/resources/config/application-dev.yml | 4 +- .../src/main/resources/config/application.yml | 2 +- 3 files changed, 60 insertions(+), 41 deletions(-) diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/impl/WmsToAcsServiceImpl.java b/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/impl/WmsToAcsServiceImpl.java index cfd6ae389..a8fc521eb 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/impl/WmsToAcsServiceImpl.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/impl/WmsToAcsServiceImpl.java @@ -39,6 +39,7 @@ import org.nl.acs.ext.wms.service.AcsToLiKuService; import org.nl.acs.ext.wms.service.WmsToAcsService; import org.nl.acs.instruction.service.InstructionService; import org.nl.acs.instruction.service.dto.Instruction; +import org.nl.acs.monitor.DeviceStageMonitor; import org.nl.acs.opc.Device; import org.nl.acs.opc.DeviceAppService; import org.nl.acs.opc.DeviceExtraManageDto; @@ -275,16 +276,16 @@ public class WmsToAcsServiceImpl implements WmsToAcsService { jo.put("action", standardCoveyorControlWithScannerDeviceDriver.getAction()); jo.put("error", standardCoveyorControlWithScannerDeviceDriver.getError()); - } else if (device.getDeviceDriver() instanceof PaperTubeConveyorDeviceDriver) { + } else if (device.getDeviceDriver() instanceof PaperTubeConveyorDeviceDriver) { paperTubeConveyorDeviceDriver = (PaperTubeConveyorDeviceDriver) device.getDeviceDriver(); jo.put("device_code", parent_device_code); jo.put("qty", paperTubeConveyorDeviceDriver.getInventory_qty()); jo.put("mode", paperTubeConveyorDeviceDriver.getMode()); jo.put("error", paperTubeConveyorDeviceDriver.getError()); - jo.put("material_code", ObjectUtil.isEmpty(paperTubeConveyorDeviceDriver.getMaterial())? "":paperTubeConveyorDeviceDriver.getMaterial() ); + jo.put("material_code", ObjectUtil.isEmpty(paperTubeConveyorDeviceDriver.getMaterial()) ? "" : paperTubeConveyorDeviceDriver.getMaterial()); jo.put("out_finish", paperTubeConveyorDeviceDriver.getOut_finish()); - }else { + } else { jo.put("device_code", parent_device_code); } backja.add(jo); @@ -919,29 +920,47 @@ public class WmsToAcsServiceImpl implements WmsToAcsService { public Map queryDeviceInfo(JSONObject param) { log.info("queryDeviceInfo--------------:输入参数" + param.toString()); String region_code = param.getString("region_code"); - if (StrUtil.isEmpty(region_code)) { - throw new BadRequestException("区域编码不能为空"); - } +// if (StrUtil.isEmpty(region_code)) { +// throw new BadRequestException("区域编码不能为空"); +// } AgvNdcTwoDeviceDriver agvNdcTwoDeviceDriver; AgvNdcOneDeviceDriver agvNdcOneDeviceDriver; List devices = deviceAppService.findDevice(DeviceType.agv); JSONArray data = new JSONArray(); - if (ObjectUtil.isNotEmpty(devices)) { - for (int i = 0; i < devices.size(); i++) { - Device device = devices.get(i); - Device agvDevice = deviceAppService.findDeviceByCode(device.getDevice_code()); - if (agvDevice.getDeviceDriver() instanceof AgvNdcTwoDeviceDriver) { - if (StrUtil.equals(region_code, "1")) { - agvNdcTwoDeviceDriver = (AgvNdcTwoDeviceDriver) agvDevice.getDeviceDriver(); - JSONObject jo = agvNdcTwoDeviceDriver.getDeviceStatusName(); - data.add(jo); + if (StrUtil.isEmpty(region_code)) { + if (ObjectUtil.isNotEmpty(devices)) { + for (int i = 0; i < devices.size(); i++) { + Device device = devices.get(i); + Device agvDevice = deviceAppService.findDeviceByCode(device.getDevice_code()); + if (agvDevice.getDeviceDriver() instanceof DeviceStageMonitor) { + DeviceStageMonitor deviceStageMonitor = (DeviceStageMonitor) agvDevice.getDeviceDriver(); + try { + JSONObject jo = deviceStageMonitor.getDeviceStatusName(); + data.add(jo); + } catch (Exception e) { + log.error("反馈AGV信息失败:{}", e.getMessage()); + } } } - if (agvDevice.getDeviceDriver() instanceof AgvNdcOneDeviceDriver) { - if (StrUtil.equals(region_code, "5")) { - agvNdcOneDeviceDriver = (AgvNdcOneDeviceDriver) agvDevice.getDeviceDriver(); - JSONObject jo = agvNdcOneDeviceDriver.getDeviceStatusName(); - data.add(jo); + } + } else { + if (ObjectUtil.isNotEmpty(devices)) { + for (int i = 0; i < devices.size(); i++) { + Device device = devices.get(i); + Device agvDevice = deviceAppService.findDeviceByCode(device.getDevice_code()); + if (agvDevice.getDeviceDriver() instanceof AgvNdcTwoDeviceDriver) { + if (StrUtil.equals(region_code, "1")) { + agvNdcTwoDeviceDriver = (AgvNdcTwoDeviceDriver) agvDevice.getDeviceDriver(); + JSONObject jo = agvNdcTwoDeviceDriver.getDeviceStatusName(); + data.add(jo); + } + } + if (agvDevice.getDeviceDriver() instanceof AgvNdcOneDeviceDriver) { + if (StrUtil.equals(region_code, "5")) { + agvNdcOneDeviceDriver = (AgvNdcOneDeviceDriver) agvDevice.getDeviceDriver(); + JSONObject jo = agvNdcOneDeviceDriver.getDeviceStatusName(); + data.add(jo); + } } } } @@ -1033,49 +1052,49 @@ public class WmsToAcsServiceImpl implements WmsToAcsService { } if (device.getDeviceDriver() instanceof PaperTubeConveyorDeviceDriver) { PaperTubeConveyorDeviceDriver paperTubeConveyorDeviceDriver = (PaperTubeConveyorDeviceDriver) device.getDeviceDriver(); - if(paperTubeConveyorDeviceDriver.getMode() != 2){ + if (paperTubeConveyorDeviceDriver.getMode() != 2) { resp.put("status", 400); - resp.put("message", "设备:"+ device_code +"未待机,无法下发信号"); + resp.put("message", "设备:" + device_code + "未待机,无法下发信号"); log.info("paperTubeAction--------------:输出参数" + resp.toString()); return resp; } - if(StrUtil.equals(type,"1")){ - if(paperTubeConveyorDeviceDriver.getInventory_qty() > 0){ + if (StrUtil.equals(type, "1")) { + if (paperTubeConveyorDeviceDriver.getInventory_qty() > 0) { resp.put("status", 400); - resp.put("message", "设备:"+ device_code +"当前数量为"+paperTubeConveyorDeviceDriver.getInventory_qty() +"无法设置物料"); + resp.put("message", "设备:" + device_code + "当前数量为" + paperTubeConveyorDeviceDriver.getInventory_qty() + "无法设置物料"); log.info("paperTubeAction--------------:输出参数" + resp.toString()); return resp; } - paperTubeConveyorDeviceDriver.writing("to_material",material_code); - } else if (StrUtil.equals(type,"2")) { - if(paperTubeConveyorDeviceDriver.getInventory_qty() < Integer.parseInt(qty)){ + paperTubeConveyorDeviceDriver.writing("to_material", material_code); + } else if (StrUtil.equals(type, "2")) { + if (paperTubeConveyorDeviceDriver.getInventory_qty() < Integer.parseInt(qty)) { resp.put("status", 400); - resp.put("message", "设备:"+ device_code +"当前数量为"+paperTubeConveyorDeviceDriver.getInventory_qty() +"小于出库数量"+qty); + resp.put("message", "设备:" + device_code + "当前数量为" + paperTubeConveyorDeviceDriver.getInventory_qty() + "小于出库数量" + qty); log.info("paperTubeAction--------------:输出参数" + resp.toString()); return resp; } - if(StrUtil.isEmpty(paperTubeConveyorDeviceDriver.getMaterial())){ + if (StrUtil.isEmpty(paperTubeConveyorDeviceDriver.getMaterial())) { resp.put("status", 400); - resp.put("message", "设备:"+ device_code +"设备上报物料为空无法出库"); + resp.put("message", "设备:" + device_code + "设备上报物料为空无法出库"); log.info("paperTubeAction--------------:输出参数" + resp.toString()); return resp; } else { - if(!StrUtil.equals(paperTubeConveyorDeviceDriver.getMaterial(),material_code)){ + if (!StrUtil.equals(paperTubeConveyorDeviceDriver.getMaterial(), material_code)) { resp.put("status", 400); - resp.put("message", "设备:"+ device_code +"设备上报物料为"+paperTubeConveyorDeviceDriver.getMaterial() +"与出库物料"+material_code+"不匹配"); + resp.put("message", "设备:" + device_code + "设备上报物料为" + paperTubeConveyorDeviceDriver.getMaterial() + "与出库物料" + material_code + "不匹配"); log.info("paperTubeAction--------------:输出参数" + resp.toString()); return resp; } } - if(paperTubeConveyorDeviceDriver.getTo_command() != 0 || paperTubeConveyorDeviceDriver.getTo_target() != 0 ){ + if (paperTubeConveyorDeviceDriver.getTo_command() != 0 || paperTubeConveyorDeviceDriver.getTo_target() != 0) { resp.put("status", 400); - resp.put("message", "设备:"+ device_code +"下发命令信号值为"+paperTubeConveyorDeviceDriver.getTo_command() + ",下发目标站:" + paperTubeConveyorDeviceDriver.getTo_target() +",已存在待执行的任务"); + resp.put("message", "设备:" + device_code + "下发命令信号值为" + paperTubeConveyorDeviceDriver.getTo_command() + ",下发目标站:" + paperTubeConveyorDeviceDriver.getTo_target() + ",已存在待执行的任务"); log.info("paperTubeAction--------------:输出参数" + resp.toString()); return resp; } - paperTubeConveyorDeviceDriver.writing("to_out_qty",qty); - paperTubeConveyorDeviceDriver.writing("to_target",device.getAddress()); - paperTubeConveyorDeviceDriver.writing("to_command","2"); + paperTubeConveyorDeviceDriver.writing("to_out_qty", qty); + paperTubeConveyorDeviceDriver.writing("to_target", device.getAddress()); + paperTubeConveyorDeviceDriver.writing("to_command", "2"); } } diff --git a/acs/nladmin-system/src/main/resources/config/application-dev.yml b/acs/nladmin-system/src/main/resources/config/application-dev.yml index a1f56261a..f57637425 100644 --- a/acs/nladmin-system/src/main/resources/config/application-dev.yml +++ b/acs/nladmin-system/src/main/resources/config/application-dev.yml @@ -13,11 +13,11 @@ spring: driverClassName: net.sf.log4jdbc.sql.jdbcapi.DriverSpy # url: jdbc:log4jdbc:mysql://${DB_HOST:10.1.3.91}:${DB_PORT:3306}/${DB_NAME:acs}?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false&useOldAliasMetadataBehavior=true # url: jdbc:log4jdbc:mysql://${DB_HOST:192.168.81.252}:${DB_PORT:3306}/${DB_NAME:lzhl_one_acs}?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false&useOldAliasMetadataBehavior=true - url: jdbc:log4jdbc:mysql://${DB_HOST:127.0.0.1}:${DB_PORT:3306}/${DB_NAME:lzhl_one_acs}?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false&useOldAliasMetadataBehavior=true&allowPublicKeyRetrieval=true + url: jdbc:log4jdbc:mysql://${DB_HOST:127.0.0.1}:${DB_PORT:3306}/${DB_NAME:lzhl_one_wcs}?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false&useOldAliasMetadataBehavior=true&allowPublicKeyRetrieval=true username: ${DB_USER:root} # password: ${DB_PWD:P@ssw0rd} # password: ${DB_PWD:Root.123456} - password: ${DB_PWD:123456} + password: ${DB_PWD:password} # 初始连接数 initial-size: 5 diff --git a/acs/nladmin-system/src/main/resources/config/application.yml b/acs/nladmin-system/src/main/resources/config/application.yml index f943602c7..cfc52fe40 100644 --- a/acs/nladmin-system/src/main/resources/config/application.yml +++ b/acs/nladmin-system/src/main/resources/config/application.yml @@ -2,7 +2,7 @@ spring: freemarker: check-template-location: false profiles: - active: dev + active: prod jackson: time-zone: GMT+8 data: