activity5.21在線設計器modeler的使用

之前習慣了在eclipse中使用工作流插件設計工作流模型圖,忽然換成在線編輯器設計就變得很不適應了,特別是中文設計器,翻譯過來就好像不一樣了;

首先上圖:

 模型中的節點在對應位置都可以找到,直接拖到設計器內;節點間的連線可以粘貼複製,拖動到指定的節點;拖動節點時要注意,必須是每個連線都有sourse、target,也就是起點和目標點,否則發佈時就報錯;

節點參數的配置

先看編制環節:

其中重要的參數就是該節點的辦理人,一開始我發現在這裏寫的是代理,以爲是和代理流程相關的參數,搞的本人在這裏查了很久才發現就是和插件設計器的assign參數是一樣的;所以辦理人直接上流程相關參數,在流程進入這個節點前,給participant參數賦值即可;

自定義表單:應該就是設置formKey使用的,本人在這裏沒有用到;

連線參數配置:

當某個環節有退回要求時,可以設計成上圖樣子,主要是配置流轉條件 :設置流程相關參數==‘no’時,才走退回連線;此處也要注意:看下圖不是退回連線的配置

就是也要配置一個參數==‘yes’,不然校對出來後,兩個連線的節點都會流轉到;當然了 ,此處也可以使用排他網關,應該就可以避免此問題;

多實例會籤

很符合我們實情的多人會籤功能;

多實例類型選擇parallel:表示該會籤是在並行執行的;本人若選擇sequential:表示會籤內的任務是順序執行的;

集合:存放參與會籤的人員變量,在進入會籤前,要爲該流程變量要賦值;

元素變量:代表集合內的每一個元素;

至於代理人這個變量要不要配置,我沒有嘗試,有興趣的可以嘗試一下;附上爲會籤人賦值的代碼:

//爲多實例集合賦值
                List<String> participantList = new ArrayList<>();
                for (FileParticipant f:fileParticipantList){
                    participantList.add(f.getUserid());
                }
                variables.put("participantList",participantList);
                //調用結束個人工作任務方法  並給變量賦值
                taskService.complete(taskId,variables);

這裏在會簽上也遇到了奇葩的要求:若會籤中有一人沒有通過,也就是點擊了退回按鈕(會籤頁面我們添加了退回按鈕),那麼會籤全部結束後,流程就退回到編制環節;

實現方案:流程圖:如上文展示的;排他網關出來的兩根連線配置相關的流轉條件即可;

代碼的實現邏輯就是:

1、審覈環節選擇了會籤人,流程就走會籤,審覈環節完成後,我會設置一下主流程的流程變量

//調用結束個人工作任務方法  並給變量賦值
taskService.complete(taskId,variables);
//發起會簽完成之後,修改一下主流程的參與人變量值爲批准者 默認流轉到批准環節
                runtimeService.setVariable(fileInfo.getProcessInstId(),"participant",fileInfo.getApproverId());
                runtimeService.setVariable(fileInfo.getProcessInstId(),"agree","signAgree");

2、當會籤環節有人退回操作時,就修改主流程的相關變量,只有修改主流程變量才能控制會簽結束的流向;

