From 7bfa3796ce60a29c4fe2244a7b7a553149773483 Mon Sep 17 00:00:00 2001
From: dengjunjie <dengjunjie@hnkhzn.com>
Date: 星期日, 26 十月 2025 12:13:40 +0800
Subject: [PATCH] 优化PDA功能

---
 新建文件夹/WIDESEA_WMSServer/WIDESEA_SquareCabinServices/Business.cs |   58 ++++++++++++++++++++++++++++++++--------------------------
 1 files changed, 32 insertions(+), 26 deletions(-)

diff --git "a/\346\226\260\345\273\272\346\226\207\344\273\266\345\244\271/WIDESEA_WMSServer/WIDESEA_SquareCabinServices/Business.cs" "b/\346\226\260\345\273\272\346\226\207\344\273\266\345\244\271/WIDESEA_WMSServer/WIDESEA_SquareCabinServices/Business.cs"
index f475cd1..b534138 100644
--- "a/\346\226\260\345\273\272\346\226\207\344\273\266\345\244\271/WIDESEA_WMSServer/WIDESEA_SquareCabinServices/Business.cs"
+++ "b/\346\226\260\345\273\272\346\226\207\344\273\266\345\244\271/WIDESEA_WMSServer/WIDESEA_SquareCabinServices/Business.cs"
@@ -97,20 +97,21 @@
                     return responseContent.OK("鎵�鏈夊叆搴撳崟宸插瓨鍦紝鏃犻渶鏂板");
                 }
 
-                _unitOfWorkManage.BeginTran();
-                try
-                {
-                    List<Dt_CabinOrder> _CabinOrders = new List<Dt_CabinOrder>();
-                    //瀛樺偍鍏ュ簱鍗曞彿
-                    List<string> orderNos = new List<string>();
+                //瀛樺偍鍏ュ簱鍗曞彿
+                List<string> orderNos = new List<string>();
 
-                    foreach (var order in newOrders)
+                foreach (var order in newOrders)
+                {
+                    try
                     {
+                        _unitOfWorkManage.BeginTran();
                         if (order.order_type == "1") //姝e父鍏ュ簱
                         {
                             responseContent = _cabinOrderServices.CreateInboundOrder(order);
+                            if (!responseContent.Status) throw new Exception(responseContent.Message);
                             List<Dt_CabinOrder>? dt_CabinOrders = responseContent.Data as List<Dt_CabinOrder>;
-                            if (dt_CabinOrders != null) _CabinOrders.AddRange(dt_CabinOrders);
+                            if (dt_CabinOrders != null)
+                                _cabinOrderServices.Db.InsertNav(dt_CabinOrders).Include(x => x.Details).ExecuteCommand();
                         }
                         else if (order.order_type == "3")//鍏ュ簱閫�鏂�
                         {
@@ -134,28 +135,30 @@
                                 };
                                 upstramOutOrderInfo.details.Add(detail);
                             }
-                            _deliveryOrderServices.CreateOutboundOrder(upstramOutOrderInfo);
+                            var content = _deliveryOrderServices.CreateOutboundOrder(upstramOutOrderInfo);
+                            if (!content.Status) throw new Exception(content.Message);
                             #endregion
                         }
                         else if (order.order_type == "5")//鎶ユ孩鍏ュ簱
                         {
-                            _cabinOrderServices.CreateCheckInOrder(order);
+                            var content = _cabinOrderServices.CreateCheckInOrder(order);
+                            if (!content.Status) throw new Exception(content.Message);
                         }
-                    };
-                    _cabinOrderServices.Db.InsertNav(_CabinOrders).Include(x => x.Details).ExecuteCommand();
+                        _unitOfWorkManage.CommitTran();
+                    }
+                    catch (Exception ex)
+                    {
+                        _unitOfWorkManage.RollbackTran();
+                        SendErrorToUpstream(1, "", ex.Message, "");
+                        return responseContent.Error("鍚屾澶辫触: " + ex.Message);
+                    }
+                };
 
-                    //鍦ㄤ笅鍙戠粰wcs 
-                    //EdiIn(); //鍙戠粰涓嬫父
-                    //濡傛灉杩欎釜鏂规硶鎴愬姛浜嗭紝閭d箞灏辫皟鐢–ompleteOrder鎺ュ彛锛岀劧鍚庢敼鍙�
-                    _unitOfWorkManage.CommitTran();
-                    return responseContent.OK("鍚屾鍏ュ簱鍗曟垚鍔�");
-                }
-                catch (Exception ex)
-                {
-                    _unitOfWorkManage.RollbackTran();
-                    SendErrorToUpstream(1, "", ex.Message, "");
-                    return responseContent.Error("鍚屾澶辫触: " + ex.Message);
-                }
+                //鍦ㄤ笅鍙戠粰wcs 
+                //EdiIn(); //鍙戠粰涓嬫父
+                //濡傛灉杩欎釜鏂规硶鎴愬姛浜嗭紝閭d箞灏辫皟鐢–ompleteOrder鎺ュ彛锛岀劧鍚庢敼鍙�
+                return responseContent.OK("鍚屾鍏ュ簱鍗曟垚鍔�");
+
             }
             catch (Exception ex)
             {
@@ -225,7 +228,8 @@
                     {
                         if (outorder.order_type == "1") // 姝e父鍑哄簱鍗�
                         {
-                            _deliveryOrderServices.CreateOutboundOrder(outorder);//鍒涘缓鍑哄簱鍗曘�佸鐞嗗簱瀛樸�佹坊鍔犲嚭搴撲换鍔�
+                            var content = _deliveryOrderServices.CreateOutboundOrder(outorder);
+                            if (!content.Status) throw new Exception(content.Message);
                         }
                         else if (outorder.order_type == "2")//鍑哄簱閫�璐�
                         {
@@ -252,6 +256,7 @@
                                 order.details.Add(detail);
                             }
                             responseContent = _cabinOrderServices.CreateInboundOrder(order);
+                            if (!responseContent.Status) throw new Exception(responseContent.Message);
                             List<Dt_CabinOrder>? dt_CabinOrders = responseContent.Data as List<Dt_CabinOrder>;
                             if (dt_CabinOrders != null && dt_CabinOrders.Count > 0)
                                 _cabinOrderServices.Db.InsertNav(dt_CabinOrders).Include(x => x.Details).ExecuteCommand();
@@ -259,7 +264,8 @@
                         }
                         else if (outorder.order_type == "6")//鎶ユ崯鍑哄簱
                         {
-                            _deliveryOrderServices.CreateCheckOutOrder(outorder);
+                            var content = _deliveryOrderServices.CreateCheckOutOrder(outorder);
+                            if (!content.Status) throw new Exception(content.Message);
                         }
                     }
 

--
Gitblit v1.9.3