mirror of
https://codeup.aliyun.com/67762337eccfc218f6110e0e/per-boe/java-servers.git
synced 2025-12-10 03:16:48 +08:00
Compare commits
11 Commits
zcwy-addXx
...
zcwy0923-w
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
002542accc | ||
|
|
df770d22d5 | ||
|
|
638aa9ee93 | ||
|
|
f9b8761951 | ||
|
|
ea2c6edc9f | ||
|
|
7db1a03379 | ||
|
|
fd3afef917 | ||
|
|
b1ef78aae2 | ||
|
|
f5ac7519e4 | ||
|
|
6f2236f3be | ||
|
|
66e4e73dd2 |
@@ -232,13 +232,6 @@
|
|||||||
<artifactId>spring-retry</artifactId>
|
<artifactId>spring-retry</artifactId>
|
||||||
<version>1.3.1</version>
|
<version>1.3.1</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.xuxueli</groupId>
|
|
||||||
<artifactId>xxl-job-core</artifactId>
|
|
||||||
<version>2.3.0</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
<build>
|
<build>
|
||||||
<resources>
|
<resources>
|
||||||
|
|||||||
@@ -1,40 +0,0 @@
|
|||||||
package com.xboe;
|
|
||||||
|
|
||||||
import com.xxl.job.core.executor.impl.XxlJobSpringExecutor;
|
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
|
||||||
import org.springframework.context.annotation.Bean;
|
|
||||||
import org.springframework.context.annotation.Configuration;
|
|
||||||
|
|
||||||
@Configuration
|
|
||||||
public class XxlJobConfig {
|
|
||||||
|
|
||||||
@Value("${xxl.job.admin.addresses}")
|
|
||||||
private String adminAddresses;
|
|
||||||
@Value("${xxl.job.executor.appname}")
|
|
||||||
private String appName;
|
|
||||||
@Value("${xxl.job.executor.ip}")
|
|
||||||
private String ip;
|
|
||||||
@Value("${xxl.job.executor.port}")
|
|
||||||
private int port;
|
|
||||||
@Value("${xxl.job.accessToken}")
|
|
||||||
private String accessToken;
|
|
||||||
@Value("${xxl.job.executor.logpath}")
|
|
||||||
private String logPath;
|
|
||||||
@Value("${xxl.job.executor.logretentiondays}")
|
|
||||||
private int logRetentionDays;
|
|
||||||
|
|
||||||
@Bean
|
|
||||||
public XxlJobSpringExecutor xxlJobExecutor() {
|
|
||||||
// 创建 XxlJobSpringExecutor 执行器
|
|
||||||
XxlJobSpringExecutor xxlJobSpringExecutor = new XxlJobSpringExecutor();
|
|
||||||
xxlJobSpringExecutor.setAdminAddresses(adminAddresses);
|
|
||||||
xxlJobSpringExecutor.setAppname(appName);
|
|
||||||
xxlJobSpringExecutor.setIp(ip);
|
|
||||||
xxlJobSpringExecutor.setPort(port);
|
|
||||||
xxlJobSpringExecutor.setAccessToken(accessToken);
|
|
||||||
xxlJobSpringExecutor.setLogPath(logPath);
|
|
||||||
xxlJobSpringExecutor.setLogRetentionDays(logRetentionDays);
|
|
||||||
// 返回
|
|
||||||
return xxlJobSpringExecutor;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -19,8 +19,6 @@ import org.springframework.beans.factory.annotation.Value;
|
|||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import java.io.UnsupportedEncodingException;
|
|
||||||
import java.net.URLEncoder;
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
package com.xboe.module.boecase.api;
|
package com.xboe.module.boecase.api;
|
||||||
|
|
||||||
import com.xboe.module.boecase.service.ICasesService;
|
import com.xboe.module.boecase.service.ICasesService;
|
||||||
import com.xxl.job.core.handler.annotation.XxlJob;
|
|
||||||
import org.springframework.scheduling.annotation.Scheduled;
|
import org.springframework.scheduling.annotation.Scheduled;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
@@ -13,20 +12,15 @@ public class CaseScheduledTasks {
|
|||||||
@Resource
|
@Resource
|
||||||
private ICasesService casesService;
|
private ICasesService casesService;
|
||||||
|
|
||||||
/**
|
@Scheduled(cron = "0 0 1 1 * ?") // 每月的第一天的1:00执行
|
||||||
* 每月的第一天的1:00执行
|
|
||||||
*/
|
|
||||||
// @Scheduled(cron = "0 0 1 1 * ?")
|
|
||||||
@XxlJob("refreshViewsRankOfMajor")
|
|
||||||
public void refreshViewsRankOfMajor() {
|
public void refreshViewsRankOfMajor() {
|
||||||
casesService.refreshViewsRankOfMajor();
|
casesService.refreshViewsRankOfMajor();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 季初第一天两点执行,cron表达式设置为每个季度的第一个月的第一天的特定时间。每个季度的第一个月是1月、4月、7月和10月:
|
* 季初执行,cron表达式设置为每个季度的第一个月的第一天的特定时间。每个季度的第一个月是1月、4月、7月和10月:
|
||||||
*/
|
*/
|
||||||
// @Scheduled(cron = "0 0 2 1 1,4,7,10 ?")
|
@Scheduled(cron = "0 0 2 1 1,4,7,10 ?")
|
||||||
@XxlJob("refreshLastQuarterStatistics")
|
|
||||||
public void refreshLastQuarterStatistics() {
|
public void refreshLastQuarterStatistics() {
|
||||||
casesService.refreshLastQuarterStatistics();
|
casesService.refreshLastQuarterStatistics();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,9 +15,7 @@ import java.util.stream.Collectors;
|
|||||||
@Repository
|
@Repository
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class CasesRankDao extends BaseDao<CasesRank> {
|
public class CasesRankDao extends BaseDao<CasesRank> {
|
||||||
/**
|
|
||||||
* 获取类别榜记录,默认按上榜时间降序排列
|
|
||||||
*/
|
|
||||||
public List<CasesRank> findViewsRankRecordByCaseId(String caseId) {
|
public List<CasesRank> findViewsRankRecordByCaseId(String caseId) {
|
||||||
String sql =
|
String sql =
|
||||||
"SELECT bdmt.name,bcvr.rise_rank_time,bcvr.rank,bcvr.major_id \n" +
|
"SELECT bdmt.name,bcvr.rise_rank_time,bcvr.rank,bcvr.major_id \n" +
|
||||||
@@ -26,7 +24,8 @@ public class CasesRankDao extends BaseDao<CasesRank> {
|
|||||||
"JOIN boe_dict_major_type bdmt \n" +
|
"JOIN boe_dict_major_type bdmt \n" +
|
||||||
" ON bdmt.code = bcvr.major_id \n" +
|
" ON bdmt.code = bcvr.major_id \n" +
|
||||||
"WHERE bcvr.case_id = ?1 AND bcvr.deleted=0 AND bdmt.deleted=0\n" +
|
"WHERE bcvr.case_id = ?1 AND bcvr.deleted=0 AND bdmt.deleted=0\n" +
|
||||||
"ORDER BY bcvr.rise_rank_time DESC;";
|
"ORDER BY bcvr.sys_update_time DESC \n" +
|
||||||
|
"LIMIT 2;";
|
||||||
|
|
||||||
List<Object[]> list = this.sqlFindList(sql, caseId);
|
List<Object[]> list = this.sqlFindList(sql, caseId);
|
||||||
|
|
||||||
|
|||||||
@@ -44,7 +44,6 @@ import javax.annotation.Resource;
|
|||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import java.lang.reflect.Array;
|
import java.lang.reflect.Array;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.time.YearMonth;
|
|
||||||
import java.time.format.DateTimeFormatter;
|
import java.time.format.DateTimeFormatter;
|
||||||
import java.time.temporal.TemporalAdjusters;
|
import java.time.temporal.TemporalAdjusters;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
@@ -417,36 +416,14 @@ public class CasesServiceImpl implements ICasesService {
|
|||||||
if (CollUtil.isEmpty(casesList)) {
|
if (CollUtil.isEmpty(casesList)) {
|
||||||
return casesList;
|
return casesList;
|
||||||
}
|
}
|
||||||
|
|
||||||
//1.推荐案例数据处理
|
//1.推荐案例数据处理
|
||||||
recommendCasesDataHandle(casesList, accountId);
|
recommendCasesDataHandle(casesList, accountId);
|
||||||
//2.标签处理,添加作者标签和新的案例标签
|
//2.标签处理,添加作者标签和新的案例标签
|
||||||
addAuthorTagAndCaseNewTag(casesList);
|
addAuthorTagAndCaseNewTag(casesList);
|
||||||
//3.案例类型处理
|
|
||||||
// majorTypeHandle(casesList);
|
|
||||||
|
|
||||||
return casesList;
|
return casesList;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void majorTypeHandle(List<Cases> casesList) {
|
|
||||||
if (CollUtil.isNotEmpty(casesList)) {
|
|
||||||
for (Cases c : casesList) {
|
|
||||||
StringBuffer stringBuffer = new StringBuffer();
|
|
||||||
List<CasesMajorType> caseId = casesMajorTypeDao.findList(FieldFilters.eq("caseId", c.getId()));
|
|
||||||
if (caseId != null && !caseId.isEmpty()) {
|
|
||||||
for (CasesMajorType cm : caseId) {
|
|
||||||
stringBuffer.append(cm.getMajorId());
|
|
||||||
stringBuffer.append(",");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (stringBuffer.length() > 0) {
|
|
||||||
stringBuffer.deleteCharAt(stringBuffer.length() - 1);
|
|
||||||
c.setMajorType(stringBuffer.toString());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void recommendCasesDataHandle(List<Cases> casesList, String accountId) {
|
private void recommendCasesDataHandle(List<Cases> casesList, String accountId) {
|
||||||
if (StrUtil.isNotBlank(accountId)) {
|
if (StrUtil.isNotBlank(accountId)) {
|
||||||
List<String> caseIdList = casesList.stream().map(Cases::getId).collect(Collectors.toList());
|
List<String> caseIdList = casesList.stream().map(Cases::getId).collect(Collectors.toList());
|
||||||
@@ -506,7 +483,7 @@ public class CasesServiceImpl implements ICasesService {
|
|||||||
|
|
||||||
|
|
||||||
caseList.forEach(e -> {
|
caseList.forEach(e -> {
|
||||||
// 获取浏览量上榜记录
|
// 获取最新的两个浏览量上榜记录
|
||||||
List<CasesRank> viewsRankRecords = casesRankDao.findViewsRankRecordByCaseId(e.getId());
|
List<CasesRank> viewsRankRecords = casesRankDao.findViewsRankRecordByCaseId(e.getId());
|
||||||
if (CollUtil.isNotEmpty(viewsRankRecords)) {
|
if (CollUtil.isNotEmpty(viewsRankRecords)) {
|
||||||
// 拼接生成浏览量排行榜的标签
|
// 拼接生成浏览量排行榜的标签
|
||||||
@@ -1204,15 +1181,15 @@ public class CasesServiceImpl implements ICasesService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//获取案例当月排名
|
//获取案例当月排名
|
||||||
String sql =
|
|
||||||
"SELECT bc.id,bcmt.major_id,bc.views - COALESCE(bc.last_month_views, 0) AS increment\n" +
|
|
||||||
"FROM boe_cases bc\n" +
|
|
||||||
"JOIN boe_cases_major_type bcmt ON bcmt.case_id = bc.id and bc.deleted=0 and file_path is not null and file_path!='' and bc.views - COALESCE(bc.last_month_views, 0)!=0";
|
|
||||||
|
|
||||||
// String sql =
|
// String sql =
|
||||||
// "SELECT bc.id,bcmt.major_id,bc.views AS increment\n" +
|
// "SELECT bc.id,bcmt.major_id,bc.views - COALESCE(bc.last_month_views, 0) AS increment\n" +
|
||||||
// "FROM boe_cases bc\n" +
|
// "FROM boe_cases bc\n" +
|
||||||
// "JOIN boe_cases_major_type bcmt ON bcmt.case_id = bc.id and bc.deleted=0 and file_path is not null and file_path!='' and bc.views !=0 and bc.views is not null";
|
// "JOIN boe_cases_major_type bcmt ON bcmt.case_id = bc.id and bc.deleted=0 and file_path is not null and file_path!='' and bc.views - COALESCE(bc.last_month_views, 0)!=0";
|
||||||
|
|
||||||
|
String sql =
|
||||||
|
"SELECT bc.id,bcmt.major_id,bc.views AS increment\n" +
|
||||||
|
"FROM boe_cases bc\n" +
|
||||||
|
"JOIN boe_cases_major_type bcmt ON bcmt.case_id = bc.id and bc.deleted=0 and file_path is not null and file_path!='' and bc.views !=0 and bc.views is not null";
|
||||||
|
|
||||||
List<Object> caseListOfObject = casesDao.sqlFindList(sql);
|
List<Object> caseListOfObject = casesDao.sqlFindList(sql);
|
||||||
|
|
||||||
@@ -1254,7 +1231,7 @@ public class CasesServiceImpl implements ICasesService {
|
|||||||
@Override
|
@Override
|
||||||
public void refreshLastQuarterStatistics() {
|
public void refreshLastQuarterStatistics() {
|
||||||
log.info("开始执行每季案例相关定时任务");
|
log.info("开始执行每季案例相关定时任务");
|
||||||
int i = casesDao.sqlUpdate("update boe_cases set last_quarter_views=views,last_quarter_praises=praises where deleted=0");
|
int i = casesDao.sqlUpdate("update boe_cases set last_quarter_views=views,last_quarter_praise=praise where deleted=0");
|
||||||
log.info("每季案例相关定时任务执行完成,boe_cases更新数据量为条数为"+i);
|
log.info("每季案例相关定时任务执行完成,boe_cases更新数据量为条数为"+i);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1300,24 +1277,21 @@ public class CasesServiceImpl implements ICasesService {
|
|||||||
pageSize = 10;
|
pageSize = 10;
|
||||||
}
|
}
|
||||||
|
|
||||||
LocalDateTime startTime = month.withDayOfMonth(1).withHour(0).withMinute(0).withSecond(0);
|
LocalDateTime startTime = month.withDayOfMonth(1);
|
||||||
LocalDateTime endTime = YearMonth.from(month).atEndOfMonth().atTime(23, 59, 59);
|
LocalDateTime endTime = month.plusMonths(1).withDayOfMonth(1).withMinute(0);
|
||||||
|
|
||||||
List<HashMap<String, Object>> popularityOfMajor = casesRankDao.findPopularityOfMajor(pageSize, startTime, endTime, majorId);
|
List<HashMap<String, Object>> popularityOfMajor = casesRankDao.findPopularityOfMajor(pageSize, startTime, endTime, majorId);
|
||||||
List<String> caseIdList = popularityOfMajor.stream().map(map -> map.get("caseId").toString()).collect(Collectors.toList());
|
List<String> caseIdList = popularityOfMajor.stream().map(map -> map.get("caseId").toString()).collect(Collectors.toList());
|
||||||
|
|
||||||
|
Map<Object, Integer> collect = popularityOfMajor.stream().collect(Collectors.toMap(map -> map.get("caseId").toString(), map -> Integer.valueOf(map.get("rank").toString())));
|
||||||
|
|
||||||
QueryBuilder query = QueryBuilder.from(Cases.class);
|
QueryBuilder query = QueryBuilder.from(Cases.class);
|
||||||
query.addFilter(FieldFilters.in("id",caseIdList));
|
query.addFilter(FieldFilters.in("id",caseIdList));
|
||||||
query.addFilter(FieldFilters.eq("deleted",false));
|
query.addFilter(FieldFilters.eq("deleted",false));
|
||||||
|
|
||||||
List<Cases> casesList = casesDao.findList(query.builder());
|
List<Cases> casesList = casesDao.findList(query.builder());
|
||||||
//处理案例数据-通用操作
|
|
||||||
casesList = caseListCommonHandle(casesList, accountId);
|
casesList = caseListCommonHandle(casesList, accountId);
|
||||||
//获取案例与排名的映射关系
|
|
||||||
Map<Object, Integer> collect = popularityOfMajor.stream().collect(Collectors.toMap(map -> map.get("caseId").toString(), map -> Integer.valueOf(map.get("rank").toString())));
|
|
||||||
|
|
||||||
//排序榜单案例顺序
|
|
||||||
Collections.sort(casesList, new Comparator<Cases>() {
|
Collections.sort(casesList, new Comparator<Cases>() {
|
||||||
@Override
|
@Override
|
||||||
public int compare(Cases c1, Cases c2) {
|
public int compare(Cases c1, Cases c2) {
|
||||||
@@ -1326,26 +1300,6 @@ public class CasesServiceImpl implements ICasesService {
|
|||||||
return Integer.compare(order1, order2);
|
return Integer.compare(order1, order2);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
casesList.forEach(cases -> {
|
|
||||||
List<CaseViewRankingItemVo> viewRankTags = cases.getViewRankTags();
|
|
||||||
|
|
||||||
// 使用 Stream API 进行排序,保持其余元素的原始顺序
|
|
||||||
List<CaseViewRankingItemVo> sortedList = viewRankTags.stream()
|
|
||||||
.sorted((o1, o2) -> {
|
|
||||||
// majorId 相等时放前面
|
|
||||||
boolean o1Matches = o1.getMajorId().equals(majorId);
|
|
||||||
boolean o2Matches = o2.getMajorId().equals(majorId);
|
|
||||||
|
|
||||||
if (o1Matches && !o2Matches) return -1; // o1是majorId, o2不是,o1排前
|
|
||||||
if (!o1Matches && o2Matches) return 1; // o2是majorId, o1不是,o2排前
|
|
||||||
return 0; // 如果两者都是或都不是majorId, 保持原有顺序
|
|
||||||
})
|
|
||||||
.collect(Collectors.toList());
|
|
||||||
|
|
||||||
// 更新原列表
|
|
||||||
cases.setViewRankTags(sortedList);
|
|
||||||
});
|
|
||||||
return casesList;
|
return casesList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,10 +4,13 @@ import java.util.List;
|
|||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
|
|
||||||
import com.xboe.common.utils.StringUtil;
|
|
||||||
import com.xboe.core.log.AutoLog;
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
|
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.RequestMethod;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
import com.xboe.core.JsonResponse;
|
import com.xboe.core.JsonResponse;
|
||||||
import com.xboe.core.api.ApiBaseController;
|
import com.xboe.core.api.ApiBaseController;
|
||||||
@@ -74,22 +77,7 @@ public class CourseContentApi extends ApiBaseController{
|
|||||||
}
|
}
|
||||||
return success(obj);
|
return success(obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/exam/paper-content")
|
|
||||||
@AutoLog(module = "试卷",action = "查看试卷试题",info = "查看当前试题内容")
|
|
||||||
public JsonResponse<Object> paperContent(String courseExamId){
|
|
||||||
if(StringUtil.isBlank(courseExamId)){
|
|
||||||
return badRequest("缺少必要参数");
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
Object paperContentOfOnline = ccontentService.getPaperContentOfOnline(courseExamId);
|
|
||||||
return success(paperContentOfOnline);
|
|
||||||
} catch (Exception e) {
|
|
||||||
log.error("查询试卷内容json错误",e);
|
|
||||||
return error("查询失败",e.getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取评估信息
|
* 获取评估信息
|
||||||
* @param ccid
|
* @param ccid
|
||||||
|
|||||||
@@ -1,7 +1,38 @@
|
|||||||
package com.xboe.module.course.api;
|
package com.xboe.module.course.api;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileInputStream;
|
||||||
|
import java.io.FileOutputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.*;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
import java.util.zip.ZipEntry;
|
||||||
|
import java.util.zip.ZipOutputStream;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
|
||||||
import com.xboe.api.ThirdApi;
|
import com.xboe.api.ThirdApi;
|
||||||
import com.xboe.api.vo.UserBasicInfo;
|
import com.xboe.api.vo.UserBasicInfo;
|
||||||
|
import com.xboe.core.orm.FieldFilters;
|
||||||
|
import com.xboe.module.course.entity.*;
|
||||||
|
import com.xboe.module.course.vo.TeacherVo;
|
||||||
|
import com.xboe.school.study.dao.StudyCourseDao;
|
||||||
|
import com.xboe.school.study.entity.StudyHomeWork;
|
||||||
|
import com.xboe.school.study.service.IStudyHomeWorkService;
|
||||||
|
import com.xboe.school.study.service.IStudyService;
|
||||||
|
import com.xboe.system.user.entity.User;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.data.redis.core.StringRedisTemplate;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
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.RequestMethod;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
import com.xboe.common.PageList;
|
import com.xboe.common.PageList;
|
||||||
import com.xboe.common.Pagination;
|
import com.xboe.common.Pagination;
|
||||||
import com.xboe.common.utils.StringUtil;
|
import com.xboe.common.utils.StringUtil;
|
||||||
@@ -11,7 +42,6 @@ import com.xboe.core.orm.FieldFilters;
|
|||||||
import com.xboe.module.course.dto.CourseQueryDto;
|
import com.xboe.module.course.dto.CourseQueryDto;
|
||||||
import com.xboe.module.course.dto.CourseTeacherDto;
|
import com.xboe.module.course.dto.CourseTeacherDto;
|
||||||
import com.xboe.module.course.dto.RankingDto;
|
import com.xboe.module.course.dto.RankingDto;
|
||||||
import com.xboe.module.course.dto.TeacherCourseDto;
|
|
||||||
import com.xboe.module.course.entity.*;
|
import com.xboe.module.course.entity.*;
|
||||||
import com.xboe.module.course.service.ICourseContentService;
|
import com.xboe.module.course.service.ICourseContentService;
|
||||||
import com.xboe.module.course.service.ICourseSectionService;
|
import com.xboe.module.course.service.ICourseSectionService;
|
||||||
@@ -29,8 +59,6 @@ import com.xboe.school.study.entity.StudyHomeWork;
|
|||||||
import com.xboe.school.study.service.IStudyCourseService;
|
import com.xboe.school.study.service.IStudyCourseService;
|
||||||
import com.xboe.school.study.service.IStudyHomeWorkService;
|
import com.xboe.school.study.service.IStudyHomeWorkService;
|
||||||
import com.xboe.school.study.service.IStudyService;
|
import com.xboe.school.study.service.IStudyService;
|
||||||
import com.xboe.system.user.entity.User;
|
|
||||||
import com.xboe.system.user.service.IUserService;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
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;
|
||||||
@@ -63,8 +91,7 @@ public class CoursePortalApi extends ApiBaseController{
|
|||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private ICourseService courseService;
|
private ICourseService courseService;
|
||||||
@Resource
|
|
||||||
private IUserService userService;
|
|
||||||
@Resource
|
@Resource
|
||||||
private ITeacherService teacherService;
|
private ITeacherService teacherService;
|
||||||
|
|
||||||
@@ -282,7 +309,7 @@ public class CoursePortalApi extends ApiBaseController{
|
|||||||
if (!Objects.isNull(studyCourse)){
|
if (!Objects.isNull(studyCourse)){
|
||||||
pass = true;
|
pass = true;
|
||||||
}
|
}
|
||||||
if (Objects.isNull(studyCourse) && !courseCrowdList.isEmpty() && !StringUtils.isEmpty(audiences)) {
|
if (Objects.isNull(studyCourse) && !courseCrowdList.isEmpty()) {
|
||||||
List<String> audienceList = Arrays.asList(audiences.split(",")); // 此用户所在受众组
|
List<String> audienceList = Arrays.asList(audiences.split(",")); // 此用户所在受众组
|
||||||
log.error("---------------参数------------ audienceList = " + audienceList);
|
log.error("---------------参数------------ audienceList = " + audienceList);
|
||||||
for (CourseCrowd c : courseCrowdList) {
|
for (CourseCrowd c : courseCrowdList) {
|
||||||
@@ -305,30 +332,17 @@ public class CoursePortalApi extends ApiBaseController{
|
|||||||
List<CourseContent> cclist=contentService.getByCourseId(id);
|
List<CourseContent> cclist=contentService.getByCourseId(id);
|
||||||
List<CourseSection> sectionlist=sectionService.getByCourseId(id);
|
List<CourseSection> sectionlist=sectionService.getByCourseId(id);
|
||||||
List<CourseTeacher> teachers=courseService.findTeachersByCourseId(id);
|
List<CourseTeacher> teachers=courseService.findTeachersByCourseId(id);
|
||||||
List<TeacherCourseDto> teacherCourseDtos = new ArrayList<>();
|
|
||||||
|
|
||||||
//获取教师的介绍信息,因为一门课程 的教师不会太多,所以这里简单直接遍历查询,后续再优化
|
//获取教师的介绍信息,因为一门课程 的教师不会太多,所以这里简单直接遍历查询,后续再优化
|
||||||
for(CourseTeacher ct : teachers) {
|
for(CourseTeacher ct : teachers) {
|
||||||
TeacherCourseDto teacherCourseDto = new TeacherCourseDto();
|
|
||||||
Teacher t = teacherService.get(ct.getTeacherId());
|
Teacher t = teacherService.get(ct.getTeacherId());
|
||||||
User user = userService.get(ct.getTeacherId());
|
|
||||||
if(t!=null) {
|
if(t!=null) {
|
||||||
ct.setRemark(t.getDescription());
|
ct.setRemark(t.getDescription());
|
||||||
if(redisTemplate.opsForValue().get(ct.getTeacherId())!=null){
|
if(redisTemplate.opsForValue().get(ct.getTeacherId())!=null){
|
||||||
if(Objects.equals(redisTemplate.opsForValue().get(ct.getTeacherId()), "1")){
|
if(Objects.equals(redisTemplate.opsForValue().get(ct.getTeacherId()), "1")){
|
||||||
ct.setTeacherName("BOE教师");
|
ct.setTeacherName("BOE教师");
|
||||||
}
|
}
|
||||||
teacherCourseDto.setCourseId(ct.getCourseId());
|
|
||||||
teacherCourseDto.setTeacherName(ct.getTeacherName());
|
|
||||||
teacherCourseDto.setTeacherId(ct.getTeacherId());
|
|
||||||
teacherCourseDto.setCode(ct.getCode());
|
|
||||||
teacherCourseDto.setRemark(ct.getRemark());
|
|
||||||
teacherCourseDto.setSysCreateAid(ct.getSysCreateAid());
|
|
||||||
teacherCourseDto.setSysCreateBy(ct.getSysCreateBy());
|
|
||||||
teacherCourseDto.setSysCreateTime(ct.getSysCreateTime());
|
|
||||||
teacherCourseDto.setId(ct.getId());
|
|
||||||
teacherCourseDto.setUserNo(user.getUserNo());
|
|
||||||
teacherCourseDtos.add(teacherCourseDto);
|
|
||||||
}else if (redisTemplate.opsForValue().get(ct.getTeacherId())==null){
|
}else if (redisTemplate.opsForValue().get(ct.getTeacherId())==null){
|
||||||
List<String> list=new ArrayList<>();
|
List<String> list=new ArrayList<>();
|
||||||
list.add(ct.getTeacherId());
|
list.add(ct.getTeacherId());
|
||||||
@@ -336,17 +350,6 @@ public class CoursePortalApi extends ApiBaseController{
|
|||||||
if(Objects.equals(redisTemplate.opsForValue().get(ct.getTeacherId()), "1")){
|
if(Objects.equals(redisTemplate.opsForValue().get(ct.getTeacherId()), "1")){
|
||||||
ct.setTeacherName("BOE教师");
|
ct.setTeacherName("BOE教师");
|
||||||
}
|
}
|
||||||
teacherCourseDto.setCourseId(ct.getCourseId());
|
|
||||||
teacherCourseDto.setTeacherName(ct.getTeacherName());
|
|
||||||
teacherCourseDto.setTeacherId(ct.getTeacherId());
|
|
||||||
teacherCourseDto.setCode(ct.getCode());
|
|
||||||
teacherCourseDto.setRemark(ct.getRemark());
|
|
||||||
teacherCourseDto.setSysCreateAid(ct.getSysCreateAid());
|
|
||||||
teacherCourseDto.setSysCreateBy(ct.getSysCreateBy());
|
|
||||||
teacherCourseDto.setSysCreateTime(ct.getSysCreateTime());
|
|
||||||
teacherCourseDto.setId(ct.getId());
|
|
||||||
teacherCourseDto.setUserNo(user.getUserNo());
|
|
||||||
teacherCourseDtos.add(teacherCourseDto);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -355,7 +358,7 @@ public class CoursePortalApi extends ApiBaseController{
|
|||||||
rs.put("isCrowd",pass);
|
rs.put("isCrowd",pass);
|
||||||
rs.put("contents", cclist);
|
rs.put("contents", cclist);
|
||||||
rs.put("sections",sectionlist);
|
rs.put("sections",sectionlist);
|
||||||
rs.put("teachers",teacherCourseDtos);
|
rs.put("teachers",teachers);
|
||||||
//查询课程
|
//查询课程
|
||||||
return success(rs);
|
return success(rs);
|
||||||
|
|
||||||
@@ -424,6 +427,49 @@ public class CoursePortalApi extends ApiBaseController{
|
|||||||
String zipFilePath = "/home/www/elearning/upload/saveZip/" + courseName+"【作业】" + ".zip";
|
String zipFilePath = "/home/www/elearning/upload/saveZip/" + courseName+"【作业】" + ".zip";
|
||||||
createZipFile(map, zipFilePath);
|
createZipFile(map, zipFilePath);
|
||||||
return success(zipFilePath);
|
return success(zipFilePath);
|
||||||
|
// 创建一个临时文件用于存储ZIP文件
|
||||||
|
// File tempZipFile = new File("/home/www/elearning/upload/temp.zip");
|
||||||
|
//
|
||||||
|
// try (ZipOutputStream zos = new ZipOutputStream(new FileOutputStream(tempZipFile))) {
|
||||||
|
// for (Map.Entry<String, String> e : map.entrySet()) {
|
||||||
|
// File fileToZip = new File(e.getValue());
|
||||||
|
// // 添加 ZIP 条目
|
||||||
|
// ZipEntry entry = new ZipEntry(e.getKey());
|
||||||
|
// entry.setSize(fileToZip.length());
|
||||||
|
//
|
||||||
|
// zos.putNextEntry(entry);
|
||||||
|
//
|
||||||
|
// try (FileInputStream fis = new FileInputStream(fileToZip)) {
|
||||||
|
// byte[] buffer = new byte[4096];
|
||||||
|
// int len;
|
||||||
|
// while ((len = fis.read(buffer)) > 0) {
|
||||||
|
// zos.write(buffer, 0, len);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// zos.closeEntry();
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// // 将临时文件移动到指定位置
|
||||||
|
// Path source = tempZipFile.toPath();
|
||||||
|
// //生成uuid
|
||||||
|
//// String uuid = UUID.randomUUID().toString();
|
||||||
|
// Path destination = Paths.get("/home/www/elearning/upload/saveZip/" + courseName+"【作业】" + ".zip");
|
||||||
|
//
|
||||||
|
// // 确保目标目录存在
|
||||||
|
// Files.createDirectories(destination.getParent());
|
||||||
|
//
|
||||||
|
// // 删除目标文件如果已存在
|
||||||
|
// if (Files.exists(destination)) {
|
||||||
|
// Files.delete(destination);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// // 移动文件
|
||||||
|
// Files.copy(source, destination, StandardCopyOption.REPLACE_EXISTING);
|
||||||
|
//
|
||||||
|
// // 返回文件路径给前端
|
||||||
|
// String filePath = destination.toAbsolutePath().toString();
|
||||||
|
// return success(filePath);
|
||||||
}
|
}
|
||||||
private static void createZipFile(Map<String, String> map, String zipFilePath) throws IOException {
|
private static void createZipFile(Map<String, String> map, String zipFilePath) throws IOException {
|
||||||
try (ZipOutputStream zos = new ZipOutputStream(new FileOutputStream(zipFilePath))) {
|
try (ZipOutputStream zos = new ZipOutputStream(new FileOutputStream(zipFilePath))) {
|
||||||
|
|||||||
@@ -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";
|
||||||
@@ -99,24 +97,24 @@ public class CourseWareApi extends ApiBaseController {
|
|||||||
return badRequest("非法请求");
|
return badRequest("非法请求");
|
||||||
// return;
|
// return;
|
||||||
}
|
}
|
||||||
|
|
||||||
String httpReferer = request.getHeader("referer");
|
String httpReferer = request.getHeader("referer");
|
||||||
if (StringUtils.isBlank(httpReferer)) {
|
if (StringUtils.isBlank(httpReferer)) {
|
||||||
return badRequest("非法请求");
|
return badRequest("非法请求");
|
||||||
// return "非法请求";
|
// return "非法请求";
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean has=false;
|
boolean has=false;
|
||||||
for(String txt :allowUrlSet) {
|
for(String txt :allowUrlSet) {
|
||||||
if(httpReferer.indexOf(txt)>-1) {
|
if(httpReferer.indexOf(txt)>-1) {
|
||||||
has=true;
|
has=true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!has) {
|
if(!has) {
|
||||||
return badRequest("页面不存在");
|
return badRequest("页面不存在");
|
||||||
//return "非法请求";
|
//return "非法请求";
|
||||||
}
|
}
|
||||||
|
|
||||||
//读取cookies中的时间
|
//读取cookies中的时间
|
||||||
String cookieTime = getSignTimeCookie(request);
|
String cookieTime = getSignTimeCookie(request);
|
||||||
@@ -133,22 +131,16 @@ 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("验证错误");
|
||||||
}
|
}
|
||||||
|
|
||||||
String time = signStr.substring(0, signStr.indexOf("/"));// 时间字符中,long
|
String time = signStr.substring(0, signStr.indexOf("/"));// 时间字符中,long
|
||||||
String cfid = signStr.substring(index+1);// 文件路径
|
String cfid = signStr.substring(index+1);// 文件路径
|
||||||
|
|
||||||
// if (!time.equals(cookieTime)) {
|
if (!time.equals(cookieTime)) {
|
||||||
// log.info("请求头时间和解析后的时间对比:"+"解析时间:"+time+" 请求头时间:"+cookieTime);
|
return badRequest("验证错误");
|
||||||
// log.info("解密后的字符串的时间拼接:"+signStr);
|
}
|
||||||
// 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("验证错误");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,11 +0,0 @@
|
|||||||
package com.xboe.module.course.dto;
|
|
||||||
|
|
||||||
import com.xboe.module.course.entity.CourseTeacher;
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
@Data
|
|
||||||
public class TeacherCourseDto extends CourseTeacher {
|
|
||||||
private String userNo;
|
|
||||||
}
|
|
||||||
@@ -85,6 +85,4 @@ public interface ICourseContentService{
|
|||||||
|
|
||||||
void updateProcessVideo(String contentId, String courseId, Float processVideo);
|
void updateProcessVideo(String contentId, String courseId, Float processVideo);
|
||||||
|
|
||||||
Object getPaperContentOfOnline(String courseExamId);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,17 +1,23 @@
|
|||||||
package com.xboe.module.course.service.impl;
|
package com.xboe.module.course.service.impl;
|
||||||
|
|
||||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
import java.sql.PreparedStatement;
|
||||||
import com.fasterxml.jackson.core.type.TypeReference;
|
import java.sql.SQLException;
|
||||||
import com.fasterxml.jackson.databind.DeserializationFeature;
|
import java.util.List;
|
||||||
import com.fasterxml.jackson.databind.JsonNode;
|
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import javax.annotation.Resource;
|
||||||
import com.fasterxml.jackson.databind.node.ObjectNode;
|
import javax.transaction.Transactional;
|
||||||
|
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import com.xboe.common.OrderCondition;
|
import com.xboe.common.OrderCondition;
|
||||||
import com.xboe.core.cache.IXaskCache;
|
|
||||||
import com.xboe.core.cache.XaskCacheProvider;
|
|
||||||
import com.xboe.core.orm.FieldFilters;
|
import com.xboe.core.orm.FieldFilters;
|
||||||
import com.xboe.core.orm.UpdateBuilder;
|
import com.xboe.core.orm.UpdateBuilder;
|
||||||
import com.xboe.module.course.dao.*;
|
import com.xboe.module.course.dao.CourseAssessDao;
|
||||||
|
import com.xboe.module.course.dao.CourseContentDao;
|
||||||
|
import com.xboe.module.course.dao.CourseExamDao;
|
||||||
|
import com.xboe.module.course.dao.CourseHomeWorkDao;
|
||||||
|
import com.xboe.module.course.dao.CourseSectionDao;
|
||||||
import com.xboe.module.course.dto.CourseContentDto;
|
import com.xboe.module.course.dto.CourseContentDto;
|
||||||
import com.xboe.module.course.dto.SortItem;
|
import com.xboe.module.course.dto.SortItem;
|
||||||
import com.xboe.module.course.entity.CourseAssess;
|
import com.xboe.module.course.entity.CourseAssess;
|
||||||
@@ -19,21 +25,8 @@ import com.xboe.module.course.entity.CourseContent;
|
|||||||
import com.xboe.module.course.entity.CourseExam;
|
import com.xboe.module.course.entity.CourseExam;
|
||||||
import com.xboe.module.course.entity.CourseHomeWork;
|
import com.xboe.module.course.entity.CourseHomeWork;
|
||||||
import com.xboe.module.course.service.ICourseContentService;
|
import com.xboe.module.course.service.ICourseContentService;
|
||||||
import com.xboe.module.exam.dao.ExamPaperDao;
|
|
||||||
import com.xboe.module.exam.vo.TestQuestionVo;
|
|
||||||
import com.xboe.standard.enums.BoedxContentType;
|
import com.xboe.standard.enums.BoedxContentType;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
|
||||||
import javax.transaction.Transactional;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.concurrent.TimeUnit;
|
|
||||||
|
|
||||||
@Slf4j
|
|
||||||
@Service
|
@Service
|
||||||
public class CourseContentServiceImpl implements ICourseContentService {
|
public class CourseContentServiceImpl implements ICourseContentService {
|
||||||
|
|
||||||
@@ -51,13 +44,7 @@ public class CourseContentServiceImpl implements ICourseContentService {
|
|||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private CourseHomeWorkDao homeworkDao;
|
private CourseHomeWorkDao homeworkDao;
|
||||||
|
|
||||||
@Resource
|
|
||||||
private CourseExamDao courseExamDao;
|
|
||||||
|
|
||||||
@Resource
|
|
||||||
private ExamPaperDao examPaperDao;
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
@@ -91,9 +78,6 @@ public class CourseContentServiceImpl implements ICourseContentService {
|
|||||||
assessDao.saveOrUpdate(assess);
|
assessDao.saveOrUpdate(assess);
|
||||||
}
|
}
|
||||||
if(exam!=null) {
|
if(exam!=null) {
|
||||||
if ((exam.getRandomMode() && !(exam.getQnum() > 0)) || (!exam.getRandomMode() && exam.getQnum() > 0)) {
|
|
||||||
throw new RuntimeException("随机选题处参数错误");
|
|
||||||
}
|
|
||||||
exam.setCourseId(cc.getCourseId());
|
exam.setCourseId(cc.getCourseId());
|
||||||
exam.setContentId(cc.getId());
|
exam.setContentId(cc.getId());
|
||||||
if(exam.getPercentScore()==null) {
|
if(exam.getPercentScore()==null) {
|
||||||
@@ -204,68 +188,4 @@ public class CourseContentServiceImpl implements ICourseContentService {
|
|||||||
|
|
||||||
return ccDao.sumDurationByCourseId(courseId);
|
return ccDao.sumDurationByCourseId(courseId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Object getPaperContentOfOnline(String courseExamId) {
|
|
||||||
CourseExam courseExam = courseExamDao.findOne(FieldFilters.eq("id", courseExamId));
|
|
||||||
if (courseExam == null) {
|
|
||||||
throw new RuntimeException("课程考试不存在");
|
|
||||||
}
|
|
||||||
|
|
||||||
String paperId = courseExam.getPaperId();
|
|
||||||
Integer qnum = courseExam.getQnum();
|
|
||||||
Boolean randomMode = courseExam.getRandomMode();
|
|
||||||
|
|
||||||
String paperJson = "";
|
|
||||||
ObjectMapper objectMapper = new ObjectMapper();
|
|
||||||
|
|
||||||
try {
|
|
||||||
// 判断试卷类型
|
|
||||||
if (courseExam.getPaperType() == 1 && StringUtils.isNotBlank(courseExam.getPaperContent())) {
|
|
||||||
paperJson = courseExam.getPaperContent();
|
|
||||||
JsonNode rootNode = objectMapper.readTree(paperJson);
|
|
||||||
JsonNode itemsNode = rootNode.path("items");
|
|
||||||
List<JsonNode> itemsNodes = new ArrayList<>();
|
|
||||||
itemsNode.forEach(itemsNodes::add);
|
|
||||||
|
|
||||||
if (randomMode && qnum != null && qnum > 0 && randomMode && qnum != null && qnum > 0 && itemsNodes.size() > qnum) {
|
|
||||||
Collections.shuffle(itemsNodes);
|
|
||||||
itemsNodes = itemsNodes.subList(0, qnum);
|
|
||||||
}
|
|
||||||
return itemsNodes;
|
|
||||||
} else if (courseExam.getPaperType() == 2) {
|
|
||||||
IXaskCache cache = XaskCacheProvider.getCache();
|
|
||||||
String cacheKey = "course:exam:" + courseExamId + ":" + paperId;
|
|
||||||
String cacheData = cache.getCacheObject(cacheKey);
|
|
||||||
|
|
||||||
if (StringUtils.isBlank(cacheData)) {
|
|
||||||
paperJson = (String) examPaperDao.findField("paperContent", FieldFilters.eq("id", paperId));
|
|
||||||
cache.setCacheObject(cacheKey, paperJson, 5, TimeUnit.HOURS);
|
|
||||||
} else {
|
|
||||||
paperJson = cacheData;
|
|
||||||
}
|
|
||||||
|
|
||||||
objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
|
|
||||||
List<TestQuestionVo> eqVoList = objectMapper.readValue(paperJson, new TypeReference<List<TestQuestionVo>>() {
|
|
||||||
});
|
|
||||||
|
|
||||||
if (randomMode && qnum != null && qnum > 0 && eqVoList.size() > qnum) {
|
|
||||||
Collections.shuffle(eqVoList);
|
|
||||||
eqVoList = eqVoList.subList(0, qnum);
|
|
||||||
}
|
|
||||||
return eqVoList;
|
|
||||||
}
|
|
||||||
|
|
||||||
} catch (JsonProcessingException e) {
|
|
||||||
log.error("JSON处理错误", e);
|
|
||||||
throw new RuntimeException(e);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (StringUtils.isBlank(paperJson)) {
|
|
||||||
throw new RuntimeException("此考试无试卷内容,考试已经过期或试卷已被删除");
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -354,18 +354,18 @@ public class AloneExamApi extends ApiBaseController {
|
|||||||
if(StringUtils.isBlank(paperJson)) {
|
if(StringUtils.isBlank(paperJson)) {
|
||||||
return badRequest("此考试无试卷内容,考试已经过期或试卷已被删除");
|
return badRequest("此考试无试卷内容,考试已经过期或试卷已被删除");
|
||||||
}
|
}
|
||||||
|
try {
|
||||||
|
List<TestQuestionVo> qlist=this.randomQuestion(examTest, paperJson);
|
||||||
|
ObjectMapper objectMapper = new ObjectMapper();
|
||||||
|
paperJson=objectMapper.writeValueAsString(qlist);
|
||||||
|
} catch (XaskException e) {
|
||||||
|
log.error("生成试卷错误",e);
|
||||||
|
return error("生成考试试卷错误",e.getMessage(),map);
|
||||||
|
} catch (JsonProcessingException e) {
|
||||||
|
log.error("生成试卷,解析生成json错误",e);
|
||||||
|
return error("生成考试试卷解析错误",e.getMessage(),map);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
try {
|
|
||||||
List<TestQuestionVo> qlist=this.randomQuestion(examTest, paperJson);
|
|
||||||
ObjectMapper objectMapper = new ObjectMapper();
|
|
||||||
paperJson=objectMapper.writeValueAsString(qlist);
|
|
||||||
} catch (XaskException e) {
|
|
||||||
log.error("生成试卷错误",e);
|
|
||||||
return error("生成考试试卷错误",e.getMessage(),map);
|
|
||||||
} catch (JsonProcessingException e) {
|
|
||||||
log.error("生成试卷,解析生成json错误",e);
|
|
||||||
return error("生成考试试卷解析错误",e.getMessage(),map);
|
|
||||||
}
|
|
||||||
map.put("paper", paperJson);
|
map.put("paper", paperJson);
|
||||||
long end=System.currentTimeMillis();
|
long end=System.currentTimeMillis();
|
||||||
log.info("开始考试用时="+(end-start)+" ms");
|
log.info("开始考试用时="+(end-start)+" ms");
|
||||||
|
|||||||
@@ -170,7 +170,7 @@ public class ExamQuestionApi extends ApiBaseController {
|
|||||||
//从第二行开始获取数据
|
//从第二行开始获取数据
|
||||||
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("")){
|
if(sheetAt.getRow(1).getCell(0).getStringCellValue().equals("标题(*)")){
|
||||||
row = sheetAt.getRow(1);
|
row = sheetAt.getRow(1);
|
||||||
for (int i = 2;i<sheetAt.getPhysicalNumberOfRows();i++) {
|
for (int i = 2;i<sheetAt.getPhysicalNumberOfRows();i++) {
|
||||||
//获取每一行
|
//获取每一行
|
||||||
@@ -190,56 +190,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 +258,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);
|
||||||
}
|
}
|
||||||
@@ -312,61 +301,45 @@ public class ExamQuestionApi extends ApiBaseController {
|
|||||||
if(row1.getCell(1).getStringCellValue().equals("多选题")){
|
if(row1.getCell(1).getStringCellValue().equals("多选题")){
|
||||||
examQuestion.setType(2);
|
examQuestion.setType(2);
|
||||||
}
|
}
|
||||||
log.debug("row1.getCell(2) = " + row1.getCell(2));
|
examQuestion.setKnowledge(row1.getCell(2).getStringCellValue());
|
||||||
if (row1.getCell(2)==null ||row1.getCell(2).getStringCellValue() == null || row1.getCell(2).getStringCellValue().equals("")){
|
if(row1.getCell(3).getStringCellValue().equals("中")){
|
||||||
examQuestion.setDifficulty(null);
|
examQuestion.setDifficulty(2f);
|
||||||
}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);
|
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());
|
||||||
@@ -396,19 +369,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<=13;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);
|
||||||
}
|
}
|
||||||
@@ -440,30 +413,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);
|
||||||
|
|||||||
@@ -177,7 +177,7 @@ public class StudyCourseApi extends ApiBaseController{
|
|||||||
if (!Objects.isNull(studyCourse)){
|
if (!Objects.isNull(studyCourse)){
|
||||||
pass = true;
|
pass = true;
|
||||||
}
|
}
|
||||||
if (Objects.isNull(studyCourse) && !courseCrowdList.isEmpty() && !StringUtils.isEmpty(audiences)) {
|
if (Objects.isNull(studyCourse) && !courseCrowdList.isEmpty()) {
|
||||||
List<String> audienceList = Arrays.asList(audiences.split(",")); // 此用户所在受众组
|
List<String> audienceList = Arrays.asList(audiences.split(",")); // 此用户所在受众组
|
||||||
log.error("---------------参数------------ audienceList = " + audienceList);
|
log.error("---------------参数------------ audienceList = " + audienceList);
|
||||||
for (CourseCrowd c : courseCrowdList) {
|
for (CourseCrowd c : courseCrowdList) {
|
||||||
@@ -228,7 +228,7 @@ public class StudyCourseApi extends ApiBaseController{
|
|||||||
|
|
||||||
//检查是否已报名
|
//检查是否已报名
|
||||||
StudyCourse sc=service.findByCourseIdAndAid(cid, aid);
|
StudyCourse sc=service.findByCourseIdAndAid(cid, aid);
|
||||||
if(pass==true && sc==null) {
|
if(sc==null) {
|
||||||
//未报名,这里直接报名
|
//未报名,这里直接报名
|
||||||
StudySignup signup=new StudySignup();
|
StudySignup signup=new StudySignup();
|
||||||
signup.setCourseId(cid);
|
signup.setCourseId(cid);
|
||||||
@@ -246,13 +246,13 @@ public class StudyCourseApi extends ApiBaseController{
|
|||||||
signup.setSignTime(LocalDateTime.now());
|
signup.setSignTime(LocalDateTime.now());
|
||||||
sc=service.autoSignup(signup);
|
sc=service.autoSignup(signup);
|
||||||
}
|
}
|
||||||
if (sc !=null){
|
|
||||||
rs.put("studyId", sc.getId());//学习id
|
rs.put("signup",true);
|
||||||
rs.put("progress", sc.getProgress());
|
rs.put("studyId", sc.getId());//学习id
|
||||||
//查询上次学习的是什么资源。查询用户的学习情况
|
rs.put("progress", sc.getProgress());
|
||||||
List<StudyCourseItem> items=studyService.findByStudyId(sc.getId());
|
//查询上次学习的是什么资源。查询用户的学习情况
|
||||||
rs.put("contentStudys",items);//学习的内容
|
List<StudyCourseItem> items=studyService.findByStudyId(sc.getId());
|
||||||
}
|
rs.put("contentStudys",items);//学习的内容
|
||||||
|
|
||||||
return success(rs);
|
return success(rs);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,14 +2,10 @@ package com.xboe.school.study.dao;
|
|||||||
|
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.concurrent.TimeUnit;
|
|
||||||
|
|
||||||
import com.xboe.api.ThirdApi;
|
import com.xboe.api.ThirdApi;
|
||||||
import com.xboe.constants.CacheName;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
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.stereotype.Repository;
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
import com.xboe.core.orm.BaseDao;
|
import com.xboe.core.orm.BaseDao;
|
||||||
@@ -30,9 +26,6 @@ public class StudyCourseDao extends BaseDao<StudyCourse> {
|
|||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
StudyCourseItemDao scItemDao;
|
StudyCourseItemDao scItemDao;
|
||||||
@Autowired
|
|
||||||
StringRedisTemplate redisTemplate;
|
|
||||||
|
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private ThirdApi thirdApi;
|
private ThirdApi thirdApi;
|
||||||
@@ -43,11 +36,6 @@ public class StudyCourseDao extends BaseDao<StudyCourse> {
|
|||||||
* @param total
|
* @param total
|
||||||
*/
|
*/
|
||||||
public void finishCheck(String studyId,String courseId,Integer total,String token){
|
public void finishCheck(String studyId,String courseId,Integer total,String token){
|
||||||
|
|
||||||
if(StringUtils.isNotEmpty(redisTemplate.opsForValue().get(studyId + "_" + courseId + "_" + total))){
|
|
||||||
return ;
|
|
||||||
}
|
|
||||||
|
|
||||||
log.info("------1.完成情况检查---------------studyId = " + studyId + " , courseId = " + courseId + " , total = " + total );
|
log.info("------1.完成情况检查---------------studyId = " + studyId + " , courseId = " + courseId + " , total = " + total );
|
||||||
LocalDateTime now=LocalDateTime.now();
|
LocalDateTime now=LocalDateTime.now();
|
||||||
//已完成的内容
|
//已完成的内容
|
||||||
@@ -62,9 +50,7 @@ public class StudyCourseDao extends BaseDao<StudyCourse> {
|
|||||||
}
|
}
|
||||||
log.info("------3.完成情况检查---------------studyId = " + studyId + " , courseId = " + courseId + " , total = " + total );
|
log.info("------3.完成情况检查---------------studyId = " + studyId + " , courseId = " + courseId + " , total = " + total );
|
||||||
//以下注意,float类型,是否等于100对应
|
//以下注意,float类型,是否等于100对应
|
||||||
float percent=n*100/total;
|
float percent=n*100/total;
|
||||||
|
|
||||||
|
|
||||||
if(n>=total) {
|
if(n>=total) {
|
||||||
//自主报名的课程,代表学习完成
|
//自主报名的课程,代表学习完成
|
||||||
super.updateMultiFieldById(studyId,
|
super.updateMultiFieldById(studyId,
|
||||||
@@ -72,13 +58,11 @@ public class StudyCourseDao extends BaseDao<StudyCourse> {
|
|||||||
UpdateBuilder.create("lastTime",now),
|
UpdateBuilder.create("lastTime",now),
|
||||||
UpdateBuilder.create("finishTime",now),
|
UpdateBuilder.create("finishTime",now),
|
||||||
UpdateBuilder.create("status",StudyCourse.STATUS_FINISH));
|
UpdateBuilder.create("status",StudyCourse.STATUS_FINISH));
|
||||||
redisTemplate.opsForValue().set(studyId + "_" + courseId + "_" + total, "100", 24, TimeUnit.HOURS);
|
|
||||||
}else {
|
}else {
|
||||||
super.updateMultiFieldById(studyId,
|
super.updateMultiFieldById(studyId,
|
||||||
UpdateBuilder.create("progress",percent),
|
UpdateBuilder.create("progress",percent),
|
||||||
UpdateBuilder.create("lastTime",LocalDateTime.now()),
|
UpdateBuilder.create("lastTime",LocalDateTime.now()),
|
||||||
UpdateBuilder.create("status",StudyCourse.STATUS_STUDYING));
|
UpdateBuilder.create("status",StudyCourse.STATUS_STUDYING));
|
||||||
// redisTemplate.opsForValue().set(studyId, String.valueOf(percent), 10, TimeUnit.SECONDS);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
List<StudyCourse> allUserList = thirdApi.getStudyCourseList(studyId ,courseId, token);
|
List<StudyCourse> allUserList = thirdApi.getStudyCourseList(studyId ,courseId, token);
|
||||||
@@ -132,8 +116,4 @@ public class StudyCourseDao extends BaseDao<StudyCourse> {
|
|||||||
|
|
||||||
this.update(update.builder());
|
this.update(update.builder());
|
||||||
}
|
}
|
||||||
|
|
||||||
public StudyCourse findByCourseIdAndAid(String aid, String courseId) {
|
|
||||||
return this.findOne(FieldFilters.eq("aid",aid),FieldFilters.eq("courseId",courseId));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -265,7 +265,6 @@ public class StudyCourseServiceImpl implements IStudyCourseService{
|
|||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public void deleteSignUp(String id,String courseId,String aid) {
|
public void deleteSignUp(String id,String courseId,String aid) {
|
||||||
log.info("参数id:"+id+"参数课程id:"+courseId+"参数用户id:"+aid);
|
|
||||||
//删除课程学习记录主表
|
//删除课程学习记录主表
|
||||||
studyCourseDao.deleteById(id);
|
studyCourseDao.deleteById(id);
|
||||||
//删除学习课程的评估测试结果
|
//删除学习课程的评估测试结果
|
||||||
|
|||||||
@@ -61,10 +61,7 @@ public class StudySignupServiceImpl implements IStudySignupService{
|
|||||||
@Override
|
@Override
|
||||||
public void selfSignup(StudySignup signup) {
|
public void selfSignup(StudySignup signup) {
|
||||||
signup.setSignType(StudySignup.SIGNTYPE_SELF);
|
signup.setSignType(StudySignup.SIGNTYPE_SELF);
|
||||||
StudyCourse sc=studyCourseDao.findByCourseIdAndAid(signup.getAid(), signup.getCourseId());
|
this.addSignup(signup);
|
||||||
if (sc == null){
|
|
||||||
this.addSignup(signup);
|
|
||||||
}
|
|
||||||
//更新课程学习人数
|
//更新课程学习人数
|
||||||
courseDao.updateMultiFieldById(signup.getCourseId(),UpdateBuilder.create("studys", "studys+1",FieldUpdateType.EXPRESSION));
|
courseDao.updateMultiFieldById(signup.getCourseId(),UpdateBuilder.create("studys", "studys+1",FieldUpdateType.EXPRESSION));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ logging.level.org.hibernate.SQL=DEBUG
|
|||||||
logging.level.org.hibernate.type.descriptor.sql.BasicBinder=TRACE
|
logging.level.org.hibernate.type.descriptor.sql.BasicBinder=TRACE
|
||||||
|
|
||||||
# 设置logback.xml位置
|
# 设置logback.xml位置
|
||||||
logging.config=classpath:log/logback-@profileActive@.xml
|
logging.config=classpath:log/logback-dev.xml
|
||||||
|
|
||||||
## 静态文件目录,默认是在static下面,以后独立到nginx下面配置
|
## 静态文件目录,默认是在static下面,以后独立到nginx下面配置
|
||||||
spring.web.resources.static-locations=file:E:/Projects/BOE/10/static
|
spring.web.resources.static-locations=file:E:/Projects/BOE/10/static
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ logging.level.org.hibernate.SQL=ERROR
|
|||||||
#logging.level.org.hibernate.type.descriptor.sql.BasicBinder=TRACE
|
#logging.level.org.hibernate.type.descriptor.sql.BasicBinder=TRACE
|
||||||
|
|
||||||
# 设置logback.xml位置
|
# 设置logback.xml位置
|
||||||
logging.config=classpath:log/logback-@profileActive@.xml
|
logging.config=classpath:log/logback-dev.xml
|
||||||
|
|
||||||
## 静态文件目录,默认是在static下面,以后独立到nginx下面配置
|
## 静态文件目录,默认是在static下面,以后独立到nginx下面配置
|
||||||
spring.web.resources.static-locations=file:E:/Projects/BOE/java/static
|
spring.web.resources.static-locations=file:E:/Projects/BOE/java/static
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ logging.level.org.hibernate.SQL=ERROR
|
|||||||
# logging.level.org.hibernate.type.descriptor.sql.BasicBinder=TRACE
|
# logging.level.org.hibernate.type.descriptor.sql.BasicBinder=TRACE
|
||||||
|
|
||||||
# 设置logback.xml位置
|
# 设置logback.xml位置
|
||||||
logging.config=classpath:log/logback-@profileActive@.xml
|
logging.config=classpath:log/logback-dev.xml
|
||||||
|
|
||||||
## ???????????static????????nginx????
|
## ???????????static????????nginx????
|
||||||
spring.web.resources.static-locations=file:E:/Projects/BOE/java/static
|
spring.web.resources.static-locations=file:E:/Projects/BOE/java/static
|
||||||
@@ -74,12 +74,3 @@ xboe.email.url=https://u.boe.com/api/b1/email/send
|
|||||||
xboe.email.from=boeu_learning@boe.com.cn
|
xboe.email.from=boeu_learning@boe.com.cn
|
||||||
xboe.email.user=
|
xboe.email.user=
|
||||||
xboe.email.security=
|
xboe.email.security=
|
||||||
|
|
||||||
xxl.job.admin.addresses=http://u.boe.com/jobAdmin
|
|
||||||
xxl.job.accessToken=65ddc683-22f5-83b4-de3a-3c97a0a29af0
|
|
||||||
xxl.job.executor.appname=java-servers-job-api
|
|
||||||
xxl.job.executor.port=9995
|
|
||||||
xxl.job.executor.address=
|
|
||||||
xxl.job.executor.ip=
|
|
||||||
xxl.job.executor.logpath=/var/log/xxl-job/dw/
|
|
||||||
xxl.job.executor.logretentiondays=30
|
|
||||||
@@ -80,13 +80,4 @@ xboe.email.from=boeu_learning@boe.com.cn
|
|||||||
xboe.email.user=
|
xboe.email.user=
|
||||||
xboe.email.security=
|
xboe.email.security=
|
||||||
|
|
||||||
boe.domain=https://u-pre.boe.com
|
boe.domain=https://u-pre.boe.com
|
||||||
|
|
||||||
xxl.job.admin.addresses=http://u-pre.boe.com/jobAdmin
|
|
||||||
xxl.job.accessToken=65ddc683-22f5-83b4-de3a-3c97a0a29af0
|
|
||||||
xxl.job.executor.appname=java-servers-job-api
|
|
||||||
xxl.job.executor.port=9995
|
|
||||||
xxl.job.executor.address=
|
|
||||||
xxl.job.executor.ip=
|
|
||||||
xxl.job.executor.logpath=/var/log/xxl-job/dw/
|
|
||||||
xxl.job.executor.logretentiondays=30
|
|
||||||
Reference in New Issue
Block a user