diff --git a/src/main/java/com/subsidy/common/RedisPrefixConstant.java b/src/main/java/com/subsidy/common/RedisPrefixConstant.java index f06de0e..99e0397 100644 --- a/src/main/java/com/subsidy/common/RedisPrefixConstant.java +++ b/src/main/java/com/subsidy/common/RedisPrefixConstant.java @@ -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_"; diff --git a/src/main/java/com/subsidy/controller/AdministerController.java b/src/main/java/com/subsidy/controller/AdministerController.java index 72ccd40..f957668 100644 --- a/src/main/java/com/subsidy/controller/AdministerController.java +++ b/src/main/java/com/subsidy/controller/AdministerController.java @@ -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){ diff --git a/src/main/java/com/subsidy/controller/ClassHourDictController.java b/src/main/java/com/subsidy/controller/ClassHourDictController.java index c3052a6..4a19aad 100644 --- a/src/main/java/com/subsidy/controller/ClassHourDictController.java +++ b/src/main/java/com/subsidy/controller/ClassHourDictController.java @@ -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)); } diff --git a/src/main/java/com/subsidy/controller/MemberController.java b/src/main/java/com/subsidy/controller/MemberController.java index d2e1bcf..e8b0f16 100644 --- a/src/main/java/com/subsidy/controller/MemberController.java +++ b/src/main/java/com/subsidy/controller/MemberController.java @@ -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)); } diff --git a/src/main/java/com/subsidy/controller/OprAdmDictController.java b/src/main/java/com/subsidy/controller/OprAdmDictController.java index 7dc33eb..69c05dc 100644 --- a/src/main/java/com/subsidy/controller/OprAdmDictController.java +++ b/src/main/java/com/subsidy/controller/OprAdmDictController.java @@ -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)); } diff --git a/src/main/java/com/subsidy/controller/OprMemDictController.java b/src/main/java/com/subsidy/controller/OprMemDictController.java index ab16191..45aa443 100644 --- a/src/main/java/com/subsidy/controller/OprMemDictController.java +++ b/src/main/java/com/subsidy/controller/OprMemDictController.java @@ -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)); } diff --git a/src/main/java/com/subsidy/controller/SignInRecordController.java b/src/main/java/com/subsidy/controller/SignInRecordController.java index fede451..98c2210 100644 --- a/src/main/java/com/subsidy/controller/SignInRecordController.java +++ b/src/main/java/com/subsidy/controller/SignInRecordController.java @@ -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)); } diff --git a/src/main/java/com/subsidy/controller/SmsVerifyCodeController.java b/src/main/java/com/subsidy/controller/SmsVerifyCodeController.java index 48f89f6..5e6d472 100644 --- a/src/main/java/com/subsidy/controller/SmsVerifyCodeController.java +++ b/src/main/java/com/subsidy/controller/SmsVerifyCodeController.java @@ -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); diff --git a/src/main/java/com/subsidy/controller/VodDictController.java b/src/main/java/com/subsidy/controller/VodDictController.java index 71f7d76..33d42e1 100644 --- a/src/main/java/com/subsidy/controller/VodDictController.java +++ b/src/main/java/com/subsidy/controller/VodDictController.java @@ -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)); } - } diff --git a/src/main/java/com/subsidy/controller/VodPlayHistoryController.java b/src/main/java/com/subsidy/controller/VodPlayHistoryController.java index 78b8de1..c6118c6 100644 --- a/src/main/java/com/subsidy/controller/VodPlayHistoryController.java +++ b/src/main/java/com/subsidy/controller/VodPlayHistoryController.java @@ -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)); diff --git a/src/main/java/com/subsidy/dto/administer/MemberStudyLogDTO.java b/src/main/java/com/subsidy/dto/administer/MemberStudyLogDTO.java new file mode 100644 index 0000000..9f169d6 --- /dev/null +++ b/src/main/java/com/subsidy/dto/administer/MemberStudyLogDTO.java @@ -0,0 +1,12 @@ +package com.subsidy.dto.administer; + +import lombok.Data; + +@Data +public class MemberStudyLogDTO { + + private Long memberId; + + private Long classId; + +} diff --git a/src/main/java/com/subsidy/mapper/CourseContentMapper.java b/src/main/java/com/subsidy/mapper/CourseContentMapper.java index 0a1ac29..c8115fc 100644 --- a/src/main/java/com/subsidy/mapper/CourseContentMapper.java +++ b/src/main/java/com/subsidy/mapper/CourseContentMapper.java @@ -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 { */ List getCourseVods(Integer courseId); + /** + * 查看某个目录下 某个成员看视频的进度 + */ + List contentVodProcess(Long contentId, Long memberId); + + /** + * 查看某个课程下的文件/课件 + */ + List contentFiles(Long courseId); + } diff --git a/src/main/java/com/subsidy/mapper/VodPlayHistoryMapper.java b/src/main/java/com/subsidy/mapper/VodPlayHistoryMapper.java index c3fa7ce..9a1d023 100644 --- a/src/main/java/com/subsidy/mapper/VodPlayHistoryMapper.java +++ b/src/main/java/com/subsidy/mapper/VodPlayHistoryMapper.java @@ -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 { /** * 查看某成员的学习历史 */ - IPage studyHistory(IPage iPage,Long memberId); + IPage studyHistory(IPage iPage, Long memberId); /** * 从成员,日期的维度查看学生学习时长 */ - List getMemberStudyInfo(Long classId,List memberIds,String startDate,String endDate); + List getMemberStudyInfo(Long classId, List memberIds, String startDate, String endDate); /** * 缩量记录 @@ -45,5 +48,24 @@ public interface VodPlayHistoryMapper extends BaseMapper { /** * 查看学生是否完成了某个视频 */ - int completeVodOrNot(Long memberId,Long vodId); + int completeVodOrNot(Long memberId, Long vodId); + + /** + * 查看某个班级的学习记录 + */ + ClassSignInfoVO classStudyHistory(Long classId); + + /** + * 查看这个课程某个成员看的视频课程 + */ + ContentVodNewVO memberRecentPlay(Long classId, Long memberId); + + + /** + * 查看某个成员某个课程的学习日志 + */ + List memberStudyLog(Long classId, Long memberId); + + + } diff --git a/src/main/java/com/subsidy/service/AdministerService.java b/src/main/java/com/subsidy/service/AdministerService.java index 8215403..6ec160f 100644 --- a/src/main/java/com/subsidy/service/AdministerService.java +++ b/src/main/java/com/subsidy/service/AdministerService.java @@ -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 { IPage 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); } diff --git a/src/main/java/com/subsidy/service/MemberService.java b/src/main/java/com/subsidy/service/MemberService.java index 928d371..39db22a 100644 --- a/src/main/java/com/subsidy/service/MemberService.java +++ b/src/main/java/com/subsidy/service/MemberService.java @@ -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; diff --git a/src/main/java/com/subsidy/service/impl/AdministerServiceImpl.java b/src/main/java/com/subsidy/service/impl/AdministerServiceImpl.java index 7bb8a85..1ed4138 100644 --- a/src/main/java/com/subsidy/service/impl/AdministerServiceImpl.java +++ b/src/main/java/com/subsidy/service/impl/AdministerServiceImpl.java @@ -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 title = new ArrayList<>(); + title.add("姓名"); + title.addAll(findDaysStr(classDailyInfoDTO.getStartDate(), classDailyInfoDTO.getEndDate())); + + //获取班级成员 + IPage classDailyInfoVOIPage = classMemberMappingMapper.getClassMembersWithName(pager, classDailyInfoDTO.getClassId(), classDailyInfoDTO.getUserName()); + //整理出这些学员id + List classDailyInfoVOS = classDailyInfoVOIPage.getRecords(); + List memberIds = new ArrayList<>(); + for (ClassDailyInfoVO classDailyInfoVO : classDailyInfoVOS) { + memberIds.add(classDailyInfoVO.getId()); + } + + //这些成员完成情况 + List getMemberStudyInfoVOS = vodPlayHistoryMapper.getMemberStudyInfo(classDailyInfoDTO.getClassId(), memberIds, classDailyInfoDTO.getStartDate(), classDailyInfoDTO.getEndDate()); + + HashMap> hashMap = new HashMap(); + + for (GetMemberStudyInfoVO getMemberStudyInfoVO : getMemberStudyInfoVOS) { + + if (!hashMap.containsKey(getMemberStudyInfoVO.getMemberId())) { + HashMap hashMap1 = new HashMap<>(); + hashMap1.put(getMemberStudyInfoVO.getStudyDate(), getMemberStudyInfoVO.getPlayLength()); + hashMap.put(getMemberStudyInfoVO.getMemberId(), hashMap1); + } else { + HashMap hashMap1 = hashMap.get(getMemberStudyInfoVO.getMemberId()); + hashMap1.put(getMemberStudyInfoVO.getStudyDate(), getMemberStudyInfoVO.getPlayLength()); + hashMap.put(getMemberStudyInfoVO.getMemberId(), hashMap1); + } + } + + writeExcel(memberIds, hashMap, title); + + + } + + /** + * 导出excel文件 + */ + public void writeExcel(List memberIds, HashMap> hashMap, List 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 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 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 daysStrList = new ArrayList(); + 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 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 future1 = newCachedThreadPool.submit(() -> ///该学生完成了多少个 学生成绩,学生进度 - pollingGetTask1(memberDO.getCompanyId())).get(); - - //查看系统设定的时长 - classHourDictDO = future1.get(); - Future 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 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 pollingGetTask2(Long memberId) { - return new AsyncResult<>(vodPlayHistoryMapper.memberDailyStudyLength(memberId)); - } - } diff --git a/src/main/java/com/subsidy/service/impl/MemberServiceImpl.java b/src/main/java/com/subsidy/service/impl/MemberServiceImpl.java index 7db9e59..123bd09 100644 --- a/src/main/java/com/subsidy/service/impl/MemberServiceImpl.java +++ b/src/main/java/com/subsidy/service/impl/MemberServiceImpl.java @@ -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 imple private VodPlayHistoryMapper vodPlayHistoryMapper; @Autowired - private VodDictMapper vodDictMapper; - - @Autowired private FileDictMapper fileDictMapper; @Autowired @@ -99,6 +95,8 @@ public class MemberServiceImpl extends ServiceImpl imple @Autowired private ClassDictMapper classDictMapper; + @Autowired + private CompanyDictMapper companyDictMapper; @Autowired private MemberDepartmentMappingMapper memberDepartmentMappingMapper; @@ -120,33 +118,13 @@ public class MemberServiceImpl extends ServiceImpl imple public String deleteMember(MemberDO memberDO) { - final ExecutorService newCachedThreadPool = Executors.newCachedThreadPool(); - - //多个任务 - newCachedThreadPool.execute(() -> ///该学生完成了多少个 学生成绩,学生进度 - this.baseMapper.deleteById(memberDO.getId())); - newCachedThreadPool.execute(() -> //答疑 - classMemberMappingMapper.delete(new QueryWrapper() - .lambda() - .eq(ClassMemberMappingDO::getMemberId, memberDO.getId()))); - newCachedThreadPool.execute(() -> //签到 - memberDepartmentMappingMapper.delete(new QueryWrapper() - .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() + .lambda() + .eq(ClassMemberMappingDO::getMemberId, memberDO.getId())); + memberDepartmentMappingMapper.delete(new QueryWrapper() + .lambda() + .eq(MemberDepartmentMappingDO::getMemberId, memberDO.getId())); return ConstantUtils.DELETE_SUCCESS; } @@ -160,9 +138,6 @@ public class MemberServiceImpl extends ServiceImpl imple throw new HttpException(20002); } - //部门 - List longs = addMemberDTO.getDepartmentIds(); - Integer count1 = this.baseMapper.selectCount(new QueryWrapper() .lambda() .eq(MemberDO::getAccountName, addMemberDTO.getAccountName()) @@ -172,7 +147,6 @@ public class MemberServiceImpl extends ServiceImpl 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 imple //公司赋值 memberDO.setCompanyId(addMemberDTO.getCompanyId()); this.baseMapper.insert(memberDO); + redisUtil.set(RedisPrefixConstant.SUBSIDY_COMPANY_MEMBER_PREFIX + memberDO.getCompanyId() + memberDO.getAccountName(), memberDO); + //部门 + List longs = addMemberDTO.getDepartmentIds(); for (Long lg : longs) { MemberDepartmentMappingDO memberDepartmentMappingDO = new MemberDepartmentMappingDO(); @@ -195,29 +172,29 @@ public class MemberServiceImpl extends ServiceImpl imple public String updateMember(AddMemberDTO addMemberDTO) { - if (null != addMemberDTO.getDepartmentIds()) { - Integer count = this.baseMapper.selectCount(new QueryWrapper() - .lambda() - .eq(MemberDO::getTelephone, addMemberDTO.getTelephone()) - .ne(MemberDO::getId, addMemberDTO.getId())); + Integer count = this.baseMapper.selectCount(new QueryWrapper() + .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() - .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() + .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() @@ -237,7 +214,6 @@ public class MemberServiceImpl extends ServiceImpl 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 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 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() - // .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 imple studyPageVO.setTotalVods(vodDictDOS.size()); newCachedThreadPool.submit(() -> studyPageTask1(studyPageVO, vodDictDOS, memberDO.getId())); } - newCachedThreadPool.shutdown(); memberStudyPageVO.setStudyPageVOS(studyPageVOS); - - //List departmentDictDOS = this.baseMapper.getDepartments(memberDO.getId()); - // - //if (departmentDictDOS.size() > 0) { - // CompanyDictDO companyDictDO = companyDictMapper.selectById(departmentDictDOS.get(0).getId()); - // if (null != companyDictDO) { - // BeanUtils.copyProperties(companyDictDO, memberStudyPageVO); - // } - //} return memberStudyPageVO; } @@ -406,12 +364,6 @@ public class MemberServiceImpl extends ServiceImpl imple return new AsyncResult<>(studyPageVO); } - public Future 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 imple for (CourseContentDO courseContentDO : courseContentDOS) { ContentVodVO contentVodVO = new ContentVodVO(); contentVodVO.setContent(courseContentDO.getContent()); - - List memberVodVOS = new ArrayList<>(); - - //目录下的视频 - List vodDictDOS = vodDictMapper.selectList(new QueryWrapper() - .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 vodPlayHistoryDOS = vodPlayHistoryMapper.selectList(new QueryWrapper() - .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 contentVodTask1(MemberVodVO memberVodVO, VodDictDO vodDictDO, Long memberId) { - - List vodPlayHistoryDOS = vodPlayHistoryMapper.selectList(new QueryWrapper() - .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 contentVodTask2(MemberVodVO memberVodVO, VodDictDO vodDictDO, Long memberId) { - - List vodPlayHistoryDOS1 = vodPlayHistoryMapper.selectList(new QueryWrapper() - .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 contentFiles(ContentMemberDTO contentMemberDTO) { List contentFilesVOS = new ArrayList<>(); @@ -563,6 +428,7 @@ public class MemberServiceImpl extends ServiceImpl imple for (QueryPapersVO queryPapersVO : queryPapersVOS) { executorService.execute(() -> getCourseTestTask(queryPapersVO, contentMemberDTO.getMemberId(), classDictDO)); } + executorService.shutdown(); return queryPapersVOS; } diff --git a/src/main/java/com/subsidy/service/impl/SignInRecordServiceImpl.java b/src/main/java/com/subsidy/service/impl/SignInRecordServiceImpl.java index 43b4ea5..3318e44 100644 --- a/src/main/java/com/subsidy/service/impl/SignInRecordServiceImpl.java +++ b/src/main/java/com/subsidy/service/impl/SignInRecordServiceImpl.java @@ -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; /** *

