Search in sources :

Example 1 with ScoreCalculationCallable

use of com.netsteadfast.greenstep.bsc.support.ScoreCalculationCallable in project bamboobsc by billchen198318.

the class ScoreCalculationCommand method processKpisScore.

private void processKpisScore(List<VisionVO> visions) throws Exception {
    //long beg = System.currentTimeMillis();
    for (VisionVO vision : visions) {
        for (PerspectiveVO perspective : vision.getPerspectives()) {
            for (ObjectiveVO objective : perspective.getObjectives()) {
                // 2015-04-11 add
                ExecutorService kpiCalculationPool = Executors.newFixedThreadPool(SimpleUtils.getAvailableProcessors(objective.getKpis().size()));
                for (KpiVO kpi : objective.getKpis()) {
                    /* 2015-04-11 rem
						float score = this.calculationMeasureData(kpi);
						kpi.setScore(score);
						kpi.setBgColor( BscScoreColorUtils.getBackgroundColor(score) );
						kpi.setFontColor( BscScoreColorUtils.getFontColor(score) );
						*/
                    // 2015-04-11 add
                    ScoreCalculationCallableData data = new ScoreCalculationCallableData();
                    data.setDefaultMode(true);
                    data.setKpi(kpi);
                    data = kpiCalculationPool.submit(new ScoreCalculationCallable(data)).get();
                }
                kpiCalculationPool.shutdown();
            }
        }
    }
//long end = System.currentTimeMillis();
//System.out.println( this.getClass().getName() + " use time(MS) = " + (end-beg) );		
}
Also used : ObjectiveVO(com.netsteadfast.greenstep.vo.ObjectiveVO) ExecutorService(java.util.concurrent.ExecutorService) KpiVO(com.netsteadfast.greenstep.vo.KpiVO) ScoreCalculationCallableData(com.netsteadfast.greenstep.bsc.support.ScoreCalculationCallableData) PerspectiveVO(com.netsteadfast.greenstep.vo.PerspectiveVO) ScoreCalculationCallable(com.netsteadfast.greenstep.bsc.support.ScoreCalculationCallable) VisionVO(com.netsteadfast.greenstep.vo.VisionVO)

Example 2 with ScoreCalculationCallable

use of com.netsteadfast.greenstep.bsc.support.ScoreCalculationCallable in project bamboobsc by billchen198318.

the class KpiDateRangeScoreCommand method execute.

/*
	private static final String QUARTER_1 = "Q1";
	private static final String QUARTER_2 = "Q2";
	private static final String QUARTER_3 = "Q3";
	private static final String QUARTER_4 = "Q4";
	private static final String HALF_YEAR_FIRST = "first";
	private static final String HALF_YEAR_LAST = "last";
	*/
@Override
public boolean execute(Context context) throws Exception {
    if (this.getResult(context) == null || !(this.getResult(context) instanceof BscStructTreeObj)) {
        return false;
    }
    BscStructTreeObj treeObj = (BscStructTreeObj) this.getResult(context);
    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();
    //long beg = System.currentTimeMillis();
    for (VisionVO vision : treeObj.getVisions()) {
        for (PerspectiveVO perspective : vision.getPerspectives()) {
            for (ObjectiveVO objective : perspective.getObjectives()) {
                // 2015-04-11 add
                ExecutorService kpiCalculationPool = Executors.newFixedThreadPool(SimpleUtils.getAvailableProcessors(objective.getKpis().size()));
                for (KpiVO kpi : objective.getKpis()) {
                    /* 2015-04-11 rem
						if (BscMeasureDataFrequency.FREQUENCY_DAY.equals(frequency) 
								|| BscMeasureDataFrequency.FREQUENCY_WEEK.equals(frequency) 
								|| BscMeasureDataFrequency.FREQUENCY_MONTH.equals(frequency) ) {
							this.fillDateRangeMonth(kpi, frequency, startDate, endDate);
						} else {
							this.fillDateRangeYear(kpi, frequency, startYearDate, endYearDate);
						}
						*/
                    // 2015-04-11 add
                    ScoreCalculationCallableData data = new ScoreCalculationCallableData();
                    data.setDefaultMode(false);
                    data.setKpi(kpi);
                    data.setFrequency(frequency);
                    data.setDate1(startYearDate);
                    data.setDate2(endYearDate);
                    if (BscMeasureDataFrequency.FREQUENCY_DAY.equals(frequency) || BscMeasureDataFrequency.FREQUENCY_WEEK.equals(frequency) || BscMeasureDataFrequency.FREQUENCY_MONTH.equals(frequency)) {
                        data.setDate1(startDate);
                        data.setDate2(endDate);
                    }
                    data = kpiCalculationPool.submit(new ScoreCalculationCallable(data)).get();
                }
                kpiCalculationPool.shutdown();
            }
        }
    }
    //System.out.println( this.getClass().getName() + " use time(MS) = " + (end-beg) );
    return false;
}
Also used : ObjectiveVO(com.netsteadfast.greenstep.vo.ObjectiveVO) BscStructTreeObj(com.netsteadfast.greenstep.bsc.model.BscStructTreeObj) ExecutorService(java.util.concurrent.ExecutorService) KpiVO(com.netsteadfast.greenstep.vo.KpiVO) ScoreCalculationCallableData(com.netsteadfast.greenstep.bsc.support.ScoreCalculationCallableData) PerspectiveVO(com.netsteadfast.greenstep.vo.PerspectiveVO) ScoreCalculationCallable(com.netsteadfast.greenstep.bsc.support.ScoreCalculationCallable) VisionVO(com.netsteadfast.greenstep.vo.VisionVO)

Aggregations

ScoreCalculationCallable (com.netsteadfast.greenstep.bsc.support.ScoreCalculationCallable)2 ScoreCalculationCallableData (com.netsteadfast.greenstep.bsc.support.ScoreCalculationCallableData)2 KpiVO (com.netsteadfast.greenstep.vo.KpiVO)2 ObjectiveVO (com.netsteadfast.greenstep.vo.ObjectiveVO)2 PerspectiveVO (com.netsteadfast.greenstep.vo.PerspectiveVO)2 VisionVO (com.netsteadfast.greenstep.vo.VisionVO)2 ExecutorService (java.util.concurrent.ExecutorService)2 BscStructTreeObj (com.netsteadfast.greenstep.bsc.model.BscStructTreeObj)1