Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
dizhen
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
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
jiangyun
dizhen
Commits
7f298ab2
Commit
7f298ab2
authored
Nov 03, 2025
by
wangqi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
会议信息-真实时间处理
parent
094ab0a0
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
144 additions
and
0 deletions
+144
-0
src/main/java/com/ruoyi/project/ys/controller/HyjyxxController.java
+10
-0
src/main/java/com/ruoyi/project/ys/service/IHyjyxxService.java
+2
-0
src/main/java/com/ruoyi/project/ys/service/impl/HyjyxxServiceImpl.java
+132
-0
No files found.
src/main/java/com/ruoyi/project/ys/controller/HyjyxxController.java
View file @
7f298ab2
...
...
@@ -121,4 +121,14 @@ public class HyjyxxController extends BaseController
return
AjaxResult
.
success
(
"会议转录任务已启动,请稍后查看结果"
);
}
/**
* 获取会议信息详细信息
*/
@GetMapping
(
value
=
"hyxx/{id}"
)
public
AjaxResult
hyxx
(
@PathVariable
(
"id"
)
Long
id
)
{
return
success
(
hyjyxxService
.
selectHyjyxxById_xq
(
id
));
}
}
src/main/java/com/ruoyi/project/ys/service/IHyjyxxService.java
View file @
7f298ab2
...
...
@@ -60,4 +60,6 @@ public interface IHyjyxxService
public
int
deleteHyjyxxById
(
Long
id
);
public
int
hyzl
(
Long
id
);
public
Hyjyxx
selectHyjyxxById_xq
(
Long
id
);
}
src/main/java/com/ruoyi/project/ys/service/impl/HyjyxxServiceImpl.java
View file @
7f298ab2
package
com
.
ruoyi
.
project
.
ys
.
service
.
impl
;
import
java.util.ArrayList
;
import
java.util.Date
;
import
java.util.List
;
import
com.ruoyi.common.utils.DateUtils
;
import
com.ruoyi.framework.config.RuoYiConfig
;
import
com.ruoyi.project.ys.domain.HyjyxxFile
;
import
com.ruoyi.project.ys.mapper.HyjyxxFileMapper
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
com.ruoyi.project.ys.mapper.HyjyxxMapper
;
...
...
@@ -20,6 +24,13 @@ import java.nio.charset.StandardCharsets;
import
java.util.Map
;
import
com.fasterxml.jackson.databind.JsonNode
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
com.fasterxml.jackson.core.type.TypeReference
;
import
com.fasterxml.jackson.databind.node.ObjectNode
;
import
java.time.Duration
;
import
java.time.LocalDateTime
;
import
java.time.format.DateTimeFormatter
;
import
java.time.format.DateTimeParseException
;
import
java.time.ZoneId
;
import
static
com
.
ruoyi
.
common
.
utils
.
SecurityUtils
.
getUserId
;
...
...
@@ -209,6 +220,127 @@ public class HyjyxxServiceImpl implements IHyjyxxService
}
}
@Autowired
private
HyjyxxFileMapper
hyjyxxFileMapper
;
private
static
final
DateTimeFormatter
TIME_FORMATTER
=
DateTimeFormatter
.
ofPattern
(
"yyyy-MM-dd HH:mm:ss.SS"
);
// 修正:最后一个说话人的区间结束时间(用一个远大于实际可能的时间,等效于“无穷大”)
private
static
final
LocalDateTime
MAX_TIME
=
LocalDateTime
.
of
(
2100
,
1
,
1
,
0
,
0
,
0
);
// 2100年1月1日
@Override
public
Hyjyxx
selectHyjyxxById_xq
(
Long
id
)
{
Hyjyxx
hyxx
=
hyjyxxMapper
.
selectHyjyxxById
(
id
);
HyjyxxFile
file
=
new
HyjyxxFile
();
file
.
setHyid
(
id
);
List
<
HyjyxxFile
>
fileList
=
hyjyxxFileMapper
.
selectHyjyxxFileList
(
file
);
String
originalJson
=
hyxx
.
getYwBzh
();
Date
hysj
=
hyxx
.
getJxwcsj
();
try
{
// 初始化ObjectMapper
ObjectMapper
objectMapper
=
new
ObjectMapper
();
// 解析JSON为ObjectNode列表(便于修改)
List
<
ObjectNode
>
speakerList
=
objectMapper
.
readValue
(
originalJson
,
new
TypeReference
<
List
<
ObjectNode
>>()
{}
);
// 解析录音开始时间
LocalDateTime
startTime
=
hysj
.
toInstant
()
.
atZone
(
ZoneId
.
of
(
"Asia/Shanghai"
))
.
toLocalDateTime
();
// 遍历每个说话人,计算并添加真实时间
for
(
ObjectNode
speakerNode
:
speakerList
)
{
// 获取timestamp字段
String
timestamp
=
speakerNode
.
get
(
"timestamp"
).
asText
();
// 计算真实时间
LocalDateTime
realTime
=
calculateRealTime
(
startTime
,
timestamp
);
// 这个人说话开始
// 新增realTime字段
speakerNode
.
put
(
"realTime"
,
realTime
.
format
(
TIME_FORMATTER
));
}
// 遍历每个说话人,计算并添加真实时间
for
(
int
i
=
0
;
i
<
speakerList
.
size
();
i
++){
ObjectNode
speakerNode
=
speakerList
.
get
(
i
);
String
realTime
=
speakerNode
.
get
(
"realTime"
).
asText
();
LocalDateTime
currentStartTime
=
parseStringToLocalDateTime
(
realTime
);
LocalDateTime
intervalEnd
;
// 区间结束时间
// 构建区间:当前说话人开始时间 → 下一个说话人开始时间(最后一个说话人特殊处理)
if
(
i
<
speakerList
.
size
()
-
1
)
{
// 非最后一个说话人:区间结束 = 下一个说话人开始时间
intervalEnd
=
parseStringToLocalDateTime
(
speakerList
.
get
(
i
+
1
).
get
(
"realTime"
).
asText
());
}
else
{
// 最后一个说话人:区间结束 = 当前开始时间 + 延长时间
intervalEnd
=
MAX_TIME
;
}
List
<
String
>
matchedScreenshots
=
new
ArrayList
<>();
for
(
HyjyxxFile
hyjyxxFile
:
fileList
)
{
Date
fileTime
=
hyjyxxFile
.
getFileTime
();
LocalDateTime
screenTime
=
fileTime
.
toInstant
()
.
atZone
(
ZoneId
.
of
(
"Asia/Shanghai"
))
.
toLocalDateTime
();
if
(
screenTime
.
isAfter
(
currentStartTime
)
||
screenTime
.
isEqual
(
currentStartTime
))
{
if
(
screenTime
.
isBefore
(
intervalEnd
))
{
matchedScreenshots
.
add
(
hyjyxxFile
.
getFileUrl
());
}
}
}
speakerNode
.
putPOJO
(
"file"
,
matchedScreenshots
);
}
// 输出处理后的JSON(可写入文件或返回)
String
resultJson
=
objectMapper
.
writerWithDefaultPrettyPrinter
().
writeValueAsString
(
speakerList
);
System
.
out
.
println
(
"处理后带真实时间的JSON:"
);
System
.
out
.
println
(
resultJson
);
hyxx
.
setYwBzh
(
resultJson
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
return
hyxx
;
}
/**
* 计算真实时间:开始时间 + timestamp偏移量
*/
private
static
LocalDateTime
calculateRealTime
(
LocalDateTime
startTime
,
String
timestamp
)
{
try
{
// 拆分timestamp为 时:分:秒.毫秒(如"00:00:25.86" → 0时0分25秒86毫秒)
String
[]
timeParts
=
timestamp
.
split
(
":"
);
int
hours
=
Integer
.
parseInt
(
timeParts
[
0
]);
int
minutes
=
Integer
.
parseInt
(
timeParts
[
1
]);
String
[]
secAndMs
=
timeParts
[
2
].
split
(
"\\."
);
int
seconds
=
Integer
.
parseInt
(
secAndMs
[
0
]);
int
millis
=
secAndMs
.
length
>
1
?
Integer
.
parseInt
(
secAndMs
[
1
])
:
0
;
// 计算总偏移量(毫秒)
long
totalMillis
=
hours
*
3600000L
+
minutes
*
60000L
+
seconds
*
1000L
+
millis
;
// 开始时间 + 偏移量
return
startTime
.
plus
(
Duration
.
ofMillis
(
totalMillis
));
}
catch
(
ArrayIndexOutOfBoundsException
|
NumberFormatException
e
)
{
throw
new
DateTimeParseException
(
"解析timestamp失败:"
+
timestamp
,
timestamp
,
0
);
}
}
/**
* 工具方法:将String时间解析为LocalDateTime(处理解析异常)
*/
private
static
LocalDateTime
parseStringToLocalDateTime
(
String
timeStr
)
{
try
{
return
LocalDateTime
.
parse
(
timeStr
,
TIME_FORMATTER
);
}
catch
(
DateTimeParseException
e
)
{
System
.
err
.
println
(
"时间解析失败:"
+
timeStr
+
",格式需为"
+
TIME_FORMATTER
);
return
null
;
// 解析失败返回null,后续跳过该数据
}
}
}
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