39 changed files with 771 additions and 95 deletions
@ -0,0 +1,47 @@ |
|||||
|
using System.ComponentModel.DataAnnotations; |
||||
|
using Win_in.Sfs.Shared.Domain; |
||||
|
|
||||
|
namespace Win_in.Sfs.Basedata.Application.Contracts; |
||||
|
|
||||
|
[Display(Name = "物品收容器信息")] |
||||
|
|
||||
|
public class ItemContainerDTO : SfsBaseDataDTOBase |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// 收容器代码
|
||||
|
/// </summary>
|
||||
|
[Display(Name = "收容器代码")] |
||||
|
[StringLength(SfsEfCorePropertyConst.CodeLength, ErrorMessage = "{0}最多输入{1}个字符")] |
||||
|
public string ContainerCode { get; set; } |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 收容器名称
|
||||
|
/// </summary>
|
||||
|
[Display(Name = "收容器名称")] |
||||
|
[StringLength(SfsEfCorePropertyConst.CodeLength, ErrorMessage = "{0}最多输入{1}个字符")] |
||||
|
public string ContainerName { get; set; } |
||||
|
/// <summary>
|
||||
|
/// 收容器类型
|
||||
|
/// </summary>
|
||||
|
[Display(Name = "收容器类型")] |
||||
|
[StringLength(SfsEfCorePropertyConst.DescLength, ErrorMessage = "{0}最多输入{1}个字符")] |
||||
|
public string ContainerType { get; set; } |
||||
|
/// <summary>
|
||||
|
/// 物品代码
|
||||
|
/// </summary>
|
||||
|
[Display(Name = "物品代码")] |
||||
|
[StringLength(SfsEfCorePropertyConst.DescLength, ErrorMessage = "{0}最多输入{1}个字符")] |
||||
|
public string ItemCode { get; set; } |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 收容器计量单位
|
||||
|
/// </summary>
|
||||
|
[Display(Name = "收容器计量单位")] |
||||
|
public string BasicUom { get; set; } |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 收容器数量
|
||||
|
/// </summary>
|
||||
|
[Display(Name = "收容器数量")] |
||||
|
public decimal Qty { get; set; } |
||||
|
} |
@ -0,0 +1,11 @@ |
|||||
|
using System.Collections.Generic; |
||||
|
using System.Threading.Tasks; |
||||
|
using Win_in.Sfs.Shared.Application.Contracts; |
||||
|
|
||||
|
namespace Win_in.Sfs.Basedata.Application.Contracts; |
||||
|
|
||||
|
public interface IItemContainerAppService : ISfsBaseDataAppServiceBase<ItemContainerDTO, SfsBaseDataRequestInputBase, ItemContainerEditInput>, ISfsUpsertAppService<ItemContainerEditInput> |
||||
|
{ |
||||
|
Task<List<ItemContainerDTO>> GetListByItemCodeAsync(string itemCode); |
||||
|
Task UpsertAndItemBasicUomAsync(string itemCode,decimal stdPackQty); |
||||
|
} |
@ -0,0 +1,53 @@ |
|||||
|
using System.ComponentModel.DataAnnotations; |
||||
|
using Win_in.Sfs.Shared.Domain; |
||||
|
|
||||
|
namespace Win_in.Sfs.Basedata.Application.Contracts; |
||||
|
|
||||
|
public class ItemContainerEditInput : SfsBaseDataCreateOrUpdateInputBase |
||||
|
{ |
||||
|
#region Base
|
||||
|
/// <summary>
|
||||
|
/// 收容器名称
|
||||
|
/// </summary>
|
||||
|
[Display(Name = "收容器名称")] |
||||
|
[StringLength(SfsEfCorePropertyConst.CodeLength, ErrorMessage = "{0}最多输入{1}个字符")] |
||||
|
public string ContainerName { get; set; } |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 收容器类型
|
||||
|
/// </summary>
|
||||
|
[Display(Name = "收容器类型")] |
||||
|
[StringLength(SfsEfCorePropertyConst.DescLength, ErrorMessage = "{0}最多输入{1}个字符")] |
||||
|
public string ContainerType { get; set; } |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 收容器计量单位
|
||||
|
/// </summary>
|
||||
|
[Display(Name = "收容器计量单位")] |
||||
|
public string BasicUom { get; set; } |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 收容器数量
|
||||
|
/// </summary>
|
||||
|
[Display(Name = "收容器数量")] |
||||
|
public decimal Qty { get; set; } |
||||
|
#endregion
|
||||
|
|
||||
|
#region Create
|
||||
|
/// <summary>
|
||||
|
/// 收容器代码
|
||||
|
/// </summary>
|
||||
|
[Display(Name = "收容器代码")] |
||||
|
[Required(ErrorMessage = "{0}是必填项")] |
||||
|
[StringLength(SfsEfCorePropertyConst.CodeLength, ErrorMessage = "{0}最多输入{1}个字符")] |
||||
|
public string ContainerCode { get; set; } |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 物品代码
|
||||
|
/// </summary>
|
||||
|
[Display(Name = "物品代码")] |
||||
|
[Required(ErrorMessage = "{0}是必填项")] |
||||
|
[StringLength(SfsEfCorePropertyConst.DescLength, ErrorMessage = "{0}最多输入{1}个字符")] |
||||
|
public string ItemCode { get; set; } |
||||
|
#endregion
|
||||
|
} |
@ -0,0 +1,64 @@ |
|||||
|
using System.ComponentModel.DataAnnotations; |
||||
|
using Win_in.Sfs.Shared.Application.Contracts; |
||||
|
using Win_in.Sfs.Shared.Domain; |
||||
|
|
||||
|
namespace Win_in.Sfs.Basedata.Application.Contracts; |
||||
|
|
||||
|
[Display(Name = "物品收容器")] |
||||
|
public class ItemContainerImportInput : SfsBaseDataImportInputBase |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// 收容器代码
|
||||
|
/// </summary>
|
||||
|
[Key] |
||||
|
[Display(Name = "收容器代码")] |
||||
|
[Required(ErrorMessage = "{0}不能为空")] |
||||
|
[StringLength(SfsEfCorePropertyConst.CodeLength, ErrorMessage = "{0}最多输入{1}个字符")] |
||||
|
public string ContainerCode { get; set; } |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 收容器名称
|
||||
|
/// </summary>
|
||||
|
[Display(Name = "收容器名称")] |
||||
|
[StringLength(SfsEfCorePropertyConst.CodeLength, ErrorMessage = "{0}最多输入{1}个字符")] |
||||
|
public string ContainerName { get; set; } |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 收容器类型
|
||||
|
/// </summary>
|
||||
|
[Display(Name = "收容器类型")] |
||||
|
[StringLength(SfsEfCorePropertyConst.DescLength, ErrorMessage = "{0}最多输入{1}个字符")] |
||||
|
[ValueMapping("EA", "EA")] |
||||
|
[ValueMapping("Box", "Box")] |
||||
|
[ValueMapping("Pallet", "Pallet")] |
||||
|
public string ContainerType { get; set; } |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 物品编号
|
||||
|
/// </summary>
|
||||
|
[Key] |
||||
|
[Display(Name = "物品编号")] |
||||
|
[Required(ErrorMessage = "物品编号不能为空")] |
||||
|
[StringLength(SfsEfCorePropertyConst.DescLength, ErrorMessage = "{0}最多输入{1}个字符")] |
||||
|
public string ItemCode { get; set; } |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 收容器计量单位
|
||||
|
/// </summary>
|
||||
|
[Display(Name = "收容器计量单位")] |
||||
|
public string BasicUom { get; set; } |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 收容器数量
|
||||
|
/// </summary>
|
||||
|
[Display(Name = "收容器数量")] |
||||
|
[Required(ErrorMessage = "{0}是必填项")] |
||||
|
public decimal Qty { get; set; } |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 备注
|
||||
|
/// </summary>
|
||||
|
[Display(Name = "备注")] |
||||
|
[StringLength(SfsEfCorePropertyConst.RemarkLength, ErrorMessage = "{0}最多输入{1}个字符")] |
||||
|
public string Remark { get; set; } |
||||
|
} |
@ -0,0 +1,21 @@ |
|||||
|
using Volo.Abp.Authorization.Permissions; |
||||
|
using Win_in.Sfs.Basedata.Domain; |
||||
|
|
||||
|
namespace Win_in.Sfs.Basedata.Application.Contracts; |
||||
|
|
||||
|
public static class ItemContainerPermissions |
||||
|
{ |
||||
|
|
||||
|
public const string Default = BasedataPermissions.GroupName + "." + nameof(ItemContainer); |
||||
|
public const string Create = Default + "." + BasedataPermissions.CreateStr; |
||||
|
public const string Update = Default + "." + BasedataPermissions.UpdateStr; |
||||
|
public const string Delete = Default + "." + BasedataPermissions.DeleteStr; |
||||
|
|
||||
|
public static void AddItemContainerPermission(this PermissionGroupDefinition permissionGroup) |
||||
|
{ |
||||
|
var itemContainerPermission = permissionGroup.AddPermission(Default, BasedataPermissionDefinitionProvider.L(nameof(ItemContainer))); |
||||
|
itemContainerPermission.AddChild(Create, BasedataPermissionDefinitionProvider.L(BasedataPermissions.CreateStr)); |
||||
|
itemContainerPermission.AddChild(Update, BasedataPermissionDefinitionProvider.L(BasedataPermissions.UpdateStr)); |
||||
|
itemContainerPermission.AddChild(Delete, BasedataPermissionDefinitionProvider.L(BasedataPermissions.DeleteStr)); |
||||
|
} |
||||
|
} |
@ -0,0 +1,100 @@ |
|||||
|
using System.Collections.Generic; |
||||
|
using System.ComponentModel.DataAnnotations; |
||||
|
using System.Linq; |
||||
|
using System.Threading.Tasks; |
||||
|
|
||||
|
using Microsoft.AspNetCore.Authorization; |
||||
|
using Microsoft.AspNetCore.Mvc; |
||||
|
using Volo.Abp; |
||||
|
using Volo.Abp.Caching; |
||||
|
using Volo.Abp.Domain.Repositories; |
||||
|
using Volo.Abp.Uow; |
||||
|
using Win_in.Sfs.Basedata.Application.Contracts; |
||||
|
using Win_in.Sfs.Basedata.Domain; |
||||
|
using Win_in.Sfs.Basedata.Domain.Shared; |
||||
|
using Win_in.Sfs.Shared.Domain.Shared; |
||||
|
|
||||
|
namespace Win_in.Sfs.Basedata.Application; |
||||
|
|
||||
|
[Authorize] |
||||
|
[Route($"{BasedataConsts.RootPath}item-container")] |
||||
|
|
||||
|
public class ItemContainerAppService |
||||
|
: SfsBaseDataAppServiceBase<ItemContainer, ItemContainerDTO, SfsBaseDataRequestInputBase, ItemContainerEditInput, ItemContainerImportInput> |
||||
|
, IItemContainerAppService |
||||
|
{ |
||||
|
private readonly IItemContainerManager _manager; |
||||
|
private new readonly IItemContainerRepository _repository; |
||||
|
|
||||
|
public ItemContainerAppService( |
||||
|
IItemContainerRepository repository |
||||
|
, IDistributedCache<ItemContainerDTO> cache |
||||
|
, IItemContainerManager manager |
||||
|
, IItemBasicAppService itemBasicAppService) : base(repository, cache) |
||||
|
{ |
||||
|
base.CreatePolicyName = ItemContainerPermissions.Create; |
||||
|
base.UpdatePolicyName = ItemContainerPermissions.Update; |
||||
|
base.DeletePolicyName = ItemContainerPermissions.Delete; |
||||
|
_repository = repository; |
||||
|
_manager = manager; |
||||
|
} |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 用来重写 新增实体
|
||||
|
/// </summary>
|
||||
|
/// <param name="input"></param>
|
||||
|
/// <returns></returns>
|
||||
|
/// <exception cref="UserFriendlyException"></exception>
|
||||
|
[HttpPost("")] |
||||
|
[UnitOfWork] |
||||
|
public override async Task<ItemContainerDTO> CreateAsync(ItemContainerEditInput input) |
||||
|
{ |
||||
|
var existEntity = await _repository.FirstOrDefaultAsync(p=>p.ContainerCode==input.ContainerCode).ConfigureAwait(false); |
||||
|
if (existEntity != null) |
||||
|
{ |
||||
|
throw new UserFriendlyException($"{input.ContainerCode} 已存在"); |
||||
|
} |
||||
|
|
||||
|
var itemBasic = await ItemBasicAppService.GetByCodeAsync(input.ItemCode).ConfigureAwait(false); |
||||
|
Check.NotNull(itemBasic, "物品代码", $"物品 {input.ItemCode} 不存在"); |
||||
|
if(itemBasic != null) |
||||
|
{ |
||||
|
input.BasicUom = itemBasic.BasicUom; |
||||
|
} |
||||
|
|
||||
|
|
||||
|
return await base.CreateAsync(input).ConfigureAwait(false); |
||||
|
} |
||||
|
|
||||
|
[HttpPost("upsert")] |
||||
|
public virtual async Task UpsertAsync(ItemContainerEditInput input) |
||||
|
{ |
||||
|
var entity = ObjectMapper.Map<ItemContainerEditInput, ItemContainer>(input); |
||||
|
await _repository.UpsertAsync(entity).ConfigureAwait(false); |
||||
|
} |
||||
|
|
||||
|
[HttpGet("list/by-item")] |
||||
|
public virtual async Task<List<ItemContainerDTO>> GetListByItemCodeAsync(string itemCode) |
||||
|
{ |
||||
|
var entities = await _repository.GetListAsync(c => c.ItemCode == itemCode).ConfigureAwait(false); |
||||
|
var dtos = ObjectMapper.Map<List<ItemContainer>, List<ItemContainerDTO>>(entities); |
||||
|
return dtos; |
||||
|
} |
||||
|
|
||||
|
|
||||
|
protected override async Task ValidateImportModelAsync(ItemContainerImportInput importInput, List<ValidationResult> validationRresult) |
||||
|
{ |
||||
|
await base.CheckItemBasicPackUomAsync(importInput.ItemCode, importInput.BasicUom, validationRresult).ConfigureAwait(false); |
||||
|
//await base.CheckItemContainerAsync(importInput.ContainerCode, validationRresult).ConfigureAwait(false);
|
||||
|
} |
||||
|
|
||||
|
[HttpPut("upsert-and-item-basic-std-pack")] |
||||
|
public async Task UpsertAndItemBasicUomAsync(string itemCode,decimal stdPackQty) |
||||
|
{ |
||||
|
var itemContainers=await _repository.GetListAsync(p => p.ItemCode == itemCode).ConfigureAwait(false); |
||||
|
var entity=itemContainers.First(); |
||||
|
entity.Qty = stdPackQty; |
||||
|
await _repository.UpsertAsync(entity).ConfigureAwait(false); |
||||
|
await ItemBasicAppService.UpsertStdPackQtyAsync(itemCode, stdPackQty).ConfigureAwait(false); |
||||
|
} |
||||
|
} |
@ -0,0 +1,33 @@ |
|||||
|
using AutoMapper; |
||||
|
using Volo.Abp.AutoMapper; |
||||
|
using Win_in.Sfs.Basedata.Application.Contracts; |
||||
|
using Win_in.Sfs.Basedata.Domain; |
||||
|
|
||||
|
namespace Win_in.Sfs.Basedata.Application; |
||||
|
|
||||
|
public partial class BasedataApplicationAutoMapperProfile : Profile |
||||
|
{ |
||||
|
private void ItemContainerAutoMapperProfile() |
||||
|
{ |
||||
|
CreateMap<ItemContainer, ItemContainerDTO>() |
||||
|
.ReverseMap(); |
||||
|
|
||||
|
CreateMap<ItemContainerImportInput, ItemContainer>() |
||||
|
.IgnoreAuditedObjectProperties() |
||||
|
.Ignore(x => x.TenantId) |
||||
|
.Ignore(x => x.ExtraProperties) |
||||
|
.Ignore(x => x.ConcurrencyStamp) |
||||
|
; |
||||
|
|
||||
|
CreateMap<ItemContainerEditInput, ItemContainer>() |
||||
|
.IgnoreAuditedObjectProperties() |
||||
|
.Ignore(x => x.TenantId) |
||||
|
.Ignore(x=>x.Id) |
||||
|
.Ignore(x => x.ExtraProperties) |
||||
|
.Ignore(x => x.ConcurrencyStamp) |
||||
|
; |
||||
|
CreateMap<ItemContainerEditInput, ItemContainer>() |
||||
|
.IgnoreAuditedObjectProperties() |
||||
|
.Ignore(x => x.ConcurrencyStamp).Ignore(x => x.Id); |
||||
|
} |
||||
|
} |
@ -0,0 +1,9 @@ |
|||||
|
using Volo.Abp.Domain.Services; |
||||
|
using Win_in.Sfs.Shared.Domain; |
||||
|
|
||||
|
namespace Win_in.Sfs.Basedata.Domain; |
||||
|
|
||||
|
public interface IItemContainerManager : IDomainService, IBulkImportService<ItemContainer> |
||||
|
{ |
||||
|
|
||||
|
} |
@ -0,0 +1,9 @@ |
|||||
|
using System.Threading.Tasks; |
||||
|
using Win_in.Sfs.Shared.Domain; |
||||
|
|
||||
|
namespace Win_in.Sfs.Basedata.Domain; |
||||
|
|
||||
|
public interface IItemContainerRepository : ISfsBaseDataRepositoryBase<ItemContainer>, ISfsBulkRepositoryBase<ItemContainer> |
||||
|
{ |
||||
|
Task UpsertAsync(ItemContainer entity); |
||||
|
} |
@ -0,0 +1,46 @@ |
|||||
|
using System.ComponentModel.DataAnnotations; |
||||
|
using System.ComponentModel.DataAnnotations.Schema; |
||||
|
using Win_in.Sfs.Shared.Domain.Entities; |
||||
|
using Win_in.Sfs.Shared.Domain.Shared; |
||||
|
|
||||
|
namespace Win_in.Sfs.Basedata.Domain; |
||||
|
|
||||
|
public class ItemContainer : SfsBaseDataAggregateRootBase |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// 收容器代码
|
||||
|
/// </summary>
|
||||
|
[IgnoreUpdate] |
||||
|
public string ContainerCode { get; set; } |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 收容器名称
|
||||
|
/// </summary>
|
||||
|
public string ContainerName { get; set; } |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 收容器类型
|
||||
|
/// </summary>
|
||||
|
public string ContainerType { get; set; } |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 物品代码
|
||||
|
/// </summary>
|
||||
|
[IgnoreUpdate] |
||||
|
public string ItemCode { get; set; } |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 计量单位
|
||||
|
/// </summary>
|
||||
|
[Display(Name = "计量单位")] |
||||
|
[MaxLength(SfsPropertyConst.CodeLength)] |
||||
|
public string BasicUom { get; set; } |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 数量
|
||||
|
/// </summary>
|
||||
|
[Display(Name = "数量")] |
||||
|
[Column(TypeName = "decimal(18,6)")] |
||||
|
public decimal Qty { get; set; } |
||||
|
|
||||
|
} |
@ -0,0 +1,31 @@ |
|||||
|
using System.Collections.Generic; |
||||
|
using System.Threading.Tasks; |
||||
|
using Volo.Abp.Domain.Services; |
||||
|
|
||||
|
namespace Win_in.Sfs.Basedata.Domain; |
||||
|
|
||||
|
public class ItemContainerManager : DomainService, IItemContainerManager |
||||
|
{ |
||||
|
private readonly IItemContainerRepository _repository; |
||||
|
|
||||
|
private readonly IItemBasicRepository _itemBasicRepository; |
||||
|
|
||||
|
public ItemContainerManager(IItemContainerRepository repository, IItemBasicRepository itemBasicRepository) |
||||
|
{ |
||||
|
_repository = repository; |
||||
|
_itemBasicRepository = itemBasicRepository; |
||||
|
} |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 执行导入
|
||||
|
/// </summary>
|
||||
|
public virtual async Task ImportDataAsync(List<ItemContainer> mergeEntities, List<ItemContainer> deleteEntities = null) |
||||
|
{ |
||||
|
if (deleteEntities != null && deleteEntities.Count > 0) |
||||
|
{ |
||||
|
await _repository.BulkDeleteAsync(deleteEntities).ConfigureAwait(false); |
||||
|
} |
||||
|
|
||||
|
await _repository.BulkMergeAsync(mergeEntities).ConfigureAwait(false); |
||||
|
} |
||||
|
} |
@ -0,0 +1,36 @@ |
|||||
|
using Microsoft.EntityFrameworkCore; |
||||
|
using Volo.Abp.EntityFrameworkCore.Modeling; |
||||
|
using Win_in.Sfs.Basedata.Domain; |
||||
|
using Win_in.Sfs.Shared.Domain.Shared; |
||||
|
using Win_in.Sfs.Shared.EntityFrameworkCore; |
||||
|
|
||||
|
namespace Win_in.Sfs.Basedata.EntityFrameworkCore; |
||||
|
|
||||
|
public static class ItemContainerDbContextModelCreatingExtensions |
||||
|
{ |
||||
|
public static void ConfigureItemContainer(this ModelBuilder builder, BasedataModelBuilderConfigurationOptions options) |
||||
|
{ |
||||
|
builder.Entity<ItemContainer>(b => |
||||
|
{ |
||||
|
//Configure table & schema name
|
||||
|
b.ToTable(options.TablePrefix + nameof(ItemContainer), options.Schema); |
||||
|
//Configure ABP properties
|
||||
|
b.ConfigureByConvention(); |
||||
|
//Configure Sfs base properties
|
||||
|
b.ConfigureSfsBase(); |
||||
|
|
||||
|
//Properties
|
||||
|
|
||||
|
b.Property(q => q.ContainerCode).IsRequired().HasMaxLength(SfsPropertyConst.CodeLength); |
||||
|
b.Property(q => q.ItemCode).IsRequired().HasMaxLength(SfsPropertyConst.CodeLength); |
||||
|
b.Property(q => q.ContainerName).HasMaxLength(SfsPropertyConst.NameLength); |
||||
|
b.Property(q => q.ContainerType).HasMaxLength(SfsPropertyConst.NameLength); |
||||
|
|
||||
|
//Relations
|
||||
|
//None
|
||||
|
|
||||
|
//Indexes
|
||||
|
b.HasIndex(q => new { q.ItemCode, q.ContainerCode }).IsUnique(); |
||||
|
}); |
||||
|
} |
||||
|
} |
@ -0,0 +1,32 @@ |
|||||
|
using System.Threading.Tasks; |
||||
|
using Microsoft.EntityFrameworkCore; |
||||
|
using Volo.Abp.EntityFrameworkCore; |
||||
|
using Win_in.Sfs.Basedata.Domain; |
||||
|
using Win_in.Sfs.Shared.Domain; |
||||
|
|
||||
|
namespace Win_in.Sfs.Basedata.EntityFrameworkCore; |
||||
|
|
||||
|
public class ItemContainerEfCoreRepository : SfsBaseDataEfCoreRepositoryBase<BasedataDbContext, ItemContainer>, IItemContainerRepository, ISfsBulkRepositoryBase<ItemContainer> |
||||
|
{ |
||||
|
public ItemContainerEfCoreRepository(IDbContextProvider<BasedataDbContext> dbContextProvider) : base(dbContextProvider) |
||||
|
{ |
||||
|
|
||||
|
} |
||||
|
|
||||
|
public virtual async Task UpsertAsync(ItemContainer entity) |
||||
|
{ |
||||
|
var dbSet = await GetDbSetAsync().ConfigureAwait(false); |
||||
|
var exist = await dbSet.FirstOrDefaultAsync(p => p.ItemCode == entity.ItemCode).ConfigureAwait(false); |
||||
|
if (exist == null) |
||||
|
{ |
||||
|
var insRet = await InsertAsync(entity).ConfigureAwait(false); |
||||
|
} |
||||
|
else |
||||
|
{ |
||||
|
exist.ContainerName = entity.ContainerName; |
||||
|
exist.ContainerCode = entity.ContainerCode; |
||||
|
exist.BasicUom = entity.BasicUom; |
||||
|
exist.Qty = entity.Qty; |
||||
|
} |
||||
|
} |
||||
|
} |
@ -0,0 +1,13 @@ |
|||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Linq; |
||||
|
using System.Text; |
||||
|
using System.Threading.Tasks; |
||||
|
|
||||
|
namespace Win_in.Sfs.Shared.Domain.Shared.Enums.Store.Types; |
||||
|
public enum EnumMesType |
||||
|
{ |
||||
|
MesFreeze=10001, |
||||
|
MesUnFreeze=10002, |
||||
|
MesUnQualified=10003 |
||||
|
} |
@ -0,0 +1,22 @@ |
|||||
|
using AutoMapper; |
||||
|
using Volo.Abp.AutoMapper; |
||||
|
using Win_in.Sfs.Wms.Inventory.Application.Contracts; |
||||
|
using Win_in.Sfs.Wms.Store.Domain; |
||||
|
|
||||
|
namespace Win_in.Sfs.Wms.Store.Event; |
||||
|
|
||||
|
public partial class StoreEventAutoMapperProfile : Profile |
||||
|
{ |
||||
|
private void ContainerNoteAutoMapperProfile() |
||||
|
{ |
||||
|
CreateMap<ContainerNoteDetail, TransferLogEditInput>() |
||||
|
.Ignore(x => x.DocNumber) |
||||
|
.Ignore(x => x.JobNumber) |
||||
|
.Ignore(x => x.Worker) |
||||
|
.Ignore(x => x.TransType) |
||||
|
.Ignore(x => x.ExtraProperties) |
||||
|
.Ignore(x => x.TransSubType) |
||||
|
; |
||||
|
} |
||||
|
|
||||
|
} |
@ -0,0 +1,159 @@ |
|||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Linq; |
||||
|
using System.Threading.Tasks; |
||||
|
using Volo.Abp.EventBus; |
||||
|
using Volo.Abp.Uow; |
||||
|
using Win_in.Sfs.Basedata.Application.Contracts; |
||||
|
using Win_in.Sfs.Shared.Domain.Shared; |
||||
|
using Win_in.Sfs.Shared.Event; |
||||
|
using Win_in.Sfs.Wms.Inventory.Application.Contracts; |
||||
|
using Win_in.Sfs.Wms.Store.Domain; |
||||
|
using Win_in.Sfs.Wms.Store.Event.Transaction; |
||||
|
using Win_in.Sfs.Wms.Store.Notes.IssueNotes; |
||||
|
|
||||
|
namespace Win_in.Sfs.Wms.Store.Event.Transactions; |
||||
|
|
||||
|
public class CoatingIssueNoteEventHandler |
||||
|
: StoreInventoryEventHandlerBase |
||||
|
, ILocalEventHandler<SfsCreatedEntityEventData<CoatingIssueNote>> |
||||
|
, ILocalEventHandler<SfsCreatedEntityEventData<List<CoatingIssueNote>>> |
||||
|
, ILocalEventHandler<SfsConfirmedEntityEventData<CoatingIssueNote>> |
||||
|
{ |
||||
|
private const EnumTransType TransType = EnumTransType.Issue; |
||||
|
|
||||
|
private readonly ILocationAppService _locationAppService; |
||||
|
|
||||
|
public CoatingIssueNoteEventHandler(ILocationAppService locationAppService) |
||||
|
{ |
||||
|
_locationAppService = locationAppService; |
||||
|
} |
||||
|
|
||||
|
[UnitOfWork] |
||||
|
public virtual async Task HandleEventAsync(SfsCreatedEntityEventData<CoatingIssueNote> eventData) |
||||
|
{ |
||||
|
var entity = eventData.Entity; |
||||
|
var transferLogs = new List<TransferLogEditInput>(); |
||||
|
var route = entity.UseOnTheWayLocation |
||||
|
? EnumTransferRoute.SourceToOnTheWay |
||||
|
: EnumTransferRoute.SourceToDestination; |
||||
|
transferLogs.AddRange(await BuildTransferLogsAsync(entity, route).ConfigureAwait(false)); |
||||
|
|
||||
|
//如果是mes拉动 先发到在途
|
||||
|
if (entity.RequestType == EnumMaterialRequestType.Issue_WIP.ToString()) |
||||
|
{ |
||||
|
route = EnumTransferRoute.SourceToOnTheWay; |
||||
|
} |
||||
|
|
||||
|
await TransferLogAppService.AddManyAsync(transferLogs).ConfigureAwait(false); |
||||
|
} |
||||
|
|
||||
|
[UnitOfWork] |
||||
|
public virtual async Task HandleEventAsync(SfsCreatedEntityEventData<List<CoatingIssueNote>> eventData) |
||||
|
{ |
||||
|
var entities = eventData.Entity; |
||||
|
var transferLogs = new List<TransferLogEditInput>(); |
||||
|
//如果要做库存事务汇总,可以修改此处
|
||||
|
foreach (var CoatingIssueNote in entities) |
||||
|
{ |
||||
|
var route = CoatingIssueNote.UseOnTheWayLocation |
||||
|
? EnumTransferRoute.SourceToOnTheWay |
||||
|
: EnumTransferRoute.SourceToDestination; |
||||
|
transferLogs.AddRange(await BuildTransferLogsAsync(CoatingIssueNote, route).ConfigureAwait(false)); |
||||
|
} |
||||
|
|
||||
|
await TransferLogAppService.AddManyAsync(transferLogs).ConfigureAwait(false); |
||||
|
} |
||||
|
|
||||
|
[UnitOfWork] |
||||
|
|
||||
|
public virtual async Task HandleEventAsync(SfsConfirmedEntityEventData<CoatingIssueNote> eventData) |
||||
|
{ |
||||
|
var entity = eventData.Entity; |
||||
|
|
||||
|
var inputList = await BuildTransferLogsAsync(entity, EnumTransferRoute.OnTheWayToDestination).ConfigureAwait(false); |
||||
|
await AddTransferLogsAsync(inputList).ConfigureAwait(false); |
||||
|
} |
||||
|
|
||||
|
private async Task AddTransferLogsAsync(List<TransferLogEditInput> inputList) |
||||
|
{ |
||||
|
var transferLogs = new List<TransferLogEditInput>(); |
||||
|
|
||||
|
transferLogs.AddRange(inputList); |
||||
|
|
||||
|
await TransferLogAppService.AddManyAsync(transferLogs).ConfigureAwait(false); |
||||
|
|
||||
|
} |
||||
|
|
||||
|
private async Task<List<TransferLogEditInput>> BuildTransferLogsAsync(CoatingIssueNote CoatingIssueNote, EnumTransferRoute route) |
||||
|
{ |
||||
|
var transferLogs = new List<TransferLogEditInput>(); |
||||
|
foreach (var detail in CoatingIssueNote.Details.Where(detail => detail.Qty != 0)) |
||||
|
{ |
||||
|
var transferLog = ObjectMapper.Map<CoatingIssueNoteDetail, TransferLogEditInput>(detail); |
||||
|
|
||||
|
LocationDTO fromLocationDTO = null; |
||||
|
LocationDTO toLocationDTO = null; |
||||
|
|
||||
|
if (CoatingIssueNote.UseOnTheWayLocation) |
||||
|
{ |
||||
|
var location = await _locationAppService.GetByCodeAsync(detail.OnTheWayLocationCode).ConfigureAwait(false); |
||||
|
switch (route) |
||||
|
{ |
||||
|
case EnumTransferRoute.SourceToOnTheWay: |
||||
|
fromLocationDTO = await _locationAppService.GetByCodeAsync(detail.FromLocationCode).ConfigureAwait(false); |
||||
|
|
||||
|
toLocationDTO = await _locationAppService.GetByCodeAsync(detail.OnTheWayLocationCode).ConfigureAwait(false); |
||||
|
break; |
||||
|
case EnumTransferRoute.OnTheWayToDestination: |
||||
|
fromLocationDTO = await _locationAppService.GetByCodeAsync(detail.OnTheWayLocationCode).ConfigureAwait(false); |
||||
|
|
||||
|
toLocationDTO = await _locationAppService.GetByCodeAsync(detail.ToLocationCode).ConfigureAwait(false); |
||||
|
|
||||
|
await RemovePackingCodeAndContainerCodeAndLotAsync(transferLog).ConfigureAwait(false); |
||||
|
break; |
||||
|
case EnumTransferRoute.SourceToDestination: |
||||
|
default: |
||||
|
throw new ArgumentOutOfRangeException(nameof(route), route, null); |
||||
|
} |
||||
|
} |
||||
|
else |
||||
|
{ |
||||
|
fromLocationDTO = await _locationAppService.GetByCodeAsync(detail.FromLocationCode).ConfigureAwait(false); |
||||
|
toLocationDTO = await _locationAppService.GetByCodeAsync(detail.ToLocationCode).ConfigureAwait(false); |
||||
|
} |
||||
|
|
||||
|
transferLog.FromLocationCode = fromLocationDTO.Code; |
||||
|
transferLog.FromLocationArea = fromLocationDTO.AreaCode; |
||||
|
transferLog.FromLocationErpCode = fromLocationDTO.ErpLocationCode; |
||||
|
transferLog.FromLocationGroup = fromLocationDTO.LocationGroupCode; |
||||
|
|
||||
|
transferLog.ToLocationCode = toLocationDTO.Code; |
||||
|
transferLog.ToLocationArea = toLocationDTO.AreaCode; |
||||
|
transferLog.ToLocationErpCode = toLocationDTO.ErpLocationCode; |
||||
|
transferLog.ToLocationGroup = toLocationDTO.LocationGroupCode; |
||||
|
transferLog.TransSubType = Enum.Parse<EnumTransSubType>(CoatingIssueNote.RequestType); |
||||
|
transferLog.TransType = TransType; |
||||
|
transferLog.DocNumber = CoatingIssueNote.Number; |
||||
|
transferLog.JobNumber = CoatingIssueNote.JobNumber; |
||||
|
|
||||
|
transferLogs.Add(transferLog); |
||||
|
} |
||||
|
|
||||
|
return transferLogs; |
||||
|
} |
||||
|
|
||||
|
private async Task RemovePackingCodeAndContainerCodeAndLotAsync(TransferLogEditInput transferLogCreateInput) |
||||
|
{ |
||||
|
transferLogCreateInput.ToPackingCode = ""; |
||||
|
transferLogCreateInput.ToLot = ""; |
||||
|
transferLogCreateInput.ToContainerCode = ""; |
||||
|
|
||||
|
transferLogCreateInput.FromPackingCode = ""; |
||||
|
transferLogCreateInput.FromLot = ""; |
||||
|
transferLogCreateInput.FromContainerCode = ""; |
||||
|
|
||||
|
|
||||
|
} |
||||
|
|
||||
|
} |
Loading…
Reference in new issue