|
@@ -1,445 +1,496 @@
|
|
|
-//package com.gyee.alarm.service;
|
|
|
-//
|
|
|
-//
|
|
|
-//import com.gyee.alarm.init.CacheContext;
|
|
|
-//import com.gyee.alarm.model.auto.*;
|
|
|
-//import com.gyee.alarm.model.vo.AlarmCustomType;
|
|
|
-//import com.gyee.alarm.model.vo.AlarmType;
|
|
|
-//import com.gyee.alarm.model.vo.AlarmTypeValue;
|
|
|
-//import com.gyee.alarm.service.auto.*;
|
|
|
-//import com.gyee.alarm.util.SnowflakeGenerator;
|
|
|
-//import com.gyee.alarm.util.DateUtils;
|
|
|
-//
|
|
|
-//import org.apache.commons.collections.CollectionUtils;
|
|
|
-//import org.springframework.beans.factory.annotation.Value;
|
|
|
-//import org.springframework.stereotype.Service;
|
|
|
-//
|
|
|
-//import javax.annotation.Resource;
|
|
|
-//import java.util.*;
|
|
|
-//import java.util.concurrent.Callable;
|
|
|
-//import java.util.stream.Collectors;
|
|
|
-//
|
|
|
-//@Service
|
|
|
-//public class EarlyReportService {
|
|
|
-//
|
|
|
-//
|
|
|
-//
|
|
|
-// @Resource
|
|
|
-// private IProEconAlarmInfoService proEconAlarmInfoService;
|
|
|
-// @Resource
|
|
|
-// private IProEconEarlyReportService proEconEarlyReportService;
|
|
|
-// @Resource
|
|
|
-// private IProEconEarlyReportWtService proEconEarlyReportWtService;
|
|
|
-// @Resource
|
|
|
-// private IProEconEarlyReportAlarmService proEconEarlyReportAlarmService;
|
|
|
-// @Resource
|
|
|
-// private IAlarmTsService alarmTsService;
|
|
|
-//
|
|
|
+package com.gyee.alarm.service;
|
|
|
+
|
|
|
+
|
|
|
+import com.gyee.alarm.init.CacheContext;
|
|
|
+import com.gyee.alarm.model.auto.*;
|
|
|
+import com.gyee.alarm.model.vo.AlarmCustomType;
|
|
|
+import com.gyee.alarm.model.vo.AlarmType;
|
|
|
+import com.gyee.alarm.model.vo.AlarmTypeValue;
|
|
|
+import com.gyee.alarm.service.auto.*;
|
|
|
+import com.gyee.alarm.util.SnowflakeGenerator;
|
|
|
+import com.gyee.alarm.util.DateUtils;
|
|
|
+
|
|
|
+import org.apache.commons.collections.CollectionUtils;
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+
|
|
|
+import javax.annotation.Resource;
|
|
|
+import java.util.*;
|
|
|
+import java.util.concurrent.Callable;
|
|
|
+import java.util.stream.Collectors;
|
|
|
+
|
|
|
+@Service
|
|
|
+public class EarlyReportService {
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private IProEconAlarmInfoService proEconAlarmInfoService;
|
|
|
+ @Resource
|
|
|
+ private IProEconEarlyReportService proEconEarlyReportService;
|
|
|
+ @Resource
|
|
|
+ private IProEconEarlyReportConclusioService proEconEarlyReportConclusioService;
|
|
|
+ @Resource
|
|
|
+ private IAlarmTsService alarmTsService;
|
|
|
+
|
|
|
+ //时间间隔(天),即从当日0点,向前间隔天数,为计算区间
|
|
|
+ @Value("${interval_day}")
|
|
|
+ private int interval_day;
|
|
|
+ @Value("${limit}")
|
|
|
+ private int limit;
|
|
|
+
|
|
|
+//
|
|
|
+// //部件编码 CLX,FDJ等
|
|
|
+// private String windturbineParts;
|
|
|
+// //分析名称(部件名称)
|
|
|
+// private String analysisName;
|
|
|
// //时间间隔(天),即从当日0点,向前间隔天数,为计算区间
|
|
|
-// @Value("${interval_day}")
|
|
|
-// private int interval_day;
|
|
|
-// @Value("${limit}")
|
|
|
-// private int limit;
|
|
|
-//
|
|
|
-////
|
|
|
-//// //部件编码 CLX,FDJ等
|
|
|
-//// private String windturbineParts;
|
|
|
-//// //分析名称(部件名称)
|
|
|
-//// private String analysisName;
|
|
|
-//// //时间间隔(天),即从当日0点,向前间隔天数,为计算区间
|
|
|
-//// private int interval;
|
|
|
-//// //自定义报警规则id
|
|
|
-//// private List<String> customRuleId;
|
|
|
-//// //风机报警规则id
|
|
|
-//// private List<String> windturbineRuleId;
|
|
|
-//// //结果数量 限制(取前多少个)
|
|
|
-//// private int resultLimit;
|
|
|
-//// //风场id
|
|
|
-//// private String stationId;
|
|
|
-//// //风机型号
|
|
|
-//// private String model;
|
|
|
-//// //故障状态统一编码,如果为空则不进行计算,不为空则计算出故障时长和次数
|
|
|
-//// private String gzztCode;
|
|
|
-// public boolean createEarlyReport() {
|
|
|
-//
|
|
|
-// boolean result=false;
|
|
|
-// //报告时间
|
|
|
-// Date reportDate = DateUtils.truncate(new Date());
|
|
|
-// //获取计算开始时间
|
|
|
-// Date statStartTime = DateUtils.addDays(DateUtils.today(), -interval_day);
|
|
|
-// //获取计算结束时间
|
|
|
-// Date statEndTime = DateUtils.today();
|
|
|
-// Map<String,List<ProEconAlarmType>> alarmTypeMap=CacheContext.alarmTypeMap;
|
|
|
-//
|
|
|
-// List<ProEconAlarmType> fjtypels=CacheContext.alarmTypeMap.get(AlarmType.FJBJ.getCode());
|
|
|
-//
|
|
|
-// List<ProEconAlarmType> gftypels=CacheContext.alarmTypeMap.get(AlarmType.GFBJ.getCode());
|
|
|
-// for(ProBasicEquipment wt: CacheContext.wtls)
|
|
|
-// {
|
|
|
-//
|
|
|
-// ProEconEarlyReport report = new ProEconEarlyReport();
|
|
|
-// report.setId(String.valueOf(SnowflakeGenerator.generateId()));
|
|
|
-// report.setReportDate(new Date());
|
|
|
-// report.setStationId(wt.getWindpowerstationId());
|
|
|
-// if(CacheContext.wpmap.containsKey(wt.getWindpowerstationId()))
|
|
|
-// {
|
|
|
-// report.setStationName(CacheContext.wpmap.get(wt.getWindpowerstationId()).getName());
|
|
|
-// }
|
|
|
-// if(wt.getWindpowerstationId().contains("FDC"))
|
|
|
-// {
|
|
|
-// for(ProEconAlarmType fjtype:fjtypels)
|
|
|
-// {
|
|
|
-// report.setRelatedParts(fjtype.getNemCode());
|
|
|
-// StringBuilder sb=new StringBuilder();
|
|
|
-// sb.append(wt.getNemCode()).append(wt.getName()).append(fjtype.getName()).append("诊断报告");
|
|
|
-// report.setReportName(String.valueOf(sb));
|
|
|
-// report.setStatStartDate(statStartTime);
|
|
|
-// report.setStatEndDate(statEndTime);
|
|
|
-// report.setProEconEarlyReportWtList(new ArrayList<>());
|
|
|
-// report.setReportDate(reportDate);
|
|
|
-// report.setStatStartDate(new Date());
|
|
|
-// }
|
|
|
-// }else
|
|
|
-// {
|
|
|
-// for(ProEconAlarmType gftype:gftypels)
|
|
|
-// {
|
|
|
-// report.setRelatedParts(gftype.getNemCode());
|
|
|
-// StringBuilder sb=new StringBuilder();
|
|
|
-// sb.append(wt.getNemCode()).append(wt.getName()).append(gftype.getName()).append("诊断报告");
|
|
|
-// report.setReportName(String.valueOf(sb));
|
|
|
-// report.setStatStartDate(statStartTime);
|
|
|
-// report.setStatEndDate(statEndTime);
|
|
|
-// report.setProEconEarlyReportWtList(new ArrayList<>());
|
|
|
-// report.setReportDate(reportDate);
|
|
|
-// report.setStatStartDate(new Date());
|
|
|
-// }
|
|
|
-// }
|
|
|
-//
|
|
|
-//
|
|
|
-// try {
|
|
|
-// //获取本次报告最差的风机信息集合
|
|
|
-// List<ProEconEarlyReportWt> nowWindturbineInfoList = getNowWindturbineInfo(wt,wt.getModelId(), report.getId(),report.getRelatedParts(), statStartTime, statEndTime, limit);
|
|
|
-//
|
|
|
-// report.getProEconEarlyReportWtList().addAll(nowWindturbineInfoList);
|
|
|
-// // 获取上次报告
|
|
|
-// List<ProEconEarlyReport> earlyReport = proEconEarlyReportService.findEarlyReportByDate(wt.getId(), DateUtils.addDays(statEndTime, -60), statEndTime);
|
|
|
-// earlyReport=earlyReport.stream().filter(s->s.getRelatedParts().equals(report.getRelatedParts())).collect(Collectors.toList());
|
|
|
-// List<ProEconEarlyReport> collect = earlyReport.stream().sorted(Comparator.comparing(ProEconEarlyReport::getId, Comparator.reverseOrder())).collect(Collectors.toList());
|
|
|
-//
|
|
|
-// if (collect.size() > 0) {
|
|
|
-// //已经进行了排序,因此获取第一个,即为最近一次报告
|
|
|
-// List<ProEconEarlyReportWt> reportWindturbineInfoList = collect.get(0).getProEconEarlyReportWtList().stream().filter(s -> s.isCompared() == false && !s.getWindturbineId().equals("全场平均")).collect(Collectors.toList());
|
|
|
-// List<ProEconEarlyReportWt> compareWindturbineInfoList = getCompareWindturbineInfo(stationId,reportWindturbineInfoList, model, report.getId(), statStartTime, statEndTime);
|
|
|
-// report.getProEconEarlyReportWtList().addAll(compareWindturbineInfoList);
|
|
|
-// }
|
|
|
-//
|
|
|
-// //执行写入操作
|
|
|
-// result = proEconEarlyReportService.save(report);
|
|
|
-//
|
|
|
-// } catch (RuntimeException ex) {
|
|
|
-//
|
|
|
-// } finally {
|
|
|
-//
|
|
|
-// }
|
|
|
-// }
|
|
|
-// return result;
|
|
|
-// }
|
|
|
-//
|
|
|
-// /**
|
|
|
-// * @param model 风机型号
|
|
|
-// * @param reportId 报告id
|
|
|
-// * @param statStartTime 统计起始时间
|
|
|
-// * @param statEndTime 统计结束时间
|
|
|
-// * @param limit 结果限制数量
|
|
|
-// * @return com.gyee.wisdom.alarm.schedule.entity.ProEconEarlyReportWt
|
|
|
-// **/
|
|
|
-// private List<ProEconEarlyReportWt> getNowWindturbineInfo(ProBasicEquipment wt,String model, String reportId,String relatedParts, Date statStartTime, Date statEndTime, int limit) {
|
|
|
-//
|
|
|
-// List<ProEconEarlyReportWt> resultList = new ArrayList<>();
|
|
|
-//
|
|
|
-// List<ProEconAlarmRule> alertRule2List = new ArrayList<>();
|
|
|
-// List<String> components= new ArrayList<>();
|
|
|
-// components.add(relatedParts);
|
|
|
-// if(wt.getWindpowerstationId().contains("FDC"))
|
|
|
-// {
|
|
|
-// List<ProEconAlarmRule> rulels=CacheContext.alarmRulesMap.get(AlarmCustomType.WT.getCode());
|
|
|
-//
|
|
|
-// if(!rulels.isEmpty())
|
|
|
-// {
|
|
|
-// for(ProEconAlarmRule rule:rulels)
|
|
|
-// {
|
|
|
-// if(rule.getRelatedParts().equals(relatedParts) && rule.getStationId().equals(wt.getWindpowerstationId()) && rule.getModelId().equals(model))
|
|
|
-// {
|
|
|
-// alertRule2List.add(rule);
|
|
|
-// }
|
|
|
-// }
|
|
|
-// }
|
|
|
-//
|
|
|
-// }else
|
|
|
-// {
|
|
|
-// List<ProEconAlarmRule> rulels=CacheContext.alarmRulesMap.get(AlarmCustomType.IN.getCode());
|
|
|
-//
|
|
|
-// if(!rulels.isEmpty())
|
|
|
-// {
|
|
|
-// for(ProEconAlarmRule rule:rulels)
|
|
|
-// {
|
|
|
-// if(rule.getRelatedParts().equals(relatedParts) && rule.getStationId().equals(wt.getWindpowerstationId()) && rule.getModelId().equals(model))
|
|
|
-// {
|
|
|
-// alertRule2List.add(rule);
|
|
|
-// }
|
|
|
-// }
|
|
|
-// }
|
|
|
-// }
|
|
|
-//
|
|
|
-//
|
|
|
-// List<ProEconAlarmInfo> customAlarmSnapList = proEconAlarmInfoService. queryAlarmInfo(wt.getId(), AlarmTypeValue.CT.getCode());
|
|
|
-// List<String> alarmidls=new ArrayList<>();
|
|
|
-// if(!customAlarmSnapList.isEmpty())
|
|
|
-// {
|
|
|
-// for(ProEconAlarmInfo alarmInfo:customAlarmSnapList)
|
|
|
-// {
|
|
|
-// alarmidls.add(alarmInfo.getAlarmId());
|
|
|
-// }
|
|
|
-// }
|
|
|
-// List<ProBasicFeatureStat> customAlarmCountList = alarmTsService.findCtFeatureStatCustom( statStartTime.getTime(), statEndTime.getTime(),wt.getWindpowerstationId(), wt.getModelId(), components,alarmidls);
|
|
|
-//
|
|
|
-// Map<String, List<ProBasicFeatureStat>> alarmCountMapByAlertValue = customAlarmCountList.stream().collect(Collectors.groupingBy(ProBasicFeatureStat::getAlarmid));
|
|
|
-//
|
|
|
-// ProEconEarlyReportWt avgWindturbineReport = new ProEconEarlyReportWt();
|
|
|
-// avgWindturbineReport.setId(String.valueOf(SnowflakeGenerator.generateId()));
|
|
|
-// avgWindturbineReport.setWindturbineId("全场平均");
|
|
|
-// avgWindturbineReport.setWindturbineCode("");
|
|
|
-// avgWindturbineReport.setModelId(model);
|
|
|
-// avgWindturbineReport.setCompared(false);
|
|
|
-// avgWindturbineReport.setAlarmInfoList(new ArrayList<>());
|
|
|
-// avgWindturbineReport.setReportId(reportId);
|
|
|
-//
|
|
|
-// for (Map.Entry<String, List<ProBasicFeatureStat>> entry :
|
|
|
-// alarmCountMapByAlertValue.entrySet()) {
|
|
|
-// ProBasicFeatureStat avgAlarmCount = proEconEarlyReportService.getAvgAlarmCount(entry.getValue());
|
|
|
-// Optional<ProEconAlarmRule> first = alertRule2List.stream().filter(s -> String.valueOf(s.getId()).equals(entry.getKey())).findFirst();
|
|
|
-// if (first.isPresent()) {
|
|
|
-// EarlyReportAlarm alarmInfo = new EarlyReportAlarm()
|
|
|
-// .setId(String.valueOf(SnowflakeGenerator.generateId()))
|
|
|
-// .setRuleId(first.get().getId())
|
|
|
-// .setAlarmType("custom")
|
|
|
-// .setRuleName(first.get().getName())
|
|
|
-// .setRuleDescription(first.get().getDescription())
|
|
|
-// .setRank(first.get().getRank())
|
|
|
-// .setCount(avgAlarmCount.getCount())
|
|
|
-// .setKeepTime((long) avgAlarmCount.getTime().doubleValue())
|
|
|
-// .setReportWindturbineId(avgWindturbineReport.getId());
|
|
|
-//
|
|
|
-// avgWindturbineReport.getAlarmInfoList().add(alarmInfo);
|
|
|
+// private int interval;
|
|
|
+// //自定义报警规则id
|
|
|
+// private List<String> customRuleId;
|
|
|
+// //风机报警规则id
|
|
|
+// private List<String> windturbineRuleId;
|
|
|
+// //结果数量 限制(取前多少个)
|
|
|
+// private int resultLimit;
|
|
|
+// //风场id
|
|
|
+// private String stationId;
|
|
|
+// //风机型号
|
|
|
+// private String model;
|
|
|
+// //故障状态统一编码,如果为空则不进行计算,不为空则计算出故障时长和次数
|
|
|
+// private String gzztCode;
|
|
|
+ public boolean createEarlyReport() {
|
|
|
+
|
|
|
+ boolean result=false;
|
|
|
+ //报告时间
|
|
|
+ Date reportDate = DateUtils.truncate(new Date());
|
|
|
+ //获取计算开始时间
|
|
|
+ Date statStartTime = DateUtils.addDays(DateUtils.today(), - interval_day);
|
|
|
+ //获取计算结束时间
|
|
|
+ Date statEndTime = DateUtils.today();
|
|
|
+ Map<String,List<ProEconAlarmType>> alarmTypeMap=CacheContext.alarmTypeMap;
|
|
|
+
|
|
|
+ List<ProEconAlarmType> fjtypels=CacheContext.alarmTypeMap.get(AlarmType.FJBJ.getCode());
|
|
|
+
|
|
|
+ List<ProEconAlarmType> gftypels=CacheContext.alarmTypeMap.get(AlarmType.GFBJ.getCode());
|
|
|
+ for(ProBasicEquipment wt: CacheContext.wtls)
|
|
|
+ {
|
|
|
+
|
|
|
+ ProEconEarlyReport report = new ProEconEarlyReport();
|
|
|
+ report.setId(String.valueOf(SnowflakeGenerator.generateId()));
|
|
|
+ report.setReportDate(new Date());
|
|
|
+ report.setStationId(wt.getWindpowerstationId());
|
|
|
+ if(CacheContext.wpmap.containsKey(wt.getWindpowerstationId()))
|
|
|
+ {
|
|
|
+ report.setStationName(CacheContext.wpmap.get(wt.getWindpowerstationId()).getName());
|
|
|
+ }
|
|
|
+ if(wt.getWindpowerstationId().contains("FDC"))
|
|
|
+ {
|
|
|
+ for(ProEconAlarmType fjtype:fjtypels)
|
|
|
+ {
|
|
|
+ report.setRelatedParts(fjtype.getNemCode());
|
|
|
+ StringBuilder sb=new StringBuilder();
|
|
|
+ sb.append(wt.getNemCode()).append(wt.getName()).append(fjtype.getName()).append("诊断报告");
|
|
|
+ report.setReportName(String.valueOf(sb));
|
|
|
+ report.setStatStartDate(statStartTime);
|
|
|
+ report.setStatEndDate(statEndTime);
|
|
|
+ report.setProEconEarlyReportWtList(new ArrayList<>());
|
|
|
+ report.setReportDate(reportDate);
|
|
|
+ report.setStatStartDate(new Date());
|
|
|
+ }
|
|
|
+ }else
|
|
|
+ {
|
|
|
+ for(ProEconAlarmType gftype:gftypels)
|
|
|
+ {
|
|
|
+ report.setRelatedParts(gftype.getNemCode());
|
|
|
+ StringBuilder sb=new StringBuilder();
|
|
|
+ sb.append(wt.getNemCode()).append(wt.getName()).append(gftype.getName()).append("诊断报告");
|
|
|
+ report.setReportName(String.valueOf(sb));
|
|
|
+ report.setStatStartDate(statStartTime);
|
|
|
+ report.setStatEndDate(statEndTime);
|
|
|
+ report.setProEconEarlyReportWtList(new ArrayList<>());
|
|
|
+ report.setReportDate(reportDate);
|
|
|
+ report.setStatStartDate(new Date());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ try {
|
|
|
+ //获取本次报告最差的风机信息集合
|
|
|
+ List<ProEconEarlyReportWt> nowWindturbineInfoList = getNowWindturbineInfo(wt,wt.getModelId(), report.getId(),report.getRelatedParts(), statStartTime, statEndTime, limit);
|
|
|
+
|
|
|
+ report.getProEconEarlyReportWtList().addAll(nowWindturbineInfoList);
|
|
|
+ // 获取上次报告
|
|
|
+ List<ProEconEarlyReport> earlyReport = proEconEarlyReportService.findEarlyReportByDate(wt.getId(), DateUtils.addDays(statEndTime, -60), statEndTime);
|
|
|
+ earlyReport=earlyReport.stream().filter(s->s.getRelatedParts().equals(report.getRelatedParts())).collect(Collectors.toList());
|
|
|
+ List<ProEconEarlyReport> collect = earlyReport.stream().sorted(Comparator.comparing(ProEconEarlyReport::getId, Comparator.reverseOrder())).collect(Collectors.toList());
|
|
|
+
|
|
|
+ if (collect.size() > 0) {
|
|
|
+ //已经进行了排序,因此获取第一个,即为最近一次报告
|
|
|
+ List<ProEconEarlyReportWt> reportWindturbineInfoList = collect.get(0).getProEconEarlyReportWtList().stream().filter(s -> s.getCompared() == false && !s.getWindturbineId().equals("全场平均")).collect(Collectors.toList());
|
|
|
+ List<ProEconEarlyReportWt> compareWindturbineInfoList = getCompareWindturbineInfo(wt,reportWindturbineInfoList, wt.getModelId(), report.getId(),report.getRelatedParts(), statStartTime, statEndTime);
|
|
|
+ report.getProEconEarlyReportWtList().addAll(compareWindturbineInfoList);
|
|
|
+ }
|
|
|
+
|
|
|
+ //执行写入操作
|
|
|
+ result = proEconEarlyReportService.save(report);
|
|
|
+
|
|
|
+ } catch (RuntimeException ex) {
|
|
|
+
|
|
|
+ } finally {
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @param model 风机型号
|
|
|
+ * @param reportId 报告id
|
|
|
+ * @param statStartTime 统计起始时间
|
|
|
+ * @param statEndTime 统计结束时间
|
|
|
+ * @param limit 结果限制数量
|
|
|
+ * @return com.gyee.wisdom.alarm.schedule.entity.ProEconEarlyReportWt
|
|
|
+ **/
|
|
|
+ private List<ProEconEarlyReportWt> getNowWindturbineInfo(ProBasicEquipment wt,String model, String reportId,String relatedParts, Date statStartTime, Date statEndTime, int limit) {
|
|
|
+
|
|
|
+ List<ProEconEarlyReportWt> resultList = new ArrayList<>();
|
|
|
+
|
|
|
+ List<ProEconAlarmRule> alertRule2List = new ArrayList<>();
|
|
|
+ List<String> components= new ArrayList<>();
|
|
|
+ components.add(relatedParts);
|
|
|
+ if(wt.getWindpowerstationId().contains("FDC"))
|
|
|
+ {
|
|
|
+ List<ProEconAlarmRule> rulels=CacheContext.alarmRulesMap.get(AlarmCustomType.WT.getCode());
|
|
|
+
|
|
|
+ if(!rulels.isEmpty())
|
|
|
+ {
|
|
|
+ for(ProEconAlarmRule rule:rulels)
|
|
|
+ {
|
|
|
+ if(rule.getRelatedParts().equals(relatedParts) && rule.getStationId().equals(wt.getWindpowerstationId()) && rule.getModelId().equals(model))
|
|
|
+ {
|
|
|
+ alertRule2List.add(rule);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }else
|
|
|
+ {
|
|
|
+ List<ProEconAlarmRule> rulels=CacheContext.alarmRulesMap.get(AlarmCustomType.IN.getCode());
|
|
|
+
|
|
|
+ if(!rulels.isEmpty())
|
|
|
+ {
|
|
|
+ for(ProEconAlarmRule rule:rulels)
|
|
|
+ {
|
|
|
+ if(rule.getRelatedParts().equals(relatedParts) && rule.getStationId().equals(wt.getWindpowerstationId()) && rule.getModelId().equals(model))
|
|
|
+ {
|
|
|
+ alertRule2List.add(rule);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ List<ProEconAlarmInfo> customAlarmSnapList = proEconAlarmInfoService. queryAlarmInfo(wt.getId(), AlarmTypeValue.CT.getCode());
|
|
|
+ List<String> alarmidls=new ArrayList<>();
|
|
|
+ if(!customAlarmSnapList.isEmpty())
|
|
|
+ {
|
|
|
+ for(ProEconAlarmInfo alarmInfo:customAlarmSnapList)
|
|
|
+ {
|
|
|
+ alarmidls.add(alarmInfo.getAlarmId());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ List<ProBasicFeatureStat> customAlarmCountList = alarmTsService.findCtFeatureStatCustom( statStartTime.getTime(), statEndTime.getTime(),wt.getWindpowerstationId(), wt.getModelId(), components,alarmidls);
|
|
|
+
|
|
|
+ Map<String, List<ProBasicFeatureStat>> alarmCountMapByAlertValue = customAlarmCountList.stream().collect(Collectors.groupingBy(ProBasicFeatureStat::getAlarmid));
|
|
|
+
|
|
|
+ ProEconEarlyReportWt avgWindturbineReport = new ProEconEarlyReportWt();
|
|
|
+ avgWindturbineReport.setId(String.valueOf(SnowflakeGenerator.generateId()));
|
|
|
+ avgWindturbineReport.setWindturbineId("全场平均");
|
|
|
+ avgWindturbineReport.setWindturbineCode("");
|
|
|
+ avgWindturbineReport.setModelId(model);
|
|
|
+ avgWindturbineReport.setCompared(false);
|
|
|
+ avgWindturbineReport.setAlarmInfoList(new ArrayList<>());
|
|
|
+ avgWindturbineReport.setReportId(reportId);
|
|
|
+
|
|
|
+ for (Map.Entry<String, List<ProBasicFeatureStat>> entry :
|
|
|
+ alarmCountMapByAlertValue.entrySet()) {
|
|
|
+ ProBasicFeatureStat avgAlarmCount = proEconEarlyReportService.getAvgAlarmCount(entry.getValue());
|
|
|
+ Optional<ProEconAlarmRule> first = alertRule2List.stream().filter(s -> String.valueOf(s.getId()).equals(entry.getKey())).findFirst();
|
|
|
+ if (first.isPresent()) {
|
|
|
+ ProEconEarlyReportAlarm alarmInfo = new ProEconEarlyReportAlarm();
|
|
|
+ alarmInfo.setId(String.valueOf(SnowflakeGenerator.generateId()));
|
|
|
+ alarmInfo.setRuleId(first.get().getId());
|
|
|
+ alarmInfo.setAlarmType("custom");
|
|
|
+ alarmInfo.setRuleName(first.get().getName());
|
|
|
+ alarmInfo.setRuleDescription(first.get().getDescription());
|
|
|
+ alarmInfo.setRank(String.valueOf(first.get().getRank()));
|
|
|
+ alarmInfo.setCount(avgAlarmCount.getTotal());
|
|
|
+ alarmInfo.setKeepTime(avgAlarmCount.getTotalSeconds());
|
|
|
+ alarmInfo.setReportWindturbineId(avgWindturbineReport.getId());
|
|
|
+
|
|
|
+ avgWindturbineReport.getAlarmInfoList().add(alarmInfo);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ resultList.add(avgWindturbineReport);
|
|
|
+
|
|
|
+ Map<String, ProBasicFeatureStat> sumAlarmCountByWindturbine = proEconEarlyReportService.getSumAlarmCountByWindturbine(customAlarmCountList, limit);
|
|
|
+
|
|
|
+ List<String> windturbineIdList = new ArrayList<>(sumAlarmCountByWindturbine.keySet());
|
|
|
+
|
|
|
+ Map<String, List<ProBasicFeatureStat>> windturbineLimitAlarmCountMap = customAlarmCountList.stream().filter(s -> windturbineIdList.contains(s.getWtId())).collect(Collectors.groupingBy(ProBasicFeatureStat::getWtId));
|
|
|
+
|
|
|
+ for (Map.Entry<String, List<ProBasicFeatureStat>> entry :
|
|
|
+ windturbineLimitAlarmCountMap.entrySet()) {
|
|
|
+ Map<String, Long> sumCountByAlertValue = entry.getValue().stream().collect(Collectors.groupingBy(ProBasicFeatureStat::getAlarmid, Collectors.summingLong(ProBasicFeatureStat::getTotal)));
|
|
|
+ Map<String, Double> sumKeepTimeByAlertValue = entry.getValue().stream().collect(Collectors.groupingBy(ProBasicFeatureStat::getAlarmid, Collectors.summingDouble(ProBasicFeatureStat::getTotalSeconds)));
|
|
|
+
|
|
|
+ ProEconEarlyReportWt reportWindturbine = new ProEconEarlyReportWt();
|
|
|
+ reportWindturbine.setId(String.valueOf(SnowflakeGenerator.generateId()));
|
|
|
+ reportWindturbine.setWindturbineId(entry.getKey());
|
|
|
+ reportWindturbine.setWindturbineCode(wt.getNemCode());
|
|
|
+ reportWindturbine.setModelId(model);
|
|
|
+ reportWindturbine.setCompared(false);
|
|
|
+ reportWindturbine.setAlarmInfoList(new ArrayList<>());
|
|
|
+ reportWindturbine.setReportId(reportId);;
|
|
|
+
|
|
|
+ for (Map.Entry<String, Long> sumCountEntry :
|
|
|
+ sumCountByAlertValue.entrySet()) {
|
|
|
+ Optional<ProEconAlarmRule> first = alertRule2List.stream().filter(s -> String.valueOf(s.getId()).equals(sumCountEntry.getKey())).findFirst();
|
|
|
+ if (first.isPresent()) {
|
|
|
+ ProEconEarlyReportAlarm alarmInfo = new ProEconEarlyReportAlarm();
|
|
|
+ alarmInfo.setId(String.valueOf(SnowflakeGenerator.generateId()));
|
|
|
+ alarmInfo.setRuleId(first.get().getId());
|
|
|
+ alarmInfo.setAlarmType("custom");
|
|
|
+ alarmInfo.setRuleName(first.get().getName());
|
|
|
+ alarmInfo.setRuleDescription(first.get().getDescription());
|
|
|
+ alarmInfo.setRank(String.valueOf(first.get().getRank()));
|
|
|
+ alarmInfo.setCount(sumCountEntry.getValue());
|
|
|
+ alarmInfo.setReportWindturbineId(reportWindturbine.getId());;
|
|
|
+ if (sumKeepTimeByAlertValue.containsKey(sumCountEntry.getKey())) {
|
|
|
+ alarmInfo.setKeepTime(sumKeepTimeByAlertValue.get(sumCountEntry.getKey()).doubleValue());
|
|
|
+ }
|
|
|
+ reportWindturbine.getAlarmInfoList().add(alarmInfo);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ resultList.add(reportWindturbine);
|
|
|
+ }
|
|
|
+
|
|
|
+ List<ProEconEarlyReportWt> earlyReportWindturbineList = checkAndFixData(resultList, alertRule2List);
|
|
|
+
|
|
|
+ return getConclusion(alertRule2List, earlyReportWindturbineList);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @param
|
|
|
+ * @param windturbineInfoList 需要对比的风机报告信息(上次报告)
|
|
|
+ * @param model 风机型号
|
|
|
+ * @param reportId 本次报告的id
|
|
|
+ * @param startTime 分析起始时间(本次分析)
|
|
|
+ * @param endTime 分析结束时间(本次分析)
|
|
|
+ * @return com.gyee.wisdom.alarm.schedule.entity.ProEconEarlyReportWt
|
|
|
+ * @author Wanghs
|
|
|
+ * @description 获取上次报告中的风机与本周报告对比信息
|
|
|
+ * @date 2022/8/29
|
|
|
+ **/
|
|
|
+
|
|
|
+ private List<ProEconEarlyReportWt> getCompareWindturbineInfo(ProBasicEquipment wt,List<ProEconEarlyReportWt> windturbineInfoList, String model, String reportId,String relatedParts, Date startTime, Date endTime) {
|
|
|
+
|
|
|
+ List<ProEconEarlyReportWt> resultList = new ArrayList<>();
|
|
|
+ List<String> windturbineIdList = windturbineInfoList.stream().map(s -> s.getWindturbineId()).collect(Collectors.toList());
|
|
|
+ List<ProEconEarlyReportAlarm> reportAlarmList = new ArrayList<>();
|
|
|
+ windturbineInfoList.forEach(s -> {
|
|
|
+ reportAlarmList.addAll(s.getAlarmInfoList());
|
|
|
+ });
|
|
|
+// List<ProEconAlarmRule> alertRule2List = proEconEarlyReportService.getAlertRule2(reportAlarmList.stream().map(s -> s.getRuleId()).collect(Collectors.toList()));
|
|
|
+// List<AlarmSnap> customAlarmSnapList = proEconEarlyReportService.getAlarmSnap(stationId,alertRule2List.stream().map(s -> s.getEdnaValue()).collect(Collectors.toList()), "custom");
|
|
|
+// List<ProBasicFeatureStat> customAlarmCountList = proEconEarlyReportService.getAlarmCount(customAlarmSnapList.stream().map(s -> s.getId()).collect(Collectors.toList()), startTime, endTime);
|
|
|
+// Map<String, List<ProBasicFeatureStat>> windturbineAlarmCountMap = customAlarmCountList.stream().filter(s -> windturbineIdList.contains(s.getWindturbineId())).collect(Collectors.groupingBy(ProBasicFeatureStat::getWindturbineId));
|
|
|
+//
|
|
|
+
|
|
|
+
|
|
|
+ List<ProEconAlarmRule> alertRule2List = new ArrayList<>();
|
|
|
+ List<String> components= new ArrayList<>();
|
|
|
+ components.add(relatedParts);
|
|
|
+ if(wt.getWindpowerstationId().contains("FDC"))
|
|
|
+ {
|
|
|
+ List<ProEconAlarmRule> rulels=CacheContext.alarmRulesMap.get(AlarmCustomType.WT.getCode());
|
|
|
+
|
|
|
+ if(!rulels.isEmpty())
|
|
|
+ {
|
|
|
+ for(ProEconAlarmRule rule:rulels)
|
|
|
+ {
|
|
|
+ if(rule.getRelatedParts().equals(relatedParts) && rule.getStationId().equals(wt.getWindpowerstationId()) && rule.getModelId().equals(model))
|
|
|
+ {
|
|
|
+ alertRule2List.add(rule);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }else
|
|
|
+ {
|
|
|
+ List<ProEconAlarmRule> rulels=CacheContext.alarmRulesMap.get(AlarmCustomType.IN.getCode());
|
|
|
+
|
|
|
+ if(!rulels.isEmpty())
|
|
|
+ {
|
|
|
+ for(ProEconAlarmRule rule:rulels)
|
|
|
+ {
|
|
|
+ if(rule.getRelatedParts().equals(relatedParts) && rule.getStationId().equals(wt.getWindpowerstationId()) && rule.getModelId().equals(model))
|
|
|
+ {
|
|
|
+ alertRule2List.add(rule);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ List<ProEconAlarmInfo> customAlarmSnapList = proEconAlarmInfoService. queryAlarmInfo(wt.getId(), AlarmTypeValue.CT.getCode());
|
|
|
+ List<String> alarmidls=new ArrayList<>();
|
|
|
+ if(!customAlarmSnapList.isEmpty())
|
|
|
+ {
|
|
|
+ for(ProEconAlarmInfo alarmInfo:customAlarmSnapList)
|
|
|
+ {
|
|
|
+ alarmidls.add(alarmInfo.getAlarmId());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ List<ProBasicFeatureStat> customAlarmCountList = alarmTsService.findCtFeatureStatCustom( startTime.getTime(), endTime.getTime(),wt.getWindpowerstationId(), wt.getModelId(), components,alarmidls);
|
|
|
+
|
|
|
+
|
|
|
+ Map<String, List<ProBasicFeatureStat>> windturbineAlarmCountMap = customAlarmCountList.stream().filter(s -> windturbineIdList.contains(s.getWtId())).collect(Collectors.groupingBy(ProBasicFeatureStat::getWtId));
|
|
|
+
|
|
|
+
|
|
|
+ for (Map.Entry<String, List<ProBasicFeatureStat>> entry :
|
|
|
+ windturbineAlarmCountMap.entrySet()) {
|
|
|
+ ProEconEarlyReportWt reportWindturbine = new ProEconEarlyReportWt();
|
|
|
+ reportWindturbine.setId(String.valueOf(SnowflakeGenerator.generateId()));
|
|
|
+ reportWindturbine.setWindturbineId(entry.getKey());
|
|
|
+ reportWindturbine.setWindturbineCode(wt.getNemCode());
|
|
|
+ reportWindturbine.setModelId(model);
|
|
|
+ reportWindturbine.setCompared(true);
|
|
|
+ reportWindturbine.setAlarmInfoList(new ArrayList<>());
|
|
|
+ reportWindturbine.setReportId(reportId);
|
|
|
+
|
|
|
+ Optional<ProEconEarlyReportWt> oldReportWindturbine = windturbineInfoList.stream().filter(s -> s.getWindturbineId().equals(entry.getKey())).findFirst();
|
|
|
+ if (oldReportWindturbine.isPresent())
|
|
|
+ reportWindturbine.setCompareId(oldReportWindturbine.get().getId());
|
|
|
+
|
|
|
+ Map<String, Long> sumCountByAlertValue = entry.getValue().stream().collect(Collectors.groupingBy(ProBasicFeatureStat::getAlarmid, Collectors.summingLong(ProBasicFeatureStat::getTotal)));
|
|
|
+ Map<String, Double> sumKeepTimeByAlertValue = entry.getValue().stream().collect(Collectors.groupingBy(ProBasicFeatureStat::getAlarmid, Collectors.summingDouble(ProBasicFeatureStat::getTotalSeconds)));
|
|
|
+
|
|
|
+ for (Map.Entry<String, Long> sumCountEntry :
|
|
|
+ sumCountByAlertValue.entrySet()) {
|
|
|
+ Optional<ProEconAlarmRule> first = alertRule2List.stream().filter(s -> String.valueOf(s.getId()).equals(sumCountEntry.getKey())).findFirst();
|
|
|
+ if (first.isPresent()) {
|
|
|
+ ProEconEarlyReportAlarm alarmInfo = new ProEconEarlyReportAlarm();
|
|
|
+ alarmInfo.setId(String.valueOf(SnowflakeGenerator.generateId()));
|
|
|
+ alarmInfo.setRuleId(first.get().getId());
|
|
|
+ alarmInfo.setAlarmType("custom");
|
|
|
+ alarmInfo.setRuleName(first.get().getName());
|
|
|
+ alarmInfo.setRuleDescription(first.get().getDescription());
|
|
|
+ alarmInfo.setRank(String.valueOf(first.get().getRank()));
|
|
|
+ alarmInfo.setCount(sumCountEntry.getValue());
|
|
|
+ alarmInfo.setReportWindturbineId(reportWindturbine.getId());
|
|
|
+ if (sumKeepTimeByAlertValue.containsKey(sumCountEntry.getKey())) {
|
|
|
+ alarmInfo.setKeepTime(sumKeepTimeByAlertValue.get(sumCountEntry.getKey()).doubleValue());
|
|
|
+ }
|
|
|
+ reportWindturbine.getAlarmInfoList().add(alarmInfo);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ resultList.add(reportWindturbine);
|
|
|
+ }
|
|
|
+
|
|
|
+ List<ProEconEarlyReportWt> earlyReportWindturbineList = checkAndFixData(resultList, alertRule2List);
|
|
|
+ return earlyReportWindturbineList;
|
|
|
+ }
|
|
|
+
|
|
|
+ private List<ProEconEarlyReportWt> getConclusion(List<ProEconAlarmRule> alertRule2List, List<ProEconEarlyReportWt> reportWindturbineList) {
|
|
|
+
|
|
|
+ List<ProEconEarlyReportConclusio> listByPart = proEconEarlyReportConclusioService.getListByPart(alertRule2List.stream().map(s -> s.getRelatedParts()).collect(Collectors.toList()));
|
|
|
+
|
|
|
+ for (ProEconEarlyReportWt windturbineData :
|
|
|
+ reportWindturbineList) {
|
|
|
+ if (!windturbineData.getWindturbineId().equals("全场平均")) {
|
|
|
+ StringBuilder firstStr = new StringBuilder("风机" + windturbineData.getWindturbineCode() + ":发生");
|
|
|
+ for (int i = 0; i < windturbineData.getAlarmInfoList().size(); i++) {
|
|
|
+ ProEconEarlyReportAlarm earlyReportAlarm = windturbineData.getAlarmInfoList().get(i);
|
|
|
+ firstStr.append(earlyReportAlarm.getRuleName());
|
|
|
+ firstStr.append(earlyReportAlarm.getCount());
|
|
|
+ firstStr.append("次,总持续时长为");
|
|
|
+ firstStr.append(earlyReportAlarm.getKeepTime() + "分钟;");
|
|
|
+ }
|
|
|
+ StringBuilder secondStr = new StringBuilder("可能存在的隐患:").append("\n");
|
|
|
+ StringBuilder thridStr = new StringBuilder("建议排查:").append("\n");
|
|
|
+
|
|
|
+ for (int i = 0; i < listByPart.size(); i++) {
|
|
|
+ secondStr.append("\b");
|
|
|
+ secondStr.append("\b");
|
|
|
+ secondStr.append("\b");
|
|
|
+ secondStr.append("-" + listByPart.get(i).getHiddanger());
|
|
|
+ secondStr.append("\n");
|
|
|
+
|
|
|
+ thridStr.append("\b");
|
|
|
+ thridStr.append("\b");
|
|
|
+ thridStr.append("\b");
|
|
|
+ thridStr.append("-" + listByPart.get(i).getCheckMatter());
|
|
|
+ thridStr.append("\n");
|
|
|
+ }
|
|
|
+ StringBuilder resultStr = new StringBuilder();
|
|
|
+
|
|
|
+ resultStr.append(firstStr);
|
|
|
+ resultStr.append("\n");
|
|
|
+ resultStr.append(secondStr);
|
|
|
+ resultStr.append("\n");
|
|
|
+ resultStr.append(thridStr);
|
|
|
+ windturbineData.setConclusion(resultStr.toString());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return reportWindturbineList;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ //数据校验,避免部分规则没有数据的情况
|
|
|
+ public List<ProEconEarlyReportWt> checkAndFixData(List<ProEconEarlyReportWt> earlyReportWindturbineList,List<ProEconAlarmRule> rule2List){
|
|
|
+
|
|
|
+ List<String> ruleIdList = rule2List.stream().map(s -> s.getId()).collect(Collectors.toList());
|
|
|
+ earlyReportWindturbineList.forEach(s -> {
|
|
|
+// if (!s.getWindturbineId().equals("全场平均") ) {
|
|
|
+ List<ProEconEarlyReportAlarm> alarmInfoList = s.getAlarmInfoList();
|
|
|
+ if (alarmInfoList.size() < rule2List.size()) {
|
|
|
+
|
|
|
+ Collection subtract = CollectionUtils.subtract(ruleIdList, alarmInfoList.stream().map(k -> k.getRuleId()).collect(Collectors.toList()));
|
|
|
+
|
|
|
+ List<String> arrayList = new ArrayList<String>(subtract);
|
|
|
+
|
|
|
+ if (arrayList.size() > 0) {
|
|
|
+ arrayList.stream().forEach(l -> {
|
|
|
+
|
|
|
+ Optional<ProEconAlarmRule> first = rule2List.stream().filter(m -> m.getId().equals(l)).findFirst();
|
|
|
+ if (first.isPresent()) {
|
|
|
+ ProEconEarlyReportAlarm alarmInfo = new ProEconEarlyReportAlarm();
|
|
|
+ alarmInfo.setId(String.valueOf(SnowflakeGenerator.generateId()));
|
|
|
+ alarmInfo.setRuleId(first.get().getId());
|
|
|
+ alarmInfo.setAlarmType("custom");
|
|
|
+ alarmInfo.setRuleName(first.get().getName());
|
|
|
+ alarmInfo.setRuleDescription(first.get().getDescription());
|
|
|
+ alarmInfo.setRank(String.valueOf(first.get().getRank()));
|
|
|
+ alarmInfo.setCount(0l);
|
|
|
+ alarmInfo.setKeepTime(0.0);
|
|
|
+ alarmInfo.setReportWindturbineId(s.getId());
|
|
|
+ alarmInfoList.add(alarmInfo);
|
|
|
+ }
|
|
|
+
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
// }
|
|
|
-// }
|
|
|
-// resultList.add(avgWindturbineReport);
|
|
|
-//
|
|
|
-// Map<String, ProBasicFeatureStat> sumAlarmCountByWindturbine = proEconEarlyReportService.getSumAlarmCountByWindturbine(customAlarmCountList, limit);
|
|
|
-//
|
|
|
-// List<String> windturbineIdList = new ArrayList<String>(sumAlarmCountByWindturbine.keySet());
|
|
|
-//
|
|
|
-// Map<String, List<ProBasicFeatureStat>> windturbineLimitAlarmCountMap = customAlarmCountList.stream().filter(s -> windturbineIdList.contains(s.getWindturbineId())).collect(Collectors.groupingBy(ProBasicFeatureStat::getWindturbineId));
|
|
|
-//
|
|
|
-// for (Map.Entry<String, List<ProBasicFeatureStat>> entry :
|
|
|
-// windturbineLimitAlarmCountMap.entrySet()) {
|
|
|
-// Map<String, Integer> sumCountByAlertValue = entry.getValue().stream().collect(Collectors.groupingBy(ProBasicFeatureStat::getAlertValue, Collectors.summingInt(ProBasicFeatureStat::getCount)));
|
|
|
-// Map<String, Double> sumKeepTimeByAlertValue = entry.getValue().stream().collect(Collectors.groupingBy(ProBasicFeatureStat::getAlertValue, Collectors.summingDouble(ProBasicFeatureStat::getTime)));
|
|
|
-//
|
|
|
-// ProEconEarlyReportWt reportWindturbine = new ProEconEarlyReportWt()
|
|
|
-// .setId(String.valueOf(SnowflakeGenerator.generateId()))
|
|
|
-// .setWindturbineId(entry.getKey())
|
|
|
-// .setWindturbineCode(windturbineCache.getWindturbine(entry.getKey()).getCode())
|
|
|
-// .setModel(model)
|
|
|
-// .setCompared(false)
|
|
|
-// .setAlarmInfoList(new ArrayList<>())
|
|
|
-// .setReportId(reportId);
|
|
|
-//
|
|
|
-// for (Map.Entry<String, Integer> sumCountEntry :
|
|
|
-// sumCountByAlertValue.entrySet()) {
|
|
|
-// Optional<ProEconAlarmRule> first = alertRule2List.stream().filter(s -> String.valueOf(s.getEdnaValue()).equals(sumCountEntry.getKey())).findFirst();
|
|
|
-// if (first.isPresent()) {
|
|
|
-// EarlyReportAlarm alarmInfo = new EarlyReportAlarm()
|
|
|
-// .setId(String.valueOf(SnowflakeGenerator.generateId()))
|
|
|
-// .setRuleId(first.get().getId())
|
|
|
-// .setAlarmType("custom")
|
|
|
-// .setRuleName(first.get().getName())
|
|
|
-// .setRuleDescription(first.get().getDescription())
|
|
|
-// .setRank(first.get().getRank())
|
|
|
-// .setCount(sumCountEntry.getValue())
|
|
|
-// .setReportWindturbineId(reportWindturbine.getId());
|
|
|
-// if (sumKeepTimeByAlertValue.containsKey(sumCountEntry.getKey())) {
|
|
|
-// alarmInfo.setKeepTime((long) sumKeepTimeByAlertValue.get(sumCountEntry.getKey()).doubleValue());
|
|
|
-// }
|
|
|
-// reportWindturbine.getAlarmInfoList().add(alarmInfo);
|
|
|
-// }
|
|
|
-// }
|
|
|
-// resultList.add(reportWindturbine);
|
|
|
-// }
|
|
|
-//
|
|
|
-// List<ProEconEarlyReportWt> earlyReportWindturbineList = checkAndFixData(resultList, alertRule2List);
|
|
|
-//
|
|
|
-// return getConclusion(alertRule2List, earlyReportWindturbineList);
|
|
|
-//
|
|
|
-// }
|
|
|
-//
|
|
|
-//
|
|
|
-////
|
|
|
-//// /**
|
|
|
-//// * @param
|
|
|
-//// * @param windturbineInfoList 需要对比的风机报告信息(上次报告)
|
|
|
-//// * @param model 风机型号
|
|
|
-//// * @param reportId 本次报告的id
|
|
|
-//// * @param startTime 分析起始时间(本次分析)
|
|
|
-//// * @param endTime 分析结束时间(本次分析)
|
|
|
-//// * @return com.gyee.wisdom.alarm.schedule.entity.ProEconEarlyReportWt
|
|
|
-//// * @author Wanghs
|
|
|
-//// * @description 获取上次报告中的风机与本周报告对比信息
|
|
|
-//// * @date 2022/8/29
|
|
|
-//// **/
|
|
|
-////
|
|
|
-//// private List<ProEconEarlyReportWt> getCompareWindturbineInfo(String stationId,List<ProEconEarlyReportWt> windturbineInfoList, String model, String reportId, Date startTime, Date endTime) {
|
|
|
-////
|
|
|
-//// List<ProEconEarlyReportWt> resultList = new ArrayList<>();
|
|
|
-//// List<String> windturbineIdList = windturbineInfoList.stream().map(s -> s.getWindturbineId()).collect(Collectors.toList());
|
|
|
-//// List<EarlyReportAlarm> reportAlarmList = new ArrayList<>();
|
|
|
-//// windturbineInfoList.forEach(s -> {
|
|
|
-//// reportAlarmList.addAll(s.getAlarmInfoList());
|
|
|
-//// });
|
|
|
-//// List<ProEconAlarmRule> alertRule2List = proEconEarlyReportService.getAlertRule2(reportAlarmList.stream().map(s -> s.getRuleId()).collect(Collectors.toList()));
|
|
|
-//// List<AlarmSnap> customAlarmSnapList = proEconEarlyReportService.getAlarmSnap(stationId,alertRule2List.stream().map(s -> s.getEdnaValue()).collect(Collectors.toList()), "custom");
|
|
|
-//// List<ProBasicFeatureStat> customAlarmCountList = proEconEarlyReportService.getAlarmCount(customAlarmSnapList.stream().map(s -> s.getId()).collect(Collectors.toList()), startTime, endTime);
|
|
|
-//// Map<String, List<ProBasicFeatureStat>> windturbineAlarmCountMap = customAlarmCountList.stream().filter(s -> windturbineIdList.contains(s.getWindturbineId())).collect(Collectors.groupingBy(ProBasicFeatureStat::getWindturbineId));
|
|
|
-////
|
|
|
-//// for (Map.Entry<String, List<ProBasicFeatureStat>> entry :
|
|
|
-//// windturbineAlarmCountMap.entrySet()) {
|
|
|
-//// ProEconEarlyReportWt reportWindturbine = new ProEconEarlyReportWt()
|
|
|
-//// .setId(String.valueOf(SnowflakeGenerator.generateId()))
|
|
|
-//// .setWindturbineId(entry.getKey())
|
|
|
-//// .setWindturbineCode(windturbineCache.getWindturbine(entry.getKey()).getCode())
|
|
|
-//// .setModel(model)
|
|
|
-//// .setCompared(true)
|
|
|
-//// .setAlarmInfoList(new ArrayList<>())
|
|
|
-//// .setReportId(reportId);
|
|
|
-////
|
|
|
-//// Optional<ProEconEarlyReportWt> oldReportWindturbine = windturbineInfoList.stream().filter(s -> s.getWindturbineId().equals(entry.getKey())).findFirst();
|
|
|
-//// if (oldReportWindturbine.isPresent())
|
|
|
-//// reportWindturbine.setCompareId(oldReportWindturbine.get().getId());
|
|
|
-////
|
|
|
-//// Map<String, Integer> sumCountByAlertValue = entry.getValue().stream().collect(Collectors.groupingBy(ProBasicFeatureStat::getAlertValue, Collectors.summingInt(ProBasicFeatureStat::getCount)));
|
|
|
-//// Map<String, Double> sumKeepTimeByAlertValue = entry.getValue().stream().collect(Collectors.groupingBy(ProBasicFeatureStat::getAlertValue, Collectors.summingDouble(ProBasicFeatureStat::getTime)));
|
|
|
-////
|
|
|
-//// for (Map.Entry<String, Integer> sumCountEntry :
|
|
|
-//// sumCountByAlertValue.entrySet()) {
|
|
|
-//// Optional<ProEconAlarmRule> first = alertRule2List.stream().filter(s -> String.valueOf(s.getEdnaValue()).equals(sumCountEntry.getKey())).findFirst();
|
|
|
-//// if (first.isPresent()) {
|
|
|
-//// EarlyReportAlarm alarmInfo = new EarlyReportAlarm()
|
|
|
-//// .setId(String.valueOf(SnowflakeGenerator.generateId()))
|
|
|
-//// .setRuleId(first.get().getId())
|
|
|
-//// .setAlarmType("custom")
|
|
|
-//// .setRuleName(first.get().getName())
|
|
|
-//// .setRuleDescription(first.get().getDescription())
|
|
|
-//// .setRank(first.get().getRank())
|
|
|
-//// .setCount(sumCountEntry.getValue())
|
|
|
-//// .setReportWindturbineId(reportWindturbine.getId());
|
|
|
-//// if (sumKeepTimeByAlertValue.containsKey(sumCountEntry.getKey())) {
|
|
|
-//// alarmInfo.setKeepTime((long) sumKeepTimeByAlertValue.get(sumCountEntry.getKey()).doubleValue());
|
|
|
-//// }
|
|
|
-//// reportWindturbine.getAlarmInfoList().add(alarmInfo);
|
|
|
-//// }
|
|
|
-//// }
|
|
|
-//// resultList.add(reportWindturbine);
|
|
|
-//// }
|
|
|
-////
|
|
|
-//// List<ProEconEarlyReportWt> earlyReportWindturbineList = checkAndFixData(resultList, alertRule2List);
|
|
|
-//// return earlyReportWindturbineList;
|
|
|
-//// }
|
|
|
-////
|
|
|
-//// private List<ProEconEarlyReportWt> getConclusion(List<ProEconAlarmRule> alertRule2List, List<ProEconEarlyReportWt> reportWindturbineList) {
|
|
|
-////
|
|
|
-//// List<EarlyReportConclusion> listByPart = ConclusionCache.getListByPart(alertRule2List.stream().map(s -> s.getRelatedParts()).collect(Collectors.toList()));
|
|
|
-////
|
|
|
-//// for (ProEconEarlyReportWt windturbineData :
|
|
|
-//// reportWindturbineList) {
|
|
|
-//// if (!windturbineData.getWindturbineId().equals("全场平均")) {
|
|
|
-//// StringBuilder firstStr = new StringBuilder("风机" + windturbineData.getWindturbineCode() + ":发生");
|
|
|
-//// for (int i = 0; i < windturbineData.getAlarmInfoList().size(); i++) {
|
|
|
-//// EarlyReportAlarm earlyReportAlarm = windturbineData.getAlarmInfoList().get(i);
|
|
|
-//// firstStr.append(earlyReportAlarm.getRuleName());
|
|
|
-//// firstStr.append(earlyReportAlarm.getCount());
|
|
|
-//// firstStr.append("次,总持续时长为");
|
|
|
-//// firstStr.append(earlyReportAlarm.getKeepTime() + "分钟;");
|
|
|
-//// }
|
|
|
-//// StringBuilder secondStr = new StringBuilder("可能存在的隐患:").append("\n");
|
|
|
-//// StringBuilder thridStr = new StringBuilder("建议排查:").append("\n");
|
|
|
-////
|
|
|
-//// for (int i = 0; i < listByPart.size(); i++) {
|
|
|
-//// secondStr.append("\b");
|
|
|
-//// secondStr.append("\b");
|
|
|
-//// secondStr.append("\b");
|
|
|
-//// secondStr.append("-" + listByPart.get(i).getHiddanger());
|
|
|
-//// secondStr.append("\n");
|
|
|
-////
|
|
|
-//// thridStr.append("\b");
|
|
|
-//// thridStr.append("\b");
|
|
|
-//// thridStr.append("\b");
|
|
|
-//// thridStr.append("-" + listByPart.get(i).getCheckmatter());
|
|
|
-//// thridStr.append("\n");
|
|
|
-//// }
|
|
|
-//// StringBuilder resultStr = new StringBuilder();
|
|
|
-////
|
|
|
-//// resultStr.append(firstStr);
|
|
|
-//// resultStr.append("\n");
|
|
|
-//// resultStr.append(secondStr);
|
|
|
-//// resultStr.append("\n");
|
|
|
-//// resultStr.append(thridStr);
|
|
|
-//// windturbineData.setConclusion(resultStr.toString());
|
|
|
-//// }
|
|
|
-//// }
|
|
|
-//// return reportWindturbineList;
|
|
|
-////
|
|
|
-//// }
|
|
|
-////
|
|
|
-//// //数据校验,避免部分规则没有数据的情况
|
|
|
-//// public List<ProEconEarlyReportWt> checkAndFixData(List<ProEconEarlyReportWt> earlyReportWindturbineList,List<ProEconAlarmRule> rule2List){
|
|
|
-////
|
|
|
-//// List<String> ruleIdList = rule2List.stream().map(s -> s.getId()).collect(Collectors.toList());
|
|
|
-//// earlyReportWindturbineList.forEach(s -> {
|
|
|
-////// if (!s.getWindturbineId().equals("全场平均") ) {
|
|
|
-//// List<EarlyReportAlarm> alarmInfoList = s.getAlarmInfoList();
|
|
|
-//// if (alarmInfoList.size() < reportParam.getCustomRuleId().size()) {
|
|
|
-////
|
|
|
-//// Collection subtract = CollectionUtils.subtract(ruleIdList, alarmInfoList.stream().map(k -> k.getRuleId()).collect(Collectors.toList()));
|
|
|
-////
|
|
|
-//// List<String> arrayList = new ArrayList<String>(subtract);
|
|
|
-////
|
|
|
-//// if (arrayList.size() > 0) {
|
|
|
-//// arrayList.stream().forEach(l -> {
|
|
|
-////
|
|
|
-//// Optional<ProEconAlarmRule> first = rule2List.stream().filter(m -> m.getId().equals(l)).findFirst();
|
|
|
-//// if (first.isPresent()) {
|
|
|
-//// EarlyReportAlarm alarmInfo = new EarlyReportAlarm()
|
|
|
-//// .setId(String.valueOf(SnowflakeGenerator.generateId()))
|
|
|
-//// .setRuleId(first.get().getId())
|
|
|
-//// .setAlarmType("custom")
|
|
|
-//// .setRuleName(first.get().getName())
|
|
|
-//// .setRuleDescription(first.get().getDescription())
|
|
|
-//// .setRank(first.get().getRank())
|
|
|
-//// .setCount(0)
|
|
|
-//// .setKeepTime(0)
|
|
|
-//// .setReportWindturbineId(s.getId());
|
|
|
-//// alarmInfoList.add(alarmInfo);
|
|
|
-//// }
|
|
|
-////
|
|
|
-//// });
|
|
|
-//// }
|
|
|
-////
|
|
|
-////
|
|
|
-//// }
|
|
|
-////// }
|
|
|
-////
|
|
|
-//// });
|
|
|
-////
|
|
|
-//// return earlyReportWindturbineList;
|
|
|
-//// }
|
|
|
-//}
|
|
|
+
|
|
|
+ });
|
|
|
+
|
|
|
+ return earlyReportWindturbineList;
|
|
|
+ }
|
|
|
+}
|