| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382 |
- <?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.sckw.slope.detection.dao.mysql.KwsDeviceMapper">
- <resultMap id="BaseResultMap" type="com.sckw.slope.detection.model.dos.mysql.KwsDevice">
- <!--@mbg.generated-->
- <!--@Table kws_device-->
- <id column="id" jdbcType="BIGINT" property="id" />
- <result column="attribute" jdbcType="INTEGER" property="attribute" />
- <result column="name" jdbcType="VARCHAR" property="name" />
- <result column="alias" jdbcType="VARCHAR" property="alias" />
- <result column="sn_code" jdbcType="VARCHAR" property="snCode" />
- <result column="sn_code_full_name" jdbcType="VARCHAR" property="snCodeFullName" />
- <result column="model_id" jdbcType="BIGINT" property="modelId" />
- <result column="mountain_id" jdbcType="VARCHAR" property="mountainId" />
- <result column="valid_time" jdbcType="TIMESTAMP" property="validTime" />
- <result column="secret_key" jdbcType="VARCHAR" property="secretKey" />
- <result column="relevance_level" jdbcType="VARCHAR" property="relevanceLevel" />
- <result column="inter_face" jdbcType="VARCHAR" property="interFace" />
- <result column="related" jdbcType="VARCHAR" property="related" />
- <result column="remark" jdbcType="VARCHAR" property="remark" />
- <result column="status" jdbcType="TINYINT" property="status" />
- <result column="create_by" jdbcType="BIGINT" property="createBy" />
- <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
- <result column="update_by" jdbcType="BIGINT" property="updateBy" />
- <result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
- <result column="del_flag" jdbcType="TINYINT" property="delFlag" />
- <result column="online" jdbcType="TINYINT" property="online" />
- </resultMap>
- <sql id="Base_Column_List">
- <!--@mbg.generated-->
- id, `attribute`, `name`, `alias`, sn_code, model_id, valid_time, secret_key, inter_face,relevance_level,sn_code_full_name,
- remark, `status`, create_by, create_time, update_by, update_time, del_flag,mountain_id,related,check_time,online
- </sql>
- <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
- <!--@mbg.generated-->
- select
- <include refid="Base_Column_List"/>
- from kws_device
- where del_flag = 0
- and id = #{id,jdbcType=BIGINT}
- </select>
- <select id="selectByDeviceParam" resultType="com.sckw.slope.detection.model.vo.DeviceVo">
- select DISTINCT d.id,
- d.name,
- manufacturer,
- m.name as m_name,
- m.device_type,
- d.remark,
- d.update_by,
- d.update_time,
- p.`name` as project_name,
- d.status,
- m.`name` as mName
- from kws_device as d
- inner join kws_device_model as m on d.model_id = m.id
- left join kws_project_device as pd on d.id = pd.device_id
- left join kws_project as p on pd.project_id = p.id
- WHERE d.del_flag = 0
- and m.del_flag = 0
- and d.mountain_id = #{deviceQuery.mountainId}
- <if test="deviceQuery.deviceName != null and deviceQuery.deviceName != ''">
- and d.name like concat('%', #{deviceQuery.deviceName}
- , '%')
- </if>
- <if test="deviceQuery.projectName != null and deviceQuery.projectName != ''">
- and p.name like concat('%', #{deviceQuery.projectName}
- , '%')
- </if>
- <if test="deviceQuery.id != null and deviceQuery.id != ''">
- and id = #{deviceQuery.id,jdbcType=BIGINT}
- </if>
- <if test="deviceQuery.deviceType != null and deviceQuery.deviceType != ''">
- and m.device_type = #{deviceQuery.deviceType,jdbcType=BIGINT}
- </if>
- <if test="deviceQuery.status != null and deviceQuery.status != ''">
- and d.status = #{deviceQuery.status,jdbcType=TINYINT}
- </if>
- <if test="deviceQuery.projectId != null and deviceQuery.projectId != ''">
- and p.id= #{deviceQuery.projectId,jdbcType=TINYINT}
- </if>
- <if test="deviceQuery.attribute != null and deviceQuery.attribute != ''">
- and attribute = #{deviceQuery.attribute,jdbcType=TINYINT}
- </if>
- order by d.create_time desc
- </select>
- <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
- <!--@mbg.generated-->
- delete
- from kws_device
- where id = #{id,jdbcType=BIGINT}
- </delete>
- <insert id="insertSelective" parameterType="com.sckw.slope.detection.model.dos.mysql.KwsDevice">
- <!--@mbg.generated-->
- insert into kws_device
- <trim prefix="(" suffix=")" suffixOverrides=",">
- <if test="id != null">
- id,
- </if>
- <if test="attribute != null">
- `attribute`,
- </if>
- <if test="name != null">
- `name`,
- </if>
- <if test="alias != null">
- `alias`,
- </if>
- <if test="snCode != null">
- sn_code,
- </if>
- <if test="modelId != null">
- model_id,
- </if>
- <if test="validTime != null">
- valid_time,
- </if>
- <if test="secretKey != null">
- secret_key,
- </if>
- <if test="interFace != null">
- interface,
- </if>
- <if test="remark != null">
- remark,
- </if>
- <if test="status != null">
- `status`,
- </if>
- <if test="createBy != null">
- create_by,
- </if>
- <if test="createTime != null">
- create_time,
- </if>
- <if test="updateBy != null">
- update_by,
- </if>
- <if test="updateTime != null">
- update_time,
- </if>
- <if test="delFlag != null">
- del_flag,
- </if>
- </trim>
- <trim prefix="values (" suffix=")" suffixOverrides=",">
- <if test="id != null">
- #{id,jdbcType=BIGINT},
- </if>
- <if test="attribute != null">
- #{attribute,jdbcType=INTEGER},
- </if>
- <if test="name != null">
- #{name,jdbcType=VARCHAR},
- </if>
- <if test="alias != null">
- #{alias,jdbcType=VARCHAR},
- </if>
- <if test="snCode != null">
- #{snCode,jdbcType=VARCHAR},
- </if>
- <if test="modelId != null">
- #{modelId,jdbcType=BIGINT},
- </if>
- <if test="validTime != null">
- #{validTime,jdbcType=TIMESTAMP},
- </if>
- <if test="secretKey != null">
- #{secretKey,jdbcType=VARCHAR},
- </if>
- <if test="interFace != null">
- #{interFace,jdbcType=VARCHAR},
- </if>
- <if test="remark != null">
- #{remark,jdbcType=VARCHAR},
- </if>
- <if test="status != null">
- #{status,jdbcType=TINYINT},
- </if>
- <if test="createBy != null">
- #{createBy,jdbcType=BIGINT},
- </if>
- <if test="createTime != null">
- #{createTime,jdbcType=TIMESTAMP},
- </if>
- <if test="updateBy != null">
- #{updateBy,jdbcType=BIGINT},
- </if>
- <if test="updateTime != null">
- #{updateTime,jdbcType=TIMESTAMP},
- </if>
- <if test="delFlag != null">
- #{delFlag,jdbcType=TINYINT},
- </if>
- </trim>
- </insert>
- <update id="updateByPrimaryKeySelective" parameterType="com.sckw.slope.detection.model.dos.mysql.KwsDevice">
- <!--@mbg.generated-->
- update kws_device
- <set>
- <if test="attribute != null">
- `attribute` = #{attribute,jdbcType=INTEGER},
- </if>
- <if test="name != null">
- `name` = #{name,jdbcType=VARCHAR},
- </if>
- <if test="alias != null">
- `alias` = #{alias,jdbcType=VARCHAR},
- </if>
- <if test="snCode != null">
- sn_code = #{snCode,jdbcType=VARCHAR},
- </if>
- <if test="modelId != null">
- model_id = #{modelId,jdbcType=BIGINT},
- </if>
- <if test="validTime != null">
- valid_time = #{validTime,jdbcType=TIMESTAMP},
- </if>
- <if test="secretKey != null">
- secret_key = #{secretKey,jdbcType=VARCHAR},
- </if>
- <if test="interFace != null">
- inter_face = #{interFace,jdbcType=VARCHAR},
- </if>
- <if test="remark != null">
- remark = #{remark,jdbcType=VARCHAR},
- </if>
- <if test="status != null">
- `status` = #{status,jdbcType=TINYINT},
- </if>
- <if test="createBy != null">
- create_by = #{createBy,jdbcType=BIGINT},
- </if>
- <if test="createTime != null">
- create_time = #{createTime,jdbcType=TIMESTAMP},
- </if>
- <if test="updateBy != null">
- update_by = #{updateBy,jdbcType=BIGINT},
- </if>
- <if test="updateTime != null">
- update_time = #{updateTime,jdbcType=TIMESTAMP},
- </if>
- <if test="delFlag != null">
- del_flag = #{delFlag,jdbcType=TINYINT},
- </if>
- </set>
- where id = #{id,jdbcType=BIGINT}
- </update>
- <update id="updateByPrimaryKey" parameterType="com.sckw.slope.detection.model.dos.mysql.KwsDevice">
- <!--@mbg.generated-->
- update kws_device
- set `attribute` = #{attribute,jdbcType=INTEGER},
- `name` = #{name,jdbcType=VARCHAR},
- `alias` = #{alias,jdbcType=VARCHAR},
- sn_code = #{snCode,jdbcType=VARCHAR},
- model_id = #{modelId,jdbcType=BIGINT},
- valid_time = #{validTime,jdbcType=TIMESTAMP},
- secret_key = #{secretKey,jdbcType=VARCHAR},
- inter_face = #{interFace,jdbcType=VARCHAR},
- remark = #{remark,jdbcType=VARCHAR},
- `status` = #{status,jdbcType=TINYINT},
- create_by = #{createBy,jdbcType=BIGINT},
- create_time = #{createTime,jdbcType=TIMESTAMP},
- update_by = #{updateBy,jdbcType=BIGINT},
- update_time = #{updateTime,jdbcType=TIMESTAMP},
- del_flag = #{delFlag,jdbcType=TINYINT}
- where id = #{id,jdbcType=BIGINT}
- </update>
- <select id="selectDeviceAllNotDeviceRelation" resultType="com.sckw.slope.detection.model.dto.DeviceDataDTO">
- SELECT c.id AS deviceId,
- c.alias as deviceAlias,
- c.`name` AS deviceName
- FROM kws_project a
- LEFT JOIN kws_device c ON a.mountain_id = c.mountain_id
- LEFT JOIN kws_device_model d ON c.model_id = d.id
- WHERE a.del_flag = 0
- AND c.del_flag = 0
- AND d.del_flag = 0
- AND c.id NOT in (SELECT DISTINCT a.relate_device_id
- FROM kws_device_relation a
- LEFT JOIN kws_project b ON a.mountain_id = b.mountain_id where a.del_flag = 0)
- AND c.id NOT in (SELECT DISTINCT a.device_id
- FROM kws_device_relation a
- LEFT JOIN kws_project b ON a.mountain_id = b.mountain_id where a.del_flag = 0)
- <if test="projectId != null and projectId != ''">
- AND a.id = #{projectId}
- </if>
- </select>
- <select id="selectDeviceAllAndProjectData"
- resultType="com.sckw.slope.detection.model.vo.AffiliationDeviceVO">
- SELECT a.id as deviceId,
- a.`name` as name,
- a.attribute as attribute,
- a.alias as alias,
- a.logic_alt as logicAlt,
- a.logic_lat as logicLat,
- a.logic_lng as logicLng
- FROM kws_device a
- LEFT JOIN kws_project_device b ON a.id = b.device_id
- LEFT JOIN kws_project c ON b.project_id = c.id
- WHERE
- a.del_flag=0
- and b.del_flag=0
- and c.del_flag=0
- and c.id = #{projectId}
- </select>
- <select id="selectDeviceAllByProjectAndMountainId" resultType="com.sckw.slope.detection.model.dto.ThresholdSelectDTO">
- SELECT b.id AS deviceId,
- b.alias AS deviceAlias,
- b.`name` AS deviceName
- FROM kws_project_device a
- LEFT JOIN kws_device b ON a.device_id = b.id
- WHERE a.del_flag = 0
- AND b.del_flag = 0
- AND a.mountain_id = b.mountain_id
- <if test="projectId != null and projectId != ''">
- and a.project_id = #{projectId}
- </if>
- <if test="mountainId != null and mountainId != ''">
- and a.mountain_id = #{mountainId}
- </if>
- <if test="status != null and status.size() > 0">
- and b.status in
- <foreach collection="status" separator="," open="(" close=")" item="status">
- #{status}
- </foreach>
- </if>
- </select>
- <select id="selectCountByProject" resultType="int">
- SELECT count(distinct c.id)
- FROM kws_project a
- LEFT JOIN kws_project_device b
- ON a.id = b.project_id
- LEFT JOIN kws_device c ON b.device_id = c.id
- WHERE a.del_flag = 0
- AND b.del_flag = 0
- AND c.del_flag = 0
- and a.mountain_id = b.mountain_id
- and b.mountain_id = c.mountain_id
- <if test="projectId != null and projectId != ''">
- and a.id=#{projectId}
- </if>
- </select>
- <select id="selectDeviceOnlineRateCountByProject" resultType="int">
- SELECT count(distinct c.id)
- FROM kws_project a
- LEFT JOIN kws_project_device b
- ON a.id = b.project_id
- LEFT JOIN kws_device c ON b.device_id = c.id
- WHERE a.del_flag = 0
- AND b.del_flag = 0
- AND c.del_flag = 0
- and a.mountain_id = b.mountain_id
- and b.mountain_id = c.mountain_id
- and c.online = 1
- <if test="projectId != null and projectId != ''">
- and a.id=#{projectId}
- </if>
- </select>
- <select id="selectListByModelType" resultType="java.util.Map">
- SELECT b.id as deviceId,
- b.name as deviceName,
- c.id as deviceModelId,
- c.`name` as deviceModelName,
- c.device_type as deviceType
- FROM kws_device b
- LEFT JOIN kws_device_model c ON b.model_id = c.id
- WHERE b.del_flag = 0
- and c.del_flag = 0
- <if test="modelType != null and modelType != ''">
- and c.device_type = #{modelType}
- </if>
- </select>
- </mapper>
|