|
|
@@ -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;
|
|
|
@@ -24,12 +25,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;
|
|
|
@@ -82,20 +83,21 @@ public class OaReceiveServiceImpl implements OaReceiveService {
|
|
|
private FileApi fileApi;
|
|
|
|
|
|
@Resource
|
|
|
- private AdminUserApi adminUserApi;
|
|
|
+ private EmployeeApi employeeApi;
|
|
|
|
|
|
@Resource
|
|
|
private DeptApi deptApi;
|
|
|
|
|
|
@Override
|
|
|
- @Transactional
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
public Long stagingOaReceive(OaReceiveSaveReqVO stagingReqVO) {
|
|
|
// 登录人信息
|
|
|
Long loginUserId = SecurityFrameworkUtils.getLoginUserId();
|
|
|
- AdminUserRespDTO loginUser = adminUserApi.getUser(loginUserId);
|
|
|
- Objects.requireNonNull(loginUser, "登录用户不能为空");
|
|
|
- // 人信息
|
|
|
- AdminUserRespDTO employee = adminUserApi.getUser(loginUserId);
|
|
|
+ // 根据登录人查询出对应的员工信息
|
|
|
+ EmployeeRespDTO loginEmployee = employeeApi.getEmployeeByUserId(loginUserId);
|
|
|
+ if (loginEmployee == null) {
|
|
|
+ throw exception(ErrorCodeConstants.OA_EMPLOYEE_NOT_EXISTS);
|
|
|
+ }
|
|
|
|
|
|
OaReceiveDO oaReceive = BeanUtils.toBean(stagingReqVO, OaReceiveDO.class);
|
|
|
if (StringUtils.isBlank(oaReceive.getReceiveUuid())) {
|
|
|
@@ -103,18 +105,18 @@ public class OaReceiveServiceImpl implements OaReceiveService {
|
|
|
String uuid = IdUtil.fastSimpleUUID();
|
|
|
oaReceive.setReceiveUuid(uuid);
|
|
|
}
|
|
|
- if (employee != null) {
|
|
|
- oaReceive.setEmployeeId(loginUser.getId());
|
|
|
- oaReceive.setEmployeeName(loginUser.getNickname());
|
|
|
- oaReceive.setEmployeePhone(loginUser.getMobile());
|
|
|
- oaReceive.setDeptId(loginUser.getDeptId());
|
|
|
- oaReceive.setPosition("员工职位");
|
|
|
- oaReceive.setUserId(loginUser.getId());
|
|
|
- }
|
|
|
+ oaReceive.setEmployeeId(loginEmployee.getId());
|
|
|
+ oaReceive.setEmployeeName(loginEmployee.getName());
|
|
|
+ oaReceive.setEmployeePhone(loginEmployee.getPhone());
|
|
|
+ oaReceive.setDeptId(loginEmployee.getDeptId());
|
|
|
+ oaReceive.setPostId(loginEmployee.getPostId());
|
|
|
+ oaReceive.setPosition(loginEmployee.getPosition());
|
|
|
+ oaReceive.setUserId(loginUserId);
|
|
|
oaReceive.setAuditStatus(DictDataConstants.OA_AUDIT_STATUS_STAGING);
|
|
|
oaReceive.setInfoSource("0");
|
|
|
- oaReceive.setApplyEmployeeId(loginUser.getId());
|
|
|
- oaReceive.setApplyEmployeeName(loginUser.getNickname());
|
|
|
+ oaReceive.setApplyEmployeeId(loginEmployee.getId());
|
|
|
+ oaReceive.setApplyEmployeeName(loginEmployee.getName());
|
|
|
+ oaReceive.setCreator(String.valueOf(loginEmployee.getId()));
|
|
|
// 暂存不保存审批人信息
|
|
|
oaReceive.setStartUserSelectAssignees(null);
|
|
|
|
|
|
@@ -138,20 +140,16 @@ public class OaReceiveServiceImpl implements OaReceiveService {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- @Transactional
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
public Long commitOaReceive(OaReceiveSaveReqVO 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) {
|
|
|
- throw exception(ErrorCodeConstants.OA_LOGIN_USER_NOT_EXISTS);
|
|
|
- }
|
|
|
- // 人信息
|
|
|
- AdminUserRespDTO employee = adminUserApi.getUser(loginUserId);
|
|
|
- if (employee == null) {
|
|
|
+ // 根据登录人查询出对应的员工信息
|
|
|
+ EmployeeRespDTO loginEmployee = employeeApi.getEmployeeByUserId(loginUserId);
|
|
|
+ if (loginEmployee == null) {
|
|
|
throw exception(ErrorCodeConstants.OA_EMPLOYEE_NOT_EXISTS);
|
|
|
}
|
|
|
|
|
|
@@ -162,15 +160,17 @@ public class OaReceiveServiceImpl implements OaReceiveService {
|
|
|
String uuid = IdUtil.fastSimpleUUID();
|
|
|
oaReceive.setReceiveUuid(uuid);
|
|
|
}
|
|
|
- oaReceive.setEmployeeId(employee.getId());
|
|
|
- oaReceive.setEmployeeName(employee.getNickname());
|
|
|
- oaReceive.setEmployeePhone(employee.getMobile());
|
|
|
- oaReceive.setDeptId(employee.getDeptId());
|
|
|
- oaReceive.setPosition("员工职位");
|
|
|
- oaReceive.setUserId(loginUser.getId());
|
|
|
+ oaReceive.setEmployeeId(loginEmployee.getId());
|
|
|
+ oaReceive.setEmployeeName(loginEmployee.getName());
|
|
|
+ oaReceive.setEmployeePhone(loginEmployee.getPhone());
|
|
|
+ oaReceive.setDeptId(loginEmployee.getDeptId());
|
|
|
+ oaReceive.setPostId(loginEmployee.getPostId());
|
|
|
+ oaReceive.setPosition(loginEmployee.getPosition());
|
|
|
+ oaReceive.setUserId(loginUserId);
|
|
|
oaReceive.setInfoSource("0");
|
|
|
- oaReceive.setApplyEmployeeId(loginUser.getId());
|
|
|
- oaReceive.setApplyEmployeeName(loginUser.getNickname());
|
|
|
+ oaReceive.setApplyEmployeeId(loginEmployee.getId());
|
|
|
+ oaReceive.setApplyEmployeeName(loginEmployee.getName());
|
|
|
+ oaReceive.setCreator(String.valueOf(loginEmployee.getId()));
|
|
|
|
|
|
// 子表信息
|
|
|
List<OaReceiveObjDO> oaReceiveObjs = commitReqVO.getOaReceiveObjs();
|
|
|
@@ -206,7 +206,7 @@ public class OaReceiveServiceImpl implements OaReceiveService {
|
|
|
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)
|
|
|
@@ -223,14 +223,14 @@ public class OaReceiveServiceImpl implements OaReceiveService {
|
|
|
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、单据状态、最后一次审批时间、当前审批人更新到单据信息中
|
|
|
@@ -240,7 +240,7 @@ public class OaReceiveServiceImpl implements OaReceiveService {
|
|
|
.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(), oaReceive.getReceiveUuid());
|
|
|
@@ -249,11 +249,15 @@ public class OaReceiveServiceImpl implements OaReceiveService {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- @Transactional
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
public Long agreeOaReceive(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) {
|
|
|
@@ -281,19 +285,19 @@ public class OaReceiveServiceImpl implements OaReceiveService {
|
|
|
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();
|
|
|
OaReceiveDO oaReceiveDO = new OaReceiveDO();
|
|
|
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);
|
|
|
oaReceiveDO.setAuditStatus(DictDataConstants.OA_AUDIT_STATUS_AUDITING)
|
|
|
.setCurrentAuditEmployeeId(currentAuditEmployeeId)
|
|
|
- .setCurrentAuditEmployeeName(currentAuditEmployee.getNickname())
|
|
|
+ .setCurrentAuditEmployeeName(currentAuditEmployee.getName())
|
|
|
.setFinalAuditDate(LocalDateTime.now())
|
|
|
.setId(oaReceive.getId());
|
|
|
|
|
|
@@ -315,11 +319,15 @@ public class OaReceiveServiceImpl implements OaReceiveService {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- @Transactional
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
public Long disagreeOaReceive(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());
|
|
|
|
|
|
@@ -328,16 +336,16 @@ public class OaReceiveServiceImpl implements OaReceiveService {
|
|
|
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);
|
|
|
+ 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<OaReceiveDO> updateWrapper = new LambdaUpdateWrapper<>();
|
|
|
updateWrapper.set(OaReceiveDO::getCurrentAuditEmployeeId, currentAuditEmployeeId)
|
|
|
- .set(OaReceiveDO::getCurrentAuditEmployeeName, currentAuditEmployee.getNickname())
|
|
|
+ .set(OaReceiveDO::getCurrentAuditEmployeeName, currentAuditEmployee.getName())
|
|
|
.set(OaReceiveDO::getFinalAuditDate, LocalDateTime.now())
|
|
|
.set(OaReceiveDO::getAuditStatus, DictDataConstants.OA_AUDIT_STATUS_RETURNED)
|
|
|
.eq(OaReceiveDO::getProcInstId, currentTask.getProcessInstanceId());
|
|
|
@@ -349,11 +357,15 @@ public class OaReceiveServiceImpl implements OaReceiveService {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- @Transactional
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
public Long revocationOaReceive(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) {
|
|
|
@@ -363,7 +375,7 @@ public class OaReceiveServiceImpl implements OaReceiveService {
|
|
|
.eq(OaReceiveDO::getProcInstId, currentTask.getProcessInstanceId());
|
|
|
OaReceiveDO oaReceiveDO = oaReceiveMapper.selectOne(lambdaQueryWrapper);
|
|
|
if (!DictDataConstants.OA_AUDIT_STATUS_COMMITTED.equals(oaReceiveDO.getAuditStatus())
|
|
|
- || !Objects.equals(String.valueOf(loginUserId), oaReceiveDO.getCreator())) {
|
|
|
+ || !Objects.equals(String.valueOf(loginEmployee.getId()), oaReceiveDO.getCreator())) {
|
|
|
throw ServiceExceptionUtil.exception(ErrorCodeConstants.TASK_REVOCATION_NOT_ALLOWED);
|
|
|
}
|
|
|
|
|
|
@@ -376,16 +388,16 @@ public class OaReceiveServiceImpl implements OaReceiveService {
|
|
|
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);
|
|
|
+ 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<OaReceiveDO> updateWrapper = new LambdaUpdateWrapper<>();
|
|
|
updateWrapper.set(OaReceiveDO::getCurrentAuditEmployeeId, currentAuditEmployeeId)
|
|
|
- .set(OaReceiveDO::getCurrentAuditEmployeeName, currentAuditEmployee.getNickname())
|
|
|
+ .set(OaReceiveDO::getCurrentAuditEmployeeName, currentAuditEmployee.getName())
|
|
|
.set(OaReceiveDO::getFinalAuditDate, LocalDateTime.now())
|
|
|
.set(OaReceiveDO::getAuditStatus, DictDataConstants.OA_AUDIT_STATUS_RECALLED)
|
|
|
.eq(OaReceiveDO::getProcInstId, currentTask.getProcessInstanceId());
|
|
|
@@ -397,20 +409,16 @@ public class OaReceiveServiceImpl implements OaReceiveService {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- @Transactional
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
public Long reCommitOaReceive(OaReceiveSaveReqVO 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(loginUserId);
|
|
|
- if (employee == null) {
|
|
|
+ // 根据登录人查询出对应的员工信息
|
|
|
+ EmployeeRespDTO loginEmployee = employeeApi.getEmployeeByUserId(loginUserId);
|
|
|
+ if (loginEmployee == null) {
|
|
|
throw exception(ErrorCodeConstants.OA_EMPLOYEE_NOT_EXISTS);
|
|
|
}
|
|
|
|
|
|
@@ -419,14 +427,15 @@ public class OaReceiveServiceImpl implements OaReceiveService {
|
|
|
oaReceiveNew.setReceiveUuid(oaReceiveOld.getReceiveUuid())
|
|
|
.setProcInstId(oaReceiveOld.getProcInstId());
|
|
|
|
|
|
- oaReceiveNew.setEmployeeId(employee.getId());
|
|
|
- oaReceiveNew.setEmployeeName(employee.getNickname());
|
|
|
- oaReceiveNew.setEmployeePhone(employee.getMobile());
|
|
|
- oaReceiveNew.setDeptId(employee.getDeptId());
|
|
|
- oaReceiveNew.setPosition("员工职位");
|
|
|
- oaReceiveNew.setUserId(loginUser.getId());
|
|
|
- oaReceiveNew.setApplyEmployeeId(loginUser.getId());
|
|
|
- oaReceiveNew.setApplyEmployeeName(loginUser.getNickname());
|
|
|
+ oaReceiveNew.setEmployeeId(loginEmployee.getId());
|
|
|
+ oaReceiveNew.setEmployeeName(loginEmployee.getName());
|
|
|
+ oaReceiveNew.setEmployeePhone(loginEmployee.getPhone());
|
|
|
+ oaReceiveNew.setDeptId(loginEmployee.getDeptId());
|
|
|
+ oaReceiveNew.setPostId(loginEmployee.getPostId());
|
|
|
+ oaReceiveNew.setPosition(loginEmployee.getPosition());
|
|
|
+ oaReceiveNew.setUserId(loginUserId);
|
|
|
+ oaReceiveNew.setApplyEmployeeId(loginEmployee.getId());
|
|
|
+ oaReceiveNew.setApplyEmployeeName(loginEmployee.getName());
|
|
|
|
|
|
// 子表信息
|
|
|
List<OaReceiveObjDO> oaReceiveObjs = reCommitReqVO.getOaReceiveObjs();
|
|
|
@@ -456,14 +465,14 @@ public class OaReceiveServiceImpl implements OaReceiveService {
|
|
|
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);
|
|
|
oaReceiveNew.setAuditStatus(DictDataConstants.OA_AUDIT_STATUS_COMMITTED)
|
|
|
.setCurrentAuditEmployeeId(currentAuditEmployeeId)
|
|
|
- .setCurrentAuditEmployeeName(currentAuditEmployee.getNickname())
|
|
|
+ .setCurrentAuditEmployeeName(currentAuditEmployee.getName())
|
|
|
.setFinalAuditDate(LocalDateTime.now());
|
|
|
oaReceiveMapper.updateById(oaReceiveNew);
|
|
|
|
|
|
@@ -479,14 +488,18 @@ public class OaReceiveServiceImpl implements OaReceiveService {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- @Transactional
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
public Long closeOaReceive(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);
|
|
|
+ }
|
|
|
|
|
|
OaReceiveDO oaReceiveDO = oaReceiveMapper.selectById(id);
|
|
|
if (!DictDataConstants.OA_AUDIT_STATUS_RETURNED.equals(oaReceiveDO.getAuditStatus())
|
|
|
@@ -502,7 +515,7 @@ public class OaReceiveServiceImpl implements OaReceiveService {
|
|
|
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<OaReceiveDO> lambdaUpdateWrapper = new LambdaUpdateWrapper<>();
|
|
|
lambdaUpdateWrapper.set(OaReceiveDO::getAuditStatus, DictDataConstants.OA_AUDIT_STATUS_CLOSED)
|
|
|
@@ -515,7 +528,7 @@ public class OaReceiveServiceImpl implements OaReceiveService {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- @Transactional
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
public void deleteOaReceive(Long id) {
|
|
|
// 校验存在
|
|
|
validateOaReceiveDelete(id);
|
|
|
@@ -529,7 +542,11 @@ public class OaReceiveServiceImpl implements OaReceiveService {
|
|
|
public OaReceiveRespVO getOaReceive(Long id) {
|
|
|
// 登录人信息
|
|
|
Long loginUserId = SecurityFrameworkUtils.getLoginUserId();
|
|
|
- // TODO DP 根据登录人查询出对应的员工信息
|
|
|
+ // 根据登录人查询出对应的员工信息
|
|
|
+ EmployeeRespDTO loginEmployee = employeeApi.getEmployeeByUserId(loginUserId);
|
|
|
+ if (loginEmployee == null) {
|
|
|
+ throw exception(ErrorCodeConstants.OA_EMPLOYEE_NOT_EXISTS);
|
|
|
+ }
|
|
|
|
|
|
OaReceiveDO oaReceiveDO = validateOaReceiveExists(id);
|
|
|
OaReceiveRespVO oaReceiveRespVO = BeanUtils.toBean(oaReceiveDO, OaReceiveRespVO.class);
|
|
|
@@ -547,7 +564,7 @@ public class OaReceiveServiceImpl implements OaReceiveService {
|
|
|
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(oaReceiveDO.getAuditStatus())) {
|
|
|
// 如果是已提交,不限制任务处理人是当前登录人,用于直接撤回
|
|
|
@@ -573,16 +590,15 @@ public class OaReceiveServiceImpl implements OaReceiveService {
|
|
|
// 审批人
|
|
|
String startUserSelectAssignees = oaReceiveDO.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);
|
|
|
}
|
|
|
}
|
|
|
oaReceiveRespVO.setAuditUserList(auditUserList);
|
|
|
@@ -615,16 +631,15 @@ public class OaReceiveServiceImpl implements OaReceiveService {
|
|
|
// 审批人
|
|
|
String startUserSelectAssignees = oaReceiveDO.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);
|
|
|
}
|
|
|
}
|
|
|
oaReceiveRespVO.setAuditUserList(auditUserList);
|
|
|
@@ -641,13 +656,12 @@ public class OaReceiveServiceImpl implements OaReceiveService {
|
|
|
List<OaReceiveRespVO> oaReceiveRespVOList = oaReceiveRespVOPageResult.getList();
|
|
|
if (CollectionUtil.isNotEmpty(oaReceiveRespVOList)) {
|
|
|
List<Long> employeeIdList = oaReceiveRespVOList.stream().map(OaReceiveRespVO::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 (OaReceiveRespVO respVO : oaReceiveRespVOList) {
|
|
|
- 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());
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -702,7 +716,7 @@ public class OaReceiveServiceImpl implements OaReceiveService {
|
|
|
// private OaReceiveObjMapper oaReceiveObjMapper;
|
|
|
//
|
|
|
// @Override
|
|
|
- // @Transactional(rollbackFor = Exception.class)
|
|
|
+ // @Transactional(rollbackFor = Exception.class)(rollbackFor = Exception.class)
|
|
|
// public Long createOaReceive(OaReceiveSaveReqVO createReqVO) {
|
|
|
// // 插入
|
|
|
// OaReceiveDO oaReceive = BeanUtils.toBean(createReqVO, OaReceiveDO.class);
|
|
|
@@ -715,7 +729,7 @@ public class OaReceiveServiceImpl implements OaReceiveService {
|
|
|
// }
|
|
|
//
|
|
|
// @Override
|
|
|
- // @Transactional(rollbackFor = Exception.class)
|
|
|
+ // @Transactional(rollbackFor = Exception.class)(rollbackFor = Exception.class)
|
|
|
// public void updateOaReceive(OaReceiveSaveReqVO updateReqVO) {
|
|
|
// // 校验存在
|
|
|
// validateOaReceiveExists(updateReqVO.getId());
|
|
|
@@ -728,7 +742,7 @@ public class OaReceiveServiceImpl implements OaReceiveService {
|
|
|
// }
|
|
|
//
|
|
|
// @Override
|
|
|
- // @Transactional(rollbackFor = Exception.class)
|
|
|
+ // @Transactional(rollbackFor = Exception.class)(rollbackFor = Exception.class)
|
|
|
// public void deleteOaReceive(Long id) {
|
|
|
// // 校验存在
|
|
|
// validateOaReceiveExists(id);
|