From 52feee3e55403d2858da59605173ec055f601bfa Mon Sep 17 00:00:00 2001
From: tuqin <tuqin@tuqin.cn>
Date: 星期六, 24 十月 2026 19:47:25 +0800
Subject: [PATCH] feat(hrm): 同步新疆中亿装配的人力资源模块到北方科技
---
yudao-module-hrm/src/main/java/cn/iocoder/yudao/module/hrm/controller/admin/attendance/HrmAttendanceRecordController.java | 92 +++++++++++++++++++---------------------------
1 files changed, 38 insertions(+), 54 deletions(-)
diff --git a/yudao-module-hrm/src/main/java/cn/iocoder/yudao/module/hrm/controller/admin/attendance/HrmAttendanceRecordController.java b/yudao-module-hrm/src/main/java/cn/iocoder/yudao/module/hrm/controller/admin/attendance/HrmAttendanceRecordController.java
index 0528f3e..8bbe2ef 100644
--- a/yudao-module-hrm/src/main/java/cn/iocoder/yudao/module/hrm/controller/admin/attendance/HrmAttendanceRecordController.java
+++ b/yudao-module-hrm/src/main/java/cn/iocoder/yudao/module/hrm/controller/admin/attendance/HrmAttendanceRecordController.java
@@ -2,34 +2,31 @@
import cn.hutool.core.collection.CollUtil;
import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog;
+import cn.iocoder.yudao.framework.common.exception.ServiceException;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
-import cn.iocoder.yudao.framework.operatelog.core.util.OperateLogUtils;
-import cn.iocoder.yudao.module.hrm.controller.admin.attendance.vo.HrmAttendanceMyStatusRespVO;
import cn.iocoder.yudao.module.hrm.controller.admin.attendance.vo.HrmAttendanceRecordImportExcelVO;
import cn.iocoder.yudao.module.hrm.controller.admin.attendance.vo.HrmAttendanceRecordImportReqVO;
import cn.iocoder.yudao.module.hrm.controller.admin.attendance.vo.HrmAttendanceRecordPageReqVO;
import cn.iocoder.yudao.module.hrm.controller.admin.attendance.vo.HrmAttendanceRecordRespVO;
+import cn.iocoder.yudao.module.hrm.controller.admin.attendance.vo.HrmAttendanceMyStatusRespVO;
import cn.iocoder.yudao.module.hrm.dal.dataobject.attendance.HrmAttendanceRecordDO;
import cn.iocoder.yudao.module.hrm.dal.dataobject.employee.HrmEmployeeDO;
-import cn.iocoder.yudao.module.hrm.enums.HrmAttendanceClockTypeEnum;
import cn.iocoder.yudao.module.hrm.service.attendance.HrmAttendanceRecordService;
import cn.iocoder.yudao.module.hrm.service.employee.HrmEmployeeService;
import cn.iocoder.yudao.module.system.api.dept.DeptApi;
import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO;
import cn.iocoder.yudao.module.system.api.user.AdminUserApi;
import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO;
-import com.mzt.logapi.starter.annotation.LogRecord;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.validation.Valid;
-import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
@@ -43,9 +40,7 @@
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.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY;
import static cn.iocoder.yudao.module.hrm.enums.ErrorCodeConstants.EMPLOYEE_NOT_EXISTS;
-import static cn.iocoder.yudao.module.hrm.enums.LogRecordConstants.*;
@Tag(name = "绠$悊鍚庡彴 - HRM 鑰冨嫟璁板綍")
@RestController
@@ -64,46 +59,16 @@
@PostMapping("/clock-in")
@Operation(summary = "涓婄彮鎵撳崱")
+ @PreAuthorize("@ss.hasPermission('hrm:attendance-record:clock')")
public CommonResult<HrmAttendanceRecordRespVO> clockIn(@RequestParam("location") String location) {
Long loginUserId = getLoginUserId();
HrmEmployeeDO employee = employeeService.getEmployeeByUserId(loginUserId);
if (employee == null) {
- throw exception(EMPLOYEE_NOT_EXISTS,
- "褰撳墠鐧诲綍璐﹀彿鏈叧鑱斿憳宸ユ。妗堬紝鏃犳硶鎵撳崱銆傝鑱旂郴绠$悊鍛樺湪銆愬憳宸ョ鐞嗐�戜腑灏嗚鐧诲綍璐﹀彿缁戝畾鍒板憳宸ャ��");
+ throw new ServiceException(EMPLOYEE_NOT_EXISTS.getCode(),
+ "褰撳墠鐧诲綍璐﹀彿鏈叧鑱斿憳宸ヤ俊鎭紝鏃犳硶鎵撳崱銆傝鑱旂郴绠$悊鍛樺湪銆愬憳宸ョ鐞嗐�戜腑灏嗚鐧诲綍璐﹀彿缁戝畾鍒板憳宸ャ��");
}
HrmAttendanceRecordDO record = attendanceRecordService.clockIn(employee.getId(), LocalDateTime.now(), location);
- return success(buildClockRespVO(record, employee));
- }
-
- @PostMapping("/clock-out")
- @Operation(summary = "涓嬬彮鎵撳崱")
- public CommonResult<HrmAttendanceRecordRespVO> clockOut(@RequestParam("location") String location) {
- Long loginUserId = getLoginUserId();
- HrmEmployeeDO employee = employeeService.getEmployeeByUserId(loginUserId);
- if (employee == null) {
- throw exception(EMPLOYEE_NOT_EXISTS,
- "褰撳墠鐧诲綍璐﹀彿鏈叧鑱斿憳宸ユ。妗堬紝鏃犳硶鎵撳崱銆傝鑱旂郴绠$悊鍛樺湪銆愬憳宸ョ鐞嗐�戜腑灏嗚鐧诲綍璐﹀彿缁戝畾鍒板憳宸ャ��");
- }
- HrmAttendanceRecordDO record = attendanceRecordService.clockOut(employee.getId(), LocalDateTime.now(), location);
- return success(buildClockRespVO(record, employee));
- }
-
- @GetMapping("/my-status")
- @Operation(summary = "鑾峰緱褰撳墠鐧诲綍浜虹殑鑰冨嫟鐘舵��")
- @Parameter(name = "date", description = "鑰冨嫟鏃ユ湡锛屾牸寮� yyyy-MM-dd锛岄粯璁ゆ湇鍔″櫒褰撳ぉ", example = "2026-10-17")
- public CommonResult<HrmAttendanceMyStatusRespVO> getMyStatus(
- @RequestParam(value = "date", required = false)
- @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY) LocalDate date) {
- return success(attendanceRecordService.getMyStatus(getLoginUserId(), date));
- }
-
- /**
- * 鏋勫缓鎵撳崱杩斿洖 VO锛屽瓧娈典笌 my-status.record 淇濇寔涓�鑷�
- */
- private HrmAttendanceRecordRespVO buildClockRespVO(HrmAttendanceRecordDO record, HrmEmployeeDO employee) {
HrmAttendanceRecordRespVO respVO = BeanUtils.toBean(record, HrmAttendanceRecordRespVO.class);
- respVO.setClockInTypeName(HrmAttendanceClockTypeEnum.getNameByType(record.getClockInType()));
- respVO.setClockOutTypeName(HrmAttendanceClockTypeEnum.getNameByType(record.getClockOutType()));
respVO.setUserName(employee.getName());
if (record.getDeptId() != null) {
DeptRespDTO dept = deptApi.getDept(record.getDeptId());
@@ -111,12 +76,42 @@
respVO.setDeptName(dept.getName());
}
}
- return respVO;
+ return success(respVO);
+ }
+
+ @PostMapping("/clock-out")
+ @Operation(summary = "涓嬬彮鎵撳崱")
+ @PreAuthorize("@ss.hasPermission('hrm:attendance-record:clock')")
+ public CommonResult<HrmAttendanceRecordRespVO> clockOut(@RequestParam("location") String location) {
+ Long loginUserId = getLoginUserId();
+ HrmEmployeeDO employee = employeeService.getEmployeeByUserId(loginUserId);
+ if (employee == null) {
+ throw new ServiceException(EMPLOYEE_NOT_EXISTS.getCode(),
+ "褰撳墠鐧诲綍璐﹀彿鏈叧鑱斿憳宸ヤ俊鎭紝鏃犳硶鎵撳崱銆傝鑱旂郴绠$悊鍛樺湪銆愬憳宸ョ鐞嗐�戜腑灏嗚鐧诲綍璐﹀彿缁戝畾鍒板憳宸ャ��");
+ }
+ HrmAttendanceRecordDO record = attendanceRecordService.clockOut(employee.getId(), LocalDateTime.now(), location);
+ HrmAttendanceRecordRespVO respVO = BeanUtils.toBean(record, HrmAttendanceRecordRespVO.class);
+ respVO.setUserName(employee.getName());
+ if (record.getDeptId() != null) {
+ DeptRespDTO dept = deptApi.getDept(record.getDeptId());
+ if (dept != null) {
+ respVO.setDeptName(dept.getName());
+ }
+ }
+ return success(respVO);
+ }
+
+ @GetMapping("/my-status")
+ @Operation(summary = "鑾峰緱褰撳墠鐧诲綍浜虹殑鑰冨嫟鐘舵��", description = "App 鎵撳崱椤典娇鐢細杩斿洖褰撴棩鑰冨嫟瑙勫垯銆佹墦鍗¤褰曚笌鍙墦鍗$姸鎬�")
+ @Parameter(name = "date", description = "鑰冨嫟鏃ユ湡锛屾牸寮� yyyy-MM-dd锛岄粯璁ゆ湇鍔″櫒褰撳ぉ", example = "2026-10-17")
+ public CommonResult<HrmAttendanceMyStatusRespVO> getMyStatus(
+ @RequestParam(value = "date", required = false)
+ @org.springframework.format.annotation.DateTimeFormat(pattern = "yyyy-MM-dd") LocalDate date) {
+ return success(attendanceRecordService.getMyStatus(getLoginUserId(), date));
}
private Long getLoginUserId() {
- return cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId();
- }
+ return cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId(); }
@GetMapping("/page")
@Operation(summary = "鑾峰緱鑰冨嫟璁板綍鍒嗛〉")
@@ -222,18 +217,12 @@
@PostMapping("/import")
@Operation(summary = "瀵煎叆鑰冨嫟璁板綍")
@PreAuthorize("@ss.hasPermission('hrm:attendance-record:import')")
- @LogRecord(type = HRM_ATTENDANCE_RECORD_TYPE, subType = HRM_ATTENDANCE_RECORD_IMPORT_SUB_TYPE, bizNo = "0",
- success = HRM_ATTENDANCE_RECORD_IMPORT_SUCCESS)
public CommonResult<String> importExcel(@Valid HrmAttendanceRecordImportReqVO importReqVO) throws IOException {
List<HrmAttendanceRecordImportExcelVO> list = ExcelUtils.read(importReqVO.getFile(), HrmAttendanceRecordImportExcelVO.class);
if (CollUtil.isEmpty(list)) {
- // 璁板綍瀵煎叆缁撴灉姹囨�伙紝渚� @LogRecord 鐨� success 鏂囨寮曠敤
- OperateLogUtils.putImportSummary(0, null, null);
return success("娌℃湁鍙鍏ョ殑鏁版嵁");
}
int successCount = 0;
- int createCount = 0; // 鏂板鐨勮褰曟暟
- int updateCount = 0; // 鏇存柊鐨勮褰曟暟锛堜粎鍕鹃�夈�屾敮鎸佹洿鏂般�嶆椂鎵嶄細璧版洿鏂帮級
Set<String> missingNames = new LinkedHashSet<>();
Set<String> duplicateNames = new LinkedHashSet<>();
Set<String> invalidRows = new LinkedHashSet<>();
@@ -279,7 +268,6 @@
.location(item.getLocation()).remark(item.getRemark())
.dataSource(2).build();
attendanceRecordService.createImportedRecord(record);
- createCount++;
} else if (Boolean.TRUE.equals(importReqVO.getUpdateSupport())) {
record.setClockInTime(item.getClockInTime());
record.setClockOutTime(item.getClockOutTime());
@@ -288,7 +276,6 @@
record.setLocation(item.getLocation());
record.setRemark(item.getRemark());
attendanceRecordService.updateImportedRecord(record);
- updateCount++;
}
successCount++;
}
@@ -302,9 +289,6 @@
if (!invalidRows.isEmpty()) {
msg.append("锛涗互涓嬭褰曟暟鎹笉瀹屾暣锛屾湭鑳藉鍏ワ細").append(String.join("銆�", invalidRows));
}
- // 璁板綍瀵煎叆缁撴灉姹囨�伙紝渚� @LogRecord 鐨� success 鏂囨寮曠敤
- OperateLogUtils.putImportSummary(createCount, updateCount,
- missingNames.size() + duplicateNames.size() + invalidRows.size());
return success(msg.toString());
}
--
Gitblit v1.9.3