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 9e3c2b72
authored
Jan 14, 2022
by
涂亚平
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
优化后版本,跑数据脚本
1 parent
2668dc30
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
77 additions
and
40 deletions
src/main/java/com/subsidy/service/impl/VodPlayHistoryServiceImpl.java
src/main/java/com/subsidy/service/impl/VodPlayHistoryServiceImpl.java
View file @
9e3c2b7
...
...
@@ -67,6 +67,8 @@ public class VodPlayHistoryServiceImpl extends ServiceImpl<VodPlayHistoryMapper,
//班级ids
List
<
String
>
classIds
=
Arrays
.
asList
(
new
String
[]{
"28"
});
Random
random
=
new
Random
();
for
(
String
str
:
classIds
)
{
ClassDictDO
classDictDO
=
classDictMapper
.
selectById
(
str
);
...
...
@@ -83,56 +85,91 @@ public class VodPlayHistoryServiceImpl extends ServiceImpl<VodPlayHistoryMapper,
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)
//
.orderByAsc(SignInRecordDO::getSignInDate));
//根据签到时间,对学生学习的课程做插入操作
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
);
}
}
}
//SignInRecordDO signInRecordDO = signInRecordDOS.get(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
){
//时间点
VodPlayHistoryDO
vodPlayHistoryDO1
=
vodPlayHistoryDOS
.
get
(
0
);
int
total
=
0
;
int
playCounts
=
random
.
nextInt
(
vodDictDOS
.
size
());
for
(
int
i
=
0
;
i
<
playCounts
;
i
++)
{
VodPlayHistoryDO
vodPlayHistoryDO
=
new
VodPlayHistoryDO
();
vodPlayHistoryDO
.
setPlayCount
(
1
);
vodPlayHistoryDO
.
setClassId
(
Long
.
valueOf
(
str
));
vodPlayHistoryDO
.
setMemberId
(
classMemberMappingDO
.
getMemberId
());
vodPlayHistoryDO
.
setPlayRecord
(
random
.
nextInt
(
vodDictDOS
.
get
(
i
).
getVodLength
()-
10
)+
1
);
vodPlayHistoryDO
.
setPlayLength
(
random
.
nextInt
(
vodPlayHistoryDO
.
getPlayRecord
()));
vodPlayHistoryDO
.
setVodId
(
vodDictDOS
.
get
(
i
).
getId
());
total
+=
vodPlayHistoryDO
.
getPlayLength
()+
random
.
nextInt
(
10
);
vodPlayHistoryDO
.
setPlayDate
(
vodPlayHistoryDO1
.
getPlayDate
().
plusSeconds
(
total
));
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);
// }
// }
//
// }
// }
//}
}
}
}
public
static
void
main
(
String
[]
args
)
{
Random
random
=
new
Random
();
System
.
out
.
println
();
//
Random random = new Random();
//
System.out.println();
System
.
out
.
println
((
int
)(
Math
.
random
()*
10
+
1
));
}
}
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