From caf9d837bc7b2bb6de6b7ba0aac72c3ab7ae93a8 Mon Sep 17 00:00:00 2001
From: linwei <872216696@qq.com>
Date: Wed, 05 Aug 2026 11:19:31 +0800
Subject: [PATCH] fix(workorder): 修复管理员查询状态列表权限问题
---
drone-service/drone-gd/src/main/java/org/sxkj/gd/workorder/mapper/GdManageDeviceMapper.xml | 135 +++++++++++++++++++++++++++-----------------
1 files changed, 83 insertions(+), 52 deletions(-)
diff --git a/drone-service/drone-gd/src/main/java/org/sxkj/gd/workorder/mapper/GdManageDeviceMapper.xml b/drone-service/drone-gd/src/main/java/org/sxkj/gd/workorder/mapper/GdManageDeviceMapper.xml
index adbcf10..8befe64 100644
--- a/drone-service/drone-gd/src/main/java/org/sxkj/gd/workorder/mapper/GdManageDeviceMapper.xml
+++ b/drone-service/drone-gd/src/main/java/org/sxkj/gd/workorder/mapper/GdManageDeviceMapper.xml
@@ -3,77 +3,108 @@
<mapper namespace="org.sxkj.gd.workorder.mapper.GdManageDeviceMapper">
<!-- 通用查询映射结果 -->
- <resultMap id="gdManageDeviceResultMap" type="org.sxkj.gd.workorder.entity.GdManageDeviceEntity">
+ <resultMap id="gdManageDeviceResultMap" type="org.sxkj.gd.workorder.vo.GdManageDeviceVO">
<result column="id" property="id"/>
<result column="device_sn" property="deviceSn"/>
<result column="device_name" property="deviceName"/>
<result column="nickname" property="nickname"/>
- <result column="workspace_id" property="workspaceId"/>
- <result column="device_type" property="deviceType"/>
- <result column="sub_type" property="subType"/>
<result column="device_payload" property="devicePayload"/>
<result column="longitude" property="longitude"/>
<result column="latitude" property="latitude"/>
- <result column="user_id" property="userId"/>
- <result column="domain" property="domain"/>
- <result column="firmware_version" property="firmwareVersion"/>
- <result column="compatible_status" property="compatibleStatus"/>
- <result column="version" property="version"/>
- <result column="device_index" property="deviceIndex"/>
- <result column="child_sn" property="childSn"/>
- <result column="bound_time" property="boundTime"/>
- <result column="bound_status" property="boundStatus"/>
- <result column="login_time" property="loginTime"/>
- <result column="device_desc" property="deviceDesc"/>
- <result column="url_normal" property="urlNormal"/>
- <result column="url_select" property="urlSelect"/>
- <result column="reserve_id" property="reserveId"/>
- <result column="creama_name" property="creamaName"/>
- <result column="machine_nest_sn" property="machineNestSn"/>
- <result column="operate_password" property="operatePassword"/>
- <result column="mode_code" property="modeCode"/>
- <result column="movable" property="movable"/>
- <result column="insure_expired_time" property="insureExpiredTime"/>
- <result column="flow_type" property="flowType"/>
- <result column="maintenance_start" property="maintenanceStart"/>
- <result column="maintenance_end" property="maintenanceEnd"/>
- <result column="insure_start_time" property="insureStartTime"/>
- <result column="eid" property="eid"/>
- <result column="traffic_remaining" property="trafficRemaining"/>
- <result column="traffic_expire_time" property="trafficExpireTime"/>
- <result column="hidden_flag" property="hiddenFlag"/>
- <result column="deployment_mode" property="deploymentMode"/>
- <result column="dept_id" property="deptId"/>
+ <result column="mode_code" property="modeCode"/>
<result column="create_time" property="createTime"/>
- <result column="update_time" property="updateTime"/>
- <result column="is_deleted" property="isDeleted"/>
- <result column="area_code" property="areaCode"/>
- <result column="traffic_data" property="trafficData"/>
- <result column="dem_status" property="demStatus"/>
+ <result column="device_dept_name" property="deviceDeptName"/>
+ <result column="maintenance_state" property="maintenanceState"/>
</resultMap>
<select id="selectGdManageDevicePage" resultMap="gdManageDeviceResultMap">
- select id, device_sn, device_name, nickname, device_payload,longitude,latitude
- from ja_gd_manage_device
- where is_deleted = 0
+ select
+ md.id,
+ md.device_sn,
+ md.device_name,
+ md.nickname,
+ md.device_payload,
+ md.longitude,
+ md.latitude,
+ md.mode_code,
+ md.create_time,
+ md.maintenance_state,
+ bd.dept_name as device_dept_name
+ from
+ ja_gd_manage_device md
+ left join
+ /* 修改点1:双向转型对齐,确保 bigint 和 varchar 都能匹配 */
+ blade_dept bd on md.create_dept::text = bd.id::text
+ <where>
+ /* 修改点2:去掉开头多余的 and,保持 SQL 语法严谨 */
+ md.is_deleted = 0
+ <if test="param2.nickname != null and param2.nickname != ''">
+ and md.nickname like concat('%',#{param2.nickname},'%')
+ </if>
+ <if test="param2.deptId != null">
+ /* 修改点3:参数过滤也建议加转型,防止 param2.deptId 被 MyBatis 传为 String */
+ and md.create_dept::text = #{param2.deptId}::text
+ </if>
+ <if test="param2.location != null and param2.location != ''">
+ and md.location like concat('%',#{param2.location},'%')
+ </if>
+ <if test="param2.modeCode != null and param2.modeCode != ''">
+ and md.mode_code::text = #{param2.modeCode}::text
+ </if>
+ <if test="param2.deviceType != null and param2.deviceType != ''">
+ and md.device_type::text = #{param2.deviceType}::text
+ </if>
+ <if test="param2.maintenanceState != null">
+ and md.maintenance_state = #{param2.maintenanceState}
+ </if>
+ </where>
</select>
<select id="exportGdManageDevice" resultType="org.sxkj.gd.workorder.excel.GdManageDeviceExcel">
- SELECT * FROM ja_gd_manage_device ${ew.customSqlSegment}
+ SELECT
+ *
+ FROM
+ ja_gd_manage_device ${ew.customSqlSegment}
</select>
<select id="selectGdManageDevice" resultType="org.sxkj.gd.workorder.vo.GdManageDeviceVO">
- select id, device_sn, device_name, nickname, device_payload,longitude,latitude
- from ja_gd_manage_device
- where is_deleted = 0
- <if test="deviceIds != null and deviceIds.size() > 0">
- and id in
- <foreach item="item" collection="deviceIds" index="index" open="(" close=")" separator=",">
- #{item}
- </foreach>
- </if>
+ select
+ md.id,
+ md.device_sn,
+ md.device_name,
+ md.nickname,
+ md.device_payload,
+ md.longitude,
+ md.latitude,
+ md.geom,
+ d2.height as height
+ from
+ ja_gd_manage_device md
+ left join ja_gd_manage_device d2
+ on md.device_sn::text = d2.device_sn::text
+ and d2.device_type = '0'
+ <where>
+ md.is_deleted = 0
+ AND md.child_sn IS NOT NULL
+ AND trim(md.child_sn) != ''
+ <if test="deviceIds != null and deviceIds.size() > 0">
+ and md.id::text in
+ <foreach item="item" collection="deviceIds" index="index" open="(" close=")" separator=",">
+ #{item}::text
+ </foreach>
+ </if>
+ <if test="devicePayload != null and devicePayload != ''">
+ and md.device_payload like concat('%', #{devicePayload}, '%')
+ </if>
+ <if test="geom != null and geom != ''">
+ AND public.st_intersects ( md.geom, public.st_geomfromtext(#{geom}::text, 4326))
+ </if>
+ <if test="deviceType != null and deviceType != '' ">
+ and md.device_type::text = #{deviceType}::text
+ </if>
+ </where>
</select>
</mapper>
--
Gitblit v1.9.3