|
|
@@ -15,12 +15,15 @@ import cn.iocoder.yudao.module.employee.controller.admin.info.vo.EmployeeInfoSav
|
|
|
import cn.iocoder.yudao.module.employee.convert.info.EmployeeConvert;
|
|
|
import cn.iocoder.yudao.module.employee.dal.dataobject.info.EmployeeInfoDO;
|
|
|
import cn.iocoder.yudao.module.employee.service.info.EmployeeInfoService;
|
|
|
+import cn.iocoder.yudao.module.relations.api.contract.RelationsContractApi;
|
|
|
+import cn.iocoder.yudao.module.relations.api.contract.dto.RelationsContractDTO;
|
|
|
import cn.iocoder.yudao.module.system.dal.dataobject.dept.DeptDO;
|
|
|
import cn.iocoder.yudao.module.system.dal.dataobject.dept.PostDO;
|
|
|
import cn.iocoder.yudao.module.system.service.dept.DeptService;
|
|
|
import cn.iocoder.yudao.module.system.service.dept.PostService;
|
|
|
import io.swagger.v3.oas.annotations.Operation;
|
|
|
import io.swagger.v3.oas.annotations.Parameter;
|
|
|
+import io.swagger.v3.oas.annotations.Parameters;
|
|
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
|
|
import org.springframework.security.access.prepost.PreAuthorize;
|
|
|
import org.springframework.validation.annotation.Validated;
|
|
|
@@ -53,6 +56,9 @@ public class EmployeeInfoController {
|
|
|
@Resource
|
|
|
private PostService postService;
|
|
|
|
|
|
+ @Resource
|
|
|
+ private RelationsContractApi relationsContractApi;
|
|
|
+
|
|
|
@PostMapping("/create")
|
|
|
@Operation(summary = "创建员工信息")
|
|
|
@PreAuthorize("@ss.hasPermission('employee:info:create')")
|
|
|
@@ -82,8 +88,39 @@ public class EmployeeInfoController {
|
|
|
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
|
|
@PreAuthorize("@ss.hasPermission('employee:info:query')")
|
|
|
public CommonResult<EmployeeInfoRespVO> getInfo(@RequestParam("id") Long id) {
|
|
|
+
|
|
|
EmployeeInfoDO info = infoService.getInfo(id);
|
|
|
- return success(BeanUtils.toBean(info, EmployeeInfoRespVO.class));
|
|
|
+ EmployeeInfoRespVO employeeInfoRespVO = BeanUtils.toBean(info, EmployeeInfoRespVO.class);
|
|
|
+
|
|
|
+ // 如果部门ID不为空,则尝试获取部门详细信息
|
|
|
+ Long deptId = employeeInfoRespVO.getDeptId();
|
|
|
+ if (deptId != null) {
|
|
|
+ DeptDO dept = deptService.getDept(deptId);
|
|
|
+ // 如果成功获取到部门信息,则设置部门名称到员工信息中
|
|
|
+ if (dept != null) {
|
|
|
+ employeeInfoRespVO.setDeptName(dept.getName());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 如果职位ID不为空,则尝试获取职位详细信息
|
|
|
+ Long postId = employeeInfoRespVO.getPostId();
|
|
|
+ if (postId != null) {
|
|
|
+ PostDO post = postService.getPost(postId);
|
|
|
+ // 如果成功获取到职位信息,则设置职位名称到员工信息中
|
|
|
+ if (post != null) {
|
|
|
+ employeeInfoRespVO.setPosition(post.getName());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 根据员工ID查询员工当前的合同信息
|
|
|
+ RelationsContractDTO lastContract = relationsContractApi.getLastContract(employeeInfoRespVO.getId());
|
|
|
+ // 如果员工的合同信息存在,则更新员工信息中的合同起始和结束日期
|
|
|
+ if (lastContract != null) {
|
|
|
+ employeeInfoRespVO.setContractStartDate(lastContract.getContractStartDate());
|
|
|
+ employeeInfoRespVO.setContractEndDate(lastContract.getContractEndDate());
|
|
|
+ }
|
|
|
+
|
|
|
+ return success(employeeInfoRespVO);
|
|
|
}
|
|
|
|
|
|
@GetMapping("/getLoginEmployee")
|
|
|
@@ -134,40 +171,34 @@ public class EmployeeInfoController {
|
|
|
|
|
|
|
|
|
@GetMapping("/listForSelectEmployee")
|
|
|
- @Operation(summary = "获得可选择的员工信息列表用于选择业务人")
|
|
|
+ @Operation(summary = "获得可选择的员工信息列表,用于选择业务人或审批人等")
|
|
|
+ @Parameter(name = "auth", description = "是否有权限,0无 1有", required = true)
|
|
|
+ @Parameter(name = "name", description = "员工姓名", required = false)
|
|
|
+ @Parameter(name = "deptId", description = "部门ID", required = false)
|
|
|
+ @Parameter(name = "phone", description = "员工手机号", required = false)
|
|
|
// @PreAuthorize("@ss.hasPermission('employee:info:listForSelectEmployee')")
|
|
|
- public CommonResult<List<EmployeeInfoRespVO>> getInfoListForSelectEmployee() {
|
|
|
- List<EmployeeInfoDO> listResult = infoService.getInfoListForSelectEmployee();
|
|
|
+ public CommonResult<List<EmployeeInfoRespVO>> getInfoListForSelectEmployee(@RequestParam(value = "auth", required = false) String auth,
|
|
|
+ @RequestParam(value = "name", required = false) String name,
|
|
|
+ @RequestParam(value = "deptId", required = false) Long deptId,
|
|
|
+ @RequestParam(value = "phone", required = false) String phone) {
|
|
|
+ // 查询员工信息列表
|
|
|
+ List<EmployeeInfoDO> listResult = infoService.getInfoListForSelectEmployee(auth, name, deptId, phone);
|
|
|
+ // 如果查询结果为空,则返回一个空列表
|
|
|
if (CollUtil.isEmpty(listResult)) {
|
|
|
return success(new ArrayList<>());
|
|
|
}
|
|
|
- // 拼接数据
|
|
|
- Map<Long, DeptDO> deptMap = deptService.getDeptMap(
|
|
|
- convertList(listResult, EmployeeInfoDO::getDeptId));
|
|
|
-
|
|
|
- List<Long> postIdList = listResult.stream().map(EmployeeInfoDO::getPostId).collect(Collectors.toList());
|
|
|
- List<PostDO> postList = postService.getPostList(postIdList);
|
|
|
- Map<Long, PostDO> postMap = CollectionUtils.convertMap(postList, PostDO::getId);
|
|
|
-
|
|
|
- return success(EmployeeConvert.INSTANCE.convertList(listResult, deptMap, postMap));
|
|
|
- }
|
|
|
-
|
|
|
- @GetMapping("/listForSelectAssigns")
|
|
|
- @Operation(summary = "获得员工信息列表用于选择审批人等")
|
|
|
- // @PreAuthorize("@ss.hasPermission('employee:info:listForSelectAssigns')")
|
|
|
- public CommonResult<List<EmployeeInfoRespVO>> getInfoListForSelectAssigns() {
|
|
|
- List<EmployeeInfoDO> listResult = infoService.getInfoListForSelectAssigns();
|
|
|
- if (CollUtil.isEmpty(listResult)) {
|
|
|
- return success(new ArrayList<>());
|
|
|
- }
|
|
|
- // 拼接数据
|
|
|
+ // 将查询结果中的部门ID映射为部门信息
|
|
|
Map<Long, DeptDO> deptMap = deptService.getDeptMap(
|
|
|
convertList(listResult, EmployeeInfoDO::getDeptId));
|
|
|
|
|
|
+ // 获取所有员工的岗位ID列表
|
|
|
List<Long> postIdList = listResult.stream().map(EmployeeInfoDO::getPostId).collect(Collectors.toList());
|
|
|
+ // 根据岗位ID列表查询岗位信息
|
|
|
List<PostDO> postList = postService.getPostList(postIdList);
|
|
|
+ // 将岗位ID与岗位信息映射
|
|
|
Map<Long, PostDO> postMap = CollectionUtils.convertMap(postList, PostDO::getId);
|
|
|
|
|
|
+ // 将员工信息、部门信息和岗位信息合并转换为前端所需的格式,并返回
|
|
|
return success(EmployeeConvert.INSTANCE.convertList(listResult, deptMap, postMap));
|
|
|
}
|
|
|
|