Compare commits
13 Commits
2d41de0c66
...
0b7d80da4a
Author | SHA1 | Date |
---|---|---|
wangliwen | 0b7d80da4a | |
wangliwen | 0f554f188d | |
wangliwen | a7de7fa61a | |
wangliwen | 1b320e74e4 | |
wangliwen | dface05dfb | |
wangliwen | 3b90fb7a4a | |
wangliwen | 5045213674 | |
wangliwen | 2d677cfefc | |
wangliwen | 42690164fb | |
wangliwen | b4af15eab1 | |
wangliwen | ae66fffc8d | |
wangliwen | 21603f50fa | |
wangliwen | ae61f7fcc5 |
|
@ -1,10 +1,13 @@
|
||||||
package io.renren.common.controller;
|
package io.renren.common.controller;
|
||||||
|
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSON;
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import io.renren.common.annotation.LogOperation;
|
import io.renren.common.annotation.LogOperation;
|
||||||
|
import io.renren.common.constant.Constant;
|
||||||
|
import io.renren.common.domain.Tsingtao_xhaProperties;
|
||||||
import io.renren.common.utils.Result;
|
import io.renren.common.utils.Result;
|
||||||
import io.renren.modules.processForm.service.TAbilityApplicationService;
|
import io.renren.modules.processForm.service.TAbilityApplicationService;
|
||||||
import io.renren.modules.resource.service.ResourceService;
|
import io.renren.modules.resource.service.ResourceService;
|
||||||
|
@ -14,6 +17,9 @@ import io.renren.modules.sys.service.SysDeptService;
|
||||||
import io.renren.modules.sys.service.SysUserService;
|
import io.renren.modules.sys.service.SysUserService;
|
||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
import okhttp3.OkHttpClient;
|
||||||
|
import okhttp3.Request;
|
||||||
|
import okhttp3.Response;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
@ -34,6 +40,8 @@ import java.util.stream.Collectors;
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/census/center/v2")
|
@RequestMapping("/census/center/v2")
|
||||||
public class CensusControllerV2 {
|
public class CensusControllerV2 {
|
||||||
|
@Value("${project.place}")
|
||||||
|
private Integer projectPlace;
|
||||||
private static final Logger logger = LoggerFactory.getLogger(CensusControllerV2.class);
|
private static final Logger logger = LoggerFactory.getLogger(CensusControllerV2.class);
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
|
@ -49,6 +57,8 @@ public class CensusControllerV2 {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private JdbcTemplate jdbcTemplate;
|
private JdbcTemplate jdbcTemplate;
|
||||||
|
@Autowired
|
||||||
|
private Tsingtao_xhaProperties tsingtao_xhaProperties;
|
||||||
|
|
||||||
@Value("${census.type}")
|
@Value("${census.type}")
|
||||||
private String[] censusTypes; // 需要进行统计的资源类型
|
private String[] censusTypes; // 需要进行统计的资源类型
|
||||||
|
@ -297,4 +307,244 @@ public class CensusControllerV2 {
|
||||||
return new Result().ok(resourceService.componentServiceRank(type));
|
return new Result().ok(resourceService.componentServiceRank(type));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@GetMapping("/infrastructureInfo")
|
||||||
|
@ApiOperation("基础设施简况")
|
||||||
|
@LogOperation("基础设施简况")
|
||||||
|
public Result<List<Map<String, Object>>> infrastructureInfo() {
|
||||||
|
List<Map<String, Object>> result = new CopyOnWriteArrayList<>();
|
||||||
|
CompletableFuture<Void> allAmount = null;
|
||||||
|
switch (Constant.ProjectPlace.getByFlag(projectPlace)) {
|
||||||
|
case BAOTOU: { // 包头
|
||||||
|
allAmount = CompletableFuture.supplyAsync(() -> { // 获取平台总基础设施数目
|
||||||
|
return jdbcTemplate.queryForObject("SELECT COUNT(id) FROM tb_data_resource WHERE type = '基础设施' AND del_flag = 0", Long.class);
|
||||||
|
}).thenAccept(sum -> {
|
||||||
|
result.add(new HashMap<String, Object>() {
|
||||||
|
{
|
||||||
|
put("amount", sum);
|
||||||
|
put("type", "视频资源数量");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case TSINGTAO: { // 青岛大数据局
|
||||||
|
allAmount = CompletableFuture.supplyAsync(() -> { // 获取平台总基础设施数目
|
||||||
|
return jdbcTemplate.queryForObject("SELECT COUNT(*) FROM t_camera;", Long.class);
|
||||||
|
}).thenAccept(sum -> {
|
||||||
|
result.add(new HashMap<String, Object>() {
|
||||||
|
{
|
||||||
|
put("amount", sum);
|
||||||
|
put("type", "视频资源数量");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case TSINGTAO_XHA: { // 青岛西海岸
|
||||||
|
allAmount = CompletableFuture.supplyAsync(() -> { // 获取平台总基础设施数目
|
||||||
|
List<Long> result_ = new CopyOnWriteArrayList<>();
|
||||||
|
CompletableFuture cloud =
|
||||||
|
CompletableFuture.runAsync(() -> { // 云脑专网
|
||||||
|
OkHttpClient client = new OkHttpClient();
|
||||||
|
Request request = new Request.Builder().url(tsingtao_xhaProperties.getCloudcam()).build();
|
||||||
|
try (Response response = client.newCall(request).execute()) {
|
||||||
|
if (response.isSuccessful()) {
|
||||||
|
JSONObject jsonObject = JSON.parseObject(response.body().string());
|
||||||
|
if (jsonObject.containsKey("data")) {
|
||||||
|
result_.add(jsonObject.getJSONObject("data").getLongValue("total"));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
logger.error("包头获取失败");
|
||||||
|
}
|
||||||
|
} catch (Exception exception) {
|
||||||
|
logger.error("包头失败", exception);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
CompletableFuture local =
|
||||||
|
CompletableFuture.runAsync(() -> { // 金宏网
|
||||||
|
OkHttpClient client = new OkHttpClient();
|
||||||
|
Request request = new Request.Builder().url(tsingtao_xhaProperties.getLocalcam()).build();
|
||||||
|
try (Response response = client.newCall(request).execute()) {
|
||||||
|
if (response.isSuccessful()) {
|
||||||
|
JSONObject jsonObject = JSON.parseObject(response.body().string());
|
||||||
|
if (jsonObject.containsKey("data")) {
|
||||||
|
result_.add(jsonObject.getJSONObject("data").getLongValue("total"));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
logger.error("包头获取失败");
|
||||||
|
}
|
||||||
|
} catch (Exception exception) {
|
||||||
|
logger.error("包头失败", exception);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
CompletableFuture.allOf(cloud, local);
|
||||||
|
return result_.stream().filter(index -> index != null).findAny().orElse(0l);
|
||||||
|
}).thenAccept(sum -> {
|
||||||
|
result.add(new HashMap<String, Object>() {
|
||||||
|
{
|
||||||
|
put("amount", sum);
|
||||||
|
put("type", "视频资源数量");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
CompletableFuture<Void> all = CompletableFuture.allOf(allAmount);
|
||||||
|
all.join();
|
||||||
|
return new Result().ok(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@GetMapping("/dataResourceInfo")
|
||||||
|
@ApiOperation("数据资源简况")
|
||||||
|
@LogOperation("数据资源简况")
|
||||||
|
public Result<List<Map<String, Object>>> dataResourceInfo() {
|
||||||
|
List<Map<String, Object>> result = new CopyOnWriteArrayList<>();
|
||||||
|
CompletableFuture<Void> allAmount = null;
|
||||||
|
CompletableFuture<Void> applyInfo = null; // 申请情况
|
||||||
|
switch (Constant.ProjectPlace.getByFlag(projectPlace)) {
|
||||||
|
case BAOTOU: { // TODO 包头
|
||||||
|
result.add(new HashMap<String, Object>() {
|
||||||
|
{
|
||||||
|
put("amount", 0L);
|
||||||
|
put("type", "总数据量");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
result.add(new HashMap<String, Object>() {
|
||||||
|
{
|
||||||
|
put("amount", 0l);
|
||||||
|
put("type", "总申请次数");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
result.add(new HashMap<String, Object>() {
|
||||||
|
{
|
||||||
|
put("amount", 1);
|
||||||
|
put("type", "满足率");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
result.add(new HashMap<String, Object>() {
|
||||||
|
{
|
||||||
|
put("resourceTop5", new ArrayList<>());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case TSINGTAO: { // TODO 青岛大数据局
|
||||||
|
result.add(new HashMap<String, Object>() {
|
||||||
|
{
|
||||||
|
put("amount", 0L);
|
||||||
|
put("type", "总数据量");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
result.add(new HashMap<String, Object>() {
|
||||||
|
{
|
||||||
|
put("amount", 0l);
|
||||||
|
put("type", "总申请次数");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
result.add(new HashMap<String, Object>() {
|
||||||
|
{
|
||||||
|
put("amount", 1);
|
||||||
|
put("type", "满足率");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
result.add(new HashMap<String, Object>() {
|
||||||
|
{
|
||||||
|
put("resourceTop5", new ArrayList<>());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case TSINGTAO_XHA: { // 青岛西海岸
|
||||||
|
allAmount = CompletableFuture.supplyAsync(() -> { // 获取平台数据资源总数目
|
||||||
|
OkHttpClient client = new OkHttpClient();
|
||||||
|
Long total = 0L;
|
||||||
|
Request request = new Request.Builder().url(tsingtao_xhaProperties.getResourcecount()).build();
|
||||||
|
try (Response response = client.newCall(request).execute()) {
|
||||||
|
if (response.isSuccessful()) {
|
||||||
|
JSONObject jsonObject = JSON.parseObject(response.body().string());
|
||||||
|
if (jsonObject.containsKey("data")) {
|
||||||
|
total = jsonObject.getJSONObject("data").getLongValue("total");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
logger.error("包头获取失败");
|
||||||
|
}
|
||||||
|
} catch (Exception exception) {
|
||||||
|
logger.error("包头失败", exception);
|
||||||
|
}
|
||||||
|
return total;
|
||||||
|
}).thenAccept(sum -> {
|
||||||
|
result.add(new HashMap<String, Object>() {
|
||||||
|
{
|
||||||
|
put("amount", sum);
|
||||||
|
put("type", "总数据量");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}); // 处理总数目
|
||||||
|
|
||||||
|
applyInfo = CompletableFuture.runAsync(() -> {
|
||||||
|
OkHttpClient client = new OkHttpClient();
|
||||||
|
Request request = new Request.Builder().url(tsingtao_xhaProperties.getResourceapplyinfo()).build();
|
||||||
|
try (Response response = client.newCall(request).execute()) {
|
||||||
|
if (response.isSuccessful()) {
|
||||||
|
JSONObject jsonObject = JSON.parseObject(response.body().string());
|
||||||
|
if (jsonObject.containsKey("data")) {
|
||||||
|
result.add(new HashMap<String, Object>() {
|
||||||
|
{
|
||||||
|
put("amount", jsonObject.getJSONObject("data").getLongValue("requestCount"));
|
||||||
|
put("type", "总申请次数");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
result.add(new HashMap<String, Object>() {
|
||||||
|
{
|
||||||
|
put("amount", jsonObject.getJSONObject("data").getIntValue("satisfactionRate"));
|
||||||
|
put("type", "满足率");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
result.add(new HashMap<String, Object>() {
|
||||||
|
{
|
||||||
|
put("resourceTop5", jsonObject.getJSONObject("data").getJSONArray("resourceTop5").stream().map(index -> (JSONObject) JSON.toJSON(index)).map(index -> new HashMap<String, Object>() {
|
||||||
|
{
|
||||||
|
put("服务名称", index.getString("service_name"));
|
||||||
|
put("申请次数", index.getLongValue("count"));
|
||||||
|
}
|
||||||
|
}).collect(Collectors.toList()));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
logger.error("包头获取失败");
|
||||||
|
}
|
||||||
|
} catch (Exception exception) {
|
||||||
|
logger.error("包头失败", exception);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (allAmount == null) {
|
||||||
|
allAmount = CompletableFuture.runAsync(() -> {
|
||||||
|
try {
|
||||||
|
Thread.sleep(100l);
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if (applyInfo == null) {
|
||||||
|
applyInfo = CompletableFuture.runAsync(() -> {
|
||||||
|
try {
|
||||||
|
Thread.sleep(100l);
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
CompletableFuture<Void> all = CompletableFuture.allOf(allAmount, applyInfo);
|
||||||
|
all.join();
|
||||||
|
return new Result().ok(result);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,19 @@
|
||||||
|
package io.renren.common.domain;
|
||||||
|
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||||
|
import org.springframework.context.annotation.PropertySource;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 包头区域配置项
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@Component
|
||||||
|
@PropertySource("classpath:/domain/baotou.properties")
|
||||||
|
@ConfigurationProperties(prefix = "baotou")
|
||||||
|
public class BaoTouProperties {
|
||||||
|
private String hlsurl;
|
||||||
|
}
|
|
@ -0,0 +1,18 @@
|
||||||
|
package io.renren.common.domain;
|
||||||
|
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||||
|
import org.springframework.context.annotation.PropertySource;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 青岛市区
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@Component
|
||||||
|
@PropertySource("classpath:/domain/tsingtao.properties")
|
||||||
|
@ConfigurationProperties(prefix = "tsingtao")
|
||||||
|
public class TsingtaoProperties {
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,23 @@
|
||||||
|
package io.renren.common.domain;
|
||||||
|
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||||
|
import org.springframework.context.annotation.PropertySource;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 青岛西海岸
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@Component
|
||||||
|
@PropertySource("classpath:/domain/tsingtao-xha.properties")
|
||||||
|
@ConfigurationProperties(prefix = "tsingtao-xha")
|
||||||
|
public class Tsingtao_xhaProperties {
|
||||||
|
private String cloudhls;
|
||||||
|
private String localhls;
|
||||||
|
private String cloudcam;
|
||||||
|
private String localcam;
|
||||||
|
private String resourcecount;
|
||||||
|
private String resourceapplyinfo;
|
||||||
|
}
|
|
@ -13,6 +13,8 @@ import io.renren.common.validator.group.DefaultGroup;
|
||||||
import io.renren.modules.resource.dto.ResourceDTO;
|
import io.renren.modules.resource.dto.ResourceDTO;
|
||||||
import io.renren.modules.resource.excel.ResourceExcelImportListener;
|
import io.renren.modules.resource.excel.ResourceExcelImportListener;
|
||||||
import io.renren.modules.resource.service.ResourceService;
|
import io.renren.modules.resource.service.ResourceService;
|
||||||
|
import io.renren.modules.resource.videoPreview.AbstractVideoPreviewService;
|
||||||
|
import io.renren.modules.resource.videoPreview.VideoPreviewFactory;
|
||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
import io.swagger.annotations.ApiImplicitParam;
|
import io.swagger.annotations.ApiImplicitParam;
|
||||||
import io.swagger.annotations.ApiImplicitParams;
|
import io.swagger.annotations.ApiImplicitParams;
|
||||||
|
@ -399,4 +401,15 @@ public class ResourceController {
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@GetMapping("getHls")
|
||||||
|
@ApiOperation("对接知识库数据")
|
||||||
|
public Result<String> getHls(String key) {
|
||||||
|
Optional<AbstractVideoPreviewService> factory = VideoPreviewFactory.build();
|
||||||
|
if (factory.isPresent()) {
|
||||||
|
String hls = factory.get().getHls(key);
|
||||||
|
return new Result<String>().ok(hls);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -81,4 +81,6 @@ public interface ResourceService extends CrudService<ResourceEntity, ResourceDTO
|
||||||
void KnowledgeBase();
|
void KnowledgeBase();
|
||||||
|
|
||||||
Object componentServiceRank(String type);
|
Object componentServiceRank(String type);
|
||||||
|
|
||||||
|
Integer getProjectPlace();
|
||||||
}
|
}
|
|
@ -58,6 +58,9 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
|
||||||
|
|
||||||
private static final Logger logger = LoggerFactory.getLogger(ResourceServiceImpl.class);
|
private static final Logger logger = LoggerFactory.getLogger(ResourceServiceImpl.class);
|
||||||
|
|
||||||
|
@Value("${project.place}")
|
||||||
|
private Integer projectPlace;
|
||||||
|
|
||||||
@Value("${zsk.appid}")
|
@Value("${zsk.appid}")
|
||||||
private String appId;
|
private String appId;
|
||||||
|
|
||||||
|
@ -730,4 +733,9 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
|
||||||
return new HashMap<>();
|
return new HashMap<>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Integer getProjectPlace() {
|
||||||
|
return this.projectPlace;
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -0,0 +1,16 @@
|
||||||
|
package io.renren.modules.resource.videoPreview;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 视频预览抽象类
|
||||||
|
*/
|
||||||
|
public abstract class AbstractVideoPreviewService {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取hls预览地址
|
||||||
|
*
|
||||||
|
* @param key 获取hls地址的键
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public abstract String getHls(String key);
|
||||||
|
}
|
|
@ -0,0 +1,72 @@
|
||||||
|
package io.renren.modules.resource.videoPreview;
|
||||||
|
|
||||||
|
|
||||||
|
import io.renren.common.constant.Constant;
|
||||||
|
import io.renren.common.domain.BaoTouProperties;
|
||||||
|
import io.renren.common.domain.TsingtaoProperties;
|
||||||
|
import io.renren.common.domain.Tsingtao_xhaProperties;
|
||||||
|
import io.renren.common.utils.SpringContextUtils;
|
||||||
|
import io.renren.modules.monitor.service.MonitorService;
|
||||||
|
import io.renren.modules.resource.service.ResourceService;
|
||||||
|
import io.renren.modules.resource.videoPreview.domain.BaoTouVideoPreviewService;
|
||||||
|
import io.renren.modules.resource.videoPreview.domain.TsingtaoVideoPreviewService;
|
||||||
|
import io.renren.modules.resource.videoPreview.domain.TsingtaoXHAVideoPreviewService;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 视频预览工厂类
|
||||||
|
*/
|
||||||
|
public final class VideoPreviewFactory {
|
||||||
|
private static Logger logger = LoggerFactory.getLogger(VideoPreviewFactory.class);
|
||||||
|
private static ResourceService resourceService;
|
||||||
|
private static int projectPlace;
|
||||||
|
|
||||||
|
private static BaoTouProperties baoTouProperties; // 包头配置
|
||||||
|
|
||||||
|
private static MonitorService monitorService;
|
||||||
|
|
||||||
|
private static TsingtaoProperties tsingtaoProperties; // 青岛市区配置
|
||||||
|
|
||||||
|
private static Tsingtao_xhaProperties tsingtao_xhaProperties; // 青岛西海岸配置
|
||||||
|
|
||||||
|
static {
|
||||||
|
VideoPreviewFactory.resourceService = SpringContextUtils.getBean(ResourceService.class);
|
||||||
|
VideoPreviewFactory.projectPlace = resourceService.getProjectPlace();
|
||||||
|
VideoPreviewFactory.baoTouProperties = SpringContextUtils.getBean(BaoTouProperties.class);
|
||||||
|
VideoPreviewFactory.monitorService = SpringContextUtils.getBean(MonitorService.class);
|
||||||
|
|
||||||
|
VideoPreviewFactory.tsingtaoProperties = SpringContextUtils.getBean(TsingtaoProperties.class);
|
||||||
|
VideoPreviewFactory.tsingtao_xhaProperties = SpringContextUtils.getBean(Tsingtao_xhaProperties.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取预览服务实现
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static Optional<AbstractVideoPreviewService> build() {
|
||||||
|
AbstractVideoPreviewService abstractVideoPreviewService = null;
|
||||||
|
switch (Constant.ProjectPlace.getByFlag(projectPlace)) {
|
||||||
|
case TSINGTAO: { // 青岛市局
|
||||||
|
abstractVideoPreviewService = new TsingtaoVideoPreviewService(monitorService);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case TSINGTAO_XHA: { // 青岛西海岸
|
||||||
|
abstractVideoPreviewService = new TsingtaoXHAVideoPreviewService(tsingtao_xhaProperties);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case BAOTOU: { // 包头
|
||||||
|
abstractVideoPreviewService = new BaoTouVideoPreviewService(baoTouProperties);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case UNKNOWN: { // 未知区域
|
||||||
|
logger.error("区域未知");
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return Optional.ofNullable(abstractVideoPreviewService);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,51 @@
|
||||||
|
package io.renren.modules.resource.videoPreview.domain;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSON;
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import io.renren.common.domain.BaoTouProperties;
|
||||||
|
import io.renren.modules.resource.videoPreview.AbstractVideoPreviewService;
|
||||||
|
import okhttp3.OkHttpClient;
|
||||||
|
import okhttp3.Request;
|
||||||
|
import okhttp3.Response;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 包头预览
|
||||||
|
*/
|
||||||
|
public class BaoTouVideoPreviewService extends AbstractVideoPreviewService {
|
||||||
|
private static Logger logger = LoggerFactory.getLogger(BaoTouVideoPreviewService.class);
|
||||||
|
private static final OkHttpClient client = new OkHttpClient();
|
||||||
|
|
||||||
|
private BaoTouProperties baoTouProperties;
|
||||||
|
|
||||||
|
public BaoTouVideoPreviewService(BaoTouProperties baoTouProperties) {
|
||||||
|
this.baoTouProperties = baoTouProperties;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取hls预览地址
|
||||||
|
*
|
||||||
|
* @param key 获取hls地址的键
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public String getHls(String key) {
|
||||||
|
String hls = null;
|
||||||
|
Request request = new Request.Builder().url(String.format(baoTouProperties.getHlsurl(), key)).build();
|
||||||
|
try (Response response = client.newCall(request).execute()) {
|
||||||
|
if (response.isSuccessful()) {
|
||||||
|
JSONObject jsonObject = JSON.parseObject(response.body().string());
|
||||||
|
if (jsonObject.containsKey("data")) {
|
||||||
|
hls = jsonObject.getString("data");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
logger.error("包头预览地址获取失败");
|
||||||
|
}
|
||||||
|
} catch (Exception exception) {
|
||||||
|
logger.error("包头预览地址获取失败", exception);
|
||||||
|
}
|
||||||
|
return hls;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,37 @@
|
||||||
|
package io.renren.modules.resource.videoPreview.domain;
|
||||||
|
|
||||||
|
import io.renren.modules.monitor.service.MonitorService;
|
||||||
|
import io.renren.modules.resource.videoPreview.AbstractVideoPreviewService;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 青岛市局预览
|
||||||
|
*/
|
||||||
|
public class TsingtaoVideoPreviewService extends AbstractVideoPreviewService {
|
||||||
|
private static Logger logger = LoggerFactory.getLogger(BaoTouVideoPreviewService.class);
|
||||||
|
|
||||||
|
private MonitorService monitorService;
|
||||||
|
|
||||||
|
public TsingtaoVideoPreviewService(MonitorService monitorService) {
|
||||||
|
this.monitorService = monitorService;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取hls预览地址
|
||||||
|
*
|
||||||
|
* @param key 获取hls地址的键
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public String getHls(String key) {
|
||||||
|
try {
|
||||||
|
return monitorService.fileCode(key);
|
||||||
|
} catch (IOException e) {
|
||||||
|
logger.error("青岛市局获取预览地址失败", e);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,76 @@
|
||||||
|
package io.renren.modules.resource.videoPreview.domain;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSON;
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import io.renren.common.domain.Tsingtao_xhaProperties;
|
||||||
|
import io.renren.modules.resource.videoPreview.AbstractVideoPreviewService;
|
||||||
|
import okhttp3.OkHttpClient;
|
||||||
|
import okhttp3.Request;
|
||||||
|
import okhttp3.Response;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
import java.util.concurrent.CopyOnWriteArrayList;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 青岛西海岸
|
||||||
|
*/
|
||||||
|
public class TsingtaoXHAVideoPreviewService extends AbstractVideoPreviewService {
|
||||||
|
private static Logger logger = LoggerFactory.getLogger(TsingtaoXHAVideoPreviewService.class);
|
||||||
|
Tsingtao_xhaProperties tsingtao_xhaProperties;
|
||||||
|
|
||||||
|
public TsingtaoXHAVideoPreviewService(Tsingtao_xhaProperties tsingtao_xhaProperties) {
|
||||||
|
this.tsingtao_xhaProperties = tsingtao_xhaProperties;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取hls预览地址
|
||||||
|
*
|
||||||
|
* @param key 获取hls地址的键
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public String getHls(String key) {
|
||||||
|
List<String> result = new CopyOnWriteArrayList<>();
|
||||||
|
CompletableFuture cloud =
|
||||||
|
CompletableFuture.runAsync(() -> { // 云脑专网
|
||||||
|
OkHttpClient client = new OkHttpClient();
|
||||||
|
Request request = new Request.Builder().url(String.format(tsingtao_xhaProperties.getCloudhls(), key)).build();
|
||||||
|
try (Response response = client.newCall(request).execute()) {
|
||||||
|
if (response.isSuccessful()) {
|
||||||
|
JSONObject jsonObject = JSON.parseObject(response.body().string());
|
||||||
|
if (jsonObject.containsKey("data")) {
|
||||||
|
result.add(jsonObject.getString("data"));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
logger.error("西海岸预览地址获取失败");
|
||||||
|
}
|
||||||
|
} catch (Exception exception) {
|
||||||
|
logger.error("西海岸预览地址获取失败", exception);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
CompletableFuture local =
|
||||||
|
CompletableFuture.runAsync(() -> { // 金宏网
|
||||||
|
OkHttpClient client = new OkHttpClient();
|
||||||
|
Request request = new Request.Builder().url(String.format(tsingtao_xhaProperties.getLocalhls(), key)).build();
|
||||||
|
try (Response response = client.newCall(request).execute()) {
|
||||||
|
if (response.isSuccessful()) {
|
||||||
|
JSONObject jsonObject = JSON.parseObject(response.body().string());
|
||||||
|
if (jsonObject.containsKey("data")) {
|
||||||
|
result.add(jsonObject.getString("data"));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
logger.error("西海岸预览地址获取失败");
|
||||||
|
}
|
||||||
|
} catch (Exception exception) {
|
||||||
|
logger.error("西海案预览地址获取失败", exception);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
CompletableFuture.allOf(cloud, local);
|
||||||
|
return result.stream().filter(index -> StringUtils.isNotEmpty(index)).findAny().orElse(null);
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,3 +1,6 @@
|
||||||
|
project:
|
||||||
|
# 平台部署位置 0:青岛市区 1:青岛西海岸 2:包头
|
||||||
|
place: 0
|
||||||
# 大数据部门相关配置
|
# 大数据部门相关配置
|
||||||
big_date:
|
big_date:
|
||||||
name: 青岛市大数据发展管理局
|
name: 青岛市大数据发展管理局
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
baotou.hlsurl=http://10.110.205.1:18088/server/device/hisdeviceapplylist/url/%s
|
|
@ -0,0 +1,6 @@
|
||||||
|
tsingtao-xha.cloudhls=http://10.10.30.9:8001/hx-weatherwarning/camera/getCameraLiveStreamByCode?cameraCode=%s&protocol=hls
|
||||||
|
tsingtao-xha.localhls=http://10.134.135.9:8001/hx-weatherwarning/camera/getCameraLiveStreamByCode?cameraCode=%s&protocol=hls
|
||||||
|
tsingtao-xha.cloudcam=http://10.10.30.9:8001/hx-weather-warning/camera/getCameraListByName?name=&pageNo=1&pageSize=10
|
||||||
|
tsingtao-xha.localcam=http://10.134.135.9:8001/hx-weather-warning/camera/getCameraListByName?name=&pageNo=1&pageSize=10
|
||||||
|
tsingtao-xha.resourcecount=http://10.16.3.224:30090/api/share-portal/platform/catalogue/query?catalogueId=&departmentId=&serviceName=&type=&orderField=requestNum&orderType=desc&pageNum=1&pageSize=10&serviceType=data&rq=1655106309671.43
|
||||||
|
tsingtao-xha.resourceapplyinfo=http://10.134.135.24:30058/shareportal/platform/index/abilityMarket/count
|
|
@ -1,5 +1,7 @@
|
||||||
package io.renren.common.constant;
|
package io.renren.common.constant;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 常量
|
* 常量
|
||||||
*/
|
*/
|
||||||
|
@ -212,4 +214,40 @@ public interface Constant {
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 项目运行地点
|
||||||
|
*/
|
||||||
|
enum ProjectPlace {
|
||||||
|
/**
|
||||||
|
* 青岛市区
|
||||||
|
*/
|
||||||
|
TSINGTAO(0),
|
||||||
|
/**
|
||||||
|
* 青岛西海岸
|
||||||
|
*/
|
||||||
|
TSINGTAO_XHA(1),
|
||||||
|
/**
|
||||||
|
* 包头
|
||||||
|
*/
|
||||||
|
BAOTOU(2),
|
||||||
|
/**
|
||||||
|
* 未知
|
||||||
|
*/
|
||||||
|
UNKNOWN(Integer.MAX_VALUE);
|
||||||
|
private int value;
|
||||||
|
|
||||||
|
ProjectPlace(int value) {
|
||||||
|
this.value = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getValue() {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ProjectPlace getByFlag(int flag) {
|
||||||
|
ProjectPlace[] index = ProjectPlace.values();
|
||||||
|
return Arrays.asList(index).stream().filter(index_ -> index_.value == flag).findAny().orElse(ProjectPlace.UNKNOWN);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue