Search in sources :

Example 11 with BscStructTreeObj

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

the class KpiReportBodyCommand method execute.

@Override
public boolean execute(Context context) throws Exception {
    if (this.getResult(context) == null || !(this.getResult(context) instanceof BscStructTreeObj)) {
        return false;
    }
    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();
    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 + "/01/01";
        date2 = endYearDate + "/12/" + SimpleUtils.getMaxDayOfMonth(Integer.parseInt(endYearDate), 12);
    }
    BscStructTreeObj treeObj = (BscStructTreeObj) this.getResult(context);
    Map<String, Object> parameter = new HashMap<String, Object>();
    parameter.put("treeObj", treeObj);
    parameter.put("date1", date1);
    parameter.put("date2", date2);
    parameter.put("frequency", BscMeasureDataFrequency.getFrequencyMap(false).get(frequency));
    parameter.put("headContent", "");
    this.fillHeadContent(context, parameter);
    this.fillReportProperty(parameter);
    String templateResourceSrc = templateResource;
    if (YesNo.YES.equals((String) context.get("ngVer"))) {
        // 有 javascript click 事件的版本
        templateResourceSrc = templateResource_NG;
    }
    String nextType = (String) context.get("nextType");
    String nextId = (String) context.get("nextId");
    if (BscConstants.HEAD_FOR_PER_ID.equals(nextType) && !StringUtils.isBlank(nextId)) {
        templateResourceSrc = templateResource_NG_PER;
    }
    if (BscConstants.HEAD_FOR_OBJ_ID.equals(nextType) && !StringUtils.isBlank(nextId)) {
        templateResourceSrc = templateResource_NG_OBJ;
    }
    if (BscConstants.HEAD_FOR_KPI_ID.equals(nextType) && !StringUtils.isBlank(nextId)) {
        templateResourceSrc = templateResource_NG_KPI;
    }
    this.setImgIconBaseAndKpiInfo(treeObj);
    String content = TemplateUtils.processTemplate("resourceTemplate", KpiReportBodyCommand.class.getClassLoader(), templateResourceSrc, parameter);
    this.setResult(context, content);
    return false;
}
Also used : HashMap(java.util.HashMap) BscStructTreeObj(com.netsteadfast.greenstep.bsc.model.BscStructTreeObj)

Example 12 with BscStructTreeObj

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

the class KpiReportExcelCommand method createExcel.

private String createExcel(Context context) throws Exception {
    String visionOid = (String) context.get("visionOid");
    VisionVO vision = null;
    BscStructTreeObj treeObj = (BscStructTreeObj) this.getResult(context);
    for (VisionVO visionObj : treeObj.getVisions()) {
        if (visionObj.getOid().equals(visionOid)) {
            vision = visionObj;
        }
    }
    BscReportPropertyUtils.loadData();
    // 2015-04-18 add
    BscReportSupportUtils.loadExpression();
    String fileName = SimpleUtils.getUUIDStr() + ".xlsx";
    String fileFullPath = Constants.getWorkTmpDir() + "/" + fileName;
    int row = 24;
    if (context.get("pieCanvasToData") == null || context.get("barCanvasToData") == null) {
        row = 0;
    }
    XSSFWorkbook wb = new XSSFWorkbook();
    XSSFSheet sh = wb.createSheet();
    row += this.createHead(wb, sh, row, vision);
    row = this.createMainBody(wb, sh, row, vision);
    // 空一列
    row = row + 1;
    row = this.createDateRange(wb, sh, row, vision, context);
    if (context.get("pieCanvasToData") != null && context.get("barCanvasToData") != null) {
        this.putCharts(wb, sh, context);
    }
    this.putSignature(wb, sh, row + 1, context);
    FileOutputStream out = new FileOutputStream(fileFullPath);
    wb.write(out);
    out.close();
    wb = null;
    File file = new File(fileFullPath);
    String oid = UploadSupportUtils.create(Constants.getSystem(), UploadTypes.IS_TEMP, false, file, "kpi-report.xlsx");
    file = null;
    return oid;
}
Also used : XSSFSheet(org.apache.poi.xssf.usermodel.XSSFSheet) BscStructTreeObj(com.netsteadfast.greenstep.bsc.model.BscStructTreeObj) FileOutputStream(java.io.FileOutputStream) XSSFWorkbook(org.apache.poi.xssf.usermodel.XSSFWorkbook) VisionVO(com.netsteadfast.greenstep.vo.VisionVO) File(java.io.File)

Example 13 with BscStructTreeObj

use of com.netsteadfast.greenstep.bsc.model.BscStructTreeObj 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)

Example 14 with BscStructTreeObj

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

the class KpiReportCoffeeChartJsonDataCommand method execute.

@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);
    this.setJsonData(context, treeObj);
    return false;
}
Also used : BscStructTreeObj(com.netsteadfast.greenstep.bsc.model.BscStructTreeObj)

Example 15 with BscStructTreeObj

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

the class LoadStrategyMapItemsForNewCommand method execute.

@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 visionOid = (String) context.get("visionOid");
    VisionVO vision = null;
    for (VisionVO obj : treeObj.getVisions()) {
        if (obj.getOid().equals(visionOid)) {
            vision = obj;
        }
    }
    StrategyMapItemsVO mapItems = this.fillStrategyMapItems(vision);
    this.setResult(context, mapItems);
    return false;
}
Also used : StrategyMapItemsVO(com.netsteadfast.greenstep.bsc.vo.StrategyMapItemsVO) BscStructTreeObj(com.netsteadfast.greenstep.bsc.model.BscStructTreeObj) VisionVO(com.netsteadfast.greenstep.vo.VisionVO)

Aggregations

BscStructTreeObj (com.netsteadfast.greenstep.bsc.model.BscStructTreeObj)28 VisionVO (com.netsteadfast.greenstep.vo.VisionVO)17 KpiVO (com.netsteadfast.greenstep.vo.KpiVO)8 ObjectiveVO (com.netsteadfast.greenstep.vo.ObjectiveVO)8 PerspectiveVO (com.netsteadfast.greenstep.vo.PerspectiveVO)8 HashMap (java.util.HashMap)8 ChainResultObj (com.netsteadfast.greenstep.base.model.ChainResultObj)7 File (java.io.File)6 FileOutputStream (java.io.FileOutputStream)6 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)3 Document (com.itextpdf.text.Document)3 PdfPTable (com.itextpdf.text.pdf.PdfPTable)3 PdfWriter (com.itextpdf.text.pdf.PdfWriter)3 SimpleChain (com.netsteadfast.greenstep.base.chain.SimpleChain)3 ServiceException (com.netsteadfast.greenstep.base.exception.ServiceException)3 OutputStream (java.io.OutputStream)3 Context (org.apache.commons.chain.Context)3 XSSFSheet (org.apache.poi.xssf.usermodel.XSSFSheet)3 XSSFWorkbook (org.apache.poi.xssf.usermodel.XSSFWorkbook)3 StrategyMapItemsVO (com.netsteadfast.greenstep.bsc.vo.StrategyMapItemsVO)2