39 changed files with 915 additions and 77 deletions
@ -0,0 +1,13 @@ |
|||
using Win_in.Sfs.Wms.DataExchange.Dapper.Fawtyg.Tyrp; |
|||
using Win_in.Sfs.Wms.DataExchange.Dapper.Fawtyg.Tyrp.Bases; |
|||
using Win_in.Sfs.Wms.DataExchange.Domain.Fawtyg.Tyrp; |
|||
|
|||
namespace Win_in.Sfs.Wms.DataExchange.LinqToDB.Fawtyg.Tyrp.ErpLocations; |
|||
|
|||
public class ErpLocationLinq2DbRepository : Linq2DbCrudRepository<locmout>, IErpLocationLinq2DbRepository |
|||
{ |
|||
public ErpLocationLinq2DbRepository(TyrpDb tyrpDb) : base(tyrpDb) |
|||
{ |
|||
|
|||
} |
|||
} |
@ -0,0 +1,22 @@ |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using System.Threading.Tasks; |
|||
using Volo.Abp.Domain.Services; |
|||
|
|||
namespace Win_in.Sfs.Wms.DataExchange.Domain.Fawtyg.Tyrp; |
|||
|
|||
public class ErpLocationManager : DomainService, IErpLocationManager |
|||
{ |
|||
private readonly IErpLocationLinq2DbRepository _repository; |
|||
|
|||
public ErpLocationManager(IErpLocationLinq2DbRepository repository) |
|||
{ |
|||
_repository = repository; |
|||
} |
|||
public virtual async Task<List<locmout>> GetToBeProcessedListAsync() |
|||
{ |
|||
var products = await _repository.GetListAsync().ConfigureAwait(false); |
|||
return products.ToList(); |
|||
|
|||
} |
|||
} |
@ -0,0 +1,6 @@ |
|||
namespace Win_in.Sfs.Wms.DataExchange.Domain.Fawtyg.Tyrp; |
|||
|
|||
public interface IErpLocationLinq2DbRepository : ILinq2DbRepository<locmout> |
|||
{ |
|||
|
|||
} |
@ -0,0 +1,9 @@ |
|||
using System.Collections.Generic; |
|||
using System.Threading.Tasks; |
|||
|
|||
namespace Win_in.Sfs.Wms.DataExchange.Domain.Fawtyg.Tyrp; |
|||
|
|||
public interface IErpLocationManager |
|||
{ |
|||
Task<List<locmout>> GetToBeProcessedListAsync(); |
|||
} |
@ -0,0 +1,21 @@ |
|||
using Volo.Abp.Domain.Entities; |
|||
|
|||
namespace Win_in.Sfs.Wms.DataExchange.Domain.Fawtyg.Tyrp; |
|||
|
|||
public class locmout : Entity |
|||
{ |
|||
/// <summary>
|
|||
/// 库位
|
|||
/// </summary>
|
|||
public string locmout_loc { get; set; } |
|||
/// <summary>
|
|||
/// 库位类型
|
|||
/// </summary>
|
|||
public string locmout_stat2 { get; set; } |
|||
|
|||
|
|||
public override object[] GetKeys() |
|||
{ |
|||
return new object[] { locmout_loc }; |
|||
} |
|||
} |
@ -0,0 +1,69 @@ |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using System.Text.Json; |
|||
using System.Threading.Tasks; |
|||
using Microsoft.Extensions.Logging; |
|||
using Volo.Abp.ObjectMapping; |
|||
using Win_in.Sfs.Basedata.Application.Contracts; |
|||
using Win_in.Sfs.Wms.DataExchange.Domain; |
|||
using Win_in.Sfs.Wms.DataExchange.WMS.ErpLocation; |
|||
|
|||
namespace Win_in.Sfs.Wms.DataExchange.Fawtyg.TyrpAgent.Incoming; |
|||
|
|||
public class ErpLocationConverter : IIncomingConverter |
|||
{ |
|||
private readonly IIncomingToWmsManager _incomingToWmsManager; |
|||
private readonly IObjectMapper _objectMapper; |
|||
private readonly ILogger<ErpLocationConverter> _logger; |
|||
private readonly IIncomingFromExternalManager _incomingFromExternalManager; |
|||
|
|||
public ErpLocationConverter( |
|||
IIncomingToWmsManager incomingToWmsManager |
|||
, IObjectMapper objectMapper |
|||
, ILogger<ErpLocationConverter> logger, |
|||
IIncomingFromExternalManager incomingFromExternalManager) |
|||
{ |
|||
_incomingToWmsManager = incomingToWmsManager; |
|||
_objectMapper = objectMapper; |
|||
_logger = logger; |
|||
_incomingFromExternalManager = incomingFromExternalManager; |
|||
} |
|||
|
|||
public virtual async Task ConvertAsync(List<IncomingFromExternal> incomingFromExternalList) |
|||
{ |
|||
if (!incomingFromExternalList.Any()) |
|||
{ |
|||
_logger.LogInformation("No ErpLocations"); |
|||
return; |
|||
} |
|||
|
|||
//按流水号创建单据
|
|||
var erpLocationRequestList = await BuildIncomingToWmsOfErpLocationRequestAsync(incomingFromExternalList).ConfigureAwait(false); |
|||
await _incomingToWmsManager.CreateManyAsync(erpLocationRequestList).ConfigureAwait(false); |
|||
//归档
|
|||
await _incomingFromExternalManager.ArchiveManyAsync(incomingFromExternalList).ConfigureAwait(false); |
|||
} |
|||
|
|||
private async Task<List<IncomingToWms>> BuildIncomingToWmsOfErpLocationRequestAsync(List<IncomingFromExternal> incomingDataList) |
|||
{ |
|||
await Task.CompletedTask.ConfigureAwait(false); |
|||
var incomingToWmsList = new List<IncomingToWms>(); |
|||
foreach (var item in incomingDataList) |
|||
{ |
|||
var incomingToWms = new IncomingToWms() |
|||
{ |
|||
DataType = item.DataType, |
|||
DataAction = item.DataAction, |
|||
SourceSystem = item.SourceSystem, |
|||
DataIdentityCode = item.SourceDataGroupCode, |
|||
}; |
|||
incomingToWms.SetEffectiveDate(item.EffectiveDate); |
|||
var exchangeErpLocationRequest = JsonSerializer.Deserialize<ErpLocationExchangeDto>(item.DestinationDataContent); |
|||
var wmsErpLocationRequest = _objectMapper.Map<ErpLocationExchangeDto, ErpLocationEditInput>(exchangeErpLocationRequest); |
|||
incomingToWms.DataContent = JsonSerializer.Serialize(wmsErpLocationRequest); |
|||
incomingToWmsList.Add(incomingToWms); |
|||
} |
|||
return incomingToWmsList; |
|||
} |
|||
|
|||
} |
@ -0,0 +1,106 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using System.Text.Json; |
|||
using System.Threading.Tasks; |
|||
using Microsoft.Extensions.Logging; |
|||
using Win_in.Sfs.Wms.DataExchange.Domain; |
|||
using Win_in.Sfs.Wms.DataExchange.Domain.Fawtyg.Tyrp; |
|||
using Win_in.Sfs.Wms.DataExchange.Domain.Shared; |
|||
using Win_in.Sfs.Wms.DataExchange.WMS.ErpLocation; |
|||
|
|||
namespace Win_in.Sfs.Wms.DataExchange.Fawtyg.TyrpAgent.Incoming; |
|||
|
|||
public class ErpLocationReader : IReader |
|||
{ |
|||
private readonly IErpLocationManager _erpLocationManager; |
|||
private readonly IIncomingFromExternalManager _incomingFromExternalManager; |
|||
private readonly ILogger<ErpLocationReader> _logger; |
|||
|
|||
public ErpLocationReader( |
|||
IErpLocationManager erpLocationManager |
|||
, IIncomingFromExternalManager incomingFromExternalManager |
|||
, ILogger<ErpLocationReader> logger |
|||
) |
|||
{ |
|||
_erpLocationManager = erpLocationManager; |
|||
_incomingFromExternalManager = incomingFromExternalManager; |
|||
_logger = logger; |
|||
} |
|||
|
|||
public virtual async Task<List<IncomingFromExternal>> ReadAsync() |
|||
{ |
|||
//从MES读取待处理locmout
|
|||
var toBeProcessedDatas = await _erpLocationManager.GetToBeProcessedListAsync().ConfigureAwait(false); |
|||
if (!toBeProcessedDatas.Any()) |
|||
{ |
|||
_logger.LogInformation("no erpLocations"); |
|||
return new List<IncomingFromExternal>(); |
|||
} |
|||
//locmout逐一转换为ErpLocation
|
|||
var incomingDataList = BuildIncomingFromExternalFromShipAsync(toBeProcessedDatas); |
|||
await _incomingFromExternalManager.CreateManyAsync(incomingDataList).ConfigureAwait(false); |
|||
|
|||
return incomingDataList; |
|||
} |
|||
|
|||
private static List<IncomingFromExternal> BuildIncomingFromExternalFromShipAsync(List<locmout> toBeProcessedDatas) |
|||
{ |
|||
var incomingDataList = new List<IncomingFromExternal>(); |
|||
foreach (var item in toBeProcessedDatas) |
|||
{ |
|||
var incomingData = BuildIncomingFromExternal(item); |
|||
|
|||
incomingData.SetEffectiveDate(DateTime.Now); |
|||
incomingData.SetSuccess(); |
|||
try |
|||
{ |
|||
var erpLocationNote = BuildErpLocationCreateInput(item); |
|||
incomingData.DestinationDataContent = JsonSerializer.Serialize(erpLocationNote); |
|||
} |
|||
catch (Exception ex) |
|||
{ |
|||
incomingData.SetError(EnumExchangeDataErrorCode.Exception, ex.Message, ex.ToString()); |
|||
} |
|||
|
|||
incomingDataList.Add(incomingData); |
|||
|
|||
} |
|||
|
|||
return incomingDataList; |
|||
} |
|||
|
|||
private static IncomingFromExternal BuildIncomingFromExternal(locmout locmout) |
|||
{ |
|||
var incomingData = new IncomingFromExternal() |
|||
{ |
|||
DataType = EnumIncomingDataType.ErpLocation.ToString(), |
|||
DataAction = EnumExchangeDataAction.Add, |
|||
SourceSystem = EnumSystemType.ERP.ToString(), |
|||
SourceDataId = locmout.locmout_loc, |
|||
SourceDataGroupCode = locmout.locmout_loc, |
|||
SourceDataDetailCode = locmout.locmout_loc, |
|||
SourceDataContent = JsonSerializer.Serialize(locmout), |
|||
WriteTime = DateTime.Now, |
|||
Writer = nameof(TyrpIncomingBackgroundWorker), |
|||
|
|||
DestinationSystem = EnumSystemType.WMS.ToString(), |
|||
}; |
|||
return incomingData; |
|||
} |
|||
|
|||
private static ErpLocationExchangeDto BuildErpLocationCreateInput(locmout locmout) |
|||
{ |
|||
|
|||
var erpLocation = new ErpLocationExchangeDto() |
|||
{ |
|||
Code = locmout.locmout_loc, |
|||
Name = locmout.locmout_loc, |
|||
Type = locmout.locmout_stat2, |
|||
WarehouseCode = locmout.locmout_stat2, |
|||
|
|||
}; |
|||
return erpLocation; |
|||
} |
|||
|
|||
} |
@ -0,0 +1,48 @@ |
|||
using System.ComponentModel.DataAnnotations; |
|||
using Win_in.Sfs.Shared.Domain; |
|||
|
|||
namespace Win_in.Sfs.Wms.DataExchange.WMS.ErpLocation; |
|||
|
|||
public class ErpLocationExchangeDto |
|||
{ |
|||
/// <summary>
|
|||
/// 代码
|
|||
/// </summary>
|
|||
|
|||
[Display(Name = "代码")] |
|||
[Required] |
|||
[StringLength(SfsEfCorePropertyConst.CodeLength, ErrorMessage = "{0}最多输入{1}个字符")] |
|||
public string Code { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 名称
|
|||
/// </summary>
|
|||
[Display(Name = "名称")] |
|||
[Required(ErrorMessage = "{0}是必填项")] |
|||
[StringLength(SfsEfCorePropertyConst.CodeLength, ErrorMessage = "{0}最多输入{1}个字符")] |
|||
public string Name { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 描述
|
|||
/// </summary>
|
|||
[Display(Name = "描述")] |
|||
[StringLength(SfsEfCorePropertyConst.NameLength, ErrorMessage = "{0}最多输入{1}个字符")] |
|||
public string Description { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 类型
|
|||
/// </summary>
|
|||
[Display(Name = "类型")] |
|||
[Required(ErrorMessage = "{0}是必填项")] |
|||
[StringLength(SfsEfCorePropertyConst.CodeLength, ErrorMessage = "{0}最多输入{1}个字符")] |
|||
public string Type { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 仓库代码
|
|||
/// </summary>
|
|||
[Display(Name = "仓库代码")] |
|||
[StringLength(SfsEfCorePropertyConst.CodeLength, ErrorMessage = "{0}最多输入{1}个字符")] |
|||
public string WarehouseCode { get; set; } |
|||
|
|||
|
|||
} |
@ -0,0 +1,73 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using System.Text; |
|||
using System.Threading.Tasks; |
|||
|
|||
using System.Collections.Generic; |
|||
|
|||
namespace Win_in.Sfs.Basedata.Domain.Shared; |
|||
|
|||
public class SingletonCacheList<T> |
|||
{ |
|||
private static volatile SingletonCacheList<T> instance; |
|||
private static object syncRoot = new object(); |
|||
private List<T> cacheList; |
|||
|
|||
private SingletonCacheList() |
|||
{ |
|||
cacheList = new List<T>(); |
|||
} |
|||
|
|||
public static SingletonCacheList<T> Instance |
|||
{ |
|||
get |
|||
{ |
|||
if (instance == null) |
|||
{ |
|||
lock (syncRoot) |
|||
{ |
|||
if (instance == null) |
|||
{ |
|||
instance = new SingletonCacheList<T>(); |
|||
} |
|||
} |
|||
} |
|||
|
|||
return instance; |
|||
} |
|||
} |
|||
|
|||
public void Add(T item) |
|||
{ |
|||
cacheList.Add(item); |
|||
} |
|||
|
|||
public void Remove(T item) |
|||
{ |
|||
cacheList.Remove(item); |
|||
} |
|||
|
|||
public bool Contains(T item) |
|||
{ |
|||
return cacheList.Contains(item); |
|||
} |
|||
|
|||
public T this[int index] |
|||
{ |
|||
get |
|||
{ |
|||
return cacheList[index]; |
|||
} |
|||
set |
|||
{ |
|||
cacheList[index] = value; |
|||
} |
|||
} |
|||
public int Count() |
|||
{ |
|||
return cacheList.Count(); |
|||
} |
|||
} |
|||
|
|||
|
@ -0,0 +1,13 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using System.Text; |
|||
using System.Threading.Tasks; |
|||
using Win_in.Sfs.Basedata.Domain; |
|||
|
|||
namespace Win_in.Sfs.Basedata.Caches; |
|||
public static class Cache |
|||
{ |
|||
public static List<Bom> Boms = new List<Bom>(); |
|||
|
|||
} |
@ -0,0 +1,20 @@ |
|||
using Volo.Abp.Authorization.Permissions; |
|||
using Win_in.Sfs.Wms.Store.Domain; |
|||
|
|||
namespace Win_in.Sfs.Wms.Store.Application.Contracts; |
|||
|
|||
public static class CustomerProductionReturnNotePermissions |
|||
{ |
|||
public const string Default = StorePermissions.GroupName + "." + nameof(CustomerProductionReturnNote); |
|||
public const string Create = Default + "." + StorePermissions.CreateStr; |
|||
public const string Update = Default + "." + StorePermissions.UpdateStr; |
|||
public const string Delete = Default + "." + StorePermissions.DeleteStr; |
|||
|
|||
public static void AddCustomerProductionReturnNotePermission(this PermissionGroupDefinition permissionGroup) |
|||
{ |
|||
var CustomerProductionReturnNotePermission = permissionGroup.AddPermission(Default, StorePermissionDefinitionProvider.L(nameof(CustomerProductionReturnNote))); |
|||
CustomerProductionReturnNotePermission.AddChild(Create, StorePermissionDefinitionProvider.L(StorePermissions.CreateStr)); |
|||
CustomerProductionReturnNotePermission.AddChild(Update, StorePermissionDefinitionProvider.L(StorePermissions.UpdateStr)); |
|||
CustomerProductionReturnNotePermission.AddChild(Delete, StorePermissionDefinitionProvider.L(StorePermissions.DeleteStr)); |
|||
} |
|||
} |
@ -0,0 +1,29 @@ |
|||
using System; |
|||
using System.ComponentModel.DataAnnotations; |
|||
|
|||
namespace Win_in.Sfs.Wms.Store.Application.Contracts; |
|||
|
|||
/// <summary>
|
|||
/// 退库记录-实体DTO
|
|||
/// </summary>
|
|||
[Display(Name = "退库记录")] |
|||
public class CustomerProductionReturnNoteDTO : SfsStoreDTOBase<CustomerProductionReturnNoteDetailDTO> |
|||
{ |
|||
/// <summary>
|
|||
/// 任务ID
|
|||
/// </summary>
|
|||
[Display(Name = "任务ID")] |
|||
public string JobNumber { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 退料单号
|
|||
/// </summary>
|
|||
[Display(Name = "退料单号")] |
|||
public string ProductionReturnRequestNumber { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 退料时间
|
|||
/// </summary>
|
|||
[Display(Name = "退料时间")] |
|||
public DateTime ReturnTime { get; set; } |
|||
} |
@ -0,0 +1,9 @@ |
|||
namespace Win_in.Sfs.Wms.Store.Application.Contracts; |
|||
|
|||
/// <summary>
|
|||
/// 退库记录-明细表-实体DTO
|
|||
/// </summary>
|
|||
public class CustomerProductionReturnNoteDetailDTO : SfsStoreRecommendToDetailWithFromToDTOBase |
|||
{ |
|||
|
|||
} |
@ -0,0 +1,9 @@ |
|||
using System.Threading.Tasks; |
|||
|
|||
namespace Win_in.Sfs.Wms.Store.Application.Contracts; |
|||
|
|||
public interface ICustomerProductionReturnNoteAppService : |
|||
ISfsStoreMasterReadOnlyAppServiceBase<CustomerProductionReturnNoteDTO, SfsStoreRequestInputBase, CustomerProductionReturnNoteDetailDTO, SfsStoreRequestInputBase> |
|||
{ |
|||
Task<CustomerProductionReturnNoteDTO> CreateAsync(CustomerProductionReturnNoteEditInput input); |
|||
} |
@ -0,0 +1,9 @@ |
|||
namespace Win_in.Sfs.Wms.Store.Application.Contracts; |
|||
|
|||
/// <summary>
|
|||
/// 退库记录-明细表-实体DTO
|
|||
/// </summary>
|
|||
public class CustomerProductionReturnNoteDetailInput : SfsStoreRecommendToDetailWithFromToDTOBase |
|||
{ |
|||
|
|||
} |
@ -0,0 +1,47 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.ComponentModel.DataAnnotations; |
|||
using Win_in.Sfs.Shared.Domain; |
|||
|
|||
namespace Win_in.Sfs.Wms.Store.Application.Contracts; |
|||
|
|||
/// <summary>
|
|||
/// 退库记录-新增和更新基础DTO
|
|||
/// </summary>
|
|||
public class CustomerProductionReturnNoteEditInput : SfsStoreCreateOrUpdateInputBase |
|||
{ |
|||
#region Base
|
|||
/// <summary>
|
|||
/// 任务ID
|
|||
/// </summary>
|
|||
[Display(Name = "任务ID")] |
|||
public string JobNumber { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 退料时间
|
|||
/// </summary>
|
|||
[Display(Name = "退料时间")] |
|||
public DateTime ReturnTime { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 退料申请单号
|
|||
/// </summary>
|
|||
[Display(Name = "退料申请单号")] |
|||
public string ProductionReturnRequestNumber { get; set; } |
|||
#endregion
|
|||
|
|||
#region Create
|
|||
/// <summary>
|
|||
/// 退库记录单号
|
|||
/// </summary>
|
|||
[Display(Name = "退库记录单号")] |
|||
[StringLength(SfsEfCorePropertyConst.CodeLength, ErrorMessage = "{0}最多输入{1}个字符")] |
|||
public string Number { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 明细列表
|
|||
/// </summary>
|
|||
[Display(Name = "明细列表")] |
|||
public List<CustomerProductionReturnNoteDetailInput> Details { get; set; } |
|||
#endregion
|
|||
} |
@ -0,0 +1,34 @@ |
|||
using System; |
|||
using System.ComponentModel.DataAnnotations; |
|||
|
|||
namespace Win_in.Sfs.Wms.Store.Application.Contracts; |
|||
|
|||
/// <summary>
|
|||
/// 退库记录-实体DTO
|
|||
/// </summary>
|
|||
public class CustomerProductionReturnNoteImportInput : SfsStoreImportInputBase |
|||
{ |
|||
/// <summary>
|
|||
/// 任务ID
|
|||
/// </summary>
|
|||
[Display(Name = "任务ID")] |
|||
public string JobNumber { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 退料时间
|
|||
/// </summary>
|
|||
[Display(Name = "退料时间")] |
|||
public DateTime ReturnTime { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 退料单号
|
|||
/// </summary>
|
|||
[Display(Name = "退料单号")] |
|||
public string ProductionReturnRequestNumber { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 采购订单号
|
|||
/// </summary>
|
|||
[Display(Name = "采购订单号")] |
|||
public string PoNumber { get; set; } |
|||
} |
@ -0,0 +1,47 @@ |
|||
using System.Threading.Tasks; |
|||
using Microsoft.AspNetCore.Authorization; |
|||
using Microsoft.AspNetCore.Mvc; |
|||
using Win_in.Sfs.Wms.Store.Application.Contracts; |
|||
using Win_in.Sfs.Wms.Store.Domain; |
|||
using Win_in.Sfs.Wms.Store.Domain.Shared; |
|||
|
|||
namespace Win_in.Sfs.Wms.Store.Application; |
|||
|
|||
/// <summary>
|
|||
/// 退库记录
|
|||
/// </summary>
|
|||
[Authorize] |
|||
[Route($"{StoreConsts.RootPath}customer-production-return-note")] |
|||
public class CustomerProductionReturnNoteAppService : |
|||
SfsStoreWithDetailsAppServiceBase<CustomerProductionReturnNote, CustomerProductionReturnNoteDTO, SfsStoreRequestInputBase, CustomerProductionReturnNoteEditInput, |
|||
CustomerProductionReturnNoteDetail, CustomerProductionReturnNoteDetailDTO, SfsStoreRequestInputBase, CustomerProductionReturnNoteImportInput>, |
|||
ICustomerProductionReturnNoteAppService |
|||
{ |
|||
private readonly ICustomerProductionReturnNoteManager _CustomerProductionReturnNoteManager; |
|||
|
|||
public CustomerProductionReturnNoteAppService( |
|||
ICustomerProductionReturnNoteRepository repository |
|||
, ICustomerProductionReturnNoteManager CustomerProductionReturnNoteManager |
|||
) : base(repository) |
|||
{ |
|||
_CustomerProductionReturnNoteManager = CustomerProductionReturnNoteManager; |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// 新增实体
|
|||
/// </summary>
|
|||
/// <param name="input"></param>
|
|||
/// <returns></returns>
|
|||
[HttpPost("")] |
|||
//[Authorize(CustomerProductionReturnNotePermissions.Create)]
|
|||
public override async Task<CustomerProductionReturnNoteDTO> CreateAsync(CustomerProductionReturnNoteEditInput input) |
|||
{ |
|||
var entity = ObjectMapper.Map<CustomerProductionReturnNoteEditInput, CustomerProductionReturnNote>(input); |
|||
await _CustomerProductionReturnNoteManager.CreateAsync(entity).ConfigureAwait(false); |
|||
var dto = ObjectMapper.Map<CustomerProductionReturnNote, CustomerProductionReturnNoteDTO>(entity); |
|||
return dto; |
|||
} |
|||
|
|||
|
|||
|
|||
} |
@ -0,0 +1,34 @@ |
|||
using AutoMapper; |
|||
using Volo.Abp.AutoMapper; |
|||
using Win_in.Sfs.Wms.Store.Application.Contracts; |
|||
using Win_in.Sfs.Wms.Store.Domain; |
|||
|
|||
namespace Win_in.Sfs.Wms.Store.Application; |
|||
|
|||
public partial class StoreApplicationAutoMapperProfile : Profile |
|||
{ |
|||
private void CustomerProductionReturnNoteAutoMapperProfile() |
|||
{ |
|||
CreateMap<CustomerProductionReturnNote, CustomerProductionReturnNoteDTO>() |
|||
.ReverseMap(); |
|||
|
|||
CreateMap<CustomerProductionReturnNoteDetail, CustomerProductionReturnNoteDetailDTO>(); |
|||
|
|||
CreateMap<CustomerProductionReturnNoteEditInput, CustomerProductionReturnNote>(); |
|||
|
|||
CreateMap<CustomerProductionReturnNoteDetailInput, CustomerProductionReturnNoteDetail>() |
|||
.IgnoreAuditedObjectProperties() |
|||
.Ignore(x => x.MasterID) |
|||
.Ignore(x => x.TenantId) |
|||
.Ignore(x => x.Number) |
|||
.Ignore(x => x.Id); |
|||
CreateMap<CustomerProductionReturnNoteEditInput, CustomerProductionReturnNote>() |
|||
.IgnoreAuditedObjectProperties() |
|||
.Ignore(x => x.TenantId) |
|||
.Ignore(x => x.Number) |
|||
.Ignore(x => x.Id) |
|||
.Ignore(x=>x.Remark) |
|||
.Ignore(x=>x.ExtraProperties) |
|||
; |
|||
} |
|||
} |
@ -0,0 +1,33 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using Win_in.Sfs.Shared.Domain.Entities; |
|||
|
|||
namespace Win_in.Sfs.Wms.Store.Domain; |
|||
|
|||
/// <summary>
|
|||
/// 退库记录
|
|||
/// </summary>
|
|||
public class CustomerProductionReturnNote : SfsStoreAggregateRootBase<CustomerProductionReturnNoteDetail>, IHasJobNumber |
|||
{ |
|||
/// <summary>
|
|||
/// 任务ID
|
|||
/// </summary>
|
|||
[IgnoreUpdate] |
|||
public string JobNumber { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 退料单号
|
|||
/// </summary>
|
|||
public string ProductionReturnRequestNumber { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 退料时间
|
|||
/// </summary>
|
|||
public DateTime ReturnTime { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 明细列表
|
|||
/// </summary>
|
|||
[IgnoreUpdate] |
|||
public override List<CustomerProductionReturnNoteDetail> Details { get; set; } = new List<CustomerProductionReturnNoteDetail>(); |
|||
} |
@ -0,0 +1,8 @@ |
|||
namespace Win_in.Sfs.Wms.Store.Domain; |
|||
|
|||
/// <summary>
|
|||
/// 退库记录-明细表
|
|||
/// </summary>
|
|||
public class CustomerProductionReturnNoteDetail : SfsStoreRecommendToDetailWithFromToEntityBase |
|||
{ |
|||
} |
@ -0,0 +1,12 @@ |
|||
namespace Win_in.Sfs.Wms.Store.Domain; |
|||
|
|||
public class CustomerProductionReturnNoteManager : SfsStoreManagerBase<CustomerProductionReturnNote, CustomerProductionReturnNoteDetail>, |
|||
ICustomerProductionReturnNoteManager |
|||
{ |
|||
|
|||
public CustomerProductionReturnNoteManager( |
|||
ICustomerProductionReturnNoteRepository repository |
|||
) : base(repository) |
|||
{ |
|||
} |
|||
} |
@ -0,0 +1,5 @@ |
|||
namespace Win_in.Sfs.Wms.Store.Domain; |
|||
|
|||
public interface ICustomerProductionReturnNoteManager : ISfsStoreManager<CustomerProductionReturnNote, CustomerProductionReturnNoteDetail> |
|||
{ |
|||
} |
@ -0,0 +1,5 @@ |
|||
namespace Win_in.Sfs.Wms.Store.Domain; |
|||
|
|||
public interface ICustomerProductionReturnNoteRepository : ISfsStoreRepositoryBase<CustomerProductionReturnNote> |
|||
{ |
|||
} |
@ -0,0 +1,49 @@ |
|||
using Microsoft.EntityFrameworkCore; |
|||
using Volo.Abp.EntityFrameworkCore.Modeling; |
|||
using Win_in.Sfs.Shared.Domain.Shared; |
|||
using Win_in.Sfs.Wms.Store.Domain; |
|||
|
|||
namespace Win_in.Sfs.Wms.Store.EntityFrameworkCore; |
|||
|
|||
public static class CustomerProductionReturnNoteDbContextModelCreatingExtensions |
|||
{ |
|||
public static void ConfigureCustomerProductionReturnNote(this ModelBuilder builder, StoreModelBuilderConfigurationOptions options) |
|||
{ |
|||
builder.Entity<CustomerProductionReturnNote>(b => |
|||
{ |
|||
|
|||
//Configure table & schema name
|
|||
b.ToTable(options.TablePrefix + nameof(CustomerProductionReturnNote), options.Schema); |
|||
//Configure ABP properties
|
|||
b.ConfigureByConvention(); |
|||
//Configure Sfs base properties
|
|||
b.ConfigureSfsStoreBase(); |
|||
//Properties
|
|||
b.Property(q => q.JobNumber).HasMaxLength(SfsPropertyConst.CodeLength); |
|||
b.Property(q => q.ProductionReturnRequestNumber).HasMaxLength(SfsPropertyConst.CodeLength); |
|||
//Relations
|
|||
b.HasMany(q => q.Details).WithOne().HasForeignKey(d => d.MasterID).IsRequired(); |
|||
//Indexes
|
|||
b.HasIndex(q => new { q.Number }).IsUnique(); |
|||
}); |
|||
|
|||
builder.Entity<CustomerProductionReturnNoteDetail>(b => |
|||
{ |
|||
//Configure table & schema name
|
|||
b.ToTable(options.TablePrefix + nameof(CustomerProductionReturnNoteDetail), options.Schema); |
|||
//Configure ABP properties
|
|||
b.ConfigureByConvention(); |
|||
//Configure Sfs base properties
|
|||
b.ConfigureSfsStoreBase(); |
|||
//Configure Sfs store detail properties
|
|||
b.ConfigureSfsStoreDetailBase(); |
|||
//Properties
|
|||
b.Property(q => q.FromStatus).HasMaxLength(SfsPropertyConst.NameLength).HasConversion<string>(); |
|||
b.Property(q => q.ToStatus).HasMaxLength(SfsPropertyConst.NameLength).HasConversion<string>(); |
|||
//Relations
|
|||
|
|||
//Indexes
|
|||
b.HasIndex(q => new { q.Number, q.ItemCode, q.FromPackingCode, q.ToPackingCode, q.FromLocationCode, q.ToLocationCode }).IsUnique(); |
|||
}); |
|||
} |
|||
} |
@ -0,0 +1,13 @@ |
|||
using Volo.Abp.EntityFrameworkCore; |
|||
using Win_in.Sfs.Wms.Store.Domain; |
|||
|
|||
namespace Win_in.Sfs.Wms.Store.EntityFrameworkCore; |
|||
|
|||
public class CustomerProductionReturnNoteEfCoreRepository : SfsStoreEfCoreRepositoryBase<StoreDbContext, CustomerProductionReturnNote>, ICustomerProductionReturnNoteRepository |
|||
{ |
|||
public CustomerProductionReturnNoteEfCoreRepository(IDbContextProvider<StoreDbContext> dbContextProvider) : base(dbContextProvider) |
|||
{ |
|||
|
|||
|
|||
} |
|||
} |
@ -0,0 +1,23 @@ |
|||
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 CustomerProductionReturnNoteAutoMapperProfile() |
|||
{ |
|||
CreateMap<CustomerProductionReturnNoteDetail, TransferLogEditInput>() |
|||
|
|||
.ForMember(x => x.DocNumber, y => y.MapFrom(t => t.Number)) |
|||
.Ignore(x => x.JobNumber) |
|||
.Ignore(x => x.Worker) |
|||
.Ignore(x => x.TransType) |
|||
.Ignore(x => x.ExtraProperties) |
|||
.Ignore(x => x.TransSubType) |
|||
; |
|||
} |
|||
|
|||
} |
@ -0,0 +1,94 @@ |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using System.Threading.Tasks; |
|||
using Volo.Abp.EventBus; |
|||
using Volo.Abp.Uow; |
|||
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.Application.Contracts; |
|||
using Win_in.Sfs.Wms.Store.Domain; |
|||
using Win_in.Sfs.Wms.Store.Event.Transaction; |
|||
|
|||
namespace Win_in.Sfs.Wms.Store.Event.Transactions; |
|||
|
|||
public class CustomerProductionReturnNoteEventHandler |
|||
: StoreInventoryEventHandlerBase |
|||
, ILocalEventHandler<SfsCreatedEntityEventData<CustomerProductionReturnNote>> |
|||
, ILocalEventHandler<SfsCreatedEntityEventData<List<CustomerProductionReturnNote>>> |
|||
|
|||
|
|||
|
|||
|
|||
{ |
|||
private const EnumTransType TransType = EnumTransType.CustomerReturn; |
|||
|
|||
private readonly IProductionReturnRequestAppService _productionReturnRequestApp; |
|||
|
|||
public CustomerProductionReturnNoteEventHandler(IProductionReturnRequestAppService productionReturnRequestApp) |
|||
{ |
|||
this._productionReturnRequestApp = productionReturnRequestApp; |
|||
} |
|||
|
|||
[UnitOfWork] |
|||
public virtual async Task HandleEventAsync(SfsCreatedEntityEventData<CustomerProductionReturnNote> eventData) |
|||
{ |
|||
var entity = eventData.Entity; |
|||
await AddTransactionsAsync(entity).ConfigureAwait(false); |
|||
|
|||
if (!string.IsNullOrEmpty(entity.ProductionReturnRequestNumber)) |
|||
{ |
|||
await _productionReturnRequestApp.CompleteByNumberAsync(entity.ProductionReturnRequestNumber).ConfigureAwait(false); |
|||
} |
|||
} |
|||
|
|||
private async Task AddTransactionsAsync(CustomerProductionReturnNote CustomerProductionReturnNote) |
|||
{ |
|||
var inboundTransactions = new List<TransferLogEditInput>(); |
|||
|
|||
inboundTransactions.AddRange(BuildTransferLogs(CustomerProductionReturnNote)); |
|||
|
|||
await TransferLogAppService.AddManyAsync(inboundTransactions).ConfigureAwait(false); |
|||
|
|||
} |
|||
|
|||
[UnitOfWork] |
|||
public virtual async Task HandleEventAsync(SfsCreatedEntityEventData<List<CustomerProductionReturnNote>> eventData) |
|||
{ |
|||
var entities = eventData.Entity; |
|||
await AddTransactionsAsync(entities).ConfigureAwait(false); |
|||
} |
|||
|
|||
private async Task AddTransactionsAsync(List<CustomerProductionReturnNote> CustomerProductionReturnNotes) |
|||
{ |
|||
var inboundTransactions = new List<TransferLogEditInput>(); |
|||
|
|||
//如果要做库存事务汇总,可以修改此处
|
|||
foreach (var CustomerProductionReturnNote in CustomerProductionReturnNotes) |
|||
{ |
|||
inboundTransactions.AddRange(BuildTransferLogs(CustomerProductionReturnNote)); |
|||
} |
|||
|
|||
await TransferLogAppService.AddManyAsync(inboundTransactions).ConfigureAwait(false); |
|||
} |
|||
|
|||
private List<TransferLogEditInput> BuildTransferLogs(CustomerProductionReturnNote CustomerProductionReturnNote) |
|||
{ |
|||
var transferLogs = new List<TransferLogEditInput>(); |
|||
foreach (var detail in CustomerProductionReturnNote.Details.Where(detail => detail.Qty != 0)) |
|||
{ |
|||
var transferLog = ObjectMapper.Map<CustomerProductionReturnNoteDetail, TransferLogEditInput>(detail); |
|||
|
|||
transferLog.TransType = TransType; |
|||
|
|||
transferLog.Worker = CustomerProductionReturnNote.Worker; |
|||
transferLog.DocNumber = CustomerProductionReturnNote.Number; |
|||
transferLog.JobNumber = CustomerProductionReturnNote.JobNumber; |
|||
|
|||
transferLogs.Add(transferLog); |
|||
} |
|||
|
|||
return transferLogs; |
|||
} |
|||
|
|||
} |
Loading…
Reference in new issue