From d54fbc9d4f8981fa0f7f613b33a28a8cd4f764ea Mon Sep 17 00:00:00 2001
From: 云 <2163098428@qq.com>
Date: 星期日, 25 十月 2026 16:29:53 +0800
Subject: [PATCH] feat(system): 优化用户搜索功能并完善ERP和MES模块验证逻辑

---
 yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/pd/reel/ProductCtcReelServiceImpl.java |   55 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 55 insertions(+), 0 deletions(-)

diff --git a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/pd/reel/ProductCtcReelServiceImpl.java b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/pd/reel/ProductCtcReelServiceImpl.java
index 25dee43..a5d18b9 100644
--- a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/pd/reel/ProductCtcReelServiceImpl.java
+++ b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/pd/reel/ProductCtcReelServiceImpl.java
@@ -1,7 +1,12 @@
 package cn.iocoder.yudao.module.mes.service.pd.reel;
 
+import cn.hutool.core.collection.CollUtil;
+import cn.hutool.core.util.StrUtil;
+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.module.mes.controller.admin.pd.reel.vo.ProductCtcReelImportExcelVO;
+import cn.iocoder.yudao.module.mes.controller.admin.pd.reel.vo.ProductCtcReelImportRespVO;
 import cn.iocoder.yudao.module.mes.controller.admin.pd.reel.vo.ProductCtcReelPageReqVO;
 import cn.iocoder.yudao.module.mes.controller.admin.pd.reel.vo.ProductCtcReelSaveReqVO;
 import cn.iocoder.yudao.module.mes.dal.dataobject.pd.ctc.ProductCtcDO;
@@ -11,12 +16,17 @@
 import jakarta.annotation.Resource;
 import org.springframework.context.annotation.Lazy;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
 import org.springframework.validation.annotation.Validated;
 
+import java.util.ArrayList;
+import java.util.LinkedHashMap;
 import java.util.List;
+import java.util.concurrent.atomic.AtomicInteger;
 
 import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
 import static cn.iocoder.yudao.module.mes.enums.ErrorCodeConstants.PD_CTC_NOT_EXISTS;
+import static cn.iocoder.yudao.module.mes.enums.ErrorCodeConstants.PD_CTC_REEL_IMPORT_LIST_IS_EMPTY;
 import static cn.iocoder.yudao.module.mes.enums.ErrorCodeConstants.PD_CTC_REEL_NOT_EXISTS;
 
 /**
@@ -84,6 +94,51 @@
         reelMapper.deleteByCtcId(ctcId);
     }
 
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public ProductCtcReelImportRespVO importReelList(List<ProductCtcReelImportExcelVO> importList, boolean updateSupport) {
+        if (CollUtil.isEmpty(importList)) {
+            throw exception(PD_CTC_REEL_IMPORT_LIST_IS_EMPTY);
+        }
+        ProductCtcReelImportRespVO respVO = ProductCtcReelImportRespVO.builder()
+                .createCodes(new ArrayList<>()).updateCodes(new ArrayList<>())
+                .failureCodes(new LinkedHashMap<>()).build();
+        AtomicInteger index = new AtomicInteger(1);
+        importList.forEach(importItem -> {
+            int currentIndex = index.getAndIncrement();
+            String key = StrUtil.blankToDefault(importItem.getCtcOrderSpec(), "绗� " + currentIndex + " 琛�");
+            if (StrUtil.isBlank(importItem.getCtcOrderSpec())) {
+                respVO.getFailureCodes().put(key, "璁㈣揣瑙勬牸涓嶈兘涓虹┖");
+                return;
+            }
+            ProductCtcDO ctc = ctcService.getCtcByOrderSpec(importItem.getCtcOrderSpec().trim());
+            if (ctc == null) {
+                respVO.getFailureCodes().put(key, "璁㈣揣瑙勬牸[" + importItem.getCtcOrderSpec() + "]涓嶅瓨鍦�");
+                return;
+            }
+            ProductCtcReelSaveReqVO reqVO = BeanUtils.toBean(importItem, ProductCtcReelSaveReqVO.class);
+            reqVO.setCtcId(ctc.getId());
+            String resultKey = importItem.getCtcOrderSpec() + "/" + StrUtil.blankToDefault(importItem.getReelType(), "鏃犵被鍨�");
+            ProductCtcReelDO existReel = reelMapper.selectByCtcIdAndReelType(ctc.getId(), importItem.getReelType());
+            try {
+                if (existReel == null) {
+                    reqVO.setId(null);
+                    createReel(reqVO);
+                    respVO.getCreateCodes().add(resultKey);
+                } else if (updateSupport) {
+                    reqVO.setId(existReel.getId());
+                    updateReel(reqVO);
+                    respVO.getUpdateCodes().add(resultKey);
+                } else {
+                    respVO.getFailureCodes().put(key, "璁㈣揣瑙勬牸+鐩樺叿绫诲瀷宸插瓨鍦�");
+                }
+            } catch (ServiceException e) {
+                respVO.getFailureCodes().put(key, e.getMessage());
+            }
+        });
+        return respVO;
+    }
+
     private void validateCtcExists(Long ctcId) {
         ProductCtcDO ctc = ctcService.getCtc(ctcId);
         if (ctc == null) {

--
Gitblit v1.9.3