From 39f62fa03a2463652e971edfabab56313db6af10 Mon Sep 17 00:00:00 2001
From: Lius <Lius2225@163.com>
Date: 星期六, 28 六月 2025 10:20:34 +0800
Subject: [PATCH] 涉密->工控

---
 lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcEquipmentRunningSectionServiceImpl.java |  138 ++++-----------------------------------------
 1 files changed, 14 insertions(+), 124 deletions(-)

diff --git a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcEquipmentRunningSectionServiceImpl.java b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcEquipmentRunningSectionServiceImpl.java
index 5db88df..0a0d678 100644
--- a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcEquipmentRunningSectionServiceImpl.java
+++ b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcEquipmentRunningSectionServiceImpl.java
@@ -13,20 +13,15 @@
 import org.jeecg.modules.mdc.service.*;
 import org.jeecg.modules.mdc.util.DateUtils;
 import org.jeecg.modules.mdc.util.TimeFieldUtils;
-import org.jeecg.modules.mdc.vo.EquFaultRecord;
 import org.jeecg.modules.mdc.vo.MdcAlarmAnalyzeQueryVo;
 import org.jeecg.modules.mdc.vo.MdcEquipmentRunningSectionVo;
-import org.jeecg.modules.mdc.vo.TimeInterval;
 import org.jeecg.modules.system.service.ISysDictService;
 import org.springframework.beans.BeanUtils;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
 import javax.annotation.Resource;
-import java.time.LocalDate;
-import java.time.LocalDateTime;
 import java.util.*;
