wwh il y a 2 ans
Parent
commit
080b3d02c2
48 fichiers modifiés avec 3574 ajouts et 24 suppressions
  1. 5 1
      huimv-farm-video/pom.xml
  2. 69 0
      huimv-farm-video/src/main/java/com/huimv/video/dhicc/test/config/OauthConfigBaseInfo.java
  3. 69 0
      huimv-farm-video/src/main/java/com/huimv/video/dhicc/test/config/OauthConfigBaseInfo02.java
  4. 67 0
      huimv-farm-video/src/main/java/com/huimv/video/dhicc/test/config/OauthConfigUserPwdInfoTest01.java
  5. 67 0
      huimv-farm-video/src/main/java/com/huimv/video/dhicc/test/config/OauthConfigUserPwdInfoTest02.java
  6. 240 0
      huimv-farm-video/src/main/java/com/huimv/video/dhicc/test/constant/Constant.java
  7. 39 0
      huimv-farm-video/src/main/java/com/huimv/video/dhicc/test/constant/ErrorEnum.java
  8. 53 0
      huimv-farm-video/src/main/java/com/huimv/video/dhicc/test/controller/ClientPersonManageControllerTest.java
  9. 51 0
      huimv-farm-video/src/main/java/com/huimv/video/dhicc/test/controller/OauthController.java
  10. 103 0
      huimv-farm-video/src/main/java/com/huimv/video/dhicc/test/controller/VideoRecorControllerSg.java
  11. 25 0
      huimv-farm-video/src/main/java/com/huimv/video/dhicc/test/manager/IOauthIntegrationManager.java
  12. 64 0
      huimv-farm-video/src/main/java/com/huimv/video/dhicc/test/manager/impl/OauthIntegrationManager.java
  13. 9 0
      huimv-farm-video/src/main/java/com/huimv/video/dhicc/test/other/BaseIntegrationManager.java
  14. 65 0
      huimv-farm-video/src/main/java/com/huimv/video/dhicc/test/other/BaseRes.java
  15. 9 0
      huimv-farm-video/src/main/java/com/huimv/video/dhicc/test/other/BaseService.java
  16. 179 0
      huimv-farm-video/src/main/java/com/huimv/video/dhicc/test/request/BaseRequest.java
  17. 179 0
      huimv-farm-video/src/main/java/com/huimv/video/dhicc/test/request/BaseRequest02.java
  18. 35 0
      huimv-farm-video/src/main/java/com/huimv/video/dhicc/test/request/GetPublicKeyRequest.java
  19. 36 0
      huimv-farm-video/src/main/java/com/huimv/video/dhicc/test/request/GetPublicKeyRequest02.java
  20. 20 0
      huimv-farm-video/src/main/java/com/huimv/video/dhicc/test/request/GetPublicKeyRes.java
  21. 87 0
      huimv-farm-video/src/main/java/com/huimv/video/dhicc/test/request/GetTokenRequestTest01.java
  22. 86 0
      huimv-farm-video/src/main/java/com/huimv/video/dhicc/test/request/GetTokenRequestTest02.java
  23. 60 0
      huimv-farm-video/src/main/java/com/huimv/video/dhicc/test/request/OauthRefreshTokenRequest.java
  24. 60 0
      huimv-farm-video/src/main/java/com/huimv/video/dhicc/test/request/OauthRefreshTokenRequest02.java
  25. 73 0
      huimv-farm-video/src/main/java/com/huimv/video/dhicc/test/request/PersonListRequestHn.java
  26. 73 0
      huimv-farm-video/src/main/java/com/huimv/video/dhicc/test/request/PersonListRequestSg.java
  27. 32 0
      huimv-farm-video/src/main/java/com/huimv/video/dhicc/test/response/BaseResponse.java
  28. 16 0
      huimv-farm-video/src/main/java/com/huimv/video/dhicc/test/response/GetPublicKeyResponse.java
  29. 13 0
      huimv-farm-video/src/main/java/com/huimv/video/dhicc/test/response/GetTokenResponse.java
  30. 25 0
      huimv-farm-video/src/main/java/com/huimv/video/dhicc/test/response/OauthRefreshTokenResponse.java
  31. 25 0
      huimv-farm-video/src/main/java/com/huimv/video/dhicc/test/response/OauthRefreshTokenResponse02.java
  32. 22 0
      huimv-farm-video/src/main/java/com/huimv/video/dhicc/test/response/PersonListResponseSg.java
  33. 238 0
      huimv-farm-video/src/main/java/com/huimv/video/dhicc/test/schedule/UpdateTokenSchedule.java
  34. 23 0
      huimv-farm-video/src/main/java/com/huimv/video/dhicc/test/service/IOauthService.java
  35. 99 0
      huimv-farm-video/src/main/java/com/huimv/video/dhicc/test/service/impl/OauthService.java
  36. 48 0
      huimv-farm-video/src/main/java/com/huimv/video/dhicc/test/token/LocalTokenStore.java
  37. 15 0
      huimv-farm-video/src/main/java/com/huimv/video/dhicc/test/token/MysqlStoredToken.java
  38. 124 0
      huimv-farm-video/src/main/java/com/huimv/video/dhicc/test/token/MysqlTokenStore.java
  39. 130 0
      huimv-farm-video/src/main/java/com/huimv/video/dhicc/test/token/RedisTokenStore.java
  40. 30 0
      huimv-farm-video/src/main/java/com/huimv/video/dhicc/test/token/Token.java
  41. 16 0
      huimv-farm-video/src/main/java/com/huimv/video/dhicc/test/token/TokenStore.java
  42. 35 0
      huimv-farm-video/src/main/java/com/huimv/video/dhicc/test/user/UserPasswordConfigInfoTest01.java
  43. 35 0
      huimv-farm-video/src/main/java/com/huimv/video/dhicc/test/user/UserPasswordConfigInfoTest02.java
  44. 66 0
      huimv-farm-video/src/main/java/com/huimv/video/dhicc/test/utils/HttpConfigInfo.java
  45. 337 0
      huimv-farm-video/src/main/java/com/huimv/video/dhicc/test/utils/HttpURLConnectionUtil.java
  46. 381 0
      huimv-farm-video/src/main/java/com/huimv/video/dhicc/test/utils/HttpsURLConnectionUtil.java
  47. 18 0
      huimv-farm-video/src/main/java/com/huimv/video/dhicc/test/utils/UrlUtil.java
  48. 23 23
      huimv-farm-video/src/main/resources/config/iccSdk.properties

+ 5 - 1
huimv-farm-video/pom.xml

@@ -51,7 +51,11 @@
 			<artifactId>httpmime</artifactId>
 			<artifactId>httpmime</artifactId>
 			<version>4.5.12</version>
 			<version>4.5.12</version>
 		</dependency>
 		</dependency>
-
+		<dependency>
+			<groupId>cn.dustlight.captcha</groupId>
+			<artifactId>redis-store</artifactId>
+			<version>0.0.6</version>
+		</dependency>
 		<dependency>
 		<dependency>
 			<groupId>commons-io</groupId>
 			<groupId>commons-io</groupId>
 			<artifactId>commons-io</artifactId>
 			<artifactId>commons-io</artifactId>

+ 69 - 0
huimv-farm-video/src/main/java/com/huimv/video/dhicc/test/config/OauthConfigBaseInfo.java

@@ -0,0 +1,69 @@
+package com.huimv.video.dhicc.test.config;
+
+import com.dahuatech.icc.oauth.profile.GrantType;
+import com.huimv.video.dhicc.test.utils.HttpConfigInfo;
+import lombok.Data;
+
+/**
+ * 鉴权配置信息
+ * **/
+@Data
+public abstract class OauthConfigBaseInfo {
+
+    /** 申请认证ID */
+    protected String clientId;
+    /** 申请认证秘钥 */
+    protected String clientSecret;
+    /** 当前使用认证类型 */
+    protected GrantType grantType;
+    /**平台ip 端口信息*/
+    protected HttpConfigInfo httpConfigInfo;
+
+    public OauthConfigBaseInfo(){
+
+    }
+
+    public OauthConfigBaseInfo(String host, String clientId, String clientSecret, GrantType grantType){
+        this.httpConfigInfo = new HttpConfigInfo(host);
+        this.clientId = clientId;
+        this.clientSecret = clientSecret;
+        this.grantType = grantType;
+    }
+
+    public OauthConfigBaseInfo(String host, String clientId, String clientSecret, GrantType grantType, boolean isEnableHttpTest, String httpsPort, String httpPort){
+        this(host,clientId,clientSecret,grantType);
+        this.httpConfigInfo = new HttpConfigInfo(host,isEnableHttpTest,httpsPort,httpPort);
+    }
+
+    public String getClientId() {
+        return clientId;
+    }
+
+    public void setClientId(String clientId) {
+        this.clientId = clientId;
+    }
+
+    public String getClientSecret() {
+        return clientSecret;
+    }
+
+    public void setClientSecret(String clientSecret) {
+        this.clientSecret = clientSecret;
+    }
+
+    public GrantType getGrantType() {
+        return grantType;
+    }
+
+    public void setGrantType(GrantType grantType) {
+        this.grantType = grantType;
+    }
+
+    public HttpConfigInfo getHttpConfigInfo() {
+        return httpConfigInfo;
+    }
+
+    public void setHttpConfigInfo(HttpConfigInfo httpConfigInfo) {
+        this.httpConfigInfo = httpConfigInfo;
+    }
+}

+ 69 - 0
huimv-farm-video/src/main/java/com/huimv/video/dhicc/test/config/OauthConfigBaseInfo02.java

@@ -0,0 +1,69 @@
+package com.huimv.video.dhicc.test.config;
+
+import com.dahuatech.icc.oauth.profile.GrantType;
+import com.huimv.video.dhicc.test.utils.HttpConfigInfo;
+import lombok.Data;
+
+/**
+ * 鉴权配置信息
+ * **/
+@Data
+public abstract class OauthConfigBaseInfo02 {
+
+    /** 申请认证ID */
+    protected String clientId;
+    /** 申请认证秘钥 */
+    protected String clientSecret;
+    /** 当前使用认证类型 */
+    protected GrantType grantType;
+    /**平台ip 端口信息*/
+    protected HttpConfigInfo httpConfigInfo;
+
+    public OauthConfigBaseInfo02(){
+
+    }
+
+    public OauthConfigBaseInfo02(String host, String clientId, String clientSecret, GrantType grantType){
+        this.httpConfigInfo = new HttpConfigInfo(host);
+        this.clientId = clientId;
+        this.clientSecret = clientSecret;
+        this.grantType = grantType;
+    }
+
+    public OauthConfigBaseInfo02(String host, String clientId, String clientSecret, GrantType grantType, boolean isEnableHttpTest, String httpsPort, String httpPort){
+        this(host,clientId,clientSecret,grantType);
+        this.httpConfigInfo = new HttpConfigInfo(host,isEnableHttpTest,httpsPort,httpPort);
+    }
+
+    public String getClientId() {
+        return clientId;
+    }
+
+    public void setClientId(String clientId) {
+        this.clientId = clientId;
+    }
+
+    public String getClientSecret() {
+        return clientSecret;
+    }
+
+    public void setClientSecret(String clientSecret) {
+        this.clientSecret = clientSecret;
+    }
+
+    public GrantType getGrantType() {
+        return grantType;
+    }
+
+    public void setGrantType(GrantType grantType) {
+        this.grantType = grantType;
+    }
+
+    public HttpConfigInfo getHttpConfigInfo() {
+        return httpConfigInfo;
+    }
+
+    public void setHttpConfigInfo(HttpConfigInfo httpConfigInfo) {
+        this.httpConfigInfo = httpConfigInfo;
+    }
+}

+ 67 - 0
huimv-farm-video/src/main/java/com/huimv/video/dhicc/test/config/OauthConfigUserPwdInfoTest01.java

@@ -0,0 +1,67 @@
+package com.huimv.video.dhicc.test.config;
+
+import com.dahuatech.icc.oauth.profile.GrantType;
+import com.huimv.video.dhicc.test.schedule.UpdateTokenSchedule;
+
+import java.util.Map;
+
+/**
+ * 用户密码模式配置信息
+ */
+public class OauthConfigUserPwdInfoTest01 extends OauthConfigBaseInfo{
+    /** 密码认证用户名 */
+    public String username;//登录平台的用户名,
+    /** 认证密码 明文 */
+    public String password;
+
+    public OauthConfigUserPwdInfoTest01(){}
+    /**
+     * 使用默认端口、默认协议构造
+     * @param host
+     * @param clientId
+     * @param clientSecret
+     */
+    public OauthConfigUserPwdInfoTest01(String host, String clientId, String clientSecret, String username, String password){
+        super(host,clientId,clientSecret, GrantType.password);
+        this.username = username;
+        this.password = password;
+        //创建用户名密码模式信息时,将客户端信息进行缓存
+        cacheClientInfo();
+    }
+
+    /**
+     * 使用指定端口、指定协议构造
+     * @param host
+     * @param clientId
+     * @param clientSecret
+     */
+    public OauthConfigUserPwdInfoTest01(String host, String clientId, String clientSecret, String username, String password, boolean isEnableHttpTest, String httpsPort, String httpPort){
+        super(host,clientId,clientSecret, GrantType.password,isEnableHttpTest,httpsPort,httpPort);
+        this.username = username;
+        this.password = password;
+        cacheClientInfo();
+    }
+
+    public String getUsername() {
+        return username;
+    }
+
+    public void setUsername(String username) {
+        this.username = username;
+    }
+
+    public String getPassword() {
+        return password;
+    }
+
+    public void setPassword(String password) {
+        this.password = password;
+    }
+
+    public void cacheClientInfo(){
+        Map<String, OauthConfigBaseInfo> clientInfoMap =  UpdateTokenSchedule.httpConfigMap;
+        String clientKey = UpdateTokenSchedule.getKey(this);
+        //缓存客户端信息
+        clientInfoMap.put(clientKey, this);
+    }
+}

+ 67 - 0
huimv-farm-video/src/main/java/com/huimv/video/dhicc/test/config/OauthConfigUserPwdInfoTest02.java

@@ -0,0 +1,67 @@
+package com.huimv.video.dhicc.test.config;
+
+import com.dahuatech.icc.oauth.profile.GrantType;
+import com.huimv.video.dhicc.test.schedule.UpdateTokenSchedule;
+
+import java.util.Map;
+
+/**
+ * 用户密码模式配置信息
+ */
+public class OauthConfigUserPwdInfoTest02 extends OauthConfigBaseInfo02{
+    /** 密码认证用户名 */
+    public String username;//登录平台的用户名,
+    /** 认证密码 明文 */
+    public String password;
+
+    public OauthConfigUserPwdInfoTest02(){}
+    /**
+     * 使用默认端口、默认协议构造
+     * @param host
+     * @param clientId
+     * @param clientSecret
+     */
+    public OauthConfigUserPwdInfoTest02(String host, String clientId, String clientSecret, String username, String password){
+        super(host,clientId,clientSecret, GrantType.password);
+        this.username = username;
+        this.password = password;
+        //创建用户名密码模式信息时,将客户端信息进行缓存
+        cacheClientInfo();
+    }
+
+    /**
+     * 使用指定端口、指定协议构造
+     * @param host
+     * @param clientId
+     * @param clientSecret
+     */
+    public OauthConfigUserPwdInfoTest02(String host, String clientId, String clientSecret, String username, String password, boolean isEnableHttpTest, String httpsPort, String httpPort){
+        super(host,clientId,clientSecret, GrantType.password,isEnableHttpTest,httpsPort,httpPort);
+        this.username = username;
+        this.password = password;
+        cacheClientInfo();
+    }
+
+    public String getUsername() {
+        return username;
+    }
+
+    public void setUsername(String username) {
+        this.username = username;
+    }
+
+    public String getPassword() {
+        return password;
+    }
+
+    public void setPassword(String password) {
+        this.password = password;
+    }
+
+    public void cacheClientInfo(){
+        Map<String, OauthConfigBaseInfo02> clientInfoMap =  UpdateTokenSchedule.httpConfigMap2;
+        String clientKey = UpdateTokenSchedule.getKey2(this);
+        //缓存客户端信息
+        clientInfoMap.put(clientKey, this);
+    }
+}

+ 240 - 0
huimv-farm-video/src/main/java/com/huimv/video/dhicc/test/constant/Constant.java

