zmc
2023-08-29 1eecc1f678668ba11b15198be4f0057cf886e7f6
src/main/resources/com/job/zsc/mapper/Vue3FumeMapper.xml
@@ -6,53 +6,74 @@
<!--   超标油烟查询-->
    <select id="conditionQuery" resultType="com.job.zsc.pojo.FumeHistoryData">
        select a1.MV_ID,a1.MV_Stat_Code,b.DI_Name,a1.MV_Create_Time,a1.MV_Data_Time,a1.MV_Fume_Concentration2
        from exceeding_st_data as a1 , ea_t_device_info as b
        SELECT a1.MV_ID, a1.MV_Stat_Code, b.DI_Name,b.DI_Supplier, a1.MV_Create_Time, a1.MV_Data_Time, a1.MV_Fume_Concentration2
        FROM exceeding_st_data AS a1
        INNER JOIN ea_t_device_info AS b ON a1.MV_Stat_Code = b.DI_Code
        <where>
            <!--  条件为空时查询全部-->
            <if test="(devId ==null or devId == '') and (beginTime ==null and endTime == null)">
                a1.MV_Stat_Code =  b.DI_Code
            </if>
            <if test="devId != null and devId != '' ">
               and a1.MV_Stat_Code = #{devId} and b.DI_Code = #{devId}
                a1.MV_Stat_Code = #{devId}
            </if>
            <if test="beginTime != null and endTime != null">
                and a1.MV_Data_Time between #{beginTime} and #{endTime}
            </if>
        </where>
        order by MV_Data_Time asc
        order by a1.MV_Data_Time asc
    </select>
<!--    历史油烟查询-->
    <!--    历史油烟查询-->
