日志配置

This commit is contained in:
2025-08-06 09:12:47 +08:00
parent 57f074995e
commit c2eb5ba524
6 changed files with 61 additions and 13 deletions

View File

@ -0,0 +1,27 @@
package com.fuyuanshen.global.mqtt.constants;
/**
* 租户常量定义类
* 包含系统中使用的各种租户标识
*
* @author: 默苍璃
* @date: 2025-08-05 10:46
*/
public class TenantsConstant {
/**
* 晶全租户
*/
public static final String JING_QUAN = "014443";
/**
* 富源晟租户
*/
public static final String FU_YUAN_SHENG = "894078";
/**
* 管理员租户
*/
public static final String ADMIN = "000000";
}

View File

@ -3,12 +3,14 @@ package com.fuyuanshen.web.handler.mqtt;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectMapper;
import com.fuyuanshen.common.satoken.utils.LoginHelper;
import com.fuyuanshen.equipment.domain.Device; import com.fuyuanshen.equipment.domain.Device;
import com.fuyuanshen.equipment.domain.DeviceLog; import com.fuyuanshen.equipment.domain.DeviceLog;
import com.fuyuanshen.equipment.mapper.DeviceLogMapper; import com.fuyuanshen.equipment.mapper.DeviceLogMapper;
import com.fuyuanshen.equipment.mapper.DeviceMapper; import com.fuyuanshen.equipment.mapper.DeviceMapper;
import com.fuyuanshen.equipment.utils.map.GetAddressFromLatUtil; import com.fuyuanshen.equipment.utils.map.GetAddressFromLatUtil;
import com.fuyuanshen.equipment.utils.map.LngLonUtil; import com.fuyuanshen.equipment.utils.map.LngLonUtil;
import com.fuyuanshen.global.mqtt.constants.TenantsConstant;
import com.fuyuanshen.web.enums.InstructType6170; import com.fuyuanshen.web.enums.InstructType6170;
import com.fuyuanshen.web.enums.LightModeEnum6170; import com.fuyuanshen.web.enums.LightModeEnum6170;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
@ -52,12 +54,16 @@ public class DeviceReceiverMessageHandler implements MessageHandler {
String receivedTopicName = (String) headers.get("mqtt_receivedTopic"); String receivedTopicName = (String) headers.get("mqtt_receivedTopic");
System.out.println("消息来自主题:" + receivedTopicName); System.out.println("消息来自主题:" + receivedTopicName);
// String tenantId = LoginHelper.getTenantId();
String tenantId = TenantsConstant.FU_YUAN_SHENG;
String payload = message.getPayload().toString(); String payload = message.getPayload().toString();
if (receivedTopicName != null) { if (receivedTopicName != null) {
// 1. 提取设备ID (从主题中获取) // 1. 提取设备ID (从主题中获取)
String deviceImei = extractDeviceId(receivedTopicName); String deviceImei = extractDeviceId(receivedTopicName);
Device device = deviceMapper.selectOne(new QueryWrapper<Device>().eq("device_imei", deviceImei)); Device device = deviceMapper.selectOne(new QueryWrapper<Device>()
.eq("tenant_id", tenantId)
.eq("device_imei", deviceImei));
if (device == null) { if (device == null) {
log.info("不存在的设备IMEI: {}", deviceImei); log.info("不存在的设备IMEI: {}", deviceImei);
} else { } else {

View File

@ -1,15 +1,15 @@
--- # 监控中心配置 --- # 监控中心配置
spring.boot.admin.client: spring.boot.admin.client:
# 增加客户端开关 # 增加客户端开关
enabled: false enabled: true
url: http://localhost:9090/admin url: http://localhost:9090/admin
instance: instance:
service-host-type: IP service-host-type: IP
metadata: metadata:
username: ${spring.boot.admin.client.username} username: ${spring.boot.admin.client.username}
userpassword: ${spring.boot.admin.client.password} userpassword: ${spring.boot.admin.client.password}
username: @monitor.username@ username: ${monitor.username}
password: @monitor.password@ password: ${monitor.password}
--- # snail-job 配置 --- # snail-job 配置
snail-job: snail-job:

View File

@ -35,7 +35,8 @@ captcha:
# 日志配置 # 日志配置
logging: logging:
level: level:
com.fuyuanshen: @logging.level@ #com.fuyuanshen: @logging.level@
com.fuyuanshen: ${logging.level}
org.springframework: warn org.springframework: warn
org.mybatis.spring.mapper: error org.mybatis.spring.mapper: error
org.apache.fury: warn org.apache.fury: warn
@ -254,7 +255,7 @@ management:
health: health:
show-details: ALWAYS show-details: ALWAYS
logfile: logfile:
external-file: ./logs/sys-console.log external-file: ./logs/sys-admin-console.log
--- # 默认/推荐使用sse推送 --- # 默认/推荐使用sse推送
sse: sse:

View File

@ -15,13 +15,13 @@
<!-- 控制台输出 --> <!-- 控制台输出 -->
<appender name="file_console" class="ch.qos.logback.core.rolling.RollingFileAppender"> <appender name="file_console" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${log.path}/sys-console.log</file> <file>${log.path}/sys-admin-console.log</file>
<!-- <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> --> <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!-- &lt;!&ndash; 日志文件名格式 &ndash;&gt; --> <!-- 日志文件名格式 -->
<!-- <fileNamePattern>${log.path}/sys-console.%d{yyyy-MM-dd}.log</fileNamePattern> --> <fileNamePattern>${log.path}/sys-admin-console.log.%d{yyyy-MM-dd}.log</fileNamePattern>
<!-- &lt;!&ndash; 日志最大 1天 &ndash;&gt; --> <!-- 日志最大 1天 -->
<!-- <maxHistory>1</maxHistory> --> <maxHistory>1</maxHistory>
<!-- </rollingPolicy> --> </rollingPolicy>
<encoder> <encoder>
<pattern>${log.pattern}</pattern> <pattern>${log.pattern}</pattern>
<charset>utf-8</charset> <charset>utf-8</charset>

14
pom.xml
View File

@ -101,6 +101,20 @@
<!-- <activeByDefault>true</activeByDefault> --> <!-- <activeByDefault>true</activeByDefault> -->
<!-- </activation> --> <!-- </activation> -->
</profile> </profile>
<profile>
<id>jingquan</id>
<properties>
<!-- 环境标识,需要与配置文件的名称相对应 -->
<profiles.active>jingquan</profiles.active>
<logging.level>info</logging.level>
<monitor.username>fys</monitor.username>
<monitor.password>123456</monitor.password>
</properties>
<!-- <activation> -->
<!-- &lt;!&ndash; 默认环境 &ndash;&gt; -->
<!-- <activeByDefault>true</activeByDefault> -->
<!-- </activation> -->
</profile>
</profiles> </profiles>
<!-- 依赖声明 --> <!-- 依赖声明 -->