| | |
| | | public MdcEfficiencyVo efficiencyList(String userId, MdcEfficiencyReportQueryVo vo) { |
| | | MdcEfficiencyVo result = new MdcEfficiencyVo(); |
| | | List<MdcEfficiencyListDto> listDtos = new ArrayList<>(); |
| | | List<String> equipmentIds = new ArrayList<>(); |
| | | if (StringUtils.isNotEmpty(vo.getParentId()) && StringUtils.isEmpty(vo.getEquipmentId())) { |
| | | if ("2".equals(vo.getTypeTree())) { |
| | | // 部门层级 |
| | | equipmentIds = mdcEquipmentService.getEquipmentIdsByDepart(userId, vo.getParentId()); |
| | | } else { |
| | | // 产线层级 |
| | | equipmentIds = mdcEquipmentService.getEquipmentIdsProduction(userId, vo.getParentId()); |
| | | } |
| | | } else if (StringUtils.isNotEmpty(vo.getEquipmentId())) { |
| | | // 单台设备信息 |
| | | vo.setEquipmentIdList(Collections.singletonList(vo.getEquipmentId())); |
| | | } else { |
| | | // 查询用户拥有的所有设备信息 |
| | | if ("2".equals(vo.getTypeTree())) { |
| | | // 部门层级 |
| | | equipmentIds = mdcEquipmentService.getEquipmentIdsByDepart(userId, null); |
| | | } else { |
| | | // 产线层级 |
| | | equipmentIds = mdcEquipmentService.getEquipmentIdsProduction(userId, null); |
| | | } |
| | | } |
| | | |
| | | // 获取设备 ID 列表 |
| | | List<String> equipmentIds = getEquipmentIds(userId, vo); |
| | | if (vo.getEquipmentIdList() == null || vo.getEquipmentIdList().isEmpty()) { |
| | | vo.setEquipmentIdList(equipmentIds); |
| | | } |
| | | |
| | | // 获取日期列表 |
| | | List<String> dates = DateUtils.getDatesStringList2(DateUtils.getShortDate2(vo.getStartTime()), DateUtils.getShortDate2(vo.getEndTime())); |
| | | result.setDates(dates); |
| | | |
| | | // 利用率等级 |
| | | // 获取设备利用率列表 |
| | | List<MdcUtilizationRate> mdcUtilizationRateList = mdcUtilizationRateService.listByType("lyl"); |
| | | |
| | | // 如果设备 ID 列表为空,直接返回 |
| | | if (vo.getEquipmentIdList() == null || vo.getEquipmentIdList().isEmpty()) { |
| | | result.setMdcEfficiencyList(listDtos); |
| | | } else { |
| | | |
| | | List<String> equipmentIdList = mdcEquipmentService.listEquipmentId(vo); |
| | | if (equipmentIdList != null && !equipmentIdList.isEmpty()) { |
| | | vo.setEquipmentIdList(equipmentIdList); |
| | | } else { |
| | | result.setMdcEfficiencyList(listDtos); |
| | | return result; |
| | | } |
| | | |
| | | // 查询利用率数据 |
| | | List<MdcEfficiencyDto> efficiencyList = mdcEfficiencyReportMapper.efficiencyList(vo); |
| | | // 封装结果 |
| | | if ("2".equals(vo.getTypeTree())) { |
| | | // 部门层级 |
| | | List<MdcEquDepDto> equipmentList = mdcEquipmentService.findEquDepList(vo.getEquipmentIdList()); |
| | | // 查询所有部门信息 |
| | | List<SysDepart> departList = sysDepartService.list(new LambdaQueryWrapper<SysDepart>().ne(SysDepart::getDelFlag, CommonConstant.DEL_FLAG_1.toString()).orderByAsc(SysDepart::getDepartOrder)); |
| | | |
| | | for (MdcEquDepDto mdcEquDepDto : equipmentList) { |
| | | MdcEfficiencyListDto mdcEfficiencyListDto = new MdcEfficiencyListDto(); |
| | | mdcEfficiencyListDto.setEquipmentId(mdcEquDepDto.getEquipmentId()); |
| | | mdcEfficiencyListDto.setEquipmentName(mdcEquDepDto.getEquipmentName()); |
| | | mdcEfficiencyListDto.setEquipmentType(mdcEquDepDto.getEquipmentType()); |
| | | mdcEfficiencyListDto.setEquipmentModel(mdcEquDepDto.getEquipmentModel()); |
| | | switch (mdcEquDepDto.getOrgType()) { |
| | | case "1": |
| | | mdcEfficiencyListDto.setLevel1(mdcEquDepDto.getDepartName()); |
| | | break; |
| | | case "2": |
| | | mdcEfficiencyListDto.setLevel2(mdcEquDepDto.getDepartName()); |
| | | break; |
| | | case "3": |
| | | mdcEfficiencyListDto.setLevel3(mdcEquDepDto.getDepartName()); |
| | | break; |
| | | default: |
| | | } |
| | | |
| | | SysDepart sysDepart = departList.stream().filter(depart -> depart.getId().equals(mdcEquDepDto.getParentId())).findAny().orElse(null); |
| | | if (sysDepart != null) { |
| | | switch (sysDepart.getOrgType()) { |
| | | case "1": |
| | | mdcEfficiencyListDto.setLevel1(sysDepart.getDepartName()); |
| | | break; |
| | | case "2": |
| | | mdcEfficiencyListDto.setLevel2(sysDepart.getDepartName()); |
| | | break; |
| | | case "3": |
| | | mdcEfficiencyListDto.setLevel3(sysDepart.getDepartName()); |
| | | break; |
| | | default: |
| | | } |
| | | if (StringUtils.isNotEmpty(sysDepart.getParentId())) { |
| | | departList.stream().filter(depart -> depart.getId().equals(sysDepart.getParentId())).findAny().ifPresent(depart1 -> { |
| | | switch (depart1.getOrgType()) { |
| | | case "1": |
| | | mdcEfficiencyListDto.setLevel1(depart1.getDepartName()); |
| | | break; |
| | | case "2": |
| | | mdcEfficiencyListDto.setLevel2(depart1.getDepartName()); |
| | | break; |
| | | case "3": |
| | | mdcEfficiencyListDto.setLevel3(depart1.getDepartName()); |
| | | break; |
| | | default: |
| | | } |
| | | }); |
| | | } |
| | | } |
| | | List<MdcEfficiencyResultDto> list = new ArrayList<>(); |
| | | MdcEfficiencyResultDto mdcEfficiencyResultDto = new MdcEfficiencyResultDto(); |
| | | MdcEfficiencyResultDto mdcEfficiencyResultDto1 = new MdcEfficiencyResultDto(); |
| | | mdcEfficiencyResultDto1.setTheDate("合计"); |
| | | mdcEfficiencyResultDto.setTheDate("平均值"); |
| | | for (String date : dates) { |
| | | list.add(this.efficiencyRate(efficiencyList, date, mdcEquDepDto.getEquipmentId(), mdcUtilizationRateList, mdcEfficiencyResultDto)); |
| | | } |
| | | mdcEfficiencyResultDto1.setProcessLong(mdcEfficiencyResultDto.getProcessLong()); |
| | | mdcEfficiencyResultDto.setProcessLong(mdcEfficiencyResultDto.getProcessLong().divide(new BigDecimal(dates.size()), 0, RoundingMode.HALF_UP)); |
| | | mdcEfficiencyResultDto.setUtilizationRate(mdcEfficiencyResultDto.getUtilizationRate().divide(new BigDecimal(dates.size()), 4, RoundingMode.HALF_UP)); |
| | | mdcEfficiencyResultDto1.setUtilizationRate(mdcEfficiencyResultDto.getUtilizationRate()); |
| | | mdcEfficiencyResultDto.setStartRate(mdcEfficiencyResultDto.getStartRate().divide(new BigDecimal(dates.size()), 4, RoundingMode.HALF_UP)); |
| | | mdcEfficiencyResultDto1.setStartRate(mdcEfficiencyResultDto.getStartRate()); |
| | | mdcEfficiencyResultDto.setOpenRate(mdcEfficiencyResultDto.getOpenRate().divide(new BigDecimal(dates.size()), 4, RoundingMode.HALF_UP)); |
| | | mdcEfficiencyResultDto1.setOpenRate(mdcEfficiencyResultDto.getOpenRate()); |
| | | mdcEfficiencyResultDto1.setOpenLong(mdcEfficiencyResultDto.getOpenLong()); |
| | | mdcEfficiencyResultDto.setOpenLong(mdcEfficiencyResultDto.getOpenLong().divide(new BigDecimal(dates.size()), 0, RoundingMode.HALF_UP)); |
| | | mdcEfficiencyResultDto1.setWaitLong(mdcEfficiencyResultDto.getWaitLong()); |
| | | mdcEfficiencyResultDto.setWaitLong(mdcEfficiencyResultDto.getWaitLong().divide(new BigDecimal(dates.size()), 0, RoundingMode.HALF_UP)); |
| | | mdcEfficiencyResultDto1.setCloseLong(mdcEfficiencyResultDto.getCloseLong()); |
| | | mdcEfficiencyResultDto.setCloseLong(mdcEfficiencyResultDto.getCloseLong().divide(new BigDecimal(dates.size()), 0, RoundingMode.HALF_UP)); |
| | | long rate = mdcEfficiencyResultDto.getUtilizationRate().multiply(new BigDecimal("100")).longValue(); |
| | | for (MdcUtilizationRate mdcUtilizationRate : mdcUtilizationRateList) { |
| | | if (rate >= mdcUtilizationRate.getMinimumRange() && rate < mdcUtilizationRate.getMaximumRange()) { |
| | | mdcEfficiencyResultDto.setColor(mdcUtilizationRate.getRateParameterColor()); |
| | | mdcEfficiencyResultDto1.setColor(mdcUtilizationRate.getRateParameterColor()); |
| | | } |
| | | } |
| | | list.add(mdcEfficiencyResultDto1); |
| | | list.add(mdcEfficiencyResultDto); |
| | | mdcEfficiencyListDto.setDataList(list); |
| | | listDtos.add(mdcEfficiencyListDto); |
| | | } |
| | | } else { |
| | | // 产线层级 |
| | | List<MdcEquProDto> equipmentList = mdcEquipmentService.findEquProList(vo.getEquipmentIdList()); |
| | | // 查询所有产线信息 |
| | | List<MdcProduction> productionList = mdcProductionService.list(new LambdaQueryWrapper<MdcProduction>().ne(MdcProduction::getDelFlag, CommonConstant.DEL_FLAG_1.toString()).orderByAsc(MdcProduction::getProductionOrder)); |
| | | |
| | | for (MdcEquProDto mdcEquProDto : equipmentList) { |
| | | MdcEfficiencyListDto mdcEfficiencyListDto = new MdcEfficiencyListDto(); |
| | | mdcEfficiencyListDto.setEquipmentId(mdcEquProDto.getEquipmentId()); |
| | | mdcEfficiencyListDto.setEquipmentName(mdcEquProDto.getEquipmentName()); |
| | | mdcEfficiencyListDto.setEquipmentType(mdcEquProDto.getEquipmentType()); |
| | | mdcEfficiencyListDto.setEquipmentModel(mdcEquProDto.getEquipmentModel()); |
| | | switch (mdcEquProDto.getOrgType()) { |
| | | case "1": |
| | | mdcEfficiencyListDto.setLevel1(mdcEquProDto.getProductionName()); |
| | | break; |
| | | case "2": |
| | | mdcEfficiencyListDto.setLevel2(mdcEquProDto.getProductionName()); |
| | | break; |
| | | case "3": |
| | | mdcEfficiencyListDto.setLevel3(mdcEquProDto.getProductionName()); |
| | | break; |
| | | default: |
| | | } |
| | | MdcProduction mdcProduction = productionList.stream().filter(production -> production.getId().equals(mdcEquProDto.getParentId())).findAny().orElse(null); |
| | | if (mdcProduction != null) { |
| | | switch (mdcProduction.getOrgType()) { |
| | | case "1": |
| | | mdcEfficiencyListDto.setLevel1(mdcProduction.getProductionName()); |
| | | break; |
| | | case "2": |
| | | mdcEfficiencyListDto.setLevel2(mdcProduction.getProductionName()); |
| | | break; |
| | | case "3": |
| | | mdcEfficiencyListDto.setLevel3(mdcProduction.getProductionName()); |
| | | break; |
| | | default: |
| | | } |
| | | if (StringUtils.isNotEmpty(mdcProduction.getParentId())) { |
| | | productionList.stream().filter(production -> production.getId().equals(mdcProduction.getParentId())).findAny().ifPresent(production1 -> { |
| | | switch (production1.getOrgType()) { |
| | | case "1": |
| | | mdcEfficiencyListDto.setLevel1(production1.getProductionName()); |
| | | break; |
| | | case "2": |
| | | mdcEfficiencyListDto.setLevel2(production1.getProductionName()); |
| | | break; |
| | | case "3": |
| | | mdcEfficiencyListDto.setLevel3(production1.getProductionName()); |
| | | break; |
| | | default: |
| | | } |
| | | }); |
| | | } |
| | | } |
| | | List<MdcEfficiencyResultDto> list = new ArrayList<>(); |
| | | MdcEfficiencyResultDto mdcEfficiencyResultDto = new MdcEfficiencyResultDto(); |
| | | MdcEfficiencyResultDto mdcEfficiencyResultDto1 = new MdcEfficiencyResultDto(); |
| | | mdcEfficiencyResultDto1.setTheDate("合计"); |
| | | mdcEfficiencyResultDto.setTheDate("平均值"); |
| | | for (String date : dates) { |
| | | list.add(this.efficiencyRate(efficiencyList, date, mdcEquProDto.getEquipmentId(), mdcUtilizationRateList, mdcEfficiencyResultDto)); |
| | | } |
| | | mdcEfficiencyResultDto1.setProcessLong(mdcEfficiencyResultDto.getProcessLong()); |
| | | mdcEfficiencyResultDto.setProcessLong(mdcEfficiencyResultDto.getProcessLong().divide(new BigDecimal(dates.size()), 0, RoundingMode.HALF_UP)); |
| | | mdcEfficiencyResultDto.setUtilizationRate(mdcEfficiencyResultDto.getUtilizationRate().divide(new BigDecimal(dates.size()), 4, RoundingMode.HALF_UP)); |
| | | mdcEfficiencyResultDto1.setUtilizationRate(mdcEfficiencyResultDto.getUtilizationRate()); |
| | | mdcEfficiencyResultDto.setStartRate(mdcEfficiencyResultDto.getStartRate().divide(new BigDecimal(dates.size()), 4, RoundingMode.HALF_UP)); |
| | | mdcEfficiencyResultDto1.setStartRate(mdcEfficiencyResultDto.getStartRate()); |
| | | mdcEfficiencyResultDto.setOpenRate(mdcEfficiencyResultDto.getOpenRate().divide(new BigDecimal(dates.size()), 4, RoundingMode.HALF_UP)); |
| | | mdcEfficiencyResultDto1.setOpenRate(mdcEfficiencyResultDto.getOpenRate()); |
| | | mdcEfficiencyResultDto1.setOpenLong(mdcEfficiencyResultDto.getOpenLong()); |
| | | mdcEfficiencyResultDto.setOpenLong(mdcEfficiencyResultDto.getOpenLong().divide(new BigDecimal(dates.size()), 0, RoundingMode.HALF_UP)); |
| | | mdcEfficiencyResultDto1.setWaitLong(mdcEfficiencyResultDto.getWaitLong()); |
| | | mdcEfficiencyResultDto.setWaitLong(mdcEfficiencyResultDto.getWaitLong().divide(new BigDecimal(dates.size()), 0, RoundingMode.HALF_UP)); |
| | | mdcEfficiencyResultDto1.setCloseLong(mdcEfficiencyResultDto.getCloseLong()); |
| | | mdcEfficiencyResultDto.setCloseLong(mdcEfficiencyResultDto.getCloseLong().divide(new BigDecimal(dates.size()), 0, RoundingMode.HALF_UP)); |
| | | long rate = mdcEfficiencyResultDto.getUtilizationRate().multiply(new BigDecimal("100")).longValue(); |
| | | for (MdcUtilizationRate mdcUtilizationRate : mdcUtilizationRateList) { |
| | | if (rate >= mdcUtilizationRate.getMinimumRange() && rate < mdcUtilizationRate.getMaximumRange()) { |
| | | mdcEfficiencyResultDto.setColor(mdcUtilizationRate.getRateParameterColor()); |
| | | mdcEfficiencyResultDto1.setColor(mdcUtilizationRate.getRateParameterColor()); |
| | | } |
| | | } |
| | | list.add(mdcEfficiencyResultDto1); |
| | | list.add(mdcEfficiencyResultDto); |
| | | mdcEfficiencyListDto.setDataList(list); |
| | | listDtos.add(mdcEfficiencyListDto); |
| | | } |
| | | } |
| | | result.setMdcEfficiencyList(listDtos); |
| | | return result; |
| | | } |
| | | |
| | | // 获取设备 ID 列表 |
| | | List<String> equipmentIdList = mdcEquipmentService.listEquipmentId(vo); |
| | | if (equipmentIdList == null || equipmentIdList.isEmpty()) { |
| | | result.setMdcEfficiencyList(listDtos); |
| | | return result; |
| | | } |
| | | |
| | | vo.setEquipmentIdList(equipmentIdList); |
| | | |
| | | // 查询设备效率数据 |
| | | List<MdcEfficiencyDto> efficiencyList = mdcEfficiencyReportMapper.efficiencyList(vo); |
| | | |
| | | // 根据类型树处理不同的层级 |
| | | if ("2".equals(vo.getTypeTree())) { |
| | | // 部门层级 |
| | | listDtos = processDepartmentLevel(vo, efficiencyList, dates, mdcUtilizationRateList); |
| | | } else { |
| | | // 产线层级 |
| | | listDtos = processProductionLevel(vo, efficiencyList, dates, mdcUtilizationRateList); |
| | | } |
| | | |
| | | result.setMdcEfficiencyList(listDtos); |
| | | |
| | | // 添加合计值和平均值 |
| | | addSummaryAndAverage(result, listDtos, mdcUtilizationRateList); |
| | | |
| | | return result; |
| | | } |
| | | |
| | | /** |
| | | * 获取设备 ID 列表 |
| | | */ |
| | | private List<String> getEquipmentIds(String userId, MdcEfficiencyReportQueryVo vo) { |
| | | if (StringUtils.isNotEmpty(vo.getParentId()) && StringUtils.isEmpty(vo.getEquipmentId())) { |
| | | return "2".equals(vo.getTypeTree()) |
| | | ? mdcEquipmentService.getEquipmentIdsByDepart(userId, vo.getParentId()) |
| | | : mdcEquipmentService.getEquipmentIdsProduction(userId, vo.getParentId()); |
| | | } else if (StringUtils.isNotEmpty(vo.getEquipmentId())) { |
| | | vo.setEquipmentIdList(Collections.singletonList(vo.getEquipmentId())); |
| | | return Collections.emptyList(); |
| | | } else { |
| | | return "2".equals(vo.getTypeTree()) |
| | | ? mdcEquipmentService.getEquipmentIdsByDepart(userId, null) |
| | | : mdcEquipmentService.getEquipmentIdsProduction(userId, null); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 处理部门层级 |
| | | */ |
| | | private List<MdcEfficiencyListDto> processDepartmentLevel(MdcEfficiencyReportQueryVo vo, List<MdcEfficiencyDto> efficiencyList, List<String> dates, List<MdcUtilizationRate> mdcUtilizationRateList) { |
| | | List<MdcEquDepDto> equipmentList = mdcEquipmentService.findEquDepList(vo.getEquipmentIdList()); |
| | | List<SysDepart> departList = sysDepartService.list(new LambdaQueryWrapper<SysDepart>() |
| | | .ne(SysDepart::getDelFlag, CommonConstant.DEL_FLAG_1.toString()) |
| | | .orderByAsc(SysDepart::getDepartOrder)); |
| | | |
| | | return equipmentList.stream().map(mdcEquDepDto -> { |
| | | MdcEfficiencyListDto mdcEfficiencyListDto = createEfficiencyListDto(mdcEquDepDto); |
| | | setDepartmentLevels(mdcEfficiencyListDto, mdcEquDepDto, departList); |
| | | mdcEfficiencyListDto.setDataList(processEfficiencyData(efficiencyList, dates, mdcEquDepDto.getEquipmentId(), mdcUtilizationRateList)); |
| | | return mdcEfficiencyListDto; |
| | | }).collect(Collectors.toList()); |
| | | } |
| | | |
| | | /** |
| | | * 处理产线层级 |
| | | */ |
| | | private List<MdcEfficiencyListDto> processProductionLevel(MdcEfficiencyReportQueryVo vo, List<MdcEfficiencyDto> efficiencyList, List<String> dates, List<MdcUtilizationRate> mdcUtilizationRateList) { |
| | | List<MdcEquProDto> equipmentList = mdcEquipmentService.findEquProList(vo.getEquipmentIdList()); |
| | | List<MdcProduction> productionList = mdcProductionService.list(new LambdaQueryWrapper<MdcProduction>() |
| | | .ne(MdcProduction::getDelFlag, CommonConstant.DEL_FLAG_1.toString()) |
| | | .orderByAsc(MdcProduction::getProductionOrder)); |
| | | |
| | | return equipmentList.stream().map(mdcEquProDto -> { |
| | | MdcEfficiencyListDto mdcEfficiencyListDto = createEfficiencyListDto(mdcEquProDto); |
| | | setProductionLevels(mdcEfficiencyListDto, mdcEquProDto, productionList); |
| | | mdcEfficiencyListDto.setDataList(processEfficiencyData(efficiencyList, dates, mdcEquProDto.getEquipmentId(), mdcUtilizationRateList)); |
| | | return mdcEfficiencyListDto; |
| | | }).collect(Collectors.toList()); |
| | | } |
| | | |
| | | /** |
| | | * 创建 MdcEfficiencyListDto 对象 |
| | | */ |
| | | private MdcEfficiencyListDto createEfficiencyListDto(MdcEquDepDto mdcEquDepDto) { |
| | | MdcEfficiencyListDto dto = new MdcEfficiencyListDto(); |
| | | dto.setEquipmentId(mdcEquDepDto.getEquipmentId()); |
| | | dto.setEquipmentName(mdcEquDepDto.getEquipmentName()); |
| | | dto.setEquipmentType(mdcEquDepDto.getEquipmentType()); |
| | | dto.setEquipmentModel(mdcEquDepDto.getEquipmentModel()); |
| | | return dto; |
| | | } |
| | | |
| | | private MdcEfficiencyListDto createEfficiencyListDto(MdcEquProDto mdcEquProDto) { |
| | | MdcEfficiencyListDto dto = new MdcEfficiencyListDto(); |
| | | dto.setEquipmentId(mdcEquProDto.getEquipmentId()); |
| | | dto.setEquipmentName(mdcEquProDto.getEquipmentName()); |
| | | dto.setEquipmentType(mdcEquProDto.getEquipmentType()); |
| | | dto.setEquipmentModel(mdcEquProDto.getEquipmentModel()); |
| | | return dto; |
| | | } |
| | | |
| | | /** |
| | | * 设置部门层级信息 |
| | | */ |
| | | private void setDepartmentLevels(MdcEfficiencyListDto dto, MdcEquDepDto mdcEquDepDto, List<SysDepart> departList) { |
| | | switch (mdcEquDepDto.getOrgType()) { |
| | | case "1": dto.setLevel1(mdcEquDepDto.getDepartName()); break; |
| | | case "2": dto.setLevel2(mdcEquDepDto.getDepartName()); break; |
| | | case "3": dto.setLevel3(mdcEquDepDto.getDepartName()); break; |
| | | } |
| | | |
| | | Optional<SysDepart> sysDepart = departList.stream().filter(depart -> depart.getId().equals(mdcEquDepDto.getParentId())).findAny(); |
| | | sysDepart.ifPresent(depart -> { |
| | | switch (depart.getOrgType()) { |
| | | case "1": dto.setLevel1(depart.getDepartName()); break; |
| | | case "2": dto.setLevel2(depart.getDepartName()); break; |
| | | case "3": dto.setLevel3(depart.getDepartName()); break; |
| | | } |
| | | if (StringUtils.isNotEmpty(depart.getParentId())) { |
| | | departList.stream().filter(d -> d.getId().equals(depart.getParentId())).findAny().ifPresent(parent -> { |
| | | switch (parent.getOrgType()) { |
| | | case "1": dto.setLevel1(parent.getDepartName()); break; |
| | | case "2": dto.setLevel2(parent.getDepartName()); break; |
| | | case "3": dto.setLevel3(parent.getDepartName()); break; |
| | | } |
| | | }); |
| | | } |
| | | }); |
| | | } |
| | | |
| | | /** |
| | | * 设置部门层级信息 |
| | | */ |
| | | private void setProductionLevels(MdcEfficiencyListDto dto, MdcEquProDto mdcEquProDto, List<MdcProduction> productionList) { |
| | | switch (mdcEquProDto.getOrgType()) { |
| | | case "1": dto.setLevel1(mdcEquProDto.getProductionName()); break; |
| | | case "2": dto.setLevel2(mdcEquProDto.getProductionName()); break; |
| | | case "3": dto.setLevel3(mdcEquProDto.getProductionName()); break; |
| | | } |
| | | |
| | | Optional<MdcProduction> mdcProduction = productionList.stream().filter(production -> production.getId().equals(mdcEquProDto.getParentId())).findAny(); |
| | | mdcProduction.ifPresent(production -> { |
| | | switch (production.getOrgType()) { |
| | | case "1": dto.setLevel1(production.getProductionName()); break; |
| | | case "2": dto.setLevel2(production.getProductionName()); break; |
| | | case "3": dto.setLevel3(production.getProductionName()); break; |
| | | } |
| | | if (StringUtils.isNotEmpty(production.getParentId())) { |
| | | productionList.stream().filter(p -> p.getId().equals(production.getParentId())).findAny().ifPresent(parent -> { |
| | | switch (parent.getOrgType()) { |
| | | case "1": dto.setLevel1(parent.getProductionName()); break; |
| | | case "2": dto.setLevel2(parent.getProductionName()); break; |
| | | case "3": dto.setLevel3(parent.getProductionName()); break; |
| | | } |
| | | }); |
| | | } |
| | | }); |
| | | } |
| | | |
| | | /** |
| | | * 处理设备效率数据 |
| | | */ |
| | | private List<MdcEfficiencyResultDto> processEfficiencyData(List<MdcEfficiencyDto> efficiencyList, List<String> dates, String equipmentId, List<MdcUtilizationRate> mdcUtilizationRateList) { |
| | | List<MdcEfficiencyResultDto> list = new ArrayList<>(); |
| | | MdcEfficiencyResultDto avgDto = new MdcEfficiencyResultDto(); |
| | | avgDto.setTheDate("平均值"); |
| | | MdcEfficiencyResultDto sumDto = new MdcEfficiencyResultDto(); |
| | | sumDto.setTheDate("合计"); |
| | | |
| | | for (String date : dates) { |
| | | MdcEfficiencyResultDto dto = efficiencyRate(efficiencyList, date, equipmentId, mdcUtilizationRateList, avgDto); |
| | | list.add(dto); |
| | | } |
| | | |
| | | sumDto.setProcessLong(avgDto.getProcessLong()); |
| | | avgDto.setProcessLong(avgDto.getProcessLong().divide(new BigDecimal(dates.size()), 0, RoundingMode.HALF_UP)); |
| | | avgDto.setUtilizationRate(avgDto.getUtilizationRate().divide(new BigDecimal(dates.size()), 4, RoundingMode.HALF_UP)); |
| | | sumDto.setUtilizationRate(avgDto.getUtilizationRate()); |
| | | avgDto.setStartRate(avgDto.getStartRate().divide(new BigDecimal(dates.size()), 4, RoundingMode.HALF_UP)); |
| | | sumDto.setStartRate(avgDto.getStartRate()); |
| | | avgDto.setOpenRate(avgDto.getOpenRate().divide(new BigDecimal(dates.size()), 4, RoundingMode.HALF_UP)); |
| | | sumDto.setOpenRate(avgDto.getOpenRate()); |
| | | sumDto.setOpenLong(avgDto.getOpenLong()); |
| | | avgDto.setOpenLong(avgDto.getOpenLong().divide(new BigDecimal(dates.size()), 0, RoundingMode.HALF_UP)); |
| | | sumDto.setWaitLong(avgDto.getWaitLong()); |
| | | avgDto.setWaitLong(avgDto.getWaitLong().divide(new BigDecimal(dates.size()), 0, RoundingMode.HALF_UP)); |
| | | sumDto.setCloseLong(avgDto.getCloseLong()); |
| | | avgDto.setCloseLong(avgDto.getCloseLong().divide(new BigDecimal(dates.size()), 0, RoundingMode.HALF_UP)); |
| | | |
| | | long rate = avgDto.getUtilizationRate().multiply(new BigDecimal("100")).longValue(); |
| | | for (MdcUtilizationRate mdcUtilizationRate : mdcUtilizationRateList) { |
| | | if (rate >= mdcUtilizationRate.getMinimumRange() && rate < mdcUtilizationRate.getMaximumRange()) { |
| | | avgDto.setColor(mdcUtilizationRate.getRateParameterColor()); |
| | | sumDto.setColor(mdcUtilizationRate.getRateParameterColor()); |
| | | } |
| | | } |
| | | |
| | | list.add(sumDto); |
| | | list.add(avgDto); |
| | | return list; |
| | | } |
| | | |
| | | /** |
| | | * 添加合计值和平均值 |
| | | */ |
| | | private void addSummaryAndAverage(MdcEfficiencyVo result, List<MdcEfficiencyListDto> listDtos, List<MdcUtilizationRate> mdcUtilizationRateList) { |
| | | result.getDates().add("合计"); |
| | | result.getDates().add("平均值"); |
| | | |
| | | MdcEfficiencyListDto sum = new MdcEfficiencyListDto(); |
| | | sum.setLevel1("合计"); |
| | | sum.setLevel2("合计"); |
| | |
| | | sum.setEquipmentId("合计"); |
| | | sum.setEquipmentName("合计"); |
| | | sum.setEquipmentType("合计"); |
| | | //计算合计值 |
| | | sum.setDataList(this.calculateTotal(result.getMdcEfficiencyList(), mdcUtilizationRateList)); |
| | | sum.setDataList(calculateTotal(listDtos, mdcUtilizationRateList)); |
| | | |
| | | MdcEfficiencyListDto avg = new MdcEfficiencyListDto(); |
| | | avg.setLevel1("平均值"); |
| | |
| | | avg.setEquipmentId("平均值"); |
| | | avg.setEquipmentName("平均值"); |
| | | avg.setEquipmentType("平均值"); |
| | | //计算平均值 |
| | | avg.setDataList(this.calculateAverage(result.getMdcEfficiencyList(), mdcUtilizationRateList)); |
| | | avg.setDataList(calculateAverage(listDtos, mdcUtilizationRateList)); |
| | | |
| | | result.getMdcEfficiencyList().add(sum); |
| | | result.getMdcEfficiencyList().add(avg); |
| | | return result; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 计算平均值 |
| | | * |