From 4337640b7ab86136baed2fd6aa959e4828a75cea Mon Sep 17 00:00:00 2001
From: Lius <Lius2225@163.com>
Date: 星期四, 07 十二月 2023 17:33:51 +0800
Subject: [PATCH] 计算加工工件个数算法和密码安全策略

---
 lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcEfficiencyReportServiceImpl.java |  118 ++++++++++++++++++++++++++++++++++++----------------------
 1 files changed, 73 insertions(+), 45 deletions(-)

diff --git a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcEfficiencyReportServiceImpl.java b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcEfficiencyReportServiceImpl.java
index 143d28d..94e7a96 100644
--- a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcEfficiencyReportServiceImpl.java
+++ b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcEfficiencyReportServiceImpl.java
@@ -1,9 +1,7 @@
 package org.jeecg.modules.mdc.service.impl;
 
-import com.alipay.api.domain.NewsfeedMediaGiftInfo;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import org.apache.commons.lang3.StringUtils;
-import org.checkerframework.checker.units.qual.A;
 import org.jeecg.common.constant.CommonConstant;
 import org.jeecg.common.exception.JeecgBootException;
 import org.jeecg.modules.mdc.dto.*;
@@ -11,8 +9,8 @@
 import org.jeecg.modules.mdc.mapper.MdcEfficiencyReportMapper;
 import org.jeecg.modules.mdc.service.*;
 import org.jeecg.modules.mdc.util.DateUtils;
-import org.jeecg.modules.mdc.vo.*;
 import org.jeecg.modules.mdc.vo.MdcUtilizationRateDto;
+import org.jeecg.modules.mdc.vo.*;
 import org.jeecg.modules.system.entity.MdcProduction;
 import org.jeecg.modules.system.entity.SysDepart;
 import org.jeecg.modules.system.service.IMdcProductionService;
@@ -21,8 +19,6 @@
 
 import javax.annotation.Resource;
 import java.math.BigDecimal;
-import java.text.ParseException;
-import java.text.SimpleDateFormat;
 import java.time.LocalDate;
 import java.time.format.DateTimeFormatter;
 import java.time.temporal.ChronoUnit;
@@ -100,6 +96,15 @@
         if (vo.getEquipmentIdList() == null || vo.getEquipmentIdList().isEmpty()) {
             result.setMdcEfficiencyList(listDtos);
         } else {
+            if (StringUtils.isNotEmpty(vo.getEquipmentType())) {
+                List<String> equipmentList = mdcEquipmentService.listEquipmentId(vo.getEquipmentType(), vo.getEquipmentIdList());
+                if (equipmentList != null && !equipmentList.isEmpty()) {
+                    vo.setEquipmentIdList(equipmentList);
+                } else {
+                    result.setMdcEfficiencyList(listDtos);
+                    return result;
+                }
+            }
             // 鏌ヨ鍒╃敤鐜囨暟鎹�
             List<MdcEfficiencyDto> efficiencyList = mdcEfficiencyReportMapper.efficiencyList(vo);
             // 鍒╃敤鐜囩瓑绾�
@@ -110,7 +115,7 @@
                 // 閮ㄩ棬灞傜骇
                 List<MdcEquDepDto> equipmentList = mdcEquipmentService.findEquDepList(vo.getEquipmentIdList());
                 // 鏌ヨ鎵�鏈夐儴闂ㄤ俊鎭�
-                List<SysDepart> departList = sysDepartService.list(new LambdaQueryWrapper<SysDepart>().ne(SysDepart::getDelFlag, CommonConstant.DEL_FLAG_1.toString()));
+                List<SysDepart> departList = sysDepartService.list(new LambdaQueryWrapper<SysDepart>().ne(SysDepart::getDelFlag, CommonConstant.DEL_FLAG_1.toString()).orderByAsc(SysDepart::getDepartOrder));
 
                 for (MdcEquDepDto mdcEquDepDto : equipmentList) {
                     MdcEfficiencyListDto mdcEfficiencyListDto = new MdcEfficiencyListDto();
@@ -172,7 +177,7 @@
                 // 浜х嚎灞傜骇
                 List<MdcEquProDto> equipmentList = mdcEquipmentService.findEquProList(vo.getEquipmentIdList());
                 // 鏌ヨ鎵�鏈変骇绾夸俊鎭�
-                List<MdcProduction> productionList = mdcProductionService.list(new LambdaQueryWrapper<MdcProduction>().ne(MdcProduction::getDelFlag, CommonConstant.DEL_FLAG_1.toString()));
+                List<MdcProduction> productionList = mdcProductionService.list(new LambdaQueryWrapper<MdcProduction>().ne(MdcProduction::getDelFlag, CommonConstant.DEL_FLAG_1.toString()).orderByAsc(MdcProduction::getProductionOrder));
 
                 for (MdcEquProDto mdcEquProDto : equipmentList) {
                     MdcEfficiencyListDto mdcEfficiencyListDto = new MdcEfficiencyListDto();
@@ -230,7 +235,7 @@
                     listDtos.add(mdcEfficiencyListDto);
                 }
             }
-
+            //listDtos.sort(((o1, o2) -> Collator.getInstance(Locale.TRADITIONAL_CHINESE).compare(o1.getLevel3(), o2.getLevel3())));
             result.setMdcEfficiencyList(listDtos);
         }
 
