From f0e887dd32942c7897567261b9de1d26f576dfb6 Mon Sep 17 00:00:00 2001
From: skyouc
Date: 星期三, 23 四月 2025 11:11:56 +0800
Subject: [PATCH] 通过单据创建DO单优化

---
 rsf-server/src/main/java/com/vincent/rsf/server/manager/controller/OutStockController.java |   16 +++++++++++-----
 1 files changed, 11 insertions(+), 5 deletions(-)

diff --git a/rsf-server/src/main/java/com/vincent/rsf/server/manager/controller/OutStockController.java b/rsf-server/src/main/java/com/vincent/rsf/server/manager/controller/OutStockController.java
index 152d98d..b442995 100644
--- a/rsf-server/src/main/java/com/vincent/rsf/server/manager/controller/OutStockController.java
+++ b/rsf-server/src/main/java/com/vincent/rsf/server/manager/controller/OutStockController.java
@@ -17,8 +17,6 @@
 import com.vincent.rsf.server.manager.entity.AsnOrderItem;
 import com.vincent.rsf.server.manager.entity.excel.AsnOrderTemplate;
 import com.vincent.rsf.server.manager.enums.AsnExceStatus;
-import com.vincent.rsf.server.manager.service.AsnOrderItemService;
-import com.vincent.rsf.server.manager.service.AsnOrderService;
 import com.vincent.rsf.server.manager.service.OutStockItemService;
 import com.vincent.rsf.server.manager.service.OutStockService;
 import com.vincent.rsf.server.system.constant.SerialRuleCode;
@@ -26,6 +24,7 @@
 import com.vincent.rsf.server.system.utils.SerialRuleUtils;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
+import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.web.bind.annotation.*;
@@ -76,9 +75,12 @@
     public R save(@RequestBody AsnOrder asnOrder) {
         asnOrder.setCreateBy(getLoginUserId())
                 .setUpdateBy(getLoginUserId());
-        if (!Objects.isNull(asnOrder.getCode())) {
-            String code = SerialRuleUtils.generateRuleCode(SerialRuleCode.SYS_OUT_STOCK_CODE, asnOrder);
-            asnOrder.setCode(code);
+        if (Objects.isNull(asnOrder.getCode())) {
+            String ruleCode = SerialRuleUtils.generateRuleCode(SerialRuleCode.SYS_OUT_STOCK_CODE, asnOrder);
+            if (Objects.isNull(ruleCode) || StringUtils.isBlank(ruleCode)) {
+                return R.error("缂栫爜瑙勫垯閿欒锛氱紪鐮併�孲YS_OUT_STOCK_CODE銆嶆槸鏈缃垚鍔燂紒锛�");
+            }
+            asnOrder.setCode(ruleCode);
         }
         if (!outStockService.save(asnOrder)) {
             return R.error("Save Fail");
@@ -94,6 +96,10 @@
         asnOrder.setType(OrderType.ORDER_OUT.type)
                 .setUpdateBy(getLoginUserId())
                 .setUpdateTime(new Date());
+        if (Objects.isNull(asnOrder.getCode())) {
+            String ruleCode = SerialRuleUtils.generateRuleCode(SerialRuleCode.SYS_OUT_STOCK_CODE, asnOrder);
+            asnOrder.setCode(ruleCode);
+        }
         if (!outStockService.updateById(asnOrder)) {
             return R.error("Update Fail");
         }

--
Gitblit v1.9.1