Lius
2024-10-12 8635cd104f18bdb629859f57daccfdd0243d6692
lxzn-module-mdc/src/main/java/org/jeecg/modules/screen/service/impl/MdcLargeScreenServiceImpl.java
@@ -1,12 +1,15 @@
package org.jeecg.modules.screen.service.impl;
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.mdc.service.IMdcEquipmentStatisticalInfoService;
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;
@@ -32,6 +35,9 @@
    private final String yesterday = LocalDate.now().plusDays(-1).toString().replaceAll("-", "");
    private final String today = LocalDate.now().toString();
    @Resource
    private IMdcProductionService mdcProductionService;
    /**
@@ -117,11 +123,39 @@
                EquipmentRateDto equipmentRateDto = new EquipmentRateDto();
                equipmentRateDto.setEquipmentId(mdcEfficiencyDto.getEquipmentId());
                equipmentRateDto.setEquipmentName(mdcEfficiencyDto.getEquipmentName());
                equipmentRateDto.setOpenRate(mdcEfficiencyDto.getOpenRate());
                equipmentRateDto.setUtilizationRate(mdcEfficiencyDto.getUtilizationRate());
                equipmentRateDto.setOpenRate(mdcEfficiencyDto.getOpenRate().setScale(4, RoundingMode.HALF_UP));
                equipmentRateDto.setUtilizationRate(mdcEfficiencyDto.getUtilizationRate().setScale(4, RoundingMode.HALF_UP));
                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));
                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));
    }
}