<!--    <select id="conditionQueryHistory" resultType="com.job.zsc.pojo.FumeHistoryData">-->
<!--        SELECT d.DI_Name, c.*-->
<!--        FROM (-->
<!--        SELECT a.*-->
<!--        FROM fd_t_minutevalue as a-->
<!--        LEFT JOIN fd_t_minutevalue  as b ON a.MV_Data_Time = b.MV_Data_Time AND a.MV_Isduplication &lt; b.MV_Isduplication-->
<!--        WHERE b.MV_ID IS NULL AND a.MV_Stat_Code = #{devId})-->
<!--        as c join ea_t_device_info as d on c.MV_Stat_Code =  d.DI_Code-->
<!--        <where>-->
<!--            <if test="devId != null and devId != '' ">-->
<!--                and c.MV_Stat_Code = #{devId}-->
<!--            </if>-->
<!--            <if test="beginTime != null and endTime != null">-->
<!--                AND c.MV_Data_Time between  #{beginTime} AND  #{endTime}-->
<!--            </if>-->
<!--        </where>-->
<!--        ORDER BY c.MV_Data_Time ASC;-->
<!--    </select>-->
    <!--    历史油烟查询 修改了语句-->
    <select id="conditionQueryHistory" resultType="com.job.zsc.pojo.FumeHistoryData">
        select a1.MV_ID,a1.MV_Stat_Code,b.DI_Name,a1.MV_Data_Time,a1.MV_Fume_Concentration2,a1.MV_Fan_Electricity,a1.MV_Purifier_Electricity
        from fd_t_minutevalue as a1 , ea_t_device_info as b
        SELECT d.DI_Name, c.*
        FROM (
        SELECT a.*
        FROM fd_t_minutevalue AS a
        INNER JOIN (
        SELECT MV_Stat_Code,MV_Data_Time, MAX(MV_Isduplication) AS Max_Isduplication
        FROM fd_t_minutevalue
        WHERE MV_Stat_Code = #{devId}
        GROUP BY MV_Data_Time
        ) AS b ON a.MV_Data_Time = b.MV_Data_Time AND a.MV_Isduplication = b.Max_Isduplication AND a.MV_Stat_Code = b.MV_Stat_Code
        WHERE a.MV_Stat_Code = #{devId}
        ) AS c
        JOIN ea_t_device_info AS d ON c.MV_Stat_Code = d.DI_Code
        <where>
            <!--  条件为空时查询全部-->
            <if test="(devId ==null or devId == '') or (beginTime ==null and endTime == null)">
                a1.MV_Stat_Code =  b.DI_Code
            </if>
            <if test="devId != null and devId != '' ">
                and a1.MV_Stat_Code = #{devId} and b.DI_Code = #{devId}
            </if>
            <if test="beginTime != null and endTime != null">
                and a1.MV_Data_Time between #{beginTime} and #{endTime}
                c.MV_Data_Time >= #{beginTime} AND c.MV_Data_Time &lt;= #{endTime}
            </if>
        </where>
        order by MV_Data_Time asc
        ORDER BY c.MV_Data_Time ASC;
    </select>
<!--    条件查询异常表-->
    <select id="conditonQueryAbnormalData" resultType="com.job.zsc.pojo.FumeAbnormalData">
        select a1.dev_id,b.DI_Name,a1.exception_type,a1.region,a1.begin_time,a1.end_time
        from abnormal_data as a1,ea_t_device_info as b
        from abnormal_data as a1 join ea_t_device_info as b on  a1.dev_id =  b.DI_Code
        <where>
            <if test="(devId ==null or devId == '') or (beginTime ==null and endTime == null)">
                a1.dev_id =  b.DI_Code
            </if>
            <if test="devId != null and devId != '' ">
                and a1.dev_id = #{devId} and b.DI_Code = #{devId}
@@ -69,11 +90,8 @@
    <!--    条件查询异常表 增加了异常类型选项-->
    <select id="conditonQueryAbnormalData1" resultType="com.job.zsc.pojo.FumeAbnormalData">
        select a1.dev_id,b.DI_Name,a1.exception,a1.exception_type,a1.region,a1.begin_time,a1.end_time
        from abnormal_data as a1,ea_t_device_info as b
        from abnormal_data as a1 join ea_t_device_info as b on a1.dev_id =  b.DI_Code
        <where>
            <if test="(devId ==null or devId == '') or (beginTime ==null and endTime == null)">
                a1.dev_id =  b.DI_Code
            </if>
            <if test="devId != null and devId != '' ">
                and a1.dev_id = #{devId} and b.DI_Code = #{devId}
@@ -109,7 +127,7 @@
    <!-- 多选店铺名 返回多选店铺最新一条数据-->
    <select id="findLaststById" resultType="com.job.zsc.pojo.FumeHistoryData">
        SELECT a.MV_Stat_Code, b.DI_Name, a.MV_Data_Time,a.MV_Fan_Electricity,a.MV_Purifier_Electricity,a.MV_Fume_Concentration2
        SELECT a.MV_Stat_Code, b.DI_Name, b.DI_Supplier, a.MV_Data_Time,a.MV_Fan_Electricity,a.MV_Purifier_Electricity,a.MV_Fume_Concentration2
        FROM fd_t_minutevalue as a
        JOIN ea_t_device_info  as b ON a.MV_Stat_Code = b.DI_Code
        JOIN (
@@ -129,15 +147,12 @@
    <!-- 条件组合查询异常表  异常类型选项改为多选-->
    <select id="conditonQueryAbnormalData2" resultType="com.job.zsc.pojo.FumeAbnormalData">
        select a1.dev_id,b.DI_Name,a1.exception,a1.exception_type,a1.region,a1.begin_time,a1.end_time
        from abnormal_data as a1,ea_t_device_info as b
        select a1.dev_id,b.DI_Name,b.DI_Supplier,a1.exception,a1.exception_type,a1.region,a1.begin_time,a1.end_time
        from abnormal_data as a1 join ea_t_device_info as b on  a1.dev_id =  b.DI_Code
        <where>
            <if test="(devId ==null or devId == '') or (beginTime ==null and endTime == null)">
                a1.dev_id =  b.DI_Code
            </if>
            <if test="devId != null and devId != '' ">
                and a1.dev_id = #{devId} and b.DI_Code = #{devId}
                and a1.dev_id = #{devId}
            </if>
            <if test="exceptionValue != null and exceptionValue != '' ">
@@ -157,12 +172,8 @@
    <!-- 条件组合查询异常表  异常类型选项改为多选-->
    <select id="conditonQueryAbnormalData3" resultType="com.job.zsc.pojo.FumeAbnormalData">
        select a1.dev_id,b.DI_Name,a1.exception,a1.exception_type,a1.region,a1.begin_time,a1.end_time
        from abnormal_data as a1,ea_t_device_info as b
        from abnormal_data as a1 join ea_t_device_info as b on a1.dev_id =  b.DI_Code
        <where>
            <if test="(devId ==null or devId == '') or (beginTime ==null and endTime == null)">
                a1.dev_id =  b.DI_Code
            </if>
            <if test="devId != null and devId != '' ">
                and a1.dev_id = #{devId} and b.DI_Code = #{devId}
            </if>