liusuyi
2024-10-10 38f29e38fcc668171dc05c53d40a36b895c86102
ard-work/src/main/resources/mapper/alarmpoints/ArdAlarmpointsWellMapper.xml
@@ -294,4 +294,37 @@
        <= (select cast(sc.config_value as decimal) from sys_config sc where sc.config_key = 'appAlarmPointsDistance')
        order by f_compute_distance(cast(#{longitude} as decimal),cast(#{latitude} as decimal),aaw.longitude,aaw.latitude) desc limit 1 offset 0
    </select>
    <select id="getWellById" resultMap="ArdAlarmpointsWellOnlyResult">
        select aaw.* from ard_alarmpoints_well aaw where aaw.id = #{id}
    </select>
    <select id="conditionList" resultType="com.ruoyi.alarmpoints.well.domain.ArdAlarmpointsWell">
        Select * from ard_alarmpoints_well well
        where WHERE well.well_id = #{wellId}
        and well.dept_id in
        <foreach item="deptList" collection="deptList" open="(" separator="," close=")">
            #{deptList}
        </foreach>
    </select>
    <select id="getArdAlarmpointsWellByDeptIdAndDistance" resultMap="ArdAlarmpointsWellOnlyResult">
        select * from ard_alarmpoints_well aaw
        where aaw.dept_id in (
        with recursive rsd as (
        select sd.dept_id from sys_dept sd where sd.dept_id = #{deptId}
        union
        select csd.dept_id from sys_dept csd inner join rsd on rsd.dept_id = csd.parent_id
        )
        select * from rsd) and f_compute_distance(aaw.longitude,aaw.latitude,cast(#{lonM} as numeric),cast(#{latM} as numeric)) &lt;= (select max(t.distance) from (
        select f_compute_distance(cast(#{lonM} as numeric),cast(#{latM} as numeric),cast(#{lonA} as numeric),cast(#{latA} as numeric)) as distance
        union
        select f_compute_distance(cast(#{lonM} as numeric),cast(#{latM} as numeric),cast(#{lonB} as numeric),cast(#{latB} as numeric)) as distance
        union
        select f_compute_distance(cast(#{lonM} as numeric),cast(#{latM} as numeric),cast(#{lonC} as numeric),cast(#{latC} as numeric)) as distance
        union
        select f_compute_distance(cast(#{lonM} as numeric),cast(#{latM} as numeric),cast(#{lonD} as numeric),cast(#{latD} as numeric)) as distance
        )t)
    </select>
</mapper>