Search in sources :

Example 1 with BscMeasureData

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

the class AggregationMethod method averageDistinctDateRange.

public void averageDistinctDateRange(KpiVO kpi, String frequency) throws Exception {
    BscReportSupportUtils.loadExpression();
    for (DateRangeScoreVO dateScore : kpi.getDateRangeScores()) {
        List<Float> scores = new ArrayList<Float>();
        float score = 0.0f;
        int size = 0;
        for (BbMeasureData measureData : kpi.getMeasureDatas()) {
            String date = dateScore.getDate().replaceAll("/", "");
            if (!this.isDateRange(date, frequency, measureData)) {
                continue;
            }
            BscMeasureData data = new BscMeasureData();
            data.setActual(measureData.getActual());
            data.setTarget(measureData.getTarget());
            try {
                Object value = BscFormulaUtils.parse(kpi.getFormula(), data);
                if (value == null) {
                    continue;
                }
                if (!NumberUtils.isNumber(String.valueOf(value))) {
                    continue;
                }
                float nowScore = NumberUtils.toFloat(String.valueOf(value), 0.0f);
                if (!scores.contains(nowScore)) {
                    scores.add(nowScore);
                    score += nowScore;
                    size++;
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
        if (score != 0.0f && size > 0) {
            score = score / size;
        }
        dateScore.setScore(score);
        dateScore.setFontColor(BscScoreColorUtils.getFontColor(score));
        dateScore.setBgColor(BscScoreColorUtils.getBackgroundColor(score));
        dateScore.setImgIcon(BscReportSupportUtils.getHtmlIcon(kpi, score));
    }
}
Also used : BscMeasureData(com.netsteadfast.greenstep.bsc.model.BscMeasureData) ArrayList(java.util.ArrayList) DateRangeScoreVO(com.netsteadfast.greenstep.vo.DateRangeScoreVO) BbMeasureData(com.netsteadfast.greenstep.po.hbm.BbMeasureData)

Example 2 with BscMeasureData

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

the class AggregationMethod method min.

public float min(KpiVO kpi) throws Exception {
    List<BbMeasureData> measureDatas = kpi.getMeasureDatas();
    // init
    float score = 0.0f;
    int size = 0;
    float nowScore = 0.0f;
    for (BbMeasureData measureData : measureDatas) {
        BscMeasureData data = new BscMeasureData();
        data.setActual(measureData.getActual());
        data.setTarget(measureData.getTarget());
        try {
            Object value = BscFormulaUtils.parse(kpi.getFormula(), data);
            if (value == null) {
                continue;
            }
            if (!NumberUtils.isNumber(String.valueOf(value))) {
                continue;
            }
            nowScore = NumberUtils.toFloat(String.valueOf(value), 0.0f);
            if (size < 1) {
                score = nowScore;
            } else {
                // Min
                if (score > nowScore) {
                    score = nowScore;
                }
            }
            size++;
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    return score;
}
Also used : BscMeasureData(com.netsteadfast.greenstep.bsc.model.BscMeasureData) BbMeasureData(com.netsteadfast.greenstep.po.hbm.BbMeasureData)

Example 3 with BscMeasureData

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

the class AggregationMethod method sumDistinct.

public float sumDistinct(KpiVO kpi) throws Exception {
    List<BbMeasureData> measureDatas = kpi.getMeasureDatas();
    List<Float> scores = new ArrayList<Float>();
    // init
    float score = 0.0f;
    //int size = 0;
    for (BbMeasureData measureData : measureDatas) {
        BscMeasureData data = new BscMeasureData();
        data.setActual(measureData.getActual());
        data.setTarget(measureData.getTarget());
        try {
            Object value = BscFormulaUtils.parse(kpi.getFormula(), data);
            if (value == null) {
                continue;
            }
            if (!NumberUtils.isNumber(String.valueOf(value))) {
                continue;
            }
            float nowScore = NumberUtils.toFloat(String.valueOf(value), 0.0f);
            if (!scores.contains(nowScore)) {
                scores.add(nowScore);
                //size++;
                score += nowScore;
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    return score;
}
Also used : BscMeasureData(com.netsteadfast.greenstep.bsc.model.BscMeasureData) ArrayList(java.util.ArrayList) BbMeasureData(com.netsteadfast.greenstep.po.hbm.BbMeasureData)

Example 4 with BscMeasureData

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

the class AggregationMethod method averageDistinct.

public float averageDistinct(KpiVO kpi) throws Exception {
    List<BbMeasureData> measureDatas = kpi.getMeasureDatas();
    List<Float> scores = new ArrayList<Float>();
    // init zero
    float score = 0.0f;
    int size = 0;
    for (BbMeasureData measureData : measureDatas) {
        BscMeasureData data = new BscMeasureData();
        data.setActual(measureData.getActual());
        data.setTarget(measureData.getTarget());
        try {
            Object value = BscFormulaUtils.parse(kpi.getFormula(), data);
            if (value == null) {
                continue;
            }
            if (!NumberUtils.isNumber(String.valueOf(value))) {
                continue;
            }
            float nowScore = NumberUtils.toFloat(String.valueOf(value), 0.0f);
            if (!scores.contains(nowScore)) {
                scores.add(nowScore);
                score += nowScore;
                size++;
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    if (score != 0.0f && size > 0) {
        score = score / size;
    }
    return score;
}
Also used : BscMeasureData(com.netsteadfast.greenstep.bsc.model.BscMeasureData) ArrayList(java.util.ArrayList) BbMeasureData(com.netsteadfast.greenstep.po.hbm.BbMeasureData)

Example 5 with BscMeasureData

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

the class AggregationMethod method sum.

public float sum(KpiVO kpi) throws Exception {
    List<BbMeasureData> measureDatas = kpi.getMeasureDatas();
    // init
    float score = 0.0f;
    //int size = 0;
    for (BbMeasureData measureData : measureDatas) {
        BscMeasureData data = new BscMeasureData();
        data.setActual(measureData.getActual());
        data.setTarget(measureData.getTarget());
        try {
            Object value = BscFormulaUtils.parse(kpi.getFormula(), data);
            if (value == null) {
                continue;
            }
            if (!NumberUtils.isNumber(String.valueOf(value))) {
                continue;
            }
            score += NumberUtils.toFloat(String.valueOf(value), 0.0f);
        //size++;
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    return score;
}
Also used : BscMeasureData(com.netsteadfast.greenstep.bsc.model.BscMeasureData) BbMeasureData(com.netsteadfast.greenstep.po.hbm.BbMeasureData)

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