|  |  | 
 |  |  |             _recordService = recordService; | 
 |  |  |         } | 
 |  |  |  | 
 |  |  |         /// <summary> | 
 |  |  |         /// éå®åºåï¼ç±ç³»ç»åé
(ä»
é»è¾è¿ç®ï¼ä¸çæä»»å¡ï¼ä¸ä¿®æ¹æ°æ®åºæ°æ®) | 
 |  |  |         /// </summary> | 
 |  |  |         /// <param name="orderDetailId"></param> | 
 |  |  |         /// <returns></returns> | 
 |  |  |         public WebResponseContent LockOutboundStock(int orderDetailId) | 
 |  |  |         { | 
 |  |  |             Dt_OutboundOrderDetail outboundOrderDetail = BaseDal.QueryFirst(x => x.Id == orderDetailId); | 
 |  |  |             (bool, string) result = CheckDeital(outboundOrderDetail); | 
 |  |  |             if (!result.Item1) return WebResponseContent.Instance.Error(result.Item2); | 
 |  |  |             if (outboundOrderDetail == null) | 
 |  |  |             { | 
 |  |  |                 return WebResponseContent.Instance.Error("æªæ¾å°åºåºåæç»ä¿¡æ¯"); | 
 |  |  |             } | 
 |  |  |             if (outboundOrderDetail.OrderDetailStatus != OrderDetailStatusEnum.New.ObjToInt()) | 
 |  |  |             { | 
 |  |  |                 return WebResponseContent.Instance.Error("该æç»ä¸å¯æä½"); | 
 |  |  |             } | 
 |  |  |             Dt_OutboundOrder outboundOrder = _outboundRepository.OutboundOrderRepository.QueryFirst(x => x.Id == outboundOrderDetail.OrderId); | 
 |  |  |  | 
 |  |  |             float needQuantity = outboundOrderDetail.OrderQuantity - outboundOrderDetail.LockQuantity; | 
 |  |  | 
 |  |  |             } | 
 |  |  |         } | 
 |  |  |  | 
 |  |  |         private (bool, string) CheckDeital(Dt_OutboundOrderDetail outboundOrderDetail) | 
 |  |  |         { | 
 |  |  |             if (outboundOrderDetail == null) | 
 |  |  |             { | 
 |  |  |                 return (false, "æªæ¾å°åºåºåæç»ä¿¡æ¯"); | 
 |  |  |             } | 
 |  |  |             if (outboundOrderDetail.OrderDetailStatus != OrderDetailStatusEnum.New.ObjToInt()) | 
 |  |  |             { | 
 |  |  |                 return (false, "该æç»ä¸å¯æä½"); | 
 |  |  |             } | 
 |  |  |             return (true, "æå"); | 
 |  |  |         } | 
 |  |  |  | 
 |  |  |         /// <summary> | 
 |  |  |         /// å个åºåºåæç»åºååé
 | 
 |  |  |         /// </summary> | 
 |  |  |         /// <param name="outboundOrderDetail"></param> | 
 |  |  |         /// <param name="stockSelectViews"></param> | 
 |  |  |         /// <returns></returns> | 
 |  |  |         /// <exception cref="Exception"></exception> | 
 |  |  |         public (List<Dt_StockInfo>, Dt_OutboundOrderDetail, List<Dt_OutStockLockInfo>, List<Dt_LocationInfo>) AssignStockOutbound(Dt_OutboundOrderDetail outboundOrderDetail, List<StockSelectViewDTO> stockSelectViews) | 
 |  |  |         { | 
 |  |  |             (bool, string) checkResult = CheckSelectStockDeital(outboundOrderDetail, stockSelectViews); | 
 |  |  | 
 |  |  |             return (outStocks, outboundOrderDetail, outStockLockInfos, locationInfos); | 
 |  |  |         } | 
 |  |  |  | 
 |  |  |         /// <summary> | 
 |  |  |         ///  | 
 |  |  |         /// </summary> | 
 |  |  |         /// <param name="outboundOrderDetails"></param> | 
 |  |  |         /// <returns></returns> | 
 |  |  |         public (List<Dt_StockInfo>, List<Dt_OutboundOrderDetail>, List<Dt_OutStockLockInfo>, List<Dt_LocationInfo>) AssignStockOutbound(List<Dt_OutboundOrderDetail> outboundOrderDetails) | 
 |  |  |         { | 
 |  |  |             if (!outboundOrderDetails.Any()) | 
 |  |  |             { | 
 |  |  |                 throw new Exception($"æªæ¾å°åºåºåæç»ä¿¡æ¯"); | 
 |  |  |             } | 
 |  |  |  | 
 |  |  |             if (outboundOrderDetails.GroupBy(x => x.OrderId).Count() > 1) | 
 |  |  |             { | 
 |  |  |                 throw new Exception($"请å¿åæ¶æä½å¤ä¸ªåæ®æç»"); | 
 |  |  |             } | 
 |  |  |             Dt_OutboundOrder outboundOrder = _outboundRepository.OutboundOrderRepository.QueryFirst(x => x.Id == outboundOrderDetails.FirstOrDefault().OrderId); | 
 |  |  |             List<Dt_StockInfo> outStocks = new List<Dt_StockInfo>(); | 
 |  |  |             List<Dt_OutboundOrderDetail> groupDetails = outboundOrderDetails.GroupBy(x => new { x.MaterielCode, x.BatchNo }).Select(x => new Dt_OutboundOrderDetail { OrderQuantity = x.Sum(v => v.OrderQuantity) - x.Sum(v => v.LockQuantity), MaterielCode = x.Key.MaterielCode, BatchNo = x.Key.BatchNo, }).ToList(); | 
 |  |  |  | 
 |  |  |             List<Dt_OutStockLockInfo> outStockLockInfos = new List<Dt_OutStockLockInfo>(); | 
 |  |  |             List<Dt_LocationInfo> locationInfos = new List<Dt_LocationInfo>(); | 
 |  |  |             foreach (var item in groupDetails) | 
 |  |  |             { | 
 |  |  |                 float originalNeedQuantity = item.OrderQuantity; | 
 |  |  |  | 
 |  |  |                 float needQuantity = originalNeedQuantity; | 
 |  |  |  | 
 |  |  |                 List<Dt_StockInfo> stockInfos = _stockService.StockInfoService.GetUseableStocks(item.MaterielCode, item.BatchNo, outboundOrder.WarehouseId); | 
 |  |  |                 if (!stockInfos.Any()) | 
 |  |  |                 { | 
 |  |  |                     throw new Exception($"æªæ¾å°å¯åé
åºå"); | 
 |  |  |                 } | 
 |  |  |                 List<Dt_StockInfo> autoAssignStocks = _stockService.StockInfoService.GetOutboundStocks(stockInfos, item.MaterielCode, needQuantity, out float residueQuantity); | 
 |  |  |                 item.LockQuantity += needQuantity - residueQuantity; | 
 |  |  |                 outStocks.AddRange(autoAssignStocks); | 
 |  |  |                 float assignQuantity = needQuantity - residueQuantity; | 
 |  |  |  | 
 |  |  |                 List<Dt_OutboundOrderDetail> details = outboundOrderDetails.Where(x => !string.IsNullOrEmpty(x.BatchNo) ? x.BatchNo == item.BatchNo : true && x.MaterielCode == item.MaterielCode).ToList(); | 
 |  |  |  | 
 |  |  |                 for (int i = 0; i < details.Count; i++) | 
 |  |  |                 { | 
 |  |  |                     float orderQuantity = details[i].OrderQuantity; | 
 |  |  |                     for (int j = 0; j < autoAssignStocks.Count; j++) | 
 |  |  |                     { | 
 |  |  |                         float detailAssignQuantity = outStockLockInfos.Where(x => !string.IsNullOrEmpty(x.BatchNo) ? x.BatchNo == item.BatchNo : true && x.MaterielCode == item.MaterielCode && x.OrderDetailId == details[i].Id).Sum(x => x.AssignQuantity);//åºåºè®¢åæç»å·²åé
æ°é | 
 |  |  |  | 
 |  |  |                         float palletAssignQuantity = outStockLockInfos.Where(x => x.BatchNo == item.BatchNo && x.MaterielCode == item.MaterielCode && x.PalletCode == autoAssignStocks[j].PalletCode).Sum(x => x.AssignQuantity);//åºåºè¯¦æ
å·²åé
æ°é | 
 |  |  |                         if (string.IsNullOrEmpty(item.BatchNo)) | 
 |  |  |                         { | 
 |  |  |                             palletAssignQuantity = outStockLockInfos.Where(x => x.MaterielCode == item.MaterielCode && x.PalletCode == autoAssignStocks[j].PalletCode).Sum(x => x.AssignQuantity);//åºåºè¯¦æ
å·²åé
æ°é | 
 |  |  |                         } | 
 |  |  |                         float palletOutboundQuantity = autoAssignStocks[j].Details.Sum(x => x.OutboundQuantity); | 
 |  |  |                         if (palletAssignQuantity < palletOutboundQuantity)//妿åºåºè¯¦æ
å·²åé
æ°éå°äºæçå·²åé
æ°éï¼åå¯ä»¥ç»§ç»æ·»å è¯¥æçåºåºä¿¡æ¯ | 
 |  |  |                         { | 
 |  |  |                             float orderDetailNeedQuantity = details[i].OrderQuantity - detailAssignQuantity; | 
 |  |  |                             if (orderDetailNeedQuantity > autoAssignStocks[j].Details.Sum(x => x.OutboundQuantity) - palletAssignQuantity) | 
 |  |  |                             { | 
 |  |  |                                 details[i].LockQuantity += autoAssignStocks[j].Details.Sum(x => x.OutboundQuantity) - palletAssignQuantity; | 
 |  |  |                                 Dt_OutStockLockInfo outStockLockInfo = _outStockLockInfoService.GetOutStockLockInfo(outboundOrder, details[i], autoAssignStocks[j], autoAssignStocks[j].Details.Sum(x => x.OutboundQuantity) - palletAssignQuantity); | 
 |  |  |                                 outStockLockInfos.Add(outStockLockInfo); | 
 |  |  |                             } | 
 |  |  |                             else | 
 |  |  |                             { | 
 |  |  |                                 Dt_OutStockLockInfo outStockLockInfo = _outStockLockInfoService.GetOutStockLockInfo(outboundOrder, details[i], autoAssignStocks[j], details[i].OrderQuantity - details[i].LockQuantity); | 
 |  |  |                                 outStockLockInfos.Add(outStockLockInfo); | 
 |  |  |                                 details[i].LockQuantity = details[i].OrderQuantity; | 
 |  |  |                                 break; | 
 |  |  |                             } | 
 |  |  |  | 
 |  |  |                         } | 
 |  |  |                     } | 
 |  |  |                 } | 
 |  |  |  | 
 |  |  |  | 
 |  |  |                 locationInfos.AddRange(_basicService.LocationInfoService.Repository.GetLocationInfos(outStocks.Select(x => x.LocationCode).ToList())); | 
 |  |  |             } | 
 |  |  |  | 
 |  |  |             return (outStocks, outboundOrderDetails, outStockLockInfos, locationInfos); | 
 |  |  |         } | 
 |  |  |  | 
 |  |  |         /// <summary> | 
 |  |  |         ///  éå®åºåï¼ç±äººå·¥æå®ï¼æå ä¸ç³»ç»åé
(å
å«é»è¾è¿ç®ï¼ä¸ä¿®æ¹æ°æ®åºæ°æ®) | 
 |  |  |         /// </summary> | 
 |  |  |         /// <param name="orderDetailId"></param> | 
 |  |  |         /// <param name="stockSelectViews"></param> | 
 |  |  |         /// <returns></returns> | 
 |  |  |         public WebResponseContent LockOutboundStock(int orderDetailId, List<StockSelectViewDTO> stockSelectViews) | 
 |  |  |         { | 
 |  |  |             try | 
 |  |  | 
 |  |  |             } | 
 |  |  |         } | 
 |  |  |  | 
 |  |  |         /// <summary> | 
 |  |  |         ///  éå®åºåï¼ç±ç³»ç»åé
