吉安感知网项目-后端
linwei
2026-06-09 1fe7ed3c48a35620811b2bde3c88139e467f60be
fix(workorder): 修复工单和巡检任务类型查询的逗号分隔值处理

- 修改 GdPatrolTaskMapper.xml 中 patrolTaskType 参数的处理逻辑
- 修改 GdWorkOrderMapper.xml 中 workOrderType 参数的处理逻辑
- 使用 PostgreSQL 的 string_agg 和 string_to_array 函数处理逗号分隔的字符串
- 将逗号分隔的字符串转换为带引号的格式进行匹配
- 修复因类型不匹配导致的数据库查询报错问题
2 files modified
16 ■■■■ changed files
drone-service/drone-gd/src/main/java/org/sxkj/gd/workorder/mapper/GdPatrolTaskMapper.xml 8 ●●●● patch | view | raw | blame | history
drone-service/drone-gd/src/main/java/org/sxkj/gd/workorder/mapper/GdWorkOrderMapper.xml 8 ●●●● patch | view | raw | blame | history
drone-service/drone-gd/src/main/java/org/sxkj/gd/workorder/mapper/GdPatrolTaskMapper.xml
@@ -65,7 +65,13 @@
                and pt.patrol_task_name like concat('%',#{param2.patrolTaskName},'%')
            </if>
            <if test="param2.patrolTaskType != null and param2.patrolTaskType != ''">
                and pt.patrol_task_type like concat('%',#{param2.patrolTaskType},'%')
                /* 将逗号分隔的字符串转换为带引号的格式,如 "road,road1" 转为 "\"road\",\"road1\"" */
                and pt.patrol_task_type like concat('%',
                (
                select string_agg(concat('"', trim(arr_val), '"'), ',')
                from unnest(string_to_array(#{param2.patrolTaskType}, ',')) as arr_val
                ),
                '%')
            </if>
            <if test="param2.taskStatus != null and param2.taskStatus != ''">
                /* 报错信息中出现了这个参数,务必加强转 */
drone-service/drone-gd/src/main/java/org/sxkj/gd/workorder/mapper/GdWorkOrderMapper.xml
@@ -115,7 +115,13 @@
                and wo.work_order_name like concat('%',#{param2.workOrderName},'%')
            </if>
            <if test="param2.workOrderType != null and param2.workOrderType != ''">
                 and wo.work_order_type like concat('%',#{param2.workOrderType},'%')
                /* 将逗号分隔的字符串转换为带引号的格式,如 "road,road1" 转为 "\"road\",\"road1\"" */
                and wo.work_order_type like concat('%',
                (
                select string_agg(concat('"', trim(arr_val), '"'), ',')
                from unnest(string_to_array(#{param2.workOrderType}, ',')) as arr_val
                ),
                '%')
            </if>
            <if test="param2.createUser != null ">
                /* 修改点2:过滤条件也进行类型对齐 */