@@ -0,0 +1,240 @@
+package com.huimv.video.dhicc.test.constant;
+
+/**
+ * 常量类
+ */
+public class Constant {
+
+    public static final String SERVICE = "Evo-ThirdParty";
+
+    /*********************************************http请求****************************************************/
+    public static final String HTTP_GET = "GET";
+    public static final String HTTP_POST = "POST";
+    public static final String HTTP_PUT = "PUT";
+    public static final String HTTP_DELETE = "DELETE";
+
+    /*********************************************错误码****************************************************/
+//    //系统异常错误码
+//    public static String SYSTEMERROR_CODE = "99999999";
+//    //系统异常错误信息
+//    public static String SYSTEMERROR_MSG = "系统异常";
+//    //系统正常错误码
+//    public static String SUCESS_CODE = "000000";
+//    //系统正常错误信息
+//    public static String SUCCESS_MSG = "处理成功";
+
+    /*********************************************鉴权中心****************************************************/
+    //刷新token
+    public static final String REFRESH_TOKEN = "/evo-apigw/evo-oauth/{version}/oauth/extend/refresh/token";
+    //获取token
+    public static final String GET_TOKEN = "/evo-apigw/evo-oauth/{version}/oauth/extend/token";
+    //获取公钥
+    public static final String GET_PUBLIC_KEY = "/evo-apigw/evo-oauth/{version}/oauth/public-key";
+
+//    /*********************************************基础框架****************************************************/
+//    //人员分页查找
+//    public static final String PERSON_PAGE = "/evo-apigw/evo-brm/{version}/person/subsystem/page";
+//    //人员批量添加
+//    public static final String PERSON_BATCH_ADD = "/evo-apigw/evo-brm/{version}/person/subsystem/batch-add";
+//    //人员批量删除
+//    public static final String PERSON_BATCH_DELETE = "/evo-apigw/evo-brm/{version}/person/delete";
+//    //人员全局id生成
+//    public static final String PERSON_ID_BATCH_GENERATE = "/evo-apigw/evo-brm/{version}/person/subsystem/batch-generate-id";
+//    //卡片分页查找
+//    public static final String CARD_PAGE = "/evo-apigw/evo-brm/{version}/card/subsystem/page";
+//    //卡片批量添加
+//    public static final String CARD_BATCH_ADD = "/evo-apigw/evo-brm/{version}/card/batch-add";
+//    //卡片全局id生成
+//    public static final String CARD_ID_BATCH_GENERATE = "/evo-apigw/evo-brm/{version}/card/batch-generate-id";
+//    //卡片批量退卡
+//    public static final String CARD_BATCH_DELETE = "/evo-apigw/evo-brm/{version}/card/delete";
+//    //卡片批量删除
+//    public static final String CARD_BATCH_RETURN = "/evo-apigw/evo-brm/{version}/card/return";
+//    //车辆分页查找
+//    public static final String CAR_PAGE = "/evo-apigw/evo-brm/{version}/car/page";
+//    //用户分页查找
+//    public static final String USER_PAGE = "/evo-apigw/evo-brm/{version}/user/subsystem/page";
+//    //角色分页查找
+//    public static final String ROLE_PAGE = "/evo-apigw/evo-brm/{version}/role/subsystem/page";
+//    //设备分页查找
+//    public static final String DEVICE_PAGE = "/evo-apigw/evo-brm/1.2.0/device/channel/subsystem/page";
+//    //组织分页查找
+//    public static final String ORGANIZATION_PAGE = "/evo-apigw/evo-brm/{version}/organization/subsystem/page";
+//    //部门分页查找
+//    public static final String DEPARTMENT_PAGE = "/evo-apigw/evo-brm/{version}/department/page";
+//
+//    /*********************************************事件中心****************************************************/
+//    //事件订阅
+//    public static final String EVENT_SUBSCRIBE = "/evo-apigw/evo-event/{version}/subscribe/mqinfo";
+//    //取消事件订阅
+//    public static final String CANCEL_EVENT_SUBSCRIBE = "/evo-apigw/evo-event/{version}/subscribe/mqinfo?name={name}";
+//
+//    /*********************************************视频应用****************************************************/
+//    //云台镜头控制
+//    public static final String OPERATE_CAMERA = "/evo-apigw/admin/API/DMS/Ptz/OperateCamera";
+//    //云台方向控制
+//    public static final String OPERATE_DIRECT = "/evo-apigw/admin/API/DMS/Ptz/OperateDirect";
+//    //云台功能控制
+//    public static final String OPERATE_FUNCTION = "/evo-apigw/admin/API/DMS/Ptz/OperateFunction";
+//    //语音对讲
+//    public static final String START_TALK = "/evo-apigw/admin/API/MTS/Audio/StartTalk";
+//    //获取RTSP实时流接口地址
+//    public static final String RTSP_REQUEST_URL = "/evo-apigw/admin/API/MTS/Video/StartVideo";
+//    //获取HLS/FLV/RTMP实时流接口地址
+//    public static final String HLS_FLV_RTMP_URL = "/evo-apigw/admin/API/video/stream/realtime";
+//    //获取回放流地址
+//    public static final String PLAY_BACK_ADDRESS = "/evo-apigw/evo-event/{version}/subscribe/mqinfo";
+//    //查询报警录像信息:前置条件:配置报警预案计划 获取报警录像
+//    public static final String AlARM_RECORD_GET = "/evo-apigw/admin/API/SS/Record/GetAlarmRecords";
+//    //查询普通录像信息:根据通道编码、录像来源、开始时间和结束时间等条件查询录像信息
+//    public static final String PLAY_INFO_GET = "/evo-apigw/admin/API/SS/Record/QueryRecords";
+//    //HLS/RTMP获取流地址
+//    public static final String HLS_RTMP_STRREAM_ADDRESS_POST = "/evo-apigw/admin/API/video/stream/record";
+//    //以文件形式回放录像:根据通道编码和录像段文件名称等条件获取对应录像的RTSP流地址
+//    public static final String PLAY_BACK_BY_FILE = "/evo-apigw/admin/API/SS/Playback/StartPlaybackByFile";
+//    //以时间形式回放录像
+//    public static final String PLAY_BACK_BY_TIME = "/evo-apigw/admin/API/SS/Playback/StartPlaybackByTime";
+//
+//    /*********************************************门禁子系统****************************************************/
+//    //按人授权新增
+//    public static final String ASSESS_CONTROL_URL_AUTH_PERSON_ADD = "/evo-apigw/evo-accesscontrol/{version}/card/accessControl/doorAuthority";
+//    //按人授权更新
+//    public static final String ASSESS_CONTROL_URL_AUTH_PERSON_UPDATE = "/evo-apigw/evo-accesscontrol/{version}/card/accessControl/doorAuthority/deltaUpdate";
+//    //按人授权删除
+//    public static final String ASSESS_CONTROL_URL_AUTH_PERSON_DELETE = "/evo-apigw/evo-accesscontrol/{version}/card/accessControl/doorAuthority/delete/batch";
+//    //人员权限分页查询
+//    public static final String ASSESS_CONTROL_URL_AUTH_PERSON_PAGE_LIST = "/evo-apigw/evo-accesscontrol/{version}/card/accessControl/doorAuthority/bycondition/combined";
+//    //新增按部门授权(通道)
+//    public static final String ASSESS_CONTROL_URL_AUTH_DEPT_CHANNEL_CODE_ADD = "/evo-apigw/evo-accesscontrol/{version}/card/accessControl/doorAuthority/authorizeAllDeptByChannelCode";
+//    //新增按部门授权(门组)
+//    public static final String ASSESS_CONTROL_URL_AUTH_DEPT_DOOR_GROUP_ADD = "/evo-apigw/evo-accesscontrol/{version}/card/accessControl/doorAuthority/authorizeAllDeptByDoorGroups";
+//    //删除按部门授权(通道)
+//    public static final String ASSESS_CONTROL_URL_AUTH_DEPT_CHANNEL_CODE_DEL = "/evo-apigw/evo-accesscontrol/{version}/card/accessControl/doorAuthority/removeAuthorizeAllByChannelCode";
+//    //删除按部门授权(门组)
+//    public static final String ASSESS_CONTROL_URL_AUTH_DEPT_DOOR_GROUP_DEL = "/evo-apigw/evo-accesscontrol/{version}/card/accessControl/doorAuthority/removeAuthorizeAllByDoorGroups";
+//    //部门权限分页查询
+//    public static final String ASSESS_CONTROL_URL_AUTH_DEPT_PAGE = "/evo-apigw/evo-accesscontrol/{version}/card/accessControl/doorAuthority/authorizedDepartment/bycondition/combined";
+//    //门组添加
+//    public static final String ASSESS_CONTROL_URL_DOOR_GROUP_ADD = "/evo-apigw/evo-accesscontrol/{version}/card/accessControl/doorGroup";
+//    //门组删除
+//    public static final String ASSESS_CONTROL_URL_DOOR_GROUP_DEL = "/evo-apigw/evo-accesscontrol/{version}/card/accessControl/doorGroup/delete/batch";
+//    //门通道控制开门
+//    public static final String ASSESS_CONTROL_URL_OPEN_DOOR = "/evo-apigw/evo-accesscontrol/{version}/card/accessControl/channelControl/openDoor";
+//    //门通道控制关门
+//    public static final String ASSESS_CONTROL_URL_CLOSE_DOOR = "/evo-apigw/evo-accesscontrol/{version}/card/accessControl/channelControl/closeDoor";
+//    //获取二维码加密串
+//    public static final String ASSESS_CONTROL_URL_ENCODE_STRING = "/evo-apigw/evo-accesscontrol/{version}/card/card/generateQRCode/{personCode}";
+//    //门通道控制获取门状态
+//    public static final String ASSESS_CONTROL_URL_DEVICE_STATE_SYNC = "/evo-apigw/evo-accesscontrol/{version}/card/accessControl/channelControl/getDoorStatus";
+//    //门通道查询
+//    public static final String ASSESS_CONTROL_URL_DEVICE_STATE_QUERY = "/evo-apigw/evo-accesscontrol/{version}/card/accessControl/channelControl/channels";
+//    //刷卡记录分页
+//    public static final String ASSESS_CONTROL_URL_CARD_RECORD_QUERD = "/evo-apigw/evo-accesscontrol/{version}/card/accessControl/swingCardRecord/bycondition/combined";
+//    //刷卡记录详情查询
+//    public static final String ASSESS_CONTROL_URL_CARD_RECORD_DETAIL = "/evo-apigw/evo-accesscontrol/{version}/card/accessControl/swingCardRecord/{id}";
+//
+//    /*********************************************报警主机子系统****************************************************/
+//    //报警主机操作控制
+//    public static final String ALARM_HOST_CONTROL = "/evo-apigw/evo-alarm/{version}/alarmhosts/operate?nodeCode={nodeCode}&operate={operate}";
+//    //报警主机操作控制(用于处理资源绑定数据)
+//    public static final String ALARM_HOST_CONTROL_OPERATE = "/evo-apigw/evo-alarm/{version}/alarmhosts/operate";
+//    //报警主机操作控制(用于处理资源绑定数据)
+//    public static final String ALARM_HOST_STATE_QUERY_ALL = "/evo-apigw/evo-alarm/{version}/alarmhosts/all";
+//    //报警主机操作控制(用于处理资源绑定数据)
+//    public static final String ALARM_HOST_STATE_QUERY_ONE = "/evo-apigw/evo-alarm/{version}/alarmhosts/one/{deviceCode}";
+//
+//
+//    /*********************************************人脸应用子系统****************************************************/
+//    //人员新增
+//    public static final String FACE_PERSON_ADD = "/evo-apigw/evo-face/personInfo/add";
+//    //人员批量删除
+//    public static final String FACE_PERSON_DELETE = "/evo-apigw/evo-face/personInfo/deleteBatch/{groupid}";
+//    //人员修改
+//    public static final String FACE_PERSON_UPDATE = "/evo-apigw/evo-face/personInfo/update";
+//    //人员分页查找
+//    public static final String FACE_PERSON_PAGE = "/evo-apigw/evo-face/personInfo/page";
+//    //人像批量布控
+//    public static final String FACE_PERSON_CONTROL = "/evo-apigw/evo-face/channelGroup/add/batch";
+//    //人像绑定
+//    public static final String FACE_PERSON_IMAGE_BIND = "/evo-apigw/evo-face/deptGroup/sync/bindPerson";
+//    //以图搜图前置条件(查询设备树)
+//    public static final String FACE_DEVICE_TREE_QUERY = "/evo-apigw/evo-face/tree/getDevChnIdsAndName";
+//    //抓拍库以图搜图前置条件(根据设备编码获取通道列表)
+//    public static final String FACE_CHANNEL_LIST_QUERY = "/evo-apigw/evo-face/faceSearch/channelList";
+//    //人像库搜图前置条件(根据设备编码查询人像库)
+//    public static final String FACE_GROUP_REL_QUERY = "/evo-apigw/evo-face/faceSearch/getGroupRelByCondition";
+//    //人像以图搜图(IVSS)
+//    public static final String FACE_SEARCH_FOR_IVS = "/evo-apigw/evo-face/faceSearch/third/faceSearchForIvs";
+//    //人像库第三方搜图同步接口(IVSS)
+//    public static final String FACE_SEARCH_SYNC = "/evo-apigw/evo-face/faceSearch/third/faceSearchSync";
+//    //人像库以图搜图进度查询
+//    public static final String FACE_RROCESS_QUERY = "/evo-apigw/evo-face/faceSearch/third/queryProgress/{sessionId}";
+//    //以图搜图对外接口(分页查询搜图结果阶段)
+//    public static final String FACE_SEARCH_RESULT = "/evo-apigw/evo-face/faceSearch/third/page";
+//
+//    /*********************************************客流统计子系统****************************************************/
+//    //在场人员查询
+//    public static final String PASSENGER_FLOW_PRESENCE_PERSON_PAGE = "/evo-apigw/evo-passengerflow/{version}/statistics/presencePerson/page";
+//    //过人记录
+//    public static final String PASSENGER_FLOW_IN_AND_OUT_RECORD_PAGE = "/evo-apigw/evo-passengerflow/{version}/statistics/inAndOutRecord/page";
+//    //分布分析(日周月年)报分页查询
+//    public static final String PASSENGER_FLOW_REGION_REPORT_DISTRIBUTION = "/evo-apigw/evo-passengerflow/{version}/region/report/distribution";
+//    //排行分析(日周月年)报查询
+//    public static final String PASSENGER_FLOW_REGION_REPORT_RANK = "/evo-apigw/evo-passengerflow/{version}/region/report/rank";
+//    //滞留分析查询
+//    public static final String PASSENGER_FLOW_REGION_REPORT_RETENTION  = "/evo-apigw/evo-passengerflow/{version}/region/report/retention";
+//    //分析报告(日报)查询接口
+//    public static final String PASSENGER_FLOW_REGION_REPORT_ANALYSE_DAY = "/evo-apigw/evo-passengerflow/{version}/region/report/analyse/day";
+//    //分析报告(周,月,年)查询接口
+//    public static final String PASSENGER_FLOW_REGION_REPORT_ANALYSE = "/evo-apigw/evo-passengerflow/{version}/region/report/analyse";
+//    //客户画像统计
+//    public static final String PASSENGER_FLOW_GET_CUSTOMER_IMAGE = "/evo-apigw/evo-passengerflow/{version}/statistics/customerQuery/getCustomerImage";
+//
+//    /*********************************************访客管理子系统****************************************************/
+//    //访客通行记录分页查询接口
+//    public static final String VISITOR_PASS_RECORD_PAGE = "/evo-apigw/evo-visitor/{version}/card/accessControl/swingCardRecord/visitor/bycondition/combined";
+//    //当日进出动态-在访人数/离访人数
+//    public static final String VISITOR_PERSON_COUNT = "/evo-apigw/evo-visitor/{version}/card/visitor/visitorCount";
+//    //统计当日进出动态
+//    public static final String VISITOR_IN_OUT_COUNT = "/evo-apigw/evo-visitor/{version}/card/accessControl/count";
+//    //访客超时对应来访人
+//    public static final String VISITOR_TIME_OUT = "/evo-apigw/evo-visitor/{version}/card/visitor/getVisitorTimeoutByDepartment";
+//    //访客预约
+//    public static final String VISITOR_APPOINTMENT = "/evo-apigw/evo-visitor/{version}/card/visitor/appointment";
+//    //社区云预约访客
+//    public static final String VISITOR_COMMUNITY_APPOINTMENT = "/evo-apigw/evo-visitor/{version}/card/visitor/community/appointment";
+//
+//    /*********************************************停车管理子系统****************************************************/
+//    //添加车辆
+//    public static final String IPMS_CAR_ADD = "/evo-apigw/ipms/car/add";
+//    //车辆进出数据
+//    public static final String IPMS_CAR_FIND_HIT = "/evo-apigw/ipms/caraccess/find/his";
+//    //过车数据
+//    public static final String IPMS_CAR_FIND_CONDITIONS = "/evo-apigw/ipms/carcapture/find/conditions";
+//    //过车数据
+//    public static final String IPMS_PAYMENT_INFORM = "/evo-apigw/ipms/integration/kingdo/payment/success";
+//    //道闸控制
+//    public static final String IPMS_SLUICE_CONTROL = "/evo-apigw/ipms/subSystem/control/sluice";
+//
+//    /*********************************************考勤管理子系统****************************************************/
+//    //考勤记录查询
+//    public static final String ATTENDANCE_RECORD_PAGE = "/evo-apigw/evo-attendance/{version}/attendance/record/page";
+//    //考勤结果查询
+//    public static final String ATTENDANCE_RESULT_PAGE = "/evo-apigw/evo-attendance/{version}/attendance/result/page";
+//    //人员考勤统计报表分页查询
+//    public static final String IPMS_RESULT_STAT_PAGE = "/evo-apigw/evo-attendance/{version}/attendance/result/stat/page";
+
+    /*********************************************Test*********************************/
+    //设备数查询
+    public static final String ASSESS_CONTROL_URL_Door = "/evo-apigw/evo-accesscontrol/1.0.0/resource/tree/search";
+
+    //门禁所有通道查询
+    public static final String CHANNEL_URL = "/evo-apigw/evo-accesscontrol/{version}/card/accessControl/channelControl/channels";
+
+    //门禁所有通道查询02
+    public static final String CHANNEL_URL_Test = "/evo-apigw/evo-accesscontrol/1.0.0/resource/tree/nodeList";
+
+    //personList
+    public static final String CHANNEL_URL_PERSON_LIST = "/evo-apigw/evo-brm/1.2.0/person/page";
+
+}

+ 39 - 0
huimv-farm-video/src/main/java/com/huimv/video/dhicc/test/constant/ErrorEnum.java

@@ -0,0 +1,39 @@
+package com.huimv.video.dhicc.test.constant;
+
+/**
+ * 错误码
+ */
+public enum ErrorEnum {
+
+    //HTTP请求错误码
+    REQUEST_FORBIDDEN_CODE("403", "Forbidden"),
+    HTTP_REQUEST_URL_ERROR("1001", "请求URL地址解析失败"),
+    HTTP_REQUEST_CREATE_ERROR("1002", "请求资源失败"),
+    ;
+
+    private String errCode;
+    private String errMsg;
+
+    ErrorEnum(){}
+
+    ErrorEnum(String errCode, String errMsg) {
+        this.errCode = errCode;
+        this.errMsg = errMsg;
+    }
+
+    public String getErrCode() {
+        return errCode;
+    }
+
+    public void setErrCode(String errCode) {
+        this.errCode = errCode;
+    }
+
+    public String getErrMsg() {
+        return errMsg;
+    }
+
+    public void setErrMsg(String errMsg) {
+        this.errMsg = errMsg;
+    }
+}

+ 53 - 0
huimv-farm-video/src/main/java/com/huimv/video/dhicc/test/controller/ClientPersonManageControllerTest.java

@@ -0,0 +1,53 @@
+package com.huimv.video.dhicc.test.controller;
+
+import com.dahuatech.icc.exception.ClientException;
+import com.huimv.video.dhicc.test.config.OauthConfigBaseInfo;
+import com.huimv.video.dhicc.test.config.OauthConfigBaseInfo02;
+import com.huimv.video.dhicc.test.request.PersonListRequestHn;
+import com.huimv.video.dhicc.test.request.PersonListRequestSg;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.util.Map;
+
+@RestController
+@RequestMapping("personTest")
+public class ClientPersonManageControllerTest {
+    @Autowired
+    private OauthConfigBaseInfo oauthConfigBaseInfo;
+    @Autowired
+    private OauthConfigBaseInfo02 oauthConfigBaseInfo02;
+
+
+    @RequestMapping("/ge_person_list")
+    public String ge_person_list(@RequestBody PersonListRequestSg personListRequestSg) throws ClientException {
+        Integer farmId = personListRequestSg.getFarmId();
+        if (farmId == 1) {
+            System.out.println("曙光");
+            PersonListRequestSg requestSg = new PersonListRequestSg(oauthConfigBaseInfo);
+            requestSg.setDepartmentId(personListRequestSg.getDepartmentId());
+            requestSg.setIsContain(personListRequestSg.getIsContain());
+            requestSg.setPageNum(personListRequestSg.getPageNum());
+            requestSg.setPageSize(personListRequestSg.getPageSize());
+            requestSg.setSearchKey(personListRequestSg.getSearchKey());
+            requestSg.setStatusList(personListRequestSg.getStatusList());
+            String s = requestSg.doAction();
+            return s;
+        } else {
+            PersonListRequestHn requestHn = new PersonListRequestHn(oauthConfigBaseInfo02);
+            requestHn.setDepartmentId(personListRequestSg.getDepartmentId());
+            requestHn.setIsContain(personListRequestSg.getIsContain());
+            requestHn.setPageNum(personListRequestSg.getPageNum());
+            requestHn.setPageSize(personListRequestSg.getPageSize());
+            requestHn.setSearchKey(personListRequestSg.getSearchKey());
+            requestHn.setStatusList(personListRequestSg.getStatusList());
+            String s = requestHn.doAction();
+            System.out.println("海宁");
+            return s;
+        }
+
+
+    }
+}

