From fa476e3ce720fd62481578d3600b09dbada8234b Mon Sep 17 00:00:00 2001 From: Administrator Date: Thu, 31 Mar 2022 18:06:59 +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/WMS/WmsDetailUnInterface.cs | 2 +- .../SettleKBWithCodeDapperReportRepository.cs | 94 ++++++++++++++++--- 2 files changed, 83 insertions(+), 13 deletions(-) diff --git a/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/WMS/WmsDetailUnInterface.cs b/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/WMS/WmsDetailUnInterface.cs index f3ec426b..e35bdee5 100644 --- a/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/WMS/WmsDetailUnInterface.cs +++ b/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/WMS/WmsDetailUnInterface.cs @@ -148,7 +148,7 @@ namespace Win.Sfs.SettleAccount.Entities.WMS if (guids != null && guids.Count() > 0) { var str = "DECLARE @return_value int \n" + - "EXEC @return_value = [dbo].[p_wms_output_modify]\n" + + "EXEC @return_value = [dbo].[p_wms_interface_modify]\n" + "@billnum = N'{0}', \n" + "@type = {1}, \n" + "@date = N'{2}', \n" + diff --git a/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/Report/SettleKBWithCodeDapperReportRepository.cs b/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/Report/SettleKBWithCodeDapperReportRepository.cs index 37c692d0..ffb9910a 100644 --- a/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/Report/SettleKBWithCodeDapperReportRepository.cs +++ b/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/Report/SettleKBWithCodeDapperReportRepository.cs @@ -48,15 +48,18 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report var date= DateTime.Parse(datestr).AddMonths(1).AddDays(-1); var datetime=date.ToShortDateString()+" 23:59:59 "; - string sqlString = "SELECT\n" + + + + string sqlString= "SELECT\n" + " * ,\n" + -" ISNULL ( temp1.InvoicePrice * Qty, 0 ) AS InvoiceMoney,--开票金额\n" + +" ISNULL ( temp1.InvoicePrice * temp1.Qty, 0 ) AS InvoiceMoney,--开票金额\n" + " ISNULL ( Price * WMSDeliveryQty, 0 ) AS Amount,--金额\n" + -" ISNULL ( Price * Qty, 0 ) AS SettlePrice,--结算金额\n" + +" ISNULL ( Price * temp1.Qty, 0 ) AS SettlePrice,--结算金额\n" + " ( Price - InvoicePrice ) AS InvoiceDiffPrice,--单价差异\n" + -" ISNULL ( Price * Qty - InvoicePrice * Qty, 0 ) AS SumDiffMoney,--总金额差异\n" + -" '' DeliveryOrderNo --出库单号\n" + -" \n" + +" ISNULL ( Price * temp1.Qty - InvoicePrice * temp1.Qty, 0 ) AS SumDiffMoney,--总金额差异\n" + +" '' DeliveryOrderNo,--出库单号\n" + +" ISNULL ( temp3.Qty, 0 ) ReturnQty,\n" + +" WMSDeliveryQty - ISNULL ( temp3.Qty, 0 ) RealQty \n" + "FROM\n" + " (\n" + " SELECT ROW_NUMBER\n" + @@ -86,20 +89,83 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report " temp1.MaterialCode,\n" + " temp1.Kanban \n" + " FROM\n" + -" ( SELECT SUM ( Qty ) Qty, Kanban, MaterialCode FROM Set_KanBanSettle WHERE VERSION < '{0}' GROUP BY kanban, MaterialCode ) temp1\n" + -" INNER JOIN ( SELECT SUM ( WMSDeliveryQty ) Qty, KanBan, MaterialCode FROM Set_WMSKanBanSettle WHERE WMSActualGoodsDate < '{2}' GROUP BY KanBan, MaterialCode ) temp2 ON temp1.Kanban = temp2.KanBan \n" + -" AND temp1.MaterialCode = temp2.KanBan \n" + +" (\n" + +" ( SELECT SUM ( WMSDeliveryQty ) Qty, KanBan, MaterialCode FROM Set_WMSKanBanSettle WHERE WMSActualGoodsDate < '{2}' GROUP BY KanBan, MaterialCode ) temp1\n" + +" LEFT JOIN ( SELECT SUM ( Qty ) Qty, Kanban, MaterialCode FROM Set_KanBanSettle WHERE VERSION < '{0}' GROUP BY kanban, MaterialCode ) temp2 ON temp1.Kanban = temp2.KanBan \n" + +" AND temp1.MaterialCode = temp2.KanBan \n" + +" ) \n" + " ) C ON A.Kanban = C.Kanban \n" + " AND A.MaterialCode = C.MaterialCode\n" + " LEFT JOIN ( SELECT SUM ( amt ) / SUM ( Qty ) InvoicePrice, MaterialCode FROM set_invoice WHERE VERSION = '{0}' GROUP BY materialcode ) d ON A.MaterialCode = d.MaterialCode \n" + " WHERE\n" + -" A.VERSION = '{0}' {1}\n" + +" A.VERSION = '{0}' {1}\n" + " ) TEMP1\n" + +" LEFT JOIN set_backQty temp3 ON temp1.Kanban = temp3.Code \n" + +" AND temp1.SapMaterialCode = temp3.MaterialCode\n" + " LEFT JOIN ( SELECT Price, --定价\n" + " MaterialCode --厂内物料号\n" + " FROM Set_PriceList WHERE VERSION = ( SELECT MAX ( VERSION ) FROM Set_PriceList ) ) TEMP2 ON TEMP1.SapMaterialCode = TEMP2.MaterialCode \n" + "WHERE\n" + -" 1 = 1;"; +" 1 = 1 \n"; + + + + + + + +// string sqlString = "SELECT\n" + +//" * ,\n" + +//" ISNULL ( temp1.InvoicePrice * Qty, 0 ) AS InvoiceMoney,--开票金额\n" + +//" ISNULL ( Price * WMSDeliveryQty, 0 ) AS Amount,--金额\n" + +//" ISNULL ( Price * Qty, 0 ) AS SettlePrice,--结算金额\n" + +//" ( Price - InvoicePrice ) AS InvoiceDiffPrice,--单价差异\n" + +//" ISNULL ( Price * Qty - InvoicePrice * Qty, 0 ) AS SumDiffMoney,--总金额差异\n" + +//" '' DeliveryOrderNo --出库单号\n" + +//" \n" + +//"FROM\n" + +//" (\n" + +//" SELECT ROW_NUMBER\n" + +//" ( ) OVER ( ORDER BY b.EstimateTypeDesc ) AS RowId,\n" + +//"--c.WMSDeliveryNote,--交货单号\n" + +//"--CONVERT ( VARCHAR ( 100 ), c.WMSActualGoodsDate, 23 ) AS WMSActualGoodsDate,--实际发货日期年-月-日\n" + +//" A.Kanban,--条码号\n" + +//" b.MaterialCode SapMaterialCode,--厂内物料号\n" + +//" b.MaterialDesc,--物料描述\n" + +//" b.CustomerPartCode,--客户物料\n" + +//" b.EstimateTypeDesc,--物料组(车型)\n" + +//" C.WMSDeliveryQty,--交货数量\n" + +//" ISNULL ( A.Qty, 0 ) AS SettleNumber,--结算数量\n" + +//" CONVERT ( VARCHAR ( 100 ), A.SettleDate, 23 ) SettleDate,--结算日期\n" + +//" ISNULL ( A.Qty, 0 ) AS Qty,--用于计算\n" + +//" ( ISNULL ( A.Qty, 0 ) - ISNULL ( C.WMSDeliveryQty, 0 ) ) AS SettleWMSDiffQty,--结算与发货差异\n" + +//" 0 AS SettleInvoiceDiffQty,--结算与开票差异\n" + +//" ISNULL ( A.Qty, 0 ) AS InvoiceDiffQty,--开票数量,默认0,后续拿算法动态算\n" + +//" ISNULL ( d.InvoicePrice, 0 ) InvoicePrice --开票单价\n" + +//" \n" + +//" FROM\n" + +//" Set_KanBanSettle\n" + +//" AS A LEFT JOIN Set_material AS b ON A.MaterialCode = b.CustomerPartCode\n" + +//" LEFT JOIN (\n" + +//"   SELECT\n" + +//" ( temp1.Qty - ISNULL ( temp2.Qty, 0 ) ) WMSDeliveryQty,\n" + +//" temp1.MaterialCode,\n" + +//" temp1.Kanban \n" + +//" FROM\n" + +//" ( SELECT SUM ( Qty ) Qty, Kanban, MaterialCode FROM Set_KanBanSettle WHERE VERSION < '{0}' GROUP BY kanban, MaterialCode ) temp1\n" + +//" INNER JOIN ( SELECT SUM ( WMSDeliveryQty ) Qty, KanBan, MaterialCode FROM Set_WMSKanBanSettle WHERE WMSActualGoodsDate < '{2}' GROUP BY KanBan, MaterialCode ) temp2 ON temp1.Kanban = temp2.KanBan \n" + +//" AND temp1.MaterialCode = temp2.KanBan \n" + +//" ) C ON A.Kanban = C.Kanban \n" + +//" AND A.MaterialCode = C.MaterialCode\n" + +//" LEFT JOIN ( SELECT SUM ( amt ) / SUM ( Qty ) InvoicePrice, MaterialCode FROM set_invoice WHERE VERSION = '{0}' GROUP BY materialcode ) d ON A.MaterialCode = d.MaterialCode \n" + +//" WHERE\n" + +//" A.VERSION = '{0}' {1}\n" + +//" ) TEMP1\n" + +//" LEFT JOIN ( SELECT Price, --定价\n" + +//" MaterialCode --厂内物料号\n" + +//" FROM Set_PriceList WHERE VERSION = ( SELECT MAX ( VERSION ) FROM Set_PriceList ) ) TEMP2 ON TEMP1.SapMaterialCode = TEMP2.MaterialCode \n" + +//"WHERE\n" + +//" 1 = 1;"; string addwhere = string.Empty; string addSqlStr = string.Format(sqlString, version, condition,datetime); @@ -392,7 +458,11 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report [ExporterHeader(DisplayName = "出库单号")] public string DeliveryOrderNo { set; get; } - + [ExporterHeader(DisplayName = "退货数量")] + public string ReturnQty { set; get; } + [ExporterHeader(DisplayName = "实际交货数量")] + public string RealQty { set; get; } + }