Commit d4bf8590 authored by 刘林's avatar 刘林

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

parent 501bbca5
......@@ -357,22 +357,22 @@ public class MqttReceiveServiceImpl implements MqttReceiveService {
JSONObject jsonObject = JSONObject.parseObject(message);
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");
value = jsonObject.getInteger("value") ==1 ? "true":"false";
value = jsonObject.getInteger("value") == 1 ? "true" : "false";
timeStamp = jsonObject.getString("timestamp");
}else{
} else {
indexAddress = jsonObject.getString("key");
value = jsonObject.getString("value");
timeStamp = jsonObject.getString("time_stamp");
quality = jsonObject.getString("quality");
}
EquipmentSpecificIndex equipmentSpeIndex = equipmentSpecificIndexService.getEquipmentSpeIndexByIndexAddress(indexAddress,null);
if (equipmentSpeIndex == null){
EquipmentSpecificIndex equipmentSpeIndex = equipmentSpecificIndexService.getEquipmentSpeIndexByIndexAddress(indexAddress, null);
if (equipmentSpeIndex == null) {
return;
}
equipmentSpeIndex.setValue(value);
......@@ -625,11 +625,11 @@ public class MqttReceiveServiceImpl implements MqttReceiveService {
String traceId = jsonObject.getString("traceId");
String deviceCode = jsonObject.getString("deviceCode");
String gatewayId = jsonObject.getString("gatewayId");
String value=jsonObject.getString("value");
String value = jsonObject.getString("value");
EquipmentSpecificIndex equipmentSpeIndex = equipmentSpecificIndexService.getEquipmentSpeIndexByIndexAddress(indexAddress,gatewayId);
if (equipmentSpeIndex == null){
EquipmentSpecificIndex equipmentSpeIndex = equipmentSpecificIndexService.getEquipmentSpeIndexByIndexAddress(indexAddress, gatewayId);
if (equipmentSpeIndex == null) {
return;
}
......@@ -644,7 +644,7 @@ public class MqttReceiveServiceImpl implements MqttReceiveService {
//更新装备性能指标
//equipmentSpecificIndexService.updateById(equipmentSpeIndex);
tagsMap.put("key", indexAddress+"_"+gatewayId);
tagsMap.put("key", indexAddress + "_" + gatewayId);
fieldsMap.put("traceId", traceId);
fieldsMap.put("address", indexAddress);
......@@ -655,10 +655,12 @@ public class MqttReceiveServiceImpl implements MqttReceiveService {
fieldsMap.put("equipmentIndexName", equipmentSpeIndex.getEquipmentIndexName());
fieldsMap.put("equipmentIndexKey", equipmentSpeIndex.getEquipmentIndexKey());
fieldsMap.put("isAlarm", equipmentSpeIndex.getIsAlarm().toString());
fieldsMap.put("unit", equipmentSpeIndex.getUnit());
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
fieldsMap.put("createdTime", simpleDateFormat.format(new Date()));
fieldsMap.put("equipmentIndex", JSON.toJSONString(equipmentSpeIndex));
//保存influxDB库
influxDbConnection.insert("iot_data", tagsMap, fieldsMap);
QueryWrapper<EquipmentSpecific> queryWrapper = new QueryWrapper<>();
......
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