UserScript.java 20.6 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559
package com.hotent.runtime.script;

import java.util.ArrayList;
import java.util.HashSet;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.HashMap;
import javax.annotation.Resource;
import java.util.StringJoiner;

import cn.hutool.core.util.BooleanUtil;
import org.springframework.stereotype.Component;
import org.springframework.util.Assert;
import com.hotent.base.exception.BaseException;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.node.ArrayNode;
import com.fasterxml.jackson.databind.node.ObjectNode;
import com.hotent.activiti.ext.model.BpmDelegateTaskImpl;
import com.hotent.base.feign.UCFeignService;
import com.hotent.base.groovy.IUserScript;
import com.hotent.base.query.QueryFilter;
import com.hotent.base.query.QueryOP;
import com.hotent.base.util.BeanUtils;
import com.hotent.base.util.JsonUtil;
import com.hotent.base.util.StringUtil;
import com.hotent.base.util.UniqueIdUtil;
import com.hotent.base.util.time.TimeUtil;
import com.hotent.bpm.api.cmd.ActionCmd;
import com.hotent.bpm.api.constant.BpmConstants;
import com.hotent.bpm.api.constant.ExtractType;
import com.hotent.bpm.api.context.ContextThreadUtil;
import com.hotent.bpm.api.helper.identity.BpmIdentityConverter;
import com.hotent.bpm.api.model.form.FormType;
import com.hotent.bpm.api.model.identity.BpmIdentity;
import com.hotent.bpm.model.identity.DefaultBpmIdentity;
import com.hotent.bpm.persistence.manager.BpmDefUserManager;
import com.hotent.bpm.persistence.manager.BpmProcessInstanceManager;
import com.hotent.runtime.manager.IFlowManager;
import com.hotent.runtime.manager.MeetingRoomAppointmentManager;
import com.hotent.runtime.manager.MeetingRoomManager;
import com.hotent.runtime.model.MeetingRoom;
import com.hotent.runtime.model.MeetingRoomAppointment;
import com.hotent.runtime.params.InstFormAndBoVo;
import com.hotent.uc.api.constant.GroupTypeConstant;
import com.hotent.uc.api.impl.model.Org;
import com.hotent.uc.api.impl.model.UserFacade;
import com.hotent.uc.api.impl.util.ContextUtil;
import com.hotent.uc.api.model.IGroup;
import com.hotent.uc.api.model.IUser;
import com.hotent.uc.api.model.IdentityType;
import com.hotent.uc.api.service.IParamService;
import com.hotent.uc.api.service.IUserGroupService;
import com.hotent.uc.api.service.IUserService;
@Component
public class UserScript implements IUserScript {
	@Resource
	IUserService userService;
	@Resource
	BpmDefUserManager bpmDefUserManager;
	@Resource
	MeetingRoomManager meetingroomManager;
	@Resource
	MeetingRoomAppointmentManager meetingRoomAppointmentManager;
	@Resource
	BpmProcessInstanceManager bpmProcessInstanceManager;
	@Resource
	UCFeignService uCFeignService;
	@Resource
	IUserGroupService userGroupService;
	@Resource
	IParamService paramService;
	@Resource
	BpmIdentityConverter bpmIdentityConverter;
    @Resource
    IFlowManager iFlowService;

	/**
	 * 将用户列表转换成BpmIdentity列表
	 * @param list
	 * @return
	 */
	private Set<BpmIdentity> convertUserList(List<IUser> list){
		Set<BpmIdentity> identitys = new LinkedHashSet<BpmIdentity>();
		for (IUser iUser : list) {
			if(BeanUtils.isNotEmpty(iUser) && iUser.getStatus()==1){
				DefaultBpmIdentity bpmIdentity = new DefaultBpmIdentity();
				bpmIdentity.setId(iUser.getUserId());
				bpmIdentity.setName(iUser.getFullname());
				bpmIdentity.setType(BpmIdentity.TYPE_USER);
				identitys.add(bpmIdentity);
			}
		}
		return identitys;
	}

