Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
E
education
Project
Project
Details
Activity
Releases
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
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
李丛阳
education
Commits
56cb86f4
Commit
56cb86f4
authored
Nov 07, 2019
by
王淑君
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改接口
parent
144d8764
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
41 deletions
+24
-41
BChapterServiceImpl.java
...t/business/bchapter/service/impl/BChapterServiceImpl.java
+15
-15
BRStudentChapterServiceImpl.java
...dentchapter/service/impl/BRStudentChapterServiceImpl.java
+9
-26
No files found.
src/main/java/org/rcisoft/business/bchapter/service/impl/BChapterServiceImpl.java
View file @
56cb86f4
...
...
@@ -60,6 +60,7 @@ import java.nio.file.Files;
import
java.nio.file.Path
;
import
java.nio.file.Paths
;
import
java.text.DecimalFormat
;
import
java.text.NumberFormat
;
import
java.util.*
;
...
...
@@ -126,8 +127,6 @@ public class BChapterServiceImpl implements BChapterService {
model
.
setLessonId
(
lessonId
);
model
.
setStudentId
(
curUser
.
getUserId
());
List
<
QueryChapterListResDTO
>
queryChapterListResDTOS
=
queryChapterListResDTO
(
model
,
curUser
.
getCorpId
());
// int i = 0;
// int percent = 0;
for
(
QueryChapterListResDTO
queryChapterListResDTO
:
queryChapterListResDTOS
)
{
for
(
QueryChapterListResDTO
childList
:
queryChapterListResDTO
.
getChildList
())
{
// 遍历学生章节中间表 查询学生观看章节进度
...
...
@@ -135,9 +134,7 @@ public class BChapterServiceImpl implements BChapterService {
if
(
null
!=
brStudentChapterList
&&
brStudentChapterList
.
size
()
>
0
)
{
childList
.
setProgress
(
brStudentChapterList
.
get
(
0
).
getProgress
()
*
100
+
"%"
);
childList
.
setCurrentLocation
(
brStudentChapterList
.
get
(
0
).
getCurrentLocation
());
// percent += brStudentChapterList.get(0).getProgress();
}
// i++;
}
}
Map
map
=
new
HashMap
();
...
...
@@ -149,7 +146,6 @@ public class BChapterServiceImpl implements BChapterService {
}
else
{
map
.
put
(
"totalProgress"
,
"0%"
);
}
// map.put("totalProgress", i == 0 ? "0%" : df.format((float) percent / i) + "%");
BLesson
bLesson
=
bLessonRepository
.
selectInfoById
(
lessonId
);
//判断课程是否存在
if
(
bLesson
==
null
){
...
...
@@ -318,12 +314,14 @@ public class BChapterServiceImpl implements BChapterService {
// 所有学习过此课程的 学生课程信息
List
<
BLessonPerson
>
bLessonPersonList
=
bLessonPersonRepository
.
selectByLessonId
(
chapterDTO
.
getLessonId
());
BLesson
bLesson
=
bLessonRepository
.
selectByPrimaryKey
(
chapterDTO
.
getLessonId
());
NumberFormat
numberFormat
=
NumberFormat
.
getInstance
();
numberFormat
.
setMaximumFractionDigits
(
2
);
for
(
BLessonPerson
lessonPerson:
bLessonPersonList
){
// 更新 学生针对此章节的中间表
List
<
BRStudentChapter
>
brStudentChapterList
=
brStudentChapterRepository
.
queryByStuIdAndChapter
(
chapterDTO
.
getBusinessId
(),
""
);
for
(
BRStudentChapter
studentChapter:
brStudentChapterList
){
double
learnProgress
=
Double
.
parseDouble
(
lessonPerson
.
getLearnProgress
().
split
(
"%"
)[
0
])
/
100
;
double
newLearnProgress
=
(
learnProgress
*
Integer
.
parseInt
(
bLesson
.
getClassHour
())
-
studentChapter
.
getProgress
())
/
Double
.
parseDouble
(
bLesson
.
getClassHour
(
));
double
newLearnProgress
=
Double
.
parseDouble
(
numberFormat
.
format
((
float
)
(
learnProgress
*
Integer
.
parseInt
(
bLesson
.
getClassHour
())
-
studentChapter
.
getProgress
())
/
Float
.
parseFloat
(
bLesson
.
getClassHour
())
));
if
(
learnProgress
>
0
&&
newLearnProgress
<
0.01
){
newLearnProgress
=
0.01
;
}
...
...
@@ -370,29 +368,31 @@ public class BChapterServiceImpl implements BChapterService {
*/
// 新增章节 - 更新学生观看课程总进度
private
void
updateLessonProgress
(
String
lessonId
,
boolean
add
){
NumberFormat
numberFormat
=
NumberFormat
.
getInstance
();
numberFormat
.
setMaximumFractionDigits
(
2
);
List
<
BLessonPerson
>
bLessonPersonList
=
bLessonPersonRepository
.
selectByLessonId
(
lessonId
);
BLesson
bLesson
=
bLessonRepository
.
selectByPrimaryKey
(
lessonId
);
for
(
BLessonPerson
lessonPerson:
bLessonPersonList
){
double
newLearnProgress
;
String
newLearnProgress
;
double
learnProgress
=
Double
.
parseDouble
(
lessonPerson
.
getLearnProgress
().
split
(
"%"
)[
0
])
/
100
;
if
(
add
){
newLearnProgress
=
(
float
)
Math
.
floor
(
learnProgress
*
Integer
.
parseInt
(
bLesson
.
getClassHour
())
/
(
Double
.
parseDouble
(
bLesson
.
getClassHour
())
+
1
));
newLearnProgress
=
numberFormat
.
format
(
Math
.
floor
(
learnProgress
*
Integer
.
parseInt
(
bLesson
.
getClassHour
())
/
(
Double
.
parseDouble
(
bLesson
.
getClassHour
())
+
1
)
));
}
else
{
newLearnProgress
=
Integer
.
parseInt
(
bLesson
.
getClassHour
())
==
0
?
0
:
(
float
)
Math
.
floor
(
learnProgress
*
Integer
.
parseInt
(
bLesson
.
getClassHour
()
+
1
)
/
Double
.
parseDouble
(
bLesson
.
getClassHour
()
));
newLearnProgress
=
Integer
.
parseInt
(
bLesson
.
getClassHour
())
==
0
?
"0"
:
numberFormat
.
format
(
Math
.
floor
(
learnProgress
*
Integer
.
parseInt
(
bLesson
.
getClassHour
()
+
1
)
/
Double
.
parseDouble
(
bLesson
.
getClassHour
())
));
}
if
(
learnProgress
>
0
&&
newLearnProgress
<
0.01
){
newLearnProgress
=
0.01
;
if
(
learnProgress
>
0
&&
Double
.
parseDouble
(
newLearnProgress
)
<
0.01
){
newLearnProgress
=
"0.01"
;
}
if
(
"2"
.
equals
(
lessonPerson
.
getIsFinish
())
&&
newLearnProgress
<
1
){
if
(
"2"
.
equals
(
lessonPerson
.
getIsFinish
())
&&
Double
.
parseDouble
(
newLearnProgress
)
<
1
){
lessonPerson
.
setIsFinish
(
"1"
);
lessonPerson
.
setFinishDate
(
null
);
}
if
(
newLearnProgress
>=
1
){
newLearnProgress
=
1
;
if
(
Double
.
parseDouble
(
newLearnProgress
)
>=
1
){
newLearnProgress
=
"1"
;
lessonPerson
.
setIsFinish
(
"2"
);
}
lessonPerson
.
setLearnProgress
(
newLearnProgress
*
100
+
"%"
);
lessonPerson
.
setLearnProgress
(
Float
.
parseFloat
(
newLearnProgress
)
*
100
+
"%"
);
bLessonPersonRepository
.
updateByPrimaryKeySelective
(
lessonPerson
);
}
}
...
...
src/main/java/org/rcisoft/business/brstudentchapter/service/impl/BRStudentChapterServiceImpl.java
View file @
56cb86f4
...
...
@@ -33,6 +33,7 @@ import org.springframework.transaction.annotation.Transactional;
import
java.math.BigDecimal
;
import
java.text.BreakIterator
;
import
java.text.DecimalFormat
;
import
java.text.NumberFormat
;
import
java.util.Date
;
import
java.util.List
;
import
lombok.extern.slf4j.Slf4j
;
...
...
@@ -65,7 +66,9 @@ public class BRStudentChapterServiceImpl implements BRStudentChapterService {
@Override
public
PersistModel
save
(
BRStudentChapterDto
brStudentChapterDto
,
CurUser
curUser
){
int
line
=
0
;
DecimalFormat
df
=
new
DecimalFormat
(
"0.00"
);
//设置保留位数
// DecimalFormat df=new DecimalFormat("0.00");//设置保留位数
NumberFormat
numberFormat
=
NumberFormat
.
getInstance
();
numberFormat
.
setMaximumFractionDigits
(
0
);
// 查詢是否已經開始觀看此章節
List
<
BRStudentChapter
>
brStudentChapterList
=
bRStudentChapterRepository
.
queryByStuIdAndChapter
(
brStudentChapterDto
.
getChapterId
(),
brStudentChapterDto
.
getStudentId
());
// 沒有開始看-新增信息
...
...
@@ -86,17 +89,7 @@ public class BRStudentChapterServiceImpl implements BRStudentChapterService {
brStudentChapter
=
this
.
dealBrstudentChapter
(
brStudentChapter
,
brStudentChapterDto
);
brStudentChapter
.
setStudentId
(
brStudentChapterDto
.
getStudentId
());
brStudentChapter
.
setChapterId
(
brStudentChapterDto
.
getChapterId
());
// brStudentChapter.setCurrentLocation(brStudentChapterDto.getCurrent()); // 保存當前學習進度
// if (brStudentChapterDto.getCurrent().equals(brStudentChapterDto.getDuration())){ // 判断是否已经完成
// brStudentChapter.setIsComplete("1");
// brStudentChapter.setProgress(1);
// isFinish = "2";
// }else {
// isFinish = "1";
// brStudentChapter.setIsComplete("0");
// brStudentChapter.setProgress((float)brStudentChapterDto.getCurrent()/brStudentChapterDto.getDuration());
//// brStudentChapter.setProgress(new BigDecimal((float)brStudentChapterDto.getCurrent()/brStudentChapterDto.getDuration()).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
// }
line
=
bRStudentChapterRepository
.
insertSelective
(
brStudentChapter
);
}
// b_lesson_person
...
...
@@ -127,17 +120,13 @@ public class BRStudentChapterServiceImpl implements BRStudentChapterService {
if
(
i
==
0
){
totalProgress
=
"0.00%"
;
}
else
{
totalProgress
=
df
.
format
((
float
)
((
percent
/
i
)
*
100
))
+
"%"
;
totalProgress
=
numberFormat
.
format
((
float
)
percent
/
(
float
)
i
*
100
)
+
"%"
;
// totalProgress = df.format((float) ((percent / i) * 100)) + "%";
};
// 判斷是否已經開始觀看此課程
if
(
null
!=
bLessonPersonList
&&
bLessonPersonList
.
size
()
>
0
){
BLessonPerson
bLessonPerson
=
this
.
dealBLessonPerson
(
bLessonPersonList
.
get
(
0
),
brStudentChapterDto
,
totalProgress
);
// BLessonPerson bLessonPerson = bLessonPersonList.get(0);
// bLessonPerson.setChapterId(brStudentChapterDto.getChapterId());
// bLessonPerson.setLearnProgress(totalProgress); // 保存课程学习进度
// if ("2".equals(isFinish))
// bLessonPerson.setFinishDate(new Date());
// bLessonPerson.setIsFinish(isFinish);
bLessonPersonRepository
.
updateByPrimaryKeySelective
(
bLessonPerson
);
}
else
{
BLessonPerson
bLessonPerson
=
new
BLessonPerson
();
...
...
@@ -145,11 +134,7 @@ public class BRStudentChapterServiceImpl implements BRStudentChapterService {
bLessonPerson
=
this
.
dealBLessonPerson
(
bLessonPersonList
.
get
(
0
),
brStudentChapterDto
,
totalProgress
);
bLessonPerson
.
setPersonId
(
brStudentChapterDto
.
getStudentId
());
bLessonPerson
.
setLessonId
(
brStudentChapterDto
.
getLessonId
());
// if ("2".equals(isFinish))
// bLessonPerson.setFinishDate(new Date());
// bLessonPerson.setIsFinish(isFinish);
// bLessonPerson.setChapterId(brStudentChapterDto.getChapterId());
// bLessonPerson.setLearnProgress(totalProgress); // 保存课程学习进度
// 保存课程学习进度
line
=
bLessonPersonRepository
.
insertSelective
(
bLessonPerson
)
;
}
// 获取章节总进度 存库
...
...
@@ -181,8 +166,6 @@ public class BRStudentChapterServiceImpl implements BRStudentChapterService {
String
isFinish
;
if
(
"100%"
.
equals
(
totalProgress
))
{
isFinish
=
"2"
;
}
else
if
(
"0%"
.
equals
(
totalProgress
)){
isFinish
=
"0"
;
}
else
{
isFinish
=
"1"
;
}
...
...
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