Commit 639f2ca4 authored by jichao's avatar jichao

更改bug

parent 041b8ccd
...@@ -21,12 +21,12 @@ public interface ProjectEvaluateRepository { ...@@ -21,12 +21,12 @@ public interface ProjectEvaluateRepository {
* @param end * @param end
* @return * @return
*/ */
List<Map<String,Object>> listProjectInformationByYear(@Param("year")String year, @Param("start")Integer start, @Param("end")Integer end ); List<Map<String,Object>> listProjectInformationByYear(@Param("year")String year, @Param("start")Integer start, @Param("end")Integer end, @Param("month")Integer month);
@Select("<script>select count(1) from (select distinct mon from energy_count_m where PRO_ID=#{proId}) a</script>") @Select("<script>select count(1) from (select distinct mon from energy_count_m where PRO_ID=#{proId} and MON &lt; ${month}) a</script>")
@ResultType(BigDecimal.class) @ResultType(BigDecimal.class)
BigDecimal countMonth(@Param("proId") String proId); BigDecimal countMonth(@Param("proId") String proId, @Param("month") Integer month);
} }
...@@ -9,6 +9,7 @@ import org.springframework.transaction.annotation.Propagation; ...@@ -9,6 +9,7 @@ import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.Calendar;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
...@@ -32,10 +33,12 @@ public class ProjectEvaluateServiceImpl implements ProjectEvaluateService { ...@@ -32,10 +33,12 @@ public class ProjectEvaluateServiceImpl implements ProjectEvaluateService {
*/ */
@Override @Override
public List<Map<String, Object>> listProjectInformationByYear(String year, Integer pageNum, Integer pageSize) { public List<Map<String, Object>> listProjectInformationByYear(String year, Integer pageNum, Integer pageSize) {
// 当前月份
int month = Calendar.getInstance().get(Calendar.MONTH) + 1;
BigDecimal zero = new BigDecimal(0); BigDecimal zero = new BigDecimal(0);
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, month);
// 循环,根据id查询月份的数量 // 循环,根据id查询月份的数量
maps.forEach(map -> { maps.forEach(map -> {
// 得到节能潜力 // 得到节能潜力
...@@ -43,7 +46,7 @@ public class ProjectEvaluateServiceImpl implements ProjectEvaluateService { ...@@ -43,7 +46,7 @@ public class ProjectEvaluateServiceImpl implements ProjectEvaluateService {
BigDecimal energyPotential = new BigDecimal(map.get("energyPotential") == null ? "0" : map.get("energyPotential").toString()); BigDecimal energyPotential = new BigDecimal(map.get("energyPotential") == null ? "0" : map.get("energyPotential").toString());
// 根据proId,查询月份的数量 // 根据proId,查询月份的数量
String proId = (String) map.get("PRO_ID"); String proId = (String) map.get("PRO_ID");
BigDecimal monthCount = projectEvaluateRepository.countMonth(proId); BigDecimal monthCount = projectEvaluateRepository.countMonth(proId, month);
energy = energy.divide(monthCount).setScale(2, BigDecimal.ROUND_HALF_UP); energy = energy.divide(monthCount).setScale(2, BigDecimal.ROUND_HALF_UP);
map.put("energy", energy); map.put("energy", energy);
// 如果减去节能潜力的结果,大于0,赋值,如果小于0,赋值0 // 如果减去节能潜力的结果,大于0,赋值,如果小于0,赋值0
......
...@@ -18,7 +18,7 @@ import java.util.List; ...@@ -18,7 +18,7 @@ import java.util.List;
@Repository @Repository
public interface MainteDistributedRepository { public interface MainteDistributedRepository {
@Select("<script>select b.PRO_NM,b.BLD_COORDINATE,b.BLD_AREA, " + @Select("<script>select b.PRO_ID,b.PRO_NM,b.BLD_COORDINATE,b.BLD_AREA, " +
"CONVERT(sum((if(e.WATER_MONEY is null, 0, e.WATER_MONEY)+if(e.ELEC_MONEY is null, 0, e.ELEC_MONEY)+if(e.GAS_MONEY is null, 0, e.GAS_MONEY))*12/b.BLD_AREA),DECIMAL(10,2)) MONEY " + "CONVERT(sum((if(e.WATER_MONEY is null, 0, e.WATER_MONEY)+if(e.ELEC_MONEY is null, 0, e.ELEC_MONEY)+if(e.GAS_MONEY is null, 0, e.GAS_MONEY))*12/b.BLD_AREA),DECIMAL(10,2)) MONEY " +
/*"sum(if(e.WATER_MONEY is null, 0, e.WATER_MONEY)) WATER_MONEY, " + /*"sum(if(e.WATER_MONEY is null, 0, e.WATER_MONEY)) WATER_MONEY, " +
"sum(if(e.ELEC_MONEY is null, 0, e.ELEC_MONEY)) ELEC_MONEY, " + "sum(if(e.ELEC_MONEY is null, 0, e.ELEC_MONEY)) ELEC_MONEY, " +
...@@ -26,7 +26,7 @@ public interface MainteDistributedRepository { ...@@ -26,7 +26,7 @@ public interface MainteDistributedRepository {
"from energy_count_m e,bus_project b " + "from energy_count_m e,bus_project b " +
"where e.PRO_ID=b.PRO_ID and e.`YEAR`=#{year} " + "where e.PRO_ID=b.PRO_ID and e.`YEAR`=#{year} " +
"<if test=\"month != null and month != ''\">and e.MON=${month} group by e.MON,b.PRO_NM</if>" + "<if test=\"month != null and month != ''\">and e.MON=${month} group by e.MON,b.PRO_NM</if>" +
"<if test=\"month == null or month == ''\">group by e.`YEAR`,b.PRO_NM</if></script>") "<if test=\"month == null or month == ''\">and e.MON &lt; ${yearMonth} group by e.`YEAR`,b.PRO_NM</if></script>")
@ResultMap(value = "EnergyDistributed") @ResultMap(value = "EnergyDistributed")
List<EnergyDistributed> queryEnergyDistributed(Params params); List<EnergyDistributed> queryEnergyDistributed(Params params);
......
...@@ -18,6 +18,7 @@ import java.math.BigDecimal; ...@@ -18,6 +18,7 @@ import java.math.BigDecimal;
@AllArgsConstructor @AllArgsConstructor
public class EnergyDistributed implements Serializable { public class EnergyDistributed implements Serializable {
private String proId;
private String proNm; private String proNm;
private String bldCoordinate; private String bldCoordinate;
private BigDecimal bldArea; private BigDecimal bldArea;
......
package org.rcisoft.business.mainte.distributed.service.impl; package org.rcisoft.business.mainte.distributed.service.impl;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.rcisoft.business.evaluate.project.dao.ProjectEvaluateRepository;
import org.rcisoft.business.mainte.distributed.dao.MainteDistributedRepository; import org.rcisoft.business.mainte.distributed.dao.MainteDistributedRepository;
import org.rcisoft.business.mainte.distributed.entity.BuildingAge; import org.rcisoft.business.mainte.distributed.entity.BuildingAge;
import org.rcisoft.business.mainte.distributed.entity.DeviceAge; import org.rcisoft.business.mainte.distributed.entity.DeviceAge;
...@@ -23,16 +24,20 @@ public class MainteDistributedServiceImpl implements MainteDistributedService { ...@@ -23,16 +24,20 @@ public class MainteDistributedServiceImpl implements MainteDistributedService {
@Autowired @Autowired
private MainteDistributedRepository mainteDistributedRepository; private MainteDistributedRepository mainteDistributedRepository;
@Autowired
private ProjectEvaluateRepository projectEvaluateRepository;
@Override @Override
public List<EnergyDistributedVo> queryEnergyDistributed(String year, String month) { public List<EnergyDistributedVo> queryEnergyDistributed(String year, String month) {
// 当月份为空,按照全年统计时,只需要统计经过的月份,未过完的月份不进行计算
int year_month = Calendar.getInstance().get(Calendar.MONTH) + 1;
List<EnergyDistributedVo> resultList = new ArrayList<>(); List<EnergyDistributedVo> resultList = new ArrayList<>();
// 如果month是空,查全年的 // 如果month是空,查全年的
/* /*
* month 如果是null 返回查找全年 * month 如果是null 返回查找全年
* month 不为null返回的月数小于当前月 * month 不为null返回的月数小于当前月
* */ * */
List<EnergyDistributed> list = mainteDistributedRepository.queryEnergyDistributed(new Params(year, month, null)); List<EnergyDistributed> list = mainteDistributedRepository.queryEnergyDistributed(new Params(year, month, null, year_month));
list.forEach(energyDistributed -> { list.forEach(energyDistributed -> {
EnergyDistributedVo vo = new EnergyDistributedVo(); EnergyDistributedVo vo = new EnergyDistributedVo();
//项目名 //项目名
...@@ -43,8 +48,14 @@ public class MainteDistributedServiceImpl implements MainteDistributedService { ...@@ -43,8 +48,14 @@ public class MainteDistributedServiceImpl implements MainteDistributedService {
value.add(Float.parseFloat(coordinate[0])); value.add(Float.parseFloat(coordinate[0]));
value.add(Float.parseFloat(coordinate[1])); value.add(Float.parseFloat(coordinate[1]));
//值 //值
// // 如果是全年的,需要查询项目的月份数量,算平均值
value.add(new BigDecimal(0).add(energyDistributed.getMoney()).setScale(2) if (StringUtils.isEmpty(month)) {
String proId = energyDistributed.getProId();
BigDecimal monthCount = projectEvaluateRepository.countMonth(proId, year_month);
value.add(energyDistributed.getMoney().divide(monthCount).setScale(2));
} else {
value.add(energyDistributed.getMoney());
}
/* value.add(new BigDecimal(0) /* value.add(new BigDecimal(0)
.add(energyDistributed.getWaterMoney()) .add(energyDistributed.getWaterMoney())
.add(energyDistributed.getElecMoney()) .add(energyDistributed.getElecMoney())
...@@ -52,7 +63,7 @@ public class MainteDistributedServiceImpl implements MainteDistributedService { ...@@ -52,7 +63,7 @@ public class MainteDistributedServiceImpl implements MainteDistributedService {
.multiply(new BigDecimal(12)) //乘以12 *GoGlic .multiply(new BigDecimal(12)) //乘以12 *GoGlic
.divide(energyDistributed.getBldArea(), 2).setScale(2)*/ .divide(energyDistributed.getBldArea(), 2).setScale(2)*/
// .divide(energyDistributed.getBldArea(), 2) // .divide(energyDistributed.getBldArea(), 2)
);
vo.setValue(value); vo.setValue(value);
//放入结果集 //放入结果集
resultList.add(vo); resultList.add(vo);
...@@ -76,7 +87,7 @@ public class MainteDistributedServiceImpl implements MainteDistributedService { ...@@ -76,7 +87,7 @@ public class MainteDistributedServiceImpl implements MainteDistributedService {
} }
System.err.println("-=-=-=-=-=-=-=-=-=-=-=-=--==-===-="+month +"-==-=-=-=-=-=-==-=-=-==-=-=-=-=-==--=-=-=-=-=-==-====--==-="); System.err.println("-=-=-=-=-=-=-=-=-=-=-=-=--==-===-="+month +"-==-=-=-=-=-=-==-=-=-==-=-=-=-=-==--=-=-=-=-=-==-====--==-=");
// List<EnergyCompared> list = mainteDistributedRepository.queryEnergyCompared(new Params(year, null, bldZoneId)); // List<EnergyCompared> list = mainteDistributedRepository.queryEnergyCompared(new Params(year, null, bldZoneId));
List<EnergyCompared> list = mainteDistributedRepository.queryEnergyCompared(new Params(year,month,bldZoneId)); List<EnergyCompared> list = mainteDistributedRepository.queryEnergyCompared(new Params(year,month,bldZoneId,null));
list.forEach(e -> { list.forEach(e -> {
String bldTPNm = e.getBldTPNm(); String bldTPNm = e.getBldTPNm();
......
...@@ -13,7 +13,9 @@ import lombok.NoArgsConstructor; ...@@ -13,7 +13,9 @@ import lombok.NoArgsConstructor;
public class Params { public class Params {
private String year; private String year;
private String month; private String month;
private String bldZoneId;
//建筑分区id //建筑分区id
private String bldZoneId;
private Integer yearMonth;
} }
...@@ -39,9 +39,10 @@ public interface ProjectRepository extends BaseMapper<BusProject> { ...@@ -39,9 +39,10 @@ public interface ProjectRepository extends BaseMapper<BusProject> {
* @return * @return
*/ */
@Select("<script>SELECT\n" + @Select("<script>SELECT\n" +
"\ta.*,e.SYS_NM,b.BLD_TP_NM,c.OWN_NM,d1.TEAM_NM TEAM_NM_ON,d2.TEAM_NM TEAM_NM_OFF," + "\ta.*,city.NAME CITY_NAME,e.SYS_NM,b.BLD_TP_NM,c.OWN_NM,d1.TEAM_NM TEAM_NM_ON,d2.TEAM_NM TEAM_NM_OFF," +
"s1.EXAMINER SAVEING_COST_NM,s2.EXAMINER SAVEING_ENERGY_NM\n" + "s1.EXAMINER SAVEING_COST_NM,s2.EXAMINER SAVEING_ENERGY_NM\n" +
"FROM bus_project a \n" + "FROM bus_project a \n" +
"left join sys_city city on city.ID=a.CITY " +
"LEFT JOIN bus_build_tp b ON a.BLD_TP_ID = b.BLD_TP_ID\n" + "LEFT JOIN bus_build_tp b ON a.BLD_TP_ID = b.BLD_TP_ID\n" +
"LEFT JOIN sys_owner c ON a.OWN_ID = c.OWN_ID\n" + "LEFT JOIN sys_owner c ON a.OWN_ID = c.OWN_ID\n" +
"LEFT JOIN bus_team d1 on a.TEAM_ID_ON = d1.TEAM_ID\n" + "LEFT JOIN bus_team d1 on a.TEAM_ID_ON = d1.TEAM_ID\n" +
......
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
LEFT JOIN bus_build_tp bbt ON bp.BLD_TP_ID = bbt.BLD_TP_ID LEFT JOIN bus_build_tp bbt ON bp.BLD_TP_ID = bbt.BLD_TP_ID
<where> <where>
<if test="year != null and year != '' "> <if test="year != null and year != '' ">
ecm.YEAR = #{year} ecm.YEAR = #{year} and ecm.MON &lt; ${month}
</if> </if>
</where> </where>
GROUP BY GROUP BY
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
<mapper namespace="org.rcisoft.business.mainte.distributed.dao.MainteDistributedRepository"> <mapper namespace="org.rcisoft.business.mainte.distributed.dao.MainteDistributedRepository">
<resultMap id="EnergyDistributed" type="org.rcisoft.business.mainte.distributed.entity.EnergyDistributed"> <resultMap id="EnergyDistributed" type="org.rcisoft.business.mainte.distributed.entity.EnergyDistributed">
<result column="PRO_ID" jdbcType="VARCHAR" property="proId"/>
<result column="PRO_NM" jdbcType="VARCHAR" property="proNm"/> <result column="PRO_NM" jdbcType="VARCHAR" property="proNm"/>
<result column="BLD_COORDINATE" jdbcType="VARCHAR" property="bldCoordinate"/> <result column="BLD_COORDINATE" jdbcType="VARCHAR" property="bldCoordinate"/>
<result column="BLD_AREA" jdbcType="DECIMAL" property="bldArea"/> <result column="BLD_AREA" jdbcType="DECIMAL" property="bldArea"/>
......
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