| | |
| | | import org.jeecg.modules.system.service.IMdcProductionService; |
| | | import org.jeecg.modules.system.service.ISysDepartService; |
| | | import org.jeecg.modules.system.service.ISysDictService; |
| | | import org.jeecg.modules.system.vo.MdcProOptionsVo; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import javax.annotation.Resource; |
| | |
| | | |
| | | @Resource |
| | | private ISysDictService sysDictService; |
| | | |
| | | @Resource |
| | | private IMdcEquipmentStatisticalInfoService mdcEquipmentStatisticalInfoService; |
| | | |
| | | /** |
| | | * 利用率报表 |
| | |
| | | mdcUtilizationRateListDto.setEquipmentType(mdcEquDepDto.getEquipmentType()); |
| | | // |
| | | List<MdcUtilizationResultDto> list = new ArrayList<>(); |
| | | List<MdcEquipmentStatisticalInfo> mdcEquipmentStatisticalInfo = mdcEquipmentStatisticalInfoService.findMdcEquipmentStatisticalInfo(mdcEquDepDto.getEquipmentId(), dateList.get(0), dateList.get(dateList.size() - 1)); |
| | | Map<String, MdcEquipmentStatisticalInfo> map = mdcEquipmentStatisticalInfo.stream() |
| | | .collect(Collectors.toMap(MdcEquipmentStatisticalInfo::getTheDate, m -> m)); |
| | | for (String date : dateList) { |
| | | if ("00:00".equals(startString) && "23:59".equals(endString)) { |
| | | list.add(this.utilizationRateTrend(mdcEquDepDto.getEquipmentId(), mdcEquDepDto.getEquipmentName(), mdcEquDepDto.getEquipmentType(), date, mdcUtilizationRateList, map)); |
| | | } else { |
| | | Date startTime = DateUtils.toDate(date + " " + startString + ":00", DateUtils.STR_DATE_TIME_SMALL); |
| | | Date endTime = DateUtils.toDate(date + " " + endString + ":00", DateUtils.STR_DATE_TIME_SMALL); |
| | | list.add(this.utilizationRate(mdcEquDepDto.getEquipmentId(), mdcEquDepDto.getEquipmentName(), mdcEquDepDto.getEquipmentType(), startTime, endTime, date, mdcUtilizationRateList)); |
| | | } |
| | | } |
| | | mdcUtilizationRateListDto.setDataList(list); |
| | | listDtos.add(mdcUtilizationRateListDto); |
| | |
| | | mdcEfficiencyListDto.setEquipmentType(mdcEquProDto.getEquipmentType()); |
| | | // |
| | | List<MdcUtilizationResultDto> list = new ArrayList<>(); |
| | | List<MdcEquipmentStatisticalInfo> mdcEquipmentStatisticalInfo = mdcEquipmentStatisticalInfoService.findMdcEquipmentStatisticalInfo(mdcEquProDto.getEquipmentId(), dateList.get(0), dateList.get(dateList.size() - 1)); |
| | | Map<String, MdcEquipmentStatisticalInfo> map = mdcEquipmentStatisticalInfo.stream() |
| | | .collect(Collectors.toMap(MdcEquipmentStatisticalInfo::getTheDate, m -> m)); |
| | | for (String date : dateList) { |
| | | if ("00:00".equals(startString) && "23:59".equals(endString)) { |
| | | list.add(this.utilizationRateTrend(mdcEquProDto.getEquipmentId(), mdcEquProDto.getEquipmentName(), mdcEquProDto.getEquipmentType(), date, mdcUtilizationRateList, map)); |
| | | } else { |
| | | Date startTime = DateUtils.toDate(date + " " + startString + ":00", DateUtils.STR_DATE_TIME_SMALL); |
| | | Date endTime = DateUtils.toDate(date + " " + endString + ":00", DateUtils.STR_DATE_TIME_SMALL); |
| | | list.add(this.utilizationRate(mdcEquProDto.getEquipmentId(), mdcEquProDto.getEquipmentName(), mdcEquProDto.getEquipmentType(), startTime, endTime, date, mdcUtilizationRateList)); |
| | | } |
| | | } |
| | | mdcEfficiencyListDto.setDataList(list); |
| | | listDtos.add(mdcEfficiencyListDto); |
| | |
| | | mdcEfficiencyListDto.setEquipmentType(mdcEquDepDto.getEquipmentType()); |
| | | |
| | | List<MdcUtilizationResultDto> list = new ArrayList<>(); |
| | | List<MdcEquipmentStatisticalInfo> mdcEquipmentStatisticalInfo = mdcEquipmentStatisticalInfoService.findMdcEquipmentStatisticalInfo(mdcEquDepDto.getEquipmentId(), dateList.get(0), dateList.get(dateList.size() - 1)); |
| | | Map<String, MdcEquipmentStatisticalInfo> map = mdcEquipmentStatisticalInfo.stream() |
| | | .collect(Collectors.toMap(MdcEquipmentStatisticalInfo::getTheDate, m -> m)); |
| | | for (String date : dateList) { |
| | | Date startTime = DateUtils.toDate(date + " 00:00:00", DateUtils.STR_DATE_TIME_SMALL); |
| | | Date endTime = DateUtils.toDate(date + " 00:00:00", DateUtils.STR_DATE_TIME_SMALL); |
| | | endTime = DateUtils.addDays(endTime, 1); |
| | | list.add(this.utilizationRate(mdcEquDepDto.getEquipmentId(), mdcEquDepDto.getEquipmentName(), mdcEquDepDto.getEquipmentType(), startTime, endTime, date, mdcUtilizationRateList)); |
| | | list.add(this.utilizationRateTrend(mdcEquDepDto.getEquipmentId(), mdcEquDepDto.getEquipmentName(), mdcEquDepDto.getEquipmentType(), date, mdcUtilizationRateList, map)); |
| | | } |
| | | mdcEfficiencyListDto.setDataList(list); |
| | | listDtos.add(mdcEfficiencyListDto); |
| | |
| | | mdcEfficiencyListDto.setEquipmentName(mdcEquProDto.getEquipmentName()); |
| | | mdcEfficiencyListDto.setEquipmentType(mdcEquProDto.getEquipmentType()); |
| | | List<MdcUtilizationResultDto> list = new ArrayList<>(); |
| | | List<MdcEquipmentStatisticalInfo> mdcEquipmentStatisticalInfo = mdcEquipmentStatisticalInfoService.findMdcEquipmentStatisticalInfo(mdcEquProDto.getEquipmentId(), dateList.get(0), dateList.get(dateList.size() - 1)); |
| | | Map<String, MdcEquipmentStatisticalInfo> map = mdcEquipmentStatisticalInfo.stream() |
| | | .collect(Collectors.toMap(MdcEquipmentStatisticalInfo::getTheDate, m -> m)); |
| | | for (String date : dateList) { |
| | | Date startTime = DateUtils.toDate(date + " 00:00:00", DateUtils.STR_DATE_TIME_SMALL); |
| | | Date endTime = DateUtils.toDate(date + " 00:00:00", DateUtils.STR_DATE_TIME_SMALL); |
| | | endTime = DateUtils.addDays(endTime, 1); |
| | | list.add(this.utilizationRate(mdcEquProDto.getEquipmentId(), mdcEquProDto.getEquipmentName(), mdcEquProDto.getEquipmentType(), startTime, endTime, date, mdcUtilizationRateList)); |
| | | list.add(this.utilizationRateTrend(mdcEquProDto.getEquipmentId(), mdcEquProDto.getEquipmentName(), mdcEquProDto.getEquipmentType(), date, mdcUtilizationRateList, map)); |
| | | } |
| | | mdcEfficiencyListDto.setDataList(list); |
| | | listDtos.add(mdcEfficiencyListDto); |
| | |
| | | return result; |
| | | } |
| | | |
| | | private MdcUtilizationResultDto utilizationRateTrend(String equipmentId, String equipmentName, String equipmentType, String date, List<MdcUtilizationRate> mdcUtilizationRateList, Map<String, MdcEquipmentStatisticalInfo> map) { |
| | | MdcUtilizationResultDto dto = new MdcUtilizationResultDto(); |
| | | dto.setEquipmentId(equipmentId); |
| | | dto.setEquipmentName(equipmentName); |
| | | dto.setEquipmentType(equipmentType); |
| | | dto.setTheDate(date); |
| | | if (map.containsKey(date.replaceAll("-", ""))) { |
| | | MdcEquipmentStatisticalInfo mdcEquipmentStatisticalInfo = map.get(date.replaceAll("-", "")); |
| | | dto.setUtilizationRate(mdcEquipmentStatisticalInfo.getProcessLong().divide(new BigDecimal("86400"), 6, RoundingMode.HALF_UP)); |
| | | } else { |
| | | dto.setUtilizationRate(new BigDecimal("0")); |
| | | } |
| | | |
| | | long rate = dto.getUtilizationRate().multiply(new BigDecimal("100")).longValue(); |
| | | for (MdcUtilizationRate mdcUtilizationRate : mdcUtilizationRateList) { |
| | | if (rate >= mdcUtilizationRate.getMinimumRange() && rate < mdcUtilizationRate.getMaximumRange()) { |
| | | dto.setColor(mdcUtilizationRate.getRateParameterColor()); |
| | | } |
| | | } |
| | | if (StringUtils.isBlank(dto.getColor())) { |
| | | dto.setColor(mdcUtilizationRateList.get(mdcUtilizationRateList.size() - 1).getRateParameterColor()); |
| | | } |
| | | return dto; |
| | | } |
| | | |
| | | @Override |
| | | public List<BigDecimal> getEfficiencyRate(String equipmentId, String date) { |
| | | return mdcEfficiencyReportMapper.getEfficiencyRate(equipmentId, date); |