@ -196,9 +196,12 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report
// " LEFT OUTER JOIN ( SELECT Price, MaterialCode FROM Set_PriceList WHERE Version = '202110' ) AS TEMP2 ON temp3.MaterialCode = TEMP2.MaterialCode";
#endregion
//temp3.HQHKanBan 订货看板编号 temp3.ExternalKanbanNumber 外部单号
string str = "SELECT\n" +
" temp3.HQHKanBan 订货看板编号,\n" +
" temp3.ExternalKanbanNumber 外部单号,\n" +
" temp3.Factory 工厂,temp3.StorageLocationDesc 存储地点描述,\n" +
" '' 外部单号,\n" +
" temp3.MaterialCode Sap编码,\n" +
" temp3.hqMaterialCode 客户物料号,\n" +
" temp3.EstimateTypeDesc 物料组,\n" +
@ -208,7 +211,7 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report
" isnull( temp3.Qty, 0 ) * isnull( temp3.Qty, 0 ) 结算金额,\n" +
" temp3.系统未结数量,\n" +
" temp3.UnHQQty 红旗未结数量,\n" +
" ( ISNULL( temp3.系统未结数量, 0 ) - ISNULL( temp3.UnHQQty, 0 ) ) 差异 \n" +
" ( ISNULL( temp3.系统未结数量, 0 ) - ISNULL( temp3.UnHQQty, 0 ) ) 数量 差异 \n" +
"FROM\n" +
" (\n" +
" SELECT\n" +
@ -219,7 +222,7 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report
" h.HQHKanBan,\n" +
" h.Qty,\n" +
" h.Price,\n" +
" h.ExternalKanbanNumber ,\n" +
" h.Factory,h.StorageLocationDesc ,\n" +
" m.MaterialCode,\n" +
" h.MaterialCode hqMaterialCode,\n" +
" m.CustomerPartCode,\n" +
@ -232,8 +235,7 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report
" ( Qty ) Qty,\n" +
" HQHKanBan,\n" +
" MaterialCode,\n" +
" ExternalKanbanNumber,\n" +
" Price \n" +
" Price,Factory,StorageLocationDesc \n" +
" FROM\n" +
" Set_UnHQSettleAccount \n" +
" WHERE\n" +
@ -241,8 +243,7 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report
" GROUP BY\n" +
" HQHKanBan,\n" +
" MaterialCode,\n" +
" ExternalKanbanNumber,\n" +
" Price \n" +
" Price,Factory,StorageLocationDesc \n" +
" ) AS h\n" +
" LEFT JOIN Set_material AS m ON h.MaterialCode = m.CustomerPartCode \n" +
" ) AS unhq\n" +
@ -393,126 +394,126 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report
//var sql10 = "SELECT DISTINCT\n" +
//" t1.* \n" +
//"FROM\n" +
//" (\n" +
//" SELECT\n" +
// " a.ExternalKanbanNumber AS ExternalKanbanNumber,\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 sql10 = "SELECT DISTINCT\n" +
" t1.* \n" +
"FROM\n" +
" (\n" +
" SELECT\n" +
" a.ExternalKanbanNumber AS ExternalKanbanNumber,\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<CompareFactoryExtend1>(string.Format(sql10, version));
var list11 = DbConnection . Query < CompareFactoryExtend1 > ( string . Format ( sql10 , version ) ) ;
//var sql11 = "SELECT DISTINCT\n" +
//" t1.* \n" +
//"FROM\n" +
//" (\n" +
//" SELECT\n" +
// " a.ExternalKanbanNumber AS ExternalKanbanNumber,\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<CompareFactoryExtend1>(string.Format(sql11, version));
//var sql12 = "SELECT\n" +
// " a.ExternalKanbanNumber AS ExternalKanbanNumber,\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 sql11 = "SELECT DISTINCT\n" +
" t1.* \n" +
"FROM\n" +
" (\n" +
" SELECT\n" +
" a.ExternalKanbanNumber AS ExternalKanbanNumber,\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 < CompareFactoryExtend1 > ( string . Format ( sql11 , version ) ) ;
var sql12 = "SELECT\n" +
" a.ExternalKanbanNumber AS ExternalKanbanNumber,\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<CompareFactoryExtend1>(string.Format(sql12, version));
var list13 = DbConnection . Query < CompareFactoryExtend1 > ( string . Format ( sql12 , version ) ) ;
//List<CompareFactoryExtend1> _lscopy = new List<CompareFactoryExtend1>();
List < CompareFactoryExtend1 > _l scopy = new List < CompareFactoryExtend1 > ( ) ;
//foreach (var itm in list11)
//{
// var first = _lscopy.FirstOrDefault(p => p.HQHKanBan == itm.HQHKanBan && p.MaterialCode == itm.MaterialCode);
// if (first != null)
// {
// //first.KanbanNumber += "," + itm.KanbanNumber;
// //first.AcceptanceDate += "," + itm.AcceptanceDate;
// first.ExternalKanbanNumber += "," + itm.ExternalKanbanNumber;
// }
// else
// {
// _lscopy.Add(itm);
// }
//}
//foreach (var itm in list12)
//{
// _lscopy.Add(itm);
//}
//foreach (var itm in list13)
//{
// _lscopy.Add(itm);
//}
foreach ( var itm in list11 )
{
var first = _l scopy . FirstOrDefault ( p = > p . HQHKanBan = = itm . HQHKanBan & & p . MaterialCode = = itm . MaterialCode ) ;
if ( first ! = null )
{
first . HQHKanBan + = "," + itm . HQHKanBan ;
//first.AcceptanceDate += "," + itm.AcceptanceDate;
first . ExternalKanbanNumber + = "," + itm . ExternalKanbanNumber ;
}
else
{
_l scopy . Add ( itm ) ;
}
}
foreach ( var itm in list12 )
{
_l scopy . Add ( itm ) ;
}
foreach ( var itm in list13 )
{
_l scopy . Add ( itm ) ;
}
//List<CompareFactoryExtend> _ls = new List<CompareFactoryExtend>();
@ -553,23 +554,23 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report
_l ist = _ query . ToList ( ) ;
//foreach (var itm1 in _list)
//{
// //var itm = _ls.FirstOrDefault(p => p.Kanban == itm1.订货看板编号 && p.MaterialCode == itm1.Sap编码);
// //if (itm != null)
// //{
// // itm1.交货单号 = itm.WmsBillNum;
// // itm1.交货时间 = itm.WmsDate;
// //}
// var itmcopy = _lscopy.FirstOrDefault(p => p.HQHKanBan == itm1.订货看板编号 && p.MaterialCode == itm1.Sap编码);
// if (itmcopy != null)
// {
// //itm1.看板编号 = itmcopy.KanbanNumber;
// //itm1.验收单日期 = itmcopy.AcceptanceDate;
// itm1.外部单号 = itmcopy.ExternalKanbanNumber;
// }
//}
foreach ( var itm1 in _l ist )
{
//var itm = _ls.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 . HQHKanBan ;
//itm1.验收单日期 = itmcopy.AcceptanceDate;
itm1 . 外 部 单 号 = itmcopy . ExternalKanbanNumber ;
}
}
return _l ist ;
@ -639,12 +640,13 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report
" temp.零件中文名称,\n" +
" isnull( TEMP2.Price, 0 ) AS 发货定价,\n" +
" temp.发货数量,\n" +
" isnull( TEMP2.Price, 0 )*isnull(temp.发货数量, 0 ) 发货 总金额,\n" +
" isnull( TEMP2.Price, 0 )*isnull(temp.发货数量, 0 ) 系统未结 总金额,\n" +
" temp.结算数量,\n" +
" temp.退货数量,\n" +
" temp3.Factory AS 工厂,temp3.ExternalKanbanNumber 外部单号,temp3.StorageLocationDesc 存储地点描述,\n" +
" ISNULL( temp.系统未结数量, 0 ) 系统未结数量,\n" +
" isnull( temp3.Qty, 0 ) AS 红旗未结数量,\n" +
" ( ISNULL( temp.系统未结数量, 0 ) - ISNULL( temp3.Qty, 0 ) ) 差异 \n" +
" ( ISNULL( temp.系统未结数量, 0 ) - ISNULL( temp3.Qty, 0 ) ) 数量 差异 \n" +
"FROM\n" +
" (\n" +
" SELECT\n" +
@ -740,7 +742,7 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report
" ) UNION2 \n" +
" ) AS temp\n" +
" LEFT OUTER JOIN ( SELECT Price, MaterialCode FROM Set_PriceList WHERE Version = '202110' ) AS TEMP2 ON temp.Sap编码 = TEMP2.MaterialCode\n" +
" LEFT JOIN ( SELECT SUM ( Qty ) Qty, HQHKanBan, MaterialCode FROM Set_UnHQSettleAccount WHERE Version ='{2}' GROUP BY HQHKanBan, MaterialCode ) temp3 ON temp.[订货看板编号] = temp3.HQHKanBan \n" +
" LEFT JOIN ( SELECT SUM ( Qty ) Qty, HQHKanBan, MaterialCode,ExternalKanbanNumber,Factory,StorageLocationDesc FROM Set_UnHQSettleAccount WHERE Version ='{2}' GROUP BY HQHKanBan, MaterialCode,ExternalKanbanNumber,Factory,StorageLocationDesc ) temp3 ON temp.[订货看板编号] = temp3.HQHKanBan \n" +
" AND temp.[客户物料号] = temp3.MaterialCode" ;
@ -871,15 +873,15 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report
public string 交 货 单 号 { set ; get ; }
[ExporterHeader(DisplayName = "交货时间")]
public string 交 货 时 间 { set ; get ; }
[ExporterHeader(DisplayName = "收货仓库", IsIgnore = true)]
public string 收 货 仓 库 { set ; get ; }
[ExporterHeader(DisplayName = "收货仓库描述", IsIgnore = true)]
public string 收 货 仓 库 描 述 { set ; get ; }
[ExporterHeader(DisplayName = "订货看板编号")]
public string 订 货 看 板 编 号 { set ; get ; }
[ExporterHeader(DisplayName = "结算验收单号", IsIgnore = true)]
public string 结 算 验 收 单 号 { set ; get ; }
[ExporterHeader(DisplayName = "工厂")]
public string 工 厂 { set ; get ; }
[ExporterHeader(DisplayName = "存储地点描述")]
public string 存 储 地 点 描 述 { set ; get ; }
[ExporterHeader(DisplayName = "外部单号")]
public string 外 部 单 号 { set ; get ; }
@ -896,30 +898,32 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report
[ExporterHeader(DisplayName = "物料组")]
public string 物 料 组 { set ; get ; }
[ExporterHeader(DisplayName = "验收单日期",IsIgnore =true)]
public string 验 收 单 日 期 { set ; get ; }
[ExporterHeader(DisplayName = "发货定价")]
public decimal 发 货 定 价 { set ; get ; }
[ExporterHeader(DisplayName = "发货数量")]
public decimal 发 货 数 量 { set ; get ; }
[ExporterHeader(DisplayName = "发货总金额")]
public decimal 发 货 总 金 额 { set ; get ; }
[ExporterHeader(DisplayName = "结算数量")]
public decimal 结 算 数 量 { set ; get ; }
[ExporterHeader(DisplayName = "退货数量")]
public decimal 退 货 数 量 { set ; get ; }
[ExporterHeader(DisplayName = "系统未结总金额")]
public decimal 系 统 未 结 总 金 额 { set ; get ; }
[ExporterHeader(DisplayName = "系统未结数量")]
public decimal 系 统 未 结 数 量 { set ; get ; }
[ExporterHeader(DisplayName = "结算数量")]
public decimal 结 算 数 量 { set ; get ; }
[ExporterHeader(DisplayName = "红旗未结数量")]
public decimal 红 旗 未 结 数 量 { set ; get ; }
[ExporterHeader(DisplayName = "差异")]
public decimal 差 异 { set ; get ; }
[ExporterHeader(DisplayName = "数量差异")]
public decimal 数 量 差 异 { set ; get ; }
[ExporterHeader(DisplayName = "工厂", IsIgnore = true)]
public string 工 厂 { set ; get ; }
@ -932,16 +936,20 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report
public class HQSettledUnFactoryDetailDiff
{
[ExporterHeader(DisplayName = "收货仓库", IsIgnore = true)]
public string 收 货 仓 库 { set ; get ; }
[ExporterHeader(DisplayName = "收货仓库描述", IsIgnore = true)]
public string 收 货 仓 库 描 述 { set ; get ; }
[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 = "Sap编码")]
public string Sap编码 { set ; get ; }
@ -954,30 +962,22 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report
[ExporterHeader(DisplayName = "物料组")]
public string 物 料 组 { set ; get ; }
[ExporterHeader(DisplayName = "验收单日期", IsIgnore = true)]
public string 验 收 单 日 期 { set ; get ; }
[ExporterHeader(DisplayName = "发货定价", IsIgnore = true)]
public decimal 发 货 定 价 { set ; get ; }
[ExporterHeader(DisplayName = "结算单价")]
public decimal 结 算 单 价 { set ; get ; }
[ExporterHeader(DisplayName = "发货数量",IsIgnore =true)]
public decimal 发 货 数 量 { set ; get ; }
[ExporterHeader(DisplayName = "结算数量")]
public decimal 结 算 数 量 { set ; get ; }
[ExporterHeader(DisplayName = "结算金额")]
public decimal 结 算 金 额 { set ; get ; }
[ExporterHeader(DisplayName = "退货数量",IsIgnore = true)]
public decimal 退 货 数 量 { set ; get ; }
[ExporterHeader(DisplayName = "系统未结数量")]
public decimal 系 统 未 结 数 量 { set ; get ; }
[ExporterHeader(DisplayName = "红旗未结数量")]
public decimal 红 旗 未 结 数 量 { set ; get ; }
[ExporterHeader(DisplayName = "差异")]
[ExporterHeader(DisplayName = "数量 差异")]
public decimal 差 异 { set ; get ; }