heshaofeng
2025-12-01 bd5e0f950340b020cdf6fecf1977992e1c6e845f
ÏîÄ¿´úÂë/WMSÎÞ²Ö´¢°æ/WIDESEA_WMSServer/WIDESEA_StockService/StockInfoService.cs
@@ -1,4 +1,5 @@
using AutoMapper;
using Autofac.Core;
using AutoMapper;
using SqlSugar;
using WIDESEA_Common.LocationEnum;
using WIDESEA_Common.StockEnum;
@@ -22,16 +23,16 @@
        public IRepository<Dt_StockInfo> Repository => BaseDal;
        private readonly IRepository<Dt_StockInfoDetail> _stockInfoDetailRepository;
        private readonly IOutboundOrderService _outboundOrderService;
        private readonly IOutboundOrderDetailService _outboundOrderDetailService;
        //private readonly IOutboundOrderDetailService _outboundOrderDetailService;
        private readonly ILocationInfoService _locationInfoService;
        public StockInfoService(IRepository<Dt_StockInfo> BaseDal, IMapper mapper, IRepository<Dt_StockInfoDetail> stockInfoDetailRepository, IRecordService recordService, ILocationInfoService locationInfoService, IOutboundOrderService outboundOrderService, IOutboundOrderDetailService outboundOrderDetailService) : base(BaseDal)
        public StockInfoService(IRepository<Dt_StockInfo> BaseDal, IMapper mapper, IRepository<Dt_StockInfoDetail> stockInfoDetailRepository, IRecordService recordService, ILocationInfoService locationInfoService, IOutboundOrderService outboundOrderService) : base(BaseDal)
        {
            _mapper = mapper;
            _stockInfoDetailRepository = stockInfoDetailRepository;
            _recordService = recordService;
            _locationInfoService = locationInfoService;
            _outboundOrderService = outboundOrderService;
            _outboundOrderDetailService = outboundOrderDetailService;
            //_outboundOrderDetailService = outboundOrderDetailService;
        }
        /// <summary>
@@ -186,7 +187,7 @@
        public List<Dt_StockInfo> GetStockInfos(string materielCode, string lotNo, string supplyCode, List<string> locationCodes)
        {
            var query = Db.Queryable<Dt_StockInfo>()
             .Where(x => locationCodes.Contains(x.LocationCode)
             .Where(x => locationCodes.Contains(x.LocationCode) && x.StockStatus==StockStatusEmun.入库完成.ObjToInt()
             //  && x.StockStatus == (int)StockStatusEmun.正常)
             ).Includes(x => x.Details);
@@ -279,6 +280,11 @@
        //    }
        //}
        public List<StockSelectViewDTO> GetSelectViewDTOs(string orderNo,string materielCode)
        {
            var outboundOrder = SqlSugarHelper.DbWMS.Queryable<Dt_OutboundOrder>().Where(x => x.UpperOrderNo == orderNo).First();
            return GetStockSelectViews(outboundOrder.Id, materielCode);
        }
        public List<StockSelectViewDTO> GetStockSelectViews(int orderId, string materielCode)
        {
@@ -289,7 +295,7 @@
            }
            // èŽ·å–å‡ºåº“å•æ˜Žç»†ï¼Œç”¨äºŽç¡®å®šéœ€è¦çš„æ‰¹æ¬¡å’Œä¾›åº”å•†
            var orderDetails = _outboundOrderDetailService.Db.Queryable<Dt_OutboundOrderDetail>().Where(x => x.OrderId == orderId && x.MaterielCode == materielCode).ToList();
            var orderDetails = SqlSugarHelper.DbWMS.Queryable<Dt_OutboundOrderDetail>().Where(x => x.OrderId == orderId && x.MaterielCode == materielCode).ToList();
            if (!orderDetails.Any())
            {
@@ -311,9 +317,9 @@
                // æ‰§è¡ŒæŸ¥è¯¢å¹¶æŒ‰å…ˆè¿›å…ˆå‡ºæŽ’序
                var stocks = stockQuery.ToList()
                    .Where(x => x.Details.Any(d =>
                        d.MaterielCode == materielCode &&
                        d.BatchNo == orderDetail.BatchNo &&
                        d.SupplyCode == orderDetail.SupplyCode &&
                        d.MaterielCode == materielCode &&
                        string.IsNullOrEmpty(orderDetail.BatchNo)?true: d.BatchNo == orderDetail.BatchNo&&
                        string.IsNullOrEmpty(orderDetail.BatchNo)?true:d.SupplyCode == orderDetail.SupplyCode &&
                        d.StockQuantity > d.OutboundQuantity
                    ))
                    .OrderBy(x => x.CreateDate)
@@ -323,8 +329,8 @@
                {
                    var relevantDetails = stock.Details
                        .Where(d => d.MaterielCode == materielCode &&
                                   d.BatchNo == orderDetail.BatchNo &&
                                   d.SupplyCode == orderDetail.SupplyCode &&
                                   string.IsNullOrEmpty(orderDetail.BatchNo) ? true : d.BatchNo == orderDetail.BatchNo &&
                                   string.IsNullOrEmpty(orderDetail.BatchNo) ? true : d.SupplyCode == orderDetail.SupplyCode &&
                                   d.StockQuantity > d.OutboundQuantity)
                        .ToList();