From 2fd5cedf6e6aedc2fdd089c38fee6194a6dea3e5 Mon Sep 17 00:00:00 2001 From: Lius <Lius2225@163.com> Date: 星期四, 18 四月 2024 10:37:35 +0800 Subject: [PATCH] 前七天利用率折线图接口修改 --- lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/IMdcHomeServiceImpl.java | 97 ++++++++++++++++++++++++++++++++++++++++++++++-- 1 files changed, 92 insertions(+), 5 deletions(-) diff --git a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/IMdcHomeServiceImpl.java b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/IMdcHomeServiceImpl.java index 5b19e55..50938c4 100644 --- a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/IMdcHomeServiceImpl.java +++ b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/IMdcHomeServiceImpl.java @@ -1,7 +1,9 @@ package org.jeecg.modules.mdc.service.impl; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.toolkit.StringUtils; import org.jeecg.modules.mdc.entity.EquipmentLog; +import org.jeecg.modules.mdc.entity.MdcEquipment; import org.jeecg.modules.mdc.entity.MdcEquipmentStatisticalInfo; import org.jeecg.modules.mdc.entity.MdcOverallEquipmentEfficiency; import org.jeecg.modules.mdc.mapper.MdcHomeMapper; @@ -9,11 +11,9 @@ import org.jeecg.modules.mdc.service.IMdcEquipmentService; import org.jeecg.modules.mdc.service.IMdcHomeService; import org.jeecg.modules.mdc.util.DateUtils; -import org.jeecg.modules.mdc.vo.EquipmentDayUtilizationVo; -import org.jeecg.modules.mdc.vo.MdcCommonVo; -import org.jeecg.modules.mdc.vo.MdcEquipmentStatusVo; -import org.jeecg.modules.mdc.vo.MdcHomeEfficiencyVo; +import org.jeecg.modules.mdc.vo.*; import org.jeecg.modules.system.entity.MdcProduction; +import org.jeecg.modules.system.service.IMdcProductionService; import org.springframework.stereotype.Service; import javax.annotation.Resource; @@ -37,6 +37,9 @@ @Resource private MdcHomeMapper mdcHomeMapper; + + @Resource + private IMdcProductionService mdcProductionService; /** * 璁惧杩愯鐘舵�佺粺璁� @@ -142,6 +145,9 @@ result.add(mdcCommonVo); } } + if (!result.isEmpty()) { + result.sort(Comparator.comparing(MdcCommonVo::getValue).reversed()); + } return result; } @@ -246,7 +252,8 @@ String start = DateUtils.format(DateUtils.toDate(LocalDate.now().plusDays(-7).toString(), DateUtils.STR_DATE), DateUtils.STRDATE); String end = DateUtils.format(DateUtils.toDate(LocalDate.now().plusDays(-1).toString(), DateUtils.STR_DATE), DateUtils.STRDATE); if (equipmentIdList != null && !equipmentIdList.isEmpty()) { - result.put("equipmentIdList", equipmentIdList); + List<MdcEquipment> mdcEquipmentList = mdcEquipmentService.list(new LambdaQueryWrapper<MdcEquipment>().in(MdcEquipment::getEquipmentId, equipmentIdList)); + result.put("mdcEquipmentList", mdcEquipmentList); List<MdcEquipmentStatisticalInfo> mdcEquipmentStatisticalInfoList = mdcHomeMapper.getEquipmentSevenUtilizationStatistics(equipmentIdList, start, end); List<EquipmentDayUtilizationVo> dataList = new ArrayList<>(); if (mdcEquipmentStatisticalInfoList != null && !mdcEquipmentStatisticalInfoList.isEmpty()) { @@ -333,6 +340,8 @@ public MdcHomeEfficiencyVo getEquipmentEfficiencyStatistics(String userId, String key) { MdcHomeEfficiencyVo result = new MdcHomeEfficiencyVo(); result.setProductionId(key); + MdcProduction mdcProduction = mdcProductionService.getById(key); + result.setProductionName(mdcProduction.getProductionName()); List<String> equipmentIdList = mdcEquipmentService.getEquipmentIdsProduction(userId, key); if (equipmentIdList != null && !equipmentIdList.isEmpty()) { // 鑾峰彇鍒╃敤鐜囨暟鎹� @@ -356,4 +365,82 @@ } return result; } + + /** + * 璁惧绾ф晥鐜囩粺璁� + */ + @Override + public MdcHomeEfficiencyVo getEquipmentLevelEfficiencyStatistics(String equipmentId) { + MdcHomeEfficiencyVo result = new MdcHomeEfficiencyVo(); + String date = DateUtils.format(DateUtils.toDate(LocalDate.now().plusDays(-1).toString(), DateUtils.STR_DATE), DateUtils.STRDATE); + MdcEquipmentStatisticalInfo mdcEquipmentStatisticalInfo = mdcHomeMapper.getUtilizationByDay(Arrays.asList(equipmentId.split(",")), date); + if (mdcEquipmentStatisticalInfo != null) { + result.setUtilizationRate(mdcEquipmentStatisticalInfo.getProcessLong().divide(new BigDecimal("864"), 4, RoundingMode.HALF_UP).setScale(2, RoundingMode.HALF_UP)); + if (BigDecimal.ZERO.compareTo(mdcEquipmentStatisticalInfo.getOpenLong()) == -1) { + result.setOpenRate(mdcEquipmentStatisticalInfo.getProcessLong().divide(mdcEquipmentStatisticalInfo.getOpenLong(), 4, RoundingMode.HALF_UP).multiply(new BigDecimal("100")).setScale(2, RoundingMode.HALF_UP)); + result.setStartRate(mdcEquipmentStatisticalInfo.getOpenLong().divide(new BigDecimal("864"), 4, RoundingMode.HALF_UP).setScale(2, RoundingMode.HALF_UP)); + } + } + //鑾峰彇OEE鏁版嵁 + String month = DateUtils.format(DateUtils.toDate(LocalDate.now().plusMonths(-1).toString(), DateUtils.STR_DATE), DateUtils.STR_YEAR_MONTH); + BigDecimal oee = mdcHomeMapper.getOeeByDate(Arrays.asList(equipmentId.split(",")), month); + if (oee == null || oee.compareTo(BigDecimal.ZERO) == 0) { + result.setOverallEquipmentEfficiency(BigDecimal.ZERO); + } else { + result.setOverallEquipmentEfficiency(oee.multiply(new BigDecimal("100")).setScale(2, RoundingMode.HALF_UP)); + } + return result; + } + + /** + * 璁惧绾ф暣骞村害鍒╃敤鐜� + */ + @Override + public Map<String, Object> getEquipmentAnnualEfficiencyStatistics(String equipmentId) { + Map<String, Object> result = new HashMap<>(); + Date end = DateUtils.toDate(LocalDate.now().plusMonths(-1).toString(), DateUtils.STR_DATE); + Date start = DateUtils.toDate(LocalDate.now().plusMonths(-12).toString(), DateUtils.STR_DATE); + List<String> monthBetween = DateUtils.getMonthBetween(start, end); + List<String> dateList = new ArrayList<>(); + List<MdcHomeEquipmentVo> dataList = new ArrayList<>(); + for (String month : monthBetween) { + String name = month.substring(month.lastIndexOf("-") + 1).replaceFirst("^0*", "") + "鏈�"; + dateList.add(name); + //鍒╃敤鐜囧拰oee + MdcHomeEquipmentVo mdcHomeEquipmentVo = new MdcHomeEquipmentVo(); + mdcHomeEquipmentVo.setMonth(name); + //鍒╃敤鐜� + Map<String, Object> resultMap = mdcHomeMapper.getUtilizationByMonth(Arrays.asList(equipmentId.split(",")), month.replace("-", "")); + if (resultMap != null && resultMap.get("processLong") != null) { + BigDecimal processLong = BigDecimal.valueOf((Double) resultMap.get("processLong")); + BigDecimal openLong = BigDecimal.valueOf((Double) resultMap.get("openLong")); + BigDecimal processDay = new BigDecimal((Integer) resultMap.get("processDay")); + if (BigDecimal.ZERO.compareTo(processLong) == -1) { + mdcHomeEquipmentVo.setUtilizationRate(processLong.divide(processDay.multiply(new BigDecimal("86400")), 4, RoundingMode.HALF_UP).multiply(new BigDecimal("100")).setScale(2, RoundingMode.HALF_UP)); + if (BigDecimal.ZERO.compareTo(openLong) == -1) { + mdcHomeEquipmentVo.setStartRate(openLong.divide(new BigDecimal("86400"), 4, RoundingMode.HALF_UP).setScale(2, RoundingMode.HALF_UP)); + mdcHomeEquipmentVo.setOpenRate(processDay.divide(openLong, 4, RoundingMode.HALF_UP).multiply(new BigDecimal("100")).setScale(2, RoundingMode.HALF_UP)); + } + } + } + + //OEE + BigDecimal oee = mdcHomeMapper.getOeeByDate(Arrays.asList(equipmentId.split(",")), month); + if (oee != null && !(oee.compareTo(BigDecimal.ZERO) == 0)) { + mdcHomeEquipmentVo.setOverallEquipmentEfficiency(oee.multiply(new BigDecimal("100")).setScale(2, RoundingMode.HALF_UP)); + } + dataList.add(mdcHomeEquipmentVo); + } + result.put("dateList", dateList); + result.put("dataList", dataList); + return result; + } + + /** + * 璁惧绾ц澶囧垪琛� + */ + @Override + public List<MdcEquipment> getEquipmentList(String key) { + return mdcHomeMapper.getEquipmentList(key); + } } -- Gitblit v1.9.3