久久国产成人av_抖音国产毛片_a片网站免费观看_A片无码播放手机在线观看,色五月在线观看,亚洲精品m在线观看,女人自慰的免费网址,悠悠在线观看精品视频,一级日本片免费的,亚洲精品久,国产精品成人久久久久久久

分享

activiti自定義流程之Spring整合activiti-modeler實例(六):啟動流程

 WindySky 2017-10-16

 1.啟動流程并分配任務(wù)是單個流程的正式開始,,因此要使用到runtimeService接口,,以及相關(guān)的啟動流程的方法,。我習(xí)慣于用流程定義的key啟動,,因為有多個版本的流程定義時,,用key啟動默認會使用最新版本,。同時,,因為啟動中查詢了流程部署時xml文件中流程節(jié)點的信息,,也用到了repositoryService及相關(guān)方法,。


2.后臺業(yè)務(wù)代碼,
  (1)自定義的申請單實體類(為的目的只為了跑通整個流程,,因此只定義了一個實體類,,按公司標準開發(fā)來說,應(yīng)該是和前臺交互一個command類(其實也還是實體類,,叫法不一樣而已),,和數(shù)據(jù)庫交互還有一個實體類),在這里定義了一個申請單的基本信息:
[java] view plain copy
 在CODE上查看代碼片派生到我的代碼片
  1. package model;  
  2.   
  3.   
  4. public class applyModel {  
  5.     /** 
  6.      * 流程定義id 
  7.      */  
  8.     private String proDefId;  
  9.     /** 
  10.      * 流程定義的key 
  11.      */  
  12.     private String key;  
  13.       
  14.     private String name;  
  15.     /** 
  16.      * 申請人 
  17.      */  
  18.     private String appPerson;  
  19.     /** 
  20.      * 原因 
  21.      */  
  22.     private String cause;  
  23.     /** 
  24.      * 內(nèi)容 
  25.      */  
  26.     private String content;  
  27.     /** 
  28.      * 處理人,,即下一個任務(wù)節(jié)點的受理人 
  29.      */  
  30.     private String proPerson;  
  31.   
  32.   
  33.     public String getKey() {  
  34.         return key;  
  35.     }  
  36.   
  37.   
  38.     public void setKey(String key) {  
  39.         this.key = key;  
  40.     }  
  41.   
  42.   
  43.     public String getAppPerson() {  
  44.         return appPerson;  
  45.     }  
  46.   
  47.   
  48.     public void setAppPerson(String appPerson) {  
  49.         this.appPerson = appPerson;  
  50.     }  
  51.   
  52.   
  53.     public String getCause() {  
  54.         return cause;  
  55.     }  
  56.   
  57.   
  58.     public void setCause(String cause) {  
  59.         this.cause = cause;  
  60.     }  
  61.   
  62.   
  63.     public String getContent() {  
  64.         return content;  
  65.     }  
  66.   
  67.   
  68.     public void setContent(String content) {  
  69.         this.content = content;  
  70.     }  
  71.   
  72.   
  73.     public String getProPerson() {  
  74.         return proPerson;  
  75.     }  
  76.   
  77.   
  78.     public void setProPerson(String proPerson) {  
  79.         this.proPerson = proPerson;  
  80.     }  
  81.   
  82.   
  83.     public String getName() {  
  84.         return name;  
  85.     }  
  86.   
  87.   
  88.     public void setName(String name) {  
  89.         this.name = name;  
  90.     }  
  91.   
  92.   
  93.     public String getProDefId() {  
  94.         return proDefId;  
  95.     }  
  96.   
  97.   
  98.     public void setProDefId(String proDefId) {  
  99.         this.proDefId = proDefId;  
  100.     }  
  101.   
  102.   
  103.     @Override  
  104.     public String toString() {  
  105.         return "applyModel [proDefId=" + proDefId + ", key=" + key + ", name="  
  106.                 + name + ", appPerson=" + appPerson + ", cause=" + cause  
  107.                 + ", content=" + content + ", proPerson=" + proPerson + "]";  
  108.     }  
  109.   
  110.   
  111. }  


(2)業(yè)務(wù)邏輯:


