package com.ningdatech.carapi.gps.service.impl;

import cn.hutool.core.collection.ListUtil;
import com.ningdatech.carapi.gps.model.entity.DataAccessGpsRealTimeData;
import com.ningdatech.carapi.gps.mapper.DataAccessGpsRealTimeDataMapper;
import com.ningdatech.carapi.gps.service.IDataAccessGpsRealTimeDataService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ningdatech.carapi.scheduler.mapper.VehicleOnlineStatusDayMapper;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author CMM
 * @since 2024-10-11
 */
@Service
@AllArgsConstructor
public class DataAccessGpsRealTimeDataServiceImpl extends ServiceImpl<DataAccessGpsRealTimeDataMapper, DataAccessGpsRealTimeData> implements IDataAccessGpsRealTimeDataService {

    private final VehicleOnlineStatusDayMapper mapper;
    @Override
    public Boolean removeByRecordIds(String tableName,List<Long> recordIdList) {
        // 根据recordIdList分批删除 每批5000
        // 分批
        List<List<Long>> batchList = new ArrayList<>(ListUtil.partition(new ArrayList<>(recordIdList), 5000));
        for (List<Long> idList : batchList) {
            mapper.batchDelete(tableName,idList);
        }
        return true;
    }
}
