Commit d4bf8590 authored by 刘林's avatar 刘林

fix(equip):装备代码集成influxDB,版本1.0,添加单位字段

parent 501bbca5
...@@ -357,22 +357,22 @@ public class MqttReceiveServiceImpl implements MqttReceiveService { ...@@ -357,22 +357,22 @@ public class MqttReceiveServiceImpl implements MqttReceiveService {
JSONObject jsonObject = JSONObject.parseObject(message); JSONObject jsonObject = JSONObject.parseObject(message);
String dataType = jsonObject.getString("datatype"); String dataType = jsonObject.getString("datatype");
String indexAddress,value,timeStamp,quality = null; String indexAddress, value, timeStamp, quality = null;
//如果消息是遥信类型,进行指标转换 //如果消息是遥信类型,进行指标转换
if(dataType != null && dataType.equals("state")){ if (dataType != null && dataType.equals("state")) {
indexAddress = jsonObject.getString("scadaid"); indexAddress = jsonObject.getString("scadaid");
value = jsonObject.getInteger("value") ==1 ? "true":"false"; value = jsonObject.getInteger("value") == 1 ? "true" : "false";
timeStamp = jsonObject.getString("timestamp"); timeStamp = jsonObject.getString("timestamp");
}else{ } else {
indexAddress = jsonObject.getString("key"); indexAddress = jsonObject.getString("key");
value = jsonObject.getString("value"); value = jsonObject.getString("value");
timeStamp = jsonObject.getString("time_stamp"); timeStamp = jsonObject.getString("time_stamp");
quality = jsonObject.getString("quality"); quality = jsonObject.getString("quality");
} }
EquipmentSpecificIndex equipmentSpeIndex = equipmentSpecificIndexService.getEquipmentSpeIndexByIndexAddress(indexAddress,null); EquipmentSpecificIndex equipmentSpeIndex = equipmentSpecificIndexService.getEquipmentSpeIndexByIndexAddress(indexAddress, null);
if (equipmentSpeIndex == null){ if (equipmentSpeIndex == null) {
return; return;
} }
equipmentSpeIndex.setValue(value); equipmentSpeIndex.setValue(value);
...@@ -625,11 +625,11 @@ public class MqttReceiveServiceImpl implements MqttReceiveService { ...@@ -625,11 +625,11 @@ public class MqttReceiveServiceImpl implements MqttReceiveService {
String traceId = jsonObject.getString("traceId"); String traceId = jsonObject.getString("traceId");
String deviceCode = jsonObject.getString("deviceCode"); String deviceCode = jsonObject.getString("deviceCode");
String gatewayId = jsonObject.getString("gatewayId"); String gatewayId = jsonObject.getString("gatewayId");
String value=jsonObject.getString("value"); String value = jsonObject.getString("value");
EquipmentSpecificIndex equipmentSpeIndex = equipmentSpecificIndexService.getEquipmentSpeIndexByIndexAddress(indexAddress,gatewayId); EquipmentSpecificIndex equipmentSpeIndex = equipmentSpecificIndexService.getEquipmentSpeIndexByIndexAddress(indexAddress, gatewayId);
if (equipmentSpeIndex == null){ if (equipmentSpeIndex == null) {
return; return;
} }
...@@ -644,7 +644,7 @@ public class MqttReceiveServiceImpl implements MqttReceiveService { ...@@ -644,7 +644,7 @@ public class MqttReceiveServiceImpl implements MqttReceiveService {
//更新装备性能指标 //更新装备性能指标
//equipmentSpecificIndexService.updateById(equipmentSpeIndex); //equipmentSpecificIndexService.updateById(equipmentSpeIndex);
tagsMap.put("key", indexAddress+"_"+gatewayId); tagsMap.put("key", indexAddress + "_" + gatewayId);
fieldsMap.put("traceId", traceId); fieldsMap.put("traceId", traceId);
fieldsMap.put("address", indexAddress); fieldsMap.put("address", indexAddress);
...@@ -655,10 +655,12 @@ public class MqttReceiveServiceImpl implements MqttReceiveService { ...@@ -655,10 +655,12 @@ public class MqttReceiveServiceImpl implements MqttReceiveService {
fieldsMap.put("equipmentIndexName", equipmentSpeIndex.getEquipmentIndexName()); fieldsMap.put("equipmentIndexName", equipmentSpeIndex.getEquipmentIndexName());
fieldsMap.put("equipmentIndexKey", equipmentSpeIndex.getEquipmentIndexKey()); fieldsMap.put("equipmentIndexKey", equipmentSpeIndex.getEquipmentIndexKey());
fieldsMap.put("isAlarm", equipmentSpeIndex.getIsAlarm().toString()); fieldsMap.put("isAlarm", equipmentSpeIndex.getIsAlarm().toString());
fieldsMap.put("unit", equipmentSpeIndex.getUnit());
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
fieldsMap.put("createdTime", simpleDateFormat.format(new Date())); fieldsMap.put("createdTime", simpleDateFormat.format(new Date()));
fieldsMap.put("equipmentIndex", JSON.toJSONString(equipmentSpeIndex)); fieldsMap.put("equipmentIndex", JSON.toJSONString(equipmentSpeIndex));
//保存influxDB库
influxDbConnection.insert("iot_data", tagsMap, fieldsMap); influxDbConnection.insert("iot_data", tagsMap, fieldsMap);
QueryWrapper<EquipmentSpecific> queryWrapper = new QueryWrapper<>(); QueryWrapper<EquipmentSpecific> queryWrapper = new QueryWrapper<>();
...@@ -697,7 +699,7 @@ public class MqttReceiveServiceImpl implements MqttReceiveService { ...@@ -697,7 +699,7 @@ public class MqttReceiveServiceImpl implements MqttReceiveService {
TransactionSynchronizationManager.registerSynchronization(new TransactionSynchronization() { TransactionSynchronizationManager.registerSynchronization(new TransactionSynchronization() {
@Override @Override
public void afterCommit() { public void afterCommit() {
// 直流中心消息推送刷新 // 直流中心消息推送刷新
publishDataToDCCenterPage(equipmentSpecificIndexList); publishDataToDCCenterPage(equipmentSpecificIndexList);
......
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