| | |
| | | using System.Linq; |
| | | using System.Text; |
| | | using System.Threading.Tasks; |
| | | using WIDESEA_Common.CommonEnum; |
| | | using WIDESEA_Common.LocationEnum; |
| | | using WIDESEA_Common.OrderEnum; |
| | | using WIDESEA_Common.TaskEnum; |
| | | using WIDESEA_Core; |
| | | using WIDESEA_Core.BaseRepository; |
| | | using WIDESEA_Model.Models; |
| | |
| | | private readonly IRepository<Dt_LocationInfo> _locationInfoRepository; |
| | | private readonly IRepository<Dt_OutboundOrderDetail> _outBoundOrderDetailRepository; |
| | | private readonly IRepository<Dt_InboundOrderDetail> _inboundOrderDetailRepository; |
| | | private readonly IRepository<Dt_Task_Hty> _taskHtyRepository; |
| | | private readonly IRepository<Dt_Task> _taskRepository; |
| | | private readonly IRepository<Dt_StockInfo> _stockInfoRepository; |
| | | |
| | | public BigGreenService(IRepository<Dt_StockInfoDetail> stockInfoDetailRepository, IRepository<Dt_OutboundOrder> outBoundOrderRepository, IRepository<Dt_LocationInfo> locationInfoRepository,IRepository<Dt_OutboundOrderDetail> outBoundOrderDetailRepository, IRepository<Dt_InboundOrderDetail> inboundOrderDetailRepository,IRepository<Dt_Task> taskRepository) |
| | | public BigGreenService(IRepository<Dt_StockInfoDetail> stockInfoDetailRepository, IRepository<Dt_OutboundOrder> outBoundOrderRepository, IRepository<Dt_LocationInfo> locationInfoRepository,IRepository<Dt_OutboundOrderDetail> outBoundOrderDetailRepository, IRepository<Dt_InboundOrderDetail> inboundOrderDetailRepository,IRepository<Dt_Task> taskRepository,IRepository<Dt_Task_Hty> taskHtyRepository, IRepository<Dt_StockInfo> stockInfoRepository) |
| | | { |
| | | _stockInfoDetailRepository = stockInfoDetailRepository; |
| | | _outBoundOrderRepository = outBoundOrderRepository; |
| | |
| | | _outBoundOrderDetailRepository = outBoundOrderDetailRepository; |
| | | _inboundOrderDetailRepository = inboundOrderDetailRepository; |
| | | _taskRepository = taskRepository; |
| | | _taskHtyRepository = taskHtyRepository; |
| | | _stockInfoRepository = stockInfoRepository; |
| | | } |
| | | public WebResponseContent GetBigGreenData() |
| | | { |
| | |
| | | |
| | | //计ç®åºä½å©ç¨ç |
| | | 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).Count(); |
| | | var inStockLocation =_locationInfoRepository.Db.Queryable<Dt_LocationInfo>().Where(x => x.LocationStatus == (int)LocationStatusEnum.InStock || x.LocationStatus == (int)LocationStatusEnum.Pallet).Count(); |
| | | int totalLocation = freeLocation + inStockLocation; |
| | | decimal locationUtilizationRate = totalLocation == 0 |
| | | ? 0 |
| | | : Math.Round((decimal)inStockLocation / totalLocation, 4); |
| | | : Math.Round((decimal)inStockLocation / totalLocation, 4)*100; |
| | | |
| | | //计ç®å
¥åºä»»å¡ååºåºä»»å¡å®ææ°é |
| | | var inboundCount =_taskHtyRepository.Db.Queryable<Dt_Task_Hty>().Where(x => x.TaskType >= 500 && x.TaskType < 900).Count(); |
| | | var outboundCount =_taskHtyRepository.Db.Queryable<Dt_Task_Hty>().Where(x => x.TaskType >= 100 && x.TaskType < 500).Count(); |
| | | |
| | | //è®¡ç®æè´§æç®±æ°é |
| | | var inStockPallet = _stockInfoRepository.Db.Queryable<Dt_StockInfo>().Where(x => x.PalletType ==(int) PalletTypeEnum.None).Count(); |
| | | //计ç®ç©ºç®±æ°é |
| | | var freeStockPallet = _stockInfoRepository.Db.Queryable<Dt_StockInfo>().Where(x => x.PalletType == (int)PalletTypeEnum.Empty).Count(); |
| | | // 4. è·åè¿7æ¥æ¯æ¥åºå
¥åºæç»ï¼æ ¸å¿ä¿®æ¹ï¼è°ç¨ä¸é¢çæ¹æ³ï¼ |
| | | var dailyInOutBoundList = Get7DaysDailyInOutBound(); |
| | | |
| | | //è·åä½ä¸ç»è®¡ |
| | | var completeTask = SimpleStatistics(); |
| | | //ä»»å¡ |
| | | List<Dt_Task> tasks = _taskRepository.QueryData(); |
| | | |
| | |
| | | UnOutBoundOrderCount = unOutBound, |
| | | LocationUtilizationRate = locationUtilizationRate, |
| | | DailyInOutBoundList = dailyInOutBoundList, |
| | | TaskList = tasks |
| | | TaskList = tasks, |
| | | InboundCount = inboundCount, |
| | | OutboundCount = outboundCount, |
| | | InStockPallet = inStockPallet, |
| | | FreeStockPallet = freeStockPallet, |
| | | CompleteTask = completeTask |
| | | }; |
| | | return WebResponseContent.Instance.OK(data: bigGreenData); |
| | | } |
| | |
| | | .Queryable<Dt_OutboundOrderDetail>() |
| | | .Where(x => x.CreateDate >= startDate |
| | | && x.CreateDate < endDate.AddDays(1)) |
| | | .GroupBy(x => x.CreateDate) // ææ¥ææ ¼å¼ååç» |
| | | |
| | | .Select(x => new |
| | | { |
| | | Date = x.CreateDate.ToString( "MM-dd"), |
| | | DailyOutbound = SqlFunc.AggregateSum((decimal?)x.OverOutQuantity) ?? 0 |
| | | Date = x.CreateDate.ToString("MM-dd"), |
| | | x.OverOutQuantity |
| | | }) |
| | | .ToList() |
| | | .ToDictionary(k => k.Date, v => v.DailyOutbound); // 转为åå
¸æ¹ä¾¿å¹é
|
| | | .GroupBy(x => x.Date) |
| | | .ToDictionary(k => k.Key , g => g.Sum(x => (decimal?)x.OverOutQuantity) ?? 0); // 转为åå
¸æ¹ä¾¿å¹é
|
| | | |
| | | // 3. æ¥è¯¢æ¯æ¥å
¥åºæç»ï¼ææ¥æåç»ï¼ |
| | | var dailyInboundList = _inboundOrderDetailRepository.Db |
| | |
| | | .Where(x => x.CreateDate != null // è¿æ»¤ç©ºæ¥æ |
| | | && x.CreateDate >= startDate |
| | | && x.CreateDate < endDate.AddDays(1)) |
| | | .GroupBy(x => x.CreateDate).Distinct() // ææ¥ææ ¼å¼ååç» |
| | | .Select(x => new |
| | | { |
| | | Date = x.CreateDate.ToString("MM-dd"), |
| | | DailyInbound = SqlFunc.AggregateSum((decimal?)x.OverInQuantity) ?? 0 |
| | | x.OverInQuantity |
| | | }) |
| | | .ToList() |
| | | .ToDictionary(k => k.Date, v => v.DailyInbound); // 转为åå
¸æ¹ä¾¿å¹é
|
| | | .GroupBy(x=>x.Date) |
| | | .ToDictionary(k => k.Key, g => g.Sum(x => (decimal?)x.OverInQuantity) ?? 0); // 转为åå
¸æ¹ä¾¿å¹é
|
| | | |
| | | // 4. åå¹¶æ¯æ¥æ°æ®ï¼ç¡®ä¿7å¤©æ¥æå®æ´ï¼æ æ°æ®è¡¥0ï¼ |
| | | var dailyInOutBoundList = all7Days.Select(date => new DailyInOutBoundDto |
| | |
| | | return dailyInOutBoundList; |
| | | } |
| | | |
| | | public List<SimpleStatisticsDTO> SimpleStatistics() |
| | | { |
| | | DateTime sevenDaysAgo = DateTime.Now.AddDays(-7); |
| | | |
| | | var stats = _taskHtyRepository |
| | | .QueryData(x => x.TaskStatus == (int)TaskStatusEnum.Finish && x.CreateDate >= sevenDaysAgo) |
| | | .GroupBy(t => |
| | | (int)t.TaskType >= 100 && (int)t.TaskType <= 299 ? "åºåº" : |
| | | (int)t.TaskType >= 500 && (int)t.TaskType <= 699 ? "å
¥åº" : "å
¶ä»" |
| | | ) |
| | | .Where(g => g.Key == "åºåº" || g.Key == "å
¥åº") |
| | | .Select(g => new SimpleStatisticsDTO |
| | | { |
| | | TaskType = g.Key, |
| | | Count = g.Count() |
| | | }) |
| | | .ToList(); |
| | | |
| | | return stats; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 大å±/æ±æ»æ°æ®è¿åDTOï¼å¤§ç»¿æ°æ®æ±æ»ï¼ |
| | | /// </summary> |
| | | public class BigGreenDataDto |
| | | { |
| | | /// <summary> |
| | | /// å
¥åºå®ææ°é |
| | | /// </summary> |
| | | public int InboundCount { get; set; } |
| | | /// <summary> |
| | | /// åºåºå®ææ°é |
| | | /// </summary> |
| | | public int OutboundCount { get; set; } |
| | | /// <summary> |
| | | /// æ»åºåæ°é |
| | | /// </summary> |
| | |
| | | public decimal NetStock7Days { get; set; } |
| | | |
| | | /// <summary> |
| | | /// è¿7æ¥åå
¥åºéï¼å
¥åº-åºåºï¼ |
| | | /// </summary> |
| | | public decimal TotalStockChangeRate { get; set; } |
| | | |
| | | /// <summary> |
| | | /// ä»»å¡å表 |
| | | /// </summary> |
| | | public List<Dt_Task> TaskList { get; set; } = new List<Dt_Task>(); |
| | | |
| | | public int InStockPallet { get; set; } |
| | | |
| | | public int FreeStockPallet { get; set; } |
| | | |
| | | public List<SimpleStatisticsDTO> CompleteTask { get; set; } |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | public decimal DailyInboundQuantity { get; set; } |
| | | |
| | | } |
| | | |
| | | public class SimpleStatisticsDTO |
| | | { |
| | | public string TaskType { get; set; } |
| | | public int Count { get; set; } |
| | | } |
| | | |
| | | |
| | | } |
| | | } |