-import java.util.stream.Collectors;
 
 /**
  * @Description: 璁惧杩愯鏃舵鐘舵�佽〃
@@ -69,8 +64,6 @@
         List<MdcEquipmentRunningSection> running = loadEquipmentRunningTrace(equipmentRunningSectionVo.getEquipmentId(), equipmentRunningSectionVo.getCollectTimeStr());
         //鏌ヨ鎶ヨ鏁版嵁
         List<MdcEquipmentRunningSection> errs = loadEquipmentErrorTrace(equipmentRunningSectionVo.getEquipmentId(), equipmentRunningSectionVo.getCollectTimeStr());
-        //鏌ヨ鏁呴殰鏁版嵁
-        List<MdcEquipmentRunningSection> faults = loadEquipmentFaultTrace(equipmentRunningSectionVo.getEquipmentId(), equipmentRunningSectionVo.getCollectTimeStr());
         Equipment equip = equipmentService.getOne(new LambdaQueryWrapper<Equipment>().eq(Equipment::getEquipmentid, equipmentRunningSectionVo.getEquipmentId()));
         if (!running.isEmpty()) {
             MdcEquipmentRunningSectionDto dto;
@@ -107,12 +100,22 @@
                         }
                     }
                 }
+//                Set<TmpEquipmentAlarm> set = entity.getTmpEquipmentAlarmSet();
+//                if (entity.getStatus() == 22 && set != null && !set.isEmpty()) {
+//                    Iterator<TmpEquipmentAlarm> iterator = entity.getTmpEquipmentAlarmSet().iterator();
+//                    //鑾峰彇鎶ヨ缂栧彿鐩稿悓鐨勬姤璀︿俊鎭�
+//                    while (iterator.hasNext()) {
+//                        TmpEquipmentAlarm next = iterator.next();
+//                        if (StringUtils.isNotBlank(next.getAlarmNo()) && next.getAlarmNo().equals(entity.getStatus())) {
+//                            dto.setAlarmContent(next.getAlarmContent());
+//                        }
+//                    }
+//                }
                 dtos.add(dto);
             }
         }
 
         List<MdcEquipmentRunningSectionDto> result = new ArrayList<>();
-
         //鍚堝苟鐩稿悓鐘舵�佹暟鎹�
         for (int i = 0; i < dtos.size() - 1; i++) {
             MdcEquipmentRunningSectionDto mdcEquipmentRunningSectionDto = dtos.get(i);
@@ -138,105 +141,7 @@
             result.addAll(dtos);
         }
 
-        if (faults != null && !faults.isEmpty()) {
-            MdcEquipmentRunningSectionDto dto;
-            for (MdcEquipmentRunningSection entity : faults) {
-                dto = new MdcEquipmentRunningSectionDto();
-                BeanUtils.copyProperties(entity, dto);
-                result.add(dto);
-            }
-        }
-
         return result;
-    }
-
-    private List<MdcEquipmentRunningSection> loadEquipmentFaultTrace(String equipmentId, String collectTimeStr) {
-        List<MdcEquipmentRunningSection> result = new ArrayList<>();
-        Date startTime = DateUtils.getShortDate(collectTimeStr);
-        Date now = DateUtils.removeTime(DateUtils.getNow());
-        long second = DateUtils.differentSecond(startTime, now);
-        Date endTime = DateUtils.plusTime(startTime, 1);
-        if (collectTimeStr.equals(LocalDate.now().toString())) {
-            endTime = DateUtils.getNow();
-        }
-        if (second < 0) {
-            return Collections.emptyList();
-        } else {
-            List<EquFaultRecord> equFaultRecordList = this.baseMapper.findFaultList(equipmentId, startTime, endTime);
-            if (equFaultRecordList != null && !equFaultRecordList.isEmpty()) {
-
-                // 淇璁板綍鏃堕棿
-                List<EquFaultRecord> correctedRecords = correctRecordTimes(equFaultRecordList, DateUtils.convertToLocalDateTime(startTime), DateUtils.convertToLocalDateTime(endTime));
-
-                // 鎸夊紑濮嬫椂闂存帓搴�
-                correctedRecords.sort(Comparator.comparing(EquFaultRecord::getStartTime));
-
-                // 鍚堝苟閲嶅彔鏃堕棿娈�
-                List<TimeInterval> mergedIntervals = mergeIntervals(correctedRecords);
-
-                for (TimeInterval mergedInterval : mergedIntervals) {
-                    MdcEquipmentRunningSection mdcEquipmentRunningSection = new MdcEquipmentRunningSection(25, equipmentId, DateUtils.convertToDate(mergedInterval.getStart()), DateUtils.convertToDate(mergedInterval.getEnd()), DateUtils.convertToDate(mergedInterval.getStart()).getTime(), DateUtils.convertToDate(mergedInterval.getEnd()).getTime());
-                    mdcEquipmentRunningSection.setDuration(DateUtils.differentSecond(mdcEquipmentRunningSection.getStartTime(), mdcEquipmentRunningSection.getEndTime()));
-                    result.add(mdcEquipmentRunningSection);
-                }
-            }
-        }
-        return result;
-    }
-
-    private static List<EquFaultRecord> correctRecordTimes(List<EquFaultRecord> records, LocalDateTime startTime, LocalDateTime endTime) {
-        return records.stream()
-                .map(record -> {
-                    LocalDateTime recordStart = DateUtils.convertToLocalDateTime(record.getStartTime());
-                    LocalDateTime recordEnd = record.getEndTime() != null ?
-                            DateUtils.convertToLocalDateTime(record.getEndTime()) : null;
-
-                    // 淇寮�濮嬫椂闂�
-                    LocalDateTime correctedStart = recordStart.isBefore(startTime) ?
-                            startTime : recordStart;
-
-                    // 淇缁撴潫鏃堕棿
-                    LocalDateTime correctedEnd = recordEnd == null || recordEnd.isAfter(endTime) ?
-                            endTime : recordEnd;
-
-                    // 鍒涘缓淇鍚庣殑璁板綍
-                    return new EquFaultRecord(
-                            record.getEquipmentId(),
-                            DateUtils.convertToDate(correctedStart),
-                            DateUtils.convertToDate(correctedEnd)
-                    );
-                })
-                .collect(Collectors.toList());
-    }
-
-    private static List<TimeInterval> mergeIntervals(List<EquFaultRecord> records) {
-        List<TimeInterval> intervals = records.stream()
-                .map(record -> new TimeInterval(
-                        DateUtils.convertToLocalDateTime(record.getStartTime()),
-                        DateUtils.convertToLocalDateTime(record.getEndTime())))
-                .collect(Collectors.toList());
-
-        if (intervals.isEmpty()) {
-            return Collections.emptyList();
-        }
-
-        List<TimeInterval> merged = new ArrayList<>();
-        TimeInterval current = intervals.get(0);
-
-        for (int i = 1; i < intervals.size(); i++) {
-            TimeInterval next = intervals.get(i);
-            if (next.getStart().isBefore(current.getEnd()) || next.getStart().equals(current.getEnd())) {
-                // 鏈夐噸鍙狅紝鍚堝苟鍖洪棿
-                current.setEnd(current.getEnd().isAfter(next.getEnd()) ? current.getEnd() : next.getEnd());
-            } else {
-                // 鏃犻噸鍙狅紝娣诲姞褰撳墠鍖洪棿骞舵洿鏂板綋鍓嶅尯闂�
-                merged.add(current);
-                current = next;
-            }
-        }
-        merged.add(current); // 娣诲姞鏈�鍚庝竴涓尯闂�
-
-        return merged;
     }
 
     /**
@@ -615,9 +520,9 @@
             //鑾峰彇running杩愯鐨勬棩蹇楄褰�
             List<MdcEquipmentRunningSection> list = this.equipmentRunningTracesLog(equipment.getEquipmentid());
             if (list != null && !list.isEmpty()) {
-//                List<MdcEquipmentRunningSection> equipList = addSequenceNumber(list); //娣诲姞绋嬪簭鍙�
-                this.ergodicTrim(list);
-                super.saveBatch(list);
+                List<MdcEquipmentRunningSection> equipList = addSequenceNumber(list); //娣诲姞绋嬪簭鍙�
+                this.ergodicTrim(equipList);
+                super.saveBatch(equipList);
             }
             //鑾峰彇鎶ヨ鐨勬棩蹇楄褰�
             List<MdcEquipmentRunningSection> errorList = this.equipmentRunningTracesErrorLog(equipment.getEquipmentid());
@@ -850,13 +755,10 @@
         Map<String, List<MdcEquipmentRunningSectionDto>> map = new HashMap<>();
         List<MdcEquipmentRunningSectionDto> normal = new ArrayList<>();
         List<MdcEquipmentRunningSectionDto> waring = new ArrayList<>();
-        List<MdcEquipmentRunningSectionDto> fault = new ArrayList<>();
         //杩愯
         List<MdcEquipmentRunningSection> running = loadEquipmentRunningTrace(equipmentRunningSectionVo.getEquipmentId(), date);
         //鎶ヨ
         List<MdcEquipmentRunningSection> errs = loadEquipmentErrorTrace(equipmentRunningSectionVo.getEquipmentId(), date);
-        //鏁呴殰
-        List<MdcEquipmentRunningSection> faults = loadEquipmentFaultTrace(equipmentRunningSectionVo.getEquipmentId(), date);
 
         if (running != null && !running.isEmpty()) {
             MdcEquipmentRunningSectionDto dto;
@@ -880,20 +782,8 @@
             map.put("waring", null);
         }
 
-        if (!faults.isEmpty()) {
-            MdcEquipmentRunningSectionDto dto;
-            for (MdcEquipmentRunningSection mdcEquipmentRunningSection : faults) {
-                dto = new MdcEquipmentRunningSectionDto();
-                BeanUtils.copyProperties(mdcEquipmentRunningSection, dto);
-                fault.add(dto);
-            }
-        } else {
-            map.put("fault", null);
-        }
-
         map.put("normal", normal);
         map.put("waring", waring);
-        map.put("fault", fault);
 
         return map;
     }

--
Gitblit v1.9.3