<?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.status, ta.project_code as projectCode, th.project_name as projectName, ta.create_time as createTime 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 and ta.del_flag = 0 <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> <choose> <when test="request.orderBy != null and request.orderBy != ''"> order by ${request.orderBy} </when> <otherwise> order by -tb.yesnoant desc, tb.uptime desc </otherwise> </choose> </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.category != null and request.category != ''"> and tb.category = #{request.category} </if> <if test="request.starttime != null and request.starttime != ''"> and ta.uptime > #{request.starttime} </if> <if test="request.endtime != null and request.endtime != ''"> and ta.uptime < #{request.endtime} </if> ORDER BY date desc </select> <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>