From b55d324f4b7465f9a7dc50e999346697f5cc35a2 Mon Sep 17 00:00:00 2001
From: wankeda <Administrator@DESKTOP-HAU3ST3>
Date: 星期五, 07 三月 2025 15:17:19 +0800
Subject: [PATCH] 1

---
 WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService.cs |  355 +++++++++++++++++++++++++++++++++++++++++++---------------
 1 files changed, 260 insertions(+), 95 deletions(-)

diff --git a/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService.cs b/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService.cs
index 63dd78b..781a06f 100644
--- a/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService.cs
+++ b/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService.cs
@@ -75,10 +75,14 @@
         private readonly ILocationInfoService _locationInfoService;
         private readonly ITaskService _taskService;
         private readonly IMaterielInfoService _materielInfoService;
+        private readonly IInboundOrder_HtyService _inboundOrder_HtyService;
+        private readonly IInboundOrderDetail_HtyService _inboundOrderDetail_HtyService;
+        private readonly IOutboundOrder_HtyService _outboundOrder_HtyService;
+        private readonly IOutboundOrderDetail_HtyService _outboundOrderDetail_HtyService;
 
         public ITaskRepository Repository => BaseDal;
 
-        public TaskService(ITaskRepository BaseDal, IMapper mapper, IUnitOfWorkManage unitOfWorkManage, IMaterielInfoService materielInfoService, IStockRepository stockRepository, IInboundOrderDetailService inboundOrderDetailService, IBasicService basicService, IOutboundService outboundService, IInboundService inboundService, IRecordService recordService, IStockService stockService, ITask_HtyService taskHtyService, ILocationInfoService locationInfoService) : base(BaseDal)
+        public TaskService(ITaskRepository BaseDal, IMapper mapper, IUnitOfWorkManage unitOfWorkManage, IMaterielInfoService materielInfoService, IInboundOrderDetail_HtyService inboundOrderDetail_HtyService, IOutboundOrder_HtyService outboundOrder_HtyService, IOutboundOrderDetail_HtyService outboundOrderDetail_HtyService, IInboundOrder_HtyService inboundOrder_HtyService, IStockRepository stockRepository, IInboundOrderDetailService inboundOrderDetailService, IBasicService basicService, IOutboundService outboundService, IInboundService inboundService, IRecordService recordService, IStockService stockService, ITask_HtyService taskHtyService, ILocationInfoService locationInfoService) : base(BaseDal)
         {
             _mapper = mapper;
             _stockRepository = stockRepository;
@@ -92,6 +96,11 @@
             _locationInfoService = locationInfoService;
             _inboundOrderDetailService = inboundOrderDetailService;
             _materielInfoService = materielInfoService;
+            _inboundOrder_HtyService = inboundOrder_HtyService;
+            _inboundOrderDetail_HtyService = inboundOrderDetail_HtyService;
+            _outboundOrder_HtyService = outboundOrder_HtyService;
+            _outboundOrderDetail_HtyService = outboundOrderDetail_HtyService;
+
         }
 
         public string ReceiveWMSTaskin = WIDESEA_Core.Helper.AppSettings.Configuration["ReceiveWMSTaskin"];
@@ -198,46 +207,51 @@
                 _recordService.StockQuantityChangeRecordService.AddStockChangeRecord(dt_StockInfo, dt_StockInfo.Details, dt_StockInfo.Details.Sum(x => x.StockQuantity), dt_StockInfo.Details.Sum(x => x.StockQuantity), StockChangeType.Inbound);
                 _unitOfWorkManage.CommitTran();
                 Dt_StockInfoDetail stockInfoDetail = _stockRepository.StockInfoDetailRepository.Db.Queryable<Dt_StockInfoDetail>().Where(x => x.StockId == dt_StockInfo.Id).First();
