From dadf90a142175590766a8bfdbc2a5486d707fa43 Mon Sep 17 00:00:00 2001
From: yb <1113799@qq.com>
Date: 星期四, 11 九月 2025 11:19:54 +0800
Subject: [PATCH] 倍率统计报表

---
 lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcEquipmentMagnificationServiceImpl.java |   40 ++++++++++++++++++++++++++++++++++++----
 1 files changed, 36 insertions(+), 4 deletions(-)

diff --git a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcEquipmentMagnificationServiceImpl.java b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcEquipmentMagnificationServiceImpl.java
index 8ce35e0..0debec7 100644
--- a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcEquipmentMagnificationServiceImpl.java
+++ b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcEquipmentMagnificationServiceImpl.java
@@ -8,8 +8,12 @@
 import org.apache.shiro.SecurityUtils;
 import org.jeecg.common.constant.CommonConstant;
 import org.jeecg.common.system.vo.LoginUser;
-import org.jeecg.modules.mdc.dto.*;
-import org.jeecg.modules.mdc.entity.*;
+import org.jeecg.modules.mdc.dto.MdcEquProDto;
+import org.jeecg.modules.mdc.dto.MdcEquipmentMagnificationDto;
+import org.jeecg.modules.mdc.entity.Equipment;
+import org.jeecg.modules.mdc.entity.MdcDriveTypeParamConfig;
+import org.jeecg.modules.mdc.entity.MdcEquipmentMagnification;
+import org.jeecg.modules.mdc.entity.MdcEquipmentRunningSection;
 import org.jeecg.modules.mdc.mapper.MdcEquipmentMagnificationMapper;
 import org.jeecg.modules.mdc.service.*;
 import org.jeecg.modules.mdc.util.DateUtils;
@@ -17,7 +21,6 @@
 import org.jeecg.modules.mdc.vo.MdcMagnificationEquipmentVo;
 import org.jeecg.modules.mdc.vo.MdcMagnificationVo;
 import org.jeecg.modules.system.entity.MdcProduction;
-import org.jeecg.modules.system.entity.SysDepart;
 import org.jeecg.modules.system.service.IMdcProductionService;
 import org.jeecg.modules.system.service.ISysDepartService;
 import org.jeecgframework.poi.excel.def.NormalExcelConstants;
@@ -31,6 +34,7 @@
 import java.math.BigDecimal;
 import java.math.RoundingMode;
 import java.util.*;
+import java.util.stream.Collectors;
 
 @Service
 public class MdcEquipmentMagnificationServiceImpl extends ServiceImpl<MdcEquipmentMagnificationMapper, MdcEquipmentMagnification> implements IMdcEquipmentMagnificationService {
@@ -329,8 +333,35 @@
         avg.setEquipmentName("骞冲潎鍊�");
         avg.setEquipmentType("骞冲潎鍊�");
         //璁$畻骞冲潎鍊�
-        avg.setMdcBeilvVoList(null);
+        avg.setMdcBeilvVoList(calculateOpenAverage(result.getMdcMagnificationVos()));
         result.getMdcMagnificationVos().add(avg);
+        return result;
+    }
+
+    /**
+     * 璁$畻骞冲潎鍊�
+     *
+     * @param mdcMagnificationVos
+     * @return
+     */
+    private List<MdcEquipmentMagnificationDto> calculateOpenAverage(List<MdcMagnificationEquipmentVo> mdcMagnificationVos) {
+        List<MdcEquipmentMagnificationDto> result = new ArrayList<>();
+        List<MdcEquipmentMagnificationDto> dataList = new ArrayList<>();
+        for (MdcMagnificationEquipmentVo mdcMagnificationEquipmentVo : mdcMagnificationVos) {
+            dataList.addAll(mdcMagnificationEquipmentVo.getMdcBeilvVoList());
+        }
+        dataList.parallelStream().collect(Collectors.groupingBy(MdcEquipmentMagnificationDto::getTheDate, Collectors.toList()))
+                .forEach((theDate, mert) -> {
+                    mert.stream().reduce((a, b) -> new MdcEquipmentMagnificationDto(
+                            a.getTheDate(),
+                            a.getFeedbeilv().add(b.getFeedbeilv()),
+                            a.getSpindlebeilv().add(b.getSpindlebeilv()))).ifPresent(result::add);
+                });
+        for (MdcEquipmentMagnificationDto mdcEquipmentMagnificationDto : result) {
+            mdcEquipmentMagnificationDto.setSpindlebeilv(mdcEquipmentMagnificationDto.getSpindlebeilv().divide(new BigDecimal(mdcMagnificationVos.size()), 2, RoundingMode.HALF_UP));
+            mdcEquipmentMagnificationDto.setFeedbeilv(mdcEquipmentMagnificationDto.getFeedbeilv().divide(new BigDecimal(mdcMagnificationVos.size()), 2, RoundingMode.HALF_UP));
+        }
+        result.sort(Comparator.comparing(MdcEquipmentMagnificationDto::getTheDate));
         return result;
     }
 
@@ -342,6 +373,7 @@
                     result.setEquipmentId(equipmentId);
                     result.setSpindlebeilv(mdcEquipmentMagnificationDto.getSpindlebeilv());
                     result.setFeedbeilv(mdcEquipmentMagnificationDto.getFeedbeilv());
+                    result.setTheDate(date);
                 }
             }
         } else {

--
Gitblit v1.9.3