use of com.dtstack.taier.dao.pager.PageQuery in project Taier by DTStack.
the class ConsoleService method groupDetail.
public PageResult groupDetail(String jobResource, String nodeAddress, Integer stage, Integer pageSize, Integer currentPage) {
if (StringUtils.isBlank(nodeAddress)) {
nodeAddress = null;
}
List<Map<String, Object>> data = new ArrayList<>();
Long count = 0L;
int start = (currentPage - 1) * pageSize;
try {
count = scheduleEngineJobCacheMapper.countByJobResource(jobResource, stage, nodeAddress);
if (count > 0) {
List<ScheduleEngineJobCache> engineJobCaches = scheduleEngineJobCacheMapper.listByJobResource(jobResource, stage, nodeAddress, start, pageSize);
List<String> jobIds = engineJobCaches.stream().map(ScheduleEngineJobCache::getJobId).collect(Collectors.toList());
List<ScheduleJob> rdosJobByJobIds = scheduleJobMapper.getRdosJobByJobIds(jobIds);
Map<String, ScheduleJob> scheduleJobMap = rdosJobByJobIds.stream().collect(Collectors.toMap(ScheduleJob::getJobId, u -> u));
Set<Long> tenantIds = rdosJobByJobIds.stream().map(ScheduleJob::getTenantId).collect(Collectors.toSet());
Map<Long, Tenant> tenantMap = tenantMapper.selectBatchIds(tenantIds).stream().collect(Collectors.toMap(Tenant::getId, t -> t));
for (ScheduleEngineJobCache engineJobCache : engineJobCaches) {
Map<String, Object> theJobMap = PublicUtil.objectToMap(engineJobCache);
ScheduleJob scheduleJob = scheduleJobMap.getOrDefault(engineJobCache.getJobId(), new ScheduleJob());
// 补充租户信息
Tenant tenant = tenantMap.get(scheduleJob.getTenantId());
this.fillJobInfo(theJobMap, scheduleJob, engineJobCache, tenant);
data.add(theJobMap);
}
}
} catch (Exception e) {
LOGGER.error("groupDetail error", e);
}
PageQuery pageQuery = new PageQuery<>(currentPage, pageSize);
return new PageResult<>(data, count.intValue(), pageQuery);
}
use of com.dtstack.taier.dao.pager.PageQuery in project Taier by DTStack.
the class BatchTaskService method getTaskById.
/**
* 数据开发-根据任务id,查询详情
*
* @return
* @author toutian
*/
public BatchTaskBatchVO getTaskById(final ScheduleTaskVO scheduleTaskVO) {
final BatchTask task = this.developTaskDao.getOne(scheduleTaskVO.getId());
if (task == null) {
throw new RdosDefineException(ErrorCode.CAN_NOT_FIND_TASK);
}
final List<BatchResource> resources = this.batchTaskResourceService.getResources(scheduleTaskVO.getId(), ResourceRefType.MAIN_RES.getType());
final List<BatchResource> refResourceIdList = this.batchTaskResourceService.getResources(scheduleTaskVO.getId(), ResourceRefType.DEPENDENCY_RES.getType());
final BatchTaskBatchVO taskVO = new BatchTaskBatchVO(this.batchTaskTaskService.getForefathers(task));
taskVO.setVersion(task.getVersion());
if (task.getTaskType().intValue() == EScheduleJobType.SYNC.getVal().intValue()) {
// 同步任务类型
final String taskJson = Base64Util.baseDecode(task.getSqlText());
if (StringUtils.isBlank(taskJson)) {
// 向导模式存在为空的情况
taskVO.setCreateModel(Constant.CREATE_MODEL_GUIDE);
taskVO.setSqlText("");
} else {
final JSONObject obj = JSON.parseObject(taskJson);
taskVO.setCreateModel(obj.get("createModel") == null ? Constant.CREATE_MODEL_GUIDE : Integer.parseInt(String.valueOf(obj.get("createModel"))));
formatSqlText(taskVO, obj);
}
}
this.setTaskOperatorModelAndOptions(taskVO, task);
if (task.getFlowId() != null && task.getFlowId() > 0) {
taskVO.setFlowId(task.getFlowId());
final BatchTask flow = this.developTaskDao.getOne(task.getFlowId());
if (flow != null) {
taskVO.setFlowName(flow.getName());
}
}
final BatchCatalogue catalogue = batchCatalogueService.getOne(task.getNodePid());
if (catalogue != null) {
taskVO.setNodePName(catalogue.getNodeName());
}
taskVO.setResourceList(resources);
taskVO.setRefResourceList(refResourceIdList);
PageQuery pageQuery = new PageQuery(1, 5, "gmt_create", Sort.DESC.name());
List<BatchTaskVersionDetailDTO> taskVersions = batchTaskVersionService.listByTaskId(scheduleTaskVO.getId(), pageQuery).stream().map(ver -> {
if (StringUtils.isNotBlank(ver.getOriginSql())) {
if (task.getTaskType().intValue() == EScheduleJobType.SYNC.getVal().intValue()) {
ver.setSqlText(ver.getSqlText());
} else {
ver.setSqlText(ver.getOriginSql());
}
}
// 填充用户名称
ver.setUserName(userService.getUserName(ver.getCreateUserId()));
return ver;
}).collect(Collectors.toList());
taskVO.setTaskVersions(taskVersions);
// 密码脱敏 --2019/10/25 茂茂-- 同步任务 密码脱敏 仅 向导模式 修改成 全部模式
if (task.getTaskType().intValue() == EScheduleJobType.SYNC.getVal().intValue()) {
try {
taskVO.setSqlText(JsonUtils.formatJSON(DataFilter.passwordFilter(taskVO.getSqlText())));
} catch (final Exception e) {
LOGGER.error("同步任务json解析失败 taskId = {}", task.getId(), e);
taskVO.setSqlText(DataFilter.passwordFilter(taskVO.getSqlText()));
}
for (BatchTaskVersionDetailDTO taskVersion : taskVO.getTaskVersions()) {
try {
taskVersion.setSqlText(JsonUtils.formatJSON(DataFilter.passwordFilter(taskVersion.getSqlText())));
} catch (final Exception e) {
LOGGER.error("同步任务json解析失败 taskVersionId = {}", taskVersion.getId(), e);
taskVersion.setSqlText(DataFilter.passwordFilter(taskVersion.getSqlText()));
}
}
}
final ReadWriteLockVO readWriteLockVO = this.readWriteLockService.getDetail(scheduleTaskVO.getTenantId(), task.getId(), ReadWriteLockType.BATCH_TASK, scheduleTaskVO.getUserId(), task.getModifyUserId(), task.getGmtModified());
taskVO.setReadWriteLockVO(readWriteLockVO);
taskVO.setUserId(scheduleTaskVO.getUserId());
setTaskVariables(taskVO, scheduleTaskVO.getId());
final List<Long> userIds = new ArrayList<>();
userIds.add(task.getCreateUserId());
final Map<Long, User> userMap = userService.getUserMap(userIds);
buildUserDTOInfo(userMap, taskVO);
return taskVO;
}
use of com.dtstack.taier.dao.pager.PageQuery in project Taier by DTStack.
the class BatchTaskService method getTaskVersionRecord.
public List<BatchTaskVersionDetailDTO> getTaskVersionRecord(Long taskId, Integer pageSize, Integer pageNo) {
if (pageNo == null) {
pageNo = 0;
}
if (pageSize == null) {
pageSize = 10;
}
PageQuery pageQuery = new PageQuery(pageNo, pageSize, "gmt_create", Sort.DESC.name());
List<BatchTaskVersionDetailDTO> res = batchTaskVersionService.listByTaskId(taskId, pageQuery);
for (BatchTaskVersionDetailDTO detail : res) {
detail.setUserName(userService.getUserName(detail.getCreateUserId()));
}
return res;
}
use of com.dtstack.taier.dao.pager.PageQuery in project Taier by DTStack.
the class BatchTaskService method getFlowWorkSubTasks.
/**
* 获取任务流下的所有子任务
*
* @param taskId
* @return
*/
public List<BatchTask> getFlowWorkSubTasks(final Long taskId) {
BatchTaskDTO batchTaskDTO = new BatchTaskDTO();
batchTaskDTO.setIsDeleted(Deleted.NORMAL.getStatus());
batchTaskDTO.setFlowId(taskId);
PageQuery<BatchTaskDTO> pageQuery = new PageQuery<>(batchTaskDTO);
List<BatchTask> batchTasks = this.developTaskDao.generalQuery(pageQuery);
return batchTasks;
}
use of com.dtstack.taier.dao.pager.PageQuery in project Taier by DTStack.
the class TenantService method pageQuery.
public PageResult<List<ClusterTenantVO>> pageQuery(Long clusterId, String tenantName, int pageSize, int currentPage) {
PageQuery query = new PageQuery(currentPage, pageSize, "gmt_modified", Sort.DESC.name());
int count = clusterTenantMapper.generalCount(clusterId, tenantName);
if (count == 0) {
return PageResult.EMPTY_PAGE_RESULT;
}
List<ClusterTenant> clusterTenants = clusterTenantMapper.generalQuery(query, clusterId, tenantName);
List<ClusterTenantVO> clusterTenantVOS = fillQueue(clusterTenants);
return new PageResult(clusterTenantVOS, count, query);
}
Aggregations