package com.ningdatech.carapi.car.rpt.model.dto;

import com.ningdatech.basic.model.PagePo;
import com.ningdatech.basic.util.NdDateUtils;
import com.ningdatech.basic.util.StrPool;
import com.ningdatech.carapi.sys.contants.RegionContant;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.apache.commons.lang3.StringUtils;

import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.util.*;

/**
 * @Classname RptOtherParamDTO
 * @Description
 * @Date 2022/11/8 17:06
 * @Created by PoffyZhang
 */
@Data
public class RptOtherParamDTO extends PagePo implements Serializable {

    @ApiModelProperty("区域ID")
    private Long regionId;
    private List<Long> regionIds;
    private Integer regionLevel;

    @ApiModelProperty("企业名称")
    private String companyName;

    @ApiModelProperty("车辆类别")
    private Integer vehicleType;

    @ApiModelProperty("运营商ID")
    private Long operatorId;

    @ApiModelProperty("报警类别")
    private Integer alarmType;

    @ApiModelProperty("企业类型")
    private String enterpriseType;
    private List<String> enterpriseTypes;

    @ApiModelProperty("运营商")
    private String operatorName;

    @ApiModelProperty("开始时间")
    private String startTime;

    @ApiModelProperty("结束时间")
    private String endTime;

    @ApiModelProperty("车牌号")
    private String carPlate;

    @ApiModelProperty("开始速率")
    private String startRate;

    @ApiModelProperty("结束速率")
    private String endRate;

    @ApiModelProperty("年月")
    private String yearMonth;

    private String dataScopeSql;

    public Long getRegionId(){
        if(Objects.isNull(this.regionId)){
            this.regionId = RegionContant.ZJ_REGION_ID;
            return this.regionId;
        }
        return this.regionId;
    }

    public List<String> getEnterpriseTypes(){
        if(StringUtils.isNotBlank(this.enterpriseType)){
            this.enterpriseTypes = Arrays.asList(this.enterpriseType.split(StrPool.COMMA));
            return this.enterpriseTypes;
        }
        return Collections.emptyList();
    }

    private String tableName = "nd_vehicle_online_status_hour_" + NdDateUtils.format(new Date(),"yyyy_MM");
}
