diff --git a/src/main/java/neatlogic/module/autoexec/job/callback/AutoexecJobNotifyCallbackHandler.java b/src/main/java/neatlogic/module/autoexec/job/callback/AutoexecJobNotifyCallbackHandler.java index 2605fe324a655ae71f24d429a3d74ed3ca0cc7fd..1d15aaf2f6b37f2048ec4b731cf2b915a9a258b4 100644 --- a/src/main/java/neatlogic/module/autoexec/job/callback/AutoexecJobNotifyCallbackHandler.java +++ b/src/main/java/neatlogic/module/autoexec/job/callback/AutoexecJobNotifyCallbackHandler.java @@ -65,7 +65,7 @@ public class AutoexecJobNotifyCallbackHandler extends AutoexecJobCallbackBase { @Override public Boolean getIsNeedCallback(AutoexecJobVo jobVo) { - AutoexecJobNotifyTriggerType trigger = AutoexecJobNotifyTriggerType.getTrigger(jobVo.getStatus()); + AutoexecJobNotifyTriggerType trigger = AutoexecJobNotifyTriggerType.getTriggerByStatus(jobVo.getStatus()); if (trigger != null) { AutoexecJobVo jobInfo; // 开启一个新事务来查询父事务提交前的作业状态,如果新事务查出来的状态与当前jobVo的状态不同,则表示该状态未通知过 @@ -86,7 +86,7 @@ public class AutoexecJobNotifyCallbackHandler extends AutoexecJobCallbackBase { @Override public void doService(Long invokeId, AutoexecJobVo jobVo) { - AutoexecJobNotifyTriggerType trigger = AutoexecJobNotifyTriggerType.getTrigger(jobVo.getStatus()); + AutoexecJobNotifyTriggerType trigger = AutoexecJobNotifyTriggerType.getTriggerByStatus(jobVo.getStatus()); if (trigger == null) { return; } diff --git a/src/main/java/neatlogic/module/autoexec/notify/handler/AutoexecCombopNotifyPolicyHandler.java b/src/main/java/neatlogic/module/autoexec/notify/handler/AutoexecCombopNotifyPolicyHandler.java index 6cf7cdb26009689b3b2c8ae3b84141e5d83d5f2d..8d706f6b3b755a313716ce480833b91567b3ac1c 100644 --- a/src/main/java/neatlogic/module/autoexec/notify/handler/AutoexecCombopNotifyPolicyHandler.java +++ b/src/main/java/neatlogic/module/autoexec/notify/handler/AutoexecCombopNotifyPolicyHandler.java @@ -20,10 +20,8 @@ import neatlogic.framework.autoexec.auth.AUTOEXEC_COMBOP_ADD; import neatlogic.framework.autoexec.constvalue.AutoexecJobNotifyParam; import neatlogic.framework.autoexec.constvalue.AutoexecJobNotifyTriggerType; import neatlogic.framework.dto.ConditionParamVo; +import neatlogic.framework.notify.core.NotifyPolicyHandlerBase; import neatlogic.framework.notify.dto.NotifyTriggerVo; -import neatlogic.framework.process.constvalue.ProcessTaskGroupSearch; -import neatlogic.framework.process.constvalue.ProcessUserType; -import neatlogic.framework.process.notify.core.ProcessTaskNotifyHandlerBase; import org.springframework.stereotype.Component; import java.util.ArrayList; @@ -34,7 +32,7 @@ import java.util.List; * @since: 2021/4/15 9:47 **/ @Component -public class AutoexecCombopNotifyPolicyHandler extends ProcessTaskNotifyHandlerBase { +public class AutoexecCombopNotifyPolicyHandler extends NotifyPolicyHandlerBase { @Override public String getName() { return "term.autoexec.combop"; @@ -49,7 +47,7 @@ public class AutoexecCombopNotifyPolicyHandler extends ProcessTaskNotifyHandlerB } @Override - protected List myCustomNotifyTriggerList() { + protected List myNotifyTriggerList() { List returnList = new ArrayList<>(); for (AutoexecJobNotifyTriggerType triggerType : AutoexecJobNotifyTriggerType.values()) { returnList.add(new NotifyTriggerVo(triggerType)); @@ -58,7 +56,7 @@ public class AutoexecCombopNotifyPolicyHandler extends ProcessTaskNotifyHandlerB } @Override - protected List myCustomSystemParamList() { + protected List mySystemParamList() { List notifyPolicyParamList = new ArrayList<>(); for (AutoexecJobNotifyParam param : AutoexecJobNotifyParam.values()) { notifyPolicyParamList.add(createConditionParam(param)); @@ -67,9 +65,12 @@ public class AutoexecCombopNotifyPolicyHandler extends ProcessTaskNotifyHandlerB } @Override - protected void myCustomAuthorityConfig(JSONObject config) { - List excludeList = config.getJSONArray("excludeList").toJavaList(String.class); - excludeList.add(ProcessTaskGroupSearch.PROCESSUSERTYPE.getValue() + "#" + ProcessUserType.MINOR.getValue()); - config.put("excludeList", excludeList); + protected List mySystemConditionOptionList() { + return new ArrayList<>(); + } + + @Override + protected void myAuthorityConfig(JSONObject config) { + } } diff --git a/src/main/java/neatlogic/module/autoexec/notify/handler/AutoexecNotifyPolicyHandler.java b/src/main/java/neatlogic/module/autoexec/notify/handler/AutoexecNotifyPolicyHandler.java new file mode 100644 index 0000000000000000000000000000000000000000..bef46df486839bfe289dc522d9fd90edf620f4ad --- /dev/null +++ b/src/main/java/neatlogic/module/autoexec/notify/handler/AutoexecNotifyPolicyHandler.java @@ -0,0 +1,76 @@ +/*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.autoexec.notify.handler; + +import com.alibaba.fastjson.JSONObject; +import neatlogic.framework.autoexec.auth.AUTOEXEC_COMBOP_ADD; +import neatlogic.framework.autoexec.constvalue.AutoexecNotifyParam; +import neatlogic.framework.autoexec.constvalue.AutoexecNotifyTriggerType; +import neatlogic.framework.dto.ConditionParamVo; +import neatlogic.framework.notify.dto.NotifyTriggerVo; +import neatlogic.framework.process.constvalue.ProcessTaskGroupSearch; +import neatlogic.framework.process.constvalue.ProcessUserType; +import neatlogic.framework.process.notify.core.ProcessTaskNotifyHandlerBase; +import org.springframework.stereotype.Component; + +import java.util.ArrayList; +import java.util.List; + +@Component +public class AutoexecNotifyPolicyHandler extends ProcessTaskNotifyHandlerBase { + @Override + public String getName() { + return "term.autoexec.groupname"; + } + + /** + * 绑定权限,每种handler对应不同的权限 + */ + @Override + public String getAuthName() { + return AUTOEXEC_COMBOP_ADD.class.getSimpleName(); + } + + @Override + protected List myCustomNotifyTriggerList() { + List returnList = new ArrayList<>(); + for (AutoexecNotifyTriggerType triggerType : AutoexecNotifyTriggerType.values()) { + returnList.add(new NotifyTriggerVo(triggerType)); + } + return returnList; + } + + @Override + protected List myCustomSystemParamList() { + List notifyPolicyParamList = new ArrayList<>(); + for (AutoexecNotifyParam param : AutoexecNotifyParam.values()) { + notifyPolicyParamList.add(createConditionParam(param)); + } + return notifyPolicyParamList; + } + + @Override + protected void myCustomAuthorityConfig(JSONObject config) { + List excludeList = config.getJSONArray("excludeList").toJavaList(String.class); + excludeList.add(ProcessTaskGroupSearch.PROCESSUSERTYPE.getValue() + "#" + ProcessUserType.MINOR.getValue()); + config.put("excludeList", excludeList); + } + + @Override + public String getModuleGroup() { + return "process"; + } +} diff --git a/src/main/java/neatlogic/module/autoexec/notify/handler/param/AutoexecCreateJobFailedContentParamHandler.java b/src/main/java/neatlogic/module/autoexec/notify/handler/param/AutoexecCreateJobFailedContentParamHandler.java new file mode 100644 index 0000000000000000000000000000000000000000..58d1b46ef12fae45eddd527b1c1ef4e41b4b31ec --- /dev/null +++ b/src/main/java/neatlogic/module/autoexec/notify/handler/param/AutoexecCreateJobFailedContentParamHandler.java @@ -0,0 +1,64 @@ +/*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.autoexec.notify.handler.param; + +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import neatlogic.framework.autoexec.constvalue.AutoexecNotifyParam; +import neatlogic.framework.autoexec.constvalue.AutoexecNotifyTriggerType; +import neatlogic.framework.crossover.CrossoverServiceFactory; +import neatlogic.framework.notify.core.INotifyTriggerType; +import neatlogic.framework.process.crossover.IProcessTaskStepDataCrossoverMapper; +import neatlogic.framework.process.dto.ProcessTaskStepDataVo; +import neatlogic.framework.process.dto.ProcessTaskStepVo; +import neatlogic.framework.process.notify.core.ProcessTaskNotifyParamHandlerBase; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.collections4.MapUtils; +import org.springframework.stereotype.Component; + +@Component +public class AutoexecCreateJobFailedContentParamHandler extends ProcessTaskNotifyParamHandlerBase { + @Override + public String getValue() { + return AutoexecNotifyParam.CREATE_JOB_FAILED_CONTENT.getValue(); + } + + @Override + public Object getMyText(ProcessTaskStepVo processTaskStepVo, INotifyTriggerType notifyTriggerType) { + if (!(notifyTriggerType == AutoexecNotifyTriggerType.CREATE_JOB_FAILED)) { + return null; + } + if (processTaskStepVo == null) { + return null; + } + IProcessTaskStepDataCrossoverMapper processTaskStepDataCrossoverMapper = CrossoverServiceFactory.getApi(IProcessTaskStepDataCrossoverMapper.class); + ProcessTaskStepDataVo searchVo = new ProcessTaskStepDataVo(); + searchVo.setProcessTaskId(processTaskStepVo.getProcessTaskId()); + searchVo.setProcessTaskStepId(processTaskStepVo.getId()); + searchVo.setType("autoexecCreateJobError"); + ProcessTaskStepDataVo processTaskStepDataVo = processTaskStepDataCrossoverMapper.getProcessTaskStepData(searchVo); + if (processTaskStepDataVo != null) { + JSONObject dataObj = processTaskStepDataVo.getData(); + if (MapUtils.isNotEmpty(dataObj)) { + JSONArray errorList = dataObj.getJSONArray("errorList"); + if (CollectionUtils.isNotEmpty(errorList)) { + return errorList.toJSONString(); + } + } + } + return null; + } +} diff --git a/src/main/java/neatlogic/module/autoexec/process/stephandler/component/CreateJobProcessComponent.java b/src/main/java/neatlogic/module/autoexec/process/stephandler/component/CreateJobProcessComponent.java index 0577e74b52840ee720d3aa1f85a283537ee81781..744ef48ff37837c28e189b74a485dc71abf291ef 100644 --- a/src/main/java/neatlogic/module/autoexec/process/stephandler/component/CreateJobProcessComponent.java +++ b/src/main/java/neatlogic/module/autoexec/process/stephandler/component/CreateJobProcessComponent.java @@ -19,6 +19,7 @@ package neatlogic.module.autoexec.process.stephandler.component; import com.alibaba.fastjson.*; import neatlogic.framework.asynchronization.threadlocal.UserContext; +import neatlogic.framework.autoexec.constvalue.AutoexecNotifyTriggerType; import neatlogic.framework.autoexec.constvalue.JobStatus; import neatlogic.framework.autoexec.dao.mapper.AutoexecJobMapper; import neatlogic.framework.autoexec.dto.combop.AutoexecCombopVersionVo; @@ -256,6 +257,9 @@ public class CreateJobProcessComponent extends ProcessStepHandlerBase { } } } + IProcessStepHandlerCrossoverUtil processStepHandlerCrossoverUtil = CrossoverServiceFactory.getApi(IProcessStepHandlerCrossoverUtil.class); + /* 触发通知 **/ + processStepHandlerCrossoverUtil.notify(currentProcessTaskStepVo, AutoexecNotifyTriggerType.CREATE_JOB_FAILED); } } catch (Exception e) { logger.error(e.getMessage(), e); diff --git a/src/main/java/neatlogic/module/autoexec/process/stephandler/utilhandler/CreateJobProcessUtilHandler.java b/src/main/java/neatlogic/module/autoexec/process/stephandler/utilhandler/CreateJobProcessUtilHandler.java index f87951c6753acd36edf57e6a0d3fb3f9c54c0141..c598af8c7a7e6f625e857f9399b2067305911a6a 100644 --- a/src/main/java/neatlogic/module/autoexec/process/stephandler/utilhandler/CreateJobProcessUtilHandler.java +++ b/src/main/java/neatlogic/module/autoexec/process/stephandler/utilhandler/CreateJobProcessUtilHandler.java @@ -30,7 +30,7 @@ import neatlogic.framework.process.crossover.IProcessTaskStepDataCrossoverMapper import neatlogic.framework.process.dto.ProcessTaskStepDataVo; import neatlogic.framework.process.dto.ProcessTaskStepVo; import neatlogic.framework.process.stephandler.core.ProcessStepInternalHandlerBase; -import neatlogic.module.autoexec.notify.handler.AutoexecCombopNotifyPolicyHandler; +import neatlogic.module.autoexec.notify.handler.AutoexecNotifyPolicyHandler; import neatlogic.module.autoexec.process.constvalue.CreateJobProcessStepHandlerType; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.MapUtils; @@ -146,7 +146,7 @@ public class CreateJobProcessUtilHandler extends ProcessStepInternalHandlerBase @Override public Class getNotifyPolicyHandlerClass() { - return AutoexecCombopNotifyPolicyHandler.class; + return AutoexecNotifyPolicyHandler.class; } @Override 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 51da6b9d3d38e77737a3daab48a1b3d642a6f021..a66509015f9cf6b0fb12658dbed60f11c536ce81 100644 --- a/src/main/java/neatlogic/module/autoexec/process/util/CreateJobConfigUtil.java +++ b/src/main/java/neatlogic/module/autoexec/process/util/CreateJobConfigUtil.java @@ -342,6 +342,9 @@ public class CreateJobConfigUtil { scenarioNameToIdMap.put(combopScenarioVo.getScenarioName(), combopScenarioVo.getScenarioId()); } for (Object obj : jsonArray) { + if (obj == null) { + continue; + } if (obj instanceof Long) { Long scenarioId = (Long) obj; if (scenarioIdList.contains(scenarioId)) { @@ -377,6 +380,9 @@ public class CreateJobConfigUtil { } IResourceAccountCrossoverMapper resourceAccountCrossoverMapper = CrossoverServiceFactory.getApi(IResourceAccountCrossoverMapper.class); for (Object obj : jsonArray) { + if (obj == null) { + continue; + } if (obj instanceof Long) { Long protocolId = (Long) obj; AccountProtocolVo accountProtocolVo = resourceAccountCrossoverMapper.getAccountProtocolVoByProtocolId(protocolId); @@ -414,6 +420,9 @@ public class CreateJobConfigUtil { } IResourceAccountCrossoverMapper resourceAccountCrossoverMapper = CrossoverServiceFactory.getApi(IResourceAccountCrossoverMapper.class); for (Object obj : jsonArray) { + if (obj == null) { + continue; + } if (obj instanceof Long) { Long accountId = (Long) obj; AccountVo accountVo = resourceAccountCrossoverMapper.getAccountById(accountId); @@ -461,6 +470,9 @@ public class CreateJobConfigUtil { List inputNodeList = new ArrayList<>(); JSONObject filter = new JSONObject(); for (Object obj : jsonArray) { + if (obj == null) { + continue; + } if (obj instanceof String) { String str = (String) obj; if (str.startsWith("{") && str.endsWith("}")) { @@ -521,6 +533,9 @@ public class CreateJobConfigUtil { return resultList; } for (Object obj : jsonArray) { + if (obj == null) { + continue; + } if (obj instanceof String) { String str = (String) obj; if (str.startsWith("{") && str.endsWith("}")) { @@ -1238,6 +1253,9 @@ public class CreateJobConfigUtil { private static Object getJSONObjectOrJSONArray(JSONArray jsonArray) { JSONArray jsonList = new JSONArray(); for (Object obj : jsonArray) { + if (obj == null) { + continue; + } if (obj instanceof JSONObject) { jsonList.add(obj); } else if (obj instanceof JSONArray) { 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 1a4ef88cadebc15b55f94d602f465c6da7d782c6..cfe0651a9a4169861845cc485b3b323687eff205 100644 --- a/src/main/java/neatlogic/module/autoexec/stephandler/component/AutoexecProcessComponent.java +++ b/src/main/java/neatlogic/module/autoexec/stephandler/component/AutoexecProcessComponent.java @@ -17,10 +17,7 @@ package neatlogic.module.autoexec.stephandler.component; import com.alibaba.fastjson.*; import neatlogic.framework.asynchronization.threadlocal.UserContext; -import neatlogic.framework.autoexec.constvalue.CombopOperationType; -import neatlogic.framework.autoexec.constvalue.JobStatus; -import neatlogic.framework.autoexec.constvalue.ParamMappingMode; -import neatlogic.framework.autoexec.constvalue.ParamType; +import neatlogic.framework.autoexec.constvalue.*; import neatlogic.framework.autoexec.dao.mapper.AutoexecJobMapper; import neatlogic.framework.autoexec.dto.combop.AutoexecCombopExecuteConfigVo; import neatlogic.framework.autoexec.dto.combop.AutoexecCombopExecuteNodeConfigVo; @@ -262,9 +259,7 @@ public class AutoexecProcessComponent extends ProcessStepHandlerBase { } } } - if (CollectionUtils.isEmpty(jobIdList)) { - processTaskStepComplete(currentProcessTaskStepVo.getId(), null); - } + // 如果有一个作业创建有异常,则根据失败策略执行操作 if (flag) { ProcessTaskStepDataVo processTaskStepDataVo = new ProcessTaskStepDataVo(); @@ -302,6 +297,11 @@ public class AutoexecProcessComponent extends ProcessStepHandlerBase { } } } + IProcessStepHandlerCrossoverUtil processStepHandlerCrossoverUtil = CrossoverServiceFactory.getApi(IProcessStepHandlerCrossoverUtil.class); + /* 触发通知 **/ + processStepHandlerCrossoverUtil.notify(currentProcessTaskStepVo, AutoexecNotifyTriggerType.CREATE_JOB_FAILED); + } else if (CollectionUtils.isEmpty(jobIdList)) { + processTaskStepComplete(currentProcessTaskStepVo.getId(), null); } } catch (Exception e) { logger.error(e.getMessage(), e); diff --git a/src/main/java/neatlogic/module/autoexec/stephandler/utilhandler/AutoexecProcessUtilHandler.java b/src/main/java/neatlogic/module/autoexec/stephandler/utilhandler/AutoexecProcessUtilHandler.java index 206eb635b9c51248554e6de6706ec6d0406b0c06..adb194a1257ee7a8668e5815307c1b8a62f7342f 100644 --- a/src/main/java/neatlogic/module/autoexec/stephandler/utilhandler/AutoexecProcessUtilHandler.java +++ b/src/main/java/neatlogic/module/autoexec/stephandler/utilhandler/AutoexecProcessUtilHandler.java @@ -33,7 +33,7 @@ import neatlogic.framework.process.dto.processconfig.ActionConfigVo; import neatlogic.framework.process.stephandler.core.ProcessStepInternalHandlerBase; import neatlogic.framework.process.util.ProcessConfigUtil; import neatlogic.framework.util.SnowflakeUtil; -import neatlogic.module.autoexec.notify.handler.AutoexecCombopNotifyPolicyHandler; +import neatlogic.module.autoexec.notify.handler.AutoexecNotifyPolicyHandler; import neatlogic.module.autoexec.service.AutoexecJobService; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.MapUtils; @@ -69,7 +69,8 @@ public class AutoexecProcessUtilHandler extends ProcessStepInternalHandlerBase { @Override public Object getNonStartStepInfo(ProcessTaskStepVo currentProcessTaskStepVo) { JSONObject resultObj = new JSONObject(); - List jobIdList = autoexecJobMapper.getJobIdListByInvokeId(currentProcessTaskStepVo.getId()); +// List jobIdList = autoexecJobMapper.getJobIdListByInvokeId(currentProcessTaskStepVo.getId()); + List jobIdList = autoexecJobMapper.getJobIdListByProcessTaskStepId(currentProcessTaskStepVo.getId()); if (CollectionUtils.isNotEmpty(jobIdList)) { int completed = 0, failed = 0, running = 0; Map> jobIdToAutoexecJobPhaseListMap = new HashMap<>(); @@ -185,7 +186,7 @@ public class AutoexecProcessUtilHandler extends ProcessStepInternalHandlerBase { /* 通知 **/ JSONObject notifyPolicyConfig = configObj.getJSONObject("notifyPolicyConfig"); INotifyServiceCrossoverService notifyServiceCrossoverService = CrossoverServiceFactory.getApi(INotifyServiceCrossoverService.class); - InvokeNotifyPolicyConfigVo invokeNotifyPolicyConfigVo = notifyServiceCrossoverService.regulateNotifyPolicyConfig(notifyPolicyConfig, AutoexecCombopNotifyPolicyHandler.class); + InvokeNotifyPolicyConfigVo invokeNotifyPolicyConfigVo = notifyServiceCrossoverService.regulateNotifyPolicyConfig(notifyPolicyConfig, AutoexecNotifyPolicyHandler.class); resultObj.put("notifyPolicyConfig", invokeNotifyPolicyConfigVo); /** 动作 **/ @@ -194,7 +195,7 @@ public class AutoexecProcessUtilHandler extends ProcessStepInternalHandlerBase { if (actionConfigVo == null) { actionConfigVo = new ActionConfigVo(); } - actionConfigVo.setHandler(AutoexecCombopNotifyPolicyHandler.class.getName()); + actionConfigVo.setHandler(AutoexecNotifyPolicyHandler.class.getName()); resultObj.put("actionConfig", actionConfigVo); /* 按钮映射列表 **/