Search in sources :

Example 1 with SimpleChain

use of com.netsteadfast.greenstep.base.chain.SimpleChain in project bamboobsc by billchen198318.

the class PeriodTrendsCalUtils method generateKpiPeriodTrendsExcel.

public static String generateKpiPeriodTrendsExcel(List<PeriodTrendsData<KpiVO>> periodDatas, String currentPeriodDateRange, String previousPeriodDateRange) throws Exception {
    Context context = new ContextBase();
    context.put("periodDatas", periodDatas);
    context.put("currentPeriodDateRange", currentPeriodDateRange);
    context.put("previousPeriodDateRange", previousPeriodDateRange);
    SimpleChain chain = new SimpleChain();
    ChainResultObj resultObj = chain.getResultFromResource("kpiPeriodTrendsExcelCommandExcelContentChain", context);
    if (!(resultObj.getValue() instanceof String)) {
        throw new java.lang.IllegalStateException("kpiPeriodTrendsExcelCommandExcelContentChain error!");
    }
    return (String) resultObj.getValue();
}
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 2 with SimpleChain

use of com.netsteadfast.greenstep.base.chain.SimpleChain in project bamboobsc by billchen198318.

the class TimeSeriesAnalysisUtils method getResultForExcel.

public static String getResultForExcel(String tsaOid, String visionOid, String startDate, String endDate, String startYearDate, String endYearDate, String frequency, String dataFor, String measureDataOrganizationOid, String measureDataEmployeeOid) throws ServiceException, Exception {
    Map<String, Object> dataMap = getResultWithVision(tsaOid, visionOid, startDate, endDate, startYearDate, endYearDate, frequency, dataFor, measureDataOrganizationOid, measureDataEmployeeOid);
    List<TimeSeriesAnalysisResult> tsaResults = (List<TimeSeriesAnalysisResult>) dataMap.get("result");
    VisionVO vision = (VisionVO) dataMap.get("vision");
    TsaVO tsa = getParam(tsaOid);
    List<BbTsaMaCoefficients> coefficients = getCoefficients(tsa);
    Context context = new ContextBase();
    context.put("tsaResults", tsaResults);
    context.put("tsa", tsa);
    context.put("coefficients", coefficients);
    // for show only.
    context.put("visionName", vision.getTitle());
    if (BscMeasureDataFrequency.FREQUENCY_YEAR.equals(frequency) || BscMeasureDataFrequency.FREQUENCY_HALF_OF_YEAR.equals(frequency) || BscMeasureDataFrequency.FREQUENCY_QUARTER.equals(frequency)) {
        context.put("date1", startYearDate);
        context.put("date2", endYearDate);
    } else {
        context.put("date1", startDate);
        context.put("date2", endDate);
    }
    context.put("frequencyName", BscMeasureDataFrequency.getFrequencyMap(false).get(frequency));
    context.put("dataFor", dataFor);
    context.put("organizationName", "");
    context.put("employeeName", "");
    if (!Constants.HTML_SELECT_NO_SELECT_ID.equals(measureDataOrganizationOid) && !StringUtils.isBlank(measureDataOrganizationOid)) {
        context.put("organizationName", BscBaseLogicServiceCommonSupport.findOrganizationData(organizationService, measureDataOrganizationOid).getName());
    }
    if (!Constants.HTML_SELECT_NO_SELECT_ID.equals(measureDataEmployeeOid) && !StringUtils.isBlank(measureDataEmployeeOid)) {
        context.put("employeeName", BscBaseLogicServiceCommonSupport.findEmployeeData(employeeService, measureDataEmployeeOid).getFullName());
    }
    SimpleChain chain = new SimpleChain();
    ChainResultObj resultObj = chain.getResultFromResource("timeSeriesAnalysisExcelCommandContentChain", context);
    if (!(resultObj.getValue() instanceof String)) {
        throw new java.lang.IllegalStateException("timeSeriesAnalysisExcelCommandContentChain error!");
    }
    return (String) resultObj.getValue();
}
Also used : AppContext(com.netsteadfast.greenstep.base.AppContext) Context(org.apache.commons.chain.Context) SimpleChain(com.netsteadfast.greenstep.base.chain.SimpleChain) VisionVO(com.netsteadfast.greenstep.vo.VisionVO) TsaVO(com.netsteadfast.greenstep.vo.TsaVO) BbTsaMaCoefficients(com.netsteadfast.greenstep.po.hbm.BbTsaMaCoefficients) TimeSeriesAnalysisResult(com.netsteadfast.greenstep.bsc.model.TimeSeriesAnalysisResult) ChainResultObj(com.netsteadfast.greenstep.base.model.ChainResultObj) ArrayList(java.util.ArrayList) List(java.util.List) ContextBase(org.apache.commons.chain.impl.ContextBase)

Example 3 with SimpleChain

use of com.netsteadfast.greenstep.base.chain.SimpleChain in project bamboobsc by billchen198318.

the class KpiReportContentQueryAction method getContent.

