diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/agv/server/impl/XianGongAgvServiceImpl.java b/acs/nladmin-system/src/main/java/org/nl/acs/agv/server/impl/XianGongAgvServiceImpl.java index e3570ba..a892f75 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/agv/server/impl/XianGongAgvServiceImpl.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/agv/server/impl/XianGongAgvServiceImpl.java @@ -348,7 +348,6 @@ public class XianGongAgvServiceImpl implements XianGongAgvService { ja.add(joi3); } } - System.out.println(ja.toString()); return ja; } @@ -455,20 +454,22 @@ public class XianGongAgvServiceImpl implements XianGongAgvService { if (StrUtil.equals(paramService.findByCode(AcsConfig.FORKAGV).getValue(), "1")) { String agvurl = paramService.findByCode(AcsConfig.AGVURL).getValue(); String agvport = paramService.findByCode(AcsConfig.AGVPORT).getValue(); - agvurl = agvurl + ":" + agvport + "/blockGroupStatus"; + log.info("获取互斥组参数:{},请求路径:{}", String.valueOf(param), agvurl); try { HttpResponse result = HttpRequest.get(agvurl) .body(String.valueOf(param))//表单内容 .timeout(20000)//超时,毫秒 .execute(); String body = result.body(); - if (StrUtil.isNotEmpty(body)){ + if (StrUtil.isNotEmpty(body)) { JSONArray jsonArray = JSONArray.parseArray(result.body()); + log.info("获取互斥组参数:{},请求路径:{},响应参数{}", String.valueOf(param), agvurl, String.valueOf(jsonArray)); return jsonArray; } return null; } catch (Exception e) { + log.info("获取互斥组参数:{},请求路径:{},响应参数{}", String.valueOf(param), agvurl, e.getMessage()); return null; } diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/agv/ItemProtocol.java b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/agv/ItemProtocol.java index ba00d70..bb4989c 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/agv/ItemProtocol.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/agv/ItemProtocol.java @@ -23,15 +23,19 @@ public class ItemProtocol { public ItemProtocol(MaGangAgvDeviceDriver driver) { this.driver = driver; } + public int getStatus() { return this.getOpcIntegerValue(item_status); } + public int getType() { return this.getOpcIntegerValue(item_type); } + public int getX_coordinate() { return this.getOpcIntegerValue(item_x_coordinate); } + public int getY_coordinate() { return this.getOpcIntegerValue(item_y_coordinate); } @@ -52,19 +56,19 @@ public class ItemProtocol { public static List getReadableItemDtos() { ArrayList list = new ArrayList(); - list.add(new ItemDto(item_status, "AGV状态", "DB620.W0")); - list.add(new ItemDto(item_type, "AGV任务类型", "DB620.W2")); - list.add(new ItemDto(item_x_coordinate, "AGVx坐标", "DB620.W4")); - list.add(new ItemDto(item_y_coordinate, "AGVy坐标", "DB620.W6")); + list.add(new ItemDto(item_status, "AGV状态", "DB602.W0")); + list.add(new ItemDto(item_type, "AGV任务类型", "DB602.W2")); + list.add(new ItemDto(item_x_coordinate, "AGVx坐标", "DB602.W4")); + list.add(new ItemDto(item_y_coordinate, "AGVy坐标", "DB602.W6")); return list; } public static List getWriteableItemDtos() { ArrayList list = new ArrayList(); - list.add(new ItemDto(item_status, "AGV状态", "DB620.W0")); - list.add(new ItemDto(item_type, "AGV任务类型", "DB620.W2")); - list.add(new ItemDto(item_x_coordinate, "AGVx坐标", "DB620.W4")); - list.add(new ItemDto(item_y_coordinate, "AGVy坐标", "DB620.W6")); + list.add(new ItemDto(item_status, "AGV状态", "DB602.W0")); + list.add(new ItemDto(item_type, "AGV任务类型", "DB602.W2")); + list.add(new ItemDto(item_x_coordinate, "AGVx坐标", "DB602.W4")); + list.add(new ItemDto(item_y_coordinate, "AGVy坐标", "DB602.W6")); return list; } diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/agv/MaGangAgvDeviceDriver.java b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/agv/MaGangAgvDeviceDriver.java index 879679c..64f501a 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/agv/MaGangAgvDeviceDriver.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/agv/MaGangAgvDeviceDriver.java @@ -117,6 +117,7 @@ public class MaGangAgvDeviceDriver extends AbstractOpcDeviceDriver implements De Map itemMap = new HashMap(); itemMap.put(to_command, value); ReadUtil.write(itemMap, server); + log.info("设备号{},kep点位名称{},下发信号{}", this.getDevice().getDevice_code(), to_command, value); } diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/led/MaGangLedDeviceDriver.java b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/led/MaGangLedDeviceDriver.java index 5d56fac..07b0ae1 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/led/MaGangLedDeviceDriver.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/led/MaGangLedDeviceDriver.java @@ -114,6 +114,7 @@ public class MaGangLedDeviceDriver extends AbstractOpcDeviceDriver implements De Map itemMap = new HashMap(); itemMap.put(to_command, value); ReadUtil.write(itemMap, server); + log.info("设备号{},kep点位名称{},下发信号{}", this.getDevice().getDevice_code(), to_command, value); } diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/maGang/MaGangConveyorDeviceDriver.java b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/maGang/MaGangConveyorDeviceDriver.java index 349bae6..0559be4 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/maGang/MaGangConveyorDeviceDriver.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/maGang/MaGangConveyorDeviceDriver.java @@ -258,12 +258,13 @@ public class MaGangConveyorDeviceDriver extends AbstractOpcDeviceDriver implemen public void writing(int command) { String to_command = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() - + "." + org.nl.acs.device_driver.basedriver.standard_conveyor_control_with_scanner.ItemProtocol.item_to_command; + + "." + ItemProtocol.item_to_command; String opcservcerid = this.getDevice().getOpc_server_id(); Server server = ReadUtil.getServer(opcservcerid); Map itemMap = new HashMap(); itemMap.put(to_command, command); ReadUtil.write(itemMap, server); + log.info("设备号{},kep点位名称{},下发信号{}", this.getDevice().getDevice_code(), to_command, String.valueOf(command)); } public void writing(int type, int command) { @@ -277,6 +278,7 @@ public class MaGangConveyorDeviceDriver extends AbstractOpcDeviceDriver implemen log.info("设备:" + device_code + ",下发PLC信号" + to_command + ",value:" + command); } ReadUtil.write(itemMap, server); + log.info("设备号{},kep点位名称{},下发信号{}", this.getDevice().getDevice_code(), to_command, String.valueOf(command)); } public void writing(String type, String value) { @@ -287,6 +289,7 @@ public class MaGangConveyorDeviceDriver extends AbstractOpcDeviceDriver implemen Map itemMap = new HashMap(); itemMap.put(param, value); ReadUtil.write(itemMap, server); + log.info("设备号{},kep点位名称{},下发信号{}", this.getDevice().getDevice_code(), param, value); } @Override diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/impl/AgvToAcsServiceImpl.java b/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/impl/AgvToAcsServiceImpl.java index 95e7f4c..ad86808 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/impl/AgvToAcsServiceImpl.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/impl/AgvToAcsServiceImpl.java @@ -9,7 +9,6 @@ import org.nl.acs.device_driver.maGang.MaGangConveyorDeviceDriver; import org.nl.acs.ext.wms.service.AgvToAcsService; import org.nl.acs.instruction.service.InstructionService; import org.nl.acs.instruction.service.dto.Instruction; -import org.nl.acs.log.service.DeviceExecuteLogService; import org.nl.acs.opc.Device; import org.nl.acs.opc.DeviceAppService; import org.nl.modules.common.exception.BadRequestException; @@ -25,7 +24,6 @@ public class AgvToAcsServiceImpl implements AgvToAcsService { private final DeviceAppService deviceAppService; private final InstructionService instructionService; - private final DeviceExecuteLogService logService; @Override public Map waitpointRequest(JSONObject param) { @@ -33,15 +31,18 @@ public class AgvToAcsServiceImpl implements AgvToAcsService { String inst_code = param.getString("task_code"); //站点 String address = param.getString("address"); - //车号 - String vehicle_code = param.getString("device_code"); + log.info("请求等待点,请求路径:{},请求参数:{},指令号:{},站点:{}", "api/agv/waitpointRequest", String.valueOf(param), inst_code, address); String deviceCode = RouteUtil.getDeviceCode(address); Instruction instructionDto = instructionService.findByCodeFromCache(inst_code); if (ObjectUtil.isEmpty(instructionDto)) { - logService.deviceExecuteLog(deviceCode, vehicle_code, inst_code, "请求路径:api/agv/waitpointRequest,请求参数:" + param.toString() + ",请求失败-原因:指令任务号不存在! 指令号:" + inst_code); - throw new BadRequestException("请求失败,指令任务号不存在!"); + log.error("请求等待点,请求路径:{},请求参数:{},指令号:{},站点:{},请求失败:{}", "api/agv/waitpointRequest", String.valueOf(param), inst_code, address, "指令任务号不存在或指令已取消或者指令已完成!"); + throw new BadRequestException("指令任务号不存在或指令已取消或者指令已完成!"); } Device device = deviceAppService.findDeviceByCode(deviceCode); + if (ObjectUtil.isEmpty(device)) { + log.error("请求等待点,请求路径:{},请求参数:{},指令号:{},站点:{},请求失败:{}", "api/agv/waitpointRequest", String.valueOf(param), inst_code, address, "设备号:'" + deviceCode + "'有误,请检查!"); + throw new BadRequestException("设备号:'" + deviceCode + "'有误,请检查!"); + } MaGangConveyorDeviceDriver maGangConveyorDeviceDriver = (MaGangConveyorDeviceDriver) device.getDeviceDriver(); Map map = new HashMap<>(); map.put("status", 200); @@ -49,55 +50,55 @@ public class AgvToAcsServiceImpl implements AgvToAcsService { //取货点等待 if (address.contains("INGET")) { //告诉设备请求取货 - maGangConveyorDeviceDriver.writing(4); + maGangConveyorDeviceDriver.writing("to_command", "4"); //判断是否满足取货条件 if (maGangConveyorDeviceDriver.getMove() == 1 && maGangConveyorDeviceDriver.getAction() == 1) { //满足响应成功 - logService.deviceExecuteLog(deviceCode, vehicle_code, inst_code, "请求路径:api/agv/waitpointRequest,请求参数:" + param.toString() + ",请求成功-响应参数:" + map.toString()); + log.info("请求等待点,请求路径:{},请求参数:{},指令号:{},站点:{},响应参数:{}", "api/agv/waitpointRequest", String.valueOf(param), inst_code, address, String.valueOf(map)); return map; } else { //不满足抛异常 - logService.deviceExecuteLog(deviceCode, vehicle_code, inst_code, "请求路径:api/agv/waitpointRequest,请求参数:" + param.toString() + ",请求失败-原因:取货前-取货点无货!"); - throw new BadRequestException("请求失败,取货前-取货点无货!"); + log.error("请求等待点,请求路径:{},请求参数:{},指令号:{},站点:{},请求失败:{}", "api/agv/waitpointRequest", String.valueOf(param), inst_code, address, "不满足取货条件: move = 1 && action = 1"); + throw new BadRequestException("请求失败,不满足取货条件: move = 1 && action = 1"); } }//取货完成等待 else if (address.contains("OUTGET")) { //取货完成以后判断取货点是否有货 if (maGangConveyorDeviceDriver.getMove() == 0) { //无货告诉设备取货完成 - maGangConveyorDeviceDriver.writing(2); - logService.deviceExecuteLog(deviceCode, vehicle_code, inst_code, "请求路径:api/agv/waitpointRequest,请求参数:" + param.toString() + ",请求成功-响应参数:" + map.toString()); + maGangConveyorDeviceDriver.writing("to_command", "2"); + log.info("请求等待点,请求路径:{},请求参数:{},指令号:{},站点:{},响应参数:{}", "api/agv/waitpointRequest", String.valueOf(param), inst_code, address, String.valueOf(map)); return map; } else { //有货抛异常 - logService.deviceExecuteLog(deviceCode, vehicle_code, inst_code, "请求路径:api/agv/waitpointRequest,请求参数:" + param.toString() + ",请求失败-原因:取货完成后-取货点有货!"); - throw new BadRequestException("请求失败,取货完成后-取货点有货!"); + log.error("请求等待点,请求路径:{},请求参数:{},指令号:{},站点:{},请求失败:{}", "api/agv/waitpointRequest", String.valueOf(param), inst_code, address, "请求失败,取货完成后: move = 1!"); + throw new BadRequestException("请求失败,取货完成后: move = 1!"); } }//放货前等待 else if (address.contains("INPUT")) { //告诉设备请求放货 - maGangConveyorDeviceDriver.writing(5); + maGangConveyorDeviceDriver.writing("to_command", "5"); //判断是否满足放货信号 if (maGangConveyorDeviceDriver.getMove() == 0 && maGangConveyorDeviceDriver.getAction() == 2) { - logService.deviceExecuteLog(deviceCode, vehicle_code, inst_code, "请求路径:api/agv/waitpointRequest,请求参数:" + param.toString() + ",请求成功-响应参数:" + map.toString()); + log.info("请求等待点,请求路径:{},请求参数:{},指令号:{},站点:{},响应参数:{}", "api/agv/waitpointRequest", String.valueOf(param), inst_code, address, String.valueOf(map)); return map; } else { - logService.deviceExecuteLog(deviceCode, vehicle_code, inst_code, "请求路径:api/agv/waitpointRequest,请求参数:" + param.toString() + ",请求失败-原因:放货前-放货点有货!"); - throw new BadRequestException("请求失败,放货前-放货点有货!"); + log.error("请求等待点,请求路径:{},请求参数:{},指令号:{},站点:{},请求失败:{}", "api/agv/waitpointRequest", String.valueOf(param), inst_code, address, "放货前不满足放货条件: move = 0 && action = 2!"); + throw new BadRequestException("请求失败,放货前不满足放货条件: move = 0 && action = 2!"); } }//放货完成等待 else if (address.contains("OUTPUT")) { //放货完成后判断放货点是否有货 if (maGangConveyorDeviceDriver.getMove() == 1) { - maGangConveyorDeviceDriver.writing(3); - logService.deviceExecuteLog(deviceCode, vehicle_code, inst_code, "请求路径:api/agv/waitpointRequest,请求参数:" + param.toString() + ",请求成功-响应参数:" + map.toString()); + maGangConveyorDeviceDriver.writing("to_command", "3"); + log.info("请求等待点,请求路径:{},请求参数:{},指令号:{},站点:{},响应参数:{}", "api/agv/waitpointRequest", String.valueOf(param), inst_code, address, String.valueOf(map)); return map; } else { - logService.deviceExecuteLog(deviceCode, vehicle_code, inst_code, "请求路径:api/agv/waitpointRequest,请求参数:" + param.toString() + ",请求失败-原因:放货完成后-放货点无货!"); - throw new BadRequestException("请求失败,放货完成后-放货点无货!"); + log.error("请求等待点,请求路径:{},请求参数:{},指令号:{},站点:{},请求失败:{}", "api/agv/waitpointRequest", String.valueOf(param), inst_code, address, "放货完成后: move = 0 !"); + throw new BadRequestException("请求失败,放货完成后: move = 0!"); } } - logService.deviceExecuteLog(deviceCode, vehicle_code, inst_code, "请求路径:api/agv/waitpointRequest,请求参数:" + param.toString() + ",请求失败-原因:请求失败,地址有误! 地址:" + address); - throw new BadRequestException("请求失败,地址有误!"); + log.error("请求等待点,请求路径:{},请求参数:{},指令号:{},站点:{},请求失败:{}", "api/agv/waitpointRequest", String.valueOf(param), inst_code, address, "请求失败,地址:'" + address + "'->有误!"); + throw new BadRequestException("请求失败,地址:'" + address + "'->有误!"); } } diff --git a/acs/nladmin-system/src/main/resources/config/application-prod.yml b/acs/nladmin-system/src/main/resources/config/application-prod.yml index f3a02b0..b9595fb 100644 --- a/acs/nladmin-system/src/main/resources/config/application-prod.yml +++ b/acs/nladmin-system/src/main/resources/config/application-prod.yml @@ -6,9 +6,9 @@ spring: druid: db-type: com.alibaba.druid.pool.DruidDataSource driverClassName: net.sf.log4jdbc.sql.jdbcapi.DriverSpy - url: jdbc:log4jdbc:mysql://${DB_HOST:127.0.0.1}:${DB_PORT:3306}/${DB_NAME:nmd_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:magang_acs}?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false&useOldAliasMetadataBehavior=true username: ${DB_USER:root} - password: ${DB_PWD:123456} + password: ${DB_PWD:123} # 初始连接数 initial-size: 5 # 最小连接数 @@ -154,4 +154,4 @@ loki: systemName: acs agvToAcs: - addr: http://127.0.0.1:8010 + addr: http://192.168.0.214:8010 diff --git a/acs/nladmin-system/src/main/resources/config/application.yml b/acs/nladmin-system/src/main/resources/config/application.yml index 7e3fbea..a4d00ab 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: