打印日志

This commit is contained in:
张江玮
2023-03-27 18:41:55 +08:00
parent 1b26f269e3
commit 130f819f1f
11 changed files with 63 additions and 47 deletions

View File

@@ -319,7 +319,7 @@ public class LnshLaminatingMachineDeviceDriver extends AbstractOpcDeviceDriver i
if (ObjectUtil.isNotEmpty(result)) {
JSONObject jsonObject = JSONObject.parseObject(result.body());
if (result.getStatus() == 200 && StrUtil.equals(jsonObject.get("status").toString(),"200")) {
// this.writing(mode);
this.writing(this.mode);
this.setRequireSucess(true);
this.setResult(true);
}
@@ -435,7 +435,7 @@ public class LnshLaminatingMachineDeviceDriver extends AbstractOpcDeviceDriver i
Map<String, Object> itemMap = new HashMap<String, Object>();
itemMap.put(to_command, command);
ReadUtil.write(itemMap, server);
logServer.deviceExecuteLog(this.device_code, "", "", to_command + " 写入 " + command);
}
public void writing(int type, int command) {
@@ -450,11 +450,13 @@ public class LnshLaminatingMachineDeviceDriver extends AbstractOpcDeviceDriver i
Map<String, Object> itemMap = new HashMap<String, Object>();
if (type == 1) {
itemMap.put(to_command, command);
logServer.deviceExecuteLog(this.device_code, "", "", to_command + " 写入 " + command);
} else if (type == 2) {
itemMap.put(to_target, command);
logServer.deviceExecuteLog(this.device_code, "", "", to_target + " 写入 " + command);
} else if (type == 3) {
itemMap.put(to_task, command);
logServer.deviceExecuteLog(this.device_code, "", "", to_task + " 写入 " + command);
}
ReadUtil.write(itemMap, server);
@@ -470,6 +472,7 @@ public class LnshLaminatingMachineDeviceDriver extends AbstractOpcDeviceDriver i
itemMap.put(to_param,value);
ReadUtil.write(itemMap, server);
logServer.deviceExecuteLog(this.device_code, "", "", to_param + " 写入 " + value);
}
public static Boolean isExistFieldName(String fieldName, Object obj) throws NoSuchFieldException {

View File

@@ -337,6 +337,7 @@ public class LnshKilnLaneDeviceDriver extends AbstractOpcDeviceDriver implements
itemMap.put(to_param, Integer.parseInt(value));
}
ReadUtil.write(itemMap, server);
logServer.deviceExecuteLog(this.device_code, "", "", to_param + " 写入 " + value);
}
public void executing(Server server, Map<String, Object> itemMap) {
@@ -352,6 +353,7 @@ public class LnshKilnLaneDeviceDriver extends AbstractOpcDeviceDriver implements
Map<String, Object> itemMap = new HashMap<String, Object>();
itemMap.put(to_command, command);
ReadUtil.write(itemMap, server);
logServer.deviceExecuteLog(this.device_code, "", "", to_command + " 写入 " + command);
}

View File

@@ -223,6 +223,7 @@ public class LnshLabelingMachineDeviceDriver extends AbstractOpcDeviceDriver imp
itemMap.put(to_param, value);
ReadUtil.write(itemMap, server);
logServer.deviceExecuteLog(this.device_code, "", "", to_param + " 写入 " + value);
}
@Override

View File

@@ -1313,7 +1313,7 @@ public class LnshPackagePalletManipulatorDeviceDriver extends AbstractOpcDeviceD
Map<String, Object> itemMap = new HashMap<String, Object>();
itemMap.put(to_command, command);
ReadUtil.write(itemMap, server);
logServer.deviceExecuteLog(this.device_code, "", "", to_command + " 写入 " + command);
}
public String autoGenericCode(String vehicle_code) {
@@ -1330,6 +1330,7 @@ public class LnshPackagePalletManipulatorDeviceDriver extends AbstractOpcDeviceD
itemMap.put(to_param, value);
ReadUtil.write(itemMap, server);
logServer.deviceExecuteLog(this.device_code, "", "", to_param + " 写入 " + value);
}
@Override

View File

