Search in sources :

Example 41 with ObjectiveVO

use of com.netsteadfast.greenstep.vo.ObjectiveVO in project bamboobsc by billchen198318.

the class HistoryItemScoreReportContentQueryUtils method getLineChartData.

public static List<Map<String, Object>> getLineChartData(String itemType, String frequency, String dateVal, String orgId, String empId) throws ServiceException, Exception {
    List<Map<String, Object>> dataList = new ArrayList<Map<String, Object>>();
    Map<String, List<MonitorItemScoreVO>> itemScoreDataMap = monitorItemScoreService.getHistoryDataList(itemType, frequency, dateVal, orgId, empId);
    if (itemScoreDataMap == null || itemScoreDataMap.size() < 1) {
        return dataList;
    }
    List<VisionVO> basicDataList = getBasicDataList();
    for (Map.Entry<String, List<MonitorItemScoreVO>> entry : itemScoreDataMap.entrySet()) {
        String name = "";
        String id = entry.getKey();
        List<MonitorItemScoreVO> scoreList = entry.getValue();
        if (scoreList == null || scoreList.size() < 1) {
            continue;
        }
        if (MonitorItemType.VISION.equals(itemType)) {
            DefaultResult<VisionVO> visionResult = visionService.findForSimpleByVisId(id);
            if (visionResult.getValue() == null) {
                throw new ServiceException(visionResult.getSystemMessage().getValue());
            }
            VisionVO vision = visionResult.getValue();
            name = getItemNameWithVisionGroup(MonitorItemType.VISION, vision.getVisId(), vision.getTitle(), basicDataList);
        }
        if (MonitorItemType.PERSPECTIVES.equals(itemType)) {
            PerspectiveVO perspective = new PerspectiveVO();
            perspective.setPerId(id);
            DefaultResult<PerspectiveVO> perspectiveResult = perspectiveService.findByUK(perspective);
            if (perspectiveResult.getValue() == null) {
                throw new ServiceException(perspectiveResult.getSystemMessage().getValue());
            }
            perspective = perspectiveResult.getValue();
            name = getItemNameWithVisionGroup(MonitorItemType.PERSPECTIVES, perspective.getPerId(), perspective.getName(), basicDataList);
        }
        if (MonitorItemType.STRATEGY_OF_OBJECTIVES.equals(itemType)) {
            ObjectiveVO objective = new ObjectiveVO();
            objective.setObjId(id);
            DefaultResult<ObjectiveVO> objectiveResult = objectiveService.findByUK(objective);
            if (objectiveResult.getValue() == null) {
                throw new ServiceException(objectiveResult.getSystemMessage().getValue());
            }
            objective = objectiveResult.getValue();
            name = getItemNameWithVisionGroup(MonitorItemType.STRATEGY_OF_OBJECTIVES, objective.getObjId(), objective.getName(), basicDataList);
        }
        if (MonitorItemType.KPI.equals(itemType)) {
            KpiVO kpi = new KpiVO();
            kpi.setId(id);
            DefaultResult<KpiVO> kpiResult = kpiService.findByUK(kpi);
            if (kpiResult.getValue() == null) {
                throw new ServiceException(kpiResult.getSystemMessage().getValue());
            }
            kpi = kpiResult.getValue();
            name = getItemNameWithVisionGroup(MonitorItemType.KPI, kpi.getId(), kpi.getName(), basicDataList);
        }
        if (StringUtils.isBlank(name)) {
            throw new ServiceException("Name not found!");
        }
        Map<String, Object> chartDataMap = new HashMap<String, Object>();
        chartDataMap.put("name", name);
        chartDataMap.put("data", new LinkedList<Float>());
        for (MonitorItemScoreVO itemScore : scoreList) {
            ((List<Float>) chartDataMap.get("data")).add(Float.valueOf(itemScore.getScore()));
        }
        dataList.add(chartDataMap);
    }
    return dataList;
}
Also used : ObjectiveVO(com.netsteadfast.greenstep.vo.ObjectiveVO) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) KpiVO(com.netsteadfast.greenstep.vo.KpiVO) PerspectiveVO(com.netsteadfast.greenstep.vo.PerspectiveVO) VisionVO(com.netsteadfast.greenstep.vo.VisionVO) ServiceException(com.netsteadfast.greenstep.base.exception.ServiceException) ArrayList(java.util.ArrayList) LinkedList(java.util.LinkedList) List(java.util.List) HashMap(java.util.HashMap) Map(java.util.Map) MonitorItemScoreVO(com.netsteadfast.greenstep.vo.MonitorItemScoreVO)

Example 42 with ObjectiveVO

use of com.netsteadfast.greenstep.vo.ObjectiveVO in project bamboobsc by billchen198318.

