|
@@ -3,13 +3,10 @@ package com.gyee.wisdom.alarm.windturbine.transport.restful;
|
|
|
|
|
|
import com.gyee.wisdom.alarm.windturbine.config.Status8Properties;
|
|
import com.gyee.wisdom.alarm.windturbine.config.Status8Properties;
|
|
import com.gyee.wisdom.alarm.windturbine.model.TagInfo;
|
|
import com.gyee.wisdom.alarm.windturbine.model.TagInfo;
|
|
-import com.gyee.wisdom.alarm.windturbine.model.ThingType;
|
|
|
|
import com.gyee.wisdom.alarm.windturbine.service.AlertSnapFactory;
|
|
import com.gyee.wisdom.alarm.windturbine.service.AlertSnapFactory;
|
|
import com.gyee.wisdom.alarm.windturbine.service.CacheService;
|
|
import com.gyee.wisdom.alarm.windturbine.service.CacheService;
|
|
import com.gyee.wisdom.alarm.windturbine.service.SqlService;
|
|
import com.gyee.wisdom.alarm.windturbine.service.SqlService;
|
|
-import com.gyee.wisdom.alarm.windturbine.service.WarningrecordsFactory;
|
|
|
|
import com.gyee.wisdom.alarm.windturbine.transport.shardingclient.dto.AlarmSnap;
|
|
import com.gyee.wisdom.alarm.windturbine.transport.shardingclient.dto.AlarmSnap;
|
|
-import com.gyee.wisdom.common.data.alarm.Warningrecords;
|
|
|
|
import com.gyee.wisdom.common.data.timeseries.BooleanTsData;
|
|
import com.gyee.wisdom.common.data.timeseries.BooleanTsData;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@@ -88,50 +85,50 @@ public class RestfulClient {
|
|
//List<Warningrecords> warnList = new ArrayList<>();
|
|
//List<Warningrecords> warnList = new ArrayList<>();
|
|
for (Map.Entry<String, HashMap<String, Object>> entry : map.entrySet()) {
|
|
for (Map.Entry<String, HashMap<String, Object>> entry : map.entrySet()) {
|
|
|
|
|
|
- String tagId = entry.getKey();
|
|
|
|
|
|
+ String tagId = entry.getKey();
|
|
|
|
+
|
|
|
|
+ TagInfo tagInfo = getTagInfoMap().get(tagId);
|
|
|
|
+ BooleanTsData tsData = getTsData(entry.getValue());
|
|
|
|
+ if (tsData == null || tsData.getTs() == 0) {
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+ if (tsData.getBooleanValue()) {
|
|
|
|
+
|
|
|
|
+ if (tagInfo.getLastTsData() == null || tagInfo.getLastTsData().getBooleanValue() == false) {
|
|
|
|
+ tagInfo.setLastTsData(tsData);
|
|
|
|
|
|
- TagInfo tagInfo = getTagInfoMap().get(tagId);
|
|
|
|
- BooleanTsData tsData = getTsData(entry.getValue());
|
|
|
|
- if (tsData == null || tsData.getTs() == 0) {
|
|
|
|
- continue;
|
|
|
|
- }
|
|
|
|
- if (tsData.getBooleanValue()) {
|
|
|
|
-
|
|
|
|
- if (tagInfo.getLastTsData() == null || tagInfo.getLastTsData().getBooleanValue() == false) {
|
|
|
|
- tagInfo.setLastTsData(tsData);
|
|
|
|
-
|
|
|
|
- AlarmSnap snap = findAlertSnap(tagInfo.getId());
|
|
|
|
- if (snap == null) {
|
|
|
|
- snap = AlertSnapFactory.createAlertsnapNew(tagInfo);
|
|
|
|
- mapSnap.put(snap.getTestingpointKey(), snap);
|
|
|
|
- }
|
|
|
|
- else {
|
|
|
|
- if (snap.getIsOpened() == 1)
|
|
|
|
- continue;
|
|
|
|
- snap.setDataInfo("0");
|
|
|
|
- snap.setCategory3("0");
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- snap.setIsOpened(1);
|
|
|
|
- //snap.setIsConfirmed(0);
|
|
|
|
- snap.setLastUpdateTime(new Date());
|
|
|
|
- snapList.add(snap);
|
|
|
|
-
|
|
|
|
- // Warningrecords wrec = WarningrecordsFactory.createWarningrecords(tagInfo,"0");
|
|
|
|
- // warnList.add(wrec);
|
|
|
|
- }
|
|
|
|
- } else {
|
|
|
|
AlarmSnap snap = findAlertSnap(tagInfo.getId());
|
|
AlarmSnap snap = findAlertSnap(tagInfo.getId());
|
|
- if (snap != null && snap.getIsOpened() == 1) {
|
|
|
|
- snap.setIsOpened(0);
|
|
|
|
- //snap.setIsConfirmed(1);
|
|
|
|
- snap.setLastUpdateTime(new Date());
|
|
|
|
- snapList.add(snap);
|
|
|
|
|
|
+ if (snap == null) {
|
|
|
|
+ snap = AlertSnapFactory.createAlertsnapNew(tagInfo);
|
|
|
|
+ mapSnap.put(snap.getTestingpointKey(), snap);
|
|
|
|
+ }
|
|
|
|
+ else {
|
|
|
|
+ if (snap.getIsOpened() == 1)
|
|
|
|
+ continue;
|
|
snap.setDataInfo("0");
|
|
snap.setDataInfo("0");
|
|
snap.setCategory3("0");
|
|
snap.setCategory3("0");
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ snap.setIsOpened(1);
|
|
|
|
+ //snap.setIsConfirmed(0);
|
|
|
|
+ snap.setLastUpdateTime(new Date());
|
|
|
|
+ snapList.add(snap);
|
|
|
|
+
|
|
|
|
+ // Warningrecords wrec = WarningrecordsFactory.createWarningrecords(tagInfo,"0");
|
|
|
|
+ // warnList.add(wrec);
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ AlarmSnap snap = findAlertSnap(tagInfo.getId());
|
|
|
|
+ if (snap != null && snap.getIsOpened() == 1) {
|
|
|
|
+ snap.setIsOpened(0);
|
|
|
|
+ //snap.setIsConfirmed(1);
|
|
|
|
+ snap.setLastUpdateTime(new Date());
|
|
|
|
+ snapList.add(snap);
|
|
|
|
+ snap.setDataInfo("0");
|
|
|
|
+ snap.setCategory3("0");
|
|
}
|
|
}
|
|
- tagInfo.setLastTsData(tsData);
|
|
|
|
|
|
+ }
|
|
|
|
+ tagInfo.setLastTsData(tsData);
|
|
}
|
|
}
|
|
|
|
|
|
if (snapList.size() > 0) {
|
|
if (snapList.size() > 0) {
|
|
@@ -139,11 +136,11 @@ public class RestfulClient {
|
|
sqlService.saveAlarmSnaps(snapList);
|
|
sqlService.saveAlarmSnaps(snapList);
|
|
//snapList.clear();
|
|
//snapList.clear();
|
|
}
|
|
}
|
|
- //warningrecord 不再写入
|
|
|
|
- //if (warnList.size() > 0) {
|
|
|
|
- // sqlService.saveWarningrecordsList(warnList);
|
|
|
|
- // //warnList.clear();
|
|
|
|
- //}
|
|
|
|
|
|
+ //warningrecord 不再写入
|
|
|
|
+ //if (warnList.size() > 0) {
|
|
|
|
+ // sqlService.saveWarningrecordsList(warnList);
|
|
|
|
+ // //warnList.clear();
|
|
|
|
+ //}
|
|
} catch (Exception ex) {
|
|
} catch (Exception ex) {
|
|
log.error("----------------{}", ex.getMessage());
|
|
log.error("----------------{}", ex.getMessage());
|
|
}
|
|
}
|
|
@@ -162,12 +159,23 @@ public class RestfulClient {
|
|
short status = ((Integer) hmp.get("status")).shortValue();
|
|
short status = ((Integer) hmp.get("status")).shortValue();
|
|
boolean bValue = false;
|
|
boolean bValue = false;
|
|
Object bo = hmp.get("booleanValue");
|
|
Object bo = hmp.get("booleanValue");
|
|
- if (bo.equals(true) || bo.equals(false))
|
|
|
|
- return new BooleanTsData(ts, status, (boolean)bo);
|
|
|
|
- else if ("true".equals(bo) || "1".equals(bo)) {
|
|
|
|
- bValue = true;
|
|
|
|
|
|
+ if(bo==null){
|
|
|
|
+ bo = hmp.get("doubleValue");
|
|
|
|
+ if (bo.equals(1))
|
|
|
|
+ return new BooleanTsData(ts, status, true);
|
|
|
|
+ else {
|
|
|
|
+ return new BooleanTsData(ts, status, false);
|
|
|
|
+ }
|
|
|
|
+ }else{
|
|
|
|
+ if (bo.equals(true) || bo.equals(false)) {
|
|
|
|
+ return new BooleanTsData(ts, status, (boolean) bo);
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ else if ("true".equals(bo) || "1".equals(bo)) {
|
|
|
|
+ bValue = true;
|
|
|
|
+ }
|
|
}
|
|
}
|
|
- return new BooleanTsData(ts, status, bValue);
|
|
|
|
|
|
+ return new BooleanTsData(ts, status, bValue);
|
|
|
|
|
|
} catch (Exception ex) {
|
|
} catch (Exception ex) {
|
|
log.info("------------{}", ex.getMessage());
|
|
log.info("------------{}", ex.getMessage());
|
|
@@ -181,7 +189,7 @@ public class RestfulClient {
|
|
return mapSnap.get(tagId);
|
|
return mapSnap.get(tagId);
|
|
else {
|
|
else {
|
|
AlarmSnap snap = sqlService.getAlertSnap(tagId);
|
|
AlarmSnap snap = sqlService.getAlertSnap(tagId);
|
|
- mapSnap.put(tagId, snap);
|
|
|
|
|
|
+ mapSnap.put(tagId, snap);
|
|
return snap;
|
|
return snap;
|
|
}
|
|
}
|
|
}
|
|
}
|