Files
notes/work/移动杭研/问题处理/2023-02/0201-cache+账户无法查看名下子帐号-朱鹏昊.md
2026-03-01 01:43:46 +08:00

102 lines
3.1 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# cache+ 账户无法查看名下子帐号
## 截图
![](../../../../attachment/images-uuid/71442718510646a593b8df01f3059213.png)
## 排查思路
1、首先明确客户是可以看到账户管理界面的,说明有对应的权限。
2、定位到查询的位置
```java
com.cmcc.cdn.platform.selfservice.controller.EnterpriseSubAccountController#getSubUserInfoList
```
代码主体流程为 `获取用户id``企业信息` 主要涉及表 `user``enterprise_user`
然后通过 `enterprise_subuser``user` 表联查得到其名下所有的用户。将每个用户的 Children 设为空后进行返回。
整体流程并没有过滤。从库中查询的话是有 5 条数据,有一条是昨天新增的,首先考虑是数据引起的,因为没有日志暂时无法具体的定位,进行日志的补充。在最近的版本进行了上线,日志显示已经全部查询完成。但是还是栈内存溢出。
二次定位到有可能是 fastjson 序列化引起的。考虑到要保留原查询框架及实体,目前方案为拷贝对象到新的实体中,解除 Controller 中返回的。
```java
log.info("用户查询完成,开始拷贝对象");
ArrayList<UserForAccountManagement> userForAccountManagements = new ArrayList<>();
for (User user : users) {
UserForAccountManagement userForAccountManagement = new UserForAccountManagement();
BeanUtils.copyProperties(user, userForAccountManagement);
userForAccountManagements.add(userForAccountManagement);
}
```
## 问题排查记录
利用对象的计算工具进行监控:
```java
查询1当前页的所有人员ID为:[1682, 1675, 1648, 1641]
查询2所有人员ID为:[1682, 1675, 1648, 1641]
出表后内存占用318.4 MB
查询3从User表中取到的用户ID集合:[1682, 1675, 1648, 1641]
开始处理用户权限
用户查询完成,开始拷贝对象
转换后内存1.3 KB
return前对象内存占用1.5 KB
```
![](../../../../attachment/images-uuid/8ddca166ba03470cba30b8e4c399e2cb.png)
![](../../../../attachment/images-uuid/738c78d1562d4470a5808a430c80cd19.png)
### 工具
地址
[查看对象大小](https://blog.csdn.net/yetaodiao/article/details/127369667)
```java
System.out.println("转换后内存"+ RamUsageEstimator.humanSizeOf(userForAccountManagements));
```
```java
//坐标
<dependency>
<groupId>org.apache.lucene</groupId>
<artifactId>lucene-core</artifactId>
<version>4.0.0</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.12.0</version>
</dependency>
```
指定项目 json 转换工具
```java
com.cmcc.cdn.platform.CustomWebAppConfigurer
```
## 前端沟通
NORMAL_ESOP_MANAGE(企业)
TYMH_YYZHGL
有这两个权限之一的有账户管理模块
1、对于集团业务管理员,是/businessManage/managerList 接口,它只需要看用户,不需要用户的查看,编辑,删除权限的东西,操作栏中的东西是一次就查完了。
1、对于企业客户接口/selfService/enterprisesubuser/getCpSubUserInfoList。页面操作是单独发起的。