package com.jjt.calc.domain;

import com.baomidou.mybatisplus.annotation.TableId;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.jjt.common.annotation.Excel;
import com.jjt.common.core.domain.BaseEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.math.BigDecimal;
import java.util.Date;

/**
 * 能源1小时统计数据对象 TWIN_CALC_HOUR_ENERGY
 *
 * @author wukai
 * @date 2025-01-18
 */
@ApiModel(value = "TwinCalcHourEnergy", description = "能源1小时统计数据")
@Data
public class TwinCalcHourEnergy extends BaseEntity {
    private static final long serialVersionUID = 1L;

    /**
     * ID
     */
    @ApiModelProperty("ID")
    @TableId
    private Long autoId;

    /**
     * 日期
     */
    @ApiModelProperty("日期")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @Excel(name = "日期", width = 30, dateFormat = "yyyy-MM-dd")
    private Date dataDate;

    /**
     * 小时;0-23
     */
    @ApiModelProperty("小时;0-23")
    @Excel(name = "小时;0-23")
    private Integer hour;

    /**
     * 设备ID
     */
    @ApiModelProperty("设备ID")
    @Excel(name = "设备ID")
    private Long energyId;

    /**
     * 统计数据
     */
    @ApiModelProperty("统计数据")
    @Excel(name = "统计数据")
    private BigDecimal dataValue;
    @ApiModelProperty("价格")
    private BigDecimal price;
    @ApiModelProperty("班组")
    private String team;
    @ApiModelProperty("车间ID")
    private Long wsId;
    @ApiModelProperty("用电类型")
    private String type;


    /**
     * 计算价格
     *
     * @param unit 单价
     */
    public void calcPrice(BigDecimal unit) {
        this.price = dataValue.multiply(unit);
    }

    /**
     * 设置班组
     */
    public void setTeam() {
        if (this.hour >= 7 && this.hour < 19) {
            //A班
            this.team = "A";
        } else {
            //B班
            this.team = "B";
        }
    }
}
