From 680a66f5aad3dc6fc41251db8ee2e8a263a34fb7 Mon Sep 17 00:00:00 2001 From: Lius <Lius2225@163.com> Date: 星期五, 28 三月 2025 14:20:47 +0800 Subject: [PATCH] 班组综合利用率图表接口 --- lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/vo/EquEffVo.java | 6 + lxzn-module-mdc-common/src/main/java/org/jeecg/modules/mdc/mapper/MdcEquipmentMapper.java | 3 lxzn-module-mdc-common/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcEquipmentMapper.xml | 16 +++ lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/dto/EquipmentEfficiencyAnalyzeDto.java | 2 lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/dto/UtilizationRateAvg.java | 9 + lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/MdcEfficiencyReportService.java | 4 lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/dto/TeamEquEffDto.java | 45 +++++++++ lxzn-module-mdc-common/src/main/java/org/jeecg/modules/mdc/service/impl/MdcEquipmentServiceImpl.java | 11 ++ lxzn-module-mdc-common/src/main/java/org/jeecg/modules/mdc/service/IMdcEquipmentService.java | 8 + lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcEfficiencyReportServiceImpl.java | 109 ++++++++++++++++++++- lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/controller/MdcEfficiencyReportController.java | 18 +-- lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/MdcEfficiencyReportMapper.java | 7 + lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcEfficiencyReportMapper.xml | 22 ++++ 13 files changed, 235 insertions(+), 25 deletions(-) diff --git a/lxzn-module-mdc-common/src/main/java/org/jeecg/modules/mdc/mapper/MdcEquipmentMapper.java b/lxzn-module-mdc-common/src/main/java/org/jeecg/modules/mdc/mapper/MdcEquipmentMapper.java index 6bde87b..698af06 100644 --- a/lxzn-module-mdc-common/src/main/java/org/jeecg/modules/mdc/mapper/MdcEquipmentMapper.java +++ b/lxzn-module-mdc-common/src/main/java/org/jeecg/modules/mdc/mapper/MdcEquipmentMapper.java @@ -131,4 +131,7 @@ MdcEquipmentDetailedDto findById(@Param("id") String id); List<MdcEquipment> findByProductionIds(@Param("mdcProductionIds") List<String> mdcProductionIds); + + List<MdcEquipment> findByProIdsAndTeamCode(@Param("mdcProductionIds") List<String> mdcProductionIds, @Param("teamCodeList") List<String> teamCodeList); + } diff --git a/lxzn-module-mdc-common/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcEquipmentMapper.xml b/lxzn-module-mdc-common/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcEquipmentMapper.xml index 2fbec81..7b7f06e 100644 --- a/lxzn-module-mdc-common/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcEquipmentMapper.xml +++ b/lxzn-module-mdc-common/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcEquipmentMapper.xml @@ -308,4 +308,20 @@ </foreach> </select> + <select id="findByProIdsAndTeamCode" resultType="org.jeecg.modules.mdc.entity.MdcEquipment"> + SELECT + t1.* + FROM + mdc_equipment t1 + LEFT JOIN mdc_production_equipment t2 ON t1.id = t2.equipment_id + WHERE t2.production_id IN + <foreach collection="mdcProductionIds" item = "productionId" index = "index" open = "(" close= ")" separator = ","> + #{productionId} + </foreach> + AND t1.team_code IN + <foreach collection="teamCodeList" item = "teamCode" index = "index" open = "(" close= ")" separator = ","> + #{teamCode} + </foreach> + </select> + </mapper> diff --git a/lxzn-module-mdc-common/src/main/java/org/jeecg/modules/mdc/service/IMdcEquipmentService.java b/lxzn-module-mdc-common/src/main/java/org/jeecg/modules/mdc/service/IMdcEquipmentService.java index 51ddf0d..16fbc71 100644 --- a/lxzn-module-mdc-common/src/main/java/org/jeecg/modules/mdc/service/IMdcEquipmentService.java +++ b/lxzn-module-mdc-common/src/main/java/org/jeecg/modules/mdc/service/IMdcEquipmentService.java @@ -223,4 +223,12 @@ * @return */ List<MdcEquipment> findByProductionIds(List<String> mdcProductionIds); + + /** + * 鏍规嵁浜х嚎id闆嗗悎鍜岄厤閫佸皬缁勬煡璇㈣澶囧垪琛� + * @param allProductionIds + * @param teamCodelist + * @return + */ + List<MdcEquipment> findByProIdsAndTeamCode(List<String> allProductionIds, List<String> teamCodelist); } diff --git a/lxzn-module-mdc-common/src/main/java/org/jeecg/modules/mdc/service/impl/MdcEquipmentServiceImpl.java b/lxzn-module-mdc-common/src/main/java/org/jeecg/modules/mdc/service/impl/MdcEquipmentServiceImpl.java index f59bcfa..7281d24 100644 --- a/lxzn-module-mdc-common/src/main/java/org/jeecg/modules/mdc/service/impl/MdcEquipmentServiceImpl.java +++ b/lxzn-module-mdc-common/src/main/java/org/jeecg/modules/mdc/service/impl/MdcEquipmentServiceImpl.java @@ -1020,4 +1020,15 @@ return this.baseMapper.findByProductionIds(mdcProductionIds); } + /** + * 鏍规嵁浜х嚎id闆嗗悎鍜岄厤閫佸皬缁勬煡璇㈣澶囧垪琛� + * @param mdcProductionIds + * @param teamCodeList + * @return + */ + @Override + public List<MdcEquipment> findByProIdsAndTeamCode(List<String> mdcProductionIds, List<String> teamCodeList) { + return this.baseMapper.findByProIdsAndTeamCode(mdcProductionIds, teamCodeList); + } + } diff --git a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/controller/MdcEfficiencyReportController.java b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/controller/MdcEfficiencyReportController.java index 1e1fa15..5b0b596 100644 --- a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/controller/MdcEfficiencyReportController.java +++ b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/controller/MdcEfficiencyReportController.java @@ -5,7 +5,6 @@ import lombok.extern.slf4j.Slf4j; import org.apache.shiro.SecurityUtils; import org.jeecg.common.api.vo.Result; -import org.jeecg.common.aspect.annotation.AutoLog; import org.jeecg.common.system.vo.LoginUser; import org.jeecg.modules.mdc.dto.ComparativeAnalysisDto; import org.jeecg.modules.mdc.dto.DayUtilizationRateDto; @@ -13,7 +12,6 @@ import org.jeecg.modules.mdc.vo.*; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; import javax.annotation.Resource; @@ -131,17 +129,17 @@ // return Result.OK(result);Equipment utilization distribution of each team // } -// @ApiOperation(value = "璁惧鏁堢巼鎶ヨ〃-閰嶉�佸皬缁勭淮搴﹀悇鐝粍鏈堣澶囧埄鐢ㄥ垎甯�", notes = "璁惧鏁堢巼鎶ヨ〃-閰嶉�佸皬缁勭淮搴﹀悇鐝粍鏈堣澶囧埄鐢ㄥ垎甯�") -// @GetMapping("/teamEquipmentEfficiencyAnalyze") -// public Result teamEquipmentEfficiencyAnalyze(TeamEquEffVo teamEquEffVo) { -// Map<String, Object> result = mdcEfficiencyReportService.teamEquipmentEfficiencyAnalyze(teamEquEffVo); -// return Result.OK(result); -// } + @ApiOperation(value = "璁惧鏁堢巼鎶ヨ〃-閰嶉�佸皬缁勭淮搴﹀悇鐝粍鏈堣澶囧埄鐢ㄥ垎甯�", notes = "璁惧鏁堢巼鎶ヨ〃-閰嶉�佸皬缁勭淮搴﹀悇鐝粍鏈堣澶囧埄鐢ㄥ垎甯�") + @GetMapping("/teamEquipmentEfficiencyAnalyze") + public Result<?> teamEquipmentEfficiencyAnalyze(EquEffVo equEffVo) { + Map<String, Object> result = mdcEfficiencyReportService.teamEquipmentEfficiencyAnalyze(equEffVo); + return Result.OK(result); + } @ApiOperation(value = "璁惧鏁堢巼鎶ヨ〃-璁惧缁村害鍚勭彮缁勬湀璁惧鍒╃敤鍒嗗竷", notes = "璁惧鏁堢巼鎶ヨ〃-璁惧缁村害鍚勭彮缁勬湀璁惧鍒╃敤鍒嗗竷") @GetMapping("/equipmentEfficiencyAnalyze") - public Result<?> equipmentEfficiencyAnalyze(TeamEquEffVo teamEquEffVo) { - Map<String, Object> result = mdcEfficiencyReportService.teamEquipmentEfficiencyAnalyze(teamEquEffVo); + public Result<?> equipmentEfficiencyAnalyze(EquEffVo equEffVo) { + Map<String, Object> result = mdcEfficiencyReportService.equipmentEfficiencyAnalyze(equEffVo); return Result.OK(result); } diff --git a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/dto/TeamEquipmentEfficiencyAnalyzeDto.java b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/dto/EquipmentEfficiencyAnalyzeDto.java similarity index 91% rename from lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/dto/TeamEquipmentEfficiencyAnalyzeDto.java rename to lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/dto/EquipmentEfficiencyAnalyzeDto.java index 9b1376d..aabf938 100644 --- a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/dto/TeamEquipmentEfficiencyAnalyzeDto.java +++ b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/dto/EquipmentEfficiencyAnalyzeDto.java @@ -10,7 +10,7 @@ * @Description: */ @Data -public class TeamEquipmentEfficiencyAnalyzeDto { +public class EquipmentEfficiencyAnalyzeDto { private String equipmentName; diff --git a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/dto/TeamEquEffDto.java b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/dto/TeamEquEffDto.java new file mode 100644 index 0000000..2f25ca5 --- /dev/null +++ b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/dto/TeamEquEffDto.java @@ -0,0 +1,45 @@ +package org.jeecg.modules.mdc.dto; + +import lombok.Data; + +import java.math.BigDecimal; + +/** + * @Author: Lius + * @CreateTime: 2025-03-28 + * @Description: + */ +@Data +public class TeamEquEffDto { + + private String teamCode; + + /** + * 鍒╃敤鐜� + */ + private BigDecimal utilizationRate = BigDecimal.ZERO; + /** + * 鐝鍒╃敤鐜� + */ + private BigDecimal shiftUtilizationRate = BigDecimal.ZERO; + /** + * 淇鍒╃敤鐜� + */ + private BigDecimal amendUtilizationRate = BigDecimal.ZERO; + + public TeamEquEffDto() { + } + + public TeamEquEffDto(String teamCode, BigDecimal utilizationRate, BigDecimal shiftUtilizationRate, BigDecimal amendUtilizationRate) { + this.teamCode = teamCode; + this.utilizationRate = utilizationRate; + this.shiftUtilizationRate = shiftUtilizationRate; + this.amendUtilizationRate = amendUtilizationRate; + } + + public TeamEquEffDto(BigDecimal utilizationRate, BigDecimal shiftUtilizationRate, BigDecimal amendUtilizationRate) { + this.utilizationRate = utilizationRate; + this.shiftUtilizationRate = shiftUtilizationRate; + this.amendUtilizationRate = amendUtilizationRate; + } +} diff --git a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/dto/UtilizationRateAvg.java b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/dto/UtilizationRateAvg.java new file mode 100644 index 0000000..5a4f7ad --- /dev/null +++ b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/dto/UtilizationRateAvg.java @@ -0,0 +1,9 @@ +package org.jeecg.modules.mdc.dto; + +/** + * @Author: Lius + * @CreateTime: 2025-03-28 + * @Description: + */ +public class UtilizationRateAvg { +} diff --git a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/MdcEfficiencyReportMapper.java b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/MdcEfficiencyReportMapper.java index 24a5cc0..dcad1ab 100644 --- a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/MdcEfficiencyReportMapper.java +++ b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/MdcEfficiencyReportMapper.java @@ -3,11 +3,12 @@ import org.apache.ibatis.annotations.Param; import org.jeecg.modules.mdc.dto.MdcComAnaDto; import org.jeecg.modules.mdc.dto.MdcEfficiencyDto; +import org.jeecg.modules.mdc.dto.TeamEquEffDto; import org.jeecg.modules.mdc.entity.MdcEquipmentStatisticalShiftInfo; import org.jeecg.modules.mdc.vo.ComparativeAnalysisQueryVo; import org.jeecg.modules.mdc.vo.MdcEfficiencyReportQueryVo; import org.jeecg.modules.mdc.vo.MdcEfficiencyReportShiftQueryVo; -import org.jeecg.modules.mdc.dto.TeamEquipmentEfficiencyAnalyzeDto; +import org.jeecg.modules.mdc.dto.EquipmentEfficiencyAnalyzeDto; import java.math.BigDecimal; import java.util.List; @@ -52,5 +53,7 @@ List<BigDecimal> getEfficiencyRate(@Param("equipmentId") String equipmentId, @Param("date") String date); - List<TeamEquipmentEfficiencyAnalyzeDto> teamEquipmentEfficiencyAnalyze(@Param("equipmentIdList") List<String> equipmentIdList, @Param("month") String month); + List<EquipmentEfficiencyAnalyzeDto> equipmentEfficiencyAnalyze(@Param("equipmentIdList") List<String> equipmentIdList, @Param("month") String month); + + List<TeamEquEffDto> teamEquipmentEfficiencyAnalyze(@Param("equipmentIdList") List<String> equipmentIdList, @Param("month") String month); } diff --git a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcEfficiencyReportMapper.xml b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcEfficiencyReportMapper.xml index 4458f0d..c706d61 100644 --- a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcEfficiencyReportMapper.xml +++ b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcEfficiencyReportMapper.xml @@ -187,7 +187,7 @@ ORDER BY the_date ASC </select> - <select id="teamEquipmentEfficiencyAnalyze" resultType="org.jeecg.modules.mdc.dto.TeamEquipmentEfficiencyAnalyzeDto"> + <select id="equipmentEfficiencyAnalyze" resultType="org.jeecg.modules.mdc.dto.EquipmentEfficiencyAnalyzeDto"> SELECT t3.equipment_name, t1.utilization_rate AS utilizationRate, @@ -202,8 +202,26 @@ <foreach collection="equipmentIdList" item="id" index="index" open="(" close=")" separator=","> #{id} </foreach> - AND t1.the_month = #{month} + AND t1.the_month = #{month} ORDER BY t1.utilization_rate DESC </select> + + <select id="teamEquipmentEfficiencyAnalyze" resultType="org.jeecg.modules.mdc.dto.TeamEquEffDto"> + SELECT + t3.team_code AS teamCode, + t1.utilization_rate AS utilizationRate, + t2.utilization_rate AS shiftUtilizationRate + FROM + mdc_equipment_statistical_info_month t1 + LEFT JOIN mdc_equipment_statistical_shift_info_month t2 ON t1.the_month = t2.the_month + AND t1.equipment_id = t2.equipment_id + LEFT JOIN mdc_equipment t3 ON t3.equipment_id = t1.equipment_id + WHERE + t1.equipment_id IN + <foreach collection="equipmentIdList" item="id" index="index" open="(" close=")" separator=","> + #{id} + </foreach> + AND t1.the_month = #{month} + </select> </mapper> \ No newline at end of file diff --git a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/MdcEfficiencyReportService.java b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/MdcEfficiencyReportService.java index 4862710..30b2f0c 100644 --- a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/MdcEfficiencyReportService.java +++ b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/MdcEfficiencyReportService.java @@ -104,5 +104,7 @@ */ List<BigDecimal> getEfficiencyRate(String equipmentId, String date); - Map<String, Object> teamEquipmentEfficiencyAnalyze(TeamEquEffVo teamEquEffVo); + Map<String, Object> equipmentEfficiencyAnalyze(EquEffVo equEffVo); + + Map<String, Object> teamEquipmentEfficiencyAnalyze(EquEffVo equEffVo); } 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 fde18f5..0d7ebe1 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 @@ -4,6 +4,7 @@ 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.mdc.dto.*; import org.jeecg.modules.mdc.entity.*; import org.jeecg.modules.mdc.mapper.MdcEfficiencyReportMapper; @@ -15,6 +16,7 @@ import org.jeecg.modules.system.entity.SysDepart; import org.jeecg.modules.system.service.IMdcProductionService; import org.jeecg.modules.system.service.ISysDepartService; +import org.jeecg.modules.system.service.ISysDictService; import org.springframework.stereotype.Service; import javax.annotation.Resource; @@ -24,6 +26,7 @@ import java.time.format.DateTimeFormatter; import java.time.temporal.ChronoUnit; import java.util.*; +import java.util.function.Function; import java.util.stream.Collectors; /** @@ -53,6 +56,9 @@ @Resource private IMdcEquipmentRunningSectionService mdcEquipmentRunningSectionService; + + @Resource + private ISysDictService sysDictService; /** * 鍒╃敤鐜囨姤琛� @@ -1739,28 +1745,115 @@ /** * 鐝粍鍚勮澶囩患鍚堝埄鐢ㄧ巼 * - * @param teamEquEffVo + * @param equEffVo * @return */ @Override - public Map<String, Object> teamEquipmentEfficiencyAnalyze(TeamEquEffVo teamEquEffVo) { + public Map<String, Object> equipmentEfficiencyAnalyze(EquEffVo equEffVo) { Map<String, Object> result = new HashMap<>(); List<String> mdcProductionIds = new ArrayList<>(); - if (StringUtils.isEmpty(teamEquEffVo.getProductionIds())) { - mdcProductionIds.add(teamEquEffVo.getProductionId()); + if (StringUtils.isBlank(equEffVo.getProductionIds())) { + mdcProductionIds.add(equEffVo.getProductionId()); } else { - mdcProductionIds.addAll(Arrays.asList(teamEquEffVo.getProductionIds().split(","))); + mdcProductionIds.addAll(Arrays.asList(equEffVo.getProductionIds().split(","))); } List<String> allProductionIds = mdcProductionService.findChildren(mdcProductionIds); List<MdcEquipment> equipmentList = mdcEquipmentService.findByProductionIds(allProductionIds); if (equipmentList != null && !equipmentList.isEmpty()) { List<String> equipmentIdList = equipmentList.stream().map(MdcEquipment::getEquipmentId).collect(Collectors.toList()); - List<TeamEquipmentEfficiencyAnalyzeDto> dataList = mdcEfficiencyReportMapper.teamEquipmentEfficiencyAnalyze(equipmentIdList, teamEquEffVo.getMonth()); + List<EquipmentEfficiencyAnalyzeDto> dataList = mdcEfficiencyReportMapper.equipmentEfficiencyAnalyze(equipmentIdList, equEffVo.getMonth()); result.put("dataList", dataList); - List<String> equipmentNameList = dataList.stream().map(TeamEquipmentEfficiencyAnalyzeDto::getEquipmentName).collect(Collectors.toList()); + List<String> equipmentNameList = dataList.stream().map(EquipmentEfficiencyAnalyzeDto::getEquipmentName).collect(Collectors.toList()); result.put("equipmentNameList", equipmentNameList); } return result; + } + + @Override + public Map<String, Object> teamEquipmentEfficiencyAnalyze(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; // 鎻愬墠杩斿洖绌虹粨鏋� + } + + // 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; + + } + + // 鎻愬彇鐨勫钩鍧囧�艰绠楁柟娉� + private TeamEquEffDto calculateAverages(List<TeamEquEffDto> items) { + BigDecimal size = new BigDecimal(items.size()); + return new TeamEquEffDto( + calculateAverage(items, TeamEquEffDto::getUtilizationRate, size), + calculateAverage(items, TeamEquEffDto::getShiftUtilizationRate, size), + calculateAverage(items, TeamEquEffDto::getAmendUtilizationRate, size) + ); + } + + // 閫氱敤鐨勫钩鍧囧�艰绠� + private BigDecimal calculateAverage(List<TeamEquEffDto> items, Function<TeamEquEffDto, BigDecimal> mapper, BigDecimal size) { + return items.stream() + .map(mapper) + .reduce(BigDecimal.ZERO, BigDecimal::add) + .divide(size, 2, RoundingMode.HALF_UP); + } + + // 鏋勫缓缁撴灉DTO + private TeamEquEffDto buildResultDto(Map.Entry<String, TeamEquEffDto> entry, Map<String, String> dictMap) { + TeamEquEffDto dto = entry.getValue(); + dto.setTeamCode(dictMap.getOrDefault(entry.getKey(), entry.getKey())); + return dto; } private MdcUtilizationResultDto utilizationRate(String equipmentId, String equipmentName, String equipmentType, Date startTime, Date endTime, String date, List<MdcUtilizationRate> mdcUtilizationRateList) { @@ -1787,7 +1880,7 @@ } } BigDecimal totalLong = new BigDecimal(DateUtils.differentSecond(startTime, endTime)); - BigDecimal utilizationRate = processLong.divide(totalLong, 6, BigDecimal.ROUND_HALF_UP); + BigDecimal utilizationRate = processLong.divide(totalLong, 6, RoundingMode.HALF_UP); dto.setUtilizationRate(utilizationRate); } else { dto.setUtilizationRate(new BigDecimal("0")); diff --git a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/vo/TeamEquEffVo.java b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/vo/EquEffVo.java similarity index 77% rename from lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/vo/TeamEquEffVo.java rename to lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/vo/EquEffVo.java index bc51746..70b0175 100644 --- a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/vo/TeamEquEffVo.java +++ b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/vo/EquEffVo.java @@ -8,7 +8,7 @@ * @Description: */ @Data -public class TeamEquEffVo { +public class EquEffVo { /** * 涓績 @@ -19,6 +19,10 @@ */ private String productionIds; /** + * 閰嶉�佸皬缁処D + */ + private String teamCodes; + /** * 鏈堜唤 */ private String month; -- Gitblit v1.9.3