diff --git a/backend/src/main/java/io/metersphere/api/service/ApiAutomationService.java b/backend/src/main/java/io/metersphere/api/service/ApiAutomationService.java index 4ba772d712..6edf6dfb7d 100644 --- a/backend/src/main/java/io/metersphere/api/service/ApiAutomationService.java +++ b/backend/src/main/java/io/metersphere/api/service/ApiAutomationService.java @@ -2098,25 +2098,29 @@ public class ApiAutomationService { } public void checkApiScenarioUseUrl() { - List noUrlScenarioIdList = extApiScenarioMapper.selectIdsByUseUrlIsNull(); - for (String id : noUrlScenarioIdList) { - try { - ApiScenarioWithBLOBs scenario = apiScenarioMapper.selectByPrimaryKey(id); - if (scenario.getUseUrl() == null) { - List useUrl = this.parseUrl(scenario); - if (useUrl != null) { - ApiScenarioWithBLOBs updateModel = new ApiScenarioWithBLOBs(); - updateModel.setId(scenario.getId()); - updateModel.setUseUrl(JSONArray.toJSONString(useUrl)); - apiScenarioMapper.updateByPrimaryKeySelective(updateModel); - updateModel = null; + try { + final String key = "init.scenario.url"; + String value = systemParameterService.getValue(key); + if (StringUtils.isBlank(value)) { + List noUrlScenarioIdList = extApiScenarioMapper.selectIdsByUseUrlIsNull(); + for (String id : noUrlScenarioIdList) { + ApiScenarioWithBLOBs scenario = apiScenarioMapper.selectByPrimaryKey(id); + if (scenario.getUseUrl() == null) { + List useUrl = this.parseUrl(scenario); + if (useUrl != null) { + ApiScenarioWithBLOBs updateModel = new ApiScenarioWithBLOBs(); + updateModel.setId(scenario.getId()); + updateModel.setUseUrl(JSONArray.toJSONString(useUrl)); + apiScenarioMapper.updateByPrimaryKeySelective(updateModel); + updateModel = null; + } } + scenario = null; } - scenario = null; - } catch (Exception e) { - e.printStackTrace(); + systemParameterService.saveInitParam(key); } - + } catch (Exception e) { + LogUtil.error(e.getMessage(), e); } } diff --git a/backend/src/main/java/io/metersphere/listener/AppStartListener.java b/backend/src/main/java/io/metersphere/listener/AppStartListener.java index e0900c9309..0009e14a51 100644 --- a/backend/src/main/java/io/metersphere/listener/AppStartListener.java +++ b/backend/src/main/java/io/metersphere/listener/AppStartListener.java @@ -7,6 +7,7 @@ import io.metersphere.base.domain.JarConfig; import io.metersphere.commons.utils.LogUtil; import io.metersphere.service.JarConfigService; import io.metersphere.service.ScheduleService; +import io.metersphere.track.service.IssuesService; import org.python.core.Options; import org.python.util.PythonInterpreter; import org.springframework.beans.factory.annotation.Value; @@ -28,6 +29,8 @@ public class AppStartListener implements ApplicationListener projectIds = projectService.getProjectIds(); - projectIds.forEach(id -> { - syncThirdPartyIssues(id); - }); + try { + final String key = "init.issue"; + String value = systemParameterService.getValue(key); + if (StringUtils.isBlank(value)) { + List projectIds = projectService.getProjectIds(); + projectIds.forEach(id -> { + try { + syncThirdPartyIssues(id); + } catch (Exception e) { + LogUtil.error(e.getMessage(), e); + } + }); + systemParameterService.saveInitParam(key); + } + } catch (Exception e) { + LogUtil.error(e.getMessage(), e); + } } public void syncThirdPartyIssues(String projectId) {