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 04198fa7
authored
Feb 20, 2022
by
涂亚平
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
签到逻辑,签到数大于等于当日可签到数就表示已经签过到了
1 parent
1f560722
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
182 additions
and
8 deletions
src/main/java/com/subsidy/service/impl/VodPlayHistoryServiceImpl.java
src/main/java/com/subsidy/service/impl/VodPlayHistoryServiceImpl.java
View file @
04198fa
...
@@ -339,10 +339,10 @@ public class VodPlayHistoryServiceImpl extends ServiceImpl<VodPlayHistoryMapper,
...
@@ -339,10 +339,10 @@ public class VodPlayHistoryServiceImpl extends ServiceImpl<VodPlayHistoryMapper,
totalLength
+=
vodPlayHistoryDO
.
getPlayLength
();
totalLength
+=
vodPlayHistoryDO
.
getPlayLength
();
}
}
int
leftLength
=
0
;
int
leftLength
=
0
;
System
.
out
.
println
(
"22222222222222222222222"
);
System
.
out
.
println
(
"22222222222222222222222"
);
if
(
memberStudyLengthDO
!=
null
)
{
if
(
memberStudyLengthDO
!=
null
)
{
//这个人还剩多少时长
//这个人还剩多少时长
leftLength
=
memberStudyLengthDO
.
getTotalLength
()
-
totalLength
;
leftLength
=
memberStudyLengthDO
.
getTotalLength
()
-
totalLength
;
}
}
...
@@ -358,7 +358,7 @@ public class VodPlayHistoryServiceImpl extends ServiceImpl<VodPlayHistoryMapper,
...
@@ -358,7 +358,7 @@ public class VodPlayHistoryServiceImpl extends ServiceImpl<VodPlayHistoryMapper,
System
.
out
.
println
(
"33333333333333333333"
);
System
.
out
.
println
(
"33333333333333333333"
);
if
(
leftLength
>
0
)
{
if
(
leftLength
>
0
)
{
//随机看几个视频
//随机看几个视频
int
playCounts
=
new
Random
().
nextInt
(
4
)
+
2
;
int
playCounts
=
new
Random
().
nextInt
(
4
)
+
2
;
System
.
out
.
println
(
"4444444444444444"
);
System
.
out
.
println
(
"4444444444444444"
);
for
(
int
i
=
0
;
i
<
playCounts
;
i
++)
{
for
(
int
i
=
0
;
i
<
playCounts
;
i
++)
{
VodPlayHistoryDO
vodPlayHistoryDO
=
new
VodPlayHistoryDO
();
VodPlayHistoryDO
vodPlayHistoryDO
=
new
VodPlayHistoryDO
();
...
@@ -380,7 +380,7 @@ public class VodPlayHistoryServiceImpl extends ServiceImpl<VodPlayHistoryMapper,
...
@@ -380,7 +380,7 @@ public class VodPlayHistoryServiceImpl extends ServiceImpl<VodPlayHistoryMapper,
vodPlayHistoryMapper
.
insert
(
vodPlayHistoryDO
);
vodPlayHistoryMapper
.
insert
(
vodPlayHistoryDO
);
}
else
{
}
else
{
vodPlayHistoryDO
.
setPlayLength
(
leftLength
);
vodPlayHistoryDO
.
setPlayLength
(
leftLength
);
playLength
+=
leftLength
;
playLength
+=
leftLength
;
vodPlayHistoryDO
.
setVodId
(
vodDictDOS
.
get
(
j
).
getId
());
vodPlayHistoryDO
.
setVodId
(
vodDictDOS
.
get
(
j
).
getId
());
vodPlayHistoryDO
.
setPlayDate
(
signInRecordDO
.
getSignInDate
().
plusSeconds
(
playLength
));
vodPlayHistoryDO
.
setPlayDate
(
signInRecordDO
.
getSignInDate
().
plusSeconds
(
playLength
));
vodPlayHistoryMapper
.
insert
(
vodPlayHistoryDO
);
vodPlayHistoryMapper
.
insert
(
vodPlayHistoryDO
);
...
@@ -392,14 +392,188 @@ public class VodPlayHistoryServiceImpl extends ServiceImpl<VodPlayHistoryMapper,
...
@@ -392,14 +392,188 @@ public class VodPlayHistoryServiceImpl extends ServiceImpl<VodPlayHistoryMapper,
}
}
}
}
public
void
playLengthFix
(
RemainSecondsDTO
remainSecondsDTO
){
public
void
playLengthFix
(
RemainSecondsDTO
remainSecondsDTO
)
{
// 查看敲到次数
// 查看签到次数
ClassDictDO
classDictDO
=
classDictMapper
.
selectById
(
remainSecondsDTO
.
getClassId
());
//按照签到次数安排每天随机学习时长
//找到班级里的学生
List
<
ClassMemberMappingDO
>
classMemberMappingDOS
=
classMemberMappingMapper
.
selectList
(
new
QueryWrapper
<
ClassMemberMappingDO
>()
.
lambda
()
.
eq
(
ClassMemberMappingDO:
:
getClassId
,
classDictDO
.
getId
()));
//查找课程里的所有视频
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
,
classDictDO
.
getId
())
.
orderByAsc
(
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
;
}
}
//是否是最后一天的
int
key_index
=
0
;
// for (LocalDateTime localDateTime : hashMap.keySet()){
// if (hashMap.get(localDateTime)>10||hashMap.get(localDateTime)<5){
// System.out.println("================");
// }
// }
for
(
LocalDateTime
localDateTime
:
localDateTimes
)
{
//今天应该看多久视频
int
totalPlayLength
=
0
;
if
(
signInRecordDOS
.
size
()
==
3
)
{
totalPlayLength
=
_3times
();
}
else
if
(
signInRecordDOS
.
size
()
==
4
)
{
totalPlayLength
=
_4times
();
}
else
if
(
signInRecordDOS
.
size
()
==
5
)
{
totalPlayLength
=
_5times
();
}
else
if
(
signInRecordDOS
.
size
()
==
6
)
{
totalPlayLength
=
_6times
();
}
else
{
totalPlayLength
=
_7times
();
}
//今天已看视频时长
int
totalPlay
=
0
;
//先续播前一天未看完的视频
List
<
VodPlayHistoryDO
>
vodPlayHistoryDOS
=
vodPlayHistoryMapper
.
selectList
(
new
QueryWrapper
<
VodPlayHistoryDO
>()
.
lambda
()
.
eq
(
VodPlayHistoryDO:
:
getMemberId
,
classMemberMappingDO
.
getMemberId
())
.
eq
(
VodPlayHistoryDO:
:
getClassId
,
classDictDO
.
getId
())
.
orderByDesc
(
VodPlayHistoryDO:
:
getPlayDate
));
//续播
if
(
vodPlayHistoryDOS
.
size
()
>
0
)
{
VodPlayHistoryDO
vodPlayHistoryDO1
=
vodPlayHistoryDOS
.
get
(
0
);
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
(
classDictDO
.
getId
());
vodPlayHistoryDO
.
setMemberId
(
classMemberMappingDO
.
getMemberId
());
vodPlayHistoryDO
.
setPlayRecord
(
vodDictDO
.
getVodLength
());
vodPlayHistoryDO
.
setPlayLength
(
leftLength
);
vodPlayHistoryDO
.
setVodId
(
vodDictDO
.
getId
());
vodPlayHistoryDO
.
setPlayDate
(
localDateTime
.
plusSeconds
(
leftLength
));
vodPlayHistoryMapper
.
insert
(
vodPlayHistoryDO
);
}
}
//查找这个人应该学的课程
for
(
VodDictDO
vodDictDO
:
vodDictDOS
)
{
//从历史记录里找中这个人有没有学过
Integer
count
=
vodPlayHistoryMapper
.
selectCount
(
new
QueryWrapper
<
VodPlayHistoryDO
>()
.
lambda
()
.
eq
(
VodPlayHistoryDO:
:
getMemberId
,
classMemberMappingDO
.
getMemberId
())
.
eq
(
VodPlayHistoryDO:
:
getClassId
,
classDictDO
.
getId
())
.
eq
(
VodPlayHistoryDO:
:
getVodId
,
vodDictDO
.
getId
()));
//表示这个视频没有学过
if
(
count
==
0
)
{
if
(
totalPlayLength
>
totalPlay
)
{
//说明今天还可以学
VodPlayHistoryDO
vodPlayHistoryDO
=
new
VodPlayHistoryDO
();
vodPlayHistoryDO
.
setPlayCount
(
1
);
vodPlayHistoryDO
.
setClassId
(
classDictDO
.
getId
());
vodPlayHistoryDO
.
setMemberId
(
classMemberMappingDO
.
getMemberId
());
vodPlayHistoryDO
.
setPlayRecord
(
vodDictDO
.
getVodLength
());
if
(
totalPlay
+
vodDictDO
.
getVodLength
()<=
totalPlayLength
){
vodPlayHistoryDO
.
setPlayLength
(
vodDictDO
.
getVodLength
());
}
else
{
vodPlayHistoryDO
.
setPlayLength
(
totalPlayLength
-
totalPlay
);
}
vodPlayHistoryDO
.
setVodId
(
vodDictDO
.
getId
());
vodPlayHistoryDO
.
setPlayDate
(
localDateTime
.
plusSeconds
(
totalPlay
));
vodPlayHistoryMapper
.
insert
(
vodPlayHistoryDO
);
}
}
}
key_index
++;
}
}
}
//19为基数的话,3次签到6.5到8,4次签到4.8-6,
// 5次4-6,6次3.2-6,7次及以上2.5-6吧
//按照视频顺序依次学习完 每天学习时长不得超过8小时
//int randNumber =rand.nextInt(MAX - MIN + 1) + MIN;
/**
* 3次签到 23400---28800
*/
public
Integer
_3times
()
{
return
new
Random
().
nextInt
(
28800
-
23400
+
1
)
+
23400
;
}
/**
* 4次签到 23400---28800
*/
public
Integer
_4times
()
{
return
new
Random
().
nextInt
(
6
*
60
*
60
-
48
*
6
*
60
+
1
)
+
48
*
6
*
60
;
}
/**
* 5次签到 23400---28800
*/
public
Integer
_5times
()
{
return
new
Random
().
nextInt
(
6
*
60
*
60
-
4
*
60
*
60
+
1
)
+
4
*
60
*
60
;
}
/**
* 6次签到 23400---28800
*/
public
Integer
_6times
()
{
return
new
Random
().
nextInt
(
6
*
60
*
60
-
32
*
6
*
60
+
1
)
+
32
*
60
*
6
;
}
/**
* 7次签到 23400---28800
*/
public
Integer
_7times
()
{
return
new
Random
().
nextInt
(
6
*
60
*
60
-
25
*
6
*
60
+
1
)
+
25
*
6
*
60
;
}
}
public
static
void
main
(
String
[]
args
)
{
public
static
void
main
(
String
[]
args
)
{
...
...
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