fix(任务中心): 系统后台任务修改第三方任务运行规则,项目管理配置页面没有更新问题
--bug=1049664 --user=王旭 【项目管理】系统后台缺陷同步定时任务-修改运行规则-项目管理未同步更新 https://www.tapd.cn/55049933/s/1620108
This commit is contained in:
parent
5ac95cea80
commit
3cc7c2de3a
|
@ -57,7 +57,7 @@ public class ProjectTaskHubControllerTests extends BaseTest {
|
|||
public static final String PROJECT_SCHEDULE_TASK_SWITCH = "/project/task-center/schedule/switch/";
|
||||
public static final String PROJECT_SCHEDULE_TASK_BATCH_ENABLE = "/project/task-center/schedule/batch-enable";
|
||||
public static final String PROJECT_SCHEDULE_TASK_BATCH_DISABLE = "/project/task-center/schedule/batch-disable";
|
||||
public static final String PROJECT_SCHEDULE_TASK_UPDATE_CRON = "/organization/task-center/schedule/update-cron";
|
||||
public static final String PROJECT_SCHEDULE_TASK_UPDATE_CRON = "/project/task-center/schedule/update-cron";
|
||||
public static final String PROJECT_BATCH_TASK_PAGE = "/project/task-center/exec-task/batch/page";
|
||||
|
||||
@Test
|
||||
|
@ -295,6 +295,8 @@ public class ProjectTaskHubControllerTests extends BaseTest {
|
|||
request.setCron("0 0 0 1 * ?");
|
||||
request.setId("pro_wx_1");
|
||||
this.requestPost(PROJECT_SCHEDULE_TASK_UPDATE_CRON, request);
|
||||
request.setId("pro_wx_2");
|
||||
this.requestPost(PROJECT_SCHEDULE_TASK_UPDATE_CRON, request);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -8,7 +8,10 @@ import io.metersphere.api.mapper.ApiReportRelateTaskMapper;
|
|||
import io.metersphere.engine.EngineFactory;
|
||||
import io.metersphere.engine.MsHttpClient;
|
||||
import io.metersphere.project.domain.Project;
|
||||
import io.metersphere.project.domain.ProjectApplication;
|
||||
import io.metersphere.project.domain.ProjectApplicationExample;
|
||||
import io.metersphere.project.domain.ProjectExample;
|
||||
import io.metersphere.project.mapper.ProjectApplicationMapper;
|
||||
import io.metersphere.project.mapper.ProjectMapper;
|
||||
import io.metersphere.sdk.constants.*;
|
||||
import io.metersphere.sdk.exception.MSException;
|
||||
|
@ -122,6 +125,8 @@ public class BaseTaskHubService {
|
|||
ApiScheduleNoticeService apiScheduleNoticeService;
|
||||
@Resource
|
||||
private UserToolService userToolService;
|
||||
@Resource
|
||||
private ProjectApplicationMapper projectApplicationMapper;
|
||||
|
||||
|
||||
/**
|
||||
|
@ -937,6 +942,7 @@ public class BaseTaskHubService {
|
|||
schedule.setValue(request.getCron());
|
||||
scheduleService.editSchedule(schedule);
|
||||
try {
|
||||
handleThirdSchedule(schedule, request.getCron());
|
||||
scheduleService.addOrUpdateCronJob(schedule, new JobKey(schedule.getKey(), schedule.getJob()),
|
||||
new TriggerKey(schedule.getKey(), schedule.getJob()), Class.forName(schedule.getJob()));
|
||||
saveLog(List.of(schedule), userId, path, HttpMethodConstants.GET.name(), module, OperationLogType.UPDATE.name());
|
||||
|
@ -946,6 +952,29 @@ public class BaseTaskHubService {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 处理三方同步任务
|
||||
*
|
||||
* @param schedule
|
||||
*/
|
||||
private void handleThirdSchedule(Schedule schedule, String cron) {
|
||||
if (StringUtils.equalsAnyIgnoreCase(schedule.getResourceType(), ScheduleResourceType.BUG_SYNC.name(), ScheduleResourceType.DEMAND_SYNC.name())) {
|
||||
ProjectApplicationExample example = new ProjectApplicationExample();
|
||||
ProjectApplicationExample.Criteria criteria = example.createCriteria();
|
||||
criteria.andProjectIdEqualTo(schedule.getProjectId());
|
||||
if (StringUtils.equalsIgnoreCase(schedule.getResourceType(), ScheduleResourceType.BUG_SYNC.name())) {
|
||||
criteria.andTypeEqualTo(ProjectApplicationType.BUG.BUG_SYNC.name() + "_" + ProjectApplicationType.BUG_SYNC_CONFIG.CRON_EXPRESSION.name());
|
||||
}
|
||||
if (StringUtils.equalsIgnoreCase(schedule.getResourceType(), ScheduleResourceType.DEMAND_SYNC.name())) {
|
||||
criteria.andTypeEqualTo(ProjectApplicationType.CASE_RELATED_CONFIG.CASE_RELATED.name() + "_" + ProjectApplicationType.CASE_RELATED_CONFIG.CRON_EXPRESSION.name());
|
||||
}
|
||||
ProjectApplication projectApplication = new ProjectApplication();
|
||||
projectApplication.setTypeValue(cron);
|
||||
projectApplicationMapper.updateByExampleSelective(projectApplication, example);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询批量执行任务报告列表
|
||||
*
|
||||
|
|
Loading…
Reference in New Issue