|
@@ -5,9 +5,11 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.usky.common.core.exception.BusinessException;
|
|
import com.usky.common.core.exception.BusinessException;
|
|
|
import com.usky.common.core.bean.ApiResult;
|
|
import com.usky.common.core.bean.ApiResult;
|
|
|
|
|
+import com.usky.system.domain.SysDept;
|
|
|
import com.usky.system.controller.web.page.TableDataInfo;
|
|
import com.usky.system.controller.web.page.TableDataInfo;
|
|
|
import com.usky.system.domain.SysPerson;
|
|
import com.usky.system.domain.SysPerson;
|
|
|
import com.usky.system.domain.SysUserPerson;
|
|
import com.usky.system.domain.SysUserPerson;
|
|
|
|
|
+import com.usky.system.service.ISysDeptService;
|
|
|
import com.usky.system.service.SysPersonService;
|
|
import com.usky.system.service.SysPersonService;
|
|
|
import com.usky.system.service.SysUserPersonService;
|
|
import com.usky.system.service.SysUserPersonService;
|
|
|
import com.usky.common.core.util.StringUtils;
|
|
import com.usky.common.core.util.StringUtils;
|
|
@@ -38,6 +40,8 @@ public class SysPersonController extends BaseController {
|
|
|
private SysPersonService sysPersonService;
|
|
private SysPersonService sysPersonService;
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private SysUserPersonService sysUserPersonService;
|
|
private SysUserPersonService sysUserPersonService;
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private ISysDeptService sysDeptService;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 人员列表(分页)
|
|
* 人员列表(分页)
|
|
@@ -57,6 +61,33 @@ public class SysPersonController extends BaseController {
|
|
|
.like(person != null && StringUtils.isNotBlank(person.getFullName()),
|
|
.like(person != null && StringUtils.isNotBlank(person.getFullName()),
|
|
|
SysPerson::getFullName, person.getFullName());
|
|
SysPerson::getFullName, person.getFullName());
|
|
|
List<SysPerson> list = sysPersonService.list(queryWrapper);
|
|
List<SysPerson> list = sysPersonService.list(queryWrapper);
|
|
|
|
|
+
|
|
|
|
|
+ // 回显部门名称
|
|
|
|
|
+ if (list != null && !list.isEmpty()) {
|
|
|
|
|
+ List<Long> deptIds = list.stream()
|
|
|
|
|
+ .map(SysPerson::getDeptId)
|
|
|
|
|
+ .filter(Objects::nonNull)
|
|
|
|
|
+ .distinct()
|
|
|
|
|
+ .collect(Collectors.toList());
|
|
|
|
|
+ if (!deptIds.isEmpty()) {
|
|
|
|
|
+ List<SysDept> depts = sysDeptService.selectDeptByIds(deptIds);
|
|
|
|
|
+ if (depts != null && !depts.isEmpty()) {
|
|
|
|
|
+ Map<Long, String> deptNameMap = depts.stream()
|
|
|
|
|
+ .collect(Collectors.toMap(
|
|
|
|
|
+ SysDept::getDeptId,
|
|
|
|
|
+ SysDept::getDeptName,
|
|
|
|
|
+ (n1, n2) -> n1
|
|
|
|
|
+ ));
|
|
|
|
|
+ list.forEach(p -> {
|
|
|
|
|
+ String deptName = deptNameMap.get(p.getDeptId());
|
|
|
|
|
+ if (deptName != null) {
|
|
|
|
|
+ p.setDeptName(deptName);
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
// 回显每个人员对应的 userId
|
|
// 回显每个人员对应的 userId
|
|
|
if (list != null && !list.isEmpty()) {
|
|
if (list != null && !list.isEmpty()) {
|
|
|
List<Integer> personIds = list.stream()
|
|
List<Integer> personIds = list.stream()
|
|
@@ -102,6 +133,13 @@ public class SysPersonController extends BaseController {
|
|
|
if (userPerson != null) {
|
|
if (userPerson != null) {
|
|
|
person.setUserId(userPerson.getUserId());
|
|
person.setUserId(userPerson.getUserId());
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ if (person.getDeptId() != null) {
|
|
|
|
|
+ SysDept dept = sysDeptService.selectDeptById(person.getDeptId());
|
|
|
|
|
+ if (dept != null) {
|
|
|
|
|
+ person.setDeptName(dept.getDeptName());
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
return ApiResult.success(person);
|
|
return ApiResult.success(person);
|
|
|
}
|
|
}
|