Browse Source

Merge remote-tracking branch 'origin/master_20240722' into lc_saas

dongpo 1 year ago
parent
commit
7896b34035

+ 5 - 0
yudao-module-personnel/yudao-module-employee-biz/pom.xml

@@ -27,6 +27,11 @@
             <artifactId>yudao-module-system-biz</artifactId>
             <version>${revision}</version>
         </dependency>
+        <dependency>
+            <groupId>cn.iocoder.boot</groupId>
+            <artifactId>yudao-module-relations-api</artifactId>
+            <version>${revision}</version>
+        </dependency>
 
         <!-- 业务组件 -->
         <dependency>

+ 55 - 24
yudao-module-personnel/yudao-module-employee-biz/src/main/java/cn/iocoder/yudao/module/employee/controller/admin/info/EmployeeInfoController.java

@@ -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));
     }
 

+ 8 - 0
yudao-module-personnel/yudao-module-employee-biz/src/main/java/cn/iocoder/yudao/module/employee/controller/admin/info/vo/EmployeeInfoRespVO.java

@@ -200,4 +200,12 @@ public class EmployeeInfoRespVO {
     @ExcelProperty("用户ID")
     private Long userId;
 
+    @Schema(description = "最新合同开始日期")
+    @ExcelProperty("最新合同开始日期")
+    private LocalDate contractStartDate;
+
+    @Schema(description = "最新合同结束日期")
+    @ExcelProperty("最新合同结束日期")
+    private LocalDate contractEndDate;
+
 }

+ 2 - 10
yudao-module-personnel/yudao-module-employee-biz/src/main/java/cn/iocoder/yudao/module/employee/service/info/EmployeeInfoService.java

@@ -89,19 +89,11 @@ public interface EmployeeInfoService {
     PageResult<EmployeeInfoDO> getInfoPage(EmployeeInfoPageReqVO pageReqVO);
 
     /**
-     * 获得可选择的员工信息列表,用于选择业务人
+     * 获得可选择的员工信息列表,用于选择业务人,审批人等
      *
      * @return 可选择的员工信息列表
      */
-    List<EmployeeInfoDO> getInfoListForSelectEmployee();
-
-    /**
-     * 获得员工信息列表,用于选择审批人
-     *
-     * @return 员工信息列表
-     */
-    List<EmployeeInfoDO> getInfoListForSelectAssigns();
-
+    List<EmployeeInfoDO> getInfoListForSelectEmployee(String auth, String name, Long deptId, String phone);
 
     /**
      *

+ 12 - 10
yudao-module-personnel/yudao-module-employee-biz/src/main/java/cn/iocoder/yudao/module/employee/service/info/EmployeeInfoServiceImpl.java

@@ -2,6 +2,7 @@ package cn.iocoder.yudao.module.employee.service.info;
 
 import cn.hutool.core.collection.CollUtil;
 import cn.hutool.core.util.IdUtil;
+import cn.hutool.core.util.StrUtil;
 import cn.iocoder.yudao.framework.common.pojo.PageResult;
 import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
 import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
@@ -205,17 +206,18 @@ public class EmployeeInfoServiceImpl implements EmployeeInfoService {
     }
 
     @Override
-    public List<EmployeeInfoDO> getInfoListForSelectEmployee() {
-        List<EmployeeInfoDO> employeeInfoDOList = infoMapper.selectList();
-        if (CollUtil.isEmpty(employeeInfoDOList)) {
-            return Collections.emptyList();
+    public List<EmployeeInfoDO> getInfoListForSelectEmployee(String auth, String name, Long deptId, String phone) {
+        LambdaQueryWrapper<EmployeeInfoDO> lambdaQueryWrapper = new LambdaQueryWrapper<>();
+        if (StrUtil.isNotBlank(name)) {
+            lambdaQueryWrapper.like(EmployeeInfoDO::getName, name);
         }
-        return employeeInfoDOList;
-    }
-
-    @Override
-    public List<EmployeeInfoDO> getInfoListForSelectAssigns() {
-        List<EmployeeInfoDO> employeeInfoDOList = infoMapper.selectList();
+        if (deptId != null) {
+            lambdaQueryWrapper.eq(EmployeeInfoDO::getDeptId, deptId);
+        }
+        if (StrUtil.isNotBlank(phone)) {
+            lambdaQueryWrapper.like(EmployeeInfoDO::getPhone, phone);
+        }
+        List<EmployeeInfoDO> employeeInfoDOList = infoMapper.selectList(lambdaQueryWrapper);
         if (CollUtil.isEmpty(employeeInfoDOList)) {
             return Collections.emptyList();
         }

+ 19 - 0
yudao-module-personnel/yudao-module-relations-api/src/main/java/cn/iocoder/yudao/module/relations/api/contract/RelationsContractApi.java

@@ -0,0 +1,19 @@
+package cn.iocoder.yudao.module.relations.api.contract;
+
+import cn.iocoder.yudao.module.relations.api.contract.dto.RelationsContractDTO;
+
+public interface RelationsContractApi {
+
+    /**
+     * 获取员工的最新合同信息
+     *
+     * 此方法用于根据员工ID检索系统中该员工的最新合同信息详情
+     * 它解释了为什么需要这个方法:为了确保能够获取到员工当前的有效合同,以便进行后续的相关操作或查询
+     *
+     * @param employeeId 员工ID
+     *                  员工ID是唯一标识员工的键值,此参数用于定位特定员工的合同信息
+     * @return RelationsContractDTO 返回员工的最新合同信息
+     *                 返回的数据传输对象(DTO)包含员工最新合同的详细信息,如合同类型、有效期等
+     */
+    RelationsContractDTO getLastContract(Long employeeId);
+}

