fix(缺陷管理): 缺陷同步相关的BUG
--bug=1039563 --user=宋昌昌 【项目管理】项目与权限-缺陷管理-同步缺陷设置6小时增量同步一次不生效 https://www.tapd.cn/55049933/s/1499368
This commit is contained in:
parent
d0a72c6c65
commit
9dc624aead
|
@ -1,8 +1,6 @@
|
|||
package io.metersphere.bug.job;
|
||||
|
||||
import io.metersphere.bug.service.BugSyncExtraService;
|
||||
import io.metersphere.bug.service.BugSyncService;
|
||||
import io.metersphere.bug.service.XpackBugService;
|
||||
import io.metersphere.project.service.ProjectApplicationService;
|
||||
import io.metersphere.sdk.util.CommonBeanFactory;
|
||||
import io.metersphere.sdk.util.LogUtils;
|
||||
|
@ -23,15 +21,11 @@ public class BugSyncJob extends BaseScheduleJob {
|
|||
|
||||
private final LicenseService licenseService;
|
||||
private final BugSyncService bugSyncService;
|
||||
private final XpackBugService xpackBugService;
|
||||
private final BugSyncExtraService bugSyncExtraService;
|
||||
private final ProjectApplicationService projectApplicationService;
|
||||
|
||||
public BugSyncJob() {
|
||||
licenseService = CommonBeanFactory.getBean(LicenseService.class);
|
||||
xpackBugService = CommonBeanFactory.getBean(XpackBugService.class);
|
||||
bugSyncService = CommonBeanFactory.getBean(BugSyncService.class);
|
||||
bugSyncExtraService = CommonBeanFactory.getBean(BugSyncExtraService.class);
|
||||
projectApplicationService = CommonBeanFactory.getBean(ProjectApplicationService.class);
|
||||
}
|
||||
|
||||
|
@ -52,12 +46,7 @@ public class BugSyncJob extends BaseScheduleJob {
|
|||
return;
|
||||
}
|
||||
LogUtils.info("bug sync job start......");
|
||||
// 获取当前项目同步缺陷唯一Key
|
||||
try{
|
||||
String syncValue = bugSyncExtraService.getSyncKey(resourceId);
|
||||
if (StringUtils.isEmpty(syncValue)) {
|
||||
// 不存在, 设置保证唯一性, 并开始同步
|
||||
bugSyncExtraService.setSyncKey(resourceId);
|
||||
if (licenseService == null) {
|
||||
LogUtils.info("license is null, sync remain bug");
|
||||
bugSyncService.syncPlatformBugBySchedule(resourceId, userId);
|
||||
|
@ -66,16 +55,13 @@ public class BugSyncJob extends BaseScheduleJob {
|
|||
if (licenseDTO != null && licenseDTO.getLicense() != null
|
||||
&& StringUtils.equals(licenseDTO.getStatus(), "valid")) {
|
||||
LogUtils.info("license is valid, sync all bug");
|
||||
xpackBugService.syncPlatformBugsBySchedule(resourceId, userId);
|
||||
bugSyncService.syncPlatformAllBugBySchedule(resourceId, userId);
|
||||
} else {
|
||||
LogUtils.info("license is invalid, sync remain bug");
|
||||
bugSyncService.syncPlatformBugBySchedule(resourceId, userId);
|
||||
}
|
||||
}
|
||||
bugSyncExtraService.deleteSyncKey(resourceId);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
bugSyncExtraService.deleteSyncKey(resourceId);
|
||||
LogUtils.error(e.getMessage());
|
||||
}
|
||||
LogUtils.info("bug sync job end......");
|
||||
|
|
|
@ -528,6 +528,8 @@ public class BugService {
|
|||
}
|
||||
} catch (Exception e) {
|
||||
LogUtils.error(e);
|
||||
// 异常或正常结束都得删除当前项目执行同步的唯一Key
|
||||
bugSyncExtraService.deleteSyncKey(request.getProjectId());
|
||||
// 同步缺陷异常, 当前同步错误信息 -> Redis(check接口获取)
|
||||
bugSyncExtraService.setSyncErrorMsg(request.getProjectId(), e.getMessage());
|
||||
} finally {
|
||||
|
@ -548,6 +550,8 @@ public class BugService {
|
|||
SubListUtils.dealForSubList(remainBugs, 100, (subBugs) -> doSyncPlatformBugs(subBugs, project));
|
||||
} catch (Exception e) {
|
||||
LogUtils.error(e);
|
||||
// 异常或正常结束都得删除当前项目执行同步的Key
|
||||
bugSyncExtraService.deleteSyncKey(project.getId());
|
||||
// 同步缺陷异常, 当前同步错误信息 -> Redis(check接口获取)
|
||||
bugSyncExtraService.setSyncErrorMsg(project.getId(), e.getMessage());
|
||||
} finally {
|
||||
|
|
|
@ -12,6 +12,8 @@ import io.metersphere.project.service.ProjectApplicationService;
|
|||
import io.metersphere.project.service.ProjectTemplateService;
|
||||
import io.metersphere.sdk.constants.TemplateScene;
|
||||
import io.metersphere.sdk.exception.MSException;
|
||||
import io.metersphere.sdk.util.CommonBeanFactory;
|
||||
import io.metersphere.sdk.util.LogUtils;
|
||||
import io.metersphere.sdk.util.Translator;
|
||||
import io.metersphere.system.domain.Template;
|
||||
import io.metersphere.system.domain.TemplateExample;
|
||||
|
@ -133,11 +135,41 @@ public class BugSyncService {
|
|||
|
||||
/**
|
||||
* 定时任务同步缺陷(存量-默认中文环境通知)
|
||||
* @param projectId 项目ID
|
||||
* @param scheduleUser 任务触发用户
|
||||
*/
|
||||
public void syncPlatformBugBySchedule(String projectId, String scheduleUser) {
|
||||
syncBugs(projectId, scheduleUser, Locale.SIMPLIFIED_CHINESE.getLanguage(), Translator.get("sync_mode.auto"));
|
||||
}
|
||||
|
||||
/**
|
||||
* 定时任务同步缺陷(全量-默认中文环境通知)
|
||||
* @param projectId 项目ID
|
||||
* @param scheduleUser 任务触发用户
|
||||
*/
|
||||
public void syncPlatformAllBugBySchedule(String projectId, String scheduleUser) {
|
||||
try {
|
||||
String syncValue = bugSyncExtraService.getSyncKey(projectId);
|
||||
if (StringUtils.isEmpty(syncValue)) {
|
||||
// 不存在, 设置保证唯一性, 并开始同步
|
||||
bugSyncExtraService.setSyncKey(projectId);
|
||||
XpackBugService bugService = CommonBeanFactory.getBean(XpackBugService.class);
|
||||
if (bugService != null) {
|
||||
Project project = getProjectById(projectId);
|
||||
BugSyncRequest syncRequest = new BugSyncRequest();
|
||||
syncRequest.setProjectId(projectId);
|
||||
bugService.syncPlatformBugs(project, syncRequest, scheduleUser, Locale.SIMPLIFIED_CHINESE.getLanguage(), Translator.get("sync_mode.auto"));
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
LogUtils.error(e);
|
||||
// 异常或正常结束都得删除当前项目执行同步的唯一Key
|
||||
bugSyncExtraService.deleteSyncKey(projectId);
|
||||
// 同步缺陷异常, 当前同步错误信息 -> Redis(check接口获取)
|
||||
bugSyncExtraService.setSyncErrorMsg(projectId, e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据项目ID获取项目信息
|
||||
* @param projectId 项目ID
|
||||
|
|
|
@ -8,13 +8,6 @@ import io.metersphere.project.domain.Project;
|
|||
*/
|
||||
public interface XpackBugService {
|
||||
|
||||
/**
|
||||
* 同步系统下所有第三方平台项目缺陷(定时任务)
|
||||
* @param projectId 项目ID
|
||||
* @param scheduleUser 定时任务执行用户
|
||||
*/
|
||||
void syncPlatformBugsBySchedule(String projectId, String scheduleUser);
|
||||
|
||||
/**
|
||||
* 同步当前项目第三方平台缺陷(前台调用, 支持全量及同步条件区间)
|
||||
* @param project 项目
|
||||
|
|
|
@ -8,11 +8,6 @@ import org.springframework.stereotype.Service;
|
|||
@Service
|
||||
public class XpackBugMockServiceImpl implements XpackBugService {
|
||||
|
||||
@Override
|
||||
public void syncPlatformBugsBySchedule(String projectId, String scheduleUser) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void syncPlatformBugs(Project project, BugSyncRequest request, String currentUser, String language, String triggerMode) {
|
||||
|
||||
|
|
|
@ -154,7 +154,6 @@
|
|||
<a-tooltip position="top">
|
||||
<template #content>
|
||||
<div>{{ t('bugManagement.syncBugTipRowOne') }}</div>
|
||||
<div>{{ t('bugManagement.syncBugTipRowTwo') }}</div>
|
||||
</template>
|
||||
<MsIcon class="text-[var(--color-text-4)]" type="icon-icon-maybe_outlined" />
|
||||
</a-tooltip>
|
||||
|
|
|
@ -21,8 +21,8 @@ export default {
|
|||
sync: 'Sync',
|
||||
synchronizing: 'Synchronizing',
|
||||
syncSuccess: 'Synchronous success',
|
||||
syncBugTipRowOne: 'Sync third plant bug,',
|
||||
syncBugTipRowTwo: 'Create bug and sync bug?',
|
||||
syncBugTipRowOne:
|
||||
'Synchronize third-party platform bug to MS as configured in << Project Management - Application Settings - Defect Management >>',
|
||||
bugAutoSync: 'System will auto sync by the project application setting frequency',
|
||||
syncTime: 'Sync time',
|
||||
deleteLabel: 'Local bug will in recycle bin and third plant bug will be deleted',
|
||||
|
|
|
@ -21,8 +21,7 @@ export default {
|
|||
sync: '同步',
|
||||
synchronizing: '正在同步中',
|
||||
syncSuccess: '同步成功',
|
||||
syncBugTipRowOne: '将第三方的缺陷同步到缺陷管理中,',
|
||||
syncBugTipRowTwo: '新增缺陷和更新已有的缺陷?',
|
||||
syncBugTipRowOne: '根据<<项目管理-应用设置-缺陷管理>>中的配置来同步第三方平台缺陷至MS',
|
||||
bugAutoSync: '系统将按照项目应用设置频率自动同步',
|
||||
syncTime: '同步时间',
|
||||
deleteLabel: '删除后, Local 的缺陷进入回收站; 第三方平台同步的缺陷将不做回收',
|
||||
|
|
|
@ -56,7 +56,7 @@
|
|||
<a-radio v-xpack value="full">
|
||||
<div class="flex flex-row items-center gap-[4px]">
|
||||
<span class="text-[var(--color-text-1)]">{{ t('project.menu.fullSync') }}</span>
|
||||
<a-tooltip :content="t('project.menu.fullSyncTip')" position="bl">
|
||||
<a-tooltip :content="t('project.menu.fullSyncTip')" position="top">
|
||||
<div>
|
||||
<MsIcon
|
||||
class="ml-[4px] text-[var(--color-text-4)] hover:text-[rgb(var(--primary-5))]"
|
||||
|
|
|
@ -50,9 +50,9 @@ export default {
|
|||
'project.menu.configure': 'to configure',
|
||||
'project.menu.status': 'Status',
|
||||
'project.menu.incrementalSync': 'Incremental Sync',
|
||||
'project.menu.incrementalSyncTip': 'Only sync the changes in the defect content created in MeterSphere',
|
||||
'project.menu.incrementalSyncTip': 'Only the contents of the three-party bug existing in MS are changed',
|
||||
'project.menu.fullSync': 'Full Sync',
|
||||
'project.menu.fullSyncTip': 'Sync all defects on the third-party platform to the MeterSphere platform',
|
||||
'project.menu.fullSyncTip': 'Fully sync bug of third-party platforms to MS',
|
||||
'project.menu.platformPlaceholder':
|
||||
'No third-party platform integrated yet, please contact the organization administrator to integrate',
|
||||
'project.menu.platformLabel': 'Third-party Project Management Platform',
|
||||
|
|
|
@ -46,9 +46,9 @@ export default {
|
|||
'project.menu.configure': '进行配置',
|
||||
'project.menu.status': '状态',
|
||||
'project.menu.incrementalSync': '增量同步',
|
||||
'project.menu.incrementalSyncTip': '仅同步在 MeterSphere 创建的缺陷内容变更',
|
||||
'project.menu.incrementalSyncTip': '仅对 MS 中存在的三方缺陷做内容变更',
|
||||
'project.menu.fullSync': '全量同步',
|
||||
'project.menu.fullSyncTip': '将第三方平台的缺陷全量同步到 MeterSphere 平台',
|
||||
'project.menu.fullSyncTip': '将第三方平台的缺陷全量同步到 MS',
|
||||
'project.menu.platformPlaceholder': '暂未集成第三方平台,请联系组织管理员集成',
|
||||
'project.menu.platformLabel': '第三方项目管理平台',
|
||||
'project.menu.syncMechanism': '同步机制',
|
||||
|
|
Loading…
Reference in New Issue