package com.qmth.themis.business.dto;

import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Set;

/**
 * @Description: 考试属性统计
 * @Param:
 * @return:
 * @Author: wangliang
 * @Date: 2020/8/19
 */
@ApiModel("考试属性统计返回信息")
public class ExamPropCountDto implements Serializable {

    @JsonSerialize(using = ToStringSerializer.class)
    @ApiModelProperty(name = "考试id")
    private Long examId;//考试批次id

    @ApiModelProperty(name = "应考人数")
    private Integer allCount = 0;//应考人数

    @ApiModelProperty(name = "已待考")
    private Integer prepareCount = 0;//已待考

    @ApiModelProperty(name = "考试中")
    private Integer examCount = 0;//考试中

//    @ApiModelProperty(name = "客户端通讯故障")
//    private Integer clientWebsocketStatusCount = 0;//客户端通讯故障

//    @ApiModelProperty(name = "监控设备通讯故障")
//    private Integer monitorStatusSourceCount = 0;//监控设备通讯故障

    @ApiModelProperty(name = "已完成")
    private Integer alreadyComplete = 0;//已完成

    @ApiModelProperty(name = "未完成")
    private Integer notComplete = 0;//未完成

    @ApiModelProperty(name = "虚拟考场代码")
    private Set<String> roomCodes;//虚拟考场代码

    @ApiModelProperty(name = "完成率")
    private BigDecimal completionRate = BigDecimal.valueOf(0);//完成率

    @ApiModelProperty(name = "重考审核")
    private Integer reexamCount = 0;//重考审核

    @ApiModelProperty(name = "最大考试时长")
    private Long maxDurationSeconds;//最大考试时长

    @ApiModelProperty(name = "强制交卷时间")
    private Long finishTime;//强制交卷时间

    @ApiModelProperty(name = "异常人数")
    private Integer exceptionCount = 0;//异常人数

    @ApiModelProperty(name = "预警人数")
    private Integer warningCount = 0;//预警人数

    public ExamPropCountDto() {

    }

    public ExamPropCountDto(Long examId, Integer allCount, Integer prepareCount, Integer examCount,
//                            Integer clientWebsocketStatusCount, Integer monitorStatusSourceCount,
                            Integer alreadyComplete, Integer notComplete, Set<String> roomCodes, BigDecimal completionRate) {
        this.examId = examId;
        this.allCount = allCount;
        this.prepareCount = prepareCount;
        this.examCount = examCount;
//        this.clientWebsocketStatusCount = clientWebsocketStatusCount;
//        this.monitorStatusSourceCount = monitorStatusSourceCount;
        this.alreadyComplete = alreadyComplete;
        this.notComplete = notComplete;
        this.roomCodes = roomCodes;
        this.completionRate = completionRate;
    }

    public ExamPropCountDto(Long examId, Integer allCount, Integer prepareCount, Integer examCount,
//                            Integer clientWebsocketStatusCount, Integer monitorStatusSourceCount,
                            Integer alreadyComplete, Integer notComplete, BigDecimal completionRate) {
        this.examId = examId;
        this.allCount = allCount;
        this.prepareCount = prepareCount;
        this.examCount = examCount;
//        this.clientWebsocketStatusCount = clientWebsocketStatusCount;
//        this.monitorStatusSourceCount = monitorStatusSourceCount;
        this.alreadyComplete = alreadyComplete;
        this.notComplete = notComplete;
        this.completionRate = completionRate;
    }

    public void updateSummary(Integer allCount, Integer prepareCount, Integer examCount, Integer alreadyComplete, Integer notComplete) {
        this.allCount = allCount;
        this.prepareCount = prepareCount;
        this.examCount = examCount;
        this.alreadyComplete = alreadyComplete;
        this.notComplete = notComplete;
        if (this.allCount.intValue() > 0) {
            BigDecimal completionRate = BigDecimal.valueOf(this.alreadyComplete)
                    .divide(BigDecimal.valueOf(this.allCount), 2, BigDecimal.ROUND_HALF_UP)
                    .setScale(2, BigDecimal.ROUND_HALF_UP);
            this.completionRate = completionRate;
        }
    }

    public Integer getExceptionCount() {
        return exceptionCount;
    }

    public void setExceptionCount(Integer exceptionCount) {
        this.exceptionCount = exceptionCount;
    }

    public Integer getWarningCount() {
        return warningCount;
    }

    public void setWarningCount(Integer warningCount) {
        this.warningCount = warningCount;
    }

    public Integer getReexamCount() {
        return reexamCount;
    }

    public void setReexamCount(Integer reexamCount) {
        this.reexamCount = reexamCount;
    }

    public Long getMaxDurationSeconds() {
        return maxDurationSeconds;
    }

    public void setMaxDurationSeconds(Long maxDurationSeconds) {
        this.maxDurationSeconds = maxDurationSeconds;
    }

    public Long getFinishTime() {
        return finishTime;
    }

    public void setFinishTime(Long finishTime) {
        this.finishTime = finishTime;
    }

    public BigDecimal getCompletionRate() {
        return completionRate;
    }

    public void setCompletionRate(BigDecimal completionRate) {
        this.completionRate = completionRate;
    }

    public Set<String> getRoomCodes() {
        return roomCodes;
    }

    public void setRoomCodes(Set<String> roomCodes) {
        this.roomCodes = roomCodes;
    }

    public Long getExamId() {
        return examId;
    }

    public void setExamId(Long examId) {
        this.examId = examId;
    }

    public Integer getAllCount() {
        return allCount;
    }

    public void setAllCount(Integer allCount) {
        this.allCount = allCount;
    }

    public Integer getPrepareCount() {
        return prepareCount;
    }

    public void setPrepareCount(Integer prepareCount) {
        this.prepareCount = prepareCount;
    }

    public Integer getExamCount() {
        return examCount;
    }

    public void setExamCount(Integer examCount) {
        this.examCount = examCount;
    }

//    public Integer getClientWebsocketStatusCount() {
//        return clientWebsocketStatusCount;
//    }
//
//    public void setClientWebsocketStatusCount(Integer clientWebsocketStatusCount) {
//        this.clientWebsocketStatusCount = clientWebsocketStatusCount;
//    }
//
//    public Integer getMonitorStatusSourceCount() {
//        return monitorStatusSourceCount;
//    }
//
//    public void setMonitorStatusSourceCount(Integer monitorStatusSourceCount) {
//        this.monitorStatusSourceCount = monitorStatusSourceCount;
//    }

    public Integer getAlreadyComplete() {
        return alreadyComplete;
    }

    public void setAlreadyComplete(Integer alreadyComplete) {
        this.alreadyComplete = alreadyComplete;
    }

    public Integer getNotComplete() {
        return notComplete;
    }

    public void setNotComplete(Integer notComplete) {
        this.notComplete = notComplete;
    }
}
