Commit 07127669 by 涂亚平

压测优化版本

多线程还有点问题,容易进入死循环
1 parent f136ed8c
Showing with 1318 additions and 1756 deletions
package com.subsidy; package com.subsidy;
import com.alibaba.druid.support.http.StatViewServlet;
import org.mybatis.spring.annotation.MapperScan; import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication; import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.servlet.ServletRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.scheduling.annotation.EnableAsync; import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.annotation.EnableScheduling; import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
...@@ -21,19 +18,19 @@ public class MeishuApplication { ...@@ -21,19 +18,19 @@ public class MeishuApplication {
SpringApplication.run(MeishuApplication.class, args); SpringApplication.run(MeishuApplication.class, args);
} }
@Bean //@Bean
public ServletRegistrationBean druidStatViewServlet() { //public ServletRegistrationBean druidStatViewServlet() {
//先配置管理后台的servLet,访问的入口为/druid/ // //先配置管理后台的servLet,访问的入口为/druid/
ServletRegistrationBean servletRegistrationBean = new ServletRegistrationBean( // ServletRegistrationBean servletRegistrationBean = new ServletRegistrationBean(
new StatViewServlet(), "/druid/*"); // new StatViewServlet(), "/druid/*");
// IP白名单 (没有配置或者为空,则允许所有访问) // // IP白名单 (没有配置或者为空,则允许所有访问)
servletRegistrationBean.addInitParameter("allow", "127.0.0.1"); // servletRegistrationBean.addInitParameter("allow", "127.0.0.1");
// IP黑名单 (存在共同时,deny优先于allow) // // IP黑名单 (存在共同时,deny优先于allow)
servletRegistrationBean.addInitParameter("deny", ""); // servletRegistrationBean.addInitParameter("deny", "");
servletRegistrationBean.addInitParameter("loginUsername", "admin"); // servletRegistrationBean.addInitParameter("loginUsername", "admin");
servletRegistrationBean.addInitParameter("loginPassword", "yhkl1234"); // servletRegistrationBean.addInitParameter("loginPassword", "yhkl1234");
servletRegistrationBean.addInitParameter("resetEnable", "false"); // servletRegistrationBean.addInitParameter("resetEnable", "false");
return servletRegistrationBean; // return servletRegistrationBean;
} //}
} }
package com.subsidy.common;
public class RedisPrefixConstant {
/**
* subsidyAdminister_accountName:AdministerDO 老师账号密码
*/
public static final String SUBSIDY_ADMINISTER_PREFIX = "subsidyAdminister_";
/**
* subsidyMember_companyId_accountName:MemberDO 学员账号密码
*/
public static final String SUBSIDY_COMPANY_MEMBER_PREFIX = "subsidyMember_";
/**
* subsidy_memberLogin_memberId_now : OprMemDictDO 学员端审计记录
*/
public static final String SUBSIDY_MEMBER_LOGIN_PREFIX = "subsidy_memberLogin_";
/**
* subsidySmsCode_telephone:code 手机验证码
*/
public static final String SUBSIDY_TELEPHONE_PREFIX = "subsidySmsCode_";
/**
* subsidySettings_companyId:ClassHourDictDO 公司操作设置
*/
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_";
}
package com.subsidy.common.configure;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.AsyncConfigurer;
import java.util.concurrent.*;
@Configuration
public class ThreadPoolConfig implements AsyncConfigurer {
@Bean
public ExecutorService getThreadPool(){
return Executors.newCachedThreadPool();
}
}
...@@ -9,28 +9,23 @@ import com.subsidy.dto.administer.ClassDetailDTO; ...@@ -9,28 +9,23 @@ import com.subsidy.dto.administer.ClassDetailDTO;
import com.subsidy.dto.administer.ClassVodInfoDTO; import com.subsidy.dto.administer.ClassVodInfoDTO;
import com.subsidy.dto.administer.OperatorsDTO; import com.subsidy.dto.administer.OperatorsDTO;
import com.subsidy.model.AdministerDO; import com.subsidy.model.AdministerDO;
import com.subsidy.model.ClassDictDO;
import com.subsidy.model.ExerciseDoneHistoryDO; import com.subsidy.model.ExerciseDoneHistoryDO;
import com.subsidy.model.ExerciseDoneResultDO; import com.subsidy.model.ExerciseDoneResultDO;
import com.subsidy.service.AdministerService; import com.subsidy.service.AdministerService;
import com.subsidy.util.ConstantUtils; import com.subsidy.util.ConstantUtils;
import com.subsidy.util.excel.ExcelUtil; import io.swagger.annotations.Api;
import com.subsidy.vo.administer.ExerciseTestVO;
import com.subsidy.vo.classdict.ClassDetailVO;
import com.subsidy.vo.member.ClassSignVO;
import com.subsidy.vo.sign.AnswerRecordVO;
import com.subsidy.vo.sign.ClassSignInfoVO;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import io.swagger.annotations.Api; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse;
import java.net.InetAddress; import java.net.InetAddress;
import java.util.Arrays;
import java.util.List;
/** /**
* <p> * <p>
...@@ -51,18 +46,17 @@ public class AdministerController { ...@@ -51,18 +46,17 @@ public class AdministerController {
@GetMapping("getIp") @GetMapping("getIp")
public String getIp()throws Exception{ public String getIp()throws Exception{
InetAddress addr = InetAddress.getLocalHost(); InetAddress addr = InetAddress.getLocalHost();
System.out.println("Local HostAddress:"+addr.getHostAddress());
return addr.getHostAddress(); return addr.getHostAddress();
} }
@PostMapping("/login") @PostMapping("/login")
@ApiOperation("** 登录接口 accountName password") @ApiOperation("登录接口 accountName password")
public ResponseVO login(@RequestBody AdministerDO administerDO){ public ResponseVO login(@RequestBody AdministerDO administerDO){
return ResponseData.generateCreatedResponse(0,administerService.login(administerDO)); return ResponseData.generateCreatedResponse(0,administerService.login(administerDO));
} }
@PostMapping("/getPermissions") @PostMapping("/getPermissions")
@ApiOperation("** 权限查询") @ApiOperation("权限查询")
@LoginRequired(value = {ConstantUtils.ADMINISTER_TERMINATE}) @LoginRequired(value = {ConstantUtils.ADMINISTER_TERMINATE})
public ResponseVO getPermissions() { public ResponseVO getPermissions() {
return ResponseData.generateCreatedResponse(0, administerService.getPermissions()); return ResponseData.generateCreatedResponse(0, administerService.getPermissions());
...@@ -93,10 +87,9 @@ public class AdministerController { ...@@ -93,10 +87,9 @@ public class AdministerController {
return ResponseData.generateCreatedResponse(0,administerService.updateAdminister(administerDO)); return ResponseData.generateCreatedResponse(0,administerService.updateAdminister(administerDO));
} }
@PostMapping("classSummary") @PostMapping("classSummary")
@ApiOperation("课程汇总 id 班级id ") @ApiOperation("课程汇总 id 班级id ")
@LoginRequired(value = {ConstantUtils.ADMINISTER_TERMINATE}) //@LoginRequired(value = {ConstantUtils.ADMINISTER_TERMINATE})
public ResponseVO classSummary(@RequestBody ClassDetailDTO classDetailDTO){ public ResponseVO classSummary(@RequestBody ClassDetailDTO classDetailDTO){
return ResponseData.generateCreatedResponse(0,administerService.classSummary(classDetailDTO)); return ResponseData.generateCreatedResponse(0,administerService.classSummary(classDetailDTO));
} }
...@@ -117,8 +110,8 @@ public class AdministerController { ...@@ -117,8 +110,8 @@ public class AdministerController {
} }
@PostMapping("signDetail") @PostMapping("signDetail")
@ApiOperation("** 班级管理--注册签到 id 班级id userName") @ApiOperation("班级管理--注册签到 id 班级id userName")
@LoginRequired(value = {ConstantUtils.ADMINISTER_TERMINATE}) //@LoginRequired(value = {ConstantUtils.ADMINISTER_TERMINATE})
public ResponseVO signDetail(@RequestBody ClassDetailDTO classDetailDTO){ public ResponseVO signDetail(@RequestBody ClassDetailDTO classDetailDTO){
return ResponseData.generateCreatedResponse(0,administerService.signDetail(classDetailDTO)); return ResponseData.generateCreatedResponse(0,administerService.signDetail(classDetailDTO));
} }
...@@ -160,14 +153,14 @@ public class AdministerController { ...@@ -160,14 +153,14 @@ public class AdministerController {
} }
@PostMapping("answerRecord") @PostMapping("answerRecord")
@ApiOperation("** 班级管理--答疑 id 班级id userName") @ApiOperation("班级管理--答疑 id 班级id userName")
@LoginRequired(value = {ConstantUtils.ADMINISTER_TERMINATE}) @LoginRequired(value = {ConstantUtils.ADMINISTER_TERMINATE})
public ResponseVO answerRecord(@RequestBody ClassDetailDTO classDetailDTO){ public ResponseVO answerRecord(@RequestBody ClassDetailDTO classDetailDTO){
return ResponseData.generateCreatedResponse(0,administerService.answerRecord(classDetailDTO)); return ResponseData.generateCreatedResponse(0,administerService.answerRecord(classDetailDTO));
} }
@PostMapping("exportAnswerRecord") @PostMapping("exportAnswerRecord")
@ApiOperation("** 班级管理--答疑 id 班级id userName") @ApiOperation("班级管理--答疑 id 班级id userName")
@LoginRequired(value = {ConstantUtils.ADMINISTER_TERMINATE}) @LoginRequired(value = {ConstantUtils.ADMINISTER_TERMINATE})
public void exportAnswerRecord(@RequestBody ClassDetailDTO classDetailDTO)throws Exception{ public void exportAnswerRecord(@RequestBody ClassDetailDTO classDetailDTO)throws Exception{
classDetailDTO.setFlag(true); classDetailDTO.setFlag(true);
...@@ -195,16 +188,9 @@ public class AdministerController { ...@@ -195,16 +188,9 @@ public class AdministerController {
} }
@PostMapping("importMember") @PostMapping("importMember")
@ApiOperation("** 导入学生 {companyId 公司id file}") @ApiOperation("导入学生 {companyId 公司id file}")
public ResponseVO importMember(Long companyId,@RequestParam("file") MultipartFile file){ public ResponseVO importMember(Long companyId,@RequestParam("file") MultipartFile file){
return ResponseData.generateCreatedResponse(0,administerService.importMember(companyId,file)); return ResponseData.generateCreatedResponse(0,administerService.importMember(companyId,file));
} }
@PostMapping("importRedis")
@ApiOperation("导入老师账号到redis")
public void importRedis(){
administerService.importRedis();
}
} }
...@@ -6,11 +6,13 @@ import com.subsidy.common.ResponseVO; ...@@ -6,11 +6,13 @@ import com.subsidy.common.ResponseVO;
import com.subsidy.dto.GetCourseQuestionDTO; import com.subsidy.dto.GetCourseQuestionDTO;
import com.subsidy.model.AnsweringQuestionDO; import com.subsidy.model.AnsweringQuestionDO;
import com.subsidy.service.AnsweringQuestionService; import com.subsidy.service.AnsweringQuestionService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import io.swagger.annotations.Api; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/** /**
* <p> * <p>
...@@ -29,25 +31,25 @@ public class AnsweringQuestionController { ...@@ -29,25 +31,25 @@ public class AnsweringQuestionController {
private AnsweringQuestionService answeringQuestionService; private AnsweringQuestionService answeringQuestionService;
@PostMapping("getCourseQuestion") @PostMapping("getCourseQuestion")
@ApiOperation("** 获取某个课程的答疑 {classId pageSize pageNum memberId}") @ApiOperation(" 获取某个课程的答疑 {classId pageSize pageNum memberId}")
public ResponseVO getCourseQuestion(@RequestBody GetCourseQuestionDTO getCourseQuestionDTO){ public ResponseVO getCourseQuestion(@RequestBody GetCourseQuestionDTO getCourseQuestionDTO){
return ResponseData.generateCreatedResponse(0,answeringQuestionService.getCourseQuestion(getCourseQuestionDTO)); return ResponseData.generateCreatedResponse(0,answeringQuestionService.getCourseQuestion(getCourseQuestionDTO));
} }
@PostMapping("addQuestion") @PostMapping("addQuestion")
@ApiOperation("** 新增答疑 {classId askId title}") @ApiOperation("新增答疑 {classId askId title}")
public ResponseVO addQuestion(@RequestBody AnsweringQuestionDO answeringQuestionDO){ public ResponseVO addQuestion(@RequestBody AnsweringQuestionDO answeringQuestionDO){
return ResponseData.generateCreatedResponse(0,answeringQuestionService.addQuestion(answeringQuestionDO)); return ResponseData.generateCreatedResponse(0,answeringQuestionService.addQuestion(answeringQuestionDO));
} }
@PostMapping("deleteQuestion") @PostMapping("deleteQuestion")
@ApiOperation("** 删除答疑 {id}") @ApiOperation(" 删除答疑 {id}")
public ResponseVO deleteQuestion(@RequestBody AnsweringQuestionDO answeringQuestionDO){ public ResponseVO deleteQuestion(@RequestBody AnsweringQuestionDO answeringQuestionDO){
return ResponseData.generateCreatedResponse(0,answeringQuestionService.deleteQuestion(answeringQuestionDO)); return ResponseData.generateCreatedResponse(0,answeringQuestionService.deleteQuestion(answeringQuestionDO));
} }
@PostMapping("updateQuestion") @PostMapping("updateQuestion")
@ApiOperation("** 编辑答疑 {id answerId answer}") @ApiOperation("编辑答疑 {id answerId answer}")
public ResponseVO updateQuestion(@RequestBody AnsweringQuestionDO answeringQuestionDO){ public ResponseVO updateQuestion(@RequestBody AnsweringQuestionDO answeringQuestionDO){
return ResponseData.generateCreatedResponse(0, answeringQuestionService.updateQuestion(answeringQuestionDO)); return ResponseData.generateCreatedResponse(0, answeringQuestionService.updateQuestion(answeringQuestionDO));
} }
......
...@@ -8,14 +8,13 @@ import com.subsidy.dto.category.GetCategoriesDTO; ...@@ -8,14 +8,13 @@ import com.subsidy.dto.category.GetCategoriesDTO;
import com.subsidy.model.CategoryDO; import com.subsidy.model.CategoryDO;
import com.subsidy.service.CategoryService; import com.subsidy.service.CategoryService;
import com.subsidy.util.ConstantUtils; import com.subsidy.util.ConstantUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import io.swagger.annotations.Api;
/** /**
* <p> * <p>
...@@ -34,34 +33,34 @@ public class CategoryController { ...@@ -34,34 +33,34 @@ public class CategoryController {
private CategoryService categoryService; private CategoryService categoryService;
@PostMapping("getCategories") @PostMapping("getCategories")
@ApiOperation("查询类目 ** name 类目名称 companyId pageSize pageNum") @ApiOperation("查询类目 name 类目名称 companyId pageSize pageNum")
@LoginRequired(value = {ConstantUtils.ADMINISTER_TERMINATE}) @LoginRequired(value = {ConstantUtils.ADMINISTER_TERMINATE})
public ResponseVO getCategories(@RequestBody GetCategoriesDTO getCategoriesDTO){ public ResponseVO getCategories(@RequestBody GetCategoriesDTO getCategoriesDTO){
return ResponseData.generateCreatedResponse(0,categoryService.getCategories(getCategoriesDTO)); return ResponseData.generateCreatedResponse(0,categoryService.getCategories(getCategoriesDTO));
} }
@PostMapping("getAll") @PostMapping("getAll")
@ApiOperation("查询所有类目 **companyId") @ApiOperation("查询所有类目 companyId")
public ResponseVO getAll(@RequestBody GetCategoriesDTO getCategoriesDTO){ public ResponseVO getAll(@RequestBody GetCategoriesDTO getCategoriesDTO){
return ResponseData.generateCreatedResponse(0,categoryService.getAll(getCategoriesDTO)); return ResponseData.generateCreatedResponse(0,categoryService.getAll(getCategoriesDTO));
} }
@PostMapping("addCategory") @PostMapping("addCategory")
@ApiOperation("新增类目 **name companyId") @ApiOperation("新增类目 name companyId")
@LoginRequired(value = {ConstantUtils.ADMINISTER_TERMINATE}) @LoginRequired(value = {ConstantUtils.ADMINISTER_TERMINATE})
public ResponseVO addCategory(@RequestBody CategoryDO categoryDO){ public ResponseVO addCategory(@RequestBody CategoryDO categoryDO){
return ResponseData.generateCreatedResponse(0,categoryService.addCategory(categoryDO)); return ResponseData.generateCreatedResponse(0,categoryService.addCategory(categoryDO));
} }
@PostMapping("deleteCategory") @PostMapping("deleteCategory")
@ApiOperation("删除类目 ** id") @ApiOperation("删除类目 id")
@LoginRequired(value = {ConstantUtils.ADMINISTER_TERMINATE}) @LoginRequired(value = {ConstantUtils.ADMINISTER_TERMINATE})
public ResponseVO deleteCategory(@RequestBody CategoryDO categoryDO){ public ResponseVO deleteCategory(@RequestBody CategoryDO categoryDO){
return ResponseData.generateCreatedResponse(0,categoryService.deleteCategory(categoryDO)); return ResponseData.generateCreatedResponse(0,categoryService.deleteCategory(categoryDO));
} }
@PostMapping("updateCategory") @PostMapping("updateCategory")
@ApiOperation("修改类目 ** id name companyId") @ApiOperation("修改类目 id name companyId")
@LoginRequired(value = {ConstantUtils.ADMINISTER_TERMINATE}) @LoginRequired(value = {ConstantUtils.ADMINISTER_TERMINATE})
public ResponseVO updateCategory(@RequestBody CategoryDO categoryDO){ public ResponseVO updateCategory(@RequestBody CategoryDO categoryDO){
return ResponseData.generateCreatedResponse(0,categoryService.updateCategory(categoryDO)); return ResponseData.generateCreatedResponse(0,categoryService.updateCategory(categoryDO));
......
...@@ -6,21 +6,18 @@ import com.subsidy.common.ResponseVO; ...@@ -6,21 +6,18 @@ import com.subsidy.common.ResponseVO;
import com.subsidy.common.interceptor.LoginRequired; import com.subsidy.common.interceptor.LoginRequired;
import com.subsidy.dto.classDict.AddClassDTO; import com.subsidy.dto.classDict.AddClassDTO;
import com.subsidy.dto.classDict.AddMemberToClassDTO; import com.subsidy.dto.classDict.AddMemberToClassDTO;
import com.subsidy.dto.classDict.GetAllClassesDTO;
import com.subsidy.dto.classDict.GetSpareMembersDTO; import com.subsidy.dto.classDict.GetSpareMembersDTO;
import com.subsidy.model.ClassDictDO; import com.subsidy.model.ClassDictDO;
import com.subsidy.model.ClassMemberMappingDO; import com.subsidy.model.ClassMemberMappingDO;
import com.subsidy.model.CourseDictDO;
import com.subsidy.service.ClassDictService; import com.subsidy.service.ClassDictService;
import com.subsidy.util.ConstantUtils; import com.subsidy.util.ConstantUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import io.swagger.annotations.Api;
/** /**
* <p> * <p>
...@@ -46,14 +43,14 @@ public class ClassDictController { ...@@ -46,14 +43,14 @@ public class ClassDictController {
} }
@PostMapping("deleteClasses") @PostMapping("deleteClasses")
@ApiOperation("** 删除课程 id") @ApiOperation(" 删除课程 id")
@LoginRequired(value = {ConstantUtils.ADMINISTER_TERMINATE}) @LoginRequired(value = {ConstantUtils.ADMINISTER_TERMINATE})
public ResponseVO deleteClasses(@RequestBody ClassDictDO classDictDO){ public ResponseVO deleteClasses(@RequestBody ClassDictDO classDictDO){
return ResponseData.generateCreatedResponse(0,classDictService.deleteClasses(classDictDO)); return ResponseData.generateCreatedResponse(0,classDictService.deleteClasses(classDictDO));
} }
@PostMapping("addClass") @PostMapping("addClass")
@ApiOperation("添加课程 ** userId:登录人id companyId courseId className startDate endDate") @ApiOperation("添加课程 userId:登录人id companyId courseId className startDate endDate")
@LoginRequired(value = {ConstantUtils.ADMINISTER_TERMINATE}) @LoginRequired(value = {ConstantUtils.ADMINISTER_TERMINATE})
public ResponseVO addClass(@RequestBody AddClassDTO addClassDTO){ public ResponseVO addClass(@RequestBody AddClassDTO addClassDTO){
return ResponseData.generateCreatedResponse(0,classDictService.addClass(addClassDTO)); return ResponseData.generateCreatedResponse(0,classDictService.addClass(addClassDTO));
...@@ -67,14 +64,14 @@ public class ClassDictController { ...@@ -67,14 +64,14 @@ public class ClassDictController {
} }
@PostMapping("classDetail") @PostMapping("classDetail")
@ApiOperation("** 获取一个班级详情 id") @ApiOperation("获取一个班级详情 id")
@LoginRequired(value = {ConstantUtils.ADMINISTER_TERMINATE}) @LoginRequired(value = {ConstantUtils.ADMINISTER_TERMINATE})
public ResponseVO classDetail(@RequestBody ClassDictDO classDictDO){ public ResponseVO classDetail(@RequestBody ClassDictDO classDictDO){
return ResponseData.generateCreatedResponse(0,classDictService.classDetail(classDictDO)); return ResponseData.generateCreatedResponse(0,classDictService.classDetail(classDictDO));
} }
@PostMapping("removeMember") @PostMapping("removeMember")
@ApiOperation("** 移除班级 classId 班级id memberId人员id") @ApiOperation("移除班级 classId 班级id memberId人员id")
@LoginRequired(value = {ConstantUtils.ADMINISTER_TERMINATE}) @LoginRequired(value = {ConstantUtils.ADMINISTER_TERMINATE})
public ResponseVO removeMember(@RequestBody ClassMemberMappingDO classMemberMappingDO){ public ResponseVO removeMember(@RequestBody ClassMemberMappingDO classMemberMappingDO){
return ResponseData.generateCreatedResponse(0,classDictService.removeMember(classMemberMappingDO)); return ResponseData.generateCreatedResponse(0,classDictService.removeMember(classMemberMappingDO));
...@@ -88,7 +85,7 @@ public class ClassDictController { ...@@ -88,7 +85,7 @@ public class ClassDictController {
} }
@PostMapping("addMemberToClass") @PostMapping("addMemberToClass")
@ApiOperation("** 将某个成员加入到某个班级里 classId memberIds []") @ApiOperation("将某个成员加入到某个班级里 classId memberIds []")
@LoginRequired(value = {ConstantUtils.ADMINISTER_TERMINATE}) @LoginRequired(value = {ConstantUtils.ADMINISTER_TERMINATE})
public ResponseVO addMemberToClass(@RequestBody AddMemberToClassDTO addMemberToClassDTO){ public ResponseVO addMemberToClass(@RequestBody AddMemberToClassDTO addMemberToClassDTO){
return ResponseData.generateCreatedResponse(0,classDictService.addMemberToClass(addMemberToClassDTO)); return ResponseData.generateCreatedResponse(0,classDictService.addMemberToClass(addMemberToClassDTO));
...@@ -96,7 +93,7 @@ public class ClassDictController { ...@@ -96,7 +93,7 @@ public class ClassDictController {
@PostMapping("batchSms") @PostMapping("batchSms")
@ApiOperation("** 批量发送班级短信 {id 班级id}") @ApiOperation(" 批量发送班级短信 {id 班级id}")
public ResponseVO batchSms(@RequestBody ClassDictDO classDictDO){ public ResponseVO batchSms(@RequestBody ClassDictDO classDictDO){
return ResponseData.generateCreatedResponse(0,classDictService.batchSms(classDictDO)); return ResponseData.generateCreatedResponse(0,classDictService.batchSms(classDictDO));
} }
......
...@@ -8,11 +8,13 @@ import com.subsidy.model.ClassHourDictDO; ...@@ -8,11 +8,13 @@ import com.subsidy.model.ClassHourDictDO;
import com.subsidy.model.VodPlayHistoryDO; import com.subsidy.model.VodPlayHistoryDO;
import com.subsidy.service.ClassHourDictService; import com.subsidy.service.ClassHourDictService;
import com.subsidy.util.ConstantUtils; import com.subsidy.util.ConstantUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import io.swagger.annotations.Api; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/** /**
* <p> * <p>
......
package com.subsidy.controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import io.swagger.annotations.Api;
/**
* <p>
* 班级成员映射表 前端控制器
* </p>
*
* @author DengMin
* @since 2021-10-12
*/
@RestController
@Api(tags = "班级成员映射表")
@RequestMapping("/class-member-mapping-do")
public class ClassMemberMappingController {
}
...@@ -6,19 +6,16 @@ import com.subsidy.common.ResponseVO; ...@@ -6,19 +6,16 @@ import com.subsidy.common.ResponseVO;
import com.subsidy.common.interceptor.LoginRequired; import com.subsidy.common.interceptor.LoginRequired;
import com.subsidy.dto.administer.OperatorsDTO; import com.subsidy.dto.administer.OperatorsDTO;
import com.subsidy.dto.company.AddCompanyDTO; import com.subsidy.dto.company.AddCompanyDTO;
import com.subsidy.mapper.CompanyDictMapper;
import com.subsidy.model.AdministerDO;
import com.subsidy.model.CompanyDictDO; import com.subsidy.model.CompanyDictDO;
import com.subsidy.service.CompanyDictService; import com.subsidy.service.CompanyDictService;
import com.subsidy.util.ConstantUtils; import com.subsidy.util.ConstantUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import io.swagger.annotations.Api;
/** /**
* <p> * <p>
......
...@@ -5,17 +5,15 @@ import com.subsidy.common.ResponseData; ...@@ -5,17 +5,15 @@ import com.subsidy.common.ResponseData;
import com.subsidy.common.ResponseVO; import com.subsidy.common.ResponseVO;
import com.subsidy.common.interceptor.LoginRequired; import com.subsidy.common.interceptor.LoginRequired;
import com.subsidy.model.CourseContentDO; import com.subsidy.model.CourseContentDO;
import com.subsidy.model.VodDictDO;
import com.subsidy.service.CourseContentService; import com.subsidy.service.CourseContentService;
import com.subsidy.util.ConstantUtils; import com.subsidy.util.ConstantUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import io.swagger.annotations.Api;
/** /**
* <p> * <p>
......
...@@ -8,11 +8,13 @@ import com.subsidy.dto.course.QueryCoursesDTO; ...@@ -8,11 +8,13 @@ import com.subsidy.dto.course.QueryCoursesDTO;
import com.subsidy.model.CourseDictDO; import com.subsidy.model.CourseDictDO;
import com.subsidy.service.CourseDictService; import com.subsidy.service.CourseDictService;
import com.subsidy.util.ConstantUtils; import com.subsidy.util.ConstantUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import io.swagger.annotations.Api; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/** /**
* <p> * <p>
......
...@@ -7,14 +7,13 @@ import com.subsidy.common.interceptor.LoginRequired; ...@@ -7,14 +7,13 @@ import com.subsidy.common.interceptor.LoginRequired;
import com.subsidy.model.DepartmentDictDO; import com.subsidy.model.DepartmentDictDO;
import com.subsidy.service.DepartmentDictService; import com.subsidy.service.DepartmentDictService;
import com.subsidy.util.ConstantUtils; import com.subsidy.util.ConstantUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import io.swagger.annotations.Api;
/** /**
* <p> * <p>
......
...@@ -7,16 +7,17 @@ import com.subsidy.common.interceptor.LoginRequired; ...@@ -7,16 +7,17 @@ import com.subsidy.common.interceptor.LoginRequired;
import com.subsidy.dto.exercise.GetAllExercisesDTO; import com.subsidy.dto.exercise.GetAllExercisesDTO;
import com.subsidy.dto.exercise.GetPaperExerciseDTO; import com.subsidy.dto.exercise.GetPaperExerciseDTO;
import com.subsidy.dto.exercise.SubmitDTO; import com.subsidy.dto.exercise.SubmitDTO;
import com.subsidy.mapper.ExerciseDictMapper;
import com.subsidy.model.CourseDictDO; import com.subsidy.model.CourseDictDO;
import com.subsidy.model.ExerciseDictDO; import com.subsidy.model.ExerciseDictDO;
import com.subsidy.service.ExerciseDictService; import com.subsidy.service.ExerciseDictService;
import com.subsidy.util.ConstantUtils; import com.subsidy.util.ConstantUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import io.swagger.annotations.Api; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/** /**
* <p> * <p>
......
...@@ -3,15 +3,15 @@ package com.subsidy.controller; ...@@ -3,15 +3,15 @@ package com.subsidy.controller;
import com.subsidy.common.ResponseData; import com.subsidy.common.ResponseData;
import com.subsidy.common.ResponseVO; import com.subsidy.common.ResponseVO;
import com.subsidy.model.ExerciseDoneHistoryDO;
import com.subsidy.model.ExerciseDoneResultDO; import com.subsidy.model.ExerciseDoneResultDO;
import com.subsidy.service.ExerciseDoneHistoryService; import com.subsidy.service.ExerciseDoneHistoryService;
import com.subsidy.service.ExerciseDoneResultService; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import io.swagger.annotations.Api; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/** /**
* <p> * <p>
......
...@@ -5,14 +5,13 @@ import com.subsidy.common.ResponseData; ...@@ -5,14 +5,13 @@ import com.subsidy.common.ResponseData;
import com.subsidy.common.ResponseVO; import com.subsidy.common.ResponseVO;
import com.subsidy.model.ExerciseDoneResultDO; import com.subsidy.model.ExerciseDoneResultDO;
import com.subsidy.service.ExerciseDoneResultService; import com.subsidy.service.ExerciseDoneResultService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import io.swagger.annotations.Api;
/** /**
* <p> * <p>
......
...@@ -5,17 +5,15 @@ import com.subsidy.common.ResponseData; ...@@ -5,17 +5,15 @@ import com.subsidy.common.ResponseData;
import com.subsidy.common.ResponseVO; import com.subsidy.common.ResponseVO;
import com.subsidy.common.interceptor.LoginRequired; import com.subsidy.common.interceptor.LoginRequired;
import com.subsidy.model.FileDictDO; import com.subsidy.model.FileDictDO;
import com.subsidy.model.VodDictDO;
import com.subsidy.service.FileDictService; import com.subsidy.service.FileDictService;
import com.subsidy.util.ConstantUtils; import com.subsidy.util.ConstantUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import io.swagger.annotations.Api;
/** /**
* <p> * <p>
......
...@@ -5,21 +5,22 @@ import com.subsidy.common.ResponseData; ...@@ -5,21 +5,22 @@ import com.subsidy.common.ResponseData;
import com.subsidy.common.ResponseVO; import com.subsidy.common.ResponseVO;
import com.subsidy.common.interceptor.LoginRequired; import com.subsidy.common.interceptor.LoginRequired;
import com.subsidy.dto.administer.VerifyCodeDTO; import com.subsidy.dto.administer.VerifyCodeDTO;
import com.subsidy.dto.member.*; import com.subsidy.dto.member.AddMemberDTO;
import com.subsidy.model.ExerciseDoneHistoryDO; import com.subsidy.dto.member.ContentMemberDTO;
import com.subsidy.dto.member.GetAllDTO;
import com.subsidy.dto.member.PasswordLoginDTO;
import com.subsidy.dto.member.StudyHistoryDTO;
import com.subsidy.model.ExerciseDoneResultDO; import com.subsidy.model.ExerciseDoneResultDO;
import com.subsidy.model.MemberDO; import com.subsidy.model.MemberDO;
import com.subsidy.service.MemberService; import com.subsidy.service.MemberService;
import com.subsidy.util.ConstantUtils; import com.subsidy.util.ConstantUtils;
import com.subsidy.vo.member.ContentVodVO; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import io.swagger.annotations.Api;
/** /**
* <p> * <p>
......
package com.subsidy.controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import io.swagger.annotations.Api;
/**
* <p>
* 老师部门映射表 前端控制器
* </p>
*
* @author DengMin
* @since 2021-11-01
*/
@RestController
@Api(tags = "老师部门映射表")
@RequestMapping("/member-department-mapping-do")
public class MemberDepartmentMappingController {
}
...@@ -5,14 +5,13 @@ import com.subsidy.common.ResponseData; ...@@ -5,14 +5,13 @@ import com.subsidy.common.ResponseData;
import com.subsidy.common.ResponseVO; import com.subsidy.common.ResponseVO;
import com.subsidy.dto.opr.GetHistoryDTO; import com.subsidy.dto.opr.GetHistoryDTO;
import com.subsidy.service.OprAdmDictService; import com.subsidy.service.OprAdmDictService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import io.swagger.annotations.Api;
/** /**
* <p> * <p>
......
...@@ -5,14 +5,13 @@ import com.subsidy.common.ResponseData; ...@@ -5,14 +5,13 @@ import com.subsidy.common.ResponseData;
import com.subsidy.common.ResponseVO; import com.subsidy.common.ResponseVO;
import com.subsidy.dto.opr.GetHistoryDTO; import com.subsidy.dto.opr.GetHistoryDTO;
import com.subsidy.service.OprMemDictService; import com.subsidy.service.OprMemDictService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import io.swagger.annotations.Api;
/** /**
* <p> * <p>
......
...@@ -3,17 +3,17 @@ package com.subsidy.controller; ...@@ -3,17 +3,17 @@ package com.subsidy.controller;
import com.subsidy.common.ResponseData; import com.subsidy.common.ResponseData;
import com.subsidy.common.ResponseVO; import com.subsidy.common.ResponseVO;
import com.subsidy.common.interceptor.LoginRequired;
import com.subsidy.model.PaperDictDO; import com.subsidy.model.PaperDictDO;
import com.subsidy.service.PaperDictService; import com.subsidy.service.PaperDictService;
import com.subsidy.util.ConstantUtils; import com.subsidy.util.ConstantUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import io.swagger.annotations.Api;
/** /**
* <p> * <p>
...@@ -33,26 +33,30 @@ public class PaperDictController { ...@@ -33,26 +33,30 @@ public class PaperDictController {
@PostMapping("queryPapers") @PostMapping("queryPapers")
@ApiOperation("查看课程下的测试 {courseId paperName}") @ApiOperation("查看课程下的测试 {courseId paperName}")
public ResponseVO queryPapers(@RequestBody PaperDictDO paperDictDO){ @LoginRequired(value = {ConstantUtils.ADMINISTER_TERMINATE})
return ResponseData.generateCreatedResponse(0,paperDictService.queryPapers(paperDictDO)); public ResponseVO queryPapers(@RequestBody PaperDictDO paperDictDO) {
return ResponseData.generateCreatedResponse(0, paperDictService.queryPapers(paperDictDO));
} }
@PostMapping("deletePaper") @PostMapping("deletePaper")
@ApiOperation("删除卷子 {id}") @ApiOperation("删除卷子 {id}")
public ResponseVO deletePaper(@RequestBody PaperDictDO paperDictDO){ @LoginRequired(value = {ConstantUtils.ADMINISTER_TERMINATE})
return ResponseData.generateCreatedResponse(0,paperDictService.deletePaper(paperDictDO)); public ResponseVO deletePaper(@RequestBody PaperDictDO paperDictDO) {
return ResponseData.generateCreatedResponse(0, paperDictService.deletePaper(paperDictDO));
} }
@PostMapping("update") @PostMapping("update")
@ApiOperation("启用/禁用 {id paperStatus}") @ApiOperation("启用/禁用 {id paperStatus}")
public ResponseVO updateStatus(@RequestBody PaperDictDO paperDictDO){ @LoginRequired(value = {ConstantUtils.ADMINISTER_TERMINATE})
return ResponseData.generateCreatedResponse(0,paperDictService.updateStatus(paperDictDO)); public ResponseVO updateStatus(@RequestBody PaperDictDO paperDictDO) {
return ResponseData.generateCreatedResponse(0, paperDictService.updateStatus(paperDictDO));
} }
@PostMapping("addPaper") @PostMapping("addPaper")
@ApiOperation("添加卷子 {courseId paperName}") @ApiOperation("添加卷子 {courseId paperName}")
public ResponseVO addPaper(@RequestBody PaperDictDO paperDictDO){ @LoginRequired(value = {ConstantUtils.ADMINISTER_TERMINATE})
return ResponseData.generateCreatedResponse(0,paperDictService.addPaper(paperDictDO)); public ResponseVO addPaper(@RequestBody PaperDictDO paperDictDO) {
return ResponseData.generateCreatedResponse(0, paperDictService.addPaper(paperDictDO));
} }
......
package com.subsidy.controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import io.swagger.annotations.Api;
/**
* <p>
* 权限表 前端控制器
* </p>
*
* @author DengMin
* @since 2021-10-11
*/
@RestController
@Api(tags = "权限表")
@RequestMapping("/permissions-dict-do")
public class PermissionsDictController {
}
package com.subsidy.controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import io.swagger.annotations.Api;
/**
* <p>
* 前端控制器
* </p>
*
* @author DengMin
* @since 2021-10-11
*/
@RestController
@Api(tags = "")
@RequestMapping("/role-administer-mapping-do")
public class RoleAdministerMappingController {
}
package com.subsidy.controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import io.swagger.annotations.Api;
/**
* <p>
* 角色表 前端控制器
* </p>
*
* @author DengMin
* @since 2021-10-11
*/
@RestController
@Api(tags = "角色表")
@RequestMapping("/role-dict-do")
public class RoleDictController {
}
package com.subsidy.controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import io.swagger.annotations.Api;
/**
* <p>
* 系统用户角色表 前端控制器
* </p>
*
* @author DengMin
* @since 2021-10-11
*/
@RestController
@Api(tags = "系统用户角色表")
@RequestMapping("/role-permission-mapping-do")
public class RolePermissionMappingController {
}
...@@ -3,22 +3,17 @@ package com.subsidy.controller; ...@@ -3,22 +3,17 @@ package com.subsidy.controller;
import com.subsidy.common.ResponseData; import com.subsidy.common.ResponseData;
import com.subsidy.common.ResponseVO; import com.subsidy.common.ResponseVO;
import com.subsidy.common.interceptor.LoginRequired;
import com.subsidy.dto.member.GetMemberSignInfoDTO; import com.subsidy.dto.member.GetMemberSignInfoDTO;
import com.subsidy.dto.sign.ClassSignInfoDTO; import com.subsidy.dto.sign.ClassSignInfoDTO;
import com.subsidy.dto.sign.SignInDTO;
import com.subsidy.model.MemberDO;
import com.subsidy.model.SignInRecordDO; import com.subsidy.model.SignInRecordDO;
import com.subsidy.service.SignInRecordService; import com.subsidy.service.SignInRecordService;
import com.subsidy.util.ConstantUtils; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import io.swagger.annotations.Api;
/** /**
* <p> * <p>
...@@ -38,32 +33,32 @@ public class SignInRecordController { ...@@ -38,32 +33,32 @@ public class SignInRecordController {
@PostMapping("getMemberSignInfo") @PostMapping("getMemberSignInfo")
@ApiOperation("** 获取某个成员的签到记录 id 成员id pageSize pageNum") @ApiOperation("** 获取某个成员的签到记录 id 成员id pageSize pageNum")
public ResponseVO getMemberSignInfo(@RequestBody GetMemberSignInfoDTO getMemberSignInfoDTO){ public ResponseVO getMemberSignInfo(@RequestBody GetMemberSignInfoDTO getMemberSignInfoDTO) {
return ResponseData.generateCreatedResponse(0,signInRecordService.getMemberSignInfo(getMemberSignInfoDTO)); return ResponseData.generateCreatedResponse(0, signInRecordService.getMemberSignInfo(getMemberSignInfoDTO));
} }
@PostMapping("signIn") @PostMapping("signIn")
@ApiOperation("** 签到 memberId") @ApiOperation("** 签到 memberId")
public ResponseVO signIn(@RequestBody SignInRecordDO signInRecordDO){ public ResponseVO signIn(@RequestBody SignInRecordDO signInRecordDO) {
return ResponseData.generateCreatedResponse(0,signInRecordService.signIn(signInRecordDO)); return ResponseData.generateCreatedResponse(0, signInRecordService.signIn(signInRecordDO));
} }
@PostMapping("classStudyHistory") @PostMapping("classStudyHistory")
@ApiOperation("** 校区学习记录 id 校区id className courseName pageSize pageNum") @ApiOperation("** 校区学习记录 id 校区id className courseName pageSize pageNum")
//@LoginRequired(value = {ConstantUtils.ADMINISTER_TERMINATE}) //@LoginRequired(value = {ConstantUtils.ADMINISTER_TERMINATE})
public ResponseVO classSignInfo(@RequestBody ClassSignInfoDTO classSignInfoDTO){ public ResponseVO classSignInfo(@RequestBody ClassSignInfoDTO classSignInfoDTO) {
return ResponseData.generateCreatedResponse(0,signInRecordService.classSignInfo(classSignInfoDTO)); return ResponseData.generateCreatedResponse(0, signInRecordService.classSignInfo(classSignInfoDTO));
} }
@PostMapping("signInStatus") @PostMapping("signInStatus")
@ApiOperation("** 判断学生当天有没有打卡 {memberId 学生id}") @ApiOperation("** 判断学生当天有没有打卡 {memberId 学生id}")
public ResponseVO signInStatus(@RequestBody SignInRecordDO signInRecordDO){ public ResponseVO signInStatus(@RequestBody SignInRecordDO signInRecordDO) {
return ResponseData.generateCreatedResponse(0,signInRecordService.signInStatus(signInRecordDO)); return ResponseData.generateCreatedResponse(0, signInRecordService.signInStatus(signInRecordDO));
} }
@PostMapping("getRedisData") @PostMapping("getRedisData")
public ResponseVO test(){ public void test() {
return ResponseData.generateCreatedResponse(0,signInRecordService.test()); signInRecordService.test();
} }
} }
...@@ -5,14 +5,13 @@ import com.subsidy.common.ResponseData; ...@@ -5,14 +5,13 @@ import com.subsidy.common.ResponseData;
import com.subsidy.common.ResponseVO; import com.subsidy.common.ResponseVO;
import com.subsidy.dto.sms.SendVerifyCodeDTO; import com.subsidy.dto.sms.SendVerifyCodeDTO;
import com.subsidy.service.SmsVerifyCodeService; import com.subsidy.service.SmsVerifyCodeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import io.swagger.annotations.Api;
/** /**
* <p> * <p>
......
...@@ -8,14 +8,13 @@ import com.subsidy.dto.content.GetContendVodsDTO; ...@@ -8,14 +8,13 @@ import com.subsidy.dto.content.GetContendVodsDTO;
import com.subsidy.model.VodDictDO; import com.subsidy.model.VodDictDO;
import com.subsidy.service.VodDictService; import com.subsidy.service.VodDictService;
import com.subsidy.util.ConstantUtils; import com.subsidy.util.ConstantUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import io.swagger.annotations.Api;
/** /**
* <p> * <p>
......
...@@ -6,14 +6,13 @@ import com.subsidy.common.ResponseData; ...@@ -6,14 +6,13 @@ import com.subsidy.common.ResponseData;
import com.subsidy.common.ResponseVO; import com.subsidy.common.ResponseVO;
import com.subsidy.model.VodPlayHistoryDO; import com.subsidy.model.VodPlayHistoryDO;
import com.subsidy.service.VodPlayHistoryService; import com.subsidy.service.VodPlayHistoryService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import io.swagger.annotations.Api;
/** /**
* <p> * <p>
......
...@@ -5,10 +5,10 @@ import lombok.Data; ...@@ -5,10 +5,10 @@ import lombok.Data;
@Data @Data
public class ContentMemberDTO { public class ContentMemberDTO {
private Integer memberId; private Long memberId;
private Long courseId; private Long courseId;
private Integer classId; private Long classId;
} }
package com.subsidy.mapper; package com.subsidy.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.subsidy.dto.administer.OperatorsDTO;
import com.subsidy.model.AdministerDO; import com.subsidy.model.AdministerDO;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.subsidy.vo.administer.ExerciseTestVO; import com.subsidy.vo.administer.ExerciseTestVO;
import com.subsidy.vo.administer.OperatorsVO;
import com.subsidy.vo.administer.PermissionsVO; import com.subsidy.vo.administer.PermissionsVO;
import com.subsidy.vo.classdict.ClassDetailVO; import com.subsidy.vo.classdict.ClassDetailVO;
import com.subsidy.vo.member.ClassSignVO; import com.subsidy.vo.member.ClassSignVO;
......
package com.subsidy.mapper; package com.subsidy.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.subsidy.model.AnsweringQuestionDO; import com.subsidy.model.AnsweringQuestionDO;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.subsidy.vo.answer.GetCourseQuestionVO; import com.subsidy.vo.answer.GetCourseQuestionVO;
import com.subsidy.vo.vod.GetContendVodsVO;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
import java.util.List;
/** /**
* <p> * <p>
* 问题答疑表 Mapper 接口 * 问题答疑表 Mapper 接口
......
package com.subsidy.mapper; package com.subsidy.mapper;
import com.subsidy.dto.classDict.GetAllClassesDTO; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.subsidy.dto.classDict.GetSpareMembersDTO; import com.subsidy.dto.classDict.GetSpareMembersDTO;
import com.subsidy.model.ClassDictDO; import com.subsidy.model.ClassDictDO;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.subsidy.model.MemberDO; import com.subsidy.model.MemberDO;
import com.subsidy.model.VodDictDO; import com.subsidy.model.VodDictDO;
import com.subsidy.vo.classdict.GetAllClassesVO; import com.subsidy.vo.classdict.GetAllClassesVO;
......
...@@ -15,10 +15,4 @@ import org.springframework.stereotype.Repository; ...@@ -15,10 +15,4 @@ import org.springframework.stereotype.Repository;
@Repository @Repository
public interface ClassHourDictMapper extends BaseMapper<ClassHourDictDO> { public interface ClassHourDictMapper extends BaseMapper<ClassHourDictDO> {
/**
* 获取课程的次数
* @return
*/
ClassHourDictDO getClassHourDictInfo(Long classId);
} }
package com.subsidy.mapper; package com.subsidy.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.subsidy.dto.classDict.GetSpareMembersDTO;
import com.subsidy.model.ClassDictDO; import com.subsidy.model.ClassDictDO;
import com.subsidy.model.ClassMemberMappingDO; import com.subsidy.model.ClassMemberMappingDO;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.subsidy.model.MemberDO;
import com.subsidy.vo.administer.ClassDailyInfoVO; import com.subsidy.vo.administer.ClassDailyInfoVO;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
...@@ -36,4 +34,9 @@ public interface ClassMemberMappingMapper extends BaseMapper<ClassMemberMappingD ...@@ -36,4 +34,9 @@ public interface ClassMemberMappingMapper extends BaseMapper<ClassMemberMappingD
* 获取班级成员id * 获取班级成员id
*/ */
IPage<ClassDailyInfoVO> getClassMembersWithName(IPage iPage, Long classId, String userName); IPage<ClassDailyInfoVO> getClassMembersWithName(IPage iPage, Long classId, String userName);
/**
* 获取学生当前有效班级
*/
long getMemberClassCount(Long memberId);
} }
package com.subsidy.mapper; package com.subsidy.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.subsidy.model.AdministerDO;
import com.subsidy.model.CompanyDictDO; import com.subsidy.model.CompanyDictDO;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.subsidy.vo.administer.OperatorsVO; import com.subsidy.vo.administer.OperatorsVO;
import com.subsidy.vo.company.GetAllCompanyVO; import com.subsidy.vo.company.GetAllCompanyVO;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
......
package com.subsidy.mapper; package com.subsidy.mapper;
import com.subsidy.model.CourseContentDO;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.subsidy.model.CourseDictDO; import com.subsidy.model.CourseContentDO;
import com.subsidy.model.VodDictDO; import com.subsidy.model.VodDictDO;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
......
package com.subsidy.mapper; package com.subsidy.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.subsidy.model.ClassMemberMappingDO; import com.subsidy.model.ClassMemberMappingDO;
import com.subsidy.model.CourseDictDO; import com.subsidy.model.CourseDictDO;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.subsidy.model.MemberDO;
import com.subsidy.vo.course.QueryCoursesVO; import com.subsidy.vo.course.QueryCoursesVO;
import com.subsidy.vo.member.StudyPageVO; import com.subsidy.vo.member.StudyPageVO;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
import java.util.List; import java.util.List;
......
package com.subsidy.mapper; package com.subsidy.mapper;
import com.subsidy.dto.department.GetDepartmentsVO;
import com.subsidy.model.DepartmentDictDO;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.subsidy.model.DepartmentDictDO;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
import java.util.List;
/** /**
* <p> * <p>
* 部门字典表 Mapper 接口 * 部门字典表 Mapper 接口
......
package com.subsidy.mapper; package com.subsidy.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.subsidy.dto.member.PasswordLoginDTO; import com.subsidy.dto.member.PasswordLoginDTO;
import com.subsidy.model.DepartmentDictDO; import com.subsidy.model.DepartmentDictDO;
import com.subsidy.model.MemberDO; import com.subsidy.model.MemberDO;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.subsidy.vo.administer.UserRoleVO; import com.subsidy.vo.administer.UserRoleVO;
import com.subsidy.vo.member.GetAllVO; import com.subsidy.vo.member.GetAllVO;
import com.subsidy.vo.member.StudyPageVO; import com.subsidy.vo.member.StudyPageVO;
import io.swagger.models.auth.In;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
import java.util.List; import java.util.List;
......
package com.subsidy.mapper; package com.subsidy.mapper;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.subsidy.dto.sign.ClassSignInfoDTO;
import com.subsidy.model.SignInRecordDO; import com.subsidy.model.SignInRecordDO;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.subsidy.vo.sign.ClassSignInfoVO; import com.subsidy.vo.sign.ClassSignInfoVO;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
/** @Repository
* <p>
* 学生签到表 Mapper 接口
* </p>
*
* @author DengMin
* @since 2021-10-18
*/
@Repository
public interface SignInRecordMapper extends BaseMapper<SignInRecordDO> { public interface SignInRecordMapper extends BaseMapper<SignInRecordDO> {
/** /**
* 公司学习记录 * 公司学习记录
*/ */
IPage<ClassSignInfoVO> classSignInfo(IPage iPage,String className,String courseName,Integer id); IPage<ClassSignInfoVO> classSignInfo(IPage iPage, String className, String courseName, Integer id);
} }
package com.subsidy.mapper; package com.subsidy.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.subsidy.model.VodPlayHistoryDO; import com.subsidy.model.VodPlayHistoryDO;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.subsidy.vo.vod.GetMemberStudyInfoVO; import com.subsidy.vo.vod.GetMemberStudyInfoVO;
import com.subsidy.vo.vod.GetVodPlayHistoryVO;
import com.subsidy.vo.vod.StudyHistoryVO; import com.subsidy.vo.vod.StudyHistoryVO;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
...@@ -37,4 +36,9 @@ public interface VodPlayHistoryMapper extends BaseMapper<VodPlayHistoryDO> { ...@@ -37,4 +36,9 @@ public interface VodPlayHistoryMapper extends BaseMapper<VodPlayHistoryDO> {
List<VodPlayHistoryDO> getVodPlayHistory(); List<VodPlayHistoryDO> getVodPlayHistory();
void deleteById(Long id); void deleteById(Long id);
/**
* 查看某人当天看了多少时间
*/
int memberDailyStudyLength(Long memberId);
} }
package com.subsidy.service; package com.subsidy.service;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.IService;
import com.subsidy.dto.administer.ClassDailyInfoDTO; import com.subsidy.dto.administer.ClassDailyInfoDTO;
import com.subsidy.dto.administer.ClassDetailDTO; import com.subsidy.dto.administer.ClassDetailDTO;
import com.subsidy.dto.administer.ClassVodInfoDTO; import com.subsidy.dto.administer.ClassVodInfoDTO;
import com.subsidy.dto.administer.OperatorsDTO; import com.subsidy.dto.administer.OperatorsDTO;
import com.subsidy.model.*; import com.subsidy.model.AdministerDO;
import com.baomidou.mybatisplus.extension.service.IService; import com.subsidy.model.ExerciseDoneHistoryDO;
import com.subsidy.vo.administer.*; import com.subsidy.model.ExerciseDoneResultDO;
import com.subsidy.vo.administer.AdministerPermissionVO;
import com.subsidy.vo.administer.ClassDailyInfoVO;
import com.subsidy.vo.administer.ClassSummaryVO;
import com.subsidy.vo.administer.ClassVodInfoVO;
import com.subsidy.vo.administer.ExerciseTestVO;
import com.subsidy.vo.administer.GetMemberPapersVO;
import com.subsidy.vo.administer.GetPaperDetailVO;
import com.subsidy.vo.administer.LoginVO;
import com.subsidy.vo.administer.OperatorsVO;
import com.subsidy.vo.classdict.ClassDetailVO; import com.subsidy.vo.classdict.ClassDetailVO;
import com.subsidy.vo.member.ClassSignVO; import com.subsidy.vo.member.ClassSignVO;
import com.subsidy.vo.sign.AnswerRecordVO; import com.subsidy.vo.sign.AnswerRecordVO;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse;
import java.util.List; import java.util.List;
/** /**
...@@ -68,5 +77,4 @@ public interface AdministerService extends IService<AdministerDO> { ...@@ -68,5 +77,4 @@ public interface AdministerService extends IService<AdministerDO> {
String importMember(Long companyId, MultipartFile multipartFile); String importMember(Long companyId, MultipartFile multipartFile);
void importRedis();
} }
package com.subsidy.service; package com.subsidy.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.subsidy.dto.classDict.AddClassDTO; import com.subsidy.dto.classDict.AddClassDTO;
import com.subsidy.dto.classDict.AddMemberToClassDTO; import com.subsidy.dto.classDict.AddMemberToClassDTO;
import com.subsidy.dto.classDict.GetAllClassesDTO;
import com.subsidy.dto.classDict.GetSpareMembersDTO; import com.subsidy.dto.classDict.GetSpareMembersDTO;
import com.subsidy.model.ClassDictDO; import com.subsidy.model.ClassDictDO;
import com.baomidou.mybatisplus.extension.service.IService;
import com.subsidy.model.ClassMemberMappingDO; import com.subsidy.model.ClassMemberMappingDO;
import com.subsidy.model.CourseDictDO;
import com.subsidy.model.MemberDO; import com.subsidy.model.MemberDO;
import com.subsidy.vo.classdict.GetAllClassesVO; import com.subsidy.vo.classdict.GetAllClassesVO;
......
package com.subsidy.service;
import com.subsidy.model.ClassMemberMappingDO;
import com.baomidou.mybatisplus.extension.service.IService;
/**
* <p>
* 班级成员映射表 服务类
* </p>
*
* @author DengMin
* @since 2021-10-12
*/
public interface ClassMemberMappingService extends IService<ClassMemberMappingDO> {
}
package com.subsidy.service; package com.subsidy.service;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.IService;
import com.subsidy.dto.administer.OperatorsDTO; import com.subsidy.dto.administer.OperatorsDTO;
import com.subsidy.dto.company.AddCompanyDTO; import com.subsidy.dto.company.AddCompanyDTO;
import com.subsidy.model.AdministerDO;
import com.subsidy.model.CompanyDictDO; import com.subsidy.model.CompanyDictDO;
import com.baomidou.mybatisplus.extension.service.IService;
import com.subsidy.vo.administer.OperatorsVO; import com.subsidy.vo.administer.OperatorsVO;
import com.subsidy.vo.company.GetAllCompanyVO; import com.subsidy.vo.company.GetAllCompanyVO;
import com.subsidy.vo.member.GetAllVO;
import java.util.List; import java.util.List;
......
package com.subsidy.service; package com.subsidy.service;
import com.subsidy.controller.CourseDictController;
import com.subsidy.model.CourseContentDO;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
import com.subsidy.model.CourseDictDO; import com.subsidy.model.CourseContentDO;
import com.subsidy.model.VodDictDO;
import com.subsidy.vo.vod.GetContendVodsVO;
import java.util.List; import java.util.List;
......
package com.subsidy.service; package com.subsidy.service;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.IService;
import com.subsidy.dto.administer.VerifyCodeDTO; import com.subsidy.dto.administer.VerifyCodeDTO;
import com.subsidy.dto.member.*; import com.subsidy.dto.member.AddMemberDTO;
import com.subsidy.model.ExerciseDoneHistoryDO; import com.subsidy.dto.member.ContentMemberDTO;
import com.subsidy.dto.member.GetAllDTO;
import com.subsidy.dto.member.PasswordLoginDTO;
import com.subsidy.dto.member.StudyHistoryDTO;
import com.subsidy.model.ExerciseDoneResultDO; import com.subsidy.model.ExerciseDoneResultDO;
import com.subsidy.model.MemberDO; import com.subsidy.model.MemberDO;
import com.baomidou.mybatisplus.extension.service.IService;
import com.subsidy.vo.administer.UserRoleVO; import com.subsidy.vo.administer.UserRoleVO;
import com.subsidy.vo.member.*; import com.subsidy.vo.member.ContentFilesVO;
import com.subsidy.vo.member.ContentVodNewVO;
import com.subsidy.vo.member.GetAllVO;
import com.subsidy.vo.member.GetStudyInfoVO;
import com.subsidy.vo.member.MemberStudyPageVO;
import com.subsidy.vo.paper.QueryPapersVO; import com.subsidy.vo.paper.QueryPapersVO;
import java.lang.reflect.Member;
import java.util.List; import java.util.List;
/** /**
......
package com.subsidy.service; package com.subsidy.service;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.IService;
import com.subsidy.dto.member.GetMemberSignInfoDTO; import com.subsidy.dto.member.GetMemberSignInfoDTO;
import com.subsidy.dto.sign.ClassSignInfoDTO; import com.subsidy.dto.sign.ClassSignInfoDTO;
import com.subsidy.dto.sign.SignInDTO;
import com.subsidy.model.MemberDO;
import com.subsidy.model.SignInRecordDO; import com.subsidy.model.SignInRecordDO;
import com.baomidou.mybatisplus.extension.service.IService;
import com.subsidy.vo.member.GetMemberSignInfoVO; import com.subsidy.vo.member.GetMemberSignInfoVO;
import com.subsidy.vo.sign.SignInStatusVO; import com.subsidy.vo.sign.SignInStatusVO;
import com.tencentcloudapi.common.Sign;
/** /**
* <p> * <p>
...@@ -29,5 +26,5 @@ public interface SignInRecordService extends IService<SignInRecordDO> { ...@@ -29,5 +26,5 @@ public interface SignInRecordService extends IService<SignInRecordDO> {
SignInStatusVO signInStatus(SignInRecordDO signInRecordDO); SignInStatusVO signInStatus(SignInRecordDO signInRecordDO);
Object test(); void test();
} }
package com.subsidy.service; package com.subsidy.service;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.IService;
import com.subsidy.dto.content.GetContendVodsDTO; import com.subsidy.dto.content.GetContendVodsDTO;
import com.subsidy.model.VodDictDO; import com.subsidy.model.VodDictDO;
import com.baomidou.mybatisplus.extension.service.IService;
import com.subsidy.vo.vod.GetContendVodsVO; import com.subsidy.vo.vod.GetContendVodsVO;
import com.subsidy.vo.vod.SignatureVO; import com.subsidy.vo.vod.SignatureVO;
import java.util.List;
/** /**
* <p> * <p>
* 视频表 服务类 * 视频表 服务类
......
...@@ -3,19 +3,62 @@ package com.subsidy.service.impl; ...@@ -3,19 +3,62 @@ package com.subsidy.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.subsidy.common.RedisPrefixConstant;
import com.subsidy.common.exception.HttpException; import com.subsidy.common.exception.HttpException;
import com.subsidy.dto.administer.ClassDailyInfoDTO; import com.subsidy.dto.administer.ClassDailyInfoDTO;
import com.subsidy.dto.administer.ClassDetailDTO; import com.subsidy.dto.administer.ClassDetailDTO;
import com.subsidy.dto.administer.ClassVodInfoDTO; import com.subsidy.dto.administer.ClassVodInfoDTO;
import com.subsidy.dto.administer.OperatorsDTO; import com.subsidy.dto.administer.OperatorsDTO;
import com.subsidy.dto.member.ImportMemberDTO; import com.subsidy.dto.member.ImportMemberDTO;
import com.subsidy.mapper.*; import com.subsidy.mapper.AdministerMapper;
import com.subsidy.model.*; import com.subsidy.mapper.AnsweringQuestionMapper;
import com.subsidy.mapper.ClassDictMapper;
import com.subsidy.mapper.ClassMemberMappingMapper;
import com.subsidy.mapper.CompanyDictMapper;
import com.subsidy.mapper.CourseDictMapper;
import com.subsidy.mapper.DepartmentDictMapper;
import com.subsidy.mapper.ExerciseDoneResultMapper;
import com.subsidy.mapper.MemberDepartmentMappingMapper;
import com.subsidy.mapper.MemberMapper;
import com.subsidy.mapper.OprAdmDictMapper;
import com.subsidy.mapper.RoleAdministerMappingMapper;
import com.subsidy.mapper.VodDictMapper;
import com.subsidy.mapper.VodPlayHistoryMapper;
import com.subsidy.model.AdministerDO;
import com.subsidy.model.AnsweringQuestionDO;
import com.subsidy.model.ClassDictDO;
import com.subsidy.model.ClassMemberMappingDO;
import com.subsidy.model.CompanyDictDO;
import com.subsidy.model.CourseDictDO;
import com.subsidy.model.DepartmentDictDO;
import com.subsidy.model.ExerciseDoneHistoryDO;
import com.subsidy.model.ExerciseDoneResultDO;
import com.subsidy.model.MemberDO;
import com.subsidy.model.MemberDepartmentMappingDO;
import com.subsidy.model.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.service.AdministerService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.subsidy.util.ConstantUtils;
import com.subsidy.util.*; import com.subsidy.util.ExcelFormatUtils;
import com.subsidy.util.JwtUtil;
import com.subsidy.util.Localstorage;
import com.subsidy.util.MathUtil;
import com.subsidy.util.RedisUtil;
import com.subsidy.util.excel.ExcelUtil; import com.subsidy.util.excel.ExcelUtil;
import com.subsidy.vo.administer.*; import com.subsidy.vo.administer.AdministerPermissionVO;
import com.subsidy.vo.administer.ClassDailyInfoVO;
import com.subsidy.vo.administer.ClassSummaryVO;
import com.subsidy.vo.administer.ClassVodInfoVO;
import com.subsidy.vo.administer.ExerciseTestVO;
import com.subsidy.vo.administer.GetMemberPapersVO;
import com.subsidy.vo.administer.GetPaperDetailVO;
import com.subsidy.vo.administer.LoginVO;
import com.subsidy.vo.administer.OperatorsVO;
import com.subsidy.vo.administer.PermissionsVO;
import com.subsidy.vo.classdict.ClassDetailVO; import com.subsidy.vo.classdict.ClassDetailVO;
import com.subsidy.vo.done.GetMaxScoreVO; import com.subsidy.vo.done.GetMaxScoreVO;
import com.subsidy.vo.member.ClassSignVO; import com.subsidy.vo.member.ClassSignVO;
...@@ -29,7 +72,8 @@ import net.sourceforge.pinyin4j.format.HanyuPinyinOutputFormat; ...@@ -29,7 +72,8 @@ import net.sourceforge.pinyin4j.format.HanyuPinyinOutputFormat;
import net.sourceforge.pinyin4j.format.HanyuPinyinToneType; import net.sourceforge.pinyin4j.format.HanyuPinyinToneType;
import net.sourceforge.pinyin4j.format.exception.BadHanyuPinyinOutputFormatCombination; import net.sourceforge.pinyin4j.format.exception.BadHanyuPinyinOutputFormatCombination;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.poi.hssf.usermodel.*; import org.apache.poi.hssf.usermodel.HSSFCellStyle;
import org.apache.poi.hssf.usermodel.HSSFFont;
import org.apache.poi.hssf.util.CellRangeAddress; import org.apache.poi.hssf.util.CellRangeAddress;
import org.apache.poi.ss.usermodel.CellStyle; import org.apache.poi.ss.usermodel.CellStyle;
import org.apache.poi.ss.usermodel.Font; import org.apache.poi.ss.usermodel.Font;
...@@ -39,7 +83,8 @@ import org.apache.poi.xssf.streaming.SXSSFSheet; ...@@ -39,7 +83,8 @@ import org.apache.poi.xssf.streaming.SXSSFSheet;
import org.apache.poi.xssf.streaming.SXSSFWorkbook; import org.apache.poi.xssf.streaming.SXSSFWorkbook;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate; import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.AsyncResult;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.context.request.RequestContextHolder; import org.springframework.web.context.request.RequestContextHolder;
...@@ -48,12 +93,20 @@ import org.springframework.web.multipart.MultipartFile; ...@@ -48,12 +93,20 @@ import org.springframework.web.multipart.MultipartFile;
import javax.servlet.ServletOutputStream; import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.io.*; import java.io.BufferedInputStream;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.text.ParseException; import java.util.ArrayList;
import java.text.SimpleDateFormat; import java.util.Arrays;
import java.util.*; 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.zip.ZipEntry; import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream; import java.util.zip.ZipOutputStream;
...@@ -88,9 +141,6 @@ public class AdministerServiceImpl extends ServiceImpl<AdministerMapper, Adminis ...@@ -88,9 +141,6 @@ public class AdministerServiceImpl extends ServiceImpl<AdministerMapper, Adminis
private CourseDictMapper courseDictMapper; private CourseDictMapper courseDictMapper;
@Autowired @Autowired
private SignInRecordMapper signInRecordMapper;
@Autowired
private CompanyDictMapper companyDictMapper; private CompanyDictMapper companyDictMapper;
@Autowired @Autowired
...@@ -121,15 +171,15 @@ public class AdministerServiceImpl extends ServiceImpl<AdministerMapper, Adminis ...@@ -121,15 +171,15 @@ public class AdministerServiceImpl extends ServiceImpl<AdministerMapper, Adminis
/** /**
* 先从redis里拿 * 先从redis里拿
*/ */
AdministerDO administerDO1 = (AdministerDO)redisUtil.get("subsidyAdminister_"+administerDO.getAccountName()); AdministerDO administerDO1 = (AdministerDO) redisUtil.get(RedisPrefixConstant.SUBSIDY_ADMINISTER_PREFIX + administerDO.getAccountName());
if (null==administerDO1){ if (null == administerDO1) {
/** /**
* 查表,并将数据写入到redis * 查表,并将数据写入到redis
*/ */
administerDO1 = this.baseMapper.selectOne(new QueryWrapper<AdministerDO>() administerDO1 = this.baseMapper.selectOne(new QueryWrapper<AdministerDO>()
.lambda() .lambda()
.eq(AdministerDO::getAccountName, administerDO.getAccountName())); .eq(AdministerDO::getAccountName, administerDO.getAccountName()));
redisUtil.set("subsidyAdminister_"+administerDO.getAccountName(),administerDO1); redisUtil.set(RedisPrefixConstant.SUBSIDY_ADMINISTER_PREFIX + administerDO.getAccountName(), administerDO1);
} }
/** /**
...@@ -178,15 +228,15 @@ public class AdministerServiceImpl extends ServiceImpl<AdministerMapper, Adminis ...@@ -178,15 +228,15 @@ public class AdministerServiceImpl extends ServiceImpl<AdministerMapper, Adminis
i++; i++;
} }
if (i == 0 ) { if (i == 0) {
throw new HttpException(10024); throw new HttpException(10024);
} else if (i == 1) { } else if (i == 1) {
throw new HttpException(10023); throw new HttpException(10023);
} else if (i == 2) { } else if (i == 2) {
throw new HttpException(10022); throw new HttpException(10022);
} else if (i ==3){ } else if (i == 3) {
throw new HttpException(10021); throw new HttpException(10021);
}else { } else {
throw new HttpException(10016); throw new HttpException(10016);
} }
...@@ -196,6 +246,7 @@ public class AdministerServiceImpl extends ServiceImpl<AdministerMapper, Adminis ...@@ -196,6 +246,7 @@ public class AdministerServiceImpl extends ServiceImpl<AdministerMapper, Adminis
} }
} }
public AdministerPermissionVO getPermissions() { public AdministerPermissionVO getPermissions() {
AdministerPermissionVO administerPermissionVO = new AdministerPermissionVO(); AdministerPermissionVO administerPermissionVO = new AdministerPermissionVO();
...@@ -243,6 +294,7 @@ public class AdministerServiceImpl extends ServiceImpl<AdministerMapper, Adminis ...@@ -243,6 +294,7 @@ public class AdministerServiceImpl extends ServiceImpl<AdministerMapper, Adminis
return companyDictMapper.operators(pager, operatorsDTO.getCompanyName(), operatorsDTO.getId(), operatorsDTO.getUserName(), 0); return companyDictMapper.operators(pager, operatorsDTO.getCompanyName(), operatorsDTO.getId(), operatorsDTO.getUserName(), 0);
} }
@Async
public String addAdminister(AdministerDO administerDO) { public String addAdminister(AdministerDO administerDO) {
int count = this.baseMapper.selectCount(new QueryWrapper<AdministerDO>() int count = this.baseMapper.selectCount(new QueryWrapper<AdministerDO>()
...@@ -266,11 +318,13 @@ public class AdministerServiceImpl extends ServiceImpl<AdministerMapper, Adminis ...@@ -266,11 +318,13 @@ public class AdministerServiceImpl extends ServiceImpl<AdministerMapper, Adminis
return ConstantUtils.ADD_SUCCESS; return ConstantUtils.ADD_SUCCESS;
} }
@Async
public String deleteAdminister(AdministerDO administerDO) { public String deleteAdminister(AdministerDO administerDO) {
this.baseMapper.deleteById(administerDO.getId()); this.baseMapper.deleteById(administerDO.getId());
return ConstantUtils.DELETE_SUCCESS; return ConstantUtils.DELETE_SUCCESS;
} }
@Async
public String updateAdminister(AdministerDO administerDO) { public String updateAdminister(AdministerDO administerDO) {
int count = this.baseMapper.selectCount(new QueryWrapper<AdministerDO>() int count = this.baseMapper.selectCount(new QueryWrapper<AdministerDO>()
...@@ -284,7 +338,7 @@ public class AdministerServiceImpl extends ServiceImpl<AdministerMapper, Adminis ...@@ -284,7 +338,7 @@ public class AdministerServiceImpl extends ServiceImpl<AdministerMapper, Adminis
this.baseMapper.updateById(administerDO); this.baseMapper.updateById(administerDO);
AdministerDO administerDO1 = this.baseMapper.selectById(administerDO.getId()); AdministerDO administerDO1 = this.baseMapper.selectById(administerDO.getId());
//更新redis里该老师的数据 //更新redis里该老师的数据
redisUtil.set("subsidyAdminister_"+administerDO1.getAccountName(),administerDO1); redisUtil.set(RedisPrefixConstant.SUBSIDY_ADMINISTER_PREFIX + administerDO1.getAccountName(), administerDO1);
return ConstantUtils.SET_SUCCESS; return ConstantUtils.SET_SUCCESS;
} }
...@@ -312,6 +366,38 @@ public class AdministerServiceImpl extends ServiceImpl<AdministerMapper, Adminis ...@@ -312,6 +366,38 @@ public class AdministerServiceImpl extends ServiceImpl<AdministerMapper, Adminis
List<VodDictDO> vodDictDOS = classDictMapper.getClassVods(classDetailDTO.getId()); List<VodDictDO> vodDictDOS = classDictMapper.getClassVods(classDetailDTO.getId());
classSummaryVO.setTotalVodCounts(vodDictDOS.size()); classSummaryVO.setTotalVodCounts(vodDictDOS.size());
/**
* 学生平均学习时长和平均学习次数
*/
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 totalStudyVods = 0;
int totalStudyLength = 0; int totalStudyLength = 0;
...@@ -340,11 +426,15 @@ public class AdministerServiceImpl extends ServiceImpl<AdministerMapper, Adminis ...@@ -340,11 +426,15 @@ public class AdministerServiceImpl extends ServiceImpl<AdministerMapper, Adminis
//平均完成时长 学生观看课程视频的全部时长/总人数 //平均完成时长 学生观看课程视频的全部时长/总人数
int avg = MathUtil.intDivCeil(totalStudyLength, classMemberMappingDOS.size()); int avg = MathUtil.intDivCeil(totalStudyLength, classMemberMappingDOS.size());
classSummaryVO.setAvgVodPlayLength(avg); classSummaryVO.setAvgVodPlayLength(avg);
return new AsyncResult<>(classSummaryVO);
}
public Future<ClassSummaryVO> summaryTask2(ClassSummaryVO classSummaryVO, Long classId) {
//测试通过率 //测试通过率
List<ExerciseDoneResultDO> exerciseDoneResultDOS = exerciseDoneResultMapper.selectList(new QueryWrapper<ExerciseDoneResultDO>() List<ExerciseDoneResultDO> exerciseDoneResultDOS = exerciseDoneResultMapper.selectList(new QueryWrapper<ExerciseDoneResultDO>()
.lambda() .lambda()
.eq(ExerciseDoneResultDO::getClassId, classDetailDTO.getId())); .eq(ExerciseDoneResultDO::getClassId, classId));
int passNum = 0; int passNum = 0;
...@@ -353,23 +443,25 @@ public class AdministerServiceImpl extends ServiceImpl<AdministerMapper, Adminis ...@@ -353,23 +443,25 @@ public class AdministerServiceImpl extends ServiceImpl<AdministerMapper, Adminis
passNum++; passNum++;
} }
} }
classSummaryVO.setPassRate(MathUtil.intDivFloorPercent(passNum, classMemberMappingDOS.size()));
classSummaryVO.setPassRate(MathUtil.intDivFloorPercent(passNum, classSummaryVO.getMemberCount()));
return new AsyncResult<>(classSummaryVO);
}
//平均签到数 向上取整 public Future<ClassSummaryVO> summaryTask3(ClassSummaryVO classSummaryVO, Long classId) {
//签到总次数 //签到总次数
Integer signCount = signInRecordMapper.selectCount(new QueryWrapper<SignInRecordDO>() long signCount = redisUtil.keys("subsidySignInfo*_classId_" + classId + "*").stream().count();
.lambda() classSummaryVO.setAvgSignCount(MathUtil.intDivCeil(signCount, classSummaryVO.getMemberCount()));
.eq(SignInRecordDO::getClassId, classDetailDTO.getId())); return new AsyncResult<>(classSummaryVO);
classSummaryVO.setAvgSignCount(MathUtil.intDivCeil(signCount, classMemberMappingDOS.size())); }
public Future<ClassSummaryVO> summaryTask4(ClassSummaryVO classSummaryVO, Long classId) {
//答疑数 //答疑数
Integer count = answeringQuestionMapper.selectCount(new QueryWrapper<AnsweringQuestionDO>() Integer count = answeringQuestionMapper.selectCount(new QueryWrapper<AnsweringQuestionDO>()
.lambda() .lambda()
.eq(AnsweringQuestionDO::getClassId, classDetailDTO.getId())); .eq(AnsweringQuestionDO::getClassId, classId));
classSummaryVO.setAnswerCount(count); classSummaryVO.setAnswerCount(count);
return new AsyncResult<>(classSummaryVO);
return classSummaryVO;
} }
public IPage<ClassDetailVO> classDetail(ClassDetailDTO classDetailDTO) { public IPage<ClassDetailVO> classDetail(ClassDetailDTO classDetailDTO) {
...@@ -390,74 +482,109 @@ public class AdministerServiceImpl extends ServiceImpl<AdministerMapper, Adminis ...@@ -390,74 +482,109 @@ public class AdministerServiceImpl extends ServiceImpl<AdministerMapper, Adminis
//全部视频数 //全部视频数
classDetailVO.setAllVodCounts(vodDictDOS.size()); classDetailVO.setAllVodCounts(vodDictDOS.size());
//该学生完成了多少个 /**
int i = 0; * 学生平均学习时长和平均学习次数
int playLength = 0; */
//该成员完成了几个视频 ExecutorService cachedThreadPool = Executors.newCachedThreadPool();
for (VodDictDO vodDictDO : vodDictDOS) {
List<VodPlayHistoryDO> vodPlayHistoryDOS = vodPlayHistoryMapper.selectList(new QueryWrapper<VodPlayHistoryDO>() //多个任务
.lambda() cachedThreadPool.execute(() -> ///该学生完成了多少个 学生成绩,学生进度
.eq(VodPlayHistoryDO::getMemberId, classDetailVO.getId()) classDetailTask1(classDetailVO, vodDictDOS, classDictDO.getId(), classDetailVO.getId()));
.eq(VodPlayHistoryDO::getVodId, vodDictDO.getId()) cachedThreadPool.execute(() -> //答疑
.orderByDesc(VodPlayHistoryDO::getPlayRecord)); classDetailTask2(classDetailVO, classDetailDTO));
cachedThreadPool.execute(() -> //签到
classDetailTask3(classDetailVO, classDetailDTO));
if (vodPlayHistoryDOS.size() > 0) {
if (vodPlayHistoryDOS.get(0).getPlayRecord() > vodDictDO.getVodLength() * 0.8) { //执行后不再接收新任务,如果里面有任务,就执行完
i++; cachedThreadPool.shutdown();
try {
while (true) {
//等待所有任务都结束了继续执行
if (cachedThreadPool.isTerminated()) {
break;
} }
} }
} catch (Exception ex) {
ex.printStackTrace();
}
}
classDetailVOIPage.setRecords(classDetailVOS);
return classDetailVOIPage;
}
for (VodPlayHistoryDO vodPlayHistoryDO : vodPlayHistoryDOS) { public Future<ClassDetailVO> classDetailTask1(ClassDetailVO classDetailVO, List<VodDictDO> vodDictDOS, Long classId, Long memberId) {
playLength += vodPlayHistoryDO.getPlayLength();
//该学生完成了多少个
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) {
i++;
} }
}
for (VodPlayHistoryDO vodPlayHistoryDO : vodPlayHistoryDOS) {
playLength += vodPlayHistoryDO.getPlayLength();
} }
classDetailVO.setStudyVodCounts(i);
//学生测试完成情况 多套卷子各返回最高成绩 }
List<GetMaxScoreVO> getMaxScoreVOS = exerciseDoneResultMapper.getMaxScore(classDictDO.getId(), classDetailVO.getId()); classDetailVO.setStudyVodCounts(i);
classDetailVO.setGetMaxScoreVOS(getMaxScoreVOS);
Boolean flag = true; //学生测试完成情况 多套卷子各返回最高成绩
List<GetMaxScoreVO> getMaxScoreVOS = exerciseDoneResultMapper.getMaxScore(classId, classDetailVO.getId());
classDetailVO.setGetMaxScoreVOS(getMaxScoreVOS);
if (getMaxScoreVOS.size() > 0) { Boolean flag = true;
for (GetMaxScoreVO getMaxScoreVO : getMaxScoreVOS) {
if (getMaxScoreVO.getScore() < 60) { if (getMaxScoreVOS.size() > 0) {
flag = false; for (GetMaxScoreVO getMaxScoreVO : getMaxScoreVOS) {
} if (getMaxScoreVO.getScore() < 60) {
flag = false;
} }
} else {
flag = false;
} }
} else {
flag = false;
}
if (flag && i == vodDictDOS.size()) {
classDetailVO.setResult("合格");
} else {
classDetailVO.setResult("不合格");
}
if (flag && i == vodDictDOS.size()) { classDetailVO.setClassProcess(i + "/" + vodDictDOS.size());
classDetailVO.setResult("合格");
} else {
classDetailVO.setResult("不合格");
}
classDetailVO.setClassProcess(i + "/" + vodDictDOS.size()); //培训时长
//答疑 classDetailVO.setTrainingLength(playLength);
Integer count = answeringQuestionMapper.selectCount(new QueryWrapper<AnsweringQuestionDO>() return new AsyncResult<>(classDetailVO);
.lambda() }
.eq(AnsweringQuestionDO::getAskId, classDetailVO.getId())
.eq(AnsweringQuestionDO::getClassId, classDetailDTO.getId()));
classDetailVO.setAskCounts(count);
//签到次数 public Future<ClassDetailVO> classDetailTask2(ClassDetailVO classDetailVO, ClassDetailDTO classDetailDTO) {
Integer signCount = signInRecordMapper.selectCount(new QueryWrapper<SignInRecordDO>()
.lambda()
.eq(SignInRecordDO::getMemberId, classDetailVO.getId())
.eq(SignInRecordDO::getClassId, classDetailDTO.getId()));
classDetailVO.setSignCounts(signCount);
//培训时长 //答疑
classDetailVO.setTrainingLength(playLength); Integer count = answeringQuestionMapper.selectCount(new QueryWrapper<AnsweringQuestionDO>()
} .lambda()
classDetailVOIPage.setRecords(classDetailVOS); .eq(AnsweringQuestionDO::getAskId, classDetailVO.getId())
return classDetailVOIPage; .eq(AnsweringQuestionDO::getClassId, classDetailDTO.getId()));
classDetailVO.setAskCounts(count);
return new AsyncResult<>(classDetailVO);
}
public Future<ClassDetailVO> classDetailTask3(ClassDetailVO classDetailVO, ClassDetailDTO classDetailDTO) {
////签到次数
long set = redisUtil.keys(RedisPrefixConstant.SUBSIDY_SIGN_INFO_PREFIX + "memberId_" + classDetailVO.getId() + "_classId_" + classDetailDTO.getId() + "*").stream().count();
classDetailVO.setSignCounts(set);
return new AsyncResult<>(classDetailVO);
} }
public List<ClassDetailVO> exportClassDetail(ClassDetailDTO classDetailDTO) throws Exception { public List<ClassDetailVO> exportClassDetail(ClassDetailDTO classDetailDTO) throws Exception {
...@@ -477,87 +604,100 @@ public class AdministerServiceImpl extends ServiceImpl<AdministerMapper, Adminis ...@@ -477,87 +604,100 @@ public class AdministerServiceImpl extends ServiceImpl<AdministerMapper, Adminis
//全部视频数 //全部视频数
//classDetailVO.setAllVodCounts(vodDictDOS.size()); //classDetailVO.setAllVodCounts(vodDictDOS.size());
//该学生完成了多少个 final ExecutorService newCachedThreadPool = Executors.newCachedThreadPool();
int i = 0;
int playLength = 0; //多个任务
//该成员完成了几个视频 newCachedThreadPool.execute(() -> ///该学生完成了多少个 学生成绩,学生进度
for (VodDictDO vodDictDO : vodDictDOS) { exportClassDetailTask(classDetailVO, vodDictDOS, classDictDO.getId(), classDetailVO.getId()));
List<VodPlayHistoryDO> vodPlayHistoryDOS = vodPlayHistoryMapper.selectList(new QueryWrapper<VodPlayHistoryDO>() newCachedThreadPool.execute(() -> //答疑
.lambda() classDetailTask2(classDetailVO, classDetailDTO));
.eq(VodPlayHistoryDO::getMemberId, classDetailVO.getId()) newCachedThreadPool.execute(() -> //签到
.eq(VodPlayHistoryDO::getVodId, vodDictDO.getId()) classDetailTask3(classDetailVO, classDetailDTO));
.orderByDesc(VodPlayHistoryDO::getPlayRecord));
//执行后不再接收新任务,如果里面有任务,就执行完
if (vodPlayHistoryDOS.size() > 0) { newCachedThreadPool.shutdown();
if (vodPlayHistoryDOS.get(0).getPlayRecord() > vodDictDO.getVodLength() * 0.8) { try {
i++; while (true) {
//等待所有任务都结束了继续执行
if (newCachedThreadPool.isTerminated()) {
break;
} }
} }
} catch (Exception ex) {
for (VodPlayHistoryDO vodPlayHistoryDO : vodPlayHistoryDOS) { ex.printStackTrace();
playLength += vodPlayHistoryDO.getPlayLength();
}
} }
//classDetailVO.setStudyVodCounts(i); }
classDetailVO.setClassProcess(i + "/" + vodDictDOS.size());
//学生测试完成情况 多套卷子各返回最高成绩 if (classDetailDTO.getFlag()) {
List<GetMaxScoreVO> getMaxScoreVOS = exerciseDoneResultMapper.getMaxScore(classDictDO.getId(), classDetailVO.getId()); CourseDictDO courseDictDO = courseDictMapper.selectById(classDictDO.getCourseId());
classDetailVO.setGetMaxScoreVOS(getMaxScoreVOS); String studyDate = classDictDO.getStartDate() + " 至 " + classDictDO.getEndDate();
ExcelUtil.writeMemberExcel(companyDictDO.getCompanyName(), studyDate, courseDictDO.getCourseName(), "授课记录汇总表", classDetailVOS, ExcelFormatUtils.memberList);
}
return classDetailVOS;
}
Boolean flag = true; public Future exportClassDetailTask(ClassDetailVO classDetailVO, List<VodDictDO> vodDictDOS, Long classId, Long memberId) {
StringBuilder stringBuilder = new StringBuilder(); //该学生完成了多少个
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 (getMaxScoreVOS.size() > 0) { if (vodPlayHistoryDOS.size() > 0) {
for (GetMaxScoreVO getMaxScoreVO : getMaxScoreVOS) { if (vodPlayHistoryDOS.get(0).getPlayRecord() > vodDictDO.getVodLength() * 0.8) {
stringBuilder.append(getMaxScoreVO.getPaperName() + ":" + getMaxScoreVO.getScore()); i++;
if (getMaxScoreVO.getScore() < 60) {
flag = false;
}
stringBuilder.append(" ");
} }
} else {
flag = false;
} }
if (flag && i == vodDictDOS.size()) {
classDetailVO.setResult("合格"); for (VodPlayHistoryDO vodPlayHistoryDO : vodPlayHistoryDOS) {
} else { playLength += vodPlayHistoryDO.getPlayLength();
classDetailVO.setResult("不合格");
} }
}
//classDetailVO.setStudyVodCounts(i);
classDetailVO.setClassProcess(i + "/" + vodDictDOS.size());
classDetailVO.setScore(stringBuilder.toString()); //学生测试完成情况 多套卷子各返回最高成绩
List<GetMaxScoreVO> getMaxScoreVOS = exerciseDoneResultMapper.getMaxScore(classId, classDetailVO.getId());
classDetailVO.setGetMaxScoreVOS(getMaxScoreVOS);
//答疑 Boolean flag = true;
Integer count = answeringQuestionMapper.selectCount(new QueryWrapper<AnsweringQuestionDO>()
.lambda()
.eq(AnsweringQuestionDO::getAskId, classDetailVO.getId())
.eq(AnsweringQuestionDO::getClassId, classDetailDTO.getId()));
classDetailVO.setAskCounts(count);
//签到次数 StringBuilder stringBuilder = new StringBuilder();
Integer signCount = signInRecordMapper.selectCount(new QueryWrapper<SignInRecordDO>()
.lambda() if (getMaxScoreVOS.size() > 0) {
.eq(SignInRecordDO::getMemberId, classDetailVO.getId()) for (GetMaxScoreVO getMaxScoreVO : getMaxScoreVOS) {
.eq(SignInRecordDO::getClassId, classDetailDTO.getId())); stringBuilder.append(getMaxScoreVO.getPaperName() + ":" + getMaxScoreVO.getScore());
classDetailVO.setSignCounts(signCount); if (getMaxScoreVO.getScore() < 60) {
flag = false;
}
stringBuilder.append(" ");
}
//培训时长 } else {
classDetailVO.setTrainingLength(playLength); flag = false;
classDetailVO.setTrainingLengthStr(MathUtil.secToTime(playLength));
} }
if (classDetailDTO.getFlag()) { if (flag && i == vodDictDOS.size()) {
CourseDictDO courseDictDO = courseDictMapper.selectById(classDictDO.getCourseId()); classDetailVO.setResult("合格");
String studyDate = classDictDO.getStartDate() + " 至 " + classDictDO.getEndDate(); } else {
ExcelUtil.writeMemberExcel(companyDictDO.getCompanyName(), studyDate, courseDictDO.getCourseName(), "授课记录汇总表", classDetailVOS, ExcelFormatUtils.memberList); classDetailVO.setResult("不合格");
} }
return classDetailVOS;
}
classDetailVO.setScore(stringBuilder.toString());
//培训时长
classDetailVO.setTrainingLength(playLength);
classDetailVO.setTrainingLengthStr(MathUtil.secToTime(playLength));
return new AsyncResult(classDetailVO);
}
public IPage<ClassSignVO> signDetail(ClassDetailDTO classDetailDTO) { public IPage<ClassSignVO> signDetail(ClassDetailDTO classDetailDTO) {
...@@ -571,58 +711,83 @@ public class AdministerServiceImpl extends ServiceImpl<AdministerMapper, Adminis ...@@ -571,58 +711,83 @@ public class AdministerServiceImpl extends ServiceImpl<AdministerMapper, Adminis
for (ClassSignVO classSignVO : classSignVOS) { for (ClassSignVO classSignVO : classSignVOS) {
//全部视频数 ExecutorService newCachedThreadPool = Executors.newCachedThreadPool();
classSignVO.setAllVodCounts(vodDictDOS.size());
//多个任务
//该学生完成了多少个 newCachedThreadPool.execute(() -> //全部视频数
int i = 0; classSignVO.setAllVodCounts(vodDictDOS.size()));
int playLength = 0; newCachedThreadPool.execute(() -> //完成率,完成情况
//该成员完成了几个视频 signDetailsTask1(vodDictDOS, classSignVO));
for (VodDictDO vodDictDO : vodDictDOS) { newCachedThreadPool.execute(() -> //签到,签到时间
List<VodPlayHistoryDO> vodPlayHistoryDOS = vodPlayHistoryMapper.selectList(new QueryWrapper<VodPlayHistoryDO>() signDetailsTask2(classSignVO, classDetailDTO));
.lambda()
.eq(VodPlayHistoryDO::getMemberId, classSignVO.getId()) //执行后不再接收新任务,如果里面有任务,就执行完
.eq(VodPlayHistoryDO::getVodId, vodDictDO.getId()) newCachedThreadPool.shutdown();
.orderByDesc(VodPlayHistoryDO::getPlayRecord)); try {
while (true) {
if (vodPlayHistoryDOS.size() > 0) { //等待所有任务都结束了继续执行
if (vodPlayHistoryDOS.get(0).getPlayRecord() > vodDictDO.getVodLength() * 0.8) { if (newCachedThreadPool.isTerminated()) {
i++; break;
} }
} }
for (VodPlayHistoryDO vodPlayHistoryDO : vodPlayHistoryDOS) {
playLength += vodPlayHistoryDO.getPlayLength(); } catch (Exception ex) {
} ex.printStackTrace();
} }
classSignVO.setStudyVodCounts(i); }
classSignVO.setClassProcess(i + "/" + vodDictDOS.size()); classSignVOIPage.setRecords(classSignVOS);
return classSignVOIPage;
}
//完成率 public Future signDetailsTask1(List<VodDictDO> vodDictDOS, ClassSignVO classSignVO) {
String percent = MathUtil.getPercentAvgIndexWithPercent(new BigDecimal(i), new BigDecimal(vodDictDOS.size()));
classSignVO.setPercent(percent);
//签到 //该学生完成了多少个
List<SignInRecordDO> signInRecordDOS = signInRecordMapper.selectList(new QueryWrapper<SignInRecordDO>() int i = 0;
int playLength = 0;
//该成员完成了几个视频
for (VodDictDO vodDictDO : vodDictDOS) {
List<VodPlayHistoryDO> vodPlayHistoryDOS = vodPlayHistoryMapper.selectList(new QueryWrapper<VodPlayHistoryDO>()
.lambda() .lambda()
.eq(SignInRecordDO::getMemberId, classSignVO.getId()) .eq(VodPlayHistoryDO::getMemberId, classSignVO.getId())
.eq(SignInRecordDO::getClassId, classDetailDTO.getId())); .eq(VodPlayHistoryDO::getVodId, vodDictDO.getId())
classSignVO.setSignCounts(signInRecordDOS.size()); .orderByDesc(VodPlayHistoryDO::getPlayRecord));
StringBuilder stringBuilder = new StringBuilder(); if (vodPlayHistoryDOS.size() > 0) {
//签到时间 if (vodPlayHistoryDOS.get(0).getPlayRecord() > vodDictDO.getVodLength() * 0.8) {
for (SignInRecordDO signInRecordDO : signInRecordDOS) { i++;
stringBuilder.append(signInRecordDO.getSignInDate().toString().replace("T", " ")).append(";"); }
} }
if (StringUtils.isNotBlank(stringBuilder.toString())) { for (VodPlayHistoryDO vodPlayHistoryDO : vodPlayHistoryDOS) {
String signInDate = stringBuilder.toString().substring(0, stringBuilder.length() - 1); playLength += vodPlayHistoryDO.getPlayLength();
classSignVO.setSignInDateList(signInDate);
} }
}
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.keys(RedisPrefixConstant.SUBSIDY_SIGN_INFO_PREFIX + "memberId_" + classSignVO.getId() + "_classId_" + classDetailDTO.getId() + "*");
classSignVO.setSignCounts(set.size());
//培训时长 StringBuilder stringBuilder = new StringBuilder();
classSignVO.setTrainingLength(playLength); //签到时间
for (SignInRecordDO signInRecordDO : set) {
stringBuilder.append(signInRecordDO.getSignInDate().toString().replace("T", " ")).append(";");
} }
classSignVOIPage.setRecords(classSignVOS); if (StringUtils.isNotBlank(stringBuilder.toString())) {
return classSignVOIPage; String signInDate = stringBuilder.toString().substring(0, stringBuilder.length() - 1);
classSignVO.setSignInDateList(signInDate);
}
return new AsyncResult<>(classSignVO);
} }
public List<ClassSignVO> exportSignDetail(ClassDetailDTO classDetailDTO) throws Exception { public List<ClassSignVO> exportSignDetail(ClassDetailDTO classDetailDTO) throws Exception {
...@@ -636,56 +801,29 @@ public class AdministerServiceImpl extends ServiceImpl<AdministerMapper, Adminis ...@@ -636,56 +801,29 @@ public class AdministerServiceImpl extends ServiceImpl<AdministerMapper, Adminis
for (ClassSignVO classSignVO : classSignVOS) { for (ClassSignVO classSignVO : classSignVOS) {
//全部视频数 final ExecutorService newCachedThreadPool = Executors.newCachedThreadPool();
//classSignVO.setAllVodCounts(vodDictDOS.size());
//多个任务
//该学生完成了多少个 newCachedThreadPool.execute(() -> //全部视频数
int i = 0; classSignVO.setAllVodCounts(vodDictDOS.size()));
int playLength = 0; newCachedThreadPool.execute(() -> //完成率,完成情况
//该成员完成了几个视频 signDetailsTask1(vodDictDOS, classSignVO));
for (VodDictDO vodDictDO : vodDictDOS) { newCachedThreadPool.execute(() -> //签到,签到时间
List<VodPlayHistoryDO> vodPlayHistoryDOS = vodPlayHistoryMapper.selectList(new QueryWrapper<VodPlayHistoryDO>() signDetailsTask2(classSignVO, classDetailDTO));
.lambda()
.eq(VodPlayHistoryDO::getMemberId, classSignVO.getId()) //执行后不再接收新任务,如果里面有任务,就执行完
.eq(VodPlayHistoryDO::getVodId, vodDictDO.getId()) newCachedThreadPool.shutdown();
.orderByDesc(VodPlayHistoryDO::getPlayRecord)); try {
while (true) {
if (vodPlayHistoryDOS.size() > 0) { //等待所有任务都结束了继续执行
if (vodPlayHistoryDOS.get(0).getPlayRecord() > vodDictDO.getVodLength() * 0.8) { if (newCachedThreadPool.isTerminated()) {
i++; break;
} }
} }
for (VodPlayHistoryDO vodPlayHistoryDO : vodPlayHistoryDOS) {
playLength += vodPlayHistoryDO.getPlayLength();
}
}
//classSignVO.setStudyVodCounts(i);
classSignVO.setClassProcess(i + "/" + vodDictDOS.size());
//完成率 } catch (Exception ex) {
String percent = MathUtil.getPercentAvgIndexWithPercent(new BigDecimal(i), new BigDecimal(vodDictDOS.size())); ex.printStackTrace();
classSignVO.setPercent(percent);
//签到
List<SignInRecordDO> signInRecordDOS = signInRecordMapper.selectList(new QueryWrapper<SignInRecordDO>()
.lambda()
.eq(SignInRecordDO::getMemberId, classSignVO.getId())
.eq(SignInRecordDO::getClassId, classDetailDTO.getId()));
classSignVO.setSignCounts(signInRecordDOS.size());
StringBuilder stringBuilder = new StringBuilder();
//签到时间
for (SignInRecordDO signInRecordDO : signInRecordDOS) {
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);
} }
//培训时长
classSignVO.setTrainingLength(playLength);
classSignVO.setTrainingLengthStr(MathUtil.secToTime(playLength));
} }
if (classDetailDTO.getFlag()) { if (classDetailDTO.getFlag()) {
...@@ -699,7 +837,6 @@ public class AdministerServiceImpl extends ServiceImpl<AdministerMapper, Adminis ...@@ -699,7 +837,6 @@ public class AdministerServiceImpl extends ServiceImpl<AdministerMapper, Adminis
return classSignVOS; return classSignVOS;
} }
public IPage<ExerciseTestVO> exerciseTest(ClassDetailDTO classDetailDTO) { public IPage<ExerciseTestVO> exerciseTest(ClassDetailDTO classDetailDTO) {
Page pager = new Page(classDetailDTO.getPageNum(), classDetailDTO.getPageSize()); Page pager = new Page(classDetailDTO.getPageNum(), classDetailDTO.getPageSize());
...@@ -707,27 +844,47 @@ public class AdministerServiceImpl extends ServiceImpl<AdministerMapper, Adminis ...@@ -707,27 +844,47 @@ public class AdministerServiceImpl extends ServiceImpl<AdministerMapper, Adminis
IPage<ExerciseTestVO> exerciseTestVOIPage = this.baseMapper.exerciseTest(pager, classDetailDTO.getId(), classDetailDTO.getUserName()); IPage<ExerciseTestVO> exerciseTestVOIPage = this.baseMapper.exerciseTest(pager, classDetailDTO.getId(), classDetailDTO.getUserName());
List<ExerciseTestVO> classSignVOS = exerciseTestVOIPage.getRecords(); List<ExerciseTestVO> classSignVOS = exerciseTestVOIPage.getRecords();
for (ExerciseTestVO exerciseTestVO : classSignVOS) { ExecutorService newCachedThreadPool = Executors.newCachedThreadPool();
//学生测试完成情况
List<GetMemberPapersVO> exerciseDoneResultDOs = exerciseDoneResultMapper.queryExerciseDoneResult(exerciseTestVO.getId(), classDetailDTO.getId(), classDetailDTO.getPaperId());
exerciseTestVO.setPaperId(exerciseTestVO.getPaperId()); for (ExerciseTestVO exerciseTestVO : classSignVOS) {
if (exerciseDoneResultDOs.size() > 0) { newCachedThreadPool.execute(() -> //签到,签到时间
exerciseTestVO.setScore(exerciseDoneResultDOs.get(0).getScore()); exerciseTestTask(exerciseTestVO, classDetailDTO.getId(), exerciseTestVO.getPaperId()));
exerciseTestVO.setResult(exerciseDoneResultDOs.get(0).getResult()); }
//测评次数 //执行后不再接收新任务,如果里面有任务,就执行完
exerciseTestVO.setCount(exerciseDoneResultDOs.size()); newCachedThreadPool.shutdown();
} else { try {
exerciseTestVO.setScore(0); while (true) {
exerciseTestVO.setResult("不合格"); //等待所有任务都结束了继续执行
exerciseTestVO.setCount(0); if (newCachedThreadPool.isTerminated()) {
break;
}
} }
} catch (Exception ex) {
ex.printStackTrace();
} }
exerciseTestVOIPage.setRecords(classSignVOS); exerciseTestVOIPage.setRecords(classSignVOS);
return exerciseTestVOIPage; return exerciseTestVOIPage;
} }
public void exerciseTestTask(ExerciseTestVO exerciseTestVO, Long classId, Long paperId) {
//学生测试完成情况
List<GetMemberPapersVO> exerciseDoneResultDOs = exerciseDoneResultMapper.queryExerciseDoneResult(exerciseTestVO.getId(), classId, paperId);
exerciseTestVO.setPaperId(exerciseTestVO.getPaperId());
if (exerciseDoneResultDOs.size() > 0) {
exerciseTestVO.setScore(exerciseDoneResultDOs.get(0).getScore());
exerciseTestVO.setResult(exerciseDoneResultDOs.get(0).getResult());
//测评次数
exerciseTestVO.setCount(exerciseDoneResultDOs.size());
} else {
exerciseTestVO.setScore(0);
exerciseTestVO.setResult("不合格");
exerciseTestVO.setCount(0);
}
}
public List<ExerciseTestVO> exportExerciseTest(ClassDetailDTO classDetailDTO) throws Exception { public List<ExerciseTestVO> exportExerciseTest(ClassDetailDTO classDetailDTO) throws Exception {
Page pager = new Page(0, -1L); Page pager = new Page(0, -1L);
...@@ -737,22 +894,26 @@ public class AdministerServiceImpl extends ServiceImpl<AdministerMapper, Adminis ...@@ -737,22 +894,26 @@ public class AdministerServiceImpl extends ServiceImpl<AdministerMapper, Adminis
//课程详情 //课程详情
ClassDictDO classDictDO = classDictMapper.selectById(classDetailDTO.getId()); ClassDictDO classDictDO = classDictMapper.selectById(classDetailDTO.getId());
for (ExerciseTestVO exerciseTestVO : exerciseTestVOS) { ExecutorService newCachedThreadPool = Executors.newCachedThreadPool();
//学生测试完成情况 for (ExerciseTestVO exerciseTestVO : exerciseTestVOS) {
List<GetMemberPapersVO> exerciseDoneResultDOs = exerciseDoneResultMapper.queryExerciseDoneResult(exerciseTestVO.getId(), classDetailDTO.getId(), classDetailDTO.getPaperId());
if (exerciseDoneResultDOs.size() > 0) { newCachedThreadPool.execute(() -> //签到,签到时间
exerciseTestVO.setScore(exerciseDoneResultDOs.get(0).getScore()); exerciseTestTask(exerciseTestVO, classDetailDTO.getId(), exerciseTestVO.getPaperId()));
exerciseTestVO.setResult(exerciseDoneResultDOs.get(0).getResult()); }
//测评次数 //执行后不再接收新任务,如果里面有任务,就执行完
exerciseTestVO.setCount(exerciseDoneResultDOs.size()); newCachedThreadPool.shutdown();
} else { try {
exerciseTestVO.setScore(0); while (true) {
exerciseTestVO.setResult("不合格"); //等待所有任务都结束了继续执行
exerciseTestVO.setCount(0); if (newCachedThreadPool.isTerminated()) {
break;
}
} }
} catch (Exception ex) {
ex.printStackTrace();
} }
if (classDetailDTO.getFlag()) { if (classDetailDTO.getFlag()) {
CompanyDictDO companyDictDO = companyDictMapper.selectById(classDictDO.getCompanyId()); CompanyDictDO companyDictDO = companyDictMapper.selectById(classDictDO.getCompanyId());
CourseDictDO courseDictDO = courseDictMapper.selectById(classDictDO.getCourseId()); CourseDictDO courseDictDO = courseDictMapper.selectById(classDictDO.getCourseId());
...@@ -775,6 +936,7 @@ public class AdministerServiceImpl extends ServiceImpl<AdministerMapper, Adminis ...@@ -775,6 +936,7 @@ public class AdministerServiceImpl extends ServiceImpl<AdministerMapper, Adminis
return this.baseMapper.answerRecord(pager, classDetailDTO.getId(), classDetailDTO.getUserName()); return this.baseMapper.answerRecord(pager, classDetailDTO.getId(), classDetailDTO.getUserName());
} }
@Async
public List<AnswerRecordVO> exportAnswerRecord(ClassDetailDTO classDetailDTO) throws Exception { public List<AnswerRecordVO> exportAnswerRecord(ClassDetailDTO classDetailDTO) throws Exception {
Page pager = new Page(1, -1L); Page pager = new Page(1, -1L);
IPage iPage = this.baseMapper.answerRecord(pager, classDetailDTO.getId(), classDetailDTO.getUserName()); IPage iPage = this.baseMapper.answerRecord(pager, classDetailDTO.getId(), classDetailDTO.getUserName());
...@@ -798,9 +960,8 @@ public class AdministerServiceImpl extends ServiceImpl<AdministerMapper, Adminis ...@@ -798,9 +960,8 @@ public class AdministerServiceImpl extends ServiceImpl<AdministerMapper, Adminis
List<VodDictDO> vodDictDOS = vodDictMapper.getCourseVods(classVodInfoDTO.getCourseId(), classVodInfoDTO.getVodName()); List<VodDictDO> vodDictDOS = vodDictMapper.getCourseVods(classVodInfoDTO.getCourseId(), classVodInfoDTO.getVodName());
for (VodDictDO vodDictDO : vodDictDOS) { for (VodDictDO vodDictDO : vodDictDOS) {
//获取这个视频的学习人数和平均学习时长 //获取这个视频的学习人数和平均学习时长
ClassVodCompleteInfoVO classVodCompleteInfoVO = vodDictMapper.classVodCompleteInfo(classVodInfoDTO.getClassId(), vodDictDO.getId(),memberIds, classVodInfoDTO.getVodName()); ClassVodCompleteInfoVO classVodCompleteInfoVO = vodDictMapper.classVodCompleteInfo(classVodInfoDTO.getClassId(), vodDictDO.getId(), memberIds, classVodInfoDTO.getVodName());
ClassVodInfoVO classVodInfoVO = new ClassVodInfoVO(); ClassVodInfoVO classVodInfoVO = new ClassVodInfoVO();
classVodInfoVO.setVodName(vodDictDO.getVodName()); classVodInfoVO.setVodName(vodDictDO.getVodName());
classVodInfoVO.setStudyCnt(classVodCompleteInfoVO.getCnt()); classVodInfoVO.setStudyCnt(classVodCompleteInfoVO.getCnt());
...@@ -841,32 +1002,7 @@ public class AdministerServiceImpl extends ServiceImpl<AdministerMapper, Adminis ...@@ -841,32 +1002,7 @@ public class AdministerServiceImpl extends ServiceImpl<AdministerMapper, Adminis
return classDailyInfoVOIPage; return classDailyInfoVOIPage;
} }
@Async
//JAVA 获取时间段内的每一天
public static List<String> findDaysStr(String begintTime, String endTime) {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
Date dBegin = null;
Date dEnd = null;
try {
dBegin = sdf.parse(begintTime);
dEnd = sdf.parse(endTime);
} catch (ParseException e) {
e.printStackTrace();
}
List<String> daysStrList = new ArrayList<String>();
daysStrList.add(sdf.format(dBegin));
Calendar calBegin = Calendar.getInstance();
calBegin.setTime(dBegin);
Calendar calEnd = Calendar.getInstance();
calEnd.setTime(dEnd);
while (dEnd.after(calBegin.getTime())) {
calBegin.add(Calendar.DAY_OF_MONTH, 1);
String dayStr = sdf.format(calBegin.getTime());
daysStrList.add(dayStr);
}
return daysStrList;
}
public void export(ClassDetailDTO classDetailDTO) throws Exception { public void export(ClassDetailDTO classDetailDTO) throws Exception {
ServletRequestAttributes servletRequestAttributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes(); ServletRequestAttributes servletRequestAttributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
...@@ -933,7 +1069,6 @@ public class AdministerServiceImpl extends ServiceImpl<AdministerMapper, Adminis ...@@ -933,7 +1069,6 @@ public class AdministerServiceImpl extends ServiceImpl<AdministerMapper, Adminis
} }
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public String importMember(Long companyId, MultipartFile multipartFile) { public String importMember(Long companyId, MultipartFile multipartFile) {
...@@ -998,13 +1133,6 @@ public class AdministerServiceImpl extends ServiceImpl<AdministerMapper, Adminis ...@@ -998,13 +1133,6 @@ public class AdministerServiceImpl extends ServiceImpl<AdministerMapper, Adminis
return ConstantUtils.ADD_SUCCESS; return ConstantUtils.ADD_SUCCESS;
} }
public void importRedis(){
List<AdministerDO> administerDOS = this.baseMapper.selectList(null);
for (AdministerDO administerDO: administerDOS){
redisUtil.set("subsidyAdmin_"+administerDO.getAccountName(),administerDO);
}
}
public String userName(String originName, int i, Long companyId) { public String userName(String originName, int i, Long companyId) {
i++; i++;
List<MemberDO> memberDOS = memberMapper.selectList(new QueryWrapper<MemberDO>() List<MemberDO> memberDOS = memberMapper.selectList(new QueryWrapper<MemberDO>()
...@@ -1018,7 +1146,6 @@ public class AdministerServiceImpl extends ServiceImpl<AdministerMapper, Adminis ...@@ -1018,7 +1146,6 @@ public class AdministerServiceImpl extends ServiceImpl<AdministerMapper, Adminis
} }
} }
public static void membersListExcel(String companyName, String studyDate, String courseName, String title, List<String> headerList, List<ClassDetailVO> classDetailVOS, String datePattern, int colWidth, OutputStream out) { public static void membersListExcel(String companyName, String studyDate, String courseName, String title, List<String> headerList, List<ClassDetailVO> classDetailVOS, String datePattern, int colWidth, OutputStream out) {
// 声明一个工作薄 // 声明一个工作薄
...@@ -1235,7 +1362,6 @@ public class AdministerServiceImpl extends ServiceImpl<AdministerMapper, Adminis ...@@ -1235,7 +1362,6 @@ public class AdministerServiceImpl extends ServiceImpl<AdministerMapper, Adminis
} }
} }
public static void signListExcel(String companyName, String studyDate, String courseName, String title, List<String> headerList, List<ClassSignVO> classSignVOS, String datePattern, int colWidth, OutputStream out) { public static void signListExcel(String companyName, String studyDate, String courseName, String title, List<String> headerList, List<ClassSignVO> classSignVOS, String datePattern, int colWidth, OutputStream out) {
// 声明一个工作薄 // 声明一个工作薄
...@@ -1853,7 +1979,6 @@ public class AdministerServiceImpl extends ServiceImpl<AdministerMapper, Adminis ...@@ -1853,7 +1979,6 @@ public class AdministerServiceImpl extends ServiceImpl<AdministerMapper, Adminis
} }
} }
/** /**
* 压缩单个excel文件的输出流 到zip输出流,注意zipOutputStream未关闭,需要交由调用者关闭之 * 压缩单个excel文件的输出流 到zip输出流,注意zipOutputStream未关闭,需要交由调用者关闭之
* *
...@@ -1887,7 +2012,6 @@ public class AdministerServiceImpl extends ServiceImpl<AdministerMapper, Adminis ...@@ -1887,7 +2012,6 @@ public class AdministerServiceImpl extends ServiceImpl<AdministerMapper, Adminis
} }
} }
//也可用以下方法 //也可用以下方法
public static void setBorderStyle(int border, CellRangeAddress region, SXSSFSheet sheet, SXSSFWorkbook wb) { public static void setBorderStyle(int border, CellRangeAddress region, SXSSFSheet sheet, SXSSFWorkbook wb) {
CellStyle cs = wb.createCellStyle(); // 样式对象 CellStyle cs = wb.createCellStyle(); // 样式对象
...@@ -1916,7 +2040,6 @@ public class AdministerServiceImpl extends ServiceImpl<AdministerMapper, Adminis ...@@ -1916,7 +2040,6 @@ public class AdministerServiceImpl extends ServiceImpl<AdministerMapper, Adminis
} }
} }
private static void setStyle(CellStyle cellStyle) { private static void setStyle(CellStyle cellStyle) {
// 水平居中 // 水平居中
cellStyle.setAlignment(CellStyle.ALIGN_CENTER); cellStyle.setAlignment(CellStyle.ALIGN_CENTER);
......
...@@ -9,6 +9,7 @@ import com.subsidy.mapper.AnsweringQuestionMapper; ...@@ -9,6 +9,7 @@ import com.subsidy.mapper.AnsweringQuestionMapper;
import com.subsidy.service.AnsweringQuestionService; import com.subsidy.service.AnsweringQuestionService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.subsidy.util.ConstantUtils; import com.subsidy.util.ConstantUtils;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
/** /**
...@@ -28,16 +29,19 @@ public class AnsweringQuestionServiceImpl extends ServiceImpl<AnsweringQuestionM ...@@ -28,16 +29,19 @@ public class AnsweringQuestionServiceImpl extends ServiceImpl<AnsweringQuestionM
return this.baseMapper.getCourseQuestion(pager, getCourseQuestionDTO.getClassId(), getCourseQuestionDTO.getMemberId()); return this.baseMapper.getCourseQuestion(pager, getCourseQuestionDTO.getClassId(), getCourseQuestionDTO.getMemberId());
} }
@Async
public String addQuestion(AnsweringQuestionDO answeringQuestionDO) { public String addQuestion(AnsweringQuestionDO answeringQuestionDO) {
this.baseMapper.insert(answeringQuestionDO); this.baseMapper.insert(answeringQuestionDO);
return ConstantUtils.ADD_SUCCESS; return ConstantUtils.ADD_SUCCESS;
} }
@Async
public String deleteQuestion(AnsweringQuestionDO answeringQuestionDO) { public String deleteQuestion(AnsweringQuestionDO answeringQuestionDO) {
this.baseMapper.deleteById(answeringQuestionDO.getId()); this.baseMapper.deleteById(answeringQuestionDO.getId());
return ConstantUtils.DELETE_SUCCESS; return ConstantUtils.DELETE_SUCCESS;
} }
@Async
public String updateQuestion(AnsweringQuestionDO answeringQuestionDO) { public String updateQuestion(AnsweringQuestionDO answeringQuestionDO) {
this.baseMapper.updateById(answeringQuestionDO); this.baseMapper.updateById(answeringQuestionDO);
return ConstantUtils.SET_SUCCESS; return ConstantUtils.SET_SUCCESS;
......
...@@ -10,6 +10,7 @@ import com.subsidy.mapper.CategoryMapper; ...@@ -10,6 +10,7 @@ import com.subsidy.mapper.CategoryMapper;
import com.subsidy.service.CategoryService; import com.subsidy.service.CategoryService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.subsidy.util.ConstantUtils; import com.subsidy.util.ConstantUtils;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.List; import java.util.List;
...@@ -56,6 +57,7 @@ public class CategoryServiceImpl extends ServiceImpl<CategoryMapper, CategoryDO> ...@@ -56,6 +57,7 @@ public class CategoryServiceImpl extends ServiceImpl<CategoryMapper, CategoryDO>
} }
@Async
public String addCategory(CategoryDO categoryDO) { public String addCategory(CategoryDO categoryDO) {
int count = 0; int count = 0;
...@@ -80,11 +82,13 @@ public class CategoryServiceImpl extends ServiceImpl<CategoryMapper, CategoryDO> ...@@ -80,11 +82,13 @@ public class CategoryServiceImpl extends ServiceImpl<CategoryMapper, CategoryDO>
return ConstantUtils.ADD_SUCCESS; return ConstantUtils.ADD_SUCCESS;
} }
@Async
public String deleteCategory(CategoryDO categoryDO) { public String deleteCategory(CategoryDO categoryDO) {
this.baseMapper.deleteById(categoryDO.getId()); this.baseMapper.deleteById(categoryDO.getId());
return ConstantUtils.DELETE_SUCCESS; return ConstantUtils.DELETE_SUCCESS;
} }
@Async
public String updateCategory(CategoryDO categoryDO) { public String updateCategory(CategoryDO categoryDO) {
int count = this.baseMapper.selectCount(new QueryWrapper<CategoryDO>() int count = this.baseMapper.selectCount(new QueryWrapper<CategoryDO>()
......
package com.subsidy.service.impl; package com.subsidy.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.subsidy.dto.classDict.AddClassDTO; import com.subsidy.dto.classDict.AddClassDTO;
import com.subsidy.dto.classDict.AddMemberToClassDTO; import com.subsidy.dto.classDict.AddMemberToClassDTO;
import com.subsidy.dto.classDict.GetAllClassesDTO;
import com.subsidy.dto.classDict.GetSpareMembersDTO; import com.subsidy.dto.classDict.GetSpareMembersDTO;
import com.subsidy.mapper.*; import com.subsidy.mapper.ClassDictMapper;
import com.subsidy.model.*; import com.subsidy.mapper.ClassMemberMappingMapper;
import com.subsidy.mapper.CompanyDictMapper;
import com.subsidy.mapper.CourseDictMapper;
import com.subsidy.mapper.RoleAdministerMappingMapper;
import com.subsidy.model.ClassDictDO;
import com.subsidy.model.ClassMemberMappingDO;
import com.subsidy.model.CompanyDictDO;
import com.subsidy.model.CourseDictDO;
import com.subsidy.model.MemberDO;
import com.subsidy.model.RoleAdministerMappingDO;
import com.subsidy.service.ClassDictService; import com.subsidy.service.ClassDictService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.subsidy.util.ConstantUtils; import com.subsidy.util.ConstantUtils;
import com.subsidy.util.SMSUtils; import com.subsidy.util.SMSUtils;
import com.subsidy.vo.classdict.GetAllClassesVO; import com.subsidy.vo.classdict.GetAllClassesVO;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import javax.management.relation.Role;
import java.util.ArrayList;
import java.util.List; import java.util.List;
/** /**
...@@ -51,6 +57,7 @@ public class ClassDictServiceImpl extends ServiceImpl<ClassDictMapper, ClassDict ...@@ -51,6 +57,7 @@ public class ClassDictServiceImpl extends ServiceImpl<ClassDictMapper, ClassDict
} }
@Transactional @Transactional
@Async
public String deleteClasses(ClassDictDO classDictDO) { public String deleteClasses(ClassDictDO classDictDO) {
this.baseMapper.deleteById(classDictDO.getId()); this.baseMapper.deleteById(classDictDO.getId());
...@@ -60,6 +67,7 @@ public class ClassDictServiceImpl extends ServiceImpl<ClassDictMapper, ClassDict ...@@ -60,6 +67,7 @@ public class ClassDictServiceImpl extends ServiceImpl<ClassDictMapper, ClassDict
return ConstantUtils.DELETE_SUCCESS; return ConstantUtils.DELETE_SUCCESS;
} }
@Async
public String addClass(AddClassDTO addClassDTO) { public String addClass(AddClassDTO addClassDTO) {
//查看当前登录人的角色 //查看当前登录人的角色
...@@ -81,6 +89,7 @@ public class ClassDictServiceImpl extends ServiceImpl<ClassDictMapper, ClassDict ...@@ -81,6 +89,7 @@ public class ClassDictServiceImpl extends ServiceImpl<ClassDictMapper, ClassDict
return ConstantUtils.ADD_SUCCESS; return ConstantUtils.ADD_SUCCESS;
} }
@Async
public String updateClass(ClassDictDO classDictDO) { public String updateClass(ClassDictDO classDictDO) {
this.baseMapper.updateById(classDictDO); this.baseMapper.updateById(classDictDO);
return ConstantUtils.SET_SUCCESS; return ConstantUtils.SET_SUCCESS;
...@@ -90,6 +99,7 @@ public class ClassDictServiceImpl extends ServiceImpl<ClassDictMapper, ClassDict ...@@ -90,6 +99,7 @@ public class ClassDictServiceImpl extends ServiceImpl<ClassDictMapper, ClassDict
return this.baseMapper.selectById(classDictDO.getId()); return this.baseMapper.selectById(classDictDO.getId());
} }
@Async
public String removeMember(ClassMemberMappingDO classMemberMappingDO) { public String removeMember(ClassMemberMappingDO classMemberMappingDO) {
classMemberMappingMapper.delete(new QueryWrapper<ClassMemberMappingDO>() classMemberMappingMapper.delete(new QueryWrapper<ClassMemberMappingDO>()
.lambda() .lambda()
...@@ -115,6 +125,7 @@ public class ClassDictServiceImpl extends ServiceImpl<ClassDictMapper, ClassDict ...@@ -115,6 +125,7 @@ public class ClassDictServiceImpl extends ServiceImpl<ClassDictMapper, ClassDict
return ConstantUtils.ADD_SUCCESS; return ConstantUtils.ADD_SUCCESS;
} }
@Async
public String batchSms(ClassDictDO classDictDO){ public String batchSms(ClassDictDO classDictDO){
ClassDictDO classDictDO1 = this.baseMapper.selectById(classDictDO.getId()); ClassDictDO classDictDO1 = this.baseMapper.selectById(classDictDO.getId());
......
package com.subsidy.service.impl; package com.subsidy.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.subsidy.common.RedisPrefixConstant;
import com.subsidy.mapper.ClassHourDictMapper;
import com.subsidy.mapper.MemberMapper; import com.subsidy.mapper.MemberMapper;
import com.subsidy.mapper.VodPlayHistoryMapper; import com.subsidy.mapper.VodPlayHistoryMapper;
import com.subsidy.model.ClassHourDictDO; import com.subsidy.model.ClassHourDictDO;
import com.subsidy.mapper.ClassHourDictMapper;
import com.subsidy.model.MemberDO; import com.subsidy.model.MemberDO;
import com.subsidy.model.VodPlayHistoryDO; import com.subsidy.model.VodPlayHistoryDO;
import com.subsidy.service.ClassHourDictService; import com.subsidy.service.ClassHourDictService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.subsidy.util.ConstantUtils; import com.subsidy.util.ConstantUtils;
import com.subsidy.util.RedisUtil;
import com.subsidy.vo.hour.PollingGetVO; import com.subsidy.vo.hour.PollingGetVO;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.AsyncResult;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.time.LocalDate; import java.time.LocalDate;
import java.util.List; import java.util.List;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
/** /**
* <p> * <p>
...@@ -29,81 +37,93 @@ import java.util.List; ...@@ -29,81 +37,93 @@ import java.util.List;
public class ClassHourDictServiceImpl extends ServiceImpl<ClassHourDictMapper, ClassHourDictDO> implements ClassHourDictService { public class ClassHourDictServiceImpl extends ServiceImpl<ClassHourDictMapper, ClassHourDictDO> implements ClassHourDictService {
@Autowired @Autowired
private ClassHourDictMapper classHourDictMapper;
@Autowired
private VodPlayHistoryMapper vodPlayHistoryMapper; private VodPlayHistoryMapper vodPlayHistoryMapper;
@Autowired @Autowired
private MemberMapper memberMapper; private MemberMapper memberMapper;
@Autowired
private RedisUtil redisUtil;
public ClassHourDictDO getSetting(ClassHourDictDO classHourDictDO) { public ClassHourDictDO getSetting(ClassHourDictDO classHourDictDO) {
ClassHourDictDO classHourDictDO1 = this.baseMapper.selectOne(new QueryWrapper<ClassHourDictDO>() return (ClassHourDictDO) redisUtil.get(RedisPrefixConstant.SUBSIDY_SETTINGS_PREFIX + classHourDictDO.getCompanyId());
.lambda()
.eq(ClassHourDictDO::getCompanyId,classHourDictDO.getCompanyId()));
//if (null==classHourDictDO){
// ClassHourDictDO classHourDictDO2 = new ClassHourDictDO();
// classHourDictDO2.setCompanyId(classHourDictDO.getCompanyId());
// classHourDictDO2.setStatus(0);
// classHourDictDO2.setClassHour(6);
//
// classHourDictDO2.setInterruptStatus(0);
// classHourDictDO2.setInterrupt(15);
//
// classHourDictDO2.setRepeatStatus(0);
// classHourDictDO2.setRepeatTime(3);
// this.baseMapper.insert(classHourDictDO2);
// return classHourDictDO2;
//}
return classHourDictDO1;
} }
public String updateSetting(ClassHourDictDO classHourDictDO){ @Async
this.baseMapper.updateById(classHourDictDO); public String updateSetting(ClassHourDictDO classHourDictDO) {
return ConstantUtils.ADD_SUCCESS;
ClassHourDictDO classHourDictDO1 = (ClassHourDictDO) redisUtil.get(RedisPrefixConstant.SUBSIDY_SETTINGS_PREFIX + classHourDictDO.getCompanyId());
BeanUtils.copyProperties(classHourDictDO, classHourDictDO1);
redisUtil.set(RedisPrefixConstant.SUBSIDY_SETTINGS_PREFIX + classHourDictDO.getCompanyId(), classHourDictDO1);
return ConstantUtils.SET_SUCCESS;
} }
public PollingGetVO pollingGet(VodPlayHistoryDO vodPlayHistoryDO){ public PollingGetVO pollingGet(VodPlayHistoryDO vodPlayHistoryDO) {
PollingGetVO pollingGetVO = new PollingGetVO(); PollingGetVO pollingGetVO = new PollingGetVO();
MemberDO memberDO = memberMapper.selectById(vodPlayHistoryDO.getMemberId()); MemberDO memberDO = memberMapper.selectById(vodPlayHistoryDO.getMemberId());
final ExecutorService newCachedThreadPool = Executors.newCachedThreadPool();
//查看系统设定的时长 ClassHourDictDO classHourDictDO = new ClassHourDictDO();
ClassHourDictDO classHourDictDO = classHourDictMapper.selectOne(new QueryWrapper<ClassHourDictDO>()
.lambda()
.eq(ClassHourDictDO::getStatus,1)
.gt(ClassHourDictDO::getCompanyId,memberDO.getCompanyId()));
if (null == classHourDictDO){
pollingGetVO.setBool(false);
return pollingGetVO;
}
//查看当天这个人看了多少时间 Integer total = 0;
List<VodPlayHistoryDO> vodPlayHistoryDOS = vodPlayHistoryMapper.selectList(new QueryWrapper<VodPlayHistoryDO>() try {
.lambda()
.eq(VodPlayHistoryDO::getMemberId,vodPlayHistoryDO.getMemberId())
.eq(VodPlayHistoryDO::getCreateDate, LocalDate.now()));
int total = 0 ; //多个任务
Future<ClassHourDictDO> future1 = newCachedThreadPool.submit(() -> ///该学生完成了多少个 学生成绩,学生进度
pollingGetTask1(memberDO.getCompanyId())).get();
for (VodPlayHistoryDO vodPlayHistoryDO1 : vodPlayHistoryDOS){ //查看系统设定的时长
total += vodPlayHistoryDO1.getPlayLength(); classHourDictDO = future1.get();
Future<Integer> future2 = newCachedThreadPool.submit(() -> //答疑
pollingGetTask2(memberDO.getId())).get();
////查看当天这个人看了多少时间
total = future2.get();
} catch (Exception e) {
e.printStackTrace();
}
//执行后不再接收新任务,如果里面有任务,就执行完
newCachedThreadPool.shutdown();
try {
while (true) {
//等待所有任务都结束了继续执行
if (newCachedThreadPool.isTerminated()) {
break;
}
}
} catch (Exception ex) {
ex.printStackTrace();
}
if (classHourDictDO.getStatus() == 0) {
pollingGetVO.setBool(false);
return pollingGetVO;
} }
//是否超过时长 没超过 false 超过 true //是否超过时长 没超过 false 超过 true
if (classHourDictDO==null){ if (classHourDictDO == null) {
pollingGetVO.setBool(true); pollingGetVO.setBool(true);
}else { } else {
if (total + vodPlayHistoryDO.getPlayLength() < classHourDictDO.getClassHour()*60*60){ if (total + vodPlayHistoryDO.getPlayLength() < classHourDictDO.getClassHour() * 60 * 60) {
pollingGetVO.setBool(false); pollingGetVO.setBool(false);
}else { } else {
pollingGetVO.setBool(true); pollingGetVO.setBool(true);
} }
} }
return pollingGetVO; return pollingGetVO;
} }
public Future<ClassHourDictDO> pollingGetTask1(Long companyId) {
System.out.println(redisUtil.get(RedisPrefixConstant.SUBSIDY_SETTINGS_PREFIX + companyId));
return new AsyncResult<>((ClassHourDictDO) redisUtil.get(RedisPrefixConstant.SUBSIDY_SETTINGS_PREFIX + companyId));
//return new AsyncResult<>("hello");
}
public Future<Integer> pollingGetTask2(Long memberId) {
return new AsyncResult<>(vodPlayHistoryMapper.memberDailyStudyLength(memberId));
}
} }
package com.subsidy.service.impl;
import com.subsidy.model.ClassMemberMappingDO;
import com.subsidy.mapper.ClassMemberMappingMapper;
import com.subsidy.service.ClassMemberMappingService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
/**
* <p>
* 班级成员映射表 服务实现类
* </p>
*
* @author DengMin
* @since 2021-10-12
*/
@Service
public class ClassMemberMappingServiceImpl extends ServiceImpl<ClassMemberMappingMapper, ClassMemberMappingDO> implements ClassMemberMappingService {
}
...@@ -4,18 +4,28 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; ...@@ -4,18 +4,28 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.StringUtils; import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.subsidy.common.RedisPrefixConstant;
import com.subsidy.common.exception.HttpException; import com.subsidy.common.exception.HttpException;
import com.subsidy.dto.administer.OperatorsDTO; import com.subsidy.dto.administer.OperatorsDTO;
import com.subsidy.dto.company.AddCompanyDTO; import com.subsidy.dto.company.AddCompanyDTO;
import com.subsidy.mapper.*; import com.subsidy.mapper.AdministerMapper;
import com.subsidy.model.*; import com.subsidy.mapper.CompanyDictMapper;
import com.subsidy.mapper.DepartmentDictMapper;
import com.subsidy.mapper.RoleAdministerMappingMapper;
import com.subsidy.model.AdministerDO;
import com.subsidy.model.ClassHourDictDO;
import com.subsidy.model.CompanyDictDO;
import com.subsidy.model.DepartmentDictDO;
import com.subsidy.model.RoleAdministerMappingDO;
import com.subsidy.service.CompanyDictService; import com.subsidy.service.CompanyDictService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.subsidy.util.ConstantUtils; import com.subsidy.util.ConstantUtils;
import com.subsidy.util.RedisUtil;
import com.subsidy.vo.administer.OperatorsVO; import com.subsidy.vo.administer.OperatorsVO;
import com.subsidy.vo.company.GetAllCompanyVO; import com.subsidy.vo.company.GetAllCompanyVO;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.List; import java.util.List;
...@@ -42,7 +52,7 @@ public class CompanyDictServiceImpl extends ServiceImpl<CompanyDictMapper, Compa ...@@ -42,7 +52,7 @@ public class CompanyDictServiceImpl extends ServiceImpl<CompanyDictMapper, Compa
private DepartmentDictMapper departmentDictMapper; private DepartmentDictMapper departmentDictMapper;
@Autowired @Autowired
private ClassHourDictMapper classHourDictMapper; private RedisUtil redisUtil;
public IPage<OperatorsVO> operators(OperatorsDTO operatorsDTO) { public IPage<OperatorsVO> operators(OperatorsDTO operatorsDTO) {
Page pager = new Page(operatorsDTO.getPageNum(), operatorsDTO.getPageSize()); Page pager = new Page(operatorsDTO.getPageNum(), operatorsDTO.getPageSize());
...@@ -109,10 +119,13 @@ public class CompanyDictServiceImpl extends ServiceImpl<CompanyDictMapper, Compa ...@@ -109,10 +119,13 @@ public class CompanyDictServiceImpl extends ServiceImpl<CompanyDictMapper, Compa
classHourDictDO2.setRepeatStatus(0); classHourDictDO2.setRepeatStatus(0);
classHourDictDO2.setRepeatTime(3); classHourDictDO2.setRepeatTime(3);
classHourDictMapper.insert(classHourDictDO2); redisUtil.set(RedisPrefixConstant.SUBSIDY_SETTINGS_PREFIX +companyDictDO.getId(),classHourDictDO2);
return ConstantUtils.ADD_SUCCESS; return ConstantUtils.ADD_SUCCESS;
} }
@Async
public String deleteAdminister(CompanyDictDO companyDictDO) { public String deleteAdminister(CompanyDictDO companyDictDO) {
this.baseMapper.deleteById(companyDictDO.getId()); this.baseMapper.deleteById(companyDictDO.getId());
...@@ -123,6 +136,7 @@ public class CompanyDictServiceImpl extends ServiceImpl<CompanyDictMapper, Compa ...@@ -123,6 +136,7 @@ public class CompanyDictServiceImpl extends ServiceImpl<CompanyDictMapper, Compa
return ConstantUtils.DELETE_SUCCESS; return ConstantUtils.DELETE_SUCCESS;
} }
@Async
public String updateAdminister(AddCompanyDTO addCompanyDTO) { public String updateAdminister(AddCompanyDTO addCompanyDTO) {
CompanyDictDO companyDictDO = new CompanyDictDO(); CompanyDictDO companyDictDO = new CompanyDictDO();
......
package com.subsidy.service.impl; package com.subsidy.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.subsidy.common.exception.HttpException; import com.subsidy.common.exception.HttpException;
import com.subsidy.controller.CourseContentController;
import com.subsidy.mapper.VodDictMapper;
import com.subsidy.model.CourseContentDO;
import com.subsidy.mapper.CourseContentMapper; import com.subsidy.mapper.CourseContentMapper;
import com.subsidy.model.CourseDictDO; import com.subsidy.model.CourseContentDO;
import com.subsidy.model.VodDictDO;
import com.subsidy.service.CourseContentService; import com.subsidy.service.CourseContentService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.subsidy.util.ConstantUtils; import com.subsidy.util.ConstantUtils;
import com.subsidy.vo.vod.GetContendVodsVO; import org.springframework.scheduling.annotation.Async;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.List; import java.util.List;
...@@ -36,11 +31,13 @@ public class CourseContentServiceImpl extends ServiceImpl<CourseContentMapper, C ...@@ -36,11 +31,13 @@ public class CourseContentServiceImpl extends ServiceImpl<CourseContentMapper, C
.orderByAsc(CourseContentDO::getCreateDate)); .orderByAsc(CourseContentDO::getCreateDate));
} }
@Async
public String deleteContent(CourseContentDO courseContentDO){ public String deleteContent(CourseContentDO courseContentDO){
this.baseMapper.deleteById(courseContentDO.getId()); this.baseMapper.deleteById(courseContentDO.getId());
return ConstantUtils.DELETE_SUCCESS; return ConstantUtils.DELETE_SUCCESS;
} }
@Async
public String addContent(CourseContentDO courseContentDO){ public String addContent(CourseContentDO courseContentDO){
List<CourseContentDO> courseContentDOS = this.baseMapper.selectList(new QueryWrapper<CourseContentDO>() List<CourseContentDO> courseContentDOS = this.baseMapper.selectList(new QueryWrapper<CourseContentDO>()
...@@ -58,6 +55,7 @@ public class CourseContentServiceImpl extends ServiceImpl<CourseContentMapper, C ...@@ -58,6 +55,7 @@ public class CourseContentServiceImpl extends ServiceImpl<CourseContentMapper, C
return ConstantUtils.ADD_SUCCESS; return ConstantUtils.ADD_SUCCESS;
} }
@Async
public String updateContent(CourseContentDO courseContentDO){ public String updateContent(CourseContentDO courseContentDO){
List<CourseContentDO> courseContentDOS = this.baseMapper.selectList(new QueryWrapper<CourseContentDO>() List<CourseContentDO> courseContentDOS = this.baseMapper.selectList(new QueryWrapper<CourseContentDO>()
......
...@@ -3,24 +3,19 @@ package com.subsidy.service.impl; ...@@ -3,24 +3,19 @@ package com.subsidy.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.subsidy.common.exception.HttpException; import com.subsidy.common.exception.HttpException;
import com.subsidy.dto.course.QueryCoursesDTO; import com.subsidy.dto.course.QueryCoursesDTO;
import com.subsidy.mapper.AdministerMapper;
import com.subsidy.mapper.CompanyDictMapper;
import com.subsidy.mapper.RoleAdministerMappingMapper;
import com.subsidy.model.*;
import com.subsidy.mapper.CourseDictMapper; import com.subsidy.mapper.CourseDictMapper;
import com.subsidy.service.CompanyDictService; import com.subsidy.mapper.RoleAdministerMappingMapper;
import com.subsidy.model.CourseDictDO;
import com.subsidy.model.RoleAdministerMappingDO;
import com.subsidy.service.CourseDictService; import com.subsidy.service.CourseDictService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.subsidy.util.ConstantUtils; import com.subsidy.util.ConstantUtils;
import com.subsidy.util.SMSUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
/** /**
* <p> * <p>
* 服务实现类 * 服务实现类
...@@ -35,6 +30,7 @@ public class CourseDictServiceImpl extends ServiceImpl<CourseDictMapper, CourseD ...@@ -35,6 +30,7 @@ public class CourseDictServiceImpl extends ServiceImpl<CourseDictMapper, CourseD
@Autowired @Autowired
private RoleAdministerMappingMapper roleAdministerMappingMapper; private RoleAdministerMappingMapper roleAdministerMappingMapper;
@Async
public String addCourse(CourseDictDO courseDictDO) { public String addCourse(CourseDictDO courseDictDO) {
int count = 0; int count = 0;
...@@ -60,6 +56,7 @@ public class CourseDictServiceImpl extends ServiceImpl<CourseDictMapper, CourseD ...@@ -60,6 +56,7 @@ public class CourseDictServiceImpl extends ServiceImpl<CourseDictMapper, CourseD
return ConstantUtils.ADD_SUCCESS; return ConstantUtils.ADD_SUCCESS;
} }
@Async
public String deleteCourse(CourseDictDO courseDictDO) { public String deleteCourse(CourseDictDO courseDictDO) {
this.baseMapper.deleteById(courseDictDO.getId()); this.baseMapper.deleteById(courseDictDO.getId());
return ConstantUtils.DELETE_SUCCESS; return ConstantUtils.DELETE_SUCCESS;
...@@ -81,6 +78,7 @@ public class CourseDictServiceImpl extends ServiceImpl<CourseDictMapper, CourseD ...@@ -81,6 +78,7 @@ public class CourseDictServiceImpl extends ServiceImpl<CourseDictMapper, CourseD
return this.baseMapper.queryCourses(pager, queryCoursesDTO.getCourseName(), queryCoursesDTO.getCategoryId(), queryCoursesDTO.getCourseType(), queryCoursesDTO.getCourseSource(), queryCoursesDTO.getCompanyId()); return this.baseMapper.queryCourses(pager, queryCoursesDTO.getCourseName(), queryCoursesDTO.getCategoryId(), queryCoursesDTO.getCourseType(), queryCoursesDTO.getCourseSource(), queryCoursesDTO.getCompanyId());
} }
@Async
public String updateCourses(CourseDictDO courseDictDO) { public String updateCourses(CourseDictDO courseDictDO) {
int count = 0; int count = 0;
......
...@@ -12,6 +12,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; ...@@ -12,6 +12,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.subsidy.util.ConstantUtils; import com.subsidy.util.ConstantUtils;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.ArrayList; import java.util.ArrayList;
...@@ -97,6 +98,7 @@ public class DepartmentDictServiceImpl extends ServiceImpl<DepartmentDictMapper, ...@@ -97,6 +98,7 @@ public class DepartmentDictServiceImpl extends ServiceImpl<DepartmentDictMapper,
return getDepartmentsVOS; return getDepartmentsVOS;
} }
@Async
public String addDepartment(DepartmentDictDO departmentDictDO) { public String addDepartment(DepartmentDictDO departmentDictDO) {
Integer counter = this.baseMapper.selectCount(new QueryWrapper<DepartmentDictDO>() Integer counter = this.baseMapper.selectCount(new QueryWrapper<DepartmentDictDO>()
...@@ -113,6 +115,7 @@ public class DepartmentDictServiceImpl extends ServiceImpl<DepartmentDictMapper, ...@@ -113,6 +115,7 @@ public class DepartmentDictServiceImpl extends ServiceImpl<DepartmentDictMapper,
return ConstantUtils.ADD_SUCCESS; return ConstantUtils.ADD_SUCCESS;
} }
@Async
public String deleteDepartment(DepartmentDictDO departmentDictDO) { public String deleteDepartment(DepartmentDictDO departmentDictDO) {
this.baseMapper.deleteById(departmentDictDO.getId()); this.baseMapper.deleteById(departmentDictDO.getId());
...@@ -140,6 +143,7 @@ public class DepartmentDictServiceImpl extends ServiceImpl<DepartmentDictMapper, ...@@ -140,6 +143,7 @@ public class DepartmentDictServiceImpl extends ServiceImpl<DepartmentDictMapper,
this.baseMapper.deleteById(departmentDictDO.getId()); this.baseMapper.deleteById(departmentDictDO.getId());
} }
@Async
public String updateDepartment(DepartmentDictDO departmentDictDO) { public String updateDepartment(DepartmentDictDO departmentDictDO) {
Integer counter = this.baseMapper.selectCount(new QueryWrapper<DepartmentDictDO>() Integer counter = this.baseMapper.selectCount(new QueryWrapper<DepartmentDictDO>()
......
...@@ -22,6 +22,7 @@ import com.subsidy.vo.exercise.GetPaperExerciseVO; ...@@ -22,6 +22,7 @@ import com.subsidy.vo.exercise.GetPaperExerciseVO;
import com.subsidy.vo.exercise.MemberExerciseVO; import com.subsidy.vo.exercise.MemberExerciseVO;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
...@@ -58,6 +59,7 @@ public class ExerciseDictServiceImpl extends ServiceImpl<ExerciseDictMapper, Exe ...@@ -58,6 +59,7 @@ public class ExerciseDictServiceImpl extends ServiceImpl<ExerciseDictMapper, Exe
.orderByAsc(ExerciseDictDO::getOrderNo)); .orderByAsc(ExerciseDictDO::getOrderNo));
} }
@Async
public String addExercise(ExerciseDictDO exerciseDictDO){ public String addExercise(ExerciseDictDO exerciseDictDO){
List<ExerciseDictDO> exerciseDictDOS = this.baseMapper.selectList(new QueryWrapper<ExerciseDictDO>() List<ExerciseDictDO> exerciseDictDOS = this.baseMapper.selectList(new QueryWrapper<ExerciseDictDO>()
...@@ -75,11 +77,13 @@ public class ExerciseDictServiceImpl extends ServiceImpl<ExerciseDictMapper, Exe ...@@ -75,11 +77,13 @@ public class ExerciseDictServiceImpl extends ServiceImpl<ExerciseDictMapper, Exe
return ConstantUtils.ADD_SUCCESS; return ConstantUtils.ADD_SUCCESS;
} }
@Async
public String deleteExercise(ExerciseDictDO exerciseDictDO) { public String deleteExercise(ExerciseDictDO exerciseDictDO) {
this.baseMapper.deleteById(exerciseDictDO.getId()); this.baseMapper.deleteById(exerciseDictDO.getId());
return ConstantUtils.DELETE_SUCCESS; return ConstantUtils.DELETE_SUCCESS;
} }
@Async
public String updateExercise(ExerciseDictDO exerciseDictDO) { public String updateExercise(ExerciseDictDO exerciseDictDO) {
this.baseMapper.updateById(exerciseDictDO); this.baseMapper.updateById(exerciseDictDO);
return ConstantUtils.SET_SUCCESS; return ConstantUtils.SET_SUCCESS;
...@@ -102,6 +106,7 @@ public class ExerciseDictServiceImpl extends ServiceImpl<ExerciseDictMapper, Exe ...@@ -102,6 +106,7 @@ public class ExerciseDictServiceImpl extends ServiceImpl<ExerciseDictMapper, Exe
} }
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
@Async
public Long submit(SubmitDTO submitDTO) { public Long submit(SubmitDTO submitDTO) {
ExerciseDoneResultDO exerciseDoneResultDO = new ExerciseDoneResultDO(); ExerciseDoneResultDO exerciseDoneResultDO = new ExerciseDoneResultDO();
...@@ -135,11 +140,6 @@ public class ExerciseDictServiceImpl extends ServiceImpl<ExerciseDictMapper, Exe ...@@ -135,11 +140,6 @@ public class ExerciseDictServiceImpl extends ServiceImpl<ExerciseDictMapper, Exe
exerciseDoneResultDO.setResult("不合格"); exerciseDoneResultDO.setResult("不合格");
} }
//exerciseDoneResultMapper.delete(new QueryWrapper<ExerciseDoneResultDO>()
// .lambda()
// .eq(ExerciseDoneResultDO::getMemberId, submitDTO.getMemberId())
// .eq(ExerciseDoneResultDO::getCourseId, submitDTO.getCourseId()));
exerciseDoneResultMapper.insert(exerciseDoneResultDO); exerciseDoneResultMapper.insert(exerciseDoneResultDO);
for (MemberExerciseVO memberExerciseVO : memberExerciseVOS){ for (MemberExerciseVO memberExerciseVO : memberExerciseVOS){
......
...@@ -18,7 +18,6 @@ import org.springframework.stereotype.Service; ...@@ -18,7 +18,6 @@ import org.springframework.stereotype.Service;
@Service @Service
public class ExerciseDoneResultServiceImpl extends ServiceImpl<ExerciseDoneResultMapper, ExerciseDoneResultDO> implements ExerciseDoneResultService { public class ExerciseDoneResultServiceImpl extends ServiceImpl<ExerciseDoneResultMapper, ExerciseDoneResultDO> implements ExerciseDoneResultService {
public GetDoneDetailVO getDoneDetail(ExerciseDoneResultDO exerciseDoneResultDO){ public GetDoneDetailVO getDoneDetail(ExerciseDoneResultDO exerciseDoneResultDO){
return this.baseMapper.getDoneDetail(exerciseDoneResultDO.getId()); return this.baseMapper.getDoneDetail(exerciseDoneResultDO.getId());
} }
......
package com.subsidy.service.impl; package com.subsidy.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.subsidy.model.FileDictDO; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.subsidy.mapper.FileDictMapper; import com.subsidy.mapper.FileDictMapper;
import com.subsidy.model.VodDictDO; import com.subsidy.model.FileDictDO;
import com.subsidy.service.FileDictService; import com.subsidy.service.FileDictService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.subsidy.util.ConstantUtils; import com.subsidy.util.ConstantUtils;
import com.subsidy.vo.vod.GetContendVodsVO; import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.List; import java.util.List;
...@@ -30,16 +29,19 @@ public class FileDictServiceImpl extends ServiceImpl<FileDictMapper, FileDictDO> ...@@ -30,16 +29,19 @@ public class FileDictServiceImpl extends ServiceImpl<FileDictMapper, FileDictDO>
.like(FileDictDO::getFileName,fileDictDO.getFileName())); .like(FileDictDO::getFileName,fileDictDO.getFileName()));
} }
@Async
public String deleteFile(FileDictDO fileDictDO) { public String deleteFile(FileDictDO fileDictDO) {
this.baseMapper.deleteById(fileDictDO.getId()); this.baseMapper.deleteById(fileDictDO.getId());
return ConstantUtils.DELETE_SUCCESS; return ConstantUtils.DELETE_SUCCESS;
} }
@Async
public String addFile(FileDictDO fileDictDO) { public String addFile(FileDictDO fileDictDO) {
this.baseMapper.insert(fileDictDO); this.baseMapper.insert(fileDictDO);
return ConstantUtils.ADD_SUCCESS; return ConstantUtils.ADD_SUCCESS;
} }
@Async
public String updateFile(FileDictDO fileDictDO) { public String updateFile(FileDictDO fileDictDO) {
this.baseMapper.updateById(fileDictDO); this.baseMapper.updateById(fileDictDO);
return ConstantUtils.SET_SUCCESS; return ConstantUtils.SET_SUCCESS;
......
...@@ -2,37 +2,69 @@ package com.subsidy.service.impl; ...@@ -2,37 +2,69 @@ package com.subsidy.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.subsidy.common.RedisPrefixConstant;
import com.subsidy.common.exception.HttpException; import com.subsidy.common.exception.HttpException;
import com.subsidy.dto.administer.VerifyCodeDTO; import com.subsidy.dto.administer.VerifyCodeDTO;
import com.subsidy.dto.member.*; import com.subsidy.dto.member.AddMemberDTO;
import com.subsidy.mapper.*; import com.subsidy.dto.member.ContentMemberDTO;
import com.subsidy.model.*; import com.subsidy.dto.member.GetAllDTO;
import com.subsidy.dto.member.PasswordLoginDTO;
import com.subsidy.dto.member.StudyHistoryDTO;
import com.subsidy.mapper.ClassDictMapper;
import com.subsidy.mapper.ClassMemberMappingMapper;
import com.subsidy.mapper.CompanyDictMapper;
import com.subsidy.mapper.CourseContentMapper;
import com.subsidy.mapper.ExerciseDoneResultMapper;
import com.subsidy.mapper.FileDictMapper;
import com.subsidy.mapper.MemberDepartmentMappingMapper;
import com.subsidy.mapper.MemberMapper;
import com.subsidy.mapper.PaperDictMapper;
import com.subsidy.mapper.VodDictMapper;
import com.subsidy.mapper.VodPlayHistoryMapper;
import com.subsidy.model.ClassDictDO;
import com.subsidy.model.ClassHourDictDO;
import com.subsidy.model.ClassMemberMappingDO;
import com.subsidy.model.CompanyDictDO;
import com.subsidy.model.CourseContentDO;
import com.subsidy.model.DepartmentDictDO;
import com.subsidy.model.ExerciseDoneResultDO;
import com.subsidy.model.FileDictDO;
import com.subsidy.model.MemberDO;
import com.subsidy.model.MemberDepartmentMappingDO;
import com.subsidy.model.OprMemDictDO;
import com.subsidy.model.VodDictDO;
import com.subsidy.model.VodPlayHistoryDO;
import com.subsidy.service.MemberService; import com.subsidy.service.MemberService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.subsidy.util.ConstantUtils; import com.subsidy.util.ConstantUtils;
import com.subsidy.util.MathUtil; import com.subsidy.util.MathUtil;
import com.subsidy.util.RedisUtil; import com.subsidy.util.RedisUtil;
import com.subsidy.vo.administer.UserRoleVO; import com.subsidy.vo.administer.UserRoleVO;
import com.subsidy.vo.course.QueryCoursesVO; import com.subsidy.vo.member.ContentFilesVO;
import com.subsidy.vo.member.*; import com.subsidy.vo.member.ContentVodNewVO;
import com.subsidy.vo.member.ContentVodVO;
import com.subsidy.vo.member.GetAllVO;
import com.subsidy.vo.member.GetStudyInfoVO;
import com.subsidy.vo.member.MemberStudyPageVO;
import com.subsidy.vo.member.MemberVodVO;
import com.subsidy.vo.member.StudyPageVO;
import com.subsidy.vo.paper.QueryPapersVO; import com.subsidy.vo.paper.QueryPapersVO;
import com.subsidy.vo.vod.StudyHistoryVO; import com.subsidy.vo.vod.StudyHistoryVO;
import net.sourceforge.pinyin4j.PinyinHelper;
import net.sourceforge.pinyin4j.format.HanyuPinyinCaseType;
import net.sourceforge.pinyin4j.format.HanyuPinyinOutputFormat;
import net.sourceforge.pinyin4j.format.HanyuPinyinToneType;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.AsyncResult;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import java.lang.reflect.Member;
import java.time.Duration; import java.time.Duration;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
/** /**
* <p> * <p>
...@@ -46,9 +78,6 @@ import java.util.List; ...@@ -46,9 +78,6 @@ import java.util.List;
public class MemberServiceImpl extends ServiceImpl<MemberMapper, MemberDO> implements MemberService { public class MemberServiceImpl extends ServiceImpl<MemberMapper, MemberDO> implements MemberService {
@Autowired @Autowired
private SmsVerifyCodeMapper smsVerifyCodeMapper;
@Autowired
private CourseContentMapper courseContentMapper; private CourseContentMapper courseContentMapper;
@Autowired @Autowired
...@@ -79,12 +108,6 @@ public class MemberServiceImpl extends ServiceImpl<MemberMapper, MemberDO> imple ...@@ -79,12 +108,6 @@ public class MemberServiceImpl extends ServiceImpl<MemberMapper, MemberDO> imple
private MemberDepartmentMappingMapper memberDepartmentMappingMapper; private MemberDepartmentMappingMapper memberDepartmentMappingMapper;
@Autowired @Autowired
private ClassHourDictMapper classHourDictMapper;
@Autowired
private OprMemDictMapper oprMemDictMapper;
@Autowired
private RedisUtil redisUtil; private RedisUtil redisUtil;
public IPage<GetAllVO> getAll(GetAllDTO getAllDTO) { public IPage<GetAllVO> getAll(GetAllDTO getAllDTO) {
...@@ -100,15 +123,33 @@ public class MemberServiceImpl extends ServiceImpl<MemberMapper, MemberDO> imple ...@@ -100,15 +123,33 @@ public class MemberServiceImpl extends ServiceImpl<MemberMapper, MemberDO> imple
} }
public String deleteMember(MemberDO memberDO) { public String deleteMember(MemberDO memberDO) {
this.baseMapper.deleteById(memberDO.getId());
classMemberMappingMapper.delete(new QueryWrapper<ClassMemberMappingDO>() final ExecutorService newCachedThreadPool = Executors.newCachedThreadPool();
.lambda()
.eq(ClassMemberMappingDO::getMemberId, memberDO.getId()));
memberDepartmentMappingMapper.delete(new QueryWrapper<MemberDepartmentMappingDO>() //多个任务
.lambda() newCachedThreadPool.execute(() -> ///该学生完成了多少个 学生成绩,学生进度
.eq(MemberDepartmentMappingDO::getMemberId, memberDO.getId())); this.baseMapper.deleteById(memberDO.getId()));
newCachedThreadPool.execute(() -> //答疑
classMemberMappingMapper.delete(new QueryWrapper<ClassMemberMappingDO>()
.lambda()
.eq(ClassMemberMappingDO::getMemberId, memberDO.getId())));
newCachedThreadPool.execute(() -> //签到
memberDepartmentMappingMapper.delete(new QueryWrapper<MemberDepartmentMappingDO>()
.lambda()
.eq(MemberDepartmentMappingDO::getMemberId, memberDO.getId())));
//执行后不再接收新任务,如果里面有任务,就执行完
newCachedThreadPool.shutdown();
try {
while (true) {
//等待所有任务都结束了继续执行
if (newCachedThreadPool.isTerminated()) {
break;
}
}
} catch (Exception ex) {
ex.printStackTrace();
}
return ConstantUtils.DELETE_SUCCESS; return ConstantUtils.DELETE_SUCCESS;
} }
...@@ -216,7 +257,8 @@ public class MemberServiceImpl extends ServiceImpl<MemberMapper, MemberDO> imple ...@@ -216,7 +257,8 @@ public class MemberServiceImpl extends ServiceImpl<MemberMapper, MemberDO> imple
oprMemDictDO.setUserId(memberDO.getId()); oprMemDictDO.setUserId(memberDO.getId());
oprMemDictDO.setOprType("登录"); oprMemDictDO.setOprType("登录");
oprMemDictDO.setResult(0); oprMemDictDO.setResult(0);
oprMemDictMapper.insert(oprMemDictDO); //oprMemDictMapper.insert(oprMemDictDO);
redisUtil.set(RedisPrefixConstant.SUBSIDY_MEMBER_LOGIN_PREFIX + memberDO.getId() + LocalDateTime.now(), oprMemDictDO);
throw new HttpException(10013); throw new HttpException(10013);
} }
...@@ -227,84 +269,93 @@ public class MemberServiceImpl extends ServiceImpl<MemberMapper, MemberDO> imple ...@@ -227,84 +269,93 @@ public class MemberServiceImpl extends ServiceImpl<MemberMapper, MemberDO> imple
} }
BeanUtils.copyProperties(memberDO, userRoleVO); BeanUtils.copyProperties(memberDO, userRoleVO);
String code = redisUtil.get("subsidySmsCode_"+verifyCodeDTO.getTelephone()).toString(); String code = redisUtil.get(RedisPrefixConstant.SUBSIDY_TELEPHONE_PREFIX + verifyCodeDTO.getTelephone()).toString();
//SmsVerifyCodeDO smsCodeDO = smsVerifyCodeMapper.selectOne(new QueryWrapper<SmsVerifyCodeDO>() //SmsVerifyCodeDO smsCodeDO = smsVerifyCodeMapper.selectOne(new QueryWrapper<SmsVerifyCodeDO>()
// .lambda() // .lambda()
// .eq(SmsVerifyCodeDO::getTelephone, verifyCodeDTO.getTelephone()) // .eq(SmsVerifyCodeDO::getTelephone, verifyCodeDTO.getTelephone())
// .eq(SmsVerifyCodeDO::getVerifyCode, verifyCodeDTO.getVerifyCode()) // .eq(SmsVerifyCodeDO::getVerifyCode, verifyCodeDTO.getVerifyCode())
// .gt(SmsVerifyCodeDO::getCreateDate, LocalDateTime.now().minusMinutes(30L))); // .gt(SmsVerifyCodeDO::getCreateDate, LocalDateTime.now().minusMinutes(30L)));
if (code == null || !verifyCodeDTO.getVerifyCode().equals(code) ) { if (code == null || !verifyCodeDTO.getVerifyCode().equals(code)) {
OprMemDictDO oprMemDictDO = new OprMemDictDO(); OprMemDictDO oprMemDictDO = new OprMemDictDO();
oprMemDictDO.setUserId(memberDO.getId()); oprMemDictDO.setUserId(memberDO.getId());
oprMemDictDO.setOprType("登录"); oprMemDictDO.setOprType("登录");
oprMemDictDO.setResult(0); oprMemDictDO.setResult(0);
oprMemDictMapper.insert(oprMemDictDO); oprMemDictDO.setCreateDate(LocalDateTime.now());
//oprMemDictMapper.insert(oprMemDictDO);
redisUtil.set(RedisPrefixConstant.SUBSIDY_MEMBER_LOGIN_PREFIX + memberDO.getId() + LocalDateTime.now(), oprMemDictDO);
throw new HttpException(70010); throw new HttpException(70010);
} }
OprMemDictDO oprMemDictDO = new OprMemDictDO(); OprMemDictDO oprMemDictDO = new OprMemDictDO();
oprMemDictDO.setUserId(memberDO.getId()); oprMemDictDO.setUserId(memberDO.getId());
oprMemDictDO.setOprType("登录"); oprMemDictDO.setOprType("登录");
oprMemDictDO.setResult(1); oprMemDictDO.setResult(1);
oprMemDictMapper.insert(oprMemDictDO); //oprMemDictMapper.insert(oprMemDictDO);
//审计日志
redisUtil.set(RedisPrefixConstant.SUBSIDY_MEMBER_LOGIN_PREFIX + memberDO.getId() + LocalDateTime.now(), oprMemDictDO);
//将学员信息写到redis //将学员信息写到redis
redisUtil.set("subsidyMember_"+memberDO.getCompanyId()+":"+memberDO.getAccountName(),memberDO); redisUtil.set(RedisPrefixConstant.SUBSIDY_COMPANY_MEMBER_PREFIX + memberDO.getCompanyId() + ":" + memberDO.getAccountName(), memberDO);
return userRoleVO; return userRoleVO;
} }
public MemberDO passwordLogin(PasswordLoginDTO passwordLoginDTO) { public MemberDO passwordLogin(PasswordLoginDTO passwordLoginDTO) {
//UserRoleVO userRoleVO = this.baseMapper.passwordLogin(passwordLoginDTO);
/** /**
* 先从redis里查 * 先从redis里查
*/ */
MemberDO memberDO = (MemberDO) redisUtil.get("subsidyMember_"+passwordLoginDTO.getCompanyId()+":"+passwordLoginDTO.getAccountName()); MemberDO memberDO = (MemberDO) redisUtil.get(RedisPrefixConstant.SUBSIDY_COMPANY_MEMBER_PREFIX + passwordLoginDTO.getCompanyId() + ":" + passwordLoginDTO.getAccountName());
if (null==memberDO){ if (null == memberDO) {
/** /**
* redis里没有,从数据库里查 * redis里没有,从数据库里查
*/ */
memberDO = this.baseMapper.selectOne(new QueryWrapper<MemberDO>() memberDO = this.baseMapper.selectOne(new QueryWrapper<MemberDO>()
.lambda() .lambda()
.eq(MemberDO::getCompanyId,passwordLoginDTO.getCompanyId()) .eq(MemberDO::getCompanyId, passwordLoginDTO.getCompanyId())
.eq(MemberDO::getAccountName,passwordLoginDTO.getAccountName())); .eq(MemberDO::getAccountName, passwordLoginDTO.getAccountName()));
} if (memberDO == null) {
if (memberDO == null) { throw new HttpException(10017);
throw new HttpException(10017); }
}
if (!memberDO.getPassword().equals(passwordLoginDTO.getPassword())) {
OprMemDictDO oprMemDictDO = new OprMemDictDO();
oprMemDictDO.setUserId(memberDO.getId());
oprMemDictDO.setOprType("登录");
oprMemDictDO.setResult(0);
oprMemDictMapper.insert(oprMemDictDO);
throw new HttpException(10016);
} }
if (0 == memberDO.getFirstLogin()) { if (memberDO.getPassword().equals(passwordLoginDTO.getPassword())&&1==memberDO.getFirstLogin()&&"冻结".equals(memberDO.getStatus())){
OprMemDictDO oprMemDictDO = new OprMemDictDO(); OprMemDictDO oprMemDictDO = new OprMemDictDO();
oprMemDictDO.setUserId(memberDO.getId()); oprMemDictDO.setUserId(memberDO.getId());
oprMemDictDO.setOprType("登录"); oprMemDictDO.setOprType("登录");
oprMemDictDO.setResult(0); oprMemDictDO.setResult(1);
oprMemDictMapper.insert(oprMemDictDO); oprMemDictDO.setCreateDate(LocalDateTime.now());
throw new HttpException(10015); redisUtil.set(RedisPrefixConstant.SUBSIDY_MEMBER_LOGIN_PREFIX + memberDO.getId() + "_" + System.currentTimeMillis(), 1);
} return memberDO;
}else {
if ("冻结".equals(memberDO.getStatus())) { if (!memberDO.getPassword().equals(passwordLoginDTO.getPassword())) {
throw new HttpException(10014); OprMemDictDO oprMemDictDO = new OprMemDictDO();
oprMemDictDO.setUserId(memberDO.getId());
oprMemDictDO.setOprType("登录");
oprMemDictDO.setResult(0);
redisUtil.set(RedisPrefixConstant.SUBSIDY_MEMBER_LOGIN_PREFIX + memberDO.getId() + LocalDateTime.now(), oprMemDictDO);
throw new HttpException(10016);
}
if (0 == memberDO.getFirstLogin()) {
OprMemDictDO oprMemDictDO = new OprMemDictDO();
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);
throw new HttpException(10015);
}
if ("冻结".equals(memberDO.getStatus())) {
throw new HttpException(10014);
}
} }
return null;
OprMemDictDO oprMemDictDO = new OprMemDictDO();
oprMemDictDO.setUserId(memberDO.getId());
oprMemDictDO.setOprType("登录");
oprMemDictDO.setResult(1);
oprMemDictMapper.insert(oprMemDictDO);
return memberDO;
} }
@Async
public String updatePassword(MemberDO memberDO) { public String updatePassword(MemberDO memberDO) {
this.baseMapper.updateById(memberDO); this.baseMapper.updateById(memberDO);
MemberDO memberDO1 = this.baseMapper.selectById(memberDO.getId()); MemberDO memberDO1 = this.baseMapper.selectById(memberDO.getId());
redisUtil.set("subsidyMember_"+memberDO1.getCompanyId()+":"+memberDO.getAccountName(),memberDO); redisUtil.set(RedisPrefixConstant.SUBSIDY_COMPANY_MEMBER_PREFIX + memberDO1.getCompanyId() + ":" + memberDO.getAccountName(), memberDO);
return ConstantUtils.SET_SUCCESS; return ConstantUtils.SET_SUCCESS;
} }
...@@ -320,6 +371,8 @@ public class MemberServiceImpl extends ServiceImpl<MemberMapper, MemberDO> imple ...@@ -320,6 +371,8 @@ public class MemberServiceImpl extends ServiceImpl<MemberMapper, MemberDO> imple
List<VodDictDO> vodDictDOS = courseContentMapper.getCourseVods(studyPageVO.getId()); List<VodDictDO> vodDictDOS = courseContentMapper.getCourseVods(studyPageVO.getId());
studyPageVO.setTotalVods(vodDictDOS.size()); studyPageVO.setTotalVods(vodDictDOS.size());
final ExecutorService newCachedThreadPool = Executors.newCachedThreadPool();
int i = 0; int i = 0;
//该成员完成了几个视频 //该成员完成了几个视频
...@@ -338,38 +391,32 @@ public class MemberServiceImpl extends ServiceImpl<MemberMapper, MemberDO> imple ...@@ -338,38 +391,32 @@ public class MemberServiceImpl extends ServiceImpl<MemberMapper, MemberDO> imple
} }
studyPageVO.setDoneVods(i); studyPageVO.setDoneVods(i);
//该班级课程下有多少人 //该班级课程下有多少人
List<ClassMemberMappingDO> classMemberMappingDOS = classMemberMappingMapper.selectList(new QueryWrapper<ClassMemberMappingDO>() List<ClassMemberMappingDO> classMemberMappingDOS = classMemberMappingMapper.selectList(new QueryWrapper<ClassMemberMappingDO>()
.lambda() .lambda()
.eq(ClassMemberMappingDO::getClassId, studyPageVO.getClassId())); .eq(ClassMemberMappingDO::getClassId, studyPageVO.getClassId()));
studyPageVO.setTotalMember(classMemberMappingDOS.size()); studyPageVO.setTotalMember(classMemberMappingDOS.size());
//多少人完成 ////多个任务
//int completedCnt = 0; //newCachedThreadPool.execute(() ->
//for (ClassMemberMappingDO cmmd : classMemberMappingDOS) { // studyPageTask1(studyPageVO, vodDictDOS, memberDO.getId()));
// //newCachedThreadPool.execute(() ->
// Boolean flag = true; // studyPageTask2(studyPageVO));
//
// for (VodDictDO vodDictDO : vodDictDOS) { //执行后不再接收新任务,如果里面有任务,就执行完
// List<VodPlayHistoryDO> vodPlayHistoryDOS = vodPlayHistoryMapper.selectList(new QueryWrapper<VodPlayHistoryDO>() newCachedThreadPool.shutdown();
// .lambda() try {
// .eq(VodPlayHistoryDO::getVodId, vodDictDO.getId()) while (true) {
// .eq(VodPlayHistoryDO::getMemberId, cmmd.getMemberId()) //等待所有任务都结束了继续执行
// .orderByDesc(VodPlayHistoryDO::getPlayRecord)); if (newCachedThreadPool.isTerminated()) {
// if (vodPlayHistoryDOS.size() > 0) { break;
// if (vodPlayHistoryDOS.get(0).getPlayRecord() < vodDictDO.getVodLength()) { }
// flag = false; }
// //break;
// } } catch (Exception ex) {
// } else { ex.printStackTrace();
// flag = false; }
// }
// }
// if (flag) {
// completedCnt++;
// }
//}
//studyPageVO.setDoneMember(completedCnt);
} }
memberStudyPageVO.setStudyPageVOS(studyPageVOS); memberStudyPageVO.setStudyPageVOS(studyPageVOS);
...@@ -385,6 +432,40 @@ public class MemberServiceImpl extends ServiceImpl<MemberMapper, MemberDO> imple ...@@ -385,6 +432,40 @@ public class MemberServiceImpl extends ServiceImpl<MemberMapper, MemberDO> imple
return memberStudyPageVO; return memberStudyPageVO;
} }
public Future<StudyPageVO> studyPageTask1(StudyPageVO studyPageVO, List<VodDictDO> vodDictDOS, Long memberId) {
int i = 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) {
i++;
}
}
}
studyPageVO.setDoneVods(i);
return new AsyncResult<>(studyPageVO);
}
public Future<StudyPageVO> studyPageTask2(StudyPageVO studyPageVO) {
//该班级课程下有多少人
List<ClassMemberMappingDO> classMemberMappingDOS = classMemberMappingMapper.selectList(new QueryWrapper<ClassMemberMappingDO>()
.lambda()
.eq(ClassMemberMappingDO::getClassId, studyPageVO.getClassId()));
studyPageVO.setTotalMember(classMemberMappingDOS.size());
return new AsyncResult<>(studyPageVO);
}
public ContentVodNewVO contentVod(ContentMemberDTO contentVodDTO) { public ContentVodNewVO contentVod(ContentMemberDTO contentVodDTO) {
ContentVodNewVO contentVodNewVO = new ContentVodNewVO(); ContentVodNewVO contentVodNewVO = new ContentVodNewVO();
...@@ -407,39 +488,27 @@ public class MemberServiceImpl extends ServiceImpl<MemberMapper, MemberDO> imple ...@@ -407,39 +488,27 @@ public class MemberServiceImpl extends ServiceImpl<MemberMapper, MemberDO> imple
.eq(VodDictDO::getContentId, courseContentDO.getId())); .eq(VodDictDO::getContentId, courseContentDO.getId()));
for (VodDictDO vodDictDO : vodDictDOS) { for (VodDictDO vodDictDO : vodDictDOS) {
MemberVodVO memberVodVO = new MemberVodVO(); MemberVodVO memberVodVO = new MemberVodVO();
List<VodPlayHistoryDO> vodPlayHistoryDOS = vodPlayHistoryMapper.selectList(new QueryWrapper<VodPlayHistoryDO>() final ExecutorService newCachedThreadPool = Executors.newCachedThreadPool();
.lambda()
.eq(VodPlayHistoryDO::getMemberId, contentVodDTO.getMemberId()) //多个任务
.eq(VodPlayHistoryDO::getVodId, vodDictDO.getId()) newCachedThreadPool.execute(() ->
.orderByDesc(VodPlayHistoryDO::getPlayRecord)); contentVodTask1(memberVodVO, vodDictDO, contentVodDTO.getMemberId()));
newCachedThreadPool.execute(() ->
memberVodVO.setStatus(false); contentVodTask2(memberVodVO, vodDictDO, contentVodDTO.getMemberId()));
if (vodPlayHistoryDOS.size() > 0) {
int length = MathUtil.intDivCeil(100 * vodPlayHistoryDOS.get(0).getPlayRecord(), vodDictDO.getVodLength()); //执行后不再接收新任务,如果里面有任务,就执行完
if (length >= 100) { newCachedThreadPool.shutdown();
memberVodVO.setPercent(100); try {
} else { while (true) {
memberVodVO.setPercent(length); //等待所有任务都结束了继续执行
if (newCachedThreadPool.isTerminated()) {
break;
}
} }
if (memberVodVO.getPercent() >= 80) { } catch (Exception ex) {
memberVodVO.setStatus(true); ex.printStackTrace();
}
} else {
memberVodVO.setPercent(0);
} }
List<VodPlayHistoryDO> vodPlayHistoryDOS1 = vodPlayHistoryMapper.selectList(new QueryWrapper<VodPlayHistoryDO>()
.lambda()
.eq(VodPlayHistoryDO::getMemberId, contentVodDTO.getMemberId())
.eq(VodPlayHistoryDO::getVodId, vodDictDO.getId())
.orderByDesc(VodPlayHistoryDO::getCreateDate));
if (vodPlayHistoryDOS1.size() > 0) {
memberVodVO.setPlayRecord(vodPlayHistoryDOS1.get(0).getPlayRecord());
}
memberVodVO.setId(vodDictDO.getId());
memberVodVO.setVodUrl(vodDictDO.getVodUrl());
memberVodVO.setTeacherName(vodDictDO.getTeacherName());
memberVodVO.setVodLength(vodDictDO.getVodLength());
memberVodVO.setVodName(vodDictDO.getVodName());
memberVodVOS.add(memberVodVO); memberVodVOS.add(memberVodVO);
} }
contentVodVO.setMemberVodVOS(memberVodVOS); contentVodVO.setMemberVodVOS(memberVodVOS);
...@@ -464,6 +533,51 @@ public class MemberServiceImpl extends ServiceImpl<MemberMapper, MemberDO> imple ...@@ -464,6 +533,51 @@ public class MemberServiceImpl extends ServiceImpl<MemberMapper, MemberDO> imple
return contentVodNewVO; return contentVodNewVO;
} }
public Future<MemberVodVO> contentVodTask1(MemberVodVO memberVodVO, VodDictDO vodDictDO, Long memberId) {
List<VodPlayHistoryDO> vodPlayHistoryDOS = vodPlayHistoryMapper.selectList(new QueryWrapper<VodPlayHistoryDO>()
.lambda()
.eq(VodPlayHistoryDO::getMemberId, memberId)
.eq(VodPlayHistoryDO::getVodId, vodDictDO.getId())
.orderByDesc(VodPlayHistoryDO::getPlayRecord));
memberVodVO.setStatus(false);
if (vodPlayHistoryDOS.size() > 0) {
int length = MathUtil.intDivCeil(100 * vodPlayHistoryDOS.get(0).getPlayRecord(), vodDictDO.getVodLength());
if (length >= 100) {
memberVodVO.setPercent(100);
} else {
memberVodVO.setPercent(length);
}
if (memberVodVO.getPercent() >= 80) {
memberVodVO.setStatus(true);
}
} else {
memberVodVO.setPercent(0);
}
return new AsyncResult<>(memberVodVO);
}
public Future<MemberVodVO> contentVodTask2(MemberVodVO memberVodVO, VodDictDO vodDictDO, Long memberId) {
List<VodPlayHistoryDO> vodPlayHistoryDOS1 = vodPlayHistoryMapper.selectList(new QueryWrapper<VodPlayHistoryDO>()
.lambda()
.eq(VodPlayHistoryDO::getMemberId, memberId)
.eq(VodPlayHistoryDO::getVodId, vodDictDO.getId())
.orderByDesc(VodPlayHistoryDO::getCreateDate));
if (vodPlayHistoryDOS1.size() > 0) {
memberVodVO.setPlayRecord(vodPlayHistoryDOS1.get(0).getPlayRecord());
}
memberVodVO.setId(vodDictDO.getId());
memberVodVO.setVodUrl(vodDictDO.getVodUrl());
memberVodVO.setTeacherName(vodDictDO.getTeacherName());
memberVodVO.setVodLength(vodDictDO.getVodLength());
memberVodVO.setVodName(vodDictDO.getVodName());
return new AsyncResult<>(memberVodVO);
}
public List<ContentFilesVO> contentFiles(ContentMemberDTO contentMemberDTO) { public List<ContentFilesVO> contentFiles(ContentMemberDTO contentMemberDTO) {
List<ContentFilesVO> contentFilesVOS = new ArrayList<>(); List<ContentFilesVO> contentFilesVOS = new ArrayList<>();
...@@ -513,31 +627,36 @@ public class MemberServiceImpl extends ServiceImpl<MemberMapper, MemberDO> imple ...@@ -513,31 +627,36 @@ public class MemberServiceImpl extends ServiceImpl<MemberMapper, MemberDO> imple
//查看该班级下的测试卷子(有效卷子) //查看该班级下的测试卷子(有效卷子)
ClassDictDO classDictDO = classDictMapper.selectById(contentMemberDTO.getClassId()); ClassDictDO classDictDO = classDictMapper.selectById(contentMemberDTO.getClassId());
List<QueryPapersVO> queryPapersVOS = paperDictMapper.queryPapers(contentMemberDTO.getCourseId(), null, 1); List<QueryPapersVO> queryPapersVOS = paperDictMapper.queryPapers(contentMemberDTO.getCourseId(), null, 1);
ExecutorService executorService = Executors.newCachedThreadPool();
for (QueryPapersVO queryPapersVO : queryPapersVOS) { for (QueryPapersVO queryPapersVO : queryPapersVOS) {
//多少人已完成 executorService.execute(()->getCourseTestTask(queryPapersVO,contentMemberDTO.getMemberId(),classDictDO));
Integer cnt = paperDictMapper.completeCount(queryPapersVO.getId());
queryPapersVO.setCompleteCnt(cnt);
//自己成绩
List<ExerciseDoneResultDO> exerciseDoneResultDOS = exerciseDoneResultMapper.selectList(new QueryWrapper<ExerciseDoneResultDO>()
.lambda()
.eq(ExerciseDoneResultDO::getMemberId, contentMemberDTO.getMemberId())
.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());
} else {
queryPapersVO.setResult("待完成");
}
//截止时间
queryPapersVO.setEndDate(classDictDO.getEndDate());
} }
return queryPapersVOS; return queryPapersVOS;
} }
public void getCourseTestTask(QueryPapersVO queryPapersVO,Long memberId,ClassDictDO classDictDO){
//多少人已完成
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());
} else {
queryPapersVO.setResult("待完成");
}
//截止时间
queryPapersVO.setEndDate(classDictDO.getEndDate());
}
public List<ExerciseDoneResultDO> getPaperDoneDetail(ExerciseDoneResultDO exerciseDoneResultDO) { public List<ExerciseDoneResultDO> getPaperDoneDetail(ExerciseDoneResultDO exerciseDoneResultDO) {
return exerciseDoneResultMapper.selectList(new QueryWrapper<ExerciseDoneResultDO>() return exerciseDoneResultMapper.selectList(new QueryWrapper<ExerciseDoneResultDO>()
.lambda() .lambda()
...@@ -551,14 +670,35 @@ public class MemberServiceImpl extends ServiceImpl<MemberMapper, MemberDO> imple ...@@ -551,14 +670,35 @@ public class MemberServiceImpl extends ServiceImpl<MemberMapper, MemberDO> imple
MemberDO memberDO1 = this.baseMapper.selectById(memberDO.getId()); MemberDO memberDO1 = this.baseMapper.selectById(memberDO.getId());
//第几天 final ExecutorService newCachedThreadPool = Executors.newCachedThreadPool();
long diff = Duration.between(memberDO1.getCreateDate(), LocalDateTime.now()).toDays();
getStudyInfoVO.setDiff(diff); //多个任务
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>() List<ClassMemberMappingDO> classMemberMappingDOS = classMemberMappingMapper.selectList(new QueryWrapper<ClassMemberMappingDO>()
.lambda() .lambda()
.eq(ClassMemberMappingDO::getMemberId, memberDO.getId())); .eq(ClassMemberMappingDO::getMemberId, memberId));
/** /**
* 遍历课程,里面的视频都看过80% 则表示已学完 * 遍历课程,里面的视频都看过80% 则表示已学完
*/ */
...@@ -568,7 +708,7 @@ public class MemberServiceImpl extends ServiceImpl<MemberMapper, MemberDO> imple ...@@ -568,7 +708,7 @@ public class MemberServiceImpl extends ServiceImpl<MemberMapper, MemberDO> imple
for (VodDictDO vodDictDO : vodDictDOS) { for (VodDictDO vodDictDO : vodDictDOS) {
List<VodPlayHistoryDO> vodPlayHistoryDOS = vodPlayHistoryMapper.selectList(new QueryWrapper<VodPlayHistoryDO>() List<VodPlayHistoryDO> vodPlayHistoryDOS = vodPlayHistoryMapper.selectList(new QueryWrapper<VodPlayHistoryDO>()
.lambda() .lambda()
.eq(VodPlayHistoryDO::getMemberId, memberDO.getId()) .eq(VodPlayHistoryDO::getMemberId, memberId)
.eq(VodPlayHistoryDO::getVodId, vodDictDO.getId()) .eq(VodPlayHistoryDO::getVodId, vodDictDO.getId())
.orderByDesc(VodPlayHistoryDO::getPlayRecord)); .orderByDesc(VodPlayHistoryDO::getPlayRecord));
if (vodPlayHistoryDOS.size() > 0) { if (vodPlayHistoryDOS.size() > 0) {
...@@ -580,7 +720,10 @@ public class MemberServiceImpl extends ServiceImpl<MemberMapper, MemberDO> imple ...@@ -580,7 +720,10 @@ public class MemberServiceImpl extends ServiceImpl<MemberMapper, MemberDO> imple
i++; i++;
} }
getStudyInfoVO.setStudyCourse(i); getStudyInfoVO.setStudyCourse(i);
return new AsyncResult<>(getStudyInfoVO);
}
public Future<GetStudyInfoVO> getStudyInfoTask2(MemberDO memberDO, GetStudyInfoVO getStudyInfoVO) {
//累计学习时长 //累计学习时长
int studyLength = 0; int studyLength = 0;
List<VodPlayHistoryDO> vodPlayHistoryDOS = vodPlayHistoryMapper.selectList(new QueryWrapper<VodPlayHistoryDO>() List<VodPlayHistoryDO> vodPlayHistoryDOS = vodPlayHistoryMapper.selectList(new QueryWrapper<VodPlayHistoryDO>()
...@@ -592,7 +735,10 @@ public class MemberServiceImpl extends ServiceImpl<MemberMapper, MemberDO> imple ...@@ -592,7 +735,10 @@ public class MemberServiceImpl extends ServiceImpl<MemberMapper, MemberDO> imple
} }
getStudyInfoVO.setStudyLength(studyLength); getStudyInfoVO.setStudyLength(studyLength);
return getStudyInfoVO; //第几天
long diff = Duration.between(memberDO.getCreateDate(), LocalDateTime.now()).toDays();
getStudyInfoVO.setDiff(diff);
return new AsyncResult(getStudyInfoVO);
} }
public ExerciseDoneResultDO getDoneResult(ExerciseDoneResultDO exerciseDoneResultDO) { public ExerciseDoneResultDO getDoneResult(ExerciseDoneResultDO exerciseDoneResultDO) {
...@@ -601,8 +747,8 @@ public class MemberServiceImpl extends ServiceImpl<MemberMapper, MemberDO> imple ...@@ -601,8 +747,8 @@ public class MemberServiceImpl extends ServiceImpl<MemberMapper, MemberDO> imple
public String checkTimes(ExerciseDoneResultDO exerciseDoneResultDO) { public String checkTimes(ExerciseDoneResultDO exerciseDoneResultDO) {
MemberDO memberDO = this.baseMapper.selectById(exerciseDoneResultDO.getMemberId());
ClassHourDictDO classHourDictDO = classHourDictMapper.getClassHourDictInfo(exerciseDoneResultDO.getClassId()); ClassHourDictDO classHourDictDO = (ClassHourDictDO) redisUtil.get(RedisPrefixConstant.SUBSIDY_SETTINGS_PREFIX+memberDO.getCompanyId());
if (null != classHourDictDO) { if (null != classHourDictDO) {
Integer status = classHourDictDO.getRepeatStatus(); Integer status = classHourDictDO.getRepeatStatus();
...@@ -626,7 +772,7 @@ public class MemberServiceImpl extends ServiceImpl<MemberMapper, MemberDO> imple ...@@ -626,7 +772,7 @@ public class MemberServiceImpl extends ServiceImpl<MemberMapper, MemberDO> imple
public void importRedis() { public void importRedis() {
List<MemberDO> memberDOS = this.baseMapper.selectList(null); List<MemberDO> memberDOS = this.baseMapper.selectList(null);
for (MemberDO memberDO : memberDOS) { for (MemberDO memberDO : memberDOS) {
redisUtil.set("subsidyMember_"+memberDO.getCompanyId()+":"+memberDO.getAccountName(),memberDO); redisUtil.set(RedisPrefixConstant.SUBSIDY_COMPANY_MEMBER_PREFIX + memberDO.getCompanyId() + ":" + memberDO.getAccountName(), memberDO);
} }
} }
......
...@@ -8,6 +8,7 @@ import com.subsidy.service.PaperDictService; ...@@ -8,6 +8,7 @@ import com.subsidy.service.PaperDictService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.subsidy.util.ConstantUtils; import com.subsidy.util.ConstantUtils;
import com.subsidy.vo.paper.QueryPapersVO; import com.subsidy.vo.paper.QueryPapersVO;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.List; import java.util.List;
...@@ -27,16 +28,19 @@ public class PaperDictServiceImpl extends ServiceImpl<PaperDictMapper, PaperDict ...@@ -27,16 +28,19 @@ public class PaperDictServiceImpl extends ServiceImpl<PaperDictMapper, PaperDict
return this.baseMapper.queryPapers(paperDictDO.getCourseId(),paperDictDO.getPaperName(),null); return this.baseMapper.queryPapers(paperDictDO.getCourseId(),paperDictDO.getPaperName(),null);
} }
@Async
public String deletePaper(PaperDictDO paperDictDO){ public String deletePaper(PaperDictDO paperDictDO){
this.baseMapper.deleteById(paperDictDO.getId()); this.baseMapper.deleteById(paperDictDO.getId());
return ConstantUtils.DELETE_SUCCESS; return ConstantUtils.DELETE_SUCCESS;
} }
@Async
public String updateStatus(PaperDictDO paperDictDO){ public String updateStatus(PaperDictDO paperDictDO){
this.baseMapper.updateById(paperDictDO); this.baseMapper.updateById(paperDictDO);
return ConstantUtils.SET_SUCCESS; return ConstantUtils.SET_SUCCESS;
} }
@Async
public String addPaper(PaperDictDO paperDictDO){ public String addPaper(PaperDictDO paperDictDO){
Integer count = this.baseMapper.selectCount(new QueryWrapper<PaperDictDO>() Integer count = this.baseMapper.selectCount(new QueryWrapper<PaperDictDO>()
......
...@@ -3,28 +3,42 @@ package com.subsidy.service.impl; ...@@ -3,28 +3,42 @@ package com.subsidy.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.subsidy.common.RedisPrefixConstant;
import com.subsidy.dto.member.GetMemberSignInfoDTO; import com.subsidy.dto.member.GetMemberSignInfoDTO;
import com.subsidy.dto.sign.ClassSignInfoDTO; import com.subsidy.dto.sign.ClassSignInfoDTO;
import com.subsidy.dto.sign.SignInDTO; import com.subsidy.mapper.AnsweringQuestionMapper;
import com.subsidy.mapper.*; import com.subsidy.mapper.ClassDictMapper;
import com.subsidy.model.*; import com.subsidy.mapper.ClassHourDictMapper;
import com.subsidy.mapper.ClassMemberMappingMapper;
import com.subsidy.mapper.ExerciseDoneResultMapper;
import com.subsidy.mapper.SignInRecordMapper;
import com.subsidy.mapper.VodPlayHistoryMapper;
import com.subsidy.model.AnsweringQuestionDO;
import com.subsidy.model.ClassDictDO;
import com.subsidy.model.ClassHourDictDO;
import com.subsidy.model.ClassMemberMappingDO;
import com.subsidy.model.ExerciseDoneResultDO;
import com.subsidy.model.SignInRecordDO;
import com.subsidy.model.VodDictDO;
import com.subsidy.model.VodPlayHistoryDO;
import com.subsidy.service.SignInRecordService; import com.subsidy.service.SignInRecordService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.subsidy.util.ConstantUtils; import com.subsidy.util.ConstantUtils;
import com.subsidy.util.DateFormatUtil; import com.subsidy.util.DateFormatUtil;
import com.subsidy.util.MathUtil; import com.subsidy.util.MathUtil;
import com.subsidy.util.RedisUtil; import com.subsidy.util.RedisUtil;
import com.subsidy.vo.member.ClassSignVO;
import com.subsidy.vo.member.GetMemberSignInfoVO; import com.subsidy.vo.member.GetMemberSignInfoVO;
import com.subsidy.vo.sign.ClassSignInfoVO; import com.subsidy.vo.sign.ClassSignInfoVO;
import com.subsidy.vo.sign.SignInStatusVO; import com.subsidy.vo.sign.SignInStatusVO;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
/** /**
* <p> * <p>
...@@ -55,6 +69,9 @@ public class SignInRecordServiceImpl extends ServiceImpl<SignInRecordMapper, Sig ...@@ -55,6 +69,9 @@ public class SignInRecordServiceImpl extends ServiceImpl<SignInRecordMapper, Sig
@Autowired @Autowired
private RedisUtil redisUtil; private RedisUtil redisUtil;
@Autowired
private ClassHourDictMapper classHourDictMapper;
public IPage<GetMemberSignInfoVO> getMemberSignInfo(GetMemberSignInfoDTO getMemberSignInfoDTO) { public IPage<GetMemberSignInfoVO> getMemberSignInfo(GetMemberSignInfoDTO getMemberSignInfoDTO) {
Page pager = new Page(getMemberSignInfoDTO.getPageNum(), getMemberSignInfoDTO.getPageSize()); Page pager = new Page(getMemberSignInfoDTO.getPageNum(), getMemberSignInfoDTO.getPageSize());
...@@ -64,6 +81,7 @@ public class SignInRecordServiceImpl extends ServiceImpl<SignInRecordMapper, Sig ...@@ -64,6 +81,7 @@ public class SignInRecordServiceImpl extends ServiceImpl<SignInRecordMapper, Sig
.orderByDesc(SignInRecordDO::getCreateDate)); .orderByDesc(SignInRecordDO::getCreateDate));
} }
@Async
public String signIn(SignInRecordDO signInRecordDO) { public String signIn(SignInRecordDO signInRecordDO) {
/** /**
...@@ -84,7 +102,7 @@ public class SignInRecordServiceImpl extends ServiceImpl<SignInRecordMapper, Sig ...@@ -84,7 +102,7 @@ public class SignInRecordServiceImpl extends ServiceImpl<SignInRecordMapper, Sig
signInRecordDO1.setSignInDate(LocalDateTime.now()); signInRecordDO1.setSignInDate(LocalDateTime.now());
*/ */
redisUtil.set("subsidySignInfo_"+signInRecordDO.getMemberId()+"_"+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);
// this.baseMapper.insert(signInRecordDO1); // this.baseMapper.insert(signInRecordDO1);
} }
...@@ -107,71 +125,95 @@ public class SignInRecordServiceImpl extends ServiceImpl<SignInRecordMapper, Sig ...@@ -107,71 +125,95 @@ public class SignInRecordServiceImpl extends ServiceImpl<SignInRecordMapper, Sig
classSignInfoVO.setMemberCount(classMemberMappingDOS.size()); classSignInfoVO.setMemberCount(classMemberMappingDOS.size());
//课程总数 //课程总数
List<VodDictDO> vodDictDOS = classDictMapper.getClassVods(classSignInfoVO.getClassId()); List<VodDictDO> vodDictDOS = classDictMapper.getClassVods(classSignInfoVO.getClassId());
classSignInfoVO.setTotalVodCounts(vodDictDOS.size()); classSignInfoVO.setTotalVodCounts(vodDictDOS.size());
final ExecutorService newCachedThreadPool = Executors.newCachedThreadPool();
int totalStudyVods = 0;
int totalStudyLength = 0; //多个任务
//学生总共学习课时数 newCachedThreadPool.execute(() -> ///该学生完成了多少个 学生成绩,学生进度
for (VodDictDO vodDictDO : vodDictDOS) { classSignInfoTask1(vodDictDOS, classMemberMappingDOS, classSignInfoVO));
for (ClassMemberMappingDO classMemberMappingDO : classMemberMappingDOS) { newCachedThreadPool.execute(() -> //答疑
List<VodPlayHistoryDO> vodPlayHistoryDOS = vodPlayHistoryMapper.selectList(new QueryWrapper<VodPlayHistoryDO>() classSignInfoTask2(classSignInfoVO, classMemberMappingDOS));
.lambda() newCachedThreadPool.execute(() -> //签到
.eq(VodPlayHistoryDO::getMemberId, classMemberMappingDO.getMemberId()) classSignInfoTask3(classSignInfoVO, classMemberMappingDOS));
.eq(VodPlayHistoryDO::getVodId, vodDictDO.getId())
.orderByDesc(VodPlayHistoryDO::getPlayRecord)); //执行后不再接收新任务,如果里面有任务,就执行完
for (VodPlayHistoryDO vodPlayHistoryDO : vodPlayHistoryDOS) { newCachedThreadPool.shutdown();
totalStudyLength += vodPlayHistoryDO.getPlayLength(); try {
} while (true) {
if (vodPlayHistoryDOS.size() > 0) { //等待所有任务都结束了继续执行
if (vodPlayHistoryDOS.get(0).getPlayRecord() >= vodDictDO.getVodLength() * 0.8) { if (newCachedThreadPool.isTerminated()) {
totalStudyVods++; break;
}
} }
} }
}
classSignInfoVO.setStudyVodCounts(MathUtil.intDivCeil(totalStudyVods, classMemberMappingDOS.size()));
//平均完成时长 学生观看课程视频的全部时长/总人数
int avg = MathUtil.intDivCeil(totalStudyLength, classMemberMappingDOS.size());
classSignInfoVO.setAvgVodPlayLength(avg);
//测试通过率 } catch (Exception ex) {
List<ExerciseDoneResultDO> exerciseDoneResultDOS = exerciseDoneResultMapper.selectList(new QueryWrapper<ExerciseDoneResultDO>() ex.printStackTrace();
.lambda() }
.eq(ExerciseDoneResultDO::getClassId, classSignInfoVO.getClassId())); }
int passNum = 0; classSignInfoVOIPage.setRecords(classSignInfoVOS);
return classSignInfoVOIPage;
}
for (ExerciseDoneResultDO exerciseDoneResultDO : exerciseDoneResultDOS) { public void classSignInfoTask1(List<VodDictDO> vodDictDOS, List<ClassMemberMappingDO> classMemberMappingDOS, ClassSignInfoVO classSignInfoVO) {
if (exerciseDoneResultDO.getRightCounts() > exerciseDoneResultDO.getTotalCounts() * 0.6) { int totalStudyVods = 0;
passNum++; int totalStudyLength = 0;
//学生总共学习课时数
for (VodDictDO vodDictDO : vodDictDOS) {
for (ClassMemberMappingDO classMemberMappingDO : classMemberMappingDOS) {
List<VodPlayHistoryDO> vodPlayHistoryDOS = vodPlayHistoryMapper.selectList(new QueryWrapper<VodPlayHistoryDO>()
.lambda()
.eq(VodPlayHistoryDO::getMemberId, classMemberMappingDO.getMemberId())
.eq(VodPlayHistoryDO::getVodId, vodDictDO.getId())
.orderByDesc(VodPlayHistoryDO::getPlayRecord));
for (VodPlayHistoryDO vodPlayHistoryDO : vodPlayHistoryDOS) {
totalStudyLength += vodPlayHistoryDO.getPlayLength();
}
if (vodPlayHistoryDOS.size() > 0) {
if (vodPlayHistoryDOS.get(0).getPlayRecord() >= vodDictDO.getVodLength() * 0.8) {
totalStudyVods++;
}
} }
} }
classSignInfoVO.setPassRate(MathUtil.intDivFloorPercent(passNum, classMemberMappingDOS.size())); }
classSignInfoVO.setStudyVodCounts(MathUtil.intDivCeil(totalStudyVods, classMemberMappingDOS.size()));
//平均完成时长 学生观看课程视频的全部时长/总人数
int avg = MathUtil.intDivCeil(totalStudyLength, classMemberMappingDOS.size());
classSignInfoVO.setAvgVodPlayLength(avg);
}
//平均签到数 向上取整 public void classSignInfoTask2(ClassSignInfoVO classSignInfoVO, List<ClassMemberMappingDO> classMemberMappingDOS) {
//签到总次数 //测试通过率
Integer signCount = this.baseMapper.selectCount(new QueryWrapper<SignInRecordDO>() List<ExerciseDoneResultDO> exerciseDoneResultDOS = exerciseDoneResultMapper.selectList(new QueryWrapper<ExerciseDoneResultDO>()
.lambda() .lambda()
.eq(SignInRecordDO::getClassId, classSignInfoVO.getClassId())); .eq(ExerciseDoneResultDO::getClassId, classSignInfoVO.getClassId()));
classSignInfoVO.setAvgSignCount(MathUtil.intDivCeil(signCount, classMemberMappingDOS.size()));
//答疑数 int passNum = 0;
Integer count = answeringQuestionMapper.selectCount(new QueryWrapper<AnsweringQuestionDO>()
.lambda()
.eq(AnsweringQuestionDO::getClassId, classSignInfoVO.getClassId()));
classSignInfoVO.setAnswerCount(count);
}
classSignInfoVOIPage.setRecords(classSignInfoVOS); for (ExerciseDoneResultDO exerciseDoneResultDO : exerciseDoneResultDOS) {
return classSignInfoVOIPage; if (exerciseDoneResultDO.getRightCounts() > exerciseDoneResultDO.getTotalCounts() * 0.6) {
passNum++;
}
}
classSignInfoVO.setPassRate(MathUtil.intDivFloorPercent(passNum, classMemberMappingDOS.size()));
} }
public void classSignInfoTask3(ClassSignInfoVO classSignInfoVO, List<ClassMemberMappingDO> classMemberMappingDOS) {
//平均签到数 向上取整
//签到总次数
long signCount = redisUtil.keys(RedisPrefixConstant.SUBSIDY_SIGN_INFO_PREFIX + "*_classId_" + classSignInfoVO.getClassId() + "_*").stream().count();
classSignInfoVO.setAvgSignCount(MathUtil.intDivCeil(signCount, classMemberMappingDOS.size()));
//答疑数
Integer count = answeringQuestionMapper.selectCount(new QueryWrapper<AnsweringQuestionDO>()
.lambda()
.eq(AnsweringQuestionDO::getClassId, classSignInfoVO.getClassId()));
classSignInfoVO.setAnswerCount(count);
}
public SignInStatusVO signInStatus(SignInRecordDO signInRecordDO) { public SignInStatusVO signInStatus(SignInRecordDO signInRecordDO) {
...@@ -180,35 +222,36 @@ public class SignInRecordServiceImpl extends ServiceImpl<SignInRecordMapper, Sig ...@@ -180,35 +222,36 @@ public class SignInRecordServiceImpl extends ServiceImpl<SignInRecordMapper, Sig
Boolean flag = true; // 已经签过到了 Boolean flag = true; // 已经签过到了
//获取有效课程 //获取有效课程
List<ClassDictDO> classDictDOS = classMemberMappingMapper.getMemberClass(signInRecordDO.getMemberId()); long count = classMemberMappingMapper.getMemberClassCount(signInRecordDO.getMemberId());
for (ClassDictDO classDictDO : classDictDOS) { long size = redisUtil.keys(RedisPrefixConstant.SUBSIDY_SIGN_INFO_PREFIX + "memberId_" + signInRecordDO.getMemberId() + "*_" + DateFormatUtil.format(new Date(), "yyyyMMdd")).stream().count();
/*Integer count = this.baseMapper.selectCount(new QueryWrapper<SignInRecordDO>()
.lambda()
.eq(SignInRecordDO::getClassId, classDictDO.getId())
.eq(SignInRecordDO::getMemberId, signInRecordDO.getMemberId())
.gt(SignInRecordDO::getSignInDate, LocalDate.now()));*/
long count = redisUtil.keys("*subsidySignInfo_"+signInRecordDO.getMemberId()+"_"+classDictDO.getId()+"_"+DateFormatUtil.format(new Date(), "yyyyMMdd")+"*").stream().count();
if (count == 0) { if (size!=count){
flag = false; //没有签到 signInStatusVO.setStatus(flag);
}
} }
signInStatusVO.setStatus(flag);
return signInStatusVO; return signInStatusVO;
} }
public Object test() { @Async
public void test() {
Set set = redisUtil.keys("*subsidyMember*"); //Set set = redisUtil.keys("*subsidyMember*");
for (Object str : set) { //for (Object str : set) {
System.out.println(str); // System.out.println(str);
// redisUtil.get(str.toString());
//}
//List<ClassHourDictDO> classHourDictDOS = classHourDictMapper.selectList(null);
//
//for (ClassHourDictDO classHourDictDO : classHourDictDOS) {
// redisUtil.set(RedisPrefixConstant.SUBSIDY_SETTINGS_PREFIX + classHourDictDO.getCompanyId(), classHourDictDO);
//}
List<ClassHourDictDO> classHourDictDOS = classHourDictMapper.selectList(null);
for (ClassHourDictDO classHourDictDO : classHourDictDOS){
redisUtil.set("subsidySettings_"+classHourDictDO.getCompanyId(),classHourDictDO);
} }
return null;
} }
} }
package com.subsidy.service.impl; package com.subsidy.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.subsidy.common.RedisPrefixConstant;
import com.subsidy.common.exception.HttpException; import com.subsidy.common.exception.HttpException;
import com.subsidy.dto.sms.SendVerifyCodeDTO; import com.subsidy.dto.sms.SendVerifyCodeDTO;
import com.subsidy.mapper.MemberMapper; import com.subsidy.mapper.MemberMapper;
import com.subsidy.mapper.SmsVerifyCodeMapper;
import com.subsidy.model.MemberDO; import com.subsidy.model.MemberDO;
import com.subsidy.model.SmsVerifyCodeDO; import com.subsidy.model.SmsVerifyCodeDO;
import com.subsidy.mapper.SmsVerifyCodeMapper;
import com.subsidy.service.MemberService;
import com.subsidy.service.SmsVerifyCodeService; import com.subsidy.service.SmsVerifyCodeService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.subsidy.util.RandomUtil; import com.subsidy.util.RandomUtil;
import com.subsidy.util.RedisUtil; import com.subsidy.util.RedisUtil;
import com.subsidy.util.SMSUtils; import com.subsidy.util.SMSUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.lang.reflect.Member;
/** /**
* <p> * <p>
* 短信验证码记录表 服务实现类 * 短信验证码记录表 服务实现类
...@@ -38,6 +37,7 @@ public class SmsVerifyCodeServiceImpl extends ServiceImpl<SmsVerifyCodeMapper, S ...@@ -38,6 +37,7 @@ public class SmsVerifyCodeServiceImpl extends ServiceImpl<SmsVerifyCodeMapper, S
@Autowired @Autowired
private RedisUtil redisUtil; private RedisUtil redisUtil;
@Async
public void sendVerifyCode(SendVerifyCodeDTO sendVerifyCodeDTO){ public void sendVerifyCode(SendVerifyCodeDTO sendVerifyCodeDTO){
MemberDO memberDO =memberMapper.selectOne(new QueryWrapper<MemberDO>() MemberDO memberDO =memberMapper.selectOne(new QueryWrapper<MemberDO>()
.lambda() .lambda()
...@@ -57,7 +57,7 @@ public class SmsVerifyCodeServiceImpl extends ServiceImpl<SmsVerifyCodeMapper, S ...@@ -57,7 +57,7 @@ public class SmsVerifyCodeServiceImpl extends ServiceImpl<SmsVerifyCodeMapper, S
/** /**
* 验证码存在redis * 验证码存在redis
*/ */
redisUtil.set("subsidySmsCode_"+sendVerifyCodeDTO.getTelephone(),code,30*60); redisUtil.set(RedisPrefixConstant.SUBSIDY_TELEPHONE_PREFIX +sendVerifyCodeDTO.getTelephone(),code,30*60);
} }
......
...@@ -2,13 +2,13 @@ package com.subsidy.service.impl; ...@@ -2,13 +2,13 @@ package com.subsidy.service.impl;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.subsidy.common.configure.VODConfig; import com.subsidy.common.configure.VODConfig;
import com.subsidy.common.exception.HttpException; import com.subsidy.common.exception.HttpException;
import com.subsidy.dto.content.GetContendVodsDTO; import com.subsidy.dto.content.GetContendVodsDTO;
import com.subsidy.model.VodDictDO;
import com.subsidy.mapper.VodDictMapper; import com.subsidy.mapper.VodDictMapper;
import com.subsidy.model.VodDictDO;
import com.subsidy.service.VodDictService; import com.subsidy.service.VodDictService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.subsidy.util.ConstantUtils; import com.subsidy.util.ConstantUtils;
import com.subsidy.util.Signature; import com.subsidy.util.Signature;
import com.subsidy.vo.vod.GetContendVodsVO; import com.subsidy.vo.vod.GetContendVodsVO;
...@@ -18,11 +18,15 @@ import com.tencentcloudapi.common.exception.TencentCloudSDKException; ...@@ -18,11 +18,15 @@ import com.tencentcloudapi.common.exception.TencentCloudSDKException;
import com.tencentcloudapi.common.profile.ClientProfile; import com.tencentcloudapi.common.profile.ClientProfile;
import com.tencentcloudapi.common.profile.HttpProfile; import com.tencentcloudapi.common.profile.HttpProfile;
import com.tencentcloudapi.vod.v20180717.VodClient; import com.tencentcloudapi.vod.v20180717.VodClient;
import com.tencentcloudapi.vod.v20180717.models.*; import com.tencentcloudapi.vod.v20180717.models.DeleteMediaRequest;
import com.tencentcloudapi.vod.v20180717.models.MediaProcessTaskInput;
import com.tencentcloudapi.vod.v20180717.models.ProcessMediaRequest;
import com.tencentcloudapi.vod.v20180717.models.ProcessMediaResponse;
import com.tencentcloudapi.vod.v20180717.models.TranscodeTaskInput;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Random; import java.util.Random;
/** /**
...@@ -67,6 +71,7 @@ public class VodDictServiceImpl extends ServiceImpl<VodDictMapper, VodDictDO> im ...@@ -67,6 +71,7 @@ public class VodDictServiceImpl extends ServiceImpl<VodDictMapper, VodDictDO> im
return this.baseMapper.getContendVods(pager,getContendVodsDTO.getVodName(),getContendVodsDTO.getContentId()); return this.baseMapper.getContendVods(pager,getContendVodsDTO.getVodName(),getContendVodsDTO.getContentId());
} }
@Async
public String deleteVod(VodDictDO vodDictDO) { public String deleteVod(VodDictDO vodDictDO) {
VodDictDO vodDictDO1 = this.baseMapper.selectById(vodDictDO.getId()); VodDictDO vodDictDO1 = this.baseMapper.selectById(vodDictDO.getId());
this.baseMapper.deleteById(vodDictDO.getId()); this.baseMapper.deleteById(vodDictDO.getId());
...@@ -95,6 +100,7 @@ public class VodDictServiceImpl extends ServiceImpl<VodDictMapper, VodDictDO> im ...@@ -95,6 +100,7 @@ public class VodDictServiceImpl extends ServiceImpl<VodDictMapper, VodDictDO> im
return ConstantUtils.DELETE_SUCCESS; return ConstantUtils.DELETE_SUCCESS;
} }
@Async
public String addVod(VodDictDO vodDictDO) { public String addVod(VodDictDO vodDictDO) {
this.baseMapper.insert(vodDictDO); this.baseMapper.insert(vodDictDO);
//上传后直接转码 //上传后直接转码
...@@ -121,7 +127,6 @@ public class VodDictServiceImpl extends ServiceImpl<VodDictMapper, VodDictDO> im ...@@ -121,7 +127,6 @@ public class VodDictServiceImpl extends ServiceImpl<VodDictMapper, VodDictDO> im
ProcessMediaResponse processMediaResponse = null; ProcessMediaResponse processMediaResponse = null;
try { try {
processMediaResponse = client.ProcessMedia(processMediaRequest); processMediaResponse = client.ProcessMedia(processMediaRequest);
System.out.println(processMediaResponse);
} catch (Exception ex) { } catch (Exception ex) {
throw new HttpException(50001); throw new HttpException(50001);
} }
...@@ -129,6 +134,7 @@ public class VodDictServiceImpl extends ServiceImpl<VodDictMapper, VodDictDO> im ...@@ -129,6 +134,7 @@ public class VodDictServiceImpl extends ServiceImpl<VodDictMapper, VodDictDO> im
return ConstantUtils.ADD_SUCCESS; return ConstantUtils.ADD_SUCCESS;
} }
@Async
public String updateVod(VodDictDO vodDictDO) { public String updateVod(VodDictDO vodDictDO) {
this.baseMapper.updateById(vodDictDO); this.baseMapper.updateById(vodDictDO);
return ConstantUtils.SET_SUCCESS; return ConstantUtils.SET_SUCCESS;
......
...@@ -5,6 +5,7 @@ import com.subsidy.mapper.VodPlayHistoryMapper; ...@@ -5,6 +5,7 @@ import com.subsidy.mapper.VodPlayHistoryMapper;
import com.subsidy.service.VodPlayHistoryService; import com.subsidy.service.VodPlayHistoryService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.subsidy.util.ConstantUtils; import com.subsidy.util.ConstantUtils;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
/** /**
...@@ -18,12 +19,16 @@ import org.springframework.stereotype.Service; ...@@ -18,12 +19,16 @@ import org.springframework.stereotype.Service;
@Service @Service
public class VodPlayHistoryServiceImpl extends ServiceImpl<VodPlayHistoryMapper, VodPlayHistoryDO> implements VodPlayHistoryService { public class VodPlayHistoryServiceImpl extends ServiceImpl<VodPlayHistoryMapper, VodPlayHistoryDO> implements VodPlayHistoryService {
@Async
public String insertHistory(VodPlayHistoryDO vodPlayHistoryDO) { public String insertHistory(VodPlayHistoryDO vodPlayHistoryDO) {
vodPlayHistoryDO.setPlayCount(1);
this.baseMapper.insert(vodPlayHistoryDO); this.baseMapper.insert(vodPlayHistoryDO);
return ConstantUtils.ADD_SUCCESS; return ConstantUtils.ADD_SUCCESS;
} }
@Async
public String insertHistoryNew(VodPlayHistoryDO vodPlayHistoryDO){ public String insertHistoryNew(VodPlayHistoryDO vodPlayHistoryDO){
vodPlayHistoryDO.setPlayCount(1);
this.baseMapper.insert(vodPlayHistoryDO); this.baseMapper.insert(vodPlayHistoryDO);
return ConstantUtils.ADD_SUCCESS; return ConstantUtils.ADD_SUCCESS;
} }
......
...@@ -6,7 +6,12 @@ import com.baomidou.mybatisplus.core.toolkit.StringPool; ...@@ -6,7 +6,12 @@ import com.baomidou.mybatisplus.core.toolkit.StringPool;
import com.baomidou.mybatisplus.core.toolkit.StringUtils; import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.generator.AutoGenerator; import com.baomidou.mybatisplus.generator.AutoGenerator;
import com.baomidou.mybatisplus.generator.InjectionConfig; import com.baomidou.mybatisplus.generator.InjectionConfig;
import com.baomidou.mybatisplus.generator.config.*; import com.baomidou.mybatisplus.generator.config.DataSourceConfig;
import com.baomidou.mybatisplus.generator.config.FileOutConfig;
import com.baomidou.mybatisplus.generator.config.GlobalConfig;
import com.baomidou.mybatisplus.generator.config.PackageConfig;
import com.baomidou.mybatisplus.generator.config.StrategyConfig;
import com.baomidou.mybatisplus.generator.config.TemplateConfig;
import com.baomidou.mybatisplus.generator.config.po.TableInfo; import com.baomidou.mybatisplus.generator.config.po.TableInfo;
import com.baomidou.mybatisplus.generator.config.rules.NamingStrategy; import com.baomidou.mybatisplus.generator.config.rules.NamingStrategy;
import com.baomidou.mybatisplus.generator.engine.FreemarkerTemplateEngine; import com.baomidou.mybatisplus.generator.engine.FreemarkerTemplateEngine;
......
package com.subsidy.util;
import org.scilab.forge.jlatexmath.TeXConstants;
import org.scilab.forge.jlatexmath.TeXFormula;
import org.scilab.forge.jlatexmath.TeXIcon;
import javax.imageio.ImageIO;
import javax.swing.*;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.*;
/**
* @author: tuyp
* @create: 2020-08-08 21:19
*/
public class LatexUtils {
/**
* @Description: 将base64编码字符串转换为图片
* @Author:
* @CreateTime:
* @param imgStr
* base64编码字符串
* @param path
* 图片路径-具体到文件
* @return
*/
public static boolean generateImage(String imgStr, String path) {
if (imgStr == null) {
return false;
}
// BASE64Decoder decoder = new BASE64Decoder();
try {
// byte[] b = decoder.decodeBuffer(imgStr);
// for (int i = 0; i < b.length; i++) {
// if (b[i] < 0) {
// b[i] += 256;
// }
// }
// OutputStream out = new FileOutputStream(path);
// out.write(b);
// out.flush();
// out.close();
return true;
} catch (Exception e) {
// TODO: handle exception
return false;
}
}
/**
* @Description: 根据图片地址转换为base64编码字符串
* @Author:
* @CreateTime:
* @return
*/
// public static String getImageStr(String imgFile) {
// InputStream inputStream = null;
// byte[] data = null;
// try {
// inputStream = new FileInputStream(imgFile);
// data = new byte[inputStream.available()];
// inputStream.read(data);
// inputStream.close();
// } catch (IOException e) {
// e.printStackTrace();
// }
// // 加密
// BASE64Encoder encoder = new BASE64Encoder();
// return encoder.encode(data);
// }
// latex 转 imgbase64
public static String latex2Png(String latex) {
try {
TeXFormula formula = new TeXFormula(latex);
// render the formla to an icon of the same size as the formula.
TeXIcon icon = formula.createTeXIcon(TeXConstants.STYLE_DISPLAY, 20);
// insert a border
icon.setInsets(new Insets(1, 1, 1, 1));
// now create an actual image of the rendered equation
BufferedImage image = new BufferedImage(icon.getIconWidth(), icon.getIconHeight(), BufferedImage.TYPE_BYTE_GRAY);
Graphics2D g2 = image.createGraphics();
g2.setColor(Color.white);
g2.fillRect(0, 0, icon.getIconWidth(), icon.getIconHeight());
JLabel jl = new JLabel();
jl.setForeground(new Color(0, 0, 0));
icon.paintIcon(jl, g2, 0, 0);
// at this point the image is created, you could also save it with ImageIO
// saveImage(image, "png", "F:\\b.png");
// ImageIO.write(image, "png", new File("F:\\c.png"));
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
try {
ImageIO.write(image, "png", outputStream);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
return null;
}
byte[] buffer = outputStream.toByteArray();
// BASE64Encoder encoder = new BASE64Encoder();
return ("data:image/png;base64,");
} catch (Exception e) {
// e.printStackTrace();
// ExceptionUtil.log(log, e);
System.err.println("公式解析有误:\n" + latex);
// e.printStackTrace();
return null;
}
}
public static void main(String[] args) {
String str = latex2Png("\\(\\sqrt[3]{2+x}\\)");
System.out.println(str);
// String omml =Latex_Word.latexToWord(str);
// System.out.println(omml);
}
}
package com.subsidy.util;
import lombok.Data;
import java.util.Date;
@Data
public class Student {
private String name;
private int age;
private Date birthday;
private float height;
private double weight;
private boolean sex;
}
package com.subsidy.util;
import org.apache.poi.hssf.usermodel.HSSFCellStyle;
import org.apache.poi.hssf.usermodel.HSSFFont;
import org.apache.poi.hssf.util.CellRangeAddress;
import org.apache.poi.ss.usermodel.CellStyle;
import org.apache.poi.ss.usermodel.Font;
import org.apache.poi.xssf.streaming.SXSSFCell;
import org.apache.poi.xssf.streaming.SXSSFRow;
import org.apache.poi.xssf.streaming.SXSSFSheet;
import org.apache.poi.xssf.streaming.SXSSFWorkbook;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;
import java.io.*;
import java.nio.charset.StandardCharsets;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;
public class ZipTestUtils {
/*
原链接:https://blog.csdn.net/houxuehan/article/details/89189820
*/
public static String NO_DEFINE = "no_define";//未定义的字段
public static String DEFAULT_DATE_PATTERN = "yyyy年MM月dd日";//默认日期格式
public static int DEFAULT_COLOUMN_WIDTH = 17;
/**
* 导出Excel 2007 OOXML (.xlsx)格式
*
* @param title 标题行
* @param headList 属性-列头
* @param students 数据集
* @param datePattern 日期格式,传null值则默认 年月日
* @param colWidth 列宽 默认 至少17个字节
* @param out 输出流
*/
public static void exportExcelX(String title, List<String> headList, List<Student> students, String datePattern, int colWidth, OutputStream out) {
if (datePattern == null) {
datePattern = DEFAULT_DATE_PATTERN;
}
// 声明一个工作薄
SXSSFWorkbook workbook = new SXSSFWorkbook(1000);//缓存
workbook.setCompressTempFiles(true);
//表头样式
CellStyle titleStyle = workbook.createCellStyle();
titleStyle.setAlignment(HSSFCellStyle.ALIGN_CENTER);
Font titleFont = workbook.createFont();
titleFont.setFontHeightInPoints((short) 20);
titleFont.setBoldweight((short) 700);
titleStyle.setFont(titleFont);
// 列头样式
CellStyle headerStyle = workbook.createCellStyle();
headerStyle.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND);
headerStyle.setBorderBottom(HSSFCellStyle.BORDER_THIN);
headerStyle.setBorderLeft(HSSFCellStyle.BORDER_THIN);
headerStyle.setBorderRight(HSSFCellStyle.BORDER_THIN);
headerStyle.setBorderTop(HSSFCellStyle.BORDER_THIN);
headerStyle.setAlignment(HSSFCellStyle.ALIGN_CENTER);
Font headerFont = workbook.createFont();
headerFont.setFontHeightInPoints((short) 12);
headerFont.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
headerStyle.setFont(headerFont);
// 单元格样式
CellStyle cellStyle = workbook.createCellStyle();
cellStyle.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND);
cellStyle.setBorderBottom(HSSFCellStyle.BORDER_THIN);
cellStyle.setBorderLeft(HSSFCellStyle.BORDER_THIN);
cellStyle.setBorderRight(HSSFCellStyle.BORDER_THIN);
cellStyle.setBorderTop(HSSFCellStyle.BORDER_THIN);
cellStyle.setAlignment(HSSFCellStyle.ALIGN_CENTER);
cellStyle.setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER);
Font cellFont = workbook.createFont();
cellFont.setBoldweight(HSSFFont.BOLDWEIGHT_NORMAL);
cellStyle.setFont(cellFont);
// 生成一个(带标题)表格
SXSSFSheet sheet = workbook.createSheet();
//设置列宽
int minBytes = colWidth < DEFAULT_COLOUMN_WIDTH ? DEFAULT_COLOUMN_WIDTH : colWidth;//至少字节数
int[] arrColWidth = new int[headList.size()];
// 产生表格标题行,以及设置列宽
String[] properties = new String[headList.size()];
String[] headers = new String[headList.size()];
int ii = 0;
for (int i = 0 ;i < headList.size(); i++) {
//properties[ii] = fieldName;
headers[ii] = headList.get(i);
int bytes = headList.get(i).getBytes().length;
arrColWidth[ii] = bytes < minBytes ? minBytes : bytes;
sheet.setColumnWidth(ii, arrColWidth[ii] * 256);
ii++;
}
// 遍历集合数据,产生数据行
int rowIndex = 0;
for (Student student : students) {
if (rowIndex == 65535 || rowIndex == 0) {
if (rowIndex != 0) {
sheet = workbook.createSheet();//如果数据超过了,则在第二页显示
}
SXSSFRow titleRow = sheet.createRow(0);//表头 rowIndex=0
titleRow.createCell(0).setCellValue(title);
titleRow.getCell(0).setCellStyle(titleStyle);
sheet.addMergedRegion(new CellRangeAddress(0, 0, 0, headList.size() - 1));
SXSSFRow headerRow = sheet.createRow(1); //列头 rowIndex =1
for (int i = 0; i < headers.length; i++) {
headerRow.createCell(i).setCellValue(headers[i]);
headerRow.getCell(i).setCellStyle(headerStyle);
}
rowIndex = 2;//数据内容从 rowIndex=2开始
}
SXSSFRow dataRow = sheet.createRow(rowIndex);
SXSSFCell newCell = dataRow.createCell(0);
newCell.setCellStyle(cellStyle);
newCell.setCellValue(student.getName());
newCell = dataRow.createCell(1);
//newCell.setCellStyle(cellStyle);
newCell.setCellValue(student.getAge());
newCell = dataRow.createCell(2);
newCell.setCellValue(new SimpleDateFormat(datePattern).format(student.getBirthday()));
newCell = dataRow.createCell(3);
newCell.setCellValue(student.getHeight());
newCell = dataRow.createCell(4);
newCell.setCellValue(student.getWeight());
newCell = dataRow.createCell(5);
newCell.setCellValue(student.isSex());
//
//for (int i = 0; i < properties.length; i++) {
//
// Object o = jo.get(properties[i]);
// String cellValue = "";
// if (o == null) {
// cellValue = "";
// } else if (o instanceof Date) {
// cellValue = new SimpleDateFormat(datePattern).format(o);
// }
// /*else if(o instanceof Float || o instanceof Double) {
// double d = (double) o;
// if(d%1==0) cellValue=o.toString();
// else cellValue= new BigDecimal(o.toString()).setScale(2,BigDecimal.ROUND_HALF_UP).toString();
// }*/
// else {
// cellValue = o.toString();
// }
// newCell.setCellValue(cellValue);
// newCell.setCellStyle(cellStyle);
//}
rowIndex++;
}
// 自动调整宽度
/*for (int i = 0; i < headers.length; i++) {
sheet.autoSizeColumn(i);
}*/
try {
workbook.write(out);
workbook.close();
workbook.dispose();
} catch (IOException e) {
e.printStackTrace();
}
}
/**
* 压缩单个excel文件的输出流 到zip输出流,注意zipOutputStream未关闭,需要交由调用者关闭之
*
* @param zipOutputStream zip文件的输出流
* @param excelOutputStream excel文件的输出流
* @param excelFilename 文件名可以带目录,例如 TestDir/test1.xlsx
*/
public static void compressFileToZipStream(ZipOutputStream zipOutputStream,
ByteArrayOutputStream excelOutputStream, String excelFilename) {
byte[] buf = new byte[1024];
try {
// Compress the files
byte[] content = excelOutputStream.toByteArray();
ByteArrayInputStream is = new ByteArrayInputStream(content);
BufferedInputStream bis = new BufferedInputStream(is);
// Add ZIP entry to output stream.
zipOutputStream.putNextEntry(new ZipEntry(excelFilename));
// Transfer bytes from the file to the ZIP file
int len;
while ((len = bis.read(buf)) > 0) {
zipOutputStream.write(buf, 0, len);
}
// Complete the entry
//excelOutputStream.close();//关闭excel输出流
zipOutputStream.closeEntry();
bis.close();
is.close();
// Complete the ZIP file
} catch (IOException e) {
e.printStackTrace();
}
}
public static void main(String[] args) throws IOException {
int count = 100;
List<Student> list = new ArrayList<>();
for (int i = 0; i < count; i++) {
Student s = new Student();
s.setName("POI" + i);
s.setAge(i);
s.setBirthday(new Date());
s.setHeight(i);
s.setWeight(i);
s.setSex(i / 2 != 0);
list.add(s);
}
//Map<String, String> headMap = new LinkedHashMap<String, String>();
//headMap.put("name", "姓名");
//headMap.put("age", "年龄");
//headMap.put("birthday", "生日");
//headMap.put("height", "身高");
//headMap.put("weight", "体重");
//headMap.put("sex", "性别");
List<String> memberList = Arrays.asList("成员名称","账号","联系方式","签到次数","课程进度","培训时长","评级测试","答疑");
//导出zip
OutputStream outXlsx = new FileOutputStream("E://test.zip");
ZipOutputStream zipOutputStream = new ZipOutputStream(outXlsx);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
exportExcelX("testExcel", memberList, list, null, 0, baos);
compressFileToZipStream(zipOutputStream, baos, "/test/aaa.xlsx");
baos.close();
zipOutputStream.flush();
zipOutputStream.close();
outXlsx.close();
System.out.println("导出zip完成");
}
public void exportZip(HttpServletResponse response, List<Student> students) throws Exception {
ServletOutputStream sos = response.getOutputStream();
ZipOutputStream zipOutputStream = new ZipOutputStream(sos);
String zipname = "test.zip";
response.reset();
response.setContentType("application/x-download");
response.setHeader("Content-Disposition", "attachment;filename=" + new String((zipname).getBytes(), StandardCharsets.ISO_8859_1));
ByteArrayOutputStream baos = new ByteArrayOutputStream();
/**
* 班级成员
*/
List<String> memberList = Arrays.asList("成员名称","账号","联系方式","签到次数","课程进度","培训时长","评级测试","答疑");
/**
* 注册签到
*/
List<String> signList = Arrays.asList("成员名称","培训时长","课程进度","完成率");
/**
* 测试成绩
*/
List<String> scoreList = Arrays.asList("成员名称","测试结果","最高分");
/**
* 答疑记录
*/
List<String> answerList = Arrays.asList("提问","答疑","提问时间","提问成员","答疑时间");
//Map<String, String> headMap = new LinkedHashMap<String, String>();
//headMap.put("name", "成员名称");
//headMap.put("age", "年龄");
//headMap.put("birthday", "生日");
//headMap.put("height", "身高");
//headMap.put("weight", "体重");
//headMap.put("sex", "性别");
exportExcelX("title", memberList, students, null, 0, baos);
compressFileToZipStream(zipOutputStream, baos, "/test/aaa.xlsx");
baos.close();
zipOutputStream.flush();
zipOutputStream.close();
sos.close();
System.out.println("导出zip完成");
}
}
package com.subsidy.util;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import org.apache.poi.hssf.usermodel.HSSFCellStyle;
import org.apache.poi.hssf.usermodel.HSSFFont;
import org.apache.poi.hssf.util.CellRangeAddress;
import org.apache.poi.ss.usermodel.CellStyle;
import org.apache.poi.ss.usermodel.Font;
import org.apache.poi.xssf.streaming.SXSSFCell;
import org.apache.poi.xssf.streaming.SXSSFRow;
import org.apache.poi.xssf.streaming.SXSSFSheet;
import org.apache.poi.xssf.streaming.SXSSFWorkbook;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;
import java.io.*;
import java.nio.charset.StandardCharsets;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;
public class ZipUtils {
/*
原链接:https://blog.csdn.net/houxuehan/article/details/89189820
*/
public static String NO_DEFINE = "no_define";//未定义的字段
public static String DEFAULT_DATE_PATTERN = "yyyy年MM月dd日";//默认日期格式
public static int DEFAULT_COLOUMN_WIDTH = 17;
/**
* 导出Excel 2007 OOXML (.xlsx)格式
*
* @param title 标题行
* @param headMap 属性-列头
* @param jsonArray 数据集
* @param datePattern 日期格式,传null值则默认 年月日
* @param colWidth 列宽 默认 至少17个字节
* @param out 输出流
*/
public static void exportExcelX(String title, Map<String, String> headMap, JSONArray jsonArray, String datePattern, int colWidth, OutputStream out) {
if (datePattern == null) {
datePattern = DEFAULT_DATE_PATTERN;
}
// 声明一个工作薄
SXSSFWorkbook workbook = new SXSSFWorkbook(1000);//缓存
workbook.setCompressTempFiles(true);
//表头样式
CellStyle titleStyle = workbook.createCellStyle();
titleStyle.setAlignment(HSSFCellStyle.ALIGN_CENTER);
Font titleFont = workbook.createFont();
titleFont.setFontHeightInPoints((short) 20);
titleFont.setBoldweight((short) 700);
titleStyle.setFont(titleFont);
// 列头样式
CellStyle headerStyle = workbook.createCellStyle();
headerStyle.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND);
headerStyle.setBorderBottom(HSSFCellStyle.BORDER_THIN);
headerStyle.setBorderLeft(HSSFCellStyle.BORDER_THIN);
headerStyle.setBorderRight(HSSFCellStyle.BORDER_THIN);
headerStyle.setBorderTop(HSSFCellStyle.BORDER_THIN);
headerStyle.setAlignment(HSSFCellStyle.ALIGN_CENTER);
Font headerFont = workbook.createFont();
headerFont.setFontHeightInPoints((short) 12);
headerFont.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
headerStyle.setFont(headerFont);
// 单元格样式
CellStyle cellStyle = workbook.createCellStyle();
cellStyle.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND);
cellStyle.setBorderBottom(HSSFCellStyle.BORDER_THIN);
cellStyle.setBorderLeft(HSSFCellStyle.BORDER_THIN);
cellStyle.setBorderRight(HSSFCellStyle.BORDER_THIN);
cellStyle.setBorderTop(HSSFCellStyle.BORDER_THIN);
cellStyle.setAlignment(HSSFCellStyle.ALIGN_CENTER);
cellStyle.setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER);
Font cellFont = workbook.createFont();
cellFont.setBoldweight(HSSFFont.BOLDWEIGHT_NORMAL);
cellStyle.setFont(cellFont);
// 生成一个(带标题)表格
SXSSFSheet sheet = workbook.createSheet();
//设置列宽
int minBytes = colWidth < DEFAULT_COLOUMN_WIDTH ? DEFAULT_COLOUMN_WIDTH : colWidth;//至少字节数
int[] arrColWidth = new int[headMap.size()];
// 产生表格标题行,以及设置列宽
String[] properties = new String[headMap.size()];
String[] headers = new String[headMap.size()];
int ii = 0;
for (Iterator<String> iter = headMap.keySet().iterator(); iter
.hasNext(); ) {
String fieldName = iter.next();
properties[ii] = fieldName;
headers[ii] = headMap.get(fieldName);
int bytes = fieldName.getBytes().length;
arrColWidth[ii] = bytes < minBytes ? minBytes : bytes;
sheet.setColumnWidth(ii, arrColWidth[ii] * 256);
ii++;
}
// 遍历集合数据,产生数据行
int rowIndex = 0;
for (Object obj : jsonArray) {
if (rowIndex == 65535 || rowIndex == 0) {
if (rowIndex != 0) {
sheet = workbook.createSheet();//如果数据超过了,则在第二页显示
}
SXSSFRow titleRow = sheet.createRow(0);//表头 rowIndex=0
titleRow.createCell(0).setCellValue(title);
titleRow.getCell(0).setCellStyle(titleStyle);
sheet.addMergedRegion(new CellRangeAddress(0, 0, 0, headMap.size() - 1));
SXSSFRow headerRow = sheet.createRow(1); //列头 rowIndex =1
for (int i = 0; i < headers.length; i++) {
headerRow.createCell(i).setCellValue(headers[i]);
headerRow.getCell(i).setCellStyle(headerStyle);
}
rowIndex = 2;//数据内容从 rowIndex=2开始
}
JSONObject jo = (JSONObject) JSONObject.toJSON(obj);
SXSSFRow dataRow = sheet.createRow(rowIndex);
for (int i = 0; i < properties.length; i++) {
SXSSFCell newCell = dataRow.createCell(i);
Object o = jo.get(properties[i]);
String cellValue = "";
if (o == null) {
cellValue = "";
} else if (o instanceof Date) {
cellValue = new SimpleDateFormat(datePattern).format(o);
}
/*else if(o instanceof Float || o instanceof Double) {
double d = (double) o;
if(d%1==0) cellValue=o.toString();
else cellValue= new BigDecimal(o.toString()).setScale(2,BigDecimal.ROUND_HALF_UP).toString();
}*/
else {
cellValue = o.toString();
}
newCell.setCellValue(cellValue);
newCell.setCellStyle(cellStyle);
}
rowIndex++;
}
// 自动调整宽度
/*for (int i = 0; i < headers.length; i++) {
sheet.autoSizeColumn(i);
}*/
try {
workbook.write(out);
workbook.close();
workbook.dispose();
} catch (IOException e) {
e.printStackTrace();
}
}
/**
* 压缩单个excel文件的输出流 到zip输出流,注意zipOutputStream未关闭,需要交由调用者关闭之
*
* @param zipOutputStream zip文件的输出流
* @param excelOutputStream excel文件的输出流
* @param excelFilename 文件名可以带目录,例如 TestDir/test1.xlsx
*/
public static void compressFileToZipStream(ZipOutputStream zipOutputStream,
ByteArrayOutputStream excelOutputStream, String excelFilename) {
byte[] buf = new byte[1024];
try {
// Compress the files
byte[] content = excelOutputStream.toByteArray();
ByteArrayInputStream is = new ByteArrayInputStream(content);
BufferedInputStream bis = new BufferedInputStream(is);
// Add ZIP entry to output stream.
zipOutputStream.putNextEntry(new ZipEntry(excelFilename));
// Transfer bytes from the file to the ZIP file
int len;
while ((len = bis.read(buf)) > 0) {
zipOutputStream.write(buf, 0, len);
}
// Complete the entry
//excelOutputStream.close();//关闭excel输出流
zipOutputStream.closeEntry();
bis.close();
is.close();
// Complete the ZIP file
} catch (IOException e) {
e.printStackTrace();
}
}
public static void main(String[] args) throws IOException {
int count = 100;
JSONArray ja = new JSONArray();
for (int i = 0; i < count; i++) {
Student s = new Student();
s.setName("POI" + i);
s.setAge(i);
s.setBirthday(new Date());
s.setHeight(i);
s.setWeight(i);
s.setSex(i / 2 != 0);
ja.add(s);
}
Map<String, String> headMap = new LinkedHashMap<String, String>();
headMap.put("name", "姓名");
headMap.put("age", "年龄");
headMap.put("birthday", "生日");
headMap.put("height", "身高");
headMap.put("weight", "体重");
headMap.put("sex", "性别");
//导出zip
OutputStream outXlsx = new FileOutputStream("E://test.zip");
ZipOutputStream zipOutputStream = new ZipOutputStream(outXlsx);
for (int i = 1; i < 6; i++) {
String dir = i % 2 == 0 ? "dirA" : "dirB";
ByteArrayOutputStream baos = new ByteArrayOutputStream();
exportExcelX("testExcel", headMap, ja, null, 0, baos);
compressFileToZipStream(zipOutputStream, baos, dir + "/test" + i + ".xlsx");
baos.close();
}
zipOutputStream.flush();
zipOutputStream.close();
outXlsx.close();
System.out.println("导出zip完成");
}
public void exportZip(HttpServletResponse response) throws Exception {
ServletOutputStream sos = response.getOutputStream();
ZipOutputStream zipOutputStream = new ZipOutputStream(sos);
String zipname = "test.zip";
response.reset();
response.setContentType("application/x-download");
response.setHeader("Content-Disposition", "attachment;filename=" + new
String((zipname).
getBytes(), StandardCharsets.ISO_8859_1));
for (int i = 1; i < 6; i++) {
String dir = i % 2 == 0 ? "dirA" : "dirB";
ByteArrayOutputStream baos = new ByteArrayOutputStream();
//exportExcelX(title, headMap, ja, null, 0, baos);
compressFileToZipStream(zipOutputStream, baos, dir + "/test" + i + ".xlsx");
baos.close();
}
zipOutputStream.flush();
zipOutputStream.close();
sos.close();
System.out.println("导出zip完成");
}
}
package com.subsidy.util.excel; package com.subsidy.util.excel;
import java.lang.annotation.*;
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@Target(ElementType.FIELD) @Target(ElementType.FIELD)
@Retention(RetentionPolicy.RUNTIME) @Retention(RetentionPolicy.RUNTIME)
......
package com.subsidy.util.excel; package com.subsidy.util.excel;
import java.lang.annotation.*;
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/** /**
* <p> * <p>
......
...@@ -14,7 +14,14 @@ import org.apache.poi.hssf.usermodel.HSSFDateUtil; ...@@ -14,7 +14,14 @@ import org.apache.poi.hssf.usermodel.HSSFDateUtil;
import org.apache.poi.hssf.usermodel.HSSFFont; import org.apache.poi.hssf.usermodel.HSSFFont;
import org.apache.poi.hssf.usermodel.HSSFWorkbook; import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.hssf.util.CellRangeAddress; import org.apache.poi.hssf.util.CellRangeAddress;
import org.apache.poi.ss.usermodel.*; import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.CellStyle;
import org.apache.poi.ss.usermodel.DateUtil;
import org.apache.poi.ss.usermodel.Font;
import org.apache.poi.ss.usermodel.IndexedColors;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.xssf.streaming.SXSSFCell; import org.apache.poi.xssf.streaming.SXSSFCell;
import org.apache.poi.xssf.streaming.SXSSFRow; import org.apache.poi.xssf.streaming.SXSSFRow;
import org.apache.poi.xssf.streaming.SXSSFSheet; import org.apache.poi.xssf.streaming.SXSSFSheet;
...@@ -24,18 +31,26 @@ import org.springframework.web.context.request.RequestContextHolder; ...@@ -24,18 +31,26 @@ import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes; import org.springframework.web.context.request.ServletRequestAttributes;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.io.*; import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.lang.reflect.Constructor; import java.lang.reflect.Constructor;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.net.URLEncoder; import java.net.URLEncoder;
import java.util.*; import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicInteger;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import java.util.stream.Stream; import java.util.stream.Stream;
import java.util.zip.ZipOutputStream;
/** /**
* Excel工具 * Excel工具
......
...@@ -28,7 +28,7 @@ public class ClassDetailVO{ ...@@ -28,7 +28,7 @@ public class ClassDetailVO{
* 签到次数 * 签到次数
*/ */
@ExcelColumn(col = 5,value = "签到次数") @ExcelColumn(col = 5,value = "签到次数")
private Integer signCounts; private Long signCounts;
/** /**
* 已看视频 * 已看视频
......
# 本地环境配置 # 本地环境配置
# 数据源配置 # 数据源配置
spring.datasource.url=jdbc:mysql://47.97.19.66:3306/subsidy?autoReconnect=true&useUnicode=true&characterEncoding=utf8&serverTimezone=GMT%2B8 #spring.datasource.url=jdbc:mysql://47.97.19.66:3306/subsidy?autoReconnect=true&useUnicode=true&characterEncoding=utf8&serverTimezone=GMT%2B8
spring.datasource.url=jdbc:mysql://rm-uf67mjh19252z6yg4eo.mysql.rds.aliyuncs.com:3306/subsidy?autoReconnect=true&useUnicode=true&characterEncoding=utf8&serverTimezone=GMT%2B8
spring.datasource.type=com.alibaba.druid.pool.DruidDataSource spring.datasource.type=com.alibaba.druid.pool.DruidDataSource
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
#spring.datasource.username=ykadmin_new #spring.datasource.username=ykadmin_new
...@@ -26,9 +27,9 @@ spring.datasource.druid.useGlobalDataSourceStat=true ...@@ -26,9 +27,9 @@ spring.datasource.druid.useGlobalDataSourceStat=true
# 控制台日志打印 # 控制台日志打印
mybatis-plus.configuration.log-impl=org.apache.ibatis.logging.stdout.StdOutImpl mybatis-plus.configuration.log-impl=org.apache.ibatis.logging.stdout.StdOutImpl
spring.redis.host=47.97.19.66 spring.redis.host=r-uf6thsc3bzt5b6f7fdpd.redis.rds.aliyuncs.com
spring.redis.password=Ykhl@208 spring.redis.password=r-uf6thsc3bzt5b6f7fd:Ykhl@208
spring.redis.port=6389 spring.redis.port=6379
spring.redis.lettuce.pool.max-idle=16 spring.redis.lettuce.pool.max-idle=16
spring.redis.lettuce.pool.max-active=32 spring.redis.lettuce.pool.max-active=32
spring.redis.lettuce.pool.min-idle=8 spring.redis.lettuce.pool.min-idle=8
\ No newline at end of file
# 环境配置 # 环境配置
spring.profiles.active=dev spring.profiles.active=dev
# 端口号 # 端口号
spring.server.port=23454 spring.server.port=23457
#嵌入tomcat配置 #嵌入tomcat配置
#和CPU数 #和CPU数
spring.server.acceptorThreadCount=200 spring.server.acceptorThreadCount=200
...@@ -53,17 +53,26 @@ vod.region=ap-shanghai ...@@ -53,17 +53,26 @@ vod.region=ap-shanghai
vod.classId=848920 vod.classId=848920
# quartz # quartz
# 数据持久化方式 # 数据持久化方式
spring.quartz.job-store-type=jdbc #spring.quartz.job-store-type=jdbc
# 初始化后是否自动启动计划程序 ## 初始化后是否自动启动计划程序
spring.quartz.auto-startup=true #spring.quartz.auto-startup=true
# 初始化完成后启动计划程序的延迟时间 ## 初始化完成后启动计划程序的延迟时间
spring.quartz.startup-delay=10s #spring.quartz.startup-delay=10s
# 配置的作业是否应覆盖现有的作业定义 ## 配置的作业是否应覆盖现有的作业定义
spring.quartz.overwrite-existing-jobs=false #spring.quartz.overwrite-existing-jobs=false
# 自动建表,如果已经存在表请勿使用,会覆盖数据表 # 自动建表,如果已经存在表请勿使用,会覆盖数据表
#spring.quartz.jdbc.initialize-schema=always #spring.quartz.jdbc.initialize-schema=always
#spring.datasource.initialization-mode=embedded #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.cluster.nodes=47.97.19.66:6377,47.97.19.66:6378,47.97.19.66:6379
##spring.redis.port=6379 ##spring.redis.port=6379
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender"> <appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
<filter class="ch.qos.logback.classic.filter.ThresholdFilter"> <filter class="ch.qos.logback.classic.filter.ThresholdFilter">
<level>debug</level> <level>info</level>
</filter> </filter>
<encoder> <encoder>
<pattern>%d [%t] %5p %c:%L - %m%n</pattern> <pattern>%d [%t] %5p %c:%L - %m%n</pattern>
...@@ -47,7 +47,7 @@ ...@@ -47,7 +47,7 @@
</appender> </appender>
<springProfile name="dev"> <springProfile name="dev">
<logger name="com.juequn" level="error" /> <logger name="com.subsidy" level="error" />
<root level="INFO"> <root level="INFO">
<appender-ref ref="CONSOLE" /> <appender-ref ref="CONSOLE" />
<appender-ref ref="INFO_FILE" /> <appender-ref ref="INFO_FILE" />
...@@ -56,14 +56,14 @@ ...@@ -56,14 +56,14 @@
</springProfile> </springProfile>
<springProfile name="pre"> <springProfile name="pre">
<logger name="com.juequn" level="error" /> <logger name="com.subsidy" level="error" />
<root level="INFO"> <root level="INFO">
<appender-ref ref="ERROR_FILE" /> <appender-ref ref="ERROR_FILE" />
</root> </root>
</springProfile> </springProfile>
<springProfile name="prod"> <springProfile name="prod">
<logger name="com.juequn" level="error" /> <logger name="com.subsidy" level="error" />
<root level="INFO"> <root level="INFO">
<appender-ref ref="ERROR_FILE" /> <appender-ref ref="ERROR_FILE" />
</root> </root>
......
...@@ -20,22 +20,4 @@ ...@@ -20,22 +20,4 @@
id, class_hour, status id, class_hour, status
</sql> </sql>
<select id="getClassHourDictInfo" parameterType="long" resultType="com.subsidy.model.ClassHourDictDO">
SELECT
class_hour,
interrupt,
repeat_time,
STATUS,
interrupt_status,
repeat_status
FROM
class_dict t
LEFT JOIN class_hour_dict t2 ON t.company_id = t2.id
WHERE
t.delete_date IS NULL
AND t2.delete_date IS NULL
AND t.id = #{classId}
AND t2.repeat_status = 1
</select>
</mapper> </mapper>
...@@ -59,4 +59,17 @@ ...@@ -59,4 +59,17 @@
</if> </if>
</select> </select>
<select id="getMemberClassCount" parameterType="long" resultType="long">
SELECT
count(1)
FROM
class_member_mapping t
LEFT JOIN class_dict t2 ON t.class_id = t2.id
WHERE
t.delete_date IS NULL
AND t2.delete_date IS NULL
and t2.end_date >=DATE_FORMAT(now(), '%Y-%m-%d')
and t.member_id = #{memberId}
</select>
</mapper> </mapper>
...@@ -55,6 +55,7 @@ ...@@ -55,6 +55,7 @@
WHERE WHERE
t.delete_date IS NULL t.delete_date IS NULL
AND t2.delete_date IS NULL AND t2.delete_date IS NULL
and t3.delete_date is null
AND t.member_id = #{id} AND t.member_id = #{id}
</select> </select>
......
...@@ -102,4 +102,15 @@ ...@@ -102,4 +102,15 @@
AND a.vod_id = b.vod_id AND a.vod_id = b.vod_id
</select> </select>
<select id="memberDailyStudyLength" parameterType="long" resultType="integer">
SELECT
ifnull( sum( t.play_length ), 0 )
FROM
vod_play_history t
WHERE
t.delete_date IS NULL
AND DATE_FORMAT( t.create_date, '%Y-%m-%d' ) = DATE_FORMAT( now(), '%Y-%m-%d' )
AND t.member_id = #{memberId}
</select>
</mapper> </mapper>
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!