DrugConsumptionDisplayVO.java 4.5 KB
package com.skua.modules.equipment.vo;

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

import java.math.BigDecimal;

@Data
@ApiModel(value="药耗分析:数据展示", description="药耗分析:数据展示(药耗分析)")
public class DrugConsumptionDisplayVO {


    @ApiModelProperty(value = "药剂code")
    private String drugCode;
    @ApiModelProperty(value = "药剂名称")
    private String drugName;


    @ApiModelProperty(value = "出水量")
    private Double CSL;
    @ApiModelProperty(value = "同比去年出水量")
    private Double tbqnCsl;
    @ApiModelProperty(value = "环比上月出水量")
    private Double hbsyCsl;

    @ApiModelProperty(value = "总药耗")
    private Double zyh;

    @ApiModelProperty(value = "同比去年总药耗")
    private Double tbqnzyh;
    @ApiModelProperty(value = "同比去年总药耗")
    private Double tbqnzyhsl;
    @ApiModelProperty(value = "同比去年总药耗比例")
    private Double tbqnzyhbl;


    @ApiModelProperty(value = "环比上月总药耗")
    private Double hbsyzyh;
    @ApiModelProperty(value = "环比上月总药耗")
    private Double hbsyzyhsl;
    @ApiModelProperty(value = "环比上月总药耗比例")
    private Double hbsyzyhbl;


    @ApiModelProperty(value = "目标吨水药耗")
    private Double mbdsyh = 0.65d;

    @ApiModelProperty(value = "月吨水药耗")
    private Double dsyh;

    @ApiModelProperty(value = "同比去年吨水药耗")
    private Double tbqndsyh;
    @ApiModelProperty(value = "同比去年吨水药耗")
    private Double tbqndsyhsl;
    @ApiModelProperty(value = "同比去年吨水药耗比例")
    private Double tbqndsyhbl;


    @ApiModelProperty(value = "环比上月吨水药耗")
    private Double hbsydsyh;
    @ApiModelProperty(value = "环比上月吨水药耗")
    private Double hbsydsyhsl;
    @ApiModelProperty(value = "环比上月吨水药耗比例")
    private Double hbsydsyhbl;



    @ApiModelProperty(value = "历史最低吨水药耗")
    private String lszddsyh;
    @ApiModelProperty(value = "历史最低吨水药耗--月份")
    private String lszddsyhyf;

    public DrugConsumptionDisplayVO() {
    }

    public DrugConsumptionDisplayVO(String drugCode, String drugName) {
        this.drugCode = drugCode;
        this.drugName = drugName;
    }

    public DrugConsumptionDisplayVO(Double CSL, Double tbqnCsl, Double hbsyCsl, Double zyh, Double hbsyzyh, Double tbqnzyh) {
        this.CSL = CSL;
        this.tbqnCsl = tbqnCsl;
        this.hbsyCsl = hbsyCsl;
        this.zyh = zyh;
        this.hbsyzyh = hbsyzyh;
        this.tbqnzyh = tbqnzyh;

        if(this.zyh != null ){
            //计算吨水药耗
            //药耗量[kg] / 处理水量[吨]
            if(this.CSL != null && Double.compare(this.CSL, 0.0) != 0)  this.dsyh = this.getValue(this.zyh /this.CSL );
            //同比总药耗
            if(this.tbqnzyh != null){
                this.tbqnzyhsl = this.getValue(this.zyh - this.tbqnzyh);
                this.tbqnzyhbl = this.getValue(((this.zyh - this.tbqnzyh)/this.tbqnzyh)*100) ;
                //计算吨水药耗  //同比吨水药耗
                if(this.tbqnCsl != null && Double.compare(this.tbqnCsl, 0.0) != 0)  this.tbqndsyh = this.getValue(this.tbqnzyh /this.tbqnCsl );
                if(this.tbqndsyh  != null ){
                    this.tbqndsyhsl = this.getValue(dsyh-tbqndsyh);
                    this.tbqndsyhbl = this.getValue((dsyh-tbqndsyh)/tbqndsyh*100);
                }
            }
            //环比总药耗
            if(this.hbsyzyh != null ){
                this.hbsyzyhsl = this.getValue(this.zyh - this.hbsyzyh);
                this.hbsyzyhbl = this.getValue(((this.zyh - this.hbsyzyh)/this.hbsyzyh)*100) ;
                //环比-吨水药耗
                if(this.hbsyCsl != null && Double.compare(this.hbsyCsl, 0.0) != 0)   this.hbsydsyh = this.getValue(this.hbsyzyh /this.hbsyCsl );
                if(this.hbsydsyh != null){
                    this.hbsydsyhsl = this.getValue(this.dsyh - this.hbsydsyh);
                    this.hbsydsyhbl = this.getValue((this.dsyh - this.hbsydsyh) / this.hbsydsyh*100);
                }
            }
        }
    }
    private Double getValue(Double d) {
        try{
            BigDecimal two = new BigDecimal(d);
            double three = two.setScale(2,BigDecimal.ROUND_HALF_UP).doubleValue();
            return three;
        }catch(Exception e){
            //e.printStackTrace();
        }
        return null;
    }
}