Commit 056b9d23 by 涂亚平

程序处理改成了sql处理

1 parent 168678a9
...@@ -103,7 +103,7 @@ public class MemberController { ...@@ -103,7 +103,7 @@ public class MemberController {
} }
@PostMapping("studyHistory") @PostMapping("studyHistory")
@ApiOperation("** 学习记录 id 成员id pageSize pageNum") @ApiOperation("** 学习记录 memberId 成员id pageSize pageNum")
public ResponseVO studyHistory(@RequestBody StudyHistoryDTO studyHistoryDTO){ public ResponseVO studyHistory(@RequestBody StudyHistoryDTO studyHistoryDTO){
return ResponseData.generateCreatedResponse(0,memberService.studyHistory(studyHistoryDTO)); return ResponseData.generateCreatedResponse(0,memberService.studyHistory(studyHistoryDTO));
} }
......
...@@ -41,4 +41,9 @@ public interface VodPlayHistoryMapper extends BaseMapper<VodPlayHistoryDO> { ...@@ -41,4 +41,9 @@ public interface VodPlayHistoryMapper extends BaseMapper<VodPlayHistoryDO> {
* 查看某人当天看了多少时间 * 查看某人当天看了多少时间
*/ */
int memberDailyStudyLength(Long memberId); int memberDailyStudyLength(Long memberId);
/**
* 查看学生是否完成了某个视频
*/
int completeVodOrNot(Long memberId,Long vodId);
} }
...@@ -319,7 +319,7 @@ public class MemberServiceImpl extends ServiceImpl<MemberMapper, MemberDO> imple ...@@ -319,7 +319,7 @@ public class MemberServiceImpl extends ServiceImpl<MemberMapper, MemberDO> imple
} }
} }
if (memberDO.getPassword().equals(passwordLoginDTO.getPassword())&&1==memberDO.getFirstLogin()&&"冻结".equals(memberDO.getStatus())){ if (memberDO.getPassword().equals(passwordLoginDTO.getPassword()) && 1 == memberDO.getFirstLogin() && "冻结".equals(memberDO.getStatus())) {
MemberVO memberVO = new MemberVO(); MemberVO memberVO = new MemberVO();
BeanUtils.copyProperties(memberDO, memberVO); BeanUtils.copyProperties(memberDO, memberVO);
OprMemDictDO oprMemDictDO = new OprMemDictDO(); OprMemDictDO oprMemDictDO = new OprMemDictDO();
...@@ -329,7 +329,7 @@ public class MemberServiceImpl extends ServiceImpl<MemberMapper, MemberDO> imple ...@@ -329,7 +329,7 @@ public class MemberServiceImpl extends ServiceImpl<MemberMapper, MemberDO> imple
oprMemDictDO.setCreateDate(LocalDateTime.now()); oprMemDictDO.setCreateDate(LocalDateTime.now());
redisUtil.set(RedisPrefixConstant.SUBSIDY_MEMBER_LOGIN_PREFIX + memberDO.getId() + "_" + System.currentTimeMillis(), 1); redisUtil.set(RedisPrefixConstant.SUBSIDY_MEMBER_LOGIN_PREFIX + memberDO.getId() + "_" + System.currentTimeMillis(), 1);
return memberVO; return memberVO;
}else { } else {
if (!memberDO.getPassword().equals(passwordLoginDTO.getPassword())) { if (!memberDO.getPassword().equals(passwordLoginDTO.getPassword())) {
OprMemDictDO oprMemDictDO = new OprMemDictDO(); OprMemDictDO oprMemDictDO = new OprMemDictDO();
oprMemDictDO.setUserId(memberDO.getId()); oprMemDictDO.setUserId(memberDO.getId());
...@@ -368,70 +368,27 @@ public class MemberServiceImpl extends ServiceImpl<MemberMapper, MemberDO> imple ...@@ -368,70 +368,27 @@ public class MemberServiceImpl extends ServiceImpl<MemberMapper, MemberDO> imple
List<StudyPageVO> studyPageVOS = this.baseMapper.studyPage(memberDO); List<StudyPageVO> studyPageVOS = this.baseMapper.studyPage(memberDO);
for (StudyPageVO studyPageVO : studyPageVOS) { final ExecutorService newCachedThreadPool = Executors.newCachedThreadPool();
for (StudyPageVO studyPageVO : studyPageVOS) {
//查看课程下有几节课 //查看课程下有几节课
List<VodDictDO> vodDictDOS = courseContentMapper.getCourseVods(studyPageVO.getId()); List<VodDictDO> vodDictDOS = courseContentMapper.getCourseVods(studyPageVO.getId());
studyPageVO.setTotalVods(vodDictDOS.size()); studyPageVO.setTotalVods(vodDictDOS.size());
newCachedThreadPool.submit(() -> studyPageTask1(studyPageVO, vodDictDOS, memberDO.getId()));
final ExecutorService newCachedThreadPool = Executors.newCachedThreadPool();
int i = 0;
//该成员完成了几个视频
for (VodDictDO vodDictDO : vodDictDOS) {
List<VodPlayHistoryDO> vodPlayHistoryDOS = vodPlayHistoryMapper.selectList(new QueryWrapper<VodPlayHistoryDO>()
.lambda()
.eq(VodPlayHistoryDO::getMemberId, memberDO.getId())
.eq(VodPlayHistoryDO::getVodId, vodDictDO.getId())
.orderByDesc(VodPlayHistoryDO::getPlayRecord));
if (vodPlayHistoryDOS.size() > 0) {
if (vodPlayHistoryDOS.get(0).getPlayRecord() > vodDictDO.getVodLength() * 0.8) {
i++;
} }
}
}
studyPageVO.setDoneVods(i);
//该班级课程下有多少人
List<ClassMemberMappingDO> classMemberMappingDOS = classMemberMappingMapper.selectList(new QueryWrapper<ClassMemberMappingDO>()
.lambda()
.eq(ClassMemberMappingDO::getClassId, studyPageVO.getClassId()));
studyPageVO.setTotalMember(classMemberMappingDOS.size());
////多个任务
//newCachedThreadPool.execute(() ->
// studyPageTask1(studyPageVO, vodDictDOS, memberDO.getId()));
//newCachedThreadPool.execute(() ->
// studyPageTask2(studyPageVO));
//执行后不再接收新任务,如果里面有任务,就执行完
newCachedThreadPool.shutdown(); newCachedThreadPool.shutdown();
try {
while (true) {
//等待所有任务都结束了继续执行
if (newCachedThreadPool.isTerminated()) {
break;
}
}
} catch (Exception ex) {
ex.printStackTrace();
}
}
memberStudyPageVO.setStudyPageVOS(studyPageVOS); memberStudyPageVO.setStudyPageVOS(studyPageVOS);
List<DepartmentDictDO> departmentDictDOS = this.baseMapper.getDepartments(memberDO.getId()); //List<DepartmentDictDO> departmentDictDOS = this.baseMapper.getDepartments(memberDO.getId());
//
if (departmentDictDOS.size() > 0) { //if (departmentDictDOS.size() > 0) {
CompanyDictDO companyDictDO = companyDictMapper.selectById(departmentDictDOS.get(0).getId()); // CompanyDictDO companyDictDO = companyDictMapper.selectById(departmentDictDOS.get(0).getId());
if (null != companyDictDO) { // if (null != companyDictDO) {
BeanUtils.copyProperties(companyDictDO, memberStudyPageVO); // BeanUtils.copyProperties(companyDictDO, memberStudyPageVO);
} // }
} //}
return memberStudyPageVO; return memberStudyPageVO;
} }
...@@ -441,30 +398,21 @@ public class MemberServiceImpl extends ServiceImpl<MemberMapper, MemberDO> imple ...@@ -441,30 +398,21 @@ public class MemberServiceImpl extends ServiceImpl<MemberMapper, MemberDO> imple
//该成员完成了几个视频 //该成员完成了几个视频
for (VodDictDO vodDictDO : vodDictDOS) { for (VodDictDO vodDictDO : vodDictDOS) {
List<VodPlayHistoryDO> vodPlayHistoryDOS = vodPlayHistoryMapper.selectList(new QueryWrapper<VodPlayHistoryDO>() int completeVodOrNot = vodPlayHistoryMapper.completeVodOrNot(memberId, vodDictDO.getId());
.lambda() i += completeVodOrNot;
.eq(VodPlayHistoryDO::getMemberId, memberId)
.eq(VodPlayHistoryDO::getVodId, vodDictDO.getId())
.orderByDesc(VodPlayHistoryDO::getPlayRecord));
if (vodPlayHistoryDOS.size() > 0) {
if (vodPlayHistoryDOS.get(0).getPlayRecord() > vodDictDO.getVodLength() * 0.8) {
i++;
}
}
} }
studyPageVO.setDoneVods(i); studyPageVO.setDoneVods(i);
//该班级课程下有多少人
Integer count = classMemberMappingMapper.selectCount(new QueryWrapper<ClassMemberMappingDO>()
.lambda()
.eq(ClassMemberMappingDO::getClassId, studyPageVO.getClassId()));
studyPageVO.setTotalMember(count);
return new AsyncResult<>(studyPageVO); return new AsyncResult<>(studyPageVO);
} }
public Future<StudyPageVO> studyPageTask2(StudyPageVO studyPageVO) { public Future<StudyPageVO> studyPageTask2(StudyPageVO studyPageVO) {
//该班级课程下有多少人
List<ClassMemberMappingDO> classMemberMappingDOS = classMemberMappingMapper.selectList(new QueryWrapper<ClassMemberMappingDO>()
.lambda()
.eq(ClassMemberMappingDO::getClassId, studyPageVO.getClassId()));
studyPageVO.setTotalMember(classMemberMappingDOS.size());
return new AsyncResult<>(studyPageVO); return new AsyncResult<>(studyPageVO);
} }
...@@ -608,21 +556,7 @@ public class MemberServiceImpl extends ServiceImpl<MemberMapper, MemberDO> imple ...@@ -608,21 +556,7 @@ public class MemberServiceImpl extends ServiceImpl<MemberMapper, MemberDO> imple
public IPage studyHistory(StudyHistoryDTO studyHistoryDTO) { public IPage studyHistory(StudyHistoryDTO studyHistoryDTO) {
Page pager = new Page(studyHistoryDTO.getPageNum(), studyHistoryDTO.getPageSize()); Page pager = new Page(studyHistoryDTO.getPageNum(), studyHistoryDTO.getPageSize());
return vodPlayHistoryMapper.studyHistory(pager, studyHistoryDTO.getMemberId());
IPage iPage = vodPlayHistoryMapper.studyHistory(pager, studyHistoryDTO.getMemberId());
List<StudyHistoryVO> studyHistoryVOS = iPage.getRecords();
for (StudyHistoryVO studyHistoryVO : studyHistoryVOS) {
if (studyHistoryVO.getPercent() >= 80) {
studyHistoryVO.setStatus(true);
} else {
studyHistoryVO.setStatus(false);
}
}
iPage.setRecords(studyHistoryVOS);
return iPage;
} }
public List<QueryPapersVO> getCourseTest(ContentMemberDTO contentMemberDTO) { public List<QueryPapersVO> getCourseTest(ContentMemberDTO contentMemberDTO) {
...@@ -632,12 +566,12 @@ public class MemberServiceImpl extends ServiceImpl<MemberMapper, MemberDO> imple ...@@ -632,12 +566,12 @@ public class MemberServiceImpl extends ServiceImpl<MemberMapper, MemberDO> imple
List<QueryPapersVO> queryPapersVOS = paperDictMapper.queryPapers(contentMemberDTO.getCourseId(), null, 1); List<QueryPapersVO> queryPapersVOS = paperDictMapper.queryPapers(contentMemberDTO.getCourseId(), null, 1);
ExecutorService executorService = Executors.newCachedThreadPool(); ExecutorService executorService = Executors.newCachedThreadPool();
for (QueryPapersVO queryPapersVO : queryPapersVOS) { for (QueryPapersVO queryPapersVO : queryPapersVOS) {
executorService.execute(()->getCourseTestTask(queryPapersVO,contentMemberDTO.getMemberId(),classDictDO)); executorService.execute(() -> getCourseTestTask(queryPapersVO, contentMemberDTO.getMemberId(), classDictDO));
} }
return queryPapersVOS; return queryPapersVOS;
} }
public void getCourseTestTask(QueryPapersVO queryPapersVO,Long memberId,ClassDictDO classDictDO){ public void getCourseTestTask(QueryPapersVO queryPapersVO, Long memberId, ClassDictDO classDictDO) {
//多少人已完成 //多少人已完成
Integer cnt = paperDictMapper.completeCount(queryPapersVO.getId()); Integer cnt = paperDictMapper.completeCount(queryPapersVO.getId());
queryPapersVO.setCompleteCnt(cnt); queryPapersVO.setCompleteCnt(cnt);
...@@ -751,7 +685,7 @@ public class MemberServiceImpl extends ServiceImpl<MemberMapper, MemberDO> imple ...@@ -751,7 +685,7 @@ public class MemberServiceImpl extends ServiceImpl<MemberMapper, MemberDO> imple
public String checkTimes(ExerciseDoneResultDO exerciseDoneResultDO) { public String checkTimes(ExerciseDoneResultDO exerciseDoneResultDO) {
MemberDO memberDO = this.baseMapper.selectById(exerciseDoneResultDO.getMemberId()); MemberDO memberDO = this.baseMapper.selectById(exerciseDoneResultDO.getMemberId());
ClassHourDictDO classHourDictDO = (ClassHourDictDO) redisUtil.get(RedisPrefixConstant.SUBSIDY_SETTINGS_PREFIX+memberDO.getCompanyId()); ClassHourDictDO classHourDictDO = (ClassHourDictDO) redisUtil.get(RedisPrefixConstant.SUBSIDY_SETTINGS_PREFIX + memberDO.getCompanyId());
if (null != classHourDictDO) { if (null != classHourDictDO) {
Integer status = classHourDictDO.getRepeatStatus(); Integer status = classHourDictDO.getRepeatStatus();
......
...@@ -222,10 +222,9 @@ public class SignInRecordServiceImpl extends ServiceImpl<SignInRecordMapper, Sig ...@@ -222,10 +222,9 @@ public class SignInRecordServiceImpl extends ServiceImpl<SignInRecordMapper, Sig
//获取有效课程 //获取有效课程
long count = classMemberMappingMapper.getMemberClassCount(signInRecordDO.getMemberId()); long count = classMemberMappingMapper.getMemberClassCount(signInRecordDO.getMemberId());
long size = redisUtil.keys(RedisPrefixConstant.SUBSIDY_SIGN_INFO_PREFIX + "memberId_" + signInRecordDO.getMemberId() + "*_" + DateFormatUtil.format(new Date(), "yyyyMMdd")).stream().count(); long size = redisUtil.keys(RedisPrefixConstant.SUBSIDY_SIGN_INFO_PREFIX + "memberId_" + signInRecordDO.getMemberId() + "*_" + DateFormatUtil.format(new Date(), "yyyyMMdd")).stream().count();
if (size!=count){ if (size != count) {
signInStatusVO.setStatus(flag); signInStatusVO.setStatus(flag);
} }
...@@ -247,8 +246,8 @@ public class SignInRecordServiceImpl extends ServiceImpl<SignInRecordMapper, Sig ...@@ -247,8 +246,8 @@ public class SignInRecordServiceImpl extends ServiceImpl<SignInRecordMapper, Sig
//} //}
List<ClassHourDictDO> classHourDictDOS = classHourDictMapper.selectList(null); List<ClassHourDictDO> classHourDictDOS = classHourDictMapper.selectList(null);
for (ClassHourDictDO classHourDictDO : classHourDictDOS){ for (ClassHourDictDO classHourDictDO : classHourDictDOS) {
redisUtil.set("subsidySettings_"+classHourDictDO.getCompanyId(),classHourDictDO); redisUtil.set("subsidySettings_" + classHourDictDO.getCompanyId(), classHourDictDO);
} }
} }
......
...@@ -4,14 +4,14 @@ spring.profiles.active=dev ...@@ -4,14 +4,14 @@ spring.profiles.active=dev
spring.server.port=23457 spring.server.port=23457
#嵌入tomcat配置 #嵌入tomcat配置
#和CPU数 #和CPU数
spring.server.acceptorThreadCount=200 spring.server.acceptorThreadCount=600
spring.server.minSpareThreads=100 spring.server.minSpareThreads=100
spring.server.maxSpareThreads=500 spring.server.maxSpareThreads=500
spring.server.maxThreads=800 spring.server.maxThreads=500
spring.server.maxConnections=50000 spring.server.maxConnections=1000
#10秒超时 #10秒超时
spring.server.connectionTimeout=20000 spring.server.connectionTimeout=20000
spring.server.protocol=org.apache.coyote.http11.Http11Nio2Protocol spring.server.protocol=org.apache.coyote.http11.Http11AprProtocol
spring.server.redirectPort=8443 spring.server.redirectPort=8443
spring.server.compression=on spring.server.compression=on
#文件请求大小 #文件请求大小
......
...@@ -23,7 +23,16 @@ ...@@ -23,7 +23,16 @@
<select id="getCourseVods" parameterType="integer" resultType="com.subsidy.model.VodDictDO"> <select id="getCourseVods" parameterType="integer" resultType="com.subsidy.model.VodDictDO">
SELECT SELECT
t2.* t2.id,
t2.content_id,
t2.vod_name,
t2.vod_length,
t2.vod_type,
t2.vod_size,
t2.vod_url,
t2.vod_code,
t2.teacher_name,
t2.cover_page
FROM FROM
course_content t course_content t
LEFT JOIN vod_dict t2 ON t.id = t2.content_id LEFT JOIN vod_dict t2 ON t.id = t2.content_id
......
...@@ -35,7 +35,7 @@ ...@@ -35,7 +35,7 @@
t2.vod_url, t2.vod_url,
t2.vod_name, t2.vod_name,
t3.play_record, t3.play_record,
round( t3.play_record * 100 / t2.vod_length, 0 ) AS percent, if(round( t3.play_record * 100 / t2.vod_length, 0 )>=80,'true','false') as status,
t.playDate t.playDate
FROM FROM
( (
...@@ -113,4 +113,17 @@ ...@@ -113,4 +113,17 @@
AND t.member_id = #{memberId} AND t.member_id = #{memberId}
</select> </select>
<select id="completeVodOrNot" resultType="integer">
SELECT
IF
( max( t.play_record ) > t2.vod_length, 1, 0 ) AS count
FROM
vod_play_history t
LEFT JOIN vod_dict t2 ON t.vod_id = t2.id
WHERE
t.delete_date is null
and t2.delete_date is null
t.member_id = #{memberId}
AND t.vod_id = #{vodId}
</select>
</mapper> </mapper>
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!