@@ -280,6 +285,15 @@
         if (vo.getEquipmentIdList() == null || vo.getEquipmentIdList().isEmpty()) {
             result.setMdcEfficiencyList(listDtos);
         } else {
+            if (StringUtils.isNotEmpty(vo.getEquipmentType())) {
+                List<String> equipmentList = mdcEquipmentService.listEquipmentId(vo.getEquipmentType(), vo.getEquipmentIdList());
+                if (equipmentList != null && !equipmentList.isEmpty()) {
+                    vo.setEquipmentIdList(equipmentList);
+                } else {
+                    result.setMdcEfficiencyList(listDtos);
+                    return result;
+                }
+            }
             // 鏌ヨ鍒╃敤鐜囨暟鎹�
             List<MdcEfficiencyDto> efficiencyList = mdcEfficiencyReportMapper.efficiencyPOList(vo);
             // 鍒╃敤鐜囩瓑绾�
@@ -290,7 +304,7 @@
                 // 閮ㄩ棬灞傜骇
                 List<MdcEquDepDto> equipmentList = mdcEquipmentService.findEquDepList(vo.getEquipmentIdList());
                 // 鏌ヨ鎵�鏈夐儴闂ㄤ俊鎭�
-                List<SysDepart> departList = sysDepartService.list(new LambdaQueryWrapper<SysDepart>().ne(SysDepart::getDelFlag, CommonConstant.DEL_FLAG_1.toString()));
+                List<SysDepart> departList = sysDepartService.list(new LambdaQueryWrapper<SysDepart>().ne(SysDepart::getDelFlag, CommonConstant.DEL_FLAG_1.toString()).orderByAsc(SysDepart::getDepartOrder));
 
                 for (MdcEquDepDto mdcEquDepDto : equipmentList) {
                     MdcEfficiencyListDto mdcEfficiencyListDto = new MdcEfficiencyListDto();
@@ -352,7 +366,7 @@
                 // 浜х嚎灞傜骇
                 List<MdcEquProDto> equipmentList = mdcEquipmentService.findEquProList(vo.getEquipmentIdList());
                 // 鏌ヨ鎵�鏈変骇绾夸俊鎭�
-                List<MdcProduction> productionList = mdcProductionService.list(new LambdaQueryWrapper<MdcProduction>().ne(MdcProduction::getDelFlag, CommonConstant.DEL_FLAG_1.toString()));
+                List<MdcProduction> productionList = mdcProductionService.list(new LambdaQueryWrapper<MdcProduction>().ne(MdcProduction::getDelFlag, CommonConstant.DEL_FLAG_1.toString()).orderByAsc(MdcProduction::getProductionOrder));
 
                 for (MdcEquProDto mdcEquProDto : equipmentList) {
                     MdcEfficiencyListDto mdcEfficiencyListDto = new MdcEfficiencyListDto();
@@ -410,7 +424,7 @@
                     listDtos.add(mdcEfficiencyListDto);
                 }
             }
-
+//            listDtos.sort(((o1, o2) -> Collator.getInstance(Locale.TRADITIONAL_CHINESE).compare(o1.getLevel3(), o2.getLevel3())));
             result.setMdcEfficiencyList(listDtos);
         }
 
