lyh
2025-07-08 f846dfa6e98f5ca07ea25fc235a25138e0f3416d
lxzn-module-eam/src/main/java/org/jeecg/modules/eam/service/impl/EamTechnicalStatusEvaluationStandardServiceImpl.java
@@ -13,10 +13,11 @@
import org.jeecg.common.exception.JeecgBootException;
import org.jeecg.common.system.vo.LoginUser;
import org.jeecg.common.util.SimpleVersionGenerateUtil;
import org.jeecg.modules.eam.base.entity.BaseFactory;
import org.jeecg.modules.eam.base.entity.BaseFactoryUser;
import org.jeecg.modules.eam.base.service.IBaseFactoryService;
import org.jeecg.modules.eam.base.service.IBaseFactoryUserService;
import org.jeecg.modules.system.entity.BaseFactory;
import org.jeecg.modules.system.entity.BaseFactoryUser;
import org.jeecg.modules.system.service.IBaseFactoryService;
import org.jeecg.modules.system.service.IBaseFactoryUserService;
import org.jeecg.modules.eam.constant.TechnicalStatusEvaluationCheckCategoryEnum;
import org.jeecg.modules.eam.constant.TechnicalStatusEvaluationStandardEnum;
import org.jeecg.modules.eam.entity.EamTechnicalStatusEvaluationStandard;
import org.jeecg.modules.eam.entity.EamTechnicalStatusEvaluationStandardDetail;
@@ -29,7 +30,6 @@
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
@@ -101,6 +101,10 @@
    @Override
    @Transactional(rollbackFor = Exception.class)
    public boolean addEamTechnicalStatusEvaluationStandard(EamTechnicalStatusEvaluationStandardRequest request) {
        if(!CommonConstant.STATUS_1.equals(request.getHasOtherCheck()) && !CommonConstant.STATUS_1.equals(request.getHasSafetyEquipmentCheck()) && !CommonConstant.STATUS_1.equals(request.getHasPrecisionCheck())) {
            //必须要选择一个检查分类
            throw new JeecgBootException("必须要选择一个检查分类!");
        }
        EamTechnicalStatusEvaluationStandard entity = new EamTechnicalStatusEvaluationStandard();
        BeanUtils.copyProperties(request, entity);
        entity.setStandardStatus(TechnicalStatusEvaluationStandardEnum.WAIT_SUBMIT.name());
@@ -121,7 +125,31 @@
            request.getTableDetailList().forEach(tableDetail -> {
                tableDetail.setStandardId(entity.getId());
            });
            standardDetailService.saveBatch(request.getTableDetailList());
            //根据分类判断是否保存
            if(CommonConstant.STATUS_1.equals(entity.getHasOtherCheck())) {
                //保存其他分类
                List<EamTechnicalStatusEvaluationStandardDetail> collect = request.getTableDetailList().stream().filter(item -> TechnicalStatusEvaluationCheckCategoryEnum.OTHER_CHECK.name().equals(item.getCheckCategory())).collect(Collectors.toList());
                if(CollectionUtils.isEmpty(collect)) {
                    throw new JeecgBootException("其他检查明细不能为空!");
                }
                standardDetailService.saveBatch(collect);
            }
            if(CommonConstant.STATUS_1.equals(entity.getHasSafetyEquipmentCheck())) {
                //保存安全装置分类
                List<EamTechnicalStatusEvaluationStandardDetail> collect = request.getTableDetailList().stream().filter(item -> TechnicalStatusEvaluationCheckCategoryEnum.SAFETY_EQUIPMENT_CHECK.name().equals(item.getCheckCategory())).collect(Collectors.toList());
                if(CollectionUtils.isEmpty(collect)) {
                    throw new JeecgBootException("安全装置检查明细不能为空!");
                }
                standardDetailService.saveBatch(collect);
            }
            if(CommonConstant.STATUS_1.equals(entity.getHasPrecisionCheck())) {
                //保存精度检验分类
                List<EamTechnicalStatusEvaluationStandardDetail> collect = request.getTableDetailList().stream().filter(item -> TechnicalStatusEvaluationCheckCategoryEnum.PRECISION_CHECK.name().equals(item.getCheckCategory())).collect(Collectors.toList());
                if(CollectionUtils.isEmpty(collect)) {
                    throw new JeecgBootException("精度检查明细不能为空!");
                }
                standardDetailService.saveBatch(collect);
            }
        }
        return true;
    }