+ 76 - 0
yudao-module-personnel/yudao-module-relations-api/src/main/java/cn/iocoder/yudao/module/relations/api/contract/dto/RelationsContractDTO.java

@@ -0,0 +1,76 @@
+package cn.iocoder.yudao.module.relations.api.contract.dto;
+
+import lombok.Data;
+
+import java.time.LocalDate;
+import java.time.LocalDateTime;
+import java.util.List;
+
+@Data
+public class RelationsContractDTO {
+
+    /**
+     * 自增ID
+     */
+    private Long id;
+    /**
+     * 业务UUID
+     */
+    private String contractId;
+    /**
+     * 员工姓名
+     */
+    private String employeeName;
+    /**
+     * 部门ID
+     */
+    private Long deptId;
+    /**
+     * 部门名称
+     */
+    private String deptName;
+    /**
+     * 职位编号
+     */
+    private Long postId;
+    /**
+     * 职位名称
+     */
+    private String position;
+    /**
+     * 员工编号
+     */
+    private String employeeNumber;
+    /**
+     * 员工手机号
+     */
+    private String employeePhone;
+    /**
+     * 合同开始日期
+     */
+    private LocalDate contractStartDate;
+    /**
+     * 合同结束日期
+     */
+    private LocalDate contractEndDate;
+    /**
+     * 合同期限
+     */
+    private String contractDeadline;
+    /**
+     * 备注信息
+     */
+    private String remarks;
+    /**
+     * 状态
+     */
+    private Integer status;
+    /**
+     * 员工ID
+     */
+    private Long employeeId;
+    /**
+     * 租户编号
+     */
+    private Long tenantId;
+}

+ 33 - 0
yudao-module-personnel/yudao-module-relations-biz/src/main/java/cn/iocoder/yudao/module/relations/api/contract/RelationsContractApiImpl.java

