Search in sources :

Example 1 with BbMeasureData

use of com.netsteadfast.greenstep.po.hbm.BbMeasureData in project bamboobsc by billchen198318.

the class LoadMeasureDataCommand method execute.

@SuppressWarnings("unchecked")
@Override
public boolean execute(Context context) throws Exception {
    measureDataService = (IMeasureDataService<MeasureDataVO, BbMeasureData, String>) AppContext.getBean("bsc.service.MeasureDataService");
    String frequency = (String) context.get("frequency");
    String startYearDate = StringUtils.defaultString((String) context.get("startYearDate")).trim();
    String endYearDate = StringUtils.defaultString((String) context.get("endYearDate")).trim();
    String startDate = StringUtils.defaultString((String) context.get("startDate")).trim();
    String endDate = StringUtils.defaultString((String) context.get("endDate")).trim();
    startDate = startDate.replaceAll("/", "").replaceAll("-", "");
    endDate = endDate.replaceAll("/", "").replaceAll("-", "");
    String date1 = startDate;
    String date2 = endDate;
    if (BscMeasureDataFrequency.FREQUENCY_QUARTER.equals(frequency) || BscMeasureDataFrequency.FREQUENCY_HALF_OF_YEAR.equals(frequency) || BscMeasureDataFrequency.FREQUENCY_YEAR.equals(frequency)) {
        date1 = startYearDate + "0101";
        date2 = endYearDate + "12" + SimpleUtils.getMaxDayOfMonth(Integer.parseInt(endYearDate), 12);
    }
    String measureDataOrgaId = (String) context.get("orgId");
    String measureDataEmplId = (String) context.get("empId");
    if (this.getResult(context) == null || !(this.getResult(context) instanceof BscStructTreeObj)) {
        return false;
    }
    BscStructTreeObj treeObj = (BscStructTreeObj) this.getResult(context);
    for (VisionVO vision : treeObj.getVisions()) {
        for (PerspectiveVO perspective : vision.getPerspectives()) {
            for (ObjectiveVO objective : perspective.getObjectives()) {
                for (KpiVO kpi : objective.getKpis()) {
                    this.fillMeasureData(kpi, frequency, date1, date2, measureDataOrgaId, measureDataEmplId);
                }
            }
        }
    }
    return false;
}
Also used : ObjectiveVO(com.netsteadfast.greenstep.vo.ObjectiveVO) BscStructTreeObj(com.netsteadfast.greenstep.bsc.model.BscStructTreeObj) KpiVO(com.netsteadfast.greenstep.vo.KpiVO) BbMeasureData(com.netsteadfast.greenstep.po.hbm.BbMeasureData) PerspectiveVO(com.netsteadfast.greenstep.vo.PerspectiveVO) MeasureDataVO(com.netsteadfast.greenstep.vo.MeasureDataVO) VisionVO(com.netsteadfast.greenstep.vo.VisionVO)

Example 2 with BbMeasureData

use of com.netsteadfast.greenstep.po.hbm.BbMeasureData in project bamboobsc by billchen198318.

the class LoadMeasureDataCommand method fillMeasureData.

private void fillMeasureData(KpiVO kpi, String frequency, String startDate, String endDate, String orgId, String empId) throws Exception {
    Map<String, Object> params = new HashMap<String, Object>();
    Map<String, CustomeOperational> customOperParams = new HashMap<String, CustomeOperational>();
    params.put("kpiId", kpi.getId());
    params.put("frequency", frequency);
    params.put("orgId", orgId);
    params.put("empId", empId);
    CustomeOperational op1 = new CustomeOperational();
    op1.setField("date");
    op1.setOp(">=");
    op1.setValue(startDate);
    CustomeOperational op2 = new CustomeOperational();
    op2.setField("date");
    op2.setOp("<=");
    op2.setValue(endDate);
    customOperParams.put("op1", op1);
    customOperParams.put("op2", op2);
    List<BbMeasureData> measureDatas = this.measureDataService.findListByParams2(params, customOperParams);
    kpi.setMeasureDatas(measureDatas);
}
Also used : HashMap(java.util.HashMap) BbMeasureData(com.netsteadfast.greenstep.po.hbm.BbMeasureData) CustomeOperational(com.netsteadfast.greenstep.base.model.CustomeOperational)

Example 3 with BbMeasureData

use of com.netsteadfast.greenstep.po.hbm.BbMeasureData 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 4 with BbMeasureData

use of com.netsteadfast.greenstep.po.hbm.BbMeasureData 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 5 with BbMeasureData

use of com.netsteadfast.greenstep.po.hbm.BbMeasureData 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)

Aggregations

BbMeasureData (com.netsteadfast.greenstep.po.hbm.BbMeasureData)19 BscMeasureData (com.netsteadfast.greenstep.bsc.model.BscMeasureData)15 DateRangeScoreVO (com.netsteadfast.greenstep.vo.DateRangeScoreVO)9 ArrayList (java.util.ArrayList)6 HashMap (java.util.HashMap)2 CustomeOperational (com.netsteadfast.greenstep.base.model.CustomeOperational)1 BscStructTreeObj (com.netsteadfast.greenstep.bsc.model.BscStructTreeObj)1 KpiVO (com.netsteadfast.greenstep.vo.KpiVO)1 MeasureDataVO (com.netsteadfast.greenstep.vo.MeasureDataVO)1 ObjectiveVO (com.netsteadfast.greenstep.vo.ObjectiveVO)1 PerspectiveVO (com.netsteadfast.greenstep.vo.PerspectiveVO)1 VisionVO (com.netsteadfast.greenstep.vo.VisionVO)1