@ -382,17 +382,6 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report
}
}
//var _ls_1 = from itm1 in _list
// join itm2 in _ls on new { Kanban = itm1.订货看板编号, MaterialCode=itm1.Sap编码 }
// equals new { itm2.Kanban, itm2.MaterialCode } into g
// from t in g.DefaultIfEmpty()
// select new HQHSettledDetailDiff
// {
// } ;
return _l ist ;
return _l ist ;
@ -575,7 +564,16 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report
}
}
/// <summary>
/// 红旗未结比对(包含有发货有结算中发货大于结算的数据)
/// </summary>
/// <param name="version"></param>
/// <param name="materialCode"></param>
/// <param name="begin"></param>
/// <param name="end"></param>
/// <param name="materialGroup"></param>
/// <param name="iscontionversion"></param>
/// <returns></returns>
public virtual List < HQHUnSettledDetailDiff > GetReverseSettledDetailDiffReportList ( string version , string materialCode , string begin , string end , string materialGroup , string iscontionversion )
public virtual List < HQHUnSettledDetailDiff > GetReverseSettledDetailDiffReportList ( string version , string materialCode , string begin , string end , string materialGroup , string iscontionversion )
{
{
@ -610,8 +608,6 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report
" SELECT\n" +
" SELECT\n" +
" temp1.交货时间,\n" +
" temp1.交货时间,\n" +
" isnull( temp1.交货单号, '' ) 交货单号,\n" +
" isnull( temp1.交货单号, '' ) 交货单号,\n" +
" temp1.收货仓库,\n" +
" temp1.收货仓库描述,\n" +
" temp1.订货看板编号,\n" +
" temp1.订货看板编号,\n" +
" temp1.订货零件号,\n" +
" temp1.订货零件号,\n" +
" temp1.Sap编码,\n" +
" temp1.Sap编码,\n" +
@ -619,7 +615,6 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report
" temp1.物料组,\n" +
" temp1.物料组,\n" +
" temp1.零件中文名称,\n" +
" temp1.零件中文名称,\n" +
" temp1.发货数量,\n" +
" temp1.发货数量,\n" +
" temp1.发货状态,\n" +
" temp1.外部验收单号,\n" +
" temp1.外部验收单号,\n" +
" temp1.结算数量,\n" +
" temp1.结算数量,\n" +
" temp1.结算单价,\n" +
" temp1.结算单价,\n" +
@ -635,23 +630,20 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report
" SELECT\n" +
" SELECT\n" +
" a.WmsBillNum AS 交货单号,\n" +
" a.WmsBillNum AS 交货单号,\n" +
" CONVERT ( VARCHAR ( 100 ), a.LastModificationTime, 23 ) AS 交货时间 ,\n" +
" CONVERT ( VARCHAR ( 100 ), a.LastModificationTime, 23 ) AS 交货时间 ,\n" +
" b.StorageLocation AS 收货仓库,\n" +
" b.StorageLocationDesc AS 收货仓库描述,\n" +
" a.Kanban AS 订货看板编号,\n" +
" a.Kanban AS 订货看板编号,\n" +
" b.MaterialCode AS 订货零件号,\n" +
" b.MaterialCode AS 订货零件号,\n" +
" c.MaterialCode Sap编码,\n" +
" c.MaterialCode Sap编码,\n" +
" c.CustomerPartCode 客户物料号,\n" +
" c.CustomerPartCode 客户物料号,\n" +
" c.MaterialDesc AS 零件中文名称,\n" +
" c.MaterialDesc AS 零件中文名称,\n" +
" isnull( a.Qty, 0 ) AS 发货数量,\n" +
" isnull( a.Qty, 0 ) AS 发货数量,\n" +
" isnull( a.State, 0 ) AS 发货状态,\n" +
" '' AS 外部验收单号,\n" +
" b.ExternalKanbanNumber AS 外部验收单号,\n" +
" isnull( b.Qty, 0 ) AS 结算数量,\n" +
" isnull( b.Qty, 0 ) AS 结算数量,\n" +
" isnull( b.Price, 0 ) AS 结算单价,\n" +
" 0 AS 结算单价,\n" +
" isnull( b.Amt, 0 ) AS 结算金额 ,\n" +
" 0 AS 结算金额 ,\n" +
" C.EstimateTypeDesc AS 物料组 \n" +
" C.EstimateTypeDesc AS 物料组 \n" +
" FROM\n" +
" FROM\n" +
" Set_HQ_H_Kanban AS a\n" +
" ( SELECT SUM ( Qty ) Qty, Kanban, MaterialCode, WmsBillNum, LastModificationTime FROM Set_HQ_H_Kanban GROUP BY kanban, MaterialCode, WmsBillNum, LastModificationTime ) AS a\n" +
" LEFT OUTER JOIN (select * from Set_HQ_H_Platform {0} ) AS b ON a.Kanban = b.HQHKanBan \n" +
" LEFT OUTER JOIN ( SELECT SUM ( Qty ) Qty, HQHKanBan, MaterialCode FROM Set_HQ_H_Platform {0} GROUP BY HQHKanBan, MaterialCode ) AS b ON a.Kanban = b.HQHKanBan \n" +
" AND a.MaterialCode = b.MaterialCode\n" +
" AND a.MaterialCode = b.MaterialCode\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" +
@ -669,8 +661,6 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report
" SELECT\n" +
" SELECT\n" +
" temp1.交货时间,\n" +
" temp1.交货时间,\n" +
" isnull( temp1.交货单号, '' ) 交货单号,\n" +
" isnull( temp1.交货单号, '' ) 交货单号,\n" +
" temp1.收货仓库,\n" +
" temp1.收货仓库描述,\n" +
" temp1.订货看板编号,\n" +
" temp1.订货看板编号,\n" +
" temp1.订货零件号,\n" +
" temp1.订货零件号,\n" +
" temp1.Sap编码,\n" +
" temp1.Sap编码,\n" +
@ -678,7 +668,6 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report
" temp1.物料组,\n" +
" temp1.物料组,\n" +
" temp1.零件中文名称,\n" +
" temp1.零件中文名称,\n" +
" temp1.发货数量,\n" +
" temp1.发货数量,\n" +
" temp1.发货状态,\n" +
" temp1.外部验收单号,\n" +
" temp1.外部验收单号,\n" +
" temp1.结算数量,\n" +
" temp1.结算数量,\n" +
" temp1.结算单价,\n" +
" temp1.结算单价,\n" +
@ -694,15 +683,12 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report
" SELECT\n" +
" SELECT\n" +
" a.WmsBillNum AS 交货单号,\n" +
" a.WmsBillNum AS 交货单号,\n" +
" CONVERT ( VARCHAR ( 100 ), a.LastModificationTime, 23 ) AS 交货时间 ,\n" +
" CONVERT ( VARCHAR ( 100 ), a.LastModificationTime, 23 ) AS 交货时间 ,\n" +
" '' AS 收货仓库,\n" +
" '' AS 收货仓库描述,\n" +
" a.Kanban AS 订货看板编号,\n" +
" a.Kanban AS 订货看板编号,\n" +
" b.MaterialCode AS 订货零件号,\n" +
" b.MaterialCode AS 订货零件号,\n" +
" c.MaterialCode Sap编码,\n" +
" c.MaterialCode Sap编码,\n" +
" c.CustomerPartCode 客户物料号,\n" +
" c.CustomerPartCode 客户物料号,\n" +
" c.MaterialDesc AS 零件中文名称,\n" +
" c.MaterialDesc AS 零件中文名称,\n" +
" isnull( a.Qty, 0 ) AS 发货数量,\n" +
" isnull( a.Qty, 0 ) AS 发货数量,\n" +
" 0 AS 发货状态,\n" +
" '' AS 外部验收单号,\n" +
" '' AS 外部验收单号,\n" +
" isnull( b.Qty, 0 ) AS 结算数量,\n" +
" isnull( b.Qty, 0 ) AS 结算数量,\n" +
" 0 AS 结算单价,\n" +
" 0 AS 结算单价,\n" +
@ -720,11 +706,13 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report
" LEFT JOIN set_backQty tt ON temp1.Sap编码 = tt.MaterialCode \n" +
" LEFT JOIN set_backQty tt ON temp1.Sap编码 = tt.MaterialCode \n" +
" AND temp1.订货看板编号 = tt.Code \n" +
" AND temp1.订货看板编号 = tt.Code \n" +
" ) UNION2" ;
" ) UNION2" ;
var _ sql = string . Format ( str , version , condition ) ;
var _ sql = string . Format ( str , contion , condition ) ;
//发运数据中,查出看板号+物料号相同的重复数据
var sql2 = "SELECT\n" +
var sql2 = "SELECT\n" +
" a.WmsBillNum,\n" +
" a.WmsBillNum,\n" +
" t1.MaterialCode MaterialCode,\n" +
" t1.MaterialCode MaterialCode,\n" +
@ -735,19 +723,12 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report
" INNER JOIN ( SELECT MaterialCode, Kanban FROM Set_HQ_H_Kanban GROUP BY MaterialCode, Kanban HAVING COUNT(*)> 1 ) B ON A.Kanban = B.Kanban \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 " +
" AND A.MaterialCode = B.MaterialCode " +
" left join Set_material t1 on a.MaterialCode=t1.CustomerPartCode " ;
" left join Set_material t1 on a.MaterialCode=t1.CustomerPartCode " ;
var listCompare = DbConnection . Query < CompareExtend > ( sql2 ) ;
var listCompare = DbConnection . Query < CompareExtend > ( sql2 ) ;
//查询发运表中,看权号+物料号没有重复的数据
var sql3 = "SELECT\n" +
var sql3 = "SELECT\n" +
" a.WmsBillNum,\n" +
" a.WmsBillNum,\n" +
" t1.MaterialCode MaterialCode,\n" +
" t1.MaterialCode MaterialCode,\n" +
@ -762,14 +743,12 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report
"WHERE\n" +
"WHERE\n" +
" B.Kanban IS NULL" ;
" B.Kanban IS NULL" ;
var listCompare1 = DbConnection . Query < CompareExtend > ( sql3 ) ;
var listCompare1 = DbConnection . Query < CompareExtend > ( sql3 ) ;
//红旗结算数据中,看板号+物料号没有重复的
var sql10 = "SELECT DISTINCT\n" +
var sql10 = "SELECT DISTINCT\n" +
" t1.* \n" +
" t1.* \n" +
"FROM\n" +
"FROM\n" +
@ -800,7 +779,7 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report
//红旗结算数据中,看板号+物料号有重复的数据
var sql11 = "SELECT DISTINCT\n" +
var sql11 = "SELECT DISTINCT\n" +
" t1.* \n" +
" t1.* \n" +
"FROM\n" +
"FROM\n" +
@ -825,8 +804,6 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report
"ORDER BY\n" +
"ORDER BY\n" +
" t1.HQHKanBan,\n" +
" t1.HQHKanBan,\n" +
" t1.MaterialCode" ;
" t1.MaterialCode" ;
var list12 = DbConnection . Query < CompareExtend1 > ( string . Format ( sql11 , version ) ) ;
var list12 = DbConnection . Query < CompareExtend1 > ( string . Format ( sql11 , version ) ) ;
@ -847,6 +824,7 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report
var list13 = DbConnection . Query < CompareExtend1 > ( string . Format ( sql12 , version ) ) ;
var list13 = DbConnection . Query < CompareExtend1 > ( string . Format ( sql12 , version ) ) ;
//结算数据比较
List < CompareExtend1 > _l scopy = new List < CompareExtend1 > ( ) ;
List < CompareExtend1 > _l scopy = new List < CompareExtend1 > ( ) ;
foreach ( var itm in list11 )
foreach ( var itm in list11 )
@ -873,6 +851,7 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report
}
}
//发运数据比较
List < CompareExtend > _l s = new List < CompareExtend > ( ) ;
List < CompareExtend > _l s = new List < CompareExtend > ( ) ;
foreach ( var itm in listCompare . ToList ( ) )
foreach ( var itm in listCompare . ToList ( ) )
{
{
@ -933,8 +912,208 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report
}
}
/// <summary>
/// 原始红旗未结数据(不包括有发货有结算中发货大于结算的数据)
/// </summary>
/// <param name="version"></param>
/// <param name="materialCode"></param>
/// <param name="begin"></param>
/// <param name="end"></param>
/// <param name="materialGroup"></param>
/// <param name="iscontionversion"></param>
/// <returns></returns>
public virtual List < HQHUnSettledDetailDiff > GetOriginalSettledDetailDiffReportList ( string version , string materialCode , string begin , string end , string materialGroup , string iscontionversion )
{
List < HQHUnSettledDetailDiff > _l ist = new List < HQHUnSettledDetailDiff > ( ) ;
string condition = " " ;
if ( ! string . IsNullOrEmpty ( begin ) )
{
condition + = string . Format ( " and a.LastModificationTime>='{0}' " , begin ) ;
}
if ( ! string . IsNullOrEmpty ( end ) )
{
condition + = string . Format ( " and a.LastModificationTime<='{0}' " , end ) ;
}
string contion = string . Empty ;
//选中,是否过滤掉当期结算数据
if ( iscontionversion = = "0" )
{
contion + = string . Format ( " WHERE Version <'{0}' " , version ) ;
}
else
{
contion + = " WHERE 1=1 " ;
}
string str = "SELECT\n" +
" * \n" +
"FROM\n" +
" (\n" +
" SELECT\n" +
" temp1.交货时间,\n" +
" isnull( temp1.交货单号, '' ) 交货单号,\n" +
" temp1.收货仓库,\n" +
" temp1.收货仓库描述,\n" +
" temp1.订货看板编号,\n" +
" temp1.订货零件号,\n" +
" temp1.Sap编码,\n" +
" temp1.[客户物料号],\n" +
" temp1.物料组,\n" +
" temp1.零件中文名称,\n" +
" temp1.发货数量,\n" +
" temp1.发货状态,\n" +
" temp1.外部验收单号,\n" +
" temp1.结算数量,\n" +
" temp1.结算单价,\n" +
" temp1.结算金额,\n" +
" isnull( TEMP2.Price, 0 ) AS 发货定价,\n" +
" isnull( temp1.发货数量, 0 ) * isnull( TEMP2.Price, 0 ) AS 发货总金额,\n" +
" isnull( tt.Qty, 0 ) 退货数量,\n" +
" isnull( temp1.发货数量, 0 ) - isnull( tt.Qty, 0 ) AS 数量差异,\n" +
" temp1.结算单价 - ISNULL( TEMP2.Price, 0 ) AS 单价差异,\n" +
" ( temp1.结算单价 - ISNULL( TEMP2.Price, 0 ) ) * ( isnull( temp1.发货数量, 0 ) - isnull( tt.Qty, 0 ) ) AS 差异总金额 \n" +
" FROM\n" +
" (\n" +
" SELECT\n" +
" a.WmsBillNum AS 交货单号,\n" +
" CONVERT ( VARCHAR ( 100 ), a.LastModificationTime, 23 ) AS 交货时间 ,\n" +
" b.StorageLocation AS 收货仓库,\n" +
" b.StorageLocationDesc AS 收货仓库描述,\n" +
" a.Kanban AS 订货看板编号,\n" +
" b.MaterialCode AS 订货零件号,\n" +
" c.MaterialCode Sap编码,\n" +
" c.CustomerPartCode 客户物料号,\n" +
" c.MaterialDesc AS 零件中文名称,\n" +
" isnull( a.Qty, 0 ) AS 发货数量,\n" +
" isnull( a.State, 0 ) AS 发货状态,\n" +
" b.ExternalKanbanNumber AS 外部验收单号,\n" +
" isnull( b.Qty, 0 ) AS 结算数量,\n" +
" isnull( b.Price, 0 ) AS 结算单价,\n" +
" isnull( b.Amt, 0 ) AS 结算金额 ,\n" +
" C.EstimateTypeDesc AS 物料组 \n" +
" FROM\n" +
" Set_HQ_H_Kanban AS a\n" +
" LEFT OUTER JOIN (select * from Set_HQ_H_Platform {0}) AS b ON a.Kanban = b.HQHKanBan \n" +
" AND a.MaterialCode = b.MaterialCode\n" +
" LEFT OUTER JOIN Set_material AS c ON a.MaterialCode = c.CustomerPartCode \n" +
" WHERE\n" +
" b.HQHKanBan IS NULL \n" +
" AND b.MaterialCode IS NULL {1}\n" +
" ) AS temp1\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" +
" LEFT JOIN set_backQty tt ON temp1.Sap编码 = tt.MaterialCode \n" +
" AND temp1.订货看板编号 = tt.Code \n" +
" ) UNION1 " ;
var _ sql = string . Format ( str , contion , condition ) ;
var _ query = DbConnection . Query < HQHUnSettledDetailDiff > ( _ sql , null , null , true , 1 2 0 0 , null ) ;
_l ist = _ query . ToList ( ) ;
return _l ist ;
}
/// <summary>
/// 有发货有结算数据且发货数量大于结算数量
/// </summary>
/// <param name="version"></param>
/// <param name="materialCode"></param>
/// <param name="begin"></param>
/// <param name="end"></param>
/// <param name="materialGroup"></param>
/// <param name="iscontionversion"></param>
/// <returns></returns>
public virtual List < HQHUnSettledDetailDiff > GetInnerJoinSettledDetailDiffReportList ( string version , string materialCode , string begin , string end , string materialGroup , string iscontionversion )
{
List < HQHUnSettledDetailDiff > _l ist = new List < HQHUnSettledDetailDiff > ( ) ;
string condition = " " ;
if ( ! string . IsNullOrEmpty ( begin ) )
{
condition + = string . Format ( " and a.LastModificationTime>='{0}' " , begin ) ;
}
if ( ! string . IsNullOrEmpty ( end ) )
{
condition + = string . Format ( " and a.LastModificationTime<='{0}' " , end ) ;
}
string contion = string . Empty ;
//选中,是否过滤掉当期结算数据
if ( iscontionversion = = "0" )
{
contion + = string . Format ( " WHERE Version <'{0}' " , version ) ;
}
else
{
contion + = " WHERE 1=1 " ;
}
string str = "SELECT\n" +
" * \n" +
"FROM\n" +
" (\n" +
" SELECT\n" +
" temp1.交货时间,\n" +
" isnull( temp1.交货单号, '' ) 交货单号,\n" +
" temp1.订货看板编号,\n" +
" temp1.订货零件号,\n" +
" temp1.Sap编码,\n" +
" temp1.[客户物料号],\n" +
" temp1.物料组,\n" +
" temp1.零件中文名称,\n" +
" temp1.发货数量,\n" +
" temp1.外部验收单号,\n" +
" temp1.结算数量,\n" +
" temp1.结算单价,\n" +
" temp1.结算金额,\n" +
" isnull( TEMP2.Price, 0 ) AS 发货定价,\n" +
" isnull( temp1.发货数量, 0 ) * isnull( TEMP2.Price, 0 ) AS 发货总金额,\n" +
" isnull( tt.Qty, 0 ) 退货数量,\n" +
" isnull( temp1.发货数量, 0 ) - isnull( temp1.结算数量, 0 ) AS 数量差异,\n" +
" temp1.结算单价 - ISNULL( TEMP2.Price, 0 ) AS 单价差异,\n" +
" ( temp1.结算单价 - ISNULL( TEMP2.Price, 0 ) ) * ( isnull( temp1.发货数量, 0 ) - isnull( tt.Qty, 0 ) ) AS 差异总金额 \n" +
" FROM\n" +
" (\n" +
" SELECT\n" +
" a.WmsBillNum AS 交货单号,\n" +
" CONVERT ( VARCHAR ( 100 ), a.LastModificationTime, 23 ) AS 交货时间 ,\n" +
" a.Kanban AS 订货看板编号,\n" +
" b.MaterialCode AS 订货零件号,\n" +
" c.MaterialCode Sap编码,\n" +
" c.CustomerPartCode 客户物料号,\n" +
" c.MaterialDesc AS 零件中文名称,\n" +
" isnull( a.Qty, 0 ) AS 发货数量,\n" +
" '' AS 外部验收单号,\n" +
" isnull( b.Qty, 0 ) AS 结算数量,\n" +
" 0 AS 结算单价,\n" +
" 0 AS 结算金额 ,\n" +
" C.EstimateTypeDesc AS 物料组 \n" +
" FROM\n" +
" ( SELECT SUM ( Qty ) Qty, Kanban, MaterialCode, WmsBillNum, LastModificationTime FROM Set_HQ_H_Kanban GROUP BY kanban, MaterialCode, WmsBillNum, LastModificationTime ) AS a\n" +
" INNER JOIN ( SELECT SUM ( Qty ) Qty, HQHKanBan, MaterialCode FROM Set_HQ_H_Platform {0} GROUP BY HQHKanBan, MaterialCode ) AS b ON a.Kanban = b.HQHKanBan \n" +
" AND a.MaterialCode = b.MaterialCode\n" +
" LEFT OUTER JOIN Set_material AS c ON a.MaterialCode = c.CustomerPartCode \n" +
" WHERE\n" +
" a.Qty> b.Qty {1}\n" +
" ) AS temp1\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" +
" LEFT JOIN set_backQty tt ON temp1.Sap编码 = tt.MaterialCode \n" +
" AND temp1.订货看板编号 = tt.Code \n" +
" ) UNION2" ;
var _ sql = string . Format ( str , contion , condition ) ;
var _ query = DbConnection . Query < HQHUnSettledDetailDiff > ( _ sql , null , null , true , 1 2 0 0 , null ) ;
_l ist = _ query . ToList ( ) ;
return _l ist ;
}
public virtual List < HQHSettleQtyDiff > GetDiffQtyList ( string version )
public virtual List < HQHSettleQtyDiff > GetDiffQtyList ( string version )