Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
涂亚平
/
subsidy
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 356c09ea
authored
Feb 05, 2022
by
涂亚平
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
视频纬度报表
1 parent
17db9bad
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
262 additions
and
34 deletions
src/main/java/com/subsidy/controller/MemberStudyLengthController.java
src/main/java/com/subsidy/controller/VodPlayHistoryController.java
src/main/java/com/subsidy/dto/vod/RemainSecondsDTO.java
src/main/java/com/subsidy/mapper/MemberStudyLengthMapper.java
src/main/java/com/subsidy/model/MemberStudyLengthDO.java
src/main/java/com/subsidy/service/MemberStudyLengthService.java
src/main/java/com/subsidy/service/VodPlayHistoryService.java
src/main/java/com/subsidy/service/impl/MemberStudyLengthServiceImpl.java
src/main/java/com/subsidy/service/impl/SignInRecordServiceImpl.java
src/main/java/com/subsidy/service/impl/VodPlayHistoryServiceImpl.java
src/main/resources/application.properties
src/main/resources/mapper/CourseContentMapper.xml
src/main/resources/mapper/MemberStudyLengthMapper.xml
src/main/java/com/subsidy/controller/MemberStudyLengthController.java
0 → 100644
View file @
356c09e
package
com
.
subsidy
.
controller
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
import
io.swagger.annotations.Api
;
/**
* <p>
* 前端控制器
* </p>
*
* @author DengMin
* @since 2022-01-28
*/
@RestController
@Api
(
tags
=
""
)
@RequestMapping
(
"/member-study-length-do"
)
public
class
MemberStudyLengthController
{
}
src/main/java/com/subsidy/controller/VodPlayHistoryController.java
View file @
356c09e
...
...
@@ -4,6 +4,7 @@ package com.subsidy.controller;
import
com.alibaba.fastjson.JSON
;
import
com.subsidy.common.ResponseData
;
import
com.subsidy.common.ResponseVO
;
import
com.subsidy.dto.vod.RemainSecondsDTO
;
import
com.subsidy.dto.vod.SignDatePlaysDTO
;
import
com.subsidy.dto.vod.FixDataTwoDTO
;
import
com.subsidy.model.VodPlayHistoryDO
;
...
...
@@ -46,12 +47,20 @@ public class VodPlayHistoryController {
}
@PostMapping
(
"dataFix"
)
@ApiOperation
(
"每个视频都看一次"
)
public
void
dadaFix
(
@RequestBody
SignDatePlaysDTO
dataFixDTO
){
vodPlayHistoryService
.
dataFix
(
dataFixDTO
);
}
@PostMapping
(
"signDatePlays"
)
@ApiOperation
(
"每天接着看几个视频 接dataFix的"
)
public
void
signDatePlays
(
@RequestBody
SignDatePlaysDTO
signDatePlaysDTO
){
vodPlayHistoryService
.
signDatePlays
(
signDatePlaysDTO
);
}
@PostMapping
(
"remainSeconds"
)
@ApiOperation
(
"每个视频先看一下,然后剩余时长分配到每天里"
)
public
void
remainSeconds
(
@RequestBody
RemainSecondsDTO
remainSecondsDTO
){
vodPlayHistoryService
.
remainSeconds
(
remainSecondsDTO
);
}
}
src/main/java/com/subsidy/dto/vod/RemainSecondsDTO.java
0 → 100644
View file @
356c09e
package
com
.
subsidy
.
dto
.
vod
;
import
lombok.Data
;
@Data
public
class
RemainSecondsDTO
{
private
Long
classId
;
}
src/main/java/com/subsidy/mapper/MemberStudyLengthMapper.java
0 → 100644
View file @
356c09e
package
com
.
subsidy
.
mapper
;
import
com.subsidy.model.MemberStudyLengthDO
;
import
com.baomidou.mybatisplus.core.mapper.BaseMapper
;
import
org.springframework.stereotype.Repository
;
/**
* <p>
* Mapper 接口
* </p>
*
* @author DengMin
* @since 2022-01-28
*/
@Repository
public
interface
MemberStudyLengthMapper
extends
BaseMapper
<
MemberStudyLengthDO
>
{
}
src/main/java/com/subsidy/model/MemberStudyLengthDO.java
0 → 100644
View file @
356c09e
package
com
.
subsidy
.
model
;
import
com.subsidy.util.BaseModel
;
import
com.baomidou.mybatisplus.annotation.TableName
;
import
com.baomidou.mybatisplus.annotation.IdType
;
import
com.baomidou.mybatisplus.annotation.TableId
;
import
lombok.Data
;
import
lombok.EqualsAndHashCode
;
/**
* <p>
*
* </p>
*
* @author DengMin
* @since 2022-01-28
*/
@Data
@EqualsAndHashCode
(
callSuper
=
true
)
@TableName
(
"member_study_length"
)
public
class
MemberStudyLengthDO
extends
BaseModel
{
private
static
final
long
serialVersionUID
=
1L
;
@TableId
(
value
=
"id"
,
type
=
IdType
.
AUTO
)
private
Long
id
;
private
Long
memberId
;
private
Integer
totalLength
;
}
src/main/java/com/subsidy/service/MemberStudyLengthService.java
0 → 100644
View file @
356c09e
package
com
.
subsidy
.
service
;
import
com.subsidy.model.MemberStudyLengthDO
;
import
com.baomidou.mybatisplus.extension.service.IService
;
/**
* <p>
* 服务类
* </p>
*
* @author DengMin
* @since 2022-01-28
*/
public
interface
MemberStudyLengthService
extends
IService
<
MemberStudyLengthDO
>
{
}
src/main/java/com/subsidy/service/VodPlayHistoryService.java
View file @
356c09e
package
com
.
subsidy
.
service
;
import
com.subsidy.dto.vod.RemainSecondsDTO
;
import
com.subsidy.dto.vod.SignDatePlaysDTO
;
import
com.subsidy.dto.vod.FixDataTwoDTO
;
import
com.subsidy.model.VodPlayHistoryDO
;
...
...
@@ -22,4 +23,6 @@ public interface VodPlayHistoryService extends IService<VodPlayHistoryDO> {
void
dataFix
(
SignDatePlaysDTO
dataFixDTO
);
void
signDatePlays
(
SignDatePlaysDTO
dataFixDTO
);
void
remainSeconds
(
RemainSecondsDTO
remainSecondsDTO
);
}
src/main/java/com/subsidy/service/impl/MemberStudyLengthServiceImpl.java
0 → 100644
View file @
356c09e
package
com
.
subsidy
.
service
.
impl
;
import
com.subsidy.model.MemberStudyLengthDO
;
import
com.subsidy.mapper.MemberStudyLengthMapper
;
import
com.subsidy.service.MemberStudyLengthService
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
org.springframework.stereotype.Service
;
/**
* <p>
* 服务实现类
* </p>
*
* @author DengMin
* @since 2022-01-28
*/
@Service
public
class
MemberStudyLengthServiceImpl
extends
ServiceImpl
<
MemberStudyLengthMapper
,
MemberStudyLengthDO
>
implements
MemberStudyLengthService
{
}
src/main/java/com/subsidy/service/impl/SignInRecordServiceImpl.java
View file @
356c09e
...
...
@@ -81,7 +81,7 @@ public class SignInRecordServiceImpl extends ServiceImpl<SignInRecordMapper, Sig
List
<
ClassDictDO
>
classDictDOS
=
classMemberMappingMapper
.
getMemberClass
(
signInRecordDO
.
getMemberId
());
for
(
ClassDictDO
classDictDO
:
classDictDOS
)
{
redisUtil
.
set
(
RedisPrefixConstant
.
SUBSIDY_SIGN_INFO_PREFIX
+
signInRecordDO
.
getMemberId
()
+
":classId:"
+
classDictDO
.
getId
()
+
":"
+
DateFormatUtil
.
format
(
new
Date
(),
"yyyy
MM
dd"
)
+
":"
+
System
.
currentTimeMillis
(),
null
);
redisUtil
.
set
(
RedisPrefixConstant
.
SUBSIDY_SIGN_INFO_PREFIX
+
signInRecordDO
.
getMemberId
()
+
":classId:"
+
classDictDO
.
getId
()
+
":"
+
DateFormatUtil
.
format
(
new
Date
(),
"yyyy
-MM-
dd"
)
+
":"
+
System
.
currentTimeMillis
(),
null
);
}
return
ConstantUtils
.
ADD_SUCCESS
;
...
...
@@ -152,6 +152,8 @@ public class SignInRecordServiceImpl extends ServiceImpl<SignInRecordMapper, Sig
signInRecordDO
.
getClassId
()+
":"
+
signInRecordDO
.
getSignInDate
().
toString
().
split
(
"T"
)[
0
]+
":"
+
signInRecordDO
.
getSignInDate
().
toInstant
(
ZoneOffset
.
of
(
"+8"
)).
toEpochMilli
(),
signInRecordDO
);
}
// redisUtil.scan("*20220126*");
// redisUtil.("*20220126*");
}
...
...
src/main/java/com/subsidy/service/impl/VodPlayHistoryServiceImpl.java
View file @
356c09e
...
...
@@ -3,18 +3,10 @@ package com.subsidy.service.impl;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
com.subsidy.dto.vod.FixDataTwoDTO
;
import
com.subsidy.dto.vod.RemainSecondsDTO
;
import
com.subsidy.dto.vod.SignDatePlaysDTO
;
import
com.subsidy.mapper.ClassDictMapper
;
import
com.subsidy.mapper.ClassMemberMappingMapper
;
import
com.subsidy.mapper.CourseContentMapper
;
import
com.subsidy.mapper.SignInRecordMapper
;
import
com.subsidy.mapper.VodDictMapper
;
import
com.subsidy.mapper.VodPlayHistoryMapper
;
import
com.subsidy.model.ClassDictDO
;
import
com.subsidy.model.ClassMemberMappingDO
;
import
com.subsidy.model.SignInRecordDO
;
import
com.subsidy.model.VodDictDO
;
import
com.subsidy.model.VodPlayHistoryDO
;
import
com.subsidy.mapper.*
;
import
com.subsidy.model.*
;
import
com.subsidy.service.VodPlayHistoryService
;
import
com.subsidy.util.ConstantUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
...
@@ -56,6 +48,9 @@ public class VodPlayHistoryServiceImpl extends ServiceImpl<VodPlayHistoryMapper,
@Autowired
private
VodDictMapper
vodDictMapper
;
@Autowired
private
MemberStudyLengthMapper
memberStudyLengthMapper
;
public
String
insertHistory
(
VodPlayHistoryDO
vodPlayHistoryDO
)
{
vodPlayHistoryDO
.
setPlayCount
(
1
);
this
.
baseMapper
.
insert
(
vodPlayHistoryDO
);
...
...
@@ -298,31 +293,108 @@ public class VodPlayHistoryServiceImpl extends ServiceImpl<VodPlayHistoryMapper,
}
}
public
int
severalPlays
(
Long
classId
,
Long
memberId
,
Long
vodId
,
int
playLength
,
LocalDateTime
localDateTime
,
List
<
VodDictDO
>
vodDictDOS
)
{
Random
random
=
new
Random
();
int
counts
=
random
.
nextInt
(
3
)
+
1
;
for
(
int
i
=
0
;
i
<
counts
;
i
++)
{
VodPlayHistoryDO
vodPlayHistoryDO
=
new
VodPlayHistoryDO
();
Random
random1
=
new
Random
();
int
j
=
random1
.
nextInt
(
vodDictDOS
.
size
());
vodPlayHistoryDO
.
setPlayCount
(
1
);
vodPlayHistoryDO
.
setClassId
(
classId
);
vodPlayHistoryDO
.
setMemberId
(
memberId
);
// vodPlayHistoryDO.setPlayRecord(h);
vodPlayHistoryDO
.
setPlayLength
(
new
Random
().
nextInt
(
vodPlayHistoryDO
.
getPlayRecord
()));
playLength
+=
vodPlayHistoryDO
.
getPlayLength
();
vodPlayHistoryDO
.
setVodId
(
vodId
);
vodPlayHistoryDO
.
setPlayDate
(
localDateTime
.
plusSeconds
(
playLength
));
vodPlayHistoryMapper
.
insert
(
vodPlayHistoryDO
);
public
void
remainSeconds
(
RemainSecondsDTO
remainSecondsDTO
)
{
Long
classId
=
remainSecondsDTO
.
getClassId
();
ClassDictDO
classDictDO
=
classDictMapper
.
selectById
(
classId
);
//找到班级里的学生
List
<
ClassMemberMappingDO
>
classMemberMappingDOS
=
classMemberMappingMapper
.
selectList
(
new
QueryWrapper
<
ClassMemberMappingDO
>()
.
lambda
()
.
eq
(
ClassMemberMappingDO:
:
getClassId
,
Long
.
valueOf
(
classId
)));
//查找课程里的所有视频
List
<
VodDictDO
>
vodDictDOS
=
courseContentMapper
.
getCourseVods
(
classDictDO
.
getCourseId
());
//查看每个人看视频的时长
for
(
ClassMemberMappingDO
classMemberMappingDO
:
classMemberMappingDOS
)
{
//查看每个人的剩余时长
MemberStudyLengthDO
memberStudyLengthDO
=
memberStudyLengthMapper
.
selectOne
(
new
QueryWrapper
<
MemberStudyLengthDO
>()
.
lambda
()
.
eq
(
MemberStudyLengthDO:
:
getMemberId
,
classMemberMappingDO
.
getMemberId
()));
//查询这个人 这节课 签到记录 排序
List
<
SignInRecordDO
>
signInRecordDOS
=
signInRecordMapper
.
selectList
(
new
QueryWrapper
<
SignInRecordDO
>()
.
lambda
()
.
eq
(
SignInRecordDO:
:
getMemberId
,
classMemberMappingDO
.
getMemberId
())
.
eq
(
SignInRecordDO:
:
getClassId
,
classId
));
for
(
SignInRecordDO
signInRecordDO
:
signInRecordDOS
)
{
//查看当天这人已经看的视频时长
List
<
VodPlayHistoryDO
>
vodPlayHistoryDOS
=
vodPlayHistoryMapper
.
exPlayInfo
(
classMemberMappingDO
.
getMemberId
(),
String
.
valueOf
(
classId
),
signInRecordDO
.
getSignInDate
());
//查看学生一看视频时长
int
totalLength
=
0
;
System
.
out
.
println
(
"111111111111111"
);
List
<
VodPlayHistoryDO
>
vodPlayHistoryDOS1
=
vodPlayHistoryMapper
.
selectList
(
new
QueryWrapper
<
VodPlayHistoryDO
>()
.
lambda
()
.
eq
(
VodPlayHistoryDO:
:
getMemberId
,
classMemberMappingDO
.
getMemberId
())
.
eq
(
VodPlayHistoryDO:
:
getClassId
,
classId
));
for
(
VodPlayHistoryDO
vodPlayHistoryDO
:
vodPlayHistoryDOS1
)
{
totalLength
+=
vodPlayHistoryDO
.
getPlayLength
();
}
int
leftLength
=
0
;
System
.
out
.
println
(
"22222222222222222222222"
);
if
(
memberStudyLengthDO
!=
null
){
//这个人还剩多少时长
leftLength
=
memberStudyLengthDO
.
getTotalLength
()
-
totalLength
;
}
System
.
out
.
println
(
"2.5==============================="
);
//当天已经看了多少时间视频
int
playLength
=
0
;
for
(
int
m
=
0
;
m
<
vodPlayHistoryDOS
.
size
();
m
++)
{
playLength
+=
vodPlayHistoryDOS
.
get
(
m
).
getPlayLength
();
}
System
.
out
.
println
(
"33333333333333333333"
);
if
(
leftLength
>
0
)
{
//随机看几个视频
int
playCounts
=
new
Random
().
nextInt
(
4
)+
2
;
System
.
out
.
println
(
"4444444444444444"
);
for
(
int
i
=
0
;
i
<
playCounts
;
i
++)
{
VodPlayHistoryDO
vodPlayHistoryDO
=
new
VodPlayHistoryDO
();
Random
random1
=
new
Random
();
System
.
out
.
println
(
"55555555555555555555"
);
int
j
=
random1
.
nextInt
(
vodDictDOS
.
size
());
vodPlayHistoryDO
.
setPlayCount
(
1
);
vodPlayHistoryDO
.
setClassId
(
classId
);
vodPlayHistoryDO
.
setMemberId
(
classMemberMappingDO
.
getMemberId
());
int
h
=
new
Random
().
nextInt
(
vodDictDOS
.
get
(
j
).
getVodLength
()
-
10
)
+
1
;
System
.
out
.
println
(
"666666666666666666"
);
vodPlayHistoryDO
.
setPlayRecord
(
new
Random
().
nextInt
(
h
));
if
(
leftLength
-
h
>
0
)
{
vodPlayHistoryDO
.
setPlayLength
(
h
);
playLength
+=
h
;
vodPlayHistoryDO
.
setVodId
(
vodDictDOS
.
get
(
j
).
getId
());
vodPlayHistoryDO
.
setPlayDate
(
signInRecordDO
.
getSignInDate
().
plusSeconds
(
playLength
));
leftLength
=
leftLength
-
h
;
vodPlayHistoryMapper
.
insert
(
vodPlayHistoryDO
);
}
else
{
vodPlayHistoryDO
.
setPlayLength
(
leftLength
);
playLength
+=
leftLength
;
vodPlayHistoryDO
.
setVodId
(
vodDictDOS
.
get
(
j
).
getId
());
vodPlayHistoryDO
.
setPlayDate
(
signInRecordDO
.
getSignInDate
().
plusSeconds
(
playLength
));
vodPlayHistoryMapper
.
insert
(
vodPlayHistoryDO
);
break
;
}
}
}
}
}
return
0
;
}
public
static
void
main
(
String
[]
args
)
{
while
(
true
){
while
(
true
)
{
System
.
out
.
println
(
new
Random
().
nextInt
(
4
));
}
// int m = 0;
...
...
src/main/resources/application.properties
View file @
356c09e
# 环境配置
spring.profiles.active
=
prod
spring.profiles.active
=
dev
# 端口号
spring.server.port
=
2345
9
spring.server.port
=
2345
7
#嵌入tomcat配置
#和CPU数
spring.server.acceptorThreadCount
=
600
...
...
src/main/resources/mapper/CourseContentMapper.xml
View file @
356c09e
...
...
@@ -40,7 +40,7 @@
t.delete_date IS NULL
AND t2.delete_date IS NULL
and t.course_id = #{courseId}
and t2.id is
not null
and t2.id is not null
</select>
<select
id=
"contentVodProcess"
resultType=
"com.subsidy.vo.member.MemberVodVO"
>
...
...
src/main/resources/mapper/MemberStudyLengthMapper.xml
0 → 100644
View file @
356c09e
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper
namespace=
"com.subsidy.mapper.MemberStudyLengthMapper"
>
<!-- 通用查询映射结果 -->
<resultMap
id=
"BaseResultMap"
type=
"com.subsidy.model.MemberStudyLengthDO"
>
<id
column=
"id"
property=
"id"
/>
<result
column=
"create_date"
property=
"createDate"
/>
<result
column=
"update_date"
property=
"updateDate"
/>
<result
column=
"delete_date"
property=
"deleteDate"
/>
<result
column=
"member_id"
property=
"memberId"
/>
<result
column=
"total_length"
property=
"totalLength"
/>
</resultMap>
<!-- 通用查询结果列 -->
<sql
id=
"Base_Column_List"
>
create_date,
update_date,
delete_date,
id, member_id, total_length
</sql>
</mapper>
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