From 7a923e32e55e9c34830690341469cc170f65092e Mon Sep 17 00:00:00 2001
From: gaoluyang <2820782392@qq.com>
Date: 星期一, 16 十一月 2026 09:32:35 +0800
Subject: [PATCH] feat: 完善销售和投标业务流程

---
 yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/pro/process/MesProProcessServiceImpl.java |   77 ++++++++++++++++++++++++++++++++++++++
 1 files changed, 76 insertions(+), 1 deletions(-)

diff --git a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/pro/process/MesProProcessServiceImpl.java b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/pro/process/MesProProcessServiceImpl.java
index 27023cb..2b1c487 100644
--- a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/pro/process/MesProProcessServiceImpl.java
+++ b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/pro/process/MesProProcessServiceImpl.java
@@ -7,8 +7,11 @@
 import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
 import cn.iocoder.yudao.module.mes.controller.admin.pro.process.vo.MesProProcessPageReqVO;
 import cn.iocoder.yudao.module.mes.controller.admin.pro.process.vo.MesProProcessSaveReqVO;
+import cn.iocoder.yudao.module.mes.controller.admin.pro.process.vo.MesProProcessImportExcelVO;
+import cn.iocoder.yudao.module.mes.controller.admin.pro.process.vo.MesProProcessImportRespVO;
 import cn.iocoder.yudao.module.mes.dal.dataobject.pro.process.MesProProcessDO;
 import cn.iocoder.yudao.module.mes.dal.mysql.pro.process.MesProProcessMapper;
+import cn.iocoder.yudao.module.mes.enums.pro.MesProProcessBillingTypeEnum;
 import cn.iocoder.yudao.module.mes.service.pro.route.MesProRouteProcessService;
 import jakarta.annotation.Resource;
 import org.springframework.context.annotation.Lazy;
@@ -19,6 +22,11 @@
 import java.util.Collection;
 import java.util.Collections;
 import java.util.List;
+import java.util.ArrayList;
+import java.util.LinkedHashMap;
+import java.util.HashSet;
+import java.util.Set;
+import java.util.Map;
 
 import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
 import static cn.iocoder.yudao.module.mes.enums.ErrorCodeConstants.*;
@@ -26,7 +34,7 @@
 /**
  * MES 鐢熶骇宸ュ簭 Service 瀹炵幇绫�
  *
- * @author 鑺嬮亾婧愮爜
+ * @author 瓒呯骇绠$悊鍛�
  */
 @Service
 @Validated
@@ -129,6 +137,14 @@
         validateProcessCodeUnique(saveReqVO.getId(), saveReqVO.getCode());
         // 2. 鏍¢獙鍚嶇О鍞竴
         validateProcessNameUnique(saveReqVO.getId(), saveReqVO.getName());
+        // 3. 鏍¢獙璁¤垂绫诲瀷鍚堟硶锛�1-璁℃椂 2-璁′欢锛夛紝鍚﹀垯鎶ュ伐鏃犳硶纭畾宸ヨ祫绠楁硶
+        if (MesProProcessBillingTypeEnum.valueOfType(saveReqVO.getBillingType()) == null) {
+            throw exception(PRO_PROCESS_BILLING_TYPE_INVALID, saveReqVO.getName(), saveReqVO.getBillingType());
+        }
+        // 4. 鏍¢獙宸ヨ祫瀹氶闈炶礋锛堝厑璁� 0锛岃〃绀烘殏鏈畾浠凤紝姝ゆ椂鎶ュ伐宸ヨ祫涓� 0锛屾牳绠楁椂鍙寜浜鸿皟鏁达級
+        if (saveReqVO.getWageRate() != null && saveReqVO.getWageRate().signum() < 0) {
+            throw exception(PRO_PROCESS_WAGE_RATE_INVALID, saveReqVO.getName(), saveReqVO.getWageRate());
+        }
     }
 
     @Override
@@ -150,6 +166,65 @@
     }
 
     @Override
