using Microsoft.IdentityModel.Tokens; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using WIDESEA_Core.BaseRepository; using WIDESEA_Core.Helper; using WIDESEA_IStockRepository; using WIDESEA_Model.Models; namespace WIDESEA_StockRepository { public class ProStockInfoRepository : RepositoryBase, IProStockInfoRepository { public ProStockInfoRepository(IUnitOfWorkManage unitOfWorkManage) : base(unitOfWorkManage) { } //根据明细数据查找可用库存库存 public List GetProStocks(Dt_ProOutOrderDetail proOutOrderDetail,List locationInfos) { List? proStockInfos = null; bool isCanLot= !string.IsNullOrEmpty(proOutOrderDetail.PLot); bool isCanDate = !string.IsNullOrEmpty(proOutOrderDetail.DateCode); proStockInfos = Db.Queryable().Where(x => locationInfos.Contains(x.LocationCode)) .Includes(x => x.proStockInfoDetails) .Where(x => x.proStockInfoDetails .Any(x => x.SaleOrder == proOutOrderDetail.SaleOrder && x.ProductCode == proOutOrderDetail.PCode && x.ProductVersion == proOutOrderDetail.PVer && (isCanLot ? x.LotNumber == proOutOrderDetail.PLot : true) && (isCanDate ? x.DateCode == proOutOrderDetail.DateCode : true) )) .ToList(); proStockInfos = proStockInfos.OrderBy(x => x.proStockInfoDetails.FirstOrDefault().DateCode).ToList(); return proStockInfos; } } }