	public Set<BpmIdentity> getUser(){

		Set<BpmIdentity> set = new LinkedHashSet<BpmIdentity>();
		BpmIdentity bpmIdentity = new DefaultBpmIdentity();
		bpmIdentity.setType(IdentityType.USER);
		bpmIdentity.setId("1234");
		bpmIdentity.setName("demoUser");
		set.add(bpmIdentity);

		bpmIdentity.setId("5678");
		bpmIdentity.setName("demoUser2");
		set.add(bpmIdentity);

		return set;
	}


	/**
	 * 更新或新增预约
	 * status=0,新增,status=1.更新
	 */
	public void updateAppointMent(String hysId,BpmDelegateTaskImpl task,String meetingName,String hostessName,String appointBenTime,String appointEndTime,String status){
		MeetingRoomAppointment meetingAppoint =null;
		String meetingId=(String) task.getVariable(BpmConstants.PROCESS_INST_ID);
		try {

			if(status.equals("0")){
				meetingAppoint =new MeetingRoomAppointment();
				meetingAppoint.setId(UniqueIdUtil.getSuid());
				meetingAppoint.setMeetingroomId(hysId);
				meetingAppoint.setMeetingId(meetingId);
				meetingAppoint.setMeetingName(meetingName);
				meetingAppoint.setHostessName(hostessName);
				meetingAppoint.setAppointmentBegTime(TimeUtil.convertString(appointBenTime));
				meetingAppoint.setAppointmentEndTime(TimeUtil.convertString(appointBenTime));
				meetingAppoint.setAppointmentStatus(0);
				meetingRoomAppointmentManager.create(meetingAppoint);
			}else{
				QueryFilter queryFilter=QueryFilter.build();
				queryFilter.addFilter("MEETING_ID_", meetingId, QueryOP.EQUAL);
				List<MeetingRoomAppointment> list= meetingRoomAppointmentManager.query(queryFilter).getRows();
				meetingAppoint=list.get(0);
				meetingAppoint.setMeetingroomId(hysId);
				meetingAppoint.setMeetingId(meetingId);
				meetingAppoint.setMeetingName(meetingName);
				meetingAppoint.setHostessName(hostessName);
				meetingAppoint.setAppointmentBegTime(TimeUtil.convertString(appointBenTime));
				meetingAppoint.setAppointmentEndTime(TimeUtil.convertString(appointBenTime));
				meetingAppoint.setAppointmentStatus(1);
				meetingRoomAppointmentManager.update(meetingAppoint);
			}
		} catch (Exception e) {
		}
	}

	/**
	 * 根据会议室id获取审批人
	 * ids "12,34"
	 */
	public Set<BpmIdentity> getPendingUsersByMeetingId(String id){
		MeetingRoom meetingroom=meetingroomManager.get(id);
		String ids=meetingroom.getPendingUserId();
		Set<BpmIdentity> set=new LinkedHashSet<BpmIdentity>();
		List<IUser> iUsers = userService.getUserByAccounts(ids);
		set = convertUserList(iUsers);
		return set;
	}

	/**
	 * 根据用户账号获取审批人
	 * ids "12,34"
	 */
	public Set<BpmIdentity> getUsersByAccount(String ids){
		Set<BpmIdentity> set=new LinkedHashSet<BpmIdentity>();
		if(StringUtil.isEmpty(ids)) return set;
		List<IUser> iUsers = userService.getUserByAccounts(ids);
		set = convertUserList(iUsers);
		return set;
	}

	public String getHasRightObjs(String objType) {
		List<String> idsList = bpmDefUserManager.getAuthorizeIdsByUserMap(objType);
		return StringUtil.join(idsList.toArray(new String[]{}), ",");
	}




	/**
	 * 根据组织id查询组织作为候选处理人(不抽取)。
	 * ids "12,34"
	 */
	public Set<BpmIdentity> getOrgById(String ids){
		Set<BpmIdentity> set=new LinkedHashSet<BpmIdentity>();
		if(StringUtil.isEmpty(ids)) return set;
		String[] idsArr = ids.split(",");
		for (String id : idsArr) {
			ObjectNode org =  uCFeignService.getOrgByIdOrCode(id);
		    BpmIdentity identity=new DefaultBpmIdentity(org.get("id").asText(),org.get("name").asText(),BpmIdentity.TYPE_GROUP);
		    identity.setGroupType(BpmIdentity.GROUP_TYPE_ORG);
		    identity.setExtractType(ExtractType.EXACT_NOEXACT);
		    set.add(identity);
		}
		return set;
	}

