Lius
2025-03-31 5cd4558fb1a7178653d77e1a982e6f26d06b5db5
lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/job/CollectEquipmentDataMonthJob.java
@@ -3,6 +3,7 @@
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
import org.jeecg.common.constant.CommonConstant;
import org.jeecg.modules.mdc.dto.MdcEquipmentStatisticalDto;
import org.jeecg.modules.mdc.entity.MdcEquipment;
import org.jeecg.modules.mdc.entity.MdcEquipmentStatisticalInfoMonth;
@@ -113,6 +114,7 @@
                    MdcEquipmentStatisticalShiftInfoMonth mdcEquipmentShiftInfoMonth = new MdcEquipmentStatisticalShiftInfoMonth();
                    mdcEquipmentShiftInfoMonth.setEquipmentId(mdcEquipment.getEquipmentId());
                    mdcEquipmentShiftInfoMonth.setTheMonth(date);
                    mdcEquipmentShiftInfoMonth.setShiftType(CommonConstant.SHIFT_TYPE_1);
                    mdcEquipmentShiftInfoMonth.setCloseLong(mdcEquipmentShiftStatisticalDto.getCloseLong().intValue());
                    mdcEquipmentShiftInfoMonth.setTotalLong(mdcEquipmentShiftStatisticalDto.getTotalLong().intValue());
                    mdcEquipmentShiftInfoMonth.setOpenLong(mdcEquipmentShiftStatisticalDto.getOpenLong().intValue());
@@ -123,6 +125,26 @@
                    mdcEquipmentShiftInfoMonth.setStartRate(mdcEquipmentShiftStatisticalDto.getOpenLong().compareTo(BigDecimal.ZERO) > 0 ? mdcEquipmentShiftStatisticalDto.getProcessLong().divide(mdcEquipmentShiftStatisticalDto.getOpenLong(), 4, RoundingMode.HALF_UP) : BigDecimal.ZERO);
                    mdcEquipmentShiftInfoMonth.setOpenRate(mdcEquipmentShiftStatisticalDto.getTotalLong().compareTo(BigDecimal.ZERO) > 0 ? mdcEquipmentShiftStatisticalDto.getOpenLong().divide(mdcEquipmentShiftStatisticalDto.getTotalLong(), 4, RoundingMode.HALF_UP) : BigDecimal.ZERO);
                    mdcEquipmentStatisticalShiftInfoMonthList.add(mdcEquipmentShiftInfoMonth);
                    // step.4 汇总各班次利用率数据
                    List<MdcEquipmentStatisticalDto> essdList = mdcEquipmentStatisticalShiftInfoService.findShiftByEquipmentAndMonth(mdcEquipment.getEquipmentId(), date);
                    if (essdList != null && !essdList.isEmpty()) {
                        for (MdcEquipmentStatisticalDto equipmentStatisticalDto : essdList) {
                            MdcEquipmentStatisticalShiftInfoMonth equipmentStatisticalShiftInfoMonth = new MdcEquipmentStatisticalShiftInfoMonth();
                            equipmentStatisticalShiftInfoMonth.setEquipmentId(mdcEquipment.getEquipmentId());
                            equipmentStatisticalShiftInfoMonth.setTheMonth(date);
                            equipmentStatisticalShiftInfoMonth.setShiftType(CommonConstant.SHIFT_TYPE_2);
                            equipmentStatisticalShiftInfoMonth.setCloseLong(equipmentStatisticalDto.getCloseLong().intValue());
                            equipmentStatisticalShiftInfoMonth.setTotalLong(equipmentStatisticalDto.getTotalLong().intValue());
                            equipmentStatisticalShiftInfoMonth.setOpenLong(equipmentStatisticalDto.getOpenLong().intValue());
                            equipmentStatisticalShiftInfoMonth.setErrorLong(equipmentStatisticalDto.getErrorLong().intValue());
                            equipmentStatisticalShiftInfoMonth.setWaitLong(equipmentStatisticalDto.getWaitLong().intValue());
                            equipmentStatisticalShiftInfoMonth.setProcessLong(equipmentStatisticalDto.getProcessLong().intValue());
                            equipmentStatisticalShiftInfoMonth.setUtilizationRate(equipmentStatisticalDto.getTotalLong().compareTo(BigDecimal.ZERO) > 0 ? equipmentStatisticalDto.getProcessLong().divide(equipmentStatisticalDto.getTotalLong(), 4, RoundingMode.HALF_UP) : BigDecimal.ZERO);
                            equipmentStatisticalShiftInfoMonth.setStartRate(equipmentStatisticalDto.getOpenLong().compareTo(BigDecimal.ZERO) > 0 ? equipmentStatisticalDto.getProcessLong().divide(equipmentStatisticalDto.getOpenLong(), 4, RoundingMode.HALF_UP) : BigDecimal.ZERO);
                            equipmentStatisticalShiftInfoMonth.setOpenRate(equipmentStatisticalDto.getTotalLong().compareTo(BigDecimal.ZERO) > 0 ? equipmentStatisticalDto.getOpenLong().divide(equipmentStatisticalDto.getTotalLong(), 4, RoundingMode.HALF_UP) : BigDecimal.ZERO);
                            mdcEquipmentStatisticalShiftInfoMonthList.add(equipmentStatisticalShiftInfoMonth);
                        }
                    }
                }
            }
            if (!mdcEquipmentStatisticalInfoMonthList.isEmpty()) {