-                Dt_InboundOrder inboundOrder = _inboundService.InbounOrderService.Db.Queryable<Dt_InboundOrder>().Where(x => x.OrderNo == stockInfoDetail.OrderNo).First();
+                Dt_InboundOrder inboundOrder = _inboundService.InbounOrderService.Db.Queryable<Dt_InboundOrder>().Where(x => x.OrderNo == stockInfoDetail.OrderNo).Includes(x => x.Details).First();
                 Dt_InboundOrderDetail inboundOrderDetail = _inboundService.InboundOrderDetailService.Repository.QueryFirst(x => x.OrderId == inboundOrder.Id);
-
-
-                Dt_InboundOrder_Hty inboundOrder_Hty = new Dt_InboundOrder_Hty
-                {
-                    OrderStatus = inboundOrder.OrderStatus,
-                    CreateType = inboundOrder.CreateType,
-                    //SourceId = oldOutboundOrder.SourceId,
-                    UpperOrderNo = inboundOrder.UpperOrderNo,
-                    OrderNo = inboundOrder.OrderNo,
-                    OutWareHouse = inboundOrder.OutWareHouse,
-                    TransactionCode = inboundOrder.TransactionCode,
-                    InoutType = inboundOrder.InoutType,
-                    OrderType = inboundOrder.OrderType,
-                    Creater = "WMS",
-                    CreateDate = DateTime.Now,
-                };
-                _inboundService.InboundOrder_HtyService.AddData(inboundOrder_Hty);
-
-                Dt_InboundOrderDetail_Hty dt_InboundOrderDetail_Hty = new Dt_InboundOrderDetail_Hty
-                {
-                    OrderId = inboundOrderDetail.OrderId,
-                    MaterielCode = inboundOrderDetail.MaterielCode,
-                    MaterielName = inboundOrderDetail.MaterielName,
-                    BatchNo = inboundOrderDetail.BatchNo,
-                    OrderQuantity = inboundOrderDetail.OrderQuantity,
-                    ReceiptQuantity = inboundOrderDetail.ReceiptQuantity,
-                    OverInQuantity = inboundOrderDetail.OverInQuantity,
-                    OrderDetailStatus = inboundOrderDetail.OrderDetailStatus,
-                };
-                _inboundService.InboundOrderDetail_HtyService.AddData(dt_InboundOrderDetail_Hty);
-                _inboundService.InbounOrderService.DeleteData(inboundOrder);
-                _inboundService.InboundOrderDetailService.DeleteData(inboundOrderDetail);
+                //鍒ゆ柇鍗曟嵁绫诲瀷鏄叆搴撹繕鏄皟鎷ㄥ叆搴撱�傘�傘�傚叆搴�
                 if (inboundOrder.OrderType == 0)
                 {
+                    #region //鍒ゆ柇鍏ュ簱鍗曟嵁鏄庣粏鍙湁鏈�鍚庝竴鏉″畬鎴愭椂鍒犻櫎鍏ュ簱鍗�
+                    if (inboundOrder.Details.Count == 1)
+                    {
+                        Dt_InboundOrder_Hty inboundOrder_Hty = new Dt_InboundOrder_Hty
+                        {
+                            OrderStatus = inboundOrder.OrderStatus,
+                            CreateType = inboundOrder.CreateType,
+                            //SourceId = oldOutboundOrder.SourceId,
+                            UpperOrderNo = inboundOrder.UpperOrderNo,
+                            OrderNo = inboundOrder.OrderNo,
+                            //OutWareHouse = inboundOrder.OutWareHouse,
+                            TransactionCode = inboundOrder.TransactionCode,
+                            InoutType = inboundOrder.InoutType,
+                            OrderType = inboundOrder.OrderType,
+                            Creater = "WMS",
+                            CreateDate = DateTime.Now,
+                        };
+                        _inboundOrder_HtyService.AddData(inboundOrder_Hty);
+                        _inboundService.InbounOrderService.DeleteData(inboundOrder);
+                    }
+                    Dt_InboundOrderDetail_Hty dt_InboundOrderDetail_Hty = new Dt_InboundOrderDetail_Hty
+                    {
+                        OrderId = inboundOrderDetail.OrderId,
+                        MaterielCode = inboundOrderDetail.MaterielCode,
+                        MaterielName = inboundOrderDetail.MaterielName,
+                        BatchNo = inboundOrderDetail.BatchNo,
+                        OrderQuantity = inboundOrderDetail.OrderQuantity,
+                        ReceiptQuantity = inboundOrderDetail.ReceiptQuantity,
+                        OverInQuantity = inboundOrderDetail.OverInQuantity,
+                        OrderDetailStatus = inboundOrderDetail.OrderDetailStatus,
+                        Creater = "WMS",
+                        CreateDate = DateTime.Now,
+                    };
+                    _inboundOrderDetail_HtyService.AddData(dt_InboundOrderDetail_Hty);
+                    _inboundService.InboundOrderDetailService.DeleteData(inboundOrderDetail);
+                    #endregion
+                    #region//鍏ュ簱淇℃伅杩斿洖涓婁綅WMS銆傘�傜珛搴撳叆搴撴暟閲忓洖浼�
                     HouseInboundPassBack houseInboundPassBack = new HouseInboundPassBack();
                     houseInboundPassBack.ApiType = "AsnController";
                     houseInboundPassBack.Method = "AsrsGroudingAsn";
-
                     data data = new data();
                     data.data1 data1 = new data.data1();
                     data1.AsnNo = task.OrderNo;
@@ -245,13 +259,15 @@
                     data1.TransactionCode = inboundOrder.TransactionCode;
                     data1.InoutType = inboundOrder.OrderType;
                     data1.OrderType = inboundOrder.InoutType;
-                    data.data1.Inbound inbound = new data.data1.Inbound();
-                    inbound.LinId = stockInfoDetail.LinId;
-                    inbound.MaterielCode = stockInfoDetail.MaterielCode;
-                    inbound.OrderQuantity = stockInfoDetail.StockQuantity;
-                    inbound.BatchNo = stockInfoDetail.BatchNo;
-                    inbound.FinishQty = stockInfoDetail.StockQuantity;
-                    inbound.LocationName = task.TargetAddress;
+                    data.data1.Inbound inbound = new data.data1.Inbound
+                    {
+                        LinId = stockInfoDetail.LinId,
+                        MaterielCode = stockInfoDetail.MaterielCode,
+                        OrderQuantity = stockInfoDetail.StockQuantity,
+                        BatchNo = stockInfoDetail.BatchNo,
+                        FinishQty = stockInfoDetail.StockQuantity,
+                        LocationName = task.TargetAddress
+                    };
                     data.Value.Add(data1);
                     data1.DetailList.Add(inbound);
                     houseInboundPassBack.Parameters.Add(data);
@@ -275,56 +291,113 @@
                         houseInboundPassBack.Context.Add("InvOrgId", InvOrgId);
                         var responses = HttpHelper.Post<WebResponseContent>(ReceiveWMSTaskin, houseInboundPassBack, "绔嬪簱鍏ュ簱鏁伴噺鍥炰紶WMS");
                     }