	/**
	 * List<BoData> + key
	 * type:"org","role","user"
	 * mainKey
	 * @return
	 */
	public Set<BpmIdentity> getUserById(String mainKey) {
		Set<BpmIdentity> set = new LinkedHashSet<BpmIdentity>();
		if (BeanUtils.isNotEmpty(mainKey)) {
			String[] idsArr = mainKey.split(",");
			for (String userId : idsArr) {
				UserFacade user = (UserFacade) userService.getUserById(userId);
				if (BeanUtils.isNotEmpty(user) && user.getStatus()==1) {
					BpmIdentity bpmIdentity = new DefaultBpmIdentity();
					bpmIdentity.setType(IdentityType.USER);
					bpmIdentity.setId(user.getId());
					bpmIdentity.setName(user.getFullname());
					set.add(bpmIdentity);
				}
			}
		}
		return set;
	}

	/**
	 * 获取组织负责人(根据组织参数获取)
	 * @param orgId 组织ID
	 * @param alias 组织参数别名
	 * @return
	 */
	public Set<BpmIdentity> getLeanderByOrgId(String orgId, String alias){
		if(StringUtil.isEmpty(orgId)||StringUtil.isEmpty(alias)) return new LinkedHashSet<BpmIdentity>();
		IGroup group = userGroupService.getGroupByIdOrCode(GroupTypeConstant.ORG.key(), orgId);
		if(BeanUtils.isEmpty(group) || !(group instanceof Org)) {
			return new LinkedHashSet<BpmIdentity>();
		}
		String value = paramService.getParamByGroup(group.getGroupId(), alias)+"";
		List<IUser> list = new ArrayList<IUser>();
		IUser iUser = userService.getUserById(value);
		list.add(iUser);
		List<BpmIdentity> listIdentity = bpmIdentityConverter.convertUserList(list);
		Set<BpmIdentity> set = new LinkedHashSet<BpmIdentity>(listIdentity);
		return set;
	}

	/**
	 * 获取上级组织的负责人(根据组织参数获取)
	 * @param orgId 组织ID
	 * @param alias 组织参数别名
	 * @return
	 */
	public Set<BpmIdentity> getUpLeanderByOrgId(String orgId,String alias){
		if(StringUtil.isEmpty(orgId)||StringUtil.isEmpty(alias)) return new LinkedHashSet<BpmIdentity>();
		IGroup group =  userGroupService.getGroupByIdOrCode(GroupTypeConstant.ORG.key(), orgId);
		if(BeanUtils.isEmpty(group) || !(group instanceof Org)) {
			return new LinkedHashSet<BpmIdentity>();
		}
		Org org = (Org)group;

		IGroup upGroup =  userGroupService.getGroupByIdOrCode(GroupTypeConstant.ORG.key(), org.getParentId());
		if(BeanUtils.isEmpty(upGroup) || !(upGroup instanceof Org)){
			 return new LinkedHashSet<BpmIdentity>();
		}
		String value = paramService.getParamByGroup(upGroup.getGroupId(), alias)+"";
		List<IUser> list = new ArrayList<IUser>();
		IUser iUser = userService.getUserById(value);
		list.add(iUser);
		List<BpmIdentity> listIdentity = bpmIdentityConverter.convertUserList(list);
		Set<BpmIdentity> set = new LinkedHashSet<BpmIdentity>(listIdentity);
		return set;
	}

