Merge branch 'feature/REQ-5965' into test
This commit is contained in:
commit
191b137add
@ -118,6 +118,8 @@ public interface BpmnConstants {
|
||||
String CONFIG_FIELD_META = "field";
|
||||
String CONFIG_FIELD_PERMISSION = "fieldPermission";
|
||||
String CONFIG_CONDITION_PERMISSION = "conditionPermission";
|
||||
String CONFIG_FIELD_OPTIONS = "options";
|
||||
@Deprecated
|
||||
String CONFIG_FIELD_OPTION = "option";
|
||||
String CONFIG_NODE_TYPE = "nodeType";
|
||||
String CONFIG_BUTTON_TYPE_INITIATOR = "initiator";
|
||||
|
||||
@ -27,7 +27,7 @@ public class BpmnFieldOptionConf implements Serializable {
|
||||
* 选项的值
|
||||
*/
|
||||
@ApiModelProperty(value = "选项的值", example = "1")
|
||||
private String value;
|
||||
private Object value;
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
@ -37,11 +37,11 @@ public class BpmnFieldOptionConf implements Serializable {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
public Object getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public void setValue(String value) {
|
||||
public void setValue(Object value) {
|
||||
this.value = value;
|
||||
}
|
||||
}
|
||||
|
||||
@ -93,4 +93,10 @@ public class CategoryCreateDTO {
|
||||
@ApiModelProperty(value = "版本号")
|
||||
private Integer version;
|
||||
|
||||
/**
|
||||
* 自定替换未设置的变量为空串
|
||||
*/
|
||||
@ApiModelProperty(value = "是否自动替换变量为空串,默认false")
|
||||
private Boolean autoReplaceVariables;
|
||||
|
||||
}
|
||||
|
||||
@ -47,6 +47,9 @@ public class CategoryItemVO {
|
||||
@ApiModelProperty(value = "版本号")
|
||||
private Integer version;
|
||||
|
||||
@ApiModelProperty(value = "自定替换未设置的变量为空串")
|
||||
private Boolean autoReplaceVariables;
|
||||
|
||||
@ApiModelProperty(value = "更新时间")
|
||||
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_FIELD;
|
||||
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_SIGN;
|
||||
import static cn.axzo.workflow.common.constant.BpmnConstants.CONFIG_SIGN_TYPE;
|
||||
@ -346,22 +346,10 @@ public final class BpmnJsonConverterUtil {
|
||||
field.addAttribute(fieldCode);
|
||||
|
||||
if (!CollectionUtils.isEmpty(i.getOptions())) {
|
||||
i.getOptions().forEach(j -> {
|
||||
ExtensionElement option = new ExtensionElement();
|
||||
option.setName(CONFIG_FIELD_OPTION);
|
||||
|
||||
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);
|
||||
});
|
||||
ExtensionAttribute fieldOptions = new ExtensionAttribute();
|
||||
fieldCode.setName(CONFIG_FIELD_OPTIONS);
|
||||
fieldCode.setValue(JSON.toJSONString(i.getOptions()));
|
||||
field.addAttribute(fieldOptions);
|
||||
}
|
||||
fieldConfigElement.addChildElement(field);
|
||||
});
|
||||
|
||||
@ -87,6 +87,7 @@ import static cn.axzo.workflow.common.constant.BpmnConstants.CONFIG_CONDITION_PE
|
||||
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_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_INITIATOR_LEADER_RANGE_UNIT;
|
||||
import static cn.axzo.workflow.common.constant.BpmnConstants.CONFIG_INITIATOR_SPECIFIED_EXCLUDE_COOPERATE_TYPES;
|
||||
@ -433,15 +434,20 @@ public final class BpmnMetaParserHelper {
|
||||
conf.setName(i.getAttributeValue(null, ELEMENT_ATTRIBUTE_NAME));
|
||||
conf.setCode(i.getAttributeValue(null, ELEMENT_ATTRIBUTE_CODE));
|
||||
|
||||
List<BpmnFieldOptionConf> options = new ArrayList<>();
|
||||
if (!CollectionUtils.isEmpty(i.getChildElements())) {
|
||||
i.getChildElements().get(CONFIG_FIELD_OPTION).forEach(j -> {
|
||||
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);
|
||||
String fieldOptionsJsonStr = i.getAttributeValue(null, CONFIG_FIELD_OPTIONS);
|
||||
if (StringUtils.hasText(fieldOptionsJsonStr)) {
|
||||
conf.setOptions(JSON.parseArray(fieldOptionsJsonStr, BpmnFieldOptionConf.class));
|
||||
} else {
|
||||
List<BpmnFieldOptionConf> options = new ArrayList<>();
|
||||
if (!CollectionUtils.isEmpty(i.getChildElements())) {
|
||||
i.getChildElements().get(CONFIG_FIELD_OPTION).forEach(j -> {
|
||||
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);
|
||||
@ -703,6 +709,7 @@ public final class BpmnMetaParserHelper {
|
||||
return defaultValid(flowElement, CONFIG_CONDITION_PERMISSION).map(element -> JSON.parseObject(element.getElementText(), new TypeReference<List<ConditionPermissionMetaInfo>>() {
|
||||
}.getType()));
|
||||
}
|
||||
|
||||
public static Optional<ImmutableTable<String, String, Integer>> getFormFieldPermissionForCalc(FlowElement flowElement) {
|
||||
List<FormPermissionMetaInfo> fieldMetaInfos = getFormFieldPermissionConf(flowElement).orElse(new ArrayList<>());
|
||||
return getFormFieldPermissionForModel(fieldMetaInfos);
|
||||
|
||||
@ -311,15 +311,10 @@ public class CustomGetProcessInstanceVariablesToObjectCmd extends AbstractComman
|
||||
groupVariables.forEach(group -> {
|
||||
if (!CollectionUtils.isEmpty(group.getVars())) {
|
||||
group.getVars().forEach(variable -> {
|
||||
Object value = bizVariables.getOrDefault(variable.getCode(), null);
|
||||
if (Objects.isNull(value)) {
|
||||
// 目前为了减少 wps 替换耗时,所以将没有值的变量,直接踢出
|
||||
return;
|
||||
}
|
||||
variables.add(VariableObjectDTO.builder()
|
||||
.key(variable.getCode())
|
||||
.desc(group.getGroupName() + variable.getName())
|
||||
.value(value)
|
||||
.value(bizVariables.getOrDefault(variable.getCode(), null))
|
||||
.type(convert(variable.getType()))
|
||||
.build());
|
||||
});
|
||||
|
||||
@ -84,4 +84,9 @@ public class ExtAxDict extends BaseEntity<ExtAxDict> {
|
||||
* 版本号
|
||||
*/
|
||||
private Integer version;
|
||||
|
||||
/**
|
||||
* 自定替换未设置的变量为空串
|
||||
*/
|
||||
private Boolean autoReplaceVariables;
|
||||
}
|
||||
|
||||
@ -119,6 +119,7 @@ public class CategoryServiceImpl extends ServiceImpl<ExtAxDictMapper, ExtAxDict>
|
||||
dict.setIcon(dto.getIcon());
|
||||
dict.setDisplayInitiateMenu(dto.getDisplayInitiateMenu());
|
||||
dict.setVersion(dto.getVersion());
|
||||
dict.setAutoReplaceVariables(Boolean.TRUE.equals(dto.getAutoReplaceVariables()));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -30,6 +30,7 @@ import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
@ -63,167 +64,34 @@ public class WpsUtil {
|
||||
@Resource
|
||||
private OrganizationalNodeUserQueryApi organizationalNodeUserQueryApi;
|
||||
|
||||
public static void main(String[] args) {
|
||||
String jsonStr = "[{\"desc\":\"审批编号\",\"key\":\"processInstanceId\",\"type\":\"text\",\"value\":\"202512200123200000000\"},{\"desc\":\"发起时间\",\"key\":\"startTime\",\"type\":\"text\",\"value\":\"2025.12.20 01:23:56\"},{\"desc\":\"审批结束时间\",\"key\":\"endTime\",\"type\":\"text\"},{\"desc\":\"业务名称\",\"key\":\"processDefinitionKey\",\"type\":\"text\",\"value\":\"安全教育签字(anquanjiaoyu)\"},{\"desc\":\"业务变量主讲人单位\",\"key\":\"speakerUnit\",\"type\":\"text\",\"value\":\"四川星腾贸易有限公司\"},{\"desc\":\"业务变量主讲人部门\",\"key\":\"speakerNode\",\"type\":\"text\",\"value\":\"四川星腾贸易有限公司\"},{\"desc\":\"业务变量项目名称\",\"key\":\"workspaceName\",\"type\":\"text\",\"value\":\"test-0925项目服务部\"},{\"desc\":\"业务变量签署发起时间\",\"key\":\"signingInitiationTime\",\"type\":\"text\",\"value\":\"20251219\"},{\"desc\":\"业务变量主讲人姓名\",\"key\":\"speakerName\",\"type\":\"text\",\"value\":\"罗福\"},{\"desc\":\"发起者\",\"key\":\"initiator\",\"type\":\"obj\",\"value\":\"{\\\"assignerName\\\":\\\"罗福\\\",\\\"avatar\\\":\\\"https://axzo-app.oss-cn-chengdu.aliyuncs.com/face/8c29d036-5db3-431d-b537-9d6d5c8019da.jpg\\\",\\\"nodeId\\\":\\\"7399\\\",\\\"ouId\\\":\\\"6158\\\",\\\"personId\\\":\\\"9000399522\\\",\\\"tenantId\\\":\\\"399\\\"}\"},{\"desc\":\"主讲人审批\",\"key\":\"node_330665593249_axv0\",\"type\":\"signatureAndAdvice\",\"value\":[{\"advice\":\"123\",\"approverName\":\"罗福\",\"operationTime\":1766165056926,\"result\":\"已同意\"}]},{\"desc\":\"教育日期\",\"key\":\"educationDate\",\"type\":\"text\",\"value\":\"2025-12-02\"},{\"desc\":\"教育时长\",\"key\":\"educationDuration\",\"type\":\"text\",\"value\":\"11小时\"},{\"desc\":\"图片\",\"key\":\"picture\",\"type\":\"img\",\"value\":\"[{\\\"fileName\\\":\\\"1738899982734-97oknewbe77.png\\\",\\\"fileUrl\\\":\\\"https://axzo-public.oss-cn-chengdu.aliyuncs.com/cms/cms_test/4c7875246b9049188a055fb1c80effa4.png\\\",\\\"fileKey\\\":\\\"4c7875246b9049188a055fb1c80effa4\\\"}]\"},{\"desc\":\"签字工人\",\"key\":\"worker\",\"type\":\"text\",\"value\":\"母春田\"},{\"desc\":\"主讲人审批姓名\",\"key\":\"node_330665593249_axv0_approverName\",\"type\":\"text\",\"value\":\"罗福\"},{\"desc\":\"主讲人审批审批结果\",\"key\":\"node_330665593249_axv0_activityResult\",\"type\":\"text\",\"value\":\"已同意\"},{\"desc\":\"主讲人审批电子签名\",\"key\":\"node_330665593249_axv0_signature\",\"type\":\"img\",\"value\":[{}]},{\"desc\":\"主讲人审批审批意见\",\"key\":\"node_330665593249_axv0_advice\",\"type\":\"text\",\"value\":\"123\"},{\"desc\":\"主讲人审批日期\",\"key\":\"node_330665593249_axv0_activityOperationTime\",\"type\":\"text\",\"value\":\"2025.12.20\"},{\"desc\":\"发起人姓名\",\"key\":\"initiatorName\",\"type\":\"text\",\"value\":\"罗福\"},{\"desc\":\"发起人岗位\",\"key\":\"initiatorPosition\",\"type\":\"text\",\"value\":\"测试岗位003\"},{\"desc\":\"发起人联系方式\",\"key\":\"initiatorPhone\",\"type\":\"text\",\"value\":\"18080995942\"}]";
|
||||
String jsonStr2 = "[\n" +
|
||||
" {\n" +
|
||||
" \"desc\": \"审批编号\",\n" +
|
||||
" \"key\": \"processInstanceId\",\n" +
|
||||
" \"type\": \"text\",\n" +
|
||||
" \"value\": \"202512200123200000000\"\n" +
|
||||
" },\n" +
|
||||
" {\n" +
|
||||
" \"desc\": \"发起时间\",\n" +
|
||||
" \"key\": \"startTime\",\n" +
|
||||
" \"type\": \"text\",\n" +
|
||||
" \"value\": \"2025.12.20 01:23:56\"\n" +
|
||||
" },\n" +
|
||||
" {\n" +
|
||||
" \"desc\": \"审批结束时间\",\n" +
|
||||
" \"key\": \"endTime\",\n" +
|
||||
" \"type\": \"text\"\n" +
|
||||
" },\n" +
|
||||
" {\n" +
|
||||
" \"desc\": \"业务名称\",\n" +
|
||||
" \"key\": \"processDefinitionKey\",\n" +
|
||||
" \"type\": \"text\",\n" +
|
||||
" \"value\": \"安全教育签字(anquanjiaoyu)\"\n" +
|
||||
" },\n" +
|
||||
" {\n" +
|
||||
" \"desc\": \"业务变量主讲人单位\",\n" +
|
||||
" \"key\": \"speakerUnit\",\n" +
|
||||
" \"type\": \"text\",\n" +
|
||||
" \"value\": \"四川星腾贸易有限公司\"\n" +
|
||||
" },\n" +
|
||||
" {\n" +
|
||||
" \"desc\": \"业务变量主讲人部门\",\n" +
|
||||
" \"key\": \"speakerNode\",\n" +
|
||||
" \"type\": \"text\",\n" +
|
||||
" \"value\": \"四川星腾贸易有限公司\"\n" +
|
||||
" },\n" +
|
||||
" {\n" +
|
||||
" \"desc\": \"业务变量项目名称\",\n" +
|
||||
" \"key\": \"workspaceName\",\n" +
|
||||
" \"type\": \"text\",\n" +
|
||||
" \"value\": \"test-0925项目服务部\"\n" +
|
||||
" },\n" +
|
||||
" {\n" +
|
||||
" \"desc\": \"业务变量签署发起时间\",\n" +
|
||||
" \"key\": \"signingInitiationTime\",\n" +
|
||||
" \"type\": \"text\",\n" +
|
||||
" \"value\": \"20251219\"\n" +
|
||||
" },\n" +
|
||||
" {\n" +
|
||||
" \"desc\": \"业务变量主讲人姓名\",\n" +
|
||||
" \"key\": \"speakerName\",\n" +
|
||||
" \"type\": \"text\",\n" +
|
||||
" \"value\": \"罗福\"\n" +
|
||||
" },\n" +
|
||||
" {\n" +
|
||||
" \"desc\": \"发起者\",\n" +
|
||||
" \"key\": \"initiator\",\n" +
|
||||
" \"type\": \"obj\",\n" +
|
||||
" \"value\": \"{\\\"assignerName\\\":\\\"罗福\\\",\\\"avatar\\\":\\\"https://axzo-app.oss-cn-chengdu.aliyuncs.com/face/8c29d036-5db3-431d-b537-9d6d5c8019da.jpg\\\",\\\"nodeId\\\":\\\"7399\\\",\\\"ouId\\\":\\\"6158\\\",\\\"personId\\\":\\\"9000399522\\\",\\\"tenantId\\\":\\\"399\\\"}\"\n" +
|
||||
" },\n" +
|
||||
" {\n" +
|
||||
" \"desc\": \"主讲人审批\",\n" +
|
||||
" \"key\": \"node_330665593249_axv0\",\n" +
|
||||
" \"type\": \"signatureAndAdvice\",\n" +
|
||||
" \"value\": [\n" +
|
||||
" {\n" +
|
||||
" \"advice\": \"123\",\n" +
|
||||
" \"approverName\": \"罗福\",\n" +
|
||||
" \"operationTime\": 1766165056926,\n" +
|
||||
" \"result\": \"已同意\"\n" +
|
||||
" }\n" +
|
||||
" ]\n" +
|
||||
" },\n" +
|
||||
" {\n" +
|
||||
" \"desc\": \"教育日期\",\n" +
|
||||
" \"key\": \"educationDate\",\n" +
|
||||
" \"type\": \"text\",\n" +
|
||||
" \"value\": \"2025-12-02\"\n" +
|
||||
" },\n" +
|
||||
" {\n" +
|
||||
" \"desc\": \"教育时长\",\n" +
|
||||
" \"key\": \"educationDuration\",\n" +
|
||||
" \"type\": \"text\",\n" +
|
||||
" \"value\": \"11小时\"\n" +
|
||||
" },\n" +
|
||||
" {\n" +
|
||||
" \"desc\": \"图片\",\n" +
|
||||
" \"key\": \"picture\",\n" +
|
||||
" \"type\": \"img\",\n" +
|
||||
" \"value\": \"[{\\\"fileName\\\":\\\"1738899982734-97oknewbe77.png\\\",\\\"fileUrl\\\":\\\"https://axzo-public.oss-cn-chengdu.aliyuncs.com/cms/cms_test/4c7875246b9049188a055fb1c80effa4.png\\\",\\\"fileKey\\\":\\\"4c7875246b9049188a055fb1c80effa4\\\"}]\"\n" +
|
||||
" },\n" +
|
||||
" {\n" +
|
||||
" \"desc\": \"签字工人\",\n" +
|
||||
" \"key\": \"worker\",\n" +
|
||||
" \"type\": \"text\",\n" +
|
||||
" \"value\": \"母春田\"\n" +
|
||||
" },\n" +
|
||||
" {\n" +
|
||||
" \"desc\": \"主讲人审批姓名\",\n" +
|
||||
" \"key\": \"node_330665593249_axv0_approverName\",\n" +
|
||||
" \"type\": \"text\",\n" +
|
||||
" \"value\": \"罗福\"\n" +
|
||||
" },\n" +
|
||||
" {\n" +
|
||||
" \"desc\": \"主讲人审批审批结果\",\n" +
|
||||
" \"key\": \"node_330665593249_axv0_activityResult\",\n" +
|
||||
" \"type\": \"text\",\n" +
|
||||
" \"value\": \"已同意\"\n" +
|
||||
" },\n" +
|
||||
" {\n" +
|
||||
" \"desc\": \"主讲人审批电子签名\",\n" +
|
||||
" \"key\": \"node_330665593249_axv0_signature\",\n" +
|
||||
" \"type\": \"img\",\n" +
|
||||
" \"value\": []\n" +
|
||||
" },\n" +
|
||||
" {\n" +
|
||||
" \"desc\": \"主讲人审批审批意见\",\n" +
|
||||
" \"key\": \"node_330665593249_axv0_advice\",\n" +
|
||||
" \"type\": \"text\",\n" +
|
||||
" \"value\": \"123\"\n" +
|
||||
" },\n" +
|
||||
" {\n" +
|
||||
" \"desc\": \"主讲人审批日期\",\n" +
|
||||
" \"key\": \"node_330665593249_axv0_activityOperationTime\",\n" +
|
||||
" \"type\": \"text\",\n" +
|
||||
" \"value\": \"2025.12.20\"\n" +
|
||||
" },\n" +
|
||||
" {\n" +
|
||||
" \"desc\": \"发起人姓名\",\n" +
|
||||
" \"key\": \"initiatorName\",\n" +
|
||||
" \"type\": \"text\",\n" +
|
||||
" \"value\": \"罗福\"\n" +
|
||||
" },\n" +
|
||||
" {\n" +
|
||||
" \"desc\": \"发起人岗位\",\n" +
|
||||
" \"key\": \"initiatorPosition\",\n" +
|
||||
" \"type\": \"text\",\n" +
|
||||
" \"value\": \"测试岗位003\"\n" +
|
||||
" },\n" +
|
||||
" {\n" +
|
||||
" \"desc\": \"发起人联系方式\",\n" +
|
||||
" \"key\": \"initiatorPhone\",\n" +
|
||||
" \"type\": \"text\",\n" +
|
||||
" \"value\": \"18080995942\"\n" +
|
||||
" }\n" +
|
||||
"]";
|
||||
List<VariableObjectDTO> wpsVariables = JSON.parseArray(jsonStr2, VariableObjectDTO.class);
|
||||
List<FileReplaceContent> fileReplaceContents = BeanMapper.copyList(wpsVariables.stream()
|
||||
.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") || Objects.equals(i.getType().name(), "text"))
|
||||
.collect(Collectors.toList()), FileReplaceContent.class, (s, t) -> {
|
||||
/**
|
||||
* 调用 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(), "img")) {
|
||||
if (Objects.equals(s.getType().name(), VariableObjectDTO.Type.img.name())) {
|
||||
List<UploadFieldDTO> uploadFieldDTOS = new ArrayList<>();
|
||||
if (isJson(s.getValue().toString())) {
|
||||
t.setContent(JSON.parseArray(s.getValue().toString(), UploadFieldDTO.class).get(0).getFileUrl());
|
||||
uploadFieldDTOS.addAll(JSON.parseArray(s.getValue().toString(), UploadFieldDTO.class));
|
||||
} else {
|
||||
t.setContent(JSON.parseArray(JSON.toJSONString(s.getValue()), UploadFieldDTO.class).get(0).getFileUrl());
|
||||
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() : "");
|
||||
}
|
||||
@ -232,7 +100,29 @@ public class WpsUtil {
|
||||
t.setSuffix("]");
|
||||
});
|
||||
|
||||
System.out.println("fileReplaceContents = " + fileReplaceContents);
|
||||
// 处理空值
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -252,11 +142,13 @@ public class WpsUtil {
|
||||
.collect(Collectors.toList()), FileReplaceContent.class, (s, t) -> {
|
||||
t.setKey(s.getDesc());
|
||||
if (Objects.equals(s.getType().name(), "img")) {
|
||||
List<UploadFieldDTO> uploadFieldDTOS;
|
||||
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 {
|
||||
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 {
|
||||
t.setContent(Objects.nonNull(s.getValue()) ? s.getValue().toString() : "");
|
||||
}
|
||||
|
||||
@ -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.VariableObjectDTO;
|
||||
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.utils.BpmnMetaParserHelper;
|
||||
import cn.axzo.workflow.core.listener.AbstractBpmnEventListener;
|
||||
import cn.axzo.workflow.core.listener.BpmnProcessEventListener;
|
||||
import cn.axzo.workflow.core.repository.entity.ExtAxDocContent;
|
||||
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.ExtAxModelDocService;
|
||||
import cn.axzo.workflow.core.service.ExtAxProcessSignService;
|
||||
@ -35,6 +37,8 @@ import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
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
|
||||
private ExtAxDocContentService extAxDocContentService;
|
||||
@Resource
|
||||
private CategoryService categoryService;
|
||||
@Resource
|
||||
private WpsUtil wpsUtil;
|
||||
|
||||
|
||||
@ -71,19 +77,21 @@ public class FileArchiveProcessEventListener extends AbstractBpmnEventListener<P
|
||||
HistoricProcessInstance instance = historyService.createHistoricProcessInstanceQuery()
|
||||
.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();
|
||||
ExtAxProcessSign processSign = extAxProcessSignService.findByProcessInstanceId(instance.getId());
|
||||
List<VariableObjectDTO> wpsReplaceVariables = wpsUtil.getWpsReplaceVariables(processEngineConfiguration, instance.getId());
|
||||
|
||||
processSign.getFileArchive().stream().filter(i -> Objects.equals(i.getFileType(), FileTypeEnum.WORD)
|
||||
|| Objects.equals(i.getFileType(), FileTypeEnum.EXCEL))
|
||||
.filter(i -> Boolean.TRUE.equals(i.getNeedReplaceVariables()))
|
||||
.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);
|
||||
});
|
||||
// 删除非 WPS 的临时文档
|
||||
@ -116,6 +124,6 @@ public class FileArchiveProcessEventListener extends AbstractBpmnEventListener<P
|
||||
|
||||
@Override
|
||||
public int getOrder() {
|
||||
return Integer.MIN_VALUE + 3;
|
||||
return Integer.MIN_VALUE + 99;
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user