Browse Source

大众备件明细输出调整,未测试

FoShanPG
44673626 3 years ago
parent
commit
1bffb61c0b
  1. 2
      src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/Report/HQFactorySettledDetailDapperRepository.cs
  2. 3
      src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/Report/HQHSettledDetailDapperRepository.cs
  3. 2
      src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/Report/SettleKBWithCodeDapperReportRepository.cs
  4. 125
      src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/Report/SettleSparePart90DapperReportRepository.cs
  5. 593
      src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/Report/SettleSparePartDapperReportRepository.cs
  6. 2
      src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/SettleSparePart90ExportService.cs

2
src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/Report/HQFactorySettledDetailDapperRepository.cs

@ -179,7 +179,7 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report
" AND temp1.订货看板编号 = tt.Code \n" + " AND temp1.订货看板编号 = tt.Code \n" +
" ) UNION2 \n" + " ) UNION2 \n" +
" ) AS temp1 ON unhq.HQHKanBan = temp1.[订货看板编号] \n" + " ) AS temp1 ON unhq.HQHKanBan = temp1.[订货看板编号] \n" +
" AND unhq.CustomerPartCode= temp1.客户物料号 \n" + " AND unhq.CustomerPartCode= temp1.客户物料号 WHERE temp1.[订货看板编号] is null and temp1.客户物料号 is null \n" +
" ) temp3\n" + " ) temp3\n" +
" LEFT OUTER JOIN ( SELECT Price, MaterialCode FROM Set_PriceList WHERE Version = '202110' ) AS TEMP2 ON temp3.MaterialCode = TEMP2.MaterialCode"; " LEFT OUTER JOIN ( SELECT Price, MaterialCode FROM Set_PriceList WHERE Version = '202110' ) AS TEMP2 ON temp3.MaterialCode = TEMP2.MaterialCode";

3
src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/Report/HQHSettledDetailDapperRepository.cs

@ -57,8 +57,6 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report
List<HQHSettledDetailDiff> _list = new List<HQHSettledDetailDiff>(); List<HQHSettledDetailDiff> _list = new List<HQHSettledDetailDiff>();
//string condition = " "; //string condition = " ";
//if (!string.IsNullOrEmpty(begin)) //if (!string.IsNullOrEmpty(begin))
@ -70,7 +68,6 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report
// condition += string.Format(" and b.LastModificationTime<='{0}' ", end); // condition += string.Format(" and b.LastModificationTime<='{0}' ", end);
//} //}
string str = "SELECT\n" + string str = "SELECT\n" +
" isnull( temp1.交货单号, '' ) 交货单号,\n" + " isnull( temp1.交货单号, '' ) 交货单号,\n" +

2
src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/Report/SettleKBWithCodeDapperReportRepository.cs

@ -87,7 +87,7 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report
" (\n" + " (\n" +
" ( SELECT SUM ( WMSDeliveryQty ) Qty, KanBan, MaterialCode FROM Set_WMSKanBanSettle GROUP BY KanBan, MaterialCode ) temp1\n" + " ( SELECT SUM ( WMSDeliveryQty ) Qty, KanBan, MaterialCode FROM Set_WMSKanBanSettle 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" + " 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" + " AND temp1.MaterialCode = temp2.MaterialCode \n" +
" ) \n" + " ) \n" +
" ) C ON A.Kanban = C.Kanban \n" + " ) C ON A.Kanban = C.Kanban \n" +
" AND A.MaterialCode = C.MaterialCode\n" + " AND A.MaterialCode = C.MaterialCode\n" +

125
src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/Report/SettleSparePart90DapperReportRepository.cs