+ 51 - 0
huimv-farm-video/src/main/java/com/huimv/video/dhicc/test/controller/OauthController.java

@@ -0,0 +1,51 @@
+package com.huimv.video.dhicc.test.controller;
+
+import com.huimv.video.dhicc.test.request.GetPublicKeyRes;
+import com.huimv.video.dhicc.test.response.GetTokenResponse;
+import com.huimv.video.dhicc.test.service.IOauthService;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.util.Map;
+
+/**
+ * 鉴权相关接口
+ */
+@RestController
+@RequestMapping("/oauth")
+public class OauthController {
+    public static final Logger logger = LoggerFactory.getLogger(OauthController.class);
+
+    @Autowired
+    public IOauthService oauthService;
+
+    /**
+     * 获取公钥
+     * **/
+    @GetMapping("/get-public-key")
+    public GetPublicKeyRes getPublicKey(){
+        return oauthService.getPublicKey();
+    }
+
+    /**
+     * 获取token
+     * **/
+    @GetMapping("/get-tokenTest01")
+    public String getTokenTest01(@RequestBody Map<String,String> paramsMap){
+        return oauthService.getTokenTest01(paramsMap);
+    }
+   /* *//**
+     * 获取token
+     * **//*
+    @GetMapping("/get-tokenTest02")
+    public GetTokenResponse getTokenTest02(){
+
+        return oauthService.getTokenTest02();
+    }*/
+
+}

+ 103 - 0
huimv-farm-video/src/main/java/com/huimv/video/dhicc/test/controller/VideoRecorControllerSg.java

@@ -0,0 +1,103 @@
+package com.huimv.video.dhicc.test.controller;
+
+//拿视频回放
+
+import com.alibaba.fastjson.JSON;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
+import com.dahuatech.hutool.http.Method;
+import com.dahuatech.icc.exception.ClientException;
+import com.dahuatech.icc.oauth.http.DefaultClient;
+import com.dahuatech.icc.oauth.http.IClient;
+import com.dahuatech.icc.oauth.model.v202010.GeneralRequest;
+import com.dahuatech.icc.oauth.model.v202010.GeneralResponse;
+import com.huimv.video.dhicc.entity.IccChannel;
+import com.huimv.video.dhicc.mapper.IccChannelMapper;
+import com.huimv.video.dhicc.result.R;
+import com.huimv.video.dhicc.service.IIccChannelService;
+import net.sf.json.JSONObject;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.text.DateFormat;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Map;
+
+//方便前端操作   传入的是  事件时间  还有通道编号就可以播放了
+@RestController
+@RequestMapping("/videoTest")
+
+public class VideoRecorControllerSg {
+
+    @Autowired
+    private IIccChannelService iIccChannelService;
+
+    @Autowired
+    private IccChannelMapper iccChannelMapper;
+
+    @RequestMapping("/getVideoRecord")
+    public R getVideoRecord(@RequestBody Map<String, Object> params1) throws ClientException, ParseException {
+        String happendTime = (String) params1.get("happendTime");
+        String channelNmae = (String) params1.get("channelName");
+        Integer farmId = (int) params1.get("farmId");
+
+        if (farmId != 1) {
+            return R.ok("当前牧场无设备").put("URL", null);
+        }
+
+        LambdaQueryWrapper<IccChannel> wrapper3 = Wrappers.lambdaQuery();
+        wrapper3.eq(IccChannel::getChannelName, channelNmae);
+        IccChannel iccChannel = iccChannelMapper.selectOne(wrapper3);
+        System.out.println(iccChannel);
+        String URL = "/evo-apigw/admin/API/SS/Playback/StartPlaybackByTime";  //获取事件URL    post请求
+        IClient iClient = new DefaultClient();
+        GeneralRequest generalRequest = new GeneralRequest(URL, Method.POST);
+        System.out.println("开始执行");
+        Map<String, Object> params = new HashMap<>();
+        Map<String, Object> value = new HashMap<>();
+        value.put("nvrId", "");
+        value.put("optional", "/evo-apigw/admin/API/SS/Playback/StartPlaybackByTime");
+        value.put("recordType", "1");
+        value.put("streamType", "1");
+        value.put("recordSource", "2");
+        value.put("channelId", iccChannel.getChannelId());
+        System.out.println(iccChannel.toString());
+        //开始结束时间代为处理
+        DateFormat fmt = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+        //格式化传入的时间---拿传入时间前后五分钟的视频
+        Date Time = fmt.parse(happendTime);   //事件时间
+        Date GapTimeBefor_gap = new Date(Time.getTime() - 1000 * 10);//star   事件十秒之前
+        Date GapAfter = new Date(Time.getTime() + 1000 * 60 * 5);// end   事件五分钟之后
+        String befor = String.valueOf(GapTimeBefor_gap.getTime() / 1000);
+        String after = String.valueOf(GapAfter.getTime() / 1000);
+        value.put("endTime", after);
+        value.put("startTime", befor);
+        params.put("clientMac", "30:9c:23:79:40:08");
+        params.put("clientPushId", "");
+        params.put("project", "PSDK");
+        params.put("method", "SS.Playback.StartPlaybackByTime");
+        params.put("data", value);
+        generalRequest.body(JSON.toJSONString(params));
+        System.out.println(JSON.toJSONString(params));
+        //这种已经在配置文件里面安排了账号ip以及密码
+        generalRequest.header("Content-Type", " application/json");
+        //发起请求处理应答
+        GeneralResponse generalResponse = iClient.doAction(generalRequest, generalRequest.getResponseClass());
+        JSONObject jsonObject = JSONObject.fromObject(generalResponse.getResult());
+        System.out.println(jsonObject.toString());
+        Object data = jsonObject.get("data");
+        String url = (String) JSONObject.fromObject(data).get("url");
+        String token = (String) JSONObject.fromObject(data).get("token");
+        // "|"  特殊字符需要加转义字符
+        String[] sourceStrArray = url.split("\\|");
+        String recordUrl = sourceStrArray[1] + "?token=" + token + "&trackID=701";
+        return R.ok("请求成功").put("URL", recordUrl);
+    }
+
+
+}

+ 25 - 0
huimv-farm-video/src/main/java/com/huimv/video/dhicc/test/manager/IOauthIntegrationManager.java

@@ -0,0 +1,25 @@
+package com.huimv.video.dhicc.test.manager;
+
+import com.huimv.video.dhicc.test.response.GetPublicKeyResponse;
+import com.huimv.video.dhicc.test.response.GetTokenResponse;
+
+/**
+ * 鉴权服务集成接口定义
+ */
+public interface IOauthIntegrationManager {
+
+    /**
+     * 获取公钥
+     **/
+    GetPublicKeyResponse getPublicKey();
+
+/*    *//**
+     * 获取token
+     **//*
+    GetTokenResponse getToken();*/
+
+    GetTokenResponse getTokenTest01();
+
+    GetTokenResponse getTokenTest02();
+
+}

+ 64 - 0
huimv-farm-video/src/main/java/com/huimv/video/dhicc/test/manager/impl/OauthIntegrationManager.java

@@ -0,0 +1,64 @@
+package com.huimv.video.dhicc.test.manager.impl;
+
+
+import com.huimv.video.dhicc.test.config.OauthConfigBaseInfo;
+import com.huimv.video.dhicc.test.config.OauthConfigBaseInfo02;
+import com.huimv.video.dhicc.test.manager.IOauthIntegrationManager;
+import com.huimv.video.dhicc.test.other.BaseIntegrationManager;
+import com.huimv.video.dhicc.test.request.GetPublicKeyRequest;
+import com.huimv.video.dhicc.test.request.GetTokenRequestTest01;
+import com.huimv.video.dhicc.test.request.GetTokenRequestTest02;
+import com.huimv.video.dhicc.test.response.GetPublicKeyResponse;
+import com.huimv.video.dhicc.test.response.GetTokenResponse;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+/**
+ * 鉴权服务集成实现类
+ */
+@Service
+public class OauthIntegrationManager extends BaseIntegrationManager implements IOauthIntegrationManager {
+
+    @Autowired
+    public OauthConfigBaseInfo oauthConfigBaseInfo;
+    @Autowired
+    public OauthConfigBaseInfo02 oauthConfigBaseInfo02;
+
+    /**
+     * 获取公钥
+     **/
+    @Override
+    public GetPublicKeyResponse getPublicKey() {
+        logger.info("OauthController,getPublicKey");
+        GetPublicKeyRequest request = new GetPublicKeyRequest(oauthConfigBaseInfo);
+        GetPublicKeyResponse getPublicKeyResponse = request.doAction();
+        return getPublicKeyResponse;
+    }
+
+  /*  *//**
+     * 获取token
+     **//*
+    @Override
+    public GetTokenResponse getToken() {
+        logger.info("OauthController,getToken");
+        GetTokenRequest request = new GetTokenRequest(oauthConfigBaseInfo);
+        GetTokenResponse getTokenResponse = request.doAction();
+        return getTokenResponse;
+    }*/
+
+    @Override
+    public GetTokenResponse getTokenTest01() {
+        logger.info("OauthController,getToken");
+        GetTokenRequestTest01 request = new GetTokenRequestTest01(oauthConfigBaseInfo);
+        GetTokenResponse getTokenResponse = request.doAction();
+        return getTokenResponse;
+    }
+
+    @Override
+    public GetTokenResponse getTokenTest02() {
+        logger.info("OauthController,getToken");
+        GetTokenRequestTest02 request = new GetTokenRequestTest02(oauthConfigBaseInfo02);
+        GetTokenResponse getTokenResponse = request.doAction();
+        return getTokenResponse;
+    }
+}

+ 9 - 0
huimv-farm-video/src/main/java/com/huimv/video/dhicc/test/other/BaseIntegrationManager.java

@@ -0,0 +1,9 @@
+package com.huimv.video.dhicc.test.other;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public abstract class BaseIntegrationManager {
+
+    public Logger logger = LoggerFactory.getLogger(this.getClass());
+}

+ 65 - 0
huimv-farm-video/src/main/java/com/huimv/video/dhicc/test/other/BaseRes.java

@@ -0,0 +1,65 @@
+package com.huimv.video.dhicc.test.other;
+
+public class BaseRes {
+
+    /** 结果原报文 */
+    private String result;
+    /** 请求ID */
+    private String requestId;
+    /** 返回状态码 */
+    private String code;
+    /** 是否成功 */
+    private boolean success;
+    /** 错误信息 */
+    private String errMsg;
+    /** 用于构建错误描述的参数 **/
+    private Object args;
+
+    public String getResult() {
+        return result;
+    }
+
+    public void setResult(String result) {
+        this.result = result;
+    }
+
+    public String getRequestId() {
+        return requestId;
+    }
+
+    public void setRequestId(String requestId) {
+        this.requestId = requestId;
+    }
+
+    public String getCode() {
+        return code;
+    }
+
+    public void setCode(String code) {
+        this.code = code;
+    }
+
+    public boolean isSuccess() {
+        return success;
+    }
+
+    public void setSuccess(boolean success) {
+        this.success = success;
+    }
+
+    public String getErrMsg() {
+        return errMsg;
+    }
+
+    public void setErrMsg(String errMsg) {
+        this.errMsg = errMsg;
+    }
+
+    public Object getArgs() {
+        return args;
+    }
+
+    public void setArgs(Object args) {
+        this.args = args;
+    }
+}

+ 9 - 0
huimv-farm-video/src/main/java/com/huimv/video/dhicc/test/other/BaseService.java

@@ -0,0 +1,9 @@
+package com.huimv.video.dhicc.test.other;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class BaseService {
+
+    public Logger logger = LoggerFactory.getLogger(this.getClass());
+}

+ 179 - 0
huimv-farm-video/src/main/java/com/huimv/video/dhicc/test/request/BaseRequest.java

@@ -0,0 +1,179 @@
+package com.huimv.video.dhicc.test.request;
+
+
+import com.dahuatech.icc.oauth.profile.GrantType;
+import com.huimv.video.dhicc.test.config.OauthConfigBaseInfo;
+import com.huimv.video.dhicc.test.response.GetTokenResponse;
+import com.huimv.video.dhicc.test.schedule.UpdateTokenSchedule;
+import com.huimv.video.dhicc.test.token.*;
+import lombok.Data;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.stereotype.Component;
+import org.springframework.util.CollectionUtils;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * 请求基类
+ */
+@Data
+@Component
+public abstract class BaseRequest<T> {
+    public static final Logger logger = LoggerFactory.getLogger(BaseRequest.class);
+
+    //客户端信息
+    private OauthConfigBaseInfo oauthConfigBaseInfo;
+    //请求方式
+    private String method;
+    //请求url
+    private String url;
+    //请求头
+    private Map<String, String> header = new HashMap<String, String>();
+    //请求体
+    protected String body;
+    //支持常见的form表单类型:application/x-www-form-urlencoded;multipart/form-data
+    protected Map<String, Object> form;
+    //是否需要鉴权,默认需要
+    private boolean needAuth = true;
+
+    private TokenStore tokenStore = UpdateTokenSchedule.tokenStore;
+
+    public abstract T doAction();
+
+    public BaseRequest(){}
+
+    public BaseRequest(OauthConfigBaseInfo oauthConfigBaseInfo, String method, String url, boolean needAuth){
+        this.oauthConfigBaseInfo = oauthConfigBaseInfo;
+        this.method = method;
+        this.url = url;
+        this.needAuth = needAuth;
+        this.header();
+        //TODO:暂时不开启刷新token任务
+        //UpdateTokenSchedule.getInstance();
+    }
+
+    public void header(){
+       //从缓存获取access_token
+        if(this.needAuth){
+            Token token = getToken();
+            if(token == null)return;
+            header.put("Authorization", "bearer " + (token != null ? token.getAccess_token() : ""));
+            if(GrantType.password == oauthConfigBaseInfo.getGrantType()){
+                header.put("User-Id", (token != null ? token.getUserId() : "1"));
+            }
+        }
+    }
+
+    public Token getToken(){
+        Token token = null;
+        if(tokenStore instanceof LocalTokenStore){
+            LocalTokenStore localTokenStore = (LocalTokenStore)tokenStore;
+            Map<String, Token> tokenMap = localTokenStore.getTokenMap();
+            String key = UpdateTokenSchedule.getKey(this.oauthConfigBaseInfo);
+            if(!CollectionUtils.isEmpty(tokenMap)){
+                token = tokenMap.get(key);
+                if(token != null){
+                    //token是否过期,过期则删除,重新获取
+                    if(System.currentTimeMillis() / 1000 >= token.getTtl()){
+                        tokenMap.remove(key);
+                    }else{
+                        logger.info("Get token from Local Story Cache...");
+                        return token;
+                    }
+                }
+                //掉接口获取token
+                token = getTokenFromRemote();
+                if(token != null){
+                    //缓存token到本地
+                    tokenMap.put(key, token);
+                }
+            }else {
+                //掉接口获取token
+                token = getTokenFromRemote();
+                if(token != null){
+                    //缓存token到本地
+                    tokenMap.put(key, token);
+                }
+            }
+        }
+        if(tokenStore instanceof MysqlTokenStore){
+            MysqlTokenStore mysqlTokenStore = (MysqlTokenStore)tokenStore;
+            Map<String, Token> tokens =  mysqlTokenStore.getToken();
+            String key = UpdateTokenSchedule.getKey(this.oauthConfigBaseInfo);
+            if(!CollectionUtils.isEmpty(tokens)){
+                token = tokens.get(key);
+                if (token != null){
+                    //token是否过期,过期则删除,重新获取
+                    if(System.currentTimeMillis() / 1000 >= token.getTtl()){
+                        tokens.remove(key);
+                    }else{
+                        logger.info("Get token from Mysql Cache...");
+                        return token;
+                    }
+                }
+                //掉接口获取token
+                token = getTokenFromRemote();
+                if(token != null){
+                    //缓存token到Mysql
+                    mysqlTokenStore.tokenStore(key, token);
+                }
+            }else {
+                //掉接口获取token
+                token = getTokenFromRemote();
+                if(token != null){
+                    //缓存token到Mysql
+                    mysqlTokenStore.tokenStore(key, token);
+                }
+            }
+        }
+        if(tokenStore instanceof RedisTokenStore){
+            RedisTokenStore redisTokenStore = (RedisTokenStore)tokenStore;
+            Map<String, Token> tokens = redisTokenStore.getToken();
+            String key = UpdateTokenSchedule.getKey(this.oauthConfigBaseInfo);
+            if(!CollectionUtils.isEmpty(tokens)){
+                token = tokens.get(key);
+                if(token != null){
+                    //token是否过期,过期则删除,重新获取
+                    if(System.currentTimeMillis() / 1000 >= token.getTtl()){
+                        tokens.remove(key);
+                    }else{
+                        logger.info("Get token from Redis Cache...");
+                        return token;
+                    }
+                }
+                //掉接口获取token
+                token = getTokenFromRemote();
+                //缓存token到Redis
+                if(token != null){
+                    redisTokenStore.tokenStore(key, token);
+                }
+            }else{
+                //掉接口获取token
+                token = getTokenFromRemote();
+                if(token != null){
+                    //缓存token到Redis
+                    redisTokenStore.tokenStore(key, token);
+                }
+            }
+
+        }
+        return token;
+    }
+
+    public Token getTokenFromRemote(){
+        logger.info("Get token from remote...");
+        //获取公钥
+        GetTokenRequestTest01 request = new GetTokenRequestTest01(oauthConfigBaseInfo);
+        GetTokenResponse getTokenResponse = request.doAction();
+        if(!getTokenResponse.isSuccess()){
+            logger.error("BaseRequest,getTokenFromRemote,get token error,error msg:{}",getTokenResponse.getErrMsg());
+            return null;
+        }
+        Token token = getTokenResponse.getData();
+        //设置ttl
+        token.setTtl(token.getExpires_in() + System.currentTimeMillis() / 1000);
+        return token;
+    }
+}

+ 179 - 0
huimv-farm-video/src/main/java/com/huimv/video/dhicc/test/request/BaseRequest02.java

