| | |
| | | <?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.yssh.mapper.QxshMapper"> |
| | | <select id="selectByTime" resultType="com.yssh.entity.Qxsh"> |
| | | select id, name, lon, lat, format(value, 2) "value", time |
| | | from yssh_qxsh |
| | | where time = #{time} |
| | | order by name; |
| | | <select id="selectByPage" resultType="com.yssh.entity.xls.XlsReport"> |
| | | select * |
| | | from xls_report |
| | | <where> |
| | | 1 = 1 |
| | | <if test="type != null"> |
| | | and type = #{type} |
| | | </if> |
| | | <if test="start != null"> |
| | | and create_time >= #{start} |
| | | </if> |
| | | <if test="end != null"> |
| | | and end <= #{end} |
| | | </if> |
| | | </where> |
| | | order by id desc |
| | | limit #{limit} offset #{offset} |
| | | </select> |
| | | |
| | | <select id="selectMonthTop10" resultType="com.yssh.entity.Qxsh"> |
| | | with rs as ( |
| | | select id, name, lon, lat, format(value, 2) "value", time |
| | | from yssh_qxsh |
| | | where time like #{time} and name like 'AI-%' |
| | | ) |
| | | select id, name, lon, lat, value, time from rs |
| | | order by value desc |
| | | limit 10; |
| | | </select> |
| | | |
| | | <select id="selectWarnByBeginAndEnd" resultType="com.yssh.entity.Qxsh"> |
| | | select id, name, lon, lat, format(value, 2) "value", time |
| | | from yssh_qxsh |
| | | where time between #{start} and #{end} and name like 'AI-%' |
| | | and value > (select jcyj from alert_config limit 1) and value <= (select jcbj from alert_config limit 1) |
| | | order by time desc, name; |
| | | </select> |
| | | |
| | | <select id="selectAlarmByBeginAndEnd" resultType="com.yssh.entity.Qxsh"> |
| | | select id, name, lon, lat, format(value, 2) "value", time |
| | | from yssh_qxsh |
| | | where time between #{start} and #{end} and name like 'AI-%' |
| | | and value > (select jcbj from alert_config limit 1) |
| | | order by time desc, name; |
| | | </select> |
| | | |
| | | <select id="countMonthForWarn" resultType="java.lang.Integer"> |
| | | <select id="xlsExists" resultType="java.lang.Integer"> |
| | | select count(*) |
| | | from yssh_qxsh |
| | | where time between #{start} and #{end} and name like 'AI-%' |
| | | and value > (select jcyj from alert_config limit 1) and value <= (select jcbj from alert_config limit 1); |
| | | from xls_report |
| | | where type = #{type} and name = #{name} |
| | | </select> |
| | | |
| | | <select id="countMonthForAlarm" resultType="java.lang.Integer"> |
| | | select count(*) |
| | | from yssh_qxsh |
| | | where time between #{start} and #{end} and name like 'AI-%' |
| | | and value > (select jcbj from alert_config limit 1); |
| | | </select> |
| | | |
| | | <select id="count7DayForWarn" resultType="java.util.Map"> |
| | | with rs as ( |
| | | select left(time, 8) "createTime" |
| | | from yssh_qxsh |
| | | where time between #{start} and #{end} and name like 'AI-%' |
| | | and value > (select jcyj from alert_config limit 1) and value <= (select jcbj from alert_config limit 1) |
| | | ) |
| | | select createTime, count(*) "num" from rs group by createTime order by createTime; |
| | | </select> |
| | | |
| | | <select id="count7DayForAlarm" resultType="java.util.Map"> |
| | | with rs as ( |
| | | select left(time, 8) "createTime" |
| | | from yssh_qxsh |
| | | where time between #{start} and #{end} and name like 'AI-%' |
| | | and value > (select jcbj from alert_config limit 1) |
| | | ) |
| | | select createTime, count(*) "num" from rs group by createTime order by createTime; |
| | | </select> |
| | | |
| | | <select id="select3Hours" resultType="com.yssh.entity.Qxsh"> |
| | | select id, name, lon, lat, format(value, 2) "value", time |
| | | from yssh_qxsh |
| | | where time between #{start} and #{end} |
| | | and value > (select jcyj from alert_config limit 1) and name like 'AI-%' |
| | | order by time, name; |
| | | </select> |
| | | |
| | | <select id="selectForReport" resultType="com.yssh.entity.Qxsh"> |
| | | select id, name, format(value, 2) "value", time |
| | | from yssh_qxsh |
| | | where time between #{start} and #{end} |
| | | and value > (select jcbj from alert_config limit 1) and name like 'AI-%' |
| | | order by time, name; |
| | | </select> |
| | | |
| | | <select id="selectLastYearVal" resultType="java.lang.Double"> |
| | | select format(value, 2) "value" |
| | | from yssh_qxsh |
| | | where time = #{time} and name = #{name} |
| | | limit 1; |
| | | </select> |
| | | |
| | | <select id="selectByTimeAndName" resultType="com.yssh.entity.Qxsh"> |
| | | select id, name, lon, lat, format(value, 2) "value", time |
| | | from yssh_qxsh |
| | | where time = #{time} and name = #{name} |
| | | limit 1; |
| | | </select> |
| | | <insert id="insert" parameterType="com.yssh.entity.xls.XlsReport"> |
| | | insert into xls_report |
| | | (name, type, path, create_time) |
| | | values |
| | | (#{name}, #{type}, #{path}, #{createTime}) |
| | | </insert> |
| | | </mapper> |