|
@@ -92,9 +92,16 @@
|
|
</select>
|
|
</select>
|
|
|
|
|
|
<!-- 根据获取实体 page -->
|
|
<!-- 根据获取实体 page -->
|
|
- <select id="findPage" resultType="com.huaxu.entity.DayReportEntity">
|
|
|
|
|
|
+ <select id="findPage" resultType="com.huaxu.dto.ReportDto">
|
|
SELECT
|
|
SELECT
|
|
- <include refid="dayReportColumns"/>
|
|
|
|
|
|
+ distinct
|
|
|
|
+ a.tenant_id as "tenantId" ,
|
|
|
|
+ a.year as "year" ,
|
|
|
|
+ a.month as "month" ,
|
|
|
|
+ a.day as "day" ,
|
|
|
|
+ a.hour as "hour" ,
|
|
|
|
+ a.parent_scene_id as "parentSceneId",
|
|
|
|
+ a.parent_scene_name as "parentSceneName"
|
|
FROM sms_day_report a
|
|
FROM sms_day_report a
|
|
<where>
|
|
<where>
|
|
<if test="dayReport.tenantId != null and dayReport.tenantId != ''">and a.tenant_id =
|
|
<if test="dayReport.tenantId != null and dayReport.tenantId != ''">and a.tenant_id =
|
|
@@ -103,15 +110,72 @@
|
|
<if test="dayReport.year != null ">and a.year = #{dayReport.year}</if>
|
|
<if test="dayReport.year != null ">and a.year = #{dayReport.year}</if>
|
|
<if test="dayReport.month != null ">and a.month = #{dayReport.month}</if>
|
|
<if test="dayReport.month != null ">and a.month = #{dayReport.month}</if>
|
|
<if test="dayReport.day != null ">and a.day = #{dayReport.day}</if>
|
|
<if test="dayReport.day != null ">and a.day = #{dayReport.day}</if>
|
|
- <if test="dayReport.hour != null ">and a.hour = #{dayReport.hour}</if>
|
|
|
|
- <if test="dayReport.parentSceneId != null ">and a.parent_scene_id = #{dayReport.parentSceneId}</if>
|
|
|
|
- <if test="dayReport.sceneId != null ">and a.scene_id = #{dayReport.sceneId}</if>
|
|
|
|
- <if test="dayReport.deviceId != null ">and a.device_id = #{dayReport.deviceId}</if>
|
|
|
|
- <if test="dayReport.deviceCode != null and dayReport.deviceCode != ''">and a.device_code =
|
|
|
|
- #{dayReport.deviceCode}
|
|
|
|
- </if>
|
|
|
|
- <if test="dayReport.attributeId != null ">and a.attribute_id = #{dayReport.attributeId}</if>
|
|
|
|
- <if test="dayReport.collectDate != null ">and a.collect_date = #{dayReport.collectDate}</if>
|
|
|
|
|
|
+ and a.parent_scene_id in
|
|
|
|
+ <foreach collection="dayReport.parentSceneIds" item="dramaId" open="(" close=")" separator=",">
|
|
|
|
+ #{dramaId}
|
|
|
|
+ </foreach>
|
|
</where>
|
|
</where>
|
|
|
|
+ order by a.parent_scene_id,a.year,a.month,a.day,a.hour
|
|
|
|
+ </select>
|
|
|
|
+ <select id="findAttributeList" resultType="com.huaxu.dto.ReportAttributeDto">
|
|
|
|
+ SELECT tab.attributeName,tab.ATTRIBUTE_TYPE,min(tab.minValue) as "minValue",
|
|
|
|
+ max(tab.maxValue) as "maxValue",AVG(tab.avgValue)as "avgValue",
|
|
|
|
+ AVG(tab.sumValue)as "sumValue",AVG(tab.latestValue) as "latestValue"
|
|
|
|
+ from
|
|
|
|
+ (SELECT IFNULL(a.REMARK,b.`NAME`) AS "attributeName",
|
|
|
|
+ c.min_value as "minValue" ,c.max_value as "maxValue" ,c.avg_value as "avgValue" ,
|
|
|
|
+ c.sum_value as "sumValue" ,c.latest_value as "latestValue",
|
|
|
|
+ b.ATTRIBUTE_TYPE
|
|
|
|
+ FROM sms_device_parm a
|
|
|
|
+ INNER JOIN sms_device_attribute b on a.ATTRIBUTE_ID=b.ID
|
|
|
|
+ INNER JOIN sms_day_report c on a.ATTRIBUTE_ID=c.ATTRIBUTE_ID and a.DEVICE_ID=c.DEVICE_ID
|
|
|
|
+ where
|
|
|
|
+ a.IS_REPORT=1
|
|
|
|
+ <if test="report.deviceIds != null and report.deviceIds.size() > 0">
|
|
|
|
+ and a.DEVICE_ID in
|
|
|
|
+ <foreach collection="report.deviceIds" item="dramaId" open="(" close=")" separator=",">
|
|
|
|
+ #{dramaId.id}
|
|
|
|
+ </foreach>
|
|
|
|
+ </if>
|
|
|
|
+ <if test="report.year != null ">and c.`YEAR`=#{report.year}</if>
|
|
|
|
+ <if test="report.month != null ">and c.`MONTH`=#{report.month}</if>
|
|
|
|
+ <if test="report.day != null ">and c.`DAY`=#{report.day}</if>
|
|
|
|
+ <if test="report.hour != null ">and c.`HOUR`=#{report.hour}</if>
|
|
|
|
+ <if test="report.parentSceneId != null ">and c.PARENT_SCENE_ID=#{report.parentSceneId}</if>
|
|
|
|
+ ORDER BY a.SEQ
|
|
|
|
+ ) as tab
|
|
|
|
+ group by tab.attributeName,tab.ATTRIBUTE_TYPE
|
|
|
|
+ </select>
|
|
|
|
+ <select id="findReport" resultType="com.huaxu.dto.ReportDto">
|
|
|
|
+ select sum(ifnull(intakeWaterUsage,0))as "intakeWaterUsage",
|
|
|
|
+ sum(ifnull(yieldWaterUsage,0))as "yieldWaterUsage",
|
|
|
|
+ sum(ifnull(powerUsage,0))as "powerUsage",
|
|
|
|
+ sum(ifnull(drugUsage,0))as "drugUsage"
|
|
|
|
+ from
|
|
|
|
+ (SELECT
|
|
|
|
+ case when b.ATTRIBUTE_TYPE=4 then
|
|
|
|
+ c.latest_value end as "intakeWaterUsage",
|
|
|
|
+ case when b.ATTRIBUTE_TYPE=3 then
|
|
|
|
+ c.latest_value end as "yieldWaterUsage",
|
|
|
|
+ case when b.ATTRIBUTE_TYPE=5 then
|
|
|
|
+ c.latest_value end as "powerUsage",
|
|
|
|
+ case when b.ATTRIBUTE_TYPE=6 then
|
|
|
|
+ c.latest_value end as "drugUsage"
|
|
|
|
+ FROM sms_device_parm a
|
|
|
|
+ INNER JOIN sms_device_attribute b on a.ATTRIBUTE_ID=b.ID
|
|
|
|
+ INNER JOIN sms_day_report c on a.ATTRIBUTE_ID=c.ATTRIBUTE_ID and a.DEVICE_ID=c.DEVICE_ID
|
|
|
|
+ where
|
|
|
|
+ <if test="report.deviceIds != null and report.deviceIds.size() > 0">
|
|
|
|
+ a.DEVICE_ID in
|
|
|
|
+ <foreach collection="report.deviceIds" item="dramaId" open="(" close=")" separator=",">
|
|
|
|
+ #{dramaId.id}
|
|
|
|
+ </foreach>
|
|
|
|
+ </if>
|
|
|
|
+ <if test="report.year != null ">and c.`YEAR`=#{report.year}</if>
|
|
|
|
+ <if test="report.month != null ">and c.`MONTH`=#{report.month}</if>
|
|
|
|
+ <if test="report.day != null ">and c.`DAY`=#{report.day}</if>
|
|
|
|
+ <if test="report.hour != null ">and c.`HOUR`=#{report.hour}</if>
|
|
|
|
+ <if test="report.parentSceneId != null ">and c.PARENT_SCENE_ID=#{report.parentSceneId}</if>
|
|
|
|
+ and (b.ATTRIBUTE_TYPE =3 or b.ATTRIBUTE_TYPE =4 or b.ATTRIBUTE_TYPE =5 or b.ATTRIBUTE_TYPE !=6)) tab
|
|
</select>
|
|
</select>
|
|
</mapper>
|
|
</mapper>
|