Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
midjourney-proxy
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
徐少华
midjourney-proxy
Commits
f6b5e260
Commit
f6b5e260
authored
Sep 21, 2022
by
李传峰
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'hotfix/jedis' into 'master'
bug: [none] jedis NPE 解决 See merge request rays/pcloud-book!1685
parents
58ce2ed2
679155e3
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
34 deletions
+7
-34
ConvertFileListener.java
...in/java/com/pcloud/book/mq/topic/ConvertFileListener.java
+7
-34
No files found.
pcloud-service-book/src/main/java/com/pcloud/book/mq/topic/ConvertFileListener.java
View file @
f6b5e260
package
com
.
pcloud
.
book
.
mq
.
topic
;
package
com
.
pcloud
.
book
.
mq
.
topic
;
import
com.google.common.collect.Maps
;
import
com.google.common.collect.Maps
;
import
com.pcloud.book.advertising.biz.AdvertisingSpaceBiz
;
import
com.pcloud.book.advertising.biz.AdvertisingSpaceBiz
;
import
com.pcloud.book.advertising.entity.AdvertisingSpace
;
import
com.pcloud.book.advertising.entity.AdvertisingSpace
;
import
com.pcloud.common.core.aspect.ParamLog
;
import
com.pcloud.common.core.aspect.ParamLog
;
...
@@ -12,20 +11,18 @@ import com.pcloud.common.exceptions.BizException;
...
@@ -12,20 +11,18 @@ import com.pcloud.common.exceptions.BizException;
import
com.pcloud.common.utils.FileUtils
;
import
com.pcloud.common.utils.FileUtils
;
import
com.pcloud.common.utils.ListUtils
;
import
com.pcloud.common.utils.ListUtils
;
import
com.pcloud.contentcenter.resource.enums.ResourceTypeEnum
;
import
com.pcloud.contentcenter.resource.enums.ResourceTypeEnum
;
import
org.apache.commons.collections.MapUtils
;
import
org.apache.commons.collections.MapUtils
;
import
org.slf4j.Logger
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.amqp.rabbit.annotation.RabbitHandler
;
import
org.springframework.amqp.rabbit.annotation.RabbitHandler
;
import
org.springframework.amqp.rabbit.annotation.RabbitListener
;
import
org.springframework.amqp.rabbit.annotation.RabbitListener
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.scheduling.annotation.Scheduled
;
import
org.springframework.stereotype.Component
;
import
org.springframework.stereotype.Component
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map
;
import
javax.annotation.PostConstruct
;
/**
/**
* @描述:文件转码
* @描述:文件转码
* @作者:zhuyajie
* @作者:zhuyajie
...
@@ -37,7 +34,6 @@ import javax.annotation.PostConstruct;
...
@@ -37,7 +34,6 @@ import javax.annotation.PostConstruct;
public
class
ConvertFileListener
{
public
class
ConvertFileListener
{
private
static
final
Logger
LOGGER
=
LoggerFactory
.
getLogger
(
ConvertFileListener
.
class
);
private
static
final
Logger
LOGGER
=
LoggerFactory
.
getLogger
(
ConvertFileListener
.
class
);
private
static
ConvertFileListener
convertFileListener
;
@Autowired
@Autowired
private
AdvertisingSpaceBiz
advertisingSpaceBiz
;
private
AdvertisingSpaceBiz
advertisingSpaceBiz
;
...
@@ -46,18 +42,12 @@ public class ConvertFileListener {
...
@@ -46,18 +42,12 @@ public class ConvertFileListener {
*/
*/
private
static
Map
<
String
,
ConvertQueueDto
>
cqds
=
Maps
.
newHashMap
();
private
static
Map
<
String
,
ConvertQueueDto
>
cqds
=
Maps
.
newHashMap
();
private
static
Thread
t1
=
new
Thread
(
new
Runnable
()
{
@Scheduled
(
fixedDelay
=
1000
*
60
)
@Override
public
void
run
()
{
public
void
run
()
{
while
(
true
)
{
//如果cqds没有记录,休眠60秒
//如果cqds没有记录,休眠60秒
if
(
MapUtils
.
isEmpty
(
cqds
))
{
if
(
MapUtils
.
isEmpty
(
cqds
))
{
try
{
return
;
Thread
.
sleep
(
1000
*
60
);
}
catch
(
InterruptedException
e
)
{
LOGGER
.
error
(
"pmrismap线程执行出错"
,
e
);
}
}
}
else
{
for
(
Map
.
Entry
<
String
,
ConvertQueueDto
>
e
:
cqds
.
entrySet
())
{
for
(
Map
.
Entry
<
String
,
ConvertQueueDto
>
e
:
cqds
.
entrySet
())
{
if
(
e
.
getValue
()
!=
null
)
{
if
(
e
.
getValue
()
!=
null
)
{
ConvertQueueDto
convertFileDto
=
e
.
getValue
();
ConvertQueueDto
convertFileDto
=
e
.
getValue
();
...
@@ -66,10 +56,10 @@ public class ConvertFileListener {
...
@@ -66,10 +56,10 @@ public class ConvertFileListener {
String
fileId
=
convertFileDto
.
getFileId
();
String
fileId
=
convertFileDto
.
getFileId
();
String
fileUrl
=
convertFileDto
.
getFileUrl
();
String
fileUrl
=
convertFileDto
.
getFileUrl
();
if
(
ResourceTypeEnum
.
AUDIO
.
code
.
equals
(
fileCategory
)
||
ResourceTypeEnum
.
VIDEO
.
code
.
equals
(
fileCategory
))
{
if
(
ResourceTypeEnum
.
AUDIO
.
code
.
equals
(
fileCategory
)
||
ResourceTypeEnum
.
VIDEO
.
code
.
equals
(
fileCategory
))
{
List
<
AdvertisingSpace
>
filelist
=
convertFileListener
.
advertisingSpaceBiz
.
getUnConvertFile
(
fileId
);
List
<
AdvertisingSpace
>
filelist
=
advertisingSpaceBiz
.
getUnConvertFile
(
fileId
);
if
(!
ListUtils
.
isEmpty
(
filelist
))
{
if
(!
ListUtils
.
isEmpty
(
filelist
))
{
//更新
//更新
convertFileListener
.
advertisingSpaceBiz
.
updateFile
(
filelist
,
fileUrl
);
advertisingSpaceBiz
.
updateFile
(
filelist
,
fileUrl
);
cqds
.
remove
(
e
.
getKey
());
cqds
.
remove
(
e
.
getKey
());
}
else
{
}
else
{
if
(
convertFileDto
.
getProcessTimes
()
<
10
)
{
if
(
convertFileDto
.
getProcessTimes
()
<
10
)
{
...
@@ -86,15 +76,6 @@ public class ConvertFileListener {
...
@@ -86,15 +76,6 @@ public class ConvertFileListener {
}
}
}
}
}
}
}
}
});
// 开始缓存处理
static
{
t1
.
start
();
}
@RabbitHandler
@RabbitHandler
@ParamLog
(
"文件转码"
)
@ParamLog
(
"文件转码"
)
...
@@ -120,22 +101,14 @@ public class ConvertFileListener {
...
@@ -120,22 +101,14 @@ public class ConvertFileListener {
String
fileUrl
=
convertFileDto
.
getFileUrl
();
String
fileUrl
=
convertFileDto
.
getFileUrl
();
// 修改点读书音频转码后的地址
// 修改点读书音频转码后的地址
if
(
ResourceTypeEnum
.
AUDIO
.
code
.
equals
(
fileCategory
))
{
if
(
ResourceTypeEnum
.
AUDIO
.
code
.
equals
(
fileCategory
))
{
List
<
AdvertisingSpace
>
filelist
=
convertFileListener
.
advertisingSpaceBiz
.
getUnConvertFile
(
fileId
);
List
<
AdvertisingSpace
>
filelist
=
advertisingSpaceBiz
.
getUnConvertFile
(
fileId
);
if
(
ListUtils
.
isEmpty
(
filelist
))
{
if
(
ListUtils
.
isEmpty
(
filelist
))
{
LOGGER
.
info
(
"接收到转码状态时,数据库还未插入记录,先将音频转码信息放到缓存fileId="
+
fileId
+
"convertFileDto="
+
convertFileDto
.
toString
());
LOGGER
.
info
(
"接收到转码状态时,数据库还未插入记录,先将音频转码信息放到缓存fileId="
+
fileId
+
"convertFileDto="
+
convertFileDto
.
toString
());
cqds
.
put
(
fileId
,
convertFileDto
);
cqds
.
put
(
fileId
,
convertFileDto
);
}
else
{
}
else
{
convertFileListener
.
advertisingSpaceBiz
.
updateFile
(
filelist
,
fileUrl
);
advertisingSpaceBiz
.
updateFile
(
filelist
,
fileUrl
);
}
}
}
}
}
}
}
}
@PostConstruct
public
void
init
()
{
convertFileListener
=
this
;
convertFileListener
.
advertisingSpaceBiz
=
this
.
advertisingSpaceBiz
;
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
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 comment