From c5e36ae40cd924ba43b0a54def1c27e225c6e613 Mon Sep 17 00:00:00 2001 From: typ Date: Tue, 18 Jan 2022 15:18:04 +0800 Subject: [PATCH] 视频纬度报表 --- src/main/java/com/subsidy/controller/AdministerController.java | 18 +++++++++++++----- src/main/java/com/subsidy/controller/VodPlayHistoryController.java | 4 ++++ src/main/java/com/subsidy/dto/administer/ClassVodDailyInfoDTO.java | 16 ++++++++++++++++ src/main/java/com/subsidy/jobs/Scheduler.java | 28 ++++++++++++++-------------- src/main/java/com/subsidy/mapper/VodPlayHistoryMapper.java | 13 ++++++++++++- src/main/java/com/subsidy/model/SignInRecordDO.java | 5 +++++ src/main/java/com/subsidy/service/AdministerService.java | 20 ++++++-------------- src/main/java/com/subsidy/service/VodPlayHistoryService.java | 2 ++ src/main/java/com/subsidy/service/impl/AdministerServiceImpl.java | 124 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++----------------------------------------- src/main/java/com/subsidy/service/impl/VodPlayHistoryServiceImpl.java | 370 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------------------------------------------------------------------------- src/main/java/com/subsidy/util/BaseModel.java | 2 +- src/main/java/com/subsidy/vo/administer/ClassDailyInfoVO.java | 2 ++ src/main/java/com/subsidy/vo/administer/ClassVodDailyInfoItemVO.java | 15 +++++++++++++++ src/main/java/com/subsidy/vo/administer/ClassVodDailyInfoVO.java | 20 ++++++++++++++++++++ src/main/resources/mapper/VodPlayHistoryMapper.xml | 30 ++++++++++++++++++++++++++++++ 15 files changed, 520 insertions(+), 149 deletions(-) create mode 100644 src/main/java/com/subsidy/dto/administer/ClassVodDailyInfoDTO.java create mode 100644 src/main/java/com/subsidy/vo/administer/ClassVodDailyInfoItemVO.java create mode 100644 src/main/java/com/subsidy/vo/administer/ClassVodDailyInfoVO.java diff --git a/src/main/java/com/subsidy/controller/AdministerController.java b/src/main/java/com/subsidy/controller/AdministerController.java index f532cf5..61f4e2a 100644 --- a/src/main/java/com/subsidy/controller/AdministerController.java +++ b/src/main/java/com/subsidy/controller/AdministerController.java @@ -4,11 +4,7 @@ package com.subsidy.controller; import com.subsidy.common.ResponseData; import com.subsidy.common.ResponseVO; import com.subsidy.common.interceptor.LoginRequired; -import com.subsidy.dto.administer.ClassDailyInfoDTO; -import com.subsidy.dto.administer.ClassDetailDTO; -import com.subsidy.dto.administer.ClassVodInfoDTO; -import com.subsidy.dto.administer.MemberStudyLogDTO; -import com.subsidy.dto.administer.OperatorsDTO; +import com.subsidy.dto.administer.*; import com.subsidy.model.AdministerDO; import com.subsidy.model.ExerciseDoneHistoryDO; import com.subsidy.model.ExerciseDoneResultDO; @@ -187,6 +183,18 @@ public class AdministerController { administerService.exportClassDailyInfo(classDailyInfoDTO); } + @PostMapping("classVodDailyInfo") + @ApiOperation("学习记录---每日学习时长(视频维度)") + public ResponseVO classVodDailyInfo(@RequestBody ClassVodDailyInfoDTO classVodDailyInfoDTO ){ + return ResponseData.generateCreatedResponse(0,administerService.classVodDailyInfo(classVodDailyInfoDTO)); + } + + @PostMapping("exportClassVodDailyInfo") + @ApiOperation("学习记录---每日学习时长(视频维度)") + public void exportClassVodDailyInfo(@RequestBody ClassVodDailyInfoDTO classVodDailyInfoDTO ){ + administerService.exportClassVodDailyInfo(classVodDailyInfoDTO); + } + @PostMapping("exportZip") @ApiOperation("下载压缩包 id 班级id") @CrossOrigin diff --git a/src/main/java/com/subsidy/controller/VodPlayHistoryController.java b/src/main/java/com/subsidy/controller/VodPlayHistoryController.java index 24a05ae..f3f62a8 100644 --- a/src/main/java/com/subsidy/controller/VodPlayHistoryController.java +++ b/src/main/java/com/subsidy/controller/VodPlayHistoryController.java @@ -48,4 +48,8 @@ public class VodPlayHistoryController { vodPlayHistoryService.dataFix(); } + @PostMapping("fixDataTwo") + public void dataFixTwo(){ + vodPlayHistoryService.dataFixTwo(); + } } diff --git a/src/main/java/com/subsidy/dto/administer/ClassVodDailyInfoDTO.java b/src/main/java/com/subsidy/dto/administer/ClassVodDailyInfoDTO.java new file mode 100644 index 0000000..cc4ae0a --- /dev/null +++ b/src/main/java/com/subsidy/dto/administer/ClassVodDailyInfoDTO.java @@ -0,0 +1,16 @@ +package com.subsidy.dto.administer; + +import lombok.Data; + +@Data +public class ClassVodDailyInfoDTO { + + private Integer pageSize; + + private Integer pageNum; + + private Long classId; + + private String userName; + +} diff --git a/src/main/java/com/subsidy/jobs/Scheduler.java b/src/main/java/com/subsidy/jobs/Scheduler.java index bfbe8b4..587bd44 100644 --- a/src/main/java/com/subsidy/jobs/Scheduler.java +++ b/src/main/java/com/subsidy/jobs/Scheduler.java @@ -95,19 +95,19 @@ public class Scheduler { /** * 视频播放记录缩量 */ - @Scheduled(cron = "0 48 14 * * ?") - @Transactional(rollbackFor = Exception.class) - public void condenseVodPlayHistory() { - List list = vodPlayHistoryMapper.getVodPlayHistory(); - vodPlayHistoryMapper.delete(null); - //List vodPlayHistoryList = vodPlayHistoryMapper.selectList(null); - //for (VodPlayHistoryDO vodPlayHistoryDO : vodPlayHistoryList) { - vodPlayHistoryMapper.deleteById(null); - //} - - for (VodPlayHistoryDO vodPlayHistoryDO : list) { - vodPlayHistoryMapper.insert(vodPlayHistoryDO); - } - } +// @Scheduled(cron = "0 48 14 * * ?") +// @Transactional(rollbackFor = Exception.class) +// public void condenseVodPlayHistory() { +// List list = vodPlayHistoryMapper.getVodPlayHistory(); +// vodPlayHistoryMapper.delete(null); +// //List vodPlayHistoryList = vodPlayHistoryMapper.selectList(null); +// //for (VodPlayHistoryDO vodPlayHistoryDO : vodPlayHistoryList) { +// vodPlayHistoryMapper.deleteById(null); +// //} +// +// for (VodPlayHistoryDO vodPlayHistoryDO : list) { +// vodPlayHistoryMapper.insert(vodPlayHistoryDO); +// } +// } } diff --git a/src/main/java/com/subsidy/mapper/VodPlayHistoryMapper.java b/src/main/java/com/subsidy/mapper/VodPlayHistoryMapper.java index afeafc7..bcff2d6 100644 --- a/src/main/java/com/subsidy/mapper/VodPlayHistoryMapper.java +++ b/src/main/java/com/subsidy/mapper/VodPlayHistoryMapper.java @@ -10,6 +10,7 @@ import com.subsidy.vo.vod.GetMemberStudyInfoVO; import com.subsidy.vo.vod.StudyHistoryVO; import org.springframework.stereotype.Repository; +import java.time.LocalDateTime; import java.util.List; /** @@ -60,7 +61,6 @@ public interface VodPlayHistoryMapper extends BaseMapper { */ ContentVodNewVO memberRecentPlay(Long classId, Long memberId); - /** * 查看某个成员某个课程的学习日志 */ @@ -76,4 +76,15 @@ public interface VodPlayHistoryMapper extends BaseMapper { */ Integer memberVodTotalLength(Long memberId,Long vodId); + /** + * 跑脚本 前一天的学习情况 + */ + List exPlayInfo(Long memberId, String classId, LocalDateTime localDateTime); + + /** + * 以班级、人的维度查询某个人的视频观看时长 + */ + List classMemberPlayLength(Long classId); + + } diff --git a/src/main/java/com/subsidy/model/SignInRecordDO.java b/src/main/java/com/subsidy/model/SignInRecordDO.java index ce9fd79..90312ac 100644 --- a/src/main/java/com/subsidy/model/SignInRecordDO.java +++ b/src/main/java/com/subsidy/model/SignInRecordDO.java @@ -5,6 +5,8 @@ import com.baomidou.mybatisplus.annotation.TableName; import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.TableId; import java.time.LocalDateTime; + +import com.subsidy.util.excel.ExcelColumnUtil; import lombok.Data; import lombok.EqualsAndHashCode; @@ -29,16 +31,19 @@ public class SignInRecordDO extends BaseModel { /** * 学生id */ + @ExcelColumnUtil(value = "member_id", col = 3) private Long memberId; /** * 班级id */ + @ExcelColumnUtil(value = "class_id", col = 2) private Long classId; /** * 签到时间 */ + @ExcelColumnUtil(value = "sign_in_date", col = 4) private LocalDateTime signInDate; diff --git a/src/main/java/com/subsidy/service/AdministerService.java b/src/main/java/com/subsidy/service/AdministerService.java index 6ec160f..f6f9b99 100644 --- a/src/main/java/com/subsidy/service/AdministerService.java +++ b/src/main/java/com/subsidy/service/AdministerService.java @@ -2,23 +2,11 @@ package com.subsidy.service; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.service.IService; -import com.subsidy.dto.administer.ClassDailyInfoDTO; -import com.subsidy.dto.administer.ClassDetailDTO; -import com.subsidy.dto.administer.ClassVodInfoDTO; -import com.subsidy.dto.administer.MemberStudyLogDTO; -import com.subsidy.dto.administer.OperatorsDTO; +import com.subsidy.dto.administer.*; import com.subsidy.model.AdministerDO; import com.subsidy.model.ExerciseDoneHistoryDO; import com.subsidy.model.ExerciseDoneResultDO; -import com.subsidy.vo.administer.AdministerPermissionVO; -import com.subsidy.vo.administer.ClassDailyInfoVO; -import com.subsidy.vo.administer.ClassSummaryVO; -import com.subsidy.vo.administer.ClassVodInfoVO; -import com.subsidy.vo.administer.ExerciseTestVO; -import com.subsidy.vo.administer.GetMemberPapersVO; -import com.subsidy.vo.administer.GetPaperDetailVO; -import com.subsidy.vo.administer.LoginVO; -import com.subsidy.vo.administer.OperatorsVO; +import com.subsidy.vo.administer.*; import com.subsidy.vo.classdict.ClassDetailVO; import com.subsidy.vo.member.ClassSignVO; import com.subsidy.vo.sign.AnswerRecordVO; @@ -76,6 +64,10 @@ public interface AdministerService extends IService { void exportClassDailyInfo(ClassDailyInfoDTO classDailyInfoDTO); + IPage classVodDailyInfo(ClassVodDailyInfoDTO classVodDailyInfoDTO); + + void exportClassVodDailyInfo(ClassVodDailyInfoDTO classVodDailyInfoDTO); + void export(ClassDetailDTO classDetailDTO)throws Exception; void memberStudyLog(MemberStudyLogDTO memberStudyLogDTO)throws Exception; diff --git a/src/main/java/com/subsidy/service/VodPlayHistoryService.java b/src/main/java/com/subsidy/service/VodPlayHistoryService.java index 6b8c5ea..8afbe47 100644 --- a/src/main/java/com/subsidy/service/VodPlayHistoryService.java +++ b/src/main/java/com/subsidy/service/VodPlayHistoryService.java @@ -18,4 +18,6 @@ public interface VodPlayHistoryService extends IService { String insertHistoryNew(VodPlayHistoryDO vodPlayHistoryDO); void dataFix(); + + void dataFixTwo(); } diff --git a/src/main/java/com/subsidy/service/impl/AdministerServiceImpl.java b/src/main/java/com/subsidy/service/impl/AdministerServiceImpl.java index cfbbac8..3017d27 100644 --- a/src/main/java/com/subsidy/service/impl/AdministerServiceImpl.java +++ b/src/main/java/com/subsidy/service/impl/AdministerServiceImpl.java @@ -6,11 +6,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.subsidy.common.RedisPrefixConstant; import com.subsidy.common.exception.HttpException; -import com.subsidy.dto.administer.ClassDailyInfoDTO; -import com.subsidy.dto.administer.ClassDetailDTO; -import com.subsidy.dto.administer.ClassVodInfoDTO; -import com.subsidy.dto.administer.MemberStudyLogDTO; -import com.subsidy.dto.administer.OperatorsDTO; +import com.subsidy.dto.administer.*; import com.subsidy.dto.member.ImportMemberDTO; import com.subsidy.mapper.AdministerMapper; import com.subsidy.mapper.AnsweringQuestionMapper; @@ -26,22 +22,8 @@ import com.subsidy.mapper.OprAdmDictMapper; import com.subsidy.mapper.RoleAdministerMappingMapper; import com.subsidy.mapper.VodDictMapper; import com.subsidy.mapper.VodPlayHistoryMapper; -import com.subsidy.model.AdministerDO; -import com.subsidy.model.AnsweringQuestionDO; -import com.subsidy.model.ClassDictDO; -import com.subsidy.model.ClassMemberMappingDO; -import com.subsidy.model.CompanyDictDO; -import com.subsidy.model.CourseDictDO; -import com.subsidy.model.DepartmentDictDO; -import com.subsidy.model.ExerciseDoneHistoryDO; -import com.subsidy.model.ExerciseDoneResultDO; -import com.subsidy.model.MemberDO; -import com.subsidy.model.MemberDepartmentMappingDO; -import com.subsidy.model.OprMemDictDO; +import com.subsidy.model.*; import com.subsidy.mongodb.OprAdmDictDO; -import com.subsidy.model.RoleAdministerMappingDO; -import com.subsidy.model.SignInRecordDO; -import com.subsidy.model.VodDictDO; import com.subsidy.service.AdministerService; import com.subsidy.util.ConstantUtils; import com.subsidy.util.DateFormatUtil; @@ -51,17 +33,7 @@ import com.subsidy.util.Localstorage; import com.subsidy.util.MathUtil; import com.subsidy.util.RedisUtil; import com.subsidy.util.excel.ExcelUtil; -import com.subsidy.vo.administer.AdministerPermissionVO; -import com.subsidy.vo.administer.ClassDailyInfoVO; -import com.subsidy.vo.administer.ClassSummaryVO; -import com.subsidy.vo.administer.ClassVodInfoVO; -import com.subsidy.vo.administer.ExerciseTestVO; -import com.subsidy.vo.administer.GetMemberPapersVO; -import com.subsidy.vo.administer.GetPaperDetailVO; -import com.subsidy.vo.administer.LoginVO; -import com.subsidy.vo.administer.MemberStudyLogVO; -import com.subsidy.vo.administer.OperatorsVO; -import com.subsidy.vo.administer.PermissionsVO; +import com.subsidy.vo.administer.*; import com.subsidy.vo.classdict.ClassDetailVO; import com.subsidy.vo.done.GetMaxScoreVO; import com.subsidy.vo.done.TestScoreInfoVO; @@ -177,9 +149,6 @@ public class AdministerServiceImpl extends ServiceImpl oprAdmDictDOS = mongoTemplate.find(query, OprAdmDictDO.class); @@ -236,7 +205,7 @@ public class AdministerServiceImpl extends ServiceImpl classVodDailyInfo(ClassVodDailyInfoDTO classVodDailyInfoDTO) { + + //查看班级里有多少人 + Page pager = new Page(classVodDailyInfoDTO.getPageNum(), classVodDailyInfoDTO.getPageSize()); + + //获取班级成员 + IPage classDailyInfoVOIPage = classMemberMappingMapper.getClassMembersWithName(pager, classVodDailyInfoDTO.getClassId(), classVodDailyInfoDTO.getUserName()); + + List classDailyInfoVOS = classDailyInfoVOIPage.getRecords(); + + //获取班级、每个学员维度的视频播放总时长 + List vodPlayHistoryDOS = vodPlayHistoryMapper.classMemberPlayLength(classVodDailyInfoDTO.getClassId()); + + HashMap hashMap = new HashMap<>(); + + //存在一个map里 + for (VodPlayHistoryDO vodPlayHistoryDO : vodPlayHistoryDOS) { + hashMap.put(vodPlayHistoryDO.getMemberId() + "-" + vodPlayHistoryDO.getVodId(), vodPlayHistoryDO.getPlayLength()); + } + + //查询这个班级的所有视频 + ClassDictDO classDictDO = classDictMapper.selectById(classVodDailyInfoDTO.getClassId()); + List vodDictDOS = vodDictMapper.getCourseVods(classDictDO.getCourseId(), null); + + for (ClassDailyInfoVO classDailyInfoVO : classDailyInfoVOS) { + //查看这个人某个视频的长度 + int total = 0; + List classVodDailyInfoItemVOS = new ArrayList<>(); + for (VodDictDO vodDictDO : vodDictDOS) { + int playLength = hashMap.get(classDailyInfoVO.getId() + "-" + vodDictDO.getId()); + ClassVodDailyInfoItemVO classVodDailyInfoItemVO = new ClassVodDailyInfoItemVO(); + classVodDailyInfoItemVO.setPlayLength(playLength); + classVodDailyInfoItemVOS.add(classVodDailyInfoItemVO); + total += playLength; + } + classDailyInfoVO.setTotal(total); + classDailyInfoVO.setClassVodDailyInfoItemVOS(classVodDailyInfoItemVOS); + } + return classDailyInfoVOIPage; + } + + public void exportClassVodDailyInfo(ClassVodDailyInfoDTO classVodDailyInfoDTO){ + + //查看班级里有多少人 + Page pager = new Page(1,-1L); + + //查询所有视频 + List vodDictDOS = vodDictMapper.getCourseVods(classVodDailyInfoDTO.getClassId(),null); + + // 表头 + List title = new ArrayList<>(); + title.add("姓名"); + title.add("合计总时长"); + for (VodDictDO vodDictDO : vodDictDOS){ + title.add(vodDictDO.getVodName()); + } + + //获取班级成员 + IPage classDailyInfoVOIPage = classMemberMappingMapper.getClassMembersWithName(pager, classVodDailyInfoDTO.getClassId(), classVodDailyInfoDTO.getUserName()); + + List classDailyInfoVOS = classDailyInfoVOIPage.getRecords(); + + //获取班级、每个学员维度的视频播放总时长 + List vodPlayHistoryDOS = vodPlayHistoryMapper.classMemberPlayLength(classVodDailyInfoDTO.getClassId()); + + HashMap hashMap = new HashMap<>(); + + //存在一个map里 + for (VodPlayHistoryDO vodPlayHistoryDO : vodPlayHistoryDOS) { + hashMap.put(vodPlayHistoryDO.getMemberId() + "-" + vodPlayHistoryDO.getVodId(), vodPlayHistoryDO.getPlayLength()); + } } @@ -921,12 +963,12 @@ public class AdministerServiceImpl extends ServiceImpl hashMap1 = hashMap.get(data); Cell namecell = r.createCell(a.getAndIncrement()); namecell.setCellValue(memberMapper.selectById(data).getUserName()); - int total = 0 ; - for (String date : dates){ - if (!date.equals("姓名")&&!"合计总时长".equals(date)) { + int total = 0; + for (String date : dates) { + if (!date.equals("姓名") && !"合计总时长".equals(date)) { Cell cell1 = r.createCell(a.getAndIncrement()); if (null != hashMap1) { - total += null == hashMap1.get(date)?0:hashMap1.get(date); + total += null == hashMap1.get(date) ? 0 : hashMap1.get(date); cell1.setCellValue(null == hashMap1.get(date) ? "00:00:00" : MathUtil.secToTime(hashMap1.get(date))); } else { cell1.setCellValue("00:00:00"); diff --git a/src/main/java/com/subsidy/service/impl/VodPlayHistoryServiceImpl.java b/src/main/java/com/subsidy/service/impl/VodPlayHistoryServiceImpl.java index c15cf95..f83d3d6 100644 --- a/src/main/java/com/subsidy/service/impl/VodPlayHistoryServiceImpl.java +++ b/src/main/java/com/subsidy/service/impl/VodPlayHistoryServiceImpl.java @@ -1,28 +1,27 @@ package com.subsidy.service.impl; +import com.amdelamar.jhash.Hash; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; -import com.subsidy.mapper.ClassDictMapper; -import com.subsidy.mapper.ClassMemberMappingMapper; -import com.subsidy.mapper.CourseContentMapper; -import com.subsidy.mapper.SignInRecordMapper; +import com.subsidy.mapper.*; import com.subsidy.model.ClassDictDO; import com.subsidy.model.ClassMemberMappingDO; import com.subsidy.model.SignInRecordDO; import com.subsidy.model.VodDictDO; import com.subsidy.model.VodPlayHistoryDO; -import com.subsidy.mapper.VodPlayHistoryMapper; +import com.subsidy.service.VodDictService; import com.subsidy.service.VodPlayHistoryService; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.subsidy.util.ConstantUtils; +import com.subsidy.util.DateFormatUtil; +import com.subsidy.util.MathUtil; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.scheduling.annotation.Async; import org.springframework.stereotype.Service; import java.time.LocalDate; import java.time.LocalDateTime; -import java.util.Arrays; -import java.util.List; -import java.util.Random; +import java.time.format.DateTimeFormatter; +import java.util.*; /** *

@@ -50,6 +49,9 @@ public class VodPlayHistoryServiceImpl extends ServiceImpl classIds = Arrays.asList(new String[]{"17","28"}); - - Random random = new Random(); + List classIds = Arrays.asList(new String[]{"28"}); for (String str : classIds) { @@ -78,34 +78,203 @@ public class VodPlayHistoryServiceImpl extends ServiceImpl vodDictDOS = courseContentMapper.getCourseVods(classDictDO.getCourseId()); //遍历班级学生 for (ClassMemberMappingDO classMemberMappingDO : classMemberMappingDOS) { - //查询这个人 这节课 排序 - //List signInRecordDOS = signInRecordMapper.selectList(new QueryWrapper() - // .lambda() - // .eq(SignInRecordDO::getMemberId, classMemberMappingDO.getMemberId()) - // .eq(SignInRecordDO::getClassId, str) - // .orderByAsc(SignInRecordDO::getSignInDate)); + //查询这个人 这节课 签到记录 排序 + List signInRecordDOS = signInRecordMapper.selectList(new QueryWrapper() + .lambda() + .eq(SignInRecordDO::getMemberId, classMemberMappingDO.getMemberId()) + .eq(SignInRecordDO::getClassId, str) + .orderByDesc(SignInRecordDO::getSignInDate)); + List 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 hashMap = new LinkedHashMap<>(); + List 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 : hashMap.keySet()) { + //今天应该看几个视频 + int total = hashMap.get(localDateTime); + + //今天已看视频时长 + int totalPlay = 0; + + //先续播前一天未看完的视频 + List vodPlayHistoryDOS = vodPlayHistoryMapper.selectList(new QueryWrapper() + .lambda() + .eq(VodPlayHistoryDO::getMemberId, classMemberMappingDO.getMemberId()) + .eq(VodPlayHistoryDO::getClassId, str) + .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(Long.valueOf(str)); + vodPlayHistoryDO.setMemberId(classMemberMappingDO.getMemberId()); + vodPlayHistoryDO.setPlayRecord(vodDictDO.getVodLength()); + vodPlayHistoryDO.setPlayLength(leftLength); + vodPlayHistoryDO.setVodId(vodDictDO.getId()); + vodPlayHistoryDO.setPlayDate(localDateTime.plusSeconds(leftLength)); + vodPlayHistoryMapper.insert(vodPlayHistoryDO); + } + } + + //今天已看几个视频 + int alreadyPlay = 0; + Random random = new Random(); + //查找这个人应该学的课程 + for (VodDictDO vodDictDO : vodDictDOS) { + //从历史记录里找中这个人有没有学过 + Integer count = vodPlayHistoryMapper.selectCount(new QueryWrapper() + .lambda() + .eq(VodPlayHistoryDO::getMemberId, classMemberMappingDO.getMemberId()) + .eq(VodPlayHistoryDO::getClassId, str) + .eq(VodPlayHistoryDO::getVodId, vodDictDO.getId())); + //表示这个视频没有学过 + if (count == 0) { + if (alreadyPlay == total) { + //最后一天最后一个视频 + if (key_index == integers.size()) { + VodPlayHistoryDO vodPlayHistoryDO = new VodPlayHistoryDO(); + vodPlayHistoryDO.setPlayCount(1); + vodPlayHistoryDO.setClassId(Long.valueOf(str)); + vodPlayHistoryDO.setMemberId(classMemberMappingDO.getMemberId()); + vodPlayHistoryDO.setPlayRecord(vodDictDO.getVodLength()); + vodPlayHistoryDO.setPlayLength(vodDictDO.getVodLength()); + vodPlayHistoryDO.setVodId(vodDictDO.getId()); + vodPlayHistoryDO.setPlayDate(localDateTime.plusSeconds(totalPlay)); + vodPlayHistoryMapper.insert(vodPlayHistoryDO); + alreadyPlay++; + }else { + //当天看的最后一个视频 + VodPlayHistoryDO vodPlayHistoryDO = new VodPlayHistoryDO(); + vodPlayHistoryDO.setPlayCount(1); + vodPlayHistoryDO.setClassId(Long.valueOf(str)); + vodPlayHistoryDO.setMemberId(classMemberMappingDO.getMemberId()); + int rdm = random.nextInt(vodDictDO.getVodLength()); + vodPlayHistoryDO.setPlayLength(rdm); + vodPlayHistoryDO.setPlayRecord(rdm); + vodPlayHistoryDO.setVodId(vodDictDO.getId()); + vodPlayHistoryDO.setPlayDate(localDateTime.plusSeconds(totalPlay + rdm)); + vodPlayHistoryMapper.insert(vodPlayHistoryDO); + alreadyPlay++; + break; + } + } else { + totalPlay += vodDictDO.getVodLength(); + VodPlayHistoryDO vodPlayHistoryDO = new VodPlayHistoryDO(); + vodPlayHistoryDO.setPlayCount(1); + vodPlayHistoryDO.setClassId(Long.valueOf(str)); + vodPlayHistoryDO.setMemberId(classMemberMappingDO.getMemberId()); + vodPlayHistoryDO.setPlayRecord(vodDictDO.getVodLength()); + vodPlayHistoryDO.setPlayLength(vodDictDO.getVodLength()); + vodPlayHistoryDO.setVodId(vodDictDO.getId()); + vodPlayHistoryDO.setPlayDate(localDateTime.plusSeconds(totalPlay)); + vodPlayHistoryMapper.insert(vodPlayHistoryDO); + alreadyPlay++; + } + } + } + key_index++; + } + } + } + } + + public void dataFixTwo() { + + //班级ids + List classIds = Arrays.asList(new String[]{"28"}); + + for (String str : classIds) { + + ClassDictDO classDictDO = classDictMapper.selectById(str); + + //找到班级里的学生 + List classMemberMappingDOS = classMemberMappingMapper.selectList(new QueryWrapper() + .lambda() + .eq(ClassMemberMappingDO::getClassId, Long.valueOf(str))); - //SignInRecordDO signInRecordDO = signInRecordDOS.get(0); + //查找课程里的所有视频 + List vodDictDOS = courseContentMapper.getCourseVods(classDictDO.getCourseId()); - //找出某个人某节课看完最后一节视频的时间 - List vodPlayHistoryDOS = vodPlayHistoryMapper.selectList(new QueryWrapper() + //遍历班级学生 + for (ClassMemberMappingDO classMemberMappingDO : classMemberMappingDOS) { + + //查询这个人 这节课 签到记录 排序 + List localDateTimes = new ArrayList<>(); + List signInRecordDOS = signInRecordMapper.selectList(new QueryWrapper() .lambda() - .eq(VodPlayHistoryDO::getMemberId, classMemberMappingDO.getMemberId()) - .eq(VodPlayHistoryDO::getClassId, str) - .orderByDesc(VodPlayHistoryDO::getPlayDate)); + .eq(SignInRecordDO::getMemberId, classMemberMappingDO.getMemberId()) + .eq(SignInRecordDO::getClassId, str) + .orderByDesc(SignInRecordDO::getSignInDate)); + for (SignInRecordDO signInrecord : signInRecordDOS) { + if (signInrecord.getSignInDate().getHour() >= 6 && signInrecord.getSignInDate().getHour() < 15) { + localDateTimes.add(signInrecord.getSignInDate()); + } + } + if (localDateTimes.size()>0){ + LocalDateTime date = localDateTimes.get(0); + + //查看当天这人已经看的视频时长 + List vodPlayHistoryDOS = vodPlayHistoryMapper.exPlayInfo(classMemberMappingDO.getMemberId(), str, date); - if (vodPlayHistoryDOS.size()>0){ - //时间点 - VodPlayHistoryDO vodPlayHistoryDO1 = vodPlayHistoryDOS.get(0); - int total = 0; - int playCounts = random.nextInt(2)+1; + int playLength = 0; + + for (int m = 0; m < vodPlayHistoryDOS.size(); m++) { + playLength += vodPlayHistoryDOS.get(m).getPlayLength(); + } + int playCounts = new Random().nextInt(2) + 1; for (int i = 0; i < playCounts; i++) { VodPlayHistoryDO vodPlayHistoryDO = new VodPlayHistoryDO(); @@ -114,64 +283,119 @@ public class VodPlayHistoryServiceImpl extends ServiceImpl vodDictDOS) { + + Random random = new Random(); + int counts = random.nextInt(3) + 1; + for (int i = 0; i < counts; i++) { + VodPlayHistoryDO vodPlayHistoryDO = new VodPlayHistoryDO(); + Random random1 = new Random(); + int j = random1.nextInt(vodDictDOS.size()); + vodPlayHistoryDO.setPlayCount(1); + vodPlayHistoryDO.setClassId(classId); + vodPlayHistoryDO.setMemberId(memberId); +// vodPlayHistoryDO.setPlayRecord(h); + vodPlayHistoryDO.setPlayLength(new Random().nextInt(vodPlayHistoryDO.getPlayRecord())); + playLength += vodPlayHistoryDO.getPlayLength(); + vodPlayHistoryDO.setVodId(vodId); + vodPlayHistoryDO.setPlayDate(localDateTime.plusSeconds(playLength)); + vodPlayHistoryMapper.insert(vodPlayHistoryDO); - //VodDictDO vodDictDO = vodDictDOS.get(random.nextInt(vodDictDOS.size())); - - //根据签到时间,对学生学习的课程做插入操作 - //for (SignInRecordDO signInRecordDO : signInRecordDOS) { - // LocalDateTime signInDate = signInRecordDO.getSignInDate(); - // if (signInDate.getHour() <= 15 && signInDate.getHour() >= 6) { - // Random random = new Random(); - // int totalDailyLength = random.nextInt(4); - // //查找这个人应该学的课程 - // for (VodDictDO vodDictDO : vodDictDOS) { - // //从历史记录里找中这个人有没有学过 - // if (totalDailyLength<=7*60*60){ - // Integer count = vodPlayHistoryMapper.selectCount(new QueryWrapper() - // .lambda() - // .eq(VodPlayHistoryDO::getMemberId, classMemberMappingDO.getMemberId()) - // .eq(VodPlayHistoryDO::getClassId, str) - // .eq(VodPlayHistoryDO::getVodId, vodDictDO.getId())); - // if (count == 0 && signInDate.plusSeconds(totalDailyLength).getHour() < 23) { - // totalDailyLength+=vodDictDO.getVodLength(); - // VodPlayHistoryDO vodPlayHistoryDO = new VodPlayHistoryDO(); - // vodPlayHistoryDO.setPlayCount(1); - // vodPlayHistoryDO.setClassId(Long.valueOf(str)); - // vodPlayHistoryDO.setMemberId(classMemberMappingDO.getMemberId()); - // vodPlayHistoryDO.setPlayRecord(vodDictDO.getVodLength()); - // vodPlayHistoryDO.setPlayLength(vodDictDO.getVodLength()); - // vodPlayHistoryDO.setVodId(vodDictDO.getId()); - // vodPlayHistoryDO.setPlayDate(signInDate.plusSeconds(totalDailyLength)); - // //vodPlayHistoryDO.setCreateDate(signInDate.plusSeconds(totalDailyLength)); - // vodPlayHistoryMapper.insert(vodPlayHistoryDO); - // Random random1 = new Random(); - // totalDailyLength+=random1.nextInt(5); - // } - // } - // - // } - // } - //} - } } + return 0; } public static void main(String[] args) { - //Random random = new Random(); - //System.out.println(); - System.out.println((int)(Math.random()*10+1)); +// int m = 0; +// +// int signInrecord = 4; +// int vodSize = 24; +// List integers = new ArrayList<>(); +// +// +// 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; +// integers.add(n); +// } else { +// integers.add(vodSize - rdm_total + n); +// break; +// } +// } +// +// int h = 0 ; +// while (true) { +// for (Integer integer : integers) { +//// System.out.println(integer + "====="); +// h += integer; +// } +// System.out.println(h+"=============="); +// +// if (h != 24) { +// System.out.println(integers); +// } +// h= 0; +// } +// int key_index = 0; + +// for (int i = 1 ; i< 100 ; i ++){ +// System.out.println((int)(Math.random()*11/2+5)); +// } + +// int m = 0 ; +// int signInRecordDOS = 3; +// int vodDictDOS = 24; +// List integers = new ArrayList<>(); +// +// for (int k = 0 ; k < signInRecordDOS ; k++){ +// if (k!=signInRecordDOS-1){ +// int n = getRandom(); +// if ((m+n)<=vodDictDOS){ +// m+=n; +// integers.add(n); +// } +// }else { +// if (m 11 || i < 5) { + System.out.println("error"); + } + } + } + + public static Integer getRandom() { + return (int) (Math.random() * 11 / 2 + 5); } } diff --git a/src/main/java/com/subsidy/util/BaseModel.java b/src/main/java/com/subsidy/util/BaseModel.java index 7504dd0..9297672 100644 --- a/src/main/java/com/subsidy/util/BaseModel.java +++ b/src/main/java/com/subsidy/util/BaseModel.java @@ -16,7 +16,7 @@ public abstract class BaseModel { * 创建时间 */ @JsonIgnore - @TableField(insertStrategy = FieldStrategy.NEVER, updateStrategy = FieldStrategy.NEVER, value = "create_date", fill = FieldFill.INSERT) +// @TableField(insertStrategy = FieldStrategy.NEVER, updateStrategy = FieldStrategy.NEVER, value = "create_date", fill = FieldFill.INSERT) private LocalDateTime createDate; /** diff --git a/src/main/java/com/subsidy/vo/administer/ClassDailyInfoVO.java b/src/main/java/com/subsidy/vo/administer/ClassDailyInfoVO.java index 44d1cb4..d6a3b63 100644 --- a/src/main/java/com/subsidy/vo/administer/ClassDailyInfoVO.java +++ b/src/main/java/com/subsidy/vo/administer/ClassDailyInfoVO.java @@ -15,4 +15,6 @@ public class ClassDailyInfoVO { private List dayInfoItemVOS; private Integer total; + + private List classVodDailyInfoItemVOS; } diff --git a/src/main/java/com/subsidy/vo/administer/ClassVodDailyInfoItemVO.java b/src/main/java/com/subsidy/vo/administer/ClassVodDailyInfoItemVO.java new file mode 100644 index 0000000..80ae840 --- /dev/null +++ b/src/main/java/com/subsidy/vo/administer/ClassVodDailyInfoItemVO.java @@ -0,0 +1,15 @@ +package com.subsidy.vo.administer; + +import lombok.Data; + +@Data +public class ClassVodDailyInfoItemVO { + + private Integer vodId; + + private String vodName; + + private Integer playLength; + + +} diff --git a/src/main/java/com/subsidy/vo/administer/ClassVodDailyInfoVO.java b/src/main/java/com/subsidy/vo/administer/ClassVodDailyInfoVO.java new file mode 100644 index 0000000..866e08e --- /dev/null +++ b/src/main/java/com/subsidy/vo/administer/ClassVodDailyInfoVO.java @@ -0,0 +1,20 @@ +package com.subsidy.vo.administer; + +import com.subsidy.vo.vod.DayInfoItemVO; +import lombok.Data; + +import java.util.List; + +@Data +public class ClassVodDailyInfoVO { + + private Long id; + + private String userName; + + private List dayInfoItemVOS; + + private Integer total; + + +} diff --git a/src/main/resources/mapper/VodPlayHistoryMapper.xml b/src/main/resources/mapper/VodPlayHistoryMapper.xml index 830eb1a..50007c6 100644 --- a/src/main/resources/mapper/VodPlayHistoryMapper.xml +++ b/src/main/resources/mapper/VodPlayHistoryMapper.xml @@ -307,4 +307,34 @@ AND t.vod_id = #{vodId} AND t.member_id = #{memberId} + + + + -- libgit2 0.25.0