Commit 85388bb5 authored by 刘林's avatar 刘林

fix(equip):江西数据中心接收消息优化

parent f6401551
......@@ -34,7 +34,7 @@ public class EquipmentIndexCacheRunner implements CommandLineRunner {
redisUtils.del(RedisKey.EQUIP_INDEX_ADDRESS);
List<EquipmentIndexVO> equipSpecificIndexList = equipmentSpecificIndexMapper.getEquipSpecificIndexList(null);
Map<String, Object> equipmentIndexVOMap = equipSpecificIndexList.stream()
.filter(v -> v.getGatewayId() != null)
.filter(v -> v.getGatewayId() != null && v.getIndexAddress() !=null)
.collect(Collectors.toMap(vo -> vo.getIndexAddress() + "_" + vo.getGatewayId(), Function.identity()));
redisUtils.hmset(RedisKey.EQUIP_INDEX_ADDRESS, equipmentIndexVOMap);
......
......@@ -640,8 +640,6 @@ public class MqttReceiveServiceImpl implements MqttReceiveService {
dataExecutor.execute(new Runnable() {
@Override
public void run() {
log.info("接收到iot消息: {}", message);
JSONObject jsonObject = JSONObject.parseObject(message);
String dataType = jsonObject.getString("dataType");
String indexAddress = jsonObject.getString("address");
......@@ -653,10 +651,12 @@ public class MqttReceiveServiceImpl implements MqttReceiveService {
try {
if (equipmentIndexVOMap.get(key) != null) {
Map<String, String> tagsMap = new HashMap<>();
Map<String, Object> fieldsMap = new HashMap<>();
EquipmentIndexVO equipmentSpeIndex = (EquipmentIndexVO) equipmentIndexVOMap.get(key);
log.info("接收到iot消息: 指标名称:{},地址:{},值:{},网关{}",
equipmentSpeIndex.getEquipmentIndexName(),indexAddress,value,gatewayId);
Map<String, String> tagsMap = new HashMap<>();
Map<String, Object> fieldsMap = new HashMap<>();
tagsMap.put("equipmentsIdx", key);
String valueLabel = valueTranslate(value, equipmentSpeIndex.getValueEnum());
......@@ -676,6 +676,7 @@ public class MqttReceiveServiceImpl implements MqttReceiveService {
//保存influxDB库
influxDbConnection.insert("iot_data", tagsMap, fieldsMap);
log.info("influxdb入库时间:{}",simpleDateFormat.format(new Date()));
}
} catch (Exception e) {
log.error("Iot透传消息解析入库失败" + e.getMessage(), e);
......
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