Search in sources :

Example 1 with StrategyMapVO

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

the class LoadStrategyMapItemsForRecCommand method fillStrategyMapItems.

private StrategyMapItemsVO fillStrategyMapItems(VisionVO vision, Context context) throws ServiceException, Exception {
    StrategyMapItemsVO mapItems = new StrategyMapItemsVO();
    int w = 190;
    StrategyMapVO map = new StrategyMapVO();
    map.setVisId(vision.getVisId());
    DefaultResult<StrategyMapVO> smResult = this.strategyMapService.findByUK(map);
    if (smResult.getValue() == null) {
        this.setMessage(context, smResult.getSystemMessage().getValue());
        return mapItems;
    }
    map = smResult.getValue();
    Map<String, Object> params = new HashMap<String, Object>();
    params.put("masterOid", map.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++) {
        BbStrategyMapNodes node = nodes.get(i);
        String div = "<div class=\"w\" id=\"" + node.getId() + "\">" + node.getText() + "<div class=\"ep\"></div></div>";
        String css = "#" + node.getId() + " { left:" + node.getPositionX() + "px; top:" + node.getPositionY() + "px; width:" + w + "px; }";
        mapItems.getDiv().add(div);
        mapItems.getCss().add(css);
    }
    for (int i = 0; conns != null && i < conns.size(); i++) {
        BbStrategyMapConns conn = conns.get(i);
        mapItems.getCon().add("{ source:\"" + conn.getSourceId() + "\", target:\"" + conn.getTargetId() + "\" }");
    }
    return mapItems;
}
Also used : BbStrategyMapConns(com.netsteadfast.greenstep.po.hbm.BbStrategyMapConns) StrategyMapItemsVO(com.netsteadfast.greenstep.bsc.vo.StrategyMapItemsVO) HashMap(java.util.HashMap) StrategyMapVO(com.netsteadfast.greenstep.vo.StrategyMapVO) BbStrategyMapNodes(com.netsteadfast.greenstep.po.hbm.BbStrategyMapNodes)

Example 2 with StrategyMapVO

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

the class StrategyMapLogicServiceImpl method create.

@ServiceMethodAuthority(type = { ServiceMethodType.INSERT, ServiceMethodType.UPDATE })
@Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = { RuntimeException.class, IOException.class, Exception.class })
@Override
public DefaultResult<Boolean> create(String visionOid, Map<String, Object> jsonData) throws ServiceException, Exception {
    this.delete(visionOid);
    VisionVO vision = new VisionVO();
    vision.setOid(visionOid);
    DefaultResult<VisionVO> vResult = this.visionService.findObjectByOid(vision);
    if (vResult.getValue() == null) {
        // 沒 TB_VISION 資料, 不用清 STRATEGY MAP 			
        throw new ServiceException(vResult.getSystemMessage().getValue());
    }
    vision = vResult.getValue();
    StrategyMapVO strategyMap = new StrategyMapVO();
    strategyMap.setVisId(vision.getVisId());
    DefaultResult<StrategyMapVO> smResult = strategyMapService.saveObject(strategyMap);
    if (smResult.getValue() == null) {
        throw new ServiceException(smResult.getSystemMessage().getValue());
    }
    strategyMap = smResult.getValue();
    DefaultResult<Boolean> result = new DefaultResult<Boolean>();
    result.setValue(Boolean.TRUE);
    result.setSystemMessage(new SystemMessage(SysMessageUtil.get(GreenStepSysMsgConstants.UPDATE_SUCCESS)));
    this.saveNodesAndConnections(strategyMap, jsonData);
    return result;
}
Also used : SystemMessage(com.netsteadfast.greenstep.base.model.SystemMessage) ServiceException(com.netsteadfast.greenstep.base.exception.ServiceException) StrategyMapVO(com.netsteadfast.greenstep.vo.StrategyMapVO) DefaultResult(com.netsteadfast.greenstep.base.model.DefaultResult) VisionVO(com.netsteadfast.greenstep.vo.VisionVO) ServiceMethodAuthority(com.netsteadfast.greenstep.base.model.ServiceMethodAuthority) Transactional(org.springframework.transaction.annotation.Transactional)

Example 3 with StrategyMapVO

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

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

the class VisionLogicServiceImpl method deleteStrategyMap.

private void deleteStrategyMap(VisionVO vision) throws ServiceException, Exception {
    StrategyMapVO strategyMap = new StrategyMapVO();
    strategyMap.setVisId(vision.getVisId());
    DefaultResult<StrategyMapVO> smResult = this.strategyMapService.findByUK(strategyMap);
    if (smResult.getValue() == null) {
        // 沒有 BB_STRATEGY_MAP 資料
        return;
    }
    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));
    }
    this.strategyMapService.deleteObject(strategyMap);
}
Also used : BbStrategyMapConns(com.netsteadfast.greenstep.po.hbm.BbStrategyMapConns) HashMap(java.util.HashMap) StrategyMapVO(com.netsteadfast.greenstep.vo.StrategyMapVO) BbStrategyMapNodes(com.netsteadfast.greenstep.po.hbm.BbStrategyMapNodes)

Aggregations

StrategyMapVO (com.netsteadfast.greenstep.vo.StrategyMapVO)4 BbStrategyMapConns (com.netsteadfast.greenstep.po.hbm.BbStrategyMapConns)3 BbStrategyMapNodes (com.netsteadfast.greenstep.po.hbm.BbStrategyMapNodes)3 HashMap (java.util.HashMap)3 ServiceException (com.netsteadfast.greenstep.base.exception.ServiceException)2 DefaultResult (com.netsteadfast.greenstep.base.model.DefaultResult)2 ServiceMethodAuthority (com.netsteadfast.greenstep.base.model.ServiceMethodAuthority)2 SystemMessage (com.netsteadfast.greenstep.base.model.SystemMessage)2 VisionVO (com.netsteadfast.greenstep.vo.VisionVO)2 Transactional (org.springframework.transaction.annotation.Transactional)2 StrategyMapItemsVO (com.netsteadfast.greenstep.bsc.vo.StrategyMapItemsVO)1