feat(REQ-3769) - 签署业务中,每个节点结束后,都进行一次文档变量替换,并更新实例签署文档数据
This commit is contained in:
parent
dedb68e5c0
commit
dc3d7a0641
@ -1,13 +1,34 @@
|
||||
package cn.axzo.workflow.server.controller.listener.activity;
|
||||
|
||||
import cn.axzo.workflow.common.model.dto.SignFileDTO;
|
||||
import cn.axzo.workflow.common.model.request.bpmn.BpmnSignConf;
|
||||
import cn.axzo.workflow.common.model.response.bpmn.model.doc.DocBaseVO;
|
||||
import cn.axzo.workflow.core.common.context.ActivityOperationContext;
|
||||
import cn.axzo.workflow.core.common.utils.BpmnMetaParserHelper;
|
||||
import cn.axzo.workflow.core.engine.cmd.CustomGetModelDocsCmd;
|
||||
import cn.axzo.workflow.core.listener.AbstractBpmnEventListener;
|
||||
import cn.axzo.workflow.core.listener.BpmnActivityEventListener;
|
||||
import cn.axzo.workflow.core.repository.entity.ExtAxProcessSign;
|
||||
import cn.axzo.workflow.core.repository.mapper.ExtAxModelDocMapper;
|
||||
import cn.axzo.workflow.core.service.ExtAxProcessSignService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.flowable.bpmn.model.Process;
|
||||
import org.flowable.common.engine.impl.interceptor.CommandExecutor;
|
||||
import org.flowable.engine.HistoryService;
|
||||
import org.flowable.engine.delegate.DelegateExecution;
|
||||
import org.flowable.engine.history.HistoricProcessInstance;
|
||||
import org.flowable.engine.impl.cfg.ProcessEngineConfigurationImpl;
|
||||
import org.flowable.engine.impl.util.CommandContextUtil;
|
||||
import org.flowable.engine.impl.util.ProcessDefinitionUtil;
|
||||
import org.springframework.context.annotation.Scope;
|
||||
import org.springframework.core.Ordered;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
* 每个审批节点完成后,生成替换变量后的文件
|
||||
@ -19,13 +40,50 @@ import org.springframework.stereotype.Component;
|
||||
@Component
|
||||
@Scope("prototype")
|
||||
public class TempFileArchiveActivityEvent_101_Listener extends AbstractBpmnEventListener<ActivityOperationContext> implements BpmnActivityEventListener, Ordered {
|
||||
@Resource
|
||||
private ExtAxModelDocMapper extAxModelDocMapper;
|
||||
@Resource
|
||||
private ExtAxProcessSignService extAxProcessSignService;
|
||||
|
||||
@Override
|
||||
public int getOrder() {
|
||||
return 0;
|
||||
return Integer.MIN_VALUE + 101;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEnd(DelegateExecution execution) {
|
||||
Process process = ProcessDefinitionUtil.getProcess(execution.getProcessDefinitionId());
|
||||
Optional<BpmnSignConf> signConfig = BpmnMetaParserHelper.getSignConfig(process);
|
||||
if (!signConfig.isPresent()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// TODO 临时替换一次变量, 并记录文件
|
||||
ProcessEngineConfigurationImpl processEngineConfiguration = CommandContextUtil.getProcessEngineConfiguration();
|
||||
CommandExecutor commandExecutor = processEngineConfiguration.getCommandExecutor();
|
||||
List<DocBaseVO> docs = commandExecutor.execute(new CustomGetModelDocsCmd(execution.getProcessInstanceId(), true, extAxModelDocMapper));
|
||||
if (CollectionUtils.isEmpty(docs)) {
|
||||
return;
|
||||
}
|
||||
|
||||
HistoryService historyService = processEngineConfiguration.getHistoryService();
|
||||
HistoricProcessInstance instance = historyService.createHistoricProcessInstanceQuery()
|
||||
.processInstanceId(execution.getProcessInstanceId())
|
||||
.includeProcessVariables()
|
||||
.singleResult();
|
||||
|
||||
ExtAxProcessSign processSign = extAxProcessSignService.findByProcessInstanceId(execution.getProcessInstanceId());
|
||||
List<SignFileDTO> archives = new ArrayList<>();
|
||||
docs.forEach(doc -> {
|
||||
SignFileDTO signFileDTO = new SignFileDTO();
|
||||
signFileDTO.setId(doc.getId());
|
||||
signFileDTO.setFileTag(doc.getTag());
|
||||
// TODO 替换变量,生成新的文档
|
||||
signFileDTO.setFileCode("");
|
||||
signFileDTO.setFileType(doc.getFileType());
|
||||
archives.add(signFileDTO);
|
||||
});
|
||||
processSign.setFileArchive(archives);
|
||||
extAxProcessSignService.updateById(processSign);
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user