package com.nantian.cloud.jljc.entity;

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

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

/**
 * 报表1-2-1能源产出表
 * @since 2020-11-03
 */
@Data
@TableName("t_report_energy_out")
@EqualsAndHashCode(callSuper = true)
@ApiModel(value = "报表1-2-1能源产出表")
public class TReportEnergyOut extends Model<TReportEnergyOut> {

    private static final long serialVersionUID = 1L;

    /**
     * 主键id
     */
    @TableId(value = "id", type = IdType.AUTO)
    @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 String modulus;

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

    /**
     * 用户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;

    /**
     * 注销状态
     */
    @ApiModelProperty(value = "注销状态 1,未注销，4,已注销")
    private String delFlag;

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

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

    /**
     * 加工转换投入合计
     */
    @ApiModelProperty(value = "加工转换投入合计")
    private Double proConTotal;

    /**
     * 加工转换投入火力发电
     */
    @ApiModelProperty(value = "加工转换投入火力发电")
    private Double thermalPower;

    /**
     * 加工转换投入供热
     */
    @ApiModelProperty(value = "加工转换投入供热")
    private Double heating;

    /**
     * 加工转换投入原煤入洗
     */
    @ApiModelProperty(value = "加工转换投入原煤入洗")
    private Double coalWashing;

    /**
     * 加工转换投入余热发电
     */
    @ApiModelProperty(value = "加工转换投入余热发电")
    private Double wastePower;

    /**
     * 加工转换投入煤气发电
     */
    @ApiModelProperty(value = "加工转换投入煤气发电")
    private Double gasPower;

    /**
     * 加工转换投入炼焦
     */
    @ApiModelProperty(value = "加工转换投入炼焦")
    private Double coking;

    /**
     * 加工转换投入炼油及煤制油
     */
    @ApiModelProperty(value = "加工转换投入炼油及煤制油")
    private Double oil;

    /**
     * 加工转换投入制气
     */
    @ApiModelProperty(value = "加工转换投入制气")
    private Double gasification;

    /**
     * 加工转换投天然气液化
     */
    @ApiModelProperty(value = "加工转换投天然气液化")
    private Double gasLiquefaction;

    /**
     * 加工转换投加工煤制品
     */
    @ApiModelProperty(value = "加工转换投加工煤制品")
    private Double coalProducts;

    /**
     * 能源加工转换产出
     */
    @ApiModelProperty(value = "能源加工转换产出")
    private Double conversionOutput;

    /**
     * 能源加工转换产出折标量（吨标准煤）
     */
    @ApiModelProperty(value = " 能源加工转换产出折标量（吨标准煤）")
    private Double conversionOutputRef;

    /**
     * 回收利用
     */
    @ApiModelProperty(value = "回收利用")
    private Double recycling;

    /**
     * 备注
     */
    @ApiModelProperty(value = "备注")
    private String remark;

    /**
     * 期初库存量
     */
    @TableField(exist = false)
    private Double startInventory;

    /**
     *购进实物量
     */
    @TableField(exist = false)
    private Double object;

    public TReportEnergyOut() {
    }

    public TReportEnergyOut(String energyCodeName, String unit, Double productionConsumption, Double proConTotal,
                            Double thermalPower, Double heating, Double coalWashing, Double wastePower, Double gasPower,Double coking, Double oil, Double gasification,
                            Double gasLiquefaction, Double coalProducts, Double conversionOutput, Double conversionOutputRef, Double recycling) {
        DecimalFormat df = new DecimalFormat(".0000"); //保留4位小数
        this.energyCodeName = energyCodeName;
        this.unit = unit;
        this.productionConsumption = Double.parseDouble(df.format(productionConsumption));
        this.proConTotal = Double.parseDouble(df.format(proConTotal));
        this.thermalPower = Double.parseDouble(df.format(thermalPower));
        this.heating = Double.parseDouble(df.format(heating));
        this.coalWashing = Double.parseDouble(df.format(coalWashing));
        this.wastePower = Double.parseDouble(df.format(wastePower));
        this.gasPower = Double.parseDouble(df.format(gasPower));
        this.coking = Double.parseDouble(df.format(coking));
        this.oil = Double.parseDouble(df.format(oil));
        this.gasification = Double.parseDouble(df.format(gasification));
        this.gasLiquefaction = Double.parseDouble(df.format(gasLiquefaction));
        this.coalProducts = Double.parseDouble(df.format(coalProducts));
        this.conversionOutput = Double.parseDouble(df.format(conversionOutput));
        this.conversionOutputRef = Double.parseDouble(df.format(conversionOutputRef));
        this.recycling = Double.parseDouble(df.format(recycling));
    }

