158 lines
5.3 KiB
Plaintext
158 lines
5.3 KiB
Plaintext
package com.securityControl.system.service.impl;
|
|
|
|
import com.securityControl.common.redis.service.RedisService;
|
|
import com.securityControl.system.domain.vo.ReturnCodeEntity;
|
|
import com.securityControl.system.domain.vo.VideoConfigVo;
|
|
import com.securityControl.system.mapper.VideoConfigDao;
|
|
import com.securityControl.system.service.VideoConfigService;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
import javax.annotation.Resource;
|
|
import java.util.ArrayList;
|
|
import java.util.List;
|
|
|
|
@Service
|
|
@Slf4j
|
|
public class VideoConfigServiceImpl implements VideoConfigService {
|
|
|
|
|
|
@Autowired
|
|
private VideoConfigDao dao;
|
|
|
|
@Resource
|
|
private RedisService redisUtil;
|
|
/**
|
|
* 获取视频配置集合
|
|
* @param videoConfigVo
|
|
* @return
|
|
*/
|
|
@Override
|
|
public List<VideoConfigVo> getVideoConfigList(VideoConfigVo videoConfigVo) {
|
|
try{
|
|
return dao.getVideoConfigList(videoConfigVo);
|
|
}catch (Exception e){
|
|
log.error(e.toString(),e);
|
|
}
|
|
return new ArrayList<VideoConfigVo>();
|
|
}
|
|
|
|
/**
|
|
* 新增视频配置
|
|
* @param videoConfigVo
|
|
* @return
|
|
*/
|
|
@Override
|
|
public ReturnCodeEntity insertVideoConfig(VideoConfigVo videoConfigVo) {
|
|
ReturnCodeEntity returnCodeEntity=new ReturnCodeEntity();
|
|
try{
|
|
|
|
dao.insertVideoConfig(videoConfigVo);
|
|
returnCodeEntity.setMsg("新增成功");
|
|
returnCodeEntity.setCode("200");
|
|
}catch (Exception e){
|
|
returnCodeEntity.setMsg("新增失败");
|
|
returnCodeEntity.setCode("201");
|
|
log.error(e.toString(),e);
|
|
}
|
|
return returnCodeEntity;
|
|
}
|
|
|
|
/**
|
|
* 修改视频配置
|
|
* @param videoConfigVo
|
|
* @return
|
|
*/
|
|
@Override
|
|
public ReturnCodeEntity updateVideoConfig(VideoConfigVo videoConfigVo) {
|
|
ReturnCodeEntity returnCodeEntity=new ReturnCodeEntity();
|
|
try{
|
|
dao.updateVideoConfig(videoConfigVo);
|
|
returnCodeEntity.setMsg("修改成功");
|
|
returnCodeEntity.setCode("200");
|
|
}catch (Exception e){
|
|
returnCodeEntity.setMsg("修改失败");
|
|
returnCodeEntity.setCode("201");
|
|
log.error(e.toString(),e);
|
|
}
|
|
return returnCodeEntity;
|
|
}
|
|
|
|
/**
|
|
* 依据id 查询数据
|
|
* @param videoConfigVo
|
|
* @return
|
|
*/
|
|
@Override
|
|
public VideoConfigVo getVideoConfigById(VideoConfigVo videoConfigVo) {
|
|
return dao.getVideoConfigById(videoConfigVo);
|
|
}
|
|
|
|
/**
|
|
*
|
|
* @param videoConfigVo
|
|
* @return
|
|
*/
|
|
@Override
|
|
public ReturnCodeEntity updateVideoConfigStatus(VideoConfigVo videoConfigVo) {
|
|
ReturnCodeEntity returnCodeEntity=new ReturnCodeEntity();
|
|
try{
|
|
VideoConfigVo data=dao.getVideoConfigById(videoConfigVo);//查询是什么类型
|
|
String videoType=data.getVideoType();//前后端类型
|
|
videoConfigVo.setVideoType(videoType);
|
|
if("2".equals(videoConfigVo.getStatus())){//关闭
|
|
int num=dao.getVideoTypeNum(videoConfigVo);
|
|
if(num<1){
|
|
returnCodeEntity.setMsg("配置必须有一个存在开启");
|
|
returnCodeEntity.setCode("201");
|
|
}else{
|
|
Integer nums= dao.updateVideoConfigStatus(videoConfigVo);
|
|
if(nums>0){
|
|
returnCodeEntity.setMsg("关闭成功");
|
|
returnCodeEntity.setCode("200");
|
|
}
|
|
}
|
|
}if("1".equals(videoConfigVo.getStatus())){//开启
|
|
dao.closerOtherConfig(videoConfigVo);//关闭其他配置
|
|
Integer num= dao.updateVideoConfigStatus(videoConfigVo);
|
|
if(num>0){
|
|
//前端
|
|
if("1".equals(videoType)){
|
|
//ip
|
|
redisUtil.set("video:webIp",data.getVideoIp());
|
|
//port
|
|
redisUtil.set("video:webPort",data.getVideoPort());
|
|
//user
|
|
redisUtil.set("video:webUser",data.getVideoUser());
|
|
//密码
|
|
redisUtil.set("video:webPwd",data.getVideoPassword());
|
|
redisUtil.set("video:webEpid",data.getEpid());
|
|
redisUtil.set("video:webBfix", data.getBfix());
|
|
redisUtil.set("video:webUrl", data.getQ2httpUrl());
|
|
redisUtil.set("video:webUrlN", data.getQ2httpUrlN());
|
|
redisUtil.set("video:webWsUrl", data.getWebsocketUrl());
|
|
redisUtil.set("video:webWsUrlN", data.getWebsocketUrlN());
|
|
}else if("2".equals(videoType)){
|
|
redisUtil.set("video:ip",data.getVideoIp());
|
|
redisUtil.set("video:port",data.getVideoPort());
|
|
redisUtil.set("video:user",data.getVideoUser());
|
|
redisUtil.set("video:pwd",data.getVideoPassword());
|
|
redisUtil.set("video:url",data.getVideoUrl());
|
|
redisUtil.set("video:bfix",data.getBfix());
|
|
redisUtil.set("video:epid",data.getEpid());
|
|
}
|
|
returnCodeEntity.setMsg("开启成功");
|
|
returnCodeEntity.setCode("200");
|
|
}
|
|
}
|
|
}catch (Exception e){
|
|
log.error(e.toString(),e);
|
|
}
|
|
return returnCodeEntity;
|
|
|
|
}
|
|
|
|
|
|
}
|