| | |
| | | package org.jeecg.modules.mdc.service.impl; |
| | | |
| | | import com.alipay.api.domain.NewsfeedMediaGiftInfo; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.checkerframework.checker.units.qual.A; |
| | | import org.jeecg.common.constant.CommonConstant; |
| | | import org.jeecg.common.exception.JeecgBootException; |
| | | import org.jeecg.modules.mdc.dto.*; |
| | |
| | | import org.jeecg.modules.mdc.mapper.MdcEfficiencyReportMapper; |
| | | import org.jeecg.modules.mdc.service.*; |
| | | import org.jeecg.modules.mdc.util.DateUtils; |
| | | import org.jeecg.modules.mdc.vo.*; |
| | | import org.jeecg.modules.mdc.vo.MdcUtilizationRateDto; |
| | | import org.jeecg.modules.mdc.vo.*; |
| | | import org.jeecg.modules.system.entity.MdcProduction; |
| | | import org.jeecg.modules.system.entity.SysDepart; |
| | | import org.jeecg.modules.system.service.IMdcProductionService; |
| | |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.math.BigDecimal; |
| | | import java.text.ParseException; |
| | | import java.text.SimpleDateFormat; |
| | | import java.time.LocalDate; |
| | | import java.time.format.DateTimeFormatter; |
| | | import java.time.temporal.ChronoUnit; |
| | |
| | | if (vo.getEquipmentIdList() == null || vo.getEquipmentIdList().isEmpty()) { |
| | | result.setMdcEfficiencyList(listDtos); |
| | | } else { |
| | | if (StringUtils.isNotEmpty(vo.getEquipmentType())) { |
| | | List<String> equipmentList = mdcEquipmentService.listEquipmentId(vo.getEquipmentType(), vo.getEquipmentIdList()); |
| | | if (equipmentList != null && !equipmentList.isEmpty()) { |
| | | vo.setEquipmentIdList(equipmentList); |
| | | } else { |
| | | result.setMdcEfficiencyList(listDtos); |
| | | return result; |
| | | } |
| | | } |
| | | // 查询利用率数据 |
| | | List<MdcEfficiencyDto> efficiencyList = mdcEfficiencyReportMapper.efficiencyList(vo); |
| | | // 利用率等级 |
| | |
| | | // 部门层级 |
| | | List<MdcEquDepDto> equipmentList = mdcEquipmentService.findEquDepList(vo.getEquipmentIdList()); |
| | | // 查询所有部门信息 |
| | | List<SysDepart> departList = sysDepartService.list(new LambdaQueryWrapper<SysDepart>().ne(SysDepart::getDelFlag, CommonConstant.DEL_FLAG_1.toString())); |
| | | 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(); |
| | |
| | | // 产线层级 |
| | | List<MdcEquProDto> equipmentList = mdcEquipmentService.findEquProList(vo.getEquipmentIdList()); |
| | | // 查询所有产线信息 |
| | | List<MdcProduction> productionList = mdcProductionService.list(new LambdaQueryWrapper<MdcProduction>().ne(MdcProduction::getDelFlag, CommonConstant.DEL_FLAG_1.toString())); |
| | | 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(); |
| | |
| | | listDtos.add(mdcEfficiencyListDto); |
| | | } |
| | | } |
| | | |
| | | //listDtos.sort(((o1, o2) -> Collator.getInstance(Locale.TRADITIONAL_CHINESE).compare(o1.getLevel3(), o2.getLevel3()))); |
| | | result.setMdcEfficiencyList(listDtos); |
| | | } |
| | | |
| | |
| | | if (vo.getEquipmentIdList() == null || vo.getEquipmentIdList().isEmpty()) { |
| | | result.setMdcEfficiencyList(listDtos); |
| | | } else { |
| | | if (StringUtils.isNotEmpty(vo.getEquipmentType())) { |
| | | List<String> equipmentList = mdcEquipmentService.listEquipmentId(vo.getEquipmentType(), vo.getEquipmentIdList()); |
| | | if (equipmentList != null && !equipmentList.isEmpty()) { |
| | | vo.setEquipmentIdList(equipmentList); |
| | | } else { |
| | | result.setMdcEfficiencyList(listDtos); |
| | | return result; |
| | | } |
| | | } |
| | | // 查询利用率数据 |
| | | List<MdcEfficiencyDto> efficiencyList = mdcEfficiencyReportMapper.efficiencyPOList(vo); |
| | | // 利用率等级 |
| | |
| | | // 部门层级 |
| | | List<MdcEquDepDto> equipmentList = mdcEquipmentService.findEquDepList(vo.getEquipmentIdList()); |
| | | // 查询所有部门信息 |
| | | List<SysDepart> departList = sysDepartService.list(new LambdaQueryWrapper<SysDepart>().ne(SysDepart::getDelFlag, CommonConstant.DEL_FLAG_1.toString())); |
| | | 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(); |
| | |
| | | // 产线层级 |
| | | List<MdcEquProDto> equipmentList = mdcEquipmentService.findEquProList(vo.getEquipmentIdList()); |
| | | // 查询所有产线信息 |
| | | List<MdcProduction> productionList = mdcProductionService.list(new LambdaQueryWrapper<MdcProduction>().ne(MdcProduction::getDelFlag, CommonConstant.DEL_FLAG_1.toString())); |
| | | 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(); |
| | |
| | | listDtos.add(mdcEfficiencyListDto); |
| | | } |
| | | } |
| | | |
| | | // listDtos.sort(((o1, o2) -> Collator.getInstance(Locale.TRADITIONAL_CHINESE).compare(o1.getLevel3(), o2.getLevel3()))); |
| | | result.setMdcEfficiencyList(listDtos); |
| | | } |
| | | |
| | |
| | | if (vo.getEquipmentIdList() == null || vo.getEquipmentIdList().isEmpty()) { |
| | | result.setMdcEfficiencyList(listDtos); |
| | | } else { |
| | | if (StringUtils.isNotEmpty(vo.getEquipmentType())) { |
| | | List<String> equipmentList = mdcEquipmentService.listEquipmentId(vo.getEquipmentType(), vo.getEquipmentIdList()); |
| | | if (equipmentList != null && !equipmentList.isEmpty()) { |
| | | vo.setEquipmentIdList(equipmentList); |
| | | } else { |
| | | result.setMdcEfficiencyList(listDtos); |
| | | return result; |
| | | } |
| | | } |
| | | // 班次利用率等级 |
| | | List<MdcUtilizationRate> mdcUtilizationRateList = mdcUtilizationRateService.listByType("bclyl"); |
| | | // 班次利用率数据 |
| | |
| | | // 部门层级 |
| | | List<MdcEquDepDto> equipmentList = mdcEquipmentService.findEquDepList(vo.getEquipmentIdList()); |
| | | // 查询所有部门信息 |
| | | List<SysDepart> departList = sysDepartService.list(new LambdaQueryWrapper<SysDepart>().ne(SysDepart::getDelFlag, CommonConstant.DEL_FLAG_1.toString())); |
| | | List<SysDepart> departList = sysDepartService.list(new LambdaQueryWrapper<SysDepart>().ne(SysDepart::getDelFlag, CommonConstant.DEL_FLAG_1.toString()).orderByAsc(SysDepart::getDepartOrder)); |
| | | // 班次名称显示处理 |
| | | String shiftSubName = ""; |
| | | if (StringUtils.isBlank(vo.getShiftId())) { |
| | |
| | | // 产线层级 |
| | | List<MdcEquProDto> equipmentList = mdcEquipmentService.findEquProList(vo.getEquipmentIdList()); |
| | | // 查询所有产线信息 |
| | | List<MdcProduction> productionList = mdcProductionService.list(new LambdaQueryWrapper<MdcProduction>().ne(MdcProduction::getDelFlag, CommonConstant.DEL_FLAG_1.toString())); |
| | | List<MdcProduction> productionList = mdcProductionService.list(new LambdaQueryWrapper<MdcProduction>().ne(MdcProduction::getDelFlag, CommonConstant.DEL_FLAG_1.toString()).orderByAsc(MdcProduction::getProductionOrder)); |
| | | |
| | | // 班次名称显示处理 |
| | | String shiftSubName = ""; |
| | |
| | | listDtos.add(mdcEfficiencyShiftListDto); |
| | | } |
| | | } |
| | | // listDtos.sort(((o1, o2) -> Collator.getInstance(Locale.TRADITIONAL_CHINESE).compare(o1.getLevel3(), o2.getLevel3()))); |
| | | result.setMdcEfficiencyList(listDtos); |
| | | } |
| | | return result; |
| | |
| | | mdcEfficiencyShiftResultDto.setColor(mdcUtilizationRate.getRateParameterColor()); |
| | | } |
| | | } |
| | | } else { |
| | | mdcEfficiencyShiftResultDto.setTheDate(date); |
| | | mdcEfficiencyShiftResultDto.setProcessLong(new BigDecimal("0")); |
| | | mdcEfficiencyShiftResultDto.setUtilizationRate(new BigDecimal("0")); |
| | | mdcEfficiencyShiftResultDto.setStartRate(new BigDecimal("0")); |
| | | mdcEfficiencyShiftResultDto.setOpenRate(new BigDecimal("0")); |
| | | mdcEfficiencyShiftResultDto.setOpenLong(new BigDecimal("0")); |
| | | mdcEfficiencyShiftResultDto.setWaitLong(new BigDecimal("0")); |
| | | mdcEfficiencyShiftResultDto.setCloseLong(new BigDecimal("0")); |
| | | for (MdcUtilizationRate mdcUtilizationRate : mdcUtilizationRateList) { |
| | | if (0 >= mdcUtilizationRate.getMinimumRange() && 0 < mdcUtilizationRate.getMaximumRange()) { |
| | | mdcEfficiencyShiftResultDto.setColor(mdcUtilizationRate.getRateParameterColor()); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } else { |
| | | mdcEfficiencyShiftResultDto.setTheDate(date); |
| | | mdcEfficiencyShiftResultDto.setProcessLong(new BigDecimal("0")); |
| | | mdcEfficiencyShiftResultDto.setUtilizationRate(new BigDecimal("0")); |
| | | mdcEfficiencyShiftResultDto.setStartRate(new BigDecimal("0")); |
| | | mdcEfficiencyShiftResultDto.setOpenRate(new BigDecimal("0")); |
| | | mdcEfficiencyShiftResultDto.setOpenLong(new BigDecimal("0")); |
| | | mdcEfficiencyShiftResultDto.setWaitLong(new BigDecimal("0")); |
| | | mdcEfficiencyShiftResultDto.setCloseLong(new BigDecimal("0")); |
| | | for (MdcUtilizationRate mdcUtilizationRate : mdcUtilizationRateList) { |
| | | if (0 >= mdcUtilizationRate.getMinimumRange() && 0 < mdcUtilizationRate.getMaximumRange()) { |
| | | mdcEfficiencyShiftResultDto.setColor(mdcUtilizationRate.getRateParameterColor()); |
| | | } |
| | | } |
| | | } |
| | | if (StringUtils.isBlank(mdcEfficiencyShiftResultDto.getColor())) { |
| | | mdcEfficiencyShiftResultDto.setTheDate(date); |
| | | mdcEfficiencyShiftResultDto.setProcessLong(new BigDecimal("0")); |
| | | mdcEfficiencyShiftResultDto.setUtilizationRate(new BigDecimal("0")); |
| | |
| | | } |
| | | result = this.efficiencyStatisticalRate(efficiencyList); |
| | | if (result.getOpenRate().compareTo(new BigDecimal("0")) > 0) { |
| | | result.setOpenRate(result.getOpenRate().multiply(new BigDecimal("100")).divide(new BigDecimal(equipmentIds.size()), 2, BigDecimal.ROUND_HALF_UP)); |
| | | result.setOpenRate(result.getOpenRate().multiply(new BigDecimal("100")).divide(new BigDecimal(vo.getEquipmentIdList().size()), 2, BigDecimal.ROUND_HALF_UP)); |
| | | } |
| | | if (result.getUtilizationRate().compareTo(new BigDecimal("0")) > 0) { |
| | | result.setUtilizationRate(result.getUtilizationRate().multiply(new BigDecimal(100)).divide(new BigDecimal(equipmentIds.size()), 2, BigDecimal.ROUND_HALF_UP)); |
| | | result.setUtilizationRate(result.getUtilizationRate().multiply(new BigDecimal(100)).divide(new BigDecimal(vo.getEquipmentIdList().size()), 2, BigDecimal.ROUND_HALF_UP)); |
| | | } |
| | | if (result.getOpenLong().compareTo(new BigDecimal(0)) > 0 && result.getProcessLong().compareTo(new BigDecimal(0)) > 0) { |
| | | result.setUsedOpenRate(result.getProcessLong().divide(result.getOpenLong(), 4, BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal(100))); |
| | |
| | | } |
| | | } else if (StringUtils.isNotEmpty(vo.getEquipmentId())) { |
| | | // 单台设备信息 |
| | | vo.setEquipmentIdList(Collections.singletonList(vo.getEquipmentId())); |
| | | vo.setEquipmentIdList(Arrays.asList(vo.getEquipmentId().split(","))); |
| | | } else { |
| | | // 查询用户拥有的所有设备信息 |
| | | if ("2".equals(vo.getTypeTree())) { |
| | |
| | | dto.setColor(mdcUtilizationRate.getRateParameterColor()); |
| | | } |
| | | } |
| | | if (StringUtils.isBlank(dto.getColor())) { |
| | | dto.setColor(mdcUtilizationRateList.get(mdcUtilizationRateList.size() - 1).getRateParameterColor()); |
| | | } |
| | | return dto; |
| | | } |
| | | |
| | |
| | | mdcEfficiencyResultDto.setColor(mdcUtilizationRate.getRateParameterColor()); |
| | | } |
| | | } |
| | | } else { |
| | | mdcEfficiencyResultDto.setTheDate(date); |
| | | mdcEfficiencyResultDto.setProcessLong(new BigDecimal("0")); |
| | | mdcEfficiencyResultDto.setUtilizationRate(new BigDecimal("0")); |
| | | mdcEfficiencyResultDto.setStartRate(new BigDecimal("0")); |
| | | mdcEfficiencyResultDto.setOpenRate(new BigDecimal("0")); |
| | | mdcEfficiencyResultDto.setOpenLong(new BigDecimal("0")); |
| | | mdcEfficiencyResultDto.setWaitLong(new BigDecimal("0")); |
| | | mdcEfficiencyResultDto.setCloseLong(new BigDecimal("0")); |
| | | for (MdcUtilizationRate mdcUtilizationRate : mdcUtilizationRateList) { |
| | | if (0 >= mdcUtilizationRate.getMinimumRange() && 0 < mdcUtilizationRate.getMaximumRange()) { |
| | | mdcEfficiencyResultDto.setColor(mdcUtilizationRate.getRateParameterColor()); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } else { |
| | |
| | | } |
| | | } |
| | | } |
| | | |
| | | if (StringUtils.isBlank(mdcEfficiencyResultDto.getColor())) { |
| | | mdcEfficiencyResultDto.setTheDate(date); |
| | | mdcEfficiencyResultDto.setProcessLong(new BigDecimal("0")); |
| | | mdcEfficiencyResultDto.setUtilizationRate(new BigDecimal("0")); |
| | | mdcEfficiencyResultDto.setStartRate(new BigDecimal("0")); |
| | | mdcEfficiencyResultDto.setOpenRate(new BigDecimal("0")); |
| | | mdcEfficiencyResultDto.setOpenLong(new BigDecimal("0")); |
| | | mdcEfficiencyResultDto.setWaitLong(new BigDecimal("0")); |
| | | mdcEfficiencyResultDto.setCloseLong(new BigDecimal("0")); |
| | | for (MdcUtilizationRate mdcUtilizationRate : mdcUtilizationRateList) { |
| | | if (0 >= mdcUtilizationRate.getMinimumRange() && 0 < mdcUtilizationRate.getMaximumRange()) { |
| | | mdcEfficiencyResultDto.setColor(mdcUtilizationRate.getRateParameterColor()); |
| | | } |
| | | } |
| | | } |
| | | return mdcEfficiencyResultDto; |
| | | } |
| | | |