|  |  |  | 
|---|
|  |  |  | using WIDESEA_Common.LocationEnum; | 
|---|
|  |  |  | using WIDESEA_Common.OrderEnum; | 
|---|
|  |  |  | using WIDESEA_Common.StockEnum; | 
|---|
|  |  |  | using WIDESEA_Common.WareHouseEnum; | 
|---|
|  |  |  | using WIDESEA_Core; | 
|---|
|  |  |  | using WIDESEA_Core.BaseRepository; | 
|---|
|  |  |  | using WIDESEA_Core.BaseServices; | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 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_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(); | 
|---|
|  |  |  | Dt_Warehouse warehouse = _basicService.WarehouseService.Repository.QueryFirst(x=>x.WarehouseId== outboundOrder.WarehouseId); | 
|---|
|  |  |  | List<Dt_OutStockLockInfo> outStockLockInfos = new List<Dt_OutStockLockInfo>(); | 
|---|
|  |  |  | List<Dt_LocationInfo> locationInfos = new List<Dt_LocationInfo>(); | 
|---|
|  |  |  | foreach (var item in groupDetails) | 
|---|
|  |  |  | 
|---|
|  |  |  | throw new Exception($"æªæ¾å°å¯åé
åºå"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | List<Dt_StockInfo> autoAssignStocks = _stockService.StockInfoService.GetOutboundStocks(stockInfos, item.MaterielCode, needQuantity, out float residueQuantity); | 
|---|
|  |  |  | if (warehouse.WarehouseCode==WarehouseEnum.HA152.ToString()) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | if (needQuantity< autoAssignStocks.Count) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | throw new Exception($"ç³»ç»è¶
æ¶,请ç¨ååè¯"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | item.LockQuantity += needQuantity - residueQuantity; | 
|---|
|  |  |  | outStocks.AddRange(autoAssignStocks); | 
|---|
|  |  |  | float assignQuantity = needQuantity - residueQuantity; | 
|---|
|  |  |  | 
|---|
|  |  |  | List<Dt_StockInfoDetail> stockInfoDetails = new List<Dt_StockInfoDetail>(); | 
|---|
|  |  |  | foreach (var item in stockInfos) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | foreach (var detail in item.Details) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | // è¿è¡å®å
¨è½¬æ¢ | 
|---|
|  |  |  | if (detail.OutboundQuantity != null && decimal.TryParse(detail.OutboundQuantity.ToString(), out decimal outboundDecimal)) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | decimal outboundDecimal1 = Convert.ToDecimal(detail.OutboundQuantity); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | else | 
|---|
|  |  |  | { | 
|---|
|  |  |  | detail.OutboundQuantity = 0; // é»è®¤å¼æè®°å½é误 | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | stockInfoDetails.AddRange(item.Details); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | _stockService.StockInfoDetailService.Repository.UpdateData(stockInfoDetails); | 
|---|
|  |  |  | BaseDal.UpdateData(outboundOrderDetails); | 
|---|