<?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.DeviceMonitoringDataRealtimeMapper"> <!-- 通用查询映射结果 --> <resultMap type="com.newfiber.termite.domain.DeviceMonitoringDataRealtime" id="DeviceMonitoringDataRealtimeResult"> <result property="id" column="id"/> <result property="sn" column="sn"/> <result property="date" column="date"/> <result property="yesnoant" column="yesnoant"/> <result property="rtpitcu" column="rtpitcu"/> <result property="idenpitcu" column="idenpitcu"/> <result property="idencolle" column="idencolle"/> <result property="antNumber" column="ant_number"/> <result property="otherAntNumber" column="other_ant_number"/> <result property="druing" column="druing"/> <result property="druingDatetime" column="druing_datetime"/> <result property="heating" column="heating"/> <result property="heatingDatetime" column="heating_datetime"/> <result property="uptime" column="uptime"/> <result property="projectCode" column="project_code"/> </resultMap> <!-- 通用查询结果列 --> <sql id="Base_Column_List"> t.id , t.sn , t.date , t.yesnoant , t.rtpitcu , t.idenpitcu , t.idencolle , t.ant_number , t.other_ant_number , t.druing , t.druing_datetime , t.heating , t.heating_datetime , t.uptime , tpi.project_code </sql> <sql id="Where_Condition"> <if test="request.sn != null and request.sn != ''"> and t.sn = #{request.sn} </if> <if test="request.date != null and request.date != ''"> and t.date = #{request.date} </if> <if test="request.yesnoant != null and request.yesnoant != ''"> and t.yesnoant = #{request.yesnoant} </if> <if test="request.userId != null and request.userId != ''"> and pu.user_id = #{request.userId} </if> <if test="request.projectCodeList != null and !request.projectCodeList.isEmpty()"> and tpi.project_code in <foreach item="projectCode" collection="request.projectCodeList" open="(" separator="," close=")"> #{projectCode} </foreach> </if> </sql> <sql id="Join_Table"> left join ter_device_info di on t.sn = di.sn left join ter_project_info tpi on di.project_code = tpi.project_code <if test="request.userId != null and request.userId != ''"> left join ter_project_user pu on tpi.project_code = pu.project_code </if> </sql> <select id="selectByCondition" resultMap="DeviceMonitoringDataRealtimeResult"> select <include refid="Base_Column_List"/> from ter_device_monitoring_data_realtime t <include refid="Join_Table"/> where t.del_flag = 0 <include refid="Where_Condition"/> order by t.${request.orderBy} </select> <select id="selectOneById" resultMap="DeviceMonitoringDataRealtimeResult"> select <include refid="Base_Column_List"/> from ter_device_monitoring_data_realtime t <include refid="Join_Table"/> where t.id = #{id} and t.del_flag = 0 </select> <delete id="deleteBySn"> delete from ter_device_monitoring_data_realtime where sn = #{sn} </delete> <select id="statistics" resultType="com.newfiber.termite.domain.response.statistic.MonitoringWarnResponseStatistics"> select tpi.project_name, di.project_code as projectCode, count(1) as warnCount from ter_device_monitoring_data_realtime t <include refid="Join_Table"/> where t.del_flag = 0 <include refid="Where_Condition"/> and (di.project_code != '' or di.project_code != null) group by di.project_code, tpi.project_name </select> </mapper>