@@ -0,0 +1,179 @@
+package com.huimv.video.dhicc.test.request;
+
+
+import com.dahuatech.icc.oauth.profile.GrantType;
+import com.huimv.video.dhicc.test.config.OauthConfigBaseInfo02;
+import com.huimv.video.dhicc.test.response.GetTokenResponse;
+import com.huimv.video.dhicc.test.schedule.UpdateTokenSchedule;
+import com.huimv.video.dhicc.test.token.*;
+import lombok.Data;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.stereotype.Component;
+import org.springframework.util.CollectionUtils;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * 请求基类
+ */
+@Data
+@Component
+public abstract class BaseRequest02<T> {
+    public static final Logger logger = LoggerFactory.getLogger(BaseRequest02.class);
+
+    //客户端信息
+    private OauthConfigBaseInfo02 oauthConfigBaseInfo;
+    //请求方式
+    private String method;
+    //请求url
+    private String url;
+    //请求头
+    private Map<String, String> header = new HashMap<String, String>();
+    //请求体
+    protected String body;
+    //支持常见的form表单类型:application/x-www-form-urlencoded;multipart/form-data
+    protected Map<String, Object> form;
+    //是否需要鉴权,默认需要
+    private boolean needAuth = true;
+
+    private TokenStore tokenStore = UpdateTokenSchedule.tokenStore;
+
+    public abstract T doAction();
+
+    public BaseRequest02(){}
+
+    public BaseRequest02(OauthConfigBaseInfo02 oauthConfigBaseInfo, String method, String url, boolean needAuth){
+        this.oauthConfigBaseInfo = oauthConfigBaseInfo;
+        this.method = method;
+        this.url = url;
+        this.needAuth = needAuth;
+        this.header();
+        //TODO:暂时不开启刷新token任务
+        //UpdateTokenSchedule.getInstance();
+    }
+
+    public void header(){
+       //从缓存获取access_token
+        if(this.needAuth){
+            Token token = getToken();
+            if(token == null)return;
+            header.put("Authorization", "bearer " + (token != null ? token.getAccess_token() : ""));
+            if(GrantType.password == oauthConfigBaseInfo.getGrantType()){
+                header.put("User-Id", (token != null ? token.getUserId() : "1"));
+            }
+        }
+    }
+
+    public Token getToken(){
+        Token token = null;
+        if(tokenStore instanceof LocalTokenStore){
+            LocalTokenStore localTokenStore = (LocalTokenStore)tokenStore;
+            Map<String, Token> tokenMap = localTokenStore.getTokenMap();
+            String key = UpdateTokenSchedule.getKey2(this.oauthConfigBaseInfo);
+            if(!CollectionUtils.isEmpty(tokenMap)){
+                token = tokenMap.get(key);
+                if(token != null){
+                    //token是否过期,过期则删除,重新获取
+                    if(System.currentTimeMillis() / 1000 >= token.getTtl()){
+                        tokenMap.remove(key);
+                    }else{
+                        logger.info("Get token from Local Story Cache...");
+                        return token;
+                    }
+                }
+                //掉接口获取token
+                token = getTokenFromRemote();
+                if(token != null){
+                    //缓存token到本地
+                    tokenMap.put(key, token);
+                }
+            }else {
+                //掉接口获取token
+                token = getTokenFromRemote();
+                if(token != null){
+                    //缓存token到本地
+                    tokenMap.put(key, token);
+                }
+            }
+        }
+        if(tokenStore instanceof MysqlTokenStore){
+            MysqlTokenStore mysqlTokenStore = (MysqlTokenStore)tokenStore;
+            Map<String, Token> tokens =  mysqlTokenStore.getToken();
+            String key = UpdateTokenSchedule.getKey2(this.oauthConfigBaseInfo);
+            if(!CollectionUtils.isEmpty(tokens)){
+                token = tokens.get(key);
+                if (token != null){
+                    //token是否过期,过期则删除,重新获取
+                    if(System.currentTimeMillis() / 1000 >= token.getTtl()){
+                        tokens.remove(key);
+                    }else{
+                        logger.info("Get token from Mysql Cache...");
+                        return token;
+                    }
+                }
+                //掉接口获取token
+                token = getTokenFromRemote();
+                if(token != null){
+                    //缓存token到Mysql
+                    mysqlTokenStore.tokenStore(key, token);
+                }
+            }else {
+                //掉接口获取token
+                token = getTokenFromRemote();
+                if(token != null){
+                    //缓存token到Mysql
+                    mysqlTokenStore.tokenStore(key, token);
+                }
+            }
+        }
+        if(tokenStore instanceof RedisTokenStore){
+            RedisTokenStore redisTokenStore = (RedisTokenStore)tokenStore;
+            Map<String, Token> tokens = redisTokenStore.getToken();
+            String key = UpdateTokenSchedule.getKey2(this.oauthConfigBaseInfo);
+            if(!CollectionUtils.isEmpty(tokens)){
+                token = tokens.get(key);
+                if(token != null){
+                    //token是否过期,过期则删除,重新获取
+                    if(System.currentTimeMillis() / 1000 >= token.getTtl()){
+                        tokens.remove(key);
+                    }else{
+                        logger.info("Get token from Redis Cache...");
+                        return token;
+                    }
+                }
+                //掉接口获取token
+                token = getTokenFromRemote();
+                //缓存token到Redis
+                if(token != null){
+                    redisTokenStore.tokenStore(key, token);
+                }
+            }else{
+                //掉接口获取token
+                token = getTokenFromRemote();
+                if(token != null){
+                    //缓存token到Redis
+                    redisTokenStore.tokenStore(key, token);
+                }
+            }
+
+        }
+        return token;
+    }
+
+    public Token getTokenFromRemote(){
+        logger.info("Get token from remote...");
+        //获取公钥
+        GetTokenRequestTest02 request = new GetTokenRequestTest02(oauthConfigBaseInfo);
+        GetTokenResponse getTokenResponse = request.doAction();
+        if(!getTokenResponse.isSuccess()){
+            logger.error("BaseRequest,getTokenFromRemote,get token error,error msg:{}",getTokenResponse.getErrMsg());
+            return null;
+        }
+        Token token = getTokenResponse.getData();
+        //设置ttl
+        token.setTtl(token.getExpires_in() + System.currentTimeMillis() / 1000);
+        return token;
+    }
+}

+ 35 - 0
huimv-farm-video/src/main/java/com/huimv/video/dhicc/test/request/GetPublicKeyRequest.java

@@ -0,0 +1,35 @@
+package com.huimv.video.dhicc.test.request;
+
+import com.alibaba.fastjson.JSON;
+import com.huimv.video.dhicc.test.config.OauthConfigBaseInfo;
+import com.huimv.video.dhicc.test.constant.Constant;
+import com.huimv.video.dhicc.test.response.GetPublicKeyResponse;
+import com.huimv.video.dhicc.test.utils.HttpURLConnectionUtil;
+import com.huimv.video.dhicc.test.utils.HttpsURLConnectionUtil;
+import com.huimv.video.dhicc.test.utils.UrlUtil;
+
+
+/**
+ * 获取公钥
+ */
+public class GetPublicKeyRequest extends BaseRequest<GetPublicKeyResponse> {
+
+    public GetPublicKeyRequest(OauthConfigBaseInfo oauthConfigBaseInfo){
+        super(oauthConfigBaseInfo, Constant.HTTP_GET, oauthConfigBaseInfo.getHttpConfigInfo().getPrefixUrl() + Constant.GET_PUBLIC_KEY, false);
+    }
+
+    public GetPublicKeyResponse doAction(){
+        //重置url信息,替换版本号
+        this.setUrl(UrlUtil.dealVersion(this.getUrl()));
+        //发送请求
+        String res = isEnableHttpTest() ? HttpURLConnectionUtil.doGet(this) : HttpsURLConnectionUtil.doGet(this);
+        //获取响应
+        GetPublicKeyResponse getPublicKeyResponse = JSON.parseObject(res, GetPublicKeyResponse.class);
+
+        return getPublicKeyResponse;
+    }
+
+    public boolean isEnableHttpTest(){
+        return super.getOauthConfigBaseInfo().getHttpConfigInfo().isEnableHttpTest();
+    }
+}

+ 36 - 0
huimv-farm-video/src/main/java/com/huimv/video/dhicc/test/request/GetPublicKeyRequest02.java

@@ -0,0 +1,36 @@
+package com.huimv.video.dhicc.test.request;
+
+import com.alibaba.fastjson.JSON;
+import com.huimv.video.dhicc.test.config.OauthConfigBaseInfo02;
+import com.huimv.video.dhicc.test.constant.Constant;
+import com.huimv.video.dhicc.test.response.GetPublicKeyResponse;
+import com.huimv.video.dhicc.test.utils.HttpURLConnectionUtil;
+import com.huimv.video.dhicc.test.utils.HttpsURLConnectionUtil;
+import com.huimv.video.dhicc.test.utils.UrlUtil;
+
+
+/**
+ * 获取公钥
+ */
+public class GetPublicKeyRequest02 extends BaseRequest02<GetPublicKeyResponse> {
+
+    public GetPublicKeyRequest02(OauthConfigBaseInfo02 oauthConfigBaseInfo){
+        super(oauthConfigBaseInfo, Constant.HTTP_GET, oauthConfigBaseInfo.getHttpConfigInfo().getPrefixUrl() + Constant.GET_PUBLIC_KEY, false);
+    }
+
+    @Override
+    public GetPublicKeyResponse doAction(){
+        //重置url信息,替换版本号
+        this.setUrl(UrlUtil.dealVersion(this.getUrl()));
+        //发送请求
+        String res = isEnableHttpTest() ? HttpURLConnectionUtil.doGet02(this) : HttpsURLConnectionUtil.doGet02(this);
+        //获取响应
+        GetPublicKeyResponse getPublicKeyResponse = JSON.parseObject(res, GetPublicKeyResponse.class);
+
+        return getPublicKeyResponse;
+    }
+
+    public boolean isEnableHttpTest(){
+        return super.getOauthConfigBaseInfo().getHttpConfigInfo().isEnableHttpTest();
+    }
+}

+ 20 - 0
huimv-farm-video/src/main/java/com/huimv/video/dhicc/test/request/GetPublicKeyRes.java

@@ -0,0 +1,20 @@
+package com.huimv.video.dhicc.test.request;
+
+
+import com.huimv.video.dhicc.test.other.BaseRes;
+import com.huimv.video.dhicc.test.response.GetPublicKeyResponse;
+
+/**
+ * 鉴权返回类
+ */
+public class GetPublicKeyRes extends BaseRes {
+    private GetPublicKeyResponse.GetPublicKeyResponseData data;
+
+    public GetPublicKeyResponse.GetPublicKeyResponseData getData() {
+        return data;
+    }
+
+    public void setData(GetPublicKeyResponse.GetPublicKeyResponseData data) {
+        this.data = data;
+    }
+}

+ 87 - 0
huimv-farm-video/src/main/java/com/huimv/video/dhicc/test/request/GetTokenRequestTest01.java

@@ -0,0 +1,87 @@
+package com.huimv.video.dhicc.test.request;
+
+import com.alibaba.fastjson.JSON;
+import com.dahuatech.icc.util.SignUtil;
+import com.huimv.video.dhicc.test.config.OauthConfigBaseInfo;
+import com.huimv.video.dhicc.test.config.OauthConfigUserPwdInfoTest01;
+import com.huimv.video.dhicc.test.constant.Constant;
+import com.huimv.video.dhicc.test.response.GetPublicKeyResponse;
+import com.huimv.video.dhicc.test.response.GetTokenResponse;
+import com.huimv.video.dhicc.test.utils.HttpURLConnectionUtil;
+import com.huimv.video.dhicc.test.utils.HttpsURLConnectionUtil;
+import com.huimv.video.dhicc.test.utils.UrlUtil;
+import lombok.Data;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * 获取token请求类
+ */
+@Data
+public class GetTokenRequestTest01 extends BaseRequest<GetTokenResponse> {
+    //授权类型
+    private String grant_type;
+    //用户名
+    private String username;
+    //通过RSA加密密码,详见获取公钥接口
+    private String password;
+    //客户端id,由鉴权中心下发
+    private String client_id;
+    //客户端secret,由鉴权中心下发
+    private String client_secret;
+    //公钥,由鉴权中心下发
+    private String public_key;
+    //默认关闭验证码校验,即无需关注verifyCodeFlag和code参数
+    private Integer verifyCodeFlag = 0;
+    private String code;
+
+    public GetTokenRequestTest01(){}
+
+    public GetTokenRequestTest01(OauthConfigBaseInfo oauthConfigBaseInfo){
+
+        super(oauthConfigBaseInfo, Constant.HTTP_POST, oauthConfigBaseInfo.getHttpConfigInfo().getPrefixUrl() + Constant.GET_TOKEN, false);
+        OauthConfigUserPwdInfoTest01 oauthConfigUserPwdInfo = (OauthConfigUserPwdInfoTest01) oauthConfigBaseInfo;
+        this.grant_type = oauthConfigUserPwdInfo.getGrantType().name();
+        this.username = oauthConfigUserPwdInfo.getUsername();
+        this.client_id = oauthConfigUserPwdInfo.getClientId();
+        this.client_secret = oauthConfigUserPwdInfo.getClientSecret();
+        GetPublicKeyRequest request = new GetPublicKeyRequest(oauthConfigBaseInfo);
+        GetPublicKeyResponse getPublicKeyResponse = request.doAction();
+        this.public_key = getPublicKeyResponse.getData().getPublicKey();
+        String enPassword = SignUtil.encryptRSA(oauthConfigUserPwdInfo.getPassword(), this.public_key);
+        this.password = enPassword;
+    }
+
+    public GetTokenResponse doAction(){
+        //重置url信息,替换版本号
+        this.setUrl(UrlUtil.dealVersion(this.getUrl()));
+        //设置请求参数
+        setBody();
+        //发送请求
+        String res = isEnableHttpTest() ? HttpURLConnectionUtil.doPost(this.getUrl(), this.getBody(), this.getHeader()) : HttpsURLConnectionUtil.doPost(this.getUrl(), this.getBody(), this.getHeader());
+        //获取响应
+        GetTokenResponse getTokenResponse = JSON.parseObject(res, GetTokenResponse.class);
+        return getTokenResponse;
+    }
+
+    /**
+     * 设置请求参数
+     * **/
+    public void setBody(){
+        //设置请求参数
+        Map<String, String> paramsMap = new HashMap();
+        paramsMap.put("grant_type", this.grant_type);
+        paramsMap.put("username", this.username);
+        paramsMap.put("password", this.password);
+        paramsMap.put("client_id", this.client_id);
+        paramsMap.put("client_secret", this.client_secret);
+        paramsMap.put("public_key", this.public_key);
+        paramsMap.put("verifyCodeFlag", String.valueOf(this.verifyCodeFlag));
+        this.setBody(JSON.toJSONString(paramsMap));
+    }
+
+    public boolean isEnableHttpTest(){
+        return super.getOauthConfigBaseInfo().getHttpConfigInfo().isEnableHttpTest();
+    }
+}

+ 86 - 0
huimv-farm-video/src/main/java/com/huimv/video/dhicc/test/request/GetTokenRequestTest02.java

@@ -0,0 +1,86 @@
+package com.huimv.video.dhicc.test.request;
+
+import com.alibaba.fastjson.JSON;
+import com.dahuatech.icc.util.SignUtil;
+import com.huimv.video.dhicc.test.config.OauthConfigBaseInfo02;
+import com.huimv.video.dhicc.test.config.OauthConfigUserPwdInfoTest02;
+import com.huimv.video.dhicc.test.constant.Constant;
+import com.huimv.video.dhicc.test.response.GetPublicKeyResponse;
+import com.huimv.video.dhicc.test.response.GetTokenResponse;
+import com.huimv.video.dhicc.test.utils.HttpURLConnectionUtil;
+import com.huimv.video.dhicc.test.utils.HttpsURLConnectionUtil;
+import com.huimv.video.dhicc.test.utils.UrlUtil;
+import lombok.Data;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * 获取token请求类
+ */
+@Data
+public class GetTokenRequestTest02 extends BaseRequest02<GetTokenResponse> {
+    //授权类型
+    private String grant_type;
+    //用户名
+    private String username;
+    //通过RSA加密密码,详见获取公钥接口
+    private String password;
+    //客户端id,由鉴权中心下发
+    private String client_id;
+    //客户端secret,由鉴权中心下发
+    private String client_secret;
+    //公钥,由鉴权中心下发
+    private String public_key;
+    //默认关闭验证码校验,即无需关注verifyCodeFlag和code参数
+    private Integer verifyCodeFlag = 0;
+    private String code;
+
+    public GetTokenRequestTest02(){}
+
+    public GetTokenRequestTest02(OauthConfigBaseInfo02 oauthConfigBaseInfo){
+        super(oauthConfigBaseInfo, Constant.HTTP_POST,oauthConfigBaseInfo.getHttpConfigInfo().getPrefixUrl() + Constant.GET_TOKEN , false);
+        OauthConfigUserPwdInfoTest02 oauthConfigUserPwdInfo = (OauthConfigUserPwdInfoTest02) oauthConfigBaseInfo;
+        this.grant_type = oauthConfigUserPwdInfo.getGrantType().name();
+        this.username = oauthConfigUserPwdInfo.getUsername();
+        this.client_id = oauthConfigUserPwdInfo.getClientId();
+        this.client_secret = oauthConfigUserPwdInfo.getClientSecret();
+        GetPublicKeyRequest02 request = new GetPublicKeyRequest02(oauthConfigBaseInfo);
+        GetPublicKeyResponse getPublicKeyResponse = request.doAction();
+        this.public_key = getPublicKeyResponse.getData().getPublicKey();
+        String enPassword = SignUtil.encryptRSA(oauthConfigUserPwdInfo.getPassword(), this.public_key);
+        this.password = enPassword;
+    }
+
+    public GetTokenResponse doAction(){
+        //重置url信息,替换版本号
+        this.setUrl(UrlUtil.dealVersion(this.getUrl()));
+        //设置请求参数
+        setBody();
+        //发送请求
+        String res = isEnableHttpTest() ? HttpURLConnectionUtil.doPost(this.getUrl(), this.getBody(), this.getHeader()) : HttpsURLConnectionUtil.doPost(this.getUrl(), this.getBody(), this.getHeader());
+        //获取响应
+        GetTokenResponse getTokenResponse = JSON.parseObject(res, GetTokenResponse.class);
+        return getTokenResponse;
+    }
+
+    /**
+     * 设置请求参数
+     * **/
+    public void setBody(){
+        //设置请求参数
+        Map<String, String> paramsMap = new HashMap();
+        paramsMap.put("grant_type", this.grant_type);
+        paramsMap.put("username", this.username);
+        paramsMap.put("password", this.password);
+        paramsMap.put("client_id", this.client_id);
+        paramsMap.put("client_secret", this.client_secret);
+        paramsMap.put("public_key", this.public_key);
+        paramsMap.put("verifyCodeFlag", String.valueOf(this.verifyCodeFlag));
+        this.setBody(JSON.toJSONString(paramsMap));
+    }
+
+    public boolean isEnableHttpTest(){
+        return super.getOauthConfigBaseInfo().getHttpConfigInfo().isEnableHttpTest();
+    }
+}

+ 60 - 0
huimv-farm-video/src/main/java/com/huimv/video/dhicc/test/request/OauthRefreshTokenRequest.java

