Search in sources :

Example 1 with PeriodTrendsData

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

the class KpiPeriodTrendsExcelCommand method putTables.

@SuppressWarnings("unchecked")
private void putTables(XSSFWorkbook wb, XSSFSheet sh, Context context) throws Exception {
    XSSFCellStyle cellHeadStyle = wb.createCellStyle();
    cellHeadStyle.setFillForegroundColor(new XSSFColor(SimpleUtils.getColorRGB4POIColor("#f5f5f5")));
    cellHeadStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND);
    cellHeadStyle.setBorderBottom(BorderStyle.THIN);
    cellHeadStyle.setBorderTop(BorderStyle.THIN);
    cellHeadStyle.setBorderRight(BorderStyle.THIN);
    cellHeadStyle.setBorderLeft(BorderStyle.THIN);
    XSSFFont cellHeadFont = wb.createFont();
    cellHeadFont.setBold(true);
    cellHeadStyle.setFont(cellHeadFont);
    sh.setColumnWidth(0, 12000);
    int row = 0;
    Row nowRow = sh.createRow(row);
    Cell cell1 = nowRow.createCell(0);
    cell1.setCellStyle(cellHeadStyle);
    cell1.setCellValue("KPI");
    Cell cell2 = nowRow.createCell(1);
    cell2.setCellStyle(cellHeadStyle);
    cell2.setCellValue("Maximum");
    Cell cell3 = nowRow.createCell(2);
    cell3.setCellStyle(cellHeadStyle);
    cell3.setCellValue("Target");
    Cell cell4 = nowRow.createCell(3);
    cell4.setCellStyle(cellHeadStyle);
    cell4.setCellValue("Minimum");
    Cell cell5 = nowRow.createCell(4);
    cell5.setCellStyle(cellHeadStyle);
    cell5.setCellValue("Current score");
    Cell cell6 = nowRow.createCell(5);
    cell6.setCellStyle(cellHeadStyle);
    cell6.setCellValue("Previous score");
    Cell cell7 = nowRow.createCell(6);
    cell7.setCellStyle(cellHeadStyle);
    cell7.setCellValue("Change(%)");
    row++;
    List<PeriodTrendsData<KpiVO>> periodDatas = (List<PeriodTrendsData<KpiVO>>) context.get("periodDatas");
    for (PeriodTrendsData<KpiVO> periodData : periodDatas) {
        nowRow = sh.createRow(row);
        cell1 = nowRow.createCell(0);
        cell1.setCellValue(periodData.getCurrent().getName());
        cell2 = nowRow.createCell(1);
        cell2.setCellValue(periodData.getCurrent().getMax());
        cell3 = nowRow.createCell(2);
        cell3.setCellValue(periodData.getCurrent().getTarget());
        cell4 = nowRow.createCell(3);
        cell4.setCellValue(periodData.getCurrent().getMin());
        cell5 = nowRow.createCell(4);
        cell5.setCellValue(BscReportSupportUtils.parse2(periodData.getCurrent().getScore()));
        cell6 = nowRow.createCell(5);
        cell6.setCellValue(BscReportSupportUtils.parse2(periodData.getPrevious().getScore()));
        cell7 = nowRow.createCell(6);
        cell7.setCellValue(BscReportSupportUtils.parse2(periodData.getChange()));
        row++;
    }
    nowRow = sh.createRow(row);
    cell1 = nowRow.createCell(0);
    cell1.setCellValue("Current period: " + (String) context.get("currentPeriodDateRange") + " , Previous period: " + (String) context.get("previousPeriodDateRange"));
}
Also used : XSSFColor(org.apache.poi.xssf.usermodel.XSSFColor) XSSFCellStyle(org.apache.poi.xssf.usermodel.XSSFCellStyle) PeriodTrendsData(com.netsteadfast.greenstep.bsc.model.PeriodTrendsData) XSSFFont(org.apache.poi.xssf.usermodel.XSSFFont) KpiVO(com.netsteadfast.greenstep.vo.KpiVO) List(java.util.List) Row(org.apache.poi.ss.usermodel.Row) Cell(org.apache.poi.ss.usermodel.Cell)

Example 2 with PeriodTrendsData

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

