Browse Source

1、修改单抄响应报文;2、分批次执行线程;

prod_202403
mh 9 months ago
parent
commit
c795ac7737
  1. 13
      user-service/src/main/java/com/mh/user/job/DealDataJob.java
  2. 13
      user-service/src/main/java/com/mh/user/serialport/SerialPortSingle2.java
  3. 12
      user-service/src/main/resources/application-prod.yml
  4. 4
      user-service/src/main/resources/application-test.yml
  5. 2
      user-service/src/main/resources/application.yml

13
user-service/src/main/java/com/mh/user/job/DealDataJob.java

@ -92,8 +92,10 @@ public class DealDataJob {
List<DeviceCodeParamEntity> deviceParamsByType = cacheUtil.getDeviceParamsByType(threadName); List<DeviceCodeParamEntity> deviceParamsByType = cacheUtil.getDeviceParamsByType(threadName);
// 分组data_com // 分组data_com
Map<String, List<DeviceCodeParamEntity>> dataComMap = deviceParamsByType.stream().collect(Collectors.groupingBy(DeviceCodeParamEntity::getDataCom)); Map<String, List<DeviceCodeParamEntity>> dataComMap = deviceParamsByType.stream().collect(Collectors.groupingBy(DeviceCodeParamEntity::getDataCom));
CountDownLatch countDownLatch = new CountDownLatch(dataComMap.size()); int batchSize = 10; // 定义一个批次大小
for (int j = 0; j < dataComMap.size(); j++) { for (int k = 0; k < dataComMap.size(); ) {
CountDownLatch countDownLatch = new CountDownLatch(Math.min(batchSize, dataComMap.size() - k));
for (int j = 0; j < Math.min(batchSize, dataComMap.size() - k); j++) {
if (Constant.WEB_FLAG) { if (Constant.WEB_FLAG) {
break; break;
} }
@ -108,6 +110,13 @@ public class DealDataJob {
countDownLatch.await(); countDownLatch.await();
// 释放资源 // 释放资源
countDownLatch = null; countDownLatch = null;
// 检查是否需要继续创建新的线程(未达到数据总数量且WEB_FLAG为false)
if (k + batchSize < dataComMap.size() && !Constant.WEB_FLAG) {
k += batchSize;
} else {
break;
}
}
} }
} }
} }

13
user-service/src/main/java/com/mh/user/serialport/SerialPortSingle2.java

@ -98,9 +98,16 @@ public class SerialPortSingle2 {
//截取去掉FE //截取去掉FE
String deviceType = deviceCodeParamEntity.getDeviceType(); String deviceType = deviceCodeParamEntity.getDeviceType();
String deviceAddr = deviceCodeParamEntity.getDeviceAddr(); String deviceAddr = deviceCodeParamEntity.getDeviceAddr();
String dataStr = receiveData; String dataStr = "";
if ("水表".equals(deviceType) || "电表".equals(deviceType)) { // if ("水表".equals(deviceType) || "电表".equals(deviceType)) {
dataStr = receiveData.replace("FE", ""); // dataStr = receiveData.replace("FE", "");
// }
if (receiveData.length() > 8 && ("水表".equals(deviceType) || "电表".equals(deviceType))) {
String str1 = receiveData.substring(0, 8);
String str2 = receiveData.substring(8);
dataStr = str1.replace("FE", "") + str2;
} else {
dataStr = receiveData;
} }
String registerAddr = deviceCodeParamEntity.getRegisterAddr(); String registerAddr = deviceCodeParamEntity.getRegisterAddr();
String brand = deviceCodeParamEntity.getBrand(); String brand = deviceCodeParamEntity.getBrand();

12
user-service/src/main/resources/application-prod.yml

@ -19,10 +19,10 @@ spring:
# username: test # username: test
# password: minghan123456@ # password: minghan123456@
#华厦云服务器 #华厦云服务器
# url: jdbc:sqlserver://127.0.0.1:1433;DatabaseName=CHWS;allowMultiQueries=true # url: jdbc:sqlserver://127.0.0.1:1433;DatabaseName=CHWS;allowMultiQueries=true
# driver-class-name: com.microsoft.sqlserver.jdbc.SQLServerDriver # driver-class-name: com.microsoft.sqlserver.jdbc.SQLServerDriver
# username: chws # username: chws
# password: minghan123456@ # password: minghan123456@
#创新服务器 #创新服务器
# url: jdbc:sqlserver://119.29.33.133:2008;DatabaseName=chws_chx;allowMultiQueries=true # url: jdbc:sqlserver://119.29.33.133:2008;DatabaseName=chws_chx;allowMultiQueries=true
# driver-class-name: com.microsoft.sqlserver.jdbc.SQLServerDriver # driver-class-name: com.microsoft.sqlserver.jdbc.SQLServerDriver
@ -63,8 +63,8 @@ spring:
fail-fast: false fail-fast: false
# 是否启用配置中心 # 是否启用配置中心
enabled: ${SPRING_CLOUD_CONFIG_ENABLED:false} enabled: ${SPRING_CLOUD_CONFIG_ENABLED:false}
# 配置中心地址 # # 配置中心地址
uri: ${SPRING_CLOUD_CONFIG_URI:http://localhost:8763} # uri: ${SPRING_CLOUD_CONFIG_URI:http://localhost:8763}
# redis: # redis:
# database: 0 # database: 0
# host: 127.0.0.1 # host: 127.0.0.1

4
user-service/src/main/resources/application-test.yml

@ -61,8 +61,8 @@ spring:
fail-fast: false fail-fast: false
# 是否启用配置中心 # 是否启用配置中心
enabled: ${SPRING_CLOUD_CONFIG_ENABLED:false} enabled: ${SPRING_CLOUD_CONFIG_ENABLED:false}
# 配置中心地址 # # 配置中心地址
uri: ${SPRING_CLOUD_CONFIG_URI:http://localhost:8763} # uri: ${SPRING_CLOUD_CONFIG_URI:http://localhost:8763}
# redis: # redis:
# database: 0 # database: 0
# host: 127.0.0.1 # host: 127.0.0.1

2
user-service/src/main/resources/application.yml

@ -1,3 +1,3 @@
spring: spring:
profiles: profiles:
active: prod active: dev

Loading…
Cancel
Save