mqtt模块新增智能插座开关,websocket模块

pdf生成功能
This commit is contained in:
2026-04-10 16:14:36 +08:00
parent 24d0aba49f
commit 897bb2ffb3
54 changed files with 2620 additions and 879 deletions

View File

@@ -47,7 +47,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
order by d.parent_id, d.order_num
</select>
<select id="selectDeptListByRoleId" resultType="Long">
<select id="selectDeptListByRoleId" resultType="java.lang.Long">
select d.dept_id
from sys_dept d
left join sys_role_dept rd on d.dept_id = rd.dept_id
@@ -169,5 +169,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
AND dept_name LIKE CONCAT('%', #{keyword}, '%')
</if>
</select>
<select id="selectDeptAndChildIds" resultType="java.lang.Long">
SELECT dept_id
FROM sys_dept
WHERE FIND_IN_SET(#{deptId}, ancestors)
</select>
</mapper>

View File

@@ -45,21 +45,27 @@
FROM worn_unique_code t
LEFT JOIN sys_dept d ON t.project_id = d.dept_id
<where>
AND (t.is_delete = '0' OR t.is_delete IS NULL)
${params.dataScope}
<if test="dataScopeDeptIds != null and dataScopeDeptIds.size() > 0">
AND t.project_id IN
<foreach collection="dataScopeDeptIds" item="id" open="(" separator="," close=")">
#{id}
</foreach>
</if>
<if test="code != null and code != ''">
AND t.code = #{code}
</if>
<if test="billNo != null and billNo != ''">
AND t.bill_no = #{billNo}
</if>
<if test="projectId != null">
AND t.project_id = #{projectId}
</if>
<if test="status != null and status != ''">
<if test="status != null">
AND t.status = #{status}
</if>
<if test="rfidCode != null and rfidCode != ''">
AND t.rfid_code = #{rfidCode}
</if>
@@ -70,6 +76,7 @@
<select id="selectWornUniqueCodeById" parameterType="Long" resultMap="WornUniqueCodeResult">
<include refid="selectWornUniqueCodeVo"/>
where id = #{id}
AND (is_delete = '0' OR is_delete IS NULL)
</select>
<select id="selectIdByCode" resultType="java.lang.Long">
@@ -136,6 +143,7 @@
update_by = #{updateBy},
update_time = #{updateTime}
where code = #{code}
AND (is_delete = '0' OR is_delete IS NULL)
</update>
<delete id="deleteWornUniqueCodeByIds" parameterType="Long">
@@ -144,6 +152,7 @@
#{id}
</foreach>
</delete>
<select id="selectByCode" resultType="com.shzg.project.unique.domain.WornUniqueCode">
SELECT
id,
@@ -196,7 +205,7 @@
WHERE uc.code = #{code}
AND (uc.is_delete = '0' OR uc.is_delete IS NULL)
AND (ucm.is_delete = '0' OR ucm.is_delete IS NULL)
AND (ucm.id IS NULL OR ucm.is_delete = '0')
AND (m.is_delete = '0' OR m.is_delete IS NULL)
ORDER BY ucm.id ASC

View File

@@ -7,6 +7,8 @@
<resultMap type="MqttSensorData" id="MqttSensorDataResult">
<result property="id" column="id"/>
<result property="deviceId" column="device_id"/>
<result property="deptId" column="dept_id"/>
<result property="topic" column="topic"/>
<result property="project" column="project"/>
<result property="warehouse" column="warehouse"/>
@@ -18,7 +20,6 @@
<result property="nh3" column="nh3"/>
<result property="h2s" column="h2s"/>
<result property="concentration" column="concentration"/>
<result property="waterStatus" column="water_status"/>
<result property="remark" column="remark"/>
@@ -31,33 +32,57 @@
<sql id="selectMqttSensorDataVo">
select
id, device_id, topic, project, warehouse, payload, data_json,
battery, temperature, humidity, nh3, h2s, concentration,
water_status,
remark, create_by, create_time, update_by, update_time, is_delete
id,
device_id,
dept_id,
topic,
project,
warehouse,
payload,
data_json,
battery,
temperature,
humidity,
nh3,
h2s,
concentration,
water_status,
remark,
create_by,
create_time,
update_by,
update_time,
is_delete
from mqtt_sensor_data
</sql>
<select id="selectMqttSensorDataList" parameterType="MqttSensorData" resultMap="MqttSensorDataResult">
<include refid="selectMqttSensorDataVo"/>
<where>
<if test="deviceId != null "> and device_id = #{deviceId}</if>
<if test="topic != null and topic != ''"> and topic = #{topic}</if>
<if test="project != null and project != ''"> and project = #{project}</if>
<if test="warehouse != null and warehouse != ''"> and warehouse = #{warehouse}</if>
<if test="payload != null and payload != ''"> and payload = #{payload}</if>
<if test="dataJson != null and dataJson != ''"> and data_json = #{dataJson}</if>
<if test="battery != null "> and battery = #{battery}</if>
<if test="temperature != null "> and temperature = #{temperature}</if>
<if test="humidity != null "> and humidity = #{humidity}</if>
<if test="nh3 != null "> and nh3 = #{nh3}</if>
<if test="h2s != null "> and h2s = #{h2s}</if>
<if test="concentration != null "> and concentration = #{concentration}</if>
<if test="deviceId != null"> and device_id = #{deviceId}</if>
<if test="waterStatus != null "> and water_status = #{waterStatus}</if>
<if test="deptIds != null and deptIds.size > 0">
and dept_id in
<foreach collection="deptIds" item="id" open="(" separator="," close=")">
#{id}
</foreach>
</if>
<if test="isDelete != null and isDelete != ''"> and is_delete = #{isDelete}</if>
<if test="topic != null and topic != ''"> and topic = #{topic}</if>
<if test="project != null and project != ''"> and project = #{project}</if>
<if test="warehouse != null and warehouse != ''"> and warehouse = #{warehouse}</if>
<if test="payload != null and payload != ''"> and payload = #{payload}</if>
<if test="dataJson != null and dataJson != ''"> and data_json = #{dataJson}</if>
<if test="battery != null"> and battery = #{battery}</if>
<if test="temperature != null"> and temperature = #{temperature}</if>
<if test="humidity != null"> and humidity = #{humidity}</if>
<if test="nh3 != null"> and nh3 = #{nh3}</if>
<if test="h2s != null"> and h2s = #{h2s}</if>
<if test="concentration != null"> and concentration = #{concentration}</if>
<if test="waterStatus != null"> and water_status = #{waterStatus}</if>
<if test="isDelete != null and isDelete != ''"> and is_delete = #{isDelete}</if>
</where>
order by create_time desc
</select>
<select id="selectMqttSensorDataById" parameterType="Long" resultMap="MqttSensorDataResult">
@@ -69,6 +94,8 @@
insert into mqtt_sensor_data
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="deviceId != null">device_id,</if>
<if test="deptId != null">dept_id,</if>
<if test="topic != null">topic,</if>
<if test="project != null">project,</if>
<if test="warehouse != null">warehouse,</if>
@@ -80,7 +107,6 @@
<if test="nh3 != null">nh3,</if>
<if test="h2s != null">h2s,</if>
<if test="concentration != null">concentration,</if>
<if test="waterStatus != null">water_status,</if>
<if test="remark != null">remark,</if>
@@ -90,8 +116,11 @@
<if test="updateTime != null">update_time,</if>
<if test="isDelete != null">is_delete,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="deviceId != null">#{deviceId},</if>
<if test="deptId != null">#{deptId},</if>
<if test="topic != null">#{topic},</if>
<if test="project != null">#{project},</if>
<if test="warehouse != null">#{warehouse},</if>
@@ -104,6 +133,7 @@
<if test="h2s != null">#{h2s},</if>
<if test="concentration != null">#{concentration},</if>
<if test="waterStatus != null">#{waterStatus},</if>
<if test="remark != null">#{remark},</if>
<if test="createBy != null">#{createBy},</if>
<if test="createTime != null">#{createTime},</if>
@@ -117,6 +147,8 @@
update mqtt_sensor_data
<trim prefix="SET" suffixOverrides=",">
<if test="deviceId != null">device_id = #{deviceId},</if>
<if test="deptId != null">dept_id = #{deptId},</if>
<if test="topic != null">topic = #{topic},</if>
<if test="project != null">project = #{project},</if>
<if test="warehouse != null">warehouse = #{warehouse},</if>
@@ -128,8 +160,6 @@
<if test="nh3 != null">nh3 = #{nh3},</if>
<if test="h2s != null">h2s = #{h2s},</if>
<if test="concentration != null">concentration = #{concentration},</if>
<!-- ✅ 新增 -->
<if test="waterStatus != null">water_status = #{waterStatus},</if>
<if test="remark != null">remark = #{remark},</if>
@@ -152,4 +182,5 @@
#{id}
</foreach>
</delete>
</mapper>

View File

@@ -1,40 +1,53 @@
<?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">
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.shzg.project.worn.mapper.MqttSensorEventMapper">
<resultMap type="MqttSensorEvent" id="MqttSensorEventResult">
<result property="id" column="id" />
<result property="deviceId" column="device_id" />
<result property="eventType" column="event_type" />
<result property="eventDesc" column="event_desc" />
<result property="level" column="level" />
<result property="status" column="status" />
<result property="remark" column="remark" />
<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="isDelete" column="is_delete" />
<result property="id" column="id"/>
<result property="deviceId" column="device_id"/>
<result property="deptId" column="dept_id"/>
<result property="eventType" column="event_type"/>
<result property="eventDesc" column="event_desc"/>
<result property="level" column="level"/>
<result property="status" column="status"/>
<result property="remark" column="remark"/>
<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="isDelete" column="is_delete"/>
</resultMap>
<sql id="selectMqttSensorEventVo">
select id, device_id, event_type, event_desc, level, status, remark, create_by, create_time, update_by, update_time, is_delete from mqtt_sensor_event
select id, device_id, dept_id, event_type, event_desc, level, status, remark, create_by, create_time, update_by, update_time, is_delete
from mqtt_sensor_event
</sql>
<select id="selectMqttSensorEventList" parameterType="MqttSensorEvent" resultMap="MqttSensorEventResult">
<include refid="selectMqttSensorEventVo"/>
<where>
<if test="deviceId != null "> and device_id = #{deviceId}</if>
<if test="eventType != null and eventType != ''"> and event_type = #{eventType}</if>
<if test="eventDesc != null and eventDesc != ''"> and event_desc = #{eventDesc}</if>
<if test="level != null and level != ''"> and level = #{level}</if>
<if test="status != null and status != ''"> and status = #{status}</if>
<if test="isDelete != null and isDelete != ''"> and is_delete = #{isDelete}</if>
<where>
<if test="deviceId != null">and device_id = #{deviceId}</if>
<if test="deptId != null">and dept_id = #{deptId}</if>
<!-- 数据权限 -->
<if test="deptIds != null and deptIds.size > 0">
AND dept_id IN
<foreach collection="deptIds" item="deptId" open="(" separator="," close=")">
#{deptId}
</foreach>
</if>
<if test="eventType != null and eventType != ''">and event_type = #{eventType}</if>
<if test="eventDesc != null and eventDesc != ''">and event_desc = #{eventDesc}</if>
<if test="level != null and level != ''">and level = #{level}</if>
<if test="status != null and status != ''">and status = #{status}</if>
<if test="isDelete != null and isDelete != ''">and is_delete = #{isDelete}</if>
</where>
order by create_time desc
</select>
<select id="selectMqttSensorEventById" parameterType="Long" resultMap="MqttSensorEventResult">
<include refid="selectMqttSensorEventVo"/>
where id = #{id}
@@ -44,6 +57,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
insert into mqtt_sensor_event
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="deviceId != null">device_id,</if>
<if test="deptId != null">dept_id,</if>
<if test="eventType != null and eventType != ''">event_type,</if>
<if test="eventDesc != null">event_desc,</if>
<if test="level != null">level,</if>
@@ -54,9 +68,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="updateBy != null">update_by,</if>
<if test="updateTime != null">update_time,</if>
<if test="isDelete != null">is_delete,</if>
</trim>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="deviceId != null">#{deviceId},</if>
<if test="deptId != null">#{deptId},</if>
<if test="eventType != null and eventType != ''">#{eventType},</if>
<if test="eventDesc != null">#{eventDesc},</if>
<if test="level != null">#{level},</if>
@@ -67,13 +82,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="updateBy != null">#{updateBy},</if>
<if test="updateTime != null">#{updateTime},</if>
<if test="isDelete != null">#{isDelete},</if>
</trim>
</trim>
</insert>
<update id="updateMqttSensorEvent" parameterType="MqttSensorEvent">
update mqtt_sensor_event
<trim prefix="SET" suffixOverrides=",">
<if test="deviceId != null">device_id = #{deviceId},</if>
<if test="deptId != null">dept_id = #{deptId},</if>
<if test="eventType != null and eventType != ''">event_type = #{eventType},</if>
<if test="eventDesc != null">event_desc = #{eventDesc},</if>
<if test="level != null">level = #{level},</if>
@@ -93,9 +109,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</delete>
<delete id="deleteMqttSensorEventByIds" parameterType="String">
delete from mqtt_sensor_event where id in
delete from mqtt_sensor_event where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
</mapper>

View File

@@ -1,46 +1,58 @@
<?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">
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.shzg.project.worn.mapper.MqttSensorThresholdMapper">
<resultMap type="MqttSensorThreshold" id="MqttSensorThresholdResult">
<result property="id" column="id" />
<result property="deviceId" column="device_id" />
<result property="metricType" column="metric_type" />
<result property="warnMin" column="warn_min" />
<result property="warnMax" column="warn_max" />
<result property="alarmMin" column="alarm_min" />
<result property="alarmMax" column="alarm_max" />
<result property="unit" column="unit" />
<result property="status" column="status" />
<result property="remark" column="remark" />
<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="isDelete" column="is_delete" />
<result property="id" column="id"/>
<result property="deviceId" column="device_id"/>
<result property="deptId" column="dept_id"/>
<result property="metricType" column="metric_type"/>
<result property="warnMin" column="warn_min"/>
<result property="warnMax" column="warn_max"/>
<result property="alarmMin" column="alarm_min"/>
<result property="alarmMax" column="alarm_max"/>
<result property="unit" column="unit"/>
<result property="status" column="status"/>
<result property="remark" column="remark"/>
<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="isDelete" column="is_delete"/>
</resultMap>
<sql id="selectMqttSensorThresholdVo">
select id, device_id, metric_type, warn_min, warn_max, alarm_min, alarm_max, unit, status, remark, create_by, create_time, update_by, update_time, is_delete from mqtt_sensor_threshold
select id, device_id, dept_id, metric_type, warn_min, warn_max, alarm_min, alarm_max,
unit, status, remark, create_by, create_time, update_by, update_time, is_delete
from mqtt_sensor_threshold
</sql>
<select id="selectMqttSensorThresholdList" parameterType="MqttSensorThreshold" resultMap="MqttSensorThresholdResult">
<include refid="selectMqttSensorThresholdVo"/>
<where>
<if test="deviceId != null "> and device_id = #{deviceId}</if>
<if test="metricType != null and metricType != ''"> and metric_type = #{metricType}</if>
<if test="warnMin != null "> and warn_min = #{warnMin}</if>
<if test="warnMax != null "> and warn_max = #{warnMax}</if>
<if test="alarmMin != null "> and alarm_min = #{alarmMin}</if>
<if test="alarmMax != null "> and alarm_max = #{alarmMax}</if>
<if test="unit != null and unit != ''"> and unit = #{unit}</if>
<if test="status != null and status != ''"> and status = #{status}</if>
<if test="isDelete != null and isDelete != ''"> and is_delete = #{isDelete}</if>
<where>
<if test="deviceId != null">and device_id = #{deviceId}</if>
<if test="deptId != null">and dept_id = #{deptId}</if>
<if test="deptIds != null and deptIds.size > 0">
and dept_id in
<foreach collection="deptIds" item="deptId" open="(" separator="," close=")">
#{deptId}
</foreach>
</if>
<if test="metricType != null and metricType != ''">and metric_type = #{metricType}</if>
<if test="warnMin != null">and warn_min = #{warnMin}</if>
<if test="warnMax != null">and warn_max = #{warnMax}</if>
<if test="alarmMin != null">and alarm_min = #{alarmMin}</if>
<if test="alarmMax != null">and alarm_max = #{alarmMax}</if>
<if test="unit != null and unit != ''">and unit = #{unit}</if>
<if test="status != null and status != ''">and status = #{status}</if>
<if test="isDelete != null and isDelete != ''">and is_delete = #{isDelete}</if>
</where>
</select>
<select id="selectMqttSensorThresholdById" parameterType="Long" resultMap="MqttSensorThresholdResult">
<include refid="selectMqttSensorThresholdVo"/>
where id = #{id}
@@ -50,6 +62,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
insert into mqtt_sensor_threshold
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="deviceId != null">device_id,</if>
<if test="deptId != null">dept_id,</if>
<if test="metricType != null and metricType != ''">metric_type,</if>
<if test="warnMin != null">warn_min,</if>
<if test="warnMax != null">warn_max,</if>
@@ -63,9 +76,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="updateBy != null">update_by,</if>
<if test="updateTime != null">update_time,</if>
<if test="isDelete != null">is_delete,</if>
</trim>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="deviceId != null">#{deviceId},</if>
<if test="deptId != null">#{deptId},</if>
<if test="metricType != null and metricType != ''">#{metricType},</if>
<if test="warnMin != null">#{warnMin},</if>
<if test="warnMax != null">#{warnMax},</if>
@@ -79,13 +93,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="updateBy != null">#{updateBy},</if>
<if test="updateTime != null">#{updateTime},</if>
<if test="isDelete != null">#{isDelete},</if>
</trim>
</trim>
</insert>
<update id="updateMqttSensorThreshold" parameterType="MqttSensorThreshold">
update mqtt_sensor_threshold
<trim prefix="SET" suffixOverrides=",">
<if test="deviceId != null">device_id = #{deviceId},</if>
<if test="deptId != null">dept_id = #{deptId},</if>
<if test="metricType != null and metricType != ''">metric_type = #{metricType},</if>
<if test="warnMin != null">warn_min = #{warnMin},</if>
<if test="warnMax != null">warn_max = #{warnMax},</if>
@@ -94,8 +109,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="unit != null">unit = #{unit},</if>
<if test="status != null">status = #{status},</if>
<if test="remark != null">remark = #{remark},</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="isDelete != null">is_delete = #{isDelete},</if>
@@ -108,12 +121,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</delete>
<delete id="deleteMqttSensorThresholdByIds" parameterType="String">
delete from mqtt_sensor_threshold where id in
delete from mqtt_sensor_threshold where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
<!-- 按设备+指标查询 -->
<select id="selectByDeviceAndMetric" resultMap="MqttSensorThresholdResult">
select *
from mqtt_sensor_threshold
@@ -123,4 +137,30 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
and is_delete = '0'
limit 1
</select>
<!-- 按部门+指标查询 -->
<select id="selectByDeptAndMetric" resultMap="MqttSensorThresholdResult">
select *
from mqtt_sensor_threshold
where dept_id = #{deptId}
and metric_type = #{metricType}
and status = '1'
and is_delete = '0'
limit 1
</select>
<select id="selectByPriority" resultMap="MqttSensorThresholdResult">
select *
from mqtt_sensor_threshold
where metric_type = #{metricType}
and status = '1'
and is_delete = '0'
and (
device_id = #{deviceId}
or dept_id = #{deptId}
)
order by case when device_id = #{deviceId} then 1 else 2 end
limit 1
</select>
</mapper>

View File

@@ -0,0 +1,138 @@
<?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.shzg.project.worn.mapper.MqttTopicConfigMapper">
<!-- ================== ResultMap ================== -->
<resultMap type="MqttTopicConfig" id="MqttTopicConfigResult">
<result property="id" column="id" />
<result property="project" column="project" />
<result property="warehouse" column="warehouse" />
<result property="deptId" column="dept_id" />
<result property="topicUp" column="topic_up" />
<result property="topicDownPrefix" column="topic_down_prefix" />
<result property="status" column="status" />
<result property="remark" column="remark" />
<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="isDelete" column="is_delete" />
</resultMap>
<!-- ================== 基础查询SQL ================== -->
<sql id="selectMqttTopicConfigVo">
select id, project, warehouse, dept_id, topic_up, topic_down_prefix,
status, remark, create_by, create_time, update_by, update_time, is_delete
from mqtt_topic_config
</sql>
<!-- ================== 列表查询(支持数据隔离) ================== -->
<select id="selectMqttTopicConfigList" parameterType="MqttTopicConfig" resultMap="MqttTopicConfigResult">
<include refid="selectMqttTopicConfigVo"/>
<where>
<if test="project != null and project != ''">and project = #{project}</if>
<if test="warehouse != null and warehouse != ''">and warehouse = #{warehouse}</if>
<if test="topicUp != null and topicUp != ''">and topic_up = #{topicUp}</if>
<if test="topicDownPrefix != null and topicDownPrefix != ''">and topic_down_prefix = #{topicDownPrefix}</if>
<if test="status != null and status != ''">and status = #{status}</if>
<if test="isDelete != null and isDelete != ''">and is_delete = #{isDelete}</if>
<if test="deptIds != null and deptIds.size() > 0">
and dept_id in
<foreach collection="deptIds" item="deptId" open="(" separator="," close=")">
#{deptId}
</foreach>
</if>
</where>
</select>
<!-- ================== 根据ID查询 ================== -->
<select id="selectMqttTopicConfigById" parameterType="Long" resultMap="MqttTopicConfigResult">
<include refid="selectMqttTopicConfigVo"/>
where id = #{id}
</select>
<!-- ================== 查询启用的TopicMQTT用 ================== -->
<select id="selectEnabledMqttTopicConfigList" resultMap="MqttTopicConfigResult">
<include refid="selectMqttTopicConfigVo"/>
where status = '0'
and is_delete = '0'
and topic_up is not null
and topic_up != ''
<!-- 🔥 防止跨项目订阅 -->
<if test="deptIds != null and deptIds.size() > 0">
and dept_id in
<foreach collection="deptIds" item="deptId" open="(" separator="," close=")">
#{deptId}
</foreach>
</if>
</select>
<!-- ================== 新增 ================== -->
<insert id="insertMqttTopicConfig" parameterType="MqttTopicConfig" useGeneratedKeys="true" keyProperty="id">
insert into mqtt_topic_config
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="project != null and project != ''">project,</if>
<if test="warehouse != null and warehouse != ''">warehouse,</if>
<if test="deptId != null">dept_id,</if>
<if test="topicUp != null and topicUp != ''">topic_up,</if>
<if test="topicDownPrefix != null and topicDownPrefix != ''">topic_down_prefix,</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="createTime != null">create_time,</if>
<if test="updateBy != null and updateBy != ''">update_by,</if>
<if test="updateTime != null">update_time,</if>
<if test="isDelete != null and isDelete != ''">is_delete,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="project != null and project != ''">#{project},</if>
<if test="warehouse != null and warehouse != ''">#{warehouse},</if>
<if test="deptId != null">#{deptId},</if>
<if test="topicUp != null and topicUp != ''">#{topicUp},</if>
<if test="topicDownPrefix != null and topicDownPrefix != ''">#{topicDownPrefix},</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="createTime != null">#{createTime},</if>
<if test="updateBy != null and updateBy != ''">#{updateBy},</if>
<if test="updateTime != null">#{updateTime},</if>
<if test="isDelete != null and isDelete != ''">#{isDelete},</if>
</trim>
</insert>
<!-- ================== 修改 ================== -->
<update id="updateMqttTopicConfig" parameterType="MqttTopicConfig">
update mqtt_topic_config
<trim prefix="SET" suffixOverrides=",">
<if test="project != null and project != ''">project = #{project},</if>
<if test="warehouse != null and warehouse != ''">warehouse = #{warehouse},</if>
<if test="deptId != null">dept_id = #{deptId},</if>
<if test="topicUp != null and topicUp != ''">topic_up = #{topicUp},</if>
<if test="topicDownPrefix != null and topicDownPrefix != ''">topic_down_prefix = #{topicDownPrefix},</if>
<if test="status != null and status != ''">status = #{status},</if>
<if test="remark != null">remark = #{remark},</if>
<if test="updateBy != null">update_by = #{updateBy},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
<if test="isDelete != null">is_delete = #{isDelete},</if>
</trim>
where id = #{id}
</update>
<!-- ================== 删除(单个) ================== -->
<delete id="deleteMqttTopicConfigById" parameterType="Long">
delete from mqtt_topic_config where id = #{id}
</delete>
<!-- ================== 批量删除================== -->
<delete id="deleteMqttTopicConfigByIds">
delete from mqtt_topic_config where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
</mapper>

View File

@@ -35,6 +35,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="typeParentNames" column="type_parent_names"/>
<result property="unitId" column="unit_id"/>
<result property="unitName" column="unit_name"/>
<result property="operatorName" column="operator_name"/>
</resultMap>
<sql id="selectWornInboundItemVo">
@@ -193,22 +194,44 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
parameterType="Long"
resultMap="WornInboundItemResult">
SELECT
id,
bill_id,
bill_no,
material_id,
quantity,
unique_code,
remark,
status,
create_by,
create_time,
update_by,
update_time,
is_delete
FROM worn_inbound_item
WHERE bill_id = #{billId}
AND (is_delete = '0' OR is_delete IS NULL)
ORDER BY id ASC
i.id,
i.bill_id,
i.bill_no,
i.material_id,
i.quantity,
i.unique_code,
i.remark,
i.status,
i.create_by,
i.create_time,
i.update_by,
i.update_time,
i.is_delete,
b.inbound_time,
b.warehouse_code,
b.warehouse_name,
b.area_code,
b.area_name,
b.remark AS bill_remark,
b.status AS bill_status,
b.bill_type,
m.material_name,
m.material_short_name,
m.material_code,
m.specification,
m.model,
m.weight,
m.unit_id,
mu.unit_name,
u.nick_name AS operator_name
FROM worn_inbound_item i
LEFT JOIN worn_inbound_bill b ON i.bill_id = b.id
LEFT JOIN worn_material m ON i.material_id = m.id
LEFT JOIN worn_material_unit mu ON m.unit_id = mu.id
LEFT JOIN sys_user u ON CAST(b.create_by AS UNSIGNED) = u.user_id
WHERE i.bill_id = #{billId}
AND (i.is_delete = '0' OR i.is_delete IS NULL)
AND (b.is_delete = '0' OR b.is_delete IS NULL)
ORDER BY i.id ASC
</select>
</mapper>
</mapper>