A,,這個方法獲取流程部署時xml文件里的各個節(jié)點相關(guān)信息,用來辨別當前是哪個節(jié)點,,下一節(jié)點又是什么,,共下邊的B方法調(diào)用。因為操作部署時的文件,,因此使用repositoryService:
[java] view plain copy
 在CODE上查看代碼片派生到我的代碼片
  1. /** 
  2.      * @throws XMLStreamException 
  3.      *             查詢流程節(jié)點 
  4.      *  
  5.      * @author:tuzongxun 
  6.      * @Title: findFlow 
  7.      * @param @return 
  8.      * @return Iterator<FlowElement> 
  9.      * @date Mar 21, 2016 9:31:42 AM 
  10.      * @throws 
  11.      */  
  12.     public Iterator<FlowElement> findFlow(String processDefId)  
  13.             throws XMLStreamException {  
  14.         List<ProcessDefinition> lists = repositoryService  
  15.                 .createProcessDefinitionQuery()  
  16.                 .processDefinitionId(processDefId)  
  17.                 .orderByProcessDefinitionVersion().desc().list();  
  18.         ProcessDefinition processDefinition = lists.get(0);  
  19.         processDefinition.getCategory();  
  20.         String resourceName = processDefinition.getResourceName();  
  21.         InputStream inputStream = repositoryService.getResourceAsStream(  
  22.                 processDefinition.getDeploymentId(), resourceName);  
  23.         BpmnXMLConverter converter = new BpmnXMLConverter();  
  24.         XMLInputFactory factory = XMLInputFactory.newInstance();  
  25.         XMLStreamReader reader = factory.createXMLStreamReader(inputStream);  
  26.         BpmnModel bpmnModel = converter.convertToBpmnModel(reader);  
  27.         Process process = bpmnModel.getMainProcess();  
  28.         Collection<FlowElement> elements = process.getFlowElements();  
  29.         Iterator<FlowElement> iterator = elements.iterator();  
  30.         return iterator;  
  31.     }  


B.這里調(diào)用上一個方法,,一起完成流程的啟動及相關(guān)信息的設(shè)置:

[java] view plain copy
 在CODE上查看代碼片派生到我的代碼片
  1. /** 
  2.      * @throws XMLStreamException 
  3.      *             啟動流程 
  4.      *  
  5.      * @author:tuzongxun 
  6.      * @Title: startProcess 
  7.      * @param @return 
  8.      * @return Object 
  9.      * @date Mar 17, 2016 2:06:34 PM 
  10.      * @throws 
  11.      */  
  12.     @RequestMapping(value = "/startProcess.do", method = RequestMethod.POST, produces = "application/json;charset=utf-8")  
  13.     @ResponseBody  
  14.     public Object startProcess(@RequestBody applyModel applyModel,  
  15.             HttpServletRequest req) throws XMLStreamException {  
  16.         Map<String, String> map = new HashMap<String, String>();  
  17.         boolean isLogin = this.isLogin(req);  
  18.         if (isLogin) {  
  19.             if (applyModel != null) {  
  20.                 String processKey = applyModel.getKey();  
  21.                 String processDefId = applyModel.getProDefId();  
  22.                 // //////////////////////////  
  23.                 Iterator<FlowElement> iterator = this.findFlow(processDefId);  
  24.                 Map<String, Object> varables = new HashMap<String, Object>();  
  25.                 int i = 1;  
  26.                 while (iterator.hasNext()) {  
  27.                     FlowElement flowElement = iterator.next();  
  28.                     // 申請人  
  29.                     if (flowElement.getClass().getSimpleName()  
  30.                             .equals("UserTask")  
  31.                             && i == 1) {  
  32.                         UserTask userTask = (UserTask) flowElement;  
  33.                         String assignee = userTask.getAssignee();  
  34.                         int index1 = assignee.indexOf("{");  
  35.                         int index2 = assignee.indexOf("}");  
  36.                         varables.put(assignee.substring(index1 + 1, index2),  
  37.                                 applyModel.getAppPerson());  
  38.                         varables.put("cause", applyModel.getCause());  
  39.                         varables.put("content", applyModel.getContent());  
  40.                         varables.put("taskType", applyModel.getName());  
  41.                         i++;  
  42.                         // 下一個處理人  
  43.                     } else if (flowElement.getClass().getSimpleName()  
  44.                             .equals("UserTask")  
  45.                             && i == 2) {  
  46.                         UserTask userTask = (UserTask) flowElement;  
  47.                         String assignee = userTask.getAssignee();  
  48.                         int index1 = assignee.indexOf("{");  
  49.                         int index2 = assignee.indexOf("}");  
  50.                         varables.put(assignee.substring(index1 + 1, index2),  
  51.                                 applyModel.getProPerson());  
  52.                         break;  
  53.                     }  
  54.                 }  
  55.                 // ///////////////////////////  
  56.                 runtimeService.startProcessInstanceByKey(processKey, varables);  
  57.                 map.put("userName",  
  58.                         (String) req.getSession().getAttribute("userName"));  
  59.                 map.put("isLogin""yes");  
  60.                 map.put("result""success");  
  61.             } else {  
  62.                 map.put("result""fail");  
  63.             }  
  64.         } else {  
  65.             map.put("isLogin""no");  
  66.         }  
  67.         return map;  
  68.     }  