if ("signTask".equals(fileInfo.getTaskKey())){//會籤環節
            //保存處理意見
            Authentication.setAuthenticatedUserId(fileInfo.getCurUserId());
            taskService.addComment(fileInfo.getTaskId(), fileInfo.getProcessInstId(), fileInfo.getDealOpinion());
            //若其中一個會籤人退回會簽結果 則重新設置主流程的流程變量  participant,agree
            if ("signBack".equals(fileInfo.getButtonType())){
                runtimeService.setVariable(fileInfo.getProcessInstId(),"participant",fileInfo.getCreateUserid());
                runtimeService.setVariable(fileInfo.getProcessInstId(),"agree","no");
                taskService.complete(fileInfo.getTaskId());
                return;
            }

最後附上流程處理的部分代碼:

 @Override
    @Transactional(rollbackFor = Exception.class)
    public void finishTaskWork(FileInfo fileInfo) {
        //先更新文件基本信息
        if ("editTask".equals(fileInfo.getTaskKey())){
            //編制環節提交後 文件狀態變更爲審籤
            fileInfo.setStatus(2);
        }
        this.fileInfoService.updateFileInfo(fileInfo);
        //更新流程變量
        Map<String, Object> variables = new HashMap<String,Object>();
        List<FileParticipant> fileParticipantList = new ArrayList<>();
        String taskId = null;
        String assignId = null;
        //根據不同環節獲取不同類型參與者
        if ("editTask".equals(fileInfo.getTaskKey())){//編制環節
            assignId = fileInfo.getRevisionPerId();
            taskId = fileInfo.getTaskId();
            //從數據庫查詢校對人
            // FileParticipant fileParticipant = new FileParticipant();
//            fileParticipant.setFileId(fileInfo.getFileId());
//            fileParticipant.setFileCode("0");
//            fileParticipantList = fileParticipantService.findAllFileParticipant(fileParticipant);
            variables.put("participant",assignId);
            variables.put("agree","yes");
            //調用結束個人工作任務方法  並給變量賦值
            taskService.complete(taskId,variables);
            return;
        }
        if ("revisionTask".equals(fileInfo.getTaskKey())){//校對環節
            //保存處理意見
            Authentication.setAuthenticatedUserId(fileInfo.getCurUserId());
            taskService.addComment(fileInfo.getTaskId(), fileInfo.getProcessInstId(), fileInfo.getDealOpinion());
            assignId = fileInfo.getAuditorId();
            taskId = fileInfo.getTaskId();
            variables.put("participant",assignId);
            variables.put("agree","yes");
            //調用結束個人工作任務方法  並給變量賦值
            taskService.complete(taskId,variables);
            return;
        }
        if ("auditTask".equals(fileInfo.getTaskKey())){//審覈環節
            //保存處理意見
            Authentication.setAuthenticatedUserId(fileInfo.getCurUserId());
            taskService.addComment(fileInfo.getTaskId(), fileInfo.getProcessInstId(), fileInfo.getDealOpinion());
            assignId = fileInfo.getApproverId();
            taskId = fileInfo.getTaskId();
            FileParticipant fileParticipant = new FileParticipant();
            fileParticipant.setFileId(fileInfo.getFileId());
            fileParticipant.setParticipantsCode("2");
            //查詢是否存在會籤人  若不存在 直接進入批准環節
            fileParticipantList = fileParticipantService.findAllFileParticipant(fileParticipant);
            if (fileParticipantList.size()>0){
                //獲取當前流程變量agree的值  判斷是否已經經過會籤
                String signFlag = (String)runtimeService.getVariable(fileInfo.getProcessInstId(),"agree");
//                //若果agree爲sign,會籤發起人再次提交進入批准環節
//                if ("sign".equals(signFlag)){
//                    variables.put("participant",assignId);
//                    variables.put("agree","yes");
//                    //調用結束個人工作任務方法  並給變量賦值
//                    taskService.complete(taskId,variables);
//                    return;
//                }
//                //若果agree不爲sign,會籤發起人提交進入會籤
                //設置進入會籤環節的流程變量
                variables.put("agree","sign");
                //爲多實例集合賦值
                List<String> participantList = new ArrayList<>();
                for (FileParticipant f:fileParticipantList){
                    participantList.add(f.getUserid());
                }
                variables.put("participantList",participantList);
                //調用結束個人工作任務方法  並給變量賦值
                taskService.complete(taskId,variables);
                //發起會簽完成之後,修改一下主流程的參與人變量值爲批准者 默認流轉到批准環節
                runtimeService.setVariable(fileInfo.getProcessInstId(),"participant",fileInfo.getApproverId());
                runtimeService.setVariable(fileInfo.getProcessInstId(),"agree","signAgree");
                return;
            }
            variables.put("participant",assignId);
            variables.put("agree","yes");
            //調用結束個人工作任務方法  並給變量賦值
            taskService.complete(taskId,variables);
            return;

        }
        if ("signTask".equals(fileInfo.getTaskKey())){//會籤環節
            //保存處理意見
            Authentication.setAuthenticatedUserId(fileInfo.getCurUserId());
            taskService.addComment(fileInfo.getTaskId(), fileInfo.getProcessInstId(), fileInfo.getDealOpinion());
            //若其中一個會籤人退回會簽結果 則重新設置主流程的流程變量  participant,agree
            if ("signBack".equals(fileInfo.getButtonType())){
                runtimeService.setVariable(fileInfo.getProcessInstId(),"participant",fileInfo.getCreateUserid());
                runtimeService.setVariable(fileInfo.getProcessInstId(),"agree","no");
                taskService.complete(fileInfo.getTaskId());
                return;
            }

            assignId = fileInfo.getApproverId();
            taskId = fileInfo.getTaskId();
            //variables.put("participant",assignId);
            //variables.put("agree","yes");
            //調用結束個人工作任務方法  並給變量賦值
            taskService.complete(taskId);
            return;
        }

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章