+                    #endregion
                 }
                 else
                 {
-                    InventoryAllocate inventoryAllocate = new InventoryAllocate();
-                    inventoryAllocate.ApiType = "InventoryAllocateController";
-                    inventoryAllocate.Method = "AsrsFinishedStockCount";
-
-                    Allocate allocate = new Allocate();
-
-                    Allocate.data1 data1 = new Allocate.data1();
-                    data1.No = task.OrderNo;
-                    data1.InWarehouse = task.Roadway;
-                    data1.TransactionCode = inboundOrder.TransactionCode;
-                    data1.InoutType = inboundOrder.OrderType;
-                    data1.OrderType = inboundOrder.InoutType;
-                    Allocate.data1.Inventory inbound = new Allocate.data1.Inventory();
-                    inbound.LinId = stockInfoDetail.LinId;
-                    inbound.MaterielCode = stockInfoDetail.MaterielCode;
-                    inbound.OrderQuantity = stockInfoDetail.StockQuantity;
-                    inbound.BatchNo = stockInfoDetail.BatchNo;
-                    inbound.FinishQty = stockInfoDetail.StockQuantity;
-                    inbound.LocationName = task.TargetAddress;
-                    allocate.Value.Add(data1);
-                    data1.DetailList.Add(inbound);
-                    inventoryAllocate.Parameters.Add(allocate);
-                    Authentication authentication = new Authentication()
+                    #region //鍒ゆ柇璋冩嫧鍏ュ簱鍗曟嵁鏄庣粏鍙湁鏈�鍚庝竴鏉″畬鎴愭椂鍒犻櫎鍏ュ簱鍗曞苟涓�娆¤繑鍥炲叆搴撴槑缁嗕俊鎭�
+                    if (inboundOrder.Details.Count == 1)
                     {
-                        ApiType = "AuthenticationController",
-                        Parameters = new List<Parameter>
+                        List<Dt_StockInfo> StockInfo = _stockService.StockInfoService.Repository.QueryData(x => x.BatchNo == inboundOrderDetail.BatchNo);
+                        Dt_InboundOrder_Hty inboundOrder_Hty = new Dt_InboundOrder_Hty
+                        {
+                            OrderStatus = inboundOrder.OrderStatus,
+                            CreateType = inboundOrder.CreateType,
+                            //SourceId = oldOutboundOrder.SourceId,
+                            UpperOrderNo = inboundOrder.UpperOrderNo,
+                            OrderNo = inboundOrder.OrderNo,
+                            //OutWareHouse = inboundOrder.OutWareHouse,
+                            TransactionCode = inboundOrder.TransactionCode,
+                            InoutType = inboundOrder.InoutType,
+                            OrderType = inboundOrder.OrderType,
+                            Creater = "WMS",
+                            CreateDate = DateTime.Now,
+                        };
+                        _inboundOrder_HtyService.AddData(inboundOrder_Hty);
+                        _inboundService.InbounOrderService.DeleteData(inboundOrder);
+                        Dt_InboundOrderDetail_Hty dt_InboundOrderDetail_HtyS = new Dt_InboundOrderDetail_Hty
+                        {
+                            OrderId = inboundOrderDetail.OrderId,
+                            MaterielCode = inboundOrderDetail.MaterielCode,
+                            MaterielName = inboundOrderDetail.MaterielName,
+                            BatchNo = inboundOrderDetail.BatchNo,
+                            OrderQuantity = inboundOrderDetail.OrderQuantity,
+                            ReceiptQuantity = inboundOrderDetail.ReceiptQuantity,
+                            OverInQuantity = inboundOrderDetail.OverInQuantity,
+                            OrderDetailStatus = inboundOrderDetail.OrderDetailStatus,
+                            Creater = "WMS",
+                            CreateDate = DateTime.Now,
+                        };
+                        _inboundOrderDetail_HtyService.AddData(dt_InboundOrderDetail_HtyS);
+                        _inboundService.InboundOrderDetailService.DeleteData(inboundOrderDetail);
+                        #endregion
+                        #region//璋冩嫧浠诲姟鏁伴噺鍥炰紶WMS
+                        InventoryAllocate inventoryAllocate = new InventoryAllocate();
+                        inventoryAllocate.ApiType = "InventoryAllocateController";
+                        inventoryAllocate.Method = "AsrsFinishedStockCount";
+
+                        Allocate allocate = new Allocate();
+
+                        Allocate.data1 data1 = new Allocate.data1();
+                        data1.No = task.OrderNo;
+                        data1.InWarehouse = task.Roadway;
+                        data1.TransactionCode = inboundOrder.TransactionCode;
+                        data1.InoutType = inboundOrder.OrderType;
+                        data1.OrderType = inboundOrder.InoutType;
+                        foreach (var item in StockInfo)
+                        {
+                            Dt_StockInfoDetail detail = _stockService.StockInfoDetailService.Repository.QueryFirst(x => x.StockId == item.Id);
+                            Allocate.data1.Inventory inbound = new Allocate.data1.Inventory();
+                            inbound.LinId = detail.LinId;
+                            inbound.LPN_No = item.PalletCode;
+                            inbound.MaterielCode = detail.MaterielCode;
+                            inbound.OrderQuantity = detail.StockQuantity;
+                            inbound.BatchNo = detail.BatchNo;
+                            inbound.FinishQty = detail.StockQuantity;
+                            inbound.LocationName = item.LocationCode;
+                            data1.DetailList.Add(inbound);
+                        }
+                        allocate.Value.Add(data1);
+                        inventoryAllocate.Parameters.Add(allocate);
+                        Authentication authentication = new Authentication()
+                        {
+                            ApiType = "AuthenticationController",
+                            Parameters = new List<Parameter>
                     {
                      new Parameter { Value = "LKAdmin"},
                      new Parameter { Value = "LKAdmin"},
                     },
-                        Method = "Login",
-                    };
-                    var responses1 = HttpHelper.Post<WebResponseContent>(ReceiveWMSTaskAUT, authentication, "鐧诲綍WMS璐﹀彿");
-                    var Ticket = responses1.Context["Ticket"].ToString();
-                    var InvOrgId = responses1.Context["InvOrgId"].ToString();
-                    if (Ticket != null)
-                    {
-                        inventoryAllocate.Context = new Dictionary<string, string>();
-                        inventoryAllocate.Context.Add("Ticket", Ticket);
-                        inventoryAllocate.Context.Add("InvOrgId", InvOrgId);
-                        var responses = HttpHelper.Post<WebResponseContent>(ReceiveWMSTaskAllocatein, inventoryAllocate, "璋冩嫧鍏ュ簱鏁伴噺鍥炰紶WMS");
+                            Method = "Login",
+                        };
+                        var responses1 = HttpHelper.Post<WebResponseContent>(ReceiveWMSTaskAUT, authentication, "鐧诲綍WMS璐﹀彿");
+                        var Ticket = responses1.Context["Ticket"].ToString();
+                        var InvOrgId = responses1.Context["InvOrgId"].ToString();
+                        if (Ticket != null)
+                        {
+                            inventoryAllocate.Context = new Dictionary<string, string>();
+                            inventoryAllocate.Context.Add("Ticket", Ticket);
+                            inventoryAllocate.Context.Add("InvOrgId", InvOrgId);
+                            var responses = HttpHelper.Post<WebResponseContent>(ReceiveWMSTaskAllocatein, inventoryAllocate, "璋冩嫧鍏ュ簱鏁伴噺鍥炰紶WMS");
+                        }
                     }
+                    #endregion
+                    Dt_InboundOrderDetail_Hty dt_InboundOrderDetail_Hty = new Dt_InboundOrderDetail_Hty
+                    {
+                        OrderId = inboundOrderDetail.OrderId,
+                        MaterielCode = inboundOrderDetail.MaterielCode,
+                        MaterielName = inboundOrderDetail.MaterielName,
+                        BatchNo = inboundOrderDetail.BatchNo,
+                        OrderQuantity = inboundOrderDetail.OrderQuantity,
+                        ReceiptQuantity = inboundOrderDetail.ReceiptQuantity,
+                        OverInQuantity = inboundOrderDetail.OverInQuantity,
+                        OrderDetailStatus = inboundOrderDetail.OrderDetailStatus,
+                        Creater = "WMS",
+                        CreateDate = DateTime.Now,
+                    };
+                    _inboundOrderDetail_HtyService.AddData(dt_InboundOrderDetail_Hty);
+                    _inboundService.InboundOrderDetailService.DeleteData(inboundOrderDetail);
                 }