	/**
	 * 根据组织ID获取该组织中为主组织的人员列表
	 * @param orgId
	 * @return
	 */
	@SuppressWarnings("rawtypes")
	public Set<BpmIdentity> getMainByOrgId(String orgId){
		Set<BpmIdentity> set=new LinkedHashSet<BpmIdentity>();
		if(StringUtil.isEmpty(orgId)) return set;
		String[] aryOrgIds=orgId.split(",");
		List<String> userIds=new ArrayList<>();
		for(String tmp:aryOrgIds){
			QueryFilter queryFilter = QueryFilter.build();
			queryFilter.addFilter("org.ID_", tmp, QueryOP.EQUAL);
			List list = uCFeignService.queryOrgUserRel(queryFilter);
			if(BeanUtils.isNotEmpty(list)){
				for(int i=0;i<list.size();i++){
					Map map = (Map) list.get(i);
					if(map.get("isMaster").toString().equals("1") && map.get("orgId").toString().equals(tmp)){
						userIds.add(map.get("userId").toString());
					}
				}
			}
		}
		ArrayNode userByIds = uCFeignService.getUserByIdsOrAccounts(StringUtil.join(userIds, ","));
		if (BeanUtils.isEmpty(userByIds)) {
			return set;
		}
		for (JsonNode jsonNode : userByIds) {
			BpmIdentity identity=new DefaultBpmIdentity();
			identity.setId(jsonNode.get("id").asText());
			identity.setName(jsonNode.get("fullname").asText());
			identity.setType(BpmIdentity.TYPE_USER);
			set.add(identity);
		}
		return set;
	}

	/**
	 * 根据所传维度下主组织参数查询执行人
	 * @param alias
	 * @param demId
	 * @return
	 */
	public Set<BpmIdentity> getLeanderByPreNode(String alias,String demId){
		if(StringUtil.isEmpty(alias)) return new LinkedHashSet<BpmIdentity>();
		ObjectNode orgNode =  uCFeignService.getMainGroup(ContextUtil.getCurrentUser().getUserId(),demId);
		if(BeanUtils.isEmpty(orgNode)){
			 return new LinkedHashSet<BpmIdentity>();
		}
		String value = paramService.getParamByGroup(orgNode.get("id").asText(), alias)+"";
		List<IUser> list = new ArrayList<IUser>();
		IUser iUser = userService.getUserById(value);
		list.add(iUser);
		Set<BpmIdentity> set = convertUserList(list);
		return set;
	}

	/**
	 * 根据角色别名获取角色。
	 * @param alias
	 * @return
	 */
	public Set<BpmIdentity> getRoleByAlias(String alias){
		Set<BpmIdentity> set=new LinkedHashSet<BpmIdentity>();
		if(StringUtil.isEmpty(alias)) return set;
		String[] aryAlias=alias.split(",");
		for(String tmp:aryAlias){
			IGroup group = userGroupService.getGroupByIdOrCode(GroupTypeConstant.ROLE.key(), tmp);
			BpmIdentity identity=new DefaultBpmIdentity(group);
			identity.setType(BpmIdentity.TYPE_GROUP);
			identity.setExtractType(ExtractType.EXACT_NOEXACT);
			identity.setGroupType( GroupTypeConstant.ROLE.key());
			set.add(identity);
		}

		return set;
	}

    /**
     * 根据岗位别名获取岗位。
     * @param alias
     * @return
     */
    public Set<BpmIdentity> getByPostAlias(String alias){
        Set<BpmIdentity> set=new LinkedHashSet<BpmIdentity>();
        if(StringUtil.isEmpty(alias)) return set;
        String[] aryAlias=alias.split(",");
        for(String tmp:aryAlias){
            IGroup group = userGroupService.getGroupByIdOrCode(GroupTypeConstant.POSITION.key(), tmp);
            BpmIdentity identity=new DefaultBpmIdentity(group.getGroupId(),group.getName(),BpmIdentity.TYPE_GROUP);
            identity.setType(BpmIdentity.TYPE_GROUP);
            identity.setExtractType(ExtractType.EXACT_NOEXACT);
            identity.setGroupType( GroupTypeConstant.POSITION.key());
            set.add(identity);
        }

        return set;
    }

    /**
     * 兼容老版本以免报错
     * @param boDefAlias
     * @param subTableName
     * @param subAccountField
     * @param subNameFiled
     * @return
     * @throws Exception
     */
    public Set<BpmIdentity> getUserFromSubData(String boDefAlias,String subTableName,String subAccountField,String subNameFiled) throws Exception{
        return getUserFromSubData(boDefAlias,subTableName,subAccountField);
    }


