package com.nantian.cloud.jljc.entity;

import com.baomidou.mybatisplus.annotation.TableId;

import java.io.Serializable;
import java.text.DecimalFormat;
import java.text.NumberFormat;
import java.util.Date;

import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import lombok.EqualsAndHashCode;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;

/**
 * 报表1-2能源消费表
 *
 * @author stz
 * @since 2020-09-16
 */
@Data
@TableName("t_report_energys_tructure")
@EqualsAndHashCode(callSuper = true)
@ApiModel(value = "报表1-2能源消费表")
public class TReportEnergysTructure extends Model<TReportEnergysTructure> {

    private static final long serialVersionUID = 1L;

    /**
     * 主键id（表1-2能源消费结构表的能源消费表）
     */
    @TableId(value = "id")
    @ApiModelProperty(value = "id")
    private Long id;

    /**
     * 报表信息表id
     */
    @ApiModelProperty(value = "报表信息表id")
    private Long reportId;

    /**
     * 能源代码
     */
    @ApiModelProperty(value = "能源代码")
    private Integer energyCode;

    /**
     * 能源名称
     */
    @ApiModelProperty(value = "能源名称")
    private String energyCodeName;

    /**
     * 计量单位
     */
    @ApiModelProperty(value = "计量单位")
    private String unit;

    /**
     * 期初库存量
     */
    @ApiModelProperty(value = "期初库存量")
    private Double startInventory;

    /**
     * 购进量-实物量
     */
    @ApiModelProperty(value = "购进量-实物量")
    private Double object;

    /**
     * 购进量-金额（千元）
     */
    @ApiModelProperty(value = "购进量-金额（千元）")
    private Double money;

    /**
     * 消费量-合计
     */
    @ApiModelProperty(value = "消费量-合计")
    private Double consumeSum;

    /**
     * 消费量-工业生产消费
     */
    @ApiModelProperty(value = "消费量-工业生产消费")
    private Double consumeIndustry;

    /**
     * 消费量-用于原料材料
     */
    @ApiModelProperty(value = "消费量-用于原料材料")
    private Double consumeMaterial;

    /**
     * 消费量-非工业生产消费
     */
    @ApiModelProperty(value = "消费量-非工业生产消费")
    private Double consumeNoindustry;

    /**
     * 消费量-合计中运输工具消费
     */
    @ApiModelProperty(value = "消费量-合计中运输工具消费")
    private Double consumeTransport;

    /**
     * 期末库存量
     */
    @ApiModelProperty(value = "期末库存量")
    private Double endInventory;

    /**
     * 采用折标系数
     */
    @ApiModelProperty(value = "采用折标系数")
    private String modulus;

    /**
     * 参考折标系数
     */
    @ApiModelProperty(value = "参考折标系数")
    private String refModulus;

    /**
     * 工业总产值（当年价）
     */
    @ApiModelProperty(value = "工业总产值（当年价）")
    private Double productionSum;

    /**
     * 用户id
     */
    @ApiModelProperty(value = "用户id")
    private Integer userid;

    /**
     * 更新时间
     */
    @ApiModelProperty(value = "更新时间")
    @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date updateTime;

    /**
     * 注销状态（1：未删除，4：已删除）
     */
    @ApiModelProperty(value = "注销状态（1：未删除，4：已删除）")
    private String delFlag;

    /**
     * 部门id
     */
    @ApiModelProperty(value = "部门id")
    private Integer deptId;

    /**
     * 主键值
     */
    @Override
    protected Serializable pkVal() {
        return this.id;
    }

    public TReportEnergysTructure(String energyCodeName, String unit, Double startInventory, Double object,
                                  Double money, Double consumeSum, Double consumeIndustry, Double consumeMaterial,
                                  Double consumeNoindustry, Double consumeTransport, Double endInventory, Double productionSum) {
        //保留2位小数
        DecimalFormat df = new DecimalFormat(".0000"); //保留4位小数
        this.energyCodeName = energyCodeName;
        this.unit = unit;
        this.startInventory = Double.parseDouble(df.format(startInventory));
        this.object = Double.parseDouble(df.format(object));
        this.money = Double.parseDouble(df.format(money));
        this.consumeSum = Double.parseDouble(df.format(consumeSum));
        this.consumeIndustry = Double.parseDouble(df.format(consumeIndustry));
        this.consumeMaterial = Double.parseDouble(df.format(consumeMaterial));
        this.consumeNoindustry = Double.parseDouble(df.format(consumeNoindustry));
        this.consumeTransport = Double.parseDouble(df.format(consumeTransport));
        this.endInventory = Double.parseDouble(df.format(endInventory));
        this.productionSum = Double.parseDouble(df.format(productionSum));
    }

