diff --git a/src/main/java/com/subsidy/controller/MemberController.java b/src/main/java/com/subsidy/controller/MemberController.java index 6c66c52..d2e1bcf 100644 --- a/src/main/java/com/subsidy/controller/MemberController.java +++ b/src/main/java/com/subsidy/controller/MemberController.java @@ -103,7 +103,7 @@ public class MemberController { } @PostMapping("studyHistory") - @ApiOperation("** 学习记录 id 成员id pageSize pageNum") + @ApiOperation("** 学习记录 memberId 成员id pageSize pageNum") public ResponseVO studyHistory(@RequestBody StudyHistoryDTO studyHistoryDTO){ return ResponseData.generateCreatedResponse(0,memberService.studyHistory(studyHistoryDTO)); } diff --git a/src/main/java/com/subsidy/mapper/VodPlayHistoryMapper.java b/src/main/java/com/subsidy/mapper/VodPlayHistoryMapper.java index dcdf6ba..c3fa7ce 100644 --- a/src/main/java/com/subsidy/mapper/VodPlayHistoryMapper.java +++ b/src/main/java/com/subsidy/mapper/VodPlayHistoryMapper.java @@ -41,4 +41,9 @@ public interface VodPlayHistoryMapper extends BaseMapper { * 查看某人当天看了多少时间 */ int memberDailyStudyLength(Long memberId); + + /** + * 查看学生是否完成了某个视频 + */ + int completeVodOrNot(Long memberId,Long vodId); } diff --git a/src/main/java/com/subsidy/service/impl/MemberServiceImpl.java b/src/main/java/com/subsidy/service/impl/MemberServiceImpl.java index 6834ee4..7a27e7d 100644 --- a/src/main/java/com/subsidy/service/impl/MemberServiceImpl.java +++ b/src/main/java/com/subsidy/service/impl/MemberServiceImpl.java @@ -319,7 +319,7 @@ public class MemberServiceImpl extends ServiceImpl 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(); BeanUtils.copyProperties(memberDO, memberVO); OprMemDictDO oprMemDictDO = new OprMemDictDO(); @@ -327,15 +327,15 @@ public class MemberServiceImpl extends ServiceImpl imple oprMemDictDO.setOprType("登录"); oprMemDictDO.setResult(1); 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; - }else { + } else { if (!memberDO.getPassword().equals(passwordLoginDTO.getPassword())) { OprMemDictDO oprMemDictDO = new OprMemDictDO(); oprMemDictDO.setUserId(memberDO.getId()); oprMemDictDO.setOprType("登录"); oprMemDictDO.setResult(0); - redisUtil.set(RedisPrefixConstant.SUBSIDY_MEMBER_LOGIN_PREFIX + memberDO.getId() + LocalDateTime.now(), oprMemDictDO); + redisUtil.set(RedisPrefixConstant.SUBSIDY_MEMBER_LOGIN_PREFIX + memberDO.getId() + LocalDateTime.now(), oprMemDictDO); throw new HttpException(10016); } if (0 == memberDO.getFirstLogin()) { @@ -344,7 +344,7 @@ public class MemberServiceImpl extends ServiceImpl imple oprMemDictDO.setOprType("登录"); oprMemDictDO.setResult(0); oprMemDictDO.setCreateDate(LocalDateTime.now()); - redisUtil.set(RedisPrefixConstant.SUBSIDY_MEMBER_LOGIN_PREFIX + memberDO.getId() + "_" + System.currentTimeMillis(), 0); + redisUtil.set(RedisPrefixConstant.SUBSIDY_MEMBER_LOGIN_PREFIX + memberDO.getId() + "_" + System.currentTimeMillis(), 0); throw new HttpException(10015); } if ("冻结".equals(memberDO.getStatus())) { @@ -358,7 +358,7 @@ public class MemberServiceImpl extends ServiceImpl imple public String updatePassword(MemberDO memberDO) { this.baseMapper.updateById(memberDO); MemberDO memberDO1 = this.baseMapper.selectById(memberDO.getId()); - redisUtil.set(RedisPrefixConstant.SUBSIDY_COMPANY_MEMBER_PREFIX + memberDO1.getCompanyId() + ":" + memberDO.getAccountName(), memberDO); + redisUtil.set(RedisPrefixConstant.SUBSIDY_COMPANY_MEMBER_PREFIX + memberDO1.getCompanyId() + ":" + memberDO.getAccountName(), memberDO); return ConstantUtils.SET_SUCCESS; } @@ -368,70 +368,27 @@ public class MemberServiceImpl extends ServiceImpl imple List studyPageVOS = this.baseMapper.studyPage(memberDO); - for (StudyPageVO studyPageVO : studyPageVOS) { + final ExecutorService newCachedThreadPool = Executors.newCachedThreadPool(); + for (StudyPageVO studyPageVO : studyPageVOS) { //查看课程下有几节课 List vodDictDOS = courseContentMapper.getCourseVods(studyPageVO.getId()); studyPageVO.setTotalVods(vodDictDOS.size()); - - final ExecutorService newCachedThreadPool = Executors.newCachedThreadPool(); - - int i = 0; - - //该成员完成了几个视频 - for (VodDictDO vodDictDO : vodDictDOS) { - List vodPlayHistoryDOS = vodPlayHistoryMapper.selectList(new QueryWrapper() - .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 classMemberMappingDOS = classMemberMappingMapper.selectList(new QueryWrapper() - .lambda() - .eq(ClassMemberMappingDO::getClassId, studyPageVO.getClassId())); - studyPageVO.setTotalMember(classMemberMappingDOS.size()); - - ////多个任务 - //newCachedThreadPool.execute(() -> - // studyPageTask1(studyPageVO, vodDictDOS, memberDO.getId())); - //newCachedThreadPool.execute(() -> - // studyPageTask2(studyPageVO)); - - //执行后不再接收新任务,如果里面有任务,就执行完 - newCachedThreadPool.shutdown(); - try { - while (true) { - //等待所有任务都结束了继续执行 - if (newCachedThreadPool.isTerminated()) { - break; - } - } - - } catch (Exception ex) { - ex.printStackTrace(); - } + newCachedThreadPool.submit(() -> studyPageTask1(studyPageVO, vodDictDOS, memberDO.getId())); } - memberStudyPageVO.setStudyPageVOS(studyPageVOS); + newCachedThreadPool.shutdown(); - List departmentDictDOS = this.baseMapper.getDepartments(memberDO.getId()); + memberStudyPageVO.setStudyPageVOS(studyPageVOS); - if (departmentDictDOS.size() > 0) { - CompanyDictDO companyDictDO = companyDictMapper.selectById(departmentDictDOS.get(0).getId()); - if (null != companyDictDO) { - BeanUtils.copyProperties(companyDictDO, memberStudyPageVO); - } - } + //List departmentDictDOS = this.baseMapper.getDepartments(memberDO.getId()); + // + //if (departmentDictDOS.size() > 0) { + // CompanyDictDO companyDictDO = companyDictMapper.selectById(departmentDictDOS.get(0).getId()); + // if (null != companyDictDO) { + // BeanUtils.copyProperties(companyDictDO, memberStudyPageVO); + // } + //} return memberStudyPageVO; } @@ -441,30 +398,21 @@ public class MemberServiceImpl extends ServiceImpl imple //该成员完成了几个视频 for (VodDictDO vodDictDO : vodDictDOS) { - List vodPlayHistoryDOS = vodPlayHistoryMapper.selectList(new QueryWrapper() - .lambda() - .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++; - } - } + int completeVodOrNot = vodPlayHistoryMapper.completeVodOrNot(memberId, vodDictDO.getId()); + i += completeVodOrNot; } studyPageVO.setDoneVods(i); + //该班级课程下有多少人 + Integer count = classMemberMappingMapper.selectCount(new QueryWrapper() + .lambda() + .eq(ClassMemberMappingDO::getClassId, studyPageVO.getClassId())); + studyPageVO.setTotalMember(count); return new AsyncResult<>(studyPageVO); } public Future studyPageTask2(StudyPageVO studyPageVO) { - //该班级课程下有多少人 - List classMemberMappingDOS = classMemberMappingMapper.selectList(new QueryWrapper() - .lambda() - .eq(ClassMemberMappingDO::getClassId, studyPageVO.getClassId())); - studyPageVO.setTotalMember(classMemberMappingDOS.size()); return new AsyncResult<>(studyPageVO); } @@ -608,21 +556,7 @@ public class MemberServiceImpl extends ServiceImpl imple public IPage studyHistory(StudyHistoryDTO studyHistoryDTO) { Page pager = new Page(studyHistoryDTO.getPageNum(), studyHistoryDTO.getPageSize()); - - IPage iPage = vodPlayHistoryMapper.studyHistory(pager, studyHistoryDTO.getMemberId()); - - List studyHistoryVOS = iPage.getRecords(); - - for (StudyHistoryVO studyHistoryVO : studyHistoryVOS) { - if (studyHistoryVO.getPercent() >= 80) { - studyHistoryVO.setStatus(true); - } else { - studyHistoryVO.setStatus(false); - } - } - iPage.setRecords(studyHistoryVOS); - - return iPage; + return vodPlayHistoryMapper.studyHistory(pager, studyHistoryDTO.getMemberId()); } public List getCourseTest(ContentMemberDTO contentMemberDTO) { @@ -632,12 +566,12 @@ public class MemberServiceImpl extends ServiceImpl imple List queryPapersVOS = paperDictMapper.queryPapers(contentMemberDTO.getCourseId(), null, 1); ExecutorService executorService = Executors.newCachedThreadPool(); for (QueryPapersVO queryPapersVO : queryPapersVOS) { - executorService.execute(()->getCourseTestTask(queryPapersVO,contentMemberDTO.getMemberId(),classDictDO)); + executorService.execute(() -> getCourseTestTask(queryPapersVO, contentMemberDTO.getMemberId(), classDictDO)); } 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()); queryPapersVO.setCompleteCnt(cnt); @@ -751,7 +685,7 @@ public class MemberServiceImpl extends ServiceImpl imple public String checkTimes(ExerciseDoneResultDO exerciseDoneResultDO) { 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) { Integer status = classHourDictDO.getRepeatStatus(); @@ -775,7 +709,7 @@ public class MemberServiceImpl extends ServiceImpl imple public void importRedis() { List memberDOS = this.baseMapper.selectList(null); for (MemberDO memberDO : memberDOS) { - redisUtil.set(RedisPrefixConstant.SUBSIDY_COMPANY_MEMBER_PREFIX + memberDO.getCompanyId() + ":" + memberDO.getAccountName(), memberDO); + redisUtil.set(RedisPrefixConstant.SUBSIDY_COMPANY_MEMBER_PREFIX + memberDO.getCompanyId() + ":" + memberDO.getAccountName(), memberDO); } } diff --git a/src/main/java/com/subsidy/service/impl/SignInRecordServiceImpl.java b/src/main/java/com/subsidy/service/impl/SignInRecordServiceImpl.java index ead06fb..d0b2287 100644 --- a/src/main/java/com/subsidy/service/impl/SignInRecordServiceImpl.java +++ b/src/main/java/com/subsidy/service/impl/SignInRecordServiceImpl.java @@ -222,10 +222,9 @@ public class SignInRecordServiceImpl extends ServiceImpl classHourDictDOS = classHourDictMapper.selectList(null); - for (ClassHourDictDO classHourDictDO : classHourDictDOS){ - redisUtil.set("subsidySettings_"+classHourDictDO.getCompanyId(),classHourDictDO); + for (ClassHourDictDO classHourDictDO : classHourDictDOS) { + redisUtil.set("subsidySettings_" + classHourDictDO.getCompanyId(), classHourDictDO); } } diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 3fbe749..9685e52 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -4,14 +4,14 @@ spring.profiles.active=dev spring.server.port=23457 #嵌入tomcat配置 #和CPU数 -spring.server.acceptorThreadCount=200 +spring.server.acceptorThreadCount=600 spring.server.minSpareThreads=100 spring.server.maxSpareThreads=500 -spring.server.maxThreads=800 -spring.server.maxConnections=50000 +spring.server.maxThreads=500 +spring.server.maxConnections=1000 #10秒超时 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.compression=on #文件请求大小 diff --git a/src/main/resources/mapper/CourseContentMapper.xml b/src/main/resources/mapper/CourseContentMapper.xml index 2b17ffb..6ecd4c3 100644 --- a/src/main/resources/mapper/CourseContentMapper.xml +++ b/src/main/resources/mapper/CourseContentMapper.xml @@ -23,7 +23,16 @@ +