Browse Source

add 日志

master
周俊杰 1 year ago
parent
commit
673f4dbbb5
  1. 41
      acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/agv/ndcone/AgvNdcOneDeviceDriver.java
  2. 2
      acs/nladmin-system/src/main/java/org/nl/acs/log/service/impl/DeviceExecuteLogServiceImpl.java
  3. 2
      acs/nladmin-system/src/main/resources/log/AgvNdcOneDeviceDriver.xml
  4. 39
      acs/nladmin-system/src/main/resources/log/NDCAgvServiceImpl.xml
  5. 1
      acs/nladmin-system/src/main/resources/logback-spring.xml

41
acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/agv/ndcone/AgvNdcOneDeviceDriver.java

@ -119,6 +119,7 @@ public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements Devic
//车号
int carno = arr[20];
logService.deviceExecuteLog(this.device_code, "", "", "接收agv上报信息:" + "phase--" + phase + " index--" + index + " 指令号--" + ikey + " 站点号--" + agvaddr + " 车号--" + carno);
log.info("接收agv上报信息:" + "phase--" + phase + " index--" + index + " ikey--" + ikey + " agvaddr--" + agvaddr + " Car--" + carno);
lucene.deviceExecuteLog(new LuceneLogDto(this.device_code, "接收agv上报信息:" + "phase--" + phase + " index--" + index + " 指令号--" + ikey + " 站点号--" + agvaddr + " 车号--" + carno));
Instruction link_inst = null;
List<Instruction> insts = null;
@ -176,15 +177,16 @@ public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements Devic
inst.setCarno(String.valueOf(carno));
instructionService.update(inst);
logService.deviceExecuteLog(this.device_code, "", "", "agvphase:" + phase + "反馈车号:" + carno + ",指令号:" + ikey);
log.info("{},{}", device_code, "agvphase:" + phase + "反馈车号:" + carno + ",指令号:" + ikey);
lucene.deviceExecuteLog(new LuceneLogDto(this.device_code, "agvphase:" + phase + "反馈车号:" + carno + ",指令号:" + ikey));
//到达取货点
//(需要WCS反馈)
} else if (phase == 0x03) {
log.info("==================AGV请求取货==================");
if (ObjectUtil.isEmpty(inst)) {
log.info("未找到指令:" + ikey);
logService.deviceExecuteLog(device_code, "", "", "未找到指令 [" + ikey + "]");
log.info("{},{}", device_code, "未找到指令 [" + ikey + "]");
lucene.deviceExecuteLog(new LuceneLogDto(this.device_code, "未找到指令 [" + ikey + "]"));
return;
}
@ -193,6 +195,7 @@ public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements Devic
}
if (agvaddr < 1) {
logService.deviceExecuteLog(this.device_code, "", "", "agv地址参数有误,phase:" + phase);
log.info("{},{}", device_code, "agv地址参数有误,phase:" + phase);
lucene.deviceExecuteLog(new LuceneLogDto(this.device_code, "agv地址参数有误,phase:" + phase));
return;
}
@ -223,6 +226,7 @@ public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements Devic
log.info("未找到编号{}对应的指令", ikey);
agv_message = "未找到编号"+ikey +"对应的指令";
logService.deviceExecuteLog(this.device_code, "", "", "未找到关联编号对应的指令" + ikey);
log.info("{},{}", device_code, "未找到关联编号对应的指令" + ikey);
lucene.deviceExecuteLog(new LuceneLogDto(this.device_code, "未找到关联编号对应的指令" + ikey));
return;
}
@ -258,6 +262,7 @@ public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements Devic
lnshPalletizingManipulatorSiteDeviceDriver.setMessage(message);
agv_message = lnshPalletizingManipulatorSiteDeviceDriver.getDevice_code() + message;
logService.deviceExecuteLog(device_code, "", "", message);
log.info("{},{}", device_code,message);
lucene.deviceExecuteLog(new LuceneLogDto(this.device_code, message));
}
}
@ -292,6 +297,7 @@ public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements Devic
lnshStationDeviceDriver.setMessage(message);
agv_message = lnshStationDeviceDriver.getDevice_code() + message;
logService.deviceExecuteLog(device_code, "", "", message);
log.info("{},{}", device_code,message);
lucene.deviceExecuteLog(new LuceneLogDto(this.device_code, message));
}
}
@ -326,6 +332,7 @@ public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements Devic
conveyorPressStationDeviceDriver.setMessage(message);
agv_message = conveyorPressStationDeviceDriver.getDevice_code() + message;
logService.deviceExecuteLog(device_code, "", "", message);
log.info("{},{}", device_code,message);
lucene.deviceExecuteLog(new LuceneLogDto(this.device_code, message));
}
}
@ -344,6 +351,7 @@ public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements Devic
flag = true;
} else {
logService.deviceExecuteLog(device_code, "", "", "AGV请求取货设备{}无货,无法反馈");
log.info("{},{}", device_code,"AGV请求取货设备{}无货,无法反馈");
lucene.deviceExecuteLog(new LuceneLogDto(this.device_code, "AGV请求取货设备{}无货,无法反馈"));
}
}
@ -372,6 +380,7 @@ public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements Devic
conveyorBarcodeDeviceDriver.setMessage(message);
agv_message = conveyorBarcodeDeviceDriver.getDevice_code() + message;
logService.deviceExecuteLog(device_code, "", "", message);
log.info("{},{}", device_code,message);
lucene.deviceExecuteLog(new LuceneLogDto(this.device_code, message));
}
}
@ -408,6 +417,7 @@ public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements Devic
agv_device.setStatus_message(agv_message);
lnshFoldDiscSiteDeviceDriver.setMessage(message);
logService.deviceExecuteLog(device_code, "", "", message);
log.info("{},{}", device_code,message);
lucene.deviceExecuteLog(new LuceneLogDto(this.device_code, message));
}
}
@ -425,6 +435,7 @@ public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements Devic
if (flag) {
log.info("==================允许AGV取货==================");
logService.deviceExecuteLog(device_code, "", "", "允许AGV取货。");
log.info("{},{}", device_code,"允许AGV取货。");
lucene.deviceExecuteLog(new LuceneLogDto(this.device_code, "允许AGV取货。"));
}
//取货完毕
@ -434,6 +445,7 @@ public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements Devic
if (ObjectUtil.isEmpty(inst)) {
log.info("未找到指令:" + ikey);
logService.deviceExecuteLog(device_code, "", "", "未找到指令 [" + ikey + "]");
log.info("{},{}", device_code,"未找到指令 [" + ikey + "]");
lucene.deviceExecuteLog(new LuceneLogDto(this.device_code, "未找到指令 [" + ikey + "]"));
return;
}
@ -442,6 +454,7 @@ public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements Devic
}
if (agvaddr < 1) {
logService.deviceExecuteLog(this.device_code, "", "", "agv地址参数有误,phase:" + phase);
log.info("{},{}", device_code,"agv地址参数有误,phase:" + phase);
lucene.deviceExecuteLog(new LuceneLogDto(this.device_code, "agv地址参数有误,phase:" + phase));
return;
}
@ -463,6 +476,7 @@ public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements Devic
if (ObjectUtil.isEmpty(device_code)) {
log.info(agvaddr + "对应设备号为空!");
logService.deviceExecuteLog(this.device_code, "", "", "对应设备号为空" + device_code);
log.info("{},{}", device_code,"对应设备号为空" + device_code);
lucene.deviceExecuteLog(new LuceneLogDto(this.device_code, "对应设备号为空" + device_code));
return;
}
@ -470,6 +484,7 @@ public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements Devic
if (ObjectUtil.isEmpty(inst)) {
log.info("未找到关联编号{}对应的指令", ikey);
logService.deviceExecuteLog(this.device_code, "", "", "未找到关联编号对应的指令" + ikey);
log.info("{},{}", device_code,"未找到关联编号对应的指令" + ikey);
lucene.deviceExecuteLog(new LuceneLogDto(this.device_code, "未找到关联编号对应的指令" + ikey));
return;
}
@ -502,6 +517,7 @@ public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements Devic
lnshPalletizingManipulatorSiteDeviceDriver.setMessage(message);
agv_message = lnshPalletizingManipulatorSiteDeviceDriver.getDevice_code() + message;
logService.deviceExecuteLog(device_code, "", "", message);
log.info("{},{}", device_code,message);
lucene.deviceExecuteLog(new LuceneLogDto(this.device_code, message));
}
}
@ -534,6 +550,7 @@ public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements Devic
lnshStationDeviceDriver.setMessage(message);
agv_message = lnshStationDeviceDriver.getDevice_code() + message;
logService.deviceExecuteLog(device_code, "", "", message);
log.info("{},{}", device_code,message);
lucene.deviceExecuteLog(new LuceneLogDto(this.device_code, message));
}
}
@ -566,6 +583,7 @@ public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements Devic
conveyorPressStationDeviceDriver.setMessage(message);
agv_message = conveyorPressStationDeviceDriver.getDevice_code() + message;
logService.deviceExecuteLog(device_code, "", "", message);
log.info("{},{}", device_code,message);
lucene.deviceExecuteLog(new LuceneLogDto(this.device_code, message));
}
}
@ -611,6 +629,7 @@ public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements Devic
conveyorBarcodeDeviceDriver.setMessage(message);
agv_message = conveyorBarcodeDeviceDriver.getDevice_code() + message;
logService.deviceExecuteLog(device_code, "", "", message);
log.info("{},{}", device_code,message);
lucene.deviceExecuteLog(new LuceneLogDto(this.device_code, message));
}
}
@ -643,6 +662,7 @@ public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements Devic
lnshFoldDiscSiteDeviceDriver.setMessage(message);
agv_message = lnshFoldDiscSiteDeviceDriver.getDevice_code() + message;
logService.deviceExecuteLog(device_code, "", "", message);
log.info("{},{}", device_code,message);
lucene.deviceExecuteLog(new LuceneLogDto(this.device_code, message));
}
}
@ -663,6 +683,7 @@ public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements Devic
}
if (ObjectUtil.isNotEmpty(data)) {
logService.deviceExecuteLog(this.device_code, "", "", "agvphase:" + phase + "反馈:" + Bytes2HexString(data));
log.info("{},{}", device_code,"agvphase:" + phase + "反馈:" + Bytes2HexString(data));
lucene.deviceExecuteLog(new LuceneLogDto(this.device_code, "agvphase:" + phase + "反馈:" + Bytes2HexString(data)));
}
// if (flag) {
@ -684,6 +705,7 @@ public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements Devic
if (flag) {
log.info("================允许AGV取货后离开=================");
logService.deviceExecuteLog(device_code, "", "", "允许AGV取货后离开。");
log.info("{},{}", device_code,"允许AGV取货后离开。");
lucene.deviceExecuteLog(new LuceneLogDto(this.device_code, "允许AGV取货后离开。"));
}
//到达放货点
@ -693,6 +715,7 @@ public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements Devic
if (ObjectUtil.isEmpty(inst)) {
log.info("未找到指令:" + ikey);
logService.deviceExecuteLog(device_code, "", "", "未找到指令 [" + ikey + "]");
log.info("{},{}", device_code,"未找到指令 [" + ikey + "]");
lucene.deviceExecuteLog(new LuceneLogDto(this.device_code, "未找到指令 [" + ikey + "]"));
return;
}
@ -701,6 +724,7 @@ public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements Devic
}
if (agvaddr < 1) {
logService.deviceExecuteLog(this.device_code, "", "", "agv地址参数有误,phase:" + phase);
log.info("{},{}", device_code,"agv地址参数有误,phase:" + phase);
lucene.deviceExecuteLog(new LuceneLogDto(this.device_code, "agv地址参数有误,phase:" + phase));
return;
}
@ -759,6 +783,7 @@ public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements Devic
agv_message = lnshPalletizingManipulatorSiteDeviceDriver.getDevice_code() + message;
lnshPalletizingManipulatorSiteDeviceDriver.setMessage(message);
logService.deviceExecuteLog(device_code, "", "", message);
log.info("{},{}", device_code,message);
lucene.deviceExecuteLog(new LuceneLogDto(this.device_code, message));
}
}
@ -794,6 +819,7 @@ public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements Devic
lnshStationDeviceDriver.setMessage(message);
agv_message = lnshStationDeviceDriver.getDevice_code() + message;
logService.deviceExecuteLog(device_code, "", "", message);
log.info("{},{}", device_code,message);
lucene.deviceExecuteLog(new LuceneLogDto(this.device_code, message));
}
}
@ -829,6 +855,7 @@ public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements Devic
conveyorPressStationDeviceDriver.setMessage(message);
agv_message = conveyorPressStationDeviceDriver.getDevice_code() + message;
logService.deviceExecuteLog(device_code, "", "", message);
log.info("{},{}", device_code,message);
lucene.deviceExecuteLog(new LuceneLogDto(this.device_code, message));
}
}
@ -871,6 +898,7 @@ public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements Devic
conveyorBarcodeDeviceDriver.setMessage(message);
agv_message = conveyorBarcodeDeviceDriver.getDevice_code() + message;
logService.deviceExecuteLog(device_code, "", "", message);
log.info("{},{}", device_code,message);
lucene.deviceExecuteLog(new LuceneLogDto(this.device_code, message));
}
}
@ -907,6 +935,7 @@ public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements Devic
lnshFoldDiscSiteDeviceDriver.setMessage(message);
agv_message = lnshFoldDiscSiteDeviceDriver.getDevice_code() + message;
logService.deviceExecuteLog(device_code, "", "", message);
log.info("{},{}", device_code,message);
lucene.deviceExecuteLog(new LuceneLogDto(this.device_code, message));
}
}
@ -926,6 +955,7 @@ public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements Devic
if (flag) {
log.info("==================允许AGV放货==================");
logService.deviceExecuteLog(device_code, "", "", "允许AGV放货。");
log.info("{},{}", device_code,"允许AGV放货。");
lucene.deviceExecuteLog(new LuceneLogDto(this.device_code, "允许AGV放货。"));
}
@ -936,6 +966,7 @@ public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements Devic
if (ObjectUtil.isEmpty(inst)) {
log.info("未找到指令:" + ikey);
logService.deviceExecuteLog("未找到指令号对应的指令:", "", "", String.valueOf(ikey));
log.info("{},{}", "未找到指令号对应的指令:",String.valueOf(ikey));
lucene.deviceExecuteLog(new LuceneLogDto(this.device_code, String.valueOf(ikey)));
return;
}
@ -944,6 +975,7 @@ public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements Devic
}
if (agvaddr < 1) {
logService.deviceExecuteLog(this.device_code, "", "", "agv地址参数有误,phase:" + phase);
log.info("{},{}", device_code,"agv地址参数有误,phase:" + phase);
lucene.deviceExecuteLog(new LuceneLogDto(this.device_code, "agv地址参数有误,phase:" + phase));
return;
}
@ -999,6 +1031,7 @@ public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements Devic
lnshPalletizingManipulatorSiteDeviceDriver.setMessage(message);
agv_message = lnshPalletizingManipulatorSiteDeviceDriver.getDevice_code() + message;
logService.deviceExecuteLog(device_code, "", "", message);
log.info("{},{}", device_code,message);
lucene.deviceExecuteLog(new LuceneLogDto(this.device_code, message));
}
}
@ -1030,6 +1063,7 @@ public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements Devic
lnshStationDeviceDriver.setMessage(message);
agv_message = lnshStationDeviceDriver.getDevice_code() + message;
logService.deviceExecuteLog(device_code, "", "", message);
log.info("{},{}", device_code,message);
lucene.deviceExecuteLog(new LuceneLogDto(this.device_code, message));
}
}
@ -1076,6 +1110,7 @@ public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements Devic
conveyorPressStationDeviceDriver.setMessage(message);
agv_message = conveyorPressStationDeviceDriver.getDevice_code() + message;
logService.deviceExecuteLog(device_code, "", "", message);
log.info("{},{}", device_code,message);
lucene.deviceExecuteLog(new LuceneLogDto(this.device_code, message));
}
}
@ -1124,6 +1159,7 @@ public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements Devic
agv_message = conveyorBarcodeDeviceDriver.getDevice_code() + message;
conveyorBarcodeDeviceDriver.setMessage(message);
logService.deviceExecuteLog(device_code, "", "", message);
log.info("{},{}", device_code,message);
lucene.deviceExecuteLog(new LuceneLogDto(this.device_code, message));
}
}
@ -1156,12 +1192,14 @@ public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements Devic
lnshFoldDiscSiteDeviceDriver.setMessage(message);
agv_message = lnshFoldDiscSiteDeviceDriver.getDevice_code() + message;
logService.deviceExecuteLog(device_code, "", "", message);
log.info("{},{}", device_code,message);
lucene.deviceExecuteLog(new LuceneLogDto(this.device_code, message));
}
}
if (flag) {
log.info("================允许AGV放货后离开=================");
logService.deviceExecuteLog(device_code, "", "", "允许AGV放货后离开。");
log.info("{},{}", device_code,"允许AGV放货后离开。");
lucene.deviceExecuteLog(new LuceneLogDto(this.device_code, "允许AGV放货后离开。"));
}
}
@ -1207,6 +1245,7 @@ public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements Devic
if (!ObjectUtil.isEmpty(data)) {
phase = 0;
logService.deviceExecuteLog(this.device_code, "", "", "agvphase:" + phase + "反馈:" + Bytes2HexString(data));
log.info("{},{}", device_code,"agvphase:" + phase + "反馈:" + Bytes2HexString(data));
lucene.deviceExecuteLog(new LuceneLogDto(this.device_code, "agvphase:" + phase + "反馈:" + Bytes2HexString(data)));
NDCSocketConnectionAutoRun.write(data);
}