    public TReportEnergyOut(Long id, Long reportId, Integer energyCode, String energyCodeName, String unit, String modulus,
                            String refModulus, String productionConsumption, String proConTotal, String thermalPower, String heating,
                            String coalWashing, String wastePower, String gasPower, String coking, String oil, String gasification, String gasLiquefaction,
                            String coalProducts, String conversionOutput, String conversionOutputRef, String recycling, String remark) {
        this.id = id;
        this.reportId = reportId;
        this.energyCode = energyCode;
        this.energyCodeName = energyCodeName;
        this.unit = unit;
        this.modulus = modulus;
        this.refModulus = refModulus;
        if(productionConsumption!=null && !"".equals(productionConsumption)) this.productionConsumption = Double.parseDouble(productionConsumption);
        if(proConTotal!=null && !"".equals(proConTotal)) this.proConTotal = Double.parseDouble(proConTotal);
        if(thermalPower!=null && !"".equals(thermalPower)) this.thermalPower = Double.parseDouble(thermalPower);
        if(heating!=null && !"".equals(heating)) this.heating = Double.parseDouble(heating);
        if(coalWashing!=null && !"".equals(coalWashing)) this.coalWashing = Double.parseDouble(coalWashing);
        if(wastePower!=null && !"".equals(wastePower)) this.wastePower = Double.parseDouble(wastePower);
        if(gasPower!=null && !"".equals(gasPower)) this.gasPower = Double.parseDouble(gasPower);
        if(coking!=null && !"".equals(coking)) this.coking = Double.parseDouble(coking);
        if(oil!=null && !"".equals(oil)) this.oil = Double.parseDouble(oil);
        if(gasification!=null && !"".equals(gasification)) this.gasification = Double.parseDouble(gasification);
        if(gasLiquefaction!=null && !"".equals(gasLiquefaction)) this.gasLiquefaction = Double.parseDouble(gasLiquefaction);
        if(coalProducts!=null && !"".equals(coalProducts)) this.coalProducts = Double.parseDouble(coalProducts);
        if(conversionOutput!=null && !"".equals(conversionOutput)) this.conversionOutput = Double.parseDouble(conversionOutput);
        if(conversionOutputRef!=null && !"".equals(conversionOutputRef)) this.conversionOutputRef = Double.parseDouble(conversionOutputRef);
        if(recycling!=null && !"".equals(recycling)) this.recycling = Double.parseDouble(recycling);
        this.remark = remark;
    }

    public TReportEnergyOut(Long id, Long reportId, Integer energyCode, String energyCodeName, String unit, String modulus, String refModulus,
                            Integer userid, Date updateTime, String delFlag, Integer deptId, Double productionConsumption, Double proConTotal,
                            Double thermalPower, Double heating, Double coalWashing, Double wastePower, Double gasPower, Double coking, Double oil, Double gasification,
                            Double gasLiquefaction, Double coalProducts, Double conversionOutput, Double conversionOutputRef, Double recycling, String remark) {
        this.id = id;
        this.reportId = reportId;
        this.energyCode = energyCode;
        this.energyCodeName = energyCodeName;
        this.unit = unit;
        this.modulus = modulus;
        this.refModulus = refModulus;
        this.userid = userid;
        this.updateTime = updateTime;
        this.delFlag = delFlag;
        this.deptId = deptId;
        this.productionConsumption = productionConsumption;
        this.proConTotal = proConTotal;
        this.thermalPower = thermalPower;
        this.heating = heating;
        this.coalWashing = coalWashing;
        this.wastePower = wastePower;
        this.gasPower = gasPower;
        this.coking = coking;
        this.oil = oil;
        this.gasification = gasification;
        this.gasLiquefaction = gasLiquefaction;
        this.coalProducts = coalProducts;
        this.conversionOutput = conversionOutput;
        this.conversionOutputRef = conversionOutputRef;
        this.recycling = recycling;
        this.remark = remark;
    }

    @Override
    public String toString() {
        return "TReportEnergyOut{" +
                "id=" + id +
                ", reportId=" + reportId +
                ", energyCode=" + energyCode +
                ", energyCodeName='" + energyCodeName + '\'' +
                ", unit='" + unit + '\'' +
                ", modulus='" + modulus + '\'' +
                ", refModulus='" + refModulus + '\'' +
                ", userid=" + userid +
                ", updateTime=" + updateTime +
                ", delFlag='" + delFlag + '\'' +
                ", deptId=" + deptId +
                ", productionConsumption=" + big(productionConsumption) +
                ", proConTotal=" + big(proConTotal) +
                ", thermalPower=" + big(thermalPower) +
                ", heating=" + big(heating) +
                ", coalWashing=" + big(coalWashing) +
                ", coking=" + big(coking) +
                ", wastePower=" + big(wastePower) +
                ", gasPower=" + big(gasPower) +
                ", oil=" + big(oil) +
                ", gasification=" + big(gasification) +
                ", gasLiquefaction=" + big(gasLiquefaction) +
                ", coalProducts=" + big(coalProducts) +
                ", conversionOutput=" + big(conversionOutput) +
                ", conversionOutputRef=" + big(conversionOutputRef) +
                ", recycling=" + big(recycling)+
                ", remark='" + remark + '\'' +
                '}';
    }

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