| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208 |
- <?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.gbd.demp.info.mapper.DeviceInfoMapper">
- <resultMap id="deviceInfo" type="com.gbd.demp.info.entity.DeviceInfo">
- <result column="device_id" jdbcType="VARCHAR" property="deviceId"/>
- <result column="device_name" jdbcType="VARCHAR" property="deviceName"/>
- <result column="device_start_date" jdbcType="DATE" property="deviceStartDate"/>
- <result column="industry_code" jdbcType="VARCHAR" property="industryCode"/>
- <result column="industry_value" jdbcType="VARCHAR" property="industryValue"/>
- <result column="dust_type" jdbcType="VARCHAR" property="dustType"/>
- <result column="dust_name" jdbcType="VARCHAR" property="dustName"/>
- <result column="company_id" jdbcType="VARCHAR" property="companyId"/>
- <result column="company_name" jdbcType="VARCHAR" property="companyName"/>
- <result column="device_location" jdbcType="VARCHAR" property="deviceLocation"/>
- <result column="possession" jdbcType="VARCHAR" property="possession"/>
- <result column="work_time_from" jdbcType="VARCHAR" property="workTimeFrom"/>
- <result column="work_time_to" jdbcType="VARCHAR" property="workTimeTo"/>
- <result column="longitude" jdbcType="DOUBLE" property="longitude"/>
- <result column="latitude" jdbcType="DOUBLE" property="latitude"/>
- <result column="editable" jdbcType="INTEGER" property="editable"/>
- </resultMap>
- <resultMap id="sensorInfo" type="com.gbd.demp.info.entity.SensorInfo">
- <result column="id" jdbcType="BIGINT" property="id"/>
- <result column="sensor_id" jdbcType="VARCHAR" property="sensorId"/>
- <result column="device_id" jdbcType="VARCHAR" property="deviceId"/>
- <result column="device_name" jdbcType="VARCHAR" property="deviceName"/>
- <result column="company_name" jdbcType="VARCHAR" property="companyName"/>
- <result column="sensor_name" jdbcType="VARCHAR" property="sensorName"/>
- <result column="sensor_unit" jdbcType="VARCHAR" property="sensorUnit"/>
- </resultMap>
- <resultMap id="videoInfo" type="com.gbd.demp.info.entity.VideoInfo">
- <result column="company_id" jdbcType="VARCHAR" property="companyId"/>
- <result column="company_name" jdbcType="VARCHAR" property="companyName"/>
- <result column="detail_name" jdbcType="VARCHAR" property="detailName"/>
- <result column="id" jdbcType="VARCHAR" property="id"/>
- <result column="place_info" jdbcType="VARCHAR" property="placeInfo"/>
- <result column="puid" jdbcType="VARCHAR" property="puid"/>
- <result column="show_name" jdbcType="VARCHAR" property="showName"/>
- <result column="status" jdbcType="VARCHAR" property="status"/>
- <result column="type" jdbcType="VARCHAR" property="type"/>
- </resultMap>
- <sql id="findDeviceInfoSql">
- SELECT
- device_id,
- device_name,
- device_start_date,
- t.industry_code,
- t1.value industry_value,
- t.dust_type,
- t2.dust_name,
- company_id,
- company_name,
- device_location,
- possession,
- work_time_from,
- work_time_to,
- longitude,
- latitude,
- editable
- FROM
- t_device_info t
- left join t_code_industry t1 on t.industry_code=t1.code
- left join t_code_dust_type t2 on t.dust_type=t2.code
- where 1=1
- <if test="deviceInfo.deviceId != null and deviceInfo.deviceId != ''">
- AND t.device_id = #{deviceInfo.deviceId}
- </if>
- <if test="deviceInfo.possession != null and deviceInfo.possession != ''">
- AND t.possession = #{deviceInfo.possession}
- </if>
- <if test="deviceInfo.deviceName != null and deviceInfo.deviceName != ''">
- AND t.device_name like CONCAT('%', #{deviceInfo.deviceName}, '%')
- </if>
- <if test="deviceInfo.startTimeFrom != null and deviceInfo.startTimeFrom !=''">
- And t.device_start_date > #{deviceInfo.startTimeFrom}
- </if>
- <if test="deviceInfo.startTimeTo!= null and deviceInfo.startTimeTo !=''">
- And t.device_start_date < #{deviceInfo.startTimeTo}
- </if>
- <if test="deviceInfo.companyId != null and deviceInfo.companyId != ''">
- AND t.company_id = #{deviceInfo.companyId}
- </if>
- <if test="deviceInfo.companyName != null and deviceInfo.companyName != ''">
- AND t.company_name like CONCAT('%', #{deviceInfo.companyName}, '%')
- </if>
- <if test="deviceInfo.editable != null and deviceInfo.editable != 0">
- AND t.editable = #{deviceInfo.editable}
- </if>
- group by
- t.device_id,
- t.device_name,
- t.industry_code,
- t.dust_type,
- t.company_id,
- t.company_name,
- t.device_location,
- t.possession
- </sql>
- <sql id="findClickInfoSql">
- /*select
- tdi.device_id AS deviceId,
- tdi.company_name AS companyName,
- tdi.device_name AS monitorName,
- '0' AS ifShow,
- '' AS videoId,
- tsv.sensor_id AS sensorId,
- tsi.sensor_name AS name,
- tsi.sensor_unit AS unit,
- tcar.value AS detail,
- tld.data_value AS value,
- tcar.color AS color,
- tvi.detail_name AS videoName,
- tvi.puid AS videoCode
- from t_sensor_video tsv
- left join t_video_info tvi on tvi.id = tsv.video_id
- left join t_sensor_info tsi on tsi.sensor_id = tsv.sensor_id and tsi.device_id=tsv.device_id
- left join t_device_info tdi on tdi.device_id = tsv.device_id
- left join t_live_data tld on tld.sensor_id = tsv.sensor_id and tld.device_id=tsv.device_id
- left join t_code_alarm_rules tcar on tcar.code = tld.status
- left join t_alarm_event tae on tae.device_id=tsv.device_id and tae.sensor_id=tsv.sensor_id
- where 1=1*/
- select
- tdi.device_id AS deviceId,
- tdi.company_name AS companyName,
- tdi.device_name AS monitorName,
- '0' AS ifShow,
- '' AS videoId,
- tld.sensor_id AS sensorId,
- tsi.sensor_name AS name,
- tsi.sensor_unit AS unit,
- tcar.value AS detail,
- tld.data_value AS value,
- tcar.color AS color,
- tvi.detail_name AS videoName,
- tvi.puid AS videoCode
- from t_live_data tld
- left join t_sensor_video tsv on tld.sensor_id = tsv.sensor_id and tld.device_id=tsv.device_id
- left join t_video_info tvi on tsv.video_id = tvi.id
- left join t_sensor_info tsi on tld.sensor_id = tsi.sensor_id and tld.device_id=tsi.device_id
- left join t_device_info tdi on tld.device_id = tdi.device_id
- left join t_code_alarm_rules tcar on tcar.code = tld.status
- left join t_alarm_event tae on tld.device_id=tae.device_id and tld.sensor_id=tae.sensor_id
- where 1=1
- <!--toto -->
- <if test="companyId != null and companyId != ''">
- AND tdi.company_id = #{companyId}
- </if>
- <if test="deviceId != null and deviceId != ''">
- AND tdi.device_id = #{deviceId}
- </if>
- <if test="alarmId != null and alarmId != ''">
- AND tae.third_party_id = #{alarmId}
- </if>
- group by
- tdi.device_id
- </sql>
- <select id="findAllDeviceInfoPage" resultMap="deviceInfo">
- <include refid="findDeviceInfoSql"/>
- </select>
- <update id="setWorkTime">
- update t_device_info
- set work_time_from=#{from},
- work_time_to=#{to}
- where device_id = #{id}
- </update>
- <!-- 2. 监测企业点位信息 -->
- <select id="findAll" resultMap="deviceInfo">
- select *
- from t_device_info
- </select>
- <!-- 3. 监测图层点击详情 -->
- <select id="getMonitorLayerClickMap" resultType="com.gbd.demp.info.vo.DeviceEventVO">
- <include refid="findClickInfoSql"/>
- </select>
- <update id="unlockEdit">
- update t_device_info
- set editable=1
- where device_id = #{id}
- </update>
- <select id="getCompanys" resultType="java.util.HashMap">
- SELECT company_id value,company_name label FROM t_device_info
- where 1=1
- <if test="possession != null and possession != ''">
- AND possession = #{possession}
- </if>
- group by company_id,company_name
- </select>
- </mapper>
|