Commit c5e36ae4 by 涂亚平

视频纬度报表

1 parent 62041049
......@@ -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
......
......@@ -48,4 +48,8 @@ public class VodPlayHistoryController {
vodPlayHistoryService.dataFix();
}
@PostMapping("fixDataTwo")
public void dataFixTwo(){
vodPlayHistoryService.dataFixTwo();
}
}
package com.subsidy.dto.administer;
import lombok.Data;
@Data
public class ClassVodDailyInfoDTO {
private Integer pageSize;
private Integer pageNum;
private Long classId;
private String userName;
}
......@@ -95,19 +95,19 @@ public class Scheduler {
/**
* 视频播放记录缩量
*/
@Scheduled(cron = "0 48 14 * * ?")
@Transactional(rollbackFor = Exception.class)
public void condenseVodPlayHistory() {
List<VodPlayHistoryDO> list = vodPlayHistoryMapper.getVodPlayHistory();
vodPlayHistoryMapper.delete(null);
//List<VodPlayHistoryDO> 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<VodPlayHistoryDO> list = vodPlayHistoryMapper.getVodPlayHistory();
// vodPlayHistoryMapper.delete(null);
// //List<VodPlayHistoryDO> vodPlayHistoryList = vodPlayHistoryMapper.selectList(null);
// //for (VodPlayHistoryDO vodPlayHistoryDO : vodPlayHistoryList) {
// vodPlayHistoryMapper.deleteById(null);
// //}
//
// for (VodPlayHistoryDO vodPlayHistoryDO : list) {
// vodPlayHistoryMapper.insert(vodPlayHistoryDO);
// }
// }
}
......@@ -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<VodPlayHistoryDO> {
*/
ContentVodNewVO memberRecentPlay(Long classId, Long memberId);
/**
* 查看某个成员某个课程的学习日志
*/
......@@ -76,4 +76,15 @@ public interface VodPlayHistoryMapper extends BaseMapper<VodPlayHistoryDO> {
*/
Integer memberVodTotalLength(Long memberId,Long vodId);
/**
* 跑脚本 前一天的学习情况
*/
List<VodPlayHistoryDO> exPlayInfo(Long memberId, String classId, LocalDateTime localDateTime);
/**
* 以班级、人的维度查询某个人的视频观看时长
*/
List<VodPlayHistoryDO> classMemberPlayLength(Long classId);
}
......@@ -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;
......
......@@ -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<AdministerDO> {
void exportClassDailyInfo(ClassDailyInfoDTO classDailyInfoDTO);
IPage<ClassDailyInfoVO> classVodDailyInfo(ClassVodDailyInfoDTO classVodDailyInfoDTO);
void exportClassVodDailyInfo(ClassVodDailyInfoDTO classVodDailyInfoDTO);
void export(ClassDetailDTO classDetailDTO)throws Exception;
void memberStudyLog(MemberStudyLogDTO memberStudyLogDTO)throws Exception;
......
......@@ -18,4 +18,6 @@ public interface VodPlayHistoryService extends IService<VodPlayHistoryDO> {
String insertHistoryNew(VodPlayHistoryDO vodPlayHistoryDO);
void dataFix();
void dataFixTwo();
}
......@@ -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<AdministerMapper, Adminis
private VodDictMapper vodDictMapper;
@Autowired
private OprAdmDictMapper oprAdmDictMapper;
@Autowired
private RedisUtil redisUtil;
@Autowired
......@@ -209,7 +178,7 @@ public class AdministerServiceImpl extends ServiceImpl<AdministerMapper, Adminis
/**
* 最近5次都输入失败,5分钟后再验证 待优化
*/
Query query = new Query(Criteria.where("userId").is(1).and("createDate").gte(System.currentTimeMillis()-5*60*1000+""));//可累加条件
Query query = new Query(Criteria.where("userId").is(1).and("createDate").gte(System.currentTimeMillis() - 5 * 60 * 1000 + ""));//可累加条件
query.with(Sort.by("createDate").descending());
List<OprAdmDictDO> oprAdmDictDOS = mongoTemplate.find(query, OprAdmDictDO.class);
......@@ -236,7 +205,7 @@ public class AdministerServiceImpl extends ServiceImpl<AdministerMapper, Adminis
oprAdmDictDO.setUserId(administerDO1.getId());
oprAdmDictDO.setOprType("登录");
oprAdmDictDO.setResult(1);
oprAdmDictDO.setCreateDate(System.currentTimeMillis()+"");
oprAdmDictDO.setCreateDate(System.currentTimeMillis() + "");
oprAdmDictDO.setLoginDateFormat(DateFormatUtil.format(new Date(), "yyyyMMdd"));
oprAdmDictDO.setUserName(administerDO1.getUserName());
oprAdmDictDO.setCompanyId(administerDO1.getCompanyId());
......@@ -251,7 +220,7 @@ public class AdministerServiceImpl extends ServiceImpl<AdministerMapper, Adminis
oprAdmDictDO.setOprType("登录");
oprAdmDictDO.setResult(0);
//oprAdmDictMapper.insert(oprAdmDictDO);
oprAdmDictDO.setCreateDate(System.currentTimeMillis()+"");
oprAdmDictDO.setCreateDate(System.currentTimeMillis() + "");
oprAdmDictDO.setLoginDateFormat(DateFormatUtil.format(new Date(), "yyyyMMdd"));
oprAdmDictDO.setUserName(administerDO1.getUserName());
oprAdmDictDO.setCompanyId(administerDO1.getCompanyId());
......@@ -882,6 +851,79 @@ public class AdministerServiceImpl extends ServiceImpl<AdministerMapper, Adminis
}
writeExcel(memberIds, hashMap, title);
}
public IPage<ClassDailyInfoVO> classVodDailyInfo(ClassVodDailyInfoDTO classVodDailyInfoDTO) {
//查看班级里有多少人
Page pager = new Page(classVodDailyInfoDTO.getPageNum(), classVodDailyInfoDTO.getPageSize());
//获取班级成员
IPage<ClassDailyInfoVO> classDailyInfoVOIPage = classMemberMappingMapper.getClassMembersWithName(pager, classVodDailyInfoDTO.getClassId(), classVodDailyInfoDTO.getUserName());
List<ClassDailyInfoVO> classDailyInfoVOS = classDailyInfoVOIPage.getRecords();
//获取班级、每个学员维度的视频播放总时长
List<VodPlayHistoryDO> vodPlayHistoryDOS = vodPlayHistoryMapper.classMemberPlayLength(classVodDailyInfoDTO.getClassId());
HashMap<String, Integer> hashMap = new HashMap<>();
//存在一个map里
for (VodPlayHistoryDO vodPlayHistoryDO : vodPlayHistoryDOS) {
hashMap.put(vodPlayHistoryDO.getMemberId() + "-" + vodPlayHistoryDO.getVodId(), vodPlayHistoryDO.getPlayLength());
}
//查询这个班级的所有视频
ClassDictDO classDictDO = classDictMapper.selectById(classVodDailyInfoDTO.getClassId());
List<VodDictDO> vodDictDOS = vodDictMapper.getCourseVods(classDictDO.getCourseId(), null);
for (ClassDailyInfoVO classDailyInfoVO : classDailyInfoVOS) {
//查看这个人某个视频的长度
int total = 0;
List<ClassVodDailyInfoItemVO> 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<VodDictDO> vodDictDOS = vodDictMapper.getCourseVods(classVodDailyInfoDTO.getClassId(),null);
// 表头
List<String> title = new ArrayList<>();
title.add("姓名");
title.add("合计总时长");
for (VodDictDO vodDictDO : vodDictDOS){
title.add(vodDictDO.getVodName());
}
//获取班级成员
IPage<ClassDailyInfoVO> classDailyInfoVOIPage = classMemberMappingMapper.getClassMembersWithName(pager, classVodDailyInfoDTO.getClassId(), classVodDailyInfoDTO.getUserName());
List<ClassDailyInfoVO> classDailyInfoVOS = classDailyInfoVOIPage.getRecords();
//获取班级、每个学员维度的视频播放总时长
List<VodPlayHistoryDO> vodPlayHistoryDOS = vodPlayHistoryMapper.classMemberPlayLength(classVodDailyInfoDTO.getClassId());
HashMap<String, Integer> 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<AdministerMapper, Adminis
HashMap<String, Integer> 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");
......
......@@ -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;
/**
......
......@@ -15,4 +15,6 @@ public class ClassDailyInfoVO {
private List<DayInfoItemVO> dayInfoItemVOS;
private Integer total;
private List<ClassVodDailyInfoItemVO> classVodDailyInfoItemVOS;
}
package com.subsidy.vo.administer;
import lombok.Data;
@Data
public class ClassVodDailyInfoItemVO {
private Integer vodId;
private String vodName;
private Integer playLength;
}
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<DayInfoItemVO> dayInfoItemVOS;
private Integer total;
}
......@@ -307,4 +307,34 @@
AND t.vod_id = #{vodId}
AND t.member_id = #{memberId}
</select>
<select id="exPlayInfo" resultType="com.subsidy.model.VodPlayHistoryDO">
SELECT
*
FROM
vod_play_history t
WHERE
t.delete_date IS NULL
AND t.member_id = #{memberId}
AND t.class_id = #{classId}
AND DATE_FORMAT( t.play_date, '%Y-%m-%d' ) = DATE_FORMAT( #{localDateTime}, '%Y-%m-%d' )
order by t.play_date desc
</select>
<select id="classMemberPlayLength" parameterType="long" resultType="com.subsidy.model.VodPlayHistoryDO">
SELECT
t.member_id,
t.vod_id,
sum( t.play_length ) AS play_length
FROM
vod_play_history t
LEFT JOIN class_member_mapping t2 ON t.member_id = t2.id
WHERE
t.delete_date IS NULL
AND t2.delete_date IS NULL
AND t.class_id = #{classId}
GROUP BY
t.class_id,
t.member_id
</select>
</mapper>
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!