第一次提交
This commit is contained in:
@ -0,0 +1,271 @@
|
||||
<?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.AlertLogMapper">
|
||||
|
||||
<resultMap type="com.fastbee.iot.domain.AlertLog" id="AlertLogResult">
|
||||
<result property="alertLogId" column="alert_log_id" />
|
||||
<result property="alertName" column="alert_name" />
|
||||
<result property="alertLevel" column="alert_level" />
|
||||
<result property="status" column="status" />
|
||||
<result property="deviceId" column="device_id" />
|
||||
<result property="deviceName" column="device_name" />
|
||||
<result property="productId" column="product_id" />
|
||||
<result property="detail" column="detail" />
|
||||
<result property="serialNumber" column="serial_number" />
|
||||
<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="userId" column="user_id"/>
|
||||
<result property="sceneId" column="scene_id"/>
|
||||
<result property="sceneName" column="scene_name"/>
|
||||
</resultMap>
|
||||
|
||||
<resultMap type="com.fastbee.iot.model.DeviceAlertCount" id="DeviceAlertCount">
|
||||
<result property="serialNumber" column="serial_number" />
|
||||
<result property="sceneId" column="scene_id" />
|
||||
<result property="alertCount" column="alert_count" />
|
||||
<result property="noprocessedCount" column="noprocessed_count" />
|
||||
<result property="unprocessedCount" column="unprocessed_count" />
|
||||
<result property="processedCount" column="processed_count" />
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectAlertLogVo">
|
||||
select alert_log_id, alert_name, alert_level, status, product_id, detail, serial_number, create_by, create_time, remark, device_name, user_id from iot_alert_log
|
||||
</sql>
|
||||
|
||||
<select id="selectAlertLogList" parameterType="com.fastbee.iot.domain.AlertLog" resultMap="AlertLogResult">
|
||||
select distinct al.alert_log_id, al.alert_name, al.alert_level, al.status, al.product_id, al.detail, al.serial_number, al.create_time, al.remark, al.device_name, al.user_id
|
||||
from iot_alert_log al
|
||||
<where>
|
||||
<if test="alertName != null and alertName != ''"> and al.alert_name like concat('%', #{alertName}, '%')</if>
|
||||
<if test="alertLevel != null "> and al.alert_level = #{alertLevel}</if>
|
||||
<if test="status != null "> and al.status = #{status}</if>
|
||||
<if test="productId != null "> and al.product_id = #{productId}</if>
|
||||
<if test="serialNumber != null "> and al.serial_number = #{serialNumber}</if>
|
||||
<if test="userId != null "> and al.user_id = #{userId}</if>
|
||||
<if test="createBy != null "> and al.create_by = #{createBy}</if>
|
||||
<if test="remark != null "> and al.remark = #{remark}</if>
|
||||
</where>
|
||||
order by al.create_time desc
|
||||
</select>
|
||||
|
||||
<select id="selectAlertLogListAndScene" parameterType="com.fastbee.iot.domain.AlertLog" resultMap="AlertLogResult">
|
||||
select al.alert_log_id, al.alert_name, al.alert_level, al.status, al.product_id, al.detail,
|
||||
al.serial_number, al.create_time, al.remark, al.device_name, al.user_id,
|
||||
s.scene_id,s.scene_name
|
||||
from iot_alert_log al
|
||||
left join iot_scene s on CAST(COALESCE(NULLIF(TRIM(al.create_by), ''), 0) AS signed) = s.scene_id
|
||||
<where>
|
||||
<if test="alertName != null and alertName != ''"> and al.alert_name like concat('%', #{alertName}, '%')</if>
|
||||
<if test="alertLevel != null "> and al.alert_level = #{alertLevel}</if>
|
||||
<if test="status != null "> and al.status = #{status}</if>
|
||||
<if test="productId != null "> and al.product_id = #{productId}</if>
|
||||
<if test="serialNumber != null "> and al.serial_number = #{serialNumber}</if>
|
||||
<if test="userId != null "> and al.user_id = #{userId}</if>
|
||||
<if test="beginTime != null "><!-- 开始时间检索 -->
|
||||
and al.create_time >= #{beginTime}
|
||||
</if>
|
||||
<if test="endTime != null "><!-- 结束时间检索 -->
|
||||
and al.create_time <= #{endTime}
|
||||
</if>
|
||||
</where>
|
||||
order by al.create_time desc
|
||||
</select>
|
||||
|
||||
<select id="selectAlertLogListCount" parameterType="com.fastbee.iot.domain.AlertLog" resultType="Long">
|
||||
select distinct count(l.alert_log_id)
|
||||
from iot_alert_log l
|
||||
left join iot_device d on l.serial_number=d.serial_number
|
||||
left join iot_device_user u on d.device_id=u.device_id
|
||||
<where>
|
||||
<if test="alertName != null and alertName != ''"> and l.alert_name like concat('%', #{alertName}, '%')</if>
|
||||
<if test="alertLevel != null "> and l.alert_level = #{alertLevel}</if>
|
||||
<if test="status != null "> and l.status = #{status}</if>
|
||||
<if test="userId != null "> and u.user_id = #{userId}</if>
|
||||
<if test="productId != null "> and l.product_id = #{productId}</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<select id="selectDeviceAlertCount" resultMap="DeviceAlertCount">
|
||||
SELECT
|
||||
serial_number,
|
||||
COUNT(*) AS alert_count,
|
||||
SUM(CASE WHEN status = 1 THEN 1 ELSE 0 END) AS noprocessed_count,
|
||||
SUM(CASE WHEN status = 2 THEN 1 ELSE 0 END) AS unprocessed_count,
|
||||
SUM(CASE WHEN status = 3 THEN 1 ELSE 0 END) AS processed_count
|
||||
FROM
|
||||
iot_alert_log
|
||||
GROUP BY
|
||||
serial_number;
|
||||
</select>
|
||||
|
||||
<select id="selectDeviceAlertCountBySN" parameterType="String" resultMap="DeviceAlertCount">
|
||||
SELECT
|
||||
serial_number,
|
||||
COUNT(*) AS alert_count,
|
||||
SUM(CASE WHEN status = 1 THEN 1 ELSE 0 END) AS noprocessed_count,
|
||||
SUM(CASE WHEN status = 2 THEN 1 ELSE 0 END) AS unprocessed_count,
|
||||
SUM(CASE WHEN status = 3 THEN 1 ELSE 0 END) AS processed_count
|
||||
FROM
|
||||
iot_alert_log
|
||||
where serial_number = #{serialNumber}
|
||||
</select>
|
||||
|
||||
<select id="selectSceneAlertCount" resultMap="DeviceAlertCount">
|
||||
SELECT
|
||||
create_by AS scene_id,
|
||||
COUNT(*) AS alert_count,
|
||||
SUM(CASE WHEN status = 1 THEN 1 ELSE 0 END) AS noprocessed_count,
|
||||
SUM(CASE WHEN status = 2 THEN 1 ELSE 0 END) AS unprocessed_count,
|
||||
SUM(CASE WHEN status = 3 THEN 1 ELSE 0 END) AS processed_count
|
||||
FROM
|
||||
iot_alert_log
|
||||
GROUP BY
|
||||
create_by;
|
||||
</select>
|
||||
|
||||
<select id="selectSceneAlertCountBySceneId" parameterType="String" resultMap="DeviceAlertCount">
|
||||
SELECT
|
||||
create_by AS scene_id,
|
||||
COUNT(*) AS alert_count,
|
||||
SUM(CASE WHEN status = 1 THEN 1 ELSE 0 END) AS noprocessed_count,
|
||||
SUM(CASE WHEN status = 2 THEN 1 ELSE 0 END) AS unprocessed_count,
|
||||
SUM(CASE WHEN status = 3 THEN 1 ELSE 0 END) AS processed_count
|
||||
FROM
|
||||
iot_alert_log
|
||||
where create_by = #{sceneId}
|
||||
</select>
|
||||
|
||||
<select id="selectAlertLogByAlertLogId" parameterType="Long" resultMap="AlertLogResult">
|
||||
<include refid="selectAlertLogVo"/>
|
||||
where alert_log_id = #{alertLogId}
|
||||
</select>
|
||||
|
||||
<select id="countAlertProcess" resultType="com.fastbee.iot.model.AlertCountVO">
|
||||
select count(1) count, status type
|
||||
from iot_alert_log
|
||||
where user_id = #{tenantId}
|
||||
<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>
|
||||
group by status
|
||||
</select>
|
||||
|
||||
<select id="countAlertLevel" resultType="com.fastbee.iot.model.AlertCountVO">
|
||||
select count(1) count, alert_level type
|
||||
from iot_alert_log
|
||||
where user_id = #{tenantId}
|
||||
<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>
|
||||
group by alert_level
|
||||
</select>
|
||||
|
||||
<insert id="insertAlertLog" parameterType="com.fastbee.iot.domain.AlertLog" useGeneratedKeys="true" keyProperty="alertLogId">
|
||||
insert into iot_alert_log
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="alertName != null and alertName != ''">alert_name,</if>
|
||||
<if test="alertLevel != null">alert_level,</if>
|
||||
<if test="status != null">status,</if>
|
||||
<if test="productId != null">product_id,</if>
|
||||
<if test="detail != null and detail != ''">detail,</if>
|
||||
<if test="serialNumber != null and serialNumber != ''">serial_number,</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="userId != null">user_id,</if>
|
||||
<if test="deviceName != null and deviceName != ''">device_name,</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="alertName != null and alertName != ''">#{alertName},</if>
|
||||
<if test="alertLevel != null">#{alertLevel},</if>
|
||||
<if test="status != null">#{status},</if>
|
||||
<if test="productId != null">#{productId},</if>
|
||||
<if test="detail != null and detail != ''">#{detail},</if>
|
||||
<if test="serialNumber != null and serialNumber != ''">#{serialNumber},</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="userId != null">#{userId},</if>
|
||||
<if test="deviceName != null and deviceName != ''">#{deviceName},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
<insert id="insertAlertLogBatch" parameterType="com.fastbee.iot.domain.AlertLog" useGeneratedKeys="true" keyProperty="alertLogId">
|
||||
insert into iot_alert_log (alert_name,alert_level,status,product_id,detail,serial_number,create_time,create_by,device_name,user_id)
|
||||
values
|
||||
<foreach collection ="list" item="alertLog" separator =",">
|
||||
(#{alertLog.alertName},
|
||||
#{alertLog.alertLevel},
|
||||
#{alertLog.status},
|
||||
#{alertLog.productId},
|
||||
#{alertLog.detail},
|
||||
#{alertLog.serialNumber},
|
||||
#{alertLog.createTime},
|
||||
#{alertLog.createBy},
|
||||
#{alertLog.deviceName},
|
||||
#{alertLog.userId})
|
||||
</foreach >
|
||||
</insert>
|
||||
|
||||
<update id="updateAlertLog" parameterType="com.fastbee.iot.domain.AlertLog">
|
||||
update iot_alert_log
|
||||
<trim prefix="SET" suffixOverrides=",">
|
||||
<if test="alertName != null and alertName != ''">alert_name = #{alertName},</if>
|
||||
<if test="alertLevel != null">alert_level = #{alertLevel},</if>
|
||||
<if test="status != null">status = #{status},</if>
|
||||
<if test="productId != null">product_id = #{productId},</if>
|
||||
<if test="detail != null and detail != ''">detail = #{detail},</if>
|
||||
<if test="serialNumber != null and serialNumber != ''">serial_number = #{serialNumber},</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 alert_log_id = #{alertLogId}
|
||||
</update>
|
||||
|
||||
<update id="updateAlertLogStatus" parameterType="com.fastbee.iot.domain.AlertLog">
|
||||
update iot_alert_log
|
||||
<trim prefix="SET" suffixOverrides=",">
|
||||
<if test="status != null">status = #{status},</if>
|
||||
</trim>
|
||||
<where>
|
||||
<if test="serialNumber != null "> and serial_number = #{serialNumber}</if>
|
||||
<if test="createBy != null "> and create_by = #{createBy}</if>
|
||||
</where>
|
||||
</update>
|
||||
|
||||
<delete id="deleteAlertLogByAlertLogId" parameterType="Long">
|
||||
delete from iot_alert_log where alert_log_id = #{alertLogId}
|
||||
</delete>
|
||||
|
||||
<delete id="deleteAlertLogBySerialNumber" parameterType="String">
|
||||
delete from iot_alert_log where serial_number = #{serialNumber}
|
||||
</delete>
|
||||
|
||||
<delete id="deleteAlertLogByAlertLogIds" parameterType="String">
|
||||
delete from iot_alert_log where alert_log_id in
|
||||
<foreach item="alertLogId" collection="array" open="(" separator="," close=")">
|
||||
#{alertLogId}
|
||||
</foreach>
|
||||
</delete>
|
||||
|
||||
</mapper>
|
@ -0,0 +1,199 @@
|
||||
<?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.AlertMapper">
|
||||
|
||||
<resultMap type="com.fastbee.iot.domain.Alert" id="AlertResult">
|
||||
<result property="alertId" column="alert_id" />
|
||||
<result property="alertName" column="alert_name" />
|
||||
<result property="alertLevel" column="alert_level" />
|
||||
<result property="status" column="status" />
|
||||
<result property="notify" column="notify" />
|
||||
<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="tenantId" column="tenant_id" />
|
||||
<result property="tenantName" column="tenant_name" />
|
||||
</resultMap>
|
||||
|
||||
<resultMap type="com.fastbee.iot.domain.Scene" id="AlertSceneResult">
|
||||
<result property="sceneId" column="scene_id" />
|
||||
<result property="sceneName" column="scene_name" />
|
||||
<result property="userId" column="user_id" />
|
||||
<result property="userName" column="user_name" />
|
||||
<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="cond" column="cond" />
|
||||
<result property="silentPeriod" column="silent_period" />
|
||||
<result property="executeMode" column="execute_mode" />
|
||||
<result property="executeDelay" column="execute_delay" />
|
||||
<result property="hasAlert" column="has_alert" />
|
||||
<result property="enable" column="enable" />
|
||||
<result property="applicationName" column="application_name" />
|
||||
</resultMap>
|
||||
|
||||
<resultMap type="com.fastbee.iot.domain.AlertNotifyTemplate" id="AlertNotifyTemplateResult">
|
||||
<result property="alertId" column="alert_id" />
|
||||
<result property="notifyTemplateId" column="notify_template_id" />
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectAlertVo">
|
||||
select alert_id, alert_name, alert_level, status, notify, create_by, create_time, update_by, update_time, remark, tenant_id, tenant_name from iot_alert
|
||||
</sql>
|
||||
|
||||
<select id="selectScenesByAlertId" parameterType="Long" resultMap="AlertSceneResult">
|
||||
select a.alert_id,a.scene_id,s.scene_name,s.cond, s.silent_period, s.execute_mode, s.execute_delay, s.has_alert,s.enable
|
||||
from (select alert_id,scene_id from iot_alert_scene where alert_id = #{alertId}) a
|
||||
left join iot_scene s on a.scene_id = s.scene_id
|
||||
</select>
|
||||
|
||||
<select id="selectAlertList" parameterType="Alert" resultMap="AlertResult">
|
||||
<include refid="selectAlertVo"/>
|
||||
<where>
|
||||
<if test="alertName != null and alertName != ''"> and alert_name like concat('%', #{alertName}, '%')</if>
|
||||
<if test="alertLevel != null "> and alert_level = #{alertLevel}</if>
|
||||
<if test="status != null "> and status = #{status}</if>
|
||||
<if test="notify != null and notify != ''"> and notify = #{notify}</if>
|
||||
<if test="tenantId != null "> and tenant_id = #{tenantId}</if>
|
||||
</where>
|
||||
order by create_time desc
|
||||
</select>
|
||||
|
||||
<select id="selectAlertByAlertId" parameterType="Long" resultMap="AlertResult">
|
||||
<include refid="selectAlertVo"/>
|
||||
where alert_id = #{alertId}
|
||||
</select>
|
||||
|
||||
<select id="selectAlertNotifyTemplateList" parameterType="Long" resultType="com.fastbee.iot.domain.AlertNotifyTemplate">
|
||||
select alert_id, notify_template_id
|
||||
from iot_alert_notify_template
|
||||
where alert_id = #{alertId}
|
||||
</select>
|
||||
|
||||
<select id="selectNotifyTemplateListByAlertId" resultType="com.fastbee.notify.domain.NotifyTemplate">
|
||||
select n.id, n.service_code,n.msg_params,n.status, n.name, n.channel_id, n.channel_type, n.provider, n.create_by, n.create_time, n.update_by, n.update_time, n.del_flag, n.tenant_id, n.tenant_name, c.name channelName
|
||||
from iot_alert_notify_template a left join notify_template n on a.notify_template_id = n.id
|
||||
left join notify_channel c on n.channel_id = c.id
|
||||
where a.alert_id = #{alertId}
|
||||
</select>
|
||||
|
||||
<select id="selectAlertSceneListBySceneId" resultType="com.fastbee.iot.domain.AlertScene">
|
||||
select alert_id, scene_id
|
||||
from iot_alert_scene
|
||||
where scene_id = #{sceneId}
|
||||
</select>
|
||||
|
||||
<select id="listByAlertIds" resultType="com.fastbee.iot.model.AlertSceneSendVO">
|
||||
select s.scene_id, s.alert_id, a.alert_name, a.alert_level
|
||||
from iot_alert_scene s left join iot_alert a on s.alert_id = a.alert_id
|
||||
where s.scene_id = #{sceneId}
|
||||
and a.status = 1
|
||||
</select>
|
||||
|
||||
<insert id="insertAlert" parameterType="com.fastbee.iot.domain.Alert" useGeneratedKeys="true" keyProperty="alertId">
|
||||
insert into iot_alert
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="alertName != null and alertName != ''">alert_name,</if>
|
||||
<if test="alertLevel != null">alert_level,</if>
|
||||
<if test="status != null">status,</if>
|
||||
<if test="notify != null">notify,</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="tenantId != null">tenant_id,</if>
|
||||
<if test="tenantName != null and tenantName != ''">tenant_name,</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="alertName != null and alertName != ''">#{alertName},</if>
|
||||
<if test="alertLevel != null">#{alertLevel},</if>
|
||||
<if test="status != null">#{status},</if>
|
||||
<if test="notify != null">#{notify},</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="tenantId != null">#{tenantId},</if>
|
||||
<if test="tenantName != null and tenantName != ''">#{tenantName},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
<update id="updateAlert" parameterType="Alert">
|
||||
update iot_alert
|
||||
<trim prefix="SET" suffixOverrides=",">
|
||||
<if test="alertName != null and alertName != ''">alert_name = #{alertName},</if>
|
||||
<if test="alertLevel != null">alert_level = #{alertLevel},</if>
|
||||
<if test="status != null">status = #{status},</if>
|
||||
<if test="notify != null">notify = #{notify},</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 alert_id = #{alertId}
|
||||
</update>
|
||||
|
||||
<update id="updateAlertStatus">
|
||||
update iot_alert
|
||||
set status = #{status}
|
||||
where alert_id = #{alertId}
|
||||
</update>
|
||||
|
||||
<delete id="deleteAlertByAlertId" parameterType="Long">
|
||||
delete from iot_alert where alert_id = #{alertId}
|
||||
</delete>
|
||||
|
||||
<delete id="deleteAlertByAlertIds" parameterType="String">
|
||||
delete from iot_alert where alert_id in
|
||||
<foreach item="alertId" collection="array" open="(" separator="," close=")">
|
||||
#{alertId}
|
||||
</foreach>
|
||||
</delete>
|
||||
|
||||
<insert id="insertAlertSceneList" parameterType="java.util.List">
|
||||
insert into iot_alert_scene (alert_id,scene_id)
|
||||
VALUES
|
||||
<foreach collection="list" item="alertScene" separator=",">
|
||||
(#{alertScene.alertId},#{alertScene.sceneId})
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
<delete id="deleteAlertSceneByAlertIds" parameterType="String">
|
||||
delete from iot_alert_scene where alert_id in
|
||||
<foreach item="alertId" collection="array" open="(" separator="," close=")">
|
||||
#{alertId}
|
||||
</foreach>
|
||||
</delete>
|
||||
|
||||
<delete id="deleteAlertSceneBySceneIds" parameterType="String">
|
||||
delete from iot_alert_scene where scene_id in
|
||||
<foreach item="sceneId" collection="array" open="(" separator="," close=")">
|
||||
#{sceneId}
|
||||
</foreach>
|
||||
</delete>
|
||||
|
||||
<insert id="insertAlertNotifyTemplateList">
|
||||
insert into iot_alert_notify_template (alert_id, notify_template_id)
|
||||
VALUES
|
||||
<foreach collection="list" item="alertNotifyTemplate" separator=",">
|
||||
(#{alertNotifyTemplate.alertId},#{alertNotifyTemplate.notifyTemplateId})
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
<delete id="deleteAlertNotifyTemplateByAlertIds">
|
||||
delete from iot_alert_notify_template where alert_id in
|
||||
<foreach item="alertId" collection="array" open="(" separator="," close=")">
|
||||
#{alertId}
|
||||
</foreach>
|
||||
</delete>
|
||||
|
||||
</mapper>
|
@ -0,0 +1,110 @@
|
||||
<?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.BridgeMapper">
|
||||
|
||||
<resultMap type="com.fastbee.iot.domain.Bridge" id="BridgeResult">
|
||||
<result property="id" column="id" />
|
||||
<result property="configJson" column="config_json" />
|
||||
<result property="name" column="name" />
|
||||
<result property="enable" column="enable" />
|
||||
<result property="status" column="status" />
|
||||
<result property="type" column="type" />
|
||||
<result property="direction" column="direction" />
|
||||
<result property="route" column="route" />
|
||||
<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="selectBridgeVo">
|
||||
select id, config_json, name, enable, status, type, direction, route, del_flag, create_by, create_time, update_by, update_time, remark from bridge
|
||||
</sql>
|
||||
|
||||
<select id="selectBridgeList" parameterType="com.fastbee.iot.domain.Bridge" resultMap="BridgeResult">
|
||||
<include refid="selectBridgeVo"/>
|
||||
<where>
|
||||
<if test="configJson != null "> and config_json = #{configJson}</if>
|
||||
<if test="name != null and name != ''"> and name like concat('%', #{name}, '%')</if>
|
||||
<if test="enable != null "> and enable = #{enable}</if>
|
||||
<if test="status != null "> and status = #{status}</if>
|
||||
<if test="type != null "> and type = #{type}</if>
|
||||
<if test="direction != null "> and direction = #{direction}</if>
|
||||
<if test="route != null "> and route = #{route}</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<select id="selectBridgeById" parameterType="Long" resultMap="BridgeResult">
|
||||
<include refid="selectBridgeVo"/>
|
||||
where id = #{id}
|
||||
</select>
|
||||
|
||||
<insert id="insertBridge" parameterType="com.fastbee.iot.domain.Bridge" useGeneratedKeys="true" keyProperty="id">
|
||||
insert into bridge
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="configJson != null">config_json,</if>
|
||||
<if test="name != null and name != ''">name,</if>
|
||||
<if test="enable != null">enable,</if>
|
||||
<if test="status != null">status,</if>
|
||||
<if test="type != null">type,</if>
|
||||
<if test="direction != null">direction,</if>
|
||||
<if test="route != null">route,</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="configJson != null">#{configJson},</if>
|
||||
<if test="name != null and name != ''">#{name},</if>
|
||||
<if test="enable != null">#{enable},</if>
|
||||
<if test="status != null">#{status},</if>
|
||||
<if test="type != null">#{type},</if>
|
||||
<if test="direction != null">#{direction},</if>
|
||||
<if test="route != null">#{route},</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="updateBridge" parameterType="com.fastbee.iot.domain.Bridge">
|
||||
update bridge
|
||||
<trim prefix="SET" suffixOverrides=",">
|
||||
<if test="configJson != null">config_json = #{configJson},</if>
|
||||
<if test="name != null and name != ''">name = #{name},</if>
|
||||
<if test="enable != null">enable = #{enable},</if>
|
||||
<if test="status != null">status = #{status},</if>
|
||||
<if test="type != null">type = #{type},</if>
|
||||
<if test="direction != null">direction = #{direction},</if>
|
||||
<if test="route != null">route = #{route},</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 id = #{id}
|
||||
</update>
|
||||
|
||||
<delete id="deleteBridgeById" parameterType="Long">
|
||||
delete from bridge where id = #{id}
|
||||
</delete>
|
||||
|
||||
<delete id="deleteBridgeByIds" parameterType="String">
|
||||
delete from bridge where id in
|
||||
<foreach item="id" collection="array" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</delete>
|
||||
</mapper>
|
@ -0,0 +1,150 @@
|
||||
<?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">
|
||||
select c.category_id, c.category_name, c.tenant_id, c.tenant_name,
|
||||
c.is_sys,c.order_num, c.create_time, c.update_time, c.remark
|
||||
from iot_category c
|
||||
<where>
|
||||
<if test="deptId != null and showSenior and !isAdmin">
|
||||
and ( c.tenant_id = #{tenantId}
|
||||
or (c.tenant_id in (
|
||||
SELECT de.dept_user_id
|
||||
FROM sys_dept de
|
||||
WHERE FIND_IN_SET( de.dept_id,(
|
||||
SELECT d.ancestors
|
||||
FROM sys_dept d
|
||||
WHERE d.dept_id = #{deptId} )
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
</if>
|
||||
<if test="!showSenior and tenantId != null and tenantId != 0 and !isAdmin">
|
||||
and c.tenant_id = #{tenantId}
|
||||
</if>
|
||||
<if test="categoryName != null and categoryName != ''"> and c.category_name like concat('%', #{categoryName}, '%')</if>
|
||||
<if test="tenantId != null and tenantId != ''"> and (c.tenant_id = #{tenantId} or c.is_sys = 1)</if>
|
||||
</where>
|
||||
order by order_num
|
||||
</select>
|
||||
|
||||
<select id="selectCategoryShortList" resultMap="CategoryShortResult">
|
||||
select c.category_id, c.category_name
|
||||
from iot_category c
|
||||
<where>
|
||||
<if test="deptId != null and showSenior and !isAdmin">
|
||||
and ( c.tenant_id = #{tenantId}
|
||||
or (c.tenant_id in (
|
||||
SELECT de.dept_user_id
|
||||
FROM sys_dept de
|
||||
WHERE FIND_IN_SET( de.dept_id,(
|
||||
SELECT d.ancestors
|
||||
FROM sys_dept d
|
||||
WHERE d.dept_id = #{deptId} )
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
</if>
|
||||
<if test="!showSenior and tenantId != null and tenantId != 0 and !isAdmin">
|
||||
and c.tenant_id = #{tenantId}
|
||||
</if>
|
||||
<if test="categoryName != null and categoryName != ''"> and c.category_name like concat('%', #{categoryName}, '%')</if>
|
||||
<if test="tenantId != null and tenantId != ''"> and (c.tenant_id = #{tenantId} or c.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>
|
@ -0,0 +1,68 @@
|
||||
<?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.CommandPreferencesMapper">
|
||||
|
||||
<resultMap type="com.fastbee.iot.domain.CommandPreferences" id="CommandPreferencesResult">
|
||||
<result property="id" column="id" />
|
||||
<result property="name" column="name" />
|
||||
<result property="command" column="command" />
|
||||
<result property="serialNumber" column="serial_number" />
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectCommandPreferencesVo">
|
||||
select id, name, command, serial_number from command_preferences
|
||||
</sql>
|
||||
|
||||
<select id="selectCommandPreferencesList" parameterType="com.fastbee.iot.domain.CommandPreferences" resultMap="CommandPreferencesResult">
|
||||
<include refid="selectCommandPreferencesVo"/>
|
||||
<where>
|
||||
<if test="name != null and name != ''"> and name like concat('%', #{name}, '%')</if>
|
||||
<if test="command != null and command != ''"> and command = #{command}</if>
|
||||
<if test="serialNumber != null and serialNumber != ''"> and serial_number = #{serialNumber}</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<select id="selectCommandPreferencesById" parameterType="Long" resultMap="CommandPreferencesResult">
|
||||
<include refid="selectCommandPreferencesVo"/>
|
||||
where id = #{id}
|
||||
</select>
|
||||
|
||||
<insert id="insertCommandPreferences" parameterType="com.fastbee.iot.domain.CommandPreferences">
|
||||
insert into command_preferences
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="id != null">id,</if>
|
||||
<if test="name != null and name != ''">name,</if>
|
||||
<if test="command != null and command != ''">command,</if>
|
||||
<if test="serialNumber != null and serialNumber != ''">serial_number,</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="id != null">#{id},</if>
|
||||
<if test="name != null and name != ''">#{name},</if>
|
||||
<if test="command != null and command != ''">#{command},</if>
|
||||
<if test="serialNumber != null and serialNumber != ''">#{serialNumber},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
<update id="updateCommandPreferences" parameterType="com.fastbee.iot.domain.CommandPreferences">
|
||||
update command_preferences
|
||||
<trim prefix="SET" suffixOverrides=",">
|
||||
<if test="name != null and name != ''">name = #{name},</if>
|
||||
<if test="command != null and command != ''">command = #{command},</if>
|
||||
<if test="serialNumber != null and serialNumber != ''">serial_number = #{serialNumber},</if>
|
||||
</trim>
|
||||
where id = #{id}
|
||||
</update>
|
||||
|
||||
<delete id="deleteCommandPreferencesById" parameterType="Long">
|
||||
delete from command_preferences where id = #{id}
|
||||
</delete>
|
||||
|
||||
<delete id="deleteCommandPreferencesByIds" parameterType="String">
|
||||
delete from command_preferences where id in
|
||||
<foreach item="id" collection="array" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</delete>
|
||||
</mapper>
|
@ -0,0 +1,66 @@
|
||||
<?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.DeviceAlertUserMapper">
|
||||
|
||||
<resultMap type="DeviceAlertUser" id="DeviceAlertUserResult">
|
||||
<result property="deviceId" column="device_id" />
|
||||
<result property="userId" column="user_id" />
|
||||
<result property="userName" column="user_name"/>
|
||||
<result property="phoneNumber" column="phonenumber"/>
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectDeviceAlertUserVo">
|
||||
select device_id, user_id from iot_device_alert_user
|
||||
</sql>
|
||||
|
||||
<select id="selectDeviceAlertUserList" parameterType="DeviceAlertUser" resultMap="DeviceAlertUserResult">
|
||||
select du.device_id, du.user_id , u.user_name, u.phonenumber
|
||||
from iot_device_alert_user du
|
||||
left join sys_user u on du.user_id = u.user_id
|
||||
where du.device_id = #{deviceId}
|
||||
</select>
|
||||
|
||||
<select id="selectDeviceAlertUserByDeviceId" parameterType="Long" resultMap="DeviceAlertUserResult">
|
||||
<include refid="selectDeviceAlertUserVo"/>
|
||||
where device_id = #{deviceId}
|
||||
</select>
|
||||
|
||||
<insert id="insertDeviceAlertUser" parameterType="DeviceAlertUser">
|
||||
insert into iot_device_alert_user
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="deviceId != null">device_id,</if>
|
||||
<if test="userId != null">user_id,</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="deviceId != null">#{deviceId},</if>
|
||||
<if test="userId != null">#{userId},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
<update id="updateDeviceAlertUser" parameterType="DeviceAlertUser">
|
||||
update iot_device_alert_user
|
||||
<trim prefix="SET" suffixOverrides=",">
|
||||
<if test="userId != null">user_id = #{userId},</if>
|
||||
</trim>
|
||||
where device_id = #{deviceId}
|
||||
</update>
|
||||
|
||||
<delete id="deleteDeviceAlertUserByDeviceId" parameterType="Long">
|
||||
delete from iot_device_alert_user where device_id = #{deviceId}
|
||||
</delete>
|
||||
|
||||
<delete id="deleteDeviceAlertUserByDeviceIds" parameterType="String">
|
||||
delete from iot_device_alert_user where device_id in
|
||||
<foreach item="deviceId" collection="array" open="(" separator="," close=")">
|
||||
#{deviceId}
|
||||
</foreach>
|
||||
</delete>
|
||||
|
||||
<delete id="deleteByDeviceIdAndUserId">
|
||||
delete from iot_device_alert_user
|
||||
where device_id = #{deviceId}
|
||||
and user_id = #{userId}
|
||||
</delete>
|
||||
</mapper>
|
@ -0,0 +1,228 @@
|
||||
<?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" />
|
||||
<result property="datasourceId" column="datasource_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, datasource_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 != 'null' and status != ''">
|
||||
AND status = #{status}
|
||||
</if>
|
||||
<if test="jobType != null">
|
||||
and job_type = #{jobType}
|
||||
</if>
|
||||
<if test="remark != null">
|
||||
and remark = #{remark}
|
||||
</if>
|
||||
<if test="deviceId != null">
|
||||
and device_id = #{deviceId}
|
||||
</if>
|
||||
</where>
|
||||
order by create_time desc
|
||||
</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>
|
||||
|
||||
<select id="selectListByJobTypeAndDatasourceIds" resultMap="DeviceJobResult">
|
||||
select job_id, job_name, job_group from iot_device_job
|
||||
where datasource_id in
|
||||
<foreach collection="datasourceIds" item="datasourceId" open="(" separator="," close=")">
|
||||
#{datasourceId}
|
||||
</foreach>
|
||||
and job_type = #{jobType}
|
||||
</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>
|
||||
|
||||
<delete id="deleteJobByJobTypeAndDatasourceIds">
|
||||
delete from iot_device_job where datasource_id in
|
||||
<foreach collection="datasourceIds" item="datasourceId" open="(" separator="," close=")">
|
||||
#{datasourceId}
|
||||
</foreach>
|
||||
and job_type = #{jobType}
|
||||
</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>
|
||||
<if test="datasourceId != null and datasourceId!=0">datasource_id = #{datasourceId},</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>
|
||||
<if test="datasourceId != null and datasourceId!=0">datasource_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>
|
||||
<if test="datasourceId != null and datasourceId!=0">#{datasourceId},</if>
|
||||
#{isAdvance},
|
||||
sysdate()
|
||||
)
|
||||
</insert>
|
||||
|
||||
<delete id="deleteJobByJobTypeAndDeviceId">
|
||||
delete from iot_device_job where device_id = #{deviceId} and job_type = #{jobType}
|
||||
</delete>
|
||||
</mapper>
|
@ -0,0 +1,293 @@
|
||||
<?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="selectDeviceLogList" parameterType="com.fastbee.iot.domain.DeviceLog" resultMap="DeviceLogResult">
|
||||
<include refid="selectDeviceLogVo"/>
|
||||
<where>
|
||||
<if test="isMonitor != null"> and is_monitor = #{isMonitor}</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="logType != null "> and log_type = #{logType}</if>
|
||||
<if test="identity != null and identity != ''"> and identity like concat('%', #{identity}, '%')</if>
|
||||
</where>
|
||||
order by create_time desc
|
||||
</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="tenantId != null and tenantId != 0"> and user_id = #{tenantId}</if>
|
||||
</where>
|
||||
) as propertyCount,
|
||||
(select count(id)
|
||||
from iot_function_log
|
||||
<where>
|
||||
<if test="1==1"> and fun_type=2</if>
|
||||
<if test="tenantId != null and tenantId != 0"> and user_id = #{tenantId}</if>
|
||||
</where>
|
||||
) as functionCount,
|
||||
(select count(log_id)
|
||||
from iot_event_log
|
||||
<where>
|
||||
<if test="1==1"> and log_type=3</if>
|
||||
<if test="tenantId != null and tenantId != 0"> and user_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="tenantId != null and tenantId != 0"> and user_id = #{tenantId}</if>
|
||||
</where>
|
||||
) as monitorCount
|
||||
limit 1
|
||||
</select>
|
||||
|
||||
<insert id="insertDeviceLog" parameterType="com.fastbee.iot.domain.DeviceLog" useGeneratedKeys="true" keyProperty="logId">
|
||||
insert into iot_device_log
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="logType != null">log_type,</if>
|
||||
<if test="logValue != null">log_value,</if>
|
||||
<if test="deviceId != null">device_id,</if>
|
||||
<if test="deviceName != null and deviceName != ''">device_name,</if>
|
||||
<if test="serialNumber != null and serialNumber != ''">serial_number,</if>
|
||||
<if test="identity != null">identity,</if>
|
||||
<if test="createBy != null">create_by,</if>
|
||||
<if test="isMonitor != null">is_monitor,</if>
|
||||
<if test="mode != null">mode,</if>
|
||||
<if test="createTime != null">create_time,</if>
|
||||
<if test="remark != null">remark,</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="modelName != null and modelName != ''">model_name,</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="logType != null">#{logType},</if>
|
||||
<if test="logValue != null">#{logValue},</if>
|
||||
<if test="deviceId != null">#{deviceId},</if>
|
||||
<if test="deviceName != null and deviceName != ''">#{deviceName},</if>
|
||||
<if test="serialNumber != null and serialNumber != ''">#{serialNumber},</if>
|
||||
<if test="identity != null">#{identity},</if>
|
||||
<if test="createBy != null">#{createBy},</if>
|
||||
<if test="isMonitor != null">#{isMonitor},</if>
|
||||
<if test="mode != null">#{mode},</if>
|
||||
<if test="createTime != null">#{createTime},</if>
|
||||
<if test="remark != null">#{remark},</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="modelName != null and modelName != ''">#{modelName},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
<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>
|
||||
|
||||
<select id="selectHistoryList" parameterType="com.fastbee.iot.domain.DeviceLog" resultMap="HistoryResult">
|
||||
select l.log_value,
|
||||
l.create_time,
|
||||
l.identity
|
||||
from iot_device_log l
|
||||
<where>
|
||||
<if test="serialNumber != null and serialNumber != ''">
|
||||
and l.serial_number = #{serialNumber}
|
||||
</if>
|
||||
<if test="beginTime != null and beginTime != '' and endTime != null and endTime != ''">
|
||||
and l.create_time between #{beginTime} and #{endTime}
|
||||
</if>
|
||||
</where>
|
||||
order by l.create_time desc
|
||||
</select>
|
||||
|
||||
<select id="listHistory" parameterType="com.fastbee.iot.domain.DeviceLog" resultMap="HistoryResult">
|
||||
select log_value,
|
||||
create_time,
|
||||
identity
|
||||
from iot_device_log
|
||||
<where>
|
||||
<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>
|
||||
<if test="identityList != null and identityList != ''">
|
||||
and identity in
|
||||
<foreach collection="identityList" item="identity" open="(" separator="," close=")">
|
||||
#{identity}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="logType != null">
|
||||
and log_type = #{logType}
|
||||
</if>
|
||||
</where>
|
||||
order by create_time desc
|
||||
</select>
|
||||
<select id="listhistoryGroupByCreateTime" resultType="com.fastbee.iot.model.HistoryModel">
|
||||
select l.create_time as time, group_concat(distinct l.identity) as identity, group_concat(distinct l.log_value) as value
|
||||
from iot_device_log l
|
||||
<where>
|
||||
<if test="serialNumber != null and serialNumber != ''">
|
||||
and l.serial_number = #{serialNumber}
|
||||
</if>
|
||||
<if test="beginTime != null and beginTime != '' and endTime != null and endTime != ''">
|
||||
and l.create_time between #{beginTime} and #{endTime}
|
||||
</if>
|
||||
</where>
|
||||
group by l.create_time
|
||||
order by l.create_time desc
|
||||
</select>
|
||||
|
||||
<select id="selectStatsValue" resultType="java.lang.String">
|
||||
select log_value
|
||||
from iot_device_log
|
||||
<where>
|
||||
<if test="logType != null">
|
||||
and log_type = #{logType}
|
||||
</if>
|
||||
<if test="beginTime != null and beginTime != '' and endTime != null and endTime != ''">
|
||||
and create_time between #{beginTime} and #{endTime}
|
||||
</if>
|
||||
<if test="identity != null and identity != ''">
|
||||
and identity = #{identity}
|
||||
</if>
|
||||
<if test="serialNumber != null and serialNumber != ''">
|
||||
and serial_number = #{serialNumber}
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<select id="countThingsModelInvoke" resultType="com.fastbee.iot.model.ThingsModelLogCountVO">
|
||||
select identity identifier, min(model_name) modelName, count(identity) count
|
||||
from iot_device_log
|
||||
where log_type = 2
|
||||
<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>
|
||||
group by identity
|
||||
</select>
|
||||
|
||||
<select id="selectLastReport" parameterType="com.fastbee.iot.domain.DeviceLog" resultMap="DeviceLogResult">
|
||||
<include refid="selectDeviceLogVo"/>
|
||||
<where>
|
||||
<if test="serialNumber != null and serialNumber != ''">
|
||||
and serial_number = #{serialNumber}
|
||||
</if>
|
||||
<if test="identity != null and identity != ''"> and identity = #{identity}</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 1
|
||||
</select>
|
||||
</mapper>
|
@ -0,0 +1,945 @@
|
||||
<?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="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" />
|
||||
<result property="guid" column="guid" />
|
||||
</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="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" />
|
||||
<result property="guid" column="guid" />
|
||||
</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="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="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.UserAndTenant" id="UserAndTenantResult">
|
||||
<result property="userId" column="user_id" />
|
||||
</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="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="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="tenantId" column="tenant_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>
|
||||
|
||||
<resultMap type="com.fastbee.iot.model.DeviceNumberStatus" id="DeviceStatusResult">
|
||||
<result property="serialNumber" column="serial_number"/>
|
||||
<result property="status" column="status" />
|
||||
</resultMap>
|
||||
|
||||
<resultMap type="com.fastbee.common.core.device.DeviceAndProtocol" id="DeviceAndProtocolResult">
|
||||
<result property="serialNumber" column="serial_number"/>
|
||||
<result property="protocolCode" column="protocol_code"/>
|
||||
<result property="productId" column="product_id"/>
|
||||
<result property="deviceId" column="device_id"/>
|
||||
<result property="transport" column="transport"/>
|
||||
<result property="deviceType" column="device_type"/>
|
||||
<result property="slaveId" column="slave_id"/>
|
||||
<result property="proSlaveId" column="pro_slave_id"/>
|
||||
<result property="gwDeviceId" column="gw_device_id"/>
|
||||
<result property="gwProductId" column="gw_product_id"/>
|
||||
<result property="gwSerialNumber" column="gw_serial_number"/>
|
||||
<result property="gwDeviceName" column="gw_device_name"/>
|
||||
<result property="gwProductName" column="gw_product_name"/>
|
||||
<result property="tenantId" column="tenant_id"/>
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectDeviceVo">
|
||||
select device_id, device_name, product_id, product_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, 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,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="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="deptId != null and deptId != 0 and showChild != null and showChild">
|
||||
and tenant_id in (SELECT u.user_id FROM sys_user u
|
||||
join sys_dept de on u.dept_id = de.dept_id
|
||||
WHERE FIND_IN_SET(#{deptId}, de.ancestors) OR de.dept_id = #{deptId})
|
||||
</if>
|
||||
<if test="deptId != null and deptId != 0 and showChild != null and !showChild">
|
||||
and tenant_id = (SELECT dept_user_id FROM sys_dept WHERE dept_id = #{deptId})
|
||||
</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.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="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="deptId != null and deptId != 0 and showChild != null and showChild">
|
||||
and d.tenant_id in (SELECT u.user_id FROM sys_user u
|
||||
join sys_dept de on u.dept_id = de.dept_id
|
||||
WHERE FIND_IN_SET(#{deptId}, de.ancestors) OR de.dept_id = #{deptId})
|
||||
</if>
|
||||
<if test="deptId != null and deptId != 0 and showChild != null and !showChild">
|
||||
and d.tenant_id = (SELECT dept_user_id FROM sys_dept WHERE dept_id = #{deptId})
|
||||
</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.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
|
||||
from iot_device d
|
||||
<where>
|
||||
<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="deptId != null and deptId != 0 and showChild != null and showChild">
|
||||
and d.tenant_id in (SELECT u.user_id FROM sys_user u
|
||||
join sys_dept de on u.dept_id = de.dept_id
|
||||
WHERE FIND_IN_SET(#{deptId}, de.ancestors) OR de.dept_id = #{deptId})
|
||||
</if>
|
||||
<if test="deptId != null and deptId != 0 and showChild != null and !showChild">
|
||||
and d.tenant_id = (SELECT dept_user_id FROM sys_dept WHERE dept_id = #{deptId})
|
||||
</if>
|
||||
<if test="firmwareVersion != null"> and firmware_version = #{firmwareVersion}</if>
|
||||
</where>
|
||||
group by d.device_id,d.tenant_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.tenant_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
|
||||
from iot_device d
|
||||
left join iot_product p on p.product_id=d.product_id
|
||||
<where>
|
||||
<if test="productId != null "> and d.product_id = #{productId}</if>
|
||||
<if test="deptId != null and deptId != 0 and showChild != null and showChild">
|
||||
and d.tenant_id in (SELECT u.user_id FROM sys_user u
|
||||
join sys_dept de on u.dept_id = de.dept_id
|
||||
WHERE FIND_IN_SET(#{deptId}, de.ancestors) OR de.dept_id = #{deptId})
|
||||
</if>
|
||||
<if test="deptId != null and deptId != 0 and showChild != null and !showChild">
|
||||
and d.tenant_id = (SELECT dept_user_id FROM sys_dept WHERE dept_id = #{deptId})
|
||||
</if>
|
||||
</where>
|
||||
group by d.device_id,d.tenant_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,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, p.product_id, p.product_name,p.device_type,
|
||||
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, if(null = d.img_url or '' = d.img_url, p.img_url, d.img_url) as img_url,
|
||||
case
|
||||
when (select count(*) from iot_device_share du where du.device_id = d.device_id and du.user_id = #{tenantId}) then 0
|
||||
else 1
|
||||
end 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,p.guid
|
||||
from iot_device d
|
||||
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>
|
||||
and d.gw_dev_code is null
|
||||
<if test="groupId != null and groupId !=0 "> and g.group_id = #{groupId}</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="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="deptId != null and deptId != 0 and showChild != null and showChild">
|
||||
and
|
||||
( d.tenant_id in (SELECT u.user_id FROM sys_user u
|
||||
join sys_dept de on u.dept_id = de.dept_id
|
||||
WHERE FIND_IN_SET(#{deptId}, de.ancestors) OR de.dept_id = #{deptId})
|
||||
or d.device_id in (select du.device_id from iot_device_share du where du.user_id = #{tenantId})
|
||||
)
|
||||
</if>
|
||||
<if test="deptId != null and deptId != 0 and showChild != null and !showChild">
|
||||
and (
|
||||
d.tenant_id = (SELECT dept_user_id FROM sys_dept WHERE dept_id = #{deptId})
|
||||
or d.device_id in (select du.device_id from iot_device_share du where du.user_id = #{tenantId})
|
||||
)
|
||||
</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.tenant_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.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,p.guid 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="Long" resultType="com.fastbee.iot.model.DeviceStatistic">
|
||||
select
|
||||
<!--设备数量-->
|
||||
(select count(distinct d.device_id,d.tenant_id)
|
||||
from iot_device d
|
||||
<where>
|
||||
<if test="deptId != null and deptId != 0">
|
||||
and d.tenant_id in (SELECT u.user_id FROM sys_user u
|
||||
join sys_dept de on u.dept_id = de.dept_id
|
||||
WHERE FIND_IN_SET(#{deptId}, de.ancestors) OR de.dept_id = #{deptId})
|
||||
</if>
|
||||
</where>
|
||||
) as deviceCount,
|
||||
|
||||
<!--在线设备数量-->
|
||||
(select count(distinct d.device_id,d.tenant_id)
|
||||
from iot_device d
|
||||
<where>
|
||||
d.status=3
|
||||
<if test="deptId != null and deptId != 0">
|
||||
and d.tenant_id in (SELECT u.user_id FROM sys_user u
|
||||
join sys_dept de on u.dept_id = de.dept_id
|
||||
WHERE FIND_IN_SET(#{deptId}, de.ancestors) OR de.dept_id = #{deptId})
|
||||
</if>
|
||||
</where>
|
||||
) as deviceOnlineCount,
|
||||
|
||||
(
|
||||
select count(product_id)
|
||||
from iot_product
|
||||
<!-- <where>-->
|
||||
<!-- <if test="deptId != null and deptId != 0">-->
|
||||
<!-- and d.user_id in (SELECT-->
|
||||
<!-- u.user_id-->
|
||||
<!-- FROM-->
|
||||
<!-- sys_user u-->
|
||||
<!-- WHERE-->
|
||||
<!-- u.dept_id IN ( SELECT dept_id FROM sys_dept WHERE find_in_set(#{deptId}, ancestors) OR dept_id = #{deptId}))-->
|
||||
<!-- </if>-->
|
||||
<!-- </where>-->
|
||||
) as productCount,
|
||||
|
||||
<!-- <!–告警设备数量–>-->
|
||||
<!-- (select count(distinct l.serial_number)-->
|
||||
<!-- from iot_alert_log l-->
|
||||
<!-- left join iot_device d on l.serial_number=d.serial_number-->
|
||||
<!-- left join iot_device_user u on d.device_id=u.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 alertDeviceCount,-->
|
||||
<!-- -->
|
||||
<!-- <!–离线设备数量–>-->
|
||||
<!-- (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=4-->
|
||||
<!-- <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 deviceOfflineCount,-->
|
||||
<!-- -->
|
||||
<!-- <!–告警未处理数量–>-->
|
||||
<!-- (select count(distinct l.serial_number)-->
|
||||
<!-- from iot_alert_log l-->
|
||||
<!-- left join iot_device d on l.serial_number=d.serial_number-->
|
||||
<!-- left join iot_device_user u on d.device_id=u.device_id-->
|
||||
<!-- where l.status = 2-->
|
||||
<!-- <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>-->
|
||||
<!-- ) as alertNotProcessedCount,-->
|
||||
<!-- -->
|
||||
<!-- <!–告警已处理数量–>-->
|
||||
<!-- (select count(distinct l.serial_number)-->
|
||||
<!-- from iot_alert_log l-->
|
||||
<!-- left join iot_device d on l.serial_number=d.serial_number-->
|
||||
<!-- left join iot_device_user u on d.device_id=u.device_id-->
|
||||
<!-- where l.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>-->
|
||||
<!-- ) as alertProcessedCount,-->
|
||||
|
||||
(select count(distinct alert_log_id)
|
||||
from iot_alert_log l
|
||||
left join iot_device d on l.serial_number=d.serial_number
|
||||
<where>
|
||||
<if test="deptId != null and deptId != 0">
|
||||
and d.tenant_id in (SELECT u.user_id FROM sys_user u
|
||||
join sys_dept de on u.dept_id = de.dept_id
|
||||
WHERE FIND_IN_SET(#{deptId}, de.ancestors) OR de.dept_id = #{deptId})
|
||||
</if>
|
||||
</where>
|
||||
) as alertCount
|
||||
</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="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="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>
|
||||
|
||||
<insert id="insertBatchDevice" parameterType="com.fastbee.iot.domain.Device" useGeneratedKeys="true" keyProperty="deviceId">
|
||||
insert into iot_device (device_name, product_id, product_name, tenant_id, tenant_name, serial_number, firmware_version, rssi, is_shadow, location_way, create_by, create_time)
|
||||
values
|
||||
<foreach collection="deviceList" item="device" separator=",">
|
||||
(#{device.deviceName},
|
||||
#{device.productId},
|
||||
#{device.productName},
|
||||
#{device.tenantId},
|
||||
#{device.tenantName},
|
||||
#{device.serialNumber},
|
||||
#{device.firmwareVersion},
|
||||
#{device.rssi},
|
||||
#{device.isShadow},
|
||||
#{device.locationWay},
|
||||
#{device.createBy},
|
||||
sysdate())
|
||||
</foreach>
|
||||
</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="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="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"
|
||||
resultMap="DeviceAndProtocolResult">
|
||||
select p.protocol_code,
|
||||
p.product_id,
|
||||
d.serial_number,
|
||||
d.device_id,
|
||||
p.device_type,
|
||||
g.slave_id,
|
||||
d.tenant_id,
|
||||
CASE
|
||||
when p.device_type = 4 then gp.transport
|
||||
ELSE p.transport
|
||||
END as transport,
|
||||
mp.slave_id as pro_slave_id,
|
||||
gw.device_id as gw_device_id,
|
||||
gw.product_id as gw_product_id,
|
||||
gw.serial_number as gw_serial_number,
|
||||
gw.device_name as gw_device_name,
|
||||
gw.product_name as gw_product_name
|
||||
from iot_device d
|
||||
inner join
|
||||
iot_product p on d.product_id = p.product_id
|
||||
left join iot_sub_gateway g on g.sub_device_id = d.device_id
|
||||
left join iot_modbus_params mp on mp.product_id = p.product_id
|
||||
left join iot_device gw on gw.device_id = g.gw_device_id
|
||||
left join iot_product gp on gp.product_id = gw.product_id
|
||||
where d.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>
|
||||
|
||||
|
||||
<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="selectMqttConnectData" resultMap="DeviceMqttVOResult">
|
||||
select d.device_id,
|
||||
d.serial_number,
|
||||
d.product_id,
|
||||
d.tenant_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
|
||||
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
|
||||
from iot_device
|
||||
where serial_number = #{deviceNumber}
|
||||
</select>
|
||||
|
||||
<select id="getDeviceNumsByProductId" parameterType="Long" resultType="String">
|
||||
select serial_number from iot_device
|
||||
where product_id = #{productId} and gw_dev_code is NULL
|
||||
</select>
|
||||
|
||||
<select id="selectDeviceStatusByNumbers" parameterType="String" resultMap="DeviceStatusResult">
|
||||
select serial_number,`status`
|
||||
from iot_device
|
||||
where serial_number in
|
||||
<foreach collection="deviceNumbers" item="deviceNumber" index="index" open="(" separator="," close=")">
|
||||
#{deviceNumber}
|
||||
</foreach>
|
||||
</select>
|
||||
|
||||
|
||||
<select id="checkExistBySerialNumbers" resultType="java.lang.String">
|
||||
select serial_number
|
||||
from iot_device
|
||||
where serial_number in
|
||||
<foreach collection="serialNumberList" item="serialNumber" open="(" separator="," close=")">
|
||||
#{serialNumber}
|
||||
</foreach>
|
||||
</select>
|
||||
|
||||
<select id="listTerminalUser" 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.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,
|
||||
(select count(*) from iot_device d1 where d1.gw_dev_code = d.serial_number) as sub_device_count,
|
||||
p.protocol_code,p.transport, u.is_owner
|
||||
from (
|
||||
select device_id, 1 AS is_owner
|
||||
from iot_device_user
|
||||
where user_id = #{tenantId}
|
||||
union
|
||||
select device_id, 0 AS is_owner
|
||||
from iot_device_share
|
||||
where user_id = #{tenantId}
|
||||
) as u
|
||||
inner join iot_device d on u.device_id = d.device_id
|
||||
inner join iot_product p on d.product_id = p.product_id
|
||||
<if test="groupId != null and groupId !=0 "> left join iot_device_group g on g.device_id=d.device_id </if>
|
||||
<where>
|
||||
and d.gw_dev_code is null
|
||||
<if test="groupId != null and groupId !=0 "> and g.group_id = #{groupId}</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="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>
|
||||
order by u.is_owner desc, d.create_time desc
|
||||
|
||||
|
||||
|
||||
<!-- select d.device_id, d.device_name, d.product_id, d.product_name,p.device_type,-->
|
||||
<!-- 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,-->
|
||||
<!-- case-->
|
||||
<!-- when (select count(*) from iot_device_share du where du.device_id = d.device_id and du.user_id = #{tenantId}) then 0-->
|
||||
<!-- else 1-->
|
||||
<!-- end 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-->
|
||||
<!-- left join iot_product p on p.product_id=d.product_id-->
|
||||
<!-- left join iot_device_user u on u.device_id = d.device_id-->
|
||||
<!-- left join iot_device_share s on s.device_id = d.device_id-->
|
||||
<!-- <if test="groupId != null and groupId !=0 "> left join iot_device_group g on g.device_id=d.device_id </if>-->
|
||||
<!-- <where>-->
|
||||
<!-- and d.gw_dev_code is null-->
|
||||
<!-- <if test="groupId != null and groupId !=0 "> and g.group_id = #{groupId}</if>-->
|
||||
<!-- <if test="deviceName != null and deviceName != ''"> and d.device_name like concat('%', #{deviceName}, '%')</if>-->
|
||||
<!-- <if test="tenantId != null "> and (u.user_id = #{tenantId} or s.user_id = #{tenantId})</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="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-->
|
||||
<!-- order by is_owner desc, d.create_time desc-->
|
||||
</select>
|
||||
|
||||
<select id="listTerminalUserByGroup" resultType="com.fastbee.iot.domain.Device">
|
||||
select d.device_id, d.device_name, d.product_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
|
||||
from (
|
||||
select device_id, 1 AS is_owner
|
||||
from iot_device_user
|
||||
where user_id = #{tenantId}
|
||||
union
|
||||
select device_id, 0 AS is_owner
|
||||
from iot_device_share
|
||||
where user_id = #{tenantId}
|
||||
) as u
|
||||
inner join iot_device d on u.device_id = d.device_id
|
||||
inner join iot_product p on d.product_id = p.product_id
|
||||
<where>
|
||||
and d.gw_dev_code is null
|
||||
<if test="deviceName != null and deviceName != ''"> and d.device_name like concat('%', #{deviceName}, '%')</if>
|
||||
</where>
|
||||
order by u.is_owner desc, d.create_time desc
|
||||
</select>
|
||||
|
||||
<update id="reSetDeviceStatus">
|
||||
update iot_device set status = 4 where status = 3
|
||||
</update>
|
||||
|
||||
<select id="selectDeviceActive" resultType="com.fastbee.iot.model.DeviceStatusVO">
|
||||
select d.status , d.serial_number as serialNumber
|
||||
from iot_device d inner join iot_product p on d.product_id = p.product_id
|
||||
where d.status in (3,4) and p.transport not in ('GB28181')
|
||||
</select>
|
||||
|
||||
<select id="countByTenantId" resultType="java.lang.Integer">
|
||||
select count(1)
|
||||
from iot_device
|
||||
where tenant_id = #{tenantId}
|
||||
and del_flag = 0
|
||||
</select>
|
||||
|
||||
<select id="selectDeviceListByDeviceIds" resultMap="DeviceResult">
|
||||
<include refid="selectDeviceShortVo"/>
|
||||
where device_id in
|
||||
<foreach collection="deviceIdList" item="deviceId" open="(" separator="," close=")">
|
||||
#{deviceId}
|
||||
</foreach>
|
||||
</select>
|
||||
|
||||
|
||||
<update id="updateTenantIdByDeptIds">
|
||||
update iot_device
|
||||
set tenant_id = #{tenantId},
|
||||
tenant_name = #{tenantName}
|
||||
where device_id in
|
||||
<foreach collection="deviceIdList" item="deviceId" open="(" separator="," close=")">
|
||||
#{deviceId}
|
||||
</foreach>
|
||||
</update>
|
||||
|
||||
<select id="selectDeviceByChannelId" resultMap="DeviceResult">
|
||||
select device_name,device_id from iot_device
|
||||
where channel_id = #{channelId}
|
||||
</select>
|
||||
|
||||
<select id="selectDeviceStatusAndTransportStatus" resultType="com.fastbee.iot.model.DeviceStatusVO">
|
||||
SELECT
|
||||
d.status,
|
||||
d.serial_number,
|
||||
p.transport,
|
||||
p.product_id,
|
||||
p.device_type
|
||||
FROM
|
||||
iot_device d inner join iot_product p on d.product_id = p.product_id
|
||||
WHERE d.serial_number = #{serialNumber,jdbcType=VARCHAR}
|
||||
</select>
|
||||
|
||||
<select id="listDeviceGroupByGroupIds" resultType="com.fastbee.iot.domain.DeviceGroup">
|
||||
select device_id, group_id
|
||||
from iot_device_group
|
||||
<where>
|
||||
<if test="collection != null and collection.size() > 0">
|
||||
and group_id in
|
||||
<foreach collection="collection" index="index" item="id" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
</mapper>
|
@ -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.DeviceRecordMapper">
|
||||
|
||||
<resultMap type="DeviceRecord" id="DeviceRecordResult">
|
||||
<result property="id" column="id" />
|
||||
<result property="operateDeptId" column="operate_dept_id" />
|
||||
<result property="targetDeptId" column="target_dept_id" />
|
||||
<result property="productId" column="product_id" />
|
||||
<result property="deviceId" column="device_id" />
|
||||
<result property="type" column="type" />
|
||||
<result property="distributeType" column="distribute_type" />
|
||||
<result property="total" column="total" />
|
||||
<result property="successQuantity" column="success_quantity" />
|
||||
<result property="failQuantity" column="fail_quantity" />
|
||||
<result property="status" column="status" />
|
||||
<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="updateBy" column="update_by" />
|
||||
<result property="updateTime" column="update_time" />
|
||||
<result property="delFlag" column="del_flag" />
|
||||
<result property="serialNumber" column="serial_number" />
|
||||
<result property="parentId" column="parent_id" />
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectDeviceRecordVo">
|
||||
select id, operate_dept_id, target_dept_id, product_id, device_id, type, distribute_type, total, success_quantity, fail_quantity, status, tenant_id, tenant_name, create_by, create_time, update_by, update_time, del_flag, serial_number, parent_id from iot_device_record
|
||||
</sql>
|
||||
|
||||
<select id="selectDeviceRecordList" parameterType="DeviceRecord" resultMap="DeviceRecordResult">
|
||||
<include refid="selectDeviceRecordVo"/>
|
||||
<where>
|
||||
<if test="operateDeptId != null "> and operate_dept_id = #{operateDeptId}</if>
|
||||
<if test="targetDeptId != null "> and target_dept_id = #{targetDeptId}</if>
|
||||
<if test="productId != null "> and product_id = #{productId}</if>
|
||||
<if test="deviceId != null "> and device_id = #{deviceId}</if>
|
||||
<if test="type != null "> and type = #{type}</if>
|
||||
<if test="distributeType != null "> and distribute_type = #{distributeType}</if>
|
||||
<if test="total != null "> and total = #{total}</if>
|
||||
<if test="successQuantity != null "> and success_quantity = #{successQuantity}</if>
|
||||
<if test="failQuantity != null "> and fail_quantity = #{failQuantity}</if>
|
||||
<if test="status != null "> and status = #{status}</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="parentId != null "> and parent_id = #{parentId}</if>
|
||||
<if test="params.beginTime != null and params.beginTime != '' and params.endTime != null and params.endTime != ''">
|
||||
and create_time between #{params.beginTime} and #{params.endTime}
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<select id="selectDeviceRecordById" parameterType="Long" resultMap="DeviceRecordResult">
|
||||
<include refid="selectDeviceRecordVo"/>
|
||||
where id = #{id}
|
||||
</select>
|
||||
|
||||
<insert id="insertDeviceRecord" parameterType="DeviceRecord" useGeneratedKeys="true" keyProperty="id">
|
||||
insert into iot_device_record
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="id != null">id,</if>
|
||||
<if test="operateDeptId != null">operate_dept_id,</if>
|
||||
<if test="targetDeptId != null">target_dept_id,</if>
|
||||
<if test="productId != null">product_id,</if>
|
||||
<if test="deviceId != null">device_id,</if>
|
||||
<if test="type != null">type,</if>
|
||||
<if test="distributeType != null">distribute_type,</if>
|
||||
<if test="total != null">total,</if>
|
||||
<if test="successQuantity != null">success_quantity,</if>
|
||||
<if test="failQuantity != null">fail_quantity,</if>
|
||||
<if test="status != null">status,</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="updateBy != null">update_by,</if>
|
||||
<if test="updateTime != null">update_time,</if>
|
||||
<if test="delFlag != null">del_flag,</if>
|
||||
<if test="serialNumber != null">serial_number,</if>
|
||||
<if test="parentId != null">parent_id,</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="id != null">#{id},</if>
|
||||
<if test="operateDeptId != null">#{operateDeptId},</if>
|
||||
<if test="targetDeptId != null">#{targetDeptId},</if>
|
||||
<if test="productId != null">#{productId},</if>
|
||||
<if test="deviceId != null">#{deviceId},</if>
|
||||
<if test="type != null">#{type},</if>
|
||||
<if test="distributeType != null">#{distributeType},</if>
|
||||
<if test="total != null">#{total},</if>
|
||||
<if test="successQuantity != null">#{successQuantity},</if>
|
||||
<if test="failQuantity != null">#{failQuantity},</if>
|
||||
<if test="status != null">#{status},</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="updateBy != null">#{updateBy},</if>
|
||||
<if test="updateTime != null">#{updateTime},</if>
|
||||
<if test="delFlag != null">#{delFlag},</if>
|
||||
<if test="serialNumber != null">#{serialNumber},</if>
|
||||
<if test="parentId != null">#{parentId},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
<update id="updateDeviceRecord" parameterType="DeviceRecord">
|
||||
update iot_device_record
|
||||
<trim prefix="SET" suffixOverrides=",">
|
||||
<if test="operateDeptId != null">operate_dept_id = #{operateDeptId},</if>
|
||||
<if test="targetDeptId != null">target_dept_id = #{targetDeptId},</if>
|
||||
<if test="productId != null">product_id = #{productId},</if>
|
||||
<if test="deviceId != null">device_id = #{deviceId},</if>
|
||||
<if test="type != null">type = #{type},</if>
|
||||
<if test="distributeType != null">distribute_type = #{distributeType},</if>
|
||||
<if test="total != null">total = #{total},</if>
|
||||
<if test="successQuantity != null">success_quantity = #{successQuantity},</if>
|
||||
<if test="failQuantity != null">fail_quantity = #{failQuantity},</if>
|
||||
<if test="status != null">status = #{status},</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="updateBy != null">update_by = #{updateBy},</if>
|
||||
<if test="updateTime != null">update_time = #{updateTime},</if>
|
||||
<if test="delFlag != null">del_flag = #{delFlag},</if>
|
||||
<if test="serialNumber != null">serial_number = #{serialNumber},</if>
|
||||
<if test="parentId != null">parent_id = #{parentId},</if>
|
||||
</trim>
|
||||
where id = #{id}
|
||||
</update>
|
||||
|
||||
<delete id="deleteDeviceRecordById" parameterType="Long">
|
||||
delete from iot_device_record where id = #{id}
|
||||
</delete>
|
||||
|
||||
<delete id="deleteDeviceRecordByIds" parameterType="String">
|
||||
delete from iot_device_record where id in
|
||||
<foreach item="id" collection="array" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</delete>
|
||||
</mapper>
|
@ -0,0 +1,147 @@
|
||||
<?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.DeviceShareMapper">
|
||||
|
||||
<resultMap type="com.fastbee.iot.domain.DeviceShare" id="DeviceShareResult">
|
||||
<result property="deviceId" column="device_id" />
|
||||
<result property="userId" column="user_id" />
|
||||
<result property="phonenumber" column="phonenumber" />
|
||||
<result property="perms" column="perms" />
|
||||
<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" />
|
||||
<result property="userName" column="user_name"/>
|
||||
</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="selectDeviceShareVo">
|
||||
select device_id, user_id, phonenumber, perms, del_flag, create_by, create_time, update_by, update_time, remark from iot_device_share
|
||||
</sql>
|
||||
|
||||
<select id="selectDeviceShareList" parameterType="com.fastbee.iot.domain.DeviceShare" resultMap="DeviceShareResult">
|
||||
|
||||
select d.device_id, d.user_id, d.phonenumber, d.perms, d.del_flag,
|
||||
d.create_by, d.create_time, d.update_by, d.update_time, d.remark,
|
||||
su.user_name
|
||||
from iot_device_share d left join sys_user su on d.user_id = su.user_id
|
||||
<where>
|
||||
<if test="1==1"> and d.device_id = #{deviceId}</if>
|
||||
<if test="userId != null and userId != 0"> and d.user_id = #{userId}</if>
|
||||
<if test="phonenumber != null and phonenumber != ''"> and d.phonenumber = #{phonenumber}</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<select id="selectDeviceShareByDeviceId" parameterType="Long" resultMap="DeviceShareResult">
|
||||
<include refid="selectDeviceShareVo"/>
|
||||
where device_id = #{deviceId}
|
||||
</select>
|
||||
|
||||
<insert id="insertDeviceShare" parameterType="com.fastbee.iot.domain.DeviceShare">
|
||||
insert into iot_device_share
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="deviceId != null">device_id,</if>
|
||||
<if test="userId != null">user_id,</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="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>
|
||||
|
||||
<update id="updateDeviceShare" parameterType="com.fastbee.iot.domain.DeviceShare">
|
||||
update iot_device_share
|
||||
<trim prefix="SET" suffixOverrides=",">
|
||||
<if test="userId != null">user_id = #{userId},</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}
|
||||
</update>
|
||||
|
||||
<delete id="deleteDeviceShareByDeviceId" parameterType="Long">
|
||||
delete from iot_device_share where device_id = #{deviceId}
|
||||
</delete>
|
||||
|
||||
<delete id="deleteDeviceShareByDeviceIds" parameterType="String">
|
||||
delete from iot_device_share where device_id in
|
||||
<foreach item="deviceId" collection="array" open="(" separator="," close=")">
|
||||
#{deviceId}
|
||||
</foreach>
|
||||
</delete>
|
||||
|
||||
<delete id="deleteDeviceShareByDeviceIdAndUserId">
|
||||
delete from iot_device_share
|
||||
where device_id = #{deviceId}
|
||||
and user_id = #{userId}
|
||||
</delete>
|
||||
|
||||
<select id="selectDeviceShareByDeviceIdAndUserId" resultMap="DeviceShareResult">
|
||||
<include refid="selectDeviceShareVo"/>
|
||||
where device_id = #{deviceId} and user_id = #{userId}
|
||||
</select>
|
||||
|
||||
<select id="selectShareUser" parameterType="com.fastbee.iot.domain.DeviceShare" 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_share
|
||||
WHERE
|
||||
iot_device_share.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
|
||||
and isnull(u.dept_id)
|
||||
</select>
|
||||
</mapper>
|
@ -0,0 +1,145 @@
|
||||
<?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="phonenumber" column="phonenumber" />
|
||||
<result property="createTime" column="create_time" />
|
||||
<result property="updateTime" column="update_time" />
|
||||
<result property="remark" column="remark" />
|
||||
<result property="userName" column="user_name"/>
|
||||
</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, phonenumber, 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">
|
||||
select d.device_id, d.user_id, d.phonenumber, d.create_time,
|
||||
d.update_time, d.remark, su.user_name
|
||||
from iot_device_user d left join sys_user su on d.user_id = su.user_id
|
||||
where d.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="phonenumber != null">phonenumber,</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="phonenumber != null">#{phonenumber},</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,phonenumber, create_time) values
|
||||
<foreach collection="list" item="item" index="index" separator=",">
|
||||
(#{item.deviceId},#{item.userId},#{item.phonenumber}, #{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="phonenumber != null">phonenumber = #{phonenumber},</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 user_id = #{userId}
|
||||
</delete>
|
||||
</mapper>
|
@ -0,0 +1,171 @@
|
||||
<?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') >= date_format(#{params.beginTime},'%y%m%d')
|
||||
</if>
|
||||
<if test="params.endTime != null and params.endTime != ''"><!-- 结束时间检索 -->
|
||||
and date_format(create_time,'%y%m%d') <= 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>
|
||||
|
||||
<select id="listHistory" resultType="com.fastbee.iot.model.HistoryModel">
|
||||
select log_value as value,
|
||||
create_time as time,
|
||||
identity as identity
|
||||
from iot_event_log
|
||||
<where>
|
||||
<if test="serialNumber != null and serialNumber != ''">
|
||||
and serial_number = #{serialNumber}
|
||||
</if>
|
||||
<if test="params.beginTime != null and params.beginTime != '' and params.endTime != null and params.endTime != ''">
|
||||
and create_time between #{params.beginTime} and #{params.endTime}
|
||||
</if>
|
||||
<if test="identityList != null and identityList != ''">
|
||||
and identity in
|
||||
<foreach collection="identityList" item="identity" open="(" separator="," close=")">
|
||||
#{identity}
|
||||
</foreach>
|
||||
</if>
|
||||
</where>
|
||||
order by create_time desc
|
||||
</select>
|
||||
</mapper>
|
@ -0,0 +1,140 @@
|
||||
<?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.FirmwareMapper">
|
||||
|
||||
<resultMap type="com.fastbee.iot.domain.Firmware" id="FirmwareResult">
|
||||
<result property="firmwareId" column="firmware_id" />
|
||||
<result property="firmwareName" column="firmware_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="isSys" column="is_sys" />
|
||||
<result property="isLatest" column="is_latest" />
|
||||
<result property="version" column="version" />
|
||||
<result property="filePath" column="file_path" />
|
||||
<result property="createTime" column="create_time" />
|
||||
<result property="updateTime" column="update_time" />
|
||||
<result property="remark" column="remark" />
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectFirmwareVo">
|
||||
select firmware_id, firmware_name, product_id, product_name, tenant_id, tenant_name, is_sys,is_latest, version, file_path, create_time, update_time, remark from iot_firmware
|
||||
</sql>
|
||||
|
||||
<select id="selectFirmwareList" parameterType="com.fastbee.iot.domain.Firmware" resultMap="FirmwareResult">
|
||||
<include refid="selectFirmwareVo"/>
|
||||
<where>
|
||||
<if test="firmwareName != null and firmwareName != ''"> and firmware_name like concat('%', #{firmwareName}, '%')</if>
|
||||
<if test="productName != null and productName != ''"> and product_name like concat('%', #{productName}, '%')</if>
|
||||
<if test="tenantId != null and tenantId != ''"> and tenant_id = #{tenantId}</if>
|
||||
<if test="productId != null"> and product_id = #{productId}</if>
|
||||
<if test="isLatest != null"> and is_latest = #{isLatest}</if>
|
||||
</where>
|
||||
order by create_time desc
|
||||
</select>
|
||||
|
||||
<select id="selectFirmwareByFirmwareId" parameterType="Long" resultMap="FirmwareResult">
|
||||
<include refid="selectFirmwareVo"/>
|
||||
where firmware_id = #{firmwareId}
|
||||
</select>
|
||||
|
||||
<select id="selectLatestFirmware" parameterType="Long" resultMap="FirmwareResult">
|
||||
select f.firmware_id, f.firmware_name, f.product_id, f.product_name, f.tenant_id, f.tenant_name, f.is_sys,f.is_latest, f.version,
|
||||
f.file_path, f.create_time, f.remark
|
||||
from iot_device d
|
||||
left join iot_firmware f on d.product_id = f.product_id
|
||||
where d.device_id=#{deviceId} and f.is_latest=1
|
||||
order by f.create_time desc
|
||||
limit 1
|
||||
</select>
|
||||
|
||||
<!--查询待升级固件版本列表-->
|
||||
<select id="selectUpGradeVersionList" parameterType="com.fastbee.iot.domain.Firmware" resultMap="FirmwareResult">
|
||||
<include refid="selectFirmwareVo"/>
|
||||
<where>
|
||||
del_flag = '0'
|
||||
<if test="tenantId != null and tenantId != ''"> and tenant_id = #{tenantId}</if>
|
||||
<if test="productId != null"> and product_id = #{productId}</if>
|
||||
<if test="version != null"> and version < #{version}</if>
|
||||
</where>
|
||||
order by create_time desc
|
||||
</select>
|
||||
|
||||
<insert id="insertFirmware" parameterType="com.fastbee.iot.domain.Firmware" useGeneratedKeys="true" keyProperty="firmwareId">
|
||||
insert into iot_firmware
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="firmwareName != null and firmwareName != ''">firmware_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="isSys != null">is_sys,</if>
|
||||
<if test="isLatest != null">is_latest,</if>
|
||||
<if test="version != null">version,</if>
|
||||
<if test="filePath != null and filePath != ''">file_path,</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="firmwareName != null and firmwareName != ''">#{firmwareName},</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="isSys != null">#{isSys},</if>
|
||||
<if test="isLatest != null">#{isLatest},</if>
|
||||
<if test="version != null">#{version},</if>
|
||||
<if test="filePath != null and filePath != ''">#{filePath},</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="updateFirmware" parameterType="com.fastbee.iot.domain.Firmware">
|
||||
update iot_firmware
|
||||
<trim prefix="SET" suffixOverrides=",">
|
||||
<if test="firmwareName != null and firmwareName != ''">firmware_name = #{firmwareName},</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="isSys != null">is_sys = #{isSys},</if>
|
||||
<if test="isLatest != null">is_latest = #{isLatest},</if>
|
||||
<if test="version != null">version = #{version},</if>
|
||||
<if test="filePath != null and filePath != ''">file_path = #{filePath},</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 firmware_id = #{firmwareId}
|
||||
</update>
|
||||
|
||||
<update id="updateOrtherFirmwareIsLast">
|
||||
update iot_firmware set is_latest = 0 where product_id = #{productId} and is_latest = 1 and firmware_id != #{firmwareId}
|
||||
</update>
|
||||
|
||||
<delete id="deleteFirmwareByFirmwareId" parameterType="Long">
|
||||
delete from iot_firmware where firmware_id = #{firmwareId}
|
||||
</delete>
|
||||
|
||||
<delete id="deleteFirmwareByFirmwareIds" parameterType="String">
|
||||
delete from iot_firmware where firmware_id in
|
||||
<foreach item="firmwareId" collection="array" open="(" separator="," close=")">
|
||||
#{firmwareId}
|
||||
</foreach>
|
||||
</delete>
|
||||
</mapper>
|
@ -0,0 +1,196 @@
|
||||
<?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.FirmwareTaskDetailMapper">
|
||||
|
||||
<resultMap type="com.fastbee.iot.domain.FirmwareTaskDetail" id="FirmwareTaskDetailResult">
|
||||
<result property="id" column="id" />
|
||||
<result property="taskId" column="task_id" />
|
||||
<result property="serialNumber" column="serial_number" />
|
||||
<result property="upgradeStatus" column="upgrade_status" />
|
||||
<result property="createTime" column="create_time" />
|
||||
<result property="updateTime" column="update_time" />
|
||||
<result property="detailMsg" column="detail_msg" />
|
||||
<result property="messageId" column="message_id" />
|
||||
</resultMap>
|
||||
|
||||
<resultMap type="com.fastbee.iot.domain.FirmwareTaskDetail" id="FirmwareTaskDetailResult2">
|
||||
<result property="id" column="id" />
|
||||
<result property="taskId" column="task_id" />
|
||||
<result property="serialNumber" column="serial_number" />
|
||||
<result property="upgradeStatus" column="upgrade_status" />
|
||||
<result property="createTime" column="create_time" />
|
||||
<result property="updateTime" column="update_time" />
|
||||
<result property="detailMsg" column="detail_msg" />
|
||||
<result property="messageId" column="message_id" />
|
||||
<result property="taskName" column="task_name" jdbcType="VARCHAR"/>
|
||||
<result property="firmwareName" column="firmware_name" jdbcType="VARCHAR"/>
|
||||
<result property="version" column="firmware_version" jdbcType="VARCHAR"/>
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectFirmwareTaskDetailVo">
|
||||
select id, task_id, serial_number, upgrade_status, create_time, update_time, detail_msg, message_id from iot_firmware_task_detail
|
||||
</sql>
|
||||
|
||||
<select id="selectFirmwareTaskDetailList" parameterType="com.fastbee.iot.domain.FirmwareTaskDetail" resultMap="FirmwareTaskDetailResult">
|
||||
<include refid="selectFirmwareTaskDetailVo"/>
|
||||
<where>
|
||||
<if test="taskId != null "> and task_id = #{taskId}</if>
|
||||
<if test="serialNumber != null and serialNumber != ''"> and serial_number = #{serialNumber}</if>
|
||||
<if test="upgradeStatus != null "> and upgrade_status = #{upgradeStatus}</if>
|
||||
<if test="detailMsg != null and detailMsg != ''"> and detail_msg = #{detailMsg}</if>
|
||||
<if test="messageId != null and messageId != ''"> and message_id = #{messageId}</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<!-- 根据固件id查询下属设备列表 -->
|
||||
<select id="selectFirmwareTaskDetailListByFirmwareId" parameterType="com.fastbee.iot.model.FirmwareTaskDetailInput" resultType="com.fastbee.iot.model.FirmwareTaskDetailOutput">
|
||||
SELECT
|
||||
ftd.id,
|
||||
ft.firmware_id AS 'firmwareId',
|
||||
ftd.task_id AS 'taskId',
|
||||
ft.task_name AS 'taskName',
|
||||
d.device_name AS 'deviceName',
|
||||
ftd.serial_number AS 'serialNumber',
|
||||
ftd.message_id AS 'messageId',
|
||||
d.firmware_version AS 'version',
|
||||
ftd.upgrade_status AS 'upgradeStatus',
|
||||
ftd.detail_msg AS 'detailMsg',
|
||||
ftd.create_time AS 'createTime',
|
||||
ftd.update_time AS 'updateTime'
|
||||
FROM
|
||||
iot_firmware_task_detail ftd
|
||||
LEFT JOIN iot_firmware_task ft ON ftd.task_id = ft.id
|
||||
LEFT JOIN iot_device d ON ftd.serial_number = d.serial_number
|
||||
<where>
|
||||
ft.firmware_id = #{firmwareId}
|
||||
<if test = "taskId != null" >
|
||||
AND ftd.task_id = #{taskId,jdbcType=BIGINT}
|
||||
</if>
|
||||
<if test = "deviceName != null and deviceName != '' " >
|
||||
AND d.device_name = #{deviceName,jdbcType=VARCHAR}
|
||||
</if>
|
||||
<if test = "serialNumber != null and serialNumber != '' " >
|
||||
AND ftd.serial_number = #{serialNumber,jdbcType=VARCHAR}
|
||||
</if>
|
||||
<if test = "upgradeStatus != null" >
|
||||
AND ftd.upgrade_status = #{upgradeStatus}
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<!--固件升级设备统计-->
|
||||
<select id="deviceStatistic" parameterType="com.fastbee.iot.model.FirmwareTaskDetailInput" resultType="com.fastbee.iot.model.FirmwareTaskDeviceStatistic">
|
||||
SELECT
|
||||
ftd.upgrade_status AS 'upgradeStatus',
|
||||
count(ftd.id) AS 'deviceCount'
|
||||
FROM
|
||||
iot_firmware_task_detail ftd
|
||||
LEFT JOIN iot_firmware_task ft ON ftd.task_id = ft.id
|
||||
<where>
|
||||
ft.firmware_id = #{firmwareId}
|
||||
<if test = "taskId != null" >
|
||||
AND ftd.task_id = #{taskId,jdbcType=BIGINT}
|
||||
</if>
|
||||
</where>
|
||||
GROUP BY ftd.upgrade_status
|
||||
</select>
|
||||
|
||||
<select id="selectFirmwareTaskDetailById" parameterType="Long" resultMap="FirmwareTaskDetailResult">
|
||||
<include refid="selectFirmwareTaskDetailVo"/>
|
||||
where id = #{id}
|
||||
</select>
|
||||
|
||||
<insert id="insertFirmwareTaskDetail" parameterType="com.fastbee.iot.domain.FirmwareTaskDetail" useGeneratedKeys="true" keyProperty="id">
|
||||
insert into iot_firmware_task_detail
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="taskId != null">task_id,</if>
|
||||
<if test="serialNumber != null and serialNumber != ''">serial_number,</if>
|
||||
<if test="upgradeStatus != null">upgrade_status,</if>
|
||||
<if test="createTime != null">create_time,</if>
|
||||
<if test="updateTime != null">update_time,</if>
|
||||
<if test="detailMsg != null and detailMsg != ''">detail_msg,</if>
|
||||
<if test="messageId != null and messageId != ''">message_id,</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="taskId != null">#{taskId},</if>
|
||||
<if test="serialNumber != null and serialNumber != ''">#{serialNumber},</if>
|
||||
<if test="upgradeStatus != null">#{upgradeStatus},</if>
|
||||
<if test="createTime != null">#{createTime},</if>
|
||||
<if test="updateTime != null">#{updateTime},</if>
|
||||
<if test="detailMsg != null and detailMsg != ''">#{detailMsg},</if>
|
||||
<if test="messageId != null and messageId != ''">#{messageId},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
<!--批量插入任务明细-->
|
||||
<insert id="insertBatchFirmwareTaskDetail" parameterType="com.fastbee.iot.domain.FirmwareTaskDetail" useGeneratedKeys="true" keyProperty="id">
|
||||
insert into iot_firmware_task_detail (task_id,serial_number,upgrade_status,detail_msg, create_time, message_id)
|
||||
values
|
||||
<foreach item="item" collection="list" separator=",">
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
#{item.taskId},#{item.serialNumber},#{item.upgradeStatus},#{item.detailMsg},#{item.createTime},#{item.messageId}
|
||||
</trim>
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
<update id="updateFirmwareTaskDetail" parameterType="com.fastbee.iot.domain.FirmwareTaskDetail">
|
||||
update iot_firmware_task_detail
|
||||
<trim prefix="SET" suffixOverrides=",">
|
||||
<if test="taskId != null">task_id = #{taskId},</if>
|
||||
<if test="serialNumber != null and serialNumber != ''">serial_number = #{serialNumber},</if>
|
||||
<if test="upgradeStatus != null">upgrade_status = #{upgradeStatus},</if>
|
||||
<if test="createTime != null">create_time = #{createTime},</if>
|
||||
<if test="updateTime != null">update_time = #{updateTime},</if>
|
||||
<if test="detailMsg != null and detailMsg != ''">detail_msg = #{detailMsg},</if>
|
||||
<if test="messageId != null and messageId != ''">message_id = #{messageId},</if>
|
||||
</trim>
|
||||
where id = #{id}
|
||||
</update>
|
||||
|
||||
<delete id="deleteFirmwareTaskDetailById" parameterType="Long">
|
||||
delete from iot_firmware_task_detail where id = #{id}
|
||||
</delete>
|
||||
|
||||
<delete id="deleteFirmwareTaskDetailByIds" parameterType="String">
|
||||
delete from iot_firmware_task_detail where id in
|
||||
<foreach item="id" collection="array" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</delete>
|
||||
|
||||
<select id="selectFirmwareALLDetailList" parameterType="com.fastbee.iot.domain.FirmwareTaskDetail" resultMap="FirmwareTaskDetailResult2">
|
||||
select ftd.*,
|
||||
f.firmware_name,
|
||||
ft.task_name,
|
||||
f.version
|
||||
from
|
||||
iot_firmware_task_detail ftd
|
||||
left join iot_firmware_task ft on ftd.task_id = ft.id
|
||||
left join iot_firmware f on ft.firmware_id = f.firmware_id
|
||||
where 1=1
|
||||
<if test="id != null">
|
||||
and ftd.id = #{id}
|
||||
</if>
|
||||
<if test="taskName != null and taskName != '' ">
|
||||
and ft.task_name like CONCAT(CONCAT('%',#{taskName},'%'))
|
||||
</if>
|
||||
|
||||
<if test="firmwareName != null and firmwareName != '' ">
|
||||
and f.firmware_name like CONCAT(CONCAT('%',#{firmwareName},'%'))
|
||||
</if>
|
||||
<if test="taskId != null">
|
||||
and ftd.task_id = #{taskId,jdbcType=BIGINT}
|
||||
</if>
|
||||
<if test="serialNumber != null and serialNumber != '' ">
|
||||
and ftd.serial_number = #{serialNumber,jdbcType=VARCHAR}
|
||||
</if>
|
||||
<if test="upgradeStatus != null">
|
||||
and ftd.upgrade_status = #{upgradeStatus,jdbcType=INTEGER}
|
||||
</if>
|
||||
<if test="messageId != null and messageId != '' ">
|
||||
and ftd.message_id = #{messageId,jdbcType=VARCHAR}
|
||||
</if>
|
||||
</select>
|
||||
</mapper>
|
@ -0,0 +1,99 @@
|
||||
<?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.FirmwareTaskMapper">
|
||||
|
||||
<resultMap type="com.fastbee.iot.domain.FirmwareTask" id="FirmwareTaskResult">
|
||||
<result property="id" column="id" />
|
||||
<result property="taskName" column="task_name" />
|
||||
<result property="firmwareId" column="firmware_id" />
|
||||
<result property="upgradeType" column="upgrade_type" />
|
||||
<result property="createTime" column="create_time" />
|
||||
<result property="updateTime" column="update_time" />
|
||||
<result property="taskDesc" column="task_desc" />
|
||||
<result property="deviceAmount" column="device_amount" />
|
||||
<result property="delFlag" column="del_flag" />
|
||||
<result property="bookTime" column="book_time" />
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectFirmwareTaskVo">
|
||||
select id, task_name, firmware_id, upgrade_type, create_time, update_time, task_desc, device_amount, del_flag, book_time from iot_firmware_task
|
||||
</sql>
|
||||
|
||||
<select id="selectFirmwareTaskList" parameterType="com.fastbee.iot.domain.FirmwareTask" resultMap="FirmwareTaskResult">
|
||||
<include refid="selectFirmwareTaskVo"/>
|
||||
<where>
|
||||
<if test="id != null "> and id = #{id}</if>
|
||||
<if test="taskName != null and taskName != ''"> and task_name like concat('%', #{taskName}, '%')</if>
|
||||
<if test="firmwareId != null "> and firmware_id = #{firmwareId}</if>
|
||||
<if test="upgradeType != null "> and upgrade_type = #{upgradeType}</if>
|
||||
<if test="taskDesc != null and taskDesc != ''"> and task_desc = #{taskDesc}</if>
|
||||
<if test="deviceAmount != null "> and device_amount = #{deviceAmount}</if>
|
||||
<if test="bookTime != null "> and book_time = #{bookTime}</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<select id="selectFirmwareTaskById" parameterType="Long" resultMap="FirmwareTaskResult">
|
||||
<include refid="selectFirmwareTaskVo"/>
|
||||
where id = #{id}
|
||||
</select>
|
||||
|
||||
<insert id="insertFirmwareTask" parameterType="com.fastbee.iot.domain.FirmwareTask" useGeneratedKeys="true" keyProperty="id">
|
||||
insert into iot_firmware_task
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="taskName != null and taskName != ''">task_name,</if>
|
||||
<if test="firmwareId != null">firmware_id,</if>
|
||||
<if test="upgradeType != null">upgrade_type,</if>
|
||||
<if test="createTime != null">create_time,</if>
|
||||
<if test="updateTime != null">update_time,</if>
|
||||
<if test="taskDesc != null and taskDesc != ''">task_desc,</if>
|
||||
<if test="deviceAmount != null">device_amount,</if>
|
||||
<if test="delFlag != null">del_flag,</if>
|
||||
<if test="bookTime != null">book_time,</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="taskName != null and taskName != ''">#{taskName},</if>
|
||||
<if test="firmwareId != null">#{firmwareId},</if>
|
||||
<if test="upgradeType != null">#{upgradeType},</if>
|
||||
<if test="createTime != null">#{createTime},</if>
|
||||
<if test="updateTime != null">#{updateTime},</if>
|
||||
<if test="taskDesc != null and taskDesc != ''">#{taskDesc},</if>
|
||||
<if test="deviceAmount != null">#{deviceAmount},</if>
|
||||
<if test="delFlag != null">#{delFlag},</if>
|
||||
<if test="bookTime != null">#{bookTime},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
<update id="updateFirmwareTask" parameterType="com.fastbee.iot.domain.FirmwareTask">
|
||||
update iot_firmware_task
|
||||
<trim prefix="SET" suffixOverrides=",">
|
||||
<if test="taskName != null and taskName != ''">task_name = #{taskName},</if>
|
||||
<if test="firmwareId != null">firmware_id = #{firmwareId},</if>
|
||||
<if test="upgradeType != null">upgrade_type = #{upgradeType},</if>
|
||||
<if test="createTime != null">create_time = #{createTime},</if>
|
||||
<if test="updateTime != null">update_time = #{updateTime},</if>
|
||||
<if test="taskDesc != null and taskDesc != ''">task_desc = #{taskDesc},</if>
|
||||
<if test="deviceAmount != null">device_amount = #{deviceAmount},</if>
|
||||
<if test="delFlag != null">del_flag = #{delFlag},</if>
|
||||
<if test="bookTime != null">book_time = #{bookTime},</if>
|
||||
</trim>
|
||||
where id = #{id}
|
||||
</update>
|
||||
|
||||
<delete id="deleteFirmwareTaskById" parameterType="Long">
|
||||
delete from iot_firmware_task where id = #{id}
|
||||
</delete>
|
||||
|
||||
<delete id="deleteFirmwareTaskByIds" parameterType="String">
|
||||
delete from iot_firmware_task where id in
|
||||
<foreach item="id" collection="array" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</delete>
|
||||
|
||||
<select id="selectCountFirmwareTaskByTaskName" parameterType="java.lang.String" resultType="int">
|
||||
select count(t.task_name) from iot_firmware_task t
|
||||
where t.task_name = #{taskName,jdbcType=VARCHAR}
|
||||
</select>
|
||||
</mapper>
|
@ -0,0 +1,225 @@
|
||||
<?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="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 date_format(create_time,'%y%m%d') >= date_format(#{beginTime},'%y%m%d')
|
||||
</if>
|
||||
<if test="endTime != null">
|
||||
and date_format(create_time,'%y%m%d') <= date_format(#{endTime},'%y%m%d')
|
||||
</if>
|
||||
<if test="modelName != null">and model_name = #{modelName}</if>
|
||||
<if test="funType != null">and fun_type = #{funType}</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>
|
||||
|
||||
<select id="listHistory" parameterType="com.fastbee.iot.domain.FunctionLog" resultType="com.fastbee.iot.model.HistoryModel">
|
||||
select fun_value as value,
|
||||
create_time as time,
|
||||
identify as identity
|
||||
from iot_function_log
|
||||
<where>
|
||||
<if test="serialNumber != null and serialNumber != ''">
|
||||
and serial_number = #{serialNumber}
|
||||
</if>
|
||||
<if test="beginTime != null and endTime != null">
|
||||
and create_time between #{beginTime} and #{endTime}
|
||||
</if>
|
||||
<if test="identifyList != null and identifyList != ''">
|
||||
and identify in
|
||||
<foreach collection="identifyList" item="identify" open="(" separator="," close=")">
|
||||
#{identify}
|
||||
</foreach>
|
||||
</if>
|
||||
</where>
|
||||
order by create_time desc
|
||||
</select>
|
||||
|
||||
<select id="countThingsModelInvoke" resultType="com.fastbee.iot.model.ThingsModelLogCountVO">
|
||||
select identify identifier, min(model_name) modelName, count(identify) count
|
||||
from iot_function_log
|
||||
where fun_type = 1
|
||||
<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>
|
||||
group by identify
|
||||
</select>
|
||||
|
||||
<select id="selectLogByMessageId" resultMap="FunctionLogResult">
|
||||
<include refid="selectFunctionLogVo"/>
|
||||
where message_id = #{messageId}
|
||||
</select>
|
||||
</mapper>
|
@ -0,0 +1,82 @@
|
||||
<?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.GoviewProjectDataMapper">
|
||||
|
||||
<resultMap type="com.fastbee.iot.domain.GoviewProjectData" id="GoviewProjectDataResult">
|
||||
<result property="id" column="id" />
|
||||
<result property="projectId" column="project_id" />
|
||||
<result property="createTime" column="create_time" />
|
||||
<result property="updateTime" column="update_time" />
|
||||
<result property="createBy" column="create_by" />
|
||||
<result property="content" column="content" />
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectGoviewProjectDataVo">
|
||||
select id, project_id, create_time,update_time, create_by, content from iot_goview_project_data
|
||||
</sql>
|
||||
|
||||
<select id="selectGoviewProjectDataList" parameterType="com.fastbee.iot.domain.GoviewProjectData" resultMap="GoviewProjectDataResult">
|
||||
<include refid="selectGoviewProjectDataVo"/>
|
||||
<where>
|
||||
<if test="projectId != null and projectId != ''"> and project_id = #{projectId}</if>
|
||||
<if test="createBy != null and createBy != ''"> and create_by = #{createBy}</if>
|
||||
<if test="content != null and content != ''"> and content = #{content}</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<select id="selectGoviewProjectDataById" parameterType="String" resultMap="GoviewProjectDataResult">
|
||||
<include refid="selectGoviewProjectDataVo"/>
|
||||
where id = #{id}
|
||||
</select>
|
||||
<select id="selectGoviewProjectDataByProjectId" resultType="com.fastbee.iot.domain.GoviewProjectData">
|
||||
<include refid="selectGoviewProjectDataVo"/>
|
||||
where project_id = #{projectId}
|
||||
</select>
|
||||
|
||||
<insert id="insertGoviewProjectData" parameterType="com.fastbee.iot.domain.GoviewProjectData">
|
||||
insert into iot_goview_project_data
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="id != null">id,</if>
|
||||
<if test="projectId != null and projectId != ''">project_id,</if>
|
||||
<if test="createTime != null">create_time,</if>
|
||||
<if test="updateTime != null">update_time,</if>
|
||||
<if test="createBy != null">create_by,</if>
|
||||
<if test="content != null">content,</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="id != null">#{id},</if>
|
||||
<if test="projectId != null and projectId != ''">#{projectId},</if>
|
||||
<if test="createTime != null">#{createTime},</if>
|
||||
<if test="updateTime != null">#{updateTime},</if>
|
||||
<if test="createBy != null">#{createBy},</if>
|
||||
<if test="content != null">#{content},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
<update id="updateGoviewProjectData" parameterType="com.fastbee.iot.domain.GoviewProjectData">
|
||||
update iot_goview_project_data
|
||||
<trim prefix="SET" suffixOverrides=",">
|
||||
<if test="projectId != null and projectId != ''">project_id = #{projectId},</if>
|
||||
<if test="updateTime != null">update_time = #{updateTime},</if>
|
||||
<if test="content != null">content = #{content},</if>
|
||||
</trim>
|
||||
where id = #{id}
|
||||
</update>
|
||||
|
||||
<delete id="deleteGoviewProjectDataById" parameterType="String">
|
||||
delete from iot_goview_project_data where id = #{id}
|
||||
</delete>
|
||||
|
||||
<delete id="deleteGoviewProjectDataByIds" parameterType="String">
|
||||
delete from iot_goview_project_data where id in
|
||||
<foreach item="id" collection="array" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</delete>
|
||||
|
||||
<select id="executeSql" resultType="java.util.LinkedHashMap">
|
||||
${value}
|
||||
</select>
|
||||
</mapper>
|
@ -0,0 +1,97 @@
|
||||
<?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.GoviewProjectMapper">
|
||||
|
||||
<resultMap type="com.fastbee.iot.domain.GoviewProject" id="GoviewProjectResult">
|
||||
<result property="id" column="id" />
|
||||
<result property="projectName" column="project_name" />
|
||||
<result property="state" column="state" />
|
||||
<result property="createTime" column="create_time" />
|
||||
<result property="updateTime" column="update_time" />
|
||||
<result property="createBy" column="create_by" />
|
||||
<result property="delFlag" column="del_flag" />
|
||||
<result property="indexImage" column="index_image" />
|
||||
<result property="remarks" column="remarks" />
|
||||
<result property="tenantId" column="tenant_id" />
|
||||
<result property="tenantName" column="tenant_name" />
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectGoviewProjectVo">
|
||||
select id, project_name, state, create_time,update_time, create_by, del_flag, index_image, remarks, tenant_id, tenant_name from iot_goview_project
|
||||
</sql>
|
||||
|
||||
<select id="selectGoviewProjectList" parameterType="com.fastbee.iot.domain.GoviewProject" resultMap="GoviewProjectResult">
|
||||
<include refid="selectGoviewProjectVo"/>
|
||||
<where>
|
||||
del_flag = 0
|
||||
<if test="projectName != null and projectName != ''"> and project_name like concat('%', #{projectName}, '%')</if>
|
||||
<if test="state != null "> and state = #{state}</if>
|
||||
<if test="createBy != null and createBy != ''"> and create_by = #{createBy}</if>
|
||||
<if test="indexImage != null and indexImage != ''"> and index_image = #{indexImage}</if>
|
||||
<if test="remarks != null and remarks != ''"> and remarks = #{remarks}</if>
|
||||
<if test="tenantId != null "> and tenant_id = #{tenantId}</if>
|
||||
</where>
|
||||
order by create_time desc
|
||||
</select>
|
||||
|
||||
<select id="selectGoviewProjectById" parameterType="String" resultMap="GoviewProjectResult">
|
||||
<include refid="selectGoviewProjectVo"/>
|
||||
where id = #{id}
|
||||
</select>
|
||||
|
||||
<insert id="insertGoviewProject" parameterType="com.fastbee.iot.domain.GoviewProject" keyProperty="id" useGeneratedKeys="true">
|
||||
insert into iot_goview_project
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="id != null">id,</if>
|
||||
<if test="projectName != null and projectName != ''">project_name,</if>
|
||||
<if test="state != null">state,</if>
|
||||
<if test="createTime != null">create_time,</if>
|
||||
<if test="updateTime != null">update_time,</if>
|
||||
<if test="createBy != null">create_by,</if>
|
||||
<if test="delFlag != null">del_flag,</if>
|
||||
<if test="indexImage != null">index_image,</if>
|
||||
<if test="remarks != null">remarks,</if>
|
||||
<if test="tenantId != null">tenant_id,</if>
|
||||
<if test="tenantName != null and tenantName != ''">tenant_name,</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="id != null">#{id},</if>
|
||||
<if test="projectName != null and projectName != ''">#{projectName},</if>
|
||||
<if test="state != null">#{state},</if>
|
||||
<if test="createTime != null">#{createTime},
|
||||
<if test="updateTime != null">#{updateTime},</if></if>
|
||||
<if test="createBy != null">#{createBy},</if>
|
||||
<if test="delFlag != null">#{delFlag},</if>
|
||||
<if test="indexImage != null">#{indexImage},</if>
|
||||
<if test="remarks != null">#{remarks},</if>
|
||||
<if test="tenantId != null">#{tenantId},</if>
|
||||
<if test="tenantName != null and tenantName != ''">#{tenantName},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
<update id="updateGoviewProject" parameterType="com.fastbee.iot.domain.GoviewProject">
|
||||
update iot_goview_project
|
||||
<trim prefix="SET" suffixOverrides=",">
|
||||
<if test="projectName != null and projectName != ''">project_name = #{projectName},</if>
|
||||
<if test="state != null">state = #{state},</if>
|
||||
<if test="updateTime != null">update_time = #{updateTime},</if>
|
||||
<if test="delFlag != null">del_flag = #{delFlag},</if>
|
||||
<if test="indexImage != null">index_image = #{indexImage},</if>
|
||||
<if test="remarks != null">remarks = #{remarks},</if>
|
||||
</trim>
|
||||
where id = #{id}
|
||||
</update>
|
||||
|
||||
<delete id="deleteGoviewProjectById" parameterType="String">
|
||||
delete from iot_goview_project where id = #{id}
|
||||
</delete>
|
||||
|
||||
<delete id="deleteGoviewProjectByIds" parameterType="String">
|
||||
update iot_goview_project set del_flag = 1 where id in
|
||||
<foreach item="id" collection="array" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</delete>
|
||||
</mapper>
|
@ -0,0 +1,136 @@
|
||||
<?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>
|
||||
|
||||
<select id="selectGroupListByUserId" parameterType="java.lang.Long" resultMap="GroupResult">
|
||||
<include refid="selectGroupVo"/>
|
||||
<where>
|
||||
user_id = #{userId}
|
||||
</where>
|
||||
order by group_order
|
||||
</select>
|
||||
|
||||
<select id="listAllByIdList" parameterType="java.util.Set" resultMap="GroupResult">
|
||||
<include refid="selectGroupVo"/>
|
||||
<where>
|
||||
group_id in
|
||||
<foreach collection="collection" item="id" open="(" close=")" separator=",">
|
||||
#{id}
|
||||
</foreach>
|
||||
</where>
|
||||
order by group_order
|
||||
</select>
|
||||
</mapper>
|
@ -0,0 +1,347 @@
|
||||
<?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.ModbusConfigMapper">
|
||||
<resultMap type="com.fastbee.iot.domain.ModbusConfig" id="ModbusConfigResult">
|
||||
<result property="id" column="id"/>
|
||||
<result property="identifier" column="identifier"/>
|
||||
<result property="address" column="address"/>
|
||||
<result property="isReadonly" column="is_readonly"/>
|
||||
<result property="dataType" column="data_type"/>
|
||||
<result property="quantity" column="quantity"/>
|
||||
<result property="type" column="type"/>
|
||||
<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"/>
|
||||
<result property="productId" column="product_id"/>
|
||||
<result property="slave" column="slave"/>
|
||||
<result property="sort" column="sort"/>
|
||||
<result property="bitOrder" column="bit_order"/>
|
||||
</resultMap>
|
||||
|
||||
<resultMap type="com.fastbee.iot.domain.ModbusConfig" id="ModbusConfigShortResult">
|
||||
<result property="id" column="id"/>
|
||||
<result property="identifier" column="identifier"/>
|
||||
<result property="address" column="address"/>
|
||||
<result property="isReadonly" column="is_readonly"/>
|
||||
<result property="dataType" column="data_type"/>
|
||||
<result property="quantity" column="quantity"/>
|
||||
<result property="type" column="type"/>
|
||||
<result property="bitOrder" column="bit_order"/>
|
||||
<result property="productId" column="product_id"/>
|
||||
<result property="slave" column="slave"/>
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectModbusConfigVo">
|
||||
select id,
|
||||
product_id,
|
||||
slave,
|
||||
identifier,
|
||||
address,
|
||||
is_readonly,
|
||||
data_type,
|
||||
quantity,
|
||||
type,
|
||||
bit_order,
|
||||
sort,
|
||||
del_flag,
|
||||
create_by,
|
||||
create_time,
|
||||
update_by,
|
||||
update_time,
|
||||
remark
|
||||
from iot_modbus_config
|
||||
</sql>
|
||||
|
||||
<sql id="selectModbusConfigShortVo">
|
||||
select id,
|
||||
product_id,
|
||||
slave,
|
||||
identifier,
|
||||
address,
|
||||
bit_order,
|
||||
is_readonly,
|
||||
data_type,
|
||||
quantity,
|
||||
type
|
||||
from iot_modbus_config
|
||||
</sql>
|
||||
|
||||
<select id="selectModbusConfigList" parameterType="com.fastbee.iot.domain.ModbusConfig"
|
||||
resultMap="ModbusConfigResult">
|
||||
<include refid="selectModbusConfigVo"/>
|
||||
<where>
|
||||
<if test="identifier != null and identifier != ''">
|
||||
and identifier = #{identifier}
|
||||
</if>
|
||||
<if test="address != null ">
|
||||
and address = #{address}
|
||||
</if>
|
||||
<if test="isReadonly != null ">
|
||||
and is_readonly = #{isReadonly}
|
||||
</if>
|
||||
<if test="dataType != null and dataType != ''">
|
||||
and data_type = #{dataType}
|
||||
</if>
|
||||
<if test="quantity != null ">
|
||||
and quantity = #{quantity}
|
||||
</if>
|
||||
<if test="type != null ">
|
||||
and type = #{type}
|
||||
</if>
|
||||
<if test="productId != null ">
|
||||
and product_id = #{productId}
|
||||
</if>
|
||||
</where>
|
||||
order by id
|
||||
</select>
|
||||
|
||||
<select id="selectModbusConfigById" parameterType="Long" resultMap="ModbusConfigResult">
|
||||
<include refid="selectModbusConfigVo"/>
|
||||
where id = #{id}
|
||||
</select>
|
||||
|
||||
<insert id="insertModbusConfig" parameterType="com.fastbee.iot.domain.ModbusConfig">
|
||||
insert into iot_modbus_config
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="id != null">
|
||||
id,
|
||||
</if>
|
||||
<if test="productId != null">
|
||||
product_id,
|
||||
</if>
|
||||
<if test="slave != null">
|
||||
slave,
|
||||
</if>
|
||||
<if test="identifier != null and identifier != ''">
|
||||
identifier,
|
||||
</if>
|
||||
<if test="address != null">
|
||||
address,
|
||||
</if>
|
||||
<if test="isReadonly != null">
|
||||
is_readonly,
|
||||
</if>
|
||||
<if test="dataType != null and dataType != ''">
|
||||
data_type,
|
||||
</if>
|
||||
<if test="quantity != null">
|
||||
quantity,
|
||||
</if>
|
||||
<if test="type != null">
|
||||
type,
|
||||
</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="sort != null">
|
||||
sort,
|
||||
</if>
|
||||
<if test="bitOrder != null">
|
||||
bit_order,
|
||||
</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="id != null">
|
||||
#{id},
|
||||
</if>
|
||||
<if test="productId != null">
|
||||
#{productId},
|
||||
</if>
|
||||
<if test="slave != null">
|
||||
#{slave},
|
||||
</if>
|
||||
<if test="identifier != null and identifier != ''">
|
||||
#{identifier},
|
||||
</if>
|
||||
<if test="address != null">
|
||||
#{address},
|
||||
</if>
|
||||
<if test="isReadonly != null">
|
||||
#{isReadonly},
|
||||
</if>
|
||||
<if test="dataType != null and dataType != ''">
|
||||
#{dataType},
|
||||
</if>
|
||||
<if test="quantity != null">
|
||||
#{quantity},
|
||||
</if>
|
||||
<if test="type != null">
|
||||
#{type},
|
||||
</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="sort != null">
|
||||
#{sort},
|
||||
</if>
|
||||
<if test="bitOrder != null">
|
||||
#{bitOrder},
|
||||
</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
<update id="updateModbusConfig" parameterType="com.fastbee.iot.domain.ModbusConfig">
|
||||
update iot_modbus_config
|
||||
<trim prefix="SET" suffixOverrides=",">
|
||||
<if test="productId != null">
|
||||
product_id = #{productId},
|
||||
</if>
|
||||
<if test="slave != null">
|
||||
slave = #{slave},
|
||||
</if>
|
||||
<if test="identifier != null and identifier != ''">
|
||||
identifier = #{identifier},
|
||||
</if>
|
||||
<if test="address != null">
|
||||
address = #{address},
|
||||
</if>
|
||||
<if test="isReadonly != null">
|
||||
is_readonly = #{isReadonly},
|
||||
</if>
|
||||
<if test="dataType != null and dataType != ''">
|
||||
data_type = #{dataType},
|
||||
</if>
|
||||
<if test="quantity != null">
|
||||
quantity = #{quantity},
|
||||
</if>
|
||||
<if test="type != null">
|
||||
type = #{type},
|
||||
</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="sort != null">
|
||||
sort = #{sort},
|
||||
</if>
|
||||
<if test="bitOrder != null">
|
||||
bit_order = #{bitOrder},
|
||||
</if>
|
||||
</trim>
|
||||
where id = #{id}
|
||||
</update>
|
||||
|
||||
<delete id="deleteModbusConfigById" parameterType="Long">
|
||||
delete
|
||||
from iot_modbus_config
|
||||
where id = #{id}
|
||||
</delete>
|
||||
|
||||
<delete id="deleteModbusConfigByIds" parameterType="String">
|
||||
delete from iot_modbus_config where id in
|
||||
<foreach item="id" collection="array" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</delete>
|
||||
|
||||
<insert id="insertModbusConfigBatch" parameterType="com.fastbee.iot.domain.ModbusConfig" useGeneratedKeys="true"
|
||||
keyProperty="id">
|
||||
insert into iot_modbus_config (product_id,identifier, address, is_readonly, data_type, quantity,
|
||||
type,bit_order,sort, create_by, create_time)
|
||||
values
|
||||
<foreach collection="list" item="item" separator=",">
|
||||
(#{item.productId},
|
||||
#{item.identifier},
|
||||
#{item.address},
|
||||
#{item.isReadonly},
|
||||
#{item.dataType},
|
||||
#{item.quantity},
|
||||
#{item.type},
|
||||
#{item.bitOrder},
|
||||
#{item.sort},
|
||||
#{item.createBy},
|
||||
#{item.createTime})
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
<update id="updateModbusConfigBatch" parameterType="com.fastbee.iot.domain.ModbusConfig">
|
||||
update iot_modbus_config
|
||||
set product_id = #{productId},
|
||||
identifier = #{identifier},
|
||||
address = #{address},
|
||||
is_readonly = #{isReadonly},
|
||||
data_type = #{dataType},
|
||||
sort = #{sort},
|
||||
type = #{type},
|
||||
bit_order = #{bitOrder},
|
||||
update_by = #{updateBy},
|
||||
update_time = #{updateTime}
|
||||
where id in
|
||||
<foreach collection="list" item="item" index="index" open="(" close=")" separator=",">
|
||||
#{item}
|
||||
</foreach>
|
||||
</update>
|
||||
|
||||
<delete id="deleteByProductId" parameterType="Long">
|
||||
delete
|
||||
from iot_modbus_config
|
||||
where product_id = #{productId}
|
||||
</delete>
|
||||
|
||||
<select id="selectByIdentify" resultMap="ModbusConfigResult">
|
||||
<include refid="selectModbusConfigVo"/>
|
||||
where product_id = #{productId} and identifier = #{identity}
|
||||
</select>
|
||||
|
||||
<select id="selectShortListByProductId" parameterType="com.fastbee.iot.domain.ModbusConfig"
|
||||
resultMap="ModbusConfigShortResult">
|
||||
<include refid="selectModbusConfigShortVo"/>
|
||||
<where>
|
||||
<if test="productId != null">
|
||||
and product_id = #{productId}
|
||||
</if>
|
||||
<if test="address != null">
|
||||
and address = #{address}
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
</mapper>
|
@ -0,0 +1,100 @@
|
||||
<?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.ModbusJobMapper">
|
||||
|
||||
<resultMap type="com.fastbee.iot.domain.ModbusJob" id="ModbusJobResult">
|
||||
<result property="taskId" column="task_id" />
|
||||
<result property="jobName" column="job_name" />
|
||||
<result property="subDeviceId" column="sub_device_id" />
|
||||
<result property="subSerialNumber" column="sub_serial_number" />
|
||||
<result property="command" column="command" />
|
||||
<result property="jobId" column="job_id" />
|
||||
<result property="status" column="status" />
|
||||
<result property="createBy" column="create_by" />
|
||||
<result property="createTime" column="create_time" />
|
||||
<result property="remark" column="remark" />
|
||||
<result property="deviceType" column="device_type" />
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectModbusJobVo">
|
||||
select task_id,job_name, sub_device_id, sub_serial_number, command,device_type, job_id, status, create_by, create_time, remark from iot_modbus_job
|
||||
</sql>
|
||||
|
||||
<select id="selectModbusJobList" parameterType="com.fastbee.iot.domain.ModbusJob" resultMap="ModbusJobResult">
|
||||
<include refid="selectModbusJobVo"/>
|
||||
<where>
|
||||
<if test="subDeviceId != null "> and sub_device_id = #{subDeviceId}</if>
|
||||
<if test="subSerialNumber != null and subSerialNumber != ''"> and sub_serial_number = #{subSerialNumber}</if>
|
||||
<if test="status != null "> and status = #{status}</if>
|
||||
<if test="jobId != null">and job_id = #{jobId}</if>
|
||||
<if test="subDeviceList != null and subDeviceList != ''">
|
||||
and sub_serial_number in
|
||||
<foreach collection="subDeviceList" index="index" item="item" open="(" close=")" separator=",">
|
||||
#{item}
|
||||
</foreach>
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<select id="selectModbusJobByTaskId" parameterType="Long" resultMap="ModbusJobResult">
|
||||
<include refid="selectModbusJobVo"/>
|
||||
where task_id = #{taskId}
|
||||
</select>
|
||||
|
||||
<insert id="insertModbusJob" parameterType="com.fastbee.iot.domain.ModbusJob" useGeneratedKeys="true" keyProperty="taskId">
|
||||
insert into iot_modbus_job
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="jobName != null">job_name,</if>
|
||||
<if test="subDeviceId != null">sub_device_id,</if>
|
||||
<if test="subSerialNumber != null and subSerialNumber != ''">sub_serial_number,</if>
|
||||
<if test="command != null and command != ''">command,</if>
|
||||
<if test="jobId != null">job_id,</if>
|
||||
<if test="status != null">status,</if>
|
||||
<if test="createBy != null">create_by,</if>
|
||||
<if test="createTime != null">create_time,</if>
|
||||
<if test="remark != null">remark,</if>
|
||||
<if test="deviceType != null">device_type,</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="jobName != null">#{jobName},</if>
|
||||
<if test="subDeviceId != null">#{subDeviceId},</if>
|
||||
<if test="subSerialNumber != null and subSerialNumber != ''">#{subSerialNumber},</if>
|
||||
<if test="command != null and command != ''">#{command},</if>
|
||||
<if test="jobId != null">#{jobId},</if>
|
||||
<if test="status != null">#{status},</if>
|
||||
<if test="createBy != null">#{createBy},</if>
|
||||
<if test="createTime != null">#{createTime},</if>
|
||||
<if test="remark != null">#{remark},</if>
|
||||
<if test="deviceType != null">#{deviceType},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
<update id="updateModbusJob" parameterType="com.fastbee.iot.domain.ModbusJob">
|
||||
update iot_modbus_job
|
||||
<trim prefix="SET" suffixOverrides=",">
|
||||
<if test="jobName != null">job_name = #{jobName},</if>
|
||||
<if test="subDeviceId != null">sub_device_id = #{subDeviceId},</if>
|
||||
<if test="subSerialNumber != null and subSerialNumber != ''">sub_serial_number = #{subSerialNumber},</if>
|
||||
<if test="command != null and command != ''">command = #{command},</if>
|
||||
<if test="jobId != null">job_id = #{jobId},</if>
|
||||
<if test="status != null">status = #{status},</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 task_id = #{taskId}
|
||||
</update>
|
||||
|
||||
<delete id="deleteModbusJobByTaskId" parameterType="Long">
|
||||
delete from iot_modbus_job where task_id = #{taskId}
|
||||
</delete>
|
||||
|
||||
<delete id="deleteModbusJobByTaskIds" parameterType="String">
|
||||
delete from iot_modbus_job where task_id in
|
||||
<foreach item="taskId" collection="array" open="(" separator="," close=")">
|
||||
#{taskId}
|
||||
</foreach>
|
||||
</delete>
|
||||
</mapper>
|
@ -0,0 +1,120 @@
|
||||
<?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.ModbusParamsMapper">
|
||||
|
||||
<resultMap type="com.fastbee.iot.domain.ModbusParams" id="ModbusParamsResult">
|
||||
<result property="id" column="id" />
|
||||
<result property="productId" column="product_id" />
|
||||
<result property="pollType" column="poll_type" />
|
||||
<result property="slaveId" column="slave_id" />
|
||||
<result property="statusDeter" column="status_deter" />
|
||||
<result property="deterTimer" column="deter_timer" />
|
||||
<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="pollLength" column="poll_length" />
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectModbusParamsVo">
|
||||
select id, product_id, poll_type,poll_length, slave_id, status_deter, deter_timer, create_by, create_time, update_by, update_time, remark from iot_modbus_params
|
||||
</sql>
|
||||
|
||||
<select id="selectModbusParamsList" parameterType="ModbusParams" resultMap="ModbusParamsResult">
|
||||
<include refid="selectModbusParamsVo"/>
|
||||
<where>
|
||||
<if test="productId != null "> and product_id = #{productId}</if>
|
||||
<if test="pollType != null "> and poll_type = #{pollType}</if>
|
||||
<if test="slaveId != null "> and slave_id = #{slaveId}</if>
|
||||
<if test="statusDeter != null "> and status_deter = #{statusDeter}</if>
|
||||
<if test="deterTimer != null and deterTimer != ''"> and deter_timer = #{deterTimer}</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<select id="selectModbusParamsById" parameterType="Long" resultMap="ModbusParamsResult">
|
||||
<include refid="selectModbusParamsVo"/>
|
||||
where id = #{id}
|
||||
</select>
|
||||
|
||||
<insert id="insertModbusParams" parameterType="ModbusParams" useGeneratedKeys="true" keyProperty="id">
|
||||
insert into iot_modbus_params
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="productId != null">product_id,</if>
|
||||
<if test="pollType != null">poll_type,</if>
|
||||
<if test="slaveId != null">slave_id,</if>
|
||||
<if test="statusDeter != null">status_deter,</if>
|
||||
<if test="deterTimer != null">deter_timer,</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="pollLength != null">poll_length,</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="productId != null">#{productId},</if>
|
||||
<if test="pollType != null">#{pollType},</if>
|
||||
<if test="slaveId != null">#{slaveId},</if>
|
||||
<if test="statusDeter != null">#{statusDeter},</if>
|
||||
<if test="deterTimer != null">#{deterTimer},</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="pollLength != null">#{pollLength},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
<update id="updateModbusParams" parameterType="ModbusParams">
|
||||
update iot_modbus_params
|
||||
<trim prefix="SET" suffixOverrides=",">
|
||||
<if test="productId != null">product_id = #{productId},</if>
|
||||
<if test="pollType != null">poll_type = #{pollType},</if>
|
||||
<if test="slaveId != null">slave_id = #{slaveId},</if>
|
||||
<if test="statusDeter != null">status_deter = #{statusDeter},</if>
|
||||
<if test="deterTimer != null">deter_timer = #{deterTimer},</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="pollLength != null">poll_length = #{pollLength},</if>
|
||||
</trim>
|
||||
where id = #{id}
|
||||
</update>
|
||||
|
||||
<delete id="deleteModbusParamsById" parameterType="Long">
|
||||
delete from iot_modbus_params where id = #{id}
|
||||
</delete>
|
||||
|
||||
<delete id="deleteModbusParamsByIds" parameterType="String">
|
||||
delete from iot_modbus_params where id in
|
||||
<foreach item="id" collection="array" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</delete>
|
||||
|
||||
<select id="getModbusParamsByProductId" resultMap="ModbusParamsResult">
|
||||
<include refid="selectModbusParamsVo"/>
|
||||
where product_id = #{product_id}
|
||||
</select>
|
||||
|
||||
<select id="getModbusParamsByDeviceId" resultMap="ModbusParamsResult">
|
||||
SELECT
|
||||
p.id,
|
||||
p.product_id,
|
||||
p.poll_type,
|
||||
p.poll_length,
|
||||
p.slave_id,
|
||||
p.status_deter,
|
||||
p.deter_timer
|
||||
FROM
|
||||
iot_modbus_params p inner join
|
||||
iot_device d on p.product_id = d.product_id
|
||||
where d.device_id = #{deviceId}
|
||||
</select>
|
||||
</mapper>
|
@ -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>
|
@ -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>
|
@ -0,0 +1,130 @@
|
||||
<?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.OrderControlMapper">
|
||||
|
||||
<resultMap type="com.fastbee.iot.domain.OrderControl" id="OrderControlResult">
|
||||
<result property="id" column="id" />
|
||||
<result property="tenantId" column="tenant_id" />
|
||||
<result property="selectOrder" column="select_order" />
|
||||
<result property="status" column="status" />
|
||||
<result property="userId" column="user_id" />
|
||||
<result property="deviceId" column="device_id" />
|
||||
<result property="count" column="count" />
|
||||
<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="imgUrl" column="img_url" />
|
||||
<result property="filePath" column="file_path"/>
|
||||
<result property="startTime" column="start_time"/>
|
||||
<result property="endTime" column="end_time"/>
|
||||
<result property="deviceName" column="device_name" />
|
||||
<result property="userName" column="user_name" />
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectOrderControlVo">
|
||||
select id, tenant_id, select_order, status, user_id, device_id, count, create_by, create_time, update_by, update_time, remark,img_url,file_path,start_time,end_time from order_control
|
||||
</sql>
|
||||
|
||||
<select id="selectOrderControlList" parameterType="com.fastbee.iot.domain.OrderControl" resultMap="OrderControlResult">
|
||||
select c.id, c.tenant_id, c.select_order, c.status, c.user_id, c.device_id, c.count,
|
||||
c.create_by, c.create_time, c.update_by,
|
||||
c.update_time, c.remark,c.img_url,c.file_path,c.start_time,c.end_time,
|
||||
d.device_name, u.user_name
|
||||
from order_control c
|
||||
left join iot_device d on c.device_id = d.device_id
|
||||
left join sys_user u on c.user_id = u.user_id
|
||||
<where>
|
||||
<if test="tenantId != null "> and c.tenant_id = #{tenantId}</if>
|
||||
<if test="selectOrder != null and selectOrder != ''"> and c.select_order = #{selectOrder}</if>
|
||||
<if test="status != null "> and c.status = #{status}</if>
|
||||
<if test="userId != null "> and c.user_id = #{userId}</if>
|
||||
<if test="deviceId != null "> and c.device_id = #{deviceId}</if>
|
||||
<if test="count != null "> and count = #{count}</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<select id="selectOrderControlById" parameterType="Long" resultMap="OrderControlResult">
|
||||
<include refid="selectOrderControlVo"/>
|
||||
where id = #{id}
|
||||
</select>
|
||||
|
||||
<insert id="insertOrderControl" parameterType="com.fastbee.iot.domain.OrderControl" useGeneratedKeys="true" keyProperty="id">
|
||||
insert into order_control
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="tenantId != null">tenant_id,</if>
|
||||
<if test="selectOrder != null">select_order,</if>
|
||||
<if test="status != null">status,</if>
|
||||
<if test="userId != null">user_id,</if>
|
||||
<if test="deviceId != null">device_id,</if>
|
||||
<if test="count != null">count,</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="filePath != null">file_path,</if>
|
||||
<if test="startTime != null">start_time,</if>
|
||||
<if test="endTime != null">end_time,</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="tenantId != null">#{tenantId},</if>
|
||||
<if test="selectOrder != null">#{selectOrder},</if>
|
||||
<if test="status != null">#{status},</if>
|
||||
<if test="userId != null">#{userId},</if>
|
||||
<if test="deviceId != null">#{deviceId},</if>
|
||||
<if test="count != null">#{count},</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="filePath != null">#{filePath},</if>
|
||||
<if test="startTime != null">#{startTime},</if>
|
||||
<if test="endTime != null">#{endTime},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
<update id="updateOrderControl" parameterType="com.fastbee.iot.domain.OrderControl">
|
||||
update order_control
|
||||
<trim prefix="SET" suffixOverrides=",">
|
||||
<if test="tenantId != null">tenant_id = #{tenantId},</if>
|
||||
<if test="selectOrder != null">select_order = #{selectOrder},</if>
|
||||
<if test="status != null">status = #{status},</if>
|
||||
<if test="userId != null">user_id = #{userId},</if>
|
||||
<if test="deviceId != null">device_id = #{deviceId},</if>
|
||||
<if test="count != null">count = #{count},</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="filePath != null">file_path = #{filePath},</if>
|
||||
<if test="startTime != null">start_time = #{startTime},</if>
|
||||
<if test="endTime != null">end_time = #{endTime}</if>
|
||||
</trim>
|
||||
where id = #{id}
|
||||
</update>
|
||||
|
||||
<delete id="deleteOrderControlById" parameterType="Long">
|
||||
delete from order_control where id = #{id}
|
||||
</delete>
|
||||
|
||||
<delete id="deleteOrderControlByIds" parameterType="String">
|
||||
delete from order_control where id in
|
||||
<foreach item="id" collection="array" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</delete>
|
||||
|
||||
<select id="selectByUserId" resultMap="OrderControlResult">
|
||||
<include refid="selectOrderControlVo" />
|
||||
where user_id = #{userId} and device_id = #{deviceId}
|
||||
</select>
|
||||
</mapper>
|
@ -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>
|
@ -0,0 +1,340 @@
|
||||
<?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"/>
|
||||
<result property="locationWay" column="location_way" />
|
||||
<result property="isOwner" column="is_owner"/>
|
||||
<result property="guid" column="guid"/>
|
||||
</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,location_way,guid from iot_product
|
||||
</sql>
|
||||
|
||||
<select id="selectProductList" parameterType="com.fastbee.iot.domain.Product" resultMap="ProductResult">
|
||||
select p.product_id, p.product_name,p.protocol_code,p.transport, p.category_id,
|
||||
p.category_name, p.tenant_id, p.tenant_name, p.is_sys, p.is_authorize,
|
||||
p.mqtt_account,p.mqtt_password,p.mqtt_secret ,p.status,p.device_type,
|
||||
p.network_method, p.vertificate_method, p.create_time, p.update_time,
|
||||
p.img_url,p.remark,p.guid,
|
||||
case
|
||||
when (select count(*) from iot_product where p.tenant_id = #{tenantId}) > 0 then 1
|
||||
else 0
|
||||
end as is_owner,
|
||||
p.location_way from iot_product p
|
||||
<where>
|
||||
<if test="deptId != null and showSenior and !isAdmin">
|
||||
and ( p.tenant_id = #{tenantId}
|
||||
or (p.tenant_id in (
|
||||
SELECT de.dept_user_id
|
||||
FROM sys_dept de
|
||||
WHERE FIND_IN_SET( de.dept_id,(
|
||||
SELECT d.ancestors
|
||||
FROM sys_dept d
|
||||
WHERE d.dept_id = #{deptId} )
|
||||
)
|
||||
)
|
||||
and p.is_sys = 0
|
||||
)
|
||||
)
|
||||
</if>
|
||||
<if test="!showSenior and tenantId != null and tenantId != 0 and !isAdmin">
|
||||
and p.tenant_id = #{tenantId}
|
||||
</if>
|
||||
<if test="productName != null and productName != ''"> and p.product_name like concat('%', #{productName}, '%')</if>
|
||||
<if test="categoryName != null and categoryName != ''"> and p.category_name like concat('%', #{categoryName}, '%')</if>
|
||||
<if test="status != null "> and p.status = #{status}</if>
|
||||
<if test="deviceType != null "> and device_type = #{deviceType}</if>
|
||||
</where>
|
||||
order by p.create_time desc
|
||||
</select>
|
||||
|
||||
<select id="selectProductShortList" parameterType="com.fastbee.iot.domain.Product" resultMap="ProductShortResult">
|
||||
select p.product_id,p.product_name from iot_product p
|
||||
<where>
|
||||
<if test="deptId != null and showSenior and !isAdmin">
|
||||
and ( p.tenant_id = #{tenantId}
|
||||
or (p.tenant_id in (
|
||||
SELECT de.dept_user_id
|
||||
FROM sys_dept de
|
||||
WHERE FIND_IN_SET( de.dept_id,(
|
||||
SELECT d.ancestors
|
||||
FROM sys_dept d
|
||||
WHERE d.dept_id = #{deptId} )
|
||||
)
|
||||
)
|
||||
and p.is_sys = 0
|
||||
)
|
||||
)
|
||||
</if>
|
||||
<if test="!showSenior and tenantId != null and tenantId != 0 and !isAdmin">
|
||||
and p.tenant_id = #{tenantId}
|
||||
</if>
|
||||
</where>
|
||||
order by p.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>
|
||||
<if test="locationWay != null">location_way,</if>
|
||||
<if test="guid != null">guid,</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>
|
||||
<if test="locationWay != null">#{locationWay},</if>
|
||||
<if test="guid != null">#{guid},</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>
|
||||
<if test="locationWay != null">location_way = #{locationWay},</if>
|
||||
<if test="guid != null">guid = #{guid},</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="firmwareCountInProducts" parameterType="String" resultType="int">
|
||||
select count(*) from iot_firmware where product_id in
|
||||
<foreach item="productId" collection="array" open="(" separator="," close=")">
|
||||
#{productId}
|
||||
</foreach>
|
||||
</select>
|
||||
|
||||
<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,
|
||||
d.serial_number as serialNumber,
|
||||
d.tenant_id as userId
|
||||
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>
|
||||
|
||||
<select id="selectImgUrlByProductId" resultType="java.lang.String">
|
||||
select img_url
|
||||
from iot_product
|
||||
where product_id = #{productId}
|
||||
</select>
|
||||
|
||||
<select id="selectTerminalUserProduct" resultType="com.fastbee.iot.domain.Product">
|
||||
select p.product_id, p.product_name,p.protocol_code,p.transport, p.category_id,
|
||||
p.category_name, p.tenant_id, p.tenant_name, p.is_sys, p.is_authorize,
|
||||
p.mqtt_account,p.mqtt_password,p.mqtt_secret ,p.status,p.device_type,
|
||||
p.network_method, p.vertificate_method, p.create_time, p.update_time,
|
||||
p.img_url,p.remark
|
||||
from (
|
||||
select device_id
|
||||
from iot_device_user
|
||||
where user_id = #{tenantId}
|
||||
union
|
||||
select device_id
|
||||
from iot_device_share
|
||||
where user_id = #{tenantId}
|
||||
) as u
|
||||
inner join iot_device d on u.device_id = d.device_id
|
||||
inner join iot_product p on d.product_id = p.product_id
|
||||
<where>
|
||||
<if test="productName != null and productName != ''">
|
||||
and p.product_name = #{productName}
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<select id="selectProductListByProductIds" resultType="com.fastbee.iot.domain.Product">
|
||||
<include refid="selectProductVo"/>
|
||||
where product_id in
|
||||
<foreach collection="productIdList" item="productId" open="(" separator="," close=")">
|
||||
#{productId}
|
||||
</foreach>
|
||||
</select>
|
||||
|
||||
<select id="selectGuidByProductId" resultType="java.lang.String">
|
||||
select p.guid from iot_product p
|
||||
where p.product_id = #{productId}
|
||||
</select>
|
||||
|
||||
<select id="selectListScadaIdByGuidS" resultType="com.fastbee.iot.domain.Product">
|
||||
select id scadaId, guid
|
||||
from scada
|
||||
where guid in
|
||||
<foreach collection="guidList" item="guid" open="(" separator="," close=")">
|
||||
#{guid}
|
||||
</foreach>
|
||||
</select>
|
||||
|
||||
</mapper>
|
@ -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>
|
@ -0,0 +1,147 @@
|
||||
<?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.SceneDeviceMapper">
|
||||
|
||||
<resultMap type="SceneDevice" id="SceneDeviceResult">
|
||||
<result property="sceneDeviceId" column="scene_device_id" />
|
||||
<result property="serialNumber" column="serial_number" />
|
||||
<result property="productId" column="product_id" />
|
||||
<result property="productName" column="product_name" />
|
||||
<result property="scriptId" column="script_id" />
|
||||
<result property="sceneId" column="scene_id" />
|
||||
<result property="source" column="source" />
|
||||
<result property="type" column="type" />
|
||||
</resultMap>
|
||||
|
||||
<resultMap type="com.fastbee.iot.domain.Scene" id="SceneResult">
|
||||
<result property="sceneId" column="scene_id" />
|
||||
<result property="chainName" column="chain_name" />
|
||||
<result property="elData" column="el_data" />
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectSceneDeviceVo">
|
||||
select scene_device_id, serial_number, product_id, product_name, script_id, scene_id, source,type from iot_scene_device
|
||||
</sql>
|
||||
|
||||
<select id="selectSceneDeviceList" parameterType="SceneDevice" resultMap="SceneDeviceResult">
|
||||
<include refid="selectSceneDeviceVo"/>
|
||||
<where>
|
||||
<if test="serialNumber != null and serialNumber != ''"> and serial_number = #{serialNumber}</if>
|
||||
<if test="productId != null "> and product_id = #{productId}</if>
|
||||
<if test="productName != null "> and product_name = #{productName}</if>
|
||||
<if test="scriptId != null "> and script_id = #{scriptId}</if>
|
||||
<if test="sceneId != null "> and scene_id = #{sceneId}</if>
|
||||
<if test="source != null "> and source = #{source}</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<select id="selectTriggerDeviceRelateScenes" parameterType="SceneDevice" resultMap="SceneResult">
|
||||
select s.scene_id,s.chain_name
|
||||
from (select distinct scene_id from iot_scene_device where type = 2 and (serial_number = #{serialNumber} OR product_id = #{productId})) d
|
||||
left join iot_scene s on s.scene_id=d.scene_id
|
||||
where s.enable = 1
|
||||
</select>
|
||||
|
||||
<select id="selectSceneDeviceBySceneDeviceId" parameterType="Long" resultMap="SceneDeviceResult">
|
||||
<include refid="selectSceneDeviceVo"/>
|
||||
where scene_device_id = #{sceneDeviceId}
|
||||
</select>
|
||||
|
||||
<select id="listSceneProductBind" resultType="com.fastbee.iot.model.SceneDeviceBindVO">
|
||||
select d.scene_id, s.scene_name, d.product_id
|
||||
from iot_scene_device d
|
||||
left join iot_scene s on d.scene_id = s.scene_id
|
||||
where d.product_id in
|
||||
<foreach item="productId" collection="array" open="(" separator="," close=")">
|
||||
#{productId}
|
||||
</foreach>
|
||||
</select>
|
||||
|
||||
<select id="listSceneDeviceBind" resultType="com.fastbee.iot.model.SceneDeviceBindVO">
|
||||
select d.scene_id, s.scene_name, d.serial_number, s.user_id
|
||||
from iot_scene_device d
|
||||
left join iot_scene s on d.scene_id = s.scene_id
|
||||
where d.serial_number = #{serialNumber}
|
||||
</select>
|
||||
|
||||
<select id="listSceneIdByDeviceIdAndUserId" resultType="Long">
|
||||
select distinct s.scene_id
|
||||
from iot_scene_device sd
|
||||
join iot_scene s on sd.scene_id = s.scene_id
|
||||
where sd.serial_number = #{serialNumber}
|
||||
and s.user_id in
|
||||
<foreach collection="userIdList" item="userId" open="(" separator="," close=")">
|
||||
#{userId}
|
||||
</foreach>
|
||||
</select>
|
||||
|
||||
<insert id="insertSceneDevice" parameterType="SceneDevice" useGeneratedKeys="true" keyProperty="sceneDeviceId" >
|
||||
insert into iot_scene_device
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="serialNumber != null">serial_number,</if>
|
||||
<if test="productId != null">product_id,</if>
|
||||
<if test="productName != null">product_name,</if>
|
||||
<if test="scriptId != null">script_id,</if>
|
||||
<if test="sceneId != null">scene_id,</if>
|
||||
<if test="source != null">source,</if>
|
||||
<if test="type != null">type,</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="serialNumber != null">#{serialNumber},</if>
|
||||
<if test="productId != null">#{productId},</if>
|
||||
<if test="productName != null">#{productName},</if>
|
||||
<if test="scriptId != null">#{scriptId},</if>
|
||||
<if test="sceneId != null">#{sceneId},</if>
|
||||
<if test="source != null">#{source},</if>
|
||||
<if test="type != null">#{type},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
<update id="updateSceneDevice" parameterType="SceneDevice">
|
||||
update iot_scene_device
|
||||
<trim prefix="SET" suffixOverrides=",">
|
||||
<if test="serialNumber != null">serial_number = #{serialNumber},</if>
|
||||
<if test="productId != null">product_id = #{productId},</if>
|
||||
<if test="productName != null">product_name = #{productName},</if>
|
||||
<if test="scriptId != null">script_id = #{scriptId},</if>
|
||||
<if test="sceneId != null">scene_id = #{sceneId},</if>
|
||||
<if test="source != null">source = #{source},</if>
|
||||
<if test="type != null">type = #{type},</if>
|
||||
</trim>
|
||||
where scene_device_id = #{sceneDeviceId}
|
||||
</update>
|
||||
|
||||
<delete id="deleteSceneDeviceBySceneDeviceId" parameterType="Long">
|
||||
delete from iot_scene_device where scene_device_id = #{sceneDeviceId}
|
||||
</delete>
|
||||
|
||||
<delete id="deleteSceneDeviceBySceneDeviceIds" parameterType="String">
|
||||
delete from iot_scene_device where scene_device_id in
|
||||
<foreach item="sceneDeviceId" collection="array" open="(" separator="," close=")">
|
||||
#{sceneDeviceId}
|
||||
</foreach>
|
||||
</delete>
|
||||
|
||||
<insert id="insertSceneDeviceList" parameterType="java.util.List" useGeneratedKeys="true" keyProperty="sceneDeviceId">
|
||||
insert into iot_scene_device (serial_number,product_id,product_name, script_id,scene_id,source,type)
|
||||
VALUES
|
||||
<foreach collection ="list" item="sceneDevice" separator =",">
|
||||
(#{sceneDevice.serialNumber},
|
||||
#{sceneDevice.productId},
|
||||
#{sceneDevice.productName},
|
||||
#{sceneDevice.scriptId},
|
||||
#{sceneDevice.sceneId},
|
||||
#{sceneDevice.source},
|
||||
#{sceneDevice.type})
|
||||
</foreach >
|
||||
</insert>
|
||||
|
||||
<delete id="deleteSceneDeviceBySceneIds" parameterType="String">
|
||||
delete from iot_scene_device where scene_id in
|
||||
<foreach item="sceneId" collection="array" open="(" separator="," close=")">
|
||||
#{sceneId}
|
||||
</foreach>
|
||||
</delete>
|
||||
</mapper>
|
@ -0,0 +1,163 @@
|
||||
<?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.SceneMapper">
|
||||
|
||||
<resultMap type="com.fastbee.iot.domain.Scene" id="SceneResult">
|
||||
<result property="sceneId" column="scene_id" />
|
||||
<result property="recoverId" column="recover_id" />
|
||||
<result property="sceneName" column="scene_name" />
|
||||
<result property="chainName" column="chain_name" />
|
||||
<result property="userId" column="user_id" />
|
||||
<result property="userName" column="user_name" />
|
||||
<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="cond" column="cond" />
|
||||
<result property="silentPeriod" column="silent_period" />
|
||||
<result property="executeMode" column="execute_mode" />
|
||||
<result property="executeDelay" column="execute_delay" />
|
||||
<result property="checkDelay" column="check_delay" />
|
||||
<result property="hasAlert" column="has_alert" />
|
||||
<result property="enable" column="enable" />
|
||||
<result property="elData" column="el_data" />
|
||||
<result property="applicationName" column="application_name" />
|
||||
<result property="terminalUser" column="terminal_user" />
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectSceneVo">
|
||||
select scene_id, recover_id, scene_name,chain_name, user_id, user_name, create_by, create_time, update_by, update_time, remark, cond, silent_period, execute_mode, execute_delay, check_delay, has_alert, enable, el_data, application_name, terminal_user from iot_scene
|
||||
</sql>
|
||||
|
||||
<sql id="selectSceneListVo">
|
||||
select scene_id, recover_id, scene_name,chain_name, user_id, user_name, create_by, create_time, update_by, update_time, remark, cond, silent_period, execute_mode, execute_delay, check_delay, has_alert, enable, application_name, terminal_user from iot_scene
|
||||
</sql>
|
||||
|
||||
<select id="selectSceneList" parameterType="Scene" resultMap="SceneResult">
|
||||
<include refid="selectSceneListVo"/>
|
||||
<where>
|
||||
<if test="recoverId != null "> and recover_id = #{recoverId}</if>
|
||||
<if test="sceneName != null and sceneName != ''"> and scene_name like concat('%', #{sceneName}, '%')</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="cond != null "> and cond = #{cond}</if>
|
||||
<if test="silentPeriod != null "> and silent_period = #{silentPeriod}</if>
|
||||
<if test="executeMode != null "> and execute_mode = #{executeMode}</if>
|
||||
<if test="executeDelay != null "> and execute_delay = #{executeDelay}</if>
|
||||
<if test="checkDelay != null "> and check_delay = #{checkDelay}</if>
|
||||
<if test="hasAlert != null "> and has_alert = #{hasAlert}</if>
|
||||
<if test="enable != null "> and enable = #{enable}</if>
|
||||
</where>
|
||||
order by create_time desc
|
||||
</select>
|
||||
|
||||
<select id="selectSceneBySceneId" parameterType="Long" resultMap="SceneResult">
|
||||
<include refid="selectSceneVo"/>
|
||||
where scene_id = #{sceneId}
|
||||
</select>
|
||||
|
||||
<select id="selectSceneListBySceneIds" parameterType="String" resultMap="SceneResult">
|
||||
<include refid="selectSceneVo"/>
|
||||
where scene_id in
|
||||
<foreach item="sceneId" collection="array" open="(" separator="," close=")">
|
||||
#{sceneId}
|
||||
</foreach>
|
||||
</select>
|
||||
|
||||
<select id="selectTerminalUserBySceneIds" resultType="com.fastbee.iot.model.SceneTerminalUserVO">
|
||||
select scene_id, user_id, terminal_user
|
||||
from iot_scene
|
||||
where scene_id in
|
||||
<foreach collection="collection" item="id" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</select>
|
||||
|
||||
<insert id="insertScene" parameterType="com.fastbee.iot.domain.Scene" useGeneratedKeys="true" keyProperty="sceneId">
|
||||
insert into iot_scene
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="recoverId != null">recover_id,</if>
|
||||
<if test="sceneName != null and sceneName != ''">scene_name,</if>
|
||||
<if test="chainName != null and chainName != ''">chain_name,</if>
|
||||
<if test="userId != null">user_id,</if>
|
||||
<if test="userName != null and userName != ''">user_name,</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="cond != null">cond,</if>
|
||||
<if test="silentPeriod != null">silent_period,</if>
|
||||
<if test="executeMode != null">execute_mode,</if>
|
||||
<if test="executeDelay != null">execute_delay,</if>
|
||||
<if test="checkDelay != null">check_delay,</if>
|
||||
<if test="hasAlert != null">has_alert,</if>
|
||||
<if test="enable != null">enable,</if>
|
||||
<if test="elData != null">el_data,</if>
|
||||
<if test="applicationName != null and applicationName != ''">application_name,</if>
|
||||
<if test="terminalUser != null">terminal_user,</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="recoverId != null">#{recoverId},</if>
|
||||
<if test="sceneName != null and sceneName != ''">#{sceneName},</if>
|
||||
<if test="chainName != null and chainName != ''">#{chainName},</if>
|
||||
<if test="userId != null">#{userId},</if>
|
||||
<if test="userName != null and userName != ''">#{userName},</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="cond != null">#{cond},</if>
|
||||
<if test="silentPeriod != null">#{silentPeriod},</if>
|
||||
<if test="executeMode != null">#{executeMode},</if>
|
||||
<if test="executeDelay != null">#{executeDelay},</if>
|
||||
<if test="checkDelay != null">#{checkDelay},</if>
|
||||
<if test="hasAlert != null">#{hasAlert},</if>
|
||||
<if test="enable != null">#{enable},</if>
|
||||
<if test="elData != null">#{elData},</if>
|
||||
<if test="applicationName != null and applicationName != ''">#{applicationName},</if>
|
||||
<if test="terminalUser != null">#{terminalUser},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
<update id="updateScene" parameterType="com.fastbee.iot.domain.Scene">
|
||||
update iot_scene
|
||||
<trim prefix="SET" suffixOverrides=",">
|
||||
<if test="recoverId != null">recover_id = #{recoverId},</if>
|
||||
<if test="sceneName != null and sceneName != ''">scene_name = #{sceneName},</if>
|
||||
<if test="chainName != null and chainName != ''">chain_name = #{chainName},</if>
|
||||
<if test="userId != null">user_id = #{userId},</if>
|
||||
<if test="userName != null and userName != ''">user_name = #{userName},</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="cond != null">cond = #{cond},</if>
|
||||
<if test="silentPeriod != null">silent_period = #{silentPeriod},</if>
|
||||
<if test="executeMode != null">execute_mode = #{executeMode},</if>
|
||||
<if test="executeDelay != null">execute_delay = #{executeDelay},</if>
|
||||
<if test="checkDelay != null">check_delay = #{checkDelay},</if>
|
||||
<if test="hasAlert != null">has_alert = #{hasAlert},</if>
|
||||
<if test="enable != null">enable = #{enable},</if>
|
||||
<if test="elData != null">el_data = #{elData},</if>
|
||||
<if test="applicationName != null and applicationName != ''">application_name = #{applicationName},</if>
|
||||
</trim>
|
||||
where scene_id = #{sceneId}
|
||||
</update>
|
||||
|
||||
<delete id="deleteSceneBySceneId" parameterType="Long">
|
||||
delete from iot_scene where scene_id = #{sceneId}
|
||||
</delete>
|
||||
|
||||
<delete id="deleteSceneBySceneIds" parameterType="String">
|
||||
delete from iot_scene where scene_id in
|
||||
<foreach item="sceneId" collection="array" open="(" separator="," close=")">
|
||||
#{sceneId}
|
||||
</foreach>
|
||||
</delete>
|
||||
</mapper>
|
@ -0,0 +1,256 @@
|
||||
<?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.SceneModelDataMapper">
|
||||
|
||||
<resultMap type="SceneModelData" id="SceneModelDataResult">
|
||||
<result property="id" column="id" />
|
||||
<result property="sceneModelId" column="scene_model_id" />
|
||||
<result property="sceneModelDeviceId" column="scene_model_device_id" />
|
||||
<result property="variableType" column="variable_type" />
|
||||
<result property="datasourceId" column="datasource_id" />
|
||||
<result property="enable" column="enable" />
|
||||
<result property="sourceName" column="source_name"/>
|
||||
<result property="identifier" column="identifier"/>
|
||||
<result property="sceneModelDeviceId" column="scene_model_device_id"/>
|
||||
<result property="sceneModelDeviceName" column="scene_model_device_name"/>
|
||||
<result property="type" column="type"/>
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectSceneModelDataVo">
|
||||
select id, scene_model_id, scene_model_device_id, variable_type, datasource_id, enable, source_name, identifier, type from scene_model_data
|
||||
</sql>
|
||||
|
||||
<select id="selectSceneModelDataList" parameterType="SceneModelData" resultMap="SceneModelDataResult">
|
||||
<include refid="selectSceneModelDataVo"/>
|
||||
where scene_model_id = #{sceneModelId}
|
||||
and del_flag = 0
|
||||
<if test="variableType != null"> and variable_type = #{variableType}</if>
|
||||
<if test="sceneModelDeviceId != null "> and scene_model_device_id = #{sceneModelDeviceId}</if>
|
||||
<if test="sourceName != null and sourceName != ''"> and source_name like concat('%', #{sourceName}, '%')</if>
|
||||
<if test="enable != null "> and enable = #{enable}</if>
|
||||
</select>
|
||||
|
||||
<select id="selectSceneModelDataDTOList" resultType="com.fastbee.iot.model.scenemodel.SceneModelDataDTO">
|
||||
select sd.id, sd.scene_model_id, sd.scene_model_device_id, sd.variable_type, sd.datasource_id, sd.enable, sd.source_name, sd.identifier, sd.type,
|
||||
s.id as scene_model_device_id, s.name as scene_model_device_name, d.serial_number, d.product_id, d.is_shadow, d.status, d.device_id
|
||||
from scene_model_device s
|
||||
left join iot_device d on s.cus_device_id = d.device_id
|
||||
left join scene_model_data sd on s.id = sd.scene_model_device_id
|
||||
where s.scene_model_id = #{sceneModelId}
|
||||
and sd.scene_model_id = #{sceneModelId}
|
||||
and sd.del_flag = 0
|
||||
and s.del_flag = 0
|
||||
<if test="variableType != null"> and sd.variable_type = #{variableType}</if>
|
||||
<if test="sceneModelDeviceId != null "> and sd.scene_model_device_id = #{sceneModelDeviceId}</if>
|
||||
<if test="sourceName != null and sourceName != ''"> and sd.source_name like concat('%', #{sourceName}, '%')</if>
|
||||
<if test="enable != null "> and sd.enable = #{enable}</if>
|
||||
</select>
|
||||
|
||||
<select id="selectSceneModelDataById" parameterType="Long" resultMap="SceneModelDataResult">
|
||||
<include refid="selectSceneModelDataVo"/>
|
||||
where id = #{id}
|
||||
and del_flag = 0
|
||||
</select>
|
||||
|
||||
<select id="listBySourceIdAndType" resultType="com.fastbee.iot.domain.SceneModelData">
|
||||
select distinct(scene_model_id), scene_model_device_id
|
||||
from scene_model_data
|
||||
where datasource_id = #{datasourceId}
|
||||
and variable_type = 1
|
||||
and del_flag = 0
|
||||
</select>
|
||||
|
||||
<select id="countNoEnableBySceneModelDeviceId" resultType="java.lang.Integer">
|
||||
select count(id)
|
||||
from scene_model_data
|
||||
where del_flag = 0
|
||||
and scene_model_device_id = #{sceneModelDeviceId}
|
||||
and enable = 0
|
||||
</select>
|
||||
|
||||
<select id="countSceneModelDataList" resultType="java.lang.Integer">
|
||||
select count(sd.id)
|
||||
from scene_model_device s join scene_model_data sd on s.id = sd.scene_model_device_id
|
||||
where s.scene_model_id = #{sceneModelId}
|
||||
and sd.scene_model_id = #{sceneModelId}
|
||||
and sd.del_flag = 0
|
||||
and s.del_flag = 0
|
||||
<if test="variableType != null"> and sd.variable_type = #{variableType}</if>
|
||||
<if test="sceneModelDeviceId != null "> and sd.scene_model_device_id = #{sceneModelDeviceId}</if>
|
||||
<if test="sourceName != null and sourceName != ''"> and sd.source_name like concat('%', #{sourceName}, '%')</if>
|
||||
<if test="enable != null "> and sd.enable = #{enable}</if>
|
||||
</select>
|
||||
|
||||
<select id="selectNoDeviceBySourceIdAndVariableType" resultType="com.fastbee.iot.domain.SceneModelData">
|
||||
<include refid="selectSceneModelDataVo"/>
|
||||
where datasource_id = #{datasourceId}
|
||||
and variable_type = #{variableType}
|
||||
and del_flag = 0
|
||||
</select>
|
||||
|
||||
<select id="selectSceneModelDeviceByDataIdList"
|
||||
resultType="com.fastbee.iot.model.scenemodel.SceneModelDeviceVO">
|
||||
select s.id as scene_model_data_id, s.scene_model_device_id, sd.name as scene_model_device_name
|
||||
from scene_model_data s join scene_model_device sd on s.scene_model_device_id = sd.id
|
||||
where s.id in
|
||||
<foreach collection="idList" item="id" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
and sd.del_flag = 0
|
||||
</select>
|
||||
<select id="selectDeviceThingsModelById"
|
||||
resultType="com.fastbee.iot.model.scenemodel.SceneDeviceThingsModelVO">
|
||||
select s.identifier, d.serial_number, d.product_id
|
||||
from scene_model_data s left join scene_model_device sd on s.scene_model_device_id = sd.id
|
||||
left join iot_device d on sd.cus_device_id = d.device_id
|
||||
where s.id = #{id}
|
||||
</select>
|
||||
|
||||
<select id="selectInputTagDefaultValueById" resultType="java.lang.String">
|
||||
select st.default_value
|
||||
from scene_model_data s left join scene_model_tag st on s.datasource_id = st.id
|
||||
where s.id = #{id}
|
||||
</select>
|
||||
|
||||
<select id="checkIsApplyAliasFormule" resultType="java.lang.Integer">
|
||||
select count(st.id)
|
||||
from scene_model_data smd join scene_tag_points st on smd.id = st.scene_model_data_id
|
||||
where smd.del_flag = 0
|
||||
and st.del_flag = 0
|
||||
and smd.datasource_id = #{datasourceId}
|
||||
<if test="variableType != null">
|
||||
and smd.variable_type = #{variableType}
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<select id="selectSceneModelDataListByIds" resultType="com.fastbee.iot.domain.SceneModelData">
|
||||
<include refid="selectSceneModelDataVo"/>
|
||||
where id in
|
||||
<foreach item="id" collection="ids" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
and del_flag = 0
|
||||
</select>
|
||||
|
||||
<select id="selectSceneDeviceThingsModelList" resultType="com.fastbee.iot.domain.SceneModelData">
|
||||
select distinct scene_model_id, scene_model_device_id
|
||||
from scene_model_data
|
||||
where variable_type = 1
|
||||
and datasource_id = #{datasourceId}
|
||||
and del_flag = 0
|
||||
</select>
|
||||
|
||||
<insert id="insertSceneModelData" parameterType="SceneModelData">
|
||||
insert into scene_model_data
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="id != null">id,</if>
|
||||
<if test="sceneModelId != null">scene_model_id,</if>
|
||||
<if test="sceneModelDeviceId != null">scene_model_device_id,</if>
|
||||
<if test="variableType != null">variable_type,</if>
|
||||
<if test="datasourceId != null">datasource_id,</if>
|
||||
<if test="enable != null">enable,</if>
|
||||
<if test="sourceName != null and sourceName != ''">source_name,</if>
|
||||
<if test="identifier != null and identifier != ''">identifier,</if>
|
||||
<if test="type != null">type,</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="id != null">#{id},</if>
|
||||
<if test="sceneModelId != null">#{sceneModelId},</if>
|
||||
<if test="sceneModelDeviceId != null">#{sceneModelDeviceId},</if>
|
||||
<if test="variableType != null">#{variableType},</if>
|
||||
<if test="datasourceId != null">#{datasourceId},</if>
|
||||
<if test="enable != null">#{enable},</if>
|
||||
<if test="sourceName != null and sourceName != ''">#{sourceName},</if>
|
||||
<if test="identifier != null and identifier != ''">#{identifier},</if>
|
||||
<if test="type != null">#{type},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
<insert id="insertBatchSceneModelData">
|
||||
insert into scene_model_data
|
||||
(scene_model_id, scene_model_device_id, variable_type, datasource_id, source_name, identifier, type)
|
||||
values
|
||||
<foreach collection="sceneModelDataList" item="sceneModelData" separator=",">
|
||||
(#{sceneModelData.sceneModelId},
|
||||
#{sceneModelData.sceneModelDeviceId},
|
||||
#{sceneModelData.variableType},
|
||||
#{sceneModelData.datasourceId},
|
||||
#{sceneModelData.sourceName},
|
||||
#{sceneModelData.identifier},
|
||||
#{sceneModelData.type})
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
<update id="updateSceneModelData" parameterType="SceneModelData">
|
||||
update scene_model_data
|
||||
<trim prefix="SET" suffixOverrides=",">
|
||||
<if test="sceneModelId != null">scene_model_id = #{sceneModelId},</if>
|
||||
<if test="sceneModelDeviceId != null">scene_model_device_id = #{sceneModelDeviceId},</if>
|
||||
<if test="variableType != null">variable_type = #{variableType},</if>
|
||||
<if test="datasourceId != null">datasource_id = #{datasourceId},</if>
|
||||
<if test="enable != null">enable = #{enable},</if>
|
||||
<if test="sourceName != null and sourceName != ''"> source_name = #{sourceName},</if>
|
||||
<if test="identifier != null and identifier != ''"> identifier = #{identifier},</if>
|
||||
<if test="type != null">type = #{type},</if>
|
||||
</trim>
|
||||
where id = #{id}
|
||||
</update>
|
||||
|
||||
<delete id="deleteSceneModelDataById" parameterType="Long">
|
||||
delete from scene_model_data where id = #{id}
|
||||
</delete>
|
||||
|
||||
<delete id="deleteSceneModelDataByIds" parameterType="String">
|
||||
delete from scene_model_data where id in
|
||||
<foreach item="id" collection="array" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</delete>
|
||||
|
||||
<delete id="deleteThingsModelByDatasourceId">
|
||||
update scene_model_data
|
||||
set del_flag = 1
|
||||
where datasource_id in
|
||||
<foreach item="datasourceId" collection="array" open="(" separator="," close=")">
|
||||
#{datasourceId}
|
||||
</foreach>
|
||||
and variable_type = 1
|
||||
</delete>
|
||||
|
||||
<update id="deleteBySourceIds">
|
||||
update scene_model_data
|
||||
set del_flag = 1
|
||||
where datasource_id in
|
||||
<foreach item="datasourceId" collection="array" open="(" separator="," close=")">
|
||||
#{datasourceId}
|
||||
</foreach>
|
||||
</update>
|
||||
|
||||
<update id="deleteBySceneModelIds">
|
||||
update scene_model_data
|
||||
set del_flag = 1
|
||||
where scene_model_id in
|
||||
<foreach item="sceneModelId" collection="array" open="(" separator="," close=")">
|
||||
#{sceneModelId}
|
||||
</foreach>
|
||||
</update>
|
||||
|
||||
<update id="editAllEnable">
|
||||
update scene_model_data
|
||||
set enable = #{enable}
|
||||
where scene_model_id = #{sceneModelId}
|
||||
and variable_type = #{variableType}
|
||||
<if test="sceneModelDeviceId != null "> and scene_model_device_id = #{sceneModelDeviceId}</if>
|
||||
</update>
|
||||
|
||||
<update id="deleteBySceneModelDeviceIds">
|
||||
update scene_model_data
|
||||
set del_flag = 1
|
||||
where scene_model_device_id in
|
||||
<foreach item="sceneModelDeviceId" collection="array" open="(" separator="," close=")">
|
||||
#{sceneModelDeviceId}
|
||||
</foreach>
|
||||
</update>
|
||||
</mapper>
|
@ -0,0 +1,164 @@
|
||||
<?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.SceneModelDeviceMapper">
|
||||
|
||||
<resultMap type="SceneModelDevice" id="SceneModelDeviceResult">
|
||||
<result property="id" column="id" />
|
||||
<result property="sceneModelId" column="scene_model_id" />
|
||||
<result property="cusDeviceId" column="cus_device_id" />
|
||||
<result property="sort" column="sort" />
|
||||
<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" />
|
||||
<result property="variableType" column="variable_type" />
|
||||
<result property="allEnable" column="all_enable" />
|
||||
<result property="name" column="name" />
|
||||
<result property="productId" column="product_id" />
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectSceneModelDeviceVo">
|
||||
select id, scene_model_id, cus_device_id, sort, del_flag, create_by, create_time, update_by, update_time, remark, variable_type, all_enable, name from scene_model_device
|
||||
</sql>
|
||||
|
||||
<select id="selectSceneModelDeviceList" parameterType="SceneModelDevice" resultMap="SceneModelDeviceResult">
|
||||
select smd.id, smd.scene_model_id, smd.cus_device_id, smd.sort, smd.del_flag,
|
||||
smd.create_by, smd.create_time, smd.update_by, smd.update_time, smd.remark, smd.variable_type, smd.all_enable, smd.name,
|
||||
d.product_id, d.serial_number
|
||||
from scene_model_device smd left join iot_device d on smd.cus_device_id = d.device_id
|
||||
<where>
|
||||
<if test="sceneModelId != null "> and smd.scene_model_id = #{sceneModelId}</if>
|
||||
<if test="cusDeviceId != null "> and smd.cus_device_id = #{cusDeviceId}</if>
|
||||
<if test="sort != null "> and smd.sort = #{sort}</if>
|
||||
<if test="allEnable != null "> and smd.all_enable = #{allEnable}</if>
|
||||
<if test="name != null and name != ''"> and smd.name like concat('%', #{name}, '%')</if>
|
||||
<if test="variableType != null "> and smd.variable_type = #{variableType}</if>
|
||||
</where>
|
||||
and smd.del_flag = 0
|
||||
order by smd.sort asc, smd.cus_device_id desc, smd.id desc
|
||||
</select>
|
||||
|
||||
<select id="selectSceneModelDeviceById" parameterType="Long" resultMap="SceneModelDeviceResult">
|
||||
<include refid="selectSceneModelDeviceVo"/>
|
||||
where id = #{id}
|
||||
and del_flag = 0
|
||||
</select>
|
||||
|
||||
<select id="selectOneModelDevice" resultType="com.fastbee.iot.domain.SceneModelDevice">
|
||||
<include refid="selectSceneModelDeviceVo"/>
|
||||
where del_flag = 0
|
||||
and variable_type = 1
|
||||
and isnull(cus_device_id)
|
||||
and scene_model_id = #{sceneModelId}
|
||||
</select>
|
||||
|
||||
<select id="selectOneNoDeviceBySceneModelId" resultType="com.fastbee.iot.domain.SceneModelDevice">
|
||||
<include refid="selectSceneModelDeviceVo"/>
|
||||
where scene_model_id = #{sceneModelId}
|
||||
and variable_type = #{variableType}
|
||||
and del_flag = 0
|
||||
</select>
|
||||
|
||||
<select id="checkContainAliasFormule" resultType="java.lang.Integer">
|
||||
select count(st.id)
|
||||
from scene_model_device s join scene_model_data smd on s.id = smd.scene_model_device_id
|
||||
join scene_tag_points st on smd.id = st.scene_model_data_id
|
||||
where s.id = #{id}
|
||||
and s.del_flag = 0
|
||||
and smd.del_flag = 0
|
||||
and st.del_flag = 0
|
||||
</select>
|
||||
|
||||
<select id="listDeviceByProductId" resultType="com.fastbee.iot.domain.SceneModelDevice">
|
||||
select sd.id, sd.`name`, sd.cus_device_id, sd.scene_model_id
|
||||
from iot_device d join scene_model_device sd on d.device_id = sd.cus_device_id
|
||||
where d.del_flag = 0
|
||||
and sd.del_flag = 0
|
||||
and d.product_id = #{productId}
|
||||
</select>
|
||||
|
||||
<insert id="insertSceneModelDevice" parameterType="SceneModelDevice" useGeneratedKeys="true" keyProperty="id">
|
||||
insert into scene_model_device
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="sceneModelId != null">scene_model_id,</if>
|
||||
<if test="cusDeviceId != null">cus_device_id,</if>
|
||||
<if test="sort != null">sort,</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="variableType != null">variable_type,</if>
|
||||
<if test="allEnable != null">all_enable,</if>
|
||||
<if test="name != null">name,</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="sceneModelId != null">#{sceneModelId},</if>
|
||||
<if test="cusDeviceId != null">#{cusDeviceId},</if>
|
||||
<if test="sort != null">#{sort},</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="variableType != null">#{variableType},</if>
|
||||
<if test="allEnable != null">#{allEnable},</if>
|
||||
<if test="name != null">#{name},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
<update id="updateSceneModelDevice" parameterType="SceneModelDevice">
|
||||
update scene_model_device
|
||||
<trim prefix="SET" suffixOverrides=",">
|
||||
<if test="sceneModelId != null">scene_model_id = #{sceneModelId},</if>
|
||||
<if test="cusDeviceId != null">cus_device_id = #{cusDeviceId},</if>
|
||||
<if test="sort != null">sort = #{sort},</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="variableType != null">variable_type = #{variableType},</if>
|
||||
<if test="allEnable != null">all_enable = #{allEnable},</if>
|
||||
<if test="name != null">name = #{name},</if>
|
||||
</trim>
|
||||
where id = #{id}
|
||||
</update>
|
||||
|
||||
<delete id="deleteSceneModelDeviceById" parameterType="Long">
|
||||
delete from scene_model_device where id = #{id}
|
||||
</delete>
|
||||
|
||||
<update id="deleteSceneModelDeviceByIds" parameterType="String">
|
||||
update scene_model_device
|
||||
set del_flag = 1
|
||||
where id in
|
||||
<foreach item="id" collection="array" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</update>
|
||||
|
||||
<update id="deleteBySceneModelIds">
|
||||
update scene_model_device
|
||||
set del_flag = 1
|
||||
where scene_model_id in
|
||||
<foreach item="sceneModelId" collection="array" open="(" separator="," close=")">
|
||||
#{sceneModelId}
|
||||
</foreach>
|
||||
</update>
|
||||
|
||||
<update id="updateAllEnable">
|
||||
update scene_model_device
|
||||
set all_enable = #{allEnable}
|
||||
where scene_model_id = #{sceneModelId}
|
||||
and variable_type = #{variableType}
|
||||
<if test="id != null "> and id = #{id}</if>
|
||||
</update>
|
||||
</mapper>
|
@ -0,0 +1,136 @@
|
||||
<?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.SceneModelMapper">
|
||||
|
||||
<resultMap type="com.fastbee.iot.domain.SceneModel" id="SceneModelResult">
|
||||
<result property="sceneModelId" column="scene_model_id" />
|
||||
<result property="tenantId" column="tenant_id" />
|
||||
<result property="sceneModelName" column="scene_model_name" />
|
||||
<result property="status" column="status" />
|
||||
<result property="guid" column="guid" />
|
||||
<result property="desc" column="desc" />
|
||||
<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" />
|
||||
<result property="imgUrl" column="img_url"/>
|
||||
<result property="deptId" column="dept_id"/>
|
||||
<result property="deptName" column="dept_name"/>
|
||||
<result property="deviceTotal" column="device_total"/>
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectSceneModelVo">
|
||||
select scene_model_id, tenant_id, scene_model_name, status, guid, `desc`, del_flag, create_by, create_time, update_by, update_time, remark, img_url from scene_model
|
||||
</sql>
|
||||
|
||||
<select id="selectSceneModelList" parameterType="SceneModel" resultMap="SceneModelResult">
|
||||
select sm.scene_model_id, sm.tenant_id, sm.scene_model_name, sm.status, sm.guid, sm.desc, sm.del_flag, sm.create_by, sm.create_time, sm.update_by, sm.update_time, sm.remark, sm.img_url,
|
||||
d.dept_id, d.dept_name,
|
||||
(select count(smd.cus_device_id) from scene_model_device smd where sm.scene_model_id = smd.scene_model_id and smd.variable_type = 1 and smd.del_flag = 0) as device_total
|
||||
from scene_model sm left join sys_dept d on sm.tenant_id = d.dept_user_id
|
||||
<where>
|
||||
<if test="tenantId != null "> and sm.tenant_id = #{tenantId}</if>
|
||||
<if test="sceneModelName != null and sceneModelName != ''"> and sm.scene_model_name like concat('%', #{sceneModelName}, '%')</if>
|
||||
<if test="status != null "> and sm.status = #{status}</if>
|
||||
<if test="guid != null and guid != ''"> and sm.guid = #{guid}</if>
|
||||
<if test="desc != null and desc != ''"> and sm.desc = #{desc}</if>
|
||||
</where>
|
||||
and sm.del_flag = 0
|
||||
order by sm.scene_model_id desc
|
||||
</select>
|
||||
|
||||
<select id="selectSceneModelBySceneModelId" parameterType="Long" resultMap="SceneModelResult">
|
||||
select sm.scene_model_id, sm.tenant_id, sm.scene_model_name, sm.status, sm.guid, sm.desc, sm.del_flag, sm.create_by, sm.create_time, sm.update_by, sm.update_time, sm.remark, sm.img_url,
|
||||
d.dept_id, d.dept_name
|
||||
from scene_model sm left join sys_dept d on sm.tenant_id = d.dept_user_id
|
||||
where sm.scene_model_id = #{sceneModelId}
|
||||
and sm.del_flag = 0
|
||||
</select>
|
||||
|
||||
<insert id="insertSceneModel" parameterType="com.fastbee.iot.domain.SceneModel" useGeneratedKeys="true" keyProperty="sceneModelId">
|
||||
insert into scene_model
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="tenantId != null">tenant_id,</if>
|
||||
<if test="sceneModelName != null and sceneModelName != ''">scene_model_name,</if>
|
||||
<if test="status != null">status,</if>
|
||||
<if test="guid != null">guid,</if>
|
||||
<if test="desc != null">`desc`,</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>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="tenantId != null">#{tenantId},</if>
|
||||
<if test="sceneModelName != null and sceneModelName != ''">#{sceneModelName},</if>
|
||||
<if test="status != null">#{status},</if>
|
||||
<if test="guid != null">#{guid},</if>
|
||||
<if test="desc != null">#{desc},</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>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
<update id="updateSceneModel" parameterType="SceneModel">
|
||||
update scene_model
|
||||
<trim prefix="SET" suffixOverrides=",">
|
||||
<if test="tenantId != null">tenant_id = #{tenantId},</if>
|
||||
<if test="sceneModelName != null and sceneModelName != ''">scene_model_name = #{sceneModelName},</if>
|
||||
<if test="status != null">status = #{status},</if>
|
||||
<if test="guid != null">guid = #{guid},</if>
|
||||
<if test="desc != null">`desc` = #{desc},</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>
|
||||
</trim>
|
||||
where scene_model_id = #{sceneModelId}
|
||||
</update>
|
||||
|
||||
<delete id="deleteSceneModelBySceneModelId" parameterType="Long">
|
||||
delete from scene_model where scene_model_id = #{sceneModelId}
|
||||
</delete>
|
||||
|
||||
<update id="deleteSceneModelBySceneModelIds" parameterType="String">
|
||||
update scene_model
|
||||
set del_flag = 1
|
||||
where scene_model_id in
|
||||
<foreach item="sceneModelId" collection="array" open="(" separator="," close=")">
|
||||
#{sceneModelId}
|
||||
</foreach>
|
||||
</update>
|
||||
|
||||
<select id="selectSceneModelByChannelId" resultMap="SceneModelResult">
|
||||
<include refid="selectSceneModelVo" />
|
||||
where channel_id = #{channelId}
|
||||
</select>
|
||||
|
||||
<select id="selectListScadaIdByGuidS" resultType="com.fastbee.iot.domain.SceneModel">
|
||||
select id scadaId, guid
|
||||
from scada
|
||||
where guid in
|
||||
<foreach collection="guidList" item="guid" open="(" separator="," close=")">
|
||||
#{guid}
|
||||
</foreach>
|
||||
</select>
|
||||
|
||||
<select id="selectBySceneModelId" resultType="com.fastbee.iot.domain.SceneModel">
|
||||
<include refid="selectSceneModelVo" />
|
||||
where scene_model_id = #{sceneModelId}
|
||||
</select>
|
||||
</mapper>
|
@ -0,0 +1,177 @@
|
||||
<?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.SceneModelTagMapper">
|
||||
|
||||
<resultMap type="SceneModelTag" id="SceneModelTagResult">
|
||||
<result property="id" column="id" />
|
||||
<result property="sceneModelId" column="scene_model_id" />
|
||||
<result property="name" column="name" />
|
||||
<result property="unit" column="unit" />
|
||||
<result property="dataType" column="data_type" />
|
||||
<result property="defaultValue" column="default_value" />
|
||||
<result property="isReadonly" column="is_readonly" />
|
||||
<result property="storage" column="storage" />
|
||||
<result property="variableType" column="variable_type" />
|
||||
<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" />
|
||||
<result property="cycleExecuted" column="cycle_executed" />
|
||||
<result property="formule" column="formule" />
|
||||
<result property="aliasFormule" column="alias_formule" />
|
||||
<result property="cycleType" column="cycle_type" />
|
||||
<result property="cycle" column="cycle" />
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectSceneModelTagVo">
|
||||
select id, scene_model_id, name, unit, data_type, default_value, is_readonly, storage, variable_type, del_flag, create_by, create_time, update_by, update_time, remark, cycle_executed, formule, alias_formule, cycle_type, cycle from scene_model_tag
|
||||
</sql>
|
||||
|
||||
<select id="selectSceneModelTagList" parameterType="SceneModelTag" resultMap="SceneModelTagResult">
|
||||
<include refid="selectSceneModelTagVo"/>
|
||||
<where>
|
||||
<if test="sceneModelId != null "> and scene_model_id = #{sceneModelId}</if>
|
||||
<if test="name != null and name != ''"> and name like concat('%', #{name}, '%')</if>
|
||||
<if test="unit != null and unit != ''"> and unit = #{unit}</if>
|
||||
<if test="dataType != null and dataType != ''"> and data_type = #{dataType}</if>
|
||||
<if test="defaultValue != null and defaultValue != ''"> and default_value = #{defaultValue}</if>
|
||||
<if test="isReadonly != null "> and is_readonly = #{isReadonly}</if>
|
||||
<if test="storage != null "> and storage = #{storage}</if>
|
||||
<if test="variableType != null "> and variable_type = #{variableType}</if>
|
||||
<if test="cycleExecuted != null "> and cycle_executed = #{cycleExecuted}</if>
|
||||
<if test="formule != null and formule != ''"> and formule = #{formule}</if>
|
||||
<if test="aliasFormule != null and aliasFormule != ''"> and alias_formule = #{aliasFormule}</if>
|
||||
<if test="cycleType != null "> and cycle_type = #{cycleType}</if>
|
||||
<if test="cycle != null and cycle != ''"> and cycle = #{cycle}</if>
|
||||
</where>
|
||||
and del_flag = 0
|
||||
</select>
|
||||
|
||||
<select id="selectSceneModelTagById" parameterType="Long" resultMap="SceneModelTagResult">
|
||||
select smt.id, smt.scene_model_id, smt.name, smt.unit, smt.data_type, smt.default_value, smt.is_readonly, smt.storage, smt.variable_type, smt.del_flag,
|
||||
smt.create_by, smt.create_time, smt.update_by, smt.update_time, smt.remark, smt.cycle_executed, smt.formule, smt.alias_formule, smt.cycle_type, smt.cycle,
|
||||
smd.id scene_model_device_id, d.enable
|
||||
from scene_model_tag smt left join scene_model_device smd on smt.scene_model_id = smd.scene_model_id and smt.variable_type = smd.variable_type
|
||||
left join scene_model_data d on smt.scene_model_id = d.scene_model_id and smt.id = d.datasource_id
|
||||
where smt.id = #{id}
|
||||
and smt.del_flag = 0
|
||||
</select>
|
||||
|
||||
<select id="listSceneModelDataByIds" resultType="com.fastbee.iot.domain.SceneModelTag">
|
||||
select id, name, unit, data_type, default_value, is_readonly, storage
|
||||
from scene_model_tag
|
||||
where id in
|
||||
<foreach collection="idList" item="id" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
and del_flag = 0
|
||||
</select>
|
||||
|
||||
<select id="checkName" resultType="com.fastbee.iot.domain.SceneModelTag">
|
||||
<include refid="selectSceneModelTagVo"/>
|
||||
where name = #{name}
|
||||
and variable_type = #{variableType}
|
||||
and del_flag = 0
|
||||
<if test="id != null">
|
||||
and id != #{id}
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<insert id="insertSceneModelTag" parameterType="SceneModelTag" useGeneratedKeys="true" keyProperty="id">
|
||||
insert into scene_model_tag
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="sceneModelId != null">scene_model_id,</if>
|
||||
<if test="name != null and name != ''">name,</if>
|
||||
<if test="unit != null">unit,</if>
|
||||
<if test="dataType != null and dataType != ''">data_type,</if>
|
||||
<if test="defaultValue != null">default_value,</if>
|
||||
<if test="isReadonly != null">is_readonly,</if>
|
||||
<if test="storage != null">storage,</if>
|
||||
<if test="variableType != null">variable_type,</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="cycleExecuted != null">cycle_executed,</if>
|
||||
<if test="formule != null">formule,</if>
|
||||
<if test="aliasFormule != null">alias_formule,</if>
|
||||
<if test="cycleType != null">cycle_type,</if>
|
||||
<if test="cycle != null and cycle != ''">cycle,</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="sceneModelId != null">#{sceneModelId},</if>
|
||||
<if test="name != null and name != ''">#{name},</if>
|
||||
<if test="unit != null">#{unit},</if>
|
||||
<if test="dataType != null and dataType != ''">#{dataType},</if>
|
||||
<if test="defaultValue != null">#{defaultValue},</if>
|
||||
<if test="isReadonly != null">#{isReadonly},</if>
|
||||
<if test="storage != null">#{storage},</if>
|
||||
<if test="variableType != null">#{variableType},</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="cycleExecuted != null">#{cycleExecuted},</if>
|
||||
<if test="formule != null">#{formule},</if>
|
||||
<if test="aliasFormule != null">#{aliasFormule},</if>
|
||||
<if test="cycleType != null">#{cycleType},</if>
|
||||
<if test="cycle != null and cycle != ''">#{cycle},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
<update id="updateSceneModelTag" parameterType="SceneModelTag">
|
||||
update scene_model_tag
|
||||
<trim prefix="SET" suffixOverrides=",">
|
||||
<if test="sceneModelId != null">scene_model_id = #{sceneModelId},</if>
|
||||
<if test="name != null and name != ''">name = #{name},</if>
|
||||
<if test="unit != null">unit = #{unit},</if>
|
||||
<if test="dataType != null and dataType != ''">data_type = #{dataType},</if>
|
||||
<if test="defaultValue != null">default_value = #{defaultValue},</if>
|
||||
<if test="isReadonly != null">is_readonly = #{isReadonly},</if>
|
||||
<if test="storage != null">storage = #{storage},</if>
|
||||
<if test="variableType != null">variable_type = #{variableType},</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="cycleExecuted != null">cycle_executed = #{cycleExecuted},</if>
|
||||
<if test="formule != null">formule = #{formule},</if>
|
||||
<if test="aliasFormule != null">alias_formule = #{aliasFormule},</if>
|
||||
<if test="cycleType != null">cycle_type = #{cycleType},</if>
|
||||
<if test="cycle != null and cycle != ''">cycle = #{cycle},</if>
|
||||
</trim>
|
||||
where id = #{id}
|
||||
</update>
|
||||
|
||||
<delete id="deleteSceneModelTagById" parameterType="Long">
|
||||
delete from scene_model_tag where id = #{id}
|
||||
</delete>
|
||||
|
||||
<update id="deleteSceneModelTagByIds" parameterType="String">
|
||||
update scene_model_tag
|
||||
set del_flag = 1
|
||||
where id in
|
||||
<foreach item="id" collection="array" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</update>
|
||||
|
||||
<update id="deleteBySceneModelIds">
|
||||
update scene_model_tag
|
||||
set del_flag = 1
|
||||
where scene_model_id in
|
||||
<foreach item="sceneModelId" collection="array" open="(" separator="," close=")">
|
||||
#{sceneModelId}
|
||||
</foreach>
|
||||
</update>
|
||||
</mapper>
|
@ -0,0 +1,223 @@
|
||||
<?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.SceneScriptMapper">
|
||||
|
||||
<resultMap type="SceneScript" id="SceneScriptResult">
|
||||
<result property="scriptId" column="script_id"/>
|
||||
<result property="sceneId" column="scene_id"/>
|
||||
<result property="productId" column="product_id"/>
|
||||
<result property="productName" column="product_name"/>
|
||||
<result property="source" column="source"/>
|
||||
<result property="scriptPurpose" column="script_purpose"/>
|
||||
<result property="id" column="id"/>
|
||||
<result property="name" column="name"/>
|
||||
<result property="value" column="value"/>
|
||||
<result property="operator" column="operator"/>
|
||||
<result property="type" column="type"/>
|
||||
<result property="deviceCount" column="device_count"/>
|
||||
<result property="jobId" column="job_id"/>
|
||||
<result property="cronExpression" column="cron_expression"/>
|
||||
<result property="isAdvance" column="is_advance"/>
|
||||
<result property="parentId" column="parent_id"/>
|
||||
<result property="parentName" column="parent_name"/>
|
||||
<result property="arrayIndex" column="array_index"/>
|
||||
<result property="arrayIndexName" column="array_index_name"/>
|
||||
<result property="createBy" column="create_by"/>
|
||||
<result property="createTime" column="create_time"/>
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectSceneScriptVo">
|
||||
select script_id,
|
||||
scene_id,
|
||||
product_id,
|
||||
product_name,
|
||||
source,
|
||||
script_purpose,
|
||||
id,
|
||||
name,
|
||||
value,
|
||||
operator,
|
||||
type,
|
||||
device_count,
|
||||
job_id,
|
||||
cron_expression,
|
||||
is_advance,
|
||||
parent_id,
|
||||
parent_name,
|
||||
array_index,
|
||||
array_index_name,
|
||||
create_by,
|
||||
create_time
|
||||
from iot_scene_script
|
||||
</sql>
|
||||
|
||||
<select id="selectSceneScriptList" parameterType="SceneScript" resultMap="SceneScriptResult">
|
||||
<include refid="selectSceneScriptVo"/>
|
||||
<where>
|
||||
<if test="scriptId != null ">and script_id = #{scriptId}</if>
|
||||
<if test="sceneId != null ">and scene_id = #{sceneId}</if>
|
||||
<if test="productId != null ">and product_id = #{productId}</if>
|
||||
<if test="productName != null ">and product_name = #{productName}</if>
|
||||
<if test="source != null ">and source = #{source}</if>
|
||||
<if test="scriptPurpose != null ">and script_purpose = #{scriptPurpose}</if>
|
||||
<if test="id != null ">and id = #{id}</if>
|
||||
<if test="name != null and name != ''">and name like concat('%', #{name}, '%')</if>
|
||||
<if test="value != null and value != ''">and value = #{value}</if>
|
||||
<if test="operator != null and operator != ''">and operator = #{operator}</if>
|
||||
<if test="type != null ">and type = #{type}</if>
|
||||
<if test="jobId != null ">and job_id = #{jobId}</if>
|
||||
<if test="cronExpression != null and cronExpression != ''">and cron_expression = #{cronExpression}</if>
|
||||
<if test="isAdvance != null ">and is_advance = #{isAdvance}</if>
|
||||
<if test="parentId != null and parentId != ''">and parent_id = #{parentId}</if>
|
||||
<if test="parentName != null and parentName != ''">and parent_name like concat('%', #{parentName}, '%')
|
||||
</if>
|
||||
<if test="arrayIndex != null and arrayIndex != ''">and array_index = #{arrayIndex}</if>
|
||||
<if test="arrayIndexName != null and arrayIndexName != ''">and array_index_name like concat('%',
|
||||
#{arrayIndexName}, '%')
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<select id="selectSceneScriptBySceneScriptId" parameterType="String" resultMap="SceneScriptResult">
|
||||
<include refid="selectSceneScriptVo"/>
|
||||
where script_id = #{scriptId}
|
||||
</select>
|
||||
|
||||
<select id="listSceneScriptByPurpose" resultMap="SceneScriptResult">
|
||||
<include refid="selectSceneScriptVo"/>
|
||||
where scene_id in
|
||||
<foreach collection="sceneIdList" item="sceneId" open="(" separator="," close=")">
|
||||
#{sceneId}
|
||||
</foreach>
|
||||
and script_purpose = #{scriptPurpose}
|
||||
</select>
|
||||
|
||||
<insert id="insertSceneScript" parameterType="SceneScript" useGeneratedKeys="false">
|
||||
insert into iot_scene_script
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="scriptId != null">script_id,</if>
|
||||
<if test="sceneId != null">scene_id,</if>
|
||||
<if test="productId != null">product_id,</if>
|
||||
<if test="productName != null">product_name,</if>
|
||||
<if test="source != null">source,</if>
|
||||
<if test="scriptPurpose != null">script_purpose,</if>
|
||||
<if test="id != null">id,</if>
|
||||
<if test="name != null">name,</if>
|
||||
<if test="value != null">value,</if>
|
||||
<if test="operator != null">operator,</if>
|
||||
<if test="type != null">type,</if>
|
||||
<if test="deviceCount != null">device_count,</if>
|
||||
<if test="jobId != null">job_id,</if>
|
||||
<if test="cronExpression != null">cron_expression,</if>
|
||||
<if test="isAdvance != null">is_advance,</if>
|
||||
<if test="parentId != null">parent_id,</if>
|
||||
<if test="parentName != null">parent_name,</if>
|
||||
<if test="arrayIndex != null">array_index,</if>
|
||||
<if test="arrayIndexName != null">array_index_name,</if>
|
||||
<if test="createBy != null">create_by,</if>
|
||||
<if test="createTime != null">create_time,</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="scriptId != null">#{scriptId},</if>
|
||||
<if test="sceneId != null">#{sceneId},</if>
|
||||
<if test="productId != null">#{productId},</if>
|
||||
<if test="productName != null">#{productName},</if>
|
||||
<if test="source != null">#{source},</if>
|
||||
<if test="scriptPurpose != null">#{scriptPurpose},</if>
|
||||
<if test="id != null">#{id},</if>
|
||||
<if test="name != null">#{name},</if>
|
||||
<if test="value != null">#{value},</if>
|
||||
<if test="operator != null">#{operator},</if>
|
||||
<if test="type != null">#{type},</if>
|
||||
<if test="deviceCount != null">#{deviceCount},</if>
|
||||
<if test="jobId != null">#{jobId},</if>
|
||||
<if test="cronExpression != null">#{cronExpression},</if>
|
||||
<if test="isAdvance != null">#{isAdvance},</if>
|
||||
<if test="parentId != null">#{parentId},</if>
|
||||
<if test="parentName != null">#{parentName},</if>
|
||||
<if test="arrayIndex != null">#{arrayIndex},</if>
|
||||
<if test="arrayIndexName != null">#{arrayIndexName},</if>
|
||||
<if test="createBy != null">#{createBy},</if>
|
||||
<if test="createTime != null">#{createTime},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
<update id="updateSceneScript" parameterType="SceneScript">
|
||||
update iot_scene_script
|
||||
<trim prefix="SET" suffixOverrides=",">
|
||||
<if test="scriptId != null">script_id = #{scriptId},</if>
|
||||
<if test="sceneId != null">scene_id = #{sceneId},</if>
|
||||
<if test="productId != null">product_id = #{productId},</if>
|
||||
<if test="productName != null">product_name = #{productName},</if>
|
||||
<if test="source != null">source = #{source},</if>
|
||||
<if test="scriptPurpose != null">script_purpose = #{scriptPurpose},</if>
|
||||
<if test="id != null">id = #{id},</if>
|
||||
<if test="name != null">name = #{name},</if>
|
||||
<if test="value != null">value = #{value},</if>
|
||||
<if test="operator != null">operator = #{operator},</if>
|
||||
<if test="type != null">type = #{type},</if>
|
||||
<if test="deviceCount != null">device_count = #{deviceCount},</if>
|
||||
<if test="jobId != null">job_id = #{jobId},</if>
|
||||
<if test="cronExpression != null">cron_expression = #{cronExpression},</if>
|
||||
<if test="isAdvance != null">is_advance = #{isAdvance},</if>
|
||||
<if test="parentId != null">parent_id = #{parentId},</if>
|
||||
<if test="parentName != null">parent_name = #{parentName},</if>
|
||||
<if test="arrayIndex != null">array_index = #{arrayIndex},</if>
|
||||
<if test="arrayIndexName != null">array_index_name = #{arrayIndexName},</if>
|
||||
<if test="createBy != null">create_by = #{createBy},</if>
|
||||
<if test="createTime != null">create_time = #{createTime},</if>
|
||||
</trim>
|
||||
where script_id = #{scriptId}
|
||||
</update>
|
||||
|
||||
<delete id="deleteSceneScriptBySceneScriptId" parameterType="String">
|
||||
delete
|
||||
from iot_scene_script
|
||||
where script_id = #{scriptId}
|
||||
</delete>
|
||||
|
||||
<delete id="deleteSceneScriptBySceneScriptIds" parameterType="String">
|
||||
delete from iot_scene_script where script_id in
|
||||
<foreach item="sceneScriptId" collection="array" open="(" separator="," close=")">
|
||||
#{scriptId}
|
||||
</foreach>
|
||||
</delete>
|
||||
|
||||
<insert id="insertSceneScriptList" parameterType="java.util.List">
|
||||
insert into iot_scene_script (script_id,scene_id,product_id,product_name,source,script_purpose,id, name,value,operator,type,device_count,job_id,
|
||||
cron_expression,is_advance,parent_id,parent_name,array_index,array_index_name,create_by,create_time)
|
||||
VALUES
|
||||
<foreach collection="list" item="sceneScript" separator=",">
|
||||
(#{sceneScript.scriptId},
|
||||
#{sceneScript.sceneId},
|
||||
#{sceneScript.productId},
|
||||
#{sceneScript.productName},
|
||||
#{sceneScript.source},
|
||||
#{sceneScript.scriptPurpose},
|
||||
#{sceneScript.id},
|
||||
#{sceneScript.name},
|
||||
#{sceneScript.value},
|
||||
#{sceneScript.operator},
|
||||
#{sceneScript.type},
|
||||
#{sceneScript.deviceCount},
|
||||
#{sceneScript.jobId},
|
||||
#{sceneScript.cronExpression},
|
||||
#{sceneScript.isAdvance},
|
||||
#{sceneScript.parentId},
|
||||
#{sceneScript.parentName},
|
||||
#{sceneScript.arrayIndex},
|
||||
#{sceneScript.arrayIndexName},
|
||||
#{sceneScript.createBy},
|
||||
#{sceneScript.createTime})
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
<delete id="deleteSceneScriptBySceneIds" parameterType="String">
|
||||
delete from iot_scene_script where scene_id in
|
||||
<foreach item="sceneId" collection="array" open="(" separator="," close=")">
|
||||
#{sceneId}
|
||||
</foreach>
|
||||
</delete>
|
||||
</mapper>
|
@ -0,0 +1,134 @@
|
||||
<?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.SceneTagPointsMapper">
|
||||
|
||||
<resultMap type="SceneTagPoints" id="SceneTagPointsResult">
|
||||
<result property="id" column="id" />
|
||||
<result property="name" column="name" />
|
||||
<result property="alias" column="alias" />
|
||||
<result property="tagId" column="tag_id" />
|
||||
<result property="operation" column="operation" />
|
||||
<result property="variableType" column="variable_type" />
|
||||
<result property="sceneModelDataId" column="scene_model_data_id" />
|
||||
<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="selectSceneTagPointsVo">
|
||||
select id, name, alias, tag_id, operation, variable_type, scene_model_data_id, del_flag, create_by, create_time, update_by, update_time, remark from scene_tag_points
|
||||
</sql>
|
||||
|
||||
<select id="selectSceneTagPointsList" parameterType="SceneTagPoints" resultMap="SceneTagPointsResult">
|
||||
<include refid="selectSceneTagPointsVo"/>
|
||||
<where>
|
||||
<if test="name != null and name != ''"> and name like concat('%', #{name}, '%')</if>
|
||||
<if test="alias != null and alias != ''"> and alias = #{alias}</if>
|
||||
<if test="tagId != null "> and tag_id = #{tagId}</if>
|
||||
<if test="operation != null "> and operation = #{operation}</if>
|
||||
<if test="variableType != null "> and variable_type = #{variableType}</if>
|
||||
<if test="sceneModelDataId != null "> and scene_model_data_id = #{sceneModelDataId}</if>
|
||||
</where>
|
||||
and del_flag = 0
|
||||
</select>
|
||||
|
||||
<select id="selectSceneTagPointsById" parameterType="Long" resultMap="SceneTagPointsResult">
|
||||
<include refid="selectSceneTagPointsVo"/>
|
||||
where id = #{id}
|
||||
and del_flag = 0
|
||||
</select>
|
||||
|
||||
<select id="selectListByTagId" resultType="com.fastbee.iot.domain.SceneTagPoints">
|
||||
<include refid="selectSceneTagPointsVo"/>
|
||||
where tag_id = #{tagId}
|
||||
and del_flag = 0
|
||||
</select>
|
||||
|
||||
<insert id="insertSceneTagPoints" parameterType="SceneTagPoints" useGeneratedKeys="true" keyProperty="id">
|
||||
insert into scene_tag_points
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="name != null and name != ''">name,</if>
|
||||
<if test="alias != null and alias != ''">alias,</if>
|
||||
<if test="tagId != null">tag_id,</if>
|
||||
<if test="operation != null">operation,</if>
|
||||
<if test="variableType != null">variable_type,</if>
|
||||
<if test="sceneModelDataId != null">scene_model_data_id,</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="name != null and name != ''">#{name},</if>
|
||||
<if test="alias != null and alias != ''">#{alias},</if>
|
||||
<if test="tagId != null">#{tagId},</if>
|
||||
<if test="operation != null">#{operation},</if>
|
||||
<if test="variableType != null">#{variableType},</if>
|
||||
<if test="sceneModelDataId != null">#{sceneModelDataId},</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="updateSceneTagPoints" parameterType="SceneTagPoints">
|
||||
update scene_tag_points
|
||||
<trim prefix="SET" suffixOverrides=",">
|
||||
<if test="name != null and name != ''">name = #{name},</if>
|
||||
<if test="alias != null and alias != ''">alias = #{alias},</if>
|
||||
<if test="tagId != null">tag_id = #{tagId},</if>
|
||||
<if test="operation != null">operation = #{operation},</if>
|
||||
<if test="variableType != null">variable_type = #{variableType},</if>
|
||||
<if test="sceneModelDataId != null">scene_model_data_id = #{sceneModelDataId},</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 id = #{id}
|
||||
</update>
|
||||
|
||||
<delete id="deleteSceneTagPointsById" parameterType="Long">
|
||||
delete from scene_tag_points where id = #{id}
|
||||
</delete>
|
||||
|
||||
<update id="deleteByTagIds">
|
||||
update scene_tag_points
|
||||
set del_flag = 1
|
||||
where tag_id in
|
||||
<foreach item="tagId" collection="array" open="(" separator="," close=")">
|
||||
#{tagId}
|
||||
</foreach>
|
||||
</update>
|
||||
|
||||
<update id="deleteSceneTagPointsByIds" parameterType="String">
|
||||
update scene_tag_points
|
||||
set del_flag = 1
|
||||
where id in
|
||||
<foreach item="id" collection="array" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</update>
|
||||
|
||||
<update id="deleteBySceneModelIds">
|
||||
update scene_tag_points
|
||||
set del_flag = 1
|
||||
where tag_id in (select id from scene_model_tag where scene_model_id in
|
||||
<foreach collection="array" item="sceneModelId" open="(" separator="," close=")">
|
||||
#{sceneModelId}
|
||||
</foreach>
|
||||
)
|
||||
</update>
|
||||
</mapper>
|
@ -0,0 +1,262 @@
|
||||
<?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.ScriptMapper">
|
||||
|
||||
<resultMap type="com.fastbee.iot.domain.Script" id="RuleScriptResult">
|
||||
<result property="userId" column="user_id" />
|
||||
<result property="userName" column="user_name" />
|
||||
<result property="sceneId" column="scene_id" />
|
||||
<result property="productId" column="product_id" />
|
||||
<result property="productName" column="product_name" />
|
||||
<result property="bridgeId" column="bridge_id" />
|
||||
<result property="bridgeName" column="bridge_name" />
|
||||
<result property="scriptEvent" column="script_event" />
|
||||
<result property="scriptAction" column="script_action" />
|
||||
<result property="scriptPurpose" column="script_purpose" />
|
||||
<result property="scriptOrder" column="script_order" />
|
||||
<result property="applicationName" column="application_name" />
|
||||
<result property="scriptId" column="script_id" />
|
||||
<result property="scriptName" column="script_name" />
|
||||
<result property="scriptData" column="script_data" />
|
||||
<result property="scriptType" column="script_type" />
|
||||
<result property="scriptLanguage" column="script_language" />
|
||||
<result property="enable" column="enable" />
|
||||
<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="selectRuleScriptVo">
|
||||
select user_id, user_name, scene_id,product_id,product_name,script_event,script_action,script_purpose,script_order,application_name, script_id, script_name, script_data, script_type, script_language,enable, del_flag, create_by, create_time, update_by, update_time, remark from iot_script
|
||||
</sql>
|
||||
|
||||
<sql id="selectRuleScriptList">
|
||||
select user_id, user_name, scene_id,product_id,product_name, script_event,script_action,script_purpose,script_order,application_name, script_id, script_name, script_type, script_language,enable, create_by, create_time, update_by, update_time from iot_script
|
||||
</sql>
|
||||
|
||||
<select id="selectRuleScriptList" parameterType="com.fastbee.iot.model.ScriptCondition" resultMap="RuleScriptResult">
|
||||
select script_event,script_action,script_purpose,script_order,application_name, script_name, script_type, script_language,
|
||||
user_id, user_name,scene_id,product_id,product_name,
|
||||
s.script_id, s.enable, s.create_by, s.create_time, s.update_by, s.update_time,
|
||||
b.id as bridge_id, b.name as bridge_name
|
||||
from iot_script s
|
||||
left join iot_script_bridge sb on s.script_id = sb.script_id
|
||||
left join bridge b on b.id = sb.bridge_id
|
||||
<where>
|
||||
<if test="applicationName != null and applicationName != ''"> and application_name like concat('%', #{applicationName}, '%')</if>
|
||||
<if test="scriptId != null and scriptId != ''"> and script_id = #{scriptId}</if>
|
||||
<if test="userId != null and userId != ''"> and user_id = #{userId}</if>
|
||||
<if test="sceneId != null and sceneId != ''"> and scene_id = #{sceneId}</if>
|
||||
<if test="productId != null and productId != ''"> and product_id = #{productId}</if>
|
||||
<if test="scriptEvent != null and scriptEvent != ''"> and script_event = #{scriptEvent}</if>
|
||||
<if test="scriptAction != null and scriptAction != ''"> and script_action = #{scriptAction}</if>
|
||||
<if test="scriptPurpose != null and scriptPurpose != ''"> and script_purpose = #{scriptPurpose}</if>
|
||||
<if test="scriptName != null and scriptName != ''"> and script_name like concat('%', #{scriptName}, '%')</if>
|
||||
<if test="scriptType != null and scriptType != ''"> and script_type = #{scriptType}</if>
|
||||
<if test="enable != null"> and enable = #{enable}</if>
|
||||
<if test="scriptLanguage != null and scriptLanguage != ''"> and script_language = #{scriptLanguage}</if>
|
||||
</where>
|
||||
order by script_order
|
||||
</select>
|
||||
|
||||
<select id="selectExecRuleScriptList" parameterType="com.fastbee.iot.model.ScriptCondition" resultMap="RuleScriptResult">
|
||||
select s.script_id, script_action
|
||||
from iot_script s
|
||||
left join iot_script_bridge sb on s.script_id = sb.script_id
|
||||
left join bridge b on b.id = sb.bridge_id
|
||||
<where>
|
||||
s.enable = 1
|
||||
<if test="productId != null and productId != ''"> and s.product_id = #{productId}</if>
|
||||
<if test="scriptEvent != null and scriptEvent != ''"> and s.script_event = #{scriptEvent}</if>
|
||||
<if test="scriptPurpose != null and scriptPurpose != ''"> and s.script_purpose = #{scriptPurpose}</if>
|
||||
<if test="route != null and route != ''" > and b.route = #{route}</if>
|
||||
</where>
|
||||
order by script_order
|
||||
</select>
|
||||
|
||||
<select id="selectRuleScriptIdArray" parameterType="com.fastbee.iot.model.ScriptCondition" resultType="String">
|
||||
select script_id from iot_script
|
||||
<where>
|
||||
enable = 1
|
||||
<if test="applicationName != null and applicationName != ''"> and application_name like concat('%', #{applicationName}, '%')</if>
|
||||
<if test="sceneId != null and sceneId != ''"> and scene_id = #{sceneId}</if>
|
||||
<if test="productId != null and productId != ''"> and product_id = #{productId}</if>
|
||||
<if test="scriptId != null and scriptId != ''"> and script_id = #{scriptId}</if>
|
||||
<if test="scriptEvent != null and scriptEvent != ''"> and script_event = #{scriptEvent}</if>
|
||||
<if test="scriptAction != null and scriptAction != ''"> and script_action = #{scriptAction}</if>
|
||||
<if test="scriptPurpose != null and scriptPurpose != ''"> and script_purpose = #{scriptPurpose}</if>
|
||||
<if test="scriptLanguage != null and scriptLanguage != ''"> and script_language = #{scriptLanguage}</if>
|
||||
<if test="userId != null and userId != ''"> and (user_id = #{userId} or user_id = #{tencentId})</if>
|
||||
</where>
|
||||
order by script_order
|
||||
</select>
|
||||
|
||||
<select id="selectRuleScriptIdCount" parameterType="String" resultType="int">
|
||||
select count(script_id) from iot_script where script_id = #{scriptId}
|
||||
</select>
|
||||
|
||||
<select id="selectRuleScriptById" parameterType="String" resultMap="RuleScriptResult">
|
||||
select script_event,script_action,script_purpose,script_order,application_name, script_name, script_data, script_type, script_language,
|
||||
user_id, user_name,scene_id,product_id,product_name,
|
||||
s.script_id, s.enable, s.create_by, s.create_time, s.update_by, s.update_time,
|
||||
b.id as bridge_id, b.name as bridge_name
|
||||
from iot_script s
|
||||
left join iot_script_bridge sb on s.script_id = sb.script_id
|
||||
left join bridge b on b.id = sb.bridge_id
|
||||
where s.script_id = #{scriptId}
|
||||
</select>
|
||||
|
||||
<insert id="insertRuleScript" parameterType="Script" useGeneratedKeys="false">
|
||||
insert into iot_script
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="userId != null and userId != ''">user_id,</if>
|
||||
<if test="userName != null and userName != ''">user_name,</if>
|
||||
<if test="sceneId != null">scene_id,</if>
|
||||
<if test="scriptEvent != null ">script_event,</if>
|
||||
<if test="scriptAction != null ">script_action,</if>
|
||||
<if test="scriptPurpose != null ">script_purpose,</if>
|
||||
<if test="scriptOrder != null ">script_order,</if>
|
||||
<if test="applicationName != null and applicationName != ''">application_name,</if>
|
||||
<if test="scriptId != null and scriptId != ''">script_id,</if>
|
||||
<if test="scriptName != null and scriptName != ''">script_name,</if>
|
||||
<if test="scriptData != null">script_data,</if>
|
||||
<if test="scriptType != null ">script_type,</if>
|
||||
<if test="scriptLanguage != null and scriptLanguage != ''">script_language,</if>
|
||||
<if test="enable != null">enable,</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="updateBy != null">update_by,</if>
|
||||
<if test="updateTime != null">update_time,</if>
|
||||
<if test="remark != null">remark,</if>
|
||||
<if test="productId != null">product_id,</if>
|
||||
<if test="productName != null">product_name,</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="userId != null and userId != ''">#{userId},</if>
|
||||
<if test="userName != null and userName != ''">#{userName},</if>
|
||||
<if test="sceneId != null">#{sceneId},</if>
|
||||
<if test="scriptEvent != null ">#{scriptEvent},</if>
|
||||
<if test="scriptAction != null ">#{scriptAction},</if>
|
||||
<if test="scriptPurpose != null ">#{scriptPurpose},</if>
|
||||
<if test="scriptOrder != null ">#{scriptOrder},</if>
|
||||
<if test="applicationName != null and applicationName != ''">#{applicationName},</if>
|
||||
<if test="scriptId != null and scriptId != ''">#{scriptId},</if>
|
||||
<if test="scriptName != null and scriptName != ''">#{scriptName},</if>
|
||||
<if test="scriptData != null">#{scriptData},</if>
|
||||
<if test="scriptType != null ">#{scriptType},</if>
|
||||
<if test="scriptLanguage != null and scriptLanguage != ''">#{scriptLanguage},</if>
|
||||
<if test="enable != null">#{enable},</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="updateBy != null">#{updateBy},</if>
|
||||
<if test="updateTime != null">#{updateTime},</if>
|
||||
<if test="remark != null">#{remark},</if>
|
||||
<if test="productId != null">#{productId},</if>
|
||||
<if test="productName != null">#{productName},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
<update id="updateRuleScript" parameterType="Script">
|
||||
update iot_script
|
||||
<trim prefix="SET" suffixOverrides=",">
|
||||
<if test="userId != null and userId != ''">user_id = #{userId},</if>
|
||||
<if test="userName != null and userName != ''">user_name = #{userName},</if>
|
||||
<if test="sceneId != null and sceneId != ''">scene_id = #{sceneId},</if>
|
||||
<if test="scriptEvent != null ">script_event = #{scriptEvent},</if>
|
||||
<if test="scriptAction != null ">script_action = #{scriptAction},</if>
|
||||
<if test="scriptPurpose != null ">script_purpose = #{scriptPurpose},</if>
|
||||
<if test="scriptOrder != null ">script_order = #{scriptOrder},</if>
|
||||
<if test="applicationName != null and applicationName != ''">application_name = #{applicationName},</if>
|
||||
<if test="scriptId != null and scriptId != ''">script_id = #{scriptId},</if>
|
||||
<if test="scriptName != null and scriptName != ''">script_name = #{scriptName},</if>
|
||||
<if test="scriptData != null">script_data = #{scriptData},</if>
|
||||
<if test="scriptType != null ">script_type = #{scriptType},</if>
|
||||
<if test="scriptLanguage != null and scriptLanguage != ''">script_language = #{scriptLanguage},</if>
|
||||
<if test="enable != null">enable = #{enable},</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>
|
||||
<if test="productId != null">product_id = #{productId},</if>
|
||||
<if test="productName != null">product_name = #{productName},</if>
|
||||
</trim>
|
||||
where script_id = #{scriptId}
|
||||
</update>
|
||||
|
||||
<delete id="deleteRuleScriptById" parameterType="String">
|
||||
delete from iot_script where script_id = #{scriptId}
|
||||
</delete>
|
||||
|
||||
<delete id="deleteRuleScriptByIds" parameterType="String">
|
||||
delete from iot_script where script_id in
|
||||
<foreach item="scriptId" collection="array" open="(" separator="," close=")">
|
||||
#{scriptId}
|
||||
</foreach>
|
||||
</delete>
|
||||
|
||||
<insert id="insertRuleScriptList" parameterType="java.util.List">
|
||||
insert into iot_script (user_id,user_name,scene_id,script_event, script_action, script_purpose,script_order,
|
||||
application_name,script_id,script_name,script_data,script_type,script_language,enable,create_by,create_time,product_id,product_name)
|
||||
VALUES
|
||||
<foreach collection ="list" item="ruleScript" separator =",">
|
||||
(#{ruleScript.userId},
|
||||
#{ruleScript.userName},
|
||||
#{ruleScript.sceneId},
|
||||
#{ruleScript.scriptEvent},
|
||||
#{ruleScript.scriptAction},
|
||||
#{ruleScript.scriptPurpose},
|
||||
#{ruleScript.scriptOrder},
|
||||
#{ruleScript.applicationName},
|
||||
#{ruleScript.scriptId},
|
||||
#{ruleScript.scriptName},
|
||||
#{ruleScript.scriptData},
|
||||
#{ruleScript.scriptType},
|
||||
#{ruleScript.scriptLanguage},
|
||||
#{ruleScript.enable},
|
||||
#{ruleScript.createBy},
|
||||
#{ruleScript.createTime},
|
||||
#{ruleScript.productId},
|
||||
#{ruleScript.productName})
|
||||
</foreach >
|
||||
</insert>
|
||||
|
||||
<delete id="deleteRuleScriptBySceneIds" parameterType="String">
|
||||
delete from iot_script where scene_id in
|
||||
<foreach item="sceneId" collection="array" open="(" separator="," close=")">
|
||||
#{sceneId}
|
||||
</foreach>
|
||||
</delete>
|
||||
|
||||
<insert id="insertScriptBridge">
|
||||
insert into iot_script_bridge
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="scriptId != null and scriptId != ''">script_id,</if>
|
||||
<if test="bridgeId != null and bridgeId != ''">bridge_id,</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="scriptId != null and scriptId != ''">#{scriptId},</if>
|
||||
<if test="bridgeId != null and bridgeId != ''">#{bridgeId},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
<update id="updateScriptBridge">
|
||||
update iot_script_bridge
|
||||
<trim prefix="SET" suffixOverrides=",">
|
||||
<if test="bridgeId != null and bridgeId != ''">bridge_id = #{bridgeId},</if>
|
||||
</trim>
|
||||
where script_id = #{scriptId}
|
||||
</update>
|
||||
|
||||
<delete id="deleteScriptBridge" parameterType="String">
|
||||
delete from iot_script_bridge where script_id = #{scriptId}
|
||||
</delete>
|
||||
</mapper>
|
@ -0,0 +1,93 @@
|
||||
<?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.SimulateLogMapper">
|
||||
|
||||
<resultMap type="com.fastbee.iot.domain.SimulateLog" id="SimulateLogResult">
|
||||
<result property="logId" column="log_id" />
|
||||
<result property="sendData" column="send_data" />
|
||||
<result property="callbackData" column="callback_data" />
|
||||
<result property="deviceId" column="device_id" />
|
||||
<result property="deviceName" column="device_name" />
|
||||
<result property="serialNumber" column="serial_number" />
|
||||
<result property="createBy" column="create_by" />
|
||||
<result property="createTime" column="create_time" />
|
||||
<result property="remark" column="remark" />
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectSimulateLogVo">
|
||||
select log_id, send_data, callback_data, device_id, device_name, serial_number, create_by, create_time, remark from iot_simulate_log
|
||||
</sql>
|
||||
|
||||
<select id="selectSimulateLogList" parameterType="com.fastbee.iot.domain.SimulateLog" resultMap="SimulateLogResult">
|
||||
<include refid="selectSimulateLogVo"/>
|
||||
<where>
|
||||
<if test="sendData != null and sendData != ''"> and send_data = #{sendData}</if>
|
||||
<if test="callbackData != null and callbackData != ''"> and callback_data = #{callbackData}</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>
|
||||
</where>
|
||||
order by create_time desc
|
||||
</select>
|
||||
|
||||
<select id="selectSimulateLogByLogId" parameterType="Long" resultMap="SimulateLogResult">
|
||||
<include refid="selectSimulateLogVo"/>
|
||||
where log_id = #{logId}
|
||||
</select>
|
||||
|
||||
<insert id="insertSimulateLog" parameterType="com.fastbee.iot.domain.SimulateLog" useGeneratedKeys="true" keyProperty="logId">
|
||||
insert into iot_simulate_log
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="sendData != null">send_data,</if>
|
||||
<if test="callbackData != null">callback_data,</if>
|
||||
<if test="deviceId != null">device_id,</if>
|
||||
<if test="deviceName != null">device_name,</if>
|
||||
<if test="serialNumber != null and serialNumber != ''">serial_number,</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="sendData != null">#{sendData},</if>
|
||||
<if test="callbackData != null">#{callbackData},</if>
|
||||
<if test="deviceId != null">#{deviceId},</if>
|
||||
<if test="deviceName != null">#{deviceName},</if>
|
||||
<if test="serialNumber != null and serialNumber != ''">#{serialNumber},</if>
|
||||
<if test="createBy != null">#{createBy},</if>
|
||||
<if test="createTime != null">#{createTime},</if>
|
||||
<if test="remark != null">#{remark},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
<update id="updateSimulateLog" parameterType="com.fastbee.iot.domain.SimulateLog">
|
||||
update iot_simulate_log
|
||||
<trim prefix="SET" suffixOverrides=",">
|
||||
<if test="sendData != null">send_data = #{sendData},</if>
|
||||
<if test="callbackData != null">callback_data = #{callbackData},</if>
|
||||
<if test="deviceId != null">device_id = #{deviceId},</if>
|
||||
<if test="deviceName != null">device_name = #{deviceName},</if>
|
||||
<if test="serialNumber != null and serialNumber != ''">serial_number = #{serialNumber},</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="deleteSimulateLogByLogId" parameterType="Long">
|
||||
delete from iot_simulate_log where log_id = #{logId}
|
||||
</delete>
|
||||
|
||||
<delete id="deleteSimulateLogBySerialNumber" parameterType="String">
|
||||
delete from iot_simulate_log where serial_number = #{serialNumber}
|
||||
</delete>
|
||||
|
||||
<delete id="deleteSimulateLogByLogIds" parameterType="String">
|
||||
delete from iot_simulate_log where log_id in
|
||||
<foreach item="logId" collection="array" open="(" separator="," close=")">
|
||||
#{logId}
|
||||
</foreach>
|
||||
</delete>
|
||||
</mapper>
|
@ -0,0 +1,112 @@
|
||||
<?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.SipRelationMapper">
|
||||
|
||||
<resultMap type="com.fastbee.iot.domain.SipRelation" id="SipRelationResult">
|
||||
<result property="id" column="id" />
|
||||
<result property="channelId" column="channel_id" />
|
||||
<result property="reDeviceId" column="re_device_id" />
|
||||
<result property="reSceneModelId" column="re_scene_model_id" />
|
||||
<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="deviceId" column="device_id"/>
|
||||
<result property="status" column="status"/>
|
||||
<result property="deviceSipId" column="device_sip_id"/>
|
||||
<result property="channelName" column="channel_name"/>
|
||||
<result property="model" column="model"/>
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectSipRelationVo">
|
||||
select id, channel_id, re_device_id, re_scene_model_id, create_by, create_time, update_by, update_time, remark from iot_sip_relation
|
||||
</sql>
|
||||
|
||||
<select id="selectSipRelationList" parameterType="com.fastbee.iot.domain.SipRelation" resultMap="SipRelationResult">
|
||||
select r.id, r.channel_id, r.re_device_id, r.re_scene_model_id, r.create_by, r.create_time, r.update_by,
|
||||
r.update_time,sd.status,sd.device_sip_id,sd.channel_name,sd.model
|
||||
from iot_sip_relation r left join sip_device_channel sd on r.channel_id = sd.channel_sip_id
|
||||
<where>
|
||||
<if test="channelId != null and channelId != ''"> and r.channel_id = #{channelId}</if>
|
||||
<if test="reDeviceId != null "> and r.re_device_id = #{reDeviceId}</if>
|
||||
<if test="reSceneModelId != null "> and r.re_scene_model_id = #{reSceneModelId}</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<select id="selectSipRelationById" parameterType="Long" resultMap="SipRelationResult">
|
||||
<include refid="selectSipRelationVo"/>
|
||||
where id = #{id}
|
||||
</select>
|
||||
|
||||
<insert id="insertSipRelation" parameterType="com.fastbee.iot.domain.SipRelation" useGeneratedKeys="true" keyProperty="id">
|
||||
insert into iot_sip_relation
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="channelId != null and channelId != ''">channel_id,</if>
|
||||
<if test="reDeviceId != null">re_device_id,</if>
|
||||
<if test="reSceneModelId != null">re_scene_model_id,</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="channelId != null and channelId != ''">#{channelId},</if>
|
||||
<if test="reDeviceId != null">#{reDeviceId},</if>
|
||||
<if test="reSceneModelId != null">#{reSceneModelId},</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="updateSipRelation" parameterType="com.fastbee.iot.domain.SipRelation">
|
||||
update iot_sip_relation
|
||||
<trim prefix="SET" suffixOverrides=",">
|
||||
<if test="channelId != null and channelId != ''">channel_id = #{channelId},</if>
|
||||
<if test="reDeviceId != null">re_device_id = #{reDeviceId},</if>
|
||||
<if test="reSceneModelId != null">re_scene_model_id = #{reSceneModelId},</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 id = #{id}
|
||||
</update>
|
||||
|
||||
<delete id="deleteSipRelationById" parameterType="Long">
|
||||
delete from iot_sip_relation where id = #{id}
|
||||
</delete>
|
||||
|
||||
<delete id="deleteSipRelationByIds" parameterType="String">
|
||||
delete from iot_sip_relation where id in
|
||||
<foreach item="id" collection="array" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</delete>
|
||||
|
||||
<select id="selectByChannelId" resultMap="SipRelationResult">
|
||||
<include refid="selectSipRelationVo"/>
|
||||
where channel_id = #{channelId}
|
||||
</select>
|
||||
|
||||
<update id="updateByChannelId" parameterType="com.fastbee.iot.domain.SipRelation">
|
||||
update iot_sip_relation
|
||||
<trim prefix="SET" suffixOverrides=",">
|
||||
<if test="reDeviceId != null">re_device_id = #{reDeviceId},</if>
|
||||
<if test="reSceneModelId != null">re_scene_model_id = #{reSceneModelId},</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 channel_id = #{channelId}
|
||||
</update>
|
||||
</mapper>
|
@ -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>
|
@ -0,0 +1,304 @@
|
||||
<?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>
|
||||
|
||||
<select id="selectByUserIdAndSourceClient" resultType="com.fastbee.iot.domain.SocialUser">
|
||||
<include refid="selectSocialUserVo"/>
|
||||
where sys_user_id = #{sysUserId}
|
||||
and source_client = #{sourceClient}
|
||||
and del_flag = 0
|
||||
</select>
|
||||
|
||||
<select id="listWechatPublicAccountOpenId" resultType="com.fastbee.iot.domain.SocialUser">
|
||||
select DISTINCT u.sys_user_id, s.open_id
|
||||
from iot_social_user u left join iot_social_user s on u.union_id = s.union_id
|
||||
where u.sys_user_id in
|
||||
<foreach collection="userIdList" item="userId" open="(" separator="," close=")">
|
||||
#{userId}
|
||||
</foreach>
|
||||
and u.status = 1
|
||||
and u.del_flag = 0
|
||||
and s.del_flag = 0
|
||||
and s.`status` =1
|
||||
and s.source_client = 'wechat_open_public_account'
|
||||
</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>
|
||||
|
||||
<delete id="deleteByOpenIdAndSourceClient">
|
||||
update iot_social_user
|
||||
set del_flag = 1,
|
||||
update_time = now()
|
||||
where open_id = #{openId}
|
||||
and source_client = #{sourceClient}
|
||||
</delete>
|
||||
</mapper>
|
@ -0,0 +1,41 @@
|
||||
<?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.SpeakerMapper">
|
||||
|
||||
|
||||
<select id="selectRelatedIdByProductIdAndUserId" resultType="java.lang.Long">
|
||||
select related_id
|
||||
from dueros_related_product
|
||||
where product_id = #{productId}
|
||||
and tenant_id = #{userId}
|
||||
</select>
|
||||
|
||||
|
||||
<select id="selectOauthAccessTokenByUserNameAndClientId"
|
||||
resultType="com.fastbee.iot.model.speaker.OauthAccessTokenReportVO">
|
||||
select client_id, open_id
|
||||
from oauth_access_token
|
||||
where user_name = #{userName}
|
||||
and client_id = #{clientId}
|
||||
</select>
|
||||
|
||||
<select id="selectOauthClientDetailsByType"
|
||||
resultType="com.fastbee.iot.model.speaker.OauthClientDetailsReportVO">
|
||||
select client_id, cloud_skill_id
|
||||
from oauth_client_details
|
||||
where type = #{type}
|
||||
and status = 0
|
||||
</select>
|
||||
|
||||
<select id="listAttributesByRelatedIdAndIdentifier" resultType="java.lang.String">
|
||||
select attributes
|
||||
from dueros_related_things_model
|
||||
where related_id = #{relatedId}
|
||||
and identifier in
|
||||
<foreach collection="identifierList" item="identifier" open="(" separator="," close=")">
|
||||
#{identifier}
|
||||
</foreach>
|
||||
</select>
|
||||
</mapper>
|
@ -0,0 +1,168 @@
|
||||
<?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.SubGatewayMapper">
|
||||
|
||||
<resultMap type="com.fastbee.iot.domain.SubGateway" id="GatewayResult">
|
||||
<result property="id" column="id" />
|
||||
<result property="gwDeviceId" column="gw_device_id"/>
|
||||
<result property="subDeviceId" column="sub_device_id" />
|
||||
<result property="slaveId" column="slave_id" />
|
||||
<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 id="GatewaySubDeviceResult" type="com.fastbee.iot.model.gateWay.GateSubDeviceVO">
|
||||
<result property="deviceId" column="device_id" />
|
||||
<result property="serialNumber" column="serial_number" />
|
||||
<result property="deviceName" column="device_name" />
|
||||
</resultMap>
|
||||
|
||||
<resultMap id="GatewaySubDeviceListResult" type="com.fastbee.iot.model.gateWay.SubDeviceListVO">
|
||||
<result property="gwDeviceId" column="gw_device_id"/>
|
||||
<result property="subDeviceId" column="sub_device_id" />
|
||||
<result property="slaveId" column="slave_id" />
|
||||
<result property="subDeviceName" column="device_name"/>
|
||||
<result property="subDeviceNo" column="serial_number"/>
|
||||
<result property="createTime" column="create_time" />
|
||||
<result property="subProductId" column="sub_product_id"/>
|
||||
<result property="id" column="id" />
|
||||
</resultMap>
|
||||
|
||||
<resultMap id="SubDeviceListResult" type="com.fastbee.common.core.mq.SubDeviceBo">
|
||||
<result property="gwDeviceId" column="gw_device_id"/>
|
||||
<result property="subDeviceId" column="sub_device_id" />
|
||||
<result property="slaveId" column="slave_id" />
|
||||
<result property="subDeviceName" column="device_name"/>
|
||||
<result property="subDeviceNo" column="serial_number"/>
|
||||
<result property="subProductId" column="sub_product_id"/>
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectGatewayVo">
|
||||
select id, gw_device_id, sub_device_id, slave_id, create_by, create_time, update_by, update_time, remark from iot_sub_gateway
|
||||
</sql>
|
||||
|
||||
<select id="selectGatewayList" parameterType="com.fastbee.iot.domain.SubGateway" resultMap="GatewaySubDeviceListResult">
|
||||
select ga.id, ga.gw_device_id, ga.sub_device_id, ga.slave_id, ga.create_time ,d.device_name, d.serial_number, d.product_id sub_product_id
|
||||
from iot_sub_gateway ga inner join iot_device d on ga.sub_device_id = d.device_id
|
||||
<where>
|
||||
<if test="gwDeviceId != null and gwDeviceId != 0">
|
||||
gw_device_id = #{gwDeviceId}
|
||||
</if>
|
||||
<if test="subDeviceId != null and subDeviceId != 0">
|
||||
sub_device_id = #{subDeviceId}
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<select id="selectGatewayById" parameterType="Long" resultMap="GatewayResult">
|
||||
<include refid="selectGatewayVo"/>
|
||||
where id = #{id}
|
||||
</select>
|
||||
|
||||
<insert id="insertGateway" parameterType="com.fastbee.iot.domain.SubGateway">
|
||||
insert into iot_sub_gateway
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="id != null">id,</if>
|
||||
<if test="gwDeviceId != null">gw_device_id,</if>
|
||||
<if test="subDeviceId != null">sub_device_id,</if>
|
||||
<if test="slaveId != null">slave_id,</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="id != null">#{id},</if>
|
||||
<if test="gwDeviceId != null">#{gwDeviceId},</if>
|
||||
<if test="subDeviceId != null">#{subDeviceId},</if>
|
||||
<if test="slaveId != null">#{slaveId},</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="updateGateway" parameterType="com.fastbee.iot.domain.SubGateway">
|
||||
update iot_sub_gateway
|
||||
<trim prefix="SET" suffixOverrides=",">
|
||||
<if test="gwDeviceId != null">gw_device_id = #{gwDeviceId},</if>
|
||||
<if test="subDeviceId != null">sub_device_id = #{subDeviceId},</if>
|
||||
<if test="slaveId != null">slave_id = #{slaveId},</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 id = #{id}
|
||||
</update>
|
||||
|
||||
<delete id="deleteGatewayById" parameterType="Long">
|
||||
delete from iot_sub_gateway where id = #{id}
|
||||
</delete>
|
||||
|
||||
<delete id="deleteGatewayByIds" parameterType="String">
|
||||
delete from iot_sub_gateway where id in
|
||||
<foreach item="id" collection="array" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</delete>
|
||||
|
||||
<select id="getIsSelectGateSubDevice" parameterType="com.fastbee.iot.model.gateWay.GateSubDeviceVO"
|
||||
resultMap="GatewaySubDeviceResult">
|
||||
select d.device_id,d.serial_number,d.device_name
|
||||
from iot_device d inner join iot_product p on d.product_id = p.product_id
|
||||
<where>
|
||||
|
||||
and NOT EXISTS (select 1 from iot_sub_gateway sg where d.device_id = sg.sub_device_id)
|
||||
and p.device_type = 4
|
||||
<if test="serialNumber != null and serialNumber != ''">
|
||||
and d.serial_number = #{serialNumber}
|
||||
</if>
|
||||
<if test="deviceName != null and deviceName != ''">
|
||||
and d.device_name = #{deviceName}
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<insert id="insertSubDeviceBatch" parameterType="com.fastbee.iot.domain.SubGateway" useGeneratedKeys="true">
|
||||
insert into iot_sub_gateway(gw_device_id, sub_device_id, slave_id, create_by, create_time)
|
||||
values
|
||||
<foreach collection="deviceList" item="device" separator=",">
|
||||
(#{device.gwDeviceId},
|
||||
#{device.subDeviceId},
|
||||
#{device.slaveId},
|
||||
#{device.createBy},
|
||||
sysdate()
|
||||
)
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
<update id="updateSubDeviceBatch">
|
||||
|
||||
</update>
|
||||
|
||||
<select id="getSubDeviceListByGw" parameterType="java.lang.String" resultMap="SubDeviceListResult">
|
||||
SELECT
|
||||
ga.id,
|
||||
ga.gw_device_id,
|
||||
ga.sub_device_id,
|
||||
ga.slave_id,
|
||||
sub.device_name,
|
||||
sub.serial_number,
|
||||
sub.product_id as sub_product_id
|
||||
FROM
|
||||
iot_sub_gateway ga
|
||||
INNER JOIN iot_device d ON ga.gw_device_id = d.device_id
|
||||
INNER JOIN iot_device sub on sub.device_id = ga.sub_device_id
|
||||
where d.serial_number = #{gwSerialNumber};
|
||||
</select>
|
||||
</mapper>
|
@ -0,0 +1,565 @@
|
||||
<?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="modelName_zh_CN" column="model_name_zh_cn"/>
|
||||
<result property="modelName_en_US" column="model_name_en_us"/>
|
||||
<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="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="isMonitor" column="is_monitor"/>
|
||||
<result property="isApp" column="is_app"/>
|
||||
<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"/>
|
||||
<result property="isReadonly" column="is_readonly"/>
|
||||
<result property="modelOrder" column="model_order"/>
|
||||
</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>
|
||||
|
||||
<resultMap type="com.fastbee.iot.model.modbus.ModbusAndThingsVO" id="ThingsModelAndModbusResult">
|
||||
<result property="modelId" column="model_id"/>
|
||||
<result property="modelName" column="model_name"/>
|
||||
<result property="identifier" column="identifier"/>
|
||||
<result property="isSelect" column="is_select"/>
|
||||
<result property="dataType" column="datatype"/>
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectThingsModelVo">
|
||||
select model_id,
|
||||
model_name,
|
||||
product_id,
|
||||
product_name,
|
||||
tenant_id,
|
||||
tenant_name,
|
||||
identifier,
|
||||
type,
|
||||
datatype,
|
||||
formula,
|
||||
specs,
|
||||
is_chart,
|
||||
is_share_perm,
|
||||
is_history,
|
||||
is_monitor,
|
||||
is_app,
|
||||
del_flag,
|
||||
create_by,
|
||||
create_time,
|
||||
update_by,
|
||||
update_time,
|
||||
remark,
|
||||
is_readonly,
|
||||
model_order
|
||||
from iot_things_model
|
||||
</sql>
|
||||
|
||||
<select id="selectThingsModelList" parameterType="com.fastbee.iot.domain.ThingsModel" resultMap="ThingsModelResult">
|
||||
select m.model_id,
|
||||
case
|
||||
when #{language} = 'zh-CN' then m.model_name
|
||||
when #{language} = 'en-US' then t.en_us
|
||||
else m.model_name
|
||||
end as model_name,
|
||||
m.model_name as model_name_zh_cn, t.en_us as model_name_en_us,
|
||||
m.product_id, m.product_name, m.tenant_id, m.tenant_name, m.identifier, m.type, m.datatype, m.formula,
|
||||
m.specs, m.is_chart, m.is_share_perm, m.is_history, m.is_monitor, m.is_app, m.del_flag, m.create_by,
|
||||
m.create_time, m.update_by, m.update_time, m.remark, m.is_readonly, m.model_order
|
||||
from iot_things_model m
|
||||
left join iot_things_model_translate t on m.model_id = t.id
|
||||
<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="modelIdList != null ">
|
||||
model_id in
|
||||
<foreach collection="modelIdList" item="item" separator="," open="(" close=")">
|
||||
#{item}
|
||||
</foreach>
|
||||
</if>
|
||||
</where>
|
||||
order by model_order desc,create_time desc
|
||||
</select>
|
||||
|
||||
<select id="selectThingsModelPermList" resultMap="ThingsModelPermResult">
|
||||
select case
|
||||
when #{language} = 'zh-CN' then m.model_name
|
||||
when #{language} = 'en-US' then t.en_us
|
||||
else m.model_name
|
||||
end as model_name,
|
||||
m.identifier, m.is_share_perm, m.remark
|
||||
from iot_things_model m
|
||||
left join iot_things_model_translate t on m.model_id = t.id
|
||||
where product_id=#{productId} and is_share_perm=1
|
||||
order by model_order desc,create_time desc
|
||||
</select>
|
||||
|
||||
|
||||
<select id="selectThingsModelListByProductIds" parameterType="String" resultMap="ThingsModelResult">
|
||||
select m.model_id,
|
||||
case
|
||||
when #{language} = 'zh-CN' then m.model_name
|
||||
when #{language} = 'en-US' then t.en_us
|
||||
else m.model_name
|
||||
end as model_name,
|
||||
m.product_id, m.product_name, m.tenant_id, m.tenant_name, m.identifier, m.type, m.datatype, m.formula,
|
||||
m.specs, m.is_chart, m.is_share_perm, m.is_history, m.is_monitor, m.is_app, m.del_flag, m.create_by,
|
||||
m.create_time, m.update_by, m.update_time, m.remark, m.is_readonly, m.model_order
|
||||
from iot_things_model m
|
||||
left join iot_things_model_translate t on m.model_id = t.id
|
||||
where is_chart=1 and product_id in
|
||||
<foreach item="productId" collection="array" open="(" separator="," close=")">
|
||||
#{productId}
|
||||
</foreach>
|
||||
</select>
|
||||
|
||||
<select id="selectThingsModelByModelId" resultMap="ThingsModelResult">
|
||||
select m.model_id,
|
||||
case
|
||||
when #{language} = 'zh-CN' then m.model_name
|
||||
when #{language} = 'en-US' then t.en_us
|
||||
else m.model_name
|
||||
end as model_name,
|
||||
m.product_id, m.product_name, m.tenant_id, m.tenant_name, m.identifier, m.type, m.datatype, m.formula,
|
||||
m.specs, m.is_chart, m.is_share_perm, m.is_history, m.is_monitor, m.is_app, m.del_flag, m.create_by,
|
||||
m.create_time, m.update_by, m.update_time, m.remark, m.is_readonly, m.model_order
|
||||
from iot_things_model m
|
||||
left join iot_things_model_translate t on m.model_id = t.id
|
||||
where model_id = #{modelId}
|
||||
</select>
|
||||
|
||||
<select id="selectSingleThingsModel" parameterType="com.fastbee.iot.domain.ThingsModel" resultMap="ThingsModelResult">
|
||||
select m.model_id,
|
||||
case
|
||||
when #{language} = 'zh-CN' then m.model_name
|
||||
when #{language} = 'en-US' then t.en_us
|
||||
else m.model_name
|
||||
end as model_name,
|
||||
m.product_id, m.product_name, m.tenant_id, m.tenant_name, m.identifier, m.type, m.datatype, m.formula,
|
||||
m.specs, m.is_chart, m.is_share_perm, m.is_history, m.is_monitor, m.is_app, m.del_flag, m.create_by,
|
||||
m.create_time, m.update_by, m.update_time, m.remark, m.is_readonly, m.model_order
|
||||
from iot_things_model m
|
||||
left join iot_things_model_translate t on m.model_id = t.id
|
||||
<where>
|
||||
<if test="productId != null">
|
||||
and product_id = #{productId}
|
||||
</if>
|
||||
<if test="identifier !=null and identifier != ''">
|
||||
and identifier = #{identifier}
|
||||
</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="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="isApp != null">
|
||||
is_app,
|
||||
</if>
|
||||
<if test="isMonitor != null">
|
||||
is_monitor,
|
||||
</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="isReadonly != null">
|
||||
is_readonly,
|
||||
</if>
|
||||
<if test="modelOrder != null">
|
||||
model_order,
|
||||
</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="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="isMonitor != null">
|
||||
#{isMonitor},
|
||||
</if>
|
||||
<if test="isApp != null">
|
||||
#{isApp},
|
||||
</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="isReadonly != null">
|
||||
#{isReadonly},
|
||||
</if>
|
||||
<if test="modelOrder != null">
|
||||
#{modelOrder},
|
||||
</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_app,
|
||||
is_readonly,
|
||||
create_by,
|
||||
create_time,
|
||||
formula
|
||||
)
|
||||
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.isApp},#{model.isReadonly},#{model.createBy},#{model.createTime},
|
||||
#{model.formula}
|
||||
</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="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="isMonitor != null">
|
||||
is_monitor = #{isMonitor},
|
||||
</if>
|
||||
<if test="isApp != null">
|
||||
is_app = #{isApp},
|
||||
</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="isReadonly != null">
|
||||
is_readonly = #{isReadonly},
|
||||
</if>
|
||||
<if test="modelOrder != null">
|
||||
model_order = #{modelOrder},
|
||||
</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 m.is_monitor as isMonitor,
|
||||
m.is_chart as isChart,
|
||||
m.is_share_perm as isSharePerm,
|
||||
m.is_history as isHistory,
|
||||
m.specs as dataType,
|
||||
case
|
||||
when #{language} = 'zh-CN' then m.model_name
|
||||
when #{language} = 'en-US' then t.en_us
|
||||
else m.model_name
|
||||
end as name,
|
||||
m.type as type,
|
||||
m.formula as formula,
|
||||
from iot_things_model m
|
||||
left join iot_things_model_translate t on m.model_id = t.id
|
||||
where m.product_id = #{productId,jdbcType=BIGINT}
|
||||
and m.identifier in
|
||||
<foreach collection="ids" item="item" open="(" separator="," close=")">
|
||||
#{item}
|
||||
</foreach>
|
||||
</select>
|
||||
|
||||
|
||||
<delete id="deleteThingsModelByProductId" parameterType="long">
|
||||
delete from iot_things_model where product_id = #{productId}
|
||||
</delete>
|
||||
|
||||
<select id="listSimByProductIds" resultType="com.fastbee.iot.model.ThingsModelSimVO">
|
||||
select m.product_id, m.identifier,
|
||||
case
|
||||
when #{language} = 'zh-CN' then m.model_name
|
||||
when #{language} = 'en-US' then t.en_us
|
||||
else m.model_name
|
||||
end as model_name,
|
||||
m.type as thingsModelType,
|
||||
m.datatype
|
||||
from iot_things_model m
|
||||
left join iot_things_model_translate t on m.model_id = t.id
|
||||
where m.product_id in
|
||||
<foreach collection="productIdList" item="productId" open="(" separator="," close=")">
|
||||
#{productId}
|
||||
</foreach>
|
||||
</select>
|
||||
|
||||
<select id="getSpecsByProductIdAndIdentifier" resultType="java.lang.String">
|
||||
select specs
|
||||
from iot_things_model
|
||||
where product_id = #{productId}
|
||||
and identifier = #{identifier}
|
||||
</select>
|
||||
|
||||
<select id="listSceneModelDataByModelIds" resultType="com.fastbee.iot.domain.ThingsModel">
|
||||
select m.model_id, m.identifier,
|
||||
case
|
||||
when #{language} = 'zh-CN' then m.model_name
|
||||
when #{language} = 'en-US' then t.en_us
|
||||
else m.model_name
|
||||
end as model_name,
|
||||
from iot_things_model m
|
||||
left join iot_things_model_translate t on m.model_id = t.id
|
||||
where m.model_id in
|
||||
<foreach collection="modelIdList" item="modelId" open="(" separator="," close=")">
|
||||
#{modelId}
|
||||
</foreach>
|
||||
</select>
|
||||
|
||||
|
||||
<select id="getModbusConfigUnSelectThingsModel" resultMap="ThingsModelAndModbusResult">
|
||||
select m.model_id, m.identifier,
|
||||
case
|
||||
when #{language} = 'zh-CN' then m.model_name
|
||||
when #{language} = 'en-US' then t.en_us
|
||||
else m.model_name
|
||||
end as model_name,
|
||||
m.datatype,
|
||||
case
|
||||
when (select count(*) from iot_modbus_config c where c.product_id = #{productId} and c.identifier = m.identifier) > 0 then 0
|
||||
else 1
|
||||
end as is_select
|
||||
from iot_things_model m
|
||||
left join iot_things_model_translate t on m.model_id = t.id
|
||||
where m.product_id = #{productId}
|
||||
</select>
|
||||
|
||||
<select id="selectThingsModelListByModelIds" resultType="com.fastbee.iot.domain.ThingsModel">
|
||||
select model_id, type
|
||||
from iot_things_model where model_id in
|
||||
<foreach item="modelId" collection="modelIdList" open="(" separator="," close=")">
|
||||
#{modelId}
|
||||
</foreach>
|
||||
and del_flag = 0
|
||||
</select>
|
||||
|
||||
<select id="selectThingsModelBySerialNumber" resultMap="ThingsModelResult">
|
||||
select m.model_id, m.identifier,
|
||||
case
|
||||
when #{language} = 'zh-CN' then m.model_name
|
||||
when #{language} = 'en-US' then t.en_us
|
||||
else m.model_name
|
||||
end as model_name
|
||||
from iot_things_model m
|
||||
inner join iot_device d on m.product_id = d.product_id
|
||||
left join iot_things_model_translate t on m.model_id = t.id
|
||||
where d.device_id = #{deviceId}
|
||||
and m.is_readonly = 0
|
||||
</select>
|
||||
</mapper>
|
@ -0,0 +1,177 @@
|
||||
<?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="isSharePerm" column="is_share_perm" />
|
||||
<result property="isHistory" column="is_history" />
|
||||
<result property="isMonitor" column="is_monitor" />
|
||||
<result property="isApp" column="is_app"/>
|
||||
<result property="formula" column="formula" />
|
||||
<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" />
|
||||
<result property="modelOrder" column="model_order" />
|
||||
</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, formula, del_flag, create_by, create_time, update_by, update_time, remark, model_order from iot_things_model_template
|
||||
</sql>
|
||||
|
||||
<select id="selectThingsModelTemplateList" parameterType="com.fastbee.iot.domain.ThingsModelTemplate" resultMap="ThingsModelTemplateResult">
|
||||
select m.template_id,
|
||||
case
|
||||
when #{language} = 'zh-CN' then m.template_name
|
||||
when #{language} = 'en-US' then t.en_us
|
||||
else m.template_name
|
||||
end as template_name,
|
||||
m.tenant_id, m.tenant_name, m.identifier, m.type, m.datatype, m.specs, m.is_sys, m.is_readonly, m.is_chart, m.is_share_perm, m.is_history, m.formula, m.del_flag, m.create_by, m.create_time, m.update_by, m.update_time, m.remark, m.model_order, m.is_monitor
|
||||
from iot_things_model_template m
|
||||
left join iot_things_model_template_translate t on m.template_id = t.id
|
||||
<where>
|
||||
<if test="templateName != null and templateName != ''"> and m.template_name like concat('%', #{templateName}, '%')</if>
|
||||
<if test="type != null "> and m.type = #{type}</if>
|
||||
<if test="specs != null and specs != ''"> and m.specs = #{specs}</if>
|
||||
<if test="tenantId != null and tenantId != ''"> and (m.tenant_id = #{tenantId} or m.is_sys = 1)</if>
|
||||
</where>
|
||||
order by m.template_id desc, m.create_time desc
|
||||
</select>
|
||||
|
||||
<select id="selectThingsModelTemplateByTemplateId" resultMap="ThingsModelTemplateResult">
|
||||
select m.template_id,
|
||||
case
|
||||
when #{language} = 'zh-CN' then m.template_name
|
||||
when #{language} = 'en-US' then t.en_us
|
||||
else m.template_name
|
||||
end as template_name,
|
||||
m.tenant_id, m.tenant_name, m.identifier, m.type, m.datatype, m.specs, m.is_sys, m.is_readonly, m.is_chart, m.is_share_perm, m.is_history, m.formula, m.del_flag, m.create_by, m.create_time, m.update_by, m.update_time, m.remark, m.model_order
|
||||
from iot_things_model_template m
|
||||
left join iot_things_model_template_translate t on m.template_id = t.id
|
||||
where m.template_id = #{templateId}
|
||||
</select>
|
||||
|
||||
<select id="selectThingsModelTemplateByTemplateIds" resultMap="ThingsModelTemplateResult">
|
||||
select m.template_id,
|
||||
case
|
||||
when #{language} = 'zh-CN' then m.template_name
|
||||
when #{language} = 'en-US' then t.en_us
|
||||
else m.template_name
|
||||
end as template_name,
|
||||
m.tenant_id, m.tenant_name, m.identifier, m.type, m.datatype, m.specs, m.is_sys, m.is_readonly, m.is_chart, m.is_share_perm, m.is_history, m.formula, m.del_flag, m.create_by, m.create_time, m.update_by, m.update_time, m.remark, m.model_order, m.is_monitor
|
||||
from iot_things_model_template m
|
||||
left join iot_things_model_template_translate t on m.template_id = t.id
|
||||
where m.template_id in
|
||||
<foreach item="templateId" collection="templateIds" 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="isMonitor != null">is_monitor,</if>
|
||||
<if test="isApp != null">is_app,</if>
|
||||
<if test="formula != null">formula,</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="modelOrder != null">model_order,</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="isMonitor != null">#{isMonitor},</if>
|
||||
<if test="isApp != null">#{isApp},</if>
|
||||
<if test="formula != null">#{formula},</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="modelOrder != null">#{modelOrder},</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="isMonitor != null">is_Monitor = #{isMonitor},</if>
|
||||
<if test="isApp != null">is_app = #{isApp},</if>
|
||||
<if test="formula != null">formula = #{formula},</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 template_id = #{templateId}
|
||||
</update>
|
||||
|
||||
<delete id="deleteThingsModelTemplateByTemplateId" parameterType="Long">
|
||||
delete from iot_things_model_template where template_id = #{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>
|
||||
|
||||
|
||||
</mapper>
|
@ -0,0 +1,98 @@
|
||||
<?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.ViewConfigMapper">
|
||||
|
||||
<resultMap type="com.fastbee.iot.domain.ViewConfig" id="ViewConfigResult">
|
||||
<result property="viewId" column="view_id" />
|
||||
<result property="viewData" column="view_data" />
|
||||
<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="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="selectViewConfigVo">
|
||||
select view_id, view_data, product_id, product_name, tenant_id, tenant_name, del_flag, create_by, create_time, update_by, update_time, remark from iot_view_config
|
||||
</sql>
|
||||
|
||||
<select id="selectViewConfigList" parameterType="com.fastbee.iot.domain.ViewConfig" resultMap="ViewConfigResult">
|
||||
<include refid="selectViewConfigVo"/>
|
||||
<where>
|
||||
<if test="viewData != null and viewData != ''"> and view_data = #{viewData}</if>
|
||||
<if test="productName != null and productName != ''"> and product_name like concat('%', #{productName}, '%')</if>
|
||||
<if test="tenantId != null "> and tenant_id = #{tenantId}</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<select id="selectViewConfigByViewId" parameterType="Long" resultMap="ViewConfigResult">
|
||||
<include refid="selectViewConfigVo"/>
|
||||
where view_id = #{viewId}
|
||||
</select>
|
||||
|
||||
<insert id="insertViewConfig" parameterType="com.fastbee.iot.domain.ViewConfig" useGeneratedKeys="true" keyProperty="viewId">
|
||||
insert into iot_view_config
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="viewData != null">view_data,</if>
|
||||
<if test="productId != null">product_id,</if>
|
||||
<if test="productName != null">product_name,</if>
|
||||
<if test="tenantId != null">tenant_id,</if>
|
||||
<if test="tenantName != null">tenant_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="viewData != null">#{viewData},</if>
|
||||
<if test="productId != null">#{productId},</if>
|
||||
<if test="productName != null">#{productName},</if>
|
||||
<if test="tenantId != null">#{tenantId},</if>
|
||||
<if test="tenantName != null">#{tenantName},</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="updateViewConfig" parameterType="com.fastbee.iot.domain.ViewConfig">
|
||||
update iot_view_config
|
||||
<trim prefix="SET" suffixOverrides=",">
|
||||
<if test="viewData != null">view_data = #{viewData},</if>
|
||||
<if test="productId != null">product_id = #{productId},</if>
|
||||
<if test="productName != null">product_name = #{productName},</if>
|
||||
<if test="tenantId != null">tenant_id = #{tenantId},</if>
|
||||
<if test="tenantName != null">tenant_name = #{tenantName},</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 view_id = #{viewId}
|
||||
</update>
|
||||
|
||||
<delete id="deleteViewConfigByViewId" parameterType="Long">
|
||||
delete from iot_view_config where view_id = #{viewId}
|
||||
</delete>
|
||||
|
||||
<delete id="deleteViewConfigByViewIds" parameterType="String">
|
||||
delete from iot_view_config where view_id in
|
||||
<foreach item="viewId" collection="array" open="(" separator="," close=")">
|
||||
#{viewId}
|
||||
</foreach>
|
||||
</delete>
|
||||
</mapper>
|
@ -0,0 +1,213 @@
|
||||
<?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.tdengine.dao.TDDeviceLogDAO">
|
||||
|
||||
<resultMap type="com.fastbee.iot.model.MonitorModel" id="MonitorResult">
|
||||
<result property="value" column="log_value" />
|
||||
<result property="time" column="ts" />
|
||||
</resultMap>
|
||||
|
||||
<resultMap type="com.fastbee.iot.domain.DeviceLog" id="DeviceLogResult">
|
||||
<result property="logType" column="log_type" />
|
||||
<result property="logValue" column="log_value" />
|
||||
<result property="mode" column="mode" />
|
||||
<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="createTime" column="ts" />
|
||||
<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="ts" />
|
||||
<result property="identity" column="identity" />
|
||||
</resultMap>
|
||||
|
||||
<update id="createDB">
|
||||
create database if not exists ${database};
|
||||
</update>
|
||||
|
||||
<update id="createSTable">
|
||||
create STABLE if not exists ${database}.device_log
|
||||
(ts timestamp,
|
||||
`log_value` BINARY(100),
|
||||
is_monitor TINYINT,
|
||||
log_type TINYINT,
|
||||
`identity` BINARY(100),
|
||||
mode TINYINT,
|
||||
remark BINARY(500))
|
||||
|
||||
TAGS(serial_number BINARY(50));
|
||||
</update>
|
||||
|
||||
<insert id="save" parameterType="com.fastbee.iot.domain.DeviceLog">
|
||||
INSERT INTO ${database}.device_${device.serialNumber} USING device_log
|
||||
TAGS (#{device.serialNumber})
|
||||
VALUES (now,
|
||||
#{device.logValue},
|
||||
#{device.isMonitor},
|
||||
#{device.logType},
|
||||
#{device.identity},
|
||||
#{device.mode},
|
||||
#{device.remark});
|
||||
</insert>
|
||||
|
||||
<insert id="saveBatch" parameterType="com.fastbee.iot.tdengine.service.model.TdLogDto">
|
||||
insert into ${database}.device_${data.serialNumber} using device_log
|
||||
TAGS (#{data.serialNumber})
|
||||
VALUES
|
||||
<foreach collection="data.list" separator=" " item="device" index="index">
|
||||
(now,
|
||||
#{device.logValue},
|
||||
#{device.isMonitor},
|
||||
#{device.logType},
|
||||
#{device.identity},
|
||||
#{device.mode},
|
||||
#{device.remark})
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
<delete id="deleteDeviceLogByDeviceNumber" parameterType="com.fastbee.iot.domain.DeviceLog">
|
||||
DROP TABLE IF EXISTS ${database}.device_${serialNumber};
|
||||
</delete>
|
||||
|
||||
<select id="selectPropertyLogCount" parameterType="com.fastbee.iot.domain.Device" resultType="Long">
|
||||
select count(mode) as propertyCount
|
||||
from ${database}.device_log
|
||||
where log_type=1
|
||||
</select>
|
||||
|
||||
<select id="selectFunctionLogCount" parameterType="com.fastbee.iot.domain.Device" resultType="Long">
|
||||
select count(mode) as functionCount
|
||||
from ${database}.device_log
|
||||
where log_type=2
|
||||
</select>
|
||||
|
||||
<select id="selectEventLogCount" parameterType="com.fastbee.iot.domain.Device" resultType="Long">
|
||||
select count(mode) as eventCount
|
||||
from ${database}.device_log
|
||||
where log_type=3
|
||||
</select>
|
||||
|
||||
<select id="selectMonitorLogCount" parameterType="com.fastbee.iot.domain.Device" resultType="Long">
|
||||
select count(mode) as monitorCount
|
||||
from ${database}.device_log
|
||||
where log_type=1 and is_monitor=1
|
||||
</select>
|
||||
|
||||
<select id="selectMonitorList" parameterType="com.fastbee.iot.domain.DeviceLog" resultMap="MonitorResult">
|
||||
select log_value, ts from ${database}.device_log
|
||||
<where>
|
||||
is_monitor=1
|
||||
<if test="device.serialNumber != null and device.serialNumber !=''"> and serial_number = #{device.serialNumber}</if>
|
||||
<if test="device.identity != null and device.identity != ''"> and identity like #{device.identity}</if>
|
||||
<if test="device.beginTime != null and device.beginTime != '' and device.endTime != null and device.endTime != ''"> and ts between #{device.beginTime} and #{device.endTime}</if>
|
||||
order by ts desc
|
||||
limit #{device.total}
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<select id="selectDeviceLogList" parameterType="com.fastbee.iot.domain.DeviceLog" resultMap="DeviceLogResult">
|
||||
select * from ${database}.device_log
|
||||
<where>
|
||||
<if test="device.isMonitor != null"> and is_monitor = #{device.isMonitor}</if>
|
||||
<if test="device.serialNumber != null and device.serialNumber !=''"> and serial_number = #{device.serialNumber}</if>
|
||||
<if test="device.logType != null "> and log_type = #{device.logType}</if>
|
||||
<if test="device.identity != null and device.identity != ''"> and identity like #{device.identity}</if>
|
||||
</where>
|
||||
order by ts desc
|
||||
</select>
|
||||
|
||||
<select id="selectHistoryList" parameterType="com.fastbee.iot.domain.DeviceLog" resultMap="HistoryResult">
|
||||
select log_value,
|
||||
ts,
|
||||
identity
|
||||
from ${database}.device_log
|
||||
<where>
|
||||
<if test="device.beginTime != null and device.beginTime != '' and device.endTime != null and device.endTime != ''">
|
||||
and ts between #{device.beginTime} and #{device.endTime}
|
||||
</if>
|
||||
<if test="device.serialNumber != null and device.serialNumber !=''"> and serial_number = #{device.serialNumber}</if>
|
||||
</where>
|
||||
order by ts desc
|
||||
</select>
|
||||
|
||||
<select id="listHistory" parameterType="com.fastbee.iot.domain.DeviceLog" resultMap="HistoryResult">
|
||||
select log_value,
|
||||
ts,
|
||||
identity
|
||||
from ${database}.device_log
|
||||
<where>
|
||||
<if test="device.beginTime != null and device.beginTime != '' and device.endTime != null and device.endTime != ''">
|
||||
and ts between #{device.beginTime} and #{device.endTime}
|
||||
</if>
|
||||
<if test="device.serialNumber != null and device.serialNumber !=''">
|
||||
and serial_number = #{device.serialNumber}
|
||||
</if>
|
||||
<if test="device.identityList != null and device.identityList.size > 0">
|
||||
and identity in
|
||||
<foreach collection="device.identityList" item="identity" open="(" separator="," close=")">
|
||||
#{identity}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="device.logType != null">
|
||||
and log_type = #{device.logType}
|
||||
</if>
|
||||
</where>
|
||||
order by ts desc
|
||||
</select>
|
||||
|
||||
<select id="listhistoryGroupByCreateTime" resultType="com.fastbee.iot.model.HistoryModel">
|
||||
select ts as time, identity, log_value as value
|
||||
from ${database}.device_log
|
||||
<where>
|
||||
<if test="device.beginTime != null and device.beginTime != '' and device.endTime != null and device.endTime != ''">
|
||||
and ts between #{device.beginTime} and #{device.endTime}
|
||||
</if>
|
||||
<if test="device.serialNumber != null and device.serialNumber !=''"> and serial_number = #{device.serialNumber}</if>
|
||||
</where>
|
||||
order by ts desc
|
||||
</select>
|
||||
|
||||
<select id="selectStatsValue" resultType="java.lang.String">
|
||||
select log_value
|
||||
from ${database}.device_log
|
||||
<where>
|
||||
<if test="device.logType != null">
|
||||
and log_type = #{device.logType}
|
||||
</if>
|
||||
<if test="device.beginTime != null and device.beginTime != '' and device.endTime != null and device.endTime != ''">
|
||||
and ts between #{device.beginTime} and #{device.endTime}
|
||||
</if>
|
||||
<if test="device.identity != null and device.identity != ''">
|
||||
and identity = #{device.identity}
|
||||
</if>
|
||||
<if test="device.serialNumber != null and device.serialNumber != ''">
|
||||
and serial_number = #{device.serialNumber}
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<select id="countThingsModelInvoke" resultType="com.fastbee.iot.model.ThingsModelLogCountVO">
|
||||
select identity identifier, count(identity) count
|
||||
from ${database}.device_log
|
||||
where log_type = 2
|
||||
<if test="dataCenterParam.serialNumber != null and dataCenterParam.serialNumber != ''">
|
||||
and serial_number = #{dataCenterParam.serialNumber}
|
||||
</if>
|
||||
<if test="dataCenterParam.beginTime != null and dataCenterParam.beginTime != '' and dataCenterParam.endTime != null and dataCenterParam.endTime != ''">
|
||||
and ts between #{dataCenterParam.beginTime} and #{dataCenterParam.endTime}
|
||||
</if>
|
||||
group by identity
|
||||
</select>
|
||||
</mapper>
|
@ -0,0 +1,115 @@
|
||||
package ${packageName}.controller;
|
||||
|
||||
import java.util.List;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import com.fastbee.common.annotation.Log;
|
||||
import com.fastbee.common.core.controller.BaseController;
|
||||
import com.fastbee.common.core.domain.AjaxResult;
|
||||
import com.fastbee.common.enums.BusinessType;
|
||||
import ${packageName}.domain.${ClassName};
|
||||
import ${packageName}.service.I${ClassName}Service;
|
||||
import com.fastbee.common.utils.poi.ExcelUtil;
|
||||
#if($table.crud || $table.sub)
|
||||
import com.fastbee.common.core.page.TableDataInfo;
|
||||
#elseif($table.tree)
|
||||
#end
|
||||
|
||||
/**
|
||||
* ${functionName}Controller
|
||||
*
|
||||
* @author ${author}
|
||||
* @date ${datetime}
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/${moduleName}/${businessName}")
|
||||
public class ${ClassName}Controller extends BaseController
|
||||
{
|
||||
@Autowired
|
||||
private I${ClassName}Service ${className}Service;
|
||||
|
||||
/**
|
||||
* 查询${functionName}列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('${permissionPrefix}:list')")
|
||||
@GetMapping("/list")
|
||||
#if($table.crud || $table.sub)
|
||||
public TableDataInfo list(${ClassName} ${className})
|
||||
{
|
||||
startPage();
|
||||
List<${ClassName}> list = ${className}Service.select${ClassName}List(${className});
|
||||
return getDataTable(list);
|
||||
}
|
||||
#elseif($table.tree)
|
||||
public AjaxResult list(${ClassName} ${className})
|
||||
{
|
||||
List<${ClassName}> list = ${className}Service.select${ClassName}List(${className});
|
||||
return AjaxResult.success(list);
|
||||
}
|
||||
#end
|
||||
|
||||
/**
|
||||
* 导出${functionName}列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('${permissionPrefix}:export')")
|
||||
@Log(title = "${functionName}", businessType = BusinessType.EXPORT)
|
||||
@PostMapping("/export")
|
||||
public void export(HttpServletResponse response, ${ClassName} ${className})
|
||||
{
|
||||
List<${ClassName}> list = ${className}Service.select${ClassName}List(${className});
|
||||
ExcelUtil<${ClassName}> util = new ExcelUtil<${ClassName}>(${ClassName}.class);
|
||||
util.exportExcel(response, list, "${functionName}数据");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取${functionName}详细信息
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('${permissionPrefix}:query')")
|
||||
@GetMapping(value = "/{${pkColumn.javaField}}")
|
||||
public AjaxResult getInfo(@PathVariable("${pkColumn.javaField}") ${pkColumn.javaType} ${pkColumn.javaField})
|
||||
{
|
||||
return AjaxResult.success(${className}Service.select${ClassName}By${pkColumn.capJavaField}(${pkColumn.javaField}));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增${functionName}
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('${permissionPrefix}:add')")
|
||||
@Log(title = "${functionName}", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
public AjaxResult add(@RequestBody ${ClassName} ${className})
|
||||
{
|
||||
return toAjax(${className}Service.insert${ClassName}(${className}));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改${functionName}
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('${permissionPrefix}:edit')")
|
||||
@Log(title = "${functionName}", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public AjaxResult edit(@RequestBody ${ClassName} ${className})
|
||||
{
|
||||
return toAjax(${className}Service.update${ClassName}(${className}));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除${functionName}
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('${permissionPrefix}:remove')")
|
||||
@Log(title = "${functionName}", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{${pkColumn.javaField}s}")
|
||||
public AjaxResult remove(@PathVariable ${pkColumn.javaType}[] ${pkColumn.javaField}s)
|
||||
{
|
||||
return toAjax(${className}Service.delete${ClassName}By${pkColumn.capJavaField}s(${pkColumn.javaField}s));
|
||||
}
|
||||
}
|
@ -0,0 +1,105 @@
|
||||
package ${packageName}.domain;
|
||||
|
||||
#foreach ($import in $importList)
|
||||
import ${import};
|
||||
#end
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
import com.fastbee.common.annotation.Excel;
|
||||
#if($table.crud || $table.sub)
|
||||
import com.fastbee.common.core.domain.BaseEntity;
|
||||
#elseif($table.tree)
|
||||
import com.fastbee.common.core.domain.TreeEntity;
|
||||
#end
|
||||
|
||||
/**
|
||||
* ${functionName}对象 ${tableName}
|
||||
*
|
||||
* @author ${author}
|
||||
* @date ${datetime}
|
||||
*/
|
||||
#if($table.crud || $table.sub)
|
||||
#set($Entity="BaseEntity")
|
||||
#elseif($table.tree)
|
||||
#set($Entity="TreeEntity")
|
||||
#end
|
||||
public class ${ClassName} extends ${Entity}
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
#foreach ($column in $columns)
|
||||
#if(!$table.isSuperColumn($column.javaField))
|
||||
/** $column.columnComment */
|
||||
#if($column.list)
|
||||
#set($parentheseIndex=$column.columnComment.indexOf("("))
|
||||
#if($parentheseIndex != -1)
|
||||
#set($comment=$column.columnComment.substring(0, $parentheseIndex))
|
||||
#else
|
||||
#set($comment=$column.columnComment)
|
||||
#end
|
||||
#if($parentheseIndex != -1)
|
||||
@Excel(name = "${comment}", readConverterExp = "$column.readConverterExp()")
|
||||
#elseif($column.javaType == 'Date')
|
||||
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||
@Excel(name = "${comment}", width = 30, dateFormat = "yyyy-MM-dd")
|
||||
#else
|
||||
@Excel(name = "${comment}")
|
||||
#end
|
||||
#end
|
||||
private $column.javaType $column.javaField;
|
||||
|
||||
#end
|
||||
#end
|
||||
#if($table.sub)
|
||||
/** $table.subTable.functionName信息 */
|
||||
private List<${subClassName}> ${subclassName}List;
|
||||
|
||||
#end
|
||||
#foreach ($column in $columns)
|
||||
#if(!$table.isSuperColumn($column.javaField))
|
||||
#if($column.javaField.length() > 2 && $column.javaField.substring(1,2).matches("[A-Z]"))
|
||||
#set($AttrName=$column.javaField)
|
||||
#else
|
||||
#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
|
||||
#end
|
||||
public void set${AttrName}($column.javaType $column.javaField)
|
||||
{
|
||||
this.$column.javaField = $column.javaField;
|
||||
}
|
||||
|
||||
public $column.javaType get${AttrName}()
|
||||
{
|
||||
return $column.javaField;
|
||||
}
|
||||
#end
|
||||
#end
|
||||
|
||||
#if($table.sub)
|
||||
public List<${subClassName}> get${subClassName}List()
|
||||
{
|
||||
return ${subclassName}List;
|
||||
}
|
||||
|
||||
public void set${subClassName}List(List<${subClassName}> ${subclassName}List)
|
||||
{
|
||||
this.${subclassName}List = ${subclassName}List;
|
||||
}
|
||||
|
||||
#end
|
||||
@Override
|
||||
public String toString() {
|
||||
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
||||
#foreach ($column in $columns)
|
||||
#if($column.javaField.length() > 2 && $column.javaField.substring(1,2).matches("[A-Z]"))
|
||||
#set($AttrName=$column.javaField)
|
||||
#else
|
||||
#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
|
||||
#end
|
||||
.append("${column.javaField}", get${AttrName}())
|
||||
#end
|
||||
#if($table.sub)
|
||||
.append("${subclassName}List", get${subClassName}List())
|
||||
#end
|
||||
.toString();
|
||||
}
|
||||
}
|
@ -0,0 +1,91 @@
|
||||
package ${packageName}.mapper;
|
||||
|
||||
import java.util.List;
|
||||
import ${packageName}.domain.${ClassName};
|
||||
#if($table.sub)
|
||||
import ${packageName}.domain.${subClassName};
|
||||
#end
|
||||
|
||||
/**
|
||||
* ${functionName}Mapper接口
|
||||
*
|
||||
* @author ${author}
|
||||
* @date ${datetime}
|
||||
*/
|
||||
public interface ${ClassName}Mapper
|
||||
{
|
||||
/**
|
||||
* 查询${functionName}
|
||||
*
|
||||
* @param ${pkColumn.javaField} ${functionName}主键
|
||||
* @return ${functionName}
|
||||
*/
|
||||
public ${ClassName} select${ClassName}By${pkColumn.capJavaField}(${pkColumn.javaType} ${pkColumn.javaField});
|
||||
|
||||
/**
|
||||
* 查询${functionName}列表
|
||||
*
|
||||
* @param ${className} ${functionName}
|
||||
* @return ${functionName}集合
|
||||
*/
|
||||
public List<${ClassName}> select${ClassName}List(${ClassName} ${className});
|
||||
|
||||
/**
|
||||
* 新增${functionName}
|
||||
*
|
||||
* @param ${className} ${functionName}
|
||||
* @return 结果
|
||||
*/
|
||||
public int insert${ClassName}(${ClassName} ${className});
|
||||
|
||||
/**
|
||||
* 修改${functionName}
|
||||
*
|
||||
* @param ${className} ${functionName}
|
||||
* @return 结果
|
||||
*/
|
||||
public int update${ClassName}(${ClassName} ${className});
|
||||
|
||||
/**
|
||||
* 删除${functionName}
|
||||
*
|
||||
* @param ${pkColumn.javaField} ${functionName}主键
|
||||
* @return 结果
|
||||
*/
|
||||
public int delete${ClassName}By${pkColumn.capJavaField}(${pkColumn.javaType} ${pkColumn.javaField});
|
||||
|
||||
/**
|
||||
* 批量删除${functionName}
|
||||
*
|
||||
* @param ${pkColumn.javaField}s 需要删除的数据主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
public int delete${ClassName}By${pkColumn.capJavaField}s(${pkColumn.javaType}[] ${pkColumn.javaField}s);
|
||||
#if($table.sub)
|
||||
|
||||
/**
|
||||
* 批量删除${subTable.functionName}
|
||||
*
|
||||
* @param ${pkColumn.javaField}s 需要删除的数据主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
public int delete${subClassName}By${subTableFkClassName}s(${pkColumn.javaType}[] ${pkColumn.javaField}s);
|
||||
|
||||
/**
|
||||
* 批量新增${subTable.functionName}
|
||||
*
|
||||
* @param ${subclassName}List ${subTable.functionName}列表
|
||||
* @return 结果
|
||||
*/
|
||||
public int batch${subClassName}(List<${subClassName}> ${subclassName}List);
|
||||
|
||||
|
||||
/**
|
||||
* 通过${functionName}主键删除${subTable.functionName}信息
|
||||
*
|
||||
* @param ${pkColumn.javaField} ${functionName}ID
|
||||
* @return 结果
|
||||
*/
|
||||
public int delete${subClassName}By${subTableFkClassName}(${pkColumn.javaType} ${pkColumn.javaField});
|
||||
#end
|
||||
}
|
@ -0,0 +1,61 @@
|
||||
package ${packageName}.service;
|
||||
|
||||
import java.util.List;
|
||||
import ${packageName}.domain.${ClassName};
|
||||
|
||||
/**
|
||||
* ${functionName}Service接口
|
||||
*
|
||||
* @author ${author}
|
||||
* @date ${datetime}
|
||||
*/
|
||||
public interface I${ClassName}Service
|
||||
{
|
||||
/**
|
||||
* 查询${functionName}
|
||||
*
|
||||
* @param ${pkColumn.javaField} ${functionName}主键
|
||||
* @return ${functionName}
|
||||
*/
|
||||
public ${ClassName} select${ClassName}By${pkColumn.capJavaField}(${pkColumn.javaType} ${pkColumn.javaField});
|
||||
|
||||
/**
|
||||
* 查询${functionName}列表
|
||||
*
|
||||
* @param ${className} ${functionName}
|
||||
* @return ${functionName}集合
|
||||
*/
|
||||
public List<${ClassName}> select${ClassName}List(${ClassName} ${className});
|
||||
|
||||
/**
|
||||
* 新增${functionName}
|
||||
*
|
||||
* @param ${className} ${functionName}
|
||||
* @return 结果
|
||||
*/
|
||||
public int insert${ClassName}(${ClassName} ${className});
|
||||
|
||||
/**
|
||||
* 修改${functionName}
|
||||
*
|
||||
* @param ${className} ${functionName}
|
||||
* @return 结果
|
||||
*/
|
||||
public int update${ClassName}(${ClassName} ${className});
|
||||
|
||||
/**
|
||||
* 批量删除${functionName}
|
||||
*
|
||||
* @param ${pkColumn.javaField}s 需要删除的${functionName}主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
public int delete${ClassName}By${pkColumn.capJavaField}s(${pkColumn.javaType}[] ${pkColumn.javaField}s);
|
||||
|
||||
/**
|
||||
* 删除${functionName}信息
|
||||
*
|
||||
* @param ${pkColumn.javaField} ${functionName}主键
|
||||
* @return 结果
|
||||
*/
|
||||
public int delete${ClassName}By${pkColumn.capJavaField}(${pkColumn.javaType} ${pkColumn.javaField});
|
||||
}
|
@ -0,0 +1,169 @@
|
||||
package ${packageName}.service.impl;
|
||||
|
||||
import java.util.List;
|
||||
#foreach ($column in $columns)
|
||||
#if($column.javaField == 'createTime' || $column.javaField == 'updateTime')
|
||||
import com.fastbee.common.utils.DateUtils;
|
||||
#break
|
||||
#end
|
||||
#end
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
#if($table.sub)
|
||||
import java.util.ArrayList;
|
||||
import com.fastbee.common.utils.StringUtils;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import ${packageName}.domain.${subClassName};
|
||||
#end
|
||||
import ${packageName}.mapper.${ClassName}Mapper;
|
||||
import ${packageName}.domain.${ClassName};
|
||||
import ${packageName}.service.I${ClassName}Service;
|
||||
|
||||
/**
|
||||
* ${functionName}Service业务层处理
|
||||
*
|
||||
* @author ${author}
|
||||
* @date ${datetime}
|
||||
*/
|
||||
@Service
|
||||
public class ${ClassName}ServiceImpl implements I${ClassName}Service
|
||||
{
|
||||
@Autowired
|
||||
private ${ClassName}Mapper ${className}Mapper;
|
||||
|
||||
/**
|
||||
* 查询${functionName}
|
||||
*
|
||||
* @param ${pkColumn.javaField} ${functionName}主键
|
||||
* @return ${functionName}
|
||||
*/
|
||||
@Override
|
||||
public ${ClassName} select${ClassName}By${pkColumn.capJavaField}(${pkColumn.javaType} ${pkColumn.javaField})
|
||||
{
|
||||
return ${className}Mapper.select${ClassName}By${pkColumn.capJavaField}(${pkColumn.javaField});
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询${functionName}列表
|
||||
*
|
||||
* @param ${className} ${functionName}
|
||||
* @return ${functionName}
|
||||
*/
|
||||
@Override
|
||||
public List<${ClassName}> select${ClassName}List(${ClassName} ${className})
|
||||
{
|
||||
return ${className}Mapper.select${ClassName}List(${className});
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增${functionName}
|
||||
*
|
||||
* @param ${className} ${functionName}
|
||||
* @return 结果
|
||||
*/
|
||||
#if($table.sub)
|
||||
@Transactional
|
||||
#end
|
||||
@Override
|
||||
public int insert${ClassName}(${ClassName} ${className})
|
||||
{
|
||||
#foreach ($column in $columns)
|
||||
#if($column.javaField == 'createTime')
|
||||
${className}.setCreateTime(DateUtils.getNowDate());
|
||||
#end
|
||||
#end
|
||||
#if($table.sub)
|
||||
int rows = ${className}Mapper.insert${ClassName}(${className});
|
||||
insert${subClassName}(${className});
|
||||
return rows;
|
||||
#else
|
||||
return ${className}Mapper.insert${ClassName}(${className});
|
||||
#end
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改${functionName}
|
||||
*
|
||||
* @param ${className} ${functionName}
|
||||
* @return 结果
|
||||
*/
|
||||
#if($table.sub)
|
||||
@Transactional
|
||||
#end
|
||||
@Override
|
||||
public int update${ClassName}(${ClassName} ${className})
|
||||
{
|
||||
#foreach ($column in $columns)
|
||||
#if($column.javaField == 'updateTime')
|
||||
${className}.setUpdateTime(DateUtils.getNowDate());
|
||||
#end
|
||||
#end
|
||||
#if($table.sub)
|
||||
${className}Mapper.delete${subClassName}By${subTableFkClassName}(${className}.get${pkColumn.capJavaField}());
|
||||
insert${subClassName}(${className});
|
||||
#end
|
||||
return ${className}Mapper.update${ClassName}(${className});
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除${functionName}
|
||||
*
|
||||
* @param ${pkColumn.javaField}s 需要删除的${functionName}主键
|
||||
* @return 结果
|
||||
*/
|
||||
#if($table.sub)
|
||||
@Transactional
|
||||
#end
|
||||
@Override
|
||||
public int delete${ClassName}By${pkColumn.capJavaField}s(${pkColumn.javaType}[] ${pkColumn.javaField}s)
|
||||
{
|
||||
#if($table.sub)
|
||||
${className}Mapper.delete${subClassName}By${subTableFkClassName}s(${pkColumn.javaField}s);
|
||||
#end
|
||||
return ${className}Mapper.delete${ClassName}By${pkColumn.capJavaField}s(${pkColumn.javaField}s);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除${functionName}信息
|
||||
*
|
||||
* @param ${pkColumn.javaField} ${functionName}主键
|
||||
* @return 结果
|
||||
*/
|
||||
#if($table.sub)
|
||||
@Transactional
|
||||
#end
|
||||
@Override
|
||||
public int delete${ClassName}By${pkColumn.capJavaField}(${pkColumn.javaType} ${pkColumn.javaField})
|
||||
{
|
||||
#if($table.sub)
|
||||
${className}Mapper.delete${subClassName}By${subTableFkClassName}(${pkColumn.javaField});
|
||||
#end
|
||||
return ${className}Mapper.delete${ClassName}By${pkColumn.capJavaField}(${pkColumn.javaField});
|
||||
}
|
||||
#if($table.sub)
|
||||
|
||||
/**
|
||||
* 新增${subTable.functionName}信息
|
||||
*
|
||||
* @param ${className} ${functionName}对象
|
||||
*/
|
||||
public void insert${subClassName}(${ClassName} ${className})
|
||||
{
|
||||
List<${subClassName}> ${subclassName}List = ${className}.get${subClassName}List();
|
||||
${pkColumn.javaType} ${pkColumn.javaField} = ${className}.get${pkColumn.capJavaField}();
|
||||
if (StringUtils.isNotNull(${subclassName}List))
|
||||
{
|
||||
List<${subClassName}> list = new ArrayList<${subClassName}>();
|
||||
for (${subClassName} ${subclassName} : ${subclassName}List)
|
||||
{
|
||||
${subclassName}.set${subTableFkClassName}(${pkColumn.javaField});
|
||||
list.add(${subclassName});
|
||||
}
|
||||
if (list.size() > 0)
|
||||
{
|
||||
${className}Mapper.batch${subClassName}(list);
|
||||
}
|
||||
}
|
||||
}
|
||||
#end
|
||||
}
|
@ -0,0 +1,76 @@
|
||||
package ${packageName}.domain;
|
||||
|
||||
#foreach ($import in $subImportList)
|
||||
import ${import};
|
||||
#end
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
import com.fastbee.common.annotation.Excel;
|
||||
import com.fastbee.common.core.domain.BaseEntity;
|
||||
|
||||
/**
|
||||
* ${subTable.functionName}对象 ${subTableName}
|
||||
*
|
||||
* @author ${author}
|
||||
* @date ${datetime}
|
||||
*/
|
||||
public class ${subClassName} extends BaseEntity
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
#foreach ($column in $subTable.columns)
|
||||
#if(!$table.isSuperColumn($column.javaField))
|
||||
/** $column.columnComment */
|
||||
#if($column.list)
|
||||
#set($parentheseIndex=$column.columnComment.indexOf("("))
|
||||
#if($parentheseIndex != -1)
|
||||
#set($comment=$column.columnComment.substring(0, $parentheseIndex))
|
||||
#else
|
||||
#set($comment=$column.columnComment)
|
||||
#end
|
||||
#if($parentheseIndex != -1)
|
||||
@Excel(name = "${comment}", readConverterExp = "$column.readConverterExp()")
|
||||
#elseif($column.javaType == 'Date')
|
||||
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||
@Excel(name = "${comment}", width = 30, dateFormat = "yyyy-MM-dd")
|
||||
#else
|
||||
@Excel(name = "${comment}")
|
||||
#end
|
||||
#end
|
||||
private $column.javaType $column.javaField;
|
||||
|
||||
#end
|
||||
#end
|
||||
#foreach ($column in $subTable.columns)
|
||||
#if(!$table.isSuperColumn($column.javaField))
|
||||
#if($column.javaField.length() > 2 && $column.javaField.substring(1,2).matches("[A-Z]"))
|
||||
#set($AttrName=$column.javaField)
|
||||
#else
|
||||
#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
|
||||
#end
|
||||
public void set${AttrName}($column.javaType $column.javaField)
|
||||
{
|
||||
this.$column.javaField = $column.javaField;
|
||||
}
|
||||
|
||||
public $column.javaType get${AttrName}()
|
||||
{
|
||||
return $column.javaField;
|
||||
}
|
||||
#end
|
||||
#end
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
||||
#foreach ($column in $subTable.columns)
|
||||
#if($column.javaField.length() > 2 && $column.javaField.substring(1,2).matches("[A-Z]"))
|
||||
#set($AttrName=$column.javaField)
|
||||
#else
|
||||
#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
|
||||
#end
|
||||
.append("${column.javaField}", get${AttrName}())
|
||||
#end
|
||||
.toString();
|
||||
}
|
||||
}
|
@ -0,0 +1,44 @@
|
||||
import request from '@/utils/request'
|
||||
|
||||
// 查询${functionName}列表
|
||||
export function list${BusinessName}(query) {
|
||||
return request({
|
||||
url: '/${moduleName}/${businessName}/list',
|
||||
method: 'get',
|
||||
params: query
|
||||
})
|
||||
}
|
||||
|
||||
// 查询${functionName}详细
|
||||
export function get${BusinessName}(${pkColumn.javaField}) {
|
||||
return request({
|
||||
url: '/${moduleName}/${businessName}/' + ${pkColumn.javaField},
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
|
||||
// 新增${functionName}
|
||||
export function add${BusinessName}(data) {
|
||||
return request({
|
||||
url: '/${moduleName}/${businessName}',
|
||||
method: 'post',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
|
||||
// 修改${functionName}
|
||||
export function update${BusinessName}(data) {
|
||||
return request({
|
||||
url: '/${moduleName}/${businessName}',
|
||||
method: 'put',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
|
||||
// 删除${functionName}
|
||||
export function del${BusinessName}(${pkColumn.javaField}) {
|
||||
return request({
|
||||
url: '/${moduleName}/${businessName}/' + ${pkColumn.javaField},
|
||||
method: 'delete'
|
||||
})
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
-- 菜单 SQL
|
||||
insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark)
|
||||
values('${functionName}', '${parentMenuId}', '1', '${businessName}', '${moduleName}/${businessName}/index', 1, 0, 'C', '0', '0', '${permissionPrefix}:list', '#', 'admin', sysdate(), '', null, '${functionName}菜单');
|
||||
|
||||
-- 按钮父菜单ID
|
||||
SELECT @parentId := LAST_INSERT_ID();
|
||||
|
||||
-- 按钮 SQL
|
||||
insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark)
|
||||
values('${functionName}查询', @parentId, '1', '#', '', 1, 0, 'F', '0', '0', '${permissionPrefix}:query', '#', 'admin', sysdate(), '', null, '');
|
||||
|
||||
insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark)
|
||||
values('${functionName}新增', @parentId, '2', '#', '', 1, 0, 'F', '0', '0', '${permissionPrefix}:add', '#', 'admin', sysdate(), '', null, '');
|
||||
|
||||
insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark)
|
||||
values('${functionName}修改', @parentId, '3', '#', '', 1, 0, 'F', '0', '0', '${permissionPrefix}:edit', '#', 'admin', sysdate(), '', null, '');
|
||||
|
||||
insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark)
|
||||
values('${functionName}删除', @parentId, '4', '#', '', 1, 0, 'F', '0', '0', '${permissionPrefix}:remove', '#', 'admin', sysdate(), '', null, '');
|
||||
|
||||
insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark)
|
||||
values('${functionName}导出', @parentId, '5', '#', '', 1, 0, 'F', '0', '0', '${permissionPrefix}:export', '#', 'admin', sysdate(), '', null, '');
|
@ -0,0 +1,476 @@
|
||||
<template>
|
||||
<div class="app-container">
|
||||
<el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
|
||||
#foreach($column in $columns)
|
||||
#if($column.query)
|
||||
#set($dictType=$column.dictType)
|
||||
#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
|
||||
#set($parentheseIndex=$column.columnComment.indexOf("("))
|
||||
#if($parentheseIndex != -1)
|
||||
#set($comment=$column.columnComment.substring(0, $parentheseIndex))
|
||||
#else
|
||||
#set($comment=$column.columnComment)
|
||||
#end
|
||||
#if($column.htmlType == "input")
|
||||
<el-form-item label="${comment}" prop="${column.javaField}">
|
||||
<el-input
|
||||
v-model="queryParams.${column.javaField}"
|
||||
placeholder="请输入${comment}"
|
||||
clearable
|
||||
size="small"
|
||||
@keyup.enter.native="handleQuery"
|
||||
/>
|
||||
</el-form-item>
|
||||
#elseif(($column.htmlType == "select" || $column.htmlType == "radio") && "" != $dictType)
|
||||
<el-form-item label="${comment}" prop="${column.javaField}">
|
||||
<el-select v-model="queryParams.${column.javaField}" placeholder="请选择${comment}" clearable size="small">
|
||||
<el-option
|
||||
v-for="dict in dict.type.${dictType}"
|
||||
:key="dict.value"
|
||||
:label="dict.label"
|
||||
:value="dict.value"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
#elseif(($column.htmlType == "select" || $column.htmlType == "radio") && $dictType)
|
||||
<el-form-item label="${comment}" prop="${column.javaField}">
|
||||
<el-select v-model="queryParams.${column.javaField}" placeholder="请选择${comment}" clearable size="small">
|
||||
<el-option label="请选择字典生成" value="" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
#elseif($column.htmlType == "datetime" && $column.queryType != "BETWEEN")
|
||||
<el-form-item label="${comment}" prop="${column.javaField}">
|
||||
<el-date-picker clearable size="small"
|
||||
v-model="queryParams.${column.javaField}"
|
||||
type="date"
|
||||
value-format="yyyy-MM-dd"
|
||||
placeholder="选择${comment}">
|
||||
</el-date-picker>
|
||||
</el-form-item>
|
||||
#elseif($column.htmlType == "datetime" && $column.queryType == "BETWEEN")
|
||||
<el-form-item label="${comment}">
|
||||
<el-date-picker
|
||||
v-model="daterange${AttrName}"
|
||||
size="small"
|
||||
style="width: 240px"
|
||||
value-format="yyyy-MM-dd"
|
||||
type="daterange"
|
||||
range-separator="-"
|
||||
start-placeholder="开始日期"
|
||||
end-placeholder="结束日期"
|
||||
></el-date-picker>
|
||||
</el-form-item>
|
||||
#end
|
||||
#end
|
||||
#end
|
||||
<el-form-item>
|
||||
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
|
||||
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
|
||||
<el-row :gutter="10" class="mb8">
|
||||
<el-col :span="1.5">
|
||||
<el-button
|
||||
type="primary"
|
||||
plain
|
||||
icon="el-icon-plus"
|
||||
size="mini"
|
||||
@click="handleAdd"
|
||||
v-hasPermi="['${moduleName}:${businessName}:add']"
|
||||
>新增</el-button>
|
||||
</el-col>
|
||||
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
|
||||
</el-row>
|
||||
|
||||
<el-table
|
||||
v-loading="loading"
|
||||
:data="${businessName}List"
|
||||
row-key="${treeCode}"
|
||||
default-expand-all
|
||||
:tree-props="{children: 'children', hasChildren: 'hasChildren'}"
|
||||
>
|
||||
#foreach($column in $columns)
|
||||
#set($javaField=$column.javaField)
|
||||
#set($parentheseIndex=$column.columnComment.indexOf("("))
|
||||
#if($parentheseIndex != -1)
|
||||
#set($comment=$column.columnComment.substring(0, $parentheseIndex))
|
||||
#else
|
||||
#set($comment=$column.columnComment)
|
||||
#end
|
||||
#if($column.pk)
|
||||
#elseif($column.list && $column.htmlType == "datetime")
|
||||
<el-table-column label="${comment}" align="center" prop="${javaField}" width="180">
|
||||
<template slot-scope="scope">
|
||||
<span>{{ parseTime(scope.row.${javaField}, '{y}-{m}-{d}') }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
#elseif($column.list && "" != $column.dictType)
|
||||
<el-table-column label="${comment}" align="center" prop="${javaField}">
|
||||
<template slot-scope="scope">
|
||||
#if($column.htmlType == "checkbox")
|
||||
<dict-tag :options="dict.type.${column.dictType}" :value="scope.row.${javaField} ? scope.row.${javaField}.split(',') : []"/>
|
||||
#else
|
||||
<dict-tag :options="dict.type.${column.dictType}" :value="scope.row.${javaField}"/>
|
||||
#end
|
||||
</template>
|
||||
</el-table-column>
|
||||
#elseif($column.list && "" != $javaField)
|
||||
#if(${foreach.index} == 1)
|
||||
<el-table-column label="${comment}" prop="${javaField}" />
|
||||
#else
|
||||
<el-table-column label="${comment}" align="center" prop="${javaField}" />
|
||||
#end
|
||||
#end
|
||||
#end
|
||||
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
|
||||
<template slot-scope="scope">
|
||||
<el-button
|
||||
size="mini"
|
||||
type="text"
|
||||
icon="el-icon-edit"
|
||||
@click="handleUpdate(scope.row)"
|
||||
v-hasPermi="['${moduleName}:${businessName}:edit']"
|
||||
>修改</el-button>
|
||||
<el-button
|
||||
size="mini"
|
||||
type="text"
|
||||
icon="el-icon-plus"
|
||||
@click="handleAdd(scope.row)"
|
||||
v-hasPermi="['${moduleName}:${businessName}:add']"
|
||||
>新增</el-button>
|
||||
<el-button
|
||||
size="mini"
|
||||
type="text"
|
||||
icon="el-icon-delete"
|
||||
@click="handleDelete(scope.row)"
|
||||
v-hasPermi="['${moduleName}:${businessName}:remove']"
|
||||
>删除</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
|
||||
<!-- 添加或修改${functionName}对话框 -->
|
||||
<el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
|
||||
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
|
||||
#foreach($column in $columns)
|
||||
#set($field=$column.javaField)
|
||||
#if($column.insert && !$column.pk)
|
||||
#if(($column.usableColumn) || (!$column.superColumn))
|
||||
#set($parentheseIndex=$column.columnComment.indexOf("("))
|
||||
#if($parentheseIndex != -1)
|
||||
#set($comment=$column.columnComment.substring(0, $parentheseIndex))
|
||||
#else
|
||||
#set($comment=$column.columnComment)
|
||||
#end
|
||||
#set($dictType=$column.dictType)
|
||||
#if("" != $treeParentCode && $column.javaField == $treeParentCode)
|
||||
<el-form-item label="${comment}" prop="${treeParentCode}">
|
||||
<treeselect v-model="form.${treeParentCode}" :options="${businessName}Options" :normalizer="normalizer" placeholder="请选择${comment}" />
|
||||
</el-form-item>
|
||||
#elseif($column.htmlType == "input")
|
||||
<el-form-item label="${comment}" prop="${field}">
|
||||
<el-input v-model="form.${field}" placeholder="请输入${comment}" />
|
||||
</el-form-item>
|
||||
#elseif($column.htmlType == "imageUpload")
|
||||
<el-form-item label="${comment}">
|
||||
<imageUpload v-model="form.${field}"/>
|
||||
</el-form-item>
|
||||
#elseif($column.htmlType == "fileUpload")
|
||||
<el-form-item label="${comment}">
|
||||
<fileUpload v-model="form.${field}"/>
|
||||
</el-form-item>
|
||||
#elseif($column.htmlType == "editor")
|
||||
<el-form-item label="${comment}">
|
||||
<editor v-model="form.${field}" :min-height="192"/>
|
||||
</el-form-item>
|
||||
#elseif($column.htmlType == "select" && "" != $dictType)
|
||||
<el-form-item label="${comment}" prop="${field}">
|
||||
<el-select v-model="form.${field}" placeholder="请选择${comment}">
|
||||
<el-option
|
||||
v-for="dict in dict.type.${dictType}"
|
||||
:key="dict.value"
|
||||
:label="dict.label"
|
||||
#if($column.javaType == "Integer" || $column.javaType == "Long"):value="parseInt(dict.value)"#else:value="dict.value"#end
|
||||
|
||||
></el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
#elseif($column.htmlType == "select" && $dictType)
|
||||
<el-form-item label="${comment}" prop="${field}">
|
||||
<el-select v-model="form.${field}" placeholder="请选择${comment}">
|
||||
<el-option label="请选择字典生成" value="" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
#elseif($column.htmlType == "checkbox" && "" != $dictType)
|
||||
<el-form-item label="${comment}">
|
||||
<el-checkbox-group v-model="form.${field}">
|
||||
<el-checkbox
|
||||
v-for="dict in dict.type.${dictType}"
|
||||
:key="dict.value"
|
||||
:label="dict.value">
|
||||
{{dict.label}}
|
||||
</el-checkbox>
|
||||
</el-checkbox-group>
|
||||
</el-form-item>
|
||||
#elseif($column.htmlType == "checkbox" && $dictType)
|
||||
<el-form-item label="${comment}">
|
||||
<el-checkbox-group v-model="form.${field}">
|
||||
<el-checkbox>请选择字典生成</el-checkbox>
|
||||
</el-checkbox-group>
|
||||
</el-form-item>
|
||||
#elseif($column.htmlType == "radio" && "" != $dictType)
|
||||
<el-form-item label="${comment}">
|
||||
<el-radio-group v-model="form.${field}">
|
||||
<el-radio
|
||||
v-for="dict in dict.type.${dictType}"
|
||||
:key="dict.value"
|
||||
#if($column.javaType == "Integer" || $column.javaType == "Long"):label="parseInt(dict.value)"#else:label="dict.value"#end
|
||||
|
||||
>{{dict.label}}</el-radio>
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
#elseif($column.htmlType == "radio" && $dictType)
|
||||
<el-form-item label="${comment}">
|
||||
<el-radio-group v-model="form.${field}">
|
||||
<el-radio label="1">请选择字典生成</el-radio>
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
#elseif($column.htmlType == "datetime")
|
||||
<el-form-item label="${comment}" prop="${field}">
|
||||
<el-date-picker clearable size="small"
|
||||
v-model="form.${field}"
|
||||
type="date"
|
||||
value-format="yyyy-MM-dd"
|
||||
placeholder="选择${comment}">
|
||||
</el-date-picker>
|
||||
</el-form-item>
|
||||
#elseif($column.htmlType == "textarea")
|
||||
<el-form-item label="${comment}" prop="${field}">
|
||||
<el-input v-model="form.${field}" type="textarea" placeholder="请输入内容" />
|
||||
</el-form-item>
|
||||
#end
|
||||
#end
|
||||
#end
|
||||
#end
|
||||
</el-form>
|
||||
<div slot="footer" class="dialog-footer">
|
||||
<el-button type="primary" @click="submitForm">确 定</el-button>
|
||||
<el-button @click="cancel">取 消</el-button>
|
||||
</div>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { list${BusinessName}, get${BusinessName}, del${BusinessName}, add${BusinessName}, update${BusinessName} } from "@/api/${moduleName}/${businessName}";
|
||||
import Treeselect from "@riophae/vue-treeselect";
|
||||
import "@riophae/vue-treeselect/dist/vue-treeselect.css";
|
||||
|
||||
export default {
|
||||
name: "${BusinessName}",
|
||||
#if(${dicts} != '')
|
||||
dicts: [${dicts}],
|
||||
#end
|
||||
components: {
|
||||
Treeselect
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
// 遮罩层
|
||||
loading: true,
|
||||
// 显示搜索条件
|
||||
showSearch: true,
|
||||
// ${functionName}表格数据
|
||||
${businessName}List: [],
|
||||
// ${functionName}树选项
|
||||
${businessName}Options: [],
|
||||
// 弹出层标题
|
||||
title: "",
|
||||
// 是否显示弹出层
|
||||
open: false,
|
||||
#foreach ($column in $columns)
|
||||
#if($column.htmlType == "datetime" && $column.queryType == "BETWEEN")
|
||||
#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
|
||||
// $comment时间范围
|
||||
daterange${AttrName}: [],
|
||||
#end
|
||||
#end
|
||||
// 查询参数
|
||||
queryParams: {
|
||||
#foreach ($column in $columns)
|
||||
#if($column.query)
|
||||
$column.javaField: null#if($foreach.count != $columns.size()),#end
|
||||
#end
|
||||
#end
|
||||
},
|
||||
// 表单参数
|
||||
form: {},
|
||||
// 表单校验
|
||||
rules: {
|
||||
#foreach ($column in $columns)
|
||||
#if($column.required)
|
||||
#set($parentheseIndex=$column.columnComment.indexOf("("))
|
||||
#if($parentheseIndex != -1)
|
||||
#set($comment=$column.columnComment.substring(0, $parentheseIndex))
|
||||
#else
|
||||
#set($comment=$column.columnComment)
|
||||
#end
|
||||
$column.javaField: [
|
||||
{ required: true, message: "$comment不能为空", trigger: #if($column.htmlType == "select")"change"#else"blur"#end }
|
||||
]#if($foreach.count != $columns.size()),#end
|
||||
#end
|
||||
#end
|
||||
}
|
||||
};
|
||||
},
|
||||
created() {
|
||||
this.getList();
|
||||
},
|
||||
methods: {
|
||||
/** 查询${functionName}列表 */
|
||||
getList() {
|
||||
this.loading = true;
|
||||
#foreach ($column in $columns)
|
||||
#if($column.htmlType == "datetime" && $column.queryType == "BETWEEN")
|
||||
this.queryParams.params = {};
|
||||
#break
|
||||
#end
|
||||
#end
|
||||
#foreach ($column in $columns)
|
||||
#if($column.htmlType == "datetime" && $column.queryType == "BETWEEN")
|
||||
#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
|
||||
if (null != this.daterange${AttrName} && '' != this.daterange${AttrName}) {
|
||||
this.queryParams.params["begin${AttrName}"] = this.daterange${AttrName}[0];
|
||||
this.queryParams.params["end${AttrName}"] = this.daterange${AttrName}[1];
|
||||
}
|
||||
#end
|
||||
#end
|
||||
list${BusinessName}(this.queryParams).then(response => {
|
||||
this.${businessName}List = this.handleTree(response.data, "${treeCode}", "${treeParentCode}");
|
||||
this.loading = false;
|
||||
});
|
||||
},
|
||||
/** 转换${functionName}数据结构 */
|
||||
normalizer(node) {
|
||||
if (node.children && !node.children.length) {
|
||||
delete node.children;
|
||||
}
|
||||
return {
|
||||
id: node.${treeCode},
|
||||
label: node.${treeName},
|
||||
children: node.children
|
||||
};
|
||||
},
|
||||
/** 查询${functionName}下拉树结构 */
|
||||
getTreeselect() {
|
||||
list${BusinessName}().then(response => {
|
||||
this.${businessName}Options = [];
|
||||
const data = { ${treeCode}: 0, ${treeName}: '顶级节点', children: [] };
|
||||
data.children = this.handleTree(response.data, "${treeCode}", "${treeParentCode}");
|
||||
this.${businessName}Options.push(data);
|
||||
});
|
||||
},
|
||||
// 取消按钮
|
||||
cancel() {
|
||||
this.open = false;
|
||||
this.reset();
|
||||
},
|
||||
// 表单重置
|
||||
reset() {
|
||||
this.form = {
|
||||
#foreach ($column in $columns)
|
||||
#if($column.htmlType == "radio")
|
||||
$column.javaField: #if($column.javaType == "Integer" || $column.javaType == "Long")0#else"0"#end#if($foreach.count != $columns.size()),#end
|
||||
|
||||
#elseif($column.htmlType == "checkbox")
|
||||
$column.javaField: []#if($foreach.count != $columns.size()),#end
|
||||
#else
|
||||
$column.javaField: null#if($foreach.count != $columns.size()),#end
|
||||
#end
|
||||
#end
|
||||
};
|
||||
this.resetForm("form");
|
||||
},
|
||||
/** 搜索按钮操作 */
|
||||
handleQuery() {
|
||||
this.getList();
|
||||
},
|
||||
/** 重置按钮操作 */
|
||||
resetQuery() {
|
||||
#foreach ($column in $columns)
|
||||
#if($column.htmlType == "datetime" && $column.queryType == "BETWEEN")
|
||||
#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
|
||||
this.daterange${AttrName} = [];
|
||||
#end
|
||||
#end
|
||||
this.resetForm("queryForm");
|
||||
this.handleQuery();
|
||||
},
|
||||
/** 新增按钮操作 */
|
||||
handleAdd(row) {
|
||||
this.reset();
|
||||
this.getTreeselect();
|
||||
if (row != null && row.${treeCode}) {
|
||||
this.form.${treeParentCode} = row.${treeCode};
|
||||
} else {
|
||||
this.form.${treeParentCode} = 0;
|
||||
}
|
||||
this.open = true;
|
||||
this.title = "添加${functionName}";
|
||||
},
|
||||
/** 修改按钮操作 */
|
||||
handleUpdate(row) {
|
||||
this.reset();
|
||||
this.getTreeselect();
|
||||
if (row != null) {
|
||||
this.form.${treeParentCode} = row.${treeCode};
|
||||
}
|
||||
get${BusinessName}(row.${pkColumn.javaField}).then(response => {
|
||||
this.form = response.data;
|
||||
#foreach ($column in $columns)
|
||||
#if($column.htmlType == "checkbox")
|
||||
this.form.$column.javaField = this.form.${column.javaField}.split(",");
|
||||
#end
|
||||
#end
|
||||
this.open = true;
|
||||
this.title = "修改${functionName}";
|
||||
});
|
||||
},
|
||||
/** 提交按钮 */
|
||||
submitForm() {
|
||||
this.#[[$]]#refs["form"].validate(valid => {
|
||||
if (valid) {
|
||||
#foreach ($column in $columns)
|
||||
#if($column.htmlType == "checkbox")
|
||||
this.form.$column.javaField = this.form.${column.javaField}.join(",");
|
||||
#end
|
||||
#end
|
||||
if (this.form.${pkColumn.javaField} != null) {
|
||||
update${BusinessName}(this.form).then(response => {
|
||||
this.#[[$modal]]#.msgSuccess("修改成功");
|
||||
this.open = false;
|
||||
this.getList();
|
||||
});
|
||||
} else {
|
||||
add${BusinessName}(this.form).then(response => {
|
||||
this.#[[$modal]]#.msgSuccess("新增成功");
|
||||
this.open = false;
|
||||
this.getList();
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
/** 删除按钮操作 */
|
||||
handleDelete(row) {
|
||||
this.#[[$modal]]#.confirm('是否确认删除${functionName}编号为"' + row.${pkColumn.javaField} + '"的数据项?').then(function() {
|
||||
return del${BusinessName}(row.${pkColumn.javaField});
|
||||
}).then(() => {
|
||||
this.getList();
|
||||
this.#[[$modal]]#.msgSuccess("删除成功");
|
||||
}).catch(() => {});
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
@ -0,0 +1,567 @@
|
||||
<template>
|
||||
<div class="app-container">
|
||||
<el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
|
||||
#foreach($column in $columns)
|
||||
#if($column.query)
|
||||
#set($dictType=$column.dictType)
|
||||
#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
|
||||
#set($parentheseIndex=$column.columnComment.indexOf("("))
|
||||
#if($parentheseIndex != -1)
|
||||
#set($comment=$column.columnComment.substring(0, $parentheseIndex))
|
||||
#else
|
||||
#set($comment=$column.columnComment)
|
||||
#end
|
||||
#if($column.htmlType == "input")
|
||||
<el-form-item label="${comment}" prop="${column.javaField}">
|
||||
<el-input
|
||||
v-model="queryParams.${column.javaField}"
|
||||
placeholder="请输入${comment}"
|
||||
clearable
|
||||
size="small"
|
||||
@keyup.enter.native="handleQuery"
|
||||
/>
|
||||
</el-form-item>
|
||||
#elseif(($column.htmlType == "select" || $column.htmlType == "radio") && "" != $dictType)
|
||||
<el-form-item label="${comment}" prop="${column.javaField}">
|
||||
<el-select v-model="queryParams.${column.javaField}" placeholder="请选择${comment}" clearable size="small">
|
||||
<el-option
|
||||
v-for="dict in dict.type.${dictType}"
|
||||
:key="dict.value"
|
||||
:label="dict.label"
|
||||
:value="dict.value"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
#elseif(($column.htmlType == "select" || $column.htmlType == "radio") && $dictType)
|
||||
<el-form-item label="${comment}" prop="${column.javaField}">
|
||||
<el-select v-model="queryParams.${column.javaField}" placeholder="请选择${comment}" clearable size="small">
|
||||
<el-option label="请选择字典生成" value="" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
#elseif($column.htmlType == "datetime" && $column.queryType != "BETWEEN")
|
||||
<el-form-item label="${comment}" prop="${column.javaField}">
|
||||
<el-date-picker clearable size="small"
|
||||
v-model="queryParams.${column.javaField}"
|
||||
type="date"
|
||||
value-format="yyyy-MM-dd"
|
||||
placeholder="选择${comment}">
|
||||
</el-date-picker>
|
||||
</el-form-item>
|
||||
#elseif($column.htmlType == "datetime" && $column.queryType == "BETWEEN")
|
||||
<el-form-item label="${comment}">
|
||||
<el-date-picker
|
||||
v-model="daterange${AttrName}"
|
||||
size="small"
|
||||
style="width: 240px"
|
||||
value-format="yyyy-MM-dd"
|
||||
type="daterange"
|
||||
range-separator="-"
|
||||
start-placeholder="开始日期"
|
||||
end-placeholder="结束日期"
|
||||
></el-date-picker>
|
||||
</el-form-item>
|
||||
#end
|
||||
#end
|
||||
#end
|
||||
<el-form-item>
|
||||
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
|
||||
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
|
||||
<el-row :gutter="10" class="mb8">
|
||||
<el-col :span="1.5">
|
||||
<el-button
|
||||
type="primary"
|
||||
plain
|
||||
icon="el-icon-plus"
|
||||
size="mini"
|
||||
@click="handleAdd"
|
||||
v-hasPermi="['${moduleName}:${businessName}:add']"
|
||||
>新增</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button
|
||||
type="success"
|
||||
plain
|
||||
icon="el-icon-edit"
|
||||
size="mini"
|
||||
:disabled="single"
|
||||
@click="handleUpdate"
|
||||
v-hasPermi="['${moduleName}:${businessName}:edit']"
|
||||
>修改</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button
|
||||
type="danger"
|
||||
plain
|
||||
icon="el-icon-delete"
|
||||
size="mini"
|
||||
:disabled="multiple"
|
||||
@click="handleDelete"
|
||||
v-hasPermi="['${moduleName}:${businessName}:remove']"
|
||||
>删除</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button
|
||||
type="warning"
|
||||
plain
|
||||
icon="el-icon-download"
|
||||
size="mini"
|
||||
@click="handleExport"
|
||||
v-hasPermi="['${moduleName}:${businessName}:export']"
|
||||
>导出</el-button>
|
||||
</el-col>
|
||||
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
|
||||
</el-row>
|
||||
|
||||
<el-table v-loading="loading" :data="${businessName}List" @selection-change="handleSelectionChange">
|
||||
<el-table-column type="selection" width="55" align="center" />
|
||||
#foreach($column in $columns)
|
||||
#set($javaField=$column.javaField)
|
||||
#set($parentheseIndex=$column.columnComment.indexOf("("))
|
||||
#if($parentheseIndex != -1)
|
||||
#set($comment=$column.columnComment.substring(0, $parentheseIndex))
|
||||
#else
|
||||
#set($comment=$column.columnComment)
|
||||
#end
|
||||
#if($column.pk)
|
||||
<el-table-column label="${comment}" align="center" prop="${javaField}" />
|
||||
#elseif($column.list && $column.htmlType == "datetime")
|
||||
<el-table-column label="${comment}" align="center" prop="${javaField}" width="180">
|
||||
<template slot-scope="scope">
|
||||
<span>{{ parseTime(scope.row.${javaField}, '{y}-{m}-{d}') }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
#elseif($column.list && "" != $column.dictType)
|
||||
<el-table-column label="${comment}" align="center" prop="${javaField}">
|
||||
<template slot-scope="scope">
|
||||
#if($column.htmlType == "checkbox")
|
||||
<dict-tag :options="dict.type.${column.dictType}" :value="scope.row.${javaField} ? scope.row.${javaField}.split(',') : []"/>
|
||||
#else
|
||||
<dict-tag :options="dict.type.${column.dictType}" :value="scope.row.${javaField}"/>
|
||||
#end
|
||||
</template>
|
||||
</el-table-column>
|
||||
#elseif($column.list && "" != $javaField)
|
||||
<el-table-column label="${comment}" align="center" prop="${javaField}" />
|
||||
#end
|
||||
#end
|
||||
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
|
||||
<template slot-scope="scope">
|
||||
<el-button
|
||||
size="mini"
|
||||
type="text"
|
||||
icon="el-icon-edit"
|
||||
@click="handleUpdate(scope.row)"
|
||||
v-hasPermi="['${moduleName}:${businessName}:edit']"
|
||||
>修改</el-button>
|
||||
<el-button
|
||||
size="mini"
|
||||
type="text"
|
||||
icon="el-icon-delete"
|
||||
@click="handleDelete(scope.row)"
|
||||
v-hasPermi="['${moduleName}:${businessName}:remove']"
|
||||
>删除</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
|
||||
<pagination
|
||||
v-show="total>0"
|
||||
:total="total"
|
||||
:page.sync="queryParams.pageNum"
|
||||
:limit.sync="queryParams.pageSize"
|
||||
@pagination="getList"
|
||||
/>
|
||||
|
||||
<!-- 添加或修改${functionName}对话框 -->
|
||||
<el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
|
||||
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
|
||||
#foreach($column in $columns)
|
||||
#set($field=$column.javaField)
|
||||
#if($column.insert && !$column.pk)
|
||||
#if(($column.usableColumn) || (!$column.superColumn))
|
||||
#set($parentheseIndex=$column.columnComment.indexOf("("))
|
||||
#if($parentheseIndex != -1)
|
||||
#set($comment=$column.columnComment.substring(0, $parentheseIndex))
|
||||
#else
|
||||
#set($comment=$column.columnComment)
|
||||
#end
|
||||
#set($dictType=$column.dictType)
|
||||
#if($column.htmlType == "input")
|
||||
<el-form-item label="${comment}" prop="${field}">
|
||||
<el-input v-model="form.${field}" placeholder="请输入${comment}" />
|
||||
</el-form-item>
|
||||
#elseif($column.htmlType == "image")
|
||||
<el-form-item label="${comment}">
|
||||
<imageUpload v-model="form.${field}"/>
|
||||
</el-form-item>
|
||||
#elseif($column.htmlType == "fileUpload")
|
||||
<el-form-item label="${comment}">
|
||||
<fileUpload v-model="form.${field}"/>
|
||||
</el-form-item>
|
||||
#elseif($column.htmlType == "editor")
|
||||
<el-form-item label="${comment}">
|
||||
<editor v-model="form.${field}" :min-height="192"/>
|
||||
</el-form-item>
|
||||
#elseif($column.htmlType == "select" && "" != $dictType)
|
||||
<el-form-item label="${comment}" prop="${field}">
|
||||
<el-select v-model="form.${field}" placeholder="请选择${comment}">
|
||||
<el-option
|
||||
v-for="dict in dict.type.${dictType}"
|
||||
:key="dict.value"
|
||||
:label="dict.label"
|
||||
#if($column.javaType == "Integer" || $column.javaType == "Long"):value="parseInt(dict.value)"#else:value="dict.value"#end
|
||||
|
||||
></el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
#elseif($column.htmlType == "select" && $dictType)
|
||||
<el-form-item label="${comment}" prop="${field}">
|
||||
<el-select v-model="form.${field}" placeholder="请选择${comment}">
|
||||
<el-option label="请选择字典生成" value="" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
#elseif($column.htmlType == "checkbox" && "" != $dictType)
|
||||
<el-form-item label="${comment}">
|
||||
<el-checkbox-group v-model="form.${field}">
|
||||
<el-checkbox
|
||||
v-for="dict in dict.type.${dictType}"
|
||||
:key="dict.value"
|
||||
:label="dict.value">
|
||||
{{dict.label}}
|
||||
</el-checkbox>
|
||||
</el-checkbox-group>
|
||||
</el-form-item>
|
||||
#elseif($column.htmlType == "checkbox" && $dictType)
|
||||
<el-form-item label="${comment}">
|
||||
<el-checkbox-group v-model="form.${field}">
|
||||
<el-checkbox>请选择字典生成</el-checkbox>
|
||||
</el-checkbox-group>
|
||||
</el-form-item>
|
||||
#elseif($column.htmlType == "radio" && "" != $dictType)
|
||||
<el-form-item label="${comment}">
|
||||
<el-radio-group v-model="form.${field}">
|
||||
<el-radio
|
||||
v-for="dict in dict.type.${dictType}"
|
||||
:key="dict.value"
|
||||
#if($column.javaType == "Integer" || $column.javaType == "Long"):label="parseInt(dict.value)"#else:label="dict.value"#end
|
||||
|
||||
>{{dict.label}}</el-radio>
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
#elseif($column.htmlType == "radio" && $dictType)
|
||||
<el-form-item label="${comment}">
|
||||
<el-radio-group v-model="form.${field}">
|
||||
<el-radio label="1">请选择字典生成</el-radio>
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
#elseif($column.htmlType == "datetime")
|
||||
<el-form-item label="${comment}" prop="${field}">
|
||||
<el-date-picker clearable size="small"
|
||||
v-model="form.${field}"
|
||||
type="date"
|
||||
value-format="yyyy-MM-dd"
|
||||
placeholder="选择${comment}">
|
||||
</el-date-picker>
|
||||
</el-form-item>
|
||||
#elseif($column.htmlType == "textarea")
|
||||
<el-form-item label="${comment}" prop="${field}">
|
||||
<el-input v-model="form.${field}" type="textarea" placeholder="请输入内容" />
|
||||
</el-form-item>
|
||||
#end
|
||||
#end
|
||||
#end
|
||||
#end
|
||||
#if($table.sub)
|
||||
<el-divider content-position="center">${subTable.functionName}信息</el-divider>
|
||||
<el-row :gutter="10" class="mb8">
|
||||
<el-col :span="1.5">
|
||||
<el-button type="primary" icon="el-icon-plus" size="mini" @click="handleAdd${subClassName}">添加</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button type="danger" icon="el-icon-delete" size="mini" @click="handleDelete${subClassName}">删除</el-button>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-table :data="${subclassName}List" :row-class-name="row${subClassName}Index" @selection-change="handle${subClassName}SelectionChange" ref="${subclassName}">
|
||||
<el-table-column type="selection" width="50" align="center" />
|
||||
<el-table-column label="序号" align="center" prop="index" width="50"/>
|
||||
#foreach($column in $subTable.columns)
|
||||
#set($javaField=$column.javaField)
|
||||
#set($parentheseIndex=$column.columnComment.indexOf("("))
|
||||
#if($parentheseIndex != -1)
|
||||
#set($comment=$column.columnComment.substring(0, $parentheseIndex))
|
||||
#else
|
||||
#set($comment=$column.columnComment)
|
||||
#end
|
||||
#if($column.pk || $javaField == ${subTableFkclassName})
|
||||
#elseif($column.list && "" != $javaField)
|
||||
<el-table-column label="$comment" prop="${javaField}">
|
||||
<template slot-scope="scope">
|
||||
<el-input v-model="scope.row.$javaField" placeholder="请输入$comment" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
#end
|
||||
#end
|
||||
</el-table>
|
||||
#end
|
||||
</el-form>
|
||||
<div slot="footer" class="dialog-footer">
|
||||
<el-button type="primary" @click="submitForm">确 定</el-button>
|
||||
<el-button @click="cancel">取 消</el-button>
|
||||
</div>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { list${BusinessName}, get${BusinessName}, del${BusinessName}, add${BusinessName}, update${BusinessName} } from "@/api/${moduleName}/${businessName}";
|
||||
|
||||
export default {
|
||||
name: "${BusinessName}",
|
||||
#if(${dicts} != '')
|
||||
dicts: [${dicts}],
|
||||
#end
|
||||
data() {
|
||||
return {
|
||||
// 遮罩层
|
||||
loading: true,
|
||||
// 选中数组
|
||||
ids: [],
|
||||
#if($table.sub)
|
||||
// 子表选中数据
|
||||
checked${subClassName}: [],
|
||||
#end
|
||||
// 非单个禁用
|
||||
single: true,
|
||||
// 非多个禁用
|
||||
multiple: true,
|
||||
// 显示搜索条件
|
||||
showSearch: true,
|
||||
// 总条数
|
||||
total: 0,
|
||||
// ${functionName}表格数据
|
||||
${businessName}List: [],
|
||||
#if($table.sub)
|
||||
// ${subTable.functionName}表格数据
|
||||
${subclassName}List: [],
|
||||
#end
|
||||
// 弹出层标题
|
||||
title: "",
|
||||
// 是否显示弹出层
|
||||
open: false,
|
||||
#foreach ($column in $columns)
|
||||
#if($column.htmlType == "datetime" && $column.queryType == "BETWEEN")
|
||||
#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
|
||||
// $comment时间范围
|
||||
daterange${AttrName}: [],
|
||||
#end
|
||||
#end
|
||||
// 查询参数
|
||||
queryParams: {
|
||||
pageNum: 1,
|
||||
pageSize: 10,
|
||||
#foreach ($column in $columns)
|
||||
#if($column.query)
|
||||
$column.javaField: null#if($foreach.count != $columns.size()),#end
|
||||
#end
|
||||
#end
|
||||
},
|
||||
// 表单参数
|
||||
form: {},
|
||||
// 表单校验
|
||||
rules: {
|
||||
#foreach ($column in $columns)
|
||||
#if($column.required)
|
||||
#set($parentheseIndex=$column.columnComment.indexOf("("))
|
||||
#if($parentheseIndex != -1)
|
||||
#set($comment=$column.columnComment.substring(0, $parentheseIndex))
|
||||
#else
|
||||
#set($comment=$column.columnComment)
|
||||
#end
|
||||
$column.javaField: [
|
||||
{ required: true, message: "$comment不能为空", trigger: #if($column.htmlType == "select")"change"#else"blur"#end }
|
||||
]#if($foreach.count != $columns.size()),#end
|
||||
#end
|
||||
#end
|
||||
}
|
||||
};
|
||||
},
|
||||
created() {
|
||||
this.getList();
|
||||
},
|
||||
methods: {
|
||||
/** 查询${functionName}列表 */
|
||||
getList() {
|
||||
this.loading = true;
|
||||
#foreach ($column in $columns)
|
||||
#if($column.htmlType == "datetime" && $column.queryType == "BETWEEN")
|
||||
this.queryParams.params = {};
|
||||
#break
|
||||
#end
|
||||
#end
|
||||
#foreach ($column in $columns)
|
||||
#if($column.htmlType == "datetime" && $column.queryType == "BETWEEN")
|
||||
#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
|
||||
if (null != this.daterange${AttrName} && '' != this.daterange${AttrName}) {
|
||||
this.queryParams.params["begin${AttrName}"] = this.daterange${AttrName}[0];
|
||||
this.queryParams.params["end${AttrName}"] = this.daterange${AttrName}[1];
|
||||
}
|
||||
#end
|
||||
#end
|
||||
list${BusinessName}(this.queryParams).then(response => {
|
||||
this.${businessName}List = response.rows;
|
||||
this.total = response.total;
|
||||
this.loading = false;
|
||||
});
|
||||
},
|
||||
// 取消按钮
|
||||
cancel() {
|
||||
this.open = false;
|
||||
this.reset();
|
||||
},
|
||||
// 表单重置
|
||||
reset() {
|
||||
this.form = {
|
||||
#foreach ($column in $columns)
|
||||
#if($column.htmlType == "radio")
|
||||
$column.javaField: #if($column.javaType == "Integer" || $column.javaType == "Long")0#else"0"#end#if($foreach.count != $columns.size()),#end
|
||||
#elseif($column.htmlType == "checkbox")
|
||||
$column.javaField: []#if($foreach.count != $columns.size()),#end
|
||||
#else
|
||||
$column.javaField: null#if($foreach.count != $columns.size()),#end
|
||||
#end
|
||||
#end
|
||||
};
|
||||
#if($table.sub)
|
||||
this.${subclassName}List = [];
|
||||
#end
|
||||
this.resetForm("form");
|
||||
},
|
||||
/** 搜索按钮操作 */
|
||||
handleQuery() {
|
||||
this.queryParams.pageNum = 1;
|
||||
this.getList();
|
||||
},
|
||||
/** 重置按钮操作 */
|
||||
resetQuery() {
|
||||
#foreach ($column in $columns)
|
||||
#if($column.htmlType == "datetime" && $column.queryType == "BETWEEN")
|
||||
#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
|
||||
this.daterange${AttrName} = [];
|
||||
#end
|
||||
#end
|
||||
this.resetForm("queryForm");
|
||||
this.handleQuery();
|
||||
},
|
||||
// 多选框选中数据
|
||||
handleSelectionChange(selection) {
|
||||
this.ids = selection.map(item => item.${pkColumn.javaField})
|
||||
this.single = selection.length!==1
|
||||
this.multiple = !selection.length
|
||||
},
|
||||
/** 新增按钮操作 */
|
||||
handleAdd() {
|
||||
this.reset();
|
||||
this.open = true;
|
||||
this.title = "添加${functionName}";
|
||||
},
|
||||
/** 修改按钮操作 */
|
||||
handleUpdate(row) {
|
||||
this.reset();
|
||||
const ${pkColumn.javaField} = row.${pkColumn.javaField} || this.ids
|
||||
get${BusinessName}(${pkColumn.javaField}).then(response => {
|
||||
this.form = response.data;
|
||||
#foreach ($column in $columns)
|
||||
#if($column.htmlType == "checkbox")
|
||||
this.form.$column.javaField = this.form.${column.javaField}.split(",");
|
||||
#end
|
||||
#end
|
||||
#if($table.sub)
|
||||
this.${subclassName}List = response.data.${subclassName}List;
|
||||
#end
|
||||
this.open = true;
|
||||
this.title = "修改${functionName}";
|
||||
});
|
||||
},
|
||||
/** 提交按钮 */
|
||||
submitForm() {
|
||||
this.#[[$]]#refs["form"].validate(valid => {
|
||||
if (valid) {
|
||||
#foreach ($column in $columns)
|
||||
#if($column.htmlType == "checkbox")
|
||||
this.form.$column.javaField = this.form.${column.javaField}.join(",");
|
||||
#end
|
||||
#end
|
||||
#if($table.sub)
|
||||
this.form.${subclassName}List = this.${subclassName}List;
|
||||
#end
|
||||
if (this.form.${pkColumn.javaField} != null) {
|
||||
update${BusinessName}(this.form).then(response => {
|
||||
this.#[[$modal]]#.msgSuccess("修改成功");
|
||||
this.open = false;
|
||||
this.getList();
|
||||
});
|
||||
} else {
|
||||
add${BusinessName}(this.form).then(response => {
|
||||
this.#[[$modal]]#.msgSuccess("新增成功");
|
||||
this.open = false;
|
||||
this.getList();
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
/** 删除按钮操作 */
|
||||
handleDelete(row) {
|
||||
const ${pkColumn.javaField}s = row.${pkColumn.javaField} || this.ids;
|
||||
this.#[[$modal]]#.confirm('是否确认删除${functionName}编号为"' + ${pkColumn.javaField}s + '"的数据项?').then(function() {
|
||||
return del${BusinessName}(${pkColumn.javaField}s);
|
||||
}).then(() => {
|
||||
this.getList();
|
||||
this.#[[$modal]]#.msgSuccess("删除成功");
|
||||
}).catch(() => {});
|
||||
},
|
||||
#if($table.sub)
|
||||
/** ${subTable.functionName}序号 */
|
||||
row${subClassName}Index({ row, rowIndex }) {
|
||||
row.index = rowIndex + 1;
|
||||
},
|
||||
/** ${subTable.functionName}添加按钮操作 */
|
||||
handleAdd${subClassName}() {
|
||||
let obj = {};
|
||||
#foreach($column in $subTable.columns)
|
||||
#if($column.pk || $column.javaField == ${subTableFkclassName})
|
||||
#elseif($column.list && "" != $javaField)
|
||||
obj.$column.javaField = "";
|
||||
#end
|
||||
#end
|
||||
this.${subclassName}List.push(obj);
|
||||
},
|
||||
/** ${subTable.functionName}删除按钮操作 */
|
||||
handleDelete${subClassName}() {
|
||||
if (this.checked${subClassName}.length == 0) {
|
||||
this.#[[$modal]]#.msgError("请先选择要删除的${subTable.functionName}数据");
|
||||
} else {
|
||||
const ${subclassName}List = this.${subclassName}List;
|
||||
const checked${subClassName} = this.checked${subClassName};
|
||||
this.${subclassName}List = ${subclassName}List.filter(function(item) {
|
||||
return checked${subClassName}.indexOf(item.index) == -1
|
||||
});
|
||||
}
|
||||
},
|
||||
/** 复选框选中数据 */
|
||||
handle${subClassName}SelectionChange(selection) {
|
||||
this.checked${subClassName} = selection.map(item => item.index)
|
||||
},
|
||||
#end
|
||||
/** 导出按钮操作 */
|
||||
handleExport() {
|
||||
this.download('${moduleName}/${businessName}/export', {
|
||||
...this.queryParams
|
||||
}, `${businessName}_#[[${new Date().getTime()}]]#.xlsx`)
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
@ -0,0 +1,135 @@
|
||||
<?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="${packageName}.mapper.${ClassName}Mapper">
|
||||
|
||||
<resultMap type="${ClassName}" id="${ClassName}Result">
|
||||
#foreach ($column in $columns)
|
||||
<result property="${column.javaField}" column="${column.columnName}" />
|
||||
#end
|
||||
</resultMap>
|
||||
#if($table.sub)
|
||||
|
||||
<resultMap id="${ClassName}${subClassName}Result" type="${ClassName}" extends="${ClassName}Result">
|
||||
<collection property="${subclassName}List" notNullColumn="sub_${subTable.pkColumn.columnName}" javaType="java.util.List" resultMap="${subClassName}Result" />
|
||||
</resultMap>
|
||||
|
||||
<resultMap type="${subClassName}" id="${subClassName}Result">
|
||||
#foreach ($column in $subTable.columns)
|
||||
<result property="${column.javaField}" column="sub_${column.columnName}" />
|
||||
#end
|
||||
</resultMap>
|
||||
#end
|
||||
|
||||
<sql id="select${ClassName}Vo">
|
||||
select#foreach($column in $columns) $column.columnName#if($foreach.count != $columns.size()),#end#end from ${tableName}
|
||||
</sql>
|
||||
|
||||
<select id="select${ClassName}List" parameterType="${ClassName}" resultMap="${ClassName}Result">
|
||||
<include refid="select${ClassName}Vo"/>
|
||||
<where>
|
||||
#foreach($column in $columns)
|
||||
#set($queryType=$column.queryType)
|
||||
#set($javaField=$column.javaField)
|
||||
#set($javaType=$column.javaType)
|
||||
#set($columnName=$column.columnName)
|
||||
#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
|
||||
#if($column.query)
|
||||
#if($column.queryType == "EQ")
|
||||
<if test="$javaField != null #if($javaType == 'String' ) and $javaField.trim() != ''#end"> and $columnName = #{$javaField}</if>
|
||||
#elseif($queryType == "NE")
|
||||
<if test="$javaField != null #if($javaType == 'String' ) and $javaField.trim() != ''#end"> and $columnName != #{$javaField}</if>
|
||||
#elseif($queryType == "GT")
|
||||
<if test="$javaField != null #if($javaType == 'String' ) and $javaField.trim() != ''#end"> and $columnName > #{$javaField}</if>
|
||||
#elseif($queryType == "GTE")
|
||||
<if test="$javaField != null #if($javaType == 'String' ) and $javaField.trim() != ''#end"> and $columnName >= #{$javaField}</if>
|
||||
#elseif($queryType == "LT")
|
||||
<if test="$javaField != null #if($javaType == 'String' ) and $javaField.trim() != ''#end"> and $columnName < #{$javaField}</if>
|
||||
#elseif($queryType == "LTE")
|
||||
<if test="$javaField != null #if($javaType == 'String' ) and $javaField.trim() != ''#end"> and $columnName <= #{$javaField}</if>
|
||||
#elseif($queryType == "LIKE")
|
||||
<if test="$javaField != null #if($javaType == 'String' ) and $javaField.trim() != ''#end"> and $columnName like concat('%', #{$javaField}, '%')</if>
|
||||
#elseif($queryType == "BETWEEN")
|
||||
<if test="params.begin$AttrName != null and params.begin$AttrName != '' and params.end$AttrName != null and params.end$AttrName != ''"> and $columnName between #{params.begin$AttrName} and #{params.end$AttrName}</if>
|
||||
#end
|
||||
#end
|
||||
#end
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<select id="select${ClassName}By${pkColumn.capJavaField}" parameterType="${pkColumn.javaType}" resultMap="#if($table.sub)${ClassName}${subClassName}Result#else${ClassName}Result#end">
|
||||
#if($table.crud || $table.tree)
|
||||
<include refid="select${ClassName}Vo"/>
|
||||
where ${pkColumn.columnName} = #{${pkColumn.javaField}}
|
||||
#elseif($table.sub)
|
||||
select#foreach($column in $columns) a.$column.columnName#if($foreach.count != $columns.size()),#end#end,
|
||||
#foreach($column in $subTable.columns) b.$column.columnName as sub_$column.columnName#if($foreach.count != $subTable.columns.size()),#end#end
|
||||
|
||||
from ${tableName} a
|
||||
left join ${subTableName} b on b.${subTableFkName} = a.${pkColumn.columnName}
|
||||
where a.${pkColumn.columnName} = #{${pkColumn.javaField}}
|
||||
#end
|
||||
</select>
|
||||
|
||||
<insert id="insert${ClassName}" parameterType="${ClassName}"#if($pkColumn.increment) useGeneratedKeys="true" keyProperty="$pkColumn.javaField"#end>
|
||||
insert into ${tableName}
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
#foreach($column in $columns)
|
||||
#if($column.columnName != $pkColumn.columnName || !$pkColumn.increment)
|
||||
<if test="$column.javaField != null#if($column.javaType == 'String' && $column.required) and $column.javaField != ''#end">$column.columnName,</if>
|
||||
#end
|
||||
#end
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
#foreach($column in $columns)
|
||||
#if($column.columnName != $pkColumn.columnName || !$pkColumn.increment)
|
||||
<if test="$column.javaField != null#if($column.javaType == 'String' && $column.required) and $column.javaField != ''#end">#{$column.javaField},</if>
|
||||
#end
|
||||
#end
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
<update id="update${ClassName}" parameterType="${ClassName}">
|
||||
update ${tableName}
|
||||
<trim prefix="SET" suffixOverrides=",">
|
||||
#foreach($column in $columns)
|
||||
#if($column.columnName != $pkColumn.columnName)
|
||||
<if test="$column.javaField != null#if($column.javaType == 'String' && $column.required) and $column.javaField != ''#end">$column.columnName = #{$column.javaField},</if>
|
||||
#end
|
||||
#end
|
||||
</trim>
|
||||
where ${pkColumn.columnName} = #{${pkColumn.javaField}}
|
||||
</update>
|
||||
|
||||
<delete id="delete${ClassName}By${pkColumn.capJavaField}" parameterType="${pkColumn.javaType}">
|
||||
delete from ${tableName} where ${pkColumn.columnName} = #{${pkColumn.javaField}}
|
||||
</delete>
|
||||
|
||||
<delete id="delete${ClassName}By${pkColumn.capJavaField}s" parameterType="String">
|
||||
delete from ${tableName} where ${pkColumn.columnName} in
|
||||
<foreach item="${pkColumn.javaField}" collection="array" open="(" separator="," close=")">
|
||||
#{${pkColumn.javaField}}
|
||||
</foreach>
|
||||
</delete>
|
||||
#if($table.sub)
|
||||
|
||||
<delete id="delete${subClassName}By${subTableFkClassName}s" parameterType="String">
|
||||
delete from ${subTableName} where ${subTableFkName} in
|
||||
<foreach item="${subTableFkclassName}" collection="array" open="(" separator="," close=")">
|
||||
#{${subTableFkclassName}}
|
||||
</foreach>
|
||||
</delete>
|
||||
|
||||
<delete id="delete${subClassName}By${subTableFkClassName}" parameterType="${pkColumn.javaType}">
|
||||
delete from ${subTableName} where ${subTableFkName} = #{${subTableFkclassName}}
|
||||
</delete>
|
||||
|
||||
<insert id="batch${subClassName}">
|
||||
insert into ${subTableName}(#foreach($column in $subTable.columns) $column.columnName#if($foreach.count != $subTable.columns.size()),#end#end) values
|
||||
<foreach item="item" index="index" collection="list" separator=",">
|
||||
(#foreach($column in $subTable.columns) #{item.$column.javaField}#if($foreach.count != $subTable.columns.size()),#end#end)
|
||||
</foreach>
|
||||
</insert>
|
||||
#end
|
||||
</mapper>
|
Reference in New Issue
Block a user