21 changed files with 663 additions and 27 deletions
@ -0,0 +1,49 @@ |
|||
using System.ComponentModel.DataAnnotations; |
|||
using Volo.Abp.Domain.Entities; |
|||
|
|||
namespace Win_in.Sfs.Wms.DataExchange.Domain.Fawtyg.Frozen; |
|||
public class Frozen : Entity |
|||
{ |
|||
/// <summary>
|
|||
/// 序号
|
|||
/// </summary>
|
|||
[Key] |
|||
public string mesout_frozen_id { get; set; } |
|||
/// <summary>
|
|||
/// 类型
|
|||
/// </summary>
|
|||
public string mesout_frozen_type { get; set; } |
|||
/// <summary>
|
|||
/// 物料
|
|||
/// </summary>
|
|||
public string mesout_frozen_part { get; set; } |
|||
/// <summary>
|
|||
/// 日期
|
|||
/// </summary>
|
|||
public string mesout_frozen_date { get; set; } |
|||
/// <summary>
|
|||
/// 来源库位
|
|||
/// </summary>
|
|||
public string mesout_frozen_loc { get; set; } |
|||
/// <summary>
|
|||
/// 冻结原因
|
|||
/// </summary>
|
|||
public string mesout_frozen_reason { get; set; } |
|||
/// <summary>
|
|||
/// 数量
|
|||
/// </summary>
|
|||
public decimal mesout_frozen_num { get; set; } |
|||
/// <summary>
|
|||
/// 冻结用户
|
|||
/// </summary>
|
|||
public string mesout_frozen_user { get; set; } |
|||
/// <summary>
|
|||
/// 是否读取(0,1)
|
|||
/// </summary>
|
|||
public long Yl1 { get; set; } |
|||
|
|||
public override object[] GetKeys() |
|||
{ |
|||
return new object[] { mesout_frozen_id }; |
|||
} |
|||
} |
@ -0,0 +1,45 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using System.Threading.Tasks; |
|||
using Volo.Abp.Domain.Services; |
|||
|
|||
namespace Win_in.Sfs.Wms.DataExchange.Domain.Fawtyg.Frozen; |
|||
public class FrozenManager : DomainService, IFrozenManager |
|||
{ |
|||
private readonly IFrozenRepository _repository; |
|||
|
|||
public FrozenManager(IFrozenRepository repository) |
|||
{ |
|||
_repository = repository; |
|||
} |
|||
public virtual async Task<List<Frozen>> GetToBeProcessedListAsync() |
|||
{ |
|||
var plans = await _repository.GetListAsync(p => p.Yl1 == 0).ConfigureAwait(false); |
|||
return plans; |
|||
|
|||
} |
|||
public virtual async Task UpdateProcesseErrordListAsync(List<Frozen> entities) |
|||
{ |
|||
var ids = entities.Select(p => p.mesout_frozen_id); |
|||
var plans = await _repository.GetListAsync(p => ids.Contains(p.mesout_frozen_id)).ConfigureAwait(false); |
|||
plans.ForEach(p => |
|||
{ |
|||
p.Yl1 = 2; |
|||
// p.WmsDate = Clock.Now;
|
|||
}); |
|||
await _repository.UpdateManyAsync(plans).ConfigureAwait(false); |
|||
} |
|||
public virtual async Task UpdateProcessedListAsync(List<Frozen> entities) |
|||
{ |
|||
var ids = entities.Select(p => p.mesout_frozen_id); |
|||
var plans = await _repository.GetListAsync(p => ids.Contains(p.mesout_frozen_id)).ConfigureAwait(false); |
|||
plans.ForEach(p => |
|||
{ |
|||
p.Yl1 = 1; |
|||
|
|||
// p.WmsDate = Clock.Now;
|
|||
}); |
|||
await _repository.UpdateManyAsync(plans).ConfigureAwait(false); |
|||
} |
|||
} |
@ -0,0 +1,10 @@ |
|||
using System.Collections.Generic; |
|||
using System.Threading.Tasks; |
|||
|
|||
namespace Win_in.Sfs.Wms.DataExchange.Domain.Fawtyg.Frozen; |
|||
public interface IFrozenManager |
|||
{ |
|||
Task<List<Frozen>> GetToBeProcessedListAsync(); |
|||
Task UpdateProcessedListAsync(List<Frozen> entities); |
|||
Task UpdateProcesseErrordListAsync(List<Frozen> entities); |
|||
} |
@ -0,0 +1,7 @@ |
|||
using Volo.Abp.Domain.Repositories; |
|||
|
|||
namespace Win_in.Sfs.Wms.DataExchange.Domain.Fawtyg.Frozen; |
|||
public interface IFrozenRepository : IRepository<Frozen> |
|||
{ |
|||
|
|||
} |
@ -0,0 +1,30 @@ |
|||
using Microsoft.EntityFrameworkCore; |
|||
using Volo.Abp.EntityFrameworkCore.Modeling; |
|||
using Win_in.Sfs.Wms.DataExchange.Domain.Fawtyg.Frozen; |
|||
|
|||
namespace Win_in.Sfs.Wms.DataExchange.EntityFrameworkCore.Fawtyg.Mes; |
|||
public static class FrozenDbContextModelCreatingExtensions |
|||
{ |
|||
public static void ConfigureFrozen(this ModelBuilder builder, MesModelBuilderConfigurationOptions options) |
|||
{ |
|||
builder.Entity<Frozen>(b => |
|||
{ |
|||
//Configure table & schema Name
|
|||
b.ToTable(options.TablePrefix + "mesout_frozen", options.Schema); |
|||
//Configure ABP properties
|
|||
b.ConfigureByConvention(); |
|||
|
|||
//Properties
|
|||
b.Property(q => q.mesout_frozen_id).HasMaxLength(20); |
|||
b.Property(q => q.mesout_frozen_type).HasMaxLength(1); |
|||
b.Property(q => q.mesout_frozen_part).HasMaxLength(20); |
|||
b.Property(q => q.mesout_frozen_date).HasMaxLength(20); |
|||
b.Property(q => q.mesout_frozen_loc).HasMaxLength(10); |
|||
b.Property(q => q.mesout_frozen_reason).HasMaxLength(500); |
|||
b.Property(q => q.mesout_frozen_num).HasPrecision(10, 2); |
|||
b.Property(q => q.mesout_frozen_user).HasMaxLength(20); |
|||
b.Property(q => q.Yl1); |
|||
}); |
|||
|
|||
} |
|||
} |
@ -0,0 +1,12 @@ |
|||
using Volo.Abp.Domain.Repositories.EntityFrameworkCore; |
|||
using Volo.Abp.EntityFrameworkCore; |
|||
using Win_in.Sfs.Wms.DataExchange.Domain.Fawtyg.Frozen; |
|||
|
|||
namespace Win_in.Sfs.Wms.DataExchange.EntityFrameworkCore.Fawtyg.Mes; |
|||
public class FrozenEfCoreRepository : EfCoreRepository<MesDbContext, Frozen>, IFrozenRepository |
|||
{ |
|||
public FrozenEfCoreRepository(IDbContextProvider<MesDbContext> dbContextProvider) |
|||
: base(dbContextProvider) |
|||
{ |
|||
} |
|||
} |
@ -0,0 +1,133 @@ |
|||
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.Basedata.Application.Contracts; |
|||
using Win_in.Sfs.Shared.Domain.Shared; |
|||
using Win_in.Sfs.Wms.DataExchange.Domain; |
|||
using Win_in.Sfs.Wms.DataExchange.WMS.MesNote; |
|||
using Win_in.Sfs.Wms.Store.Application.Contracts; |
|||
using Volo.Abp.ObjectMapping; |
|||
using Win_in.Sfs.Wms.DataExchange.WMS.MesNote; |
|||
|
|||
namespace Win_in.Sfs.Wms.DataExchange.Fawtyg.MesAgent.Incoming; |
|||
|
|||
public class FrozenConverter : IIncomingConverter |
|||
{ |
|||
private readonly IIncomingFromExternalManager _incomingFromExternalManager; |
|||
private readonly IIncomingToWmsManager _incomingToWmsManager; |
|||
private readonly IObjectMapper _objectMapper; |
|||
private readonly IItemBasicAppService _itemBasicAppService; |
|||
private readonly ILocationAppService _locationAppService; |
|||
private readonly ILogger<FrozenConverter> _logger; |
|||
|
|||
public FrozenConverter( |
|||
IIncomingToWmsManager incomingToWmsManager |
|||
, IObjectMapper objectMapper |
|||
, IItemBasicAppService itemBasicAppService |
|||
, ILogger<FrozenConverter> logger, |
|||
ILocationAppService locationAppService, |
|||
IIncomingFromExternalManager incomingFromExternalManager) |
|||
{ |
|||
_incomingToWmsManager = incomingToWmsManager; |
|||
_objectMapper = objectMapper; |
|||
_itemBasicAppService = itemBasicAppService; |
|||
_logger = logger; |
|||
_locationAppService = locationAppService; |
|||
_incomingFromExternalManager = incomingFromExternalManager; |
|||
} |
|||
|
|||
public virtual async Task ConvertAsync(List<IncomingFromExternal> incomingFromExternalList) |
|||
{ |
|||
if (!incomingFromExternalList.Any()) |
|||
{ |
|||
_logger.LogInformation("no Frozens"); |
|||
return; |
|||
} |
|||
|
|||
//按Number合并MesNote单据
|
|||
var transferNoteList = await BuildIncomingToWmsOfMesNoteAsync(incomingFromExternalList).ConfigureAwait(false); |
|||
await _incomingToWmsManager.CreateManyAsync(transferNoteList).ConfigureAwait(false); |
|||
//归档
|
|||
await _incomingFromExternalManager.ArchiveManyAsync(incomingFromExternalList).ConfigureAwait(false); |
|||
} |
|||
|
|||
private async Task<List<IncomingToWms>> BuildIncomingToWmsOfMesNoteAsync(List<IncomingFromExternal> incomingDataList) |
|||
{ |
|||
var incomingToWmsList = new List<IncomingToWms>(); |
|||
foreach (var incomingData in incomingDataList) |
|||
{ |
|||
var incomingToWms = new IncomingToWms() |
|||
{ |
|||
DataType = incomingData.DataType, |
|||
DataAction = incomingData.DataAction, |
|||
SourceSystem = incomingData.SourceSystem, |
|||
DataIdentityCode = incomingData.SourceDataGroupCode, |
|||
}; |
|||
incomingToWms.SetEffectiveDate(incomingData.EffectiveDate); |
|||
var exchangeMesNote = JsonSerializer.Deserialize<MesNoteExchangeDto>(incomingData.DestinationDataContent); |
|||
var wmsMesNoteDetail = _objectMapper.Map<MesNoteDetailExchangeDto, MesNoteDetailInput>(exchangeMesNote.Detail); |
|||
var wmsMesNote = _objectMapper.Map<MesNoteExchangeDto, MesNoteEditInput>(exchangeMesNote); |
|||
wmsMesNote.Details = new List<MesNoteDetailInput>(); |
|||
var item = await _itemBasicAppService.GetByCodeAsync(wmsMesNoteDetail.ItemCode).ConfigureAwait(false); |
|||
try |
|||
{ |
|||
wmsMesNoteDetail.FromPackingCode = ""; |
|||
wmsMesNoteDetail.ToPackingCode = ""; |
|||
wmsMesNoteDetail.FromLot = ""; |
|||
wmsMesNoteDetail.ToLot = ""; |
|||
wmsMesNoteDetail.FromWarehouseCode = ""; |
|||
wmsMesNoteDetail.ToWarehouseCode = ""; |
|||
//if (transferNote.Remark.Contains("质量补移库"))//质量补
|
|||
//{
|
|||
// wmsMesNoteDetail.FromPackingCode = "RFE"; //质量补排序批次
|
|||
// wmsMesNoteDetail.FromLot = "RFE";//质量补箱标签
|
|||
// wmsMesNoteDetail.ToPackingCode = "RFE"; //质量补排序批次
|
|||
// wmsMesNoteDetail.ToLot = "RFE";//质量补箱标签
|
|||
//}
|
|||
if (item != null) |
|||
{ |
|||
wmsMesNoteDetail.ItemName = item.Name; |
|||
wmsMesNoteDetail.ItemDesc1 = !string.IsNullOrEmpty(item.Desc1) ? item.Desc1 : ""; |
|||
wmsMesNoteDetail.ItemDesc2 = !string.IsNullOrEmpty(item.Desc2) ? item.Desc2 : ""; |
|||
wmsMesNoteDetail.Uom = !string.IsNullOrEmpty(item.BasicUom) ? item.BasicUom : ""; |
|||
wmsMesNoteDetail.StdPackQty = item.StdPackQty; |
|||
} |
|||
//if (tolocation != null)
|
|||
//{
|
|||
// wmsMesNoteDetail.ToLocationCode = tolocation.Code;
|
|||
// wmsMesNoteDetail.ToLocationArea = tolocation.AreaCode;
|
|||
// wmsMesNoteDetail.ToLocationGroup = tolocation.LocationGroupCode;
|
|||
// wmsMesNoteDetail.ToWarehouseCode = tolocation.WarehouseCode;
|
|||
// if (tolocation.Type == EnumLocationType.CUST)
|
|||
// {
|
|||
// wmsMesNote.Type = EnumTransSubType.Mes_Customer.ToString();//客户储位调拨
|
|||
// }
|
|||
//}
|
|||
//if (fromlocation != null)
|
|||
//{
|
|||
// wmsMesNoteDetail.FromLocationCode = fromlocation.Code;
|
|||
// wmsMesNoteDetail.FromLocationArea = fromlocation.AreaCode;
|
|||
// wmsMesNoteDetail.FromLocationGroup = fromlocation.LocationGroupCode;
|
|||
// wmsMesNoteDetail.FromWarehouseCode = fromlocation.WarehouseCode;
|
|||
//}
|
|||
} |
|||
catch (Exception) |
|||
{ |
|||
wmsMesNoteDetail.ItemName = ""; |
|||
wmsMesNoteDetail.ItemDesc1 = ""; |
|||
wmsMesNoteDetail.ItemDesc2 = ""; |
|||
wmsMesNoteDetail.Uom = ""; |
|||
} |
|||
|
|||
wmsMesNote.Details.Add(wmsMesNoteDetail); |
|||
|
|||
incomingToWms.DataContent = JsonSerializer.Serialize(wmsMesNote); |
|||
incomingToWmsList.Add(incomingToWms); |
|||
} |
|||
return incomingToWmsList; |
|||
} |
|||
|
|||
} |
@ -0,0 +1,123 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using System.Threading.Tasks; |
|||
using Microsoft.Extensions.Logging; |
|||
using Win_in.Sfs.Wms.DataExchange.Domain.Fawtyg.Frozen; |
|||
using Win_in.Sfs.Wms.DataExchange.Domain.Shared; |
|||
using Win_in.Sfs.Wms.DataExchange.Domain; |
|||
using System.Text.Json; |
|||
using Win_in.Sfs.Wms.DataExchange.WMS.MesNote; |
|||
using Win_in.Sfs.Basedata.Application.Contracts; |
|||
using Win_in.Sfs.Shared.Domain.Shared; |
|||
|
|||
namespace Win_in.Sfs.Wms.DataExchange.Fawtyg.MesAgent.Incoming; |
|||
public class FrozenReader : IReader |
|||
{ |
|||
private readonly IFrozenManager _FrozenManager; |
|||
private readonly IIncomingFromExternalManager _incomingFromExternalManager; |
|||
private readonly ILogger<FrozenReader> _logger; |
|||
private readonly ILocationAppService _locationAppService; |
|||
|
|||
public FrozenReader( |
|||
IFrozenManager pillTaskManager |
|||
, IIncomingFromExternalManager incomingFromExternalManager |
|||
, ILogger<FrozenReader> logger |
|||
, ILocationAppService locationAppService |
|||
) |
|||
{ |
|||
_FrozenManager = pillTaskManager; |
|||
_incomingFromExternalManager = incomingFromExternalManager; |
|||
_logger = logger; |
|||
_locationAppService = locationAppService; |
|||
} |
|||
|
|||
public virtual async Task<List<IncomingFromExternal>> ReadAsync() |
|||
|
|||
{ |
|||
//从MES读取待处理Frozen
|
|||
var toBeProcessedPillTasks = await _FrozenManager.GetToBeProcessedListAsync().ConfigureAwait(false); |
|||
if (!toBeProcessedPillTasks.Any()) |
|||
{ |
|||
_logger.LogInformation("no Frozens"); |
|||
return new List<IncomingFromExternal>(); |
|||
} |
|||
//Frozen逐一转换为MaterialRequest
|
|||
var holdLocation = await _locationAppService.GetFirstByTypeAsync(EnumLocationType.HOLD).ConfigureAwait(false); |
|||
var incomingDataList = BuildIncomingFromExternalFromPillTaskAsync(toBeProcessedPillTasks, holdLocation==null?"": holdLocation.Code); |
|||
await _incomingFromExternalManager.CreateManyAsync(incomingDataList).ConfigureAwait(false); |
|||
//更新MES数据状态
|
|||
await _FrozenManager.UpdateProcessedListAsync(toBeProcessedPillTasks).ConfigureAwait(false); |
|||
|
|||
return incomingDataList; |
|||
} |
|||
|
|||
private static List<IncomingFromExternal> BuildIncomingFromExternalFromPillTaskAsync(List<Frozen> toBeProcessedFrozens,string holdLocationCode) |
|||
{ |
|||
var incomingDataList = new List<IncomingFromExternal>(); |
|||
foreach (var Frozen in toBeProcessedFrozens) |
|||
{ |
|||
var incomingData = BuildIncomingFromExternal(Frozen); |
|||
|
|||
incomingData.SetEffectiveDate(DateTime.Now); |
|||
incomingData.SetSuccess(); |
|||
try |
|||
{ |
|||
var MaterialRequest = BuildTransferNoteCreateInput(Frozen, holdLocationCode); |
|||
incomingData.DestinationDataContent = JsonSerializer.Serialize(MaterialRequest); |
|||
} |
|||
catch (Exception ex) |
|||
{ |
|||
incomingData.SetError(EnumExchangeDataErrorCode.Exception, ex.Message, ex.ToString()); |
|||
} |
|||
|
|||
incomingDataList.Add(incomingData); |
|||
|
|||
} |
|||
|
|||
return incomingDataList; |
|||
} |
|||
|
|||
private static IncomingFromExternal BuildIncomingFromExternal(Frozen Frozen) |
|||
{ |
|||
var incomingData = new IncomingFromExternal() |
|||
{ |
|||
DataType = EnumIncomingDataType.MesNote.ToString(), |
|||
DataAction = EnumExchangeDataAction.Add, |
|||
SourceSystem = EnumSystemType.MES.ToString(), |
|||
SourceDataId = Frozen.mesout_frozen_id.ToString(), |
|||
SourceDataGroupCode = Frozen.mesout_frozen_id, |
|||
SourceDataDetailCode = Frozen.mesout_frozen_part, |
|||
SourceDataContent = JsonSerializer.Serialize(Frozen), |
|||
WriteTime = DateTime.Now, |
|||
Writer = nameof(MesIncomingBackgroundWorker), |
|||
|
|||
DestinationSystem = EnumSystemType.WMS.ToString(), |
|||
}; |
|||
return incomingData; |
|||
} |
|||
|
|||
private static MesNoteExchangeDto BuildTransferNoteCreateInput(Frozen Frozen, string holdLocationCode) |
|||
{ |
|||
var mesNote = new MesNoteExchangeDto() |
|||
{ |
|||
MesRequestNumber=Frozen.mesout_frozen_id, |
|||
Worker = Frozen.mesout_frozen_user, |
|||
Remark = Frozen.mesout_frozen_reason, |
|||
Type = Frozen.mesout_frozen_type == "0" ? EnumTransType.MesFreezed.ToString() : EnumTransType.MesUnFreezed.ToString(), |
|||
ActiveDate = DateTime.TryParse(Frozen.mesout_frozen_date, out DateTime dateTime) ? dateTime : DateTime.Now |
|||
}; |
|||
var mesNoteDetail = new MesNoteDetailExchangeDto() |
|||
{ |
|||
ItemCode = Frozen.mesout_frozen_part, |
|||
Qty = Frozen.mesout_frozen_num, |
|||
ToLocationErpCode = Frozen.mesout_frozen_type == "0"? holdLocationCode : Frozen.mesout_frozen_loc, |
|||
FromLocationErpCode = Frozen.mesout_frozen_type != "0"? holdLocationCode:Frozen.mesout_frozen_loc, |
|||
ToStatus= Frozen.mesout_frozen_type == "0"? EnumInventoryStatus.HOLD: EnumInventoryStatus.OK, |
|||
FromStatus = Frozen.mesout_frozen_type != "0" ? EnumInventoryStatus.HOLD : EnumInventoryStatus.OK, |
|||
}; |
|||
mesNote.Detail = mesNoteDetail; |
|||
return mesNote; |
|||
} |
|||
|
|||
} |
@ -0,0 +1,48 @@ |
|||
using System.ComponentModel.DataAnnotations; |
|||
using Win_in.Sfs.Shared.Domain.Shared; |
|||
|
|||
namespace Win_in.Sfs.Wms.DataExchange.WMS.MesNote; |
|||
|
|||
public class MesNoteDetailExchangeDto |
|||
{ |
|||
/// <summary>
|
|||
/// 上架单号
|
|||
/// </summary>
|
|||
[Display(Name = "移库单号")] |
|||
public string Number { get; set; } |
|||
/// <summary>
|
|||
/// 物品代码
|
|||
/// </summary>
|
|||
[Display(Name = "物品代码")] |
|||
public string ItemCode { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 目标ERP库位
|
|||
/// </summary>
|
|||
[Display(Name = "目标ERP库位")] |
|||
public string ToLocationErpCode { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 来源ERP库位
|
|||
/// </summary>
|
|||
[Display(Name = "来源ERP库位")] |
|||
public string FromLocationErpCode { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 目标ERP库位
|
|||
/// </summary>
|
|||
[Display(Name = "来源库位状态")] |
|||
public EnumInventoryStatus FromStatus { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 来源ERP库位
|
|||
/// </summary>
|
|||
[Display(Name = "目标库位状态")] |
|||
public EnumInventoryStatus ToStatus { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 数量
|
|||
/// </summary>
|
|||
[Display(Name = "数量")] |
|||
public decimal Qty { get; set; } |
|||
} |
@ -0,0 +1,47 @@ |
|||
using System; |
|||
using System.ComponentModel.DataAnnotations; |
|||
|
|||
namespace Win_in.Sfs.Wms.DataExchange.WMS.MesNote; |
|||
public class MesNoteExchangeDto |
|||
{ |
|||
/// <summary>
|
|||
/// 上架单号
|
|||
/// </summary>
|
|||
[Display(Name = "移库单号")] |
|||
public string Number { get; set; } |
|||
/// <summary>
|
|||
/// MES请求单号
|
|||
/// </summary>
|
|||
[Display(Name = "MES请求单号")] |
|||
public string MesRequestNumber { get; set; } |
|||
|
|||
|
|||
/// <summary>
|
|||
/// 生效日期
|
|||
/// </summary>
|
|||
[Display(Name = "生效日期")] |
|||
public DateTime ActiveDate { get; set; } = DateTime.Now.Date; |
|||
|
|||
/// <summary>
|
|||
/// 操作员
|
|||
/// </summary>
|
|||
[Display(Name = "操作员")] |
|||
public string Worker { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 调拨类型
|
|||
/// </summary>
|
|||
[Display(Name = "调拨类型")] |
|||
public string Type { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 备注
|
|||
/// </summary>
|
|||
[Display(Name = "备注")] |
|||
public string Remark { get; set; } |
|||
/// <summary>
|
|||
/// 明细列表
|
|||
/// </summary>
|
|||
[Display(Name = "明细列表")] |
|||
public MesNoteDetailExchangeDto Detail { get; set; } = new(); |
|||
} |
Loading…
Reference in new issue