| | |
| | | private readonly IRepository<SysDictData, MasterDbContextLocator> _sysDictDataRep; |
| | | private readonly ISysExcelTemplateService _sysExcelTemplateService; |
| | | private readonly static object _lock = new(); |
| | | |
| | | private readonly IRepository<WmsArea, MasterDbContextLocator> _wmsAreaRep; |
| | | public WmsPlaceService( |
| | | IRepository<WmsPlace,MasterDbContextLocator> wmsPlaceRep |
| | | ,IRepository<SysDictType, MasterDbContextLocator> sysDictTypeRep |
| | | ,IRepository<SysDictData, MasterDbContextLocator> sysDictDataRep |
| | | ,ISysExcelTemplateService sysExcelTemplateService |
| | | , IRepository<WmsArea, MasterDbContextLocator> wmsAreaRep |
| | | ) |
| | | { |
| | | _wmsPlaceRep = wmsPlaceRep; |
| | | _sysDictTypeRep = sysDictTypeRep; |
| | | _sysDictDataRep = sysDictDataRep; |
| | | _sysExcelTemplateService = sysExcelTemplateService; |
| | | _wmsAreaRep = wmsAreaRep; |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | public async Task Add(AddWmsPlaceInput input) |
| | | { |
| | | var wmsPlace = input.Adapt<WmsPlace>(); |
| | | wmsPlace.PlaceCode =await SerialUtil.GetSerial(EnumSerialType.库位编号); |
| | | |
| | | var area = (await _wmsAreaRep.DetachedEntities.FirstOrDefaultAsync(u => u.Id == input.AreaId&&u.IsDeleted==false)).Adapt<WmsAreaOutput>(); |
| | | if (area == null) |
| | | { |
| | | throw Oops.Oh($"库区不存在"); |
| | | } |
| | | if (area.IsDisabled==true) |
| | | { |
| | | throw Oops.Oh($"库区已禁用"); |
| | | } |
| | | wmsPlace.AreaName= area.AreaName; |
| | | wmsPlace.AreaCode= area.AreaCode; |
| | | wmsPlace.PlaceTypeName = wmsPlace.PlaceType.ToString(); |
| | | //验证 |
| | | await CheckExisit(wmsPlace); |
| | | |
| | |
| | | if (!isExist) throw Oops.Oh(ErrorCode.D1002); |
| | | |
| | | var wmsPlace = input.Adapt<WmsPlace>(); |
| | | |
| | | var area = (await _wmsAreaRep.DetachedEntities.FirstOrDefaultAsync(u => u.Id == input.AreaId && u.IsDeleted == false)).Adapt<WmsAreaOutput>(); |
| | | if (area == null) |
| | | { |
| | | throw Oops.Oh($"库区不存在"); |
| | | } |
| | | if (area.IsDisabled == true) |
| | | { |
| | | throw Oops.Oh($"库区已禁用"); |
| | | } |
| | | wmsPlace.AreaName = area.AreaName; |
| | | wmsPlace.AreaCode = area.AreaCode; |
| | | wmsPlace.PlaceTypeName = wmsPlace.PlaceType.ToString(); |
| | | //验证 |
| | | await CheckExisit(wmsPlace,true); |
| | | |