fix(client): 设备移除逻辑与认证流程优化
- 修改设备移除时的本地清理方法,统一调用 clearLocalAuth - 优化设备数量限制校验逻辑,避免重复计算当前设备- 移除冗余的设备状态检查,简化设备移除流程- 调整 Redis 连接超时与等待时间,提升连接稳定性- 增强 MySQL 数据库连接配置,添加自动重连机制 -优化 Druid 连接池参数,提高数据库连接性能 - 简化客户端认证与数据上报逻辑,提升处理效率 - 移除过期设备状态更新逻辑,减少不必要的数据库操作- 调整慢 SQL 记录阈值,便于及时发现性能问题-优化版本分布与数据类型统计查询逻辑,提高响应速度
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
package com.tashow.erp;
|
||||
|
||||
import com.tashow.erp.utils.ErrorReporter;
|
||||
import com.tashow.erp.utils.ResourcePreloader;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@@ -10,7 +9,6 @@ import org.springframework.context.ConfigurableApplicationContext;
|
||||
@Slf4j
|
||||
@SpringBootApplication
|
||||
public class ErpClientSbApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
ConfigurableApplicationContext applicationContext = SpringApplication.run(ErpClientSbApplication.class, args);
|
||||
ErrorReporter errorReporter = applicationContext.getBean(ErrorReporter.class);
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
package com.tashow.erp.test;
|
||||
|
||||
import com.tashow.erp.utils.DeviceUtils;
|
||||
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public class SeleniumWithProfile {
|
||||
private static final Pattern WEIGHT_PATTERN = Pattern.compile("\"(?:unitWeight|weight)\":(\\d+(?:\\.\\d+)?)");
|
||||
public static void main(String[] args) {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.tashow.erp.utils;
|
||||
|
||||
import cn.hutool.crypto.SecureUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.InputStreamReader;
|
||||
@@ -11,6 +12,7 @@ import java.util.Enumeration;
|
||||
* 设备工具类 - 基于 Windows Registry + PowerShell 实现稳定的设备ID获取
|
||||
* 兼容 Windows 10/11
|
||||
*/
|
||||
@Slf4j
|
||||
public class DeviceUtils {
|
||||
|
||||
/**
|
||||
@@ -19,9 +21,11 @@ public class DeviceUtils {
|
||||
*
|
||||
* @return 固定的设备ID,格式: 类型前缀_MD5哈希值
|
||||
*/
|
||||
|
||||
public static String generateDeviceId() {
|
||||
String deviceId = null;
|
||||
|
||||
log.info("========== 开始生成设备ID ==========");
|
||||
|
||||
// 策略1: Windows MachineGuid(注册表)
|
||||
deviceId = getMachineGuid();
|
||||
if (deviceId != null) return deviceId;
|
||||
@@ -72,7 +76,7 @@ public class DeviceUtils {
|
||||
}
|
||||
process.waitFor();
|
||||
} catch (Exception e) {
|
||||
System.err.println("获取 MachineGuid 失败: " + e.getMessage());
|
||||
log.error("获取 MachineGuid 异常: {}", e.getMessage());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@@ -97,7 +101,7 @@ public class DeviceUtils {
|
||||
}
|
||||
process.waitFor();
|
||||
} catch (Exception e) {
|
||||
System.err.println("获取硬件 UUID 失败: " + e.getMessage());
|
||||
log.error("获取硬件 UUID 异常: {}", e.getMessage());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@@ -121,7 +125,7 @@ public class DeviceUtils {
|
||||
}
|
||||
process.waitFor();
|
||||
} catch (Exception e) {
|
||||
System.err.println("获取处理器 ID 失败: " + e.getMessage());
|
||||
log.error("获取处理器 ID 异常: {}", e.getMessage());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@@ -145,7 +149,7 @@ public class DeviceUtils {
|
||||
}
|
||||
process.waitFor();
|
||||
} catch (Exception e) {
|
||||
System.err.println("获取主板序列号失败: " + e.getMessage());
|
||||
log.error("获取主板序列号异常: {}", e.getMessage());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@@ -171,7 +175,7 @@ public class DeviceUtils {
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
System.err.println("获取 MAC 地址失败: " + e.getMessage());
|
||||
log.error("获取 MAC 地址异常: {}", e.getMessage());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@@ -191,9 +195,11 @@ public class DeviceUtils {
|
||||
String combined = sb.toString();
|
||||
return "SYS_" + SecureUtil.md5(combined).substring(0, 16).toUpperCase();
|
||||
} catch (Exception e) {
|
||||
System.err.println("获取系统信息失败: " + e.getMessage());
|
||||
log.error("获取系统信息异常: {}", e.getMessage());
|
||||
// 最终的最终降级:时间戳哈希(不推荐,但保证不返回null)
|
||||
return "FALLBACK_" + SecureUtil.md5(String.valueOf(System.currentTimeMillis())).substring(0, 16).toUpperCase();
|
||||
String fallbackId = "FALLBACK_" + SecureUtil.md5(String.valueOf(System.currentTimeMillis())).substring(0, 16).toUpperCase();
|
||||
log.warn("使用最终降级方案(时间戳哈希),设备ID: {}", fallbackId);
|
||||
return fallbackId;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<configuration>
|
||||
<!-- 固定日志路径到系统公共数据目录 -->
|
||||
<property name="LOG_HOME" value="C:/ProgramData/erp-logs" />
|
||||
|
||||
<!-- 控制台输出 -->
|
||||
<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
|
||||
<encoder>
|
||||
<pattern>%d{yyyy-MM-dd HH:mm:ss} [%thread] %-5level %logger{36} - %msg%n</pattern>
|
||||
@@ -7,13 +11,43 @@
|
||||
</encoder>
|
||||
</appender>
|
||||
|
||||
<!-- 设置根日志级别 -->
|
||||
<!-- 文件输出 - 按天滚动 -->
|
||||
<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||
<file>${LOG_HOME}/spring-boot.log</file>
|
||||
<encoder>
|
||||
<pattern>%d{yyyy-MM-dd HH:mm:ss} [%thread] %-5level %logger{36} - %msg%n</pattern>
|
||||
<charset>UTF-8</charset>
|
||||
</encoder>
|
||||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
||||
<fileNamePattern>${LOG_HOME}/spring-boot-%d{yyyy-MM-dd}.log</fileNamePattern>
|
||||
<maxHistory>30</maxHistory>
|
||||
<totalSizeCap>1GB</totalSizeCap>
|
||||
</rollingPolicy>
|
||||
</appender>
|
||||
|
||||
<!-- 设置根日志级别 - 同时输出到控制台和文件 -->
|
||||
<root level="INFO">
|
||||
<appender-ref ref="CONSOLE" />
|
||||
<appender-ref ref="FILE" />
|
||||
</root>
|
||||
|
||||
<!-- 设置特定包的日志级别 -->
|
||||
<logger name="com.tashow.erp" level="INFO" additivity="false">
|
||||
<appender-ref ref="CONSOLE" />
|
||||
<appender-ref ref="FILE" />
|
||||
</logger>
|
||||
|
||||
<!-- 确保 Hibernate 日志也输出 -->
|
||||
<logger name="org.hibernate" level="INFO">
|
||||
<appender-ref ref="CONSOLE" />
|
||||
<appender-ref ref="FILE" />
|
||||
</logger>
|
||||
|
||||
<!-- 确保 Spring 日志也输出 -->
|
||||
<logger name="org.springframework" level="INFO">
|
||||
<appender-ref ref="CONSOLE" />
|
||||
<appender-ref ref="FILE" />
|
||||
</logger>
|
||||
</configuration>
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user