package com.ylcm.sys.vo;

import com.ylcm.sys.common.Util;
import com.ylcm.sys.domain.AdTheatreTv;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.time.LocalDate;
import java.util.ArrayList;
import java.util.List;

@ApiModel("人群构成")
@Data
public class AdTvRatioPeopleVO {

    @ApiModelProperty("男/女/4-24...")
    private String type;

    private Float ratio;

    public static List<AdTvRatioPeopleVO> from(AdTheatreTv adTheatreTv) {
        List<AdTvRatioPeopleVO> peopleVOS = new ArrayList<>();

        if (adTheatreTv == null){
            return peopleVOS;
        }

        AdTvRatioPeopleVO peopleVO = new AdTvRatioPeopleVO();
        peopleVO.setRatio(Util.newScale(adTheatreTv.getPeopleMan29(), 2));
        peopleVO.setType("男");
        peopleVOS.add(peopleVO);

        peopleVO = new AdTvRatioPeopleVO();
        peopleVO.setRatio(Util.newScale(adTheatreTv.getPeopleWomen29(), 2));
        peopleVO.setType("女");
        peopleVOS.add(peopleVO);

        peopleVO = new AdTvRatioPeopleVO();
        peopleVO.setRatio(Util.newScale(adTheatreTv.getPeople41429(), 2));
        peopleVO.setType("4-14岁");
        peopleVOS.add(peopleVO);

        peopleVO = new AdTvRatioPeopleVO();
        peopleVO.setRatio(Util.newScale(adTheatreTv.getPeople152429(), 2));
        peopleVO.setType("14-24岁");
        peopleVOS.add(peopleVO);

        peopleVO = new AdTvRatioPeopleVO();
        peopleVO.setRatio(Util.newScale(adTheatreTv.getPeople253429(), 2));
        peopleVO.setType("25-34岁");
        peopleVOS.add(peopleVO);

        peopleVO = new AdTvRatioPeopleVO();
        peopleVO.setRatio(Util.newScale(adTheatreTv.getPeople354429(), 2));
        peopleVO.setType("35-44岁");
        peopleVOS.add(peopleVO);

        peopleVO = new AdTvRatioPeopleVO();
        peopleVO.setRatio(Util.newScale(adTheatreTv.getPeople455429(), 2));
        peopleVO.setType("45-54岁");
        peopleVOS.add(peopleVO);

        peopleVO = new AdTvRatioPeopleVO();
        peopleVO.setRatio(Util.newScale(adTheatreTv.getPeople556429(), 2));
        peopleVO.setType("55-64岁");
        peopleVOS.add(peopleVO);

        peopleVO = new AdTvRatioPeopleVO();
        peopleVO.setRatio(Util.newScale(adTheatreTv.getPeople6529(), 2));
        peopleVO.setType("65以上");
        peopleVOS.add(peopleVO);


        return peopleVOS;
    }

}
