Search in sources :

Example 21 with VisionVO

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

the class StrategyMapLogicServiceImpl method delete.

@ServiceMethodAuthority(type = { ServiceMethodType.DELETE })
@Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = { RuntimeException.class, IOException.class, Exception.class })
@Override
public DefaultResult<Boolean> delete(String visionOid) throws ServiceException, Exception {
    if (super.isBlank(visionOid) || super.isNoSelectId(visionOid)) {
        throw new ServiceException(SysMessageUtil.get(GreenStepSysMsgConstants.PARAMS_BLANK));
    }
    DefaultResult<Boolean> result = new DefaultResult<Boolean>();
    result.setValue(Boolean.TRUE);
    result.setSystemMessage(new SystemMessage(SysMessageUtil.get(GreenStepSysMsgConstants.DELETE_SUCCESS)));
    VisionVO vision = new VisionVO();
    vision.setOid(visionOid);
    DefaultResult<VisionVO> vResult = this.visionService.findObjectByOid(vision);
    if (vResult.getValue() == null) {
        // 沒 TB_VISION 資料, 不用清 STRATEGY MAP 			
        return result;
    }
    vision = vResult.getValue();
    StrategyMapVO strategyMap = new StrategyMapVO();
    strategyMap.setVisId(vision.getVisId());
    DefaultResult<StrategyMapVO> smResult = this.strategyMapService.findByUK(strategyMap);
    if (smResult.getValue() == null) {
        // 沒有 BB_STRATEGY_MAP 資料
        return result;
    }
    strategyMap = smResult.getValue();
    Map<String, Object> params = new HashMap<String, Object>();
    params.put("masterOid", strategyMap.getOid());
    List<BbStrategyMapNodes> nodes = this.strategyMapNodesService.findListByParams(params);
    List<BbStrategyMapConns> conns = this.strategyMapConnsService.findListByParams(params);
    for (int i = 0; nodes != null && i < nodes.size(); i++) {
        strategyMapNodesService.delete(nodes.get(i));
    }
    for (int i = 0; conns != null && i < conns.size(); i++) {
        strategyMapConnsService.delete(conns.get(i));
    }
    return strategyMapService.deleteObject(strategyMap);
}
Also used : SystemMessage(com.netsteadfast.greenstep.base.model.SystemMessage) BbStrategyMapConns(com.netsteadfast.greenstep.po.hbm.BbStrategyMapConns) HashMap(java.util.HashMap) StrategyMapVO(com.netsteadfast.greenstep.vo.StrategyMapVO) VisionVO(com.netsteadfast.greenstep.vo.VisionVO) ServiceException(com.netsteadfast.greenstep.base.exception.ServiceException) DefaultResult(com.netsteadfast.greenstep.base.model.DefaultResult) BbStrategyMapNodes(com.netsteadfast.greenstep.po.hbm.BbStrategyMapNodes) ServiceMethodAuthority(com.netsteadfast.greenstep.base.model.ServiceMethodAuthority) Transactional(org.springframework.transaction.annotation.Transactional)

Example 22 with VisionVO

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

the class BscMobileCardUtils method getVisionCardFromUpload.

public static VisionVO getVisionCardFromUpload(String uploadOid) throws ServiceException, Exception {
    byte[] content = UploadSupportUtils.getDataBytes(uploadOid);
    String jsonStr = new String(content, Constants.BASE_ENCODING);
    if (StringUtils.isBlank(jsonStr)) {
        throw new Exception("vision-card json data error.");
    }
    VisionVO vision = new ObjectMapper().readValue(jsonStr, VisionVO.class);
    return vision;
}
Also used : VisionVO(com.netsteadfast.greenstep.vo.VisionVO) ServiceException(com.netsteadfast.greenstep.base.exception.ServiceException) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Example 23 with VisionVO

use of com.netsteadfast.greenstep.vo.VisionVO 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 24 with VisionVO

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

Example 25 with VisionVO

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

the class HistoryItemScoreReportContentQueryUtils method getBasicDataList.

