吉安感知网项目-后端
rain
2026-01-09 3ae46f2a59f9d4e751f78d8dc1a896ceba5ca495
drone-service/drone-fw/src/main/java/org/sxkj/fw/area/mapper/FwAreaDivideMapper.xml
@@ -3,7 +3,7 @@
<mapper namespace="org.sxkj.fw.area.mapper.FwAreaDivideMapper">
    <!-- 通用查询映射结果 -->
    <resultMap id="fwAreaDivideResultMap" type="org.sxkj.fw.area.entity.FwAreaDivideEntity">
    <resultMap id="fwAreaDivideResultMap" type="org.sxkj.fw.area.vo.FwAreaDivideVO">
        <result column="id" property="id"/>
        <result column="area_name" property="areaName"/>
        <result column="longitude" property="longitude"/>
@@ -20,6 +20,9 @@
        <result column="fly_date_start" property="flyDateStart"/>
        <result column="fly_date_end" property="flyDateEnd"/>
        <result column="area_code" property="areaCode"/>
        <result column="police_station_name" property="policeStationName"/>
        <result column="police_station_contact_person" property="policeStationContactPerson"/>
        <result column="police_station_contact_phone" property="policeStationContactPhone"/>
        <result column="create_user" property="createUser"/>
        <result column="create_dept" property="createDept"/>
        <result column="create_time" property="createTime"/>
