diff --git a/pom.xml b/pom.xml
index 49fa3b31..5cd5f048 100644
--- a/pom.xml
+++ b/pom.xml
@@ -13,6 +13,7 @@
wvp-pro
2.0
web video platform
+ 国标28181视频平台
@@ -250,6 +251,11 @@
+
+ pl.project13.maven
+ git-commit-id-plugin
+
+
org.apache.maven.plugins
maven-surefire-plugin
diff --git a/src/main/java/com/genersoft/iot/vmp/common/VersionPo.java b/src/main/java/com/genersoft/iot/vmp/common/VersionPo.java
new file mode 100644
index 00000000..a7d8ce67
--- /dev/null
+++ b/src/main/java/com/genersoft/iot/vmp/common/VersionPo.java
@@ -0,0 +1,136 @@
+package com.genersoft.iot.vmp.common;
+
+import com.alibaba.fastjson.annotation.JSONField;
+
+public class VersionPo {
+ /**
+ * git的全版本号
+ */
+ @JSONField(name="GIT-Revision")
+ private String GIT_Revision;
+ /**
+ * maven版本
+ */
+ @JSONField(name = "Create-By")
+ private String Create_By;
+ /**
+ * git的分支
+ */
+ @JSONField(name = "GIT-BRANCH")
+ private String GIT_BRANCH;
+ /**
+ * git的url
+ */
+ @JSONField(name = "GIT-URL")
+ private String GIT_URL;
+ /**
+ * 构建日期
+ */
+ @JSONField(name = "BUILD-DATE")
+ private String BUILD_DATE;
+ /**
+ * 项目名称 配合pom使用
+ */
+ @JSONField(name = "artifactId")
+ private String artifactId;
+ /**
+ * git局部版本号
+ */
+ @JSONField(name = "GIT-Revision-SHORT")
+ private String GIT_Revision_SHORT;
+ /**
+ * 项目的版本如2.0.1.0 配合pom使用
+ */
+ @JSONField(name = "version")
+ private String version;
+ /**
+ * 子系统名称
+ */
+ @JSONField(name = "project")
+ private String project;
+ /**
+ * jdk版本
+ */
+ @JSONField(name="Build_Jdk")
+ private String Build_Jdk;
+
+ public void setGIT_Revision(String GIT_Revision) {
+ this.GIT_Revision = GIT_Revision;
+ }
+
+ public void setCreate_By(String create_By) {
+ Create_By = create_By;
+ }
+
+ public void setGIT_BRANCH(String GIT_BRANCH) {
+ this.GIT_BRANCH = GIT_BRANCH;
+ }
+
+ public void setGIT_URL(String GIT_URL) {
+ this.GIT_URL = GIT_URL;
+ }
+
+ public void setBUILD_DATE(String BUILD_DATE) {
+ this.BUILD_DATE = BUILD_DATE;
+ }
+
+ public void setArtifactId(String artifactId) {
+ this.artifactId = artifactId;
+ }
+
+ public void setGIT_Revision_SHORT(String GIT_Revision_SHORT) {
+ this.GIT_Revision_SHORT = GIT_Revision_SHORT;
+ }
+
+ public void setVersion(String version) {
+ this.version = version;
+ }
+
+ public void setProject(String project) {
+ this.project = project;
+ }
+
+ public void setBuild_Jdk(String build_Jdk) {
+ Build_Jdk = build_Jdk;
+ }
+
+ public String getGIT_Revision() {
+ return GIT_Revision;
+ }
+
+ public String getCreate_By() {
+ return Create_By;
+ }
+
+ public String getGIT_BRANCH() {
+ return GIT_BRANCH;
+ }
+
+ public String getGIT_URL() {
+ return GIT_URL;
+ }
+
+ public String getBUILD_DATE() {
+ return BUILD_DATE;
+ }
+
+ public String getArtifactId() {
+ return artifactId;
+ }
+
+ public String getGIT_Revision_SHORT() {
+ return GIT_Revision_SHORT;
+ }
+
+ public String getVersion() {
+ return version;
+ }
+
+ public String getProject() {
+ return project;
+ }
+
+ public String getBuild_Jdk() {
+ return Build_Jdk;
+ }
+}
diff --git a/src/main/java/com/genersoft/iot/vmp/conf/ProxyServletConfig.java b/src/main/java/com/genersoft/iot/vmp/conf/ProxyServletConfig.java
index ab327b0e..907e30d3 100644
--- a/src/main/java/com/genersoft/iot/vmp/conf/ProxyServletConfig.java
+++ b/src/main/java/com/genersoft/iot/vmp/conf/ProxyServletConfig.java
@@ -141,8 +141,6 @@ public class ProxyServletConfig {
}
}
-
-
@Bean
public ServletRegistrationBean recordServletRegistrationBean(){
ServletRegistrationBean servletRegistrationBean = new ServletRegistrationBean(new RecordProxySerlet(),"/record_proxy/*");
diff --git a/src/main/java/com/genersoft/iot/vmp/conf/VersionConfig.java b/src/main/java/com/genersoft/iot/vmp/conf/VersionConfig.java
new file mode 100644
index 00000000..a24ade41
--- /dev/null
+++ b/src/main/java/com/genersoft/iot/vmp/conf/VersionConfig.java
@@ -0,0 +1,37 @@
+package com.genersoft.iot.vmp.conf;
+
+import org.springframework.boot.context.properties.ConfigurationProperties;
+import org.springframework.stereotype.Component;
+
+@Component
+@ConfigurationProperties(prefix = "version")
+public class VersionConfig {
+
+ private String version;
+ private String artifactId;
+ private String description;
+
+ public void setVersion(String version) {
+ this.version = version;
+ }
+
+ public void setArtifactId(String artifactId) {
+ this.artifactId = artifactId;
+ }
+
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ public String getVersion() {
+ return version;
+ }
+
+ public String getArtifactId() {
+ return artifactId;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+}
diff --git a/src/main/java/com/genersoft/iot/vmp/conf/VersionInfo.java b/src/main/java/com/genersoft/iot/vmp/conf/VersionInfo.java
new file mode 100644
index 00000000..4ff5eba6
--- /dev/null
+++ b/src/main/java/com/genersoft/iot/vmp/conf/VersionInfo.java
@@ -0,0 +1,37 @@
+package com.genersoft.iot.vmp.conf;
+
+import com.genersoft.iot.vmp.common.VersionPo;
+import com.genersoft.iot.vmp.utils.GitUtil;
+import com.genersoft.iot.vmp.utils.JarFileUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+import java.util.Map;
+
+@Component
+public class VersionInfo {
+
+ @Autowired
+ VersionConfig config;
+ @Autowired
+ GitUtil gitUtil;
+ @Autowired
+ JarFileUtils jarFileUtils;
+
+ public VersionPo getVersion() {
+ VersionPo versionPo = new VersionPo();
+ Map map=jarFileUtils.readJarFile();
+ versionPo.setGIT_Revision(gitUtil.getGitCommitId());
+ versionPo.setCreate_By(map.get("Created-By"));
+ versionPo.setGIT_BRANCH(gitUtil.getBranch());
+ versionPo.setGIT_URL(gitUtil.getGitUrl());
+ versionPo.setBUILD_DATE(gitUtil.getBuildDate());
+ versionPo.setArtifactId(config.getArtifactId());
+ versionPo.setGIT_Revision_SHORT(gitUtil.getCommitIdShort());
+ versionPo.setVersion(config.getVersion());
+ versionPo.setProject(config.getDescription());
+ versionPo.setBuild_Jdk(map.get("Build-Jdk"));
+
+ return versionPo;
+ }
+}
diff --git a/src/main/java/com/genersoft/iot/vmp/utils/GitUtil.java b/src/main/java/com/genersoft/iot/vmp/utils/GitUtil.java
new file mode 100644
index 00000000..60ee987c
--- /dev/null
+++ b/src/main/java/com/genersoft/iot/vmp/utils/GitUtil.java
@@ -0,0 +1,44 @@
+package com.genersoft.iot.vmp.utils;
+
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.context.annotation.PropertySource;
+import org.springframework.stereotype.Component;
+
+/**
+ * 一个优秀的颓废程序猿(CSDN)
+ */
+@Component
+@PropertySource(value = {"classpath:git.properties" }, ignoreResourceNotFound = true)
+public class GitUtil {
+
+ @Value("${git.branch:null}")
+ private String branch;
+ @Value("${git.commit.id:null}")
+ private String gitCommitId;
+ @Value("${git.remote.origin.url:null}")
+ private String gitUrl;
+ @Value("${git.build.time:null}")
+ private String buildDate;
+ @Value("${git.commit.id.abbrev:null}")
+ private String commitIdShort;
+
+ public String getGitCommitId() {
+ return gitCommitId;
+ }
+
+ public String getBranch() {
+ return branch;
+ }
+
+ public String getGitUrl() {
+ return gitUrl;
+ }
+
+ public String getBuildDate() {
+ return buildDate;
+ }
+
+ public String getCommitIdShort() {
+ return commitIdShort;
+ }
+}
diff --git a/src/main/java/com/genersoft/iot/vmp/utils/JarFileUtils.java b/src/main/java/com/genersoft/iot/vmp/utils/JarFileUtils.java
new file mode 100644
index 00000000..686b562d
--- /dev/null
+++ b/src/main/java/com/genersoft/iot/vmp/utils/JarFileUtils.java
@@ -0,0 +1,73 @@
+package com.genersoft.iot.vmp.utils;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.stereotype.Component;
+import org.springframework.util.ClassUtils;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.jar.JarEntry;
+import java.util.jar.JarFile;
+
+/**
+ * 一个优秀的颓废程序猿
+ */
+@Component
+public class JarFileUtils {
+ private static Logger log = LoggerFactory.getLogger(JarFileUtils.class);
+ private static Map map = new HashMap<>();
+
+ public Map readJarFile() {
+ JarFile jarFile = null;
+ BufferedReader br = null;
+ try {
+ // 获取jar的运行路径,因linux下jar的路径为”file:/app/.../test.jar!/BOOT-INF/class!/“这种格式,所以需要去掉”file:“和”!/BOOT-INF/class!/“
+ String jarFilePath = ClassUtils.getDefaultClassLoader().getResource("").getPath().replace("!/BOOT-INF/classes!/", "");
+ if (jarFilePath.startsWith("file")) {
+ jarFilePath = jarFilePath.substring(5);
+ }
+ log.debug("jarFilePath:" + jarFilePath);
+ // 通过JarFile的getJarEntry方法读取META-INF/MANIFEST.MF
+ jarFile = new JarFile(jarFilePath);
+ JarEntry entry = jarFile.getJarEntry("META-INF/MANIFEST.MF");
+ log.info("读取的内容:" + entry.toString());
+ // 如果读取到MANIFEST.MF文件内容,则转换为string
+ if (entry != null) {
+ InputStream in = jarFile.getInputStream(entry);
+
+ StringBuilder sb = new StringBuilder();
+ br = new BufferedReader(new InputStreamReader(in));
+ String line = "";
+ while ((line = br.readLine()) != null) {
+ if (line != null && line.contains(":")) {
+ int index = line.indexOf(":");
+ map.put(line.substring(0, index).trim(), line.substring(index + 1, line.length()).trim());
+ }
+ }
+ return map;
+ }
+ } catch (IOException e) {
+ log.debug("读取MANIFEST.MF文件异常:" + e.getMessage());
+ } finally {
+ try {
+ if (null != br) {
+ br.close();
+ }
+ if (null != jarFile) {
+ jarFile.close();
+ }
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+
+ return map;
+
+ }
+
+}
diff --git a/src/main/java/com/genersoft/iot/vmp/vmanager/server/ServerController.java b/src/main/java/com/genersoft/iot/vmp/vmanager/server/ServerController.java
index 76ad86c9..4b7adc60 100644
--- a/src/main/java/com/genersoft/iot/vmp/vmanager/server/ServerController.java
+++ b/src/main/java/com/genersoft/iot/vmp/vmanager/server/ServerController.java
@@ -1,6 +1,8 @@
package com.genersoft.iot.vmp.vmanager.server;
import com.genersoft.iot.vmp.VManageBootstrap;
+import com.genersoft.iot.vmp.common.VersionPo;
+import com.genersoft.iot.vmp.conf.VersionInfo;
import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem;
import com.genersoft.iot.vmp.service.IMediaServerService;
import com.genersoft.iot.vmp.utils.SpringBeanFactory;
@@ -31,6 +33,9 @@ public class ServerController {
@Autowired
private IMediaServerService mediaServerService;
+ @Autowired
+ VersionInfo versionInfo;
+
@ApiOperation("流媒体服务列表")
@GetMapping(value = "/media_server/list")
@@ -97,4 +102,15 @@ public class ServerController {
restartThread.start();
return "success";
}
+
+ @ApiOperation("版本信息")
+ @GetMapping(value = "/version")
+ @ResponseBody
+ public WVPResult getVersion(){
+ WVPResult result = new WVPResult<>();
+ result.setCode(0);
+ result.setMsg("success");
+ result.setData(versionInfo.getVersion());
+ return result;
+ }
}