提交 dc45166e 作者: Administrator

refactor : 视频监控点位参数变化

上级 9289132c
...@@ -3,6 +3,7 @@ package com.yiring.app.param.video; ...@@ -3,6 +3,7 @@ package com.yiring.app.param.video;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import java.io.Serial;
import java.io.Serializable; import java.io.Serializable;
import javax.validation.constraints.NotEmpty; import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull; import javax.validation.constraints.NotNull;
...@@ -24,6 +25,7 @@ import lombok.experimental.FieldDefaults; ...@@ -24,6 +25,7 @@ import lombok.experimental.FieldDefaults;
@FieldDefaults(level = AccessLevel.PRIVATE) @FieldDefaults(level = AccessLevel.PRIVATE)
public class VideoParam implements Serializable { public class VideoParam implements Serializable {
@Serial
private static final long serialVersionUID = 6031274771790265507L; private static final long serialVersionUID = 6031274771790265507L;
@ApiModelProperty(value = "编号", example = "88888888", required = true) @ApiModelProperty(value = "编号", example = "88888888", required = true)
...@@ -40,11 +42,11 @@ public class VideoParam implements Serializable { ...@@ -40,11 +42,11 @@ public class VideoParam implements Serializable {
@ApiModelProperty(value = "经度", example = "1.00", required = true) @ApiModelProperty(value = "经度", example = "1.00", required = true)
@NotNull(message = "经度") @NotNull(message = "经度")
double lon; Double lon;
@ApiModelProperty(value = "纬度", example = "1.00", required = true) @ApiModelProperty(value = "纬度", example = "1.00", required = true)
@NotNull(message = "纬度") @NotNull(message = "纬度")
double lat; Double lat;
@ApiModelProperty(value = "备注", example = "厂区摄像头") @ApiModelProperty(value = "备注", example = "厂区摄像头")
@Size(max = 100, message = "备注不能超过100字") @Size(max = 100, message = "备注不能超过100字")
......
...@@ -73,13 +73,8 @@ public class VideoServiceImpl implements VideoService { ...@@ -73,13 +73,8 @@ public class VideoServiceImpl implements VideoService {
Video video = Video Video video = Video
.builder() .builder()
.createTime(LocalDateTime.now()) .createTime(LocalDateTime.now())
// .enable(videoParam.getEnable())
// .m3u8(videoParam.getM3u8())
// .point(videoParam.getPoint())
.m3u8(videoParam.getM3u8()) .m3u8(videoParam.getM3u8())
.point(GeoUtils.createPoint(videoParam.getLon(), videoParam.getLat())) .point(GeoUtils.createPoint(videoParam.getLon(), videoParam.getLat()))
// .online(videoParam.getOnline())
// .type(videoParam.getType())
//默认正常 //默认正常
.videoName(videoParam.getVideoName()) .videoName(videoParam.getVideoName())
.status("1") .status("1")
...@@ -89,25 +84,22 @@ public class VideoServiceImpl implements VideoService { ...@@ -89,25 +84,22 @@ public class VideoServiceImpl implements VideoService {
videoRepository.saveAndFlush(video); videoRepository.saveAndFlush(video);
//还需要同步添加国标28181中对应的摄像头信息 //还需要同步添加国标28181中对应的摄像头信息
//标识uuid对应流id,m3u8对应拉流地址,如m3u8中有标注 则将类型切换为FFmpeg,摄像头名称videoName对应名称,流名称默认"stream",超时时间默认60 //标识uuid对应流id,m3u8对应拉流地址,如m3u8中有标注 则将类型切换为FFmpeg,摄像头名称videoName对应名称,流名称默认"stream",超时时间默认60
new Thread(() -> { StreamProxyItem streamProxyItem = StreamProxyItem
StreamProxyItem streamProxyItem = StreamProxyItem .builder()
.builder() .name(video.getVideoName())
.name(video.getVideoName()) .app("stream")
.app("stream") .stream(video.getUuid())
.stream(video.getUuid()) .url(video.getM3u8())
.url(video.getM3u8()) .mediaServerId("ZbnQN5csqxrPix7a")
.mediaServerId("ZbnQN5csqxrPix7a") .enable(true)
.enable(true) .enable_hls(true)
.enable_hls(true) .type(video.getM3u8().contains("sss") ? "ffmpeg" : "default")
.type(video.getM3u8().contains("sss") ? "ffmpeg" : "default") .timeout_ms(video.getM3u8().contains("sss") ? 60 : null)
.timeout_ms(video.getM3u8().contains("sss") ? 60 : null) .build();
.build(); JSONObject jsonObject = gbClient.proxySave(streamProxyItem, gbCookie());
JSONObject jsonObject = gbClient.proxySave(streamProxyItem, gbCookie()); if (!jsonObject.get("code").equals(0)) {
if (!jsonObject.get("code").equals(0)) { throw new RuntimeException(jsonObject.get("msg").toString());
throw new RuntimeException(jsonObject.get("msg").toString()); }
}
})
.start();
return Result.ok(); return Result.ok();
} }
...@@ -119,13 +111,10 @@ public class VideoServiceImpl implements VideoService { ...@@ -119,13 +111,10 @@ public class VideoServiceImpl implements VideoService {
} }
Video video = optional.get(); Video video = optional.get();
//还需要同步删除国标28181中对应的摄像头信息 //还需要同步删除国标28181中对应的摄像头信息
new Thread(() -> { JSONObject jsonObject = gbClient.proxyDel("stream", video.getUuid(), gbCookie());
JSONObject jsonObject = gbClient.proxyDel("stream", video.getUuid(), gbCookie()); if (!jsonObject.get("code").equals(0)) {
if (!jsonObject.get("code").equals(0)) { throw new RuntimeException(jsonObject.get("msg").toString());
throw new RuntimeException(jsonObject.get("msg").toString()); }
}
})
.start();
videoRepository.delete(video); videoRepository.delete(video);
return Result.ok(); return Result.ok();
...@@ -147,16 +136,14 @@ public class VideoServiceImpl implements VideoService { ...@@ -147,16 +136,14 @@ public class VideoServiceImpl implements VideoService {
// if ( // if (
// !video.getVideoName().equals(videoParam.getVideoName()) && !video.getM3u8().equals(videoParam.getM3u8()) // !video.getVideoName().equals(videoParam.getVideoName()) && !video.getM3u8().equals(videoParam.getM3u8())
// ) { // ) {
new Thread(() -> { JSONObject jsonObject = gbClient.proxyDel("stream", video.getUuid(), gbCookie());
JSONObject jsonObject = gbClient.proxyDel("stream", video.getUuid(), gbCookie()); if (!jsonObject.get("code").equals(0)) {
if (!jsonObject.get("code").equals(0)) { throw new RuntimeException(jsonObject.get("msg").toString());
throw new RuntimeException(jsonObject.get("msg").toString()); }
}
})
.start();
} }
// } // }
BeanUtils.copyProperties(videoParam, video); BeanUtils.copyProperties(videoParam, video);
video.setPoint(GeoUtils.createPoint(videoParam.getLon(), videoParam.getLat()));
videoRepository.saveAndFlush(video); videoRepository.saveAndFlush(video);
//将信息发送到队列,等待同步至国标 //将信息发送到队列,等待同步至国标
// new Thread(() -> { // new Thread(() -> {
...@@ -214,9 +201,10 @@ public class VideoServiceImpl implements VideoService { ...@@ -214,9 +201,10 @@ public class VideoServiceImpl implements VideoService {
List<Video> all = videoRepository.findAll(condition(videoQueryParam), sort); List<Video> all = videoRepository.findAll(condition(videoQueryParam), sort);
List<VideoVo> data = all List<VideoVo> data = all
.stream() .stream()
.map(car -> { .map(video -> {
VideoVo vo = new VideoVo(); VideoVo vo = new VideoVo();
BeanUtils.copyProperties(car, vo); BeanUtils.copyProperties(video, vo);
// vo.setPoint(video.getPoint());
return vo; return vo;
}) })
.collect(Collectors.toList()); .collect(Collectors.toList());
...@@ -287,6 +275,7 @@ public class VideoServiceImpl implements VideoService { ...@@ -287,6 +275,7 @@ public class VideoServiceImpl implements VideoService {
String fileName = URLEncoder.encode("监控点位来访信息.xlsx", StandardCharsets.UTF_8); String fileName = URLEncoder.encode("监控点位来访信息.xlsx", StandardCharsets.UTF_8);
response.setContentType("application/octet-stream"); response.setContentType("application/octet-stream");
response.setHeader("Access-Control-Expose-Headers", "Content-Disposition");
response.setHeader("Content-Disposition", "attachment;filename=" + fileName); response.setHeader("Content-Disposition", "attachment;filename=" + fileName);
OutputStream out = response.getOutputStream(); OutputStream out = response.getOutputStream();
...@@ -324,6 +313,8 @@ public class VideoServiceImpl implements VideoService { ...@@ -324,6 +313,8 @@ public class VideoServiceImpl implements VideoService {
.map(videoImportExcel -> { .map(videoImportExcel -> {
Video video = new Video(); Video video = new Video();
BeanUtils.copyProperties(videoImportExcel, video); BeanUtils.copyProperties(videoImportExcel, video);
video.setPoint(GeoUtils.createPoint(videoImportExcel.getLon(), videoImportExcel.getLat()));
video.setCreateTime(LocalDateTime.now());
return video; return video;
}) })
.toList(); .toList();
...@@ -333,7 +324,6 @@ public class VideoServiceImpl implements VideoService { ...@@ -333,7 +324,6 @@ public class VideoServiceImpl implements VideoService {
videoRepository videoRepository
.findOne((root, cq, cb) -> { .findOne((root, cq, cb) -> {
List<Predicate> predicates = new ArrayList<>(); List<Predicate> predicates = new ArrayList<>();
if (StrUtil.isNotBlank(video.getUuid())) { if (StrUtil.isNotBlank(video.getUuid())) {
predicates.add(cb.equal(root.get("uuid").as(String.class), video.getUuid())); predicates.add(cb.equal(root.get("uuid").as(String.class), video.getUuid()));
} }
......
...@@ -5,10 +5,11 @@ import com.fasterxml.jackson.databind.annotation.JsonSerialize; ...@@ -5,10 +5,11 @@ import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import java.awt.*; import java.io.Serial;
import java.io.Serializable; import java.io.Serializable;
import lombok.*; import lombok.*;
import lombok.experimental.FieldDefaults; import lombok.experimental.FieldDefaults;
import org.locationtech.jts.geom.Point;
/** /**
* @author tzl * @author tzl
...@@ -22,6 +23,7 @@ import lombok.experimental.FieldDefaults; ...@@ -22,6 +23,7 @@ import lombok.experimental.FieldDefaults;
@FieldDefaults(level = AccessLevel.PRIVATE) @FieldDefaults(level = AccessLevel.PRIVATE)
public class VideoVo implements Serializable { public class VideoVo implements Serializable {
@Serial
private static final long serialVersionUID = 3968078657827350557L; private static final long serialVersionUID = 3968078657827350557L;
@JsonSerialize(using = ToStringSerializer.class) @JsonSerialize(using = ToStringSerializer.class)
...@@ -37,7 +39,7 @@ public class VideoVo implements Serializable { ...@@ -37,7 +39,7 @@ public class VideoVo implements Serializable {
@ApiModelProperty(value = "m3u8地址", example = "m3u8地址") @ApiModelProperty(value = "m3u8地址", example = "m3u8地址")
String m3u8; String m3u8;
@ApiModelProperty(value = "备注", example = "摄像头") @ApiModelProperty(value = "备注", example = "备注")
String remark; String remark;
@ApiModelProperty(value = "摄像头名称", example = "摄像头1") @ApiModelProperty(value = "摄像头名称", example = "摄像头1")
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论