From 2b9ff0c274a847af41b2f5a04de1b23ed6fbb9bb Mon Sep 17 00:00:00 2001
From: Lius <Lius2225@163.com>
Date: 星期一, 25 八月 2025 15:50:15 +0800
Subject: [PATCH] mdc模块更新

---
 lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcEquipmentStatisticalShiftInfoServiceImpl.java |  220 ++++++++++++++-----------------------------------------
 1 files changed, 56 insertions(+), 164 deletions(-)

diff --git a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcEquipmentStatisticalShiftInfoServiceImpl.java b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcEquipmentStatisticalShiftInfoServiceImpl.java
index 938b7a9..95fdf49 100644
--- a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcEquipmentStatisticalShiftInfoServiceImpl.java
+++ b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcEquipmentStatisticalShiftInfoServiceImpl.java
@@ -4,7 +4,6 @@
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import org.apache.commons.lang.StringUtils;
 import org.jeecg.modules.mdc.entity.Equipment;
-import org.jeecg.modules.mdc.entity.MdcEquipmentRepair;
 import org.jeecg.modules.mdc.entity.MdcEquipmentRunningSection;
 import org.jeecg.modules.mdc.entity.MdcEquipmentStatisticalShiftInfo;
 import org.jeecg.modules.mdc.mapper.MdcEquipmentStatisticalShiftInfoMapper;
@@ -18,7 +17,6 @@
 
 import javax.annotation.Resource;
 import java.math.BigDecimal;
-import java.math.RoundingMode;
 import java.text.ParseException;
 import java.text.SimpleDateFormat;
 import java.util.*;
@@ -40,9 +38,6 @@
 
     @Resource
     private IMdcDeviceCalendarService mdcDeviceCalendarService;
