| | |
| | | |
| | | import com.baomidou.mybatisplus.core.toolkit.StringUtils; |
| | | import org.jeecg.modules.mdc.entity.EquipmentLog; |
| | | import org.jeecg.modules.mdc.entity.MdcEquipmentStatisticalInfo; |
| | | import org.jeecg.modules.mdc.entity.MdcOverallEquipmentEfficiency; |
| | | import org.jeecg.modules.mdc.mapper.MdcHomeMapper; |
| | | import org.jeecg.modules.mdc.service.IEquipmentLogService; |
| | | 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.system.entity.MdcProduction; |
| | |
| | | result.put("oeeList", oeeList); |
| | | return result; |
| | | } |
| | | |
| | | /** |
| | | * 工段级前七天利用率折线图 |
| | | */ |
| | | @Override |
| | | public Map<String, Object> getEquipmentDayUtilizationStatistics(String userId, String key) { |
| | | Map<String, Object> result = new HashMap<>(); |
| | | List<String> equipmentIdList = mdcEquipmentService.getEquipmentIdsProduction(userId, key); |
| | | //获取前七天日期集合 |
| | | Date start = DateUtils.toDate(LocalDate.now().plusDays(-7).toString(), DateUtils.STR_DATE); |
| | | Date end = DateUtils.toDate(LocalDate.now().plusDays(-1).toString(), DateUtils.STR_DATE); |
| | | List<String> dayBetween = DateUtils.getDatesStringList2(start, end); |
| | | List<String> dateList = new ArrayList<>(); |
| | | List<EquipmentDayUtilizationVo> dataList = new ArrayList<>(); |
| | | for (String date : dayBetween) { |
| | | EquipmentDayUtilizationVo equipmentDayUtilizationVo = new EquipmentDayUtilizationVo(); |
| | | String item = date.substring(4); |
| | | if (item.startsWith("0")) { |
| | | item = item.substring(1); |
| | | String sub = item.substring(1); |
| | | if (sub.startsWith("0")) { |
| | | item = item.substring(0, 1) + "月" + sub.substring(1) + "日"; |
| | | } else { |
| | | item = item.substring(0, 1) + "月" + item.substring(1) + "日"; |
| | | } |
| | | } else { |
| | | String sub = item.substring(2); |
| | | if (sub.startsWith("0")) { |
| | | item = item.substring(0, 2) + "月" + sub.substring(2) + "日"; |
| | | } else { |
| | | item = item.substring(0, 2) + "月" + item.substring(2) + "日"; |
| | | } |
| | | } |
| | | dateList.add(item); |
| | | equipmentDayUtilizationVo.setDate(item); |
| | | if (equipmentIdList != null && !equipmentIdList.isEmpty()) { |
| | | //获取前七天利用率数据 |
| | | List<MdcEquipmentStatisticalInfo> mdcEquipmentStatisticalInfos = mdcHomeMapper.getEquipmentDayUtilizationStatistics(equipmentIdList, dayBetween); |
| | | if (mdcEquipmentStatisticalInfos != null && !mdcEquipmentStatisticalInfos.isEmpty()) { |
| | | for (MdcEquipmentStatisticalInfo mdcEquipmentStatisticalInfo : mdcEquipmentStatisticalInfos) { |
| | | if (mdcEquipmentStatisticalInfo.getTheDate().equals(date)) { |
| | | equipmentDayUtilizationVo.setUtilizationRate(mdcEquipmentStatisticalInfo.getProcessLong().divide(new BigDecimal("864"), 4, RoundingMode.HALF_UP).divide(new BigDecimal(equipmentIdList.size()), 4, RoundingMode.HALF_UP).setScale(2, RoundingMode.HALF_UP)); |
| | | if (BigDecimal.ZERO.compareTo(mdcEquipmentStatisticalInfo.getOpenLong()) == -1) { |
| | | equipmentDayUtilizationVo.setOpenRate(mdcEquipmentStatisticalInfo.getProcessLong().divide(mdcEquipmentStatisticalInfo.getOpenLong(), 4, RoundingMode.HALF_UP).multiply(new BigDecimal("100")).setScale(2, RoundingMode.HALF_UP)); |
| | | equipmentDayUtilizationVo.setStartRate(mdcEquipmentStatisticalInfo.getOpenLong().divide(new BigDecimal("864"), 4, RoundingMode.HALF_UP).divide(new BigDecimal(equipmentIdList.size()), 4, RoundingMode.HALF_UP).setScale(2, RoundingMode.HALF_UP)); |
| | | } |
| | | } |
| | | } |
| | | } else { |
| | | dataList.add(equipmentDayUtilizationVo); |
| | | } |
| | | } else { |
| | | dataList.add(equipmentDayUtilizationVo); |
| | | } |
| | | } |
| | | result.put("dateList", dateList); |
| | | result.put("dataList", dataList); |
| | | return result; |
| | | } |
| | | |
| | | /** |
| | | * 查询设备上月OEE |
| | | */ |
| | | @Override |
| | | public List<MdcOverallEquipmentEfficiency> getEquipmentOEEMonthStatistics(String userId, String key) { |
| | | List<MdcOverallEquipmentEfficiency> result = new ArrayList<>(); |
| | | List<String> equipmentIdList = mdcEquipmentService.getEquipmentIdsProduction(userId, key); |
| | | if (equipmentIdList != null && !equipmentIdList.isEmpty()) { |
| | | String validDate = DateUtils.format(DateUtils.toDate(LocalDate.now().plusMonths(-1).toString(), DateUtils.STR_DATE), DateUtils.STR_YEAR_MONTH); |
| | | result = mdcHomeMapper.getEquipmentOEEMonthStatistics(validDate, equipmentIdList); |
| | | } |
| | | return result; |
| | | } |
| | | } |