+    public MesProProcessImportRespVO importProcessList(List<MesProProcessImportExcelVO> rows, boolean updateSupport) {
+        if (CollUtil.isEmpty(rows)) {
+            throw new cn.iocoder.yudao.framework.common.exception.ServiceException(400, "瀵煎叆鏂囦欢娌℃湁宸ュ簭鏁版嵁");
+        }
+        MesProProcessImportRespVO result = MesProProcessImportRespVO.builder()
+                .createCodes(new ArrayList<>()).updateCodes(new ArrayList<>())
+                .failureCodes(new LinkedHashMap<>()).build();
+        Set<String> seenCodes = new HashSet<>();
+        for (int index = 0; index < rows.size(); index++) {
+            MesProProcessImportExcelVO row = rows.get(index);
+            String code = row.getCode() == null ? "" : row.getCode().trim();
+            String key = code.isEmpty() ? "绗� " + (index + 2) + " 琛�" : code;
+            try {
+                if (code.isEmpty() || row.getName() == null || row.getName().isBlank()) {
+                    throw new IllegalArgumentException("宸ュ簭缂栫爜鍜屽悕绉颁笉鑳戒负绌�");
+                }
+                if (!seenCodes.add(code)) throw new IllegalArgumentException("鏂囦欢鍐呭伐搴忕紪鐮侀噸澶�");
+                if (row.getBillingType() == null || row.getWageRate() == null) {
+                    throw new IllegalArgumentException("璁¤垂绫诲瀷鍜屽伐璧勫畾棰濅笉鑳戒负绌�");
+                }
+                if (row.getStatus() != null && row.getStatus() != 0 && row.getStatus() != 1) {
+                    throw new IllegalArgumentException("鐘舵�佸彧鑳藉~鍐� 0 鎴� 1");
+                }
+                MesProProcessSaveReqVO save = BeanUtils.toBean(row, MesProProcessSaveReqVO.class);
+                save.setStdTimeMode(parseStdTimeMode(row.getStdTimeModeName()));
+                save.setCode(code);
+                save.setName(row.getName().trim());
+                save.setStatus(row.getStatus() == null ? 0 : row.getStatus());
+                MesProProcessDO existing = processMapper.selectByCode(code);
+                if (existing == null) {
+                    createProcess(save);
+                    result.getCreateCodes().add(code);
+                } else if (updateSupport) {
+                    save.setId(existing.getId());
+                    updateProcess(save);
+                    result.getUpdateCodes().add(code);
+                } else {
+                    throw new IllegalArgumentException("宸ュ簭缂栫爜宸插瓨鍦紝鍕鹃�夎鐩栧悗鍙洿鏂�");
+                }
+            } catch (RuntimeException ex) {
+                result.getFailureCodes().put(key, ex.getMessage());
+            }
+        }
+        return result;
+    }
+
+    private Integer parseStdTimeMode(String value) {
+        if (value == null || value.isBlank()) return null;
+        String normalized = value.trim().replace(" ", "").replace("锛�", "脳").replace("*", "脳");
+        return switch (normalized) {
+            case "0", "鏈惎鐢�" -> 0;
+            case "1", "杞�熋楄妭璺�" -> 1;
+            case "2", "绾块�熷害鐩村彇" -> 2;
+            case "3", "婊¢�熺櫨鍒嗘瘮脳鑺傝窛" -> 3;
+            default -> throw new IllegalArgumentException("鏍囧噯宸ユ椂璁$畻鏂瑰紡璇峰~鍐欙細鏈惎鐢ㄣ�佽浆閫熋楄妭璺濄�佺嚎閫熷害鐩村彇銆佹弧閫熺櫨鍒嗘瘮脳鑺傝窛");
+        };
+    }
+
+    @Override
     public List<MesProProcessDO> getProcessListByStatus(Integer status) {
         return processMapper.selectListByStatus(status);
     }

--
Gitblit v1.9.3