@@ -460,6 +474,15 @@
         if (vo.getEquipmentIdList() == null || vo.getEquipmentIdList().isEmpty()) {
             result.setMdcEfficiencyList(listDtos);
         } else {
+            if (StringUtils.isNotEmpty(vo.getEquipmentType())) {
+                List<String> equipmentList = mdcEquipmentService.listEquipmentId(vo.getEquipmentType(), vo.getEquipmentIdList());
+                if (equipmentList != null && !equipmentList.isEmpty()) {
+                    vo.setEquipmentIdList(equipmentList);
+                } else {
+                    result.setMdcEfficiencyList(listDtos);
+                    return result;
+                }
+            }
             // 鐝鍒╃敤鐜囩瓑绾�
             List<MdcUtilizationRate> mdcUtilizationRateList = mdcUtilizationRateService.listByType("bclyl");
             // 鐝鍒╃敤鐜囨暟鎹�
@@ -470,7 +493,7 @@
                 // 閮ㄩ棬灞傜骇
                 List<MdcEquDepDto> equipmentList = mdcEquipmentService.findEquDepList(vo.getEquipmentIdList());
                 // 鏌ヨ鎵�鏈夐儴闂ㄤ俊鎭�
-                List<SysDepart> departList = sysDepartService.list(new LambdaQueryWrapper<SysDepart>().ne(SysDepart::getDelFlag, CommonConstant.DEL_FLAG_1.toString()));
+                List<SysDepart> departList = sysDepartService.list(new LambdaQueryWrapper<SysDepart>().ne(SysDepart::getDelFlag, CommonConstant.DEL_FLAG_1.toString()).orderByAsc(SysDepart::getDepartOrder));
                 // 鐝鍚嶇О鏄剧ず澶勭悊
                 String shiftSubName = "";
                 if (StringUtils.isBlank(vo.getShiftId())) {
@@ -553,7 +576,7 @@
                 // 浜х嚎灞傜骇
                 List<MdcEquProDto> equipmentList = mdcEquipmentService.findEquProList(vo.getEquipmentIdList());
                 // 鏌ヨ鎵�鏈変骇绾夸俊鎭�
-                List<MdcProduction> productionList = mdcProductionService.list(new LambdaQueryWrapper<MdcProduction>().ne(MdcProduction::getDelFlag, CommonConstant.DEL_FLAG_1.toString()));
+                List<MdcProduction> productionList = mdcProductionService.list(new LambdaQueryWrapper<MdcProduction>().ne(MdcProduction::getDelFlag, CommonConstant.DEL_FLAG_1.toString()).orderByAsc(MdcProduction::getProductionOrder));
 
                 // 鐝鍚嶇О鏄剧ず澶勭悊
                 String shiftSubName = "";
@@ -633,6 +656,7 @@
                     listDtos.add(mdcEfficiencyShiftListDto);
                 }
             }
+//            listDtos.sort(((o1, o2) -> Collator.getInstance(Locale.TRADITIONAL_CHINESE).compare(o1.getLevel3(), o2.getLevel3())));
             result.setMdcEfficiencyList(listDtos);
         }
         return result;