the class BscMobileCardUtils method getVisionCardContent.

public static String getVisionCardContent(VisionVO vision, String frequencyName, String startDate, String endDate) throws ServiceException, Exception {
    String content = "";
    int perspectiveSize = vision.getPerspectives().size();
    int objectiveSize = 0;
    int kpiSize = 0;
    for (PerspectiveVO perspective : vision.getPerspectives()) {
        objectiveSize += perspective.getObjectives().size();
        List<ObjectiveVO> objectives = perspective.getObjectives();
        for (ObjectiveVO objective : objectives) {
            kpiSize += objective.getKpis().size();
        }
    }
    BscReportPropertyUtils.loadData();
    String uploadOid = getVisionCardUpload(vision);
    Map<String, Object> paramMap = new HashMap<String, Object>();
    paramMap.put("perspectiveTitle", BscReportPropertyUtils.getPerspectiveTitle());
    paramMap.put("objectiveTitle", BscReportPropertyUtils.getObjectiveTitle());
    paramMap.put("kpiTitle", BscReportPropertyUtils.getKpiTitle());
    paramMap.put("backgroundColor", BscReportPropertyUtils.getBackgroundColor());
    paramMap.put("fontColor", BscReportPropertyUtils.getFontColor());
    paramMap.put("vision", vision);
    paramMap.put("visionContent", new String(vision.getContent(), Constants.BASE_ENCODING));
    paramMap.put("perspectiveSize", perspectiveSize);
    paramMap.put("objectiveSize", objectiveSize);
    paramMap.put("kpiSize", kpiSize);
    paramMap.put("percentage", getPercentage(vision.getScore(), 100f));
    paramMap.put("uploadOid", uploadOid);
    paramMap.put("frequencyName", frequencyName);
    paramMap.put("startDate", startDate);
    paramMap.put("endDate", endDate);
    content = TemplateUtils.processTemplate("resourceTemplate", BscMobileCardUtils.class.getClassLoader(), _RESOURCE_VISION_CARD, paramMap);
    return content;
}
Also used : ObjectiveVO(com.netsteadfast.greenstep.vo.ObjectiveVO) HashMap(java.util.HashMap) PerspectiveVO(com.netsteadfast.greenstep.vo.PerspectiveVO)

Example 43 with ObjectiveVO

use of com.netsteadfast.greenstep.vo.ObjectiveVO in project bamboobsc by billchen198318.

the class ApiWebServiceImpl method processForScorecard.

