diff --git a/src/main/java/com/subsidy/controller/ClassHourDictController.java b/src/main/java/com/subsidy/controller/ClassHourDictController.java index c228d7f..f9bdb0e 100644 --- a/src/main/java/com/subsidy/controller/ClassHourDictController.java +++ b/src/main/java/com/subsidy/controller/ClassHourDictController.java @@ -48,14 +48,12 @@ public class ClassHourDictController { return ResponseData.generateCreatedResponse(0,classHourDictService.updateSetting(getSettingVO)); } - @PostMapping("pollingGet") - @ApiOperation("轮询查询当前这个人当天有没有超过最长时长 memberId playLength") - @LoginRequired - @TimeRequired - public ResponseVO pollingGet(@RequestBody VodPlayHistoryDO vodPlayHistoryDO){ - return ResponseData.generateCreatedResponse(0,classHourDictService.pollingGet(vodPlayHistoryDO)); - } - - - +// @PostMapping("pollingGet") +// @ApiOperation("轮询查询当前这个人当天有没有超过最长时长 memberId playLength") +// @LoginRequired +// @TimeRequired +// public ResponseVO pollingGet(@RequestBody VodPlayHistoryDO vodPlayHistoryDO){ +// return ResponseData.generateCreatedResponse(0,classHourDictService.pollingGet(vodPlayHistoryDO)); +// } +// } diff --git a/src/main/java/com/subsidy/mapper/VodPlayHistoryMapper.java b/src/main/java/com/subsidy/mapper/VodPlayHistoryMapper.java index 32d52f5..df1fcc2 100644 --- a/src/main/java/com/subsidy/mapper/VodPlayHistoryMapper.java +++ b/src/main/java/com/subsidy/mapper/VodPlayHistoryMapper.java @@ -44,7 +44,7 @@ public interface VodPlayHistoryMapper extends BaseMapper { /** * 查看某人当天看了多少时间 */ - int memberDailyStudyLength(Long memberId); + int memberDailyStudyLength(Long memberId,Long classId); /** * 查看学生是否完成了某个视频 diff --git a/src/main/java/com/subsidy/service/impl/ClassHourDictServiceImpl.java b/src/main/java/com/subsidy/service/impl/ClassHourDictServiceImpl.java index 138cc8d..c8ad28d 100644 --- a/src/main/java/com/subsidy/service/impl/ClassHourDictServiceImpl.java +++ b/src/main/java/com/subsidy/service/impl/ClassHourDictServiceImpl.java @@ -127,7 +127,7 @@ public class ClassHourDictServiceImpl extends ServiceImpl 3) { - MemberDO memberDO = memberMapper.selectById(vodPlayHistoryDO.getMemberId()); + if (vodPlayHistoryDO.getPlayLength() > 5) { //查看系统设定的时长 - ClassHourDictDO classHourDictDO = classHourDictMapper.selectOne(new QueryWrapper() + ClassDictDO classDictDO = classDictMapper.selectOne(new QueryWrapper() .lambda() - .eq(ClassHourDictDO::getCompanyId, memberDO.getCompanyId())); + .eq(ClassDictDO::getId, vodPlayHistoryDO.getClassId())); - if (classHourDictDO.getStatus() == 1) { + if (classDictDO.getLimitHour()==1){ //查看当天这个人看了多少时间 - Integer total = vodPlayHistoryMapper.memberDailyStudyLength(memberDO.getId()); + Integer total = vodPlayHistoryMapper.memberDailyStudyLength(vodPlayHistoryDO.getMemberId(), classDictDO.getId()); - if (total == classHourDictDO.getClassHour() * 3600) { + if (total == 6 * 3600) { throw new HttpException(13001); } //是否超过时长 没超过 false 超过 true - if (total + vodPlayHistoryDO.getPlayLength() > classHourDictDO.getClassHour() * 3600) { - int playLength = classHourDictDO.getClassHour() * 3600 - total; + if (total + vodPlayHistoryDO.getPlayLength() > classDictDO.getLimitHour() * 3600) { + int playLength = classDictDO.getLimitHour() * 3600 - total; vodPlayHistoryDO.setPlayLength(playLength); vodPlayHistoryDO.setPlayCount(1); - if (playLength > 3) { + if (playLength > 5) { this.baseMapper.insert(vodPlayHistoryDO); } throw new HttpException(13001); } + }else { + vodPlayHistoryDO.setPlayCount(1); + this.baseMapper.insert(vodPlayHistoryDO); } - vodPlayHistoryDO.setPlayCount(1); - this.baseMapper.insert(vodPlayHistoryDO); } return ConstantUtils.ADD_SUCCESS; } public String insertHistoryNew(InsertHistoryNewDTO insertHistoryNewDTO) { - if (insertHistoryNewDTO.getPlayLength() > 3) { + if (insertHistoryNewDTO.getPlayLength() > 5) { VodPlayHistoryDO vodPlayHistoryDO = new VodPlayHistoryDO(); BeanUtils.copyProperties(insertHistoryNewDTO, vodPlayHistoryDO); - MemberDO memberDO = memberMapper.selectById(vodPlayHistoryDO.getMemberId()); //查看系统设定的时长 - ClassHourDictDO classHourDictDO = classHourDictMapper.selectOne(new QueryWrapper() + ClassDictDO classDictDO = classDictMapper.selectOne(new QueryWrapper() .lambda() - .eq(ClassHourDictDO::getCompanyId, memberDO.getCompanyId())); + .eq(ClassDictDO::getId, insertHistoryNewDTO.getClassId())); - if (classHourDictDO.getStatus() == 1) { + if (classDictDO.getLimitHour()==1){ //查看当天这个人看了多少时间 - Integer total = vodPlayHistoryMapper.memberDailyStudyLength(memberDO.getId()); + Integer total = vodPlayHistoryMapper.memberDailyStudyLength(insertHistoryNewDTO.getMemberId(),insertHistoryNewDTO.getClassId()); - if (total == classHourDictDO.getClassHour() * 3600) { + if (total == 6 * 3600) { throw new HttpException(13001); } //是否超过时长 没超过 false 超过 true - if (total + vodPlayHistoryDO.getPlayLength() > classHourDictDO.getClassHour() * 3600) { - int playLength = classHourDictDO.getClassHour() * 3600 - total; + if (total + vodPlayHistoryDO.getPlayLength() > classDictDO.getLimitHour() * 3600) { + int playLength = classDictDO.getLimitHour() * 3600 - total; vodPlayHistoryDO.setPlayLength(playLength); vodPlayHistoryDO.setPlayCount(1); - if (playLength > 3) { + if (playLength > 5) { this.baseMapper.insert(vodPlayHistoryDO); } throw new HttpException(13001); } + }else { + vodPlayHistoryDO.setPlayCount(1); + this.baseMapper.insert(vodPlayHistoryDO); } - vodPlayHistoryDO.setPlayCount(1); - this.baseMapper.insert(vodPlayHistoryDO); } - return ConstantUtils.ADD_SUCCESS; } @@ -630,7 +623,7 @@ public class VodPlayHistoryServiceImpl extends ServiceImpl testPlays(VodPlayHistoryDO vodPlayHistoryDO) { - String classIds = "344"; + String classIds = "286,292,350,355,302,366,379,367,368,371,374,373"; String[] classIdArr = classIds.split(","); @@ -647,19 +640,19 @@ public class VodPlayHistoryServiceImpl extends ServiceImpl vodPlayStateVO.getStartDate().getTime() && vodPlayStateVO.getPlayLength() >= 3) { //这一条数据有问题 System.out.println("111111111111111111111" + vodPlayStateVO); - //查看这个人 这个课程 当天的全部数据 按照createDate升序排序 - List vodPlayHistoryDOS = this.baseMapper.getVodPlayDay(Long.valueOf(classId), classMemberMappingDO.getMemberId(), vodPlayStateVO.getStartDate()); - //从第一条开始看,顺延减去第二条的playlength得到第二条的create_date 以此类推 - for (int l = 0; l < vodPlayHistoryDOS.size() - 1; l++) { - VodPlayHistoryDO vph1 = vodPlayHistoryDOS.get(l); //第一条 - if (l==0){ - vph1.setPlayDate(vph1.getCreateDate()); - } - VodPlayHistoryDO vph2 = vodPlayHistoryDOS.get(l + 1); //第二条 - LocalDateTime dateTmp = vph1.getPlayDate().plusSeconds(vph2.getPlayLength()+getRandom1_2()); - vph2.setPlayDate(dateTmp); - this.baseMapper.updateById(vph2); - } +// //查看这个人 这个课程 当天的全部数据 按照createDate升序排序 +// List vodPlayHistoryDOS = this.baseMapper.getVodPlayDay(Long.valueOf(classId), classMemberMappingDO.getMemberId(), vodPlayStateVO.getStartDate()); +// //从第一条开始看,顺延减去第二条的playlength得到第二条的create_date 以此类推 +// for (int l = 0; l < vodPlayHistoryDOS.size() - 1; l++) { +// VodPlayHistoryDO vph1 = vodPlayHistoryDOS.get(l); //第一条 +// if (l==0){ +// vph1.setPlayDate(vph1.getCreateDate()); +// } +// VodPlayHistoryDO vph2 = vodPlayHistoryDOS.get(l + 1); //第二条 +// LocalDateTime dateTmp = vph1.getPlayDate().plusSeconds(vph2.getPlayLength()+getRandom1_2()); +// vph2.setPlayDate(dateTmp); +// this.baseMapper.updateById(vph2); +// } result.add(vodPlayStateVO.getId()); // break; } diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 50ca700..559f4ed 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -1,5 +1,5 @@ # 环境配置 -spring.profiles.active=prod +spring.profiles.active=dev #和CPU数 spring.server.acceptorThreadCount=600 spring.server.minSpareThreads=100 diff --git a/src/main/resources/mapper/VodPlayHistoryMapper.xml b/src/main/resources/mapper/VodPlayHistoryMapper.xml index c19dd46..c16ee43 100644 --- a/src/main/resources/mapper/VodPlayHistoryMapper.xml +++ b/src/main/resources/mapper/VodPlayHistoryMapper.xml @@ -105,7 +105,7 @@ AND a.vod_id = b.vod_id - SELECT ifnull( sum( t.play_length ), 0 ) FROM @@ -114,6 +114,7 @@ t.delete_date IS NULL AND DATE_FORMAT( t.create_date, '%Y-%m-%d' ) = DATE_FORMAT( now(), '%Y-%m-%d' ) AND t.member_id = #{memberId} + and t.class_id = #{classId}