Lius
2025-06-17 d0f024586f38a11662787c42b84e037a1c1be6cd
lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcEquipmentStatisticalInfoServiceImpl.java
@@ -4,6 +4,7 @@
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.apache.commons.lang.StringUtils;
import org.jeecg.common.system.vo.DictModel;
import org.jeecg.modules.mdc.dto.MdcEquipmentStatisticalDto;
import org.jeecg.modules.mdc.entity.*;
import org.jeecg.modules.mdc.mapper.MdcEquipmentStatisticalInfoMapper;
import org.jeecg.modules.mdc.service.*;
@@ -36,10 +37,7 @@
    private IMdcSystemParametersService mdcSystemParametersService;
    @Resource
    private ISysDictService sysDictService;
    @Resource
    private IEquipmentStatisticalInfoService equipmentStatisticalInfoService;
    private IMdcEquipmentFaultInfoService mdcEquipmentFaultInfoService;
    /**
     * 计算设备单日运行数据
@@ -68,28 +66,8 @@
        }
        if (!result.isEmpty()) {
            this.saveBatch(result);
            List<DictModel> dictList = sysDictService.queryDictItemsByCode("data_synchronization_flag");
            if (dictList != null && !dictList.isEmpty() && "0".equals(dictList.get(0).getValue())) {
                List<EquipmentStatisticalInfo> list = this.dataHandle(result);
                equipmentStatisticalInfoService.saveBatch(list);
            }
        }
    }
    private List<EquipmentStatisticalInfo> dataHandle(List<MdcEquipmentStatisticalInfo> list) {
        List<EquipmentStatisticalInfo> result = new ArrayList<>();
        list.forEach(item -> {
            EquipmentStatisticalInfo equipmentStatisticalInfo = new EquipmentStatisticalInfo();
            equipmentStatisticalInfo.setEquipment(item.getEquipmentId());
            equipmentStatisticalInfo.setTheDate(item.getTheDate());
            equipmentStatisticalInfo.setClosedLong(item.getCloseLong());
            equipmentStatisticalInfo.setOpeningLong(item.getOpenLong());
            equipmentStatisticalInfo.setErroringLong(item.getErrorLong());
            equipmentStatisticalInfo.setProcessingLong(item.getProcessLong());
            equipmentStatisticalInfo.setWaitingLong(item.getWaitLong());
            result.add(equipmentStatisticalInfo);
        });
        return result;
        mdcEquipmentFaultInfoService.runningAllEquFaultStatistical(dateTime);
    }
    private List<MdcEquipmentStatisticalInfo> equipmentStatisticalProcess(Equipment equipment, String dateTime) {
@@ -140,7 +118,6 @@
                List<MdcEquipmentRunningSection> equipmentRunningSectionList = mdcEquipmentRunningSectionService.listForEquipmentStatisticalInfo(equipment.getEquipmentid(), startDate, endDate);
                return this.statisticsData(equipmentRunningSectionList, planTime, startDate, endDate, equipment);
            } else {
                //待验证
                Date end = DateUtils.plusTime(initDate, 1);
                endDate = DateUtils.setTimeForDay(end, planTime);
                List<MdcEquipmentRunningSection> equipmentRunningSectionList = mdcEquipmentRunningSectionService.listForEquipmentStatisticalInfo(equipment.getEquipmentid(), startDate, endDate);
@@ -317,4 +294,19 @@
            return Integer.parseInt(new BigDecimal(processLong).divide(new BigDecimal("60"), 0, RoundingMode.HALF_UP).toString());
        }
    }
    @Override
    public MdcEquipmentStatisticalDto findByEquipmentAndMonth(String equipmentId, String date) {
        return this.baseMapper.findByEquipmentAndMonth(equipmentId, date);
    }
    @Override
    public MdcEquipmentStatisticalInfo findByEquIdsAndMonth(List<String> equipmentIdList, String month) {
        return this.baseMapper.findByEquIdsAndMonth(equipmentIdList, month);
    }
    @Override
    public List<MdcEquipmentStatisticalInfo> findByEquipmentAndDate(List<String> equipmentIdList, String date) {
        return this.baseMapper.findByEquipmentAndDate(equipmentIdList, date);
    }
}