select c.config_id, c.config_type, c.dept_id, c.vehicle_id, c.mileage_threshold, c.daily_alert_limit, c.alert_interval, c.notify_user_ids, c.status, c.remark, c.create_by, c.create_time, c.update_by, c.update_time, CASE WHEN c.config_type = 'DEPT' THEN d.dept_name WHEN c.config_type = 'VEHICLE' THEN v.vehicle_no ELSE NULL END as target_name from tb_vehicle_alert_config c left join sys_dept d on c.dept_id = d.dept_id left join tb_vehicle_info v on c.vehicle_id = v.vehicle_id insert into tb_vehicle_alert_config config_type, dept_id, vehicle_id, mileage_threshold, daily_alert_limit, alert_interval, notify_user_ids, status, remark, create_by, create_time #{configType}, #{deptId}, #{vehicleId}, #{mileageThreshold}, #{dailyAlertLimit}, #{alertInterval}, #{notifyUserIds}, #{status}, #{remark}, #{createBy}, now() update tb_vehicle_alert_config config_type = #{configType}, dept_id = #{deptId}, vehicle_id = #{vehicleId}, mileage_threshold = #{mileageThreshold}, daily_alert_limit = #{dailyAlertLimit}, alert_interval = #{alertInterval}, notify_user_ids = #{notifyUserIds}, status = #{status}, remark = #{remark}, update_by = #{updateBy}, update_time = now() where config_id = #{configId} delete from tb_vehicle_alert_config where config_id = #{configId} delete from tb_vehicle_alert_config where config_id in #{configId}