|
|
@@ -2,33 +2,45 @@ package cn.iocoder.yudao.module.bpm.service.oa.entry;
|
|
|
|
|
|
import cn.hutool.core.collection.CollectionUtil;
|
|
|
import cn.hutool.core.util.IdUtil;
|
|
|
+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.object.BeanUtils;
|
|
|
+import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils;
|
|
|
import cn.iocoder.yudao.module.bpm.api.task.BpmProcessInstanceApi;
|
|
|
import cn.iocoder.yudao.module.bpm.api.task.dto.BpmProcessInstanceCreateReqDTO;
|
|
|
import cn.iocoder.yudao.module.bpm.controller.admin.oa.entry.vo.OaEntryPageReqVO;
|
|
|
+import cn.iocoder.yudao.module.bpm.controller.admin.oa.entry.vo.OaEntryRespVO;
|
|
|
import cn.iocoder.yudao.module.bpm.controller.admin.oa.entry.vo.OaEntrySaveReqVO;
|
|
|
import cn.iocoder.yudao.module.bpm.controller.admin.task.vo.task.BpmTaskApproveReqVO;
|
|
|
+import cn.iocoder.yudao.module.bpm.controller.admin.task.vo.task.BpmTaskRespVO;
|
|
|
import cn.iocoder.yudao.module.bpm.controller.admin.task.vo.task.BpmTaskReturnReqVO;
|
|
|
import cn.iocoder.yudao.module.bpm.dal.dataobject.oa.entry.OaEntryDO;
|
|
|
import cn.iocoder.yudao.module.bpm.dal.mysql.oa.entry.OaEntryMapper;
|
|
|
+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.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 com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
-import org.flowable.engine.RuntimeService;
|
|
|
import org.flowable.engine.TaskService;
|
|
|
import org.flowable.task.api.Task;
|
|
|
-import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.validation.annotation.Validated;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
-import java.util.Date;
|
|
|
-import java.util.HashMap;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
+import java.time.LocalDateTime;
|
|
|
+import java.util.*;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
|
|
import static cn.iocoder.yudao.module.bpm.enums.ErrorCodeConstants.OA_ENTRY_NOT_EXISTS;
|
|
|
@@ -40,12 +52,12 @@ import static cn.iocoder.yudao.module.bpm.enums.ErrorCodeConstants.OA_ENTRY_NOT_
|
|
|
*/
|
|
|
@Service
|
|
|
@Validated
|
|
|
-public class OaEntryServiceImpl extends ServiceImpl<OaEntryMapper, OaEntryDO> implements OaEntryService {
|
|
|
+public class OaEntryServiceImpl implements OaEntryService {
|
|
|
|
|
|
/**
|
|
|
* OA 入职对应的流程定义 KEY
|
|
|
*/
|
|
|
- public static final String PROCESS_KEY = "oa_entry_workflow";
|
|
|
+ public static final String PROCESS_KEY = "oa_entry";
|
|
|
|
|
|
@Resource
|
|
|
private OaEntryMapper oaEntryMapper;
|
|
|
@@ -59,189 +71,504 @@ public class OaEntryServiceImpl extends ServiceImpl<OaEntryMapper, OaEntryDO> im
|
|
|
@Resource
|
|
|
private TaskService taskService;
|
|
|
|
|
|
- @Autowired
|
|
|
- private RuntimeService runtimeService;
|
|
|
+ @Resource
|
|
|
+ private FileApi fileApi;
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private AdminUserApi adminUserApi;
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private DeptApi deptApi;
|
|
|
|
|
|
@Override
|
|
|
@Transactional
|
|
|
- public Integer startOaEntry(Long userId, OaEntrySaveReqVO createReqVO) {
|
|
|
- //判断是否已经发起流程
|
|
|
- Boolean auditPass = createReqVO.getAuditPass();
|
|
|
- // 创建单据uuid
|
|
|
- String uuid = IdUtil.fastSimpleUUID();
|
|
|
- OaEntryDO oaEntry = BeanUtils.toBean(createReqVO, OaEntryDO.class);
|
|
|
+ public Long stagingOaEntry(OaEntrySaveReqVO stagingReqVO) {
|
|
|
+ // 登录人信息
|
|
|
+ Long loginUserId = SecurityFrameworkUtils.getLoginUserId();
|
|
|
+ AdminUserRespDTO loginUser = adminUserApi.getUser(loginUserId);
|
|
|
+ Objects.requireNonNull(loginUser, "登录用户不能为空");
|
|
|
+ // TODO DP 根据登录人查询出对应的员工信息
|
|
|
+
|
|
|
+ OaEntryDO oaEntry = BeanUtils.toBean(stagingReqVO, OaEntryDO.class);
|
|
|
if (StringUtils.isBlank(oaEntry.getEntryId())) {
|
|
|
+ // 创建单据uuid
|
|
|
+ String uuid = IdUtil.fastSimpleUUID();
|
|
|
oaEntry.setEntryId(uuid);
|
|
|
}
|
|
|
+ oaEntry.setAuditStatus(DictDataConstants.OA_AUDIT_STATUS_STAGING);
|
|
|
+ oaEntry.setInfoSource("0");
|
|
|
+ // 暂存不保存审批人信息
|
|
|
+ oaEntry.setStartUserSelectAssignees(null);
|
|
|
// 保存或更新表单信息
|
|
|
- this.saveOrUpdate(oaEntry);
|
|
|
-
|
|
|
- // 提交
|
|
|
- if (auditPass) {
|
|
|
- // 发起 BPM 流程
|
|
|
- Map<String, Object> processInstanceVariables = new HashMap<>();
|
|
|
- processInstanceVariables.put("auditPass", auditPass);
|
|
|
- //添加审批人信息
|
|
|
- Map<String, List<Long>> startUserSelectAssignees = new HashMap<>();
|
|
|
- startUserSelectAssignees.put("approver", createReqVO.getStartUserSelectAssignees());
|
|
|
- String processInstanceId = processInstanceApi
|
|
|
- .createProcessInstance(userId,
|
|
|
- new BpmProcessInstanceCreateReqDTO()
|
|
|
- .setProcessDefinitionKey(PROCESS_KEY)
|
|
|
- .setVariables(processInstanceVariables)
|
|
|
- .setBusinessKey(String.valueOf(oaEntry.getId()))
|
|
|
- .setStartUserSelectAssignees(startUserSelectAssignees));
|
|
|
-
|
|
|
- //获取下一个审批人
|
|
|
- Task task = taskService.createTaskQuery().processInstanceId(processInstanceId).singleResult();
|
|
|
+ if (oaEntry.getId() == null) {
|
|
|
+ oaEntryMapper.insert(oaEntry);
|
|
|
+ } else {
|
|
|
+ oaEntryMapper.updateById(oaEntry);
|
|
|
+ }
|
|
|
+ // 保存业务uuid到附件中
|
|
|
+ saveFileList(stagingReqVO.getFileIdList(), oaEntry.getEntryId());
|
|
|
|
|
|
- // 将工作流的编号,单据状态 最后一次审批时间 当前审批人 更新到 OA 入职中
|
|
|
- oaEntryMapper.updateById(new OaEntryDO()
|
|
|
- .setId(oaEntry.getId())
|
|
|
- .setProcInstId(processInstanceId)
|
|
|
- .setAuditStatus("1")
|
|
|
- .setEntryId(uuid)
|
|
|
- .setFinalAuditDate(new Date())
|
|
|
- .setCurrentAuditEmployeeId(task.getAssignee()));
|
|
|
+ return oaEntry.getId();
|
|
|
+ }
|
|
|
|
|
|
- // TODO 发送通知
|
|
|
+ @Override
|
|
|
+ @Transactional
|
|
|
+ public Long commitOaEntry(OaEntrySaveReqVO 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);
|
|
|
+ Objects.requireNonNull(loginUser, "登录用户不能为空");
|
|
|
+ // TODO DP 根据登录人查询出对应的员工信息
|
|
|
|
|
|
- }else {
|
|
|
- // 暂存,不发起流程
|
|
|
- // 将单据状态 更新到 OA入职中
|
|
|
- oaEntryMapper.updateById(new OaEntryDO()
|
|
|
- .setId(oaEntry.getId())
|
|
|
- .setAuditStatus("0"));
|
|
|
+ OaEntryDO oaEntry = BeanUtils.toBean(commitReqVO, OaEntryDO.class);
|
|
|
+ if (StringUtils.isBlank(oaEntry.getEntryId())) {
|
|
|
+ // 创建单据uuid
|
|
|
+ String uuid = IdUtil.fastSimpleUUID();
|
|
|
+ oaEntry.setEntryId(uuid);
|
|
|
}
|
|
|
+ oaEntry.setInfoSource("0");
|
|
|
+ // 保存或更新表单信息
|
|
|
+ if (oaEntry.getId() == null) {
|
|
|
+ oaEntryMapper.insert(oaEntry);
|
|
|
+ } else {
|
|
|
+ OaEntryDO oaEntryDO = oaEntryMapper.selectById(oaEntry.getId());
|
|
|
+ if (StrUtil.isNotBlank(oaEntryDO.getProcInstId())) {
|
|
|
+ throw exception(ErrorCodeConstants.PROCESS_INSTANCE_CREATE_FAIL_HAS_PROCESS);
|
|
|
+ }
|
|
|
+ oaEntryMapper.updateById(oaEntry);
|
|
|
+ }
|
|
|
+ // 发起流程
|
|
|
+ Map<String, Object> processInstanceVariables = new HashMap<>();
|
|
|
+ processInstanceVariables.put("auditPass", "true");
|
|
|
+ // 添加审批人信息
|
|
|
+ Map<String, List<Long>> startUserSelectAssignees = new HashMap<>();
|
|
|
+ List<Long> selectAssignees = commitReqVO.getStartUserSelectAssignees();
|
|
|
+ startUserSelectAssignees.put("approver", selectAssignees);
|
|
|
+ String processInstanceId = processInstanceApi
|
|
|
+ .createProcessInstance(loginUser.getId(),
|
|
|
+ new BpmProcessInstanceCreateReqDTO()
|
|
|
+ .setProcessDefinitionKey(PROCESS_KEY)
|
|
|
+ .setVariables(processInstanceVariables)
|
|
|
+ .setBusinessKey(String.valueOf(oaEntry.getId()))
|
|
|
+ .setStartUserSelectAssignees(startUserSelectAssignees));
|
|
|
+
|
|
|
+ //获取下一个审批人
|
|
|
+ Task task = taskService.createTaskQuery().processInstanceId(processInstanceId).singleResult();
|
|
|
|
|
|
- // TODO 保存或更新附件uuid
|
|
|
- if (CollectionUtil.isNotEmpty(createReqVO.getFileIdList())) {
|
|
|
+ // 审批同意
|
|
|
+ BpmTaskApproveReqVO agreeReqVO = new BpmTaskApproveReqVO();
|
|
|
+ agreeReqVO.setId(task.getId());
|
|
|
+ agreeReqVO.setReason("[首次提交]");
|
|
|
+ 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);
|
|
|
+
|
|
|
+ Task nextTask = taskService.createTaskQuery().processInstanceId(processInstanceId).singleResult();
|
|
|
+ if (nextTask == null) {
|
|
|
+ throw exception(ErrorCodeConstants.TASK_CREATE_FAIL_NO_START_SELECT_ASSIGNEE);
|
|
|
}
|
|
|
|
|
|
- // 返回
|
|
|
+ // 将工作流的流程实例ID、单据状态、最后一次审批时间、当前审批人更新到单据信息中
|
|
|
+ oaEntryMapper.updateById(new OaEntryDO()
|
|
|
+ .setId(oaEntry.getId())
|
|
|
+ .setProcInstId(processInstanceId)
|
|
|
+ .setAuditStatus(DictDataConstants.OA_AUDIT_STATUS_COMMITTED)
|
|
|
+ .setFinalAuditDate(LocalDateTime.now())
|
|
|
+ .setCurrentAuditEmployeeId(Long.valueOf(nextTask.getAssignee()))
|
|
|
+ .setStartUserSelectAssignees(selectAssignees.stream().map(String::valueOf).collect(Collectors.joining(","))));
|
|
|
+ // 保存业务uuid到附件中
|
|
|
+ saveFileList(commitReqVO.getFileIdList(), oaEntry.getEntryId());
|
|
|
+ // TODO DP 发送提交成功站内信
|
|
|
return oaEntry.getId();
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public Integer completeTrueOaEntry(Long userId, BpmTaskApproveReqVO reqVO) {
|
|
|
- Task currentTask = bpmTaskService.getTask(reqVO.getId());
|
|
|
+ @Transactional
|
|
|
+ public Long agreeOaEntry(BpmTaskApproveReqVO agreeReqVO) {
|
|
|
+ // 登录人信息
|
|
|
+ Long loginUserId = SecurityFrameworkUtils.getLoginUserId();
|
|
|
+ // TODO DP 根据登录人查询出对应的员工信息
|
|
|
+
|
|
|
+ Task currentTask = bpmTaskService.getTask(agreeReqVO.getId());
|
|
|
+ if (currentTask == null) {
|
|
|
+ throw exception(ErrorCodeConstants.TASK_NOT_EXISTS);
|
|
|
+ }
|
|
|
+ // 先更新为审批中
|
|
|
+ taskService.setVariable(currentTask.getId(), BpmConstants.PROCESS_INSTANCE_VARIABLE_STATUS, DictDataConstants.OA_AUDIT_STATUS_AUDITING);
|
|
|
+ LambdaQueryWrapper<OaEntryDO> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ lambdaQueryWrapper.eq(OaEntryDO::getProcInstId, currentTask.getProcessInstanceId());
|
|
|
+ OaEntryDO oaEntry = oaEntryMapper.selectOne(lambdaQueryWrapper);
|
|
|
+ // 如果是最后一个人审批同意,设置流程审批状态为已审核
|
|
|
+ String[] auditPersons = oaEntry.getStartUserSelectAssignees().split(",");
|
|
|
+ String lastAuditPerson = Arrays.stream(auditPersons)
|
|
|
+ .reduce((first, second) -> second)
|
|
|
+ .orElse(null);
|
|
|
+ if (currentTask.getAssignee().equals(lastAuditPerson)) {
|
|
|
+ // 更新为已审核(暂时未生效,未找到原因,先不处理)
|
|
|
+ taskService.setVariable(agreeReqVO.getId(),BpmConstants.PROCESS_INSTANCE_VARIABLE_STATUS, DictDataConstants.OA_AUDIT_STATUS_AUDITED);
|
|
|
+ }
|
|
|
// 审批同意
|
|
|
- bpmTaskService.approveTask(userId, reqVO);
|
|
|
+ String reason = "[同意]";
|
|
|
+ if (StrUtil.isNotBlank(agreeReqVO.getReason())) {
|
|
|
+ reason = reason + agreeReqVO.getReason();
|
|
|
+ }
|
|
|
+ agreeReqVO.setReason(reason);
|
|
|
+ agreeReqVO.setTaskStatus(Integer.valueOf(DictDataConstants.OA_AUDIT_STATUS_AUDITING));
|
|
|
+ taskService.setVariable(agreeReqVO.getId(), "auditPass", "true");
|
|
|
+ bpmTaskService.approveTask(loginUserId, agreeReqVO);
|
|
|
|
|
|
Task nextTask = taskService.createTaskQuery().processInstanceId(currentTask.getProcessInstanceId()).singleResult();
|
|
|
+ OaEntryDO oaEntryDO = new OaEntryDO();
|
|
|
if (nextTask != null) {
|
|
|
- LambdaUpdateWrapper<OaEntryDO> updateWrapper = new LambdaUpdateWrapper<>();
|
|
|
- updateWrapper.set(OaEntryDO::getAuditStatus, "2")
|
|
|
- .set(OaEntryDO::getCurrentAuditEmployeeId, nextTask.getAssignee())
|
|
|
- .set(OaEntryDO::getFinalAuditDate, new Date())
|
|
|
- .eq(OaEntryDO::getProcInstId, currentTask.getProcessInstanceId());
|
|
|
- oaEntryMapper.update(updateWrapper);
|
|
|
+ // 如果审批人重复,实际未结束,再次更新为审核中
|
|
|
+ taskService.setVariable(nextTask.getId(), BpmConstants.PROCESS_INSTANCE_VARIABLE_STATUS, DictDataConstants.OA_AUDIT_STATUS_AUDITING);
|
|
|
+ oaEntryDO.setAuditStatus(DictDataConstants.OA_AUDIT_STATUS_AUDITING)
|
|
|
+ .setCurrentAuditEmployeeId(Long.valueOf(nextTask.getAssignee()))
|
|
|
+ .setFinalAuditDate(LocalDateTime.now())
|
|
|
+ .setId(oaEntry.getId());
|
|
|
+
|
|
|
} else {
|
|
|
- LambdaUpdateWrapper<OaEntryDO> updateWrapper = new LambdaUpdateWrapper<>();
|
|
|
- updateWrapper.set(OaEntryDO::getAuditStatus, "3")
|
|
|
- .set(OaEntryDO::getCurrentAuditEmployeeId, null)
|
|
|
- .set(OaEntryDO::getFinalAuditDate, new Date())
|
|
|
- .eq(OaEntryDO::getProcInstId, currentTask.getProcessInstanceId());
|
|
|
- oaEntryMapper.update(updateWrapper);
|
|
|
+ oaEntryDO.setAuditStatus(DictDataConstants.OA_AUDIT_STATUS_AUDITED)
|
|
|
+ .setCurrentAuditEmployeeId(null)
|
|
|
+ .setFinalAuditDate(LocalDateTime.now())
|
|
|
+ .setId(oaEntry.getId());
|
|
|
|
|
|
// TODO 复制业务单据信息到业务模块单据表
|
|
|
|
|
|
}
|
|
|
+ oaEntryMapper.updateById(oaEntryDO);
|
|
|
// 发送通知
|
|
|
|
|
|
// 返回
|
|
|
- return 1;
|
|
|
+ return 1L;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public Integer completeFalseOaEntry(Long userId, BpmTaskApproveReqVO reqVO) {
|
|
|
+ @Transactional
|
|
|
+ public Long disagreeOaEntry(BpmTaskReturnReqVO disagreeReqVO) {
|
|
|
+ // 登录人信息
|
|
|
+ Long loginUserId = SecurityFrameworkUtils.getLoginUserId();
|
|
|
+ // TODO DP 根据登录人查询出对应的员工信息
|
|
|
|
|
|
- Task currentTask = bpmTaskService.getTask(reqVO.getId());
|
|
|
+ Task currentTask = bpmTaskService.getTask(disagreeReqVO.getId());
|
|
|
|
|
|
- BpmTaskReturnReqVO reqVO2 = BeanUtils.toBean(reqVO, BpmTaskReturnReqVO.class);
|
|
|
- reqVO2.setTargetTaskDefinitionKey("modifyApply");
|
|
|
- bpmTaskService.returnTask(userId, reqVO2);
|
|
|
+ disagreeReqVO.setTargetTaskDefinitionKey("modifyApply");
|
|
|
+ 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);
|
|
|
|
|
|
Task nextTask = taskService.createTaskQuery().processInstanceId(currentTask.getProcessInstanceId()).singleResult();
|
|
|
|
|
|
// 更新单据状态,当前处理人,最后处理时间
|
|
|
LambdaUpdateWrapper<OaEntryDO> updateWrapper = new LambdaUpdateWrapper<>();
|
|
|
updateWrapper.set(OaEntryDO::getCurrentAuditEmployeeId, nextTask.getAssignee())
|
|
|
- .set(OaEntryDO::getFinalAuditDate, new Date())
|
|
|
- .set(OaEntryDO::getAuditStatus, "0")
|
|
|
+ .set(OaEntryDO::getFinalAuditDate, LocalDateTime.now())
|
|
|
+ .set(OaEntryDO::getAuditStatus, DictDataConstants.OA_AUDIT_STATUS_RETURNED)
|
|
|
.eq(OaEntryDO::getProcInstId, currentTask.getProcessInstanceId());
|
|
|
oaEntryMapper.update(updateWrapper);
|
|
|
|
|
|
// 发送通知
|
|
|
|
|
|
- // 返回
|
|
|
- return 1;
|
|
|
+ return 1L;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public Integer updateCompleteOaEntry(Long userId, OaEntrySaveReqVO createReqVO, BpmTaskApproveReqVO reqVO) {
|
|
|
- // 判断是否已经发起流程
|
|
|
- Boolean auditPass = createReqVO.getAuditPass();
|
|
|
+ @Transactional
|
|
|
+ public Long revocationOaEntry(BpmTaskApproveReqVO revocationReqVO) {
|
|
|
+ // 登录人信息
|
|
|
+ Long loginUserId = SecurityFrameworkUtils.getLoginUserId();
|
|
|
+ // TODO DP 根据登录人查询出对应的员工信息
|
|
|
+
|
|
|
+ Task currentTask = bpmTaskService.getTask(revocationReqVO.getId());
|
|
|
+ if (currentTask == null) {
|
|
|
+ throw ServiceExceptionUtil.exception(ErrorCodeConstants.TASK_NOT_EXISTS);
|
|
|
+ }
|
|
|
+ LambdaQueryWrapper<OaEntryDO> lambdaQueryWrapper = new LambdaQueryWrapper<OaEntryDO>()
|
|
|
+ .eq(OaEntryDO::getProcInstId, currentTask.getProcessInstanceId());
|
|
|
+ OaEntryDO oaEntryDO = oaEntryMapper.selectOne(lambdaQueryWrapper);
|
|
|
+ if (!DictDataConstants.OA_AUDIT_STATUS_COMMITTED.equals(oaEntryDO.getAuditStatus())
|
|
|
+ || !Objects.equals(String.valueOf(loginUserId), oaEntryDO.getCreator())) {
|
|
|
+ throw ServiceExceptionUtil.exception(ErrorCodeConstants.TASK_REVOCATION_NO_ALLOWED);
|
|
|
+ }
|
|
|
|
|
|
- OaEntryDO oaEntry = BeanUtils.toBean(createReqVO, OaEntryDO.class);
|
|
|
+ BpmTaskReturnReqVO returnReqVO = BeanUtils.toBean(revocationReqVO, BpmTaskReturnReqVO.class);
|
|
|
+ returnReqVO.setTargetTaskDefinitionKey("modifyApply");
|
|
|
+ String reason = "[撤回]";
|
|
|
+ if (StrUtil.isNotBlank(returnReqVO.getReason())) {
|
|
|
+ reason = reason + returnReqVO.getReason();
|
|
|
+ }
|
|
|
+ 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);
|
|
|
|
|
|
- Task currentTask = taskService.createTaskQuery().processInstanceId(oaEntry.getProcInstId()).singleResult();
|
|
|
+ Task nextTask = taskService.createTaskQuery().processInstanceId(currentTask.getProcessInstanceId()).singleResult();
|
|
|
|
|
|
- //审批通过
|
|
|
- bpmTaskService.approveTask(userId, reqVO);
|
|
|
+ // 更新单据状态,当前处理人,最后处理时间
|
|
|
+ LambdaUpdateWrapper<OaEntryDO> updateWrapper = new LambdaUpdateWrapper<>();
|
|
|
+ updateWrapper.set(OaEntryDO::getCurrentAuditEmployeeId, nextTask.getAssignee())
|
|
|
+ .set(OaEntryDO::getFinalAuditDate, LocalDateTime.now())
|
|
|
+ .set(OaEntryDO::getAuditStatus, DictDataConstants.OA_AUDIT_STATUS_RECALLED)
|
|
|
+ .eq(OaEntryDO::getProcInstId, currentTask.getProcessInstanceId());
|
|
|
+ oaEntryMapper.update(updateWrapper);
|
|
|
|
|
|
- // 提交
|
|
|
- if (auditPass) {
|
|
|
- Task nextTask = taskService.createTaskQuery().processInstanceId(currentTask.getProcessInstanceId()).singleResult();
|
|
|
+ // 发送通知
|
|
|
|
|
|
- oaEntry.setAuditStatus("1");
|
|
|
- oaEntry.setCurrentAuditEmployeeId(nextTask.getAssignee());
|
|
|
- oaEntry.setFinalAuditDate(new Date());
|
|
|
- oaEntryMapper.updateById(oaEntry);
|
|
|
+ return 1L;
|
|
|
+ }
|
|
|
|
|
|
- } else {
|
|
|
- OaEntryDO oaEntryClose = new OaEntryDO();
|
|
|
- oaEntryClose.setId(oaEntry.getId());
|
|
|
- oaEntryClose.setAuditStatus("4");
|
|
|
- oaEntryClose.setCurrentAuditEmployeeId(null);
|
|
|
- oaEntryClose.setFinalAuditDate(new Date());
|
|
|
- oaEntryMapper.updateById(oaEntryClose);
|
|
|
+ @Override
|
|
|
+ @Transactional
|
|
|
+ public Long reCommitOaEntry(OaEntrySaveReqVO reCommitReqVO) {
|
|
|
+ if (reCommitReqVO.getId() == null) {
|
|
|
+ throw exception(ErrorCodeConstants.SERVICE_ID_NOT_EXISTS);
|
|
|
}
|
|
|
+ // 登录人信息
|
|
|
+ Long loginUserId = SecurityFrameworkUtils.getLoginUserId();
|
|
|
+ // TODO DP 根据登录人查询出对应的员工信息
|
|
|
+
|
|
|
+ OaEntryDO oaEntryNew = BeanUtils.toBean(reCommitReqVO, OaEntryDO.class);
|
|
|
+ OaEntryDO oaEntryOld = oaEntryMapper.selectById(oaEntryNew.getId());
|
|
|
+ oaEntryNew.setEntryId(oaEntryOld.getEntryId())
|
|
|
+ .setProcInstId(oaEntryOld.getProcInstId());
|
|
|
+
|
|
|
+ Task currentTask = taskService.createTaskQuery().processInstanceId(oaEntryNew.getProcInstId()).singleResult();
|
|
|
+ BpmTaskApproveReqVO approveReqVO = new BpmTaskApproveReqVO();
|
|
|
+ approveReqVO.setId(currentTask.getId())
|
|
|
+ .setReason("[再次提交]");
|
|
|
+ approveReqVO.setTaskStatus(Integer.valueOf(DictDataConstants.OA_AUDIT_STATUS_COMMITTED));
|
|
|
+ if (CollectionUtil.isNotEmpty(reCommitReqVO.getStartUserSelectAssignees())) {
|
|
|
+ // 添加审批人信息到流程参数中
|
|
|
+ Map<String, List<Long>> startUserSelectAssignees = new HashMap<>();
|
|
|
+ List<Long> selectAssignees = reCommitReqVO.getStartUserSelectAssignees();
|
|
|
+ startUserSelectAssignees.put("approver", selectAssignees);
|
|
|
+ taskService.setVariable(currentTask.getId(), BpmConstants.PROCESS_INSTANCE_VARIABLE_START_USER_SELECT_ASSIGNEES, startUserSelectAssignees);
|
|
|
+ // 保存审批人信息
|
|
|
+ oaEntryNew.setStartUserSelectAssignees(selectAssignees.stream().map(String::valueOf).collect(Collectors.joining(",")));
|
|
|
+ }
|
|
|
+ taskService.setVariable(currentTask.getId(), "auditPass", "true");
|
|
|
+ taskService.setVariable(currentTask.getId(),BpmConstants.PROCESS_INSTANCE_VARIABLE_STATUS, DictDataConstants.OA_AUDIT_STATUS_COMMITTED);
|
|
|
+ // 再次提交,和审批通过逻辑相同
|
|
|
+ bpmTaskService.approveTask(loginUserId, approveReqVO);
|
|
|
|
|
|
- return oaEntry.getId();
|
|
|
+ Task nextTask = taskService.createTaskQuery().processInstanceId(currentTask.getProcessInstanceId()).singleResult();
|
|
|
+ oaEntryNew.setAuditStatus(DictDataConstants.OA_AUDIT_STATUS_COMMITTED)
|
|
|
+ .setCurrentAuditEmployeeId(Long.valueOf(nextTask.getAssignee()))
|
|
|
+ .setFinalAuditDate(LocalDateTime.now());
|
|
|
+ oaEntryMapper.updateById(oaEntryNew);
|
|
|
+
|
|
|
+ // 保存业务uuid到附件中
|
|
|
+ saveFileList(reCommitReqVO.getFileIdList(), oaEntryNew.getEntryId());
|
|
|
+
|
|
|
+ return 1L;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public void updateOaEntry(OaEntrySaveReqVO updateReqVO) {
|
|
|
- // 校验存在
|
|
|
- validateOaEntryExists(updateReqVO.getId());
|
|
|
- // 更新
|
|
|
- OaEntryDO updateObj = BeanUtils.toBean(updateReqVO, OaEntryDO.class);
|
|
|
- oaEntryMapper.updateById(updateObj);
|
|
|
+ @Transactional
|
|
|
+ public Long closeOaEntry(OaEntrySaveReqVO closeReqVO) {
|
|
|
+ if (closeReqVO.getId() == null) {
|
|
|
+ throw exception(ErrorCodeConstants.SERVICE_ID_NOT_EXISTS);
|
|
|
+ }
|
|
|
+ // 登录人信息
|
|
|
+ Long loginUserId = SecurityFrameworkUtils.getLoginUserId();
|
|
|
+ // TODO DP 根据登录人查询出对应的员工信息
|
|
|
+
|
|
|
+ OaEntryDO oaEntryNew = BeanUtils.toBean(closeReqVO, OaEntryDO.class);
|
|
|
+ OaEntryDO oaEntryOld = oaEntryMapper.selectById(oaEntryNew.getId());
|
|
|
+
|
|
|
+ Task currentTask = taskService.createTaskQuery().processInstanceId(oaEntryOld.getProcInstId()).singleResult();
|
|
|
+ BpmTaskApproveReqVO approveReqVO = new BpmTaskApproveReqVO();
|
|
|
+ approveReqVO.setId(currentTask.getId())
|
|
|
+ .setReason("[关闭]");
|
|
|
+ approveReqVO.setTaskStatus(Integer.valueOf(DictDataConstants.OA_AUDIT_STATUS_CLOSED));
|
|
|
+ taskService.setVariable(currentTask.getId(), "auditPass", "false");
|
|
|
+ taskService.setVariable(currentTask.getId(),BpmConstants.PROCESS_INSTANCE_VARIABLE_STATUS, DictDataConstants.OA_AUDIT_STATUS_CLOSED);
|
|
|
+ // 关闭,使用审批通过的方法实现
|
|
|
+ bpmTaskService.approveTask(loginUserId, approveReqVO);
|
|
|
+
|
|
|
+ oaEntryOld.setAuditStatus(DictDataConstants.OA_AUDIT_STATUS_CLOSED)
|
|
|
+ .setCurrentAuditEmployeeId(-1L)
|
|
|
+ .setFinalAuditDate(LocalDateTime.now());
|
|
|
+ oaEntryMapper.updateById(oaEntryOld);
|
|
|
+
|
|
|
+ return 1L;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public void deleteOaEntry(Integer id) {
|
|
|
+ public void deleteOaEntry(Long id) {
|
|
|
// 校验存在
|
|
|
validateOaEntryExists(id);
|
|
|
// 删除
|
|
|
oaEntryMapper.deleteById(id);
|
|
|
}
|
|
|
|
|
|
- private void validateOaEntryExists(Integer id) {
|
|
|
- if (oaEntryMapper.selectById(id) == null) {
|
|
|
- throw exception(OA_ENTRY_NOT_EXISTS);
|
|
|
+ @Override
|
|
|
+ public OaEntryRespVO getOaEntry(Long id) {
|
|
|
+ // 登录人信息
|
|
|
+ Long loginUserId = SecurityFrameworkUtils.getLoginUserId();
|
|
|
+ // TODO DP 根据登录人查询出对应的员工信息
|
|
|
+
|
|
|
+ OaEntryDO oaEntryDO = oaEntryMapper.selectById(id);
|
|
|
+ OaEntryRespVO oaEntryRespVO = BeanUtils.toBean(oaEntryDO, OaEntryRespVO.class);
|
|
|
+ if (oaEntryDO.getDeptId() != null) {
|
|
|
+ DeptRespDTO dept = deptApi.getDept(oaEntryDO.getDeptId());
|
|
|
+ if (dept != null) {
|
|
|
+ oaEntryRespVO.setDeptName(dept.getName());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ String procInstId = oaEntryDO.getProcInstId();
|
|
|
+ if (StrUtil.isNotBlank(procInstId)) {
|
|
|
+ Task task = taskService.createTaskQuery()
|
|
|
+ .processInstanceId(procInstId)
|
|
|
+ .taskAssignee(String.valueOf(loginUserId))
|
|
|
+ .singleResult();
|
|
|
+ if (DictDataConstants.OA_AUDIT_STATUS_COMMITTED.equals(oaEntryDO.getAuditStatus())) {
|
|
|
+ // 如果是已提交,不限制任务处理人是当前登录人,用于直接撤回
|
|
|
+ task = taskService.createTaskQuery()
|
|
|
+ .processInstanceId(procInstId)
|
|
|
+ .singleResult();
|
|
|
+ }
|
|
|
+ if (task != null) {
|
|
|
+ oaEntryRespVO.setTaskId(task.getId());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 附件列表
|
|
|
+ List<FileDTO> fileList = fileApi.getFileDTOListByBiz(oaEntryDO.getEntryId());
|
|
|
+ oaEntryRespVO.setFileList(fileList);
|
|
|
+
|
|
|
+ // 审批记录
|
|
|
+ if (StrUtil.isNotBlank(oaEntryDO.getProcInstId())) {
|
|
|
+ List<BpmTaskRespVO> auditRecordList = bpmTaskService.getAuditRecordListByProcessInstanceId(oaEntryDO.getProcInstId());
|
|
|
+ oaEntryRespVO.setAuditRecordList(auditRecordList);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 审批人
|
|
|
+ String startUserSelectAssignees = oaEntryDO.getStartUserSelectAssignees();
|
|
|
+ if (StrUtil.isNotEmpty(startUserSelectAssignees)) {
|
|
|
+ List<Long> userIdList = 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;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ oaEntryRespVO.setAuditUserList(auditUserList);
|
|
|
+ }
|
|
|
+
|
|
|
+ return oaEntryRespVO;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public OaEntryRespVO getOaEntryByProcInstId(String procInstId) {
|
|
|
+ OaEntryDO oaEntryDO = oaEntryMapper.selectOne(OaEntryDO::getProcInstId, procInstId);
|
|
|
+ OaEntryRespVO oaEntryRespVO = BeanUtils.toBean(oaEntryDO, OaEntryRespVO.class);
|
|
|
+ if (oaEntryDO.getDeptId() != null) {
|
|
|
+ DeptRespDTO dept = deptApi.getDept(oaEntryDO.getDeptId());
|
|
|
+ if (dept != null) {
|
|
|
+ oaEntryRespVO.setDeptName(dept.getName());
|
|
|
+ }
|
|
|
}
|
|
|
+
|
|
|
+ // 附件列表
|
|
|
+ List<FileDTO> fileList = fileApi.getFileDTOListByBiz(oaEntryDO.getEntryId());
|
|
|
+ oaEntryRespVO.setFileList(fileList);
|
|
|
+
|
|
|
+ // 审批记录
|
|
|
+ if (StrUtil.isNotBlank(oaEntryDO.getProcInstId())) {
|
|
|
+ List<BpmTaskRespVO> auditRecordList = bpmTaskService.getAuditRecordListByProcessInstanceId(oaEntryDO.getProcInstId());
|
|
|
+ oaEntryRespVO.setAuditRecordList(auditRecordList);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 审批人
|
|
|
+ String startUserSelectAssignees = oaEntryDO.getStartUserSelectAssignees();
|
|
|
+ if (StrUtil.isNotEmpty(startUserSelectAssignees)) {
|
|
|
+ List<Long> userIdList = 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;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ oaEntryRespVO.setAuditUserList(auditUserList);
|
|
|
+ }
|
|
|
+
|
|
|
+ return oaEntryRespVO;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public OaEntryDO getOaEntry(Integer id) {
|
|
|
- return oaEntryMapper.selectById(id);
|
|
|
+ public PageResult<OaEntryRespVO> getOaEntryPage(OaEntryPageReqVO pageReqVO) {
|
|
|
+ PageResult<OaEntryDO> oaEntryDOPageResult = oaEntryMapper.selectPage(pageReqVO);
|
|
|
+ PageResult<OaEntryRespVO> oaEntryRespVOPageResult = BeanUtils.toBean(oaEntryDOPageResult, OaEntryRespVO.class);
|
|
|
+
|
|
|
+ List<OaEntryRespVO> oaEntryRespVOList = oaEntryRespVOPageResult.getList();
|
|
|
+ if (CollectionUtil.isNotEmpty(oaEntryRespVOList)) {
|
|
|
+ List<Long> employeeIdList = oaEntryRespVOList.stream().map(OaEntryRespVO::getCurrentAuditEmployeeId).collect(Collectors.toList());
|
|
|
+ List<AdminUserRespDTO> employeeList = adminUserApi.getUserList(employeeIdList);
|
|
|
+ for (OaEntryRespVO respVO : oaEntryRespVOList) {
|
|
|
+ for (AdminUserRespDTO employee : employeeList) {
|
|
|
+ if (respVO.getCurrentAuditEmployeeId() == employee.getId()) {
|
|
|
+ respVO.setCurrentAuditEmployeeName(employee.getNickname());
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ List<Long> deptIdList = oaEntryRespVOList.stream().map(OaEntryRespVO::getDeptId).collect(Collectors.toList());
|
|
|
+ List<DeptRespDTO> deptList = deptApi.getDeptList(deptIdList);
|
|
|
+ for (OaEntryRespVO respVO : oaEntryRespVOList) {
|
|
|
+ for (DeptRespDTO dept : deptList) {
|
|
|
+ if (respVO.getDeptId() == dept.getId()) {
|
|
|
+ respVO.setDeptName(dept.getName());
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return oaEntryRespVOPageResult;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public PageResult<OaEntryDO> getOaEntryPage(OaEntryPageReqVO pageReqVO) {
|
|
|
- return oaEntryMapper.selectPage(pageReqVO);
|
|
|
+ public PageResult<OaEntryRespVO> exportOaEntryExcel(OaEntryPageReqVO pageReqVO) {
|
|
|
+ pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
|
|
+ return getOaEntryPage(pageReqVO);
|
|
|
+ }
|
|
|
+
|
|
|
+ private void validateOaEntryExists(Long id) {
|
|
|
+ OaEntryDO oaEntryDO = oaEntryMapper.selectById(id);
|
|
|
+ if (oaEntryDO == null) {
|
|
|
+ throw exception(OA_ENTRY_NOT_EXISTS);
|
|
|
+ }
|
|
|
+ if (!DictDataConstants.OA_AUDIT_STATUS_STAGING.equals(oaEntryDO.getAuditStatus())) {
|
|
|
+ throw exception(ErrorCodeConstants.DELETE_FAIL_NOT_STAGING);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 保存业务uuid到附件中
|
|
|
+ */
|
|
|
+ private void saveFileList(List<Long> fileIdList, String serviceId) {
|
|
|
+ if (CollectionUtil.isNotEmpty(fileIdList) && StrUtil.isNotEmpty(serviceId)) {
|
|
|
+ fileApi.updateFileBiz(fileIdList, serviceId);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
}
|