@ -21,6 +21,17 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report
}
public class CompareExtend1
{
public string AcceptanceNo { set ; get ; }
public string KanbanNumber { set ; get ; }
public string AcceptanceDate { set ; get ; }
public string HQHKanBan { set ; get ; }
public string MaterialCode { set ; get ; }
}
/// <summary>
/// 红旗H平台输出报表
@ -154,9 +165,16 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report
" AND A.MaterialCode = B.MaterialCode" ;
var listCompare = DbConnection . Query < CompareExtend > ( sql2 ) ;
var sql3 = "SELECT\n" +
" a.WmsBillNum,\n" +
" a.MaterialCode,\n" +
@ -177,14 +195,113 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report
var sql10 = "SELECT DISTINCT\n" +
" t1.* \n" +
"FROM\n" +
" (\n" +
" SELECT\n" +
" a.AcceptanceNo AS AcceptanceNo,\n" +
" a.KanbanNumber AS KanbanNumber,\n" +
" CONVERT ( VARCHAR ( 100 ), a.AcceptanceDate, 23 ) AS AcceptanceDate,\n" +
" HQHKanBan,\n" +
" MaterialCode \n" +
" FROM\n" +
" Set_HQ_H_Platform a \n" +
" WHERE\n" +
" Version = '{0}' \n" +
" AND HQHKanBan <> 'BJ' \n" +
" ) t1\n" +
" LEFT JOIN ( SELECT HQHKanBan, MaterialCode FROM Set_HQ_H_Platform a WHERE Version = '{0}' AND HQHKanBan <> 'BJ' GROUP BY HQHKanBan, MaterialCode HAVING count(*)> 1 ) t2 ON t1.HQHKanBan = t2.HQHKanBan \n" +
" AND t1.MaterialCode = t2.MaterialCode \n" +
"WHERE\n" +
" t2.HQHKanBan IS NULL" ;
var list11 = DbConnection . Query < CompareExtend1 > ( string . Format ( sql10 , version ) ) ;
var sql11 = "SELECT DISTINCT\n" +
" t1.* \n" +
"FROM\n" +
" (\n" +
" SELECT\n" +
" a.AcceptanceNo AS AcceptanceNo,\n" +
" a.KanbanNumber AS KanbanNumber,\n" +
" CONVERT ( VARCHAR ( 100 ), a.AcceptanceDate, 23 ) AS AcceptanceDate,\n" +
" HQHKanBan,\n" +
" MaterialCode \n" +
" FROM\n" +
" Set_HQ_H_Platform a \n" +
" WHERE\n" +
" Version = '{0}' \n" +
" AND HQHKanBan <> 'BJ' \n" +
" ) t1\n" +
" INNER JOIN ( SELECT HQHKanBan, MaterialCode FROM Set_HQ_H_Platform a WHERE Version = '{0}' AND HQHKanBan <> 'BJ' GROUP BY HQHKanBan, MaterialCode HAVING count(*)> 1 ) t2 ON t1.HQHKanBan = t2.HQHKanBan \n" +
" AND t1.MaterialCode = t2.MaterialCode \n" +
"ORDER BY\n" +
" t1.HQHKanBan,\n" +
" t1.MaterialCode" ;
var list12 = DbConnection . Query < CompareExtend1 > ( string . Format ( sql11 , version ) ) ;
var sql12 = "SELECT\n" +
" a.AcceptanceNo AS AcceptanceNo,\n" +
" a.KanbanNumber AS KanbanNumber,\n" +
" CONVERT ( VARCHAR ( 100 ), a.AcceptanceDate, 23 ) AS AcceptanceDate,\n" +
" HQHKanBan,\n" +
" MaterialCode \n" +
"FROM\n" +
" Set_HQ_H_Platform a \n" +
"WHERE\n" +
" Version = '{0}' \n" +
" AND HQHKanBan = 'BJ'" ;
var list13 = DbConnection . Query < CompareExtend1 > ( string . Format ( sql12 , version ) ) ;
List < CompareExtend1 > _l scopy = new List < CompareExtend1 > ( ) ;
foreach ( var itm in list11 )
{
var first = _l scopy . FirstOrDefault ( p = > p . HQHKanBan = = itm . HQHKanBan & & p . MaterialCode = = itm . MaterialCode ) ;
if ( first ! = null )
{
first . KanbanNumber + = "," + itm . KanbanNumber ;
first . AcceptanceDate + = "," + itm . AcceptanceDate ;
first . AcceptanceNo + = "," + itm . AcceptanceNo ;
}
else
{
_l scopy . Add ( itm ) ;
}
}
foreach ( var itm in list12 )
{
_l scopy . Add ( itm ) ;
}
foreach ( var itm in list13 )
{
_l scopy . Add ( itm ) ;
}
List < CompareExtend > _l s = new List < CompareExtend > ( ) ;
foreach ( var itm in listCompare . ToList ( ) )
{
var first = _l s . FirstOrDefault ( p = > p . Kanban = = itm . Kanban & & p . MaterialCode = = itm . MaterialCode ) ;
if ( first ! = null )
{
first . WmsBillNum + = itm . WmsBillNum ;
first . WmsDate + = itm . WmsDate ;
first . WmsBillNum + = "," + itm . WmsBillNum ;
first . WmsDate + = "," + itm . WmsDate ;
}
else
{
_l s . Add ( itm ) ;
}
}