package com.ningdatech.carapi.car.rpt.service.impl;

import java.util.Date;
import java.util.List;

import org.springframework.stereotype.Service;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ningdatech.basic.util.NdDateUtils;
import com.ningdatech.carapi.car.rpt.entity.RptDailySpecialVehiclesLaunchRate;
import com.ningdatech.carapi.car.rpt.mapper.RptDailySpecialVehiclesLaunchRateMapper;
import com.ningdatech.carapi.car.rpt.model.dto.RptDailySpecialVehiclesLaunchRateParamDTO;
import com.ningdatech.carapi.car.rpt.model.po.RptDailySpecialVehiclesLaunchRatePO;
import com.ningdatech.carapi.car.rpt.service.IRptDailySpecialVehiclesLaunchRateService;
import com.ningdatech.carapi.common.util.CodeUtil;

import lombok.RequiredArgsConstructor;

/**
 * <p>
 * 专用车辆上线率日报 服务实现类
 * </p>
 *
 * @author PoffyZhang
 * @since 2022-11-08
 */
@Service
@RequiredArgsConstructor
public class RptDailySpecialVehiclesLaunchRateServiceImpl extends ServiceImpl<RptDailySpecialVehiclesLaunchRateMapper, RptDailySpecialVehiclesLaunchRate> implements IRptDailySpecialVehiclesLaunchRateService {

    private final RptDailySpecialVehiclesLaunchRateMapper mapper;

    @Override
    public List<RptDailySpecialVehiclesLaunchRatePO> report(RptDailySpecialVehiclesLaunchRateParamDTO param) {
        CodeUtil.buildRegionLevel(param);
        Date date = NdDateUtils.parseAsDate(param.getDate());
        String tableName = "nd_vehicle_online_status_hour_" + NdDateUtils.format(date,"yyyy_MM");
        param.setTableName(tableName);
        List<RptDailySpecialVehiclesLaunchRatePO> res = mapper.report(param);
        return res;
    }
}