@@ -0,0 +1,60 @@
+package com.huimv.video.dhicc.test.request;
+
+import com.alibaba.fastjson.JSON;
+import com.dahuatech.icc.oauth.model.v202010.OauthRefreshTokenResponse;
+import com.dahuatech.icc.oauth.profile.GrantType;
+import com.huimv.video.dhicc.test.config.OauthConfigBaseInfo;
+import com.huimv.video.dhicc.test.constant.Constant;
+import com.huimv.video.dhicc.test.utils.HttpURLConnectionUtil;
+import com.huimv.video.dhicc.test.utils.UrlUtil;
+import lombok.Data;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * 刷新token请求
+ */
+@Data
+public class OauthRefreshTokenRequest extends BaseRequest<OauthRefreshTokenResponse> {
+    private String grant_type;
+    private String client_id;
+    private String client_secret;
+    private String refresh_token;
+
+    OauthRefreshTokenRequest(){}
+
+    public OauthRefreshTokenRequest(OauthConfigBaseInfo oauthConfigBaseInfo, String refresh_token){
+        super(oauthConfigBaseInfo, Constant.HTTP_POST, Constant.REFRESH_TOKEN, true);
+        this.grant_type = GrantType.refresh_token.name();
+        this.client_id = oauthConfigBaseInfo.getClientId();
+        this.client_secret = oauthConfigBaseInfo.getClientSecret();
+        this.refresh_token = refresh_token;
+        setBody();
+    }
+
+    public OauthRefreshTokenResponse doAction(){
+        //重置url信息,替换版本号
+        this.setUrl(UrlUtil.dealVersion(this.getUrl()));
+        //设置请求参数
+        setBody();
+        //发送请求
+        String res = HttpURLConnectionUtil.doPost(this.getBody(), this.getUrl(), this.getHeader());
+        //获取响应
+        OauthRefreshTokenResponse oauthRefreshTokenResponse = JSON.parseObject(res, OauthRefreshTokenResponse.class);
+        return oauthRefreshTokenResponse;
+    }
+
+    /**
+     * 设置请求参数
+     * **/
+    public void setBody(){
+        //设置请求参数
+        Map<String, String> paramsMap = new HashMap();
+        paramsMap.put("grant_type", this.grant_type);
+        paramsMap.put("client_id", this.client_id);
+        paramsMap.put("client_secret", this.client_secret);
+        paramsMap.put("refresh_token", this.refresh_token);
+        this.setBody(JSON.toJSONString(paramsMap));
+    }
+}

+ 60 - 0
huimv-farm-video/src/main/java/com/huimv/video/dhicc/test/request/OauthRefreshTokenRequest02.java

@@ -0,0 +1,60 @@
+package com.huimv.video.dhicc.test.request;
+
+import com.alibaba.fastjson.JSON;
+import com.dahuatech.icc.oauth.profile.GrantType;
+import com.huimv.video.dhicc.test.config.OauthConfigBaseInfo02;
+import com.huimv.video.dhicc.test.constant.Constant;
+import com.huimv.video.dhicc.test.response.OauthRefreshTokenResponse;
+import com.huimv.video.dhicc.test.utils.HttpURLConnectionUtil;
+import com.huimv.video.dhicc.test.utils.UrlUtil;
+import lombok.Data;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * 刷新token请求
+ */
+@Data
+public class OauthRefreshTokenRequest02 extends BaseRequest02<OauthRefreshTokenResponse> {
+    private String grant_type;
+    private String client_id;
+    private String client_secret;
+    private String refresh_token;
+
+    OauthRefreshTokenRequest02(){}
+
+    public OauthRefreshTokenRequest02(OauthConfigBaseInfo02 oauthConfigBaseInfo, String refresh_token){
+        super(oauthConfigBaseInfo, Constant.HTTP_POST, Constant.REFRESH_TOKEN, true);
+        this.grant_type = GrantType.refresh_token.name();
+        this.client_id = oauthConfigBaseInfo.getClientId();
+        this.client_secret = oauthConfigBaseInfo.getClientSecret();
+        this.refresh_token = refresh_token;
+        setBody();
+    }
+
+    public OauthRefreshTokenResponse doAction(){
+        //重置url信息,替换版本号
+        this.setUrl(UrlUtil.dealVersion(this.getUrl()));
+        //设置请求参数
+        setBody();
+        //发送请求
+        String res = HttpURLConnectionUtil.doPost(this.getBody(), this.getUrl(), this.getHeader());
+        //获取响应
+        OauthRefreshTokenResponse oauthRefreshTokenResponse = JSON.parseObject(res, OauthRefreshTokenResponse.class);
+        return oauthRefreshTokenResponse;
+    }
+
+    /**
+     * 设置请求参数
+     * **/
+    public void setBody(){
+        //设置请求参数
+        Map<String, String> paramsMap = new HashMap();
+        paramsMap.put("grant_type", this.grant_type);
+        paramsMap.put("client_id", this.client_id);
+        paramsMap.put("client_secret", this.client_secret);
+        paramsMap.put("refresh_token", this.refresh_token);
+        this.setBody(JSON.toJSONString(paramsMap));
+    }
+}

+ 73 - 0
huimv-farm-video/src/main/java/com/huimv/video/dhicc/test/request/PersonListRequestHn.java

@@ -0,0 +1,73 @@
+package com.huimv.video.dhicc.test.request;
+
+import com.alibaba.fastjson.JSON;
+import com.huimv.video.dhicc.test.config.OauthConfigBaseInfo;
+import com.huimv.video.dhicc.test.config.OauthConfigBaseInfo02;
+import com.huimv.video.dhicc.test.constant.Constant;
+import com.huimv.video.dhicc.test.utils.HttpURLConnectionUtil;
+import com.huimv.video.dhicc.test.utils.HttpsURLConnectionUtil;
+import com.huimv.video.dhicc.test.utils.UrlUtil;
+import lombok.Data;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+@Data
+public class PersonListRequestHn extends BaseRequest02<String> {
+
+    private Integer farmId;
+
+    private String searchKey;
+
+    private Integer pageNum;
+
+    private Integer pageSize;
+
+    private Integer departmentId;
+
+    private Boolean isContain;
+
+    private List<Integer> statusList;
+
+
+    public PersonListRequestHn() {
+    }
+
+    public PersonListRequestHn(OauthConfigBaseInfo02 oauthConfigBaseInfo) {
+        super(oauthConfigBaseInfo, Constant.HTTP_POST, oauthConfigBaseInfo.getHttpConfigInfo().getPrefixUrl() + Constant.CHANNEL_URL_PERSON_LIST, true);
+    }
+
+    @Override
+    public String doAction() {
+        //重置url信息,替换版本号
+        this.setUrl(UrlUtil.dealVersion(this.getUrl()));
+        //设置请求参数
+        setBody();
+        //发送请求
+        String res = isEnableHttpTest() ? HttpURLConnectionUtil.doPost(this.getUrl(), this.getBody(), this.getHeader()) : HttpsURLConnectionUtil.doPost(this.getUrl(), this.getBody(), this.getHeader());
+        //获取响应
+
+       // PersonListResponseSg devicePageResponse = JSON.parseObject(res, PersonListResponseSg.class);
+
+        return res;
+    }
+
+    private void setBody() {
+        //设置请求参数
+        Map<String, Object> map = new HashMap<>();
+        map.put("pageNum", this.pageNum);
+        map.put("pageSize", this.pageSize);
+        map.put("isContain", this.isContain);
+        map.put("searchKey", this.searchKey);
+        map.put("statusList", this.statusList);
+        map.put("departmentId", this.departmentId);
+        this.setBody(JSON.toJSONString(map));
+
+    }
+
+
+    public boolean isEnableHttpTest() {
+        return super.getOauthConfigBaseInfo().getHttpConfigInfo().isEnableHttpTest();
+    }
+}

+ 73 - 0
huimv-farm-video/src/main/java/com/huimv/video/dhicc/test/request/PersonListRequestSg.java

@@ -0,0 +1,73 @@
+package com.huimv.video.dhicc.test.request;
+
+import com.alibaba.fastjson.JSON;
+import com.huimv.video.dhicc.test.config.OauthConfigBaseInfo;
+import com.huimv.video.dhicc.test.constant.Constant;
+import com.huimv.video.dhicc.test.response.PersonListResponseSg;
+import com.huimv.video.dhicc.test.utils.HttpURLConnectionUtil;
+import com.huimv.video.dhicc.test.utils.HttpsURLConnectionUtil;
+import com.huimv.video.dhicc.test.utils.UrlUtil;
+import lombok.Data;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+@Data
+public class PersonListRequestSg extends BaseRequest<String> {
+
+    private Integer farmId;
+
+    private String searchKey;
+
+    private Integer pageNum;
+
+    private Integer pageSize;
+
+    private Integer departmentId;
+
+    private Boolean isContain;
+
+    private List<Integer> statusList;
+
+
+    public PersonListRequestSg() {
+    }
+
+    public PersonListRequestSg(OauthConfigBaseInfo oauthConfigBaseInfo) {
+        super(oauthConfigBaseInfo, Constant.HTTP_POST, oauthConfigBaseInfo.getHttpConfigInfo().getPrefixUrl() + Constant.CHANNEL_URL_PERSON_LIST, true);
+    }
+
+    @Override
+    public String doAction() {
+        //重置url信息,替换版本号
+        this.setUrl(UrlUtil.dealVersion(this.getUrl()));
+        //设置请求参数
+        setBody();
+        //发送请求
+        String res = isEnableHttpTest() ? HttpURLConnectionUtil.doPost(this.getUrl(), this.getBody(), this.getHeader()) : HttpsURLConnectionUtil.doPost(this.getUrl(), this.getBody(), this.getHeader());
+        //获取响应
+
+       // PersonListResponseSg devicePageResponse = JSON.parseObject(res, PersonListResponseSg.class);
+
+        return res;
+    }
+
+    private void setBody() {
+        //设置请求参数
+        Map<String, Object> map = new HashMap<>();
+        map.put("pageNum", this.pageNum);
+        map.put("pageSize", this.pageSize);
+        map.put("isContain", this.isContain);
+        map.put("searchKey", this.searchKey);
+        map.put("statusList", this.statusList);
+        map.put("departmentId", this.departmentId);
+        this.setBody(JSON.toJSONString(map));
+
+    }
+
+
+    public boolean isEnableHttpTest() {
+        return super.getOauthConfigBaseInfo().getHttpConfigInfo().isEnableHttpTest();
+    }
+}

+ 32 - 0
huimv-farm-video/src/main/java/com/huimv/video/dhicc/test/response/BaseResponse.java

@@ -0,0 +1,32 @@
+package com.huimv.video.dhicc.test.response;
+
+import lombok.AllArgsConstructor;
+import lombok.Data;
+
+/**
+ * 响应基类
+ */
+@AllArgsConstructor
+@Data
+public class BaseResponse {
+    /** 结果原报文 */
+    private String result;
+    /** 请求ID */
+    private String requestId;
+    /** 返回状态码 */
+    private String code;
+    /** 是否成功 */
+    private boolean success;
+    /** 错误信息 */
+    private String errMsg;
+    /** 用于构建错误描述的参数 **/
+    private Object args;
+
+    public BaseResponse(){}
+
+    public BaseResponse(String code, String errMsg, boolean success){
+        this.code = code;
+        this.errMsg = errMsg;
+        this.success = success;
+    }
+}

+ 16 - 0
huimv-farm-video/src/main/java/com/huimv/video/dhicc/test/response/GetPublicKeyResponse.java

@@ -0,0 +1,16 @@
+package com.huimv.video.dhicc.test.response;
+
+import lombok.Data;
+
+/**
+ * 获取公钥响应类
+ */
+@Data
+public class GetPublicKeyResponse extends BaseResponse {
+    private GetPublicKeyResponseData data;
+
+    @Data
+    public class GetPublicKeyResponseData{
+        private String publicKey;
+    }
+}

+ 13 - 0
huimv-farm-video/src/main/java/com/huimv/video/dhicc/test/response/GetTokenResponse.java

@@ -0,0 +1,13 @@
+package com.huimv.video.dhicc.test.response;
+
+
+import com.huimv.video.dhicc.test.token.Token;
+import lombok.Data;
+
+/**
+ * 获取token响应类
+ */
+@Data
+public class GetTokenResponse extends BaseResponse {
+    private Token data;
+}

+ 25 - 0
huimv-farm-video/src/main/java/com/huimv/video/dhicc/test/response/OauthRefreshTokenResponse.java

@@ -0,0 +1,25 @@
+package com.huimv.video.dhicc.test.response;
+
+import lombok.Data;
+import lombok.ToString;
+
+/**
+ * 刷新token响应
+ */
+@Data
+@ToString
+public class OauthRefreshTokenResponse extends BaseResponse {
+    private IccReFreshToken data;
+
+    @Data
+    @ToString
+    public class IccReFreshToken{
+        private String access_token;
+        private String refresh_token;
+        private Long expires_in;
+        private String scope;
+        private String userId;
+        private String magicId;
+        private String token_type;
+    }
+}

+ 25 - 0
huimv-farm-video/src/main/java/com/huimv/video/dhicc/test/response/OauthRefreshTokenResponse02.java

@@ -0,0 +1,25 @@
+package com.huimv.video.dhicc.test.response;
+
+import lombok.Data;
+import lombok.ToString;
+
+/**
+ * 刷新token响应
+ */
+@Data
+@ToString
+public class OauthRefreshTokenResponse02 extends BaseResponse {
+    private IccReFreshToken data;
+
+    @Data
+    @ToString
+    public class IccReFreshToken{
+        private String access_token;
+        private String refresh_token;
+        private Long expires_in;
+        private String scope;
+        private String userId;
+        private String magicId;
+        private String token_type;
+    }
+}

+ 22 - 0
huimv-farm-video/src/main/java/com/huimv/video/dhicc/test/response/PersonListResponseSg.java

@@ -0,0 +1,22 @@
+package com.huimv.video.dhicc.test.response;
+
+import lombok.Data;
+
+import java.util.List;
+
+/*
+* personList
+* */
+@Data
+/*@ToString*/
+public class PersonListResponseSg extends BaseResponse {
+
+    /*private ChannerlCardData data;*/
+
+    /*private List<ChannelData> data;*/
+
+   /* @Data
+    public static class ChannerlCardData {
+        private List<ChannelData> data;
+    }*/
+}

+ 238 - 0
huimv-farm-video/src/main/java/com/huimv/video/dhicc/test/schedule/UpdateTokenSchedule.java

@@ -0,0 +1,238 @@
+package com.huimv.video.dhicc.test.schedule;
+
+import com.alibaba.fastjson.JSON;
+import com.dahuatech.icc.oauth.model.v202010.OauthRefreshTokenResponse;
+import com.dahuatech.icc.oauth.profile.GrantType;
+import com.huimv.video.dhicc.test.config.OauthConfigBaseInfo;
+import com.huimv.video.dhicc.test.config.OauthConfigBaseInfo02;
+import com.huimv.video.dhicc.test.config.OauthConfigUserPwdInfoTest01;
+import com.huimv.video.dhicc.test.config.OauthConfigUserPwdInfoTest02;
+import com.huimv.video.dhicc.test.request.OauthRefreshTokenRequest;
+import com.huimv.video.dhicc.test.token.LocalTokenStore;
+import com.huimv.video.dhicc.test.token.RedisTokenStore;
+import com.huimv.video.dhicc.test.token.Token;
+import com.huimv.video.dhicc.test.token.TokenStore;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.BeanUtils;
+import org.springframework.util.CollectionUtils;
+import org.springframework.util.StringUtils;
+
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.Executors;
+import java.util.concurrent.ScheduledExecutorService;
+
+/**
+ * 定时任务类:更新token
+ * TODO: 当前版本暂未支持自动刷新token
+ */
+public class UpdateTokenSchedule {
+    public static final Logger logger = LoggerFactory.getLogger(UpdateTokenSchedule.class);
+
+    //token存储方式:这里采用本地缓存,如需修改,可替换为Redis或MySQL存储
+    public static final TokenStore tokenStore = new LocalTokenStore();
+    private static final Object lock = new Object();
+    private static UpdateTokenSchedule instance;
+    public static final Map<String, OauthConfigBaseInfo> httpConfigMap = new ConcurrentHashMap<String, OauthConfigBaseInfo>();
+    public static final Map<String, OauthConfigBaseInfo02> httpConfigMap2 = new ConcurrentHashMap<String, OauthConfigBaseInfo02>();
+    //2分钟刷新一次过期token
+    private static final Long expireTime = 120 * 1000L;
+    //线程刷新token和保活
+    private static final ScheduledExecutorService executorService = Executors.newScheduledThreadPool(1);
+    //初始延迟
+    private static final Long INITIAL_DELAY = 0L;
+    //执行任务延迟
+    private static final Long FRESH_TOKEN_INTERVAL = 2L;
+
+    private UpdateTokenSchedule() {
+        //定时刷新token
+//        executorService.scheduleWithFixedDelay(new Thread()() -> {
+//            logger.info("UpdateTokenSchedule,UpdateTokenSchedule,Start refreshing token...");
+//            updateToken();
+//        }, INITIAL_DELAY, FRESH_TOKEN_INTERVAL, TimeUnit.SECONDS);
+    }
+//
+//    public static UpdateTokenSchedule getInstance(){
+//        if(instance == null){
+//            synchronized (lock){
+//                if(instance == null){
+//                    instance = new UpdateTokenSchedule();
+//                }
+//            }
+//        }
+//        return instance;
+//    }
+
+    public void updateToken() {
+        Object o = tokenStore.getToken();
+        if (o != null) {
+            dealToken(o);
+        } else {
+            logger.info("Token story is empty, update token task return.");
+        }
+    }
+
+    public void dealToken(Object o) {
+      /*  if (tokenStore instanceof MysqlTokenStore) {
+            logger.info("Update token from mysql.");
+            MysqlTokenStore mysqlTokenStore = (MysqlTokenStore) tokenStore;
+            Map<String, Token> tokens = (Map<String, Token>) o;
+            if (CollectionUtils.isEmpty(tokens)) {
+                logger.info("Mysql token story is empty, update token task return.");
+                return;
+            }
+            dealExpiredToken(mysqlTokenStore, tokens);
+        }*/
+
+        if (tokenStore instanceof RedisTokenStore) {
+            logger.info("Update token from redis.");
+            RedisTokenStore redisTokenStore = (RedisTokenStore) tokenStore;
+            Map<String, String> tokens = (Map<String, String>) o;
+            if (CollectionUtils.isEmpty(tokens)) {
+                logger.info("Redis token story is empty, update token task return.");
+                return;
+            }
+            dealExpiredToken(redisTokenStore, tokens);
+        }
+
+        if (tokenStore instanceof LocalTokenStore) {
+            logger.info("Update token from local story.");
+            LocalTokenStore localTokenStore = (LocalTokenStore) tokenStore;
+            Map<String, Token> tokenMap = (Map<String, Token>) o;
+            if (CollectionUtils.isEmpty(tokenMap)) {
+                logger.info("Local map token story is empty, update token task return.");
+                return;
+            }
+            dealExpiredToken(localTokenStore, tokenMap);
+        }
+    }
+
+  /*  public void dealExpiredToken(MysqlTokenStore mysqlTokenStore, Map<String, Token> tokenMap) {
+        for (Map.Entry entry : tokenMap.entrySet()) {
+            String key = (String) entry.getKey();
+            Token token = (Token) entry.getValue();
+            Long ttl = token.getTtl();
+
+            //token剩余过期时间小于等于2分钟时,更新token
+            if (ttl - System.currentTimeMillis() <= expireTime) {
+                logger.info("UpdateTokenSchedule,dealExpiredToken, key:{}", key);
+                token = refreshToken(key, token.getRefresh_token());
+                if (token == null) {
+                    return;
+                }
+                //生成用于缓存的key
+                OauthConfigBaseInfo oauthConfigBaseInfo = httpConfigMap.get(key);
+                String tokenKey = getKey(oauthConfigBaseInfo);
+                if (StringUtils.isEmpty(tokenKey)) {
+                    return;
+                }
+                //将token进行缓存
+                mysqlTokenStore.updateToken(tokenKey, token);
+            }
+        }
+
+    }*/
+
+    public void dealExpiredToken(LocalTokenStore localTokenStore, Map<String, Token> tokenMap) {
+        for (Map.Entry entry : tokenMap.entrySet()) {
+            String key = (String) entry.getKey();
+            Token token = (Token) entry.getValue();
+            Long ttl = token.getTtl();
+
+            //token剩余过期时间小于等于2分钟时,更新token
+            if (ttl - System.currentTimeMillis() <= expireTime) {
+                logger.info("UpdateTokenSchedule,dealExpiredToken, key:{}", key);
+                token = refreshToken(key, token.getRefresh_token());
+                if (token == null) {
+                    return;
+                }
+                //生成用于缓存的key
+                OauthConfigBaseInfo oauthConfigBaseInfo = httpConfigMap.get(key);
+                String tokenKey = getKey(oauthConfigBaseInfo);
+                if (StringUtils.isEmpty(tokenKey)) {
+                    return;
+                }
+                //将token进行缓存
+                localTokenStore.tokenMap.put(tokenKey, token);
+            }
+        }
+    }
+
+    public void dealExpiredToken(RedisTokenStore redisTokenStore, Map<String, String> tokens) {
+        for (Map.Entry entry : tokens.entrySet()) {
+            String key = (String) entry.getKey();
+            String value = (String) entry.getValue();
+            Token token = JSON.parseObject(value, Token.class);
+            Long ttl = token.getTtl();
+
+            //token剩余过期时间小于等于2分钟时,更新token
+            if (ttl - System.currentTimeMillis() <= expireTime) {
+                logger.info("UpdateTokenSchedule,dealExpiredToken, key:{}", key);
+                token = refreshToken(key, token.getRefresh_token());
+                if (token == null) return;
+                //生成用于缓存的key
+                OauthConfigBaseInfo oauthConfigBaseInfo = httpConfigMap.get(key);
+                String tokenKey = getKey(oauthConfigBaseInfo);
+                if (StringUtils.isEmpty(tokenKey)) return;
+                //将token进行缓存
+                redisTokenStore.updateToken(tokenKey, token);
+            }
+        }
+    }
+
+    public Token refreshToken(String key, String refreshToken) {
+        Token newToken = null;
+        OauthConfigBaseInfo oauthConfigBaseInfo = httpConfigMap.get(key);
+
+        //目前只支持密码模式
+        if (oauthConfigBaseInfo.getGrantType() == GrantType.password) {
+            OauthRefreshTokenRequest oauthRefreshTokenRequest = new OauthRefreshTokenRequest(oauthConfigBaseInfo, refreshToken);
+            OauthRefreshTokenResponse oauthRefreshTokenResponse = oauthRefreshTokenRequest.doAction();
+            if (oauthRefreshTokenResponse.isSuccess()) {
+                OauthRefreshTokenResponse.IccReFreshToken iccReFreshToken = oauthRefreshTokenResponse.getData();
+                newToken = new Token();
+                BeanUtils.copyProperties(iccReFreshToken, newToken);
+                //设置过期时间
+                newToken.setTtl(System.currentTimeMillis() + iccReFreshToken.getExpires_in() * 1000);
+                return newToken;
+            } else {
+                logger.error("UpdateTokenSchedule,refreshToken, error:{}", key);
+                return null;
+            }
+        }
+        //客户端模式,暂不作处理
+        else if (oauthConfigBaseInfo.getGrantType() == GrantType.client_credentials) {
+
+        }
+        return newToken;
+    }
+
+    public static String getKey(OauthConfigBaseInfo oauthConfigBaseInfo) {
+        if (oauthConfigBaseInfo.getGrantType() == GrantType.password) {
+            String host = oauthConfigBaseInfo.getHttpConfigInfo().getHost();
+            String grantType = oauthConfigBaseInfo.getGrantType().name();
+            String userName = null;
+            OauthConfigUserPwdInfoTest01 oauthConfigUserPwdInfo = (OauthConfigUserPwdInfoTest01) oauthConfigBaseInfo;
+            userName = oauthConfigUserPwdInfo.getUsername();
+            String key = host + "_" + grantType + "_" + userName;
+            logger.info("UpdateTokenSchedule,getKey, key:{}", key);
+            return key;
+        }
+        return null;
+    }
+
+    public static String getKey2(OauthConfigBaseInfo02 oauthConfigBaseInfo) {
+        if (oauthConfigBaseInfo.getGrantType() == GrantType.password) {
+            String host = oauthConfigBaseInfo.getHttpConfigInfo().getHost();
+            String grantType = oauthConfigBaseInfo.getGrantType().name();
+            String userName = null;
+            OauthConfigUserPwdInfoTest02 oauthConfigUserPwdInfo = (OauthConfigUserPwdInfoTest02) oauthConfigBaseInfo;
+            userName = oauthConfigUserPwdInfo.getUsername();
+            String key = host + "_" + grantType + "_" + userName;
+            logger.info("UpdateTokenSchedule,getKey, key:{}", key);
+            return key;
+        }
+        return null;
+    }
+}

