Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wecloud_im_server
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
hewei
wecloud_im_server
Commits
b31dcf5d
Commit
b31dcf5d
authored
Jun 09, 2022
by
吴星煌
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
音视频通讯的语音通话和视频通话时长统计
parent
86c95259
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
203 additions
and
17 deletions
+203
-17
client/src/main/java/com/wecloud/imserver/client/api/ImOverview.java
+3
-1
client/src/main/java/com/wecloud/imserver/client/model/vo/RtcRecordVo.java
+14
-0
core/src/main/java/com/wecloud/im/appmanager/ImOverviewImpl.java
+112
-16
core/src/main/java/com/wecloud/im/appmanager/ImRtcTranscribeImpl.java
+13
-0
core/src/main/java/com/wecloud/im/entity/ImRtcTranscribe.java
+44
-0
core/src/main/java/com/wecloud/im/mapper/ImRtcTranscribeMapper.java
+9
-0
core/src/main/java/com/wecloud/im/service/ImRtcTranscribeService.java
+8
-0
No files found.
client/src/main/java/com/wecloud/imserver/client/api/ImOverview.java
View file @
b31dcf5d
...
@@ -2,10 +2,10 @@ package com.wecloud.imserver.client.api;
...
@@ -2,10 +2,10 @@ package com.wecloud.imserver.client.api;
import
com.wecloud.imserver.client.model.vo.LineChart
;
import
com.wecloud.imserver.client.model.vo.LineChart
;
import
com.wecloud.imserver.client.model.vo.OverviewVo
;
import
com.wecloud.imserver.client.model.vo.OverviewVo
;
import
com.wecloud.imserver.client.model.vo.RtcRecordVo
;
import
com.wecloud.imserver.client.model.vo.StatisticsVo
;
import
com.wecloud.imserver.client.model.vo.StatisticsVo
;
import
java.time.LocalDateTime
;
import
java.time.LocalDateTime
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.List
;
public
interface
ImOverview
{
public
interface
ImOverview
{
...
@@ -17,4 +17,6 @@ public interface ImOverview {
...
@@ -17,4 +17,6 @@ public interface ImOverview {
//用户统计折线图
//用户统计折线图
List
<
LineChart
>
activeUser
(
Long
appId
,
LocalDateTime
start
,
LocalDateTime
end
);
List
<
LineChart
>
activeUser
(
Long
appId
,
LocalDateTime
start
,
LocalDateTime
end
);
//音视频资讯的数量统计
RtcRecordVo
RtcStatistics
(
Long
appId
,
LocalDateTime
date
);
}
}
client/src/main/java/com/wecloud/imserver/client/model/vo/RtcRecordVo.java
0 → 100644
View file @
b31dcf5d
package
com
.
wecloud
.
imserver
.
client
.
model
.
vo
;
import
lombok.Data
;
import
java.util.List
;
@Data
public
class
RtcRecordVo
{
private
List
<
LineChart
>
video
;
private
List
<
LineChart
>
voice
;
private
List
<
LineChart
>
videoTranscribe
;
private
List
<
LineChart
>
voiceTranscribe
;
}
core/src/main/java/com/wecloud/im/appmanager/ImOverviewImpl.java
View file @
b31dcf5d
package
com
.
wecloud
.
im
.
appmanager
;
package
com
.
wecloud
.
im
.
appmanager
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.wecloud.im.entity.ImClient
;
import
com.wecloud.im.entity.*
;
import
com.wecloud.im.entity.ImConversation
;
import
com.wecloud.im.entity.ImMessage
;
import
com.wecloud.im.entity.ImStatistics
;
import
com.wecloud.im.sdk.enums.ChatTypeEnum
;
import
com.wecloud.im.sdk.enums.ChatTypeEnum
;
import
com.wecloud.im.service.ImClientService
;
import
com.wecloud.im.service.*
;
import
com.wecloud.im.service.ImConversationService
;
import
com.wecloud.im.ws.enums.MsgTypeEnum
;
import
com.wecloud.im.service.ImMessageService
;
import
com.wecloud.im.service.ImStatisticsService
;
import
com.wecloud.imserver.client.api.ImOverview
;
import
com.wecloud.imserver.client.api.ImOverview
;
import
com.wecloud.imserver.client.model.vo.LineChart
;
import
com.wecloud.imserver.client.model.vo.LineChart
;
import
com.wecloud.imserver.client.model.vo.OverviewVo
;
import
com.wecloud.imserver.client.model.vo.OverviewVo
;
import
com.wecloud.imserver.client.model.vo.RtcRecordVo
;
import
com.wecloud.imserver.client.model.vo.StatisticsVo
;
import
com.wecloud.imserver.client.model.vo.StatisticsVo
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.dubbo.config.annotation.DubboService
;
import
org.apache.dubbo.config.annotation.DubboService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
java.time.LocalDate
;
import
java.time.*
;
import
java.time.LocalDateTime
;
import
java.time.LocalTime
;
import
java.time.temporal.ChronoUnit
;
import
java.time.temporal.ChronoUnit
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.List
;
...
@@ -40,6 +34,10 @@ public class ImOverviewImpl implements ImOverview {
...
@@ -40,6 +34,10 @@ public class ImOverviewImpl implements ImOverview {
private
ImConversationService
imConversationService
;
private
ImConversationService
imConversationService
;
@Autowired
@Autowired
private
ImStatisticsService
imStatisticsService
;
private
ImStatisticsService
imStatisticsService
;
@Autowired
private
ImRtcRecordService
imRtcRecordService
;
@Autowired
private
ImRtcTranscribeService
imRtcTranscribeService
;
@Override
@Override
public
OverviewVo
overview
(
Long
appId
)
{
public
OverviewVo
overview
(
Long
appId
)
{
...
@@ -86,7 +84,7 @@ public class ImOverviewImpl implements ImOverview {
...
@@ -86,7 +84,7 @@ public class ImOverviewImpl implements ImOverview {
@Override
@Override
public
StatisticsVo
groupStatistics
(
Long
appId
,
LocalDateTime
start
,
LocalDateTime
end
)
{
public
StatisticsVo
groupStatistics
(
Long
appId
,
LocalDateTime
start
,
LocalDateTime
end
)
{
if
(
start
==
null
&&
end
==
null
){
if
(
start
==
null
&&
end
==
null
){
start
=
LocalDateTime
.
of
(
LocalDate
.
now
(),
LocalTime
.
MIN
.
minusHours
(
24
*
8
)
);
start
=
LocalDateTime
.
of
(
LocalDate
.
now
(),
LocalTime
.
MIN
).
minusDays
(
8
);
end
=
start
.
plusDays
(
7
);
end
=
start
.
plusDays
(
7
);
}
}
...
@@ -113,8 +111,15 @@ public class ImOverviewImpl implements ImOverview {
...
@@ -113,8 +111,15 @@ public class ImOverviewImpl implements ImOverview {
);
);
statisticsVo
.
setNewGroup
(
newGroup
);
statisticsVo
.
setNewGroup
(
newGroup
);
//todo 解散群组数,暂时未能查询
//解散群组数(前一天)
statisticsVo
.
setDismissGroup
(
0
);
Integer
dismissGroup
=
imMessageService
.
count
(
new
LambdaQueryWrapper
<
ImMessage
>()
.
eq
(
ImMessage:
:
getFkAppid
,
appId
)
.
eq
(
ImMessage:
:
getMsgType
,
MsgTypeEnum
.
CONVERSATION_DISBAND
.
getUriCode
())
.
between
(
ImMessage:
:
getCreateTime
,
LocalDateTime
.
of
(
LocalDate
.
now
(),
LocalTime
.
MIN
).
minusDays
(
1
),
LocalDateTime
.
of
(
LocalDate
.
now
(),
LocalTime
.
MAX
).
minusDays
(
1
))
);
statisticsVo
.
setDismissGroup
(
dismissGroup
);
//活跃群组平均成员数
//活跃群组平均成员数
Integer
avgMember
=
statistics
==
null
?
0
:
statistics
.
getGroupMember
()/
statistics
.
getData
();
Integer
avgMember
=
statistics
==
null
?
0
:
statistics
.
getGroupMember
()/
statistics
.
getData
();
...
@@ -148,8 +153,19 @@ public class ImOverviewImpl implements ImOverview {
...
@@ -148,8 +153,19 @@ public class ImOverviewImpl implements ImOverview {
}
}
statisticsVo
.
setNewGroupLine
(
newGroupLine
);
statisticsVo
.
setNewGroupLine
(
newGroupLine
);
//
todo
解散群组折线图
//解散群组折线图
List
<
LineChart
>
dismissGroupLine
=
new
ArrayList
<>();
List
<
LineChart
>
dismissGroupLine
=
new
ArrayList
<>();
for
(
int
i
=
days
.
intValue
();
i
>
0
;
i
--){
LineChart
lineChart
=
new
LineChart
();
Integer
count
=
imMessageService
.
count
(
new
LambdaQueryWrapper
<
ImMessage
>()
.
eq
(
ImMessage:
:
getFkAppid
,
appId
)
.
eq
(
ImMessage:
:
getMsgType
,
MsgTypeEnum
.
CONVERSATION_DISBAND
.
getUriCode
())
.
between
(
ImMessage:
:
getCreateTime
,
LocalDateTime
.
of
(
LocalDate
.
now
(),
LocalTime
.
MIN
).
minusDays
(
i
),
LocalDateTime
.
of
(
LocalDate
.
now
(),
LocalTime
.
MIN
).
minusDays
(
i
-
1
))
);
lineChart
.
setDate
(
LocalDateTime
.
of
(
LocalDate
.
now
(),
LocalTime
.
MIN
).
minusDays
(
i
));
lineChart
.
setCount
(
count
);
dismissGroupLine
.
add
(
lineChart
);
}
statisticsVo
.
setDismissGroupLine
(
dismissGroupLine
);
statisticsVo
.
setDismissGroupLine
(
dismissGroupLine
);
//活跃群组平均成员数
//活跃群组平均成员数
...
@@ -165,10 +181,11 @@ public class ImOverviewImpl implements ImOverview {
...
@@ -165,10 +181,11 @@ public class ImOverviewImpl implements ImOverview {
return
statisticsVo
;
return
statisticsVo
;
}
}
@Override
@Override
public
List
<
LineChart
>
activeUser
(
Long
appId
,
LocalDateTime
start
,
LocalDateTime
end
)
{
public
List
<
LineChart
>
activeUser
(
Long
appId
,
LocalDateTime
start
,
LocalDateTime
end
)
{
if
(
start
==
null
&&
end
==
null
){
if
(
start
==
null
&&
end
==
null
){
start
=
LocalDateTime
.
of
(
LocalDate
.
now
(),
LocalTime
.
MIN
.
minusHours
(
24
*
8
)
);
start
=
LocalDateTime
.
of
(
LocalDate
.
now
(),
LocalTime
.
MIN
).
minusDays
(
8
);
end
=
start
.
plusDays
(
7
);
end
=
start
.
plusDays
(
7
);
}
}
//活跃用户数
//活跃用户数
...
@@ -182,4 +199,83 @@ public class ImOverviewImpl implements ImOverview {
...
@@ -182,4 +199,83 @@ public class ImOverviewImpl implements ImOverview {
}
}
return
activeUser
;
return
activeUser
;
}
}
@Override
public
RtcRecordVo
RtcStatistics
(
Long
appId
,
LocalDateTime
date
)
{
RtcRecordVo
rtcRecordVo
=
new
RtcRecordVo
();
List
<
LineChart
>
video
=
new
ArrayList
<>();
List
<
LineChart
>
voice
=
new
ArrayList
<>();
List
<
LineChart
>
videoTranscribe
=
new
ArrayList
<>();
List
<
LineChart
>
voiceTranscribe
=
new
ArrayList
<>();
for
(
int
i
=
0
;
i
<
ChronoUnit
.
DAYS
.
between
(
date
,
date
.
plusMonths
(
1
));
i
++)
{
//每天的视频通话数据==============================
LineChart
videoLineChart
=
new
LineChart
();
LocalDateTime
start
=
date
.
plusDays
(
i
);
LocalDateTime
end
=
date
.
plusDays
(
i
+
1
);
Integer
videoLength
=
0
;
List
<
ImRtcRecord
>
imVideoList
=
imRtcRecordService
.
list
(
new
LambdaQueryWrapper
<
ImRtcRecord
>()
.
eq
(
ImRtcRecord:
:
getFkAppid
,
appId
)
.
eq
(
ImRtcRecord:
:
getCallType
,
1
)
.
between
(
ImRtcRecord:
:
getStartTime
,
start
,
end
)
);
for
(
ImRtcRecord
imRtcRecord
:
imVideoList
)
{
Instant
startInstant
=
imRtcRecord
.
getStartTime
().
toInstant
();
Instant
endInstant
=
imRtcRecord
.
getEndTime
().
toInstant
();
ZoneId
zone
=
ZoneId
.
systemDefault
();
LocalDateTime
startTime
=
LocalDateTime
.
ofInstant
(
startInstant
,
zone
);
LocalDateTime
endTime
=
LocalDateTime
.
ofInstant
(
endInstant
,
zone
);
Long
between
=
ChronoUnit
.
MINUTES
.
between
(
startTime
,
endTime
);
if
(
startTime
.
getSecond
()
!=
endTime
.
getSecond
()){
between
+=
1
;
}
videoLength
+=
between
.
intValue
();
}
videoLineChart
.
setCount
(
videoLength
);
videoLineChart
.
setDate
(
start
);
video
.
add
(
videoLineChart
);
//每天的音频通话数据==============================
LineChart
voiceLineChart
=
new
LineChart
();
Integer
voiceLength
=
0
;
List
<
ImRtcRecord
>
imVoiceList
=
imRtcRecordService
.
list
(
new
LambdaQueryWrapper
<
ImRtcRecord
>()
.
eq
(
ImRtcRecord:
:
getFkAppid
,
appId
)
.
eq
(
ImRtcRecord:
:
getCallType
,
2
)
.
between
(
ImRtcRecord:
:
getStartTime
,
start
,
end
)
);
for
(
ImRtcRecord
imRtcRecord
:
imVoiceList
)
{
Instant
startInstant
=
imRtcRecord
.
getStartTime
().
toInstant
();
Instant
endInstant
=
imRtcRecord
.
getEndTime
().
toInstant
();
ZoneId
zone
=
ZoneId
.
systemDefault
();
LocalDateTime
startTime
=
LocalDateTime
.
ofInstant
(
startInstant
,
zone
);
LocalDateTime
endTime
=
LocalDateTime
.
ofInstant
(
endInstant
,
zone
);
Long
between
=
ChronoUnit
.
MINUTES
.
between
(
startTime
,
endTime
);
if
(
startTime
.
getSecond
()
!=
endTime
.
getSecond
()){
between
+=
1
;
}
voiceLength
+=
between
.
intValue
();
}
voiceLineChart
.
setDate
(
start
);
voiceLineChart
.
setCount
(
voiceLength
);
voice
.
add
(
voiceLineChart
);
//每天的视频通话录制=============================
List
<
ImRtcTranscribe
>
imRtcTranscribeList
=
imRtcTranscribeService
.
list
(
new
LambdaQueryWrapper
<
ImRtcTranscribe
>()
.
between
(
ImRtcTranscribe:
:
getStartTime
,
start
,
end
)
.
groupBy
(
ImRtcTranscribe:
:
getFkRecordId
)
.
select
(
ImRtcTranscribe:
:
getFkRecordId
)
);
}
rtcRecordVo
.
setVideo
(
video
);
rtcRecordVo
.
setVoice
(
voice
);
return
rtcRecordVo
;
}
}
}
core/src/main/java/com/wecloud/im/appmanager/ImRtcTranscribeImpl.java
0 → 100644
View file @
b31dcf5d
package
com
.
wecloud
.
im
.
appmanager
;
import
com.wecloud.im.entity.ImRtcTranscribe
;
import
com.wecloud.im.mapper.ImRtcTranscribeMapper
;
import
com.wecloud.im.service.ImRtcTranscribeService
;
import
io.geekidea.springbootplus.framework.common.service.impl.BaseServiceImpl
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.stereotype.Service
;
@Slf4j
@Service
public
class
ImRtcTranscribeImpl
extends
BaseServiceImpl
<
ImRtcTranscribeMapper
,
ImRtcTranscribe
>
implements
ImRtcTranscribeService
{
}
core/src/main/java/com/wecloud/im/entity/ImRtcTranscribe.java
0 → 100644
View file @
b31dcf5d
package
com
.
wecloud
.
im
.
entity
;
import
com.baomidou.mybatisplus.annotation.IdType
;
import
com.baomidou.mybatisplus.annotation.TableId
;
import
io.geekidea.springbootplus.framework.common.entity.BaseEntity
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
import
lombok.EqualsAndHashCode
;
import
lombok.experimental.Accessors
;
import
javax.validation.constraints.NotNull
;
import
java.time.LocalDateTime
;
@Data
@Accessors
(
chain
=
true
)
@EqualsAndHashCode
(
callSuper
=
true
)
@ApiModel
(
value
=
"rtc录制时长记录"
)
public
class
ImRtcTranscribe
extends
BaseEntity
{
private
static
final
long
serialVersionUID
=
1L
;
@NotNull
(
message
=
"id不能为空"
)
@ApiModelProperty
(
"id"
)
@TableId
(
value
=
"id"
,
type
=
IdType
.
INPUT
)
private
Long
id
;
@ApiModelProperty
(
"im_rtc_record表主键id"
)
private
Long
fkRecordId
;
@ApiModelProperty
(
"录制开始时间"
)
private
LocalDateTime
startTime
;
@ApiModelProperty
(
"录制结束时间"
)
private
LocalDateTime
endTime
;
@ApiModelProperty
(
"创建时间"
)
private
LocalDateTime
createTime
;
@ApiModelProperty
(
"修改时间"
)
private
LocalDateTime
updateTime
;
}
core/src/main/java/com/wecloud/im/mapper/ImRtcTranscribeMapper.java
0 → 100644
View file @
b31dcf5d
package
com
.
wecloud
.
im
.
mapper
;
import
com.baomidou.mybatisplus.core.mapper.BaseMapper
;
import
com.wecloud.im.entity.ImRtcTranscribe
;
import
org.springframework.stereotype.Repository
;
@Repository
public
interface
ImRtcTranscribeMapper
extends
BaseMapper
<
ImRtcTranscribe
>
{
}
core/src/main/java/com/wecloud/im/service/ImRtcTranscribeService.java
0 → 100644
View file @
b31dcf5d
package
com
.
wecloud
.
im
.
service
;
import
com.wecloud.im.entity.ImRtcTranscribe
;
import
io.geekidea.springbootplus.framework.common.service.BaseService
;
public
interface
ImRtcTranscribeService
extends
BaseService
<
ImRtcTranscribe
>
{
}
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