-
-    @Resource
-    private IMdcEquipmentRepairService mdcEquipmentRepairService;
 
     /**
      * 璁$畻璁惧鍗曟棩鐝杩愯鏁版嵁
@@ -75,25 +70,6 @@
         }
     }
 
-    /**
-     * 鏌ヨ涓昏酱杩愯鏃堕棿
-     *
-     * @param equipmentId
-     * @param validDate
-     * @return
-     */
-    @Override
-    public BigDecimal findSpindleRunDuration(String equipmentId, String validDate) {
-        validDate = validDate.replaceAll("-", "");
-        BigDecimal duration = this.baseMapper.findSpindleRunDuration(equipmentId, validDate);
-        if (duration != null && duration.compareTo(BigDecimal.ZERO) != 0) {
-            return duration.divide(new BigDecimal("60"), 0, RoundingMode.HALF_UP);
-        } else {
-            return new BigDecimal("0");
-        }
-    }
-
-    @Transactional(readOnly = true)
     List<MdcEquipmentStatisticalShiftInfo> equipmentShiftStatisticalProcess(Equipment equipment, String dateTime) {
         Date initDate = null;
         //鍙栨渶鍚庣殑缁熻鏁版嵁
@@ -175,96 +151,16 @@
      * 鏌ヨ鏌愪竴澶╂煇涓彮娆$殑鏁版嵁
      *
      * @param dates
-     * @param equipmentid
+     * @param equipmentId
      * @return
      */
-    private MdcEquipmentStatisticalShiftInfo selectRunningEquipment(MdcShiftDateVo dates, String equipmentid) {
-        if (dates == null || StringUtils.isBlank(equipmentid)) {
+    private MdcEquipmentStatisticalShiftInfo selectRunningEquipment(MdcShiftDateVo dates, String equipmentId) {
+        if (dates == null || StringUtils.isBlank(equipmentId)) {
             return null;
         }
-        //鏌ヨ鏄惁闇�瑕佺淮淇殑璁惧
-        List<MdcEquipmentRepair> repairs = mdcEquipmentRepairService.mdcRepairListDate(equipmentid, dates.getStartDate(), dates.getEndDate());
-        //鍒跺害鏃堕棿娈靛唴鐨勪紤鐝拰缁翠慨鏃堕棿娈电瓫閫�
-        List<MdcEquipmentRepair> repairList = this.findSubRepairs(repairs, dates);
         List<MdcDateVo> dateList = new ArrayList<>();
-        if (repairList == null || repairList.isEmpty()) {
             //鍒跺害鏃堕棿娈靛唴娌℃湁缁翠慨鍜屼紤鐝椂闂存
-            MdcEquipmentStatisticalShiftInfo shiftInfo = mdcRateEquipment(equipmentid, dates.getStartDate(), dates.getEndDate());
-            return shiftInfo;
-        } else {
-            if (repairList.size() == 1) {
-                long start = repairList.get(0).getStartTime().getTime();
-                long end = repairList.get(0).getEndTime().getTime();
-                if (start > dates.getStart() && end < dates.getEnd()) {
-                    MdcDateVo d1 = new MdcDateVo();
-                    d1.setStartTime(dates.getStartDate());
-                    d1.setEndTime(repairList.get(0).getStartTime());
-                    dateList.add(d1);
-                    MdcDateVo d2 = new MdcDateVo();
-                    d2.setStartTime(repairList.get(0).getEndTime());
-                    d2.setEndTime(dates.getEndDate());
-                    dateList.add(d2);
-                } else if (start == dates.getStart() && end < dates.getEnd()) {
-                    MdcDateVo d2 = new MdcDateVo();
-                    d2.setStartTime(repairList.get(0).getEndTime());
-                    d2.setEndTime(dates.getEndDate());
-                    dateList.add(d2);
-                } else if (start > dates.getStart() && end == dates.getEnd()) {
-                    MdcDateVo d1 = new MdcDateVo();
-                    d1.setStartTime(dates.getStartDate());
-                    d1.setEndTime(repairList.get(0).getStartTime());
-                    dateList.add(d1);
-                } else {
-                    //浼戠彮
-                    MdcEquipmentStatisticalShiftInfo vo = new MdcEquipmentStatisticalShiftInfo();
-                    vo.setTotalLong(BigDecimal.ZERO);
-                    vo.setErrorLong(BigDecimal.ZERO);
-                    vo.setProcessLong(BigDecimal.ZERO);
-                    vo.setWaitLong(BigDecimal.ZERO);
-                    vo.setCloseLong(BigDecimal.ZERO);
-                    vo.setOpenLong(BigDecimal.ZERO);
-                    return vo;
-                }
-            } else {
-                long s = dates.getStartDate().getTime();
-                for (int i = 0; i < repairList.size(); i++) {
-                    long start = repairList.get(i).getStartTime().getTime();
-                    long end = repairList.get(i).getEndTime().getTime();
-
-                    if (start > s) {
-                        MdcDateVo d = new MdcDateVo();
-                        d.setStartTime(dates.getStartDate());
-                        d.setEndTime(repairList.get(i).getStartTime());
-                        if (d.getEndTime().getTime() != d.getStartTime().getTime()) {
-                            dateList.add(d);
-                        }
-                        dates.setStartDate(repairList.get(i).getEndTime());
-                    } else if (start == s) {
-                        dates.setStartDate(repairList.get(i).getEndTime());
-                    }
-                    if (i == repairList.size() - 1) {
-                        if (dates.getStartDate().getTime() >= end) {
-                            MdcDateVo d = new MdcDateVo();
-                            d.setStartTime(repairList.get(i).getEndTime());
-                            d.setEndTime(dates.getEndDate());
-                            if (d.getEndTime().getTime() != d.getStartTime().getTime()) {
-                                dateList.add(d);
-                            }
-                        }
-                    }
-                }
-            }
-        }
-        MdcEquipmentStatisticalShiftInfo shiftInfo = new MdcEquipmentStatisticalShiftInfo();
-        for (MdcDateVo date : dateList) {
-            MdcEquipmentStatisticalShiftInfo v = mdcRateEquipment(equipmentid, date.getStartTime(), date.getEndTime());
-            shiftInfo.setTotalLong(v.getTotalLong().add(shiftInfo.getTotalLong()));
-            shiftInfo.setOpenLong(v.getOpenLong().add(shiftInfo.getOpenLong()));
-            shiftInfo.setCloseLong(v.getCloseLong().add(shiftInfo.getCloseLong()));
-            shiftInfo.setWaitLong(v.getWaitLong().add(shiftInfo.getWaitLong()));
-            shiftInfo.setProcessLong(v.getProcessLong().add(shiftInfo.getProcessLong()));
-            shiftInfo.setErrorLong(v.getErrorLong().add(shiftInfo.getErrorLong()));
-        }
+        MdcEquipmentStatisticalShiftInfo shiftInfo = mdcRateEquipment(equipmentId, dates.getStartDate(), dates.getEndDate());
         return shiftInfo;
     }
 
@@ -287,7 +183,7 @@
         //sectionErrors = filterSectionErrors(equipmentId, sectionErrors);
         MdcEquipmentStatisticalShiftInfo shiftInfo = new MdcEquipmentStatisticalShiftInfo();
         BigDecimal totalLongRairs = new BigDecimal("0");
-        List<MdcEquipmentRunningSection> sectionList = findStatsEquipment(null, runningSections, date, sectionErrors);
+        List<MdcEquipmentRunningSection> sectionList = findStatsEquipment(runningSections, date, sectionErrors);
         if (sectionList == null || sectionList.isEmpty()) {
             shiftInfo.setEquipmentId(equipmentid);
             return shiftInfo;
@@ -394,10 +290,9 @@
         return processLong;
     }
 
-    private List<MdcEquipmentRunningSection> findStatsEquipment(List<MdcEquipmentRepair> repairs, List<MdcEquipmentRunningSection> sRun, MdcDateVo mdcDate, List<MdcEquipmentRunningSection> errors) {
+    private List<MdcEquipmentRunningSection> findStatsEquipment(List<MdcEquipmentRunningSection> sRun, MdcDateVo mdcDate, List<MdcEquipmentRunningSection> errors) {
         if (sRun == null || sRun.isEmpty()) {
             //鏃犳暟鎹鐞�
-            //TODO
             return null;
         }
         Long startMdc = mdcDate.getStartTime().getTime();
@@ -501,9 +396,6 @@
                                 errors.get(i).setEndTime(se.getStartTime());
                                 Long sen = DateUtils.differentSecond(errors.get(i).getStartTime(),
                                         errors.get(i).getEndTime());
-                                //
-
-                                //TODO
                                 errOne.setStatus(22);
                                 errOne.setEquipmentId(errors.get(i).getEquipmentId());
                                 errOne.setStartTime(se.getEndTime());
@@ -547,56 +439,56 @@
         }
         return sectionList;
     }
-
-    private List<MdcEquipmentRepair> findSubRepairs(List<MdcEquipmentRepair> repairs, MdcShiftDateVo dates) {
-        if (repairs == null || repairs.isEmpty() || dates == null) {
-            return null;
-        }
-        for (MdcEquipmentRepair repair : repairs) {
-            //璋冩暣
-            Date start = null;
-            Date end = null;
-            long dStart = dates.getStartDate().getTime();
-            long dEnd = dates.getEndDate().getTime();
-            long rStart = repair.getStartTime().getTime();
-            long rEnd = repair.getEndTime().getTime();
-
-            if (rStart <= dStart && rEnd >= dStart && rEnd <= dEnd) {
-                start = dates.getStartDate();
-                end = repair.getEndTime();
-            } else if (rStart >= dStart && rEnd <= dEnd) {
-                start = repair.getStartTime();
-                end = repair.getEndTime();
-            } else if (rStart >= dStart && rStart <= dEnd && rEnd >= dEnd) {
-                start = repair.getStartTime();
-                end = dates.getEndDate();
-            } else if (rStart <= dStart && rEnd >= dEnd) {
-                start = dates.getStartDate();
-                end = dates.getEndDate();
-            }
-            repair.setStartTime(start);
-            repair.setEndTime(end);
-            //澶勭悊寮傚父鏁版嵁
-            if (start == null || end == null) {
-                repair.setSecondLong(0);
-            } else {
-                try {
-                    repair.setSecondLong(DateUtils.getSeconds(start, end));
-                } catch (Exception e) {
-                    repair.setSecondLong(0);
-                }
-
-            }
-
-        }
-        for (int i = 0; i < repairs.size(); i++) {
-            if (repairs.get(i).getStartTime() == null || repairs.get(i).getEndTime() == null || repairs.get(i).getSecondLong() == 0) {
-                repairs.remove(i);
-                i--;
-            }
-        }
-        return repairs;
-    }
+//
+//    private List<MdcEquipmentRepair> findSubRepairs(List<MdcEquipmentRepair> repairs, MdcShiftDateVo dates) {
+//        if (repairs == null || repairs.isEmpty() || dates == null) {
+//            return null;
+//        }
+//        for (MdcEquipmentRepair repair : repairs) {
+//            //璋冩暣
+//            Date start = null;
+//            Date end = null;
+//            long dStart = dates.getStartDate().getTime();
+//            long dEnd = dates.getEndDate().getTime();
+//            long rStart = repair.getStartTime().getTime();
+//            long rEnd = repair.getEndTime().getTime();
+//
+//            if (rStart <= dStart && rEnd >= dStart && rEnd <= dEnd) {
+//                start = dates.getStartDate();
+//                end = repair.getEndTime();
+//            } else if (rStart >= dStart && rEnd <= dEnd) {
+//                start = repair.getStartTime();
+//                end = repair.getEndTime();
+//            } else if (rStart >= dStart && rStart <= dEnd && rEnd >= dEnd) {
+//                start = repair.getStartTime();
+//                end = dates.getEndDate();
+//            } else if (rStart <= dStart && rEnd >= dEnd) {
+//                start = dates.getStartDate();
+//                end = dates.getEndDate();
+//            }
+//            repair.setStartTime(start);
+//            repair.setEndTime(end);
+//            //澶勭悊寮傚父鏁版嵁
+//            if (start == null || end == null) {
+//                repair.setSecondLong(0);
+//            } else {
+//                try {
+//                    repair.setSecondLong(DateUtils.getSeconds(start, end));
+//                } catch (Exception e) {
+//                    repair.setSecondLong(0);
+//                }
+//
+//            }
+//
+//        }
+//        for (int i = 0; i < repairs.size(); i++) {
+//            if (repairs.get(i).getStartTime() == null || repairs.get(i).getEndTime() == null || repairs.get(i).getSecondLong() == 0) {
+//                repairs.remove(i);
+//                i--;
+//            }
+//        }
+//        return repairs;
+//    }
 
     /**
      * 鏃堕棿闂澶勭悊 濡傛灉褰撳ぉ鏈�鏈熬鏃堕棿澶т簬褰撳墠鏃堕棿 杩斿洖0

--
Gitblit v1.9.3