heshaofeng
2025-12-29 266e4bf654c55ce2f7e9271048e4625f1b8b49f6
ÏîÄ¿´úÂë/WMSÎÞ²Ö´¢°æ/WIDESEA_WMSServer/WIDESEA_StockService/StockInfoService.cs
@@ -4,6 +4,7 @@
using SqlSugar;
using WIDESEA_Common.LocationEnum;
using WIDESEA_Common.StockEnum;
using WIDESEA_Core;
using WIDESEA_Core.BaseRepository;
using WIDESEA_Core.BaseServices;
using WIDESEA_Core.Helper;
@@ -20,7 +21,7 @@
    public partial class StockInfoService : ServiceBase<Dt_StockInfo, IRepository<Dt_StockInfo>>, IStockInfoService
    {
        private readonly IMapper _mapper;
        private readonly IUnitOfWorkManage _unitOfWorkManage;
        private readonly IRecordService _recordService;
        public IRepository<Dt_StockInfo> Repository => BaseDal;
        private readonly IRepository<Dt_StockInfoDetail> _stockInfoDetailRepository;
@@ -29,7 +30,7 @@
        private readonly IRepository<Dt_AllocateOrder> _allocateRepository;
        private readonly ILocationInfoService _locationInfoService;
        public StockInfoService(IRepository<Dt_StockInfo> BaseDal, IMapper mapper, IRepository<Dt_StockInfoDetail> stockInfoDetailRepository, IRecordService recordService, ILocationInfoService locationInfoService, IOutboundOrderService outboundOrderService, IRepository<Dt_AllocateOrder> allocateRepository) : base(BaseDal)
        public StockInfoService(IRepository<Dt_StockInfo> BaseDal, IUnitOfWorkManage unitOfWorkManage, IMapper mapper, IRepository<Dt_StockInfoDetail> stockInfoDetailRepository, IRecordService recordService, ILocationInfoService locationInfoService, IOutboundOrderService outboundOrderService, IRepository<Dt_AllocateOrder> allocateRepository) : base(BaseDal)
        {
            _mapper = mapper;
            _stockInfoDetailRepository = stockInfoDetailRepository;
@@ -37,6 +38,7 @@
            _locationInfoService = locationInfoService;
            _outboundOrderService = outboundOrderService;
            _allocateRepository = allocateRepository;
            _unitOfWorkManage = unitOfWorkManage;
            //_outboundOrderDetailService = outboundOrderDetailService;
        }
@@ -55,7 +57,34 @@
            return stockInfo;
        }
        public override WebResponseContent DeleteData(object[] keys)
        {
            try
            {
                List<int> stockIds = keys.Select(x => x.ObjToInt()).ToList();
                List<Dt_StockInfo> stockInfos = BaseDal.QueryData(x => stockIds.Contains(x.Id) && x.StockStatus == StockStatusEmun.入库完成.ObjToInt());
                List<string> locationCodes = stockInfos.Select(x => x.LocationCode).Distinct().ToList();
                List<Dt_LocationInfo> locationInfos = _locationInfoService.Repository.QueryData(x => locationCodes.Contains(x.LocationCode) && x.LocationStatus == LocationStatusEnum.Pallet.ObjToInt());
                stockInfos = stockInfos.Where(x => locationInfos.Select(l => l.LocationCode).Contains(x.LocationCode)).ToList();
                _unitOfWorkManage.BeginTran();
                _locationInfoService.UpdateLocationStatus(locationInfos, LocationStatusEnum.Free);
                BaseDal.DeleteAndMoveIntoHty(stockInfos, WIDESEA_Core.Enums.OperateTypeEnum.人工删除);
                _unitOfWorkManage.CommitTran();
                return WebResponseContent.Instance.OK("删除成功");
            }
            catch(Exception ex)
            {
                _unitOfWorkManage.RollbackTran();
                return WebResponseContent.Instance.Error("删除失败,"+ex.Message);
            }
        }
        public void AddMaterielGroup(Dt_StockInfo stockInfo)
        {
            decimal beforeQuantity = 0;