Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
B
basic-api-boot
概览
概览
详情
活动
周期分析
版本库
存储库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
Basic
basic-api-boot
Commits
b7c9acd7
提交
b7c9acd7
authored
4月 20, 2022
作者:
谭志磊
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
合并,备份
上级
c7db2617
显示空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
137 行增加
和
30 行删除
+137
-30
VideoServiceImpl.java
...a/com/yiring/app/service/video/impl/VideoServiceImpl.java
+137
-30
没有找到文件。
app/src/main/java/com/yiring/app/service/video/impl/VideoServiceImpl.java
浏览文件 @
b7c9acd7
...
@@ -11,22 +11,21 @@ import com.yiring.app.vo.video.VideoVo;
...
@@ -11,22 +11,21 @@ import com.yiring.app.vo.video.VideoVo;
import
com.yiring.common.core.Result
;
import
com.yiring.common.core.Result
;
import
com.yiring.common.core.Status
;
import
com.yiring.common.core.Status
;
import
com.yiring.common.param.IdParam
;
import
com.yiring.common.param.IdParam
;
import
com.yiring.common.param.PageParam
;
import
com.yiring.common.util.StrUtils
;
import
com.yiring.common.vo.PageVo
;
import
com.yiring.common.vo.PageVo
;
import
java.time.LocalDateTime
;
import
java.time.LocalDateTime
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Objects
;
import
java.util.Optional
;
import
java.util.Optional
;
import
java.util.stream.Collectors
;
import
java.util.stream.Collectors
;
import
javax.annotation.Resource
;
import
javax.annotation.Resource
;
import
javax.persistence.criteria.Predicate
;
import
javax.persistence.criteria.Predicate
;
import
org.locationtech.jts.geom.Point
;
import
org.locationtech.jts.geom.Point
;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.data.domain.Example
;
import
org.springframework.data.domain.*
;
import
org.springframework.data.domain.Page
;
import
org.springframework.data.jpa.domain.Specification
;
import
org.springframework.data.jpa.domain.Specification
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
org.springframework.web.multipart.MultipartFile
;
/**
/**
* @author tzl
* @author tzl
...
@@ -92,11 +91,30 @@ public class VideoServiceImpl implements VideoService {
...
@@ -92,11 +91,30 @@ public class VideoServiceImpl implements VideoService {
if
(
has
(
videoParam
.
getUuid
()))
{
if
(
has
(
videoParam
.
getUuid
()))
{
return
Result
.
no
(
Status
.
BAD_REQUEST
,
"您输入的编号已存在"
);
return
Result
.
no
(
Status
.
BAD_REQUEST
,
"您输入的编号已存在"
);
}
}
//当修改跟国标相关联的信息时同步更新国标数据
// if (
// !video.getVideoName().equals(videoParam.getVideoName()) && !video.getM3u8().equals(videoParam.getM3u8())
// ) {
// gbClient.proxyDel("stream", video.getUuid(), gbCookie());
// }
}
}
BeanUtils
.
copyProperties
(
videoParam
,
video
);
BeanUtils
.
copyProperties
(
videoParam
,
video
);
videoRepository
.
saveAndFlush
(
video
);
videoRepository
.
saveAndFlush
(
video
);
//还需要同步修改国标28181中对应的摄像头信息
//将信息发送到队列,等待同步至国标
// StreamProxyItem streamProxyItem = StreamProxyItem
// .builder()
// .name(video.getVideoName())
// .app("stream")
// .stream(video.getUuid())
// .url(video.getM3u8())
// .mediaServerId("ZbnQN5csqxrPix7a")
// .enable(true)
// .enable_hls(true)
// .type(video.getM3u8().contains("sss") ? "ffmpeg" : "default")
// .timeout_ms(video.getM3u8().contains("sss") ? 60 : null)
// .build();
// JSONObject jsonObject = gbClient.proxySave(streamProxyItem, gbCookie());
// System.out.println(jsonObject);
return
Result
.
ok
();
return
Result
.
ok
();
}
}
...
@@ -111,54 +129,143 @@ public class VideoServiceImpl implements VideoService {
...
@@ -111,54 +129,143 @@ public class VideoServiceImpl implements VideoService {
}
}
@Override
@Override
public
Result
<
PageVo
<
VideoVo
>>
pageVideo
(
VideoQueryParam
videoQueryParam
,
PageParam
param
)
{
public
Result
<
PageVo
<
VideoVo
>>
pageVideo
(
VideoQueryParam
videoQueryParam
)
{
Page
<
Video
>
all
=
videoRepository
.
findAll
(
condition
(
videoQueryParam
),
PageParam
.
toPageable
(
param
));
PageVo
<
VideoVo
>
resultVo
=
null
;
//排序
Sort
sort
=
Sort
.
by
(
Sort
.
Order
.
desc
(
Video
.
Fields
.
createTime
));
//如果传分页参数则分页,否查全部数据
if
(
Objects
.
nonNull
(
videoQueryParam
.
getPageNo
())
&&
Objects
.
nonNull
(
videoQueryParam
.
getPageSize
()))
{
//分页
Pageable
pageable
=
PageRequest
.
of
(
videoQueryParam
.
getPageNo
()
-
1
,
videoQueryParam
.
getPageSize
());
Page
<
Video
>
all
=
videoRepository
.
findAll
(
condition
(
videoQueryParam
),
pageable
);
List
<
VideoVo
>
data
=
all
List
<
VideoVo
>
data
=
all
.
get
()
.
get
()
.
map
(
video
->
{
.
map
(
car
->
{
VideoVo
vo
=
new
VideoVo
();
BeanUtils
.
copyProperties
(
car
,
vo
);
return
vo
;
})
.
collect
(
Collectors
.
toList
());
resultVo
=
PageVo
.
build
(
data
,
all
.
getTotalElements
());
}
else
{
List
<
Video
>
all
=
videoRepository
.
findAll
(
condition
(
videoQueryParam
),
sort
);
List
<
VideoVo
>
data
=
all
.
stream
()
.
map
(
car
->
{
VideoVo
vo
=
new
VideoVo
();
VideoVo
vo
=
new
VideoVo
();
BeanUtils
.
copyProperties
(
video
,
vo
);
BeanUtils
.
copyProperties
(
car
,
vo
);
return
vo
;
return
vo
;
})
})
.
collect
(
Collectors
.
toList
());
.
collect
(
Collectors
.
toList
());
PageVo
<
VideoVo
>
vo
=
PageVo
.
build
(
data
,
all
.
getTotalElements
());
resultVo
=
PageVo
.
build
(
data
,
data
.
size
());
return
Result
.
ok
(
vo
);
}
return
Result
.
ok
(
resultVo
);
}
}
/**
/**
* 条件查询
* 条件查询
*
* @param videoQueryParam 筛选条件
* @param videoQueryParam 筛选条件
* @return Specification
* @return Specification
*/
*/
@Override
public
Specification
<
Video
>
condition
(
VideoQueryParam
videoQueryParam
)
{
public
Specification
<
Video
>
condition
(
VideoQueryParam
videoQueryParam
)
{
return
(
root
,
query
,
criteriaBuilder
)
->
{
return
(
root
,
query
,
criteriaBuilder
)
->
{
List
<
Predicate
>
list
=
new
ArrayList
<>();
List
<
Predicate
>
list
=
new
ArrayList
<>();
if
(
StrUtils
.
isNotBlank
(
videoQueryParam
.
getVideoName
()))
{
//
if (StrUtils.isNotBlank(videoQueryParam.getVideoName())) {
list
.
add
(
//
list.add(
criteriaBuilder
.
like
(
//
criteriaBuilder.like(
root
.
get
(
"videoName"
).
as
(
String
.
class
),
//
root.get("videoName").as(String.class),
"%"
+
videoQueryParam
.
getVideoName
()
+
"%"
//
"%" + videoQueryParam.getVideoName() + "%"
)
//
)
);
//
);
}
//
}
//
if
(
StrUtils
.
isNotBlank
(
videoQueryParam
.
getUuid
()))
{
//
if (StrUtils.isNotBlank(videoQueryParam.getUuid())) {
list
.
add
(
//
list.add(
criteriaBuilder
.
like
(
root
.
get
(
"uuid"
).
as
(
String
.
class
),
"%"
+
videoQueryParam
.
getUuid
()
+
"%"
)
//
criteriaBuilder.like(root.get("uuid").as(String.class), "%" + videoQueryParam.getUuid() + "%")
);
//
);
}
//
}
//
if
(
StrUtils
.
isNotBlank
(
videoQueryParam
.
getStatus
()))
{
//
if (StrUtils.isNotBlank(videoQueryParam.getStatus())) {
list
.
add
(
criteriaBuilder
.
equal
(
root
.
get
(
"uuid
"
).
as
(
String
.
class
),
videoQueryParam
.
getStatus
()));
// list.add(criteriaBuilder.equal(root.get("status
").as(String.class), videoQueryParam.getStatus()));
}
//
}
Predicate
[]
predicates
=
new
Predicate
[
list
.
size
()];
Predicate
[]
predicates
=
new
Predicate
[
list
.
size
()];
query
.
where
(
list
.
toArray
(
predicates
));
query
.
where
(
list
.
toArray
(
predicates
));
return
criteriaBuilder
.
and
(
list
.
toArray
(
predicates
));
return
criteriaBuilder
.
and
(
list
.
toArray
(
predicates
));
};
};
}
}
@Override
public
List
<
Video
>
exportVideo
(
VideoQueryParam
videoQueryParam
)
{
return
videoRepository
.
findAll
(
condition
(
videoQueryParam
));
}
@Override
public
Result
<
String
>
importVideo
(
String
sheet
,
MultipartFile
file
,
Integer
titleRow
)
{
return
null
;
}
// @Override
// public Result<String> importVideo(String sheet, MultipartFile file, Integer titleRow) {
//// String s = gbCookie();
// ExcelUtils<Video> util = new ExcelUtils<>(Video.class);
// List<Video> videos = null;
// try {
// InputStream inputStream = file.getInputStream();
// if(titleRow==null){
// titleRow=0;
// }
// videos = util.importExcel(sheet, inputStream,titleRow);
// } catch (Exception e) {
// e.printStackTrace();
// }
// if (videos != null) {
// videos.forEach(video -> {
// videoRepository
// .findOne((root, cq, cb) -> {
// List<Predicate> predicates = new ArrayList<>();
//
// if (StringUtils.isNotBlank(video.getUuid())) {
// predicates.add(cb.equal(root.get("uuid").as(String.class), video.getUuid()));
// }
// return cq.where(predicates.toArray(new Predicate[0])).getRestriction();
// })
// .ifPresent(one -> {
// //如果存在则操作修改
// video.setId(one.getId());
// //删除国标关联监控信息
//// gbClient.proxyDel("stream", video.getUuid(),s);
// });
// videoRepository.saveAndFlush(video);
// //导入监控点位后,还需要同步数据到国标28181
//// StreamProxyItem streamProxyItem = StreamProxyItem
//// .builder()
//// .name(video.getVideoName())
//// .app("stream")
//// .stream(video.getUuid())
//// .url(video.getM3u8())
//// .mediaServerId("ZbnQN5csqxrPix7a")
//// .enable(true)
//// .enable_hls(true)
//// .type(video.getM3u8().contains("sss") ? "default" : "ffmpeg")
//// .timeout_ms(video.getM3u8().contains("sss") ? 60 : null)
//// .build();
//// JSONObject jsonObject = gbClient.proxySave(streamProxyItem, gbCookie());
//// System.out.println(jsonObject);
// });
// }
// return Result.ok();
// }
boolean
has
(
String
uuid
)
{
boolean
has
(
String
uuid
)
{
Video
video
=
Video
.
builder
().
uuid
(
uuid
).
build
();
Video
video
=
Video
.
builder
().
uuid
(
uuid
).
build
();
return
videoRepository
.
count
(
Example
.
of
(
video
))
>
0
;
return
videoRepository
.
count
(
Example
.
of
(
video
))
>
0
;
}
}
// //登录国标28181获取cookie
// String gbCookie() {
// Response response = gbClient.userLogin("admin", "21232f297a57a5a743894a0e4a801fc3");
// Collection<String> strings = response.headers().get("Set-Cookie");
// return strings.stream().filter(a -> a.contains("JSESSIONID")).collect(Collectors.joining(", "));
// }
}
}
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论