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 c5e36ae4
authored
Jan 18, 2022
by
涂亚平
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
视频纬度报表
1 parent
62041049
Show whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
516 additions
and
145 deletions
src/main/java/com/subsidy/controller/AdministerController.java
src/main/java/com/subsidy/controller/VodPlayHistoryController.java
src/main/java/com/subsidy/dto/administer/ClassVodDailyInfoDTO.java
src/main/java/com/subsidy/jobs/Scheduler.java
src/main/java/com/subsidy/mapper/VodPlayHistoryMapper.java
src/main/java/com/subsidy/model/SignInRecordDO.java
src/main/java/com/subsidy/service/AdministerService.java
src/main/java/com/subsidy/service/VodPlayHistoryService.java
src/main/java/com/subsidy/service/impl/AdministerServiceImpl.java
src/main/java/com/subsidy/service/impl/VodPlayHistoryServiceImpl.java
src/main/java/com/subsidy/util/BaseModel.java
src/main/java/com/subsidy/vo/administer/ClassDailyInfoVO.java
src/main/java/com/subsidy/vo/administer/ClassVodDailyInfoItemVO.java
src/main/java/com/subsidy/vo/administer/ClassVodDailyInfoVO.java
src/main/resources/mapper/VodPlayHistoryMapper.xml
src/main/java/com/subsidy/controller/AdministerController.java
View file @
c5e36ae
...
...
@@ -4,11 +4,7 @@ package com.subsidy.controller;
import
com.subsidy.common.ResponseData
;
import
com.subsidy.common.ResponseVO
;
import
com.subsidy.common.interceptor.LoginRequired
;
import
com.subsidy.dto.administer.ClassDailyInfoDTO
;
import
com.subsidy.dto.administer.ClassDetailDTO
;
import
com.subsidy.dto.administer.ClassVodInfoDTO
;
import
com.subsidy.dto.administer.MemberStudyLogDTO
;
import
com.subsidy.dto.administer.OperatorsDTO
;
import
com.subsidy.dto.administer.*
;
import
com.subsidy.model.AdministerDO
;
import
com.subsidy.model.ExerciseDoneHistoryDO
;
import
com.subsidy.model.ExerciseDoneResultDO
;
...
...
@@ -187,6 +183,18 @@ public class AdministerController {
administerService
.
exportClassDailyInfo
(
classDailyInfoDTO
);
}
@PostMapping
(
"classVodDailyInfo"
)
@ApiOperation
(
"学习记录---每日学习时长(视频维度)"
)
public
ResponseVO
classVodDailyInfo
(
@RequestBody
ClassVodDailyInfoDTO
classVodDailyInfoDTO
){
return
ResponseData
.
generateCreatedResponse
(
0
,
administerService
.
classVodDailyInfo
(
classVodDailyInfoDTO
));
}
@PostMapping
(
"exportClassVodDailyInfo"
)
@ApiOperation
(
"学习记录---每日学习时长(视频维度)"
)
public
void
exportClassVodDailyInfo
(
@RequestBody
ClassVodDailyInfoDTO
classVodDailyInfoDTO
){
administerService
.
exportClassVodDailyInfo
(
classVodDailyInfoDTO
);
}
@PostMapping
(
"exportZip"
)
@ApiOperation
(
"下载压缩包 id 班级id"
)
@CrossOrigin
...
...
src/main/java/com/subsidy/controller/VodPlayHistoryController.java
View file @
c5e36ae
...
...
@@ -48,4 +48,8 @@ public class VodPlayHistoryController {
vodPlayHistoryService
.
dataFix
();
}
@PostMapping
(
"fixDataTwo"
)
public
void
dataFixTwo
(){
vodPlayHistoryService
.
dataFixTwo
();
}
}
src/main/java/com/subsidy/dto/administer/ClassVodDailyInfoDTO.java
0 → 100644
View file @
c5e36ae
package
com
.
subsidy
.
dto
.
administer
;
import
lombok.Data
;
@Data
public
class
ClassVodDailyInfoDTO
{
private
Integer
pageSize
;
private
Integer
pageNum
;
private
Long
classId
;
private
String
userName
;
}
src/main/java/com/subsidy/jobs/Scheduler.java
View file @
c5e36ae
...
...
@@ -95,19 +95,19 @@ public class Scheduler {
/**
* 视频播放记录缩量
*/
@Scheduled
(
cron
=
"0 48 14 * * ?"
)
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
void
condenseVodPlayHistory
()
{
List
<
VodPlayHistoryDO
>
list
=
vodPlayHistoryMapper
.
getVodPlayHistory
();
vodPlayHistoryMapper
.
delete
(
null
);
//List<VodPlayHistoryDO> vodPlayHistoryList = vodPlayHistoryMapper.selectList(null);
//for (VodPlayHistoryDO vodPlayHistoryDO : vodPlayHistoryList) {
vodPlayHistoryMapper
.
deleteById
(
null
);
//}
for
(
VodPlayHistoryDO
vodPlayHistoryDO
:
list
)
{
vodPlayHistoryMapper
.
insert
(
vodPlayHistoryDO
);
}
}
//
@Scheduled(cron = "0 48 14 * * ?")
//
@Transactional(rollbackFor = Exception.class)
//
public void condenseVodPlayHistory() {
//
List<VodPlayHistoryDO> list = vodPlayHistoryMapper.getVodPlayHistory();
//
vodPlayHistoryMapper.delete(null);
//
//List<VodPlayHistoryDO> vodPlayHistoryList = vodPlayHistoryMapper.selectList(null);
//
//for (VodPlayHistoryDO vodPlayHistoryDO : vodPlayHistoryList) {
//
vodPlayHistoryMapper.deleteById(null);
//
//}
//
//
for (VodPlayHistoryDO vodPlayHistoryDO : list) {
//
vodPlayHistoryMapper.insert(vodPlayHistoryDO);
//
}
//
}
}
src/main/java/com/subsidy/mapper/VodPlayHistoryMapper.java
View file @
c5e36ae
...
...
@@ -10,6 +10,7 @@ import com.subsidy.vo.vod.GetMemberStudyInfoVO;
import
com.subsidy.vo.vod.StudyHistoryVO
;
import
org.springframework.stereotype.Repository
;
import
java.time.LocalDateTime
;
import
java.util.List
;
/**
...
...
@@ -60,7 +61,6 @@ public interface VodPlayHistoryMapper extends BaseMapper<VodPlayHistoryDO> {
*/
ContentVodNewVO
memberRecentPlay
(
Long
classId
,
Long
memberId
);
/**
* 查看某个成员某个课程的学习日志
*/
...
...
@@ -76,4 +76,15 @@ public interface VodPlayHistoryMapper extends BaseMapper<VodPlayHistoryDO> {
*/
Integer
memberVodTotalLength
(
Long
memberId
,
Long
vodId
);
/**
* 跑脚本 前一天的学习情况
*/
List
<
VodPlayHistoryDO
>
exPlayInfo
(
Long
memberId
,
String
classId
,
LocalDateTime
localDateTime
);
/**
* 以班级、人的维度查询某个人的视频观看时长
*/
List
<
VodPlayHistoryDO
>
classMemberPlayLength
(
Long
classId
);
}
src/main/java/com/subsidy/model/SignInRecordDO.java
View file @
c5e36ae
...
...
@@ -5,6 +5,8 @@ import com.baomidou.mybatisplus.annotation.TableName;
import
com.baomidou.mybatisplus.annotation.IdType
;
import
com.baomidou.mybatisplus.annotation.TableId
;
import
java.time.LocalDateTime
;
import
com.subsidy.util.excel.ExcelColumnUtil
;
import
lombok.Data
;
import
lombok.EqualsAndHashCode
;
...
...
@@ -29,16 +31,19 @@ public class SignInRecordDO extends BaseModel {
/**
* 学生id
*/
@ExcelColumnUtil
(
value
=
"member_id"
,
col
=
3
)
private
Long
memberId
;
/**
* 班级id
*/
@ExcelColumnUtil
(
value
=
"class_id"
,
col
=
2
)
private
Long
classId
;
/**
* 签到时间
*/
@ExcelColumnUtil
(
value
=
"sign_in_date"
,
col
=
4
)
private
LocalDateTime
signInDate
;
...
...
src/main/java/com/subsidy/service/AdministerService.java
View file @
c5e36ae
...
...
@@ -2,23 +2,11 @@ package com.subsidy.service;
import
com.baomidou.mybatisplus.core.metadata.IPage
;
import
com.baomidou.mybatisplus.extension.service.IService
;
import
com.subsidy.dto.administer.ClassDailyInfoDTO
;
import
com.subsidy.dto.administer.ClassDetailDTO
;
import
com.subsidy.dto.administer.ClassVodInfoDTO
;
import
com.subsidy.dto.administer.MemberStudyLogDTO
;
import
com.subsidy.dto.administer.OperatorsDTO
;
import
com.subsidy.dto.administer.*
;
import
com.subsidy.model.AdministerDO
;
import
com.subsidy.model.ExerciseDoneHistoryDO
;
import
com.subsidy.model.ExerciseDoneResultDO
;
import
com.subsidy.vo.administer.AdministerPermissionVO
;
import
com.subsidy.vo.administer.ClassDailyInfoVO
;
import
com.subsidy.vo.administer.ClassSummaryVO
;
import
com.subsidy.vo.administer.ClassVodInfoVO
;
import
com.subsidy.vo.administer.ExerciseTestVO
;
import
com.subsidy.vo.administer.GetMemberPapersVO
;
import
com.subsidy.vo.administer.GetPaperDetailVO
;
import
com.subsidy.vo.administer.LoginVO
;
import
com.subsidy.vo.administer.OperatorsVO
;
import
com.subsidy.vo.administer.*
;
import
com.subsidy.vo.classdict.ClassDetailVO
;
import
com.subsidy.vo.member.ClassSignVO
;
import
com.subsidy.vo.sign.AnswerRecordVO
;
...
...
@@ -76,6 +64,10 @@ public interface AdministerService extends IService<AdministerDO> {
void
exportClassDailyInfo
(
ClassDailyInfoDTO
classDailyInfoDTO
);
IPage
<
ClassDailyInfoVO
>
classVodDailyInfo
(
ClassVodDailyInfoDTO
classVodDailyInfoDTO
);
void
exportClassVodDailyInfo
(
ClassVodDailyInfoDTO
classVodDailyInfoDTO
);
void
export
(
ClassDetailDTO
classDetailDTO
)
throws
Exception
;
void
memberStudyLog
(
MemberStudyLogDTO
memberStudyLogDTO
)
throws
Exception
;
...
...
src/main/java/com/subsidy/service/VodPlayHistoryService.java
View file @
c5e36ae
...
...
@@ -18,4 +18,6 @@ public interface VodPlayHistoryService extends IService<VodPlayHistoryDO> {
String
insertHistoryNew
(
VodPlayHistoryDO
vodPlayHistoryDO
);
void
dataFix
();
void
dataFixTwo
();
}
src/main/java/com/subsidy/service/impl/AdministerServiceImpl.java
View file @
c5e36ae
...
...
@@ -6,11 +6,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
com.subsidy.common.RedisPrefixConstant
;
import
com.subsidy.common.exception.HttpException
;
import
com.subsidy.dto.administer.ClassDailyInfoDTO
;
import
com.subsidy.dto.administer.ClassDetailDTO
;
import
com.subsidy.dto.administer.ClassVodInfoDTO
;
import
com.subsidy.dto.administer.MemberStudyLogDTO
;
import
com.subsidy.dto.administer.OperatorsDTO
;
import
com.subsidy.dto.administer.*
;
import
com.subsidy.dto.member.ImportMemberDTO
;
import
com.subsidy.mapper.AdministerMapper
;
import
com.subsidy.mapper.AnsweringQuestionMapper
;
...
...
@@ -26,22 +22,8 @@ import com.subsidy.mapper.OprAdmDictMapper;
import
com.subsidy.mapper.RoleAdministerMappingMapper
;
import
com.subsidy.mapper.VodDictMapper
;
import
com.subsidy.mapper.VodPlayHistoryMapper
;
import
com.subsidy.model.AdministerDO
;
import
com.subsidy.model.AnsweringQuestionDO
;
import
com.subsidy.model.ClassDictDO
;
import
com.subsidy.model.ClassMemberMappingDO
;
import
com.subsidy.model.CompanyDictDO
;
import
com.subsidy.model.CourseDictDO
;
import
com.subsidy.model.DepartmentDictDO
;
import
com.subsidy.model.ExerciseDoneHistoryDO
;
import
com.subsidy.model.ExerciseDoneResultDO
;
import
com.subsidy.model.MemberDO
;
import
com.subsidy.model.MemberDepartmentMappingDO
;
import
com.subsidy.model.OprMemDictDO
;
import
com.subsidy.model.*
;
import
com.subsidy.mongodb.OprAdmDictDO
;
import
com.subsidy.model.RoleAdministerMappingDO
;
import
com.subsidy.model.SignInRecordDO
;
import
com.subsidy.model.VodDictDO
;
import
com.subsidy.service.AdministerService
;
import
com.subsidy.util.ConstantUtils
;
import
com.subsidy.util.DateFormatUtil
;
...
...
@@ -51,17 +33,7 @@ import com.subsidy.util.Localstorage;
import
com.subsidy.util.MathUtil
;
import
com.subsidy.util.RedisUtil
;
import
com.subsidy.util.excel.ExcelUtil
;
import
com.subsidy.vo.administer.AdministerPermissionVO
;
import
com.subsidy.vo.administer.ClassDailyInfoVO
;
import
com.subsidy.vo.administer.ClassSummaryVO
;
import
com.subsidy.vo.administer.ClassVodInfoVO
;
import
com.subsidy.vo.administer.ExerciseTestVO
;
import
com.subsidy.vo.administer.GetMemberPapersVO
;
import
com.subsidy.vo.administer.GetPaperDetailVO
;
import
com.subsidy.vo.administer.LoginVO
;
import
com.subsidy.vo.administer.MemberStudyLogVO
;
import
com.subsidy.vo.administer.OperatorsVO
;
import
com.subsidy.vo.administer.PermissionsVO
;
import
com.subsidy.vo.administer.*
;
import
com.subsidy.vo.classdict.ClassDetailVO
;
import
com.subsidy.vo.done.GetMaxScoreVO
;
import
com.subsidy.vo.done.TestScoreInfoVO
;
...
...
@@ -177,9 +149,6 @@ public class AdministerServiceImpl extends ServiceImpl<AdministerMapper, Adminis
private
VodDictMapper
vodDictMapper
;
@Autowired
private
OprAdmDictMapper
oprAdmDictMapper
;
@Autowired
private
RedisUtil
redisUtil
;
@Autowired
...
...
@@ -209,7 +178,7 @@ public class AdministerServiceImpl extends ServiceImpl<AdministerMapper, Adminis
/**
* 最近5次都输入失败,5分钟后再验证 待优化
*/
Query
query
=
new
Query
(
Criteria
.
where
(
"userId"
).
is
(
1
).
and
(
"createDate"
).
gte
(
System
.
currentTimeMillis
()
-
5
*
60
*
1000
+
""
));
//可累加条件
Query
query
=
new
Query
(
Criteria
.
where
(
"userId"
).
is
(
1
).
and
(
"createDate"
).
gte
(
System
.
currentTimeMillis
()
-
5
*
60
*
1000
+
""
));
//可累加条件
query
.
with
(
Sort
.
by
(
"createDate"
).
descending
());
List
<
OprAdmDictDO
>
oprAdmDictDOS
=
mongoTemplate
.
find
(
query
,
OprAdmDictDO
.
class
);
...
...
@@ -236,7 +205,7 @@ public class AdministerServiceImpl extends ServiceImpl<AdministerMapper, Adminis
oprAdmDictDO
.
setUserId
(
administerDO1
.
getId
());
oprAdmDictDO
.
setOprType
(
"登录"
);
oprAdmDictDO
.
setResult
(
1
);
oprAdmDictDO
.
setCreateDate
(
System
.
currentTimeMillis
()
+
""
);
oprAdmDictDO
.
setCreateDate
(
System
.
currentTimeMillis
()
+
""
);
oprAdmDictDO
.
setLoginDateFormat
(
DateFormatUtil
.
format
(
new
Date
(),
"yyyyMMdd"
));
oprAdmDictDO
.
setUserName
(
administerDO1
.
getUserName
());
oprAdmDictDO
.
setCompanyId
(
administerDO1
.
getCompanyId
());
...
...
@@ -251,7 +220,7 @@ public class AdministerServiceImpl extends ServiceImpl<AdministerMapper, Adminis
oprAdmDictDO
.
setOprType
(
"登录"
);
oprAdmDictDO
.
setResult
(
0
);
//oprAdmDictMapper.insert(oprAdmDictDO);
oprAdmDictDO
.
setCreateDate
(
System
.
currentTimeMillis
()
+
""
);
oprAdmDictDO
.
setCreateDate
(
System
.
currentTimeMillis
()
+
""
);
oprAdmDictDO
.
setLoginDateFormat
(
DateFormatUtil
.
format
(
new
Date
(),
"yyyyMMdd"
));
oprAdmDictDO
.
setUserName
(
administerDO1
.
getUserName
());
oprAdmDictDO
.
setCompanyId
(
administerDO1
.
getCompanyId
());
...
...
@@ -882,6 +851,79 @@ public class AdministerServiceImpl extends ServiceImpl<AdministerMapper, Adminis
}
writeExcel
(
memberIds
,
hashMap
,
title
);
}
public
IPage
<
ClassDailyInfoVO
>
classVodDailyInfo
(
ClassVodDailyInfoDTO
classVodDailyInfoDTO
)
{
//查看班级里有多少人
Page
pager
=
new
Page
(
classVodDailyInfoDTO
.
getPageNum
(),
classVodDailyInfoDTO
.
getPageSize
());
//获取班级成员
IPage
<
ClassDailyInfoVO
>
classDailyInfoVOIPage
=
classMemberMappingMapper
.
getClassMembersWithName
(
pager
,
classVodDailyInfoDTO
.
getClassId
(),
classVodDailyInfoDTO
.
getUserName
());
List
<
ClassDailyInfoVO
>
classDailyInfoVOS
=
classDailyInfoVOIPage
.
getRecords
();
//获取班级、每个学员维度的视频播放总时长
List
<
VodPlayHistoryDO
>
vodPlayHistoryDOS
=
vodPlayHistoryMapper
.
classMemberPlayLength
(
classVodDailyInfoDTO
.
getClassId
());
HashMap
<
String
,
Integer
>
hashMap
=
new
HashMap
<>();
//存在一个map里
for
(
VodPlayHistoryDO
vodPlayHistoryDO
:
vodPlayHistoryDOS
)
{
hashMap
.
put
(
vodPlayHistoryDO
.
getMemberId
()
+
"-"
+
vodPlayHistoryDO
.
getVodId
(),
vodPlayHistoryDO
.
getPlayLength
());
}
//查询这个班级的所有视频
ClassDictDO
classDictDO
=
classDictMapper
.
selectById
(
classVodDailyInfoDTO
.
getClassId
());
List
<
VodDictDO
>
vodDictDOS
=
vodDictMapper
.
getCourseVods
(
classDictDO
.
getCourseId
(),
null
);
for
(
ClassDailyInfoVO
classDailyInfoVO
:
classDailyInfoVOS
)
{
//查看这个人某个视频的长度
int
total
=
0
;
List
<
ClassVodDailyInfoItemVO
>
classVodDailyInfoItemVOS
=
new
ArrayList
<>();
for
(
VodDictDO
vodDictDO
:
vodDictDOS
)
{
int
playLength
=
hashMap
.
get
(
classDailyInfoVO
.
getId
()
+
"-"
+
vodDictDO
.
getId
());
ClassVodDailyInfoItemVO
classVodDailyInfoItemVO
=
new
ClassVodDailyInfoItemVO
();
classVodDailyInfoItemVO
.
setPlayLength
(
playLength
);
classVodDailyInfoItemVOS
.
add
(
classVodDailyInfoItemVO
);
total
+=
playLength
;
}
classDailyInfoVO
.
setTotal
(
total
);
classDailyInfoVO
.
setClassVodDailyInfoItemVOS
(
classVodDailyInfoItemVOS
);
}
return
classDailyInfoVOIPage
;
}
public
void
exportClassVodDailyInfo
(
ClassVodDailyInfoDTO
classVodDailyInfoDTO
){
//查看班级里有多少人
Page
pager
=
new
Page
(
1
,-
1L
);
//查询所有视频
List
<
VodDictDO
>
vodDictDOS
=
vodDictMapper
.
getCourseVods
(
classVodDailyInfoDTO
.
getClassId
(),
null
);
// 表头
List
<
String
>
title
=
new
ArrayList
<>();
title
.
add
(
"姓名"
);
title
.
add
(
"合计总时长"
);
for
(
VodDictDO
vodDictDO
:
vodDictDOS
){
title
.
add
(
vodDictDO
.
getVodName
());
}
//获取班级成员
IPage
<
ClassDailyInfoVO
>
classDailyInfoVOIPage
=
classMemberMappingMapper
.
getClassMembersWithName
(
pager
,
classVodDailyInfoDTO
.
getClassId
(),
classVodDailyInfoDTO
.
getUserName
());
List
<
ClassDailyInfoVO
>
classDailyInfoVOS
=
classDailyInfoVOIPage
.
getRecords
();
//获取班级、每个学员维度的视频播放总时长
List
<
VodPlayHistoryDO
>
vodPlayHistoryDOS
=
vodPlayHistoryMapper
.
classMemberPlayLength
(
classVodDailyInfoDTO
.
getClassId
());
HashMap
<
String
,
Integer
>
hashMap
=
new
HashMap
<>();
//存在一个map里
for
(
VodPlayHistoryDO
vodPlayHistoryDO
:
vodPlayHistoryDOS
)
{
hashMap
.
put
(
vodPlayHistoryDO
.
getMemberId
()
+
"-"
+
vodPlayHistoryDO
.
getVodId
(),
vodPlayHistoryDO
.
getPlayLength
());
}
}
...
...
@@ -921,12 +963,12 @@ public class AdministerServiceImpl extends ServiceImpl<AdministerMapper, Adminis
HashMap
<
String
,
Integer
>
hashMap1
=
hashMap
.
get
(
data
);
Cell
namecell
=
r
.
createCell
(
a
.
getAndIncrement
());
namecell
.
setCellValue
(
memberMapper
.
selectById
(
data
).
getUserName
());
int
total
=
0
;
for
(
String
date
:
dates
){
if
(!
date
.
equals
(
"姓名"
)
&&
!
"合计总时长"
.
equals
(
date
))
{
int
total
=
0
;
for
(
String
date
:
dates
)
{
if
(!
date
.
equals
(
"姓名"
)
&&
!
"合计总时长"
.
equals
(
date
))
{
Cell
cell1
=
r
.
createCell
(
a
.
getAndIncrement
());
if
(
null
!=
hashMap1
)
{
total
+=
null
==
hashMap1
.
get
(
date
)
?
0
:
hashMap1
.
get
(
date
);
total
+=
null
==
hashMap1
.
get
(
date
)
?
0
:
hashMap1
.
get
(
date
);
cell1
.
setCellValue
(
null
==
hashMap1
.
get
(
date
)
?
"00:00:00"
:
MathUtil
.
secToTime
(
hashMap1
.
get
(
date
)));
}
else
{
cell1
.
setCellValue
(
"00:00:00"
);
...
...
src/main/java/com/subsidy/service/impl/VodPlayHistoryServiceImpl.java
View file @
c5e36ae
package
com
.
subsidy
.
service
.
impl
;
import
com.amdelamar.jhash.Hash
;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
com.subsidy.mapper.ClassDictMapper
;
import
com.subsidy.mapper.ClassMemberMappingMapper
;
import
com.subsidy.mapper.CourseContentMapper
;
import
com.subsidy.mapper.SignInRecordMapper
;
import
com.subsidy.mapper.*
;
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.VodPlayHistoryMapper
;
import
com.subsidy.
service.VodDictService
;
import
com.subsidy.service.VodPlayHistoryService
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
com.subsidy.util.ConstantUtils
;
import
com.subsidy.util.DateFormatUtil
;
import
com.subsidy.util.MathUtil
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.scheduling.annotation.Async
;
import
org.springframework.stereotype.Service
;
import
java.time.LocalDate
;
import
java.time.LocalDateTime
;
import
java.util.Arrays
;
import
java.util.List
;
import
java.util.Random
;
import
java.time.format.DateTimeFormatter
;
import
java.util.*
;
/**
* <p>
...
...
@@ -50,6 +49,9 @@ public class VodPlayHistoryServiceImpl extends ServiceImpl<VodPlayHistoryMapper,
@Autowired
private
VodPlayHistoryMapper
vodPlayHistoryMapper
;
@Autowired
private
VodDictMapper
vodDictMapper
;
public
String
insertHistory
(
VodPlayHistoryDO
vodPlayHistoryDO
)
{
vodPlayHistoryDO
.
setPlayCount
(
1
);
this
.
baseMapper
.
insert
(
vodPlayHistoryDO
);
...
...
@@ -65,9 +67,7 @@ public class VodPlayHistoryServiceImpl extends ServiceImpl<VodPlayHistoryMapper,
public
void
dataFix
()
{
//班级ids
List
<
String
>
classIds
=
Arrays
.
asList
(
new
String
[]{
"17"
,
"28"
});
Random
random
=
new
Random
();
List
<
String
>
classIds
=
Arrays
.
asList
(
new
String
[]{
"28"
});
for
(
String
str
:
classIds
)
{
...
...
@@ -78,34 +78,203 @@ public class VodPlayHistoryServiceImpl extends ServiceImpl<VodPlayHistoryMapper,
.
lambda
()
.
eq
(
ClassMemberMappingDO:
:
getClassId
,
Long
.
valueOf
(
str
)));
//查找课程里的所有视频
List
<
VodDictDO
>
vodDictDOS
=
courseContentMapper
.
getCourseVods
(
classDictDO
.
getCourseId
());
//遍历班级学生
for
(
ClassMemberMappingDO
classMemberMappingDO
:
classMemberMappingDOS
)
{
//查询这个人 这节课 排序
//List<SignInRecordDO> signInRecordDOS = signInRecordMapper.selectList(new QueryWrapper<SignInRecordDO>()
// .lambda()
// .eq(SignInRecordDO::getMemberId, classMemberMappingDO.getMemberId())
// .eq(SignInRecordDO::getClassId, str)
// .orderByAsc(SignInRecordDO::getSignInDate));
//查询这个人 这节课 签到记录 排序
List
<
SignInRecordDO
>
signInRecordDOS
=
signInRecordMapper
.
selectList
(
new
QueryWrapper
<
SignInRecordDO
>()
.
lambda
()
.
eq
(
SignInRecordDO:
:
getMemberId
,
classMemberMappingDO
.
getMemberId
())
.
eq
(
SignInRecordDO:
:
getClassId
,
str
)
.
orderByDesc
(
SignInRecordDO:
:
getSignInDate
));
List
<
LocalDateTime
>
localDateTimes
=
new
ArrayList
<>();
for
(
SignInRecordDO
signInrecord
:
signInRecordDOS
)
{
if
(
signInrecord
.
getSignInDate
().
getHour
()
>=
6
&&
signInrecord
.
getSignInDate
().
getHour
()
<
15
)
{
localDateTimes
.
add
(
signInrecord
.
getSignInDate
());
}
}
int
signInrecord
=
localDateTimes
.
size
();
int
vodSize
=
vodDictDOS
.
size
();
LinkedHashMap
<
LocalDateTime
,
Integer
>
hashMap
=
new
LinkedHashMap
<>();
List
<
LocalDateTime
>
integers
=
new
ArrayList
<>();
int
m
=
0
;
int
rdm_total
=
0
;
for
(
int
k
=
0
;
k
<
signInrecord
;
k
++)
{
int
n
=
getRandom
();
rdm_total
+=
n
;
if
((
m
+
n
)
<
vodSize
&&
k
!=
signInrecord
-
1
)
{
m
+=
n
;
if
(
n
>
11
||
n
<
5
)
{
System
.
out
.
println
(
"error"
+
"==================="
);
}
hashMap
.
put
(
localDateTimes
.
get
(
k
),
n
);
integers
.
add
(
localDateTimes
.
get
(
k
));
}
else
{
if
(
vodSize
-
rdm_total
+
n
>
10
||
vodSize
-
rdm_total
+
n
<
5
)
{
System
.
out
.
println
(
"error+=================="
);
}
hashMap
.
put
(
localDateTimes
.
get
(
k
),
vodSize
-
rdm_total
+
n
);
integers
.
add
(
localDateTimes
.
get
(
k
));
break
;
}
}
//SignInRecordDO signInRecordDO = signInRecordDOS.get(0);
// //是否是最后一天的
int
key_index
=
0
;
// for (LocalDateTime localDateTime : hashMap.keySet()){
// if (hashMap.get(localDateTime)>10||hashMap.get(localDateTime)<5){
// System.out.println("================");
// }
// }
// 根据签到时间,对学生学习的课程做插入操作
for
(
LocalDateTime
localDateTime
:
hashMap
.
keySet
())
{
//今天应该看几个视频
int
total
=
hashMap
.
get
(
localDateTime
);
//找出某个人某节课看完最后一节视频的时间
//今天已看视频时长
int
totalPlay
=
0
;
//先续播前一天未看完的视频
List
<
VodPlayHistoryDO
>
vodPlayHistoryDOS
=
vodPlayHistoryMapper
.
selectList
(
new
QueryWrapper
<
VodPlayHistoryDO
>()
.
lambda
()
.
eq
(
VodPlayHistoryDO:
:
getMemberId
,
classMemberMappingDO
.
getMemberId
())
.
eq
(
VodPlayHistoryDO:
:
getClassId
,
str
)
.
orderByDesc
(
VodPlayHistoryDO:
:
getPlayDate
));
if
(
vodPlayHistoryDOS
.
size
()>
0
){
//时间点
//续播
if
(
vodPlayHistoryDOS
.
size
()
>
0
)
{
VodPlayHistoryDO
vodPlayHistoryDO1
=
vodPlayHistoryDOS
.
get
(
0
);
int
total
=
0
;
int
playCounts
=
random
.
nextInt
(
2
)+
1
;
VodDictDO
vodDictDO
=
vodDictMapper
.
selectById
(
vodPlayHistoryDO1
.
getVodId
());
//剩下的学习时长
int
leftLength
=
vodDictDO
.
getVodLength
()
-
vodPlayHistoryDO1
.
getPlayLength
();
if
(
leftLength
>
0
)
{
totalPlay
+=
leftLength
;
VodPlayHistoryDO
vodPlayHistoryDO
=
new
VodPlayHistoryDO
();
vodPlayHistoryDO
.
setPlayCount
(
1
);
vodPlayHistoryDO
.
setClassId
(
Long
.
valueOf
(
str
));
vodPlayHistoryDO
.
setMemberId
(
classMemberMappingDO
.
getMemberId
());
vodPlayHistoryDO
.
setPlayRecord
(
vodDictDO
.
getVodLength
());
vodPlayHistoryDO
.
setPlayLength
(
leftLength
);
vodPlayHistoryDO
.
setVodId
(
vodDictDO
.
getId
());
vodPlayHistoryDO
.
setPlayDate
(
localDateTime
.
plusSeconds
(
leftLength
));
vodPlayHistoryMapper
.
insert
(
vodPlayHistoryDO
);
}
}
//今天已看几个视频
int
alreadyPlay
=
0
;
Random
random
=
new
Random
();
//查找这个人应该学的课程
for
(
VodDictDO
vodDictDO
:
vodDictDOS
)
{
//从历史记录里找中这个人有没有学过
Integer
count
=
vodPlayHistoryMapper
.
selectCount
(
new
QueryWrapper
<
VodPlayHistoryDO
>()
.
lambda
()
.
eq
(
VodPlayHistoryDO:
:
getMemberId
,
classMemberMappingDO
.
getMemberId
())
.
eq
(
VodPlayHistoryDO:
:
getClassId
,
str
)
.
eq
(
VodPlayHistoryDO:
:
getVodId
,
vodDictDO
.
getId
()));
//表示这个视频没有学过
if
(
count
==
0
)
{
if
(
alreadyPlay
==
total
)
{
//最后一天最后一个视频
if
(
key_index
==
integers
.
size
())
{
VodPlayHistoryDO
vodPlayHistoryDO
=
new
VodPlayHistoryDO
();
vodPlayHistoryDO
.
setPlayCount
(
1
);
vodPlayHistoryDO
.
setClassId
(
Long
.
valueOf
(
str
));
vodPlayHistoryDO
.
setMemberId
(
classMemberMappingDO
.
getMemberId
());
vodPlayHistoryDO
.
setPlayRecord
(
vodDictDO
.
getVodLength
());
vodPlayHistoryDO
.
setPlayLength
(
vodDictDO
.
getVodLength
());
vodPlayHistoryDO
.
setVodId
(
vodDictDO
.
getId
());
vodPlayHistoryDO
.
setPlayDate
(
localDateTime
.
plusSeconds
(
totalPlay
));
vodPlayHistoryMapper
.
insert
(
vodPlayHistoryDO
);
alreadyPlay
++;
}
else
{
//当天看的最后一个视频
VodPlayHistoryDO
vodPlayHistoryDO
=
new
VodPlayHistoryDO
();
vodPlayHistoryDO
.
setPlayCount
(
1
);
vodPlayHistoryDO
.
setClassId
(
Long
.
valueOf
(
str
));
vodPlayHistoryDO
.
setMemberId
(
classMemberMappingDO
.
getMemberId
());
int
rdm
=
random
.
nextInt
(
vodDictDO
.
getVodLength
());
vodPlayHistoryDO
.
setPlayLength
(
rdm
);
vodPlayHistoryDO
.
setPlayRecord
(
rdm
);
vodPlayHistoryDO
.
setVodId
(
vodDictDO
.
getId
());
vodPlayHistoryDO
.
setPlayDate
(
localDateTime
.
plusSeconds
(
totalPlay
+
rdm
));
vodPlayHistoryMapper
.
insert
(
vodPlayHistoryDO
);
alreadyPlay
++;
break
;
}
}
else
{
totalPlay
+=
vodDictDO
.
getVodLength
();
VodPlayHistoryDO
vodPlayHistoryDO
=
new
VodPlayHistoryDO
();
vodPlayHistoryDO
.
setPlayCount
(
1
);
vodPlayHistoryDO
.
setClassId
(
Long
.
valueOf
(
str
));
vodPlayHistoryDO
.
setMemberId
(
classMemberMappingDO
.
getMemberId
());
vodPlayHistoryDO
.
setPlayRecord
(
vodDictDO
.
getVodLength
());
vodPlayHistoryDO
.
setPlayLength
(
vodDictDO
.
getVodLength
());
vodPlayHistoryDO
.
setVodId
(
vodDictDO
.
getId
());
vodPlayHistoryDO
.
setPlayDate
(
localDateTime
.
plusSeconds
(
totalPlay
));
vodPlayHistoryMapper
.
insert
(
vodPlayHistoryDO
);
alreadyPlay
++;
}
}
}
key_index
++;
}
}
}
}
public
void
dataFixTwo
()
{
//班级ids
List
<
String
>
classIds
=
Arrays
.
asList
(
new
String
[]{
"28"
});
for
(
String
str
:
classIds
)
{
ClassDictDO
classDictDO
=
classDictMapper
.
selectById
(
str
);
//找到班级里的学生
List
<
ClassMemberMappingDO
>
classMemberMappingDOS
=
classMemberMappingMapper
.
selectList
(
new
QueryWrapper
<
ClassMemberMappingDO
>()
.
lambda
()
.
eq
(
ClassMemberMappingDO:
:
getClassId
,
Long
.
valueOf
(
str
)));
//查找课程里的所有视频
List
<
VodDictDO
>
vodDictDOS
=
courseContentMapper
.
getCourseVods
(
classDictDO
.
getCourseId
());
//遍历班级学生
for
(
ClassMemberMappingDO
classMemberMappingDO
:
classMemberMappingDOS
)
{
//查询这个人 这节课 签到记录 排序
List
<
LocalDateTime
>
localDateTimes
=
new
ArrayList
<>();
List
<
SignInRecordDO
>
signInRecordDOS
=
signInRecordMapper
.
selectList
(
new
QueryWrapper
<
SignInRecordDO
>()
.
lambda
()
.
eq
(
SignInRecordDO:
:
getMemberId
,
classMemberMappingDO
.
getMemberId
())
.
eq
(
SignInRecordDO:
:
getClassId
,
str
)
.
orderByDesc
(
SignInRecordDO:
:
getSignInDate
));
for
(
SignInRecordDO
signInrecord
:
signInRecordDOS
)
{
if
(
signInrecord
.
getSignInDate
().
getHour
()
>=
6
&&
signInrecord
.
getSignInDate
().
getHour
()
<
15
)
{
localDateTimes
.
add
(
signInrecord
.
getSignInDate
());
}
}
if
(
localDateTimes
.
size
()>
0
){
LocalDateTime
date
=
localDateTimes
.
get
(
0
);
//查看当天这人已经看的视频时长
List
<
VodPlayHistoryDO
>
vodPlayHistoryDOS
=
vodPlayHistoryMapper
.
exPlayInfo
(
classMemberMappingDO
.
getMemberId
(),
str
,
date
);
int
playLength
=
0
;
for
(
int
m
=
0
;
m
<
vodPlayHistoryDOS
.
size
();
m
++)
{
playLength
+=
vodPlayHistoryDOS
.
get
(
m
).
getPlayLength
();
}
int
playCounts
=
new
Random
().
nextInt
(
2
)
+
1
;
for
(
int
i
=
0
;
i
<
playCounts
;
i
++)
{
VodPlayHistoryDO
vodPlayHistoryDO
=
new
VodPlayHistoryDO
();
...
...
@@ -114,64 +283,119 @@ public class VodPlayHistoryServiceImpl extends ServiceImpl<VodPlayHistoryMapper,
vodPlayHistoryDO
.
setPlayCount
(
1
);
vodPlayHistoryDO
.
setClassId
(
Long
.
valueOf
(
str
));
vodPlayHistoryDO
.
setMemberId
(
classMemberMappingDO
.
getMemberId
());
vodPlayHistoryDO
.
setPlayRecord
(
random
.
nextInt
(
vodDictDOS
.
get
(
j
).
getVodLength
()-
10
)+
1
);
vodPlayHistoryDO
.
setPlayLength
(
random
.
nextInt
(
vodPlayHistoryDO
.
getPlayRecord
()));
int
h
=
new
Random
().
nextInt
(
vodDictDOS
.
get
(
j
).
getVodLength
()
-
10
)
+
1
;
vodPlayHistoryDO
.
setPlayRecord
(
h
);
vodPlayHistoryDO
.
setPlayLength
(
new
Random
().
nextInt
(
vodPlayHistoryDO
.
getPlayRecord
()));
playLength
+=
vodPlayHistoryDO
.
getPlayLength
();
vodPlayHistoryDO
.
setVodId
(
vodDictDOS
.
get
(
j
).
getId
());
total
+=
vodPlayHistoryDO
.
getPlayLength
()+
random
.
nextInt
(
10
);
vodPlayHistoryDO
.
setPlayDate
(
vodPlayHistoryDO1
.
getPlayDate
().
plusSeconds
(
total
));
vodPlayHistoryDO
.
setPlayDate
(
date
.
plusSeconds
(
playLength
));
vodPlayHistoryMapper
.
insert
(
vodPlayHistoryDO
);
}
}
}
}
}
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
);
//VodDictDO vodDictDO = vodDictDOS.get(random.nextInt(vodDictDOS.size()));
//根据签到时间,对学生学习的课程做插入操作
//for (SignInRecordDO signInRecordDO : signInRecordDOS) {
// LocalDateTime signInDate = signInRecordDO.getSignInDate();
// if (signInDate.getHour() <= 15 && signInDate.getHour() >= 6) {
// Random random = new Random();
// int totalDailyLength = random.nextInt(4);
// //查找这个人应该学的课程
// for (VodDictDO vodDictDO : vodDictDOS) {
// //从历史记录里找中这个人有没有学过
// if (totalDailyLength<=7*60*60){
// Integer count = vodPlayHistoryMapper.selectCount(new QueryWrapper<VodPlayHistoryDO>()
// .lambda()
// .eq(VodPlayHistoryDO::getMemberId, classMemberMappingDO.getMemberId())
// .eq(VodPlayHistoryDO::getClassId, str)
// .eq(VodPlayHistoryDO::getVodId, vodDictDO.getId()));
// if (count == 0 && signInDate.plusSeconds(totalDailyLength).getHour() < 23) {
// totalDailyLength+=vodDictDO.getVodLength();
// VodPlayHistoryDO vodPlayHistoryDO = new VodPlayHistoryDO();
// vodPlayHistoryDO.setPlayCount(1);
// vodPlayHistoryDO.setClassId(Long.valueOf(str));
// vodPlayHistoryDO.setMemberId(classMemberMappingDO.getMemberId());
// vodPlayHistoryDO.setPlayRecord(vodDictDO.getVodLength());
// vodPlayHistoryDO.setPlayLength(vodDictDO.getVodLength());
// vodPlayHistoryDO.setVodId(vodDictDO.getId());
// vodPlayHistoryDO.setPlayDate(signInDate.plusSeconds(totalDailyLength));
// //vodPlayHistoryDO.setCreateDate(signInDate.plusSeconds(totalDailyLength));
// vodPlayHistoryMapper.insert(vodPlayHistoryDO);
// Random random1 = new Random();
// totalDailyLength+=random1.nextInt(5);
// }
// }
//
// }
// }
//}
}
}
return
0
;
}
public
static
void
main
(
String
[]
args
)
{
//Random random = new Random();
//System.out.println();
System
.
out
.
println
((
int
)(
Math
.
random
()*
10
+
1
));
// int m = 0;
//
// int signInrecord = 4;
// int vodSize = 24;
// List<Integer> integers = new ArrayList<>();
//
//
// int rdm_total = 0;
// for (int k = 0; k < signInrecord; k++) {
// int n = getRandom();
// rdm_total += n;
// if ((m + n) < vodSize && k != signInrecord - 1) {
// m += n;
// integers.add(n);
// } else {
// integers.add(vodSize - rdm_total + n);
// break;
// }
// }
//
// int h = 0 ;
// while (true) {
// for (Integer integer : integers) {
//// System.out.println(integer + "=====");
// h += integer;
// }
// System.out.println(h+"==============");
//
// if (h != 24) {
// System.out.println(integers);
// }
// h= 0;
// }
// int key_index = 0;
// for (int i = 1 ; i< 100 ; i ++){
// System.out.println((int)(Math.random()*11/2+5));
// }
// int m = 0 ;
// int signInRecordDOS = 3;
// int vodDictDOS = 24;
// List<Integer> integers = new ArrayList<>();
//
// for (int k = 0 ; k < signInRecordDOS ; k++){
// if (k!=signInRecordDOS-1){
// int n = getRandom();
// if ((m+n)<=vodDictDOS){
// m+=n;
// integers.add(n);
// }
// }else {
// if (m<vodDictDOS){
// integers.add(vodDictDOS-m);
// }
//
// }
// }
//
// for (Integer integer : integers){
// System.out.println(integer+"=====");
// }
while
(
true
)
{
int
i
=
getRandom
();
System
.
out
.
println
(
i
+
"============"
);
if
(
i
>
11
||
i
<
5
)
{
System
.
out
.
println
(
"error"
);
}
}
}
public
static
Integer
getRandom
()
{
return
(
int
)
(
Math
.
random
()
*
11
/
2
+
5
);
}
}
src/main/java/com/subsidy/util/BaseModel.java
View file @
c5e36ae
...
...
@@ -16,7 +16,7 @@ public abstract class BaseModel {
* 创建时间
*/
@JsonIgnore
@TableField
(
insertStrategy
=
FieldStrategy
.
NEVER
,
updateStrategy
=
FieldStrategy
.
NEVER
,
value
=
"create_date"
,
fill
=
FieldFill
.
INSERT
)
//
@TableField(insertStrategy = FieldStrategy.NEVER, updateStrategy = FieldStrategy.NEVER, value = "create_date", fill = FieldFill.INSERT)
private
LocalDateTime
createDate
;
/**
...
...
src/main/java/com/subsidy/vo/administer/ClassDailyInfoVO.java
View file @
c5e36ae
...
...
@@ -15,4 +15,6 @@ public class ClassDailyInfoVO {
private
List
<
DayInfoItemVO
>
dayInfoItemVOS
;
private
Integer
total
;
private
List
<
ClassVodDailyInfoItemVO
>
classVodDailyInfoItemVOS
;
}
src/main/java/com/subsidy/vo/administer/ClassVodDailyInfoItemVO.java
0 → 100644
View file @
c5e36ae
package
com
.
subsidy
.
vo
.
administer
;
import
lombok.Data
;
@Data
public
class
ClassVodDailyInfoItemVO
{
private
Integer
vodId
;
private
String
vodName
;
private
Integer
playLength
;
}
src/main/java/com/subsidy/vo/administer/ClassVodDailyInfoVO.java
0 → 100644
View file @
c5e36ae
package
com
.
subsidy
.
vo
.
administer
;
import
com.subsidy.vo.vod.DayInfoItemVO
;
import
lombok.Data
;
import
java.util.List
;
@Data
public
class
ClassVodDailyInfoVO
{
private
Long
id
;
private
String
userName
;
private
List
<
DayInfoItemVO
>
dayInfoItemVOS
;
private
Integer
total
;
}
src/main/resources/mapper/VodPlayHistoryMapper.xml
View file @
c5e36ae
...
...
@@ -307,4 +307,34 @@
AND t.vod_id = #{vodId}
AND t.member_id = #{memberId}
</select>
<select
id=
"exPlayInfo"
resultType=
"com.subsidy.model.VodPlayHistoryDO"
>
SELECT
*
FROM
vod_play_history t
WHERE
t.delete_date IS NULL
AND t.member_id = #{memberId}
AND t.class_id = #{classId}
AND DATE_FORMAT( t.play_date, '%Y-%m-%d' ) = DATE_FORMAT( #{localDateTime}, '%Y-%m-%d' )
order by t.play_date desc
</select>
<select
id=
"classMemberPlayLength"
parameterType=
"long"
resultType=
"com.subsidy.model.VodPlayHistoryDO"
>
SELECT
t.member_id,
t.vod_id,
sum( t.play_length ) AS play_length
FROM
vod_play_history t
LEFT JOIN class_member_mapping t2 ON t.member_id = t2.id
WHERE
t.delete_date IS NULL
AND t2.delete_date IS NULL
AND t.class_id = #{classId}
GROUP BY
t.class_id,
t.member_id
</select>
</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