1
hutongqing
2024-09-23 d1a2afa67032339c2eb1019a02c6b6d036c0bdb1
代码管理/WMS/WIDESEA_WMSServer/WIDESEA_StockService/StockInfoService.cs
@@ -23,22 +23,19 @@
    public class StockInfoService : ServiceBase<Dt_StockInfo, IStockInfoRepository>, IStockInfoService
    {
        private readonly IMapper _mapper;
        private readonly IStockQuantityChangeRecordService _stockQuantityChangeRecordService;
        private readonly IStockInfoDetailRepository _stockInfoDetailRepository;
        private readonly IWarehouseRepository _warehouseRepository;
        private readonly IRoadwayInfoRepository _roadwayInfoRepository;
        private readonly IAreaInfoRepository _areaInfoRepository;
        private readonly ILocationInfoRepository _locationInfoRepository;
        public StockInfoService(IStockInfoRepository BaseDal, IMapper mapper, IStockQuantityChangeRecordService stockQuantityChangeRecordService, IStockInfoDetailRepository stockInfoDetailRepository, IWarehouseRepository warehouseRepository, IRoadwayInfoRepository roadwayInfoRepository, IAreaInfoRepository areaInfoRepository, ILocationInfoRepository locationInfoRepository) : base(BaseDal)
        private readonly IBasicRepository _basicRepository;
        private readonly IStockRepository _stockRepository;
        private readonly IRecordService _recordService;
        public IStockInfoRepository Repository => BaseDal;
        public StockInfoService(IStockInfoRepository BaseDal, IMapper mapper, IBasicRepository basicRepository, IStockRepository stockRepository,IRecordService recordService) : base(BaseDal)
        {
            _mapper = mapper;
            _stockQuantityChangeRecordService = stockQuantityChangeRecordService;
            _stockInfoDetailRepository = stockInfoDetailRepository;
            _warehouseRepository = warehouseRepository;
            _roadwayInfoRepository = roadwayInfoRepository;
            _areaInfoRepository = areaInfoRepository;
            _locationInfoRepository = locationInfoRepository;
            _basicRepository = basicRepository;
            _stockRepository = stockRepository;
            _recordService = recordService;
        }
        public Dt_StockInfo? GetStockByPalletCode(string palletCode)
@@ -46,7 +43,7 @@
            Dt_StockInfo stockInfo = BaseDal.QueryFirst(x => x.PalletCode == palletCode);
            if (stockInfo != null)
            {
                stockInfo.Details = _stockInfoDetailRepository.QueryData(x => x.StockId == stockInfo.Id);
                stockInfo.Details = _stockRepository.StockInfoDetailRepository.QueryData(x => x.StockId == stockInfo.Id);
            }
            return stockInfo;
        }
@@ -76,7 +73,7 @@
                {
                    if (stockInfo.Details[i].Id == 0)
                    {
                        details.Add(_stockInfoDetailRepository.Db.Insertable(stockInfo.Details[i]).ExecuteReturnEntity());
                        details.Add(_stockRepository.StockInfoDetailRepository.Db.Insertable(stockInfo.Details[i]).ExecuteReturnEntity());
                    }
                }
@@ -95,31 +92,31 @@
            }
            //_stockQuantityChangeRecordRepository.AddData(stockQuantityChangeRecords);
            stockInfo.Details = details;
            _stockQuantityChangeRecordService.AddStockChangeRecord(stockInfo, stockInfo.Details, beforeQuantity, stockInfo.Details.Sum(x => x.StockQuantity) + beforeQuantity, StockChangeType.MaterielGroup);
            _recordService.StockQuantityChangeRecordService.AddStockChangeRecord(stockInfo, stockInfo.Details, beforeQuantity, stockInfo.Details.Sum(x => x.StockQuantity) + beforeQuantity, StockChangeType.MaterielGroup);
        }
        public List<Dt_StockInfo> GetUseableStocks(string materielCode)
        {
            List<string> roadways = _roadwayInfoRepository.CanOutRoadwayNos;
            List<string> roadways = _basicRepository.RoadwayInfoRepository.CanOutRoadwayNos;
            List<int> warehouseIds = _warehouseRepository.EnableWarehouseIds;
            List<int> warehouseIds = _basicRepository.WarehouseRepository.EnableWarehouseIds;
            List<int> areaIds = _areaInfoRepository.GetEnableAreaIds(warehouseIds);
            List<int> areaIds = _basicRepository.AreaInfoRepository.GetEnableAreaIds(warehouseIds);
            List<string> locationCodes = _locationInfoRepository.GetCanOutLocationCodes(roadways, areaIds);
            List<string> locationCodes = _basicRepository.LocationInfoRepository.GetCanOutLocationCodes(roadways, areaIds);
            return BaseDal.GetStockInfos(materielCode, locationCodes);
        }
        public List<StockSelectViewDTO> GetStockSelectViews(string materielCode)
        {
            List<string> roadways = _roadwayInfoRepository.CanOutRoadwayNos;
            List<string> roadways = _basicRepository.RoadwayInfoRepository.CanOutRoadwayNos;
            List<int> warehouseIds = _warehouseRepository.EnableWarehouseIds;
            List<int> warehouseIds = _basicRepository.WarehouseRepository.EnableWarehouseIds;
            List<int> areaIds = _areaInfoRepository.GetEnableAreaIds(warehouseIds);
            List<int> areaIds = _basicRepository.AreaInfoRepository.GetEnableAreaIds(warehouseIds);
            List<string> locationCodes = _locationInfoRepository.GetCanOutLocationCodes(roadways, areaIds);
            List<string> locationCodes = _basicRepository.LocationInfoRepository.GetCanOutLocationCodes(roadways, areaIds);
            return BaseDal.QueryTabs<Dt_StockInfo, Dt_StockInfoDetail, StockSelectViewDTO>((a, b) => a.Id == b.StockId, (a, b) => new StockSelectViewDTO
            {