Browse Source

备件报表生成

branch_ccpg_220107
44673626 3 years ago
parent
commit
2c1cbc8f09
  1. 83
      src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/Report/SettleSparePartDapperReportRepository.cs

83
src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/Report/SettleSparePartDapperReportRepository.cs

@ -23,37 +23,58 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report
public virtual List<SettleSparePartExport> GetSettleSparePartReportList(string purchaseOrderNo, string version, string sapCode, string matialCode,
string begintime, string endtime)
{
string sqlString = " SELECT \n" +
" * , \n" +
" (Price-InvoicePrice) as InvoiceDiffPrice, --单价差异 \n" +
" ISNULL( Price * ReceiptQty-InvoiceMoney, 0 ) AS SumDiffMoney --总金额差异 \n" +
" FROM \n" +
" ( \n" +
" SELECT \n" +
" c.Period as WMSDeliveryDate,--交货日期 \n" +
" c.WMSDeliveryNote,--交货单号 \n" +
" c.SpareDate as OrderDate,--订单日期 \n" +
" a.PurchaseOrderNo,--采购订单号 \n" +
" b.MaterialCode as SAPCode,--SAP编码,即厂内物料号 \n" +
" a.MaterialCode,--物料代码 \n" +
" b.MaterialDesc,--物料描述 \n" +
" a.PurchaseOrderNoText,--采购订单文本 \n" +
" c.ReceiptQty,-- 发货数量 \n" +
" a.InvoicedQty as InvoicedQty,--开票数量 \n" +
" (c.ReceiptQty-d.Amt) as SettleInvoiceDiffQty,--发货与开票差异 \n" +
" d.InvoicePrice,--开票单价 \n" +
" 0 as InvoiceMoney --开票金额 \n" +
" \n" +
" FROM \n" +
" Set_SparePart AS a \n" +
" LEFT JOIN Set_material AS b ON a.MaterialCode= b.CustomerPartCode \n" +
" LEFT JOIN Set_WMSSparePart c ON a.PurchaseOrderNo= c.WMSDeliveryNote \n" +
" AND a.MaterialCode= c.MaterialCode \n" +
" LEFT JOIN ( SELECT SUM ( amt ) / SUM ( Qty ) InvoicePrice, MaterialCode,Amt FROM set_invoice WHERE version = '{0}' GROUP BY materialcode,Amt ) d ON a.MaterialCode= d.MaterialCode \n" +
" ) TEMP1 \n" +
" LEFT JOIN ( SELECT Price, --定价 \n" +
" MaterialCode --厂内物料号 \n" +
" FROM Set_PriceList WHERE version = ( SELECT MAX ( Version ) FROM Set_PriceList ) ) TEMP2 ON TEMP1.SAPCode= TEMP2.MaterialCode ";
string sqlString = "SELECT\n" +
" * ,\n" +
" ( Price - InvoicePrice ) AS InvoiceDiffPrice,--单价差异\n" +
" ISNULL( Price * ReceiptQty - InvoiceMoney, 0 ) AS SumDiffMoney --总金额差异\n" +
" \n" +
"FROM\n" +
" (\n" +
" SELECT\n" +
" c.Period AS WMSDeliveryDate,--交货日期\n" +
" c.WMSDeliveryNote,--交货单号\n" +
" c.SpareDate AS OrderDate,--订单日期\n" +
" a.PurchaseOrderNo,--采购订单号\n" +
" b.MaterialCode AS SAPCode,--SAP编码,即厂内物料号\n" +
" a.MaterialCode,--物料代码\n" +
" b.MaterialDesc,--物料描述\n" +
" a.PurchaseOrderNoText,--采购订单文本\n" +
" c.ReceiptQty,-- 发货数量\n" +
" a.InvoicedQty AS InvoicedQty,--开票数量\n" +
" ( c.ReceiptQty- d.Amt ) AS SettleInvoiceDiffQty,--发货与开票差异\n" +
" d.InvoicePrice,--开票单价\n" +
" 0 AS InvoiceMoney --开票金额\n" +
" \n" +
" FROM\n" +
" (\n" +
" SELECT\n" +
" t.PurchaseOrderNoText,\n" +
" t.LineNumber,\n" +
" t.PurchaseOrderNo,\n" +
" t.MaterialCode,\n" +
" MAX ( t.SpareDate ) SpareDate,\n" +
" t.DeliveryOrderNo,\n" +
" SUM ( t.InvoicedQty ) AS InvoicedQty \n" +
" FROM\n" +
" Set_SparePart t \n" +
" WHERE\n" +
" t.Version= '{0}' \n" +
" GROUP BY\n" +
" t.PurchaseOrderNo,\n" +
" t.MaterialCode,\n" +
" t.SpareDate,\n" +
" t.DeliveryOrderNo,\n" +
" t.LineNumber,\n" +
" t.PurchaseOrderNoText \n" +
" ) AS a\n" +
" LEFT JOIN Set_material AS b ON a.MaterialCode= b.CustomerPartCode\n" +
" LEFT JOIN Set_WMSSparePart c ON a.PurchaseOrderNo= c.WMSDeliveryNote \n" +
" AND a.MaterialCode= c.MaterialCode\n" +
" LEFT JOIN ( SELECT SUM ( amt ) / SUM ( Qty ) InvoicePrice, MaterialCode, Amt FROM set_invoice WHERE version = '{0}' GROUP BY materialcode, Amt ) d ON a.MaterialCode= d.MaterialCode \n" +
" ) TEMP1\n" +
" LEFT JOIN ( SELECT Price, --定价\n" +
" MaterialCode --厂内物料号\n" +
" FROM Set_PriceList WHERE version = ( SELECT MAX ( Version ) FROM Set_PriceList ) ) TEMP2 ON TEMP1.SAPCode= TEMP2.MaterialCode";
string addwhere = string.Empty;
string addSqlStr = string.Format(sqlString, version);
//if (!string.IsNullOrEmpty(purchaseOrderNo))

Loading…
Cancel
Save