当前位置: 首页 > wzjs >正文

巴音郭楞网站建设网站开发前台代码和后台代码

巴音郭楞网站建设,网站开发前台代码和后台代码,title (网站建设),化妆品网站欣赏Activiti6.0中审批不通过时回退到上一个节点/指定节点 在当前做的这个审批流中,需要增加一个审批不通过时回退节点的功能,因为当前系统需求还没有特别明确这部分,所以我就先写了以下两种回退情况: 1.回退到上一个节点 /*** 撤回…

Activiti6.0中审批不通过时回退到上一个节点/指定节点

在当前做的这个审批流中,需要增加一个审批不通过时回退节点的功能,因为当前系统需求还没有特别明确这部分,所以我就先写了以下两种回退情况:

1.回退到上一个节点

 /*** 撤回到上一个节点* @param processInstanceId* @param nowUserId*/@Override@Transactionalpublic void revoke(String processInstanceId, String nowUserId) {//获取待执行的任务节点Task task = taskService.createTaskQuery().processInstanceId(processInstanceId).singleResult();if(task == null){// throw new Exception("sorry,the process is not started or has finished, cannot be withdrawn");System.out.println("sorry,the process is not started or has finished, cannot be withdrawn");}//通过processInstanceId查询历史节点List<HistoricTaskInstance> htiList = historyService.createHistoricTaskInstanceQuery().processInstanceId(processInstanceId).orderByTaskCreateTime().asc().list();String myTaskId = null;HistoricTaskInstance myTask = null;//找到当前运行的节点HistoricProcessInstance processInstance = historyService.createHistoricProcessInstanceQuery().processInstanceId(processInstanceId).singleResult();ProcInstance procInstance = procInstanceMapper.selectById(processInstance.getBusinessKey()).get(0);SysUser startUser = sysUserService.selectUserById(procInstance.getUserId());List<SysUser> currUsers = findCurrUsers(task, startUser);System.out.println("----------- =-= -------currUser-----------------------"+currUsers.get(0).getUserId());System.out.println("------ =-= ------nowUserId--------------------------"+nowUserId);for (HistoricTaskInstance hti : htiList) {//判断一下当前的用户是否为当前任务的审批负责人 , 感觉后面通过权限赋予也可以不加这个判断//if (currUsers.get(0).getUserId().equals(nowUserId)&& hti.getId().equals(task.getId())) {if ( currUsers.get(0).getUserId().toString().equals(nowUserId)&&hti.getId().equals(task.getId())) {myTaskId = hti.getId();  //当前任务idmyTask = hti;break;}}if (null == myTaskId) {//throw new Exception("该任务非当前用户提交,无法撤回");System.out.println("该任务非当前用户提交,无法撤回~~!!");}String processDefinitionId = myTask.getProcessDefinitionId();//获取流程模型BpmnModel bpmnModel = repositoryService.getBpmnModel(processDefinitionId);String myActivityId = null;//查询已经完成的流程节点,查询到上一条已完成的节点,则跳出循环List<HistoricActivityInstance> haiList = historyService.createHistoricActivityInstanceQuery().executionId(myTask.getExecutionId()).finished().orderByHistoricActivityInstanceStartTime().desc().list();System.out.println("---------------the latest finished---------------"+haiList.get(0));myActivityId = haiList.get(0).getActivityId();
//        for (HistoricActivityInstance hai : haiList) {
//            if (myTaskId.equals(hai.getTaskId())) {
//                myActivityId = hai.getActivityId();
//                break;
//            }
//        }//最近一个已完成节点的 FlowNodeFlowNode myFlowNode = (FlowNode) bpmnModel.getMainProcess().getFlowElement(myActivityId);//原本的活动方向Execution execution = runtimeService.createExecutionQuery().executionId(task.getExecutionId()).singleResult();String activityId = execution.getActivityId();FlowNode flowNode = (FlowNode) bpmnModel.getMainProcess().getFlowElement(activityId);//记录原活动方向List<SequenceFlow> oriSequenceFlows = new ArrayList<SequenceFlow>();oriSequenceFlows.addAll(flowNode.getOutgoingFlows());//清理活动方向flowNode.getOutgoingFlows().clear();//建立新方向List<SequenceFlow> newSequenceFlowList = new ArrayList<SequenceFlow>();SequenceFlow newSequenceFlow = new SequenceFlow();newSequenceFlow.setId("newSequenceFlowId"+" WITHDRAW: "+nowtime());//新方向的源头---当前节点newSequenceFlow.setSourceFlowElement(flowNode);//新方向的目标---上一个已完成节点newSequenceFlow.setTargetFlowElement(myFlowNode);newSequenceFlowList.add(newSequenceFlow);flowNode.setOutgoingFlows(newSequenceFlowList);Authentication.setAuthenticatedUserId(nowUserId);taskService.addComment(task.getId(), task.getProcessInstanceId(), "撤回");//完成任务taskService.complete(task.getId());//恢复原方向flowNode.setOutgoingFlows(oriSequenceFlows);System.out.println("------------------withdraw successfully!!----------------------------");logger.info("退回成功!");}

2.回退到当前审批用户指定的节点
先查询一下当前流程实例的历史Activity表:

 /*** 展示历史Activity表* @param proInstanceId* @return*/@Override@Transactionalpublic List hisActInst(String proInstanceId){HistoricProcessInstance instance = historyService.createHistoricProcessInstanceQuery().processInstanceBusinessKey(proInstanceId).singleResult();String processInstanceId = instance.getId();//获取待执行的任务节点Task task = taskService.createTaskQuery().processInstanceId(processInstanceId).singleResult();if(task == null){// throw new Exception("sorry,the process is not started or has finished, cannot be withdrawn");System.out.println("sorry,the process is not started or has finished, cannot be withdrawn");}//通过processInstanceId查询历史节点List<HistoricTaskInstance> htiList = historyService.createHistoricTaskInstanceQuery().processInstanceId(processInstanceId).orderByTaskCreateTime().asc().list();String myTaskId = null;HistoricTaskInstance myTask = null;//找到当前运行的节点HistoricProcessInstance processInstance = historyService.createHistoricProcessInstanceQuery().processInstanceId(processInstanceId).singleResult();ProcInstance procInstance = procInstanceMapper.selectById(processInstance.getBusinessKey()).get(0);SysUser startUser = sysUserService.selectUserById(procInstance.getUserId());List<SysUser> currUsers = findCurrUsers(task, startUser);for (HistoricTaskInstance hti : htiList) {//判断一下当前的用户是否为当前任务的审批负责人 , 感觉后面通过权限赋予也可以不加这个判断//if (currUsers.get(0).getUserId().equals(nowUserId)&& hti.getId().equals(task.getId())) {if ( hti.getId().equals(task.getId())) {myTaskId = hti.getId();  //当前任务idmyTask = hti;break;}}if (null == myTaskId) {//throw new Exception("该任务非当前用户提交,无法撤回");System.out.println("该任务非当前用户提交,无法撤回~~!!");}List<HistoricActivityInstance> haiList = historyService.createHistoricActivityInstanceQuery().executionId(myTask.getExecutionId()).finished().orderByHistoricActivityInstanceStartTime().desc().list();return haiList;}

在根据获取到的目标回退节点的ActivityId进行回退操作:

/*** 回退到指定节点处* @param processInstanceId* @param nowUserId* @param tarActivityId* @return*/@Override@Transactionalpublic void rollBackToSpec(String processInstanceId, String nowUserId, String tarActivityId) {//获取待执行的任务节点Task task = taskService.createTaskQuery().processInstanceId(processInstanceId).singleResult();if(task == null){// throw new Exception("sorry,the process is not started or has finished, cannot be withdrawn");System.out.println("sorry,the process is not started or has finished, cannot be withdrawn");}//通过processInstanceId查询历史节点List<HistoricTaskInstance> htiList = historyService.createHistoricTaskInstanceQuery().processInstanceId(processInstanceId).orderByTaskCreateTime().asc().list();String myTaskId = null;HistoricTaskInstance myTask = null;//找到当前运行的节点HistoricProcessInstance processInstance = historyService.createHistoricProcessInstanceQuery().processInstanceId(processInstanceId).singleResult();ProcInstance procInstance = procInstanceMapper.selectById(processInstance.getBusinessKey()).get(0);SysUser startUser = sysUserService.selectUserById(procInstance.getUserId());List<SysUser> currUsers = findCurrUsers(task, startUser);System.out.println("----------- =-= -------currUser-----------------------"+currUsers.get(0).getUserId());System.out.println("------ =-= ------nowUserId--------------------------"+nowUserId);for (HistoricTaskInstance hti : htiList) {//判断一下当前的用户是否为当前任务的审批负责人 , 感觉后面通过权限赋予也可以不加这个判断//if (currUsers.get(0).getUserId().equals(nowUserId)&& hti.getId().equals(task.getId())) {if ( currUsers.get(0).getUserId().toString().equals(nowUserId)&&hti.getId().equals(task.getId())) {myTaskId = hti.getId();  //当前任务idmyTask = hti;break;}}if (null == myTaskId) {//throw new Exception("该任务非当前用户提交,无法撤回");System.out.println("该任务非当前用户提交,无法撤回~~!!");}String processDefinitionId = myTask.getProcessDefinitionId();//获取流程模型BpmnModel bpmnModel = repositoryService.getBpmnModel(processDefinitionId);
//        String myActivityId = null;//查询已经完成的流程节点,查询到上一条已完成的节点,则跳出循环
//        List<HistoricActivityInstance> haiList = historyService.createHistoricActivityInstanceQuery()
//                .executionId(myTask.getExecutionId())
//                .finished()
//                .orderByHistoricActivityInstanceStartTime()
//                .desc()
//                .list();
//        System.out.println("---------------the latest finished---------------"+haiList.get(0));
//        myActivityId = haiList.get(0).getActivityId();//想要回退到的节点位置System.out.println(tarActivityId);FlowNode myFlowNode = (FlowNode) bpmnModel.getMainProcess().getFlowElement(tarActivityId);//原本的活动方向Execution execution = runtimeService.createExecutionQuery().executionId(task.getExecutionId()).singleResult();String activityId = execution.getActivityId();FlowNode flowNode = (FlowNode) bpmnModel.getMainProcess().getFlowElement(activityId);//记录原活动方向List<SequenceFlow> oriSequenceFlows = new ArrayList<SequenceFlow>();oriSequenceFlows.addAll(flowNode.getOutgoingFlows());//清理活动方向flowNode.getOutgoingFlows().clear();//建立新方向List<SequenceFlow> newSequenceFlowList = new ArrayList<SequenceFlow>();SequenceFlow newSequenceFlow = new SequenceFlow();newSequenceFlow.setId("newSequenceFlowId"+" ROLLBACK: "+nowtime());//新方向的源头---当前节点newSequenceFlow.setSourceFlowElement(flowNode);System.out.println("--------------new flow-----------------"+flowNode);//新方向的目标---要回退的节点System.out.println("--------------target flow-----------------"+myFlowNode);newSequenceFlow.setTargetFlowElement(myFlowNode);newSequenceFlowList.add(newSequenceFlow);flowNode.setOutgoingFlows(newSequenceFlowList);Authentication.setAuthenticatedUserId(nowUserId);taskService.addComment(task.getId(), task.getProcessInstanceId(), "回退");//完成任务System.out.println("========================完成任务====================");taskService.complete(task.getId());//恢复原方向flowNode.setOutgoingFlows(oriSequenceFlows);System.out.println("------------------RollBack successfully!!----------------------------");logger.info("退回成功!");//将退回完成后的当前节点的task返回
//        HistoricActivityInstance historicActivityInstance = historyService.createHistoricActivityInstanceQuery().activityId(tarActivityId).singleResult();
//
//        return historicActivityInstance.getTaskId();}

文章转载自:

http://kORyUHNM.pxfxd.cn
http://lHu5ebZ5.pxfxd.cn
http://sevPm4N4.pxfxd.cn
http://ZwBgMhMI.pxfxd.cn
http://6zPPBYSr.pxfxd.cn
http://d4zwkh7K.pxfxd.cn
http://AgbEL5mA.pxfxd.cn
http://WIMoI1mY.pxfxd.cn
http://eNzLj6ah.pxfxd.cn
http://Mn4AVquJ.pxfxd.cn
http://vQ1PhONZ.pxfxd.cn
http://WBMVIhAy.pxfxd.cn
http://x1fptdY7.pxfxd.cn
http://j5u7AqSN.pxfxd.cn
http://ESfr0yh2.pxfxd.cn
http://Gt7yjlEG.pxfxd.cn
http://y4mA52su.pxfxd.cn
http://iuvNs0zd.pxfxd.cn
http://PM0TqdGN.pxfxd.cn
http://TdI7wwA7.pxfxd.cn
http://qPfjxpQE.pxfxd.cn
http://EMO5rOTd.pxfxd.cn
http://13BAyvHn.pxfxd.cn
http://60ch5Z0b.pxfxd.cn
http://DWogGLHS.pxfxd.cn
http://VPk0H65b.pxfxd.cn
http://qNLM0A1v.pxfxd.cn
http://HqiLIh7G.pxfxd.cn
http://YP7r2rzV.pxfxd.cn
http://CMproAUI.pxfxd.cn
http://www.dtcms.com/wzjs/607861.html

相关文章:

  • 网站中文模板商丘做网站推广
  • 做化妆品网站的原因郑州做网站公司汉狮网
  • 东莞网站设计实力深圳网站设计公司的
  • 企业网站管理系统添加教程wordpress 熊掌号api
  • 网站整体框架东莞建设网站的公司简介
  • 网站小空间贵州网站建设哪家好
  • 钱币网站建设可以做海报的网站
  • 小程序视频网站开发免费看看视频用什么软件好
  • 百捷网站建设龙海市建设局网站
  • 怎么做免费网站推南京本地网站
  • 网站如何申请微信支付接口自助建站优化排名
  • 免费开源cms网站源码wordpress新闻模板
  • 药业做网站的网站目标分析解决方案网站
  • 深圳网站建设公司推荐乐云seo嘉兴白酒网站建设
  • 个人网站 做啥好wordpress 模板 管理
  • 在线教育网站建设方案网页制作q元素
  • 跨境电商网站建设流程做网站文字字号大小
  • 网站建设top图做动物网站的素材
  • 公司设计网站多少钱怎么用电脑自带软件做网站页面
  • 黄埔网站建设价格设计衣服的网站
  • 网站首页一般做多大尺寸海淀搜索引擎优化seo
  • 门户手机网站源码外网门户网站建设方案
  • 做电商网站需要多少时间网页制作专业知识
  • 门户网站建设多少钱电子商务网站案例分析
  • 1000元能否做网站厦门安岭路网站建设
  • 网站页尾的作用wordpress 商品 模板下载
  • 网站开发ppt转h5欧美风格英文网站设计
  • 专门做恐怖电影网站手机如何制作游戏
  • 网站从建设到赚钱的流程wordpress改后台
  • 做除尘环保的如何推广自己的网站深圳百度公司地址