package com.ym.mec.biz.dal.dto;


import io.swagger.annotations.ApiModelProperty;

import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.Objects;

public class ExportOperatingVisitDto {

    @ApiModelProperty(value = "分部", required = true)
    private String organName;

    @ApiModelProperty(value = "预计回访人数", required = true)
    private Integer expectVisitNum;

    @ApiModelProperty(value = "回访人数", required = true)
    private Integer visitNum;

    @ApiModelProperty(value = "覆盖率", required = true)
    private String coverRate;

    public String getOrganName() {
        return organName;
    }

    public void setOrganName(String organName) {
        this.organName = organName;
    }

    public Integer getExpectVisitNum() {
        return expectVisitNum;
    }

    public void setExpectVisitNum(Integer expectVisitNum) {
        this.expectVisitNum = expectVisitNum;
        calcCoverRate(visitNum);
    }

    public Integer getVisitNum() {
        return visitNum;
    }

    public void setVisitNum(Integer visitNum) {
        this.visitNum = visitNum;
        calcCoverRate(expectVisitNum);
    }

    public String getCoverRate() {
        return coverRate;
    }

    public void setCoverRate(String coverRate) {
        this.coverRate = coverRate;
    }

    private void calcCoverRate(Integer param){
        if(Objects.nonNull(param)){
            if(visitNum.equals(0) || expectVisitNum.equals(0)){
                this.coverRate = "0%";
            }else {
                this.coverRate = new BigDecimal(visitNum).divide(new BigDecimal(expectVisitNum),BigDecimal.ROUND_HALF_UP,BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal(100)).setScale(BigDecimal.ROUND_CEILING) + "%";
            }
        }
    }
}
