|
|
@@ -1,13 +1,18 @@
|
|
|
package cn.iocoder.yudao.module.attendance.service.employeesetting;
|
|
|
|
|
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
|
|
+import cn.iocoder.yudao.framework.security.core.LoginUser;
|
|
|
+import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils;
|
|
|
import cn.iocoder.yudao.framework.tenant.core.aop.TenantIgnore;
|
|
|
+import cn.iocoder.yudao.module.attendance.controller.admin.employeesetting.vo.AttendanceEmployeeSettingBatchSaveReqVO;
|
|
|
import cn.iocoder.yudao.module.attendance.controller.admin.employeesetting.vo.AttendanceEmployeeSettingPageReqVO;
|
|
|
import cn.iocoder.yudao.module.attendance.controller.admin.employeesetting.vo.AttendanceEmployeeSettingRespVO;
|
|
|
import cn.iocoder.yudao.module.attendance.controller.admin.employeesetting.vo.AttendanceEmployeeSettingSaveReqVO;
|
|
|
import cn.iocoder.yudao.module.attendance.controller.admin.info.vo.AttendanceDailyInfoRespVO;
|
|
|
import cn.iocoder.yudao.module.attendance.dal.dataobject.employeesetting.AttendanceEmployeeSettingDO;
|
|
|
import cn.iocoder.yudao.module.attendance.dal.mysql.employeesetting.AttendanceEmployeeSettingMapper;
|
|
|
+import cn.iocoder.yudao.module.employee.dal.dataobject.info.EmployeeInfoDO;
|
|
|
+import cn.iocoder.yudao.module.employee.service.info.EmployeeInfoService;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.validation.annotation.Validated;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
@@ -19,6 +24,8 @@ import javax.annotation.Resource;
|
|
|
|
|
|
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
|
|
import static cn.iocoder.yudao.module.attendance.enums.ErrorCodeConstants.ATTENDANCE_EMPLOYEE_SETTING_NOT_EXISTS;
|
|
|
+import static cn.iocoder.yudao.module.attendance.enums.ErrorCodeConstants.ATTENDANCE_SCHEDULING_MANAGE_NOT_EXISTS;
|
|
|
+import static cn.iocoder.yudao.module.employee.enums.ErrorCodeConstants.EMPLOYEE_INFO_NOT_EXISTS;
|
|
|
|
|
|
/**
|
|
|
* 考勤员工设置 Service 实现类
|
|
|
@@ -31,6 +38,8 @@ public class AttendanceEmployeeSettingServiceImpl implements AttendanceEmployeeS
|
|
|
|
|
|
@Resource
|
|
|
private AttendanceEmployeeSettingMapper employeeSettingMapper;
|
|
|
+ @Resource
|
|
|
+ private EmployeeInfoService employeeInfoService;
|
|
|
|
|
|
@Override
|
|
|
@TenantIgnore
|
|
|
@@ -80,10 +89,77 @@ public class AttendanceEmployeeSettingServiceImpl implements AttendanceEmployeeS
|
|
|
return employeeSettingMapper.selectPage(pageReqVO);
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ @TenantIgnore
|
|
|
+ public PageResult<AttendanceEmployeeSettingRespVO> getEmployeeInfoSettingPage(AttendanceEmployeeSettingPageReqVO pageReqVO) {
|
|
|
+ // 获取用户信息和租户ID
|
|
|
+ LoginUser user = SecurityFrameworkUtils.getLoginUser();
|
|
|
+ Long tenantId = user != null && user.getTenantId() != null ? user.getTenantId() : 0L;
|
|
|
+ pageReqVO.setTenantId(tenantId);
|
|
|
+ List<AttendanceEmployeeSettingRespVO> list = employeeSettingMapper.getEmployeeInfoSettingPage(pageReqVO);
|
|
|
+ return new PageResult<>(list, (long) list.size());
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
@TenantIgnore
|
|
|
public AttendanceEmployeeSettingRespVO getByEmployeeId(Long employeeId) {
|
|
|
return employeeSettingMapper.getByEmployeeId(employeeId);
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ @TenantIgnore
|
|
|
+ public void batchUpdateEmployeeSetting(AttendanceEmployeeSettingBatchSaveReqVO updateReqVO) {
|
|
|
+ List<Long> employeeIds = updateReqVO.getEmployeeIds();
|
|
|
+ Long schedulingId = updateReqVO.getSchedulingId();
|
|
|
+ if (schedulingId == null) {
|
|
|
+ throw exception(ATTENDANCE_SCHEDULING_MANAGE_NOT_EXISTS);
|
|
|
+ }
|
|
|
+ for (Long employeeId : employeeIds) {
|
|
|
+ // 校验存在
|
|
|
+ boolean exists = validateEmployeeSettingExistsByEmployeeId(employeeId);
|
|
|
+ if (exists) {
|
|
|
+ // 更新
|
|
|
+ AttendanceEmployeeSettingDO updateObj = new AttendanceEmployeeSettingDO();
|
|
|
+ updateObj.setSchedulingId(schedulingId);
|
|
|
+ employeeSettingMapper.updateById(updateObj);
|
|
|
+ } else {
|
|
|
+ // 先查询员工信息
|
|
|
+ EmployeeInfoDO employeeInfoDO = employeeInfoService.getInfo(employeeId);
|
|
|
+ if (employeeInfoDO == null) {
|
|
|
+ throw exception(EMPLOYEE_INFO_NOT_EXISTS);
|
|
|
+ }
|
|
|
+ // 新增
|
|
|
+ AttendanceEmployeeSettingDO employeeSetting = new AttendanceEmployeeSettingDO();
|
|
|
+ // 设置非空字段
|
|
|
+ if (employeeInfoDO.getName() != null) {
|
|
|
+ employeeSetting.setName(employeeInfoDO.getName());
|
|
|
+ }
|
|
|
+ if (employeeInfoDO.getDeptId() != null) {
|
|
|
+ employeeSetting.setDeptId(employeeInfoDO.getDeptId());
|
|
|
+ }
|
|
|
+ employeeSetting.setSchedulingId(schedulingId);
|
|
|
+ employeeSetting.setEmployeeId(employeeId);
|
|
|
+
|
|
|
+ if (employeeInfoDO.getEmail() != null) {
|
|
|
+ employeeSetting.setEmail(employeeInfoDO.getEmail());
|
|
|
+ }
|
|
|
+ if (employeeInfoDO.getPhone() != null) {
|
|
|
+ employeeSetting.setPhoneNumber(employeeInfoDO.getPhone());
|
|
|
+ }
|
|
|
+
|
|
|
+ if (employeeInfoDO.getTenantId() != null) {
|
|
|
+ employeeSetting.setTenantId(employeeInfoDO.getTenantId());
|
|
|
+ }
|
|
|
+
|
|
|
+ employeeSettingMapper.insert(employeeSetting);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @TenantIgnore
|
|
|
+ private boolean validateEmployeeSettingExistsByEmployeeId(Long employeeId) {
|
|
|
+ return employeeSettingMapper.getByEmployeeId(employeeId) != null;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
}
|