From a2dd1610605f51cc9035afa1eee4b0b3bf3ca72c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AD=A6=20=E8=B5=B5?= <89237069@qq.com> Date: Mon, 4 Dec 2023 11:18:00 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E7=89=88=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Entities/BQ/INVOICE_SERVICE.cs | 9 --- .../Entities/BQ/Syncs/BalanceSumService .cs | 1 + .../Entities/BQ/VmiAppService.cs | 66 +++++++++++++++++++ 3 files changed, 67 insertions(+), 9 deletions(-) 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 528f416a..c535ee0d 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 @@ -127,12 +127,10 @@ namespace Win.Sfs.SettleAccount.Entities.BQ /// private async Task SubmitToQadSingle(string invbillNum) { - var invoiceGrp = _settleAccountDbContext.Set() .Where(t => t.InvbillNum == invbillNum) .Where(t => t.State == SettleBillState.已扣减) .FirstOrDefault(); - if (invoiceGrp.BusinessType == EnumBusinessType.JisBBAC) { @@ -161,8 +159,6 @@ namespace Win.Sfs.SettleAccount.Entities.BQ foreach (var itm in invoiceGrpDetails) { invdetials.Add(itm);//添加发票明细 - - var first = _detail.FirstOrDefault(p => p.ContractDocID == itm.Extend1 && p.PartCode == itm.PartCode ); if (first == null) { @@ -186,8 +182,6 @@ namespace Win.Sfs.SettleAccount.Entities.BQ invdetials.Add(inv); } - - for (var i = 0; i < invdetials.Count; i++) { var invoiceGrpDetail = invdetials[i]; @@ -276,9 +270,6 @@ namespace Win.Sfs.SettleAccount.Entities.BQ { var invoiceGrpDetail = invoiceGrpDetails[i]; - - - tedSaInvs.Add(new TED_SAS_INVOICE() { GUID = GuidGenerator.Create(), diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/BalanceSumService .cs b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/BalanceSumService .cs index 46cfdec2..4f5579f0 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/BalanceSumService .cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/BalanceSumService .cs @@ -39,6 +39,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs var list=_dapper.GetBalanceSum(year); return id.ToString(); + } diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/VmiAppService.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/VmiAppService.cs index fcf42368..ace474aa 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/VmiAppService.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/VmiAppService.cs @@ -49,6 +49,7 @@ using Win.Sfs.SettleAccount.Constant; using Win.Sfs.SettleAccount.Entities.BQ.Dtos; using Win.Sfs.SettleAccount.Entities.BQ.Syncs; using Win.Sfs.SettleAccount.Entities.BQ.Vmi; +using Win.Sfs.SettleAccount.Entities.CodeSettings; using Win.Sfs.SettleAccount.Entities.TaskJobs; using Win.Sfs.SettleAccount.ExcelImporter; using Win.Sfs.SettleAccount.ExportReports; @@ -68,6 +69,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ private readonly IServiceProvider _serviceProvider; private readonly INormalEfCoreRepository _balanceRepository; private readonly INormalEfCoreRepository _logRepository; + private readonly INormalEfCoreRepository _codeRepository; private readonly IBlobContainer _fileContainer; private readonly IHubContext _hubContext; private readonly ICurrentUser _currentUser; @@ -79,6 +81,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ IGuidGenerator guidGenerator, INormalEfCoreRepository balanceRepository, INormalEfCoreRepository logRepository, + INormalEfCoreRepository codeRepository, IBlobContainer fileContainer, IHubContext hubContext, @@ -88,7 +91,9 @@ namespace Win.Sfs.SettleAccount.Entities.BQ TaskJobService service ) + { + this._codeRepository = codeRepository; this._cfg = cfg; this._guidGenerator = guidGenerator; this._serviceProvider = serviceProvider; @@ -739,6 +744,57 @@ namespace Win.Sfs.SettleAccount.Entities.BQ log.ChangedBy = this._currentUser.UserName; } + + private int GetVersionByBillTime(DateTime p_billtime, string p_day) + { + + var before = p_billtime.Year; + var last = before - 1; + DateTime lastYear = DateTime.ParseExact(string.Format("{0}-12-{1} 08:00:00", last, p_day), "yyyy-MM-dd HH:mm:ss", CultureInfo.InvariantCulture);//上期时间 + DateTime beforeYear = DateTime.ParseExact(string.Format("{0}-12-{1} 07:59:59", before, p_day), "yyyy-MM-dd HH:mm:ss", CultureInfo.InvariantCulture);//这期时间 + + //var result = seDetails + // .Select(log => + // { + string version = null; + + if (p_billtime >= lastYear && p_billtime <= lastYear.AddMonths(1)) + { + version = $"{before.ToString()}01"; + } + else if (p_billtime >= lastYear.AddMonths(1) && p_billtime <= lastYear.AddMonths(2)) + { version = $"{before.ToString()}02"; } + else if (p_billtime >= lastYear.AddMonths(2) && p_billtime <= lastYear.AddMonths(3)) + { version = $"{before.ToString()}03"; } + else if (p_billtime >= lastYear.AddMonths(3) && p_billtime <= lastYear.AddMonths(4)) + { version = $"{before.ToString()}04"; } + else if (p_billtime >= lastYear.AddMonths(4) && p_billtime <= lastYear.AddMonths(5)) + { version = $"{before.ToString()}05"; } + else if (p_billtime >= lastYear.AddMonths(5) && p_billtime <= lastYear.AddMonths(6)) + { version = $"{before.ToString()}06"; } + else if (p_billtime >= lastYear.AddMonths(6) && p_billtime <= lastYear.AddMonths(7)) + { version = $"{before.ToString()}07"; } + else if (p_billtime >= lastYear.AddMonths(7) && p_billtime <= lastYear.AddMonths(8)) + { version = $"{before.ToString()}08"; } + else if (p_billtime >= lastYear.AddMonths(8) && p_billtime <= lastYear.AddMonths(9)) + { version = $"{before.ToString()}09"; } + else if (p_billtime >= lastYear.AddMonths(9) && p_billtime <= lastYear.AddMonths(10)) + { version = $"{before.ToString()}10"; } + else if (p_billtime >= lastYear.AddMonths(10) && p_billtime <= lastYear.AddMonths(11)) + { version = $"{before.ToString()}11"; } + else if (p_billtime >= lastYear.AddMonths(11) && p_billtime <= beforeYear) + { version = $"{before.ToString()}12"; } + + + if (string.IsNullOrEmpty(version)) + { + return 200802;//找不到的数据默认写到这个区间 + } + return int.Parse(version); + + + } + /// /// 库存调整导入 /// @@ -783,6 +839,16 @@ namespace Win.Sfs.SettleAccount.Entities.BQ try { using var transaction = context.Database.BeginTransaction(); + + var value = _codeRepository.FirstOrDefault(p => p.Project == "库存账期").Value; + + + foreach (var itm in logList) + { + itm.Version= GetVersionByBillTime(itm.BillTime.Value, value); + } + + await context.BulkInsertAsync(logList).ConfigureAwait(false); await context.BulkInsertAsync(messageList).ConfigureAwait(false); transaction.Commit();