| | |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.StringUtils; |
| | | import com.sun.org.apache.bcel.internal.generic.NEW; |
| | | import org.jeecg.common.constant.CommonConstant; |
| | | import org.jeecg.modules.mdc.constant.MdcConstant; |
| | | import org.jeecg.modules.mdc.entity.Equipment; |
| | | import org.jeecg.modules.mdc.entity.MdcEquipment; |
| | | import org.jeecg.modules.mdc.entity.MdcEquipmentStatisticalInfo; |
| | | import org.jeecg.modules.mdc.entity.MdcOeeInfo; |
| | | import org.jeecg.modules.mdc.service.*; |
| | | import org.jeecg.modules.mdc.util.DateUtils; |
| | | import org.jeecg.modules.mdc.vo.MdcBoardRateVo; |
| | |
| | | if (StringUtils.isBlank(productionId)) { |
| | | MdcProduction mdcProduction = mdcProductionService.getOne(new LambdaQueryWrapper<MdcProduction>().eq(MdcProduction::getParentId, "")); |
| | | productionId = mdcProduction.getId(); |
| | | result.put("productionName", mdcProduction.getProductionName()); |
| | | } else { |
| | | MdcProduction mdcProduction = mdcProductionService.getById(productionId); |
| | | result.put("productionName", mdcProduction.getProductionName()); |
| | | } |
| | | List<String> proIds = mdcProductionService.findChildByProId(productionId); |
| | | if (proIds == null || proIds.isEmpty()) { |
| | |
| | | LocalDate now = LocalDate.now(); |
| | | Date startDate = DateUtils.toDate(now.plusDays(-15).toString(), DateUtils.STR_DATE); |
| | | Date endDate = DateUtils.toDate(now.plusDays(-1).toString(), DateUtils.STR_DATE); |
| | | String start = DateUtils.format(startDate, DateUtils.STR_DATE); |
| | | String end = DateUtils.format(endDate, DateUtils.STR_DATE); |
| | | List<String> dateList = DateUtils.getDatesStringList(startDate, endDate); |
| | | List<String> dates = new ArrayList<>(); |
| | | List<MdcBoardRateVo> dataList = new ArrayList<>(); |
| | | for (String date : dateList) { |
| | | MdcBoardRateVo mdcBoardRateVo = new MdcBoardRateVo(); |
| | | String s = date.substring(5, 10); |
| | | dates.add(s); |
| | | mdcBoardRateVo.setDate(s); |
| | | List<String> dates = dateList.stream().map(date -> date.substring(5, 10)).collect(Collectors.toList()); |
| | | result.put("dateList", dates); |
| | | Map<String, MdcBoardRateVo> statisticsMap = new LinkedHashMap<>(); |
| | | dateList.forEach(date -> { |
| | | statisticsMap.put(date, new MdcBoardRateVo(date.substring(5, 10))); |
| | | }); |
| | | |
| | | // TEEP 开机率 开动率 |
| | | MdcEquipmentStatisticalInfo mdcEquipmentStatisticalInfo = mdcEquipmentStatisticalInfoService.findByEquipmentAndDate(equipmentIdList, date.replaceAll("-", "")); |
| | | mdcBoardRateVo.setUtilizationRate(mdcEquipmentStatisticalInfo.getProcessLong().divide(new BigDecimal("864"), 2, RoundingMode.HALF_UP)); |
| | | mdcBoardRateVo.setOpenRate(mdcEquipmentStatisticalInfo.getOpenLong().divide(new BigDecimal("864"), 2, RoundingMode.HALF_UP)); |
| | | if (mdcEquipmentStatisticalInfo.getOpenLong().compareTo(BigDecimal.ZERO) > 0) { |
| | | mdcBoardRateVo.setStartRate(mdcEquipmentStatisticalInfo.getProcessLong().divide(mdcEquipmentStatisticalInfo.getOpenLong(), 4, RoundingMode.HALF_UP).multiply(new BigDecimal("100"))); |
| | | List<MdcEquipmentStatisticalInfo> mdcEquipmentStatisticalInfo = mdcEquipmentStatisticalInfoService.findByEquipmentAndDate(equipmentIdList, start.replaceAll("-", ""), end.replaceAll("-", "")); |
| | | if (mdcEquipmentStatisticalInfo != null && !mdcEquipmentStatisticalInfo.isEmpty()) { |
| | | mdcEquipmentStatisticalInfo.forEach(equipmentStatisticalInfo -> { |
| | | String date = DateUtils.format(DateUtils.toDate(equipmentStatisticalInfo.getTheDate(), DateUtils.STRDATE), DateUtils.STR_DATE); |
| | | if (statisticsMap.containsKey(date)) { |
| | | MdcBoardRateVo mdcBoardRateVo = statisticsMap.get(date); |
| | | if (equipmentStatisticalInfo.getProcessLong().compareTo(BigDecimal.ZERO) > 0) { |
| | | mdcBoardRateVo.setUtilizationRate(equipmentStatisticalInfo.getProcessLong().divide(new BigDecimal("864"), 2, RoundingMode.HALF_UP)); |
| | | } |
| | | if (equipmentStatisticalInfo.getOpenLong().compareTo(BigDecimal.ZERO) > 0) { |
| | | mdcBoardRateVo.setOpenRate(equipmentStatisticalInfo.getOpenLong().divide(new BigDecimal("864"), 2, RoundingMode.HALF_UP)); |
| | | } |
| | | if (equipmentStatisticalInfo.getOpenLong().compareTo(BigDecimal.ZERO) > 0) { |
| | | mdcBoardRateVo.setStartRate(equipmentStatisticalInfo.getProcessLong().multiply(new BigDecimal("100").divide(equipmentStatisticalInfo.getOpenLong(), 2, RoundingMode.HALF_UP))); |
| | | } |
| | | statisticsMap.put(date, mdcBoardRateVo); |
| | | } |
| | | }); |
| | | } |
| | | // OEE |
| | | BigDecimal oee = mdcOeeInfoService.findByEquIdsAndDate(equipmentIdList, date); |
| | | if (oee != null) { |
| | | mdcBoardRateVo.setOee(oee.setScale(2, RoundingMode.HALF_UP)); |
| | | List<MdcOeeInfo> oeeInfo = mdcOeeInfoService.findByEquIdsAndDate(equipmentIdList, start, end); |
| | | if (oeeInfo != null && !oeeInfo.isEmpty()) { |
| | | oeeInfo.forEach(mdcOeeInfo -> { |
| | | if (statisticsMap.containsKey(mdcOeeInfo.getTheDate())) { |
| | | MdcBoardRateVo mdcBoardRateVo = statisticsMap.get(mdcOeeInfo.getTheDate()); |
| | | if (mdcOeeInfo.getOee().compareTo(BigDecimal.ZERO) > 0) { |
| | | mdcBoardRateVo.setOee(mdcOeeInfo.getOee().setScale(2, RoundingMode.HALF_UP)); |
| | | } |
| | | dataList.add(mdcBoardRateVo); |
| | | statisticsMap.put(mdcOeeInfo.getTheDate(), mdcBoardRateVo); |
| | | } |
| | | result.put("dateList", dates); |
| | | }); |
| | | } |
| | | List<MdcBoardRateVo> dataList = new ArrayList<>(statisticsMap.values()); |
| | | result.put("dataList", dataList); |
| | | return result; |
| | | } |
| | |
| | | LocalDate now = LocalDate.now(); |
| | | Date startDate = DateUtils.toDate(now.plusDays(-7).toString(), DateUtils.STR_DATE); |
| | | Date endDate = DateUtils.toDate(now.plusDays(-1).toString(), DateUtils.STR_DATE); |
| | | String start = DateUtils.format(startDate, DateUtils.STR_DATE); |
| | | String end = DateUtils.format(endDate, DateUtils.STR_DATE); |
| | | List<String> dayBetween = DateUtils.getDatesStringList(startDate, endDate); |
| | | List<String> dateList = new ArrayList<>(); |
| | | List<MdcBoardRateVo> dataList = new ArrayList<>(); |
| | | for (String date : dayBetween) { |
| | | MdcBoardRateVo mdcBoardRateVo = new MdcBoardRateVo(); |
| | | String s = date.substring(5, 10); |
| | | dateList.add(s); |
| | | mdcBoardRateVo.setDate(s); |
| | | // TEEP |
| | | MdcEquipmentStatisticalInfo mdcEquipmentStatisticalInfo = mdcEquipmentStatisticalInfoService.findByEquIdAndDate(equipmentId, date.replaceAll("-", "")); |
| | | mdcBoardRateVo.setUtilizationRate(mdcEquipmentStatisticalInfo.getProcessLong().divide(new BigDecimal("864"), 2, RoundingMode.HALF_UP)); |
| | | // OEE |
| | | BigDecimal oee = mdcOeeInfoService.findByEquIdAndDate(equipmentId, date); |
| | | if (oee != null) { |
| | | mdcBoardRateVo.setOee(oee.setScale(2, RoundingMode.HALF_UP)); |
| | | } |
| | | dataList.add(mdcBoardRateVo); |
| | | } |
| | | List<String> dateList = dayBetween.stream().map(date -> date.substring(5, 10)).collect(Collectors.toList()); |
| | | result.put("dateList", dateList); |
| | | Map<String, MdcBoardRateVo> statisticsMap = new LinkedHashMap<>(); |
| | | dayBetween.forEach(date -> { |
| | | statisticsMap.put(date, new MdcBoardRateVo(date.substring(5, 10))); |
| | | }); |
| | | // TEEP |
| | | List<MdcEquipmentStatisticalInfo> mdcEquipmentStatisticalInfo = mdcEquipmentStatisticalInfoService.findByEquIdAndDate(equipmentId, start.replaceAll("-", ""), end.replaceAll("-", "")); |
| | | if (mdcEquipmentStatisticalInfo != null && !mdcEquipmentStatisticalInfo.isEmpty()) { |
| | | mdcEquipmentStatisticalInfo.forEach(equipmentStatisticalInfo -> { |
| | | String date = DateUtils.format(DateUtils.toDate(equipmentStatisticalInfo.getTheDate(), DateUtils.STRDATE), DateUtils.STR_DATE); |
| | | if (statisticsMap.containsKey(date)) { |
| | | MdcBoardRateVo mdcBoardRateVo = statisticsMap.get(date); |
| | | if (equipmentStatisticalInfo.getProcessLong().compareTo(BigDecimal.ZERO) > 0) { |
| | | mdcBoardRateVo.setUtilizationRate(equipmentStatisticalInfo.getProcessLong().divide(new BigDecimal("864"), 2, RoundingMode.HALF_UP)); |
| | | } |
| | | statisticsMap.put(date, mdcBoardRateVo); |
| | | } |
| | | }); |
| | | } |
| | | // OEE |
| | | List<MdcOeeInfo> oeeInfo = mdcOeeInfoService.findByEquIdAndDate(equipmentId, start, end); |
| | | if (oeeInfo != null && !oeeInfo.isEmpty()) { |
| | | oeeInfo.forEach(mdcOeeInfo -> { |
| | | if (statisticsMap.containsKey(mdcOeeInfo.getTheDate())) { |
| | | MdcBoardRateVo mdcBoardRateVo = statisticsMap.get(mdcOeeInfo.getTheDate()); |
| | | if (mdcOeeInfo.getOee().compareTo(BigDecimal.ZERO) > 0) { |
| | | mdcBoardRateVo.setOee(mdcOeeInfo.getOee().setScale(2, RoundingMode.HALF_UP)); |
| | | } |
| | | statisticsMap.put(mdcOeeInfo.getTheDate(), mdcBoardRateVo); |
| | | } |
| | | }); |
| | | } |
| | | |
| | | List<MdcBoardRateVo> dataList = new ArrayList<>(statisticsMap.values()); |
| | | result.put("dataList", dataList); |
| | | return result; |
| | | } |
| | |
| | | return result; |
| | | } |
| | | |
| | | // /** |
| | | // * 设备产品合格率 |
| | | // */ |
| | | // @Override |
| | | // public Map<String, Object> passRate(String equipmentId) { |
| | | // Map<String, Object> result = new HashMap<>(); |
| | | // 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 = new ArrayList<>(); |
| | | // for (String month : monthBetween) { |
| | | // String name = month.substring(month.lastIndexOf("-") + 1).replaceFirst("^0*", "") + "月"; |
| | | // dateList.add(name); |
| | | // MdcBoardRateVo mdcBoardRateVo = new MdcBoardRateVo(); |
| | | // // 合格率 |
| | | // |
| | | // } |
| | | // return result; |
| | | // } |
| | | } |