From 6105d55575b95d751bca8f36680f5c5f266be0ea Mon Sep 17 00:00:00 2001 From: gengby <858962040@qq.com> Date: Thu, 8 Jun 2023 18:14:30 +0800 Subject: [PATCH] =?UTF-8?q?REV=20=E5=A2=9E=E5=8A=A0AGV=E8=AF=B7=E6=B1=82?= =?UTF-8?q?=E7=AD=89=E5=BE=85=E7=82=B9=E6=97=A5=E5=BF=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../driver/AbstractOpcDeviceDriver.java | 137 +----------------- .../StandardCoveyorControlDeviceDriver.java | 12 +- .../StandardConveyorLineDeviceDriver.java | 108 +++++++------- .../StandardInspectSiteDeviceDriver.java | 101 ++++++------- .../nl/acs/ext/wms/service/AgvWaitUtil.java | 79 ++++++---- .../wms/service/impl/AgvToAcsServiceImpl.java | 9 +- .../quartz/task/QueryXZAgvTaskStatus.java | 2 +- .../src/main/resources/log/AgvToAcs.xml | 35 +++++ .../src/main/resources/logback-spring.xml | 1 + 9 files changed, 209 insertions(+), 275 deletions(-) create mode 100644 hd/nladmin-system/src/main/resources/log/AgvToAcs.xml diff --git a/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/driver/AbstractOpcDeviceDriver.java b/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/driver/AbstractOpcDeviceDriver.java index b87ce71..6154335 100644 --- a/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/driver/AbstractOpcDeviceDriver.java +++ b/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/driver/AbstractOpcDeviceDriver.java @@ -16,7 +16,7 @@ import java.lang.reflect.Method; import java.util.HashMap; import java.util.Map; -public class AbstractOpcDeviceDriver extends AbstractDeviceDriver implements OpcDeviceDriver { +public class AbstractOpcDeviceDriver extends AbstractDeviceDriver implements OpcDeviceDriver { UnifiedDataAccessor opcUdw; public AbstractOpcDeviceDriver() { @@ -28,139 +28,4 @@ public class AbstractOpcDeviceDriver extends AbstractDeviceDriver implements return this.opcUdw; } - //信号值与上次值不一致时的日志 - public void writeLogInfo(String device_code, String name, int lastNumber, int nowNumber) { - if (lastNumber != nowNumber) { - this.execute_log.setResource(device_code, this.device.getDevice_name()); - this.execute_log.log("设备:" + device_code + ",last_'" + name + "' -> '" + name + "':" + lastNumber + "->" + nowNumber); - } - } - - //判断信号是否异常 - public synchronized void signalIsException(T sonDriver) { - Class sonDriverClass = sonDriver.getClass(); - try { - Method methodItemProtocol = sonDriverClass.getMethod("getItemProtocol"); - Object itemProtocol = methodItemProtocol.invoke(sonDriver); - String deviceCode = (String) sonDriverClass.getMethod("getDeviceCode").invoke(sonDriver); - //获取itemProtocol中所有属性 - Field[] fields = itemProtocol.getClass().getDeclaredFields(); - //遍历所有属性 - for (Field field : fields) { - //获取属性名字 - String fieldName = field.getName(); - if (fieldName.contains("item_")) { - if (!fieldName.contains("to_")) { - String fieldValue = (String) field.get(fieldName); - Method methodGet = null; - try { - methodGet = itemProtocol.getClass().getMethod("get" + initialUpperCase(fieldValue)); - } catch (Exception e) { - } - Integer itemValue = 0; - if (ObjectUtil.isNotEmpty(methodGet)) { - itemValue = (Integer) methodGet.invoke(itemProtocol); - } - if (!fieldValue.equals("heartbeat")) { - Method methodSet = null; - try { - methodSet = sonDriverClass.getMethod("set" + initialUpperCase(fieldValue), int.class); - } catch (Exception e) { - } - if (ObjectUtil.isNotEmpty(methodSet)) { - try { - methodSet.invoke(sonDriver, itemValue); - Integer last_Number = (Integer) sonDriverClass.getMethod("getLast_" + fieldValue).invoke(sonDriver); - Method writeLogInfo = sonDriverClass.getMethod("writeLogInfo", String.class, String.class, int.class, int.class); - writeLogInfo.invoke(sonDriver, deviceCode, fieldValue, last_Number, itemValue); - } catch (Exception e) { - } - } - } - } - } - } - - Method methodIsonline = sonDriverClass.getMethod("setIsonline", Boolean.class); - Method methodIserror = sonDriverClass.getMethod("setIserror", Boolean.class); - Method methodMessage = sonDriverClass.getMethod("setMessage", String.class); - Method methodMode = sonDriverClass.getMethod("getMode"); - Method methodError = sonDriverClass.getMethod("getError"); - Integer mode = (Integer) methodMode.invoke(sonDriver); - Integer error = (Integer) methodError.invoke(sonDriver); - Boolean isonline = (Boolean) itemProtocol.getClass().getMethod("getIsonline").invoke(itemProtocol); - - if (!isonline) { - methodIsonline.invoke(sonDriver, false); - methodIserror.invoke(sonDriver, true); - methodMessage.invoke(sonDriver, "信号量同步异常"); - } else if (mode == 0) { - methodIsonline.invoke(sonDriver, false); - methodIserror.invoke(sonDriver, true); - methodMessage.invoke(sonDriver, "未联机"); - } else if (error != 0) { - methodIsonline.invoke(sonDriver, false); - methodIserror.invoke(sonDriver, true); - methodMessage.invoke(sonDriver, "有报警"); - } else { - methodIsonline.invoke(sonDriver, true); - methodIserror.invoke(sonDriver, false); - //判断是否符合生成任务的条件 - Method methodIsSatisfyCreateTask = sonDriverClass.getMethod("isSatisfyCreateTask"); - String methodName = (String) methodIsSatisfyCreateTask.invoke(sonDriver); - if (StrUtil.isNotEmpty(methodName)) { - Method methodTask = null; - try { - methodTask = sonDriverClass.getMethod(methodName); - } catch (Exception e) { - - } - if (ObjectUtil.isNotEmpty(methodTask)) { - methodTask.invoke(sonDriver); - } - //sonDriverClass.getMethod(methodName).invoke(sonDriver); - } - - - } - //赋值last_属性 - Field[] declaredFields = sonDriverClass.getDeclaredFields(); - for (Field declaredField : declaredFields) { - String fieldName = declaredField.getName(); - Class fieldType = declaredField.getType(); - if (fieldType == int.class || fieldType == Integer.class) { - if (fieldName.contains("last_")) { - Method method = null; - try { - method = sonDriverClass.getMethod("set" + initialUpperCase(fieldName), int.class); - } catch (Exception e) { - - } - int index = fieldName.indexOf("last_"); - String subName = fieldName.substring(index + 5); - Method methodSub = null; - try { - methodSub = sonDriverClass.getMethod("get" + initialUpperCase(subName)); - } catch (Exception e) { - - } - int nowItemValue = 0; - if (ObjectUtil.isNotEmpty(methodSub)) { - nowItemValue = (int) methodSub.invoke(sonDriver); - } - if (ObjectUtil.isNotEmpty(method)) { - method.invoke(sonDriver, nowItemValue); - } - } - } - } - } catch (Exception e) { - e.printStackTrace(); - } - } - - //首字母转大写 - public String initialUpperCase(String str) { - return str.substring(0, 1).toUpperCase() + str.substring(1, str.length()); - } } diff --git a/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_conveyor_control/StandardCoveyorControlDeviceDriver.java b/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_conveyor_control/StandardCoveyorControlDeviceDriver.java index 6f2c5a3..d7b9dd1 100644 --- a/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_conveyor_control/StandardCoveyorControlDeviceDriver.java +++ b/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_conveyor_control/StandardCoveyorControlDeviceDriver.java @@ -1,14 +1,9 @@ package org.nl.acs.device_driver.standard_conveyor_control; -import cn.hutool.core.date.DateUtil; -import cn.hutool.core.util.IdUtil; -import cn.hutool.core.util.ObjectUtil; -import cn.hutool.core.util.StrUtil; + import lombok.Data; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; -import net.sf.json.JSONObject; -import org.nl.acs.config.AcsConfig; import org.nl.acs.config.server.AcsConfigService; import org.nl.acs.device.device_driver.standard_inspect.ReadUtil; import org.nl.acs.device.service.DeviceService; @@ -23,14 +18,9 @@ import org.nl.acs.instruction.service.dto.Instruction; import org.nl.acs.log.service.LogServer; import org.nl.acs.opc.Device; import org.nl.acs.opc.DeviceAppService; -import org.nl.acs.opc.WcsConfig; import org.nl.acs.route.service.RouteLineService; -import org.nl.acs.route.service.dto.RouteLineDto; import org.nl.acs.task.service.TaskService; -import org.nl.acs.task.service.dto.TaskDto; -import org.nl.modules.system.util.CodeUtil; import org.nl.utils.SpringContextHolder; -import org.nl.wql.core.bean.WQLObject; import org.openscada.opc.lib.da.Server; import org.springframework.beans.factory.annotation.Autowired; diff --git a/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_conveyor_line/StandardConveyorLineDeviceDriver.java b/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_conveyor_line/StandardConveyorLineDeviceDriver.java index 7bd1c86..7b65bc2 100644 --- a/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_conveyor_line/StandardConveyorLineDeviceDriver.java +++ b/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_conveyor_line/StandardConveyorLineDeviceDriver.java @@ -1,6 +1,5 @@ package org.nl.acs.device_driver.standard_conveyor_line; -import cn.hutool.core.util.ObjectUtil; import lombok.Data; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; @@ -21,6 +20,7 @@ import org.springframework.beans.factory.annotation.Autowired; import java.util.Date; import java.util.HashMap; +import java.util.List; import java.util.Map; /** @@ -118,27 +118,66 @@ public class StandardConveyorLineDeviceDriver extends AbstractOpcDeviceDriver im @Override public synchronized void execute() { - device_code = this.getDeviceCode(); - this.signalIsException(this); - } - - //判断是否符合生成任务的条件 - public String isSatisfyCreateTask() { - switch (flag) { - //取货完成 - case 1: - writing(2); - return null; - //放货完成 - case 2: - writing(3); - return null; - + try { + device_code = this.getDeviceCode(); + mode = this.itemProtocol.getMode(); + error = this.itemProtocol.getError(); + move = this.itemProtocol.getMove(); + action = this.itemProtocol.getAction(); + task = this.itemProtocol.getTask(); + if (mode != last_mode) { + this.execute_log.setResource(this.device_code, this.device_code); + this.execute_log.log("设备:" + device_code + ",last_mode -> mode:" + last_mode + "->" + mode); + } + if (error != last_error) { + this.execute_log.setResource(this.device_code, this.device_code); + this.execute_log.log("设备:" + device_code + ",last_error -> error:" + last_error + "->" + error); + } + if (move != last_move) { + this.execute_log.setResource(this.device_code, this.device_code); + this.execute_log.log("设备:" + device_code + ",last_move -> move:" + last_move + "->" + move); + } + if (action != last_action) { + this.execute_log.setResource(this.device_code, this.device_code); + this.execute_log.log("设备:" + device_code + ",last_action -> action:" + last_action + "->" + action); + } + if (task != last_task) { + this.execute_log.setResource(this.device_code, this.device_code); + this.execute_log.log("设备:" + device_code + ",last_task -> task:" + last_task + "->" + task); + } + }catch (Exception e){ + return; } - return "createTask"; - } + if (1 > 2) { +// this.setIsonline(false); +// this.setIserror(true); +// message = "信号量同步异常"; +// //未联机 +// } else if (mode == 0) { +// this.setIsonline(false); +// this.setIserror(true); +// message = "未联机"; +// //有报警 +// } else if (error != 0) { +// this.setIsonline(false); +// this.setIserror(true); +// message = "有报警"; +// //无报警 + } else { + this.setIsonline(true); + this.setIserror(false); + message = ""; + Instruction instruction = null; + List toInstructions; + } + last_mode = mode; + last_error = error; + last_move = move; + last_action = action; + last_task = task; + } public boolean exe_business() { return true; @@ -208,37 +247,6 @@ public class StandardConveyorLineDeviceDriver extends AbstractOpcDeviceDriver im } - public void writeLogInfo(String device_code, String name, int lastNumber, int nowNumber) { - super.writeLogInfo(device_code, name, lastNumber, nowNumber); - if (lastNumber != nowNumber) { - if (name.equals("mode")) { - this.setRequireSucess(false); - } - } - } - - public String getStringValue(String key, int value) { - Map> map = new HashMap<>(); - Map modeMap = new HashMap<>(); - modeMap.put(0, "脱机"); - modeMap.put(1, ""); - modeMap.put(2, "待机"); - map.put("mode", modeMap); - Map moveMap = new HashMap<>(); - moveMap.put(0, "无货"); - moveMap.put(1, "有货"); - map.put("move", moveMap); - Map valuesMap = map.get(key); - if (ObjectUtil.isNotEmpty(valuesMap)) { - for (Map.Entry entry : valuesMap.entrySet()) { - if (value == (Integer) entry.getKey()) { - return (String) entry.getValue(); - } - } - } - return null; - } - @Override public String toString() { return ""; diff --git a/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_inspect_site/StandardInspectSiteDeviceDriver.java b/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_inspect_site/StandardInspectSiteDeviceDriver.java index 4d53dfd..6149249 100644 --- a/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_inspect_site/StandardInspectSiteDeviceDriver.java +++ b/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_inspect_site/StandardInspectSiteDeviceDriver.java @@ -51,10 +51,12 @@ public class StandardInspectSiteDeviceDriver extends AbstractOpcDeviceDriver imp int error = 0; int move = 0; int task = 0; + int io_action = 0; int last_mode = 0; int last_error = 0; int last_move = 0; int last_task = 0; + int last_io_action = 0; Boolean isonline = true; int hasGoods = 0; String message = null; @@ -114,27 +116,62 @@ public class StandardInspectSiteDeviceDriver extends AbstractOpcDeviceDriver imp @Override public synchronized void execute() { - device_code = this.getDeviceCode(); - this.signalIsException(this); - } + String message = null; + try { + device_code = this.getDeviceCode(); + mode = this.itemProtocol.getMode(); + error = this.itemProtocol.getError(); + move = this.itemProtocol.getMove(); + io_action = this.itemProtocol.getIoaction(); + task = this.itemProtocol.getTask(); + hasGoods = this.itemProtocol.getMove(); + if (mode != last_mode) { + this.execute_log.setResource(this.device_code, this.device.getDevice_name()); + this.execute_log.log("设备:" + device_code + ",last_mode -> mode:" + last_mode + "->" + mode); + } + if (move != last_move) { + this.execute_log.setResource(this.device_code, this.device.getDevice_name()); + this.execute_log.log("设备:" + device_code + ",last_move -> move:" + last_mode + "->" + move); + } + + } catch (Exception var17) { - //判断是否符合生成任务的条件 - public String isSatisfyCreateTask(){ - switch (flag) { - //取货完成 - case 1: - writing(2); - return ""; - //放货完成 - case 2: - writing(3); - return ""; } - return ""; + + if (mode == 0) { + this.setIsonline(false); + message = "未联机"; + //有报警 + + } else { + this.setIsonline(true); + this.setIserror(false); + if (error != 0) { + this.setIserror(true); + message = "有报警"; + } + message = ""; + Instruction instruction = null; + List toInstructions; + switch (mode) { + case 1: + log.debug("设备运转模式:等待工作"); + return; + case 2: + break; + } + + } + last_mode = mode; + last_error = error; + last_move = move; + last_io_action = io_action; + last_task = task; } + protected void executing(Instruction instruction) { this.executing(1, instruction, ""); } @@ -198,41 +235,7 @@ public class StandardInspectSiteDeviceDriver extends AbstractOpcDeviceDriver imp } - public void writeLogInfo(String device_code, String name, int lastNumber, int nowNumber) { - super.writeLogInfo(device_code, name, lastNumber, nowNumber); - if (lastNumber != nowNumber) { - if (name.equals("mode")) { - this.setRequireSucess(false); - } - } - } - public String getStringValue(String key,int value){ - Map> map = new HashMap<>(); - Map modeMap = new HashMap<>(); - modeMap.put(0,"脱机"); - modeMap.put(1,""); - modeMap.put(2,"待机"); - map.put("mode",modeMap); - Map moveMap = new HashMap<>(); - moveMap.put(0,"无货"); - moveMap.put(1,"有货"); - moveMap.put(2,"有托盘有货"); - map.put("move",moveMap); - for(Map.Entry entry:map.entrySet()){ - if (key == (String) entry.getKey()){ - Map valuesMap = map.get(key); - if (ObjectUtil.isNotEmpty(valuesMap)){ - for(Map.Entry entryV:valuesMap.entrySet()){ - if (value == (Integer)entryV.getKey()){ - return (String) entryV.getValue(); - } - } - } - } - } - return null; - } @Override public String toString() { diff --git a/hd/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/AgvWaitUtil.java b/hd/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/AgvWaitUtil.java index f5d097c..a1f3b38 100644 --- a/hd/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/AgvWaitUtil.java +++ b/hd/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/AgvWaitUtil.java @@ -54,19 +54,22 @@ public class AgvWaitUtil { map.put("status", 200); map.put("message", "请求成功"); type = "info"; - logServer.log(task_code, "waitpointRequest", type, param.toString(), String.valueOf(map), "200", "api/agv/waitpointRequest", instructionDto.getVehicle_code()); + log.info("任务号:{},请求方法:{},请求参数:{},响应参数:{},响应状态:{},请求路径:{},载具号:{}", task_code, "waitpointRequest", param.toString(), map.toString(), "200", "api/agv/waitpointRequest", instructionDto.getVehicle_code()); + //logServer.log(task_code, "waitpointRequest", type, param.toString(), String.valueOf(map), "200", "api/agv/waitpointRequest", instructionDto.getVehicle_code()); } else { map.put("status", responseCode); map.put("message", responseMessage); type = "erro"; - logServer.log(task_code, "feedbackTask", type, param.toString(), String.valueOf(map), "400", "/restful/api/v3/feedbackTask", instructionDto.getVehicle_code()); + log.error("任务号:{},请求方法:{},请求参数:{},响应参数:{},响应状态:{},请求路径:{},载具号:{}", task_code, "feedbackTask", param.toString(), map.toString(), "400", "/restful/api/v3/feedbackTask", instructionDto.getVehicle_code()); + //logServer.log(task_code, "feedbackTask", type, param.toString(), String.valueOf(map), "400", "/restful/api/v3/feedbackTask", instructionDto.getVehicle_code()); throw new BadRequestException("请求失败!"); } } else { map.put("status", 400); map.put("message", "请求失败,起点位置无货或其他信号不满足取货条件!move = " + standardConveyorLineDeviceDriver.getMove() + "action = " + standardConveyorLineDeviceDriver.getAction()); type = "erro"; - logServer.log(task_code, "waitpointRequest", type, param.toString(), String.valueOf(map), "400", "api/agv/waitpointRequest", instructionDto.getVehicle_code()); + log.error("任务号:{},请求方法:{},请求参数:{},响应参数:{},响应状态:{},请求路径:{},载具号:{}", task_code, "waitpointRequest", param.toString(), map.toString(), "400", "api/agv/waitpointRequest", instructionDto.getVehicle_code()); + //logServer.log(task_code, "waitpointRequest", type, param.toString(), String.valueOf(map), "400", "api/agv/waitpointRequest", instructionDto.getVehicle_code()); throw new BadRequestException("请求失败,起点位置无货!"); } } @@ -77,10 +80,10 @@ public class AgvWaitUtil { int byAction = standardCoveyorControlDeviceDriver.getByAction(); if (byError == 0 && bySignal == 1 && byAction == 0) { standardCoveyorControlDeviceDriver.writing(1, "0"); + log.info("任务号:{},设备号:{},在请求取货前等待下发信号0成功", task_code, standardCoveyorControlDeviceDriver.getDevice_code()); feedMap.put("feedbackStatus", "applyTake"); Map feedback = acsToWmsZDService.taskFeedback(feedMap); int responseCode = Integer.parseInt(String.valueOf(feedback.get("responseCode"))); - String responseMessage = String.valueOf(feedback.get("responseMessage")); if (responseCode == 0) { feedMap.put("feedbackStatus", "taking"); @@ -88,19 +91,22 @@ public class AgvWaitUtil { map.put("status", 200); map.put("message", "请求成功"); type = "info"; - logServer.log(task_code, "waitpointRequest", type, param.toString(), String.valueOf(map), "200", "api/agv/waitpointRequest", instructionDto.getVehicle_code()); + log.info("任务号:{},请求方法:{},请求参数:{},响应参数:{},响应状态:{},请求路径:{},载具号:{}", task_code, "waitpointRequest", param.toString(), map.toString(), "200", "api/agv/waitpointRequest", instructionDto.getVehicle_code()); + //logServer.log(task_code, "waitpointRequest", type, param.toString(), String.valueOf(map), "200", "api/agv/waitpointRequest", instructionDto.getVehicle_code()); } else { map.put("status", responseCode); map.put("message", responseMessage); type = "erro"; - logServer.log(task_code, "feedbackTask", type, param.toString(), String.valueOf(map), "400", "/restful/api/v3/feedbackTask", instructionDto.getVehicle_code()); + log.error("任务号:{},请求方法:{},请求参数:{},响应参数:{},响应状态:{},请求路径:{},载具号:{}", task_code, "feedbackTask", param.toString(), map.toString(), "400", "/restful/api/v3/feedbackTask", instructionDto.getVehicle_code()); + //logServer.log(task_code, "feedbackTask", type, param.toString(), String.valueOf(map), "400", "/restful/api/v3/feedbackTask", instructionDto.getVehicle_code()); throw new BadRequestException("请求失败!"); } } else { map.put("status", 400); map.put("message", "请求失败,起点位置无货或其他信号不满足取货条件!move = " + bySignal + ",action = " + byAction + ",error = " + byError); type = "erro"; - logServer.log(task_code, "waitpointRequest", type, param.toString(), String.valueOf(map), "400", "api/agv/waitpointRequest", instructionDto.getVehicle_code()); + log.error("任务号:{},请求方法:{},请求参数:{},响应参数:{},响应状态:{},请求路径:{},载具号:{}", task_code, "waitpointRequest", param.toString(), map.toString(), "400", "api/agv/waitpointRequest", instructionDto.getVehicle_code()); + //logServer.log(task_code, "waitpointRequest", type, param.toString(), String.valueOf(map), "400", "api/agv/waitpointRequest", instructionDto.getVehicle_code()); throw new BadRequestException("请求失败,起点位置无货!"); } } @@ -121,6 +127,7 @@ public class AgvWaitUtil { standardConveyorLineDeviceDriver = (StandardConveyorLineDeviceDriver) device.getDeviceDriver(); if (standardConveyorLineDeviceDriver.getMove() == 0) { standardConveyorLineDeviceDriver.writing(2); + log.info("任务号:{},设备号:{},在请求取货完成等待下发信号2成功", task_code, standardConveyorLineDeviceDriver.getDevice_code()); feedMap.put("feedbackStatus", "takeFinish"); Map feedback = acsToWmsZDService.taskFeedback(feedMap); int responseCode = Integer.parseInt(String.valueOf(feedback.get("responseCode"))); @@ -129,19 +136,22 @@ public class AgvWaitUtil { map.put("status", 200); map.put("message", "请求成功"); type = "info"; - logServer.log(task_code, "waitpointRequest", type, param.toString(), String.valueOf(map), "200", "api/agv/waitpointRequest", instructionDto.getVehicle_code()); + log.info("任务号:{},请求方法:{},请求参数:{},响应参数:{},响应状态:{},请求路径:{},载具号:{}", task_code, "waitpointRequest", param.toString(), map.toString(), "200", "api/agv/waitpointRequest", instructionDto.getVehicle_code()); + //logServer.log(task_code, "waitpointRequest", type, param.toString(), String.valueOf(map), "200", "api/agv/waitpointRequest", instructionDto.getVehicle_code()); } else { map.put("status", responseCode); map.put("message", responseMessage); type = "erro"; - logServer.log(task_code, "feedbackTask", type, param.toString(), String.valueOf(map), "400", "/restful/api/v3/feedbackTask", instructionDto.getVehicle_code()); + log.error("任务号:{},请求方法:{},请求参数:{},响应参数:{},响应状态:{},请求路径:{},载具号:{}", task_code, "feedbackTask", param.toString(), map.toString(), "400", "/restful/api/v3/feedbackTask", instructionDto.getVehicle_code()); + //logServer.log(task_code, "feedbackTask", type, param.toString(), String.valueOf(map), "400", "/restful/api/v3/feedbackTask", instructionDto.getVehicle_code()); throw new BadRequestException("请求失败!"); } } else { map.put("status", 400); map.put("message", "请求失败,取货完成后,起点位置仍有货!move=" + standardConveyorLineDeviceDriver.getMove()); type = "erro"; - logServer.log(task_code, "waitpointRequest", type, param.toString(), String.valueOf(map), "400", "api/agv/waitpointRequest", instructionDto.getVehicle_code()); + log.error("任务号:{},请求方法:{},请求参数:{},响应参数:{},响应状态:{},请求路径:{},载具号:{}", task_code, "waitpointRequest", param.toString(), map.toString(), "400", "api/agv/waitpointRequest", instructionDto.getVehicle_code()); + //logServer.log(task_code, "waitpointRequest", type, param.toString(), String.valueOf(map), "400", "api/agv/waitpointRequest", instructionDto.getVehicle_code()); throw new BadRequestException("请求失败,起点位置有货!"); } } @@ -149,6 +159,7 @@ public class AgvWaitUtil { standardCoveyorControlDeviceDriver = (StandardCoveyorControlDeviceDriver) device.getDeviceDriver(); if (standardCoveyorControlDeviceDriver.getBySignal() == 0) { standardCoveyorControlDeviceDriver.writing(1, "2"); + log.info("任务号:{},设备号:{},在请求取货完成等待下发信号2成功", task_code, standardCoveyorControlDeviceDriver.getDevice_code()); feedMap.put("feedbackStatus", "takeFinish"); Map feedback = acsToWmsZDService.taskFeedback(feedMap); int responseCode = Integer.parseInt(String.valueOf(feedback.get("responseCode"))); @@ -157,19 +168,22 @@ public class AgvWaitUtil { map.put("status", 200); map.put("message", "请求成功"); type = "info"; - logServer.log(task_code, "waitpointRequest", type, param.toString(), String.valueOf(map), "200", "api/agv/waitpointRequest", instructionDto.getVehicle_code()); + log.info("任务号:{},请求方法:{},请求参数:{},响应参数:{},响应状态:{},请求路径:{},载具号:{}", task_code, "waitpointRequest", param.toString(), map.toString(), "200", "api/agv/waitpointRequest", instructionDto.getVehicle_code()); + //logServer.log(task_code, "waitpointRequest", type, param.toString(), String.valueOf(map), "200", "api/agv/waitpointRequest", instructionDto.getVehicle_code()); } else { map.put("status", responseCode); map.put("message", responseMessage); type = "erro"; - logServer.log(task_code, "feedbackTask", type, param.toString(), String.valueOf(map), "400", "/restful/api/v3/feedbackTask", instructionDto.getVehicle_code()); + log.error("任务号:{},请求方法:{},请求参数:{},响应参数:{},响应状态:{},请求路径:{},载具号:{}", task_code, "feedbackTask", param.toString(), map.toString(), "400", "/restful/api/v3/feedbackTask", instructionDto.getVehicle_code()); + //logServer.log(task_code, "feedbackTask", type, param.toString(), String.valueOf(map), "400", "/restful/api/v3/feedbackTask", instructionDto.getVehicle_code()); throw new BadRequestException("请求失败!"); } } else { map.put("status", 400); map.put("message", "请求失败,取货完成后,起点位置仍有货!move=" + standardCoveyorControlDeviceDriver.getBySignal()); type = "erro"; - logServer.log(task_code, "waitpointRequest", type, param.toString(), String.valueOf(map), "400", "api/agv/waitpointRequest", instructionDto.getVehicle_code()); + log.error("任务号:{},请求方法:{},请求参数:{},响应参数:{},响应状态:{},请求路径:{},载具号:{}", task_code, "waitpointRequest", param.toString(), map.toString(), "400", "api/agv/waitpointRequest", instructionDto.getVehicle_code()); + //logServer.log(task_code, "waitpointRequest", type, param.toString(), String.valueOf(map), "400", "api/agv/waitpointRequest", instructionDto.getVehicle_code()); throw new BadRequestException("请求失败,取货完成后起点位置有货!"); } } @@ -200,19 +214,22 @@ public class AgvWaitUtil { map.put("status", 200); map.put("message", "请求成功"); type = "info"; - logServer.log(task_code, "waitpointRequest", type, param.toString(), String.valueOf(map), "200", "api/agv/waitpointRequest", instructionDto.getVehicle_code()); + log.info("任务号:{},请求方法:{},请求参数:{},响应参数:{},响应状态:{},请求路径:{},载具号:{}", task_code, "waitpointRequest", param.toString(), map.toString(), "200", "api/agv/waitpointRequest", instructionDto.getVehicle_code()); + //logServer.log(task_code, "waitpointRequest", type, param.toString(), String.valueOf(map), "200", "api/agv/waitpointRequest", instructionDto.getVehicle_code()); } else { map.put("status", responseCode); map.put("message", responseMessage); type = "erro"; - logServer.log(task_code, "feedbackTask", type, param.toString(), String.valueOf(map), "400", "/restful/api/v3/feedbackTask", instructionDto.getVehicle_code()); + log.error("任务号:{},请求方法:{},请求参数:{},响应参数:{},响应状态:{},请求路径:{},载具号:{}", task_code, "feedbackTask", param.toString(), map.toString(), "400", "/restful/api/v3/feedbackTask", instructionDto.getVehicle_code()); + //logServer.log(task_code, "feedbackTask", type, param.toString(), String.valueOf(map), "400", "/restful/api/v3/feedbackTask", instructionDto.getVehicle_code()); throw new BadRequestException("请求失败!"); } } else { map.put("status", 400); map.put("message", "请求失败,终点位置有货或其他信号不满足放货条件!move = " + standardConveyorLineDeviceDriver.getMove() + "action = " + standardConveyorLineDeviceDriver.getAction()); type = "erro"; - logServer.log(task_code, "waitpointRequest", type, param.toString(), String.valueOf(map), "400", "api/agv/waitpointRequest", instructionDto.getVehicle_code()); + log.error("任务号:{},请求方法:{},请求参数:{},响应参数:{},响应状态:{},请求路径:{},载具号:{}", task_code, "waitpointRequest", param.toString(), map.toString(), "400", "api/agv/waitpointRequest", instructionDto.getVehicle_code()); + // logServer.log(task_code, "waitpointRequest", type, param.toString(), String.valueOf(map), "400", "api/agv/waitpointRequest", instructionDto.getVehicle_code()); throw new BadRequestException("请求失败,终点位置有货或不允许放货!"); } } @@ -223,6 +240,7 @@ public class AgvWaitUtil { int byAction = standardCoveyorControlDeviceDriver.getByAction(); if (byError == 0 && bySignal == 0 && byAction == 0) { standardCoveyorControlDeviceDriver.writing(1, "0"); + log.info("任务号:{},设备号:{},在请求放货前等待下发信号0成功", task_code, standardCoveyorControlDeviceDriver.getDevice_code()); feedMap.put("feedbackStatus", "applyPut"); Map feedback = acsToWmsZDService.taskFeedback(feedMap); int responseCode = Integer.parseInt(String.valueOf(feedback.get("responseCode"))); @@ -234,19 +252,22 @@ public class AgvWaitUtil { map.put("status", 200); map.put("message", "请求成功"); type = "info"; - logServer.log(task_code, "waitpointRequest", type, param.toString(), String.valueOf(map), "200", "api/agv/waitpointRequest", instructionDto.getVehicle_code()); + log.info("任务号:{},请求方法:{},请求参数:{},响应参数:{},响应状态:{},请求路径:{},载具号:{}", task_code, "waitpointRequest", param.toString(), map.toString(), "200", "api/agv/waitpointRequest", instructionDto.getVehicle_code()); + //logServer.log(task_code, "waitpointRequest", type, param.toString(), String.valueOf(map), "200", "api/agv/waitpointRequest", instructionDto.getVehicle_code()); } else { map.put("status", responseCode); map.put("message", responseMessage); type = "erro"; - logServer.log(task_code, "feedbackTask", type, param.toString(), String.valueOf(map), "400", "/restful/api/v3/feedbackTask", instructionDto.getVehicle_code()); + log.error("任务号:{},请求方法:{},请求参数:{},响应参数:{},响应状态:{},请求路径:{},载具号:{}", task_code, "feedbackTask", param.toString(), map.toString(), "400", "/restful/api/v3/feedbackTask", instructionDto.getVehicle_code()); + //logServer.log(task_code, "feedbackTask", type, param.toString(), String.valueOf(map), "400", "/restful/api/v3/feedbackTask", instructionDto.getVehicle_code()); throw new BadRequestException("请求失败!"); } } else { map.put("status", 400); map.put("message", "请求失败,终点位置有货或其他信号不满足放货条件!move = " + bySignal + ",action = " + byAction + ",error = " + byError); type = "erro"; - logServer.log(task_code, "waitpointRequest", type, param.toString(), String.valueOf(map), "400", "api/agv/waitpointRequest", instructionDto.getVehicle_code()); + log.error("任务号:{},请求方法:{},请求参数:{},响应参数:{},响应状态:{},请求路径:{},载具号:{}", task_code, "waitpointRequest", param.toString(), map.toString(), "400", "api/agv/waitpointRequest", instructionDto.getVehicle_code()); + //logServer.log(task_code, "waitpointRequest", type, param.toString(), String.valueOf(map), "400", "api/agv/waitpointRequest", instructionDto.getVehicle_code()); throw new BadRequestException("请求失败,终点位置有货!"); } } @@ -268,6 +289,7 @@ public class AgvWaitUtil { standardConveyorLineDeviceDriver = (StandardConveyorLineDeviceDriver) device.getDeviceDriver(); if (standardConveyorLineDeviceDriver.getMove() == 1) { standardConveyorLineDeviceDriver.writing(3); + log.info("任务号:{},设备号:{},在请求放货完成等待下发信号3成功", task_code, standardConveyorLineDeviceDriver.getDevice_code()); feedMap.put("feedbackStatus", "putFinish"); Map feedback = acsToWmsZDService.taskFeedback(feedMap); int responseCode = Integer.parseInt(String.valueOf(feedback.get("responseCode"))); @@ -277,19 +299,22 @@ public class AgvWaitUtil { map.put("status", 200); map.put("message", "请求成功"); type = "info"; - logServer.log(task_code, "waitpointRequest", type, param.toString(), String.valueOf(map), "200", "api/agv/waitpointRequest", instructionDto.getVehicle_code()); + log.info("任务号:{},请求方法:{},请求参数:{},响应参数:{},响应状态:{},请求路径:{},载具号:{}", task_code, "waitpointRequest", param.toString(), map.toString(), "200", "api/agv/waitpointRequest", instructionDto.getVehicle_code()); + //logServer.log(task_code, "waitpointRequest", type, param.toString(), String.valueOf(map), "200", "api/agv/waitpointRequest", instructionDto.getVehicle_code()); } else { map.put("status", responseCode); map.put("message", responseMessage); type = "erro"; - logServer.log(task_code, "feedbackTask", type, param.toString(), String.valueOf(map), "400", "/restful/api/v3/feedbackTask", instructionDto.getVehicle_code()); + log.error("任务号:{},请求方法:{},请求参数:{},响应参数:{},响应状态:{},请求路径:{},载具号:{}", task_code, "feedbackTask", param.toString(), map.toString(), "400", "/restful/api/v3/feedbackTask", instructionDto.getVehicle_code()); + //logServer.log(task_code, "feedbackTask", type, param.toString(), String.valueOf(map), "400", "/restful/api/v3/feedbackTask", instructionDto.getVehicle_code()); throw new BadRequestException("请求失败"); } } else { map.put("status", 400); map.put("message", "请求失败,放货货完成后,终点位置仍无货!move=" + standardConveyorLineDeviceDriver.getMove()); type = "erro"; - logServer.log(task_code, "waitpointRequest", type, param.toString(), String.valueOf(map), "400", "api/agv/waitpointRequest", instructionDto.getVehicle_code()); + log.error("任务号:{},请求方法:{},请求参数:{},响应参数:{},响应状态:{},请求路径:{},载具号:{}", task_code, "waitpointRequest", param.toString(), map.toString(), "400", "api/agv/waitpointRequest", instructionDto.getVehicle_code()); + //logServer.log(task_code, "waitpointRequest", type, param.toString(), String.valueOf(map), "400", "api/agv/waitpointRequest", instructionDto.getVehicle_code()); throw new BadRequestException("请求失败,放货货完成后,终点位置仍无货!"); } } @@ -297,6 +322,7 @@ public class AgvWaitUtil { standardCoveyorControlDeviceDriver = (StandardCoveyorControlDeviceDriver) device.getDeviceDriver(); if (standardCoveyorControlDeviceDriver.getBySignal() == 1) { standardCoveyorControlDeviceDriver.writing(1, "3"); + log.info("任务号:{},设备号:{},在请求放货完成等待下发信号3成功", task_code, standardCoveyorControlDeviceDriver.getDevice_code()); feedMap.put("feedbackStatus", "putFinish"); Map feedback = acsToWmsZDService.taskFeedback(feedMap); int responseCode = Integer.parseInt(String.valueOf(feedback.get("responseCode"))); @@ -305,19 +331,22 @@ public class AgvWaitUtil { map.put("status", 200); map.put("message", "请求成功"); type = "info"; - logServer.log(task_code, "waitpointRequest", type, param.toString(), String.valueOf(map), "200", "api/agv/waitpointRequest", instructionDto.getVehicle_code()); + log.info("任务号:{},请求方法:{},请求参数:{},响应参数:{},响应状态:{},请求路径:{},载具号:{}", task_code, "waitpointRequest", param.toString(), map.toString(), "200", "api/agv/waitpointRequest", instructionDto.getVehicle_code()); + //logServer.log(task_code, "waitpointRequest", type, param.toString(), String.valueOf(map), "200", "api/agv/waitpointRequest", instructionDto.getVehicle_code()); } else { map.put("status", responseCode); map.put("message", responseMessage); type = "erro"; - logServer.log(task_code, "feedbackTask", type, param.toString(), String.valueOf(map), "400", "/restful/api/v3/feedbackTask", instructionDto.getVehicle_code()); + log.error("任务号:{},请求方法:{},请求参数:{},响应参数:{},响应状态:{},请求路径:{},载具号:{}", task_code, "feedbackTask", param.toString(), map.toString(), "400", "/restful/api/v3/feedbackTask", instructionDto.getVehicle_code()); + //logServer.log(task_code, "feedbackTask", type, param.toString(), String.valueOf(map), "400", "/restful/api/v3/feedbackTask", instructionDto.getVehicle_code()); throw new BadRequestException("请求失败"); } } else { map.put("status", 400); map.put("message", "请求失败,放货货完成后,终点位置仍无货!move=" + standardCoveyorControlDeviceDriver.getBySignal()); type = "erro"; - logServer.log(task_code, "waitpointRequest", type, param.toString(), String.valueOf(map), "400", "api/agv/waitpointRequest", instructionDto.getVehicle_code()); + log.error("任务号:{},请求方法:{},请求参数:{},响应参数:{},响应状态:{},请求路径:{},载具号:{}", task_code, "waitpointRequest", param.toString(), map.toString(), "400", "api/agv/waitpointRequest", instructionDto.getVehicle_code()); + //logServer.log(task_code, "waitpointRequest", type, param.toString(), String.valueOf(map), "400", "api/agv/waitpointRequest", instructionDto.getVehicle_code()); throw new BadRequestException("请求失败,放货货完成后,终点位置仍无货!"); } } diff --git a/hd/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/impl/AgvToAcsServiceImpl.java b/hd/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/impl/AgvToAcsServiceImpl.java index c8f24e9..788c410 100644 --- a/hd/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/impl/AgvToAcsServiceImpl.java +++ b/hd/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/impl/AgvToAcsServiceImpl.java @@ -36,10 +36,12 @@ public class AgvToAcsServiceImpl implements AgvToAcsService { if (ObjectUtil.isEmpty(instructionDto)) { map.put("status", 400); map.put("message", "请求失败,指令为空!"); - logServer.log("", "waitpointRequest", "erro", param.toString(), String.valueOf(map), "400", "api/agv/waitpointRequest", ""); + log.error("任务号:{},请求方法:{},请求参数:{},响应参数:{},响应状态:{},请求路径:{},载具号:{}", inst_code, "waitpointRequest", param.toString(), map.toString(), "400", "api/agv/waitpointRequest", instructionDto.getVehicle_code()); + //logServer.log("", "waitpointRequest", "erro", param.toString(), String.valueOf(map), "400", "api/agv/waitpointRequest", ""); throw new BadRequestException("请求失败,指令为空!"); } - logServer.log(inst_code, "waitpointRequest", "info", param.toString(), String.valueOf(map) + "请求等待点!", "200", "api/agv/waitpointRequest", ""); + log.info("任务号:{},请求成功!", inst_code); + //logServer.log(inst_code, "waitpointRequest", "info", param.toString(), String.valueOf(map) + "请求等待点!", "200", "api/agv/waitpointRequest", ""); String task_code = instructionDto.getTask_code(); Map feedMap = new HashMap(); feedMap.put("taskCode", task_code); @@ -65,7 +67,8 @@ public class AgvToAcsServiceImpl implements AgvToAcsService { } map.put("status", 400); map.put("message", "请求失败,IN OUT 站点错误!"); - logServer.log(task_code, "waitpointRequest", "erro", param.toString(), String.valueOf(map), "400", "api/agv/waitpointRequest", instructionDto.getVehicle_code()); + log.error("任务号:{},请求方法:{},请求参数:{},响应参数:{},响应状态:{},请求路径:{},载具号:{}", inst_code, "waitpointRequest", param.toString(), map.toString(), "400", "api/agv/waitpointRequest", instructionDto.getVehicle_code()); + //logServer.log(task_code, "waitpointRequest", "erro", param.toString(), String.valueOf(map), "400", "api/agv/waitpointRequest", instructionDto.getVehicle_code()); throw new BadRequestException("请求失败,IN OUT 站点错误!"); } } diff --git a/hd/nladmin-system/src/main/java/org/nl/modules/quartz/task/QueryXZAgvTaskStatus.java b/hd/nladmin-system/src/main/java/org/nl/modules/quartz/task/QueryXZAgvTaskStatus.java index 7201cb9..b8ea35a 100644 --- a/hd/nladmin-system/src/main/java/org/nl/modules/quartz/task/QueryXZAgvTaskStatus.java +++ b/hd/nladmin-system/src/main/java/org/nl/modules/quartz/task/QueryXZAgvTaskStatus.java @@ -87,7 +87,7 @@ public class QueryXZAgvTaskStatus { } } else if ("STOPPED".equals(state) || "FAILED".equals(state) || "Error".equals(state)) { if (inst != null) { - inst.setInstruction_status("4"); + inst.setInstruction_status("1"); instructionService.update(inst); } } else { diff --git a/hd/nladmin-system/src/main/resources/log/AgvToAcs.xml b/hd/nladmin-system/src/main/resources/log/AgvToAcs.xml new file mode 100644 index 0000000..ee9781d --- /dev/null +++ b/hd/nladmin-system/src/main/resources/log/AgvToAcs.xml @@ -0,0 +1,35 @@ + + + + + + + + + ${LOG_HOME}/AGV请求等待点/%d{yyyy-MM-dd}.%i.log + + 15 + + 200MB + + 20GB + + + + %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n + + + + + + + + + + + + + + diff --git a/hd/nladmin-system/src/main/resources/logback-spring.xml b/hd/nladmin-system/src/main/resources/logback-spring.xml index 4773f1d..12df59c 100644 --- a/hd/nladmin-system/src/main/resources/logback-spring.xml +++ b/hd/nladmin-system/src/main/resources/logback-spring.xml @@ -26,6 +26,7 @@ https://juejin.cn/post/6844903775631572999 +