燕山石化溯源三维电子沙盘-【后端】-服务
1
13693261870
2024-11-29 9a8c8a90c7c01b6bc770d4be5baeff72c058468c
src/main/resources/mapper/XlsReportMapper.xml
@@ -1,101 +1,102 @@
<?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>
    <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 &lt;= (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">
<mapper namespace="com.yssh.mapper.XlsReportMapper">
    <select id="selectReportCount" 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 &lt;= (select jcbj from alert_config limit 1);
        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 create_time &lt;= #{end}
            </if>
        </where>
    </select>
    <select id="countMonthForAlarm" resultType="java.lang.Integer">
    <!-- 分页查询报告 -->
    <select id="selectReportByPage" 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 create_time &lt;= #{end}
            </if>
        </where>
        order by create_time desc
        limit #{limit} offset #{offset}
    </select>
    <!-- 根据ID查询报告 -->
    <select id="selectById" resultType="com.yssh.entity.xls.XlsReport">
        select *
        from xls_report
        where id = #{id};
    </select>
    <!-- 报告是否存在 -->
    <select id="reportExists" 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);
        from xls_report
        where type = #{type} and name = #{name}
    </select>
    <select id="count7DayForWarn" resultType="java.util.Map">
        with rs as (
            select left(time, 8) "createTime"
    <!-- 插入报告 -->
    <insert id="insertReport" parameterType="com.yssh.entity.xls.XlsReport">
       insert into xls_report
       (name, type, path, create_time)
       values
       (#{name}, #{type}, #{path}, #{createTime})
    </insert>
    <!-- 查询日均值 -->
    <select id="selectDayAvg" resultType="java.lang.Double">
        select ifnull(round(avg(value), 2), 0)
        from yssh_qxsh
        where time like #{time} and name = #{name};
    </select>
    <!-- 查询累计值 -->
    <select id="selectAccumulate" resultType="java.lang.Double">
        select ifnull(round(avg(value), 2), 0)
        from yssh_qxsh
        where time between #{start} and #{end} and name = #{name};
    </select>
    <!-- 查询年累计值 -->
    <select id="selectYearAccumulate" resultType="java.lang.Double">
        select ifnull(round(avg(value), 2), 0)
        from yssh_qxsh
        where time like #{time} and name = #{name};
    </select>
    <!-- 根据时间查询溯源 -->
    <select id="selectSuYuanByTime" resultType="com.yssh.entity.SuYuan700">
        select *
        from suyuan_46
        where su_yuan_id = #{id} and create_time between #{start} and #{end}
        order by create_time;
    </select>
    <!-- 根据时间段查询溯源 -->
    <select id="selectSuYuanByStartAndEnd" resultType="com.yssh.entity.SuYuan700">
        select *
        from suyuan_46
        where su_yuan_id = #{id} and date_format(create_time, '%Y%m%d%H') in (
            select 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 &lt;= (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;
            where value > #{yjz} and name = #{name} and time between #{start} and #{end}
        );
    </select>
</mapper>