Merge branch 'feature/REQ-5965' into dev
This commit is contained in:
commit
24db7ff862
@ -118,7 +118,7 @@ public interface BpmnConstants {
|
|||||||
String CONFIG_FIELD_META = "field";
|
String CONFIG_FIELD_META = "field";
|
||||||
String CONFIG_FIELD_PERMISSION = "fieldPermission";
|
String CONFIG_FIELD_PERMISSION = "fieldPermission";
|
||||||
String CONFIG_CONDITION_PERMISSION = "conditionPermission";
|
String CONFIG_CONDITION_PERMISSION = "conditionPermission";
|
||||||
String CONFIG_FIELD_OPTION = "option";
|
String CONFIG_FIELD_OPTIONS = "options";
|
||||||
String CONFIG_NODE_TYPE = "nodeType";
|
String CONFIG_NODE_TYPE = "nodeType";
|
||||||
String CONFIG_BUTTON_TYPE_INITIATOR = "initiator";
|
String CONFIG_BUTTON_TYPE_INITIATOR = "initiator";
|
||||||
String CONFIG_BUTTON_TYPE_CURRENT = "current";
|
String CONFIG_BUTTON_TYPE_CURRENT = "current";
|
||||||
|
|||||||
@ -27,7 +27,7 @@ public class BpmnFieldOptionConf implements Serializable {
|
|||||||
* 选项的值
|
* 选项的值
|
||||||
*/
|
*/
|
||||||
@ApiModelProperty(value = "选项的值", example = "1")
|
@ApiModelProperty(value = "选项的值", example = "1")
|
||||||
private String value;
|
private Object value;
|
||||||
|
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return name;
|
return name;
|
||||||
@ -37,11 +37,11 @@ public class BpmnFieldOptionConf implements Serializable {
|
|||||||
this.name = name;
|
this.name = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getValue() {
|
public Object getValue() {
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setValue(String value) {
|
public void setValue(Object value) {
|
||||||
this.value = value;
|
this.value = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -93,4 +93,10 @@ public class CategoryCreateDTO {
|
|||||||
@ApiModelProperty(value = "版本号")
|
@ApiModelProperty(value = "版本号")
|
||||||
private Integer version;
|
private Integer version;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 自定替换未设置的变量为空串
|
||||||
|
*/
|
||||||
|
@ApiModelProperty(value = "是否自动替换变量为空串,默认false")
|
||||||
|
private Boolean autoReplaceVariables;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -62,7 +62,7 @@ public class ConditionPermissionMetaInfo implements Serializable {
|
|||||||
/**
|
/**
|
||||||
* 前端回显字段,后端不做任何消费逻辑
|
* 前端回显字段,后端不做任何消费逻辑
|
||||||
*/
|
*/
|
||||||
private String value;
|
private Object value;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 类型是单选复选时的选项值
|
* 类型是单选复选时的选项值
|
||||||
|
|||||||
@ -47,6 +47,9 @@ public class CategoryItemVO {
|
|||||||
@ApiModelProperty(value = "版本号")
|
@ApiModelProperty(value = "版本号")
|
||||||
private Integer version;
|
private Integer version;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "自定替换未设置的变量为空串")
|
||||||
|
private Boolean autoReplaceVariables;
|
||||||
|
|
||||||
@ApiModelProperty(value = "更新时间")
|
@ApiModelProperty(value = "更新时间")
|
||||||
private Date updateAt;
|
private Date updateAt;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -90,7 +90,7 @@ import static cn.axzo.workflow.common.constant.BpmnConstants.CONFIG_BUTTON_TYPE_
|
|||||||
import static cn.axzo.workflow.common.constant.BpmnConstants.CONFIG_BUTTON_TYPE_INITIATOR;
|
import static cn.axzo.workflow.common.constant.BpmnConstants.CONFIG_BUTTON_TYPE_INITIATOR;
|
||||||
import static cn.axzo.workflow.common.constant.BpmnConstants.CONFIG_FIELD;
|
import static cn.axzo.workflow.common.constant.BpmnConstants.CONFIG_FIELD;
|
||||||
import static cn.axzo.workflow.common.constant.BpmnConstants.CONFIG_FIELD_META;
|
import static cn.axzo.workflow.common.constant.BpmnConstants.CONFIG_FIELD_META;
|
||||||
import static cn.axzo.workflow.common.constant.BpmnConstants.CONFIG_FIELD_OPTION;
|
import static cn.axzo.workflow.common.constant.BpmnConstants.CONFIG_FIELD_OPTIONS;
|
||||||
import static cn.axzo.workflow.common.constant.BpmnConstants.CONFIG_NOTICE;
|
import static cn.axzo.workflow.common.constant.BpmnConstants.CONFIG_NOTICE;
|
||||||
import static cn.axzo.workflow.common.constant.BpmnConstants.CONFIG_SIGN;
|
import static cn.axzo.workflow.common.constant.BpmnConstants.CONFIG_SIGN;
|
||||||
import static cn.axzo.workflow.common.constant.BpmnConstants.CONFIG_SIGN_TYPE;
|
import static cn.axzo.workflow.common.constant.BpmnConstants.CONFIG_SIGN_TYPE;
|
||||||
@ -346,22 +346,10 @@ public final class BpmnJsonConverterUtil {
|
|||||||
field.addAttribute(fieldCode);
|
field.addAttribute(fieldCode);
|
||||||
|
|
||||||
if (!CollectionUtils.isEmpty(i.getOptions())) {
|
if (!CollectionUtils.isEmpty(i.getOptions())) {
|
||||||
i.getOptions().forEach(j -> {
|
ExtensionAttribute fieldOptions = new ExtensionAttribute();
|
||||||
ExtensionElement option = new ExtensionElement();
|
fieldCode.setName(CONFIG_FIELD_OPTIONS);
|
||||||
option.setName(CONFIG_FIELD_OPTION);
|
fieldCode.setValue(JSON.toJSONString(i.getOptions()));
|
||||||
|
field.addAttribute(fieldOptions);
|
||||||
ExtensionAttribute optionName = new ExtensionAttribute();
|
|
||||||
optionName.setName(ELEMENT_ATTRIBUTE_NAME);
|
|
||||||
optionName.setValue(j.getName());
|
|
||||||
option.addAttribute(optionName);
|
|
||||||
|
|
||||||
ExtensionAttribute optionValue = new ExtensionAttribute();
|
|
||||||
optionValue.setName(ELEMENT_ATTRIBUTE_VALUE);
|
|
||||||
optionValue.setValue(j.getValue());
|
|
||||||
option.addAttribute(optionValue);
|
|
||||||
|
|
||||||
field.addChildElement(option);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
fieldConfigElement.addChildElement(field);
|
fieldConfigElement.addChildElement(field);
|
||||||
});
|
});
|
||||||
|
|||||||
@ -86,7 +86,7 @@ import static cn.axzo.workflow.common.constant.BpmnConstants.CONFIG_CARBON_COPY_
|
|||||||
import static cn.axzo.workflow.common.constant.BpmnConstants.CONFIG_CONDITION_PERMISSION;
|
import static cn.axzo.workflow.common.constant.BpmnConstants.CONFIG_CONDITION_PERMISSION;
|
||||||
import static cn.axzo.workflow.common.constant.BpmnConstants.CONFIG_FIELD;
|
import static cn.axzo.workflow.common.constant.BpmnConstants.CONFIG_FIELD;
|
||||||
import static cn.axzo.workflow.common.constant.BpmnConstants.CONFIG_FIELD_META;
|
import static cn.axzo.workflow.common.constant.BpmnConstants.CONFIG_FIELD_META;
|
||||||
import static cn.axzo.workflow.common.constant.BpmnConstants.CONFIG_FIELD_OPTION;
|
import static cn.axzo.workflow.common.constant.BpmnConstants.CONFIG_FIELD_OPTIONS;
|
||||||
import static cn.axzo.workflow.common.constant.BpmnConstants.CONFIG_FIELD_PERMISSION;
|
import static cn.axzo.workflow.common.constant.BpmnConstants.CONFIG_FIELD_PERMISSION;
|
||||||
import static cn.axzo.workflow.common.constant.BpmnConstants.CONFIG_INITIATOR_LEADER_RANGE_UNIT;
|
import static cn.axzo.workflow.common.constant.BpmnConstants.CONFIG_INITIATOR_LEADER_RANGE_UNIT;
|
||||||
import static cn.axzo.workflow.common.constant.BpmnConstants.CONFIG_INITIATOR_SPECIFIED_EXCLUDE_COOPERATE_TYPES;
|
import static cn.axzo.workflow.common.constant.BpmnConstants.CONFIG_INITIATOR_SPECIFIED_EXCLUDE_COOPERATE_TYPES;
|
||||||
@ -433,15 +433,9 @@ public final class BpmnMetaParserHelper {
|
|||||||
conf.setName(i.getAttributeValue(null, ELEMENT_ATTRIBUTE_NAME));
|
conf.setName(i.getAttributeValue(null, ELEMENT_ATTRIBUTE_NAME));
|
||||||
conf.setCode(i.getAttributeValue(null, ELEMENT_ATTRIBUTE_CODE));
|
conf.setCode(i.getAttributeValue(null, ELEMENT_ATTRIBUTE_CODE));
|
||||||
|
|
||||||
List<BpmnFieldOptionConf> options = new ArrayList<>();
|
String fieldOptionsJsonStr = i.getAttributeValue(null, CONFIG_FIELD_OPTIONS);
|
||||||
if (!CollectionUtils.isEmpty(i.getChildElements())) {
|
if (StringUtils.hasText(fieldOptionsJsonStr)) {
|
||||||
i.getChildElements().get(CONFIG_FIELD_OPTION).forEach(j -> {
|
conf.setOptions(JSON.parseArray(fieldOptionsJsonStr, BpmnFieldOptionConf.class));
|
||||||
BpmnFieldOptionConf option = new BpmnFieldOptionConf();
|
|
||||||
option.setName(j.getAttributeValue(null, ELEMENT_ATTRIBUTE_NAME));
|
|
||||||
option.setValue(j.getAttributeValue(null, ELEMENT_ATTRIBUTE_VALUE));
|
|
||||||
options.add(option);
|
|
||||||
});
|
|
||||||
conf.setOptions(options);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fields.add(conf);
|
fields.add(conf);
|
||||||
@ -703,6 +697,7 @@ public final class BpmnMetaParserHelper {
|
|||||||
return defaultValid(flowElement, CONFIG_CONDITION_PERMISSION).map(element -> JSON.parseObject(element.getElementText(), new TypeReference<List<ConditionPermissionMetaInfo>>() {
|
return defaultValid(flowElement, CONFIG_CONDITION_PERMISSION).map(element -> JSON.parseObject(element.getElementText(), new TypeReference<List<ConditionPermissionMetaInfo>>() {
|
||||||
}.getType()));
|
}.getType()));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Optional<ImmutableTable<String, String, Integer>> getFormFieldPermissionForCalc(FlowElement flowElement) {
|
public static Optional<ImmutableTable<String, String, Integer>> getFormFieldPermissionForCalc(FlowElement flowElement) {
|
||||||
List<FormPermissionMetaInfo> fieldMetaInfos = getFormFieldPermissionConf(flowElement).orElse(new ArrayList<>());
|
List<FormPermissionMetaInfo> fieldMetaInfos = getFormFieldPermissionConf(flowElement).orElse(new ArrayList<>());
|
||||||
return getFormFieldPermissionForModel(fieldMetaInfos);
|
return getFormFieldPermissionForModel(fieldMetaInfos);
|
||||||
|
|||||||
@ -210,6 +210,9 @@ public class CustomApproveTaskCmd extends AbstractCommand<Void> implements Seria
|
|||||||
List<AttachmentDTO> attachmentList,
|
List<AttachmentDTO> attachmentList,
|
||||||
String advice,
|
String advice,
|
||||||
BpmnTaskDelegateAssigner approver) {
|
BpmnTaskDelegateAssigner approver) {
|
||||||
|
if (Objects.isNull(approver)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
List<SignatureDTO> signatures = runtimeService.getVariable(task.getProcessInstanceId(), SIGNATURE_COLLECTION, List.class);
|
List<SignatureDTO> signatures = runtimeService.getVariable(task.getProcessInstanceId(), SIGNATURE_COLLECTION, List.class);
|
||||||
if (Objects.isNull(signatures)) {
|
if (Objects.isNull(signatures)) {
|
||||||
signatures = new ArrayList<>();
|
signatures = new ArrayList<>();
|
||||||
@ -220,16 +223,16 @@ public class CustomApproveTaskCmd extends AbstractCommand<Void> implements Seria
|
|||||||
.setActivityId(task.getTaskDefinitionKey())
|
.setActivityId(task.getTaskDefinitionKey())
|
||||||
.setActivityName(task.getName())
|
.setActivityName(task.getName())
|
||||||
.setSignatures(new ArrayList<>()));
|
.setSignatures(new ArrayList<>()));
|
||||||
ListUtils.emptyIfNull(attachmentList).stream()
|
|
||||||
.filter(i -> Objects.equals(i.getType(), AttachmentTypeEnum.signature))
|
dto.getSignatures().add(0, new SignatureDTO.SignDetail()
|
||||||
.findFirst()
|
.setApproverName(approver.getAssignerName())
|
||||||
.ifPresent(attachment -> dto.getSignatures().add(0,
|
.setSignature(ListUtils.emptyIfNull(attachmentList).stream()
|
||||||
new SignatureDTO.SignDetail()
|
.filter(i -> Objects.equals(i.getType(), AttachmentTypeEnum.signature))
|
||||||
.setApproverName(approver.getAssignerName())
|
.findFirst().orElse(new AttachmentDTO()).getUrl())
|
||||||
.setSignature(attachment.getUrl())
|
.setAdvice(advice)
|
||||||
.setAdvice(advice)
|
.setResult(BpmnProcessTaskResultEnum.APPROVED.getDesc())
|
||||||
.setResult(BpmnProcessTaskResultEnum.APPROVED.getDesc())
|
.setOperationTime(new Date())
|
||||||
.setOperationTime(new Date())));
|
);
|
||||||
if (!any.isPresent()) {
|
if (!any.isPresent()) {
|
||||||
signatures.add(dto);
|
signatures.add(dto);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -272,6 +272,7 @@ public class CustomGetProcessInstanceVariablesToObjectCmd extends AbstractComman
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void addSignature(List<VariableObjectDTO> variables, List<SignatureDTO> signatures) {
|
private void addSignature(List<VariableObjectDTO> variables, List<SignatureDTO> signatures) {
|
||||||
|
log.info("addSignature:{}", JSON.toJSONString(signatures));
|
||||||
if (CollectionUtils.isEmpty(signatures)) {
|
if (CollectionUtils.isEmpty(signatures)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -310,15 +311,10 @@ public class CustomGetProcessInstanceVariablesToObjectCmd extends AbstractComman
|
|||||||
groupVariables.forEach(group -> {
|
groupVariables.forEach(group -> {
|
||||||
if (!CollectionUtils.isEmpty(group.getVars())) {
|
if (!CollectionUtils.isEmpty(group.getVars())) {
|
||||||
group.getVars().forEach(variable -> {
|
group.getVars().forEach(variable -> {
|
||||||
Object value = bizVariables.getOrDefault(variable.getCode(), null);
|
|
||||||
if (Objects.isNull(value)) {
|
|
||||||
// 目前为了减少 wps 替换耗时,所以将没有值的变量,直接踢出
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
variables.add(VariableObjectDTO.builder()
|
variables.add(VariableObjectDTO.builder()
|
||||||
.key(variable.getCode())
|
.key(variable.getCode())
|
||||||
.desc(group.getGroupName() + variable.getName())
|
.desc(group.getGroupName() + variable.getName())
|
||||||
.value(value)
|
.value(bizVariables.getOrDefault(variable.getCode(), null))
|
||||||
.type(convert(variable.getType()))
|
.type(convert(variable.getType()))
|
||||||
.build());
|
.build());
|
||||||
});
|
});
|
||||||
|
|||||||
@ -84,4 +84,9 @@ public class ExtAxDict extends BaseEntity<ExtAxDict> {
|
|||||||
* 版本号
|
* 版本号
|
||||||
*/
|
*/
|
||||||
private Integer version;
|
private Integer version;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 自定替换未设置的变量为空串
|
||||||
|
*/
|
||||||
|
private Boolean autoReplaceVariables;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -119,6 +119,7 @@ public class CategoryServiceImpl extends ServiceImpl<ExtAxDictMapper, ExtAxDict>
|
|||||||
dict.setIcon(dto.getIcon());
|
dict.setIcon(dto.getIcon());
|
||||||
dict.setDisplayInitiateMenu(dto.getDisplayInitiateMenu());
|
dict.setDisplayInitiateMenu(dto.getDisplayInitiateMenu());
|
||||||
dict.setVersion(dto.getVersion());
|
dict.setVersion(dto.getVersion());
|
||||||
|
dict.setAutoReplaceVariables(Boolean.TRUE.equals(dto.getAutoReplaceVariables()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@ -22,6 +22,7 @@ import cn.hutool.core.date.DateUtil;
|
|||||||
import com.alibaba.fastjson.JSON;
|
import com.alibaba.fastjson.JSON;
|
||||||
import com.alibaba.fastjson.JSONException;
|
import com.alibaba.fastjson.JSONException;
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.flowable.common.engine.impl.interceptor.CommandExecutor;
|
import org.flowable.common.engine.impl.interceptor.CommandExecutor;
|
||||||
import org.flowable.engine.impl.cfg.ProcessEngineConfigurationImpl;
|
import org.flowable.engine.impl.cfg.ProcessEngineConfigurationImpl;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
@ -29,6 +30,8 @@ import org.springframework.util.CollectionUtils;
|
|||||||
import org.springframework.util.StringUtils;
|
import org.springframework.util.StringUtils;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collection;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
@ -51,6 +54,7 @@ import static cn.axzo.workflow.common.model.dto.VariableObjectDTO.Type.signature
|
|||||||
* @since 2025-04-09 20:41
|
* @since 2025-04-09 20:41
|
||||||
*/
|
*/
|
||||||
@Component
|
@Component
|
||||||
|
@Slf4j
|
||||||
public class WpsUtil {
|
public class WpsUtil {
|
||||||
public static final List<FileTypeEnum> WPS_SUPPORTED_FILE_TYPES = Lists.newArrayList(FileTypeEnum.WORD, FileTypeEnum.EXCEL);
|
public static final List<FileTypeEnum> WPS_SUPPORTED_FILE_TYPES = Lists.newArrayList(FileTypeEnum.WORD, FileTypeEnum.EXCEL);
|
||||||
@Resource
|
@Resource
|
||||||
@ -60,6 +64,67 @@ public class WpsUtil {
|
|||||||
@Resource
|
@Resource
|
||||||
private OrganizationalNodeUserQueryApi organizationalNodeUserQueryApi;
|
private OrganizationalNodeUserQueryApi organizationalNodeUserQueryApi;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 调用 wps 文件变量替换接口
|
||||||
|
*
|
||||||
|
* @param fileCode 基于该模板进行变量替换
|
||||||
|
* @param fileKey 如果有值,则变量替换完成后,直接将文档覆盖该 fileKey 对应的文件;
|
||||||
|
* @return 返回替换变量后的文件oss 的 fileKey
|
||||||
|
*/
|
||||||
|
public String wpsFileVariableReplace(List<VariableObjectDTO> wpsVariables,
|
||||||
|
String fileCode, String fileKey, String fileName, Boolean autoReplaceVariables) {
|
||||||
|
List<VariableObjectDTO> variables = wpsVariables.stream()
|
||||||
|
.filter(i -> Objects.equals(i.getType().name(), VariableObjectDTO.Type.img.name()) || Objects.equals(i.getType().name(), VariableObjectDTO.Type.text.name()))
|
||||||
|
.filter(i -> {
|
||||||
|
if (Objects.equals(Boolean.TRUE, autoReplaceVariables)) {
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return Objects.nonNull(i.getValue());
|
||||||
|
}
|
||||||
|
}).collect(Collectors.toList());
|
||||||
|
List<FileReplaceContent> fileReplaceContents = BeanMapper.copyList(variables, FileReplaceContent.class, (s, t) -> {
|
||||||
|
t.setKey(s.getDesc());
|
||||||
|
if (Objects.equals(s.getType().name(), VariableObjectDTO.Type.img.name())) {
|
||||||
|
List<UploadFieldDTO> uploadFieldDTOS = new ArrayList<>();
|
||||||
|
if (isJson(s.getValue().toString())) {
|
||||||
|
uploadFieldDTOS.addAll(JSON.parseArray(s.getValue().toString(), UploadFieldDTO.class));
|
||||||
|
} else {
|
||||||
|
uploadFieldDTOS.addAll(JSON.parseArray(JSON.toJSONString(s.getValue()), UploadFieldDTO.class));
|
||||||
|
}
|
||||||
|
t.setContent(CollectionUtils.isEmpty(uploadFieldDTOS) ? "" : uploadFieldDTOS.get(0).getFileUrl());
|
||||||
|
} else {
|
||||||
|
t.setContent(Objects.nonNull(s.getValue()) ? s.getValue().toString() : "");
|
||||||
|
}
|
||||||
|
t.setType(s.getType().name());
|
||||||
|
t.setPrefix("[");
|
||||||
|
t.setSuffix("]");
|
||||||
|
});
|
||||||
|
|
||||||
|
// 处理空值
|
||||||
|
if (Objects.equals(Boolean.TRUE, autoReplaceVariables)) {
|
||||||
|
fileReplaceContents.stream()
|
||||||
|
.filter(i -> !StringUtils.hasText(i.getContent()))
|
||||||
|
.forEach(i -> {
|
||||||
|
// TODO 将变量替换未空串
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (StringUtils.hasText(fileCode)) {
|
||||||
|
FileTemplateReplaceRequest request = new FileTemplateReplaceRequest();
|
||||||
|
request.setFileCode(fileCode);
|
||||||
|
request.setFileKey(fileKey);
|
||||||
|
request.setReplaceContentList(fileReplaceContents);
|
||||||
|
return RpcExternalUtil.rpcProcessor(() -> fileTemplateApi.replaceWordText(request), "替换 WPS 文档变量", request);
|
||||||
|
} else {
|
||||||
|
SimpleFileTemplateReplaceRequest request = new SimpleFileTemplateReplaceRequest();
|
||||||
|
request.setFileName(fileName);
|
||||||
|
request.setFileKey(fileKey);
|
||||||
|
request.setReplaceContentList(fileReplaceContents);
|
||||||
|
return RpcExternalUtil.rpcProcessor(() -> fileTemplateApi.replaceWordTextForFileKey(request), "替换 WPS 文档变量(simple)", request);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 调用 wps 文件变量替换接口
|
* 调用 wps 文件变量替换接口
|
||||||
*
|
*
|
||||||
@ -71,17 +136,19 @@ public class WpsUtil {
|
|||||||
String fileCode, String fileKey, String fileName) {
|
String fileCode, String fileKey, String fileName) {
|
||||||
|
|
||||||
List<FileReplaceContent> fileReplaceContents = BeanMapper.copyList(wpsVariables.stream()
|
List<FileReplaceContent> fileReplaceContents = BeanMapper.copyList(wpsVariables.stream()
|
||||||
.filter(i -> Objects.nonNull(i.getValue()))
|
.filter(i -> Objects.nonNull(i.getValue()) && checkNotEmptyColl(i))
|
||||||
.filter(i -> !(Objects.equals(i.getType().name(), "img") && !StringUtils.hasText(i.getValue().toString())))
|
.filter(i -> !(Objects.equals(i.getType().name(), "img") && !StringUtils.hasText(i.getValue().toString())))
|
||||||
.filter(i -> Objects.equals(i.getType().name(), "img") || Objects.equals(i.getType().name(), "text"))
|
.filter(i -> Objects.equals(i.getType().name(), "img") || Objects.equals(i.getType().name(), "text"))
|
||||||
.collect(Collectors.toList()), FileReplaceContent.class, (s, t) -> {
|
.collect(Collectors.toList()), FileReplaceContent.class, (s, t) -> {
|
||||||
t.setKey(s.getDesc());
|
t.setKey(s.getDesc());
|
||||||
if (Objects.equals(s.getType().name(), "img")) {
|
if (Objects.equals(s.getType().name(), "img")) {
|
||||||
|
List<UploadFieldDTO> uploadFieldDTOS;
|
||||||
if (isJson(s.getValue().toString())) {
|
if (isJson(s.getValue().toString())) {
|
||||||
t.setContent(JSON.parseArray(s.getValue().toString(), UploadFieldDTO.class).get(0).getFileUrl());
|
uploadFieldDTOS = JSON.parseArray(s.getValue().toString(), UploadFieldDTO.class);
|
||||||
} else {
|
} else {
|
||||||
t.setContent(JSON.parseArray(JSON.toJSONString(s.getValue()), UploadFieldDTO.class).get(0).getFileUrl());
|
uploadFieldDTOS = JSON.parseArray(JSON.toJSONString(s.getValue()), UploadFieldDTO.class);
|
||||||
}
|
}
|
||||||
|
t.setContent(CollectionUtils.isEmpty(uploadFieldDTOS) ? "" : uploadFieldDTOS.get(0).getFileUrl());
|
||||||
} else {
|
} else {
|
||||||
t.setContent(Objects.nonNull(s.getValue()) ? s.getValue().toString() : "");
|
t.setContent(Objects.nonNull(s.getValue()) ? s.getValue().toString() : "");
|
||||||
}
|
}
|
||||||
@ -104,6 +171,14 @@ public class WpsUtil {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static boolean checkNotEmptyColl(VariableObjectDTO i) {
|
||||||
|
if (!(i.getValue() instanceof Collection)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return !CollectionUtils.isEmpty((Collection<?>) i.getValue());
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public List<VariableObjectDTO> getWpsReplaceVariables(ProcessEngineConfigurationImpl processEngineConfiguration, String processInstanceId) {
|
public List<VariableObjectDTO> getWpsReplaceVariables(ProcessEngineConfigurationImpl processEngineConfiguration, String processInstanceId) {
|
||||||
CommandExecutor commandExecutor = processEngineConfiguration.getCommandExecutor();
|
CommandExecutor commandExecutor = processEngineConfiguration.getCommandExecutor();
|
||||||
List<VariableObjectDTO> wpsVariables =
|
List<VariableObjectDTO> wpsVariables =
|
||||||
@ -112,6 +187,7 @@ public class WpsUtil {
|
|||||||
List<VariableObjectDTO> signatureAndAdvices = Lists.newArrayList();
|
List<VariableObjectDTO> signatureAndAdvices = Lists.newArrayList();
|
||||||
wpsVariables.stream().filter(i -> Objects.equals(signatureAndAdvice, i.getType())).forEach(variableObjectDTO -> {
|
wpsVariables.stream().filter(i -> Objects.equals(signatureAndAdvice, i.getType())).forEach(variableObjectDTO -> {
|
||||||
List<SignatureDTO.SignDetail> signDetails = (List<SignatureDTO.SignDetail>) variableObjectDTO.getValue();
|
List<SignatureDTO.SignDetail> signDetails = (List<SignatureDTO.SignDetail>) variableObjectDTO.getValue();
|
||||||
|
log.info("getWpsReplaceVariables signDetails: {}", JSON.toJSONString(signDetails));
|
||||||
if (!CollectionUtils.isEmpty(signDetails)) {
|
if (!CollectionUtils.isEmpty(signDetails)) {
|
||||||
SignatureDTO.SignDetail signDetail = signDetails.get(0);
|
SignatureDTO.SignDetail signDetail = signDetails.get(0);
|
||||||
signatureAndAdvices.add(VariableObjectDTO.builder()
|
signatureAndAdvices.add(VariableObjectDTO.builder()
|
||||||
@ -132,7 +208,7 @@ public class WpsUtil {
|
|||||||
signatureAndAdvices.add(VariableObjectDTO.builder()
|
signatureAndAdvices.add(VariableObjectDTO.builder()
|
||||||
.key(variableObjectDTO.getKey() + "_signature")
|
.key(variableObjectDTO.getKey() + "_signature")
|
||||||
.desc(variableObjectDTO.getDesc() + "电子签名")
|
.desc(variableObjectDTO.getDesc() + "电子签名")
|
||||||
.value(Lists.newArrayList(UploadFieldDTO.builder().fileKey(signDetail.getSignature()).fileUrl(signUrl.get(0).getSignUrl()).build()))
|
.value(CollectionUtils.isEmpty(signUrl) ? Lists.newArrayList() : Lists.newArrayList(UploadFieldDTO.builder().fileKey(signDetail.getSignature()).fileUrl(CollectionUtils.isEmpty(signUrl) ? null : signUrl.get(0).getSignUrl()).build()))
|
||||||
.type(VariableObjectDTO.Type.img)
|
.type(VariableObjectDTO.Type.img)
|
||||||
.build());
|
.build());
|
||||||
signatureAndAdvices.add(VariableObjectDTO.builder()
|
signatureAndAdvices.add(VariableObjectDTO.builder()
|
||||||
@ -171,6 +247,7 @@ public class WpsUtil {
|
|||||||
.build());
|
.build());
|
||||||
|
|
||||||
});
|
});
|
||||||
|
log.info("wpsVariables: {}", JSON.toJSONString(wpsVariables));
|
||||||
return wpsVariables;
|
return wpsVariables;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -81,7 +81,7 @@ public class BasedIdentityV2TaskAssigneeSelector extends AbstractBpmnTaskAssigne
|
|||||||
.initiatorPersonId(initiator.parsePersonId())
|
.initiatorPersonId(initiator.parsePersonId())
|
||||||
.areaCodes(getAreaFilterEnable(flowElement) ? Sets.newHashSet(ListUtils.emptyIfNull(orgDTO.getIncludeAreaCodes())) : Sets.newHashSet())
|
.areaCodes(getAreaFilterEnable(flowElement) ? Sets.newHashSet(ListUtils.emptyIfNull(orgDTO.getIncludeAreaCodes())) : Sets.newHashSet())
|
||||||
.specialtyCodes(getSpecialtyFilterEnable(flowElement) ? Sets.newHashSet(ListUtils.emptyIfNull(orgDTO.getIncludeSpecialtyCodes())) : Sets.newHashSet())
|
.specialtyCodes(getSpecialtyFilterEnable(flowElement) ? Sets.newHashSet(ListUtils.emptyIfNull(orgDTO.getIncludeSpecialtyCodes())) : Sets.newHashSet())
|
||||||
.projectIds(getOnlyInProjectEnable(flowElement) ? Sets.newHashSet(orgDTO.getProjectIds()) : Sets.newHashSet())
|
.projectIds(getOnlyInProjectEnable(flowElement) ? Sets.newHashSet(ListUtils.emptyIfNull(orgDTO.getProjectIds())) : Sets.newHashSet())
|
||||||
.querySupervisorWhileMissMatched(getApproverEmptyHandleType(flowElement).filter(type -> Objects.equals(type, transferToAdmin)).isPresent());
|
.querySupervisorWhileMissMatched(getApproverEmptyHandleType(flowElement).filter(type -> Objects.equals(type, transferToAdmin)).isPresent());
|
||||||
switch (optRange.get()) {
|
switch (optRange.get()) {
|
||||||
case within_the_project:
|
case within_the_project:
|
||||||
|
|||||||
@ -74,7 +74,7 @@ public class BasedInitiatorLeaderV2TaskAssigneeSelector extends AbstractBpmnTask
|
|||||||
.initiatorPersonId(initiator.parsePersonId())
|
.initiatorPersonId(initiator.parsePersonId())
|
||||||
.areaCodes(getAreaFilterEnable(flowElement) ? Sets.newHashSet(ListUtils.emptyIfNull(orgDTO.getIncludeAreaCodes())) : Sets.newHashSet())
|
.areaCodes(getAreaFilterEnable(flowElement) ? Sets.newHashSet(ListUtils.emptyIfNull(orgDTO.getIncludeAreaCodes())) : Sets.newHashSet())
|
||||||
.specialtyCodes(getSpecialtyFilterEnable(flowElement) ? Sets.newHashSet(ListUtils.emptyIfNull(orgDTO.getIncludeSpecialtyCodes())) : Sets.newHashSet())
|
.specialtyCodes(getSpecialtyFilterEnable(flowElement) ? Sets.newHashSet(ListUtils.emptyIfNull(orgDTO.getIncludeSpecialtyCodes())) : Sets.newHashSet())
|
||||||
.projectIds(getOnlyInProjectEnable(flowElement) ? Sets.newHashSet(orgDTO.getProjectIds()) : Sets.newHashSet())
|
.projectIds(getOnlyInProjectEnable(flowElement) ? Sets.newHashSet(ListUtils.emptyIfNull(orgDTO.getProjectIds())) : Sets.newHashSet())
|
||||||
.querySupervisorWhileMissMatched(getApproverEmptyHandleType(flowElement).filter(type -> Objects.equals(type, transferToAdmin)).isPresent());
|
.querySupervisorWhileMissMatched(getApproverEmptyHandleType(flowElement).filter(type -> Objects.equals(type, transferToAdmin)).isPresent());
|
||||||
|
|
||||||
FlowTaskAssignerV2Req request = v2ReqBuilder.build();
|
FlowTaskAssignerV2Req request = v2ReqBuilder.build();
|
||||||
|
|||||||
@ -85,7 +85,7 @@ public class BasedPositionV2TaskAssigneeSelector extends AbstractBpmnTaskAssigne
|
|||||||
.initiatorPersonId(initiator.parsePersonId())
|
.initiatorPersonId(initiator.parsePersonId())
|
||||||
.areaCodes(getAreaFilterEnable(flowElement) ? Sets.newHashSet(ListUtils.emptyIfNull(orgDTO.getIncludeAreaCodes())) : Sets.newHashSet())
|
.areaCodes(getAreaFilterEnable(flowElement) ? Sets.newHashSet(ListUtils.emptyIfNull(orgDTO.getIncludeAreaCodes())) : Sets.newHashSet())
|
||||||
.specialtyCodes(getSpecialtyFilterEnable(flowElement) ? Sets.newHashSet(ListUtils.emptyIfNull(orgDTO.getIncludeSpecialtyCodes())) : Sets.newHashSet())
|
.specialtyCodes(getSpecialtyFilterEnable(flowElement) ? Sets.newHashSet(ListUtils.emptyIfNull(orgDTO.getIncludeSpecialtyCodes())) : Sets.newHashSet())
|
||||||
.projectIds(getOnlyInProjectEnable(flowElement) ? Sets.newHashSet(orgDTO.getProjectIds()) : Sets.newHashSet())
|
.projectIds(getOnlyInProjectEnable(flowElement) ? Sets.newHashSet(ListUtils.emptyIfNull(orgDTO.getProjectIds())) : Sets.newHashSet())
|
||||||
.querySupervisorWhileMissMatched(getApproverEmptyHandleType(flowElement).filter(type -> Objects.equals(type, transferToAdmin)).isPresent());
|
.querySupervisorWhileMissMatched(getApproverEmptyHandleType(flowElement).filter(type -> Objects.equals(type, transferToAdmin)).isPresent());
|
||||||
switch (optRange.get()) {
|
switch (optRange.get()) {
|
||||||
case within_the_project:
|
case within_the_project:
|
||||||
|
|||||||
@ -87,7 +87,7 @@ public class BasedRoleV2TaskAssigneeSelector extends AbstractBpmnTaskAssigneeSel
|
|||||||
.initiatorPersonId(initiator.parsePersonId())
|
.initiatorPersonId(initiator.parsePersonId())
|
||||||
.areaCodes(getAreaFilterEnable(flowElement) ? Sets.newHashSet(ListUtils.emptyIfNull(orgDTO.getIncludeAreaCodes())) : Sets.newHashSet())
|
.areaCodes(getAreaFilterEnable(flowElement) ? Sets.newHashSet(ListUtils.emptyIfNull(orgDTO.getIncludeAreaCodes())) : Sets.newHashSet())
|
||||||
.specialtyCodes(getSpecialtyFilterEnable(flowElement) ? Sets.newHashSet(ListUtils.emptyIfNull(orgDTO.getIncludeSpecialtyCodes())) : Sets.newHashSet())
|
.specialtyCodes(getSpecialtyFilterEnable(flowElement) ? Sets.newHashSet(ListUtils.emptyIfNull(orgDTO.getIncludeSpecialtyCodes())) : Sets.newHashSet())
|
||||||
.projectIds(getOnlyInProjectEnable(flowElement) ? Sets.newHashSet(orgDTO.getProjectIds()) : Sets.newHashSet())
|
.projectIds(getOnlyInProjectEnable(flowElement) ? Sets.newHashSet(ListUtils.emptyIfNull(orgDTO.getProjectIds())) : Sets.newHashSet())
|
||||||
.querySupervisorWhileMissMatched(getApproverEmptyHandleType(flowElement).filter(type -> Objects.equals(type, transferToAdmin)).isPresent());
|
.querySupervisorWhileMissMatched(getApproverEmptyHandleType(flowElement).filter(type -> Objects.equals(type, transferToAdmin)).isPresent());
|
||||||
switch (optRange.get()) {
|
switch (optRange.get()) {
|
||||||
case within_the_project:
|
case within_the_project:
|
||||||
|
|||||||
@ -4,12 +4,14 @@ import cn.axzo.workflow.common.enums.FileTypeEnum;
|
|||||||
import cn.axzo.workflow.common.model.dto.SignFileDTO;
|
import cn.axzo.workflow.common.model.dto.SignFileDTO;
|
||||||
import cn.axzo.workflow.common.model.dto.VariableObjectDTO;
|
import cn.axzo.workflow.common.model.dto.VariableObjectDTO;
|
||||||
import cn.axzo.workflow.common.model.request.bpmn.BpmnSignConf;
|
import cn.axzo.workflow.common.model.request.bpmn.BpmnSignConf;
|
||||||
|
import cn.axzo.workflow.common.model.response.category.CategoryItemVO;
|
||||||
import cn.axzo.workflow.core.common.context.ProcessOperationContext;
|
import cn.axzo.workflow.core.common.context.ProcessOperationContext;
|
||||||
import cn.axzo.workflow.core.common.utils.BpmnMetaParserHelper;
|
import cn.axzo.workflow.core.common.utils.BpmnMetaParserHelper;
|
||||||
import cn.axzo.workflow.core.listener.AbstractBpmnEventListener;
|
import cn.axzo.workflow.core.listener.AbstractBpmnEventListener;
|
||||||
import cn.axzo.workflow.core.listener.BpmnProcessEventListener;
|
import cn.axzo.workflow.core.listener.BpmnProcessEventListener;
|
||||||
import cn.axzo.workflow.core.repository.entity.ExtAxDocContent;
|
import cn.axzo.workflow.core.repository.entity.ExtAxDocContent;
|
||||||
import cn.axzo.workflow.core.repository.entity.ExtAxProcessSign;
|
import cn.axzo.workflow.core.repository.entity.ExtAxProcessSign;
|
||||||
|
import cn.axzo.workflow.core.service.CategoryService;
|
||||||
import cn.axzo.workflow.core.service.ExtAxDocContentService;
|
import cn.axzo.workflow.core.service.ExtAxDocContentService;
|
||||||
import cn.axzo.workflow.core.service.ExtAxModelDocService;
|
import cn.axzo.workflow.core.service.ExtAxModelDocService;
|
||||||
import cn.axzo.workflow.core.service.ExtAxProcessSignService;
|
import cn.axzo.workflow.core.service.ExtAxProcessSignService;
|
||||||
@ -35,6 +37,8 @@ import java.util.Objects;
|
|||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
import static cn.axzo.workflow.common.constant.BpmnConstants.BPM_MODEL_CATEGORY;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 签署业务,审批完成后,进行文件归档,并对所有工人发送业务待办
|
* 签署业务,审批完成后,进行文件归档,并对所有工人发送业务待办
|
||||||
*
|
*
|
||||||
@ -55,6 +59,8 @@ public class FileArchiveProcessEventListener extends AbstractBpmnEventListener<P
|
|||||||
@Resource
|
@Resource
|
||||||
private ExtAxDocContentService extAxDocContentService;
|
private ExtAxDocContentService extAxDocContentService;
|
||||||
@Resource
|
@Resource
|
||||||
|
private CategoryService categoryService;
|
||||||
|
@Resource
|
||||||
private WpsUtil wpsUtil;
|
private WpsUtil wpsUtil;
|
||||||
|
|
||||||
|
|
||||||
@ -71,19 +77,21 @@ public class FileArchiveProcessEventListener extends AbstractBpmnEventListener<P
|
|||||||
HistoricProcessInstance instance = historyService.createHistoricProcessInstanceQuery()
|
HistoricProcessInstance instance = historyService.createHistoricProcessInstanceQuery()
|
||||||
.processInstanceId(processInstanceId).includeProcessVariables().singleResult();
|
.processInstanceId(processInstanceId).includeProcessVariables().singleResult();
|
||||||
|
|
||||||
|
CategoryItemVO category = categoryService.get(BPM_MODEL_CATEGORY, mainProcess.getId()).orElse(new CategoryItemVO());
|
||||||
// 文件归档,将审批过程中产生的数据全部替换文档模板变量
|
// 文件归档,将审批过程中产生的数据全部替换文档模板变量
|
||||||
archiveFinalDocs(instance);
|
archiveFinalDocs(instance, category.getAutoReplaceVariables());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void archiveFinalDocs(HistoricProcessInstance instance) {
|
private void archiveFinalDocs(HistoricProcessInstance instance, Boolean autoReplaceVariables) {
|
||||||
ProcessEngineConfigurationImpl processEngineConfiguration = (ProcessEngineConfigurationImpl) getEngineConfiguration();
|
ProcessEngineConfigurationImpl processEngineConfiguration = (ProcessEngineConfigurationImpl) getEngineConfiguration();
|
||||||
ExtAxProcessSign processSign = extAxProcessSignService.findByProcessInstanceId(instance.getId());
|
ExtAxProcessSign processSign = extAxProcessSignService.findByProcessInstanceId(instance.getId());
|
||||||
List<VariableObjectDTO> wpsReplaceVariables = wpsUtil.getWpsReplaceVariables(processEngineConfiguration, instance.getId());
|
List<VariableObjectDTO> wpsReplaceVariables = wpsUtil.getWpsReplaceVariables(processEngineConfiguration, instance.getId());
|
||||||
|
|
||||||
processSign.getFileArchive().stream().filter(i -> Objects.equals(i.getFileType(), FileTypeEnum.WORD)
|
processSign.getFileArchive().stream().filter(i -> Objects.equals(i.getFileType(), FileTypeEnum.WORD)
|
||||||
|| Objects.equals(i.getFileType(), FileTypeEnum.EXCEL))
|
|| Objects.equals(i.getFileType(), FileTypeEnum.EXCEL))
|
||||||
.filter(i -> Boolean.TRUE.equals(i.getNeedReplaceVariables()))
|
.filter(i -> Boolean.TRUE.equals(i.getNeedReplaceVariables()))
|
||||||
.forEach(docBaseVO -> {
|
.forEach(docBaseVO -> {
|
||||||
String newFileKey = wpsUtil.wpsFileVariableReplace(wpsReplaceVariables, null, docBaseVO.getFileKey(), docBaseVO.getTemplateName() + docBaseVO.getFileType().getSuffix());
|
String newFileKey = wpsUtil.wpsFileVariableReplace(wpsReplaceVariables, null, docBaseVO.getFileKey(), docBaseVO.getTemplateName() + docBaseVO.getFileType().getSuffix(), autoReplaceVariables);
|
||||||
docBaseVO.setFileKey(newFileKey);
|
docBaseVO.setFileKey(newFileKey);
|
||||||
});
|
});
|
||||||
// 删除非 WPS 的临时文档
|
// 删除非 WPS 的临时文档
|
||||||
@ -116,6 +124,6 @@ public class FileArchiveProcessEventListener extends AbstractBpmnEventListener<P
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getOrder() {
|
public int getOrder() {
|
||||||
return Integer.MIN_VALUE + 3;
|
return Integer.MIN_VALUE + 99;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -168,6 +168,7 @@ public class FirstCopyTemplateFileTaskEvent_105_Listener extends AbstractBpmnEve
|
|||||||
signFileDTO.setFileTag(template.getFileTag());
|
signFileDTO.setFileTag(template.getFileTag());
|
||||||
signFileDTO.setFileType(template.getFileType());
|
signFileDTO.setFileType(template.getFileType());
|
||||||
signFileDTO.setFileCode(template.getFileCode());
|
signFileDTO.setFileCode(template.getFileCode());
|
||||||
|
signFileDTO.setNeedReplaceVariables(template.getNeedReplaceVariables());
|
||||||
if (Objects.equals(template.getFileType(), FileTypeEnum.WORD) || Objects.equals(template.getFileType(), FileTypeEnum.EXCEL)) {
|
if (Objects.equals(template.getFileType(), FileTypeEnum.WORD) || Objects.equals(template.getFileType(), FileTypeEnum.EXCEL)) {
|
||||||
String fileKey = wpsUtil.wpsFileVariableReplace(wpsReplaceVariables, template.getFileCode(), template.getFileKey(), template.getTemplateName() + template.getFileType().getSuffix());
|
String fileKey = wpsUtil.wpsFileVariableReplace(wpsReplaceVariables, template.getFileCode(), template.getFileKey(), template.getTemplateName() + template.getFileType().getSuffix());
|
||||||
signFileDTO.setFileKey(fileKey);
|
signFileDTO.setFileKey(fileKey);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user