| | |
| | | |
| | | //计ç®åºä½å©ç¨ç |
| | | var freeLocation = _locationInfoRepository.Db.Queryable<Dt_LocationInfo>().Where(x => x.LocationStatus == (int)LocationStatusEnum.Free).Count(); |
| | | var inStockLocation = _locationInfoRepository.Db.Queryable<Dt_LocationInfo>().Where(x => x.LocationStatus == (int)LocationStatusEnum.InStock || x.LocationStatus == (int)LocationStatusEnum.Pallet).Count(); |
| | | var inStockLocation = _locationInfoRepository.Db.Queryable<Dt_LocationInfo>().Where(x => x.LocationStatus != (int)LocationStatusEnum.Free).Count(); |
| | | int totalLocation = freeLocation + inStockLocation; |
| | | decimal locationUtilizationRate = totalLocation == 0 |
| | | ? 0 |
| | |
| | | // 4. è·åè¿7æ¥æ¯æ¥åºå
¥åºæç»ï¼æ ¸å¿ä¿®æ¹ï¼è°ç¨ä¸é¢çæ¹æ³ï¼ |
| | | var dailyInOutBoundList = Get7DaysDailyInOutBound(); |
| | | |
| | | var nearExpirationList = GetMaterialsNearExpiration(); |
| | | List<StockInfoDetailExtDTO> nearExpirationList = GetMaterialsNearExpiration(); |
| | | //è·åä½ä¸ç»è®¡ |
| | | var completeTask = SimpleStatistics(); |
| | | //ä»»å¡ |
| | |
| | | |
| | | public List<SimpleStatisticsDTO> CompleteTask { get; set; } |
| | | |
| | | public NearExpirationDTO NearExpirationList { get; set; } |
| | | public List<StockInfoDetailExtDTO> NearExpirationList { get; set; } |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | public int Count { get; set; } |
| | | } |
| | | |
| | | public class NearExpirationDTO |
| | | |
| | | public class StockInfoDetailExtDTO : Dt_StockInfoDetail |
| | | { |
| | | public int DaysToExpiration { get; set; } |
| | | |
| | | public List<Dt_StockInfoDetail> Details { get; set; } |
| | | |
| | | public string LocationCode { get; set; } |
| | | |
| | | public string PalletCode { get; set; } |
| | | public int DaysToExpiration { get; set; } |
| | | } |
| | | |
| | | ///<summary> |
| | | ///è·åè¿30天è¦è¿æçç©æ |
| | | /// </summary> |
| | | public NearExpirationDTO GetMaterialsNearExpiration() |
| | | public List<StockInfoDetailExtDTO> GetMaterialsNearExpiration() |
| | | { |
| | | // åå§åè¿åDTO |
| | | var resultDTO = new NearExpirationDTO |
| | | { |
| | | Details = new List<Dt_StockInfoDetail>(), |
| | | LocationCode = string.Empty, |
| | | PalletCode = string.Empty, |
| | | DaysToExpiration = 0 // åå§åå¤©æ° |
| | | }; |
| | | List<StockInfoDetailExtDTO> resultDTO = new List<StockInfoDetailExtDTO>(); |
| | | |
| | | DateTime currentTime = DateTime.Now; |
| | | DateTime thirtyDaysLater = currentTime.AddDays(30); |
| | | |
| | | // çé30天å
è¿æçåºåæç» |
| | | var nearExpirationList = _stockInfoDetailRepository.Db.Queryable<Dt_StockInfoDetail>() |
| | | .Where(x => (x.ValidDate.Value - x.CreateDate).TotalDays <= 30) |
| | | var nearExpirationList = _stockInfoDetailRepository.QueryData() |
| | | .Join( |
| | | _stockInfoRepository.QueryData(), |
| | | detail => detail.StockId, |
| | | stock => stock.Id, |
| | | (detail, stock) => new |
| | | { |
| | | Detail = detail, |
| | | LocationCode = stock.LocationCode, |
| | | PalletCode = stock.PalletCode |
| | | } |
| | | ) |
| | | .Where(x => x.Detail.ValidDate.HasValue |
| | | && (x.Detail.ValidDate.Value - x.Detail.CreateDate).TotalDays <= 30) |
| | | .ToList(); |
| | | |
| | | // æ ç¬¦åæ¡ä»¶çæç»ï¼ç´æ¥è¿å |
| | | |
| | | if (!nearExpirationList.Any()) |
| | | { |
| | | return resultDTO; |
| | | } |
| | | |
| | | |
| | | var firstStockId = nearExpirationList.First().StockId; |
| | | |
| | | var stock = _stockInfoRepository.Db.Queryable<Dt_StockInfo>() |
| | | .First(x => x.Id == firstStockId); |
| | | |
| | | |
| | | if (stock == null) |
| | | foreach (var item in nearExpirationList) |
| | | { |
| | | return resultDTO; |
| | | } |
| | | int daysToExpire = item.Detail.ValidDate.HasValue |
| | | ? Math.Max(0, (item.Detail.ValidDate.Value - item.Detail.CreateDate).Days) |
| | | : 0; |
| | | |
| | | |
| | | resultDTO.LocationCode = stock.LocationCode; |
| | | resultDTO.PalletCode = stock.PalletCode; |
| | | |
| | | |
| | | int minDaysToExpiration = int.MaxValue; |
| | | foreach (var detail in nearExpirationList) |
| | | { |
| | | |
| | | TimeSpan totalDaysToExpiration = detail.ValidDate.Value - detail.CreateDate; |
| | | double remainingDays = totalDaysToExpiration.TotalDays; |
| | | int daysToExpiration = (int)Math.Ceiling(Math.Max(0, remainingDays)); |
| | | var extDetail = new StockInfoDetailExtDTO |
| | | { |
| | | MaterielCode = item.Detail.MaterielCode, |
| | | MaterielName = item.Detail.MaterielName, |
| | | BatchNo = item.Detail.BatchNo, |
| | | SupplyCode = item.Detail.SupplyCode, |
| | | StockQuantity = item.Detail.StockQuantity, |
| | | CreateDate = item.Detail.CreateDate, |
| | | ValidDate = item.Detail.ValidDate, |
| | | LocationCode = item.LocationCode, |
| | | PalletCode = item.PalletCode, |
| | | Barcode = item.Detail.Barcode, |
| | | DaysToExpiration = daysToExpire |
| | | }; |
| | | |
| | | |
| | | if (daysToExpiration < minDaysToExpiration) |
| | | { |
| | | minDaysToExpiration = daysToExpiration; |
| | | } |
| | | |
| | | |
| | | resultDTO.Details.Add(detail); |
| | | resultDTO.Add(extDetail); |
| | | } |
| | | |
| | | |
| | | resultDTO.DaysToExpiration = minDaysToExpiration; |
| | | resultDTO = resultDTO.OrderBy(d => d.DaysToExpiration).ToList(); |
| | | |
| | | return resultDTO; |
| | | } |