| | |
| | | d2.height as height |
| | | from |
| | | ja_gd_manage_device md |
| | | /* 修改点1:关联条件双向转型 text(规避之前的 bigint = varchar 错误) */ |
| | | left join ja_gd_manage_device d2 on md.device_sn::text = d2.device_sn::text and d2.device_type = '0' |
| | | left join ja_gd_manage_device d2 |
| | | on md.device_sn::text = d2.device_sn::text |
| | | and d2.device_type = '0' |
| | | <where> |
| | | <if test="deviceIds != null and deviceIds.size() > 0"> |
| | | and md.id::text in |
| | |
| | | </foreach> |
| | | </if> |
| | | <if test="devicePayload != null and devicePayload != ''"> |
| | | and md.device_payload like concat('%',#{devicePayload},'%') |
| | | and md.device_payload like concat('%', #{devicePayload}, '%') |
| | | </if> |
| | | <if test="geom != null and geom != ''"> |
| | | /* 修改点2:增加显式类型转换 ::text,并建议指定 SRID (如 4326) */ |
| | | and ST_Intersects(md.geom, ST_GeomFromText(#{geom}::text, 4326)) |
| | | /* 确保这里是第一个条件时,and 能被 MyBatis 正确处理,或者直接去掉这个 and */ |
| | | and ST_Intersects(md.geom, ST_GeomFromText(#{geom}::text)) |
| | | </if> |
| | | <if test="deviceType != null and deviceType != '' "> |
| | | and md.device_type::text = #{deviceType}::text |
| | | </if> |
| | | /* 将固定条件放在最前面或最后面,确保逻辑严健 */ |
| | | and md.is_deleted = 0 |
| | | </where> |
| | | </select> |