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);
}
Aggregations