Commit 75b8885d8318456358c257c1e42f99b7de87bd97

Authored by 273548560@qq.com
2 parents 7b5936e1 6d4ef200

Merge remote-tracking branch 'origin/dev' into dev

trash-activiti/src/main/java/com/trash/activiti/controller/TaskController.java
... ... @@ -7,6 +7,7 @@ import com.trash.common.core.domain.AjaxResult;
7 7 import com.trash.common.core.page.PageDomain;
8 8 import com.trash.common.core.page.TableDataInfo;
9 9 import com.trash.common.core.page.TableSupport;
  10 +import com.trash.common.utils.ServletUtils;
10 11 import com.trash.activiti.domain.dto.ActTaskDTO;
11 12 import com.trash.activiti.domain.dto.ActWorkflowFormDataDTO;
12 13 import com.trash.activiti.service.IActTaskService;
... ...
trash-activiti/src/main/java/com/trash/activiti/service/impl/ActTaskServiceImpl.java
... ... @@ -26,9 +26,13 @@ import org.activiti.engine.TaskService;
26 26 import org.activiti.engine.history.HistoricProcessInstance;
27 27 import org.activiti.engine.history.HistoricProcessInstanceQuery;
28 28 import org.activiti.engine.runtime.ProcessInstance;
  29 +import org.activiti.engine.task.IdentityLink;
  30 +import org.apache.commons.collections4.map.HashedMap;
29 31 import org.springframework.beans.factory.annotation.Autowired;
30 32 import org.springframework.stereotype.Service;
31 33  
  34 +import com.alibaba.fastjson.JSONArray;
  35 +import com.alibaba.fastjson.JSONObject;
32 36 import com.github.pagehelper.Page;
33 37 import com.trash.activiti.domain.ActWorkflowFormData;
34 38 import com.trash.activiti.domain.dto.ActTaskDTO;
... ... @@ -38,7 +42,11 @@ import com.trash.activiti.service.IActTaskService;
38 42 import com.trash.activiti.service.IActWorkflowFormDataService;
39 43 import com.trash.activiti.service.myTaskService;
40 44 import com.trash.common.core.page.PageDomain;
  45 +import com.trash.common.utils.RemoteServerUtils;
  46 +import com.trash.common.utils.RouteUtils;
41 47 import com.trash.common.utils.SecurityUtils;
  48 +import com.trash.common.utils.ServletUtils;
  49 +import com.trash.common.utils.spring.SpringUtils;