@@ -657,23 +681,24 @@
                             mdcEfficiencyShiftResultDto.setColor(mdcUtilizationRate.getRateParameterColor());
                         }
                     }
-                } else {
-                    mdcEfficiencyShiftResultDto.setTheDate(date);
-                    mdcEfficiencyShiftResultDto.setProcessLong(new BigDecimal("0"));
-                    mdcEfficiencyShiftResultDto.setUtilizationRate(new BigDecimal("0"));
-                    mdcEfficiencyShiftResultDto.setStartRate(new BigDecimal("0"));
-                    mdcEfficiencyShiftResultDto.setOpenRate(new BigDecimal("0"));
-                    mdcEfficiencyShiftResultDto.setOpenLong(new BigDecimal("0"));
-                    mdcEfficiencyShiftResultDto.setWaitLong(new BigDecimal("0"));
-                    mdcEfficiencyShiftResultDto.setCloseLong(new BigDecimal("0"));
-                    for (MdcUtilizationRate mdcUtilizationRate : mdcUtilizationRateList) {
-                        if (0 >= mdcUtilizationRate.getMinimumRange() && 0 < mdcUtilizationRate.getMaximumRange()) {
-                            mdcEfficiencyShiftResultDto.setColor(mdcUtilizationRate.getRateParameterColor());
-                        }
-                    }
                 }
             }
         } else {
+            mdcEfficiencyShiftResultDto.setTheDate(date);
+            mdcEfficiencyShiftResultDto.setProcessLong(new BigDecimal("0"));
+            mdcEfficiencyShiftResultDto.setUtilizationRate(new BigDecimal("0"));
+            mdcEfficiencyShiftResultDto.setStartRate(new BigDecimal("0"));
+            mdcEfficiencyShiftResultDto.setOpenRate(new BigDecimal("0"));
+            mdcEfficiencyShiftResultDto.setOpenLong(new BigDecimal("0"));
+            mdcEfficiencyShiftResultDto.setWaitLong(new BigDecimal("0"));
+            mdcEfficiencyShiftResultDto.setCloseLong(new BigDecimal("0"));
+            for (MdcUtilizationRate mdcUtilizationRate : mdcUtilizationRateList) {
+                if (0 >= mdcUtilizationRate.getMinimumRange() && 0 < mdcUtilizationRate.getMaximumRange()) {
+                    mdcEfficiencyShiftResultDto.setColor(mdcUtilizationRate.getRateParameterColor());
+                }
+            }
+        }
+        if (StringUtils.isBlank(mdcEfficiencyShiftResultDto.getColor())) {
             mdcEfficiencyShiftResultDto.setTheDate(date);
             mdcEfficiencyShiftResultDto.setProcessLong(new BigDecimal("0"));
             mdcEfficiencyShiftResultDto.setUtilizationRate(new BigDecimal("0"));
@@ -768,10 +793,10 @@
         }
         result = this.efficiencyStatisticalRate(efficiencyList);
         if (result.getOpenRate().compareTo(new BigDecimal("0")) > 0) {
-            result.setOpenRate(result.getOpenRate().multiply(new BigDecimal("100")).divide(new BigDecimal(equipmentIds.size()), 2, BigDecimal.ROUND_HALF_UP));
+            result.setOpenRate(result.getOpenRate().multiply(new BigDecimal("100")).divide(new BigDecimal(vo.getEquipmentIdList().size()), 2, BigDecimal.ROUND_HALF_UP));
         }
         if (result.getUtilizationRate().compareTo(new BigDecimal("0")) > 0) {
-            result.setUtilizationRate(result.getUtilizationRate().multiply(new BigDecimal(100)).divide(new BigDecimal(equipmentIds.size()), 2, BigDecimal.ROUND_HALF_UP));
+            result.setUtilizationRate(result.getUtilizationRate().multiply(new BigDecimal(100)).divide(new BigDecimal(vo.getEquipmentIdList().size()), 2, BigDecimal.ROUND_HALF_UP));
         }
         if (result.getOpenLong().compareTo(new BigDecimal(0)) > 0 && result.getProcessLong().compareTo(new BigDecimal(0)) > 0) {
             result.setUsedOpenRate(result.getProcessLong().divide(result.getOpenLong(), 4, BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal(100)));
@@ -796,7 +821,7 @@
             }
         } else if (StringUtils.isNotEmpty(vo.getEquipmentId())) {
             // 鍗曞彴璁惧淇℃伅
-            vo.setEquipmentIdList(Collections.singletonList(vo.getEquipmentId()));
+            vo.setEquipmentIdList(Arrays.asList(vo.getEquipmentId().split(",")));
         } else {
             // 鏌ヨ鐢ㄦ埛鎷ユ湁鐨勬墍鏈夎澶囦俊鎭�
             if ("2".equals(vo.getTypeTree())) {
@@ -1245,6 +1270,9 @@
                 dto.setColor(mdcUtilizationRate.getRateParameterColor());
             }
         }