@ -12,7 +12,7 @@ using Volo.Abp.EntityFrameworkCore;
namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report
{ {
/// <summary> /// <summary>
/// 根据虚拟单号0-90天的是按照SAP物料号进行先进先出操作 /// 大众备件明细输出,
/// </summary> /// </summary>
public class SettleSparePart90DapperReportRepository : DapperRepository<SettleAccountDbContext>, ITransientDependency public class SettleSparePart90DapperReportRepository : DapperRepository<SettleAccountDbContext>, ITransientDependency
{ {
@ -21,7 +21,113 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report
{ } { }
/// <summary>
/// 大众备件数据调整:期初没有WMS发运数据,调整的数据就是给WMS一份,给结算一份
/// </summary>
/// <param name="purchaseOrderNo"></param>
/// <param name="version"></param>
/// <param name="sapCode"></param>
/// <param name="matialCode"></param>
/// <param name="begintime"></param>
/// <param name="endtime"></param>
/// <returns></returns>
public virtual List<SettleSparePart90Export> GetSettleSparePart90ReportList(string purchaseOrderNo, string version, string sapCode, string matialCode, public virtual List<SettleSparePart90Export> GetSettleSparePart90ReportList(string purchaseOrderNo, string version, string sapCode, string matialCode,
string begintime, string endtime)
{
string sqlString = "SELECT\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" +
" 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" +
" ( ReceiptQty ) AS ReceiptQty,\n" +
" PurchaseOrderNo,\n" +
" MaterialCode,\n" +
" Version,\n" +
" PurchasePriceNoTax,\n" +
" InvoicedQty,\n" +
" PurchaseOrderNoText,\n" +
" AmountNoTax \n" +
" FROM\n" +
" Set_SparePart where Extend='is90' \n" +
" GROUP BY\n" +
" PurchaseOrderNo,\n" +
" MaterialCode,\n" +
" Version,\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" +
" ( a.Version = '{0}' ) \n" +
" ) AS temp1\n" +
" LEFT OUTER JOIN ( SELECT Price, MaterialCode FROM Set_PriceList WHERE Version = '202110' ) 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);
//string _sql = string.Format(sqlString, version);
var _query = DbConnection.Query<SettleSparePart90Export>(_sql, null, null, true, 1200, null);
return _query.ToList();
}
public virtual List<SettleSparePart90Export> GetSettleSparePart90ReportList_old(string purchaseOrderNo, string version, string sapCode, string matialCode,
string begintime, string endtime) string begintime, string endtime)
{ {
string sqlString = "SELECT\n" + string sqlString = "SELECT\n" +
@ -70,7 +176,7 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report
" PurchaseOrderNoText,\n" + " PurchaseOrderNoText,\n" +
" AmountNoTax \n" + " AmountNoTax \n" +
" FROM\n" + " FROM\n" +
" Set_SparePart \n" + " Set_SparePart where Extend='is90' \n" +
" GROUP BY\n" + " GROUP BY\n" +
" PurchaseOrderNo,\n" + " PurchaseOrderNo,\n" +
" MaterialCode,\n" + " MaterialCode,\n" +
@ -116,7 +222,16 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report
} }
/// <summary>
/// 大众备件未结明细
/// </summary>
/// <param name="purchaseOrderNo"></param>
/// <param name="version"></param>
/// <param name="sapCode"></param>
/// <param name="matialCode"></param>
/// <param name="begintime"></param>
/// <param name="endtime"></param>
/// <returns></returns>
public virtual List<SettleSparePart90Export> GetUnSettleSparePart90ReportList(string purchaseOrderNo, string version, string sapCode, string matialCode, public virtual List<SettleSparePart90Export> GetUnSettleSparePart90ReportList(string purchaseOrderNo, string version, string sapCode, string matialCode,
string begintime, string endtime) string begintime, string endtime)
{ {
@ -156,7 +271,7 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report
" ISNULL( b.AmountNoTax, 0 ) AS 开票金额 \n" + " ISNULL( b.AmountNoTax, 0 ) AS 开票金额 \n" +
" FROM\n" + " FROM\n" +
" Set_WMSSparePart a\n" + " Set_WMSSparePart a\n" +
" LEFT JOIN ( SELECT PurchaseOrderNo, Version, PurchaseOrderNoText, PurchasePriceNoTax, InvoicedQty, AmountNoTax FROM Set_SparePart WHERE Version = '{0}' ) b ON a.PurchaseOrderNo = b.PurchaseOrderNo\n" + " LEFT JOIN ( SELECT PurchaseOrderNo, Version, PurchaseOrderNoText, PurchasePriceNoTax, InvoicedQty, AmountNoTax FROM Set_SparePart WHERE Version = '{0}' and Extend='is90' ) b ON a.PurchaseOrderNo = b.PurchaseOrderNo\n" +
" LEFT OUTER JOIN Set_material AS c ON a.MaterialCode = c.CustomerPartCode \n" + " LEFT OUTER JOIN Set_material AS c ON a.MaterialCode = c.CustomerPartCode \n" +
" WHERE\n" + " WHERE\n" +
" b.PurchaseOrderNo IS NULL \n" + " b.PurchaseOrderNo IS NULL \n" +
@ -183,7 +298,7 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report
// " a.PurchaseOrderNo 订单号,\n" + // " a.PurchaseOrderNo 订单号,\n" +
// " a.MaterialCode 物料号 \n" + // " a.MaterialCode 物料号 \n" +
// "FROM\n" + // "FROM\n" +
// " ( SELECT SUM ( ReceiptQty ) ReceiptQty, PurchaseOrderNo, MaterialCode FROM Set_SparePart WHERE Version = '{0}' GROUP BY PurchaseOrderNo, MaterialCode ) A\n" + // " ( SELECT SUM ( ReceiptQty ) ReceiptQty, PurchaseOrderNo, MaterialCode FROM Set_SparePart WHERE Version = '{0}' and Extend='is90' 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" + // " 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" + // " AND A.PurchaseOrderNo = B.PurchaseOrderNo \n" +
// "WHERE\n" + // "WHERE\n" +

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

@ -18,12 +18,10 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report
: base(dbContextProvider) : base(dbContextProvider)
{ } { }
//public async Task<string> SettledSparePart(string purchaseOrderNo, string sapCode, string version, string customerCode, string factory, string matialCode,
//string state, DateTime begin, DateTime end)
/// <summary> /// <summary>
/// 带采购订单号和无订单号一起统计报表 WHERE Extend != 'is90' /// 带采购订单号和无订单号一起统计报表 WHERE Extend != 'is90' 去掉 备件调整数据
/// </summary> /// </summary>
/// <param name="purchaseOrderNo"></param> /// <param name="purchaseOrderNo"></param>
/// <param name="version"></param> /// <param name="version"></param>
@ -36,163 +34,424 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report
string begintime, string endtime) string begintime, string endtime)
{ {
string sqlString = "SELECT\n" + string sqlString = "SELECT\n" +
" union1.* \n" + " union1.* \n" +
"FROM\n" + "FROM\n" +
" (\n" + " (\n" +
" SELECT\n" + " SELECT\n" +
" temp1.交货日期,\n" + " temp1.交货日期,\n" +
" temp1.交货单号,\n" + " temp1.交货单号,\n" +
" '' 订单日期,\n" + " NULL 订单日期,\n" +
" temp1.采购订单号,\n" + " temp1.采购订单号,\n" +
" temp1.SAP编码,\n" + " temp1.SAP编码,\n" +
" temp1.物料代码,\n" + " temp1.物料代码,\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" + " ISNULL( temp1.收货数量, 0 ) - ISNULL( temp1.开票数量, 0 ) AS 收货与开票差异,\n" +
" temp1.开票单价,\n" + " temp1.开票单价,\n" +
" ISNULL( temp1.开票金额, 0 ) AS 开票金额,\n" + " ISNULL( temp1.开票金额, 0 ) AS 开票金额,\n" +
" ISNULL( TEMP2.Price, 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" + " ( temp1.开票单价 - ISNULL( TEMP2.Price, 0 ) ) * temp1.开票数量 AS 差异总金额,\n" +
" FROM\n" + " temp1.交货数量,\n" +
" (\n" + " temp1.收货与交货差异,\n" +
" SELECT\n" + " ISNULL( temp1.交货数量, 0 ) - ISNULL( temp3.Qty, 0 ) 实际交货数量,\n" +
" a.Version AS 期间,\n" + " ISNULL( temp3.Qty, 0 ) 退货数量 \n" +
" a.PurchaseOrderNoText AS 采购订单文本,\n" + " FROM\n" +
" b.WMSDeliveryNote AS 交货单号,\n" + " (\n" +
" b.SpareDate AS 交货日期,\n" + " SELECT\n" +
" a.PurchaseOrderNo AS 采购订单号,\n" + " a.Version AS 期间,\n" +
" c.MaterialCode AS SAP编码,\n" + " a.PurchaseOrderNoText AS 采购订单文本,\n" +
" b.MaterialCode AS 物料代码,\n" + " '' AS 交货单号,\n" +
" c.MaterialDesc AS 物料描述,\n" + " NULL AS 交货日期,\n" +
" c.EstimateTypeDesc AS 物料组,\n" + " a.PurchaseOrderNo AS 采购订单号,\n" +
" a.PurchasePriceNoTax AS 开票单价,\n" + " b.MaterialCode AS SAP编码,\n" +
" 0 AS 数量差异,\n" + " b.CustomerPartCode AS 物料代码,\n" +
" ISNULL( b.ReceiptQty, 0 ) AS 发货数量,\n" + " b.MaterialDesc AS 物料描述,\n" +
" ISNULL( a.InvoicedQty, 0 ) AS 开票数量 ,\n" + " b.EstimateTypeDesc AS 物料组,\n" +
" ISNULL( a.AmountNoTax, 0 ) AS 开票金额 \n" + " ISNULL( a.PurchasePriceNoTax, 0 ) AS 开票单价,\n" +
" FROM\n" + " ISNULL( a.ReceiptQty, 0 ) AS 收货数量,\n" +
" (\n" + " ISNULL( a.InvoicedQty, 0 ) AS 开票数量 ,\n" +
" SELECT SUM\n" + " ISNULL( a.InvoicedQty, 0 ) * ISNULL( a.PurchasePriceNoTax, 0 ) AS 开票金额,\n" +
" ( ReceiptQty ) AS ReceiptQty,\n" + " ISNULL( C.WMSDeliveryQty, 0 ) AS 交货数量,\n" +
" PurchaseOrderNo,\n" + " ( ISNULL( a.ReceiptQty, 0 ) - ISNULL( C.WMSDeliveryQty, 0 ) ) AS 收货与交货差异 \n" +
" MaterialCode,\n" + " FROM\n" +
" Version,\n" + " ( SELECT * FROM Set_SparePart WHERE Extend != 'is90' ) AS a\n" +
" PurchasePriceNoTax,\n" + " LEFT OUTER JOIN Set_material AS b ON a.MaterialCode = b.CustomerPartCode\n" +
" InvoicedQty,\n" + " LEFT JOIN (\n" +
" PurchaseOrderNoText,\n" + "   SELECT\n" +
" AmountNoTax \n" + " ( ISNULL( temp1.Qty, 0 ) - ISNULL( temp2.Qty, 0 ) ) WMSDeliveryQty,\n" +
" FROM\n" + " temp1.MaterialCode,\n" +
" Set_SparePart WHERE Extend != 'is90' \n" + " temp1.PurchaseOrderNo \n" +
" GROUP BY\n" + " FROM\n" +
" PurchaseOrderNo,\n" + " (\n" +
" MaterialCode,\n" + " ( SELECT SUM ( ReceiptQty ) Qty, PurchaseOrderNo, MaterialCode FROM Set_WMSSparePart GROUP BY PurchaseOrderNo, MaterialCode ) temp1\n" +
" Version,\n" + " LEFT JOIN ( SELECT SUM ( ReceiptQty ) Qty, PurchaseOrderNo, MaterialCode FROM Set_SparePart WHERE VERSION < '{0}' AND Extend != 'is90' GROUP BY PurchaseOrderNo, MaterialCode ) temp2 ON temp1.PurchaseOrderNo = temp2.PurchaseOrderNo \n" +
" PurchasePriceNoTax,\n" + " AND temp1.MaterialCode = temp2.MaterialCode \n" +
" InvoicedQty,\n" + " ) \n" +
" PurchaseOrderNoText,\n" + " ) C ON A.PurchaseOrderNo = C.PurchaseOrderNo \n" +
" AmountNoTax \n" + " AND A.MaterialCode = C.MaterialCode \n" +
" ) AS a\n" + " WHERE\n" +
" INNER JOIN (\n" + " ( a.Version = '{0}' ) \n" +
" SELECT SUM\n" + " ) AS temp1\n" +
" ( ReceiptQty ) AS ReceiptQty,\n" + " LEFT JOIN ( SELECT * FROM set_backQty WHERE Version = '{0}' ) temp3 ON temp1.采购订单号 = temp3.Code \n" +
" PurchaseOrderNo,\n" + " AND temp1.SAP编码= temp3.MaterialCode\n" +
" SapCode,\n" + " LEFT OUTER JOIN ( SELECT Price, MaterialCode FROM Set_PriceList WHERE Version = '202110' ) AS TEMP2 ON temp1.SAP编码 = TEMP2.MaterialCode \n" +
" MaterialCode,\n" + " ) union1 UNION ALL\n" +
" WMSDeliveryNote,\n" + "SELECT\n" +
" SpareDate \n" + " union2.* \n" +
" FROM\n" + "FROM\n" +
" Set_WMSSparePart \n" + " (\n" +
" GROUP BY\n" + " SELECT\n" +
" PurchaseOrderNo,\n" + " temp1.交货日期,\n" +
" SapCode,\n" + " '' 交货单号,\n" +
" MaterialCode,\n" + " '' 订单日期,\n" +
" WMSDeliveryNote,\n" + " '' 采购订单号,\n" +
" SpareDate \n" + " temp1.SAP编码,\n" +
" ) AS b ON a.PurchaseOrderNo = b.PurchaseOrderNo \n" + " temp1.物料代码,\n" +
" AND a.MaterialCode = b.MaterialCode\n" + " temp1.物料描述,\n" +
" LEFT OUTER JOIN Set_material AS c ON a.MaterialCode = c.CustomerPartCode \n" + " '' 采购订单文本,\n" +
" WHERE\n" + " temp1.收货数量,\n" +
" ( a.Version = '{0}' ) \n" + " temp1.开票数量,\n" +
" ) AS temp1\n" + " ISNULL( temp1.收货数量, 0 ) - ISNULL( temp1.开票数量, 0 ) AS 发货与开票差异,\n" +
" LEFT OUTER JOIN ( SELECT Price, MaterialCode FROM Set_PriceList WHERE Version = '202110' ) AS TEMP2 ON temp1.SAP编码 = TEMP2.MaterialCode \n" + " temp1.开票单价,\n" +
" ) union1 UNION ALL\n" + " ISNULL( temp1.开票金额, 0 ) AS 开票金额,\n" +
"SELECT\n" + " ISNULL( TEMP2.Price, 0 ) AS 定价,\n" +
" union2.* \n" + " temp1.开票单价 - ISNULL( TEMP2.Price, 0 ) AS 单价差异 ,\n" +
"FROM\n" + " ( temp1.开票单价 - ISNULL( TEMP2.Price, 0 ) ) * temp1.开票数量 AS 差异总金额,\n" +
" (\n" + " 0 交货数量,\n" +
" SELECT\n" + " 0 收货与交货差异,\n" +
" temp1.交货日期,\n" + " 0 实际交货数量,\n" +
" '' 交货单号,\n" + " 0 退货数量 \n" +
" '' 订单日期,\n" + " FROM\n" +
" '' 采购订单号,\n" + " (\n" +
" temp1.SAP编码,\n" + " SELECT\n" +
" temp1.物料代码,\n" + " '' AS 交货单号,\n" +
" temp1.物料描述,\n" + " NULL AS 交货日期,\n" +
" temp1.采购订单文本,\n" + " c.MaterialCode AS SAP编码,\n" +
" temp1.发货数量,\n" + " a.MaterialCode AS 物料代码,\n" +
" temp1.开票数量,\n" + " c.MaterialDesc AS 物料描述,\n" +
" ISNULL( temp1.发货数量, 0 ) - ISNULL( temp1.开票数量, 0 ) AS 发货与开票差异,\n" + " c.EstimateTypeDesc AS 物料组,\n" +
" temp1.开票单价,\n" + " ISNULL( a.PurchasePriceNoTax, 0 ) AS 开票单价,\n" +
" ISNULL( temp1.开票金额, 0 ) AS 开票金额,\n" + " ISNULL( a.ReceiptQty, 0 ) AS 收货数量,\n" +
" ISNULL( TEMP2.Price, 0 ) AS 定价,\n" + " ISNULL( a.InvoicedQty, 0 ) AS 开票数量 ,\n" +
" temp1.开票单价 - ISNULL( TEMP2.Price, 0 ) AS 单价差异 ,\n" + " ISNULL( a.ReceiptQty, 0 ) * ISNULL( a.PurchasePriceNoTax, 0 ) AS 开票金额 \n" +
" ( temp1.开票单价 - ISNULL( TEMP2.Price, 0 ) ) * temp1.开票数量 AS 差异总金额 \n" + " FROM\n" +
" FROM\n" + " (\n" +
" (\n" + " SELECT SUM\n" +
" SELECT\n" + " ( ReceiptQty ) AS ReceiptQty,\n" +
" a.Version AS 期间,\n" + " SUM ( InvoicedQty ) InvoicedQty,\n" +
" '' AS 采购订单文本,\n" + " MaterialCode,\n" +
" NULL AS 交货日期,\n" + " PurchasePriceNoTax \n" +
" c.MaterialCode AS SAP编码,\n" + " FROM\n" +
" a.MaterialCode AS 物料代码,\n" + " Set_SparePart \n" +
" c.MaterialDesc AS 物料描述,\n" + " WHERE\n" +
" c.EstimateTypeDesc AS 物料组,\n" + " Extend != 'is90' \n" +
" a.PurchasePriceNoTax AS 开票单价,\n" + " AND Version = '{0}' \n" +
" 0 AS 数量差异,\n" + " AND PurchaseOrderNo IS NULL \n" +
" ISNULL( b.ReceiptQty, 0 ) AS 发货数量,\n" + " GROUP BY\n" +
" ISNULL( a.ReceiptQty, 0 ) AS 开票数量 ,\n" + " MaterialCode,\n" +
" ISNULL( a.ReceiptQty, 0 ) * ISNULL( a.PurchasePriceNoTax, 0 ) AS 开票金额 \n" + " PurchasePriceNoTax \n" +
" FROM\n" + " ) AS a\n" +
" ( SELECT SUM ( ReceiptQty ) AS ReceiptQty, MaterialCode, Version, PurchasePriceNoTax FROM Set_SparePart WHERE Extend != 'is90' GROUP BY MaterialCode, Version, PurchasePriceNoTax ) AS a\n" + " LEFT JOIN ( SELECT SUM ( ReceiptQty ) AS ReceiptQty, MaterialCode FROM Set_WMSSparePart GROUP BY MaterialCode ) AS b ON a.MaterialCode = b.MaterialCode\n" +
" LEFT JOIN ( SELECT SUM ( ReceiptQty ) AS ReceiptQty, SapCode, MaterialCode FROM Set_WMSSparePart GROUP BY SapCode, MaterialCode ) AS b ON a.MaterialCode = b.MaterialCode\n" + " LEFT OUTER JOIN ( SELECT MAX ( Id ) Id, MaterialCode, CustomerPartCode, MaterialDesc, EstimateTypeDesc FROM Set_material GROUP BY MaterialCode, MaterialDesc, EstimateTypeDesc, CustomerPartCode ) AS c ON a.MaterialCode = c.CustomerPartCode \n" +
" LEFT OUTER JOIN ( SELECT MAX ( Id ) Id, MaterialCode, CustomerPartCode, MaterialDesc, EstimateTypeDesc FROM Set_material GROUP BY MaterialCode, MaterialDesc, EstimateTypeDesc, CustomerPartCode ) AS c ON a.MaterialCode = c.CustomerPartCode \n" + " ) AS temp1\n" +
" WHERE\n" + " LEFT OUTER JOIN ( SELECT Price, MaterialCode FROM Set_PriceList WHERE Version = ( SELECT MAX ( VERSION ) FROM Set_PriceList ) ) AS TEMP2 ON temp1.SAP编码 = TEMP2.MaterialCode \n" +
" ( a.Version = '{0}' ) \n" + " ) union2";
" ) AS temp1\n" +
" LEFT OUTER JOIN ( SELECT Price, MaterialCode FROM Set_PriceList WHERE Version = '202110' ) AS TEMP2 ON temp1.SAP编码 = TEMP2.MaterialCode \n" +
" ) union2";
string _sql = string.Format(sqlString, version);
//" LEFT OUTER JOIN ( SELECT Price, MaterialCode FROM Set_PriceList WHERE ( Version = ( SELECT MAX ( Version ) FROM Set_PriceList ) ) ) AS TEMP2 ON temp.Sap编码 = TEMP2.MaterialCode\n" +
string addwhere = string.Empty; var _query = DbConnection.Query<SettleSparePartExport>(_sql, null, null, true, 1200, null);
string addSqlStr = string.Format(sqlString, version);
//if (!string.IsNullOrEmpty(purchaseOrderNo)) var _lst = _query.ToList();
//{
// addwhere += string.Format(" AND PurchaseOrderNo LIKE '{0}%' ", purchaseOrderNo);
//}
//else if (!string.IsNullOrEmpty(sapCode))
//{
// addwhere += string.Format(" AND SAPCode LIKE '{0}%' ", sapCode);
//}
//else if (!string.IsNullOrEmpty(matialCode))
//{
// addwhere += string.Format(" AND MaterialCode LIKE '{0}%' ", matialCode);
//}
//else if (!string.IsNullOrEmpty(begintime)&& !string.IsNullOrEmpty(endtime))
//{
// addwhere += string.Format(" AND OrderDate BETWEEN '{0}' AND '{1}' ", begintime, endtime);
//}
string _sql = string.Format(addSqlStr, addwhere); var sql1 = "SELECT\n" +
//string _sql = string.Format(sqlString, version); " A.WMSDeliveryNote WmsBillNum,\n" +
var _query = DbConnection.Query<SettleSparePartExport>(_sql, null, null, true, 1200, null); " t1.MaterialCode MaterialCode,\n" +
return _query.ToList(); " A.PurchaseOrderNo,\n" +
" A.SpareDate WmsDate \n" +
"FROM\n" +
" Set_WMSSparePart A\n" +
" INNER JOIN ( SELECT MaterialCode, PurchaseOrderNo FROM Set_WMSSparePart GROUP BY MaterialCode, PurchaseOrderNo HAVING COUNT ( 1 ) = 1 ) B ON A.PurchaseOrderNo = B.PurchaseOrderNo \n" +
" AND A.MaterialCode = B.MaterialCode\n" +
" LEFT JOIN Set_material t1 ON A.MaterialCode = t1.CustomerPartCode \n" +
"WHERE\n" +
" A.WMSDeliveryNote IS NOT NULL ";
var listCompare1 = DbConnection.Query<CompareExtend>(sql1);
List<CompareExtend> _ls1 = new List<CompareExtend>();
foreach (var itm in listCompare1.ToList())
{
var first = _ls1.FirstOrDefault(p => p.Kanban == itm.Kanban && p.MaterialCode == itm.MaterialCode);
if (first != null)
{
if (!string.IsNullOrEmpty(itm.WmsDate))
{
itm.WmsDate = DateTime.Parse(itm.WmsDate).ToShortDateString();
}
first.WmsBillNum += "," + itm.WmsBillNum;
first.WmsDate += "," + itm.WmsDate;
}
else
{
if (!string.IsNullOrEmpty(itm.WmsDate))
{
itm.WmsDate = DateTime.Parse(itm.WmsDate).ToShortDateString();
}
_ls1.Add(itm);
}
}
var sql2 = "SELECT\n" +
" A.WMSDeliveryNote WmsBillNum,\n" +
" t1.MaterialCode MaterialCode,\n" +
" A.PurchaseOrderNo,\n" +
" A.SpareDate WmsDate \n" +
"FROM\n" +
" Set_WMSSparePart A\n" +
" INNER JOIN ( SELECT MaterialCode, PurchaseOrderNo FROM Set_WMSSparePart GROUP BY MaterialCode, PurchaseOrderNo HAVING COUNT ( * ) > 1 ) B ON A.PurchaseOrderNo = B.PurchaseOrderNo \n" +
" AND A.MaterialCode = B.MaterialCode\n" +
" LEFT JOIN Set_material t1 ON A.MaterialCode = t1.CustomerPartCode";
var listCompare = DbConnection.Query<CompareExtend>(sql2);
List<CompareExtend> _ls = new List<CompareExtend>();
foreach (var itm in listCompare.ToList())
{
var first = _ls.FirstOrDefault(p => p.Kanban == itm.Kanban && p.MaterialCode == itm.MaterialCode);
if (first != null)
{
if (!string.IsNullOrEmpty(itm.WmsDate))
{
itm.WmsDate = DateTime.Parse(itm.WmsDate).ToShortDateString();
}
first.WmsBillNum += "," + itm.WmsBillNum;
first.WmsDate += "," + itm.WmsDate;
}
else
{
if (!string.IsNullOrEmpty(itm.WmsDate))
{
itm.WmsDate = DateTime.Parse(itm.WmsDate).ToShortDateString();
}
_ls.Add(itm);
}
}
foreach (var itm1 in _lst)
{
//itm1.收货与交货差异 = itm1.收货数量 - ((!string.IsNullOrEmpty(itm1.实际交货数量)) ? decimal.Parse(itm1.实际交货数量) : 0);
var item = _ls1.FirstOrDefault(p => p.Kanban == itm1. && p.MaterialCode == itm1.SAP编码);
if (item != null)
{
itm1. = item.WmsBillNum;
itm1. = item.WmsDate;
}
var itm = _ls.FirstOrDefault(p => p.Kanban == itm1. && p.MaterialCode == itm1.SAP编码);
if (itm != null)
{
itm1. = itm.WmsBillNum;
itm1. = itm.WmsDate;
}
}
return _lst;
} }
/// <summary>
/// 带采购订单号和无订单号一起统计报表 WHERE Extend != 'is90'
/// </summary>
/// <param name="purchaseOrderNo"></param>
/// <param name="version"></param>
/// <param name="sapCode"></param>
/// <param name="matialCode"></param>
/// <param name="begintime"></param>
/// <param name="endtime"></param>
/// <returns></returns>
//public virtual List<SettleSparePartExport> GetSettleSparePartReportList(string purchaseOrderNo, string version, string sapCode, string matialCode,
// string begintime, string endtime)
//{
// string sqlString = "SELECT\n" +
// " union1.* \n" +
// "FROM\n" +
// " (\n" +
// " SELECT\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" +
// " 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" +
// " ( ReceiptQty ) AS ReceiptQty,\n" +
// " PurchaseOrderNo,\n" +
// " MaterialCode,\n" +
// " Version,\n" +
// " PurchasePriceNoTax,\n" +
// " InvoicedQty,\n" +
// " PurchaseOrderNoText,\n" +
// " AmountNoTax \n" +
// " FROM\n" +
// " Set_SparePart WHERE Extend != 'is90' \n" +
// " GROUP BY\n" +
// " PurchaseOrderNo,\n" +
// " MaterialCode,\n" +
// " Version,\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" +
// " ( a.Version = '{0}' ) \n" +
// " ) AS temp1\n" +
// " LEFT OUTER JOIN ( SELECT Price, MaterialCode FROM Set_PriceList WHERE Version = '202110' ) AS TEMP2 ON temp1.SAP编码 = TEMP2.MaterialCode \n" +
// " ) union1 UNION ALL\n" +
// "SELECT\n" +
// " union2.* \n" +
// "FROM\n" +
// " (\n" +
// " SELECT\n" +
// " temp1.交货日期,\n" +
// " '' 交货单号,\n" +
// " '' 订单日期,\n" +
// " '' 采购订单号,\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" +
// " a.Version AS 期间,\n" +
// " '' AS 采购订单文本,\n" +
// " NULL AS 交货日期,\n" +
// " c.MaterialCode AS SAP编码,\n" +
// " a.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.ReceiptQty, 0 ) AS 开票数量 ,\n" +
// " ISNULL( a.ReceiptQty, 0 ) * ISNULL( a.PurchasePriceNoTax, 0 ) AS 开票金额 \n" +
// " FROM\n" +
// " ( SELECT SUM ( ReceiptQty ) AS ReceiptQty, MaterialCode, Version, PurchasePriceNoTax FROM Set_SparePart WHERE Extend != 'is90' and PurchaseOrderNo is null GROUP BY MaterialCode, Version, PurchasePriceNoTax ) AS a\n" +
// " LEFT JOIN ( SELECT SUM ( ReceiptQty ) AS ReceiptQty, SapCode, MaterialCode FROM Set_WMSSparePart GROUP BY SapCode, MaterialCode ) AS b ON a.MaterialCode = b.MaterialCode\n" +
// " LEFT OUTER JOIN ( SELECT MAX ( Id ) Id, MaterialCode, CustomerPartCode, MaterialDesc, EstimateTypeDesc FROM Set_material GROUP BY MaterialCode, MaterialDesc, EstimateTypeDesc, CustomerPartCode ) 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 = '202110' ) AS TEMP2 ON temp1.SAP编码 = TEMP2.MaterialCode \n" +
// " ) union2";
// //" LEFT OUTER JOIN ( SELECT Price, MaterialCode FROM Set_PriceList WHERE ( Version = ( SELECT MAX ( Version ) FROM Set_PriceList ) ) ) AS TEMP2 ON temp.Sap编码 = TEMP2.MaterialCode\n" +
// string addwhere = string.Empty;
// string addSqlStr = string.Format(sqlString, version);
// //if (!string.IsNullOrEmpty(purchaseOrderNo))
// //{
// // addwhere += string.Format(" AND PurchaseOrderNo LIKE '{0}%' ", purchaseOrderNo);
// //}
// //else if (!string.IsNullOrEmpty(sapCode))
// //{
// // addwhere += string.Format(" AND SAPCode LIKE '{0}%' ", sapCode);
// //}
// //else if (!string.IsNullOrEmpty(matialCode))
// //{
// // addwhere += string.Format(" AND MaterialCode LIKE '{0}%' ", matialCode);
// //}
// //else if (!string.IsNullOrEmpty(begintime)&& !string.IsNullOrEmpty(endtime))
// //{
// // addwhere += string.Format(" AND OrderDate BETWEEN '{0}' AND '{1}' ", begintime, endtime);
// //}
// string _sql = string.Format(addSqlStr, addwhere);
// //string _sql = string.Format(sqlString, version);
// var _query = DbConnection.Query<SettleSparePartExport>(_sql, null, null, true, 1200, null);
// return _query.ToList();
//}
/// <summary> /// <summary>
/// 有结算无发货的报表统计 /// 有结算无发货的报表统计
/// </summary> /// </summary>
@ -239,8 +498,8 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report
" ISNULL( a.ReceiptQty, 0 ) AS 开票数量 ,\n" + " ISNULL( a.ReceiptQty, 0 ) AS 开票数量 ,\n" +
" ISNULL( a.ReceiptQty, 0 ) * ISNULL( a.PurchasePriceNoTax, 0 ) AS 开票金额 \n" + " ISNULL( a.ReceiptQty, 0 ) * ISNULL( a.PurchasePriceNoTax, 0 ) AS 开票金额 \n" +
" FROM\n" + " FROM\n" +
" ( SELECT SUM ( ReceiptQty ) AS ReceiptQty, MaterialCode, Version, PurchasePriceNoTax FROM Set_SparePart WHERE Extend != 'is90' GROUP BY MaterialCode, Version, PurchasePriceNoTax ) AS a\n" + " ( SELECT SUM ( ReceiptQty ) AS ReceiptQty, MaterialCode, PurchasePriceNoTax FROM Set_SparePart WHERE Extend != 'is90' GROUP BY MaterialCode, PurchasePriceNoTax ) AS a\n" +
" LEFT JOIN ( SELECT SUM ( ReceiptQty ) AS ReceiptQty, SapCode, MaterialCode FROM Set_WMSSparePart GROUP BY SapCode, MaterialCode ) AS b ON a.MaterialCode = b.MaterialCode\n" + " LEFT JOIN ( SELECT SUM ( ReceiptQty ) AS ReceiptQty, MaterialCode FROM Set_WMSSparePart GROUP BY MaterialCode ) AS b ON a.MaterialCode = b.MaterialCode\n" +
" LEFT OUTER JOIN ( SELECT MAX ( Id ) Id, MaterialCode, CustomerPartCode, MaterialDesc, EstimateTypeDesc FROM Set_material GROUP BY MaterialCode, MaterialDesc, EstimateTypeDesc, CustomerPartCode ) AS c ON a.MaterialCode = c.CustomerPartCode \n" + " LEFT OUTER JOIN ( SELECT MAX ( Id ) Id, MaterialCode, CustomerPartCode, MaterialDesc, EstimateTypeDesc FROM Set_material GROUP BY MaterialCode, MaterialDesc, EstimateTypeDesc, CustomerPartCode ) AS c ON a.MaterialCode = c.CustomerPartCode \n" +
" WHERE\n" + " WHERE\n" +
" ( a.Version = '{0}' ) \n" + " ( a.Version = '{0}' ) \n" +
@ -304,7 +563,7 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report
" ISNULL( b.ReceiptQty, 0 ) AS 开票数量 ,\n" + " ISNULL( b.ReceiptQty, 0 ) AS 开票数量 ,\n" +
" ISNULL( b.ReceiptQty, 0 ) * ISNULL( b.PurchasePriceNoTax, 0 ) AS 开票金额 \n" + " ISNULL( b.ReceiptQty, 0 ) * ISNULL( b.PurchasePriceNoTax, 0 ) AS 开票金额 \n" +
" FROM\n" + " FROM\n" +
" ( SELECT SUM ( ReceiptQty ) AS ReceiptQty, SapCode, MaterialCode FROM Set_WMSSparePart GROUP BY SapCode, MaterialCode ) AS a\n" + " ( SELECT SUM ( ReceiptQty ) AS ReceiptQty, MaterialCode FROM Set_WMSSparePart GROUP BY MaterialCode ) AS a\n" +
" LEFT JOIN ( SELECT * FROM Set_SparePart WHERE Extend != 'is90' AND Version = '{0}' ) AS b ON a.MaterialCode = b.MaterialCode\n" + " LEFT JOIN ( SELECT * FROM Set_SparePart WHERE Extend != 'is90' AND Version = '{0}' ) AS b ON a.MaterialCode = b.MaterialCode\n" +
" LEFT OUTER JOIN ( SELECT MAX ( Id ) Id, MaterialCode, CustomerPartCode, MaterialDesc, EstimateTypeDesc FROM Set_material GROUP BY MaterialCode, MaterialDesc, EstimateTypeDesc, CustomerPartCode ) AS c ON a.MaterialCode = c.CustomerPartCode \n" + " LEFT OUTER JOIN ( SELECT MAX ( Id ) Id, MaterialCode, CustomerPartCode, MaterialDesc, EstimateTypeDesc FROM Set_material GROUP BY MaterialCode, MaterialDesc, EstimateTypeDesc, CustomerPartCode ) AS c ON a.MaterialCode = c.CustomerPartCode \n" +
" WHERE\n" + " WHERE\n" +
@ -395,10 +654,11 @@ public class SparePartSumQtyDiff
[ExporterHeader(DisplayName = "采购订单文本")] [ExporterHeader(DisplayName = "采购订单文本")]
public string { set; get; } public string { set; get; }
[ExporterHeader(DisplayName = "货数量")] [ExporterHeader(DisplayName = "货数量")]
public decimal { set; get; } public decimal { set; get; }
[ExporterHeader(DisplayName = "开票数量")] [ExporterHeader(DisplayName = "开票数量")]
public decimal { set; get; } public decimal { set; get; }
[ExporterHeader(DisplayName = "发货与开票差异")] [ExporterHeader(DisplayName = "发货与开票差异")]
public decimal { set; get; } public decimal { set; get; }
[ExporterHeader(DisplayName = "开票单价")] [ExporterHeader(DisplayName = "开票单价")]
@ -417,5 +677,16 @@ public class SparePartSumQtyDiff
[ExporterHeader(DisplayName = "寄售库存数量")] [ExporterHeader(DisplayName = "寄售库存数量")]
public decimal { set; get; } public decimal { set; get; }
[ExporterHeader(DisplayName = "交货数量")]
public decimal { set; get; }
[ExporterHeader(DisplayName = "退货数量")]
public string 退 { set; get; }
[ExporterHeader(DisplayName = "实际交货数量")]
public string { set; get; }
[ExporterHeader(DisplayName = "收货与交货差异")]
public decimal { set; get; }
} }
} }

2
src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/SettleSparePart90ExportService.cs

@ -97,7 +97,7 @@ namespace SettleAccount.Job.Services.Report
ExcelExporter _exporter = new ExcelExporter();//导出Excel ExcelExporter _exporter = new ExcelExporter();//导出Excel
var result = _exporter.Append(_ls.ToList(), "大众备件数据调整") var result = _exporter.Append(_ls.ToList(), "大众备件数据调整输出")
.SeparateBySheet() .SeparateBySheet()
.Append(_unls.ToList(), "有发货无结算") .Append(_unls.ToList(), "有发货无结算")
.ExportAppendDataAsByteArray(); .ExportAppendDataAsByteArray();

Loading…
Cancel
Save