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); + } + } } } }