|
|
@@ -12,6 +12,7 @@ import com.yunfeiyun.agmp.iot.common.domain.IotWarnconfig;
|
|
|
import com.yunfeiyun.agmp.iot.common.enums.EnumWarnRuleOp;
|
|
|
import com.yunfeiyun.agmp.iots.service.IIotDevicefactorService;
|
|
|
import com.yunfeiyun.agmp.iots.warn.model.WarnConfigInfo;
|
|
|
+import com.yunfeiyun.agmp.iots.warn.model.WarnQxSqInfoDto;
|
|
|
import com.yunfeiyun.agmp.iots.warn.model.WarnResult;
|
|
|
import com.yunfeiyun.agmp.iots.warn.model.WarnStatusDto;
|
|
|
import com.yunfeiyun.agmp.iots.warn.util.CompareUtil;
|
|
|
@@ -105,16 +106,28 @@ public class WarnService {
|
|
|
for(Map.Entry<String, List<WarnConfigInfo>> entry : configMap.entrySet()) {
|
|
|
List<WarnConfigInfo> configList = entry.getValue();
|
|
|
WarnResult warnResult = null;
|
|
|
+
|
|
|
+ WarnQxSqInfoDto warnQxSqInfoDto = new WarnQxSqInfoDto();
|
|
|
+ warnQxSqInfoDto.setIotDevice(iotDevice);
|
|
|
+ warnQxSqInfoDto.setConfigList(configList);
|
|
|
+ warnQxSqInfoDto.setJsonObject(data);
|
|
|
+ warnQxSqInfoDto.setFactorMap(factorMap);
|
|
|
+ warnQxSqInfoDto.setIotDeviceTypeLv1Enum(iotDeviceTypeLv1Enum);
|
|
|
+
|
|
|
try{
|
|
|
switch (iotDeviceTypeLv1Enum) {
|
|
|
case QXZ: {
|
|
|
- warnResult = comparableQxzReportData(iotDevice, configList, data, factorMap);
|
|
|
+ warnResult = comparableQxzReportData(warnQxSqInfoDto);
|
|
|
break;
|
|
|
}
|
|
|
-// case SQZ: {
|
|
|
-// warnResult = comparableSqzReportData(devBid, config, data);
|
|
|
-// break;
|
|
|
-// }
|
|
|
+// case SQZ: {
|
|
|
+// warnResult = comparableSqzReportData(warnQxSqInfoDto);
|
|
|
+// break;
|
|
|
+// }
|
|
|
+// case GSSQ: {
|
|
|
+// warnResult = comparableGssqReportData(warnQxSqInfoDto);
|
|
|
+// break;
|
|
|
+// }
|
|
|
// case "病虫害": {
|
|
|
// warnResult = comparableBchReportData(devBid, config, data);
|
|
|
// break;
|
|
|
@@ -205,8 +218,13 @@ public class WarnService {
|
|
|
return wiName;
|
|
|
}
|
|
|
|
|
|
- private WarnStatusDto getQxzWarnStatusDto(WarnConfigInfo config, Map<String, String> currentValueMap, Map<String,
|
|
|
- IotDevicefactor> factorMap, String devCode) {
|
|
|
+ private WarnStatusDto getQxzWarnStatusDto(WarnConfigInfo config, WarnQxSqInfoDto warnQxSqInfoDto) {
|
|
|
+ IotDevice iotDevice = warnQxSqInfoDto.getIotDevice();
|
|
|
+ String devCode = iotDevice.getDevCode();
|
|
|
+ Map<String, String> currentValueMap = warnQxSqInfoDto.getCurrentValueMap();
|
|
|
+ Map<String, IotDevicefactor> factorMap = warnQxSqInfoDto.getFactorMap();
|
|
|
+ IotDeviceTypeLv1Enum iotDeviceTypeLv1Enum = warnQxSqInfoDto.getIotDeviceTypeLv1Enum();
|
|
|
+
|
|
|
String targetValue = config.getWiValue();
|
|
|
String wiAddress = config.getWiAddress();
|
|
|
String wiCode = config.getWiCode();
|
|
|
@@ -254,7 +272,7 @@ public class WarnService {
|
|
|
boolean tempSuccess = CompareUtil.comp(currentValue, expression, targetValue);
|
|
|
|
|
|
WarnStatusDto warnStatusDto = new WarnStatusDto();
|
|
|
- warnStatusDto.setDevType("气象站");
|
|
|
+ warnStatusDto.setDevType(iotDeviceTypeLv1Enum.getName());
|
|
|
warnStatusDto.setDevCode(devCode);
|
|
|
warnStatusDto.setName(wiName);
|
|
|
warnStatusDto.setValue(currentValue);
|
|
|
@@ -274,11 +292,11 @@ public class WarnService {
|
|
|
* @param devCode
|
|
|
* @return
|
|
|
*/
|
|
|
- public WarnResult comparableQxzSingleIndicator(WarnResult warnResult, List<WarnConfigInfo> configList, Map<String, IotDevicefactor> factorMap,
|
|
|
- Map<String, String> currentValueMap, String devCode) {
|
|
|
+ public WarnResult comparableQxzSingleIndicator(WarnResult warnResult, WarnQxSqInfoDto warnQxSqInfoDto) {
|
|
|
+ List<WarnConfigInfo> configList = warnQxSqInfoDto.getConfigList();
|
|
|
WarnStatusDto warnStatusDto = null;
|
|
|
for (WarnConfigInfo config : configList) {
|
|
|
- warnStatusDto = getQxzWarnStatusDto(config, currentValueMap, factorMap, devCode);
|
|
|
+ warnStatusDto = getQxzWarnStatusDto(config, warnQxSqInfoDto);
|
|
|
// 如果没有预警配置,直接返回null,不进行预警判断
|
|
|
if(warnStatusDto == null){
|
|
|
continue;
|
|
|
@@ -312,12 +330,12 @@ public class WarnService {
|
|
|
* @param jsonObject 上报的数据
|
|
|
* @return WarnResult 包含是否触发告警的信息
|
|
|
*/
|
|
|
- public WarnResult comparableQxzMultipleIndicators(WarnResult warnResult, List<WarnConfigInfo> configList, Map<String, IotDevicefactor> factorMap,
|
|
|
- Map<String, String> currentValueMap, String devCode) {
|
|
|
+ public WarnResult comparableQxzMultipleIndicators(WarnResult warnResult, WarnQxSqInfoDto warnQxSqInfoDto) {
|
|
|
+ List<WarnConfigInfo> configList = warnQxSqInfoDto.getConfigList();
|
|
|
WarnStatusDto warnStatusDto = null;
|
|
|
List<WarnStatusDto> warnStatusDtos = new ArrayList<>();
|
|
|
for (WarnConfigInfo config : configList) {
|
|
|
- warnStatusDto = getQxzWarnStatusDto(config, currentValueMap, factorMap, devCode);
|
|
|
+ warnStatusDto = getQxzWarnStatusDto(config, warnQxSqInfoDto);
|
|
|
// 如果没有预警配置,直接返回null,不进行预警判断
|
|
|
if(warnStatusDto == null){
|
|
|
continue;
|
|
|
@@ -364,15 +382,18 @@ public class WarnService {
|
|
|
* @param config 对应的配置
|
|
|
* @param jsonObject 上报的数据
|
|
|
*/
|
|
|
- private WarnResult comparableQxzReportData(IotDevice iotDevice, List<WarnConfigInfo> configList,
|
|
|
- JSONObject jsonObject, Map<String, IotDevicefactor> factorMap) {
|
|
|
- String devCode = iotDevice.getDevCode();
|
|
|
+ private WarnResult comparableQxzReportData(WarnQxSqInfoDto warnQxSqInfoDto) {
|
|
|
+ IotDevice iotDevice = warnQxSqInfoDto.getIotDevice();
|
|
|
+ List<WarnConfigInfo> configList = warnQxSqInfoDto.getConfigList();
|
|
|
+ JSONObject jsonObject = warnQxSqInfoDto.getJsonObject();
|
|
|
+ JSONArray jsonArray = jsonObject.getJSONArray("data");
|
|
|
+ Map<String, String> currentValueMap = getQxzCurrentValueMap(iotDevice, jsonArray);
|
|
|
+
|
|
|
+ warnQxSqInfoDto.setCurrentValueMap(currentValueMap);
|
|
|
+
|
|
|
String devBid = iotDevice.getDevBid();
|
|
|
WarnConfigInfo configInfo = configList.get(0);
|
|
|
String wcCondition = configInfo.getWcCondition();
|
|
|
- JSONArray jsonArray = jsonObject.getJSONArray("data");
|
|
|
-
|
|
|
- Map<String, String> currentValueMap = getQxzCurrentValueMap(iotDevice, jsonArray);
|
|
|
|
|
|
IotWarnconfig iotWarnconfig = new IotWarnconfig();
|
|
|
BeanUtils.copyProperties(configInfo, iotWarnconfig);
|
|
|
@@ -387,24 +408,31 @@ public class WarnService {
|
|
|
warnResult.setDevtypeBid(iotDevice.getDevtypeBid());
|
|
|
warnResult.setConfig(iotWarnconfig);
|
|
|
warnResult.setTriggered(false);
|
|
|
+
|
|
|
if("0".equals(wcCondition)){
|
|
|
- warnResult = comparableQxzSingleIndicator(warnResult, configList, factorMap, currentValueMap, devCode);
|
|
|
+ warnResult = comparableQxzSingleIndicator(warnResult, warnQxSqInfoDto);
|
|
|
} else {
|
|
|
- warnResult = comparableQxzMultipleIndicators(warnResult, configList, factorMap, currentValueMap, devCode);
|
|
|
+ warnResult = comparableQxzMultipleIndicators(warnResult, warnQxSqInfoDto);
|
|
|
}
|
|
|
return warnResult;
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
- * 【墒情站】比较该设备上报的要素和配置是否达到预警条件,暂不实现,预留
|
|
|
+ * 【墒情站】比较该设备上报的要素和配置是否达到预警条件
|
|
|
*
|
|
|
- * @param devId
|
|
|
- * @param config
|
|
|
- * @param jsonObject
|
|
|
*/
|
|
|
- WarnResult comparableSqzReportData(String devId, Object config, JSONObject jsonObject) {
|
|
|
- return null;
|
|
|
+ WarnResult comparableSqzReportData(WarnQxSqInfoDto warnQxSqInfoDto) {
|
|
|
+ return comparableQxzReportData(warnQxSqInfoDto);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 【管式墒情】比较该设备上报的要素和配置是否达到预警条件
|
|
|
+ *
|
|
|
+ */
|
|
|
+ WarnResult comparableGssqReportData(WarnQxSqInfoDto warnQxSqInfoDto) {
|
|
|
+ return comparableQxzReportData(warnQxSqInfoDto);
|
|
|
|
|
|
}
|
|
|
|