2026-06-02 15:01:23 +08:00
|
|
|
<?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.cmvr.inspection.mapper.InspectionRobotMapper">
|
|
|
|
|
|
|
|
|
|
<resultMap type="InspectionRobot" id="InspectionRobotResult">
|
|
|
|
|
<result property="id" column="id" />
|
2026-08-05 11:10:19 +08:00
|
|
|
<result property="robotId" column="robot_id" />
|
2026-06-02 15:01:23 +08:00
|
|
|
<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="robotCode" column="robot_code" />
|
|
|
|
|
<result property="robotName" column="robot_name" />
|
|
|
|
|
<result property="robotModel" column="robot_model" />
|
|
|
|
|
<result property="robotType" column="robot_type" />
|
|
|
|
|
<result property="ipAddress" column="ip_address" />
|
|
|
|
|
<result property="port" column="port" />
|
|
|
|
|
<result property="currentMapId" column="current_map_id" />
|
|
|
|
|
<result property="status" column="status" />
|
|
|
|
|
<result property="batteryLevel" column="battery_level" />
|
|
|
|
|
<result property="currentPosition" column="current_position" />
|
2026-08-05 11:10:19 +08:00
|
|
|
<result property="connectStatus" column="connect_status" />
|
|
|
|
|
<result property="quicNodeId" column="quic_node_id" />
|
|
|
|
|
<result property="quicSessionId" column="quic_session_id" />
|
|
|
|
|
<result property="quicBootId" column="quic_boot_id" />
|
|
|
|
|
<result property="observedIp" column="observed_ip" />
|
|
|
|
|
<result property="softwareVersion" column="software_version" />
|
|
|
|
|
<result property="lastHeartbeatTime" column="last_heartbeat_time" />
|
|
|
|
|
<result property="archivedStatus" column="archived_status" />
|
2026-06-02 15:01:23 +08:00
|
|
|
</resultMap>
|
|
|
|
|
|
|
|
|
|
<resultMap type="com.cmvr.inspection.domain.vo.InspectionRobotVo" id="InspectionRobotVoResult">
|
|
|
|
|
<result property="id" column="id" />
|
2026-08-05 11:10:19 +08:00
|
|
|
<result property="robotId" column="robot_id" />
|
2026-06-02 15:01:23 +08:00
|
|
|
<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="robotCode" column="robot_code" />
|
|
|
|
|
<result property="robotName" column="robot_name" />
|
|
|
|
|
<result property="robotModel" column="robot_model" />
|
|
|
|
|
<result property="robotType" column="robot_type" />
|
|
|
|
|
<result property="ipAddress" column="ip_address" />
|
|
|
|
|
<result property="port" column="port" />
|
|
|
|
|
<result property="currentMapId" column="current_map_id" />
|
|
|
|
|
<result property="currentMapName" column="current_map_name" />
|
2026-06-15 16:46:04 +08:00
|
|
|
<result property="robotMapName" column="robot_map_name" />
|
2026-06-02 15:01:23 +08:00
|
|
|
<result property="status" column="status" />
|
|
|
|
|
<result property="batteryLevel" column="battery_level" />
|
|
|
|
|
<result property="currentPosition" column="current_position" />
|
|
|
|
|
<result property="createByName" column="create_by_name" />
|
|
|
|
|
<result property="updateByName" column="update_by_name" />
|
2026-08-05 11:10:19 +08:00
|
|
|
<result property="connectStatus" column="connect_status" />
|
|
|
|
|
<result property="quicNodeId" column="quic_node_id" />
|
|
|
|
|
<result property="quicSessionId" column="quic_session_id" />
|
|
|
|
|
<result property="quicBootId" column="quic_boot_id" />
|
|
|
|
|
<result property="observedIp" column="observed_ip" />
|
|
|
|
|
<result property="softwareVersion" column="software_version" />
|
|
|
|
|
<result property="lastHeartbeatTime" column="last_heartbeat_time" />
|
|
|
|
|
<result property="deviceTotal" column="device_total" />
|
|
|
|
|
<result property="onlineDeviceCount" column="online_device_count" />
|
|
|
|
|
<result property="faultDeviceCount" column="fault_device_count" />
|
2026-06-02 15:01:23 +08:00
|
|
|
</resultMap>
|
|
|
|
|
|
|
|
|
|
<sql id="selectInspectionRobotVo">
|
2026-08-05 11:10:19 +08:00
|
|
|
select id, robot_id, create_by, create_time, update_by, update_time, remark,
|
|
|
|
|
robot_code, robot_name, robot_model, robot_type, ip_address, port,
|
|
|
|
|
current_map_id, status, battery_level, current_position,
|
|
|
|
|
connect_status, quic_node_id, quic_session_id, quic_boot_id,
|
|
|
|
|
observed_ip, software_version, last_heartbeat_time, archived_status
|
|
|
|
|
from inspection_robot
|
2026-06-02 15:01:23 +08:00
|
|
|
</sql>
|
|
|
|
|
|
|
|
|
|
<select id="selectInspectionRobotList" parameterType="InspectionRobot" resultMap="InspectionRobotResult">
|
|
|
|
|
<include refid="selectInspectionRobotVo"/>
|
|
|
|
|
<where>
|
|
|
|
|
<if test="robotCode != null and robotCode != ''"> and robot_code = #{robotCode}</if>
|
2026-08-05 11:10:19 +08:00
|
|
|
<if test="robotId != null and robotId != ''"> and robot_id = #{robotId}</if>
|
2026-06-02 15:01:23 +08:00
|
|
|
<if test="robotName != null and robotName != ''"> and robot_name like concat('%', #{robotName}, '%')</if>
|
|
|
|
|
<if test="robotModel != null and robotModel != ''"> and robot_model = #{robotModel}</if>
|
|
|
|
|
<if test="robotType != null and robotType != ''"> and robot_type = #{robotType}</if>
|
|
|
|
|
<if test="status != null and status != ''"> and status = #{status}</if>
|
|
|
|
|
<if test="currentMapId != null and currentMapId != ''"> and current_map_id = #{currentMapId}</if>
|
|
|
|
|
</where>
|
|
|
|
|
</select>
|
|
|
|
|
|
|
|
|
|
<select id="selectInspectionRobotById" parameterType="String" resultMap="InspectionRobotResult">
|
|
|
|
|
<include refid="selectInspectionRobotVo"/>
|
|
|
|
|
where id = #{id}
|
|
|
|
|
</select>
|
|
|
|
|
|
2026-08-05 11:10:19 +08:00
|
|
|
<select id="selectByRobotId" parameterType="String" resultMap="InspectionRobotResult">
|
|
|
|
|
<include refid="selectInspectionRobotVo"/>
|
|
|
|
|
where robot_id = #{robotId}
|
|
|
|
|
</select>
|
|
|
|
|
|
2026-06-02 15:01:23 +08:00
|
|
|
<insert id="insertInspectionRobot" parameterType="InspectionRobot">
|
|
|
|
|
insert into inspection_robot
|
|
|
|
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
|
|
|
|
<if test="id != null">id,</if>
|
2026-08-05 11:10:19 +08:00
|
|
|
<if test="robotId != null">robot_id,</if>
|
2026-06-02 15:01:23 +08:00
|
|
|
<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="robotCode != null">robot_code,</if>
|
|
|
|
|
<if test="robotName != null">robot_name,</if>
|
|
|
|
|
<if test="robotModel != null">robot_model,</if>
|
|
|
|
|
<if test="robotType != null">robot_type,</if>
|
|
|
|
|
<if test="ipAddress != null">ip_address,</if>
|
|
|
|
|
<if test="port != null">port,</if>
|
|
|
|
|
<if test="currentMapId != null">current_map_id,</if>
|
|
|
|
|
<if test="status != null">status,</if>
|
|
|
|
|
<if test="batteryLevel != null">battery_level,</if>
|
|
|
|
|
<if test="currentPosition != null">current_position,</if>
|
2026-08-05 11:10:19 +08:00
|
|
|
<if test="connectStatus != null">connect_status,</if>
|
|
|
|
|
<if test="archivedStatus != null">archived_status,</if>
|
2026-06-02 15:01:23 +08:00
|
|
|
</trim>
|
|
|
|
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
|
|
|
|
<if test="id != null">#{id},</if>
|
2026-08-05 11:10:19 +08:00
|
|
|
<if test="robotId != null">#{robotId},</if>
|
2026-06-02 15:01:23 +08:00
|
|
|
<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="robotCode != null">#{robotCode},</if>
|
|
|
|
|
<if test="robotName != null">#{robotName},</if>
|
|
|
|
|
<if test="robotModel != null">#{robotModel},</if>
|
|
|
|
|
<if test="robotType != null">#{robotType},</if>
|
|
|
|
|
<if test="ipAddress != null">#{ipAddress},</if>
|
|
|
|
|
<if test="port != null">#{port},</if>
|
|
|
|
|
<if test="currentMapId != null">#{currentMapId},</if>
|
|
|
|
|
<if test="status != null">#{status},</if>
|
|
|
|
|
<if test="batteryLevel != null">#{batteryLevel},</if>
|
|
|
|
|
<if test="currentPosition != null">#{currentPosition},</if>
|
2026-08-05 11:10:19 +08:00
|
|
|
<if test="connectStatus != null">#{connectStatus},</if>
|
|
|
|
|
<if test="archivedStatus != null">#{archivedStatus},</if>
|
2026-06-02 15:01:23 +08:00
|
|
|
</trim>
|
|
|
|
|
</insert>
|
|
|
|
|
|
|
|
|
|
<update id="updateInspectionRobot" parameterType="InspectionRobot">
|
|
|
|
|
update inspection_robot
|
|
|
|
|
<trim prefix="SET" suffixOverrides=",">
|
|
|
|
|
<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="robotCode != null">robot_code = #{robotCode},</if>
|
|
|
|
|
<if test="robotName != null">robot_name = #{robotName},</if>
|
|
|
|
|
<if test="robotModel != null">robot_model = #{robotModel},</if>
|
|
|
|
|
<if test="robotType != null">robot_type = #{robotType},</if>
|
|
|
|
|
<if test="ipAddress != null">ip_address = #{ipAddress},</if>
|
|
|
|
|
<if test="port != null">port = #{port},</if>
|
|
|
|
|
<if test="currentMapId != null">current_map_id = #{currentMapId},</if>
|
|
|
|
|
<if test="status != null">status = #{status},</if>
|
|
|
|
|
<if test="batteryLevel != null">battery_level = #{batteryLevel},</if>
|
|
|
|
|
<if test="currentPosition != null">current_position = #{currentPosition},</if>
|
|
|
|
|
</trim>
|
|
|
|
|
where id = #{id}
|
|
|
|
|
</update>
|
|
|
|
|
|
2026-08-05 11:10:19 +08:00
|
|
|
<update id="updateQuicRuntimeState" parameterType="InspectionRobot">
|
|
|
|
|
update inspection_robot
|
|
|
|
|
set ip_address = #{ipAddress}, port = #{port}, connect_status = #{connectStatus},
|
2026-08-07 16:17:12 +08:00
|
|
|
status = coalesce(#{status}, status),
|
2026-08-05 11:10:19 +08:00
|
|
|
quic_node_id = #{quicNodeId}, quic_session_id = #{quicSessionId},
|
|
|
|
|
quic_boot_id = #{quicBootId}, observed_ip = #{observedIp},
|
|
|
|
|
software_version = #{softwareVersion}, last_heartbeat_time = #{lastHeartbeatTime},
|
|
|
|
|
update_by = 'quic', update_time = #{updateTime}
|
|
|
|
|
where id = #{id}
|
|
|
|
|
</update>
|
|
|
|
|
|
2026-08-07 16:17:12 +08:00
|
|
|
<update id="updateRuntimeStatus" parameterType="InspectionRobot">
|
|
|
|
|
update inspection_robot
|
|
|
|
|
set status = coalesce(#{status}, status),
|
|
|
|
|
battery_level = coalesce(#{batteryLevel}, battery_level),
|
|
|
|
|
current_position = coalesce(#{currentPosition}, current_position)
|
|
|
|
|
where id = #{id}
|
|
|
|
|
</update>
|
|
|
|
|
|
|
|
|
|
<select id="selectRuntimeSyncCandidates" resultMap="InspectionRobotResult">
|
|
|
|
|
select r.id, r.robot_id, r.robot_code, r.robot_name, r.robot_model, r.robot_type,
|
|
|
|
|
r.ip_address, r.port, r.current_map_id, r.status, r.battery_level,
|
|
|
|
|
r.current_position, r.connect_status, r.archived_status
|
|
|
|
|
from inspection_robot r
|
|
|
|
|
where r.connect_status = '1'
|
|
|
|
|
and coalesce(r.archived_status, '0') = '0'
|
2026-08-21 11:48:52 +08:00
|
|
|
and r.last_heartbeat_time is not null
|
|
|
|
|
and r.last_heartbeat_time >= #{heartbeatCutoff}
|
|
|
|
|
<if test="excludedRobotIds != null and excludedRobotIds.size() > 0">
|
|
|
|
|
and lower(r.robot_id) not in
|
|
|
|
|
<foreach collection="excludedRobotIds" item="robotId" open="(" separator="," close=")">
|
|
|
|
|
#{robotId}
|
|
|
|
|
</foreach>
|
|
|
|
|
</if>
|
2026-08-07 16:17:12 +08:00
|
|
|
and (select count(*)
|
|
|
|
|
from inspection_robot_device d
|
|
|
|
|
where d.robot_id = r.robot_id
|
|
|
|
|
and d.device_kind = 1
|
|
|
|
|
and d.enabled = '1'
|
|
|
|
|
and d.online_status = '1') = 1
|
|
|
|
|
</select>
|
|
|
|
|
|
2026-08-21 11:48:52 +08:00
|
|
|
<select id="selectStaleConnectedRobots" resultMap="InspectionRobotResult">
|
|
|
|
|
select r.id, r.robot_id, r.connect_status, r.last_heartbeat_time, r.archived_status
|
|
|
|
|
from inspection_robot r
|
|
|
|
|
where r.connect_status = '1'
|
|
|
|
|
and coalesce(r.archived_status, '0') = '0'
|
|
|
|
|
and (r.last_heartbeat_time is null or r.last_heartbeat_time < #{heartbeatCutoff})
|
|
|
|
|
<if test="excludedRobotIds != null and excludedRobotIds.size() > 0">
|
|
|
|
|
and lower(r.robot_id) not in
|
|
|
|
|
<foreach collection="excludedRobotIds" item="robotId" open="(" separator="," close=")">
|
|
|
|
|
#{robotId}
|
|
|
|
|
</foreach>
|
|
|
|
|
</if>
|
|
|
|
|
</select>
|
|
|
|
|
|
|
|
|
|
<update id="markHeartbeatExpiredOffline">
|
|
|
|
|
update inspection_robot
|
|
|
|
|
set connect_status = '0', status = '1',
|
|
|
|
|
update_by = 'heartbeat-timeout', update_time = #{offlineTime}
|
|
|
|
|
where id = #{id}
|
|
|
|
|
and connect_status = '1'
|
|
|
|
|
and (last_heartbeat_time is null or last_heartbeat_time < #{heartbeatCutoff})
|
|
|
|
|
</update>
|
|
|
|
|
|
2026-08-05 11:10:19 +08:00
|
|
|
<update id="archiveInspectionRobotByIds" parameterType="String">
|
|
|
|
|
update inspection_robot set archived_status = '1', connect_status = '0',
|
|
|
|
|
update_time = sysdate(), update_by = #{updateBy}
|
|
|
|
|
where id in
|
|
|
|
|
<foreach item="id" collection="ids" open="(" separator="," close=")">
|
|
|
|
|
#{id}
|
|
|
|
|
</foreach>
|
|
|
|
|
</update>
|
|
|
|
|
|
2026-06-02 15:01:23 +08:00
|
|
|
<delete id="deleteInspectionRobotById" parameterType="String">
|
|
|
|
|
delete from inspection_robot where id = #{id}
|
|
|
|
|
</delete>
|
|
|
|
|
|
|
|
|
|
<delete id="deleteInspectionRobotByIds" parameterType="String">
|
|
|
|
|
delete from inspection_robot where id in
|
|
|
|
|
<foreach item="id" collection="array" open="(" separator="," close=")">
|
|
|
|
|
#{id}
|
|
|
|
|
</foreach>
|
|
|
|
|
</delete>
|
|
|
|
|
|
|
|
|
|
<select id="selectInspectionRobotVoList" parameterType="InspectionRobot" resultMap="InspectionRobotVoResult">
|
|
|
|
|
select r.id, r.create_by, r.create_time, r.update_by, r.update_time, r.remark,
|
2026-08-05 11:10:19 +08:00
|
|
|
r.robot_id, r.robot_code, r.robot_name, r.robot_model, r.robot_type,
|
2026-06-02 15:01:23 +08:00
|
|
|
r.ip_address, r.port, r.current_map_id,
|
|
|
|
|
m.map_name as current_map_name,
|
2026-08-05 11:10:19 +08:00
|
|
|
r.status, r.battery_level, r.current_position,
|
|
|
|
|
r.connect_status, r.quic_node_id, r.quic_session_id, r.quic_boot_id,
|
|
|
|
|
r.observed_ip, r.software_version, r.last_heartbeat_time,
|
|
|
|
|
(select count(*) from inspection_robot_device d where d.robot_id = r.robot_id) as device_total,
|
|
|
|
|
(select count(*) from inspection_robot_device d where d.robot_id = r.robot_id and d.online_status = '1') as online_device_count,
|
|
|
|
|
(select count(*) from inspection_robot_device d where d.robot_id = r.robot_id and (d.health_status = 3 or d.has_error = '1')) as fault_device_count,
|
2026-06-15 16:46:04 +08:00
|
|
|
u1.nick_name as create_by_name, u2.nick_name as update_by_name, m.map_source_name as robot_map_name
|
2026-06-02 15:01:23 +08:00
|
|
|
from inspection_robot r
|
|
|
|
|
left join inspection_map m on r.current_map_id = m.id
|
|
|
|
|
left join sys_user u1 on r.create_by = u1.user_name <!-- 创建人关联用户 -->
|
|
|
|
|
left join sys_user u2 on r.update_by = u2.user_name <!-- 更新人关联用户 -->
|
|
|
|
|
<where>
|
2026-08-05 11:10:19 +08:00
|
|
|
and coalesce(r.archived_status, '0') = '0'
|
|
|
|
|
<if test="robotId != null and robotId != ''"> and r.robot_id = #{robotId}</if>
|
2026-06-02 15:01:23 +08:00
|
|
|
<if test="robotCode != null and robotCode != ''"> and r.robot_code = #{robotCode}</if>
|
|
|
|
|
<if test="robotName != null and robotName != ''"> and r.robot_name like concat('%', #{robotName}, '%')</if>
|
|
|
|
|
<if test="robotModel != null and robotModel != ''"> and r.robot_model = #{robotModel}</if>
|
|
|
|
|
<if test="robotType != null and robotType != ''"> and r.robot_type = #{robotType}</if>
|
2026-08-05 11:10:19 +08:00
|
|
|
<if test="connectStatus != null and connectStatus != ''"> and r.connect_status = #{connectStatus}</if>
|
2026-06-02 15:01:23 +08:00
|
|
|
<if test="status != null and status != ''"> and r.status = #{status}</if>
|
|
|
|
|
<if test="currentMapId != null and currentMapId != ''"> and r.current_map_id = #{currentMapId}</if>
|
|
|
|
|
<if test="ipAddress != null and ipAddress != ''"> and r.ip_address = #{ipAddress}</if>
|
|
|
|
|
</where>
|
|
|
|
|
</select>
|
|
|
|
|
</mapper>
|