Commit 2d925f71 authored by jichao's avatar jichao

改bug

parent 40c29256
......@@ -17,7 +17,10 @@ public interface BusTeamRepository extends BaseMapper<BusTeam>{
@Select("<script>select a.*,count(b.TEAM_ID) as teamNumber,sum(b.BLD_AREA) as area from `bus_team` a join `bus_project` b on a.`TEAM_ID`=b.`TEAM_ID` where 1=1 <if test=\"type != null\"> and `TEAM_TYPE` = #{type}</if> GROUP BY TEAM_ID</script>")
@Select("<script>select a.*,count(1) teamNumber,sum(b.BLD_AREA) area from bus_team a,bus_project b where " +
" case when a.TEAM_TYPE = '1' then a.TEAM_ID=b.TEAM_ID_ON else a.TEAM_ID=b.TEAM_ID_OFF end" +
"<if test=\"type != null\"> and TEAM_TYPE = #{type}</if>" +
" GROUP BY a.TEAM_ID</script>")
@ResultMap(value = "BaseResultMap" )
List<BusTeam> selectByTeamId(@Param("type") String type);
......
......@@ -14,11 +14,11 @@ import java.math.BigDecimal;
@Data
@NoArgsConstructor
@AllArgsConstructor
@Table(name = "sys_principal")
@Table(name = "bus_team")
public class BusTeam implements Serializable {
@Id
private String teamId;
private String teamNm;
......
......@@ -22,7 +22,7 @@ public interface MainteDistributedRepository {
"sum(if(e.ELEC_MONEY is null, 0, e.ELEC_MONEY)) ELEC_MONEY, " +
"sum(if(e.GAS_MONEY is null, 0, e.GAS_MONEY)) GAS_MONEY " +
"from energy_count_m e,bus_project b " +
"where e.PRO_ID=b.PRO_ID and e.`YEAR`=#{year} and e.MON=#{month} " +
"where e.PRO_ID=b.PRO_ID and e.`YEAR`=#{year} and e.MON=${month} " +
"group by e.MON,b.PRO_NM</script>")
@ResultMap(value = "EnergyDistributed")
List<EnergyDistributed> queryEnergyDistributed(Params params);
......
......@@ -42,8 +42,7 @@ public class MainteDistributedServiceImpl implements MainteDistributedService {
.add(energyDistributed.getWaterMoney())
.add(energyDistributed.getElecMoney())
.add(energyDistributed.getGasMoney())
.divide(energyDistributed.getBldArea())
.setScale(1)
.divide(energyDistributed.getBldArea(), 1)
);
vo.setValue(value);
//放入结果集
......
......@@ -29,10 +29,9 @@ public interface BusDeviceFaultRepository extends BaseMapper<BusDeviceFault> {
* @param busDeviceFaultVo
* @return
*/
@Select("<script>select date_format(f.TM,'%Y-%m-%d') `DATE`,f.CONTENT,d.DEV_NM,s.SYS_NM,p.PARAM_NM " +
"from bus_device_fault f,bus_device d,bus_param p,bus_system s " +
"where f.DEV_NUM=d.DEV_NUM and d.SYS_ID=s.SYS_ID and f.P_CODE=p.PARAM " +
"and f.PRO_ID=#{proId} and date_format(f.TM,'%Y-%c')=#{date}</script>")
@Select("<script>select date_format(f.TM,'%Y-%m-%d') `DATE`,d.DEV_NM,dp.PARAM_NM,f.CONTENT from bus_device_fault f,bus_device d,bus_device_param p,bus_devicetp_param dp \n" +
"where f.DEV_NUM=d.DEV_NUM and f.DEV_NUM=p.DEV_NUM and f.P_CODE=p.PARAM and p.PARAM_CODE=dp.PARAM_CODE \n" +
"and dp.PRO_ID=#{proId} and date_format(f.TM,'%Y-%c')=#{date}</script>")
@ResultMap(value = "faultList")
List<BusDeviceFaultVo> queryFaultList(BusDeviceFaultVo busDeviceFaultVo);
}
......
......@@ -28,8 +28,8 @@ public interface EnergyCountMRepository extends BaseMapper<EnergyCountM> {
"sum(GAS) as gas,sum(GAS_MONEY) as gasMoney" +
" from ENERGY_COUNT_M e " +
"where e.PRO_ID=#{proId} and `year`=#{year}" +
"<if test=\"day != null\"> and `day`=#{day} group by e.`day`</if>" +
"<if test=\"mon != null\"> and mon=#{mon} group by e.mon</if></script>")
"<if test=\"day != null\"> and `day`=${day} group by e.`day`</if>" +
"<if test=\"mon != null\"> and mon=${mon} group by e.mon</if></script>")
@ResultMap("BaseResultMap")
EnergyCountM countAmountAndPrice(EnergyCountM energyCountM);
......@@ -43,7 +43,7 @@ public interface EnergyCountMRepository extends BaseMapper<EnergyCountM> {
"<if test=\"type == 2\">sum(e.ELEC_MONEY)</if>" +
"<if test=\"type == 3\">sum(e.GAS_MONEY)</if>" +
" as MONEY from ENERGY_COUNT_M e" +
" where e.PRO_ID=#{proId} and e.`YEAR`=#{year} and e.MON=#{mon} and e.`DAY`=#{day} group by e.`HOUR`+0 asc</script>")
" where e.PRO_ID=#{proId} and e.`YEAR`=#{year} and e.MON=${mon} and e.`DAY`=${day} group by e.`HOUR`+0 asc</script>")
@ResultMap("resultMapVo")
List<EnergyCountMVo> countDailyPrice(EnergyCountMVo energyCountMVo);
......@@ -53,7 +53,7 @@ public interface EnergyCountMRepository extends BaseMapper<EnergyCountM> {
* @return
*/
@Select("<script>select if(sum(e.WATER) is null, 0, sum(e.WATER)) ENERGY from energy_count_m e " +
"where e.`DAY`=#{day} and e.MON=#{mon} and e.`YEAR`=#{year} and e.PRO_ID=#{proId}</script>")
"where e.`DAY`=${day} and e.MON=${mon} and e.`YEAR`=#{year} and e.PRO_ID=#{proId}</script>")
@ResultMap("resultMapVo")
List<EnergyCountMVo> countEnergySplitWater(EnergyCountMVo energyCountMVo);
......@@ -67,7 +67,7 @@ public interface EnergyCountMRepository extends BaseMapper<EnergyCountM> {
"<if test=\"type == 3\">sum(e.GAS) ENERGY </if>" +
"from bus_device d,bus_device_meter dm,energy_count_m e " +
"where d.DEV_NUM=dm.DEV_NUM and dm.MET_NUM=e.MET_NUM and " +
"e.`DAY`=#{day} and e.MON=#{mon} and e.`YEAR`=#{year} and e.PRO_ID=#{proId} " +
"e.`DAY`=${day} and e.MON=${mon} and e.`YEAR`=#{year} and e.PRO_ID=#{proId} " +
"group by d.DEV_NM</script>")
@ResultMap("resultMapVo")
List<EnergyCountMVo> countEnergySplitElecGas(EnergyCountMVo energyCountMVo);
......@@ -82,7 +82,7 @@ public interface EnergyCountMRepository extends BaseMapper<EnergyCountM> {
"<if test=\"type == 1\">sum(e.WATER_MONEY)</if>" +
"<if test=\"type == 2\">sum(e.ELEC_MONEY)</if>" +
"<if test=\"type == 3\">sum(e.GAS_MONEY)</if>" +
" as MONEY from ENERGY_COUNT_M e where e.PRO_ID=#{proId} and e.`YEAR`=#{year} and e.MON=#{mon}" +
" as MONEY from ENERGY_COUNT_M e where e.PRO_ID=#{proId} and e.`YEAR`=#{year} and e.MON=${mon}" +
"<if test=\"hour != null\"> and e.HOUR &lt;= #{hour}</if>" +
" group by e.`DAY`+0 asc) a order by a.MONEY desc</script>")
@ResultMap("resultMapVo")
......@@ -97,7 +97,7 @@ public interface EnergyCountMRepository extends BaseMapper<EnergyCountM> {
"<if test=\"type == 1\">sum(e.WATER)</if>" +
"<if test=\"type == 2\">sum(e.ELEC)</if>" +
"<if test=\"type == 3\">sum(e.GAS)</if>" +
" as ENERGY from energy_count_m e where e.PRO_ID=#{proId} and e.`YEAR`=#{year} and e.MON=#{mon} group by e.`DAY`+0 asc</script>")
" as ENERGY from energy_count_m e where e.PRO_ID=#{proId} and e.`YEAR`=#{year} and e.MON=${mon} group by e.`DAY`+0 asc</script>")
@ResultMap("resultMapVo")
List<EnergyCountMVo> getEnergyCompare(EnergyCountMVo energyCountMVo);
......@@ -116,7 +116,7 @@ public interface EnergyCountMRepository extends BaseMapper<EnergyCountM> {
* @param energyCountM
* @return
*/
@Select("<script>select SUM(e.WATER) WATER,SUM(e.ELEC) ELEC,SUM(e.GAS) GAS from energy_count_m e where e.PRO_ID=#{proId} and e.`YEAR`=#{year} and e.MON=#{mon} and e.`DAY`=#{day}</script>")
@Select("<script>select SUM(e.WATER) WATER,SUM(e.ELEC) ELEC,SUM(e.GAS) GAS from energy_count_m e where e.PRO_ID=#{proId} and e.`YEAR`=#{year} and e.MON=${mon} and e.`DAY`=${day}</script>")
@ResultMap("BaseResultMap")
EnergyCountM countEnergyDay(EnergyCountM energyCountM);
......@@ -134,7 +134,7 @@ public interface EnergyCountMRepository extends BaseMapper<EnergyCountM> {
* @param energyCountMVo
* @return
*/
@Select("<script>select e.`DAY`,sum(if(e.WATER_MONEY is null,0,e.WATER_MONEY))+sum(if(e.ELEC_MONEY is null,0,e.ELEC_MONEY))+sum(if(e.GAS_MONEY is null,0,e.GAS_MONEY)) MONEY from energy_count_m e where e.PRO_ID=#{proId} and e.`YEAR`=#{year} and e.MON=#{mon} group by e.`DAY`+0 asc</script>")
@Select("<script>select e.`DAY`,sum(if(e.WATER_MONEY is null,0,e.WATER_MONEY))+sum(if(e.ELEC_MONEY is null,0,e.ELEC_MONEY))+sum(if(e.GAS_MONEY is null,0,e.GAS_MONEY)) MONEY from energy_count_m e where e.PRO_ID=#{proId} and e.`YEAR`=#{year} and e.MON=${mon} group by e.`DAY`+0 asc</script>")
@ResultMap("resultMapVo")
List<EnergyCountMVo> statEnergyPlanMonth(EnergyCountMVo energyCountMVo);
......@@ -143,7 +143,7 @@ public interface EnergyCountMRepository extends BaseMapper<EnergyCountM> {
* @param energyCountMVo
* @return
*/
@Select("<script>select e.`HOUR`,sum(if(e.WATER_MONEY is null,0,e.WATER_MONEY))+sum(if(e.ELEC_MONEY is null,0,e.ELEC_MONEY))+sum(if(e.GAS_MONEY is null,0,e.GAS_MONEY)) MONEY from energy_count_m e where e.PRO_ID=#{proId} and e.`YEAR`=#{year} and e.MON=#{mon} and e.`DAY`=#{day} group by e.`HOUR`+0 asc</script>")
@Select("<script>select e.`HOUR`,sum(if(e.WATER_MONEY is null,0,e.WATER_MONEY))+sum(if(e.ELEC_MONEY is null,0,e.ELEC_MONEY))+sum(if(e.GAS_MONEY is null,0,e.GAS_MONEY)) MONEY from energy_count_m e where e.PRO_ID=#{proId} and e.`YEAR`=#{year} and e.MON=${mon} and e.`DAY`=${day} group by e.`HOUR`+0 asc</script>")
@ResultMap("resultMapVo")
List<EnergyCountMVo> statEnergyPlanDay(EnergyCountMVo energyCountMVo);
......
......@@ -36,7 +36,9 @@ public class BusProject implements Serializable {
private String ownId;
private String teamId;
private String teamIdOn;
private String teamIdOff;
private String jwnum;
......
......@@ -347,7 +347,10 @@ public class OverViewServiceImpl implements OverViewService {
if (list.size() > 0) {
EnergyCountMVo m = list.get(0);
m.setName("水能耗");
m.setPercent("100%");
if (m.getEnergy().compareTo(new BigDecimal(0)) == 0)
m.setPercent("0%");
else
m.setPercent("100%");
}
} else {//电气统计
list = energyCountMRepository.countEnergySplitElecGas(e);
......@@ -357,7 +360,11 @@ public class OverViewServiceImpl implements OverViewService {
}
for (int i = 0; i < list.size(); i++) {
EnergyCountMVo energyCountMVo = list.get(i);
energyCountMVo.setPercent(energyCountMVo.getEnergy().divide(total).multiply(new BigDecimal(100)).setScale(1) + "%");
//如果total=0
if (total.compareTo(new BigDecimal(0)) == 0)
energyCountMVo.setPercent(total + "%");
else
energyCountMVo.setPercent(energyCountMVo.getEnergy().divide(total).multiply(new BigDecimal(100)).setScale(1) + "%");
}
}
return list;
......@@ -397,6 +404,13 @@ public class OverViewServiceImpl implements OverViewService {
String type = this.getType(busProjectArea.getType());
if(StringUtils.isNotEmpty(type)) result.put(type, busProjectArea);
}
//水电气不存在的数据,返回对象,填空值
String[] keys = new String[]{"water", "elec", "gas"};
for (String key : keys) {
if (!result.containsKey(key)) {
result.put(key, new BusProjectArea());
}
}
return result;
}
......
......@@ -17,7 +17,6 @@
<resultMap id="faultList" type="org.rcisoft.business.mainte.fault.vo.BusDeviceFaultVo">
<result column="DATE" jdbcType="VARCHAR" property="date"/>
<result column="SYS_NM" jdbcType="VARCHAR" property="sysNm"/>
<result column="DEV_NM" jdbcType="VARCHAR" property="devNm"/>
<result column="PARAM_NM" jdbcType="VARCHAR" property="paramNm"/>
<result column="CONTENT" jdbcType="VARCHAR" property="content"/>
......
......@@ -9,7 +9,8 @@
<result column="BLD_LOCAL" jdbcType="VARCHAR" property="bldLocal"/>
<result column="BLD_COORDINATE" jdbcType="VARCHAR" property="bldCoordinate"/>
<result column="OWN_ID" jdbcType="VARCHAR" property="ownId"/>
<result column="TEAM_ID" jdbcType="VARCHAR" property="teamId"/>
<result column="TEAM_ID_ON" jdbcType="VARCHAR" property="teamIdOn"/>
<result column="TEAM_ID_OFF" jdbcType="VARCHAR" property="teamIdOff"/>
<result column="JWNUM" jdbcType="VARCHAR" property="jwnum"/>
<result column="PROVINCE" jdbcType="VARCHAR" property="province"/>
<result column="CITY" jdbcType="VARCHAR" property="city"/>
......
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