Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
Toggle navigation
This project
Loading...
Sign in
谢明辉
/
fanxing3
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 21644c07
authored
Apr 29, 2022
by
翟柏林
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
[chg]解决视频转发的bug
1 parent
e4e2862d
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
16 additions
and
4 deletions
fanxing-forward/src/main/java/com/viontech/fanxing/forward/batch/processor/ForwardProcessor.java
fanxing-forward/src/main/java/com/viontech/fanxing/forward/controller/DataReceiveController.java
fanxing-forward/src/main/java/com/viontech/fanxing/forward/util/PicUtils.java
fanxing-forward/src/main/java/com/viontech/fanxing/forward/batch/processor/ForwardProcessor.java
View file @
21644c0
...
...
@@ -13,6 +13,8 @@ import org.springframework.stereotype.Component;
import
javax.annotation.Resource
;
import
java.util.List
;
import
java.util.stream.Collectors
;
import
java.util.stream.Stream
;
/**
* .
...
...
@@ -35,13 +37,14 @@ public class ForwardProcessor implements ItemStream, ItemProcessor<JSONObject, F
if
(
allForward
==
null
||
allForward
.
size
()
==
0
)
{
return
null
;
}
List
<
Forward
>
forwardList
=
allForward
.
stream
().
filter
(
forward
->
forward
.
getStatus
()
==
0
).
collect
(
Collectors
.
toList
());
String
eventType
=
item
.
getString
(
"event_type"
);
String
eventCate
=
item
.
getString
(
"event_cate"
);
ForwardContent
forwardContent
=
new
ForwardContent
();
forwardContent
.
setJson
(
item
.
toJSONString
());
forwardContent
.
setForwardList
(
allForward
);
forwardContent
.
setForwardList
(
forwardList
);
return
forwardContent
;
}
...
...
fanxing-forward/src/main/java/com/viontech/fanxing/forward/controller/DataReceiveController.java
View file @
21644c0
...
...
@@ -29,6 +29,7 @@ import javax.annotation.Resource;
import
java.io.File
;
import
java.time.Duration
;
import
java.util.Date
;
import
java.util.List
;
/**
* .
...
...
@@ -92,16 +93,19 @@ public class DataReceiveController {
}
FileUtils
.
copyToFile
(
videoResult
.
getFile
().
getInputStream
(),
file
);
videoResult
.
setFile
(
null
);
for
(
Forward
forward
:
cacheUtils
.
getAllForward
())
{
List
<
Forward
>
allForward
=
cacheUtils
.
getAllForward
();
log
.
info
(
"需要转发的地址的数量为{},分别为{}"
,
allForward
.
size
(),
allForward
);
for
(
Forward
forward
:
allForward
)
{
if
(
forward
.
getStatus
()
==
1
)
{
ForwardApp
.
THREAD_POOL_EXECUTOR
.
submit
(()
->
{
try
{
log
.
info
(
"需要转发的地址的为{}"
,
forward
.
getUrl
());
MultiValueMap
<
String
,
Object
>
param
=
new
LinkedMultiValueMap
<>();
param
.
add
(
"refid"
,
videoResult
.
getRefid
());
param
.
add
(
"format"
,
videoResult
.
getFormat
());
param
.
add
(
"file"
,
new
FileSystemResource
(
file
));
Mono
<
String
>
response
=
WebClientUtils
.
buildClient
(
null
).
post
().
uri
(
forward
.
getUrl
()).
contentType
(
MediaType
.
MULTIPART_FORM_DATA
).
contentLength
(
file
.
length
()).
body
(
BodyInserters
.
fromMultipartData
(
param
)).
retrieve
().
bodyToMono
(
String
.
class
);
Mono
<
String
>
response
=
WebClientUtils
.
buildClient
(
null
).
post
().
uri
(
forward
.
getUrl
()).
contentType
(
MediaType
.
MULTIPART_FORM_DATA
).
body
(
BodyInserters
.
fromMultipartData
(
param
)).
retrieve
().
bodyToMono
(
String
.
class
);
String
block
=
response
.
block
(
Duration
.
ofSeconds
(
10
));
log
.
info
(
"发送视频文件完成,对接名称:[{}],结果:[{}]"
,
forward
.
getName
(),
block
);
}
catch
(
Exception
e
)
{
...
...
fanxing-forward/src/main/java/com/viontech/fanxing/forward/util/PicUtils.java
View file @
21644c0
...
...
@@ -7,8 +7,10 @@ import org.springframework.stereotype.Component;
import
java.io.File
;
import
java.io.IOException
;
import
java.text.SimpleDateFormat
;
import
java.util.Base64
;
import
java.util.Date
;
import
java.util.TimeZone
;
import
java.util.UUID
;
/**
...
...
@@ -50,7 +52,10 @@ public class PicUtils {
int
i
=
unid
.
hashCode
();
i
^=
(
i
>>>
16
);
i
=
127
&
i
;
String
dateStr
=
DateUtil
.
format
(
"yyyyMMdd"
,
date
);
//String dateStr = DateUtil.format("yyyyMMdd", date);
SimpleDateFormat
simpleDateFormat
=
new
SimpleDateFormat
(
"yyyyMMdd"
);
simpleDateFormat
.
setTimeZone
(
TimeZone
.
getTimeZone
(
"GMT+8:00"
));
String
dateStr
=
simpleDateFormat
.
format
(
date
);
return
basePath
+
File
.
separator
+
dateStr
+
File
.
separator
+
i
+
File
.
separator
+
unid
+
"."
+
format
;
}
...
...
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment