use of com.netsteadfast.greenstep.vo.FormulaVO in project bamboobsc by billchen198318.
the class KpiLogicServiceImpl method fetchFormulaByOid.
private FormulaVO fetchFormulaByOid(String formulaOid) throws ServiceException, Exception {
FormulaVO formula = new FormulaVO();
formula.setOid(formulaOid);
DefaultResult<FormulaVO> forResult = this.formulaService.findObjectByOid(formula);
if (forResult.getValue() == null) {
throw new ServiceException(forResult.getSystemMessage().getValue());
}
return forResult.getValue();
}
use of com.netsteadfast.greenstep.vo.FormulaVO in project bamboobsc by billchen198318.
the class MeasureDataCalendarUtils method renderBody.
public static String renderBody(String kpiOid, String date, String frequency, String dataFor, String orgaOid, String emplOid, Map<String, String> labels) throws ServiceException, Exception {
if (StringUtils.isBlank(kpiOid) || StringUtils.isBlank(date) || StringUtils.isBlank(frequency) || StringUtils.isBlank(dataFor)) {
throw new ServiceException(SysMessageUtil.get(GreenStepSysMsgConstants.PARAMS_BLANK));
}
KpiVO kpi = findKpi(kpiOid);
//FormulaVO formula = findFormula(kpi.getForId());
FormulaVO formula = BscFormulaUtils.getFormulaById(kpi.getForId());
Map<String, Object> parameter = getParameter(kpi, formula, date, frequency, dataFor, orgaOid, emplOid);
if (BscMeasureDataFrequency.FREQUENCY_DAY.equals(frequency)) {
fillParameterForDay(parameter);
}
if (BscMeasureDataFrequency.FREQUENCY_WEEK.equals(frequency) || BscMeasureDataFrequency.FREQUENCY_MONTH.equals(frequency)) {
fillParameterForWeekOrMonth(parameter);
}
if (BscMeasureDataFrequency.FREQUENCY_QUARTER.equals(frequency) || BscMeasureDataFrequency.FREQUENCY_HALF_OF_YEAR.equals(frequency) || BscMeasureDataFrequency.FREQUENCY_YEAR.equals(frequency)) {
fillParameterForQuarterOrYear(parameter);
}
for (Map.Entry<String, String> entry : labels.entrySet()) {
parameter.put(entry.getKey(), entry.getValue());
}
return render(parameter, getTemplateResource(frequency));
}
use of com.netsteadfast.greenstep.vo.FormulaVO in project bamboobsc by billchen198318.
the class FormulaSaveOrUpdateAction method update.
private void update() throws ControllerException, AuthorityException, ServiceException, Exception {
this.checkFields();
this.testFormula();
FormulaVO formula = new FormulaVO();
this.transformFields2ValueObject(formula, new String[] { "oid", "forId", "name", "type", "trendsFlag", "returnMode", "returnVar", "expression", "description" });
DefaultResult<FormulaVO> result = this.formulaLogicService.update(formula);
this.message = result.getSystemMessage().getValue();
if (result.getValue() != null) {
this.success = IS_YES;
}
}
use of com.netsteadfast.greenstep.vo.FormulaVO in project bamboobsc by billchen198318.
the class FormulaSaveOrUpdateAction method save.
private void save() throws ControllerException, AuthorityException, ServiceException, Exception {
this.checkFields();
this.testFormula();
FormulaVO formula = new FormulaVO();
this.transformFields2ValueObject(formula, new String[] { "forId", "name", "type", "trendsFlag", "returnMode", "returnVar", "expression", "description" });
DefaultResult<FormulaVO> result = this.formulaLogicService.create(formula);
this.message = result.getSystemMessage().getValue();
if (result.getValue() != null) {
this.success = IS_YES;
}
}
use of com.netsteadfast.greenstep.vo.FormulaVO 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