Search in sources :

Example 11 with ChainResultObj

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

the class PdcaReportContentQueryAction method getBscReportContent.

private List<ChainResultObj> getBscReportContent(String chainId) throws ControllerException, AuthorityException, ServiceException, Exception {
    List<ChainResultObj> results = new ArrayList<ChainResultObj>();
    String pdcaOid = this.getFields().get("pdcaOid");
    // 先找出 bb_pdca_kpis 的最上層 vision
    List<String> visionOids = this.visionService.findForOidByPdcaOid(pdcaOid);
    for (String visionOid : visionOids) {
        PdcaMeasureFreqVO measureFreq = new PdcaMeasureFreqVO();
        measureFreq.setPdcaOid(pdcaOid);
        DefaultResult<PdcaMeasureFreqVO> mfResult = this.pdcaMeasureFreqService.findByUK(measureFreq);
        if (mfResult.getValue() == null) {
            throw new ServiceException(mfResult.getSystemMessage().getValue());
        }
        measureFreq = mfResult.getValue();
        Context context = this.getBscReportChainContext(pdcaOid, visionOid, measureFreq);
        SimpleChain chain = new SimpleChain();
        ChainResultObj resultObj = chain.getResultFromResource(chainId, context);
        results.add(resultObj);
    }
    return results;
}
Also used : Context(org.apache.commons.chain.Context) ServiceException(com.netsteadfast.greenstep.base.exception.ServiceException) ChainResultObj(com.netsteadfast.greenstep.base.model.ChainResultObj) ArrayList(java.util.ArrayList) SimpleChain(com.netsteadfast.greenstep.base.chain.SimpleChain) PdcaMeasureFreqVO(com.netsteadfast.greenstep.vo.PdcaMeasureFreqVO)

Example 12 with ChainResultObj

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

the class PersonalReportContentQueryAction method getContent.

private void getContent() throws ControllerException, AuthorityException, ServiceException, Exception {
    this.checkFields();
    Context context = this.getChainContext();
    SimpleChain chain = new SimpleChain();
    ChainResultObj resultObj = chain.getResultFromResource("personalReportHtmlContentChain", context);
    this.body = String.valueOf(resultObj.getValue());
    this.message = resultObj.getMessage();
    if (!StringUtils.isBlank(this.body) && this.body.startsWith("<!-- BSC_PROG003D0002Q -->")) {
        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 13 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 14 with ChainResultObj

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

the class BscMobileCardUtils method getVisionCard.

public static List<VisionVO> getVisionCard(String frequency, String startDate, String endDate) throws ServiceException, Exception {
    List<VisionVO> visionScores = new ArrayList<VisionVO>();
    Map<String, String> visions = visionService.findForMap(false);
    if (null == visions || visions.size() < 1) {
        return visionScores;
    }
    Context context = new ContextBase();
    context.put("startDate", startDate);
    context.put("endDate", endDate);
    context.put("startYearDate", startDate.substring(0, 4));
    context.put("endYearDate", endDate.substring(0, 4));
    context.put("frequency", frequency);
    context.put("dataFor", BscConstants.MEASURE_DATA_FOR_ALL);
    context.put("orgId", BscConstants.MEASURE_DATA_ORGANIZATION_FULL);
    context.put("empId", BscConstants.MEASURE_DATA_EMPLOYEE_FULL);
    for (Map.Entry<String, String> entry : visions.entrySet()) {
        String visionOid = entry.getKey();
        context.put("visionOid", visionOid);
        SimpleChain chain = new SimpleChain();
        ChainResultObj resultObj = chain.getResultFromResource("performanceScoreChain", context);
        BscStructTreeObj treeObj = (BscStructTreeObj) resultObj.getValue();
        for (int i = 0; treeObj.getVisions() != null && i < treeObj.getVisions().size(); i++) {
            VisionVO vision = treeObj.getVisions().get(i);
            vision.setContent(" ".getBytes());
            DefaultResult<VisionVO> vResult = visionService.findObjectByOid(vision);
            if (vResult.getValue() != null) {
                // 計算分數chain 取出的vision資料沒有放 content 欄位, 但這邊要用到, 所以取出content欄位
                vision.setContent(new String(vResult.getValue().getContent(), Constants.BASE_ENCODING).getBytes());
            }
            for (PerspectiveVO perspective : vision.getPerspectives()) {
                for (ObjectiveVO objective : perspective.getObjectives()) {
                    for (KpiVO kpi : objective.getKpis()) {
                        // 產生報表不需要以下欄位
                        kpi.getAggregationMethod().setDescription(" ");
                        kpi.getAggregationMethod().setExpression1(" ");
                        kpi.getAggregationMethod().setExpression2(" ");
                        kpi.getFormula().setExpression(" ");
                    }
                }
            }
            visionScores.add(vision);
        }
    }
    return visionScores;
}
Also used : AppContext(com.netsteadfast.greenstep.base.AppContext) Context(org.apache.commons.chain.Context) ObjectiveVO(com.netsteadfast.greenstep.vo.ObjectiveVO) ArrayList(java.util.ArrayList) SimpleChain(com.netsteadfast.greenstep.base.chain.SimpleChain) KpiVO(com.netsteadfast.greenstep.vo.KpiVO) PerspectiveVO(com.netsteadfast.greenstep.vo.PerspectiveVO) VisionVO(com.netsteadfast.greenstep.vo.VisionVO) ChainResultObj(com.netsteadfast.greenstep.base.model.ChainResultObj) BscStructTreeObj(com.netsteadfast.greenstep.bsc.model.BscStructTreeObj) HashMap(java.util.HashMap) Map(java.util.Map) ContextBase(org.apache.commons.chain.impl.ContextBase)

Example 15 with ChainResultObj

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

the class BscMobileCardUtils method getDashboardScore.

public static VisionVO getDashboardScore(String visionOid, String frequency, String startDate, String endDate) throws ServiceException, Exception {
    String startYear = "";
    String endYear = "";
    if (BscMeasureDataFrequency.FREQUENCY_YEAR.equals(frequency) || BscMeasureDataFrequency.FREQUENCY_HALF_OF_YEAR.equals(frequency) || BscMeasureDataFrequency.FREQUENCY_QUARTER.equals(frequency)) {
        startYear = startDate.substring(0, 4);
        endYear = endDate.substring(0, 4);
    }
    ChainResultObj result = PerformanceScoreChainUtils.getResult(visionOid, startDate, endDate, startYear, endYear, frequency, BscConstants.MEASURE_DATA_FOR_ALL, "", "");
    if (result.getValue() == null || ((BscStructTreeObj) result.getValue()).getVisions() == null || ((BscStructTreeObj) result.getValue()).getVisions().size() == 0) {
        throw new ServiceException(SysMessageUtil.get(GreenStepSysMsgConstants.SEARCH_NO_DATA));
    }
    BscStructTreeObj resultObj = (BscStructTreeObj) result.getValue();
    VisionVO visionObj = resultObj.getVisions().get(0);
    return visionObj;
}
Also used : ServiceException(com.netsteadfast.greenstep.base.exception.ServiceException) ChainResultObj(com.netsteadfast.greenstep.base.model.ChainResultObj) BscStructTreeObj(com.netsteadfast.greenstep.bsc.model.BscStructTreeObj) VisionVO(com.netsteadfast.greenstep.vo.VisionVO)

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