@@ -31,81 +34,253 @@
    <select id="selectFwAreaDividePage" resultMap="fwAreaDivideResultMap">
        select * from ja_fw_area_divide
        select
        ad.id,
        ad.area_name,
        ad.longitude,
        ad.latitude,
        ad.area_size,
        concat(ST_AsText(ad.geom), ' | ', ST_SRID(ad.geom)) as geom,
        ad.area_type,
        ad.trigger_condition,
        ad.response_mechanism,
        ad.control_level,
        ad.police_station_id,
        ad.fly_time_start,
        ad.fly_time_end,
        ad.fly_date_start,
        ad.fly_date_end,
        ad.area_code,
        ps.station_name as police_station_name,
        ad.create_user,
        ad.create_dept,
        ad.create_time,
        ad.update_user,
        ad.update_time,
        ad.status,
        ad.is_deleted
        from ja_fw_area_divide ad
        left join ja_fw_police_station ps on ps.id = ad.police_station_id and ps.is_deleted = 0
        <where>
            is_deleted = 0
            ad.is_deleted = 0
            <if test="param2.id != null and param2.id != ''">
                and id = #{param2.id}
                and ad.id = #{param2.id}
            </if>
            <if test="param2.areaName != null and param2.areaName != ''">
                and area_name like concat('%', #{param2.areaName}, '%')
                and ad.area_name like concat('%', #{param2.areaName}, '%')
            </if>
            <if test="param2.longitude != null and param2.longitude != ''">
                and longitude = #{param2.longitude}
                and ad.longitude = #{param2.longitude}
            </if>
            <if test="param2.latitude != null and param2.latitude != ''">
                and latitude = #{param2.latitude}
                and ad.latitude = #{param2.latitude}
            </if>
            <if test="param2.areaSize != null and param2.areaSize != ''">
                and area_size = #{param2.areaSize}
                and ad.area_size = #{param2.areaSize}
            </if>
            <if test="param2.geom != null and param2.geom != ''">
                and geom = #{param2.geom}
                and ST_Equals(
                    ad.geom,
                    ST_SRID(
                        ST_GeomFromText(
                            trim(case when instr(#{param2.geom}, '|') &gt; 0 then substring_index(#{param2.geom}, '|', 1) else #{param2.geom} end)
                        ),
                        case when instr(#{param2.geom}, '|') &gt; 0 then cast(trim(substring_index(#{param2.geom}, '|', -1)) as unsigned) else 4326 end
                    )
                )
            </if>
            <if test="param2.areaType != null and param2.areaType != ''">
                and area_type = #{param2.areaType}
                and ad.area_type = #{param2.areaType}
            </if>
            <if test="param2.triggerCondition != null and param2.triggerCondition != ''">
                and trigger_condition = #{param2.triggerCondition}
                and ad.trigger_condition = #{param2.triggerCondition}
            </if>
            <if test="param2.responseMechanism != null and param2.responseMechanism != ''">
                and response_mechanism = #{param2.responseMechanism}
                and ad.response_mechanism = #{param2.responseMechanism}
            </if>
            <if test="param2.controlLevel != null and param2.controlLevel != ''">
                and control_level = #{param2.controlLevel}
                and ad.control_level = #{param2.controlLevel}
            </if>
            <if test="param2.policeStationId != null and param2.policeStationId != ''">
                and police_station_id = #{param2.policeStationId}
                and ad.police_station_id = #{param2.policeStationId}
            </if>
            <if test="param2.flyTimeStart != null and param2.flyTimeStart != ''">
                and fly_time_start &gt;= #{param2.flyTimeStart}
                and ad.fly_time_start &gt;= #{param2.flyTimeStart}
            </if>
            <if test="param2.flyTimeEnd != null and param2.flyTimeEnd != ''">
                and fly_time_end &lt;= #{param2.flyTimeEnd}
                and ad.fly_time_end &lt;= #{param2.flyTimeEnd}
            </if>
            <if test="param2.flyDateStart != null and param2.flyDateStart != ''">
                and fly_date_start &gt;= #{param2.flyDateStart}
                and ad.fly_date_start &gt;= #{param2.flyDateStart}
            </if>
            <if test="param2.flyDateEnd != null and param2.flyDateEnd != ''">
                and fly_date_end &lt;= #{param2.flyDateEnd}
                and ad.fly_date_end &lt;= #{param2.flyDateEnd}
            </if>
            <if test="param2.areaCode != null and param2.areaCode != ''">
                and area_code = #{param2.areaCode}
            </if>
            <if test="param2.createUser != null and param2.createUser != ''">
                and create_user = #{param2.createUser}
            </if>
            <if test="param2.createDept != null and param2.createDept != ''">
                and create_dept = #{param2.createDept}
            </if>
            <if test="param2.createTime != null and param2.createTime != ''">
                and create_time = #{param2.createTime}
            </if>
            <if test="param2.updateUser != null and param2.updateUser != ''">
                and update_user = #{param2.updateUser}
            </if>
            <if test="param2.updateTime != null and param2.updateTime != ''">
                and update_time = #{param2.updateTime}
            </if>
            <if test="param2.status != null and param2.status != ''">
                and status = #{param2.status}
                and ad.area_code = #{param2.areaCode}
            </if>
        </where>
    </select>
    <select id="selectFwAreaDivideDetail" resultMap="fwAreaDivideResultMap">
        select
        ad.id,
        ad.area_name,
        ad.longitude,
        ad.latitude,
        ad.area_size,
        concat(ST_AsText(ad.geom), ' | ', ST_SRID(ad.geom)) as geom,
        ad.area_type,
        ad.trigger_condition,
        ad.response_mechanism,
        ad.control_level,
        ad.police_station_id,
        ad.fly_time_start,
        ad.fly_time_end,
        ad.fly_date_start,
        ad.fly_date_end,
        ad.area_code,
        ps.station_name as police_station_name,
        ps.contact_person as police_station_contact_person,
        ps.contact_phone as police_station_contact_phone,
        ad.create_user,
        ad.create_dept,
        ad.create_time,
        ad.update_user,
        ad.update_time,
        ad.status,
        ad.is_deleted
        from ja_fw_area_divide ad
        left join ja_fw_police_station ps on ps.id = ad.police_station_id and ps.is_deleted = 0
        where ad.is_deleted = 0
          and ad.id = #{id}
    </select>
    <select id="exportFwAreaDivide" resultType="org.sxkj.fw.area.excel.FwAreaDivideExcel">
        SELECT * FROM ja_fw_area_divide ${ew.customSqlSegment}
        SELECT
        id,
        area_name,
        longitude,
        latitude,
        area_size,
        concat(ST_AsText(geom), ' | ', ST_SRID(geom)) as geom,
        area_type,
        trigger_condition,
        response_mechanism,
        control_level,
        police_station_id,
        fly_time_start,
        fly_time_end,
        fly_date_start,
        fly_date_end,
        area_code,
        create_user,
        create_dept,
        create_time,
        update_user,
        update_time,
        status,
        is_deleted
        FROM ja_fw_area_divide ${ew.customSqlSegment}
    </select>
    <insert id="insertWithGeom" parameterType="org.sxkj.fw.area.entity.FwAreaDivideEntity" useGeneratedKeys="true" keyProperty="id">
        insert into ja_fw_area_divide (
            id,
            area_name,
            longitude,
            latitude,
            area_size,
            geom,
            area_type,
            trigger_condition,
            response_mechanism,
            control_level,
            police_station_id,
            fly_time_start,
            fly_time_end,
            fly_date_start,
            fly_date_end,
            area_code,
            create_user,
            create_dept,
            create_time,
            update_user,
            update_time,
            status,
            is_deleted
        ) values (
            #{id},
            #{areaName},
            #{longitude},
            #{latitude},
            #{areaSize},
            <choose>
                <when test="geom != null and geom != ''">
                    ST_SRID(
                        ST_GeomFromText(
                            trim(case when instr(#{geom}, '|') &gt; 0 then substring_index(#{geom}, '|', 1) else #{geom} end)
                        ),
                        case when instr(#{geom}, '|') &gt; 0 then cast(trim(substring_index(#{geom}, '|', -1)) as unsigned) else 4326 end
                    )
                </when>
                <otherwise>null</otherwise>
            </choose>,
            #{areaType},
            #{triggerCondition},
            #{responseMechanism},
            #{controlLevel},
            #{policeStationId},
            #{flyTimeStart},
            #{flyTimeEnd},
            #{flyDateStart},
            #{flyDateEnd},
            #{areaCode},
            #{createUser},
            #{createDept},
            #{createTime},
            #{updateUser},
            #{updateTime},
            #{status},
            #{isDeleted}
        )
    </insert>
    <update id="updateWithGeomById" parameterType="org.sxkj.fw.area.entity.FwAreaDivideEntity">
        update ja_fw_area_divide
        <set>
            <if test="areaName != null">area_name = #{areaName},</if>
            <if test="longitude != null">longitude = #{longitude},</if>
            <if test="latitude != null">latitude = #{latitude},</if>
            <if test="areaSize != null">area_size = #{areaSize},</if>
            <if test="geom != null and geom != ''">
                geom = ST_SRID(
                    ST_GeomFromText(
                        trim(case when instr(#{geom}, '|') &gt; 0 then substring_index(#{geom}, '|', 1) else #{geom} end)
                    ),
                    case when instr(#{geom}, '|') &gt; 0 then cast(trim(substring_index(#{geom}, '|', -1)) as unsigned) else 4326 end
                ),
            </if>
            <if test="areaType != null">area_type = #{areaType},</if>
            <if test="triggerCondition != null">trigger_condition = #{triggerCondition},</if>
            <if test="responseMechanism != null">response_mechanism = #{responseMechanism},</if>
            <if test="controlLevel != null">control_level = #{controlLevel},</if>
            <if test="policeStationId != null">police_station_id = #{policeStationId},</if>
            <if test="flyTimeStart != null">fly_time_start = #{flyTimeStart},</if>
            <if test="flyTimeEnd != null">fly_time_end = #{flyTimeEnd},</if>
            <if test="flyDateStart != null">fly_date_start = #{flyDateStart},</if>
            <if test="flyDateEnd != null">fly_date_end = #{flyDateEnd},</if>
            <if test="areaCode != null">area_code = #{areaCode},</if>
            <if test="createUser != null">create_user = #{createUser},</if>
            <if test="createDept != null">create_dept = #{createDept},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="updateUser != null">update_user = #{updateUser},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="status != null">status = #{status},</if>
            <if test="isDeleted != null">is_deleted = #{isDeleted},</if>
        </set>
        where id = #{id}
    </update>
</mapper>