|
|
@@ -4,12 +4,14 @@ import com.yunfeiyun.agmp.common.enums.RedisCacheKey;
|
|
|
import com.yunfeiyun.agmp.common.framework.manager.RedisCacheManager;
|
|
|
import com.yunfeiyun.agmp.common.utils.DateUtils;
|
|
|
import com.yunfeiyun.agmp.common.utils.uuid.IdUtils;
|
|
|
-import com.yunfeiyun.agmp.common.web.system.domain.SysConfig;
|
|
|
import com.yunfeiyun.agmp.iot.common.domain.*;
|
|
|
import com.yunfeiyun.agmp.iots.warn.mapper.IotWarnBussinessMapper;
|
|
|
+import com.yunfeiyun.agmp.iots.warn.model.IotWarnconfigCbdInfoVo;
|
|
|
+import com.yunfeiyun.agmp.iots.warn.model.IotWarnconfigDevVo;
|
|
|
import com.yunfeiyun.agmp.iots.warn.model.WarnConfigInfo;
|
|
|
import com.yunfeiyun.agmp.iots.warn.model.WarnResult;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.data.mongodb.core.MongoTemplate;
|
|
|
import org.springframework.data.mongodb.core.aggregation.Aggregation;
|
|
|
@@ -19,10 +21,7 @@ import org.springframework.data.mongodb.core.query.Query;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.HashMap;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
+import java.util.*;
|
|
|
|
|
|
@Service
|
|
|
@Slf4j
|
|
|
@@ -250,4 +249,89 @@ public class IotWarnBussinessService {
|
|
|
// 获取统计结果,默认为0
|
|
|
return result != null ? ((Number) result.get("totalPestCount")).intValue() : 0;
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查询告警指标,存储所有与告警相关的指标信息列表
|
|
|
+ *
|
|
|
+ * @param iotWarnindicator 告警指标,存储所有与告警相关的指标信息
|
|
|
+ * @return 告警指标,存储所有与告警相关的指标信息集合
|
|
|
+ */
|
|
|
+ public Map<String, List<IotWarnindicator>> selectIotWarnindicatorMap(IotWarnindicator iotWarnindicator){
|
|
|
+ List<IotWarnindicator> iotWarnindicatorList = iotWarnBussinessMapper.selectIotWarnindicatorList(iotWarnindicator);
|
|
|
+ Map<String, List<IotWarnindicator>> iotWarnindicatorMap = new HashMap<>();
|
|
|
+ for(IotWarnindicator item: iotWarnindicatorList){
|
|
|
+ String wcBid = item.getWcBid();
|
|
|
+ if(!iotWarnindicatorMap.containsKey(wcBid)){
|
|
|
+ iotWarnindicatorMap.put(wcBid,new ArrayList<>());
|
|
|
+ }
|
|
|
+ iotWarnindicatorMap.get(wcBid).add(item);
|
|
|
+ }
|
|
|
+ return iotWarnindicatorMap;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查询测报灯设备所有告警配置信息
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+
|
|
|
+ public Map<String, List<IotWarnindicator>> selectCbdIndicatorAllMap(){
|
|
|
+ List<IotWarnindicator> iotWarnindicators = iotWarnBussinessMapper.selectCbdIndicatorAllList();
|
|
|
+ Map<String, List<IotWarnindicator>> iotWarnindicatorMap = new LinkedHashMap<>();
|
|
|
+ for(IotWarnindicator iotWarnindicator : iotWarnindicators){
|
|
|
+ String wcBid = iotWarnindicator.getWcBid();
|
|
|
+ if(!iotWarnindicatorMap.containsKey(wcBid)){
|
|
|
+ iotWarnindicatorMap.put(wcBid,new ArrayList<>());
|
|
|
+ }
|
|
|
+ iotWarnindicatorMap.get(wcBid).add(iotWarnindicator);
|
|
|
+ }
|
|
|
+ return iotWarnindicatorMap;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查询测报灯设备所有告警配置信息列表
|
|
|
+ *
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+
|
|
|
+ public List<IotWarnconfigCbdInfoVo> selectIotWarnconfigCbdInfoList() {
|
|
|
+ List<IotWarnconfigDevVo> iotWarnconfigDevVoList = iotWarnBussinessMapper.selectIotWarnconfigCbdDevList();
|
|
|
+ Map<String, List<IotWarnindicator>> iotWarnindicatorMap = selectCbdIndicatorAllMap();
|
|
|
+ List<IotWarnconfigCbdInfoVo> iotWarnconfigCbdInfoVoList = new ArrayList<>();
|
|
|
+ List<String> parentbidList = new ArrayList<>();
|
|
|
+ for(IotWarnconfigDevVo iotWarnconfigDevVo : iotWarnconfigDevVoList){
|
|
|
+ String wcBid = iotWarnconfigDevVo.getWcBid();
|
|
|
+ List<IotWarnindicator> iotWarnindicatorList = iotWarnindicatorMap.get(wcBid);
|
|
|
+ for(IotWarnindicator item: iotWarnindicatorList){
|
|
|
+ String wiCode = item.getWiCode();
|
|
|
+ if("pestDetail".equals(wiCode)){
|
|
|
+ parentbidList.add(item.getWiBid());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ IotDevice iotDevice = new IotDevice();
|
|
|
+ BeanUtils.copyProperties(iotWarnconfigDevVo, iotDevice);
|
|
|
+
|
|
|
+ IotWarnconfigCbdInfoVo iotWarnconfigCbdInfoVo = new IotWarnconfigCbdInfoVo();
|
|
|
+ BeanUtils.copyProperties(iotWarnconfigDevVo, iotWarnconfigCbdInfoVo);
|
|
|
+ iotWarnconfigCbdInfoVo.setIotDevice(iotDevice);
|
|
|
+ iotWarnconfigCbdInfoVo.setIotWarnindicatorList(iotWarnindicatorList);
|
|
|
+ iotWarnconfigCbdInfoVoList.add(iotWarnconfigCbdInfoVo);
|
|
|
+ }
|
|
|
+ if(!parentbidList.isEmpty()){
|
|
|
+ IotWarnindicator selectIotWarnindicator = new IotWarnindicator();
|
|
|
+ selectIotWarnindicator.setWiParentbidList(parentbidList);
|
|
|
+ Map<String, List<IotWarnindicator>> iotMap = selectIotWarnindicatorMap(selectIotWarnindicator);
|
|
|
+ for(IotWarnconfigCbdInfoVo cbdInfoVo : iotWarnconfigCbdInfoVoList){
|
|
|
+ String wcBid = cbdInfoVo.getWcBid();
|
|
|
+ List<IotWarnindicator> pestDetailList = iotMap.get(wcBid);
|
|
|
+ List<IotWarnindicator> iotWarnindicatorList = cbdInfoVo.getIotWarnindicatorList();
|
|
|
+ for(IotWarnindicator item: iotWarnindicatorList){
|
|
|
+ String wiCode = item.getWiCode();
|
|
|
+ if("pestDetail".equals(wiCode)){
|
|
|
+ item.setChildrenList(pestDetailList);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return iotWarnconfigCbdInfoVoList;
|
|
|
+ }
|
|
|
}
|