Browse Source

REV 增加AGV请求等待点日志

master
gengby 1 year ago
parent
commit
6105d55575
  1. 137
      hd/nladmin-system/src/main/java/org/nl/acs/device_driver/driver/AbstractOpcDeviceDriver.java
  2. 12
      hd/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_conveyor_control/StandardCoveyorControlDeviceDriver.java
  3. 108
      hd/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_conveyor_line/StandardConveyorLineDeviceDriver.java
  4. 101
      hd/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_inspect_site/StandardInspectSiteDeviceDriver.java
  5. 79
      hd/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/AgvWaitUtil.java
  6. 9
      hd/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/impl/AgvToAcsServiceImpl.java
  7. 2
      hd/nladmin-system/src/main/java/org/nl/modules/quartz/task/QueryXZAgvTaskStatus.java
  8. 35
      hd/nladmin-system/src/main/resources/log/AgvToAcs.xml
  9. 1
      hd/nladmin-system/src/main/resources/logback-spring.xml

137
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<T> extends AbstractDeviceDriver implements OpcDeviceDriver {
public class AbstractOpcDeviceDriver extends AbstractDeviceDriver implements OpcDeviceDriver {
UnifiedDataAccessor opcUdw;
public AbstractOpcDeviceDriver() {
@ -28,139 +28,4 @@ public class AbstractOpcDeviceDriver<T> 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());
}
}

12
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;

108
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<String, Map<Integer, String>> map = new HashMap<>();
Map<Integer, String> modeMap = new HashMap<>();
modeMap.put(0, "脱机");
modeMap.put(1, "");
modeMap.put(2, "待机");
map.put("mode", modeMap);
Map<Integer, String> moveMap = new HashMap<>();
moveMap.put(0, "无货");
moveMap.put(1, "有货");
map.put("move", moveMap);
Map<Integer, String> 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 "";

101
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<String,Map<Integer,String>> map = new HashMap<>();
Map<Integer,String> modeMap = new HashMap<>();
modeMap.put(0,"脱机");
modeMap.put(1,"");
modeMap.put(2,"待机");
map.put("mode",modeMap);
Map<Integer,String> 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<Integer, String> 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() {

79
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<String, Object> 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<String, Object> 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<String, Object> 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<String, Object> 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<String, Object> 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<String, Object> 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("请求失败,放货货完成后,终点位置仍无货!");
}
}

9
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<String, Object> 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 站点错误!");
}
}

2
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 {

35
hd/nladmin-system/src/main/resources/log/AgvToAcs.xml

@ -0,0 +1,35 @@
<?xml version="1.0" encoding="UTF-8"?>
<included>
<springProperty scope="context" name="logPath" source="logging.file.path" defaultValue="logs"/>
<property name="LOG_HOME" value="${logPath}"/>
<!-- 按照每天生成日志文件 -->
<appender name="FILE10" class="ch.qos.logback.core.rolling.RollingFileAppender">
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<!--日志文件输出的文件名-->
<FileNamePattern>${LOG_HOME}/AGV请求等待点/%d{yyyy-MM-dd}.%i.log</FileNamePattern>
<!--日志文件保留天数-->
<maxHistory>15</maxHistory>
<!--单个日志最大容量 至少10MB才能看得出来-->
<maxFileSize>200MB</maxFileSize>
<!--所有日志最多占多大容量-->
<totalSizeCap>20GB</totalSizeCap>
</rollingPolicy>
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<!--格式化输出:%d表示日期,%thread表示线程名,%-5level:级别从左显示5个字符宽度%msg:日志消息,%n是换行符-->
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n</pattern>
</encoder>
</appender>
<!-- <logger name="org.nl.start.Init" level="info" additivity="false">
<appender-ref ref="FILE3"/>
</logger>-->
<!-- 打印sql -->
<logger name="org.nl.acs.ext.wms.service.impl.AgvToAcsServiceImpl" level="info" additivity="false">
<appender-ref ref="FILE10"/>
</logger>
<logger name="org.nl.acs.ext.wms.service.AgvWaitUtil" level="info" additivity="false">
<appender-ref ref="FILE10"/>
</logger>
</included>

1
hd/nladmin-system/src/main/resources/logback-spring.xml

@ -26,6 +26,7 @@ https://juejin.cn/post/6844903775631572999
<include resource="log/QueryXZAgvTaskStatus.xml"/>
<include resource="log/NDCSocketConnectionAutoRun.xml"/>
<include resource="log/ScannerBarcode.xml"/>
<include resource="log/AgvToAcs.xml"/>
<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">

Loading…
Cancel
Save