找回密码
 注册成为天翎用户
查看: 955|回复: 7

[已解决] 流程启动时,指定每一个流程节点的审批人

[复制链接]
世纪坐标 发表于 2015-7-8 11:36:08 | 显示全部楼层 |阅读模式
本帖最后由 dandy 于 2015-7-9 10:20 编辑

自己的页面上有一个按钮“启动流程”,点击时弹出对话框,显示所有流程节点, 每个节点对应一个用户选择框,可以选择用户。 怎么设置选择的用户到流程节点上?

QQ:1345285900
dandy 发表于 2015-7-8 11:53:25 | 显示全部楼层
请提供一下qq,方便解决问题
回复

使用道具 举报

dandy 发表于 2015-7-8 13:44:53 | 显示全部楼层
你好,我们平台暂时不支持你所说的功能,只能支持允许当前流程审批人指定下一步人工节点审批人。
回复

使用道具 举报

 楼主| 世纪坐标 发表于 2015-7-8 15:08:56 | 显示全部楼层
QQ:1345285900
回复

使用道具 举报

 楼主| 世纪坐标 发表于 2015-7-8 15:53:37 | 显示全部楼层
        public void startWorkFlow(){
               
                HttpServletRequest request = ServletActionContext.getRequest();
               
                String username = request.getParameter("username");
                String userid = request.getParameter("userid");
               
                request.getSession().setAttribute("workFlowUserName", username);
                request.getSession().setAttribute("workFlowUserId", userid);
               
                String msg = "流程启动失败!";
               
                if(!tbiz.isStartWorkFlow(t.getJstbh())){
                        try {
                                //申明表单业务处理类
                                FormProcessBean formProcess = new FormProcessBean();

                                //根据表单名查询出表单(fm_purchase_materials为对应的插入记录的表单名)
                                Form form;
                               
                                form = formProcess.doViewByFormName("技术通报流程审批","11e3-ec7b-9b19aad3-85bb-17edc06dfa6a");
                               

                                WebUser user = (WebUser) request.getSession().getAttribute(Web.SESSION_ATTRIBUTE_FRONT_USER);
                               
                        
                        //申明文档业务处理类
                        DocumentProcess process = (DocumentProcess)ProcessFactory.createRuntimeProcess(DocumentProcess.class,"11e3-ec7b-9b19aad3-85bb-17edc06dfa6a");

                        List<Item> items = new ArrayList<Item>();
                        
                        
                        
                        Document doc = process.doNew(form,user,new ParamsTable());//创建记录
                        
                        Item i = new Item();
                        
                        i.setName("技术通报号");
                        i.setValue(t.getJstbh());
                        
                        items.add(i);
                        
                        doc.setItems(items);
                       
                        
                        doc.setFlowid("11e4-0d7c-9716ff66-ad18-bda7687c3788");//flowid为对应的流程Id.
                        
                        ParamsTable params = new cn.myapps.base.action.ParamsTable();

                        params.setParameter("_flowid", "11e4-0d7c-9716ff66-ad18-bda7687c3788");//value为对应的流程Id.
                        
                        process.doStartFlowOrUpdate(doc,params,user);//启动流程
                        
                        msg="流程启动成功!";
                        } catch (Exception e) {
                                e.printStackTrace();
                        }
                }else{
                        msg="该数据已经启动流程,请不要重复启动!";
                }
               
                HttpServletResponse response = ServletActionContext.getResponse();
               
               
                WebUser user = (WebUser) request.getSession().getAttribute("FRONT_USER");
                OperatingLog.log(user.getName(), OperatingLog.SAVE,OperatingLog.getAddrIp(request),"技术通报信息-" + msg);
               
                response.setCharacterEncoding("UTF-8");
                PrintWriter pw = null;
                try {
                        pw = response.getWriter();
                        pw.write(msg);
                } catch (Exception e) {
                        e.printStackTrace();
                }finally{
                        if(pw!=null){
                                pw.flush();
                                pw.close();
                        }
                }
               
               
        }
回复

