| | |
| | | package org.jeecg.modules.screen.service.impl; |
| | | |
| | | import org.jeecg.modules.mdc.service.IMdcEquipmentStatisticalInfoService; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import org.jeecg.common.constant.CommonConstant; |
| | | import org.jeecg.modules.mdc.dto.MdcEfficiencyDto; |
| | | import org.jeecg.modules.mdcJc.entity.MdcProductDayschedule; |
| | | import org.jeecg.modules.mdcJc.service.IMdcProductDayScheduleService; |
| | | import org.jeecg.modules.screen.dto.*; |
| | | import org.jeecg.modules.screen.mapper.MdcLargeScreenMapper; |
| | | import org.jeecg.modules.screen.service.MdcLargeScreenService; |
| | | import org.jeecg.modules.system.entity.MdcProduction; |
| | | import org.jeecg.modules.system.service.IMdcProductionService; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import javax.annotation.Resource; |
| | |
| | | import java.time.LocalDate; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * @author Lius |
| | |
| | | @Resource |
| | | private MdcLargeScreenMapper mdcLargeScreenMapper; |
| | | |
| | | private final String yesterday = LocalDate.now().plusDays(-1).toString(); |
| | | private final String yesterday = LocalDate.now().plusDays(-1).toString().replaceAll("-", ""); |
| | | |
| | | private final String today = LocalDate.now().toString(); |
| | | |
| | | @Resource |
| | | private IMdcProductionService mdcProductionService; |
| | | |
| | | |
| | | /** |
| | |
| | | BigDecimal processCount = mdcLargeScreenMapper.findYesterdayProcessCount(yesterday); |
| | | BigDecimal utilizationRate = BigDecimal.ZERO; |
| | | if (equipmentCount != null && processCount != null) { |
| | | utilizationRate = processCount.divide(new BigDecimal("86400").multiply(equipmentCount), 0, RoundingMode.HALF_UP).multiply(new BigDecimal("100")).setScale(2, RoundingMode.HALF_UP); |
| | | utilizationRate = processCount.divide(new BigDecimal("86400").multiply(equipmentCount), 4, RoundingMode.HALF_UP).multiply(new BigDecimal("100")).setScale(0, RoundingMode.HALF_UP); |
| | | } |
| | | yesterdayOverviewDto.setUtilizationRate(utilizationRate); |
| | | return yesterdayOverviewDto; |
| | |
| | | for (MdcProductDayschedule mdcProductDayschedule : list) { |
| | | TodayProductionPassRateDto todayProductionPassRateDto = new TodayProductionPassRateDto(); |
| | | todayProductionPassRateDto.setProductionName(mdcProductDayschedule.getProductName()); |
| | | todayProductionPassRateDto.setPassRate(new BigDecimal(mdcProductDayschedule.getQualifiedCount()).divide(new BigDecimal(mdcProductDayschedule.getCompletionCount()), 0, RoundingMode.HALF_UP).multiply(new BigDecimal("100")).setScale(2, RoundingMode.HALF_UP)); |
| | | result.add(todayProductionPassRateDto); |
| | | if (mdcProductDayschedule.getCompletionCount() != 0) { |
| | | todayProductionPassRateDto.setPassRate(new BigDecimal(mdcProductDayschedule.getQualifiedCount()).divide(new BigDecimal(mdcProductDayschedule.getCompletionCount()), 0, RoundingMode.HALF_UP).multiply(new BigDecimal("100")).setScale(2, RoundingMode.HALF_UP)); |
| | | } |
| | | if (!(todayProductionPassRateDto.getPassRate().compareTo(BigDecimal.ZERO) == 0)) { |
| | | result.add(todayProductionPassRateDto); |
| | | } |
| | | } |
| | | } |
| | | return result; |
| | |
| | | */ |
| | | @Override |
| | | public List<ClazzCompletionCountDto> todayClazzCompletionCount() { |
| | | return mdcLargeScreenMapper.todayClazzCompletionCount(today); |
| | | List<ClazzCompletionCountDto> result = mdcLargeScreenMapper.todayClazzCompletionCount(today); |
| | | return result.stream().filter(clazzCompletionCountDto -> clazzCompletionCountDto.getCompletionCount() != 0).collect(Collectors.toList()); |
| | | } |
| | | |
| | | /** |
| | |
| | | */ |
| | | @Override |
| | | public List<EquipmentRateDto> todayEquipmentRate() { |
| | | return null; |
| | | // return mdcLargeScreenMapper.todayEquipmentRate(); |
| | | List<EquipmentRateDto> result = new ArrayList<>(); |
| | | List<MdcEfficiencyDto> mdcEfficiencyDtoList = mdcLargeScreenMapper.efficiencyList(yesterday); |
| | | if (mdcEfficiencyDtoList != null && !mdcEfficiencyDtoList.isEmpty()) { |
| | | for (MdcEfficiencyDto mdcEfficiencyDto : mdcEfficiencyDtoList) { |
| | | EquipmentRateDto equipmentRateDto = new EquipmentRateDto(); |
| | | equipmentRateDto.setEquipmentId(mdcEfficiencyDto.getEquipmentId()); |
| | | equipmentRateDto.setEquipmentName(mdcEfficiencyDto.getEquipmentName()); |
| | | equipmentRateDto.setOpenRate(mdcEfficiencyDto.getOpenRate().multiply(new BigDecimal("100")).setScale(2, RoundingMode.HALF_UP)); |
| | | equipmentRateDto.setUtilizationRate(mdcEfficiencyDto.getUtilizationRate().multiply(new BigDecimal("100")).setScale(2, RoundingMode.HALF_UP)); |
| | | if (!(equipmentRateDto.getOpenRate().compareTo(BigDecimal.ZERO) == 0) && !(equipmentRateDto.getUtilizationRate().compareTo(BigDecimal.ZERO) == 0)) { |
| | | result.add(equipmentRateDto); |
| | | } |
| | | } |
| | | } |
| | | return result; |
| | | } |
| | | |
| | | /** |
| | | * 月利用率 |
| | | * |
| | | * @return |
| | | */ |
| | | @Override |
| | | public List<MonthEquipmentUtilizationRateDto> monthEquipmentUtilizationRate() { |
| | | List<MonthEquipmentUtilizationRateDto> result = new ArrayList<>(); |
| | | String startDate = LocalDate.now().plusDays(-32).toString().replaceAll("-", ""); |
| | | List<MdcEfficiencyDto> mdcEfficiencyDtoList = mdcLargeScreenMapper.efficiency(startDate, yesterday); |
| | | if (mdcEfficiencyDtoList != null && !mdcEfficiencyDtoList.isEmpty()) { |
| | | for (MdcEfficiencyDto mdcEfficiencyDto : mdcEfficiencyDtoList) { |
| | | MonthEquipmentUtilizationRateDto meu = new MonthEquipmentUtilizationRateDto(); |
| | | meu.setDate(new StringBuilder(mdcEfficiencyDto.getTheDate().substring(4, 8)).insert(2, "-").toString()); |
| | | BigDecimal equipmentCount = mdcLargeScreenMapper.findEquipmentCount(yesterday); |
| | | meu.setUtilizationRate(mdcEfficiencyDto.getProcessLong().divide(equipmentCount.multiply(new BigDecimal("86400")), 4, RoundingMode.HALF_UP).multiply(new BigDecimal("100")).setScale(2, RoundingMode.HALF_UP)); |
| | | if (!(meu.getUtilizationRate().compareTo(BigDecimal.ZERO) == 0)) { |
| | | result.add(meu); |
| | | } |
| | | } |
| | | } |
| | | return result; |
| | | } |
| | | |
| | | @Override |
| | | public List<MdcProduction> productionList() { |
| | | return mdcProductionService.list(new LambdaQueryWrapper<MdcProduction>().eq(MdcProduction::getOrgType, "3").eq(MdcProduction::getDelFlag, CommonConstant.DEL_FLAG_0.toString()).orderByAsc(MdcProduction::getProductionOrder)); |
| | | } |
| | | |
| | | } |