+ 23 - 0
huimv-farm-video/src/main/java/com/huimv/video/dhicc/test/service/IOauthService.java

@@ -0,0 +1,23 @@
+package com.huimv.video.dhicc.test.service;
+
+
+import com.huimv.video.dhicc.test.request.GetPublicKeyRes;
+import com.huimv.video.dhicc.test.response.GetTokenResponse;
+
+import java.util.Map;
+
+public interface IOauthService {
+    /**
+     * 获取公钥
+     **/
+    GetPublicKeyRes getPublicKey();
+
+   /* *//**
+     * 获取token
+     **//*
+    GetTokenResponse getToken();*/
+
+    String getTokenTest01(Map<String, String> paramsMap);
+
+    GetTokenResponse getTokenTest02();
+}

+ 99 - 0
huimv-farm-video/src/main/java/com/huimv/video/dhicc/test/service/impl/OauthService.java

@@ -0,0 +1,99 @@
+package com.huimv.video.dhicc.test.service.impl;
+
+import com.huimv.video.dhicc.test.manager.IOauthIntegrationManager;
+import com.huimv.video.dhicc.test.other.BaseService;
+import com.huimv.video.dhicc.test.request.GetPublicKeyRes;
+import com.huimv.video.dhicc.test.response.GetPublicKeyResponse;
+import com.huimv.video.dhicc.test.response.GetTokenResponse;
+import com.huimv.video.dhicc.test.service.IOauthService;
+import org.springframework.beans.BeanUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.Map;
+
+@Service
+public class OauthService extends BaseService implements IOauthService {
+
+    @Autowired
+    private IOauthIntegrationManager oauthIntegrationManager;
+
+    /**
+     * 获取公钥
+     **/
+    @Override
+    public GetPublicKeyRes getPublicKey() {
+        GetPublicKeyResponse response = oauthIntegrationManager.getPublicKey();
+        GetPublicKeyRes res = new GetPublicKeyRes();
+        if(response.isSuccess()){
+            //处理成功逻辑
+        }else{
+            //处理异常逻辑
+        }
+        BeanUtils.copyProperties(response,res);
+        return res;
+    }
+
+  /*  *//**
+     * 获取token
+     **//*
+    public GetTokenResponse getToken() {
+        GetTokenResponse response = oauthIntegrationManager.getToken();
+        if(response.isSuccess()){
+            //处理成功逻辑
+        }else{
+            //处理异常逻辑
+        }
+        GetTokenResponse res = new GetTokenResponse();
+        BeanUtils.copyProperties(response,res);
+        return res;
+    }*/
+
+    /**
+     * 获取token
+     **/
+    @Override
+    public String getTokenTest01(Map<String,String> paramsMap) {
+        String type = paramsMap.get("type");
+        if ("1".equals(type)) {
+            GetTokenResponse response = oauthIntegrationManager.getTokenTest01();
+            if(response.isSuccess()){
+                //处理成功逻辑
+            }else{
+                //处理异常逻辑
+            }
+            String access_token = response.getData().getAccess_token();
+            GetTokenResponse res = new GetTokenResponse();
+            BeanUtils.copyProperties(response,res);
+            return ("token:"+access_token);
+        } else {
+            GetTokenResponse response = oauthIntegrationManager.getTokenTest02();
+            if(response.isSuccess()){
+                //处理成功逻辑
+            }else{
+                //处理异常逻辑
+            }
+            String access_token = response.getData().getAccess_token();
+            GetTokenResponse res = new GetTokenResponse();
+            BeanUtils.copyProperties(response,res);
+            return ("token:"+access_token);
+        }
+
+    }
+
+    /**
+     * 获取token
+     **/
+    @Override
+    public GetTokenResponse getTokenTest02() {
+        GetTokenResponse response = oauthIntegrationManager.getTokenTest02();
+        if(response.isSuccess()){
+            //处理成功逻辑
+        }else{
+            //处理异常逻辑
+        }
+        GetTokenResponse res = new GetTokenResponse();
+        BeanUtils.copyProperties(response,res);
+        return res;
+    }
+}

+ 48 - 0
huimv-farm-video/src/main/java/com/huimv/video/dhicc/test/token/LocalTokenStore.java

@@ -0,0 +1,48 @@
+package com.huimv.video.dhicc.test.token;
+
+import lombok.ToString;
+import org.springframework.stereotype.Component;
+import org.springframework.util.CollectionUtils;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * token存储方式为本地缓存
+ */
+@Component
+@ToString
+public class LocalTokenStore implements TokenStore {
+
+    public static Map<String, Token> tokenMap;
+    public static final Object lock = new Object();
+
+    public LocalTokenStore(){}
+
+    public static Map<String, Token> getTokenMap(){
+        if(CollectionUtils.isEmpty(tokenMap)){
+            synchronized (lock){
+                if(CollectionUtils.isEmpty(tokenMap)){
+                    tokenMap = new HashMap<String, Token>();
+                }
+            }
+        }
+        return tokenMap;
+    }
+
+    /**
+     * 存储token
+     * @param:key 键
+     * @param:token 值
+     * **/
+    public void tokenStore(String key, Token token){
+        tokenMap.put(key, token);
+    }
+
+    /**
+     * 获取token
+     * **/
+    public Map<String, Token> getToken(){
+        return tokenMap;
+    }
+}

+ 15 - 0
huimv-farm-video/src/main/java/com/huimv/video/dhicc/test/token/MysqlStoredToken.java

@@ -0,0 +1,15 @@
+package com.huimv.video.dhicc.test.token;
+
+import lombok.Data;
+import lombok.ToString;
+
+/**
+ * mysql方式存储的token对象
+ */
+@Data
+@ToString
+public class MysqlStoredToken {
+    private Integer id;
+    private String token_key;
+    private String token_value;
+}

+ 124 - 0
huimv-farm-video/src/main/java/com/huimv/video/dhicc/test/token/MysqlTokenStore.java

@@ -0,0 +1,124 @@
+package com.huimv.video.dhicc.test.token;
+
+import com.alibaba.fastjson.JSON;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.jdbc.core.BeanPropertyRowMapper;
+import org.springframework.jdbc.core.JdbcTemplate;
+import org.springframework.jdbc.core.RowMapper;
+import org.springframework.jdbc.datasource.DriverManagerDataSource;
+
+import javax.sql.DataSource;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+
+/**
+ * token存储方式为Mysql
+ */
+public class MysqlTokenStore implements TokenStore {
+    public static final Logger logger = LoggerFactory.getLogger(MysqlTokenStore.class);
+    public static final Object lock = new Object();
+
+    public static String INSERT_TOKEN_INFO = "insert into token(token_key,token_value) values(?, ?)";
+    public static String QUERY_TOKEN_INFO = "select id,token_key,token_value from token";
+    public static String UPDATE_TOKEN_INFO = "update token set token_value = ? where token_key = ?";
+    public static String DELETE_TOKEN_ALL = "delete from token";
+
+    private JdbcTemplate jdbcTemplate;
+
+    public MysqlTokenStore(){}
+
+    public JdbcTemplate getJdbcTemplate(){
+        if(jdbcTemplate == null){
+            synchronized (lock){
+                if(jdbcTemplate == null){
+                    jdbcTemplate = new JdbcTemplate(getDataSource());
+                }
+            }
+        }
+        return jdbcTemplate;
+    }
+
+    /**
+     * 存储token
+     * @param:key 键
+     * @param:token 值
+     * **/
+    public void tokenStore(String tokenKey, Token token){
+        INSERT_TOKEN_INFO = INSERT_TOKEN_INFO.replaceFirst("[?]", tokenKey);
+        INSERT_TOKEN_INFO = INSERT_TOKEN_INFO.replaceFirst("[?]", "\'" + JSON.toJSONString(token) + "\'");
+        jdbcTemplate.execute(INSERT_TOKEN_INFO);
+    }
+
+    /**
+     * 获取token信息
+     * @return List<Token>
+     * **/
+    public Map<String, Token> getToken(){
+        RowMapper<MysqlStoredToken> rowMapper = new BeanPropertyRowMapper<MysqlStoredToken>(MysqlStoredToken.class);
+        List<MysqlStoredToken> mysqlStoredTokens = jdbcTemplate.query(QUERY_TOKEN_INFO, rowMapper);
+        Map<String, Token> tokens = new HashMap<String, Token>();
+        for(int i = 0; i < mysqlStoredTokens.size(); i++){
+            MysqlStoredToken mysqlStoredToken = mysqlStoredTokens.get(i);
+            Token token = JSON.parseObject(mysqlStoredToken.getToken_value(), Token.class);
+            tokens.put(mysqlStoredToken.getToken_key(),token);
+        }
+        return tokens;
+    }
+
+    /**
+     * 更新token信息
+     * @param token
+     * **/
+    public void updateToken(String key, Token token){
+        UPDATE_TOKEN_INFO = UPDATE_TOKEN_INFO.replaceFirst("[?]", "\'" + JSON.toJSONString(token) + "\'");
+        UPDATE_TOKEN_INFO = UPDATE_TOKEN_INFO.replaceFirst("[?]", "\'" + key + "\'");
+        jdbcTemplate.execute(UPDATE_TOKEN_INFO);
+    }
+
+    /**
+     * 删除token信息
+     * **/
+    public void deleteToken(){
+        jdbcTemplate.execute(DELETE_TOKEN_ALL);
+    }
+
+    /**
+     * 获取数据源
+     * @return Datasource
+     * **/
+    public DataSource getDataSource(){
+        DriverManagerDataSource dataSource = null;
+        Properties properties = new Properties();
+
+        try{
+            //加载配置信息
+            properties.load(this.getClass().getClassLoader().getResourceAsStream("application.properties"));
+            String driverClassName = properties.getProperty("spring.datasource.driver-class-name");
+            String url = properties.getProperty("spring.datasource.url");
+            String username = properties.getProperty("spring.datasource.username");
+            String password = properties.getProperty("spring.datasource.password");
+
+            //设置数据源
+            dataSource = new DriverManagerDataSource();
+            dataSource.setDriverClassName(driverClassName);
+            dataSource.setUrl(url);
+            dataSource.setUsername(username);
+            dataSource.setPassword(password);
+        }catch (Exception e){
+            logger.error("an error occurred while getting the data source,errMsg:{}", e.getMessage());
+            e.printStackTrace();
+        }
+        return dataSource;
+    }
+
+//    public static void main(String[] args) {
+//        Map<String, Token> tokens = new MysqlTokenStore().getToken();
+//        Token token = tokens.get("system");
+//        token.setTtl(22222L);
+//
+//        new MysqlTokenStore().updateToken("system", token);
+//    }
+}

+ 130 - 0
huimv-farm-video/src/main/java/com/huimv/video/dhicc/test/token/RedisTokenStore.java

@@ -0,0 +1,130 @@
+package com.huimv.video.dhicc.test.token;
+
+import com.alibaba.fastjson.JSON;
+import org.springframework.data.redis.core.RedisTemplate;
+import org.springframework.util.CollectionUtils;
+
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
+
+//import org.springframework.data.redis.connection.RedisStandaloneConfiguration;
+
+/**
+ * token存储方式为Redis
+ * TODO: JDK版本需jdk7及以上,springboot版本需在2.0.0及以上
+ */
+public class RedisTokenStore implements TokenStore {
+
+    private RedisTemplate<String, String> redisTemplate;
+    public static final String hashKey = "key_scene:token_hash_key";
+    public static final Object lock = new Object();
+
+    public RedisTokenStore(){}
+
+//    public RedisTemplate getRedisTemplate(){
+//        if(redisTemplate == null){
+//            synchronized (lock){
+//                if(redisTemplate == null){
+//                    redisTemplate = new RedisTemplate();
+//                    JedisConnectionFactory fac = new JedisConnectionFactory(getRedisStandaloneConfiguration());
+//                    fac.afterPropertiesSet();
+//
+//                    redisTemplate.setConnectionFactory(fac);
+//                    redisTemplate.afterPropertiesSet();
+//                    RedisSerializer stringSerializer = new StringRedisSerializer();
+//                    redisTemplate.setKeySerializer(stringSerializer);
+//                    redisTemplate.setValueSerializer(stringSerializer);
+//                    redisTemplate.setHashKeySerializer(stringSerializer);
+//                    redisTemplate.setHashValueSerializer(stringSerializer);
+//                }
+//            }
+//        }
+//        return redisTemplate;
+//    }
+    /**
+     * 存储token
+     * @param:key 键
+     * @param:token 值
+     * **/
+    public void tokenStore(String key, Token token){
+        redisTemplate.opsForHash().put(hashKey, key, JSON.toJSONString(token));
+    }
+
+    /**
+     * 获取token
+     * @return Map<String, String>
+     * **/
+    @Override
+    public Map<String, Token> getToken(){
+        Map tokenFromRedis = redisTemplate.opsForHash().entries(hashKey);
+        Map<String, Token> tokens = new HashMap<String, Token>();
+        if(!CollectionUtils.isEmpty(tokenFromRedis)){
+            Set set = tokenFromRedis.entrySet();
+            Iterator iterator = set.iterator();
+            while(iterator.hasNext()){
+                Map.Entry<String, String> entry = (Map.Entry<String, String>)iterator.next();
+                tokens.put(entry.getKey(), JSON.parseObject(entry.getValue(), Token.class));
+            }
+        }
+        return tokens;
+    }
+
+    /**
+     * 更新token
+     * @param key
+     * @param token
+     * **/
+    public void updateToken(String key, Token token){
+        tokenStore(key, token);
+    }
+
+    /**
+     * 清空token
+     * **/
+    public void clearToken(){
+        redisTemplate.delete(hashKey);
+    }
+
+    /**
+     * 加载配置信息
+     * **/
+//    public RedisStandaloneConfiguration getRedisStandaloneConfiguration(){
+//        RedisStandaloneConfiguration redisStandaloneConfiguration = new RedisStandaloneConfiguration();
+//        Properties properties = new Properties();
+//        try{
+//            //加载配置信息
+//            properties.load(this.getClass().getClassLoader().getResourceAsStream("application.properties"));
+//            String host = properties.getProperty("spring.redis.host");
+//            String port = properties.getProperty("spring.redis.port");
+//            String password = properties.getProperty("spring.redis.password");
+//            //设置数据源
+//            redisStandaloneConfiguration.setHostName(host);
+//            redisStandaloneConfiguration.setPort(Integer.parseInt(port));
+//            //redisStandaloneConfiguration.setPassword(password);
+//        }catch (IOException e){
+//            e.printStackTrace();
+//        }
+//
+//        return redisStandaloneConfiguration;
+//    }
+
+//    public static void main(String[] args) {
+//        String key = "000adc8888888";
+//        Token token = JSON.parseObject("{\n" +
+//                "    \"access_token\": \"1:186fc877-6ab6-43d5-8d49-6311c47968a5\",\n" +
+//                "    \"token_type\": \"password\",\n" +
+//                "    \"refresh_token\": \"1:186fc877-6ab6-43d5-8d49-6311c47968a5\",\n" +
+//                "    \"expires_in\": 121221,\n" +
+//                "    \"scope\": \"all\",\n" +
+//                "    \"userId\": \"0\",\n" +
+//                "    \"magicId\": \"10.35.239.100\",\n" +
+//                "    \"remainderDays\": 999,\n" +
+//                "    \"ttl\": 58880\n" +
+//                "}", Token.class);
+//        new RedisTokenStore().updateToken(key, token);
+//        //new RedisTokenStore().clearToken();
+//
+//    }
+}

