From 9fe9be7f5626325e012fb25261e9bcb069b924c9 Mon Sep 17 00:00:00 2001 From: mahao Date: Mon, 25 Sep 2023 09:05:29 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=8F=91=E8=BF=90?= =?UTF-8?q?=E5=90=8C=E6=AD=A5=E8=A1=A8=E5=90=8D=E7=A7=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Entities/BQ/INVOICE_SERVICE.cs | 232 ++++++++++++++---- .../Entities/BQ/Syncs/TM_BJBMPT_JIS_RECORD.cs | 9 +- .../Entities/BQ/Syncs/TM_BJBMPT_JIT_RECORD.cs | 9 +- .../BQ/Syncs/TM_BJBMPT_OTHER_RECORD.cs | 9 +- .../Entities/BQ/TEA_TASK_SUB.cs | 31 +++ .../Entities/BQ/TED_SA_INV.cs | 6 +- .../ExChangeCenterDbContext.cs | 5 +- .../SettleAccountEntityFrameworkCoreModule.cs | 17 +- .../EntityFrameworkCore/WMSBJBMPTDbContext.cs | 13 - 9 files changed, 252 insertions(+), 79 deletions(-) create mode 100644 code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/TEA_TASK_SUB.cs 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 3e1c6510..f6cbf570 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 @@ -1,9 +1,14 @@ using System; +using System.Collections; using System.Collections.Generic; using System.ComponentModel.DataAnnotations; +using System.DirectoryServices.ActiveDirectory; using System.Linq; using System.Reflection; +using System.Security.Policy; using System.Threading.Tasks; +using DocumentFormat.OpenXml.Drawing; +using DocumentFormat.OpenXml.Wordprocessing; using EFCore.BulkExtensions; using Magicodes.ExporterAndImporter.Core; using Magicodes.ExporterAndImporter.Csv; @@ -11,6 +16,7 @@ using Magicodes.ExporterAndImporter.Excel; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; +using Microsoft.CodeAnalysis.Operations; using Microsoft.OpenApi.Writers; using SettleAccount.Domain.BQ; using ShardingCore.Extensions; @@ -27,11 +33,20 @@ using Win.Sfs.SettleAccount.Bases; using Win.Sfs.SettleAccount.Bases.DomainServices; using Win.Sfs.SettleAccount.CommonManagers; using Win.Sfs.SettleAccount.Constant; +using Win.Sfs.SettleAccount.Customers; using Win.Sfs.SettleAccount.Entities.BQ.Dtos; using Win.Sfs.SettleAccount.Entities.BQ.Managers; +using Win.Sfs.SettleAccount.Entities.BQ.Syncs; +using Win.Sfs.SettleAccount.Entities.BQ.Temp; +using Win.Sfs.SettleAccount.Entities.Invoices; +using Win.Sfs.SettleAccount.EntityFrameworkCore; using Win.Sfs.SettleAccount.ExcelImporter; using Win.Sfs.SettleAccount.ExportReports; +using Win.Sfs.SettleAccount.Suppliers; +using Win.Sfs.Shared; using Win.Sfs.Shared.RepositoryBase; +using static Dm.parser.LVal; +using static LinqToDB.Sql; namespace Win.Sfs.SettleAccount.Entities.BQ { @@ -39,6 +54,19 @@ namespace Win.Sfs.SettleAccount.Entities.BQ [Route("api/settleaccount/[controller]/[action]")] public class INVOICE_SERVICE : BASE_SERVICE { + /// + /// 数据上下文 + /// + private readonly SettleAccountDbContext _settleAccountDbContext; + /// + /// WMS数据上下文 + /// + private readonly WMSBJBMPTDbContext _wmsBJBMPTContext; + /// + /// 数据中心S数据上下文 + /// + private readonly ExChangeCenterDbContext _exChangeCenterDbContext; + private readonly INormalEfCoreRepository _repository; private readonly INormalEfCoreRepository _wRepository; private readonly INormalEfCoreRepository _sRepository; @@ -49,7 +77,11 @@ namespace Win.Sfs.SettleAccount.Entities.BQ private readonly HBPO_CAN_SA_MNG _hbpoMng; private readonly INV_MNG _invMng; private readonly BaseDomainService _baseservice; - public INVOICE_SERVICE(IExcelImportAppService excelImportService, + public INVOICE_SERVICE( + SettleAccountDbContext settleAccountDbContext, + WMSBJBMPTDbContext wmsBJBMPTContext, + ExChangeCenterDbContext exChangeCenterDbContext, + IExcelImportAppService excelImportService, ISnowflakeIdGenerator snowflakeIdGenerator, ICommonManager commonManager, INormalEfCoreRepository repository, @@ -65,6 +97,9 @@ namespace Win.Sfs.SettleAccount.Entities.BQ ) : base(excelImportService, snowflakeIdGenerator, commonManager) { + _settleAccountDbContext = settleAccountDbContext; + _wmsBJBMPTContext = wmsBJBMPTContext; + _exChangeCenterDbContext = exChangeCenterDbContext; _baseservice = baseservice; _repository = repository; _wRepository = wRepository; @@ -77,6 +112,116 @@ namespace Win.Sfs.SettleAccount.Entities.BQ _invMng = invMng; } + /// + /// 提交到QAD + /// + /// + /// 已扣减发票提交到QAD + /// + [HttpPost] + public virtual async Task SubmitToQad(List invbillNums) + { + var invoiceGrps = _settleAccountDbContext.Set() + .Where(t => invbillNums.Contains(t.InvbillNum)) + .Where(t => t.State == SettleBillState.已扣减) + .ToList(); + + invbillNums = invoiceGrps.Select(t => t.InvbillNum).ToList(); + + var invoiceGrpDetails = _settleAccountDbContext.Set() + .Where(t => invbillNums.Contains(t.InvbillNum)) + .ToList(); + + var taskId = GuidGenerator.Create(); + var teaTaskSub = new TEA_TASK_SUB() + { + GUID = taskId, + TaskState = 0, + TaskID = taskId, + TableName = "TED_SA_INV", + Creator = "SAS", + Subscriber = "QAD", + Domain = "BJBMPT", + Site = "BJ02", + CreateTime = DateTime.Now, + UpdateTime = DateTime.Now, + }; + + var tedSaInvs = invoiceGrpDetails.Join(invoiceGrps, x => x.InvbillNum, y => y.InvbillNum, (x, y) => + { + return new TED_SA_INV() + { + GUID = GuidGenerator.Create(), + TaskID = taskId, + InvoiceNumber = y.RealnvBillNum, + SASInvoiceNumber = y.InvbillNum, + Customer = y.ClientCode, + BillTo = y.ClientCode, + InvoiceDate = y.CreationTime, + Site = "BJ02", + TYPE = default, + PartNumber = x.LU, + InvoiceQuatity = x.Qty, + Price = x.PRICE, + Supplier = default, + Remark = default, + InvoiceNetAmount = x.Amt, + InvoiceTaxAmount = x.Amt * 0.13m, + TaxRate = 0.13m, + Location = $"C{y.ClientCode}", + InvoiceNet = default, + InvoiceTax = default, + begintime = x.BeginDate, + endtime = x.EndDate, + Domain = "BJBMPT" + }; + }).ToList(); + + var invoiceGrpTedSaInvs = invoiceGrps.Select(t => + { + return new TED_SA_INV() + { + GUID = GuidGenerator.Create(), + TaskID = taskId, + UID = default, + InvoiceNumber = t.RealnvBillNum, + SASInvoiceNumber = t.InvbillNum, + Customer = t.ClientCode, + BillTo = t.ClientCode, + InvoiceDate = t.CreationTime, + Site = "BJ02", + TYPE = default, + PartNumber = default, + InvoiceQuatity = default, + Price = default, + Supplier = default, + Remark = default, + InvoiceNetAmount = default, + InvoiceTaxAmount = default, + TaxRate = 0.13m, + Location = $"C{t.ClientCode}", + InvoiceNet = t.Amt, + InvoiceTax = default, + begintime = default, + endtime = default, + Domain = "BJBMPT" + }; + }); + + tedSaInvs.AddRange(invoiceGrpTedSaInvs); + if (tedSaInvs.Any()) + { + await _exChangeCenterDbContext.Set().AddAsync(teaTaskSub).ConfigureAwait(false); + await _exChangeCenterDbContext.Set().AddRangeAsync(tedSaInvs).ConfigureAwait(false); + await _exChangeCenterDbContext.SaveChangesAsync().ConfigureAwait(false); + invoiceGrps.ForEach(t => t.State = SettleBillState.已提交QAD); + await _settleAccountDbContext.SaveChangesAsync().ConfigureAwait(false); + } + + await Task.CompletedTask.ConfigureAwait(false); + return new OkResult(); + } + /// /// 通过审核 /// @@ -196,24 +341,24 @@ namespace Win.Sfs.SettleAccount.Entities.BQ { INVOICE_WAIT_DETAIL_BJ_DTO bj = new INVOICE_WAIT_DETAIL_BJ_DTO(); bj.LU = itm.LU; - bj.InvbillNum=itm.InvbillNum; + bj.InvbillNum = itm.InvbillNum; bj.PRICE = itm.PRICE; - // bj.InvGroupNum = itm.InvGroupNum; - bj.DeliveryIndexNumber =itm.GetProperty("DeliveryIndexNumber",""); + // bj.InvGroupNum = itm.InvGroupNum; + bj.DeliveryIndexNumber = itm.GetProperty("DeliveryIndexNumber", ""); bj.Qty = itm.Qty; bj.PRICE = itm.PRICE; bj.Amt = Math.Round(itm.PRICE * itm.Qty, 2); bj.RealAmt = Math.Round(Math.Round(itm.PRICE * itm.Qty, 2) * 0.13m, 2); bj.TaxAmt = Math.Round(itm.PRICE * itm.Qty, 2) + Math.Round(Math.Round(itm.PRICE * itm.Qty, 2) * 0.13m, 2); - bj.Extend1=itm.Extend1;//合同号 - bj.VendorCode = itm.GetProperty("VendorCode","");//供应商代码 - bj.VendorName = itm.GetProperty("VendorName","");//供应商名称 - bj.DeliveryNumber = itm.GetProperty("DeliveryNumber","");//交货号; - bj.PN = itm.GetProperty("PN","");// - bj.PO= itm.GetProperty("PO",""); - bj.ProductionGroup = itm.GetProperty("PartGroup",""); + bj.Extend1 = itm.Extend1;//合同号 + bj.VendorCode = itm.GetProperty("VendorCode", "");//供应商代码 + bj.VendorName = itm.GetProperty("VendorName", "");//供应商名称 + bj.DeliveryNumber = itm.GetProperty("DeliveryNumber", "");//交货号; + bj.PN = itm.GetProperty("PN", "");// + bj.PO = itm.GetProperty("PO", ""); + bj.ProductionGroup = itm.GetProperty("PartGroup", ""); bj.LineCode = itm.LineCode; - bj.BeginDate=itm.BeginDate; + bj.BeginDate = itm.BeginDate; bj.EndDate = itm.EndDate; //bj.DeliveryNumber = itm.GetProperty("DeliveryNumber", "");//交货号 //bj.InvbillNum = itm.GetProperty("InvoiceNumber", "");//发票号 @@ -242,8 +387,8 @@ namespace Win.Sfs.SettleAccount.Entities.BQ //InvGroupNum = itm.InvGroupNum, LU = itm.LU, //PartCode = itm.PartCode, - PO=itm.PO, - PN=itm.PN, + PO = itm.PO, + PN = itm.PN, PRICE = itm.PRICE, Qty = itm.Qty, Amt = itm.Amt, @@ -251,18 +396,18 @@ namespace Win.Sfs.SettleAccount.Entities.BQ VendorCode = itm.VendorCode, VendorName = itm.VendorName, // PurchaseOrderNumber = itm.PurchaseOrderNumber, - DeliveryIndexNumber = itm.DeliveryIndexNumber , + DeliveryIndexNumber = itm.DeliveryIndexNumber, Extend1 = itm.Extend1, BeginDate = itm.BeginDate, EndDate = itm.EndDate, - RealAmt=itm.RealAmt, - TaxAmt=itm.TaxAmt, + RealAmt = itm.RealAmt, + TaxAmt = itm.TaxAmt, SettleDate = itm.SettleDate, - ProductionGroup=itm.ProductionGroup, - LineCode=itm.LineCode - + ProductionGroup = itm.ProductionGroup, + LineCode = itm.LineCode + }; - entity.INVOICE_WAIT_DETAIL_BJ = bjquery.OrderBy(p=>p.LineCode).ToList(); + entity.INVOICE_WAIT_DETAIL_BJ = bjquery.OrderBy(p => p.LineCode).ToList(); } else @@ -364,41 +509,42 @@ namespace Win.Sfs.SettleAccount.Entities.BQ .Select(p => new JIT_UNSETTLED_DETAIL_DTO { LU = p.Key.LU, GroupNum = p.Key.SettleGroupNum, Qty = p.Sum(itm => itm.Qty.Value) }); entity.JIT_UNSETTLED_DETAIL = unsettledList.ToList().OrderBy(p => p.GroupNum).ThenBy(p => p.LU).ToList(); } - if (first.BusinessType == EnumBusinessType.JisHBPO || first.BusinessType == EnumBusinessType.JisBBAC || first.BusinessType==EnumBusinessType.ZhiGongJianHBPO) + if (first.BusinessType == EnumBusinessType.JisHBPO || first.BusinessType == EnumBusinessType.JisBBAC || first.BusinessType == EnumBusinessType.ZhiGongJianHBPO) { entity.INVOICE_MAP_GROUP = lscompare.ToList().OrderBy(p => p.SettleGroupNum).ToList();//包含不可结结算分组号 } - if (first.BusinessType == EnumBusinessType.MaiDanJianHBPO ) + if (first.BusinessType == EnumBusinessType.MaiDanJianHBPO) { //List maidan = new List(); var maiquery = from itm in m - join itm1 in invs on itm.InvbillNum equals itm1.InvbillNum - select - new MAIDAN_HBPO_INVOICE_MAP_GROUP_DTO() - { - Extend1 = itm.Extend1, - InvGroupNum = itm.InvGroupNum, - SettleGroupNum = itm.SettleGroupNum, - InvbillNum = itm.InvbillNum, - RealInvBillNum = itm1.RealnvBillNum - }; + join itm1 in invs on itm.InvbillNum equals itm1.InvbillNum + select + new MAIDAN_HBPO_INVOICE_MAP_GROUP_DTO() + { + Extend1 = itm.Extend1, + InvGroupNum = itm.InvGroupNum, + SettleGroupNum = itm.SettleGroupNum, + InvbillNum = itm.InvbillNum, + RealInvBillNum = itm1.RealnvBillNum + }; entity.MAIDAN_HBPO_INVOICE_MAP_GROUP = maiquery.ToList(); List unsettle = new List(); foreach (var itm in sdtos) { - unsettle.Add(new MAIDAN_HBPO_UNSETTLED_DETAIL_DTO() { - GroupNum=itm.SettleGroupNum, - LU=itm.LU, - PN=itm.Extend1, - + unsettle.Add(new MAIDAN_HBPO_UNSETTLED_DETAIL_DTO() + { + GroupNum = itm.SettleGroupNum, + LU = itm.LU, + PN = itm.Extend1, + }); } entity.MAIDAN_HBPO_UNSETTLED_DETAIL = unsettle; } - - entity.ADJ_DETAIL = adjQuery.ToList().OrderBy(p=>p.GroupNum).ThenBy(p=>p.LU).ToList(); + + entity.ADJ_DETAIL = adjQuery.ToList().OrderBy(p => p.GroupNum).ThenBy(p => p.LU).ToList(); return entity; } [HttpPost] @@ -482,7 +628,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ #endregion // 发票分组 - if (first.BusinessType == EnumBusinessType.JisBBAC || first.BusinessType == EnumBusinessType.JisHBPO || first.BusinessType==EnumBusinessType.ZhiGongJianHBPO) + if (first.BusinessType == EnumBusinessType.JisBBAC || first.BusinessType == EnumBusinessType.JisHBPO || first.BusinessType == EnumBusinessType.ZhiGongJianHBPO) { if (m != null) { @@ -512,12 +658,12 @@ namespace Win.Sfs.SettleAccount.Entities.BQ } } //jis业务,发票分组对应关系,未结数据,调整数据 - if (first.BusinessType == EnumBusinessType.JisBBAC || first.BusinessType == EnumBusinessType.JisHBPO || first.BusinessType==EnumBusinessType.ZhiGongJianHBPO) + if (first.BusinessType == EnumBusinessType.JisBBAC || first.BusinessType == EnumBusinessType.JisHBPO || first.BusinessType == EnumBusinessType.ZhiGongJianHBPO) { foreach (var itm in entities) { var mgroup = m.Where(p => p.InvbillNum == itm.InvbillNum).ToList(); - var adjp = adj.Where(p => p.InvBillNum == itm.InvbillNum).ToList(); + var adjp = adj.Where(p => p.InvBillNum == itm.InvbillNum).ToList(); var nolist = not.Where(p => p.InvBillNum == itm.InvbillNum).ToList(); var lsC = nolist.Where(p => p.Extend1 == "可结算") .GroupBy(p => new diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Syncs/TM_BJBMPT_JIS_RECORD.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Syncs/TM_BJBMPT_JIS_RECORD.cs index d580d9d8..a5f9eddf 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Syncs/TM_BJBMPT_JIS_RECORD.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Syncs/TM_BJBMPT_JIS_RECORD.cs @@ -5,11 +5,12 @@ using System.ComponentModel.DataAnnotations.Schema; namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs { -#if DEBUG + //#if DEBUG + // [Table("TM_BJBMPT_JIS_RECORD")] + //#else + // [Table("EX_BJBMPT_JIS_RECORD")] + //#endif [Table("TM_BJBMPT_JIS_RECORD")] -#else - [Table("EX_BJBMPT_JIS_RECORD")] -#endif public class TM_BJBMPT_JIS_RECORD { [Key] diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Syncs/TM_BJBMPT_JIT_RECORD.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Syncs/TM_BJBMPT_JIT_RECORD.cs index 8c6214a7..87e2aad5 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Syncs/TM_BJBMPT_JIT_RECORD.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Syncs/TM_BJBMPT_JIT_RECORD.cs @@ -8,11 +8,12 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs /// /// Jis小件 /// -#if DEBUG + //#if DEBUG + // [Table("TM_BJBMPT_JIT_RECORD")] + //#else + // [Table("EX_BJBMPT_JIT_RECORD")] + //#endif [Table("TM_BJBMPT_JIT_RECORD")] -#else - [Table("EX_BJBMPT_JIT_RECORD")] -#endif public class TM_BJBMPT_JIT_RECORD { [Key] diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Syncs/TM_BJBMPT_OTHER_RECORD.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Syncs/TM_BJBMPT_OTHER_RECORD.cs index 22c7245f..d2785a80 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Syncs/TM_BJBMPT_OTHER_RECORD.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Syncs/TM_BJBMPT_OTHER_RECORD.cs @@ -8,11 +8,12 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs /// /// Jit(非Jis) /// -#if DEBUG +//#if DEBUG +// [Table("TM_BJBMPT_OTHER_RECORD")] +//#else +// [Table("EX_BJBMPT_OTHER_RECORD")] +//#endif [Table("TM_BJBMPT_OTHER_RECORD")] -#else - [Table("EX_BJBMPT_OTHER_RECORD")] -#endif public class TM_BJBMPT_OTHER_RECORD { [Key] diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/TEA_TASK_SUB.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/TEA_TASK_SUB.cs new file mode 100644 index 00000000..55796744 --- /dev/null +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/TEA_TASK_SUB.cs @@ -0,0 +1,31 @@ +using System; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; + +namespace Win.Sfs.SettleAccount.Entities.BQ +{ + public class TEA_TASK_SUB + { + [Key] + public Guid GUID { get; set; } + public int TaskState { get; set; } + public Guid TaskID { get; set; } + public string TableName { get; set; } + public string TableName2 { get; set; } + public string TableName3 { get; set; } + public string Creator { get; set; } + public int DataCount { get; set; } + public string Subscriber { get; set; } + public int FailedCount { get; set; } + public string FailedInfo { get; set; } + public string Domain { get; set; } + public string Site { get; set; } + [DatabaseGenerated(DatabaseGeneratedOption.Identity)] + public int UID { get; set; } + public string CreateUser { get; set; } + public DateTime CreateTime { get; set; } + public string Remark { get; set; } + public string UpdateUser { get; set; } + public DateTime UpdateTime { get; set; } + } +} diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/TED_SA_INV.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/TED_SA_INV.cs index 14d3d4e9..c778cc19 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/TED_SA_INV.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/TED_SA_INV.cs @@ -1,14 +1,16 @@ using System; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; namespace Win.Sfs.SettleAccount.Entities.BQ { public class TED_SA_INV { - + [Key] public Guid GUID { set; get; } public Guid TaskID { set; get; } - + [DatabaseGenerated(DatabaseGeneratedOption.Identity)] public int UID { set; get; } /// diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/EntityFrameworkCore/ExChangeCenterDbContext.cs b/code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/EntityFrameworkCore/ExChangeCenterDbContext.cs index 3031bda8..0f98d446 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/EntityFrameworkCore/ExChangeCenterDbContext.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/EntityFrameworkCore/ExChangeCenterDbContext.cs @@ -9,10 +9,11 @@ namespace Win.Sfs.SettleAccount.EntityFrameworkCore public class ExChangeCenterDbContext : DbContext { + public DbSet TEA_TASK_SUB { get; set; } public DbSet TED_SA_INV { set; get; } - public ExChangeCenterDbContext(DbContextOptions options) : base(options) - { + public ExChangeCenterDbContext(DbContextOptions options) : base(options) + { } diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/EntityFrameworkCore/SettleAccountEntityFrameworkCoreModule.cs b/code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/EntityFrameworkCore/SettleAccountEntityFrameworkCoreModule.cs index 28176f61..ef722c22 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/EntityFrameworkCore/SettleAccountEntityFrameworkCoreModule.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/EntityFrameworkCore/SettleAccountEntityFrameworkCoreModule.cs @@ -1,4 +1,6 @@ +using System.Configuration; using Microsoft.EntityFrameworkCore; +using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Volo.Abp.AuditLogging.EntityFrameworkCore; using Volo.Abp.Dapper; @@ -45,6 +47,7 @@ namespace Win.Sfs.SettleAccount private static void ConfigureRepository(ServiceConfigurationContext context) { + var configuration = context.Services.GetConfiguration(); context.Services.AddAbpDbContext(options => { options.AddDefaultRepositories(); @@ -59,13 +62,13 @@ namespace Win.Sfs.SettleAccount context.Services.AddDbContext(options => { - //IConfiguration config = new ConfigurationBuilder() - // .SetBasePath(Directory.GetCurrentDirectory()) - // .AddJsonFile("appsettings.json") - // .Build(); - //var ConnectStr = config.GetConnectionString("WMSBJBMPT"); - //optionsBuilder.UseSqlServer(ConnectStr); - options.UseSqlServer("Server=dev.ccwin-in.com,6208;Database=WMS_BJBMPT_2;User ID=sa;Password=ChangkeTec@2021;Trusted_Connection=False;TrustServerCertificate=True;"); + options.UseSqlServer(configuration.GetConnectionString("WMSBJBMPT")); + //options.UseSqlServer("Server=dev.ccwin-in.com,6208;Database=WMS_BJBMPT_2;User ID=sa;Password=ChangkeTec@2021;Trusted_Connection=False;TrustServerCertificate=True;"); + }); + + context.Services.AddDbContext(options => + { + options.UseSqlServer(configuration.GetConnectionString("ExChangeCenterService")); }); // context.Services.AddTransient(typeof(IInventoryDetailRepository), diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/EntityFrameworkCore/WMSBJBMPTDbContext.cs b/code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/EntityFrameworkCore/WMSBJBMPTDbContext.cs index 42b35fd7..e5d47f3c 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/EntityFrameworkCore/WMSBJBMPTDbContext.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/EntityFrameworkCore/WMSBJBMPTDbContext.cs @@ -19,19 +19,6 @@ namespace Win.Sfs.SettleAccount.EntityFrameworkCore { } - //protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) - //{ - // if (!optionsBuilder.IsConfigured) - // { - // IConfiguration config = new ConfigurationBuilder() - // .SetBasePath(Directory.GetCurrentDirectory()) - // .AddJsonFile("appsettings.json") - // .Build(); - // var ConnectStr = config.GetConnectionString("WMSBJBMPT"); - // optionsBuilder.UseSqlServer(ConnectStr); - // } - //} - protected override void OnModelCreating(ModelBuilder modelBuilder) { base.OnModelCreating(modelBuilder); From b50fd1ea31f721fbed76b30a7953046567566512 Mon Sep 17 00:00:00 2001 From: mahao Date: Mon, 25 Sep 2023 09:32:43 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=B8=80=E6=AC=A1?= =?UTF-8?q?=E5=8F=91=E8=BF=90=E5=90=8C=E6=AD=A5=E6=95=B0=E6=8D=AE=E9=87=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Entities/BQ/Syncs/JisBBACSeSyncBaseAppService.cs | 4 ++-- .../Entities/BQ/Syncs/JisHBPOSeSyncBaseAppService.cs | 4 ++-- .../Entities/BQ/Syncs/JitSeSyncAppService.cs | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/JisBBACSeSyncBaseAppService.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/JisBBACSeSyncBaseAppService.cs index 8b2e7ecd..7cd62c05 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/JisBBACSeSyncBaseAppService.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/JisBBACSeSyncBaseAppService.cs @@ -98,7 +98,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs .Where(t => t.UID > int.Parse(syncPosition)) .Where(t => t.DeliverBillType == deliverBillType) .Where(t => deliverSubBillTypes.Contains(t.DeliverSubBillType)) - .OrderBy(b => b.UID).Take(100_000).ToList(); + .OrderBy(b => b.UID).Take(10_000).ToList(); var jisSeDetails = ObjectMapper.Map, List>(wmsSeRecords); if (jisSeDetails.Any()) { @@ -140,7 +140,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs .Where(t => t.UID > int.Parse(syncPosition)) .Where(t => t.DeliverBillType == deliverBillType) .Where(t => deliverSubBillTypes.Contains(t.DeliverSubBillType)) - .OrderBy(b => b.UID).Take(100_000).ToList(); + .OrderBy(b => b.UID).Take(10_000).ToList(); var jisSeDetails = ObjectMapper.Map, List>(wmsSeRecords); if (jisSeDetails.Any()) { diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/JisHBPOSeSyncBaseAppService.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/JisHBPOSeSyncBaseAppService.cs index 3084dcf5..d5074f24 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/JisHBPOSeSyncBaseAppService.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/JisHBPOSeSyncBaseAppService.cs @@ -99,7 +99,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs .Where(t => t.UID > int.Parse(syncPosition)) .Where(t => t.DeliverBillType == deliverBillType) .Where(t => deliverSubBillTypes.Contains(t.DeliverSubBillType)) - .OrderBy(b => b.UID).Take(100_000).ToList(); + .OrderBy(b => b.UID).Take(10_000).ToList(); var jisSeDetails = ObjectMapper.Map, List>(wmsSeRecords); if (jisSeDetails.Any()) { @@ -141,7 +141,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs .Where(t => t.UID > int.Parse(syncPosition)) .Where(t => t.DeliverBillType == deliverBillType) .Where(t => deliverSubBillTypes.Contains(t.DeliverSubBillType)) - .OrderBy(b => b.UID).Take(100_000).ToList(); + .OrderBy(b => b.UID).Take(10_000).ToList(); var jisSeDetails = ObjectMapper.Map, List>(wmsRecords); if (jisSeDetails.Any()) { 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 index bfb66f7e..5eecce8d 100644 --- 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 @@ -83,7 +83,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs Expression> predicate = (t) => t.DeliverBillType == deliverBillType && t.UID > int.Parse(syncPosition) && (!deliverSubBillTypes.Any() || deliverSubBillTypes.Contains(t.DeliverSubBillType)); //WMS发运记录 - var wmsSeRecords = _wmsBJBMPTContext.TM_BJBMPT_OTHER_RECORD.Where(predicate).Take(100_000).OrderBy(b => b.UID).ToList(); + var wmsSeRecords = _wmsBJBMPTContext.TM_BJBMPT_OTHER_RECORD.Where(predicate).Take(10_000).OrderBy(b => b.UID).ToList(); var pubSeDetails = ObjectMapper.Map, List>(wmsSeRecords); if (pubSeDetails.Any()) { From 13ff2997f01f01f3ae3891b53285f6f248a1b2ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AD=A6=20=E8=B5=B5?= <89237069@qq.com> Date: Mon, 25 Sep 2023 09:45:25 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=8F=91=E7=A5=A8?= =?UTF-8?q?=E6=98=8E=E7=BB=86=E4=B8=AD=E6=96=87=E6=8F=8F=E8=BF=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Bases/BA_SERVICE.cs | 12 +++++++---- .../Entities/BQ/BBAC_NOT_SA_SERVICE.cs | 1 - .../Entities/BQ/INVOICE_SERVICE.cs | 20 +++++++++---------- .../BaseDomainServices/BaseDomainService.cs | 16 ++++++++++++--- .../Entities/BQ/Managers/PUB_NOT_SA_MNG.cs | 5 ----- 5 files changed, 30 insertions(+), 24 deletions(-) diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Bases/BA_SERVICE.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Bases/BA_SERVICE.cs index 0611e8af..0044b45f 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Bases/BA_SERVICE.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Bases/BA_SERVICE.cs @@ -133,11 +133,17 @@ namespace Win.Sfs.SettleAccount.Bases public virtual async Task DetailQueryAsync(INVOICE_GRP_REQ_DTO input) { INVOICE_GRP_DETAIL_DTO entity = new INVOICE_GRP_DETAIL_DTO(); - var materialList = await _baseservice.GetMaterialList().ConfigureAwait(false); + var invs = await _repository.GetListByFilterAsync(input.Filters, input.Sorting, int.MaxValue, input.SkipCount).ConfigureAwait(false); var m = await _mRepository.GetListByFilterAsync(input.Filters, input.Sorting, int.MaxValue, input.SkipCount).ConfigureAwait(false); var mdtos = ObjectMapper.Map, List>(m); var first = invs.FirstOrDefault(); + var materialList = await _baseservice.GetMaterialList(first.BusinessType).ConfigureAwait(false); + //if (materialList.Count == 0) + //{ + // throw new UserFriendlyException($" 零件关系表无对应业务,零件关系记录!", "400"); + //} + if (invs.FirstOrDefault().BusinessType == EnumBusinessType.JisBBAC) { @@ -150,7 +156,7 @@ namespace Win.Sfs.SettleAccount.Bases select new INVOICE_WAIT_DETAIL_BBAC_DTO() { - PartDesc = tm == null ? string.Empty : itm.PartDesc, + PartDesc = tm == null ? string.Empty : tm.MaterialDesc, InvDate = itm1.CreationTime, RealInvbillNum = string.IsNullOrEmpty(itm1.RealnvBillNum) ? string.Empty : itm1.RealnvBillNum, Version = itm.Version, @@ -422,14 +428,12 @@ namespace Win.Sfs.SettleAccount.Bases [HttpPost] public virtual async Task ReceivedAsync(List p_ins) { - bool issuc = await _invMng.ReceivedAsync(p_ins).ConfigureAwait(false); if (issuc == true) { return new JsonResult(new { Code = 200, Message = "收票成功" }); } - return new JsonResult(new { Code = 400, Message = "收票失败" }); } protected virtual async Task> GetMapGroupAsync(INVOICE_GRP_REQ_DTO input) diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/BBAC_NOT_SA_SERVICE.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/BBAC_NOT_SA_SERVICE.cs index 0c889c03..4a481eac 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/BBAC_NOT_SA_SERVICE.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/BBAC_NOT_SA_SERVICE.cs @@ -48,7 +48,6 @@ namespace Win.Sfs.SettleAccount.Entities.BQ } else { - var errors = await _bbacNotMng.GenerateSettlementOrder(entitys).ConfigureAwait(false); if (errors.Count > 0) { 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 d9d62bcc..7ea30593 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 @@ -17,6 +17,7 @@ using SettleAccount.Domain.BQ; using ShardingCore.Extensions; using Shouldly; using SqlSugar; +using Volo.Abp; using Volo.Abp.Application.Dtos; using Volo.Abp.Application.Services; using Volo.Abp.Data; @@ -154,19 +155,16 @@ namespace Win.Sfs.SettleAccount.Entities.BQ public virtual async Task DetailQueryAsync(INVOICE_GRP_REQ_DTO input) { INVOICE_GRP_DETAIL_DTO entity = new INVOICE_GRP_DETAIL_DTO(); - input.Filters.Add(new FilterCondition("InvoiceState", "1", EnumFilterAction.Equal, EnumFilterLogic.And)); - - - var materialList = await _baseservice.GetMaterialList().ConfigureAwait(false); var invs = await _repository.GetListByFilterAsync(input.Filters, input.Sorting, int.MaxValue, input.SkipCount).ConfigureAwait(false); var m = await _mRepository.GetListByFilterAsync(input.Filters, input.Sorting, int.MaxValue, input.SkipCount).ConfigureAwait(false); var mdtos = ObjectMapper.Map, List>(m); var first = invs.FirstOrDefault(); - - - - + var materialList = await _baseservice.GetMaterialList(first.BusinessType).ConfigureAwait(false); + //if (materialList.Count == 0) + //{ + // throw new UserFriendlyException($" 零件关系表无对应业务,零件关系记录!", "400"); + //} if (invs.FirstOrDefault().BusinessType == EnumBusinessType.JisBBAC) { var A = await _wRepository.GetListByFilterAsync(input.Filters, input.Sorting, int.MaxValue, input.SkipCount).ConfigureAwait(false); @@ -178,7 +176,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ select new INVOICE_WAIT_DETAIL_BBAC_DTO() { - PartDesc = tm == null ? string.Empty : itm.PartDesc, + PartDesc = tm == null ? string.Empty : tm.MaterialDesc, InvDate = itm1.CreationTime, RealInvbillNum = string.IsNullOrEmpty(itm1.RealnvBillNum) ? string.Empty : itm1.RealnvBillNum, Version = itm.Version, @@ -286,7 +284,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ select new INVOICE_WAIT_DETAIL_DTO() { - PartDesc = tm == null ? string.Empty : itm.PartDesc, + PartDesc = tm == null ? string.Empty : tm.MaterialDesc, InvDate = itm1.CreationTime, RealInvbillNum = string.IsNullOrEmpty(itm1.RealnvBillNum) ? string.Empty : itm1.RealnvBillNum, Version = itm.Version, @@ -456,7 +454,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ { IExporter _csv = new CsvExporter(); ExcelExporter _excel = new ExcelExporter(); - var materialList = await _baseservice.GetMaterialList().ConfigureAwait(false); + // var materialList = await _baseservice.GetMaterialList().ConfigureAwait(false); var entities = await _repository.GetListByFilterAsync(input.Filters, input.Sorting, int.MaxValue, 0, true).ConfigureAwait(false); var first = entities.FirstOrDefault(); var dtoDetails = ObjectMapper.Map, List>(entities); 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 2d980eb4..d943db3b 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 @@ -43,15 +43,25 @@ namespace Win.Sfs.SettleAccount.Bases.DomainServices _bomshipRepository = bomshipRepository; } - public async Task> GetMaterialList() + public async Task> GetMaterialList(EnumBusinessType businessType) { List ls = new List(); - var lst = await _relationshipRepository.Where(p => !string.IsNullOrEmpty(p.SettleMaterialCode)).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(); } + //public async Task> CheckRelationlList(EnumBusinessType businessType,) + //{ + // List ls = new List(); + // 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(); + //} + + + public static async Task DoWorkBulkWithTransaction(DbContext dbContext, Action p_dowork) { using (var transaction = await dbContext.Database.BeginTransactionAsync().ConfigureAwait(false)) diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Managers/PUB_NOT_SA_MNG.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Managers/PUB_NOT_SA_MNG.cs index d072b567..2adccc6f 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Managers/PUB_NOT_SA_MNG.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Managers/PUB_NOT_SA_MNG.cs @@ -91,9 +91,6 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers priceList = _priceRepository.Where(p => p.IsCancel == false && p.ClientCode==site).ToList();//价格单 } - - - if (first.BusinessType == EnumBusinessType.ZhiGongJianBBAC || first.BusinessType == EnumBusinessType.BeiJian || first.BusinessType == EnumBusinessType.YinDuJian ) @@ -123,8 +120,6 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers return errors; } - - var billNumber = OrderNumberGenerator.GenerateOrderNumber("N"); var _entity = new PUB_CAN_SA(); _entity.SetId(Guid.NewGuid());