@@ -57,24 +50,12 @@ public class SignInRecordServiceImpl extends ServiceImpl getMemberSignInfo(GetMemberSignInfoDTO getMemberSignInfoDTO) { @@ -88,135 +69,43 @@ public class SignInRecordServiceImpl extends ServiceImpl classDictDOS = classMemberMappingMapper.getMemberClass(signInRecordDO.getMemberId()); - /*this.baseMapper.delete(new QueryWrapper() - .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 classSignInfo(ClassSignInfoDTO classSignInfoDTO) { Page pager = new Page(classSignInfoDTO.getPageNum(), classSignInfoDTO.getPageSize()); IPage classSignInfoVOIPage = this.baseMapper.classSignInfo(pager, classSignInfoDTO.getClassName(), classSignInfoDTO.getCourseName(), classSignInfoDTO.getCompanyId()); List classSignInfoVOS = classSignInfoVOIPage.getRecords(); - for (ClassSignInfoVO classSignInfoVO : classSignInfoVOS) { + final ExecutorService newCachedThreadPool = Executors.newCachedThreadPool(); - //班级人数 - List classMemberMappingDOS = classMemberMappingMapper.selectList(new QueryWrapper() - .lambda() - .eq(ClassMemberMappingDO::getClassId, classSignInfoVO.getClassId())); - - classSignInfoVO.setMemberCount(classMemberMappingDOS.size()); - - //课程总数 - List 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 vodDictDOS, List classMemberMappingDOS, ClassSignInfoVO classSignInfoVO) { - int totalStudyVods = 0; - int totalStudyLength = 0; - //学生总共学习课时数 - for (VodDictDO vodDictDO : vodDictDOS) { - for (ClassMemberMappingDO classMemberMappingDO : classMemberMappingDOS) { - List vodPlayHistoryDOS = vodPlayHistoryMapper.selectList(new QueryWrapper() - .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 classMemberMappingDOS) { - //测试通过率 - List exerciseDoneResultDOS = exerciseDoneResultMapper.selectList(new QueryWrapper() - .lambda() - .eq(ExerciseDoneResultDO::getClassId, classSignInfoVO.getClassId())); - - int passNum = 0; + public Future 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 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() - .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 classHourDictDOS = classHourDictMapper.selectList(null); - // - //for (ClassHourDictDO classHourDictDO : classHourDictDOS) { - // redisUtil.set(RedisPrefixConstant.SUBSIDY_SETTINGS_PREFIX + classHourDictDO.getCompanyId(), classHourDictDO); - //} + //预写公司设置数据 List classHourDictDOS = classHourDictMapper.selectList(null); for (ClassHourDictDO classHourDictDO : classHourDictDOS) { redisUtil.set("subsidySettings_" + classHourDictDO.getCompanyId(), classHourDictDO); } + //预写学生账号数据 //List memberDOS = memberMapper.selectList(null); //for (MemberDO memberDO : memberDOS){ // redisUtil.set(RedisPrefixConstant.SUBSIDY_COMPANY_MEMBER_PREFIX+memberDO.getCompanyId()+"_"+memberDO.getAccountName(),memberDO); //} - } } diff --git a/src/main/java/com/subsidy/service/impl/SmsVerifyCodeServiceImpl.java b/src/main/java/com/subsidy/service/impl/SmsVerifyCodeServiceImpl.java index a3621be..5914543 100644 --- a/src/main/java/com/subsidy/service/impl/SmsVerifyCodeServiceImpl.java +++ b/src/main/java/com/subsidy/service/impl/SmsVerifyCodeServiceImpl.java @@ -38,27 +38,20 @@ public class SmsVerifyCodeServiceImpl extends ServiceImpl() + public void sendVerifyCode(SendVerifyCodeDTO sendVerifyCodeDTO) { + MemberDO memberDO = memberMapper.selectOne(new QueryWrapper() .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); } } diff --git a/src/main/java/com/subsidy/service/impl/VodDictServiceImpl.java b/src/main/java/com/subsidy/service/impl/VodDictServiceImpl.java index 69ba14c..eeb1a3c 100644 --- a/src/main/java/com/subsidy/service/impl/VodDictServiceImpl.java +++ b/src/main/java/com/subsidy/service/impl/VodDictServiceImpl.java @@ -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 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 im signatureVO.setSign(sign); } catch (Exception ex) { ex.printStackTrace(); -// throw new MyException(ResultEnum.UNKNOWN_ERROR); } return signatureVO; } public IPage 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 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 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 im return ConstantUtils.ADD_SUCCESS; } - @Async public String updateVod(VodDictDO vodDictDO) { this.baseMapper.updateById(vodDictDO); return ConstantUtils.SET_SUCCESS; } - } diff --git a/src/main/java/com/subsidy/util/ExcelFormatUtils.java b/src/main/java/com/subsidy/util/ExcelFormatUtils.java index a109629..280e5e9 100644 --- a/src/main/java/com/subsidy/util/ExcelFormatUtils.java +++ b/src/main/java/com/subsidy/util/ExcelFormatUtils.java @@ -14,4 +14,6 @@ public class ExcelFormatUtils { public static final List answersList = Arrays.asList("序号", "提问", "答疑", "提问时间", "提问成员", "答疑时间"); + public static final List studyLogList = Arrays.asList("开始时间","结束时间","操作对象","类型","平台","学习时长","有效时长"); + } diff --git a/src/main/java/com/subsidy/util/MathUtil.java b/src/main/java/com/subsidy/util/MathUtil.java index 580af1a..5d81796 100644 --- a/src/main/java/com/subsidy/util/MathUtil.java +++ b/src/main/java/com/subsidy/util/MathUtil.java @@ -157,7 +157,6 @@ public class MathUtil { } return timeStr; } - public static String unitFormat(int i) { String retStr = null; if (i >= 0 && i < 10) { diff --git a/src/main/java/com/subsidy/util/excel/ExcelUtil.java b/src/main/java/com/subsidy/util/excel/ExcelUtil.java index 729ecbd..bf61a07 100644 --- a/src/main/java/com/subsidy/util/excel/ExcelUtil.java +++ b/src/main/java/com/subsidy/util/excel/ExcelUtil.java @@ -1,6 +1,8 @@ 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 - */ - public static void writeExcel(List list, Class cls) { + public static void writeExcel(List memberIds, HashMap> hashMap, List dates) { ServletRequestAttributes servletRequestAttributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes(); HttpServletResponse response = servletRequestAttributes.getResponse(); - Field[] fields = cls.getDeclaredFields(); - List 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 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 void writeMemberExcel(String companyName, String studyDate, String courseName, String title, List list, List 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 void writeMemberStudyLog(MemberDO memberDO, String title, List list, List 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 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); diff --git a/src/main/java/com/subsidy/vo/administer/MemberStudyLogVO.java b/src/main/java/com/subsidy/vo/administer/MemberStudyLogVO.java new file mode 100644 index 0000000..ae8a621 --- /dev/null +++ b/src/main/java/com/subsidy/vo/administer/MemberStudyLogVO.java @@ -0,0 +1,22 @@ +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; + +} diff --git a/src/main/java/com/subsidy/vo/member/ContentVodNewVO.java b/src/main/java/com/subsidy/vo/member/ContentVodNewVO.java index c4ec7a3..e595f29 100644 --- a/src/main/java/com/subsidy/vo/member/ContentVodNewVO.java +++ b/src/main/java/com/subsidy/vo/member/ContentVodNewVO.java @@ -1,8 +1,5 @@ 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 contentVodVOS; diff --git a/src/main/java/com/subsidy/vo/vod/DayInfoItemVO.java b/src/main/java/com/subsidy/vo/vod/DayInfoItemVO.java index bb4e088..20340e6 100644 --- a/src/main/java/com/subsidy/vo/vod/DayInfoItemVO.java +++ b/src/main/java/com/subsidy/vo/vod/DayInfoItemVO.java @@ -7,7 +7,7 @@ public class DayInfoItemVO { private String studyDate; - private Long totalLength; + private Integer totalLength; private Integer distinctLength; diff --git a/src/main/java/com/subsidy/vo/vod/GetMemberStudyInfoVO.java b/src/main/java/com/subsidy/vo/vod/GetMemberStudyInfoVO.java index 1cfc897..b73ba7d 100644 --- a/src/main/java/com/subsidy/vo/vod/GetMemberStudyInfoVO.java +++ b/src/main/java/com/subsidy/vo/vod/GetMemberStudyInfoVO.java @@ -9,7 +9,7 @@ public class GetMemberStudyInfoVO { private String studyDate; - private Long playLength; + private Integer playLength; private Integer distinctLength; diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 05b49fc..e4f49f3 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -1,7 +1,7 @@ # 环境配置 spring.profiles.active=dev # 端口号 -spring.server.port=23457 +spring.server.port=23454 #嵌入tomcat配置 #和CPU数 spring.server.acceptorThreadCount=600 diff --git a/src/main/resources/mapper/ClassMemberMappingMapper.xml b/src/main/resources/mapper/ClassMemberMappingMapper.xml index ead4ba5..3487154 100644 --- a/src/main/resources/mapper/ClassMemberMappingMapper.xml +++ b/src/main/resources/mapper/ClassMemberMappingMapper.xml @@ -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} and t2.user_name like concat('%',#{userName} ,'%') diff --git a/src/main/resources/mapper/CourseContentMapper.xml b/src/main/resources/mapper/CourseContentMapper.xml index 6ecd4c3..6147558 100644 --- a/src/main/resources/mapper/CourseContentMapper.xml +++ b/src/main/resources/mapper/CourseContentMapper.xml @@ -43,4 +43,42 @@ and t2.id is not null + + + + diff --git a/src/main/resources/mapper/ExerciseDoneResultMapper.xml b/src/main/resources/mapper/ExerciseDoneResultMapper.xml index 22bcf4c..f798a14 100644 --- a/src/main/resources/mapper/ExerciseDoneResultMapper.xml +++ b/src/main/resources/mapper/ExerciseDoneResultMapper.xml @@ -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, diff --git a/src/main/resources/mapper/MemberMapper.xml b/src/main/resources/mapper/MemberMapper.xml index 2554aed..72edbc5 100644 --- a/src/main/resources/mapper/MemberMapper.xml +++ b/src/main/resources/mapper/MemberMapper.xml @@ -76,7 +76,13 @@ 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 diff --git a/src/main/resources/mapper/VodPlayHistoryMapper.xml b/src/main/resources/mapper/VodPlayHistoryMapper.xml index 7d3e6a1..992c0a0 100644 --- a/src/main/resources/mapper/VodPlayHistoryMapper.xml +++ b/src/main/resources/mapper/VodPlayHistoryMapper.xml @@ -103,7 +103,7 @@ 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} + + + + + + +