| | |
| | | using System.Web; |
| | | using System.ComponentModel; |
| | | using System.Data; |
| | | using NetTopologySuite.Algorithm; |
| | | using Pipelines.Sockets.Unofficial.Arenas; |
| | | namespace Admin.NET.Application |
| | | { |
| | | /// <summary> |
| | |
| | | private readonly IRepository<SysDictData, MasterDbContextLocator> _sysDictDataRep; |
| | | private readonly ISysExcelTemplateService _sysExcelTemplateService; |
| | | private readonly static object _lock = new(); |
| | | |
| | | private readonly IRepository<WmsMaterialType, MasterDbContextLocator> _wmsMaterialTypeRep; |
| | | private readonly IRepository<WmsContainerType, MasterDbContextLocator> _wmsContainerTypeRep; |
| | | public WmsContainerPackagingService( |
| | | IRepository<WmsContainerPackaging,MasterDbContextLocator> wmsContainerPackagingRep |
| | | ,IRepository<SysDictType, MasterDbContextLocator> sysDictTypeRep |
| | | ,IRepository<SysDictData, MasterDbContextLocator> sysDictDataRep |
| | | ,ISysExcelTemplateService sysExcelTemplateService |
| | | , IRepository<WmsMaterialType, MasterDbContextLocator> wmsMaterialTypeRep |
| | | , IRepository<WmsContainerType, MasterDbContextLocator> wmsContainerTypeRep |
| | | ) |
| | | { |
| | | _wmsContainerPackagingRep = wmsContainerPackagingRep; |
| | | _sysDictTypeRep = sysDictTypeRep; |
| | | _sysDictDataRep = sysDictDataRep; |
| | | _sysExcelTemplateService = sysExcelTemplateService; |
| | | _wmsMaterialTypeRep = wmsMaterialTypeRep; |
| | | _wmsContainerTypeRep = wmsContainerTypeRep; |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | public async Task Add(AddWmsContainerPackagingInput input) |
| | | { |
| | | var wmsContainerPackaging = input.Adapt<WmsContainerPackaging>(); |
| | | //验证 |
| | | |
| | | var wmsMaterialType=(await _wmsMaterialTypeRep.DetachedEntities.FirstOrDefaultAsync(u => u.Id == input.MaterialTypeId&&u.IsDeleted==false)).Adapt<WmsMaterialTypeOutput>(); |
| | | if (wmsMaterialType == null) |
| | | { |
| | | throw Oops.Oh($"物料类型不存在"); |
| | | } |
| | | if (wmsMaterialType.IsDisabled == true) |
| | | { |
| | | throw Oops.Oh($"物料类型已禁用"); |
| | | } |
| | | var wmsContainerType=(await _wmsContainerTypeRep.DetachedEntities.FirstOrDefaultAsync(u => u.Id == input.ContainerTypeId&& u.IsDeleted == false)).Adapt<WmsContainerTypeOutput>(); |
| | | if (wmsContainerType == null) |
| | | { |
| | | throw Oops.Oh($"容器类型不存在"); |
| | | } |
| | | if (wmsContainerType.IsDisabled == true) |
| | | { |
| | | throw Oops.Oh($"容器类型已禁用"); |
| | | } |
| | | wmsContainerPackaging.ContainerTypeName = wmsContainerType.TypeName; |
| | | wmsContainerPackaging.MaterialTypeName= wmsMaterialType.MaterialTypeName; |
| | | wmsContainerPackaging.MaterialTypeCode = wmsMaterialType.MaterialTypeCode; |
| | | //验证 |
| | | await CheckExisit(wmsContainerPackaging); |
| | | |
| | | wmsContainerPackaging.CreatedUserId = wmsContainerPackaging.UpdatedUserId = SysHelper.GetUserId(); |
| | |
| | | var _MaterialTypeCode = "";//物料类型编号 |
| | | var _MaterialTypeName = "";//物料类型名称 |
| | | var _BoxQty = "";//物料容器容量 |
| | | var _Id = "";//Id主键 |
| | | #endregion |
| | | |
| | | |
| | |
| | | _MaterialTypeCode = row["物料类型编号"]?.ToString() ; |
| | | _MaterialTypeName = row["物料类型名称"]?.ToString() ; |
| | | _BoxQty = row["物料容器容量"]?.ToString() ; |
| | | _Id = row["Id主键"]?.ToString() ; |
| | | #endregion |
| | | |
| | | |
| | |
| | | } |
| | | |
| | | } |
| | | if(!string.IsNullOrEmpty(_Id)) |
| | | { |
| | | if (!long.TryParse(_Id, out long outId)&&!string.IsNullOrEmpty(_Id)) |
| | | { |
| | | throw Oops.Oh($"第{index}行[Id主键]{_Id}值不正确!"); |
| | | } |
| | | if (outId <= 0&&!string.IsNullOrEmpty(_Id)) |
| | | { |
| | | throw Oops.Oh($"第{index}行[Id主键]{_Id}值不能小于等于0!"); |
| | | } |
| | | else |
| | | { |
| | | addItem.Id = outId; |
| | | } |
| | | |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | |
| | |
| | | /// <returns></returns> |
| | | private async Task CheckExisit( WmsContainerPackaging input,bool isEdit=false) |
| | | { |
| | | |
| | | |
| | | |
| | | bool isExist = false; |
| | | |
| | | string erorMsg = string.Empty; |
| | | bool isExist = false; |
| | | if (!isEdit)//新增 |
| | | { |
| | | //数据是否存在重复 |
| | | isExist = await _wmsContainerPackagingRep.AnyAsync(u => |
| | | u.ContainerTypeId.Equals(input.ContainerTypeId) |
| | | &&u.MaterialTypeId.Equals(input.MaterialTypeId) |
| | | ,false); |
| | | } |
| | | if (isExist) |
| | | { |
| | | erorMsg = $"系统中,容器类型[{input.ContainerTypeName}]-物料类型[{input.MaterialTypeName}]关系已存在"; |
| | | throw Oops.Oh(erorMsg); |
| | | } |
| | | } |
| | | else//编辑 |
| | | { |
| | | |
| | |
| | | //当前编辑数据以外是否存在重复 |
| | | isExist = await _wmsContainerPackagingRep.AnyAsync(u => |
| | | u.Id != input.Id |
| | | &&u.ContainerTypeId.Equals(input.ContainerTypeId) |
| | | ,false); |
| | | } |
| | | &&u.ContainerTypeId.Equals(input.ContainerTypeId) |
| | | && u.MaterialTypeId.Equals(input.MaterialTypeId) |
| | | , false); |
| | | if (isExist) |
| | | { |
| | | erorMsg = $"系统中,容器类型[{input.ContainerTypeName}]-物料类型[{input.MaterialTypeName}]关系已存在"; |
| | | throw Oops.Oh(erorMsg); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | if (isExist) throw Oops.Oh(ErrorCode.E0001); |
| | | } |
| | | |
| | | /// <summary> |