From a3014f9d30664e964975ec9e03574d27097051b0 Mon Sep 17 00:00:00 2001 From: 44673626 <44673626@qq.com> Date: Thu, 27 Jan 2022 11:18:55 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E4=B8=80=E6=B1=BD=E8=BD=BF=E8=BD=A6?= =?UTF-8?q?=E5=AD=97=E6=AE=B5=E6=96=B0=E5=8A=A0=20=E6=98=AF=E5=90=A6?= =?UTF-8?q?=E5=A4=87=E4=BB=B6=20=E5=AD=97=E6=AE=B5=EF=BC=8C=E8=B4=A2?= =?UTF-8?q?=E5=8A=A1=E8=A6=81=E9=80=9A=E8=BF=87=E6=89=8B=E5=8A=A8=E5=AF=BC?= =?UTF-8?q?=E5=85=A5=E7=BB=93=E7=AE=97=E5=8D=95=E8=BF=9B=E8=A1=8C=E6=89=A3?= =?UTF-8?q?=E5=87=8F=E5=BA=93=E5=AD=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../SettleAccount.HttpApi.Host.csproj | 1 - .../Entities/WMS/WmsHQCarAppService.cs | 5 ++++- .../src/SettleAccount.Domain/Entities/WMS/TaskList.cs | 8 +++++++- .../Report/HQCarSettledDetailDapperRepository.cs | 3 +++ 4 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/SettleAccount.HttpApi.Host.csproj b/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/SettleAccount.HttpApi.Host.csproj index 47366b8f..c09813b6 100644 --- a/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/SettleAccount.HttpApi.Host.csproj +++ b/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/SettleAccount.HttpApi.Host.csproj @@ -54,7 +54,6 @@ - diff --git a/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/WMS/WmsHQCarAppService.cs b/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/WMS/WmsHQCarAppService.cs index 823cb6d8..82305adc 100644 --- a/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/WMS/WmsHQCarAppService.cs +++ b/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/WMS/WmsHQCarAppService.cs @@ -150,7 +150,8 @@ namespace Win.Sfs.SettleAccount.Entities.WMS itm.TaskId, itm.Remark, itm.Qty, - tm1 == null ? 0 : tm1.Qty + tm1 == null ? 0 : tm1.Qty, + itm.IsSparePart ); @@ -221,6 +222,7 @@ namespace Win.Sfs.SettleAccount.Entities.WMS string.Empty, p.Qty, p.StockQty + ,p.IsSparePart )); _lst.AddRange(_lsAry.ToArray()); } @@ -403,6 +405,7 @@ namespace Win.Sfs.SettleAccount.Entities.WMS , string.Empty , itm.Qty , 0 + ,itm.IsSparePart ); _lsCopy.Add(_detail); } diff --git a/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/WMS/TaskList.cs b/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/WMS/TaskList.cs index 7b4fb824..b32b5d09 100644 --- a/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/WMS/TaskList.cs +++ b/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/WMS/TaskList.cs @@ -711,7 +711,9 @@ namespace Win.Sfs.SettleAccount.Entities.WMS public WmsHQCarOutPutDetial() { } - public WmsHQCarOutPutDetial(Guid id, string wmsBillNum, string orderBillNum, string materialCode, string materialDesc, string materialGroup, string outPut, string inPut, int state, string extend1, string extend2, string extend3, string parentMaterialCode, string billNum, Guid taskId, string remark, decimal qty, decimal stockQty) + public WmsHQCarOutPutDetial(Guid id, string wmsBillNum, string orderBillNum, string materialCode, + string materialDesc, string materialGroup, string outPut, string inPut, int state, string extend1, string extend2, + string extend3, string parentMaterialCode, string billNum, Guid taskId, string remark, decimal qty, decimal stockQty,string issparepart) { Id = id; WmsBillNum = wmsBillNum; @@ -731,11 +733,15 @@ namespace Win.Sfs.SettleAccount.Entities.WMS Remark = remark; Qty = qty; StockQty = stockQty; + IsSparePart = issparepart; } public void SetId(Guid id) { Id = id; } + + [ImporterHeader(Name = "是否备件")] + public string IsSparePart { set; get; } //交货单号 [ImporterHeader(Name = "寄销库数量", IsIgnore = true)] diff --git a/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/Report/HQCarSettledDetailDapperRepository.cs b/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/Report/HQCarSettledDetailDapperRepository.cs index c9256a02..d0a9653d 100644 --- a/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/Report/HQCarSettledDetailDapperRepository.cs +++ b/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/Report/HQCarSettledDetailDapperRepository.cs @@ -142,6 +142,9 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report [ExporterHeader(DisplayName = "寄销库数量")] public decimal 寄销库数量 { set; get; } + [ExporterHeader(DisplayName = "是否备件")] + public string 是否备件 { set; get; } + } public class HQCarSettleQtyDiff From 2c16192aabd09b9df850d043ea24c71e0714081a Mon Sep 17 00:00:00 2001 From: 44673626 <44673626@qq.com> Date: Thu, 27 Jan 2022 18:56:59 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E5=A4=A7=E4=BC=97=E5=A4=87=E4=BB=B6?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E8=B0=83=E6=95=B4=E5=8F=8A=E6=AD=A3=E5=B8=B8?= =?UTF-8?q?=E8=BE=93=E5=87=BA=E7=9A=84=E6=9B=B4=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ReportServices/ReportMakeService.cs | 4 +- ...SettleSparePart90DapperReportRepository.cs | 322 ++++++------------ .../SettleSparePartDapperReportRepository.cs | 142 ++++++-- .../Report/SettleSparePart90ExportService.cs | 26 +- .../Report/SettleSparePartExportService.cs | 29 +- 5 files changed, 253 insertions(+), 270 deletions(-) diff --git a/src/Modules/SettleAccount/src/SettleAccount.Application/Reports/ReportServices/ReportMakeService.cs b/src/Modules/SettleAccount/src/SettleAccount.Application/Reports/ReportServices/ReportMakeService.cs index 10a39ca3..a9f7692e 100644 --- a/src/Modules/SettleAccount/src/SettleAccount.Application/Reports/ReportServices/ReportMakeService.cs +++ b/src/Modules/SettleAccount/src/SettleAccount.Application/Reports/ReportServices/ReportMakeService.cs @@ -208,7 +208,7 @@ namespace Win.Sfs.SettleAccount.Reports.ReportServices customConditionList.Add(new CustomCondition() { Name = "BegingTime", Value = begin.ToString() }); customConditionList.Add(new CustomCondition() { Name = "EndTime", Value = end.ToString() }); - var _taskid = await _service.ExportEnqueueAsync("(0-90天)大众备件结算输出", ExportExtentsion.Excel, version, string.Empty, CurrentUser, typeof(SettleSparePart90ExportService), customConditionList, (rs) => + var _taskid = await _service.ExportEnqueueAsync("大众备件数据调整结算输出", ExportExtentsion.Excel, version, string.Empty, CurrentUser, typeof(SettleSparePart90ExportService), customConditionList, (rs) => { }); @@ -247,7 +247,7 @@ namespace Win.Sfs.SettleAccount.Reports.ReportServices customConditionList.Add(new CustomCondition() { Name = "BegingTime", Value = begin.ToString() }); customConditionList.Add(new CustomCondition() { Name = "EndTime", Value = end.ToString() }); - var _taskid = await _service.ExportEnqueueAsync("备件结算输出", ExportExtentsion.Excel, version, string.Empty, CurrentUser, typeof(SettleSparePartExportService), customConditionList, (rs) => + var _taskid = await _service.ExportEnqueueAsync("大众备件正常结算输出", ExportExtentsion.Excel, version, string.Empty, CurrentUser, typeof(SettleSparePartExportService), customConditionList, (rs) => { }); diff --git a/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/Report/SettleSparePart90DapperReportRepository.cs b/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/Report/SettleSparePart90DapperReportRepository.cs index aeef360d..e00c9580 100644 --- a/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/Report/SettleSparePart90DapperReportRepository.cs +++ b/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/Report/SettleSparePart90DapperReportRepository.cs @@ -23,181 +23,41 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report public virtual List GetSettleSparePart90ReportList(string purchaseOrderNo, string version, string sapCode, string matialCode, string begintime, string endtime) - { - string sqlString = - "SELECT\n" + - " temp1.期间,\n" + - " temp1.交货单号,\n" + - " temp1.发货日期,\n" + - " temp1.采购订单号,\n" + - " temp1.SAP编码,\n" + - " temp1.物料代码,\n" + - " temp1.物料描述,\n" + - " temp1.物料组,\n" + - " temp1.开票单价,\n" + - " temp1.数量差异,\n" + - " temp1.发货数量,\n" + - " temp1.开票数量,\n" + - " ISNULL( TEMP2.Price, 0 ) AS 定价,\n" + - " temp1.开票单价 - ISNULL( TEMP2.Price, 0 ) AS 单价差异 \n" + - "FROM\n" + - " (\n" + - " SELECT\n" + - " a.Version AS 期间,\n" + - " b.WMSDeliveryNote AS 交货单号,\n" + - " b.SpareDate AS 发货日期,\n" + - " b.PurchaseOrderNo AS 采购订单号,\n" + - " b.SapCode AS SAP编码,\n" + - " b.MaterialCode AS 物料代码,\n" + - " c.MaterialDesc AS 物料描述,\n" + - " c.EstimateTypeDesc AS 物料组,\n" + - " a.PurchasePriceNoTax AS 开票单价,\n" + - " 0 AS 数量差异,\n" + - " ISNULL( b.ReceiptQty, 0 ) AS 发货数量,\n" + - " ISNULL( b.ReceiptQty, 0 ) AS 开票数量 \n" + - " FROM\n" + - " (\n" + - " SELECT\n" + - " t.ReceiptQty,\n" + - " t.PurchaseOrderNo,\n" + - " t.Version,\n" + - " t.PurchasePriceNoTax,\n" + - " ( SELECT MaterialCode FROM Set_material WHERE CustomerPartCode = t.MaterialCode ) AS SapCode \n" + - " FROM\n" + - " (\n" + - " SELECT SUM\n" + - " ( ReceiptQty ) AS ReceiptQty,\n" + - " PurchaseOrderNo,\n" + - " MaterialCode,\n" + - " Version,\n" + - " PurchasePriceNoTax \n" + - " FROM\n" + - " Set_SparePart \n" + - " WHERE\n" + - " Extend = 'is90' \n" + - " GROUP BY\n" + - " PurchaseOrderNo,\n" + - " MaterialCode,\n" + - " Version,\n" + - " PurchasePriceNoTax \n" + - " ) t \n" + - " ) AS a\n" + - " INNER JOIN (\n" + - " SELECT\n" + - " WMSDeliveryNote,\n" + - " SpareDate,\n" + - " MaterialCode,\n" + - " ReceiptQty,\n" + - " PurchaseOrderNo,\n" + - " SapCode \n" + - " FROM\n" + - " Set_WMSSparePart \n" + - " WHERE\n" + - " PurchaseOrderNo != 'BM' \n" + - " AND PurchaseOrderNo LIKE '%D30%' \n" + - " OR PurchaseOrderNo LIKE '%D60%' \n" + - " OR PurchaseOrderNo LIKE '%D90%' \n" + - " ) AS b ON a.SapCode = b.SapCode\n" + - " LEFT OUTER JOIN ( SELECT MAX ( Id ) Id, MaterialCode, MaterialDesc, EstimateTypeDesc FROM Set_material GROUP BY MaterialCode, MaterialDesc, EstimateTypeDesc ) AS c ON b.SapCode = c.MaterialCode \n" + - " WHERE\n" + - " ( a.Version = '202112' ) \n" + - " ) AS temp1\n" + - " LEFT OUTER JOIN ( SELECT Price, MaterialCode FROM Set_PriceList WHERE ( Version = ( SELECT MAX ( Version ) AS Expr1 FROM Set_PriceList ) ) ) AS TEMP2 ON temp1.SAP编码 = TEMP2.MaterialCode \n" + - "ORDER BY\n" + - " temp1.采购订单号"; - //"SELECT\n" + - //" temp1.期间,\n" + - //" temp1.交货单号,\n" + - //" temp1.发货日期,\n" + - //" temp1.采购订单号,\n" + - //" temp1.SAP编码,\n" + - //" temp1.物料代码,\n" + - //" temp1.物料描述,\n" + - //" temp1.物料组,\n" + - //" temp1.开票单价,\n" + - //" temp1.数量差异,\n" + - //" temp1.发货数量,\n" + - //" temp1.开票数量,\n" + - //" ISNULL( TEMP2.Price, 0 ) AS 定价,\n" + - //" temp1.开票单价 - ISNULL( TEMP2.Price, 0 ) AS 单价差异 \n" + - //"FROM\n" + - //" (\n" + - //" SELECT\n" + - //" a.Version AS 期间,\n" + - //" b.WMSDeliveryNote AS 交货单号,\n" + - //" b.SpareDate AS 发货日期,\n" + - //" b.PurchaseOrderNo AS 采购订单号,\n" + - //" c.MaterialCode AS SAP编码,\n" + - //" b.MaterialCode AS 物料代码,\n" + - //" c.MaterialDesc AS 物料描述,\n" + - //" c.EstimateTypeDesc AS 物料组,\n" + - //" a.PurchasePriceNoTax AS 开票单价,\n" + - //" 0 AS 数量差异,\n" + - //" ISNULL( b.ReceiptQty, 0 ) AS 发货数量,\n" + - //" ISNULL( b.ReceiptQty, 0 ) AS 开票数量 \n" + - //" FROM\n" + - //" (\n" + - //" SELECT SUM\n" + - //" ( ReceiptQty ) AS ReceiptQty,\n" + - //" PurchaseOrderNo,\n" + - //" MaterialCode,\n" + - //" Version,\n" + - //" PurchasePriceNoTax \n" + - //" FROM\n" + - //" Set_SparePart \n" + - //" WHERE\n" + - //" Extend = 'is90' \n" + - //" GROUP BY\n" + - //" PurchaseOrderNo,\n" + - //" MaterialCode,\n" + - //" Version,\n" + - //" PurchasePriceNoTax \n" + - //" ) AS a\n" + - //" LEFT OUTER JOIN (\n" + - //" SELECT\n" + - //" WMSDeliveryNote,\n" + - //" SpareDate,\n" + - //" MaterialCode,\n" + - //" ReceiptQty,\n" + - //" PurchaseOrderNo \n" + - //" FROM\n" + - //" Set_WMSSparePart \n" + - //" WHERE\n" + - //" PurchaseOrderNo != 'BM' \n" + - //" AND PurchaseOrderNo LIKE '%D30%' \n" + - //" OR PurchaseOrderNo LIKE '%D60%' \n" + - //" OR PurchaseOrderNo LIKE '%D90%' \n" + - //" ) AS b ON a.MaterialCode = b.MaterialCode\n" + - //" LEFT OUTER JOIN Set_material AS c ON a.MaterialCode = c.CustomerPartCode \n" + - //" WHERE\n" + - //" ( a.Version = '{0}' ) \n" + - //" ) AS temp1\n" + - //" LEFT OUTER JOIN ( SELECT Price, MaterialCode FROM Set_PriceList WHERE ( Version = ( SELECT MAX ( Version ) AS Expr1 FROM Set_PriceList ) ) ) AS TEMP2 ON temp1.SAP编码 = TEMP2.MaterialCode ORDER BY temp1.采购订单号"; - string addwhere = string.Empty; - string addSqlStr = string.Format(sqlString, version); - - string _sql = string.Format(addSqlStr, addwhere); - //string _sql = string.Format(sqlString, version); - var _query = DbConnection.Query(_sql, null, null, true, 1200, null); - return _query.ToList(); - - } - - - public virtual List GetSettleSparePart90SumQtyDiff(string version) { string sqlString = "SELECT\n" + - " ISNULL( A.ReceiptQty - ISNULL( B.ReceiptQty, 0 ), 0 ) 数量差异,\n" + - " a.PurchaseOrderNo 订单号,\n" + - " a.SapCode 厂内物料号 \n" + + " temp1.交货日期,\n" + + " temp1.交货单号,\n" + + " '' 订单日期,\n" + + " temp1.采购订单号,\n" + + " temp1.SAP编码,\n" + + " temp1.物料代码,\n" + + " temp1.物料描述,\n" + + " temp1.采购订单文本,\n" + + " temp1.发货数量,\n" + + " temp1.开票数量,\n" + + " ISNULL( temp1.发货数量, 0 ) - ISNULL( temp1.开票数量, 0 ) AS 发货与开票差异,\n" + + " temp1.开票单价,\n" + + " ISNULL( temp1.开票金额, 0 ) AS 开票金额,\n" + + " ISNULL( TEMP2.Price, 0 ) AS 定价,\n" + + " temp1.开票单价 - ISNULL( TEMP2.Price, 0 ) AS 单价差异 ,\n" + + " ( temp1.开票单价 - ISNULL( TEMP2.Price, 0 ) ) * temp1.开票数量 AS 差异总金额 \n" + "FROM\n" + " (\n" + " SELECT\n" + - " t.ReceiptQty,\n" + - " t.PurchaseOrderNo,\n" + - " t.Version,\n" + - " t.PurchasePriceNoTax,\n" + - " ( SELECT MaterialCode FROM Set_material WHERE CustomerPartCode = t.MaterialCode ) AS SapCode \n" + + " a.Version AS 期间,\n" + + " a.PurchaseOrderNoText AS 采购订单文本,\n" + + " b.WMSDeliveryNote AS 交货单号,\n" + + " b.SpareDate AS 交货日期,\n" + + " a.PurchaseOrderNo AS 采购订单号,\n" + + " c.MaterialCode AS SAP编码,\n" + + " b.MaterialCode AS 物料代码,\n" + + " c.MaterialDesc AS 物料描述,\n" + + " c.EstimateTypeDesc AS 物料组,\n" + + " a.PurchasePriceNoTax AS 开票单价,\n" + + " 0 AS 数量差异,\n" + + " ISNULL( b.ReceiptQty, 0 ) AS 发货数量,\n" + + " ISNULL( a.InvoicedQty, 0 ) AS 开票数量 ,\n" + + " ISNULL( a.AmountNoTax, 0 ) AS 开票金额 \n" + " FROM\n" + " (\n" + " SELECT SUM\n" + @@ -205,56 +65,84 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report " PurchaseOrderNo,\n" + " MaterialCode,\n" + " Version,\n" + - " PurchasePriceNoTax \n" + + " PurchasePriceNoTax,\n" + + " InvoicedQty,\n" + + " PurchaseOrderNoText,\n" + + " AmountNoTax \n" + " FROM\n" + " Set_SparePart \n" + - " WHERE\n" + - " Extend = 'is90' \n" + " GROUP BY\n" + " PurchaseOrderNo,\n" + " MaterialCode,\n" + " Version,\n" + - " PurchasePriceNoTax \n" + - " ) t \n" + - " ) A\n" + - " LEFT JOIN (\n" + - " SELECT\n" + - " WMSDeliveryNote,\n" + - " SpareDate,\n" + - " MaterialCode,\n" + - " ReceiptQty,\n" + - " PurchaseOrderNo,\n" + - " SapCode \n" + - " FROM\n" + - " Set_WMSSparePart \n" + + " PurchasePriceNoTax,\n" + + " InvoicedQty,\n" + + " PurchaseOrderNoText,\n" + + " AmountNoTax \n" + + " ) AS a\n" + + " INNER JOIN (\n" + + " SELECT SUM\n" + + " ( ReceiptQty ) AS ReceiptQty,\n" + + " PurchaseOrderNo,\n" + + " SapCode,\n" + + " MaterialCode,\n" + + " WMSDeliveryNote,\n" + + " SpareDate \n" + + " FROM\n" + + " Set_WMSSparePart \n" + + " GROUP BY\n" + + " PurchaseOrderNo,\n" + + " SapCode,\n" + + " MaterialCode,\n" + + " WMSDeliveryNote,\n" + + " SpareDate \n" + + " ) AS b ON a.PurchaseOrderNo = b.PurchaseOrderNo \n" + + " AND a.MaterialCode = b.MaterialCode\n" + + " LEFT OUTER JOIN Set_material AS c ON a.MaterialCode = c.CustomerPartCode \n" + " WHERE\n" + - " PurchaseOrderNo != 'BM' \n" + - " AND PurchaseOrderNo LIKE '%D30%' \n" + - " OR PurchaseOrderNo LIKE '%D60%' \n" + - " OR PurchaseOrderNo LIKE '%D90%' \n" + - " ) B ON A.SapCode = B.SapCode WHERE (A.ReceiptQty - ISNULL( B.ReceiptQty, 0 )) <> 0"; + " ( a.Version = '{0}' ) \n" + + " ) AS temp1\n" + + " LEFT OUTER JOIN ( SELECT Price, MaterialCode FROM Set_PriceList WHERE ( Version = ( SELECT MAX ( Version ) AS Expr1 FROM Set_PriceList ) ) ) AS TEMP2 ON temp1.SAP编码 = TEMP2.MaterialCode \n" + + "ORDER BY\n" + + " temp1.采购订单号"; + ; + string addwhere = string.Empty; string addSqlStr = string.Format(sqlString, version); - string _sql = string.Format(addSqlStr, addwhere); - - var _query = DbConnection.Query(_sql, null, null, true, 1200, null); + //string _sql = string.Format(sqlString, version); + var _query = DbConnection.Query(_sql, null, null, true, 1200, null); return _query.ToList(); } + //public virtual List GetSettleSparePart90SumQtyDiff(string version) + //{ + // string sqlString = "SELECT\n" + + // " ISNULL( A.ReceiptQty - ISNULL( B.ReceiptQty, 0 ), 0 ) 数量差异,\n" + + // " a.PurchaseOrderNo 订单号,\n" + + // " a.MaterialCode 物料号 \n" + + // "FROM\n" + + // " ( SELECT SUM ( ReceiptQty ) ReceiptQty, PurchaseOrderNo, MaterialCode FROM Set_SparePart WHERE Version = '{0}' GROUP BY PurchaseOrderNo, MaterialCode ) A\n" + + // " LEFT JOIN ( SELECT SUM ( ReceiptQty ) ReceiptQty, PurchaseOrderNo, MaterialCode FROM Set_WMSSparePart GROUP BY PurchaseOrderNo, MaterialCode ) B ON A.MaterialCode = B.MaterialCode \n" + + // " AND A.PurchaseOrderNo = B.PurchaseOrderNo \n" + + // "WHERE\n" + + // " A.ReceiptQty - ISNULL( B.ReceiptQty, 0 ) <> 0"; + // string addwhere = string.Empty; + // string addSqlStr = string.Format(sqlString, version); - } - - - + // string _sql = string.Format(addSqlStr, addwhere); + // var _query = DbConnection.Query(_sql, null, null, true, 1200, null); + // return _query.ToList(); + //} + } @@ -279,12 +167,14 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report public class SettleSparePart90Export { - [ExporterHeader(DisplayName = "期间 ")] - public string 期间 { set; get; } + [ExporterHeader(DisplayName = "交货日期 ")] + public string 交货日期 { set; get; } [ExporterHeader(DisplayName = "交货单号")] public string 交货单号 { set; get; } - [ExporterHeader(DisplayName = "发货日期")] - public string 发货日期 { set; get; } + + [ExporterHeader(DisplayName = "订单日期")] + public string 订单日期 { set; get; } + [ExporterHeader(DisplayName = "采购订单号")] public string 采购订单号 { set; get; } [ExporterHeader(DisplayName = "SAP编码")] @@ -293,26 +183,34 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report public string 物料代码 { set; get; } [ExporterHeader(DisplayName = "物料描述")] public string 物料描述 { set; get; } - [ExporterHeader(DisplayName = "物料组")] - public string 物料组 { set; get; } - [ExporterHeader(DisplayName = "开票单价")] - public decimal 开票单价 { set; get; } - [ExporterHeader(DisplayName = "数量差异")] - public decimal 数量差异 { set; get; } + + [ExporterHeader(DisplayName = "采购订单文本")] + public string 采购订单文本 { set; get; } + [ExporterHeader(DisplayName = "发货数量")] public decimal 发货数量 { set; get; } [ExporterHeader(DisplayName = "开票数量")] public decimal 开票数量 { set; get; } + [ExporterHeader(DisplayName = "发货与开票差异")] + public decimal 发货与开票差异 { set; get; } + [ExporterHeader(DisplayName = "开票单价")] + public decimal 开票单价 { set; get; } + + [ExporterHeader(DisplayName = "开票金额")] + public decimal 开票金额 { set; get; } [ExporterHeader(DisplayName = "定价")] public decimal 定价 { set; get; } [ExporterHeader(DisplayName = "单价差异")] public decimal 单价差异 { set; get; } - [ExporterHeader(DisplayName = "寄售库数量")] - public decimal 寄售库数量 { set; get; } + [ExporterHeader(DisplayName = "差异总金额")] + public decimal 差异总金额 { set; get; } + + //[ExporterHeader(DisplayName = "寄售库数量")] + //public decimal 寄售库数量 { set; get; } - [ExporterHeader(DisplayName = "出库数量")] - public decimal 出库数量 { set; get; } + //[ExporterHeader(DisplayName = "出库数量")] + //public decimal 出库数量 { set; get; } } } diff --git a/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/Report/SettleSparePartDapperReportRepository.cs b/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/Report/SettleSparePartDapperReportRepository.cs index 22506b69..df4abb47 100644 --- a/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/Report/SettleSparePartDapperReportRepository.cs +++ b/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/Report/SettleSparePartDapperReportRepository.cs @@ -25,64 +25,103 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report public virtual List GetSettleSparePartReportList(string purchaseOrderNo, string version, string sapCode, string matialCode, string begintime, string endtime) { - string sqlString = - "SELECT\n" + - " temp1.期间,\n" + + string sqlString = "SELECT\n" + + " temp1.交货日期,\n" + " temp1.交货单号,\n" + - " temp1.发货日期,\n" + + " '' 订单日期,\n" + " temp1.采购订单号,\n" + " temp1.SAP编码,\n" + " temp1.物料代码,\n" + " temp1.物料描述,\n" + - " temp1.物料组,\n" + - " temp1.开票单价,\n" + - " temp1.数量差异,\n" + + " temp1.采购订单文本,\n" + " temp1.发货数量,\n" + " temp1.开票数量,\n" + + " ISNULL( temp1.发货数量, 0 ) - ISNULL( temp1.开票数量, 0 ) AS 发货与开票差异,\n" + + " temp1.开票单价,\n" + + " ISNULL( temp1.开票金额, 0 ) AS 开票金额,\n" + " ISNULL( TEMP2.Price, 0 ) AS 定价,\n" + - " temp1.开票单价 - ISNULL( TEMP2.Price, 0 ) AS 单价差异 \n" + + " temp1.开票单价 - ISNULL( TEMP2.Price, 0 ) AS 单价差异 ,\n" + + " ( temp1.开票单价 - ISNULL( TEMP2.Price, 0 ) ) * temp1.开票数量 AS 差异总金额 \n" + "FROM\n" + " (\n" + " SELECT\n" + " a.Version AS 期间,\n" + + " a.PurchaseOrderNoText AS 采购订单文本,\n" + " b.WMSDeliveryNote AS 交货单号,\n" + - " b.SpareDate AS 发货日期,\n" + + " b.SpareDate AS 交货日期,\n" + " a.PurchaseOrderNo AS 采购订单号,\n" + - " c.MaterialCode AS SAP编码,\n" + + " b.SapCode AS SAP编码,\n" + " b.MaterialCode AS 物料代码,\n" + " c.MaterialDesc AS 物料描述,\n" + " c.EstimateTypeDesc AS 物料组,\n" + " a.PurchasePriceNoTax AS 开票单价,\n" + " 0 AS 数量差异,\n" + " ISNULL( b.ReceiptQty, 0 ) AS 发货数量,\n" + - " ISNULL( b.ReceiptQty, 0 ) AS 开票数量 \n" + + " ISNULL( a.InvoicedQty, 0 ) AS 开票数量 ,\n" + + " ISNULL( a.AmountNoTax, 0 ) AS 开票金额 \n" + " FROM\n" + " (\n" + + " SELECT\n" + + " t.ReceiptQty,\n" + + " t.PurchaseOrderNo,\n" + + " t.Version,\n" + + " t.PurchasePriceNoTax,\n" + + " t.InvoicedQty,\n" + + " t.AmountNoTax,\n" + + " t.PurchaseOrderNoText,\n" + + " ( SELECT MaterialCode FROM Set_material WHERE CustomerPartCode = t.MaterialCode ) AS SapCode \n" + + " FROM\n" + + " (\n" + + " SELECT SUM\n" + + " ( ReceiptQty ) AS ReceiptQty,\n" + + " PurchaseOrderNo,\n" + + " MaterialCode,\n" + + " Version,\n" + + " PurchasePriceNoTax,\n" + + " InvoicedQty,\n" + + " PurchaseOrderNoText,\n" + + " AmountNoTax \n" + + " FROM\n" + + " Set_SparePart \n" + + " WHERE\n" + + " Extend != 'is90' \n" + + " GROUP BY\n" + + " PurchaseOrderNo,\n" + + " MaterialCode,\n" + + " Version,\n" + + " PurchasePriceNoTax,\n" + + " InvoicedQty,\n" + + " PurchaseOrderNoText,\n" + + " AmountNoTax \n" + + " ) t \n" + + " ) AS a\n" + + " LEFT OUTER JOIN (\n" + " SELECT SUM\n" + " ( ReceiptQty ) AS ReceiptQty,\n" + " PurchaseOrderNo,\n" + + " SapCode,\n" + " MaterialCode,\n" + - " Version,\n" + - " PurchasePriceNoTax \n" + + " WMSDeliveryNote,\n" + + " SpareDate \n" + " FROM\n" + - " Set_SparePart \n" + - " WHERE\n" + - " Extend = 'not90' \n" + + " Set_WMSSparePart \n" + " GROUP BY\n" + " PurchaseOrderNo,\n" + + " SapCode,\n" + " MaterialCode,\n" + - " Version,\n" + - " PurchasePriceNoTax \n" + - " ) AS a\n" + - " LEFT OUTER JOIN Set_WMSSparePart AS b ON a.PurchaseOrderNo = b.PurchaseOrderNo \n" + - " AND a.MaterialCode = b.MaterialCode\n" + - " LEFT OUTER JOIN Set_material AS c ON a.MaterialCode = c.CustomerPartCode \n" + + " WMSDeliveryNote,\n" + + " SpareDate \n" + + " ) AS b ON a.SapCode = b.SapCode\n" + + " LEFT OUTER JOIN ( SELECT MAX ( Id ) Id, MaterialCode, MaterialDesc, EstimateTypeDesc FROM Set_material GROUP BY MaterialCode, MaterialDesc, EstimateTypeDesc ) AS c ON b.SapCode = c.MaterialCode \n" + " WHERE\n" + " ( a.Version = '{0}' ) \n" + " ) AS temp1\n" + - " LEFT OUTER JOIN ( SELECT Price, MaterialCode FROM Set_PriceList WHERE ( Version = ( SELECT MAX ( Version ) AS Expr1 FROM Set_PriceList ) ) ) AS TEMP2 ON temp1.SAP编码 = TEMP2.MaterialCode ORDER BY temp1.采购订单号"; + " LEFT OUTER JOIN ( SELECT Price, MaterialCode FROM Set_PriceList WHERE ( Version = ( SELECT MAX ( Version ) AS Expr1 FROM Set_PriceList ) ) ) AS TEMP2 ON temp1.SAP编码 = TEMP2.MaterialCode \n" + + "ORDER BY\n" + + " temp1.采购订单号"; string addwhere = string.Empty; string addSqlStr = string.Format(sqlString, version); + //if (!string.IsNullOrEmpty(purchaseOrderNo)) //{ // addwhere += string.Format(" AND PurchaseOrderNo LIKE '{0}%' ", purchaseOrderNo); @@ -170,13 +209,56 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report public virtual List GetSettleSparePartSumQtyDiff(string version) { string sqlString = "SELECT\n" + - " ISNULL( A.ReceiptQty - ISNULL( B.ReceiptQty, 0 ), 0 ) 数量差异,\n" + - " a.PurchaseOrderNo 订单号,\n" + - " a.MaterialCode 物料号 \n" + - " FROM\n" + - " ( SELECT sum( ReceiptQty ) ReceiptQty, PurchaseOrderNo, MaterialCode FROM Set_SparePart where Version='{0}' GROUP BY PurchaseOrderNo, MaterialCode ) A\n" + - " LEFT JOIN ( SELECT sum( ReceiptQty ) ReceiptQty, PurchaseOrderNo, MaterialCode FROM Set_WMSSparePart GROUP BY PurchaseOrderNo, MaterialCode ) B ON A.MaterialCode = B.MaterialCode \n" + - " AND A.PurchaseOrderNo = B.PurchaseOrderNo"; + " ISNULL( A.ReceiptQty - ISNULL( B.ReceiptQty, 0 ), 0 ) 数量差异,\n" + + " a.PurchaseOrderNo 订单号,\n" + + " a.SapCode 厂内物料号 \n" + + "FROM\n" + + " (\n" + + " SELECT\n" + + " t.ReceiptQty,\n" + + " t.PurchaseOrderNo,\n" + + " t.Version,\n" + + " t.PurchasePriceNoTax,\n" + + " ( SELECT MaterialCode FROM Set_material WHERE CustomerPartCode = t.MaterialCode ) AS SapCode \n" + + " FROM\n" + + " (\n" + + " SELECT SUM\n" + + " ( ReceiptQty ) AS ReceiptQty,\n" + + " PurchaseOrderNo,\n" + + " MaterialCode,\n" + + " Version,\n" + + " PurchasePriceNoTax \n" + + " FROM\n" + + " Set_SparePart \n" + + " WHERE\n" + + " Version = '{0}' \n" + + " AND Extend != 'is90' \n" + + " GROUP BY\n" + + " PurchaseOrderNo,\n" + + " MaterialCode,\n" + + " Version,\n" + + " PurchasePriceNoTax \n" + + " ) t \n" + + " ) A\n" + + " LEFT JOIN (\n" + + " SELECT SUM\n" + + " ( ReceiptQty ) AS ReceiptQty,\n" + + " PurchaseOrderNo,\n" + + " SapCode,\n" + + " MaterialCode,\n" + + " WMSDeliveryNote,\n" + + " SpareDate \n" + + " FROM\n" + + " Set_WMSSparePart \n" + + " GROUP BY\n" + + " PurchaseOrderNo,\n" + + " SapCode,\n" + + " MaterialCode,\n" + + " WMSDeliveryNote,\n" + + " SpareDate \n" + + " ) B ON A.SapCode = B.SapCode \n" + + "WHERE\n" + + " ( A.ReceiptQty - ISNULL( B.ReceiptQty, 0 ) ) <> 0"; string addwhere = string.Empty; string addSqlStr = string.Format(sqlString, version); diff --git a/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/SettleSparePart90ExportService.cs b/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/SettleSparePart90ExportService.cs index b9c9dcee..2e0537bf 100644 --- a/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/SettleSparePart90ExportService.cs +++ b/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/SettleSparePart90ExportService.cs @@ -35,20 +35,20 @@ namespace SettleAccount.Job.Services.Report var endTime = p_list.Where(p => p.Name == "EndTime").FirstOrDefault().Value; var _ls = _dapper.GetSettleSparePart90ReportList(purchaseOrderNo, version, sapCode, matialCode, beginTime, endTime); - var diffList = _dapper.GetSettleSparePart90SumQtyDiff(version); - if (diffList != null) - { - foreach (var itm in diffList) - { - var _first = _ls.FirstOrDefault(p => p.SAP编码 == itm.厂内物料号); - if (_first != null) - { - _first.开票数量 = _first.发货数量 + itm.数量差异;//开票数量(结算数量+差异) - _first.数量差异 = itm.数量差异; + //var diffList = _dapper.GetSettleSparePart90SumQtyDiff(version); + //if (diffList != null) + //{ + // foreach (var itm in diffList) + // { + // var _first = _ls.FirstOrDefault(p => p.SAP编码 == itm.厂内物料号); + // if (_first != null) + // { + // _first.开票数量 = _first.发货数量 + itm.数量差异;//开票数量(结算数量+差异) + // _first.数量差异 = itm.数量差异; - } - } - } + // } + // } + //} //if (!string.IsNullOrEmpty(materialGroup)) //{ diff --git a/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/SettleSparePartExportService.cs b/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/SettleSparePartExportService.cs index 3c5d35ff..40d12e55 100644 --- a/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/SettleSparePartExportService.cs +++ b/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/SettleSparePartExportService.cs @@ -34,20 +34,23 @@ namespace SettleAccount.Job.Services.Report var beginTime = p_list.Where(p => p.Name == "BegingTime").FirstOrDefault().Value; var endTime = p_list.Where(p => p.Name == "EndTime").FirstOrDefault().Value; var _ls = _dapper.GetSettleSparePartReportList(purchaseOrderNo, version, sapCode, matialCode, beginTime, endTime); - var diffList = _dapper.GetSettleSparePartSumQtyDiff(version); - if (diffList != null) - { - foreach (var itm in diffList) - { - var _first = _ls.FirstOrDefault(p => p.采购订单号 == itm.订单号 && p.物料代码==itm.物料号); - if (_first != null) - { - _first.开票数量 = _first.发货数量 + itm.数量差异;//开票数量(结算数量+差异) - _first.数量差异 = itm.数量差异; + + + //var diffList = _dapper.GetSettleSparePartSumQtyDiff(version); + //if (diffList != null) + //{ + // foreach (var itm in diffList) + // { + // var _first = _ls.FirstOrDefault(p => p.采购订单号 == itm.订单号 && p.物料代码==itm.物料号); + // if (_first != null) + // { + // _first.开票数量 = _first.发货数量 + itm.数量差异;//开票数量(结算数量+差异) + // _first.数量差异 = itm.数量差异; - } - } - } + // } + // } + //} + //if (!string.IsNullOrEmpty(materialGroup)) //{