Browse Source

添加库存事务枚举

dev_DY_CC
赵新宇 1 year ago
parent
commit
405427b6f4
  1. 9
      be/Modules/Shared/src/Win_in.Sfs.Shared.Domain.Shared/Enums/Inventory/EnumTransSubType.cs
  2. 13
      be/Modules/Shared/src/Win_in.Sfs.Shared.Domain.Shared/Enums/Store/Types/EnumMesType.cs
  3. 8
      be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Notes/MesNotes/DTOs/MesNoteDTO.cs
  4. 11
      be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Notes/MesNotes/Inputs/MesNoteEditInput.cs
  5. 4
      be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Notes/MesNotes/Inputs/MesNoteImportInput.cs
  6. 3
      be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Notes/MesNotes/MesNote.cs
  7. 2
      be/Modules/Store/src/Win_in.Sfs.Wms.Store.EntityFrameworkCore/Notes/MesNotes/MesNoteDbContextModelCreatingExtensions.cs
  8. 159
      be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Transactions/CoatingIssueNoteEventHandler.cs

9
be/Modules/Shared/src/Win_in.Sfs.Shared.Domain.Shared/Enums/Inventory/EnumTransSubType.cs

@ -198,4 +198,13 @@ public enum EnumTransSubType
/// </summary>
[Display(Name = "导入盘点计划")]
ExcelInCountPlan = 6002,
[Display(Name = "MES冻结")]
MesFreeze = 10001,
[Display(Name = "MES解冻")]
MesUnFreeze = 10002,
[Display(Name = "MES不合格")]
MesUnQualified = 10003
}

13
be/Modules/Shared/src/Win_in.Sfs.Shared.Domain.Shared/Enums/Store/Types/EnumMesType.cs

@ -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
}

8
be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Notes/MesNotes/DTOs/MesNoteDTO.cs

@ -12,15 +12,15 @@ public class MesNoteDTO : SfsStoreDTOBase<MesNoteDetailDTO>, IHasNumber
public string JobNumber { get; set; }
/// <summary>
/// 报废类型
/// 类型
/// </summary>
[Display(Name = "报废类型")]
[Display(Name = "类型")]
public string Type { get; set; }
/// <summary>
/// 报废请求单号
/// 请求单号
/// </summary>
[Display(Name = "报废请求单号")]
[Display(Name = "请求单号")]
public string ScrapRequestNumber { get; set; }
}

11
be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Notes/MesNotes/Inputs/MesNoteEditInput.cs

@ -1,6 +1,7 @@
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using Win_in.Sfs.Shared.Domain;
using Win_in.Sfs.Shared.Domain.Shared.Enums.Store.Types;
namespace Win_in.Sfs.Wms.Store.Application.Contracts;
@ -16,20 +17,20 @@ public class MesNoteEditInput : SfsStoreCreateOrUpdateInputBase
/// <summary>
/// 报废记录号
/// </summary>
[Display(Name = "报废记录号")]
[Display(Name = "记录号")]
[StringLength(SfsEfCorePropertyConst.CodeLength, ErrorMessage = "{0}最多输入{1}个字符")]
public string Number { get; set; }
/// <summary>
/// 报废请求单号
/// 请求单号
/// </summary>
[Display(Name = "报废请求单号")]
public string ScrapRequestNumber { get; set; }
[Display(Name = "请求单号")]
public string MesRequestNumber { get; set; }
/// <summary>
/// 报废类型
/// </summary>
[Display(Name = "报废类型")]
[Display(Name = "类型")]
public string Type { get; set; }
/// <summary>

4
be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Notes/MesNotes/Inputs/MesNoteImportInput.cs

@ -14,7 +14,7 @@ public class MesNoteImportInput : SfsStoreImportInputBase
/// <summary>
/// 报废请求单号
/// </summary>
[Display(Name = "报废请求单号")]
public string ScrapRequestNumber { get; set; }
[Display(Name = "请求单号")]
public string MesRequestNumber { get; set; }
}

3
be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Notes/MesNotes/MesNote.cs

@ -1,5 +1,6 @@
using System.Collections.Generic;
using Win_in.Sfs.Shared.Domain.Entities;
using Win_in.Sfs.Shared.Domain.Shared.Enums.Store.Types;
namespace Win_in.Sfs.Wms.Store.Domain;
@ -18,7 +19,7 @@ public class MesNote : SfsStoreAggregateRootBase<MesNoteDetail>, IHasJobNumber
/// 报废请求单号
/// </summary>
[IgnoreUpdate]
public string ScrapRequestNumber { get; set; }
public string MesRequestNumber { get; set; }
/// <summary>
/// Mes类型

2
be/Modules/Store/src/Win_in.Sfs.Wms.Store.EntityFrameworkCore/Notes/MesNotes/MesNoteDbContextModelCreatingExtensions.cs

@ -20,7 +20,7 @@ public static class MesNoteDbContextModelCreatingExtensions
//Properties
b.Property(q => q.Type).HasMaxLength(SfsPropertyConst.CodeLength);
b.Property(q => q.ScrapRequestNumber).HasMaxLength(SfsPropertyConst.CodeLength);
b.Property(q => q.MesRequestNumber).HasMaxLength(SfsPropertyConst.CodeLength);
//Relations
b.HasMany(q => q.Details).WithOne().HasForeignKey(d => d.MasterID).IsRequired();

159
be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Transactions/CoatingIssueNoteEventHandler.cs

@ -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…
Cancel
Save