From 24e1afea871c5f24d6018f560389359e143031cd Mon Sep 17 00:00:00 2001
From: dengjunjie <dengjunjie@hnkhzn.com>
Date: 星期一, 27 十月 2025 10:45:16 +0800
Subject: [PATCH] 添加出入库单人工完成功能

---
 新建文件夹/WIDESEA_WMSServer/WIDESEA_SquareCabinServices/CabinOrderServices.cs |   56 +++++++++++++++++++++++++++++++++++++++++++++++++++-----
 1 files changed, 51 insertions(+), 5 deletions(-)

diff --git "a/\346\226\260\345\273\272\346\226\207\344\273\266\345\244\271/WIDESEA_WMSServer/WIDESEA_SquareCabinServices/CabinOrderServices.cs" "b/\346\226\260\345\273\272\346\226\207\344\273\266\345\244\271/WIDESEA_WMSServer/WIDESEA_SquareCabinServices/CabinOrderServices.cs"
index c274e66..d744bac 100644
--- "a/\346\226\260\345\273\272\346\226\207\344\273\266\345\244\271/WIDESEA_WMSServer/WIDESEA_SquareCabinServices/CabinOrderServices.cs"
+++ "b/\346\226\260\345\273\272\346\226\207\344\273\266\345\244\271/WIDESEA_WMSServer/WIDESEA_SquareCabinServices/CabinOrderServices.cs"
@@ -43,9 +43,10 @@
         private readonly ICabinOrderDetailServices _cabinOrderDetailServices;
         private readonly ISupplyTaskService _supplyTaskService;
         private readonly ISupplyTaskHtyService _supplyTaskHtyService;
+        private readonly IMessageInfoService _messageInfoService;
         public IRepository<Dt_CabinOrder> Repository => BaseDal;
 
-        public CabinOrderServices(IRepository<Dt_CabinOrder> BaseDal, IBasicService basicService, IMedicineGoodsServices medicineGoodsServices, IUnitOfWorkManage unitOfWorkManage, IInventory_BatchServices inventory_BatchServices, IInventoryInfoService inventoryInfoService, ICabinOrderDetailServices cabinOrderDetailServices, ICabinOrderHtyServices cabinOrderHtyServices, ICabinOrderDetailHtyServices cabinOrderDetailHtyServices, ISupplyTaskService supplyTaskService, ISupplyTaskHtyService supplyTaskHtyService) : base(BaseDal)
+        public CabinOrderServices(IRepository<Dt_CabinOrder> BaseDal, IBasicService basicService, IMedicineGoodsServices medicineGoodsServices, IUnitOfWorkManage unitOfWorkManage, IInventory_BatchServices inventory_BatchServices, IInventoryInfoService inventoryInfoService, ICabinOrderDetailServices cabinOrderDetailServices, ICabinOrderHtyServices cabinOrderHtyServices, ICabinOrderDetailHtyServices cabinOrderDetailHtyServices, ISupplyTaskService supplyTaskService, ISupplyTaskHtyService supplyTaskHtyService, IMessageInfoService messageInfoService) : base(BaseDal)
         {
             _basicService = basicService;
             _medicineGoodsServices = medicineGoodsServices;
@@ -55,6 +56,7 @@
             _cabinOrderDetailServices = cabinOrderDetailServices;
             _supplyTaskService = supplyTaskService;
             _supplyTaskHtyService = supplyTaskHtyService;
+            _messageInfoService = messageInfoService;
         }
 
 
@@ -540,7 +542,8 @@
                             Status = 2,
                         }).ToList()
                     };
-                    Repository.AddData(entityOrder);
+                    Db.InsertNav(entityOrder).Include(it => it.Details).ExecuteCommand();
+                    //Repository.AddData(entityOrder);
                     #endregion
                 }
                 #endregion
@@ -626,7 +629,9 @@
                                     Status = 2,
                                 }).ToList()
                             };
-                            Repository.AddData(entityOrder);
+                            //Repository.AddData(entityOrder);
+                            Db.InsertNav(entityOrder).Include(it => it.Details).ExecuteCommand();
+
                             #endregion
                         }
                         else
@@ -691,7 +696,9 @@
                                         Status = 2,
                                     }).ToList()
                                 };
-                                Repository.AddData(cabinOrder);
+                                //Repository.AddData(cabinOrder);
+                                Db.InsertNav(cabinOrder).Include(it => it.Details).ExecuteCommand();
+
                             }
                             #endregion
 
@@ -716,7 +723,8 @@
                                     Status = 0,
                                 }).ToList()
                             };
-                            Repository.AddData(entityOrder);
+                            //Repository.AddData(entityOrder);
+                            Db.InsertNav(entityOrder).Include(it => it.Details).ExecuteCommand();
                             #endregion
                         }
                     }
@@ -724,10 +732,48 @@
             }
             catch (Exception ex)
             {
+                //_messageInfoService.AddMessageInfo(MessageGroupByEnum.InOrderAlarm, "鍒涘缓鐩樼泩鍏ュ簱鍗�", ex.Message);
                 content.Error(ex.Message);
             }
             return content;
         }
         #endregion
+
+        public WebResponseContent FinishInOrder(int key)
+        {
+            WebResponseContent content = new WebResponseContent();
+            try
+            {
+                Dt_CabinOrder cabinOrder = BaseDal.QueryFirst(x => x.Id == key);
+                List<Dt_CabinOrder> cabinOrders = Db.Queryable<Dt_CabinOrder>().Where(x => x.Order_no == cabinOrder.Order_no).Includes(x => x.Details).ToList();//鎵惧嚭鎵�鏈夊嚭搴撳崟鍙风浉鍚岀殑鍑哄簱鍗�
+                _unitOfWorkManage.BeginTran();
+                foreach (var item in cabinOrders)
+                {
+                    if (item.Details != null)
+                        _cabinOrderDetailServices.Repository.DeleteAndMoveIntoHty(item.Details, OperateTypeEnum.浜哄伐瀹屾垚);
+                    item.Modifier = App.User.UserName;
+                    item.ModifyDate = DateTime.Now;
+                    item.Details = null;
+                }
+                BaseDal.DeleteAndMoveIntoHty(cabinOrders, OperateTypeEnum.浜哄伐瀹屾垚);
+                var url = "http://121.37.118.63:80/GYZ2/95fck/outOrderOk";
+                var requestDate = new
+                {
+                    order_no = cabinOrder.Order_no
+                };
+                var result = HttpHelper.Post(url, requestDate.ToJsonString());
+                var response = JsonConvert.DeserializeObject<UpstreamOrderResponse>(result);
+                if (response == null) throw new Exception("涓婃姤ERP鍏ュ簱鍗曞畬鎴愬け璐ワ紒");
+                if (response.resultCode != "0") throw new Exception(response.resultMsg);
+                _unitOfWorkManage.CommitTran();
+                content.OK();
+            }
+            catch (Exception ex)
+            {
+                _unitOfWorkManage.RollbackTran();
+                content.Error(ex.Message);
+            }
+            return content;
+        }
     }
 }

--
Gitblit v1.9.3