Browse Source

rev:增加日志

master
刘先源 1 month ago
parent
commit
2227ac3041
  1. 9
      acs2/nladmin-system/src/main/java/org/nl/acs/agv/server/AgvWaitUtil.java
  2. 13
      acs2/nladmin-system/src/main/java/org/nl/acs/agv/server/impl/XianGongAgvServiceImpl.java
  3. 6
      acs2/nladmin-system/src/main/java/org/nl/acs/ext/wms/LmsHttpUtil.java
  4. 2
      acs2/nladmin-system/src/main/resources/config/application-dev2.yml
  5. 2
      acs2/nladmin-system/src/main/resources/config/application.yml
  6. 5
      acs2/nladmin-system/src/main/resources/log/AcsToWms.xml
  7. 19
      acs2/nladmin-system/src/main/resources/log/XgToAcs.xml
  8. 35
      acs2/nladmin-system/src/main/resources/logback-spring.xml
  9. 1
      acs2/nladmin-ui/src/views/monitor/server/index.vue
  10. 0
      lms/nladmin-system/logPath_IS_UNDEFINED/LmsToMes/2024-10-24.0.log
  11. 0
      lms/nladmin-system/logPath_IS_UNDEFINED/MesToLms/2024-10-24.0.log
  12. 7
      lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/mes/service/impl/MesToWmsServiceImpl.java
  13. 21
      lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/AcsCarType.java
  14. 33
      lms/nladmin-system/nlsso-server/src/main/resources/log/LmsToMes.xml
  15. 35
      lms/nladmin-system/nlsso-server/src/main/resources/log/MesToLms.xml
  16. 5
      lms/nladmin-system/nlsso-server/src/main/resources/logback-spring.xml

9
acs2/nladmin-system/src/main/java/org/nl/acs/agv/server/AgvWaitUtil.java

