zhousq
1 year ago
3 changed files with 107 additions and 17 deletions
@ -0,0 +1,86 @@ |
|||
package com.lzbi.bi.controller; |
|||
|
|||
import cn.hutool.Hutool; |
|||
import cn.hutool.core.util.StrUtil; |
|||
import cn.hutool.crypto.digest.MD5; |
|||
import cn.hutool.http.HttpRequest; |
|||
import cn.hutool.http.HttpResponse; |
|||
import cn.hutool.http.HttpUtil; |
|||
import com.alibaba.fastjson2.JSONObject; |
|||
import com.lzbi.common.core.controller.BaseController; |
|||
import com.lzbi.common.core.domain.AjaxResult; |
|||
import com.lzbi.common.utils.SecurityUtils; |
|||
import com.lzbi.common.utils.StringUtils; |
|||
import com.lzbi.common.utils.sign.Md5Utils; |
|||
import io.swagger.annotations.Api; |
|||
import io.swagger.annotations.ApiImplicitParam; |
|||
import io.swagger.annotations.ApiImplicitParams; |
|||
import io.swagger.annotations.ApiOperation; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.beans.factory.annotation.Value; |
|||
import org.springframework.data.redis.core.RedisTemplate; |
|||
import org.springframework.util.DigestUtils; |
|||
import org.springframework.web.bind.annotation.*; |
|||
|
|||
import java.util.Optional; |
|||
|
|||
/** |
|||
* @auth create by Administrator |
|||
* @date 2023/12/27 |
|||
* DCVedioScreenControler |
|||
*/ |
|||
@Api("视频监控大屏接口") |
|||
@RestController |
|||
@RequestMapping("/vedio") |
|||
public class DCVedioScreenControler extends BaseController { |
|||
@Autowired |
|||
RedisTemplate<String,String> redisTemplate; |
|||
@Value("${luenmeilz.vedioServer.url}") |
|||
String vedio_server_url; |
|||
//String md532Upper=md532Lower.toUpperCase();
|
|||
//16位,小写
|
|||
//String md516Lower =md532Lower.substring(8, 24);
|
|||
//16位,大写
|
|||
//String md516Upper=md532Lower.substring(8, 24).toUpperCase();
|
|||
@ApiOperation("根据用户对照信息并获取视频的用户登录token") |
|||
@GetMapping("/getToken") |
|||
public AjaxResult getToken2(){ |
|||
return AjaxResult.success(getToken()); |
|||
} |
|||
private String getToken(){ |
|||
String userName=SecurityUtils.getUsername(); |
|||
String token= redisTemplate.opsForValue().get("vedio:" + userName); |
|||
if(StringUtils.isNull(token)){//没有tokean需要重新获取
|
|||
String vedio_userName="easycvr" ;//SecurityUtils.getUsername();
|
|||
String vedio_password="lmlz@2019"; //
|
|||
//根据平台用户名查询 对应的监控用户名和密码,如果不需要则默认给出easycvr lmlz@2019
|
|||
String passwordMd532 = DigestUtils.md5DigestAsHex(vedio_password.getBytes()); |
|||
HttpRequest get = HttpUtil.createGet(StrUtil.format("{}/api/v1/login?username={}&password={}", vedio_server_url, userName, passwordMd532)); |
|||
HttpResponse execute = get.execute(); |
|||
if(execute.getStatus()==200){ |
|||
//解析token
|
|||
token= Optional.ofNullable(JSONObject.parseObject(execute.body()).getString("token")).orElse(""); |
|||
redisTemplate.opsForValue().set("vedio:" + userName,token); |
|||
} |
|||
|
|||
} |
|||
return token; |
|||
} |
|||
@ApiOperation("获取设备列表") |
|||
@GetMapping("/getDevcieList") |
|||
public AjaxResult getDeviceList(){ |
|||
|
|||
String token=getToken(); |
|||
HttpRequest get = HttpUtil.createGet(StrUtil.format("{}/api/v1/devices?device={}&start={}&limit={}&token={}", vedio_server_url,0,0,100,token)); |
|||
return AjaxResult.success(get.execute().body()); |
|||
} |
|||
@ApiOperation("获取通道列表") |
|||
@ApiImplicitParams({ |
|||
@ApiImplicitParam(name = "depId", value = "上级部门编码默认0", dataType = "Long", dataTypeClass = Long.class), |
|||
}) |
|||
@GetMapping("/getChanleList") |
|||
public AjaxResult getChanelList(){ |
|||
String token=""; |
|||
return AjaxResult.success(token); |
|||
} |
|||
} |
Loading…
Reference in new issue