|
@@ -5,8 +5,11 @@ import com.flow.common.core.util.ApplicationContextUtil;
|
|
|
import com.flow.common.oauth2.utils.SecurityContextUtil;
|
|
|
import com.flow.entity.User;
|
|
|
import com.flow.enums.AssigneeTypeEnum;
|
|
|
+import com.flow.enums.OrganizationTypeEnum;
|
|
|
+import com.flow.service.DeptService;
|
|
|
import com.flow.service.RoleService;
|
|
|
import com.flow.service.UserService;
|
|
|
+import com.google.common.collect.Lists;
|
|
|
import lombok.Data;
|
|
|
import lombok.EqualsAndHashCode;
|
|
|
import org.flowable.bpmn.model.FlowElement;
|
|
@@ -27,6 +30,12 @@ public abstract class AssigneeNode extends Node {
|
|
|
private List<String> users;
|
|
|
// 审批人角色
|
|
|
private List<String> roles;
|
|
|
+ // 组织
|
|
|
+ private List<String> organizations;
|
|
|
+ // 表单内组织
|
|
|
+ private String formOrganization;
|
|
|
+ // 组织办理类型
|
|
|
+ private OrganizationTypeEnum organizationType;
|
|
|
// 主管
|
|
|
private Integer leader;
|
|
|
// 组织主管
|
|
@@ -41,6 +50,7 @@ public abstract class AssigneeNode extends Node {
|
|
|
public List<String> getAssignees(Map<String, Object> values) {
|
|
|
UserService userService = ApplicationContextUtil.getBean(UserService.class);
|
|
|
RoleService roleService = ApplicationContextUtil.getBean(RoleService.class);
|
|
|
+ DeptService deptService = ApplicationContextUtil.getBean(DeptService.class);
|
|
|
String userId = SecurityContextUtil.getUserId();
|
|
|
List<String> assignees = new ArrayList<>();
|
|
|
switch (this.assigneeType) {
|
|
@@ -94,6 +104,45 @@ public abstract class AssigneeNode extends Node {
|
|
|
assignees.add(leader.getUsername());
|
|
|
}
|
|
|
break;
|
|
|
+ case ORG:
|
|
|
+ OrganizationTypeEnum organizationTypeEnum = this.getOrganizationType();
|
|
|
+ List<User> leaderList = Lists.newArrayList();
|
|
|
+ if (organizationTypeEnum == OrganizationTypeEnum.LEADER) {
|
|
|
+ leaderList = deptService.getLeader(this.getOrganizations());
|
|
|
+ }
|
|
|
+ if (organizationTypeEnum == OrganizationTypeEnum.ALL) {
|
|
|
+ leaderList = deptService.getUsers(this.getOrganizations());
|
|
|
+ }
|
|
|
+ if (CollectionUtils.isNotEmpty(leaderList)) {
|
|
|
+ List<String> userIds = leaderList.stream().map(User::getUsername).collect(Collectors.toList());
|
|
|
+ assignees.addAll(userIds);
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case FORM_ORG:
|
|
|
+ Object formOrg = values.get(this.getFormOrganization());
|
|
|
+ if (Objects.nonNull(formOrg)) {
|
|
|
+ ArrayList<String> orgIds = new ArrayList<>();
|
|
|
+ if (formOrg instanceof Collection) {
|
|
|
+ orgIds.addAll((Collection<? extends String>) formOrg);
|
|
|
+ } else {
|
|
|
+ orgIds.add(formOrg.toString());
|
|
|
+ }
|
|
|
+ OrganizationTypeEnum organizationType = this.getOrganizationType();
|
|
|
+ List<User> userList = Lists.newArrayList();
|
|
|
+ if (organizationType == OrganizationTypeEnum.LEADER) {
|
|
|
+ userList = deptService.getLeader(this.getOrganizations());
|
|
|
+ }
|
|
|
+ if (organizationType == OrganizationTypeEnum.ALL) {
|
|
|
+ userList = deptService.getUsers(this.getOrganizations());
|
|
|
+ }
|
|
|
+ if (CollectionUtils.isNotEmpty(userList)) {
|
|
|
+ List<String> userIds = userList.stream()
|
|
|
+ .map(User::getUsername)
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ assignees.addAll(userIds);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ break;
|
|
|
case ORG_LEADER:
|
|
|
User orgLeader = userService.getOrgLeader(userId, this.orgLeader);
|
|
|
if (Objects.nonNull(orgLeader)) {
|