refactor: 启动时自动同步第三方平台缺陷 (#4304)
Co-authored-by: chenjianxing <jianxing.chen@fit2cloud.com>
This commit is contained in:
parent
1da8b42ed0
commit
6381462a4d
|
@ -2098,25 +2098,29 @@ public class ApiAutomationService {
|
|||
}
|
||||
|
||||
public void checkApiScenarioUseUrl() {
|
||||
List<String> noUrlScenarioIdList = extApiScenarioMapper.selectIdsByUseUrlIsNull();
|
||||
for (String id : noUrlScenarioIdList) {
|
||||
try {
|
||||
ApiScenarioWithBLOBs scenario = apiScenarioMapper.selectByPrimaryKey(id);
|
||||
if (scenario.getUseUrl() == null) {
|
||||
List<ApiMethodUrlDTO> 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<String> noUrlScenarioIdList = extApiScenarioMapper.selectIdsByUseUrlIsNull();
|
||||
for (String id : noUrlScenarioIdList) {
|
||||
ApiScenarioWithBLOBs scenario = apiScenarioMapper.selectByPrimaryKey(id);
|
||||
if (scenario.getUseUrl() == null) {
|
||||
List<ApiMethodUrlDTO> 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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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<ApplicationReadyEve
|
|||
private JarConfigService jarConfigService;
|
||||
@Resource
|
||||
private ApiAutomationService apiAutomationService;
|
||||
@Resource
|
||||
private IssuesService issuesService;
|
||||
@Value("${jmeter.home}")
|
||||
private String jmeterHome;
|
||||
|
||||
|
@ -44,6 +47,8 @@ public class AppStartListener implements ApplicationListener<ApplicationReadyEve
|
|||
|
||||
checkApiScenarioUseUrl();
|
||||
|
||||
issuesService.syncThirdPartyIssues();
|
||||
|
||||
try {
|
||||
Thread.sleep(1 * 60 * 1000);
|
||||
} catch (InterruptedException e) {
|
||||
|
|
|
@ -268,6 +268,15 @@ public class SystemParameterService {
|
|||
});
|
||||
}
|
||||
|
||||
public void saveInitParam(String key) {
|
||||
SystemParameter parameter = new SystemParameter();
|
||||
parameter.setParamKey(key);
|
||||
parameter.setParamValue("over");
|
||||
parameter.setType("text");
|
||||
systemParameterMapper.insert(parameter);
|
||||
}
|
||||
|
||||
|
||||
//保存表头
|
||||
public void saveHeader(UserHeader userHeader) {
|
||||
UserHeaderExample example = new UserHeaderExample();
|
||||
|
|
|
@ -23,6 +23,7 @@ import io.metersphere.notice.service.NoticeSendService;
|
|||
import io.metersphere.service.IntegrationService;
|
||||
import io.metersphere.service.IssueTemplateService;
|
||||
import io.metersphere.service.ProjectService;
|
||||
import io.metersphere.service.SystemParameterService;
|
||||
import io.metersphere.track.issue.*;
|
||||
import io.metersphere.track.issue.domain.PlatformUser;
|
||||
import io.metersphere.track.issue.domain.zentao.ZentaoBuild;
|
||||
|
@ -72,6 +73,8 @@ public class IssuesService {
|
|||
private IssueTemplateService issueTemplateService;
|
||||
@Resource
|
||||
private TestCaseMapper testCaseMapper;
|
||||
@Resource
|
||||
private SystemParameterService systemParameterService;
|
||||
|
||||
public void testAuth(String orgId, String platform) {
|
||||
IssuesRequest issuesRequest = new IssuesRequest();
|
||||
|
@ -360,47 +363,24 @@ public class IssuesService {
|
|||
return IssueFactory.createPlatformsForMap(platforms, request);
|
||||
}
|
||||
|
||||
// public IssuesWithBLOBs getPlatformIssue(IssuesWithBLOBs issue) {
|
||||
// String platform = issue.getPlatform();
|
||||
// if (StringUtils.isNotBlank(issue.getProjectId())) {
|
||||
// Project project = projectService.getProjectById(issue.getProjectId());
|
||||
// Workspace workspace = workspaceMapper.selectByPrimaryKey(project.getWorkspaceId());
|
||||
// String orgId = workspace.getOrganizationId();
|
||||
// try {
|
||||
// if (StringUtils.equals(platform, IssuesManagePlatform.Tapd.name())) {
|
||||
// TapdPlatform tapdPlatform = new TapdPlatform(new IssuesRequest());
|
||||
// String tapdId = projectService.getProjectById(issue.getProjectId()).getTapdId();
|
||||
// IssuesDao tapdIssues = tapdPlatform.getTapdIssues(tapdId, issue.getId());
|
||||
// issue.setTitle(tapdIssues.getTitle());
|
||||
// issue.setDescription(tapdIssues.getDescription());
|
||||
// issue.setStatus(tapdIssues.getStatus());
|
||||
// } else if (StringUtils.equals(platform, IssuesManagePlatform.Jira.name())) {
|
||||
// JiraPlatform jiraPlatform = new JiraPlatform(new IssuesRequest());
|
||||
// jiraPlatform.getJiraIssues(issue, issue.getId());
|
||||
// } else if (StringUtils.equals(platform, IssuesManagePlatform.Zentao.name())) {
|
||||
// String config = getConfig(orgId, IssuesManagePlatform.Zentao.toString());
|
||||
// JSONObject object = JSON.parseObject(config);
|
||||
// String account = object.getString("account");
|
||||
// String password = object.getString("password");
|
||||
// String url = object.getString("url");
|
||||
// ZentaoPlatform zentaoPlatform = new ZentaoPlatform(account, password, url);
|
||||
// IssuesDao zentaoIssues = zentaoPlatform.getZentaoIssues(issue.getId());
|
||||
// issue.setTitle(zentaoIssues.getTitle());
|
||||
// issue.setDescription(zentaoIssues.getDescription());
|
||||
// issue.setStatus(zentaoIssues.getStatus());
|
||||
// }
|
||||
// } catch (Exception e) {
|
||||
// LogUtil.error(e.getMessage(), e);
|
||||
// }
|
||||
// }
|
||||
// return issue;
|
||||
// }
|
||||
|
||||
public void syncThirdPartyIssues() {
|
||||
List<String> projectIds = projectService.getProjectIds();
|
||||
projectIds.forEach(id -> {
|
||||
syncThirdPartyIssues(id);
|
||||
});
|
||||
try {
|
||||
final String key = "init.issue";
|
||||
String value = systemParameterService.getValue(key);
|
||||
if (StringUtils.isBlank(value)) {
|
||||
List<String> 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) {
|
||||
|
|
Loading…
Reference in New Issue