diff --git a/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/Report/HQHSettledDetailDapperRepository.cs b/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/Report/HQHSettledDetailDapperRepository.cs index 9e14c83d..ae8e9ef3 100644 --- a/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/Report/HQHSettledDetailDapperRepository.cs +++ b/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/Report/HQHSettledDetailDapperRepository.cs @@ -651,7 +651,7 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report " 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" + + " LEFT JOIN (select * from set_backQty WHERE Version='{2}') tt ON temp1.Sap编码 = tt.MaterialCode \n" + " AND temp1.订货看板编号 = tt.Code \n" + " ) UNION1 UNION ALL\n" + "SELECT\n" + @@ -675,9 +675,9 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report " 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" + + " isnull( temp1.发货数量, 0 ) - 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" + + " ( temp1.结算单价 - ISNULL( TEMP2.Price, 0 ) ) * ( isnull( temp1.发货数量, 0 ) - isnull( temp1.结算数量, 0 ) - isnull( tt.Qty, 0 ) ) AS 差异总金额 \n" + " FROM\n" + " (\n" + " SELECT\n" + @@ -691,24 +691,24 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report " isnull( a.Qty, 0 ) AS 发货数量,\n" + " '' AS 外部验收单号,\n" + " isnull( b.Qty, 0 ) AS 结算数量,\n" + - " 0 AS 结算单价,\n" + - " 0 AS 结算金额 ,\n" + + " isnull( b.Price, 0 ) AS 结算单价,\n" + + " isnull( b.Qty, 0 ) * isnull( b.Price, 0 ) AS 结算金额 ,\n" + " C.EstimateTypeDesc AS 物料组 \n" + " FROM\n" + " ( SELECT SUM ( Qty ) Qty, Kanban, MaterialCode, LastModificationTime FROM Set_HQ_H_Kanban GROUP BY kanban, MaterialCode, 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" + + " INNER JOIN ( SELECT SUM ( Qty ) Qty, HQHKanBan, MaterialCode,Price FROM Set_HQ_H_Platform {0} GROUP BY HQHKanBan, MaterialCode,Price ) 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" + + " LEFT JOIN (select * from set_backQty WHERE Version='{2}') tt ON temp1.Sap编码 = tt.MaterialCode \n" + " AND temp1.订货看板编号 = tt.Code \n" + " ) UNION2"; - var _sql = string.Format(str, contion, condition); + var _sql = string.Format(str, contion, condition,version); @@ -746,35 +746,52 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report var listCompare1 = DbConnection.Query(sql3); - + string contionCompare = string.Empty; + //选中,是否过滤掉当期结算数据 + if (iscontionversion == "0") + { + contionCompare += string.Format(" WHERE Version <'{0}' AND HQHKanBan <> 'BJ' ", version); + } + else + { + contionCompare += " WHERE 1=1 "; + } //红旗结算数据中,看板号+物料号没有重复的数据 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_HQ_H_Platform 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 ( 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"; + " 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_HQ_H_Platform a\n" + + " LEFT JOIN Set_material b2 ON a.MaterialCode = b2.CustomerPartCode \n" + + " {0} \n" + + " ) t1\n" + + " LEFT JOIN (\n" + + " SELECT\n" + + " HQHKanBan,\n" + + " MaterialCode \n" + + " FROM\n" + + " Set_HQ_H_Platform a \n" + + " {0} \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 list_leftjoin_hplatform = DbConnection.Query(string.Format(sql10, version)); + var list_leftjoin_hplatform = DbConnection.Query(string.Format(sql10, contionCompare)); @@ -791,37 +808,53 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report " HQHKanBan,\n" + " b2.MaterialCode \n" + " FROM\n" + - " Set_HQ_H_Platform a \n" + - - " left join Set_material b2 on a.MaterialCode = b2.CustomerPartCode \n" + - - " WHERE\n" + - " Version = '{0}' \n" + - " AND HQHKanBan <> 'BJ' \n" + + " Set_HQ_H_Platform a\n" + + " LEFT JOIN Set_material b2 ON a.MaterialCode = b2.CustomerPartCode \n" + + " {0}\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" + + " INNER JOIN (\n" + + " SELECT\n" + + " HQHKanBan,\n" + + " MaterialCode \n" + + " FROM\n" + + " Set_HQ_H_Platform a \n" + + " {0}\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 list_innerjoin_hplatform = DbConnection.Query(string.Format(sql11, version)); + var list_innerjoin_hplatform = DbConnection.Query(string.Format(sql11, contionCompare)); - 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_HQ_H_Platform a \n" + - " left join Set_material b2 on a.MaterialCode = b2.CustomerPartCode \n" + + string contionCompareBJ = string.Empty; + //选中,是否过滤掉当期结算数据 + if (iscontionversion == "0") + { + contionCompareBJ += string.Format(" WHERE Version <'{0}' AND HQHKanBan = 'BJ' ", version); + } + else + { + contionCompareBJ += " WHERE 1=1 "; + } - "WHERE\n" + - " Version = '{0}' \n" + - " AND HQHKanBan = 'BJ'"; + 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_HQ_H_Platform a\n" + + " LEFT JOIN Set_material b2 ON a.MaterialCode = b2.CustomerPartCode \n" + + "{0}"; - var list_hplaform_bj = DbConnection.Query(string.Format(sql12, version)); + var list_hplaform_bj = DbConnection.Query(string.Format(sql12, contionCompareBJ)); //结算数据比较 @@ -1525,6 +1558,10 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report public decimal 发货定价 { set; get; } [ExporterHeader(DisplayName = "发货总金额")] public decimal 发货总金额 { set; get; } + + [ExporterHeader(DisplayName = "退货数量")] + public decimal 退货数量 { set; get; } + [ExporterHeader(DisplayName = "数量差异")] public decimal 数量差异 { set; get; } [ExporterHeader(DisplayName = "单价差异")]