_priceList=DbConnection.Query<ErpPrice>("select Price SapPrice, MaterialCode SapErpPartCode from Set_PriceList where type='10' and version=(select max(version) from Set_PriceListVersion)").ToList();
}
List<T>tmpList=newList<T>();
if(isNotHistoryPart==true)
{
varstr="SELECT\n"+
" temp2.ErpMaterialCode,\n"+
" temp2.OrderBillNum KENNCode ,\n"+
" temp2.ChassisNumber\n"+
" FROM\n"+
" (\n"+
" SELECT DISTINCT\n"+
" ErpMaterialCode,\n"+
" b.OrderBillNum, \n"+
" "+
"b.KENNCode,\n"+
" b.ChassisNumber2, \n"+
" b.ChassisNumber \n"+
" FROM\n"+
" Set_fis b\n"+
" INNER JOIN set_settle a ON a.KENNCode = b.KENNCode \n"+
" AND a.ChassisNumber = b.ChassisNumber2 \n"+
" AND a.MaterialCode = b.ItemCode \n"+
" WHERE\n"+
" a.Version = '{0}' \n"+
" ) temp1\n"+
" INNER JOIN (\n"+
" SELECT DISTINCT\n"+
" ErpMaterialCode,\n"+
" d.OrderBillNum, \n"+
" d.KENNCode,\n"+
" d.ChassisNumber2 ,\n"+
" d.ChassisNumber \n"+
" FROM\n"+
" Set_fis d\n"+
" INNER JOIN set_settle c ON c.KENNCode = d.KENNCode \n"+
" AND c.ChassisNumber = d.ChassisNumber2 \n"+
" AND c.MaterialCode = d.ItemCode \n"+
" WHERE\n"+
" c.Version < '{0}' \n"+
" ) temp2 ON temp1.ChassisNumber2 = temp2.ChassisNumber2 \n"+
" AND temp1.ErpMaterialCode = temp2.ErpMaterialCode \n"+
// " row_number() over(order by b.EstimateTypeDesc) as RowId ,\n" +
// " c.WMSDeliveryNote,--交货单号\n" +
// " c.WMSActualGoodsDate,--实际发货日期\n" +
// " a.Kanban,--条码号\n" +
// " b.MaterialCode SapMaterialCode,--厂内物料号\n" +
// " b.MaterialDesc,--物料描述\n" +
// " b.CustomerPartCode,--客户物料\n" +
// " b.EstimateTypeDesc,--物料组(车型)\n" +
// " c.WMSDeliveryQty,--交货数量\n" +
// " a.Qty AS SettleNumber,--结算数量\n" +
// " a.SettleDate,--结算日期\n" +
// " a.Qty,--用于计算\n" +
// " ( a.Qty- c.WMSDeliveryQty ) AS SettleWMSDiffQty,--结算与发货差异\n" +
// " ( a.Qty- a.Qty ) AS SettleInvoiceDiffQty,--结算与发货差异\n" +
// " 0 AS InvoiceDiffQty,--开票数量,默认0,后续拿算法动态算\n" +
// " d.InvoicePrice,--开票单价\n" +
// " 0 AS InvoiceMoney,--开票金额\n" +
// " c.DeliveryOrderNo --出库单号\n" +
// " \n" +
// " FROM\n" +
// " Set_KanBanSettle AS a\n" +
// " LEFT JOIN Set_material AS b ON a.MaterialCode= b.CustomerPartCode\n" +
// " LEFT JOIN Set_WMSKanBanSettle c ON a.Kanban= c.Kanban \n" +
// " AND a.MaterialCode= c.MaterialCode\n" +
// " LEFT JOIN ( SELECT SUM ( amt ) / SUM ( Qty ) InvoicePrice, MaterialCode FROM set_invoice WHERE version = '{0}' GROUP BY materialcode ) d ON a.MaterialCode= d.MaterialCode \n" +
// " ) TEMP1\n" +
// " LEFT JOIN ( SELECT Price, --定价\n" +
// " MaterialCode --厂内物料号\n" +
// " FROM Set_PriceList WHERE version = ( SELECT MAX ( Version ) FROM Set_PriceList ) ) TEMP2 ON TEMP1.SapMaterialCode= TEMP2.MaterialCode \n" +
" LEFT JOIN ( SELECT Price, MaterialCode FROM Set_PriceList WHERE version = ( SELECT Max( Version ) FROM Set_PriceList ) ) temp2 ON temp1.SapMaterialCode = temp2.MaterialCode";
//var _materialList = DbConnection.Query<Material>("select * from set_material").ToList();
//var _priceList = DbConnection.Query<PriceList>("select MaterialCode,Price from Set_PriceList where version=(select max(version) from set_Set_PriceListVersion)").ToList();
" left join Set_Unsettle f on a.MaterialCode=f.MaterialCode and a.KENNCode=f.KENNCode and a.ChassisNumber=f.ChassisNumber \n"+
" LEFT JOIN Set_material B ON a.MaterialCode = b.CustomerPartCode \n"+
" LEFT JOIN Set_material d ON a.ParentSapMaterialCode = d.MaterialCode \n"+
" ) temp1\n"+
" LEFT JOIN ( SELECT Price, MaterialCode FROM Set_PriceList WHERE version = ( SELECT Max( Version ) FROM Set_PriceList ) ) temp2 ON temp1.SapMaterialCode = temp2.MaterialCode";