From 4d58609275685b1b5deaace933697dcf3f01359e Mon Sep 17 00:00:00 2001
From: dengjunjie <dengjunjie@hnkhzn.com>
Date: 星期二, 04 十一月 2025 12:29:00 +0800
Subject: [PATCH] 优化前端页面显示,优化前后端盘点

---
 新建文件夹/WIDESEA_WMSServer/WIDESEA_SquareCabinServices/extend/Check.cs |   46 +++++++++++++++++++++++++---------------------
 1 files changed, 25 insertions(+), 21 deletions(-)

diff --git "a/\346\226\260\345\273\272\346\226\207\344\273\266\345\244\271/WIDESEA_WMSServer/WIDESEA_SquareCabinServices/extend/Check.cs" "b/\346\226\260\345\273\272\346\226\207\344\273\266\345\244\271/WIDESEA_WMSServer/WIDESEA_SquareCabinServices/extend/Check.cs"
index 9679eb4..f72a092 100644
--- "a/\346\226\260\345\273\272\346\226\207\344\273\266\345\244\271/WIDESEA_WMSServer/WIDESEA_SquareCabinServices/extend/Check.cs"
+++ "b/\346\226\260\345\273\272\346\226\207\344\273\266\345\244\271/WIDESEA_WMSServer/WIDESEA_SquareCabinServices/extend/Check.cs"
@@ -38,20 +38,27 @@
                     var supplyTasks = _supplyTaskService.Repository.QueryData(x => x.MaterielCode == item.MaterielCode && x.BatchNo == item.BatchNo && x.TaskStatus == SupplyStatusEnum.NewCheck.ObjToInt()).ToList();
                     if (supplyTasks.Count > 0) throw new Exception($"鐗╂枡缂栧彿銆恵item.MaterielCode}銆戞壒娆″彿銆恵item.BatchNo}銆戝凡瀛樺湪鐩樼偣浠诲姟锛岃鍏堝畬鎴愬綋鍓嶇洏鐐逛换鍔�");
                     supplyTasks = _supplyTaskService.Repository.QueryData(x => x.MaterielCode == item.MaterielCode && x.BatchNo == item.BatchNo && x.TaskStatus == SupplyStatusEnum.NewOut.ObjToInt()).ToList();
