Browse Source

1、数据上报和下发控制逻辑优化;

dev
mh 1 month ago
parent
commit
7ea2e176e3
  1. 2
      mh-admin/src/main/java/com/mh/web/controller/device/OperationController.java
  2. 10
      mh-admin/src/main/resources/application-dev.yml
  3. 4
      mh-admin/src/main/resources/application-druid.yml
  4. 19
      mh-admin/src/main/resources/application-prod.yml
  5. 2
      mh-common/src/main/java/com/mh/common/model/request/AdvantechDatas.java
  6. 11
      mh-framework/src/main/java/com/mh/framework/dealdata/impl/DataProcessServiceImpl.java
  7. 13
      mh-system/src/main/java/com/mh/system/service/device/impl/CollectionParamsManageServiceImpl.java
  8. 2
      mh-system/src/main/java/com/mh/system/service/operation/impl/OperationDeviceServiceImpl.java

2
mh-admin/src/main/java/com/mh/web/controller/device/OperationController.java

@ -83,7 +83,7 @@ public class OperationController extends BaseController {
public AjaxResult operationDevice(@RequestBody List<OrderEntity> changeValues) { public AjaxResult operationDevice(@RequestBody List<OrderEntity> changeValues) {
try { try {
String sendOrder = iOperationService.operationDevice(changeValues); String sendOrder = iOperationService.operationDevice(changeValues);
iMqttGatewayService.publish("mh_upload/events_upload/devices", sendOrder, 1); iMqttGatewayService.publish("mh_control/events_upload/devices", sendOrder, 1);
} catch (Exception e) { } catch (Exception e) {
log.error("设备操作失败", e); log.error("设备操作失败", e);
return AjaxResult.error(); return AjaxResult.error();

10
mh-admin/src/main/resources/application-dev.yml

@ -191,11 +191,11 @@ mqttSpring:
# BASIC parameters are required. # BASIC parameters are required.
BASIC: BASIC:
protocol: MQTT protocol: MQTT
host: 127.0.0.1 host: mqtt.mhito.net
port: 2883 port: 1883
username: mh username: sa
password: mhtech@803 password: sa123
client-id: mqtt_mz_producer_dev client-id: eemcs_hw_mqtt_dev
# If the protocol is ws/wss, this value is required. # If the protocol is ws/wss, this value is required.
path: path:
# Topics that need to be subscribed when initially connecting to mqtt, multiple topics are divided by ",". # Topics that need to be subscribed when initially connecting to mqtt, multiple topics are divided by ",".

4
mh-admin/src/main/resources/application-druid.yml

@ -7,8 +7,8 @@ spring:
# 主库数据源 # 主库数据源
master: master:
#添加allowMultiQueries=true 在批量更新时才不会出错 #添加allowMultiQueries=true 在批量更新时才不会出错
url: jdbc:postgresql://127.0.0.1:5432/eemcs_hw # url: jdbc:postgresql://127.0.0.1:5432/eemcs_hw
# url: jdbc:postgresql://127.0.0.1:5432/eemcs url: jdbc:postgresql://127.0.0.1:5432/eemcs
username: postgres username: postgres
password: mh@803 password: mh@803
# 从库数据源 # 从库数据源

19
mh-admin/src/main/resources/application-prod.yml

@ -7,7 +7,7 @@ mh:
# 版权年份 # 版权年份
copyrightYear: 2024 copyrightYear: 2024
# 文件路径 示例( Windows配置D:/mh/uploadPath,Linux配置 /home/mh/uploadPath) # 文件路径 示例( Windows配置D:/mh/uploadPath,Linux配置 /home/mh/uploadPath)
profile: D:/mh/uploadPath profile: E:/mh/uploadPath
# 获取ip地址开关 # 获取ip地址开关
addressEnabled: false addressEnabled: false
# 验证码类型 math 数字计算 char 字符验证 # 验证码类型 math 数字计算 char 字符验证
@ -16,7 +16,7 @@ mh:
# 开发环境配置 # 开发环境配置
server: server:
# 服务器的HTTP端口,默认为8080 # 服务器的HTTP端口,默认为8080
port: 8080 port: 8090
servlet: servlet:
# 应用的访问路径 # 应用的访问路径
context-path: / context-path: /
@ -98,9 +98,10 @@ spring:
# 主库数据源 # 主库数据源
master: master:
#添加allowMultiQueries=true 在批量更新时才不会出错 #添加allowMultiQueries=true 在批量更新时才不会出错
url: jdbc:postgresql://127.0.0.1:5432/eemcs # url: jdbc:postgresql://127.0.0.1:5505/eemcs_hw
url: jdbc:postgresql://127.0.0.1:5505/eemcs
username: postgres username: postgres
password: mh@803 password: mhtech@803
# 从库数据源 # 从库数据源
slave: slave:
# 从数据源开关/默认关闭 # 从数据源开关/默认关闭
@ -190,11 +191,11 @@ mqttSpring:
# BASIC parameters are required. # BASIC parameters are required.
BASIC: BASIC:
protocol: MQTT protocol: MQTT
host: 127.0.0.1 host: mqtt.mhito.net
port: 2883 port: 1883
username: mh username: sa
password: mhtech@803 password: sa123
client-id: mqtt_mz_producer_dev client-id: eemcs_hw_mqtt_pro
# If the protocol is ws/wss, this value is required. # If the protocol is ws/wss, this value is required.
path: path:
# Topics that need to be subscribed when initially connecting to mqtt, multiple topics are divided by ",". # Topics that need to be subscribed when initially connecting to mqtt, multiple topics are divided by ",".

2
mh-common/src/main/java/com/mh/common/model/request/AdvantechDatas.java

@ -20,6 +20,6 @@ public class AdvantechDatas {
/** /**
* 上报值 * 上报值
*/ */
private String value; private Integer value;
} }

11
mh-framework/src/main/java/com/mh/framework/dealdata/impl/DataProcessServiceImpl.java

@ -110,16 +110,15 @@ public class DataProcessServiceImpl implements DataProcessService {
List<AdvantechDatas> list = JSON.parseObject(data.getD().toString(), new TypeReference<List<AdvantechDatas>>() {}); List<AdvantechDatas> list = JSON.parseObject(data.getD().toString(), new TypeReference<List<AdvantechDatas>>() {});
for (AdvantechDatas advantechDatas : list) { for (AdvantechDatas advantechDatas : list) {
String tag = advantechDatas.getTag(); String tag = advantechDatas.getTag();
String value = advantechDatas.getValue(); String value = String.valueOf(advantechDatas.getValue());
log.info("时间: {},tag标签: {},value值: {}", formattedTime, tag, value); log.info("时间: {},tag标签: {},value值: {}", formattedTime, tag, value);
try { try {
if (StringUtils.isBlank(tag)) { if (StringUtils.isBlank(tag)) {
continue; continue;
} }
CollectionParamsManage collectionParamsManage = new CollectionParamsManage();
for (CollectionParamsManage entity : registers) { for (CollectionParamsManage entity : registers) {
if (tag.equals(String.valueOf(entity.getOtherName()))) { if (tag.equals(String.valueOf(entity.getOtherName()))) {
CollectionParamsManage collectionParamsManage = new CollectionParamsManage();
collectionParamsManage = entity; collectionParamsManage = entity;
try { try {
collectionParamsManage.setCurValue(new BigDecimal(value)); collectionParamsManage.setCurValue(new BigDecimal(value));
@ -129,10 +128,10 @@ public class DataProcessServiceImpl implements DataProcessService {
} }
Date date = Date.from(localDateTime.atZone(ZoneId.systemDefault()).toInstant()); Date date = Date.from(localDateTime.atZone(ZoneId.systemDefault()).toInstant());
collectionParamsManage.setCurTime(date); collectionParamsManage.setCurTime(date);
entities.add(collectionParamsManage);
break; break;
} }
} }
entities.add(collectionParamsManage);
} catch (Exception e) { } catch (Exception e) {
log.error("解析异常", e); log.error("解析异常", e);
} }
@ -141,7 +140,9 @@ public class DataProcessServiceImpl implements DataProcessService {
redisCache.setCacheList(cacheKey, entities); redisCache.setCacheList(cacheKey, entities);
threadPoolService.execute(() -> { threadPoolService.execute(() -> {
collectionParamsManageService.updateCollectionParamsManages(entities); if (!entities.isEmpty()) {
collectionParamsManageService.updateCollectionParamsManages(entities);
}
}); });
} }

13
mh-system/src/main/java/com/mh/system/service/device/impl/CollectionParamsManageServiceImpl.java

@ -139,11 +139,13 @@ public class CollectionParamsManageServiceImpl implements ICollectionParamsManag
@Override @Override
public List<CollectionParamsManage> queryCollectionParamsByMtType(String mtType) { public List<CollectionParamsManage> queryCollectionParamsByMtType(String mtType) {
QueryWrapper<CollectionParamsManage> queryWrapper = new QueryWrapper<>(); QueryWrapper<CollectionParamsManage> queryWrapper = new QueryWrapper<>();
if ("0".equals(mtType)) { // if ("0".equals(mtType)) {
queryWrapper.eq("mt_type", mtType); // queryWrapper.eq("mt_type", mtType);
} else { // } else {
queryWrapper.ne("mt_type", mtType); // queryWrapper.ne("mt_type", mtType);
} // }
queryWrapper.eq("is_use", 0);
queryWrapper.orderByAsc("order_num");
return collectionParamsManageMapper.selectList(queryWrapper); return collectionParamsManageMapper.selectList(queryWrapper);
} }
@ -151,6 +153,7 @@ public class CollectionParamsManageServiceImpl implements ICollectionParamsManag
public void updateCollectionParamsManages(ArrayList<CollectionParamsManage> chillersEntities) { public void updateCollectionParamsManages(ArrayList<CollectionParamsManage> chillersEntities) {
// 批量更新 // 批量更新
chillersEntities.forEach(chillerEntity -> { chillersEntities.forEach(chillerEntity -> {
log.info("chillerEntity: {}", chillerEntity.toString());
collectionParamsManageMapper.updateById(chillerEntity); collectionParamsManageMapper.updateById(chillerEntity);
}); });
// 根据台账id更新台账在线情况 // 根据台账id更新台账在线情况

2
mh-system/src/main/java/com/mh/system/service/operation/impl/OperationDeviceServiceImpl.java

@ -70,7 +70,7 @@ public class OperationDeviceServiceImpl implements IOperationDeviceService {
// 发送报文 // 发送报文
AdvantechDatas data = new AdvantechDatas(); AdvantechDatas data = new AdvantechDatas();
data.setTag(otherName); data.setTag(otherName);
data.setValue(message); data.setValue(Integer.valueOf(message));
advantechDatas.add(data); advantechDatas.add(data);
} }
return advantechDatas; return advantechDatas;

Loading…
Cancel
Save