the class PeriodTrendsCalUtils method getKpiScoreChange.

public static List<PeriodTrendsData<KpiVO>> getKpiScoreChange(String visionOid1, String startDate1, String endDate1, String startYearDate1, String endYearDate1, String frequency1, String dataFor1, String measureDataOrganizationOid1, String measureDataEmployeeOid1, String visionOid2, String startDate2, String endDate2, String startYearDate2, String endYearDate2, String frequency2, String dataFor2, String measureDataOrganizationOid2, String measureDataEmployeeOid2) throws ServiceException, Exception {
    List<PeriodTrendsData<KpiVO>> result = new ArrayList<PeriodTrendsData<KpiVO>>();
    Context context1 = PerformanceScoreChainUtils.getContext(visionOid1, startDate1, endDate1, startYearDate1, endYearDate1, frequency1, dataFor1, measureDataOrganizationOid1, measureDataEmployeeOid1);
    Context context2 = PerformanceScoreChainUtils.getContext(visionOid2, startDate2, endDate2, startYearDate2, endYearDate2, frequency2, dataFor2, measureDataOrganizationOid2, measureDataEmployeeOid2);
    /*
		SimpleChain chain1 = new SimpleChain();
		SimpleChain chain2 = new SimpleChain();
		ChainResultObj resultObj1 = chain1.getResultFromResource("performanceScoreChain", context1);
		ChainResultObj resultObj2 = chain2.getResultFromResource("performanceScoreChain", context2);
		*/
    fillKpiPeriodTrends(result, PerformanceScoreChainUtils.getResult(context1), PerformanceScoreChainUtils.getResult(context2), frequency1.equals(frequency2));
    return result;
}
Also used : Context(org.apache.commons.chain.Context) PeriodTrendsData(com.netsteadfast.greenstep.bsc.model.PeriodTrendsData) ArrayList(java.util.ArrayList) KpiVO(com.netsteadfast.greenstep.vo.KpiVO)

Example 3 with PeriodTrendsData

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

the class PeriodTrendsCalUtils method fillKpiPeriodTrends.

/*
	private static Context getContext(String visionOid, String startDate, String endDate, 
			String startYearDate, String endYearDate, String frequency, String dataFor, String orgId, String empId,
			String measureDataOrganizationOid, String measureDataEmployeeOid) throws ServiceException, Exception {
		Context context = new ContextBase();
		context.put("visionOid", visionOid);
		context.put("startDate", startDate);
		context.put("endDate", endDate);		
		context.put("startYearDate", startYearDate);
		context.put("endYearDate", endYearDate);		
		context.put("frequency", frequency);
		context.put("dataFor", dataFor);
		context.put("orgId", BscConstants.MEASURE_DATA_ORGANIZATION_FULL);
		context.put("empId", BscConstants.MEASURE_DATA_EMPLOYEE_FULL);
		context.put("account", "");
		if (!Constants.HTML_SELECT_NO_SELECT_ID.equals(measureDataOrganizationOid) && !StringUtils.isBlank(measureDataOrganizationOid)) {
			OrganizationVO organization = new OrganizationVO();
			organization.setOid( measureDataOrganizationOid );
			DefaultResult<OrganizationVO> result = organizationService.findObjectByOid(organization);
			if (result.getValue()==null) {
				throw new ServiceException(result.getSystemMessage().getValue());
			}
			organization = result.getValue();
			context.put("orgId", organization.getOrgId() );
		}
		if (!Constants.HTML_SELECT_NO_SELECT_ID.equals(measureDataEmployeeOid) && !StringUtils.isBlank(measureDataEmployeeOid)) {
			EmployeeVO employee = new EmployeeVO();
			employee.setOid( measureDataEmployeeOid );
			DefaultResult<EmployeeVO> result = employeeService.findObjectByOid(employee);
			if (result.getValue()==null) {
				throw new ServiceException(result.getSystemMessage().getValue());
			}
			employee = result.getValue();
			context.put("empId", employee.getEmpId() );
			context.put("account", employee.getAccount() );
		}				
		return context;
	}
	*/
