select preset_pos_id,
preset_pos_code,
preset_pos_name,
patrol_point_id,
channel_id,
coordinate_type,
stop_time,
channel_img,
description,
is_enable,
create_time,
alg_subtype_code,
eqp_book_id,
channel_code,
channel_type,
patrol_device_code,
video_nvr_code
from patrol_preset_pos
insert into patrol_preset_pos
preset_pos_id,preset_pos_code,preset_pos_name,patrol_point_id,channel_id,coordinate_type,stop_time,channel_img,description,is_enable,create_time,alg_subtype_code,eqp_book_id,channel_code,channel_type,patrol_device_code,video_nvr_code,#{presetPosId},#{presetPosCode},#{presetPosName},#{patrolPointId},#{channelId},#{coordinateType},#{stopTime},#{channelImg},#{description},#{isEnable},#{createTime},#{algSubtypeCode},#{eqpBookId},#{channelCode},#{channelType},#{patrolDeviceCode},#{videoNvrCode},
update patrol_preset_pos
preset_pos_name = #{presetPosName},patrol_point_id = #{patrolPointId},coordinate_type = #{coordinateType},stop_time = #{stopTime},channel_img = #{channelImg},description = #{description},create_time = #{createTime},alg_subtype_code = #{algSubtypeCode},video_nvr_code = #{videoNvrCode},
where preset_pos_id = #{presetPosId}
delete
from patrol_preset_pos
where preset_pos_id = #{presetPosId}
delete
from basedata_patrolpoint_preset a
where a.patrolpoint_preset_id =
(select b.patrolpoint_preset_id
from basedata_patrolpoint_preset b
left join patrol_preset_pos c on c.preset_pos_code = b.preset_code
and a.eqp_book_id = b.eqp_book_id and c.channel_id = b.channel_id and
b.patrol_point_id = c.patrol_point_id
where c.preset_pos_id = #{presetPosId} limit 1
)
delete from patrol_preset_pos
where preset_pos_id in
#{presetPosId}
delete from basedata_patrolpoint_preset where video_nvr_code is not null and patrol_point_id in
(select patrol_point_id from patrol_preset_pos where preset_pos_id in
#{presetPosId}
)