From df79931f1845d6f8e624793c284a4dd8ffe42e84 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AD=A6=20=E8=B5=B5?= <89237069@qq.com> Date: Mon, 27 Nov 2023 16:29:07 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=20=20=E5=AF=84=E5=94=AE?= =?UTF-8?q?=E5=BA=93VERSION=E5=AD=97=E6=AE=B5=E5=AF=84=E5=94=AE=E5=BA=93?= =?UTF-8?q?=E4=B8=9A=E5=8A=A1=E5=AD=97=E6=AE=B5=EF=BC=8C=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E5=8F=91=E8=BF=90=E6=9C=9F=E9=97=B4=E5=88=A4=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BQ/Syncs/PendingDeductionService.cs | 79 ++++++++++++----- .../Entities/BQ/Syncs/SeSyncExtendManager.cs | 85 ++++++++++++++++++- .../Entities/BQ/VmiAppService.cs | 16 ---- .../BaseDomainServices/BaseDomainService.cs | 13 ++- .../Entities/BQ/Vmi/VmiLog.cs | 4 +- 5 files changed, 149 insertions(+), 48 deletions(-) diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/PendingDeductionService.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/PendingDeductionService.cs index 85e3ea71..147a3e6c 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/PendingDeductionService.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/PendingDeductionService.cs @@ -202,29 +202,62 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs public void Sync(List p_ls, EnumDeliverBjBmpBillType bussinessType, string p_email, bool flag = true) where T : PD_BASE, new() { - var query = from itm in p_ls - select new VmiLog() - { - CodeType = string.Empty, - BillTime = DateTime.Now, - ChangedTime = DateTime.Now, - Qty = itm.Qty, - RealPartCode = itm.RELU,//替换件 结算数据 RealPartCode->RELU - RealCode = itm.PN, - LogType = Entities.BQ.Vmi.VmiLogType.Type200, - ChangedQty = (flag == true) ? -itm.Qty : itm.Qty, - ChangedType = VmiType.Out, - //SubBillType = EnumDeliverSubBillType.小件BBAC, - //BillType = EnumDeliverBjBmpBillType.JIS件, - CustPartCode = itm.LU, - SettlementVinCode = itm.PN, - DeliverBillType = bussinessType, - VinCode = itm.PN, - OrderNum = itm.GroupNum, - ErpToLoc = itm.Extend2, //寄售库 - ReMark = itm.Extend3 - }; - var ls = query.ToList(); + var ls=new List(); + var invbills=p_ls.Select(p => p.BillNum).ToList();//发票号 + var invs=_dbcontext.Set().Where(p => invbills.Contains(p.InvbillNum)).ToList();//所有发票 + + foreach (var inv in invs) + { + var pdls= p_ls.Where(p => p.BillNum == inv.InvbillNum).ToList(); + var query1 = from itm in pdls + select new VmiLog() + { + CodeType = string.Empty, + BillTime = inv.LastModificationTime, + ChangedTime = DateTime.Now, + Qty = itm.Qty, + RealPartCode = itm.RELU,//替换件 结算数据 RealPartCode->RELU + RealCode = itm.PN, + LogType = Entities.BQ.Vmi.VmiLogType.Type200, + ChangedQty = (flag == true) ? -itm.Qty : itm.Qty, + ChangedType = VmiType.Out, + //SubBillType = EnumDeliverSubBillType.小件BBAC, + //BillType = EnumDeliverBjBmpBillType.JIS件, + CustPartCode = itm.LU, + SettlementVinCode = itm.PN, + DeliverBillType = bussinessType, + VinCode = itm.PN, + OrderNum = itm.GroupNum, + ErpToLoc = itm.Extend2, //寄售库 + ReMark = itm.Extend3, + Version=int.Parse(inv.LastModificationTime.Value.ToString("yyyyMM")), + factory=itm.BusinessType.ToString() + }; + ls.AddRange(query1.ToList()); + } + //var query = from itm in p_ls + // select new VmiLog() + // { + // CodeType = string.Empty, + // BillTime = DateTime.Now, + // ChangedTime = DateTime.Now, + // Qty = itm.Qty, + // RealPartCode = itm.RELU,//替换件 结算数据 RealPartCode->RELU + // RealCode = itm.PN, + // LogType = Entities.BQ.Vmi.VmiLogType.Type200, + // ChangedQty = (flag == true) ? -itm.Qty : itm.Qty, + // ChangedType = VmiType.Out, + // //SubBillType = EnumDeliverSubBillType.小件BBAC, + // //BillType = EnumDeliverBjBmpBillType.JIS件, + // CustPartCode = itm.LU, + // SettlementVinCode = itm.PN, + // DeliverBillType = bussinessType, + // VinCode = itm.PN, + // OrderNum = itm.GroupNum, + // ErpToLoc = itm.Extend2, //寄售库 + // ReMark = itm.Extend3, + // }; + //var ls = query.ToList(); foreach (var itm in ls) { diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/SeSyncExtendManager.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/SeSyncExtendManager.cs index 9e381997..e6400a3d 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/SeSyncExtendManager.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/SeSyncExtendManager.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Globalization; using System.Linq; using System.Threading.Tasks; using EFCore.BulkExtensions; @@ -8,7 +9,9 @@ using Newtonsoft.Json; using SettleAccount.Bases; using SettleAccount.Domain.BQ; using Volo.Abp.Domain.Services; +using Volo.Abp.SettingManagement; using Win.Sfs.SettleAccount.Entities.BQ.Vmi; +using Win.Sfs.SettleAccount.Entities.CodeSettings; using Win.Sfs.SettleAccount.MaterialRelationships; namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs @@ -63,10 +66,12 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs /// public async Task JisSeDetailsSaveConsignAsync(List seDetails, bool isJisTable) where T : JisSeBase { + var value = _settleAccountDbContext.Set().FirstOrDefault(p => p.Project == "库存账期").Value; var deliverSeDetails = seDetails.FindAll(t => t.TransType == EnumDelTransType.发货); var returnSeDetails = seDetails.FindAll(t => t.TransType == EnumDelTransType.退货); var dateTimeNow = DateTime.Now; + var vmiLogList = deliverSeDetails.Select(t => new VmiLog { LogType = VmiLogType.Type100, @@ -93,7 +98,8 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs Seq = t.Seq, UniqueCode = isJisTable ? t.UniqueCode : t.DeliverCode, VinCode = t.PN, - factory = t.Factory + Version = GetVersionByBillTimeAsync(t.BillTime.Value, value),//加区间字段 + factory = t.BusinessType.ToString() }).ToList(); var returnVmiLogList = returnSeDetails.Select(t => new VmiLog { @@ -121,7 +127,8 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs Seq = t.Seq, UniqueCode = isJisTable ? t.UniqueCode : t.DeliverCode, VinCode = t.VinCode, - factory = t.Factory + Version = GetVersionByBillTimeAsync(t.BillTime.Value, value),//加区间字段 + factory = t.BusinessType.ToString() }).ToList(); vmiLogList.AddRange(returnVmiLogList); await SaveVmiLogsAsync(vmiLogList).ConfigureAwait(false); @@ -136,6 +143,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs /// public async Task PubSeDetailsSaveConsignAsync(List seDetails) { + var value = _settleAccountDbContext.Set().FirstOrDefault(p => p.Project == "库存账期").Value; var deliverSeDetails = seDetails.FindAll(t => t.TransType == EnumDelTransType.发货); var returnSeDetails = seDetails.FindAll(t => t.TransType == EnumDelTransType.退货); var dateTimeNow = DateTime.Now; @@ -158,7 +166,10 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs Qty = t.Qty, ReMark = t.Remark, RealPartCode = t.PartCode, - VinCode = t.PN + VinCode = t.PN, + Version=GetVersionByBillTimeAsync(t.BillTime.Value,value),//加区间字段 + factory=t.BusinessType.ToString() + }).ToList(); var returnVmiLogList = returnSeDetails.Select(t => new VmiLog { @@ -177,7 +188,10 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs OrderNum = t.DeliveryIndex, Qty = -t.Qty, ReMark = t.Remark, - RealPartCode = t.PartCode + RealPartCode = t.PartCode, + Version = GetVersionByBillTimeAsync(t.BillTime.Value, value),//加区间字段 + factory = t.BusinessType.ToString() + }).ToList(); vmiLogList.AddRange(returnVmiLogList); await SaveVmiLogsAsync(vmiLogList).ConfigureAwait(false); @@ -203,5 +217,68 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs }).ToList(); await _settleAccountDbContext.BulkInsertAsync(vmiMessages).ConfigureAwait(false); } + + + public int GetVersionByBillTimeAsync(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); + + + } + + + + + + + + + + + } } 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 d15bf8cd..fcf42368 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 @@ -342,15 +342,6 @@ namespace Win.Sfs.SettleAccount.Entities.BQ return fileName; } - - - - - - - - - /// /// 快照列表 /// @@ -477,13 +468,6 @@ namespace Win.Sfs.SettleAccount.Entities.BQ //query = string.IsNullOrEmpty(input.Sorting) ? query : DynamicQueryableExtensions.OrderBy(query, input.Sorting); //var entities = await query.PageBy(input.SkipCount, input.MaxResultCount).ToListAsync().ConfigureAwait(false); - - - - - - - var entities = await _logRepository.GetListByFilterAsync(input.Filters, input.Sorting, input.MaxResultCount, input.SkipCount).ConfigureAwait(false); var totalCount = await _logRepository.GetCountByFilterAsync(input.Filters).ConfigureAwait(false); diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Bases/BaseDomainServices/BaseDomainService.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Bases/BaseDomainServices/BaseDomainService.cs index 327ae02e..39f9ebcb 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Bases/BaseDomainServices/BaseDomainService.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Bases/BaseDomainServices/BaseDomainService.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Globalization; using System.Linq; using System.Threading.Tasks; using Microsoft.EntityFrameworkCore; @@ -9,6 +10,7 @@ using Volo.Abp.Domain.Services; using Volo.Abp.Guids; using Volo.Abp.ObjectMapping; using Win.Sfs.SettleAccount.Boms; +using Win.Sfs.SettleAccount.Entities.CodeSettings; using Win.Sfs.SettleAccount.Entities.Materials; using Win.Sfs.SettleAccount.Entities.Prices; using Win.Sfs.SettleAccount.MaterialRelationships; @@ -19,6 +21,7 @@ namespace Win.Sfs.SettleAccount.Bases.DomainServices public class BaseDomainService : DomainService { private readonly INormalEfCoreRepository _materialRepository; + private readonly INormalEfCoreRepository _settringRepository; private readonly INormalEfCoreRepository _relationshipRepository; private readonly INormalEfCoreRepository _priceRepository; private readonly INormalEfCoreRepository _pricebjRepository; @@ -32,12 +35,14 @@ namespace Win.Sfs.SettleAccount.Bases.DomainServices INormalEfCoreRepository bomshipRepository, INormalEfCoreRepository priceRepository, INormalEfCoreRepository pricebjRepository, - INormalEfCoreRepository priceYinDuRepository + INormalEfCoreRepository priceYinDuRepository, + INormalEfCoreRepository settringRepository //IExcelImportAppService excelImportService, //ISnowflakeIdGenerator snowflakeIdGenerator, //ICommonManager commonManager ) { + _settringRepository = settringRepository; _priceYinDuRepository = priceYinDuRepository; _priceRepository = priceRepository; _pricebjRepository = pricebjRepository; @@ -49,7 +54,7 @@ namespace Win.Sfs.SettleAccount.Bases.DomainServices public async Task> GetMaterialList(EnumBusinessType businessType) { List ls = new List(); - var lst = await _relationshipRepository.Where(p => !string.IsNullOrEmpty(p.SettleMaterialCode) && p.BusinessType==businessType).ToListAsync().ConfigureAwait(false); + var lst = await _relationshipRepository.Where(p => !string.IsNullOrEmpty(p.SettleMaterialCode) && p.BusinessType == businessType).ToListAsync().ConfigureAwait(false); var l = lst.GroupBy(p => p.SettleMaterialCode).Select(g => g.First()); return l.ToList(); } @@ -263,7 +268,7 @@ namespace Win.Sfs.SettleAccount.Bases.DomainServices } else { - var first= p_list.FirstOrDefault(); + var first = p_list.FirstOrDefault(); if (first.BusinessType == EnumBusinessType.YinDuJian) { @@ -305,6 +310,6 @@ namespace Win.Sfs.SettleAccount.Bases.DomainServices return errorList; } - + } } diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Vmi/VmiLog.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Vmi/VmiLog.cs index 6c76b2e6..f7223d3c 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Vmi/VmiLog.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Vmi/VmiLog.cs @@ -56,7 +56,9 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Vmi [ExporterHeader(DisplayName = "库存变动")] [Display(Name = "库存变动", Order = 5)] public decimal ChangedQty { get; set; } - + [ExporterHeader(DisplayName = "库存变动")] + [Display(Name = "库存变动", Order = 5)] + public int Version { get; set; } public string ConcurrencyStamp { get; set; } public DateTime CreatedTime { get; set; } public DateTime UpdatedTime { get; set; } = DateTime.Now;