From 5b999730e081bb5ba934ebf361280ca477a0e714 Mon Sep 17 00:00:00 2001
From: cuijian <cuijian@xalxzn.com>
Date: 星期四, 14 八月 2025 17:03:04 +0800
Subject: [PATCH] 工厂建模功能调整
---
src/main/java/org/jeecg/modules/mdc/service/impl/MdcEfficiencyReportServiceImpl.java | 782 +++++++++++++++++++++++++++----------------------------
1 files changed, 388 insertions(+), 394 deletions(-)
diff --git a/src/main/java/org/jeecg/modules/mdc/service/impl/MdcEfficiencyReportServiceImpl.java b/src/main/java/org/jeecg/modules/mdc/service/impl/MdcEfficiencyReportServiceImpl.java
index 2a15529..5faa6b6 100644
--- a/src/main/java/org/jeecg/modules/mdc/service/impl/MdcEfficiencyReportServiceImpl.java
+++ b/src/main/java/org/jeecg/modules/mdc/service/impl/MdcEfficiencyReportServiceImpl.java
@@ -1,10 +1,13 @@
package org.jeecg.modules.mdc.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import liquibase.pro.packaged.I;
import org.apache.commons.lang3.StringUtils;
import org.jeecg.common.constant.CommonConstant;
import org.jeecg.common.exception.JeecgBootException;
import org.jeecg.common.system.vo.DictModel;
+import org.jeecg.modules.base.entity.Factory;
+import org.jeecg.modules.base.service.IFactoryService;
import org.jeecg.modules.mdc.dto.*;
import org.jeecg.modules.mdc.entity.*;
import org.jeecg.modules.mdc.mapper.MdcEfficiencyReportMapper;
@@ -46,7 +49,10 @@
private ISysDepartService sysDepartService;
@Resource
- private IMdcProductionService mdcProductionService;
+ private IFactoryService factoryService;
+
+// @Resource
+// private IMdcProductionService mdcProductionService;
@Resource
private IMdcShiftSubService mdcShiftSubService;
@@ -192,12 +198,12 @@
mdcEfficiencyResultDto.setWaitLong(mdcEfficiencyResultDto.getWaitLong().divide(new BigDecimal(dates.size()), 0, RoundingMode.HALF_UP));
mdcEfficiencyResultDto1.setCloseLong(mdcEfficiencyResultDto.getCloseLong());
mdcEfficiencyResultDto.setCloseLong(mdcEfficiencyResultDto.getCloseLong().divide(new BigDecimal(dates.size()), 0, RoundingMode.HALF_UP));
- mdcEfficiencyResultDto1.setFaultLong(mdcEfficiencyResultDto.getFaultLong());
- mdcEfficiencyResultDto.setFaultLong(mdcEfficiencyResultDto.getFaultLong().divide(new BigDecimal(dates.size()), 0, RoundingMode.HALF_UP));
- mdcEfficiencyResultDto1.setFaultRate(mdcEfficiencyResultDto.getFaultRate());
- mdcEfficiencyResultDto.setFaultRate(mdcEfficiencyResultDto.getFaultRate().divide(new BigDecimal(dates.size()), 4, RoundingMode.HALF_UP));
- mdcEfficiencyResultDto1.setRemoveFaultRunLong(mdcEfficiencyResultDto.getRemoveFaultRunLong());
- mdcEfficiencyResultDto.setRemoveFaultRunLong(mdcEfficiencyResultDto.getRemoveFaultRunLong().divide(new BigDecimal(dates.size()), 0, RoundingMode.HALF_UP));
+// mdcEfficiencyResultDto1.setFaultLong(mdcEfficiencyResultDto.getFaultLong());
+// mdcEfficiencyResultDto.setFaultLong(mdcEfficiencyResultDto.getFaultLong().divide(new BigDecimal(dates.size()), 0, RoundingMode.HALF_UP));
+// mdcEfficiencyResultDto1.setFaultRate(mdcEfficiencyResultDto.getFaultRate());
+// mdcEfficiencyResultDto.setFaultRate(mdcEfficiencyResultDto.getFaultRate().divide(new BigDecimal(dates.size()), 4, RoundingMode.HALF_UP));
+// mdcEfficiencyResultDto1.setRemoveFaultRunLong(mdcEfficiencyResultDto.getRemoveFaultRunLong());
+// mdcEfficiencyResultDto.setRemoveFaultRunLong(mdcEfficiencyResultDto.getRemoveFaultRunLong().divide(new BigDecimal(dates.size()), 0, RoundingMode.HALF_UP));
long rate = mdcEfficiencyResultDto.getUtilizationRate().multiply(new BigDecimal("100")).longValue();
for (MdcUtilizationRate mdcUtilizationRate : mdcUtilizationRateList) {
if (rate >= mdcUtilizationRate.getMinimumRange() && rate < mdcUtilizationRate.getMaximumRange()) {
@@ -214,7 +220,7 @@
// 浜х嚎灞傜骇
List<MdcEquProDto> equipmentList = mdcEquipmentService.findEquProList(vo.getEquipmentIdList());
// 鏌ヨ鎵�鏈変骇绾夸俊鎭�
- List<MdcProduction> productionList = mdcProductionService.list(new LambdaQueryWrapper<MdcProduction>().ne(MdcProduction::getDelFlag, CommonConstant.DEL_FLAG_1.toString()).orderByAsc(MdcProduction::getProductionOrder));
+ List<Factory> factoryList = factoryService.list(new LambdaQueryWrapper<Factory>().ne(Factory::getDelFlag, CommonConstant.DEL_FLAG_1.toString()).orderByAsc(Factory::getSorter));
for (MdcEquProDto mdcEquProDto : equipmentList) {
MdcEfficiencyListDto mdcEfficiencyListDto = new MdcEfficiencyListDto();
@@ -233,31 +239,31 @@
break;
default:
}
- MdcProduction mdcProduction = productionList.stream().filter(production -> production.getId().equals(mdcEquProDto.getParentId())).findAny().orElse(null);
- if (mdcProduction != null) {
- switch (mdcProduction.getOrgType()) {
+ Factory baseFactory = factoryList.stream().filter(factory -> factory.getId().equals(mdcEquProDto.getParentId())).findAny().orElse(null);
+ if (baseFactory != null) {
+ switch (baseFactory.getFactoryCategory()) {
case "1":
- mdcEfficiencyListDto.setLevel1(mdcProduction.getProductionName());
+ mdcEfficiencyListDto.setLevel1(baseFactory.getFactoryName());
break;
case "2":
- mdcEfficiencyListDto.setLevel2(mdcProduction.getProductionName());
+ mdcEfficiencyListDto.setLevel2(baseFactory.getFactoryName());
break;
case "3":
- mdcEfficiencyListDto.setLevel3(mdcProduction.getProductionName());
+ mdcEfficiencyListDto.setLevel3(baseFactory.getFactoryName());
break;
default:
}
- if (StringUtils.isNotEmpty(mdcProduction.getParentId())) {
- productionList.stream().filter(production -> production.getId().equals(mdcProduction.getParentId())).findAny().ifPresent(production1 -> {
- switch (production1.getOrgType()) {
+ if (StringUtils.isNotEmpty(baseFactory.getParentId())) {
+ factoryList.stream().filter(factory -> factory.getId().equals(baseFactory.getParentId())).findAny().ifPresent(factory1 -> {
+ switch (factory1.getFactoryCategory()) {
case "1":
- mdcEfficiencyListDto.setLevel1(production1.getProductionName());
+ mdcEfficiencyListDto.setLevel1(factory1.getFactoryName());
break;
case "2":
- mdcEfficiencyListDto.setLevel2(production1.getProductionName());
+ mdcEfficiencyListDto.setLevel2(factory1.getFactoryName());
break;
case "3":
- mdcEfficiencyListDto.setLevel3(production1.getProductionName());
+ mdcEfficiencyListDto.setLevel3(factory1.getFactoryName());
break;
default:
}
@@ -286,12 +292,12 @@
mdcEfficiencyResultDto.setWaitLong(mdcEfficiencyResultDto.getWaitLong().divide(new BigDecimal(dates.size()), 0, RoundingMode.HALF_UP));
mdcEfficiencyResultDto1.setCloseLong(mdcEfficiencyResultDto.getCloseLong());
mdcEfficiencyResultDto.setCloseLong(mdcEfficiencyResultDto.getCloseLong().divide(new BigDecimal(dates.size()), 0, RoundingMode.HALF_UP));
- mdcEfficiencyResultDto1.setFaultLong(mdcEfficiencyResultDto.getFaultLong());
- mdcEfficiencyResultDto.setFaultLong(mdcEfficiencyResultDto.getFaultLong().divide(new BigDecimal(dates.size()), 0, RoundingMode.HALF_UP));
- mdcEfficiencyResultDto1.setFaultRate(mdcEfficiencyResultDto.getFaultRate());
- mdcEfficiencyResultDto.setFaultRate(mdcEfficiencyResultDto.getFaultRate().divide(new BigDecimal(dates.size()), 4, RoundingMode.HALF_UP));
- mdcEfficiencyResultDto1.setRemoveFaultRunLong(mdcEfficiencyResultDto.getRemoveFaultRunLong());
- mdcEfficiencyResultDto.setRemoveFaultRunLong(mdcEfficiencyResultDto.getRemoveFaultRunLong().divide(new BigDecimal(dates.size()), 0, RoundingMode.HALF_UP));
+// mdcEfficiencyResultDto1.setFaultLong(mdcEfficiencyResultDto.getFaultLong());
+// mdcEfficiencyResultDto.setFaultLong(mdcEfficiencyResultDto.getFaultLong().divide(new BigDecimal(dates.size()), 0, RoundingMode.HALF_UP));
+// mdcEfficiencyResultDto1.setFaultRate(mdcEfficiencyResultDto.getFaultRate());
+// mdcEfficiencyResultDto.setFaultRate(mdcEfficiencyResultDto.getFaultRate().divide(new BigDecimal(dates.size()), 4, RoundingMode.HALF_UP));
+// mdcEfficiencyResultDto1.setRemoveFaultRunLong(mdcEfficiencyResultDto.getRemoveFaultRunLong());
+// mdcEfficiencyResultDto.setRemoveFaultRunLong(mdcEfficiencyResultDto.getRemoveFaultRunLong().divide(new BigDecimal(dates.size()), 0, RoundingMode.HALF_UP));
long rate = mdcEfficiencyResultDto.getUtilizationRate().multiply(new BigDecimal("100")).longValue();
for (MdcUtilizationRate mdcUtilizationRate : mdcUtilizationRateList) {
if (rate >= mdcUtilizationRate.getMinimumRange() && rate < mdcUtilizationRate.getMaximumRange()) {
@@ -357,10 +363,7 @@
a.getOpenRate().add(b.getOpenRate()),
a.getOpenLong().add(b.getOpenLong()),
a.getWaitLong().add(b.getWaitLong()),
- a.getCloseLong().add(b.getCloseLong()),
- a.getFaultLong().add(b.getFaultLong()),
- a.getFaultRate().add(b.getFaultRate()),
- a.getRemoveFaultRunLong().add(b.getRemoveFaultRunLong()))).ifPresent(result::add);
+ a.getCloseLong().add(b.getCloseLong()))).ifPresent(result::add);
});
for (MdcEfficiencyResultDto mdcEfficiencyResultDto : result) {
mdcEfficiencyResultDto.setUtilizationRate(mdcEfficiencyResultDto.getUtilizationRate().divide(new BigDecimal(mdcEfficiencyList.size()), 4, RoundingMode.HALF_UP));
@@ -403,10 +406,7 @@
a.getOpenRate().add(b.getOpenRate()),
a.getOpenLong().add(b.getOpenLong()),
a.getWaitLong().add(b.getWaitLong()),
- a.getCloseLong().add(b.getCloseLong()),
- a.getFaultLong().add(b.getFaultLong()),
- a.getFaultRate().add(b.getFaultRate()),
- a.getRemoveFaultRunLong().add(b.getRemoveFaultRunLong()))).ifPresent(result::add);
+ a.getCloseLong().add(b.getCloseLong()))).ifPresent(result::add);
});
for (MdcEfficiencyResultDto mdcEfficiencyResultDto : result) {
mdcEfficiencyResultDto.setUtilizationRate(mdcEfficiencyResultDto.getUtilizationRate().divide(new BigDecimal(mdcEfficiencyList.size()), 4, RoundingMode.HALF_UP));
@@ -574,7 +574,7 @@
// 浜х嚎灞傜骇
List<MdcEquProDto> equipmentList = mdcEquipmentService.findEquProList(vo.getEquipmentIdList());
// 鏌ヨ鎵�鏈変骇绾夸俊鎭�
- List<MdcProduction> productionList = mdcProductionService.list(new LambdaQueryWrapper<MdcProduction>().ne(MdcProduction::getDelFlag, CommonConstant.DEL_FLAG_1.toString()).orderByAsc(MdcProduction::getProductionOrder));
+ List<Factory> factoryList = factoryService.list(new LambdaQueryWrapper<Factory>().ne(Factory::getDelFlag, CommonConstant.DEL_FLAG_1.toString()).orderByAsc(Factory::getSorter));
for (MdcEquProDto mdcEquProDto : equipmentList) {
MdcEfficiencyListDto mdcEfficiencyListDto = new MdcEfficiencyListDto();
@@ -593,31 +593,31 @@
break;
default:
}
- MdcProduction mdcProduction = productionList.stream().filter(production -> production.getId().equals(mdcEquProDto.getParentId())).findAny().orElse(null);
- if (mdcProduction != null) {
- switch (mdcProduction.getOrgType()) {
+ Factory baseFactory = factoryList.stream().filter(factory -> factory.getId().equals(mdcEquProDto.getParentId())).findAny().orElse(null);
+ if (baseFactory != null) {
+ switch (baseFactory.getFactoryCategory()) {
case "1":
- mdcEfficiencyListDto.setLevel1(mdcProduction.getProductionName());
+ mdcEfficiencyListDto.setLevel1(baseFactory.getFactoryName());
break;
case "2":
- mdcEfficiencyListDto.setLevel2(mdcProduction.getProductionName());
+ mdcEfficiencyListDto.setLevel2(baseFactory.getFactoryName());
break;
case "3":
- mdcEfficiencyListDto.setLevel3(mdcProduction.getProductionName());
+ mdcEfficiencyListDto.setLevel3(baseFactory.getFactoryName());
break;
default:
}
- if (StringUtils.isNotEmpty(mdcProduction.getParentId())) {
- productionList.stream().filter(production -> production.getId().equals(mdcProduction.getParentId())).findAny().ifPresent(production1 -> {
- switch (production1.getOrgType()) {
+ if (StringUtils.isNotEmpty(baseFactory.getParentId())) {
+ factoryList.stream().filter(factory -> factory.getId().equals(baseFactory.getParentId())).findAny().ifPresent(factory1 -> {
+ switch (factory1.getFactoryCategory()) {
case "1":
- mdcEfficiencyListDto.setLevel1(production1.getProductionName());
+ mdcEfficiencyListDto.setLevel1(factory1.getFactoryName());
break;
case "2":
- mdcEfficiencyListDto.setLevel2(production1.getProductionName());
+ mdcEfficiencyListDto.setLevel2(factory1.getFactoryName());
break;
case "3":
- mdcEfficiencyListDto.setLevel3(production1.getProductionName());
+ mdcEfficiencyListDto.setLevel3(factory1.getFactoryName());
break;
default:
}
@@ -710,10 +710,7 @@
a.getOpenRate().add(b.getOpenRate()),
a.getOpenLong().add(b.getOpenLong()),
a.getWaitLong().add(b.getWaitLong()),
- a.getCloseLong().add(b.getCloseLong()),
- a.getFaultLong().add(b.getFaultLong()),
- a.getFaultRate().add(b.getFaultRate()),
- a.getRemoveFaultRunLong().add(b.getRemoveFaultRunLong()))).ifPresent(result::add);
+ a.getCloseLong().add(b.getCloseLong()))).ifPresent(result::add);
});
for (MdcEfficiencyResultDto mdcEfficiencyResultDto : result) {
mdcEfficiencyResultDto.setUtilizationRate(mdcEfficiencyResultDto.getUtilizationRate().divide(new BigDecimal(mdcEfficiencyList.size()), 4, RoundingMode.HALF_UP));
@@ -723,9 +720,9 @@
mdcEfficiencyResultDto.setWaitLong(mdcEfficiencyResultDto.getWaitLong().divide(new BigDecimal(mdcEfficiencyList.size()), 0, RoundingMode.HALF_UP));
mdcEfficiencyResultDto.setOpenLong(mdcEfficiencyResultDto.getOpenLong().divide(new BigDecimal(mdcEfficiencyList.size()), 0, RoundingMode.HALF_UP));
mdcEfficiencyResultDto.setProcessLong(mdcEfficiencyResultDto.getProcessLong().divide(new BigDecimal(mdcEfficiencyList.size()), 0, RoundingMode.HALF_UP));
- mdcEfficiencyResultDto.setFaultLong(mdcEfficiencyResultDto.getFaultLong().divide(new BigDecimal(mdcEfficiencyList.size()), 0, RoundingMode.HALF_UP));
- mdcEfficiencyResultDto.setFaultRate(mdcEfficiencyResultDto.getFaultRate().divide(new BigDecimal(mdcEfficiencyList.size()), 4, RoundingMode.HALF_UP));
- mdcEfficiencyResultDto.setRemoveFaultRunLong(mdcEfficiencyResultDto.getRemoveFaultRunLong().divide(new BigDecimal(mdcEfficiencyList.size()), 0, RoundingMode.HALF_UP));
+// mdcEfficiencyResultDto.setFaultLong(mdcEfficiencyResultDto.getFaultLong().divide(new BigDecimal(mdcEfficiencyList.size()), 0, RoundingMode.HALF_UP));
+// mdcEfficiencyResultDto.setFaultRate(mdcEfficiencyResultDto.getFaultRate().divide(new BigDecimal(mdcEfficiencyList.size()), 4, RoundingMode.HALF_UP));
+// mdcEfficiencyResultDto.setRemoveFaultRunLong(mdcEfficiencyResultDto.getRemoveFaultRunLong().divide(new BigDecimal(mdcEfficiencyList.size()), 0, RoundingMode.HALF_UP));
long rate = mdcEfficiencyResultDto.getStartRate().multiply(new BigDecimal("100")).longValue();
for (MdcUtilizationRate mdcUtilizationRate : mdcUtilizationRateList) {
if (rate >= mdcUtilizationRate.getMinimumRange() && rate < mdcUtilizationRate.getMaximumRange()) {
@@ -760,16 +757,13 @@
a.getOpenRate().add(b.getOpenRate()),
a.getOpenLong().add(b.getOpenLong()),
a.getWaitLong().add(b.getWaitLong()),
- a.getCloseLong().add(b.getCloseLong()),
- a.getFaultLong().add(b.getFaultLong()),
- a.getFaultRate().add(b.getFaultRate()),
- a.getRemoveFaultRunLong().add(b.getRemoveFaultRunLong()))).ifPresent(result::add);
+ a.getCloseLong().add(b.getCloseLong()))).ifPresent(result::add);
});
for (MdcEfficiencyResultDto mdcEfficiencyResultDto : result) {
mdcEfficiencyResultDto.setUtilizationRate(mdcEfficiencyResultDto.getUtilizationRate().divide(new BigDecimal(mdcEfficiencyList.size()), 4, RoundingMode.HALF_UP));
mdcEfficiencyResultDto.setOpenRate(mdcEfficiencyResultDto.getOpenRate().divide(new BigDecimal(mdcEfficiencyList.size()), 4, RoundingMode.HALF_UP));
mdcEfficiencyResultDto.setStartRate(mdcEfficiencyResultDto.getStartRate().divide(new BigDecimal(mdcEfficiencyList.size()), 4, RoundingMode.HALF_UP));
- mdcEfficiencyResultDto.setFaultRate(mdcEfficiencyResultDto.getFaultRate().divide(new BigDecimal(mdcEfficiencyList.size()), 4, RoundingMode.HALF_UP));
+// mdcEfficiencyResultDto.setFaultRate(mdcEfficiencyResultDto.getFaultRate().divide(new BigDecimal(mdcEfficiencyList.size()), 4, RoundingMode.HALF_UP));
long rate = mdcEfficiencyResultDto.getStartRate().multiply(new BigDecimal("100")).longValue();
for (MdcUtilizationRate mdcUtilizationRate : mdcUtilizationRateList) {
if (rate >= mdcUtilizationRate.getMinimumRange() && rate < mdcUtilizationRate.getMaximumRange()) {
@@ -955,7 +949,7 @@
// 浜х嚎灞傜骇
List<MdcEquProDto> equipmentList = mdcEquipmentService.findEquProList(vo.getEquipmentIdList());
// 鏌ヨ鎵�鏈変骇绾夸俊鎭�
- List<MdcProduction> productionList = mdcProductionService.list(new LambdaQueryWrapper<MdcProduction>().ne(MdcProduction::getDelFlag, CommonConstant.DEL_FLAG_1.toString()).orderByAsc(MdcProduction::getProductionOrder));
+ List<Factory> factoryList = factoryService.list(new LambdaQueryWrapper<Factory>().ne(Factory::getDelFlag, CommonConstant.DEL_FLAG_1.toString()).orderByAsc(Factory::getSorter));
// 鐝鍚嶇О鏄剧ず澶勭悊
String shiftSubName = "";
@@ -996,31 +990,31 @@
break;
default:
}
- MdcProduction mdcProduction = productionList.stream().filter(production -> production.getId().equals(mdcEquProDto.getParentId())).findAny().orElse(null);
- if (mdcProduction != null) {
- switch (mdcProduction.getOrgType()) {
+ Factory baseFactory = factoryList.stream().filter(factory -> factory.getId().equals(mdcEquProDto.getParentId())).findAny().orElse(null);
+ if (baseFactory != null) {
+ switch (baseFactory.getFactoryCategory()) {
case "1":
- mdcEfficiencyShiftListDto.setLevel1(mdcProduction.getProductionName());
+ mdcEfficiencyShiftListDto.setLevel1(baseFactory.getFactoryName());
break;
case "2":
- mdcEfficiencyShiftListDto.setLevel2(mdcProduction.getProductionName());
+ mdcEfficiencyShiftListDto.setLevel2(baseFactory.getFactoryName());
break;
case "3":
- mdcEfficiencyShiftListDto.setLevel3(mdcProduction.getProductionName());
+ mdcEfficiencyShiftListDto.setLevel3(baseFactory.getFactoryName());
break;
default:
}
- if (StringUtils.isNotEmpty(mdcProduction.getParentId())) {
- productionList.stream().filter(production -> production.getId().equals(mdcProduction.getParentId())).findAny().ifPresent(production1 -> {
- switch (production1.getOrgType()) {
+ if (StringUtils.isNotEmpty(baseFactory.getParentId())) {
+ factoryList.stream().filter(factory -> factory.getId().equals(baseFactory.getParentId())).findAny().ifPresent(factory1 -> {
+ switch (factory1.getFactoryCategory()) {
case "1":
- mdcEfficiencyShiftListDto.setLevel1(production1.getProductionName());
+ mdcEfficiencyShiftListDto.setLevel1(factory1.getFactoryName());
break;
case "2":
- mdcEfficiencyShiftListDto.setLevel2(production1.getProductionName());
+ mdcEfficiencyShiftListDto.setLevel2(factory1.getFactoryName());
break;
case "3":
- mdcEfficiencyShiftListDto.setLevel3(production1.getProductionName());
+ mdcEfficiencyShiftListDto.setLevel3(factory1.getFactoryName());
break;
default:
}
@@ -1767,316 +1761,316 @@
return mdcEfficiencyReportMapper.getEfficiencyRate(equipmentId, date);
}
- /**
- * 鐝粍鍚勮澶囩患鍚堝埄鐢ㄧ巼
- *
- * @param equEffVo
- * @return
- */
- @Override
- public Map<String, Object> equipmentEfficiencyAnalyze(String userId, EquEffVo equEffVo) {
- Map<String, Object> result = new HashMap<>();
- List<String> mdcProductionIds = new ArrayList<>();
- if (StringUtils.isBlank(equEffVo.getProductionIds())) {
- mdcProductionIds.add(equEffVo.getProductionId());
- } else {
- mdcProductionIds.addAll(Arrays.asList(equEffVo.getProductionIds().split(",")));
- }
- List<String> allProductionIds = mdcProductionService.findChildren(mdcProductionIds);
- //鏁版嵁鏉冮檺杩囨护
- allProductionIds = mdcProductionService.findProIdsByUId(userId, allProductionIds);
- List<MdcEquipment> equipmentList = mdcEquipmentService.findByProductionIds(allProductionIds);
- if (equipmentList != null && !equipmentList.isEmpty()) {
- List<String> equipmentIdList = equipmentList.stream().map(MdcEquipment::getEquipmentId).collect(Collectors.toList());
- List<EquipmentEfficiencyAnalyzeDto> dataList = mdcEfficiencyReportMapper.equipmentEfficiencyAnalyze(equipmentIdList, equEffVo.getMonth());
- result.put("dataList", dataList);
- List<String> equipmentNameList = dataList.stream().map(EquipmentEfficiencyAnalyzeDto::getEquipmentId).collect(Collectors.toList());
- result.put("equipmentNameList", equipmentNameList);
- }
- return result;
- }
-
- @Override
- public Map<String, Object> teamEquipmentEfficiencyAnalyze(String userId, EquEffVo equEffVo) {
- Map<String, Object> result = new HashMap<>();
- // 1. 澶勭悊鐢熶骇ID
- List<String> mdcProductionIds = StringUtils.isBlank(equEffVo.getProductionIds())
- ? Collections.singletonList(equEffVo.getProductionId())
- : Arrays.asList(equEffVo.getProductionIds().split(","));
-
- List<String> allProductionIds = mdcProductionService.findChildren(mdcProductionIds);
- if (allProductionIds.isEmpty()) {
- return result; // 鎻愬墠杩斿洖绌虹粨鏋�
- }
- //鏁版嵁鏉冮檺杩囨护
- allProductionIds = mdcProductionService.findProIdsByUId(userId, allProductionIds);
- // 2. 鑾峰彇璁惧鍒楄〃
- List<MdcEquipment> equipmentList = StringUtils.isNotBlank(equEffVo.getTeamCodes())
- ? mdcEquipmentService.findByProIdsAndTeamCode(allProductionIds, Arrays.asList(equEffVo.getTeamCodes().split(",")))
- : mdcEquipmentService.findByProductionIds(allProductionIds);
-
- if (equipmentList.isEmpty()) {
- return result;
- }
-
- // 3. 鏁版嵁澶勭悊
- List<String> equipmentIdList = equipmentList.stream()
- .map(MdcEquipment::getEquipmentId)
- .collect(Collectors.toList());
-
- List<TeamEquEffDto> dataList = mdcEfficiencyReportMapper
- .teamEquipmentEfficiencyAnalyze(equipmentIdList, equEffVo.getMonth());
-
- if (dataList.isEmpty()) {
- return result;
- }
-
- // 4. 鍒嗙粍璁$畻骞冲潎鍊�
- Map<String, TeamEquEffDto> grouped = dataList.stream()
- .collect(Collectors.groupingBy(
- TeamEquEffDto::getTeamCode,
- Collectors.collectingAndThen(
- Collectors.toList(),
- this::calculateAverages // 鎻愬彇璁$畻鏂规硶
- )));
-
- // 5. 瀛楀吀杞崲
- Map<String, String> dictMap = sysDictService.queryEnableDictItemsByCode(CommonConstant.DICT_MDC_STAFF_TEAM)
- .stream()
- .collect(Collectors.toMap(DictModel::getValue, DictModel::getText));
-
- List<TeamEquEffDto> resultList = grouped.entrySet().stream()
- .map(entry -> buildResultDto(entry, dictMap))// 鎻愬彇鏋勫缓鏂规硶
- .sorted(Comparator.comparing(TeamEquEffDto::getUtilizationRate).reversed())
- .collect(Collectors.toList());
-
- result.put("dataList", resultList);
- result.put("teamCodeList", resultList.stream()
- .map(TeamEquEffDto::getTeamCode)
- .collect(Collectors.toList()));
-
- return result;
-
- }
-
- @Override
- public Map<String, Object> teamEfficiencyAnalyzeByMonth(String userId, EquEffVo equEffVo) {
- Map<String, Object> result = new HashMap<>();
-
- // 1. 鏃ユ湡澶勭悊
- LocalDate now = LocalDate.now();
- Date start = DateUtils.toDate(now.plusMonths(-6).toString(), DateUtils.STR_DATE);
- Date end = DateUtils.toDate(now.plusMonths(-1).toString(), DateUtils.STR_DATE);
-
- List<String> monthBetween = DateUtils.getMonthBetween(start, end);
- List<String> dateList = monthBetween.stream()
- .map(date -> date.substring(date.lastIndexOf("-") + 1).replaceFirst("^0*", "") + "鏈�")
- .collect(Collectors.toList());
- result.put("dateList", dateList);
-
- // 2. 鑾峰彇浜х嚎鏁版嵁
- List<MdcProduction> mdcProductions = mdcProductionService.findMdcPros(userId, equEffVo.getProductionId());
-
- // 3. 鍒濆鍖栫粨鏋滈泦
- List<TeamEquEffMonthDto> utilizationRateList = new ArrayList<>();
- List<TeamEquEffMonthDto> shiftUtilizationRateList = new ArrayList<>();
- List<TeamEquEffMonthDto> amendUtilizationRateList = new ArrayList<>();
-
- // 4. 澶勭悊姣忎釜浜х嚎
- mdcProductions.forEach(mdcProduction -> {
- // 4.1 鑾峰彇涓嬬骇浜х嚎骞惰繃婊�
- List<String> allProductionIds = mdcProductionService.recursionChildren(mdcProduction.getId());
- // 鏁版嵁鏉冮檺杩囨护
- allProductionIds = mdcProductionService.findProIdsByUId(userId, allProductionIds);
- // 4.2 鑾峰彇璁惧鍒楄〃
- List<MdcEquipment> equipmentList = mdcEquipmentService.findByProductionIds(allProductionIds);
- if (equipmentList == null || equipmentList.isEmpty()) {
- return;
- }
- //鎻愬彇id闆嗗悎
- List<String> equipmentIdList = equipmentList.stream()
- .map(MdcEquipment::getEquipmentId)
- .collect(Collectors.toList());
-
- TeamEquEffMonthDto urDto = new TeamEquEffMonthDto();
- TeamEquEffMonthDto surDto = new TeamEquEffMonthDto();
- TeamEquEffMonthDto aurDto = new TeamEquEffMonthDto();
- urDto.setProductionName(mdcProduction.getProductionName());
- surDto.setProductionName(mdcProduction.getProductionName());
- aurDto.setProductionName(mdcProduction.getProductionName());
- List<TeamEquEffMonthChildDto> urDataList = new ArrayList<>();
- List<TeamEquEffMonthChildDto> surDataList = new ArrayList<>();
- List<TeamEquEffMonthChildDto> aurDataList = new ArrayList<>();
-
- monthBetween.forEach(date -> {
- TeamEquEffMonthChildDto urCDto = new TeamEquEffMonthChildDto();
- TeamEquEffMonthChildDto surCDto = new TeamEquEffMonthChildDto();
- TeamEquEffMonthChildDto aurCDto = new TeamEquEffMonthChildDto();
- String month = date.substring(date.lastIndexOf("-") + 1).replaceFirst("^0*", "") + "鏈�";
- urCDto.setMonth(month);
- surCDto.setMonth(month);
- aurCDto.setMonth(month);
- List<TeamEquEffDto> dataList = mdcEfficiencyReportMapper.teamEquipmentEfficiencyAnalyze(equipmentIdList, date.replaceAll("-", ""));
- if (dataList != null && !dataList.isEmpty()) {
- // 璁$畻骞冲潎鍊�
- BigDecimal ur = dataList.stream()
- .map(TeamEquEffDto::getUtilizationRate)
- .reduce(BigDecimal.ZERO, BigDecimal::add)
- .divide(BigDecimal.valueOf(dataList.size()), 2, RoundingMode.HALF_UP);
- //鍒╃敤鐜�
- urCDto.setUtilizationRate(ur);
- //鐝鍒╃敤鐜�
- BigDecimal sur = dataList.stream()
- .map(TeamEquEffDto::getShiftUtilizationRate)
- .reduce(BigDecimal.ZERO, BigDecimal::add)
- .divide(BigDecimal.valueOf(dataList.size()), 2, RoundingMode.HALF_UP);
- surCDto.setUtilizationRate(sur);
- //鍘婚櫎鏁呴殰24灏忔椂鍒╃敤鐜�
- BigDecimal aur = dataList.stream()
- .map(TeamEquEffDto::getAmendUtilizationRate)
- .reduce(BigDecimal.ZERO, BigDecimal::add)
- .divide(BigDecimal.valueOf(dataList.size()), 2, RoundingMode.HALF_UP);
- aurCDto.setUtilizationRate(aur);
- }
- urDataList.add(urCDto);
- surDataList.add(surCDto);
- aurDataList.add(aurCDto);
- });
- urDto.setDataList(urDataList);
- surDto.setDataList(surDataList);
- aurDto.setDataList(aurDataList);
- utilizationRateList.add(urDto);
- shiftUtilizationRateList.add(surDto);
- amendUtilizationRateList.add(aurDto);
- });
- result.put("utilizationRateList", utilizationRateList);
- result.put("shiftUtilizationRateList", shiftUtilizationRateList);
- result.put("amendUtilizationRateList", amendUtilizationRateList);
- return result;
- }
-
- @Override
- public Map<String, Object> comprehensiveRateAnalyze(String userId, EquEffVo vo) {
- Map<String, Object> result = new HashMap<>();
- // 1. 鏃ユ湡澶勭悊
- LocalDate now = LocalDate.now();
- Date start = DateUtils.toDate(now.plusMonths(-12).toString(), DateUtils.STR_DATE);
- Date end = DateUtils.toDate(now.plusMonths(-1).toString(), DateUtils.STR_DATE);
-
- List<String> monthBetween = DateUtils.getMonthBetween(start, end);
- List<String> dateList = monthBetween.stream()
- .map(date -> date.substring(date.lastIndexOf("-") + 1).replaceFirst("^0*", "") + "鏈�")
- .collect(Collectors.toList());
- result.put("dateList", dateList);
-
- // 1. 澶勭悊鐢熶骇ID
- List<String> mdcProductionIds = StringUtils.isBlank(vo.getProductionIds())
- ? Collections.singletonList(vo.getProductionId())
- : Arrays.asList(vo.getProductionIds().split(","));
-
- List<String> allProductionIds = mdcProductionService.findChildren(mdcProductionIds);
- if (allProductionIds.isEmpty()) {
- return result; // 鎻愬墠杩斿洖绌虹粨鏋�
- }
- //鏁版嵁鏉冮檺杩囨护
- allProductionIds = mdcProductionService.findProIdsByUId(userId, allProductionIds);
- // 2. 鑾峰彇璁惧鍒楄〃
- List<MdcEquipment> equipmentList = StringUtils.isNotBlank(vo.getEquipmentType())
- ? mdcEquipmentService.findByProIdsAndType(allProductionIds, Arrays.asList(vo.getEquipmentType().split(",")))
- : mdcEquipmentService.findByProductionIds(allProductionIds);
-
- if (equipmentList.isEmpty()) {
- return result;
- }
-
- // 3. 鏁版嵁澶勭悊
- List<String> equipmentIdList = equipmentList.stream()
- .map(MdcEquipment::getEquipmentId)
- .collect(Collectors.toList());
- String startStr = monthBetween.get(0).replaceAll("-", "");
- String endStr = monthBetween.get(monthBetween.size() - 1).replaceAll("-", "");
- List<ComRateDto> comRateDtoList = mdcEfficiencyReportMapper.comprehensiveRateAnalyze(equipmentIdList, startStr, endStr);
- if (comRateDtoList.isEmpty()) {
- return result; // 鎻愬墠杩斿洖绌虹粨鏋�
- }
- List<ComRateDto> dataList = new ArrayList<>();
- Map<String, ComRateDto> map = comRateDtoList.stream().collect(Collectors.toMap(ComRateDto::getTheMonth, comRateDto -> comRateDto));
- monthBetween.forEach(date -> {
- String d = date.replaceAll("-", "");
- String month = date.substring(date.lastIndexOf("-") + 1).replaceFirst("^0*", "") + "鏈�";
- if (map.containsKey(d)) {
- ComRateDto comRateDto = map.get(d);
- comRateDto.setTheMonth(month);
- comRateDto.setUtilizationRate(comRateDto.getUtilizationRate().setScale(2, RoundingMode.HALF_UP));
- comRateDto.setShiftUtilizationRate(comRateDto.getShiftUtilizationRate() != null ? comRateDto.getShiftUtilizationRate().setScale(2, RoundingMode.HALF_UP) : BigDecimal.ZERO);
- comRateDto.setAmendUtilizationRate(comRateDto.getAmendUtilizationRate().setScale(2, RoundingMode.HALF_UP));
- comRateDto.setProcessLong(comRateDto.getProcessLong().divide(new BigDecimal("3600"), 2, RoundingMode.HALF_UP));
- dataList.add(comRateDto);
- } else {
- ComRateDto comRateDto = new ComRateDto();
- comRateDto.setTheMonth(month);
- dataList.add(comRateDto);
- }
- });
- result.put("dataList", dataList);
-
- if (StringUtils.isNotBlank(vo.getShiftId())) {
- List<MdcShiftSub> shiftSubList = mdcShiftSubService.list(new LambdaQueryWrapper<MdcShiftSub>().eq(MdcShiftSub::getShiftId, vo.getShiftId()));
- if (shiftSubList == null || shiftSubList.isEmpty()) {
- return result;
- }
- List<String> shiftSubNameList = shiftSubList.stream().map(MdcShiftSub::getShiftSubName).collect(Collectors.toList());
- result.put("shiftSubList", shiftSubNameList);
-
- List<ComShiftRateDto> comShiftRateDtoList = mdcEfficiencyReportMapper.comprehensiveShiftRateAnalyze(equipmentIdList, startStr, endStr, vo.getShiftId());
- Map<String, List<ComShiftRateDto>> groupMap;
- if (comShiftRateDtoList != null && !comShiftRateDtoList.isEmpty()) {
- groupMap = comShiftRateDtoList.stream().collect(Collectors.groupingBy(ComShiftRateDto::getShiftSub));
- } else {
- groupMap = new HashMap<>();
- }
- List<ComShiftDto> shiftDataList = new ArrayList<>();
- shiftSubList.forEach(mdcShiftSub -> {
- ComShiftDto comShiftDto = new ComShiftDto();
- comShiftDto.setShiftSubName(mdcShiftSub.getShiftSubName());
- if (groupMap.containsKey(mdcShiftSub.getId())) {
- List<ComShiftRateDto> csrd = groupMap.get(mdcShiftSub.getId());
- Map<String, ComShiftRateDto> collect = csrd.stream().collect(Collectors.toMap(ComShiftRateDto::getTheMonth, comShiftRateDto -> comShiftRateDto));
- List<ComShiftChildDto> comShiftChildDtoList = new ArrayList<>();
- monthBetween.forEach(date -> {
- String d = date.replaceAll("-", "");
- String month = date.substring(date.lastIndexOf("-") + 1).replaceFirst("^0*", "") + "鏈�";
- if (collect.containsKey(d)) {
- ComShiftRateDto comShiftRateDto = collect.get(d);
- ComShiftChildDto comShiftChildDto = new ComShiftChildDto();
- comShiftChildDto.setMonth(month);
- comShiftChildDto.setUtilizationRate(comShiftRateDto.getUtilizationRate().setScale(2, RoundingMode.HALF_UP));
- comShiftChildDtoList.add(comShiftChildDto);
- } else {
- ComShiftChildDto comShiftChildDto = new ComShiftChildDto();
- comShiftChildDto.setMonth(month);
- comShiftChildDtoList.add(comShiftChildDto);
- }
- });
- comShiftDto.setDataList(comShiftChildDtoList);
- } else {
- List<ComShiftChildDto> comShiftChildDtoList = new ArrayList<>();
- monthBetween.forEach(date -> {
- String month = date.substring(date.lastIndexOf("-") + 1).replaceFirst("^0*", "") + "鏈�";
- ComShiftChildDto comShiftChildDto = new ComShiftChildDto();
- comShiftChildDto.setMonth(month);
- comShiftChildDtoList.add(comShiftChildDto);
- });
- comShiftDto.setDataList(comShiftChildDtoList);
- }
- shiftDataList.add(comShiftDto);
- });
-
- result.put("shiftDataList", shiftDataList);
- }
-
- return result;
- }
+// /**
+// * 鐝粍鍚勮澶囩患鍚堝埄鐢ㄧ巼
+// *
+// * @param equEffVo
+// * @return
+// */
+// @Override
+// public Map<String, Object> equipmentEfficiencyAnalyze(String userId, EquEffVo equEffVo) {
+// Map<String, Object> result = new HashMap<>();
+// List<String> mdcProductionIds = new ArrayList<>();
+// if (StringUtils.isBlank(equEffVo.getProductionIds())) {
+// mdcProductionIds.add(equEffVo.getProductionId());
+// } else {
+// mdcProductionIds.addAll(Arrays.asList(equEffVo.getProductionIds().split(",")));
+// }
+// List<String> allProductionIds = mdcProductionService.findChildren(mdcProductionIds);
+// //鏁版嵁鏉冮檺杩囨护
+// allProductionIds = mdcProductionService.findProIdsByUId(userId, allProductionIds);
+// List<MdcEquipment> equipmentList = mdcEquipmentService.findByProductionIds(allProductionIds);
+// if (equipmentList != null && !equipmentList.isEmpty()) {
+// List<String> equipmentIdList = equipmentList.stream().map(MdcEquipment::getEquipmentId).collect(Collectors.toList());
+// List<EquipmentEfficiencyAnalyzeDto> dataList = mdcEfficiencyReportMapper.equipmentEfficiencyAnalyze(equipmentIdList, equEffVo.getMonth());
+// result.put("dataList", dataList);
+// List<String> equipmentNameList = dataList.stream().map(EquipmentEfficiencyAnalyzeDto::getEquipmentId).collect(Collectors.toList());
+// result.put("equipmentNameList", equipmentNameList);
+// }
+// return result;
+// }
+//
+// @Override
+// public Map<String, Object> teamEquipmentEfficiencyAnalyze(String userId, EquEffVo equEffVo) {
+// Map<String, Object> result = new HashMap<>();
+// // 1. 澶勭悊鐢熶骇ID
+// List<String> mdcProductionIds = StringUtils.isBlank(equEffVo.getProductionIds())
+// ? Collections.singletonList(equEffVo.getProductionId())
+// : Arrays.asList(equEffVo.getProductionIds().split(","));
+//
+// List<String> allProductionIds = mdcProductionService.findChildren(mdcProductionIds);
+// if (allProductionIds.isEmpty()) {
+// return result; // 鎻愬墠杩斿洖绌虹粨鏋�
+// }
+// //鏁版嵁鏉冮檺杩囨护
+// allProductionIds = mdcProductionService.findProIdsByUId(userId, allProductionIds);
+// // 2. 鑾峰彇璁惧鍒楄〃
+// List<MdcEquipment> equipmentList = StringUtils.isNotBlank(equEffVo.getTeamCodes())
+// ? mdcEquipmentService.findByProIdsAndTeamCode(allProductionIds, Arrays.asList(equEffVo.getTeamCodes().split(",")))
+// : mdcEquipmentService.findByProductionIds(allProductionIds);
+//
+// if (equipmentList.isEmpty()) {
+// return result;
+// }
+//
+// // 3. 鏁版嵁澶勭悊
+// List<String> equipmentIdList = equipmentList.stream()
+// .map(MdcEquipment::getEquipmentId)
+// .collect(Collectors.toList());
+//
+// List<TeamEquEffDto> dataList = mdcEfficiencyReportMapper
+// .teamEquipmentEfficiencyAnalyze(equipmentIdList, equEffVo.getMonth());
+//
+// if (dataList.isEmpty()) {
+// return result;
+// }
+//
+// // 4. 鍒嗙粍璁$畻骞冲潎鍊�
+// Map<String, TeamEquEffDto> grouped = dataList.stream()
+// .collect(Collectors.groupingBy(
+// TeamEquEffDto::getTeamCode,
+// Collectors.collectingAndThen(
+// Collectors.toList(),
+// this::calculateAverages // 鎻愬彇璁$畻鏂规硶
+// )));
+//
+// // 5. 瀛楀吀杞崲
+// Map<String, String> dictMap = sysDictService.queryEnableDictItemsByCode(CommonConstant.DICT_MDC_STAFF_TEAM)
+// .stream()
+// .collect(Collectors.toMap(DictModel::getValue, DictModel::getText));
+//
+// List<TeamEquEffDto> resultList = grouped.entrySet().stream()
+// .map(entry -> buildResultDto(entry, dictMap))// 鎻愬彇鏋勫缓鏂规硶
+// .sorted(Comparator.comparing(TeamEquEffDto::getUtilizationRate).reversed())
+// .collect(Collectors.toList());
+//
+// result.put("dataList", resultList);
+// result.put("teamCodeList", resultList.stream()
+// .map(TeamEquEffDto::getTeamCode)
+// .collect(Collectors.toList()));
+//
+// return result;
+//
+// }
+//
+// @Override
+// public Map<String, Object> teamEfficiencyAnalyzeByMonth(String userId, EquEffVo equEffVo) {
+// Map<String, Object> result = new HashMap<>();
+//
+// // 1. 鏃ユ湡澶勭悊
+// LocalDate now = LocalDate.now();
+// Date start = DateUtils.toDate(now.plusMonths(-6).toString(), DateUtils.STR_DATE);
+// Date end = DateUtils.toDate(now.plusMonths(-1).toString(), DateUtils.STR_DATE);
+//
+// List<String> monthBetween = DateUtils.getMonthBetween(start, end);
+// List<String> dateList = monthBetween.stream()
+// .map(date -> date.substring(date.lastIndexOf("-") + 1).replaceFirst("^0*", "") + "鏈�")
+// .collect(Collectors.toList());
+// result.put("dateList", dateList);
+//
+// // 2. 鑾峰彇浜х嚎鏁版嵁
+// List<MdcProduction> mdcProductions = mdcProductionService.findMdcPros(userId, equEffVo.getProductionId());
+//
+// // 3. 鍒濆鍖栫粨鏋滈泦
+// List<TeamEquEffMonthDto> utilizationRateList = new ArrayList<>();
+// List<TeamEquEffMonthDto> shiftUtilizationRateList = new ArrayList<>();
+// List<TeamEquEffMonthDto> amendUtilizationRateList = new ArrayList<>();
+//
+// // 4. 澶勭悊姣忎釜浜х嚎
+// mdcProductions.forEach(mdcProduction -> {
+// // 4.1 鑾峰彇涓嬬骇浜х嚎骞惰繃婊�
+// List<String> allProductionIds = mdcProductionService.recursionChildren(mdcProduction.getId());
+// // 鏁版嵁鏉冮檺杩囨护
+// allProductionIds = mdcProductionService.findProIdsByUId(userId, allProductionIds);
+// // 4.2 鑾峰彇璁惧鍒楄〃
+// List<MdcEquipment> equipmentList = mdcEquipmentService.findByProductionIds(allProductionIds);
+// if (equipmentList == null || equipmentList.isEmpty()) {
+// return;
+// }
+// //鎻愬彇id闆嗗悎
+// List<String> equipmentIdList = equipmentList.stream()
+// .map(MdcEquipment::getEquipmentId)
+// .collect(Collectors.toList());
+//
+// TeamEquEffMonthDto urDto = new TeamEquEffMonthDto();
+// TeamEquEffMonthDto surDto = new TeamEquEffMonthDto();
+// TeamEquEffMonthDto aurDto = new TeamEquEffMonthDto();
+// urDto.setProductionName(mdcProduction.getProductionName());
+// surDto.setProductionName(mdcProduction.getProductionName());
+// aurDto.setProductionName(mdcProduction.getProductionName());
+// List<TeamEquEffMonthChildDto> urDataList = new ArrayList<>();
+// List<TeamEquEffMonthChildDto> surDataList = new ArrayList<>();
+// List<TeamEquEffMonthChildDto> aurDataList = new ArrayList<>();
+//
+// monthBetween.forEach(date -> {
+// TeamEquEffMonthChildDto urCDto = new TeamEquEffMonthChildDto();
+// TeamEquEffMonthChildDto surCDto = new TeamEquEffMonthChildDto();
+// TeamEquEffMonthChildDto aurCDto = new TeamEquEffMonthChildDto();
+// String month = date.substring(date.lastIndexOf("-") + 1).replaceFirst("^0*", "") + "鏈�";
+// urCDto.setMonth(month);
+// surCDto.setMonth(month);
+// aurCDto.setMonth(month);
+// List<TeamEquEffDto> dataList = mdcEfficiencyReportMapper.teamEquipmentEfficiencyAnalyze(equipmentIdList, date.replaceAll("-", ""));
+// if (dataList != null && !dataList.isEmpty()) {
+// // 璁$畻骞冲潎鍊�
+// BigDecimal ur = dataList.stream()
+// .map(TeamEquEffDto::getUtilizationRate)
+// .reduce(BigDecimal.ZERO, BigDecimal::add)
+// .divide(BigDecimal.valueOf(dataList.size()), 2, RoundingMode.HALF_UP);
+// //鍒╃敤鐜�
+// urCDto.setUtilizationRate(ur);
+// //鐝鍒╃敤鐜�
+// BigDecimal sur = dataList.stream()
+// .map(TeamEquEffDto::getShiftUtilizationRate)
+// .reduce(BigDecimal.ZERO, BigDecimal::add)
+// .divide(BigDecimal.valueOf(dataList.size()), 2, RoundingMode.HALF_UP);
+// surCDto.setUtilizationRate(sur);
+// //鍘婚櫎鏁呴殰24灏忔椂鍒╃敤鐜�
+// BigDecimal aur = dataList.stream()
+// .map(TeamEquEffDto::getAmendUtilizationRate)
+// .reduce(BigDecimal.ZERO, BigDecimal::add)
+// .divide(BigDecimal.valueOf(dataList.size()), 2, RoundingMode.HALF_UP);
+// aurCDto.setUtilizationRate(aur);
+// }
+// urDataList.add(urCDto);
+// surDataList.add(surCDto);
+// aurDataList.add(aurCDto);
+// });
+// urDto.setDataList(urDataList);
+// surDto.setDataList(surDataList);
+// aurDto.setDataList(aurDataList);
+// utilizationRateList.add(urDto);
+// shiftUtilizationRateList.add(surDto);
+// amendUtilizationRateList.add(aurDto);
+// });
+// result.put("utilizationRateList", utilizationRateList);
+// result.put("shiftUtilizationRateList", shiftUtilizationRateList);
+// result.put("amendUtilizationRateList", amendUtilizationRateList);
+// return result;
+// }
+//
+// @Override
+// public Map<String, Object> comprehensiveRateAnalyze(String userId, EquEffVo vo) {
+// Map<String, Object> result = new HashMap<>();
+// // 1. 鏃ユ湡澶勭悊
+// LocalDate now = LocalDate.now();
+// Date start = DateUtils.toDate(now.plusMonths(-12).toString(), DateUtils.STR_DATE);
+// Date end = DateUtils.toDate(now.plusMonths(-1).toString(), DateUtils.STR_DATE);
+//
+// List<String> monthBetween = DateUtils.getMonthBetween(start, end);
+// List<String> dateList = monthBetween.stream()
+// .map(date -> date.substring(date.lastIndexOf("-") + 1).replaceFirst("^0*", "") + "鏈�")
+// .collect(Collectors.toList());
+// result.put("dateList", dateList);
+//
+// // 1. 澶勭悊鐢熶骇ID
+// List<String> mdcProductionIds = StringUtils.isBlank(vo.getProductionIds())
+// ? Collections.singletonList(vo.getProductionId())
+// : Arrays.asList(vo.getProductionIds().split(","));
+//
+// List<String> allProductionIds = mdcProductionService.findChildren(mdcProductionIds);
+// if (allProductionIds.isEmpty()) {
+// return result; // 鎻愬墠杩斿洖绌虹粨鏋�
+// }
+// //鏁版嵁鏉冮檺杩囨护
+// allProductionIds = mdcProductionService.findProIdsByUId(userId, allProductionIds);
+// // 2. 鑾峰彇璁惧鍒楄〃
+// List<MdcEquipment> equipmentList = StringUtils.isNotBlank(vo.getEquipmentType())
+// ? mdcEquipmentService.findByProIdsAndType(allProductionIds, Arrays.asList(vo.getEquipmentType().split(",")))
+// : mdcEquipmentService.findByProductionIds(allProductionIds);
+//
+// if (equipmentList.isEmpty()) {
+// return result;
+// }
+//
+// // 3. 鏁版嵁澶勭悊
+// List<String> equipmentIdList = equipmentList.stream()
+// .map(MdcEquipment::getEquipmentId)
+// .collect(Collectors.toList());
+// String startStr = monthBetween.get(0).replaceAll("-", "");
+// String endStr = monthBetween.get(monthBetween.size() - 1).replaceAll("-", "");
+// List<ComRateDto> comRateDtoList = mdcEfficiencyReportMapper.comprehensiveRateAnalyze(equipmentIdList, startStr, endStr);
+// if (comRateDtoList.isEmpty()) {
+// return result; // 鎻愬墠杩斿洖绌虹粨鏋�
+// }
+// List<ComRateDto> dataList = new ArrayList<>();
+// Map<String, ComRateDto> map = comRateDtoList.stream().collect(Collectors.toMap(ComRateDto::getTheMonth, comRateDto -> comRateDto));
+// monthBetween.forEach(date -> {
+// String d = date.replaceAll("-", "");
+// String month = date.substring(date.lastIndexOf("-") + 1).replaceFirst("^0*", "") + "鏈�";
+// if (map.containsKey(d)) {
+// ComRateDto comRateDto = map.get(d);
+// comRateDto.setTheMonth(month);
+// comRateDto.setUtilizationRate(comRateDto.getUtilizationRate().setScale(2, RoundingMode.HALF_UP));
+// comRateDto.setShiftUtilizationRate(comRateDto.getShiftUtilizationRate() != null ? comRateDto.getShiftUtilizationRate().setScale(2, RoundingMode.HALF_UP) : BigDecimal.ZERO);
+// comRateDto.setAmendUtilizationRate(comRateDto.getAmendUtilizationRate().setScale(2, RoundingMode.HALF_UP));
+// comRateDto.setProcessLong(comRateDto.getProcessLong().divide(new BigDecimal("3600"), 2, RoundingMode.HALF_UP));
+// dataList.add(comRateDto);
+// } else {
+// ComRateDto comRateDto = new ComRateDto();
+// comRateDto.setTheMonth(month);
+// dataList.add(comRateDto);
+// }
+// });
+// result.put("dataList", dataList);
+//
+// if (StringUtils.isNotBlank(vo.getShiftId())) {
+// List<MdcShiftSub> shiftSubList = mdcShiftSubService.list(new LambdaQueryWrapper<MdcShiftSub>().eq(MdcShiftSub::getShiftId, vo.getShiftId()));
+// if (shiftSubList == null || shiftSubList.isEmpty()) {
+// return result;
+// }
+// List<String> shiftSubNameList = shiftSubList.stream().map(MdcShiftSub::getShiftSubName).collect(Collectors.toList());
+// result.put("shiftSubList", shiftSubNameList);
+//
+// List<ComShiftRateDto> comShiftRateDtoList = mdcEfficiencyReportMapper.comprehensiveShiftRateAnalyze(equipmentIdList, startStr, endStr, vo.getShiftId());
+// Map<String, List<ComShiftRateDto>> groupMap;
+// if (comShiftRateDtoList != null && !comShiftRateDtoList.isEmpty()) {
+// groupMap = comShiftRateDtoList.stream().collect(Collectors.groupingBy(ComShiftRateDto::getShiftSub));
+// } else {
+// groupMap = new HashMap<>();
+// }
+// List<ComShiftDto> shiftDataList = new ArrayList<>();
+// shiftSubList.forEach(mdcShiftSub -> {
+// ComShiftDto comShiftDto = new ComShiftDto();
+// comShiftDto.setShiftSubName(mdcShiftSub.getShiftSubName());
+// if (groupMap.containsKey(mdcShiftSub.getId())) {
+// List<ComShiftRateDto> csrd = groupMap.get(mdcShiftSub.getId());
+// Map<String, ComShiftRateDto> collect = csrd.stream().collect(Collectors.toMap(ComShiftRateDto::getTheMonth, comShiftRateDto -> comShiftRateDto));
+// List<ComShiftChildDto> comShiftChildDtoList = new ArrayList<>();
+// monthBetween.forEach(date -> {
+// String d = date.replaceAll("-", "");
+// String month = date.substring(date.lastIndexOf("-") + 1).replaceFirst("^0*", "") + "鏈�";
+// if (collect.containsKey(d)) {
+// ComShiftRateDto comShiftRateDto = collect.get(d);
+// ComShiftChildDto comShiftChildDto = new ComShiftChildDto();
+// comShiftChildDto.setMonth(month);
+// comShiftChildDto.setUtilizationRate(comShiftRateDto.getUtilizationRate().setScale(2, RoundingMode.HALF_UP));
+// comShiftChildDtoList.add(comShiftChildDto);
+// } else {
+// ComShiftChildDto comShiftChildDto = new ComShiftChildDto();
+// comShiftChildDto.setMonth(month);
+// comShiftChildDtoList.add(comShiftChildDto);
+// }
+// });
+// comShiftDto.setDataList(comShiftChildDtoList);
+// } else {
+// List<ComShiftChildDto> comShiftChildDtoList = new ArrayList<>();
+// monthBetween.forEach(date -> {
+// String month = date.substring(date.lastIndexOf("-") + 1).replaceFirst("^0*", "") + "鏈�";
+// ComShiftChildDto comShiftChildDto = new ComShiftChildDto();
+// comShiftChildDto.setMonth(month);
+// comShiftChildDtoList.add(comShiftChildDto);
+// });
+// comShiftDto.setDataList(comShiftChildDtoList);
+// }
+// shiftDataList.add(comShiftDto);
+// });
+//
+// result.put("shiftDataList", shiftDataList);
+// }
+//
+// return result;
+// }
// 鎻愬彇鐨勫钩鍧囧�艰绠楁柟娉�
private TeamEquEffDto calculateAverages(List<TeamEquEffDto> items) {
@@ -2170,9 +2164,9 @@
mdcEfficiencyResultDto.setOpenLong(efficiencyDto.getOpenLong());
mdcEfficiencyResultDto.setWaitLong(efficiencyDto.getWaitLong());
mdcEfficiencyResultDto.setCloseLong(efficiencyDto.getCloseLong());
- mdcEfficiencyResultDto.setFaultLong(efficiencyDto.getFaultLong());
- mdcEfficiencyResultDto.setFaultRate(efficiencyDto.getFaultRate());
- mdcEfficiencyResultDto.setRemoveFaultRunLong(efficiencyDto.getRemoveFaultRunLong());
+// mdcEfficiencyResultDto.setFaultLong(efficiencyDto.getFaultLong());
+// mdcEfficiencyResultDto.setFaultRate(efficiencyDto.getFaultRate());
+// mdcEfficiencyResultDto.setRemoveFaultRunLong(efficiencyDto.getRemoveFaultRunLong());
long rate = efficiencyDto.getUtilizationRate().multiply(new BigDecimal("100")).longValue();
for (MdcUtilizationRate mdcUtilizationRate : mdcUtilizationRateList) {
if (rate >= mdcUtilizationRate.getMinimumRange() && rate < mdcUtilizationRate.getMaximumRange()) {
@@ -2190,9 +2184,9 @@
mdcEfficiencyResultDto.setOpenLong(new BigDecimal("0"));
mdcEfficiencyResultDto.setWaitLong(new BigDecimal("0"));
mdcEfficiencyResultDto.setCloseLong(new BigDecimal("0"));
- mdcEfficiencyResultDto.setFaultLong(new BigDecimal("0"));
- mdcEfficiencyResultDto.setFaultRate(new BigDecimal("0"));
- mdcEfficiencyResultDto.setRemoveFaultRunLong(new BigDecimal("0"));
+// mdcEfficiencyResultDto.setFaultLong(new BigDecimal("0"));
+// mdcEfficiencyResultDto.setFaultRate(new BigDecimal("0"));
+// mdcEfficiencyResultDto.setRemoveFaultRunLong(new BigDecimal("0"));
for (MdcUtilizationRate mdcUtilizationRate : mdcUtilizationRateList) {
if (0 >= mdcUtilizationRate.getMinimumRange() && 0 < mdcUtilizationRate.getMaximumRange()) {
mdcEfficiencyResultDto.setColor(mdcUtilizationRate.getRateParameterColor());
@@ -2208,9 +2202,9 @@
mdcEfficiencyResultDto.setOpenLong(new BigDecimal("0"));
mdcEfficiencyResultDto.setWaitLong(new BigDecimal("0"));
mdcEfficiencyResultDto.setCloseLong(new BigDecimal("0"));
- mdcEfficiencyResultDto.setFaultLong(new BigDecimal("0"));
- mdcEfficiencyResultDto.setFaultRate(new BigDecimal("0"));
- mdcEfficiencyResultDto.setRemoveFaultRunLong(new BigDecimal("0"));
+// mdcEfficiencyResultDto.setFaultLong(new BigDecimal("0"));
+// mdcEfficiencyResultDto.setFaultRate(new BigDecimal("0"));
+// mdcEfficiencyResultDto.setRemoveFaultRunLong(new BigDecimal("0"));
for (MdcUtilizationRate mdcUtilizationRate : mdcUtilizationRateList) {
if (0 >= mdcUtilizationRate.getMinimumRange() && 0 < mdcUtilizationRate.getMaximumRange()) {
mdcEfficiencyResultDto.setColor(mdcUtilizationRate.getRateParameterColor());
@@ -2224,9 +2218,9 @@
efficiencyResultDto.setOpenLong(efficiencyResultDto.getOpenLong().add(mdcEfficiencyResultDto.getOpenLong()));
efficiencyResultDto.setWaitLong(efficiencyResultDto.getWaitLong().add(mdcEfficiencyResultDto.getWaitLong()));
efficiencyResultDto.setCloseLong(efficiencyResultDto.getCloseLong().add(mdcEfficiencyResultDto.getCloseLong()));
- efficiencyResultDto.setFaultLong(efficiencyResultDto.getFaultLong().add(mdcEfficiencyResultDto.getFaultLong()));
- efficiencyResultDto.setFaultRate(efficiencyResultDto.getFaultRate().add(mdcEfficiencyResultDto.getFaultRate()));
- efficiencyResultDto.setRemoveFaultRunLong(efficiencyResultDto.getRemoveFaultRunLong().add(mdcEfficiencyResultDto.getRemoveFaultRunLong()));
+// efficiencyResultDto.setFaultLong(efficiencyResultDto.getFaultLong().add(mdcEfficiencyResultDto.getFaultLong()));
+// efficiencyResultDto.setFaultRate(efficiencyResultDto.getFaultRate().add(mdcEfficiencyResultDto.getFaultRate()));
+// efficiencyResultDto.setRemoveFaultRunLong(efficiencyResultDto.getRemoveFaultRunLong().add(mdcEfficiencyResultDto.getRemoveFaultRunLong()));
return mdcEfficiencyResultDto;
}
--
Gitblit v1.9.3