Newer
Older
newfiber-termite / newfiber-termites / newfiber-termites-dataup / src / main / resources / mapper / termite / TermiteMapper.xml
@xiongkai xiongkai on 2 Jul 5 KB 集成mq
<?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.newfiber.termite.mapper.TermiteMapper">

    <select id="querytermiteData" resultType="com.newfiber.termite.domain.response.TermiteInfoResponse">
        SELECT
        ta.id as deviceId,
        tb.id,
        ta.category,
        ta.sn,
        ta.location,
        ta.lonandlat,
        tb.date,
        tb.yesnoant,
        tb.rtpitcu,
        tb.idenpitcu,
        tb.idencolle,
        tb.druing,
        tb.druing_datetime,
        tb.heating,
        tb.heating_datetime,
        tb.uptime,
        ta.project_code as projectCode,
        th.project_name as projectName
        FROM
        `ter_device_info` ta
        left join ter_project_info th on ta.project_code =th.project_code
        LEFT JOIN ter_device_monitoring_data_realtime tb ON ta.sn = tb.sn
      where 1=1
        <if test="request.sn != null and request.sn != ''">
            and ta.sn  like concat('%',#{request.sn},'%')
        </if>
        <if test="request.uptime != null and request.uptime != ''">
            and tb.uptime  like concat('%',#{request.uptime},'%')
        </if>
        <if test="request.location != null and request.location != ''">
            and ta.location  like concat('%',#{request.location},'%')
        </if>
        <if test="request.yesnoant != null and request.yesnoant != ''">
            and tb.yesnoant =#{request.yesnoant}
        </if>
        <if test="request.idencolle != null and request.idencolle != ''">
            and tb.idencolle =#{request.idencolle}
        </if>
        <if test="request.druing != null and request.druing != ''">
            and tb.druing =#{request.druing}
        </if>
        <if test="request.projectCode != null and request.projectCode != ''">
            and th.project_code =#{request.projectCode}
        </if>
        <if test="request.category != null and request.category != ''">
            and ta.category =#{request.category}
        </if>
        <if test="request.projectCodeList != null and request.projectCodeList.size > 0">
            and th.project_code in
            <foreach collection="request.projectCodeList" item="projectCode" index="index" open="(" close=")" separator=",">
                #{projectCode}
            </foreach>
        </if>

      order by  -tb.yesnoant desc, ta.create_time desc
    </select>

    <update id="updateMonitorDevice">
        UPDATE `ter_device_info`
        SET
            `project_code` = #{request.projectCode},
            `location` = #{request.location},
            `lonandlat` = #{request.lonandlat},
            `sn` = #{request.sn}
        WHERE
            `id` =#{request.id};
    </update>

    <select id="queryhistoryData" resultType="com.newfiber.termite.domain.response.TermiteInfoResponse">
        SELECT
            ta.id,
            ta.sn,
            ta.date,
            ta.yesnoant,
            ta.rtpitcu,
            ta.idenpitcu,
            ta.idencolle,
            ta.druing,
            ta.uptime,
            tb.location
        FROM
        ter_device_monitoring_data ta
                left join ter_device_info tb on ta.sn=tb.sn
        where ta.sn=#{request.sn}
        <if test="request.yesnoant != null and request.yesnoant != ''">
            and ta.yesnoant =#{request.yesnoant}
        </if>
        <if test="request.idencolle != null and request.idencolle != ''">
            and ta.idencolle =#{request.idencolle}
        </if>
        <if test="request.druing != null and request.druing != ''">
            and ta.druing =#{request.druing}
        </if>

        <if test="request.starttime != null and request.starttime != ''">
            and ta.uptime  &gt;  #{request.starttime}
        </if>

        <if test="request.endtime != null and request.endtime != ''">
            and ta.uptime &lt;  #{request.endtime}
        </if>
        ORDER BY date desc
    </select>



    <insert id="insertMonitorDevice">

        INSERT INTO `ter_device_info` ( `sn`, `location`, `lonandlat`,`project_code`, `category` )
        VALUES
            ( #{request.sn}, #{request.location}, #{request.lonandlat},#{request.projectCode} ,#{request.category});
    </insert>

    <update id="removeMonitorDevice">
        UPDATE `ter_device_info`
        SET
            `del_flag` = '1'
        WHERE
            `id` = #{id};
    </update>


    <select id="querynewphoto" resultType="java.lang.String">
        select rtpitcu from ter_device_monitoring_data where sn=#{sn} order by uptime desc limit 1
    </select>


    <update id="updateModlefirstData">
        UPDATE `ter_device_info`
        SET
            `initialpictu` = #{newphoto}
        WHERE
            `sn` = #{sn}
    </update>

    <resultMap type="com.newfiber.termite.domain.response.DataUpResponse" id="DataUpResponseResult">
        <result property="druing" column="druing"/>
        <result property="heating" column="heating"/>
    </resultMap>
    <select id="queryDataUpResponse" resultMap="DataUpResponseResult">
        select druing, heating from ter_device_monitoring_data where sn=#{sn} order by uptime desc  limit 1
    </select>

    <select id="queryUnitdata" resultType="com.newfiber.termite.domain.dto.UnitInfoDto">
        SELECT
            construction_unit,
            people,
            telephone
        FROM
            `ter_unit_info`
        where is_choose = 1
    </select>
</mapper>