cloudcc 查找指定用户的所有下属

/查询所有彭晓燕下属的roleid
List<CCObject> roleList = cs.cquery("role", " parentrole_id__c='"+ 彭晓燕的roleid +"' and gap__c > 0  ");
 
String roleIds = "";
for(CCObject obj : roleList){
    if(!"".equals(obj.get("roleid"))){
        roleIds += "'" + obj.get("roleid") + "',";
    }
}
if(roleIds.length() > 0){
    roleIds = "(" + roleIds.substring(0, roleIds.length() - 1) + ")";
}else{
    roleIds = "('')";
}
 
//根据下属roleid,查询对应的用户
List<CCObject> userList=cs.cquery("User", "role__c in " + roleIds ;);
 
String userIds=””;
for(CCObject obj1 : userList){
    if(!"".equals(obj1.get("id"))){
        userIds += "'" + obj1.get("id") + "',";
    }
}
if(userList.length() > 0){
    userIds = "(" + userIds.substring(0, userIds.length() - 1) + ")";
}else{
    userIds = "('')";
}
 
 

上述方法就把彭晓燕下属的用户id,都拼成userIds这个参数了 
然后在写查询业务数据的的sql,在查询条件里用业务员字段 in userIds,就能查询出下属人员的数据了

 

posted @ 2016-11-15 15:08  _范先森  阅读(172)  评论(0编辑  收藏  举报