@@ -0,0 +1,33 @@
+package cn.iocoder.yudao.module.relations.api.contract;
+
+import cn.hutool.core.collection.CollUtil;
+import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
+import cn.iocoder.yudao.module.relations.api.contract.dto.RelationsContractDTO;
+import cn.iocoder.yudao.module.relations.dal.dataobject.contract.RelationsContractDO;
+import cn.iocoder.yudao.module.relations.service.contract.RelationsContractService;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.Resource;
+import java.util.List;
+
+@Service
+public class RelationsContractApiImpl implements RelationsContractApi{
+
+    @Resource
+    private RelationsContractService relationsContractService;
+
+    @Override
+    public RelationsContractDTO getLastContract(Long employeeId) {
+        // 根据员工ID查询关联合同信息列表
+        List<RelationsContractDO> relationsContractDOList = relationsContractService.getContractInfoList(employeeId);
+        // 如果列表不为空
+        if (CollUtil.isNotEmpty(relationsContractDOList)) {
+            // 获取列表中的第一个关联合同信息
+            RelationsContractDO relationsContractDO = relationsContractDOList.get(0);
+            // 将关联合同信息转换为DTO对象并返回
+            return BeanUtils.toBean(relationsContractDO, RelationsContractDTO.class);
+        }
+        // 如果列表为空,返回null
+        return null;
+    }
+}

+ 11 - 0
yudao-module-personnel/yudao-module-relations-biz/src/main/java/cn/iocoder/yudao/module/relations/service/contract/RelationsContractService.java

@@ -8,6 +8,7 @@ import cn.iocoder.yudao.module.relations.controller.admin.contract.vo.RelationsC
 import cn.iocoder.yudao.module.relations.dal.dataobject.contract.RelationsContractDO;
 
 import javax.validation.Valid;
+import java.util.List;
 
 /**
  * 员工合同信息 Service 接口
@@ -70,4 +71,14 @@ public interface RelationsContractService {
      */
     int effectiveContractInfo();
 
+    /**
+     * 根据员工ID获取合同信息列表
+     *
+     * 此方法用于查询特定员工相关的合同信息列表它提供了一种根据员工ID检索该员工所有相关合同的方式,
+     * 使得用户可以在系统中查看和分析员工的合同情况
+     *
+     * @param employeeId 员工ID,用于定位特定员工的相关合同信息
+     * @return 返回一个包含特定员工所有相关合同信息的列表
+     */
+    List<RelationsContractDO> getContractInfoList(Long employeeId);
 }

+ 16 - 0
yudao-module-personnel/yudao-module-relations-biz/src/main/java/cn/iocoder/yudao/module/relations/service/contract/RelationsContractServiceImpl.java

@@ -14,6 +14,7 @@ import cn.iocoder.yudao.module.relations.controller.admin.contract.vo.RelationsC
 import cn.iocoder.yudao.module.relations.dal.dataobject.contract.RelationsContractDO;
 import cn.iocoder.yudao.module.relations.dal.mysql.contract.RelationsContractMapper;
 import cn.iocoder.yudao.module.relations.enums.contractinfo.ContractInfoStatusEnum;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import org.springframework.stereotype.Service;
 import org.springframework.validation.annotation.Validated;
 import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
@@ -180,6 +181,21 @@ public class RelationsContractServiceImpl implements RelationsContractService {
         return doneContracts.size();
     }
 
+    @Override
+    public List<RelationsContractDO> getContractInfoList(Long employeeId) {
+        // 检查员工ID是否为空,如果为空则直接返回一个空的列表
+        if (employeeId == null) {
+            return Collections.emptyList();
+        }
+        // 创建一个查询包装器,用于构建查询条件
+        LambdaQueryWrapper<RelationsContractDO> lambdaQueryWrapper = new LambdaQueryWrapper<>();
+        // 设置查询条件,查找与给定员工ID相匹配的合同记录,并按创建时间降序排序
+        lambdaQueryWrapper.eq(RelationsContractDO::getEmployeeId, employeeId)
+                .orderByDesc(RelationsContractDO::getCreateTime);
+        // 执行查询并返回结果列表
+        return contractMapper.selectList(lambdaQueryWrapper);
+    }
+
     /**
      * 保存业务uuid到附件中
      */