diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/INVOICE_SERVICE.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/INVOICE_SERVICE.cs index df1c0ede..f02e19fa 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/INVOICE_SERVICE.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/INVOICE_SERVICE.cs @@ -146,7 +146,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ case EnumBusinessType.ZhiGongJianHBPO: await _pubMng.SetNewState(input.InvGroupNum); break; - case EnumBusinessType.YingDuJian: + case EnumBusinessType.YinDuJian: await _pubMng.SetNewState(input.InvGroupNum); break; case EnumBusinessType.JisBBAC: diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/JitSeSyncAppService.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/JitSeSyncAppService.cs new file mode 100644 index 00000000..c3a913ce --- /dev/null +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/JitSeSyncAppService.cs @@ -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; + +/// +/// Jit发运数据同步 +/// +public class JitSeSyncAppService : ApplicationService, IInvocable +{ + /// + /// WMS数据上下文 + /// + private readonly WMSBJBMPTDbContext _wmsBJBMPTContext; + + /// + /// 同步位置标记 + /// + private readonly INormalEfCoreRepository _syncPositionFlagRepository; + + /// + /// Jit发运数据仓储 + /// + private readonly INormalEfCoreRepository _pubSeDetailRepository; + + /// + /// 构造 + /// + public JitSeSyncAppService( + WMSBJBMPTDbContext wmsBJBMPTContext, + INormalEfCoreRepository syncPositionFlagRepository, + INormalEfCoreRepository pubSeDetailRepository) + { + _wmsBJBMPTContext = wmsBJBMPTContext; + _syncPositionFlagRepository = syncPositionFlagRepository; + _pubSeDetailRepository = pubSeDetailRepository; + } + + /// + /// 发运同步配置 + /// + 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> 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>(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; + } +} diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/SeSyncConfig.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/SeSyncConfig.cs index aa27261e..d528bd8e 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/SeSyncConfig.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/SeSyncConfig.cs @@ -25,7 +25,7 @@ public class SeSyncConfig public List SyncDeliverSubBillTypes { get; set; } /// - /// + /// 业务类别 /// public EnumBusinessType BusinessType { get; set; } } diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/YinDuSeSyncAppService.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/YinDuSeSyncAppService.cs new file mode 100644 index 00000000..3ea72c05 --- /dev/null +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/YinDuSeSyncAppService.cs @@ -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; + +/// +/// 印度件发运同步 +/// +[AllowAnonymous] +[Route("api/settleaccount/[controller]/[action]")] +public class YinDuSeSyncAppService : JitSeSyncAppService +{ + /// + /// 构造 + /// + public YinDuSeSyncAppService( + WMSBJBMPTDbContext wmsBJBMPTContext, + INormalEfCoreRepository syncPositionFlagRepository, + INormalEfCoreRepository pubSeDetailRepository + ) : base(wmsBJBMPTContext, syncPositionFlagRepository, pubSeDetailRepository) + { + base.SeSyncConfigInfo = new SeSyncConfig() + { + SyncTableName = "YinDuSeSync", + SyncDeliverBillType = EnumDeliverBjBmpBillType.印度件, + SyncDeliverSubBillTypes = new List + { + EnumDeliverSubBillType.无 + }, + BusinessType = EnumBusinessType.YinDuJian + }; + } +} diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/ZhiGongBBACSeSyncAppService.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/ZhiGongBBACSeSyncAppService.cs index 199f5f9b..e8f370a1 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/ZhiGongBBACSeSyncAppService.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/ZhiGongBBACSeSyncAppService.cs @@ -1,13 +1,8 @@ using System; using System.Collections.Generic; -using System.Linq; -using System.Linq.Expressions; -using System.Threading.Tasks; -using Coravel.Invocable; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using SettleAccount.Domain.BQ; -using Volo.Abp.Application.Services; using Win.Sfs.SettleAccount.EntityFrameworkCore; using Win.Sfs.Shared.RepositoryBase; @@ -36,87 +31,8 @@ public class ZhiGongBBACSeSyncAppService : JitSeSyncAppService SyncDeliverSubBillTypes = new List { EnumDeliverSubBillType.JIT直供件BBAC - } + }, + BusinessType = EnumBusinessType.ZhiGongJianBBAC }; } } - -/// -/// Jit发运数据同步 -/// -public class JitSeSyncAppService : ApplicationService, IInvocable -{ - /// - /// WMS数据上下文 - /// - private readonly WMSBJBMPTDbContext _wmsBJBMPTContext; - - /// - /// 同步位置标记 - /// - private readonly INormalEfCoreRepository _syncPositionFlagRepository; - - /// - /// Jit发运数据仓储 - /// - private readonly INormalEfCoreRepository _pubSeDetailRepository; - - /// - /// 构造 - /// - public JitSeSyncAppService( - WMSBJBMPTDbContext wmsBJBMPTContext, - INormalEfCoreRepository syncPositionFlagRepository, - INormalEfCoreRepository pubSeDetailRepository) - { - _wmsBJBMPTContext = wmsBJBMPTContext; - _syncPositionFlagRepository = syncPositionFlagRepository; - _pubSeDetailRepository = pubSeDetailRepository; - } - - public SeSyncConfig SeSyncConfigInfo { get; set; } - - [HttpPost] - public async Task Invoke() - { - //同步表名称 - var syncTableName = SeSyncConfigInfo.SyncTableName; - //同步发运主类型 - var deliverBillType = SeSyncConfigInfo.SyncDeliverBillType; - //同步发运子类型 - var deliverSubBillTypes = SeSyncConfigInfo.SyncDeliverSubBillTypes; - - Expression> predicate = (t) => t.DeliverBillType == deliverBillType && (!deliverSubBillTypes.Any() || deliverSubBillTypes.Contains(t.DeliverSubBillType)); - var syncPositionFlag = await _syncPositionFlagRepository.FindAsync(t => t.TableName == syncTableName); - if (syncPositionFlag != null) - { - Expression> expression = (t) => t.UID > int.Parse(syncPositionFlag.Position); - var body = expression.Body; - predicate = Expression.Lambda>(Expression.And(predicate.Body, body), predicate.Parameters); - } - - var jitRecords = _wmsBJBMPTContext.TM_BJBMPT_OTHER_RECORD.Where(predicate).OrderBy(b => b.UID)?.ToList(); - - var pubSeDetails = ObjectMapper.Map, List>(jitRecords); - if (pubSeDetails.Any()) - { - 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; - } -} diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/ZhiGongHBPOSeSyncAppService.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/ZhiGongHBPOSeSyncAppService.cs new file mode 100644 index 00000000..cc3ecb3d --- /dev/null +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/ZhiGongHBPOSeSyncAppService.cs @@ -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; + +/// +/// 直供件HBPO发运同步 +/// +[AllowAnonymous] +[Route("api/settleaccount/[controller]/[action]")] +public class ZhiGongHBPOSeSyncAppService : JitSeSyncAppService +{ + /// + /// 构造 + /// + public ZhiGongHBPOSeSyncAppService( + WMSBJBMPTDbContext wmsBJBMPTContext, + INormalEfCoreRepository syncPositionFlagRepository, + INormalEfCoreRepository pubSeDetailRepository + ) : base(wmsBJBMPTContext, syncPositionFlagRepository, pubSeDetailRepository) + { + base.SeSyncConfigInfo = new SeSyncConfig() + { + SyncTableName = "ZhiGongHBPOSeSync", + SyncDeliverBillType = EnumDeliverBjBmpBillType.JIT直供件, + SyncDeliverSubBillTypes = new List + { + EnumDeliverSubBillType.JIT直供件HBPO + }, + BusinessType = EnumBusinessType.ZhiGongJianHBPO + }; + } +} diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Managers/INV_MNG.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Managers/INV_MNG.cs index fbe0ffc7..94861230 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Managers/INV_MNG.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Managers/INV_MNG.cs @@ -70,7 +70,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers private async Task SetSettleState(INVOICE_GRP p_entiy, SettleBillState p_State,bool IsForward=true) { if (p_entiy.BusinessType == EnumBusinessType.BeiJian || - p_entiy.BusinessType == EnumBusinessType.YingDuJian || + p_entiy.BusinessType == EnumBusinessType.YinDuJian || p_entiy.BusinessType == EnumBusinessType.MaiDanJianBBAC || p_entiy.BusinessType == EnumBusinessType.MaiDanJianHBPO || p_entiy.BusinessType == EnumBusinessType.ZhiGongJianBBAC ||