-                    if (supplyTasks.Count > 0) throw new Exception($"鐗╂枡缂栧彿銆恵item.MaterielCode}銆戞壒娆″彿銆恵item.BatchNo}銆戝凡瀛樺湪鐩樼偣浠诲姟锛岃鍏堝畬鎴愬綋鍓嶇洏鐐逛换鍔�");
+                    if (supplyTasks.Count > 0) throw new Exception($"鐗╂枡缂栧彿銆恵item.MaterielCode}銆戞壒娆″彿銆恵item.BatchNo}銆戝凡瀛樺湪鍑哄簱浠诲姟锛岃鍏堝畬鎴愬綋鍓嶅嚭搴撲换鍔�");
                     List<Dt_InventoryInfo> inventoryInfos = _inventoryInfoService.Repository.QueryData(x => item.MaterielCode == x.MaterielCode && x.BatchNo == item.BatchNo);
                     if (inventoryInfos.Count > 0)
                     {
                         foreach (var items in inventoryInfos.GroupBy(x => x.WarehouseCode))
                         {
-                            Dt_DeliveryOrder deliveryOrder = new Dt_DeliveryOrder()
+                            Dt_DeliveryOrder? deliveryOrder = deliveryOrders.Where(x => x.Warehouse_no == items.Key).FirstOrDefault();
+                            bool isNull = false;
+                            if (deliveryOrder == null)
                             {
-                                Out_no = item.MaterielCode + "_" + item.BatchNo,
-                                Out_type = "20",
-                                OutStatus = "鏂板缓",
-                                Warehouse_no = items.Key,
-                                Details = new List<Dt_DeliveryOrderDetail>()
-                            };
+                                isNull = true;
+                                deliveryOrder = new Dt_DeliveryOrder()
+                                {
+                                    //Out_no = item.MaterielCode + "_" + item.BatchNo,
+                                    Out_no = $"PD{items.Key}{DateTime.Now.ToString("yyMMddHHmmss")}",
+                                    Out_type = "20",
+                                    OutStatus = "鏂板缓",
+                                    Warehouse_no = items.Key,
+                                    Details = new List<Dt_DeliveryOrderDetail>()
+                                };
+                            }
                             var Status = items.Key == "001" ? 0 : 2;//鍒ゆ柇鏄惁涓虹珛搴撳尯鍩�
                             Dt_DeliveryOrderDetail deliveryOrderDetail = new Dt_DeliveryOrderDetail()
                             {
@@ -66,7 +73,7 @@
                                 Reservoirarea = items.Key
                             };
                             deliveryOrder.Details.Add(deliveryOrderDetail);
-                            deliveryOrders.Add(deliveryOrder);
+                            if (isNull) deliveryOrders.Add(deliveryOrder);
                             #region 鍒涘缓鐩樼偣浠诲姟
                             foreach (var inventory in items)
                             {
@@ -250,7 +257,7 @@
                 {
                     inventoryInfo = _inventoryInfoService.Repository.QueryFirst(x => x.BatchNo == cabinOrderDetail.Batch_num && x.MaterielCode == cabinOrderDetail.Goods_no && x.WarehouseCode == supplyTask.WarehouseCode);
                 }
-                inventoryInfo.SupplyQuantity = supplyTask.SupplyQuantity;
+                inventoryInfo.SupplyQuantity = supplyTask.SupplyQuantity - inventoryInfo.StockQuantity;
                 #endregion
 
                 #region 鍒ゆ柇褰撳墠鐗╂枡鎵规鐨勭洏鐐逛换鍔℃槸鍚﹀叏閮ㄥ畬鎴�
@@ -262,27 +269,27 @@
                 {
                     #region 鏌ユ壘搴撳瓨
                     inventoryInfos = _inventoryInfoService.Repository.QueryData(x => x.BatchNo == cabinOrderDetail.Batch_num && x.MaterielCode == cabinOrderDetail.Goods_no && x.Id != inventoryInfo.Id);
-                    var SupplyQuantitys = inventoryInfos.Sum(x => x.SupplyQuantity) + supplyTask.SupplyQuantity;
+                    var SupplyQuantitys = inventoryInfos.Sum(x => x.SupplyQuantity) + inventoryInfo.SupplyQuantity;//璁$畻鐩樼偣鎬绘暟
                     #endregion
 
                     #region 搴撳瓨鎵规
                     inventory_Batch = _inventory_BatchServices.Repository.QueryFirst(x => x.BatchNo == cabinOrderDetail.Batch_num && x.MaterielCode == cabinOrderDetail.Goods_no);
-                    //濡傛灉鐩樼偣鏁板拰鎵规鎬绘暟瀵逛笂浜嗭紝鐩樼偣鏁拌祴鍊间负0锛岃祴鍊煎氨娣诲姞鐩樼偣鏁�
-                    if (SupplyQuantitys == inventory_Batch.StockQuantity)
+                    
+                    if (SupplyQuantitys == 0)
                     {
                         foreach (var item in inventoryInfos)
                         {
-                            item.StockQuantity = item.SupplyQuantity;
+                            item.StockQuantity += item.SupplyQuantity;
                             item.SupplyQuantity = 0;
                             item.StockStatus = StockStatusEmun.鍏ュ簱瀹屾垚.ObjToInt();
                         }
-                        inventoryInfo.StockQuantity = supplyTask.SupplyQuantity;
+                        inventoryInfo.StockQuantity += inventoryInfo.SupplyQuantity;
                         inventoryInfo.SupplyQuantity = 0;
                         inventoryInfo.StockStatus = StockStatusEmun.鍏ュ簱瀹屾垚.ObjToInt();
                     }
                     else
                     {
-                        inventory_Batch.SupplyQuantity = SupplyQuantitys;
+                        inventory_Batch.SupplyQuantity += SupplyQuantitys;
                     }
                     #endregion
                 }
@@ -310,11 +317,8 @@
                 #endregion
                 _inventoryInfoService.UpdateData(inventoryInfo);
                 _supplyTaskService.Repository.DeleteAndMoveIntoHty(supplyTask, OperateTypeEnum.鑷姩瀹屾垚);
-                if (inventoryInfos.Count >= 1)
-                {
-                    _inventoryInfoService.UpdateData(inventoryInfos);
-                    _inventory_BatchServices.UpdateData(inventory_Batch);
-                }
+                _inventoryInfoService.UpdateData(inventoryInfos);
+                _inventory_BatchServices.UpdateData(inventory_Batch);
                 _unitOfWorkManage.CommitTran();
                 #endregion
                 content.OK();

--
Gitblit v1.9.3