Browse Source

fix:巡检对象人员列表修改获取用户名称逻辑

zhongwei
haungxing 4 months ago
parent
commit
8c80d96ab4
  1. 17
      hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/obj/services/impl/ObjectUserServiceImpl.java

17
hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/obj/services/impl/ObjectUserServiceImpl.java

@ -11,7 +11,9 @@ import org.springblade.core.secure.utils.AuthUtil;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.constant.BladeConstant;
import org.springblade.core.tool.utils.CollectionUtil;
import org.springblade.core.tool.utils.Func;
import org.springblade.core.tool.utils.ObjectUtil;
import org.springblade.system.user.cache.UserCache;
import org.springblade.system.user.entity.User;
import org.springblade.system.user.feign.IUserClient;
import org.springframework.stereotype.Service;
@ -53,11 +55,11 @@ public class ObjectUserServiceImpl extends ServiceImpl<ObjectUserMapper, ObjectU
if(objectUsers.isEmpty()){
return new ArrayList<>();
}
R<List<User>> users = userClient.userListByCodeAndNameAndAccount(AuthUtil.getTenantId(),content.getUserCode(),content.getUserName(),content.getLoginName());
if(!users.isSuccess() || CollectionUtil.isEmpty(users.getData())){
return new ArrayList<>();
}
Map<Long,User> userMap = users.getData().stream().collect(Collectors.toMap(User::getId, Function.identity()));
// R<List<User>> users = userClient.userListByCodeAndNameAndAccount(AuthUtil.getTenantId(),content.getUserCode(),content.getUserName(),content.getLoginName());
// if(!users.isSuccess() || CollectionUtil.isEmpty(users.getData())){
// return new ArrayList<>();
// }
// Map<Long,User> userMap = users.getData().stream().collect(Collectors.toMap(User::getId, Function.identity()));
return objectUsers.stream().map(objectUser->{
ObjectUserListVO builder = new ObjectUserListVO();
builder.setId(objectUser.getId());
@ -65,7 +67,8 @@ public class ObjectUserServiceImpl extends ServiceImpl<ObjectUserMapper, ObjectU
builder.setObjName(objectUser.getObjName());
builder.setTempCode(objectUser.getTempCode());
builder.setTempName(objectUser.getTempName());
User user = userMap.get(objectUser.getUserId());
// User user = userMap.get(objectUser.getUserId());
User user = UserCache.getUser(objectUser.getUserId());
if(ObjectUtil.isNotEmpty(user)){
builder.setUserCode(user.getCode());
builder.setUserName(user.getRealName());
@ -73,6 +76,6 @@ public class ObjectUserServiceImpl extends ServiceImpl<ObjectUserMapper, ObjectU
builder.setUserId(user.getId());
}
return builder;
}).collect(Collectors.toList());
}).filter(o -> Func.isNotEmpty(o.getUserId())).collect(Collectors.toList());
}
}

Loading…
Cancel
Save