private void processForScorecard(BscApiServiceResponse responseObj, HttpServletRequest request, String visionOid, String startDate, String endDate, String startYearDate, String endYearDate, String frequency, String dataFor, String measureDataOrganizationOid, String measureDataEmployeeOid, String contentFlag) throws ServiceException, Exception {
    org.apache.commons.chain.Context context = PerformanceScoreChainUtils.getContext(visionOid, startDate, endDate, startYearDate, endYearDate, frequency, dataFor, measureDataOrganizationOid, measureDataEmployeeOid);
    ChainResultObj result = PerformanceScoreChainUtils.getResult(context);
    if (result.getValue() == null || ((BscStructTreeObj) result.getValue()).getVisions() == null || ((BscStructTreeObj) result.getValue()).getVisions().size() == 0) {
        return;
    }
    // 給 Meter Chart 用的
    String meterChartBaseUrl = "";
    // 給 BAR Chart 用的
    String barChartBaseUrl = "";
    // 給 PIE Chart 用的
    String pieChartBaseUrl = "";
    // 給 HTML 報表用的
    String url = "";
    if (request != null) {
        url = ApplicationSiteUtils.getBasePath(Constants.getSystem(), request);
    } else {
        url = HostUtils.getHostAddress() + ":" + HostUtils.getHttpPort() + "/" + ApplicationSiteUtils.getContextPath(Constants.getSystem());
    }
    if (!url.endsWith("/")) {
        url += "/";
    }
    meterChartBaseUrl = url + "bsc.commonMeterChartAction.action";
    barChartBaseUrl = url + "bsc.commonBarChartAction.action";
    pieChartBaseUrl = url + "bsc.commonPieChartAction.action";
    BscStructTreeObj resultObj = (BscStructTreeObj) result.getValue();
    KpiReportBodyCommand reportBody = new KpiReportBodyCommand();
    reportBody.execute(context);
    Object htmlBody = reportBody.getResult(context);
    if (htmlBody != null && htmlBody instanceof String) {
        String htmlUploadOid = UploadSupportUtils.create(Constants.getSystem(), UploadTypes.IS_TEMP, false, String.valueOf(htmlBody).getBytes(), "KPI-HTML-REPORT.html");
        url += "bsc.printContentAction.action?oid=" + htmlUploadOid;
        responseObj.setHtmlBodyUrl(url);
    }
    VisionVO visionObj = resultObj.getVisions().get(0);
    // 產生 Meter Chart 資料
    for (PerspectiveVO perspective : visionObj.getPerspectives()) {
        String perspectiveMeterChartOid = JFreeChartDataMapperUtils.createMeterData(perspective.getName(), perspective.getScore(), this.getMeterChartLowerBound(perspective.getScore(), perspective.getMin()), this.getMeterChartUpperBound(perspective.getScore(), perspective.getTarget()), MeterChart_width, MeterChart_height);
        responseObj.getPerspectivesMeterChartUrl().add(meterChartBaseUrl + "?oid=" + perspectiveMeterChartOid);
        for (ObjectiveVO objective : perspective.getObjectives()) {
            String objectiveMeterChartOid = JFreeChartDataMapperUtils.createMeterData(objective.getName(), (int) objective.getScore(), this.getMeterChartLowerBound(objective.getScore(), objective.getMin()), this.getMeterChartUpperBound(objective.getScore(), objective.getTarget()), MeterChart_width, MeterChart_height);
            responseObj.getObjectivesMeterChartUrl().add(meterChartBaseUrl + "?oid=" + objectiveMeterChartOid);
            for (KpiVO kpi : objective.getKpis()) {
                String kpiMeterChartOid = JFreeChartDataMapperUtils.createMeterData(kpi.getName(), kpi.getScore(), this.getMeterChartLowerBound(kpi.getScore(), kpi.getMin()), this.getMeterChartUpperBound(kpi.getScore(), kpi.getTarget()), MeterChart_width, MeterChart_height);
                responseObj.getKpisMeterChartUrl().add(meterChartBaseUrl + "?oid=" + kpiMeterChartOid);
            }
        }
    }
    // 產生 Perspectives Bar/Pie chart
    String barUploadOid = "";
    String pieUploadOid = "";
    List<String> names = new LinkedList<String>();
    List<Float> values = new LinkedList<Float>();
    List<String> colors = new LinkedList<String>();
    for (PerspectiveVO perspective : visionObj.getPerspectives()) {
        names.add(perspective.getName() + "(" + BscReportSupportUtils.parse2(perspective.getScore()) + ")");
        values.add(perspective.getScore());
        colors.add(perspective.getBgColor());
    }
    barUploadOid = JFreeChartDataMapperUtils.createBarData(visionObj.getTitle(), "Score", "", names, values, colors, 480, 280, false);
    pieUploadOid = JFreeChartDataMapperUtils.createPieData(visionObj.getTitle(), names, values, colors, 480, 280);
    responseObj.setPieChartUrl(pieChartBaseUrl + "?oid=" + pieUploadOid);
    responseObj.setBarChartUrl(barChartBaseUrl + "?oid=" + barUploadOid);
    PerformanceScoreChainUtils.clearExpressionContentOut(visionObj);
    responseObj.setSuccess(YesNo.YES);
    if (YesNo.YES.equals(contentFlag)) {
        ObjectMapper objectMapper = new ObjectMapper();
        String jsonData = objectMapper.writeValueAsString(visionObj);
        XStream xstream = new XStream();
        xstream.setMode(XStream.NO_REFERENCES);
        xstream.alias("vision", VisionVO.class);
        xstream.alias("perspective", PerspectiveVO.class);
        xstream.alias("objective", ObjectiveVO.class);
        xstream.alias("kpi", KpiVO.class);
        xstream.alias("measureData", BbMeasureData.class);
        xstream.alias("dateRangeScore", DateRangeScoreVO.class);
        xstream.alias("employee", EmployeeVO.class);
        xstream.alias("organization", OrganizationVO.class);
        String xmlData = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + xstream.toXML(visionObj);
        responseObj.setOutJsonData(jsonData);
        responseObj.setOutXmlData(xmlData);
    }
}
Also used : ObjectiveVO(com.netsteadfast.greenstep.vo.ObjectiveVO) XStream(com.thoughtworks.xstream.XStream) KpiReportBodyCommand(com.netsteadfast.greenstep.bsc.command.KpiReportBodyCommand) KpiVO(com.netsteadfast.greenstep.vo.KpiVO) PerspectiveVO(com.netsteadfast.greenstep.vo.PerspectiveVO) VisionVO(com.netsteadfast.greenstep.vo.VisionVO) LinkedList(java.util.LinkedList) ChainResultObj(com.netsteadfast.greenstep.base.model.ChainResultObj) BscStructTreeObj(com.netsteadfast.greenstep.bsc.model.BscStructTreeObj) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Example 44 with ObjectiveVO