-
-
                 return WebResponseContent.Instance.OK();
-
             }
             catch (Exception ex)
             {
@@ -391,10 +464,48 @@
                 _recordService.LocationStatusChangeRecordSetvice.AddLocationStatusChangeRecord(locationInfo, beforeStatus, StockChangeType.Outbound.ObjToInt(), stockInfo.Details.FirstOrDefault()?.OrderNo ?? "", task.TaskNum);
                 _unitOfWorkManage.CommitTran();
                 Dt_StockInfoDetail stockInfoDetail = _stockRepository.StockInfoDetailRepository.Db.Queryable<Dt_StockInfoDetail>().Where(x => x.StockId == stockInfo.Id).First();
-                Dt_OutboundOrderDetail outDetail = _outboundService.OutboundOrderDetailService.Db.Queryable<Dt_OutboundOrderDetail>().Where(x => x.BatchNo == stockInfoDetail.BatchNo).First();
-                Dt_OutboundOrder outboundOrder = _outboundService.OutboundOrderService.Db.Queryable<Dt_OutboundOrder>().Where(x => x.Id == outDetail.OrderId).First();
+                Dt_OutboundOrderDetail outDetail = _outboundService.OutboundOrderDetailService.Db.Queryable<Dt_OutboundOrderDetail>().Where(x => x.LPNNo == stockInfo.PalletCode).First();
+                Dt_OutboundOrder outboundOrder = _outboundService.OutboundOrderService.Db.Queryable<Dt_OutboundOrder>().Where(x => x.Id == outDetail.OrderId).Includes(x => x.Details).First();
+                //鍒ゆ柇鍗曟嵁绫诲瀷鏄嚭搴撹繕鏄皟鎷ㄥ嚭搴撱�傘�傘�傚嚭搴�
                 if (outboundOrder.OrderType == 1)
                 {
+                    #region //鍒ゆ柇鍑哄簱鍗曟嵁鏄庣粏鍙湁鏈�鍚庝竴鏉″畬鎴愭椂鍒犻櫎鍑哄簱鍗�
+                    if (outboundOrder.Details.Count == 1)
+                    {
+                        Dt_OutboundOrder_Hty inboundOrder_Hty = new Dt_OutboundOrder_Hty
+                        {
+                            OrderStatus = outboundOrder.OrderStatus,
+                            CreateType = outboundOrder.CreateType,
+                            //SourceId = oldOutboundOrder.SourceId,
+                            UpperOrderNo = outboundOrder.UpperOrderNo,
+                            OrderNo = outboundOrder.OrderNo,
+                            OutWareHouse = outboundOrder.OutWareHouse,
+                            TransactionCode = outboundOrder.TransactionCode,
+                            InoutType = outboundOrder.InoutType,
+                            OrderType = outboundOrder.OrderType,
+                            Creater = "WMS",
+                            CreateDate = DateTime.Now,
+                        };
+                        _outboundOrder_HtyService.AddData(inboundOrder_Hty);
+                        _outboundService.OutboundOrderService.DeleteData(outboundOrder);
+                    }
+                    Dt_OutboundOrderDetail_Hty dt_InboundOrderDetail_Hty = new Dt_OutboundOrderDetail_Hty
+                    {
+                        OrderId = outDetail.OrderId,
+                        MaterielCode = outDetail.MaterielCode,
+                        MaterielName = outDetail.MaterielName,
+                        BatchNo = outDetail.BatchNo,
+                        OrderQuantity = outDetail.OrderQuantity,
+                        //ReceiptQuantity = outDetail.ReceiptQuantity,
+                        //OverInQuantity = outDetail.OverInQuantity,
+                        OrderDetailStatus = outDetail.OrderDetailStatus,
+                        Creater = "WMS",
+                        CreateDate = DateTime.Now,
+                    };
+                    _outboundOrderDetail_HtyService.AddData(dt_InboundOrderDetail_Hty);
+                    _outboundService.OutboundOrderService.DeleteData(outDetail);
+                    #endregion
+                    #region//鍑哄簱淇℃伅杩斿洖涓婁綅WMS銆傘�傘�傜珛搴撳嚭搴撴暟閲忓洖浼�
                     HouseoutboundPassBack houseInboundPassBack = new HouseoutboundPassBack();
                     houseInboundPassBack.ApiType = "ShippingOrderController";
                     houseInboundPassBack.Method = "AsrsOutboundSO";
@@ -408,6 +519,7 @@
 
                     datas.data1.Inbound inbound = new datas.data1.Inbound();
                     inbound.LinId = outDetail.LinId;
+                    inbound.LPN_No = task.PalletCode;
                     inbound.MaterielCode = stockInfoDetail.MaterielCode;
                     inbound.OrderQuantity = stockInfoDetail.OutboundQuantity;
                     inbound.BatchNo = stockInfoDetail.BatchNo;
@@ -420,10 +532,10 @@
                     {
                         ApiType = "AuthenticationController",
                         Parameters = new List<Parameter>
-                {
+                    {
                      new Parameter { Value = "LKAdmin"},
                      new Parameter { Value = "LKAdmin"},
-                },
+                    },
                         Method = "Login",
                     };
                     var responses1 = HttpHelper.Post<WebResponseContent>(ReceiveWMSTaskAUT, authentication, "鐧诲綍WMS璐﹀彿");
@@ -436,9 +548,54 @@
                         houseInboundPassBack.Context.Add("InvOrgId", InvOrgId);
                         var responses = HttpHelper.Post<WebResponseContent>(ReceiveWMSTaskout, houseInboundPassBack, "绔嬪簱鍑哄簱鏁伴噺鍥炰紶WMS");
                     }
+                    #endregion
+                    //鍒犻櫎搴撳瓨淇℃伅
+                    _stockService.StockInfoService.Repository.DeleteAndMoveIntoHty(stockInfo, App.User.UserId == 0 ? OperateType.鑷姩瀹屾垚 : OperateType.浜哄伐瀹屾垚);
+                    _stockService.StockInfoDetailService.Repository.DeleteAndMoveIntoHty(stockInfo.Details, App.User.UserId == 0 ? OperateType.鑷姩瀹屾垚 : OperateType.浜哄伐瀹屾垚);
+                }
+                else if (outboundOrder.OrderType == 240)
+                {
+                    //鐩樼偣鍑哄簱浠诲姟瀹屾垚銆併�併�併�併�併�併�併�併�佷笉鑳藉垹闄ゅ簱瀛樼瓑閫昏緫
                 }
                 else
                 {
+
+                    List<Dt_StockInfo> StockInfo = _stockService.StockInfoService.Repository.QueryData(x => x.BatchNo == outDetail.BatchNo);
+                    if (outboundOrder.Details.Count == 1)
+                    {
+                        Dt_OutboundOrder_Hty inboundOrder_Hty = new Dt_OutboundOrder_Hty
+                        {
+                            OrderStatus = outboundOrder.OrderStatus,
+                            CreateType = outboundOrder.CreateType,
+                            //SourceId = oldOutboundOrder.SourceId,
+                            UpperOrderNo = outboundOrder.UpperOrderNo,
+                            OrderNo = outboundOrder.OrderNo,
+                            OutWareHouse = outboundOrder.OutWareHouse,
+                            TransactionCode = outboundOrder.TransactionCode,
+                            InoutType = outboundOrder.InoutType,
+                            OrderType = outboundOrder.OrderType,
+                            Creater = "WMS",
+                            CreateDate = DateTime.Now,
+                        };
+                        _outboundOrder_HtyService.AddData(inboundOrder_Hty);
+                        _outboundService.OutboundOrderService.DeleteData(outboundOrder);
+                    }
+                    Dt_OutboundOrderDetail_Hty dt_InboundOrderDetail_Hty = new Dt_OutboundOrderDetail_Hty
+                    {
+                        OrderId = outDetail.OrderId,
+                        MaterielCode = outDetail.MaterielCode,
+                        MaterielName = outDetail.MaterielName,
+                        BatchNo = outDetail.BatchNo,
+                        OrderQuantity = outDetail.OrderQuantity,
+                        //ReceiptQuantity = outDetail.ReceiptQuantity,
+                        //OverInQuantity = outDetail.OverInQuantity,
+                        OrderDetailStatus = outDetail.OrderDetailStatus,
+                        Creater = "WMS",
+                        CreateDate = DateTime.Now,
+                    };
+                    _outboundOrderDetail_HtyService.AddData(dt_InboundOrderDetail_Hty);
+                    _outboundService.OutboundOrderService.DeleteData(outDetail);
+
                     InventoryAllocate inventoryAllocate = new InventoryAllocate();
                     inventoryAllocate.ApiType = "InventoryAllocateController";
                     inventoryAllocate.Method = "AsrsFinishedStockCount";
@@ -451,15 +608,23 @@
                     data1.TransactionCode = outboundOrder.TransactionCode;
                     data1.InoutType = outboundOrder.OrderType;
                     data1.OrderType = outboundOrder.InoutType;
-                    Allocate.data1.Inventory inbound = new Allocate.data1.Inventory();
-                    inbound.LinId = outDetail.LinId;
-                    inbound.MaterielCode = stockInfoDetail.MaterielCode;
-                    inbound.OrderQuantity = stockInfoDetail.StockQuantity;
-                    inbound.BatchNo = stockInfoDetail.BatchNo;
-                    inbound.FinishQty = stockInfoDetail.StockQuantity;
-                    inbound.LocationName = task.SourceAddress;
+
+                    foreach (var item in StockInfo)
+                    {
+                        Dt_StockInfoDetail detail = _stockService.StockInfoDetailService.Repository.QueryFirst(x => x.StockId == item.Id);
+                        Allocate.data1.Inventory inbound = new Allocate.data1.Inventory();
+                        inbound.LinId = outDetail.LinId;
+                        inbound.LPN_No = item.PalletCode;
+                        inbound.MaterielCode = detail.MaterielCode;
+                        inbound.OrderQuantity = detail.OutboundQuantity;
+                        inbound.BatchNo = detail.BatchNo;
+                        inbound.FinishQty = detail.OutboundQuantity;
+                        inbound.LocationName = task.SourceAddress;
+                        data1.DetailList.Add(inbound);
+                    }
+
+
                     allocate.Value.Add(data1);
-                    data1.DetailList.Add(inbound);
                     inventoryAllocate.Parameters.Add(allocate);
                     Authentication authentication = new Authentication()
                     {
@@ -481,9 +646,9 @@
                         inventoryAllocate.Context.Add("InvOrgId", InvOrgId);
                         var responses = HttpHelper.Post<WebResponseContent>(ReceiveWMSTaskAllocatein, inventoryAllocate, "璋冩嫧鍑哄簱鏁伴噺鍥炰紶WMS");
                     }
+                    _stockService.StockInfoService.Repository.DeleteAndMoveIntoHty(stockInfo, App.User.UserId == 0 ? OperateType.鑷姩瀹屾垚 : OperateType.浜哄伐瀹屾垚);
+                    _stockService.StockInfoDetailService.Repository.DeleteAndMoveIntoHty(stockInfo.Details, App.User.UserId == 0 ? OperateType.鑷姩瀹屾垚 : OperateType.浜哄伐瀹屾垚);
                 }
-
-
                 return WebResponseContent.Instance.OK();
             }
             catch (Exception ex)

--
Gitblit v1.9.3