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 ruoyi
 * @date 2024-12-30
 */
@ApiModel(value = "EnergyTradeVO", description = "能耗趋势视图")
@Data
public class EnergyTradeVO {
    @ApiModelProperty("时间")
    private String date;
    @ApiModelProperty("原始时间")
    private String tips;
    @ApiModelProperty("经编能耗趋势")
    private JB jb;
    @ApiModelProperty("染整能耗趋势")
    private RZ rz;

    @Data
    public static class JB {
        @ApiModelProperty("电")
        private BigDecimal electricity;
        @ApiModelProperty("汽")
        private BigDecimal steam;
        @ApiModelProperty("水")
        private BigDecimal water;
        @ApiModelProperty("价格")
        private BigDecimal price;
    }

    @Data
    public static class RZ {
        @ApiModelProperty("电")
        private BigDecimal electricity;
        @ApiModelProperty("汽")
        private BigDecimal steam;
        @ApiModelProperty("水")
        private BigDecimal water;
        @ApiModelProperty("价格")
        private BigDecimal price;

        public void addElectricity(BigDecimal electricity) {
            if (this.electricity == null) {
                this.electricity = BigDecimal.ZERO;
            }
            this.electricity.add(electricity);
        }

        public void addPrice(BigDecimal price) {
            if (this.price == null) {
                this.price = BigDecimal.ZERO;
            }
            if (price != null) {
                this.price.add(price);
            }
        }
    }

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

    public void mock() {
        Random random = new Random();
        double price = 2.0 + random.nextDouble();
        this.jb.price = BigDecimal.valueOf(price).setScale(1, RoundingMode.HALF_UP);
        price = 2.0 + random.nextDouble();
        this.rz.price = BigDecimal.valueOf(price).setScale(1, RoundingMode.HALF_UP);
        double electricity = 50000 + 10000 * random.nextDouble();
        this.rz.electricity = BigDecimal.valueOf(electricity).setScale(1, RoundingMode.HALF_UP);
        electricity = 5000 + 1000 * random.nextDouble();
        this.jb.electricity = BigDecimal.valueOf(electricity).setScale(1, RoundingMode.HALF_UP);
        double steam = 400 + 200 * random.nextDouble();
        this.rz.steam = BigDecimal.valueOf(steam).setScale(1, RoundingMode.HALF_UP);
        double water = 400 + 200 * random.nextDouble();
        this.rz.water = BigDecimal.valueOf(water).setScale(1, RoundingMode.HALF_UP);
    }
}
