Commit 0ea7e3df authored by 刘林's avatar 刘林

fix(equip):江西数据中心添加多线程以及缓存预热处理消息

parent 47f280da
...@@ -43,6 +43,11 @@ public class RedisKey { ...@@ -43,6 +43,11 @@ public class RedisKey {
/** 企业用户注册前缀 */ /** 企业用户注册前缀 */
public static final String FLC_USER_TEL = "flc_tel_"; public static final String FLC_USER_TEL = "flc_tel_";
/**
* 装备指标Key值
*/
public static final String EQUIP_INDEX_ADDRESS = "equip_index_address";
/** 驼峰转下划线(简单写法,效率低于 ) */ /** 驼峰转下划线(简单写法,效率低于 ) */
public static String humpToLine(String str) { public static String humpToLine(String str) {
return str.replaceAll("[A-Z]", "_$0").toLowerCase(); return str.replaceAll("[A-Z]", "_$0").toLowerCase();
......
...@@ -69,4 +69,13 @@ public class EquipmentIndexVO { ...@@ -69,4 +69,13 @@ public class EquipmentIndexVO {
@ApiModelProperty(value = "指标枚举") @ApiModelProperty(value = "指标枚举")
private String valueEnum; private String valueEnum;
@ApiModelProperty(value = "信号的索引键key,用于唯一索引信号")
private String indexAddress;
@ApiModelProperty(value = "测点类型,analog/state")
private String dataType;
@ApiModelProperty(value = "网关标识")
private String gatewayId;
} }
package com.yeejoin.equipmanage.config;
import com.yeejoin.amos.boot.biz.common.utils.RedisKey;
import com.yeejoin.amos.boot.biz.common.utils.RedisUtils;
import com.yeejoin.equipmanage.common.entity.vo.EquipmentIndexVO;
import com.yeejoin.equipmanage.mapper.EquipmentSpecificIndexMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.util.List;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;
/**
* @author LiuLin
* @date 2023/6/15
* @apiNote
*/
@Component
@Slf4j
public class EquipmentIndexCacheRunner implements CommandLineRunner {
@Resource
private EquipmentSpecificIndexMapper equipmentSpecificIndexMapper;
@Resource
private RedisUtils redisUtils;
@Override
public void run(String... args) throws Exception {
log.info(">>服务启动执行,执行预加载数据等操作");
redisUtils.del(RedisKey.EQUIP_INDEX_ADDRESS);
List<EquipmentIndexVO> equipSpecificIndexList = equipmentSpecificIndexMapper.getEquipSpecificIndexList(null);
Map<String, Object> equipmentIndexVOMap = equipSpecificIndexList.stream()
.filter(v -> v.getGatewayId() != null)
.collect(Collectors.toMap(vo -> vo.getIndexAddress() + "_" + vo.getGatewayId(), Function.identity()));
redisUtils.hmset(RedisKey.EQUIP_INDEX_ADDRESS, equipmentIndexVOMap);
}
}
...@@ -76,10 +76,12 @@ public class EquipmentIotMqttReceiveConfig { ...@@ -76,10 +76,12 @@ public class EquipmentIotMqttReceiveConfig {
public void setEquipmentSpecificMapper(EquipmentSpecificMapper equipmentSpecificMapper) { public void setEquipmentSpecificMapper(EquipmentSpecificMapper equipmentSpecificMapper) {
this.equipmentSpecificMapper = equipmentSpecificMapper; this.equipmentSpecificMapper = equipmentSpecificMapper;
} }
@Autowired @Autowired
public void setMqttEventReceiveService(MqttEventReceiveService mqttEventReceiveService) { public void setMqttEventReceiveService(MqttEventReceiveService mqttEventReceiveService) {
this.mqttEventReceiveService = mqttEventReceiveService; this.mqttEventReceiveService = mqttEventReceiveService;
} }
@Autowired @Autowired
public void setiSyncDataService(ISyncDataService iSyncDataService) { public void setiSyncDataService(ISyncDataService iSyncDataService) {
this.iSyncDataService = iSyncDataService; this.iSyncDataService = iSyncDataService;
...@@ -156,10 +158,10 @@ public class EquipmentIotMqttReceiveConfig { ...@@ -156,10 +158,10 @@ public class EquipmentIotMqttReceiveConfig {
mqttReceiveService.handlerMqttIncrementMessage(topic, msg); mqttReceiveService.handlerMqttIncrementMessage(topic, msg);
} else if (dataType.equals("event") && StringUtil.isNotEmpty(msg)) { } else if (dataType.equals("event") && StringUtil.isNotEmpty(msg)) {
mqttEventReceiveService.handlerMqttIncrementMessage(topic, msg); mqttEventReceiveService.handlerMqttIncrementMessage(topic, msg);
}else if (dataType.equals("transmit") && StringUtil.isNotEmpty(msg)){ } else if (dataType.equals("transmit") && StringUtil.isNotEmpty(msg)) {
mqttReceiveService.handlerMqttRomaMessage(topic,msg); mqttReceiveService.handlerMqttRomaMessage(topic, msg);
}else if (dataType.equals("perspective") && StringUtil.isNotEmpty(msg)){ } else if (dataType.equals("perspective") && StringUtil.isNotEmpty(msg)) {
mqttReceiveService.handlerMqttIotMessage(topic,msg); mqttReceiveService.handlerIotMessage(topic, msg);
} else if (dataType.equals("trigger") && StringUtil.isNotEmpty(msg)) { } else if (dataType.equals("trigger") && StringUtil.isNotEmpty(msg)) {
mqttReceiveService.handleDataToRiskModel(topic, msg); mqttReceiveService.handleDataToRiskModel(topic, msg);
} }
......
...@@ -13,6 +13,7 @@ public interface MqttReceiveService { ...@@ -13,6 +13,7 @@ public interface MqttReceiveService {
/** /**
* 增量数据处理 * 增量数据处理
*
* @param topic 主题 * @param topic 主题
* @param message 消息内容 * @param message 消息内容
*/ */
...@@ -20,6 +21,7 @@ public interface MqttReceiveService { ...@@ -20,6 +21,7 @@ public interface MqttReceiveService {
/** /**
* 处理交换站消息数据 * 处理交换站消息数据
*
* @param topic 主题 * @param topic 主题
* @param message 消息内容 * @param message 消息内容
*/ */
...@@ -27,14 +29,25 @@ public interface MqttReceiveService { ...@@ -27,14 +29,25 @@ public interface MqttReceiveService {
/** /**
* 处理Iot消息数据 * 处理Iot消息数据
*
* @param topic 主题 * @param topic 主题
* @param message 消息内容 * @param message 消息内容
*/ */
void handlerMqttIotMessage(String topic, String message); void handlerMqttIotMessage(String topic, String message);
/** /**
* 中心级接收消息发送至消息服务 * 中心级接收消息发送至消息服务
*
* @param topic * @param topic
* @param message * @param message
*/ */
void handleDataToRiskModel(String topic, String message); void handleDataToRiskModel(String topic, String message);
/**
* 处理Iot消息数据
*
* @param topic 主题
* @param message 消息内容
*/
void handlerIotMessage(String topic, String message);
} }
...@@ -324,10 +324,13 @@ ...@@ -324,10 +324,13 @@
ei.`name` AS perfQuotaName, ei.`name` AS perfQuotaName,
si.`value`, si.`value`,
ei.is_iot, ei.is_iot,
ei.unit AS unitName, si.unit AS unitName,
ei.sort_num, ei.sort_num,
si.create_date, si.create_date,
si.update_date si.update_date,
si.index_address,
si.gateway_id,
si.data_type
FROM FROM
wl_equipment_specific_index si wl_equipment_specific_index si
LEFT JOIN wl_equipment_index ei ON si.equipment_index_id = ei.id LEFT JOIN wl_equipment_index ei ON si.equipment_index_id = ei.id
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment