<?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.ProSiteInfoDao"> <!-- 可根据自己的需求,是否要使用 --> <resultMap type="com.newfiber.api.pc.model.entity.ProSiteInfoEntity" id="proSiteInfoMap"> <result property="id" column="id"/> <result property="siteNo" column="site_no"/> <result property="siteName" column="site_name"/> <result property="siteAddr" column="site_addr"/> <result property="pointx" column="pointx"/> <result property="pointy" column="pointy"/> <result property="createTime" column="create_time"/> <result property="createUser" column="create_user"/> <result property="isEnable" column="is_enable"/> <result property="typeId" column="type_id"/> </resultMap> <!-- 通用查询结果列 --> <sql id="Base_Column_List"> <trim suffixOverrides=","> s.id, s.site_no, s.site_name, s.site_addr, s.pointx, s.pointy, s.create_time, s.create_user, s.is_enable, s.type_id, </trim> </sql> <select id="queryListWithPage" resultMap="siteResultMap"> select t.*,ti.type_name, f.id,f.file_no,f.file_extension,f.file_original_name,f.file_cloud_storage_key,file_abbreviated_cloud_storage_key,f.file_upload_type,f.file_upload_type_desc,f.type_selection,f.type_selection_desc, f.generation_time,f.update_time,f.file_founder,f.site_reserve1,f.site_reserve2 from (select s.* from pro_site_info s where 1 = 1 <if test="siteNo != null and siteNo.trim() != ''"> and s.site_no = #{siteNo} </if> <if test="typeId != null"> and s.type_id = #{typeId} </if> <if test="siteName != null"> and concat(s.site_no,s.site_name) like concat('%',#{siteName},'%') </if> <if test="pageSize > 0"> limit #{pageNo},#{pageSize} </if> ) t left join base_type_info ti on t.type_id = ti.id left join pro_site_file sf on t.site_no = sf.site_no and sf.type = 1 left join base_file_info f on f.file_no = sf.file_no <choose> <when test="sidx != null and sidx.trim() != ''"> order by ${sidx} ${order} </when> <otherwise> order by t.site_no </otherwise> </choose> </select> <!-- 获取站点基础表列表 --> <resultMap id="siteResultMap" type="ProSiteInfoEntity"> <result property="id" column="id"/> <result property="siteNo" column="site_no"/> <result property="siteName" column="site_name"/> <result property="siteAddr" column="site_addr"/> <result property="pointx" column="pointx"/> <result property="pointy" column="pointy"/> <result property="createTime" column="create_time"/> <result property="createUser" column="create_user"/> <result property="isEnable" column="is_enable"/> <result property="typeId" column="type_id"/> <!-- <collection property="fileList" column="site_no" ofType="BaseFileInfoEntity">--> <!-- <result property="id" column="f_id"/>--> <!-- <result property="fileNo" column="file_no"/>--> <!-- <result property="fileExtension" column="file_extension"/>--> <!-- <result property="fileOriginalName" column="file_original_name"/>--> <!-- <result property="fileCloudStorageKey" column="file_cloud_storage_key"/>--> <!-- <result property="fileAbbreviatedCloudStorageKey" column="file_abbreviated_cloud_storage_key"/>--> <!-- <result property="fileUploadType" column="file_upload_type"/>--> <!-- <result property="fileUploadTypeDesc" column="file_upload_type_desc"/>--> <!-- <result property="typeSelection" column="type_selection"/>--> <!-- <result property="typeSelectionDesc" column="type_selection_desc"/>--> <!-- <result property="generationTime" column="generation_time"/>--> <!-- <result property="updateTime" column="update_time"/>--> <!-- <result property="fileFounder" column="file_founder"/>--> <!-- <result property="siteReserve1" column="f_site_reserve1"/>--> <!-- <result property="siteReserve2" column="f_site_reserve2"/>--> <!-- </collection>--> </resultMap> <select id="queryList" resultMap="siteResultMap"> select <include refid="Base_Column_List" />,t.type_name, f.id f_id,f.file_no,f.file_extension,f.file_original_name,f.file_cloud_storage_key,f.file_abbreviated_cloud_storage_key,f.file_upload_type,f.file_upload_type_desc,f.type_selection,f.type_selection_desc, f.generation_time,f.update_time,f.file_founder,f.site_reserve1 f_site_reserve1,f.site_reserve2 f_site_reserve2 from pro_site_info s left join base_type_info t on s.type_id = t.id left join pro_site_file sf on s.site_no = sf.site_no and sf.type = 1 left join base_file_info f on f.file_no = sf.file_no where 1 = 1 <if test="siteNo != null and siteNo.trim() != ''"> and s.site_no = #{siteNo} </if> <if test="typeId != null"> and s.type_id = #{typeId} </if> <if test="siteName != null"> and concat(s.site_no,s.site_name) like concat('%',#{siteName},'%') </if> <choose> <when test="sidx != null and sidx.trim() != ''"> order by ${sidx} ${order} </when> <otherwise> order by s.site_no </otherwise> </choose> </select> <update id="updateBySiteNo" parameterType="com.newfiber.api.pc.model.entity.ProSiteInfoEntity"> update pro_site_info <set> <if test="siteName != null"> site_name = #{siteName}, </if> <if test="siteAddr != null"> site_addr = #{siteAddr}, </if> <if test="pointx != null"> pointx = #{pointx}, </if> <if test="pointy != null"> pointy = #{pointy}, </if> <if test="siteNumber != null"> site_number = #{siteNumber}, </if> <if test="isEnable != null"> is_enable = #{isEnable}, </if> <if test="siteOrder != null"> site_order = #{siteOrder}, </if> <if test="typeId != null"> type_id = #{typeId}, </if> <if test="topFlag != null"> top_flag = #{topFlag}, </if> </set> where site_no = #{siteNo} </update> <select id="havaAllocated" resultType="com.newfiber.api.pc.model.entity.ProEquipInfoEntity"> select e.id,e.equip_no,e.equip_desc,e.equip_factory,e.create_time from pro_equip_info e <choose> <when test="flag"> inner join pro_site_equip se on e.equip_no = se.equip_no where se.site_no = #{siteNo} </when> <otherwise> left join pro_site_equip se on e.equip_no = se.equip_no and se.site_no = #{siteNo} where se.equip_no is null </otherwise> </choose> <if test="equipDesc != null"> and e.equip_desc like concat('%',#{equipDesc},'%') </if> </select> <select id="getTypeSiteCount" parameterType="java.lang.Long" resultType="java.util.Map"> select t.id,t.type_name,count(s.site_no) count from base_type_info t left join pro_site_info s on t.id = s.type_id where t.parentid = #{parentId} group by t.id,t.type_name </select> <select id="listFactorsByNo" parameterType="java.lang.String" resultType="ProFactorsInfoEntity"> select distinct 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 ef.factors_no = f.factors_no inner join pro_site_equip se on se.equip_no = ef.equip_no where se.site_no = #{siteNo} order by f.factors_order </select> <select id="listFactorsBySiteType" parameterType="java.lang.Long" resultType="ProFactorsInfoEntity"> select distinct 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 ef.factors_no = f.factors_no inner join pro_site_equip se on se.equip_no = ef.equip_no inner join pro_site_info s on se.site_no = s.site_no where s.type_id = #{typeId} order by f.factors_order </select> <resultMap id="sitePropertyResultMap" type="ProSiteInfoEntity"> <result property="id" column="s_id"/> <result property="siteNo" column="site_no"/> <result property="siteName" column="site_name"/> <result property="siteAddr" column="site_addr"/> <result property="pointx" column="pointx"/> <result property="pointy" column="pointy"/> <result property="createTime" column="s_create_time"/> <result property="createUser" column="create_user"/> <result property="isEnable" column="is_enable"/> <result property="typeId" column="type_id"/> <collection property="list" resultMap="com.newfiber.api.pc.dao.monitoring.ProFactorsInfoDao.proFactorsInfoMap"/> </resultMap> <select id="getSiteByType" resultMap="sitePropertyResultMap"> select s.id s_id, s.site_no, s.site_name, s.site_addr, s.pointx, s.pointy, s.create_time s_create_time, s.create_user, s.is_enable, s.type_id, 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_site_info s left join base_type_info t on s.type_id = t.id left join pro_site_equip se on s.site_no = se.site_no left join pro_equip_factors ef on se.equip_no = ef.equip_no left join pro_factors_info f on ef.factors_no = f.factors_no where 1 = 1 <if test="typeId != null"> and s.type_id = #{typeId} </if> <if test="fuzzyQuery != null and fuzzyQuery.trim() != ''"> and s.site_name like concat('%',#{fuzzyQuery},'%') </if> </select> <resultMap id="myResultMap" type="ProSiteInfoEntity"> <result property="id" column="id"/> <result property="siteNo" column="site_no"/> <result property="siteName" column="site_name"/> <result property="siteAddr" column="site_addr"/> <result property="pointx" column="pointx"/> <result property="pointy" column="pointy"/> <result property="createTime" column="create_time"/> <result property="createUser" column="create_user"/> <result property="isEnable" column="is_enable"/> <result property="typeId" column="type_id"/> <collection property="warnLogs" column="site_no" ofType="ProWarnLogEntity" columnPrefix="w_"> <result property="id" column="id"/> <result property="siteNo" column="site_no"/> <result property="siteName" column="site_name"/> <result property="warnType" column="warn_type"/> <result property="warnTypeDesc" column="warn_type_desc"/> <result property="factorsAscii" column="factors_ascii"/> <result property="factorsName" column="factors_name"/> <result property="warnValue" column="warn_value"/> <result property="ttTime" column="tt_time"/> <result property="createTime" column="create_time"/> </collection> <collection property="warnProprties" column="site_no" ofType="WarnProprtyEntity" columnPrefix="sw_"> <result property="factorsAscii" column="factors_ascii"/> <result property="factorsName" column="factors_name"/> <result property="warnValue" column="warnValue"/> <result property="warnCompareWay" column="warnCompareWay"/> <result property="alarmValue" column="alarmValue"/> <result property="alarmCompareWay" column="alarmCompareWay"/> </collection> </resultMap> <select id="getSiteList" resultMap="myResultMap"> select <include refid="Base_Column_List" />,t.type_name, w.id w_id,w.site_no w_site_no,w.site_name w_site_name,w.warn_type w_warn_type,w.warn_type_desc w_warn_type_desc,w.factors_ascii w_factors_ascii,w.factors_name w_factors_name,w.warn_value w_warn_value,w.tt_time w_tt_time,w.create_time w_create_time ,sw.factors_ascii sw_factors_ascii,sw.factors_name sw_factors_name, max(case sw.warn_type when 1 then sw.warn_value else null end ) sw_warnValue, max(case sw.warn_type when 1 then sw.compare_way else null end ) sw_warnCompareWay, max(case sw.warn_type when 2 then sw.warn_value else null end ) sw_alarmValue, max(case sw.warn_type when 2 then sw.compare_way else null end ) sw_alarmCompareWay from pro_site_info s left join base_type_info t on s.type_id = t.id left join (select l.* from pro_warn_log l inner join (select site_no,factors_ascii,warn_type,max(tt_time) maxtt from pro_warn_log where tt_time BETWEEN DATE_SUB(NOW(),INTERVAL 10 MINUTE) AND NOW() GROUP BY site_no,factors_ascii,warn_type) t on l.site_no = t.site_no AND l.factors_ascii = t.factors_ascii AND l.warn_type = t.warn_type AND l.tt_time = t.maxtt where l.warn_type = 1 or l.warn_type = 2) w on s.site_no = w.site_no left join pro_site_warn sw on s.site_no = sw.site_no <!--where 1 = 1 <if test="siteNo != null and siteNo.trim() != ''"> and s.site_no = #{siteNo} </if> <if test="typeId != null"> and s.type_id = #{typeId} </if> <if test="siteName != null"> and concat(s.site_no,s.site_name) like concat('%',#{siteName},'%') </if> group by <include refid="Base_Column_List" />,t.type_name, w.id,w.site_no,w.site_name,w.warn_type,w.warn_type_desc,w.factors_ascii,w.factors_name,w.warn_value,w.tt_time,w.create_time ,sw.factors_ascii,sw.factors_name <choose> <when test="sidx != null and sidx.trim() != ''"> order by ${sidx} ${order} </when> <otherwise> order by s.id desc </otherwise> </choose>--> </select> <resultMap id="siteStatusMap" type="ProSiteInfoEntity"> <result property="id" column="id"/> <result property="siteNo" column="site_no"/> <result property="siteName" column="site_name"/> <result property="siteAddr" column="site_addr"/> <result property="pointx" column="pointx"/> <result property="pointy" column="pointy"/> <result property="createTime" column="create_time"/> <result property="createUser" column="create_user"/> <result property="isEnable" column="is_enable"/> <result property="typeId" column="type_id"/> <!-- <collection property="fileList" column="site_no" ofType="BaseFileInfoEntity">--> <!-- <result property="id" column="f_id"/>--> <!-- <result property="fileNo" column="file_no"/>--> <!-- <result property="fileExtension" column="file_extension"/>--> <!-- <result property="fileOriginalName" column="file_original_name"/>--> <!-- <result property="fileCloudStorageKey" column="file_cloud_storage_key"/>--> <!-- <result property="fileAbbreviatedCloudStorageKey" column="file_abbreviated_cloud_storage_key"/>--> <!-- <result property="fileUploadType" column="file_upload_type"/>--> <!-- <result property="fileUploadTypeDesc" column="file_upload_type_desc"/>--> <!-- <result property="typeSelection" column="type_selection"/>--> <!-- <result property="typeSelectionDesc" column="type_selection_desc"/>--> <!-- <result property="generationTime" column="generation_time"/>--> <!-- <result property="updateTime" column="update_time"/>--> <!-- <result property="fileFounder" column="file_founder"/>--> <!-- <result property="siteReserve1" column="f_site_reserve1"/>--> <!-- <result property="siteReserve2" column="f_site_reserve2"/>--> <!-- </collection>--> <collection property="warnLogs" column="site_no" ofType="ProWarnLogEntity" columnPrefix="w_"> <result property="id" column="id"/> <result property="siteNo" column="site_no"/> <result property="siteName" column="site_name"/> <result property="warnType" column="warn_type"/> <result property="warnTypeDesc" column="warn_type_desc"/> <result property="factorsAscii" column="factors_ascii"/> <result property="factorsName" column="factors_name"/> <result property="warnValue" column="warn_value"/> <result property="ttTime" column="tt_time"/> <result property="createTime" column="create_time"/> </collection> </resultMap> <select id="getSiteStatusList" resultMap="siteStatusMap"> select <include refid="Base_Column_List" />,t.type_name, f.id f_id,f.file_no,f.file_extension,f.file_original_name,f.file_cloud_storage_key,file_abbreviated_cloud_storage_key,f.file_upload_type,f.file_upload_type_desc,f.type_selection,f.type_selection_desc, f.generation_time,f.update_time,f.file_founder,f.site_reserve1 f_site_reserve1,f.site_reserve2 f_site_reserve2, w.id w_id,w.site_no w_site_no,w.site_name w_site_name,w.warn_type w_warn_type,w.warn_type_desc w_warn_type_desc,w.factors_ascii w_factors_ascii,w.factors_name w_factors_name,w.warn_value w_warn_value,w.tt_time w_tt_time,w.create_time w_create_time from pro_site_info s left join base_type_info t on s.type_id = t.id left join pro_site_file sf on s.site_no = sf.site_no and sf.type = 1 left join base_file_info f on f.file_no = sf.file_no left join (select l.* from pro_warn_log l inner join (select site_no,factors_ascii,warn_type,max(tt_time) maxtt from pro_warn_log where tt_time BETWEEN DATE_SUB(NOW(),INTERVAL 10 MINUTE) AND NOW() GROUP BY site_no,factors_ascii,warn_type) t on l.site_no = t.site_no AND l.factors_ascii = t.factors_ascii AND l.warn_type = t.warn_type AND l.tt_time = t.maxtt where l.warn_type = 1 or l.warn_type = 2) w on s.site_no = w.site_no where 1 = 1 <if test="siteNo != null and siteNo.trim() != ''"> and s.site_no = #{siteNo} </if> <if test="typeId != null"> and s.type_id = #{typeId} </if> <if test="siteName != null"> and concat(s.site_no,s.site_name) like concat('%',#{siteName},'%') </if> <choose> <when test="sidx != null and sidx.trim() != ''"> order by ${sidx} ${order} </when> <otherwise> order by s.site_no </otherwise> </choose> </select> <select id="query" resultType="com.newfiber.api.pc.model.entity.ProSiteInfoEntity"> select a.site_no,a.site_name,a.site_addr, a.pointx, a.pointy,type_id,b.device_code deviceId,b.channel_id channelId from pro_site_info a left join camera_info b on a.id=b.site_id where 1=1 <if test="type!=null and type>0"> and type_id != #{type} </if> </select> </mapper>