feature(web): 增加跨天版本表显示
This commit is contained in:
@@ -1,9 +1,12 @@
|
||||
package com.lanyuanxiaoyao.service.web.controller;
|
||||
|
||||
import cn.hutool.core.map.MapUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.lanyuanxiaoyao.service.configuration.entity.AmisResponse;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import org.eclipse.collections.api.factory.Maps;
|
||||
import org.eclipse.collections.api.map.MutableMap;
|
||||
|
||||
/**
|
||||
* 放一些 Controller 的辅助方法
|
||||
@@ -65,4 +68,28 @@ public class BaseController {
|
||||
.build())
|
||||
.build();
|
||||
}
|
||||
|
||||
protected MutableMap<String, Object> buildQueryMap(
|
||||
Integer page,
|
||||
Integer count,
|
||||
String order,
|
||||
String direction,
|
||||
String searchFlinkJobId,
|
||||
String searchAlias
|
||||
) {
|
||||
MutableMap<String, Object> queryMap = Maps.mutable.empty();
|
||||
queryMap.put("page", page);
|
||||
queryMap.put("count", count);
|
||||
if (StrUtil.isNotBlank(searchFlinkJobId)) {
|
||||
queryMap.put("flink_job_id", searchFlinkJobId);
|
||||
}
|
||||
if (StrUtil.isNotBlank(searchAlias)) {
|
||||
queryMap.put("alias", searchAlias);
|
||||
}
|
||||
if (StrUtil.isNotBlank(order) && StrUtil.isNotBlank(direction)) {
|
||||
queryMap.put("order", order);
|
||||
queryMap.put("direction", direction);
|
||||
}
|
||||
return queryMap;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ import cn.hutool.core.util.StrUtil;
|
||||
import com.lanyuanxiaoyao.service.configuration.entity.AmisResponse;
|
||||
import com.lanyuanxiaoyao.service.web.entity.CloudServiceVO;
|
||||
import com.netflix.appinfo.InstanceInfo;
|
||||
import java.util.Map;
|
||||
import org.eclipse.collections.api.block.function.Function;
|
||||
import org.eclipse.collections.api.factory.Lists;
|
||||
import org.eclipse.collections.api.factory.Maps;
|
||||
@@ -20,8 +21,6 @@ import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 云页面
|
||||
*
|
||||
@@ -138,4 +137,9 @@ public class CloudController extends BaseController {
|
||||
.build()
|
||||
);
|
||||
}
|
||||
|
||||
@GetMapping("heart")
|
||||
public AmisResponse heart() {
|
||||
return responseData().withData("status", true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,89 @@
|
||||
package com.lanyuanxiaoyao.service.web.controller;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.eshore.odcp.hudi.connector.entity.FlinkJob;
|
||||
import com.eshore.odcp.hudi.connector.entity.TableMeta;
|
||||
import com.lanyuanxiaoyao.service.configuration.ExecutorProvider;
|
||||
import com.lanyuanxiaoyao.service.configuration.entity.AmisResponse;
|
||||
import com.lanyuanxiaoyao.service.configuration.entity.PageResponse;
|
||||
import com.lanyuanxiaoyao.service.configuration.entity.info.VersionUpdated;
|
||||
import com.lanyuanxiaoyao.service.forest.service.InfoService;
|
||||
import com.lanyuanxiaoyao.service.web.entity.VersionUpdateVO;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import org.eclipse.collections.api.factory.Lists;
|
||||
import org.eclipse.collections.api.list.ImmutableList;
|
||||
import org.eclipse.collections.api.map.MutableMap;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* 跨天相关
|
||||
*
|
||||
* @author lanyuanxiaoyao
|
||||
* @date 2023-06-06
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("version_upadte")
|
||||
public class VersionController extends BaseController {
|
||||
private static final Logger logger = LoggerFactory.getLogger(VersionController.class);
|
||||
|
||||
private final InfoService infoService;
|
||||
|
||||
@SuppressWarnings("SpringJavaInjectionPointsAutowiringInspection")
|
||||
public VersionController(InfoService infoService) {
|
||||
this.infoService = infoService;
|
||||
}
|
||||
|
||||
@GetMapping("list")
|
||||
public AmisResponse list(
|
||||
@RequestParam(value = "page", defaultValue = "1") Integer page,
|
||||
@RequestParam(value = "count", defaultValue = "10") Integer count,
|
||||
@RequestParam(value = "order", required = false) String order,
|
||||
@RequestParam(value = "direction", required = false) String direction,
|
||||
@RequestParam(value = "search_version", required = false) String searchVersion,
|
||||
@RequestParam(value = "search_flink_job_id", required = false) String searchFlinkJobId,
|
||||
@RequestParam(value = "search_alias", required = false) String searchAlias,
|
||||
@RequestParam(value = "filter_schedules", required = false) List<Boolean> filterSchedules
|
||||
) {
|
||||
MutableMap<String, Object> queryMap = buildQueryMap(page, count, order, direction, searchFlinkJobId, searchAlias);
|
||||
if (StrUtil.isNotBlank(searchVersion)) {
|
||||
queryMap.put("version", searchVersion);
|
||||
}
|
||||
if (ObjectUtil.isNotEmpty(filterSchedules)) {
|
||||
queryMap.put("filter_schedules", filterSchedules);
|
||||
}
|
||||
PageResponse<VersionUpdated> pageResponse = infoService.versionTables(queryMap);
|
||||
Long total = pageResponse.getTotal();
|
||||
ImmutableList<VersionUpdateVO> vos = Lists.immutable.ofAll(pageResponse.getData())
|
||||
.asParallel(ExecutorProvider.EXECUTORS, 1)
|
||||
.collect(item -> {
|
||||
CompletableFuture<FlinkJob> flinkJobFuture = CompletableFuture.supplyAsync(() -> infoService.flinkJobDetail(item.getFlinkJobId()), ExecutorProvider.EXECUTORS);
|
||||
CompletableFuture<TableMeta> tableMetaFuture = CompletableFuture.supplyAsync(() -> infoService.tableMetaDetail(item.getFlinkJobId(), item.getAlias()), ExecutorProvider.EXECUTORS);
|
||||
try {
|
||||
CompletableFuture.allOf(flinkJobFuture, tableMetaFuture).get();
|
||||
return new VersionUpdateVO(
|
||||
item.getFlinkJobId(),
|
||||
item.getAlias(),
|
||||
item.getVersion(),
|
||||
item.getUpdated(),
|
||||
flinkJobFuture.get(),
|
||||
tableMetaFuture.get()
|
||||
);
|
||||
} catch (InterruptedException | ExecutionException e) {
|
||||
logger.error("Something bad", e);
|
||||
return null;
|
||||
}
|
||||
})
|
||||
.reject(ObjectUtil::isNull)
|
||||
.toList()
|
||||
.toImmutable();
|
||||
return responseCrudData(vos, total);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
package com.lanyuanxiaoyao.service.web.entity;
|
||||
|
||||
import com.eshore.odcp.hudi.connector.entity.FlinkJob;
|
||||
import com.eshore.odcp.hudi.connector.entity.TableMeta;
|
||||
|
||||
/**
|
||||
* @author lanyuanxiaoyao
|
||||
* @date 2023-06-07
|
||||
*/
|
||||
public class VersionUpdateVO {
|
||||
private final String flinkJobId;
|
||||
private final String alias;
|
||||
private final String version;
|
||||
private final Boolean updated;
|
||||
private final Integer priority;
|
||||
|
||||
private final FlinkJob flinkJob;
|
||||
private final TableMeta tableMeta;
|
||||
|
||||
public VersionUpdateVO(Long flinkJobId, String alias, String version, Boolean updated, FlinkJob flinkJob, TableMeta tableMeta) {
|
||||
this.flinkJobId = flinkJobId.toString();
|
||||
this.alias = alias;
|
||||
this.version = version;
|
||||
this.updated = updated;
|
||||
this.flinkJob = flinkJob;
|
||||
this.tableMeta = tableMeta;
|
||||
this.priority = tableMeta.getPriority();
|
||||
}
|
||||
|
||||
public String getFlinkJobId() {
|
||||
return flinkJobId;
|
||||
}
|
||||
|
||||
public String getAlias() {
|
||||
return alias;
|
||||
}
|
||||
|
||||
public String getVersion() {
|
||||
return version;
|
||||
}
|
||||
|
||||
public Boolean getUpdated() {
|
||||
return updated;
|
||||
}
|
||||
|
||||
public Integer getPriority() {
|
||||
return priority;
|
||||
}
|
||||
|
||||
public FlinkJob getFlinkJob() {
|
||||
return flinkJob;
|
||||
}
|
||||
|
||||
public TableMeta getTableMeta() {
|
||||
return tableMeta;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "VersionUpdateVO{" +
|
||||
"flinkJobId='" + flinkJobId + '\'' +
|
||||
", alias='" + alias + '\'' +
|
||||
", version='" + version + '\'' +
|
||||
", updated=" + updated +
|
||||
", priority=" + priority +
|
||||
", flinkJob=" + flinkJob +
|
||||
", tableMeta=" + tableMeta +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user