mahao 1 year ago
parent
commit
cd6b8f260f
  1. 100
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/HBPOSeSyncAppService.cs
  2. 31
      code/src/Modules/SettleAccount/src/SettleAccount.Application/SettleAccountApplicationAutoMapperProfile.cs
  3. 5
      code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Syncs/SyncPositionFlag.cs
  4. 104
      code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Syncs/TM_BJBMPT_JIS_RECORD.cs
  5. 3
      code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Syncs/TM_BJBMPT_JIT_RECORD.cs
  6. 3
      code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/EntityFrameworkCore/WMSBJBMPTDbContext.cs

100
code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/HBPOSeSyncAppService.cs

@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Threading.Tasks;
using Coravel.Invocable;
using Microsoft.AspNetCore.Authorization;
@ -8,6 +9,7 @@ using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using SettleAccount.Domain.BQ;
using Volo.Abp.Application.Services;
using Win.Sfs.SettleAccount.Entities.BQ.Syncs;
using Win.Sfs.SettleAccount.Entities.BQ.Vmi;
using Win.Sfs.SettleAccount.Entities.Prices;
using Win.Sfs.SettleAccount.EntityFrameworkCore;
@ -27,6 +29,11 @@ public class HBPOSeSyncAppService : ApplicationService, IInvocable //IJobService
/// </summary>
private readonly WMSBJBMPTDbContext _wmsBJBMPTContext;
/// <summary>
/// 同步位置标记
/// </summary>
private readonly INormalEfCoreRepository<SyncPositionFlag, Guid> _syncPositionFlagRepository;
/// <summary>
/// HBPO发运数据仓储
/// </summary>
@ -37,9 +44,11 @@ public class HBPOSeSyncAppService : ApplicationService, IInvocable //IJobService
/// </summary>
public HBPOSeSyncAppService(
WMSBJBMPTDbContext wmsBJBMPTContext,
INormalEfCoreRepository<SyncPositionFlag, Guid> syncPositionFlagRepository,
INormalEfCoreRepository<HBPO_SE_DETAIL, Guid> hbpoSeDetailRepository)
{
_wmsBJBMPTContext = wmsBJBMPTContext;
_syncPositionFlagRepository = syncPositionFlagRepository;
_hbpoSeDetailRepository = hbpoSeDetailRepository;
}
@ -53,16 +62,8 @@ public class HBPOSeSyncAppService : ApplicationService, IInvocable //IJobService
[HttpPost]
public async Task Invoke()
{
//using var dbContext = new WMSBJBMPTDbContext();
var TM_BJBMPT_JIT_RECORDs = _wmsBJBMPTContext.TM_BJBMPT_JIT_RECORD
.Where(b => b.UID > 3)
.OrderBy(b => b.BillTime)
.ToList();
var hbpoSeDetails = ObjectMapper.Map<List<TM_BJBMPT_JIT_RECORD>, List<HBPO_SE_DETAIL>>(TM_BJBMPT_JIT_RECORDs);
_hbpoSeDetailRepository.InsertManyAsync(hbpoSeDetails);
//await SyncJitRecord();
//await SyncJisRecord();
//if (!dbContext.GetService<IRelationalDatabaseCreator>().Exists() && dbContext.Database.EnsureCreated())
//{
// this._balanceRepository.AsNoTracking().ForEachAsync(o =>
@ -109,4 +110,83 @@ public class HBPOSeSyncAppService : ApplicationService, IInvocable //IJobService
Console.WriteLine($"{this.GetType().FullName}执行了");
}
/// <summary>
/// 同步JitRecord
/// </summary>
/// <returns></returns>
private async Task SyncJitRecord()
{
//同步表名称
var syncTableName = "TM_BJBMPT_JIT_RECORD";
Expression<Func<TM_BJBMPT_JIT_RECORD, bool>> predicate = (t) => true;
var syncPositionFlag = await _syncPositionFlagRepository.FindAsync(t => t.TableName == syncTableName);
if (syncPositionFlag != null)
{
predicate = (t) => t.UID > int.Parse(syncPositionFlag.Position);
}
var jitRecords = _wmsBJBMPTContext.TM_BJBMPT_JIT_RECORD
.Where(predicate)
.OrderBy(b => b.UID)
.ToList();
var hbpoSeDetails = ObjectMapper.Map<List<TM_BJBMPT_JIT_RECORD>, List<HBPO_SE_DETAIL>>(jitRecords);
if (hbpoSeDetails.Any())
{
await _hbpoSeDetailRepository.InsertManyAsync(hbpoSeDetails);
if (syncPositionFlag != null)
{
syncPositionFlag.Position = jitRecords.Last().UID.ToString();
await _syncPositionFlagRepository.UpdateAsync(syncPositionFlag);
}
else
{
syncPositionFlag = new SyncPositionFlag()
{
TableName = syncTableName,
Position = jitRecords.Last().UID.ToString()
};
await _syncPositionFlagRepository.InsertAsync(syncPositionFlag);
}
}
}
private async Task SyncJisRecord()
{
//同步表名称
var syncTableName = "TM_BJBMPT_JIS_RECORD";
Expression<Func<TM_BJBMPT_JIS_RECORD, bool>> predicate = (t) => true;
var syncPositionFlag = await _syncPositionFlagRepository.FindAsync(t => t.TableName == syncTableName);
if (syncPositionFlag != null)
{
predicate = (t) => t.UID > int.Parse(syncPositionFlag.Position);
}
var jisRecords = _wmsBJBMPTContext.TM_BJBMPT_JIS_RECORD
.Where(predicate)
.OrderBy(b => b.UID)
.ToList();
var hbpoSeDetails = ObjectMapper.Map<List<TM_BJBMPT_JIS_RECORD>, List<HBPO_SE_DETAIL>>(jisRecords);
if (hbpoSeDetails.Any())
{
await _hbpoSeDetailRepository.InsertManyAsync(hbpoSeDetails);
if (syncPositionFlag != null)
{
syncPositionFlag.Position = jisRecords.Last().UID.ToString();
await _syncPositionFlagRepository.UpdateAsync(syncPositionFlag);
}
else
{
syncPositionFlag = new SyncPositionFlag()
{
TableName = syncTableName,
Position = jisRecords.Last().UID.ToString()
};
await _syncPositionFlagRepository.InsertAsync(syncPositionFlag);
}
}
}
}

