| | |
| | | private readonly IStockService _stockInfoService; |
| | | private readonly IBasicService _basicService; |
| | | private readonly IOutProStockInfoService _outProStockInfoService; |
| | | private readonly IProOutOrderRepository _proOutOrderRepository; |
| | | private readonly IRecordService _recordService; |
| | | public ProOutOrderDetailService(IProOutOrderDetailRepository BaseDal, IUnitOfWorkManage unitOfWorkManage, IStockService stockInfoService, IBasicService basicService,IOutProStockInfoService outProStockInfoService, IRecordService recordService) : base(BaseDal) |
| | | public ProOutOrderDetailService(IProOutOrderDetailRepository BaseDal, IUnitOfWorkManage unitOfWorkManage, IStockService stockInfoService, IBasicService basicService,IOutProStockInfoService outProStockInfoService, IRecordService recordService, IProOutOrderRepository proOutOrderRepository) : base(BaseDal) |
| | | { |
| | | _unitOfWorkManage = unitOfWorkManage; |
| | | _stockInfoService = stockInfoService; |
| | | _basicService = basicService; |
| | | _outProStockInfoService = outProStockInfoService; |
| | | _recordService = recordService; |
| | | _proOutOrderRepository=proOutOrderRepository; |
| | | } |
| | | /// <summary> |
| | | /// åºåºåºååé
åï¼æ´æ°æ°æ®åºæ°æ® |
| | |
| | | /// <summary> |
| | | /// åé
åºåå¤çè´§ä½æ°æ® |
| | | /// </summary> |
| | | public (List<Dt_ProStockInfo>, List<Dt_ProOutOrderDetail>, List<Dt_OutProStockInfo>, List<Dt_LocationInfo>) AssignProStockOut(int warehouseId, Dt_ProOutOrder proOutOrder) |
| | | public (List<Dt_ProStockInfo>, List<Dt_ProOutOrderDetail>, List<Dt_OutProStockInfo>, List<Dt_LocationInfo>) AssignProStockOut(List<Dt_ProOutOrderDetail> proOutOrderDetails) |
| | | { |
| | | List<Dt_ProOutOrderDetail> OutOrderDetails = proOutOrder.Details; |
| | | if (!OutOrderDetails.Any()) |
| | | { |
| | | throw new Exception($"æªæ¾å°åºåºåæç»ä¿¡æ¯"); |
| | | } |
| | | List<Dt_ProStockInfo> outStocks = new List<Dt_ProStockInfo>(); |
| | | List<Dt_OutProStockInfo> outProStockInfos = new List<Dt_OutProStockInfo>(); |
| | | List<Dt_LocationInfo> locationInfos = new List<Dt_LocationInfo>(); |
| | | List<Dt_ProOutOrderDetail> groupDetails = OutOrderDetails.GroupBy(x => new { x.SaleOrder, x.PCode, x.PVer, x.PLot, x.DateCode }).Select(x => new Dt_ProOutOrderDetail() |
| | | //è·åæå订å |
| | | Dt_ProOutOrder proOutOrder = _proOutOrderRepository.QueryFirst(x=>x.Id==proOutOrderDetails.FirstOrDefault().ProOrderId); |
| | | if (proOutOrder==null) |
| | | { |
| | | throw new Exception("æªæ¾å°æå订å"); |
| | | } |
| | | List<Dt_ProOutOrderDetail> groupDetails = proOutOrderDetails.GroupBy(x => new { x.SaleOrder, x.PCode, x.PVer, x.PLot, x.DateCode }).Select(x => new Dt_ProOutOrderDetail() |
| | | { |
| | | QtyPcs = x.Sum(x => x.QtyPcs) - x.Sum(x => x.OverQtyPcs), |
| | | SaleOrder = x.Key.SaleOrder, |
| | |
| | | { |
| | | float needQty = item.QtyPcs; |
| | | //æ¥æ¾å¯ç¨åºå |
| | | List<Dt_ProStockInfo> stockInfoss = _stockInfoService.ProStockInfoService.GetUseableStocks(warehouseId, item); |
| | | List<Dt_ProStockInfo> stockInfoss = _stockInfoService.ProStockInfoService.GetUseableStocks(proOutOrder.WarehouseId, item); |
| | | if (!stockInfoss.Any()) |
| | | { |
| | | throw new Exception("æªæ¾å°å¯åé
åºå"); |
| | |
| | | float assignQuantity = needQty - residueQuantity; |
| | | bool isCanLot = !string.IsNullOrEmpty(item.PLot); |
| | | bool isCanDate = !string.IsNullOrEmpty(item.DateCode); |
| | | List<Dt_ProOutOrderDetail> details = OutOrderDetails |
| | | List<Dt_ProOutOrderDetail> details = proOutOrderDetails |
| | | .Where(x => x.SaleOrder == item.SaleOrder && x.PCode == item.PCode && x.PVer == item.PVer |
| | | && (isCanLot ? x.PLot == item.PLot : true) |
| | | && (isCanDate ? x.DateCode == item.DateCode : true)) |
| | |
| | | locationInfos.AddRange(_basicService.LocationInfoService.Repository.GetLocationInfos(locationArr)); |
| | | |
| | | } |
| | | return (outStocks, OutOrderDetails, outProStockInfos, locationInfos); |
| | | return (outStocks, proOutOrderDetails, outProStockInfos, locationInfos); |
| | | } |
| | | } |
| | | } |