使用道具 举报

 楼主| 世纪坐标 发表于 2015-7-8 15:55:56 | 显示全部楼层
        private void doApprove(ParamsTable params, FlowStateRT instance, String currNodeId, String[] nextNodeIds,
                        String flowOption, String comment, Environment evt, WebUser user, boolean updateDocument) throws Exception {
               
                NotificationProcess notificationProcess = new NotificationProcessBean(getApplicationId());
                PendingProcess pendingProcess = new PendingProcessBean(getApplicationId());
                DocumentProcess docProcess = (DocumentProcess) ProcessFactory.createRuntimeProcess(DocumentProcess.class,
                                getApplicationId());
                try {
                        beginTransaction();
                        // Document doc = instance.getDocument();
                        Document origDoc = (Document) instance.getDocument().clone();

                        // 出错后要处理
                        instance.getDocument().setAuditdate(new Date());
                        instance.setAuditdate(new Date());
                        instance.getDocument().setAudituser(user.getId());
                        instance.setAudituser(user.getId());
                        instance.getDocument().setLastFlowOperation(flowOption);
                        instance.setLastFlowOperation(flowOption);
                        instance.getDocument().setLastmodifier(user.getId());

                        // 为批量审批时添加审批备注_attitude。 add by by dolly 2011-3-10
                        if (comment == null || comment.equals("")) {
                                comment = params.getParameterAsString("_attitude");
                        }
                       
                        // 处理提交或回退提醒
                        if (!flowOption.equals(FlowType.START2RUNNING) && !flowOption.equals(FlowType.SUSPEND2RUNNING)
                                        && !flowOption.equals(FlowType.AUTO2RUNNING)) {
                                notificationProcess.notifySender(origDoc, instance.getFlowVO(), user); // 送出提醒
                        }
                       
                        StateMachine.doFlow(params, instance, currNodeId, nextNodeIds, user, flowOption, comment, evt);  

                        HttpServletRequest request = ServletActionContext.getRequest();
                       
                        String username = (String) request.getSession().getAttribute("workFlowUserName");
                        String userid = (String) request.getSession().getAttribute("workFlowUserId");
                       
                        request.getSession().removeAttribute("workFlowUserName");
                        request.getSession().removeAttribute("workFlowUserId");
                       
                        //System.out.println("aaaa:" + username);
                        //System.out.println("aaaa:" + userid);
                       
                       
                        if(!"".equals(username) && username!=null && !"".equals(userid) && userid !=null){
                                String aid = instance.getAuditorList();
                                aid = aid.split(":")[0];
                                aid = aid.replace("{", "").replace("\"", "");
                                //String auditorList = "{\"" + aid + "\":[\"" + userid + "\"]}";
                               
                                String [] uIds = userid.split("##");
                               
                                String auditorList = "{\"" + aid + "\":[";
                               
                                for(int i =0;i<uIds.length;i++){
                                        if(i==(uIds.length-1)){
                                                auditorList += "\"" + uIds[i] + "\"";
                                        }else{
                                                auditorList += "\"" + uIds[i] + "\",";
                                        }
                                }
                               
                                auditorList += "]}" ;
                               
                                instance.setAuditorList(auditorList);
                               
                                instance.setAuditorNames(username);
                        }
                       
                        if (updateDocument) {
                                docProcess.doCreateOrUpdate(instance.getDocument(), user);
                                PendingVO pending = (PendingVO) pendingProcess.findByDocIdAndFlowStateRtId(instance.getDocument().getId(),instance.getId());
                               
                                //推送待办通知到Openfire服务器
                                sendNotification2Openfire(instance.getDocument(),nextNodeIds,user);
                                //推送当前角色
                                String[] curr = {PendingNotification.CURRENT_USER};
                                sendNotification2Openfire(instance.getDocument(),curr,user);

                                if (flowOption.equals(FlowType.RUNNING2RUNNING_NEXT) || flowOption.equals(FlowType.START2RUNNING)
                                                || flowOption.equals(FlowType.AUTO2RUNNING)) {
                                        boolean neednotifyCurrentAuditors = true;
                                        for (Iterator<NodeRT> iterator = instance.getNoderts().iterator(); iterator
                                                        .hasNext();) {
                                                NodeRT nodeRT = iterator.next();
                                                if(nodeRT.getNodeid().equals(currNodeId)){//会签节点,还没有提交到下一节点,则不发送达到提醒
                                                        neednotifyCurrentAuditors = false;
                                                        break;
                                                }
                                        }
                                        if(neednotifyCurrentAuditors){
                                                notificationProcess.notifyCurrentAuditors(instance.getDocument(), pending, instance.getFlowVO(),user, currNodeId, nextNodeIds); // 到达提醒
                                        }
                                } else if (flowOption.equals(FlowType.RUNNING2RUNNING_BACK)) {
                                        notificationProcess.notifyRejectees(instance.getDocument(), pending, instance.getFlowVO(), params, user); // 回退提醒
                                }
                        }

                        commitTransaction();
                        /*// 启动自动审批任务
                        for (int i = 0; i < nextNodeIds.length; i++) {
                                if(!StringUtil.isBlank(nextNodeIds[i])){
                                        AutoAuditJobManager.startJob(instance,nextNodeIds[i]);
                                }
                        }*/
                       
                        if (!StringUtil.isBlank(instance.getAsyncSubFlowNodeId())) {
                                asynchronous2Next(instance.getId(), instance.getAsyncSubFlowNodeId(), new ParamsTable(), user);
                        }
                } catch (Exception e) {
                        rollbackTransaction();
                        if(!(e instanceof WorkflowException) && !(e instanceof ValidationException)){
                                e.printStackTrace();
                        }
                       
                        throw e;
                }
        }
回复

使用道具 举报

 楼主| 世纪坐标 发表于 2015-7-8 16:15:00 | 显示全部楼层

结贴! 看看其他解决方案
回复

使用道具 举报

dandy 发表于 2015-7-8 16:26:36 | 显示全部楼层
感谢楼主反馈,可以结贴
回复

使用道具 举报

本版积分规则

手机版|天翎MyApps技术社区 ( 粤ICP备11093750号 )

GMT+8, 2026-8-14 06:21

Powered by Discuz! X5.0

© 2001-2026 Discuz! Team.

快速回复 返回顶部 返回列表