31
code/src/Modules/SettleAccount/src/SettleAccount.Application/SettleAccountApplicationAutoMapperProfile.cs

@ -58,7 +58,7 @@ using Win.Sfs.SettleAccount.Entities.BQ.Dtos;
using SettleAccount.Domain.BQ;
using System.ComponentModel.DataAnnotations;
using System.Reflection;
using Win.Sfs.SettleAccount.Entities.BQ;
using Win.Sfs.SettleAccount.Entities.BQ.Syncs;
namespace Win.Sfs.SettleAccount
{
@ -1029,15 +1029,26 @@ namespace Win.Sfs.SettleAccount
private void CreateMapSeSync()
{
CreateMap<TM_BJBMPT_JIT_RECORD, HBPO_SE_DETAIL>()
.ForMember(x => x.SeqNumber, y => y.MapFrom(d => d.JISNum))
.ForMember(x => x.AssemblyCode, y => y.MapFrom(d => d.RealPartCode))
.ForMember(x => x.InjectionCode, y => y.MapFrom(d => d.DeliverCode))
.ForMember(x => x.BeginDate, y => y.MapFrom(d => d.BillTime))
.ForMember(x => x.ShippingDate, y => y.MapFrom(d => d.BillTime))
.ForMember(x => x.WmsBillNum, y => y.MapFrom(d => d.BillNum))
.ForMember(x => x.LU, y => y.MapFrom(d => d.PartCode))
.ForMember(x => x.PN, y => y.MapFrom(d => d.VinCode))
.ForMember(x => x.Qty, y => y.MapFrom(d => d.Qty));
.ForMember(x => x.SeqNumber, y => y.MapFrom(d => d.JISNum))
.ForMember(x => x.AssemblyCode, y => y.MapFrom(d => d.RealPartCode))
.ForMember(x => x.InjectionCode, y => y.MapFrom(d => d.DeliverCode))
.ForMember(x => x.BeginDate, y => y.MapFrom(d => d.BillTime))
.ForMember(x => x.ShippingDate, y => y.MapFrom(d => d.BillTime))
.ForMember(x => x.WmsBillNum, y => y.MapFrom(d => d.BillNum))
.ForMember(x => x.LU, y => y.MapFrom(d => d.PartCode))
.ForMember(x => x.PN, y => y.MapFrom(d => d.VinCode))
.ForMember(x => x.Qty, y => y.MapFrom(d => d.Qty));
CreateMap<TM_BJBMPT_JIS_RECORD, HBPO_SE_DETAIL>()
.ForMember(x => x.SeqNumber, y => y.MapFrom(d => d.JISNum))
.ForMember(x => x.AssemblyCode, y => y.MapFrom(d => d.RealPartCode))
.ForMember(x => x.InjectionCode, y => y.MapFrom(d => d.DeliverCode))
.ForMember(x => x.BeginDate, y => y.MapFrom(d => d.BillTime))
.ForMember(x => x.ShippingDate, y => y.MapFrom(d => d.BillTime))
.ForMember(x => x.WmsBillNum, y => y.MapFrom(d => d.BillNum))
.ForMember(x => x.LU, y => y.MapFrom(d => d.PartCode))
.ForMember(x => x.PN, y => y.MapFrom(d => d.VinCode))
.ForMember(x => x.Qty, y => y.MapFrom(d => d.Qty));
}
}

