增加tenantId和触发器默认的id和获取右边流程详情更新最新版
This commit is contained in:
parent
6403d548f7
commit
cc5fff0bde
@ -51,5 +51,7 @@ public class WflowModelHistorys implements Serializable {
|
||||
|
||||
private String logo;
|
||||
|
||||
private String tenantId;
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -1,6 +1,9 @@
|
||||
package com.wflow.workflow.bean.vo;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@ -9,6 +12,9 @@ import java.util.Map;
|
||||
* @date : 2023/11/10
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class ProcessConditionResolveParamsVo {
|
||||
//流程定义ID
|
||||
private String processDfId;
|
||||
|
||||
@ -27,7 +27,6 @@ import com.wflow.workflow.bean.vo.*;
|
||||
import com.wflow.workflow.config.WflowGlobalVarDef;
|
||||
import com.wflow.workflow.extension.cmd.RecallToHisApprovalNodeCmd;
|
||||
import com.wflow.workflow.service.*;
|
||||
import com.wflow.workflow.service.FormService;
|
||||
import com.wflow.workflow.utils.FlowableUtils;
|
||||
import com.zhgd.xmgl.tenant.TenantContextHolder;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@ -38,16 +37,13 @@ import org.flowable.common.engine.impl.identity.Authentication;
|
||||
import org.flowable.engine.*;
|
||||
import org.flowable.engine.delegate.DelegateExecution;
|
||||
import org.flowable.engine.history.HistoricProcessInstance;
|
||||
import org.flowable.engine.history.HistoricProcessInstanceQuery;
|
||||
import org.flowable.engine.impl.persistence.entity.ExecutionEntity;
|
||||
import org.flowable.engine.impl.util.ExecutionGraphUtil;
|
||||
import org.flowable.engine.repository.ProcessDefinition;
|
||||
import org.flowable.engine.runtime.ActivityInstance;
|
||||
import org.flowable.engine.runtime.Execution;
|
||||
import org.flowable.engine.runtime.ProcessInstance;
|
||||
import org.flowable.engine.runtime.ProcessInstanceQuery;
|
||||
import org.flowable.task.api.Task;
|
||||
import org.flowable.task.api.TaskInfo;
|
||||
import org.flowable.task.api.TaskQuery;
|
||||
import org.flowable.task.api.history.HistoricTaskInstance;
|
||||
import org.flowable.task.service.history.NativeHistoricTaskInstanceQuery;
|
||||
@ -55,7 +51,6 @@ import org.flowable.variable.api.history.HistoricVariableInstance;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.transaction.interceptor.TransactionAspectSupport;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
@ -479,7 +474,8 @@ public class ProcessTaskServiceImpl implements ProcessTaskService {
|
||||
log.info("获取节点[{}]的审批人", execution.getActivityId());
|
||||
Map propsMap = execution.getVariable(WflowGlobalVarDef.WFLOW_NODE_PROPS, Map.class);
|
||||
ApprovalProps props = (ApprovalProps) propsMap.get(execution.getActivityId());
|
||||
List<String> approvalUsers = getApprovalUsers(execution, props);
|
||||
WflowModels wflowModels = wflowModelsMapper.selectById(execution.getProcessDefinitionKey());
|
||||
List<String> approvalUsers = getApprovalUsers(execution.getProcessInstanceId(), execution.getActivityId(), props, wflowModels.getTenantId());
|
||||
taskCache.put(execution.getProcessInstanceId() + execution.getActivityId(), approvalUsers);
|
||||
return approvalUsers;
|
||||
}
|
||||
@ -552,16 +548,14 @@ public class ProcessTaskServiceImpl implements ProcessTaskService {
|
||||
/**
|
||||
* 获取审批人
|
||||
*
|
||||
* @param execution 上下文
|
||||
* @param props 节点熟悉
|
||||
* @param tenantId
|
||||
* @return 审批人ID列表
|
||||
*/
|
||||
public List<String> getApprovalUsers(ExecutionEntity execution, ApprovalProps props) {
|
||||
WflowModels wflowModels = wflowModelsMapper.selectById(execution.getProcessDefinitionKey());
|
||||
String userId = execution.getStartUserId();
|
||||
userId = StrUtil.isNotBlank(userId) ? userId : execution.getParent().getStartUserId();
|
||||
String deptId = execution.getVariable("startDept", String.class);
|
||||
deptId = StrUtil.isNotBlank(deptId) ? deptId : execution.getVariable("owner", ProcessInstanceOwnerDto.class).getOwnerDeptId();
|
||||
public List<String> getApprovalUsers(String instanceId, String nodeId, ApprovalProps props, String tenantId) {
|
||||
String userId = runtimeService.getVariable(instanceId, WflowGlobalVarDef.INITIATOR, String.class);
|
||||
String deptId = runtimeService.getVariable(instanceId, WflowGlobalVarDef.START_DEPT, String.class);
|
||||
deptId = StrUtil.isNotBlank(deptId) ? deptId : runtimeService.getVariable(instanceId, WflowGlobalVarDef.OWNER, ProcessInstanceOwnerDto.class).getOwnerDeptId();;
|
||||
Set<String> userSet = new LinkedHashSet<>();
|
||||
switch (props.getAssignedType()) {
|
||||
case REFUSE:
|
||||
@ -571,16 +565,16 @@ public class ProcessTaskServiceImpl implements ProcessTaskService {
|
||||
userSet.add(userId);
|
||||
break;
|
||||
case ROLE: //取角色
|
||||
userSet.addAll(userDeptOrLeaderService.getUsersByRoles(props.getRole().stream().map(OrgUser::getId).collect(Collectors.toList()), wflowModels.getTenantId()));
|
||||
userSet.addAll(userDeptOrLeaderService.getUsersByRoles(props.getRole().stream().map(OrgUser::getId).collect(Collectors.toList()), tenantId));
|
||||
break;
|
||||
case FORM_USER: //从表单取
|
||||
List<Map<String, Object>> userList = execution.getVariable(props.getFormUser(), List.class);
|
||||
List<Map<String, Object>> userList = runtimeService.getVariable(instanceId, props.getFormUser(), List.class);
|
||||
Optional.ofNullable(userList).ifPresent(users -> {
|
||||
userSet.addAll(users.stream().map(u -> u.get("id").toString()).collect(Collectors.toList()));
|
||||
});
|
||||
break;
|
||||
case FORM_DEPT: //从表单取
|
||||
List<Map<String, Object>> deptList = execution.getVariable(props.getFormDept(), List.class);
|
||||
List<Map<String, Object>> deptList = runtimeService.getVariable(instanceId, props.getFormDept(), List.class);
|
||||
Optional.ofNullable(deptList).ifPresent(users -> {
|
||||
userSet.addAll(userDeptOrLeaderService.getLeadersByDept(
|
||||
users.stream().map(u -> u.get("id").toString()).collect(Collectors.toList())));
|
||||
@ -594,7 +588,7 @@ public class ProcessTaskServiceImpl implements ProcessTaskService {
|
||||
userSet.addAll(userDeptOrLeaderService.getLeadersByDept(collect));
|
||||
break;
|
||||
case SELF_SELECT: //自选用户,从变量取,这一步在发起流程时设置的
|
||||
List<OrgUser> selectUsers = execution.getVariable(execution.getActivityId(), List.class);
|
||||
List<OrgUser> selectUsers = runtimeService.getVariable(instanceId, nodeId, List.class);
|
||||
Optional.ofNullable(selectUsers).ifPresent(on -> userSet.addAll(on.stream().map(OrgUser::getId).collect(Collectors.toList())));
|
||||
break;
|
||||
case LEADER: //用户的指定级别部门主管
|
||||
@ -616,7 +610,7 @@ public class ProcessTaskServiceImpl implements ProcessTaskService {
|
||||
userSet.addAll(props.getNobody().getAssignedUser().stream().map(OrgUser::getId).collect(Collectors.toList()));
|
||||
break;
|
||||
case TO_ADMIN: //TODO 注意系统需要包含该角色 WFLOW_APPROVAL_ADMIN
|
||||
userSet.addAll(userDeptOrLeaderService.getUsersByRoles(CollectionUtil.newArrayList(WflowGlobalVarDef.WFLOW_APPROVAL_ADMIN), wflowModels.getTenantId()));
|
||||
userSet.addAll(userDeptOrLeaderService.getUsersByRoles(CollectionUtil.newArrayList(WflowGlobalVarDef.WFLOW_APPROVAL_ADMIN), tenantId));
|
||||
break;
|
||||
case TO_PASS:
|
||||
userSet.add(WflowGlobalVarDef.WFLOW_TASK_AGRRE);
|
||||
|
||||
@ -119,12 +119,16 @@ public class TriggerServiceTask implements JavaDelegate {
|
||||
String.valueOf(variables.getOrDefault(String.valueOf(hd.getValue()), ""))
|
||||
: getStrByRegex(String.valueOf(hd.getValue()), variables));
|
||||
});
|
||||
request.form("dfInstanceId", execution.getProcessInstanceId());
|
||||
request.form("dfNodeId", execution.getCurrentActivityId());
|
||||
} else {
|
||||
request.body(JSONObject.toJSONString(http.getParams().stream().filter(o -> o != null && o.getName() != null && !"".equals(o.getName()))
|
||||
.collect(Collectors.toMap(TriggerProps.Http.Variable::getName,
|
||||
v -> v.getIsField() ? variables.getOrDefault(String.valueOf(v.getValue()), "")
|
||||
: getStrByRegex(String.valueOf(v.getValue()), variables))))
|
||||
, "application/json");
|
||||
Map<String, Object> m = http.getParams().stream().filter(o -> o != null && o.getName() != null && !"".equals(o.getName()))
|
||||
.collect(Collectors.toMap(TriggerProps.Http.Variable::getName,
|
||||
v -> v.getIsField() ? variables.getOrDefault(String.valueOf(v.getValue()), "")
|
||||
: getStrByRegex(String.valueOf(v.getValue()), variables)));
|
||||
m.put("dfInstanceId", execution.getProcessInstanceId());
|
||||
m.put("dfNodeId", execution.getCurrentActivityId());
|
||||
request.body(JSONObject.toJSONString(m), "application/json");
|
||||
}
|
||||
HttpResponse response = request.timeout(10000).executeAsync();
|
||||
if (response.isOk()) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user