|
@@ -45,6 +45,7 @@ import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.validation.annotation.Validated;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
+import java.math.BigDecimal;
|
|
|
import java.time.LocalDateTime;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.Arrays;
|
|
@@ -55,6 +56,7 @@ import java.util.Objects;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
|
|
+import static cn.iocoder.yudao.module.attendance.enums.ErrorCodeConstants.ATTENDANCE_EMAINING_ANNUAL_LEAVE_IS_INSUFFICIENT;
|
|
|
import static cn.iocoder.yudao.module.bpm.enums.ErrorCodeConstants.OA_LEAVE_NOT_EXISTS;
|
|
|
|
|
|
/**
|
|
@@ -159,6 +161,17 @@ public class OaLeaveServiceImpl implements OaLeaveService {
|
|
|
throw exception(ErrorCodeConstants.OA_EMPLOYEE_NOT_EXISTS);
|
|
|
}
|
|
|
|
|
|
+ if ("年假".equals(commitReqVO.getLeaveType())) {
|
|
|
+ // 获取剩余年假和申请天数
|
|
|
+ BigDecimal remainingAnnualLeave = loginEmployee.getRemainingAnnualLeave();
|
|
|
+ String requestDayStr = commitReqVO.getDay(); // 更清晰的变量名
|
|
|
+ BigDecimal requestDays = new BigDecimal(requestDayStr); // 假设getDay返回的是可以解析为double的字符串
|
|
|
+ // 检查剩余年假是否足够
|
|
|
+ if (remainingAnnualLeave.compareTo(requestDays) < 0) {
|
|
|
+ throw exception(ATTENDANCE_EMAINING_ANNUAL_LEAVE_IS_INSUFFICIENT);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
OaLeaveDO oaLeave = BeanUtils.toBean(commitReqVO, OaLeaveDO.class);
|
|
|
if (StringUtils.isBlank(oaLeave.getLeaveId())) {
|
|
@@ -269,11 +282,30 @@ public class OaLeaveServiceImpl implements OaLeaveService {
|
|
|
if (currentTask == null) {
|
|
|
throw exception(ErrorCodeConstants.TASK_NOT_EXISTS);
|
|
|
}
|
|
|
- // 先更新为审批中
|
|
|
- taskService.setVariable(currentTask.getId(), BpmConstants.PROCESS_INSTANCE_VARIABLE_STATUS, DictDataConstants.OA_AUDIT_STATUS_AUDITING);
|
|
|
LambdaQueryWrapper<OaLeaveDO> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
lambdaQueryWrapper.eq(OaLeaveDO::getProcInstId, currentTask.getProcessInstanceId());
|
|
|
OaLeaveDO oaLeave = oaLeaveMapper.selectOne(lambdaQueryWrapper);
|
|
|
+ if (oaLeave == null) {
|
|
|
+ throw exception(ErrorCodeConstants.OA_LEAVE_NOT_EXISTS);
|
|
|
+ }
|
|
|
+
|
|
|
+ if ("年假".equals(oaLeave.getLeaveType())) {
|
|
|
+ // 请假人
|
|
|
+ Long employeeId = oaLeave.getEmployeeId();
|
|
|
+ EmployeeRespDTO employee = employeeApi.getEmployeeById(employeeId);
|
|
|
+ // 获取剩余年假和申请天数
|
|
|
+ BigDecimal remainingAnnualLeave = employee.getRemainingAnnualLeave();
|
|
|
+ String requestDayStr = oaLeave.getDay(); // 更清晰的变量名
|
|
|
+ BigDecimal requestDays = new BigDecimal(requestDayStr); // 假设getDay返回的是可以解析为double的字符串
|
|
|
+ // 检查剩余年假是否足够
|
|
|
+ if (remainingAnnualLeave.compareTo(requestDays) < 0) {
|
|
|
+ throw exception(ATTENDANCE_EMAINING_ANNUAL_LEAVE_IS_INSUFFICIENT);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 先更新为审批中
|
|
|
+ taskService.setVariable(currentTask.getId(), BpmConstants.PROCESS_INSTANCE_VARIABLE_STATUS, DictDataConstants.OA_AUDIT_STATUS_AUDITING);
|
|
|
+
|
|
|
// 如果是最后一个人审批同意,设置流程审批状态为已审核
|
|
|
String[] auditPersons = oaLeave.getStartUserSelectAssignees().split(",");
|
|
|
String lastAuditPerson = Arrays.stream(auditPersons)
|
|
@@ -480,6 +512,18 @@ public class OaLeaveServiceImpl implements OaLeaveService {
|
|
|
throw exception(ErrorCodeConstants.OA_EMPLOYEE_NOT_EXISTS);
|
|
|
}
|
|
|
|
|
|
+ if ("年假".equals(reCommitReqVO.getLeaveType())) {
|
|
|
+ // 获取剩余年假和申请天数
|
|
|
+ BigDecimal remainingAnnualLeave = loginEmployee.getRemainingAnnualLeave();
|
|
|
+ String requestDayStr = reCommitReqVO.getDay(); // 更清晰的变量名
|
|
|
+ BigDecimal requestDays = new BigDecimal(requestDayStr); // 假设getDay返回的是可以解析为double的字符串
|
|
|
+ // 检查剩余年假是否足够
|
|
|
+ if (remainingAnnualLeave.compareTo(requestDays) < 0) {
|
|
|
+ throw exception(ATTENDANCE_EMAINING_ANNUAL_LEAVE_IS_INSUFFICIENT);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
OaLeaveDO oaLeaveNew = BeanUtils.toBean(reCommitReqVO, OaLeaveDO.class);
|
|
|
OaLeaveDO oaLeaveOld = validateOaLeaveExists(oaLeaveNew.getId());
|
|
|
oaLeaveNew.setLeaveId(oaLeaveOld.getLeaveId())
|