云
5 天以前 cccbfadcb6e96c23a33c40c0687a27c2f6efa1db
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/dv/machinery/MesDvMachineryServiceImpl.java
@@ -4,8 +4,10 @@
import cn.hutool.core.util.ObjUtil;
import cn.hutool.core.util.StrUtil;
import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
import cn.iocoder.yudao.framework.common.exception.ServiceException;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.framework.operatelog.core.util.OperateLogUtils;
import cn.iocoder.yudao.module.mes.controller.admin.dv.machinery.vo.MesDvMachineryImportExcelVO;
import cn.iocoder.yudao.module.mes.controller.admin.dv.machinery.vo.MesDvMachineryImportRespVO;
import cn.iocoder.yudao.module.mes.controller.admin.dv.machinery.vo.MesDvMachineryPageReqVO;
@@ -21,6 +23,7 @@
import cn.iocoder.yudao.module.mes.service.dv.repair.MesDvRepairService;
import cn.iocoder.yudao.module.mes.service.md.workstation.MesMdWorkshopService;
import cn.iocoder.yudao.module.mes.service.wm.barcode.MesWmBarcodeService;
import com.mzt.logapi.starter.annotation.LogRecord;
import jakarta.annotation.Resource;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;
@@ -34,6 +37,7 @@
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
import static cn.iocoder.yudao.module.mes.enums.ErrorCodeConstants.*;
import static cn.iocoder.yudao.module.mes.enums.LogRecordConstants.*;
/**
 * MES 设备台账 Service 实现类
@@ -144,7 +148,8 @@
            return;
        }
        if (ObjUtil.notEqual(machinery.getId(), id)) {
            throw exception(DV_MACHINERY_CODE_DUPLICATE);
            throw new ServiceException(DV_MACHINERY_CODE_DUPLICATE.getCode(),
                    "设备编号[" + code + "]已被设备[" + machinery.getName() + "]使用,请更换编号,或点击“自动生成”重新生成");
        }
    }
@@ -197,6 +202,8 @@
    @Override
    @Transactional(rollbackFor = Exception.class)
    @LogRecord(type = MES_DV_MACHINERY_TYPE, subType = MES_DV_MACHINERY_IMPORT_SUB_TYPE, bizNo = "0",
            success = MES_DV_MACHINERY_IMPORT_SUCCESS)
    public MesDvMachineryImportRespVO importMachineryList(List<MesDvMachineryImportExcelVO> importMachineryList,
                                                          boolean updateSupport) {
        // 1. 参数校验
@@ -231,7 +238,7 @@
            // 3.1 校验必填字段
            String key = StrUtil.blankToDefault(importItem.getCode(), "第 " + currentIndex + " 行");
            if (StrUtil.isBlank(importItem.getCode())) {
                respVO.getFailureCodes().put(key, "设备编码不能为空");
                respVO.getFailureCodes().put(key, "设备编号不能为空");
                return;
            }
            if (StrUtil.isBlank(importItem.getName())) {
@@ -295,9 +302,11 @@
                respVO.getUpdateCodes().add(importItem.getCode());
            } else {
                // 不支持更新
                respVO.getFailureCodes().put(key, "设备编码已存在");
                respVO.getFailureCodes().put(key, "设备编号已存在,如需覆盖请勾选“是否覆盖”后重新导入");
            }
        });
        // 记录导入结果汇总,供 @LogRecord 的 success 文案引用
        OperateLogUtils.putImportSummary(respVO.getCreateCodes(), respVO.getUpdateCodes(), respVO.getFailureCodes());
        return respVO;
    }