<?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.api.pc.dao.monitoring.ProSiteWarnDao"> <!-- 可根据自己的需求,是否要使用 --> <resultMap type="com.newfiber.api.pc.model.entity.ProSiteWarnEntity" id="proSiteWarnMap"> <result property="id" column="id"/> <result property="siteNo" column="site_no"/> <result property="factorsAscii" column="factors_ascii"/> <result property="factorsName" column="factors_name"/> <result property="warnValue" column="warn_value"/> <result property="warnType" column="warn_type"/> <result property="warnTypeDesc" column="warn_type_desc"/> <result property="compareWay" column="compare_way"/> <result property="compareWayDesc" column="compare_way_desc"/> <result property="createTime" column="create_time"/> </resultMap> <!-- 通用查询结果列 --> <sql id="Base_Column_List"> <trim suffixOverrides=","> sw.id, sw.site_no, sw.factors_ascii, sw.factors_name, sw.warn_value, sw.warn_type, sw.warn_type_desc, sw.compare_way, sw.compare_way_desc, sw.create_time, </trim> </sql> <!-- 获取警戒线配置表列表 --> <select id="queryList" resultType="com.newfiber.api.pc.model.entity.ProSiteWarnEntity"> select <include refid="Base_Column_List" />,f.factors_unit from pro_site_warn sw inner join pro_factors_info f on sw.factors_ascii = f.factors_ascii where 1 = 1 <if test="siteNo != null"> and sw.site_no = #{siteNo} </if> <if test="fuzzyQuery != null and fuzzyQuery.trim() != ''"> and concat(sw.factors_ascii,sw.factors_name) like concat('%',#{fuzzyQuery},'%') </if> <if test="factorsAscii != null"> and sw.factors_ascii = #{factorsAscii} </if> <if test="warnType != null"> and sw.warn_type = #{warnType} </if> <choose> <when test="sidx != null and sidx.trim() != ''"> order by ${sidx} ${order} </when> <otherwise> order by sw.id desc </otherwise> </choose> </select> <update id="updateBySiteNoAndCodeASCII"> update pro_site_warn <set> <if test="warnValue != null"> warn_value = #{warnValue}, </if> <if test="compareWay != null"> compare_way = #{compareWay}, </if> <if test="compareWayDesc != null"> compare_way_desc = #{compareWayDesc}, </if> </set> where site_no = #{siteNo} and factors_ascii = #{factorsAscii} and warn_type = #{warnType} </update> <select id="listNotAllocated" resultType="ProFactorsInfoEntity"> select f.id,f.factors_no,f.factors_code,f.factors_ascii,f.factors_name,f.factors_unit,f.factors_max_v,f.factors_mix_v,f.factors_order,f.create_time,f.factors_reserve1,f.factors_reserve2 from pro_factors_info f inner join pro_equip_factors ef on f.factors_no = ef.factors_no inner join pro_site_equip se on ef.equip_no = se.equip_no left join pro_site_warn sw on se.site_no = sw.site_no and f.factors_ascii = sw.factors_ascii and warn_type = #{warnType} where sw.factors_ascii is null and se.site_no = #{siteNo} </select> <resultMap id="siteWarnResultMap" type="SiteHaveWarnEntity"> <id column="site_no" property="siteNo" jdbcType="VARCHAR"/> <result column="site_name" property="siteName" jdbcType="VARCHAR"/> <collection property="list" column="site_no" ofType="WarnProprtyEntity" select="com.newfiber.api.pc.dao.ProSiteWarnDao.getWarnProprty"/> </resultMap> <select id="getSiteHaveWarn" resultMap="siteWarnResultMap"> select distinct w.site_no,s.site_name from pro_site_warn w inner join pro_site_info s on w.site_no = s.site_no </select> <select id="getWarnProprty" resultType="WarnProprtyEntity"> select factors_ascii,factors_name, max(case warn_type when 1 then warn_value else null end ) warnValue, max(case warn_type when 1 then compare_way else null end ) warnCompareWay, max(case warn_type when 2 then warn_value else null end ) alarmValue, max(case warn_type when 2 then compare_way else null end ) alarmCompareWay from pro_site_warn where site_no = #{siteNo} group by factors_ascii,factors_name </select> </mapper>