select s.stats_id, s.vehicle_id, s.vehicle_no, s.stat_date, s.total_mileage, s.task_mileage, s.non_task_mileage, s.task_ratio, s.gps_point_count, s.task_count, s.segment_count, s.data_source, s.create_time, s.update_time, GROUP_CONCAT(DISTINCT d.dept_name ORDER BY d.dept_name SEPARATOR ',') as dept_name, vd.dept_id from tb_vehicle_mileage_stats s left join tb_vehicle_info v on s.vehicle_id = v.vehicle_id left join tb_vehicle_dept vd on v.vehicle_id = vd.vehicle_id left join sys_dept d on vd.dept_id = d.dept_id insert into tb_vehicle_mileage_stats vehicle_id, vehicle_no, stat_date, total_mileage, task_mileage, non_task_mileage, task_ratio, gps_point_count, task_count, segment_count, data_source, create_time #{vehicleId}, #{vehicleNo}, #{statDate}, #{totalMileage}, #{taskMileage}, #{nonTaskMileage}, #{taskRatio}, #{gpsPointCount}, #{taskCount}, #{segmentCount}, #{dataSource}, NOW() update tb_vehicle_mileage_stats vehicle_no = #{vehicleNo}, total_mileage = #{totalMileage}, task_mileage = #{taskMileage}, non_task_mileage = #{nonTaskMileage}, task_ratio = #{taskRatio}, gps_point_count = #{gpsPointCount}, task_count = #{taskCount}, segment_count = #{segmentCount}, data_source = #{dataSource}, update_time = NOW() where stats_id = #{statsId} delete from tb_vehicle_mileage_stats where stats_id = #{statsId} delete from tb_vehicle_mileage_stats where stats_id in #{statsId}