mirror of
https://codeup.aliyun.com/67762337eccfc218f6110e0e/per-boe/java-servers.git
synced 2025-12-10 19:36:50 +08:00
Compare commits
6 Commits
zcwy0912-l
...
zcwy0815-l
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
29a17efd44 | ||
|
|
903a1369f5 | ||
|
|
0fcd4568ec | ||
|
|
616594af9e | ||
|
|
4ff47085b8 | ||
|
|
b7e8c43b5f |
@@ -84,7 +84,6 @@
|
|||||||
<artifactId>xboe-module-es</artifactId>
|
<artifactId>xboe-module-es</artifactId>
|
||||||
<version>1.0.0</version>
|
<version>1.0.0</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>it.sauronsoftware</groupId>
|
<groupId>it.sauronsoftware</groupId>
|
||||||
<artifactId>jave</artifactId>
|
<artifactId>jave</artifactId>
|
||||||
|
|||||||
@@ -133,4 +133,6 @@ public interface CacheName {
|
|||||||
* 字典缓存key
|
* 字典缓存key
|
||||||
* */
|
* */
|
||||||
String KEY_DICT="dict";
|
String KEY_DICT="dict";
|
||||||
|
|
||||||
|
String STUDY_KEY = "StudyKey:";
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,7 +9,6 @@ import javax.servlet.http.Cookie;
|
|||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
@@ -29,7 +28,6 @@ import com.xboe.module.course.service.ICourseFileService;
|
|||||||
*/
|
*/
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping(value = "/xboe/m/course/cware")
|
@RequestMapping(value = "/xboe/m/course/cware")
|
||||||
@Slf4j
|
|
||||||
public class CourseWareApi extends ApiBaseController {
|
public class CourseWareApi extends ApiBaseController {
|
||||||
|
|
||||||
private String cookieName = "PLAYSIGN_TIME";
|
private String cookieName = "PLAYSIGN_TIME";
|
||||||
@@ -133,8 +131,6 @@ public class CourseWareApi extends ApiBaseController {
|
|||||||
// 第一个/前端是时间
|
// 第一个/前端是时间
|
||||||
int index = signStr.indexOf("/");
|
int index = signStr.indexOf("/");
|
||||||
if (index <= 0) {
|
if (index <= 0) {
|
||||||
log.info("解密后的字符串:"+signStr);
|
|
||||||
log.info("解密后的字符串的时间拼接:"+index);
|
|
||||||
return badRequest("验证错误");
|
return badRequest("验证错误");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -142,13 +138,9 @@ public class CourseWareApi extends ApiBaseController {
|
|||||||
String cfid = signStr.substring(index+1);// 文件路径
|
String cfid = signStr.substring(index+1);// 文件路径
|
||||||
|
|
||||||
if (!time.equals(cookieTime)) {
|
if (!time.equals(cookieTime)) {
|
||||||
log.info("请求头时间和解析后的时间对比:"+"解析时间:"+time+" 请求头时间:"+cookieTime);
|
|
||||||
log.info("解密后的字符串的时间拼接:"+signStr);
|
|
||||||
return badRequest("验证错误");
|
return badRequest("验证错误");
|
||||||
}
|
}
|
||||||
if(StringUtils.isBlank(cfid) || cfid.length()<10) {
|
if(StringUtils.isBlank(cfid) || cfid.length()<10) {
|
||||||
log.info("查看时间文件路径:"+cfid);
|
|
||||||
log.info("解密后的字符串的时间拼接:"+signStr);
|
|
||||||
return badRequest("验证错误");
|
return badRequest("验证错误");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -166,12 +166,11 @@ public class ExamQuestionApi extends ApiBaseController {
|
|||||||
return badRequest("请上传正确的试题文件");
|
return badRequest("请上传正确的试题文件");
|
||||||
}
|
}
|
||||||
//获取表头
|
//获取表头
|
||||||
Row row ;
|
Row row = sheetAt.getRow(1);
|
||||||
//从第二行开始获取数据
|
//从第二行开始获取数据
|
||||||
List<ExamQuestion> examQuestions1 = new ArrayList<>();
|
List<ExamQuestion> examQuestions1 = new ArrayList<>();
|
||||||
QuestionDto questionDto = new QuestionDto();
|
QuestionDto questionDto = new QuestionDto();
|
||||||
if(sheetAt.getRow(1).getCell(0).getStringCellValue().equals("标题(*)") && !sheetAt.getRow(1).getCell(0).getStringCellValue().equals("")){
|
|
||||||
row = sheetAt.getRow(1);
|
|
||||||
for (int i=2;i<sheetAt.getPhysicalNumberOfRows();i++) {
|
for (int i=2;i<sheetAt.getPhysicalNumberOfRows();i++) {
|
||||||
//获取每一行
|
//获取每一行
|
||||||
|
|
||||||
@@ -190,56 +189,45 @@ public class ExamQuestionApi extends ApiBaseController {
|
|||||||
if(row1.getCell(1).getStringCellValue().equals("多选题")){
|
if(row1.getCell(1).getStringCellValue().equals("多选题")){
|
||||||
examQuestion.setType(2);
|
examQuestion.setType(2);
|
||||||
}
|
}
|
||||||
if(row1.getCell(2).getStringCellValue().equals("中")){
|
examQuestion.setKnowledge(row1.getCell(2).getStringCellValue());
|
||||||
|
if(row1.getCell(3).getStringCellValue().equals("中")){
|
||||||
examQuestion.setDifficulty(2f);
|
examQuestion.setDifficulty(2f);
|
||||||
}else if(row1.getCell(2).getStringCellValue().equals("难")){
|
|
||||||
examQuestion.setDifficulty(3f);
|
|
||||||
} else if(row1.getCell(2).getStringCellValue().equals("易")){
|
|
||||||
examQuestion.setDifficulty(1f);
|
|
||||||
}else if(row1.getCell(2).getStringCellValue().equals("")){
|
|
||||||
examQuestion.setDifficulty(null);
|
|
||||||
}
|
}
|
||||||
Cell cell = row1.getCell(3);
|
if(row1.getCell(3).getStringCellValue().equals("难")){
|
||||||
|
examQuestion.setDifficulty(3f);
|
||||||
|
}
|
||||||
|
if(row1.getCell(3).getStringCellValue().equals("低")){
|
||||||
|
examQuestion.setDifficulty(1f);
|
||||||
|
}
|
||||||
|
Cell cell = row1.getCell(4);
|
||||||
cell.setCellType(CellType.STRING);
|
cell.setCellType(CellType.STRING);
|
||||||
|
|
||||||
// examQuestion.setDefaultScore(Float.valueOf(cell.getStringCellValue()));
|
// examQuestion.setDefaultScore(Float.valueOf(cell.getStringCellValue()));
|
||||||
|
|
||||||
//单选
|
//单选
|
||||||
if (!cell.getStringCellValue().contains(",")){
|
if (!cell.getStringCellValue().contains(",")){
|
||||||
examQuestion.setAnswer(row1.getCell(5).getStringCellValue());
|
examQuestion.setAnswer(row1.getCell(6).getStringCellValue());
|
||||||
if (row1.getCell(3).getStringCellValue().isEmpty()){
|
examQuestion.setDefaultScore(Float.valueOf(row1.getCell(4).getStringCellValue()));
|
||||||
examQuestion.setDefaultScore(null);
|
Cell cell1 = row1.getCell(5, Row.MissingCellPolicy.CREATE_NULL_AS_BLANK);
|
||||||
}else {
|
|
||||||
examQuestion.setDefaultScore(Float.valueOf(row1.getCell(3).getStringCellValue()));
|
|
||||||
}
|
|
||||||
Cell cell1 = row1.getCell(4, Row.MissingCellPolicy.CREATE_NULL_AS_BLANK);
|
|
||||||
cell1.setCellType(CellType.STRING);
|
cell1.setCellType(CellType.STRING);
|
||||||
examQuestion.setAnalysis(cell1.getStringCellValue());
|
examQuestion.setAnalysis(cell1.getStringCellValue());
|
||||||
|
|
||||||
List<ExamOption> examOptions = new ArrayList<>();
|
List<ExamOption> examOptions = new ArrayList<>();
|
||||||
for (int j=6;j<=12;j++) {
|
for (int j=7;j<=13;j++) {
|
||||||
|
|
||||||
if(row1.getCell(j)!=null) {
|
if(row1.getCell(j)!=null) {
|
||||||
ExamOption examOption = new ExamOption();
|
ExamOption examOption = new ExamOption();
|
||||||
// 截取表头
|
// 截取表头
|
||||||
String substring = row.getCell(j).getStringCellValue().substring(3, 4);
|
String substring = row.getCell(j).getStringCellValue().substring(3, 4);
|
||||||
if (row1.getCell(5).getStringCellValue().contains(substring)) {
|
if (row1.getCell(6).getStringCellValue().contains(substring)) {
|
||||||
|
|
||||||
examOption.setIsAnswer(true);
|
examOption.setIsAnswer(true);
|
||||||
if (row1.getCell(3).getStringCellValue().isEmpty()){
|
examOption.setScore(Float.valueOf(row1.getCell(4).getStringCellValue()));
|
||||||
examOption.setScore(null);
|
|
||||||
}else {
|
|
||||||
examOption.setScore(Float.valueOf(row1.getCell(3).getStringCellValue()));
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
examOption.setIsAnswer(false);
|
examOption.setIsAnswer(false);
|
||||||
}
|
}
|
||||||
if (examOption.getIsAnswer()) {
|
if (examOption.getIsAnswer()) {
|
||||||
if (row1.getCell(3).getStringCellValue().isEmpty()){
|
examOption.setScore(Float.valueOf(row1.getCell(4).getStringCellValue()));
|
||||||
examOption.setScore(null);
|
|
||||||
}else {
|
|
||||||
examOption.setScore(Float.valueOf(row1.getCell(3).getStringCellValue()));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
examOption.setOptions(row.getCell(j).getStringCellValue());
|
examOption.setOptions(row.getCell(j).getStringCellValue());
|
||||||
@@ -269,19 +257,19 @@ public class ExamQuestionApi extends ApiBaseController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
examQuestion.setDefaultScore(Float.valueOf(max));
|
examQuestion.setDefaultScore(Float.valueOf(max));
|
||||||
Cell cell1 = row1.getCell(4, Row.MissingCellPolicy.CREATE_NULL_AS_BLANK);
|
Cell cell1 = row1.getCell(5, Row.MissingCellPolicy.CREATE_NULL_AS_BLANK);
|
||||||
cell1.setCellType(CellType.STRING);
|
cell1.setCellType(CellType.STRING);
|
||||||
examQuestion.setAnalysis(cell1.getStringCellValue());
|
examQuestion.setAnalysis(cell1.getStringCellValue());
|
||||||
examQuestion.setAnswer(row1.getCell(5).getStringCellValue());
|
examQuestion.setAnswer(row1.getCell(6).getStringCellValue());
|
||||||
List<ExamOption> examOptions = new ArrayList<>();
|
List<ExamOption> examOptions = new ArrayList<>();
|
||||||
//A
|
//A
|
||||||
for (int j=6;j<=12;j++){
|
for (int j=7;j<=13;j++){
|
||||||
if(row1.getCell(j)!=null && StringUtil.isNotBlank(row1.getCell(j).getStringCellValue())){
|
if(row1.getCell(j)!=null && StringUtil.isNotBlank(row1.getCell(j).getStringCellValue())){
|
||||||
ExamOption examOption=new ExamOption();
|
ExamOption examOption=new ExamOption();
|
||||||
examOption.setOptions(row.getCell(j).getStringCellValue());
|
examOption.setOptions(row.getCell(j).getStringCellValue());
|
||||||
examOption.setContent(row1.getCell(j).getStringCellValue());
|
examOption.setContent(row1.getCell(j).getStringCellValue());
|
||||||
examOption.setIsAnswer(true);
|
examOption.setIsAnswer(true);
|
||||||
examOption.setScore(Float.valueOf(strings[j-6]));
|
examOption.setScore(Float.valueOf(strings[j-7]));
|
||||||
if(examOption!=null && StringUtil.isNotBlank(examOption.getContent())){
|
if(examOption!=null && StringUtil.isNotBlank(examOption.getContent())){
|
||||||
examOptions.add(examOption);
|
examOptions.add(examOption);
|
||||||
}
|
}
|
||||||
@@ -292,134 +280,6 @@ public class ExamQuestionApi extends ApiBaseController {
|
|||||||
examQuestions1.add(examQuestion);
|
examQuestions1.add(examQuestion);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}else {
|
|
||||||
row = sheetAt.getRow(2);
|
|
||||||
for (int i = 3;i<sheetAt.getPhysicalNumberOfRows();i++) {
|
|
||||||
//获取每一行
|
|
||||||
|
|
||||||
Row row1 = sheetAt.getRow(i);
|
|
||||||
if(row1==null || row1.getCell(0)==null){
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if(StringUtil.isBlank(row1.getCell(0).getStringCellValue())){
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
ExamQuestion examQuestion = new ExamQuestion();
|
|
||||||
examQuestion.setTitle(row1.getCell(0).getStringCellValue());
|
|
||||||
if(row1.getCell(1).getStringCellValue().equals("单选题")){
|
|
||||||
examQuestion.setType(1);
|
|
||||||
}
|
|
||||||
if(row1.getCell(1).getStringCellValue().equals("多选题")){
|
|
||||||
examQuestion.setType(2);
|
|
||||||
}
|
|
||||||
log.debug("row1.getCell(2) = " + row1.getCell(2));
|
|
||||||
if (row1.getCell(2)==null ||row1.getCell(2).getStringCellValue() == null || row1.getCell(2).getStringCellValue().equals("")){
|
|
||||||
examQuestion.setDifficulty(null);
|
|
||||||
}else{
|
|
||||||
if( row1.getCell(2).getStringCellValue().equals("中")){
|
|
||||||
examQuestion.setDifficulty(2f);
|
|
||||||
}else if(row1.getCell(2).getStringCellValue().equals("难")){
|
|
||||||
examQuestion.setDifficulty(3f);
|
|
||||||
} else if(row1.getCell(2).getStringCellValue().equals("易")){
|
|
||||||
examQuestion.setDifficulty(1f);
|
|
||||||
}else if(row1.getCell(2).getStringCellValue().equals("")){
|
|
||||||
examQuestion.setDifficulty(null);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Cell cell = row1.getCell(3);
|
|
||||||
cell.setCellType(CellType.STRING);
|
|
||||||
|
|
||||||
// examQuestion.setDefaultScore(Float.valueOf(cell.getStringCellValue()));
|
|
||||||
|
|
||||||
//单选
|
|
||||||
if (!cell.getStringCellValue().contains(",")){
|
|
||||||
examQuestion.setAnswer(row1.getCell(5).getStringCellValue());
|
|
||||||
if (row1.getCell(3).getStringCellValue().isEmpty()){
|
|
||||||
examQuestion.setDefaultScore(null);
|
|
||||||
}else {
|
|
||||||
examQuestion.setDefaultScore(Float.valueOf(row1.getCell(3).getStringCellValue()));
|
|
||||||
}
|
|
||||||
Cell cell1 = row1.getCell(4, Row.MissingCellPolicy.CREATE_NULL_AS_BLANK);
|
|
||||||
cell1.setCellType(CellType.STRING);
|
|
||||||
examQuestion.setAnalysis(cell1.getStringCellValue());
|
|
||||||
|
|
||||||
List<ExamOption> examOptions = new ArrayList<>();
|
|
||||||
for (int j=6;j<=12;j++) {
|
|
||||||
|
|
||||||
if(row1.getCell(j)!=null) {
|
|
||||||
ExamOption examOption = new ExamOption();
|
|
||||||
// 截取表头
|
|
||||||
String substring = row.getCell(j).getStringCellValue().substring(3, 4);
|
|
||||||
if (row1.getCell(5).getStringCellValue().contains(substring)) {
|
|
||||||
|
|
||||||
examOption.setIsAnswer(true);
|
|
||||||
if (row1.getCell(3).getStringCellValue().isEmpty()){
|
|
||||||
examOption.setScore(null);
|
|
||||||
}else {
|
|
||||||
examOption.setScore(Float.valueOf(row1.getCell(3).getStringCellValue()));
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
examOption.setIsAnswer(false);
|
|
||||||
}
|
|
||||||
if (examOption.getIsAnswer()) {
|
|
||||||
if (row1.getCell(3).getStringCellValue().isEmpty()){
|
|
||||||
examOption.setScore(null);
|
|
||||||
}else {
|
|
||||||
examOption.setScore(Float.valueOf(row1.getCell(3).getStringCellValue()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
examOption.setOptions(row.getCell(j).getStringCellValue());
|
|
||||||
|
|
||||||
Cell cell2 = row1.getCell(j);
|
|
||||||
cell2.setCellType(CellType.STRING);
|
|
||||||
examOption.setContent(cell2.getStringCellValue());
|
|
||||||
|
|
||||||
if (examOption != null && StringUtil.isNotBlank(examOption.getContent())) {
|
|
||||||
examOptions.add(examOption);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
examQuestion.setOptionList(examOptions);
|
|
||||||
examQuestions1.add(examQuestion);
|
|
||||||
}
|
|
||||||
//多选 多选的默认分存的是最大分
|
|
||||||
else{
|
|
||||||
String stringCellValue = row1.getCell(4).getStringCellValue();
|
|
||||||
String[] strings = stringCellValue.split(",");
|
|
||||||
// String[] strings = new String[stringCellValue.length()];
|
|
||||||
String max=strings[0];
|
|
||||||
for (int j=0;j<strings.length;j++) {
|
|
||||||
if(Float.valueOf(max)<Float.valueOf(strings[j])){
|
|
||||||
max=strings[j];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
examQuestion.setDefaultScore(Float.valueOf(max));
|
|
||||||
Cell cell1 = row1.getCell(4, Row.MissingCellPolicy.CREATE_NULL_AS_BLANK);
|
|
||||||
cell1.setCellType(CellType.STRING);
|
|
||||||
examQuestion.setAnalysis(cell1.getStringCellValue());
|
|
||||||
examQuestion.setAnswer(row1.getCell(5).getStringCellValue());
|
|
||||||
List<ExamOption> examOptions = new ArrayList<>();
|
|
||||||
//A
|
|
||||||
for (int j=6;j<=13;j++){
|
|
||||||
if(row1.getCell(j)!=null && StringUtil.isNotBlank(row1.getCell(j).getStringCellValue())){
|
|
||||||
ExamOption examOption=new ExamOption();
|
|
||||||
examOption.setOptions(row.getCell(j).getStringCellValue());
|
|
||||||
examOption.setContent(row1.getCell(j).getStringCellValue());
|
|
||||||
examOption.setIsAnswer(true);
|
|
||||||
examOption.setScore(Float.valueOf(strings[j-6]));
|
|
||||||
if(examOption!=null && StringUtil.isNotBlank(examOption.getContent())){
|
|
||||||
examOptions.add(examOption);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
examQuestion.setOptionList(examOptions);
|
|
||||||
examQuestions1.add(examQuestion);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//判断题 只存在试题表中
|
//判断题 只存在试题表中
|
||||||
Sheet sheetAt1 = workbook.getSheet("判断题");
|
Sheet sheetAt1 = workbook.getSheet("判断题");
|
||||||
// questionDto.setCounts(sheetAt1.getPhysicalNumberOfRows()-2);
|
// questionDto.setCounts(sheetAt1.getPhysicalNumberOfRows()-2);
|
||||||
@@ -440,30 +300,27 @@ public class ExamQuestionApi extends ApiBaseController {
|
|||||||
ExamQuestion examQuestion1 = new ExamQuestion();
|
ExamQuestion examQuestion1 = new ExamQuestion();
|
||||||
examQuestion1.setTitle(row2.getCell(0).getStringCellValue());
|
examQuestion1.setTitle(row2.getCell(0).getStringCellValue());
|
||||||
examQuestion1.setType(3);
|
examQuestion1.setType(3);
|
||||||
System.out.println("1+++++++"+row2.getCell(1));
|
examQuestion1.setKnowledge(row2.getCell(1).getStringCellValue());
|
||||||
if(row2.getCell(1).getStringCellValue().equals("中")){
|
if(row2.getCell(2).getStringCellValue().equals("中")){
|
||||||
examQuestion1.setDifficulty(2f);
|
examQuestion1.setDifficulty(2f);
|
||||||
}else if(row2.getCell(1).getStringCellValue().equals("难")){
|
}
|
||||||
|
if(row2.getCell(2).getStringCellValue().equals("难")){
|
||||||
examQuestion1.setDifficulty(3f);
|
examQuestion1.setDifficulty(3f);
|
||||||
} else if(row2.getCell(1).getStringCellValue().equals("易")){
|
}
|
||||||
|
if(row2.getCell(2).getStringCellValue().equals("易")){
|
||||||
examQuestion1.setDifficulty(1f);
|
examQuestion1.setDifficulty(1f);
|
||||||
}else if(row2.getCell(1).getStringCellValue().equals("")){
|
|
||||||
examQuestion1.setDifficulty(null);
|
|
||||||
}
|
}
|
||||||
Cell cell1 = row2.getCell(2);
|
Cell cell1 = row2.getCell(3);
|
||||||
cell1.setCellType(CellType.STRING);
|
cell1.setCellType(CellType.STRING);
|
||||||
if (row2.getCell(2).getStringCellValue().isEmpty()){
|
examQuestion1.setDefaultScore(Float.valueOf(cell1.getStringCellValue()));
|
||||||
examQuestion1.setDefaultScore(null);
|
|
||||||
}else {
|
if(row2.getCell(4)!=null) {
|
||||||
examQuestion1.setDefaultScore(Float.valueOf(row2.getCell(2).getStringCellValue()));
|
examQuestion1.setAnalysis(row2.getCell(4).getStringCellValue());
|
||||||
}
|
|
||||||
if(row2.getCell(3)!=null) {
|
|
||||||
examQuestion1.setAnalysis(row2.getCell(3).getStringCellValue());
|
|
||||||
}else {
|
}else {
|
||||||
examQuestion1.setAnalysis("");
|
examQuestion1.setAnalysis("");
|
||||||
}
|
}
|
||||||
|
|
||||||
String cvalue=row2.getCell(4).getStringCellValue();
|
String cvalue=row2.getCell(5).getStringCellValue();
|
||||||
examQuestion1.setAnswer(cvalue.equals("正确")? "true":"false");
|
examQuestion1.setAnswer(cvalue.equals("正确")? "true":"false");
|
||||||
if(examQuestion1!=null){
|
if(examQuestion1!=null){
|
||||||
examQuestions2.add(examQuestion1);
|
examQuestions2.add(examQuestion1);
|
||||||
|
|||||||
@@ -3,16 +3,12 @@ package com.xboe.school.study.api;
|
|||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
import cn.hutool.core.util.ArrayUtil;
|
import com.alibaba.nacos.shaded.com.google.common.util.concurrent.RateLimiter;
|
||||||
import com.xboe.api.ThirdApi;
|
import com.xboe.api.ThirdApi;
|
||||||
import com.xboe.api.vo.*;
|
import com.xboe.constants.CacheName;
|
||||||
import com.xboe.module.course.vo.TeacherVo;
|
import com.xboe.module.course.vo.TeacherVo;
|
||||||
import com.xboe.module.usergroup.entity.UserGroupItem;
|
|
||||||
import com.xboe.module.usergroup.service.IUserGroupService;
|
import com.xboe.module.usergroup.service.IUserGroupService;
|
||||||
import com.xboe.school.study.dao.StudyCourseDao;
|
|
||||||
import org.apache.commons.lang3.ArrayUtils;
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.data.redis.core.StringRedisTemplate;
|
import org.springframework.data.redis.core.StringRedisTemplate;
|
||||||
@@ -67,8 +63,6 @@ import javax.servlet.http.HttpServletRequest;
|
|||||||
@RequestMapping(value="/xboe/school/study/course")
|
@RequestMapping(value="/xboe/school/study/course")
|
||||||
public class StudyCourseApi extends ApiBaseController{
|
public class StudyCourseApi extends ApiBaseController{
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
IStudyCourseService service;
|
IStudyCourseService service;
|
||||||
|
|
||||||
@@ -98,7 +92,6 @@ public class StudyCourseApi extends ApiBaseController{
|
|||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
StringRedisTemplate redisTemplate;
|
StringRedisTemplate redisTemplate;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 用于查询课程的学习记录
|
* 用于查询课程的学习记录
|
||||||
* @param pager
|
* @param pager
|
||||||
@@ -290,11 +283,7 @@ public class StudyCourseApi extends ApiBaseController{
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 记录学习信息,在学习每个资源时都要记录.前端用户打开课程资源按规则调用带着课程及学习信息调用此接口。
|
|
||||||
* @param
|
|
||||||
* @return 返回学习条目的id
|
|
||||||
*/
|
|
||||||
@PostMapping("/study")
|
@PostMapping("/study")
|
||||||
public JsonResponse<String> study(@RequestBody StudyContentDto sci, HttpServletRequest request){
|
public JsonResponse<String> study(@RequestBody StudyContentDto sci, HttpServletRequest request){
|
||||||
|
|
||||||
@@ -324,29 +313,32 @@ public class StudyCourseApi extends ApiBaseController{
|
|||||||
if (StringUtils.isEmpty(token)) {
|
if (StringUtils.isEmpty(token)) {
|
||||||
token = request.getHeader("token");
|
token = request.getHeader("token");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//检查是否已存在
|
|
||||||
StudyCourseItem item = studyService.checkHas(sci.getStudyId(),sci.getContentId());
|
StudyCourseItem item = studyService.checkHas(sci.getStudyId(),sci.getContentId());
|
||||||
|
|
||||||
// 20240815 特训营结营考试 临时代码
|
|
||||||
// if(item != null && redisTemplate.opsForValue().get(item.getId())==null){
|
|
||||||
// redisTemplate.opsForValue().set(item.getId(),item.getId());
|
|
||||||
// //设置过期时间为1天
|
|
||||||
// redisTemplate.expire(item.getId(), 60, TimeUnit.SECONDS);
|
|
||||||
// }else{
|
|
||||||
// return success("");
|
|
||||||
// }
|
|
||||||
if(item!=null) {
|
if(item!=null) {
|
||||||
//如果记录存在,但是进度不100无成情况,就更新进度,一期不会有这种情况
|
String studyKey = CacheName.NAME_AUTH + ":" + CacheName.STUDY_KEY + item.getCourseId()+":"+cuser.getAccountId()+":"+item.getContentId();
|
||||||
if(item.getProgress()<100 && sci.getProgress()>item.getProgress()) {
|
String studyKey2 = CacheName.NAME_AUTH + ":" + CacheName.STUDY_KEY + sci.getCourseId()+":"+cuser.getAccountId()+":"+sci.getContentId();
|
||||||
|
redisTemplate.opsForValue().set(studyKey,
|
||||||
|
String.valueOf(item.getProgress()), 2, TimeUnit.HOURS);
|
||||||
|
String progressStr = redisTemplate.opsForValue().get(studyKey2);
|
||||||
|
if (progressStr != null && !progressStr.isEmpty()) {
|
||||||
|
// 尝试将 Redis 中的字符串转换为整数
|
||||||
|
int redisProgress = Integer.parseInt(progressStr);
|
||||||
|
// 假设 item.getProgress() 返回的是 int 类型
|
||||||
|
int sciProgress = sci.getProgress();
|
||||||
|
|
||||||
|
if (redisProgress < sciProgress && redisProgress < 100) {
|
||||||
|
// 执行一些操作
|
||||||
|
// if(item.getProgress()<100 && sci.getProgress()>item.getProgress()) {
|
||||||
|
// }
|
||||||
studyService.updateProcess(item.getId(), sci.getStudyId(), sci.getCourseId(), sci.getContentTotal(), sci.getProgress(),token);
|
studyService.updateProcess(item.getId(), sci.getStudyId(), sci.getCourseId(), sci.getContentTotal(), sci.getProgress(),token);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
//追加学习时长
|
//追加学习时长
|
||||||
studyService.appendStudyDuration(sci.getStudyId(),item.getId(),sci.getContentId(),sci.getDuration());
|
studyService.appendStudyDuration(sci.getStudyId(),item.getId(),sci.getContentId(),sci.getDuration());
|
||||||
List<StudyCourse> allUserList = thirdApi.getStudyCourseList(sci.getStudyId() ,sci.getCourseId(), token);
|
List<StudyCourse> allUserList = thirdApi.getStudyCourseList(sci.getStudyId() ,sci.getCourseId(), token);
|
||||||
log.info("在线课学习记录"+allUserList);
|
log.info("在线课学习记录"+allUserList);
|
||||||
return success(item.getId());
|
return success(item.getId());
|
||||||
|
//如果记录存在,但是进度不100无成情况,就更新进度,一期不会有这种情况
|
||||||
}
|
}
|
||||||
|
|
||||||
if(StringUtils.isBlank(sci.getCourseId())){
|
if(StringUtils.isBlank(sci.getCourseId())){
|
||||||
@@ -421,14 +413,6 @@ public class StudyCourseApi extends ApiBaseController{
|
|||||||
StudyCourseItem item = studyService.checkHas(sci.getStudyId(),sci.getContentId());
|
StudyCourseItem item = studyService.checkHas(sci.getStudyId(),sci.getContentId());
|
||||||
if(item!=null) {
|
if(item!=null) {
|
||||||
//如果记录存在,但是进度不到100,未完成情况,就更新进度,一期不会有这种情况
|
//如果记录存在,但是进度不到100,未完成情况,就更新进度,一期不会有这种情况
|
||||||
// 20240815 特训营结营考试 临时代码
|
|
||||||
// if(item != null && redisTemplate.opsForValue().get(item.getId())==null){
|
|
||||||
// redisTemplate.opsForValue().set(item.getId(),item.getId());
|
|
||||||
// //设置过期时间为1天
|
|
||||||
// redisTemplate.expire(item.getId(), 60, TimeUnit.SECONDS);
|
|
||||||
// }else{
|
|
||||||
// return success("");
|
|
||||||
// }
|
|
||||||
if(item.getProgress()<100) {
|
if(item.getProgress()<100) {
|
||||||
studyService.updateProcess(item.getId(),sci.getStudyId(),sci.getCourseId(), sci.getContentTotal(),100,token);
|
studyService.updateProcess(item.getId(),sci.getStudyId(),sci.getCourseId(), sci.getContentTotal(),100,token);
|
||||||
}
|
}
|
||||||
@@ -534,14 +518,6 @@ public class StudyCourseApi extends ApiBaseController{
|
|||||||
token = request.getHeader("token");
|
token = request.getHeader("token");
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
// 20240815 特训营结营考试 临时代码
|
|
||||||
// if(itemId != null && redisTemplate.opsForValue().get(itemId)==null){
|
|
||||||
// redisTemplate.opsForValue().set(itemId,itemId);
|
|
||||||
// //设置过期时间为1天
|
|
||||||
// redisTemplate.expire(itemId, 60, TimeUnit.SECONDS);
|
|
||||||
// }else{
|
|
||||||
// return success(true);
|
|
||||||
// }
|
|
||||||
studyService.finishVideoStudyItem(itemId, studyId,courseId,cnum,token);
|
studyService.finishVideoStudyItem(itemId, studyId,courseId,cnum,token);
|
||||||
List<StudyCourse> allUserList = thirdApi.getStudyCourseList(studyId ,courseId, token);
|
List<StudyCourse> allUserList = thirdApi.getStudyCourseList(studyId ,courseId, token);
|
||||||
log.info("在线课学习记录"+allUserList);
|
log.info("在线课学习记录"+allUserList);
|
||||||
@@ -724,9 +700,8 @@ public class StudyCourseApi extends ApiBaseController{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@RequestMapping(value="/study-course-content",method = {RequestMethod.GET,RequestMethod.POST})
|
@RequestMapping(value="/study-course-content",method = {RequestMethod.GET,RequestMethod.POST})
|
||||||
public JsonResponse<StudyCourseItem> findStudyCourseItem(String studyId,String contentId, HttpServletRequest request){
|
public JsonResponse<StudyCourseItem> findStudyCourseItem(String studyId,String contentId){
|
||||||
if(StringUtils.isBlank(studyId)){
|
if(StringUtils.isBlank(studyId)){
|
||||||
return error("无学习信息");
|
return error("无学习信息");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ import java.util.Map;
|
|||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
import com.xboe.api.ThirdApi;
|
import com.xboe.api.ThirdApi;
|
||||||
import com.xboe.school.study.dao.StudyCourseDao;
|
|
||||||
import com.xboe.school.study.entity.StudyCourse;
|
import com.xboe.school.study.entity.StudyCourse;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
@@ -33,8 +32,6 @@ import javax.servlet.http.HttpServletRequest;
|
|||||||
@RestController
|
@RestController
|
||||||
@RequestMapping(value="/xboe/school/study/exam")
|
@RequestMapping(value="/xboe/school/study/exam")
|
||||||
public class StudyExamApi extends ApiBaseController{
|
public class StudyExamApi extends ApiBaseController{
|
||||||
@Autowired
|
|
||||||
StudyCourseDao scDao;
|
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
IStudyExamService sexamService;
|
IStudyExamService sexamService;
|
||||||
|
|||||||
Reference in New Issue
Block a user