private static List<VisionVO> getBasicDataList() throws ServiceException, Exception {
    List<VisionVO> visions = new LinkedList<VisionVO>();
    List<VisionVO> visionsTempList = new ArrayList<VisionVO>();
    Map<String, String> visionMap = visionService.findForMap(false);
    for (Map.Entry<String, String> visionEntry : visionMap.entrySet()) {
        DefaultResult<VisionVO> visionResult = visionService.findForSimple(visionEntry.getKey());
        if (visionResult.getValue() == null) {
            throw new ServiceException(visionResult.getSystemMessage().getValue());
        }
        VisionVO vision = visionResult.getValue();
        visionsTempList.add(vision);
    }
    Map<String, Object> paramMap = new HashMap<String, Object>();
    for (VisionVO vision : visionsTempList) {
        paramMap.clear();
        paramMap.put("visId", vision.getVisId());
        List<PerspectiveVO> perspectivesList = perspectiveService.findListVOByParams(paramMap);
        for (int p = 0; perspectivesList != null && p < perspectivesList.size(); p++) {
            PerspectiveVO perspective = perspectivesList.get(p);
            vision.getPerspectives().add(perspective);
            paramMap.clear();
            paramMap.put("perId", perspective.getPerId());
            List<ObjectiveVO> objectivesList = objectiveService.findListVOByParams(paramMap);
            for (int o = 0; objectivesList != null && o < objectivesList.size(); o++) {
                ObjectiveVO objective = objectivesList.get(o);
                perspective.getObjectives().add(objective);
                paramMap.clear();
                paramMap.put("objId", objective.getObjId());
                List<KpiVO> kpiList = kpiService.findListVOByParams(paramMap);
                if (kpiList != null && kpiList.size() > 0) {
                    objective.getKpis().addAll(kpiList);
                }
            }
        }
    }
    // 必須有 KPI 才能放到回傳的 visions
    for (int v = 0; v < visionsTempList.size(); v++) {
        boolean isFoundData = true;
        VisionVO vision = visionsTempList.get(v);
        for (int p = 0; p < vision.getPerspectives().size() && isFoundData; p++) {
            PerspectiveVO perspective = vision.getPerspectives().get(p);
            for (int o = 0; o < perspective.getObjectives().size() && isFoundData; o++) {
                ObjectiveVO objective = perspective.getObjectives().get(o);
                if (objective.getKpis() == null || objective.getKpis().size() < 1) {
                    isFoundData = false;
                }
            }
        }
        if (isFoundData) {
            visions.add(vision);
        }
    }
    return visions;
}
Also used : HashMap(java.util.HashMap) ObjectiveVO(com.netsteadfast.greenstep.vo.ObjectiveVO) ArrayList(java.util.ArrayList) KpiVO(com.netsteadfast.greenstep.vo.KpiVO) PerspectiveVO(com.netsteadfast.greenstep.vo.PerspectiveVO) VisionVO(com.netsteadfast.greenstep.vo.VisionVO) LinkedList(java.util.LinkedList) ServiceException(com.netsteadfast.greenstep.base.exception.ServiceException) HashMap(java.util.HashMap) Map(java.util.Map)

Aggregations

VisionVO (com.netsteadfast.greenstep.vo.VisionVO)66 PerspectiveVO (com.netsteadfast.greenstep.vo.PerspectiveVO)38 ObjectiveVO (com.netsteadfast.greenstep.vo.ObjectiveVO)29 KpiVO (com.netsteadfast.greenstep.vo.KpiVO)22 ServiceException (com.netsteadfast.greenstep.base.exception.ServiceException)21 BscStructTreeObj (com.netsteadfast.greenstep.bsc.model.BscStructTreeObj)17 HashMap (java.util.HashMap)16 Map (java.util.Map)8 DefaultResult (com.netsteadfast.greenstep.base.model.DefaultResult)7 ServiceMethodAuthority (com.netsteadfast.greenstep.base.model.ServiceMethodAuthority)7 SystemMessage (com.netsteadfast.greenstep.base.model.SystemMessage)7 ArrayList (java.util.ArrayList)7 LinkedList (java.util.LinkedList)7 Transactional (org.springframework.transaction.annotation.Transactional)7 ChainResultObj (com.netsteadfast.greenstep.base.model.ChainResultObj)6 File (java.io.File)6 FileOutputStream (java.io.FileOutputStream)6 BscMixDataVO (com.netsteadfast.greenstep.bsc.vo.BscMixDataVO)4 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)3 Document (com.itextpdf.text.Document)3