From 5b8bf171b9afda52fa366a72e54eedbd9e6d4d17 Mon Sep 17 00:00:00 2001
From: yanjinhui <3306209981@qq.com>
Date: 星期六, 01 十一月 2025 19:54:25 +0800
Subject: [PATCH] Merge branch 'master' of http://115.159.85.185:8098/r/ZhiHuiQiCe/FangCangZhiNeng
---
新建文件夹/WIDESEA_WMSServer/WIDESEA_SquareCabinServices/LKBusiness/DeliveryOrderServicesLK.cs | 119 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 119 insertions(+), 0 deletions(-)
diff --git "a/\346\226\260\345\273\272\346\226\207\344\273\266\345\244\271/WIDESEA_WMSServer/WIDESEA_SquareCabinServices/LKBusiness/DeliveryOrderServicesLK.cs" "b/\346\226\260\345\273\272\346\226\207\344\273\266\345\244\271/WIDESEA_WMSServer/WIDESEA_SquareCabinServices/LKBusiness/DeliveryOrderServicesLK.cs"
new file mode 100644
index 0000000..a806578
--- /dev/null
+++ "b/\346\226\260\345\273\272\346\226\207\344\273\266\345\244\271/WIDESEA_WMSServer/WIDESEA_SquareCabinServices/LKBusiness/DeliveryOrderServicesLK.cs"
@@ -0,0 +1,119 @@
+锘縰sing System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using static WIDESEA_DTO.SquareCabin.TowcsDto;
+using WIDESEA_Core;
+using WIDESEA_Model.Models;
+using WIDESEA_Common.StockEnum;
+using WIDESEA_Common.TaskEnum;
+using WIDESEA_Core.Enums;
+using WIDESEA_ISquareCabinServices;
+using WIDESEA_Core.Helper;
+
+namespace WIDESEA_SquareCabinServices
+{
+ public partial class DeliveryOrderServices
+ {
+ public WebResponseContent CompleteLKOutOrder(Dt_DeliveryOrder deliveryOrder, EdiOrderCallbackRequest request)
+ {
+ WebResponseContent content = new WebResponseContent();
+ try
+ {
+ List<Dt_DeliveryOrderDetail> cabinOrderDetailsUp = new List<Dt_DeliveryOrderDetail>();
+ List<Dt_SupplyTask_Hty> supplyTask_Hties = new List<Dt_SupplyTask_Hty>();
+ List<Dt_InventoryInfo> infosUp = new List<Dt_InventoryInfo>();
+ List<Dt_Inventory_Batch> batchesUp = new List<Dt_Inventory_Batch>();
+ List<Dt_MaterielInfo> materielInfos = _materielInfoService.Repository.QueryData(x => deliveryOrder.Details.Select(x => x.Goods_no).ToList().Contains(x.MaterielCode));
+ List<Dt_InventoryInfo> inventoryInfos = _inventoryInfoService.Repository.QueryData(x => deliveryOrder.Warehouse_no == x.WarehouseCode && deliveryOrder.Details.Select(x => x.Goods_no).ToList().Contains(x.MaterielCode));
+ List<Dt_Inventory_Batch> inventory_Batches = _inventory_BatchServices.Repository.QueryData(x => deliveryOrder.Details.Select(x => x.Goods_no).ToList().Contains(x.MaterielCode));
+ #region 鐩樹簭鍑哄簱鍗�
+ if (deliveryOrder.Out_type == "6")
+ {
+ try
+ {
+ foreach (var detail in request.details)
+ {
+ Dt_DeliveryOrderDetail? orderDetail = deliveryOrder.Details.FirstOrDefault(x => x.Goods_no == detail.productCode && x.Batch_num == detail.batchNo);
+ if (orderDetail == null) throw new Exception($"鏈壘鍒扮洏鐐瑰崟銆恵deliveryOrder.Out_no}銆戠墿鏂欑紪鍙枫�恵detail.productCode}銆戠墿鏂欐壒娆°�恵detail.batchNo}銆戠殑鏄庣粏淇℃伅");
+ decimal orderQty = detail.orderDetails?.Sum(x => decimal.TryParse(x.quantity, out var q) ? Math.Abs(q) : 0) ?? 0;
+ Dt_InventoryInfo inventoryInfo = inventoryInfos.Where(x => x.MaterielCode == detail.productCode && x.BatchNo == detail.batchNo).First();
+ var qty = inventoryInfo.SupplyQuantity - inventoryInfo.StockQuantity;
+ if (orderQty != qty)
+ throw new Exception($"鐩樹簭鍑哄簱鏁伴噺涓嶄竴鑷�,涓婁紶鏁伴噺銆恵orderQty}銆�,搴撳瓨鐩樹簭鏁伴噺銆恵qty}銆�");
+ inventoryInfo.StockQuantity = inventoryInfo.SupplyQuantity;
+ inventoryInfo.SupplyQuantity = 0;
+ inventoryInfo.StockStatus = StockStatusEmun.鍏ュ簱瀹屾垚.ObjToInt();
+ infosUp.Add(inventoryInfo);
+ Dt_Inventory_Batch inventory_Batch = inventory_Batches.First(x => x.MaterielCode == inventoryInfo.MaterielCode && x.BatchNo == inventoryInfo.BatchNo);
+ inventory_Batch.StockQuantity = inventory_Batch.SupplyQuantity;
+ inventory_Batch.SupplyQuantity = 0;
+ batchesUp.Add(inventory_Batch);
+ orderDetail.OotDetailStatus = "宸插畬鎴�";
+ cabinOrderDetailsUp.Add(orderDetail);
+ #region 娣诲姞鐩樼泩鍏ュ簱浠诲姟
+ Dt_SupplyTask_Hty supplyTask_Hty = new Dt_SupplyTask_Hty()
+ {
+ WarehouseCode = inventoryInfo.WarehouseCode,
+ OperateType = OperateTypeEnum.鑷姩瀹屾垚.ToString(),
+ InsertTime = DateTime.Now,
+ TaskStatus = SupplyStatusEnum.OutFinish.ObjToInt(),
+ BatchNo = inventoryInfo.BatchNo,
+ MaterielName = inventoryInfo.MaterielName,
+ MaterielCode = inventoryInfo.MaterielCode,
+ MaterielSpec = inventoryInfo.MaterielSpec,
+ TaskType = TaskTypeEnum.ChenckOut.ObjToInt(),
+ CreateDate = DateTime.Now,
+ Creater = App.User.UserName,
+ LocationCode = inventoryInfo.LocationCode,
+ OrderNo = deliveryOrder.Out_no,
+ StockQuantity = orderQty,
+ SupplyQuantity = 0,
+ Remark = "鐩樹簭鍑哄簱"
+ };
+ supplyTask_Hties.Add(supplyTask_Hty);
+ #endregion
+ }
+ deliveryOrder.OutStatus = "宸插畬鎴�";
+ if (deliveryOrder.Details.Where(x => !cabinOrderDetailsUp.Select(x => x.Id).Contains(x.Id)).Any())
+ deliveryOrder.OutStatus = "寮�濮�";
+ _unitOfWorkManage.BeginTran();
+ _supplyTaskHtyService.AddData(supplyTask_Hties);
+ _inventoryInfoService.UpdateData(infosUp);
+ _inventory_BatchServices.UpdateData(batchesUp);
+ _deliveryOrderDetailServices.UpdateData(cabinOrderDetailsUp);
+ BaseDal.UpdateData(deliveryOrder);
+ _unitOfWorkManage.CommitTran();
+ }
+ catch (Exception ex)
+ {
+ _unitOfWorkManage.RollbackTran();
+ throw new Exception(ex.Message);
+ }
+ }
+ #endregion
+ else
+ {
+ List<Dt_SupplyTask> supplyTasks = _supplyTaskService.Repository.QueryData(x => deliveryOrder.Details.Select(x => x.Goods_no).ToList().Contains(x.MaterielCode) && x.OrderNo == request.externalOrderNo && x.WarehouseCode == deliveryOrder.Warehouse_no && x.TaskStatus == SupplyStatusEnum.NewOut.ObjToInt());
+ foreach (var detail in request.details)
+ {
+ decimal orderQty = detail.orderDetails?.Sum(x => decimal.TryParse(x.quantity, out var q) ? Math.Abs(q) : 0) ?? 0;
+ Dt_SupplyTask? supplyTask = supplyTasks.FirstOrDefault(x => x.MaterielCode == detail.productCode && x.BatchNo == detail.batchNo);
+ if (supplyTask == null) throw new Exception($"鏈壘鍒拌鍗曞彿銆恵request.externalOrderNo}銆戠墿鏂欑紪鍙枫�恵detail.productCode}銆戠殑鍑哄簱浠诲姟");
+ if (supplyTask.StockQuantity != orderQty)
+ throw new Exception($"璁㈠崟鍙枫�恵request.orderNo}銆戠墿鏂欑紪鍙枫�恵detail.productCode}銆戠殑鍑哄簱鏁伴噺涓庡嚭搴撲换鍔℃暟閲忎笉鐩哥瓑");
+ content = OutTaskFinish(supplyTask, deliveryOrder);
+ if (!content.Status) throw new Exception(content.Message);
+ }
+ }
+ content.OK();
+ }
+ catch (Exception ex)
+ {
+ content.Error(ex.Message);
+ }
+ return content;
+ }
+ }
+}
--
Gitblit v1.9.3