|
@@ -71,38 +71,27 @@ public class AllPostTopic implements BusinessAgreement<AllPostDto> { |
|
@@ -71,38 +71,27 @@ public class AllPostTopic implements BusinessAgreement<AllPostDto> { |
|
71
|
{
|
71
|
{
|
|
72
|
if(deviceDataConfigMap.containsKey(key))
|
72
|
if(deviceDataConfigMap.containsKey(key))
|
|
73
|
{
|
73
|
{
|
|
|
|
74
|
+ log.info("点位{}",key);
|
|
74
|
String dttribute_value = object.get(key).toString();
|
75
|
String dttribute_value = object.get(key).toString();
|
|
75
|
String newDataValue= ByteUtil.changerTwoStr(dttribute_value);
|
76
|
String newDataValue= ByteUtil.changerTwoStr(dttribute_value);
|
|
76
|
|
77
|
|
|
77
|
DeviceDataConfig deviceDataConfig = deviceDataConfigMap.get(key);
|
78
|
DeviceDataConfig deviceDataConfig = deviceDataConfigMap.get(key);
|
|
78
|
- String newAlrmCode = "00";
|
|
|
|
79
|
String deviceInfoId = deviceDataConfig.getDeviceInfoId(topic.getClientid()); //根据点位协议解析到设备id
|
79
|
String deviceInfoId = deviceDataConfig.getDeviceInfoId(topic.getClientid()); //根据点位协议解析到设备id
|
|
80
|
- DeviceInfo deviceInfo = getDeviceInfo(deviceInfoList,deviceInfoId);
|
|
|
|
81
|
- if(null != deviceInfo)
|
80
|
+ log.info("点位对应的设备id{}",deviceInfoId);
|
|
|
|
81
|
+ if(deviceInfoId.equals(topic.getClientid()))
|
|
82
|
{
|
82
|
{
|
|
83
|
- switch (PLCDataType.valueOf(deviceDataConfig.getPlc_data_type()))
|
83
|
+ if(null != list )
|
|
84
|
{
|
84
|
{
|
|
85
|
- case 故障代码:
|
|
|
|
86
|
- if(newDataValue.equals(deviceDataConfig.getAlarmValue()))
|
|
|
|
87
|
- {
|
|
|
|
88
|
- newAlrmCode = deviceDataConfig.getAlarmCode();
|
|
|
|
89
|
- }
|
|
|
|
90
|
- break;
|
|
|
|
91
|
- case 控制柜状态:
|
|
|
|
92
|
- analysisData(data,deviceInfo,deviceDataConfig,newDataValue,topic);
|
|
|
|
93
|
- break;
|
|
|
|
94
|
- case 校准时间:
|
|
|
|
95
|
- analysisData(data,deviceInfo,deviceDataConfig,newDataValue,topic);
|
|
|
|
96
|
- break;
|
|
|
|
97
|
- default:
|
|
|
|
98
|
- analysisData(data,deviceInfo,deviceDataConfig,newDataValue,topic);
|
|
|
|
99
|
- break;
|
85
|
+ for (DeviceInfo deviceInfo:list)
|
|
|
|
86
|
+ {
|
|
|
|
87
|
+ updevice(deviceInfo,deviceDataConfig,topic,data,newDataValue);
|
|
|
|
88
|
+ }
|
|
100
|
}
|
89
|
}
|
|
101
|
- deviceInfo.setAlarmCode(newAlrmCode);
|
|
|
|
102
|
- deviceInfo.setDataUpdateTime(DateUtils.getNowTimeMilly());
|
|
|
|
103
|
- deviceInfo.setDeviceServiceIp(SysParameter.service_ip);
|
|
|
|
104
|
- deviceInfo.setOnline("01");
|
90
|
+ }else {
|
|
|
|
91
|
+ DeviceInfo deviceInfo = getDeviceInfo(deviceInfoList,deviceInfoId);
|
|
|
|
92
|
+ updevice(deviceInfo,deviceDataConfig,topic,data,newDataValue);
|
|
105
|
}
|
93
|
}
|
|
|
|
94
|
+
|
|
106
|
}
|
95
|
}
|
|
107
|
|
96
|
|
|
108
|
}
|
97
|
}
|
|
@@ -112,6 +101,41 @@ public class AllPostTopic implements BusinessAgreement<AllPostDto> { |
|
@@ -112,6 +101,41 @@ public class AllPostTopic implements BusinessAgreement<AllPostDto> { |
|
112
|
return data;
|
101
|
return data;
|
|
113
|
}
|
102
|
}
|
|
114
|
|
103
|
|
|
|
|
104
|
+
|
|
|
|
105
|
+ private void updevice(DeviceInfo deviceInfo, DeviceDataConfig deviceDataConfig,Topic topic,AllPostDto data,String newDataValue)
|
|
|
|
106
|
+ {
|
|
|
|
107
|
+ if(null != deviceInfo)
|
|
|
|
108
|
+ {
|
|
|
|
109
|
+ String newAlrmCode = "00";
|
|
|
|
110
|
+
|
|
|
|
111
|
+ switch (PLCDataType.valueOf(deviceDataConfig.getPlc_data_type()))
|
|
|
|
112
|
+ {
|
|
|
|
113
|
+ case 故障代码:
|
|
|
|
114
|
+ log.info("故障代码{}",newDataValue);
|
|
|
|
115
|
+ if(newDataValue.equals(deviceDataConfig.getAlarmValue()))
|
|
|
|
116
|
+ {
|
|
|
|
117
|
+ newAlrmCode = deviceDataConfig.getAlarmCode();
|
|
|
|
118
|
+ }
|
|
|
|
119
|
+ break;
|
|
|
|
120
|
+ case 控制柜状态:
|
|
|
|
121
|
+ log.info("控制柜状态{}",newDataValue);
|
|
|
|
122
|
+ analysisData(data,deviceInfo,deviceDataConfig,newDataValue,topic);
|
|
|
|
123
|
+ break;
|
|
|
|
124
|
+ case 校准时间:
|
|
|
|
125
|
+ log.info("校准时间{}",newDataValue);
|
|
|
|
126
|
+ analysisData(data,deviceInfo,deviceDataConfig,newDataValue,topic);
|
|
|
|
127
|
+ break;
|
|
|
|
128
|
+ default:
|
|
|
|
129
|
+ log.info("默认功能{}",newDataValue);
|
|
|
|
130
|
+ analysisData(data,deviceInfo,deviceDataConfig,newDataValue,topic);
|
|
|
|
131
|
+ break;
|
|
|
|
132
|
+ }
|
|
|
|
133
|
+ deviceInfo.setAlarmCode(newAlrmCode);
|
|
|
|
134
|
+ deviceInfo.setDataUpdateTime(DateUtils.getNowTimeMilly());
|
|
|
|
135
|
+ deviceInfo.setDeviceServiceIp(SysParameter.service_ip);
|
|
|
|
136
|
+ deviceInfo.setOnline("01");
|
|
|
|
137
|
+ }
|
|
|
|
138
|
+ }
|
|
115
|
private void analysisTime( JSONObject jsonObject,Map<String, DeviceDataConfig> deviceDataConfigMap,Topic topic,List<DeviceInfo> deviceInfoList)
|
139
|
private void analysisTime( JSONObject jsonObject,Map<String, DeviceDataConfig> deviceDataConfigMap,Topic topic,List<DeviceInfo> deviceInfoList)
|
|
116
|
{
|
140
|
{
|
|
117
|
if(null != jsonObject && jsonObject.size() != 0)
|
141
|
if(null != jsonObject && jsonObject.size() != 0)
|
|
@@ -227,6 +251,7 @@ public class AllPostTopic implements BusinessAgreement<AllPostDto> { |
|
@@ -227,6 +251,7 @@ public class AllPostTopic implements BusinessAgreement<AllPostDto> { |
|
227
|
jsonObject = GsonConstructor.get().fromJson(dataValue,JSONObject.class);
|
251
|
jsonObject = GsonConstructor.get().fromJson(dataValue,JSONObject.class);
|
|
228
|
}
|
252
|
}
|
|
229
|
String odlDataValue = (String) jsonObject.get(PLCDataType.valueOf(deviceDataConfig.getPlc_data_type()).sensorDataType);
|
253
|
String odlDataValue = (String) jsonObject.get(PLCDataType.valueOf(deviceDataConfig.getPlc_data_type()).sensorDataType);
|
|
|
|
254
|
+ log.info("数据变化"+deviceDataConfig.getAttribute_name()+" "+odlDataValue+"-->"+newDataValue);
|
|
230
|
if(!newDataValue.equals(odlDataValue))
|
255
|
if(!newDataValue.equals(odlDataValue))
|
|
231
|
{
|
256
|
{
|
|
232
|
jsonObject.put(PLCDataType.valueOf(deviceDataConfig.getPlc_data_type()).sensorDataType,newDataValue); //更新数据
|
257
|
jsonObject.put(PLCDataType.valueOf(deviceDataConfig.getPlc_data_type()).sensorDataType,newDataValue); //更新数据
|