commit
834a9ec5a4
@ -0,0 +1,102 @@ |
||||
package com.psdc.entity; |
||||
|
||||
import com.psdc.annotation.Excel; |
||||
import lombok.AllArgsConstructor; |
||||
import lombok.Data; |
||||
import lombok.NoArgsConstructor; |
||||
import org.springframework.stereotype.Component; |
||||
|
||||
|
||||
/** |
||||
* 每日统计表; |
||||
* @date : 2023-5-11 |
||||
*/ |
||||
@Data |
||||
@Component |
||||
@AllArgsConstructor |
||||
@NoArgsConstructor |
||||
public class PsdcStatisticsDay{ |
||||
/** 主键 */ |
||||
@Excel(name = "序号", cellType = Excel.ColumnType.NUMERIC, prompt = "序号") |
||||
private Integer dayId ; |
||||
/** 日期 */ |
||||
@Excel(name = "日期") |
||||
private String dayDate ; |
||||
/** 设备id */ |
||||
private Integer deviceId ; |
||||
/** 设备名称 */ |
||||
@Excel(name="设备名称") |
||||
private String deviceName ; |
||||
/** */ |
||||
@Excel(name = "00时") |
||||
private Double hour00 ; |
||||
/** */ |
||||
@Excel(name = "01时") |
||||
private Double hour01 ; |
||||
/** */ |
||||
@Excel(name = "02时") |
||||
private Double hour02 ; |
||||
/** */ |
||||
@Excel(name = "03时") |
||||
private Double hour03 ; |
||||
/** */ |
||||
@Excel(name = "04时") |
||||
private Double hour04 ; |
||||
/** */ |
||||
@Excel(name = "05时") |
||||
private Double hour05 ; |
||||
/** */ |
||||
@Excel(name = "06时") |
||||
private Double hour06 ; |
||||
/** */ |
||||
@Excel(name = "07时") |
||||
private Double hour07 ; |
||||
/** */ |
||||
@Excel(name = "08时") |
||||
private Double hour08 ; |
||||
/** */ |
||||
@Excel(name = "09时") |
||||
private Double hour09 ; |
||||
/** */ |
||||
@Excel(name = "10时") |
||||
private Double hour10 ; |
||||
/** */ |
||||
@Excel(name = "11时") |
||||
private Double hour11 ; |
||||
/** */ |
||||
@Excel(name = "12时") |
||||
private Double hour12 ; |
||||
/** */ |
||||
@Excel(name = "13时") |
||||
private Double hour13 ; |
||||
/** */ |
||||
@Excel(name = "14时") |
||||
private Double hour14 ; |
||||
/** */ |
||||
@Excel(name = "15时") |
||||
private Double hour15 ; |
||||
/** */ |
||||
@Excel(name = "16时") |
||||
private Double hour16 ; |
||||
/** */ |
||||
@Excel(name = "17时") |
||||
private Double hour17 ; |
||||
/** */ |
||||
@Excel(name = "18时") |
||||
private Double hour18 ; |
||||
/** */ |
||||
@Excel(name = "19时") |
||||
private Double hour19 ; |
||||
/** */ |
||||
@Excel(name = "20时") |
||||
private Double hour20 ; |
||||
/** */ |
||||
@Excel(name = "21时") |
||||
private Double hour21 ; |
||||
/** */ |
||||
@Excel(name = "22时") |
||||
private Double hour22 ; |
||||
/** */ |
||||
@Excel(name = "23时") |
||||
private Double hour23 ; |
||||
} |
@ -0,0 +1,125 @@ |
||||
package com.psdc.entity; |
||||
|
||||
|
||||
import com.psdc.annotation.Excel; |
||||
import lombok.AllArgsConstructor; |
||||
import lombok.Data; |
||||
import lombok.NoArgsConstructor; |
||||
import org.springframework.stereotype.Component; |
||||
|
||||
|
||||
/** |
||||
* 每月统计表; |
||||
* @date : 2023-5-11 |
||||
*/ |
||||
@Data |
||||
@Component |
||||
@AllArgsConstructor |
||||
@NoArgsConstructor |
||||
public class PsdcStatisticsMonth { |
||||
/** id */ |
||||
@Excel(name = "序号", cellType = Excel.ColumnType.NUMERIC, prompt = "序号") |
||||
private Integer monthId ; |
||||
/** 设备id */ |
||||
private Integer deviceId ; |
||||
/** 设备名称 */ |
||||
@Excel(name="设备名称") |
||||
private String deviceName ; |
||||
/** 月 */ |
||||
@Excel(name = "日期") |
||||
private String monthDate ; |
||||
/** 第1日电量 */ |
||||
@Excel(name="01日") |
||||
private Double day01 ; |
||||
/** 第2日电量 */ |
||||
@Excel(name="02日") |
||||
private Double day02 ; |
||||
/** 第3日电量 */ |
||||
@Excel(name="03日") |
||||
private Double day03 ; |
||||
/** 第4日电量 */ |
||||
@Excel(name="04日") |
||||
private Double day04 ; |
||||
/** 第5日电量 */ |
||||
@Excel(name="05日") |
||||
private Double day05 ; |
||||
/** 第6日电量 */ |
||||
@Excel(name="06日") |
||||
private Double day06 ; |
||||
/** 第7日电量 */ |
||||
@Excel(name="07日") |
||||
private Double day07 ; |
||||
/** 第8日电量 */ |
||||
@Excel(name="08日") |
||||
private Double day08 ; |
||||
/** 第9日电量 */ |
||||
@Excel(name="09日") |
||||
private Double day09 ; |
||||
/** 第10日电量 */ |
||||
@Excel(name="10日") |
||||
private Double day10 ; |
||||
/** 第11日电量 */ |
||||
@Excel(name="11日") |
||||
private Double day11 ; |
||||
/** 第12日电量 */ |
||||
@Excel(name="12日") |
||||
private Double day12 ; |
||||
/** 第13日电量 */ |
||||
@Excel(name="13日") |
||||
private Double day13 ; |
||||
/** 第14日电量 */ |
||||
@Excel(name="14日") |
||||
private Double day14 ; |
||||
/** 第15日电量 */ |
||||
@Excel(name="15日") |
||||
private Double day15 ; |
||||
/** 第16日电量 */ |
||||
@Excel(name="16日") |
||||
private Double day16 ; |
||||
/** */ |
||||
@Excel(name="17日") |
||||
private Double day17 ; |
||||
/** 第18日电量 */ |
||||
@Excel(name="18日") |
||||
private Double day18 ; |
||||
/** 第19日电量 */ |
||||
@Excel(name="19日") |
||||
private Double day19 ; |
||||
/** 第20日电量 */ |
||||
@Excel(name="20日") |
||||
private Double day20 ; |
||||
/** 第21日电量 */ |
||||
@Excel(name="21日") |
||||
private Double day21 ; |
||||
/** 第22日电量 */ |
||||
@Excel(name="22日") |
||||
private Double day22 ; |
||||
/** 第23日电量 */ |
||||
@Excel(name="23日") |
||||
private Double day23 ; |
||||
/** 第24日电量 */ |
||||
@Excel(name="24日") |
||||
private Double day24 ; |
||||
/** 第25日电量 */ |
||||
@Excel(name="25日") |
||||
private Double day25 ; |
||||
/** 第26日电量 */ |
||||
@Excel(name="26日") |
||||
private Double day26 ; |
||||
/** 第27日电量 */ |
||||
@Excel(name="27日") |
||||
private Double day27 ; |
||||
/** 第28日电量 */ |
||||
@Excel(name="28日") |
||||
private Double day28 ; |
||||
/** 第29日电量 */ |
||||
@Excel(name="29日") |
||||
private Double day29 ; |
||||
/** 第30日电量 */ |
||||
@Excel(name="30日") |
||||
private Double day30 ; |
||||
/** */ |
||||
@Excel(name="31日") |
||||
private Double day31 ; |
||||
|
||||
} |
@ -0,0 +1,68 @@ |
||||
package com.psdc.entity; |
||||
|
||||
import com.psdc.annotation.Excel; |
||||
import lombok.AllArgsConstructor; |
||||
import lombok.Data; |
||||
import lombok.NoArgsConstructor; |
||||
import org.springframework.stereotype.Component; |
||||
|
||||
|
||||
|
||||
/** |
||||
* 每年数据; |
||||
* @date : 2023-5-11 |
||||
*/ |
||||
@Data |
||||
@Component |
||||
@AllArgsConstructor |
||||
@NoArgsConstructor |
||||
public class PsdcStatisticsYear { |
||||
/** id */ |
||||
@Excel(name = "序号", cellType = Excel.ColumnType.NUMERIC, prompt = "序号") |
||||
private Integer yearId ; |
||||
/** 设备id */ |
||||
private Integer deviceId ; |
||||
/** 设备名称 */ |
||||
@Excel(name="设备名称") |
||||
private String deviceName ; |
||||
/** 年份 */ |
||||
@Excel(name = "日期") |
||||
private String yearDate ; |
||||
/** 第1月电量 */ |
||||
@Excel(name = "一月") |
||||
private Double month01 ; |
||||
/** 第2月电量 */ |
||||
@Excel(name = "二月") |
||||
private Double month02 ; |
||||
/** 第3月电量 */ |
||||
@Excel(name = "三月") |
||||
private Double month03 ; |
||||
/** 第4月电量 */ |
||||
@Excel(name = "四月") |
||||
private Double month04 ; |
||||
/** 第5月电量 */ |
||||
@Excel(name = "五月") |
||||
private Double month05 ; |
||||
/** 第6月电量 */ |
||||
@Excel(name = "六月") |
||||
private Double month06 ; |
||||
/** 第7月电量 */ |
||||
@Excel(name = "七月") |
||||
private Double month07 ; |
||||
/** 第8月电量 */ |
||||
@Excel(name = "八月") |
||||
private Double month08 ; |
||||
/** 第9月电量 */ |
||||
@Excel(name = "九月") |
||||
private Double month09 ; |
||||
/** 第10月电量 */ |
||||
@Excel(name = "十月") |
||||
private Double month10 ; |
||||
/** 第11月电量 */ |
||||
@Excel(name = "十一月") |
||||
private Double month11 ; |
||||
/** 第12月电量 */ |
||||
@Excel(name = "十二月") |
||||
private Double month12 ; |
||||
|
||||
} |
@ -0,0 +1,34 @@ |
||||
package com.psdc.entity.request; |
||||
|
||||
import lombok.AllArgsConstructor; |
||||
import lombok.Data; |
||||
import lombok.NoArgsConstructor; |
||||
|
||||
@Data |
||||
@AllArgsConstructor |
||||
@NoArgsConstructor |
||||
public class EnergyStatisticsRequest { |
||||
|
||||
/** |
||||
* 设备id |
||||
*/ |
||||
private Integer deviceId; |
||||
|
||||
/** |
||||
* 时间类型,1日2月3年 |
||||
*/ |
||||
private Integer timeType; |
||||
|
||||
/** |
||||
* 开始时间 |
||||
*/ |
||||
private String startTime; |
||||
|
||||
/** |
||||
* 结束时间 |
||||
*/ |
||||
private String endTime; |
||||
|
||||
|
||||
|
||||
} |
@ -0,0 +1,64 @@ |
||||
package com.psdc.mapper; |
||||
|
||||
import java.util.List; |
||||
|
||||
import com.psdc.entity.PsdcStatisticsDay; |
||||
import com.psdc.entity.request.EnergyStatisticsRequest; |
||||
import org.apache.ibatis.annotations.Mapper; |
||||
import org.apache.ibatis.annotations.Param; |
||||
import org.springframework.data.domain.Pageable; |
||||
|
||||
|
||||
/** |
||||
* 每日统计表;(psdc_statistics_day)表数据库访问层 |
||||
* @date : 2023-5-11 |
||||
*/ |
||||
@Mapper |
||||
public interface PsdcStatisticsDayMapper{ |
||||
/** |
||||
* 通过ID查询单条数据 |
||||
* |
||||
* @param statisticsId 主键 |
||||
* @return 实例对象 |
||||
*/ |
||||
PsdcStatisticsDay queryById(Integer statisticsId); |
||||
/** |
||||
* 分页查询指定行数据 |
||||
* |
||||
* @param psdcStatisticsDay 查询条件 |
||||
* @param pageable 分页对象 |
||||
* @return 对象列表 |
||||
*/ |
||||
List<PsdcStatisticsDay> queryAllByLimit(EnergyStatisticsRequest energyStatisticsRequest); |
||||
|
||||
/** |
||||
* 新增数据 |
||||
* |
||||
* @param psdcStatisticsDay 实例对象 |
||||
* @return 影响行数 |
||||
*/ |
||||
int insert(PsdcStatisticsDay psdcStatisticsDay); |
||||
|
||||
/** |
||||
* 新增数据 |
||||
* |
||||
* @param psdcStatisticsDay 实例对象 |
||||
* @return 影响行数 |
||||
*/ |
||||
int insertDay(PsdcStatisticsDay psdcStatisticsDay); |
||||
|
||||
/** |
||||
* 更新数据 |
||||
* |
||||
* @param psdcStatisticsDay 实例对象 |
||||
* @return 影响行数 |
||||
*/ |
||||
int update(PsdcStatisticsDay psdcStatisticsDay); |
||||
/** |
||||
* 通过主键删除数据 |
||||
* |
||||
* @param statisticsId 主键 |
||||
* @return 影响行数 |
||||
*/ |
||||
int deleteById(Integer statisticsId); |
||||
} |
@ -0,0 +1,91 @@ |
||||
package com.psdc.mapper; |
||||
|
||||
import java.util.List; |
||||
|
||||
import com.psdc.entity.PsdcStatisticsMonth; |
||||
import com.psdc.entity.request.EnergyStatisticsRequest; |
||||
import org.apache.ibatis.annotations.Mapper; |
||||
import org.apache.ibatis.annotations.Param; |
||||
import org.springframework.data.domain.Pageable; |
||||
import org.springframework.security.core.parameters.P; |
||||
|
||||
|
||||
/** |
||||
* 每月统计表;(psdc_statistics_month)表数据库访问层 |
||||
* @date : 2023-5-11 |
||||
*/ |
||||
@Mapper |
||||
public interface PsdcStatisticsMonthMapper{ |
||||
/** |
||||
* 通过ID查询单条数据 |
||||
* |
||||
* @param monthId 主键 |
||||
* @return 实例对象 |
||||
*/ |
||||
PsdcStatisticsMonth queryById(Integer monthId); |
||||
/** |
||||
* 分页查询指定行数据 |
||||
* |
||||
* @param psdcStatisticsMonth 查询条件 |
||||
* @param pageable 分页对象 |
||||
* @return 对象列表 |
||||
*/ |
||||
List<PsdcStatisticsMonth> queryAllByLimit(EnergyStatisticsRequest energyStatisticsRequest); |
||||
/** |
||||
* 新增数据 |
||||
* |
||||
* @param psdcStatisticsMonth 实例对象 |
||||
* @return 影响行数 |
||||
*/ |
||||
int insert(PsdcStatisticsMonth psdcStatisticsMonth); |
||||
/** |
||||
* 新增数据 |
||||
* |
||||
* @param psdcStatisticsMonth 实例对象 |
||||
* @return 影响行数 |
||||
*/ |
||||
int insertMonth(PsdcStatisticsMonth psdcStatisticsMonth); |
||||
/** |
||||
* 更新数据 |
||||
* |
||||
* @param psdcStatisticsMonth 实例对象 |
||||
* @return 影响行数 |
||||
*/ |
||||
int update(PsdcStatisticsMonth psdcStatisticsMonth); |
||||
|
||||
/** |
||||
* 更新固定点位数据 |
||||
* @param monthPoint 点位 |
||||
* @param value 值 |
||||
* @param monthId 月id |
||||
* @return 条数 |
||||
*/ |
||||
int updatePoint(@Param("monthPoint") String monthPoint, |
||||
@Param("value") Double value, |
||||
@Param("monthId") Integer monthId); |
||||
/** |
||||
* 通过主键删除数据 |
||||
* |
||||
* @param monthId 主键 |
||||
* @return 影响行数 |
||||
*/ |
||||
int deleteById(Integer monthId); |
||||
|
||||
/** |
||||
* 根据设备id和日期查询 |
||||
* @param deviceId 设备id |
||||
* @param date 日期 |
||||
* @return 对象 |
||||
*/ |
||||
PsdcStatisticsMonth queryByDeviceIdAndDate(@Param("deviceId") Integer deviceId, |
||||
@Param("date") String date); |
||||
|
||||
/** |
||||
* 计算一行数据总和 |
||||
* @param deviceId 设备id |
||||
* @param date 日期 |
||||
* @return 总和 |
||||
*/ |
||||
Double queryOneLineSum(@Param("deviceId") Integer deviceId, |
||||
@Param("date") String date); |
||||
} |
@ -0,0 +1,85 @@ |
||||
package com.psdc.mapper; |
||||
|
||||
import java.util.List; |
||||
|
||||
import com.psdc.entity.PsdcStatisticsMonth; |
||||
import com.psdc.entity.PsdcStatisticsYear; |
||||
import com.psdc.entity.request.EnergyStatisticsRequest; |
||||
import org.apache.ibatis.annotations.Mapper; |
||||
import org.apache.ibatis.annotations.Param; |
||||
import org.springframework.data.domain.Pageable; |
||||
|
||||
|
||||
/** |
||||
* 每年数据;(psdc_statistics_year)表数据库访问层 |
||||
* @date : 2023-5-11 |
||||
*/ |
||||
@Mapper |
||||
public interface PsdcStatisticsYearMapper{ |
||||
/** |
||||
* 通过ID查询单条数据 |
||||
* |
||||
* @param yearId 主键 |
||||
* @return 实例对象 |
||||
*/ |
||||
PsdcStatisticsYear queryById(Integer yearId); |
||||
/** |
||||
* 分页查询指定行数据 |
||||
* |
||||
* @param psdcStatisticsYear 查询条件 |
||||
* @param pageable 分页对象 |
||||
* @return 对象列表 |
||||
*/ |
||||
List<PsdcStatisticsYear> queryAllByLimit(EnergyStatisticsRequest energyStatisticsRequest); |
||||
|
||||
/** |
||||
* 新增数据 |
||||
* |
||||
* @param psdcStatisticsYear 实例对象 |
||||
* @return 影响行数 |
||||
*/ |
||||
int insert(PsdcStatisticsYear psdcStatisticsYear); |
||||
/** |
||||
* 新增数据 |
||||
* |
||||
* @param psdcStatisticsYear 实例对象 |
||||
* @return 影响行数 |
||||
*/ |
||||
int insertYear(PsdcStatisticsYear psdcStatisticsYear); |
||||
|
||||
/** |
||||
* 更新数据 |
||||
* |
||||
* @param psdcStatisticsYear 实例对象 |
||||
* @return 影响行数 |
||||
*/ |
||||
int update(PsdcStatisticsYear psdcStatisticsYear); |
||||
|
||||
|
||||
/** |
||||
* 更新固定点位数据 |
||||
* @param yearPoint 点位 |
||||
* @param value 值 |
||||
* @param yearId 年id |
||||
* @return 条数 |
||||
*/ |
||||
int updatePoint(@Param("yearPoint") String yearPoint, |
||||
@Param("value") Double value, |
||||
@Param("yearId") Integer yearId); |
||||
/** |
||||
* 通过主键删除数据 |
||||
* |
||||
* @param yearId 主键 |
||||
* @return 影响行数 |
||||
*/ |
||||
int deleteById(Integer yearId); |
||||
|
||||
/** |
||||
* 根据设备id和日期查询 |
||||
* @param deviceId |
||||
* @param date |
||||
* @return |
||||
*/ |
||||
PsdcStatisticsYear queryByDeviceIdAndDate(@Param("deviceId") Integer deviceId, |
||||
@Param("date") String date); |
||||
} |
@ -0,0 +1,223 @@ |
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
||||
<mapper namespace="com.psdc.mapper.PsdcStatisticsDayMapper"> |
||||
<resultMap type="com.psdc.entity.PsdcStatisticsDay" id="PsdcStatisticsDayMap"> |
||||
<result property="dayId" column="day_id" /> |
||||
<result property="dayDate" column="day_date" /> |
||||
<result property="deviceId" column="device_id" /> |
||||
<result property="deviceName" column="device_name" /> |
||||
<result property="hour00" column="hour_00" /> |
||||
<result property="hour01" column="hour_01" /> |
||||
<result property="hour02" column="hour_02" /> |
||||
<result property="hour03" column="hour_03" /> |
||||
<result property="hour04" column="hour_04" /> |
||||
<result property="hour05" column="hour_05" /> |
||||
<result property="hour06" column="hour_06" /> |
||||
<result property="hour07" column="hour_07" /> |
||||
<result property="hour08" column="hour_08" /> |
||||
<result property="hour09" column="hour_09" /> |
||||
<result property="hour10" column="hour_10" /> |
||||
<result property="hour11" column="hour_11" /> |
||||
<result property="hour12" column="hour_12" /> |
||||
<result property="hour13" column="hour_13" /> |
||||
<result property="hour14" column="hour_14" /> |
||||
<result property="hour15" column="hour_15" /> |
||||
<result property="hour16" column="hour_16" /> |
||||
<result property="hour17" column="hour_17" /> |
||||
<result property="hour18" column="hour_18" /> |
||||
<result property="hour19" column="hour_19" /> |
||||
<result property="hour20" column="hour_20" /> |
||||
<result property="hour21" column="hour_21" /> |
||||
<result property="hour22" column="hour_22" /> |
||||
<result property="hour23" column="hour_23" /> |
||||
</resultMap> |
||||
|
||||
<!-- 通过ID查询单条数据 --> |
||||
<select id="queryById" resultMap="PsdcStatisticsDayMap"> |
||||
select |
||||
day_id,day_date,device_id,device_name,hour_00,hour_01,hour_02,hour_03,hour_04,hour_05,hour_06,hour_07,hour_08,hour_09,hour_10,hour_11,hour_12,hour_13,hour_14,hour_15,hour_16,hour_17,hour_18,hour_19,hour_20,hour_21,hour_22,hour_23 |
||||
from psdc_statistics_day |
||||
where day_id = #{dayId} |
||||
</select> |
||||
|
||||
<!--分页查询指定行数据--> |
||||
<select id="queryAllByLimit" resultMap="PsdcStatisticsDayMap"> |
||||
select |
||||
day_id,day_date,device_id,device_name,hour_00,hour_01,hour_02,hour_03,hour_04,hour_05,hour_06,hour_07,hour_08,hour_09,hour_10,hour_11,hour_12,hour_13,hour_14,hour_15,hour_16,hour_17,hour_18,hour_19,hour_20,hour_21,hour_22,hour_23 |
||||
from psdc_statistics_day |
||||
<where> |
||||
<if test="deviceId != null and deviceId != ''"> |
||||
and device_id = #{deviceId} |
||||
</if> |
||||
<if test="startTime != null and startTime != ''"><!-- 开始时间检索 --> |
||||
AND date_format(day_date,'%Y-%m-%d') >= #{startTime} |
||||
</if> |
||||
<if test="endTime != null and endTime != ''"><!-- 结束时间检索 --> |
||||
AND date_format(day_date,'%Y-%m-%d') <= #{endTime} |
||||
</if> |
||||
</where> |
||||
</select> |
||||
|
||||
|
||||
<!--新增数据--> |
||||
<insert id="insert" > |
||||
insert into psdc_statistics_day(day_id,day_date,device_id,device_name,hour_00,hour_01,hour_02,hour_03,hour_04,hour_05,hour_06,hour_07,hour_08,hour_09,hour_10,hour_11,hour_12,hour_13,hour_14,hour_15,hour_16,hour_17,hour_18,hour_19,hour_20,hour_21,hour_22,hour_23) |
||||
values (#{dayId},#{dayDate},#{deviceId},#{deviceName},#{hour00},#{hour01},#{hour02},#{hour03},#{hour04},#{hour05},#{hour06},#{hour07},#{hour08},#{hour09},#{hour10},#{hour11},#{hour12},#{hour13},#{hour14},#{hour15},#{hour16},#{hour17},#{hour18},#{hour19},#{hour20},#{hour21},#{hour22},#{hour23}) |
||||
</insert> |
||||
|
||||
|
||||
<insert id="insertDay" > |
||||
Insert into psdc_statistics_day( |
||||
day_date, |
||||
device_id, |
||||
device_name |
||||
<if test="hour00 != null and hour00 != 0">,hour_00,</if> |
||||
<if test="hour01 != null and hour01 != 0">hour_01,</if> |
||||
<if test="hour02 != null and hour02 != 0">hour_02,</if> |
||||
<if test="hour03 != null and hour03 != 0">hour_03,</if> |
||||
<if test="hour04 != null and hour04 != 0">hour_04,</if> |
||||
<if test="hour05 != null and hour05 != 0">hour_05,</if> |
||||
<if test="hour06 != null and hour06 != 0">hour_06,</if> |
||||
<if test="hour07 != null and hour07 != 0">hour_07,</if> |
||||
<if test="hour08 != null and hour08 != 0">hour_08,</if> |
||||
<if test="hour09 != null and hour09 != 0">hour_09,</if> |
||||
<if test="hour10 != null and hour10 != 0">hour_10,</if> |
||||
<if test="hour11 != null and hour11 != 0">hour_11,</if> |
||||
<if test="hour12 != null and hour12 != 0">hour_12,</if> |
||||
<if test="hour13 != null and hour13 != 0">hour_13,</if> |
||||
<if test="hour14 != null and hour14 != 0">hour_14,</if> |
||||
<if test="hour15 != null and hour15 != 0">hour_15,</if> |
||||
<if test="hour16 != null and hour16 != 0">hour_16,</if> |
||||
<if test="hour17 != null and hour17 != 0">hour_17,</if> |
||||
<if test="hour18 != null and hour18 != 0">hour_18,</if> |
||||
<if test="hour19 != null and hour19 != 0">hour_19,</if> |
||||
<if test="hour20 != null and hour20 != 0">hour_20,</if> |
||||
<if test="hour21 != null and hour21 != 0">hour_21,</if> |
||||
<if test="hour22 != null and hour22 != 0">hour_22,</if> |
||||
<if test="hour23 != null and hour23 != 0">hour_23,</if> |
||||
)values( |
||||
#{dayDate}, |
||||
#{deviceId}, |
||||
#{deviceName} |
||||
<if test="hour00 != null and hour00 != 0">,#{hour00},</if> |
||||
<if test="hour01 != null and hour01 != 0">#{hour01},</if> |
||||
<if test="hour02 != null and hour02 != 0">#{hour02},</if> |
||||
<if test="hour03 != null and hour03 != 0">#{hour03},</if> |
||||
<if test="hour04 != null and hour04 != 0">#{hour04},</if> |
||||
<if test="hour05 != null and hour05 != 0">#{hour05},</if> |
||||
<if test="hour06 != null and hour06 != 0">#{hour06},</if> |
||||
<if test="hour07 != null and hour07 != 0">#{hour07},</if> |
||||
<if test="hour08 != null and hour08 != 0">#{hour08},</if> |
||||
<if test="hour09 != null and hour09 != 0">#{hour09},</if> |
||||
<if test="hour10 != null and hour10 != 0">#{hour10},</if> |
||||
<if test="hour11 != null and hour11 != 0">#{hour11},</if> |
||||
<if test="hour12 != null and hour12 != 0">#{hour12},</if> |
||||
<if test="hour13 != null and hour13 != 0">#{hour13},</if> |
||||
<if test="hour14 != null and hour14 != 0">#{hour14},</if> |
||||
<if test="hour15 != null and hour15 != 0">#{hour15},</if> |
||||
<if test="hour16 != null and hour16 != 0">#{hour16},</if> |
||||
<if test="hour17 != null and hour17 != 0">#{hour17},</if> |
||||
<if test="hour18 != null and hour18 != 0">#{hour18},</if> |
||||
<if test="hour19 != null and hour19 != 0">#{hour19},</if> |
||||
<if test="hour20 != null and hour20 != 0">#{hour20},</if> |
||||
<if test="hour21 != null and hour21 != 0">#{hour21},</if> |
||||
<if test="hour22 != null and hour22 != 0">#{hour22},</if> |
||||
<if test="hour23 != null and hour23 != 0">#{hour23},</if> |
||||
) |
||||
</insert> |
||||
|
||||
|
||||
<!-- 更新数据 --> |
||||
<update id="update"> |
||||
update psdc_statistics_day |
||||
<set> |
||||
<if test="day_date != null and day_date != ''"> |
||||
day_date = #{dayDate}, |
||||
</if> |
||||
<if test="deviceId != null and deviceId != ''"> |
||||
device_id = #{deviceId}, |
||||
</if> |
||||
<if test="deviceName != null and deviceName != ''"> |
||||
device_name = #{deviceName}, |
||||
</if> |
||||
<if test="hour00 != null and hour00 != ''"> |
||||
hour_00 = #{hour00}, |
||||
</if> |
||||
<if test="hour01 != null and hour01 != ''"> |
||||
hour_01 = #{hour01}, |
||||
</if> |
||||
<if test="hour02 != null and hour02 != ''"> |
||||
hour_02 = #{hour02}, |
||||
</if> |
||||
<if test="hour03 != null and hour03 != ''"> |
||||
hour_03 = #{hour03}, |
||||
</if> |
||||
<if test="hour04 != null and hour04 != ''"> |
||||
hour_04 = #{hour04}, |
||||
</if> |
||||
<if test="hour05 != null and hour05 != ''"> |
||||
hour_05 = #{hour05}, |
||||
</if> |
||||
<if test="hour06 != null and hour06 != ''"> |
||||
hour_06 = #{hour06}, |
||||
</if> |
||||
<if test="hour07 != null and hour07 != ''"> |
||||
hour_07 = #{hour07}, |
||||
</if> |
||||
<if test="hour08 != null and hour08 != ''"> |
||||
hour_08 = #{hour08}, |
||||
</if> |
||||
<if test="hour09 != null and hour09 != ''"> |
||||
hour_09 = #{hour09}, |
||||
</if> |
||||
<if test="hour10 != null and hour10 != ''"> |
||||
hour_10 = #{hour10}, |
||||
</if> |
||||
<if test="hour11 != null and hour11 != ''"> |
||||
hour_11 = #{hour11}, |
||||
</if> |
||||
<if test="hour12 != null and hour12 != ''"> |
||||
hour_12 = #{hour12}, |
||||
</if> |
||||
<if test="hour13 != null and hour13 != ''"> |
||||
hour_13 = #{hour13}, |
||||
</if> |
||||
<if test="hour14 != null and hour14 != ''"> |
||||
hour_14 = #{hour14}, |
||||
</if> |
||||
<if test="hour15 != null and hour15 != ''"> |
||||
hour_15 = #{hour15}, |
||||
</if> |
||||
<if test="hour16 != null and hour16 != ''"> |
||||
hour_16 = #{hour16}, |
||||
</if> |
||||
<if test="hour17 != null and hour17 != ''"> |
||||
hour_17 = #{hour17}, |
||||
</if> |
||||
<if test="hour18 != null and hour18 != ''"> |
||||
hour_18 = #{hour18}, |
||||
</if> |
||||
<if test="hour19 != null and hour19 != ''"> |
||||
hour_19 = #{hour19}, |
||||
</if> |
||||
<if test="hour20 != null and hour20 != ''"> |
||||
hour_20 = #{hour20}, |
||||
</if> |
||||
<if test="hour21 != null and hour21 != ''"> |
||||
hour_21 = #{hour21}, |
||||
</if> |
||||
<if test="hour22 != null and hour22 != ''"> |
||||
hour_22 = #{hour22}, |
||||
</if> |
||||
<if test="hour23 != null and hour23 != ''"> |
||||
hour_23 = #{hour23}, |
||||
</if> |
||||
</set> |
||||
where day_id = #{dayId} |
||||
</update> |
||||
|
||||
<!--通过主键删除--> |
||||
<delete id="deleteById"> |
||||
delete from psdc_statistics_day where day_id = #{dayId} |
||||
</delete> |
||||
</mapper> |
@ -0,0 +1,332 @@ |
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
||||
<mapper namespace="com.psdc.mapper.PsdcStatisticsMonthMapper"> |
||||
<resultMap type="com.psdc.entity.PsdcStatisticsMonth" id="PsdcStatisticsMonthMap"> |
||||
<result property="monthId" column="month_id"/> |
||||
<result property="deviceId" column="device_id"/> |
||||
<result property="deviceName" column="device_name"/> |
||||
<result property="monthDate" column="month_date"/> |
||||
<result property="day01" column="day_01"/> |
||||
<result property="day02" column="day_02"/> |
||||
<result property="day03" column="day_03"/> |
||||
<result property="day04" column="day_04"/> |
||||
<result property="day05" column="day_05"/> |
||||
<result property="day06" column="day_06"/> |
||||
<result property="day07" column="day_07"/> |
||||
<result property="day08" column="day_08"/> |
||||
<result property="day09" column="day_09"/> |
||||
<result property="day10" column="day_10"/> |
||||
<result property="day11" column="day_11"/> |
||||
<result property="day12" column="day_12"/> |
||||
<result property="day13" column="day_13"/> |
||||
<result property="day14" column="day_14"/> |
||||
<result property="day15" column="day_15"/> |
||||
<result property="day16" column="day_16"/> |
||||
<result property="day17" column="day_17"/> |
||||
<result property="day18" column="day_18"/> |
||||
<result property="day19" column="day_19"/> |
||||
<result property="day20" column="day_20"/> |
||||
<result property="day21" column="day_21"/> |
||||
<result property="day22" column="day_22"/> |
||||
<result property="day23" column="day_23"/> |
||||
<result property="day24" column="day_24"/> |
||||
<result property="day25" column="day_25"/> |
||||
<result property="day26" column="day_26"/> |
||||
<result property="day27" column="day_27"/> |
||||
<result property="day28" column="day_28"/> |
||||
<result property="day29" column="day_29"/> |
||||
<result property="day30" column="day_30"/> |
||||
<result property="day31" column="day_31"/> |
||||
</resultMap> |
||||
|
||||
<!-- 通过ID查询单条数据 --> |
||||
<select id="queryById" resultMap="PsdcStatisticsMonthMap"> |
||||
select month_id, |
||||
device_id, |
||||
device_name, |
||||
month_date, |
||||
day_01, |
||||
day_02, |
||||
day_03, |
||||
day_04, |
||||
day_05, |
||||
day_06, |
||||
day_07, |
||||
day_08, |
||||
day_09, |
||||
day_10, |
||||
day_11, |
||||
day_12, |
||||
day_13, |
||||
day_14, |
||||
day_15, |
||||
day_16, |
||||
day_17, |
||||
day_18, |
||||
day_19, |
||||
day_20, |
||||
day_21, |
||||
day_22, |
||||
day_23, |
||||
day_24, |
||||
day_25, |
||||
day_26, |
||||
day_27, |
||||
day_28, |
||||
day_29, |
||||
day_30, |
||||
day_31 |
||||
from psdc_statistics_month |
||||
where month_id = #{monthId} |
||||
</select> |
||||
|
||||
<!--分页查询指定行数据--> |
||||
<select id="queryAllByLimit" resultMap="PsdcStatisticsMonthMap"> |
||||
select |
||||
month_id,device_id,device_name,month_date,day_01,day_02,day_03,day_04,day_05,day_06,day_07,day_08,day_09,day_10,day_11,day_12,day_13,day_14,day_15,day_16,day_17,day_18,day_19,day_20,day_21,day_22,day_23,day_24,day_25,day_26,day_27,day_28,day_29,day_30,day_31 |
||||
from psdc_statistics_month |
||||
<where> |
||||
<if test="deviceId != null and deviceId != ''"> |
||||
and device_id = #{deviceId} |
||||
</if> |
||||
<!-- 开始时间检索 --> |
||||
<if test="startTime != null and startTime != ''"> |
||||
AND date_format(monthDate,'%Y-%m') >= #{startTime} |
||||
</if> |
||||
<!-- 结束时间检索 --> |
||||
<if test="endTime != null and endTime != ''"> |
||||
AND date_format(monthDate,'%Y-%m') <= #{endTime} |
||||
</if> |
||||
</where> |
||||
</select> |
||||
|
||||
<insert id="insertMonth"> |
||||
Insert into psdc_statistics_month( |
||||
month_date, |
||||
device_id, |
||||
device_name |
||||
<if test="day01 != null and day01 != 0">,day_01,</if> |
||||
<if test="day02 != null and day02 != 0">day_02,</if> |
||||
<if test="day03 != null and day03 != 0">day_03,</if> |
||||
<if test="day04 != null and day04 != 0">day_04,</if> |
||||
<if test="day05 != null and day05 != 0">day_05,</if> |
||||
<if test="day06 != null and day06 != 0">day_06,</if> |
||||
<if test="day07 != null and day07 != 0">day_07,</if> |
||||
<if test="day08 != null and day08 != 0">day_08,</if> |
||||
<if test="day09 != null and day09 != 0">day_09,</if> |
||||
<if test="day10 != null and day10 != 0">day_10,</if> |
||||
<if test="day11 != null and day11 != 0">day_11,</if> |
||||
<if test="day12 != null and day12 != 0">day_12,</if> |
||||
<if test="day13 != null and day13 != 0">day_13,</if> |
||||
<if test="day14 != null and day14 != 0">day_14,</if> |
||||
<if test="day15 != null and day15 != 0">day_15,</if> |
||||
<if test="day16 != null and day16 != 0">day_16,</if> |
||||
<if test="day17 != null and day17 != 0">day_17,</if> |
||||
<if test="day18 != null and day18 != 0">day_18,</if> |
||||
<if test="day19 != null and day19 != 0">day_19,</if> |
||||
<if test="day20 != null and day20 != 0">day_20,</if> |
||||
<if test="day21 != null and day21 != 0">day_21,</if> |
||||
<if test="day22 != null and day22 != 0">day_22,</if> |
||||
<if test="day23 != null and day23 != 0">day_23,</if> |
||||
<if test="day24 != null and day24 != 0">day_24,</if> |
||||
<if test="day25 != null and day25 != 0">day_25,</if> |
||||
<if test="day26 != null and day26 != 0">day_26,</if> |
||||
<if test="day27 != null and day27 != 0">day_27,</if> |
||||
<if test="day28 != null and day28 != 0">day_28,</if> |
||||
<if test="day29 != null and day29 != 0">day_29,</if> |
||||
<if test="day30 != null and day30 != 0">day_30,</if> |
||||
<if test="day31 != null and day31 != 0">day_31,</if> |
||||
)values( |
||||
#{monthDate}, |
||||
#{deviceId}, |
||||
#{deviceName} |
||||
<if test="day01 != null and day01 != 0">,#{day01},</if> |
||||
<if test="day02 != null and day02 != 0">#{day02},</if> |
||||
<if test="day03 != null and day03 != 0">#{day03},</if> |
||||
<if test="day04 != null and day04 != 0">#{day04},</if> |
||||
<if test="day05 != null and day05 != 0">#{day05},</if> |
||||
<if test="day06 != null and day06 != 0">#{day06},</if> |
||||
<if test="day07 != null and day07 != 0">#{day07},</if> |
||||
<if test="day08 != null and day08 != 0">#{day08},</if> |
||||
<if test="day09 != null and day09 != 0">#{day09},</if> |
||||
<if test="day10 != null and day10 != 0">#{day10},</if> |
||||
<if test="day11 != null and day11 != 0">#{day11},</if> |
||||
<if test="day12 != null and day12 != 0">#{day12},</if> |
||||
<if test="day13 != null and day13 != 0">#{day13},</if> |
||||
<if test="day14 != null and day14 != 0">#{day14},</if> |
||||
<if test="day15 != null and day15 != 0">#{day15},</if> |
||||
<if test="day16 != null and day16 != 0">#{day16},</if> |
||||
<if test="day17 != null and day17 != 0">#{day17},</if> |
||||
<if test="day18 != null and day18 != 0">#{day18},</if> |
||||
<if test="day19 != null and day19 != 0">#{day19},</if> |
||||
<if test="day20 != null and day20 != 0">#{day20},</if> |
||||
<if test="day21 != null and day21 != 0">#{day21},</if> |
||||
<if test="day22 != null and day22 != 0">#{day22},</if> |
||||
<if test="day23 != null and day23 != 0">#{day23},</if> |
||||
<if test="day24 != null and day24 != 0">#{day24},</if> |
||||
<if test="day25 != null and day25 != 0">#{day25},</if> |
||||
<if test="day26 != null and day26 != 0">#{day26},</if> |
||||
<if test="day27 != null and day27 != 0">#{day27},</if> |
||||
<if test="day28 != null and day28 != 0">#{day28},</if> |
||||
<if test="day29 != null and day29 != 0">#{day29},</if> |
||||
<if test="day30 != null and day30 != 0">#{day30},</if> |
||||
<if test="day31 != null and day31 != 0">#{day31},</if> |
||||
) |
||||
</insert> |
||||
|
||||
|
||||
<!--新增数据--> |
||||
<insert id="insert" useGeneratedKeys = 'true' keyProperty="monthId"> |
||||
insert into psdc_statistics_month(month_id, device_id, device_name, month_date, day_01, day_02, day_03, day_04, |
||||
day_05, day_06, day_07, day_08, day_09, day_10, day_11, day_12, day_13, |
||||
day_14, day_15, day_16, day_17, day_18, day_19, day_20, day_21, day_22, |
||||
day_23, day_24, day_25, day_26, day_27, day_28, day_29, day_30, day_31) |
||||
values (#{monthId}, #{deviceId}, #{deviceName}, #{monthDate}, #{day01}, #{day02}, #{day03}, #{day04}, #{day05}, |
||||
#{day06}, #{day07}, #{day08}, #{day09}, #{day10}, #{day11}, #{day12}, #{day13}, #{day14}, #{day15}, |
||||
#{day16}, #{day17}, #{day18}, #{day19}, #{day20}, #{day21}, #{day22}, #{day23}, #{day24}, #{day25}, |
||||
#{day26}, #{day27}, #{day28}, #{day29}, #{day30}, #{day31}) |
||||
</insert> |
||||
|
||||
<!-- 更新数据 --> |
||||
<update id="updatePoint"> |
||||
update psdc_statistics_month |
||||
set ${monthPoint} = #{value} |
||||
where month_id = #{monthId}; |
||||
</update> |
||||
|
||||
<!-- 更新数据 --> |
||||
<update id="update"> |
||||
update psdc_statistics_month |
||||
<set> |
||||
<if test="monthId != null and monthId != ''"> |
||||
month_id = #{monthId}, |
||||
</if> |
||||
<if test="deviceId != null and deviceId != ''"> |
||||
device_id = #{deviceId}, |
||||
</if> |
||||
<if test="deviceName != null and deviceName != ''"> |
||||
device_name = #{deviceName}, |
||||
</if> |
||||
<if test="month_date != null and month_date != ''"> |
||||
month_date = #{monthDate}, |
||||
</if> |
||||
<if test="day01 != null and day01 != ''"> |
||||
day_01 = #{day01}, |
||||
</if> |
||||
<if test="day02 != null and day02 != ''"> |
||||
day_02 = #{day02}, |
||||
</if> |
||||
<if test="day03 != null and day03 != ''"> |
||||
day_03 = #{day03}, |
||||
</if> |
||||
<if test="day04 != null and day04 != ''"> |
||||
day_04 = #{day04}, |
||||
</if> |
||||
<if test="day05 != null and day05 != ''"> |
||||
day_05 = #{day05}, |
||||
</if> |
||||
<if test="day06 != null and day06 != ''"> |
||||
day_06 = #{day06}, |
||||
</if> |
||||
<if test="day07 != null and day07 != ''"> |
||||
day_07 = #{day07}, |
||||
</if> |
||||
<if test="day08 != null and day08 != ''"> |
||||
day_08 = #{day08}, |
||||
</if> |
||||
<if test="day09 != null and day09 != ''"> |
||||
day_09 = #{day09}, |
||||
</if> |
||||
<if test="day10 != null and day10 != ''"> |
||||
day_10 = #{day10}, |
||||
</if> |
||||
<if test="day11 != null and day11 != ''"> |
||||
day_11 = #{day11}, |
||||
</if> |
||||
<if test="day12 != null and day12 != ''"> |
||||
day_12 = #{day12}, |
||||
</if> |
||||
<if test="day13 != null and day13 != ''"> |
||||
day_13 = #{day13}, |
||||
</if> |
||||
<if test="day14 != null and day14 != ''"> |
||||
day_14 = #{day14}, |
||||
</if> |
||||
<if test="day15 != null and day15 != ''"> |
||||
day_15 = #{day15}, |
||||
</if> |
||||
<if test="day16 != null and day16 != ''"> |
||||
day_16 = #{day16}, |
||||
</if> |
||||
<if test="day17 != null and day17 != ''"> |
||||
day_17 = #{day17}, |
||||
</if> |
||||
<if test="day18 != null and day18 != ''"> |
||||
day_18 = #{day18}, |
||||
</if> |
||||
<if test="day19 != null and day19 != ''"> |
||||
day_19 = #{day19}, |
||||
</if> |
||||
<if test="day20 != null and day20 != ''"> |
||||
day_20 = #{day20}, |
||||
</if> |
||||
<if test="day21 != null and day21 != ''"> |
||||
day_21 = #{day21}, |
||||
</if> |
||||
<if test="day22 != null and day22 != ''"> |
||||
day_22 = #{day22}, |
||||
</if> |
||||
<if test="day23 != null and day23 != ''"> |
||||
day_23 = #{day23}, |
||||
</if> |
||||
<if test="day24 != null and day24 != ''"> |
||||
day_24 = #{day24}, |
||||
</if> |
||||
<if test="day25 != null and day25 != ''"> |
||||
day_25 = #{day25}, |
||||
</if> |
||||
<if test="day26 != null and day26 != ''"> |
||||
day_26 = #{day26}, |
||||
</if> |
||||
<if test="day27 != null and day27 != ''"> |
||||
day_27 = #{day27}, |
||||
</if> |
||||
<if test="day28 != null and day28 != ''"> |
||||
day_28 = #{day28}, |
||||
</if> |
||||
<if test="day29 != null and day29 != ''"> |
||||
day_29 = #{day29}, |
||||
</if> |
||||
<if test="day30 != null and day30 != ''"> |
||||
day_30 = #{day30}, |
||||
</if> |
||||
<if test="day31 != null and day31 != ''"> |
||||
day_31 = #{day31}, |
||||
</if> |
||||
</set> |
||||
where month_id = #{monthId} |
||||
</update> |
||||
|
||||
<!--通过主键删除--> |
||||
<delete id="deleteById"> |
||||
delete |
||||
from psdc_statistics_month |
||||
where month_id = #{monthId} |
||||
</delete> |
||||
|
||||
<!-- 根据设备id和日期查询--> |
||||
<select id="queryByDeviceIdAndDate" resultMap="PsdcStatisticsMonthMap"> |
||||
select * from psdc_statistics_month where device_id = #{deviceId} and date_format(month_date,'%Y-%m') = #{date} |
||||
</select> |
||||
|
||||
<!-- 算一行数据总和--> |
||||
<select id="queryOneLineSum" resultType="double"> |
||||
select ifnull(day_01,0.0) + ifnull(day_02,0.0) + ifnull(day_03,0.0) + ifnull(day_04,0.0) + ifnull(day_05,0.0) + |
||||
ifnull(day_06,0.0) + ifnull(day_07,0.0) + ifnull(day_08,0.0) + ifnull(day_09,0.0) + ifnull(day_10,0.0) + |
||||
ifnull(day_11,0.0) + ifnull(day_12,0.0) + ifnull(day_13,0.0) + ifnull(day_14,0.0) + ifnull(day_15,0.0) + |
||||
ifnull(day_16,0.0) + ifnull(day_17,0.0) + ifnull(day_18,0.0) + ifnull(day_19,0.0) + ifnull(day_20,0.0) + |
||||
ifnull(day_21,0.0) + ifnull(day_22,0.0) + ifnull(day_23,0.0) + ifnull(day_24,0.0) + ifnull(day_25,0.0) + |
||||
ifnull(day_26,0.0) + ifnull(day_27,0.0) + ifnull(day_28,0.0) + ifnull(day_29,0.0) + ifnull(day_30,0.0) + |
||||
ifnull(day_31,0.0) as total from psdc_statistics_month where device_id = #{deviceId} and date_format(month_date,'%Y-%m') = #{date} |
||||
</select> |
||||
</mapper> |
@ -0,0 +1,165 @@ |
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
||||
<mapper namespace="com.psdc.mapper.PsdcStatisticsYearMapper"> |
||||
<resultMap type="com.psdc.entity.PsdcStatisticsYear" id="PsdcStatisticsYearMap"> |
||||
<result property="yearId" column="year_id" /> |
||||
<result property="deviceId" column="device_id" /> |
||||
<result property="deviceName" column="device_name" /> |
||||
<result property="yearDate" column="year_date" /> |
||||
<result property="month01" column="month_01" /> |
||||
<result property="month02" column="month_02" /> |
||||
<result property="month03" column="month_03" /> |
||||
<result property="month04" column="month_04" /> |
||||
<result property="month05" column="month_05" /> |
||||
<result property="month06" column="month_06" /> |
||||
<result property="month07" column="month_07" /> |
||||
<result property="month08" column="month_08" /> |
||||
<result property="month09" column="month_09" /> |
||||
<result property="month10" column="month_10" /> |
||||
<result property="month11" column="month_11" /> |
||||
<result property="month12" column="month_12" /> |
||||
</resultMap> |
||||
|
||||
<!-- 通过ID查询单条数据 --> |
||||
<select id="queryById" resultMap="PsdcStatisticsYearMap"> |
||||
select |
||||
year_id,device_id,device_name,year_date,month_01,month_02,month_03,month_04,month_05,month_06,month_07,month_08,month_09,month_10,month_11,month_12 |
||||
from psdc_statistics_year |
||||
where year_id = #{yearId} |
||||
</select> |
||||
|
||||
<!--分页查询指定行数据--> |
||||
<select id="queryAllByLimit" resultMap="PsdcStatisticsYearMap"> |
||||
select |
||||
year_id,device_id,device_name,year_date,month_01,month_02,month_03,month_04,month_05,month_06,month_07,month_08,month_09,month_10,month_11,month_12 |
||||
from psdc_statistics_year |
||||
<where> |
||||
<if test="deviceId != null and deviceId != ''"> |
||||
and device_id = #{deviceId} |
||||
</if> |
||||
<!-- 开始时间检索 --> |
||||
<if test="startTime != null and startTime != ''"> |
||||
AND date_format(year_date,'%Y') >= #{startTime} |
||||
</if> |
||||
<!-- 结束时间检索 --> |
||||
<if test="endTime != null and endTime != ''"> |
||||
AND date_format(year_date,'%Y') <= #{endTime} |
||||
</if> |
||||
</where> |
||||
|
||||
</select> |
||||
|
||||
|
||||
<!--新增数据--> |
||||
<insert id="insert" useGeneratedKeys = 'true' keyProperty="yearId" > |
||||
insert into psdc_statistics_year(year_id,device_id,device_name,year_date,month_01,month_02,month_03,month_04,month_05,month_06,month_07,month_08,month_09,month_10,month_11,month_12) |
||||
values (#{yearId},#{deviceId},#{deviceName},#{yearDate},#{month01},#{month02},#{month03},#{month04},#{month05},#{month06},#{month07},#{month08},#{month09},#{month10},#{month11},#{month12}) |
||||
</insert> |
||||
|
||||
<insert id="insertYear" useGeneratedKeys = 'true' keyProperty="yearId"> |
||||
Insert into psdc_statistics_year( |
||||
year_date, |
||||
device_id, |
||||
device_name |
||||
<if test="month01 != null and month01 != 0">,month_01,</if> |
||||
<if test="month02 != null and month02 != 0">month_02,</if> |
||||
<if test="month03 != null and month03 != 0">month_03,</if> |
||||
<if test="month04 != null and month04 != 0">month_04,</if> |
||||
<if test="month05 != null and month05 != 0">month_05,</if> |
||||
<if test="month06 != null and month06 != 0">month_06,</if> |
||||
<if test="month07 != null and month07 != 0">month_07,</if> |
||||
<if test="month08 != null and month08 != 0">month_08,</if> |
||||
<if test="month09 != null and month09 != 0">month_09,</if> |
||||
<if test="month10 != null and month10 != 0">month_10,</if> |
||||
<if test="month11 != null and month11 != 0">month_11,</if> |
||||
<if test="month12 != null and month12 != 0">month_12,</if> |
||||
)values( |
||||
#{yearDate}, |
||||
#{deviceId}, |
||||
#{deviceName} |
||||
<if test="month01 != null and month01 != 0">,#{month01},</if> |
||||
<if test="month02 != null and month02 != 0">#{month02},</if> |
||||
<if test="month03 != null and month03 != 0">#{month03},</if> |
||||
<if test="month04 != null and month04 != 0">#{month04},</if> |
||||
<if test="month05 != null and month05 != 0">#{month05},</if> |
||||
<if test="month06 != null and month06 != 0">#{month06},</if> |
||||
<if test="month07 != null and month07 != 0">#{month07},</if> |
||||
<if test="month08 != null and month08 != 0">#{month08},</if> |
||||
<if test="month09 != null and month09 != 0">#{month09},</if> |
||||
<if test="month10 != null and month10 != 0">#{month10},</if> |
||||
<if test="month11 != null and month11 != 0">#{month11},</if> |
||||
<if test="month12 != null and month12 != 0">#{month12},</if> |
||||
) |
||||
</insert> |
||||
|
||||
|
||||
<!-- 更新数据 --> |
||||
<update id="update"> |
||||
update psdc_statistics_year |
||||
<set> |
||||
<if test="deviceId != null and deviceId != ''"> |
||||
device_id = #{deviceId}, |
||||
</if> |
||||
<if test="deviceName != null and deviceName != ''"> |
||||
device_name = #{deviceName}, |
||||
</if> |
||||
<if test="year_date != null and year_date != ''"> |
||||
year_date = #{yearDate}, |
||||
</if> |
||||
<if test="month01 != null and month01 != ''"> |
||||
month_01 = #{month01}, |
||||
</if> |
||||
<if test="month02 != null and month02 != ''"> |
||||
month_02 = #{month02}, |
||||
</if> |
||||
<if test="month03 != null and month03 != ''"> |
||||
month_03 = #{month03}, |
||||
</if> |
||||
<if test="month04 != null and month04 != ''"> |
||||
month_04 = #{month04}, |
||||
</if> |
||||
<if test="month05 != null and month05 != ''"> |
||||
month_05 = #{month05}, |
||||
</if> |
||||
<if test="month06 != null and month06 != ''"> |
||||
month_06 = #{month06}, |
||||
</if> |
||||
<if test="month07 != null and month07 != ''"> |
||||
month_07 = #{month07}, |
||||
</if> |
||||
<if test="month08 != null and month08 != ''"> |
||||
month_08 = #{month08}, |
||||
</if> |
||||
<if test="month09 != null and month09 != ''"> |
||||
month_09 = #{month09}, |
||||
</if> |
||||
<if test="month10 != null and month10 != ''"> |
||||
month_10 = #{month10}, |
||||
</if> |
||||
<if test="month11 != null and month11 != ''"> |
||||
month_11 = #{month11}, |
||||
</if> |
||||
<if test="month12 != null and month12 != ''"> |
||||
month_12 = #{month12}, |
||||
</if> |
||||
</set> |
||||
where year_id = #{yearId} |
||||
</update> |
||||
|
||||
<!-- 更新固定点位数据--> |
||||
<update id="updatePoint" > |
||||
update psdc_statistics_year |
||||
set ${yearPoint} = #{value} |
||||
where year_id = #{yearId}; |
||||
</update> |
||||
|
||||
<!--通过主键删除--> |
||||
<delete id="deleteById"> |
||||
delete from psdc_statistics_year where year_id = #{yearId} |
||||
</delete> |
||||
|
||||
<!-- 根据设备id和日期查询--> |
||||
<select id="queryByDeviceIdAndDate" resultMap="PsdcStatisticsYearMap"> |
||||
select * from psdc_statistics_year where device_id = #{deviceId} and date_format(year_date,'%Y-%m') = #{date} |
||||
</select> |
||||
</mapper> |
@ -1,4 +1,4 @@ |
||||
package com.psdc.controller.evaluate; |
||||
|
||||
public class EnergyAnalysis { |
||||
public class EnergyAnalysisController { |
||||
} |
@ -1,4 +0,0 @@ |
||||
package com.psdc.controller.evaluate; |
||||
|
||||
public class EnergyStatistics { |
||||
} |
@ -0,0 +1,96 @@ |
||||
package com.psdc.controller.evaluate; |
||||
|
||||
import com.alibaba.fastjson2.JSONObject; |
||||
import com.psdc.core.controller.BaseController; |
||||
import com.psdc.core.page.TableDataInfo; |
||||
import com.psdc.entity.PsdcStatisticsDay; |
||||
import com.psdc.entity.PsdcStatisticsMonth; |
||||
import com.psdc.entity.PsdcStatisticsYear; |
||||
import com.psdc.entity.request.EnergyStatisticsRequest; |
||||
import com.psdc.service.IPsdcElectricHtdataService; |
||||
import com.psdc.utils.poi.ExcelUtil; |
||||
import lombok.extern.slf4j.Slf4j; |
||||
import org.springframework.security.access.prepost.PreAuthorize; |
||||
import org.springframework.web.bind.annotation.*; |
||||
|
||||
import javax.annotation.Resource; |
||||
import javax.servlet.http.HttpServletResponse; |
||||
import java.util.List; |
||||
|
||||
@RestController |
||||
@Slf4j |
||||
@RequestMapping("/evaluate/statistics") |
||||
public class EnergyStatisticsController extends BaseController { |
||||
|
||||
@Resource |
||||
private IPsdcElectricHtdataService psdcElectricHtdataService; |
||||
|
||||
/** |
||||
* 查询能耗统计列表 |
||||
* @return ajax |
||||
*/ |
||||
@PreAuthorize("@ss.hasPermi('analyse:nhtj:list')") |
||||
@PostMapping("/list") |
||||
public TableDataInfo getStatisticsList(@RequestBody JSONObject jsonObject) { |
||||
EnergyStatisticsRequest energyStatisticsRequest = myPage(jsonObject, EnergyStatisticsRequest.class); |
||||
if ( energyStatisticsRequest.getTimeType() == 1){ |
||||
|
||||
log.info("日"); |
||||
List<PsdcStatisticsDay> list = psdcElectricHtdataService.selectAllByListDay(energyStatisticsRequest); |
||||
return getDataTable(list); |
||||
|
||||
} else if ( energyStatisticsRequest.getTimeType() == 2) { |
||||
|
||||
log.info("月"); |
||||
List<PsdcStatisticsMonth> list = psdcElectricHtdataService.selectAllByListMonth(energyStatisticsRequest); |
||||
return getDataTable(list); |
||||
|
||||
} else if ( energyStatisticsRequest.getTimeType() == 3){ |
||||
|
||||
log.info("年"); |
||||
List<PsdcStatisticsYear> list = psdcElectricHtdataService.selectAllByListYear(energyStatisticsRequest); |
||||
return getDataTable(list); |
||||
|
||||
} |
||||
return null; |
||||
} |
||||
|
||||
/** |
||||
* 导出能耗数据 |
||||
*/ |
||||
@PreAuthorize("@ss.hasPermi('analyse:nhtj:export')") |
||||
@PostMapping("/export") |
||||
public void exportStatisticsList(HttpServletResponse response,@RequestBody EnergyStatisticsRequest energyStatisticsRequest){ |
||||
if ( energyStatisticsRequest.getTimeType() == 1){ |
||||
log.info("日"); |
||||
List<PsdcStatisticsDay> list = psdcElectricHtdataService.selectAllByListDay(energyStatisticsRequest); |
||||
ExcelUtil<PsdcStatisticsDay> psdcStatisticsDayExcelUtil = new ExcelUtil<>(PsdcStatisticsDay.class); |
||||
psdcStatisticsDayExcelUtil.exportExcel(response, list, "今日每小时数据"); |
||||
} else if ( energyStatisticsRequest.getTimeType() == 2) { |
||||
log.info("月"); |
||||
List<PsdcStatisticsMonth> list = psdcElectricHtdataService.selectAllByListMonth(energyStatisticsRequest); |
||||
ExcelUtil<PsdcStatisticsMonth> psdcStatisticsMonthExcelUtil = new ExcelUtil<>(PsdcStatisticsMonth.class); |
||||
psdcStatisticsMonthExcelUtil.exportExcel(response, list, "本月每天数据"); |
||||
} else if ( energyStatisticsRequest.getTimeType() == 3){ |
||||
log.info("年"); |
||||
List<PsdcStatisticsYear> list = psdcElectricHtdataService.selectAllByListYear(energyStatisticsRequest); |
||||
ExcelUtil<PsdcStatisticsYear> psdcStatisticsYearExcelUtil = new ExcelUtil<>(PsdcStatisticsYear.class); |
||||
psdcStatisticsYearExcelUtil.exportExcel(response, list, "今年每月数据"); |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* 查询能耗统计列表 |
||||
* @return ajax |
||||
*/ |
||||
@PreAuthorize("@ss.hasPermi('analyse:nhtj:list')") |
||||
@PostMapping("/list2") |
||||
public TableDataInfo getStatisticsList() { |
||||
psdcElectricHtdataService.statisticalTask(); |
||||
return null; |
||||
} |
||||
|
||||
|
||||
|
||||
|
||||
} |
Loading…
Reference in new issue