From c145b787d2562cc7e7d3ead7982c5c62b62fe795 Mon Sep 17 00:00:00 2001 From: linbangquan <1437892690@qq.com> Date: Tue, 19 Mar 2024 18:11:33 +0800 Subject: [PATCH] =?UTF-8?q?[=E5=8A=9F=E8=83=BD]=20=E7=AC=AC=E4=B8=89?= =?UTF-8?q?=E6=96=B9=E5=88=9B=E5=BB=BA=E5=B7=A5=E5=8D=95=E7=9A=84=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3=EF=BC=8C=E8=A1=A8=E5=8D=95=E5=80=BC=E7=AE=80=E5=8C=96?= =?UTF-8?q?=E8=A7=84=E8=8C=83=EF=BC=8C=E7=BB=9F=E4=B8=80=E7=94=A8=E6=95=B0?= =?UTF-8?q?=E7=BB=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 关联 #[1114550416408576]第三方创建工单的接口,表单值简化规范,统一用数组 http://192.168.0.96:8090/demo/rdm.html#/story-detail/939050947543040/939050947543042/1114550416408576 --- .../ProcessTaskCreatePublicServiceImpl.java | 166 +++++++++++++++++- 1 file changed, 158 insertions(+), 8 deletions(-) diff --git a/src/main/java/neatlogic/module/process/service/ProcessTaskCreatePublicServiceImpl.java b/src/main/java/neatlogic/module/process/service/ProcessTaskCreatePublicServiceImpl.java index ee8673d36..ab1ca5bd2 100644 --- a/src/main/java/neatlogic/module/process/service/ProcessTaskCreatePublicServiceImpl.java +++ b/src/main/java/neatlogic/module/process/service/ProcessTaskCreatePublicServiceImpl.java @@ -3,6 +3,7 @@ package neatlogic.module.process.service; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import neatlogic.framework.asynchronization.threadlocal.UserContext; +import neatlogic.framework.common.constvalue.GroupSearch; import neatlogic.framework.common.constvalue.SystemUser; import neatlogic.framework.dao.mapper.UserMapper; import neatlogic.framework.dto.AuthenticationInfoVo; @@ -12,9 +13,12 @@ import neatlogic.framework.file.dao.mapper.FileMapper; import neatlogic.framework.file.dto.FileVo; import neatlogic.framework.form.attribute.core.FormAttributeHandlerFactory; import neatlogic.framework.form.attribute.core.FormHandlerBase; +import neatlogic.framework.form.constvalue.FormHandler; import neatlogic.framework.form.dao.mapper.FormMapper; +import neatlogic.framework.form.dto.AttributeDataVo; import neatlogic.framework.form.dto.FormAttributeVo; import neatlogic.framework.form.dto.FormVersionVo; +import neatlogic.framework.form.exception.FormAttributeHandlerNotFoundException; import neatlogic.framework.form.exception.FormAttributeNotFoundException; import neatlogic.framework.process.constvalue.ProcessFlowDirection; import neatlogic.framework.process.dao.mapper.ChannelMapper; @@ -38,9 +42,7 @@ import org.springframework.stereotype.Service; import javax.activation.MimetypesFileTypeMap; import javax.annotation.Resource; import java.io.File; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import java.util.*; @Service public class ProcessTaskCreatePublicServiceImpl implements ProcessTaskCreatePublicService { @@ -161,6 +163,17 @@ public class ProcessTaskCreatePublicServiceImpl implements ProcessTaskCreatePubl FormVersionVo actionFormVersionVo = formMapper.getActionFormVersionByFormUuid(processFormVo.getFormUuid()); List formAttributeVoList = actionFormVersionVo.getFormAttributeList(); if (CollectionUtils.isNotEmpty(formAttributeVoList)) { + List dataTypeNotArrayHandlerList = new ArrayList<>(); + dataTypeNotArrayHandlerList.add(FormHandler.FORMDATE.getHandler()); + dataTypeNotArrayHandlerList.add(FormHandler.FORMTIME.getHandler()); + dataTypeNotArrayHandlerList.add(FormHandler.FORMRATE.getHandler()); + dataTypeNotArrayHandlerList.add(FormHandler.FORMCKEDITOR.getHandler()); + dataTypeNotArrayHandlerList.add(FormHandler.FORMTEXTAREA.getHandler()); + dataTypeNotArrayHandlerList.add(FormHandler.FORMTEXT.getHandler()); + dataTypeNotArrayHandlerList.add(FormHandler.FORMNUMBER.getHandler()); + dataTypeNotArrayHandlerList.add(FormHandler.FORMPASSWORD.getHandler()); + dataTypeNotArrayHandlerList.add(FormHandler.FORMTREESELECT.getHandler()); + dataTypeNotArrayHandlerList.add(neatlogic.framework.cmdb.enums.FormHandler.FORMPROTOCOL.getHandler()); Map labelAttributeMap = new HashMap<>(); for (FormAttributeVo formAttributeVo : formAttributeVoList) { labelAttributeMap.put(formAttributeVo.getLabel(), formAttributeVo); @@ -175,13 +188,150 @@ public class ProcessTaskCreatePublicServiceImpl implements ProcessTaskCreatePubl if (formAttributeVo == null) { throw new FormAttributeNotFoundException(label); } + FormHandlerBase formAttributeHandler = (FormHandlerBase) FormAttributeHandlerFactory.getHandler(formAttributeVo.getHandler()); + if (formAttributeHandler == null) { + throw new FormAttributeHandlerNotFoundException(formAttributeVo.getHandler()); + } + JSONObject config = JSONObject.parseObject(formAttributeVo.getConfig()); formAttributeData.put("attributeUuid", formAttributeVo.getUuid()); formAttributeData.put("handler", formAttributeVo.getHandler()); - FormHandlerBase formAttributeHandler = (FormHandlerBase) FormAttributeHandlerFactory.getHandler(formAttributeVo.getHandler()); - if (formAttributeHandler != null) { - JSONObject config = JSONObject.parseObject(formAttributeVo.getConfig()); - Object dataList = formAttributeHandler.textConversionValue(formAttributeData.get("dataList"), config); - formAttributeData.put("dataList", dataList); + Object dataObj = formAttributeData.get("dataList"); + if (Objects.equals(formAttributeVo.getHandler(), FormHandler.FORMSELECT.getHandler())) { + boolean isMultiple = config.getBooleanValue("isMultiple"); + if (isMultiple) { + JSONArray dataList = new JSONArray(); + for (Object data : (List) dataObj) { + Object value = formAttributeHandler.textConversionValue(data, config); + if (value != null) { + dataList.addAll((JSONArray) value); + } else { + AttributeDataVo attributeDataVo = new AttributeDataVo(); + attributeDataVo.setAttributeUuid(formAttributeVo.getUuid()); + attributeDataVo.setAttributeLabel(formAttributeVo.getLabel()); + attributeDataVo.setDataObj(data); + JSONArray textList = (JSONArray) formAttributeHandler.valueConversionText(attributeDataVo, config); + if (!Objects.equals(textList.get(0), data)) { + JSONObject jsonObj = new JSONObject(); + jsonObj.put("value", data); + jsonObj.put("text", textList.get(0)); + dataList.add(jsonObj); + } + } + } + if (CollectionUtils.isNotEmpty(dataList)) { + formAttributeData.put("dataList", dataList); + } + } else { + Object data = dataObj; + if (dataObj instanceof List) { + data = ((List) dataObj).get(0); + } + Object value = formAttributeHandler.textConversionValue(data, config); + if (value != null) { + formAttributeData.put("dataList", value); + } else { + AttributeDataVo attributeDataVo = new AttributeDataVo(); + attributeDataVo.setAttributeUuid(formAttributeVo.getUuid()); + attributeDataVo.setAttributeLabel(formAttributeVo.getLabel()); + attributeDataVo.setDataObj(data); + JSONArray textList = (JSONArray) formAttributeHandler.valueConversionText(attributeDataVo, config); + if (!Objects.equals(textList.get(0), data)) { + JSONObject jsonObj = new JSONObject(); + jsonObj.put("value", data); + jsonObj.put("text", textList.get(0)); + formAttributeData.put("dataList", jsonObj); + } + } + } + } else if (Objects.equals(formAttributeVo.getHandler(), FormHandler.FORMRADIO.getHandler())) { + Object data = dataObj; + if (dataObj instanceof List) { + data = ((List) dataObj).get(0); + } + Object value = formAttributeHandler.textConversionValue(data, config); + if (value != null) { + formAttributeData.put("dataList", value); + } else { + AttributeDataVo attributeDataVo = new AttributeDataVo(); + attributeDataVo.setAttributeUuid(formAttributeVo.getUuid()); + attributeDataVo.setAttributeLabel(formAttributeVo.getLabel()); + attributeDataVo.setDataObj(data); + JSONArray textList = (JSONArray) formAttributeHandler.valueConversionText(attributeDataVo, config); + if (!Objects.equals(textList.get(0), data)) { + JSONObject jsonObj = new JSONObject(); + jsonObj.put("value", data); + jsonObj.put("text", textList.get(0)); + formAttributeData.put("dataList", jsonObj); + } + } + } else if (Objects.equals(formAttributeVo.getHandler(), FormHandler.FORMCHECKBOX.getHandler())) { + JSONArray dataList = new JSONArray(); + for (Object data : (List) dataObj) { + Object value = formAttributeHandler.textConversionValue(data, config); + if (value != null) { + dataList.addAll((JSONArray) value); + } else { + AttributeDataVo attributeDataVo = new AttributeDataVo(); + attributeDataVo.setAttributeUuid(formAttributeVo.getUuid()); + attributeDataVo.setAttributeLabel(formAttributeVo.getLabel()); + attributeDataVo.setDataObj(data); + JSONArray textList = (JSONArray) formAttributeHandler.valueConversionText(attributeDataVo, config); + if (!Objects.equals(textList.get(0), data)) { + JSONObject jsonObj = new JSONObject(); + jsonObj.put("value", data); + jsonObj.put("text", textList.get(0)); + dataList.add(jsonObj); + } + } + } + if (CollectionUtils.isNotEmpty(dataList)) { + formAttributeData.put("dataList", dataList); + } + } else if (Objects.equals(formAttributeVo.getHandler(), FormHandler.FORMUSERSELECT.getHandler())) { + boolean isMultiple = config.getBooleanValue("isMultiple"); + if (isMultiple) { + boolean flag = false; + for (Object data : (List) dataObj) { + String dataStr = data.toString(); + if (dataStr.contains(GroupSearch.COMMON.getValuePlugin()) + || dataStr.contains(GroupSearch.USER.getValuePlugin()) + || dataStr.contains(GroupSearch.TEAM.getValuePlugin()) + || dataStr.contains(GroupSearch.ROLE.getValuePlugin())) { + flag = true; + break; + } + } + if (flag) { + formAttributeData.put("dataList", dataObj); + } else { + Object value = formAttributeHandler.textConversionValue(dataObj, config); + formAttributeData.put("dataList", value); + } + + } else { + Object data = dataObj; + if (dataObj instanceof List) { + data = ((List) dataObj).get(0); + } + String dataStr = data.toString(); + if (dataStr.contains(GroupSearch.COMMON.getValuePlugin()) + || dataStr.contains(GroupSearch.USER.getValuePlugin()) + || dataStr.contains(GroupSearch.TEAM.getValuePlugin()) + || dataStr.contains(GroupSearch.ROLE.getValuePlugin())) { + formAttributeData.put("dataList", data); + } else { + Object value = formAttributeHandler.textConversionValue(data, config); + formAttributeData.put("dataList", value); + } + } + } else { + Object data = dataObj; + if (dataObj instanceof List) { + if (dataTypeNotArrayHandlerList.contains(formAttributeVo.getHandler())) { + data = ((List) dataObj).get(0); + } + } + formAttributeData.put("dataList", data); } } } -- Gitee