From 7bb924775c82c26bb141c1b4e1eba47812e0bb25 Mon Sep 17 00:00:00 2001 From: "1437892690@qq.com" <1437892690@qq.com> Date: Wed, 3 Jul 2024 18:41:50 +0800 Subject: [PATCH 1/2] =?UTF-8?q?[=E4=BF=AE=E5=A4=8D]=20=E6=B5=81=E7=A8=8B?= =?UTF-8?q?=E4=B8=AD=E8=87=AA=E5=8A=A8=E5=8C=96=E8=8A=82=E7=82=B9=E9=85=8D?= =?UTF-8?q?=E7=BD=AE=E5=A6=82=E6=9E=9C=E9=80=89=E4=BA=86=E8=A1=A8=E5=8D=95?= =?UTF-8?q?=E6=A0=87=E7=AD=BE=EF=BC=8C=E5=88=99=E4=BD=9C=E4=B8=9A=E5=8F=82?= =?UTF-8?q?=E6=95=B0=E9=85=8D=E7=BD=AE=E6=97=B6=E6=99=AE=E9=80=9A=E7=BB=84?= =?UTF-8?q?=E4=BB=B6=EF=BC=88=E6=AF=94=E5=A6=82=E4=B8=8A=E4=BC=A0=E9=99=84?= =?UTF-8?q?=E4=BB=B6=EF=BC=89=E9=80=89=E4=B8=8D=E4=BA=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 关联 #[1192023095214080]流程中自动化节点配置如果选了表单标签,则作业参数配置时普通组件(比如上传附件)选不了 http://192.168.0.96:8090/demo/rdm.html#/bug-detail/939050947543040/939050947543057/1192023095214080 --- .../process/util/CreateJobConfigUtil.java | 115 ++++++++++++++---- .../component/AutoexecProcessComponent.java | 69 ++++++++++- 2 files changed, 161 insertions(+), 23 deletions(-) diff --git a/src/main/java/neatlogic/module/autoexec/process/util/CreateJobConfigUtil.java b/src/main/java/neatlogic/module/autoexec/process/util/CreateJobConfigUtil.java index 06de932b..8466a5e5 100644 --- a/src/main/java/neatlogic/module/autoexec/process/util/CreateJobConfigUtil.java +++ b/src/main/java/neatlogic/module/autoexec/process/util/CreateJobConfigUtil.java @@ -32,6 +32,8 @@ import neatlogic.framework.cmdb.dto.resourcecenter.AccountVo; import neatlogic.framework.common.constvalue.Expression; import neatlogic.framework.common.constvalue.GroupSearch; import neatlogic.framework.crossover.CrossoverServiceFactory; +import neatlogic.framework.crossover.IFileCrossoverService; +import neatlogic.framework.file.dto.FileVo; import neatlogic.framework.form.attribute.core.FormAttributeDataConversionHandlerFactory; import neatlogic.framework.form.attribute.core.IFormAttributeDataConversionHandler; import neatlogic.framework.form.dto.FormAttributeVo; @@ -68,18 +70,24 @@ public class CreateJobConfigUtil { if (CollectionUtils.isNotEmpty(formAttributeList)) { List processTaskFormAttributeDataList = processTaskCrossoverService.getProcessTaskFormAttributeDataListByProcessTaskIdAndTag(processTaskId, createJobConfigConfigVo.getFormTag()); for (ProcessTaskFormAttributeDataVo attributeDataVo : processTaskFormAttributeDataList) { - originalFormAttributeDataMap.put(attributeDataVo.getAttributeUuid(), attributeDataVo.getDataObj()); // 放入表单普通组件数据 if (!Objects.equals(attributeDataVo.getHandler(), neatlogic.framework.form.constvalue.FormHandler.FORMTABLEINPUTER.getHandler()) && !Objects.equals(attributeDataVo.getHandler(), neatlogic.framework.form.constvalue.FormHandler.FORMSUBASSEMBLY.getHandler()) && !Objects.equals(attributeDataVo.getHandler(), neatlogic.framework.form.constvalue.FormHandler.FORMTABLESELECTOR.getHandler())) { IFormAttributeDataConversionHandler handler = FormAttributeDataConversionHandlerFactory.getHandler(attributeDataVo.getHandler()); if (handler != null) { - formAttributeDataMap.put(attributeDataVo.getAttributeUuid(), handler.getSimpleValue(attributeDataVo.getDataObj())); + Object simpleValue = handler.getSimpleValue(attributeDataVo.getDataObj()); + formAttributeDataMap.put(attributeDataVo.getAttributeUuid(), simpleValue); + formAttributeDataMap.put(attributeDataVo.getAttributeKey(), simpleValue); } else { - formAttributeDataMap.put(attributeDataVo.getAttributeUuid(), attributeDataVo.getDataObj()); + Object dataObj = attributeDataVo.getDataObj(); + formAttributeDataMap.put(attributeDataVo.getAttributeUuid(), dataObj); + formAttributeDataMap.put(attributeDataVo.getAttributeKey(), dataObj); } } + Object dataObj = attributeDataVo.getDataObj(); + originalFormAttributeDataMap.put(attributeDataVo.getAttributeUuid(), dataObj); + originalFormAttributeDataMap.put(attributeDataVo.getAttributeKey(), dataObj); } // 添加表格组件中的子组件到组件列表中 List allDownwardFormAttributeList = new ArrayList<>(); @@ -100,7 +108,8 @@ public class CreateJobConfigUtil { } formAttributeList.addAll(allDownwardFormAttributeList); } - + System.out.println("formAttributeDataMap = " + JSONObject.toJSONString(formAttributeDataMap)); + System.out.println("originalFormAttributeDataMap = " + JSONObject.toJSONString(originalFormAttributeDataMap)); JSONObject processTaskParam = ProcessTaskConditionFactory.getConditionParamData(Arrays.stream(ConditionProcessTaskOptions.values()).map(ConditionProcessTaskOptions::getValue).collect(Collectors.toList()), currentProcessTaskStepVo); // 作业策略createJobPolicy为single时表示单次创建作业,createJobPolicy为batch时表示批量创建作业 String createPolicy = createJobConfigConfigVo.getCreatePolicy(); @@ -147,9 +156,18 @@ public class CreateJobConfigUtil { if (CollectionUtils.isEmpty(tbodyList)) { return resultList; } + FormAttributeVo formAttributeVo = getFormAttributeVo(formAttributeList, batchDataSourceMapping.getValue().toString()); + if (formAttributeVo == null) { + formAttributeVo = getFormAttributeVoByKeyAndParentUuid(formAttributeList, batchDataSourceMapping.getValue().toString(), null); + } + if (formAttributeVo == null) { + return resultList; + } // 遍历表格数据,创建AutoexecJobVo对象列表 for (Object obj : tbodyList) { - formAttributeDataMap.put(batchDataSourceMapping.getValue().toString(), Collections.singletonList(obj)); + List list = Collections.singletonList(obj); + formAttributeDataMap.put(formAttributeVo.getUuid(), list); + formAttributeDataMap.put(formAttributeVo.getKey(), list); AutoexecJobBuilder builder = createSingleAutoexecJobBuilder(currentProcessTaskStepVo, createJobConfigConfigVo, autoexecCombopVersionVo, formAttributeList, originalFormAttributeDataMap, formAttributeDataMap, processTaskParam); resultList.add(builder); } @@ -893,7 +911,7 @@ public class CreateJobConfigUtil { * 获取表单表格组件的数据 * @param formAttributeList * @param originalFormAttributeDataMap - * @param attributeUuid + * @param attribute * @return */ @SuppressWarnings("unchecked") @@ -901,13 +919,20 @@ public class CreateJobConfigUtil { List formAttributeList, Map originalFormAttributeDataMap, Map formAttributeDataMap, - String attributeUuid) { + String attribute) { List resultList = new ArrayList<>(); - Object object = formAttributeDataMap.get(attributeUuid); + FormAttributeVo formAttributeVo = getFormAttributeVo(formAttributeList, attribute); + if (formAttributeVo == null) { + formAttributeVo = getFormAttributeVoByKeyAndParentUuid(formAttributeList, attribute, null); + } + if (formAttributeVo == null) { + return resultList; + } + Object object = formAttributeDataMap.get(attribute); if (object != null) { return (List) object; } - Object obj = originalFormAttributeDataMap.get(attributeUuid); + Object obj = originalFormAttributeDataMap.get(attribute); if (obj == null) { return resultList; } @@ -918,26 +943,31 @@ public class CreateJobConfigUtil { if (CollectionUtils.isEmpty(array)) { return resultList; } - + // 将表格组件中下拉框属性数据值由{"value": "a", "text": "A"}转换为"a" for (int i = 0; i < array.size(); i++) { JSONObject newJsonObj = new JSONObject(); JSONObject jsonObj = array.getJSONObject(i); for (Map.Entry entry : jsonObj.entrySet()) { String key = entry.getKey(); Object value = entry.getValue(); - FormAttributeVo formAttributeVo = getFormAttributeVo(formAttributeList, key); - if (formAttributeVo != null) { - IFormAttributeDataConversionHandler handler = FormAttributeDataConversionHandlerFactory.getHandler(formAttributeVo.getHandler()); + FormAttributeVo columnFormAttributeVo = getFormAttributeVo(formAttributeList, key); + if (columnFormAttributeVo == null) { + columnFormAttributeVo = getFormAttributeVoByKeyAndParentUuid(formAttributeList, key, formAttributeVo.getUuid()); + } + if (columnFormAttributeVo != null) { + IFormAttributeDataConversionHandler handler = FormAttributeDataConversionHandlerFactory.getHandler(columnFormAttributeVo.getHandler()); if (handler != null) { value = handler.getSimpleValue(value); } - newJsonObj.put(key, value); + newJsonObj.put(columnFormAttributeVo.getUuid(), value); + newJsonObj.put(columnFormAttributeVo.getKey(), value); } else { newJsonObj.put(key, value); } } resultList.add(newJsonObj); } + System.out.println("resultList = " + JSONObject.toJSONString(resultList)); return resultList; } @@ -1243,19 +1273,28 @@ public class CreateJobConfigUtil { JSONObject resultObj = new JSONObject(); JSONArray fileIdList = new JSONArray(); JSONArray fileList = new JSONArray(); + IFileCrossoverService fileCrossoverService = CrossoverServiceFactory.getApi(IFileCrossoverService.class); for (Object obj : jsonArray) { if (obj == null) { continue; } if (obj instanceof JSONObject) { JSONObject jsonObj = (JSONObject) obj; + Long fileId = jsonObj.getLong("id"); JSONArray fileIdArray = jsonObj.getJSONArray("fileIdList"); - if (CollectionUtils.isNotEmpty(fileIdArray)) { - fileIdList.addAll(fileIdArray); - } JSONArray fileArray = jsonObj.getJSONArray("fileList"); - if (CollectionUtils.isNotEmpty(fileArray)) { + if (CollectionUtils.isNotEmpty(fileIdArray) && CollectionUtils.isNotEmpty(fileArray)) { + fileIdList.addAll(fileIdArray); fileList.addAll(fileArray); + } else if (fileId != null) { + FileVo file = fileCrossoverService.getFileById(fileId); + if (file != null) { + fileIdList.add(fileId); + JSONObject fileObj = new JSONObject(); + fileObj.put("id", fileId); + fileObj.put("name", file.getName()); + fileList.add(fileObj); + } } } else if (obj instanceof JSONArray) { JSONArray array = (JSONArray) obj; @@ -1268,17 +1307,35 @@ public class CreateJobConfigUtil { if (CollectionUtils.isNotEmpty(fileArray)) { fileList.addAll(fileArray); } + } else if (obj instanceof Long) { + Long fileId = (Long) obj; + FileVo file = fileCrossoverService.getFileById(fileId); + if (file != null) { + fileIdList.add(fileId); + JSONObject fileObj = new JSONObject(); + fileObj.put("id", fileId); + fileObj.put("name", file.getName()); + fileList.add(fileObj); + } } else { String str = obj.toString(); if (str.startsWith("{") && str.endsWith("}")) { JSONObject jsonObj = JSONObject.parseObject(str); + Long fileId = jsonObj.getLong("id"); JSONArray fileIdArray = jsonObj.getJSONArray("fileIdList"); - if (CollectionUtils.isNotEmpty(fileIdArray)) { - fileIdList.addAll(fileIdArray); - } JSONArray fileArray = jsonObj.getJSONArray("fileList"); - if (CollectionUtils.isNotEmpty(fileArray)) { + if (CollectionUtils.isNotEmpty(fileIdArray) && CollectionUtils.isNotEmpty(fileArray)) { + fileIdList.addAll(fileIdArray); fileList.addAll(fileArray); + } else if (fileId != null) { + FileVo file = fileCrossoverService.getFileById(fileId); + if (file != null) { + fileIdList.add(fileId); + JSONObject fileObj = new JSONObject(); + fileObj.put("id", fileId); + fileObj.put("name", file.getName()); + fileList.add(fileObj); + } } } else if (str.startsWith("[") && str.endsWith("]")) { JSONArray array = JSONArray.parseArray(str); @@ -1291,6 +1348,20 @@ public class CreateJobConfigUtil { if (CollectionUtils.isNotEmpty(fileArray)) { fileList.addAll(fileArray); } + } else { + try { + Long fileId = Long.valueOf(str); + FileVo file = fileCrossoverService.getFileById(fileId); + if (file != null) { + fileIdList.add(fileId); + JSONObject fileObj = new JSONObject(); + fileObj.put("id", fileId); + fileObj.put("name", file.getName()); + fileList.add(fileObj); + } + } catch (NumberFormatException e) { + + } } } } diff --git a/src/main/java/neatlogic/module/autoexec/stephandler/component/AutoexecProcessComponent.java b/src/main/java/neatlogic/module/autoexec/stephandler/component/AutoexecProcessComponent.java index 0f74417f..d61b6175 100644 --- a/src/main/java/neatlogic/module/autoexec/stephandler/component/AutoexecProcessComponent.java +++ b/src/main/java/neatlogic/module/autoexec/stephandler/component/AutoexecProcessComponent.java @@ -37,6 +37,8 @@ import neatlogic.framework.common.constvalue.SystemUser; import neatlogic.framework.crossover.CrossoverServiceFactory; import neatlogic.framework.dao.mapper.runner.RunnerMapper; import neatlogic.framework.dto.runner.RunnerGroupVo; +import neatlogic.framework.file.dao.mapper.FileMapper; +import neatlogic.framework.file.dto.FileVo; import neatlogic.framework.form.attribute.core.FormAttributeDataConversionHandlerFactory; import neatlogic.framework.form.attribute.core.IFormAttributeDataConversionHandler; import neatlogic.framework.form.dto.AttributeDataVo; @@ -97,6 +99,9 @@ public class AutoexecProcessComponent extends ProcessStepHandlerBase { @Resource private RunnerMapper runnerMapper; + @Resource + private FileMapper fileMapper; + @Override public String getHandler() { @@ -888,7 +893,10 @@ public class AutoexecProcessComponent extends ProcessStepHandlerBase { array.add(dataObj); param.put(key, array); } - } else { + } else if (Objects.equals(type, ParamType.FILE.getValue())) { + param.put(key, convertDateTypeForFile(attributeDataVo.getDataObj())); + } + else { param.put(key, attributeDataVo.getDataObj()); } } @@ -1392,6 +1400,65 @@ public class AutoexecProcessComponent extends ProcessStepHandlerBase { return source; } + /** + * 将数据转换成文件类型参数需要的格式 + * @param dataObj + * @return + */ + private JSONObject convertDateTypeForFile(Object dataObj) { + if (dataObj == null) { + return null; + } + if (dataObj instanceof JSONObject) { + JSONObject jsonObject = (JSONObject) dataObj; + Long fileId = jsonObject.getLong("id"); + return convertDateTypeForFile(fileId); + } else if (dataObj instanceof JSONArray) { + JSONArray jsonArray = (JSONArray) dataObj; + if (!jsonArray.isEmpty()) { + JSONObject resultObj = new JSONObject(); + JSONArray fileIdList = new JSONArray(); + JSONArray fileList = new JSONArray(); + for (Object obj : jsonArray) { + JSONObject jsonObj = convertDateTypeForFile(obj); + if (jsonObj != null) { + JSONArray fileIdArray = jsonObj.getJSONArray("fileIdList"); + fileIdList.addAll(fileIdArray); + JSONArray fileArray = jsonObj.getJSONArray("fileList"); + fileList.addAll(fileArray); + } + } + resultObj.put("fileIdList", fileIdList); + resultObj.put("fileList", fileList); + return resultObj; + } + } else if (dataObj instanceof Long) { + Long fileId = (Long) dataObj; + FileVo file = fileMapper.getFileById(fileId); + if (file != null) { + JSONObject resultObj = new JSONObject(); + JSONArray fileIdList = new JSONArray(); + fileIdList.add(fileId); + JSONArray fileList = new JSONArray(); + JSONObject fileObj = new JSONObject(); + fileObj.put("id", fileId); + fileObj.put("name", file.getName()); + fileList.add(fileObj); + resultObj.put("fileIdList", fileIdList); + resultObj.put("fileList", fileList); + return resultObj; + } + } else { + String str = dataObj.toString(); + try { + Long fileId = Long.valueOf(str); + return convertDateTypeForFile(fileId); + } catch (NumberFormatException e) { + + } + } + return null; + } @Override protected int myAssign(ProcessTaskStepVo currentProcessTaskStepVo, Set workerSet) throws ProcessTaskException { return defaultAssign(currentProcessTaskStepVo, workerSet); -- Gitee From bb9bc2f5614ef0742b8096d0bdffc65eff42e6bf Mon Sep 17 00:00:00 2001 From: "1437892690@qq.com" <1437892690@qq.com> Date: Wed, 3 Jul 2024 18:44:06 +0800 Subject: [PATCH 2/2] =?UTF-8?q?[=E4=BF=AE=E5=A4=8D]=20=E6=B5=81=E7=A8=8B?= =?UTF-8?q?=E4=B8=AD=E8=87=AA=E5=8A=A8=E5=8C=96=E8=8A=82=E7=82=B9=E9=85=8D?= =?UTF-8?q?=E7=BD=AE=E5=A6=82=E6=9E=9C=E9=80=89=E4=BA=86=E8=A1=A8=E5=8D=95?= =?UTF-8?q?=E6=A0=87=E7=AD=BE=EF=BC=8C=E5=88=99=E4=BD=9C=E4=B8=9A=E5=8F=82?= =?UTF-8?q?=E6=95=B0=E9=85=8D=E7=BD=AE=E6=97=B6=E6=99=AE=E9=80=9A=E7=BB=84?= =?UTF-8?q?=E4=BB=B6=EF=BC=88=E6=AF=94=E5=A6=82=E4=B8=8A=E4=BC=A0=E9=99=84?= =?UTF-8?q?=E4=BB=B6=EF=BC=89=E9=80=89=E4=B8=8D=E4=BA=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 关联 #[1192023095214080]流程中自动化节点配置如果选了表单标签,则作业参数配置时普通组件(比如上传附件)选不了 http://192.168.0.96:8090/demo/rdm.html#/bug-detail/939050947543040/939050947543057/1192023095214080 --- .../module/autoexec/process/util/CreateJobConfigUtil.java | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/main/java/neatlogic/module/autoexec/process/util/CreateJobConfigUtil.java b/src/main/java/neatlogic/module/autoexec/process/util/CreateJobConfigUtil.java index 8466a5e5..bd83c1cd 100644 --- a/src/main/java/neatlogic/module/autoexec/process/util/CreateJobConfigUtil.java +++ b/src/main/java/neatlogic/module/autoexec/process/util/CreateJobConfigUtil.java @@ -108,8 +108,6 @@ public class CreateJobConfigUtil { } formAttributeList.addAll(allDownwardFormAttributeList); } - System.out.println("formAttributeDataMap = " + JSONObject.toJSONString(formAttributeDataMap)); - System.out.println("originalFormAttributeDataMap = " + JSONObject.toJSONString(originalFormAttributeDataMap)); JSONObject processTaskParam = ProcessTaskConditionFactory.getConditionParamData(Arrays.stream(ConditionProcessTaskOptions.values()).map(ConditionProcessTaskOptions::getValue).collect(Collectors.toList()), currentProcessTaskStepVo); // 作业策略createJobPolicy为single时表示单次创建作业,createJobPolicy为batch时表示批量创建作业 String createPolicy = createJobConfigConfigVo.getCreatePolicy(); @@ -967,7 +965,6 @@ public class CreateJobConfigUtil { } resultList.add(newJsonObj); } - System.out.println("resultList = " + JSONObject.toJSONString(resultList)); return resultList; } -- Gitee