From c5f2f587789a3509af4b8319f20afd833b94e1c4 Mon Sep 17 00:00:00 2001
From: "1437892690@qq.com" <1437892690@qq.com>
Date: Mon, 2 Dec 2024 16:03:09 +0800
Subject: [PATCH] =?UTF-8?q?[=E5=8A=9F=E8=83=BD]=20IT=E6=9C=8D=E5=8A=A1-?=
=?UTF-8?q?=E5=A2=9E=E5=8A=A0=E4=B8=80=E4=B8=AA=E6=8E=A5=E5=8F=A3=E5=90=AF?=
=?UTF-8?q?=E7=94=A8=E8=A1=A8=E5=8D=95debug=E6=A8=A1=E5=BC=8F=EF=BC=8C?=
=?UTF-8?q?=E5=B7=A5=E5=8D=95=E5=A4=84=E7=90=86=E9=A1=B5=E8=A1=A8=E5=8D=95?=
=?UTF-8?q?=E8=87=AA=E5=AE=9A=E4=B9=89=E7=BB=84=E4=BB=B6=E6=98=BE=E7=A4=BA?=
=?UTF-8?q?=E9=9A=90=E8=97=8F=E7=9A=84=E5=88=97?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
关联 #[1302902038036480]IT服务-增加一个接口启用表单debug模式,工单处理页表单自定义组件显示隐藏的列 http://192.168.0.96:8090/demo/rdm.html#/story-detail/939050947543040/939050947543042/1302902038036480
---
.../EnableProcessTaskFormDebugModeApi.java | 141 ++++++++++++++++++
.../mapper/processtask/ProcessTaskMapper.xml | 2 +
2 files changed, 143 insertions(+)
create mode 100644 src/main/java/neatlogic/module/process/api/processtask/manualintervention/EnableProcessTaskFormDebugModeApi.java
diff --git a/src/main/java/neatlogic/module/process/api/processtask/manualintervention/EnableProcessTaskFormDebugModeApi.java b/src/main/java/neatlogic/module/process/api/processtask/manualintervention/EnableProcessTaskFormDebugModeApi.java
new file mode 100644
index 000000000..214d9cbab
--- /dev/null
+++ b/src/main/java/neatlogic/module/process/api/processtask/manualintervention/EnableProcessTaskFormDebugModeApi.java
@@ -0,0 +1,141 @@
+/*
+ * Copyright (C) 2024 深圳极向量科技有限公司 All Rights Reserved.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
+ */
+
+package neatlogic.module.process.api.processtask.manualintervention;
+
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import neatlogic.framework.auth.core.AuthAction;
+import neatlogic.framework.common.constvalue.ApiParamType;
+import neatlogic.framework.process.auth.PROCESSTASK_MODIFY;
+import neatlogic.framework.process.dto.ProcessTaskFormVo;
+import neatlogic.framework.restful.annotation.*;
+import neatlogic.framework.restful.constvalue.OperationTypeEnum;
+import neatlogic.framework.restful.core.privateapi.PrivateApiComponentBase;
+import neatlogic.module.process.dao.mapper.processtask.ProcessTaskMapper;
+import org.apache.commons.collections4.CollectionUtils;
+import org.apache.commons.collections4.MapUtils;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.stereotype.Service;
+import org.springframework.util.DigestUtils;
+
+import javax.annotation.Resource;
+import java.util.Objects;
+
+@Service
+@OperationType(type = OperationTypeEnum.SEARCH)
+@AuthAction(action = PROCESSTASK_MODIFY.class)
+public class EnableProcessTaskFormDebugModeApi extends PrivateApiComponentBase {
+
+ @Resource
+ private ProcessTaskMapper processTaskMapper;
+
+ @Override
+ public String getName() {
+ return "nmpapm.enableprocesstaskformdebugmodeapi.getname";
+ }
+
+ @Input({
+ @Param(name = "processTaskId", type = ApiParamType.LONG, isRequired = true, desc = "term.itsm.processtaskid"),
+ @Param(name = "enableDebugMode", type = ApiParamType.BOOLEAN, isRequired = true, desc = "common.enabledebugmode")
+ })
+ @Output({})
+ @Description(desc = "nmpapm.enableprocesstaskformdebugmodeapi.getname")
+ @Override
+ public Object myDoService(JSONObject paramObj) throws Exception {
+ boolean flag = false;
+ Long processTaskId = paramObj.getLong("processTaskId");
+ ProcessTaskFormVo processTaskForm = processTaskMapper.getProcessTaskFormByProcessTaskId(processTaskId);
+ if (processTaskForm != null) {
+ String formContent = processTaskForm.getFormContent();
+ if (StringUtils.isNotBlank(formContent)) {
+ JSONObject config = JSONObject.parseObject(processTaskForm.getFormContent());
+ if (MapUtils.isNotEmpty(config)) {
+ String formContentHash = DigestUtils.md5DigestAsHex(formContent.getBytes());
+ Boolean enableDebugMode = paramObj.getBoolean("enableDebugMode");
+ {
+ JSONArray tableList = config.getJSONArray("tableList");
+ if (CollectionUtils.isNotEmpty(tableList)) {
+ for (int i = 0; i < tableList.size(); i++) {
+ JSONObject tableObj = tableList.getJSONObject(i);
+ if (MapUtils.isNotEmpty(tableObj)) {
+ JSONObject component = tableObj.getJSONObject("component");
+ if (MapUtils.isNotEmpty(component)) {
+ String handler = component.getString("handler");
+ if (Objects.equals(handler, "formcustom")) {// 自定义表单组件
+ String componentStr = component.toJSONString();
+ if (enableDebugMode) {
+ componentStr = componentStr.replace("\"isShow\":false", "\"isShow\":true");
+ } else {
+ componentStr = componentStr.replace("\"isShow\":true", "\"isShow\":false");
+ }
+ tableObj.put("component", JSONObject.parseObject(componentStr));
+ }
+ }
+ }
+ }
+ }
+ }
+ JSONArray sceneList = config.getJSONArray("sceneList");
+ if (CollectionUtils.isNotEmpty(sceneList)) {
+ for (int j = 0; j < sceneList.size(); j++) {
+ JSONObject sceneObj = sceneList.getJSONObject(j);
+ if (MapUtils.isNotEmpty(sceneObj)) {
+ JSONArray tableList = sceneObj.getJSONArray("tableList");
+ if (CollectionUtils.isNotEmpty(tableList)) {
+ for (int i = 0; i < tableList.size(); i++) {
+ JSONObject tableObj = tableList.getJSONObject(i);
+ if (MapUtils.isNotEmpty(tableObj)) {
+ JSONObject component = tableObj.getJSONObject("component");
+ if (MapUtils.isNotEmpty(component)) {
+ String handler = component.getString("handler");
+ if (Objects.equals(handler, "formcustom")) {// 自定义表单组件
+ String componentStr = component.toJSONString();
+ if (enableDebugMode) {
+ componentStr = componentStr.replace("\"isShow\":false", "\"isShow\":true");
+ } else {
+ componentStr = componentStr.replace("\"isShow\":true", "\"isShow\":false");
+ }
+ tableObj.put("component", JSONObject.parseObject(componentStr));
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ String newFormContent = config.toJSONString();
+ String newFormContentHash = DigestUtils.md5DigestAsHex(newFormContent.getBytes());
+ if (!Objects.equals(newFormContentHash, formContentHash)) {
+ processTaskForm.setFormContent(newFormContent);
+ processTaskForm.setFormContentHash(newFormContentHash);
+ processTaskMapper.insertIgnoreProcessTaskFormContent(processTaskForm);
+ processTaskMapper.insertProcessTaskForm(processTaskForm);
+ flag = true;
+ }
+ }
+ }
+ }
+ return flag;
+ }
+
+ @Override
+ public String getToken() {
+ return "manualintervention/processtask/form/debug/enable";
+ }
+}
diff --git a/src/main/java/neatlogic/module/process/dao/mapper/processtask/ProcessTaskMapper.xml b/src/main/java/neatlogic/module/process/dao/mapper/processtask/ProcessTaskMapper.xml
index 371b205ee..d0d25eea2 100644
--- a/src/main/java/neatlogic/module/process/dao/mapper/processtask/ProcessTaskMapper.xml
+++ b/src/main/java/neatlogic/module/process/dao/mapper/processtask/ProcessTaskMapper.xml
@@ -3029,6 +3029,8 @@
#{formUuid},
#{formName},
#{formContentHash})
+ ON DUPLICATE KEY
+ UPDATE `form_content_hash` = #{formContentHash}
--
Gitee