+        if (StringUtils.isBlank(dto.getColor())) {
+            dto.setColor(mdcUtilizationRateList.get(mdcUtilizationRateList.size() - 1).getRateParameterColor());
+        }
         return dto;
     }
 
@@ -1280,20 +1308,6 @@
                             mdcEfficiencyResultDto.setColor(mdcUtilizationRate.getRateParameterColor());
                         }
                     }
-                } else {
-                    mdcEfficiencyResultDto.setTheDate(date);
-                    mdcEfficiencyResultDto.setProcessLong(new BigDecimal("0"));
-                    mdcEfficiencyResultDto.setUtilizationRate(new BigDecimal("0"));
-                    mdcEfficiencyResultDto.setStartRate(new BigDecimal("0"));
-                    mdcEfficiencyResultDto.setOpenRate(new BigDecimal("0"));
-                    mdcEfficiencyResultDto.setOpenLong(new BigDecimal("0"));
-                    mdcEfficiencyResultDto.setWaitLong(new BigDecimal("0"));
-                    mdcEfficiencyResultDto.setCloseLong(new BigDecimal("0"));
-                    for (MdcUtilizationRate mdcUtilizationRate : mdcUtilizationRateList) {
-                        if (0 >= mdcUtilizationRate.getMinimumRange() && 0 < mdcUtilizationRate.getMaximumRange()) {
-                            mdcEfficiencyResultDto.setColor(mdcUtilizationRate.getRateParameterColor());
-                        }
-                    }
                 }
             }
         } else {
@@ -1311,7 +1325,21 @@
                 }
             }
         }
-
+        if (StringUtils.isBlank(mdcEfficiencyResultDto.getColor())) {
+            mdcEfficiencyResultDto.setTheDate(date);
+            mdcEfficiencyResultDto.setProcessLong(new BigDecimal("0"));
+            mdcEfficiencyResultDto.setUtilizationRate(new BigDecimal("0"));
+            mdcEfficiencyResultDto.setStartRate(new BigDecimal("0"));
+            mdcEfficiencyResultDto.setOpenRate(new BigDecimal("0"));
+            mdcEfficiencyResultDto.setOpenLong(new BigDecimal("0"));
+            mdcEfficiencyResultDto.setWaitLong(new BigDecimal("0"));
+            mdcEfficiencyResultDto.setCloseLong(new BigDecimal("0"));
+            for (MdcUtilizationRate mdcUtilizationRate : mdcUtilizationRateList) {
+                if (0 >= mdcUtilizationRate.getMinimumRange() && 0 < mdcUtilizationRate.getMaximumRange()) {
+                    mdcEfficiencyResultDto.setColor(mdcUtilizationRate.getRateParameterColor());
+                }
+            }
+        }
         return mdcEfficiencyResultDto;
     }
 

--
Gitblit v1.9.3