| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192 |
- <?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.middle.platform.manage.biz.mapper.IotDeviceMapper">
- <resultMap id="BaseResultMap" type="com.middle.platform.manage.biz.entity.IotDevice">
- <!--@mbg.generated-->
- <!--@Table iot_device-->
- <id column="id" jdbcType="BIGINT" property="id"/>
- <result column="product_id" jdbcType="BIGINT" property="productId"/>
- <result column="name" jdbcType="VARCHAR" property="name"/>
- <result column="sn" jdbcType="VARCHAR" property="sn"/>
- <result column="guid" jdbcType="VARCHAR" property="guid"/>
- <result column="subtitle" jdbcType="VARCHAR" property="subtitle"/>
- <result column="lon" jdbcType="DECIMAL" property="lon"/>
- <result column="lat" jdbcType="DECIMAL" property="lat"/>
- <result column="address" jdbcType="VARCHAR" property="address"/>
- <result column="online_time" jdbcType="TIMESTAMP" property="onlineTime"/>
- <result column="status" jdbcType="TINYINT" property="status"/>
- <result column="enable_flag" jdbcType="TINYINT" property="enableFlag"/>
- <result column="remark" jdbcType="VARCHAR" property="remark"/>
- <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="delete_time" jdbcType="TIMESTAMP" property="deleteTime"/>
- <result column="del_flag" jdbcType="TINYINT" property="delFlag"/>
- </resultMap>
- <sql id="Base_Column_List">
- <!--@mbg.generated-->
- id,
- product_id,
- `name`,
- sn,
- guid,
- subtitle,
- lon,
- lat,
- address,
- online_time,
- `status`,
- enable_flag,
- remark,
- create_by,
- create_time,
- update_by,
- update_time,
- delete_time,
- del_flag
- </sql>
- <select id="queryByProduct" resultType="java.lang.Long">
- select count(1)
- from iot_device id
- <where>
- id.product_id = #{id,jdbcType=BIGINT}
- </where>
- </select>
- <!-- <select id="pageQuery" resultType="com.middle.platform.manage.biz.domain.vo.IotDeviceVo">-->
- <!-- select *-->
- <!-- from iot_device id-->
- <!-- <where>-->
- <!-- <if test="keywords != null and keywords != ''">-->
- <!-- and id.name like concat('%', #{keywords,jdbcType=VARCHAR}, '%')-->
- <!-- </if>-->
- <!-- </where>-->
- <!-- </select>-->
- <select id="queryTotalNumberOfDevices" resultType="int">
- select count(id) as num
- from iot_device
- <where>
- del_flag = 0
- and enable_flag = 1
- </where>
- </select>
- <select id="queryOnlineEquipment" resultType="int">
- select count(id) as num
- from iot_device
- <where>
- del_flag = 0
- and status = 1
- and enable_flag = 1
- </where>
- </select>
- <select id="queryTypeStatistics" resultType="com.middle.platform.manage.biz.domain.vo.TypeStatisticsVo">
- select ide.*,
- ipr.title projectTitle
- from iot_device ide
- left join iot_project_device ipd on ipd.device_id = ide.id
- left join iot_project ipr on ipr.id = ipd.project_id
- <where>
- ide.del_flag = 0
- and ide.enable_flag = 1
- <if test="deviceId != null">
- and ide.id = #{deviceId,jdbcType=BIGINT}
- </if>
- <if test="productId != null">
- and ipd.product_id = #{productId,jdbcType=BIGINT}
- </if>
- </where>
- </select>
- <select id="pageQuery" resultType="com.middle.platform.manage.biz.domain.vo.IotDeviceVo">
- select id.*, ip.name as productName
- from iot_device id
- inner join iot_product ip on id.product_id = ip.id and ip.del_flag = 0
- <where>
- <if test="keywords != null and keywords != ''">
- and id.name like concat('%', #{keywords,jdbcType=VARCHAR}, '%')
- </if>
- <if test="productId != null">
- and id.product_id = #{productId,jdbcType=BIGINT}
- </if>
- and id.del_flag = 0
- </where>
- </select>
- <select id="count" resultType="java.util.Map">
- select count(case when id.status = 1 then 1 end) online,
- count(case when id.status = 0 then 1 end) offline
- from iot_device id
- <where>
- <if test="productId != null">
- and id.product_id = #{productId,jdbcType=BIGINT}
- </if>
- and id.del_flag = 0
- </where>
- </select>
- <select id="detail" resultType="com.middle.platform.manage.biz.domain.vo.IotDeviceDetailVo">
- select id.id,
- id.name,
- id.sn,
- id.guid,
- id.subtitle,
- id.lat,
- id.lon,
- id.address,
- id.online_time,
- id.status,
- id.enable_flag,
- id.remark,
- id.create_time,
- id.create_by,
- id.update_time,
- id.update_by,
- ip.code productCode,
- ip.name productName,
- ip.secret,
- ip.node_type nodeType,
- ip.network_type networkType,
- ip.report_protocol reportProtocol,
- ip.data_format dataFormat,
- ip.auth_type authType,
- ip.vendors,
- ip.tag
- from iot_device id
- inner join iot_product ip on id.product_id = ip.id and ip.del_flag = 0
- where id.id = #{id,jdbcType=BIGINT}
- and id.del_flag = 0
- </select>
- <select id="query" resultType="com.middle.platform.manage.biz.domain.vo.ProductDeviceDto">
- select id.id,
- id.sn,
- ip.code
- from iot_device id
- inner join iot_product ip on id.product_id = ip.id and ip.del_flag = 0
- <where>
- <if test="id != null">
- and id.id = #{id,jdbcType=BIGINT}
- </if>
- and id.del_flag = 0
- </where>
- </select>
- <select id="deviceCache" resultType="com.middle.platform.manage.api.pojo.DeviceVo">
- select id.id,
- ip.id productId,
- id.sn,
- ip.code
- from iot_device id
- inner join iot_product ip on id.product_id = ip.id and ip.del_flag = 0
- <where>
- <if test="guid != null and guid != ''">
- and id.guid = #{guid,jdbcType=VARCHAR}
- </if>
- and id.enable_flag = 1
- and id.del_flag = 0
- </where>
- </select>
- </mapper>
|