Browse Source

调整1

FoShanPG
44673626 3 years ago
parent
commit
ede60a34a7
  1. 100
      src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/Report/HQHSettledDetailDapperRepository.cs

100
src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/Report/HQHSettledDetailDapperRepository.cs

@ -57,42 +57,19 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report
List<HQHSettledDetailDiff> _list = new List<HQHSettledDetailDiff>();
//string condition = " where 1=1 ";
string condition = " ";
////if (!string.IsNullOrEmpty(materialCode))
////{
//// condition += string.Format(" and d.MaterialCode in ({0}) ", materialCode);
////}
if (!string.IsNullOrEmpty(begin))
{
condition += string.Format(" and b.LastModificationTime>='{0}' ", begin);
}
if (!string.IsNullOrEmpty(end))
{
condition += string.Format(" and b.LastModificationTime<='{0}' ", end);
}
//if (!string.IsNullOrEmpty(cp7begin))
//string condition = " ";
//if (!string.IsNullOrEmpty(begin))
//{
// condition += string.Format(" and B.cp7>='{0}' ", cp7begin);
// condition += string.Format(" and b.LastModificationTime>='{0}' ", begin);
//}
//if (!string.IsNullOrEmpty(cp7end))
//if (!string.IsNullOrEmpty(end))
//{
// condition += string.Format(" and B.cp7<='{0}' ", cp7end);
// condition += string.Format(" and b.LastModificationTime<='{0}' ", end);
//}
////if (!string.IsNullOrEmpty(kennCode))
////{
//// condition += string.Format(" and B.kenncode='{0}' ", kennCode);
////}
////if (!string.IsNullOrEmpty(chassisNumber))
////{
//// condition += string.Format(" and B.chassisNumber='{0}' ", chassisNumber);
////}
////if (!string.IsNullOrEmpty(materialGroup))
////{
//// condition += string.Format(" B.chassisNumber='{0}' ", materialGroup);
////}
string str = "SELECT\n" +
" isnull( temp1.交货单号, '' ) 交货单号,\n" +
" temp1.交货时间,\n" +
@ -111,13 +88,13 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report
" temp1.发货状态,\n" +
" temp1.结算验收单号,\n" +
" temp1.结算数量,\n" +
" temp1.结算单价,\n" +
" temp1.结算金额,\n" +
" temp3.Price AS 结算单价,\n" +
" ( temp1.[结算数量] * ISNULL( temp3.Price, 0 ) ) AS 结算金额,\n" +
" isnull( TEMP2.Price, 0 ) AS 发货定价,\n" +
" isnull( temp1.发货数量, 0 ) * isnull( TEMP2.Price, 0 ) AS 发货总金额,\n" +
" 0 AS 数量差异,\n" +
" temp1.结算单价 - ISNULL( TEMP2.Price, 0 ) AS 单价差异,\n" +
" ( temp1.结算单价 - ISNULL( TEMP2.Price, 0 ) ) * temp1.结算数量 AS 差异总金额 \n" +
" ISNULL( temp3.Price, 0 ) - ISNULL( TEMP2.Price, 0 ) AS 单价差异,\n" +
" ( ISNULL( temp3.Price, 0 ) - ISNULL( TEMP2.Price, 0 ) ) * temp1.结算数量 AS 差异总金额 \n" +
"FROM\n" +
" (\n" +
" SELECT\n" +
@ -127,30 +104,65 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report
" a.StorageLocation AS 收货仓库,\n" +
" a.StorageLocationDesc AS 收货仓库描述,\n" +
" a.HQHKanBan AS 订货看板编号,\n" +
" a.MaterialCode AS 订货零件号,\n" +
" '' AS 订货零件号,\n" +
" c.MaterialCode Sap编码,\n" +
" a.MaterialCode 结算物料代码,\n" +
" c.MaterialDesc AS 零件中文名称,\n" +
" isnull( b.Qty, 0 ) AS 发货数量,\n" +
" 0 AS 发货状态,\n" +
" a.AcceptanceNo AS 结算验收单号,\n" +
" '' AS 结算验收单号,\n" +
" isnull( a.Qty, 0 ) AS 结算数量,\n" +
" isnull( a.Price, 0 ) AS 结算单价,\n" +
" ( isnull( a.Qty, 0 ) * isnull( a.Price, 0 ) ) AS 结算金额 ,\n" +
" C.EstimateTypeDesc AS 物料组,\n" +
" a.Factory AS 工厂,\n" +
" a.KanbanNumber AS 看板编号,\n" +
" CONVERT ( VARCHAR ( 100 ), a.AcceptanceDate, 23 ) AS 验收单日期 \n" +
" '' AS 看板编号,\n" +
" NULL AS 验收单日期 \n" +
" FROM\n" +
" Set_HQ_H_Platform AS a\n" +
" (\n" +
" SELECT SUM\n" +
" ( Qty ) AS Qty,\n" +
" HQHKanBan,\n" +
" MaterialCode,\n" +
" Version,\n" +
" StorageLocation,\n" +
" StorageLocationDesc,\n" +
" Factory \n" +
" FROM\n" +
" Set_HQ_H_Platform \n" +
" GROUP BY\n" +
" HQHKanBan,\n" +
" MaterialCode,\n" +
" Version,\n" +
" StorageLocation,\n" +
" StorageLocationDesc,\n" +
" Factory \n" +
" ) AS a\n" +
" INNER JOIN ( SELECT SUM ( Qty ) AS Qty, Kanban, MaterialCode FROM Set_HQ_H_Kanban GROUP BY Kanban, MaterialCode ) AS b ON a.HQHKanBan = b.Kanban \n" +
" AND a.MaterialCode = b.MaterialCode\n" +
" LEFT OUTER JOIN Set_material AS c ON a.MaterialCode = c.CustomerPartCode \n" +
" WHERE\n" +
" ( a.HQHKanBan <> 'BJ' ) \n" +
" AND a.Version= '{0}' {1} \n" +
" AND a.Version= '{0}' \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";
var _sql = string.Format(str, version, condition);
" 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 (\n" +
" SELECT SUM\n" +
" ( Amt ) / SUM ( Qty ) AS Price,\n" +
" HQHKanBan,\n" +
" MaterialCode,\n" +
" Version \n" +
" FROM\n" +
" Set_HQ_H_Platform \n" +
" WHERE\n" +
" HQHKanBan <> 'BJ' \n" +
" AND Version = '{0}' \n" +
" GROUP BY\n" +
" HQHKanBan,\n" +
" MaterialCode,\n" +
" Version \n" +
" ) AS TEMP3 ON temp1.[结算物料代码] = TEMP3.MaterialCode \n" +
" AND temp1.订货看板编号 = TEMP3.HQHKanBan";
//var _sql = string.Format(str, version, condition);
var _sql = string.Format(str, version);

Loading…
Cancel
Save