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)) //{