@ -48,8 +48,9 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report
" temp3.StorageLocationDesc 收货仓库描述,\n" +
" temp3.HQHKanBan 订货看板编号,\n" +
" temp3.AcceptanceNo 结算验收单号,\n" +
" temp3.AcceptanceDate 验收单日期,\n" +
" temp3.MaterialCode Sap编码,\n" +
" temp3.CustomerPart Code 客户物料号,\n" +
" temp3.hqMaterial Code 客户物料号,\n" +
" temp3.EstimateTypeDesc 物料组,\n" +
" temp3.MaterialDesc 零件中文名称,\n" +
" isnull( TEMP2.Price, 0 ) AS 发货定价,\n" +
@ -68,7 +69,9 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report
" h.StorageLocationDesc,\n" +
" h.HQHKanBan,\n" +
" h.AcceptanceNo,\n" +
" CONVERT ( VARCHAR ( 100 ), h.AcceptanceDate, 23 ) AcceptanceDate,\n" +
" m.MaterialCode,\n" +
" h.MaterialCode hqMaterialCode,\n" +
" m.CustomerPartCode,\n" +
" m.MaterialDesc,\n" +
" m.EstimateTypeDesc,\n" +
@ -83,7 +86,8 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report
" StorageLocation,\n" +
" StorageLocationDesc,\n" +
" AcceptanceNo,\n" +
" MaterialCode \n" +
" MaterialCode,\n" +
" AcceptanceDate \n" +
" FROM\n" +
" Set_UnHQSettleAccount \n" +
" GROUP BY\n" +
@ -92,7 +96,8 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report
" StorageLocationDesc,\n" +
" AcceptanceNo,\n" +
" Amt,\n" +
" MaterialCode \n" +
" MaterialCode,\n" +
" AcceptanceDate \n" +
" ) AS h\n" +
" LEFT JOIN Set_material AS m ON h.MaterialCode = m.CustomerPartCode \n" +
" ) AS unhq\n" +
@ -123,8 +128,219 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report
" LEFT OUTER JOIN ( SELECT Price, MaterialCode FROM Set_PriceList WHERE ( Version = ( SELECT MAX ( Version ) FROM Set_PriceList ) ) ) AS TEMP2 ON temp3.MaterialCode = TEMP2.MaterialCode" ;
var _ sql = string . Format ( str , condition ) ;
var sql2 = "SELECT\n" +
" a.WmsBillNum,\n" +
" t1.MaterialCode MaterialCode,\n" +
" a.Kanban ,\n" +
" A.LastModificationTime WmsDate \n" +
"FROM\n" +
" Set_HQ_H_Kanban A\n" +
" INNER JOIN ( SELECT MaterialCode, Kanban FROM Set_HQ_H_Kanban GROUP BY MaterialCode, Kanban HAVING COUNT(*)> 1 ) B ON A.Kanban = B.Kanban \n" +
" AND A.MaterialCode = B.MaterialCode " +
" left join Set_material t1 on a.MaterialCode=t1.CustomerPartCode " ;
var listCompare = DbConnection . Query < CompareExtend > ( sql2 ) ;
var sql3 = "SELECT\n" +
" a.WmsBillNum,\n" +
" t1.MaterialCode MaterialCode,\n" +
" a.Kanban,\n" +
" A.LastModificationTime WmsDate \n" +
"FROM\n" +
" Set_HQ_H_Kanban A\n" +
" LEFT JOIN ( SELECT MaterialCode, Kanban FROM Set_HQ_H_Kanban GROUP BY MaterialCode, Kanban HAVING COUNT(*)> 1 ) B ON A.Kanban = B.Kanban \n" +
" AND A.MaterialCode = B.MaterialCode \n" +
" left join Set_material t1 on a.MaterialCode=t1.CustomerPartCode \n" +
"WHERE\n" +
" B.Kanban IS NULL" ;
var listCompare1 = DbConnection . Query < CompareExtend > ( sql3 ) ;
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" +
" b2.MaterialCode \n" +
" FROM\n" +
" Set_UnHQSettleAccount a\n" +
" LEFT JOIN Set_material b2 ON a.MaterialCode = b2.CustomerPartCode \n" +
" WHERE\n" +
" Version = '{0}' \n" +
" AND HQHKanBan <> 'BJ' \n" +
" ) t1\n" +
" LEFT JOIN (\n" +
" SELECT\n" +
" HQHKanBan,\n" +
" MaterialCode \n" +
" FROM\n" +
" Set_UnHQSettleAccount a \n" +
" WHERE\n" +
" Version = '{0}' \n" +
" AND HQHKanBan <> 'BJ' \n" +
" GROUP BY\n" +
" HQHKanBan,\n" +
" MaterialCode \n" +
" HAVING\n" +
" COUNT ( * ) > 1 \n" +
" ) 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" +
" b2.MaterialCode \n" +
" FROM\n" +
" Set_UnHQSettleAccount a\n" +
" LEFT JOIN Set_material b2 ON a.MaterialCode = b2.CustomerPartCode \n" +
" WHERE\n" +
" Version = '{0}' \n" +
" AND HQHKanBan <> 'BJ' \n" +
" ) t1\n" +
" INNER JOIN (\n" +
" SELECT\n" +
" HQHKanBan,\n" +
" MaterialCode \n" +
" FROM\n" +
" Set_UnHQSettleAccount a \n" +
" WHERE\n" +
" Version = '{0}' \n" +
" AND HQHKanBan <> 'BJ' \n" +
" GROUP BY\n" +
" HQHKanBan,\n" +
" MaterialCode \n" +
" HAVING\n" +
" COUNT ( * ) > 1 \n" +
" ) 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" +
" b2.MaterialCode \n" +
"FROM\n" +
" Set_UnHQSettleAccount a\n" +
" LEFT JOIN Set_material b2 ON a.MaterialCode = b2.CustomerPartCode \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 )
{
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 ( ) ;
}
_l s . Add ( itm ) ;
}
}
foreach ( var itm in listCompare1 . ToList ( ) )
{
if ( ! string . IsNullOrEmpty ( itm . WmsDate ) )
{
itm . WmsDate = DateTime . Parse ( itm . WmsDate ) . ToShortDateString ( ) ;
}
_l s . Add ( itm ) ;
}
var _ query = DbConnection . Query < HQFactoryUnSettledDetailDiff > ( _ sql , null , null , true , 1 2 0 0 , null ) ;
_l ist = _ query . ToList ( ) ;
foreach ( var itm1 in _l ist )
{
var itm = _l s . FirstOrDefault ( p = > p . Kanban = = itm1 . 订 货 看 板 编 号 & & p . MaterialCode = = itm1 . Sap编码 ) ;
if ( itm ! = null )
{
itm1 . 交 货 单 号 = itm . WmsBillNum ;
itm1 . 交 货 时 间 = itm . WmsDate ;
}
var itmcopy = _l scopy . FirstOrDefault ( p = > p . HQHKanBan = = itm1 . 订 货 看 板 编 号 & & p . MaterialCode = = itm1 . Sap编码 ) ;
if ( itmcopy ! = null )
{
//itm1.看板编号 = itmcopy.KanbanNumber;
itm1 . 验 收 单 日 期 = itmcopy . AcceptanceDate ;
itm1 . 结 算 验 收 单 号 = itmcopy . AcceptanceNo ;
}
}
return _l ist ;
}
@ -157,7 +373,7 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report
string str = "SELECT\n" +
" temp1.交货单号,\n" +
" temp1.交货日期 ,\n" +
" temp1.交货时间 ,\n" +
" temp1.收货仓库,\n" +
" temp1.收货仓库描述,\n" +
" temp1.订货看板编号,\n" +
@ -174,7 +390,7 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report
" (\n" +
" SELECT\n" +
" a.WmsBillNum [交货单号],\n" +
" CONVERT ( VARCHAR ( 100 ), a.LastModificationTime, 23 ) 交货日期 ,\n" +
" CONVERT ( VARCHAR ( 100 ), a.LastModificationTime, 23 ) 交货时间 ,\n" +
" b.StorageLocation AS 收货仓库,\n" +
" b.StorageLocationDesc AS 收货仓库描述,\n" +
" a.Kanban AS 订货看板编号,\n" +
@ -209,8 +425,8 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report
{
[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 = "收货仓库描述")]