feat(REQ-3340) - 调整查询是否有打印模板的逻辑

This commit is contained in:
wangli 2025-02-24 16:57:47 +08:00
parent 888147c2fe
commit bd5f578a71
2 changed files with 24 additions and 10 deletions

View File

@ -100,7 +100,6 @@ import org.flowable.engine.history.HistoricProcessInstanceQuery;
import org.flowable.engine.history.NativeHistoricProcessInstanceQuery;
import org.flowable.engine.impl.bpmn.behavior.MultiInstanceActivityBehavior;
import org.flowable.engine.impl.persistence.entity.ActivityInstanceEntity;
import org.flowable.engine.repository.Model;
import org.flowable.engine.repository.ProcessDefinition;
import org.flowable.engine.runtime.ActivityInstance;
import org.flowable.engine.runtime.NativeActivityInstanceQuery;
@ -162,6 +161,7 @@ import static cn.axzo.workflow.common.constant.BpmnConstants.INITIATOR_SPECIFY;
import static cn.axzo.workflow.common.constant.BpmnConstants.INTERNAL_INITIATOR;
import static cn.axzo.workflow.common.constant.BpmnConstants.INTERNAL_PROCESS_AGENT;
import static cn.axzo.workflow.common.constant.BpmnConstants.INTERNAL_PROCESS_WORKSPACE_TYPE;
import static cn.axzo.workflow.common.constant.BpmnConstants.NO_TENANT_ID;
import static cn.axzo.workflow.common.constant.BpmnConstants.OLD_INTERNAL_INITIATOR;
import static cn.axzo.workflow.common.constant.BpmnConstants.PENDING_TEMPLATE_VARIABLE;
import static cn.axzo.workflow.common.constant.BpmnConstants.PROCESS_OWNERSHIP_APPLICATION;
@ -1287,7 +1287,12 @@ public class BpmnProcessInstanceServiceImpl implements BpmnProcessInstanceServic
@Override
public boolean hasPrintTemplate(String processInstanceId, String processDefinitionId) {
return extAxReModelService.hasPrintTemplateConfig(getModelIdByProcessDefinitionId(processInstanceId, processDefinitionId));
try {
return extAxReModelService.hasPrintTemplateConfig(getModelIdByProcessDefinitionId(processInstanceId, processDefinitionId));
} catch (Exception e) {
log.warn("hasPrintTemplate error:{}", e.getMessage(), e);
return false;
}
}
private void calcAuthorizedButtons(BpmnProcessInstanceLogVO logVO, BpmnTaskDelegateAssigner visitor) {
@ -1646,15 +1651,23 @@ public class BpmnProcessInstanceServiceImpl implements BpmnProcessInstanceServic
key = processDefinition.getKey();
tenantId = processDefinition.getTenantId();
}
Optional<Model> first = repositoryService.createModelQuery()
return repositoryService.createModelQuery()
.modelKey(key)
// .modelCategory(BPMN_FILE_SUFFIX)
.modelTenantId(tenantId)
.list().stream().filter(i -> Objects.equals(i.getCategory(), BPMN_FILE_SUFFIX) || Objects.equals(i.getCategory(), i.getKey()))
.filter(i -> i.getMetaInfo().contains(MODEL_TYPE_PROCESS))
.findFirst();
return first.orElseThrow(() -> new WorkflowEngineException(MODEL_NOT_EXISTS)).getId();
.list().stream()
.filter(i -> (Objects.equals(i.getTenantId(), tenantId) || Objects.equals(i.getTenantId(), NO_TENANT_ID))
&& (Objects.equals(i.getCategory(), BPMN_FILE_SUFFIX) || Objects.equals(i.getCategory(), i.getKey()))
&& i.getMetaInfo().contains(MODEL_TYPE_PROCESS))
.sorted((a, b) -> {
if (Objects.equals(a.getTenantId(), tenantId)) {
return -1;
} else if (Objects.equals(b.getTenantId(), tenantId)) {
return 1;
}
return 0;
})
.findFirst()
.orElseThrow(() -> new WorkflowEngineException(MODEL_NOT_EXISTS))
.getId();
}
@Override

View File

@ -107,6 +107,7 @@ public class PrintAdminController implements PrintAdminApi {
private UserTaskForecasting userTaskForecasting;
@Override
@PostMapping("/template/exists")
public CommonResponse<Boolean> hasPrintTemplate(String processInstanceId) {
return CommonResponse.success(bpmnProcessInstanceService.hasPrintTemplate(processInstanceId, null));
}