@@ -147,35 +175,50 @@
    @Override
    @Transactional(rollbackFor = Exception.class)
    public boolean editEamTechnicalStatusEvaluationStandard(EamTechnicalStatusEvaluationStandardRequest request) {
        if(!CommonConstant.STATUS_1.equals(request.getHasOtherCheck()) && !CommonConstant.STATUS_1.equals(request.getHasSafetyEquipmentCheck()) && !CommonConstant.STATUS_1.equals(request.getHasPrecisionCheck())) {
            //必须要选择一个检查分类
            throw new JeecgBootException("必须要选择一个检查分类!");
        }
        EamTechnicalStatusEvaluationStandard entity = this.getBaseMapper().selectById(request.getId());
        if(entity == null){
            throw new JeecgBootException("编辑的数据已删除,请刷新重试!");
        }
        entity.setStandardName(request.getStandardName());
        entity.setEvaluationPeriod(request.getEvaluationPeriod());
        entity.setHasOtherCheck(request.getHasOtherCheck());
        entity.setHasPrecisionCheck(request.getHasPrecisionCheck());
        entity.setHasSafetyEquipmentCheck(request.getHasSafetyEquipmentCheck());
        this.getBaseMapper().updateById(entity);
        //处理详情
        if(CollectionUtil.isNotEmpty(request.getTableDetailList())) {
            List<EamTechnicalStatusEvaluationStandardDetail> addList = new ArrayList<>();
            List<EamTechnicalStatusEvaluationStandardDetail> updateList = new ArrayList<>();
            request.getTableDetailList().forEach(tableDetail -> {
                tableDetail.setStandardId(entity.getId());
                if(tableDetail.getId() == null){
                    addList.add(tableDetail);
                }else {
                    updateList.add(tableDetail);
            //先删除检查项
            standardDetailService.removeByStandardId(entity.getId());
            //根据分类判断是否保存
            if(CommonConstant.STATUS_1.equals(entity.getHasOtherCheck())) {
                //保存其他分类
                List<EamTechnicalStatusEvaluationStandardDetail> collect = request.getTableDetailList().stream().filter(item -> TechnicalStatusEvaluationCheckCategoryEnum.OTHER_CHECK.name().equals(item.getCheckCategory())).collect(Collectors.toList());
                if(CollectionUtils.isEmpty(collect)) {
                    throw new JeecgBootException("其他检查明细不能为空!");
                }
            });
            if(CollectionUtil.isNotEmpty(addList)){
                standardDetailService.saveBatch(addList);
                standardDetailService.saveBatch(collect);
            }
            if(CollectionUtil.isNotEmpty(updateList)){
                standardDetailService.updateBatchById(updateList);
            if(CommonConstant.STATUS_1.equals(entity.getHasSafetyEquipmentCheck())) {
                //保存安全装置分类
                List<EamTechnicalStatusEvaluationStandardDetail> collect = request.getTableDetailList().stream().filter(item -> TechnicalStatusEvaluationCheckCategoryEnum.SAFETY_EQUIPMENT_CHECK.name().equals(item.getCheckCategory())).collect(Collectors.toList());
                if(CollectionUtils.isEmpty(collect)) {
                    throw new JeecgBootException("安全装置检查明细不能为空!");
                }
                standardDetailService.saveBatch(collect);
            }
        }
        if(CollectionUtil.isNotEmpty(request.getRemoveDetailList())) {
            List<String> ids = request.getRemoveDetailList().stream().map(EamTechnicalStatusEvaluationStandardDetail::getId).collect(Collectors.toList());
            standardDetailService.removeBatchByIds(ids);
            if(CommonConstant.STATUS_1.equals(entity.getHasPrecisionCheck())) {
                //保存精度检验分类
                List<EamTechnicalStatusEvaluationStandardDetail> collect = request.getTableDetailList().stream().filter(item -> TechnicalStatusEvaluationCheckCategoryEnum.PRECISION_CHECK.name().equals(item.getCheckCategory())).collect(Collectors.toList());
                if(CollectionUtils.isEmpty(collect)) {
                    throw new JeecgBootException("精度检查明细不能为空!");
                }
                standardDetailService.saveBatch(collect);
            }
        }
        return true;
    }
@@ -183,6 +226,10 @@
    @Override
    @Transactional(rollbackFor = Exception.class)
    public boolean upgrade(EamTechnicalStatusEvaluationStandardRequest request) {
        if(!CommonConstant.STATUS_1.equals(request.getHasOtherCheck()) && !CommonConstant.STATUS_1.equals(request.getHasSafetyEquipmentCheck()) && !CommonConstant.STATUS_1.equals(request.getHasPrecisionCheck())) {
            //必须要选择一个检查分类
            throw new JeecgBootException("必须要选择一个检查分类!");
        }
        EamTechnicalStatusEvaluationStandard entity = this.getBaseMapper().selectById(request.getId());
        if(entity == null){
            throw new JeecgBootException("升版的数据已删除,请刷新重试!");
@@ -198,6 +245,9 @@
        newEntity.setStandardVersion(SimpleVersionGenerateUtil.addVersion(entity.getStandardVersion()));
        //设备处理
        newEntity.setEquipmentId(request.getEquipmentId());
        newEntity.setHasOtherCheck(request.getHasOtherCheck());
        newEntity.setHasPrecisionCheck(request.getHasPrecisionCheck());
        newEntity.setHasSafetyEquipmentCheck(request.getHasSafetyEquipmentCheck());
        //删除标记
        newEntity.setDelFlag(CommonConstant.DEL_FLAG_0);
        //重复性校验
@@ -216,7 +266,31 @@
                tableDetail.setUpdateTime(null);
                tableDetail.setStandardId(newEntity.getId());
            });
            standardDetailService.saveBatch(request.getTableDetailList());
            //根据分类判断是否保存
            if(CommonConstant.STATUS_1.equals(entity.getHasOtherCheck())) {
                //保存其他分类
                List<EamTechnicalStatusEvaluationStandardDetail> collect = request.getTableDetailList().stream().filter(item -> TechnicalStatusEvaluationCheckCategoryEnum.OTHER_CHECK.name().equals(item.getCheckCategory())).collect(Collectors.toList());
                if(CollectionUtils.isEmpty(collect)) {
                    throw new JeecgBootException("其他检查明细不能为空!");
                }
                standardDetailService.saveBatch(collect);
            }
            if(CommonConstant.STATUS_1.equals(entity.getHasSafetyEquipmentCheck())) {
                //保存安全装置分类
                List<EamTechnicalStatusEvaluationStandardDetail> collect = request.getTableDetailList().stream().filter(item -> TechnicalStatusEvaluationCheckCategoryEnum.SAFETY_EQUIPMENT_CHECK.name().equals(item.getCheckCategory())).collect(Collectors.toList());
                if(CollectionUtils.isEmpty(collect)) {
                    throw new JeecgBootException("安全装置检查明细不能为空!");
                }
                standardDetailService.saveBatch(collect);
            }
            if(CommonConstant.STATUS_1.equals(entity.getHasPrecisionCheck())) {
                //保存精度检验分类
                List<EamTechnicalStatusEvaluationStandardDetail> collect = request.getTableDetailList().stream().filter(item -> TechnicalStatusEvaluationCheckCategoryEnum.PRECISION_CHECK.name().equals(item.getCheckCategory())).collect(Collectors.toList());
                if(CollectionUtils.isEmpty(collect)) {
                    throw new JeecgBootException("精度检查明细不能为空!");
                }
                standardDetailService.saveBatch(collect);
            }
        }
        //禁用原来的版本
        entity.setStandardStatus(TechnicalStatusEvaluationStandardEnum.DISABLE.name());