wangxinhui
昨天 011ca316e6ec2ed93e31c45a9ebd9d3c66664871
ÏîÄ¿´úÂë/WMS/WMSServices/WIDESEA_TaskInfoService/TaskService_Outbound.cs
@@ -1,4 +1,4 @@

using System;
using System.Collections.Generic;
using System.Linq;
@@ -59,6 +59,10 @@
                {
                    return content.Error($"生成任务失败");
                }
                tasks.ForEach(x =>
                {
                    x.Grade = 1;
                });
                stockInfos.ForEach(x =>
                {
                    x.StockStatus = StockStatusEmun.出库锁定.ObjToInt();
@@ -219,7 +223,7 @@
                            }
                            if (outStockLockInfosMES != null && outStockLockInfosMES.Count() > 0)
                            {
                                Dt_AGVStationInfo aGVStationInfo = _basicRepository.AGVStationInfoRepository.QueryFirst(x=>x.AGVStationCode==task.TargetAddress);
                                Dt_AGVStationInfo aGVStationInfo = _basicRepository.AGVStationInfoRepository.QueryFirst(x=>x.AGVStationCode==task.TargetAddress || x.MESPointCode == task.TargetAddress);
                                MESDeliveryModel mESDeliveryModel = MESDeliveryUp(outStockLockInfosMES, aGVStationInfo.MESPointCode);
                                MESResponse response = _invokeMESService.MESDelivery(mESDeliveryModel).DeserializeObject<MESResponse>() ?? throw new Exception("未获取到返回信息");
                                if (!response.Result)
@@ -391,8 +395,11 @@
                        taskType = outStockLockInfo.MachineName.ObjToInt() switch
                        {
                            (int)StationAreaEnum.二楼纸袋 => TaskTypeEnum.PaperYLOutZDGL,
                            (int)StationAreaEnum.二楼无纺布袋 => TaskTypeEnum.OutWFBGL,
                            (int)StationAreaEnum.一楼无纺淋膜 => TaskTypeEnum.OutWFBLM,
                            (int)StationAreaEnum.一楼印刷 => TaskTypeEnum.PrintYLOutbound,
                            (int)StationAreaEnum.一楼分切 => TaskTypeEnum.OutFenQie,
                            (int)StationAreaEnum.一楼纸张淋膜 => TaskTypeEnum.OutPaperLM,
                            _ => throw new Exception($"未找到加工中心任务类型分配")
                        };
                        Dt_Task task = new()
@@ -679,7 +686,7 @@
                List<Dt_OutStockLockInfo> outStockLockInfos = new List<Dt_OutStockLockInfo>();
                List<Dt_LocationInfo> locationInfos = new List<Dt_LocationInfo>();
                //生成任务、库存等信息
                (List<Dt_Task>, List<Dt_StockInfo>?, List<Dt_OutSGOrderDetail>?, List<Dt_OutStockLockInfo>?, List<Dt_LocationInfo>?) result = OutSGTaskDataHandle(keys);
                (List<Dt_Task>, List<Dt_StockInfo>?, List<Dt_OutSGOrderDetail>?, List<Dt_OutStockLockInfo>?, List<Dt_LocationInfo>?,string) result = OutSGTaskDataHandle(keys);
                if (result.Item2 != null && result.Item2.Count > 0)
                {
                    stockInfos.AddRange(result.Item2);
@@ -700,8 +707,9 @@
                {
                    tasks.AddRange(result.Item1);
                }
                content.Message = result.Item6;
                //处理出库数据
                return GenerateOutboundTaskDataUpdate(tasks, stockInfos, outSGOrderDetails, outStockLockInfos, locationInfos);
                return GenerateOutboundTaskDataUpdate(tasks, stockInfos, outSGOrderDetails, outStockLockInfos, locationInfos, result.Item6);
            }
            catch (Exception ex)
            {
@@ -717,7 +725,7 @@
        /// <param name="stockSelectViews"></param>
        /// <returns></returns>
        /// <exception cref="Exception"></exception>
        public (List<Dt_Task>, List<Dt_StockInfo>?, List<Dt_OutSGOrderDetail>?, List<Dt_OutStockLockInfo>?, List<Dt_LocationInfo>?) OutSGTaskDataHandle(int[] keys)
        public (List<Dt_Task>, List<Dt_StockInfo>?, List<Dt_OutSGOrderDetail>?, List<Dt_OutStockLockInfo>?, List<Dt_LocationInfo>?,string) OutSGTaskDataHandle(int[] keys)
        {
            List<Dt_Task> tasks = new List<Dt_Task>();
            List<Dt_OutSGOrderDetail> outSGOrderDetails = _outboundRepository.OutSGOrderDetailRepository.QueryData(x => keys.Contains(x.Id));
@@ -737,7 +745,15 @@
            List<Dt_LocationInfo>? locationInfos = null;
            //分配库存
            (List<Dt_StockInfo>, List<Dt_OutSGOrderDetail>, List<Dt_OutStockLockInfo>, List<Dt_LocationInfo>) result = _outboundService.OutSGOrderDetailService.AssignStockOutbound(outSGOrderDetails);
            (List<Dt_StockInfo>, List<Dt_OutSGOrderDetail>, List<Dt_OutStockLockInfo>, List<Dt_LocationInfo>,string) result = _outboundService.OutSGOrderDetailService.AssignStockOutbound(outSGOrderDetails);
            //保存缺料状态,无论是否生成了任务
            var shortageDetails = result.Item2.Where(x => x.OutSGOrderDetailStatus == OutOrderStatusEnum.缺料.ObjToInt()).ToList();
            if (shortageDetails.Any())
            {
                _outboundRepository.OutSGOrderDetailRepository.UpdateData(shortageDetails);
            }
            if (result.Item1 != null && result.Item1.Count > 0)
            {
                //获取任务
@@ -768,16 +784,17 @@
            }
            else
            {
                throw new Exception("无库存");
                //没有库存,但已经在AssignStockOutbound方法中标记了缺料状态,并且已经保存
                orderDetails = result.Item2;
            }
            return (tasks, stockInfos, orderDetails, outStockLockInfos, locationInfos);
            return (tasks, stockInfos, orderDetails, outStockLockInfos, locationInfos, result.Item5);
        }
        /// <summary>
        /// å¤„理出库数据
        /// </summary>
        /// <returns></returns>
        public WebResponseContent GenerateOutboundTaskDataUpdate(List<Dt_Task> tasks, List<Dt_StockInfo>? stockInfos = null, List<Dt_OutSGOrderDetail>? outboundOrderDetails = null, List<Dt_OutStockLockInfo>? outStockLockInfos = null, List<Dt_LocationInfo>? locationInfos = null)
        public WebResponseContent GenerateOutboundTaskDataUpdate(List<Dt_Task> tasks, List<Dt_StockInfo>? stockInfos = null, List<Dt_OutSGOrderDetail>? outboundOrderDetails = null, List<Dt_OutStockLockInfo>? outStockLockInfos = null, List<Dt_LocationInfo>? locationInfos = null, string message = "")
        {
            try
            {
@@ -787,8 +804,12 @@
                {
                    tasks.ForEach(x =>
                    {
                        string orderNos = string.Join(",", outStockLockInfos.Where(t => t.PalletCode == x.PalletCode).Select(x => x.OrderNo).Distinct());
                        List<Dt_OutStockLockInfo> outStockNos = outStockLockInfos.Where(t => t.PalletCode == x.PalletCode).ToList();
                        List<int> outDetailIds = outStockNos.Select(t => t.OrderDetailId).ToList();
                        int numberNo = outboundOrderDetails.Where(t => outDetailIds.Contains(t.Id)).OrderBy(x => x.Number).FirstOrDefault().Number;
                        string orderNos = string.Join(",", outStockNos.Select(t => t.OrderNo).Distinct());
                        x.OrderNo = orderNos;
                        x.Grade = numberNo;
                    });
                }
                BaseDal.AddData(tasks);
@@ -817,7 +838,7 @@
                }
                _unitOfWorkManage.CommitTran();
                PushTasksToWCS(tasks);
                return WebResponseContent.Instance.OK();
                return WebResponseContent.Instance.OK(message);
            }
            catch (Exception ex)
            {
@@ -839,7 +860,8 @@
                
                //获取领料条码及库存
                List<string> lockCodes = bSTPickInfoDTOs.SelectMany(x => x.PaperMattakeDetails).Select(x=>x.Barcode).Distinct().ToList();
                List<Dt_StockInfo> stockInfos = _stockRepository.StockInfoRepository.QueryData(x=> lockCodes.Contains(x.PalletCode));
                List<Dt_StockInfo> stockInfos = _stockRepository.StockInfoRepository.QueryData(x => lockCodes.Contains(x.PalletCode) && x.WarehouseId == WarehouseEnum.LLDOldCache.ObjToInt());
                List<string> ExistNoCodes = lockCodes.Where(x => !stockInfos.Select(x=>x.PalletCode).Contains(x)).ToList();
                //获取待领料的出库详情
                List<Dt_OutStockLockInfo> outStockLockInfos = _outboundRepository.OutStockLockInfoRepository.QueryData(x => x.OrderType == OutOrderTypeEnum.OutSGPick.ObjToInt() && x.Status==OutLockStockStatusEnum.出库完成.ObjToInt() && lockCodes.Distinct().ToList().Contains(x.PalletCode));
                //出库详情状态更新
@@ -880,24 +902,27 @@
                #region é¢†æ–™é€»è¾‘
                foreach (var item in stockInfos)
                {
                    if (item.StockStatus==StockStatusEmun.出库完成.ObjToInt())
                    if (item.StockStatus==StockStatusEmun.出库完成.ObjToInt() || item.StockStatus == StockStatusEmun.老厂退料暂存.ObjToInt())
                    {
                        item.StockLength = 0;
                        item.MaterielWeight = 0;
                        item.MaterielThickness = 0;
                        item.MaterielWide = 0;
                        item.StockOutLength = 0;
                        item.IsFull = WhetherEnum.True.ObjToInt();
                        item.IsPick = WhetherEnum.True.ObjToInt();
                    }
                }
                #endregion
                List<Dt_OutLineView> outLineViewsDel = _outboundRepository.OutLineViewRepository.QueryData(x => stockInfos.Select(x=>x.PalletCode).Contains(x.PalletCode));
                //数据库操作
                _unitOfWorkManage.BeginTran();
                _stockRepository.StockInfoRepository.UpdateData(stockInfos);
                _outboundRepository.OutStockLockInfoRepository.UpdateData(outStockLockInfos);
                _outboundRepository.OutSGOrderRepository.UpdateData(outSGOrders);
                _outboundRepository.OutSGOrderDetailRepository.UpdateData(orderDetails);
                _outboundRepository.OutLineViewRepository.DeleteData(outLineViewsDel);
                _unitOfWorkManage.CommitTran();
                content.OK(ExistNoCodes.Count>0 ? string.Join(",", ExistNoCodes)+"老厂可扣库存不存在" : "");
            }
            catch (Exception ex)
            {
@@ -934,6 +959,76 @@
            }
            return content;
        }
        /// <summary>
        /// åˆ›å»ºé”€å”®å‡ºåº“
        /// </summary>
        /// <param name="ids"></param>
        /// <returns></returns>
        public WebResponseContent CreateProDeliveryTasks(List<int> ids)
        {
            WebResponseContent content=new WebResponseContent();
            try
            {
                ////获取销售出库单据
                //List<Dt_ProDeliveryOrder> deliveryOrders = BaseDal.Db.Queryable<Dt_ProDeliveryOrder>().Where(x=> ids.Contains(x.Id)).Includes(x=>x.Details).ToList();
                //Dt_ProDeliveryOrder? proDeliveryOrder = deliveryOrders.FirstOrDefault(x => x.ProDeliveryStatus != OutOrderStatusEnum.未开始.ObjToInt());
                //if (proDeliveryOrder != null)
                //{
                //    return content.Error($"单号{proDeliveryOrder.DeliveryCode},订单状态{(OutOrderStatusEnum)proDeliveryOrder.ProDeliveryStatus}");
                //}
                //List<Dt_ProDeliveryOrderDetail> proDeliveryOrderDetails = deliveryOrders.SelectMany(x=>x.Details).ToList();
                //if (!proDeliveryOrderDetails.Any())
                //{
                //    throw new Exception($"未找到需出库的明细信息");
                //}
                //_unitOfWorkManage.BeginTran();
                //List<Dt_Task> tasks = new List<Dt_Task>();
                //List<Dt_ProStockInfo>? stockInfos = null;
                //List<Dt_ProDeliveryOrder>? Orders = null;
                //List<Dt_ProDeliveryOrderDetail>? OrderDetails = null;
                //List<Dt_OutStockLockInfo>? outStockLockInfos = null;
                //List<Dt_LocationInfo>? locationInfos = null;
                //{
                //    //分配库存
                //    (List<Dt_ProStockInfo>, List<Dt_ProDeliveryOrder>, List<Dt_ProDeliveryOrderDetail>, List<Dt_OutStockLockInfo>, List<Dt_LocationInfo>) result = _outboundService.ProDeliveryOrderService.AssignProStockOutbound(deliveryOrders, proDeliveryOrderDetails);
                //    if (result.Item1 != null && result.Item1.Count > 0)
                //    {
                //        //创建任务
                //        tasks = GetTasks(result.Item1, result.Item3);
                //        result.Item3.ForEach(x =>
                //        {
                //            x.Status = OutLockStockStatusEnum.出库中.ObjToInt();
                //        });
                //        stockInfos = result.Item1;
                //        Orders = result.Item2;
                //        outStockLockInfos = result.Item3;
                //        locationInfos = result.Item4;
                //    }
                //}
                //if (stockInfos != null && stockInfos.Count > 0 && outStockLockInfos != null && outStockLockInfos.Count > 0 && locationInfos != null && locationInfos.Count > 0 && tasks.Count > 0)
                //{
                //    BaseDal.AddData(tasks);
                //    stockInfos.ForEach(x =>
                //    {
                //        x.StockStatus = StockStatusEmun.出库锁定.ObjToInt();
                //    });
                //    WebResponseContent contentResponse = _outboundService.OutMESOrderService.LockOutboundStockDataUpdate(stockInfos, Orders, outStockLockInfos, locationInfos, tasks: tasks);
                //    if (!contentResponse.Status)
                //    {
                //        _unitOfWorkManage.RollbackTran();
                //        return content.Error(contentResponse.Message);
                //    }
                //}
                //_unitOfWorkManage.CommitTran();
            }
            catch (Exception ex)
            {
                _unitOfWorkManage.RollbackTran();
                content.Error(ex.Message);
            }
            return content;
        }
        List<string> GradeCodes = new List<string>
        {
            "001"
@@ -945,6 +1040,7 @@
        public WebResponseContent ReceiveOutBound(List<OutMESOrderDTO> outMESOrderDTOs)
        {
            WebResponseContent content = new WebResponseContent();
            string ErrorMsg = "";
            try
            {
                if (outMESOrderDTOs == null || outMESOrderDTOs.Count <= 0)
@@ -974,11 +1070,11 @@
                //获取所有加工中心
                List<Dt_MakeCenterInfo> makeCenterInfos = _basicRepository.MakeCenterInfoRepository.QueryData();
                OutMESOrderDTO? CheckMaterialCode = outMESOrderDTOs.FirstOrDefault(x => !materielInfos.Select(x => x.MaterielCode).Contains(x.MaterialCode));
                if (CheckMaterialCode != null)
                {
                    return content.Error($"物料编码{nameof(OutMESOrderDTO.MaterialCode)}:{CheckMaterialCode.MaterialCode}信息不存在");
                }
                //OutMESOrderDTO? CheckMaterialCode = outMESOrderDTOs.FirstOrDefault(x => !materielInfos.Select(x => x.MaterielCode).Contains(x.MaterialCode));
                //if (CheckMaterialCode != null)
                //{
                //    return content.Error($"物料编码{nameof(OutMESOrderDTO.MaterialCode)}:{CheckMaterialCode.MaterialCode}信息不存在");
                //}
                OutMESOrderDTO? CheckMakeCenterCode = outMESOrderDTOs.FirstOrDefault(x => !makeCenterInfos.Select(x => x.MakeCode).Contains(x.MakeCode));
                if (CheckMakeCenterCode!=null)
                {
@@ -989,107 +1085,112 @@
                {
                    return content.Error($"领料计划{nameof(OutMESOrderDTO.OutDetailId)}:{OldoutMESOrder.OutDetailId}信息已存在");
                }
                List<Dt_OutMESOrder> AddoutMESOrders = outMESOrderDTOs.Select(x => _mapper.Map<Dt_OutMESOrder>(x)).ToList();
                foreach (var item in AddoutMESOrders)
                List<Dt_OutMESOrder> AddoutMESOrders = new List<Dt_OutMESOrder>();
                foreach (var item in outMESOrderDTOs)
                {
                    Dt_MaterielInfo materielInfo = materielInfos.FirstOrDefault(x => x.MaterielCode == item.MaterialCode);
                    Dt_MakeCenterInfo makeCenterInfo=makeCenterInfos.FirstOrDefault(x => x.MakeCode == item.MakeCode);
                    item.MakeArea = makeCenterInfo.MakeArea;
                    item.WarehouseId = materielInfo.WarehouseId;
                    item.MaterielUnit = materielInfo.MaterielUnit;
                    item.AssistUnitCode = materielInfo.AssistUnitCode;
                    Dt_MaterielInfo? materielInfo = materielInfos.FirstOrDefault(x => x.MaterielCode == item.MaterialCode);
                    if (materielInfo==null)
                    {
                        ErrorMsg += $"物料编码:{item.MaterialCode}信息不存在;";
                        continue;
                    }
                    Dt_MakeCenterInfo makeCenterInfo = makeCenterInfos.FirstOrDefault(x => x.MakeCode == item.MakeCode);
                    Dt_OutMESOrder outMESOrder = _mapper.Map<Dt_OutMESOrder>(item);
                    outMESOrder.MakeArea = makeCenterInfo.MakeArea;
                    outMESOrder.WarehouseId = materielInfo.WarehouseId;
                    outMESOrder.MaterielUnit = materielInfo.MaterielUnit;
                    outMESOrder.AssistUnitCode = materielInfo.AssistUnitCode;
                    AddoutMESOrders.Add(outMESOrder);
                }
                _unitOfWorkManage.BeginTran();
                //操作数据,并分配需求库存
                _outboundRepository.OutMESOrderRepository.AddData(AddoutMESOrders);
                //List<Dt_OutMESOrder> mESOrders = _outboundRepository.OutMESOrderRepository.QueryData(x => AddoutMESOrders.Select(x => x.OutDetailId).Contains(x.OutDetailId));
                //{
                //    List<Dt_Task> tasks = new List<Dt_Task>();
                //    List<Dt_ProStockInfo>? stockInfos = null;
                //    List<Dt_OutMESOrder>? Orders = null;
                //    List<Dt_OutStockLockInfo>? outStockLockInfos = null;
                //    List<Dt_LocationInfo>? locationInfos = null;
                //    {
                //        if (mESOrders.Where(x => x.WarehouseId == WarehouseEnum.LLDFL.ObjToInt()).ToList().Count>0)
                //        {
                //            //分配库存
                //            (List<Dt_ProStockInfo>, List<Dt_OutMESOrder>, List<Dt_OutStockLockInfo>, List<Dt_LocationInfo>) result = _outboundService.OutMESOrderService.AssignProStockOutbound(mESOrders.Where(x => x.WarehouseId == WarehouseEnum.LLDFL.ObjToInt()).ToList());
                //            if (result.Item1 != null && result.Item1.Count > 0)
                //            {
                //                //创建任务
                //                tasks = GetTasks(result.Item1, result.Item3);
                //                result.Item3.ForEach(x =>
                //                {
                //                    x.Status = OutLockStockStatusEnum.出库中.ObjToInt();
                //                });
                //                stockInfos = result.Item1;
                //                Orders = result.Item2;
                //                outStockLockInfos = result.Item3;
                //                locationInfos = result.Item4;
                //            }
                //        }
                //    }
                //    if (stockInfos != null && stockInfos.Count > 0 && outStockLockInfos != null && outStockLockInfos.Count > 0 && locationInfos != null && locationInfos.Count > 0 && tasks.Count>0)
                //    {
                //        BaseDal.AddData(tasks);
                //        stockInfos.ForEach(x =>
                //        {
                //            x.StockStatus = StockStatusEmun.出库锁定.ObjToInt();
                //        });
                //        WebResponseContent contentResponse = _outboundService.OutMESOrderService.LockOutboundStockDataUpdate(stockInfos, Orders, outStockLockInfos, locationInfos, tasks: tasks);
                List<Dt_OutMESOrder> mESOrders = _outboundRepository.OutMESOrderRepository.QueryData(x => AddoutMESOrders.Select(x => x.OutDetailId).Contains(x.OutDetailId));
                {
                    List<Dt_Task> tasks = new List<Dt_Task>();
                    List<Dt_ProStockInfo>? stockInfos = null;
                    List<Dt_OutMESOrder>? Orders = null;
                    List<Dt_OutStockLockInfo>? outStockLockInfos = null;
                    List<Dt_LocationInfo>? locationInfos = null;
                    {
                        if (mESOrders.Where(x => x.WarehouseId == WarehouseEnum.LLDFL.ObjToInt()).ToList().Count > 0)
                        {
                            //分配库存
                            (List<Dt_ProStockInfo>, List<Dt_OutMESOrder>, List<Dt_OutStockLockInfo>, List<Dt_LocationInfo>) result = _outboundService.OutMESOrderService.AssignProStockOutbound(mESOrders.Where(x => x.WarehouseId == WarehouseEnum.LLDFL.ObjToInt()).ToList());
                            if (result.Item1 != null && result.Item1.Count > 0)
                            {
                                //创建任务
                                tasks = GetTasks(result.Item1, result.Item3);
                                result.Item3.ForEach(x =>
                                {
                                    x.Status = OutLockStockStatusEnum.出库中.ObjToInt();
                                });
                                stockInfos = result.Item1;
                                Orders = result.Item2;
                                outStockLockInfos = result.Item3;
                                locationInfos = result.Item4;
                            }
                        }
                    }
                    if (stockInfos != null && stockInfos.Count > 0 && outStockLockInfos != null && outStockLockInfos.Count > 0 && locationInfos != null && locationInfos.Count > 0 && tasks.Count > 0)
                    {
                        BaseDal.AddData(tasks);
                        stockInfos.ForEach(x =>
                        {
                            x.StockStatus = StockStatusEmun.出库锁定.ObjToInt();
                        });
                        WebResponseContent contentResponse = _outboundService.OutMESOrderService.LockOutboundStockDataUpdate(stockInfos, Orders, outStockLockInfos, locationInfos, tasks: tasks);
                //        if (!contentResponse.Status)
                //        {
                //            _unitOfWorkManage.RollbackTran();
                //            return content.Error(contentResponse.Message);
                //        }
                //    }
                //}
                //{
                //    List<Dt_Task> tasks = new List<Dt_Task>();
                //    List<Dt_StockInfo>? stockInfos = null;
                //    List<Dt_OutMESOrder>? Orders = null;
                //    List<Dt_OutStockLockInfo>? outStockLockInfos = null;
                //    List<Dt_LocationInfo>? locationInfos = null;
                //    {
                //        if (mESOrders.Where(x => x.WarehouseId == WarehouseEnum.LLDYL.ObjToInt()).ToList().Count > 0)
                //        {
                //            //分配库存
                //            (List<Dt_StockInfo>, List<Dt_OutMESOrder>, List<Dt_OutStockLockInfo>, List<Dt_LocationInfo>) result = _outboundService.OutMESOrderService.AssignStockOutbound(mESOrders.Where(x => x.WarehouseId == WarehouseEnum.LLDYL.ObjToInt()).ToList());
                //            if (result.Item1 != null && result.Item1.Count > 0)
                //            {
                //                //创建任务
                //                tasks = GetTasks(result.Item1, result.Item3);
                //                result.Item3.ForEach(x =>
                //                {
                //                    x.Status = OutLockStockStatusEnum.出库中.ObjToInt();
                //                });
                //                stockInfos = result.Item1;
                //                Orders = result.Item2;
                //                outStockLockInfos = result.Item3;
                //                locationInfos = result.Item4;
                //            }
                //        }
                //    }
                //    if (stockInfos != null && stockInfos.Count > 0 && outStockLockInfos != null && outStockLockInfos.Count > 0 && locationInfos != null && locationInfos.Count > 0 && tasks.Count>0)
                //    {
                //        BaseDal.AddData(tasks);
                //        stockInfos.ForEach(x =>
                //        {
                //            x.StockStatus = StockStatusEmun.出库锁定.ObjToInt();
                //        });
                //        WebResponseContent contentResponse = _outboundService.OutMESOrderService.LockOutboundStockDataUpdate(stockInfos, Orders, outStockLockInfos, locationInfos, tasks: tasks);
                //        if (!contentResponse.Status)
                //        {
                //            _unitOfWorkManage.RollbackTran();
                //            return content.Error(contentResponse.Message);
                //        }
                //    }
                //}
                        if (!contentResponse.Status)
                        {
                            _unitOfWorkManage.RollbackTran();
                            return content.Error(contentResponse.Message);
                        }
                    }
                }
                {
                    List<Dt_Task> tasks = new List<Dt_Task>();
                    List<Dt_StockInfo>? stockInfos = null;
                    List<Dt_OutMESOrder>? Orders = null;
                    List<Dt_OutStockLockInfo>? outStockLockInfos = null;
                    List<Dt_LocationInfo>? locationInfos = null;
                    {
                        if (mESOrders.Where(x => x.WarehouseId == WarehouseEnum.LLDYL.ObjToInt()).ToList().Count > 0)
                        {
                            //分配库存
                            (List<Dt_StockInfo>, List<Dt_OutMESOrder>, List<Dt_OutStockLockInfo>, List<Dt_LocationInfo>) result = _outboundService.OutMESOrderService.AssignStockOutbound(mESOrders.Where(x => x.WarehouseId == WarehouseEnum.LLDYL.ObjToInt()).ToList());
                            if (result.Item1 != null && result.Item1.Count > 0)
                            {
                                //创建任务
                                tasks = GetTasks(result.Item1, result.Item3);
                                result.Item3.ForEach(x =>
                                {
                                    x.Status = OutLockStockStatusEnum.出库中.ObjToInt();
                                });
                                stockInfos = result.Item1;
                                Orders = result.Item2;
                                outStockLockInfos = result.Item3;
                                locationInfos = result.Item4;
                            }
                        }
                    }
                    if (stockInfos != null && stockInfos.Count > 0 && outStockLockInfos != null && outStockLockInfos.Count > 0 && locationInfos != null && locationInfos.Count > 0 && tasks.Count > 0)
                    {
                        BaseDal.AddData(tasks);
                        stockInfos.ForEach(x =>
                        {
                            x.StockStatus = StockStatusEmun.出库锁定.ObjToInt();
                        });
                        WebResponseContent contentResponse = _outboundService.OutMESOrderService.LockOutboundStockDataUpdate(stockInfos, Orders, outStockLockInfos, locationInfos, tasks: tasks);
                        if (!contentResponse.Status)
                        {
                            _unitOfWorkManage.RollbackTran();
                            return content.Error(contentResponse.Message);
                        }
                    }
                }
                _unitOfWorkManage.CommitTran();
                return content.OK("接收成功");
                return content.OK(ErrorMsg.IsNullOrEmpty()? "接收成功" : $"信息:{ErrorMsg}");
            }
            catch (Exception ex)
            {
@@ -1145,6 +1246,7 @@
            }
            catch (Exception ex)
            {
                _unitOfWorkManage.RollbackTran();
                content.Error(ex.Message);
            }
            return content;