@ -1,6 +1,7 @@
package org.nl.acs.agv.server;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.http.HttpStatus;
import com.alibaba.fastjson.JSONObject;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
@ -61,7 +62,7 @@ public class AgvWaitUtil {
if (flag) {
JSONObject result = new JSONObject();
result.put("status", 200);
result.put("status", HttpStatus.HTTP_OK);
result.put("message", "允许取货!");
log.info("允许仙工AGV取货,设备号 - {}", deviceCode);
return result;
@ -101,7 +102,7 @@ public class AgvWaitUtil {
if (flag) {
JSONObject result = new JSONObject();
result.put("status", 200);
result.put("status", HttpStatus.HTTP_OK);
result.put("message", "允许取货后离开!");
log.info("允许仙工AGV取货后离开,设备号 - {}", deviceCode);
return result;
@ -147,7 +148,7 @@ public class AgvWaitUtil {
if (flag) {
JSONObject result = new JSONObject();
result.put("status", 200);
result.put("status", HttpStatus.HTTP_OK);
result.put("message", "允许放货!");
log.info("允许仙工AGV放货,设备号 - {}", deviceCode);
return result;
@ -188,7 +189,7 @@ public class AgvWaitUtil {
if (flag) {
JSONObject result = new JSONObject();
result.put("status", 200);
result.put("status", HttpStatus.HTTP_OK);
result.put("message", "允许放货后离开!");
log.info("允许仙工AGV放货后离开,设备号 - {}", deviceCode);
return result;

13
acs2/nladmin-system/src/main/java/org/nl/acs/agv/server/impl/XianGongAgvServiceImpl.java

@ -3,6 +3,7 @@ package org.nl.acs.agv.server.impl;
import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.http.HttpStatus;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import lombok.RequiredArgsConstructor;
@ -157,14 +158,14 @@ public class XianGongAgvServiceImpl implements XianGongAgvService {
// 记录车号
driver.setCar_no(reqParam.getString("robot_name"));
result.put("code", 200);
result.put("code", HttpStatus.HTTP_OK);
result.put("message", "ok");
} else {
result.put("code", 400);
result.put("code", HttpStatus.HTTP_BAD_REQUEST);
result.put("message", "ok");
}
} else {
result.put("code", 400);
result.put("code", HttpStatus.HTTP_BAD_REQUEST);
result.put("message", "ok");
}
log.info("getBlockGroup反馈AGV输出参数:{}", result.toString());
@ -197,14 +198,14 @@ public class XianGongAgvServiceImpl implements XianGongAgvService {
if (device.getExtraValue().get("is_clean").toString().equals("1")) {
driver.setCar_no("");
}
result.put("code", 200);
result.put("code", HttpStatus.HTTP_OK);
result.put("message", "ok");
} else {
result.put("code", 400);
result.put("code", HttpStatus.HTTP_BAD_REQUEST);
result.put("message", "ok");
}
} else {
result.put("code", 400);
result.put("code", HttpStatus.HTTP_BAD_REQUEST);
result.put("message", "ok");
}
log.info("releaseBlockGroup反馈AGV输出参数:{}", result.toString());

6
acs2/nladmin-system/src/main/java/org/nl/acs/ext/wms/LmsHttpUtil.java

@ -4,6 +4,7 @@ import cn.hutool.core.util.StrUtil;
import cn.hutool.http.HttpRequest;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import lombok.extern.slf4j.Slf4j;
import org.nl.acs.config.AcsConfig;
import org.nl.acs.ext.RequestAdapter;
import org.nl.acs.ext.ResponseAdapter;
@ -19,6 +20,7 @@ import org.springframework.stereotype.Component;
* @Date 2024/4/22
*/
@Component
@Slf4j
public class LmsHttpUtil {
private static final RequestAdapter REQUEST_ADAPTER = new LmsRequestAdapter();
@ -29,6 +31,7 @@ public class LmsHttpUtil {
@ToOthersInterfaceLog("ACS->LMS")
public <T, W> UnifiedResponse<T> sendPostRequest(String path, W requestParam, Class<T> type) {
log.info("acs向lms反馈任务状态,请求参数:--------------------------------------" + requestParam.toString());
if (!StrUtil.equals(paramService.findByCode(AcsConfig.HAS_WMS).getValue(), "1")) {
return new UnifiedResponse<>(false, "未开启连接该系统!");
}
@ -39,6 +42,7 @@ public class LmsHttpUtil {
.body(JSON.toJSONString(requestParam))
.execute()
.body();
log.info("acs向lms反馈任务状态,输出参数:--------------------------------------" + RESPONSE_ADAPTER.adapt(body, type).toString());
return RESPONSE_ADAPTER.adapt(body, type);
} catch (Exception e) {
return new UnifiedResponse<>(false, e.getMessage());
@ -47,6 +51,7 @@ public class LmsHttpUtil {
@ToOthersInterfaceLog("ACS->LMS")
public <T, W> UnifiedResponse<T> sendPostRequest(String path, W requestParam) {
log.info("acs向lms反馈任务状态,请求参数:--------------------------------------" + requestParam.toString());
if (!StrUtil.equals(paramService.findByCode(AcsConfig.HAS_WMS).getValue(),"1")) {
return new UnifiedResponse<>(false, "未开启连接该系统!");
}
@ -59,6 +64,7 @@ public class LmsHttpUtil {
.body(JSON.toJSONString(array))
.execute()
.body();
log.info("acs向lms反馈任务状态,输出参数:--------------------------------------" + RESPONSE_ADAPTER.adapt(body, null).toString());
return RESPONSE_ADAPTER.adapt(body, null);
} catch (Exception e) {
return new UnifiedResponse<>(false, e.getMessage());

2
acs2/nladmin-system/src/main/resources/config/application-dev2.yml

@ -140,7 +140,7 @@ file:
avatarMaxSize: 5
logging:
file:
path: /Users/onepiece/myFile/acs
path: C:\log\ACS
config: classpath:logback-spring.xml
# Sa-Token配置

2
acs2/nladmin-system/src/main/resources/config/application.yml

@ -44,7 +44,7 @@ rsa:
private_key: MIIBUwIBADANBgkqhkiG9w0BAQEFAASCAT0wggE5AgEAAkEA0vfvyTdGJkdbHkB8mp0f3FE0GYP3AYPaJF7jUd1M0XxFSE2ceK3k2kw20YvQ09NJKk+OMjWQl9WitG9pB6tSCQIDAQABAkA2SimBrWC2/wvauBuYqjCFwLvYiRYqZKThUS3MZlebXJiLB+Ue/gUifAAKIg1avttUZsHBHrop4qfJCwAI0+YRAiEA+W3NK/RaXtnRqmoUUkb59zsZUBLpvZgQPfj1MhyHDz0CIQDYhsAhPJ3mgS64NbUZmGWuuNKp5coY2GIj/zYDMJp6vQIgUueLFXv/eZ1ekgz2Oi67MNCk5jeTF2BurZqNLR3MSmUCIFT3Q6uHMtsB9Eha4u7hS31tj1UWE+D+ADzp59MGnoftAiBeHT7gDMuqeJHPL4b+kC+gzV4FGTfhR9q3tTbklZkD2A==
logging:
file:
path: C:\log\ACS
path: C:\logs\ACS
config: classpath:logback-spring.xml
# sa-token白名单配置
security:

5
acs2/nladmin-system/src/main/resources/log/AcsToWms.xml

@ -22,12 +22,13 @@
</appender>
<appender name="asyncFileAppender" class="ch.qos.logback.classic.AsyncAppender">
<appender name="asyncFileAppender" class="com.yomahub.tlog.core.enhance.logback.async.AspectLogbackAsyncAppender">
<discardingThreshold>2</discardingThreshold>
<appender-ref ref="AcsToWmsServiceImpl"/>
<!-- 设置队列大小,根据您的需求调整 -->
<queueSize>512</queueSize>
</appender>
<logger name="org.nl.acs.ext.wms.LmsUtil" level="info" additivity="true">
<logger name="org.nl.acs.ext.wms.LmsHttpUtil" level="info" additivity="true">
<appender-ref ref="asyncFileAppender"/>
</logger>
</included>

19
lms/nladmin-system/nlsso-server/src/main/resources/log/XgAgvDeviceDriver.xml → acs2/nladmin-system/src/main/resources/log/XgToAcs.xml

@ -2,12 +2,11 @@
<included>
<springProperty scope="context" name="logPath" source="logging.file.path" defaultValue="logs"/>
<property name="LOG_HOME" value="${logPath}"/>
<!--<define name="DEVICECODE" class="org.nl.common.logging.DeviceCodeDir"/>-->
<!-- 按照每天生成日志文件 -->
<appender name="FILE_XGAGV" class="ch.qos.logback.core.rolling.RollingFileAppender">
<appender name="XianGongAgvServiceImpl" class="ch.qos.logback.core.rolling.RollingFileAppender">
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<!--日志文件输出的文件名-->
<FileNamePattern>${LOG_HOME}/XgAgvDeviceDriver/${DEVICECODE}/%d{yyyy-MM-dd}.%i.log</FileNamePattern>
<FileNamePattern>${LOG_HOME}/XG请求ACS/%d{yyyy-MM-dd}.%i.log</FileNamePattern>
<!--日志文件保留天数-->
<maxHistory>15</maxHistory>
<!--单个日志最大容量 至少10MB才能看得出来-->
@ -23,12 +22,12 @@
</appender>
<!-- <logger name="org.nl.start.Init" level="info" additivity="true">
<appender-ref ref="FILE3"/>
</logger>-->
<!-- 打印sql -->
<logger name="org.nl.system.service.lucene.impl.LuceneExecuteLogServiceImpl" level="info" additivity="true">
<appender-ref ref="FILE_XGAGV"/>
<appender name="asyncFileAppender" class="ch.qos.logback.classic.AsyncAppender">
<appender-ref ref="XianGongAgvServiceImpl"/>
<!-- 设置队列大小,根据您的需求调整 -->
<queueSize>512</queueSize>
</appender>
<logger name="org.nl.acs.agv.server.impl.XianGongAgvServiceImpl" level="info" additivity="true">
<appender-ref ref="asyncFileAppender"/>
</logger>
</included>

35
acs2/nladmin-system/src/main/resources/logback-spring.xml

@ -15,24 +15,28 @@ https://juejin.cn/post/6844903775631572999
value="%black(%contextName-) %red(%d{yyyy-MM-dd HH:mm:ss.SSS}) %green([%thread]) %highlight(%-5level) %boldMagenta(%logger{36}) - %gray(%msg%n)"/>
<springProperty scope="context" name="logPath" source="logging.file.path" defaultValue="logs"/>
<!-- <springProperty scope="context" name="lokiUrl" source="loki.url"/>-->
<springProperty scope="context" name="systemName" source="loki.systemName"/>
<!-- <springProperty scope="context" name="systemName" source="loki.systemName"/>-->
<!-- <property name="LOKI_URL" value="${lokiUrl}"/>-->
<property name="SYSTEM_NAME" value="${systemName}"/>
<!--定义日志文件的存储地址 勿在 LogBack 的配置中使用相对路径-->
<property name="LOG_HOME" value="${logPath}"/>
<!-- <property name="SYSTEM_NAME" value="${systemName}"/>-->
<!--引入默认的一些设置-->
<include resource="log/AutoCreateInst.xml"/>
<include resource="log/AcsToWms.xml"/>
<include resource="log/WmsToAcs.xml"/>
<include resource="log/ElevatorSocketUtil.xml"/>
<include resource="log/Elevator.xml"/>
<include resource="log/XgToAcs.xml"/>
<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<!--withJansi 参数改为true-->
<withJansi>true</withJansi>
<encoder class="com.yomahub.tlog.core.enhance.logback.AspectLogbackEncoder">
<pattern>${log.pattern}</pattern>
<charset>${log.charset}</charset>
<!-- <charset>${log.charset}</charset>-->
</encoder>
</appender>
<!--定义日志文件的存储地址 勿在 LogBack 的配置中使用相对路径-->
<property name="LOG_HOME" value="${logPath}"/>
<!-- 按照每天生成日志文件 -->
<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
@ -51,19 +55,20 @@ https://juejin.cn/post/6844903775631572999
</encoder>
</appender>
<!--异步到文件-->
<appender name="asyncFileAppender" class="ch.qos.logback.classic.AsyncAppender">
<discardingThreshold>0</discardingThreshold>
<queueSize>200</queueSize>
<appender-ref ref="FILE"/>
</appender>
<appender name="luceneAppender" class="org.nl.modules.lucene.config.LuceneAppender"/>
<appender name="asyncLuceneAppender" class="org.nl.modules.lucene.config.AsyncLuceneAppender">
<appender name="asyncLuceneAppender" class="ch.qos.logback.classic.AsyncAppender">
<appender-ref ref="luceneAppender"/>
<!-- 设置队列大小,根据您的需求调整 -->
<queueSize>512</queueSize>
</appender>
<!--异步到文件-->
<appender name="asyncFileAppender" class="com.yomahub.tlog.core.enhance.logback.async.AspectLogbackAsyncAppender">
<discardingThreshold>0</discardingThreshold>
<queueSize>200</queueSize>
<appender-ref ref="FILE"/>
</appender>
<!--开发环境:打印控制台-->
<springProfile name="dev2">
<root level="info">

1
acs2/nladmin-ui/src/views/monitor/server/index.vue

@ -219,6 +219,7 @@ export default {
}
},
created() {
debugger
this.init()
this.monitor = window.setInterval(() => {
setTimeout(() => {

0
lms/nladmin-system/logPath_IS_UNDEFINED/LmsToMes/2024-10-24.0.log

0
lms/nladmin-system/logPath_IS_UNDEFINED/MesToLms/2024-10-24.0.log

7
lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/mes/service/impl/MesToWmsServiceImpl.java

@ -75,6 +75,7 @@ public class MesToWmsServiceImpl implements MesToWmsService {
@Override
@Transactional(rollbackFor = Exception.class)
public JSONObject taskSend(JSONObject jo) {
log.info("mes接口taskSend下发任务输入参数:"+jo.toString());
// 返回给mes的结果
JSONObject result = new JSONObject();
// 需要返回的所有任务及状态
@ -157,11 +158,14 @@ public class MesToWmsServiceImpl implements MesToWmsService {
}
resultAllList.addAll(erroList);
result.put("item", resultAllList);
log.info("mes接口taskSend下发任务输出参数:"+result.toString());
return result;
}
@Override
public JSONObject SearchTasks(JSONObject jo) {
log.info("mes接口SearchTasks查看任务输入参数:"+jo.toString());
JSONObject result = new JSONObject();
// 查询所有任务
List<SchBaseTask> taskList = taskService.list(
@ -188,12 +192,14 @@ public class MesToWmsServiceImpl implements MesToWmsService {
result.put("ReturnStatus", 0);
result.put("MsgTime", DateUtil.now());
result.put("TaskLists", mesDtoList);
log.info("mes接口SearchTasks查看任务输出参数:"+result.toString());
return result;
}
@Override
@Transactional(rollbackFor = Exception.class)
public JSONObject deleteTask(JSONObject jo) {
log.info("mes接口deleteTask删除任务输入参数:"+jo.toString());
JSONObject result = new JSONObject();
// 根据任务号查询出对应任务
SchBaseTask taskDao = taskService.getByCode(jo.getString("TaskCode"));
@ -222,6 +228,7 @@ public class MesToWmsServiceImpl implements MesToWmsService {
result.put("ReturnStatus",0);
result.put("ReturnInfo", "任务【"+jo.getString("TaskCode")+"】删除成功!");
result.put("MsgTime", DateUtil.now());
log.info("mes接口deleteTask删除任务输出参数:"+result.toString());
return result;
}

21
lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/AcsCarType.java

@ -0,0 +1,21 @@
package org.nl.wms.sch.task_manage;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
/**
* acs车辆类型
*/
@Getter
@RequiredArgsConstructor
public enum AcsCarType {
GROUP_001("Group-001","ps20"),
GROUP_002("Group-001","ps30"),
GROUP_003("Group-001","ps10"),
GROUP_004("Group-001","ps15")
;
private final String code;
private final String name;
}

33
lms/nladmin-system/nlsso-server/src/main/resources/log/LmsToMes.xml

@ -0,0 +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="FILE4" class="ch.qos.logback.core.rolling.RollingFileAppender">
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<!--日志文件输出的文件名-->
<FileNamePattern>${LOG_HOME}/LmsToMes/%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>
<charset>${log.charset}</charset>
</encoder>
</appender>
<appender name="asyncFileAppender" class="com.yomahub.tlog.core.enhance.logback.async.AspectLogbackAsyncAppender">
<discardingThreshold>2</discardingThreshold>
<queueSize>500</queueSize>
<appender-ref ref="FILE4"/>
</appender>
<logger name="org.nl.wms.ext.mes.service.impl.WmsToMesServiceImpl" level="info" additivity="true">
<appender-ref ref="asyncFileAppender"/>
</logger>
<!-- 打印sql -->
</included>

35
lms/nladmin-system/nlsso-server/src/main/resources/log/MesToLms.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="FILE3" class="ch.qos.logback.core.rolling.RollingFileAppender">
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<!--日志文件输出的文件名-->
<FileNamePattern>${LOG_HOME}/MesToLms/%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>
<charset>${log.charset}</charset>
</encoder>
</appender>
<appender name="asyncFileAppender" class="com.yomahub.tlog.core.enhance.logback.async.AspectLogbackAsyncAppender">
<discardingThreshold>2</discardingThreshold>
<queueSize>500</queueSize>
<appender-ref ref="FILE3"/>
</appender>
<logger name="org.nl.wms.ext.mes.service.impl.MesToWmsServiceImpl" level="info" additivity="true">
<appender-ref ref="asyncFileAppender"/>
</logger>
<!-- 打印sql -->
</included>

5
lms/nladmin-system/nlsso-server/src/main/resources/logback-spring.xml

@ -18,7 +18,8 @@ https://juejin.cn/post/6844903775631572999
<!--引入默认的一些设置-->
<!--<include resource="log/XrToMes.xml"/>
<include resource="log/MesToErp.xml"/>-->
<include resource="log/XgAgvDeviceDriver.xml"/>
<include resource="log/LmsToMes.xml"/>
<include resource="log/MesToLms.xml"/>
<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
<!--withJansi 参数改为true-->
@ -63,7 +64,7 @@ https://juejin.cn/post/6844903775631572999
</appender>
<!--异步到文件-->
<appender name="asyncFileAppender" class="com.yomahub.tlog.core.enhance.logback.async.AspectLogbackAsyncAppender">
<appender name="asyncFileAppender" class="com.yomahub.tlog.core.enhance.logback.async.AspectLogbackAsyncAppender">
<discardingThreshold>0</discardingThreshold>
<queueSize>500</queueSize>
<appender-ref ref="FILE"/>

Loading…
Cancel
Save