|
@@ -56,4 +56,151 @@
|
|
|
<if test="tpmMessageAlarm.status != null"> and s.status = #{tpmMessageAlarm.status}</if>
|
|
|
</where> order by s.alarmtime desc
|
|
|
</select>
|
|
|
+
|
|
|
+
|
|
|
+ <resultMap type="org.jeecg.modules.tpmMessageAlarm.entity.TpmMessageAlarmStatistics" id="AlarmStatisticsResult">
|
|
|
+ <result property="equipmentid" column="equipmentid" />
|
|
|
+ <result property="equipmentname" column="equipmentname" />
|
|
|
+ <result property="year" column="year" />
|
|
|
+ <result property="month" column="month" />
|
|
|
+ <result property="week" column="week" />
|
|
|
+ <result property="day" column="day" />
|
|
|
+ <result property="dayofweek" column="dayofweek" />
|
|
|
+ <result property="howManyTimes" column="howManyTimes" />
|
|
|
+ <result property="howManyTimes2" column="howManyTimes2" />
|
|
|
+ <result property="type" column="type" />
|
|
|
+ </resultMap>
|
|
|
+
|
|
|
+ <!-- 报警信息统计 -->
|
|
|
+ <select id="selectAlarmStatistics" parameterType="org.jeecg.modules.tpmMessageAlarm.entity.TpmMessageAlarmStatistics" resultMap="AlarmStatisticsResult">
|
|
|
+ select 'year' as type, count(*) as howManyTimes
|
|
|
+ from tpm_message_alarm
|
|
|
+ where year=#{alarmStatistics.year}
|
|
|
+ union
|
|
|
+ select 'month' as type, count(*) as howManyTimes
|
|
|
+ from tpm_message_alarm
|
|
|
+ where year=#{alarmStatistics.year} and month=#{alarmStatistics.month}
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <!-- 报警等级统计 -->
|
|
|
+ <select id="selectLevelStatistics" parameterType="org.jeecg.modules.tpmMessageAlarm.entity.TpmMessageAlarmStatistics" resultMap="AlarmStatisticsResult">
|
|
|
+ select d.item_text as equipmentname, count(a.id) as howManyTimes
|
|
|
+ from tpm_message_alarm as a
|
|
|
+ left join
|
|
|
+ (
|
|
|
+ select dt.item_text,dt.item_value
|
|
|
+ from sys_dict sd
|
|
|
+ LEFT JOIN sys_dict_item dt
|
|
|
+ on sd.dict_code = 'alarm_level' and sd.id = dt.dict_id
|
|
|
+ )d
|
|
|
+ on a.alarmlevel = d.item_value
|
|
|
+ where a.year=#{alarmStatistics.year} and a.month=#{alarmStatistics.month}
|
|
|
+ group by d.item_text
|
|
|
+ order by d.item_text asc
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <!-- 报警排名 -->
|
|
|
+ <select id="selectAlarmRank" parameterType="org.jeecg.modules.tpmMessageAlarm.entity.TpmMessageAlarmStatistics" resultMap="AlarmStatisticsResult">
|
|
|
+ select d.item_text as equipmentname, count(a.id) as howManyTimes
|
|
|
+ from tpm_message_alarm as a
|
|
|
+ left join
|
|
|
+ (
|
|
|
+ select dt.item_text,dt.item_value
|
|
|
+ from sys_dict sd
|
|
|
+ LEFT JOIN sys_dict_item dt
|
|
|
+ on sd.dict_code = 'alarm_type' and sd.id = dt.dict_id
|
|
|
+ )d
|
|
|
+ on a.alarmtype = d.item_value
|
|
|
+ where a.year=#{alarmStatistics.year} and a.month=#{alarmStatistics.month}
|
|
|
+ group by d.item_text
|
|
|
+ order by count(a.id) desc, d.item_text asc
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <!-- 近两年报警对比图(报警类型) -->
|
|
|
+ <select id="selectAlarmTwoYear" parameterType="org.jeecg.modules.tpmMessageAlarm.entity.TpmMessageAlarmStatistics" resultMap="AlarmStatisticsResult">
|
|
|
+ select t.*
|
|
|
+ from (
|
|
|
+ select 'lastyear' as type, d.item_text as equipmentname, count(a.id) as howManyTimes
|
|
|
+ from tpm_message_alarm as a
|
|
|
+ left join
|
|
|
+ (
|
|
|
+ select dt.item_text,dt.item_value
|
|
|
+ from sys_dict sd
|
|
|
+ left JOIN sys_dict_item dt on sd.dict_code = 'alarm_type' and sd.id = dt.dict_id
|
|
|
+ )d
|
|
|
+ on a.alarmtype = d.item_value
|
|
|
+ where a.year=#{alarmStatistics.year}-1
|
|
|
+ group by type, d.item_text
|
|
|
+
|
|
|
+ union
|
|
|
+
|
|
|
+ select 'thisyear' as type, d.item_text as equipmentname, count(a.id) as howManyTimes
|
|
|
+ from tpm_message_alarm as a
|
|
|
+ left join
|
|
|
+ (
|
|
|
+ select dt.item_text,dt.item_value
|
|
|
+ from sys_dict sd
|
|
|
+ left JOIN sys_dict_item dt on sd.dict_code = 'alarm_type' and sd.id = dt.dict_id
|
|
|
+ )d
|
|
|
+ on a.alarmtype = d.item_value
|
|
|
+ where a.year=#{alarmStatistics.year}
|
|
|
+ group by type, d.item_text
|
|
|
+
|
|
|
+ union
|
|
|
+
|
|
|
+ select 'all' as type, d.item_text as equipmentname, count(a.id) as howManyTimes
|
|
|
+ from tpm_message_alarm as a
|
|
|
+ left join
|
|
|
+ (
|
|
|
+ select dt.item_text,dt.item_value
|
|
|
+ from sys_dict sd
|
|
|
+ left JOIN sys_dict_item dt on sd.dict_code = 'alarm_type' and sd.id = dt.dict_id
|
|
|
+ )d
|
|
|
+ on a.alarmtype = d.item_value
|
|
|
+ where a.year in (#{alarmStatistics.year},#{alarmStatistics.year}-1)
|
|
|
+ group by type, d.item_text
|
|
|
+ ) as t
|
|
|
+ order by t.type, t.equipmentname
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <!-- 报警类型占比 -->
|
|
|
+ <select id="selectTypeRatio" parameterType="org.jeecg.modules.tpmMessageAlarm.entity.TpmMessageAlarmStatistics" resultMap="AlarmStatisticsResult">
|
|
|
+ select d.item_text as equipmentname, count(a.id) as howManyTimes
|
|
|
+ from tpm_message_alarm as a
|
|
|
+ left join
|
|
|
+ (
|
|
|
+ select dt.item_text,dt.item_value
|
|
|
+ from sys_dict sd
|
|
|
+ LEFT JOIN sys_dict_item dt
|
|
|
+ on sd.dict_code = 'alarm_type' and sd.id = dt.dict_id
|
|
|
+ )d
|
|
|
+ on a.alarmtype = d.item_value
|
|
|
+ where a.year=#{alarmStatistics.year} and a.month=#{alarmStatistics.month}
|
|
|
+ group by d.item_text
|
|
|
+ order by d.item_text
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <!-- 报警趋势散点图 -->
|
|
|
+ <select id="selectAlarmScatter" parameterType="org.jeecg.modules.tpmMessageAlarm.entity.TpmMessageAlarmStatistics" resultMap="AlarmStatisticsResult">
|
|
|
+ SELECT d.item_text as equipmentname,a.day,count(a.id) as howManyTimes
|
|
|
+ from tpm_message_alarm as a
|
|
|
+ left join
|
|
|
+ (
|
|
|
+ select dt.item_text,dt.item_value
|
|
|
+ from sys_dict sd
|
|
|
+ LEFT JOIN sys_dict_item dt on sd.dict_code = 'alarm_type' and sd.id = dt.dict_id
|
|
|
+ )d
|
|
|
+ on a.alarmtype = d.item_value
|
|
|
+ where a.year=#{alarmStatistics.year} and a.month=#{alarmStatistics.month}
|
|
|
+ group by a.day,d.item_text;
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <!-- 报警类型信息 -->
|
|
|
+ <select id="selectAlarmType" parameterType="org.jeecg.modules.tpmMessageAlarm.entity.TpmMessageAlarmStatistics" resultMap="AlarmStatisticsResult">
|
|
|
+ select item_text as equipmentname, 0 as howManyTimes
|
|
|
+ from sys_dict_item i
|
|
|
+ left join sys_dict d on i.dict_id = d.id
|
|
|
+ where d.dict_code = 'alarm_type'
|
|
|
+ group by i.item_text
|
|
|
+ </select>
|
|
|
</mapper>
|