20 changed files with 500 additions and 45 deletions
@ -0,0 +1,10 @@ |
|||
using System.Collections.Generic; |
|||
using System.Threading.Tasks; |
|||
|
|||
namespace Win_in.Sfs.Wms.DataExchange.Domain.Fawtyg.Chassis; |
|||
public interface IMesChassisManager |
|||
{ |
|||
Task<List<MesChassis>> GetToBeProcessedListAsync(); |
|||
Task UpdateProcessedListAsync(List<MesChassis> entities); |
|||
Task UpdateProcesseErrordListAsync(List<MesChassis> entities); |
|||
} |
@ -0,0 +1,8 @@ |
|||
using Volo.Abp.Domain.Repositories; |
|||
|
|||
namespace Win_in.Sfs.Wms.DataExchange.Domain.Fawtyg.Chassis; |
|||
|
|||
public interface IMesChassisRepository : IRepository<MesChassis> |
|||
{ |
|||
|
|||
} |
@ -0,0 +1,49 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.ComponentModel.DataAnnotations; |
|||
using System.Linq; |
|||
using System.Text; |
|||
using System.Threading.Tasks; |
|||
using Volo.Abp.Domain.Entities; |
|||
|
|||
namespace Win_in.Sfs.Wms.DataExchange.Domain.Fawtyg.Chassis; |
|||
public class MesChassis : Entity |
|||
{ /// <summary>
|
|||
/// 序号
|
|||
/// </summary>
|
|||
[Key] |
|||
public int mesout_fis_id { get; set; } |
|||
/// <summary>
|
|||
/// erp号
|
|||
/// </summary>
|
|||
public string mesout_fis_erpno { get; set; } |
|||
/// <summary>
|
|||
/// 底盘号
|
|||
/// </summary>
|
|||
public string mesout_fis_vin { get; set; } |
|||
/// <summary>
|
|||
/// 产品类型
|
|||
/// </summary>
|
|||
public string mesout_fis_productType { get; set; } |
|||
/// <summary>
|
|||
/// 颜色
|
|||
/// </summary>
|
|||
public string mesout_fis_productColor { get; set; } |
|||
/// <summary>
|
|||
/// 添加时间
|
|||
/// </summary>
|
|||
public DateTime? addtime { get; set; } |
|||
/// <summary>
|
|||
/// 修改时间
|
|||
/// </summary>
|
|||
public DateTime? updatetime { get; set; } |
|||
/// <summary>
|
|||
/// 是否读取(0,1)
|
|||
/// </summary>
|
|||
public int mesout_fis_status { get; set; } |
|||
|
|||
public override object[] GetKeys() |
|||
{ |
|||
return new object[] { mesout_fis_id }; |
|||
} |
|||
} |
@ -0,0 +1,47 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using System.Text; |
|||
using System.Threading.Tasks; |
|||
using Volo.Abp.Domain.Services; |
|||
|
|||
namespace Win_in.Sfs.Wms.DataExchange.Domain.Fawtyg.Chassis; |
|||
|
|||
public class MesChassisManager : DomainService, IMesChassisManager |
|||
{ |
|||
private readonly IMesChassisRepository _repository; |
|||
|
|||
public MesChassisManager(IMesChassisRepository repository) |
|||
{ |
|||
_repository = repository; |
|||
} |
|||
public virtual async Task<List<MesChassis>> GetToBeProcessedListAsync() |
|||
{ |
|||
var plans = await _repository.GetListAsync(p => p.mesout_fis_status == 0).ConfigureAwait(false); |
|||
return plans; |
|||
|
|||
} |
|||
public virtual async Task UpdateProcesseErrordListAsync(List<MesChassis> entities) |
|||
{ |
|||
var ids = entities.Select(p => p.mesout_fis_id); |
|||
var plans = await _repository.GetListAsync(p => ids.Contains(p.mesout_fis_id)).ConfigureAwait(false); |
|||
plans.ForEach(p => |
|||
{ |
|||
p.mesout_fis_status = 2; |
|||
// p.WmsDate = Clock.Now;
|
|||
}); |
|||
await _repository.UpdateManyAsync(plans).ConfigureAwait(false); |
|||
} |
|||
public virtual async Task UpdateProcessedListAsync(List<MesChassis> entities) |
|||
{ |
|||
var ids = entities.Select(p => p.mesout_fis_id); |
|||
var plans = await _repository.GetListAsync(p => ids.Contains(p.mesout_fis_id)).ConfigureAwait(false); |
|||
plans.ForEach(p => |
|||
{ |
|||
p.mesout_fis_status = 1; |
|||
|
|||
// p.WmsDate = Clock.Now;
|
|||
}); |
|||
await _repository.UpdateManyAsync(plans).ConfigureAwait(false); |
|||
} |
|||
} |
@ -0,0 +1,27 @@ |
|||
using Microsoft.EntityFrameworkCore; |
|||
using Volo.Abp.EntityFrameworkCore.Modeling; |
|||
using Win_in.Sfs.Wms.DataExchange.Domain.Fawtyg.Chassis; |
|||
|
|||
namespace Win_in.Sfs.Wms.DataExchange.EntityFrameworkCore.Fawtyg.Mes; |
|||
public static class MesChassisDbContextModelCreatingExtensions |
|||
{ |
|||
public static void ConfigureMesChassis(this ModelBuilder builder, MesModelBuilderConfigurationOptions options) |
|||
{ |
|||
builder.Entity<MesChassis>(b => |
|||
{ |
|||
//Configure table & schema Name
|
|||
b.ToTable(options.TablePrefix + "mesout_fis", options.Schema); |
|||
//Configure ABP properties
|
|||
b.ConfigureByConvention(); |
|||
|
|||
//Properties
|
|||
b.Property(q => q.mesout_fis_id).HasMaxLength(20); |
|||
b.Property(q => q.mesout_fis_erpno).HasMaxLength(50); |
|||
b.Property(q => q.mesout_fis_vin).HasMaxLength(50); |
|||
b.Property(q => q.mesout_fis_productType).HasMaxLength(50); |
|||
b.Property(q => q.mesout_fis_productColor).HasMaxLength(50); |
|||
b.Property(q => q.mesout_fis_status); |
|||
}); |
|||
|
|||
} |
|||
} |
@ -0,0 +1,13 @@ |
|||
using Volo.Abp.Domain.Repositories.EntityFrameworkCore; |
|||
using Volo.Abp.EntityFrameworkCore; |
|||
using Win_in.Sfs.Wms.DataExchange.Domain.Fawtyg.Chassis; |
|||
|
|||
|
|||
namespace Win_in.Sfs.Wms.DataExchange.EntityFrameworkCore.Fawtyg.Mes; |
|||
public class MesChassisEfCoreRepository : EfCoreRepository<MesDbContext, MesChassis>, IMesChassisRepository |
|||
{ |
|||
public MesChassisEfCoreRepository(IDbContextProvider<MesDbContext> dbContextProvider) |
|||
: base(dbContextProvider) |
|||
{ |
|||
} |
|||
} |
@ -0,0 +1,92 @@ |
|||
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.Chassis; |
|||
using Win_in.Sfs.Wms.Store.Application.Contracts; |
|||
using Volo.Abp.ObjectMapping; |
|||
|
|||
namespace Win_in.Sfs.Wms.DataExchange.Fawtyg.MesAgent.Incoming; |
|||
public class MesChassisConverter : IIncomingConverter |
|||
{ |
|||
private readonly IIncomingFromExternalManager _incomingFromExternalManager; |
|||
private readonly IIncomingToWmsManager _incomingToWmsManager; |
|||
private readonly IObjectMapper _objectMapper; |
|||
private readonly IItemBasicAppService _itemBasicAppService; |
|||
private readonly ILocationAppService _locationAppService; |
|||
private readonly ILogger<MesChassisConverter> _logger; |
|||
|
|||
public MesChassisConverter( |
|||
IIncomingToWmsManager incomingToWmsManager |
|||
, IObjectMapper objectMapper |
|||
, IItemBasicAppService itemBasicAppService |
|||
, ILogger<MesChassisConverter> 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("无底盘数据【转换】"); |
|||
return; |
|||
} |
|||
|
|||
//按Number合并Chassis单据
|
|||
var transferNoteList = await BuildIncomingToWmsOfChassisAsync(incomingFromExternalList).ConfigureAwait(false); |
|||
await _incomingToWmsManager.CreateManyAsync(transferNoteList).ConfigureAwait(false); |
|||
//归档
|
|||
await _incomingFromExternalManager.ArchiveManyAsync(incomingFromExternalList).ConfigureAwait(false); |
|||
} |
|||
|
|||
private async Task<List<IncomingToWms>> BuildIncomingToWmsOfChassisAsync(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 exchangeChassis = JsonSerializer.Deserialize<ChassisExchangeDto>(incomingData.DestinationDataContent); |
|||
var wmsChassis = _objectMapper.Map<ChassisExchangeDto, ChassisEditInput>(exchangeChassis); |
|||
try |
|||
{ |
|||
var item = await _itemBasicAppService.GetByCodeAsync(exchangeChassis.ItemCode).ConfigureAwait(false); |
|||
if (item != null) |
|||
{ |
|||
wmsChassis.ItemName = item.Name; |
|||
wmsChassis.ItemDesc1 = !string.IsNullOrEmpty(item.Desc1) ? item.Desc1 : ""; |
|||
wmsChassis.ItemDesc2 = !string.IsNullOrEmpty(item.Desc2) ? item.Desc2 : ""; |
|||
} |
|||
} |
|||
catch (Exception) |
|||
{ |
|||
wmsChassis.ItemName = ""; |
|||
wmsChassis.ItemDesc1 = ""; |
|||
wmsChassis.ItemDesc2 = ""; |
|||
} |
|||
incomingToWms.DataContent = JsonSerializer.Serialize(wmsChassis); |
|||
incomingToWmsList.Add(incomingToWms); |
|||
} |
|||
return incomingToWmsList; |
|||
} |
|||
|
|||
} |
@ -0,0 +1,116 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using System.Threading.Tasks; |
|||
using Microsoft.Extensions.Logging; |
|||
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; |
|||
using Win_in.Sfs.Wms.DataExchange.Domain.Fawtyg.Chassis; |
|||
using Win_in.Sfs.Wms.DataExchange.WMS.Chassis; |
|||
|
|||
namespace Win_in.Sfs.Wms.DataExchange.Fawtyg.MesAgent.Incoming; |
|||
public class MesChassisReader : IReader |
|||
{ |
|||
private readonly IMesChassisManager _mesChassisManager; |
|||
private readonly IIncomingFromExternalManager _incomingFromExternalManager; |
|||
private readonly ILogger<MesChassisReader> _logger; |
|||
private readonly ILocationAppService _locationAppService; |
|||
|
|||
public MesChassisReader( |
|||
IMesChassisManager mesChassisManager |
|||
, IIncomingFromExternalManager incomingFromExternalManager |
|||
, ILogger<MesChassisReader> logger |
|||
, ILocationAppService locationAppService |
|||
) |
|||
{ |
|||
_mesChassisManager = mesChassisManager; |
|||
_incomingFromExternalManager = incomingFromExternalManager; |
|||
_logger = logger; |
|||
_locationAppService = locationAppService; |
|||
} |
|||
|
|||
public virtual async Task<List<IncomingFromExternal>> ReadAsync() |
|||
|
|||
{ |
|||
//从MES读取待处理MesChassis
|
|||
var toBeProcessedPillTasks = await _mesChassisManager.GetToBeProcessedListAsync().ConfigureAwait(false); |
|||
if (!toBeProcessedPillTasks.Any()) |
|||
{ |
|||
_logger.LogInformation("无底盘数据【读取】"); |
|||
return new List<IncomingFromExternal>(); |
|||
} |
|||
//MesChassis逐一转换为MaterialRequest
|
|||
var incomingDataList = BuildIncomingFromExternalFromPillTaskAsync(toBeProcessedPillTasks); |
|||
await _incomingFromExternalManager.CreateManyAsync(incomingDataList).ConfigureAwait(false); |
|||
//更新MES数据状态
|
|||
await _mesChassisManager.UpdateProcessedListAsync(toBeProcessedPillTasks).ConfigureAwait(false); |
|||
|
|||
return incomingDataList; |
|||
} |
|||
|
|||
private static List<IncomingFromExternal> BuildIncomingFromExternalFromPillTaskAsync(List<MesChassis> toBeProcessedMesChassiss) |
|||
{ |
|||
var incomingDataList = new List<IncomingFromExternal>(); |
|||
foreach (var MesChassis in toBeProcessedMesChassiss) |
|||
{ |
|||
var incomingData = BuildIncomingFromExternal(MesChassis); |
|||
|
|||
incomingData.SetEffectiveDate(DateTime.Now); |
|||
incomingData.SetSuccess(); |
|||
try |
|||
{ |
|||
var MaterialRequest = BuildChassisCreateInput(MesChassis); |
|||
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(MesChassis MesChassis) |
|||
{ |
|||
var incomingData = new IncomingFromExternal() |
|||
{ |
|||
DataType = EnumIncomingDataType.MesChassis.ToString(), |
|||
DataAction = EnumExchangeDataAction.Add, |
|||
SourceSystem = EnumSystemType.MES.ToString(), |
|||
SourceDataId = MesChassis.mesout_fis_id.ToString(), |
|||
SourceDataGroupCode = MesChassis.mesout_fis_vin.ToString(), |
|||
SourceDataDetailCode = MesChassis.mesout_fis_erpno, |
|||
SourceDataContent = JsonSerializer.Serialize(MesChassis), |
|||
WriteTime = DateTime.Now, |
|||
Writer = nameof(MesIncomingBackgroundWorker), |
|||
|
|||
DestinationSystem = EnumSystemType.WMS.ToString(), |
|||
}; |
|||
return incomingData; |
|||
} |
|||
|
|||
private static ChassisExchangeDto BuildChassisCreateInput(MesChassis MesChassis) |
|||
{ |
|||
var chassis = new ChassisExchangeDto() |
|||
{ |
|||
Number = MesChassis.mesout_fis_id.ToString(), |
|||
ChassisNumber= MesChassis.mesout_fis_vin, |
|||
Description= MesChassis.mesout_fis_productType, |
|||
ProduceDateTime= DateTime.Now, |
|||
ReceiveInterfaceDateTime= DateTime.Now, |
|||
SortNumber = MesChassis.mesout_fis_id, |
|||
ItemCode = MesChassis.mesout_fis_erpno, |
|||
Configuration= MesChassis.mesout_fis_productColor, |
|||
}; |
|||
return chassis; |
|||
} |
|||
|
|||
} |
@ -0,0 +1,50 @@ |
|||
using System; |
|||
using System.ComponentModel.DataAnnotations; |
|||
|
|||
namespace Win_in.Sfs.Wms.DataExchange.WMS.Chassis; |
|||
public class ChassisExchangeDto |
|||
{ |
|||
/// <summary>
|
|||
/// Wms编号
|
|||
/// </summary>
|
|||
[Display(Name = "Wms编号")] |
|||
public string Number { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 底盘号
|
|||
/// </summary>
|
|||
[Display(Name = "底盘号")] |
|||
public string ChassisNumber { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 描述
|
|||
/// </summary>
|
|||
[Display(Name = "描述")] |
|||
public string Description { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 底盘生产时间
|
|||
/// </summary>
|
|||
[Display(Name = "底盘生产时间")] |
|||
public DateTime ProduceDateTime { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 接收接口时间
|
|||
/// </summary>
|
|||
[Display(Name = "接收接口时间")] |
|||
public DateTime ReceiveInterfaceDateTime { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 执行位置排序列
|
|||
/// </summary>
|
|||
[Display(Name = "执行位置排序列")] |
|||
public long SortNumber { get; set; } |
|||
|
|||
public string ItemCode { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 配置号
|
|||
/// </summary>
|
|||
[Display(Name = "配置号")] |
|||
public string Configuration { get; set; } |
|||
} |
Loading…
Reference in new issue