Commit 60ef60b3 by 徐高华

查询优化

parent d117540a
...@@ -903,7 +903,7 @@ public class StaffApiServiceImpl implements StaffApiService { ...@@ -903,7 +903,7 @@ public class StaffApiServiceImpl implements StaffApiService {
if (CollectionUtils.isEmpty(list)) { if (CollectionUtils.isEmpty(list)) {
return Collections.EMPTY_LIST; return Collections.EMPTY_LIST;
} }
for (StaffDTO staffDTO : list) { /*for (StaffDTO staffDTO : list) {
List<String> departmentIds = new ArrayList<>(); List<String> departmentIds = new ArrayList<>();
List<TabHaobanStaffDepartmentRelated> relatedList = staffDepartmentRelatedService.listStaffDepartmentByStaffId(staffDTO.getStaffId()); List<TabHaobanStaffDepartmentRelated> relatedList = staffDepartmentRelatedService.listStaffDepartmentByStaffId(staffDTO.getStaffId());
for (TabHaobanStaffDepartmentRelated tabHaobanStaffDepartmentRelated : relatedList) { for (TabHaobanStaffDepartmentRelated tabHaobanStaffDepartmentRelated : relatedList) {
...@@ -911,7 +911,8 @@ public class StaffApiServiceImpl implements StaffApiService { ...@@ -911,7 +911,8 @@ public class StaffApiServiceImpl implements StaffApiService {
} }
List<DepartmentDTO> departmentList = departmentService.listByIds(departmentIds); List<DepartmentDTO> departmentList = departmentService.listByIds(departmentIds);
staffDTO.setDepartmentList(departmentList); staffDTO.setDepartmentList(departmentList);
} }*/
this.addDepartInfo(list);
return list; return list;
} }
...@@ -1194,7 +1195,7 @@ public class StaffApiServiceImpl implements StaffApiService { ...@@ -1194,7 +1195,7 @@ public class StaffApiServiceImpl implements StaffApiService {
if (CollectionUtils.isEmpty(list)) { if (CollectionUtils.isEmpty(list)) {
return Collections.EMPTY_LIST; return Collections.EMPTY_LIST;
} }
for (StaffDTO staffDTO : list) { /*for (StaffDTO staffDTO : list) {
List<String> departmentIds = new ArrayList<>(); List<String> departmentIds = new ArrayList<>();
List<TabHaobanStaffDepartmentRelated> relatedList = staffDepartmentRelatedService.listStaffDepartmentByStaffId(staffDTO.getStaffId()); List<TabHaobanStaffDepartmentRelated> relatedList = staffDepartmentRelatedService.listStaffDepartmentByStaffId(staffDTO.getStaffId());
for (TabHaobanStaffDepartmentRelated tabHaobanStaffDepartmentRelated : relatedList) { for (TabHaobanStaffDepartmentRelated tabHaobanStaffDepartmentRelated : relatedList) {
...@@ -1202,9 +1203,34 @@ public class StaffApiServiceImpl implements StaffApiService { ...@@ -1202,9 +1203,34 @@ public class StaffApiServiceImpl implements StaffApiService {
} }
List<DepartmentDTO> departmentList = departmentService.listByIds(departmentIds); List<DepartmentDTO> departmentList = departmentService.listByIds(departmentIds);
staffDTO.setDepartmentList(departmentList); staffDTO.setDepartmentList(departmentList);
} }*/
this.addDepartInfo(list);
return list; return list;
} }
private void addDepartInfo(List<StaffDTO> list) {
List<String> staffIdList = list.stream().map(dto->dto.getStaffId()).collect(Collectors.toList()) ;
List<TabHaobanStaffDepartmentRelated> deplist = staffDepartmentRelatedMapper.listStaffDepartmentByStaffIds(staffIdList);
if (CollectionUtil.isNotEmpty(list)) {
Map<String, List<TabHaobanStaffDepartmentRelated>> map = deplist.stream().collect(Collectors.groupingBy(TabHaobanStaffDepartmentRelated::getStaffId)) ;
List<String> depIdList = deplist.stream().map(dto->dto.getDepartmentId()).collect(Collectors.toList()) ;
List<DepartmentDTO> departmentList = this.departmentService.listByIds(depIdList);
Map<String,DepartmentDTO> depMap = departmentList.stream().collect(Collectors.toMap(DepartmentDTO::getDepartmentId, dto->dto,(k1,k2)->k1)) ;
for(StaffDTO dto : list) {
String staffId = dto.getStaffId() ;
List<TabHaobanStaffDepartmentRelated> relateList = map.get(staffId) ;
if(CollectionUtils.isNotEmpty(relateList)) {
List<DepartmentDTO> staffDepList = new ArrayList<>();
for(TabHaobanStaffDepartmentRelated item :relateList) {
if(null != depMap.get(item.getDepartmentId())) {
staffDepList.add(depMap.get(item.getDepartmentId())) ;
}
}
}
}
}
}
@Override @Override
public int updateOpenUserIdsByUserId(String wxEnterpriseId, String wxUserId, String wxOpenUseId) { public int updateOpenUserIdsByUserId(String wxEnterpriseId, String wxUserId, String wxOpenUseId) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment