Compare commits

...

4 Commits

Author SHA1 Message Date
曹鹏飞 5bf26c76d5 Merge branch 'feature/gongfu' into feature/data-permission
# Conflicts:
#	nflg-mobilebroken-admin/src/test/java/TTest.java
2026-01-16 15:16:49 +08:00
曹鹏飞 142b47f91f refactor(customer): 优化代理商公司同步逻辑,按公司名称和编码排重,任一个相同责认为是相同的记录,会覆盖旧记录 2026-01-16 15:15:29 +08:00
曹鹏飞 5ea168155f feat(admin): 实现管理员账号搜索功能优化
- 搜索账号接口添加新版本标识
- 重构搜索逻辑,使用流式过滤替代模糊查询
- 优化部门层级绑定逻辑,支持更精确的树形结构构建
- 添加子节点递归处理功能,完善用户组织架构展示
- 修复部门与用户关联关系的数据转换问题
- 优化集合操作提高搜索性能
2026-01-16 13:54:05 +08:00
曹鹏飞 d0d78d54c6 feat(filter): 更新白名单并优化设备类型查询性能
- 在AppVersionFilter白名单中添加hangUp和exportPdf接口
- 优化DeviceTypeController中的数据库查询逻辑
- 使用Set替代List避免重复数据提高查询效率
- 添加CollectionUtil非空检查增强代码健壮性
- 减少不必要的流操作提升查询性能
2026-01-16 09:21:57 +08:00
7 changed files with 96 additions and 46 deletions

View File

@ -373,7 +373,7 @@ public class AdminUserController extends ControllerBase {
}
/**
* 搜索账号
* 搜索账号
* @param request 请求参数
*/
@PostMapping("searchAccountNew")

View File

