|
@ -1,3 +1,4 @@ |
|
|
|
|
|
using System; |
|
|
using System.Collections.Generic; |
|
|
using System.Collections.Generic; |
|
|
using System.ComponentModel.DataAnnotations; |
|
|
using System.ComponentModel.DataAnnotations; |
|
|
using System.Linq; |
|
|
using System.Linq; |
|
@ -15,6 +16,7 @@ using Win_in.Sfs.Label.Application.Contracts; |
|
|
using Win_in.Sfs.Label.Domain; |
|
|
using Win_in.Sfs.Label.Domain; |
|
|
using Win_in.Sfs.Label.Domain.Shared; |
|
|
using Win_in.Sfs.Label.Domain.Shared; |
|
|
using Win_in.Sfs.Shared.Application.Contracts; |
|
|
using Win_in.Sfs.Shared.Application.Contracts; |
|
|
|
|
|
using Win_in.Sfs.Shared.Domain.Shared; |
|
|
|
|
|
|
|
|
namespace Win_in.Sfs.Label.Application; |
|
|
namespace Win_in.Sfs.Label.Application; |
|
|
|
|
|
|
|
@ -33,12 +35,14 @@ public class InventoryLabelAppService |
|
|
private new readonly IInventoryLabelRepository _repository; |
|
|
private new readonly IInventoryLabelRepository _repository; |
|
|
private readonly ISupplierAppService _supplierAppService; |
|
|
private readonly ISupplierAppService _supplierAppService; |
|
|
private readonly ISupplierItemAppService _supplierItemAppService; |
|
|
private readonly ISupplierItemAppService _supplierItemAppService; |
|
|
|
|
|
private readonly IItemBasicAppService _itemBasicAppService; |
|
|
|
|
|
|
|
|
public InventoryLabelAppService( |
|
|
public InventoryLabelAppService( |
|
|
IInventoryLabelRepository repository, ILabelDefinitionManager labelDefinitionManager |
|
|
IInventoryLabelRepository repository, ILabelDefinitionManager labelDefinitionManager |
|
|
, ISupplierAppService supplierAppService |
|
|
, ISupplierAppService supplierAppService |
|
|
, IItemPackAppService itemPackAppService |
|
|
, IItemPackAppService itemPackAppService |
|
|
, ISupplierItemAppService supplierItemAppService |
|
|
, ISupplierItemAppService supplierItemAppService |
|
|
|
|
|
, IItemBasicAppService itemBasicAppService |
|
|
) : base(repository) |
|
|
) : base(repository) |
|
|
{ |
|
|
{ |
|
|
_repository = repository; |
|
|
_repository = repository; |
|
@ -46,6 +50,7 @@ public class InventoryLabelAppService |
|
|
_supplierAppService = supplierAppService; |
|
|
_supplierAppService = supplierAppService; |
|
|
_itemPackAppService = itemPackAppService; |
|
|
_itemPackAppService = itemPackAppService; |
|
|
_supplierItemAppService = supplierItemAppService; |
|
|
_supplierItemAppService = supplierItemAppService; |
|
|
|
|
|
_itemBasicAppService = itemBasicAppService; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
[HttpPost("")] |
|
|
[HttpPost("")] |
|
@ -60,6 +65,45 @@ public class InventoryLabelAppService |
|
|
return await base.CreateAsync(input).ConfigureAwait(false); |
|
|
return await base.CreateAsync(input).ConfigureAwait(false); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 按Id获取实体
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="id">实体Id</param>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
[HttpGet("{id}")] |
|
|
|
|
|
public override async Task<InventoryLabelDto> GetAsync(Guid id) |
|
|
|
|
|
{ |
|
|
|
|
|
var dto = await base.GetAsync(id).ConfigureAwait(false); |
|
|
|
|
|
|
|
|
|
|
|
if (dto != null) |
|
|
|
|
|
{ |
|
|
|
|
|
var itemBasicDto = await _itemBasicAppService.GetByCodeAsync(dto.ItemCode).ConfigureAwait(false); |
|
|
|
|
|
if (itemBasicDto != null) |
|
|
|
|
|
{ |
|
|
|
|
|
switch (itemBasicDto.ValidityUnit) |
|
|
|
|
|
{ |
|
|
|
|
|
case EnumValidityUnit.Infinite: |
|
|
|
|
|
dto.ExpireDate = DateTime.MaxValue; |
|
|
|
|
|
break; |
|
|
|
|
|
case EnumValidityUnit.Day: |
|
|
|
|
|
dto.ExpireDate = DateTime.Now.AddDays(itemBasicDto.Validity); |
|
|
|
|
|
break; |
|
|
|
|
|
case EnumValidityUnit.WeeK: |
|
|
|
|
|
dto.ExpireDate = DateTime.Now.AddDays(itemBasicDto.Validity * 7); |
|
|
|
|
|
break; |
|
|
|
|
|
case EnumValidityUnit.Month: |
|
|
|
|
|
dto.ExpireDate = DateTime.Now.AddMonths(itemBasicDto.Validity); |
|
|
|
|
|
break; |
|
|
|
|
|
case EnumValidityUnit.None: |
|
|
|
|
|
default: |
|
|
|
|
|
break; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return dto; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
[HttpPost("many")] |
|
|
[HttpPost("many")] |
|
|
[UnitOfWork] |
|
|
[UnitOfWork] |
|
|
public virtual async Task<List<InventoryLabelDto>> CreateManyAsync(List<InventoryLabelEditInput> inputs) |
|
|
public virtual async Task<List<InventoryLabelDto>> CreateManyAsync(List<InventoryLabelEditInput> inputs) |
|
@ -83,7 +127,7 @@ public class InventoryLabelAppService |
|
|
[UnitOfWork] |
|
|
[UnitOfWork] |
|
|
public virtual async Task<List<InventoryLabelDto>> CreateManyByNoCodeAsync(List<InventoryLabelEditInput> inputs) |
|
|
public virtual async Task<List<InventoryLabelDto>> CreateManyByNoCodeAsync(List<InventoryLabelEditInput> inputs) |
|
|
{ |
|
|
{ |
|
|
var entitys= ObjectMapper.Map<List<InventoryLabelEditInput>, List<InventoryLabel>>(inputs); |
|
|
var entitys = ObjectMapper.Map<List<InventoryLabelEditInput>, List<InventoryLabel>>(inputs); |
|
|
await _repository.InsertManyAsync(entitys).ConfigureAwait(false); |
|
|
await _repository.InsertManyAsync(entitys).ConfigureAwait(false); |
|
|
return ObjectMapper.Map<List<InventoryLabel>, List<InventoryLabelDto>>(entitys); |
|
|
return ObjectMapper.Map<List<InventoryLabel>, List<InventoryLabelDto>>(entitys); |
|
|
} |
|
|
} |
|
@ -133,8 +177,32 @@ public class InventoryLabelAppService |
|
|
dto.SupplierCode = input.SupplierCode; |
|
|
dto.SupplierCode = input.SupplierCode; |
|
|
dto.PoNumber = input.PoNumber; |
|
|
dto.PoNumber = input.PoNumber; |
|
|
dto.Remark = input.Remark; |
|
|
dto.Remark = input.Remark; |
|
|
|
|
|
dto.AsnNumber = input.AsnNumber; |
|
|
dto.FullBarcodeString = dto.Code; |
|
|
dto.FullBarcodeString = dto.Code; |
|
|
|
|
|
|
|
|
|
|
|
var itemBasicDto = await _itemBasicAppService.GetByCodeAsync(dto.ItemCode).ConfigureAwait(false); |
|
|
|
|
|
if (itemBasicDto != null) |
|
|
|
|
|
{ |
|
|
|
|
|
switch (itemBasicDto.ValidityUnit) |
|
|
|
|
|
{ |
|
|
|
|
|
case EnumValidityUnit.Infinite: |
|
|
|
|
|
dto.ExpireDate = DateTime.MaxValue; |
|
|
|
|
|
break; |
|
|
|
|
|
case EnumValidityUnit.Day: |
|
|
|
|
|
dto.ExpireDate = DateTime.Now.AddDays(itemBasicDto.Validity); |
|
|
|
|
|
break; |
|
|
|
|
|
case EnumValidityUnit.WeeK: |
|
|
|
|
|
dto.ExpireDate = DateTime.Now.AddDays(itemBasicDto.Validity * 7); |
|
|
|
|
|
break; |
|
|
|
|
|
case EnumValidityUnit.Month: |
|
|
|
|
|
dto.ExpireDate = DateTime.Now.AddMonths(itemBasicDto.Validity); |
|
|
|
|
|
break; |
|
|
|
|
|
case EnumValidityUnit.None: |
|
|
|
|
|
default: |
|
|
|
|
|
break; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
dtos.Add(dto); |
|
|
dtos.Add(dto); |
|
|
} |
|
|
} |
|
|
return dtos; |
|
|
return dtos; |
|
|