(å
å«é»è¾è¿ç®ï¼ä¸ä¿®æ¹æ°æ®åºæ°æ®) | 
 |  |  |         /// </summary> | 
 |  |  |         /// <param name="orderDetailId"></param> | 
 |  |  |         /// <param name="stockSelectViews"></param> | 
 |  |  |         /// <returns></returns> | 
 |  |  |         public WebResponseContent LockOutboundStock(int[] keys) | 
 |  |  |         { | 
 |  |  |             try | 
 |  |  | 
 |  |  |             } | 
 |  |  |         } | 
 |  |  |  | 
 |  |  |         /// <summary> | 
 |  |  |         /// åºåºåºååé
åï¼æ´æ°æ°æ®åºæ°æ® | 
 |  |  |         /// </summary> | 
 |  |  |         /// <param name="stockInfos"></param> | 
 |  |  |         /// <param name="outboundOrderDetails"></param> | 
 |  |  |         /// <param name="outStockLockInfos"></param> | 
 |  |  |         /// <param name="locationInfos"></param> | 
 |  |  |         /// <param name="locationStatus"></param> | 
 |  |  |         /// <param name="tasks"></param> | 
 |  |  |         /// <returns></returns> | 
 |  |  |         public WebResponseContent LockOutboundStockDataUpdate(List<Dt_StockInfo> stockInfos, List<Dt_OutboundOrderDetail> outboundOrderDetails, List<Dt_OutStockLockInfo> outStockLockInfos, List<Dt_LocationInfo> locationInfos, LocationStatusEnum locationStatus = LocationStatusEnum.Lock, List<Dt_Task>? tasks = null) | 
 |  |  |         { | 
 |  |  |             try | 
 |  |  | 
 |  |  |                 List<Dt_OutStockLockInfo> addOutStockLockInfos = outStockLockInfos.Where(x => x.Id == 0).ToList(); | 
 |  |  |                 if (addOutStockLockInfos != null && addOutStockLockInfos.Any()) | 
 |  |  |                 { | 
 |  |  |                     if (tasks != null) | 
 |  |  |                     { | 
 |  |  |                         addOutStockLockInfos.ForEach(x => | 
 |  |  |                         { | 
 |  |  |                             x.TaskNum = tasks.FirstOrDefault(v => v.PalletCode == x.PalletCode)?.TaskNum; | 
 |  |  |                         }); | 
 |  |  |                     } | 
 |  |  |  | 
 |  |  |                     _outStockLockInfoService.Repository.AddData(addOutStockLockInfos); | 
 |  |  |                 } | 
 |  |  |                 List<Dt_OutStockLockInfo> updateOutStockLockInfos = outStockLockInfos.Where(x => x.Id > 0).ToList(); | 
 |  |  | 
 |  |  |             return (true, "æå"); | 
 |  |  |         } | 
 |  |  |  | 
 |  |  |         /// <summary> | 
 |  |  |         /// æ¤ééå®åºå | 
 |  |  |         /// </summary> | 
 |  |  |         /// <param name="orderDetailId"></param> | 
 |  |  |         /// <returns></returns> | 
 |  |  |         public WebResponseContent RevokeLockOutboundStock(int orderDetailId) | 
 |  |  |         { | 
 |  |  |             Dt_OutboundOrderDetail outboundOrderDetail = BaseDal.QueryFirst(x => x.Id == orderDetailId); |