#update
This commit is contained in:
@@ -14,6 +14,7 @@ import java.util.concurrent.ScheduledExecutorService;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import com.maibu.memory.DeviceSessionManager;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.eclipse.paho.client.mqttv3.MqttException;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -36,7 +37,6 @@ import com.maibu.core.enums.ErrorSource;
|
||||
import com.maibu.core.enums.RespondCode;
|
||||
import com.maibu.core.redis.RedisCache;
|
||||
import com.maibu.dto.DeviceErrorPushDTO;
|
||||
import com.maibu.manager.DeviceSessionManager;
|
||||
import com.maibu.mapper.ErrorIdentificationStandardMapper;
|
||||
import com.maibu.memory.GlobalMemory;
|
||||
import com.maibu.memory.SiteMemory;
|
||||
@@ -92,19 +92,22 @@ public class DeviceThreadService {
|
||||
String[] parts = k.split(":");
|
||||
String deviceId = parts[1];
|
||||
NettyDevice slaveDevice = sessionManager.getDevice(deviceId);
|
||||
Long siteId = slaveDevice != null ? slaveDevice.getDevice().getSiteId() : null;
|
||||
Long orgId = slaveDevice != null ? slaveDevice.getDevice().getOrgId() : null;
|
||||
|
||||
SiteMemory siteMemory = GlobalMemory.getSiteMemory(orgId, siteId);
|
||||
List<AlarmMessage> compared = compareErrorStandard(siteId, orgId, history,
|
||||
siteMemory.standards.get(ErrorSource.MOWER));
|
||||
|
||||
DeviceErrorPushDTO pushDTO = new DeviceErrorPushDTO();
|
||||
pushDTO.setDeviceId(deviceId);
|
||||
pushDTO.setTime(System.currentTimeMillis());
|
||||
pushDTO.setDetails(compared);
|
||||
pushDTO.setEvent(RespondCode.device_error_push);
|
||||
pushList.add(pushDTO);
|
||||
if (slaveDevice != null && slaveDevice.isOnline()) {
|
||||
Long siteId = slaveDevice.getDevice().getSiteId();
|
||||
Long orgId = slaveDevice.getDevice().getOrgId();
|
||||
log.debug("compare siteId:{},orgId:{}", siteId, orgId);
|
||||
SiteMemory siteMemory = GlobalMemory.getSiteMemory(orgId, siteId);
|
||||
if (siteMemory != null) {
|
||||
List<AlarmMessage> compared = compareErrorStandard(siteId, orgId, history,
|
||||
siteMemory.standards.get(ErrorSource.MOWER));
|
||||
DeviceErrorPushDTO pushDTO = new DeviceErrorPushDTO();
|
||||
pushDTO.setDeviceId(deviceId);
|
||||
pushDTO.setTime(System.currentTimeMillis());
|
||||
pushDTO.setDetails(compared);
|
||||
pushDTO.setEvent(RespondCode.device_error_push);
|
||||
pushList.add(pushDTO);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
// 按实际deviceId分组,推送错误信息
|
||||
@@ -195,7 +198,7 @@ public class DeviceThreadService {
|
||||
}
|
||||
|
||||
public List<AlarmMessage> compareErrorStandard(Long siteId, Long orgId, DeviceRunningStatusHistory history,
|
||||
List<ErrorIdentificationStandard> standards) {
|
||||
List<ErrorIdentificationStandard> standards) {
|
||||
if (history == null || CollectionUtils.isEmpty(standards))
|
||||
return null;
|
||||
List<AlarmMessage> list = new ArrayList<>();
|
||||
@@ -204,9 +207,11 @@ public class DeviceThreadService {
|
||||
String compareValues = standard.getCompareValues();
|
||||
CompareEnum compareType = standard.getCompareType();
|
||||
String targetValue = knownClassFieldFinding(fieldName, history);
|
||||
log.debug("compare2 compareType:{} compareValues:{},targetValue:{}", compareType, compareValues, targetValue);
|
||||
if (!StringUtils.isEmpty(compareValues) && !StringUtils.isEmpty(targetValue)) {
|
||||
boolean result = CompareUtils.compare(compareType, compareValues, targetValue);
|
||||
if (!result) {
|
||||
boolean result = CompareUtils.compare(compareType, targetValue, compareValues);
|
||||
log.debug("compare3 result:{}", result);
|
||||
if (result) {
|
||||
AlarmMessage alarm = new AlarmMessage();
|
||||
alarm.setContent(standard.getErrorDescription());
|
||||
alarm.setDeviceSn(history.getDeviceId());
|
||||
@@ -217,6 +222,7 @@ public class DeviceThreadService {
|
||||
alarm.setNo(standard.getErrorCode());
|
||||
alarm.setSuggestion(standard.getSuggestion());
|
||||
alarm.setStatus("未处理");
|
||||
alarm.setTimeValues(targetValue);
|
||||
alarm.setTime(LocalDateTime.now());
|
||||
alarm.setOrgId(orgId);
|
||||
alarm.setSiteId(siteId);
|
||||
|
||||
Reference in New Issue
Block a user