|
@@ -11,11 +11,13 @@
|
|
|
<resultMap id="AttributeData" type="com.huaxu.dto.MonitorDataChartReportAttributeDto">
|
|
|
<result property="attributeType" column="attributeType"/>
|
|
|
<result property="attributeName" column="attributeName"/>
|
|
|
+ <result property="unit" column="unit"/>
|
|
|
<collection property="monitorDataChartReportValue" resultMap="MonitorDataChartReportValue"/>
|
|
|
</resultMap>
|
|
|
|
|
|
<resultMap id="MonitorDataChartReportValue" type="com.huaxu.dto.MonitorDataChartReportValueDto">
|
|
|
<result property="dateLabel" column="dateLabel" />
|
|
|
+ <result property="dateStringLabel" column="dateStringLabel" />
|
|
|
<result property="monitorData" column="monitorData" />
|
|
|
<result property="data" column="data"/>
|
|
|
<result property="date" column="date"/>
|
|
@@ -30,12 +32,15 @@
|
|
|
select
|
|
|
<if test="type != null and type ==1">
|
|
|
r.`MONTH` as "dateLabel",
|
|
|
+ CONCAT(r.`YEAR`,'-',if(r.`MONTH`<10,CONCAT(0,r.`MONTH`),r.`MONTH`)) as "dateStringLabel",
|
|
|
</if>
|
|
|
<if test="type != null and type ==2">
|
|
|
r.`DAY` as "dateLabel",
|
|
|
+ CONCAT(r.`YEAR`,'-',if(r.`MONTH`<10,CONCAT(0,r.`MONTH`),r.`MONTH`),'-',if(r.`DAY`<10,CONCAT(0,r.`DAY`),r.`DAY`)) as "dateStringLabel",
|
|
|
</if>
|
|
|
<if test="type != null and type ==3">
|
|
|
r.`HOUR` as "dateLabel",
|
|
|
+ CONCAT(r.`YEAR`,'-',if(r.`MONTH`<10,CONCAT(0,r.`MONTH`),r.`MONTH`),'-',if(r.`DAY`<10,CONCAT(0,r.`DAY`),r.`DAY`),' ',if(r.`HOUR`<10,CONCAT(0,r.`HOUR`),r.`HOUR`),':00') as "dateStringLabel",
|
|
|
</if>
|
|
|
cast(ifnull(r.AVG_VALUE,'') as char)+ifnull(da.UNIT,'') as "monitorData"
|
|
|
,r.AVG_VALUE as "data"
|
|
@@ -43,6 +48,7 @@
|
|
|
|
|
|
,d.DEVICE_CODE as "devoceCode"
|
|
|
,d.DEVICE_NAME as "deviceName"
|
|
|
+ ,da.unit as "unit"
|
|
|
,r.ATTRIBUTE_NAME as "attributeName"
|
|
|
|
|
|
from ${tableName} r
|
|
@@ -104,23 +110,28 @@
|
|
|
|
|
|
<select id="MonitorDataEnergyReport" resultMap="MonitorDataChartReportMap">
|
|
|
select
|
|
|
- <if test="type != null and type ==1">
|
|
|
- r.`MONTH` as "dateLabel",
|
|
|
- </if>
|
|
|
- <if test="type != null and type ==2">
|
|
|
- r.`DAY` as "dateLabel",
|
|
|
- </if>
|
|
|
- <if test="type != null and type ==3">
|
|
|
- r.`HOUR` as "dateLabel",
|
|
|
- </if>
|
|
|
- cast(ifnull(r.SUM_VALUE,0) as char)+ifnull(da.UNIT,'') as "monitorData"
|
|
|
+ <if test="type != null and type ==1">
|
|
|
+ r.`MONTH` as "dateLabel",
|
|
|
+ CONCAT(r.`YEAR`,'-',if(r.`MONTH`<10,CONCAT(0,r.`MONTH`),r.`MONTH`)) as "dateStringLabel",
|
|
|
+ </if>
|
|
|
+ <if test="type != null and type ==2">
|
|
|
+ r.`DAY` as "dateLabel",
|
|
|
+ CONCAT(r.`YEAR`,'-',if(r.`MONTH`<10,CONCAT(0,r.`MONTH`),r.`MONTH`),'-',if(r.`DAY`<10,CONCAT(0,r.`DAY`),r.`DAY`)) as "dateStringLabel",
|
|
|
+ </if>
|
|
|
+ <if test="type != null and type ==3">
|
|
|
+ r.`HOUR` as "dateLabel",
|
|
|
+ CONCAT(r.`YEAR`,'-',if(r.`MONTH`<10,CONCAT(0,r.`MONTH`),r.`MONTH`),'-',if(r.`DAY`<10,CONCAT(0,r.`DAY`),r.`DAY`),' ',if(r.`HOUR`<10,CONCAT(0,r.`HOUR`),r.`HOUR`),':00') as "dateStringLabel",
|
|
|
+ </if>
|
|
|
+ cast(ifnull(r.SUM_VALUE,0) as char)+ifnull(da.UNIT,'') as "monitorData"
|
|
|
,ifnull(r.SUM_VALUE ,0) as "data"
|
|
|
,r.COLLECT_DATE as "date"
|
|
|
|
|
|
,d.DEVICE_CODE as "devoceCode"
|
|
|
,d.DEVICE_NAME as "deviceName"
|
|
|
,da.ATTRIBUTE_TYPE as "attributeType"
|
|
|
+ ,da.unit as "unit"
|
|
|
,if(da.ATTRIBUTE_TYPE=3,'用水量','耗电量') as "attributeName"
|
|
|
+
|
|
|
<if test="type != null and type ==1">
|
|
|
from sms_year_report r
|
|
|
</if>
|
|
@@ -188,12 +199,15 @@
|
|
|
select
|
|
|
<if test="type != null and type ==1">
|
|
|
r.`MONTH` as "dateLabel",
|
|
|
+ CONCAT(r.`YEAR`,'-',if(r.`MONTH`<10,CONCAT(0,r.`MONTH`),r.`MONTH`)) as "dateStringLabel",
|
|
|
</if>
|
|
|
<if test="type != null and type ==2">
|
|
|
r.`DAY` as "dateLabel",
|
|
|
+ CONCAT(r.`YEAR`,'-',if(r.`MONTH`<10,CONCAT(0,r.`MONTH`),r.`MONTH`),'-',if(r.`DAY`<10,CONCAT(0,r.`DAY`),r.`DAY`)) as "dateStringLabel",
|
|
|
</if>
|
|
|
<if test="type != null and type ==3">
|
|
|
r.`HOUR` as "dateLabel",
|
|
|
+ CONCAT(r.`YEAR`,'-',if(r.`MONTH`<10,CONCAT(0,r.`MONTH`),r.`MONTH`),'-',if(r.`DAY`<10,CONCAT(0,r.`DAY`),r.`DAY`),' ',if(r.`HOUR`<10,CONCAT(0,r.`HOUR`),r.`HOUR`),':00') as "dateStringLabel",
|
|
|
</if>
|
|
|
cast(ifnull(r.AVG_VALUE,'') as char)+ifnull(da.UNIT,'') as "monitorData"
|
|
|
,r.AVG_VALUE as "data"
|
|
@@ -202,6 +216,7 @@
|
|
|
,d.DEVICE_CODE as "devoceCode"
|
|
|
,d.DEVICE_NAME as "deviceName"
|
|
|
,da.ATTRIBUTE_TYPE as "attributeType"
|
|
|
+ ,da.unit as "unit"
|
|
|
,if(da.ATTRIBUTE_TYPE=8,'PH',if(da.ATTRIBUTE_TYPE=11,'余氯','浊度')) as "attributeName"
|
|
|
<if test="type != null and type ==1">
|
|
|
from sms_year_report r
|
|
@@ -271,10 +286,20 @@
|
|
|
|
|
|
<select id="DeviceAlarmReport" resultMap="MonitorDataChartReportMap">
|
|
|
select
|
|
|
- a.*,DATE_ADD(#{beginDate},INTERVAL a.dateLabel ${dateType}) as "date"
|
|
|
+ a.*,DATE_ADD(#{beginDate},INTERVAL a.dateLabel-1 ${dateType}) as "date"
|
|
|
from (
|
|
|
select
|
|
|
${dateType}(ad.ALARM_START_TIME) as "dateLabel"
|
|
|
+
|
|
|
+ <if test="dateType != null and dateType == 'month'">
|
|
|
+ ,DATE_FORMAT(max(ad.ALARM_START_TIME),'%Y-%m') as "dateStringLabel"
|
|
|
+ </if>
|
|
|
+ <if test="dateType != null and dateType == 'day'">
|
|
|
+ ,DATE_FORMAT(max(ad.ALARM_START_TIME),'%Y-%m-%d') as "dateStringLabel"
|
|
|
+ </if>
|
|
|
+ <if test="dateType != null and dateType == 'hour'">
|
|
|
+ ,DATE_FORMAT(max(ad.ALARM_START_TIME),'%Y-%m-%d %H:00') as "dateStringLabel"
|
|
|
+ </if>
|
|
|
,count(1) as "monitorData"
|
|
|
,count(1) as "data"
|
|
|
|