+ 30 - 0
huimv-farm-video/src/main/java/com/huimv/video/dhicc/test/token/Token.java

@@ -0,0 +1,30 @@
+package com.huimv.video.dhicc.test.token;
+
+import lombok.Data;
+import lombok.ToString;
+
+/**
+ * 令牌对象
+ */
+@Data
+@ToString
+public class Token {
+    //token
+    private String access_token;
+    //token类型
+    private String token_type;
+    //refresh_token
+    private String refresh_token;
+    //还剩多少时间就过期
+    private Long expires_in;
+    //令牌权限范围
+    private String scope;
+    //用户id
+    private String userId;
+    //magicId
+    private String magicId;
+    //remainDays
+    private Long remainderDays;
+    //令牌过期时间,当前时间+剩余过期时间expires_in
+    private Long ttl;
+}

+ 16 - 0
huimv-farm-video/src/main/java/com/huimv/video/dhicc/test/token/TokenStore.java

@@ -0,0 +1,16 @@
+package com.huimv.video.dhicc.test.token;
+
+/**
+ * token存储方式
+ */
+public interface TokenStore {
+    /**
+     * token的存储方式,用户可通过实现该方法来自定义存储方式,如存储到redis、Msql、Map缓存等
+     * **/
+    public void tokenStore(String key, Token token);
+
+    /**
+     * 获取token
+     * **/
+    public Object getToken();
+}

+ 35 - 0
huimv-farm-video/src/main/java/com/huimv/video/dhicc/test/user/UserPasswordConfigInfoTest01.java

@@ -0,0 +1,35 @@
+package com.huimv.video.dhicc.test.user;
+
+
+import com.huimv.video.dhicc.test.config.OauthConfigBaseInfo;
+import com.huimv.video.dhicc.test.config.OauthConfigUserPwdInfoTest01;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+/**
+ * 用户名密码模式全局配置类,测试时需改为自己的配置信息,可在此进行修改
+ */
+@Configuration
+public class UserPasswordConfigInfoTest01 {
+    //主机地址 默认是联调环境
+    private static String host = "36.26.62.70";
+    //用户名
+    private static String username = "system";
+    //密码
+    private static String password = "admin123.";
+    //客户端id
+    private static String clientId = "huimv";
+    //客户端秘钥
+    private static String clientSecret = "1653d6c9-c611-4827-ac87-0bfd48deadd4";
+    //https端口
+    private static String https = "447";//https 默认端口443,做了内外网映射 9021
+    //http端口
+    private static String http = "83";//http http调试模式端口默认是83,未作外网映射,此环境不支持83端口调试
+    //http请求协议 是否开启http调试模式,开启需登录运维中心 系统管理-》安全设置-》调试模式 开启;开启后端口是固定83端口
+    private static boolean isEnableHttpTest = false;
+
+    @Bean
+    public OauthConfigBaseInfo getOauthConfigBaseInfoInstance01(){
+        return new OauthConfigUserPwdInfoTest01(host,clientId,clientSecret,username,password,isEnableHttpTest,https,http);
+    }
+}

+ 35 - 0
huimv-farm-video/src/main/java/com/huimv/video/dhicc/test/user/UserPasswordConfigInfoTest02.java

@@ -0,0 +1,35 @@
+package com.huimv.video.dhicc.test.user;
+
+
+import com.huimv.video.dhicc.test.config.OauthConfigBaseInfo02;
+import com.huimv.video.dhicc.test.config.OauthConfigUserPwdInfoTest02;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+/**
+ * 用户名密码模式全局配置类,测试时需改为自己的配置信息,可在此进行修改
+ */
+@Configuration
+public class UserPasswordConfigInfoTest02 {
+    //主机地址 默认是联调环境
+    private static String host = "122.225.64.254";
+    //用户名
+    private static String username = "system";
+    //密码
+    private static String password = "Admin123";
+    //客户端id
+    private static String clientId = "huimv";
+    //客户端秘钥
+    private static String clientSecret = "b67ca816-eab5-4879-b2ba-d205af9f8f34";
+    //https端口
+    private static String https = "447";//https 默认端口443,做了内外网映射 9021
+    //http端口
+    private static String http = "83";//http http调试模式端口默认是83,未作外网映射,此环境不支持83端口调试
+    //http请求协议 是否开启http调试模式,开启需登录运维中心 系统管理-》安全设置-》调试模式 开启;开启后端口是固定83端口
+    private static boolean isEnableHttpTest = false;
+
+    @Bean
+    public OauthConfigBaseInfo02 getOauthConfigBaseInfoInstance02(){
+        return new OauthConfigUserPwdInfoTest02(host,clientId,clientSecret,username,password,isEnableHttpTest,https,http);
+    }
+}

+ 66 - 0
huimv-farm-video/src/main/java/com/huimv/video/dhicc/test/utils/HttpConfigInfo.java

@@ -0,0 +1,66 @@
+package com.huimv.video.dhicc.test.utils;
+
+public class HttpConfigInfo {
+
+    /** 平台服务IP或域名 */
+    protected String host;
+    /** 配置config */
+    protected boolean isEnableHttpTest = false;
+    /**https访问端口 默认443*/
+    protected String httpsPort = "443";
+    /**http访问端口 默认83,前提运维平台需要开启http调试模式*/
+    protected String httpPort = "83";
+
+    public HttpConfigInfo(String host, boolean isEnableHttpTest, String httpsPort, String httpPort){
+        this(host);
+        this.isEnableHttpTest = isEnableHttpTest;
+        this.httpsPort = httpsPort == null?"443":httpsPort;
+        this.httpPort = httpPort == null?"83":httpPort;
+    }
+
+    public HttpConfigInfo(String host){
+        this.host = host;
+    }
+
+    public HttpConfigInfo(){}
+
+    public boolean isEnableHttpTest() {
+        return isEnableHttpTest;
+    }
+
+    public void setEnableHttpTest(boolean enableHttpTest) {
+        isEnableHttpTest = enableHttpTest;
+    }
+
+    public String getHttpsPort() {
+        return httpsPort;
+    }
+
+    public void setHttpsPort(String httpsPort) {
+        this.httpsPort = httpsPort;
+    }
+
+    public String getHttpPort() {
+        return httpPort;
+    }
+
+    public void setHttpPort(String httpPort) {
+        this.httpPort = httpPort;
+    }
+
+    public String getHost() {
+        return host;
+    }
+
+    public void setHost(String host) {
+        this.host = host;
+    }
+
+    public String getPrefixUrl(){
+        if(!isEnableHttpTest){
+            return "https://" + host + ":" + httpsPort;
+        }else{
+            return "http://" + host + ":" + httpPort;
+        }
+    }
+}

+ 337 - 0
huimv-farm-video/src/main/java/com/huimv/video/dhicc/test/utils/HttpURLConnectionUtil.java

@@ -0,0 +1,337 @@
+package com.huimv.video.dhicc.test.utils;
+
+import com.alibaba.fastjson.JSONObject;
+import com.huimv.video.dhicc.test.constant.Constant;
+import com.huimv.video.dhicc.test.request.BaseRequest;
+import com.huimv.video.dhicc.test.request.BaseRequest02;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.util.CollectionUtils;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.io.OutputStream;
+import java.net.HttpURLConnection;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
+
+
+/**
+ * Http请求类,基于JDK自带的HttpURLConnectionUtil请求类
+ */
+public class HttpURLConnectionUtil {
+    private static Logger logger = LoggerFactory.getLogger(HttpURLConnectionUtil.class);
+
+    /**
+     * @param request 请求对象
+     * @return String json字符串格式的响应数据
+     * **/
+    public static String doGet(BaseRequest request){
+        String httpUrl = request.getUrl();
+        Map<String, String> headers = request.getHeader();
+        logger.info("HttpURLConnectionUtil,doGet,URL:{}, headers:{}", httpUrl, headers);
+        StringBuilder response = new StringBuilder();
+        BufferedReader bufferedReader = null;
+
+        try{
+            //创建连接
+            URL url = new URL(httpUrl);
+            HttpURLConnection connection = (HttpURLConnection)url.openConnection();
+
+            //设置请求方式
+            connection.setRequestMethod(Constant.HTTP_GET);
+            connection.setRequestProperty("accept", "*/*");
+            connection.setRequestProperty("connection", "Keep-Alive");
+            connection.setRequestProperty("content-type", "application/x-www-form-urlencoded;charset=UTF-8");
+            //设置自定义请求头信息
+            setCustomHeader(connection, headers);
+
+            //设置请求超时时间:10秒
+            connection.setConnectTimeout(10 * 1000);
+            //设置读取超时时间:10秒
+            connection.setReadTimeout(10 * 1000);
+            //开始连接
+            connection.connect();
+            if(connection.getResponseCode() == 404){
+                JSONObject result = new JSONObject();
+                result.put("code","404");
+                result.put("errMsg","子系统未安装或接口与版本不匹配");
+                return result.toJSONString();
+            }
+            //获取响应数据
+            String readLine = null;
+            bufferedReader = new BufferedReader(new InputStreamReader(connection.getInputStream(), "utf-8"));
+            while((readLine = bufferedReader.readLine()) != null){
+                response.append(readLine);
+            }
+            bufferedReader.close();
+        }catch (MalformedURLException e){
+            logger.error("HttpURLConnectionUtil,doGet,request error:{}", e.getMessage());
+            e.printStackTrace();
+        }catch (IOException e){
+            logger.error("HttpURLConnectionUtil,doGet,request error:{}", e.getMessage());
+            e.printStackTrace();
+        }
+        return response.toString();
+    }
+
+
+    public static String doGet02(BaseRequest02 request){
+        String httpUrl = request.getUrl();
+        Map<String, String> headers = request.getHeader();
+        logger.info("HttpURLConnectionUtil,doGet,URL:{}, headers:{}", httpUrl, headers);
+        StringBuilder response = new StringBuilder();
+        BufferedReader bufferedReader = null;
+
+        try{
+            //创建连接
+            URL url = new URL(httpUrl);
+            HttpURLConnection connection = (HttpURLConnection)url.openConnection();
+
+            //设置请求方式
+            connection.setRequestMethod(Constant.HTTP_GET);
+            connection.setRequestProperty("accept", "*/*");
+            connection.setRequestProperty("connection", "Keep-Alive");
+            connection.setRequestProperty("content-type", "application/x-www-form-urlencoded;charset=UTF-8");
+            //设置自定义请求头信息
+            setCustomHeader(connection, headers);
+
+            //设置请求超时时间:10秒
+            connection.setConnectTimeout(10 * 1000);
+            //设置读取超时时间:10秒
+            connection.setReadTimeout(10 * 1000);
+            //开始连接
+            connection.connect();
+            if(connection.getResponseCode() == 404){
+                JSONObject result = new JSONObject();
+                result.put("code","404");
+                result.put("errMsg","子系统未安装或接口与版本不匹配");
+                return result.toJSONString();
+            }
+            //获取响应数据
+            String readLine = null;
+            bufferedReader = new BufferedReader(new InputStreamReader(connection.getInputStream(), "utf-8"));
+            while((readLine = bufferedReader.readLine()) != null){
+                response.append(readLine);
+            }
+            bufferedReader.close();
+        }catch (MalformedURLException e){
+            logger.error("HttpURLConnectionUtil,doGet,request error:{}", e.getMessage());
+            e.printStackTrace();
+        }catch (IOException e){
+            logger.error("HttpURLConnectionUtil,doGet,request error:{}", e.getMessage());
+            e.printStackTrace();
+        }
+        return response.toString();
+    }
+
+
+    /**
+     * @param httpUrl 请求地址
+     * @param jsonStr json字符串格式的请求数据
+     * @return String json字符串格式的响应数据
+     * **/
+    public static String doPost(String httpUrl, String jsonStr, Map<String, String> headers){
+        logger.info("HttpURLConnectionUtil,doPost,URL:" + httpUrl);
+        StringBuilder response = new StringBuilder();
+        BufferedReader bufferedReader = null;
+
+        try{
+            //创建连接
+            URL url = new URL(httpUrl);
+            HttpURLConnection connection = (HttpURLConnection)url.openConnection();
+
+            //设置请求方式
+            connection.setRequestMethod(Constant.HTTP_POST);
+            connection.setRequestProperty("accept", "application/json");
+            connection.setRequestProperty("connection", "Keep-Alive");
+            connection.setRequestProperty("content-type", "application/json;charset=UTF-8");
+            //设置自定义请求头信息
+            setCustomHeader(connection, headers);
+
+            connection.setDoOutput(true);
+            connection.setDoInput(true);
+            //设置请求超时时间:10秒
+            connection.setConnectTimeout(10 * 1000);
+            //设置读取超时时间:10秒
+            connection.setReadTimeout(10 * 1000);
+            //设置请求参数
+            if(jsonStr != null && !"".equalsIgnoreCase(jsonStr)){
+                OutputStream outputStream = connection.getOutputStream();
+                byte[] input = jsonStr.getBytes("utf-8");
+                outputStream.write(input, 0, input.length);
+                outputStream.flush();
+                outputStream.close();
+            }
+            connection.connect();
+            if(connection.getResponseCode() == 404){
+                JSONObject result = new JSONObject();
+                result.put("code","404");
+                result.put("errMsg","子系统未安装或接口与版本不匹配");
+                return result.toJSONString();
+            }
+            //获取响应数据
+            String readLine = null;
+            bufferedReader = new BufferedReader(new InputStreamReader(connection.getInputStream(), "utf-8"));
+            while((readLine = bufferedReader.readLine()) != null){
+                response.append(readLine);
+            }
+            bufferedReader.close();
+        }catch (MalformedURLException e){
+            logger.error("HttpURLConnectionUtil,doPost,request error:{}", e.getMessage());
+            e.printStackTrace();
+        }catch (IOException e){
+            logger.error("HttpURLConnectionUtil,doPost,request error:{}", e.getMessage());
+            e.printStackTrace();
+        }
+
+        return response.toString();
+    }
+
+
+
+
+    /**
+     * @param httpUrl 请求地址
+     * @param jsonStr json字符串格式的请求数据
+     * @return String json字符串格式的响应数据
+     * **/
+    public static String doPut(String httpUrl, String jsonStr, Map<String, String> headers){
+        logger.info("HttpURLConnectionUtil,doPut,URL:" + httpUrl);
+        StringBuilder response = new StringBuilder();
+        BufferedReader bufferedReader = null;
+
+        try{
+            //创建连接
+            URL url = new URL(httpUrl);
+            HttpURLConnection connection = (HttpURLConnection)url.openConnection();
+
+            //设置请求方式
+            connection.setRequestMethod(Constant.HTTP_PUT);
+            connection.setRequestProperty("accept", "application/json");
+            connection.setRequestProperty("connection", "Keep-Alive");
+            connection.setRequestProperty("content-type", "application/json;charset=UTF-8");
+            //设置自定义请求头信息
+            setCustomHeader(connection, headers);
+
+            connection.setDoOutput(true);
+            connection.setDoInput(true);
+            //设置请求超时时间:10秒
+            connection.setConnectTimeout(10 * 1000);
+            //设置读取超时时间:10秒
+            connection.setReadTimeout(10 * 1000);
+            //设置请求参数
+            if(jsonStr != null && !"".equalsIgnoreCase(jsonStr)){
+                OutputStream outputStream = connection.getOutputStream();
+                byte[] input = jsonStr.getBytes("utf-8");
+                outputStream.write(input, 0, input.length);
+                outputStream.flush();
+                outputStream.close();
+            }
+            connection.connect();
+            if(connection.getResponseCode() == 404){
+                JSONObject result = new JSONObject();
+                result.put("code","404");
+                result.put("errMsg","子系统未安装或接口与版本不匹配");
+                return result.toJSONString();
+            }
+            //获取响应数据
+            String readLine = null;
+            bufferedReader = new BufferedReader(new InputStreamReader(connection.getInputStream(), "utf-8"));
+            while((readLine = bufferedReader.readLine()) != null){
+                response.append(readLine);
+            }
+            bufferedReader.close();
+        }catch (MalformedURLException e){
+            logger.error("HttpURLConnectionUtil,doPut,request error:{}", e.getMessage());
+            e.printStackTrace();
+        }catch (IOException e){
+            logger.error("HttpURLConnectionUtil,doPut,request error:{}", e.getMessage());
+            e.printStackTrace();
+        }
+
+        return response.toString();
+    }
+
+    /**
+     * @param httpUrl 请求地址
+     * @param jsonStr json字符串格式的请求数据
+     * @return String json字符串格式的响应数据
+     * **/
+    public static String doDelete(String httpUrl, String jsonStr, Map<String, String> headers){
+        logger.info("HttpURLConnectionUtil,doDelete,URL:" + httpUrl);
+        StringBuilder response = new StringBuilder();
+        BufferedReader bufferedReader = null;
+
+        try{
+            //创建连接
+            URL url = new URL(httpUrl);
+            HttpURLConnection connection = (HttpURLConnection)url.openConnection();
+
+            //设置请求方式
+            connection.setRequestMethod(Constant.HTTP_DELETE);
+            connection.setRequestProperty("accept", "application/json");
+            connection.setRequestProperty("connection", "Keep-Alive");
+            connection.setRequestProperty("content-type", "application/json;charset=UTF-8");
+            //设置自定义请求头信息
+            setCustomHeader(connection, headers);
+
+            connection.setDoOutput(true);
+            connection.setDoInput(true);
+            //设置请求超时时间:10秒
+            connection.setConnectTimeout(10 * 1000);
+            //设置读取超时时间:10秒
+            connection.setReadTimeout(10 * 1000);
+            //设置请求参数
+            if(jsonStr != null && !"".equalsIgnoreCase(jsonStr)){
+                OutputStream outputStream = connection.getOutputStream();
+                byte[] input = jsonStr.getBytes("utf-8");
+                outputStream.write(input, 0, input.length);
+                outputStream.flush();
+                outputStream.close();
+            }
+            connection.connect();
+            if(connection.getResponseCode() == 404){
+                JSONObject result = new JSONObject();
+                result.put("code","404");
+                result.put("errMsg","子系统未安装或接口与版本不匹配");
+                return result.toJSONString();
+            }
+            //获取响应数据
+            String readLine = null;
+            bufferedReader = new BufferedReader(new InputStreamReader(connection.getInputStream(), "utf-8"));
+            while((readLine = bufferedReader.readLine()) != null){
+                response.append(readLine);
+            }
+            bufferedReader.close();
+        }catch (MalformedURLException e){
+            logger.error("HttpURLConnectionUtil,doDelete,request error:{}", e.getMessage());
+            e.printStackTrace();
+        }catch (IOException e){
+            logger.error("HttpURLConnectionUtil,doDelete,request error:{}", e.getMessage());
+            e.printStackTrace();
+        }
+
+        return response.toString();
+    }
+
+    /**
+     * 设置自定义请求头信息
+     * **/
+    public static void setCustomHeader(HttpURLConnection connection, Map<String, String> headers){
+        if(!CollectionUtils.isEmpty(headers)){
+            Set set = headers.entrySet();
+            Iterator iterator = set.iterator();
+            while(iterator.hasNext()){
+                Map.Entry<String, String> entry = (Map.Entry<String, String>)iterator.next();
+                String key = entry.getKey();
+                String value = entry.getValue();
+                connection.setRequestProperty(key, value);
+            }
+        }
+    }
+}

