update 强制撤回通用逻辑

update 保存草稿时如果有draftId就删掉之前草稿
This commit is contained in:
lijiarao
2024-01-11 11:27:08 +08:00
parent 07e6e2a489
commit 403ec83e7e
2 changed files with 17 additions and 5 deletions
@@ -351,6 +351,10 @@ public class ProcessHandleServiceImpl implements IProcessHandleService{
updateApprovalRecord(processInfoVO);
// 删除自己的草稿
String draftId = processInfoVO.getDraftId();
if (StringUtils.isNotBlank(draftId)){
processDraftService.removeById(draftId);
}
deleteMyDraft(taskId, processInfoVO.getBusinessId(), basicProcessInfoDTO.getProcessType());
// 根据是否有taskId区分保存来源(待办、草稿)
BasicTaskInfoDTO basicTaskInfoDTO1 = processInfoVO.getBasicTaskInfoDTO();
@@ -1,5 +1,6 @@
package com.jero.modules.activiti.service;
import cn.hutool.core.collection.CollStreamUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
@@ -37,6 +38,8 @@ import java.util.stream.Collectors;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.jero.modules.activiti.mapper.ProcessAllMapper;
import com.jero.modules.activiti.entity.ProcessAll;
import org.springframework.transaction.annotation.Transactional;
/**
*
*@author liJiaRao
@@ -76,22 +79,27 @@ public class ProcessAllService extends ServiceImpl<ProcessAllMapper, ProcessAll>
public IPage<ProcessAll> getSentList(Page<ProcessAll> page, QueryWrapper<ProcessAll> queryWrapper) {
return processAllMapper.getSentList(page,queryWrapper);
}
@Transactional(rollbackFor = Exception.class)
public void forcedWithdrawal(String processInstanceId) {
//获得流程总表
ProcessAll processAll = getByProcessInstanceId(processInstanceId);
//删除所有草稿
//删除流程中所有草稿(除了初始草稿)
LambdaUpdateWrapper<ProcessDraft> processDraftUpdateWrapper = new LambdaUpdateWrapper<>();
processDraftUpdateWrapper.eq(ProcessDraft::getProcessInstanceId, processInstanceId);
processDraftUpdateWrapper.ne(ProcessDraft::getSaveSource, DraftCommon.INITIAL_SOURCE);
processDraftService.remove(processDraftUpdateWrapper);
List<ProcessDraft> drafts = processDraftService.list(processDraftUpdateWrapper);
List<String> draftIds = CollStreamUtil.toList(drafts, ProcessDraft::getId);
processDraftService.removeByIds(draftIds);
processDraftUpdateWrapper.clear();
//业务表修改为草稿
Integer prcType = processAll.getPrcType();
WorkCenterService classByValue = null;
try {
classByValue = (WorkCenterService) Class.forName(ProcessTypeEnum.getClassByValue(prcType)).newInstance();
classByValue.changeToDraft(processAll);
Object o = Class.forName(ProcessTypeEnum.getClassByValue(prcType)).newInstance();
if (o instanceof WorkCenterService){
classByValue = (WorkCenterService) o;
classByValue.changeToDraft(processAll);
}
}catch (Exception e) {
log.error(e.getMessage(),e);
}