BPMN-Activiti信号中间件实例

BPM流程图如下:


        ExecutionService executionService=bpmProcessService.bpmRestServices(userId).getExecutionService();
        String parentId="";
        //
        HistoricProcessInstancesQueryParam historicProcessInstancesQueryParam = new HistoricProcessInstancesQueryParam();
        historicProcessInstancesQueryParam.setBusinessKey(bussinessKey);
        try {
            JsonNode jsonNode = (JsonNode) bpmProcessService.bpmRestServices(userId).getHistoryService().getHistoricProcessInstances(historicProcessInstancesQueryParam);
            logger.debug(jsonNode.toString());
            ArrayNode node = BaseUtils.getData(jsonNode);
            List<HistoricProcessInstanceResponse> list = new ArrayList<HistoricProcessInstanceResponse>();

            for (int i = 0; node != null && i < node.size(); i++) {
                JsonNode jn = node.get(i);
                HistoricProcessInstanceResponse resp = jsonResultService.toObject(jn.toString(), HistoricProcessInstanceResponse.class);
                list.add(resp);
                parentId=resp.getId();
                logger.debug("parentId:"+parentId);
            }

        } catch (RestException e) {
            logger.error(e.getMessage(),e);
        }

//        ProcessInstanceParam processInstanceParam = new ProcessInstanceParam();
//        processInstanceParam.setBusinessKey(bussinessKey);
//        try {
//            Object obj = bpmProcessService.bpmRestServices(userId).getRuntimeService().getProcessInstances(processInstanceParam);
//            logger.debug(obj.toString());
//        } catch (RestException e) {
//            e.printStackTrace();
//        }
        //---

        String executionId="";
        try {
            ExecutionQueryParam executionQueryParam=new ExecutionQueryParam();
//            executionQueryParam.setActivityId("CatchSignalEvent1");
            executionQueryParam.setParentId(parentId);//"a0f4ec59-62bf-11e6-9214-b8aeed2e916b"
            JsonNode executionsJsonNode = (JsonNode)executionService.getExecutions(executionQueryParam);
            logger.debug(executionsJsonNode.toString());
            ArrayNode node = BaseUtils.getData(executionsJsonNode);
            List<ExecutionResponse> list = new ArrayList<ExecutionResponse>();
            for (int i = 0; node != null && i < node.size(); i++) {
                JsonNode jn = node.get(i);
                ExecutionResponse resp = jsonResultService.toObject(jn.toString(), ExecutionResponse.class);
                list.add(resp);
                executionId=resp.getId();
                logger.debug("parentId:"+parentId);
            }
        } catch (RestException e) {
            e.printStackTrace();
        }
        //---

        ExecutionParam executionParam = new ExecutionParam();
        executionParam.setAction(ExecutionParam.SIGNAL_ACTION);
        executionParam.setSignalName(signal);
        try {
            executionService.actionExecutions(executionId,executionParam);//"743233f1-62ad-11e6-9214-b8aeed2e916b"
        } catch (RestException e) {
            e.printStackTrace();
        }
    }

posted @ 2016-08-16 15:17  江晓曼博客园  阅读(300)  评论(0编辑  收藏  举报