This commit is contained in:
USER-20220102CG\noblelift
2023-04-21 19:54:10 +08:00
parent 2a527249ee
commit 2d9f011c61
5 changed files with 73 additions and 31 deletions

View File

@@ -0,0 +1,34 @@
package org.nl.modules.quartz.task;
import cn.hutool.core.util.StrUtil;
import lombok.extern.slf4j.Slf4j;
import org.nl.acs.config.AcsConfig;
import org.nl.acs.config.server.AcsConfigService;
import org.nl.start.auto.run.AutoRunService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
/**
* NDC自动重连
*/
@Slf4j
@Component
public class NdcAutoReconnection {
@Autowired
AcsConfigService acsConfigService;
@Autowired
AutoRunService autoRunService;
public void run(String threadCode) throws Exception {
if (StrUtil.equals(acsConfigService.findByCode(AcsConfig.NDC_RECONNECTION).getValue().toString(), "1")) {
String[] threadCodes = threadCode.split(",");
for (String code : threadCodes) {
if (!autoRunService.getThreadByCode(code).isAlive()) {
autoRunService.startThread(code);
}
}
}
}
}

View File

@@ -139,8 +139,8 @@ public class NDCSocketConnectionAutoRun extends AbstractAutoRunnable {
if (ikey != 0) {
inst = instructionService.findByCodeFromCache(String.valueOf(ikey));
}
// log.info("接收agv上报信息" + bs);
// log.info("接收agv上报信息" + "phase--" + phase + " index--" + index + " ikey--" + ikey + " agvaddr--" + agvaddr + " Car--" + carno);
log.info("接收agv上报信息" + bs);
log.info("接收agv上报信息" + "phase--" + phase + " index--" + index + " ikey--" + ikey + " agvaddr--" + agvaddr + " Car--" + carno);
logServer.deviceExecuteLog("ndc", "","","接收agv上报信息" + bs);
logServer.deviceExecuteLog("ndc", "","","接收agv上报信息" + "phase--" + phase + " index--" + index + " ikey--" + ikey + " agvaddr--" + agvaddr + " Car--" + carno);
Device device = null;
@@ -199,7 +199,8 @@ public class NDCSocketConnectionAutoRun extends AbstractAutoRunnable {
else if (phase == 0x03) {
if (ObjectUtil.isEmpty(inst)) {
logServer.deviceExecuteLog("ndc", "","","未找到指令号对应的指令:" + ikey);
return;
log.info("未找到指令号{}对应的指令", ikey);
continue;
}
if (device_code.equals("MDJXS601")) {
data = AgvService.sendAgvOneModeInst(phase, index, 0);
@@ -298,8 +299,9 @@ public class NDCSocketConnectionAutoRun extends AbstractAutoRunnable {
// 取货完成请求离开
else if (phase == 0x05) {
if (ObjectUtil.isEmpty(inst)) {
log.info("未找到指令号{}对应的指令", ikey);
logServer.deviceExecuteLog("ndc", "","","未找到指令号对应的指令:" + ikey);
return;
continue;
}
if (device_code.equals("MDJXS601")) {
data = AgvService.sendAgvOneModeInst(phase, index, 0);
@@ -391,8 +393,9 @@ public class NDCSocketConnectionAutoRun extends AbstractAutoRunnable {
// 到达扫码点
else if (phase == 0x06) {
if (ObjectUtil.isEmpty(inst)) {
log.info("未找到指令号{}对应的指令", ikey);
logServer.deviceExecuteLog("ndc", "","","未找到指令号对应的指令:" + ikey);
return;
continue;
}
logServer.deviceExecuteLog("ndc","","","phase==0x06," + "指令号:" + ikey + ",addressRYSMW01");
//检测站点
@@ -415,8 +418,9 @@ public class NDCSocketConnectionAutoRun extends AbstractAutoRunnable {
//请求放货
else if (phase == 0x07) {
if (ObjectUtil.isEmpty(inst)) {
log.info("未找到指令号{}对应的指令", ikey);
logServer.deviceExecuteLog("ndc", "","","未找到指令号对应的指令:" + ikey);
return;
continue;
}
if (device_code.equals("MDJXS601")) {
data = AgvService.sendAgvOneModeInst(phase, index, 0);
@@ -496,8 +500,9 @@ public class NDCSocketConnectionAutoRun extends AbstractAutoRunnable {
// 放货完成请求离开
else if (phase == 0x09) {
if (ObjectUtil.isEmpty(inst)) {
log.info("未找到指令号{}对应的指令", ikey);
logServer.deviceExecuteLog("ndc", "","","未找到指令号对应的指令:" + ikey);
return;
continue;
}
if (device_code.equals("MDJXS601")) {
data = AgvService.sendAgvOneModeInst(phase, index, 0);

View File

@@ -10,7 +10,7 @@
<!--日志文件保留天数-->
<maxHistory>15</maxHistory>
<!--单个日志最大容量 至少10MB才能看得出来-->
<maxFileSize>200MB</maxFileSize>
<maxFileSize>50MB</maxFileSize>
<!--所有日志最多占多大容量-->
<totalSizeCap>2GB</totalSizeCap>
</rollingPolicy>

View File

@@ -3,14 +3,14 @@
<springProperty scope="context" name="logPath" source="logging.file.path" defaultValue="logs"/>
<property name="LOG_HOME" value="${logPath}"/>
<!-- 按照每天生成日志文件 -->
<appender name="FILE12" class="ch.qos.logback.core.rolling.RollingFileAppender">
<appender name="FILE10" 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>
<maxFileSize>50MB</maxFileSize>
<!--所有日志最多占多大容量-->
<totalSizeCap>2GB</totalSizeCap>
</rollingPolicy>
@@ -28,6 +28,6 @@
<!-- 打印sql -->
<logger name="org.nl.start.auto.run.NDCSocketConnectionAutoRun" level="info" additivity="false">
<appender-ref ref="FILE12"/>
<appender-ref ref="FILE10"/>
</logger>
</included>

View File

@@ -1,30 +1,33 @@
<?xml version="1.0" encoding="UTF-8"?>
<included>
<springProperty scope="context" name="logPath" source="logging.file.path" defaultValue="logs"/>
<springProperty scope="context" name="lokiUrl" source="loki.url"/>
<property name="LOKI_URL" value="${lokiUrl}"/>
<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)"/>
<property name="LOG_HOME" value="${logPath}"/>
<!-- 按照每天生成日志文件 -->
<appender name="FILE13" class="ch.qos.logback.core.rolling.RollingFileAppender">
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<!--日志文件输出的文件名-->
<FileNamePattern>${LOG_HOME}/WMS下发ACS/%d{yyyy-MM-dd}.%i.log</FileNamePattern>
<!--日志文件保留天数-->
<maxHistory>15</maxHistory>
<!--单个日志最大容量 至少10MB才能看得出来-->
<maxFileSize>50MB</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>
<!--添加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=wms_to_acs</pattern>
</label>
<message>
<pattern>${log.pattern}</pattern>
</message>
<sortByTime>true</sortByTime>
</format>
</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.WmsToAcsServiceImpl" level="info" additivity="false">
<appender-ref ref="lokiAppender" />
<appender-ref ref="FILE13"/>
</logger>
</included>