Commit b509e5d7 by 涂亚平

高并发ing 杭州前版本

1 parent ec1f234c
Showing with 793 additions and 545 deletions
......@@ -13,7 +13,7 @@ public class RedisPrefixConstant {
public static final String SUBSIDY_COMPANY_MEMBER_PREFIX = "subsidyMember_";
/**
* subsidy_memberLogin_memberId_now : OprMemDictDO 学员端审计记录
*subsidy_memberLogin_memberId_userName_companyName_now : 学员端审计记录
*/
public static final String SUBSIDY_MEMBER_LOGIN_PREFIX = "subsidy_memberLogin_";
......
......@@ -7,6 +7,7 @@ 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.model.AdministerDO;
import com.subsidy.model.ExerciseDoneHistoryDO;
......@@ -179,6 +180,11 @@ public class AdministerController {
return ResponseData.generateCreatedResponse(0,administerService.classDailyInfo(classDailyInfoDTO));
}
@PostMapping("exportClassDailyInfo")
public void exportVodInfo(@RequestBody ClassDailyInfoDTO classDailyInfoDTO){
administerService.exportClassDailyInfo(classDailyInfoDTO);
}
@PostMapping("exportZip")
@ApiOperation("** 下载压缩包 id 班级id")
@CrossOrigin
......@@ -187,6 +193,13 @@ public class AdministerController {
administerService.export(classDetailDTO);
}
@PostMapping("memberStudyLog")
@ApiOperation("学员学习日志 classId memberId")
public void memberStudyLog(@RequestBody MemberStudyLogDTO memberStudyLogDTO) throws Exception{
administerService.memberStudyLog(memberStudyLogDTO);
}
@PostMapping("importMember")
@ApiOperation("导入学生 {companyId 公司id file}")
public ResponseVO importMember(Long companyId,@RequestParam("file") MultipartFile file){
......
......@@ -47,7 +47,7 @@ public class ClassHourDictController {
}
@PostMapping("pollingGet")
@ApiOperation("** 轮询查询当前这个人当天有没有超过最长时长 memberId playLength")
@ApiOperation("轮询查询当前这个人当天有没有超过最长时长 memberId playLength")
public ResponseVO pollingGet(@RequestBody VodPlayHistoryDO vodPlayHistoryDO){
return ResponseData.generateCreatedResponse(0,classHourDictService.pollingGet(vodPlayHistoryDO));
}
......
......@@ -40,27 +40,27 @@ public class MemberController {
@PostMapping("getAll")
@ApiOperation("查询某部门成员 pageNum pageSize departmentId userName status")
//@LoginRequired(value = {ConstantUtils.ADMINISTER_TERMINATE})
@LoginRequired(value = {ConstantUtils.ADMINISTER_TERMINATE})
public ResponseVO getAll(@RequestBody GetAllDTO getAllDTO){
return ResponseData.generateCreatedResponse(0,memberService.getAll(getAllDTO));
}
@PostMapping("deleteMember")
@ApiOperation("** 删除成员 id ")
@ApiOperation("删除成员 id ")
@LoginRequired(value = {ConstantUtils.ADMINISTER_TERMINATE})
public ResponseVO deleteMember(@RequestBody MemberDO memberDO){
return ResponseData.generateCreatedResponse(0,memberService.deleteMember(memberDO));
}
@PostMapping("addMember")
@ApiOperation("** 新增成员 companyId departmentId userName accountName telephone gender image idCard")
@ApiOperation("新增成员 companyId departmentId userName accountName telephone gender image idCard")
@LoginRequired(value = {ConstantUtils.ADMINISTER_TERMINATE})
public ResponseVO addMember(@RequestBody AddMemberDTO addMemberDTO){
return ResponseData.generateCreatedResponse(0,memberService.addMember(addMemberDTO));
}
@PostMapping("updateMember")
@ApiOperation("** 编辑成员 {id companyId departmentId userName accountName telephone gender image idCard status}")
@ApiOperation("编辑成员 {id companyId departmentId userName accountName telephone gender image idCard status}")
@LoginRequired(value = {ConstantUtils.ADMINISTER_TERMINATE})
public ResponseVO updateMember(@RequestBody AddMemberDTO addMemberDTO){
return ResponseData.generateCreatedResponse(0,memberService.updateMember(addMemberDTO));
......@@ -85,19 +85,19 @@ public class MemberController {
}
@PostMapping("studyPage")
@ApiOperation("** 手机端:学习主页 id 学员id")
@ApiOperation("手机端:学习主页 id 学员id")
public ResponseVO studyPage(@RequestBody MemberDO memberDO){
return ResponseData.generateCreatedResponse(0,memberService.studyPage(memberDO));
}
@PostMapping("contentVod")
@ApiOperation("** 手机端:目录+视频 courseId 课程 memberId 学员id")
@ApiOperation("手机端:目录+视频 courseId 课程 memberId 学员id")
public ResponseVO contentVod(@RequestBody ContentMemberDTO contentVodDTO){
return ResponseData.generateCreatedResponse(0,memberService.contentVod(contentVodDTO));
}
@PostMapping("contentFiles")
@ApiOperation("** 手机端:目录+课件 courseId 课程 memberId 学员id")
@ApiOperation("手机端:目录+课件 courseId 课程 memberId 学员id")
public ResponseVO contentFiles(@RequestBody ContentMemberDTO contentMemberDTO){
return ResponseData.generateCreatedResponse(0,memberService.contentFiles(contentMemberDTO));
}
......
......@@ -30,7 +30,7 @@ public class OprAdmDictController {
private OprAdmDictService oprAdmDictService;
@PostMapping("getHistory")
@ApiOperation("获取后台用户审计 {pageSize pageNum userName startDate endDate}")
@ApiOperation("###获取后台用户审计 {pageSize pageNum userName startDate endDate}")
public ResponseVO getHistory(@RequestBody GetHistoryDTO getHistoryDTO){
return ResponseData.generateCreatedResponse(0,oprAdmDictService.getHistory(getHistoryDTO));
}
......
......@@ -31,7 +31,7 @@ public class OprMemDictController {
@PostMapping("getHistory")
@ApiOperation("获取学员审计 {pageSize pageNum userName startDate endDate}")
@ApiOperation("###获取学员审计 {pageSize pageNum userName startDate endDate}")
public ResponseVO getHistory(@RequestBody GetHistoryDTO getHistoryDTO){
return ResponseData.generateCreatedResponse(0,oprMemDictService.getHistory(getHistoryDTO));
}
......
......@@ -3,10 +3,12 @@ package com.subsidy.controller;
import com.subsidy.common.ResponseData;
import com.subsidy.common.ResponseVO;
import com.subsidy.common.interceptor.LoginRequired;
import com.subsidy.dto.member.GetMemberSignInfoDTO;
import com.subsidy.dto.sign.ClassSignInfoDTO;
import com.subsidy.model.SignInRecordDO;
import com.subsidy.service.SignInRecordService;
import com.subsidy.util.ConstantUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -32,26 +34,26 @@ public class SignInRecordController {
private SignInRecordService signInRecordService;
@PostMapping("getMemberSignInfo")
@ApiOperation("** 获取某个成员的签到记录 id 成员id pageSize pageNum")
@ApiOperation("###获取某个成员的签到记录 id 成员id pageSize pageNum")
public ResponseVO getMemberSignInfo(@RequestBody GetMemberSignInfoDTO getMemberSignInfoDTO) {
return ResponseData.generateCreatedResponse(0, signInRecordService.getMemberSignInfo(getMemberSignInfoDTO));
}
@PostMapping("signIn")
@ApiOperation("** 签到 memberId")
@ApiOperation("签到 memberId")
public ResponseVO signIn(@RequestBody SignInRecordDO signInRecordDO) {
return ResponseData.generateCreatedResponse(0, signInRecordService.signIn(signInRecordDO));
}
@PostMapping("classStudyHistory")
@ApiOperation("** 校区学习记录 id 校区id className courseName pageSize pageNum")
//@LoginRequired(value = {ConstantUtils.ADMINISTER_TERMINATE})
@ApiOperation("校区学习记录 id 校区id className courseName pageSize pageNum")
@LoginRequired(value = {ConstantUtils.ADMINISTER_TERMINATE})
public ResponseVO classSignInfo(@RequestBody ClassSignInfoDTO classSignInfoDTO) {
return ResponseData.generateCreatedResponse(0, signInRecordService.classSignInfo(classSignInfoDTO));
}
@PostMapping("signInStatus")
@ApiOperation("** 判断学生当天有没有打卡 {memberId 学生id}")
@ApiOperation("判断学生当天有没有打卡 {memberId 学生id}")
public ResponseVO signInStatus(@RequestBody SignInRecordDO signInRecordDO) {
return ResponseData.generateCreatedResponse(0, signInRecordService.signInStatus(signInRecordDO));
}
......
......@@ -30,7 +30,7 @@ public class SmsVerifyCodeController {
private SmsVerifyCodeService smsVerifyCodeService;
@PostMapping(value = "/send")
@ApiOperation("** 发送短信验证码 {telephone} ")
@ApiOperation("发送短信验证码 {telephone} ")
public ResponseVO sendVerifyCode(@RequestBody SendVerifyCodeDTO sendVerifyCodeDTO ) {
smsVerifyCodeService.sendVerifyCode(sendVerifyCodeDTO);
return ResponseData.generateCreatedResponse(0);
......
......@@ -33,39 +33,38 @@ public class VodDictController {
private VodDictService vodDictService;
@PostMapping("/signature")
@ApiOperation("** 获取签名")
public ResponseVO signature()throws Exception{
return ResponseData.generateCreatedResponse(0,vodDictService.signature());
@ApiOperation("获取签名")
public ResponseVO signature() throws Exception {
return ResponseData.generateCreatedResponse(0, vodDictService.signature());
}
@PostMapping("getContendVods")
@ApiOperation("** 获取目录下的视频 {contentId vodName}")
@ApiOperation("获取目录下的视频 {contentId vodName}")
@LoginRequired(value = {ConstantUtils.ADMINISTER_TERMINATE})
public ResponseVO getContendVods(@RequestBody GetContendVodsDTO getContendVodsDTO){
return ResponseData.generateCreatedResponse(0,vodDictService.getContendVods(getContendVodsDTO));
public ResponseVO getContendVods(@RequestBody GetContendVodsDTO getContendVodsDTO) {
return ResponseData.generateCreatedResponse(0, vodDictService.getContendVods(getContendVodsDTO));
}
@PostMapping("deleteVod")
@ApiOperation("** 删除视频 id ")
@ApiOperation("删除视频 id ")
@LoginRequired(value = {ConstantUtils.ADMINISTER_TERMINATE})
public ResponseVO deleteVod(@RequestBody VodDictDO vodDictDO){
return ResponseData.generateCreatedResponse(0,vodDictService.deleteVod(vodDictDO));
public ResponseVO deleteVod(@RequestBody VodDictDO vodDictDO) {
return ResponseData.generateCreatedResponse(0, vodDictService.deleteVod(vodDictDO));
}
@PostMapping("addVod")
@ApiOperation("** 新增视频 contentId vodName vodLength vodType vodSize vodUrl vodCode")
@ApiOperation("新增视频 contentId vodName vodLength vodType vodSize vodUrl vodCode")
@LoginRequired(value = {ConstantUtils.ADMINISTER_TERMINATE})
public ResponseVO addVod(@RequestBody VodDictDO vodDictDO){
return ResponseData.generateCreatedResponse(0,vodDictService.addVod(vodDictDO));
public ResponseVO addVod(@RequestBody VodDictDO vodDictDO) {
return ResponseData.generateCreatedResponse(0, vodDictService.addVod(vodDictDO));
}
@PostMapping("updateVod")
@ApiOperation("** 新增视频 id contentId vodName vodLength vodType vodSize vodUrl vodCode")
@ApiOperation("新增视频 id contentId vodName vodLength vodType vodSize vodUrl vodCode")
@LoginRequired(value = {ConstantUtils.ADMINISTER_TERMINATE})
public ResponseVO updateVod(@RequestBody VodDictDO vodDictDO){
return ResponseData.generateCreatedResponse(0,vodDictService.updateVod(vodDictDO));
public ResponseVO updateVod(@RequestBody VodDictDO vodDictDO) {
return ResponseData.generateCreatedResponse(0, vodDictService.updateVod(vodDictDO));
}
}
......@@ -31,13 +31,13 @@ public class VodPlayHistoryController {
private VodPlayHistoryService vodPlayHistoryService;
@PostMapping("insertHistory")
@ApiOperation("** 记录学生看视频位置 ajax请求 classId班级id vodId 视频id memberId 成员id playLength 播放时长 playRecord 位点")
@ApiOperation("记录学生看视频位置 ajax请求 classId班级id vodId 视频id memberId 成员id playLength 播放时长 playRecord 位点")
public ResponseVO insertHistory(@RequestBody VodPlayHistoryDO vodPlayHistoryDO){
return ResponseData.generateCreatedResponse(0,vodPlayHistoryService.insertHistory(vodPlayHistoryDO));
}
@RequestMapping("insertHistoryNew")
@ApiOperation("** 记录学生看视频位置 classId班级id vodId 视频id memberId 成员id playLength 播放时长 playRecord 位点")
@ApiOperation("记录学生看视频位置 classId班级id vodId 视频id memberId 成员id playLength 播放时长 playRecord 位点")
public ResponseVO insertHistoryNew(@RequestBody String param){
VodPlayHistoryDO vodPlayHistoryDO = JSON.parseObject(param,VodPlayHistoryDO.class);
return ResponseData.generateCreatedResponse(0,vodPlayHistoryService.insertHistoryNew(vodPlayHistoryDO));
......
package com.subsidy.dto.administer;
import lombok.Data;
@Data
public class MemberStudyLogDTO {
private Long memberId;
private Long classId;
}
......@@ -2,9 +2,12 @@ package com.subsidy.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.subsidy.model.CourseContentDO;
import com.subsidy.model.FileDictDO;
import com.subsidy.model.VodDictDO;
import com.subsidy.vo.member.MemberVodVO;
import org.springframework.stereotype.Repository;
import java.io.File;
import java.util.List;
/**
......@@ -23,4 +26,14 @@ public interface CourseContentMapper extends BaseMapper<CourseContentDO> {
*/
List<VodDictDO> getCourseVods(Integer courseId);
/**
* 查看某个目录下 某个成员看视频的进度
*/
List<MemberVodVO> contentVodProcess(Long contentId, Long memberId);
/**
* 查看某个课程下的文件/课件
*/
List<FileDictDO> contentFiles(Long courseId);
}
......@@ -3,6 +3,9 @@ package com.subsidy.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.subsidy.model.VodPlayHistoryDO;
import com.subsidy.vo.administer.MemberStudyLogVO;
import com.subsidy.vo.member.ContentVodNewVO;
import com.subsidy.vo.sign.ClassSignInfoVO;
import com.subsidy.vo.vod.GetMemberStudyInfoVO;
import com.subsidy.vo.vod.StudyHistoryVO;
import org.springframework.stereotype.Repository;
......@@ -23,12 +26,12 @@ public interface VodPlayHistoryMapper extends BaseMapper<VodPlayHistoryDO> {
/**
* 查看某成员的学习历史
*/
IPage<StudyHistoryVO> studyHistory(IPage iPage,Long memberId);
IPage<StudyHistoryVO> studyHistory(IPage iPage, Long memberId);
/**
* 从成员,日期的维度查看学生学习时长
*/
List<GetMemberStudyInfoVO> getMemberStudyInfo(Long classId,List<Long> memberIds,String startDate,String endDate);
List<GetMemberStudyInfoVO> getMemberStudyInfo(Long classId, List<Long> memberIds, String startDate, String endDate);
/**
* 缩量记录
......@@ -45,5 +48,24 @@ public interface VodPlayHistoryMapper extends BaseMapper<VodPlayHistoryDO> {
/**
* 查看学生是否完成了某个视频
*/
int completeVodOrNot(Long memberId,Long vodId);
int completeVodOrNot(Long memberId, Long vodId);
/**
* 查看某个班级的学习记录
*/
ClassSignInfoVO classStudyHistory(Long classId);
/**
* 查看这个课程某个成员看的视频课程
*/
ContentVodNewVO memberRecentPlay(Long classId, Long memberId);
/**
* 查看某个成员某个课程的学习日志
*/
List<MemberStudyLogVO> memberStudyLog(Long classId, Long memberId);
}
......@@ -5,6 +5,7 @@ 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.model.AdministerDO;
import com.subsidy.model.ExerciseDoneHistoryDO;
......@@ -73,8 +74,12 @@ public interface AdministerService extends IService<AdministerDO> {
IPage<ClassDailyInfoVO> classDailyInfo(ClassDailyInfoDTO classDailyInfoDTO);
void exportClassDailyInfo(ClassDailyInfoDTO classDailyInfoDTO);
void export(ClassDetailDTO classDetailDTO)throws Exception;
void memberStudyLog(MemberStudyLogDTO memberStudyLogDTO)throws Exception;
String importMember(Long companyId, MultipartFile multipartFile);
}
......@@ -9,6 +9,7 @@ import com.subsidy.dto.member.GetAllDTO;
import com.subsidy.dto.member.PasswordLoginDTO;
import com.subsidy.dto.member.StudyHistoryDTO;
import com.subsidy.model.ExerciseDoneResultDO;
import com.subsidy.model.FileDictDO;
import com.subsidy.model.MemberDO;
import com.subsidy.vo.administer.UserRoleVO;
import com.subsidy.vo.member.ContentFilesVO;
......
......@@ -9,6 +9,7 @@ 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.member.ImportMemberDTO;
import com.subsidy.mapper.AdministerMapper;
......@@ -57,6 +58,7 @@ 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.classdict.ClassDetailVO;
......@@ -75,12 +77,18 @@ import org.apache.commons.lang3.StringUtils;
import org.apache.poi.hssf.usermodel.HSSFCellStyle;
import org.apache.poi.hssf.usermodel.HSSFFont;
import org.apache.poi.hssf.util.CellRangeAddress;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.CellStyle;
import org.apache.poi.ss.usermodel.Font;
import org.apache.poi.ss.usermodel.IndexedColors;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.xssf.streaming.SXSSFCell;
import org.apache.poi.xssf.streaming.SXSSFRow;
import org.apache.poi.xssf.streaming.SXSSFSheet;
import org.apache.poi.xssf.streaming.SXSSFWorkbook;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
......@@ -99,14 +107,21 @@ import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.math.BigDecimal;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Set;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;
......@@ -182,6 +197,9 @@ public class AdministerServiceImpl extends ServiceImpl<AdministerMapper, Adminis
redisUtil.set(RedisPrefixConstant.SUBSIDY_ADMINISTER_PREFIX + administerDO.getAccountName(), administerDO1);
}
if ("0".equals(administerDO1.getStatus())){
throw new HttpException(10013);
}
/**
* 最近5次都输入失败,5分钟后再验证 待优化
*/
......@@ -1002,7 +1020,130 @@ public class AdministerServiceImpl extends ServiceImpl<AdministerMapper, Adminis
return classDailyInfoVOIPage;
}
@Async
public void exportClassDailyInfo(ClassDailyInfoDTO classDailyInfoDTO) {
Page pager = new Page(1, -1L);
// 表头
List<String> title = new ArrayList<>();
title.add("姓名");
title.addAll(findDaysStr(classDailyInfoDTO.getStartDate(), classDailyInfoDTO.getEndDate()));
//获取班级成员
IPage<ClassDailyInfoVO> classDailyInfoVOIPage = classMemberMappingMapper.getClassMembersWithName(pager, classDailyInfoDTO.getClassId(), classDailyInfoDTO.getUserName());
//整理出这些学员id
List<ClassDailyInfoVO> classDailyInfoVOS = classDailyInfoVOIPage.getRecords();
List<Long> memberIds = new ArrayList<>();
for (ClassDailyInfoVO classDailyInfoVO : classDailyInfoVOS) {
memberIds.add(classDailyInfoVO.getId());
}
//这些成员完成情况
List<GetMemberStudyInfoVO> getMemberStudyInfoVOS = vodPlayHistoryMapper.getMemberStudyInfo(classDailyInfoDTO.getClassId(), memberIds, classDailyInfoDTO.getStartDate(), classDailyInfoDTO.getEndDate());
HashMap<Long, HashMap<String, Integer>> hashMap = new HashMap();
for (GetMemberStudyInfoVO getMemberStudyInfoVO : getMemberStudyInfoVOS) {
if (!hashMap.containsKey(getMemberStudyInfoVO.getMemberId())) {
HashMap<String, Integer> hashMap1 = new HashMap<>();
hashMap1.put(getMemberStudyInfoVO.getStudyDate(), getMemberStudyInfoVO.getPlayLength());
hashMap.put(getMemberStudyInfoVO.getMemberId(), hashMap1);
} else {
HashMap<String, Integer> hashMap1 = hashMap.get(getMemberStudyInfoVO.getMemberId());
hashMap1.put(getMemberStudyInfoVO.getStudyDate(), getMemberStudyInfoVO.getPlayLength());
hashMap.put(getMemberStudyInfoVO.getMemberId(), hashMap1);
}
}
writeExcel(memberIds, hashMap, title);
}
/**
* 导出excel文件
*/
public <T> void writeExcel(List<Long> memberIds, HashMap<Long, HashMap<String, Integer>> hashMap, List<String> dates) {
ServletRequestAttributes servletRequestAttributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
HttpServletResponse response = servletRequestAttributes.getResponse();
Workbook wb = new XSSFWorkbook();
Sheet sheet = wb.createSheet();
AtomicInteger ai = new AtomicInteger();
Row row = sheet.createRow(ai.getAndIncrement());
AtomicInteger at = new AtomicInteger();
dates.forEach(field -> {
Cell cell = row.createCell(at.getAndIncrement());
CellStyle cellStyle = wb.createCellStyle();
cellStyle.setFillForegroundColor(IndexedColors.PALE_BLUE.getIndex());
Font font = wb.createFont();
font.setBoldweight(Font.BOLDWEIGHT_BOLD);
cellStyle.setFont(font);
cell.setCellStyle(cellStyle);
cell.setCellValue(field);
});
if (hashMap != null) {
memberIds.forEach(data -> {
Row r = sheet.createRow(ai.getAndIncrement());
AtomicInteger a = new AtomicInteger();
Cell cell = r.createCell(at.getAndIncrement());
CellStyle cellStyle = wb.createCellStyle();
cellStyle.setFillForegroundColor(IndexedColors.PALE_BLUE.getIndex());
cell.setCellStyle(cellStyle);
HashMap<String, Integer> hashMap1 = hashMap.get(data);
Cell namecell = r.createCell(a.getAndIncrement());
namecell.setCellValue(memberMapper.selectById(data).getUserName());
dates.forEach(field -> {
if (!field.equals("姓名")) {
Cell cell1 = r.createCell(a.getAndIncrement());
if (null != hashMap1) {
cell1.setCellValue(null == hashMap1.get(field) ? "00:00:00" : MathUtil.secToTime(hashMap1.get(field)));
} else {
cell1.setCellValue("00:00:00");
}
}
});
});
}
String fileName = String.valueOf(new Date().getTime());
try {
response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
response.setHeader("content-disposition", "attachment;filename=" + URLEncoder.encode(fileName + ".xlsx", "utf-8"));
response.flushBuffer();
wb.write(response.getOutputStream());
} catch (IOException e) {
log.error(String.format("downLoad excel exception"), e);
}
}
//JAVA 获取时间段内的每一天
public static List<String> findDaysStr(String begintTime, String endTime) {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
Date dBegin = null;
Date dEnd = null;
try {
dBegin = sdf.parse(begintTime);
dEnd = sdf.parse(endTime);
} catch (ParseException e) {
e.printStackTrace();
}
List<String> daysStrList = new ArrayList<String>();
daysStrList.add(sdf.format(dBegin));
Calendar calBegin = Calendar.getInstance();
calBegin.setTime(dBegin);
Calendar calEnd = Calendar.getInstance();
calEnd.setTime(dEnd);
while (dEnd.after(calBegin.getTime())) {
calBegin.add(Calendar.DAY_OF_MONTH, 1);
String dayStr = sdf.format(calBegin.getTime());
daysStrList.add(dayStr);
}
return daysStrList;
}
public void export(ClassDetailDTO classDetailDTO) throws Exception {
ServletRequestAttributes servletRequestAttributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
......@@ -1069,6 +1210,20 @@ public class AdministerServiceImpl extends ServiceImpl<AdministerMapper, Adminis
}
public void memberStudyLog(MemberStudyLogDTO memberStudyLogDTO) throws Exception {
MemberDO memberDO = memberMapper.selectById(memberStudyLogDTO.getMemberId());
List<MemberStudyLogVO> memberStudyLog = vodPlayHistoryMapper.memberStudyLog(memberStudyLogDTO.getClassId(), memberStudyLogDTO.getMemberId());
for (MemberStudyLogVO memberStudyLogVO : memberStudyLog) {
memberStudyLogVO.setPlayLength(MathUtil.secToTime(Integer.valueOf(memberStudyLogVO.getPlayLength())));
memberStudyLogVO.setTotalLength(MathUtil.secToTime(Integer.valueOf(memberStudyLogVO.getTotalLength())));
}
ExcelUtil.writeMemberStudyLog(memberDO, "学习日志", memberStudyLog, ExcelFormatUtils.studyLogList);
}
@Transactional(rollbackFor = Exception.class)
public String importMember(Long companyId, MultipartFile multipartFile) {
......@@ -1348,6 +1503,7 @@ public class AdministerServiceImpl extends ServiceImpl<AdministerMapper, Adminis
newCell = dataRow.createCell(10);
newCell.setCellStyle(cellStyle);
newCell.setCellValue(classDetailVO.getResult());
rowIndex++;
seq++;
......@@ -1755,11 +1911,8 @@ public class AdministerServiceImpl extends ServiceImpl<AdministerMapper, Adminis
//次数
newCell = dataRow.createCell(5);
newCell.setCellStyle(cellStyle);
if (exerciseTestVO.getScore() != 0) {
newCell.setCellValue(1);
} else {
newCell.setCellValue(0);
}
newCell.setCellValue(exerciseTestVO.getCount());
newCell = dataRow.createCell(6);
newCell.setCellStyle(cellStyle);
......
......@@ -64,50 +64,22 @@ public class ClassHourDictServiceImpl extends ServiceImpl<ClassHourDictMapper, C
MemberDO memberDO = memberMapper.selectById(vodPlayHistoryDO.getMemberId());
final ExecutorService newCachedThreadPool = Executors.newCachedThreadPool();
//查看系统设定的时长
ClassHourDictDO classHourDictDO = (ClassHourDictDO) redisUtil.get(RedisPrefixConstant.SUBSIDY_SETTINGS_PREFIX + memberDO.getCompanyId());
ClassHourDictDO classHourDictDO = new ClassHourDictDO();
Integer total = 0;
try {
//多个任务
Future<ClassHourDictDO> future1 = newCachedThreadPool.submit(() -> ///该学生完成了多少个 学生成绩,学生进度
pollingGetTask1(memberDO.getCompanyId())).get();
//查看系统设定的时长
classHourDictDO = future1.get();
Future<Integer> future2 = newCachedThreadPool.submit(() -> //答疑
pollingGetTask2(memberDO.getId())).get();
////查看当天这个人看了多少时间
total = future2.get();
} catch (Exception e) {
e.printStackTrace();
}
//执行后不再接收新任务,如果里面有任务,就执行完
newCachedThreadPool.shutdown();
try {
while (true) {
//等待所有任务都结束了继续执行
if (newCachedThreadPool.isTerminated()) {
break;
}
}
} catch (Exception ex) {
ex.printStackTrace();
}
if (classHourDictDO.getStatus() == 0) {
pollingGetVO.setBool(false);
return pollingGetVO;
}
//查看当天这个人看了多少时间
Integer total = vodPlayHistoryMapper.memberDailyStudyLength(memberDO.getId());
//是否超过时长 没超过 false 超过 true
if (classHourDictDO == null) {
pollingGetVO.setBool(true);
} else {
if (total + vodPlayHistoryDO.getPlayLength() < classHourDictDO.getClassHour() * 60 * 60) {
if (total + vodPlayHistoryDO.getPlayLength() <= classHourDictDO.getClassHour() * 60 * 60) {
pollingGetVO.setBool(false);
} else {
pollingGetVO.setBool(true);
......@@ -116,14 +88,4 @@ public class ClassHourDictServiceImpl extends ServiceImpl<ClassHourDictMapper, C
return pollingGetVO;
}
public Future<ClassHourDictDO> pollingGetTask1(Long companyId) {
System.out.println(redisUtil.get(RedisPrefixConstant.SUBSIDY_SETTINGS_PREFIX + companyId));
return new AsyncResult<>((ClassHourDictDO) redisUtil.get(RedisPrefixConstant.SUBSIDY_SETTINGS_PREFIX + companyId));
//return new AsyncResult<>("hello");
}
public Future<Integer> pollingGetTask2(Long memberId) {
return new AsyncResult<>(vodPlayHistoryMapper.memberDailyStudyLength(memberId));
}
}
......@@ -14,17 +14,18 @@ import com.subsidy.dto.member.PasswordLoginDTO;
import com.subsidy.dto.member.StudyHistoryDTO;
import com.subsidy.mapper.ClassDictMapper;
import com.subsidy.mapper.ClassMemberMappingMapper;
import com.subsidy.mapper.CompanyDictMapper;
import com.subsidy.mapper.CourseContentMapper;
import com.subsidy.mapper.ExerciseDoneResultMapper;
import com.subsidy.mapper.FileDictMapper;
import com.subsidy.mapper.MemberDepartmentMappingMapper;
import com.subsidy.mapper.MemberMapper;
import com.subsidy.mapper.PaperDictMapper;
import com.subsidy.mapper.VodDictMapper;
import com.subsidy.mapper.VodPlayHistoryMapper;
import com.subsidy.model.ClassDictDO;
import com.subsidy.model.ClassHourDictDO;
import com.subsidy.model.ClassMemberMappingDO;
import com.subsidy.model.CompanyDictDO;
import com.subsidy.model.CourseContentDO;
import com.subsidy.model.DepartmentDictDO;
import com.subsidy.model.ExerciseDoneResultDO;
......@@ -36,7 +37,6 @@ import com.subsidy.model.VodDictDO;
import com.subsidy.model.VodPlayHistoryDO;
import com.subsidy.service.MemberService;
import com.subsidy.util.ConstantUtils;
import com.subsidy.util.MathUtil;
import com.subsidy.util.RedisUtil;
import com.subsidy.vo.administer.UserRoleVO;
import com.subsidy.vo.member.ContentFilesVO;
......@@ -46,7 +46,6 @@ import com.subsidy.vo.member.GetAllVO;
import com.subsidy.vo.member.GetStudyInfoVO;
import com.subsidy.vo.member.MemberStudyPageVO;
import com.subsidy.vo.member.MemberVO;
import com.subsidy.vo.member.MemberVodVO;
import com.subsidy.vo.member.StudyPageVO;
import com.subsidy.vo.paper.QueryPapersVO;
import org.springframework.beans.BeanUtils;
......@@ -82,9 +81,6 @@ public class MemberServiceImpl extends ServiceImpl<MemberMapper, MemberDO> imple
private VodPlayHistoryMapper vodPlayHistoryMapper;
@Autowired
private VodDictMapper vodDictMapper;
@Autowired
private FileDictMapper fileDictMapper;
@Autowired
......@@ -99,6 +95,8 @@ public class MemberServiceImpl extends ServiceImpl<MemberMapper, MemberDO> imple
@Autowired
private ClassDictMapper classDictMapper;
@Autowired
private CompanyDictMapper companyDictMapper;
@Autowired
private MemberDepartmentMappingMapper memberDepartmentMappingMapper;
......@@ -120,33 +118,13 @@ public class MemberServiceImpl extends ServiceImpl<MemberMapper, MemberDO> imple
public String deleteMember(MemberDO memberDO) {
final ExecutorService newCachedThreadPool = Executors.newCachedThreadPool();
//多个任务
newCachedThreadPool.execute(() -> ///该学生完成了多少个 学生成绩,学生进度
this.baseMapper.deleteById(memberDO.getId()));
newCachedThreadPool.execute(() -> //答疑
classMemberMappingMapper.delete(new QueryWrapper<ClassMemberMappingDO>()
.lambda()
.eq(ClassMemberMappingDO::getMemberId, memberDO.getId())));
newCachedThreadPool.execute(() -> //签到
memberDepartmentMappingMapper.delete(new QueryWrapper<MemberDepartmentMappingDO>()
.lambda()
.eq(MemberDepartmentMappingDO::getMemberId, memberDO.getId())));
//执行后不再接收新任务,如果里面有任务,就执行完
newCachedThreadPool.shutdown();
try {
while (true) {
//等待所有任务都结束了继续执行
if (newCachedThreadPool.isTerminated()) {
break;
}
}
} catch (Exception ex) {
ex.printStackTrace();
}
this.baseMapper.deleteById(memberDO.getId());
classMemberMappingMapper.delete(new QueryWrapper<ClassMemberMappingDO>()
.lambda()
.eq(ClassMemberMappingDO::getMemberId, memberDO.getId()));
memberDepartmentMappingMapper.delete(new QueryWrapper<MemberDepartmentMappingDO>()
.lambda()
.eq(MemberDepartmentMappingDO::getMemberId, memberDO.getId()));
return ConstantUtils.DELETE_SUCCESS;
}
......@@ -160,9 +138,6 @@ public class MemberServiceImpl extends ServiceImpl<MemberMapper, MemberDO> imple
throw new HttpException(20002);
}
//部门
List<Long> longs = addMemberDTO.getDepartmentIds();
Integer count1 = this.baseMapper.selectCount(new QueryWrapper<MemberDO>()
.lambda()
.eq(MemberDO::getAccountName, addMemberDTO.getAccountName())
......@@ -172,7 +147,6 @@ public class MemberServiceImpl extends ServiceImpl<MemberMapper, MemberDO> imple
throw new HttpException(20002);
}
MemberDO memberDO = new MemberDO();
BeanUtils.copyProperties(addMemberDTO, memberDO);
memberDO.setPassword("123456");
......@@ -181,7 +155,10 @@ public class MemberServiceImpl extends ServiceImpl<MemberMapper, MemberDO> imple
//公司赋值
memberDO.setCompanyId(addMemberDTO.getCompanyId());
this.baseMapper.insert(memberDO);
redisUtil.set(RedisPrefixConstant.SUBSIDY_COMPANY_MEMBER_PREFIX + memberDO.getCompanyId() + memberDO.getAccountName(), memberDO);
//部门
List<Long> longs = addMemberDTO.getDepartmentIds();
for (Long lg : longs) {
MemberDepartmentMappingDO memberDepartmentMappingDO = new MemberDepartmentMappingDO();
......@@ -195,29 +172,29 @@ public class MemberServiceImpl extends ServiceImpl<MemberMapper, MemberDO> imple
public String updateMember(AddMemberDTO addMemberDTO) {
if (null != addMemberDTO.getDepartmentIds()) {
Integer count = this.baseMapper.selectCount(new QueryWrapper<MemberDO>()
.lambda()
.eq(MemberDO::getTelephone, addMemberDTO.getTelephone())
.ne(MemberDO::getId, addMemberDTO.getId()));
Integer count = this.baseMapper.selectCount(new QueryWrapper<MemberDO>()
.lambda()
.eq(MemberDO::getTelephone, addMemberDTO.getTelephone())
.ne(MemberDO::getId, addMemberDTO.getId()));
if (count > 0) {
throw new HttpException(20002);
}
Integer count1 = this.baseMapper.selectCount(new QueryWrapper<MemberDO>()
.lambda()
.eq(MemberDO::getAccountName, addMemberDTO.getAccountName())
.eq(MemberDO::getCompanyId, addMemberDTO.getCompanyId())
.ne(MemberDO::getId, addMemberDTO.getId()));
if (count > 0) {
throw new HttpException(20002);
}
if (count1 > 0) {
throw new HttpException(20002);
}
Integer count1 = this.baseMapper.selectCount(new QueryWrapper<MemberDO>()
.lambda()
.eq(MemberDO::getAccountName, addMemberDTO.getAccountName())
.eq(MemberDO::getCompanyId, addMemberDTO.getCompanyId())
.ne(MemberDO::getId, addMemberDTO.getId()));
if (count1 > 0) {
throw new HttpException(20002);
}
MemberDO memberDO = new MemberDO();
BeanUtils.copyProperties(addMemberDTO, memberDO);
this.baseMapper.updateById(memberDO);
redisUtil.set(RedisPrefixConstant.SUBSIDY_COMPANY_MEMBER_PREFIX + memberDO.getCompanyId() + memberDO.getAccountName(), memberDO);
if (null != addMemberDTO.getDepartmentIds()) {
memberDepartmentMappingMapper.delete(new QueryWrapper<MemberDepartmentMappingDO>()
......@@ -237,7 +214,6 @@ public class MemberServiceImpl extends ServiceImpl<MemberMapper, MemberDO> imple
return ConstantUtils.SET_SUCCESS;
}
@Override
@Transactional(rollbackFor = Exception.class)
public UserRoleVO login(VerifyCodeDTO verifyCodeDTO) {
UserRoleVO userRoleVO = new UserRoleVO();
......@@ -248,13 +224,14 @@ public class MemberServiceImpl extends ServiceImpl<MemberMapper, MemberDO> imple
throw new HttpException(10010);
}
CompanyDictDO companyDictDO = companyDictMapper.selectById(memberDO.getCompanyId());
if ("冻结".equals(memberDO.getStatus())) {
OprMemDictDO oprMemDictDO = new OprMemDictDO();
oprMemDictDO.setUserId(memberDO.getId());
oprMemDictDO.setOprType("登录");
oprMemDictDO.setResult(0);
//oprMemDictMapper.insert(oprMemDictDO);
redisUtil.set(RedisPrefixConstant.SUBSIDY_MEMBER_LOGIN_PREFIX + memberDO.getId() + LocalDateTime.now(), oprMemDictDO);
redisUtil.set(RedisPrefixConstant.SUBSIDY_MEMBER_LOGIN_PREFIX + memberDO.getId() + "_" + memberDO.getUserName() + "_" + companyDictDO.getCompanyName() + "_" + LocalDateTime.now(), oprMemDictDO);
throw new HttpException(10013);
}
......@@ -262,37 +239,28 @@ public class MemberServiceImpl extends ServiceImpl<MemberMapper, MemberDO> imple
if (0 == memberDO.getFirstLogin()) {
memberDO.setFirstLogin(1);
this.baseMapper.updateById(memberDO);
redisUtil.set(RedisPrefixConstant.SUBSIDY_COMPANY_MEMBER_PREFIX + memberDO.getCompanyId() + "_" + memberDO.getAccountName(), memberDO);
}
BeanUtils.copyProperties(memberDO, userRoleVO);
String code = redisUtil.get(RedisPrefixConstant.SUBSIDY_TELEPHONE_PREFIX + verifyCodeDTO.getTelephone()).toString();
//SmsVerifyCodeDO smsCodeDO = smsVerifyCodeMapper.selectOne(new QueryWrapper<SmsVerifyCodeDO>()
// .lambda()
// .eq(SmsVerifyCodeDO::getTelephone, verifyCodeDTO.getTelephone())
// .eq(SmsVerifyCodeDO::getVerifyCode, verifyCodeDTO.getVerifyCode())
// .gt(SmsVerifyCodeDO::getCreateDate, LocalDateTime.now().minusMinutes(30L)));
if (code == null || !verifyCodeDTO.getVerifyCode().equals(code)) {
OprMemDictDO oprMemDictDO = new OprMemDictDO();
oprMemDictDO.setUserId(memberDO.getId());
oprMemDictDO.setOprType("登录");
oprMemDictDO.setResult(0);
oprMemDictDO.setCreateDate(LocalDateTime.now());
//oprMemDictMapper.insert(oprMemDictDO);
redisUtil.set(RedisPrefixConstant.SUBSIDY_MEMBER_LOGIN_PREFIX + memberDO.getId() + LocalDateTime.now(), oprMemDictDO);
throw new HttpException(70010);
}
OprMemDictDO oprMemDictDO = new OprMemDictDO();
oprMemDictDO.setUserId(memberDO.getId());
oprMemDictDO.setOprType("登录");
oprMemDictDO.setResult(1);
//oprMemDictMapper.insert(oprMemDictDO);
//审计日志
redisUtil.set(RedisPrefixConstant.SUBSIDY_MEMBER_LOGIN_PREFIX + memberDO.getId() + LocalDateTime.now(), oprMemDictDO);
//将学员信息写到redis
redisUtil.set(RedisPrefixConstant.SUBSIDY_COMPANY_MEMBER_PREFIX + memberDO.getCompanyId() + ":" + memberDO.getAccountName(), memberDO);
return userRoleVO;
}
......@@ -371,19 +339,9 @@ public class MemberServiceImpl extends ServiceImpl<MemberMapper, MemberDO> imple
studyPageVO.setTotalVods(vodDictDOS.size());
newCachedThreadPool.submit(() -> studyPageTask1(studyPageVO, vodDictDOS, memberDO.getId()));
}
newCachedThreadPool.shutdown();
memberStudyPageVO.setStudyPageVOS(studyPageVOS);
//List<DepartmentDictDO> 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;
}
......@@ -406,12 +364,6 @@ public class MemberServiceImpl extends ServiceImpl<MemberMapper, MemberDO> imple
return new AsyncResult<>(studyPageVO);
}
public Future<StudyPageVO> studyPageTask2(StudyPageVO studyPageVO) {
return new AsyncResult<>(studyPageVO);
}
public ContentVodNewVO contentVod(ContentMemberDTO contentVodDTO) {
ContentVodNewVO contentVodNewVO = new ContentVodNewVO();
......@@ -425,105 +377,18 @@ public class MemberServiceImpl extends ServiceImpl<MemberMapper, MemberDO> imple
for (CourseContentDO courseContentDO : courseContentDOS) {
ContentVodVO contentVodVO = new ContentVodVO();
contentVodVO.setContent(courseContentDO.getContent());
List<MemberVodVO> memberVodVOS = new ArrayList<>();
//目录下的视频
List<VodDictDO> vodDictDOS = vodDictMapper.selectList(new QueryWrapper<VodDictDO>()
.lambda()
.eq(VodDictDO::getContentId, courseContentDO.getId()));
for (VodDictDO vodDictDO : vodDictDOS) {
MemberVodVO memberVodVO = new MemberVodVO();
final ExecutorService newCachedThreadPool = Executors.newCachedThreadPool();
//多个任务
newCachedThreadPool.execute(() ->
contentVodTask1(memberVodVO, vodDictDO, contentVodDTO.getMemberId()));
newCachedThreadPool.execute(() ->
contentVodTask2(memberVodVO, vodDictDO, contentVodDTO.getMemberId()));
//执行后不再接收新任务,如果里面有任务,就执行完
newCachedThreadPool.shutdown();
try {
while (true) {
//等待所有任务都结束了继续执行
if (newCachedThreadPool.isTerminated()) {
break;
}
}
} catch (Exception ex) {
ex.printStackTrace();
}
memberVodVOS.add(memberVodVO);
}
contentVodVO.setMemberVodVOS(memberVodVOS);
contentVodVO.setMemberVodVOS(courseContentMapper.contentVodProcess(courseContentDO.getId(),contentVodDTO.getMemberId()));
contentVodVOS.add(contentVodVO);
}
contentVodNewVO.setContentVodVOS(contentVodVOS);
List<VodPlayHistoryDO> vodPlayHistoryDOS = vodPlayHistoryMapper.selectList(new QueryWrapper<VodPlayHistoryDO>()
.lambda()
.eq(VodPlayHistoryDO::getClassId, contentVodDTO.getClassId())
.eq(VodPlayHistoryDO::getMemberId, contentVodDTO.getMemberId())
.orderByDesc(VodPlayHistoryDO::getCreateDate));
if (vodPlayHistoryDOS.size() > 0) {
VodPlayHistoryDO vodPlayHistoryDO = vodPlayHistoryDOS.get(0);
VodDictDO vodDictDO = vodDictMapper.selectById(vodPlayHistoryDO.getVodId());
if (null != vodDictDO) {
BeanUtils.copyProperties(vodDictDO, contentVodNewVO);
contentVodNewVO.setPlayRecord(vodPlayHistoryDO.getPlayRecord());
}
}
//最新的视频记录
ContentVodNewVO contentVodNewVO1 = vodPlayHistoryMapper.memberRecentPlay(contentVodDTO.getClassId(),contentVodDTO.getMemberId());
contentVodNewVO.setId(contentVodNewVO1.getId());
contentVodNewVO.setPlayRecord(contentVodNewVO.getPlayRecord());
return contentVodNewVO;
}
public Future<MemberVodVO> contentVodTask1(MemberVodVO memberVodVO, VodDictDO vodDictDO, Long memberId) {
List<VodPlayHistoryDO> vodPlayHistoryDOS = vodPlayHistoryMapper.selectList(new QueryWrapper<VodPlayHistoryDO>()
.lambda()
.eq(VodPlayHistoryDO::getMemberId, memberId)
.eq(VodPlayHistoryDO::getVodId, vodDictDO.getId())
.orderByDesc(VodPlayHistoryDO::getPlayRecord));
memberVodVO.setStatus(false);
if (vodPlayHistoryDOS.size() > 0) {
int length = MathUtil.intDivCeil(100 * vodPlayHistoryDOS.get(0).getPlayRecord(), vodDictDO.getVodLength());
if (length >= 100) {
memberVodVO.setPercent(100);
} else {
memberVodVO.setPercent(length);
}
if (memberVodVO.getPercent() >= 80) {
memberVodVO.setStatus(true);
}
} else {
memberVodVO.setPercent(0);
}
return new AsyncResult<>(memberVodVO);
}
public Future<MemberVodVO> contentVodTask2(MemberVodVO memberVodVO, VodDictDO vodDictDO, Long memberId) {
List<VodPlayHistoryDO> vodPlayHistoryDOS1 = vodPlayHistoryMapper.selectList(new QueryWrapper<VodPlayHistoryDO>()
.lambda()
.eq(VodPlayHistoryDO::getMemberId, memberId)
.eq(VodPlayHistoryDO::getVodId, vodDictDO.getId())
.orderByDesc(VodPlayHistoryDO::getCreateDate));
if (vodPlayHistoryDOS1.size() > 0) {
memberVodVO.setPlayRecord(vodPlayHistoryDOS1.get(0).getPlayRecord());
}
memberVodVO.setId(vodDictDO.getId());
memberVodVO.setVodUrl(vodDictDO.getVodUrl());
memberVodVO.setTeacherName(vodDictDO.getTeacherName());
memberVodVO.setVodLength(vodDictDO.getVodLength());
memberVodVO.setVodName(vodDictDO.getVodName());
return new AsyncResult<>(memberVodVO);
}
public List<ContentFilesVO> contentFiles(ContentMemberDTO contentMemberDTO) {
List<ContentFilesVO> contentFilesVOS = new ArrayList<>();
......@@ -563,6 +428,7 @@ public class MemberServiceImpl extends ServiceImpl<MemberMapper, MemberDO> imple
for (QueryPapersVO queryPapersVO : queryPapersVOS) {
executorService.execute(() -> getCourseTestTask(queryPapersVO, contentMemberDTO.getMemberId(), classDictDO));
}
executorService.shutdown();
return queryPapersVOS;
}
......
......@@ -7,40 +7,33 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.subsidy.common.RedisPrefixConstant;
import com.subsidy.dto.member.GetMemberSignInfoDTO;
import com.subsidy.dto.sign.ClassSignInfoDTO;
import com.subsidy.mapper.AnsweringQuestionMapper;
import com.subsidy.mapper.ClassDictMapper;
import com.subsidy.mapper.ClassHourDictMapper;
import com.subsidy.mapper.ClassMemberMappingMapper;
import com.subsidy.mapper.ExerciseDoneResultMapper;
import com.subsidy.mapper.MemberMapper;
import com.subsidy.mapper.SignInRecordMapper;
import com.subsidy.mapper.VodPlayHistoryMapper;
import com.subsidy.model.AnsweringQuestionDO;
import com.subsidy.model.ClassDictDO;
import com.subsidy.model.ClassHourDictDO;
import com.subsidy.model.ClassMemberMappingDO;
import com.subsidy.model.ExerciseDoneResultDO;
import com.subsidy.model.MemberDO;
import com.subsidy.model.SignInRecordDO;
import com.subsidy.model.VodDictDO;
import com.subsidy.model.VodPlayHistoryDO;
import com.subsidy.service.SignInRecordService;
import com.subsidy.util.ConstantUtils;
import com.subsidy.util.DateFormatUtil;
import com.subsidy.util.MathUtil;
import com.subsidy.util.RedisUtil;
import com.subsidy.vo.member.ClassSignVO;
import com.subsidy.vo.member.GetMemberSignInfoVO;
import com.subsidy.vo.member.StudyPageVO;
import com.subsidy.vo.sign.ClassSignInfoVO;
import com.subsidy.vo.sign.SignInStatusVO;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.AsyncResult;
import org.springframework.stereotype.Service;
import java.util.Date;
import java.util.List;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
/**
* <p>
......@@ -57,24 +50,12 @@ public class SignInRecordServiceImpl extends ServiceImpl<SignInRecordMapper, Sig
private ClassMemberMappingMapper classMemberMappingMapper;
@Autowired
private ClassDictMapper classDictMapper;
@Autowired
private VodPlayHistoryMapper vodPlayHistoryMapper;
@Autowired
private ExerciseDoneResultMapper exerciseDoneResultMapper;
@Autowired
private AnsweringQuestionMapper answeringQuestionMapper;
@Autowired
private RedisUtil redisUtil;
@Autowired
private MemberMapper memberMapper;
@Autowired
private ClassHourDictMapper classHourDictMapper;
public IPage<GetMemberSignInfoVO> getMemberSignInfo(GetMemberSignInfoDTO getMemberSignInfoDTO) {
......@@ -88,135 +69,43 @@ public class SignInRecordServiceImpl extends ServiceImpl<SignInRecordMapper, Sig
public String signIn(SignInRecordDO signInRecordDO) {
/**
* 查看学生所有在读班级
*/
//查看学生所有在读班级
List<ClassDictDO> classDictDOS = classMemberMappingMapper.getMemberClass(signInRecordDO.getMemberId());
/*this.baseMapper.delete(new QueryWrapper<SignInRecordDO>()
.lambda()
.eq(SignInRecordDO::getMemberId, signInRecordDO.getMemberId())
.gt(SignInRecordDO::getSignInDate, LocalDate.now()));*/
for (ClassDictDO classDictDO : classDictDOS) {
/*
SignInRecordDO signInRecordDO1 = new SignInRecordDO();
signInRecordDO1.setClassId(classDictDO.getId());
signInRecordDO1.setMemberId(signInRecordDO.getMemberId());
signInRecordDO1.setSignInDate(LocalDateTime.now());
*/
redisUtil.set(RedisPrefixConstant.SUBSIDY_SIGN_INFO_PREFIX + "memberId_" + signInRecordDO.getMemberId() + "_classId_" + classDictDO.getId() + "_" + DateFormatUtil.format(new Date(), "yyyyMMdd") + "_" + System.currentTimeMillis(), null);
// this.baseMapper.insert(signInRecordDO1);
}
return ConstantUtils.ADD_SUCCESS;
}
public IPage classSignInfo(ClassSignInfoDTO classSignInfoDTO) {
public IPage<ClassSignInfoVO> classSignInfo(ClassSignInfoDTO classSignInfoDTO) {
Page pager = new Page(classSignInfoDTO.getPageNum(), classSignInfoDTO.getPageSize());
IPage<ClassSignInfoVO> classSignInfoVOIPage = this.baseMapper.classSignInfo(pager, classSignInfoDTO.getClassName(), classSignInfoDTO.getCourseName(), classSignInfoDTO.getCompanyId());
List<ClassSignInfoVO> classSignInfoVOS = classSignInfoVOIPage.getRecords();
for (ClassSignInfoVO classSignInfoVO : classSignInfoVOS) {
final ExecutorService newCachedThreadPool = Executors.newCachedThreadPool();
//班级人数
List<ClassMemberMappingDO> classMemberMappingDOS = classMemberMappingMapper.selectList(new QueryWrapper<ClassMemberMappingDO>()
.lambda()
.eq(ClassMemberMappingDO::getClassId, classSignInfoVO.getClassId()));
classSignInfoVO.setMemberCount(classMemberMappingDOS.size());
//课程总数
List<VodDictDO> vodDictDOS = classDictMapper.getClassVods(classSignInfoVO.getClassId());
classSignInfoVO.setTotalVodCounts(vodDictDOS.size());
final ExecutorService newCachedThreadPool = Executors.newCachedThreadPool();
//多个任务
newCachedThreadPool.execute(() -> ///该学生完成了多少个 学生成绩,学生进度
classSignInfoTask1(vodDictDOS, classMemberMappingDOS, classSignInfoVO));
newCachedThreadPool.execute(() -> //答疑
classSignInfoTask2(classSignInfoVO, classMemberMappingDOS));
newCachedThreadPool.execute(() -> //签到
classSignInfoTask3(classSignInfoVO, classMemberMappingDOS));
//执行后不再接收新任务,如果里面有任务,就执行完
newCachedThreadPool.shutdown();
try {
while (true) {
//等待所有任务都结束了继续执行
if (newCachedThreadPool.isTerminated()) {
break;
}
}
} catch (Exception ex) {
ex.printStackTrace();
}
}
newCachedThreadPool.shutdown();
for (ClassSignInfoVO classSignInfoVO : classSignInfoVOS) {
newCachedThreadPool.submit(()->classSignInfoTask(classSignInfoVO));
}
newCachedThreadPool.shutdown();
classSignInfoVOIPage.setRecords(classSignInfoVOS);
return classSignInfoVOIPage;
}
public void classSignInfoTask1(List<VodDictDO> vodDictDOS, List<ClassMemberMappingDO> classMemberMappingDOS, ClassSignInfoVO classSignInfoVO) {
int totalStudyVods = 0;
int totalStudyLength = 0;
//学生总共学习课时数
for (VodDictDO vodDictDO : vodDictDOS) {
for (ClassMemberMappingDO classMemberMappingDO : classMemberMappingDOS) {
List<VodPlayHistoryDO> vodPlayHistoryDOS = vodPlayHistoryMapper.selectList(new QueryWrapper<VodPlayHistoryDO>()
.lambda()
.eq(VodPlayHistoryDO::getMemberId, classMemberMappingDO.getMemberId())
.eq(VodPlayHistoryDO::getVodId, vodDictDO.getId())
.orderByDesc(VodPlayHistoryDO::getPlayRecord));
for (VodPlayHistoryDO vodPlayHistoryDO : vodPlayHistoryDOS) {
totalStudyLength += vodPlayHistoryDO.getPlayLength();
}
if (vodPlayHistoryDOS.size() > 0) {
if (vodPlayHistoryDOS.get(0).getPlayRecord() >= vodDictDO.getVodLength() * 0.8) {
totalStudyVods++;
}
}
}
}
classSignInfoVO.setStudyVodCounts(MathUtil.intDivCeil(totalStudyVods, classMemberMappingDOS.size()));
//平均完成时长 学生观看课程视频的全部时长/总人数
int avg = MathUtil.intDivCeil(totalStudyLength, classMemberMappingDOS.size());
classSignInfoVO.setAvgVodPlayLength(avg);
}
public void classSignInfoTask2(ClassSignInfoVO classSignInfoVO, List<ClassMemberMappingDO> classMemberMappingDOS) {
//测试通过率
List<ExerciseDoneResultDO> exerciseDoneResultDOS = exerciseDoneResultMapper.selectList(new QueryWrapper<ExerciseDoneResultDO>()
.lambda()
.eq(ExerciseDoneResultDO::getClassId, classSignInfoVO.getClassId()));
int passNum = 0;
public Future<ClassSignInfoVO> classSignInfoTask(ClassSignInfoVO classSignInfoVO){
ClassSignInfoVO classSignInfoVO1 = vodPlayHistoryMapper.classStudyHistory(classSignInfoVO.getClassId());
BeanUtils.copyProperties(classSignInfoVO1,classSignInfoVO);
for (ExerciseDoneResultDO exerciseDoneResultDO : exerciseDoneResultDOS) {
if (exerciseDoneResultDO.getRightCounts() > exerciseDoneResultDO.getTotalCounts() * 0.6) {
passNum++;
}
}
classSignInfoVO.setPassRate(MathUtil.intDivFloorPercent(passNum, classMemberMappingDOS.size()));
}
public void classSignInfoTask3(ClassSignInfoVO classSignInfoVO, List<ClassMemberMappingDO> classMemberMappingDOS) {
//平均签到数 向上取整
//签到总次数
//平均签到数 向下取整
long signCount = redisUtil.keys(RedisPrefixConstant.SUBSIDY_SIGN_INFO_PREFIX + "*_classId_" + classSignInfoVO.getClassId() + "_*").stream().count();
classSignInfoVO.setAvgSignCount(MathUtil.intDivCeil(signCount, classMemberMappingDOS.size()));
//答疑数
Integer count = answeringQuestionMapper.selectCount(new QueryWrapper<AnsweringQuestionDO>()
.lambda()
.eq(AnsweringQuestionDO::getClassId, classSignInfoVO.getClassId()));
classSignInfoVO.setAnswerCount(count);
classSignInfoVO.setAvgSignCount(MathUtil.intDivCeil(signCount, classSignInfoVO1.getMemberCount()));
return new AsyncResult<>(classSignInfoVO);
}
public SignInStatusVO signInStatus(SignInRecordDO signInRecordDO) {
......@@ -227,7 +116,7 @@ public class SignInRecordServiceImpl extends ServiceImpl<SignInRecordMapper, Sig
//获取有效课程
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) {
signInStatusVO.setStatus(flag);
......@@ -237,29 +126,24 @@ public class SignInRecordServiceImpl extends ServiceImpl<SignInRecordMapper, Sig
}
@Async
public void test() {
//Set set = redisUtil.keys("*subsidyMember*");
//for (Object str : set) {
// System.out.println(str);
// redisUtil.get(str.toString());
//}
//List<ClassHourDictDO> classHourDictDOS = classHourDictMapper.selectList(null);
//
//for (ClassHourDictDO classHourDictDO : classHourDictDOS) {
// redisUtil.set(RedisPrefixConstant.SUBSIDY_SETTINGS_PREFIX + classHourDictDO.getCompanyId(), classHourDictDO);
//}
//预写公司设置数据
List<ClassHourDictDO> classHourDictDOS = classHourDictMapper.selectList(null);
for (ClassHourDictDO classHourDictDO : classHourDictDOS) {
redisUtil.set("subsidySettings_" + classHourDictDO.getCompanyId(), classHourDictDO);
}
//预写学生账号数据
//List<MemberDO> memberDOS = memberMapper.selectList(null);
//for (MemberDO memberDO : memberDOS){
// redisUtil.set(RedisPrefixConstant.SUBSIDY_COMPANY_MEMBER_PREFIX+memberDO.getCompanyId()+"_"+memberDO.getAccountName(),memberDO);
//}
}
}
......@@ -38,27 +38,20 @@ public class SmsVerifyCodeServiceImpl extends ServiceImpl<SmsVerifyCodeMapper, S
private RedisUtil redisUtil;
@Async
public void sendVerifyCode(SendVerifyCodeDTO sendVerifyCodeDTO){
MemberDO memberDO =memberMapper.selectOne(new QueryWrapper<MemberDO>()
public void sendVerifyCode(SendVerifyCodeDTO sendVerifyCodeDTO) {
MemberDO memberDO = memberMapper.selectOne(new QueryWrapper<MemberDO>()
.lambda()
.eq(MemberDO::getTelephone, sendVerifyCodeDTO.getTelephone()));
if(memberDO == null) {
if (memberDO == null) {
throw new HttpException(70012);
}
String code = RandomUtil.getRandomCode(6);
smsUtils.send(sendVerifyCodeDTO.getTelephone(), code);
//SmsVerifyCodeDO smsCodeDO = new SmsVerifyCodeDO();
//smsCodeDO.setVerifyCode(code);
//smsCodeDO.setTelephone(sendVerifyCodeDTO.getTelephone());
//this.baseMapper.insert(smsCodeDO);
/**
* 验证码存在redis
*/
redisUtil.set(RedisPrefixConstant.SUBSIDY_TELEPHONE_PREFIX +sendVerifyCodeDTO.getTelephone(),code,30*60);
redisUtil.set(RedisPrefixConstant.SUBSIDY_TELEPHONE_PREFIX + sendVerifyCodeDTO.getTelephone(), code, 30 * 60);
}
}
......@@ -21,10 +21,8 @@ import com.tencentcloudapi.vod.v20180717.VodClient;
import com.tencentcloudapi.vod.v20180717.models.DeleteMediaRequest;
import com.tencentcloudapi.vod.v20180717.models.MediaProcessTaskInput;
import com.tencentcloudapi.vod.v20180717.models.ProcessMediaRequest;
import com.tencentcloudapi.vod.v20180717.models.ProcessMediaResponse;
import com.tencentcloudapi.vod.v20180717.models.TranscodeTaskInput;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import java.util.Random;
......@@ -44,8 +42,7 @@ public class VodDictServiceImpl extends ServiceImpl<VodDictMapper, VodDictDO> im
private VODConfig vodConfig;
public SignatureVO signature() throws Exception {
//
public SignatureVO signature() {
SignatureVO signatureVO = new SignatureVO();
Signature signature = new Signature();
......@@ -61,21 +58,19 @@ public class VodDictServiceImpl extends ServiceImpl<VodDictMapper, VodDictDO> im
signatureVO.setSign(sign);
} catch (Exception ex) {
ex.printStackTrace();
// throw new MyException(ResultEnum.UNKNOWN_ERROR);
}
return signatureVO;
}
public IPage<GetContendVodsVO> getContendVods(GetContendVodsDTO getContendVodsDTO) {
Page pager = new Page(getContendVodsDTO.getPageNum(), getContendVodsDTO.getPageSize());
return this.baseMapper.getContendVods(pager,getContendVodsDTO.getVodName(),getContendVodsDTO.getContentId());
return this.baseMapper.getContendVods(pager, getContendVodsDTO.getVodName(), getContendVodsDTO.getContentId());
}
@Async
public String deleteVod(VodDictDO vodDictDO) {
VodDictDO vodDictDO1 = this.baseMapper.selectById(vodDictDO.getId());
this.baseMapper.deleteById(vodDictDO.getId());
try{
try {
//删除原视频
Credential cred = new Credential(vodConfig.getSecretId(), vodConfig.getSecretKey());
......@@ -94,13 +89,11 @@ public class VodDictServiceImpl extends ServiceImpl<VodDictMapper, VodDictDO> im
// 返回的resp是一个DeleteMediaResponse的实例,与请求对象对应
client.DeleteMedia(req);
} catch (TencentCloudSDKException e) {
System.out.println(e.toString());
}
return ConstantUtils.DELETE_SUCCESS;
}
@Async
public String addVod(VodDictDO vodDictDO) {
this.baseMapper.insert(vodDictDO);
//上传后直接转码
......@@ -124,9 +117,8 @@ public class VodDictServiceImpl extends ServiceImpl<VodDictMapper, VodDictDO> im
processMediaRequest.setMediaProcessTask(mediaProcessTaskInput1);
processMediaRequest.setFileId(vodDictDO.getVodCode());
ProcessMediaResponse processMediaResponse = null;
try {
processMediaResponse = client.ProcessMedia(processMediaRequest);
client.ProcessMedia(processMediaRequest);
} catch (Exception ex) {
throw new HttpException(50001);
}
......@@ -134,12 +126,10 @@ public class VodDictServiceImpl extends ServiceImpl<VodDictMapper, VodDictDO> im
return ConstantUtils.ADD_SUCCESS;
}
@Async
public String updateVod(VodDictDO vodDictDO) {
this.baseMapper.updateById(vodDictDO);
return ConstantUtils.SET_SUCCESS;
}
}
......@@ -14,4 +14,6 @@ public class ExcelFormatUtils {
public static final List<String> answersList = Arrays.asList("序号", "提问", "答疑", "提问时间", "提问成员", "答疑时间");
public static final List<String> studyLogList = Arrays.asList("开始时间","结束时间","操作对象","类型","平台","学习时长","有效时长");
}
......@@ -157,7 +157,6 @@ public class MathUtil {
}
return timeStr;
}
public static String unitFormat(int i) {
String retStr = null;
if (i >= 0 && i < 10) {
......
package com.subsidy.util.excel;
import com.subsidy.model.MemberDO;
import com.subsidy.vo.administer.ExerciseTestVO;
import com.subsidy.vo.administer.MemberStudyLogVO;
import com.subsidy.vo.classdict.ClassDetailVO;
import com.subsidy.vo.member.ClassSignVO;
import com.subsidy.vo.sign.AnswerRecordVO;
......@@ -188,79 +190,51 @@ public class ExcelUtil {
return dataList;
}
/**
* 导出excel文件
*
* @param list
* @param cls
* @param <T>
*/
public static <T> void writeExcel(List<T> list, Class cls) {
public static <T> void writeExcel(List<Long> memberIds, HashMap<Long, HashMap<String, Integer>> hashMap, List<String> dates) {
ServletRequestAttributes servletRequestAttributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
HttpServletResponse response = servletRequestAttributes.getResponse();
Field[] fields = cls.getDeclaredFields();
List<Field> fieldList = Arrays.stream(fields).filter(field -> {
ExcelColumn annotation = field.getAnnotation(ExcelColumn.class);
if (annotation != null) {
field.setAccessible(true);
return true;
}
return false;
}).sorted(Comparator.comparing(field -> {
int col = 0;
ExcelColumn annotation = field.getAnnotation(ExcelColumn.class);
if (annotation != null) {
col = annotation.col();
}
return col;
})).collect(Collectors.toList());
Workbook wb = new XSSFWorkbook();
Sheet sheet = wb.createSheet();
AtomicInteger ai = new AtomicInteger();
{
Row row = sheet.createRow(ai.getAndIncrement());
AtomicInteger at = new AtomicInteger();
fieldList.forEach(field -> {
ExcelColumn annotation = field.getAnnotation(ExcelColumn.class);
String columnName = "";
if (annotation != null) {
columnName = annotation.value();
}
Cell cell = row.createCell(at.getAndIncrement());
Row row = sheet.createRow(ai.getAndIncrement());
AtomicInteger at = new AtomicInteger();
dates.forEach(field -> {
Cell cell = row.createCell(at.getAndIncrement());
CellStyle cellStyle = wb.createCellStyle();
cellStyle.setFillForegroundColor(IndexedColors.PALE_BLUE.getIndex());
Font font = wb.createFont();
font.setBoldweight(Font.BOLDWEIGHT_BOLD);
cellStyle.setFont(font);
cell.setCellStyle(cellStyle);
cell.setCellValue(field);
});
if (hashMap != null) {
memberIds.forEach(data -> {
Row r = sheet.createRow(ai.getAndIncrement());
AtomicInteger a = new AtomicInteger();
Cell cell = r.createCell(at.getAndIncrement());
CellStyle cellStyle = wb.createCellStyle();
cellStyle.setFillForegroundColor(IndexedColors.PALE_BLUE.getIndex());
Font font = wb.createFont();
font.setBoldweight(Font.BOLDWEIGHT_BOLD);
cellStyle.setFont(font);
cell.setCellStyle(cellStyle);
cell.setCellValue(columnName);
});
if (list != null) {
list.forEach(data -> {
Row r = sheet.createRow(ai.getAndIncrement());
AtomicInteger a = new AtomicInteger();
fieldList.forEach(field -> {
try {
Class<?> type = field.getType();
Object value = field.get(data);
Cell cell = r.createCell(a.getAndIncrement());
if (value != null) {
cell.setCellValue(value.toString());
}
} catch (IllegalAccessException e) {
e.printStackTrace();
}
});
HashMap<String, Integer> hashMap1 = hashMap.get(data);
dates.forEach(field -> {
System.out.println(data + "========");
System.out.println(field);
Cell cell1 = r.createCell(a.getAndIncrement());
if (null != hashMap1) {
cell1.setCellValue(null == hashMap1.get(field) ? 0 : hashMap1.get(field));
} else {
cell1.setCellValue(0);
}
});
for (int i = 0; i < list.size(); i++) {
sheet.autoSizeColumn(i);
}
}
String fileName = String.valueOf(new Date().getTime());
buildExcelDocument(fileName + "." + EXCEL2007, wb, response);
});
}
String fileName = String.valueOf(new Date().getTime());
buildExcelDocument(fileName + "." + EXCEL2007, wb, response);
}
public static <T> void writeMemberExcel(String companyName, String studyDate, String courseName, String title, List<ClassDetailVO> list, List<String> headerList) throws Exception {
......@@ -885,7 +859,7 @@ public class ExcelUtil {
newCell = dataRow.createCell(5);
newCell.setCellStyle(cellStyle);
if (exerciseTestVO.getScore() != 0) {
newCell.setCellValue(1);
newCell.setCellValue(exerciseTestVO.getCount());
} else {
newCell.setCellValue(0);
}
......@@ -1119,6 +1093,174 @@ public class ExcelUtil {
}
}
public static <T> void writeMemberStudyLog(MemberDO memberDO, String title, List<MemberStudyLogVO> list, List<String> headerList) throws Exception {
ServletRequestAttributes requestAttributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
HttpServletResponse response = requestAttributes.getResponse();
response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
response.addHeader("content-disposition", "attachment;filename="
+ java.net.URLEncoder.encode("studyLog.xlsx", "utf-8"));
// 声明一个工作薄
SXSSFWorkbook workbook = new SXSSFWorkbook(1000);//缓存
workbook.setCompressTempFiles(true);
//表头样式
CellStyle titleStyle = workbook.createCellStyle();
titleStyle.setBorderBottom(HSSFCellStyle.BORDER_THIN); //下边框
titleStyle.setBorderLeft(HSSFCellStyle.BORDER_THIN);//左边框
titleStyle.setBorderTop(HSSFCellStyle.BORDER_THIN);//上边框
titleStyle.setBorderRight(HSSFCellStyle.BORDER_THIN);//右边框
titleStyle.setAlignment(HSSFCellStyle.ALIGN_CENTER);
Font titleFont = workbook.createFont();
titleFont.setFontHeightInPoints((short) 20);
titleFont.setBoldweight((short) 700);
titleStyle.setFont(titleFont);
//第二行
CellStyle secondStyle = workbook.createCellStyle();
secondStyle.setBorderBottom(HSSFCellStyle.BORDER_THIN); //下边框
secondStyle.setBorderLeft(HSSFCellStyle.BORDER_THIN);//左边框
secondStyle.setBorderTop(HSSFCellStyle.BORDER_THIN);//上边框
secondStyle.setBorderRight(HSSFCellStyle.BORDER_THIN);//右边框
secondStyle.setAlignment(HSSFCellStyle.ALIGN_CENTER);
Font secondFont = workbook.createFont();
secondStyle.setFont(secondFont);
secondFont.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);//粗体显示
// 列头样式
CellStyle headerStyle = workbook.createCellStyle();
setStyle(headerStyle);
Font headerFont = workbook.createFont();
headerFont.setFontHeightInPoints((short) 12);
headerStyle.setFont(headerFont);
// 数据单元格样式
CellStyle cellStyle = workbook.createCellStyle();
setStyle(cellStyle);
Font cellFont = workbook.createFont();
cellFont.setBoldweight(HSSFFont.BOLDWEIGHT_NORMAL);
cellStyle.setFont(cellFont);
// 生成一个(带标题)表格
SXSSFSheet sheet = workbook.createSheet();
//设置列宽
int minBytes = 17;//至少字节数
int[] arrColWidth = new int[headerList.size()];
// 产生表格标题行,以及设置列宽
String[] headers = new String[headerList.size()];
int ii = 0;
for (int i = 0; i < headerList.size(); i++) {
headers[ii] = headerList.get(i);
int bytes = headerList.get(i).getBytes().length;
arrColWidth[ii] = bytes < minBytes ? minBytes : bytes;
sheet.setColumnWidth(ii, arrColWidth[ii] * 256);
ii++;
}
//第二行
int[] secondWidth = new int[7];
// 产生表格标题行,以及设置列宽
String[] secondHead = new String[7];
List<String> secondList = Arrays.asList("学员姓名", memberDO.getUserName(), "性别:" + memberDO.getGender(), "身份证号", memberDO.getIdCard(), "手机号", memberDO.getTelephone());
ii = 0;
for (int i = 0; i < 7; i++) {
secondHead[ii] = secondList.get(i);
int bytes = secondList.get(i).getBytes().length;
secondWidth[ii] = bytes < minBytes ? minBytes : bytes;
sheet.setColumnWidth(ii, secondWidth[ii] * 256);
ii++;
}
// 遍历集合数据,产生数据行
//标题 0
SXSSFRow titleRow = sheet.createRow(0);//表头 rowIndex=0
titleRow.createCell(0).setCellValue(title);
setBorderStyle(HSSFCellStyle.BORDER_THIN, new CellRangeAddress(0, 0, 0, 0), sheet, workbook); //给合并过的单元格加边框
titleRow.getCell(0).setCellStyle(titleStyle);
sheet.addMergedRegion(new CellRangeAddress(0, 0, 0, headerList.size() - 1));
////第二行 1
SXSSFRow secondRow = sheet.createRow(1); //第二行 rowIndex =1
//CellRangeAddress cellRangeAddress21 = new CellRangeAddress(1, 1, 0, 4);
//sheet.addMergedRegion(cellRangeAddress21);
//setBorderStyle(HSSFCellStyle.BORDER_THIN, cellRangeAddress21, sheet, workbook); //给合并过的单元格加边框
//
//CellRangeAddress cellRangeAddress22 = new CellRangeAddress(1, 1, 5, 10);
//sheet.addMergedRegion(cellRangeAddress22);
//setBorderStyle(HSSFCellStyle.BORDER_THIN, cellRangeAddress22, sheet, workbook); //给合并过的单元格加边框
//
for (int j = 0; j < secondList.size(); j++) {
Cell cell = secondRow.createCell(j);
cell.setCellStyle(secondStyle);
cell.setCellValue(secondList.get(j));
}
//标题 3
SXSSFRow headerRow = sheet.createRow(2); //列头 rowIndex =1
for (int i = 0; i < headers.length; i++) {
headerRow.createCell(i).setCellValue(headers[i]);
headerRow.getCell(i).setCellStyle(headerStyle);
}
//内容
int rowIndex = 0;
for (MemberStudyLogVO memberStudyLogVO : list) {
if (rowIndex == 65535 || rowIndex == 0) {
if (rowIndex != 0) {
sheet = workbook.createSheet();//如果数据超过了,则在第二页显示
}
rowIndex = 3;//数据内容从 rowIndex=2开始
}
SXSSFRow dataRow = sheet.createRow(rowIndex);
SXSSFCell newCell = dataRow.createCell(0);
newCell.setCellStyle(cellStyle);
newCell.setCellValue(memberStudyLogVO.getStartDate());
newCell = dataRow.createCell(1);
newCell.setCellStyle(cellStyle);
newCell.setCellValue(memberStudyLogVO.getEndDate());
newCell = dataRow.createCell(2);
newCell.setCellStyle(cellStyle);
newCell.setCellValue(memberStudyLogVO.getVodName());
newCell = dataRow.createCell(3);
newCell.setCellStyle(cellStyle);
newCell.setCellValue(memberStudyLogVO.getStudyType());
newCell = dataRow.createCell(4);
newCell.setCellStyle(cellStyle);
newCell.setCellValue(memberStudyLogVO.getPlatForm());
newCell = dataRow.createCell(5);
newCell.setCellStyle(cellStyle);
newCell.setCellValue(memberStudyLogVO.getPlayLength());
newCell = dataRow.createCell(6);
newCell.setCellStyle(cellStyle);
newCell.setCellValue(memberStudyLogVO.getTotalLength());
rowIndex++;
}
try {
OutputStream outputStream = response.getOutputStream();
workbook.write(outputStream);
workbook.close();
workbook.dispose();
} catch (IOException e) {
e.printStackTrace();
}
}
private static void setStyle(CellStyle cellStyle) {
// 水平居中
cellStyle.setAlignment(CellStyle.ALIGN_CENTER);
......
package com.subsidy.vo.administer;
import lombok.Data;
@Data
public class MemberStudyLogVO {
private String startDate;
private String endDate;
private String vodName;
private String studyType;
private String platForm;
private String playLength;
private String totalLength;
}
package com.subsidy.vo.member;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.subsidy.model.VodDictDO;
import lombok.Data;
import java.util.List;
......@@ -10,54 +7,9 @@ import java.util.List;
@Data
public class ContentVodNewVO {
private Integer playRecord;
private Long id;
/**
* 目录id
*/
private Long contentId;
/**
* 视频名称
*/
private String vodName;
/**
* 视频时长
*/
private Integer vodLength;
/**
* 视频格式
*/
private String vodType;
/**
* 视频大小
*/
private String vodSize;
/**
* 视频地址
*/
private String vodUrl;
/**
* 视频编码
*/
private String vodCode;
/**
* 讲师名称
*/
private String teacherName;
/**
* 封面
*/
private String coverPage;
private Integer playRecord;
private List<ContentVodVO> contentVodVOS;
......
......@@ -7,7 +7,7 @@ public class DayInfoItemVO {
private String studyDate;
private Long totalLength;
private Integer totalLength;
private Integer distinctLength;
......
......@@ -9,7 +9,7 @@ public class GetMemberStudyInfoVO {
private String studyDate;
private Long playLength;
private Integer playLength;
private Integer distinctLength;
......
# 环境配置
spring.profiles.active=dev
# 端口号
spring.server.port=23457
spring.server.port=23454
#嵌入tomcat配置
#和CPU数
spring.server.acceptorThreadCount=600
......
......@@ -53,6 +53,7 @@
left join member t2 on t.member_id = t2.id
WHERE
t.delete_date IS NULL
and t2.delete_date is null
AND t.class_id = #{classId}
<if test="userName !=null and userName !=''">
and t2.user_name like concat('%',#{userName} ,'%')
......
......@@ -43,4 +43,42 @@
and t2.id is not null
</select>
<select id="contentVodProcess" resultType="com.subsidy.vo.member.MemberVodVO">
SELECT
t3.id,
t2.play_record,
t3.vod_length,
t3.vod_name,
t3.vod_url,
floor( t2.play_record * 100 / t3.vod_length ) AS percent,
IF
( t2.play_record >= t3.vod_length * 0.8, 'true', 'false' ) AS STATUS
FROM
vod_play_history t2
LEFT JOIN vod_dict t3 ON t2.vod_id = t3.id
WHERE
t2.vod_id IN ( SELECT id FROM vod_dict t WHERE t.content_id = #{contentId} )
AND t2.member_id = #{memberId}
</select>
<select id="contentFiles" parameterType="long" resultType="com.subsidy.model.FileDictDO">
SELECT
t2.id,
t2.file_name,
t2.file_size,
t2.file_type,
t2.file_url
FROM
course_content t
LEFT JOIN file_dict t2 ON t.id = t2.content_id
WHERE
t.delete_date IS NULL
AND t2.delete_date IS NULL
AND t2.id IS NOT NULL
AND t.course_id = #{courseId}
ORDER BY
t.order_no,
t2.order_no
</select>
</mapper>
......@@ -84,7 +84,8 @@
exercise_done_result t
left join paper_dict t2 on t.paper_id = t2.id
WHERE
t.member_id = #{memberId}
t.delete_date is null
and t.member_id = #{memberId}
AND t.class_id = #{classId}
GROUP BY
t.class_id,
......
......@@ -76,7 +76,13 @@
<select id="getMembers" resultType="com.subsidy.vo.member.GetAllVO">
SELECT
t2.*
t2.id,
t2.user_name,
t2.account_name,
t2.telephone,
t2.gender,
t2.id_card,
t2.status
FROM
member_department_mapping t
LEFT JOIN member t2 ON t.member_id = t2.id
......
......@@ -37,6 +37,7 @@
WHERE
t.delete_date IS NULL
AND t2.delete_date IS NULL
and t3.delete_date is null
and t3.id = #{id}
<if test="courseName != null and courseName !=''">
AND t.course_name like concat('%',#{courseName} ,'%')
......
......@@ -27,7 +27,15 @@
<select id="getContendVods" resultType="com.subsidy.vo.vod.GetContendVodsVO">
SELECT
t.*,
t.id,
t.content_id,
t.vod_name,
t.vod_length,
t.vod_type,
t.vod_size,
t.vod_url,
t.teacher_name,
t.cover_page,
t2.content
FROM
vod_dict t
......
......@@ -103,7 +103,7 @@
<select id="memberDailyStudyLength" parameterType="long" resultType="integer">
SELECT
ifnull( sum( t.play_length ), 0 )
ifnull( sum( t.play_length ), 0 )
FROM
vod_play_history t
WHERE
......@@ -115,7 +115,7 @@
<select id="completeVodOrNot" resultType="integer">
SELECT
IF
( max( t.play_record ) > t2.vod_length*0.8, 1, 0 ) AS count
( max( t.play_record ) >= t2.vod_length*0.8, 1, 0 ) AS count
FROM
vod_play_history t
LEFT JOIN vod_dict t2 ON t.vod_id = t2.id
......@@ -125,4 +125,165 @@
t.member_id = #{memberId}
AND t.vod_id = #{vodId}
</select>
<select id="classStudyHistory" parameterType="long" resultType="com.subsidy.vo.sign.ClassSignInfoVO">
SELECT
mem_cnt AS memberCount,
floor( t2.ttl / mem_cnt ) AS studyVodCounts,
t3.total_vods AS totalVodCounts,
avg_playlength AS avgVodPlayLength,
floor( t4.pass_cnt * 100 / mem_cnt ) AS passRate,
t5.ask_cnt AS answerCount
FROM
(
SELECT
t.class_id,
count(
DISTINCT ( t.member_id )) AS mem_cnt,
round( sum( t.play_length )/ count( DISTINCT ( t.member_id )), 0 ) AS avg_playlength
FROM
vod_play_history t
WHERE
t.delete_date IS NULL
AND t.class_id = 17
) t
LEFT JOIN (
SELECT
t3.class_id,
sum( t3.cnt ) AS ttl
FROM
(
SELECT
t.class_id,
t.member_id,
t.vod_id,
IF
( max( t.play_length )>= t2.vod_length * 0.8, 1, 0 ) AS cnt
FROM
vod_play_history t
LEFT JOIN vod_dict t2 ON t.vod_id = t2.id
WHERE
t.class_id = #{classId}
AND t.delete_date IS NULL
GROUP BY
t.class_id,
t.member_id,
t.vod_id
) t3
) t2 ON t.class_id = t2.class_id
LEFT JOIN (
SELECT
t.id,
count( 1 ) AS total_vods
FROM
class_dict t
LEFT JOIN course_content t2 ON t.course_id = t2.course_id
LEFT JOIN vod_dict t3 ON t2.id = t3.content_id
WHERE
t.delete_date IS NULL
AND t2.delete_date IS NULL
AND t3.delete_date IS NULL
AND t.id = #{classId}
) t3 ON t.class_id = t3.id
LEFT JOIN (
SELECT
t2.class_id,
sum(
IF
( t2.cnt >= t4.paper_cnt, 1, 0 )) AS pass_cnt
FROM
(
SELECT
t2.class_id,
t2.member_id,
sum( t2.cnt ) AS cnt
FROM
(
SELECT
t.paper_id,
t.class_id,
t.member_id,
IF
( max( t.score )>= 60, 1, 0 ) AS cnt
FROM
exercise_done_result t
WHERE
t.class_id = #{classId}
AND t.delete_date IS NULL
GROUP BY
t.paper_id,
t.class_id,
t.member_id
) t2
GROUP BY
t2.class_id,
t2.member_id
) t2
LEFT JOIN class_dict t3 ON t2.class_id = t3.id
LEFT JOIN ( SELECT t.course_id, count( 1 ) AS paper_cnt FROM paper_dict t WHERE t.delete_date IS NULL GROUP BY t.course_id ) t4 ON t3.course_id = t4.course_id
) t4 ON t.class_id = t4.class_id
LEFT JOIN ( SELECT t.class_id, sum( 1 ) AS ask_cnt FROM answering_question t WHERE t.class_id = #{classId} AND t.delete_date IS NULL ) t5 ON t.class_id = t5.class_id
</select>
<select id="memberRecentPlay" resultType="com.subsidy.vo.member.ContentVodNewVO">
SELECT
t2.id,
t1.play_record
FROM
(
SELECT
t.vod_id,
max( t.create_date ) AS create_date,
t.play_record
FROM
vod_play_history t
WHERE
t.member_id = 1
AND t.class_id = 3
) t1
LEFT JOIN vod_dict t2 ON t1.vod_id = t2.id
</select>
<select id="memberStudyLog" resultType="com.subsidy.vo.administer.MemberStudyLogVO">
SELECT
DATE_SUB( t1.create_date, INTERVAL t1.play_length SECOND ) AS startDate,
t1.create_date AS endDate,
t1.vod_name,
'视频学习' AS studyType,
'有课互联系统' as platForm,
t1.play_length,
IF
( t2.total_length &lt;= t1.vod_length, t2.total_length, t1.vod_length ) AS total_length
FROM
(
SELECT
t.vod_id,
t.create_date,
t2.vod_name,
t.play_length,
t2.vod_length
FROM
vod_play_history t
LEFT JOIN vod_dict t2 ON t.vod_id = t2.id
WHERE
t.class_id = #{classId}
AND t.member_id = #{memberId}
) t1
LEFT JOIN (
SELECT
t.vod_id,
sum( t.play_length ) AS total_length
FROM
vod_play_history t
LEFT JOIN vod_dict t2 ON t.vod_id = t2.id
WHERE
t.class_id = #{classId}
AND t.member_id = #{memberId}
GROUP BY
t.vod_id
) t2 ON t1.vod_id = t2.vod_id
ORDER BY
t1.create_date DESC
</select>
</mapper>
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!