Lius
2025-04-27 2f98fd6d840a1f10c0518e1b24d6c28debe06917
lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcOeeInfoServiceImpl.java
@@ -15,6 +15,7 @@
import org.jeecg.modules.mdc.util.DateUtils;
import org.jeecg.modules.mdc.vo.MdcOeeComputeVo;
import org.jeecg.modules.mdc.vo.MdcOeeInfoVo;
import org.jeecg.modules.mdcJc.service.IMdcJcRcJobreportService;
import org.jeecgframework.poi.excel.def.NormalExcelConstants;
import org.jeecgframework.poi.excel.entity.ExportParams;
import org.jeecgframework.poi.excel.view.JeecgEntityExcelView;
@@ -45,8 +46,11 @@
    @Resource
    private IMdcDowntimeService mdcDowntimeService;
//    @Resource
//    private IMdcPartProcessInfoService mdcPartProcessInfoService;
    @Resource
    private IMdcPartProcessInfoService mdcPartProcessInfoService;
    private IMdcJcRcJobreportService mdcJcRcJobreportService;
    @Resource
    private IMdcEquipmentStatisticalInfoService mdcEquipmentStatisticalInfoService;
@@ -165,8 +169,8 @@
    @Transactional(rollbackFor = Exception.class)
    public void computeOee(MdcOeeComputeVo mdcOeeComputeVo) {
        List<MdcOeeInfo> result = new ArrayList<>();
        String startDate = mdcOeeComputeVo.getStartDate();
        String endDate = mdcOeeComputeVo.getEndDate();
        String startDate = mdcOeeComputeVo.getStartTime();
        String endDate = mdcOeeComputeVo.getEndTime();
        List<String> dateList = DateUtils.getDatesStringList(DateUtils.getShortDate(startDate), DateUtils.getShortDate(endDate));
        if (!dateList.isEmpty()) {
            //获取设备列表
@@ -204,13 +208,17 @@
                    mdcOeeInfo.setTimeActuationRate(timeActuationRate);
                    // 有效运行时间 --- 按需求维护零件加工总时长||系统主轴负载时间
                    Integer effectiveRunLong = 0;
                    Integer totalProcessLong = mdcPartProcessInfoService.selectTotalProcessLong(equipmentId, validDate);
                    if (totalProcessLong == 0) {
                        //查询设备运行时间
                        effectiveRunLong = mdcEquipmentStatisticalInfoService.selectProcessLong(equipmentId, validDate.replace("-", ""));
                    } else {
                        effectiveRunLong = totalProcessLong;
//                    Integer totalProcessLong = mdcPartProcessInfoService.selectTotalProcessLong(equipmentId, validDate);
                    //查询设备运行时间
                    effectiveRunLong = mdcEquipmentStatisticalInfoService.selectProcessLong(equipmentId, validDate.replace("-", ""));
                    if (effectiveRunLong == null) {
                        effectiveRunLong = 0;
                    }
//                    if (totalProcessLong == 0) {
//
//                    } else {
//                        effectiveRunLong = totalProcessLong;
//                    }
                    mdcOeeInfo.setEffectiveRunLong(effectiveRunLong);
                    // 性能开动率 --- 有效运行时间/开动时间
                    BigDecimal performanceRate = BigDecimal.ZERO;
@@ -219,13 +227,24 @@
                    }
                    mdcOeeInfo.setPerformanceRate(performanceRate);
                    // 加工零件数量 --- 按维护数据统计当天
                    Integer processCount = mdcPartProcessInfoService.selectTotalProcessCount(equipmentId, validDate);
//                    Integer processCount = mdcPartProcessInfoService.selectTotalProcessCount(equipmentId, validDate);
//                    mdcOeeInfo.setProcessCount(processCount);
//                    // 合格零件数量 --- 按维护数据统计当天
//                    Integer passCount = mdcPartProcessInfoService.selectTotalPassCount(equipmentId, validDate);
//                    mdcOeeInfo.setPassCount(passCount);
//                    // 合格率 --- 合格数/加工数
//                    BigDecimal passRate = BigDecimal.ZERO;
//                    if (processCount != 0 && passCount != 0) {
//                        passRate = new BigDecimal(passCount).divide(new BigDecimal(processCount), 4, RoundingMode.HALF_UP).multiply(new BigDecimal("100")).setScale(2, RoundingMode.HALF_UP);
//                    }
                    // 加工零件数量
                    Integer processCount = mdcJcRcJobreportService.selectTotalProcessCount(equipmentId, validDate);
                    mdcOeeInfo.setProcessCount(processCount);
                    // 合格零件数量 --- 按维护数据统计当天
                    Integer passCount = mdcPartProcessInfoService.selectTotalPassCount(equipmentId, validDate);
                    // 合格零件数量
                    Integer passCount = mdcJcRcJobreportService.selectTotalPassCount(equipmentId, validDate);
                    mdcOeeInfo.setPassCount(passCount);
                    // 合格率 --- 合格数/加工数
                    BigDecimal passRate = BigDecimal.ZERO;
                    BigDecimal passRate = new BigDecimal("100");
                    if (processCount != 0 && passCount != 0) {
                        passRate = new BigDecimal(passCount).divide(new BigDecimal(processCount), 4, RoundingMode.HALF_UP).multiply(new BigDecimal("100")).setScale(2, RoundingMode.HALF_UP);
                    }