mahao
1 year ago
7 changed files with 184 additions and 89 deletions
@ -0,0 +1,97 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using System.Linq.Expressions; |
|||
using System.Threading.Tasks; |
|||
using Coravel.Invocable; |
|||
using Microsoft.AspNetCore.Mvc; |
|||
using SettleAccount.Domain.BQ; |
|||
using Volo.Abp.Application.Services; |
|||
using Win.Sfs.SettleAccount.EntityFrameworkCore; |
|||
using Win.Sfs.Shared.RepositoryBase; |
|||
|
|||
namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs; |
|||
|
|||
/// <summary>
|
|||
/// Jit发运数据同步
|
|||
/// </summary>
|
|||
public class JitSeSyncAppService : ApplicationService, IInvocable |
|||
{ |
|||
/// <summary>
|
|||
/// WMS数据上下文
|
|||
/// </summary>
|
|||
private readonly WMSBJBMPTDbContext _wmsBJBMPTContext; |
|||
|
|||
/// <summary>
|
|||
/// 同步位置标记
|
|||
/// </summary>
|
|||
private readonly INormalEfCoreRepository<SyncPositionFlag, Guid> _syncPositionFlagRepository; |
|||
|
|||
/// <summary>
|
|||
/// Jit发运数据仓储
|
|||
/// </summary>
|
|||
private readonly INormalEfCoreRepository<PUB_SE_DETAIL, Guid> _pubSeDetailRepository; |
|||
|
|||
/// <summary>
|
|||
/// 构造
|
|||
/// </summary>
|
|||
public JitSeSyncAppService( |
|||
WMSBJBMPTDbContext wmsBJBMPTContext, |
|||
INormalEfCoreRepository<SyncPositionFlag, Guid> syncPositionFlagRepository, |
|||
INormalEfCoreRepository<PUB_SE_DETAIL, Guid> pubSeDetailRepository) |
|||
{ |
|||
_wmsBJBMPTContext = wmsBJBMPTContext; |
|||
_syncPositionFlagRepository = syncPositionFlagRepository; |
|||
_pubSeDetailRepository = pubSeDetailRepository; |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// 发运同步配置
|
|||
/// </summary>
|
|||
public SeSyncConfig SeSyncConfigInfo { get; set; } |
|||
|
|||
[HttpPost] |
|||
public async Task Invoke() |
|||
{ |
|||
//同步表名称
|
|||
var syncTableName = SeSyncConfigInfo.SyncTableName; |
|||
//同步发运主类型
|
|||
var deliverBillType = SeSyncConfigInfo.SyncDeliverBillType; |
|||
//同步发运子类型
|
|||
var deliverSubBillTypes = SeSyncConfigInfo.SyncDeliverSubBillTypes; |
|||
//业务类别
|
|||
var businessType = SeSyncConfigInfo.BusinessType; |
|||
|
|||
Expression<Func<TM_BJBMPT_OTHER_RECORD, bool>> predicate = (t) => t.DeliverBillType == deliverBillType && (!deliverSubBillTypes.Any() || deliverSubBillTypes.Contains(t.DeliverSubBillType)); |
|||
var syncPositionFlag = await _syncPositionFlagRepository.FindAsync(t => t.TableName == syncTableName); |
|||
if (syncPositionFlag != null) |
|||
{ |
|||
predicate = (t) => t.DeliverBillType == deliverBillType && t.UID > int.Parse(syncPositionFlag.Position) && (!deliverSubBillTypes.Any() || deliverSubBillTypes.Contains(t.DeliverSubBillType)); |
|||
} |
|||
|
|||
var jitRecords = _wmsBJBMPTContext.TM_BJBMPT_OTHER_RECORD.Where(predicate).OrderBy(b => b.UID).ToList(); |
|||
|
|||
var pubSeDetails = ObjectMapper.Map<List<TM_BJBMPT_OTHER_RECORD>, List<PUB_SE_DETAIL>>(jitRecords); |
|||
if (pubSeDetails.Any()) |
|||
{ |
|||
pubSeDetails.ForEach(t => t.BusinessType = businessType); |
|||
await _pubSeDetailRepository.InsertManyAsync(pubSeDetails); |
|||
|
|||
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); |
|||
} |
|||
} |
|||
await Task.CompletedTask; |
|||
} |
|||
} |
@ -0,0 +1,41 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using System.Text; |
|||
using System.Threading.Tasks; |
|||
using Microsoft.AspNetCore.Authorization; |
|||
using Microsoft.AspNetCore.Mvc; |
|||
using SettleAccount.Domain.BQ; |
|||
using Win.Sfs.SettleAccount.EntityFrameworkCore; |
|||
using Win.Sfs.Shared.RepositoryBase; |
|||
|
|||
namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs; |
|||
|
|||
/// <summary>
|
|||
/// 印度件发运同步
|
|||
/// </summary>
|
|||
[AllowAnonymous] |
|||
[Route("api/settleaccount/[controller]/[action]")]
|
|||
public class YinDuSeSyncAppService : JitSeSyncAppService |
|||
{ |
|||
/// <summary>
|
|||
/// 构造
|
|||
/// </summary>
|
|||
public YinDuSeSyncAppService( |
|||
WMSBJBMPTDbContext wmsBJBMPTContext, |
|||
INormalEfCoreRepository<SyncPositionFlag, Guid> syncPositionFlagRepository, |
|||
INormalEfCoreRepository<PUB_SE_DETAIL, Guid> pubSeDetailRepository |
|||
) : base(wmsBJBMPTContext, syncPositionFlagRepository, pubSeDetailRepository) |
|||
{ |
|||
base.SeSyncConfigInfo = new SeSyncConfig() |
|||
{ |
|||
SyncTableName = "YinDuSeSync", |
|||
SyncDeliverBillType = EnumDeliverBjBmpBillType.印度件, |
|||
SyncDeliverSubBillTypes = new List<EnumDeliverSubBillType> |
|||
{ |
|||
EnumDeliverSubBillType.无 |
|||
}, |
|||
BusinessType = EnumBusinessType.YinDuJian |
|||
}; |
|||
} |
|||
} |
@ -0,0 +1,41 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using System.Text; |
|||
using System.Threading.Tasks; |
|||
using Microsoft.AspNetCore.Authorization; |
|||
using Microsoft.AspNetCore.Mvc; |
|||
using SettleAccount.Domain.BQ; |
|||
using Win.Sfs.SettleAccount.EntityFrameworkCore; |
|||
using Win.Sfs.Shared.RepositoryBase; |
|||
|
|||
namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs; |
|||
|
|||
/// <summary>
|
|||
/// 直供件HBPO发运同步
|
|||
/// </summary>
|
|||
[AllowAnonymous] |
|||
[Route("api/settleaccount/[controller]/[action]")]
|
|||
public class ZhiGongHBPOSeSyncAppService : JitSeSyncAppService |
|||
{ |
|||
/// <summary>
|
|||
/// 构造
|
|||
/// </summary>
|
|||
public ZhiGongHBPOSeSyncAppService( |
|||
WMSBJBMPTDbContext wmsBJBMPTContext, |
|||
INormalEfCoreRepository<SyncPositionFlag, Guid> syncPositionFlagRepository, |
|||
INormalEfCoreRepository<PUB_SE_DETAIL, Guid> pubSeDetailRepository |
|||
) : base(wmsBJBMPTContext, syncPositionFlagRepository, pubSeDetailRepository) |
|||
{ |
|||
base.SeSyncConfigInfo = new SeSyncConfig() |
|||
{ |
|||
SyncTableName = "ZhiGongHBPOSeSync", |
|||
SyncDeliverBillType = EnumDeliverBjBmpBillType.JIT直供件, |
|||
SyncDeliverSubBillTypes = new List<EnumDeliverSubBillType> |
|||
{ |
|||
EnumDeliverSubBillType.JIT直供件HBPO |
|||
}, |
|||
BusinessType = EnumBusinessType.ZhiGongJianHBPO |
|||
}; |
|||
} |
|||
} |
Loading…
Reference in new issue