根据心跳更新风机通讯状态
This commit is contained in:
parent
ab64bf4ee3
commit
68c15b469a
@ -1,7 +1,10 @@
|
|||||||
package com.das.modules.node.command;
|
package com.das.modules.node.command;
|
||||||
|
|
||||||
|
import com.das.common.constant.EquipmentTypeIds;
|
||||||
import com.das.common.utils.AdminRedisTemplate;
|
import com.das.common.utils.AdminRedisTemplate;
|
||||||
import com.das.common.utils.StringUtils;
|
import com.das.common.utils.StringUtils;
|
||||||
|
import com.das.modules.cache.domain.DeviceInfoCache;
|
||||||
|
import com.das.modules.cache.service.CacheService;
|
||||||
import com.das.modules.node.constant.NodeConstant;
|
import com.das.modules.node.constant.NodeConstant;
|
||||||
import com.das.modules.node.domain.bo.TerminalMessage;
|
import com.das.modules.node.domain.bo.TerminalMessage;
|
||||||
import com.fasterxml.jackson.databind.JsonNode;
|
import com.fasterxml.jackson.databind.JsonNode;
|
||||||
@ -17,6 +20,9 @@ public class HeartbeatCommand implements BaseCommand{
|
|||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
AdminRedisTemplate adminRedisTemplate;
|
AdminRedisTemplate adminRedisTemplate;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
CacheService cacheService;
|
||||||
@Override
|
@Override
|
||||||
public void doCommand(TerminalMessage data) {
|
public void doCommand(TerminalMessage data) {
|
||||||
JsonNode dataInfo = data.getData();
|
JsonNode dataInfo = data.getData();
|
||||||
@ -39,6 +45,27 @@ public class HeartbeatCommand implements BaseCommand{
|
|||||||
adminRedisTemplate.expire(key, 300L);
|
adminRedisTemplate.expire(key, 300L);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
JsonNode devices = data.getData().get("devices");
|
||||||
|
if (devices != null && devices.isArray()) {
|
||||||
|
for (JsonNode device : devices) {
|
||||||
|
Long deviceId = device.get("deviceId").asLong();
|
||||||
|
Boolean online = device.get("online").asBoolean();
|
||||||
|
DeviceInfoCache deviceInfoCacheById = cacheService.getEquipmentCache().getDeviceInfoCacheById(deviceId);
|
||||||
|
if (deviceInfoCacheById == null || !deviceInfoCacheById.getObjectType().equals(EquipmentTypeIds.EQUIPMENT_TYPE_STATION_WTG)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
//判断是不是风机
|
||||||
|
String keyPLCDeviceStatus = String.format("RT:%d:iturbineoperationmode", deviceId);
|
||||||
|
String keyDeviceStatus = String.format("RT:%d:commfaultstate");
|
||||||
|
Integer plcDeviceStatus = adminRedisTemplate.get(keyPLCDeviceStatus);
|
||||||
|
if (plcDeviceStatus == null){
|
||||||
|
adminRedisTemplate.set(keyDeviceStatus, online ? 1 : 0);
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
adminRedisTemplate.set(keyDeviceStatus, online && plcDeviceStatus == 1 ? 1 : 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user