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 |   83 +++++++++++++++++++++++++----------------
 1 files changed, 50 insertions(+), 33 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 355747b..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")//鎶ユ孩鍏ュ簱
                         {
-
+                            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)
             {
@@ -173,8 +176,8 @@
             var responseContent = new WebResponseContent();
             try
             {
-                var url = "http://121.37.118.63:80/GYZ2/95fck/outOrder";
-                //var url = "http://127.0.0.1:4523/m1/5660322-5340849-default/GYZ2/95fck/outOrder";
+                //var url = "http://121.37.118.63:80/GYZ2/95fck/outOrder";
+                var url = "http://127.0.0.1:4523/m1/5660322-5340849-default/GYZ2/95fck/outOrder";
                 if (string.IsNullOrEmpty(SearchOutDate)) SearchOutDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                 //// 璇锋眰鍙傛暟
                 var requestData = new
@@ -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")//鎶ユ崯鍑哄簱
                         {
-
+                            var content = _deliveryOrderServices.CreateCheckOutOrder(outorder);
+                            if (!content.Status) throw new Exception(content.Message);
                         }
                     }
 
@@ -344,7 +350,7 @@
                         //鍏ュ簱鍗曞彿
                         externalOrderNo = order.Order_no,
                         //鍏ュ簱鍗曠被鍨�
-                        inOrderType = order.Order_type == "1" ? "10" : "20",
+                        inOrderType = order.Order_type == "5" ? "20" : "10",
                         //浼樺厛绾�
                         priority = 0,
                         //鏄惁鍙栨秷
@@ -413,11 +419,12 @@
         public WebResponseContent EdiOut()
         {
             var responseContent = new WebResponseContent();
+            var WarehouseLk = WarehouseEnum.绔嬪簱.ObjToInt().ToString("000");
             try
             {
                 // 1. 鏌ヨ绗﹀悎鏉′欢鐨勮鍗曪紙琛ㄥご=鏂板缓 && 鍖呭惈鏈夋晥鏄庣粏锛�
                 var outOrders = _deliveryOrderServices.Db.CopyNew().Queryable<Dt_DeliveryOrder>()
-                    .Where(o => o.OutStatus == "鏂板缓" && o.Warehouse_no == WarehouseEnum.绔嬪簱.ObjToInt().ToString("000"))
+                    .Where(o => o.OutStatus == "鏂板缓" && o.Warehouse_no == WarehouseLk)
                     .Includes(o => o.Details, d => d.MedicineGoods)
                     .ToList();
 
@@ -445,13 +452,23 @@
                             //濡傛灉鏉′欢婊¤冻锛屽皢鐗╂枡浠g爜璁剧疆涓虹涓�涓槑缁嗛」瀵瑰簲鐨勮嵂鍝佺墿鏂欎唬鐮�
                             materialCode = firstDetail.MedicineGoods.MaterielErpType;
                         }
+                        switch (order.Out_type)
+                        {
+                            case "1"://姝e父鍑哄簱
+                            case "3"://鍏ュ簱閫�璐�
+                                order.Out_type = "10";//涓�鑸氦鏄撳嚭搴撳崟
+                                break;
+                            case "6"://鐩樹簭鍑哄簱
+                                order.Out_type = "30";//鐩樹簭鍑哄簱鍗�
+                                break;
+                        }
                         // 3. 缁勮 DTO
                         var ediDto = new TowcsDto.ToediOutInfo
                         {
                             customerCode = "905",
                             materialCode = materialCode,
                             externalOrderNo = order.Out_no,
-                            outOrderType = order.Out_type == "1" ? "10" : order.Out_type == "3" ? "20" : "30",//鍑哄簱鍗曠被鍨嬫槸1灏辨槸姝e父鐨勶紝3灏辨槸鐩樼偣
+                            outOrderType = order.Out_type,//20鏄洏鐐瑰嚭搴撳崟
                             priority = 1,
                             Is_cancel = 0,
                             details = order.Details.Select(d => new TowcsDto.ToeOutdiInDetail
@@ -471,8 +488,8 @@
                         };
 
                         // 4. 璋冪敤鎺ュ彛
-                        var url = "http://172.16.1.2:9357/file-admin/api/out/ediOut";
-                        //var url = "http://127.0.0.1:4523/m2/5660322-5340849-default/363076920";
+                        //var url = "http://172.16.1.2:9357/file-admin/api/out/ediOut";
+                        var url = "http://127.0.0.1:4523/m2/5660322-5340849-default/363076920";
 
                         var result = HttpHelper.Post(url, ediDto.ToJsonString());
                         var resp = JsonConvert.DeserializeObject<TowcsDto.TowcsResponse<object>>(result);

--
Gitblit v1.9.3