From 28c78d45e99668af2398363cfe904b612193d945 Mon Sep 17 00:00:00 2001 From: lau572 <1010031226@qq.com> Date: Tue, 23 Apr 2024 11:05:30 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=86=E9=A2=91=E6=B5=81=E5=9C=B0=E5=9D=80?= =?UTF-8?q?=E3=80=81=E6=89=AB=E7=A0=81=E6=8A=A5=E8=AD=A6=E5=9C=B0=E5=9D=80?= =?UTF-8?q?=E5=8F=AF=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../business/controller/VideoController.java | 31 ++++++++++++++++--- 1 file changed, 26 insertions(+), 5 deletions(-) diff --git a/zc-business/src/main/java/com/zc/business/controller/VideoController.java b/zc-business/src/main/java/com/zc/business/controller/VideoController.java index dea3812d..3fb84c7c 100644 --- a/zc-business/src/main/java/com/zc/business/controller/VideoController.java +++ b/zc-business/src/main/java/com/zc/business/controller/VideoController.java @@ -4,9 +4,11 @@ import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.ruoyi.common.constant.HttpStatus; import com.ruoyi.common.core.controller.BaseController; import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.common.core.redis.RedisCache; +import com.ruoyi.system.service.ISysConfigService; import com.zc.business.constant.DeviceTypeConstants; import com.zc.business.domain.DcDevice; import com.zc.business.enums.CameraDirectionEnum; @@ -20,6 +22,7 @@ import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiParam; import okhttp3.Response; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.scheduling.annotation.Scheduled; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PatchMapping; @@ -33,6 +36,7 @@ import java.util.concurrent.TimeUnit; import java.util.stream.Collectors; import static com.ruoyi.common.constant.Constants.HTTP; +import static com.ruoyi.common.constant.Constants.HTTPS; import static java.util.Comparator.comparing; @@ -68,6 +72,8 @@ public class VideoController extends BaseController { @Resource private IMiddleDatabaseService middleDatabaseService; + @Autowired + private ISysConfigService configService; // 组织机构id private final static String CAM_DEPT_ID = "1301730"; @@ -483,11 +489,26 @@ public class VideoController extends BaseController { if (response.body() != null) { jsonResult = JSONObject.parseObject(response.body().string()); - if (jsonResult.containsKey("code") && UNAUTHORIZED.equals(jsonResult.getInteger("code"))) { - getToken(); - okHttp.post(); - if (response.body() != null) { - jsonResult = JSONObject.parseObject(response.body().string()); + if (jsonResult.containsKey("code")) { + if (HttpStatus.SUCCESS == jsonResult.getInteger("code")) { + Map data = jsonResult.getJSONObject("data"); + String liveUrl = data.get("liveUrl").toString(); + liveUrl = configService.selectConfigByKey("dc.cameraUrl") + liveUrl.substring(7); + data.put("liveUrl",liveUrl); + jsonResult.put("data",data); + } else if (UNAUTHORIZED.equals(jsonResult.getInteger("code"))) { + getToken(); + okHttp.post(); + if (response.body() != null) { + jsonResult = JSONObject.parseObject(response.body().string()); + if (HttpStatus.SUCCESS == jsonResult.getInteger("code")) { + Map data = jsonResult.getJSONObject("data"); + String liveUrl = data.get("liveUrl").toString(); + liveUrl = configService.selectConfigByKey("cameraUrl") + liveUrl.substring(7); + data.put("liveUrl",liveUrl); + jsonResult.put("data",data); + } + } } } }