From ffec90c897e9bd78e88b9fa590a5dd75d26b82c8 Mon Sep 17 00:00:00 2001
From: tuqin <tuqin@local>
Date: 星期五, 06 十一月 2026 11:38:23 +0800
Subject: [PATCH] fix(hrm): 修复员工导入失败(日期格式 + 部门/岗位/角色不存在)
---
yudao-module-hrm/src/main/java/cn/iocoder/yudao/module/hrm/controller/admin/salary/HrmSalaryCalculationController.java | 44 +++++++++++++++++++++++++++++++++++++-------
1 files changed, 37 insertions(+), 7 deletions(-)
diff --git a/yudao-module-hrm/src/main/java/cn/iocoder/yudao/module/hrm/controller/admin/salary/HrmSalaryCalculationController.java b/yudao-module-hrm/src/main/java/cn/iocoder/yudao/module/hrm/controller/admin/salary/HrmSalaryCalculationController.java
index b90e2bc..e55d7de 100644
--- a/yudao-module-hrm/src/main/java/cn/iocoder/yudao/module/hrm/controller/admin/salary/HrmSalaryCalculationController.java
+++ b/yudao-module-hrm/src/main/java/cn/iocoder/yudao/module/hrm/controller/admin/salary/HrmSalaryCalculationController.java
@@ -16,6 +16,7 @@
import cn.iocoder.yudao.module.hrm.service.salary.HrmSalaryCalculationService;
import cn.iocoder.yudao.module.system.api.dept.DeptApi;
import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO;
+import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
@@ -31,7 +32,9 @@
import java.util.stream.Collectors;
import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPORT;
+import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
+import static cn.iocoder.yudao.module.hrm.enums.ErrorCodeConstants.SALARY_CALCULATION_NOT_EXISTS;
@Tag(name = "绠$悊鍚庡彴 - HRM 钖叕鏍哥畻")
@RestController
@@ -45,6 +48,29 @@
private HrmEmployeeService employeeService;
@Resource
private DeptApi deptApi;
+
+ @GetMapping("/my-page")
+ @Operation(summary = "鑾峰緱鎴戠殑钖祫鏍哥畻鍒嗛〉")
+ public CommonResult<PageResult<HrmSalaryCalculationRespVO>> getMySalaryCalculationPage(@Valid HrmSalaryCalculationPageReqVO pageReqVO) {
+ // 鍙煡褰撳墠鐧诲綍浜鸿嚜宸辩殑钖祫锛屾棤闇�钖叕鏌ヨ鏉冮檺锛岀櫥褰曞嵆鍙闂�
+ PageResult<HrmSalaryCalculationDO> pageResult = salaryCalculationService
+ .getMySalaryCalculationPage(SecurityFrameworkUtils.getLoginUserId(), pageReqVO);
+ List<HrmSalaryCalculationRespVO> list = BeanUtils.toBean(pageResult.getList(), HrmSalaryCalculationRespVO.class);
+ return success(new PageResult<>(list, pageResult.getTotal()));
+ }
+
+ @GetMapping("/my-get")
+ @Operation(summary = "鑾峰緱鎴戠殑钖祫鏍哥畻")
+ @Parameter(name = "id", description = "缂栧彿", required = true, example = "1024")
+ public CommonResult<HrmSalaryCalculationRespVO> getMySalaryCalculation(@RequestParam("id") Long id) {
+ HrmSalaryCalculationDO calculation = salaryCalculationService
+ .getMySalaryCalculation(id, SecurityFrameworkUtils.getLoginUserId());
+ // 璁板綍涓嶅瓨鍦ㄣ�佹垨涓嶅睘浜庡綋鍓嶇櫥褰曚汉鏃剁粺涓�杩斿洖鈥滀笉瀛樺湪鈥濓紝閬垮厤娉勯湶浠栦汉钖祫鏄惁瀛樺湪
+ if (calculation == null) {
+ throw exception(SALARY_CALCULATION_NOT_EXISTS);
+ }
+ return success(BeanUtils.toBean(calculation, HrmSalaryCalculationRespVO.class));
+ }
@GetMapping("/page")
@Operation(summary = "鑾峰緱钖叕鏍哥畻鍒嗛〉")
@@ -64,16 +90,18 @@
* 濉厖鍛樺伐鍜岄儴闂ㄤ俊鎭紙userId 鏄憳宸D锛�
*/
private void fillUserInfo(List<HrmSalaryCalculationRespVO> respList, List<HrmSalaryCalculationDO> calculationList) {
- // userId 鏄憳宸D锛屾壒閲忚幏鍙栧憳宸ヤ俊鎭�
- Set<Long> employeeIds = calculationList.stream()
+ // 娉ㄦ剰锛氭牳绠楄褰曠殑 userId 瀛樼殑鏄�岀郴缁熻处鍙� ID銆嶏紙system_users.id锛夛紝
+ // 涓嶆槸鍛樺伐妗f涓婚敭锛坔rm_employee.id锛夈�傜敤 getEmployee 浼氭案杩滄煡涓嶅埌锛�
+ // 瀵艰嚧鍒楄〃閲屻�屽憳宸ュ鍚嶃�嶄竴鍒楀叏绌恒�傚繀椤荤敤 getEmployeeByUserId銆�
+ Set<Long> userIds = calculationList.stream()
.map(HrmSalaryCalculationDO::getUserId)
.filter(Objects::nonNull)
.collect(Collectors.toSet());
Map<Long, HrmEmployeeDO> employeeMap = new HashMap<>();
- for (Long employeeId : employeeIds) {
- HrmEmployeeDO employee = employeeService.getEmployee(employeeId);
+ for (Long userId : userIds) {
+ HrmEmployeeDO employee = employeeService.getEmployeeByUserId(userId);
if (employee != null) {
- employeeMap.put(employeeId, employee);
+ employeeMap.put(userId, employee);
}
}
@@ -107,9 +135,11 @@
return success(null);
}
HrmSalaryCalculationRespVO respVO = BeanUtils.toBean(salaryCalculation, HrmSalaryCalculationRespVO.class);
- // 濉厖鍛樺伐鍜岄儴闂ㄤ俊鎭紙userId 鏄憳宸D锛�
+ // 濉厖鍛樺伐鍜岄儴闂ㄤ俊鎭�
+ // 娉ㄦ剰锛氭牳绠楄褰曠殑 userId 瀛樼殑鏄�岀郴缁熻处鍙� ID銆嶏紙system_users.id锛夛紝
+ // 涓嶆槸鍛樺伐妗f涓婚敭锛坔rm_employee.id锛夛紝蹇呴』鐢� getEmployeeByUserId 鏌�
if (salaryCalculation.getUserId() != null) {
- HrmEmployeeDO employee = employeeService.getEmployee(salaryCalculation.getUserId());
+ HrmEmployeeDO employee = employeeService.getEmployeeByUserId(salaryCalculation.getUserId());
if (employee != null) {
respVO.setUserName(employee.getName());
}
--
Gitblit v1.9.3