5
code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Syncs/SyncPositionFlag.cs

@ -20,4 +20,9 @@ public class SyncPositionFlag : AuditedAggregateRoot<Guid>
/// </summary>
[Display(Name = "位置")]
public string Position { get; set; }
/// <summary>
/// 构造
/// </summary>
public SyncPositionFlag() { }
}

104
code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Syncs/TM_BJBMPT_JIS_RECORD.cs

@ -0,0 +1,104 @@
using System;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs;
public class TM_BJBMPT_JIS_RECORD
{
[Key]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int UID { get; set; }
[DisplayName("JIS单据编号")]
public string JISNum { get; set; }
[DisplayName("发货时间")]
public DateTime? BillTime { get; set; }
[DisplayName("发货人")]
public string Oper { get; set; }
[DisplayName("JIS排序单号")]
public string OrderNum { get; set; }
[DisplayName("订单序号")]
public string Seq { get; set; }
[DisplayName("JIS实际生产码")]
public string RealCode { get; set; }
[DisplayName("订单生产码")]
public string VinCode { get; set; }
[DisplayName("JIS生产码类型")]
public string CodeType { get; set; }
[DisplayName("订单零件号")]
public string PartCode { get; set; }
[DisplayName("数量")]
public decimal? Qty { get; set; }
[DisplayName("发货单号")]
public string BillNum { get; set; }
public string MESConfigCode { get; set; }
[DisplayName("来源库位")]
public string FromLoc { get; set; }
[DisplayName("目标库位")]
public string ToLoc { get; set; }
public string RealPartCode { get; set; }
public string Batch { get; set; }
[DisplayName("参照订单生产码")]
public string RefVinCode { get; set; }
//[DisplayName("单据类型")]
//public EnumBillType BillType { get; set; }
//[DisplayName("子单据类型")]
//public EnumSubBillType SubBillType { get; set; }
[DisplayName("单据性质")]
public string BillCharacter { get; set; }
public int? TransType { get; set; }
public int? DeliverBillType { get; set; }
public int? DeliverSubBillType { get; set; }
[DisplayName("发货关联单号")]
public string RefBillNum { get; set; }
[DisplayName("Erp目标库位")]
public string ErpToLoc { get; set; }
[DisplayName("原生产码")]
public string OrigiCode { get; set; }
[DisplayName("备注")]
public string Remark { get; set; }
[DisplayName("塑件唯一码")]
public string UniqueCode { get; set; }
[DisplayName("PJS顺序号")]
public string PjsNum { get; set; }
[DisplayName("虚拟小总成")]
public string MatchNumber { get; set; }
//[DisplayName("业务类型")]
//public EnumProTpe ProType { get; set; }
public string DeliverCode { get; set; }
public string Position { get; set; }
}

3
code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/TM_BJBMPT_JIT_RECORD.cs → code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Syncs/TM_BJBMPT_JIT_RECORD.cs

@ -3,7 +3,8 @@ using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace Win.Sfs.SettleAccount.Entities.BQ;
namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs;
public class TM_BJBMPT_JIT_RECORD
{
[Key]

3
code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/EntityFrameworkCore/WMSBJBMPTDbContext.cs

@ -1,6 +1,6 @@
using Microsoft.EntityFrameworkCore;
using Volo.Abp.Data;
using Win.Sfs.SettleAccount.Entities.BQ;
using Win.Sfs.SettleAccount.Entities.BQ.Syncs;
namespace Win.Sfs.SettleAccount.EntityFrameworkCore;
@ -8,6 +8,7 @@ namespace Win.Sfs.SettleAccount.EntityFrameworkCore;
public class WMSBJBMPTDbContext : DbContext
{
public DbSet<TM_BJBMPT_JIT_RECORD> TM_BJBMPT_JIT_RECORD { get; set; }
public DbSet<TM_BJBMPT_JIS_RECORD> TM_BJBMPT_JIS_RECORD { get; set; }
public WMSBJBMPTDbContext()
{

Loading…
Cancel
Save