From 208ba32323f73ade277e230b78fde2db04f860ac Mon Sep 17 00:00:00 2001
From: dengjunjie <dengjunjie@hnkhzn.com>
Date: 星期日, 02 十一月 2025 17:25:54 +0800
Subject: [PATCH] 优化处理出库单逻辑

---
 新建文件夹/WIDESEA_WMSServer/WIDESEA_SquareCabinServices/NewBusiness.cs |   56 +++++++++++++++++++++++++++++++++++++++++---------------
 1 files changed, 41 insertions(+), 15 deletions(-)

diff --git "a/\346\226\260\345\273\272\346\226\207\344\273\266\345\244\271/WIDESEA_WMSServer/WIDESEA_SquareCabinServices/NewBusiness.cs" "b/\346\226\260\345\273\272\346\226\207\344\273\266\345\244\271/WIDESEA_WMSServer/WIDESEA_SquareCabinServices/NewBusiness.cs"
index 508891d..907c025 100644
--- "a/\346\226\260\345\273\272\346\226\207\344\273\266\345\244\271/WIDESEA_WMSServer/WIDESEA_SquareCabinServices/NewBusiness.cs"
+++ "b/\346\226\260\345\273\272\346\226\207\344\273\266\345\244\271/WIDESEA_WMSServer/WIDESEA_SquareCabinServices/NewBusiness.cs"
@@ -16,31 +16,42 @@
     public partial class Business
     {
         #region 鑾峰彇ERP鍏ュ簱鍗�
-        static string SearchInOrderDate = "2025-10-30 00:00:00";
+        static string SearchInOrderDate = "2025-11-01 00:00:00";
         public WebResponseContent GetInOrder()
         {
             WebResponseContent content = new WebResponseContent();
             try
             {
                 var url = "http://121.37.118.63:80/GYZ2/95fck/inOrder";
+                string GetOutOrderDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                 if (string.IsNullOrEmpty(SearchInOrderDate)) SearchInOrderDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                 var requestData = new { searchDate = SearchInOrderDate };
-                SearchInOrderDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
+                //SearchInOrderDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                 var result = HttpHelper.Post(url, requestData.ToJsonString());
                 var response = JsonConvert.DeserializeObject<UpstreamResponse<UpstreamOrderInfo>>(result);
                 if (response == null || response.resultCode != "0") return content;
-                if (response.data.Count < 1) return content;
+                if (response.data.Count < 1)
+                {
+                    SearchInOrderDate = GetOutOrderDate;
+                    return content;
+                }
                 var ordernos = response.data.Select(x => x.order_no).ToList();
                 var existingOrderNos = _cabinOrderServices.Repository.QueryData(x => ordernos.Contains(x.Order_no)).Select(x => x.Order_no).Distinct().ToList();
                 var newOrders = response.data.Where(order => !existingOrderNos.Contains(order.order_no)).ToList();
-                if (newOrders.Count < 1) return content;
+                if (newOrders.Count < 1)
+                {
+                    SearchInOrderDate = GetOutOrderDate;
+                    return content;
+                }
+                int messQty = 0;
                 foreach (var order in newOrders)
                 {
                     try
                     {
                         if (order.order_type == "1")
                         {
-                            _cabinOrderServices.CreateInboundOrder(order);
+                            content = _cabinOrderServices.CreateInboundOrder(order);
+                            if (!content.Status) messQty++;
                         }
                         else if (order.order_type == "3")//鍏ュ簱閫�鏂�
                         {
@@ -63,12 +74,14 @@
                                 };
                                 upstramOutOrderInfo.details.Add(detail);
                             }
-                            _deliveryOrderServices.CreateOutboundOrder(upstramOutOrderInfo);
                             #endregion
+                            content = _deliveryOrderServices.CreateOutboundOrder(upstramOutOrderInfo);
+                            if (!content.Status) messQty++;
                         }
                         else if (order.order_type == "5")//鎶ユ孩鍏ュ簱
                         {
-                            _cabinOrderServices.CreateCheckInOrder(order);
+                            content = _cabinOrderServices.CreateCheckInOrder(order);
+                            if (!content.Status) messQty++;
                         }
                     }
                     catch (Exception ex)
@@ -76,6 +89,7 @@
                         continue;
                     }
                 }
+                if (messQty == 0) SearchInOrderDate = GetOutOrderDate;
                 return content.OK();
             }
             catch (Exception ex)
@@ -87,31 +101,40 @@
         #endregion
 
         #region 鑾峰彇ERP鍑哄簱鍗�
-        static string SearchOutOrderDate = "2025-10-30 00:00:00";
+        static string SearchOutOrderDate = "2025-11-01 00:00:00";
         public WebResponseContent GetOutOrder()
         {
             WebResponseContent content = new WebResponseContent();
             try
             {
                 var url = "http://121.37.118.63:80/GYZ2/95fck/outOrder";
+                string GetOutOrderDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                 if (string.IsNullOrEmpty(SearchOutOrderDate)) SearchOutOrderDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                 var requestData = new { searchDate = SearchOutOrderDate };
-                SearchOutOrderDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                 var result = HttpHelper.Post(url, requestData.ToJsonString());
                 var response = JsonConvert.DeserializeObject<UpstreamResponse<UpstramOutOrderInfo>>(result);
 
                 if (response == null || response.resultCode != "0") return content;
-                if (response.data.Count < 1) return content;
+                if (response.data.Count < 1)
+                {
+                    SearchOutOrderDate = GetOutOrderDate;
+                    return content;
+                }
                 var ordernos = response.data.Select(x => x.order_no).ToList();
                 var existingOutOrderNos = _deliveryOrderServices.Repository.QueryData(x => ordernos.Contains(x.Out_no)).Select(x => x.Out_no).Distinct().ToList();
                 var newOutOrders = response.data.Where(outorder => !existingOutOrderNos.Contains(outorder.order_no)).ToList();
-                if (newOutOrders.Count < 1) return content;
-
+                if (newOutOrders.Count < 1)
+                {
+                    SearchOutOrderDate = GetOutOrderDate;
+                    return content;
+                }
+                int messQty = 0;
                 foreach (var outorder in newOutOrders)
                 {
                     if (outorder.order_type == "1")// 姝e父鍑哄簱鍗�
                     {
-                        _deliveryOrderServices.CreateOutboundOrder(outorder);
+                        content = _deliveryOrderServices.CreateOutboundOrder(outorder);
+                        if (!content.Status) messQty++;
                     }
                     else if (outorder.order_type == "2")//鍑哄簱閫�璐�
                     {
@@ -135,13 +158,16 @@
                             order.details.Add(detail);
                         }
                         #endregion
-                        _cabinOrderServices.CreateInboundOrder(order);
+                        content = _cabinOrderServices.CreateInboundOrder(order);
+                        if (!content.Status) messQty++;
                     }
                     else if (outorder.order_type == "6")//鎶ユ崯鍑哄簱
                     {
-                        _deliveryOrderServices.CreateCheckOutOrder(outorder);
+                        content = _deliveryOrderServices.CreateCheckOutOrder(outorder);
+                        if (!content.Status) messQty++;
                     }
                 }
+                if (messQty == 0) SearchOutOrderDate = GetOutOrderDate;
             }
             catch (Exception ex)
             {

--
Gitblit v1.9.3