在开发中我们可以根据当前组织ID返回委托组织BOSUuid
该方法在客户端服务端通用:客户端ctx传入空值,服务端传入ctx即可:
代码参考如下:
public String getCompanyOrg(Context ctx, String fromOrgId, String fromOrgType, String toOrgType) throws BOSException{
String orgID = "";
FullOrgUnitInfo orgInfo = null;
//获取委托关系
OrgTypeRelationInfo relationTypeInfo = null;
if (ctx != null) {
relationTypeInfo = OrgTypeRelationFactory.getLocalInstance(ctx).getOrgTypeRelationCollection("where fromType = "+fromOrgType+" and toType = "+toOrgType).get(0);
}else {
relationTypeInfo = OrgTypeRelationFactory.getRemoteInstance().getOrgTypeRelationCollection("where fromType = "+fromOrgType+" and toType = "+toOrgType).get(0);
}
if (!EmptyUtil.isEmpty(relationTypeInfo)) {
//获取委托信息
EntityViewInfo ev = new EntityViewInfo();
FilterInfo filter = new FilterInfo();
filter.getFilterItems().add(new FilterItemInfo("fromUnit.id",fromOrgId,CompareType.EQUALS));
filter.getFilterItems().add(new FilterItemInfo("typeRelation.id",relationTypeInfo.getId(),CompareType.EQUALS));
filter.setMaskString("#0 and #1");
ev.setFilter(filter);
OrgUnitRelationInfo relationInfo = null;
if (ctx != null) {
relationInfo = OrgUnitRelationFactory.getLocalInstance(ctx).getOrgUnitRelationCollection(ev).get(0);
} else {
relationInfo = OrgUnitRelationFactory.getRemoteInstance().getOrgUnitRelationCollection(ev).get(0);
}
if (!EmptyUtil.isEmpty(relationInfo)) {
//获取委托组织
orgInfo = relationInfo.getToUnit();
if (!EmptyUtil.isEmpty(orgInfo)) {
orgID = orgInfo.getId().toString();
}
}
}
return orgID;
}
推荐阅读