@@ -615,6 +615,7 @@ public class LnshPalletizingManipulatorDeviceDriver extends AbstractOpcDeviceDri
itemMap.put(to_param, value);
ReadUtil.write(itemMap, server);
logServer.deviceExecuteLog(this.device_code, "", "", to_param + " 写入 " + value);
}
public void writing(int command) {
@@ -625,6 +626,7 @@ public class LnshPalletizingManipulatorDeviceDriver extends AbstractOpcDeviceDri
Map<String, Object> itemMap = new HashMap<String, Object>();
itemMap.put(to_command, command);
ReadUtil.write(itemMap, server);
logServer.deviceExecuteLog(this.device_code, "", "", to_command + " 写入 " + command);
}
public synchronized void OpenOrClose(String type) {

View File

@@ -392,9 +392,9 @@ public class LnshPalletizingManipulatorSiteDeviceDriver extends AbstractOpcDevic
json.put("device_code",this.device_code);
json.put("type","4");
// json.put("vehicle_code",barcode);
logServer.deviceExecuteLog(device_code, String.valueOf(barcode), "", "申请空盘请求参数:" + json);
logServer.deviceExecuteLog(device_code, "", "", "申请空盘请求参数:" + json);
HttpResponse result = acsToWmsService.lnshApplyTaskToWms(json);
logServer.deviceExecuteLog(device_code, String.valueOf(barcode), "", "申请空盘返回参数:" + result);
logServer.deviceExecuteLog(device_code, "", "", "申请空盘返回参数:" + result);
if (ObjectUtil.isNotEmpty(result)) {
JSONObject jsonObject = JSONObject.parseObject(result.body());
if (result.getStatus() == 200 && StrUtil.equals(jsonObject.getString("status"),"200")) {
@@ -418,9 +418,9 @@ public class LnshPalletizingManipulatorSiteDeviceDriver extends AbstractOpcDevic
return false;
} else {
this.instruction_require_time = date;
logServer.deviceExecuteLog(device_code, String.valueOf(barcode), "", "排产单确认请求参数:" + json);
logServer.deviceExecuteLog(device_code, "", "", "排产单确认请求参数:" + json);
HttpResponse result = acsToWmsService.enterOrder(json);
logServer.deviceExecuteLog(device_code, String.valueOf(barcode), "", "排产单确认返回参数:" + result);
logServer.deviceExecuteLog(device_code, "", "", "排产单确认返回参数:" + result);
if (ObjectUtil.isNotEmpty(result)) {
JSONObject jsonObject = JSONObject.parseObject(result.body());
if (result.getStatus() == 200 && StrUtil.equals(jsonObject.getString("status"),"200")) {
@@ -463,9 +463,9 @@ public class LnshPalletizingManipulatorSiteDeviceDriver extends AbstractOpcDevic
json.put("producetask_code",order_No);
json.put("unqualified_qty",unqualified_qty);
json.put("is_full","1");
logServer.deviceExecuteLog(device_code, String.valueOf(barcode), "", "码垛完成请求参数:" + json);
logServer.deviceExecuteLog(device_code, "", "", "码垛完成请求参数:" + json);
HttpResponse result = acsToWmsService.applyTaskManipulatorToWms(json);
logServer.deviceExecuteLog(device_code, String.valueOf(barcode), "", "码垛完成返回参数:" + result);
logServer.deviceExecuteLog(device_code, "", "", "码垛完成返回参数:" + result);
if (ObjectUtil.isNotEmpty(result)) {
JSONObject jsonObject = JSONObject.parseObject(result.body());
if (result.getStatus() == 200 && StrUtil.equals(jsonObject.getString("status"),"200")) {
@@ -501,9 +501,9 @@ public class LnshPalletizingManipulatorSiteDeviceDriver extends AbstractOpcDevic
json.put("batch",batch);
json.put("producetask_code",order_No);
json.put("is_full","0");
logServer.deviceExecuteLog(device_code, String.valueOf(barcode), "", "码垛强制完成请求参数:" + json);
logServer.deviceExecuteLog(device_code, "", "", "码垛强制完成请求参数:" + json);
HttpResponse result = acsToWmsService.applyTaskManipulatorToWms(json);
logServer.deviceExecuteLog(device_code, String.valueOf(barcode), "", "码垛强制完成返回参数:" + result);
logServer.deviceExecuteLog(device_code, "", "", "码垛强制完成返回参数:" + result);
if (ObjectUtil.isNotEmpty(result)) {
JSONObject jsonObject = JSONObject.parseObject(result.body());
if (result.getStatus() == 200 && StrUtil.equals(jsonObject.getString("status"),"200")) {
@@ -535,9 +535,9 @@ public class LnshPalletizingManipulatorSiteDeviceDriver extends AbstractOpcDevic
json.put("qty",encoder_qty);
json.put("unqualified_qty",unqualified_qty);
json.put("is_full","1");
logServer.deviceExecuteLog(device_code, String.valueOf(barcode), "", "申请入库请求参数:" + json);
logServer.deviceExecuteLog(device_code, "", "", "申请入库请求参数:" + json);
HttpResponse result = acsToWmsService.lnshApplyTaskToWms(json);
logServer.deviceExecuteLog(device_code, String.valueOf(barcode), "", "申请入库返回参数:" + result);
logServer.deviceExecuteLog(device_code, "", "", "申请入库返回参数:" + result);
if (ObjectUtil.isNotEmpty(result)) {
JSONObject jsonObject = JSONObject.parseObject(result.body());
if (result.getStatus() == 200 && StrUtil.equals(jsonObject.getString("status"),"200")) {
@@ -607,13 +607,13 @@ public class LnshPalletizingManipulatorSiteDeviceDriver extends AbstractOpcDevic
Map<String, Object> itemMap = new HashMap<String, Object>();
if (type == 1) {
itemMap.put(to_command, command);
logServer.deviceExecuteLog(device_code, String.valueOf(barcode), "", to_command + "下发" + command);
logServer.deviceExecuteLog(this.device_code, "", "", to_command + " 写入 " + command);
} else if (type == 2) {
itemMap.put(to_target, command);
logServer.deviceExecuteLog(device_code, String.valueOf(barcode), "", to_target + "下发" + command);
logServer.deviceExecuteLog(this.device_code, "", "", to_target + " 写入 " + command);
} else if (type == 3) {
itemMap.put(to_task, command);
logServer.deviceExecuteLog(device_code, String.valueOf(barcode), "", to_task + "下发" + command);
logServer.deviceExecuteLog(this.device_code, "", "", to_task + " 写入 " + command);
}
ReadUtil.write(itemMap, server);
@@ -627,8 +627,8 @@ public class LnshPalletizingManipulatorSiteDeviceDriver extends AbstractOpcDevic
Server server = ReadUtil.getServer(opcservcerid);
Map<String, Object> itemMap = new HashMap<String, Object>();
itemMap.put(to_param, value);
logServer.deviceExecuteLog(device_code, String.valueOf(barcode), "", to_param + "下发" + value);
ReadUtil.write(itemMap, server);
logServer.deviceExecuteLog(this.device_code, "", "", to_param + " 写入 " + value);
}
public void writing(int command) {
@@ -638,8 +638,8 @@ public class LnshPalletizingManipulatorSiteDeviceDriver extends AbstractOpcDevic
Server server = ReadUtil.getServer(opcservcerid);
Map<String, Object> itemMap = new HashMap<String, Object>();
itemMap.put(to_command, command);
logServer.deviceExecuteLog(device_code, String.valueOf(barcode), "", to_command + "下发" + command);
ReadUtil.write(itemMap, server);
logServer.deviceExecuteLog(this.device_code, "", "", to_command + " 写入 " + command);
}
public synchronized void OpenOrClose(String type) {

View File

@@ -608,9 +608,9 @@ public class LnshRGVDeviceDriver extends AbstractOpcDeviceDriver implements Devi
Server server = ReadUtil.getServer(opcservcerid);
Map<String, Object> itemMap = new HashMap<String, Object>();
itemMap.put(to_param, value);
logServer.deviceExecuteLog(this.device_code, "", "", "下发电气信号:"+to_param +",值:"+value);
ReadUtil.write(itemMap, server);
logServer.deviceExecuteLog(this.device_code, "", "", to_param + " 写入 " + value);
}
public boolean exe_business() {
@@ -650,7 +650,7 @@ public class LnshRGVDeviceDriver extends AbstractOpcDeviceDriver implements Devi
Map<String, Object> itemMap = new HashMap<String, Object>();
itemMap.put(to_command1, command);
ReadUtil.write(itemMap, server);
logServer.deviceExecuteLog(this.device_code, "", "", to_command1 + " 写入 " + command);
}
public void writing2(int command) {
@@ -662,7 +662,7 @@ public class LnshRGVDeviceDriver extends AbstractOpcDeviceDriver implements Devi
Map<String, Object> itemMap = new HashMap<String, Object>();
itemMap.put(to_command2, command);
ReadUtil.write(itemMap, server);
logServer.deviceExecuteLog(this.device_code, "", "", to_command2 + " 写入 " + command);
}
public void writing(int type, int command) {

View File

@@ -1146,7 +1146,7 @@ public class LnshSplitManipulatorDeviceDriver extends AbstractOpcDeviceDriver im
Map<String, Object> itemMap = new HashMap<String, Object>();
itemMap.put(to_feedback, feedback);
ReadUtil.write(itemMap, server);
logServer.deviceExecuteLog(this.device_code, "", "", to_feedback + " 写入 " + feedback);
}
public void writing(int type, int command) {
@@ -1170,6 +1170,7 @@ public class LnshSplitManipulatorDeviceDriver extends AbstractOpcDeviceDriver im
itemMap.put(to_param, value);
ReadUtil.write(itemMap, server);
logServer.deviceExecuteLog(this.device_code, "", "", to_param + " 写入 " + value);
}
public static Boolean isExistFieldName(String fieldName, Object obj) throws NoSuchFieldException {

View File

@@ -591,11 +591,13 @@ public class LnshStationDeviceDriver extends AbstractOpcDeviceDriver implements
Map<String, Object> itemMap = new HashMap<String, Object>();
if (type == 1) {
itemMap.put(to_command, command);
logServer.deviceExecuteLog(this.device_code, "", "", to_command + " 写入 " + command);
} else if (type == 2) {
itemMap.put(to_target, command);
logServer.deviceExecuteLog(this.device_code, "", "", to_target + " 写入 " + command);
} else if (type == 3) {
itemMap.put(to_task, command);
logServer.deviceExecuteLog(this.device_code, "", "", to_task + " 写入 " + command);
}
ReadUtil.write(itemMap, server);
@@ -608,8 +610,8 @@ public class LnshStationDeviceDriver extends AbstractOpcDeviceDriver implements
Server server = ReadUtil.getServer(opcservcerid);
Map<String, Object> itemMap = new HashMap<String, Object>();
itemMap.put(to_command, command);
logServer.deviceExecuteLog(this.device_code,"","","下发电气信号:"+to_command+",value"+command);
ReadUtil.write(itemMap, server);
logServer.deviceExecuteLog(this.device_code, "", "", to_command + " 写入 " + command);
}
public synchronized boolean finish_instruction() throws Exception {

View File

@@ -1579,7 +1579,7 @@ public class RljnPackagePalletSplitManipulatorDeviceDriver extends AbstractOpcDe
Map<String, Object> itemMap = new HashMap<String, Object>();
itemMap.put(to_command, command);
ReadUtil.write(itemMap, server);
logServer.deviceExecuteLog(this.device_code,"","","下发电气信号:to_command,value"+command);
logServer.deviceExecuteLog(this.device_code, "", "", to_command + " 写入 " + command);
}
public void writing(String param, String value) {
@@ -1592,7 +1592,7 @@ public class RljnPackagePalletSplitManipulatorDeviceDriver extends AbstractOpcDe
itemMap.put(to_param, value);
ReadUtil.write(itemMap, server);
logServer.deviceExecuteLog(this.device_code,"","","下发电气信号:"+to_param+",value"+value);
logServer.deviceExecuteLog(this.device_code, "", "", to_param + " 写入 " + value);
}
@Override

View File

@@ -1,29 +1,33 @@
<?xml version="1.0" encoding="UTF-8"?>
<included>
<springProperty scope="context" name="logPath" source="logging.file.path" defaultValue="logs"/>
<property name="log.pattern"
value="%black(%contextName-) %red(%d{yyyy-MM-dd HH:mm:ss}) %green([%thread]) %highlight(%-5level) %boldMagenta(%logger{36}) - %gray(%msg%n)"/>
<springProperty scope="context" name="lokiUrl" source="loki.url"/>
<property name="LOKI_URL" value="${lokiUrl}"/>
<!--添加loki-->
<appender name="lokiAppender" class="com.github.loki4j.logback.Loki4jAppender">
<batchTimeoutMs>1000</batchTimeoutMs>
<http class="com.github.loki4j.logback.ApacheHttpSender">
<url>${LOKI_URL}</url>
</http>
<format>
<label>
<pattern>logType=ndc_socket_connection_autorun</pattern>
</label>
<message>
<pattern>${log.pattern}</pattern>
</message>
<sortByTime>true</sortByTime>
</format>
<property name="LOG_HOME" value="${logPath}"/>
<!-- 按照每天生成日志文件 -->
<appender name="FILE12" class="ch.qos.logback.core.rolling.RollingFileAppender">
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<!--日志文件输出的文件名-->
<FileNamePattern>${LOG_HOME}/NDC交互日志/%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>
</appender>
<!-- <logger name="org.nl.start.Init" level="info" additivity="false">
<appender-ref ref="FILE3"/>
</logger>-->
<!-- 打印sql -->
<logger name="org.nl.start.auto.run.NDCSocketConnectionAutoRun" level="info" additivity="false">
<appender-ref ref="lokiAppender" />
<appender-ref ref="FILE12"/>
</logger>
</included>