diff --git a/src/main/java/neatlogic/module/autoexec/api/combop/AutoexecCombopListApi.java b/src/main/java/neatlogic/module/autoexec/api/combop/AutoexecCombopListApi.java index 27d23b5742d3e8cb9dc7baea3675f7fea2ca9e17..9e69f03323c6c834d3b3712232a264218b3b85e8 100644 --- a/src/main/java/neatlogic/module/autoexec/api/combop/AutoexecCombopListApi.java +++ b/src/main/java/neatlogic/module/autoexec/api/combop/AutoexecCombopListApi.java @@ -19,16 +19,17 @@ import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import neatlogic.framework.auth.core.AuthAction; import neatlogic.framework.autoexec.auth.AUTOEXEC; +import neatlogic.framework.autoexec.constvalue.AutoexecFromType; import neatlogic.framework.autoexec.constvalue.ScriptVersionStatus; import neatlogic.framework.autoexec.dao.mapper.AutoexecCombopMapper; import neatlogic.framework.autoexec.dao.mapper.AutoexecTypeMapper; import neatlogic.framework.autoexec.dto.AutoexecTypeVo; import neatlogic.framework.autoexec.dto.combop.AutoexecCombopVo; -import neatlogic.framework.autoexec.exception.AutoexecTypeNotFoundException; import neatlogic.framework.cmdb.enums.CmdbTenantConfig; import neatlogic.framework.common.constvalue.ApiParamType; import neatlogic.framework.common.dto.BasePageVo; import neatlogic.framework.config.ConfigManager; +import neatlogic.framework.dependency.core.DependencyManager; import neatlogic.framework.restful.annotation.*; import neatlogic.framework.restful.constvalue.OperationTypeEnum; import neatlogic.framework.restful.core.privateapi.PrivateApiComponentBase; @@ -118,6 +119,7 @@ public class AutoexecCombopListApi extends PrivateApiComponentBase { for (String status : versionStatusList) { List combopIdList = autoexecCombopVersionMapper.getAutoexecCombopIdListByStatus(status); if (CollectionUtils.isNotEmpty(combopIdList)) { + Map countMap = DependencyManager.getBatchDependencyCount(AutoexecFromType.COMBOP, combopIdList); JSONArray idArray = new JSONArray(); combopIdList.forEach(item -> idArray.add(item)); searchVo.setDefaultValue(idArray); @@ -127,11 +129,15 @@ public class AutoexecCombopListApi extends PrivateApiComponentBase { List autoexecCombopList = autoexecCombopMapper.getAutoexecCombopList(searchVo); for (AutoexecCombopVo autoexecCombopVo : autoexecCombopList) { AutoexecTypeVo autoexecTypeVo = autoexecTypeMapper.getTypeById(autoexecCombopVo.getTypeId()); - if (autoexecTypeVo == null) { - throw new AutoexecTypeNotFoundException(autoexecCombopVo.getTypeId()); + if (autoexecTypeVo != null) { + autoexecCombopVo.setTypeName(autoexecTypeVo.getName()); } - autoexecCombopVo.setTypeName(autoexecTypeVo.getName()); autoexecCombopService.setOperableButtonList(autoexecCombopVo); + Integer count = countMap.get(autoexecCombopVo.getId().toString()); + if (count == null) { + count = 0; + } + autoexecCombopVo.setReferenceCount(count); } resultObj.put("tbodyList", autoexecCombopList); } diff --git a/src/main/java/neatlogic/module/autoexec/dependency/AutoexecCombop2ProcessStepDependencyHandler.java b/src/main/java/neatlogic/module/autoexec/dependency/AutoexecCombop2ProcessStepDependencyHandler.java new file mode 100644 index 0000000000000000000000000000000000000000..878b12253e7d28553e576d765339503594403bae --- /dev/null +++ b/src/main/java/neatlogic/module/autoexec/dependency/AutoexecCombop2ProcessStepDependencyHandler.java @@ -0,0 +1,114 @@ +/*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.dependency; + +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import neatlogic.framework.asynchronization.threadlocal.TenantContext; +import neatlogic.framework.autoexec.constvalue.AutoexecFromType; +import neatlogic.framework.crossover.CrossoverServiceFactory; +import neatlogic.framework.dependency.core.DefaultDependencyHandlerBase; +import neatlogic.framework.dependency.core.IFromType; +import neatlogic.framework.dependency.dto.DependencyInfoVo; +import neatlogic.framework.dependency.dto.DependencyVo; +import neatlogic.framework.process.crossover.IProcessCrossoverMapper; +import neatlogic.framework.process.dto.ProcessVo; +import neatlogic.module.autoexec.process.dto.CreateJobConfigConfigVo; +import neatlogic.module.autoexec.process.dto.CreateJobConfigVo; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.collections4.MapUtils; +import org.springframework.stereotype.Component; + +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; + +@Component +public class AutoexecCombop2ProcessStepDependencyHandler extends DefaultDependencyHandlerBase { + + @Override + protected DependencyInfoVo parse(DependencyVo dependencyVo) { + JSONObject config = dependencyVo.getConfig(); + if (MapUtils.isEmpty(config)) { + return null; + } + String stepUuid = dependencyVo.getTo(); + String processUuid = config.getString("processUuid"); + IProcessCrossoverMapper processCrossoverMapper = CrossoverServiceFactory.getApi(IProcessCrossoverMapper.class); + ProcessVo processVo = processCrossoverMapper.getProcessBaseInfoByUuid(processUuid); + if (processVo == null) { + return null; + } + JSONObject processConfig = processVo.getConfig(); + if (MapUtils.isEmpty(processConfig)) { + return null; + } + JSONObject processObj = processConfig.getJSONObject("process"); + if (MapUtils.isEmpty(processObj)) { + return null; + } + JSONArray stepList = processObj.getJSONArray("stepList"); + if (CollectionUtils.isEmpty(stepList)) { + return null; + } + for (int i = 0; i < stepList.size(); i++) { + JSONObject stepObj = stepList.getJSONObject(i); + if (MapUtils.isEmpty(stepObj)) { + continue; + } + String uuid = stepObj.getString("uuid"); + if (!Objects.equals(uuid, stepUuid)) { + continue; + } + JSONObject stepConfig = stepObj.getJSONObject("stepConfig"); + if (MapUtils.isEmpty(stepConfig)) { + return null; + } + JSONObject createJobConfig = stepConfig.getJSONObject("createJobConfig"); + if (MapUtils.isEmpty(createJobConfig)) { + return null; + } + boolean flag = false; + CreateJobConfigVo createJobConfigVo = createJobConfig.toJavaObject(CreateJobConfigVo.class); + List configList = createJobConfigVo.getConfigList(); + if (CollectionUtils.isNotEmpty(configList)) { + for (CreateJobConfigConfigVo createJobConfigConfigVo : configList) { + if (createJobConfigConfigVo.getCombopId() != null && Objects.equals(createJobConfigConfigVo.getCombopId().toString(), dependencyVo.getFrom())) { + flag = true; + break; + } + } + } + if (!flag) { + return null; + } + JSONObject dependencyInfoConfig = new JSONObject(); + dependencyInfoConfig.put("processUuid", processUuid); + dependencyInfoConfig.put("stepUuid", stepUuid); + List pathList = new ArrayList<>(); + pathList.add("流程管理"); + pathList.add(processVo.getName()); + String urlFormat = "/" + TenantContext.get().getTenantUuid() + "/process.html#/flow-edit?uuid=${DATA.processUuid}&stepUuid=${DATA.stepUuid}"; + return new DependencyInfoVo(stepUuid, dependencyInfoConfig, stepObj.getString("name"), pathList, urlFormat, this.getGroupName()); + } + return null; + } + + @Override + public IFromType getFromType() { + return AutoexecFromType.COMBOP; + } +}