Commit 2668dc30 by 涂亚平

优化后版本,跑数据脚本

1 parent d5c90365
Showing with 1016 additions and 766 deletions
......@@ -203,6 +203,12 @@
<artifactId>jedis</artifactId>
<version>${jedis.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-mongodb</artifactId>
</dependency>
</dependencies>
<build>
......
......@@ -5,31 +5,31 @@ public class RedisPrefixConstant {
/**
* subsidyAdminister_accountName:AdministerDO 老师账号密码
*/
public static final String SUBSIDY_ADMINISTER_PREFIX = "subsidyAdminister_";
public static final String SUBSIDY_ADMINISTER_PREFIX = "subsidyAdminister:";
/**
* subsidyMember_companyId_accountName:MemberDO 学员账号密码
*/
public static final String SUBSIDY_COMPANY_MEMBER_PREFIX = "subsidyMember_";
public static final String SUBSIDY_COMPANY_MEMBER_PREFIX = "subsidyMember:";
/**
*subsidy_memberLogin_memberId_userName_companyName_now : 学员端审计记录
*/
public static final String SUBSIDY_MEMBER_LOGIN_PREFIX = "subsidy_memberLogin_";
///**
// *subsidy_memberLogin_memberId_userName_companyName_now : 学员端审计记录
// */
//public static final String SUBSIDY_MEMBER_LOGIN_PREFIX = "subsidy:memberLogin:";
/**
* subsidySmsCode_telephone:code 手机验证码
*/
public static final String SUBSIDY_TELEPHONE_PREFIX = "subsidySmsCode_";
public static final String SUBSIDY_TELEPHONE_PREFIX = "subsidySmsCode:";
/**
* subsidySettings_companyId:ClassHourDictDO 公司操作设置
*/
public static final String SUBSIDY_SETTINGS_PREFIX = "subsidySettings_";
public static final String SUBSIDY_SETTINGS_PREFIX = "subsidySettings:";
/**
* subsidySignInfo_memberId_1_classId_12_20211223_long,do 学生签到数据
*/
public static final String SUBSIDY_SIGN_INFO_PREFIX = "subsidySignInfo_";
public static final String SUBSIDY_SIGN_INFO_PREFIX = "subsidySignInfo:";
}
......@@ -16,6 +16,7 @@ import com.subsidy.service.AdministerService;
import com.subsidy.util.ConstantUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
......@@ -65,7 +66,7 @@ public class AdministerController {
@PostMapping("/administers")
@ApiOperation("查询所有运营者 { userName pageNum pageSize }")
@LoginRequired(value = {ConstantUtils.ADMINISTER_TERMINATE})
//@LoginRequired(value = {ConstantUtils.ADMINISTER_TERMINATE})
public ResponseVO operators(@RequestBody OperatorsDTO operatorsDTO){
return ResponseData.generateCreatedResponse(0,administerService.operators(operatorsDTO));
}
......@@ -90,7 +91,7 @@ public class AdministerController {
@PostMapping("classSummary")
@ApiOperation("课程汇总 id 班级id ")
//@LoginRequired(value = {ConstantUtils.ADMINISTER_TERMINATE})
@LoginRequired(value = {ConstantUtils.ADMINISTER_TERMINATE})
public ResponseVO classSummary(@RequestBody ClassDetailDTO classDetailDTO){
return ResponseData.generateCreatedResponse(0,administerService.classSummary(classDetailDTO));
}
......@@ -112,13 +113,13 @@ public class AdministerController {
@PostMapping("signDetail")
@ApiOperation("班级管理--注册签到 id 班级id userName")
//@LoginRequired(value = {ConstantUtils.ADMINISTER_TERMINATE})
@LoginRequired(value = {ConstantUtils.ADMINISTER_TERMINATE})
public ResponseVO signDetail(@RequestBody ClassDetailDTO classDetailDTO){
return ResponseData.generateCreatedResponse(0,administerService.signDetail(classDetailDTO));
}
@PostMapping("exportSignDetail")
@ApiOperation("** 班级管理--注册签到 id 班级id userName")
@ApiOperation("班级管理--注册签到 id 班级id userName")
@LoginRequired(value = {ConstantUtils.ADMINISTER_TERMINATE})
public void exportSignDetail(@RequestBody ClassDetailDTO classDetailDTO)throws Exception{
classDetailDTO.setFlag(true);
......@@ -142,7 +143,7 @@ public class AdministerController {
@PostMapping("getMemberPapers")
@ApiOperation("获取某个成员某个卷子的做题历史 memberId paperId")
//@LoginRequired(value = {ConstantUtils.ADMINISTER_TERMINATE})
@LoginRequired(value = {ConstantUtils.ADMINISTER_TERMINATE})
public ResponseVO getMemberPapers(@RequestBody ExerciseDoneResultDO exerciseDoneResultDO){
return ResponseData.generateCreatedResponse(0,administerService.getMemberPapers(exerciseDoneResultDO));
}
......@@ -181,12 +182,13 @@ public class AdministerController {
}
@PostMapping("exportClassDailyInfo")
@ApiParam("每日学习日志")
public void exportVodInfo(@RequestBody ClassDailyInfoDTO classDailyInfoDTO){
administerService.exportClassDailyInfo(classDailyInfoDTO);
}
@PostMapping("exportZip")
@ApiOperation("** 下载压缩包 id 班级id")
@ApiOperation("下载压缩包 id 班级id")
@CrossOrigin
@LoginRequired(value = {ConstantUtils.ADMINISTER_TERMINATE})
public void exportZip(@RequestBody ClassDetailDTO classDetailDTO)throws Exception{
......
......@@ -36,7 +36,7 @@ public class ClassDictController {
private ClassDictService classDictService;
@PostMapping("getAllClasses")
@ApiOperation("获取某老师下的所有课程 ** companyId 所选企业id className 班级名称")
@ApiOperation("获取某老师下的所有课程 companyId 所选企业id className 班级名称")
@LoginRequired(value = {ConstantUtils.ADMINISTER_TERMINATE})
public ResponseVO getAllClasses(@RequestBody ClassDictDO classDictDO){
return ResponseData.generateCreatedResponse(0,classDictService.getAllClasses(classDictDO));
......@@ -78,8 +78,8 @@ public class ClassDictController {
}
@PostMapping("getSpareMembers")
@ApiOperation("获取不在某班级的某企业里所有成员 ** companyId 企业id classId 班级id")
//@LoginRequired(value = {ConstantUtils.ADMINISTER_TERMINATE})
@ApiOperation("获取不在某班级的某企业里所有成员 companyId 企业id classId 班级id")
@LoginRequired(value = {ConstantUtils.ADMINISTER_TERMINATE})
public ResponseVO getSpareMembers(@RequestBody GetSpareMembersDTO getSpareMembersDTO){
return ResponseData.generateCreatedResponse(0,classDictService.getSpareMembers(getSpareMembersDTO));
}
......@@ -91,7 +91,6 @@ public class ClassDictController {
return ResponseData.generateCreatedResponse(0,classDictService.addMemberToClass(addMemberToClassDTO));
}
@PostMapping("batchSms")
@ApiOperation(" 批量发送班级短信 {id 班级id}")
public ResponseVO batchSms(@RequestBody ClassDictDO classDictDO){
......
......@@ -33,14 +33,14 @@ public class ClassHourDictController {
private ClassHourDictService classHourDictService;
@PostMapping("getSetting")
@ApiOperation("** 查看当天设置的最大学习时长 companyId")
@ApiOperation("查看当天设置的最大学习时长 companyId")
@LoginRequired(value = {ConstantUtils.ADMINISTER_TERMINATE})
public ResponseVO getSetting(@RequestBody ClassHourDictDO classHourDictDO){
return ResponseData.generateCreatedResponse(0,classHourDictService.getSetting(classHourDictDO));
}
@PostMapping("updateSetting")
@ApiOperation("** 修改当天设置时长 id 主键 classHour status interrupt interruptStatus repeatTime repeatStatus")
@ApiOperation("修改当天设置时长 id 主键 classHour status interrupt interruptStatus repeatTime repeatStatus")
@LoginRequired(value = {ConstantUtils.ADMINISTER_TERMINATE})
public ResponseVO updateSetting(@RequestBody ClassHourDictDO classHourDictDO){
return ResponseData.generateCreatedResponse(0,classHourDictService.updateSetting(classHourDictDO));
......
......@@ -34,28 +34,28 @@ public class CompanyDictController {
private CompanyDictService companyDictService;
@PostMapping("/administers")
@ApiOperation("** 查询所有企业 {id companyName pageNum pageSize }")
@ApiOperation("查询所有企业 {id companyName pageNum pageSize }")
@LoginRequired(value = {ConstantUtils.ADMINISTER_TERMINATE})
public ResponseVO operators(@RequestBody OperatorsDTO operatorsDTO){
return ResponseData.generateCreatedResponse(0,companyDictService.operators(operatorsDTO));
}
@PostMapping("addCompany")
@ApiOperation("** 添加企业 {accountName:账号 companyName:企业名称 shortName 简称 banner:标语 field:领域 role 1:超级管理员 2:普通成员}")
@ApiOperation("添加企业 {accountName:账号 companyName:企业名称 shortName 简称 banner:标语 field:领域 role 1:超级管理员 2:普通成员}")
@LoginRequired(value = {ConstantUtils.ADMINISTER_TERMINATE})
public ResponseVO addOperator(@RequestBody AddCompanyDTO addCompanyDTO){
return ResponseData.generateCreatedResponse(0,companyDictService.addOperator(addCompanyDTO));
}
@PostMapping("deleteCompany")
@ApiOperation("** 删除企业 id")
@ApiOperation("删除企业 id")
@LoginRequired(value = {ConstantUtils.ADMINISTER_TERMINATE})
public ResponseVO deleteAdminister(@RequestBody CompanyDictDO companyDictDO){
return ResponseData.generateCreatedResponse(0,companyDictService.deleteAdminister(companyDictDO));
}
@PostMapping("updateCompany")
@ApiOperation("** 修改企业 id accountName:账号 companyName:企业名称 shortName 简称 banner:标语 field:领域 role 1:超级管理员 2:普通成员")
@ApiOperation("修改企业 id accountName:账号 companyName:企业名称 shortName 简称 banner:标语 field:领域 role 1:超级管理员 2:普通成员")
@LoginRequired(value = {ConstantUtils.ADMINISTER_TERMINATE})
public ResponseVO updateAdminister(@RequestBody AddCompanyDTO addCompanyDTO){
return ResponseData.generateCreatedResponse(0,companyDictService.updateAdminister(addCompanyDTO));
......
......@@ -32,28 +32,28 @@ public class CourseContentController {
private CourseContentService courseContentService;
@PostMapping("getContents")
@ApiOperation("** 获取课程目录 {courseId}")
@ApiOperation("获取课程目录 {courseId}")
@LoginRequired(value = {ConstantUtils.ADMINISTER_TERMINATE})
public ResponseVO getContents(@RequestBody CourseContentDO courseContentDO){
return ResponseData.generateCreatedResponse(0,courseContentService.getContents(courseContentDO));
}
@PostMapping("deleteContent")
@ApiOperation("** 删除一个目录 {id} ")
@ApiOperation("删除一个目录 {id} ")
@LoginRequired(value = {ConstantUtils.ADMINISTER_TERMINATE})
public ResponseVO deleteContent(@RequestBody CourseContentDO courseContentDO){
return ResponseData.generateCreatedResponse(0,courseContentService.deleteContent(courseContentDO));
}
@PostMapping("addContent")
@ApiOperation("** 添加一个目录 {courseId content}")
@ApiOperation("添加一个目录 {courseId content}")
@LoginRequired(value = {ConstantUtils.ADMINISTER_TERMINATE})
public ResponseVO addContent(@RequestBody CourseContentDO courseContentDO){
return ResponseData.generateCreatedResponse(0,courseContentService.addContent(courseContentDO));
}
@PostMapping("updateContent")
@ApiOperation("** 更新一个目录 {id courseId content}")
@ApiOperation("更新一个目录 {id courseId content}")
@LoginRequired(value = {ConstantUtils.ADMINISTER_TERMINATE})
public ResponseVO updateContent(@RequestBody CourseContentDO courseContentDO){
return ResponseData.generateCreatedResponse(0,courseContentService.updateContent(courseContentDO));
......
......@@ -33,14 +33,14 @@ public class CourseDictController {
private CourseDictService courseDictService;
@PostMapping("addCourse")
@ApiOperation("添加课程 **companyId courseName categoryId courseType courseSource")
@ApiOperation("添加课程 companyId courseName categoryId courseType courseSource")
@LoginRequired(value = {ConstantUtils.ADMINISTER_TERMINATE})
public ResponseVO addCourse(@RequestBody CourseDictDO courseDictDO){
return ResponseData.generateCreatedResponse(0,courseDictService.addCourse(courseDictDO));
}
@PostMapping("deleteCourse")
@ApiOperation("** 删除课程 id")
@ApiOperation("删除课程 id")
@LoginRequired(value = {ConstantUtils.ADMINISTER_TERMINATE})
public ResponseVO deleteCourse(@RequestBody CourseDictDO courseDictDO){
return ResponseData.generateCreatedResponse(0,courseDictService.deleteCourse(courseDictDO));
......@@ -48,13 +48,13 @@ public class CourseDictController {
@PostMapping("queryCourses")
@ApiOperation("平台运营者--查询课程 pageSize pageNum administerId companyId courseName categoryId courseType courseSource")
//@LoginRequired(value = {ConstantUtils.ADMINISTER_TERMINATE})
@LoginRequired(value = {ConstantUtils.ADMINISTER_TERMINATE})
public ResponseVO queryCourses(@RequestBody QueryCoursesDTO queryCoursesDTO){
return ResponseData.generateCreatedResponse(0,courseDictService.queryCourses(queryCoursesDTO));
}
@PostMapping("updateCourses")
@ApiOperation("编辑课程 id ** companyId courseName categoryId courseType courseSource")
@ApiOperation("编辑课程 id companyId courseName categoryId courseType courseSource")
@LoginRequired(value = {ConstantUtils.ADMINISTER_TERMINATE})
public ResponseVO updateCourses(@RequestBody CourseDictDO courseDictDO){
return ResponseData.generateCreatedResponse(0,courseDictService.updateCourses(courseDictDO));
......
......@@ -32,28 +32,28 @@ public class DepartmentDictController {
private DepartmentDictService departmentDictService;
@PostMapping("getDepartments")
@ApiOperation("** 获取所有部门 companyId 企业id")
@ApiOperation("获取所有部门 companyId 企业id")
@LoginRequired(value = {ConstantUtils.ADMINISTER_TERMINATE})
public ResponseVO getDepartments(@RequestBody DepartmentDictDO departmentDictDO){
return ResponseData.generateCreatedResponse(0,departmentDictService.getDepartments(departmentDictDO));
}
@PostMapping("addDepartment")
@ApiOperation("添加部门 ** companyId departmentName leaderName parentId 父节点")
@ApiOperation("添加部门 companyId departmentName leaderName parentId 父节点")
@LoginRequired(value = {ConstantUtils.ADMINISTER_TERMINATE})
public ResponseVO addDepartment(@RequestBody DepartmentDictDO departmentDictDO){
return ResponseData.generateCreatedResponse(0,departmentDictService.addDepartment(departmentDictDO));
}
@PostMapping("deleteDepartment")
@ApiOperation("** 删除部门 id")
@ApiOperation("删除部门 id")
@LoginRequired(value = {ConstantUtils.ADMINISTER_TERMINATE})
public ResponseVO deleteDepartment(@RequestBody DepartmentDictDO departmentDictDO){
return ResponseData.generateCreatedResponse(0,departmentDictService.deleteDepartment(departmentDictDO));
}
@PostMapping("updateDepartment")
@ApiOperation("编辑部门 id ** companyId departmentName leaderName parentId")
@ApiOperation("编辑部门 id companyId departmentName leaderName parentId")
@LoginRequired(value = {ConstantUtils.ADMINISTER_TERMINATE})
public ResponseVO updateDepartment(@RequestBody DepartmentDictDO departmentDictDO){
return ResponseData.generateCreatedResponse(0,departmentDictService.updateDepartment(departmentDictDO));
......
......@@ -35,13 +35,6 @@ public class ExerciseDictController {
@Autowired
private ExerciseDictService exerciseDictService;
@PostMapping("getAllExercises")
@ApiOperation("【弃用】 查询所有题目 {courseId 课程id exerciseType 题目类型 difficulty 难度 title 题目 pageSize pageNum}")
@LoginRequired(value = {ConstantUtils.ADMINISTER_TERMINATE})
public ResponseVO getAllExercises(@RequestBody GetAllExercisesDTO getAllExercisesDTO){
return ResponseData.generateCreatedResponse(0,exerciseDictService.getAllExercises(getAllExercisesDTO));
}
@PostMapping("addExercise")
@ApiOperation("添加题目 {paperId 试卷id courseId 课程id exerciseType 题目类型 difficulty 难度 title题目 items 选项 rightAnswer 正确答案 }")
@LoginRequired(value = {ConstantUtils.ADMINISTER_TERMINATE})
......@@ -63,14 +56,8 @@ public class ExerciseDictController {
return ResponseData.generateCreatedResponse(0,exerciseDictService.updateExercise(exerciseDictDO));
}
@PostMapping("getCourseExercises")
@ApiOperation("【废弃】获取课程的习题 id 课程id")
public ResponseVO getCourseExercises(@RequestBody CourseDictDO courseDictDO){
return ResponseData.generateCreatedResponse(0,exerciseDictService.getCourseExercises(courseDictDO));
}
@PostMapping("submit")
@ApiOperation("** 提交答案 {paperId 卷子id memberId 成员id classId课程 courseId 课程id memberExerciseVOS [ id selectAnswer ] length:做题时长} ")
@ApiOperation("提交答案 {paperId 卷子id memberId 成员id classId课程 courseId 课程id memberExerciseVOS [ id selectAnswer ] length:做题时长} ")
public ResponseVO submit(@RequestBody SubmitDTO submitDTO){
return ResponseData.generateCreatedResponse(0,exerciseDictService.submit(submitDTO));
}
......
......@@ -32,7 +32,7 @@ public class FileDictController {
private FileDictService fileDictService;
@PostMapping("getContendFiles")
@ApiOperation("** 获取目录下的视频 {contentId fileName}")
@ApiOperation("获取目录下的视频 {contentId fileName}")
@LoginRequired(value = {ConstantUtils.ADMINISTER_TERMINATE})
public ResponseVO getContendFiles(@RequestBody FileDictDO fileDictDO){
return ResponseData.generateCreatedResponse(0,fileDictService.getContendFiles(fileDictDO));
......
......@@ -79,7 +79,7 @@ public class MemberController {
}
@PostMapping("updatePassword")
@ApiOperation("** 修改密码 {id password}")
@ApiOperation("修改密码 {id password}")
public ResponseVO updatePassword(@RequestBody MemberDO memberDO){
return ResponseData.generateCreatedResponse(0,memberService.updatePassword(memberDO));
}
......@@ -103,7 +103,7 @@ public class MemberController {
}
@PostMapping("studyHistory")
@ApiOperation("** 学习记录 memberId 成员id pageSize pageNum")
@ApiOperation("学习记录 memberId 成员id pageSize pageNum")
public ResponseVO studyHistory(@RequestBody StudyHistoryDTO studyHistoryDTO){
return ResponseData.generateCreatedResponse(0,memberService.studyHistory(studyHistoryDTO));
}
......@@ -121,17 +121,11 @@ public class MemberController {
}
@PostMapping("getStudyInfo")
@ApiOperation("** 获取学生完成课程情况 id 学员id")
@ApiOperation("获取学生完成课程情况 id 学员id")
public ResponseVO getStudyInfo(@RequestBody MemberDO memberDO){
return ResponseData.generateCreatedResponse(0,memberService.getStudyInfo(memberDO));
}
//@PostMapping("getDoneResult")
//@ApiOperation("获取此次完成情况 id 提交接口返回的id")
//public ResponseVO getDoneResult(@RequestBody ExerciseDoneResultDO exerciseDoneResultDO){
// return ResponseData.generateCreatedResponse(0,memberService.getDoneResult(exerciseDoneResultDO));
//}
@PostMapping("checkTimes")
@ApiOperation("检测是否超过次数 memberId paperId classId")
public ResponseVO checkTimes(@RequestBody ExerciseDoneResultDO exerciseDoneResultDO){
......
......@@ -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));
}
......
......@@ -34,7 +34,7 @@ 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));
}
......
......@@ -42,4 +42,10 @@ public class VodPlayHistoryController {
VodPlayHistoryDO vodPlayHistoryDO = JSON.parseObject(param,VodPlayHistoryDO.class);
return ResponseData.generateCreatedResponse(0,vodPlayHistoryService.insertHistoryNew(vodPlayHistoryDO));
}
@PostMapping("dataFix")
public void dadaFix(){
vodPlayHistoryService.dataFix();
}
}
package com.subsidy.jobs;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.subsidy.mapper.OprAdmDictMapper;
import com.subsidy.mapper.OprMemDictMapper;
import com.subsidy.mapper.VodPlayHistoryMapper;
import com.subsidy.model.OprAdmDictDO;
import com.subsidy.mongodb.OprAdmDictDO;
import com.subsidy.model.OprMemDictDO;
import com.subsidy.model.VodPlayHistoryDO;
import com.subsidy.util.DateFormatUtil;
import com.subsidy.util.RedisUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import java.time.LocalDateTime;
import java.util.List;
import java.util.Set;
......@@ -41,6 +42,8 @@ public class Scheduler {
@Autowired
private RedisUtil redisUtil;
@Autowired
private MongoTemplate mongoTemplate;
/**
删除十天前登录记录(管理端)
*/
......@@ -49,45 +52,45 @@ public class Scheduler {
List<OprAdmDictDO> list = oprAdmDictMapper.getRecordByDate();
if(list != null) {
for (OprAdmDictDO oprAdmDictDO : list) {
oprAdmDictMapper.deleteById(oprAdmDictDO.getId());
//oprAdmDictMapper.deleteById(oprAdmDictDO.getId());
}
}
}
/**
* 删除十天前登录记录(学员)
*/
//@Scheduled(cron = "0 42 18 * * ?")
public void delOprMemRecord() {
List<OprMemDictDO> list = oprMemDictMapper.getRecordByDate();
if(list != null) {
for (OprMemDictDO oprMemDictDO : list) {
oprMemDictMapper.deleteById(oprMemDictDO.getId());
}
}
}
///**
// * 删除十天前登录记录(学员)
// */
////@Scheduled(cron = "0 42 18 * * ?")
//public void delOprMemRecord() {
// List<OprMemDictDO> list = oprMemDictMapper.getRecordByDate();
// if(list != null) {
// for (OprMemDictDO oprMemDictDO : list) {
// oprMemDictMapper.deleteById(oprMemDictDO.getId());
// }
// }
//}
/**
* 用户数据审计记录添加(学员)
*/
//@Scheduled(cron = "0 39 18 * * ?")
public void getOprMemRecord() {
Set<String> set = redisUtil.scan("*memberLogin*");
if(set != null) {
for (String str : set) {
int result = (Integer) redisUtil.get(str);
OprMemDictDO oprMemDictDO = new OprMemDictDO();
String [] opr = str.split("_");
LocalDateTime createDate = DateFormatUtil.secondToLocalDateTime(Long.valueOf(opr[3]));
oprMemDictDO.setResult(result);
oprMemDictDO.setOprType("登录");
oprMemDictDO.setUserId(Long.valueOf(opr[2]));
oprMemDictDO.setCreateDate(createDate);
oprMemDictMapper.insert(oprMemDictDO);
redisUtil.del(str);
}
}
}
///**
// * 用户数据审计记录添加(学员)
// */
////@Scheduled(cron = "0 39 18 * * ?")
//public void getOprMemRecord() {
// Set<String> set = redisUtil.scan("*memberLogin*");
// if(set != null) {
// for (String str : set) {
// int result = (Integer) redisUtil.get(str);
// OprMemDictDO oprMemDictDO = new OprMemDictDO();
// String [] opr = str.split("_");
// LocalDateTime createDate = DateFormatUtil.secondToLocalDateTime(Long.valueOf(opr[3]));
// oprMemDictDO.setResult(result);
// oprMemDictDO.setOprType("登录");
// oprMemDictDO.setUserId(Long.valueOf(opr[2]));
// oprMemDictDO.setCreateDate(createDate);
// oprMemDictMapper.insert(oprMemDictDO);
// redisUtil.del(str);
// }
// }
//}
/**
* 视频播放记录缩量
......@@ -106,4 +109,5 @@ public class Scheduler {
vodPlayHistoryMapper.insert(vodPlayHistoryDO);
}
}
}
......@@ -24,7 +24,7 @@ public interface CourseContentMapper extends BaseMapper<CourseContentDO> {
/**
* 查看课程下有多少个视频
*/
List<VodDictDO> getCourseVods(Integer courseId);
List<VodDictDO> getCourseVods(Long courseId);
/**
* 查看某个目录下 某个成员看视频的进度
......@@ -36,4 +36,5 @@ public interface CourseContentMapper extends BaseMapper<CourseContentDO> {
*/
List<FileDictDO> contentFiles(Long courseId);
Integer selectMaxOrderNo(Long courseId);
}
......@@ -14,14 +14,16 @@ import org.springframework.stereotype.Repository;
* @author DengMin
* @since 2021-10-12
*/
@Repository
@Repository
public interface ExerciseDictMapper extends BaseMapper<ExerciseDictDO> {
/**
* 获取某一套卷子的题目
*/
IPage<GetPaperExerciseVO> getPaperExercise(IPage page,Long paperId,String difficulty,String exerciseType,String title);
IPage<GetPaperExerciseVO> getPaperExercise(IPage page, Long paperId, String difficulty, String exerciseType, String title);
/**
* 获取某个卷子的最大排序号
*/
Integer getMaximumNo(Long paperId);
}
package com.subsidy.mapper;
import com.subsidy.model.ExerciseDoneResultDO;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.subsidy.model.ExerciseDoneResultDO;
import com.subsidy.vo.administer.GetMemberPapersVO;
import com.subsidy.vo.administer.GetPaperDetailVO;
import com.subsidy.vo.done.GetMaxScoreVO;
import com.subsidy.vo.done.TestScoreInfoVO;
import com.subsidy.vo.exercise.GetDoneDetailVO;
import org.springframework.stereotype.Repository;
......@@ -42,6 +43,18 @@ public interface ExerciseDoneResultMapper extends BaseMapper<ExerciseDoneResultD
*/
List<GetMaxScoreVO> getMaxScore(Long classId, Long memberId);
/**
* 查看某个人某个卷子完成的最好成绩
*/
ExerciseDoneResultDO getMaxScorePaper(Long paperId,Long memberId);
/**
* 测试成绩 最高成绩 测试测试 总评价
*/
TestScoreInfoVO testScoreInfo(Long paperId, Long memberId);
/**
* 汇总 查看课程通过情况
*/
Integer getClassTestPassRate(Long classId);
}
......@@ -4,6 +4,8 @@ import com.subsidy.model.FileDictDO;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.springframework.stereotype.Repository;
import java.util.List;
/**
* <p>
* 课件表 Mapper 接口
......@@ -15,4 +17,6 @@ import org.springframework.stereotype.Repository;
@Repository
public interface FileDictMapper extends BaseMapper<FileDictDO> {
List<FileDictDO> selectFiles(Long contentId,String fileName);
}
package com.subsidy.mapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.subsidy.model.OprAdmDictDO;
import com.subsidy.mongodb.OprAdmDictDO;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.subsidy.vo.opr.GetHistoryVO;
import org.springframework.stereotype.Repository;
......
......@@ -66,6 +66,14 @@ public interface VodPlayHistoryMapper extends BaseMapper<VodPlayHistoryDO> {
*/
List<MemberStudyLogVO> memberStudyLog(Long classId, Long memberId);
/**
* 查看某个人的学习累计时长
*/
Integer memberTotalLength(Long memberId);
/**
* 查看某个人某个视频的累计时长
*/
Integer memberVodTotalLength(Long memberId,Long vodId);
}
package com.subsidy.model;
import lombok.Data;
@Data
public class Collection {
private String _id;
private String name;
}
......@@ -16,14 +16,9 @@ import lombok.EqualsAndHashCode;
* @since 2021-12-13
*/
@Data
@EqualsAndHashCode(callSuper = true)
@TableName("opr_mem_dict")
public class OprMemDictDO extends BaseModel {
public class OprMemDictDO {
private static final long serialVersionUID = 1L;
@TableId(value = "id", type = IdType.AUTO)
private Long id;
private String _id;
/**
* 用户id
......@@ -40,4 +35,13 @@ public class OprMemDictDO extends BaseModel {
*/
private Integer result;
/**
* 登录时间
*/
private String loginDateFormat;
/**
* 创建时间
*/
private String createDate;
}
......@@ -7,6 +7,8 @@ import com.baomidou.mybatisplus.annotation.TableId;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.time.LocalDateTime;
/**
* <p>
* 视频播放历史记录表
......@@ -55,5 +57,7 @@ public class VodPlayHistoryDO extends BaseModel {
*/
private Integer playCount;
private LocalDateTime playDate;
}
package com.subsidy.mongodb;
import com.subsidy.util.MongoUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping("/mango")
public class MongoController {
@Autowired
private MongoTemplate mongoTemplate;
@Autowired
private MongoUtil mongoUtil;
@PostMapping("getOne")
public void getAll(){
////Query query=new Query();
////MongoDO user = mongoTemplate.getDb(query , MongoDO.class);
////List<MongoDO> mongo= mongoTemplate.findAll(MongoDO.class);
////System.out.println(mongo);
//System.out.println(mongoTemplate.getDb().getName());
//
//Collection mongoDO = mongoTemplate.findById("61de944c5cdc5e3f896c95c7", Collection.class);
//System.out.println(mongoDO);
//
//List<Collection> collections = mongoTemplate.findAll(Collection.class);
//System.out.println(collections);
//
//Query query = new Query(Criteria.where("name").regex("张"));//可累加条件
//List<Collection> entrY = mongoTemplate.find(query,Collection.class);
//System.out.println(entrY);
//添加
//Collection collection = new Collection();
//collection.setName("bbbbbbbb");
//collection.set_id("61de944c5cdc5e3f896c95c7");
//mongoTemplate.save(collection,"collection");
//for (int i = 0 ; i < 100; i++){
// Collection collection1 = new Collection();
// collection1.setName("aaaa"+i);
// mongoTemplate.save(collection1);
//}
//Query query =new Query(new Criteria());
//query.with(Sort.by("name"));
////mongoUtil.start(1,5,query);
//List<Collection> collections = mongoTemplate.find(query,Collection.class);
//for (Collection collection : collections){
// System.out.println(collection+"=========");
//}
//OprAdmDictDO oprAdmDictDO = new OprAdmDictDO();
//oprAdmDictDO.setUserId(1L);
//oprAdmDictDO.setResult(1);
//oprAdmDictDO.setOprType("登录成功");
//mongoTemplate.save(oprAdmDictDO);
}
}
package com.subsidy.model;
package com.subsidy.mongodb;
import com.subsidy.util.BaseModel;
import com.baomidou.mybatisplus.annotation.TableName;
......@@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.omg.CosNaming.NamingContextExtPackage.StringNameHelper;
/**
* <p>
......@@ -16,14 +17,9 @@ import lombok.EqualsAndHashCode;
* @since 2021-12-13
*/
@Data
@EqualsAndHashCode(callSuper = true)
@TableName("opr_adm_dict")
public class OprAdmDictDO extends BaseModel {
public class OprAdmDictDO {
private static final long serialVersionUID = 1L;
@TableId(value = "id", type = IdType.AUTO)
private Long id;
private String _id;
/**
* 用户id
......@@ -31,6 +27,16 @@ public class OprAdmDictDO extends BaseModel {
private Long userId;
/**
* 公司id
*/
private Long companyId;
/**
* 名字
*/
private String userName;
/**
* 操作类型
*/
private String oprType;
......@@ -40,4 +46,14 @@ public class OprAdmDictDO extends BaseModel {
*/
private Integer result;
/**
* 登录时间
*/
private String loginDateFormat;
/**
* 创建时间
*/
private String createDate;
}
package com.subsidy.mongodb;
import com.baomidou.mybatisplus.core.metadata.IPage;
import lombok.Data;
import java.util.List;
@Data
public class PageVO<T> {
/**
* 分页记录列表
*
* @return 分页对象记录列表
*/
private List<T> records;
/**
* 设置当前满足条件总行数
*/
private long total;
}
......@@ -21,16 +21,12 @@ import java.util.List;
*/
public interface ExerciseDictService extends IService<ExerciseDictDO> {
IPage<ExerciseDictDO> getAllExercises(GetAllExercisesDTO getAllExercisesDTO);
String addExercise(ExerciseDictDO exerciseDictDO);
String deleteExercise(ExerciseDictDO exerciseDictDO);
String updateExercise(ExerciseDictDO exerciseDictDO);
List<ExerciseVO> getCourseExercises(CourseDictDO courseDictDO);
Long submit(SubmitDTO submitDTO);
IPage getPaperExercise(GetPaperExerciseDTO getPaperExerciseDTO);
......
......@@ -60,8 +60,6 @@ public interface MemberService extends IService<MemberDO> {
GetStudyInfoVO getStudyInfo(MemberDO memberDO);
ExerciseDoneResultDO getDoneResult(ExerciseDoneResultDO exerciseDoneResultDO);
String checkTimes(ExerciseDoneResultDO exerciseDoneResultDO);
void importRedis();
......
......@@ -2,8 +2,9 @@ package com.subsidy.service;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.subsidy.dto.opr.GetHistoryDTO;
import com.subsidy.model.OprAdmDictDO;
import com.subsidy.mongodb.OprAdmDictDO;
import com.baomidou.mybatisplus.extension.service.IService;
import com.subsidy.mongodb.PageVO;
import com.subsidy.vo.opr.GetHistoryVO;
/**
......@@ -16,6 +17,6 @@ import com.subsidy.vo.opr.GetHistoryVO;
*/
public interface OprAdmDictService extends IService<OprAdmDictDO> {
IPage<GetHistoryVO> getHistory(GetHistoryDTO getHistoryDTO);
PageVO<GetHistoryVO> getHistory(GetHistoryDTO getHistoryDTO);
}
......@@ -16,4 +16,6 @@ public interface VodPlayHistoryService extends IService<VodPlayHistoryDO> {
String insertHistory(VodPlayHistoryDO vodPlayHistoryDO);
String insertHistoryNew(VodPlayHistoryDO vodPlayHistoryDO);
void dataFix();
}
......@@ -37,13 +37,14 @@ import com.subsidy.model.ExerciseDoneHistoryDO;
import com.subsidy.model.ExerciseDoneResultDO;
import com.subsidy.model.MemberDO;
import com.subsidy.model.MemberDepartmentMappingDO;
import com.subsidy.model.OprAdmDictDO;
import com.subsidy.model.OprMemDictDO;
import com.subsidy.mongodb.OprAdmDictDO;
import com.subsidy.model.RoleAdministerMappingDO;
import com.subsidy.model.SignInRecordDO;
import com.subsidy.model.VodDictDO;
import com.subsidy.model.VodPlayHistoryDO;
import com.subsidy.service.AdministerService;
import com.subsidy.util.ConstantUtils;
import com.subsidy.util.DateFormatUtil;
import com.subsidy.util.ExcelFormatUtils;
import com.subsidy.util.JwtUtil;
import com.subsidy.util.Localstorage;
......@@ -63,11 +64,13 @@ import com.subsidy.vo.administer.OperatorsVO;
import com.subsidy.vo.administer.PermissionsVO;
import com.subsidy.vo.classdict.ClassDetailVO;
import com.subsidy.vo.done.GetMaxScoreVO;
import com.subsidy.vo.done.TestScoreInfoVO;
import com.subsidy.vo.member.ClassSignVO;
import com.subsidy.vo.sign.AnswerRecordVO;
import com.subsidy.vo.vod.ClassVodCompleteInfoVO;
import com.subsidy.vo.vod.DayInfoItemVO;
import com.subsidy.vo.vod.GetMemberStudyInfoVO;
import net.bytebuddy.description.modifier.SynchronizationState;
import net.sourceforge.pinyin4j.PinyinHelper;
import net.sourceforge.pinyin4j.format.HanyuPinyinCaseType;
import net.sourceforge.pinyin4j.format.HanyuPinyinOutputFormat;
......@@ -91,8 +94,11 @@ 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.data.domain.Sort;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.AsyncResult;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.context.request.RequestContextHolder;
......@@ -118,9 +124,6 @@ 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;
......@@ -179,6 +182,9 @@ public class AdministerServiceImpl extends ServiceImpl<AdministerMapper, Adminis
@Autowired
private RedisUtil redisUtil;
@Autowired
private MongoTemplate mongoTemplate;
public LoginVO login(AdministerDO administerDO) {
LoginVO loginVO = new LoginVO();
......@@ -197,13 +203,18 @@ public class AdministerServiceImpl extends ServiceImpl<AdministerMapper, Adminis
redisUtil.set(RedisPrefixConstant.SUBSIDY_ADMINISTER_PREFIX + administerDO.getAccountName(), administerDO1);
}
if ("0".equals(administerDO1.getStatus())){
if ("0".equals(administerDO1.getStatus())) {
throw new HttpException(10013);
}
/**
* 最近5次都输入失败,5分钟后再验证 待优化
*/
List<OprAdmDictDO> oprAdmDictDOS = oprAdmDictMapper.getLoginInfo(administerDO1.getId());
Query query = new Query(Criteria.where("userId").is(1).and("createDate").gte(System.currentTimeMillis()-5*60*1000+""));//可累加条件
query.with(Sort.by("createDate").descending());
List<OprAdmDictDO> oprAdmDictDOS = mongoTemplate.find(query, OprAdmDictDO.class);
//查mysql逻辑
//List<OprAdmDictDO> oprAdmDictDOS = oprAdmDictMapper.getLoginInfo(administerDO1.getId());
boolean flag = false;
for (int i = 0; i < oprAdmDictDOS.size(); i++) {
......@@ -217,7 +228,6 @@ public class AdministerServiceImpl extends ServiceImpl<AdministerMapper, Adminis
throw new HttpException(10016);
}
if (null != administerDO1) {
if (administerDO.getPassword().equals(administerDO1.getPassword())) {
String token = JwtUtil.generateToken(administerDO1.getId(), ConstantUtils.ADMINISTER_TERMINATE);
......@@ -226,7 +236,12 @@ public class AdministerServiceImpl extends ServiceImpl<AdministerMapper, Adminis
oprAdmDictDO.setUserId(administerDO1.getId());
oprAdmDictDO.setOprType("登录");
oprAdmDictDO.setResult(1);
oprAdmDictMapper.insert(oprAdmDictDO);
oprAdmDictDO.setCreateDate(System.currentTimeMillis()+"");
oprAdmDictDO.setLoginDateFormat(DateFormatUtil.format(new Date(), "yyyyMMdd"));
oprAdmDictDO.setUserName(administerDO1.getUserName());
oprAdmDictDO.setCompanyId(administerDO1.getCompanyId());
//oprAdmDictMapper.insert(oprAdmDictDO);
mongoTemplate.insert(oprAdmDictDO);
loginVO.setToken(token);
return loginVO;
} else {
......@@ -235,7 +250,12 @@ public class AdministerServiceImpl extends ServiceImpl<AdministerMapper, Adminis
oprAdmDictDO.setUserId(administerDO1.getId());
oprAdmDictDO.setOprType("登录");
oprAdmDictDO.setResult(0);
oprAdmDictMapper.insert(oprAdmDictDO);
//oprAdmDictMapper.insert(oprAdmDictDO);
oprAdmDictDO.setCreateDate(System.currentTimeMillis()+"");
oprAdmDictDO.setLoginDateFormat(DateFormatUtil.format(new Date(), "yyyyMMdd"));
oprAdmDictDO.setUserName(administerDO1.getUserName());
oprAdmDictDO.setCompanyId(administerDO1.getCompanyId());
mongoTemplate.insert(oprAdmDictDO);
int i = 0;
......@@ -264,7 +284,6 @@ public class AdministerServiceImpl extends ServiceImpl<AdministerMapper, Adminis
}
}
public AdministerPermissionVO getPermissions() {
AdministerPermissionVO administerPermissionVO = new AdministerPermissionVO();
......@@ -339,6 +358,10 @@ public class AdministerServiceImpl extends ServiceImpl<AdministerMapper, Adminis
@Async
public String deleteAdminister(AdministerDO administerDO) {
this.baseMapper.deleteById(administerDO.getId());
roleAdministerMappingMapper.delete(new QueryWrapper<RoleAdministerMappingDO>()
.lambda()
.eq(RoleAdministerMappingDO::getAdministerId, administerDO.getId()));
return ConstantUtils.DELETE_SUCCESS;
}
......@@ -360,7 +383,6 @@ public class AdministerServiceImpl extends ServiceImpl<AdministerMapper, Adminis
return ConstantUtils.SET_SUCCESS;
}
public ClassSummaryVO classSummary(ClassDetailDTO classDetailDTO) {
ClassSummaryVO classSummaryVO = new ClassSummaryVO();
......@@ -387,106 +409,43 @@ public class AdministerServiceImpl extends ServiceImpl<AdministerMapper, Adminis
/**
* 学生平均学习时长和平均学习次数
*/
ExecutorService executorService = Executors.newCachedThreadPool();
//多个任务
executorService.execute(() -> //总共学习课时数 + 学习时长
summaryTask1(classSummaryVO, classMemberMappingDOS, vodDictDOS));
executorService.execute(() -> //测试通过率
summaryTask2(classSummaryVO, classDictDO.getId()));
executorService.execute(() -> //签到总次数
summaryTask3(classSummaryVO, classDictDO.getId()));
executorService.execute(() -> //答疑数
summaryTask4(classSummaryVO, classDictDO.getId()));
//执行后不再接收新任务,如果里面有任务,就执行完
executorService.shutdown();
try {
while (true) {
//等待所有任务都结束了继续执行
if (executorService.isTerminated()) {
break;
}
}
} catch (Exception ex) {
ex.printStackTrace();
}
return classSummaryVO;
}
public Future<ClassSummaryVO> summaryTask1(ClassSummaryVO classSummaryVO, List<ClassMemberMappingDO> classMemberMappingDOS, List<VodDictDO> vodDictDOS) {
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) {
int totalLength = vodPlayHistoryMapper.memberVodTotalLength(classMemberMappingDO.getMemberId(), vodDictDO.getId());
if (totalLength >= vodDictDO.getVodLength()) {
totalStudyVods++;
}
}
}
}
classSummaryVO.setStudyVodCounts(MathUtil.intDivCeil(totalStudyVods, classMemberMappingDOS.size()));
//平均完成时长 学生观看课程视频的全部时长/总人数
int avg = MathUtil.intDivCeil(totalStudyLength, classMemberMappingDOS.size());
classSummaryVO.setAvgVodPlayLength(avg);
return new AsyncResult<>(classSummaryVO);
}
public Future<ClassSummaryVO> summaryTask2(ClassSummaryVO classSummaryVO, Long classId) {
//测试通过率
List<ExerciseDoneResultDO> exerciseDoneResultDOS = exerciseDoneResultMapper.selectList(new QueryWrapper<ExerciseDoneResultDO>()
.lambda()
.eq(ExerciseDoneResultDO::getClassId, classId));
int passNum = 0;
for (ExerciseDoneResultDO exerciseDoneResultDO : exerciseDoneResultDOS) {
if (exerciseDoneResultDO.getRightCounts() >= exerciseDoneResultDO.getTotalCounts() * 0.6) {
passNum++;
}
}
Integer passNum = exerciseDoneResultMapper.getClassTestPassRate(classDictDO.getId());
classSummaryVO.setPassRate(MathUtil.intDivFloorPercent(passNum, classSummaryVO.getMemberCount()));
return new AsyncResult<>(classSummaryVO);
}
public Future<ClassSummaryVO> summaryTask3(ClassSummaryVO classSummaryVO, Long classId) {
//签到总次数
long signCount = redisUtil.scan("subsidySignInfo*_classId_" + classId + "*").stream().count();
long signCount = redisUtil.scan("subsidySignInfo*:classId:" + classDictDO.getId() + "*").stream().count();
classSummaryVO.setAvgSignCount(MathUtil.intDivCeil(signCount, classSummaryVO.getMemberCount()));
return new AsyncResult<>(classSummaryVO);
}
public Future<ClassSummaryVO> summaryTask4(ClassSummaryVO classSummaryVO, Long classId) {
//答疑数
Integer count = answeringQuestionMapper.selectCount(new QueryWrapper<AnsweringQuestionDO>()
.lambda()
.eq(AnsweringQuestionDO::getClassId, classId));
.eq(AnsweringQuestionDO::getClassId, classDictDO.getId()));
classSummaryVO.setAnswerCount(count);
return new AsyncResult<>(classSummaryVO);
return classSummaryVO;
}
public IPage<ClassDetailVO> classDetail(ClassDetailDTO classDetailDTO) {
Page pager = new Page(classDetailDTO.getPageNum(), classDetailDTO.getPageSize());
IPage<ClassDetailVO> classDetailVOIPage = this.baseMapper.classMembers(pager, classDetailDTO.getId(), classDetailDTO.getUserName());
List<ClassDetailVO> classDetailVOS = classDetailVOIPage.getRecords();
......@@ -497,68 +456,26 @@ public class AdministerServiceImpl extends ServiceImpl<AdministerMapper, Adminis
ClassDictDO classDictDO = classDictMapper.selectById(classDetailDTO.getId());
for (ClassDetailVO classDetailVO : classDetailVOS) {
//全部视频数
classDetailVO.setAllVodCounts(vodDictDOS.size());
/**
* 学生平均学习时长和平均学习次数
*/
ExecutorService cachedThreadPool = Executors.newCachedThreadPool();
//多个任务
cachedThreadPool.execute(() -> ///该学生完成了多少个 学生成绩,学生进度
classDetailTask1(classDetailVO, vodDictDOS, classDictDO.getId(), classDetailVO.getId()));
cachedThreadPool.execute(() -> //答疑
classDetailTask2(classDetailVO, classDetailDTO));
cachedThreadPool.execute(() -> //签到
classDetailTask3(classDetailVO, classDetailDTO));
//执行后不再接收新任务,如果里面有任务,就执行完
cachedThreadPool.shutdown();
try {
while (true) {
//等待所有任务都结束了继续执行
if (cachedThreadPool.isTerminated()) {
break;
}
}
} catch (Exception ex) {
ex.printStackTrace();
}
}
classDetailVOIPage.setRecords(classDetailVOS);
return classDetailVOIPage;
}
public Future<ClassDetailVO> classDetailTask1(ClassDetailVO classDetailVO, List<VodDictDO> vodDictDOS, Long classId, Long memberId) {
//该学生完成了多少个
int i = 0;
int playLength = 0;
//该成员完成了几个视频
for (VodDictDO vodDictDO : vodDictDOS) {
List<VodPlayHistoryDO> vodPlayHistoryDOS = vodPlayHistoryMapper.selectList(new QueryWrapper<VodPlayHistoryDO>()
.lambda()
.eq(VodPlayHistoryDO::getMemberId, memberId)
.eq(VodPlayHistoryDO::getVodId, vodDictDO.getId())
.orderByDesc(VodPlayHistoryDO::getPlayRecord));
if (vodPlayHistoryDOS.size() > 0) {
if (vodPlayHistoryDOS.get(0).getPlayRecord() > vodDictDO.getVodLength() * 0.8) {
int totalPlayLength = vodPlayHistoryMapper.memberVodTotalLength(classDetailVO.getId(), vodDictDO.getId());
if (totalPlayLength >= vodDictDO.getVodLength()) {
i++;
}
playLength += totalPlayLength;
}
for (VodPlayHistoryDO vodPlayHistoryDO : vodPlayHistoryDOS) {
playLength += vodPlayHistoryDO.getPlayLength();
}
}
classDetailVO.setStudyVodCounts(i);
//培训时长
classDetailVO.setTrainingLength(playLength);
//学生测试完成情况 多套卷子各返回最高成绩
List<GetMaxScoreVO> getMaxScoreVOS = exerciseDoneResultMapper.getMaxScore(classId, classDetailVO.getId());
List<GetMaxScoreVO> getMaxScoreVOS = exerciseDoneResultMapper.getMaxScore(classDictDO.getId(), classDetailVO.getId());
classDetailVO.setGetMaxScoreVOS(getMaxScoreVOS);
Boolean flag = true;
......@@ -573,36 +490,25 @@ public class AdministerServiceImpl extends ServiceImpl<AdministerMapper, Adminis
flag = false;
}
if (flag && i == vodDictDOS.size()) {
classDetailVO.setResult("合格");
} else {
classDetailVO.setResult("不合格");
}
//总评价
classDetailVO.setResult(flag && i == vodDictDOS.size() ? "合格" : "不合格");
//课程进度
classDetailVO.setClassProcess(i + "/" + vodDictDOS.size());
//培训时长
classDetailVO.setTrainingLength(playLength);
return new AsyncResult<>(classDetailVO);
}
public Future<ClassDetailVO> classDetailTask2(ClassDetailVO classDetailVO, ClassDetailDTO classDetailDTO) {
//答疑
Integer count = answeringQuestionMapper.selectCount(new QueryWrapper<AnsweringQuestionDO>()
.lambda()
.eq(AnsweringQuestionDO::getAskId, classDetailVO.getId())
.eq(AnsweringQuestionDO::getClassId, classDetailDTO.getId()));
classDetailVO.setAskCounts(count);
//签到次数
long set = redisUtil.scan(RedisPrefixConstant.SUBSIDY_SIGN_INFO_PREFIX + "memberId:" + classDetailVO.getId() + ":classId:" + classDetailDTO.getId() + "*").stream().count();
classDetailVO.setSignCounts(set);
return new AsyncResult<>(classDetailVO);
}
public Future<ClassDetailVO> classDetailTask3(ClassDetailVO classDetailVO, ClassDetailDTO classDetailDTO) {
////签到次数
long set = redisUtil.scan(RedisPrefixConstant.SUBSIDY_SIGN_INFO_PREFIX + "memberId_" + classDetailVO.getId() + "_classId_" + classDetailDTO.getId() + "*").stream().count();
classDetailVO.setSignCounts(set);
return new AsyncResult<>(classDetailVO);
classDetailVOIPage.setRecords(classDetailVOS);
return classDetailVOIPage;
}
public List<ClassDetailVO> exportClassDetail(ClassDetailDTO classDetailDTO) throws Exception {
......@@ -619,71 +525,23 @@ public class AdministerServiceImpl extends ServiceImpl<AdministerMapper, Adminis
CompanyDictDO companyDictDO = companyDictMapper.selectById(classDictDO.getCompanyId());
for (ClassDetailVO classDetailVO : classDetailVOS) {
//全部视频数
//classDetailVO.setAllVodCounts(vodDictDOS.size());
final ExecutorService newCachedThreadPool = Executors.newCachedThreadPool();
//多个任务
newCachedThreadPool.execute(() -> ///该学生完成了多少个 学生成绩,学生进度
exportClassDetailTask(classDetailVO, vodDictDOS, classDictDO.getId(), classDetailVO.getId()));
newCachedThreadPool.execute(() -> //答疑
classDetailTask2(classDetailVO, classDetailDTO));
newCachedThreadPool.execute(() -> //签到
classDetailTask3(classDetailVO, classDetailDTO));
//执行后不再接收新任务,如果里面有任务,就执行完
newCachedThreadPool.shutdown();
try {
while (true) {
//等待所有任务都结束了继续执行
if (newCachedThreadPool.isTerminated()) {
break;
}
}
} catch (Exception ex) {
ex.printStackTrace();
}
}
if (classDetailDTO.getFlag()) {
CourseDictDO courseDictDO = courseDictMapper.selectById(classDictDO.getCourseId());
String studyDate = classDictDO.getStartDate() + " 至 " + classDictDO.getEndDate();
ExcelUtil.writeMemberExcel(companyDictDO.getCompanyName(), studyDate, courseDictDO.getCourseName(), "授课记录汇总表", classDetailVOS, ExcelFormatUtils.memberList);
}
return classDetailVOS;
}
public Future exportClassDetailTask(ClassDetailVO classDetailVO, List<VodDictDO> vodDictDOS, Long classId, Long memberId) {
//该学生完成了多少个
int i = 0;
int playLength = 0;
//该成员完成了几个视频
for (VodDictDO vodDictDO : vodDictDOS) {
List<VodPlayHistoryDO> vodPlayHistoryDOS = vodPlayHistoryMapper.selectList(new QueryWrapper<VodPlayHistoryDO>()
.lambda()
.eq(VodPlayHistoryDO::getMemberId, memberId)
.eq(VodPlayHistoryDO::getVodId, vodDictDO.getId())
.orderByDesc(VodPlayHistoryDO::getPlayRecord));
if (vodPlayHistoryDOS.size() > 0) {
if (vodPlayHistoryDOS.get(0).getPlayRecord() > vodDictDO.getVodLength() * 0.8) {
int totalPlayLength = vodPlayHistoryMapper.memberVodTotalLength(classDetailVO.getId(), vodDictDO.getId());
if (totalPlayLength >= vodDictDO.getVodLength()) {
i++;
}
playLength += totalPlayLength;
}
for (VodPlayHistoryDO vodPlayHistoryDO : vodPlayHistoryDOS) {
playLength += vodPlayHistoryDO.getPlayLength();
}
}
//classDetailVO.setStudyVodCounts(i);
//课程进度
classDetailVO.setClassProcess(i + "/" + vodDictDOS.size());
//学生测试完成情况 多套卷子各返回最高成绩
List<GetMaxScoreVO> getMaxScoreVOS = exerciseDoneResultMapper.getMaxScore(classId, classDetailVO.getId());
List<GetMaxScoreVO> getMaxScoreVOS = exerciseDoneResultMapper.getMaxScore(classDictDO.getId(), classDetailVO.getId());
classDetailVO.setGetMaxScoreVOS(getMaxScoreVOS);
Boolean flag = true;
......@@ -703,18 +561,33 @@ public class AdministerServiceImpl extends ServiceImpl<AdministerMapper, Adminis
flag = false;
}
if (flag && i == vodDictDOS.size()) {
classDetailVO.setResult("合格");
} else {
classDetailVO.setResult("不合格");
}
//总评价
classDetailVO.setResult(flag && i == vodDictDOS.size() ? "合格" : "不合格");
classDetailVO.setScore(stringBuilder.toString());
//培训时长
classDetailVO.setTrainingLength(playLength);
classDetailVO.setTrainingLengthStr(MathUtil.secToTime(playLength));
return new AsyncResult(classDetailVO);
//答疑
Integer count = answeringQuestionMapper.selectCount(new QueryWrapper<AnsweringQuestionDO>()
.lambda()
.eq(AnsweringQuestionDO::getAskId, classDetailVO.getId())
.eq(AnsweringQuestionDO::getClassId, classDetailDTO.getId()));
classDetailVO.setAskCounts(count);
//签到次数
long set = redisUtil.scan(RedisPrefixConstant.SUBSIDY_SIGN_INFO_PREFIX + "memberId:" + classDetailVO.getId() + ":classId:" + classDetailDTO.getId() + "*").stream().count();
classDetailVO.setSignCounts(set);
}
if (classDetailDTO.getFlag()) {
CourseDictDO courseDictDO = courseDictMapper.selectById(classDictDO.getCourseId());
String studyDate = classDictDO.getStartDate() + " 至 " + classDictDO.getEndDate();
ExcelUtil.writeMemberExcel(companyDictDO.getCompanyName(), studyDate, courseDictDO.getCourseName(), "授课记录汇总表", classDetailVOS, ExcelFormatUtils.memberList);
}
return classDetailVOS;
}
public IPage<ClassSignVO> signDetail(ClassDetailDTO classDetailDTO) {
......@@ -729,71 +602,30 @@ public class AdministerServiceImpl extends ServiceImpl<AdministerMapper, Adminis
for (ClassSignVO classSignVO : classSignVOS) {
ExecutorService newCachedThreadPool = Executors.newCachedThreadPool();
//多个任务
newCachedThreadPool.execute(() -> //全部视频数
classSignVO.setAllVodCounts(vodDictDOS.size()));
newCachedThreadPool.execute(() -> //完成率,完成情况
signDetailsTask1(vodDictDOS, classSignVO));
newCachedThreadPool.execute(() -> //签到,签到时间
signDetailsTask2(classSignVO, classDetailDTO));
//执行后不再接收新任务,如果里面有任务,就执行完
newCachedThreadPool.shutdown();
try {
while (true) {
//等待所有任务都结束了继续执行
if (newCachedThreadPool.isTerminated()) {
break;
}
}
} catch (Exception ex) {
ex.printStackTrace();
}
}
classSignVOIPage.setRecords(classSignVOS);
return classSignVOIPage;
}
public Future signDetailsTask1(List<VodDictDO> vodDictDOS, ClassSignVO classSignVO) {
//该学生完成了多少个
int i = 0;
int playLength = 0;
//该成员完成了几个视频
for (VodDictDO vodDictDO : vodDictDOS) {
List<VodPlayHistoryDO> vodPlayHistoryDOS = vodPlayHistoryMapper.selectList(new QueryWrapper<VodPlayHistoryDO>()
.lambda()
.eq(VodPlayHistoryDO::getMemberId, classSignVO.getId())
.eq(VodPlayHistoryDO::getVodId, vodDictDO.getId())
.orderByDesc(VodPlayHistoryDO::getPlayRecord));
if (vodPlayHistoryDOS.size() > 0) {
if (vodPlayHistoryDOS.get(0).getPlayRecord() > vodDictDO.getVodLength() * 0.8) {
int totalPlayLength = vodPlayHistoryMapper.memberVodTotalLength(classSignVO.getId(), vodDictDO.getId());
if (totalPlayLength >= vodDictDO.getVodLength()) {
i++;
}
playLength += totalPlayLength;
}
for (VodPlayHistoryDO vodPlayHistoryDO : vodPlayHistoryDOS) {
playLength += vodPlayHistoryDO.getPlayLength();
}
}
classSignVO.setStudyVodCounts(i);
//课程进度
classSignVO.setClassProcess(i + "/" + vodDictDOS.size());
//完成率
String percent = MathUtil.getPercentAvgIndexWithPercent(new BigDecimal(i), new BigDecimal(vodDictDOS.size()));
classSignVO.setPercent(percent);
//培训时长
classSignVO.setTrainingLength(playLength);
classSignVO.setTrainingLengthStr(MathUtil.secToTime(playLength));
return new AsyncResult<>(classSignVO);
}
public Future signDetailsTask2(ClassSignVO classSignVO, ClassDetailDTO classDetailDTO) {
//签到
Set<SignInRecordDO> set = redisUtil.scan(RedisPrefixConstant.SUBSIDY_SIGN_INFO_PREFIX + "memberId_" + classSignVO.getId() + "_classId_" + classDetailDTO.getId() + "*");
Set<SignInRecordDO> set = redisUtil.scan(RedisPrefixConstant.SUBSIDY_SIGN_INFO_PREFIX + "memberId:" + classSignVO.getId() + ":classId:" + classDetailDTO.getId() + "*");
classSignVO.setSignCounts(set.size());
StringBuilder stringBuilder = new StringBuilder();
......@@ -805,7 +637,10 @@ public class AdministerServiceImpl extends ServiceImpl<AdministerMapper, Adminis
String signInDate = stringBuilder.toString().substring(0, stringBuilder.length() - 1);
classSignVO.setSignInDateList(signInDate);
}
return new AsyncResult<>(classSignVO);
}
classSignVOIPage.setRecords(classSignVOS);
return classSignVOIPage;
}
public List<ClassSignVO> exportSignDetail(ClassDetailDTO classDetailDTO) throws Exception {
......@@ -819,29 +654,40 @@ public class AdministerServiceImpl extends ServiceImpl<AdministerMapper, Adminis
for (ClassSignVO classSignVO : classSignVOS) {
final ExecutorService newCachedThreadPool = Executors.newCachedThreadPool();
//该学生完成了多少个
int i = 0;
int playLength = 0;
//该成员完成了几个视频
for (VodDictDO vodDictDO : vodDictDOS) {
int totalPlayLength = vodPlayHistoryMapper.memberVodTotalLength(classSignVO.getId(), vodDictDO.getId());
if (totalPlayLength >= vodDictDO.getVodLength()) {
i++;
}
playLength += totalPlayLength;
}
classSignVO.setClassProcess(i + "/" + vodDictDOS.size());
//多个任务
newCachedThreadPool.execute(() -> //全部视频数
classSignVO.setAllVodCounts(vodDictDOS.size()));
newCachedThreadPool.execute(() -> //完成率,完成情况
signDetailsTask1(vodDictDOS, classSignVO));
newCachedThreadPool.execute(() -> //签到,签到时间
signDetailsTask2(classSignVO, classDetailDTO));
//完成率
String percent = MathUtil.getPercentAvgIndexWithPercent(new BigDecimal(i), new BigDecimal(vodDictDOS.size()));
classSignVO.setPercent(percent);
//执行后不再接收新任务,如果里面有任务,就执行完
newCachedThreadPool.shutdown();
try {
while (true) {
//等待所有任务都结束了继续执行
if (newCachedThreadPool.isTerminated()) {
break;
//培训时长
classSignVO.setTrainingLengthStr(MathUtil.secToTime(playLength));
//签到
Set<SignInRecordDO> set = redisUtil.scan(RedisPrefixConstant.SUBSIDY_SIGN_INFO_PREFIX + "memberId:" + classSignVO.getId() + ":classId:" + classDetailDTO.getId() + "*");
classSignVO.setSignCounts(set.size());
StringBuilder stringBuilder = new StringBuilder();
//签到时间
for (SignInRecordDO signInRecordDO : set) {
stringBuilder.append(signInRecordDO.getSignInDate().toString().replace("T", " ")).append(";");
}
if (StringUtils.isNotBlank(stringBuilder.toString())) {
String signInDate = stringBuilder.toString().substring(0, stringBuilder.length() - 1);
classSignVO.setSignInDateList(signInDate);
}
} catch (Exception ex) {
ex.printStackTrace();
}
}
if (classDetailDTO.getFlag()) {
......@@ -862,45 +708,24 @@ public class AdministerServiceImpl extends ServiceImpl<AdministerMapper, Adminis
IPage<ExerciseTestVO> exerciseTestVOIPage = this.baseMapper.exerciseTest(pager, classDetailDTO.getId(), classDetailDTO.getUserName());
List<ExerciseTestVO> classSignVOS = exerciseTestVOIPage.getRecords();
ExecutorService newCachedThreadPool = Executors.newCachedThreadPool();
for (ExerciseTestVO exerciseTestVO : classSignVOS) {
newCachedThreadPool.execute(() -> //签到,签到时间
exerciseTestTask(exerciseTestVO, classDetailDTO.getId(), exerciseTestVO.getPaperId()));
}
//执行后不再接收新任务,如果里面有任务,就执行完
newCachedThreadPool.shutdown();
try {
while (true) {
//等待所有任务都结束了继续执行
if (newCachedThreadPool.isTerminated()) {
break;
}
}
} catch (Exception ex) {
ex.printStackTrace();
}
exerciseTestVOIPage.setRecords(classSignVOS);
return exerciseTestVOIPage;
}
public void exerciseTestTask(ExerciseTestVO exerciseTestVO, Long classId, Long paperId) {
//学生测试完成情况
List<GetMemberPapersVO> exerciseDoneResultDOs = exerciseDoneResultMapper.queryExerciseDoneResult(exerciseTestVO.getId(), classId, paperId);
TestScoreInfoVO testScoreInfoVO = exerciseDoneResultMapper.testScoreInfo(classDetailDTO.getPaperId(), exerciseTestVO.getId());
exerciseTestVO.setPaperId(exerciseTestVO.getPaperId());
if (exerciseDoneResultDOs.size() > 0) {
exerciseTestVO.setScore(exerciseDoneResultDOs.get(0).getScore());
exerciseTestVO.setResult(exerciseDoneResultDOs.get(0).getResult());
if (null != testScoreInfoVO) {
exerciseTestVO.setScore(testScoreInfoVO.getScore());
exerciseTestVO.setResult(testScoreInfoVO.getResult());
//测评次数
exerciseTestVO.setCount(exerciseDoneResultDOs.size());
exerciseTestVO.setCount(testScoreInfoVO.getCnt());
} else {
exerciseTestVO.setScore(0);
exerciseTestVO.setResult("不合格");
exerciseTestVO.setCount(0);
}
}
exerciseTestVOIPage.setRecords(classSignVOS);
return exerciseTestVOIPage;
}
public List<ExerciseTestVO> exportExerciseTest(ClassDetailDTO classDetailDTO) throws Exception {
......@@ -912,24 +737,20 @@ public class AdministerServiceImpl extends ServiceImpl<AdministerMapper, Adminis
//课程详情
ClassDictDO classDictDO = classDictMapper.selectById(classDetailDTO.getId());
ExecutorService newCachedThreadPool = Executors.newCachedThreadPool();
for (ExerciseTestVO exerciseTestVO : exerciseTestVOS) {
newCachedThreadPool.execute(() -> //签到,签到时间
exerciseTestTask(exerciseTestVO, classDetailDTO.getId(), exerciseTestVO.getPaperId()));
}
//执行后不再接收新任务,如果里面有任务,就执行完
newCachedThreadPool.shutdown();
try {
while (true) {
//等待所有任务都结束了继续执行
if (newCachedThreadPool.isTerminated()) {
break;
}
//学生测试完成情况
TestScoreInfoVO testScoreInfoVO = exerciseDoneResultMapper.testScoreInfo(classDetailDTO.getPaperId(), exerciseTestVO.getId());
exerciseTestVO.setPaperId(exerciseTestVO.getPaperId());
if (null != testScoreInfoVO) {
exerciseTestVO.setScore(testScoreInfoVO.getScore());
exerciseTestVO.setResult(testScoreInfoVO.getResult());
//测评次数
exerciseTestVO.setCount(testScoreInfoVO.getCnt());
} else {
exerciseTestVO.setScore(0);
exerciseTestVO.setResult("不合格");
exerciseTestVO.setCount(0);
}
} catch (Exception ex) {
ex.printStackTrace();
}
if (classDetailDTO.getFlag()) {
......@@ -976,6 +797,7 @@ public class AdministerServiceImpl extends ServiceImpl<AdministerMapper, Adminis
//获取班级成员
List<Long> memberIds = classMemberMappingMapper.getClassMembers(classVodInfoDTO.getClassId());
//获取课程下的视频
List<VodDictDO> vodDictDOS = vodDictMapper.getCourseVods(classVodInfoDTO.getCourseId(), classVodInfoDTO.getVodName());
for (VodDictDO vodDictDO : vodDictDOS) {
//获取这个视频的学习人数和平均学习时长
......@@ -1007,14 +829,17 @@ public class AdministerServiceImpl extends ServiceImpl<AdministerMapper, Adminis
for (ClassDailyInfoVO classDailyInfoVO : classDailyInfoVOS) {
List<DayInfoItemVO> dayInfoItemVOS = new ArrayList<>();
int total = 0;
for (GetMemberStudyInfoVO getMemberStudyInfoVO : getMemberStudyInfoVOS) {
if (classDailyInfoVO.getId().equals(getMemberStudyInfoVO.getMemberId())) {
DayInfoItemVO dayInfoItemVO = new DayInfoItemVO();
dayInfoItemVO.setStudyDate(getMemberStudyInfoVO.getStudyDate());
dayInfoItemVO.setTotalLength(getMemberStudyInfoVO.getPlayLength());
total += getMemberStudyInfoVO.getPlayLength();
dayInfoItemVOS.add(dayInfoItemVO);
}
}
classDailyInfoVO.setTotal(total);
classDailyInfoVO.setDayInfoItemVOS(dayInfoItemVOS);
}
return classDailyInfoVOIPage;
......@@ -1027,6 +852,7 @@ public class AdministerServiceImpl extends ServiceImpl<AdministerMapper, Adminis
List<String> title = new ArrayList<>();
title.add("姓名");
title.addAll(findDaysStr(classDailyInfoDTO.getStartDate(), classDailyInfoDTO.getEndDate()));
title.add("合计总时长");
//获取班级成员
IPage<ClassDailyInfoVO> classDailyInfoVOIPage = classMemberMappingMapper.getClassMembersWithName(pager, classDailyInfoDTO.getClassId(), classDailyInfoDTO.getUserName());
......@@ -1095,16 +921,21 @@ public class AdministerServiceImpl extends ServiceImpl<AdministerMapper, Adminis
HashMap<String, Integer> hashMap1 = hashMap.get(data);
Cell namecell = r.createCell(a.getAndIncrement());
namecell.setCellValue(memberMapper.selectById(data).getUserName());
dates.forEach(field -> {
if (!field.equals("姓名")) {
int total = 0 ;
for (String date : dates){
if (!date.equals("姓名")&&!"合计总时长".equals(date)) {
Cell cell1 = r.createCell(a.getAndIncrement());
if (null != hashMap1) {
cell1.setCellValue(null == hashMap1.get(field) ? "00:00:00" : MathUtil.secToTime(hashMap1.get(field)));
total += null == hashMap1.get(date)?0:hashMap1.get(date);
cell1.setCellValue(null == hashMap1.get(date) ? "00:00:00" : MathUtil.secToTime(hashMap1.get(date)));
} else {
cell1.setCellValue("00:00:00");
}
}
});
}
Cell totalCell = r.createCell(a.getAndIncrement());
totalCell.setCellValue(MathUtil.secToTime(total));
});
}
String fileName = String.valueOf(new Date().getTime());
......@@ -1916,11 +1747,7 @@ public class AdministerServiceImpl extends ServiceImpl<AdministerMapper, Adminis
newCell = dataRow.createCell(6);
newCell.setCellStyle(cellStyle);
if (exerciseTestVO.getScore() >= 60) {
newCell.setCellValue("合格");
} else {
newCell.setCellValue("不合格");
}
newCell.setCellValue(exerciseTestVO.getScore() >= 60 ? "合格" : "不合格");
rowIndex++;
seq++;
......
......@@ -29,19 +29,16 @@ public class AnsweringQuestionServiceImpl extends ServiceImpl<AnsweringQuestionM
return this.baseMapper.getCourseQuestion(pager, getCourseQuestionDTO.getClassId(), getCourseQuestionDTO.getMemberId());
}
@Async
public String addQuestion(AnsweringQuestionDO answeringQuestionDO) {
this.baseMapper.insert(answeringQuestionDO);
return ConstantUtils.ADD_SUCCESS;
}
@Async
public String deleteQuestion(AnsweringQuestionDO answeringQuestionDO) {
this.baseMapper.deleteById(answeringQuestionDO.getId());
return ConstantUtils.DELETE_SUCCESS;
}
@Async
public String updateQuestion(AnsweringQuestionDO answeringQuestionDO) {
this.baseMapper.updateById(answeringQuestionDO);
return ConstantUtils.SET_SUCCESS;
......
......@@ -56,11 +56,9 @@ public class CategoryServiceImpl extends ServiceImpl<CategoryMapper, CategoryDO>
}
}
@Async
public String addCategory(CategoryDO categoryDO) {
int count = 0;
int count;
if (null == categoryDO.getCompanyId()) {
count = this.baseMapper.selectCount(new QueryWrapper<CategoryDO>()
......@@ -82,20 +80,20 @@ public class CategoryServiceImpl extends ServiceImpl<CategoryMapper, CategoryDO>
return ConstantUtils.ADD_SUCCESS;
}
@Async
public String deleteCategory(CategoryDO categoryDO) {
this.baseMapper.deleteById(categoryDO.getId());
return ConstantUtils.DELETE_SUCCESS;
}
@Async
public String updateCategory(CategoryDO categoryDO) {
int count = this.baseMapper.selectCount(new QueryWrapper<CategoryDO>()
.lambda()
.eq(CategoryDO::getName, categoryDO.getName()));
.eq(CategoryDO::getName, categoryDO.getName())
.eq(CategoryDO::getCompanyId, categoryDO.getCompanyId())
.ne(CategoryDO::getId, categoryDO.getId()));
if (count > 2) {
if (count > 0) {
throw new HttpException(90001);
}
......
......@@ -57,7 +57,6 @@ public class ClassDictServiceImpl extends ServiceImpl<ClassDictMapper, ClassDict
}
@Transactional
@Async
public String deleteClasses(ClassDictDO classDictDO) {
this.baseMapper.deleteById(classDictDO.getId());
......@@ -67,7 +66,6 @@ public class ClassDictServiceImpl extends ServiceImpl<ClassDictMapper, ClassDict
return ConstantUtils.DELETE_SUCCESS;
}
@Async
public String addClass(AddClassDTO addClassDTO) {
//查看当前登录人的角色
......@@ -79,17 +77,12 @@ public class ClassDictServiceImpl extends ServiceImpl<ClassDictMapper, ClassDict
ClassDictDO classDictDO = new ClassDictDO();
BeanUtils.copyProperties(addClassDTO,classDictDO);
if (count>0){
classDictDO.setClassType("平台支持");
}else{
classDictDO.setClassType("企业自建");
}
classDictDO.setClassType(count>0?"平台支持":"企业自建");
this.baseMapper.insert(classDictDO);
return ConstantUtils.ADD_SUCCESS;
}
@Async
public String updateClass(ClassDictDO classDictDO) {
this.baseMapper.updateById(classDictDO);
return ConstantUtils.SET_SUCCESS;
......@@ -99,7 +92,6 @@ public class ClassDictServiceImpl extends ServiceImpl<ClassDictMapper, ClassDict
return this.baseMapper.selectById(classDictDO.getId());
}
@Async
public String removeMember(ClassMemberMappingDO classMemberMappingDO) {
classMemberMappingMapper.delete(new QueryWrapper<ClassMemberMappingDO>()
.lambda()
......@@ -125,7 +117,6 @@ public class ClassDictServiceImpl extends ServiceImpl<ClassDictMapper, ClassDict
return ConstantUtils.ADD_SUCCESS;
}
@Async
public String batchSms(ClassDictDO classDictDO){
ClassDictDO classDictDO1 = this.baseMapper.selectById(classDictDO.getId());
......
......@@ -79,7 +79,7 @@ public class ClassHourDictServiceImpl extends ServiceImpl<ClassHourDictMapper, C
if (classHourDictDO == null) {
pollingGetVO.setBool(true);
} else {
if (total + vodPlayHistoryDO.getPlayLength() <= classHourDictDO.getClassHour() * 60 * 60) {
if (total + vodPlayHistoryDO.getPlayLength() <= classHourDictDO.getClassHour() * 3600) {
pollingGetVO.setBool(false);
} else {
pollingGetVO.setBool(true);
......
......@@ -59,14 +59,15 @@ public class CompanyDictServiceImpl extends ServiceImpl<CompanyDictMapper, Compa
//判断该用户的角色
Integer count = roleAdministerMappingMapper.selectCount(new QueryWrapper<RoleAdministerMappingDO>()
.lambda()
.eq(RoleAdministerMappingDO::getAdministerId,operatorsDTO.getId())
.eq(RoleAdministerMappingDO::getRoleId,1));
.eq(RoleAdministerMappingDO::getAdministerId, operatorsDTO.getId())
.eq(RoleAdministerMappingDO::getRoleId, 1));
if (count > 0){
if (count > 0) {
//后台管理员
operatorsDTO.setId(null);
}
return this.baseMapper.operators(pager, operatorsDTO.getCompanyName(), operatorsDTO.getId(),operatorsDTO.getUserName(),1);
return this.baseMapper.operators(pager, operatorsDTO.getCompanyName(), operatorsDTO.getId(), operatorsDTO.getUserName(), 1);
}
public String addOperator(AddCompanyDTO addCompanyDTO) {
......@@ -75,16 +76,20 @@ public class CompanyDictServiceImpl extends ServiceImpl<CompanyDictMapper, Compa
.lambda()
.eq(CompanyDictDO::getCompanyName, addCompanyDTO.getAccountName()));
if (count > 0 ) {
throw new HttpException(20002);
}
Integer count1 = administerMapper.selectCount(new QueryWrapper<AdministerDO>()
.lambda()
.eq(AdministerDO::getAccountName, addCompanyDTO.getAccountName()));
if (count > 0 || count1>0) {
if (count1 > 0) {
throw new HttpException(20002);
}
CompanyDictDO companyDictDO =new CompanyDictDO();
BeanUtils.copyProperties(addCompanyDTO,companyDictDO);
CompanyDictDO companyDictDO = new CompanyDictDO();
BeanUtils.copyProperties(addCompanyDTO, companyDictDO);
this.baseMapper.insert(companyDictDO);
AdministerDO administerDO = new AdministerDO();
......@@ -108,7 +113,6 @@ public class CompanyDictServiceImpl extends ServiceImpl<CompanyDictMapper, Compa
departmentDictMapper.insert(departmentDictDO);
//class_hour_dict
ClassHourDictDO classHourDictDO2 = new ClassHourDictDO();
classHourDictDO2.setCompanyId(companyDictDO.getId());
classHourDictDO2.setStatus(0);
......@@ -119,46 +123,44 @@ public class CompanyDictServiceImpl extends ServiceImpl<CompanyDictMapper, Compa
classHourDictDO2.setRepeatStatus(0);
classHourDictDO2.setRepeatTime(3);
redisUtil.set(RedisPrefixConstant.SUBSIDY_SETTINGS_PREFIX +companyDictDO.getId(),classHourDictDO2);
redisUtil.set(RedisPrefixConstant.SUBSIDY_SETTINGS_PREFIX + companyDictDO.getId(), classHourDictDO2);
return ConstantUtils.ADD_SUCCESS;
}
@Async
public String deleteAdminister(CompanyDictDO companyDictDO) {
this.baseMapper.deleteById(companyDictDO.getId());
administerMapper.delete(new QueryWrapper<AdministerDO>()
.lambda()
.eq(AdministerDO::getCompanyId,companyDictDO.getId()));
.eq(AdministerDO::getCompanyId, companyDictDO.getId()));
redisUtil.del(RedisPrefixConstant.SUBSIDY_SETTINGS_PREFIX+companyDictDO.getId());
return ConstantUtils.DELETE_SUCCESS;
}
@Async
public String updateAdminister(AddCompanyDTO addCompanyDTO) {
CompanyDictDO companyDictDO = new CompanyDictDO();
BeanUtils.copyProperties(addCompanyDTO,companyDictDO);
BeanUtils.copyProperties(addCompanyDTO, companyDictDO);
this.baseMapper.updateById(companyDictDO);
//查找企业管理员
AdministerDO administerDO = administerMapper.selectOne(new QueryWrapper<AdministerDO>()
.lambda()
.eq(AdministerDO::getCompanyId,addCompanyDTO.getId())
.eq(AdministerDO::getRole,1));
if (StringUtils.isNotBlank(addCompanyDTO.getAccountName())){
.eq(AdministerDO::getCompanyId, addCompanyDTO.getId())
.eq(AdministerDO::getRole, 1));
if (StringUtils.isNotBlank(addCompanyDTO.getAccountName())) {
administerDO.setAccountName(addCompanyDTO.getAccountName());
}
if (StringUtils.isBlank(addCompanyDTO.getPassword())){
if (StringUtils.isBlank(addCompanyDTO.getPassword())) {
addCompanyDTO.setPassword(addCompanyDTO.getPassword());
}
administerMapper.updateById(administerDO);
return ConstantUtils.SET_SUCCESS;
}
public List<GetAllCompanyVO> getAllCompany(CompanyDictDO companyDictDO){
public List<GetAllCompanyVO> getAllCompany(CompanyDictDO companyDictDO) {
return this.baseMapper.getAllCompany(companyDictDO);
}
......
......@@ -31,39 +31,34 @@ public class CourseContentServiceImpl extends ServiceImpl<CourseContentMapper, C
.orderByAsc(CourseContentDO::getCreateDate));
}
@Async
public String deleteContent(CourseContentDO courseContentDO){
this.baseMapper.deleteById(courseContentDO.getId());
return ConstantUtils.DELETE_SUCCESS;
}
@Async
public String addContent(CourseContentDO courseContentDO){
List<CourseContentDO> courseContentDOS = this.baseMapper.selectList(new QueryWrapper<CourseContentDO>()
.lambda()
.eq(CourseContentDO::getCourseId,courseContentDO.getCourseId())
.orderByDesc(CourseContentDO::getOrderNo));
Integer orderNoTmp = this.baseMapper.selectMaxOrderNo(courseContentDO.getCourseId());
int orderNo = 1 ;
if (courseContentDOS.size()>0){
orderNo = courseContentDOS.get(0).getOrderNo()+1;
if (null!=orderNoTmp){
orderNo = orderNoTmp+1;
}
courseContentDO.setOrderNo(orderNo);
this.baseMapper.insert(courseContentDO);
return ConstantUtils.ADD_SUCCESS;
}
@Async
public String updateContent(CourseContentDO courseContentDO){
List<CourseContentDO> courseContentDOS = this.baseMapper.selectList(new QueryWrapper<CourseContentDO>()
int count = this.baseMapper.selectCount(new QueryWrapper<CourseContentDO>()
.lambda()
.eq(CourseContentDO::getCourseId,courseContentDO.getCourseId())
.eq(CourseContentDO::getContent,courseContentDO.getContent()));
.eq(CourseContentDO::getContent,courseContentDO.getContent())
.ne(CourseContentDO::getId,courseContentDO.getId()));
if (courseContentDOS.size()>0){
if (count>0){
throw new HttpException(40001);
}
this.baseMapper.updateById(courseContentDO);
......
......@@ -30,10 +30,9 @@ public class CourseDictServiceImpl extends ServiceImpl<CourseDictMapper, CourseD
@Autowired
private RoleAdministerMappingMapper roleAdministerMappingMapper;
@Async
public String addCourse(CourseDictDO courseDictDO) {
int count = 0;
int count;
if (null != courseDictDO.getCompanyId()) {
count = this.baseMapper.selectCount(new QueryWrapper<CourseDictDO>()
......@@ -56,7 +55,6 @@ public class CourseDictServiceImpl extends ServiceImpl<CourseDictMapper, CourseD
return ConstantUtils.ADD_SUCCESS;
}
@Async
public String deleteCourse(CourseDictDO courseDictDO) {
this.baseMapper.deleteById(courseDictDO.getId());
return ConstantUtils.DELETE_SUCCESS;
......@@ -72,6 +70,7 @@ public class CourseDictServiceImpl extends ServiceImpl<CourseDictMapper, CourseD
.eq(RoleAdministerMappingDO::getRoleId,1));
if (count > 0){
//后台管理员
queryCoursesDTO.setCompanyId(null);
}
......@@ -80,7 +79,7 @@ public class CourseDictServiceImpl extends ServiceImpl<CourseDictMapper, CourseD
@Async
public String updateCourses(CourseDictDO courseDictDO) {
int count = 0;
int count;
if (null != courseDictDO.getCompanyId()) {
count = this.baseMapper.selectCount(new QueryWrapper<CourseDictDO>()
......
package com.subsidy.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.subsidy.dto.exercise.GetAllExercisesDTO;
import com.subsidy.dto.exercise.GetPaperExerciseDTO;
import com.subsidy.dto.exercise.SubmitDTO;
import com.subsidy.mapper.ExerciseDictMapper;
import com.subsidy.mapper.ExerciseDoneHistoryMapper;
import com.subsidy.mapper.ExerciseDoneResultMapper;
import com.subsidy.model.CourseDictDO;
import com.subsidy.model.ExerciseDictDO;
import com.subsidy.model.ExerciseDoneHistoryDO;
import com.subsidy.model.ExerciseDoneResultDO;
import com.subsidy.service.ExerciseDictService;
import com.subsidy.util.ConstantUtils;
import com.subsidy.util.MathUtil;
import com.subsidy.vo.course.ExerciseVO;
import com.subsidy.vo.exercise.GetPaperExerciseVO;
import com.subsidy.vo.exercise.MemberExerciseVO;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.List;
/**
......@@ -46,67 +39,31 @@ public class ExerciseDictServiceImpl extends ServiceImpl<ExerciseDictMapper, Exe
@Autowired
private ExerciseDoneHistoryMapper exerciseDoneHistoryMapper;
public IPage<ExerciseDictDO> getAllExercises(GetAllExercisesDTO getAllExercisesDTO) {
Page pager = new Page(getAllExercisesDTO.getPageNum(), getAllExercisesDTO.getPageSize());
return this.baseMapper.selectPage(pager, new QueryWrapper<ExerciseDictDO>()
.lambda()
.eq(ExerciseDictDO::getCourseId, getAllExercisesDTO.getCourseId())
.like(ExerciseDictDO::getDifficulty, getAllExercisesDTO.getDifficulty())
.like(ExerciseDictDO::getExerciseType, getAllExercisesDTO.getExerciseType())
.like(ExerciseDictDO::getTitle, getAllExercisesDTO.getTitle())
.orderByAsc(ExerciseDictDO::getOrderNo));
}
@Async
public String addExercise(ExerciseDictDO exerciseDictDO){
List<ExerciseDictDO> exerciseDictDOS = this.baseMapper.selectList(new QueryWrapper<ExerciseDictDO>()
.lambda()
.eq(ExerciseDictDO::getCourseId,exerciseDictDO.getCourseId())
.orderByDesc(ExerciseDictDO::getOrderNo));
Integer orderNoTmp = this.baseMapper.getMaximumNo(exerciseDictDO.getPaperId());
int orderNo = 1;
if (exerciseDictDOS.size() > 0) {
orderNo = exerciseDictDOS.get(0).getOrderNo() + 1;
if (null!= orderNoTmp) {
orderNo = orderNoTmp + 1;
}
exerciseDictDO.setOrderNo(orderNo);
this.baseMapper.insert(exerciseDictDO);
return ConstantUtils.ADD_SUCCESS;
}
@Async
public String deleteExercise(ExerciseDictDO exerciseDictDO) {
this.baseMapper.deleteById(exerciseDictDO.getId());
return ConstantUtils.DELETE_SUCCESS;
}
@Async
public String updateExercise(ExerciseDictDO exerciseDictDO) {
this.baseMapper.updateById(exerciseDictDO);
return ConstantUtils.SET_SUCCESS;
}
public List<ExerciseVO> getCourseExercises(CourseDictDO courseDictDO) {
List<ExerciseVO> exerciseVOS = new ArrayList<>();
List<ExerciseDictDO> exerciseDictDOS = this.baseMapper.selectList(new QueryWrapper<ExerciseDictDO>()
.lambda()
.eq(ExerciseDictDO::getCourseId, courseDictDO.getId()));
for (ExerciseDictDO exerciseDictDO : exerciseDictDOS) {
ExerciseVO exerciseVO = new ExerciseVO();
BeanUtils.copyProperties(exerciseDictDO, exerciseVO);
exerciseVOS.add(exerciseVO);
}
return exerciseVOS;
}
@Transactional(rollbackFor = Exception.class)
@Async
public Long submit(SubmitDTO submitDTO) {
ExerciseDoneResultDO exerciseDoneResultDO = new ExerciseDoneResultDO();
......@@ -134,11 +91,7 @@ public class ExerciseDictServiceImpl extends ServiceImpl<ExerciseDictMapper, Exe
exerciseDoneResultDO.setLength(submitDTO.getLength());
int score = MathUtil.intDivFloorPercent(rightCounts, memberExerciseVOS.size());
exerciseDoneResultDO.setScore(score);
if (score >= 60) {
exerciseDoneResultDO.setResult("合格");
} else {
exerciseDoneResultDO.setResult("不合格");
}
exerciseDoneResultDO.setResult(score>=60?"合格":"不合格");
exerciseDoneResultMapper.insert(exerciseDoneResultDO);
......
......@@ -78,12 +78,6 @@ public class ExerciseDoneResultServiceImpl extends ServiceImpl<ExerciseDoneResul
exerciseDoneHistoryMapper.insert(ex);
}
// SignInRecordDO signInRecordDO = new SignInRecordDO();
// signInRecordDO.setClassId(s.getClassId());
// signInRecordDO.setMemberId(s.getMemberId());
// signInRecordDO.setCreateDate(LocalDateTime.parse(s.getSignInDate().replace("2021-12-17","2021-12-26"),df));
// signInRecordDO.setSignInDate(LocalDateTime.parse(s.getSignInDate().replace("2021-12-17","2021-12-26"),df));
});
}catch (Exception ex){
ex.printStackTrace();
......
......@@ -23,25 +23,19 @@ import java.util.List;
public class FileDictServiceImpl extends ServiceImpl<FileDictMapper, FileDictDO> implements FileDictService {
public List<FileDictDO> getContendFiles(FileDictDO fileDictDO) {
return this.baseMapper.selectList(new QueryWrapper<FileDictDO>()
.lambda()
.eq(FileDictDO::getContentId,fileDictDO.getContentId())
.like(FileDictDO::getFileName,fileDictDO.getFileName()));
return this.baseMapper.selectFiles(fileDictDO.getContentId(),fileDictDO.getFileName());
}
@Async
public String deleteFile(FileDictDO fileDictDO) {
this.baseMapper.deleteById(fileDictDO.getId());
return ConstantUtils.DELETE_SUCCESS;
}
@Async
public String addFile(FileDictDO fileDictDO) {
this.baseMapper.insert(fileDictDO);
return ConstantUtils.ADD_SUCCESS;
}
@Async
public String updateFile(FileDictDO fileDictDO) {
this.baseMapper.updateById(fileDictDO);
return ConstantUtils.SET_SUCCESS;
......
......@@ -37,6 +37,7 @@ import com.subsidy.model.VodDictDO;
import com.subsidy.model.VodPlayHistoryDO;
import com.subsidy.service.MemberService;
import com.subsidy.util.ConstantUtils;
import com.subsidy.util.DateFormatUtil;
import com.subsidy.util.RedisUtil;
import com.subsidy.vo.administer.UserRoleVO;
import com.subsidy.vo.member.ContentFilesVO;
......@@ -50,6 +51,7 @@ import com.subsidy.vo.member.StudyPageVO;
import com.subsidy.vo.paper.QueryPapersVO;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.AsyncResult;
import org.springframework.stereotype.Service;
......@@ -58,6 +60,7 @@ import org.springframework.transaction.annotation.Transactional;
import java.time.Duration;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
......@@ -104,6 +107,9 @@ public class MemberServiceImpl extends ServiceImpl<MemberMapper, MemberDO> imple
@Autowired
private RedisUtil redisUtil;
@Autowired
private MongoTemplate mongoTemplate;
public IPage<GetAllVO> getAll(GetAllDTO getAllDTO) {
Page pager = new Page(getAllDTO.getPageNum(), getAllDTO.getPageSize());
IPage iPage = this.baseMapper.getMembers(pager, getAllDTO.getDepartmentId(), getAllDTO.getUserName(), getAllDTO.getStatus());
......@@ -155,7 +161,7 @@ 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);
redisUtil.set(RedisPrefixConstant.SUBSIDY_COMPANY_MEMBER_PREFIX + memberDO.getCompanyId() + ":" + memberDO.getAccountName(), memberDO);
//部门
List<Long> longs = addMemberDTO.getDepartmentIds();
......@@ -194,7 +200,7 @@ public class MemberServiceImpl extends ServiceImpl<MemberMapper, MemberDO> imple
MemberDO memberDO = new MemberDO();
BeanUtils.copyProperties(addMemberDTO, memberDO);
this.baseMapper.updateById(memberDO);
redisUtil.set(RedisPrefixConstant.SUBSIDY_COMPANY_MEMBER_PREFIX + memberDO.getCompanyId() + memberDO.getAccountName(), memberDO);
redisUtil.set(RedisPrefixConstant.SUBSIDY_COMPANY_MEMBER_PREFIX + memberDO.getCompanyId() + ":" + memberDO.getAccountName(), memberDO);
if (null != addMemberDTO.getDepartmentIds()) {
memberDepartmentMappingMapper.delete(new QueryWrapper<MemberDepartmentMappingDO>()
......@@ -224,14 +230,15 @@ 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);
redisUtil.set(RedisPrefixConstant.SUBSIDY_MEMBER_LOGIN_PREFIX + memberDO.getId() + "_" + memberDO.getUserName() + "_" + companyDictDO.getCompanyName() + "_" + LocalDateTime.now(), oprMemDictDO);
oprMemDictDO.setCreateDate(System.currentTimeMillis()+"");
oprMemDictDO.setLoginDateFormat(DateFormatUtil.format(new Date(), "yyyyMMdd"));
mongoTemplate.insert(oprMemDictDO);
//redisUtil.set(RedisPrefixConstant.SUBSIDY_MEMBER_LOGIN_PREFIX + memberDO.getId() + ":" + memberDO.getUserName() + ":" + companyDictDO.getCompanyName() + ":" + LocalDateTime.now(), oprMemDictDO);
throw new HttpException(10013);
}
......@@ -239,7 +246,7 @@ 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);
redisUtil.set(RedisPrefixConstant.SUBSIDY_COMPANY_MEMBER_PREFIX + memberDO.getCompanyId() + ":" + memberDO.getAccountName(), memberDO);
}
BeanUtils.copyProperties(memberDO, userRoleVO);
......@@ -250,17 +257,21 @@ public class MemberServiceImpl extends ServiceImpl<MemberMapper, MemberDO> imple
oprMemDictDO.setUserId(memberDO.getId());
oprMemDictDO.setOprType("登录");
oprMemDictDO.setResult(0);
oprMemDictDO.setCreateDate(LocalDateTime.now());
redisUtil.set(RedisPrefixConstant.SUBSIDY_MEMBER_LOGIN_PREFIX + memberDO.getId() + LocalDateTime.now(), oprMemDictDO);
oprMemDictDO.setCreateDate(System.currentTimeMillis()+"");
oprMemDictDO.setLoginDateFormat(DateFormatUtil.format(new Date(), "yyyyMMdd"));
mongoTemplate.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);
//审计日志
redisUtil.set(RedisPrefixConstant.SUBSIDY_MEMBER_LOGIN_PREFIX + memberDO.getId() + LocalDateTime.now(), oprMemDictDO);
oprMemDictDO.setCreateDate(System.currentTimeMillis()+"");
oprMemDictDO.setLoginDateFormat(DateFormatUtil.format(new Date(), "yyyyMMdd"));
//redisUtil.set(RedisPrefixConstant.SUBSIDY_MEMBER_LOGIN_PREFIX + memberDO.getId() + ":" + LocalDateTime.now(), oprMemDictDO);
mongoTemplate.insert(oprMemDictDO);
return userRoleVO;
}
......@@ -282,15 +293,17 @@ public class MemberServiceImpl extends ServiceImpl<MemberMapper, MemberDO> imple
}
}
if (memberDO.getPassword().equals(passwordLoginDTO.getPassword()) && 1 == memberDO.getFirstLogin() && "冻结".equals(memberDO.getStatus())) {
if (memberDO.getPassword().equals(passwordLoginDTO.getPassword()) && 1 == memberDO.getFirstLogin() && !"冻结".equals(memberDO.getStatus())) {
MemberVO memberVO = new MemberVO();
BeanUtils.copyProperties(memberDO, memberVO);
OprMemDictDO oprMemDictDO = new OprMemDictDO();
oprMemDictDO.setUserId(memberDO.getId());
oprMemDictDO.setOprType("登录");
oprMemDictDO.setResult(1);
oprMemDictDO.setCreateDate(LocalDateTime.now());
redisUtil.set(RedisPrefixConstant.SUBSIDY_MEMBER_LOGIN_PREFIX + memberDO.getId() + "_" + System.currentTimeMillis(), 1);
oprMemDictDO.setCreateDate(System.currentTimeMillis()+"");
oprMemDictDO.setLoginDateFormat(DateFormatUtil.format(new Date(), "yyyyMMdd"));
mongoTemplate.insert(oprMemDictDO);
//redisUtil.set(RedisPrefixConstant.SUBSIDY_MEMBER_LOGIN_PREFIX + memberDO.getId() + ":" + System.currentTimeMillis(), 1);
return memberVO;
} else {
if (!memberDO.getPassword().equals(passwordLoginDTO.getPassword())) {
......@@ -298,7 +311,10 @@ public class MemberServiceImpl extends ServiceImpl<MemberMapper, MemberDO> imple
oprMemDictDO.setUserId(memberDO.getId());
oprMemDictDO.setOprType("登录");
oprMemDictDO.setResult(0);
redisUtil.set(RedisPrefixConstant.SUBSIDY_MEMBER_LOGIN_PREFIX + memberDO.getId() + LocalDateTime.now(), oprMemDictDO);
oprMemDictDO.setCreateDate(System.currentTimeMillis()+"");
oprMemDictDO.setLoginDateFormat(DateFormatUtil.format(new Date(), "yyyyMMdd"));
mongoTemplate.insert(oprMemDictDO);
//redisUtil.set(RedisPrefixConstant.SUBSIDY_MEMBER_LOGIN_PREFIX + memberDO.getId() + ":" + System.currentTimeMillis(), oprMemDictDO);
throw new HttpException(10016);
}
if (0 == memberDO.getFirstLogin()) {
......@@ -306,8 +322,10 @@ public class MemberServiceImpl extends ServiceImpl<MemberMapper, MemberDO> imple
oprMemDictDO.setUserId(memberDO.getId());
oprMemDictDO.setOprType("登录");
oprMemDictDO.setResult(0);
oprMemDictDO.setCreateDate(LocalDateTime.now());
redisUtil.set(RedisPrefixConstant.SUBSIDY_MEMBER_LOGIN_PREFIX + memberDO.getId() + "_" + System.currentTimeMillis(), 0);
oprMemDictDO.setCreateDate(System.currentTimeMillis()+"");
oprMemDictDO.setLoginDateFormat(DateFormatUtil.format(new Date(), "yyyyMMdd"));
mongoTemplate.insert(oprMemDictDO);
//redisUtil.set(RedisPrefixConstant.SUBSIDY_MEMBER_LOGIN_PREFIX + memberDO.getId() + ":" + System.currentTimeMillis(), 0);
throw new HttpException(10015);
}
if ("冻结".equals(memberDO.getStatus())) {
......@@ -332,7 +350,6 @@ public class MemberServiceImpl extends ServiceImpl<MemberMapper, MemberDO> imple
List<StudyPageVO> studyPageVOS = this.baseMapper.studyPage(memberDO);
final ExecutorService newCachedThreadPool = Executors.newCachedThreadPool();
for (StudyPageVO studyPageVO : studyPageVOS) {
//查看课程下有几节课
List<VodDictDO> vodDictDOS = courseContentMapper.getCourseVods(studyPageVO.getId());
......@@ -377,13 +394,13 @@ public class MemberServiceImpl extends ServiceImpl<MemberMapper, MemberDO> imple
for (CourseContentDO courseContentDO : courseContentDOS) {
ContentVodVO contentVodVO = new ContentVodVO();
contentVodVO.setContent(courseContentDO.getContent());
contentVodVO.setMemberVodVOS(courseContentMapper.contentVodProcess(courseContentDO.getId(),contentVodDTO.getMemberId()));
contentVodVO.setMemberVodVOS(courseContentMapper.contentVodProcess(courseContentDO.getId(), contentVodDTO.getMemberId()));
contentVodVOS.add(contentVodVO);
}
contentVodNewVO.setContentVodVOS(contentVodVOS);
//最新的视频记录
ContentVodNewVO contentVodNewVO1 = vodPlayHistoryMapper.memberRecentPlay(contentVodDTO.getClassId(),contentVodDTO.getMemberId());
ContentVodNewVO contentVodNewVO1 = vodPlayHistoryMapper.memberRecentPlay(contentVodDTO.getClassId(), contentVodDTO.getMemberId());
contentVodNewVO.setId(contentVodNewVO1.getId());
contentVodNewVO.setPlayRecord(contentVodNewVO.getPlayRecord());
return contentVodNewVO;
......@@ -437,20 +454,15 @@ public class MemberServiceImpl extends ServiceImpl<MemberMapper, MemberDO> imple
Integer cnt = paperDictMapper.completeCount(queryPapersVO.getId());
queryPapersVO.setCompleteCnt(cnt);
//自己成绩
List<ExerciseDoneResultDO> exerciseDoneResultDOS = exerciseDoneResultMapper.selectList(new QueryWrapper<ExerciseDoneResultDO>()
.lambda()
.eq(ExerciseDoneResultDO::getMemberId, memberId)
.eq(ExerciseDoneResultDO::getPaperId, queryPapersVO.getId())
.orderByDesc(ExerciseDoneResultDO::getScore));
if (exerciseDoneResultDOS.size() > 0) {
queryPapersVO.setRightCounts(exerciseDoneResultDOS.get(0).getRightCounts());
queryPapersVO.setTotalCount(exerciseDoneResultDOS.get(0).getTotalCounts());
queryPapersVO.setResult(exerciseDoneResultDOS.get(0).getResult());
ExerciseDoneResultDO exerciseDoneResultDO = exerciseDoneResultMapper.getMaxScorePaper(queryPapersVO.getId(),memberId);
if (null!=exerciseDoneResultDO) {
queryPapersVO.setRightCounts(exerciseDoneResultDO.getRightCounts());
queryPapersVO.setTotalCount(exerciseDoneResultDO.getTotalCounts());
queryPapersVO.setResult(exerciseDoneResultDO.getResult());
} else {
queryPapersVO.setResult("待完成");
}
//截止时间
queryPapersVO.setEndDate(classDictDO.getEndDate());
}
......@@ -466,81 +478,36 @@ public class MemberServiceImpl extends ServiceImpl<MemberMapper, MemberDO> imple
GetStudyInfoVO getStudyInfoVO = new GetStudyInfoVO();
MemberDO memberDO1 = this.baseMapper.selectById(memberDO.getId());
final ExecutorService newCachedThreadPool = Executors.newCachedThreadPool();
//多个任务
newCachedThreadPool.execute(() ->
getStudyInfoTask1(memberDO1.getId(), getStudyInfoVO));
newCachedThreadPool.execute(() ->
getStudyInfoTask2(memberDO1, getStudyInfoVO));
//执行后不再接收新任务,如果里面有任务,就执行完
newCachedThreadPool.shutdown();
try {
while (true) {
//等待所有任务都结束了继续执行
if (newCachedThreadPool.isTerminated()) {
break;
}
}
} catch (Exception ex) {
ex.printStackTrace();
}
return getStudyInfoVO;
}
public Future<GetStudyInfoVO> getStudyInfoTask1(Long memberId, GetStudyInfoVO getStudyInfoVO) {
//已学课程
List<ClassMemberMappingDO> classMemberMappingDOS = classMemberMappingMapper.selectList(new QueryWrapper<ClassMemberMappingDO>()
.lambda()
.eq(ClassMemberMappingDO::getMemberId, memberId));
.eq(ClassMemberMappingDO::getMemberId, memberDO.getId()));
/**
* 遍历课程,里面的视频都看过80% 则表示已学完
* 遍历课程,累计学习时长超过视频时长 则表示已学完
*/
int i = 0; //已学课程
for (ClassMemberMappingDO classMemberMappingDO : classMemberMappingDOS) {
List<VodDictDO> vodDictDOS = classDictMapper.getClassVods(classMemberMappingDO.getClassId());
for (VodDictDO vodDictDO : vodDictDOS) {
List<VodPlayHistoryDO> vodPlayHistoryDOS = vodPlayHistoryMapper.selectList(new QueryWrapper<VodPlayHistoryDO>()
.lambda()
.eq(VodPlayHistoryDO::getMemberId, memberId)
.eq(VodPlayHistoryDO::getVodId, vodDictDO.getId())
.orderByDesc(VodPlayHistoryDO::getPlayRecord));
if (vodPlayHistoryDOS.size() > 0) {
if (vodPlayHistoryDOS.get(0).getPlayRecord() < vodDictDO.getVodLength() * 0.8) {
int playLength = vodPlayHistoryMapper.memberVodTotalLength(memberDO.getId(), vodDictDO.getId());
if (playLength < vodDictDO.getVodLength()) {
break;
}
}
}
i++;
}
getStudyInfoVO.setStudyCourse(i);
return new AsyncResult<>(getStudyInfoVO);
}
public Future<GetStudyInfoVO> getStudyInfoTask2(MemberDO memberDO, GetStudyInfoVO getStudyInfoVO) {
//累计学习时长
int studyLength = 0;
List<VodPlayHistoryDO> vodPlayHistoryDOS = vodPlayHistoryMapper.selectList(new QueryWrapper<VodPlayHistoryDO>()
.lambda()
.eq(VodPlayHistoryDO::getMemberId, memberDO.getId()));
for (VodPlayHistoryDO vodPlayHistoryDO : vodPlayHistoryDOS) {
studyLength += vodPlayHistoryDO.getPlayLength();
}
int studyLength = vodPlayHistoryMapper.memberTotalLength(memberDO.getId());
getStudyInfoVO.setStudyLength(studyLength);
//第几天
long diff = Duration.between(memberDO.getCreateDate(), LocalDateTime.now()).toDays();
MemberDO memberDO1 = this.baseMapper.selectById(memberDO.getId());
long diff = Duration.between(memberDO1.getCreateDate(), LocalDateTime.now()).toDays();
getStudyInfoVO.setDiff(diff);
return new AsyncResult(getStudyInfoVO);
}
public ExerciseDoneResultDO getDoneResult(ExerciseDoneResultDO exerciseDoneResultDO) {
return exerciseDoneResultMapper.selectById(exerciseDoneResultDO.getId());
return getStudyInfoVO;
}
public String checkTimes(ExerciseDoneResultDO exerciseDoneResultDO) {
......
......@@ -3,13 +3,27 @@ package com.subsidy.service.impl;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.subsidy.dto.opr.GetHistoryDTO;
import com.subsidy.model.OprAdmDictDO;
import com.subsidy.mapper.AdministerMapper;
import com.subsidy.mapper.CompanyDictMapper;
import com.subsidy.model.AdministerDO;
import com.subsidy.model.CompanyDictDO;
import com.subsidy.mongodb.OprAdmDictDO;
import com.subsidy.mapper.OprAdmDictMapper;
import com.subsidy.mongodb.PageVO;
import com.subsidy.service.OprAdmDictService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.subsidy.util.MongoUtil;
import com.subsidy.vo.opr.GetHistoryVO;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
/**
* <p>
* 审计表 服务实现类
......@@ -21,10 +35,44 @@ import org.springframework.stereotype.Service;
@Service
public class OprAdmDictServiceImpl extends ServiceImpl<OprAdmDictMapper, OprAdmDictDO> implements OprAdmDictService {
@Autowired
private MongoTemplate mongoTemplate;
@Autowired
private MongoUtil mongoUtil;
@Autowired
private AdministerMapper administerMapper;
@Autowired
private CompanyDictMapper companyDictMapper;
public PageVO<GetHistoryVO> getHistory(GetHistoryDTO getHistoryDTO){
PageVO pageVO = new PageVO();
List<GetHistoryVO> getHistoryVOS = new ArrayList<>();
//可累加条件
Query query = new Query(Criteria.where("userName").regex(getHistoryDTO.getUserName())
.and("loginDateFormat").gte(getHistoryDTO.getStartDate())
.and("loginDateFormat").lte(getHistoryDTO.getEndDate()));
Long count = mongoTemplate.count(query,OprAdmDictDO.class);
mongoUtil.start(getHistoryDTO.getPageNum(),getHistoryDTO.getPageSize(),query);
List<OprAdmDictDO> oprAdmDictDOS = mongoTemplate.find(query,OprAdmDictDO.class);
for (OprAdmDictDO oprAdmDictDO : oprAdmDictDOS){
AdministerDO administerDO = administerMapper.selectById(oprAdmDictDO.getUserId());
CompanyDictDO companyDictDO = companyDictMapper.selectById(administerDO.getCompanyId());
GetHistoryVO getHistoryVO = new GetHistoryVO();
BeanUtils.copyProperties(oprAdmDictDO,getHistoryVO);
getHistoryVO.setCompanyName(companyDictDO.getCompanyName());
getHistoryVO.setUserName(administerDO.getUserName());
getHistoryVOS.add(getHistoryVO);
}
pageVO.setRecords(getHistoryVOS);
pageVO.setTotal(count);
public IPage<GetHistoryVO> getHistory(GetHistoryDTO getHistoryDTO){
Page pager = new Page(getHistoryDTO.getPageNum(), getHistoryDTO.getPageSize());
return this.baseMapper.getHistory(pager,getHistoryDTO.getUserName(),getHistoryDTO.getStartDate(),getHistoryDTO.getEndDate());
return pageVO;
}
}
......@@ -9,31 +9,29 @@ import com.subsidy.dto.member.GetMemberSignInfoDTO;
import com.subsidy.dto.sign.ClassSignInfoDTO;
import com.subsidy.mapper.ClassHourDictMapper;
import com.subsidy.mapper.ClassMemberMappingMapper;
import com.subsidy.mapper.MemberMapper;
import com.subsidy.mapper.SignInRecordMapper;
import com.subsidy.mapper.VodPlayHistoryMapper;
import com.subsidy.model.ClassDictDO;
import com.subsidy.model.ClassHourDictDO;
import com.subsidy.model.MemberDO;
import com.subsidy.model.SignInRecordDO;
import com.subsidy.model.VodDictDO;
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.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.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>
......@@ -56,6 +54,9 @@ public class SignInRecordServiceImpl extends ServiceImpl<SignInRecordMapper, Sig
private RedisUtil redisUtil;
@Autowired
private MemberMapper memberMapper;
@Autowired
private ClassHourDictMapper classHourDictMapper;
public IPage<GetMemberSignInfoVO> getMemberSignInfo(GetMemberSignInfoDTO getMemberSignInfoDTO) {
......@@ -73,7 +74,7 @@ public class SignInRecordServiceImpl extends ServiceImpl<SignInRecordMapper, Sig
List<ClassDictDO> classDictDOS = classMemberMappingMapper.getMemberClass(signInRecordDO.getMemberId());
for (ClassDictDO classDictDO : classDictDOS) {
redisUtil.set(RedisPrefixConstant.SUBSIDY_SIGN_INFO_PREFIX + "memberId_" + signInRecordDO.getMemberId() + "_classId_" + classDictDO.getId() + "_" + DateFormatUtil.format(new Date(), "yyyyMMdd") + "_" + System.currentTimeMillis(), null);
redisUtil.set(RedisPrefixConstant.SUBSIDY_SIGN_INFO_PREFIX + "memberId:" + signInRecordDO.getMemberId() + ":classId:" + classDictDO.getId() + ":" + DateFormatUtil.format(new Date(), "yyyyMMdd") + ":" + System.currentTimeMillis(), null);
}
return ConstantUtils.ADD_SUCCESS;
......@@ -88,24 +89,21 @@ public class SignInRecordServiceImpl extends ServiceImpl<SignInRecordMapper, Sig
final ExecutorService newCachedThreadPool = Executors.newCachedThreadPool();
newCachedThreadPool.shutdown();
for (ClassSignInfoVO classSignInfoVO : classSignInfoVOS) {
newCachedThreadPool.submit(()->classSignInfoTask(classSignInfoVO));
newCachedThreadPool.execute(()->classSignInfoTask(classSignInfoVO));
}
newCachedThreadPool.shutdown();
classSignInfoVOIPage.setRecords(classSignInfoVOS);
return classSignInfoVOIPage;
}
public Future<ClassSignInfoVO> classSignInfoTask(ClassSignInfoVO classSignInfoVO){
public void classSignInfoTask(ClassSignInfoVO classSignInfoVO){
ClassSignInfoVO classSignInfoVO1 = vodPlayHistoryMapper.classStudyHistory(classSignInfoVO.getClassId());
BeanUtils.copyProperties(classSignInfoVO1,classSignInfoVO);
//平均签到数 向下取整
long signCount = redisUtil.scan(RedisPrefixConstant.SUBSIDY_SIGN_INFO_PREFIX + "*_classId_" + classSignInfoVO.getClassId() + "_*").stream().count();
long signCount = redisUtil.scan(RedisPrefixConstant.SUBSIDY_SIGN_INFO_PREFIX + "*:classId:" + classSignInfoVO.getClassId() + ":*").stream().count();
classSignInfoVO.setAvgSignCount(MathUtil.intDivCeil(signCount, classSignInfoVO1.getMemberCount()));
return new AsyncResult<>(classSignInfoVO);
}
public SignInStatusVO signInStatus(SignInRecordDO signInRecordDO) {
......@@ -113,10 +111,10 @@ public class SignInRecordServiceImpl extends ServiceImpl<SignInRecordMapper, Sig
SignInStatusVO signInStatusVO = new SignInStatusVO();
Boolean flag = true; // 已经签过到了
signInStatusVO.setStatus(flag);
//获取有效课程
long count = classMemberMappingMapper.getMemberClassCount(signInRecordDO.getMemberId());
long size = redisUtil.scan(RedisPrefixConstant.SUBSIDY_SIGN_INFO_PREFIX + "memberId_" + signInRecordDO.getMemberId() + "*_" + DateFormatUtil.format(new Date(), "yyyyMMdd")+"*").stream().count();
long size = redisUtil.scan(RedisPrefixConstant.SUBSIDY_SIGN_INFO_PREFIX + "memberId:" + signInRecordDO.getMemberId() + "*:" + DateFormatUtil.format(new Date(), "yyyyMMdd")+"*").stream().count();
if (size != count) {
signInStatusVO.setStatus(flag);
......@@ -136,13 +134,13 @@ public class SignInRecordServiceImpl extends ServiceImpl<SignInRecordMapper, Sig
//预写公司设置数据
List<ClassHourDictDO> classHourDictDOS = classHourDictMapper.selectList(null);
for (ClassHourDictDO classHourDictDO : classHourDictDOS) {
redisUtil.set("subsidySettings_" + classHourDictDO.getCompanyId(), classHourDictDO);
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);
// redisUtil.set(RedisPrefixConstant.SUBSIDY_COMPANY_MEMBER_PREFIX+memberDO.getCompanyId()+":"+memberDO.getAccountName(),memberDO);
//}
}
......
package com.subsidy.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.subsidy.mapper.ClassDictMapper;
import com.subsidy.mapper.ClassMemberMappingMapper;
import com.subsidy.mapper.CourseContentMapper;
import com.subsidy.mapper.SignInRecordMapper;
import com.subsidy.model.ClassDictDO;
import com.subsidy.model.ClassMemberMappingDO;
import com.subsidy.model.SignInRecordDO;
import com.subsidy.model.VodDictDO;
import com.subsidy.model.VodPlayHistoryDO;
import com.subsidy.mapper.VodPlayHistoryMapper;
import com.subsidy.service.VodPlayHistoryService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.subsidy.util.ConstantUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.Arrays;
import java.util.List;
import java.util.Random;
/**
* <p>
* 视频播放历史记录表 服务实现类
......@@ -19,18 +35,104 @@ import org.springframework.stereotype.Service;
@Service
public class VodPlayHistoryServiceImpl extends ServiceImpl<VodPlayHistoryMapper, VodPlayHistoryDO> implements VodPlayHistoryService {
@Async
@Autowired
private ClassMemberMappingMapper classMemberMappingMapper;
@Autowired
private ClassDictMapper classDictMapper;
@Autowired
private CourseContentMapper courseContentMapper;
@Autowired
private SignInRecordMapper signInRecordMapper;
@Autowired
private VodPlayHistoryMapper vodPlayHistoryMapper;
public String insertHistory(VodPlayHistoryDO vodPlayHistoryDO) {
vodPlayHistoryDO.setPlayCount(1);
this.baseMapper.insert(vodPlayHistoryDO);
return ConstantUtils.ADD_SUCCESS;
}
@Async
public String insertHistoryNew(VodPlayHistoryDO vodPlayHistoryDO){
public String insertHistoryNew(VodPlayHistoryDO vodPlayHistoryDO) {
vodPlayHistoryDO.setPlayCount(1);
this.baseMapper.insert(vodPlayHistoryDO);
return ConstantUtils.ADD_SUCCESS;
}
public void dataFix() {
//班级ids
List<String> classIds = Arrays.asList(new String[]{"28"});
for (String str : classIds) {
ClassDictDO classDictDO = classDictMapper.selectById(str);
//找到班级里的学生
List<ClassMemberMappingDO> classMemberMappingDOS = classMemberMappingMapper.selectList(new QueryWrapper<ClassMemberMappingDO>()
.lambda()
.eq(ClassMemberMappingDO::getClassId, Long.valueOf(str)));
//查找课程里的所有视频
List<VodDictDO> vodDictDOS = courseContentMapper.getCourseVods(classDictDO.getCourseId());
//遍历班级学生
for (ClassMemberMappingDO classMemberMappingDO : classMemberMappingDOS) {
//查询这个人 这节课 排序
List<SignInRecordDO> signInRecordDOS = signInRecordMapper.selectList(new QueryWrapper<SignInRecordDO>()
.lambda()
.eq(SignInRecordDO::getMemberId, classMemberMappingDO.getMemberId())
.eq(SignInRecordDO::getClassId, str)
.orderByAsc(SignInRecordDO::getSignInDate));
//根据签到时间,对学生学习的课程做插入操作
for (SignInRecordDO signInRecordDO : signInRecordDOS) {
LocalDateTime signInDate = signInRecordDO.getSignInDate();
if (signInDate.getHour() <= 15 && signInDate.getHour() >= 6) {
Random random = new Random();
int totalDailyLength = random.nextInt(4);
//查找这个人应该学的课程
for (VodDictDO vodDictDO : vodDictDOS) {
//从历史记录里找中这个人有没有学过
if (totalDailyLength<=7*60*60){
Integer count = vodPlayHistoryMapper.selectCount(new QueryWrapper<VodPlayHistoryDO>()
.lambda()
.eq(VodPlayHistoryDO::getMemberId, classMemberMappingDO.getMemberId())
.eq(VodPlayHistoryDO::getClassId, str)
.eq(VodPlayHistoryDO::getVodId, vodDictDO.getId()));
if (count == 0 && signInDate.plusSeconds(totalDailyLength).getHour() < 23) {
totalDailyLength+=vodDictDO.getVodLength();
VodPlayHistoryDO vodPlayHistoryDO = new VodPlayHistoryDO();
vodPlayHistoryDO.setPlayCount(1);
vodPlayHistoryDO.setClassId(Long.valueOf(str));
vodPlayHistoryDO.setMemberId(classMemberMappingDO.getMemberId());
vodPlayHistoryDO.setPlayRecord(vodDictDO.getVodLength());
vodPlayHistoryDO.setPlayLength(vodDictDO.getVodLength());
vodPlayHistoryDO.setVodId(vodDictDO.getId());
vodPlayHistoryDO.setPlayDate(signInDate.plusSeconds(totalDailyLength));
//vodPlayHistoryDO.setCreateDate(signInDate.plusSeconds(totalDailyLength));
vodPlayHistoryMapper.insert(vodPlayHistoryDO);
Random random1 = new Random();
totalDailyLength+=random1.nextInt(5);
}
}
}
}
}
}
}
}
public static void main(String[] args) {
Random random = new Random();
System.out.println();
}
}
......@@ -52,8 +52,6 @@ public class ConstantUtils {
public static final String COMPRESS_SUCCESS = "压缩成功";
public static final String SCHOOL = "上海市市西中学";
public static final String CHECK_STATUS = "审核通过";
/**
......
......@@ -14,6 +14,6 @@ public class ExcelFormatUtils {
public static final List<String> answersList = Arrays.asList("序号", "提问", "答疑", "提问时间", "提问成员", "答疑时间");
public static final List<String> studyLogList = Arrays.asList("开始时间","结束时间","操作对象","类型","平台","学习时长","有效时长");
public static final List<String> studyLogList = Arrays.asList("开始时间","结束时间","操作对象","类型","平台","学习时长","累计有效时长");
}
......@@ -137,17 +137,17 @@ public class MathUtil {
// }
public static String secToTime(int time) {
String timeStr = null;
int hour = 0;
int minute = 0;
int second = 0;
String timeStr ;
int hour;
int minute;
int second;
if (time <= 0) {
return "00:00";
return "00:00:00";
} else {
minute = time / 60;
if (minute < 60) {
second = time % 60;
timeStr = unitFormat(minute) + ":" + unitFormat(second);
timeStr = "00:"+unitFormat(minute) + ":" + unitFormat(second);
} else {
hour = minute / 60;
minute = minute % 60;
......
package com.subsidy.util;
import lombok.Data;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.stereotype.Component;
import java.util.List;
import java.util.regex.Pattern;
@Data
@Component
public class MongoUtil<T> {
public Integer pageSize;
private Integer currentPage;
public void start(Integer currentPage, Integer pageSize, Query query) {
pageSize = pageSize == 0 ? 10 : pageSize;
query.limit(pageSize);
query.skip((currentPage - 1) * pageSize);
this.pageSize = pageSize;
this.currentPage = currentPage;
}
public PageHelper pageHelper(long total, List<T> list) {
return new PageHelper(this.currentPage, total, this.pageSize, list);
}
public PageHelper pageHelper(List<T> list) {
return new PageHelper(this.currentPage, this.pageSize, list);
}
public PageHelper pageHelper(long currentPage, long total, long pageSize, List<T> list) {
return new PageHelper(currentPage, total, pageSize, list);
}
public PageHelper pageHelper(long currentPage, long pageSize, List<T> list) {
return new PageHelper(currentPage, pageSize, list);
}
/**
* 用于模糊查询忽略大小写
*
* @param string
* @return
*/
public Pattern getPattern(String string) {
Pattern pattern = Pattern.compile("^.*" + string + ".*$", Pattern.CASE_INSENSITIVE);
return pattern;
}
}
package com.subsidy.util;
import lombok.Data;
import org.apache.poi.ss.formula.functions.T;
import java.util.List;
@Data
public class PageHelper<T> {
private long currentPage;
private long total;
private long pageSize;
private List<T> list;
public PageHelper(long pageNum, long total, long pageSize, List<T> list) {
this.currentPage = pageNum;
this.total = total;
this.pageSize = pageSize;
this.list = list;
}
public PageHelper(long pageNum, long pageSize, List<T> list) {
this.currentPage = pageNum;
this.pageSize = pageSize;
this.list = list;
}
}
......@@ -557,14 +557,14 @@ public class RedisUtil {
}
}
/**
* 模糊查询获取key值
* @param pattern
* @return
*/
public Set keys(String pattern){
return redisTemplate.keys(pattern);
}
///**
// * 模糊查询获取key值
// * @param pattern
// * @return
// */
//public Set keys(String pattern){
// return redisTemplate.keys(pattern);
//}
/**
* 模糊查询
......
......@@ -13,4 +13,6 @@ public class ClassDailyInfoVO {
private String userName;
private List<DayInfoItemVO> dayInfoItemVOS;
private Integer total;
}
......@@ -5,17 +5,12 @@ import lombok.Data;
@Data
public class GetMemberPapersVO {
private Long id;
private Long paperId;
private String paperName;
private String score;
private Integer rightCounts;
private Integer cnt;
private Integer totalCounts;
private Integer result;
private String result;
private String createDate;
private Integer score;
}
......@@ -44,6 +44,5 @@ public class GetCourseQuestionVO {
private String updateDate;
private String deleteDate;
}
......@@ -33,12 +33,12 @@ public class ClassDetailVO{
/**
* 已看视频
*/
private Integer studyVodCounts;
//private Integer studyVodCounts;
/**
* 全部视频
*/
private Integer allVodCounts;
//private Integer allVodCounts;
@ExcelColumn(col = 6,value = "课程进度")
private String classProcess;
......
......@@ -11,4 +11,5 @@ public class GetMaxScoreVO {
private Long score;
private Integer result;
}
package com.subsidy.vo.done;
import lombok.Data;
@Data
public class TestScoreInfoVO {
private Long paperId;
private Integer score;
private Integer cnt;
private String result;
}
......@@ -34,15 +34,6 @@ public class ClassSignVO {
@ExcelColumn(col = 4,value = "培训时长")
private String trainingLengthStr;
/**
* 已看视频
*/
private Integer studyVodCounts;
/**
* 全部视频
*/
private Integer allVodCounts;
@ExcelColumn(col = 5,value = "课程进度")
private String classProcess;
......
......@@ -5,7 +5,7 @@ import lombok.Data;
@Data
public class StudyPageVO {
private Integer id;
private Long id;
private Integer classId;
......
......@@ -2,7 +2,7 @@
# 数据源配置
spring.datasource.url=jdbc:mysql://47.97.19.66:3306/subsidy_test?autoReconnect=true&useUnicode=true&characterEncoding=utf8&serverTimezone=GMT%2B8
#spring.datasource.url=jdbc:mysql://rm-uf606h696n5qod70cfo.mysql.rds.aliyuncs.com:3306/subsidy_test?autoReconnect=true&useUnicode=true&characterEncoding=utf8&serverTimezone=GMT%2B8
#spring.datasource.url=jdbc:mysql://rm-uf6rab73w0qg843opxo.mysql.rds.aliyuncs.com:3306/subsidy_test?autoReconnect=true&useUnicode=true&characterEncoding=utf8&serverTimezone=GMT%2B8
spring.datasource.type=com.alibaba.druid.pool.DruidDataSource
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
#spring.datasource.username=ykadmin_new
......@@ -27,9 +27,19 @@ spring.datasource.druid.useGlobalDataSourceStat=true
# 控制台日志打印
mybatis-plus.configuration.log-impl=org.apache.ibatis.logging.stdout.StdOutImpl
#spring.redis.host=r-uf6thsc3bzt5b6f7fdpd.redis.rds.aliyuncs.com
#spring.redis.password=r-uf6thsc3bzt5b6f7fd:Ykhl@208
#spring.redis.host=r-uf6meywj6ysuehg148pd.redis.rds.aliyuncs.com
#spring.redis.password=r-uf6meywj6ysuehg148:Ykhl@208
#spring.redis.port=6379
#spring.redis.lettuce.pool.max-idle=16
#spring.redis.lettuce.pool.max-active=32
#spring.redis.lettuce.pool.min-idle=8
spring.application.name=spring-boot-mongodb
# mongodb
#spring.data.mongodb.uri=mongodb://47.97.19.66:27017/subsidy
spring.data.mongodb.username=root
spring.data.mongodb.password=123456
#spring.data.mongodb.authentication-database=subsidy
spring.data.mongodb.database=subsidy
spring.data.mongodb.host=47.97.19.66
spring.data.mongodb.port=27017
# 环境配置
spring.profiles.active=dev
# 端口号
spring.server.port=23454
spring.server.port=23457
#嵌入tomcat配置
#和CPU数
spring.server.acceptorThreadCount=600
......@@ -64,24 +64,6 @@ spring.quartz.overwrite-existing-jobs=false
#spring.quartz.jdbc.initialize-schema=always
#spring.datasource.initialization-mode=embedded
#spring.task.execution.pool.allow-core-thread-timeout=true
#spring.task.execution.pool.core-size=8
#spring.task.execution.pool.keep-alive=60
#spring.task.execution.pool.max-size=200
#spring.task.execution.pool.queue-capacity=200
#spring.task.execution.thread-name-prefix=subsidy-
#spring.task.scheduling.pool.size=2
#spring.task.scheduling.thread-name-prefix=subsidy-
#spring.redis.cluster.nodes=47.97.19.66:6377,47.97.19.66:6378,47.97.19.66:6379
##spring.redis.port=6379
#spring.redis.password=Ykhl@208
## spring.redis.cluster.max-redirects=3
#spring.redis.lettuce.pool.max-idle=16
#spring.redis.lettuce.pool.max-active=32
#spring.redis.lettuce.pool.min-idle=8
#spring.redis.host=r-uf6m4cpkjrgpzywjm3pd.redis.rds.aliyuncs.com
#spring.redis.port=6379
#spring.redis.password=r-uf6m4cpkjrgpzywjm3:Ykhl@208
......
......@@ -4,15 +4,15 @@
<!-- 通用查询映射结果 -->
<resultMap id="BaseResultMap" type="com.subsidy.model.AnsweringQuestionDO">
<id column="id" property="id" />
<result column="create_date" property="createDate" />
<result column="update_date" property="updateDate" />
<result column="delete_date" property="deleteDate" />
<result column="course_id" property="courseId" />
<result column="ask_id" property="askId" />
<result column="answer_id" property="answerId" />
<result column="title" property="title" />
<result column="answer" property="answer" />
<id column="id" property="id"/>
<result column="create_date" property="createDate"/>
<result column="update_date" property="updateDate"/>
<result column="delete_date" property="deleteDate"/>
<result column="course_id" property="courseId"/>
<result column="ask_id" property="askId"/>
<result column="answer_id" property="answerId"/>
<result column="title" property="title"/>
<result column="answer" property="answer"/>
</resultMap>
<!-- 通用查询结果列 -->
......@@ -25,7 +25,14 @@
<select id="getCourseQuestion" resultType="com.subsidy.vo.answer.GetCourseQuestionVO">
SELECT
t.*,
t.id,
t.class_id,
t.ask_id,
t.answer_id,
t.title,
t.answer,
t.create_date,
t.update_date,
t2.user_name as memberName,
t3.user_name as administerName,
t4.company_name
......
......@@ -65,7 +65,17 @@
<select id="getSpareMembers" parameterType="com.subsidy.dto.classDict.GetSpareMembersDTO"
resultType="com.subsidy.model.MemberDO">
SELECT
distinct t2.*
distinct t2.id,
t2.company_id,
t2.user_name,
t2.account_name,
t2.telephone,
t2.PASSWORD,
t2.gender,
t2.image,
t2.id_card,
t2.STATUS,
t2.first_login
FROM
member t2
LEFT JOIN member_department_mapping t ON t.member_id = t2.id
......@@ -87,7 +97,17 @@
<select id="classMembers" parameterType="long" resultType="com.subsidy.model.MemberDO">
SELECT
t2.*
t2.id,
t2.company_id,
t2.user_name,
t2.account_name,
t2.telephone,
t2.PASSWORD,
t2.gender,
t2.image,
t2.id_card,
t2.STATUS,
t2.first_login
FROM
class_member_mapping t
LEFT JOIN member t2 ON t.member_id = t2.id
......
......@@ -21,7 +21,7 @@
id, course_id, content, order_no
</sql>
<select id="getCourseVods" parameterType="integer" resultType="com.subsidy.model.VodDictDO">
<select id="getCourseVods" parameterType="long" resultType="com.subsidy.model.VodDictDO">
SELECT
t2.id,
t2.content_id,
......@@ -81,4 +81,14 @@
t2.order_no
</select>
<select id="selectMaxOrderNo" parameterType="long" resultType="integer">
SELECT
max(t.order_no)
FROM
course_content t
WHERE
t.delete_date IS NULL
AND t.course_id = #{courseId}
</select>
</mapper>
......@@ -92,7 +92,12 @@
<select id="queryCompanyCourse" resultType="com.subsidy.vo.course.QueryCoursesVO">
SELECT
t.*,
t.id,
t.company_id,
t.course_name,
t.category_id,
t.course_type,
t.course_source,
t2.name
FROM
course_dict t
......
......@@ -51,7 +51,16 @@
and t.title like concat('%',#{title} ,'%')
</if>
order by t.order_no
</select>
<select id="getMaximumNo" parameterType="long" resultType="integer">
SELECT
max( t.order_no )
FROM
exercise_dict t
WHERE
t.delete_date IS NULL
AND t.paper_id = #{paperId}
</select>
</mapper>
......@@ -93,4 +93,68 @@
t.member_id
</select>
<select id="getMaxScorePaper" resultType="com.subsidy.model.ExerciseDoneResultDO">
SELECT
max( t.score ),
t.right_counts,
t.total_counts,
t.result
FROM
exercise_done_result t
WHERE
t.delete_date IS NULL
AND t.paper_id = #{paperId}
AND t.member_id = #{memberId}
</select>
<select id="testScoreInfo" resultType="com.subsidy.vo.done.TestScoreInfoVO">
SELECT
t.paper_id,
max( t.score ) AS score,
count( 1 ) AS cnt,
IF
( max( t.score )>= 60, '合格', '不合格' ) AS result
FROM
exercise_done_result t
LEFT JOIN paper_dict t2 ON t.paper_id = t2.id
WHERE
t.delete_date IS NULL
AND t.member_id = #{memberId}
AND t.paper_id = #{paperId}
GROUP BY
t.class_id,
t.paper_id,
t.member_id
</select>
<select id="getClassTestPassRate" parameterType="long" resultType="integer">
SELECT
sum( t11.result )
FROM
(
SELECT
IF
( sum( cnt )= sum( result ), 1, 0 ) AS result
FROM
(
SELECT
t.paper_id,
t.member_id,
max( t.score ) AS score,
1 AS cnt,
IF
( max( t.score )>= 60, '1', '0' ) AS result
FROM
exercise_done_result t
LEFT JOIN paper_dict t2 ON t.paper_id = t2.id
WHERE
t.delete_date IS NULL
AND t.class_id = 2
GROUP BY
t.class_id,
t.paper_id,
t.member_id
) t10
) t11
</select>
</mapper>
......@@ -22,4 +22,22 @@
id, content_id, file_name, file_size, order_no
</sql>
<select id="selectFiles" resultType="com.subsidy.model.FileDictDO">
SELECT
id,
content_id,
file_name,
file_size,
file_type,
file_url,
order_no,
create_date
FROM
file_dict t
WHERE
t.delete_date IS NULL
AND t.content_id = 2
AND t.file_name LIKE concat('%',#{fileName} ,'%')
</select>
</mapper>
......@@ -3,7 +3,7 @@
<mapper namespace="com.subsidy.mapper.OprAdmDictMapper">
<!-- 通用查询映射结果 -->
<resultMap id="BaseResultMap" type="com.subsidy.model.OprAdmDictDO">
<resultMap id="BaseResultMap" type="com.subsidy.mongodb.OprAdmDictDO">
<id column="id" property="id" />
<result column="create_date" property="createDate" />
<result column="update_date" property="updateDate" />
......@@ -50,7 +50,7 @@
t.create_date DESC
</select>
<select id="getLoginInfo" parameterType="long" resultType="com.subsidy.model.OprAdmDictDO">
<select id="getLoginInfo" parameterType="long" resultType="com.subsidy.mongodb.OprAdmDictDO">
SELECT
*
FROM
......@@ -68,7 +68,7 @@
LIMIT 5)t2
</select>
<select id="getRecordByDate" resultType="com.subsidy.model.OprAdmDictDO">
<select id="getRecordByDate" resultType="com.subsidy.mongodb.OprAdmDictDO">
SELECT
*
FROM
......
......@@ -228,7 +228,7 @@
<select id="memberRecentPlay" resultType="com.subsidy.vo.member.ContentVodNewVO">
SELECT
t2.id,
t1.play_record
ifnull(t1.play_record,0) as play_record
FROM
(
SELECT
......@@ -238,8 +238,8 @@
FROM
vod_play_history t
WHERE
t.member_id = 1
AND t.class_id = 3
t.member_id = #{memberId}
AND t.class_id = #{classId}
) t1
LEFT JOIN vod_dict t2 ON t1.vod_id = t2.id
</select>
......@@ -286,4 +286,25 @@
ORDER BY
t1.create_date DESC
</select>
<select id="memberTotalLength" parameterType="long" resultType="integer">
SELECT
sum( play_length )
FROM
vod_play_history t
WHERE
t.delete_date IS NULL
AND t.member_id = #{memberId}
</select>
<select id="memberVodTotalLength" resultType="integer">
SELECT
sum( t.play_length )
FROM
vod_play_history t
WHERE
t.delete_date IS NULL
AND t.vod_id = #{vodId}
AND t.member_id = #{memberId}
</select>
</mapper>
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!