Search in sources :

Example 6 with FormulaVO

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();
}
Also used : ServiceException(com.netsteadfast.greenstep.base.exception.ServiceException) FormulaVO(com.netsteadfast.greenstep.vo.FormulaVO)

Example 7 with FormulaVO

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));
}
Also used : ServiceException(com.netsteadfast.greenstep.base.exception.ServiceException) KpiVO(com.netsteadfast.greenstep.vo.KpiVO) FormulaVO(com.netsteadfast.greenstep.vo.FormulaVO) HashMap(java.util.HashMap) Map(java.util.Map)

Example 8 with FormulaVO

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;
    }
}
Also used : FormulaVO(com.netsteadfast.greenstep.vo.FormulaVO)

Example 9 with FormulaVO

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;
    }
}
Also used : FormulaVO(com.netsteadfast.greenstep.vo.FormulaVO)

Example 10 with FormulaVO

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);
}
Also used : BscMeasureData(com.netsteadfast.greenstep.bsc.model.BscMeasureData) FormulaVO(com.netsteadfast.greenstep.vo.FormulaVO)

Aggregations

FormulaVO (com.netsteadfast.greenstep.vo.FormulaVO)10 ServiceException (com.netsteadfast.greenstep.base.exception.ServiceException)3 KpiVO (com.netsteadfast.greenstep.vo.KpiVO)2 DefaultResult (com.netsteadfast.greenstep.base.model.DefaultResult)1 SystemMessage (com.netsteadfast.greenstep.base.model.SystemMessage)1 BscMeasureData (com.netsteadfast.greenstep.bsc.model.BscMeasureData)1 IFormulaService (com.netsteadfast.greenstep.bsc.service.IFormulaService)1 BscMixDataVO (com.netsteadfast.greenstep.bsc.vo.BscMixDataVO)1 BbFormula (com.netsteadfast.greenstep.po.hbm.BbFormula)1 AggregationMethodVO (com.netsteadfast.greenstep.vo.AggregationMethodVO)1 ObjectiveVO (com.netsteadfast.greenstep.vo.ObjectiveVO)1 PerspectiveVO (com.netsteadfast.greenstep.vo.PerspectiveVO)1 VisionVO (com.netsteadfast.greenstep.vo.VisionVO)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1