+ 381 - 0
huimv-farm-video/src/main/java/com/huimv/video/dhicc/test/utils/HttpsURLConnectionUtil.java

@@ -0,0 +1,381 @@
+package com.huimv.video.dhicc.test.utils;
+
+import com.alibaba.fastjson.JSONObject;
+import com.huimv.video.dhicc.test.constant.Constant;
+import com.huimv.video.dhicc.test.request.BaseRequest;
+import com.huimv.video.dhicc.test.request.BaseRequest02;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.util.CollectionUtils;
+
+import javax.net.ssl.*;
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.io.OutputStream;
+import java.net.HttpURLConnection;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.security.KeyManagementException;
+import java.security.NoSuchAlgorithmException;
+import java.security.cert.CertificateException;
+import java.security.cert.X509Certificate;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
+
+
+/**
+ * Http请求类,基于JDK自带的HttpURLConnectionUtil请求类
+ */
+public class HttpsURLConnectionUtil {
+    private static Logger logger = LoggerFactory.getLogger(HttpsURLConnectionUtil.class);
+
+    static {
+        try {
+            trustAllHttpsCertificates();
+            HttpsURLConnection.setDefaultHostnameVerifier(new HostnameVerifier() {
+                public boolean verify(String urlHostName, SSLSession session) {
+                    return true;
+                }
+            });
+        } catch (Exception e) {
+        }
+    }
+
+    private static void trustAllHttpsCertificates() throws NoSuchAlgorithmException, KeyManagementException {
+        TrustManager[] trustAllCerts = new TrustManager[1];
+        trustAllCerts[0] = new TrustAllManager();
+        /** JDK1.7是TLS1.0,而JDK1.8是TLSv1.2,要调用ICC框架版本是JDK8,因此这里设置为TLSv1.2 **/
+        SSLContext sc = SSLContext.getInstance("TLSv1.2");
+        sc.init(null, trustAllCerts, null);
+        HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory());
+    }
+
+    private static class TrustAllManager implements X509TrustManager {
+
+        public X509Certificate[] getAcceptedIssuers() {
+            return null;
+        }
+
+        public void checkServerTrusted(X509Certificate[] certs, String authType) throws CertificateException {
+        }
+
+        public void checkClientTrusted(X509Certificate[] certs, String authType) throws CertificateException {
+        }
+    }
+
+
+    /**
+     * @param request 请求对象
+     * @return String json字符串格式的响应数据
+     * **/
+    public static String doGet(BaseRequest request){
+        String httpUrl = request.getUrl();
+        Map<String, String> headers = request.getHeader();
+        logger.info("HttpsURLConnectionUtil,doGet,URL:{}, headers:{}", httpUrl, headers);
+        StringBuilder response = new StringBuilder();
+        BufferedReader bufferedReader = null;
+
+        try{
+            //创建连接
+            URL url = new URL(httpUrl);
+            HttpsURLConnection connection = (HttpsURLConnection)url.openConnection();
+            //忽略ssl验证
+            //disableSslVerification(connection);
+            //设置请求方式
+            connection.setRequestMethod(Constant.HTTP_GET);
+            connection.setRequestProperty("accept", "*/*");
+            connection.setRequestProperty("connection", "Keep-Alive");
+            connection.setRequestProperty("content-type", "application/x-www-form-urlencoded;charset=UTF-8");
+            //设置自定义请求头信息
+            setCustomHeader(connection, headers);
+
+            //设置请求超时时间:10秒
+            connection.setConnectTimeout(10 * 1000);
+            //设置读取超时时间:10秒
+            connection.setReadTimeout(10 * 1000);
+            //开始连接
+            connection.connect();
+            if(connection.getResponseCode() == 404){
+                JSONObject result = new JSONObject();
+                result.put("code","404");
+                result.put("errMsg","子系统未安装或接口与版本不匹配");
+                return result.toJSONString();
+            }
+            //获取响应数据
+            String readLine = null;
+            bufferedReader = new BufferedReader(new InputStreamReader(connection.getInputStream(), "utf-8"));
+            while((readLine = bufferedReader.readLine()) != null){
+                response.append(readLine);
+            }
+            bufferedReader.close();
+        }catch (MalformedURLException e){
+            logger.error("HttpsURLConnectionUtil,doGet,request error:{}", e.getMessage());
+            e.printStackTrace();
+        }catch (IOException e){
+            logger.error("HttpsURLConnectionUtil,doGet,request error:{}", e.getMessage());
+            e.printStackTrace();
+        }
+        return response.toString();
+    }
+
+    public static String doGet02(BaseRequest02 request){
+        String httpUrl = request.getUrl();
+        Map<String, String> headers = request.getHeader();
+        logger.info("HttpsURLConnectionUtil,doGet,URL:{}, headers:{}", httpUrl, headers);
+        StringBuilder response = new StringBuilder();
+        BufferedReader bufferedReader = null;
+
+        try{
+            //创建连接
+            URL url = new URL(httpUrl);
+            HttpsURLConnection connection = (HttpsURLConnection)url.openConnection();
+            //忽略ssl验证
+            //disableSslVerification(connection);
+            //设置请求方式
+            connection.setRequestMethod(Constant.HTTP_GET);
+            connection.setRequestProperty("accept", "*/*");
+            connection.setRequestProperty("connection", "Keep-Alive");
+            connection.setRequestProperty("content-type", "application/x-www-form-urlencoded;charset=UTF-8");
+            //设置自定义请求头信息
+            setCustomHeader(connection, headers);
+
+            //设置请求超时时间:10秒
+            connection.setConnectTimeout(10 * 1000);
+            //设置读取超时时间:10秒
+            connection.setReadTimeout(10 * 1000);
+            //开始连接
+            connection.connect();
+            if(connection.getResponseCode() == 404){
+                JSONObject result = new JSONObject();
+                result.put("code","404");
+                result.put("errMsg","子系统未安装或接口与版本不匹配");
+                return result.toJSONString();
+            }
+            //获取响应数据
+            String readLine = null;
+            bufferedReader = new BufferedReader(new InputStreamReader(connection.getInputStream(), "utf-8"));
+            while((readLine = bufferedReader.readLine()) != null){
+                response.append(readLine);
+            }
+            bufferedReader.close();
+        }catch (MalformedURLException e){
+            logger.error("HttpsURLConnectionUtil,doGet,request error:{}", e.getMessage());
+            e.printStackTrace();
+        }catch (IOException e){
+            logger.error("HttpsURLConnectionUtil,doGet,request error:{}", e.getMessage());
+            e.printStackTrace();
+        }
+        return response.toString();
+    }
+
+
+    /**
+     * @param httpUrl 请求地址
+     * @param jsonStr json字符串格式的请求数据
+     * @return String json字符串格式的响应数据
+     * **/
+    public static String doPost(String httpUrl, String jsonStr, Map<String, String> headers){
+        logger.info("HttpsURLConnectionUtil,doPost,URL:" + httpUrl);
+        StringBuilder response = new StringBuilder();
+        BufferedReader bufferedReader = null;
+
+        try{
+            //创建连接
+            URL url = new URL(httpUrl);
+            HttpsURLConnection connection = (HttpsURLConnection)url.openConnection();
+            //忽略ssl验证
+            //disableSslVerification(connection);
+
+            //设置请求方式
+            connection.setRequestMethod(Constant.HTTP_POST);
+            connection.setRequestProperty("accept", "application/json");
+            connection.setRequestProperty("connection", "Keep-Alive");
+            connection.setRequestProperty("content-type", "application/json;charset=UTF-8");
+            //设置自定义请求头信息
+            setCustomHeader(connection, headers);
+
+            connection.setDoOutput(true);
+            connection.setDoInput(true);
+            //设置请求超时时间:10秒
+            connection.setConnectTimeout(10 * 1000);
+            //设置读取超时时间:10秒
+            connection.setReadTimeout(10 * 1000);
+            //设置请求参数
+            if(jsonStr != null && !"".equalsIgnoreCase(jsonStr)){
+                OutputStream outputStream = connection.getOutputStream();
+                byte[] input = jsonStr.getBytes("utf-8");
+                outputStream.write(input, 0, input.length);
+                outputStream.flush();
+                outputStream.close();
+            }
+            connection.connect();
+            if(connection.getResponseCode() == 404){
+                JSONObject result = new JSONObject();
+                result.put("code","404");
+                result.put("errMsg","子系统未安装或接口与版本不匹配");
+                return result.toJSONString();
+            }
+            //获取响应数据
+            String readLine = null;
+            bufferedReader = new BufferedReader(new InputStreamReader(connection.getInputStream(), "utf-8"));
+            while((readLine = bufferedReader.readLine()) != null){
+                response.append(readLine);
+            }
+            bufferedReader.close();
+        }catch (MalformedURLException e){
+            logger.error("HttpsURLConnectionUtil,doPost,request error:{}", e.getMessage());
+            e.printStackTrace();
+        }catch (IOException e){
+            logger.error("HttpsURLConnectionUtil,doPost,request error:{}", e.getMessage());
+            e.printStackTrace();
+        }
+
+        return response.toString();
+    }
+
+    /**
+     * @param httpUrl 请求地址
+     * @param jsonStr json字符串格式的请求数据
+     * @return String json字符串格式的响应数据
+     * **/
+    public static String doPut(String httpUrl, String jsonStr, Map<String, String> headers){
+        logger.info("HttpsURLConnectionUtil,doPut,URL:" + httpUrl);
+        StringBuilder response = new StringBuilder();
+        BufferedReader bufferedReader = null;
+
+        try{
+            //创建连接
+            URL url = new URL(httpUrl);
+            HttpsURLConnection connection = (HttpsURLConnection)url.openConnection();
+            //忽略ssl验证
+            //disableSslVerification(connection);
+
+            //设置请求方式
+            connection.setRequestMethod(Constant.HTTP_PUT);
+            connection.setRequestProperty("accept", "application/json");
+            connection.setRequestProperty("connection", "Keep-Alive");
+            connection.setRequestProperty("content-type", "application/json;charset=UTF-8");
+            //设置自定义请求头信息
+            setCustomHeader(connection, headers);
+
+            connection.setDoOutput(true);
+            connection.setDoInput(true);
+            //设置请求超时时间:10秒
+            connection.setConnectTimeout(10 * 1000);
+            //设置读取超时时间:10秒
+            connection.setReadTimeout(10 * 1000);
+            //设置请求参数
+            if(jsonStr != null && !"".equalsIgnoreCase(jsonStr)){
+                OutputStream outputStream = connection.getOutputStream();
+                byte[] input = jsonStr.getBytes("utf-8");
+                outputStream.write(input, 0, input.length);
+                outputStream.flush();
+                outputStream.close();
+            }
+            connection.connect();
+            if(connection.getResponseCode() == 404){
+                JSONObject result = new JSONObject();
+                result.put("code","404");
+                result.put("errMsg","子系统未安装或接口与版本不匹配");
+                return result.toJSONString();
+            }
+            //获取响应数据
+            String readLine = null;
+            bufferedReader = new BufferedReader(new InputStreamReader(connection.getInputStream(), "utf-8"));
+            while((readLine = bufferedReader.readLine()) != null){
+                response.append(readLine);
+            }
+            bufferedReader.close();
+        }catch (MalformedURLException e){
+            logger.error("HttpsURLConnectionUtil,doPut,request error:{}", e.getMessage());
+            e.printStackTrace();
+        }catch (IOException e){
+            logger.error("HttpsURLConnectionUtil,doPut,request error:{}", e.getMessage());
+            e.printStackTrace();
+        }
+
+        return response.toString();
+    }
+
+    /**
+     * @param httpUrl 请求地址
+     * @param jsonStr json字符串格式的请求数据
+     * @return String json字符串格式的响应数据
+     * **/
+    public static String doDelete(String httpUrl, String jsonStr, Map<String, String> headers){
+        logger.info("HttpsURLConnectionUtil,doDelete,URL:" + httpUrl);
+        StringBuilder response = new StringBuilder();
+        BufferedReader bufferedReader = null;
+
+        try{
+            //创建连接
+            URL url = new URL(httpUrl);
+            HttpsURLConnection connection = (HttpsURLConnection)url.openConnection();
+            //忽略ssl验证
+            //disableSslVerification(connection);
+
+            //设置请求方式
+            connection.setRequestMethod(Constant.HTTP_DELETE);
+            connection.setRequestProperty("accept", "application/json");
+            connection.setRequestProperty("connection", "Keep-Alive");
+            connection.setRequestProperty("content-type", "application/json;charset=UTF-8");
+            //设置自定义请求头信息
+            setCustomHeader(connection, headers);
+
+            connection.setDoOutput(true);
+            connection.setDoInput(true);
+            //设置请求超时时间:10秒
+            connection.setConnectTimeout(10 * 1000);
+            //设置读取超时时间:10秒
+            connection.setReadTimeout(10 * 1000);
+            //设置请求参数
+            if(jsonStr != null && !"".equalsIgnoreCase(jsonStr)){
+                OutputStream outputStream = connection.getOutputStream();
+                byte[] input = jsonStr.getBytes("utf-8");
+                outputStream.write(input, 0, input.length);
+                outputStream.flush();
+                outputStream.close();
+            }
+            connection.connect();
+            if(connection.getResponseCode() == 404){
+                JSONObject result = new JSONObject();
+                result.put("code","404");
+                result.put("errMsg","子系统未安装或接口与版本不匹配");
+                return result.toJSONString();
+            }
+            //获取响应数据
+            String readLine = null;
+            bufferedReader = new BufferedReader(new InputStreamReader(connection.getInputStream(), "utf-8"));
+            while((readLine = bufferedReader.readLine()) != null){
+                response.append(readLine);
+            }
+            bufferedReader.close();
+        }catch (MalformedURLException e){
+            logger.error("HttpsURLConnectionUtil,doDelete,request error:{}", e.getMessage());
+            e.printStackTrace();
+        }catch (IOException e){
+            logger.error("HttpsURLConnectionUtil,doDelete,request error:{}", e.getMessage());
+            e.printStackTrace();
+        }
+
+        return response.toString();
+    }
+
+    /**
+     * 设置自定义请求头信息
+     * **/
+    public static void setCustomHeader(HttpURLConnection connection, Map<String, String> headers){
+        if(!CollectionUtils.isEmpty(headers)){
+            Set set = headers.entrySet();
+            Iterator iterator = set.iterator();
+            while(iterator.hasNext()){
+                Map.Entry<String, String> entry = (Map.Entry<String, String>)iterator.next();
+                String key = entry.getKey();
+                String value = entry.getValue();
+                connection.setRequestProperty(key, value);
+            }
+        }
+    }
+}

+ 18 - 0
huimv-farm-video/src/main/java/com/huimv/video/dhicc/test/utils/UrlUtil.java

@@ -0,0 +1,18 @@
+package com.huimv.video.dhicc.test.utils;
+
+/**
+url工具类
+ */
+public class UrlUtil {
+
+    public static String dealVersion(String url){
+        String sourceVersion = "{version}";
+        String targetVersion = "1.0.0";
+
+        if(url.contains(sourceVersion)){
+            url = url.replace(sourceVersion, targetVersion);
+        }
+
+        return url;
+    }
+}

+ 23 - 23
huimv-farm-video/src/main/resources/config/iccSdk.properties

@@ -1,32 +1,32 @@
+### host
+##icc.sdk.host=39.171.45.196:447
+### 客户端模式
+##icc.sdk.clientId=huimv
+##icc.sdk.clientSecret=6df1106c-d855-4861-a774-71bf8eea0d7d
+### 1653d6c9-c611-4827-ac87-0bfd48deadd4
+### 密码校验模式
+##icc.sdk.pwdClientId=huimv
+##icc.sdk.pwdClientSecret=6df1106c-d855-4861-a774-71bf8eea0d7d
+##icc.sdk.username=system
+##icc.sdk.password=hmkj6688
+### 使用授权类型password,client_credentials
+##icc.sdk.grantType=password
+#
+##青莲
 ## host
 ## host
-#icc.sdk.host=39.171.45.196:447
+#icc.sdk.host=36.26.62.70:447
 ## 客户端模式
 ## 客户端模式
 #icc.sdk.clientId=huimv
 #icc.sdk.clientId=huimv
-#icc.sdk.clientSecret=6df1106c-d855-4861-a774-71bf8eea0d7d
+#icc.sdk.clientSecret=1653d6c9-c611-4827-ac87-0bfd48deadd4
 ## 1653d6c9-c611-4827-ac87-0bfd48deadd4
 ## 1653d6c9-c611-4827-ac87-0bfd48deadd4
 ## 密码校验模式
 ## 密码校验模式
 #icc.sdk.pwdClientId=huimv
 #icc.sdk.pwdClientId=huimv
-#icc.sdk.pwdClientSecret=6df1106c-d855-4861-a774-71bf8eea0d7d
+#icc.sdk.pwdClientSecret=1653d6c9-c611-4827-ac87-0bfd48deadd4
+##icc.sdk.username=system
+##icc.sdk.password=hmkj6688
 #icc.sdk.username=system
 #icc.sdk.username=system
-#icc.sdk.password=hmkj6688
+#icc.sdk.password=admin123.
 ## 使用授权类型password,client_credentials
 ## 使用授权类型password,client_credentials
 #icc.sdk.grantType=password
 #icc.sdk.grantType=password
-
-#青莲
-# host
-icc.sdk.host=36.26.62.70:447
-# 客户端模式
-icc.sdk.clientId=huimv
-icc.sdk.clientSecret=1653d6c9-c611-4827-ac87-0bfd48deadd4
-# 1653d6c9-c611-4827-ac87-0bfd48deadd4
-# 密码校验模式
-icc.sdk.pwdClientId=huimv
-icc.sdk.pwdClientSecret=1653d6c9-c611-4827-ac87-0bfd48deadd4
-#icc.sdk.username=system
-#icc.sdk.password=hmkj6688
-icc.sdk.username=system
-icc.sdk.password=admin123.
-# 使用授权类型password,client_credentials
-icc.sdk.grantType=password
-
-#海宁
+#
+##海宁