| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177 |
- <?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.xunmei.iot.mapper.DiagnoseMissionChMapper">
- <select id="selectPageData" resultType="com.xunmei.iot.vo.sensor.DiagnoseMissionPageVo">
- select c.* from
- (
- select s.id,s.org_id, s.org_name,s.org_path, s.device_name, dvs.device_name as host_name,
- (select mission_id from iot_device_diagnose_mission_ch ch where ch.iot_token = s.iot_token
- and ch.device_product=s.device_product and ch.dvs = s.host_code and ch.channel = s.device_code limit 1) mission_id
- from iot_device_info s
- inner join iot_device_info dvs on dvs.iot_token = s.iot_token
- and dvs.device_product = s.device_product and dvs.device_code = s.host_code
- and dvs.deleted = 0 and s.enable = 0 and dvs.device_type = 1
- where s.deleted=0 and s.enable=0 and s.device_type = 2
- <if test="request.orgId!= null">
- and s.org_id=#{request.orgId}
- </if>
- <if test="request.orgPath!= null">
- and s.org_path like CONCAT(#{request.orgPath}, '%')
- </if>
- <if test="request.deviceName != null and request.deviceName!= ''">
- and s.device_name like CONCAT('%',#{request.deviceName},'%')
- </if>
- order by s.host_code ,cast(s.device_code as signed)
- ) c where 1=1
- <choose>
- <when test=" request.state == null">
- </when>
- <when test=" request.state == 0">
- and c.mission_id is null
- </when>
- <otherwise>
- and c.mission_id is not null
- </otherwise>
- </choose>
- <choose>
- <when test=" request.missionCode != null and request.missionCode != '' ">
- and c.mission_id = #{request.missionCode}
- </when>
- <otherwise>
- </otherwise>
- </choose>
- </select>
- <select id="selectCamerasCount" resultType="java.lang.Integer">
- select count(1) from
- (
- select s.iot_token,s.device_product,s.host_code dvs,s.device_code channel,
- (select mission_id from iot_device_diagnose_mission_ch ch where ch.iot_token = s.iot_token
- and ch.device_product=s.device_product and ch.dvs = s.host_code and ch.channel = s.device_code limit 1) mission_id
- from iot_device_info s
- inner join iot_device_info dvs on dvs.iot_token = s.iot_token
- and dvs.device_product = s.device_product and dvs.device_code = s.host_code
- and dvs.deleted = 0 and s.enable = 0 and dvs.device_type = 1
- where s.deleted=0 and s.enable=0 and s.device_type = 2
- <if test="request.orgId!= null">
- and s.org_id=#{request.orgId}
- </if>
- <if test="request.orgPath!= null">
- and s.org_path like CONCAT(#{request.orgPath}, '%')
- </if>
- <if test="request.deviceName != null and request.deviceName!= ''">
- and s.device_name like CONCAT('%',#{request.deviceName},'%')
- </if>
- order by s.host_code ,cast(s.device_code as signed)
- ) c where 1=1
- <choose>
- <when test=" request.state == null">
- </when>
- <when test=" request.state == 0">
- and c.mission_id is null
- </when>
- <otherwise>
- and c.mission_id is not null
- </otherwise>
- </choose>
- <choose>
- <when test=" request.missionCode != null and request.missionCode != '' ">
- and c.mission_id = #{request.missionCode}
- </when>
- <otherwise>
- </otherwise>
- </choose>
- </select>
- <select id="selectCamerasBind" resultType="com.xunmei.iot.vo.sensor.DiagnoseMissionBindVo">
- select c.* from
- (
- select s.iot_token,s.device_product,s.host_code dvs,s.device_code channel,ch.mission_id,ch.id,
- (select group_concat(threshold_code) from iot_device_diagnose_threshold_ch ch where ch.iot_token = s.iot_token
- and ch.device_product=s.device_product and ch.dvs = s.host_code and ch.channel = s.device_code) threshold_codes
- from iot_device_info s
- inner join iot_device_info dvs on dvs.iot_token = s.iot_token
- and dvs.device_product = s.device_product and dvs.device_code = s.host_code
- and dvs.deleted = 0 and s.enable = 0 and dvs.device_type = 1
- left join iot_device_diagnose_mission_ch ch on ch.iot_token = s.iot_token
- and ch.device_product=s.device_product and ch.dvs = s.host_code and ch.channel = s.device_code
- where s.deleted=0 and s.enable=0 and s.device_type = 2
- <if test="request.orgId!= null">
- and s.org_id=#{request.orgId}
- </if>
- <if test="request.orgPath!= null">
- and s.org_path like CONCAT(#{request.orgPath}, '%')
- </if>
- <if test="request.deviceName != null and request.deviceName!= ''">
- and s.device_name like CONCAT('%',#{request.deviceName},'%')
- </if>
- order by s.host_code ,cast(s.device_code as signed)
- ) c where 1=1
- <choose>
- <when test=" request.state == null">
- </when>
- <when test=" request.state == 0">
- and c.mission_id is null
- </when>
- <otherwise>
- and c.mission_id is not null
- </otherwise>
- </choose>
- <choose>
- <when test=" request.missionCode != null and request.missionCode != '' ">
- and c.mission_id = #{request.missionCode}
- </when>
- <otherwise>
- </otherwise>
- </choose>
- </select>
- <insert id="batchInsertMissionCh" parameterType="java.util.List">
- insert into iot_device_diagnose_mission_ch (id,mission_id,iot_token,device_product,dvs,channel)
- values
- <foreach collection="list" item="item" index="index" separator=",">
- (#{item.id},#{item.missionId},#{item.iotToken},#{item.deviceProduct},#{item.dvs}, #{item.channel})
- </foreach>
- </insert>
- <update id="batchUpdateMissionCh" parameterType="java.util.List">
- <foreach collection="list" item="item" index="index" open="" close="" separator=";">
- update iot_device_diagnose_mission_ch
- <set>
- <if test="item.missionId != null">
- mission_id = #{item.missionId},
- </if>
- </set>
- where iot_token = #{item.iotToken} and device_product = #{item.deviceProduct}
- and dvs = #{item.dvs} and channel = #{item.channel}
- </foreach>
- </update>
- <insert id="batchInsertThresholdCh" parameterType="java.util.List">
- insert into iot_device_diagnose_threshold_ch (id,threshold_code, iot_token,device_product,dvs,channel)
- values
- <foreach collection="list" item="item" index="index" separator="," >
- (#{item.id},#{item.thresholdCode},#{item.iotToken},#{item.deviceProduct},#{item.dvs}, #{item.channel})
- </foreach>
- </insert>
- <delete id="batchDeleteMissionCh" parameterType="java.lang.Long">
- delete from iot_device_diagnose_mission_ch where id in
- <foreach collection="ids" item="item" index="index"
- open="(" separator="," close=")">#{item}
- </foreach>
- </delete>
- <delete id="deleteCamerasByMissionId" parameterType="java.lang.String">
- delete from iot_device_diagnose_mission_ch where mission_id = #{missionId}
- </delete>
- <select id="selectAllDiagnoseMission" resultType="com.xunmei.common.core.domain.iot.domain.IotDeviceDiagnoseMission">
- select * from iot_device_diagnose_mission
- </select>
- </mapper>
|