REQ-3982: 没有打印模版时去掉相关的按钮
This commit is contained in:
parent
f79473ad1a
commit
0092fbdaa9
@ -2,6 +2,7 @@ package cn.axzo.nanopart.visa.api.response;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
@ -324,7 +325,7 @@ public class VisaDetailByIdResponse {
|
||||
public void addButton(String name, WorkflowButtonType type) {
|
||||
if (buttons == null)
|
||||
buttons = new ArrayList<>();
|
||||
if (hasButtonOfType(type))
|
||||
if (containsButtonOfType(type))
|
||||
return;
|
||||
WorkflowDetailButton workflowDetailButton = new WorkflowDetailButton();
|
||||
workflowDetailButton.setName(name);
|
||||
@ -332,10 +333,16 @@ public class VisaDetailByIdResponse {
|
||||
buttons.add(workflowDetailButton);
|
||||
}
|
||||
|
||||
public boolean hasButtonOfType(WorkflowButtonType type) {
|
||||
public boolean containsButtonOfType(WorkflowButtonType type) {
|
||||
return buttons.stream().anyMatch(button -> button.type == type);
|
||||
}
|
||||
|
||||
public void removeButtonOfType(WorkflowButtonType... types) {
|
||||
if (buttons == null || types.length == 0) return;
|
||||
HashSet<WorkflowButtonType> typesSet = Sets.newHashSet(types);
|
||||
buttons.removeIf(button -> typesSet.contains(button.type));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Setter @Getter
|
||||
|
||||
@ -28,15 +28,18 @@ import cn.axzo.nanopart.visa.api.response.VisaDetailByIdResponse.WorkflowButtonT
|
||||
import cn.axzo.nanopart.visa.server.domain.ChangeRecord;
|
||||
import cn.axzo.nanopart.visa.server.domain.ChangeRecordRelation;
|
||||
import cn.axzo.nanopart.visa.server.dto.VisaRelationDto;
|
||||
import cn.axzo.nanopart.visa.server.rpc.WorkflowGateway;
|
||||
import cn.axzo.nanopart.visa.server.service.ChangeRecordRelationService;
|
||||
import cn.axzo.workflow.common.enums.BpmnProcessInstanceResultEnum;
|
||||
import cn.axzo.workflow.common.model.response.form.instance.FormInstanceVO;
|
||||
import cn.axzo.workflow.common.model.response.print.PrintModelDTO;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
/**
|
||||
* @author yanglin
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
@RequiredArgsConstructor
|
||||
public class DetailCardBuilder {
|
||||
@ -44,6 +47,7 @@ public class DetailCardBuilder {
|
||||
private final PrintModelService printModelService;
|
||||
private final ChangeRecordRelationService changeRecordRelationService;
|
||||
private final PendingMessageClient pendingMessageClient;
|
||||
private final WorkflowGateway workflowGateway;
|
||||
|
||||
List<DetailCard> build(ChangeRecord visa) {
|
||||
ArrayList<DetailCard> details = new ArrayList<>();
|
||||
@ -92,7 +96,7 @@ public class DetailCardBuilder {
|
||||
detail.addButton("用印进展", WorkflowButtonType.STAMP_PROGRESS);
|
||||
// 未用印,但有历史被驳回的用印
|
||||
if (stampStatus == VisaStampStatusEnum.UNPRINTED
|
||||
&& !detail.hasButtonOfType(WorkflowButtonType.STAMP_PROGRESS)) {
|
||||
&& !detail.containsButtonOfType(WorkflowButtonType.STAMP_PROGRESS)) {
|
||||
VisaRelationFieldEnum fieldType = phase == VisaProcessPhase.PROJECT ? PROCESS_INSTANCE_OF_ESS : PROCESS_INSTANCE_OF_ESS_PAY;
|
||||
List<ChangeRecordRelation> essInstances = changeRecordRelationService.findByCondition(VisaRelationDto.builder()
|
||||
.visaId(visa.getId())
|
||||
@ -102,6 +106,13 @@ public class DetailCardBuilder {
|
||||
if (CollectionUtils.isNotEmpty(essInstances))
|
||||
detail.addButton("用印进展", WorkflowButtonType.STAMP_PROGRESS);
|
||||
}
|
||||
|
||||
if (!workflowGateway.hasPrintTemplate(detail.getWorkflowInstanceId())) {
|
||||
log.info("没有打印模版, 用掉打印/用印相关按钮. workflowInstanceId={}", detail.getWorkflowInstanceId());
|
||||
detail.removeButtonOfType(WorkflowButtonType.PRINT, //
|
||||
WorkflowButtonType.STAMP_PROGRESS, //
|
||||
WorkflowButtonType.REQUEST_STAMP);
|
||||
}
|
||||
}
|
||||
details.add(detail);
|
||||
};
|
||||
|
||||
Loading…
Reference in New Issue
Block a user