From 435c2e83b4caefee5676fedfd7a27d7b0362693d Mon Sep 17 00:00:00 2001 From: Lius <Lius2225@163.com> Date: 星期五, 27 九月 2024 15:19:32 +0800 Subject: [PATCH] update --- lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/vo/OeeStatisticsVo.java | 36 +++++++++ lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcOverallEquipmentEfficiencyMapper.xml | 30 +++++++ lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/IMdcOverallEquipmentEfficiencyService.java | 18 ++++ lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/vo/OeeStatisticsChartVo.java | 21 +++++ lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/MdcOverallEquipmentEfficiencyMapper.java | 6 + lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/controller/MdcOverallEquipmentEfficiencyController.java | 23 +++++ lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcOverallEquipmentEfficiencyServiceImpl.java | 80 +++++++++++++++++++- 7 files changed, 210 insertions(+), 4 deletions(-) diff --git a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/controller/MdcOverallEquipmentEfficiencyController.java b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/controller/MdcOverallEquipmentEfficiencyController.java index 7d16641..2ab1438 100644 --- a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/controller/MdcOverallEquipmentEfficiencyController.java +++ b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/controller/MdcOverallEquipmentEfficiencyController.java @@ -13,6 +13,8 @@ import org.jeecg.modules.mdc.entity.MdcOverallEquipmentEfficiency; import org.jeecg.modules.mdc.service.IMdcOverallEquipmentEfficiencyService; import org.jeecg.modules.mdc.vo.MdcOverallEquipmentEfficiencyVo; +import org.jeecg.modules.mdc.vo.OeeStatisticsChartVo; +import org.jeecg.modules.mdc.vo.OeeStatisticsVo; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; @@ -20,6 +22,7 @@ import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; +import java.util.List; /** * @Description: OEE璁惧缁煎悎鏁堢巼琛� @@ -58,5 +61,25 @@ return Result.OK(pageList); } + /** + * + * @return + */ + @AutoLog(value = "OEE璁惧缁煎悎鏁堢巼琛�-oee缁熻") + @ApiOperation(value = "OEE璁惧缁煎悎鏁堢巼琛�-oee缁熻", notes = "OEE璁惧缁煎悎鏁堢巼琛�-oee缁熻") + @GetMapping("/oeeStatisticsList") + public Result oeeStatisticsList(String date) { + List<OeeStatisticsVo> result = mdcOverallEquipmentEfficiencyService.oeeStatisticsList(date); + return Result.OK(result); + } + + @AutoLog(value = "OEE璁惧缁煎悎鏁堢巼琛�-oee缁熻鏌辩姸鍥�") + @ApiOperation(value = "OEE璁惧缁煎悎鏁堢巼琛�-oee缁熻鏌辩姸鍥�", notes = "OEE璁惧缁煎悎鏁堢巼琛�-oee缁熻鏌辩姸鍥�") + @GetMapping("/oeeStatisticsChart") + public Result oeeStatisticsChart(String date, String equipmentType) { + List<OeeStatisticsChartVo> result = mdcOverallEquipmentEfficiencyService.oeeStatisticsChart(date, equipmentType); + return Result.OK(result); + } + } diff --git a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/MdcOverallEquipmentEfficiencyMapper.java b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/MdcOverallEquipmentEfficiencyMapper.java index a6de59d..8fef015 100644 --- a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/MdcOverallEquipmentEfficiencyMapper.java +++ b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/MdcOverallEquipmentEfficiencyMapper.java @@ -7,6 +7,9 @@ import org.jeecg.modules.mdc.entity.MdcOverallEquipmentEfficiency; import org.jeecg.modules.mdc.vo.MdcOverallEquipmentEfficiencyVo; +import java.math.BigDecimal; +import java.util.List; + /** * @author Lius * @date 2023/11/3 14:29 @@ -22,4 +25,7 @@ */ IPage<MdcOverallEquipmentEfficiency> pageList(Page<MdcOverallEquipmentEfficiency> page, @Param("mdcOverallEquipmentEfficiency") MdcOverallEquipmentEfficiencyVo mdcOverallEquipmentEfficiencyVo); + List<MdcOverallEquipmentEfficiency> findOeeByDate(@Param("date") String date, @Param("productionId") String id); + + BigDecimal findAvgOee(@Param("date") String date, @Param("equipmentType") String equipmentType, @Param("productionId") String id); } diff --git a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcOverallEquipmentEfficiencyMapper.xml b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcOverallEquipmentEfficiencyMapper.xml index 9ee2316..801e2da 100644 --- a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcOverallEquipmentEfficiencyMapper.xml +++ b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcOverallEquipmentEfficiencyMapper.xml @@ -79,4 +79,34 @@ AND t2.device_abnormal_status = 1 </where> </select> + + + <select id="findOeeByDate" resultType="org.jeecg.modules.mdc.entity.MdcOverallEquipmentEfficiency"> + SELECT + t1.* + FROM + mdc_overall_equipment_efficiency t1 + LEFT JOIN mdc_equipment t2 ON t1.equipment_id = t2.equipment_id + LEFT JOIN mdc_production_equipment t3 ON t2.id = t3.equipment_id + LEFT JOIN mdc_production t4 ON t4.id = t3.production_id + WHERE + ( t4.id = #{productionId} OR t4.parent_id = #{productionId} ) + AND t1.valid_date = #{date} + </select> + + <select id="findAvgOee" resultType="java.math.BigDecimal"> + SELECT + SUM( t1.overall_equipment_efficiency ) / COUNT ( t1.equipment_id ) oee + FROM + mdc_overall_equipment_efficiency t1 + LEFT JOIN mdc_equipment t2 ON t1.equipment_id = t2.equipment_id + LEFT JOIN mdc_production_equipment t3 ON t2.id = t3.equipment_id + LEFT JOIN mdc_production t4 ON t4.id = t3.production_id + WHERE + ( t4.id = #{productionId} OR t4.parent_id = #{productionId} ) + AND t1.valid_date = #{date} + <if test="equipmentType != null and equipmentType != ''"> + AND t2.equipment_type = #{equipmentType} + </if> + </select> </mapper> \ No newline at end of file diff --git a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/IMdcOverallEquipmentEfficiencyService.java b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/IMdcOverallEquipmentEfficiencyService.java index 58d4635..2cc3fd9 100644 --- a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/IMdcOverallEquipmentEfficiencyService.java +++ b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/IMdcOverallEquipmentEfficiencyService.java @@ -5,8 +5,11 @@ import com.baomidou.mybatisplus.extension.service.IService; import org.jeecg.modules.mdc.entity.MdcOverallEquipmentEfficiency; import org.jeecg.modules.mdc.vo.MdcOverallEquipmentEfficiencyVo; +import org.jeecg.modules.mdc.vo.OeeStatisticsChartVo; +import org.jeecg.modules.mdc.vo.OeeStatisticsVo; import javax.servlet.http.HttpServletRequest; +import java.util.List; /** * @author: LiuS @@ -29,4 +32,19 @@ * @return */ IPage<MdcOverallEquipmentEfficiency> pageList(String userId, Page<MdcOverallEquipmentEfficiency> page, MdcOverallEquipmentEfficiencyVo mdcOverallEquipmentEfficiencyVo, HttpServletRequest req); + + /** + * + * @param date + * @return + */ + List<OeeStatisticsVo> oeeStatisticsList(String date); + + /** + * + * @param date + * @param equipmentType + * @return + */ + List<OeeStatisticsChartVo> oeeStatisticsChart(String date, String equipmentType); } diff --git a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcOverallEquipmentEfficiencyServiceImpl.java b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcOverallEquipmentEfficiencyServiceImpl.java index e7f137d..10f3bdf 100644 --- a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcOverallEquipmentEfficiencyServiceImpl.java +++ b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcOverallEquipmentEfficiencyServiceImpl.java @@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import org.apache.commons.lang3.StringUtils; +import org.jeecg.common.constant.CommonConstant; import org.jeecg.modules.mdc.constant.MdcConstant; import org.jeecg.modules.mdc.entity.MdcEquipment; import org.jeecg.modules.mdc.entity.MdcOverallEquipmentEfficiency; @@ -12,6 +13,8 @@ import org.jeecg.modules.mdc.service.*; import org.jeecg.modules.mdc.util.DateUtils; import org.jeecg.modules.mdc.vo.MdcOverallEquipmentEfficiencyVo; +import org.jeecg.modules.mdc.vo.OeeStatisticsChartVo; +import org.jeecg.modules.mdc.vo.OeeStatisticsVo; import org.jeecg.modules.system.entity.MdcProduction; import org.jeecg.modules.system.service.IMdcProductionService; import org.springframework.stereotype.Service; @@ -20,11 +23,11 @@ import javax.servlet.http.HttpServletRequest; import java.math.BigDecimal; import java.math.RoundingMode; +import java.time.LocalDate; import java.time.YearMonth; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.List; +import java.time.format.DateTimeFormatter; +import java.util.*; +import java.util.stream.Collectors; /** * @author: LiuS @@ -316,6 +319,75 @@ return mdcOverallEquipmentEfficiencyIPage; } + /** + * + * @param date + * @return + */ + @Override + public List<OeeStatisticsVo> oeeStatisticsList(String date) { + List<OeeStatisticsVo> result = new ArrayList<>(); + if (StringUtils.isEmpty(date)) { + date = DateTimeFormatter.ofPattern("yyyy-MM").format(LocalDate.now().plusMonths(-1)); + } + List<MdcProduction> mdcProductionList = mdcProductionService.list(new LambdaQueryWrapper<MdcProduction>().eq(MdcProduction::getOrgType, 2).eq(MdcProduction::getDelFlag, CommonConstant.DEL_FLAG_0)); + if (mdcProductionList != null && !mdcProductionList.isEmpty()) { + for (MdcProduction mdcProduction : mdcProductionList) { + OeeStatisticsVo oeeStatisticsVo = new OeeStatisticsVo(); + oeeStatisticsVo.setProductionName(mdcProduction.getProductionName()); + List<MdcOverallEquipmentEfficiency> mdcOverallEquipmentEfficiencyList = this.baseMapper.findOeeByDate(date, mdcProduction.getId()); + if (mdcOverallEquipmentEfficiencyList != null && !mdcOverallEquipmentEfficiencyList.isEmpty()) { + for (MdcOverallEquipmentEfficiency mdcOverallEquipmentEfficiency : mdcOverallEquipmentEfficiencyList) { + int oee = mdcOverallEquipmentEfficiency.getOverallEquipmentEfficiency().multiply(new BigDecimal("10000")).intValue(); + if (oee < 500) { + oeeStatisticsVo.setLevel1(oeeStatisticsVo.getLevel1() + 1); + } else if (oee >= 500 && oee < 1000) { + oeeStatisticsVo.setLevel2(oeeStatisticsVo.getLevel2() + 1); + } else if (oee >= 1000 && oee < 3000) { + oeeStatisticsVo.setLevel3(oeeStatisticsVo.getLevel3() + 1); + } else if (oee >= 3000 && oee < 6000) { + oeeStatisticsVo.setLevel4(oeeStatisticsVo.getLevel4() + 1); + } else if (oee >= 6000) { + oeeStatisticsVo.setLevel5(oeeStatisticsVo.getLevel5() + 1); + } + } + } + result.add(oeeStatisticsVo); + } + } + return result; + } + + /** + * + * @param date + * @param equipmentType + * @return + */ + @Override + public List<OeeStatisticsChartVo> oeeStatisticsChart(String date, String equipmentType) { + List<OeeStatisticsChartVo> result = new ArrayList<>(); + if (StringUtils.isEmpty(date)) { + date = DateTimeFormatter.ofPattern("yyyy-MM").format(LocalDate.now().plusMonths(-1)); + } + List<MdcProduction> mdcProductionList = mdcProductionService.list(new LambdaQueryWrapper<MdcProduction>().eq(MdcProduction::getOrgType, 2).eq(MdcProduction::getDelFlag, CommonConstant.DEL_FLAG_0)); + if (mdcProductionList != null && !mdcProductionList.isEmpty()) { + for (MdcProduction mdcProduction : mdcProductionList) { + OeeStatisticsChartVo oeeStatisticsChartVo = new OeeStatisticsChartVo(); + oeeStatisticsChartVo.setKey(mdcProduction.getProductionName()); + BigDecimal oee = this.baseMapper.findAvgOee(date, equipmentType, mdcProduction.getId()); + if (oee != null) { + oeeStatisticsChartVo.setValue(oee); + } + result.add(oeeStatisticsChartVo); + } + } + if (!result.isEmpty()) { + result = result.stream().sorted(Comparator.comparing(OeeStatisticsChartVo::getValue)).collect(Collectors.toList()); + } + return result; + } + /** * 閫掑綊鏌ヨ璁惧杞﹂棿鍚嶇О diff --git a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/vo/OeeStatisticsChartVo.java b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/vo/OeeStatisticsChartVo.java new file mode 100644 index 0000000..9321675 --- /dev/null +++ b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/vo/OeeStatisticsChartVo.java @@ -0,0 +1,21 @@ +package org.jeecg.modules.mdc.vo; + +import lombok.Data; + +import java.math.BigDecimal; + +/** + * @author Lius + * @date 2024/9/27 14:17 + */ +@Data +public class OeeStatisticsChartVo { + /** + * 杞﹂棿鍚嶇О + */ + private String key; + /** + * oee + */ + private BigDecimal value = BigDecimal.ZERO; +} diff --git a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/vo/OeeStatisticsVo.java b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/vo/OeeStatisticsVo.java new file mode 100644 index 0000000..d19a0e6 --- /dev/null +++ b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/vo/OeeStatisticsVo.java @@ -0,0 +1,36 @@ +package org.jeecg.modules.mdc.vo; + +import lombok.Data; + +/** + * @author Lius + * @date 2024/9/27 10:19 + */ +@Data +public class OeeStatisticsVo { + + /** + * 浣跨敤鍗曚綅 + */ + private String productionName; + /** + * 灏忎簬5% + */ + private Integer level1 = 0; + /** + * 5%-10% + */ + private Integer level2 = 0; + /** + * 10%-30% + */ + private Integer level3 = 0; + /** + * 30%-60% + */ + private Integer level4 = 0; + /** + * 60%浠ヤ笂 + */ + private Integer level5 = 0; +} -- Gitblit v1.9.3