mirror of
https://codeup.aliyun.com/67762337eccfc218f6110e0e/per-boe/java-servers.git
synced 2025-12-08 18:36:51 +08:00
Compare commits
52 Commits
master-104
...
yx1101-tea
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6532cf75e3 | ||
|
|
ad357a61b7 | ||
|
|
ffe232eeb9 | ||
|
|
f273e9df4a | ||
|
|
aab82de81b | ||
|
|
af6efd3151 | ||
|
|
c724080a3c | ||
|
|
aa63a6618f | ||
|
|
d3fcbaeab6 | ||
|
|
82bf84bbaa | ||
|
|
3f59552c2e | ||
|
|
e0d731e296 | ||
|
|
f5c26d02d1 | ||
|
|
0e74f11615 | ||
|
|
3559553484 | ||
|
|
9faa8307ee | ||
|
|
1a6c8f8af9 | ||
|
|
f1b96c8af9 | ||
|
|
5b691c5bb8 | ||
|
|
b0f01c6300 | ||
|
|
e51d4dd8cb | ||
|
|
ea1cda25bd | ||
|
|
3d3e660e68 | ||
|
|
b509b783a1 | ||
|
|
bbda82b8f5 | ||
|
|
fec28f5baf | ||
|
|
469145d25c | ||
|
|
25d8594a2b | ||
|
|
3001c25590 | ||
|
|
95b63155cd | ||
|
|
85517dcd57 | ||
|
|
0e897b5f14 | ||
|
|
39e336d044 | ||
|
|
9da0eae4c0 | ||
|
|
74a36d72a1 | ||
|
|
4ef1b5b1e9 | ||
|
|
33df8b0831 | ||
|
|
b61923233a | ||
|
|
effb45c6d0 | ||
|
|
95aa5f7abe | ||
|
|
3af3c2eedf | ||
|
|
516225f52e | ||
|
|
e3c060b8d9 | ||
|
|
72783fb1ac | ||
|
|
f5f8fcee98 | ||
|
|
003d227ba3 | ||
|
|
e6bd808a3d | ||
|
|
b87eb65b3e | ||
|
|
28af48581e | ||
|
|
57e04f46c0 | ||
|
|
2c967cef0a | ||
|
|
45fce7927d |
@@ -5,6 +5,8 @@ import cn.hutool.core.lang.Opt;
|
|||||||
import cn.hutool.http.HttpRequest;
|
import cn.hutool.http.HttpRequest;
|
||||||
import cn.hutool.json.JSONUtil;
|
import cn.hutool.json.JSONUtil;
|
||||||
import com.xboe.api.vo.*;
|
import com.xboe.api.vo.*;
|
||||||
|
import com.xboe.module.course.dto.CourseParam;
|
||||||
|
import com.xboe.module.course.dto.ScoreParam;
|
||||||
import com.xboe.module.course.vo.StudyCourseVo;
|
import com.xboe.module.course.vo.StudyCourseVo;
|
||||||
import com.xboe.module.course.vo.TeacherInfoVo;
|
import com.xboe.module.course.vo.TeacherInfoVo;
|
||||||
import com.xboe.module.course.vo.TeacherVo;
|
import com.xboe.module.course.vo.TeacherVo;
|
||||||
@@ -13,10 +15,12 @@ import com.xboe.module.exam.entity.ExamTest;
|
|||||||
import com.xboe.school.study.entity.StudyCourse;
|
import com.xboe.school.study.entity.StudyCourse;
|
||||||
import com.xboe.system.user.dao.UserDao;
|
import com.xboe.system.user.dao.UserDao;
|
||||||
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.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import java.io.UnsupportedEncodingException;
|
import java.io.UnsupportedEncodingException;
|
||||||
import java.net.URLEncoder;
|
import java.net.URLEncoder;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
@@ -66,6 +70,20 @@ public class ThirdApi {
|
|||||||
|
|
||||||
@Value("${manageApi.editExam}")
|
@Value("${manageApi.editExam}")
|
||||||
private String editExam;
|
private String editExam;
|
||||||
|
|
||||||
|
@Value("${userBasic.getUserBasicInfo}")
|
||||||
|
private String getUserBasicInfo;
|
||||||
|
|
||||||
|
@Value("${coursesuilt.updateOrSaveCourse}")
|
||||||
|
private String updateOrSaveCourse;
|
||||||
|
@Value("${coursesuilt.syncCourseStudent}")
|
||||||
|
private String syncCourseStudent;
|
||||||
|
@Value("${coursesuilt.syncOnLineScore}")
|
||||||
|
private String syncOnLineScore;
|
||||||
|
@Value("${coursesuilt.updateOnLineStatus}")
|
||||||
|
private String updateOnLineStatus;
|
||||||
|
|
||||||
|
|
||||||
//获取例外人员的id
|
//获取例外人员的id
|
||||||
public List<String> getUserId(){
|
public List<String> getUserId(){
|
||||||
String responseBody = Optional.ofNullable(HttpRequest.get(infarasApiUrl+"?pid=316&type=1").execute() //prod 316
|
String responseBody = Optional.ofNullable(HttpRequest.get(infarasApiUrl+"?pid=316&type=1").execute() //prod 316
|
||||||
@@ -268,4 +286,59 @@ public class ThirdApi {
|
|||||||
}
|
}
|
||||||
return builder.toString();
|
return builder.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 虽然当前已存在接口查询用户基本信息,目前仅仅包括用户名、工号、用户ID
|
||||||
|
*/
|
||||||
|
public List<UserBasicInfo> getUserBasicInfoByUserId(List<String> userIds, HttpServletRequest request) {
|
||||||
|
String token = request.getHeader("Xboe-Access-Token");
|
||||||
|
if (StringUtils.isEmpty(token)) {
|
||||||
|
token = request.getHeader("token");
|
||||||
|
}
|
||||||
|
if (StringUtils.isEmpty(token)) {
|
||||||
|
token = request.getHeader("x-access-token");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 将userIds列表转换为逗号分隔的字符串
|
||||||
|
String userIdsStr = userIds.stream()
|
||||||
|
.collect(Collectors.joining(","));
|
||||||
|
String url = getUserBasicInfo +"?userIds=" + userIdsStr;
|
||||||
|
|
||||||
|
String respStr = Optional.ofNullable(HttpRequest
|
||||||
|
.get(url)
|
||||||
|
.header("token", token)
|
||||||
|
.execute().body()).orElseThrow(() -> new RuntimeException("用户中心用户数据获取失败"));
|
||||||
|
|
||||||
|
UserBasicInfoResult userBasicInfoResult = JSONUtil.parseObj(respStr).toBean(UserBasicInfoResult.class);
|
||||||
|
List<UserBasicInfo> basicInfos = userBasicInfoResult.getResult();
|
||||||
|
return basicInfos;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void updateOrSaveCourse(CourseParam param, String token){
|
||||||
|
log.info("---------------准备同步在线课到讲师管理完毕 ------- param " + param);
|
||||||
|
String resp = Optional.ofNullable(
|
||||||
|
HttpRequest.post(updateOrSaveCourse).body(JSONUtil.toJsonStr(param)).header("token", token).execute()
|
||||||
|
.body()).orElseThrow(() -> new RuntimeException("token校验失败"));
|
||||||
|
log.info("updateOrSaveCourse = " + resp);
|
||||||
|
}
|
||||||
|
public void syncCourseStudent(Long courseId, String token){
|
||||||
|
String resp = Optional.ofNullable(
|
||||||
|
HttpRequest.post(syncCourseStudent).body(JSONUtil.toJsonStr(courseId)).header("token", token).execute()
|
||||||
|
.body()).orElseThrow(() -> new RuntimeException("token校验失败"));
|
||||||
|
log.info("syncCourseStudent = " + resp);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void syncOnLineScore(ScoreParam param, String token) {
|
||||||
|
String resp = Optional.ofNullable(
|
||||||
|
HttpRequest.post(syncOnLineScore).body(JSONUtil.toJsonStr(param)).header("token", token).execute()
|
||||||
|
.body()).orElseThrow(() -> new RuntimeException("token校验失败"));
|
||||||
|
log.info("syncOnLineScore = " + resp);
|
||||||
|
}
|
||||||
|
public void updateOnLineStatus(CourseParam param, String token){
|
||||||
|
String resp = Optional.ofNullable(
|
||||||
|
HttpRequest.post(updateOnLineStatus).body(JSONUtil.toJsonStr(param)).header("token", token).execute()
|
||||||
|
.body()).orElseThrow(() -> new RuntimeException("token校验失败"));
|
||||||
|
log.info("updateOrSaveCourse = " + resp);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,23 @@
|
|||||||
|
package com.xboe.api.vo;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class UserBasicInfo {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户ID
|
||||||
|
*/
|
||||||
|
private String userId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户名。
|
||||||
|
*/
|
||||||
|
private String userName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 工号。
|
||||||
|
*/
|
||||||
|
private String workNum;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
package com.xboe.api.vo;
|
||||||
|
|
||||||
|
import cn.hutool.json.JSONUtil;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@Slf4j
|
||||||
|
@Builder
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class UserBasicInfoResult {
|
||||||
|
|
||||||
|
private String error;
|
||||||
|
private String message;
|
||||||
|
private String permissions;
|
||||||
|
private List<UserBasicInfo> result;
|
||||||
|
private int status;
|
||||||
|
private Date timestamp;
|
||||||
|
|
||||||
|
public UserBasicInfoResult success() {
|
||||||
|
if (this.status != 200) {
|
||||||
|
log.error("获取用户基本信息失败----{}", JSONUtil.toJsonPrettyStr(this));
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -12,13 +12,16 @@ 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 * ?")
|
||||||
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 ?")
|
||||||
public void refreshLastQuarterStatistics() {
|
public void refreshLastQuarterStatistics() {
|
||||||
|
|||||||
@@ -15,7 +15,9 @@ 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" +
|
||||||
@@ -24,8 +26,7 @@ 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.sys_update_time DESC \n" +
|
"ORDER BY bcvr.rise_rank_time DESC;";
|
||||||
"LIMIT 2;";
|
|
||||||
|
|
||||||
List<Object[]> list = this.sqlFindList(sql, caseId);
|
List<Object[]> list = this.sqlFindList(sql, caseId);
|
||||||
|
|
||||||
|
|||||||
@@ -44,6 +44,7 @@ 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.*;
|
||||||
@@ -416,14 +417,36 @@ 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());
|
||||||
@@ -483,7 +506,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)) {
|
||||||
// 拼接生成浏览量排行榜的标签
|
// 拼接生成浏览量排行榜的标签
|
||||||
@@ -1181,15 +1204,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);
|
||||||
|
|
||||||
@@ -1231,7 +1254,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_praise=praise where deleted=0");
|
int i = casesDao.sqlUpdate("update boe_cases set last_quarter_views=views,last_quarter_praises=praises where deleted=0");
|
||||||
log.info("每季案例相关定时任务执行完成,boe_cases更新数据量为条数为"+i);
|
log.info("每季案例相关定时任务执行完成,boe_cases更新数据量为条数为"+i);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1277,21 +1300,24 @@ public class CasesServiceImpl implements ICasesService {
|
|||||||
pageSize = 10;
|
pageSize = 10;
|
||||||
}
|
}
|
||||||
|
|
||||||
LocalDateTime startTime = month.withDayOfMonth(1);
|
LocalDateTime startTime = month.withDayOfMonth(1).withHour(0).withMinute(0).withSecond(0);
|
||||||
LocalDateTime endTime = month.plusMonths(1).withDayOfMonth(1).withMinute(0);
|
LocalDateTime endTime = YearMonth.from(month).atEndOfMonth().atTime(23, 59, 59);
|
||||||
|
|
||||||
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) {
|
||||||
@@ -1300,6 +1326,26 @@ 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,10 @@ import java.util.ArrayList;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
|
||||||
|
import com.xboe.api.ThirdApi;
|
||||||
|
import com.xboe.module.course.dto.CourseParam;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
@@ -55,6 +58,9 @@ public class CourseAuditApi extends ApiBaseController{
|
|||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private ICourseContentService ccontentService;
|
private ICourseContentService ccontentService;
|
||||||
|
@Resource
|
||||||
|
private ThirdApi thirdApi;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 教师需要审核的课程
|
* 教师需要审核的课程
|
||||||
@@ -315,7 +321,7 @@ public class CourseAuditApi extends ApiBaseController{
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@PostMapping("/hrbp-submit-audit")
|
@PostMapping("/hrbp-submit-audit")
|
||||||
public JsonResponse<Boolean> hrbpAudit(String auditId,String courseId,String title,Boolean pass,String remark){
|
public JsonResponse<Boolean> hrbpAudit(String auditId,String courseId,String title,Boolean pass,String remark, HttpServletRequest request){
|
||||||
if(StringUtils.isBlank(auditId)){
|
if(StringUtils.isBlank(auditId)){
|
||||||
return badRequest("参数错误");
|
return badRequest("参数错误");
|
||||||
}
|
}
|
||||||
@@ -347,6 +353,14 @@ public class CourseAuditApi extends ApiBaseController{
|
|||||||
try {
|
try {
|
||||||
CurrentUser cu=getCurrent();
|
CurrentUser cu=getCurrent();
|
||||||
service.hrbpSubmitAudit(auditId, courseId,open, pass,cu.getAccountId(),cu.getName(), remark);
|
service.hrbpSubmitAudit(auditId, courseId,open, pass,cu.getAccountId(),cu.getName(), remark);
|
||||||
|
|
||||||
|
if (pass){
|
||||||
|
//修改在线课开课状态=已开课
|
||||||
|
String token = request.getHeader("Xboe-Access-Token");
|
||||||
|
CourseParam param = new CourseParam();
|
||||||
|
param.setId(courseId);
|
||||||
|
thirdApi.updateOnLineStatus(param,token);
|
||||||
|
}
|
||||||
return success(true);
|
return success(true);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("HRBP审核提交处理错误",e);
|
log.error("HRBP审核提交处理错误",e);
|
||||||
@@ -378,7 +392,8 @@ public class CourseAuditApi extends ApiBaseController{
|
|||||||
*/
|
*/
|
||||||
@PostMapping("/submit-publish")
|
@PostMapping("/submit-publish")
|
||||||
@AutoLog(module = "课程",action = "默认管理员提交发布",info = "")
|
@AutoLog(module = "课程",action = "默认管理员提交发布",info = "")
|
||||||
public JsonResponse<Boolean> submitAndPublish(@RequestBody CourseFullDto dto){
|
public JsonResponse<Boolean> submitAndPublish(@RequestBody CourseFullDto dto, HttpServletRequest request){
|
||||||
|
log.info("---------------提交并直接发布,用于默认管理直接操作 -------");
|
||||||
if(dto.getCourse()==null){
|
if(dto.getCourse()==null){
|
||||||
return badRequest("无课程信息");
|
return badRequest("无课程信息");
|
||||||
}
|
}
|
||||||
@@ -402,12 +417,22 @@ public class CourseAuditApi extends ApiBaseController{
|
|||||||
if(StringUtils.isBlank(dto.getCourse().getOrgId())) {
|
if(StringUtils.isBlank(dto.getCourse().getOrgId())) {
|
||||||
return badRequest("请选择资源归属");
|
return badRequest("请选择资源归属");
|
||||||
}
|
}
|
||||||
|
String token = request.getHeader("Xboe-Access-Token");
|
||||||
|
|
||||||
CurrentUser cuser=getCurrent();
|
CurrentUser cuser=getCurrent();
|
||||||
dto.getCourse().setStatus(Course.STATUS_AUDIT_FINISH);//设置为审核通过状态
|
dto.getCourse().setStatus(Course.STATUS_AUDIT_FINISH);//设置为审核通过状态
|
||||||
dto.getCourse().setEnabled(true);//设置启用状态问题
|
dto.getCourse().setEnabled(true);//设置启用状态问题
|
||||||
dto.getCourse().setPublished(false);//重新提交审核设置为未发布状态
|
dto.getCourse().setPublished(false);//重新提交审核设置为未发布状态
|
||||||
try {
|
try {
|
||||||
|
|
||||||
courseService.submitAndPublish(dto,cuser.getAccountId(),cuser.getName());
|
courseService.submitAndPublish(dto,cuser.getAccountId(),cuser.getName());
|
||||||
|
log.info("---------------在线课开始同步到讲师管理 ------- token = " + token);
|
||||||
|
CourseParam param = new CourseParam();
|
||||||
|
param.setId(dto.getCourse().getId());
|
||||||
|
param.setOrgId(dto.getCourse().getOrgId());
|
||||||
|
param.setOrgName(dto.getCourse().getOrgName());
|
||||||
|
thirdApi.updateOrSaveCourse(param,token);
|
||||||
|
log.info("---------------在线课同步到讲师管理完毕 -------");
|
||||||
return success(true);
|
return success(true);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("默认管理员提交直接发布处理失败",e);
|
log.error("默认管理员提交直接发布处理失败",e);
|
||||||
|
|||||||
@@ -4,13 +4,10 @@ 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.PathVariable;
|
import org.springframework.web.bind.annotation.*;
|
||||||
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;
|
||||||
@@ -78,6 +75,21 @@ 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
|
||||||
|
|||||||
@@ -7,6 +7,8 @@ import javax.annotation.Resource;
|
|||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
|
||||||
|
import com.xboe.api.ThirdApi;
|
||||||
|
import com.xboe.module.course.dto.*;
|
||||||
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.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
@@ -26,11 +28,6 @@ import com.xboe.data.dto.UserOrgIds;
|
|||||||
import com.xboe.data.outside.IOutSideDataService;
|
import com.xboe.data.outside.IOutSideDataService;
|
||||||
import com.xboe.data.service.IDataUserSyncService;
|
import com.xboe.data.service.IDataUserSyncService;
|
||||||
import com.xboe.module.assistance.service.IEmailService;
|
import com.xboe.module.assistance.service.IEmailService;
|
||||||
import com.xboe.module.course.dto.CourseExportDto;
|
|
||||||
import com.xboe.module.course.dto.CourseFullDto;
|
|
||||||
import com.xboe.module.course.dto.CourseQueryDto;
|
|
||||||
import com.xboe.module.course.dto.CourseTeacherAndCourse;
|
|
||||||
import com.xboe.module.course.dto.CourseTeacherExportDto;
|
|
||||||
import com.xboe.module.course.entity.Course;
|
import com.xboe.module.course.entity.Course;
|
||||||
import com.xboe.module.course.entity.CourseContent;
|
import com.xboe.module.course.entity.CourseContent;
|
||||||
import com.xboe.module.course.entity.CourseCrowd;
|
import com.xboe.module.course.entity.CourseCrowd;
|
||||||
@@ -100,7 +97,8 @@ public class CourseManageApi extends ApiBaseController{
|
|||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
IDataUserSyncService userSyncService;
|
IDataUserSyncService userSyncService;
|
||||||
|
@Resource
|
||||||
|
private ThirdApi thirdApi;
|
||||||
|
|
||||||
// @PostMapping("/test")
|
// @PostMapping("/test")
|
||||||
// public JsonResponse<PageList<Course>> findTest(Pagination pager,CourseQueryDto dto){
|
// public JsonResponse<PageList<Course>> findTest(Pagination pager,CourseQueryDto dto){
|
||||||
@@ -271,7 +269,7 @@ public class CourseManageApi extends ApiBaseController{
|
|||||||
*/
|
*/
|
||||||
@PostMapping("/save")
|
@PostMapping("/save")
|
||||||
@AutoLog(module = "课程",action = "保存课程基本信息",info = "")
|
@AutoLog(module = "课程",action = "保存课程基本信息",info = "")
|
||||||
public JsonResponse<CourseFullDto> saveCourseFull(@RequestBody CourseFullDto dto){
|
public JsonResponse<CourseFullDto> saveCourseFull(@RequestBody CourseFullDto dto, HttpServletRequest request){
|
||||||
if(dto.getCourse()==null){
|
if(dto.getCourse()==null){
|
||||||
return badRequest("无课程信息");
|
return badRequest("无课程信息");
|
||||||
}
|
}
|
||||||
@@ -302,7 +300,14 @@ public class CourseManageApi extends ApiBaseController{
|
|||||||
dto.getCourse().setStatus(Course.STATUS_NONE);
|
dto.getCourse().setStatus(Course.STATUS_NONE);
|
||||||
courseService.update(dto);
|
courseService.update(dto);
|
||||||
}
|
}
|
||||||
|
String token = request.getHeader("Xboe-Access-Token");
|
||||||
|
log.info("---------------在线课开始同步到讲师管理 ------- token = " + token);
|
||||||
|
CourseParam param = new CourseParam();
|
||||||
|
param.setId(dto.getCourse().getId());
|
||||||
|
param.setOrgId(dto.getCourse().getOrgId());
|
||||||
|
param.setOrgName(dto.getCourse().getOrgName());
|
||||||
|
thirdApi.updateOrSaveCourse(param,token);
|
||||||
|
log.info("---------------在线课同步到讲师管理完毕 -------");
|
||||||
return success(dto);
|
return success(dto);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("整体保存课程信息错误",e);
|
log.error("整体保存课程信息错误",e);
|
||||||
|
|||||||
@@ -1,64 +1,50 @@
|
|||||||
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.net.URLEncoder;
|
|
||||||
import java.nio.file.Files;
|
|
||||||
import java.nio.file.Path;
|
|
||||||
import java.nio.file.Paths;
|
|
||||||
import java.nio.file.StandardCopyOption;
|
|
||||||
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 javax.servlet.http.HttpServletResponse;
|
|
||||||
|
|
||||||
import com.xboe.api.ThirdApi;
|
import com.xboe.api.ThirdApi;
|
||||||
import com.xboe.core.orm.FieldFilters;
|
import com.xboe.api.vo.UserBasicInfo;
|
||||||
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;
|
||||||
import com.xboe.core.JsonResponse;
|
import com.xboe.core.JsonResponse;
|
||||||
import com.xboe.core.api.ApiBaseController;
|
import com.xboe.core.api.ApiBaseController;
|
||||||
|
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.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;
|
||||||
import com.xboe.module.course.service.ICourseService;
|
import com.xboe.module.course.service.ICourseService;
|
||||||
import com.xboe.module.course.service.ICourseTeacherService;
|
import com.xboe.module.course.service.ICourseTeacherService;
|
||||||
import com.xboe.module.course.vo.CourseStudyVo;
|
import com.xboe.module.course.vo.CourseStudyVo;
|
||||||
|
import com.xboe.module.course.vo.TeacherVo;
|
||||||
import com.xboe.module.teacher.entity.Teacher;
|
import com.xboe.module.teacher.entity.Teacher;
|
||||||
import com.xboe.module.teacher.service.ITeacherService;
|
import com.xboe.module.teacher.service.ITeacherService;
|
||||||
import com.xboe.module.usergroup.service.IUserGroupService;
|
import com.xboe.module.usergroup.service.IUserGroupService;
|
||||||
|
import com.xboe.school.study.dao.StudyCourseDao;
|
||||||
import com.xboe.school.study.entity.StudyCourse;
|
import com.xboe.school.study.entity.StudyCourse;
|
||||||
import com.xboe.school.study.entity.StudyCourseItem;
|
import com.xboe.school.study.entity.StudyCourseItem;
|
||||||
|
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.IStudyService;
|
||||||
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.data.redis.core.StringRedisTemplate;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
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;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -365,13 +351,15 @@ public class CoursePortalApi extends ApiBaseController{
|
|||||||
}
|
}
|
||||||
//作业导出
|
//作业导出
|
||||||
@GetMapping("/export")
|
@GetMapping("/export")
|
||||||
public JsonResponse<String> export(String courseName,String courseId,String contentId,String name,Integer status) throws IOException {
|
public JsonResponse<String> export(String courseId,String courseName,String contentId,String name,Integer status,HttpServletRequest request) throws IOException {
|
||||||
Map<String, String>map=new HashMap<>();
|
Map<String, String>map=new HashMap<>();
|
||||||
List<String> userIds = studyCourseDao.findList(FieldFilters.eq("courseId", courseId)).stream().filter(Objects::nonNull).map(StudyCourse::getAid).collect(Collectors.toList());
|
List<String> userIds = studyCourseDao.findList(FieldFilters.eq("courseId", courseId)).stream().filter(Objects::nonNull).map(StudyCourse::getAid).collect(Collectors.toList());
|
||||||
if (userIds.isEmpty()){
|
if (userIds.isEmpty()){
|
||||||
return error("查询不到用户");
|
return error("查询不到用户");
|
||||||
}
|
}
|
||||||
List<User>user=studyService.getUserNo(userIds);
|
|
||||||
|
List <UserBasicInfo> userBasicInfoList =thirdApi.getUserBasicInfoByUserId(userIds,request);
|
||||||
|
|
||||||
try {//筛选出的人员
|
try {//筛选出的人员
|
||||||
List<StudyCourseItem> list = studyService.getList(courseId, contentId, name, status);
|
List<StudyCourseItem> list = studyService.getList(courseId, contentId, name, status);
|
||||||
if(list.isEmpty()){
|
if(list.isEmpty()){
|
||||||
@@ -383,12 +371,12 @@ public class CoursePortalApi extends ApiBaseController{
|
|||||||
return success("暂无数据");
|
return success("暂无数据");
|
||||||
}
|
}
|
||||||
studyHomeWorks.forEach(e->{
|
studyHomeWorks.forEach(e->{
|
||||||
user.forEach(u->{
|
userBasicInfoList.forEach(u->{
|
||||||
if(u.getId().equals(s.getAid())){
|
if(u.getUserId().equals(s.getAid())){
|
||||||
//取后缀
|
//取后缀
|
||||||
int dotIndex = e.getFilePath().lastIndexOf('.'); // 查找最后一个'.'的位置
|
int dotIndex = e.getFilePath().lastIndexOf('.'); // 查找最后一个'.'的位置
|
||||||
String extension = e.getFilePath().substring(dotIndex);
|
String extension = e.getFilePath().substring(dotIndex);
|
||||||
map.put(u.getName()+"-"+u.getUserNo()+extension,"/home/www/elearning/upload"+e.getFilePath());
|
map.put(u.getUserName()+"-"+u.getWorkNum()+extension,"/home/www/elearning/upload"+e.getFilePath());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -404,60 +392,36 @@ public class CoursePortalApi extends ApiBaseController{
|
|||||||
if (totalFileSize > 2L * 1024 * 1024 * 1024) {
|
if (totalFileSize > 2L * 1024 * 1024 * 1024) {
|
||||||
return success("您要下载的作业过大,请分批下载或联系管理员!");
|
return success("您要下载的作业过大,请分批下载或联系管理员!");
|
||||||
}
|
}
|
||||||
|
// 创建压缩文件
|
||||||
|
String zipFilePath = "/home/www/elearning/upload/saveZip/" + courseName+"【作业】" + ".zip";
|
||||||
|
createZipFile(map, zipFilePath);
|
||||||
|
return success(zipFilePath);
|
||||||
|
}
|
||||||
|
private static void createZipFile(Map<String, String> map, String zipFilePath) throws IOException {
|
||||||
|
try (ZipOutputStream zos = new ZipOutputStream(new FileOutputStream(zipFilePath))) {
|
||||||
|
for (Map.Entry<String, String> entry : map.entrySet()) {
|
||||||
|
String key = entry.getKey();
|
||||||
|
String value = entry.getValue();
|
||||||
|
|
||||||
// String encodedFilename = URLEncoder.encode(courseName+"【作业】.zip")
|
File file = new File(value);
|
||||||
// .replace("+", "%20") // 空格替换为"%20"
|
if (!file.exists()) {
|
||||||
// .replace("%2F", "/"); // 解决斜杠问题
|
continue;
|
||||||
// StringBuilder contentDispositionValue = new StringBuilder();
|
}
|
||||||
// contentDispositionValue.append("attachment; filename=\"")
|
|
||||||
// .append(encodedFilename)
|
|
||||||
// .append("\"")
|
|
||||||
// .append("; filename*=utf-8''")
|
|
||||||
// .append(encodedFilename);
|
|
||||||
//
|
|
||||||
// // 设置响应类型和Content-Disposition头
|
|
||||||
// response.setContentType("application/zip");
|
|
||||||
|
|
||||||
// 创建一个临时文件用于存储ZIP文件
|
byte[] buffer = new byte[1024];
|
||||||
File tempZipFile = new File("/home/www/elearning/upload/temp.zip");
|
FileInputStream fis = new FileInputStream(file);
|
||||||
|
ZipEntry zipEntry = new ZipEntry(key);
|
||||||
|
zos.putNextEntry(zipEntry);
|
||||||
|
|
||||||
try (ZipOutputStream zos = new ZipOutputStream(new FileOutputStream(tempZipFile))) {
|
int length;
|
||||||
for (Map.Entry<String, String> e : map.entrySet()) {
|
while ((length = fis.read(buffer)) > 0) {
|
||||||
File fileToZip = new File(e.getValue());
|
zos.write(buffer, 0, length);
|
||||||
// 添加 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();
|
zos.closeEntry();
|
||||||
|
fis.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// 将临时文件移动到指定位置
|
|
||||||
Path source = tempZipFile.toPath();
|
|
||||||
//生成uuid
|
|
||||||
String uuid = UUID.randomUUID().toString();
|
|
||||||
Path destination = Paths.get("/home/www/elearning/upload/saveZip/" + uuid + ".zip");
|
|
||||||
|
|
||||||
// 删除目标文件如果已存在
|
|
||||||
if (Files.exists(destination)) {
|
|
||||||
Files.delete(destination);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 移动文件
|
|
||||||
Files.copy(source, destination, StandardCopyOption.REPLACE_EXISTING);
|
|
||||||
|
|
||||||
// 返回文件路径给前端
|
|
||||||
String filePath = destination.toAbsolutePath().toString();
|
|
||||||
return success(filePath);
|
|
||||||
}
|
}
|
||||||
@GetMapping("/detail-study")
|
@GetMapping("/detail-study")
|
||||||
public JsonResponse<List<CourseStudyVo>> detailStudy(String courseId, String aid){
|
public JsonResponse<List<CourseStudyVo>> detailStudy(String courseId, String aid){
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ 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;
|
||||||
@@ -28,6 +29,7 @@ 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";
|
||||||
@@ -105,16 +107,16 @@ public class CourseWareApi extends ApiBaseController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
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);
|
||||||
@@ -131,16 +133,22 @@ 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)) {
|
||||||
return badRequest("验证错误");
|
// log.info("请求头时间和解析后的时间对比:"+"解析时间:"+time+" 请求头时间:"+cookieTime);
|
||||||
}
|
// 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("验证错误");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,10 @@
|
|||||||
|
package com.xboe.module.course.dto;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class CourseParam {
|
||||||
|
private String id;
|
||||||
|
private String orgId;
|
||||||
|
private String orgName;
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
package com.xboe.module.course.dto;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class ScoreParam {
|
||||||
|
private Long courseId;
|
||||||
|
private Float score;
|
||||||
|
}
|
||||||
@@ -85,4 +85,6 @@ public interface ICourseContentService{
|
|||||||
|
|
||||||
void updateProcessVideo(String contentId, String courseId, Float processVideo);
|
void updateProcessVideo(String contentId, String courseId, Float processVideo);
|
||||||
|
|
||||||
|
Object getPaperContentOfOnline(String courseExamId);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,23 +1,17 @@
|
|||||||
package com.xboe.module.course.service.impl;
|
package com.xboe.module.course.service.impl;
|
||||||
|
|
||||||
import java.sql.PreparedStatement;
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||||
import java.sql.SQLException;
|
import com.fasterxml.jackson.core.type.TypeReference;
|
||||||
import java.util.List;
|
import com.fasterxml.jackson.databind.DeserializationFeature;
|
||||||
|
import com.fasterxml.jackson.databind.JsonNode;
|
||||||
import javax.annotation.Resource;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import javax.transaction.Transactional;
|
import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||||
|
|
||||||
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.CourseAssessDao;
|
import com.xboe.module.course.dao.*;
|
||||||
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;
|
||||||
@@ -25,8 +19,21 @@ 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 {
|
||||||
|
|
||||||
@@ -45,6 +52,12 @@ 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
|
||||||
@@ -78,6 +91,9 @@ 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) {
|
||||||
@@ -188,4 +204,68 @@ 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("标题(*)")){
|
if(sheetAt.getRow(1).getCell(0).getStringCellValue().equals("标题(*)") && !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,45 +190,56 @@ public class ExamQuestionApi extends ApiBaseController {
|
|||||||
if(row1.getCell(1).getStringCellValue().equals("多选题")){
|
if(row1.getCell(1).getStringCellValue().equals("多选题")){
|
||||||
examQuestion.setType(2);
|
examQuestion.setType(2);
|
||||||
}
|
}
|
||||||
examQuestion.setKnowledge(row1.getCell(2).getStringCellValue());
|
if(row1.getCell(2).getStringCellValue().equals("中")){
|
||||||
if(row1.getCell(3).getStringCellValue().equals("中")){
|
|
||||||
examQuestion.setDifficulty(2f);
|
examQuestion.setDifficulty(2f);
|
||||||
}
|
}else if(row1.getCell(2).getStringCellValue().equals("难")){
|
||||||
if(row1.getCell(3).getStringCellValue().equals("难")){
|
|
||||||
examQuestion.setDifficulty(3f);
|
examQuestion.setDifficulty(3f);
|
||||||
}
|
} else if(row1.getCell(2).getStringCellValue().equals("易")){
|
||||||
if(row1.getCell(3).getStringCellValue().equals("低")){
|
|
||||||
examQuestion.setDifficulty(1f);
|
examQuestion.setDifficulty(1f);
|
||||||
|
}else if(row1.getCell(2).getStringCellValue().equals("")){
|
||||||
|
examQuestion.setDifficulty(null);
|
||||||
}
|
}
|
||||||
Cell cell = row1.getCell(4);
|
Cell cell = row1.getCell(3);
|
||||||
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(6).getStringCellValue());
|
examQuestion.setAnswer(row1.getCell(5).getStringCellValue());
|
||||||
examQuestion.setDefaultScore(Float.valueOf(row1.getCell(4).getStringCellValue()));
|
if (row1.getCell(3).getStringCellValue().isEmpty()){
|
||||||
Cell cell1 = row1.getCell(5, Row.MissingCellPolicy.CREATE_NULL_AS_BLANK);
|
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);
|
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=7;j<=13;j++) {
|
for (int j=6;j<=12;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(6).getStringCellValue().contains(substring)) {
|
if (row1.getCell(5).getStringCellValue().contains(substring)) {
|
||||||
|
|
||||||
examOption.setIsAnswer(true);
|
examOption.setIsAnswer(true);
|
||||||
examOption.setScore(Float.valueOf(row1.getCell(4).getStringCellValue()));
|
if (row1.getCell(3).getStringCellValue().isEmpty()){
|
||||||
|
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()) {
|
||||||
examOption.setScore(Float.valueOf(row1.getCell(4).getStringCellValue()));
|
if (row1.getCell(3).getStringCellValue().isEmpty()){
|
||||||
|
examOption.setScore(null);
|
||||||
|
}else {
|
||||||
|
examOption.setScore(Float.valueOf(row1.getCell(3).getStringCellValue()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
examOption.setOptions(row.getCell(j).getStringCellValue());
|
examOption.setOptions(row.getCell(j).getStringCellValue());
|
||||||
@@ -258,19 +269,19 @@ public class ExamQuestionApi extends ApiBaseController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
examQuestion.setDefaultScore(Float.valueOf(max));
|
examQuestion.setDefaultScore(Float.valueOf(max));
|
||||||
Cell cell1 = row1.getCell(5, Row.MissingCellPolicy.CREATE_NULL_AS_BLANK);
|
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());
|
||||||
examQuestion.setAnswer(row1.getCell(6).getStringCellValue());
|
examQuestion.setAnswer(row1.getCell(5).getStringCellValue());
|
||||||
List<ExamOption> examOptions = new ArrayList<>();
|
List<ExamOption> examOptions = new ArrayList<>();
|
||||||
//A
|
//A
|
||||||
for (int j=7;j<=13;j++){
|
for (int j=6;j<=12;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-7]));
|
examOption.setScore(Float.valueOf(strings[j-6]));
|
||||||
if(examOption!=null && StringUtil.isNotBlank(examOption.getContent())){
|
if(examOption!=null && StringUtil.isNotBlank(examOption.getContent())){
|
||||||
examOptions.add(examOption);
|
examOptions.add(examOption);
|
||||||
}
|
}
|
||||||
@@ -301,45 +312,61 @@ public class ExamQuestionApi extends ApiBaseController {
|
|||||||
if(row1.getCell(1).getStringCellValue().equals("多选题")){
|
if(row1.getCell(1).getStringCellValue().equals("多选题")){
|
||||||
examQuestion.setType(2);
|
examQuestion.setType(2);
|
||||||
}
|
}
|
||||||
examQuestion.setKnowledge(row1.getCell(2).getStringCellValue());
|
log.debug("row1.getCell(2) = " + row1.getCell(2));
|
||||||
if(row1.getCell(3).getStringCellValue().equals("中")){
|
if (row1.getCell(2)==null ||row1.getCell(2).getStringCellValue() == null || row1.getCell(2).getStringCellValue().equals("")){
|
||||||
examQuestion.setDifficulty(2f);
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if(row1.getCell(3).getStringCellValue().equals("难")){
|
Cell cell = row1.getCell(3);
|
||||||
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(6).getStringCellValue());
|
examQuestion.setAnswer(row1.getCell(5).getStringCellValue());
|
||||||
examQuestion.setDefaultScore(Float.valueOf(row1.getCell(4).getStringCellValue()));
|
if (row1.getCell(3).getStringCellValue().isEmpty()){
|
||||||
Cell cell1 = row1.getCell(5, Row.MissingCellPolicy.CREATE_NULL_AS_BLANK);
|
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);
|
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=7;j<=13;j++) {
|
for (int j=6;j<=12;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(6).getStringCellValue().contains(substring)) {
|
if (row1.getCell(5).getStringCellValue().contains(substring)) {
|
||||||
|
|
||||||
examOption.setIsAnswer(true);
|
examOption.setIsAnswer(true);
|
||||||
examOption.setScore(Float.valueOf(row1.getCell(4).getStringCellValue()));
|
if (row1.getCell(3).getStringCellValue().isEmpty()){
|
||||||
|
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()) {
|
||||||
examOption.setScore(Float.valueOf(row1.getCell(4).getStringCellValue()));
|
if (row1.getCell(3).getStringCellValue().isEmpty()){
|
||||||
|
examOption.setScore(null);
|
||||||
|
}else {
|
||||||
|
examOption.setScore(Float.valueOf(row1.getCell(3).getStringCellValue()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
examOption.setOptions(row.getCell(j).getStringCellValue());
|
examOption.setOptions(row.getCell(j).getStringCellValue());
|
||||||
@@ -369,19 +396,19 @@ public class ExamQuestionApi extends ApiBaseController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
examQuestion.setDefaultScore(Float.valueOf(max));
|
examQuestion.setDefaultScore(Float.valueOf(max));
|
||||||
Cell cell1 = row1.getCell(5, Row.MissingCellPolicy.CREATE_NULL_AS_BLANK);
|
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());
|
||||||
examQuestion.setAnswer(row1.getCell(6).getStringCellValue());
|
examQuestion.setAnswer(row1.getCell(5).getStringCellValue());
|
||||||
List<ExamOption> examOptions = new ArrayList<>();
|
List<ExamOption> examOptions = new ArrayList<>();
|
||||||
//A
|
//A
|
||||||
for (int j=7;j<=13;j++){
|
for (int j=6;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-7]));
|
examOption.setScore(Float.valueOf(strings[j-6]));
|
||||||
if(examOption!=null && StringUtil.isNotBlank(examOption.getContent())){
|
if(examOption!=null && StringUtil.isNotBlank(examOption.getContent())){
|
||||||
examOptions.add(examOption);
|
examOptions.add(examOption);
|
||||||
}
|
}
|
||||||
@@ -413,27 +440,30 @@ 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);
|
||||||
examQuestion1.setKnowledge(row2.getCell(1).getStringCellValue());
|
System.out.println("1+++++++"+row2.getCell(1));
|
||||||
if(row2.getCell(2).getStringCellValue().equals("中")){
|
if(row2.getCell(1).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(3);
|
Cell cell1 = row2.getCell(2);
|
||||||
cell1.setCellType(CellType.STRING);
|
cell1.setCellType(CellType.STRING);
|
||||||
examQuestion1.setDefaultScore(Float.valueOf(cell1.getStringCellValue()));
|
if (row2.getCell(2).getStringCellValue().isEmpty()){
|
||||||
|
examQuestion1.setDefaultScore(null);
|
||||||
if(row2.getCell(4)!=null) {
|
}else {
|
||||||
examQuestion1.setAnalysis(row2.getCell(4).getStringCellValue());
|
examQuestion1.setDefaultScore(Float.valueOf(row2.getCell(2).getStringCellValue()));
|
||||||
|
}
|
||||||
|
if(row2.getCell(3)!=null) {
|
||||||
|
examQuestion1.setAnalysis(row2.getCell(3).getStringCellValue());
|
||||||
}else {
|
}else {
|
||||||
examQuestion1.setAnalysis("");
|
examQuestion1.setAnalysis("");
|
||||||
}
|
}
|
||||||
|
|
||||||
String cvalue=row2.getCell(5).getStringCellValue();
|
String cvalue=row2.getCell(4).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);
|
||||||
|
|||||||
@@ -1,7 +1,10 @@
|
|||||||
package com.xboe.module.interaction.api;
|
package com.xboe.module.interaction.api;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
|
||||||
|
import com.xboe.api.ThirdApi;
|
||||||
|
import com.xboe.module.course.dto.ScoreParam;
|
||||||
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.PostMapping;
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
@@ -25,18 +28,27 @@ public class CourseGradeApi extends ApiBaseController {
|
|||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private ICourseGradeService service;
|
private ICourseGradeService service;
|
||||||
|
@Resource
|
||||||
|
private ThirdApi thirdApi;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 评分
|
* 评分
|
||||||
* */
|
* */
|
||||||
@PostMapping("/grade")
|
@PostMapping("/grade")
|
||||||
@AutoLog(module = "评分",action = "评分")
|
@AutoLog(module = "评分",action = "评分")
|
||||||
public JsonResponse<Float> grade(String courseId,Float score,String studyId){
|
public JsonResponse<Float> grade(String courseId,Float score,String studyId, HttpServletRequest request){
|
||||||
CourseGrade courseGrade = new CourseGrade();
|
CourseGrade courseGrade = new CourseGrade();
|
||||||
courseGrade.setCourseId(courseId);
|
courseGrade.setCourseId(courseId);
|
||||||
courseGrade.setScores(score);
|
courseGrade.setScores(score);
|
||||||
courseGrade.setStudyId(studyId);
|
courseGrade.setStudyId(studyId);
|
||||||
try {
|
try {
|
||||||
Float aFloat = service.save(courseGrade);
|
Float aFloat = service.save(courseGrade);
|
||||||
|
String token = request.getHeader("Xboe-Access-Token");
|
||||||
|
ScoreParam param = new ScoreParam();
|
||||||
|
param.setCourseId(Long.parseLong(courseId));
|
||||||
|
param.setScore(score);
|
||||||
|
// 同步在线课评分
|
||||||
|
// thirdApi.syncOnLineScore(param,token);
|
||||||
return success(aFloat);
|
return success(aFloat);
|
||||||
}catch(Exception e) {
|
}catch(Exception e) {
|
||||||
log.error("评分保存错误",e);
|
log.error("评分保存错误",e);
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
package com.xboe.module.teacher.entity;
|
package com.xboe.module.teacher.entity;
|
||||||
|
|
||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import javax.persistence.Column;
|
import javax.persistence.Column;
|
||||||
import javax.persistence.Entity;
|
import javax.persistence.Entity;
|
||||||
@@ -206,4 +208,56 @@ public class Teacher extends BaseEntity {
|
|||||||
@Column(name = "expertise")
|
@Column(name = "expertise")
|
||||||
private String expertise;
|
private String expertise;
|
||||||
|
|
||||||
|
@Column(name = "user_no",length = 1)
|
||||||
|
private String userNo;
|
||||||
|
|
||||||
|
// @ApiModelProperty(value = "讲师类型 1 内部讲师 2外部讲师")
|
||||||
|
@Column(name = "teacher_type")
|
||||||
|
private Integer teacherType;
|
||||||
|
|
||||||
|
// @ApiModelProperty(value = "默认授课时长(分钟)")
|
||||||
|
@Column(name = "default_teaching_time")
|
||||||
|
private Integer defaultTeachingTime;
|
||||||
|
|
||||||
|
// @ApiModelProperty(value = "认证人")
|
||||||
|
@Column(name = "certify_by")
|
||||||
|
private String certifyBy;
|
||||||
|
|
||||||
|
// @ApiModelProperty(value = "认证时间")
|
||||||
|
@Column(name = "certify_at")
|
||||||
|
private LocalDateTime certifyAt;
|
||||||
|
|
||||||
|
// @ApiModelProperty(value = "认证资料路径")
|
||||||
|
@Column(name = "certification")
|
||||||
|
private String certification;
|
||||||
|
|
||||||
|
// @ApiModelProperty(value = "认证资料路径名称")
|
||||||
|
@Column(name = "certification_name")
|
||||||
|
private String certificationName;
|
||||||
|
|
||||||
|
// @ApiModelProperty(value = "供应商")
|
||||||
|
@Column(name = "supplier")
|
||||||
|
private String supplier;
|
||||||
|
|
||||||
|
|
||||||
|
// @ApiModelProperty(value = "教师专长名称 逗号分割")
|
||||||
|
@Column(name = "expertise_names")
|
||||||
|
private String expertiseNames;
|
||||||
|
|
||||||
|
// @ApiModelProperty(value = "标识 0:自动录入/1:手动录入")
|
||||||
|
@Column(name = "create_from")
|
||||||
|
private Integer createFrom;
|
||||||
|
|
||||||
|
// @ApiModelProperty(value = "组织id")
|
||||||
|
@Column(name = "org_id")
|
||||||
|
private Long orgId;
|
||||||
|
|
||||||
|
// @ApiModelProperty(value = "组织名称")
|
||||||
|
@Column(name = "org_name")
|
||||||
|
private String orgName;
|
||||||
|
|
||||||
|
// @ApiModelProperty(value = "旧系统kid字段")
|
||||||
|
@Column(name = "kid")
|
||||||
|
private String kid;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -102,9 +102,12 @@ public class TeacherServiceImpl implements ITeacherService {
|
|||||||
public List<Teacher> findByName(String name) {
|
public List<Teacher> findByName(String name) {
|
||||||
String hql="Select t.id,t.name,u.userNo from "+Teacher.class.getSimpleName()+" t,"+User.class.getSimpleName()+" u ";
|
String hql="Select t.id,t.name,u.userNo from "+Teacher.class.getSimpleName()+" t,"+User.class.getSimpleName()+" u ";
|
||||||
hql+=" where t.id=u.id and (t.name like '%"+name+"%' or u.userNo=?1)";
|
hql+=" where t.id=u.id and (t.name like '%"+name+"%' or u.userNo=?1)";
|
||||||
|
// String hql="Select t.id,t.name,t.userNo from "+Teacher.class.getSimpleName()+" t";
|
||||||
|
// hql+=" where t.deleted =0 and t.status =1 and (t.name like '%"+name+"%' or t.userNo like '%"+name+"%' )";
|
||||||
|
|
||||||
List<Teacher> teachers=new ArrayList<Teacher>();
|
List<Teacher> teachers=new ArrayList<Teacher>();
|
||||||
try {
|
try {
|
||||||
List<Object[]> list =dao.findListFields(hql,name);
|
List<Object[]> list =dao.findListFields(hql);
|
||||||
for(Object[] objs :list) {
|
for(Object[] objs :list) {
|
||||||
Teacher t=new Teacher();
|
Teacher t=new Teacher();
|
||||||
t.setId((String)objs[0]);
|
t.setId((String)objs[0]);
|
||||||
|
|||||||
@@ -750,18 +750,26 @@ public class StudyCourseApi extends ApiBaseController{
|
|||||||
* @param courseId 课程id 用于删除课程报名信息和修改课程学习人数
|
* @param courseId 课程id 用于删除课程报名信息和修改课程学习人数
|
||||||
* */
|
* */
|
||||||
@PostMapping("/delete-signup")
|
@PostMapping("/delete-signup")
|
||||||
public JsonResponse<Boolean> deleteSignUp(String id,String courseId,String studentId){
|
public JsonResponse<Boolean> deleteSignUp(String id,String courseId,String studentId, HttpServletRequest request){
|
||||||
if(StringUtils.isBlank(id)){
|
if(StringUtils.isBlank(id)){
|
||||||
return badRequest("参数异常");
|
return badRequest("参数异常");
|
||||||
}
|
}
|
||||||
//String aid = this.getCurrent().getAccountId();
|
//String aid = this.getCurrent().getAccountId();
|
||||||
try {
|
try {
|
||||||
service.deleteSignUp(id,courseId,studentId);
|
service.deleteSignUp(id,courseId,studentId);
|
||||||
return success(true);
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("删除报名信息失败",e.getMessage());
|
log.error("删除报名信息失败",e.getMessage());
|
||||||
return error("删除失败",e.getMessage());
|
return error("删除失败",e.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
String token = request.getHeader("Xboe-Access-Token");
|
||||||
|
thirdApi.syncCourseStudent(Long.parseLong(courseId),token);
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return success(true);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -116,4 +116,8 @@ 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));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -117,7 +117,7 @@ public class StudyExam extends IdEntity {
|
|||||||
/*
|
/*
|
||||||
* 开始时间
|
* 开始时间
|
||||||
* */
|
* */
|
||||||
@JsonFormat(pattern = "yyyy--MM-dd HH:mm:ss")
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
@Column(name = "start_time")
|
@Column(name = "start_time")
|
||||||
private LocalDateTime startTime;
|
private LocalDateTime startTime;
|
||||||
/*
|
/*
|
||||||
|
|||||||
@@ -99,5 +99,4 @@ public interface IStudyService {
|
|||||||
|
|
||||||
List<StudyCourseItem> getList(String courseId, String contentId, String name, Integer status);
|
List<StudyCourseItem> getList(String courseId, String contentId, String name, Integer status);
|
||||||
|
|
||||||
List<User> getUserNo(List<String> userIds);
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -265,6 +265,7 @@ 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);
|
||||||
//删除学习课程的评估测试结果
|
//删除学习课程的评估测试结果
|
||||||
|
|||||||
@@ -1,24 +1,9 @@
|
|||||||
package com.xboe.school.study.service.impl;
|
package com.xboe.school.study.service.impl;
|
||||||
|
|
||||||
import java.time.LocalDateTime;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.concurrent.TimeUnit;
|
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
|
||||||
import javax.transaction.Transactional;
|
|
||||||
|
|
||||||
import com.xboe.api.ThirdApi;
|
|
||||||
import com.xboe.core.orm.QueryBuilder;
|
|
||||||
import com.xboe.school.study.entity.StudyCourse;
|
|
||||||
import com.xboe.system.user.entity.Message;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.data.redis.core.StringRedisTemplate;
|
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
|
|
||||||
import com.xboe.common.OrderCondition;
|
import com.xboe.common.OrderCondition;
|
||||||
import com.xboe.core.orm.FieldFilters;
|
import com.xboe.core.orm.FieldFilters;
|
||||||
|
import com.xboe.core.orm.QueryBuilder;
|
||||||
|
import com.xboe.core.orm.UpdateBuilder;
|
||||||
import com.xboe.module.course.dao.CourseContentDao;
|
import com.xboe.module.course.dao.CourseContentDao;
|
||||||
import com.xboe.module.course.dao.CourseExamDao;
|
import com.xboe.module.course.dao.CourseExamDao;
|
||||||
import com.xboe.module.course.entity.CourseExam;
|
import com.xboe.module.course.entity.CourseExam;
|
||||||
@@ -28,6 +13,17 @@ import com.xboe.school.study.dao.StudyExamDao;
|
|||||||
import com.xboe.school.study.entity.StudyCourseItem;
|
import com.xboe.school.study.entity.StudyCourseItem;
|
||||||
import com.xboe.school.study.entity.StudyExam;
|
import com.xboe.school.study.entity.StudyExam;
|
||||||
import com.xboe.school.study.service.IStudyExamService;
|
import com.xboe.school.study.service.IStudyExamService;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.data.redis.core.StringRedisTemplate;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import javax.transaction.Transactional;
|
||||||
|
import java.time.Duration;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@Service
|
@Service
|
||||||
@@ -73,29 +69,31 @@ public class StudyExamServiceImpl implements IStudyExamService{
|
|||||||
exam.setPassLine(0);
|
exam.setPassLine(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
int prog=exam.getScore().intValue()>=exam.getPassLine()?100:exam.getScore().intValue();
|
|
||||||
//完成处理,判断是否已存在
|
//完成处理,判断是否已存在
|
||||||
Object obj=scItemDao.findField("id", FieldFilters.eq("studyId", exam.getStudyId()), FieldFilters.eq("contentId", exam.getContentId()));
|
Object obj=scItemDao.findField("id", FieldFilters.eq("studyId", exam.getStudyId()), FieldFilters.eq("contentId", exam.getContentId()));
|
||||||
|
//获取本次考试提交,学习状态与学习进度
|
||||||
int status=exam.getScore()>=exam.getPassLine()?StudyCourseItem.STATUS_FINISH:StudyCourseItem.STATUS_STUDYING;
|
int status=exam.getScore()>=exam.getPassLine()?StudyCourseItem.STATUS_FINISH:StudyCourseItem.STATUS_STUDYING;
|
||||||
|
int progress = exam.getScore().intValue() >= exam.getPassLine() ? 100 : 0;
|
||||||
|
//计算时长
|
||||||
|
LocalDateTime ldt=LocalDateTime.now();
|
||||||
|
|
||||||
if(obj==null) {
|
if(obj==null) {
|
||||||
StudyCourseItem sci=new StudyCourseItem();
|
StudyCourseItem sci=new StudyCourseItem();
|
||||||
LocalDateTime ldt=LocalDateTime.now();
|
|
||||||
sci.setStudyId(exam.getStudyId());
|
sci.setStudyId(exam.getStudyId());
|
||||||
sci.setContentId(exam.getContentId());
|
sci.setContentId(exam.getContentId());
|
||||||
sci.setContentName("考试");
|
sci.setContentName("考试");
|
||||||
sci.setCourseId(exam.getCourseId());
|
sci.setCourseId(exam.getCourseId());
|
||||||
//sci.setCsectionId(homework.getCsectionId());
|
//sci.setCsectionId(homework.getCsectionId());
|
||||||
sci.setProgress(prog);//直接设置为学习完成
|
sci.setProgress(progress);//直接设置为学习完成
|
||||||
sci.setStatus(status);//状态直接更新为已完成
|
sci.setStatus(status);//状态直接更新为已完成
|
||||||
sci.setStartTime(ldt);
|
sci.setStartTime(exam.getStartTime());
|
||||||
sci.setAid(exam.getStudentId());
|
sci.setAid(exam.getStudentId());
|
||||||
sci.setAname(exam.getStudentName());
|
sci.setAname(exam.getStudentName());
|
||||||
sci.setFinishTime(LocalDateTime.now());
|
sci.setFinishTime(ldt);
|
||||||
sci.setLastStudyTime(0);//此项用户记录视频内容当前学习的时间点
|
sci.setLastStudyTime(0);//此项用户记录视频内容当前学习的时间点
|
||||||
sci.setLastTime(ldt);
|
sci.setLastTime(ldt);
|
||||||
if(cexam.getScoringType()==CourseExam.SCORINGTYPE_LAST) {
|
sci.setScore(exam.getScore());
|
||||||
sci.setScore(exam.getScore());
|
sci.setStudyDuration(exam.getTestDuration());
|
||||||
}
|
|
||||||
scItemDao.save(sci);
|
scItemDao.save(sci);
|
||||||
exam.setStudyItemId(sci.getId());
|
exam.setStudyItemId(sci.getId());
|
||||||
dao.save(exam);
|
dao.save(exam);
|
||||||
@@ -108,35 +106,34 @@ public class StudyExamServiceImpl implements IStudyExamService{
|
|||||||
|
|
||||||
}else {
|
}else {
|
||||||
exam.setStudyItemId(obj.toString());//此项就是学习条目的id
|
exam.setStudyItemId(obj.toString());//此项就是学习条目的id
|
||||||
|
Float maxScore = (Float) dao.findField("max(score)", FieldFilters.eq("contentId", exam.getContentId()), FieldFilters.eq("courseId", exam.getCourseId()), FieldFilters.eq("studyId", exam.getStudyId()));
|
||||||
dao.save(exam);
|
dao.save(exam);
|
||||||
if(cexam.getScoringType()==CourseExam.SCORINGTYPE_LAST){
|
//最新考试分值
|
||||||
scItemDao.updateFieldById(exam.getStudyItemId(), "score",exam.getScore());
|
if (cexam.getScoringType() == CourseExam.SCORINGTYPE_LAST) {
|
||||||
scItemDao.updateFieldById(exam.getStudyItemId(), "progress",prog);
|
scItemDao.updateMultiFieldById(exam.getStudyItemId(),
|
||||||
if(exam.getScore()>=exam.getPassLine()){
|
UpdateBuilder.create("startTime", exam.getStartTime()),
|
||||||
scItemDao.updateFieldById(exam.getStudyId(), "progress",100);
|
UpdateBuilder.create("finishTime", ldt),
|
||||||
scItemDao.updateFieldById(exam.getStudyId(), "finish_time",LocalDateTime.now());
|
UpdateBuilder.create("score", exam.getScore()),
|
||||||
scItemDao.updateFieldById(exam.getStudyId(), "status",StudyCourseItem.STATUS_FINISH);
|
UpdateBuilder.create("progress", progress),
|
||||||
scItemDao.updateFieldById(exam.getStudyId(), "score",exam.getScore());
|
UpdateBuilder.create("status", status),
|
||||||
//scDao.updateFieldById(exam.getStudyId(), "last_score",100.0f);
|
UpdateBuilder.create("studyDuration", exam.getTestDuration())
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
//最高分
|
||||||
|
if (cexam.getScoringType() == CourseExam.SCORINGTYPE_MAX) {
|
||||||
|
if (exam.getScore() > maxScore) {
|
||||||
|
scItemDao.updateMultiFieldById(exam.getStudyItemId(),
|
||||||
|
UpdateBuilder.create("startTime", exam.getStartTime()),
|
||||||
|
UpdateBuilder.create("finishTime", LocalDateTime.now()),
|
||||||
|
UpdateBuilder.create("score", exam.getScore()),
|
||||||
|
UpdateBuilder.create("progress", progress),
|
||||||
|
UpdateBuilder.create("status", status)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//1最高一次,用于最高一次的计算
|
|
||||||
if(cexam.getScoringType()==CourseExam.SCORINGTYPE_MAX) {
|
|
||||||
Float f=(Float)dao.findField("max(score)", FieldFilters.eq("contentId", exam.getContentId()), FieldFilters.eq("courseId", exam.getCourseId()), FieldFilters.eq("studyId", exam.getStudyId()));
|
|
||||||
scItemDao.updateFieldById(exam.getStudyItemId(), "score", f);
|
|
||||||
scItemDao.updateFieldById(exam.getStudyItemId(), "status", f>=exam.getPassLine()?StudyCourseItem.STATUS_FINISH:StudyCourseItem.STATUS_STUDYING);
|
|
||||||
scItemDao.updateFieldById(exam.getStudyItemId(), "progress",f>=exam.getPassLine()?100:f.intValue());
|
|
||||||
|
|
||||||
if(f>=exam.getPassLine()){
|
|
||||||
scItemDao.updateFieldById(exam.getStudyId(), "progress",100);
|
|
||||||
scItemDao.updateFieldById(exam.getStudyId(), "finish_time",LocalDateTime.now());
|
|
||||||
scItemDao.updateFieldById(exam.getStudyId(), "status",StudyCourseItem.STATUS_FINISH);
|
|
||||||
scItemDao.updateFieldById(exam.getStudyId(), "score",exam.getScore());
|
|
||||||
//scDao.updateFieldById(exam.getStudyId(), "last_score",100.0f);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
int totalContent = courseContentDao.getCount(exam.getCourseId());
|
int totalContent = courseContentDao.getCount(exam.getCourseId());
|
||||||
scDao.finishCheck(exam.getStudyId(),exam.getCourseId(),totalContent,token);
|
scDao.finishCheck(exam.getStudyId(),exam.getCourseId(),totalContent,token);
|
||||||
scDao.updateFieldById(exam.getStudyId(), "last_score",exam.getScore());
|
scDao.updateFieldById(exam.getStudyId(), "last_score",exam.getScore());
|
||||||
|
|||||||
@@ -64,6 +64,7 @@ public class StudyHomeWorkServiceImpl implements IStudyHomeWorkService{
|
|||||||
int totalContent=courseContentDao.count(FieldFilters.eq("courseId", homework.getCourseId()),FieldFilters.eq("deleted",false));
|
int totalContent=courseContentDao.count(FieldFilters.eq("courseId", homework.getCourseId()),FieldFilters.eq("deleted",false));
|
||||||
scDao.finishCheck(homework.getStudyId(),homework.getCourseId(),totalContent,token);
|
scDao.finishCheck(homework.getStudyId(),homework.getCourseId(),totalContent,token);
|
||||||
}else {
|
}else {
|
||||||
|
scItemDao.updateFieldById(obj.toString(), "finishTime", LocalDateTime.now());
|
||||||
//只是保留一条作业记录,不再保存多条记录了
|
//只是保留一条作业记录,不再保存多条记录了
|
||||||
//dao.save(homework);
|
//dao.save(homework);
|
||||||
//设置id。然后进行悠
|
//设置id。然后进行悠
|
||||||
|
|||||||
@@ -294,16 +294,11 @@ public class StudyServiceImpl implements IStudyService{
|
|||||||
|
|
||||||
}
|
}
|
||||||
if(StringUtils.isNotBlank(name)) {
|
if(StringUtils.isNotBlank(name)) {
|
||||||
query.addFilter(FieldFilters.eq("aname", name));
|
query.addFilter(FieldFilters.like("aname", name));
|
||||||
}
|
}
|
||||||
return scItemDao.findList(query.builder());
|
return scItemDao.findList(query.builder());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<User> getUserNo(List<String> userIds) {
|
|
||||||
return userDao.findList(FieldFilters.in("id", userIds));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
public void updateProcess(String studyContentId,String studyId, String courseId,Integer total, Integer progress,String token) {
|
public void updateProcess(String studyContentId,String studyId, String courseId,Integer total, Integer progress,String token) {
|
||||||
|
|||||||
@@ -61,7 +61,10 @@ 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);
|
||||||
this.addSignup(signup);
|
StudyCourse sc=studyCourseDao.findByCourseIdAndAid(signup.getAid(), signup.getCourseId());
|
||||||
|
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-dev.xml
|
logging.config=classpath:log/logback-@profileActive@.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-dev.xml
|
logging.config=classpath:log/logback-@profileActive@.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-dev.xml
|
logging.config=classpath:log/logback-@profileActive@.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
|
||||||
|
|||||||
@@ -75,3 +75,9 @@ manageApi.editExam=${boe.domain}/manageApi/admin/project/editExam
|
|||||||
#获取离职教师id
|
#获取离职教师id
|
||||||
userBasic.getTeacherIds=${boe.domain}/userbasic/user/getTeacherInfo
|
userBasic.getTeacherIds=${boe.domain}/userbasic/user/getTeacherInfo
|
||||||
coursesuilt.getStudyStatus=${boe.domain}/manageApi/stu/project/completeStatus
|
coursesuilt.getStudyStatus=${boe.domain}/manageApi/stu/project/completeStatus
|
||||||
|
userBasic.getUserBasicInfo=${boe.domain}/userbasic/user/getUserBasicInfo
|
||||||
|
#讲师管理创建或修改在线课授课记录
|
||||||
|
coursesuilt.updateOrSaveCourse=${boe.domain}/manageApi/admin/teacherRecord/updateOrSaveCourse
|
||||||
|
coursesuilt.syncCourseStudent=${boe.domain}/manageApi/admin/teacherRecord/syncCourseStudent
|
||||||
|
coursesuilt.syncOnLineScore=${boe.domain}/manageApi/admin/teacherRecord/syncOnLineScore
|
||||||
|
coursesuilt.updateOnLineStatus=${boe.domain}/manageApi/admin/teacherRecord/updateOnLineStatus
|
||||||
|
|||||||
Reference in New Issue
Block a user