| | |
| | | import org.jeecg.modules.system.entity.MdcProduction; |
| | | import org.jeecg.modules.system.service.IMdcProductionService; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import javax.annotation.Resource; |
| | | import javax.servlet.http.HttpServletRequest; |
| | |
| | | * 计算设备综合效率OEE |
| | | */ |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void runningOverallEquipmentEfficiency(String dateTime) { |
| | | /* |
| | | OEE = 时间开动率 × 性能开动率 × 合格品率 |
| | |
| | | String validDate = YearMonth.now().minusMonths(1).toString(); |
| | | if (StringUtils.isNotBlank(dateTime)) { |
| | | validDate = DateUtils.format(DateUtils.toDate(dateTime, "yyyyMM"), DateUtils.STR_YEAR_MONTH); |
| | | try { |
| | | if (validDate != null) { |
| | | this.remove(new LambdaQueryWrapper<MdcOverallEquipmentEfficiency>(). |
| | | eq(MdcOverallEquipmentEfficiency::getValidDate, validDate)); |
| | | } |
| | | } catch (Exception e) { |
| | | log.error("参数格式不对", e); |
| | | } |
| | | } |
| | | try { |
| | | this.remove(new LambdaQueryWrapper<MdcOverallEquipmentEfficiency>().eq(MdcOverallEquipmentEfficiency::getValidDate, validDate)); |
| | | } catch (Exception e) { |
| | | log.error("参数格式不对", e); |
| | | } |
| | | // 获取设备列表 |
| | | List<MdcEquipment> equipmentList = mdcEquipmentService.list(); |
| | |
| | | if (StringUtils.isNotEmpty(mdcOverallEquipmentEfficiencyVo.getDriveType())) { |
| | | mdcOverallEquipmentEfficiencyVo.setDriveTypeList(Arrays.asList(mdcOverallEquipmentEfficiencyVo.getDriveType().split(","))); |
| | | } |
| | | if (StringUtils.isNotEmpty(mdcOverallEquipmentEfficiencyVo.getPercentageLevel())) { |
| | | List<BigDecimal> stringList = new ArrayList<>(); |
| | | String[] strings = mdcOverallEquipmentEfficiencyVo.getPercentageLevel().split(","); |
| | | for (String string : strings) { |
| | | for (String s : string.split("-")) { |
| | | stringList.add(new BigDecimal(s).divide(new BigDecimal("100"), 2, RoundingMode.HALF_UP)); |
| | | } |
| | | } |
| | | mdcOverallEquipmentEfficiencyVo.setMax(stringList.stream().max(BigDecimal::compareTo).get().toString()); |
| | | mdcOverallEquipmentEfficiencyVo.setMin(stringList.stream().min(BigDecimal::compareTo).get().toString()); |
| | | } |
| | | IPage<MdcOverallEquipmentEfficiency> mdcOverallEquipmentEfficiencyIPage = this.baseMapper.pageList(page, mdcOverallEquipmentEfficiencyVo); |
| | | // List<MdcOverallEquipmentEfficiency> list = mdcOverallEquipmentEfficiencyIPage.getRecords(); |
| | | for (MdcOverallEquipmentEfficiency mdcOverallEquipmentEfficiency : mdcOverallEquipmentEfficiencyIPage.getRecords()) { |
| | |
| | | } |
| | | result.add(oeeStatisticsVo); |
| | | } |
| | | OeeStatisticsVo oeeStatisticsVo = new OeeStatisticsVo(); |
| | | oeeStatisticsVo.setProductionId(UUID.randomUUID().toString()); |
| | | oeeStatisticsVo.setProductionName("合计"); |
| | | oeeStatisticsVo.setLevel1(result.stream().mapToInt(OeeStatisticsVo::getLevel1).sum()); |
| | | oeeStatisticsVo.setLevel2(result.stream().mapToInt(OeeStatisticsVo::getLevel2).sum()); |
| | | oeeStatisticsVo.setLevel3(result.stream().mapToInt(OeeStatisticsVo::getLevel3).sum()); |
| | | oeeStatisticsVo.setLevel4(result.stream().mapToInt(OeeStatisticsVo::getLevel4).sum()); |
| | | oeeStatisticsVo.setLevel5(result.stream().mapToInt(OeeStatisticsVo::getLevel5).sum()); |
| | | result.add(oeeStatisticsVo); |
| | | } |
| | | return result; |
| | | } |
| | |
| | | if (StringUtils.isEmpty(date)) { |
| | | date = DateTimeFormatter.ofPattern("yyyy-MM").format(LocalDate.now().plusMonths(-1)); |
| | | } |
| | | List<String> equipmentTypeList = new ArrayList<>(); |
| | | if (StringUtils.isNotEmpty(equipmentType)) { |
| | | equipmentTypeList = Arrays.asList(equipmentType.split(",")); |
| | | } |
| | | 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()); |
| | | BigDecimal oee = this.baseMapper.findAvgOee(date, equipmentTypeList, mdcProduction.getId()); |
| | | if (oee != null) { |
| | | oeeStatisticsChartVo.setValue(oee); |
| | | oeeStatisticsChartVo.setValue(oee.multiply(new BigDecimal("100")).setScale(2, RoundingMode.HALF_UP)); |
| | | } |
| | | result.add(oeeStatisticsChartVo); |
| | | } |