| | |
| | | import org.jeecg.modules.mdc.mapper.MdcOeeInfoMapper; |
| | | import org.jeecg.modules.mdc.service.*; |
| | | import org.jeecg.modules.mdc.util.DateUtils; |
| | | import org.jeecg.modules.mdc.vo.MdcOeeComputeVo; |
| | | import org.jeecg.modules.mdc.vo.MdcOeeInfoVo; |
| | | import org.jeecgframework.poi.excel.def.NormalExcelConstants; |
| | | import org.jeecgframework.poi.excel.entity.ExportParams; |
| | |
| | | } |
| | | |
| | | /** |
| | | * 计ç®OEE |
| | | * @param mdcOeeComputeVo |
| | | */ |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void computeOee(MdcOeeComputeVo mdcOeeComputeVo) { |
| | | List<MdcOeeInfo> result = new ArrayList<>(); |
| | | String startDate = mdcOeeComputeVo.getStartDate(); |
| | | String endDate = mdcOeeComputeVo.getEndDate(); |
| | | List<String> dateList = DateUtils.getDatesStringList(DateUtils.getShortDate(startDate), DateUtils.getShortDate(endDate)); |
| | | if (!dateList.isEmpty()) { |
| | | //è·å设å¤å表 |
| | | List<MdcEquipment> equipmentList = mdcEquipmentService.list(); |
| | | |
| | | for (String validDate : dateList) { |
| | | try { |
| | | this.remove(new LambdaQueryWrapper<MdcOeeInfo>().eq(MdcOeeInfo::getTheDate, validDate)); |
| | | } catch (Exception e) { |
| | | log.error("åæ°æ ¼å¼ä¸å¯¹", e); |
| | | } |
| | | for (MdcEquipment mdcEquipment : equipmentList) { |
| | | String equipmentId = mdcEquipment.getEquipmentId(); |
| | | MdcOeeInfo mdcOeeInfo = new MdcOeeInfo(); |
| | | // 设å¤ç¼å· |
| | | mdcOeeInfo.setEquipmentId(equipmentId); |
| | | // è®¡ç®æ¥æ |
| | | mdcOeeInfo.setTheDate(validDate); |
| | | // 工使¥åæ¶é´(min) --- ææ¯å¤©24å°æ¶ç® |
| | | mdcOeeInfo.setCalendarLong(1440); |
| | | // 计ååæºæ¶é´(min) --- æç»´æ¤æ°æ®ç»è®¡å½å¤©æ»æ¶é¿ |
| | | Integer planCloseLong = mdcPlanCloseService.findPlanTimeDuration(equipmentId, validDate, CommonConstant.CLOSE_TYPE_1); |
| | | mdcOeeInfo.setPlanCloseLong(planCloseLong); |
| | | // è´è·æ¶é´(min) --- æ¥å工使¶é´-计ååæºæ¶é´ |
| | | Integer loadLong = mdcOeeInfo.getCalendarLong() - planCloseLong; |
| | | mdcOeeInfo.setLoadLong(loadLong); |
| | | // é计ååæºæ¶é´(min) --- æç»´æ¤æ°æ®ç»è®¡å½å¤©æ»æ¶é¿ |
| | | Integer noPlanCloseLong = mdcPlanCloseService.findPlanTimeDuration(equipmentId, validDate, CommonConstant.CLOSE_TYPE_2); |
| | | mdcOeeInfo.setNoplanCloseLong(noPlanCloseLong); |
| | | // å¼å¨æ¶é´(min) --- è´è·æ¶é´-é计ååæºæ¶é´ |
| | | int actuateLong = loadLong - noPlanCloseLong; |
| | | mdcOeeInfo.setActuateLong(actuateLong); |
| | | // æ¶é´å¼å¨ç --- å¼å¨æ¶é´/è´è·æ¶é´ |
| | | BigDecimal timeActuationRate = new BigDecimal(actuateLong).divide(new BigDecimal(loadLong), 4, RoundingMode.HALF_UP).multiply(new BigDecimal("100")).setScale(2, RoundingMode.HALF_UP); |
| | | mdcOeeInfo.setTimeActuationRate(timeActuationRate); |
| | | // ææè¿è¡æ¶é´ --- æéæ±ç»´æ¤é¶ä»¶å å·¥æ»æ¶é¿||ç³»ç»ä¸»è½´è´è½½æ¶é´ |
| | | Integer effectiveRunLong = 0; |
| | | Integer totalProcessLong = mdcPartProcessInfoService.selectTotalProcessLong(equipmentId, validDate); |
| | | if (totalProcessLong == 0) { |
| | | //æ¥è¯¢è®¾å¤è¿è¡æ¶é´ |
| | | effectiveRunLong = mdcEquipmentStatisticalInfoService.selectProcessLong(equipmentId, validDate.replace("-", "")); |
| | | } else { |
| | | effectiveRunLong = totalProcessLong; |
| | | } |
| | | mdcOeeInfo.setEffectiveRunLong(effectiveRunLong); |
| | | // æ§è½å¼å¨ç --- ææè¿è¡æ¶é´/å¼å¨æ¶é´ |
| | | BigDecimal performanceRate = BigDecimal.ZERO; |
| | | if (effectiveRunLong != 0 && actuateLong != 0) { |
| | | performanceRate = new BigDecimal(effectiveRunLong).divide(new BigDecimal(actuateLong), 4, RoundingMode.HALF_UP).multiply(new BigDecimal("100")).setScale(2, RoundingMode.HALF_UP); |
| | | } |
| | | mdcOeeInfo.setPerformanceRate(performanceRate); |
| | | // å å·¥é¶ä»¶æ°é --- æç»´æ¤æ°æ®ç»è®¡å½å¤© |
| | | Integer processCount = mdcPartProcessInfoService.selectTotalProcessCount(equipmentId, validDate); |
| | | mdcOeeInfo.setProcessCount(processCount); |
| | | // åæ ¼é¶ä»¶æ°é --- æç»´æ¤æ°æ®ç»è®¡å½å¤© |
| | | Integer passCount = mdcPartProcessInfoService.selectTotalPassCount(equipmentId, validDate); |
| | | mdcOeeInfo.setPassCount(passCount); |
| | | // åæ ¼ç --- åæ ¼æ°/å å·¥æ° |
| | | BigDecimal passRate = BigDecimal.ZERO; |
| | | if (processCount != 0 && passCount != 0) { |
| | | passRate = new BigDecimal(passCount).divide(new BigDecimal(processCount), 4, RoundingMode.HALF_UP).multiply(new BigDecimal("100")).setScale(2, RoundingMode.HALF_UP); |
| | | } |
| | | mdcOeeInfo.setPassRate(passRate); |
| | | // OEE --- æ¶é´å¼å¨ç * æ§è½å¼å¨ç * 䏿¬¡åæ ¼ç |
| | | BigDecimal oee = BigDecimal.ZERO; |
| | | if (!timeActuationRate.equals(BigDecimal.ZERO) && !performanceRate.equals(BigDecimal.ZERO) && !passRate.equals(BigDecimal.ZERO)) { |
| | | oee = timeActuationRate.multiply(performanceRate).multiply(passRate).divide(new BigDecimal("10000"), 4, RoundingMode.HALF_UP); |
| | | } |
| | | mdcOeeInfo.setOee(oee); |
| | | result.add(mdcOeeInfo); |
| | | } |
| | | } |
| | | } |
| | | super.saveBatch(result); |
| | | } |
| | | |
| | | /** |
| | | * 计ç®oee |
| | | * @param dateTime åæ° |
| | | */ |