3.angular js前臺代碼,:
  (1)app.js中配置路由:
   
[javascript] view plain copy
 在CODE上查看代碼片派生到我的代碼片
  1. $stateProvider    
  2.    .state('startProcess', {    
  3.    url: "/startProcess",    
  4.    views: {    
  5.       'view': {    
  6.        templateUrl: 'activi_views/startProcess.html',    
  7.        controller: 'startProcessCtr'    
  8.       }    
  9.    }    
  10.   });    


  (2)邏輯相關(guān)代碼:

     
[javascript] view plain copy
 在CODE上查看代碼片派生到我的代碼片
  1. angular.module('activitiApp')    
  2. .controller('startProcessCtr', ['$rootScope','$scope','$http','$location'function($rootScope,$scope,$http,$location){    
  3.   
  4.   
  5.     $http.post("createFlush.do").success(function(result){  
  6.         if(result.isLogin==="yes"){  
  7.             $rootScope.userName=result.userName;  
  8.             $scope.process1={"proDefId":"","key":"","appPerson":"","cause":"","content":"","proPerson":"","name":""};  
  9.             if($rootScope.process==null||$rootScope.process.key==null){  
  10.                 $location.path("/processList");  
  11.             }else{  
  12.                 $scope.process1.proDefId=$rootScope.process.id;  
  13.                  $scope.process1.key=$rootScope.process.key;  
  14.                    $scope.process1.name=$rootScope.process.name;  
  15.             }  
  16.         }else{  
  17.             $location.path("/login");  
  18.         }  
  19.     });  
  20.          
  21.         
  22.         $scope.startProcess=function(process){  
  23.             console.log(process);  
  24.             $http.post("./startProcess.do",process).success(function(deployResult){  
  25.                 $location.path("/taskList");  
  26.             });  
  27.         }  
  28.         
  29.     
  30. }])    


4.對應(yīng)的填寫相關(guān)信息的頁面:
[html] view plain copy
 在CODE上查看代碼片派生到我的代碼片
  1. <center>    
  2. <div style="margin-top:20px;margin-left:200px;background-color:#9cc;height:500px;width:50%;font-size:22px;position:relative;float:left;">    
  3.     <p style="font-size:28px">新建申請</p>  
  4.     流程定義id:<input type="text" ng-model="process1.proDefId" readonly="readonly" style="background-color:#9dc"/>   
  5.     </br>    
  6.     </br>    
  7.     流程定義key:<input type="text" ng-model="process1.key" readonly="readonly" style="background-color:#9dc"/>   
  8.     </br>    
  9.     </br>    
  10.     申請類型:<input type="text" ng-model="process1.name" readonly="readonly" style="background-color:#9dc"/>   
  11.     </br>    
  12.     </br>    
  13.     申請人:<input type="text" ng-model="process1.appPerson" />   
  14.     </br>    
  15.     </br>    
  16.     申請原因:<input type="text" ng-model="process1.cause"/>    
  17.     </br>    
  18.     </br>    
  19.     申請內(nèi)容:<input type="text" ng-model="process1.content"/>    
  20.     </br>    
  21.     </br>    
  22.   受理人:<input type="text" ng-model="process1.proPerson"/>    
  23.     </br>    
  24.     </br>    
  25.     <input style="font-size:24px;cursor:pointer" type="button" value="提交申請" ng-click="startProcess(process1);">    
  26.              
  27.     <input style="font-size:24px;cursor:pointer" type="button" value="返回">    
  28. </div>    
  29. </center>    



5.成功啟動一個流程實例后,,會看到act_ru_execution,、act_ru_identitylink、act_ru_task,、act_ru_variable以及act_hi_actinst,、act_hi_detail、act_hi_indentitylink,、act_hi_procinst,、act_hi_taskinst、act_hi_varinst表中都有了數(shù)據(jù),。除開variable和varinst中的數(shù)據(jù)條數(shù)是根據(jù)對應(yīng)的流程變量多少來定的,,其他都是增加了一條數(shù)據(jù)。

    本站是提供個人知識管理的網(wǎng)絡(luò)存儲空間,所有內(nèi)容均由用戶發(fā)布,,不代表本站觀點,。請注意甄別內(nèi)容中的聯(lián)系方式、誘導(dǎo)購買等信息,,謹防詐騙,。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請點擊一鍵舉報,。
    轉(zhuǎn)藏 分享 獻花(0

    0條評論

    發(fā)表

    請遵守用戶 評論公約

    類似文章 更多