From 21603f50faab9ecf1572398cc5531199cced6e08 Mon Sep 17 00:00:00 2001 From: wangliwen Date: Tue, 21 Jun 2022 09:48:36 +0800 Subject: [PATCH 01/10] =?UTF-8?q?=E9=BB=98=E8=AE=A4=E9=83=A8=E7=BD=B2=20?= =?UTF-8?q?=E9=9D=92=E5=B2=9B=E5=B8=82=E5=8C=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- renren-admin/src/main/resources/application.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/renren-admin/src/main/resources/application.yml b/renren-admin/src/main/resources/application.yml index 425c184e..35bf83c3 100644 --- a/renren-admin/src/main/resources/application.yml +++ b/renren-admin/src/main/resources/application.yml @@ -1,6 +1,6 @@ project: # 平台部署位置 0:青岛市区 1:青岛西海岸 2:包头 - place: + place: 0 # 大数据部门相关配置 big_date: name: 青岛市大数据发展管理局 From ae66fffc8de27c60bb0c67967248cb452852f3d7 Mon Sep 17 00:00:00 2001 From: wangliwen Date: Tue, 21 Jun 2022 09:57:12 +0800 Subject: [PATCH 02/10] =?UTF-8?q?=E5=8C=85=E5=A4=B4=E9=85=8D=E7=BD=AE?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E5=BC=95=E5=85=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/domain/BaoTouProperties.java | 19 +++++++++++++++++++ .../src/main/resources/baotou.properties | 1 + 2 files changed, 20 insertions(+) create mode 100644 renren-admin/src/main/java/io/renren/common/domain/BaoTouProperties.java create mode 100644 renren-admin/src/main/resources/baotou.properties diff --git a/renren-admin/src/main/java/io/renren/common/domain/BaoTouProperties.java b/renren-admin/src/main/java/io/renren/common/domain/BaoTouProperties.java new file mode 100644 index 00000000..61f0b17a --- /dev/null +++ b/renren-admin/src/main/java/io/renren/common/domain/BaoTouProperties.java @@ -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:baotou.properties") +@ConfigurationProperties(prefix = "baotou") +public class BaoTouProperties { + private String hlsurl; +} diff --git a/renren-admin/src/main/resources/baotou.properties b/renren-admin/src/main/resources/baotou.properties new file mode 100644 index 00000000..f59252f2 --- /dev/null +++ b/renren-admin/src/main/resources/baotou.properties @@ -0,0 +1 @@ +baotou.hlsurl=http://10.110.205.1:18088/server/device/hisdeviceapplylist/url/%s \ No newline at end of file From b4af15eab1d450af30235db8ec6255db3301bd0b Mon Sep 17 00:00:00 2001 From: wangliwen Date: Tue, 21 Jun 2022 10:05:18 +0800 Subject: [PATCH 03/10] =?UTF-8?q?=E7=8E=B0=E6=9C=89=E5=8C=BA=E5=9F=9F?= =?UTF-8?q?=E9=85=8D=E7=BD=AE=E6=96=87=E4=BB=B6=20=E5=8A=A0=E5=85=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../renren/common/domain/BaoTouProperties.java | 2 +- .../common/domain/TsingtaoProperties.java | 18 ++++++++++++++++++ .../common/domain/Tsingtao_xhaProperties.java | 15 +++++++++++++++ .../resources/{ => domain}/baotou.properties | 0 .../main/resources/domain/tsingtao.properties | 0 .../resources/domain/tsingtao_xha.properties | 0 6 files changed, 34 insertions(+), 1 deletion(-) create mode 100644 renren-admin/src/main/java/io/renren/common/domain/TsingtaoProperties.java create mode 100644 renren-admin/src/main/java/io/renren/common/domain/Tsingtao_xhaProperties.java rename renren-admin/src/main/resources/{ => domain}/baotou.properties (100%) create mode 100644 renren-admin/src/main/resources/domain/tsingtao.properties create mode 100644 renren-admin/src/main/resources/domain/tsingtao_xha.properties diff --git a/renren-admin/src/main/java/io/renren/common/domain/BaoTouProperties.java b/renren-admin/src/main/java/io/renren/common/domain/BaoTouProperties.java index 61f0b17a..471b2158 100644 --- a/renren-admin/src/main/java/io/renren/common/domain/BaoTouProperties.java +++ b/renren-admin/src/main/java/io/renren/common/domain/BaoTouProperties.java @@ -12,7 +12,7 @@ import org.springframework.stereotype.Component; */ @Data @Component -@PropertySource("classpath:baotou.properties") +@PropertySource("classpath:/domain/baotou.properties") @ConfigurationProperties(prefix = "baotou") public class BaoTouProperties { private String hlsurl; diff --git a/renren-admin/src/main/java/io/renren/common/domain/TsingtaoProperties.java b/renren-admin/src/main/java/io/renren/common/domain/TsingtaoProperties.java new file mode 100644 index 00000000..7041bcd8 --- /dev/null +++ b/renren-admin/src/main/java/io/renren/common/domain/TsingtaoProperties.java @@ -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 { + +} diff --git a/renren-admin/src/main/java/io/renren/common/domain/Tsingtao_xhaProperties.java b/renren-admin/src/main/java/io/renren/common/domain/Tsingtao_xhaProperties.java new file mode 100644 index 00000000..391d91d4 --- /dev/null +++ b/renren-admin/src/main/java/io/renren/common/domain/Tsingtao_xhaProperties.java @@ -0,0 +1,15 @@ +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") +public class Tsingtao_xhaProperties { + +} diff --git a/renren-admin/src/main/resources/baotou.properties b/renren-admin/src/main/resources/domain/baotou.properties similarity index 100% rename from renren-admin/src/main/resources/baotou.properties rename to renren-admin/src/main/resources/domain/baotou.properties diff --git a/renren-admin/src/main/resources/domain/tsingtao.properties b/renren-admin/src/main/resources/domain/tsingtao.properties new file mode 100644 index 00000000..e69de29b diff --git a/renren-admin/src/main/resources/domain/tsingtao_xha.properties b/renren-admin/src/main/resources/domain/tsingtao_xha.properties new file mode 100644 index 00000000..e69de29b From 42690164fba2dfd3e4f88ef41138ef5a28224f3b Mon Sep 17 00:00:00 2001 From: wangliwen Date: Tue, 21 Jun 2022 10:08:01 +0800 Subject: [PATCH 04/10] ... --- .../java/io/renren/common/domain/Tsingtao_xhaProperties.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/renren-admin/src/main/java/io/renren/common/domain/Tsingtao_xhaProperties.java b/renren-admin/src/main/java/io/renren/common/domain/Tsingtao_xhaProperties.java index 391d91d4..89e468b5 100644 --- a/renren-admin/src/main/java/io/renren/common/domain/Tsingtao_xhaProperties.java +++ b/renren-admin/src/main/java/io/renren/common/domain/Tsingtao_xhaProperties.java @@ -6,10 +6,13 @@ 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") +@ConfigurationProperties(prefix = "tsingtao_xha") public class Tsingtao_xhaProperties { } From 2d677cfefcfef773e92b673c1abc947d6becee01 Mon Sep 17 00:00:00 2001 From: wangliwen Date: Tue, 21 Jun 2022 10:17:07 +0800 Subject: [PATCH 05/10] .... --- .../java/io/renren/common/domain/Tsingtao_xhaProperties.java | 4 ++-- .../{tsingtao_xha.properties => tsingtao-xha.properties} | 0 2 files changed, 2 insertions(+), 2 deletions(-) rename renren-admin/src/main/resources/domain/{tsingtao_xha.properties => tsingtao-xha.properties} (100%) diff --git a/renren-admin/src/main/java/io/renren/common/domain/Tsingtao_xhaProperties.java b/renren-admin/src/main/java/io/renren/common/domain/Tsingtao_xhaProperties.java index 89e468b5..c435f79b 100644 --- a/renren-admin/src/main/java/io/renren/common/domain/Tsingtao_xhaProperties.java +++ b/renren-admin/src/main/java/io/renren/common/domain/Tsingtao_xhaProperties.java @@ -11,8 +11,8 @@ import org.springframework.stereotype.Component; */ @Data @Component -@PropertySource("classpath:/domain/tsingtao_xha.properties") -@ConfigurationProperties(prefix = "tsingtao_xha") +@PropertySource("classpath:/domain/tsingtao-xha.properties") +@ConfigurationProperties(prefix = "tsingtao-xha") public class Tsingtao_xhaProperties { } diff --git a/renren-admin/src/main/resources/domain/tsingtao_xha.properties b/renren-admin/src/main/resources/domain/tsingtao-xha.properties similarity index 100% rename from renren-admin/src/main/resources/domain/tsingtao_xha.properties rename to renren-admin/src/main/resources/domain/tsingtao-xha.properties From 50452136749414c0c3381bd4298f1ffa91089f89 Mon Sep 17 00:00:00 2001 From: wangliwen Date: Tue, 21 Jun 2022 11:55:26 +0800 Subject: [PATCH 06/10] =?UTF-8?q?=E8=A7=86=E9=A2=91=E9=A2=84=E8=A7=88=20?= =?UTF-8?q?=E5=B7=A5=E5=8E=82=E6=A8=A1=E5=BC=8F=E4=B8=8B=E5=90=84=E5=8C=BA?= =?UTF-8?q?=E5=9F=9F=E7=9A=84=E5=AE=9E=E7=8E=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/domain/Tsingtao_xhaProperties.java | 3 +- .../resource/service/ResourceService.java | 2 + .../service/impl/ResourceServiceImpl.java | 8 ++ .../AbstractVideoPreviewService.java | 16 ++++ .../videoPreview/VideoPreviewFactory.java | 64 ++++++++++++++++ .../domain/BaoTouVideoPreviewService.java | 51 +++++++++++++ .../domain/TsingtaoVideoPreviewService.java | 37 +++++++++ .../TsingtaoXHAVideoPreviewService.java | 76 +++++++++++++++++++ .../resources/domain/tsingtao-xha.properties | 2 + .../io/renren/common/constant/Constant.java | 13 +++- 10 files changed, 270 insertions(+), 2 deletions(-) create mode 100644 renren-admin/src/main/java/io/renren/modules/resource/videoPreview/AbstractVideoPreviewService.java create mode 100644 renren-admin/src/main/java/io/renren/modules/resource/videoPreview/VideoPreviewFactory.java create mode 100644 renren-admin/src/main/java/io/renren/modules/resource/videoPreview/domain/BaoTouVideoPreviewService.java create mode 100644 renren-admin/src/main/java/io/renren/modules/resource/videoPreview/domain/TsingtaoVideoPreviewService.java create mode 100644 renren-admin/src/main/java/io/renren/modules/resource/videoPreview/domain/TsingtaoXHAVideoPreviewService.java diff --git a/renren-admin/src/main/java/io/renren/common/domain/Tsingtao_xhaProperties.java b/renren-admin/src/main/java/io/renren/common/domain/Tsingtao_xhaProperties.java index c435f79b..f816620a 100644 --- a/renren-admin/src/main/java/io/renren/common/domain/Tsingtao_xhaProperties.java +++ b/renren-admin/src/main/java/io/renren/common/domain/Tsingtao_xhaProperties.java @@ -14,5 +14,6 @@ import org.springframework.stereotype.Component; @PropertySource("classpath:/domain/tsingtao-xha.properties") @ConfigurationProperties(prefix = "tsingtao-xha") public class Tsingtao_xhaProperties { - + private String cloudhls; + private String localhls; } diff --git a/renren-admin/src/main/java/io/renren/modules/resource/service/ResourceService.java b/renren-admin/src/main/java/io/renren/modules/resource/service/ResourceService.java index 45888fe0..979c40d5 100644 --- a/renren-admin/src/main/java/io/renren/modules/resource/service/ResourceService.java +++ b/renren-admin/src/main/java/io/renren/modules/resource/service/ResourceService.java @@ -81,4 +81,6 @@ public interface ResourceService extends CrudService(); } } + + @Override + public Integer getProjectPlace() { + return this.projectPlace; + } } \ No newline at end of file diff --git a/renren-admin/src/main/java/io/renren/modules/resource/videoPreview/AbstractVideoPreviewService.java b/renren-admin/src/main/java/io/renren/modules/resource/videoPreview/AbstractVideoPreviewService.java new file mode 100644 index 00000000..79f94a8a --- /dev/null +++ b/renren-admin/src/main/java/io/renren/modules/resource/videoPreview/AbstractVideoPreviewService.java @@ -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); +} diff --git a/renren-admin/src/main/java/io/renren/modules/resource/videoPreview/VideoPreviewFactory.java b/renren-admin/src/main/java/io/renren/modules/resource/videoPreview/VideoPreviewFactory.java new file mode 100644 index 00000000..bd07edfa --- /dev/null +++ b/renren-admin/src/main/java/io/renren/modules/resource/videoPreview/VideoPreviewFactory.java @@ -0,0 +1,64 @@ +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 java.util.Optional; + +/** + * 视频预览工厂类 + */ +public final class VideoPreviewFactory { + 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); + } + + /** + * 获取预览服务实现 + * + * @return + */ + public static Optional build() { + AbstractVideoPreviewService abstractVideoPreviewService = null; + switch (Constant.ProjectPlace.getByFlag(projectPlace)) { + case TSINGTAO: { // 青岛市局 + abstractVideoPreviewService = new TsingtaoVideoPreviewService(monitorService); + } + break; + case TSINGTAO_XHA: { // 青岛西海岸 + + } + break; + case BAOTOU: { // 包头 + abstractVideoPreviewService = new BaoTouVideoPreviewService(baoTouProperties); + } + case UNKNOWN: { // 未知区域 + + } + break; + } + return Optional.ofNullable(abstractVideoPreviewService); + } +} diff --git a/renren-admin/src/main/java/io/renren/modules/resource/videoPreview/domain/BaoTouVideoPreviewService.java b/renren-admin/src/main/java/io/renren/modules/resource/videoPreview/domain/BaoTouVideoPreviewService.java new file mode 100644 index 00000000..b76882b7 --- /dev/null +++ b/renren-admin/src/main/java/io/renren/modules/resource/videoPreview/domain/BaoTouVideoPreviewService.java @@ -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; + } +} diff --git a/renren-admin/src/main/java/io/renren/modules/resource/videoPreview/domain/TsingtaoVideoPreviewService.java b/renren-admin/src/main/java/io/renren/modules/resource/videoPreview/domain/TsingtaoVideoPreviewService.java new file mode 100644 index 00000000..516b4aae --- /dev/null +++ b/renren-admin/src/main/java/io/renren/modules/resource/videoPreview/domain/TsingtaoVideoPreviewService.java @@ -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; + } + } +} diff --git a/renren-admin/src/main/java/io/renren/modules/resource/videoPreview/domain/TsingtaoXHAVideoPreviewService.java b/renren-admin/src/main/java/io/renren/modules/resource/videoPreview/domain/TsingtaoXHAVideoPreviewService.java new file mode 100644 index 00000000..41441d00 --- /dev/null +++ b/renren-admin/src/main/java/io/renren/modules/resource/videoPreview/domain/TsingtaoXHAVideoPreviewService.java @@ -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 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); + } +} diff --git a/renren-admin/src/main/resources/domain/tsingtao-xha.properties b/renren-admin/src/main/resources/domain/tsingtao-xha.properties index e69de29b..b8ee1e93 100644 --- a/renren-admin/src/main/resources/domain/tsingtao-xha.properties +++ b/renren-admin/src/main/resources/domain/tsingtao-xha.properties @@ -0,0 +1,2 @@ +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 \ No newline at end of file diff --git a/renren-common/src/main/java/io/renren/common/constant/Constant.java b/renren-common/src/main/java/io/renren/common/constant/Constant.java index eb0c1beb..1f306bc2 100644 --- a/renren-common/src/main/java/io/renren/common/constant/Constant.java +++ b/renren-common/src/main/java/io/renren/common/constant/Constant.java @@ -1,5 +1,7 @@ package io.renren.common.constant; +import java.util.Arrays; + /** * 常量 */ @@ -228,7 +230,11 @@ public interface Constant { /** * 包头 */ - BAOTOU(2); + BAOTOU(2), + /** + * 未知 + */ + UNKNOWN(Integer.MAX_VALUE); private int value; ProjectPlace(int value) { @@ -238,5 +244,10 @@ public interface Constant { 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); + } } } \ No newline at end of file From 3b90fb7a4acf48a1786993707313df90c1589b7f Mon Sep 17 00:00:00 2001 From: wangliwen Date: Tue, 21 Jun 2022 12:02:13 +0800 Subject: [PATCH 07/10] =?UTF-8?q?=E8=8E=B7=E5=8F=96=E9=A2=84=E8=A7=88?= =?UTF-8?q?=E5=9C=B0=E5=9D=80=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../resource/controller/ResourceController.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/renren-admin/src/main/java/io/renren/modules/resource/controller/ResourceController.java b/renren-admin/src/main/java/io/renren/modules/resource/controller/ResourceController.java index 7353e579..d29d47e1 100644 --- a/renren-admin/src/main/java/io/renren/modules/resource/controller/ResourceController.java +++ b/renren-admin/src/main/java/io/renren/modules/resource/controller/ResourceController.java @@ -13,6 +13,8 @@ import io.renren.common.validator.group.DefaultGroup; import io.renren.modules.resource.dto.ResourceDTO; import io.renren.modules.resource.excel.ResourceExcelImportListener; 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.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParams; @@ -399,4 +401,15 @@ public class ResourceController { } */ + @GetMapping("getHls") + @ApiOperation("对接知识库数据") + public Result getHls(String key) { + Optional factory = VideoPreviewFactory.build(); + if (factory.isPresent()) { + String hls = factory.get().getHls(key); + return new Result().ok(hls); + } + return null; + } + } \ No newline at end of file From dface05dfb85fa1e93d53f3f805ad2e5ab1625e1 Mon Sep 17 00:00:00 2001 From: wangliwen Date: Tue, 21 Jun 2022 13:55:07 +0800 Subject: [PATCH 08/10] ... --- .../resource/videoPreview/VideoPreviewFactory.java | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/renren-admin/src/main/java/io/renren/modules/resource/videoPreview/VideoPreviewFactory.java b/renren-admin/src/main/java/io/renren/modules/resource/videoPreview/VideoPreviewFactory.java index bd07edfa..7b9f2b61 100644 --- a/renren-admin/src/main/java/io/renren/modules/resource/videoPreview/VideoPreviewFactory.java +++ b/renren-admin/src/main/java/io/renren/modules/resource/videoPreview/VideoPreviewFactory.java @@ -10,6 +10,9 @@ 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; @@ -17,6 +20,7 @@ import java.util.Optional; * 视频预览工厂类 */ public final class VideoPreviewFactory { + private static Logger logger = LoggerFactory.getLogger(VideoPreviewFactory.class); private static ResourceService resourceService; private static int projectPlace; @@ -33,6 +37,9 @@ public final class VideoPreviewFactory { 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); } /** @@ -48,14 +55,14 @@ public final class VideoPreviewFactory { } break; case TSINGTAO_XHA: { // 青岛西海岸 - + abstractVideoPreviewService = new TsingtaoXHAVideoPreviewService(tsingtao_xhaProperties); } break; case BAOTOU: { // 包头 abstractVideoPreviewService = new BaoTouVideoPreviewService(baoTouProperties); } case UNKNOWN: { // 未知区域 - + logger.error("区域未知"); } break; } From 1b320e74e47d14002a10498402aebb104c7ee13b Mon Sep 17 00:00:00 2001 From: wangliwen Date: Tue, 21 Jun 2022 14:07:50 +0800 Subject: [PATCH 09/10] =?UTF-8?q?=E3=80=82=E3=80=82=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../modules/resource/videoPreview/VideoPreviewFactory.java | 1 + 1 file changed, 1 insertion(+) diff --git a/renren-admin/src/main/java/io/renren/modules/resource/videoPreview/VideoPreviewFactory.java b/renren-admin/src/main/java/io/renren/modules/resource/videoPreview/VideoPreviewFactory.java index 7b9f2b61..fdf3fcef 100644 --- a/renren-admin/src/main/java/io/renren/modules/resource/videoPreview/VideoPreviewFactory.java +++ b/renren-admin/src/main/java/io/renren/modules/resource/videoPreview/VideoPreviewFactory.java @@ -61,6 +61,7 @@ public final class VideoPreviewFactory { case BAOTOU: { // 包头 abstractVideoPreviewService = new BaoTouVideoPreviewService(baoTouProperties); } + break; case UNKNOWN: { // 未知区域 logger.error("区域未知"); } From a7de7fa61ac14073db983f174555d3bc93de68d0 Mon Sep 17 00:00:00 2001 From: wangliwen Date: Tue, 21 Jun 2022 14:44:29 +0800 Subject: [PATCH 10/10] =?UTF-8?q?=E5=9F=BA=E7=A1=80=E8=AE=BE=E6=96=BD?= =?UTF-8?q?=E7=BB=9F=E8=AE=A1=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/controller/CensusControllerV2.java | 98 +++++++++++++++++++ .../TsingtaoXHAVideoPreviewService.java | 8 +- 2 files changed, 102 insertions(+), 4 deletions(-) diff --git a/renren-admin/src/main/java/io/renren/common/controller/CensusControllerV2.java b/renren-admin/src/main/java/io/renren/common/controller/CensusControllerV2.java index 6ef03b50..dcbe6ea6 100644 --- a/renren-admin/src/main/java/io/renren/common/controller/CensusControllerV2.java +++ b/renren-admin/src/main/java/io/renren/common/controller/CensusControllerV2.java @@ -1,10 +1,13 @@ package io.renren.common.controller; +import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; 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.modules.processForm.service.TAbilityApplicationService; 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.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -34,6 +40,8 @@ import java.util.stream.Collectors; @RestController @RequestMapping("/census/center/v2") public class CensusControllerV2 { + @Value("${project.place}") + private Integer projectPlace; private static final Logger logger = LoggerFactory.getLogger(CensusControllerV2.class); @Autowired @@ -49,6 +57,8 @@ public class CensusControllerV2 { @Autowired private JdbcTemplate jdbcTemplate; + @Autowired + private Tsingtao_xhaProperties tsingtao_xhaProperties; @Value("${census.type}") private String[] censusTypes; // 需要进行统计的资源类型 @@ -297,4 +307,92 @@ public class CensusControllerV2 { return new Result().ok(resourceService.componentServiceRank(type)); } + @GetMapping("/infrastructureInfo") + @ApiOperation("基础设施简况") + @LogOperation("基础设施简况") + public Result>> infrastructureInfo() { + List> result = new CopyOnWriteArrayList<>(); + CompletableFuture 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() { + { + 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() { + { + put("amount", sum); + put("type", "视频资源数量"); + } + }); + }); + } + break; + case TSINGTAO_XHA: { // 青岛西海岸 + allAmount = CompletableFuture.supplyAsync(() -> { // 获取平台总基础设施数目 + List 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() { + { + put("amount", sum); + put("type", "视频资源数量"); + } + }); + }); + } + break; + } + CompletableFuture all = CompletableFuture.allOf(allAmount); + all.join(); + return new Result().ok(result); + } + } diff --git a/renren-admin/src/main/java/io/renren/modules/resource/videoPreview/domain/TsingtaoXHAVideoPreviewService.java b/renren-admin/src/main/java/io/renren/modules/resource/videoPreview/domain/TsingtaoXHAVideoPreviewService.java index 41441d00..bb6b68fe 100644 --- a/renren-admin/src/main/java/io/renren/modules/resource/videoPreview/domain/TsingtaoXHAVideoPreviewService.java +++ b/renren-admin/src/main/java/io/renren/modules/resource/videoPreview/domain/TsingtaoXHAVideoPreviewService.java @@ -47,10 +47,10 @@ public class TsingtaoXHAVideoPreviewService extends AbstractVideoPreviewService result.add(jsonObject.getString("data")); } } else { - logger.error("包头预览地址获取失败"); + logger.error("西海岸预览地址获取失败"); } } catch (Exception exception) { - logger.error("包头预览地址获取失败", exception); + logger.error("西海岸预览地址获取失败", exception); } }); CompletableFuture local = @@ -64,10 +64,10 @@ public class TsingtaoXHAVideoPreviewService extends AbstractVideoPreviewService result.add(jsonObject.getString("data")); } } else { - logger.error("包头预览地址获取失败"); + logger.error("西海岸预览地址获取失败"); } } catch (Exception exception) { - logger.error("包头预览地址获取失败", exception); + logger.error("西海案预览地址获取失败", exception); } }); CompletableFuture.allOf(cloud, local);