|
@@ -39,25 +39,29 @@ public class ApprovalTaskServiceImpl implements ApprovalTaskService {
|
|
|
|
|
|
@Override
|
|
|
public Map<String, Object> salesmanSubmitApply(int type) {
|
|
|
+ // type = 1表示生产订单审批;type = 2表示提货申请审批
|
|
|
Map<String, Object> result = new HashMap<>(4);
|
|
|
result.put("status", 1);
|
|
|
// 使用流程定义的key启动流程实例
|
|
|
ProcessInstance pi = runtimeService.startProcessInstanceByKey(type == 1 ? GENERATION_APPROVAL_KEY : APPLICATION_FOR_DELIVERY_KEY);
|
|
|
- // 因为第一个审批节点为用户自己,所以默认启动并通过第一个审批流程
|
|
|
+ // 寻找第一个审批任务,如果不存在表示审批结束
|
|
|
Task task = taskService.createTaskQuery().processInstanceId(pi.getId()).singleResult();
|
|
|
if (task == null) {
|
|
|
result.put("status", 0);
|
|
|
result.put("key", pi.getId());
|
|
|
return result;
|
|
|
}
|
|
|
+ // 执行第一个审批流程,标记为完成
|
|
|
taskService.complete(task.getId());
|
|
|
- // 寻找下一个审批人
|
|
|
+ // 寻找下一个审批人(0 - n 个)
|
|
|
Map<String, Object> approver = findTaskNextAssignee(pi.getId());
|
|
|
if (approver == null) {
|
|
|
+ // 如果没有审批人时,表示审批结束
|
|
|
result.put("status", 0);
|
|
|
result.put("key", pi.getId());
|
|
|
return result;
|
|
|
}
|
|
|
+ // 返回数据
|
|
|
result.put("key", pi.getId());
|
|
|
result.put("users", approver.get("assignee"));
|
|
|
result.put("taskId", approver.get("taskId"));
|
|
@@ -70,12 +74,15 @@ public class ApprovalTaskServiceImpl implements ApprovalTaskService {
|
|
|
result.put("status", 0);
|
|
|
// 提交任务
|
|
|
taskService.complete(taskId);
|
|
|
- // 是否存在下一个审批人
|
|
|
+ // 寻找下一个审批人(0 - n 个)
|
|
|
Map<String, Object> approver = findTaskNextAssignee(pid);
|
|
|
if (approver == null) {
|
|
|
+ // 不存在下一个审批人,表示审批结束
|
|
|
result.put("status", 1);
|
|
|
return result;
|
|
|
}
|
|
|
+
|
|
|
+ // 返回数据
|
|
|
result.put("users", approver.get("assignee"));
|
|
|
result.put("taskId", approver.get("taskId"));
|
|
|
return result;
|
|
@@ -93,11 +100,12 @@ public class ApprovalTaskServiceImpl implements ApprovalTaskService {
|
|
|
*/
|
|
|
private Map<String, Object> findTaskNextAssignee(String pid) {
|
|
|
Map<String, Object> result = new HashMap<>(2);
|
|
|
- // 搜索当前实例的待处理信息
|
|
|
+ // 搜索当前实例的待处理任务
|
|
|
Task nextTask = taskService.createTaskQuery().processInstanceId(pid).singleResult();
|
|
|
if (nextTask == null) {
|
|
|
return null;
|
|
|
}
|
|
|
+ // 在BMPN中,通过&分割多个审批人
|
|
|
String assignee = nextTask.getAssignee();
|
|
|
if (assignee.contains(SPLIT_ASSIGNEE_CHAR)) {
|
|
|
result.put("taskId", nextTask.getId());
|
|
@@ -105,7 +113,7 @@ public class ApprovalTaskServiceImpl implements ApprovalTaskService {
|
|
|
return result;
|
|
|
}
|
|
|
result.put("taskId", nextTask.getId());
|
|
|
- result.put("assignee", assignee);
|
|
|
+ result.put("assignee", new String[]{assignee});
|
|
|
return result;
|
|
|
}
|
|
|
}
|