|
@@ -4,17 +4,22 @@ import com.yunfeiyun.agmp.common.constant.ErrorCode;
|
|
|
import com.yunfeiyun.agmp.common.exception.BizException;
|
|
import com.yunfeiyun.agmp.common.exception.BizException;
|
|
|
import com.yunfeiyun.agmp.common.utils.DateUtils;
|
|
import com.yunfeiyun.agmp.common.utils.DateUtils;
|
|
|
import com.yunfeiyun.agmp.common.utils.StringUtils;
|
|
import com.yunfeiyun.agmp.common.utils.StringUtils;
|
|
|
|
|
+import com.yunfeiyun.agmp.iot.common.domain.IotDevice;
|
|
|
import com.yunfeiyun.agmp.iot.common.domain.IotWarnconfig;
|
|
import com.yunfeiyun.agmp.iot.common.domain.IotWarnconfig;
|
|
|
import com.yunfeiyun.agmp.iot.common.domain.IotWarnindicator;
|
|
import com.yunfeiyun.agmp.iot.common.domain.IotWarnindicator;
|
|
|
import com.yunfeiyun.agmp.iot.common.enums.EnumWarnRuleOp;
|
|
import com.yunfeiyun.agmp.iot.common.enums.EnumWarnRuleOp;
|
|
|
|
|
+import com.yunfeiyun.agmp.iots.warn.model.IotWarnconfigCbdInfoVo;
|
|
|
import com.yunfeiyun.agmp.iots.warn.model.WarnResult;
|
|
import com.yunfeiyun.agmp.iots.warn.model.WarnResult;
|
|
|
import com.yunfeiyun.agmp.iots.warn.model.WarnStatusDto;
|
|
import com.yunfeiyun.agmp.iots.warn.model.WarnStatusDto;
|
|
|
import com.yunfeiyun.agmp.iots.warn.util.CompareUtil;
|
|
import com.yunfeiyun.agmp.iots.warn.util.CompareUtil;
|
|
|
import com.yunfeiyun.agmp.iots.warn.util.WarnMessageBuilderUtil;
|
|
import com.yunfeiyun.agmp.iots.warn.util.WarnMessageBuilderUtil;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
+import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
|
|
+import java.util.List;
|
|
|
|
|
+
|
|
|
|
|
|
|
|
@Service
|
|
@Service
|
|
|
@Slf4j
|
|
@Slf4j
|
|
@@ -29,19 +34,31 @@ public class WarnPestService {
|
|
|
*/
|
|
*/
|
|
|
public void process() {
|
|
public void process() {
|
|
|
//单个配置单个设备的处理逻辑,外层需要遍历
|
|
//单个配置单个设备的处理逻辑,外层需要遍历
|
|
|
-
|
|
|
|
|
- //需要的参数,devId
|
|
|
|
|
- String devId = "";
|
|
|
|
|
- //需要的参数,iotWarnindicator的:默认全部,外加+devCode,devTypeBid
|
|
|
|
|
- IotWarnindicator pestByTypeWarnindicator = new IotWarnindicator();
|
|
|
|
|
- IotWarnindicator pestByCountWarnindicator = new IotWarnindicator();
|
|
|
|
|
- IotWarnindicator designatePestWarnindicator = new IotWarnindicator();
|
|
|
|
|
-
|
|
|
|
|
- //需要的参数,iotWarnconfig的:全部
|
|
|
|
|
- IotWarnconfig iotWarnconfig = new IotWarnconfig();
|
|
|
|
|
-
|
|
|
|
|
- //底层调用:统一处理一个虫情设备的三个要素
|
|
|
|
|
- processPestIotWarnindicators(devId, iotWarnconfig, pestByTypeWarnindicator, pestByCountWarnindicator, designatePestWarnindicator);
|
|
|
|
|
|
|
+ List<IotWarnconfigCbdInfoVo> iotWarnconfigCbdInfoVoList = iotWarnBussinessService.selectIotWarnconfigCbdInfoList();
|
|
|
|
|
+ for (IotWarnconfigCbdInfoVo iotWarnconfigCbdInfoVo : iotWarnconfigCbdInfoVoList) {
|
|
|
|
|
+ IotDevice iotDevice = iotWarnconfigCbdInfoVo.getIotDevice();
|
|
|
|
|
+ String devBid = iotDevice.getDevBid();
|
|
|
|
|
+ List<IotWarnindicator> iotWarnindicatorList = iotWarnconfigCbdInfoVo.getIotWarnindicatorList();
|
|
|
|
|
+ IotWarnconfig iotWarnconfig = new IotWarnconfig();
|
|
|
|
|
+ BeanUtils.copyProperties(iotWarnconfigCbdInfoVo, iotWarnconfig);
|
|
|
|
|
+
|
|
|
|
|
+ IotWarnindicator pestByTypeWarnindicator = new IotWarnindicator();
|
|
|
|
|
+ IotWarnindicator pestByCountWarnindicator = new IotWarnindicator();
|
|
|
|
|
+ IotWarnindicator designatePestWarnindicator = new IotWarnindicator();
|
|
|
|
|
+ for(IotWarnindicator iotWarnindicator : iotWarnindicatorList){
|
|
|
|
|
+ BeanUtils.copyProperties(iotDevice, iotWarnindicator);
|
|
|
|
|
+
|
|
|
|
|
+ if("pestType".equals(iotWarnindicator.getWiCode())){
|
|
|
|
|
+ BeanUtils.copyProperties(iotWarnindicator, pestByTypeWarnindicator);
|
|
|
|
|
+ }else if("pestNum".equals(iotWarnindicator.getWiCode())){
|
|
|
|
|
+ BeanUtils.copyProperties(iotWarnindicator, pestByCountWarnindicator);
|
|
|
|
|
+ }else if("pestDetail".equals(iotWarnindicator.getWiCode())){
|
|
|
|
|
+ BeanUtils.copyProperties(iotWarnindicator, designatePestWarnindicator);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ //底层调用:统一处理一个虫情设备的三个要素
|
|
|
|
|
+ processPestIotWarnindicators(devBid, iotWarnconfig, pestByTypeWarnindicator, pestByCountWarnindicator, designatePestWarnindicator);
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -99,7 +116,7 @@ public class WarnPestService {
|
|
|
EnumWarnRuleOp warnRuleOp = EnumWarnRuleOp.findEnumByCode(expression);
|
|
EnumWarnRuleOp warnRuleOp = EnumWarnRuleOp.findEnumByCode(expression);
|
|
|
boolean tempSuccess = CompareUtil.comp(currentValue + "", expression, targetValue);
|
|
boolean tempSuccess = CompareUtil.comp(currentValue + "", expression, targetValue);
|
|
|
WarnStatusDto warnStatusDto = new WarnStatusDto();
|
|
WarnStatusDto warnStatusDto = new WarnStatusDto();
|
|
|
- warnStatusDto.setDevType(iotWarnindicator.getDevTypeBid());
|
|
|
|
|
|
|
+ warnStatusDto.setDevType(iotWarnindicator.getDevtypeBid());
|
|
|
warnStatusDto.setDevCode(iotWarnindicator.getDevCode());
|
|
warnStatusDto.setDevCode(iotWarnindicator.getDevCode());
|
|
|
warnStatusDto.setName(iotWarnindicator.getWiName());
|
|
warnStatusDto.setName(iotWarnindicator.getWiName());
|
|
|
warnStatusDto.setValue(currentValue + "");
|
|
warnStatusDto.setValue(currentValue + "");
|
|
@@ -212,8 +229,8 @@ public class WarnPestService {
|
|
|
log.error("【设备预警】病虫害:设备code 不可为空");
|
|
log.error("【设备预警】病虫害:设备code 不可为空");
|
|
|
throw new BizException(ErrorCode.FAILURE.getCode(), "设备code不可为空");
|
|
throw new BizException(ErrorCode.FAILURE.getCode(), "设备code不可为空");
|
|
|
}
|
|
}
|
|
|
- String devTypeBid = warnStatusDto.getDevTypeBid();
|
|
|
|
|
- if (StringUtils.isEmpty(devTypeBid)) {
|
|
|
|
|
|
|
+ String devtypeBid = warnStatusDto.getDevtypeBid();
|
|
|
|
|
+ if (StringUtils.isEmpty(devtypeBid)) {
|
|
|
log.error("【设备预警】病虫害:设备类型 不可为空");
|
|
log.error("【设备预警】病虫害:设备类型 不可为空");
|
|
|
throw new BizException(ErrorCode.FAILURE.getCode(), "病虫害:设备类型 不可为空");
|
|
throw new BizException(ErrorCode.FAILURE.getCode(), "病虫害:设备类型 不可为空");
|
|
|
}
|
|
}
|