use of com.netsteadfast.greenstep.vo.ObjectiveVO 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)

Example 45 with ObjectiveVO

use of com.netsteadfast.greenstep.vo.ObjectiveVO in project bamboobsc by billchen198318.

the class TimeSeriesAnalysisUtils method getResultWithVision.

public static Map<String, Object> getResultWithVision(String tsaOid, String visionOid, String startDate, String endDate, String startYearDate, String endYearDate, String frequency, String dataFor, String measureDataOrganizationOid, String measureDataEmployeeOid) throws ServiceException, Exception {
    List<TimeSeriesAnalysisResult> results = new ArrayList<TimeSeriesAnalysisResult>();
    ChainResultObj chainResult = PerformanceScoreChainUtils.getResult(visionOid, startDate, endDate, startYearDate, endYearDate, frequency, dataFor, measureDataOrganizationOid, measureDataEmployeeOid);
    if (chainResult.getValue() == null || ((BscStructTreeObj) chainResult.getValue()).getVisions() == null || ((BscStructTreeObj) chainResult.getValue()).getVisions().size() == 0) {
        throw new ServiceException(SysMessageUtil.get(GreenStepSysMsgConstants.SEARCH_NO_DATA));
    }
    TsaVO tsa = getParam(tsaOid);
    BscStructTreeObj resultObj = (BscStructTreeObj) chainResult.getValue();
    VisionVO visionObj = resultObj.getVisions().get(0);
    for (PerspectiveVO perspective : visionObj.getPerspectives()) {
        for (ObjectiveVO objective : perspective.getObjectives()) {
            for (KpiVO kpi : objective.getKpis()) {
                double[] observations = new double[kpi.getDateRangeScores().size()];
                for (int i = 0; i < observations.length; i++) {
                    observations[i] = Double.parseDouble(Float.toString(kpi.getDateRangeScores().get(i).getScore()));
                }
                double[] forecastNext = getForecastNext(tsa, observations);
                TimeSeriesAnalysisResult tsaModel = new TimeSeriesAnalysisResult(kpi, forecastNext);
                results.add(tsaModel);
            }
        }
    }
    Map<String, Object> dataMap = new HashMap<String, Object>();
    dataMap.put("vision", visionObj);
    dataMap.put("result", results);
    return dataMap;
}
Also used : ObjectiveVO(com.netsteadfast.greenstep.vo.ObjectiveVO) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) KpiVO(com.netsteadfast.greenstep.vo.KpiVO) PerspectiveVO(com.netsteadfast.greenstep.vo.PerspectiveVO) VisionVO(com.netsteadfast.greenstep.vo.VisionVO) TsaVO(com.netsteadfast.greenstep.vo.TsaVO) TimeSeriesAnalysisResult(com.netsteadfast.greenstep.bsc.model.TimeSeriesAnalysisResult) ServiceException(com.netsteadfast.greenstep.base.exception.ServiceException) ChainResultObj(com.netsteadfast.greenstep.base.model.ChainResultObj) BscStructTreeObj(com.netsteadfast.greenstep.bsc.model.BscStructTreeObj)

Aggregations

ObjectiveVO (com.netsteadfast.greenstep.vo.ObjectiveVO)50 PerspectiveVO (com.netsteadfast.greenstep.vo.PerspectiveVO)44 KpiVO (com.netsteadfast.greenstep.vo.KpiVO)34 VisionVO (com.netsteadfast.greenstep.vo.VisionVO)29 HashMap (java.util.HashMap)15 ServiceException (com.netsteadfast.greenstep.base.exception.ServiceException)13 BscStructTreeObj (com.netsteadfast.greenstep.bsc.model.BscStructTreeObj)8 DateRangeScoreVO (com.netsteadfast.greenstep.vo.DateRangeScoreVO)8 ArrayList (java.util.ArrayList)7 Map (java.util.Map)7 LinkedList (java.util.LinkedList)6 Phrase (com.itextpdf.text.Phrase)4 PdfPCell (com.itextpdf.text.pdf.PdfPCell)4 ChainResultObj (com.netsteadfast.greenstep.base.model.ChainResultObj)4 ServiceMethodAuthority (com.netsteadfast.greenstep.base.model.ServiceMethodAuthority)4 Cell (org.apache.poi.ss.usermodel.Cell)4 Row (org.apache.poi.ss.usermodel.Row)4 CellRangeAddress (org.apache.poi.ss.util.CellRangeAddress)4 XSSFCellStyle (org.apache.poi.xssf.usermodel.XSSFCellStyle)4 XSSFColor (org.apache.poi.xssf.usermodel.XSSFColor)4