@ -22,7 +22,6 @@ import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.*;
import java.util.stream.Collectors;
@ -99,10 +98,10 @@ public class AdminCustomerService {
*/
public void syncFromCrm(SyncFromCrmDTO dateParam) {
DateTimeFormatter dateFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
// DateTimeFormatter dateFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
// 循环从起始日期到结束日期每次增加一天
List<TBaseCustomer> result = new ArrayList<>();
// List<TBaseCustomer> result = new ArrayList<>();
// for (LocalDate date = stDate; !date.isAfter(edDate); date = date.plusDays(1)) {
@ -110,12 +109,19 @@ public class AdminCustomerService {
if (CollUtil.isEmpty(agentList)) {
return;
}
Set<String> crmComanyCodes = agentList.stream().map(u -> u.getId()).collect(Collectors.toSet());
List<TBaseCustomer> crmCompanyList = baseCustomerService.lambdaQuery().in(TBaseCustomer::getAgencyCompanyCode, crmComanyCodes).list();
Map<String, TBaseCustomer> crmCompanyMap = crmCompanyList.stream().collect(Collectors.toMap(TBaseCustomer::getAgencyCompanyCode, cm -> cm));
List<TBaseCustomer> result = new ArrayList<>();
// Set<String> crmComanyCodes = agentList.stream().map(u -> u.getId()).collect(Collectors.toSet());
// List<TBaseCustomer> crmCompanyList = baseCustomerService.lambdaQuery().in(TBaseCustomer::getAgencyCompanyCode, crmComanyCodes).list();
// Map<String, TBaseCustomer> crmCompanyMap = crmCompanyList.stream().collect(Collectors.toMap(TBaseCustomer::getAgencyCompanyCode, cm -> cm));
List<TBaseCustomer> customers = baseCustomerService.list();
agentList.forEach(u -> {
TBaseCustomer ent = crmCompanyMap.get(u.getId());
// TBaseCustomer ent = crmCompanyMap.get(u.getId());
TBaseCustomer ent = customers.stream()
.filter(c -> Objects.equals(c.getAgencyCompanyCode(), u.getId())
|| StrUtil.equals(convertName(c.getAgencyCompanyName()), convertName(u.getName())))
.findFirst()
.orElse(null);
if (Objects.nonNull(ent)) {
ent.setDataModifyTime(LocalDateTime.now());
@ -150,5 +156,7 @@ public class AdminCustomerService {
}
private String convertName(String name) {
return name.replaceAll("\\s+", "");
}
}

View File

@ -20,4 +20,9 @@ public class TTest {
public void test2() {
System.out.println(StrUtil.toCamelCase("user_name"));
}
}
@Test
public void test3() {
System.out.println("" + " 打 撒sfc dffd发多少分多少 分多少分的d f ".replaceAll("\\s+", "") + "");
}
}

View File

@ -5,6 +5,7 @@ import lombok.Data;
import lombok.experimental.Accessors;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
@ -83,5 +84,5 @@ public class AdminUserVO {
@JsonProperty("isGongfu")
private boolean isGongfu;
private List<AdminUserVO> children;
private List<AdminUserVO> children = new ArrayList<>();
}

View File

@ -30,6 +30,7 @@ import javax.validation.Valid;
import java.time.LocalDateTime;
import java.util.Collections;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
/**
@ -58,8 +59,9 @@ public class DeviceTypeController extends ControllerBase {
.eq(GongfuDeviceType::getParentId, 0)
.orderByDesc(GongfuDeviceType::getId)
.page(new Page<>(query.getPage(), query.getPageSize()));
Set<Long> ids = result.getRecords().stream().map(GongfuDeviceType::getId).collect(Collectors.toSet());
List<GongfuDeviceType> children = deviceTypeService.lambdaQuery()
.in(GongfuDeviceType::getParentId, result.getRecords().stream().map(GongfuDeviceType::getId).collect(Collectors.toList()))
.in(CollectionUtil.isNotEmpty(ids), GongfuDeviceType::getParentId, ids)
.list();
return ApiResult.success(convert(query, result, children));
} else {
@ -70,8 +72,9 @@ public class DeviceTypeController extends ControllerBase {
if (CollectionUtil.isEmpty(children)) {
return ApiResult.success(new PageData<>());
}
Set<Long> ids = children.stream().map(GongfuDeviceType::getParentId).collect(Collectors.toSet());
Page<GongfuDeviceType> result = deviceTypeService.lambdaQuery()
.in(GongfuDeviceType::getId, children.stream().map(GongfuDeviceType::getParentId).collect(Collectors.toSet()))
.in(CollectionUtil.isNotEmpty(ids), GongfuDeviceType::getId, ids)
.orderByDesc(GongfuDeviceType::getId)
.page(new Page<>(query.getPage(), query.getPageSize()));
return ApiResult.success(convert(query, result, children));

View File

@ -443,34 +443,66 @@ public class AdminUserServiceImpl extends ServiceImpl<AdminUserMapper, AdminUser
if (CollectionUtil.isEmpty(adminUsers)) {
return Collections.emptyList();
}
List<AdminUserVO> userVOS = convert(roots, department, positions, roleMaps, roles);
getChildren(userVOS.get(0), departments, adminUsers, positions, roleMaps, roles);
for (int index = 1, size = userVOS.size(); index < size; index++) {
userVOS.get(index).setChildren(userVOS.get(0).getChildren());
List<AdminUserVO> rootUserVOS = convert(roots, department, positions, roleMaps, roles);
getChildren(rootUserVOS.get(0), departments, adminUsers, positions, roleMaps, roles);
for (int index = 1, size = rootUserVOS.size(); index < size; index++) {
rootUserVOS.get(index).setChildren(rootUserVOS.get(0).getChildren());
}
return userVOS;
return rootUserVOS;
} else {
List<AdminUser> adminUsers = lambdaQuery()
.eq(AdminUser::getIsDel, false)
.like(StrUtil.isNotBlank(request.getLoginName()), AdminUser::getLoginName, request.getLoginName())
.like(StrUtil.isNotBlank(request.getUserName()), AdminUser::getUserName, request.getUserName())
.eq(request.getState() != null, AdminUser::getState, request.getState())
.list();
if (CollectionUtil.isEmpty(adminUsers)) {
List<AdminUser> searchUsers = adminUsers.stream()
.filter(u -> (StrUtil.isBlank(request.getLoginName()) || StrUtil.contains(u.getLoginName(), request.getLoginName()))
&& (StrUtil.isBlank(request.getUserName()) || StrUtil.contains(u.getUserName(), request.getUserName()))
&& (request.getState() == null || Objects.equals(u.getState(), request.getState()))
)
.collect(Collectors.toList());
if (CollectionUtil.isEmpty(searchUsers)) {
return Collections.emptyList();
}
List<AdminUserVO> userVOS = convert1(adminUsers, departments, positions, roleMaps, roles);
Set<TBaseDepartment> departmentVOS = departments.stream()
.filter(d -> userVOS.stream().map(AdminUserVO::getDepartmentId).anyMatch(dt -> Objects.equals(d.getId(), dt)))
Set<TBaseDepartment> searchDepartments = departments.stream()
.filter(d -> searchUsers.stream().map(AdminUser::getDepartmentId).anyMatch(dt -> Objects.equals(d.getId(), dt)))
.collect(Collectors.toSet());
departmentVOS.forEach(d -> bindParent(d, departmentVOS, departments));
List<TBaseDepartment> rootDepartments = departmentVOS.stream()
searchDepartments.forEach(d -> bindParent(d, searchDepartments, departments));
List<TBaseDepartment> rootDepartments = searchDepartments.stream()
.filter(d -> d.getDeptParentId() == 0)
.collect(Collectors.toList());
// List<AdminUserVO>
// rootDepartments.forEach(d -> getChildren1(d, departmentVOS, adminUsers, positions, roleMaps, roles));
//TODO 绑定树形结构
return userVOS;
List<AdminUser> rootUsers = adminUsers.stream()
.filter(u -> rootDepartments.stream()
.map(TBaseDepartment::getId).anyMatch(dt -> Objects.equals(u.getDepartmentId(), dt))
).collect(Collectors.toList());
List<AdminUserVO> rootUserVOS = convert1(rootUsers, departments, positions, roleMaps, roles);
rootUserVOS.forEach(uvo -> getChildren1(uvo, departments, adminUsers, searchUsers, positions, roleMaps, roles));
return rootUserVOS;
}
}
private void getChildren1(AdminUserVO user, List<TBaseDepartment> departments, List<AdminUser> users, List<AdminUser> searchUsers
, List<TBasePosition> positions, List<AdminUserRoleMap> roleMaps, List<AdminRole> roles) {
List<TBaseDepartment> cdepartments = departments.stream()
.filter(d -> Objects.equals(d.getDeptParentId(), user.getDepartmentId()))
.collect(Collectors.toList());
if (CollectionUtil.isNotEmpty(cdepartments)) {
cdepartments.forEach(department -> {
List<AdminUser> csers = searchUsers.stream()
.filter(u -> Objects.equals(u.getDepartmentId(), department.getId()))
.collect(Collectors.toList());
if (CollectionUtil.isEmpty(csers)) {
csers = users.stream()
.filter(u -> Objects.equals(u.getDepartmentId(), department.getId()))
.collect(Collectors.toList());
}
if (CollectionUtil.isNotEmpty(csers)) {
List<AdminUserVO> cuserVOS = convert(csers, department, positions, roleMaps, roles);
user.getChildren().addAll(cuserVOS);
getChildren(cuserVOS.get(0), departments, users, positions, roleMaps, roles);
for (int index = 1, size = cuserVOS.size(); index < size; index++) {
cuserVOS.get(index).setChildren(cuserVOS.get(0).getChildren());
}
}
});
}
}
@ -540,22 +572,23 @@ public class AdminUserServiceImpl extends ServiceImpl<AdminUserMapper, AdminUser
private void getChildren(AdminUserVO user, List<TBaseDepartment> departments, List<AdminUser> users
, List<TBasePosition> positions, List<AdminUserRoleMap> roleMaps, List<AdminRole> roles) {
TBaseDepartment department = departments.stream()
List<TBaseDepartment> cdepartments = departments.stream()
.filter(d -> Objects.equals(d.getDeptParentId(), user.getDepartmentId()))
.findFirst()
.orElse(null);
if (Objects.nonNull(department)) {
List<AdminUser> csers = users.stream()
.filter(u -> Objects.equals(u.getDepartmentId(), department.getId()))
.collect(Collectors.toList());
if (CollectionUtil.isNotEmpty(csers)) {
List<AdminUserVO> cuserVOS = convert(csers, department, positions, roleMaps, roles);
user.setChildren(cuserVOS);
getChildren(cuserVOS.get(0), departments, users, positions, roleMaps, roles);
for (int index = 1, size = cuserVOS.size(); index < size; index++) {
cuserVOS.get(index).setChildren(cuserVOS.get(0).getChildren());
.collect(Collectors.toList());
if (CollectionUtil.isNotEmpty(cdepartments)) {
cdepartments.forEach(department -> {
List<AdminUser> csers = users.stream()
.filter(u -> Objects.equals(u.getDepartmentId(), department.getId()))
.collect(Collectors.toList());
if (CollectionUtil.isNotEmpty(csers)) {
List<AdminUserVO> cuserVOS = convert(csers, department, positions, roleMaps, roles);
user.getChildren().addAll(cuserVOS);
getChildren(cuserVOS.get(0), departments, users, positions, roleMaps, roles);
for (int index = 1, size = cuserVOS.size(); index < size; index++) {
cuserVOS.get(index).setChildren(cuserVOS.get(0).getChildren());
}
}
}
});
}
}
}

View File

@ -30,7 +30,7 @@ public class AppVersionFilter extends OncePerRequestFilter {
/**
* 因前端部分接口遗漏App-Version参数ios打包重新审核需要很久所以需要排除掉否则会导致接口无法访问
*/
private static final Set<String> WHITE_LIST = Set.of("getTicket", "uploadSingleFile", "getInfoById");
private static final Set<String> WHITE_LIST = Set.of("getTicket", "uploadSingleFile", "getInfoById", "hangUp", "exportPdf");
private static final String MIN_SUPPER_VERSION = "1.0.9";