Commit 790fd9e1 authored by gaoliwei's avatar gaoliwei

修改项目评估查询总条数不准确问题,优化

parent 03e5e5d7
...@@ -34,13 +34,6 @@ public class ProjectEvaluateServiceImpl implements ProjectEvaluateService { ...@@ -34,13 +34,6 @@ public class ProjectEvaluateServiceImpl implements ProjectEvaluateService {
Integer start = pageSize * (pageNum - 1); Integer start = pageSize * (pageNum - 1);
Integer end = pageSize * pageNum; Integer end = pageSize * pageNum;
List<Map<String, Object>> maps = projectEvaluateRepository.listProjectInformationByYear(year, start, end); List<Map<String, Object>> maps = projectEvaluateRepository.listProjectInformationByYear(year, start, end);
if (maps.size() > 0){
for (Map<String, Object> map : maps){
if((double)map.get("energyPotential") < 0){
map.put("energyPotential", 0);
}
}
}
return maps; return maps;
} }
} }
...@@ -2,27 +2,36 @@ ...@@ -2,27 +2,36 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="org.rcisoft.business.evaluate.project.dao.ProjectEvaluateRepository"> <mapper namespace="org.rcisoft.business.evaluate.project.dao.ProjectEvaluateRepository">
<sql id="listProjectInformationByYearSql">
SELECT
PRO_NM,
BLD_LOCAL,
bbt.BLD_TP_NM,
bp.BLD_AREA,
SUM( WATER + ELEC + GAS ) / bp.BLD_AREA AS energy,
CASE WHEN SUM(WATER + ELEC + GAS) / bp.BLD_AREA - bp.ENERGY_POTENTIAL > 0
THEN SUM(WATER + ELEC + GAS) / bp.BLD_AREA - bp.ENERGY_POTENTIAL ELSE 0 END AS energyPotential,
ecm.YEAR
FROM
bus_project bp
LEFT JOIN energy_count_m ecm ON bp.PRO_ID = ecm.PRO_ID
LEFT JOIN bus_build_tp bbt ON bp.BLD_TP_ID = bbt.BLD_TP_ID
<where>
<if test="year != null and year != '' ">
ecm.YEAR = #{year}
</if>
</where>
GROUP BY
bp.PRO_ID,ecm.YEAR
</sql>
<select id="listProjectInformationByYear" resultType="map"> <select id="listProjectInformationByYear" resultType="map">
SELECT SELECT
(select count(*) from bus_project) as total, (SELECT count(*) FROM ( <include refid="listProjectInformationByYearSql"/>) s) AS total,
PRO_NM, t.*
BLD_LOCAL, FROM (
bbt.BLD_TP_NM, <include refid="listProjectInformationByYearSql"/>
bp.BLD_AREA, ) t
SUM( WATER + ELEC + GAS ) / bp.BLD_AREA AS energy, LIMIT #{start},#{end}
SUM( WATER + ELEC + GAS ) / bp.BLD_AREA - bp.ENERGY_POTENTIAL AS energyPotential,
ecm.YEAR
FROM
bus_project bp
LEFT JOIN energy_count_m ecm ON bp.PRO_ID = ecm.PRO_ID
LEFT JOIN bus_build_tp bbt ON bp.BLD_TP_ID = bbt.BLD_TP_ID
<where>
<if test="year != null and year != '' ">
ecm.YEAR = #{year}
</if>
</where>
GROUP BY
bp.PRO_ID,ecm.YEAR
LIMIT #{start},#{end}
</select> </select>
</mapper> </mapper>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment