Search in sources :

Example 16 with ChainResultObj

use of com.netsteadfast.greenstep.base.model.ChainResultObj in project bamboobsc by billchen198318.

the class WeightContentQueryAction method renderBody.

@SuppressWarnings("unchecked")
private void renderBody() throws ControllerException, ServiceException, Exception {
    this.getCheckFieldHandler().single("visionOid", (super.isNoSelectId(this.getFields().get("visionOid"))), this.getText("MESSAGE.BSC_PROG002D0006Q_visionOid")).throwMessage();
    SimpleChain simpleChanin = new SimpleChain();
    Context context = new ContextBase();
    context.put("visionOid", this.getFields().get("visionOid"));
    if (YesNo.YES.equals(this.getFields().get("autoAllocation"))) {
        context.put("autoAllocation", this.getFields().get("autoAllocation"));
    }
    context.put("weightName", this.getText("TPL.BSC_PROG002D0006Q_weightName"));
    ChainResultObj resultObj = simpleChanin.getResultFromResource("weightItemsChain", context);
    this.body = String.valueOf(resultObj.getValue());
    this.message = resultObj.getMessage();
    this.success = IS_YES;
}
Also used : Context(org.apache.commons.chain.Context) ChainResultObj(com.netsteadfast.greenstep.base.model.ChainResultObj) SimpleChain(com.netsteadfast.greenstep.base.chain.SimpleChain) ContextBase(org.apache.commons.chain.impl.ContextBase)

Example 17 with ChainResultObj

use of com.netsteadfast.greenstep.base.model.ChainResultObj 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 18 with ChainResultObj

use of com.netsteadfast.greenstep.base.model.ChainResultObj in project bamboobsc by billchen198318.

the class KpiReportContentQueryAction method getCoffeeChartJsonData.

private void getCoffeeChartJsonData() throws ControllerException, AuthorityException, ServiceException, Exception {
    this.checkFields();
    this.setDateValue();
    this.checkDateRange();
    Context context = this.getChainContext();
    SimpleChain chain = new SimpleChain();
    ChainResultObj resultObj = chain.getResultFromResource("kpiReportCoffeeChartJsonDataContentChain", context);
    this.message = resultObj.getMessage();
    if (resultObj.getValue() instanceof String) {
        this.body = String.valueOf(resultObj.getValue());
        this.inputStream = new ByteArrayInputStream(this.body.getBytes(Constants.BASE_ENCODING));
        this.success = IS_YES;
    }
}
Also used : Context(org.apache.commons.chain.Context) ByteArrayInputStream(java.io.ByteArrayInputStream) ChainResultObj(com.netsteadfast.greenstep.base.model.ChainResultObj) SimpleChain(com.netsteadfast.greenstep.base.chain.SimpleChain)

Example 19 with ChainResultObj

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

Example 20 with ChainResultObj

use of com.netsteadfast.greenstep.base.model.ChainResultObj in project bamboobsc by billchen198318.

the class DepartmentReportContentQueryAction method getContent.

private void getContent() throws ControllerException, AuthorityException, ServiceException, Exception {
    this.checkFields();
    Context context = this.getChainContext();
    SimpleChain chain = new SimpleChain();
    ChainResultObj resultObj = chain.getResultFromResource("organizationReportHtmlContentChain", context);
    this.body = String.valueOf(resultObj.getValue());
    this.message = resultObj.getMessage();
    if (!StringUtils.isBlank(this.body) && this.body.startsWith("<!-- BSC_PROG003D0003Q -->")) {
        this.success = IS_YES;
    }
}
Also used : Context(org.apache.commons.chain.Context) ChainResultObj(com.netsteadfast.greenstep.base.model.ChainResultObj) SimpleChain(com.netsteadfast.greenstep.base.chain.SimpleChain)

Aggregations

ChainResultObj (com.netsteadfast.greenstep.base.model.ChainResultObj)34 SimpleChain (com.netsteadfast.greenstep.base.chain.SimpleChain)28 Context (org.apache.commons.chain.Context)27 ContextBase (org.apache.commons.chain.impl.ContextBase)8 BscStructTreeObj (com.netsteadfast.greenstep.bsc.model.BscStructTreeObj)7 VisionVO (com.netsteadfast.greenstep.vo.VisionVO)6 ServiceException (com.netsteadfast.greenstep.base.exception.ServiceException)5 ArrayList (java.util.ArrayList)5 List (java.util.List)5 Map (java.util.Map)5 KpiVO (com.netsteadfast.greenstep.vo.KpiVO)4 ObjectiveVO (com.netsteadfast.greenstep.vo.ObjectiveVO)4 PerspectiveVO (com.netsteadfast.greenstep.vo.PerspectiveVO)4 LinkedHashMap (java.util.LinkedHashMap)4 LinkedList (java.util.LinkedList)4 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)3 ControllerException (com.netsteadfast.greenstep.base.exception.ControllerException)3 StrategyMapItemsVO (com.netsteadfast.greenstep.bsc.vo.StrategyMapItemsVO)3 HashMap (java.util.HashMap)3 AppContext (com.netsteadfast.greenstep.base.AppContext)2