zhangherong
2025-05-06 665ffec07abac9fa14e7613fe1c73922a537ff77
lxzn-module-eam/src/main/java/org/jeecg/modules/eam/service/impl/EamReportRepairServiceImpl.java
@@ -1,5 +1,7 @@
package org.jeecg.modules.eam.service.impl;
import cn.hutool.core.collection.CollectionUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.fasterxml.jackson.core.JsonProcessingException;
@@ -7,32 +9,25 @@
import org.apache.commons.lang3.StringUtils;
import org.apache.shiro.SecurityUtils;
import org.jeecg.common.api.vo.FileUploadResult;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.constant.CommonConstant;
import org.jeecg.common.system.vo.LoginUser;
import org.jeecg.modules.eam.aspect.annotation.EquipmentHistoryLog;
import org.jeecg.modules.eam.constant.EquipmentMaintenanceStatus;
import org.jeecg.modules.eam.constant.EquipmentOperationTagEnum;
import org.jeecg.modules.eam.constant.EquipmentRepairStatus;
import org.jeecg.modules.eam.constant.ReportRepairEnum;
import org.jeecg.modules.eam.entity.EamInspectionOrderDetail;
import org.jeecg.modules.eam.entity.EamReportRepair;
import org.jeecg.modules.eam.entity.EamWeekMaintenanceOrderDetail;
import org.jeecg.modules.eam.constant.*;
import org.jeecg.modules.eam.entity.*;
import org.jeecg.modules.eam.mapper.EamReportRepairMapper;
import org.jeecg.modules.eam.request.EamReportRepairQuery;
import org.jeecg.modules.eam.service.IEamEquipmentExtendService;
import org.jeecg.modules.eam.service.IEamReportRepairService;
import org.jeecg.modules.eam.vo.EquipmentRepairStatistics;
import org.jeecg.modules.system.service.IMdcProductionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import java.time.LocalDate;
import java.util.*;
/**
 * @Description: 故障报修
@@ -44,6 +39,8 @@
    @Resource
    private IEamEquipmentExtendService eamEquipmentExtendService;
    @Autowired
    private IMdcProductionService mdcProductionService;
    /**
     * 分页列表
@@ -139,4 +136,45 @@
        eamEquipmentExtendService.updateEquipmentRepairStatus(eamReportRepair.getEquipmentId(), EquipmentRepairStatus.WAIT_REPAIR.name());
        return eamReportRepair;
    }
    @Override
    @Transactional(rollbackFor = Exception.class)
    public boolean edit(EamReportRepair eamReportRepair) {
        // 附件处理
        if (eamReportRepair.getImageFilesResult() != null) {
            List<FileUploadResult> imageFilesResult = eamReportRepair.getImageFilesResult();
            ObjectMapper mapper = new ObjectMapper();
            try {
                String referenceFile = mapper.writeValueAsString(imageFilesResult);
                eamReportRepair.setImageFiles(referenceFile);
            } catch (JsonProcessingException e) {
                return false;
            }
        } else {
            eamReportRepair.setImageFiles(null);
        }
        this.baseMapper.updateById(eamReportRepair);
        return true;
    }
    @Override
    public List<EquipmentRepairStatistics> equipmentRepairStatistics(String productionId, LocalDate firstOfMonth, LocalDate today) {
        if (StringUtils.isNotBlank(productionId)) {
            //车间编码不为空
            List<String> productIds = mdcProductionService.recursionChildren(productionId);
            if (CollectionUtil.isEmpty(productIds)) {
                return Collections.emptyList();
            }
            List<EquipmentRepairStatistics> list = this.baseMapper.equipmentRepairStatistics(productIds, firstOfMonth.toString(), today.plusDays(1).toString());
            if (CollectionUtil.isEmpty(list)) {
                return Collections.emptyList();
            }
            return list;
        }
        List<EquipmentRepairStatistics> list = this.baseMapper.equipmentRepairStatistics(null, firstOfMonth.toString(), today.plusDays(1).toString());
        if (CollectionUtil.isEmpty(list)) {
            return Collections.emptyList();
        }
        return list;
    }
}