2
acs/nladmin-system/src/main/java/org/nl/acs/log/service/impl/DeviceExecuteLogServiceImpl.java

@ -31,7 +31,7 @@ public class DeviceExecuteLogServiceImpl implements DeviceExecuteLogService {
public void deviceExecuteLog(String device_code, String vehicle_code, String inst_code, String message) {
try {
MDC.put("device_code_log", device_code);
log.info("{} - {}", device_code, message);
log.info("{},{}", device_code, message);
} catch (Throwable t) {
log.error("设备日志报错", t);
} finally {

2
acs/nladmin-system/src/main/resources/log/AgvNdcOneDeviceDriver.xml

@ -6,7 +6,7 @@
<appender name="AgvNdcOneDeviceDriver" class="ch.qos.logback.core.rolling.RollingFileAppender">
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<!--日志文件输出的文件名-->
<FileNamePattern>${LOG_HOME}/AGVNDC交互/%d{yyyy-MM-dd}.%i.log</FileNamePattern>
<FileNamePattern>${LOG_HOME}/AGV驱动与NDC交互/%d{yyyy-MM-dd}.%i.log</FileNamePattern>
<!--日志文件保留天数-->
<maxHistory>15</maxHistory>
<!--单个日志最大容量 至少10MB才能看得出来-->

39
acs/nladmin-system/src/main/resources/log/NDCAgvServiceImpl.xml

@ -1,14 +1,33 @@
<?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="NDCAgvServiceImpl" class="ch.qos.logback.core.rolling.RollingFileAppender">
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<!--日志文件输出的文件名-->
<FileNamePattern>${LOG_HOME}/NDCAGV服务/%d{yyyy-MM-dd}.%i.log</FileNamePattern>
<!--日志文件保留天数-->
<maxHistory>15</maxHistory>
<!--单个日志最大容量 至少10MB才能看得出来-->
<maxFileSize>200MB</maxFileSize>
<!--所有日志最多占多大容量-->
<totalSizeCap>2GB</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>
<charset>${log.charset}</charset>
</encoder>
<?import java.lang.*?>
<?import java.util.*?>
<?import javafx.scene.*?>
<?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?>
</appender>
<AnchorPane xmlns="http://javafx.com/javafx"
xmlns:fx="http://javafx.com/fxml"
fx:controller="$CONTROLLER_NAME$"
prefHeight="400.0" prefWidth="600.0">
<!-- <logger name="org.nl.start.Init" level="info" additivity="false">
<appender-ref ref="FILE3"/>
</logger>-->
</AnchorPane>
<!-- 打印sql -->
<logger name="org.nl.acs.agv.server.impl.NDCAgvServiceImpl" level="info" additivity="false">
<appender-ref ref="NDCAgvServiceImpl"/>
</logger>
</included>

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

@ -27,6 +27,7 @@ https://juejin.cn/post/6844903775631572999
<include resource="log/NDCSocketConnectionAutoRun.xml"/>
<include resource="log/Lucene.xml"/>
<include resource="log/AgvNdcOneDeviceDriver.xml"/>
<include resource="log/NDCAgvServiceImpl.xml"/>
<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
<encoder>

Loading…
Cancel
Save