| | |
| | | using System.Linq; |
| | | using System.Text; |
| | | using System.Threading.Tasks; |
| | | using WIDESEA_Common.CommonEnum; |
| | | using WIDESEA_Common.StockEnum; |
| | | using WIDESEA_Core.BaseRepository; |
| | | using WIDESEA_Core.Helper; |
| | | using WIDESEA_IBasicRepository; |
| | | using WIDESEA_IStockRepository; |
| | | using WIDESEA_Model.Models; |
| | | |
| | |
| | | { |
| | | public class ProStockInfoRepository : RepositoryBase<Dt_ProStockInfo>, IProStockInfoRepository |
| | | { |
| | | public ProStockInfoRepository(IUnitOfWorkManage unitOfWorkManage) : base(unitOfWorkManage) |
| | | private readonly IBasicRepository _basicRepository; |
| | | public ProStockInfoRepository(IUnitOfWorkManage unitOfWorkManage,IBasicRepository basicRepository) : base(unitOfWorkManage) |
| | | { |
| | | _basicRepository = basicRepository; |
| | | } |
| | | //æ ¹æ®æç»æ°æ®æ¥æ¾å¯ç¨åºååºå |
| | | public List<Dt_ProStockInfo> GetProStocks(Dt_ProOutOrderDetail proOutOrderDetail,List<string> locationInfos) |
| | |
| | | bool isCanLot= string.IsNullOrEmpty(proOutOrderDetail.PLot); |
| | | bool isCanDate = string.IsNullOrEmpty(proOutOrderDetail.DateCode); |
| | | bool isCanVer = string.IsNullOrEmpty(proOutOrderDetail.OutSpecifyVer); |
| | | proStockInfos = Db.Queryable<Dt_ProStockInfo>().Where(x => locationInfos.Contains(x.LocationCode) && x.ProStockAttribute == ProStockAttributeEnum.æå.ObjToInt()) |
| | | ////夿客æ·åºå
¥è§å |
| | | //Dt_CustomerInfo customerInfo = _basicRepository.CustomerInfoRepository.QueryFirst(x=>x.Code== proOutOrderDetail.Customer); |
| | | //if (customerInfo==null) |
| | | //{ |
| | | // throw new Exception("æªæ¾å°å®¢æ·ä¿¡æ¯"); |
| | | //} |
| | | //if (customerInfo.OutRule==CustomerOutRuleEnum.SaleOrderRule.ObjToInt()) |
| | | //{ |
| | | // proStockInfos = Db.Queryable<Dt_ProStockInfo>().Where(x => locationInfos.Contains(x.LocationCode) && x.ProStockAttribute == ProStockAttributeEnum.æå.ObjToInt()) |
| | | // .Includes(x => x.proStockInfoDetails) |
| | | // .Where(x => x.proStockInfoDetails |
| | | // .Any(v => |
| | | // v.SaleOrder==proOutOrderDetail.SaleOrder |
| | | // && v.ProductCode == proOutOrderDetail.PCode |
| | | // && v.ProductVersion == proOutOrderDetail.PVer |
| | | // && (isCanLot ? isCanLot : v.BagNo == proOutOrderDetail.PLot) |
| | | // && (isCanDate ? isCanDate : v.DateCode == proOutOrderDetail.DateCode) |
| | | // )) |
| | | // .ToList(); |
| | | //} |
| | | //else |
| | | //{ |
| | | proStockInfos = Db.Queryable<Dt_ProStockInfo>().Where(x => locationInfos.Contains(x.LocationCode) && x.ProStockAttribute == ProStockAttributeEnum.æå.ObjToInt()) |
| | | .Includes(x => x.proStockInfoDetails) |
| | | .Where(x => x.proStockInfoDetails |
| | | .Any(v => v.SaleOrder == proOutOrderDetail.SaleOrder |
| | | && v.ProductCode == proOutOrderDetail.PCode |
| | | && v.ProductVersion == proOutOrderDetail.PVer |
| | | && (isCanLot ? isCanLot : v.LotNumber == proOutOrderDetail.PLot) |
| | | && (isCanDate ? isCanDate : v.DateCode == proOutOrderDetail.DateCode) |
| | | .Any(v => |
| | | v.ProductCode == proOutOrderDetail.PCode |
| | | && v.ProductVersion == proOutOrderDetail.PVer |
| | | && (isCanLot ? isCanLot : v.BagNo == proOutOrderDetail.PLot) |
| | | && (isCanDate ? isCanDate : v.DateCode == proOutOrderDetail.DateCode) |
| | | )) |
| | | .ToList(); |
| | | |
| | | proStockInfos = proStockInfos.OrderBy(x => x.proStockInfoDetails.FirstOrDefault()?.DateCode).ThenBy(x=>x.proStockInfoDetails.Sum(x=>x.StockPcsQty)).ToList(); |
| | | .ToList(); |
| | | //} |
| | | proStockInfos = proStockInfos?.OrderBy(x => x.proStockInfoDetails.FirstOrDefault()?.DateCode).ThenBy(x=>x.CreateDate).ThenBy(x=>x.proStockInfoDetails.Sum(x=>x.StockPcsQty)).ToList(); |
| | | return proStockInfos; |
| | | } |
| | | /// <summary> |