    /**
     * 从子表数据中提取节点审批人
     * @param boDefAlias
     * @param subTableName
     * @param subIdField
     * @param subNameFiled
     * @return
     * @throws Exception
     */
    public Set<BpmIdentity> getUserFromSubData(String boDefAlias,String subTableName,String subAccountField) throws Exception{
        Set<BpmIdentity> set=new LinkedHashSet<BpmIdentity>();
        ActionCmd cmd =  ContextThreadUtil.getActionCmd();
        ObjectNode  jsonObject = JsonUtil.getMapper().createObjectNode();
        if(BeanUtils.isEmpty(cmd.getBusData())){
            InstFormAndBoVo instFormAndBoVo = iFlowService.getInstFormAndBO(cmd.getVariables().get(BpmConstants.PROCESS_INST_ID).toString(),"",null, FormType.PC,true,true,false);
            jsonObject = instFormAndBoVo.getData();
        }else{
            jsonObject = (ObjectNode) JsonUtil.toJsonNode(cmd.getBusData());
        }
        if(BeanUtils.isNotEmpty(jsonObject) && BeanUtils.isNotEmpty(jsonObject.get(boDefAlias).get(subTableName)) && jsonObject.get(boDefAlias).get(subTableName).size()>0){
            Set<String> userAccounts = new HashSet<>();
            for (int i = 0; i < jsonObject.get(boDefAlias).get(subTableName).size(); i++) {
                if(BeanUtils.isNotEmpty(jsonObject.get(boDefAlias).get(subTableName).get(i).get(subAccountField))){
                    userAccounts.add(jsonObject.get(boDefAlias).get(subTableName).get(i).get(subAccountField).asText());
                }
            }
            if(BeanUtils.isNotEmpty(userAccounts)){
                ArrayNode iUsers = uCFeignService.getUserByIdsOrAccounts(StringUtil.join(userAccounts));
                Assert.notNull(iUsers, String.format("根据子表所传账号【%s】未查找到用户", StringUtil.join(userAccounts)));
                for (JsonNode userNode : iUsers) {
                    DefaultBpmIdentity bpmIdentity = new DefaultBpmIdentity();
                    bpmIdentity.setId(userNode.get("id").asText());
                    bpmIdentity.setName(userNode.get("fullname").asText());
                    bpmIdentity.setType(BpmIdentity.TYPE_USER);
                    set.add(bpmIdentity);
                }
            }
        }
        return set;
    }