private void getContent() throws ControllerException, AuthorityException, ServiceException, Exception {
    this.checkFields();
    this.setDateValue();
    this.checkDateRange();
    Context context = this.getChainContext();
    SimpleChain chain = new SimpleChain();
    ChainResultObj resultObj = chain.getResultFromResource("kpiReportHtmlContentChain", context);
    this.body = String.valueOf(resultObj.getValue());
    this.message = resultObj.getMessage();
    if (!StringUtils.isBlank(this.body) && this.body.startsWith("<!-- BSC_PROG003D0001Q -->")) {
        this.success = IS_YES;
    }
    if (context.get("treeObj") == null) {
        return;
    }
    BscStructTreeObj treeObj = (BscStructTreeObj) context.get("treeObj");
    this.fillPerspectivesPieChartData(treeObj);
    this.fillPerspectivesBarChartData(treeObj);
    this.fillLineChartData(treeObj);
    if (YesNo.YES.equals(this.getFields().get("nobody"))) {
        // 不要有 HTML版本的輸出, 通常是給 dashboard 用的
        this.body = "";
    }
    // ------------------------------------------------------------------
    if (YesNo.YES.equals(this.getFields().get("saveResultJson")) && treeObj.getVisions() != null && treeObj.getVisions().size() == 1) {
        ObjectMapper objectMapper = new ObjectMapper();
        Map<String, Object> dataMap = new HashMap<String, Object>();
        dataMap.put("treeObjJsonStr", SimpleUtils.toB64(objectMapper.writeValueAsString(treeObj)));
        dataMap.put("resultObjJsonStr", SimpleUtils.toB64(objectMapper.writeValueAsString(resultObj)));
        String jsonData = objectMapper.writeValueAsString(dataMap);
        this.uploadOid = UploadSupportUtils.create(Constants.getSystem(), UploadTypes.IS_TEMP, false, jsonData.getBytes(), SimpleUtils.getUUIDStr() + ".json");
    }
// ------------------------------------------------------------------
}
Also used : Context(org.apache.commons.chain.Context) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) ChainResultObj(com.netsteadfast.greenstep.base.model.ChainResultObj) BscStructTreeObj(com.netsteadfast.greenstep.bsc.model.BscStructTreeObj) SimpleChain(com.netsteadfast.greenstep.base.chain.SimpleChain) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Example 4 with SimpleChain

use of com.netsteadfast.greenstep.base.chain.SimpleChain in project bamboobsc by billchen198318.

the class KpiReportContentQueryAction method getPdf.

private void getPdf() throws ControllerException, AuthorityException, ServiceException, Exception {
    this.checkFields();
    this.setDateValue();
    this.checkDateRange();
    Context context = this.getChainContext();
    SimpleChain chain = new SimpleChain();
    ChainResultObj resultObj = chain.getResultFromResource("kpiReportPdfContentChain", context);
    this.message = resultObj.getMessage();
    if (resultObj.getValue() instanceof String) {
        this.uploadOid = (String) resultObj.getValue();
        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)

Example 5 with SimpleChain

use of com.netsteadfast.greenstep.base.chain.SimpleChain in project bamboobsc by billchen198318.

the class DepartmentReportContentQueryAction method getExcel.

private void getExcel() throws ControllerException, AuthorityException, ServiceException, Exception {
    this.checkFields();
    Context context = this.getChainContext();
    SimpleChain chain = new SimpleChain();
    ChainResultObj resultObj = chain.getResultFromResource("organizationReportExcelContentChain", context);
    this.message = resultObj.getMessage();
    if (resultObj.getValue() instanceof String) {
        this.uploadOid = (String) resultObj.getValue();
        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

SimpleChain (com.netsteadfast.greenstep.base.chain.SimpleChain)29 ChainResultObj (com.netsteadfast.greenstep.base.model.ChainResultObj)28 Context (org.apache.commons.chain.Context)28 ContextBase (org.apache.commons.chain.impl.ContextBase)8 List (java.util.List)5 Map (java.util.Map)5 ArrayList (java.util.ArrayList)4 LinkedHashMap (java.util.LinkedHashMap)4 BscStructTreeObj (com.netsteadfast.greenstep.bsc.model.BscStructTreeObj)3 StrategyMapItemsVO (com.netsteadfast.greenstep.bsc.vo.StrategyMapItemsVO)3 LinkedList (java.util.LinkedList)3 AppContext (com.netsteadfast.greenstep.base.AppContext)2 ControllerException (com.netsteadfast.greenstep.base.exception.ControllerException)2 ServiceException (com.netsteadfast.greenstep.base.exception.ServiceException)2 VisionVO (com.netsteadfast.greenstep.vo.VisionVO)2 HashMap (java.util.HashMap)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 TimeSeriesAnalysisResult (com.netsteadfast.greenstep.bsc.model.TimeSeriesAnalysisResult)1 BbTsaMaCoefficients (com.netsteadfast.greenstep.po.hbm.BbTsaMaCoefficients)1 KpiVO (com.netsteadfast.greenstep.vo.KpiVO)1