private static void fillKpiPeriodTrends(List<PeriodTrendsData<KpiVO>> result, ChainResultObj result1, ChainResultObj result2, boolean sameFrequency) throws ServiceException, Exception {
    if (result1.getValue() == null || ((BscStructTreeObj) result1.getValue()).getVisions() == null || ((BscStructTreeObj) result1.getValue()).getVisions().size() == 0) {
        throw new ServiceException("No found previous period data can do calculate change score!" + Constants.HTML_BR);
    }
    if (result2.getValue() == null || ((BscStructTreeObj) result2.getValue()).getVisions() == null || ((BscStructTreeObj) result2.getValue()).getVisions().size() == 0) {
        throw new ServiceException("No found current period data can do calculate change score!" + Constants.HTML_BR);
    }
    VisionVO visionCV = ((BscStructTreeObj) result1.getValue()).getVisions().get(0);
    VisionVO visionPV = ((BscStructTreeObj) result2.getValue()).getVisions().get(0);
    for (PerspectiveVO perspective : visionCV.getPerspectives()) {
        for (ObjectiveVO objective : perspective.getObjectives()) {
            for (KpiVO kpi : objective.getKpis()) {
                PeriodTrendsData<KpiVO> periodData = new PeriodTrendsData<KpiVO>();
                periodData.setCurrent(kpi);
                result.add(periodData);
            }
        }
    }
    for (PeriodTrendsData<KpiVO> periodData : result) {
        for (PerspectiveVO perspective : visionPV.getPerspectives()) {
            for (ObjectiveVO objective : perspective.getObjectives()) {
                for (KpiVO kpi : objective.getKpis()) {
                    if (periodData.getCurrent().getId().equals(kpi.getId())) {
                        periodData.setPrevious(kpi);
                    }
                }
            }
        }
        if (periodData.getPrevious() == null) {
            //throw new ServiceException(SysMessageUtil.get(GreenStepSysMsgConstants.DATA_ERRORS));
            throw new ServiceException("No found previous period data can do calculate change score!" + Constants.HTML_BR + "KPI: " + periodData.getCurrent().getName());
        }
        /**
			 * periodData.getCurrent().getTrendsFormula() 與 periodData.getPrevious().getTrendsFormula() 一定是相同的 
			 */
        Object ans = BscFormulaUtils.parseKPIPeroidScoreChangeValue(periodData.getCurrent().getTrendsFormula(), periodData.getCurrent().getScore(), periodData.getPrevious().getScore());
        String change = String.valueOf(ans);
        if (NumberUtils.isNumber(String.valueOf(change))) {
            periodData.setChange(NumberUtils.toFloat(change));
        }
        if (sameFrequency && periodData.getCurrent().getDateRangeScores().size() == periodData.getPrevious().getDateRangeScores().size()) {
            fillKpiPeriodTrendsDateRangeScore(periodData);
        }
    }
}
Also used : ServiceException(com.netsteadfast.greenstep.base.exception.ServiceException) ObjectiveVO(com.netsteadfast.greenstep.vo.ObjectiveVO) PeriodTrendsData(com.netsteadfast.greenstep.bsc.model.PeriodTrendsData) KpiVO(com.netsteadfast.greenstep.vo.KpiVO) PerspectiveVO(com.netsteadfast.greenstep.vo.PerspectiveVO) VisionVO(com.netsteadfast.greenstep.vo.VisionVO)

Aggregations

PeriodTrendsData (com.netsteadfast.greenstep.bsc.model.PeriodTrendsData)3 KpiVO (com.netsteadfast.greenstep.vo.KpiVO)3 ServiceException (com.netsteadfast.greenstep.base.exception.ServiceException)1 ObjectiveVO (com.netsteadfast.greenstep.vo.ObjectiveVO)1 PerspectiveVO (com.netsteadfast.greenstep.vo.PerspectiveVO)1 VisionVO (com.netsteadfast.greenstep.vo.VisionVO)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Context (org.apache.commons.chain.Context)1 Cell (org.apache.poi.ss.usermodel.Cell)1 Row (org.apache.poi.ss.usermodel.Row)1 XSSFCellStyle (org.apache.poi.xssf.usermodel.XSSFCellStyle)1 XSSFColor (org.apache.poi.xssf.usermodel.XSSFColor)1 XSSFFont (org.apache.poi.xssf.usermodel.XSSFFont)1