diff --git a/src/main/java/neatlogic/module/process/stephandler/regulatehandler/FormConfigRegulateHandler.java b/src/main/java/neatlogic/module/process/stephandler/regulatehandler/FormConfigRegulateHandler.java new file mode 100644 index 0000000000000000000000000000000000000000..606c7b6c33c459c84e0bff8004f99761fa7375df --- /dev/null +++ b/src/main/java/neatlogic/module/process/stephandler/regulatehandler/FormConfigRegulateHandler.java @@ -0,0 +1,48 @@ +/* + * 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.stephandler.regulatehandler; + +import com.alibaba.fastjson.JSONObject; +import neatlogic.framework.process.stephandler.core.IProcessStepInternalHandler; +import neatlogic.framework.process.stephandler.core.IRegulateHandler; +import org.apache.commons.collections4.MapUtils; +import org.springframework.stereotype.Service; + +@Service +public class FormConfigRegulateHandler implements IRegulateHandler { + + @Override + public String getName() { + return "formConfig"; + } + + @Override + public void regulateConfig(IProcessStepInternalHandler processStepInternalHandler, JSONObject oldConfigObj, JSONObject newConfigObj) { + JSONObject formConfig = oldConfigObj.getJSONObject("formConfig"); + String formUuid = ""; + String formName = ""; + if (MapUtils.isNotEmpty(formConfig)) { + formUuid = formConfig.getString("uuid"); + formName = formConfig.getString("name"); + } + JSONObject formObj = new JSONObject(); + formObj.put("uuid", formUuid); + formObj.put("name", formName); + newConfigObj.put("formConfig", formObj); + } +} diff --git a/src/main/java/neatlogic/module/process/stephandler/regulatehandler/FormTagRegulateHandler.java b/src/main/java/neatlogic/module/process/stephandler/regulatehandler/FormTagRegulateHandler.java new file mode 100644 index 0000000000000000000000000000000000000000..17229a566f9e27bf13395f916825161c620bd627 --- /dev/null +++ b/src/main/java/neatlogic/module/process/stephandler/regulatehandler/FormTagRegulateHandler.java @@ -0,0 +1,42 @@ +/* + * 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.stephandler.regulatehandler; + +import com.alibaba.fastjson.JSONObject; +import neatlogic.framework.process.stephandler.core.IProcessStepInternalHandler; +import neatlogic.framework.process.stephandler.core.IRegulateHandler; +import org.apache.commons.lang3.StringUtils; +import org.springframework.stereotype.Service; + +@Service +public class FormTagRegulateHandler implements IRegulateHandler { + + @Override + public String getName() { + return "formTag"; + } + + @Override + public void regulateConfig(IProcessStepInternalHandler processStepInternalHandler, JSONObject oldConfigObj, JSONObject newConfigObj) { + String formTag = oldConfigObj.getString("formTag"); + if (StringUtils.isBlank(formTag)) { + formTag = StringUtils.EMPTY; + } + newConfigObj.put("formTag", formTag); + } +} diff --git a/src/main/java/neatlogic/module/process/stephandler/regulatehandler/MoveonConfigListRegulateHandler.java b/src/main/java/neatlogic/module/process/stephandler/regulatehandler/MoveonConfigListRegulateHandler.java new file mode 100644 index 0000000000000000000000000000000000000000..62b46f872dc85ac5a28bb33809e42cc59ce75d5f --- /dev/null +++ b/src/main/java/neatlogic/module/process/stephandler/regulatehandler/MoveonConfigListRegulateHandler.java @@ -0,0 +1,66 @@ +/* + * 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.stephandler.regulatehandler; + +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import neatlogic.framework.process.dto.processconfig.MoveonConfigVo; +import neatlogic.framework.process.exception.process.ProcessConfigException; +import neatlogic.framework.process.stephandler.core.IProcessStepInternalHandler; +import neatlogic.framework.process.stephandler.core.IRegulateHandler; +import neatlogic.framework.process.stephandler.core.ProcessMessageManager; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.collections4.ListUtils; +import org.springframework.stereotype.Service; + +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; + +@Service +public class MoveonConfigListRegulateHandler implements IRegulateHandler { + + @Override + public String getName() { + return "moveonConfigList"; + } + + @Override + public void regulateConfig(IProcessStepInternalHandler processStepInternalHandler, JSONObject oldConfigObj, JSONObject newConfigObj) { + List moveonConfigList = new ArrayList<>(); + JSONArray moveonConfigArray = oldConfigObj.getJSONArray("moveonConfigList"); + if(CollectionUtils.isNotEmpty(moveonConfigArray)){ + moveonConfigArray.removeIf(Objects::isNull); + List effectiveStepUuidList = ProcessMessageManager.getEffectiveStepUuidList(); + for(int i = 0; i < moveonConfigArray.size(); i++){ + MoveonConfigVo moveonConfigVo = moveonConfigArray.getObject(i, MoveonConfigVo.class); + if(moveonConfigVo != null){ + List targetStepList = moveonConfigVo.getTargetStepList(); + if (CollectionUtils.isNotEmpty(targetStepList)) { + List list = ListUtils.removeAll(targetStepList, effectiveStepUuidList); + if (CollectionUtils.isNotEmpty(list)) { + throw new ProcessConfigException(ProcessConfigException.Type.CONDITION, ProcessMessageManager.getStepName()); + } + } + moveonConfigList.add(moveonConfigVo); + } + } + } + newConfigObj.put("moveonConfigList", moveonConfigList); + } +} diff --git a/src/main/java/neatlogic/module/process/stephandler/regulatehandler/ProcessConfigRegulateHandler.java b/src/main/java/neatlogic/module/process/stephandler/regulatehandler/ProcessConfigRegulateHandler.java new file mode 100644 index 0000000000000000000000000000000000000000..5058dca2c712589f5dcfb434284a198419eff3ad --- /dev/null +++ b/src/main/java/neatlogic/module/process/stephandler/regulatehandler/ProcessConfigRegulateHandler.java @@ -0,0 +1,92 @@ +/* + * 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.stephandler.regulatehandler; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import neatlogic.framework.crossover.CrossoverServiceFactory; +import neatlogic.framework.notify.crossover.INotifyServiceCrossoverService; +import neatlogic.framework.notify.dto.InvokeNotifyPolicyConfigVo; +import neatlogic.framework.process.constvalue.ProcessTaskOperationType; +import neatlogic.framework.process.dto.processconfig.ActionConfigVo; +import neatlogic.framework.process.stephandler.core.IProcessStepInternalHandler; +import neatlogic.framework.process.stephandler.core.IRegulateHandler; +import neatlogic.framework.process.util.ProcessConfigUtil; +import neatlogic.module.process.notify.handler.TaskNotifyPolicyHandler; +import org.springframework.stereotype.Service; + +import java.util.Objects; + +@Service +public class ProcessConfigRegulateHandler implements IRegulateHandler { + + @Override + public String getName() { + return "processConfig"; + } + + @Override + public void regulateConfig(IProcessStepInternalHandler processStepInternalHandler, JSONObject oldConfigObj, JSONObject newConfigObj) { + JSONObject processConfig = oldConfigObj.getJSONObject("processConfig"); + JSONObject processObj = new JSONObject(); + if (processConfig == null) { + processConfig = new JSONObject(); + } + String uuid = processConfig.getString("uuid"); + String name = processConfig.getString("name"); + processObj.put("uuid", uuid); + processObj.put("name", name); + /* 授权 **/ + ProcessTaskOperationType[] stepActions = { + ProcessTaskOperationType.PROCESSTASK_ABORT, + ProcessTaskOperationType.PROCESSTASK_UPDATE, + ProcessTaskOperationType.PROCESSTASK_URGE + }; + JSONArray authorityList = null; + Integer enableAuthority = processConfig.getInteger("enableAuthority"); + if (Objects.equals(enableAuthority, 1)) { + authorityList = processConfig.getJSONArray("authorityList"); + } else { + enableAuthority = 0; + } + processObj.put("enableAuthority", enableAuthority); + JSONArray authorityArray = ProcessConfigUtil.regulateAuthorityList(authorityList, stepActions); + processObj.put("authorityList", authorityArray); + + /* 通知 **/ + JSONObject notifyPolicyConfig = processConfig.getJSONObject("notifyPolicyConfig"); + INotifyServiceCrossoverService notifyServiceCrossoverService = CrossoverServiceFactory.getApi(INotifyServiceCrossoverService.class); + InvokeNotifyPolicyConfigVo invokeNotifyPolicyConfigVo = notifyServiceCrossoverService.regulateNotifyPolicyConfig(notifyPolicyConfig, TaskNotifyPolicyHandler.class); + processObj.put("notifyPolicyConfig", invokeNotifyPolicyConfigVo); + + /* 动作 **/ + JSONObject actionConfig = processConfig.getJSONObject("actionConfig"); + ActionConfigVo actionConfigVo = JSON.toJavaObject(actionConfig, ActionConfigVo.class); + if (actionConfigVo == null) { + actionConfigVo = new ActionConfigVo(); + } + actionConfigVo.setHandler(TaskNotifyPolicyHandler.class.getName()); + processObj.put("actionConfig", actionConfigVo); + + Integer enableMarkRepeat = processConfig.getInteger("enableMarkRepeat"); + enableMarkRepeat = enableMarkRepeat == null ? 0 : enableMarkRepeat; + processObj.put("enableMarkRepeat", enableMarkRepeat); + newConfigObj.put("processConfig", processObj); + } +} diff --git a/src/main/java/neatlogic/module/process/stephandler/regulatehandler/ScoreConfigRegulateHandler.java b/src/main/java/neatlogic/module/process/stephandler/regulatehandler/ScoreConfigRegulateHandler.java new file mode 100644 index 0000000000000000000000000000000000000000..8c8806080333bda0fcee6088eb75db46acaf9de5 --- /dev/null +++ b/src/main/java/neatlogic/module/process/stephandler/regulatehandler/ScoreConfigRegulateHandler.java @@ -0,0 +1,68 @@ +/* + * 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.stephandler.regulatehandler; + +import com.alibaba.fastjson.JSONObject; +import neatlogic.framework.process.stephandler.core.IProcessStepInternalHandler; +import neatlogic.framework.process.stephandler.core.IRegulateHandler; +import org.apache.commons.collections4.MapUtils; +import org.springframework.stereotype.Service; + +import java.util.Objects; + +@Service +public class ScoreConfigRegulateHandler implements IRegulateHandler { + + @Override + public String getName() { + return "scoreConfig"; + } + + @Override + public void regulateConfig(IProcessStepInternalHandler processStepInternalHandler, JSONObject oldConfigObj, JSONObject newConfigObj) { + JSONObject scoreConfig = oldConfigObj.getJSONObject("scoreConfig"); + JSONObject scoreConfigObj = new JSONObject(); + Integer isActive = 0; + if (MapUtils.isNotEmpty(scoreConfig)) { + isActive = scoreConfig.getInteger("isActive"); + if (Objects.equals(isActive, 1)) { + Long scoreTemplateId = scoreConfig.getLong("scoreTemplateId"); + Integer isAuto = scoreConfig.getInteger("isAuto"); + if (Objects.equals(isAuto, 1)) { + String autoTimeType = "naturalDay"; + Integer autoTime = 3; + JSONObject autoConfig = scoreConfig.getJSONObject("config"); + if (MapUtils.isNotEmpty(autoConfig)) { + autoTimeType = autoConfig.getString("autoTimeType"); + autoTime = autoConfig.getInteger("autoTime"); + } + JSONObject autoConfigObj = new JSONObject(); + autoConfigObj.put("autoTimeType", autoTimeType); + autoConfigObj.put("autoTime", autoTime); + scoreConfigObj.put("config", autoConfigObj); + } else { + isAuto = 0; + } + scoreConfigObj.put("scoreTemplateId", scoreTemplateId); + scoreConfigObj.put("isAuto", isAuto); + } + } + scoreConfigObj.put("isActive", isActive); + newConfigObj.put("scoreConfig", scoreConfigObj); + } +} diff --git a/src/main/java/neatlogic/module/process/stephandler/regulatehandler/SlaListRegulateHandler.java b/src/main/java/neatlogic/module/process/stephandler/regulatehandler/SlaListRegulateHandler.java new file mode 100644 index 0000000000000000000000000000000000000000..dba4e6743b67a7e02d1b35a6a058a5135b16b001 --- /dev/null +++ b/src/main/java/neatlogic/module/process/stephandler/regulatehandler/SlaListRegulateHandler.java @@ -0,0 +1,117 @@ +/* + * 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.stephandler.regulatehandler; + +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import neatlogic.framework.process.dto.processconfig.SlaCalculatePolicyVo; +import neatlogic.framework.process.dto.processconfig.SlaNotifyPolicyVo; +import neatlogic.framework.process.dto.processconfig.SlaTransferPolicyVo; +import neatlogic.framework.process.exception.process.ProcessConfigException; +import neatlogic.framework.process.stephandler.core.IProcessStepInternalHandler; +import neatlogic.framework.process.stephandler.core.IRegulateHandler; +import neatlogic.framework.process.stephandler.core.ProcessMessageManager; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.collections4.ListUtils; +import org.apache.commons.collections4.MapUtils; +import org.springframework.stereotype.Service; + +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; + +@Service +public class SlaListRegulateHandler implements IRegulateHandler { + + @Override + public String getName() { + return "slaList"; + } + + @Override + public void regulateConfig(IProcessStepInternalHandler processStepInternalHandler, JSONObject oldConfigObj, JSONObject newConfigObj) { + JSONArray slaList = oldConfigObj.getJSONArray("slaList"); + JSONArray slaArray = new JSONArray(); + if (CollectionUtils.isNotEmpty(slaList)) { + List effectiveStepUuidList = ProcessMessageManager.getEffectiveStepUuidList(); + for (int i = 0; i < slaList.size(); i++) { + JSONObject sla = slaList.getJSONObject(i); + if (MapUtils.isNotEmpty(sla)) { + JSONObject slaObj = new JSONObject(); + String slaName = sla.getString("name"); + List processStepUuidList = sla.getJSONArray("processStepUuidList").toJavaList(String.class); + if (processStepUuidList == null) { + processStepUuidList = new ArrayList<>(); + } else { + processStepUuidList.removeIf(Objects::isNull); + } + List list = ListUtils.removeAll(processStepUuidList, effectiveStepUuidList); + if (CollectionUtils.isNotEmpty(list)) { + throw new ProcessConfigException(ProcessConfigException.Type.SLA, slaName); + } + slaObj.put("processStepUuidList", processStepUuidList); + List slaTransferPolicyList = new ArrayList<>(); + JSONArray transferPolicyList = sla.getJSONArray("transferPolicyList"); + if (CollectionUtils.isNotEmpty(transferPolicyList)) { + transferPolicyList.removeIf(Objects::isNull); + for (int j = 0; j < transferPolicyList.size(); j++) { + SlaTransferPolicyVo slaTransferPolicyVo = transferPolicyList.getObject(j, SlaTransferPolicyVo.class); + if (slaTransferPolicyVo != null) { + slaTransferPolicyList.add(slaTransferPolicyVo); + } + } + } + slaObj.put("transferPolicyList", slaTransferPolicyList); + + List calculatePolicyArray = new ArrayList<>(); + JSONArray calculatePolicyList = sla.getJSONArray("calculatePolicyList"); + if (CollectionUtils.isNotEmpty(calculatePolicyList)) { + calculatePolicyList.removeIf(Objects::isNull); + for (int j = 0; j < calculatePolicyList.size(); j++) { + SlaCalculatePolicyVo slaCalculatePolicyVo = calculatePolicyList.getObject(j, SlaCalculatePolicyVo.class); + if (slaCalculatePolicyVo != null) { + calculatePolicyArray.add(slaCalculatePolicyVo); + } + } + } + slaObj.put("calculatePolicyList", calculatePolicyArray); + + List notifyPolicyArray = new ArrayList<>(); + JSONArray notifyPolicyList = sla.getJSONArray("notifyPolicyList"); + if (CollectionUtils.isNotEmpty(notifyPolicyList)) { + notifyPolicyList.removeIf(Objects::isNull); + for (int j = 0; j < notifyPolicyList.size(); j++) { + SlaNotifyPolicyVo slaNotifyPolicyVo = notifyPolicyList.getObject(j, SlaNotifyPolicyVo.class); + if (slaNotifyPolicyVo != null) { + notifyPolicyArray.add(slaNotifyPolicyVo); + } + } + } + slaObj.put("notifyPolicyList", notifyPolicyArray); + String slaUuid = sla.getString("uuid"); + String calculateHandler = sla.getString("calculateHandler"); + slaObj.put("uuid", slaUuid); + slaObj.put("name", slaName); + slaObj.put("calculateHandler", calculateHandler); + slaArray.add(slaObj); + } + } + } + newConfigObj.put("slaList", slaArray); + } +} diff --git a/src/main/java/neatlogic/module/process/stephandler/utilhandler/ConditionProcessUtilHandler.java b/src/main/java/neatlogic/module/process/stephandler/utilhandler/ConditionProcessUtilHandler.java index d1d8c0e7b0e9b541d68e98bdd2b8ea24ccf79389..767e942a5e6eb517b19e9f991d6408262884031a 100755 --- a/src/main/java/neatlogic/module/process/stephandler/utilhandler/ConditionProcessUtilHandler.java +++ b/src/main/java/neatlogic/module/process/stephandler/utilhandler/ConditionProcessUtilHandler.java @@ -1,20 +1,12 @@ package neatlogic.module.process.stephandler.utilhandler; -import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import neatlogic.framework.process.constvalue.ProcessStepHandlerType; import neatlogic.framework.process.dto.ProcessStepVo; import neatlogic.framework.process.dto.ProcessTaskStepVo; -import neatlogic.framework.process.dto.processconfig.MoveonConfigVo; import neatlogic.framework.process.stephandler.core.ProcessStepInternalHandlerBase; -import org.apache.commons.collections4.CollectionUtils; -import org.apache.commons.lang3.StringUtils; import org.springframework.stereotype.Service; -import java.util.ArrayList; -import java.util.List; -import java.util.Objects; - @Service public class ConditionProcessUtilHandler extends ProcessStepInternalHandlerBase { @@ -56,28 +48,45 @@ public class ConditionProcessUtilHandler extends ProcessStepInternalHandlerBase } @Override - public JSONObject regulateProcessStepConfig(JSONObject configObj) { - if (configObj == null) { - configObj = new JSONObject(); - } - JSONObject resultObj = new JSONObject(); - List moveonConfigList = new ArrayList<>(); - JSONArray moveonConfigArray = configObj.getJSONArray("moveonConfigList"); - if(CollectionUtils.isNotEmpty(moveonConfigArray)){ - moveonConfigArray.removeIf(Objects::isNull); - for(int i = 0; i < moveonConfigArray.size(); i++){ - MoveonConfigVo moveonConfigVo = moveonConfigArray.getObject(i, MoveonConfigVo.class); - if(moveonConfigVo != null){ - moveonConfigList.add(moveonConfigVo); - } - } - } - resultObj.put("moveonConfigList", moveonConfigList); - String formTag = configObj.getString("formTag"); - if (StringUtils.isBlank(formTag)) { - formTag = StringUtils.EMPTY; - } - resultObj.put("formTag", formTag); - return resultObj; + public String[] getRegulateKeyList() { + return new String[]{"moveonConfigList", "formTag"}; } + +// @Override +// public JSONObject regulateProcessStepConfig(JSONObject configObj) { +// if (configObj == null) { +// configObj = new JSONObject(); +// } +// JSONObject resultObj = new JSONObject(); +// List moveonConfigList = new ArrayList<>(); +// JSONArray moveonConfigArray = configObj.getJSONArray("moveonConfigList"); +// if(CollectionUtils.isNotEmpty(moveonConfigArray)){ +// moveonConfigArray.removeIf(Objects::isNull); +// List effectiveStepUuidList = ProcessMessageManager.getEffectiveStepUuidList(); +// for(int i = 0; i < moveonConfigArray.size(); i++){ +// MoveonConfigVo moveonConfigVo = moveonConfigArray.getObject(i, MoveonConfigVo.class); +// if(moveonConfigVo != null){ +// List targetStepList = moveonConfigVo.getTargetStepList(); +// if (CollectionUtils.isNotEmpty(targetStepList)) { +// List list = ListUtils.removeAll(targetStepList, effectiveStepUuidList); +// if (CollectionUtils.isNotEmpty(list)) { +// throw new RuntimeException("条件步骤流转规则设置中存在无效的步骤"); +// } +// } +//// targetStepList.removeIf(e -> !effectiveStepUuidList.contains(e)); +//// if (CollectionUtils.isEmpty(targetStepList)) { +//// continue; +//// } +// moveonConfigList.add(moveonConfigVo); +// } +// } +// } +// resultObj.put("moveonConfigList", moveonConfigList); +// String formTag = configObj.getString("formTag"); +// if (StringUtils.isBlank(formTag)) { +// formTag = StringUtils.EMPTY; +// } +// resultObj.put("formTag", formTag); +// return resultObj; +// } } diff --git a/src/main/java/neatlogic/module/process/stephandler/utilhandler/EndProcessUtilHandler.java b/src/main/java/neatlogic/module/process/stephandler/utilhandler/EndProcessUtilHandler.java index 6d837546ce4bf9985bf442265ff8bca722b3fda6..d79376af2fe9d225c808d81cd71123e241f08b9f 100644 --- a/src/main/java/neatlogic/module/process/stephandler/utilhandler/EndProcessUtilHandler.java +++ b/src/main/java/neatlogic/module/process/stephandler/utilhandler/EndProcessUtilHandler.java @@ -1,30 +1,15 @@ package neatlogic.module.process.stephandler.utilhandler; -import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; -import neatlogic.framework.crossover.CrossoverServiceFactory; -import neatlogic.framework.notify.crossover.INotifyServiceCrossoverService; -import neatlogic.framework.notify.dto.InvokeNotifyPolicyConfigVo; import neatlogic.framework.process.constvalue.ProcessStepHandlerType; import neatlogic.framework.process.constvalue.ProcessTaskOperationType; import neatlogic.framework.process.dto.ProcessStepVo; import neatlogic.framework.process.dto.ProcessTaskStepVo; -import neatlogic.framework.process.dto.processconfig.ActionConfigVo; -import neatlogic.framework.process.dto.processconfig.SlaCalculatePolicyVo; -import neatlogic.framework.process.dto.processconfig.SlaNotifyPolicyVo; -import neatlogic.framework.process.dto.processconfig.SlaTransferPolicyVo; import neatlogic.framework.process.stephandler.core.ProcessStepInternalHandlerBase; import neatlogic.framework.process.util.ProcessConfigUtil; -import neatlogic.module.process.notify.handler.TaskNotifyPolicyHandler; -import org.apache.commons.collections4.CollectionUtils; -import org.apache.commons.collections4.MapUtils; import org.springframework.stereotype.Service; -import java.util.ArrayList; -import java.util.List; -import java.util.Objects; - @Service public class EndProcessUtilHandler extends ProcessStepInternalHandlerBase { @@ -52,6 +37,10 @@ public class EndProcessUtilHandler extends ProcessStepInternalHandlerBase { public void updateProcessTaskStepUserAndWorker(Long processTaskId, Long processTaskStepId) { } + @Override + public String[] getRegulateKeyList() { + return new String[]{"processConfig", "formConfig", "scoreConfig", "slaList"}; + } @Override public JSONObject makeupConfig(JSONObject configObj) { @@ -73,199 +62,210 @@ public class EndProcessUtilHandler extends ProcessStepInternalHandlerBase { return resultObj; } - @Override - public JSONObject regulateProcessStepConfig(JSONObject configObj) { - if (configObj == null) { - configObj = new JSONObject(); - } - JSONObject resultObj = new JSONObject(); - /* 流程设置 **/ - JSONObject processConfig = configObj.getJSONObject("processConfig"); - JSONObject processObj = regulateProcessConfig(processConfig); - resultObj.put("processConfig", processObj); - /* 表单设置 **/ - JSONObject formConfig = configObj.getJSONObject("formConfig"); - JSONObject formObj = regulateFormConfig(formConfig); - resultObj.put("formConfig", formObj); - /* 评分设置 **/ - JSONObject scoreConfig = configObj.getJSONObject("scoreConfig"); - JSONObject scoreConfigObj = regulateScoreConfig(scoreConfig); - resultObj.put("scoreConfig", scoreConfigObj); - /* 时效设置 **/ - JSONArray slaList = configObj.getJSONArray("slaList"); - JSONArray slaArray = regulateSlaList(slaList); - resultObj.put("slaList", slaArray); - return resultObj; - } - - private JSONObject regulateProcessConfig(JSONObject processConfig) { - JSONObject processObj = new JSONObject(); - if (processConfig == null) { - processConfig = new JSONObject(); - } - String uuid = processConfig.getString("uuid"); - String name = processConfig.getString("name"); - processObj.put("uuid", uuid); - processObj.put("name", name); - /* 授权 **/ - ProcessTaskOperationType[] stepActions = { - ProcessTaskOperationType.PROCESSTASK_ABORT, - ProcessTaskOperationType.PROCESSTASK_UPDATE, - ProcessTaskOperationType.PROCESSTASK_URGE - }; - JSONArray authorityList = null; - Integer enableAuthority = processConfig.getInteger("enableAuthority"); - if (Objects.equals(enableAuthority, 1)) { - authorityList = processConfig.getJSONArray("authorityList"); - } else { - enableAuthority = 0; - } - processObj.put("enableAuthority", enableAuthority); - JSONArray authorityArray = ProcessConfigUtil.regulateAuthorityList(authorityList, stepActions); - processObj.put("authorityList", authorityArray); - - /* 通知 **/ - JSONObject notifyPolicyConfig = processConfig.getJSONObject("notifyPolicyConfig"); - INotifyServiceCrossoverService notifyServiceCrossoverService = CrossoverServiceFactory.getApi(INotifyServiceCrossoverService.class); - InvokeNotifyPolicyConfigVo invokeNotifyPolicyConfigVo = notifyServiceCrossoverService.regulateNotifyPolicyConfig(notifyPolicyConfig, TaskNotifyPolicyHandler.class); - processObj.put("notifyPolicyConfig", invokeNotifyPolicyConfigVo); - - /* 动作 **/ - JSONObject actionConfig = processConfig.getJSONObject("actionConfig"); - ActionConfigVo actionConfigVo = JSON.toJavaObject(actionConfig, ActionConfigVo.class); - if (actionConfigVo == null) { - actionConfigVo = new ActionConfigVo(); - } - actionConfigVo.setHandler(TaskNotifyPolicyHandler.class.getName()); - processObj.put("actionConfig", actionConfigVo); - - Integer enableMarkRepeat = processConfig.getInteger("enableMarkRepeat"); - enableMarkRepeat = enableMarkRepeat == null ? 0 : enableMarkRepeat; - processObj.put("enableMarkRepeat", enableMarkRepeat); - return processObj; - } - - private JSONObject regulateFormConfig(JSONObject formConfig) { - String formUuid = ""; - String formName = ""; -// List formAuthorityList = new ArrayList<>(); - if (MapUtils.isNotEmpty(formConfig)) { - formUuid = formConfig.getString("uuid"); - formName = formConfig.getString("name"); -// JSONArray authorityList = formConfig.getJSONArray("authorityList"); -// if (CollectionUtils.isNotEmpty(authorityList)) { -// authorityList.removeIf(e -> e == null); -// for (int i = 0; i < authorityList.size(); i++) { -// FormAttributeAuthorityVo formAttributeAuthorityVo = authorityList.getObject(i, FormAttributeAuthorityVo.class); -// if (formAttributeAuthorityVo != null) { -// formAuthorityList.add(formAttributeAuthorityVo); +// @Override +// public JSONObject regulateProcessStepConfig(JSONObject configObj) { +// if (configObj == null) { +// configObj = new JSONObject(); +// } +// JSONObject resultObj = new JSONObject(); +// /* 流程设置 **/ +// JSONObject processConfig = configObj.getJSONObject("processConfig"); +// JSONObject processObj = regulateProcessConfig(processConfig); +// resultObj.put("processConfig", processObj); +// /* 表单设置 **/ +// JSONObject formConfig = configObj.getJSONObject("formConfig"); +// JSONObject formObj = regulateFormConfig(formConfig); +// resultObj.put("formConfig", formObj); +// /* 评分设置 **/ +// JSONObject scoreConfig = configObj.getJSONObject("scoreConfig"); +// JSONObject scoreConfigObj = regulateScoreConfig(scoreConfig); +// resultObj.put("scoreConfig", scoreConfigObj); +// /* 时效设置 **/ +// JSONArray slaList = configObj.getJSONArray("slaList"); +// JSONArray slaArray = regulateSlaList(slaList); +// resultObj.put("slaList", slaArray); +// return resultObj; +// } +// +// private JSONObject regulateProcessConfig(JSONObject processConfig) { +// JSONObject processObj = new JSONObject(); +// if (processConfig == null) { +// processConfig = new JSONObject(); +// } +// String uuid = processConfig.getString("uuid"); +// String name = processConfig.getString("name"); +// processObj.put("uuid", uuid); +// processObj.put("name", name); +// /* 授权 **/ +// ProcessTaskOperationType[] stepActions = { +// ProcessTaskOperationType.PROCESSTASK_ABORT, +// ProcessTaskOperationType.PROCESSTASK_UPDATE, +// ProcessTaskOperationType.PROCESSTASK_URGE +// }; +// JSONArray authorityList = null; +// Integer enableAuthority = processConfig.getInteger("enableAuthority"); +// if (Objects.equals(enableAuthority, 1)) { +// authorityList = processConfig.getJSONArray("authorityList"); +// } else { +// enableAuthority = 0; +// } +// processObj.put("enableAuthority", enableAuthority); +// JSONArray authorityArray = ProcessConfigUtil.regulateAuthorityList(authorityList, stepActions); +// processObj.put("authorityList", authorityArray); +// +// /* 通知 **/ +// JSONObject notifyPolicyConfig = processConfig.getJSONObject("notifyPolicyConfig"); +// INotifyServiceCrossoverService notifyServiceCrossoverService = CrossoverServiceFactory.getApi(INotifyServiceCrossoverService.class); +// InvokeNotifyPolicyConfigVo invokeNotifyPolicyConfigVo = notifyServiceCrossoverService.regulateNotifyPolicyConfig(notifyPolicyConfig, TaskNotifyPolicyHandler.class); +// processObj.put("notifyPolicyConfig", invokeNotifyPolicyConfigVo); +// +// /* 动作 **/ +// JSONObject actionConfig = processConfig.getJSONObject("actionConfig"); +// ActionConfigVo actionConfigVo = JSON.toJavaObject(actionConfig, ActionConfigVo.class); +// if (actionConfigVo == null) { +// actionConfigVo = new ActionConfigVo(); +// } +// actionConfigVo.setHandler(TaskNotifyPolicyHandler.class.getName()); +// processObj.put("actionConfig", actionConfigVo); +// +// Integer enableMarkRepeat = processConfig.getInteger("enableMarkRepeat"); +// enableMarkRepeat = enableMarkRepeat == null ? 0 : enableMarkRepeat; +// processObj.put("enableMarkRepeat", enableMarkRepeat); +// return processObj; +// } +// +// private JSONObject regulateFormConfig(JSONObject formConfig) { +// String formUuid = ""; +// String formName = ""; +//// List formAuthorityList = new ArrayList<>(); +// if (MapUtils.isNotEmpty(formConfig)) { +// formUuid = formConfig.getString("uuid"); +// formName = formConfig.getString("name"); +//// JSONArray authorityList = formConfig.getJSONArray("authorityList"); +//// if (CollectionUtils.isNotEmpty(authorityList)) { +//// authorityList.removeIf(e -> e == null); +//// for (int i = 0; i < authorityList.size(); i++) { +//// FormAttributeAuthorityVo formAttributeAuthorityVo = authorityList.getObject(i, FormAttributeAuthorityVo.class); +//// if (formAttributeAuthorityVo != null) { +//// formAuthorityList.add(formAttributeAuthorityVo); +//// } +//// } +//// } +// } +// JSONObject formObj = new JSONObject(); +// formObj.put("uuid", formUuid); +// formObj.put("name", formName); +//// formObj.put("authorityList", formAuthorityList); +// return formObj; +// } +// +// private JSONObject regulateScoreConfig(JSONObject scoreConfig) { +// JSONObject scoreConfigObj = new JSONObject(); +// Integer isActive = 0; +// if (MapUtils.isNotEmpty(scoreConfig)) { +// isActive = scoreConfig.getInteger("isActive"); +// if (Objects.equals(isActive, 1)) { +// Long scoreTemplateId = scoreConfig.getLong("scoreTemplateId"); +// Integer isAuto = scoreConfig.getInteger("isAuto"); +// if (Objects.equals(isAuto, 1)) { +// String autoTimeType = "naturalDay"; +// Integer autoTime = 3; +// JSONObject autoConfig = scoreConfig.getJSONObject("config"); +// if (MapUtils.isNotEmpty(autoConfig)) { +// autoTimeType = autoConfig.getString("autoTimeType"); +// autoTime = autoConfig.getInteger("autoTime"); // } +// JSONObject autoConfigObj = new JSONObject(); +// autoConfigObj.put("autoTimeType", autoTimeType); +// autoConfigObj.put("autoTime", autoTime); +// scoreConfigObj.put("config", autoConfigObj); +// } else { +// isAuto = 0; // } +// scoreConfigObj.put("scoreTemplateId", scoreTemplateId); +// scoreConfigObj.put("isAuto", isAuto); // } - } - JSONObject formObj = new JSONObject(); - formObj.put("uuid", formUuid); - formObj.put("name", formName); -// formObj.put("authorityList", formAuthorityList); - return formObj; - } - - private JSONObject regulateScoreConfig(JSONObject scoreConfig) { - JSONObject scoreConfigObj = new JSONObject(); - Integer isActive = 0; - if (MapUtils.isNotEmpty(scoreConfig)) { - isActive = scoreConfig.getInteger("isActive"); - if (Objects.equals(isActive, 1)) { - Long scoreTemplateId = scoreConfig.getLong("scoreTemplateId"); - Integer isAuto = scoreConfig.getInteger("isAuto"); - if (Objects.equals(isAuto, 1)) { - String autoTimeType = "naturalDay"; - Integer autoTime = 3; - JSONObject autoConfig = scoreConfig.getJSONObject("config"); - if (MapUtils.isNotEmpty(autoConfig)) { - autoTimeType = autoConfig.getString("autoTimeType"); - autoTime = autoConfig.getInteger("autoTime"); - } - JSONObject autoConfigObj = new JSONObject(); - autoConfigObj.put("autoTimeType", autoTimeType); - autoConfigObj.put("autoTime", autoTime); - scoreConfigObj.put("config", autoConfigObj); - } else { - isAuto = 0; - } - scoreConfigObj.put("scoreTemplateId", scoreTemplateId); - scoreConfigObj.put("isAuto", isAuto); - } - } - scoreConfigObj.put("isActive", isActive); - return scoreConfigObj; - } - - private JSONArray regulateSlaList(JSONArray slaList) { - JSONArray slaArray = new JSONArray(); - if (CollectionUtils.isNotEmpty(slaList)) { - for (int i = 0; i < slaList.size(); i++) { - JSONObject sla = slaList.getJSONObject(i); - if (MapUtils.isNotEmpty(sla)) { - JSONObject slaObj = new JSONObject(); - List slaTransferPolicyList = new ArrayList<>(); - JSONArray transferPolicyList = sla.getJSONArray("transferPolicyList"); - if (CollectionUtils.isNotEmpty(transferPolicyList)) { - transferPolicyList.removeIf(Objects::isNull); - for (int j = 0; j < transferPolicyList.size(); j++) { - SlaTransferPolicyVo slaTransferPolicyVo = transferPolicyList.getObject(j, SlaTransferPolicyVo.class); - if (slaTransferPolicyVo != null) { - slaTransferPolicyList.add(slaTransferPolicyVo); - } - } - } - slaObj.put("transferPolicyList", slaTransferPolicyList); - - List processStepUuidList = sla.getJSONArray("processStepUuidList").toJavaList(String.class); - if (processStepUuidList == null) { - processStepUuidList = new ArrayList<>(); - } else { - processStepUuidList.removeIf(Objects::isNull); - } - slaObj.put("processStepUuidList", processStepUuidList); - - List calculatePolicyArray = new ArrayList<>(); - JSONArray calculatePolicyList = sla.getJSONArray("calculatePolicyList"); - if (CollectionUtils.isNotEmpty(calculatePolicyList)) { - calculatePolicyList.removeIf(Objects::isNull); - for (int j = 0; j < calculatePolicyList.size(); j++) { - SlaCalculatePolicyVo slaCalculatePolicyVo = calculatePolicyList.getObject(j, SlaCalculatePolicyVo.class); - if (slaCalculatePolicyVo != null) { - calculatePolicyArray.add(slaCalculatePolicyVo); - } - } - } - slaObj.put("calculatePolicyList", calculatePolicyArray); - - List notifyPolicyArray = new ArrayList<>(); - JSONArray notifyPolicyList = sla.getJSONArray("notifyPolicyList"); - if (CollectionUtils.isNotEmpty(notifyPolicyList)) { - notifyPolicyList.removeIf(Objects::isNull); - for (int j = 0; j < notifyPolicyList.size(); j++) { - SlaNotifyPolicyVo slaNotifyPolicyVo = notifyPolicyList.getObject(j, SlaNotifyPolicyVo.class); - if (slaNotifyPolicyVo != null) { -// NotifyPolicyConfigVo notifyPolicyConfigVo = slaNotifyPolicyVo.getNotifyPolicyConfig(); -// notifyPolicyConfigVo.setHandler(SlaNotifyPolicyHandler.class.getName()); - notifyPolicyArray.add(slaNotifyPolicyVo); - } - } - } - slaObj.put("notifyPolicyList", notifyPolicyArray); - String slaUuid = sla.getString("uuid"); - String slaName = sla.getString("name"); - String calculateHandler = sla.getString("calculateHandler"); - slaObj.put("uuid", slaUuid); - slaObj.put("name", slaName); - slaObj.put("calculateHandler", calculateHandler); - slaArray.add(slaObj); - } - } - } - return slaArray; - } +// } +// scoreConfigObj.put("isActive", isActive); +// return scoreConfigObj; +// } +// +// private JSONArray regulateSlaList(JSONArray slaList) { +// JSONArray slaArray = new JSONArray(); +// if (CollectionUtils.isNotEmpty(slaList)) { +// List effectiveStepUuidList = ProcessMessageManager.getEffectiveStepUuidList(); +// for (int i = 0; i < slaList.size(); i++) { +// JSONObject sla = slaList.getJSONObject(i); +// if (MapUtils.isNotEmpty(sla)) { +// JSONObject slaObj = new JSONObject(); +// String slaName = sla.getString("name"); +// List processStepUuidList = sla.getJSONArray("processStepUuidList").toJavaList(String.class); +// if (processStepUuidList == null) { +// processStepUuidList = new ArrayList<>(); +// } else { +// processStepUuidList.removeIf(Objects::isNull); +// } +// List list = ListUtils.removeAll(processStepUuidList, effectiveStepUuidList); +// if (CollectionUtils.isNotEmpty(list)) { +// throw new RuntimeException("时效设置-时效aaa的关联步骤中存在无效的步骤"); +// } +//// if (CollectionUtils.isEmpty(processStepUuidList)) { +//// continue; +//// } +//// processStepUuidList.removeIf(e -> !effectiveStepUuidList.contains(e)); +//// if (CollectionUtils.isEmpty(processStepUuidList)) { +//// continue; +//// } +// slaObj.put("processStepUuidList", processStepUuidList); +// List slaTransferPolicyList = new ArrayList<>(); +// JSONArray transferPolicyList = sla.getJSONArray("transferPolicyList"); +// if (CollectionUtils.isNotEmpty(transferPolicyList)) { +// transferPolicyList.removeIf(Objects::isNull); +// for (int j = 0; j < transferPolicyList.size(); j++) { +// SlaTransferPolicyVo slaTransferPolicyVo = transferPolicyList.getObject(j, SlaTransferPolicyVo.class); +// if (slaTransferPolicyVo != null) { +// slaTransferPolicyList.add(slaTransferPolicyVo); +// } +// } +// } +// slaObj.put("transferPolicyList", slaTransferPolicyList); +// +// List calculatePolicyArray = new ArrayList<>(); +// JSONArray calculatePolicyList = sla.getJSONArray("calculatePolicyList"); +// if (CollectionUtils.isNotEmpty(calculatePolicyList)) { +// calculatePolicyList.removeIf(Objects::isNull); +// for (int j = 0; j < calculatePolicyList.size(); j++) { +// SlaCalculatePolicyVo slaCalculatePolicyVo = calculatePolicyList.getObject(j, SlaCalculatePolicyVo.class); +// if (slaCalculatePolicyVo != null) { +// calculatePolicyArray.add(slaCalculatePolicyVo); +// } +// } +// } +// slaObj.put("calculatePolicyList", calculatePolicyArray); +// +// List notifyPolicyArray = new ArrayList<>(); +// JSONArray notifyPolicyList = sla.getJSONArray("notifyPolicyList"); +// if (CollectionUtils.isNotEmpty(notifyPolicyList)) { +// notifyPolicyList.removeIf(Objects::isNull); +// for (int j = 0; j < notifyPolicyList.size(); j++) { +// SlaNotifyPolicyVo slaNotifyPolicyVo = notifyPolicyList.getObject(j, SlaNotifyPolicyVo.class); +// if (slaNotifyPolicyVo != null) { +//// NotifyPolicyConfigVo notifyPolicyConfigVo = slaNotifyPolicyVo.getNotifyPolicyConfig(); +//// notifyPolicyConfigVo.setHandler(SlaNotifyPolicyHandler.class.getName()); +// notifyPolicyArray.add(slaNotifyPolicyVo); +// } +// } +// } +// slaObj.put("notifyPolicyList", notifyPolicyArray); +// String slaUuid = sla.getString("uuid"); +// String calculateHandler = sla.getString("calculateHandler"); +// slaObj.put("uuid", slaUuid); +// slaObj.put("name", slaName); +// slaObj.put("calculateHandler", calculateHandler); +// slaArray.add(slaObj); +// } +// } +// } +// return slaArray; +// } }