Search in sources :

Example 16 with BscMeasureData

use of com.netsteadfast.greenstep.bsc.model.BscMeasureData in project bamboobsc by billchen198318.

the class FormulaSaveOrUpdateAction method testFormula.

private Object testFormula() throws ControllerException, AuthorityException, ServiceException, Exception {
    this.getCheckFieldHandler().single("type", (this.isNoSelectId(this.getFields().get("type"))), this.getText("MESSAGE.BSC_PROG001D0003A_type")).single("trendsFlag", (this.isNoSelectId(this.getFields().get("trendsFlag"))), this.getText("MESSAGE.BSC_PROG001D0003A_trendsFlag")).single("returnMode", (this.isNoSelectId(this.getFields().get("returnMode"))), this.getText("MESSAGE.BSC_PROG001D0003A_returnMode")).single("returnVar", (FormulaMode.MODE_CUSTOM.equals(this.getFields().get("returnMode")) && StringUtils.isBlank(this.getFields().get("returnVar"))), this.getText("MESSAGE.BSC_PROG001D0003A_msg2")).single("expression", (StringUtils.isBlank(this.getFields().get("expression"))), this.getText("MESSAGE.BSC_PROG001D0003A_expression")).throwMessage();
    String actual = this.getFields().get("actual");
    String target = this.getFields().get("target");
    String cv = this.getFields().get("cv");
    String pv = this.getFields().get("pv");
    if (!NumberUtils.isNumber(actual)) {
        actual = "60.0";
    }
    if (!NumberUtils.isNumber(target)) {
        target = "100.0";
    }
    if (!NumberUtils.isNumber(cv)) {
        cv = "70.0";
    }
    if (!NumberUtils.isNumber(pv)) {
        pv = "55.0";
    }
    FormulaVO formula = new FormulaVO();
    this.transformFields2ValueObject(formula, new String[] { "type", "trendsFlag", "returnMode", "returnVar", "expression" });
    if (YesNo.YES.equals(formula.getTrendsFlag())) {
        return BscFormulaUtils.parseKPIPeroidScoreChangeValue(formula, Float.parseFloat(cv), Float.parseFloat(pv));
    }
    BscMeasureData data = new BscMeasureData();
    data.setActual(Float.parseFloat(actual));
    data.setTarget(Float.parseFloat(target));
    return BscFormulaUtils.parse(formula, data);
}
Also used : BscMeasureData(com.netsteadfast.greenstep.bsc.model.BscMeasureData) FormulaVO(com.netsteadfast.greenstep.vo.FormulaVO)

Aggregations

BscMeasureData (com.netsteadfast.greenstep.bsc.model.BscMeasureData)16 BbMeasureData (com.netsteadfast.greenstep.po.hbm.BbMeasureData)15 DateRangeScoreVO (com.netsteadfast.greenstep.vo.DateRangeScoreVO)8 ArrayList (java.util.ArrayList)6 FormulaVO (com.netsteadfast.greenstep.vo.FormulaVO)1