42 50  
43 51 @Service
44 52 public class ActTaskServiceImpl implements IActTaskService {
... ... @@ -54,9 +62,11 @@ public class ActTaskServiceImpl implements IActTaskService {
54 62  
55 63 @Autowired
56 64 private RuntimeService runtimeService;
  65 +
57 66 @Autowired
58 67 private IActWorkflowFormDataService actWorkflowFormDataService;
59 68  
  69 +
60 70 @Autowired
61 71 private ActReDeploymentMapper actMapper;
62 72  
... ... @@ -69,17 +79,21 @@ public class ActTaskServiceImpl implements IActTaskService {
69 79 HistoricProcessInstanceQuery processInstanceQuery;
70 80  
71 81  
72   -
73 82 @Override
74 83 public Page<ActTaskDTO> selectProcessDefinitionList(PageDomain pageDomain) {
75 84 Page<ActTaskDTO> list = new Page<ActTaskDTO>();
76 85  
77   -// List<String> posts = new ArrayList<>();
78   -// posts.add("4");
79   -// SecurityUtils.getLoginUser().getUser().setPostIds(posts);
80   -// List<String> roles = new ArrayList<>();
81   -// posts.add("7");
82   -// SecurityUtils.getLoginUser().getUser().setRoleIds(roles);
  86 +
  87 + if(ServletUtils.getParameter("role") != null){
  88 + List<String> posts = new ArrayList<>();
  89 + posts.add(ServletUtils.getParameter("role"));
  90 + SecurityUtils.getLoginUser().getUser().setPostIds(posts);
  91 + }
  92 + if(ServletUtils.getParameter("dept") != null){
  93 + List<String> roles = new ArrayList<>();
  94 + roles.add(ServletUtils.getParameter("dept"));
  95 + SecurityUtils.getLoginUser().getUser().setRoleIds(roles);
  96 + }
83 97  
84 98 org.activiti.api.runtime.shared.query.Page<Task> pageTasks = taskRuntime.tasks(Pageable.of((pageDomain.getPageNum() - 1) * pageDomain.getPageSize(), pageDomain.getPageSize()));
85 99  
... ... @@ -218,9 +232,13 @@ public class ActTaskServiceImpl implements IActTaskService {
218 232 @Override
219 233 public int formDataSave(String taskID, List<ActWorkflowFormDataDTO> awfs) throws ParseException {
220 234 Task task = taskRuntime.task(taskID);
  235 +
  236 +
221 237 ProcessInstance processInstance = runtimeService.createProcessInstanceQuery()
222 238 .processInstanceId(task.getProcessInstanceId()).singleResult();
223   -
  239 +
  240 + String desc = taskService.createTaskQuery().processInstanceId(processInstance.getId()).singleResult().getDescription();
  241 +
224 242 Boolean hasVariables = false;// 没有任何参数
225 243 HashMap<String, Object> variables = new HashMap<String, Object>();
226 244 // 前端传来的字符串,拆分成每个控件
... ... @@ -246,14 +264,56 @@ public class ActTaskServiceImpl implements IActTaskService {
246 264 }
247 265  
248 266  
249   - List<org.activiti.engine.task.Task> tasks = taskService.createTaskQuery().processInstanceId(processInstance.getId()).list(); //测试 当前用户为审批用户
250   -
251   -
  267 + updateThreesetpTask(processInstance,desc);
  268 +
  269 +
252 270  
253 271 // 写入数据库
254 272 return actWorkflowFormDataService.insertActWorkflowFormDatas(acwfds);
255 273 }
256 274  
  275 +
  276 +
  277 + private void updateThreesetpTask(ProcessInstance processInstance, String placeCode) {
  278 +
  279 + org.activiti.engine.task.Task task = taskService.createTaskQuery().processInstanceId(processInstance.getId()).singleResult();
  280 +
  281 + if(task == null)
  282 + return;
  283 +
  284 + task.setDescription(placeCode);
  285 +
  286 + if(processInstance.getProcessDefinitionKey().equals("workflow_threestep") ){
  287 + if(task.getName().equals("巡查")){
  288 + List<IdentityLink> list = taskService.getIdentityLinksForTask(task.getId());
  289 +
  290 + for(IdentityLink identityLink:list){
  291 +// if(identityLink.getGroupId() != null)
  292 +// taskService.deleteGroupIdentityLink(task.getId(), identityLink.getGroupId(), identityLink.getType());
  293 + if(identityLink.getUserId() != null)
  294 + taskService.deleteUserIdentityLink(task.getId(), identityLink.getUserId(), identityLink.getType());
  295 + }
  296 +
  297 + taskService.addCandidateUser(task.getId(), placeCode);
  298 +
  299 + task.setDescription(placeCode);
  300 + }
  301 + }else if(processInstance.getProcessDefinitionKey().equals("workflow_leave") ){
  302 + List<IdentityLink> list = taskService.getIdentityLinksForTask(task.getId());
  303 +
  304 + if(list.size() == 1){
  305 + taskService.addCandidateUser(task.getId(), placeCode);
  306 + }
  307 +
  308 +
  309 + task.setDescription(placeCode);
  310 + }
  311 +
  312 + taskService.saveTask(task);
  313 +
  314 + }
  315 +
  316 +
257 317 @Override
258 318 public void deleteProcessById(String type) {
259 319 runtimeService.deleteProcessInstance(type, "删除");
... ...
trash-admin/src/main/resources/application-dev.yml
... ... @@ -27,8 +27,7 @@ spring:
27 27 master:
28 28 url: jdbc:mysql://localhost:3306/trash?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&nullCatalogMeansCurrent=true
29 29 username: root
30   -# password: root
31   - password: asd0731.
  30 + password: root
32 31 # 从库数据源
33 32 slave:
34 33 # 从数据源开关/默认关闭
... ... @@ -82,7 +81,7 @@ spring:
82 81 # 端口,默认为6379
83 82 port: 6379
84 83 # 密码
85   - password: bsth123
  84 + password:
86 85 # 连接超时时间
87 86 timeout: 10s
88 87 database: 10
... ...
trash-ui/src/views/activiti/task/index.vue
1 1 <template>
2 2 <div class="app-container">
  3 + <el-select v-model="queryParams.dept" filterable clearable reserve-keyword @change="getList">
  4 + <el-option v-for="item in depts" :label="item.name"
  5 + :value="item.code" :key="item.code" >
  6 + </el-option>
  7 + </el-select>
  8 + <el-select v-model="queryParams.role" filterable clearable reserve-keyword @change="getList">
  9 + <el-option v-for="item in roles" :label="item.name"
  10 + :value="item.code" :key="item.code" >
  11 + </el-option>
  12 + </el-select>
  13 +
3 14  
4 15 <taskCard :task="task" v-for="task in taskList" @sendToParent="showTask" />
5 16  
... ... @@ -246,6 +257,8 @@
246 257 queryParams: {
247 258 pageNum: 1,
248 259 pageSize: 10,
  260 + role:null,
  261 + dept:null,
249 262 },
250 263 // 表单参数
251 264 form: {
... ... @@ -281,12 +294,24 @@
281 294 conferenceOpen: false,
282 295 idInfo:null,
283 296 leaveApplicationOpen:false,
284   - areas:{},
  297 + areas:[],
285 298 roles:[],
286   - depts:{},
  299 + depts:[],
287 300 };
288 301 },
289 302 created() {
  303 + let dep = {type:"CSUserDepartmentType"};
  304 +
  305 + getDict(dep).then(res=>{
  306 + this.depts = res.result;
  307 + });
  308 +
  309 + let role = {type:"CSUserPostType"};
  310 +
  311 + getDict(role).then(res=>{
  312 + this.roles = res.result;
  313 + });
  314 +
290 315 this.getList();
291 316 },
292 317 methods: {
... ...
trash-workFlow/src/main/java/com/trash/workflow/service/IWorkflowService.java
... ... @@ -3,6 +3,8 @@ package com.trash.workflow.service;
3 3 import java.util.List;
4 4 import java.util.Map;
5 5  
  6 +import org.activiti.api.process.model.ProcessInstance;
  7 +
6 8 import com.trash.activiti.domain.dto.HistoryDataDTO;
7 9 import com.trash.business.domain.SupervisionThreestep;
8 10 import com.trash.workflow.domain.Workflow;
... ... @@ -77,7 +79,10 @@ public interface IWorkflowService
77 79 int createLeaveWorkFlow(Workflow workflow,int index);
78 80  
79 81 Workflow selectWorkflowByInstanceId(String instanceId);
  82 +
80 83 int createThreeStepWorkFlow(SupervisionThreestep supervision);
81 84  
82 85 public void deleteWorkflowByName(String string);
  86 +
  87 + public void PorcThreeStepTask(String pId,String place);
83 88 }
... ...
trash-workFlow/src/main/java/com/trash/workflow/service/impl/WorkflowServiceImpl.java
... ... @@ -22,6 +22,7 @@ import org.springframework.transaction.annotation.Transactional;
22 22 import com.alibaba.fastjson.JSONArray;
23 23 import com.alibaba.fastjson.JSONObject;
24 24 import com.trash.business.domain.SupervisionThreestep;
  25 +import com.trash.business.service.ISupervisionThreestepService;
25 26 import com.trash.common.utils.DateUtils;
26 27 import com.trash.common.utils.RemoteServerUtils;
27 28 import com.trash.common.utils.SecurityUtils;
... ... @@ -60,9 +61,12 @@ public class WorkflowServiceImpl implements IWorkflowService {
60 61 @Autowired
61 62 RuntimeService runTImeService;
62 63  
  64 + @Autowired
  65 + ISupervisionThreestepService server;
  66 +
63 67 @Override
64 68 @Transactional
65   - public int createWorkFlow(Map<String, Object> data) {
  69 + public int createWorkFlow(Map<String, Object> data) { //第三方通用接收接口
66 70  
67 71 String flowType = data.get("type").toString();
68 72  
... ... @@ -82,12 +86,6 @@ public class WorkflowServiceImpl implements IWorkflowService {
82 86 processInstance = processRuntime.start(ProcessPayloadBuilder.start().withProcessDefinitionKey(flowType)
83 87 .withName(title).withBusinessKey(businessKey).build());
84 88  
85   - // Task task =
86   - // taskService.createTaskQuery().processInstanceId(processInstance.getId()).singleResult();
87   - //
88   - // task.setAssignee(SecurityUtils.getUsername());
89   - //
90   - // taskService.saveTask(task);
91 89  
92 90 Workflow workflow = new Workflow();
93 91 workflow.setId(businessKey);
... ... @@ -125,19 +123,18 @@ public class WorkflowServiceImpl implements IWorkflowService {
125 123 .withBusinessKey("workflow_leave:"+workflow.getId())
126 124 .withVariable("route",index)
127 125 .build());
  126 +
  127 +
  128 + Task task = taskService.createTaskQuery().processInstanceId(processInstance.getId()).singleResult();
  129 +
  130 + if(task != null){
  131 +
  132 + task.setDescription(SecurityUtils.getLoginUser().getUser().getRoleIds().get(0));
  133 + taskService.saveTask(task);
  134 + }
  135 +
128 136  
129   -
130   -
131   -
132   -// Workflow workflow = new Workflow();
133   -// workflow.setId(businessKey);
134   -// workflow.setTitle(title);
135   -// workflow.setReason(reason);
136   -// workflow.setStartTime(startTime);
137   -// workflow.setEndTime(endTime);
138   -// workflow.setType(siteType[Integer.parseInt(map.get("type").toString())]);
139 137 workflow.setInstanceId(processInstance.getId());
140   -// workflow.setState("0");
141 138  
142 139 return workflowMapper.insertWorkflow(workflow);
143 140 } catch (Exception e) {
... ... @@ -152,7 +149,7 @@ public class WorkflowServiceImpl implements IWorkflowService {
152 149  
153 150 @Override
154 151 @Transactional
155   - public int createThreeStepWorkFlow(SupervisionThreestep supervision){
  152 + public int createThreeStepWorkFlow(SupervisionThreestep supervision){ //三查
156 153 ProcessInstance processInstance = null;
157 154 try {
158 155 processInstance = processRuntime.start(ProcessPayloadBuilder
... ... @@ -162,66 +159,7 @@ public class WorkflowServiceImpl implements IWorkflowService {
162 159 .withBusinessKey("workflow_threestep:" + supervision.getId())
163 160 .build());
164 161  
165   - JSONArray array = RemoteServerUtils.getAreas();
166   -
167   - Map map = new HashedMap<>();
168   -
169   - map.put("type", "CSUserDepartmentType");
170   -
171   - JSONArray array2 = RemoteServerUtils.getDict(map);
172   -
173   - String placeName = null;
174   -
175   - for(Object obj:array){
176   - if(((JSONObject)(obj)).getString("code").equals(supervision.getPlace())){
177   -
178   - placeName = ((JSONObject)(obj)).getString("name");
179   -
180   - break;
181   - }
182   -
183   - }
184   -
185   - if(placeName != null){
186   -
187   - String placeCode = null;
188   - String code = null;
189   -
190   - for(Object obj:array2){
191   - if(((JSONObject)obj).getString("name").equals("渣土办")){
192   - code = ((JSONObject)(obj)).getString("code");
193   - }
194   - if(((JSONObject)obj).getString("name").replace("渣土办", "").equals(placeName)){
195   - placeCode = ((JSONObject)(obj)).getString("code");
196   -
197   - if(code != null){
198   - break;
199   - }
200   - }
201   -
202   - }
203   -
204   -
205   -// List<Task> tasks = taskService.createTaskQuery().processInstanceId(processInstance.getId()).list();
206   -
207   - if(placeCode != null){
208   - Task task = taskService.createTaskQuery().processInstanceId(processInstance.getId()).singleResult();
209   -
210   -
211   - List<IdentityLink> list = taskService.getIdentityLinksForTask(task.getId());
212   -
213   - for(IdentityLink identityLink:list){
214   -// if(identityLink.getGroupId() != null)
215   -// taskService.deleteGroupIdentityLink(task.getId(), identityLink.getGroupId(), identityLink.getType());
216   - if(identityLink.getUserId() != null)
217   - taskService.deleteUserIdentityLink(task.getId(), identityLink.getUserId(), identityLink.getType());
218   - }
219   -
220   - taskService.addCandidateUser(task.getId(), placeCode);
221   -
222   - taskService.saveTask(task);
223   - }
224   - }
  162 + PorcThreeStepTask(processInstance,supervision.getPlace());
225 163  
226 164  
227 165 Workflow workflow = new Workflow();
... ... @@ -242,6 +180,73 @@ public class WorkflowServiceImpl implements IWorkflowService {
242 180  
243 181 return 0;
244 182 }
  183 +
  184 +
  185 +
  186 + public void PorcThreeStepTask(ProcessInstance processInstance,String place) {
  187 +
  188 + JSONArray array = RemoteServerUtils.getAreas();
  189 +
  190 + Map map = new HashedMap<>();
  191 +
  192 + map.put("type", "CSUserDepartmentType");
  193 +
  194 + JSONArray array2 = RemoteServerUtils.getDict(map);
  195 +
  196 + String placeName = null;
  197 +
  198 + for(Object obj:array){
  199 + if(((JSONObject)(obj)).getString("code").equals(place)){
  200 +
  201 + placeName = ((JSONObject)(obj)).getString("name");
  202 +
  203 + break;
  204 + }
  205 +
  206 + }
  207 +
  208 + if(placeName != null){
  209 +
  210 + String placeCode = null;
  211 + String code = null;
  212 +
  213 + for(Object obj:array2){
  214 + if(((JSONObject)obj).getString("name").equals("渣土办")){
  215 + code = ((JSONObject)(obj)).getString("code");
  216 + }
  217 + if(((JSONObject)obj).getString("name").replace("渣土办", "").equals(placeName)){
  218 + placeCode = ((JSONObject)(obj)).getString("code");
  219 +
  220 + if(code != null){
  221 + break;
  222 + }
  223 + }
  224 +
  225 + }
  226 +
  227 + if(placeCode != null){
  228 + Task task = taskService.createTaskQuery().processInstanceId(processInstance.getId()).singleResult();
  229 +
  230 +
  231 + List<IdentityLink> list = taskService.getIdentityLinksForTask(task.getId());
  232 +
  233 + for(IdentityLink identityLink:list){
  234 +// if(identityLink.getGroupId() != null)
  235 +// taskService.deleteGroupIdentityLink(task.getId(), identityLink.getGroupId(), identityLink.getType());
  236 + if(identityLink.getUserId() != null)
  237 + taskService.deleteUserIdentityLink(task.getId(), identityLink.getUserId(), identityLink.getType());
  238 + }
  239 +
  240 + taskService.addCandidateUser(task.getId(), placeCode);
  241 +
  242 + task.setDescription(placeCode);
  243 +
  244 + taskService.saveTask(task);
  245 + }
  246 + }
  247 +
  248 + }
  249 +
245 250  
246 251 /**
247 252 * 查询请假
... ... @@ -365,4 +370,11 @@ public class WorkflowServiceImpl implements IWorkflowService {
365 370  
366 371 return workflowMapper.selectWorkflowByInstanceId(instanceId);
367 372 }
  373 +
  374 +
  375 + @Override
  376 + public void PorcThreeStepTask(String pId, String place) {
  377 + // TODO Auto-generated method stub
  378 +
  379 + }
368 380 }
... ...