package com.jjt.biz.vo;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

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

/**
 * 月平均
 *
 * @author wukai
 */
@ApiModel(value = "CurrProdVO", description = "当前生产情况")
@Data
public class CurrYieldVO {
    @ApiModelProperty("经编生产情况")
    private JB jb;
    @ApiModelProperty("染整生产情况")
    private RZ rz;

    /**
     * 经编当前产量内部类
     */
    @Data
    public static class JB {
        @ApiModelProperty("稼动率")
        private BigDecimal jdl;
        @ApiModelProperty("开机率")
        private BigDecimal openRatio;
        @ApiModelProperty("产量")
        private BigDecimal yield;
        @ApiModelProperty("最大产量")
        private BigDecimal yieldMax;
        @ApiModelProperty("开机数")
        private Integer openNum;
        @ApiModelProperty("设备总数")
        private Integer totalNum;
    }

    /**
     * 染整当前产量内部类
     */
    @Data
    public static class RZ {
        @ApiModelProperty("开动产线")
        private Integer openLine;
        @ApiModelProperty("总产线")
        private Integer maxLine;
        @ApiModelProperty("开机率")
        private BigDecimal openRatio;
        @ApiModelProperty("产量")
        private BigDecimal yield;
        @ApiModelProperty("最大产量")
        private BigDecimal yieldMax;
        @ApiModelProperty("开机数")
        private Integer openNum;
        @ApiModelProperty("设备总数")
        private Integer totalNum;
    }


    public CurrYieldVO() {
        this.jb = new JB();
        this.rz = new RZ();
    }


    public void mock() {
        Random random = new Random();
        double jdl = 70 + 10 * random.nextDouble();
        this.jb.jdl = BigDecimal.valueOf(jdl).setScale(0, RoundingMode.HALF_UP);
        jdl = 85 + 15 * random.nextDouble();
        this.jb.openRatio = BigDecimal.valueOf(jdl).setScale(0, RoundingMode.HALF_UP);
        this.rz.openLine = 8;
        this.rz.maxLine = 8;
        this.rz.openNum = 187;
        this.rz.totalNum = 267;
        this.rz.openRatio = BigDecimal.valueOf(this.rz.openNum*100).divide(BigDecimal.valueOf(this.rz.totalNum), 0, RoundingMode.HALF_UP);

        this.jb.openNum = 100;
        this.jb.totalNum = 150;

        jdl = 15000 + 30000 * random.nextDouble();
        this.jb.yield = BigDecimal.valueOf(jdl).setScale(0, RoundingMode.HALF_UP);
        jdl = 15000 + 30000 * random.nextDouble();
        this.rz.yield = BigDecimal.valueOf(jdl).setScale(0, RoundingMode.HALF_UP);
        this.jb.yieldMax = BigDecimal.valueOf(45000);
        this.rz.yieldMax = BigDecimal.valueOf(45000);
    }
}
