feat:(1.3.0-beta1): 任务管理列表新增负责人
This commit is contained in:
parent
e1cc61fd47
commit
d19635b3e4
@ -147,4 +147,9 @@ public class Job extends CreateUpdateDt {
|
||||
*/
|
||||
private String notifyIds;
|
||||
|
||||
/**
|
||||
* 负责人id
|
||||
*/
|
||||
private Long owerId;
|
||||
|
||||
}
|
||||
|
@ -15,5 +15,6 @@ public class JobQueryVO extends BaseQueryVO {
|
||||
private String groupName;
|
||||
private String jobName;
|
||||
private Integer jobStatus;
|
||||
private String owerName;
|
||||
private String executorInfo;
|
||||
}
|
||||
|
@ -130,4 +130,9 @@ public class JobRequestVO {
|
||||
*/
|
||||
private Set<Long> notifyIds;
|
||||
|
||||
/**
|
||||
* 负责人id
|
||||
*/
|
||||
private Long owerId;
|
||||
|
||||
}
|
||||
|
@ -134,4 +134,12 @@ public class JobResponseVO {
|
||||
* 通知告警场景配置id列表
|
||||
*/
|
||||
private Set<Long> notifyIds;
|
||||
|
||||
/**
|
||||
* 负责人名称
|
||||
*/
|
||||
private String owerName;
|
||||
|
||||
private Long owerId;
|
||||
|
||||
}
|
||||
|
@ -33,11 +33,14 @@ import com.aizuda.snailjob.server.web.util.UserSessionUtils;
|
||||
import com.aizuda.snailjob.template.datasource.access.AccessTemplate;
|
||||
import com.aizuda.snailjob.template.datasource.persistence.mapper.JobMapper;
|
||||
import com.aizuda.snailjob.template.datasource.persistence.mapper.JobSummaryMapper;
|
||||
import com.aizuda.snailjob.template.datasource.persistence.mapper.SystemUserMapper;
|
||||
import com.aizuda.snailjob.template.datasource.persistence.po.GroupConfig;
|
||||
import com.aizuda.snailjob.template.datasource.persistence.po.Job;
|
||||
import com.aizuda.snailjob.template.datasource.persistence.po.JobSummary;
|
||||
import com.aizuda.snailjob.template.datasource.persistence.po.SystemUser;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.PageDTO;
|
||||
import com.google.common.collect.Lists;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.Getter;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
@ -48,6 +51,7 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @author opensnail
|
||||
@ -66,6 +70,7 @@ public class JobServiceImpl implements JobService {
|
||||
private final AccessTemplate accessTemplate;
|
||||
private final GroupHandler groupHandler;
|
||||
private final JobSummaryMapper jobSummaryMapper;
|
||||
private final SystemUserMapper systemUserMapper;
|
||||
|
||||
private static Long calculateNextTriggerAt(final JobRequestVO jobRequestVO, Long time) {
|
||||
if (Objects.equals(jobRequestVO.getTriggerType(), SystemConstants.WORKFLOW_TRIGGER_TYPE)) {
|
||||
@ -86,20 +91,35 @@ public class JobServiceImpl implements JobService {
|
||||
UserSessionVO userSessionVO = UserSessionUtils.currentUserSession();
|
||||
List<String> groupNames = UserSessionUtils.getGroupNames(queryVO.getGroupName());
|
||||
|
||||
Set<Long> owerIds = systemUserMapper.selectList(new LambdaQueryWrapper<SystemUser>()
|
||||
.select(SystemUser::getId)
|
||||
.likeRight(SystemUser::getUsername, queryVO.getOwerName()))
|
||||
.stream()
|
||||
.map(i -> i.getId())
|
||||
.collect(Collectors.toSet());
|
||||
if (CollUtil.isEmpty(owerIds) && StrUtil.isNotBlank(queryVO.getOwerName())) {
|
||||
return new PageResult<>(pageDTO, Lists.newArrayList());
|
||||
}
|
||||
|
||||
PageDTO<Job> selectPage = jobMapper.selectPage(pageDTO,
|
||||
new LambdaQueryWrapper<Job>()
|
||||
.eq(Job::getNamespaceId, userSessionVO.getNamespaceId())
|
||||
.in(CollUtil.isNotEmpty(groupNames), Job::getGroupName, groupNames)
|
||||
.likeRight(StrUtil.isNotBlank(queryVO.getJobName()), Job::getJobName,
|
||||
StrUtil.trim(queryVO.getJobName()))
|
||||
.likeRight(StrUtil.isNotBlank(queryVO.getJobName()), Job::getJobName, StrUtil.trim(queryVO.getJobName()))
|
||||
.like(StrUtil.isNotBlank(queryVO.getExecutorInfo()), Job::getExecutorInfo,
|
||||
StrUtil.trim(queryVO.getExecutorInfo()))
|
||||
.eq(Objects.nonNull(queryVO.getJobStatus()), Job::getJobStatus, queryVO.getJobStatus())
|
||||
.eq(Job::getDeleted, StatusEnum.NO.getStatus())
|
||||
.in(CollUtil.isNotEmpty(owerIds), Job::getOwerId, owerIds)
|
||||
.orderByDesc(Job::getId));
|
||||
|
||||
List<JobResponseVO> jobResponseList = JobResponseVOConverter.INSTANCE.convertList(selectPage.getRecords());
|
||||
|
||||
for (JobResponseVO jobResponseVO : jobResponseList) {
|
||||
SystemUser systemUser = systemUserMapper.selectById(jobResponseVO.getOwerId());
|
||||
if (Objects.nonNull(systemUser)) {
|
||||
jobResponseVO.setOwerName(systemUser.getUsername());
|
||||
}
|
||||
}
|
||||
return new PageResult<>(pageDTO, jobResponseList);
|
||||
}
|
||||
|
||||
@ -142,6 +162,7 @@ public class JobServiceImpl implements JobService {
|
||||
job.setNextTriggerAt(calculateNextTriggerAt(jobRequestVO, DateUtils.toNowMilli()));
|
||||
job.setNamespaceId(UserSessionUtils.currentUserSession().getNamespaceId());
|
||||
job.setNotifyIds(JsonUtil.toJsonString(jobRequestVO.getNotifyIds()));
|
||||
job.setOwerId(jobRequestVO.getOwerId());
|
||||
job.setId(null);
|
||||
return 1 == jobMapper.insert(job);
|
||||
}
|
||||
@ -156,6 +177,7 @@ public class JobServiceImpl implements JobService {
|
||||
// 判断常驻任务
|
||||
Job updateJob = JobConverter.INSTANCE.convert(jobRequestVO);
|
||||
updateJob.setNotifyIds(JsonUtil.toJsonString(jobRequestVO.getNotifyIds()));
|
||||
updateJob.setOwerId(jobRequestVO.getOwerId());
|
||||
updateJob.setResident(isResident(jobRequestVO));
|
||||
updateJob.setNamespaceId(job.getNamespaceId());
|
||||
|
||||
|
@ -53,7 +53,7 @@ public class NotifyConfigServiceImpl implements NotifyConfigService {
|
||||
.eq(StrUtil.isNotBlank(queryVO.getGroupName()), NotifyConfig::getGroupName, queryVO.getGroupName())
|
||||
.eq(Objects.nonNull(queryVO.getNotifyStatus()), NotifyConfig::getNotifyStatus, queryVO.getNotifyStatus())
|
||||
.eq(Objects.nonNull(queryVO.getSystemTaskType()), NotifyConfig::getSystemTaskType, queryVO.getSystemTaskType())
|
||||
.like(StrUtil.isNotBlank(queryVO.getNotifyName()), NotifyConfig::getNotifyName, queryVO.getNotifyName())
|
||||
.likeRight(StrUtil.isNotBlank(queryVO.getNotifyName()), NotifyConfig::getNotifyName, queryVO.getNotifyName())
|
||||
.orderByDesc(NotifyConfig::getId))
|
||||
.getRecords();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user