|
@@ -11,6 +11,7 @@ import com.gyee.wisdom.alarm.schedule.util.SnowflakeGenerator;
|
|
import com.gyee.wisdom.alarm.schedule.util.SpringContextUtils;
|
|
import com.gyee.wisdom.alarm.schedule.util.SpringContextUtils;
|
|
import com.gyee.wisdom.common.utils.DateUtil;
|
|
import com.gyee.wisdom.common.utils.DateUtil;
|
|
import lombok.Data;
|
|
import lombok.Data;
|
|
|
|
+import org.apache.commons.collections.CollectionUtils;
|
|
|
|
|
|
import java.util.*;
|
|
import java.util.*;
|
|
import java.util.concurrent.Callable;
|
|
import java.util.concurrent.Callable;
|
|
@@ -60,14 +61,14 @@ public class EarlyReportTask implements Callable<TaskResult> {
|
|
.setStationId(stationId)
|
|
.setStationId(stationId)
|
|
.setStationName(StationCache.getStationName(stationId))
|
|
.setStationName(StationCache.getStationName(stationId))
|
|
.setRelatedParts(reportParam.getWindturbineParts())
|
|
.setRelatedParts(reportParam.getWindturbineParts())
|
|
- .setReportName(StationCache.getStationName(stationId)+"风机"+reportParam.getAnalysisName()+"诊断报告")
|
|
|
|
|
|
+ .setReportName(StationCache.getStationName(stationId) + "风机" + reportParam.getAnalysisName() + "诊断报告")
|
|
.setStatStartDate(statStartTime)
|
|
.setStatStartDate(statStartTime)
|
|
.setStatEndDate(statEndTime)
|
|
.setStatEndDate(statEndTime)
|
|
.setReportWindturbineInfoList(new ArrayList<>());
|
|
.setReportWindturbineInfoList(new ArrayList<>());
|
|
|
|
|
|
try {
|
|
try {
|
|
//获取本次报告最差的风机信息集合
|
|
//获取本次报告最差的风机信息集合
|
|
- List<EarlyReportWindturbine> nowWindturbineInfoList = getNowWindturbineInfo(model, report.getId(), statStartTime, statEndTime, limit);
|
|
|
|
|
|
+ List<EarlyReportWindturbine> nowWindturbineInfoList = getNowWindturbineInfo(stationId,model, report.getId(), statStartTime, statEndTime, limit);
|
|
|
|
|
|
report.getReportWindturbineInfoList().addAll(nowWindturbineInfoList);
|
|
report.getReportWindturbineInfoList().addAll(nowWindturbineInfoList);
|
|
// 获取上次报告
|
|
// 获取上次报告
|
|
@@ -77,7 +78,7 @@ public class EarlyReportTask implements Callable<TaskResult> {
|
|
if (collect.size() > 0) {
|
|
if (collect.size() > 0) {
|
|
//已经进行了排序,因此获取第一个,即为最近一次报告
|
|
//已经进行了排序,因此获取第一个,即为最近一次报告
|
|
List<EarlyReportWindturbine> reportWindturbineInfoList = collect.get(0).getReportWindturbineInfoList().stream().filter(s -> s.isCompared() == false && !s.getWindturbineId().equals("全场平均")).collect(Collectors.toList());
|
|
List<EarlyReportWindturbine> reportWindturbineInfoList = collect.get(0).getReportWindturbineInfoList().stream().filter(s -> s.isCompared() == false && !s.getWindturbineId().equals("全场平均")).collect(Collectors.toList());
|
|
- List<EarlyReportWindturbine> compareWindturbineInfoList = getCompareWindturbineInfo(reportWindturbineInfoList, model, report.getId(), statStartTime, statEndTime);
|
|
|
|
|
|
+ List<EarlyReportWindturbine> compareWindturbineInfoList = getCompareWindturbineInfo(stationId,reportWindturbineInfoList, model, report.getId(), statStartTime, statEndTime);
|
|
report.getReportWindturbineInfoList().addAll(compareWindturbineInfoList);
|
|
report.getReportWindturbineInfoList().addAll(compareWindturbineInfoList);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -103,13 +104,13 @@ public class EarlyReportTask implements Callable<TaskResult> {
|
|
* @description 获取本次报告风机信息
|
|
* @description 获取本次报告风机信息
|
|
* @date 2022/8/29
|
|
* @date 2022/8/29
|
|
**/
|
|
**/
|
|
- private List<EarlyReportWindturbine> getNowWindturbineInfo(String model, String reportId, Date statStartTime, Date statEndTime, int limit) {
|
|
|
|
|
|
+ private List<EarlyReportWindturbine> getNowWindturbineInfo(String stationId,String model, String reportId, Date statStartTime, Date statEndTime, int limit) {
|
|
|
|
|
|
List<EarlyReportWindturbine> resultList = new ArrayList<>();
|
|
List<EarlyReportWindturbine> resultList = new ArrayList<>();
|
|
|
|
|
|
List<AlertRule2> alertRule2List = earlyReportBiz.getAlertRule2(reportParam.getCustomRuleId());
|
|
List<AlertRule2> alertRule2List = earlyReportBiz.getAlertRule2(reportParam.getCustomRuleId());
|
|
|
|
|
|
- List<AlarmSnap> customAlarmSnapList = earlyReportBiz.getAlarmSnap(alertRule2List.stream().map(s -> String.valueOf(s.getEdnaValue())).collect(Collectors.toList()), "custom");
|
|
|
|
|
|
+ List<AlarmSnap> customAlarmSnapList = earlyReportBiz.getAlarmSnap(stationId,alertRule2List.stream().map(s -> String.valueOf(s.getEdnaValue())).collect(Collectors.toList()), "custom");
|
|
|
|
|
|
List<AlarmCount> customAlarmCountList = earlyReportBiz.getAlarmCount(customAlarmSnapList.stream().map(s -> s.getId()).collect(Collectors.toList()), statStartTime, statEndTime);
|
|
List<AlarmCount> customAlarmCountList = earlyReportBiz.getAlarmCount(customAlarmSnapList.stream().map(s -> s.getId()).collect(Collectors.toList()), statStartTime, statEndTime);
|
|
|
|
|
|
@@ -187,7 +188,9 @@ public class EarlyReportTask implements Callable<TaskResult> {
|
|
resultList.add(reportWindturbine);
|
|
resultList.add(reportWindturbine);
|
|
}
|
|
}
|
|
|
|
|
|
- return getConclusion(alertRule2List,resultList);
|
|
|
|
|
|
+ List<EarlyReportWindturbine> earlyReportWindturbineList = checkAndFixData(resultList, alertRule2List);
|
|
|
|
+
|
|
|
|
+ return getConclusion(alertRule2List, earlyReportWindturbineList);
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
@@ -204,7 +207,7 @@ public class EarlyReportTask implements Callable<TaskResult> {
|
|
* @date 2022/8/29
|
|
* @date 2022/8/29
|
|
**/
|
|
**/
|
|
|
|
|
|
- private List<EarlyReportWindturbine> getCompareWindturbineInfo(List<EarlyReportWindturbine> windturbineInfoList, String model, String reportId, Date startTime, Date endTime) {
|
|
|
|
|
|
+ private List<EarlyReportWindturbine> getCompareWindturbineInfo(String stationId,List<EarlyReportWindturbine> windturbineInfoList, String model, String reportId, Date startTime, Date endTime) {
|
|
|
|
|
|
List<EarlyReportWindturbine> resultList = new ArrayList<>();
|
|
List<EarlyReportWindturbine> resultList = new ArrayList<>();
|
|
List<String> windturbineIdList = windturbineInfoList.stream().map(s -> s.getWindturbineId()).collect(Collectors.toList());
|
|
List<String> windturbineIdList = windturbineInfoList.stream().map(s -> s.getWindturbineId()).collect(Collectors.toList());
|
|
@@ -213,7 +216,7 @@ public class EarlyReportTask implements Callable<TaskResult> {
|
|
reportAlarmList.addAll(s.getAlarmInfoList());
|
|
reportAlarmList.addAll(s.getAlarmInfoList());
|
|
});
|
|
});
|
|
List<AlertRule2> alertRule2List = earlyReportBiz.getAlertRule2(reportAlarmList.stream().map(s -> s.getRuleId()).collect(Collectors.toList()));
|
|
List<AlertRule2> alertRule2List = earlyReportBiz.getAlertRule2(reportAlarmList.stream().map(s -> s.getRuleId()).collect(Collectors.toList()));
|
|
- List<AlarmSnap> customAlarmSnapList = earlyReportBiz.getAlarmSnap(alertRule2List.stream().map(s -> String.valueOf(s.getEdnaValue())).collect(Collectors.toList()), "custom");
|
|
|
|
|
|
+ List<AlarmSnap> customAlarmSnapList = earlyReportBiz.getAlarmSnap(stationId,alertRule2List.stream().map(s -> String.valueOf(s.getEdnaValue())).collect(Collectors.toList()), "custom");
|
|
List<AlarmCount> customAlarmCountList = earlyReportBiz.getAlarmCount(customAlarmSnapList.stream().map(s -> s.getId()).collect(Collectors.toList()), startTime, endTime);
|
|
List<AlarmCount> customAlarmCountList = earlyReportBiz.getAlarmCount(customAlarmSnapList.stream().map(s -> s.getId()).collect(Collectors.toList()), startTime, endTime);
|
|
Map<String, List<AlarmCount>> windturbineAlarmCountMap = customAlarmCountList.stream().filter(s -> windturbineIdList.contains(s.getWindturbineId())).collect(Collectors.groupingBy(AlarmCount::getWindturbineId));
|
|
Map<String, List<AlarmCount>> windturbineAlarmCountMap = customAlarmCountList.stream().filter(s -> windturbineIdList.contains(s.getWindturbineId())).collect(Collectors.groupingBy(AlarmCount::getWindturbineId));
|
|
|
|
|
|
@@ -256,7 +259,9 @@ public class EarlyReportTask implements Callable<TaskResult> {
|
|
}
|
|
}
|
|
resultList.add(reportWindturbine);
|
|
resultList.add(reportWindturbine);
|
|
}
|
|
}
|
|
- return resultList;
|
|
|
|
|
|
+
|
|
|
|
+ List<EarlyReportWindturbine> earlyReportWindturbineList = checkAndFixData(resultList, alertRule2List);
|
|
|
|
+ return earlyReportWindturbineList;
|
|
}
|
|
}
|
|
|
|
|
|
private List<EarlyReportWindturbine> getConclusion(List<AlertRule2> alertRule2List, List<EarlyReportWindturbine> reportWindturbineList) {
|
|
private List<EarlyReportWindturbine> getConclusion(List<AlertRule2> alertRule2List, List<EarlyReportWindturbine> reportWindturbineList) {
|
|
@@ -265,8 +270,8 @@ public class EarlyReportTask implements Callable<TaskResult> {
|
|
|
|
|
|
for (EarlyReportWindturbine windturbineData :
|
|
for (EarlyReportWindturbine windturbineData :
|
|
reportWindturbineList) {
|
|
reportWindturbineList) {
|
|
- if(!windturbineData.getWindturbineId().equals("全场平均")){
|
|
|
|
- StringBuilder firstStr = new StringBuilder("风机"+windturbineData.getWindturbineCode()+":发生");
|
|
|
|
|
|
+ if (!windturbineData.getWindturbineId().equals("全场平均")) {
|
|
|
|
+ StringBuilder firstStr = new StringBuilder("风机" + windturbineData.getWindturbineCode() + ":发生");
|
|
for (int i = 0; i < windturbineData.getAlarmInfoList().size(); i++) {
|
|
for (int i = 0; i < windturbineData.getAlarmInfoList().size(); i++) {
|
|
EarlyReportAlarm earlyReportAlarm = windturbineData.getAlarmInfoList().get(i);
|
|
EarlyReportAlarm earlyReportAlarm = windturbineData.getAlarmInfoList().get(i);
|
|
firstStr.append(earlyReportAlarm.getRuleName());
|
|
firstStr.append(earlyReportAlarm.getRuleName());
|
|
@@ -281,13 +286,13 @@ public class EarlyReportTask implements Callable<TaskResult> {
|
|
secondStr.append("\b");
|
|
secondStr.append("\b");
|
|
secondStr.append("\b");
|
|
secondStr.append("\b");
|
|
secondStr.append("\b");
|
|
secondStr.append("\b");
|
|
- secondStr.append("-"+listByPart.get(i).getHiddanger());
|
|
|
|
|
|
+ secondStr.append("-" + listByPart.get(i).getHiddanger());
|
|
secondStr.append("\n");
|
|
secondStr.append("\n");
|
|
|
|
|
|
thridStr.append("\b");
|
|
thridStr.append("\b");
|
|
thridStr.append("\b");
|
|
thridStr.append("\b");
|
|
thridStr.append("\b");
|
|
thridStr.append("\b");
|
|
- thridStr.append("-"+listByPart.get(i).getCheckmatter());
|
|
|
|
|
|
+ thridStr.append("-" + listByPart.get(i).getCheckmatter());
|
|
thridStr.append("\n");
|
|
thridStr.append("\n");
|
|
}
|
|
}
|
|
StringBuilder resultStr = new StringBuilder();
|
|
StringBuilder resultStr = new StringBuilder();
|
|
@@ -303,4 +308,47 @@ public class EarlyReportTask implements Callable<TaskResult> {
|
|
return reportWindturbineList;
|
|
return reportWindturbineList;
|
|
|
|
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ //数据校验,避免部分规则没有数据的情况
|
|
|
|
+ public List<EarlyReportWindturbine> checkAndFixData(List<EarlyReportWindturbine> earlyReportWindturbineList,List<AlertRule2> 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<AlertRule2> 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;
|
|
|
|
+ }
|
|
}
|
|
}
|