This commit is contained in:
kerwincui
2024-03-17 14:59:23 +08:00
parent 3d44f4674c
commit 5539c1b6af
999 changed files with 115642 additions and 10757 deletions

View File

@@ -0,0 +1,113 @@
<?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.fastbee.iot.mapper.CategoryMapper">
<resultMap type="com.fastbee.iot.domain.Category" id="CategoryResult">
<result property="categoryId" column="category_id" />
<result property="categoryName" column="category_name" />
<result property="tenantId" column="tenant_id" />
<result property="tenantName" column="tenant_name" />
<result property="isSys" column="is_sys" />
<result property="orderNum" column="order_num" />
<result property="createTime" column="create_time" />
<result property="updateTime" column="update_time" />
<result property="remark" column="remark" />
</resultMap>
<resultMap type="com.fastbee.iot.model.IdAndName" id="CategoryShortResult">
<result property="id" column="category_id" />
<result property="name" column="category_name" />
</resultMap>
<sql id="selectCategoryVo">
select category_id, category_name, tenant_id, tenant_name, is_sys,order_num, create_time, update_time, remark from iot_category
</sql>
<select id="selectCategoryList" parameterType="com.fastbee.iot.domain.Category" resultMap="CategoryResult">
<include refid="selectCategoryVo"/>
<where>
<if test="categoryName != null and categoryName != ''"> and category_name like concat('%', #{categoryName}, '%')</if>
<if test="tenantId != null and tenantId != ''"> and (tenant_id = #{tenantId} or is_sys = 1)</if>
</where>
order by order_num
</select>
<select id="selectCategoryShortList" resultMap="CategoryShortResult">
select category_id, category_name
from iot_category
<where>
<if test="tenantId != null and tenantId != ''"> and (tenant_id = #{tenantId} or is_sys = 1)</if>
</where>
order by order_num
</select>
<select id="selectCategoryByCategoryId" parameterType="Long" resultMap="CategoryResult">
<include refid="selectCategoryVo"/>
where category_id = #{categoryId}
</select>
<insert id="insertCategory" parameterType="com.fastbee.iot.domain.Category" useGeneratedKeys="true" keyProperty="categoryId">
insert into iot_category
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="categoryName != null and categoryName != ''">category_name,</if>
<if test="tenantId != null">tenant_id,</if>
<if test="tenantName != null and tenantName != ''">tenant_name,</if>
<if test="isSys != null">is_sys,</if>
<if test="orderNum != null">order_num,</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="remark != null">remark,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="categoryName != null and categoryName != ''">#{categoryName},</if>
<if test="tenantId != null">#{tenantId},</if>
<if test="tenantName != null and tenantName != ''">#{tenantName},</if>
<if test="isSys != null">#{isSys},</if>
<if test="orderNum != null">#{orderNum},</if>
<if test="createBy != null">#{createBy},</if>
<if test="createTime != null">#{createTime},</if>
<if test="updateBy != null">#{updateBy},</if>
<if test="updateTime != null">#{updateTime},</if>
<if test="remark != null">#{remark},</if>
</trim>
</insert>
<update id="updateCategory" parameterType="com.fastbee.iot.domain.Category">
update iot_category
<trim prefix="SET" suffixOverrides=",">
<if test="categoryName != null and categoryName != ''">category_name = #{categoryName},</if>
<if test="tenantId != null">tenant_id = #{tenantId},</if>
<if test="tenantName != null and tenantName != ''">tenant_name = #{tenantName},</if>
<if test="isSys != null">is_sys = #{isSys},</if>
<if test="orderNum != null">order_num = #{orderNum},</if>
<if test="createBy != null">create_by = #{createBy},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="updateBy != null">update_by = #{updateBy},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
<if test="remark != null">remark = #{remark},</if>
</trim>
where category_id = #{categoryId}
</update>
<delete id="deleteCategoryByCategoryId" parameterType="Long">
delete from iot_category where category_id = #{categoryId}
</delete>
<delete id="deleteCategoryByCategoryIds" parameterType="String">
delete from iot_category where category_id in
<foreach item="categoryId" collection="array" open="(" separator="," close=")">
#{categoryId}
</foreach>
</delete>
<select id="productCountInCategorys" parameterType="String" resultType="int">
select count(*) from iot_product where category_id in
<foreach item="categoryId" collection="array" open="(" separator="," close=")">
#{categoryId}
</foreach>
</select>
</mapper>

View File

@@ -0,0 +1,194 @@
<?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.fastbee.iot.mapper.DeviceJobMapper">
<resultMap type="com.fastbee.iot.domain.DeviceJob" id="DeviceJobResult">
<id property="jobId" column="job_id" />
<result property="jobName" column="job_name" />
<result property="jobGroup" column="job_group" />
<result property="serialNumber" column="serial_number" />
<result property="deviceId" column="device_id" />
<result property="deviceName" column="device_name" />
<result property="actions" column="actions" />
<result property="alertTrigger" column="alertTrigger" />
<result property="isAdvance" column="is_advance" />
<result property="cronExpression" column="cron_expression" />
<result property="misfirePolicy" column="misfire_policy" />
<result property="concurrent" column="concurrent" />
<result property="status" column="status" />
<result property="createBy" column="create_by" />
<result property="createTime" column="create_time" />
<result property="updateBy" column="update_by" />
<result property="updateTime" column="update_time" />
<result property="remark" column="remark" />
<result property="jobType" column="job_type" />
<result property="productId" column="product_id" />
<result property="productName" column="product_name" />
<result property="sceneId" column="scene_id" />
<result property="alertId" column="alert_id" />
</resultMap>
<sql id="selectJobVo">
select job_id, job_name, job_group,serial_number, device_id,device_name,actions,alert_trigger,is_advance, cron_expression, misfire_policy, concurrent, status, create_by, create_time, remark, job_type, product_id, product_name, scene_id, alert_id
from iot_device_job
</sql>
<select id="selectShortJobListByDeviceIds" parameterType="Long" resultMap="DeviceJobResult">
select job_id, job_name, job_group from iot_device_job
where device_id in
<foreach collection="array" item="deviceId" open="(" separator="," close=")">
#{deviceId}
</foreach>
</select>
<select id="selectShortJobListByAlertIds" parameterType="Long" resultMap="DeviceJobResult">
select job_id, job_name, job_group from iot_device_job
where alert_id in
<foreach collection="array" item="alertId" open="(" separator="," close=")">
#{alertId}
</foreach>
</select>
<select id="selectShortJobListBySceneIds" parameterType="Long" resultMap="DeviceJobResult">
select job_id, job_name, job_group from iot_device_job
where scene_id in
<foreach collection="array" item="sceneId" open="(" separator="," close=")">
#{sceneId}
</foreach>
</select>
<select id="selectJobList" parameterType="com.fastbee.iot.domain.DeviceJob" resultMap="DeviceJobResult">
<include refid="selectJobVo"/>
<where>
<if test="1==1"> and device_id = #{deviceId}</if>
<if test="jobName != null and jobName != ''">
AND job_name like concat('%', #{jobName}, '%')
</if>
<if test="jobGroup != null and jobGroup != ''">
AND job_group = #{jobGroup}
</if>
<if test="status != null and status != ''">
AND status = #{status}
</if>
</where>
</select>
<select id="selectJobAll" resultMap="DeviceJobResult">
<include refid="selectJobVo"/>
</select>
<select id="selectJobById" parameterType="Long" resultMap="DeviceJobResult">
<include refid="selectJobVo"/>
where job_id = #{jobId}
</select>
<delete id="deleteJobById" parameterType="Long">
delete from iot_device_job where job_id = #{jobId}
</delete>
<delete id="deleteJobByIds" parameterType="Long">
delete from iot_device_job where job_id in
<foreach collection="array" item="jobId" open="(" separator="," close=")">
#{jobId}
</foreach>
</delete>
<delete id="deleteJobByDeviceIds" parameterType="Long">
delete from iot_device_job where device_id in
<foreach collection="array" item="deviceId" open="(" separator="," close=")">
#{deviceId}
</foreach>
</delete>
<delete id="deleteJobByAlertIds" parameterType="Long">
delete from iot_device_job where alert_id in
<foreach collection="array" item="alertId" open="(" separator="," close=")">
#{alertId}
</foreach>
</delete>
<delete id="deleteJobBySceneIds" parameterType="Long">
delete from iot_device_job where scene_id in
<foreach collection="array" item="sceneId" open="(" separator="," close=")">
#{sceneId}
</foreach>
</delete>
<update id="updateJob" parameterType="com.fastbee.iot.domain.DeviceJob">
update iot_device_job
<set>
<if test="jobName != null and jobName != ''">job_name = #{jobName},</if>
<if test="jobGroup != null and jobGroup != ''">job_group = #{jobGroup},</if>
<if test="deviceId != null and deviceId != ''">device_id = #{deviceId},</if>
<if test="deviceName != null and deviceName != ''">device_name = #{deviceName},</if>
<if test="serialNumber != null and serialNumber != ''">serial_number = #{serialNumber},</if>
<if test="actions != null and actions != ''">actions = #{actions},</if>
<if test="alertTrigger != null and alertTrigger != ''">alert_trigger = #{alertTrigger},</if>
<if test="cronExpression != null and cronExpression != ''">cron_expression = #{cronExpression},</if>
<if test="misfirePolicy != null and misfirePolicy != ''">misfire_policy = #{misfirePolicy},</if>
<if test="concurrent != null and concurrent != ''">concurrent = #{concurrent},</if>
<if test="status !=null">status = #{status},</if>
<if test="remark != null and remark != ''">remark = #{remark},</if>
<if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
<if test="jobType != null">job_type = #{jobType},</if>
<if test="productId != null and productId!=0">product_id = #{productId},</if>
<if test="productName != null and productName!=''">product_name = #{productName},</if>
<if test="sceneId != null and sceneId!=0">scene_id = #{sceneId},</if>
<if test="alertId != null and alertId!=0">alert_id = #{alertId},</if>
is_advance =#{isAdvance},
update_time = sysdate()
</set>
where job_id = #{jobId}
</update>
<insert id="insertJob" parameterType="com.fastbee.iot.domain.DeviceJob" useGeneratedKeys="true" keyProperty="jobId">
insert into iot_device_job(
<if test="jobId != null and jobId != 0">job_id,</if>
<if test="jobName != null and jobName != ''">job_name,</if>
<if test="jobGroup != null and jobGroup != ''">job_group,</if>
<if test="deviceId != null and deviceId != ''">device_id,</if>
<if test="deviceName != null and deviceName != ''">device_name,</if>
<if test="serialNumber != null and serialNumber != ''">serial_number,</if>
<if test="actions != null and actions != ''">actions,</if>
<if test="alertTrigger != null and alertTrigger != ''">alert_trigger,</if>
<if test="cronExpression != null and cronExpression != ''">cron_expression,</if>
<if test="misfirePolicy != null and misfirePolicy != ''">misfire_policy,</if>
<if test="concurrent != null and concurrent != ''">concurrent,</if>
<if test="status != null and status != ''">status,</if>
<if test="remark != null and remark != ''">remark,</if>
<if test="createBy != null and createBy != ''">create_by,</if>
<if test="jobType != null and jobType!=''">job_type,</if>
<if test="productId != null and productId!=0">product_id,</if>
<if test="productName != null and productName!=''">product_name,</if>
<if test="sceneId != null and sceneId!=0">scene_id,</if>
<if test="alertId != null and alertId!=0">alert_id,</if>
is_advance,
create_time
)values(
<if test="jobId != null and jobId != 0">#{jobId},</if>
<if test="jobName != null and jobName != ''">#{jobName},</if>
<if test="jobGroup != null and jobGroup != ''">#{jobGroup},</if>
<if test="deviceId != null and deviceId != ''">#{deviceId},</if>
<if test="deviceName != null and deviceName != ''">#{deviceName},</if>
<if test="serialNumber != null and serialNumber != ''">#{serialNumber},</if>
<if test="actions != null and actions != ''">#{actions},</if>
<if test="alertTrigger != null and alertTrigger != ''">#{alertTrigger},</if>
<if test="cronExpression != null and cronExpression != ''">#{cronExpression},</if>
<if test="misfirePolicy != null and misfirePolicy != ''">#{misfirePolicy},</if>
<if test="concurrent != null and concurrent != ''">#{concurrent},</if>
<if test="status != null and status != ''">#{status},</if>
<if test="remark != null and remark != ''">#{remark},</if>
<if test="createBy != null and createBy != ''">#{createBy},</if>
<if test="jobType != null and jobType!=''">#{jobType},</if>
<if test="productId != null and productId!=0">#{productId},</if>
<if test="productName != null and productName!=''">#{productName},</if>
<if test="sceneId != null and sceneId!=0">#{sceneId},</if>
<if test="alertId != null and alertId!=0">#{alertId},</if>
#{isAdvance},
sysdate()
)
</insert>
</mapper>

View File

@@ -0,0 +1,146 @@
<?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.fastbee.iot.mapper.DeviceLogMapper">
<resultMap type="com.fastbee.iot.model.MonitorModel" id="MonitorResult">
<result property="value" column="log_value" />
<result property="time" column="create_time" />
</resultMap>
<resultMap type="com.fastbee.iot.domain.DeviceLog" id="DeviceLogResult">
<result property="logId" column="log_id" />
<result property="logType" column="log_type" />
<result property="logValue" column="log_value" />
<result property="deviceId" column="device_id" />
<result property="deviceName" column="device_name" />
<result property="serialNumber" column="serial_number" />
<result property="identity" column="identity" />
<result property="createBy" column="create_by" />
<result property="isMonitor" column="is_monitor" />
<result property="mode" column="mode" />
<result property="createTime" column="create_time" />
<result property="userId" column="user_id" />
<result property="userName" column="user_name" />
<result property="tenantId" column="tenant_id" />
<result property="tenantName" column="tenant_name" />
<result property="remark" column="remark" />
</resultMap>
<resultMap type="com.fastbee.iot.model.HistoryModel" id="HistoryResult">
<result property="value" column="log_value" />
<result property="time" column="create_time" />
<result property="identity" column="identity" />
</resultMap>
<sql id="selectDeviceLogVo">
select log_id, log_type, log_value, device_id, device_name,serial_number, identity, create_by, is_monitor,mode, user_id, user_name, tenant_id, tenant_name, create_time, remark from iot_device_log
</sql>
<select id="selectMonitorList" parameterType="com.fastbee.iot.domain.DeviceLog" resultMap="MonitorResult">
select log_value, create_time from iot_device_log
<where>
<if test="1==1"> and is_monitor=1</if>
<if test="identity != null and identity != ''"> and identity = #{identity}</if>
<if test="deviceId != null and deviceId !=0"> and device_id = #{deviceId}</if>
<if test="serialNumber != null and serialNumber !=''"> and serial_number = #{serialNumber}</if>
<if test="beginTime != null and beginTime != '' and endTime != null and endTime != ''"> and create_time between #{beginTime} and #{endTime}</if>
</where>
order by create_time desc
limit #{total}
</select>
<select id="selectDeviceLogByLogId" parameterType="Long" resultMap="DeviceLogResult">
<include refid="selectDeviceLogVo"/>
where log_id = #{logId}
</select>
<select id="selectCategoryLogCount" parameterType="com.fastbee.iot.domain.Device" resultType="com.fastbee.iot.model.DeviceStatistic">
SELECT
(select count(log_id)
from iot_device_log
<where>
<if test="1==1"> and log_type=1</if>
<if test="userId != null and userId != 0"> and user_id = #{userId}</if>
<if test="tenantId != null and tenantId != 0"> and tenant_id = #{tenantId}</if>
</where>
) as propertyCount,
(select count(log_id)
from iot_device_log
<where>
<if test="1==1"> and log_type=2</if>
<if test="userId != null and userId != 0"> and user_id = #{userId}</if>
<if test="tenantId != null and tenantId != 0"> and tenant_id = #{tenantId}</if>
</where>
) as functionCount,
(select count(log_id)
from iot_device_log
<where>
<if test="1==1"> and log_type=3</if>
<if test="userId != null and userId != 0"> and user_id = #{userId}</if>
<if test="tenantId != null and tenantId != 0"> and tenant_id = #{tenantId}</if>
</where>
) as eventCount,
(select count(log_id)
from iot_device_log
<where>
<if test="1==1"> and log_type=1 and is_monitor=1</if>
<if test="userId != null and userId != 0"> and user_id = #{userId}</if>
<if test="tenantId != null and tenantId != 0"> and tenant_id = #{tenantId}</if>
</where>
) as monitorCount
limit 1
</select>
<insert id="saveBatch" parameterType="com.fastbee.iot.domain.DeviceLog">
insert into iot_device_log (log_type,log_value,device_id,device_name,serial_number,identity,create_by,
is_monitor,mode,create_time,remark,user_id,user_name,tenant_id,tenant_name,model_name)
values
<foreach collection="list" item="item" index="index" separator=",">
(#{item.logType},#{item.logValue},#{item.deviceId},#{item.deviceName},#{item.serialNumber},
#{item.identity},#{item.createBy},#{item.isMonitor},#{item.mode},#{item.createTime},#{item.remark},
#{item.userId},#{item.userName},#{item.tenantId},#{item.tenantName},#{item.modelName})
</foreach>
</insert>
<update id="updateDeviceLog" parameterType="com.fastbee.iot.domain.DeviceLog">
update iot_device_log
<trim prefix="SET" suffixOverrides=",">
<if test="logType != null">log_type = #{logType},</if>
<if test="logValue != null">log_value = #{logValue},</if>
<if test="deviceId != null">device_id = #{deviceId},</if>
<if test="deviceName != null and deviceName != ''">device_name = #{deviceName},</if>
<if test="serialNumber != null and serialNumber != ''">serial_number = #{serialNumber},</if>
<if test="identity != null">identity = #{identity},</if>
<if test="createBy != null">create_by = #{createBy},</if>
<if test="isMonitor != null">is_monitor = #{isMonitor},</if>
<if test="mode != null">mode = #{mode},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="remark != null">remark = #{remark},</if>
<if test="userId != null">user_id = #{userId},</if>
<if test="userName != null and userName != ''">user_name = #{userName},</if>
<if test="tenantId != null">tenant_id = #{tenantId},</if>
<if test="tenantName != null and tenantName != ''">tenant_name = #{tenantName},</if>
</trim>
where log_id = #{logId}
</update>
<delete id="deleteDeviceLogByLogId" parameterType="Long">
delete from iot_device_log where log_id = #{logId}
</delete>
<delete id="deleteDeviceLogByLogIds" parameterType="String">
delete from iot_device_log where log_id in
<foreach item="logId" collection="array" open="(" separator="," close=")">
#{logId}
</foreach>
</delete>
<delete id="deleteDeviceLogByDeviceNumber" parameterType="String">
delete from iot_device_log where serial_number = #{deviceNumber}
</delete>
</mapper>

View File

@@ -0,0 +1,639 @@
<?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.fastbee.iot.mapper.DeviceMapper">
<resultMap type="com.fastbee.iot.domain.Device" id="DeviceResult">
<result property="deviceId" column="device_id" />
<result property="deviceName" column="device_name" />
<result property="productId" column="product_id" />
<result property="productName" column="product_name" />
<result property="userId" column="user_id" />
<result property="userName" column="user_name" />
<result property="tenantId" column="tenant_id" />
<result property="tenantName" column="tenant_name" />
<result property="serialNumber" column="serial_number" />
<result property="firmwareVersion" column="firmware_version" />
<result property="status" column="status" />
<result property="deviceType" column="device_type" />
<result property="rssi" column="rssi" />
<result property="isShadow" column="is_shadow" />
<result property="locationWay" column="location_way" />
<result property="thingsModelValue" column="things_model_value" />
<result property="networkAddress" column="network_address" />
<result property="networkIp" column="network_ip" />
<result property="longitude" column="longitude" />
<result property="latitude" column="latitude" />
<result property="activeTime" column="active_time" />
<result property="createTime" column="create_time" />
<result property="updateTime" column="update_time" />
<result property="remark" column="remark" />
<result property="imgUrl" column="img_url" />
<result property="summary" column="summary" />
<result property="isOwner" column="is_owner" />
<result property="gwDevCode" column="gw_dev_code"/>
<result property="isSimulate" column="is_simulate"/>
<result property="slaveId" column="slave_id" />
<result property="transport" column="transport" />
</resultMap>
<resultMap type="com.fastbee.iot.model.DeviceShortOutput" id="DeviceShortResult">
<result property="deviceId" column="device_id" />
<result property="deviceName" column="device_name" />
<result property="productId" column="product_id" />
<result property="productName" column="product_name" />
<result property="deviceType" column="device_type" />
<result property="userId" column="user_id" />
<result property="userName" column="user_name" />
<result property="tenantId" column="tenant_id" />
<result property="tenantName" column="tenant_name" />
<result property="serialNumber" column="serial_number" />
<result property="firmwareVersion" column="firmware_version" />
<result property="status" column="status" />
<result property="activeTime" column="active_time" />
<result property="createTime" column="create_time" />
<result property="rssi" column="rssi" />
<result property="isShadow" column="is_shadow" />
<result property="isSimulate" column="is_simulate" />
<result property="locationWay" column="location_way" />
<result property="thingsModelValue" column="things_model_value" />
<result property="imgUrl" column="img_url" />
<result property="isOwner" column="is_owner" />
<result property="gwDevCode" column="gw_dev_code"/>
<result property="subDeviceCount" column="sub_device_count"/>
<result property="slaveId" column="slave_id" />
<result property="protocolCode" column="protocol_code"/>
<result property="transport" column="transport" />
</resultMap>
<resultMap type="com.fastbee.iot.model.DeviceAllShortOutput" id="DeviceAllShortResult">
<result property="deviceId" column="device_id" />
<result property="deviceName" column="device_name" />
<result property="productName" column="product_name" />
<result property="deviceType" column="device_type" />
<result property="userName" column="user_name" />
<result property="serialNumber" column="serial_number" />
<result property="firmwareVersion" column="firmware_version" />
<result property="status" column="status" />
<result property="activeTime" column="active_time" />
<result property="rssi" column="rssi" />
<result property="isShadow" column="is_shadow" />
<result property="locationWay" column="location_way" />
<result property="networkAddress" column="network_address" />
<result property="longitude" column="longitude" />
<result property="latitude" column="latitude" />
<result property="isOwner" column="is_owner" />
<result property="subDeviceCount" column="sub_device_count"/>
</resultMap>
<resultMap type="com.fastbee.iot.model.ProductAuthenticateModel" id="DeviceAuthenticateResult">
<result property="deviceId" column="device_id" />
<result property="deviceName" column="device_name" />
<result property="status" column="status" />
<result property="productId" column="product_id" />
<result property="productName" column="product_name" />
<result property="productStatus" column="product_status" />
<result property="isAuthorize" column="is_authorize" />
<result property="serialNumber" column="serial_number" />
<result property="mqttAccount" column="mqtt_account" />
<result property="mqttPassword" column="mqtt_password" />
<result property="mqttSecret" column="mqtt_secret" />
<result property="vertificateMethod" column="vertificate_method" />
</resultMap>
<resultMap type="com.fastbee.iot.model.ThingsModels.ThingsModelValuesOutput" id="DeviceThingsValueResult">
<result property="deviceId" column="device_id" />
<result property="deviceName" column="device_name" />
<result property="serialNumber" column="serial_number" />
<result property="status" column="status" />
<result property="isShadow" column="is_shadow" />
<result property="isSimulate" column="is_Simulate" />
<result property="productId" column="product_id" />
<result property="productName" column="product_name" />
<result property="serialNumber" column="serial_number" />
<result property="thingsModelValue" column="things_model_value" />
<result property="userId" column="user_id" />
<result property="userName" column="user_name" />
<result property="tenantId" column="tenant_id" />
<result property="tenantName" column="tenant_name" />
<result property="slaveId" column="slave_id" />
</resultMap>
<resultMap type="com.fastbee.iot.model.DeviceMqttVO" id="DeviceMqttVOResult">
<result property="deviceId" column="device_id"/>
<result property="serialNumber" column="serial_number"/>
<result property="productId" column="product_id"/>
<result property="userId" column="user_id"/>
<result property="mqttAccount" column="mqtt_account"/>
<result property="mqttPassword" column="mqtt_password"/>
<result property="mqttSecret" column="mqtt_secret"/>
<result property="vertificateMethod" column="vertificate_method"/>
<result property="isAuthorize" column="is_authorize"/>
</resultMap>
<resultMap type="com.fastbee.iot.model.DeviceRelateAlertLogVO" id="DeviceRelateAlertLogVOResult">
<result property="deviceId" column="device_id"/>
<result property="serialNumber" column="serial_number"/>
<result property="deviceName" column="device_name" />
<result property="userId" column="user_id"/>
</resultMap>
<sql id="selectDeviceVo">
select device_id, device_name, product_id, product_name, user_id, user_name, tenant_id, tenant_name, serial_number,gw_dev_code, firmware_version, status, rssi,is_shadow ,is_simulate,location_way,things_model_value,network_address, network_ip, longitude, latitude, active_time, create_time, update_time, img_url,summary,remark,slave_id from iot_device
</sql>
<sql id="selectDeviceShortVo">
select device_id, device_name, product_id, product_name, user_id, user_name, tenant_id, tenant_name, serial_number, firmware_version, status,rssi,is_shadow ,is_simulate,location_way,things_model_value, active_time,img_url,slave_id from iot_device
</sql>
<sql id="selectWebhookDeviceVo">
select device_id, device_name,product_id, serial_number,user_id, user_name, tenant_id, tenant_name, status,is_shadow,is_simulate, rssi ,location_way,things_model_value, active_time from iot_device
</sql>
<select id="selectDeviceList" parameterType="com.fastbee.iot.domain.Device" resultMap="DeviceResult">
<include refid="selectDeviceVo"/>
<where>
<if test="gwDevCode != null and gwDevCode != ''">and gw_dev_code = #{gwDevCode}</if>
<if test="deviceName != null and deviceName != ''"> and device_name like concat('%', #{deviceName}, '%')</if>
<if test="productId != null "> and product_id = #{productId}</if>
<if test="productName != null and productName != ''"> and product_name like concat('%', #{productName}, '%')</if>
<if test="userId != null "> and user_id = #{userId}</if>
<if test="userName != null and userName != ''"> and user_name like concat('%', #{userName}, '%')</if>
<if test="tenantId != null "> and tenant_id = #{tenantId}</if>
<if test="tenantName != null and tenantName != ''"> and tenant_name like concat('%', #{tenantName}, '%')</if>
<if test="serialNumber != null and serialNumber != ''"> and serial_number = #{serialNumber}</if>
<if test="status != null "> and status = #{status}</if>
<if test="networkAddress != null and networkAddress != ''"> and network_address like concat('%', #{networkAddress}, '%')</if>
<if test="params.beginActiveTime != null and params.beginActiveTime != '' and params.endActiveTime != null and params.endActiveTime != ''"> and active_time between #{params.beginActiveTime} and #{params.endActiveTime}</if>
</where>
order by create_time desc
</select>
<select id="selectUnAuthDeviceList" parameterType="com.fastbee.iot.domain.Device" resultMap="DeviceResult">
select d.device_id, d.device_name, d.product_id, d.product_name, d.user_id, d.user_name, d.tenant_id, d.tenant_name,
d.serial_number,d.gw_dev_code, d.firmware_version, d.status,d.is_shadow,d.is_simulate ,d.location_way,d.active_time, d.img_url,a.device_id as auth_device_id
from iot_device d
left join iot_product_authorize a on a.device_id=d.device_id
<where>
<if test="1==1"> and ISNULL(a.device_id)</if>
<if test="deviceName != null and deviceName != ''"> and d.device_name like concat('%', #{deviceName}, '%')</if>
<if test="productId != null "> and d.product_id = #{productId}</if>
<if test="productName != null and productName != ''"> and d.product_name like concat('%', #{productName}, '%')</if>
<if test="userId != null "> and d.user_id = #{userId}</if>
<if test="userName != null and userName != ''"> and d.user_name like concat('%', #{userName}, '%')</if>
<if test="tenantId != null "> and d.tenant_id = #{tenantId}</if>
<if test="tenantName != null and tenantName != ''"> and d.tenant_name like concat('%', #{tenantName}, '%')</if>
<if test="serialNumber != null and serialNumber != ''"> and d.serial_number = #{serialNumber}</if>
<if test="gwDevCode != null and gwDevCode != ''">and d.gw_dev_code = #{gwDevCode,jdbcType=VARCHAR}</if>
<if test="status != null "> and d.status = #{status}</if>
<if test="params.beginActiveTime != null and params.beginActiveTime != '' and params.endActiveTime != null and params.endActiveTime != ''"> and d.active_time between #{params.beginActiveTime} and #{params.endActiveTime}</if>
</where>
order by d.create_time desc
</select>
<select id="selectDeviceListByGroup" parameterType="com.fastbee.iot.domain.Device" resultMap="DeviceResult">
select d.device_id, d.device_name, d.product_name, d.user_name, d.serial_number,d.gw_dev_code, d.firmware_version, d.status,d.rssi,d.is_shadow ,
d.location_way, d.active_time,d.network_address,d.longitude,d.latitude,max(u.is_owner) as is_owner
from iot_device d
inner join iot_device_user u on u.device_id = d.device_id
<where>
<if test="userId != null "> and u.user_id = #{userId}</if>
<if test="productId != null "> and d.product_id = #{productId}</if>
<if test="deviceName != null and deviceName != ''"> and d.device_name like concat('%', #{deviceName}, '%')</if>
<if test="productName != null and productName != ''"> and d.product_name like concat('%', #{productName}, '%')</if>
<if test="serialNumber != null and serialNumber != ''"> and d.serial_number = #{serialNumber}</if>
<if test="gwDevCode != null and gwDevCode != ''"> and d.gw_dev_code = #{gwDevCode}</if>
<if test="status != null "> and d.status = #{status}</if>
<if test="networkAddress != null and networkAddress != ''"> and d.network_address like concat('%', #{networkAddress}, '%')</if>
<if test="params.beginActiveTime != null and params.beginActiveTime != '' and params.endActiveTime != null and params.endActiveTime != ''"> and d.active_time between #{params.beginActiveTime} and #{params.endActiveTime}</if>
<if test="firmwareVersion != null"> and firmware_version = #{firmwareVersion}</if>
</where>
group by d.device_id,d.user_id
order by d.create_time desc
</select>
<select id="selectAllDeviceShortList" parameterType="com.fastbee.iot.domain.Device" resultMap="DeviceAllShortResult">
select d.device_id, d.device_name, d.product_name,p.device_type, d.user_name, d.serial_number,d.gw_dev_code, d.firmware_version, d.status,d.rssi,d.is_shadow ,
d.location_way, d.active_time,d.network_address,d.longitude,d.latitude,max(u.is_owner) as is_owner,
(select count(*) from iot_device d1 where d1.gw_dev_code = d.serial_number) as sub_device_count
from iot_device d
inner join iot_device_user u on u.device_id = d.device_id
left join iot_product p on p.product_id=d.product_id
<where>
<if test="userId != null "> and u.user_id = #{userId}</if>
<if test="tenantId != null "> and d.tenant_id = #{tenantId}</if>
<if test="productId != null "> and d.product_id = #{productId}</if>
</where>
group by d.device_id,d.user_id
</select>
<select id="selectSerialNumberByProductId" parameterType="Long" resultType="String">
select serial_number from iot_device where product_id = #{productId}
</select>
<select id="selectDeviceCountByProductId" parameterType="Long" resultType="Integer">
select count(device_id) from iot_device where product_id = #{productId}
</select>
<select id="selectDeviceThingsModelValueBySerialNumber" parameterType="String" resultMap="DeviceThingsValueResult">
select product_id,product_name,device_id,device_name,serial_number,gw_dev_code,is_shadow,is_simulate,status,user_id, user_name, tenant_id, tenant_name,things_model_value from iot_device where serial_number = #{serialNumber}
</select>
<update id="updateDeviceThingsModelValue" parameterType="com.fastbee.common.core.thingsModel.ThingsModelValuesInput">
update iot_device set things_model_value=#{stringValue} where device_id = #{deviceId}
</update>
<select id="selectDeviceShortList" parameterType="com.fastbee.iot.domain.Device" resultMap="DeviceShortResult">
select d.device_id, d.device_name, d.product_id, d.product_name,p.device_type,
d.user_id, d.user_name, d.tenant_id, d.tenant_name, d.serial_number,d.gw_dev_code,
d.firmware_version, d.status,d.rssi,d.is_shadow,d.is_simulate ,d.location_way,
d.things_model_value, d.active_time,d.create_time,d.img_url,max(u.is_owner) as is_owner,
(select count(*) from iot_device d1 where d1.gw_dev_code = d.serial_number) as sub_device_count,
p.protocol_code,p.transport
from iot_device d
inner join iot_device_user u on u.device_id = d.device_id
left join iot_product p on p.product_id=d.product_id
<if test="groupId != null and groupId !=0 "> left join iot_device_group g on g.device_id=d.device_id </if>
<where>
<if test="groupId != null and groupId !=0 "> and g.group_id = #{groupId}</if>
<if test="userId != null and userId != 0"> and u.user_id = #{userId}</if>
<if test="tenantId != null and tenantId != 0"> and d.tenant_id = #{tenantId}</if>
<if test="deviceName != null and deviceName != ''"> and d.device_name like concat('%', #{deviceName}, '%')</if>
<if test="productId != null "> and d.product_id = #{productId}</if>
<if test="deviceType != null "> and p.device_type = #{deviceType}</if>
<if test="productName != null and productName != ''"> and d.product_name like concat('%', #{productName}, '%')</if>
<if test="userName != null and userName != ''"> and d.user_name like concat('%', #{userName}, '%')</if>
<if test="tenantName != null and tenantName != ''"> and d.tenant_name like concat('%', #{tenantName}, '%')</if>
<if test="serialNumber != null and serialNumber != ''"> and d.serial_number = #{serialNumber}</if>
<if test="gwDevCode != null and gwDevCode != ''"> and d.gw_dev_code = #{gwDevCode}</if>
<if test="status != null "> and d.status = #{status}</if>
<if test="isSimulate != null">and d.is_simulate = #{isSimulate}</if>
<if test="params.beginActiveTime != null and params.beginActiveTime != '' and params.endActiveTime != null and params.endActiveTime != ''"> and d.active_time between #{params.beginActiveTime} and #{params.endActiveTime}</if>
</where>
group by d.device_id,d.user_id
order by d.create_time desc
</select>
<select id="selectDeviceByDeviceId" parameterType="Long" resultMap="DeviceResult">
select d.device_id, d.device_name, d.product_id, p.product_name,p.device_type, d.user_id, d.user_name, d.tenant_id, d.tenant_name,
d.serial_number, d.firmware_version, d.status, d.rssi,d.is_shadow,d.is_simulate ,d.location_way,d.things_model_value,
d.network_address, d.network_ip, d.longitude, d.latitude, d.active_time, d.create_time, d.update_time,
d.img_url,d.summary,d.remark from iot_device d
left join iot_product p on p.product_id=d.product_id
where device_id = #{deviceId}
</select>
<select id="selectDeviceBySerialNumber" parameterType="String" resultMap="DeviceResult">
<include refid="selectDeviceVo"/>
where serial_number = #{serialNumber}
</select>
<select id="selectDeviceCountBySerialNumber" parameterType="String" resultType="int">
select count(device_id) from iot_device
where serial_number = #{serialNumber}
</select>
<select id="selectDeviceProductAlertCount" parameterType="com.fastbee.iot.domain.Device" resultType="com.fastbee.iot.model.DeviceStatistic">
select
<!--设备数量-->
(select count(distinct d.device_id,d.user_id)
from iot_device d
inner join iot_device_user u on u.device_id = d.device_id
<where>
<if test="userId != null and userId != 0"> and u.user_id = #{userId}</if>
<if test="tenantId != null and tenantId != 0"> and d.tenant_id = #{tenantId}</if>
</where>
) as deviceCount,
<!--在线设备数量-->
(select count(distinct d.device_id,d.user_id)
from iot_device d
inner join iot_device_user u on u.device_id = d.device_id
<where>
d.status=3
<if test="userId != null and userId != 0"> and u.user_id = #{userId}</if>
<if test="tenantId != null and tenantId != 0"> and d.tenant_id = #{tenantId}</if>
</where>
) as deviceOnlineCount,
(
<!--普通用户查询设备中的产品数量-->
<if test="userId != null and userId != 0">
select count(distinct product_id)
from iot_device
where user_id = #{userId}
</if>
<!--管理员和租户直接查询产品的数量-->
<if test="userId == null || userId == 0">
select count(product_id)
from iot_product
<where>
<if test="tenantId != null and tenantId != 0"> and tenant_id = #{tenantId} </if>
</where>
</if>
) as productCount
</select>
<select id="selectProductAuthenticate" parameterType="com.fastbee.iot.model.AuthenticateInputModel" resultMap="DeviceAuthenticateResult">
SELECT p.mqtt_password,p.mqtt_account, p.mqtt_secret,p.is_authorize,p.product_id,p.product_name,p.vertificate_method,p.STATUS as product_status,d.device_id,d.device_name,d.STATUS,d.serial_number
FROM iot_product p
LEFT JOIN ( SELECT device_id, device_name, STATUS, product_id, product_name, serial_number
FROM iot_device
WHERE serial_number = #{serialNumber} ) AS d ON d.product_id = p.product_id
WHERE
p.product_id = #{productId}
</select>
<select id="selectShortDeviceBySerialNumber" parameterType="String" resultMap="DeviceResult">
<include refid="selectWebhookDeviceVo"/>
where serial_number = #{serialNumber}
</select>
<select id="selectDeviceRunningStatusByDeviceId" parameterType="Long" resultMap="DeviceShortResult">
<include refid="selectDeviceShortVo"/>
where device_id = #{deviceId}
</select>
<insert id="insertDevice" parameterType="com.fastbee.iot.domain.Device" useGeneratedKeys="true" keyProperty="deviceId">
insert into iot_device
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="deviceName != null and deviceName != ''">device_name,</if>
<if test="productId != null">product_id,</if>
<if test="productName != null and productName != ''">product_name,</if>
<if test="userId != null">user_id,</if>
<if test="userName != null and userName != ''">user_name,</if>
<if test="tenantId != null">tenant_id,</if>
<if test="tenantName != null and tenantName != ''">tenant_name,</if>
<if test="serialNumber != null and serialNumber != ''">serial_number,</if>
<if test="firmwareVersion != null">firmware_version,</if>
<if test="status != null">status,</if>
<if test="rssi != null">rssi,</if>
<if test="isShadow != null">is_shadow,</if>
<if test="locationWay != null">location_way,</if>
<if test="thingsModelValue != null">things_model_value,</if>
<if test="networkAddress != null">network_address,</if>
<if test="networkIp != null">network_ip,</if>
<if test="longitude != null">longitude,</if>
<if test="latitude != null">latitude,</if>
<if test="activeTime != null">active_time,</if>
<if test="delFlag != null">del_flag,</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="remark != null">remark,</if>
<if test="imgUrl != null">img_url,</if>
<if test="summary != null">summary,</if>
<if test="gwDevCode != null">gw_dev_code,</if>
<if test="isSimulate != null">is_simulate,</if>
<if test="slaveId != null">slave_id,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="deviceName != null and deviceName != ''">#{deviceName},</if>
<if test="productId != null">#{productId},</if>
<if test="productName != null and productName != ''">#{productName},</if>
<if test="userId != null">#{userId},</if>
<if test="userName != null and userName != ''">#{userName},</if>
<if test="tenantId != null">#{tenantId},</if>
<if test="tenantName != null and tenantName != ''">#{tenantName},</if>
<if test="serialNumber != null and serialNumber != ''">#{serialNumber},</if>
<if test="firmwareVersion != null">#{firmwareVersion},</if>
<if test="status != null">#{status},</if>
<if test="rssi != null">#{rssi},</if>
<if test="isShadow != null">#{isShadow},</if>
<if test="locationWay != null">#{locationWay},</if>
<if test="thingsModelValue != null">#{thingsModelValue},</if>
<if test="networkAddress != null">#{networkAddress},</if>
<if test="networkIp != null">#{networkIp},</if>
<if test="longitude != null">#{longitude},</if>
<if test="latitude != null">#{latitude},</if>
<if test="activeTime != null">#{activeTime},</if>
<if test="delFlag != null">#{delFlag},</if>
<if test="createBy != null">#{createBy},</if>
<if test="createTime != null">#{createTime},</if>
<if test="updateBy != null">#{updateBy},</if>
<if test="updateTime != null">#{updateTime},</if>
<if test="remark != null">#{remark},</if>
<if test="imgUrl != null">#{imgUrl},</if>
<if test="summary != null">#{summary},</if>
<if test="gwDevCode != null">#{gwDevCode},</if>
<if test="isSimulate != null">#{isSimulate},</if>
<if test="slaveId != null">#{slaveId},</if>
</trim>
</insert>
<update id="updateDevice" parameterType="com.fastbee.iot.domain.Device">
update iot_device
<trim prefix="SET" suffixOverrides=",">
<if test="deviceName != null and deviceName != ''">device_name = #{deviceName},</if>
<if test="productId != null">product_id = #{productId},</if>
<if test="productName != null and productName != ''">product_name = #{productName},</if>
<if test="userId != null">user_id = #{userId},</if>
<if test="userName != null and userName != ''">user_name = #{userName},</if>
<if test="tenantId != null">tenant_id = #{tenantId},</if>
<if test="tenantName != null and tenantName != ''">tenant_name = #{tenantName},</if>
<if test="serialNumber != null and serialNumber != ''">serial_number = #{serialNumber},</if>
<if test="gwDevCode != null and gwDevCode != ''">gw_dev_code = #{gwDevCode}, </if>
<if test="firmwareVersion != null">firmware_version = #{firmwareVersion},</if>
<if test="status != null">status = #{status},</if>
<if test="rssi != null">rssi = #{rssi},</if>
<if test="isShadow != null">is_shadow = #{isShadow},</if>
<if test="isSimulate != null">is_simulate = #{isSimulate},</if>
<if test="locationWay != null">location_way = #{locationWay},</if>
<if test="thingsModelValue != null">things_model_value = #{thingsModelValue},</if>
<if test="networkAddress != null">network_address = #{networkAddress},</if>
<if test="networkIp != null">network_ip = #{networkIp},</if>
<if test="longitude != null">longitude = #{longitude},</if>
<if test="latitude != null">latitude = #{latitude},</if>
<if test="activeTime != null">active_time = #{activeTime},</if>
<if test="delFlag != null">del_flag = #{delFlag},</if>
<if test="createBy != null">create_by = #{createBy},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="updateBy != null">update_by = #{updateBy},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
<if test="remark != null">remark = #{remark},</if>
<if test="imgUrl != null">img_url = #{imgUrl},</if>
<if test="summary != null">summary = #{summary},</if>
<if test="slaveId != null">slave_id = #{slaveId},</if>
</trim>
where device_id = #{deviceId}
</update>
<update id="updateDeviceStatus" parameterType="com.fastbee.iot.domain.Device">
update iot_device
<trim prefix="SET" suffixOverrides=",">
<if test="status != null">status = #{status},</if>
<if test="networkAddress != null">network_address = #{networkAddress},</if>
<if test="networkIp != null">network_ip = #{networkIp},</if>
<if test="longitude != null">longitude = #{longitude},</if>
<if test="latitude != null">latitude = #{latitude},</if>
<if test="activeTime != null">active_time = #{activeTime},</if>
<if test="updateTime !=null">update_time = #{updateTime,jdbcType=TIMESTAMP}</if>
</trim>
where serial_number = #{serialNumber} or gw_dev_code = #{serialNumber}
</update>
<update id="updateDeviceFirmwareVersion" parameterType="com.fastbee.iot.domain.Device">
update iot_device
set firmware_version = #{firmwareVersion,jdbcType=DECIMAL}
where serial_number = #{serialNumber,jdbcType=VARCHAR}
</update>
<update id="resetDeviceStatus" parameterType="String">
-- 设备状态1-未激活2-禁用3-在线4-离线)
update iot_device set status=4
where serial_number = #{serialNumber} and status = 3
</update>
<update id="updateDeviceBySerialNumber" parameterType="com.fastbee.iot.domain.Device">
update iot_device
<trim prefix="SET" suffixOverrides=",">
<if test="deviceName != null and deviceName != ''">device_name = #{deviceName},</if>
<if test="productId != null">product_id = #{productId},</if>
<if test="productName != null and productName != ''">product_name = #{productName},</if>
<if test="userId != null">user_id = #{userId},</if>
<if test="userName != null and userName != ''">user_name = #{userName},</if>
<if test="tenantId != null">tenant_id = #{tenantId},</if>
<if test="tenantName != null and tenantName != ''">tenant_name = #{tenantName},</if>
<if test="serialNumber != null and serialNumber != ''">serial_number = #{serialNumber},</if>
<if test="firmwareVersion != null">firmware_version = #{firmwareVersion},</if>
<if test="status != null">status = #{status},</if>
<if test="rssi != null">rssi = #{rssi},</if>
<if test="isShadow != null">is_shadow = #{isShadow},</if>
<if test="isSimulate != null">is_simulate = #{isSimulate},</if>
<if test="locationWay != null">location_way = #{locationWay},</if>
<if test="thingsModelValue != null">things_model_value = #{thingsModelValue},</if>
<if test="networkAddress != null">network_address = #{networkAddress},</if>
<if test="networkIp != null">network_ip = #{networkIp},</if>
<if test="longitude != null">longitude = #{longitude},</if>
<if test="latitude != null">latitude = #{latitude},</if>
<if test="activeTime != null">active_time = #{activeTime},</if>
<if test="delFlag != null">del_flag = #{delFlag},</if>
<if test="createBy != null">create_by = #{createBy},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="updateBy != null">update_by = #{updateBy},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
<if test="remark != null">remark = #{remark},</if>
<if test="imgUrl != null">img_url = #{imgUrl},</if>
<if test="summary != null">summary = #{summary},</if>
<if test="gwDevCode != null">gw_dev_code = #{gwDevCode},</if>
</trim>
where serial_number = #{serialNumber}
</update>
<delete id="deleteDeviceByDeviceId" parameterType="Long">
delete from iot_device where device_id = #{deviceId}
</delete>
<delete id="deleteDeviceByDeviceIds" parameterType="String">
delete from iot_device where device_id in
<foreach item="deviceId" collection="array" open="(" separator="," close=")">
#{deviceId}
</foreach>
</delete>
<select id="getDeviceNumCount" parameterType="String" resultType="int">
select count(*) from iot_device where serial_number = #{deviceNum}
</select>
<delete id="deleteDeviceGroupByDeviceId" parameterType="com.fastbee.iot.model.UserIdDeviceIdModel">
delete from iot_device_group
<where>
<if test="1==1"> and device_id = #{deviceId}</if>
<if test="userId != null"> and group_id in(select group_id from iot_group where user_id = #{userId})</if>
</where>
</delete>
<select id="selectProtocolBySerialNumber" parameterType="java.lang.String" resultType="java.util.Map">
select p.protocol_code as protocolCode,
p.product_id as productId,
d.serial_number as serialNumber
from iot_device d inner join
iot_product p on d.product_id = p.product_id
where serial_number = #{serialNumber,jdbcType=VARCHAR}
</select>
<select id="selectDevicesByProductId" resultMap="DeviceResult">
select d.serial_number,
d.device_name
from iot_device d
where d.product_id = #{productId,jdbcType=BIGINT}
<if test="hasSub != null and hasSub == 2">
and d.gw_dev_code is NULL
</if>
</select>
<select id="getSubDeviceCount" resultType="java.lang.Integer">
select count(*) from iot_device d where d.gw_dev_code = #{gwDevCode,jdbcType=VARCHAR}
</select>
<update id="batchChangeOnline">
update iot_device d
set d.status = 3,
d.update_time = now()
where d.serial_number in
<foreach collection="list" item="item" index="index" open="(" separator="," close=")">
#{item}
</foreach>
</update>
<update id="batchChangeOffline">
update iot_device d
set d.status = 4,
d.update_time = now()
where d.serial_number in
<foreach collection="list" item="item" index="index" open="(" separator="," close=")">
#{item}
</foreach>
</update>
<select id="selectOnlineModbusDevices" resultMap="DeviceResult">
select d.product_id,
d.serial_number,
d.is_simulate,
p.transport
from iot_device d inner join iot_product p on d.product_id = p.product_id
where d.status = 3
and p.protocol_code = 'MODBUS-RTU'
and d.gw_dev_code is null
</select>
<select id="selectMqttConnectData" resultMap="DeviceMqttVOResult">
select d.device_id,
d.serial_number,
d.product_id,
d.user_id,
p.mqtt_account,
p.mqtt_password,
p.mqtt_secret,
p.vertificate_method,
p.is_authorize
from iot_device d inner join iot_product p on d.product_id = p.product_id
where d.device_id = #{deviceId}
and d.del_flag = 0
and p.del_flag = 0
</select>
<select id="selectDeviceBySerialNumbers" resultMap="DeviceRelateAlertLogVOResult">
select device_id, serial_number, device_name, user_id
from iot_device
where serial_number in
<foreach collection="deviceNumbers" item="deviceNumber" index="index" open="(" separator="," close=")">
#{deviceNumber}
</foreach>
</select>
<select id="selectRelateAlertLogBySerialNumber" parameterType="java.lang.String" resultMap="DeviceRelateAlertLogVOResult">
select device_id, serial_number, device_name, user_id
from iot_device
where serial_number = #{deviceNumber}
</select>
<delete id="deleteSubDevice">
delete from iot_device where gw_dev_code = #{gwCode}
</delete>
</mapper>

View File

@@ -0,0 +1,146 @@
<?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.fastbee.iot.mapper.DeviceUserMapper">
<resultMap type="com.fastbee.iot.domain.DeviceUser" id="DeviceUserResult">
<result property="deviceId" column="device_id" />
<result property="userId" column="user_id" />
<result property="deviceName" column="device_name" />
<result property="userName" column="user_name" />
<result property="isOwner" column="is_owner" />
<result property="tenantId" column="tenant_id" />
<result property="tenantName" column="tenant_name" />
<result property="phonenumber" column="phonenumber" />
<result property="perms" column="perms" />
<result property="createTime" column="create_time" />
<result property="updateTime" column="update_time" />
<result property="remark" column="remark" />
</resultMap>
<resultMap type="com.fastbee.common.core.domain.entity.SysUser" id="ShareUserResult">
<id property="userId" column="user_id" />
<result property="userName" column="user_name" />
<result property="nickName" column="nick_name" />
<result property="email" column="email" />
<result property="phonenumber" column="phonenumber" />
<result property="sex" column="sex" />
<result property="avatar" column="avatar" />
<result property="createTime" column="create_time" />
<result property="remark" column="remark" />
</resultMap>
<sql id="selectDeviceUserVo">
select device_id, user_id, device_name, user_name, is_owner,tenant_id,tenant_name,phonenumber,perms, create_time, update_time, remark from iot_device_user
</sql>
<select id="selectShareUser" parameterType="com.fastbee.iot.domain.DeviceUser" resultMap="ShareUserResult">
select u.user_id, u.nick_name, u.user_name, u.email, u.avatar, u.phonenumber, u.sex, u.create_time from sys_user u
left join (select * from iot_device_user where iot_device_user.device_id=#{deviceId}) d on u.user_id = d.user_id
where u.del_flag = '0' and u.status=0 and u.phonenumber = #{phonenumber} and d.device_id is null
</select>
<select id="selectDeviceUserList" parameterType="com.fastbee.iot.domain.DeviceUser" resultMap="DeviceUserResult">
<include refid="selectDeviceUserVo"/>
<where>
<if test="1==1"> and device_id = #{deviceId}</if>
<if test="userId != null and userId != 0"> and user_id = #{userId}</if>
</where>
</select>
<select id="selectDeviceUserByDeviceId" parameterType="Long" resultMap="DeviceUserResult">
<include refid="selectDeviceUserVo"/>
where device_id = #{deviceId}
</select>
<select id="selectDeviceUserByDeviceIdAndUserId" resultMap="DeviceUserResult">
<include refid="selectDeviceUserVo"/>
where device_id = #{deviceId} and user_id = #{userId}
</select>
<insert id="insertDeviceUser" parameterType="com.fastbee.iot.domain.DeviceUser" keyProperty="deviceId">
insert into iot_device_user
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="deviceId != null">device_id,</if>
<if test="userId != null">user_id,</if>
<if test="deviceName != null and deviceName != ''">device_name,</if>
<if test="userName != null and userName != ''">user_name,</if>
<if test="isOwner != null">is_owner,</if>
<if test="tenantId != null">tenant_id,</if>
<if test="tenantName != null">tenant_name,</if>
<if test="phonenumber != null">phonenumber,</if>
<if test="perms != null">perms,</if>
<if test="delFlag != null">del_flag,</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="remark != null">remark,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="deviceId != null">#{deviceId},</if>
<if test="userId != null">#{userId},</if>
<if test="deviceName != null and deviceName != ''">#{deviceName},</if>
<if test="userName != null and userName != ''">#{userName},</if>
<if test="isOwner != null">#{isOwner},</if>
<if test="tenantId != null">#{tenantId},</if>
<if test="tenantName != null">#{tenantName},</if>
<if test="phonenumber != null">#{phonenumber},</if>
<if test="perms != null">#{perms},</if>
<if test="delFlag != null">#{delFlag},</if>
<if test="createBy != null">#{createBy},</if>
<if test="createTime != null">#{createTime},</if>
<if test="updateBy != null">#{updateBy},</if>
<if test="updateTime != null">#{updateTime},</if>
<if test="remark != null">#{remark},</if>
</trim>
</insert>
<insert id="insertDeviceUserList" parameterType="java.util.ArrayList">
insert into iot_device_user
(device_id, user_id, device_name, user_name, is_owner,tenant_id,tenant_name,phonenumber,perms, create_time) values
<foreach collection="list" item="item" index="index" separator=",">
(#{item.deviceId},#{item.userId},#{item.deviceName}, #{item.userName}, #{item.isOwner}, #{item.tenantId},#{item.tenantName},#{item.phonenumber},#{item.perms}, #{item.createTime})
</foreach>
</insert>
<update id="updateDeviceUser" parameterType="com.fastbee.iot.domain.DeviceUser">
update iot_device_user
<trim prefix="SET" suffixOverrides=",">
<if test="userId != null">user_id = #{userId},</if>
<if test="deviceName != null and deviceName != ''">device_name = #{deviceName},</if>
<if test="userName != null and userName != ''">user_name = #{userName},</if>
<if test="isOwner != null">is_owner = #{isOwner},</if>
<if test="tenantId != null">tenant_id = #{tenantId},</if>
<if test="tenantName != null">tenant_name = #{tenantName},</if>
<if test="phonenumber != null">phonenumber = #{phonenumber},</if>
<if test="perms != null">perms = #{perms},</if>
<if test="delFlag != null">del_flag = #{delFlag},</if>
<if test="createBy != null">create_by = #{createBy},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="updateBy != null">update_by = #{updateBy},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
<if test="remark != null">remark = #{remark},</if>
</trim>
where device_id = #{deviceId} and user_id = #{userId}
</update>
<delete id="deleteDeviceUserByDeviceId" parameterType="com.fastbee.iot.model.UserIdDeviceIdModel">
delete from iot_device_user
<where>
<if test="1==1"> and device_id = #{deviceId}</if>
<if test="userId != null"> and user_id = #{userId}</if>
</where>
</delete>
<delete id="deleteDeviceUserByDeviceIds" parameterType="String">
delete from iot_device_user where device_id in
<foreach item="deviceId" collection="array" open="(" separator="," close=")">
#{deviceId}
</foreach>
</delete>
<delete id="deleteDeviceUser">
delete from iot_device_user where device_id = #{deviceId} and is_owner !=1 and user_id = #{userId}
</delete>
</mapper>

View File

@@ -0,0 +1,149 @@
<?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.fastbee.iot.mapper.EventLogMapper">
<resultMap type="com.fastbee.iot.domain.EventLog" id="EventLogResult">
<result property="logId" column="log_id" />
<result property="identity" column="identity" />
<result property="modelName" column="model_name" />
<result property="logType" column="log_type" />
<result property="logValue" column="log_value" />
<result property="deviceId" column="device_id" />
<result property="deviceName" column="device_name" />
<result property="serialNumber" column="serial_number" />
<result property="isMonitor" column="is_monitor" />
<result property="mode" column="mode" />
<result property="userId" column="user_id" />
<result property="userName" column="user_name" />
<result property="tenantId" column="tenant_id" />
<result property="tenantName" column="tenant_name" />
<result property="createBy" column="create_by" />
<result property="createTime" column="create_time" />
<result property="remark" column="remark" />
</resultMap>
<sql id="selectEventLogVo">
select log_id, identity, model_name, log_type, log_value, device_id, device_name, serial_number, is_monitor, mode, user_id, user_name, tenant_id, tenant_name, create_by, create_time, remark from iot_event_log
</sql>
<select id="selectEventLogList" parameterType="com.fastbee.iot.domain.EventLog" resultMap="EventLogResult">
<include refid="selectEventLogVo"/>
<where>
<if test="identity != null and identity != ''"> and identity = #{identity}</if>
<if test="modelName != null and modelName != ''"> and model_name like concat('%', #{modelName}, '%')</if>
<if test="logType != null "> and log_type = #{logType}</if>
<if test="logValue != null and logValue != ''"> and log_value = #{logValue}</if>
<if test="deviceId != null "> and device_id = #{deviceId}</if>
<if test="deviceName != null and deviceName != ''"> and device_name like concat('%', #{deviceName}, '%')</if>
<if test="serialNumber != null and serialNumber != ''"> and serial_number = #{serialNumber}</if>
<if test="isMonitor != null "> and is_monitor = #{isMonitor}</if>
<if test="mode != null "> and mode = #{mode}</if>
<if test="userId != null "> and user_id = #{userId}</if>
<if test="userName != null and userName != ''"> and user_name like concat('%', #{userName}, '%')</if>
<if test="tenantId != null "> and tenant_id = #{tenantId}</if>
<if test="tenantName != null and tenantName != ''"> and tenant_name like concat('%', #{tenantName}, '%')</if>
<if test="params.beginTime != null and params.beginTime != ''"><!-- 开始时间检索 -->
and date_format(create_time,'%y%m%d') &gt;= date_format(#{params.beginTime},'%y%m%d')
</if>
<if test="params.endTime != null and params.endTime != ''"><!-- 结束时间检索 -->
and date_format(create_time,'%y%m%d') &lt;= date_format(#{params.endTime},'%y%m%d')
</if>
</where>
order by create_time DESC
</select>
<select id="selectEventLogByLogId" parameterType="Long" resultMap="EventLogResult">
<include refid="selectEventLogVo"/>
where log_id = #{logId}
</select>
<insert id="insertEventLog" parameterType="com.fastbee.iot.domain.EventLog" useGeneratedKeys="true" keyProperty="logId">
insert into iot_event_log
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="identity != null and identity != ''">identity,</if>
<if test="modelName != null">model_name,</if>
<if test="logType != null">log_type,</if>
<if test="logValue != null and logValue != ''">log_value,</if>
<if test="deviceId != null">device_id,</if>
<if test="deviceName != null">device_name,</if>
<if test="serialNumber != null">serial_number,</if>
<if test="isMonitor != null">is_monitor,</if>
<if test="mode != null">mode,</if>
<if test="userId != null">user_id,</if>
<if test="userName != null">user_name,</if>
<if test="tenantId != null">tenant_id,</if>
<if test="tenantName != null">tenant_name,</if>
<if test="createBy != null">create_by,</if>
<if test="createTime != null">create_time,</if>
<if test="remark != null">remark,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="identity != null and identity != ''">#{identity},</if>
<if test="modelName != null">#{modelName},</if>
<if test="logType != null">#{logType},</if>
<if test="logValue != null and logValue != ''">#{logValue},</if>
<if test="deviceId != null">#{deviceId},</if>
<if test="deviceName != null">#{deviceName},</if>
<if test="serialNumber != null">#{serialNumber},</if>
<if test="isMonitor != null">#{isMonitor},</if>
<if test="mode != null">#{mode},</if>
<if test="userId != null">#{userId},</if>
<if test="userName != null">#{userName},</if>
<if test="tenantId != null">#{tenantId},</if>
<if test="tenantName != null">#{tenantName},</if>
<if test="createBy != null">#{createBy},</if>
<if test="createTime != null">#{createTime},</if>
<if test="remark != null">#{remark},</if>
</trim>
</insert>
<insert id="insertBatch" parameterType="com.fastbee.iot.domain.EventLog">
insert into iot_event_log (identity,model_name,log_type,log_value,device_id,device_name,serial_number,is_monitor,mode,user_id,
user_name,tenant_id,tenant_name,create_by,create_time,remark)
values
<foreach collection="list" separator="," index="index" item="item">
(#{item.identity},#{item.modelName},#{item.logType},#{item.logValue},#{item.deviceId},#{item.deviceName},#{item.serialNumber},#{item.isMonitor},
#{item.mode},#{item.userId},#{item.userName},#{item.tenantId},#{item.tenantName},#{item.createBy},#{item.createTime},#{item.remark})
</foreach>
</insert>
<update id="updateEventLog" parameterType="com.fastbee.iot.domain.EventLog">
update iot_event_log
<trim prefix="SET" suffixOverrides=",">
<if test="identity != null and identity != ''">identity = #{identity},</if>
<if test="modelName != null">model_name = #{modelName},</if>
<if test="logType != null">log_type = #{logType},</if>
<if test="logValue != null and logValue != ''">log_value = #{logValue},</if>
<if test="deviceId != null">device_id = #{deviceId},</if>
<if test="deviceName != null">device_name = #{deviceName},</if>
<if test="serialNumber != null">serial_number = #{serialNumber},</if>
<if test="isMonitor != null">is_monitor = #{isMonitor},</if>
<if test="mode != null">mode = #{mode},</if>
<if test="userId != null">user_id = #{userId},</if>
<if test="userName != null">user_name = #{userName},</if>
<if test="tenantId != null">tenant_id = #{tenantId},</if>
<if test="tenantName != null">tenant_name = #{tenantName},</if>
<if test="createBy != null">create_by = #{createBy},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="remark != null">remark = #{remark},</if>
</trim>
where log_id = #{logId}
</update>
<delete id="deleteEventLogByLogId" parameterType="Long">
delete from iot_event_log where log_id = #{logId}
</delete>
<delete id="deleteEventLogBySerialNumber" parameterType="String">
delete from iot_event_log where serial_number = #{serialNumber}
</delete>
<delete id="deleteEventLogByLogIds" parameterType="String">
delete from iot_event_log where log_id in
<foreach item="logId" collection="array" open="(" separator="," close=")">
#{logId}
</foreach>
</delete>
</mapper>

View File

@@ -0,0 +1,185 @@
<?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.fastbee.iot.mapper.FunctionLogMapper">
<resultMap type="com.fastbee.iot.domain.FunctionLog" id="FunctionLogResult">
<result property="id" column="id" />
<result property="identify" column="identify" />
<result property="funType" column="fun_type" />
<result property="funValue" column="fun_value" />
<result property="messageId" column="message_id" />
<result property="deviceName" column="device_name" />
<result property="serialNumber" column="serial_number" />
<result property="mode" column="mode" />
<result property="userId" column="user_id" />
<result property="resultMsg" column="result_msg" />
<result property="resultCode" column="result_code" />
<result property="createBy" column="create_by" />
<result property="createTime" column="create_time" />
<result property="remark" column="remark" />
<result property="showValue" column="show_value"/>
<result property="modelName" column="model_name"/>
<result property="replyTime" column="reply_time"/>
</resultMap>
<sql id="selectFunctionLogVo">
select id, identify, fun_type, fun_value, message_id, device_name, serial_number, mode, user_id, result_msg, result_code, create_by,
create_time, remark,show_value,model_name,reply_time from iot_function_log
</sql>
<select id="selectFunctionLogList" parameterType="FunctionLog" resultMap="FunctionLogResult">
<include refid="selectFunctionLogVo"/>
<where>
<if test="prefixIdentify != null and prefixIdentify != ''"> and identify like concat(#{prefixIdentify},'%')</if>
<if test="identify != null and identify != ''"> and identify = #{identify}</if>
<if test="funType != null "> and fun_type = #{funType}</if>
<if test="funValue != null and funValue != ''"> and fun_value = #{funValue}</if>
<if test="messageId != null and messageId != ''"> and message_id = #{messageId}</if>
<if test="deviceName != null and deviceName != ''"> and device_name like concat('%', #{deviceName}, '%')</if>
<if test="serialNumber != null and serialNumber != ''"> and serial_number = #{serialNumber}</if>
<if test="mode != null "> and mode = #{mode}</if>
<if test="userId != null "> and user_id = #{userId}</if>
<if test="resultMsg != null and resultMsg != ''"> and result_msg = #{resultMsg}</if>
<if test="resultCode != null "> and result_code = #{resultCode}</if>
<if test="beginTime != null and beginTime != ''">
and date_format(create_time,'%y%m%d') &gt;= date_format(#{beginTime},'%y%m%d')
</if>
<if test="endTime != null and endTime != ''">
and date_format(create_time,'%y%m%d') &lt;= date_format(#{endTime},'%y%m%d')
</if>
<if test="modelName != null and modelName != ''">and model_name = #{modelName}</if>
</where>
order by create_time DESC
</select>
<select id="selectFunctionLogById" parameterType="Long" resultMap="FunctionLogResult">
<include refid="selectFunctionLogVo"/>
where id = #{id}
</select>
<insert id="insertFunctionLog" parameterType="FunctionLog" useGeneratedKeys="true" keyProperty="id">
insert into iot_function_log
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="identify != null and identify != ''">identify,</if>
<if test="funType != null">fun_type,</if>
<if test="funValue != null and funValue != ''">fun_value,</if>
<if test="messageId != null">message_id,</if>
<if test="deviceName != null">device_name,</if>
<if test="serialNumber != null and serialNumber != ''">serial_number,</if>
<if test="mode != null">mode,</if>
<if test="userId != null">user_id,</if>
<if test="resultMsg != null">result_msg,</if>
<if test="resultCode != null">result_code,</if>
<if test="createBy != null">create_by,</if>
<if test="createTime != null">create_time,</if>
<if test="remark != null">remark,</if>
<if test="showValue != null">show_value,</if>
<if test="modelName != null and modelName !=''">model_name,</if>
<if test="replyTime != null">reply_time,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="identify != null and identify != ''">#{identify},</if>
<if test="funType != null">#{funType},</if>
<if test="funValue != null and funValue != ''">#{funValue},</if>
<if test="messageId != null">#{messageId},</if>
<if test="deviceName != null">#{deviceName},</if>
<if test="serialNumber != null and serialNumber != ''">#{serialNumber},</if>
<if test="mode != null">#{mode},</if>
<if test="userId != null">#{userId},</if>
<if test="resultMsg != null">#{resultMsg},</if>
<if test="resultCode != null">#{resultCode},</if>
<if test="createBy != null">#{createBy},</if>
<if test="createTime != null">#{createTime},</if>
<if test="remark != null">#{remark},</if>
<if test="showValue != null">#{showValue},</if>
<if test="modelName != null and modelName !=''">#{modelName},</if>
<if test="replyTime != null">#{replyTime},</if>
</trim>
</insert>
<insert id="insertBatch" parameterType="com.fastbee.iot.domain.FunctionLog">
insert into iot_function_log (identify,fun_type,fun_value,message_id,device_name,serial_number,mode,user_id,
result_msg,result_code,create_by,create_time,remark,show_value,model_name,reply_time)
values
<foreach collection="list" item="item" index="index" separator=",">
(#{item.identify},#{item.funType},#{item.funValue},#{item.messageId},#{item.deviceName},#{item.serialNumber},#{item.mode},#{item.userId},
#{item.resultMsg},#{item.resultCode},#{item.createBy},#{item.createTime},#{item.remark},#{item.showValue},#{item.modelName},#{item.replyTime})
</foreach>
</insert>
<update id="updateFunctionLog" parameterType="FunctionLog">
update iot_function_log
<trim prefix="SET" suffixOverrides=",">
<if test="identify != null and identify != ''">identify = #{identify},</if>
<if test="funType != null">fun_type = #{funType},</if>
<if test="funValue != null and funValue != ''">fun_value = #{funValue},</if>
<if test="messageId != null">message_id = #{messageId},</if>
<if test="deviceName != null">device_name = #{deviceName},</if>
<if test="serialNumber != null and serialNumber != ''">serial_number = #{serialNumber},</if>
<if test="mode != null">mode = #{mode},</if>
<if test="userId != null">user_id = #{userId},</if>
<if test="resultMsg != null">result_msg = #{resultMsg},</if>
<if test="resultCode != null">result_code = #{resultCode},</if>
<if test="createBy != null">create_by = #{createBy},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="remark != null">remark = #{remark},</if>
<if test="showValue != null">show_value=#{showValue},</if>
<if test="modelName != null and modelName !=''">model_name=#{modelName},</if>
<if test="replyTime != null">reply_time = #{replyTime},</if>
</trim>
where id = #{id}
</update>
<delete id="deleteFunctionLogById" parameterType="Long">
delete from iot_function_log where id = #{id}
</delete>
<delete id="deleteFunctionLogBySerialNumber" parameterType="String">
delete from iot_function_log where serial_number = #{serialNumber}
</delete>
<delete id="deleteFunctionLogByPreIdentify" parameterType="FunctionLog">
delete from iot_function_log where identify like concat(#{prefixIdentify},'%') and serial_number = #{serialNumber}
</delete>
<delete id="deleteFunctionLogByIds" parameterType="String">
delete from iot_function_log where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
<update id="updateFuncLogBatch" parameterType="com.fastbee.iot.domain.FunctionLog">
update iot_function_log l
set l.result_msg = #{resultMsg},
l.result_code = #{resultCode},
l.reply_time = #{replyTime}
where l.id in
<foreach collection="list" item="item" index="index" open="(" close=")" separator=",">
#{item}
</foreach>
</update>
<update id="updateByMessageId" parameterType="FunctionLog">
update iot_function_log
<trim prefix="SET" suffixOverrides=",">
<if test="identify != null and identify != ''">identify = #{identify},</if>
<if test="funType != null">fun_type = #{funType},</if>
<if test="funValue != null and funValue != ''">fun_value = #{funValue},</if>
<if test="deviceName != null">device_name = #{deviceName},</if>
<if test="serialNumber != null and serialNumber != ''">serial_number = #{serialNumber},</if>
<if test="mode != null">mode = #{mode},</if>
<if test="userId != null">user_id = #{userId},</if>
<if test="resultMsg != null">result_msg = #{resultMsg},</if>
<if test="resultCode != null">result_code = #{resultCode},</if>
<if test="createBy != null">create_by = #{createBy},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="remark != null">remark = #{remark},</if>
<if test="showValue != null">show_value=#{showValue},</if>
<if test="modelName != null and modelName !=''">model_name=#{modelName},</if>
<if test="replyTime != null">reply_time = #{replyTime},</if>
</trim>
where message_id = #{messageId}
</update>
</mapper>

View File

@@ -0,0 +1,117 @@
<?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.fastbee.iot.mapper.GroupMapper">
<resultMap type="com.fastbee.iot.domain.Group" id="GroupResult">
<result property="groupId" column="group_id" />
<result property="groupName" column="group_name" />
<result property="groupOrder" column="group_order" />
<result property="userId" column="user_id" />
<result property="userName" column="user_name" />
<result property="createTime" column="create_time" />
<result property="updateTime" column="update_time" />
<result property="remark" column="remark" />
</resultMap>
<resultMap type="com.fastbee.iot.model.IdOutput" id="IdsResult">
<result property="id" column="device_id" />
</resultMap>
<sql id="selectGroupVo">
select group_id, group_name, group_order, user_id, user_name, create_time, update_time, remark from iot_group
</sql>
<select id="selectGroupList" parameterType="com.fastbee.iot.domain.Group" resultMap="GroupResult">
<include refid="selectGroupVo"/>
<where>
<if test="groupName != null and groupName != ''"> and group_name like concat('%', #{groupName}, '%')</if>
<if test="userName != null and userName != ''"> and user_name like concat('%', #{userName}, '%')</if>
<if test="userId != null "> and user_id = #{userId}</if>
</where>
order by group_order
</select>
<select id="selectGroupByGroupId" parameterType="Long" resultMap="GroupResult">
<include refid="selectGroupVo"/>
where group_id = #{groupId}
</select>
<select id="selectDeviceIdsByGroupId" parameterType="Long" resultMap="IdsResult">
select device_id from iot_device_group where group_id=#{groupId}
</select>
<insert id="insertGroup" parameterType="com.fastbee.iot.domain.Group" useGeneratedKeys="true" keyProperty="groupId">
insert into iot_group
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="groupName != null and groupName != ''">group_name,</if>
<if test="groupOrder != null">group_order,</if>
<if test="userId != null">user_id,</if>
<if test="userName != null and userName != ''">user_name,</if>
<if test="delFlag != null">del_flag,</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="remark != null">remark,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="groupName != null and groupName != ''">#{groupName},</if>
<if test="groupOrder != null">#{groupOrder},</if>
<if test="userId != null">#{userId},</if>
<if test="userName != null and userName != ''">#{userName},</if>
<if test="delFlag != null">#{delFlag},</if>
<if test="createBy != null">#{createBy},</if>
<if test="createTime != null">#{createTime},</if>
<if test="updateBy != null">#{updateBy},</if>
<if test="updateTime != null">#{updateTime},</if>
<if test="remark != null">#{remark},</if>
</trim>
</insert>
<insert id="insertDeviceGroups" parameterType="com.fastbee.iot.model.DeviceGroupInput">
insert into iot_device_group (device_id,group_id)
values
<foreach item="deviceId" collection="deviceIds" separator=",">
<trim prefix="(" suffix=")" suffixOverrides=",">
#{deviceId},#{groupId},
</trim>
</foreach>
</insert>
<update id="updateGroup" parameterType="com.fastbee.iot.domain.Group">
update iot_group
<trim prefix="SET" suffixOverrides=",">
<if test="groupName != null and groupName != ''">group_name = #{groupName},</if>
<if test="groupOrder != null">group_order = #{groupOrder},</if>
<if test="userId != null">user_id = #{userId},</if>
<if test="userName != null and userName != ''">user_name = #{userName},</if>
<if test="delFlag != null">del_flag = #{delFlag},</if>
<if test="createBy != null">create_by = #{createBy},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="updateBy != null">update_by = #{updateBy},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
<if test="remark != null">remark = #{remark},</if>
</trim>
where group_id = #{groupId}
</update>
<delete id="deleteGroupByGroupId" parameterType="Long">
delete from iot_group where group_id = #{groupId}
</delete>
<delete id="deleteGroupByGroupIds" parameterType="String">
delete from iot_group where group_id in
<foreach item="groupId" collection="array" open="(" separator="," close=")">
#{groupId}
</foreach>
</delete>
<delete id="deleteDeviceGroupByGroupIds" parameterType="String">
delete from iot_device_group where group_id in
<foreach item="groupId" collection="array" open="(" separator="," close=")">
#{groupId}
</foreach>
</delete>
</mapper>

View File

@@ -0,0 +1,103 @@
<?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.fastbee.iot.mapper.NewsCategoryMapper">
<resultMap type="com.fastbee.iot.domain.NewsCategory" id="NewsCategoryResult">
<result property="categoryId" column="category_id" />
<result property="categoryName" column="category_name" />
<result property="orderNum" column="order_num" />
<result property="delFlag" column="del_flag" />
<result property="createBy" column="create_by" />
<result property="createTime" column="create_time" />
<result property="updateBy" column="update_by" />
<result property="updateTime" column="update_time" />
<result property="remark" column="remark" />
</resultMap>
<resultMap type="com.fastbee.iot.model.IdAndName" id="CategoryShortResult">
<result property="id" column="category_id" />
<result property="name" column="category_name" />
</resultMap>
<sql id="selectNewsCategoryVo">
select category_id, category_name, order_num, del_flag, create_by, create_time, update_by, update_time, remark from news_category
</sql>
<select id="selectNewsCategoryList" parameterType="com.fastbee.iot.domain.NewsCategory" resultMap="NewsCategoryResult">
<include refid="selectNewsCategoryVo"/>
<where>
<if test="categoryName != null and categoryName != ''"> and category_name like concat('%', #{categoryName}, '%')</if>
</where>
order by order_num
</select>
<select id="selectNewsCategoryShortList" resultMap="CategoryShortResult">
select category_id, category_name
from news_category
order by order_num
</select>
<select id="selectNewsCategoryByCategoryId" parameterType="Long" resultMap="NewsCategoryResult">
<include refid="selectNewsCategoryVo"/>
where category_id = #{categoryId}
</select>
<insert id="insertNewsCategory" parameterType="com.fastbee.iot.domain.NewsCategory" useGeneratedKeys="true" keyProperty="categoryId">
insert into news_category
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="categoryName != null and categoryName != ''">category_name,</if>
<if test="orderNum != null">order_num,</if>
<if test="delFlag != null">del_flag,</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="remark != null">remark,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="categoryName != null and categoryName != ''">#{categoryName},</if>
<if test="orderNum != null">#{orderNum},</if>
<if test="delFlag != null">#{delFlag},</if>
<if test="createBy != null">#{createBy},</if>
<if test="createTime != null">#{createTime},</if>
<if test="updateBy != null">#{updateBy},</if>
<if test="updateTime != null">#{updateTime},</if>
<if test="remark != null">#{remark},</if>
</trim>
</insert>
<update id="updateNewsCategory" parameterType="com.fastbee.iot.domain.NewsCategory">
update news_category
<trim prefix="SET" suffixOverrides=",">
<if test="categoryName != null and categoryName != ''">category_name = #{categoryName},</if>
<if test="orderNum != null">order_num = #{orderNum},</if>
<if test="delFlag != null">del_flag = #{delFlag},</if>
<if test="createBy != null">create_by = #{createBy},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="updateBy != null">update_by = #{updateBy},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
<if test="remark != null">remark = #{remark},</if>
</trim>
where category_id = #{categoryId}
</update>
<delete id="deleteNewsCategoryByCategoryId" parameterType="Long">
delete from news_category where category_id = #{categoryId}
</delete>
<delete id="deleteNewsCategoryByCategoryIds" parameterType="String">
delete from news_category where category_id in
<foreach item="categoryId" collection="array" open="(" separator="," close=")">
#{categoryId}
</foreach>
</delete>
<select id="newsCountInCategorys" parameterType="String" resultType="int">
select count(*) from news where category_id in
<foreach item="categoryId" collection="array" open="(" separator="," close=")">
#{categoryId}
</foreach>
</select>
</mapper>

View File

@@ -0,0 +1,127 @@
<?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.fastbee.iot.mapper.NewsMapper">
<resultMap type="com.fastbee.iot.domain.News" id="NewsResult">
<result property="newsId" column="news_id" />
<result property="title" column="title" />
<result property="content" column="content" />
<result property="imgUrl" column="img_url" />
<result property="isTop" column="is_top" />
<result property="isBanner" column="is_banner" />
<result property="categoryId" column="category_id" />
<result property="categoryName" column="category_name" />
<result property="status" column="status" />
<result property="author" column="author" />
<result property="delFlag" column="del_flag" />
<result property="createBy" column="create_by" />
<result property="createTime" column="create_time" />
<result property="updateBy" column="update_by" />
<result property="updateTime" column="update_time" />
<result property="remark" column="remark" />
</resultMap>
<sql id="selectNewsVo">
select news_id, title, img_url, is_top, is_banner, category_id, category_name, status, author, del_flag, create_by, create_time, update_by, update_time, remark from news
</sql>
<select id="selectNewsList" parameterType="com.fastbee.iot.domain.News" resultMap="NewsResult">
select news_id, title, img_url, is_top, is_banner, category_id, category_name, status, author,
create_by, create_time, update_by, update_time, remark
from news s
<where>
<if test="title != null and title != ''"> and title like concat('%', #{title}, '%')</if>
<if test="categoryId != null "> and category_id = #{categoryId}</if>
<if test="isTop != null "> and is_top = #{isTop}</if>
<if test="isBanner != null "> and is_banner = #{isBanner}</if>
<if test="categoryName != null and categoryName != ''"> and category_name like concat('%', #{categoryName}, '%')</if>
<if test="status != null "> and status = #{status}</if>
</where>
order by create_time desc
</select>
<select id="selectTopNewsList" parameterType="com.fastbee.iot.domain.News" resultMap="NewsResult">
select n.news_id, n.title, n.img_url, n.is_top, n.is_banner, n.category_id, c.category_name, n.status, n.author, n.create_time, n.remark
from news n left join news_category c on c.category_id=n.category_id
where n.is_top=1 and n.status=1
order by n.create_time desc
</select>
<select id="selectNewsByNewsId" parameterType="Long" resultMap="NewsResult">
select news_id, title, content, img_url, is_top, is_banner, category_id, category_name, status, author, del_flag, create_by, create_time, update_by, update_time, remark from news
where news_id = #{newsId}
</select>
<insert id="insertNews" parameterType="com.fastbee.iot.domain.News" useGeneratedKeys="true" keyProperty="newsId">
insert into news
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="title != null and title != ''">title,</if>
<if test="content != null and content != ''">content,</if>
<if test="imgUrl != null and imgUrl != ''">img_url,</if>
<if test="isTop != null">is_top,</if>
<if test="isBanner != null">is_banner,</if>
<if test="categoryId != null">category_id,</if>
<if test="categoryName != null and categoryName != ''">category_name,</if>
<if test="status != null">status,</if>
<if test="author != null and author != ''">author,</if>
<if test="delFlag != null">del_flag,</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="remark != null">remark,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="title != null and title != ''">#{title},</if>
<if test="content != null and content != ''">#{content},</if>
<if test="imgUrl != null and imgUrl != ''">#{imgUrl},</if>
<if test="isTop != null">#{isTop},</if>
<if test="isBanner != null">#{isBanner},</if>
<if test="categoryId != null">#{categoryId},</if>
<if test="categoryName != null and categoryName != ''">#{categoryName},</if>
<if test="status != null">#{status},</if>
<if test="author != null and author != ''">#{author},</if>
<if test="delFlag != null">#{delFlag},</if>
<if test="createBy != null">#{createBy},</if>
<if test="createTime != null">#{createTime},</if>
<if test="updateBy != null">#{updateBy},</if>
<if test="updateTime != null">#{updateTime},</if>
<if test="remark != null">#{remark},</if>
</trim>
</insert>
<update id="updateNews" parameterType="com.fastbee.iot.domain.News">
update news
<trim prefix="SET" suffixOverrides=",">
<if test="title != null and title != ''">title = #{title},</if>
<if test="content != null and content != ''">content = #{content},</if>
<if test="imgUrl != null and imgUrl != ''">img_url = #{imgUrl},</if>
<if test="isTop != null">is_top = #{isTop},</if>
<if test="isBanner != null">is_banner = #{isBanner},</if>
<if test="categoryId != null">category_id = #{categoryId},</if>
<if test="categoryName != null and categoryName != ''">category_name = #{categoryName},</if>
<if test="status != null">status = #{status},</if>
<if test="author != null and author != ''">author = #{author},</if>
<if test="delFlag != null">del_flag = #{delFlag},</if>
<if test="createBy != null">create_by = #{createBy},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="updateBy != null">update_by = #{updateBy},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
<if test="remark != null">remark = #{remark},</if>
</trim>
where news_id = #{newsId}
</update>
<delete id="deleteNewsByNewsId" parameterType="Long">
delete from news where news_id = #{newsId}
</delete>
<delete id="deleteNewsByNewsIds" parameterType="String">
delete from news where news_id in
<foreach item="newsId" collection="array" open="(" separator="," close=")">
#{newsId}
</foreach>
</delete>
</mapper>

View File

@@ -0,0 +1,101 @@
<?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.fastbee.iot.mapper.OauthClientDetailsMapper">
<resultMap type="com.fastbee.iot.domain.OauthClientDetails" id="OauthClientDetailsResult">
<result property="clientId" column="client_id" />
<result property="resourceIds" column="resource_ids" />
<result property="clientSecret" column="client_secret" />
<result property="scope" column="scope" />
<result property="authorizedGrantTypes" column="authorized_grant_types" />
<result property="webServerRedirectUri" column="web_server_redirect_uri" />
<result property="authorities" column="authorities" />
<result property="accessTokenValidity" column="access_token_validity" />
<result property="refreshTokenValidity" column="refresh_token_validity" />
<result property="additionalInformation" column="additional_information" />
<result property="autoapprove" column="autoapprove" />
<result property="type" column="type" />
</resultMap>
<sql id="selectOauthClientDetailsVo">
select client_id, resource_ids, client_secret, scope, authorized_grant_types, web_server_redirect_uri, authorities, access_token_validity, refresh_token_validity, additional_information, autoapprove, type from oauth_client_details
</sql>
<select id="selectOauthClientDetailsList" parameterType="com.fastbee.iot.domain.OauthClientDetails" resultMap="OauthClientDetailsResult">
<include refid="selectOauthClientDetailsVo"/>
<where>
<if test="clientId != null and clientId != ''"> and client_id = #{clientId}</if>
<if test="authorizedGrantTypes != null and authorizedGrantTypes != ''"> and authorized_grant_types = #{authorizedGrantTypes}</if>
<if test="autoapprove != null and autoapprove != ''"> and autoapprove = #{autoapprove}</if>
<if test="type != null "> and type = #{type}</if>
</where>
</select>
<select id="selectOauthClientDetailsByClientId" parameterType="String" resultMap="OauthClientDetailsResult">
<include refid="selectOauthClientDetailsVo"/>
where client_id = #{clientId}
</select>
<insert id="insertOauthClientDetails" parameterType="com.fastbee.iot.domain.OauthClientDetails">
insert into oauth_client_details
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="clientId != null">client_id,</if>
<if test="resourceIds != null">resource_ids,</if>
<if test="clientSecret != null">client_secret,</if>
<if test="scope != null">scope,</if>
<if test="authorizedGrantTypes != null">authorized_grant_types,</if>
<if test="webServerRedirectUri != null">web_server_redirect_uri,</if>
<if test="authorities != null">authorities,</if>
<if test="accessTokenValidity != null">access_token_validity,</if>
<if test="refreshTokenValidity != null">refresh_token_validity,</if>
<if test="additionalInformation != null">additional_information,</if>
<if test="autoapprove != null">autoapprove,</if>
<if test="type != null">type,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="clientId != null">#{clientId},</if>
<if test="resourceIds != null">#{resourceIds},</if>
<if test="clientSecret != null">#{clientSecret},</if>
<if test="scope != null">#{scope},</if>
<if test="authorizedGrantTypes != null">#{authorizedGrantTypes},</if>
<if test="webServerRedirectUri != null">#{webServerRedirectUri},</if>
<if test="authorities != null">#{authorities},</if>
<if test="accessTokenValidity != null">#{accessTokenValidity},</if>
<if test="refreshTokenValidity != null">#{refreshTokenValidity},</if>
<if test="additionalInformation != null">#{additionalInformation},</if>
<if test="autoapprove != null">#{autoapprove},</if>
<if test="type != null">#{type},</if>
</trim>
</insert>
<update id="updateOauthClientDetails" parameterType="com.fastbee.iot.domain.OauthClientDetails">
update oauth_client_details
<trim prefix="SET" suffixOverrides=",">
<if test="resourceIds != null">resource_ids = #{resourceIds},</if>
<if test="clientSecret != null">client_secret = #{clientSecret},</if>
<if test="scope != null">scope = #{scope},</if>
<if test="authorizedGrantTypes != null">authorized_grant_types = #{authorizedGrantTypes},</if>
<if test="webServerRedirectUri != null">web_server_redirect_uri = #{webServerRedirectUri},</if>
<if test="authorities != null">authorities = #{authorities},</if>
<if test="accessTokenValidity != null">access_token_validity = #{accessTokenValidity},</if>
<if test="refreshTokenValidity != null">refresh_token_validity = #{refreshTokenValidity},</if>
<if test="additionalInformation != null">additional_information = #{additionalInformation},</if>
<if test="autoapprove != null">autoapprove = #{autoapprove},</if>
<if test="type != null">type = #{type},</if>
</trim>
where client_id = #{clientId}
</update>
<delete id="deleteOauthClientDetailsByClientId" parameterType="String">
delete from oauth_client_details where client_id = #{clientId}
</delete>
<delete id="deleteOauthClientDetailsByClientIds" parameterType="String">
delete from oauth_client_details where client_id in
<foreach item="clientId" collection="array" open="(" separator="," close=")">
#{clientId}
</foreach>
</delete>
</mapper>

View File

@@ -0,0 +1,142 @@
<?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.fastbee.iot.mapper.ProductAuthorizeMapper">
<resultMap type="com.fastbee.iot.domain.ProductAuthorize" id="ProductAuthorizeResult">
<result property="authorizeId" column="authorize_id" />
<result property="authorizeCode" column="authorize_code" />
<result property="productId" column="product_id" />
<result property="deviceId" column="device_id" />
<result property="serialNumber" column="serial_number" />
<result property="userId" column="user_id" />
<result property="userName" column="user_name" />
<result property="status" column="status" />
<result property="delFlag" column="del_flag" />
<result property="createBy" column="create_by" />
<result property="createTime" column="create_time" />
<result property="updateBy" column="update_by" />
<result property="updateTime" column="update_time" />
<result property="remark" column="remark" />
</resultMap>
<sql id="selectProductAuthorizeVo">
select authorize_id, authorize_code, product_id, device_id, serial_number, user_id, user_name,status, del_flag, create_by, create_time, update_by, update_time, remark from iot_product_authorize
</sql>
<select id="selectProductAuthorizeList" parameterType="com.fastbee.iot.domain.ProductAuthorize" resultMap="ProductAuthorizeResult">
<include refid="selectProductAuthorizeVo"/>
<where>
<if test="authorizeCode != null and authorizeCode != ''"> and authorize_code = #{authorizeCode}</if>
<if test="productId != null "> and product_id = #{productId}</if>
<if test="deviceId != null "> and device_id = #{deviceId}</if>
<if test="status != null "> and status = #{status}</if>
<if test="serialNumber != null and serialNumber != ''"> and serial_number = #{serialNumber}</if>
<if test="userId != null "> and user_id = #{userId}</if>
<if test="userName != null and userName != ''"> and user_name like concat('%', #{userName}, '%')</if>
</where>
order by create_time desc
</select>
<select id="selectProductAuthorizeByAuthorizeId" parameterType="Long" resultMap="ProductAuthorizeResult">
<include refid="selectProductAuthorizeVo"/>
where authorize_id = #{authorizeId}
</select>
<select id="selectFirstAuthorizeByAuthorizeCode" parameterType="com.fastbee.iot.domain.ProductAuthorize" resultMap="ProductAuthorizeResult">
<include refid="selectProductAuthorizeVo"/>
where
del_flag = 0
and authorize_code = #{authorizeCode}
and product_id = #{productId}
limit 1
</select>
<select id="selectProductAuthorizeListByProductId" parameterType="com.fastbee.iot.domain.ProductAuthorize" resultMap="ProductAuthorizeResult">
<include refid="selectProductAuthorizeVo"/>
where product_id = #{productId}
and del_flag = 0
order by create_time desc
</select>
<insert id="insertProductAuthorize" parameterType="com.fastbee.iot.domain.ProductAuthorize">
insert into iot_product_authorize
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="authorizeCode != null and authorizeCode != ''">authorize_code,</if>
<if test="productId != null">product_id,</if>
<if test="deviceId != null">device_id,</if>
<if test="serialNumber != null">serial_number,</if>
<if test="userId != null">user_id,</if>
<if test="userName != null">user_name,</if>
<if test="status != null">status,</if>
<if test="createBy != null and createBy != ''">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="remark != null">remark,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="authorizeCode != null and authorizeCode != ''">#{authorizeCode},</if>
<if test="productId != null">#{productId},</if>
<if test="deviceId != null">#{deviceId},</if>
<if test="serialNumber != null">#{serialNumber},</if>
<if test="userId != null">#{userId},</if>
<if test="userName != null">#{userName},</if>
<if test="status != null">#{status},</if>
<if test="createBy != null and createBy != ''">#{createBy},</if>
<if test="createTime != null">#{createTime},</if>
<if test="updateBy != null">#{updateBy},</if>
<if test="updateTime != null">#{updateTime},</if>
<if test="remark != null">#{remark},</if>
</trim>
</insert>
<insert id="insertBatchAuthorize" parameterType="com.fastbee.iot.domain.ProductAuthorize" useGeneratedKeys="true" keyProperty="authorizeId">
insert into iot_product_authorize (authorize_code,product_id,create_by,create_time,status)
values
<foreach item="item" collection="list" separator=",">
<trim prefix="(" suffix=")" suffixOverrides=",">
#{item.authorizeCode},#{item.productId},#{item.createBy},#{item.createTime},#{item.status}
</trim>
</foreach>
</insert>
<update id="updateProductAuthorize" parameterType="com.fastbee.iot.domain.ProductAuthorize">
update iot_product_authorize
<trim prefix="SET" suffixOverrides=",">
user_id = #{userId},
device_id = #{deviceId},
<if test="authorizeCode != null and authorizeCode != ''">authorize_code = #{authorizeCode},</if>
<if test="productId != null">product_id = #{productId},</if>
<if test="serialNumber != null">serial_number = #{serialNumber},</if>
<if test="userName != null">user_name = #{userName},</if>
<if test="status != null">status = #{status},</if>
<if test="delFlag != null and delFlag != ''">del_flag = #{delFlag},</if>
<if test="createBy != null and createBy != ''">create_by = #{createBy},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="updateBy != null">update_by = #{updateBy},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
<if test="remark != null">remark = #{remark},</if>
</trim>
where authorize_id = #{authorizeId}
</update>
<delete id="deleteProductAuthorizeByAuthorizeId" parameterType="Long">
delete from iot_product_authorize where authorize_id = #{authorizeId}
</delete>
<delete id="deleteProductAuthorizeByAuthorizeIds" parameterType="String">
delete from iot_product_authorize where authorize_id in
<foreach item="authorizeId" collection="array" open="(" separator="," close=")">
#{authorizeId}
</foreach>
</delete>
<delete id="deleteProductAuthorizeByProductIds" parameterType="String">
delete from iot_product_authorize where product_id in
<foreach item="productId" collection="array" open="(" separator="," close=")">
#{productId}
</foreach>
</delete>
</mapper>

View File

@@ -0,0 +1,230 @@
<?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.fastbee.iot.mapper.ProductMapper">
<resultMap type="com.fastbee.iot.domain.Product" id="ProductResult">
<result property="productId" column="product_id" />
<result property="productName" column="product_name" />
<result property="protocolCode" column="protocol_code"/>
<result property="categoryId" column="category_id" />
<result property="categoryName" column="category_name" />
<result property="tenantId" column="tenant_id" />
<result property="tenantName" column="tenant_name" />
<result property="isSys" column="is_sys" />
<result property="isAuthorize" column="is_authorize" />
<result property="mqttAccount" column="mqtt_account" />
<result property="mqttPassword" column="mqtt_password" />
<result property="mqttSecret" column="mqtt_secret" />
<result property="status" column="status" />
<result property="deviceType" column="device_type" />
<result property="networkMethod" column="network_method" />
<result property="vertificateMethod" column="vertificate_method" />
<result property="imgUrl" column="img_url" />
<result property="createTime" column="create_time" />
<result property="updateTime" column="update_time" />
<result property="remark" column="remark" />
<result property="transport" column="transport"/>
</resultMap>
<resultMap type="com.fastbee.iot.model.IdAndName" id="ProductShortResult">
<result property="id" column="product_id" />
<result property="name" column="product_name" />
</resultMap>
<sql id="selectProductVo">
select product_id, product_name,protocol_code,transport, category_id, category_name, tenant_id, tenant_name, is_sys, is_authorize, mqtt_account,mqtt_password,mqtt_secret ,status, device_type, network_method, vertificate_method, create_time, update_time, img_url,remark from iot_product
</sql>
<select id="selectProductList" parameterType="com.fastbee.iot.domain.Product" resultMap="ProductResult">
<include refid="selectProductVo"/>
<where>
<if test="productName != null and productName != ''"> and product_name like concat('%', #{productName}, '%')</if>
<if test="categoryId != null "> and category_id = #{categoryId}</if>
<if test="categoryName != null and categoryName != ''"> and category_name like concat('%', #{categoryName}, '%')</if>
<if test="tenantName != null and tenantName != ''"> and tenant_name like concat('%', #{tenantName}, '%')</if>
<if test="isAuthorize != null "> and is_authorize = #{isAuthorize}</if>
<if test="status != null "> and status = #{status}</if>
<if test="deviceType != null "> and device_type = #{deviceType}</if>
<if test="networkMethod != null "> and network_method = #{networkMethod}</if>
<if test="tenantId != null and tenantId != 0"> and tenant_id = #{tenantId}</if>
</where>
order by create_time desc
</select>
<select id="selectProductShortList" parameterType="com.fastbee.iot.domain.Product" resultMap="ProductShortResult">
select product_id,product_name from iot_product
<where>
<if test="tenantId != null and tenantId != 0"> and tenant_id = #{tenantId}</if>
</where>
order by create_time desc
</select>
<select id="selectProductByProductId" parameterType="Long" resultMap="ProductResult">
<include refid="selectProductVo"/>
where product_id = #{productId}
</select>
<insert id="insertProduct" parameterType="com.fastbee.iot.domain.Product" useGeneratedKeys="true" keyProperty="productId">
insert into iot_product
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="productName != null and productName != ''">product_name,</if>
<if test="categoryId != null">category_id,</if>
<if test="categoryName != null and categoryName != ''">category_name,</if>
<if test="tenantId != null">tenant_id,</if>
<if test="tenantName != null and tenantName != ''">tenant_name,</if>
<if test="isSys != null">is_sys,</if>
<if test="isAuthorize != null">is_authorize,</if>
<if test="mqttAccount != null and mqttAccount != ''">mqtt_account,</if>
<if test="mqttPassword != null and mqttPassword != ''">mqtt_password,</if>
<if test="mqttSecret != null and mqttSecret != ''">mqtt_secret,</if>
<if test="status != null">status,</if>
<if test="deviceType != null">device_type,</if>
<if test="networkMethod != null">network_method,</if>
<if test="vertificateMethod != null">vertificate_method,</if>
<if test="delFlag != null">del_flag,</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="remark != null">remark,</if>
<if test="imgUrl != null">img_url,</if>
<if test="protocolCode != null">protocol_code,</if>
<if test="transport != null" >transport,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="productName != null and productName != ''">#{productName},</if>
<if test="categoryId != null">#{categoryId},</if>
<if test="categoryName != null and categoryName != ''">#{categoryName},</if>
<if test="tenantId != null">#{tenantId},</if>
<if test="tenantName != null and tenantName != ''">#{tenantName},</if>
<if test="isSys != null">#{isSys},</if>
<if test="isAuthorize != null">#{isAuthorize},</if>
<if test="mqttAccount != null and mqttAccount != ''">#{mqttAccount},</if>
<if test="mqttPassword != null and mqttPassword != ''">#{mqttPassword},</if>
<if test="mqttSecret != null and mqttSecret != ''">#{mqttSecret},</if>
<if test="status != null">#{status},</if>
<if test="deviceType != null">#{deviceType},</if>
<if test="networkMethod != null">#{networkMethod},</if>
<if test="vertificateMethod != null">#{vertificateMethod},</if>
<if test="delFlag != null">#{delFlag},</if>
<if test="createBy != null">#{createBy},</if>
<if test="createTime != null">#{createTime},</if>
<if test="updateBy != null">#{updateBy},</if>
<if test="updateTime != null">#{updateTime},</if>
<if test="remark != null">#{remark},</if>
<if test="imgUrl != null">#{imgUrl},</if>
<if test="protocolCode != null">#{protocolCode,jdbcType=VARCHAR}, </if>
<if test="transport != null" >#{transport,jdbcType=VARCHAR},</if>
</trim>
</insert>
<update id="updateProduct" parameterType="com.fastbee.iot.domain.Product">
update iot_product
<trim prefix="SET" suffixOverrides=",">
<if test="productName != null and productName != ''">product_name = #{productName},</if>
<if test="categoryId != null">category_id = #{categoryId},</if>
<if test="categoryName != null and categoryName != ''">category_name = #{categoryName},</if>
<if test="tenantId != null">tenant_id = #{tenantId},</if>
<if test="tenantName != null and tenantName != ''">tenant_name = #{tenantName},</if>
<if test="isSys != null">is_sys = #{isSys},</if>
<if test="isAuthorize != null">is_authorize = #{isAuthorize},</if>
<if test="mqttAccount != null and mqttAccount != ''">mqtt_account = #{mqttAccount},</if>
<if test="mqttPassword != null and mqttPassword != ''">mqtt_password = #{mqttPassword},</if>
<if test="mqttSecret != null and mqttSecret != ''">mqtt_secret = #{mqttSecret},</if>
<if test="status != null">status = #{status},</if>
<if test="deviceType != null">device_type = #{deviceType},</if>
<if test="networkMethod != null">network_method = #{networkMethod},</if>
<if test="vertificateMethod != null">vertificate_method = #{vertificateMethod},</if>
<if test="delFlag != null">del_flag = #{delFlag},</if>
<if test="createBy != null">create_by = #{createBy},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="updateBy != null">update_by = #{updateBy},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
<if test="remark != null">remark = #{remark},</if>
<if test="imgUrl != null">img_url = #{imgUrl},</if>
<if test="protocolCode != null">protocol_code = #{protocolCode,jdbcType=VARCHAR}, </if>
<if test="transport != null" >transport = #{transport,jdbcType=VARCHAR},</if>
</trim>
where product_id = #{productId}
</update>
<update id="changeProductStatus" parameterType="com.fastbee.iot.model.ChangeProductStatusModel">
update iot_product set status=#{status}
where product_id = #{productId}
</update>
<update id="updateThingsModelJson" parameterType="com.fastbee.iot.domain.Product">
update iot_product set things_models_json=#{thingsModelsJson}
where product_id = #{productId}
</update>
<delete id="deleteProductByProductId" parameterType="Long">
delete from iot_product where product_id = #{productId}
</delete>
<delete id="deleteProductByProductIds" parameterType="String">
delete from iot_product where product_id in
<foreach item="productId" collection="array" open="(" separator="," close=")">
#{productId}
</foreach>
</delete>
<delete id="deleteProductThingsModelByProductIds" parameterType="String">
delete from iot_things_model where product_id in
<foreach item="productId" collection="array" open="(" separator="," close=")">
#{productId}
</foreach>
</delete>
<select id="deviceCountInProducts" parameterType="String" resultType="int">
select count(*) from iot_device where product_id in
<foreach item="productId" collection="array" open="(" separator="," close=")">
#{productId}
</foreach>
</select>
<select id="thingsCountInProduct" parameterType="Long" resultType="int">
select count(model_id) from iot_things_model
where product_id = #{productId}
</select>
<select id="thingsRepeatCountInProduct" parameterType="Long" resultType="int">
SELECT count( identifier )
FROM ( SELECT identifier
FROM iot_things_model
WHERE product_id = #{productId}
GROUP BY identifier,product_id
HAVING count( identifier )> 1 ) AS identifiers
</select>
<select id="getProductBySerialNumber" resultMap="ProductResult" parameterType="String">
<include refid="selectProductVo" />
where product_id =
(select product_id from iot_device
where serial_number = #{serialNumber,jdbcType=VARCHAR}
)
</select>
<select id="getProtocolBySerialNumber" resultType="com.fastbee.iot.model.ProductCode">
select p.protocol_code as protocolCode,
p.product_id as productId
from
iot_product p
inner join iot_device d on p.product_id = d.product_id
and d.serial_number = #{serialNumber,jdbcType=VARCHAR}
</select>
<select id="getProtocolByProductId" resultType="java.lang.String">
select p.protocol_code from
iot_product p
where p.product_id = #{productId,jdbcType=BIGINT}
</select>
<select id="selectByTempleId" resultMap="ProductResult">
select p.product_id,p.product_name,p.protocol_code,p.transport from iot_device_template t inner join
iot_product p on t.product_id = p.product_id
where t.template_id = #{templeId}
</select>
</mapper>

View File

@@ -0,0 +1,143 @@
<?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.fastbee.iot.mapper.ProtocolMapper">
<resultMap id="BaseResultMap" type="com.fastbee.iot.domain.Protocol">
<id column="id" jdbcType="BIGINT" property="id"/>
<result column="protocol_code" jdbcType="VARCHAR" property="protocolCode"/>
<result column="protocol_name" jdbcType="VARCHAR" property="protocolName"/>
<result column="protocol_file_url" jdbcType="VARCHAR" property="protocolFileUrl"/>
<result column="protocol_type" jdbcType="INTEGER" property="protocolType"/>
<result column="jar_sign" jdbcType="VARCHAR" property="jarSign"/>
<result column="create_time" jdbcType="TIMESTAMP" property="createTime"/>
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime"/>
<result column="protocol_status" jdbcType="INTEGER" property="protocolStatus"/>
<result column="del_flag" jdbcType="INTEGER" property="delFlag"/>
</resultMap>
<sql id="Base_Column_List">
id, protocol_code, protocol_name, protocol_file_url, protocol_type,
jar_sign, create_time, update_time, protocol_status, del_flag
</sql>
<sql id="selectProtocolVo">
select id, protocol_code, protocol_name, protocol_file_url, protocol_type,
jar_sign, create_time, update_time, protocol_status, del_flag from iot_protocol
</sql>
<select id="selectByUnion" parameterType="com.fastbee.iot.domain.Protocol" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from iot_protocol
where
1 = 1
<if test="protocolStatus != null">
AND protocol_status = #{protocolStatus}
</if>
<if test="delFlag != null">
AND del_flag = #{delFlag,jdbcType=INTEGER}
</if>
</select>
<select id="selectAll" parameterType="com.fastbee.iot.domain.Protocol" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from iot_protocol
where
1 = 1
<if test="protocolCode != null">
AND protocol_code = #{protocolCode,jdbcType=VARCHAR}
</if>
<if test="protocolName != null">
AND protocol_name = #{protocolName,jdbcType=VARCHAR}
</if>
<if test="protocolFileUrl != null">
AND protocol_file_url = #{protocolFileUrl,jdbcType=VARCHAR}
</if>
<if test="protocolType != null">
AND protocol_type = #{protocolType,jdbcType=INTEGER},
</if>
<if test="jarSign != null">
AND jar_sign = #{jarSign,jdbcType=VARCHAR},
</if>
<if test="createTime != null">
AND create_time = #{createTime,jdbcType=TIMESTAMP}
</if>
<if test="updateTime != null">
AND update_time = #{updateTime,jdbcType=TIMESTAMP}
</if>
<if test="protocolStatus != null">
AND protocol_status = #{protocolStatus,jdbcType=INTEGER}
</if>
</select>
<select id="selectProtocolList" parameterType="Protocol" resultMap="BaseResultMap">
<include refid="selectProtocolVo"/>
<where>
<if test="protocolCode != null and protocolCode != ''"> and protocol_code = #{protocolCode}</if>
<if test="protocolName != null and protocolName != ''"> and protocol_name like concat('%', #{protocolName}, '%')</if>
<if test="protocolFileUrl != null and protocolFileUrl != ''"> and protocol_file_url = #{protocolFileUrl}</if>
<if test="protocolType != null "> and protocol_type = #{protocolType}</if>
<if test="jarSign != null and jarSign != ''"> and jar_sign = #{jarSign}</if>
<if test="protocolStatus != null "> and protocol_status = #{protocolStatus}</if>
</where>
</select>
<select id="selectProtocolById" parameterType="Long" resultMap="BaseResultMap">
<include refid="selectProtocolVo"/>
where id = #{id}
</select>
<insert id="insertProtocol" parameterType="Protocol" useGeneratedKeys="true" keyProperty="id">
insert into iot_protocol
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="protocolCode != null and protocolCode != ''">protocol_code,</if>
<if test="protocolName != null and protocolName != ''">protocol_name,</if>
<if test="protocolFileUrl != null and protocolFileUrl != ''">protocol_file_url,</if>
<if test="protocolType != null">protocol_type,</if>
<if test="jarSign != null and jarSign != ''">jar_sign,</if>
<if test="createTime != null">create_time,</if>
<if test="updateTime != null">update_time,</if>
<if test="protocolStatus != null">protocol_status,</if>
<if test="delFlag != null">del_flag,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="protocolCode != null and protocolCode != ''">#{protocolCode},</if>
<if test="protocolName != null and protocolName != ''">#{protocolName},</if>
<if test="protocolFileUrl != null and protocolFileUrl != ''">#{protocolFileUrl},</if>
<if test="protocolType != null">#{protocolType},</if>
<if test="jarSign != null and jarSign != ''">#{jarSign},</if>
<if test="createTime != null">#{createTime},</if>
<if test="updateTime != null">#{updateTime},</if>
<if test="protocolStatus != null">#{protocolStatus},</if>
<if test="delFlag != null">#{delFlag},</if>
</trim>
</insert>
<update id="updateProtocol" parameterType="Protocol">
update iot_protocol
<trim prefix="SET" suffixOverrides=",">
<if test="protocolCode != null and protocolCode != ''">protocol_code = #{protocolCode},</if>
<if test="protocolName != null and protocolName != ''">protocol_name = #{protocolName},</if>
<if test="protocolFileUrl != null and protocolFileUrl != ''">protocol_file_url = #{protocolFileUrl},</if>
<if test="protocolType != null">protocol_type = #{protocolType},</if>
<if test="jarSign != null and jarSign != ''">jar_sign = #{jarSign},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
<if test="protocolStatus != null">protocol_status = #{protocolStatus},</if>
<if test="delFlag != null">del_flag = #{delFlag},</if>
</trim>
where id = #{id}
</update>
<delete id="deleteProtocolById" parameterType="Long">
delete from iot_protocol where id = #{id}
</delete>
<delete id="deleteProtocolByIds" parameterType="String">
delete from iot_protocol where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
</mapper>

View File

@@ -0,0 +1,141 @@
<?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.fastbee.iot.mapper.SocialPlatformMapper">
<resultMap type="com.fastbee.iot.domain.SocialPlatform" id="SocialPlatformResult">
<result property="socialPlatformId" column="social_platform_id"/>
<result property="platform" column="platform"/>
<result property="status" column="status"/>
<result property="clientId" column="client_id"/>
<result property="secretKey" column="secret_key"/>
<result property="redirectUri" column="redirect_uri"/>
<result property="delFlag" column="del_flag"/>
<result property="createBy" column="create_by"/>
<result property="createTime" column="create_time"/>
<result property="updateTime" column="update_time"/>
<result property="updateBy" column="update_by"/>
<result property="remark" column="remark"/>
<result property="bindUri" column="bind_uri"/>
<result property="redirectLoginUri" column="redirect_login_uri"/>
<result property="errorMsgUri" column="error_msg_uri"/>
</resultMap>
<sql id="selectSocialPlatformVo">
select social_platform_id,
platform,
status,
client_id,
secret_key,
redirect_uri,
del_flag,
create_by,
create_time,
update_time,
update_by,
remark,
bind_uri,
redirect_login_uri,
error_msg_uri
from iot_social_platform
</sql>
<select id="selectSocialPlatformList" parameterType="com.fastbee.iot.domain.SocialPlatform" resultMap="SocialPlatformResult">
<include refid="selectSocialPlatformVo"/>
<where>
<if test="platform != null and platform != ''">and platform = #{platform}</if>
<if test="status != null and status != ''">and status = #{status}</if>
<if test="clientId != null and clientId != ''">and client_id = #{clientId}</if>
<if test="secretKey != null and secretKey != ''">and secret_key = #{secretKey}</if>
<if test="redirectUri != null and redirectUri != ''">and redirect_uri = #{redirectUri}</if>
<if test="bindUri != null and bindUri != ''">and bind_uri = #{bindUri}</if>
<if test="redirectLoginUri != null and redirectLoginUri != ''">and redirect_login_uri =
#{redirectLoginUri}
</if>
<if test="errorMsgUri != null ">and error_msg_uri = #{errorMsgUri}</if>
</where>
</select>
<select id="selectSocialPlatformBySocialPlatformId" parameterType="Long" resultMap="SocialPlatformResult">
<include refid="selectSocialPlatformVo"/>
where social_platform_id = #{socialPlatformId}
</select>
<select id="selectSocialPlatformByPlatform" parameterType="String" resultMap="SocialPlatformResult">
<include refid="selectSocialPlatformVo"/>
where platform = #{platform}
</select>
<insert id="insertSocialPlatform" parameterType="com.fastbee.iot.domain.SocialPlatform" useGeneratedKeys="true"
keyProperty="socialPlatformId">
insert into iot_social_platform
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="platform != null and platform != ''">platform,</if>
<if test="status != null and status != ''">status,</if>
<if test="clientId != null and clientId != ''">client_id,</if>
<if test="secretKey != null and secretKey != ''">secret_key,</if>
<if test="redirectUri != null and redirectUri != ''">redirect_uri,</if>
<if test="delFlag != null and delFlag != ''">del_flag,</if>
<if test="createBy != null and createBy != ''">create_by,</if>
<if test="createTime != null">create_time,</if>
<if test="updateTime != null">update_time,</if>
<if test="updateBy != null">update_by,</if>
<if test="remark != null">remark,</if>
<if test="bindUri != null and bindUri != ''">bind_uri,</if>
<if test="redirectLoginUri != null and redirectLoginUri != ''">redirect_login_uri,</if>
<if test="errorMsgUri != null and errorMsgUri != ''">error_msg_uri,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="platform != null and platform != ''">#{platform},</if>
<if test="status != null and status != ''">#{status},</if>
<if test="clientId != null and clientId != ''">#{clientId},</if>
<if test="secretKey != null and secretKey != ''">#{secretKey},</if>
<if test="redirectUri != null and redirectUri != ''">#{redirectUri},</if>
<if test="delFlag != null and delFlag != ''">#{delFlag},</if>
<if test="createBy != null and createBy != ''">#{createBy},</if>
<if test="createTime != null">#{createTime},</if>
<if test="updateTime != null">#{updateTime},</if>
<if test="updateBy != null">#{updateBy},</if>
<if test="remark != null">#{remark},</if>
<if test="bindUri != null and bindUri != ''">#{bindUri},</if>
<if test="redirectLoginUri != null and redirectLoginUri != ''">#{redirectLoginUri},</if>
<if test="errorMsgUri != null and errorMsgUri != ''">#{errorMsgUri},</if>
</trim>
</insert>
<update id="updateSocialPlatform" parameterType="com.fastbee.iot.domain.SocialPlatform">
update iot_social_platform
<trim prefix="SET" suffixOverrides=",">
<if test="platform != null and platform != ''">platform = #{platform},</if>
<if test="status != null and status != ''">status = #{status},</if>
<if test="clientId != null and clientId != ''">client_id = #{clientId},</if>
<if test="secretKey != null and secretKey != ''">secret_key = #{secretKey},</if>
<if test="redirectUri != null and redirectUri != ''">redirect_uri = #{redirectUri},</if>
<if test="delFlag != null and delFlag != ''">del_flag = #{delFlag},</if>
<if test="createBy != null and createBy != ''">create_by = #{createBy},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
<if test="updateBy != null">update_by = #{updateBy},</if>
<if test="remark != null">remark = #{remark},</if>
<if test="bindUri != null and bindUri != ''">bind_uri = #{bindUri},</if>
<if test="redirectLoginUri != null and redirectLoginUri != ''">redirect_login_uri = #{redirectLoginUri},
</if>
<if test="errorMsgUri != null and errorMsgUri != ''">error_msg_uri = #{errorMsgUri},</if>
</trim>
where social_platform_id = #{socialPlatformId}
</update>
<delete id="deleteSocialPlatformBySocialPlatformId" parameterType="Long">
delete
from iot_social_platform
where social_platform_id = #{socialPlatformId}
</delete>
<delete id="deleteSocialPlatformBySocialPlatformIds" parameterType="String">
delete from iot_social_platform where social_platform_id in
<foreach item="socialPlatformId" collection="array" open="(" separator="," close=")">
#{socialPlatformId}
</foreach>
</delete>
</mapper>

View File

@@ -0,0 +1,275 @@
<?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.fastbee.iot.mapper.SocialUserMapper">
<resultMap type="com.fastbee.iot.domain.SocialUser" id="SocialUserResult">
<result property="socialUserId" column="social_user_id"/>
<result property="uuid" column="uuid"/>
<result property="source" column="source"/>
<result property="accessToken" column="access_token"/>
<result property="expireIn" column="expire_in"/>
<result property="refreshToken" column="refresh_token"/>
<result property="openId" column="open_id"/>
<result property="uid" column="uid"/>
<result property="accessCode" column="access_code"/>
<result property="unionId" column="union_id"/>
<result property="scope" column="scope"/>
<result property="tokenType" column="token_type"/>
<result property="idToken" column="id_token"/>
<result property="macAlgorithm" column="mac_algorithm"/>
<result property="macKey" column="mac_key"/>
<result property="code" column="code"/>
<result property="oauthToken" column="oauth_token"/>
<result property="oauthTokenSecret" column="oauth_token_secret"/>
<result property="createTime" column="create_time"/>
<result property="createBy" column="create_by"/>
<result property="updateTime" column="update_time"/>
<result property="updateBy" column="update_by"/>
<result property="delFlag" column="del_flag"/>
<result property="status" column="status"/>
<result property="sysUserId" column="sys_user_id"/>
<result property="username" column="username"/>
<result property="nickname" column="nickname"/>
<result property="avatar" column="avatar"/>
<result property="gender" column="gender"/>
<result property="sourceClient" column="source_client"/>
</resultMap>
<sql id="selectSocialUserVo">
select social_user_id,
uuid,
source,
access_token,
expire_in,
refresh_token,
open_id,
uid,
access_code,
union_id,
scope,
token_type,
id_token,
mac_algorithm,
mac_key,
code,
oauth_token,
oauth_token_secret,
create_time,
create_by,
update_time,
update_by,
del_flag,
status,
sys_user_id,
username,
nickname,
avatar,
gender,
source_client
from iot_social_user
</sql>
<select id="selectSocialUserList" parameterType="com.fastbee.iot.domain.SocialUser" resultMap="SocialUserResult">
<include refid="selectSocialUserVo"/>
<where>
<if test="uuid != null and uuid != ''">and uuid = #{uuid}</if>
<if test="source != null and source != ''">and source = #{source}</if>
<if test="accessToken != null and accessToken != ''">and access_token = #{accessToken}</if>
<if test="expireIn != null ">and expire_in = #{expireIn}</if>
<if test="refreshToken != null and refreshToken != ''">and refresh_token = #{refreshToken}</if>
<if test="openId != null and openId != ''">and open_id = #{openId}</if>
<if test="uid != null and uid != ''">and uid = #{uid}</if>
<if test="accessCode != null and accessCode != ''">and access_code = #{accessCode}</if>
<if test="unionId != null and unionId != ''">and union_id = #{unionId}</if>
<if test="scope != null and scope != ''">and scope = #{scope}</if>
<if test="tokenType != null and tokenType != ''">and token_type = #{tokenType}</if>
<if test="idToken != null and idToken != ''">and id_token = #{idToken}</if>
<if test="macAlgorithm != null and macAlgorithm != ''">and mac_algorithm = #{macAlgorithm}</if>
<if test="macKey != null and macKey != ''">and mac_key = #{macKey}</if>
<if test="code != null and code != ''">and code = #{code}</if>
<if test="oauthToken != null and oauthToken != ''">and oauth_token = #{oauthToken}</if>
<if test="oauthTokenSecret != null and oauthTokenSecret != ''">and oauth_token_secret =
#{oauthTokenSecret}
</if>
<if test="status != null and status != ''">and status = #{status}</if>
<if test="sysUserId != null ">and sys_user_id = #{sysUserId}</if>
<if test="username != null and username != ''">and username like concat('%', #{username}, '%')</if>
<if test="nickname != null and nickname != ''">and nickname like concat('%', #{nickname}, '%')</if>
<if test="avatar != null and avatar != ''">and avatar = #{avatar}</if>
<if test="gender != null ">and gender = #{gender}</if>
and del_flag = 0
</where>
</select>
<select id="selectSocialUserBySocialUserId" parameterType="Long" resultMap="SocialUserResult">
<include refid="selectSocialUserVo"/>
where social_user_id = #{socialUserId}
and del_flag = 0
</select>
<select id="selectOneByOpenIdAndUnionId" resultMap="SocialUserResult">
<include refid="selectSocialUserVo"/>
where open_id = #{openId}
and del_flag = 0
<if test="unionId != null and unionId != ''">and union_id = #{unionId}</if>
</select>
<select id="selectSysUserIdByUnionId" resultType="java.lang.Long">
select sys_user_id
from iot_social_user
where union_id = #{unionId}
and sys_user_id is not null
and del_flag = 0
order by social_user_id desc
limit 1
</select>
<select id="selectBySysUserId" resultType="com.fastbee.iot.domain.SocialUser">
<include refid="selectSocialUserVo"/>
where sys_user_id = #{sysUserId}
and del_flag = 0
</select>
<insert id="insertSocialUser" parameterType="com.fastbee.iot.domain.SocialUser" useGeneratedKeys="true" keyProperty="socialUserId">
insert into iot_social_user
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="uuid != null and uuid != ''">uuid,</if>
<if test="source != null and source != ''">source,</if>
<if test="accessToken != null and accessToken != ''">access_token,</if>
<if test="expireIn != null">expire_in,</if>
<if test="refreshToken != null">refresh_token,</if>
<if test="openId != null">open_id,</if>
<if test="uid != null">uid,</if>
<if test="accessCode != null">access_code,</if>
<if test="unionId != null">union_id,</if>
<if test="scope != null">scope,</if>
<if test="tokenType != null">token_type,</if>
<if test="idToken != null">id_token,</if>
<if test="macAlgorithm != null">mac_algorithm,</if>
<if test="macKey != null">mac_key,</if>
<if test="code != null">code,</if>
<if test="oauthToken != null">oauth_token,</if>
<if test="oauthTokenSecret != null">oauth_token_secret,</if>
<if test="createTime != null">create_time,</if>
<if test="createBy != null and createBy != ''">create_by,</if>
<if test="updateTime != null">update_time,</if>
<if test="updateBy != null">update_by,</if>
<if test="delFlag != null and delFlag != ''">del_flag,</if>
<if test="status != null and status != ''">status,</if>
<if test="sysUserId != null">sys_user_id,</if>
<if test="username != null">username,</if>
<if test="nickname != null">nickname,</if>
<if test="avatar != null">avatar,</if>
<if test="gender != null">gender,</if>
<if test="sourceClient != null and sourceClient != ''">source_client,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="uuid != null and uuid != ''">#{uuid},</if>
<if test="source != null and source != ''">#{source},</if>
<if test="accessToken != null and accessToken != ''">#{accessToken},</if>
<if test="expireIn != null">#{expireIn},</if>
<if test="refreshToken != null">#{refreshToken},</if>
<if test="openId != null">#{openId},</if>
<if test="uid != null">#{uid},</if>
<if test="accessCode != null">#{accessCode},</if>
<if test="unionId != null">#{unionId},</if>
<if test="scope != null">#{scope},</if>
<if test="tokenType != null">#{tokenType},</if>
<if test="idToken != null">#{idToken},</if>
<if test="macAlgorithm != null">#{macAlgorithm},</if>
<if test="macKey != null">#{macKey},</if>
<if test="code != null">#{code},</if>
<if test="oauthToken != null">#{oauthToken},</if>
<if test="oauthTokenSecret != null">#{oauthTokenSecret},</if>
<if test="createTime != null">#{createTime},</if>
<if test="createBy != null and createBy != ''">#{createBy},</if>
<if test="updateTime != null">#{updateTime},</if>
<if test="updateBy != null">#{updateBy},</if>
<if test="delFlag != null and delFlag != ''">#{delFlag},</if>
<if test="status != null and status != ''">#{status},</if>
<if test="sysUserId != null">#{sysUserId},</if>
<if test="username != null">#{username},</if>
<if test="nickname != null">#{nickname},</if>
<if test="avatar != null">#{avatar},</if>
<if test="gender != null">#{gender},</if>
<if test="sourceClient != null and sourceClient != ''">#{sourceClient},</if>
</trim>
</insert>
<update id="updateSocialUser" parameterType="com.fastbee.iot.domain.SocialUser">
update iot_social_user
<trim prefix="SET" suffixOverrides=",">
<if test="uuid != null and uuid != ''">uuid = #{uuid},</if>
<if test="source != null and source != ''">source = #{source},</if>
<if test="accessToken != null and accessToken != ''">access_token = #{accessToken},</if>
<if test="expireIn != null">expire_in = #{expireIn},</if>
<if test="refreshToken != null">refresh_token = #{refreshToken},</if>
<if test="openId != null">open_id = #{openId},</if>
<if test="uid != null">uid = #{uid},</if>
<if test="accessCode != null">access_code = #{accessCode},</if>
<if test="unionId != null">union_id = #{unionId},</if>
<if test="scope != null">scope = #{scope},</if>
<if test="tokenType != null">token_type = #{tokenType},</if>
<if test="idToken != null">id_token = #{idToken},</if>
<if test="macAlgorithm != null">mac_algorithm = #{macAlgorithm},</if>
<if test="macKey != null">mac_key = #{macKey},</if>
<if test="code != null">code = #{code},</if>
<if test="oauthToken != null">oauth_token = #{oauthToken},</if>
<if test="oauthTokenSecret != null">oauth_token_secret = #{oauthTokenSecret},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="createBy != null and createBy != ''">create_by = #{createBy},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
<if test="updateBy != null">update_by = #{updateBy},</if>
<if test="delFlag != null and delFlag != ''">del_flag = #{delFlag},</if>
<if test="status != null and status != ''">status = #{status},</if>
<if test="sysUserId != null">sys_user_id = #{sysUserId},</if>
<if test="username != null">username = #{username},</if>
<if test="nickname != null">nickname = #{nickname},</if>
<if test="avatar != null">avatar = #{avatar},</if>
<if test="gender != null">gender = #{gender},</if>
<if test="sourceClient != null and sourceClient != ''">source_client = #{sourceClient},</if>
</trim>
where social_user_id = #{socialUserId}
</update>
<delete id="deleteSocialUserBySocialUserId" parameterType="Long">
delete
from iot_social_user
where social_user_id = #{socialUserId}
</delete>
<delete id="deleteSocialUserBySocialUserIds" parameterType="String">
delete from iot_social_user where social_user_id in
<foreach item="socialUserId" collection="array" open="(" separator="," close=")">
#{socialUserId}
</foreach>
</delete>
<delete id="deleteBySysUserIdAndSourceClient">
update iot_social_user
set del_flag = 1,
update_time = now()
where sys_user_id = #{sysUserId}
and source_client in
<foreach item="sourceClient" collection="sourceClientList" open="(" separator="," close=")">
#{sourceClient}
</foreach>
</delete>
<delete id="deleteBySysUserIdsAndSourceClient">
update iot_social_user
set del_flag = 1,
update_time = now()
where sys_user_id in
<foreach item="sysUserId" collection="sysUserIds" open="(" separator="," close=")">
#{sysUserId}
</foreach>
and source_client in
<foreach item="sourceClient" collection="sourceClientList" open="(" separator="," close=")">
#{sourceClient}
</foreach>
</delete>
</mapper>

View File

@@ -0,0 +1,519 @@
<?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.fastbee.iot.mapper.ThingsModelMapper">
<resultMap type="com.fastbee.iot.domain.ThingsModel" id="ThingsModelResult">
<result property="modelId" column="model_id"/>
<result property="modelName" column="model_name"/>
<result property="productId" column="product_id"/>
<result property="productName" column="product_name"/>
<result property="tenantId" column="tenant_id"/>
<result property="tenantName" column="tenant_name"/>
<result property="identifier" column="identifier"/>
<result property="type" column="type"/>
<result property="datatype" column="datatype"/>
<result property="tempSlaveId" column="temp_slave_id"/>
<result property="formula" column="formula"/>
<result property="specs" column="specs"/>
<result property="isChart" column="is_chart"/>
<result property="isSharePerm" column="is_share_perm"/>
<result property="isHistory" column="is_history"/>
<result property="reverseFormula" column="reverse_formula"/>
<result property="regAddr" column="reg_addr"/>
<result property="isMonitor" column="is_monitor"/>
<result property="delFlag" column="del_flag"/>
<result property="bitOption" column="bit_option"/>
<result property="valueType" column="value_type"/>
<result property="createBy" column="create_by"/>
<result property="createTime" column="create_time"/>
<result property="updateBy" column="update_by"/>
<result property="updateTime" column="update_time"/>
<result property="remark" column="remark"/>
<result property="isReadonly" column="is_readonly"/>
<result property="modelOrder" column="model_order"/>
<result property="quantity" column="quantity"/>
<result property="code" column="code"/>
<result property="parseType" column="parse_type"/>
</resultMap>
<resultMap type="com.fastbee.iot.model.ThingsModelPerm" id="ThingsModelPermResult">
<result property="modelName" column="model_name"/>
<result property="identifier" column="identifier"/>
<result property="remark" column="remark"/>
</resultMap>
<sql id="selectThingsModelVo">
select model_id,
model_name,
product_id,
product_name,
tenant_id,
tenant_name,
identifier,
type,
datatype,
temp_slave_id,
formula,
specs,
is_chart,
is_share_perm,
is_history,
reverse_formula,
reg_addr,
is_monitor,
del_flag,
bit_option,
value_type,
create_by,
create_time,
update_by,
update_time,
remark,
is_readonly,
model_order,
quantity,
code,
parse_type
from iot_things_model
</sql>
<select id="selectThingsModelList" parameterType="com.fastbee.iot.domain.ThingsModel" resultMap="ThingsModelResult">
<include refid="selectThingsModelVo"/>
<where>
<if test="productId != null">
and product_id = #{productId}
</if>
<if test="type!=null and type==4 ">
and type in(1,2)
</if>
<if test="isChart != null ">
and is_chart = #{isChart}
</if>
<if test="isHistory != null ">
and is_history = #{isHistory}
</if>
<if test="isMonitor != null ">
and is_monitor = #{isMonitor}
</if>
<if test="isReadonly != null ">
and is_readonly = #{isReadonly}
</if>
<if test="tempSlaveId != null ">
and temp_slave_id = #{tempSlaveId}
</if>
</where>
order by model_order desc,create_time desc
</select>
<select id="selectThingsModelPermList" parameterType="Long" resultMap="ThingsModelPermResult">
select model_name,identifier,is_share_perm,remark from iot_things_model
where product_id=#{productId} and is_share_perm=1
order by model_order desc,create_time desc
</select>
<select id="selectThingsModelListCache" parameterType="com.fastbee.common.core.iot.response.IdentityAndName" resultMap="ThingsModelResult">
select reg_addr as id,
temp_slave_id as tempSlaveId
from iot_things_model
<where>
<if test="productId != null">
and product_id = #{productId}
</if>
</where>
order by reg_addr asc
</select>
<select id="selectThingsModelListByProductIds" parameterType="String" resultMap="ThingsModelResult">
<include refid="selectThingsModelVo"/>
where is_chart=1 and product_id in
<foreach item="productId" collection="array" open="(" separator="," close=")">
#{productId}
</foreach>
</select>
<select id="selectThingsModelByModelId" parameterType="Long" resultMap="ThingsModelResult">
<include refid="selectThingsModelVo"/>
where model_id = #{modelId}
</select>
<select id="selectSingleThingsModel" parameterType="com.fastbee.iot.domain.ThingsModel" resultMap="ThingsModelResult">
<include refid="selectThingsModelVo"/>
<where>
<if test="productId != null">
and product_id = #{productId}
</if>
<if test="identifier !=null and identifier != ''">
and identifier = #{identifier}
</if>
<if test="tempSlaveId != null and tempSlaveId != ''">
and temp_slave_id = #{tempSlaveId}
</if>
</where>
</select>
<insert id="insertThingsModel" parameterType="com.fastbee.iot.domain.ThingsModel" useGeneratedKeys="true"
keyProperty="modelId">
insert into iot_things_model
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="modelName != null and modelName != ''">
model_name,
</if>
<if test="productId != null">
product_id,
</if>
<if test="productName != null and productName != ''">
product_name,
</if>
<if test="tenantId != null">
tenant_id,
</if>
<if test="tenantName != null and tenantName != ''">
tenant_name,
</if>
<if test="identifier != null and identifier != ''">
identifier,
</if>
<if test="type != null">
type,
</if>
<if test="datatype != null and datatype != ''">
datatype,
</if>
<if test="tempSlaveId != null">
temp_slave_id,
</if>
<if test="formula != null">
formula,
</if>
<if test="specs != null and specs != ''">
specs,
</if>
<if test="isChart != null">
is_chart,
</if>
<if test="isSharePerm != null">
is_share_perm,
</if>
<if test="isHistory != null">
is_history,
</if>
<if test="reverseFormula != null">
reverse_formula,
</if>
<if test="regAddr != null">
reg_addr,
</if>
<if test="isMonitor != null">
is_monitor,
</if>
<if test="delFlag != null">
del_flag,
</if>
<if test="bitOption != null">
bit_option,
</if>
<if test="valueType != null">
value_type,
</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="remark != null">
remark,
</if>
<if test="isReadonly != null">
is_readonly,
</if>
<if test="modelOrder != null">
model_order,
</if>
<if test="quantity != null">
quantity,
</if>
<if test="code != null">
code,
</if>
<if test="parseType != null">
parse_type,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="modelName != null and modelName != ''">
#{modelName},
</if>
<if test="productId != null">
#{productId},
</if>
<if test="productName != null and productName != ''">
#{productName},
</if>
<if test="tenantId != null">
#{tenantId},
</if>
<if test="tenantName != null and tenantName != ''">
#{tenantName},
</if>
<if test="identifier != null and identifier != ''">
#{identifier},
</if>
<if test="type != null">
#{type},
</if>
<if test="datatype != null and datatype != ''">
#{datatype},
</if>
<if test="tempSlaveId != null">
#{tempSlaveId},
</if>
<if test="formula != null">
#{formula},
</if>
<if test="specs != null and specs != ''">
#{specs},
</if>
<if test="isChart != null">
#{isChart},
</if>
<if test="isSharePerm != null">
#{isSharePerm},
</if>
<if test="isHistory != null">
#{isHistory},
</if>
<if test="reverseFormula != null">
#{reverseFormula},
</if>
<if test="regAddr != null">
#{regAddr},
</if>
<if test="isMonitor != null">
#{isMonitor},
</if>
<if test="delFlag != null">
#{delFlag},
</if>
<if test="bitOption != null">
#{bitOption},
</if>
<if test="valueType != null">
#{valueType},
</if>
<if test="createBy != null">
#{createBy},
</if>
<if test="createTime != null">
#{createTime},
</if>
<if test="updateBy != null">
#{updateBy},
</if>
<if test="updateTime != null">
#{updateTime},
</if>
<if test="remark != null">
#{remark},
</if>
<if test="isReadonly != null">
#{isReadonly},
</if>
<if test="modelOrder != null">
#{modelOrder},
</if>
<if test="quantity != null">
#{quantity},
</if>
<if test="code != null">
#{code},
</if>
<if test="parseType != null">
#{parseType},
</if>
</trim>
</insert>
<insert id="insertBatchThingsModel" parameterType="com.fastbee.iot.domain.ThingsModel" useGeneratedKeys="true"
keyProperty="modelId">
insert into iot_things_model (
model_name,product_id,product_name,tenant_id,tenant_name,identifier,type,
datatype,specs,is_chart,is_share_perm,is_history,is_monitor,is_readonly,create_by,create_time,temp_slave_id,formula,
reverse_formula,reg_addr,bit_option,value_type,quantity,code,parse_type
)
values
<foreach item="model" collection="list" separator=",">
<trim prefix="(" suffix=")" suffixOverrides=",">
#{model.modelName},#{model.productId},#{model.productName},#{model.tenantId},#{model.tenantName}
,#{model.identifier},#{model.type},#{model.datatype},#{model.specs}
,#{model.isChart},#{model.isSharePerm},#{model.isHistory},#{model.isMonitor},#{model.isReadonly},#{model.createBy},#{model.createTime},
#{model.tempSlaveId},#{model.formula},#{model.reverseFormula},#{model.regAddr},
#{model.bitOption},#{model.valueType},#{model.quantity},#{model.code},#{model.parseType}
</trim>
</foreach>
</insert>
<update id="updateThingsModel" parameterType="com.fastbee.iot.domain.ThingsModel">
update iot_things_model
<trim prefix="SET" suffixOverrides=",">
<if test="modelName != null and modelName != ''">
model_name = #{modelName},
</if>
<if test="productId != null">
product_id = #{productId},
</if>
<if test="productName != null and productName != ''">
product_name = #{productName},
</if>
<if test="tenantId != null">
tenant_id = #{tenantId},
</if>
<if test="tenantName != null and tenantName != ''">
tenant_name = #{tenantName},
</if>
<if test="identifier != null and identifier != ''">
identifier = #{identifier},
</if>
<if test="type != null">
type = #{type},
</if>
<if test="datatype != null and datatype != ''">
datatype = #{datatype},
</if>
<if test="tempSlaveId != null">
temp_slave_id = #{tempSlaveId},
</if>
<if test="formula != null">
formula = #{formula},
</if>
<if test="specs != null and specs != ''">
specs = #{specs},
</if>
<if test="isChart != null">
is_chart = #{isChart},
</if>
<if test="isSharePerm != null">
is_share_perm = #{isSharePerm},
</if>
<if test="isHistory != null">
is_history = #{isHistory},
</if>
<if test="reverseFormula != null">
reverse_formula = #{reverseFormula},
</if>
<if test="regAddr != null">
reg_addr = #{regAddr},
</if>
<if test="isMonitor != null">
is_monitor = #{isMonitor},
</if>
<if test="delFlag != null">
del_flag = #{delFlag},
</if>
<if test="bitOption != null">
bit_option = #{bitOption},
</if>
<if test="valueType != null">
value_type = #{valueType},
</if>
<if test="createBy != null">
create_by = #{createBy},
</if>
<if test="createTime != null">
create_time = #{createTime},
</if>
<if test="updateBy != null">
update_by = #{updateBy},
</if>
<if test="updateTime != null">
update_time = #{updateTime},
</if>
<if test="remark != null">
remark = #{remark},
</if>
<if test="isReadonly != null">
is_readonly = #{isReadonly},
</if>
<if test="modelOrder != null">
model_order = #{modelOrder},
</if>
<if test="quantity != null">
quantity =#{quantity},
</if>
<if test="code != null">
code = #{code},
</if>
<if test="parseType != null">
parse_type= #{parseType},
</if>
</trim>
where model_id = #{modelId}
</update>
<delete id="deleteThingsModelByModelId" parameterType="Long">
delete
from iot_things_model
where model_id = #{modelId}
</delete>
<delete id="deleteThingsModelByModelIds" parameterType="String">
delete from iot_things_model where model_id in
<foreach item="modelId" collection="array" open="(" separator="," close=")">
#{modelId}
</foreach>
</delete>
<select id="selectThingsModelIsMonitor" parameterType="com.fastbee.iot.model.ThingsModels.ThingsItems"
resultType="com.fastbee.common.core.iot.response.IdentityAndName">
select t.reg_addr as id,
t.is_monitor as isMonitor,
t.is_chart as isChart,
t.is_share_perm as isSharePerm,
t.is_history as isHistory,
t.specs as dataType,
t.model_name as name,
t.type as type,
t.is_params as isParams,
t.formula as formula,
t.quantity as quantity,
t.code as code
from iot_things_model t
where t.product_id = #{productId,jdbcType=BIGINT}
and t.identifier in
<foreach collection="ids" item="item" open="(" separator="," close=")">
#{item}
</foreach>
<if test="slaveId != null">
and t.temp_slave_id = (
SELECT
s.id
FROM
iot_device_template temp
INNER JOIN iot_var_temp v ON temp.template_id = v.template_id
INNER JOIN iot_var_temp_salve s ON v.template_id = s.device_temp_id
WHERE
temp.product_id = t.product_id
AND s.slave_addr = #{slaveId} )
</if>
</select>
<select id="selectAllByTemplateId" resultMap="ThingsModelResult">
select m.*
from iot_var_temp t
left join iot_var_temp_salve s
on t.template_id = s.device_temp_id
left join iot_things_model m on s.id = m.temp_slave_id
where t.template_id = #{templateId,jdbcType=BIGINT}
</select>
<delete id="deleteThingsModelByProductId" parameterType="long">
delete from iot_things_model where product_id = #{productId}
</delete>
</mapper>

View File

@@ -0,0 +1,207 @@
<?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.fastbee.iot.mapper.ThingsModelTemplateMapper">
<resultMap type="com.fastbee.iot.domain.ThingsModelTemplate" id="ThingsModelTemplateResult">
<result property="templateId" column="template_id" />
<result property="templateName" column="template_name" />
<result property="tenantId" column="tenant_id" />
<result property="tenantName" column="tenant_name" />
<result property="identifier" column="identifier" />
<result property="type" column="type" />
<result property="datatype" column="datatype" />
<result property="specs" column="specs" />
<result property="isSys" column="is_sys" />
<result property="isReadonly" column="is_readonly" />
<result property="isChart" column="is_chart" />
<result property="isSharePerm" column="is_share_perm" />
<result property="isHistory" column="is_history" />
<result property="tempSlaveId" column="temp_slave_id" />
<result property="isMonitor" column="is_monitor" />
<result property="formula" column="formula" />
<result property="delFlag" column="del_flag" />
<result property="reverseFormula" column="reverse_formula" />
<result property="createBy" column="create_by" />
<result property="regAddr" column="reg_addr" />
<result property="createTime" column="create_time" />
<result property="bitOption" column="bit_option" />
<result property="updateBy" column="update_by" />
<result property="valueType" column="value_type" />
<result property="updateTime" column="update_time" />
<result property="remark" column="remark" />
<result property="isParams" column="is_params"/>
<result property="modelOrder" column="model_order" />
<result property="quantity" column="quantity" />
<result property="code" column="code"/>
<result property="parseType" column="parse_type" />
</resultMap>
<sql id="selectThingsModelTemplateVo">
select template_id, template_name, tenant_id, tenant_name, identifier, type, datatype, specs, is_sys, is_readonly, is_chart,is_share_perm, is_history, temp_slave_id, is_monitor, formula, del_flag, reverse_formula, create_by, reg_addr, create_time, bit_option, update_by, value_type, update_time, remark, model_order,is_params,quantity,code,parse_type from iot_things_model_template
</sql>
<select id="selectThingsModelTemplateList" parameterType="com.fastbee.iot.domain.ThingsModelTemplate" resultMap="ThingsModelTemplateResult">
<include refid="selectThingsModelTemplateVo"/>
<where>
<if test="tempSlaveId != null "> and temp_slave_id = #{tempSlaveId}</if>
<if test="tempSlaveId == null "> and temp_slave_id is null</if>
<if test="templateName != null and templateName != ''"> and template_name like concat('%', #{templateName}, '%')</if>
<if test="type != null "> and type = #{type}</if>
<if test="specs != null and specs != ''"> and specs = #{specs}</if>
<if test="tenantId != null and tenantId != ''"> and (tenant_id = #{tenantId} or is_sys = 1)</if>
</where>
order by template_id desc,create_time desc
</select>
<select id="selectThingsModelTemplateByTemplateId" parameterType="Long" resultMap="ThingsModelTemplateResult">
<include refid="selectThingsModelTemplateVo"/>
where template_id = #{templateId}
</select>
<select id="selectThingsModelTemplateByTemplateIds" parameterType="String" resultMap="ThingsModelTemplateResult">
<include refid="selectThingsModelTemplateVo"/> where template_id in
<foreach item="templateId" collection="array" open="(" separator="," close=")">
#{templateId}
</foreach>
</select>
<insert id="insertThingsModelTemplate" parameterType="com.fastbee.iot.domain.ThingsModelTemplate" useGeneratedKeys="true" keyProperty="templateId">
insert into iot_things_model_template
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="templateName != null and templateName != ''">template_name,</if>
<if test="tenantId != null">tenant_id,</if>
<if test="tenantName != null and tenantName != ''">tenant_name,</if>
<if test="identifier != null and identifier != ''">identifier,</if>
<if test="type != null">type,</if>
<if test="datatype != null and datatype != ''">datatype,</if>
<if test="specs != null and specs != ''">specs,</if>
<if test="isSys != null">is_sys,</if>
<if test="isReadonly != null">is_readonly,</if>
<if test="isChart != null">is_chart,</if>
<if test="isSharePerm != null">is_share_perm,</if>
<if test="isHistory != null">is_history,</if>
<if test="tempSlaveId != null">temp_slave_id,</if>
<if test="isMonitor != null">is_monitor,</if>
<if test="formula != null">formula,</if>
<if test="delFlag != null">del_flag,</if>
<if test="reverseFormula != null">reverse_formula,</if>
<if test="createBy != null">create_by,</if>
<if test="regAddr != null">reg_addr,</if>
<if test="createTime != null">create_time,</if>
<if test="bitOption != null">bit_option,</if>
<if test="updateBy != null">update_by,</if>
<if test="valueType != null">value_type,</if>
<if test="updateTime != null">update_time,</if>
<if test="remark != null">remark,</if>
<if test="modelOrder != null">model_order,</if>
<if test="isParams != null">is_params,</if>
<if test="quantity != null">quantity,</if>
<if test="code != null">code,</if>
<if test="parseType != null">parse_type,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="templateName != null and templateName != ''">#{templateName},</if>
<if test="tenantId != null">#{tenantId},</if>
<if test="tenantName != null and tenantName != ''">#{tenantName},</if>
<if test="identifier != null and identifier != ''">#{identifier},</if>
<if test="type != null">#{type},</if>
<if test="datatype != null and datatype != ''">#{datatype},</if>
<if test="specs != null and specs != ''">#{specs},</if>
<if test="isSys != null">#{isSys},</if>
<if test="isReadonly != null">#{isReadonly},</if>
<if test="isChart != null">#{isChart},</if>
<if test="isSharePerm != null">#{isSharePerm},</if>
<if test="isHistory != null">#{isHistory},</if>
<if test="tempSlaveId != null">#{tempSlaveId},</if>
<if test="isMonitor != null">#{isMonitor},</if>
<if test="formula != null">#{formula},</if>
<if test="delFlag != null">#{delFlag},</if>
<if test="reverseFormula != null">#{reverseFormula},</if>
<if test="createBy != null">#{createBy},</if>
<if test="regAddr != null">#{regAddr},</if>
<if test="createTime != null">#{createTime},</if>
<if test="bitOption != null">#{bitOption},</if>
<if test="updateBy != null">#{updateBy},</if>
<if test="valueType != null">#{valueType},</if>
<if test="updateTime != null">#{updateTime},</if>
<if test="remark != null">#{remark},</if>
<if test="modelOrder != null">#{modelOrder},</if>
<if test="isParams != null">#{isParams},</if>
<if test="quantity != null">#{quantity},</if>
<if test="code != null">#{code},</if>
<if test="parseType != null">#{parseType},</if>
</trim>
</insert>
<update id="updateThingsModelTemplate" parameterType="com.fastbee.iot.domain.ThingsModelTemplate">
update iot_things_model_template
<trim prefix="SET" suffixOverrides=",">
<if test="templateName != null and templateName != ''">template_name = #{templateName},</if>
<if test="tenantId != null">tenant_id = #{tenantId},</if>
<if test="tenantName != null and tenantName != ''">tenant_name = #{tenantName},</if>
<if test="identifier != null and identifier != ''">identifier = #{identifier},</if>
<if test="type != null">type = #{type},</if>
<if test="datatype != null and datatype != ''">datatype = #{datatype},</if>
<if test="specs != null and specs != ''">specs = #{specs},</if>
<if test="isSys != null">is_sys = #{isSys},</if>
<if test="isReadonly != null">is_readonly = #{isReadonly},</if>
<if test="isChart != null">is_chart = #{isChart},</if>
<if test="isSharePerm != null">is_share_perm = #{isSharePerm},</if>
<if test="isHistory != null">is_history = #{isHistory},</if>
<if test="tempSlaveId != null">temp_slave_id = #{tempSlaveId},</if>
<if test="isMonitor != null">is_Monitor = #{isMonitor},</if>
<if test="formula != null">formula = #{formula},</if>
<if test="delFlag != null">del_flag = #{delFlag},</if>
<if test="reverseFormula != null">reverse_formula = #{reverseFormula},</if>
<if test="createBy != null">create_by = #{createBy},</if>
<if test="regAddr != null">reg_addr = #{regAddr},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="bitOption != null">bit_option = #{bitOption},</if>
<if test="updateBy != null">update_by = #{updateBy},</if>
<if test="valueType != null">value_type = #{valueType},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
<if test="remark != null">remark = #{remark},</if>
<if test="modelOrder != null">model_order = #{modelOrder},</if>
<if test="isParams != null">is_params = #{isParams},</if>
<if test="quantity != null">quantity=#{quantity},</if>
<if test="code != null">code = #{code},</if>
<if test="parseType != null">parse_type = #{parseType},</if>
</trim>
where template_id = #{templateId}
</update>
<update id="updateTemplateByTempSlaveId" parameterType="com.fastbee.iot.domain.ThingsModelTemplate">
update iot_things_model_template
<trim prefix="SET" suffixOverrides=",">
<if test="updateTime != null">update_time = #{updateTime},</if>
<if test="tempSlaveId != null">temp_slave_id = #{tempSlaveId},</if>
<if test="oldTempSlaveId != null">old_temp_slave_id = #{oldTempSlaveId}</if>
</trim>
where temp_slave_id = #{oldTempSlaveId}
</update>
<delete id="deleteThingsModelTemplateByTemplateId" parameterType="Long">
delete from iot_things_model_template where template_id = #{templateId}
</delete>
<delete id="deleteThingsModelTemplateByVarTemplateId" parameterType="Long">
delete from iot_things_model_template
where temp_slave_id like concat(#{templateId},'#%')
</delete>
<delete id="deleteThingsModelTemplateByTemplateIds" parameterType="String">
delete from iot_things_model_template where template_id in
<foreach item="templateId" collection="array" open="(" separator="," close=")">
#{templateId}
</foreach>
</delete>
<select id="selectAllByTemplateId" resultMap="ThingsModelTemplateResult">
select m.* from iot_var_temp t inner join iot_var_temp_salve s
on t.template_id = s.device_temp_id
inner join iot_things_model_template m on concat(s.device_temp_id,'#',s.slave_addr) = m.temp_slave_id
where t.template_id = #{templateId,jdbcType=BIGINT}
</select>
</mapper>

View File

@@ -0,0 +1,220 @@
<?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.fastbee.iot.mapper.VarTempMapper">
<resultMap type="com.fastbee.iot.domain.VarTemp" id="VarTempResult">
<result property="templateId" column="template_id"/>
<result property="templateName" column="template_name"/>
<result property="type" column="type"/>
<result property="pollingMethod" column="polling_method"/>
<result property="slaveTotal" column="slave_total"/>
<result property="pointTotal" column="point_total"/>
<result property="share" column="share"/>
<result property="createTime" column="create_time"/>
<result property="createBy" column="create_by"/>
<result property="updateTime" column="update_time"/>
<result property="updateBy" column="update_by"/>
<result property="userId" column="user_id"/>
</resultMap>
<sql id="selectVarTempVo">
select template_id,
template_name,
type,
polling_method,
slave_total,
point_total,
share,
create_time,
create_by,
update_time,
update_by,
user_id
from iot_var_temp
</sql>
<select id="selectVarTempList" parameterType="VarTemp" resultMap="VarTempResult">
select template_id, template_name, type, polling_method,
(select count(s.device_temp_id)
FROM iot_var_temp_salve s
WHERE s.device_temp_id = t.template_id) as slave_total,
(select count(p.temp_slave_id)
from iot_var_temp_salve s
inner join
iot_things_model_template p on CONCAT(s.device_temp_id,'#',s.slave_addr) = p.temp_slave_id
where s.device_temp_id = t.template_id ) as point_total,
share, create_time, create_by, update_time, update_by, user_id from iot_var_temp t
<where>
<if test="templateName != null and templateName != ''">
and t.template_name like concat('%', #{templateName}, '%')
</if>
<if test="type != null ">
and t.type = #{type}
</if>
<if test="pollingMethod != null ">
and t.polling_method = #{pollingMethod}
</if>
<if test="slaveTotal != null ">
and t.slave_total = #{slaveTotal}
</if>
<if test="pointTotal != null ">
and t.point_total = #{pointTotal}
</if>
<if test="share != null ">
and t.share = #{share}
</if>
<if test="userId != null ">
and t.user_id = #{userId}
</if>
</where>
</select>
<select id="selectVarTempByTemplateId" parameterType="Long" resultMap="VarTempResult">
<include refid="selectVarTempVo"/>
where template_id = #{templateId}
</select>
<insert id="insertVarTemp" parameterType="com.fastbee.iot.domain.VarTemp" useGeneratedKeys="true" keyProperty="templateId">
insert into iot_var_temp
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="templateName != null and templateName != ''">
template_name,
</if>
<if test="type != null">
type,
</if>
<if test="pollingMethod != null">
polling_method,
</if>
<if test="slaveTotal != null">
slave_total,
</if>
<if test="pointTotal != null">
point_total,
</if>
<if test="share != null">
share,
</if>
<if test="createTime != null">
create_time,
</if>
<if test="createBy != null">
create_by,
</if>
<if test="updateTime != null">
update_time,
</if>
<if test="updateBy != null">
update_by,
</if>
<if test="userId != null">
user_id,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="templateName != null and templateName != ''">
#{templateName},
</if>
<if test="type != null">
#{type},
</if>
<if test="pollingMethod != null">
#{pollingMethod},
</if>
<if test="slaveTotal != null">
#{slaveTotal},
</if>
<if test="pointTotal != null">
#{pointTotal},
</if>
<if test="share != null">
#{share},
</if>
<if test="createTime != null">
#{createTime},
</if>
<if test="createBy != null">
#{createBy},
</if>
<if test="updateTime != null">
#{updateTime},
</if>
<if test="updateBy != null">
#{updateBy},
</if>
<if test="userId != null">
#{userId},
</if>
</trim>
</insert>
<update id="updateVarTemp" parameterType="VarTemp">
update iot_var_temp
<trim prefix="SET" suffixOverrides=",">
<if test="templateName != null and templateName != ''">
template_name = #{templateName},
</if>
<if test="type != null">
type = #{type},
</if>
<if test="pollingMethod != null">
polling_method = #{pollingMethod},
</if>
<if test="slaveTotal != null">
slave_total = #{slaveTotal},
</if>
<if test="pointTotal != null">
point_total = #{pointTotal},
</if>
<if test="share != null">
share = #{share},
</if>
<if test="createTime != null">
create_time = #{createTime},
</if>
<if test="createBy != null">
create_by = #{createBy},
</if>
<if test="updateTime != null">
update_time = #{updateTime},
</if>
<if test="updateBy != null">
update_by = #{updateBy},
</if>
<if test="userId != null">
user_id = #{userId},
</if>
</trim>
where template_id = #{templateId}
</update>
<delete id="deleteVarTempByTemplateId" parameterType="Long">
delete
from iot_var_temp
where template_id = #{templateId}
</delete>
<delete id="deleteVarTempByTemplateIds" parameterType="String">
delete from iot_var_temp where template_id in
<foreach item="templateId" collection="array" open="(" separator="," close=")">
#{templateId}
</foreach>
</delete>
<select id="selectVarTempByProductId" resultMap="VarTempResult" parameterType="java.lang.Long">
select v.template_id, v.template_name, v.type, v.polling_method from
iot_device_template t inner join
iot_var_temp v on t.template_id = v.template_id
where t.product_id = #{productId,jdbcType=BIGINT}
</select>
<select id="selectByProductAndSlaveId" resultType="java.lang.Long">
select s.id
from iot_device_template t inner join
iot_var_temp v on t.template_id = v.template_id inner join
iot_var_temp_salve s on v.template_id = s.device_temp_id
where t.product_id = #{productId}
and s.slave_addr = #{slaveId}
</select>
</mapper>

View File

@@ -0,0 +1,139 @@
<?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.fastbee.iot.mapper.VarTempSalveMapper">
<resultMap type="com.fastbee.iot.domain.VarTempSalve" id="VarTempSalveResult">
<result property="id" column="id" />
<result property="deviceTempId" column="device_temp_id" />
<result property="slaveAddr" column="slave_addr" />
<result property="slaveIp" column="slave_ip" />
<result property="slaveName" column="slave_name" />
<result property="addrStart" column="addr_start" />
<result property="addrEnd" column="addr_end" />
<result property="packetLength" column="packet_length"/>
<result property="timer" column="timer" />
<result property="status" column="status" />
<result property="createTime" column="create_time" />
<result property="createBy" column="create_by" />
<result property="updateTime" column="update_time" />
<result property="updateBy" column="update_by" />
<result property="remark" column="remark" />
</resultMap>
<sql id="selectVarTempSalveVo">
select id, device_temp_id, slave_addr, slave_ip, slave_name, addr_start, addr_end,packet_length, timer, status, create_time, create_by, update_time, update_by, remark from iot_var_temp_salve
</sql>
<select id="selectVarTempSalveList" parameterType="com.fastbee.iot.domain.VarTempSalve" resultMap="VarTempSalveResult">
<include refid="selectVarTempSalveVo"/>
<where>
<if test="deviceTempId != null "> and device_temp_id = #{deviceTempId}</if>
<if test="slaveAddr != null "> and slave_addr = #{slaveAddr}</if>
<if test="slaveIp != null and slaveIp != ''"> and slave_ip = #{slaveIp}</if>
<if test="slaveName != null and slaveName != ''"> and slave_name like concat('%', #{slaveName}, '%')</if>
<if test="addrStart != null "> and addr_start = #{addrStart}</if>
<if test="addrEnd != null "> and addr_end = #{addrEnd}</if>
<if test="packetLength != null">and packet_length = #{packetLength}</if>
<if test="timer != null "> and timer = #{timer}</if>
<if test="status != null "> and status = #{status}</if>
</where>
</select>
<select id="selectVarTempSalveById" parameterType="Long" resultMap="VarTempSalveResult">
<include refid="selectVarTempSalveVo"/>
where id = #{id}
</select>
<insert id="insertVarTempSalve" parameterType="com.fastbee.iot.domain.VarTempSalve" useGeneratedKeys="true" keyProperty="id">
insert into iot_var_temp_salve
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="deviceTempId != null">device_temp_id,</if>
<if test="slaveAddr != null">slave_addr,</if>
<if test="slaveIp != null">slave_ip,</if>
<if test="slaveName != null">slave_name,</if>
<if test="addrStart != null">addr_start,</if>
<if test="addrEnd != null">addr_end,</if>
<if test="packetLength != null">packet_length,</if>
<if test="timer != null">timer,</if>
<if test="status != null">status,</if>
<if test="createTime != null">create_time,</if>
<if test="createBy != null">create_by,</if>
<if test="updateTime != null">update_time,</if>
<if test="updateBy != null">update_by,</if>
<if test="remark != null">remark,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="deviceTempId != null">#{deviceTempId},</if>
<if test="slaveAddr != null">#{slaveAddr},</if>
<if test="slaveIp != null">#{slaveIp},</if>
<if test="slaveName != null">#{slaveName},</if>
<if test="addrStart != null">#{addrStart},</if>
<if test="addrEnd != null">#{addrEnd},</if>
<if test="packetLength != null">#{packetLength},</if>
<if test="timer != null">#{timer},</if>
<if test="status != null">#{status},</if>
<if test="createTime != null">#{createTime},</if>
<if test="createBy != null">#{createBy},</if>
<if test="updateTime != null">#{updateTime},</if>
<if test="updateBy != null">#{updateBy},</if>
<if test="remark != null">#{remark},</if>
</trim>
</insert>
<update id="updateVarTempSalve" parameterType="com.fastbee.iot.domain.VarTempSalve">
update iot_var_temp_salve
<trim prefix="SET" suffixOverrides=",">
<if test="deviceTempId != null">device_temp_id = #{deviceTempId},</if>
<if test="slaveAddr != null">slave_addr = #{slaveAddr},</if>
<if test="slaveIp != null">slave_ip = #{slaveIp},</if>
<if test="slaveName != null">slave_name = #{slaveName},</if>
<if test="addrStart != null">addr_start = #{addrStart},</if>
<if test="addrEnd != null">addr_end = #{addrEnd},</if>
<if test="packetLength != null">packet_length = #{packetLength},</if>
<if test="timer != null">timer = #{timer},</if>
<if test="status != null">status = #{status},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="createBy != null">create_by = #{createBy},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
<if test="updateBy != null">update_by = #{updateBy},</if>
<if test="remark != null">remark = #{remark},</if>
</trim>
where id = #{id}
</update>
<delete id="deleteVarTempSalveById" parameterType="Long">
delete from iot_var_temp_salve where id = #{id}
</delete>
<delete id="deleteVarTempSalveByIds" parameterType="String">
delete from iot_var_temp_salve where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
<delete id="deleteVarTempSalveByTempIds" parameterType="String">
delete from iot_var_temp_salve where device_temp_id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
<select id="selectVarTempSalveListByProductId" resultMap="VarTempSalveResult" parameterType="Long">
select s.* from iot_device_template t
inner join iot_var_temp_salve s on t.template_id = s.device_temp_id
where t.product_id = #{productId,jdbcType=BIGINT}
</select>
<select id="selectByIds" resultType="com.fastbee.iot.model.varTemp.SlaveIdAndId" parameterType="java.util.List">
select s.id as id,
s.slave_addr as slaveId
from iot_var_temp_salve s
where s.id in
<foreach collection="list" open="(" close=")" separator="," item="item">
#{item}
</foreach>
</select>
</mapper>