|
|
@@ -6,6 +6,7 @@ import cn.hutool.core.util.StrUtil;
|
|
|
import cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil;
|
|
|
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
|
|
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;
|
|
|
import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils;
|
|
|
import cn.iocoder.yudao.module.bpm.api.task.BpmProcessInstanceApi;
|
|
|
@@ -22,12 +23,12 @@ import cn.iocoder.yudao.module.bpm.enums.DictDataConstants;
|
|
|
import cn.iocoder.yudao.module.bpm.enums.ErrorCodeConstants;
|
|
|
import cn.iocoder.yudao.module.bpm.framework.flowable.core.enums.BpmConstants;
|
|
|
import cn.iocoder.yudao.module.bpm.service.task.BpmTaskService;
|
|
|
+import cn.iocoder.yudao.module.employee.api.EmployeeApi;
|
|
|
+import cn.iocoder.yudao.module.employee.api.dto.EmployeeRespDTO;
|
|
|
import cn.iocoder.yudao.module.infra.api.file.FileApi;
|
|
|
import cn.iocoder.yudao.module.infra.api.file.dto.FileDTO;
|
|
|
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.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
@@ -38,7 +39,9 @@ import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.validation.annotation.Validated;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
+import java.time.LocalDate;
|
|
|
import java.time.LocalDateTime;
|
|
|
+import java.time.format.DateTimeFormatter;
|
|
|
import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
@@ -76,20 +79,23 @@ public class OaRenewServiceImpl implements OaRenewService {
|
|
|
private FileApi fileApi;
|
|
|
|
|
|
@Resource
|
|
|
- private AdminUserApi adminUserApi;
|
|
|
+ private EmployeeApi employeeApi;
|
|
|
|
|
|
@Resource
|
|
|
private DeptApi deptApi;
|
|
|
|
|
|
@Override
|
|
|
- @Transactional
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
public Long stagingOaRenew(OaRenewSaveReqVO stagingReqVO) {
|
|
|
// 登录人信息
|
|
|
Long loginUserId = SecurityFrameworkUtils.getLoginUserId();
|
|
|
- AdminUserRespDTO loginUser = adminUserApi.getUser(loginUserId);
|
|
|
- Objects.requireNonNull(loginUser, "登录用户不能为空");
|
|
|
- // 人信息
|
|
|
- AdminUserRespDTO employee = adminUserApi.getUser(stagingReqVO.getEmployeeId());
|
|
|
+ // 登录员工信息
|
|
|
+ EmployeeRespDTO loginEmployee = employeeApi.getEmployeeByUserId(loginUserId);
|
|
|
+ // 续签人信息
|
|
|
+ EmployeeRespDTO employee = employeeApi.getEmployeeById(stagingReqVO.getEmployeeId());
|
|
|
+ if (loginEmployee == null || employee == null) {
|
|
|
+ throw exception(ErrorCodeConstants.OA_EMPLOYEE_NOT_EXISTS);
|
|
|
+ }
|
|
|
|
|
|
OaRenewDO oaRenew = BeanUtils.toBean(stagingReqVO, OaRenewDO.class);
|
|
|
if (StringUtils.isBlank(oaRenew.getRenewId())) {
|
|
|
@@ -97,20 +103,27 @@ public class OaRenewServiceImpl implements OaRenewService {
|
|
|
String uuid = IdUtil.fastSimpleUUID();
|
|
|
oaRenew.setRenewId(uuid);
|
|
|
}
|
|
|
- if (employee != null) {
|
|
|
- oaRenew.setEmployeeId(loginUser.getId());
|
|
|
- oaRenew.setEmployeeName(loginUser.getNickname());
|
|
|
- oaRenew.setEmployeePhone(loginUser.getMobile());
|
|
|
- oaRenew.setDeptId(loginUser.getDeptId());
|
|
|
- oaRenew.setPosition("员工职位");
|
|
|
- oaRenew.setOldContractStartDate("2023-01-01");
|
|
|
- oaRenew.setOldContractEndDate("2023-12-31");
|
|
|
- oaRenew.setUserId(loginUser.getId());
|
|
|
- }
|
|
|
+ oaRenew.setEmployeeId(employee.getId());
|
|
|
+ oaRenew.setEmployeeName(employee.getName());
|
|
|
+ oaRenew.setEmployeePhone(employee.getPhone());
|
|
|
+ oaRenew.setDeptId(employee.getDeptId());
|
|
|
+ oaRenew.setPostId(employee.getPostId());
|
|
|
+ oaRenew.setPosition(employee.getPosition());
|
|
|
+ DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
|
|
+ LocalDate contractStartDate = loginEmployee.getContractStartDate();
|
|
|
+ if (contractStartDate != null) {
|
|
|
+ oaRenew.setOldContractStartDate(formatter.format(contractStartDate));
|
|
|
+ }
|
|
|
+ LocalDate contractEndDate = loginEmployee.getContractEndDate();
|
|
|
+ if (contractEndDate != null) {
|
|
|
+ oaRenew.setOldContractEndDate(formatter.format(contractEndDate));
|
|
|
+ }
|
|
|
+ oaRenew.setUserId(loginUserId);
|
|
|
oaRenew.setAuditStatus(DictDataConstants.OA_AUDIT_STATUS_STAGING);
|
|
|
oaRenew.setInfoSource("0");
|
|
|
- oaRenew.setApplyEmployeeId(loginUser.getId());
|
|
|
- oaRenew.setApplyEmployeeName(loginUser.getNickname());
|
|
|
+ oaRenew.setApplyEmployeeId(loginEmployee.getId());
|
|
|
+ oaRenew.setApplyEmployeeName(loginEmployee.getName());
|
|
|
+ oaRenew.setCreator(String.valueOf(loginEmployee.getId()));
|
|
|
// 暂存不保存审批人信息
|
|
|
oaRenew.setStartUserSelectAssignees(null);
|
|
|
// 保存或更新表单信息
|
|
|
@@ -127,20 +140,21 @@ public class OaRenewServiceImpl implements OaRenewService {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- @Transactional
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
public Long commitOaRenew(OaRenewSaveReqVO commitReqVO) {
|
|
|
if (CollectionUtil.isEmpty(commitReqVO.getStartUserSelectAssignees())) {
|
|
|
throw exception(ErrorCodeConstants.TASK_CREATE_FAIL_NO_START_SELECT_ASSIGNEE);
|
|
|
}
|
|
|
// 登录人信息
|
|
|
Long loginUserId = SecurityFrameworkUtils.getLoginUserId();
|
|
|
- AdminUserRespDTO loginUser = adminUserApi.getUser(loginUserId);
|
|
|
- if (loginUser == null) {
|
|
|
+ if (loginUserId == null) {
|
|
|
throw exception(ErrorCodeConstants.OA_LOGIN_USER_NOT_EXISTS);
|
|
|
}
|
|
|
- // 人信息
|
|
|
- AdminUserRespDTO employee = adminUserApi.getUser(commitReqVO.getEmployeeId());
|
|
|
- if (employee == null) {
|
|
|
+ // 登录员工信息
|
|
|
+ EmployeeRespDTO loginEmployee = employeeApi.getEmployeeByUserId(loginUserId);
|
|
|
+ // 续签人信息
|
|
|
+ EmployeeRespDTO employee = employeeApi.getEmployeeById(commitReqVO.getEmployeeId());
|
|
|
+ if (loginEmployee == null || employee == null) {
|
|
|
throw exception(ErrorCodeConstants.OA_EMPLOYEE_NOT_EXISTS);
|
|
|
}
|
|
|
|
|
|
@@ -152,16 +166,25 @@ public class OaRenewServiceImpl implements OaRenewService {
|
|
|
oaRenew.setRenewId(uuid);
|
|
|
}
|
|
|
oaRenew.setEmployeeId(employee.getId());
|
|
|
- oaRenew.setEmployeeName(employee.getNickname());
|
|
|
- oaRenew.setEmployeePhone(employee.getMobile());
|
|
|
+ oaRenew.setEmployeeName(employee.getName());
|
|
|
+ oaRenew.setEmployeePhone(employee.getPhone());
|
|
|
oaRenew.setDeptId(employee.getDeptId());
|
|
|
- oaRenew.setPosition("员工职位");
|
|
|
- oaRenew.setOldContractStartDate("2023-01-01");
|
|
|
- oaRenew.setOldContractEndDate("2023-12-31");
|
|
|
- oaRenew.setUserId(loginUser.getId());
|
|
|
+ oaRenew.setPostId(employee.getPostId());
|
|
|
+ oaRenew.setPosition(employee.getPosition());
|
|
|
+ DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
|
|
+ LocalDate contractStartDate = loginEmployee.getContractStartDate();
|
|
|
+ if (contractStartDate != null) {
|
|
|
+ oaRenew.setOldContractStartDate(formatter.format(contractStartDate));
|
|
|
+ }
|
|
|
+ LocalDate contractEndDate = loginEmployee.getContractEndDate();
|
|
|
+ if (contractEndDate != null) {
|
|
|
+ oaRenew.setOldContractEndDate(formatter.format(contractEndDate));
|
|
|
+ }
|
|
|
+ oaRenew.setUserId(loginUserId);
|
|
|
oaRenew.setInfoSource("0");
|
|
|
- oaRenew.setApplyEmployeeId(loginUser.getId());
|
|
|
- oaRenew.setApplyEmployeeName(loginUser.getNickname());
|
|
|
+ oaRenew.setApplyEmployeeId(loginEmployee.getId());
|
|
|
+ oaRenew.setApplyEmployeeName(loginEmployee.getName());
|
|
|
+ oaRenew.setCreator(String.valueOf(loginEmployee.getId()));
|
|
|
// 保存或更新表单信息
|
|
|
if (oaRenew.getId() == null) {
|
|
|
oaRenewMapper.insert(oaRenew);
|
|
|
@@ -180,7 +203,7 @@ public class OaRenewServiceImpl implements OaRenewService {
|
|
|
List<Long> selectAssignees = commitReqVO.getStartUserSelectAssignees();
|
|
|
startUserSelectAssignees.put("approver", selectAssignees);
|
|
|
String processInstanceId = processInstanceApi
|
|
|
- .createProcessInstance(loginUser.getId(),
|
|
|
+ .createProcessInstance(loginEmployee.getId(),
|
|
|
new BpmProcessInstanceCreateReqDTO()
|
|
|
.setProcessDefinitionKey(PROCESS_KEY)
|
|
|
.setVariables(processInstanceVariables)
|
|
|
@@ -197,14 +220,14 @@ public class OaRenewServiceImpl implements OaRenewService {
|
|
|
agreeReqVO.setTaskStatus(Integer.valueOf(DictDataConstants.OA_AUDIT_STATUS_COMMITTED));
|
|
|
taskService.setVariable(task.getId(), BpmConstants.PROCESS_INSTANCE_VARIABLE_STATUS, DictDataConstants.OA_AUDIT_STATUS_COMMITTED);
|
|
|
taskService.setVariable(task.getId(), "auditPass", "true");
|
|
|
- bpmTaskService.approveTask(loginUserId, agreeReqVO);
|
|
|
+ bpmTaskService.approveTask(loginEmployee.getId(), agreeReqVO);
|
|
|
|
|
|
Task nextTask = taskService.createTaskQuery().processInstanceId(processInstanceId).singleResult();
|
|
|
if (nextTask == null) {
|
|
|
throw exception(ErrorCodeConstants.TASK_CREATE_FAIL_NO_START_SELECT_ASSIGNEE);
|
|
|
}
|
|
|
Long currentAuditEmployeeId = Long.valueOf(nextTask.getAssignee());
|
|
|
- AdminUserRespDTO currentAuditEmployee = adminUserApi.getUser(currentAuditEmployeeId);
|
|
|
+ EmployeeRespDTO currentAuditEmployee = employeeApi.getEmployeeById(currentAuditEmployeeId);
|
|
|
|
|
|
|
|
|
// 将工作流的流程实例ID、单据状态、最后一次审批时间、当前审批人更新到单据信息中
|
|
|
@@ -214,7 +237,7 @@ public class OaRenewServiceImpl implements OaRenewService {
|
|
|
.setAuditStatus(DictDataConstants.OA_AUDIT_STATUS_COMMITTED)
|
|
|
.setFinalAuditDate(LocalDateTime.now())
|
|
|
.setCurrentAuditEmployeeId(currentAuditEmployeeId)
|
|
|
- .setCurrentAuditEmployeeName(currentAuditEmployee.getNickname())
|
|
|
+ .setCurrentAuditEmployeeName(currentAuditEmployee.getName())
|
|
|
.setStartUserSelectAssignees(selectAssignees.stream().map(String::valueOf).collect(Collectors.joining(","))));
|
|
|
// 保存业务uuid到附件中
|
|
|
saveFileList(commitReqVO.getFileIdList(), oaRenew.getRenewId());
|
|
|
@@ -223,11 +246,15 @@ public class OaRenewServiceImpl implements OaRenewService {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- @Transactional
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
public Long agreeOaRenew(BpmTaskApproveReqVO agreeReqVO) {
|
|
|
// 登录人信息
|
|
|
Long loginUserId = SecurityFrameworkUtils.getLoginUserId();
|
|
|
- // TODO DP 根据登录人查询出对应的员工信息
|
|
|
+ // 根据登录人查询出对应的员工信息
|
|
|
+ EmployeeRespDTO loginEmployee = employeeApi.getEmployeeByUserId(loginUserId);
|
|
|
+ if (loginEmployee == null) {
|
|
|
+ throw exception(ErrorCodeConstants.OA_EMPLOYEE_NOT_EXISTS);
|
|
|
+ }
|
|
|
|
|
|
Task currentTask = bpmTaskService.getTask(agreeReqVO.getId());
|
|
|
if (currentTask == null) {
|
|
|
@@ -255,19 +282,19 @@ public class OaRenewServiceImpl implements OaRenewService {
|
|
|
agreeReqVO.setReason(reason);
|
|
|
agreeReqVO.setTaskStatus(Integer.valueOf(DictDataConstants.OA_AUDIT_STATUS_AUDITING));
|
|
|
taskService.setVariable(agreeReqVO.getId(), "auditPass", "true");
|
|
|
- bpmTaskService.approveTask(loginUserId, agreeReqVO);
|
|
|
+ bpmTaskService.approveTask(loginEmployee.getId(), agreeReqVO);
|
|
|
|
|
|
Task nextTask = taskService.createTaskQuery().processInstanceId(currentTask.getProcessInstanceId()).singleResult();
|
|
|
OaRenewDO oaRenewDO = new OaRenewDO();
|
|
|
if (nextTask != null) {
|
|
|
Long currentAuditEmployeeId = Long.valueOf(nextTask.getAssignee());
|
|
|
- AdminUserRespDTO currentAuditEmployee = adminUserApi.getUser(currentAuditEmployeeId);
|
|
|
+ EmployeeRespDTO currentAuditEmployee = employeeApi.getEmployeeById(currentAuditEmployeeId);
|
|
|
|
|
|
// 如果审批人重复,实际未结束,再次更新为审核中
|
|
|
taskService.setVariable(nextTask.getId(), BpmConstants.PROCESS_INSTANCE_VARIABLE_STATUS, DictDataConstants.OA_AUDIT_STATUS_AUDITING);
|
|
|
oaRenewDO.setAuditStatus(DictDataConstants.OA_AUDIT_STATUS_AUDITING)
|
|
|
.setCurrentAuditEmployeeId(currentAuditEmployeeId)
|
|
|
- .setCurrentAuditEmployeeName(currentAuditEmployee.getNickname())
|
|
|
+ .setCurrentAuditEmployeeName(currentAuditEmployee.getName())
|
|
|
.setFinalAuditDate(LocalDateTime.now())
|
|
|
.setId(oaRenew.getId());
|
|
|
|
|
|
@@ -289,11 +316,15 @@ public class OaRenewServiceImpl implements OaRenewService {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- @Transactional
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
public Long disagreeOaRenew(BpmTaskReturnReqVO disagreeReqVO) {
|
|
|
// 登录人信息
|
|
|
Long loginUserId = SecurityFrameworkUtils.getLoginUserId();
|
|
|
- // TODO DP 根据登录人查询出对应的员工信息
|
|
|
+ // 根据登录人查询出对应的员工信息
|
|
|
+ EmployeeRespDTO loginEmployee = employeeApi.getEmployeeByUserId(loginUserId);
|
|
|
+ if (loginEmployee == null) {
|
|
|
+ throw exception(ErrorCodeConstants.OA_EMPLOYEE_NOT_EXISTS);
|
|
|
+ }
|
|
|
|
|
|
Task currentTask = bpmTaskService.getTask(disagreeReqVO.getId());
|
|
|
|
|
|
@@ -301,17 +332,17 @@ public class OaRenewServiceImpl implements OaRenewService {
|
|
|
disagreeReqVO.setReason("[驳回]" + disagreeReqVO.getReason());
|
|
|
disagreeReqVO.setTaskStatus(Integer.valueOf(DictDataConstants.OA_AUDIT_STATUS_RETURNED));
|
|
|
taskService.setVariable(disagreeReqVO.getId(), "auditPass", "false");
|
|
|
- taskService.setVariable(disagreeReqVO.getId(),BpmConstants.PROCESS_INSTANCE_VARIABLE_STATUS, DictDataConstants.OA_AUDIT_STATUS_RETURNED);
|
|
|
- bpmTaskService.returnTask(loginUserId, disagreeReqVO);
|
|
|
+ taskService.setVariable(disagreeReqVO.getId(), BpmConstants.PROCESS_INSTANCE_VARIABLE_STATUS, DictDataConstants.OA_AUDIT_STATUS_RETURNED);
|
|
|
+ bpmTaskService.returnTask(loginEmployee.getId(), disagreeReqVO);
|
|
|
|
|
|
Task nextTask = taskService.createTaskQuery().processInstanceId(currentTask.getProcessInstanceId()).singleResult();
|
|
|
Long currentAuditEmployeeId = Long.valueOf(nextTask.getAssignee());
|
|
|
- AdminUserRespDTO currentAuditEmployee = adminUserApi.getUser(currentAuditEmployeeId);
|
|
|
+ EmployeeRespDTO currentAuditEmployee = employeeApi.getEmployeeById(currentAuditEmployeeId);
|
|
|
|
|
|
// 更新单据状态,当前处理人,最后处理时间
|
|
|
LambdaUpdateWrapper<OaRenewDO> updateWrapper = new LambdaUpdateWrapper<>();
|
|
|
updateWrapper.set(OaRenewDO::getCurrentAuditEmployeeId, currentAuditEmployeeId)
|
|
|
- .set(OaRenewDO::getCurrentAuditEmployeeName, currentAuditEmployee.getNickname())
|
|
|
+ .set(OaRenewDO::getCurrentAuditEmployeeName, currentAuditEmployee.getName())
|
|
|
.set(OaRenewDO::getFinalAuditDate, LocalDateTime.now())
|
|
|
.set(OaRenewDO::getAuditStatus, DictDataConstants.OA_AUDIT_STATUS_RETURNED)
|
|
|
.eq(OaRenewDO::getProcInstId, currentTask.getProcessInstanceId());
|
|
|
@@ -323,11 +354,15 @@ public class OaRenewServiceImpl implements OaRenewService {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- @Transactional
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
public Long revocationOaRenew(BpmTaskApproveReqVO revocationReqVO) {
|
|
|
// 登录人信息
|
|
|
Long loginUserId = SecurityFrameworkUtils.getLoginUserId();
|
|
|
- // TODO DP 根据登录人查询出对应的员工信息
|
|
|
+ // 根据登录人查询出对应的员工信息
|
|
|
+ EmployeeRespDTO loginEmployee = employeeApi.getEmployeeByUserId(loginUserId);
|
|
|
+ if (loginEmployee == null) {
|
|
|
+ throw exception(ErrorCodeConstants.OA_EMPLOYEE_NOT_EXISTS);
|
|
|
+ }
|
|
|
|
|
|
Task currentTask = bpmTaskService.getTask(revocationReqVO.getId());
|
|
|
if (currentTask == null) {
|
|
|
@@ -337,7 +372,7 @@ public class OaRenewServiceImpl implements OaRenewService {
|
|
|
.eq(OaRenewDO::getProcInstId, currentTask.getProcessInstanceId());
|
|
|
OaRenewDO oaRenewDO = oaRenewMapper.selectOne(lambdaQueryWrapper);
|
|
|
if (!DictDataConstants.OA_AUDIT_STATUS_COMMITTED.equals(oaRenewDO.getAuditStatus())
|
|
|
- || !Objects.equals(String.valueOf(loginUserId), oaRenewDO.getCreator())) {
|
|
|
+ || !Objects.equals(String.valueOf(loginEmployee.getId()), oaRenewDO.getCreator())) {
|
|
|
throw ServiceExceptionUtil.exception(ErrorCodeConstants.TASK_REVOCATION_NOT_ALLOWED);
|
|
|
}
|
|
|
|
|
|
@@ -349,17 +384,17 @@ public class OaRenewServiceImpl implements OaRenewService {
|
|
|
}
|
|
|
returnReqVO.setReason(reason);
|
|
|
returnReqVO.setTaskStatus(Integer.valueOf(DictDataConstants.OA_AUDIT_STATUS_RECALLED));
|
|
|
- taskService.setVariable(currentTask.getId(),BpmConstants.PROCESS_INSTANCE_VARIABLE_STATUS, DictDataConstants.OA_AUDIT_STATUS_RECALLED);
|
|
|
- bpmTaskService.revocationTask(loginUserId, returnReqVO);
|
|
|
+ taskService.setVariable(currentTask.getId(), BpmConstants.PROCESS_INSTANCE_VARIABLE_STATUS, DictDataConstants.OA_AUDIT_STATUS_RECALLED);
|
|
|
+ bpmTaskService.revocationTask(loginEmployee.getId(), returnReqVO);
|
|
|
|
|
|
Task nextTask = taskService.createTaskQuery().processInstanceId(currentTask.getProcessInstanceId()).singleResult();
|
|
|
Long currentAuditEmployeeId = Long.valueOf(nextTask.getAssignee());
|
|
|
- AdminUserRespDTO currentAuditEmployee = adminUserApi.getUser(currentAuditEmployeeId);
|
|
|
+ EmployeeRespDTO currentAuditEmployee = employeeApi.getEmployeeById(currentAuditEmployeeId);
|
|
|
|
|
|
// 更新单据状态,当前处理人,最后处理时间
|
|
|
LambdaUpdateWrapper<OaRenewDO> updateWrapper = new LambdaUpdateWrapper<>();
|
|
|
updateWrapper.set(OaRenewDO::getCurrentAuditEmployeeId, currentAuditEmployeeId)
|
|
|
- .set(OaRenewDO::getCurrentAuditEmployeeName, currentAuditEmployee.getNickname())
|
|
|
+ .set(OaRenewDO::getCurrentAuditEmployeeName, currentAuditEmployee.getName())
|
|
|
.set(OaRenewDO::getFinalAuditDate, LocalDateTime.now())
|
|
|
.set(OaRenewDO::getAuditStatus, DictDataConstants.OA_AUDIT_STATUS_RECALLED)
|
|
|
.eq(OaRenewDO::getProcInstId, currentTask.getProcessInstanceId());
|
|
|
@@ -371,20 +406,18 @@ public class OaRenewServiceImpl implements OaRenewService {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- @Transactional
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
public Long reCommitOaRenew(OaRenewSaveReqVO reCommitReqVO) {
|
|
|
if (reCommitReqVO.getId() == null) {
|
|
|
throw exception(ErrorCodeConstants.SERVICE_ID_NOT_EXISTS);
|
|
|
}
|
|
|
// 登录人信息
|
|
|
Long loginUserId = SecurityFrameworkUtils.getLoginUserId();
|
|
|
- AdminUserRespDTO loginUser = adminUserApi.getUser(loginUserId);
|
|
|
- if (loginUser == null) {
|
|
|
- throw exception(ErrorCodeConstants.OA_LOGIN_USER_NOT_EXISTS);
|
|
|
- }
|
|
|
- // 人信息
|
|
|
- AdminUserRespDTO employee = adminUserApi.getUser(reCommitReqVO.getEmployeeId());
|
|
|
- if (employee == null) {
|
|
|
+ // 登录员工信息
|
|
|
+ EmployeeRespDTO loginEmployee = employeeApi.getEmployeeByUserId(loginUserId);
|
|
|
+ // 续签人信息
|
|
|
+ EmployeeRespDTO employee = employeeApi.getEmployeeById(reCommitReqVO.getEmployeeId());
|
|
|
+ if (loginEmployee == null || employee == null) {
|
|
|
throw exception(ErrorCodeConstants.OA_EMPLOYEE_NOT_EXISTS);
|
|
|
}
|
|
|
|
|
|
@@ -394,15 +427,23 @@ public class OaRenewServiceImpl implements OaRenewService {
|
|
|
.setProcInstId(oaRenewOld.getProcInstId());
|
|
|
|
|
|
oaRenewNew.setEmployeeId(employee.getId());
|
|
|
- oaRenewNew.setEmployeeName(employee.getNickname());
|
|
|
- oaRenewNew.setEmployeePhone(employee.getMobile());
|
|
|
+ oaRenewNew.setEmployeeName(employee.getName());
|
|
|
+ oaRenewNew.setEmployeePhone(employee.getPhone());
|
|
|
oaRenewNew.setDeptId(employee.getDeptId());
|
|
|
- oaRenewNew.setPosition("员工职位");
|
|
|
- oaRenewNew.setOldContractStartDate("2023-01-01");
|
|
|
- oaRenewNew.setOldContractEndDate("2023-12-31");
|
|
|
- oaRenewNew.setUserId(loginUser.getId());
|
|
|
- oaRenewNew.setApplyEmployeeId(loginUser.getId());
|
|
|
- oaRenewNew.setApplyEmployeeName(loginUser.getNickname());
|
|
|
+ oaRenewNew.setPostId(employee.getPostId());
|
|
|
+ oaRenewNew.setPosition(employee.getPosition());
|
|
|
+ DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
|
|
+ LocalDate contractStartDate = loginEmployee.getContractStartDate();
|
|
|
+ if (contractStartDate != null) {
|
|
|
+ oaRenewNew.setOldContractStartDate(formatter.format(contractStartDate));
|
|
|
+ }
|
|
|
+ LocalDate contractEndDate = loginEmployee.getContractEndDate();
|
|
|
+ if (contractEndDate != null) {
|
|
|
+ oaRenewNew.setOldContractEndDate(formatter.format(contractEndDate));
|
|
|
+ }
|
|
|
+ oaRenewNew.setUserId(loginUserId);
|
|
|
+ oaRenewNew.setApplyEmployeeId(loginEmployee.getId());
|
|
|
+ oaRenewNew.setApplyEmployeeName(loginEmployee.getName());
|
|
|
|
|
|
Task currentTask = taskService.createTaskQuery().processInstanceId(oaRenewNew.getProcInstId()).singleResult();
|
|
|
BpmTaskApproveReqVO approveReqVO = new BpmTaskApproveReqVO();
|
|
|
@@ -421,14 +462,14 @@ public class OaRenewServiceImpl implements OaRenewService {
|
|
|
taskService.setVariable(currentTask.getId(), "auditPass", "true");
|
|
|
taskService.setVariable(currentTask.getId(),BpmConstants.PROCESS_INSTANCE_VARIABLE_STATUS, DictDataConstants.OA_AUDIT_STATUS_COMMITTED);
|
|
|
// 再次提交,和审批通过逻辑相同
|
|
|
- bpmTaskService.approveTask(loginUserId, approveReqVO);
|
|
|
+ bpmTaskService.approveTask(loginEmployee.getId(), approveReqVO);
|
|
|
|
|
|
Task nextTask = taskService.createTaskQuery().processInstanceId(currentTask.getProcessInstanceId()).singleResult();
|
|
|
Long currentAuditEmployeeId = Long.valueOf(nextTask.getAssignee());
|
|
|
- AdminUserRespDTO currentAuditEmployee = adminUserApi.getUser(currentAuditEmployeeId);
|
|
|
+ EmployeeRespDTO currentAuditEmployee = employeeApi.getEmployeeById(currentAuditEmployeeId);
|
|
|
oaRenewNew.setAuditStatus(DictDataConstants.OA_AUDIT_STATUS_COMMITTED)
|
|
|
.setCurrentAuditEmployeeId(currentAuditEmployeeId)
|
|
|
- .setCurrentAuditEmployeeName(currentAuditEmployee.getNickname())
|
|
|
+ .setCurrentAuditEmployeeName(currentAuditEmployee.getName())
|
|
|
.setFinalAuditDate(LocalDateTime.now());
|
|
|
oaRenewMapper.updateById(oaRenewNew);
|
|
|
|
|
|
@@ -439,14 +480,18 @@ public class OaRenewServiceImpl implements OaRenewService {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- @Transactional
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
public Long closeOaRenew(Long id) {
|
|
|
if (id == null) {
|
|
|
throw exception(ErrorCodeConstants.SERVICE_ID_NOT_EXISTS);
|
|
|
}
|
|
|
// 登录人信息
|
|
|
Long loginUserId = SecurityFrameworkUtils.getLoginUserId();
|
|
|
- // TODO DP 根据登录人查询出对应的员工信息
|
|
|
+ // 根据登录人查询出对应的员工信息
|
|
|
+ EmployeeRespDTO loginEmployee = employeeApi.getEmployeeByUserId(loginUserId);
|
|
|
+ if (loginEmployee == null) {
|
|
|
+ throw exception(ErrorCodeConstants.OA_EMPLOYEE_NOT_EXISTS);
|
|
|
+ }
|
|
|
|
|
|
OaRenewDO oaRenewDO = validateOaRenewExists(id);
|
|
|
if (!DictDataConstants.OA_AUDIT_STATUS_RETURNED.equals(oaRenewDO.getAuditStatus())
|
|
|
@@ -462,7 +507,7 @@ public class OaRenewServiceImpl implements OaRenewService {
|
|
|
taskService.setVariable(currentTask.getId(), "auditPass", "false");
|
|
|
taskService.setVariable(currentTask.getId(),BpmConstants.PROCESS_INSTANCE_VARIABLE_STATUS, DictDataConstants.OA_AUDIT_STATUS_CLOSED);
|
|
|
// 关闭,使用审批通过的方法实现
|
|
|
- bpmTaskService.approveTask(loginUserId, approveReqVO);
|
|
|
+ bpmTaskService.approveTask(loginEmployee.getId(), approveReqVO);
|
|
|
|
|
|
LambdaUpdateWrapper<OaRenewDO> lambdaUpdateWrapper = new LambdaUpdateWrapper<>();
|
|
|
lambdaUpdateWrapper.set(OaRenewDO::getAuditStatus, DictDataConstants.OA_AUDIT_STATUS_CLOSED)
|
|
|
@@ -486,7 +531,11 @@ public class OaRenewServiceImpl implements OaRenewService {
|
|
|
public OaRenewRespVO getOaRenew(Long id) {
|
|
|
// 登录人信息
|
|
|
Long loginUserId = SecurityFrameworkUtils.getLoginUserId();
|
|
|
- // TODO DP 根据登录人查询出对应的员工信息
|
|
|
+ // 根据登录人查询出对应的员工信息
|
|
|
+ EmployeeRespDTO loginEmployee = employeeApi.getEmployeeByUserId(loginUserId);
|
|
|
+ if (loginEmployee == null) {
|
|
|
+ throw exception(ErrorCodeConstants.OA_EMPLOYEE_NOT_EXISTS);
|
|
|
+ }
|
|
|
|
|
|
OaRenewDO oaRenewDO = validateOaRenewExists(id);
|
|
|
OaRenewRespVO oaRenewRespVO = BeanUtils.toBean(oaRenewDO, OaRenewRespVO.class);
|
|
|
@@ -501,7 +550,7 @@ public class OaRenewServiceImpl implements OaRenewService {
|
|
|
if (StrUtil.isNotBlank(procInstId)) {
|
|
|
Task task = taskService.createTaskQuery()
|
|
|
.processInstanceId(procInstId)
|
|
|
- .taskAssignee(String.valueOf(loginUserId))
|
|
|
+ .taskAssignee(String.valueOf(loginEmployee.getId()))
|
|
|
.singleResult();
|
|
|
if (DictDataConstants.OA_AUDIT_STATUS_COMMITTED.equals(oaRenewDO.getAuditStatus())) {
|
|
|
// 如果是已提交,不限制任务处理人是当前登录人,用于直接撤回
|
|
|
@@ -527,16 +576,15 @@ public class OaRenewServiceImpl implements OaRenewService {
|
|
|
// 审批人
|
|
|
String startUserSelectAssignees = oaRenewDO.getStartUserSelectAssignees();
|
|
|
if (StrUtil.isNotEmpty(startUserSelectAssignees)) {
|
|
|
- List<Long> userIdList = Arrays.stream(startUserSelectAssignees.split(","))
|
|
|
+ List<Long> employeeIdList = Arrays.stream(startUserSelectAssignees.split(","))
|
|
|
.map(Long::valueOf).collect(Collectors.toList());
|
|
|
- List<AdminUserRespDTO> userList = adminUserApi.getUserList(userIdList);
|
|
|
- List<AdminUserRespDTO> auditUserList = new ArrayList<>();
|
|
|
- for (Long userId : userIdList) {
|
|
|
- for (AdminUserRespDTO adminUserRespDTO : userList) {
|
|
|
- if (Objects.equals(userId, adminUserRespDTO.getId())) {
|
|
|
- auditUserList.add(adminUserRespDTO);
|
|
|
- break;
|
|
|
- }
|
|
|
+ List<EmployeeRespDTO> employeeRespDTOList = employeeApi.getEmployeeListByIds(employeeIdList);
|
|
|
+ Map<Long, EmployeeRespDTO> longEmployeeRespDTOMap = CollectionUtils.convertMap(employeeRespDTOList, EmployeeRespDTO::getId);
|
|
|
+ List<EmployeeRespDTO> auditUserList = new ArrayList<>();
|
|
|
+ for (Long employeeId : employeeIdList) {
|
|
|
+ EmployeeRespDTO employeeRespDTO = longEmployeeRespDTOMap.get(employeeId);
|
|
|
+ if (employeeRespDTO != null) {
|
|
|
+ auditUserList.add(employeeRespDTO);
|
|
|
}
|
|
|
}
|
|
|
oaRenewRespVO.setAuditUserList(auditUserList);
|
|
|
@@ -569,16 +617,15 @@ public class OaRenewServiceImpl implements OaRenewService {
|
|
|
// 审批人
|
|
|
String startUserSelectAssignees = oaRenewDO.getStartUserSelectAssignees();
|
|
|
if (StrUtil.isNotEmpty(startUserSelectAssignees)) {
|
|
|
- List<Long> userIdList = Arrays.stream(startUserSelectAssignees.split(","))
|
|
|
+ List<Long> employeeIdList = Arrays.stream(startUserSelectAssignees.split(","))
|
|
|
.map(Long::valueOf).collect(Collectors.toList());
|
|
|
- List<AdminUserRespDTO> userList = adminUserApi.getUserList(userIdList);
|
|
|
- List<AdminUserRespDTO> auditUserList = new ArrayList<>();
|
|
|
- for (Long userId : userIdList) {
|
|
|
- for (AdminUserRespDTO adminUserRespDTO : userList) {
|
|
|
- if (Objects.equals(userId, adminUserRespDTO.getId())) {
|
|
|
- auditUserList.add(adminUserRespDTO);
|
|
|
- break;
|
|
|
- }
|
|
|
+ List<EmployeeRespDTO> employeeRespDTOList = employeeApi.getEmployeeListByIds(employeeIdList);
|
|
|
+ Map<Long, EmployeeRespDTO> longEmployeeRespDTOMap = CollectionUtils.convertMap(employeeRespDTOList, EmployeeRespDTO::getId);
|
|
|
+ List<EmployeeRespDTO> auditUserList = new ArrayList<>();
|
|
|
+ for (Long employeeId : employeeIdList) {
|
|
|
+ EmployeeRespDTO employeeRespDTO = longEmployeeRespDTOMap.get(employeeId);
|
|
|
+ if (employeeRespDTO != null) {
|
|
|
+ auditUserList.add(employeeRespDTO);
|
|
|
}
|
|
|
}
|
|
|
oaRenewRespVO.setAuditUserList(auditUserList);
|
|
|
@@ -595,13 +642,12 @@ public class OaRenewServiceImpl implements OaRenewService {
|
|
|
List<OaRenewRespVO> oaRenewRespVOList = oaRenewRespVOPageResult.getList();
|
|
|
if (CollectionUtil.isNotEmpty(oaRenewRespVOList)) {
|
|
|
List<Long> employeeIdList = oaRenewRespVOList.stream().map(OaRenewRespVO::getCurrentAuditEmployeeId).collect(Collectors.toList());
|
|
|
- List<AdminUserRespDTO> employeeList = adminUserApi.getUserList(employeeIdList);
|
|
|
+ List<EmployeeRespDTO> employeeRespDTOList = employeeApi.getEmployeeListByIds(employeeIdList);
|
|
|
+ Map<Long, EmployeeRespDTO> longEmployeeRespDTOMap = CollectionUtils.convertMap(employeeRespDTOList, EmployeeRespDTO::getId);
|
|
|
for (OaRenewRespVO respVO : oaRenewRespVOList) {
|
|
|
- for (AdminUserRespDTO employee : employeeList) {
|
|
|
- if (employee.getId() != null && employee.getId().equals(respVO.getCurrentAuditEmployeeId())) {
|
|
|
- respVO.setCurrentAuditEmployeeName(employee.getNickname());
|
|
|
- break;
|
|
|
- }
|
|
|
+ EmployeeRespDTO employeeRespDTO = longEmployeeRespDTOMap.get(respVO.getCurrentAuditEmployeeId());
|
|
|
+ if (employeeRespDTO != null) {
|
|
|
+ respVO.setCurrentAuditEmployeeName(employeeRespDTO.getName());
|
|
|
}
|
|
|
}
|
|
|
|