|
@@ -2,6 +2,8 @@ package org.jeecg.modules.interlockjob;
|
|
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.jeecg.common.util.DateUtils;
|
|
|
+import org.jeecg.modules.base.entity.InterlockBase;
|
|
|
+import org.jeecg.modules.base.service.IInterlockBaseService;
|
|
|
import org.jeecg.modules.history.entity.InterlockDetailHistory;
|
|
|
import org.jeecg.modules.history.entity.InterlockSummaryHistory;
|
|
|
import org.jeecg.modules.history.service.IInterlockDetailHistoryService;
|
|
@@ -48,6 +50,10 @@ public class DayStatisticsJob implements Job {
|
|
|
@SuppressWarnings("all")
|
|
|
private IInterlockDetailHistoryService detailHistoryService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ @SuppressWarnings("all")
|
|
|
+ private IInterlockBaseService baseService;
|
|
|
+
|
|
|
@Override
|
|
|
public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
|
|
|
// 日统计的定时任务 统计 每个系统下的每个联锁 健康等级(A/B/C/D)、联锁状态,每个联锁条件的仪表状态 的个数
|
|
@@ -55,7 +61,7 @@ public class DayStatisticsJob implements Job {
|
|
|
String currentDay = DateUtils.getDate("yyyy-MM-dd"); // 当前日期
|
|
|
LocalDate yesterDate = LocalDate.now().minusDays(1); // 当前 00:00:00 执行定时任务 减一天获取昨天的日期
|
|
|
//String yesterday = yesterDate.format(formatter); // 昨天的日期
|
|
|
- String yesterday = "2024-06-12"; // 昨天的日期
|
|
|
+ String yesterday = "2024-06-26"; // 测试模拟的昨天日期
|
|
|
|
|
|
// 统计健康等级 count_type = 0
|
|
|
List<InterlockCount> loopHealthLevelList = summaryHistoryService.getLoopHealthLevelByTagTime(yesterday);
|
|
@@ -120,12 +126,16 @@ public class DayStatisticsJob implements Job {
|
|
|
}
|
|
|
|
|
|
ArrayList<InterlockCount> interlockStatusResultList = new ArrayList<>();
|
|
|
- ArrayList<String> lsList = new ArrayList<>();
|
|
|
- lsList.add("0");
|
|
|
- lsList.add("1");
|
|
|
+ //ArrayList<String> lsList = new ArrayList<>();
|
|
|
+ //lsList.add("0");
|
|
|
+ //lsList.add("1");
|
|
|
for (String key:interlockStatusMap.keySet()){
|
|
|
+ InterlockBase base = baseService.getById(key);
|
|
|
+ ArrayList<String> lsList = new ArrayList<>();
|
|
|
+ lsList.add(base.getInterlockStatusTy());
|
|
|
+ lsList.add(inversionStatus(base.getInterlockStatusTy()));
|
|
|
List<InterlockCount> sonList = interlockStatusMap.get(key);
|
|
|
- if (sonList.size() != 4){
|
|
|
+ if (sonList.size() != 2){
|
|
|
ArrayList<String> lsStatusList = new ArrayList<>();
|
|
|
for (InterlockCount son : sonList) {
|
|
|
lsStatusList.add(son.getCountName());
|
|
@@ -165,15 +175,16 @@ public class DayStatisticsJob implements Job {
|
|
|
}
|
|
|
|
|
|
for (String key:tylMap.keySet()) {
|
|
|
+ InterlockBase base = baseService.getById(key);
|
|
|
List<InterlockCount> sonList = tylMap.get(key);
|
|
|
BigDecimal yty = BigDecimal.valueOf(0);
|
|
|
BigDecimal wty = BigDecimal.valueOf(0);
|
|
|
BigDecimal tyl = BigDecimal.valueOf(0);
|
|
|
for (InterlockCount son:sonList) {
|
|
|
- if ("0".equals(son.getCountName())){
|
|
|
+ if (inversionStatus(base.getInterlockStatusTy()).equals(son.getCountName())){
|
|
|
wty = wty.add(new BigDecimal(son.getCountNum()));
|
|
|
}
|
|
|
- if ("1".equals(son.getCountName())){
|
|
|
+ if (base.getInterlockStatusTy().equals(son.getCountName())){
|
|
|
yty = yty.add(new BigDecimal(son.getCountNum()));
|
|
|
}
|
|
|
}
|
|
@@ -197,6 +208,8 @@ public class DayStatisticsJob implements Job {
|
|
|
// 统计仪表状态 count_type = 3
|
|
|
List<InterlockCount> ybStatusList = summaryHistoryService.getYbStatusListByTagTime(yesterday);
|
|
|
|
|
|
+ ArrayList<InterlockCount> ybResultList = new ArrayList<>();
|
|
|
+
|
|
|
HashMap<String, List<InterlockCount>> ybStatusMap = new HashMap<>();
|
|
|
for (InterlockCount item:ybStatusList) {
|
|
|
if (ybStatusMap.containsKey(item.getInterlockSystemId())){
|
|
@@ -209,12 +222,51 @@ public class DayStatisticsJob implements Job {
|
|
|
}
|
|
|
|
|
|
for (String key : ybStatusMap.keySet()) {
|
|
|
+ InterlockBase base = baseService.getById(key);
|
|
|
List<InterlockCount> interlockList = ybStatusMap.get(key);
|
|
|
for (InterlockCount item : interlockList) {
|
|
|
+ int count = 0;
|
|
|
List<InterlockDetailHistory> detailHistoryList = detailHistoryService.getYbStatusListBySummaryIdAndTagTime(item.getId(),yesterday);
|
|
|
- // 遍历集合 查询仪表状态 是否异常 如果有一个异常的 联锁状态为异常
|
|
|
-
|
|
|
+ // 遍历集合 查询仪表状态 是否异常 如果有一个异常的 总的仪表状态为异常
|
|
|
+ for (InterlockDetailHistory detail : detailHistoryList) {
|
|
|
+ if (inversionStatus(base.getInstrumentStatusNormal()).equals(detail.getInstrumentStatus())){
|
|
|
+ count++;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (count != 0){
|
|
|
+ item.setCountNum("1");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ int totalCount1 = 0; // 异常的数量
|
|
|
+ int totalCount2 = 0; // 正常的数量
|
|
|
+ for (InterlockCount item : interlockList) {
|
|
|
+ if ("1".equals(item.getCountNum())){
|
|
|
+ totalCount1++;
|
|
|
+ }else {
|
|
|
+ totalCount2++;
|
|
|
+ }
|
|
|
}
|
|
|
+
|
|
|
+ InterlockCount interlockCount1 = new InterlockCount();
|
|
|
+ interlockCount1.setInterlockSystemId(key);
|
|
|
+ interlockCount1.setInterlockName(interlockList.get(0).getInterlockName());
|
|
|
+ interlockCount1.setCountName(base.getInstrumentStatusNormal());
|
|
|
+ interlockCount1.setCountNum(String.valueOf(totalCount2));
|
|
|
+ interlockCount1.setCountType("3");
|
|
|
+ interlockCount1.setTimeType("10");
|
|
|
+ interlockCount1.setDay(yesterday);
|
|
|
+
|
|
|
+ InterlockCount interlockCount2 = new InterlockCount();
|
|
|
+ interlockCount2.setInterlockSystemId(key);
|
|
|
+ interlockCount2.setInterlockName(interlockList.get(0).getInterlockName());
|
|
|
+ interlockCount2.setCountName(inversionStatus(base.getInstrumentStatusNormal()));
|
|
|
+ interlockCount2.setCountNum(String.valueOf(totalCount1));
|
|
|
+ interlockCount2.setCountType("3");
|
|
|
+ interlockCount2.setTimeType("10");
|
|
|
+ interlockCount2.setDay(yesterday);
|
|
|
+
|
|
|
+ ybResultList.add(interlockCount1);
|
|
|
+ ybResultList.add(interlockCount2);
|
|
|
}
|
|
|
|
|
|
|
|
@@ -225,11 +277,22 @@ public class DayStatisticsJob implements Job {
|
|
|
|
|
|
|
|
|
// 批量保存
|
|
|
- List<InterlockCount> list = Stream.concat(Stream.concat(loopHealthLevelResultList.stream(), interlockStatusResultList.stream()), tylResultList.stream())
|
|
|
+ List<InterlockCount> list = Stream.concat(Stream.concat(loopHealthLevelResultList.stream(), Stream.concat(interlockStatusResultList.stream(),ybResultList.stream())), tylResultList.stream())
|
|
|
.collect(Collectors.toList());
|
|
|
|
|
|
countService.saveBatch(list);
|
|
|
|
|
|
log.info("日统计任务执行成功!");
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * author: dzc
|
|
|
+ * version: 1.0
|
|
|
+ * des: 取反
|
|
|
+ * date: 2024/6/26
|
|
|
+ */
|
|
|
+ private String inversionStatus(String str) {
|
|
|
+ if("0".equals(str)) return "1";
|
|
|
+ else return "0";
|
|
|
+ }
|
|
|
}
|