fix(workorder): 修复工单和巡检任务类型查询的逗号分隔值处理
- 修改 GdPatrolTaskMapper.xml 中 patrolTaskType 参数的处理逻辑
- 修改 GdWorkOrderMapper.xml 中 workOrderType 参数的处理逻辑
- 使用 PostgreSQL 的 string_agg 和 string_to_array 函数处理逗号分隔的字符串
- 将逗号分隔的字符串转换为带引号的格式进行匹配
- 修复因类型不匹配导致的数据库查询报错问题
| | |
| | | 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 != ''"> |
| | | /* 报错信息中出现了这个参数,务必加强转 */ |
| | |
| | | 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:过滤条件也进行类型对齐 */ |