| | |
| | | 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> |
| | |
| | | .Where(!string.IsNullOrEmpty(input.PlaceAlias), u => u.PlaceAlias == input.PlaceAlias) |
| | | .Where(input.PlaceType != null, u => u.PlaceType == input.PlaceType) |
| | | .Where(!string.IsNullOrEmpty(input.PlaceTypeName), u => u.PlaceTypeName == input.PlaceTypeName) |
| | | .Where(!string.IsNullOrEmpty(input.StockUnit), u => u.StockUnit == input.StockUnit) |
| | | .Where(input.PlaceStatus != null, u => u.PlaceStatus == input.PlaceStatus) |
| | | .Where(input.IsSrmPlace != null, u => u.IsSrmPlace == input.IsSrmPlace) |
| | | .Where(!string.IsNullOrEmpty(input.SrmPlaceNo), u => u.SrmPlaceNo == input.SrmPlaceNo) |
| | | .Where(input.IsRgvPlace != null, u => u.IsRgvPlace == input.IsRgvPlace) |
| | | .Where(!string.IsNullOrEmpty(input.RgvPlaceNo), u => u.RgvPlaceNo == input.RgvPlaceNo) |
| | | .Where(input.IsAgvPlace != null, u => u.IsAgvPlace == input.IsAgvPlace) |
| | | .Where(!string.IsNullOrEmpty(input.AgvPlaceNo), u => u.AgvPlaceNo == input.AgvPlaceNo) |
| | | .Where(input.IsTransPlace != null, u => u.IsTransPlace == input.IsTransPlace) |
| | | .Where(!string.IsNullOrEmpty(input.TransPlaceNo), u => u.TransPlaceNo == input.TransPlaceNo) |
| | | .Where(input.IsActivateWCS != null, u => u.IsActivateWCS == input.IsActivateWCS) |
| | | .Where(!string.IsNullOrEmpty(input.Environment), u => u.Environment == input.Environment) |
| | | .Where(!string.IsNullOrEmpty(input.AreaCode), u => u.AreaCode == input.AreaCode) |
| | |
| | | var pPlaceAlias = input.PlaceAlias?.Trim() ?? ""; |
| | | var pPlaceType = input.PlaceType; |
| | | var pPlaceTypeName = input.PlaceTypeName?.Trim() ?? ""; |
| | | var pStockUnit = input.StockUnit?.Trim() ?? ""; |
| | | var pPlaceStatus = input.PlaceStatus; |
| | | var pIsSrmPlace = input.IsSrmPlace; |
| | | var pSrmPlaceNo = input.SrmPlaceNo?.Trim() ?? ""; |
| | | var pIsRgvPlace = input.IsRgvPlace; |
| | | var pRgvPlaceNo = input.RgvPlaceNo?.Trim() ?? ""; |
| | | var pIsAgvPlace = input.IsAgvPlace; |
| | | var pAgvPlaceNo = input.AgvPlaceNo?.Trim() ?? ""; |
| | | var pIsTransPlace = input.IsTransPlace; |
| | | var pTransPlaceNo = input.TransPlaceNo?.Trim() ?? ""; |
| | | var pIsActivateWCS = input.IsActivateWCS; |
| | | var pEnvironment = input.Environment?.Trim() ?? ""; |
| | | var pAreaCode = input.AreaCode?.Trim() ?? ""; |
| | |
| | | .Where(!string.IsNullOrEmpty(pPlaceAlias), u => u.PlaceAlias == pPlaceAlias) |
| | | .Where(pPlaceType != null, u => u.PlaceType == pPlaceType) |
| | | .Where(!string.IsNullOrEmpty(pPlaceTypeName), u => u.PlaceTypeName == pPlaceTypeName) |
| | | .Where(!string.IsNullOrEmpty(pStockUnit), u => u.StockUnit == pStockUnit) |
| | | .Where(pPlaceStatus != null, u => u.PlaceStatus == pPlaceStatus) |
| | | .Where(pIsSrmPlace != null, u => u.IsSrmPlace == pIsSrmPlace) |
| | | .Where(!string.IsNullOrEmpty(pSrmPlaceNo), u => u.SrmPlaceNo == pSrmPlaceNo) |
| | | .Where(pIsRgvPlace != null, u => u.IsRgvPlace == pIsRgvPlace) |
| | | .Where(!string.IsNullOrEmpty(pRgvPlaceNo), u => u.RgvPlaceNo == pRgvPlaceNo) |
| | | .Where(pIsAgvPlace != null, u => u.IsAgvPlace == pIsAgvPlace) |
| | | .Where(!string.IsNullOrEmpty(pAgvPlaceNo), u => u.AgvPlaceNo == pAgvPlaceNo) |
| | | .Where(pIsTransPlace != null, u => u.IsTransPlace == pIsTransPlace) |
| | | .Where(!string.IsNullOrEmpty(pTransPlaceNo), u => u.TransPlaceNo == pTransPlaceNo) |
| | | .Where(pIsActivateWCS != null, u => u.IsActivateWCS == pIsActivateWCS) |
| | | .Where(!string.IsNullOrEmpty(pEnvironment), u => u.Environment == pEnvironment) |
| | | .Where(!string.IsNullOrEmpty(pAreaCode), u => u.AreaCode == pAreaCode) |
| | |
| | | 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); |
| | | |
| | | wmsPlace.CreatedUserId = wmsPlace.UpdatedUserId = SysHelper.GetUserId(); |
| | |
| | | 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); |
| | | |
| | |
| | | var _PlaceAlias = "";//库位别名 |
| | | var _PlaceType = "";//库位类型 |
| | | var _PlaceTypeName = "";//库位类型名称 |
| | | var _StockUnit = "";//存放单位 |
| | | var _PlaceStatus = "";//库位属性 |
| | | var _IsSrmPlace = "";//是否堆垛机库位 |
| | | var _SrmPlaceNo = "";//堆垛机库位号 |
| | |
| | | _PlaceAlias = row["库位别名"]?.ToString() ; |
| | | _PlaceType = row["库位类型"]?.ToString() ; |
| | | _PlaceTypeName = row["库位类型名称"]?.ToString() ; |
| | | _StockUnit = row["存放单位"]?.ToString() ; |
| | | _PlaceStatus = row["库位属性"]?.ToString() ; |
| | | _IsSrmPlace = row["是否堆垛机库位"]?.ToString() ; |
| | | _SrmPlaceNo = row["堆垛机库位号"]?.ToString() ; |
| | |
| | | |
| | | if(!string.IsNullOrEmpty(_PlaceType)) |
| | | { |
| | | if (!int.TryParse(_PlaceType, out int outPlaceType)&&!string.IsNullOrEmpty(_PlaceType)) |
| | | Admin.NET.Core.PlaceTypeEnum enumPlaceType = default(Admin.NET.Core.PlaceTypeEnum); |
| | | |
| | | if(!Enum.TryParse<Admin.NET.Core.PlaceTypeEnum>(_PlaceType, out enumPlaceType)&&!string.IsNullOrEmpty(_PlaceType)) |
| | | { |
| | | throw Oops.Oh($"第{index}行[库位类型]{_PlaceType}值不正确!"); |
| | | } |
| | | if (outPlaceType <= 0&&!string.IsNullOrEmpty(_PlaceType)) |
| | | { |
| | | throw Oops.Oh($"第{index}行[库位类型]{_PlaceType}值不能小于等于0!"); |
| | | throw Oops.Oh($"第{index}行[库位类型]{_PlaceType}值不正确!"); |
| | | } |
| | | else |
| | | { |
| | | addItem.PlaceType = outPlaceType; |
| | | addItem.PlaceType = enumPlaceType; |
| | | } |
| | | |
| | | } |
| | | |
| | | if (string.IsNullOrEmpty(_PlaceTypeName)) |
| | | { |
| | | throw Oops.Oh($"第{index}行[库位类型名称]{_PlaceTypeName}不能为空!"); |
| | | } |
| | | |
| | | if(!string.IsNullOrEmpty(_PlaceTypeName)) |
| | | { |
| | | addItem.PlaceTypeName = (string)_PlaceTypeName; |
| | | } |
| | | if(!string.IsNullOrEmpty(_StockUnit)) |
| | | |
| | | if (string.IsNullOrEmpty(_PlaceStatus)) |
| | | { |
| | | addItem.StockUnit = (string)_StockUnit; |
| | | } |
| | | throw Oops.Oh($"第{index}行[库位属性]{_PlaceStatus}不能为空!"); |
| | | } |
| | | |
| | | if(!string.IsNullOrEmpty(_PlaceStatus)) |
| | | { |
| | | if (!int.TryParse(_PlaceStatus, out int outPlaceStatus)&&!string.IsNullOrEmpty(_PlaceStatus)) |
| | | Admin.NET.Core.PlaceStatusEnum enumPlaceStatus = default(Admin.NET.Core.PlaceStatusEnum); |
| | | |
| | | if(!Enum.TryParse<Admin.NET.Core.PlaceStatusEnum>(_PlaceStatus, out enumPlaceStatus)&&!string.IsNullOrEmpty(_PlaceStatus)) |
| | | { |
| | | throw Oops.Oh($"第{index}行[库位属性]{_PlaceStatus}值不正确!"); |
| | | } |
| | | if (outPlaceStatus <= 0&&!string.IsNullOrEmpty(_PlaceStatus)) |
| | | { |
| | | throw Oops.Oh($"第{index}行[库位属性]{_PlaceStatus}值不能小于等于0!"); |
| | | throw Oops.Oh($"第{index}行[库位属性]{_PlaceStatus}值不正确!"); |
| | | } |
| | | else |
| | | { |
| | | addItem.PlaceStatus = outPlaceStatus; |
| | | addItem.PlaceStatus = enumPlaceStatus; |
| | | } |
| | | |
| | | } |
| | | if(!string.IsNullOrEmpty(_IsSrmPlace)) |
| | | { |
| | | if(!_IsSrmPlace.Equals("是") && !_IsSrmPlace.Equals("否")) |
| | | { |
| | | throw Oops.Oh($"第{index}行[是否堆垛机库位]{_IsSrmPlace}值不正确!"); |
| | | } |
| | | else |
| | | { |
| | | bool outIsSrmPlace = _IsSrmPlace.Equals("是") ? true : false; |
| | | addItem.IsSrmPlace = outIsSrmPlace; |
| | | } |
| | | } |
| | | |
| | | if(!string.IsNullOrEmpty(_SrmPlaceNo)) |
| | | { |
| | | addItem.SrmPlaceNo = (string)_SrmPlaceNo; |
| | | } |
| | | if(!string.IsNullOrEmpty(_IsRgvPlace)) |
| | | { |
| | | if(!_IsRgvPlace.Equals("是") && !_IsRgvPlace.Equals("否")) |
| | | { |
| | | throw Oops.Oh($"第{index}行[是否RGV库位]{_IsRgvPlace}值不正确!"); |
| | | } |
| | | else |
| | | { |
| | | bool outIsRgvPlace = _IsRgvPlace.Equals("是") ? true : false; |
| | | addItem.IsRgvPlace = outIsRgvPlace; |
| | | } |
| | | } |
| | | |
| | | if(!string.IsNullOrEmpty(_RgvPlaceNo)) |
| | | { |
| | | addItem.RgvPlaceNo = (string)_RgvPlaceNo; |
| | | } |
| | | if(!string.IsNullOrEmpty(_IsAgvPlace)) |
| | | { |
| | | if(!_IsAgvPlace.Equals("是") && !_IsAgvPlace.Equals("否")) |
| | | { |
| | | throw Oops.Oh($"第{index}行[是否AGV库位]{_IsAgvPlace}值不正确!"); |
| | | } |
| | | else |
| | | { |
| | | bool outIsAgvPlace = _IsAgvPlace.Equals("是") ? true : false; |
| | | addItem.IsAgvPlace = outIsAgvPlace; |
| | | } |
| | | } |
| | | |
| | | if(!string.IsNullOrEmpty(_AgvPlaceNo)) |
| | | { |
| | | addItem.AgvPlaceNo = (string)_AgvPlaceNo; |
| | | } |
| | | if(!string.IsNullOrEmpty(_IsTransPlace)) |
| | | { |
| | | if(!_IsTransPlace.Equals("是") && !_IsTransPlace.Equals("否")) |
| | | { |
| | | throw Oops.Oh($"第{index}行[是否输送线库位]{_IsTransPlace}值不正确!"); |
| | | } |
| | | else |
| | | { |
| | | bool outIsTransPlace = _IsTransPlace.Equals("是") ? true : false; |
| | | addItem.IsTransPlace = outIsTransPlace; |
| | | } |
| | | } |
| | | |
| | | if(!string.IsNullOrEmpty(_TransPlaceNo)) |
| | | { |
| | | addItem.TransPlaceNo = (string)_TransPlaceNo; |
| | | } |
| | | |
| | | if(!string.IsNullOrEmpty(_IsActivateWCS)) |
| | | { |
| | | if(!_IsActivateWCS.Equals("是") && !_IsActivateWCS.Equals("否")) |
| | |
| | | { |
| | | addItem.AreaCode = (string)_AreaCode; |
| | | } |
| | | |
| | | if (string.IsNullOrEmpty(_AreaId)) |
| | | { |
| | | throw Oops.Oh($"第{index}行[所在库区]{_AreaId}不能为空!"); |
| | | } |
| | | |
| | | if(!string.IsNullOrEmpty(_AreaId)) |
| | | { |
| | | if (!long.TryParse(_AreaId, out long outAreaId)&&!string.IsNullOrEmpty(_AreaId)) |