方法1
UserVO userVO=null;
for(int i=0;i<deviceKeeperList.size();i++){
//尤其注意
userVO=deviceKeeperList.get(i);
//根据deviceKeeperList.get(i).getUserId();查询user_building_rel条数 返回list
//判断list条数
String userId =deviceKeeperList.get(i).getUserId();
userQO.setUserId(userId);
List<UserVO> idList=userMapper.getBuildingId(userQO);
for(int j=0;j<idList.size();j++){
if(j == 0){
buildingId =buildingId+idList.get(j).getBuildingId();
}else{
buildingId =buildingId+","+idList.get(j).getBuildingId();
}
}
userVO.setBuildingId(buildingId);
}
方法2
for(UserVO userVo : deviceKeeperList){
String buildingId="";
String userId =userVo.getUserId();
userQO.setUserId(userId);
List<UserVO> idList=userMapper.getBuildingId(userQO);
for(int j=0;j<idList.size();j++){
if(j == 0){
buildingId =buildingId+idList.get(j).getBuildingId();
}else{
buildingId =buildingId+","+idList.get(j).getBuildingId();
}
}
userVo.setBuildingId(buildingId);
}
UserVO userVO=null;
for(int i=0;i<deviceKeeperList.size();i++){
//尤其注意
userVO=deviceKeeperList.get(i);
//根据deviceKeeperList.get(i).getUserId();查询user_building_rel条数 返回list
//判断list条数
String userId =deviceKeeperList.get(i).getUserId();
userQO.setUserId(userId);
List<UserVO> idList=userMapper.getBuildingId(userQO);
for(int j=0;j<idList.size();j++){
if(j == 0){
buildingId =buildingId+idList.get(j).getBuildingId();
}else{
buildingId =buildingId+","+idList.get(j).getBuildingId();
}
}
userVO.setBuildingId(buildingId);
}
方法2
for(UserVO userVo : deviceKeeperList){
String buildingId="";
String userId =userVo.getUserId();
userQO.setUserId(userId);
List<UserVO> idList=userMapper.getBuildingId(userQO);
for(int j=0;j<idList.size();j++){
if(j == 0){
buildingId =buildingId+idList.get(j).getBuildingId();
}else{
buildingId =buildingId+","+idList.get(j).getBuildingId();
}
}
userVo.setBuildingId(buildingId);
}