    public TReportEnergysTructure() {
    }

    public TReportEnergysTructure(Long id, Long reportId, Integer energyCode, String energyCodeName, String unit, Double startInventory, Double object, Double money, Double consumeSum, Double consumeIndustry, Double consumeMaterial, Double consumeNoindustry, Double consumeTransport, Double endInventory, String modulus, String refModulus, Double productionSum, Integer userid, Date updateTime, String delFlag, Integer deptId) {
        this.id = id;
        this.reportId = reportId;
        this.energyCode = energyCode;
        this.energyCodeName = energyCodeName;
        this.unit = unit;
        this.startInventory = startInventory;
        this.object = object;
        this.money = money;
        this.consumeSum = consumeSum;
        this.consumeIndustry = consumeIndustry;
        this.consumeMaterial = consumeMaterial;
        this.consumeNoindustry = consumeNoindustry;
        this.consumeTransport = consumeTransport;
        this.endInventory = endInventory;
        this.modulus = modulus;
        this.refModulus = refModulus;
        this.productionSum = productionSum;
        this.userid = userid;
        this.updateTime = updateTime;
        this.delFlag = delFlag;
        this.deptId = deptId;
    }

    public TReportEnergysTructure(Long id, Long reportId, Integer energyCode, String energyCodeName, String unit, String startInventory, String object, String money,
                                  String consumeSum, String consumeIndustry, String consumeMaterial, String consumeNoindustry, String consumeTransport, String endInventory,
                                  String modulus, String refModulus, String productionSum) {
        this.id = id;
        this.reportId = reportId;
        this.energyCode = energyCode;
        this.energyCodeName = energyCodeName;
        this.unit = unit;
        if(startInventory!=null) this.startInventory = Double.parseDouble(startInventory);
        if(object!=null) this.object = Double.parseDouble(object);
        if(money!=null) this.money = Double.parseDouble(money);
        if(consumeSum!=null) this.consumeSum = Double.parseDouble(consumeSum);
        if(consumeIndustry!=null) this.consumeIndustry = Double.parseDouble(consumeIndustry);
        if(consumeMaterial!=null) this.consumeMaterial = Double.parseDouble(consumeMaterial);
        if(consumeNoindustry!=null) this.consumeNoindustry = Double.parseDouble(consumeNoindustry);
        if(consumeTransport!=null) this.consumeTransport = Double.parseDouble(consumeTransport);
        if(endInventory!=null) this.endInventory = Double.parseDouble(endInventory);
        if(modulus!=null) this.modulus = modulus;
        if(refModulus!=null) this.refModulus = refModulus;
        if(productionSum!=null) this.productionSum = Double.parseDouble(productionSum);
    }

    @Override
    public String toString() {
        return "TReportEnergysTructure{" +
                "id=" + id +
                ", reportId=" + reportId +
                ", energyCode=" + energyCode +
                ", energyCodeName='" + energyCodeName + '\'' +
                ", unit='" + unit + '\'' +
                ", startInventory=" + startInventory +
                ", object=" + big(object) +
                ", money=" + big(money) +
                ", consumeSum=" + big(consumeSum) +
                ", consumeIndustry=" + big(consumeIndustry) +
                ", consumeMaterial=" + big(consumeMaterial) +
                ", consumeNoindustry=" + big(consumeNoindustry) +
                ", consumeTransport=" + big(consumeTransport) +
                ", endInventory=" + big(endInventory) +
                ", modulus='" + modulus + '\'' +
                ", refModulus='" + refModulus + '\'' +
                ", productionSum=" + big(productionSum) +
                ", userid=" + userid +
                ", updateTime=" + updateTime +
                ", delFlag='" + delFlag + '\'' +
                ", deptId=" + deptId +
                '}';
    }

    private static String big(double d) {
        NumberFormat nf = NumberFormat.getInstance();
        nf.setGroupingUsed(false);
        return nf.format(d);
    }
}