    /**
     * 从子表数据中提取节点审批人 会签用户组
     * @param boDefAlias
     * @param subTableName
     * @param subIdField
     * @param subNameFiled
     * @return
     * @throws Exception
     */
    public Set<BpmIdentity> getUserFromSubDataGroupUser(String boDefAlias,String subTableName,String subAccountField,String subGroupField) throws Exception{
        Set<BpmIdentity> set=new LinkedHashSet<BpmIdentity>();
        ActionCmd cmd =  ContextThreadUtil.getActionCmd();
        ObjectNode  jsonObject = JsonUtil.getMapper().createObjectNode();
        if(BeanUtils.isEmpty(cmd.getBusData())){
            InstFormAndBoVo instFormAndBoVo = iFlowService.getInstFormAndBO(cmd.getVariables().get(BpmConstants.PROCESS_INST_ID).toString(),"",null, FormType.PC,true,true,false);
            jsonObject = instFormAndBoVo.getData();
        }else{
            jsonObject = (ObjectNode) JsonUtil.toJsonNode(cmd.getBusData());
        }
        if(BeanUtils.isNotEmpty(jsonObject) && BeanUtils.isNotEmpty(jsonObject.get(boDefAlias).get(subTableName)) && jsonObject.get(boDefAlias).get(subTableName).size()>0){
            Map<String,Set<String>> groupMap = new HashMap<String, Set<String>>();
            for (int i = 0; i < jsonObject.get(boDefAlias).get(subTableName).size(); i++) {
            	Set<String> userAccounts = new HashSet<String>();
            	if(BeanUtils.isNotEmpty(jsonObject.get(boDefAlias).get(subTableName).get(i).get(subGroupField))) {
            		String key = jsonObject.get(boDefAlias).get(subTableName).get(i).get(subGroupField).asText();
            		if(groupMap.containsKey(key)) {
            			userAccounts = groupMap.get(key);
            		}else {
            			groupMap.put(key, userAccounts);
            		}
            	}else {
            		throw new BaseException("子表分组字段必填");
            	}
            	if(BeanUtils.isNotEmpty(jsonObject.get(boDefAlias).get(subTableName).get(i).get(subAccountField))){
                    userAccounts.add(jsonObject.get(boDefAlias).get(subTableName).get(i).get(subAccountField).asText());
                }
            }
            if(BeanUtils.isNotEmpty(groupMap)){
            	Set<String> keySet = groupMap.keySet();
            	for (String key : keySet) {
            		ArrayNode iUsers = uCFeignService.getUserByIdsOrAccounts(StringUtil.join(groupMap.get(key)));
                    Assert.notNull(iUsers, String.format("根据子表所传账号【%s】未查找到用户", StringUtil.join(groupMap.get(key))));

                    Set<String> ids = new HashSet<String>();
                    Set<String> names = new HashSet<String>();
                    for (JsonNode userNode : iUsers) {
                    	ids.add(userNode.get("id").asText());
                    	names.add(userNode.get("fullname").asText());
                    }
                    DefaultBpmIdentity bpmIdentity = new DefaultBpmIdentity();
                    bpmIdentity.setId(StringUtil.join(ids));
                    bpmIdentity.setName(StringUtil.join(names));
                    bpmIdentity.setType(BpmIdentity.TYPE_GROUP_USER);
                    set.add(bpmIdentity);
				}

            }
        }
        return set;
    }





	public Set<BpmIdentity> getByCompanyRole(String company,String role){
		List<ObjectNode> list = uCFeignService.getByCompanyRole(company,role);
		Set<BpmIdentity> set = getBpmIdentities(list);
		return set;
	}


	private Set<BpmIdentity> getBpmIdentities(List<ObjectNode> list) {
		Set<BpmIdentity> set=new LinkedHashSet<BpmIdentity>();
		if(BeanUtils.isEmpty(list)){
			return set;
		}
		list.forEach(item->{
			BpmIdentity bpmIdentity=new DefaultBpmIdentity();
			bpmIdentity.setType(BpmIdentity.TYPE_USER);
			bpmIdentity.setName(item.get("fullname").asText());
			bpmIdentity.setId(item.get("id").asText());
			bpmIdentity.setCode(item.get("account").asText());
			set.add(bpmIdentity);
		});
		return set;
	}

	/**
	 * 逐级审批
	 * @param grade 组织级别
	 * @param res  是否需要上级领导
	 * @return
	 */
	public Set<BpmIdentity> getLeaderStep(Object gradeParam,Object resParam){
        Integer grade = Integer.parseInt(String.valueOf(gradeParam));
        Boolean res = BooleanUtil.toBooleanObject(String.valueOf(resParam));
        List<ObjectNode> list = uCFeignService.getLeaderStep(ContextUtil.getCurrentUserId(),grade,res);
        Set<BpmIdentity> set = getBpmIdentities(list);
		return set;
	}

	public Set<BpmIdentity> getFgUsers(String orgId,String orgParam,String userParam){
		List<ObjectNode> list = uCFeignService.getFgUsers(orgId,orgParam,userParam);
		Set<BpmIdentity> set = new HashSet<>();
		if(BeanUtils.isNotEmpty(list)){
			set=getBpmIdentities(list);
		}
		return set;
	}

	/**
	 * 根据组织ID获取逐级审批
	 * @param orgId 组织ID
	 * @param grade 组织级别
	 * @return
	 * */
	public Set<BpmIdentity> getLeaderStepByOrgId(String orgId, Object gradeParam){
        Integer grade = Integer.parseInt(String.valueOf(gradeParam));
		List<ObjectNode> list = uCFeignService.getLeaderStepByOrgId(orgId,grade);
		Set<BpmIdentity> set = getBpmIdentities(list);
		return set;
	}





}