From f823e2384c9dc9a9074b5d30f43599f561c839bb Mon Sep 17 00:00:00 2001 From: zhouhongjun <565221961@qq.com> Date: Tue, 30 Jul 2024 20:42:59 +0800 Subject: [PATCH] =?UTF-8?q?=E9=80=9A=E8=BF=87SQL=E6=9B=B4=E6=96=B0?= =?UTF-8?q?=E7=BB=93=E7=AE=97=E5=BA=93=E4=BD=8D=E3=80=81=E5=8F=91=E8=BF=90?= =?UTF-8?q?=E9=9B=B6=E4=BB=B6=E5=8F=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../JisBBACSaSeEdiCompareExportService.cs | 2 +- .../JisHBPOSaSeEdiCompareExportService.cs | 2 +- .../Report/SaSeEdiCompareExportBaseService.cs | 73 +++++++++++++++++++ 3 files changed, 75 insertions(+), 2 deletions(-) diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/JisBBACSaSeEdiCompareExportService.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/JisBBACSaSeEdiCompareExportService.cs index b592a689..592eb97d 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/JisBBACSaSeEdiCompareExportService.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/JisBBACSaSeEdiCompareExportService.cs @@ -103,7 +103,7 @@ namespace SettleAccount.Job.Services.Report #endregion #region 结算数据处理 - HandleSaDetails(saSeEdiCompareDiffs, businessType, version); + HandleSQLSaDetails(saSeEdiCompareDiffs, businessType, version); HandleSaDetailsMain(saSeEdiCompareDiffs, businessType, version); #endregion diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/JisHBPOSaSeEdiCompareExportService.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/JisHBPOSaSeEdiCompareExportService.cs index f5b11f1c..aa9e9b24 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/JisHBPOSaSeEdiCompareExportService.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/JisHBPOSaSeEdiCompareExportService.cs @@ -99,7 +99,7 @@ namespace SettleAccount.Job.Services.Report #endregion #region 结算数据处理 - HandleSaDetails(saSeEdiCompareDiffs, businessType, version); + HandleSQLSaDetails(saSeEdiCompareDiffs, businessType, version); HandleSaDetailsMain(saSeEdiCompareDiffs, businessType, version); #endregion diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/SaSeEdiCompareExportBaseService.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/SaSeEdiCompareExportBaseService.cs index 141a13f8..1a2a9880 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/SaSeEdiCompareExportBaseService.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/SaSeEdiCompareExportBaseService.cs @@ -1,17 +1,23 @@ using System; using System.Collections.Generic; +using System.Data.SqlClient; using System.Linq; +using System.Threading.Tasks; using EFCore.BulkExtensions; using Magicodes.ExporterAndImporter.Core.Extension; using Magicodes.ExporterAndImporter.Excel; using Microsoft.AspNetCore.SignalR; +using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.DependencyInjection; using NPOI.HPSF; using SettleAccount.Bases; using SettleAccount.Domain.BQ; using SettleAccount.Job.SignalR; +using Volo.Abp; using Win.Sfs.SettleAccount; using Win.Sfs.SettleAccount.Consts; +using Win.Sfs.SettleAccount.Entities.BQ.Vmi; using Win.Sfs.SettleAccount.Enums; using Win.Sfs.SettleAccount.Reports; @@ -209,6 +215,73 @@ namespace SettleAccount.Job.Services.Report } } + /// + /// 结算数据处理-直接执行sql + /// + /// + /// 比对上发有发运的结算数据写入库位、替换零件号 + /// + public virtual void HandleSQLSaDetails(List saSeEdiCompareDiff, EnumBusinessType businessType, int version) + where TCanSa : SA_CAN_BASE + where TNotSa : SA_NOT_BASE + { + //通过SQL直接更新库位、替换零件号 + + try + { + if(businessType== EnumBusinessType.JisBBAC) + { + var sql_CAN_SA = @"UPDATE a +SET a.ErpLoc=b.ErpToLoc,a.PartCode=b.RealPartCode,a.RealPartCode=b.RealPartCode +FROM [BQ_SA].[dbo].[Set_BBAC_CAN_SA_DETAIL] a +INNER JOIN [BQ_SA].[dbo].[Set_BBAC_SE_DETAIL] b ON a.LU=b.lu and a.PN=b.PN and a.BusinessType=b.BusinessType +WHERE a.version='" + version + "'"; + + _settleAccountDbContext.Database.ExecuteSqlRaw(sql_CAN_SA); + _settleAccountDbContext.SaveChanges(); + + var sql_NOTCAN_SA = @"UPDATE a +SET a.ErpLoc=b.ErpToLoc,a.PartCode=b.RealPartCode,a.RealPartCode=b.RealPartCode +FROM [BQ_SA].[dbo].[Set_BBAC_NOT_SA_DETAIL] a +INNER JOIN [BQ_SA].[dbo].[Set_BBAC_SE_DETAIL] b ON a.LU=b.lu and a.PN=b.PN and a.BusinessType=b.BusinessType +WHERE a.version='" + version + "'"; + + _settleAccountDbContext.Database.ExecuteSqlRaw(sql_NOTCAN_SA); + _settleAccountDbContext.SaveChanges(); + } + else + { + var sql_CAN_SA = @"UPDATE a +SET a.ErpLoc=b.ErpToLoc,a.PartCode=b.RealPartCode,a.RealPartCode=b.RealPartCode +FROM [BQ_SA].[dbo].[Set_HBPO_CAN_SA_DETAIL] a +INNER JOIN [BQ_SA].[dbo].[Set_HBPO_SE_DETAIL] b ON a.LU=b.lu and a.PN=b.PN and a.BusinessType=b.BusinessType +WHERE a.version='" + version + "'"; + + _settleAccountDbContext.Database.ExecuteSqlRaw(sql_CAN_SA); + _settleAccountDbContext.SaveChanges(); + + var sql_NOTCAN_SA = @"UPDATE a +SET a.ErpLoc=b.ErpToLoc,a.PartCode=b.RealPartCode,a.RealPartCode=b.RealPartCode +FROM [BQ_SA].[dbo].[Set_HBPO_NOT_SA_DETAIL] a +INNER JOIN [BQ_SA].[dbo].[Set_HBPO_SE_DETAIL] b ON a.LU=b.lu and a.PN=b.PN and a.BusinessType=b.BusinessType +WHERE a.version='" + version + "'"; + + _settleAccountDbContext.Database.ExecuteSqlRaw(sql_NOTCAN_SA); + _settleAccountDbContext.SaveChanges(); + + } + + + } + catch (Exception ex) + { + throw new UserFriendlyException(ex.ToString(), "500"); + } + + + } + + /// /// 处理结算数据 ///