1
heshaofeng
2025-12-29 93c9b23160dae882b982c97db941fc3bf8d38c25
ÏîÄ¿´úÂë/WMSÎÞ²Ö´¢°æ/WIDESEA_WMSServer/BigGreenService/BigGreenService.cs
@@ -5,8 +5,10 @@
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;
@@ -20,9 +22,11 @@
        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;
@@ -30,6 +34,8 @@
            _outBoundOrderDetailRepository = outBoundOrderDetailRepository;
            _inboundOrderDetailRepository = inboundOrderDetailRepository;
            _taskRepository = taskRepository;
            _taskHtyRepository = taskHtyRepository;
            _stockInfoRepository = stockInfoRepository;
        }
        public WebResponseContent GetBigGreenData()
        {
@@ -46,12 +52,20 @@
            //计算库位利用率
            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();
@@ -64,7 +78,11 @@
                UnOutBoundOrderCount = unOutBound,
                LocationUtilizationRate = locationUtilizationRate,
                DailyInOutBoundList = dailyInOutBoundList,
                TaskList = tasks
                TaskList = tasks,
                InboundCount = inboundCount,
                OutboundCount = outboundCount,
                InStockPallet = inStockPallet,
                FreeStockPallet = freeStockPallet
            };
            return WebResponseContent.Instance.OK(data: bigGreenData);
        }
@@ -125,11 +143,21 @@
            return dailyInOutBoundList;
        }
        /// <summary>
        /// å¤§å±/汇总数据返回DTO(大绿数据汇总)
        /// </summary>
        public class BigGreenDataDto
        {
            /// <summary>
            /// å…¥åº“完成数量
            /// </summary>
            public int InboundCount { get; set; }
            /// <summary>
            /// å‡ºåº“完成数量
            /// </summary>
            public int OutboundCount { get; set; }
            /// <summary>
            /// æ€»åº“存数量
            /// </summary>
@@ -166,9 +194,18 @@
            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; }
        }
        /// <summary>
@@ -192,5 +229,7 @@
            public decimal DailyInboundQuantity { get; set; }
        }
    }
}