Compare commits

..

68 Commits

Author SHA1 Message Date
joshen
be0386f2d1 Merge remote-tracking branch 'yx/zxwy-esSync' into master-teacher-1202 2024-12-17 19:57:35 +08:00
yang
e412f5b6eb es数据同步,全量、分页 2024-12-15 20:27:47 +08:00
yang
255b854a08 es数据同步,全量、分页 2024-12-15 19:37:22 +08:00
yang
3343474f33 es数据同步 2024-12-13 20:52:11 +08:00
yang
cb8a333b4f es数据同步 2024-12-13 20:20:49 +08:00
yang
09f64bdb08 es数据同步 2024-12-12 22:21:06 +08:00
joshen
b092cd3889 Merge branch 'yx1101-teacher-l' into master-teacher-1202 2024-12-12 19:11:33 +08:00
yang
4ec4b861f7 es数据同步-在线课 2024-12-12 17:43:58 +08:00
Wangxxz
ffe232eeb9 注释同步在线课评分 2024-12-12 11:25:28 +08:00
joshen
e54c8b457b Merge branch 'yx1101-teacher-l' into master-teacher-1202 2024-12-03 10:23:16 +08:00
Wangxxz
f273e9df4a 加bean字段 2024-12-03 10:22:43 +08:00
joshen
1a93ab8abd Merge branch 'yx1101-teacher-l' into master-teacher-1202 2024-12-03 10:10:03 +08:00
Wangxxz
aab82de81b 加bean字段 2024-12-03 10:01:31 +08:00
joshen
0b5b882a6c Merge branch 'yx1101-teacher-l' into master-teacher-1202 2024-12-02 17:38:04 +08:00
yang
4205912db5 定时任务测试 2024-11-30 12:08:11 +08:00
Wangxxz
af6efd3151 统一讲师查询 还原 2024-11-26 13:22:17 +08:00
Wangxxz
c724080a3c 统一讲师查询 2024-11-26 11:24:17 +08:00
Wangxxz
aa63a6618f 统一讲师查询 2024-11-26 11:20:50 +08:00
Wangxxz
d3fcbaeab6 统一案例接口 2024-11-26 09:26:44 +08:00
Wangxxz
82bf84bbaa 未开课在线课同步 2024-11-22 11:30:14 +08:00
nisen
423b658e04 Merge branch 'yx1107-bug-l' into 104-master 2024-11-18 20:08:14 +08:00
Wangxxz
acc62c85e0 优化 2024-11-18 20:07:36 +08:00
nisen
795966d944 Merge branch 'yx1107-bug-l' into 104-master 2024-11-18 15:46:23 +08:00
Wangxxz
ec00f55606 频繁调用finishCheck100进度更新 2024-11-18 15:43:01 +08:00
Wangxxz
3f59552c2e 提交 2024-11-16 10:21:12 +08:00
zhaolongfei
e5c8dbabed 无目录无权限不能报名 2024-11-10 14:00:11 +08:00
Wangxxz
e0d731e296 更改在线课状态 2024-11-09 16:52:07 +08:00
Wangxxz
f5c26d02d1 更改在线课状态 2024-11-09 16:51:34 +08:00
zhaolongfei
a3aad61ac8 讲师审批添加讲师工号 2024-11-08 15:04:12 +08:00
Wangxxz
fc94e4aedd 受众加判空 2024-11-08 10:42:05 +08:00
Wangxxz
ae75aedff9 受众传参判空 2024-11-07 09:47:01 +08:00
Wangxxz
0e74f11615 同步授课记录评分 2024-11-03 17:07:14 +08:00
Wangxxz
3559553484 同步授课记录评分 2024-11-03 16:55:53 +08:00
Wangxxz
9faa8307ee 删除时同步授课记录学员数 2024-11-03 16:08:53 +08:00
Wangxxz
1a6c8f8af9 在线课同步授课记录 2024-11-01 15:05:55 +08:00
Wangxxz
f1b96c8af9 创建在线课授课记录 2024-11-01 11:51:06 +08:00
nisen
5b691c5bb8 Merge branch 'master' into yx-master 2024-11-01 10:46:34 +08:00
yang
b0f01c6300 取消定时任务 2024-10-27 18:08:39 +08:00
nisen
e51d4dd8cb 视频请求头解析时间对比注释 2024-10-24 19:29:42 +08:00
zhaolongfei
ea1cda25bd 删除报名信息添加日志 2024-10-24 16:22:51 +08:00
zhaolongfei
3d3e660e68 在线课多目录重复学习记录问题修复 2024-10-22 16:49:23 +08:00
zhaolongfei
b509b783a1 视频解析添加日志 2024-10-21 14:04:52 +08:00
Wangxxz
bbda82b8f5 还原-讲师管理-查询讲师时加启用条件判断 2024-10-20 14:25:48 +08:00
Wangxxz
fec28f5baf 讲师管理-查询讲师时加启用条件判断 2024-10-20 14:24:04 +08:00
nisen
469145d25c Merge remote-tracking branch 'yx/master-0930' 2024-10-09 18:53:40 +08:00
yang
25d8594a2b 案例,bug 2024-10-09 18:52:23 +08:00
nisen
3001c25590 Merge remote-tracking branch '104/master' 2024-10-09 17:48:11 +08:00
nisen
95b63155cd Merge branch 'zcwy0927-yang-random' 2024-10-09 17:46:52 +08:00
yang
85517dcd57 随机选题,bug 2024-10-09 14:57:56 +08:00
nisen
0e897b5f14 Merge remote-tracking branch 'yx/master-0930' into 104-master 2024-10-08 20:18:33 +08:00
yang
39e336d044 案例bug修复 2024-10-08 20:17:08 +08:00
yang
9da0eae4c0 考试随机选题 2024-10-08 19:27:46 +08:00
yang
74a36d72a1 作业导出,考试随机选题 2024-10-08 17:40:28 +08:00
nisen
4ef1b5b1e9 Merge branch 'zcwy0912-llf' into 104-master 2024-09-30 12:02:11 +08:00
Wangxxz
33df8b0831 加判断 2024-09-30 11:57:55 +08:00
nisen
b61923233a Merge branch 'zcwy0912-llf' 2024-09-30 11:52:29 +08:00
Wangxxz
effb45c6d0 加判断 2024-09-30 11:51:47 +08:00
nisen
95aa5f7abe Merge branch 'zcwy0912-llf' 2024-09-30 10:43:13 +08:00
zhaolongfei
3af3c2eedf 考试随机试题功能修改 2024-09-29 11:17:00 +08:00
yang
516225f52e 作业导出,案例类型处理代码回退版本 2024-09-27 22:38:35 +08:00
nisen
e3c060b8d9 Merge remote-tracking branch 'yx/zcwy0913-yang-case-prod' 2024-09-27 18:00:06 +08:00
nisen
72783fb1ac Merge remote-tracking branch 'yx/zcwy0923-wjwyyk-online-prod2' 2024-09-27 17:59:32 +08:00
nisen
f5f8fcee98 Merge branch 'zcwy0912-llf' into 104-master 2024-09-27 17:47:55 +08:00
yang
003d227ba3 案例萃取,案例榜单排序,定时任务 2024-09-27 17:07:24 +08:00
yang
e6bd808a3d 作业导出,删除注释代码 2024-09-27 16:46:50 +08:00
yang
b87eb65b3e Merge branch 'refs/heads/zcwy-0724-wjw-online-prod' into zcwy0923-wjwyyk-online2
# Conflicts:
#	servers/boe-server-all/src/main/java/com/xboe/api/ThirdApi.java
#	servers/boe-server-all/src/main/java/com/xboe/module/course/api/CoursePortalApi.java
2024-09-27 16:07:55 +08:00
yang
28af48581e 作业导出,相关bug修复与补充
作业导出,计算时长

作业导出,分数设置

作业导出,最高分、与作业完成时间

作业导出,考试

作业导出,模糊搜索

作业导出,优化导包

在线导出

作业导出,token

作业导出,bug修复
2024-09-27 16:00:32 +08:00
zhaolongfei
57e04f46c0 试题管理模板修改 2024-09-27 14:22:51 +08:00
34 changed files with 1227 additions and 229 deletions

View File

@@ -232,6 +232,13 @@
<artifactId>spring-retry</artifactId>
<version>1.3.1</version>
</dependency>
<dependency>
<groupId>com.xuxueli</groupId>
<artifactId>xxl-job-core</artifactId>
<version>2.3.0</version>
</dependency>
</dependencies>
<build>
<resources>

View File

@@ -0,0 +1,40 @@
package com.xboe;
import com.xxl.job.core.executor.impl.XxlJobSpringExecutor;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@Configuration
public class XxlJobConfig {
@Value("${xxl.job.admin.addresses}")
private String adminAddresses;
@Value("${xxl.job.executor.appname}")
private String appName;
@Value("${xxl.job.executor.ip}")
private String ip;
@Value("${xxl.job.executor.port}")
private int port;
@Value("${xxl.job.accessToken}")
private String accessToken;
@Value("${xxl.job.executor.logpath}")
private String logPath;
@Value("${xxl.job.executor.logretentiondays}")
private int logRetentionDays;
@Bean
public XxlJobSpringExecutor xxlJobExecutor() {
// 创建 XxlJobSpringExecutor 执行器
XxlJobSpringExecutor xxlJobSpringExecutor = new XxlJobSpringExecutor();
xxlJobSpringExecutor.setAdminAddresses(adminAddresses);
xxlJobSpringExecutor.setAppname(appName);
xxlJobSpringExecutor.setIp(ip);
xxlJobSpringExecutor.setPort(port);
xxlJobSpringExecutor.setAccessToken(accessToken);
xxlJobSpringExecutor.setLogPath(logPath);
xxlJobSpringExecutor.setLogRetentionDays(logRetentionDays);
// 返回
return xxlJobSpringExecutor;
}
}

View File

@@ -5,6 +5,8 @@ import cn.hutool.core.lang.Opt;
import cn.hutool.http.HttpRequest;
import cn.hutool.json.JSONUtil;
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.TeacherInfoVo;
import com.xboe.module.course.vo.TeacherVo;
@@ -19,6 +21,8 @@ import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import javax.servlet.http.HttpServletRequest;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.util.Collection;
import java.util.List;
import java.util.Optional;
@@ -70,6 +74,16 @@ public class ThirdApi {
@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.updateOnLineStatua}")
private String updateOnLineStatua;
//获取例外人员的id
public List<String> getUserId(){
String responseBody = Optional.ofNullable(HttpRequest.get(infarasApiUrl+"?pid=316&type=1").execute() //prod 316
@@ -300,4 +314,31 @@ public class ThirdApi {
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 updateOnLineStatua(CourseParam param, String token){
String resp = Optional.ofNullable(
HttpRequest.post(updateOnLineStatua).body(JSONUtil.toJsonStr(param)).header("token", token).execute()
.body()).orElseThrow(() -> new RuntimeException("token校验失败"));
log.info("updateOrSaveCourse = " + resp);
}
}

View File

@@ -1,6 +1,7 @@
package com.xboe.module.boecase.api;
import com.xboe.module.boecase.service.ICasesService;
import com.xxl.job.core.handler.annotation.XxlJob;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
@@ -12,15 +13,20 @@ public class CaseScheduledTasks {
@Resource
private ICasesService casesService;
@Scheduled(cron = "0 0 1 1 * ?") // 每月的第一天的1:00执行
/**
* 每月的第一天的1:00执行
*/
// @Scheduled(cron = "0 0 1 1 * ?")
@XxlJob("refreshViewsRankOfMajor")
public void refreshViewsRankOfMajor() {
casesService.refreshViewsRankOfMajor();
}
/**
* 季初执行cron表达式设置为每个季度的第一个月的第一天的特定时间。每个季度的第一个月是1月、4月、7月和10月
* 季初第一天两点执行cron表达式设置为每个季度的第一个月的第一天的特定时间。每个季度的第一个月是1月、4月、7月和10月
*/
@Scheduled(cron = "0 0 2 1 1,4,7,10 ?")
// @Scheduled(cron = "0 0 2 1 1,4,7,10 ?")
@XxlJob("refreshLastQuarterStatistics")
public void refreshLastQuarterStatistics() {
casesService.refreshLastQuarterStatistics();
}

View File

@@ -15,7 +15,9 @@ import java.util.stream.Collectors;
@Repository
@Slf4j
public class CasesRankDao extends BaseDao<CasesRank> {
/**
* 获取类别榜记录,默认按上榜时间降序排列
*/
public List<CasesRank> findViewsRankRecordByCaseId(String caseId) {
String sql =
"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" +
" ON bdmt.code = bcvr.major_id \n" +
"WHERE bcvr.case_id = ?1 AND bcvr.deleted=0 AND bdmt.deleted=0\n" +
"ORDER BY bcvr.sys_update_time DESC \n" +
"LIMIT 2;";
"ORDER BY bcvr.rise_rank_time DESC;";
List<Object[]> list = this.sqlFindList(sql, caseId);

View File

@@ -44,6 +44,7 @@ import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.lang.reflect.Array;
import java.time.LocalDateTime;
import java.time.YearMonth;
import java.time.format.DateTimeFormatter;
import java.time.temporal.TemporalAdjusters;
import java.util.*;
@@ -416,14 +417,36 @@ public class CasesServiceImpl implements ICasesService {
if (CollUtil.isEmpty(casesList)) {
return casesList;
}
//1.推荐案例数据处理
recommendCasesDataHandle(casesList, accountId);
//2.标签处理,添加作者标签和新的案例标签
addAuthorTagAndCaseNewTag(casesList);
//3.案例类型处理
// majorTypeHandle(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) {
if (StrUtil.isNotBlank(accountId)) {
List<String> caseIdList = casesList.stream().map(Cases::getId).collect(Collectors.toList());
@@ -483,7 +506,7 @@ public class CasesServiceImpl implements ICasesService {
caseList.forEach(e -> {
// 获取最新的两个浏览量上榜记录
// 获取浏览量上榜记录
List<CasesRank> viewsRankRecords = casesRankDao.findViewsRankRecordByCaseId(e.getId());
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 =
"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";
"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 =
// "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);
@@ -1231,7 +1254,7 @@ public class CasesServiceImpl implements ICasesService {
@Override
public void refreshLastQuarterStatistics() {
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);
}
@@ -1277,21 +1300,24 @@ public class CasesServiceImpl implements ICasesService {
pageSize = 10;
}
LocalDateTime startTime = month.withDayOfMonth(1);
LocalDateTime endTime = month.plusMonths(1).withDayOfMonth(1).withMinute(0);
LocalDateTime startTime = month.withDayOfMonth(1).withHour(0).withMinute(0).withSecond(0);
LocalDateTime endTime = YearMonth.from(month).atEndOfMonth().atTime(23, 59, 59);
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());
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);
query.addFilter(FieldFilters.in("id",caseIdList));
query.addFilter(FieldFilters.eq("deleted",false));
List<Cases> casesList = casesDao.findList(query.builder());
//处理案例数据-通用操作
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>() {
@Override
public int compare(Cases c1, Cases c2) {
@@ -1300,6 +1326,26 @@ public class CasesServiceImpl implements ICasesService {
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;
}

View File

@@ -5,7 +5,10 @@ import java.util.ArrayList;
import java.util.List;
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.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
@@ -55,7 +58,10 @@ public class CourseAuditApi extends ApiBaseController{
@Resource
private ICourseContentService ccontentService;
@Resource
private ThirdApi thirdApi;
/**
* 教师需要审核的课程
* @param pager
@@ -315,7 +321,7 @@ public class CourseAuditApi extends ApiBaseController{
* @return
*/
@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)){
return badRequest("参数错误");
}
@@ -347,6 +353,14 @@ public class CourseAuditApi extends ApiBaseController{
try {
CurrentUser cu=getCurrent();
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.updateOnLineStatua(param,token);
}
return success(true);
} catch (Exception e) {
log.error("HRBP审核提交处理错误",e);
@@ -378,7 +392,8 @@ public class CourseAuditApi extends ApiBaseController{
*/
@PostMapping("/submit-publish")
@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){
return badRequest("无课程信息");
}
@@ -402,12 +417,22 @@ public class CourseAuditApi extends ApiBaseController{
if(StringUtils.isBlank(dto.getCourse().getOrgId())) {
return badRequest("请选择资源归属");
}
String token = request.getHeader("Xboe-Access-Token");
CurrentUser cuser=getCurrent();
dto.getCourse().setStatus(Course.STATUS_AUDIT_FINISH);//设置为审核通过状态
dto.getCourse().setEnabled(true);//设置启用状态问题
dto.getCourse().setPublished(false);//重新提交审核设置为未发布状态
try {
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);
} catch (Exception e) {
log.error("默认管理员提交直接发布处理失败",e);

View File

@@ -4,13 +4,10 @@ import java.util.List;
import javax.annotation.Resource;
import com.xboe.common.utils.StringUtil;
import com.xboe.core.log.AutoLog;
import org.apache.commons.lang3.StringUtils;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import com.xboe.core.JsonResponse;
import com.xboe.core.api.ApiBaseController;
@@ -77,7 +74,22 @@ public class CourseContentApi extends ApiBaseController{
}
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

View File

@@ -7,6 +7,8 @@ import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.xboe.api.ThirdApi;
import com.xboe.module.course.dto.*;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
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.service.IDataUserSyncService;
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.CourseContent;
import com.xboe.module.course.entity.CourseCrowd;
@@ -100,7 +97,8 @@ public class CourseManageApi extends ApiBaseController{
@Autowired
IDataUserSyncService userSyncService;
@Resource
private ThirdApi thirdApi;
// @PostMapping("/test")
// public JsonResponse<PageList<Course>> findTest(Pagination pager,CourseQueryDto dto){
@@ -271,7 +269,7 @@ public class CourseManageApi extends ApiBaseController{
*/
@PostMapping("/save")
@AutoLog(module = "课程",action = "保存课程基本信息",info = "")
public JsonResponse<CourseFullDto> saveCourseFull(@RequestBody CourseFullDto dto){
public JsonResponse<CourseFullDto> saveCourseFull(@RequestBody CourseFullDto dto, HttpServletRequest request){
if(dto.getCourse()==null){
return badRequest("无课程信息");
}
@@ -302,7 +300,14 @@ public class CourseManageApi extends ApiBaseController{
dto.getCourse().setStatus(Course.STATUS_NONE);
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);
} catch (Exception e) {
log.error("整体保存课程信息错误",e);

View File

@@ -1,38 +1,7 @@
package com.xboe.module.course.api;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.*;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import com.xboe.api.ThirdApi;
import com.xboe.api.vo.UserBasicInfo;
import com.xboe.core.orm.FieldFilters;
import com.xboe.module.course.entity.*;
import com.xboe.module.course.vo.TeacherVo;
import com.xboe.school.study.dao.StudyCourseDao;
import com.xboe.school.study.entity.StudyHomeWork;
import com.xboe.school.study.service.IStudyHomeWorkService;
import com.xboe.school.study.service.IStudyService;
import com.xboe.system.user.entity.User;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import com.xboe.common.PageList;
import com.xboe.common.Pagination;
import com.xboe.common.utils.StringUtil;
@@ -42,6 +11,7 @@ import com.xboe.core.orm.FieldFilters;
import com.xboe.module.course.dto.CourseQueryDto;
import com.xboe.module.course.dto.CourseTeacherDto;
import com.xboe.module.course.dto.RankingDto;
import com.xboe.module.course.dto.TeacherCourseDto;
import com.xboe.module.course.entity.*;
import com.xboe.module.course.service.ICourseContentService;
import com.xboe.module.course.service.ICourseSectionService;
@@ -59,6 +29,8 @@ import com.xboe.school.study.entity.StudyHomeWork;
import com.xboe.school.study.service.IStudyCourseService;
import com.xboe.school.study.service.IStudyHomeWorkService;
import com.xboe.school.study.service.IStudyService;
import com.xboe.system.user.entity.User;
import com.xboe.system.user.service.IUserService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
@@ -91,7 +63,8 @@ public class CoursePortalApi extends ApiBaseController{
@Resource
private ICourseService courseService;
@Resource
private IUserService userService;
@Resource
private ITeacherService teacherService;
@@ -309,7 +282,7 @@ public class CoursePortalApi extends ApiBaseController{
if (!Objects.isNull(studyCourse)){
pass = true;
}
if (Objects.isNull(studyCourse) && !courseCrowdList.isEmpty()) {
if (Objects.isNull(studyCourse) && !courseCrowdList.isEmpty() && !StringUtils.isEmpty(audiences)) {
List<String> audienceList = Arrays.asList(audiences.split(",")); // 此用户所在受众组
log.error("---------------参数------------ audienceList = " + audienceList);
for (CourseCrowd c : courseCrowdList) {
@@ -332,17 +305,30 @@ public class CoursePortalApi extends ApiBaseController{
List<CourseContent> cclist=contentService.getByCourseId(id);
List<CourseSection> sectionlist=sectionService.getByCourseId(id);
List<CourseTeacher> teachers=courseService.findTeachersByCourseId(id);
List<TeacherCourseDto> teacherCourseDtos = new ArrayList<>();
//获取教师的介绍信息,因为一门课程 的教师不会太多,所以这里简单直接遍历查询,后续再优化
for(CourseTeacher ct : teachers) {
TeacherCourseDto teacherCourseDto = new TeacherCourseDto();
Teacher t = teacherService.get(ct.getTeacherId());
User user = userService.get(ct.getTeacherId());
if(t!=null) {
ct.setRemark(t.getDescription());
if(redisTemplate.opsForValue().get(ct.getTeacherId())!=null){
if(Objects.equals(redisTemplate.opsForValue().get(ct.getTeacherId()), "1")){
ct.setTeacherName("BOE教师");
}
teacherCourseDto.setCourseId(ct.getCourseId());
teacherCourseDto.setTeacherName(ct.getTeacherName());
teacherCourseDto.setTeacherId(ct.getTeacherId());
teacherCourseDto.setCode(ct.getCode());
teacherCourseDto.setRemark(ct.getRemark());
teacherCourseDto.setSysCreateAid(ct.getSysCreateAid());
teacherCourseDto.setSysCreateBy(ct.getSysCreateBy());
teacherCourseDto.setSysCreateTime(ct.getSysCreateTime());
teacherCourseDto.setId(ct.getId());
teacherCourseDto.setUserNo(user.getUserNo());
teacherCourseDtos.add(teacherCourseDto);
}else if (redisTemplate.opsForValue().get(ct.getTeacherId())==null){
List<String> list=new ArrayList<>();
list.add(ct.getTeacherId());
@@ -350,6 +336,17 @@ public class CoursePortalApi extends ApiBaseController{
if(Objects.equals(redisTemplate.opsForValue().get(ct.getTeacherId()), "1")){
ct.setTeacherName("BOE教师");
}
teacherCourseDto.setCourseId(ct.getCourseId());
teacherCourseDto.setTeacherName(ct.getTeacherName());
teacherCourseDto.setTeacherId(ct.getTeacherId());
teacherCourseDto.setCode(ct.getCode());
teacherCourseDto.setRemark(ct.getRemark());
teacherCourseDto.setSysCreateAid(ct.getSysCreateAid());
teacherCourseDto.setSysCreateBy(ct.getSysCreateBy());
teacherCourseDto.setSysCreateTime(ct.getSysCreateTime());
teacherCourseDto.setId(ct.getId());
teacherCourseDto.setUserNo(user.getUserNo());
teacherCourseDtos.add(teacherCourseDto);
}
}
@@ -358,7 +355,7 @@ public class CoursePortalApi extends ApiBaseController{
rs.put("isCrowd",pass);
rs.put("contents", cclist);
rs.put("sections",sectionlist);
rs.put("teachers",teachers);
rs.put("teachers",teacherCourseDtos);
//查询课程
return success(rs);
@@ -427,49 +424,6 @@ public class CoursePortalApi extends ApiBaseController{
String zipFilePath = "/home/www/elearning/upload/saveZip/" + courseName+"【作业】" + ".zip";
createZipFile(map, zipFilePath);
return success(zipFilePath);
// 创建一个临时文件用于存储ZIP文件
// File tempZipFile = new File("/home/www/elearning/upload/temp.zip");
//
// try (ZipOutputStream zos = new ZipOutputStream(new FileOutputStream(tempZipFile))) {
// for (Map.Entry<String, String> e : map.entrySet()) {
// File fileToZip = new File(e.getValue());
// // 添加 ZIP 条目
// ZipEntry entry = new ZipEntry(e.getKey());
// entry.setSize(fileToZip.length());
//
// zos.putNextEntry(entry);
//
// try (FileInputStream fis = new FileInputStream(fileToZip)) {
// byte[] buffer = new byte[4096];
// int len;
// while ((len = fis.read(buffer)) > 0) {
// zos.write(buffer, 0, len);
// }
// }
//
// zos.closeEntry();
// }
// }
// // 将临时文件移动到指定位置
// Path source = tempZipFile.toPath();
// //生成uuid
//// String uuid = UUID.randomUUID().toString();
// Path destination = Paths.get("/home/www/elearning/upload/saveZip/" + courseName+"【作业】" + ".zip");
//
// // 确保目标目录存在
// Files.createDirectories(destination.getParent());
//
// // 删除目标文件如果已存在
// if (Files.exists(destination)) {
// Files.delete(destination);
// }
//
// // 移动文件
// Files.copy(source, destination, StandardCopyOption.REPLACE_EXISTING);
//
// // 返回文件路径给前端
// String filePath = destination.toAbsolutePath().toString();
// return success(filePath);
}
private static void createZipFile(Map<String, String> map, String zipFilePath) throws IOException {
try (ZipOutputStream zos = new ZipOutputStream(new FileOutputStream(zipFilePath))) {

View File

@@ -9,6 +9,7 @@ import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
@@ -28,6 +29,7 @@ import com.xboe.module.course.service.ICourseFileService;
*/
@RestController
@RequestMapping(value = "/xboe/m/course/cware")
@Slf4j
public class CourseWareApi extends ApiBaseController {
private String cookieName = "PLAYSIGN_TIME";
@@ -97,24 +99,24 @@ public class CourseWareApi extends ApiBaseController {
return badRequest("非法请求");
// return;
}
String httpReferer = request.getHeader("referer");
if (StringUtils.isBlank(httpReferer)) {
return badRequest("非法请求");
// return "非法请求";
}
boolean has=false;
for(String txt :allowUrlSet) {
if(httpReferer.indexOf(txt)>-1) {
has=true;
}
}
if(!has) {
return badRequest("页面不存在");
//return "非法请求";
}
for(String txt :allowUrlSet) {
if(httpReferer.indexOf(txt)>-1) {
has=true;
}
}
if(!has) {
return badRequest("页面不存在");
//return "非法请求";
}
//读取cookies中的时间
String cookieTime = getSignTimeCookie(request);
@@ -131,16 +133,22 @@ public class CourseWareApi extends ApiBaseController {
// 第一个/前端是时间
int index = signStr.indexOf("/");
if (index <= 0) {
log.info("解密后的字符串:"+signStr);
log.info("解密后的字符串的时间拼接:"+index);
return badRequest("验证错误");
}
String time = signStr.substring(0, signStr.indexOf("/"));// 时间字符中long
String cfid = signStr.substring(index+1);// 文件路径
if (!time.equals(cookieTime)) {
return badRequest("验证错误");
}
// if (!time.equals(cookieTime)) {
// log.info("请求头时间和解析后的时间对比:"+"解析时间:"+time+" 请求头时间:"+cookieTime);
// log.info("解密后的字符串的时间拼接:"+signStr);
// return badRequest("验证错误");
// }
if(StringUtils.isBlank(cfid) || cfid.length()<10) {
log.info("查看时间文件路径:"+cfid);
log.info("解密后的字符串的时间拼接:"+signStr);
return badRequest("验证错误");
}

View File

@@ -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;
}

View File

@@ -0,0 +1,9 @@
package com.xboe.module.course.dto;
import lombok.Data;
@Data
public class ScoreParam {
private Long courseId;
private Float score;
}

View File

@@ -0,0 +1,11 @@
package com.xboe.module.course.dto;
import com.xboe.module.course.entity.CourseTeacher;
import lombok.Data;
import java.util.List;
@Data
public class TeacherCourseDto extends CourseTeacher {
private String userNo;
}

View File

@@ -85,4 +85,6 @@ public interface ICourseContentService{
void updateProcessVideo(String contentId, String courseId, Float processVideo);
Object getPaperContentOfOnline(String courseExamId);
}

View File

@@ -1,23 +1,17 @@
package com.xboe.module.course.service.impl;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.util.List;
import javax.annotation.Resource;
import javax.transaction.Transactional;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ObjectNode;
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.UpdateBuilder;
import com.xboe.module.course.dao.CourseAssessDao;
import com.xboe.module.course.dao.CourseContentDao;
import com.xboe.module.course.dao.CourseExamDao;
import com.xboe.module.course.dao.CourseHomeWorkDao;
import com.xboe.module.course.dao.CourseSectionDao;
import com.xboe.module.course.dao.*;
import com.xboe.module.course.dto.CourseContentDto;
import com.xboe.module.course.dto.SortItem;
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.CourseHomeWork;
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 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
public class CourseContentServiceImpl implements ICourseContentService {
@@ -44,7 +51,13 @@ public class CourseContentServiceImpl implements ICourseContentService {
@Resource
private CourseHomeWorkDao homeworkDao;
@Resource
private CourseExamDao courseExamDao;
@Resource
private ExamPaperDao examPaperDao;
@Override
@Transactional
@@ -78,6 +91,9 @@ public class CourseContentServiceImpl implements ICourseContentService {
assessDao.saveOrUpdate(assess);
}
if(exam!=null) {
if ((exam.getRandomMode() && !(exam.getQnum() > 0)) || (!exam.getRandomMode() && exam.getQnum() > 0)) {
throw new RuntimeException("随机选题处参数错误");
}
exam.setCourseId(cc.getCourseId());
exam.setContentId(cc.getId());
if(exam.getPercentScore()==null) {
@@ -188,4 +204,68 @@ public class CourseContentServiceImpl implements ICourseContentService {
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;
}
}

View File

@@ -354,18 +354,18 @@ public class AloneExamApi extends ApiBaseController {
if(StringUtils.isBlank(paperJson)) {
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);
long end=System.currentTimeMillis();
log.info("开始考试用时="+(end-start)+" ms");

View File

@@ -170,7 +170,7 @@ public class ExamQuestionApi extends ApiBaseController {
//从第二行开始获取数据
List<ExamQuestion> examQuestions1 = new ArrayList<>();
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);
for (int i = 2;i<sheetAt.getPhysicalNumberOfRows();i++) {
//获取每一行
@@ -190,45 +190,56 @@ public class ExamQuestionApi extends ApiBaseController {
if(row1.getCell(1).getStringCellValue().equals("多选题")){
examQuestion.setType(2);
}
examQuestion.setKnowledge(row1.getCell(2).getStringCellValue());
if(row1.getCell(3).getStringCellValue().equals("")){
if(row1.getCell(2).getStringCellValue().equals("")){
examQuestion.setDifficulty(2f);
}
if(row1.getCell(3).getStringCellValue().equals("")){
}else if(row1.getCell(2).getStringCellValue().equals("")){
examQuestion.setDifficulty(3f);
}
if(row1.getCell(3).getStringCellValue().equals("")){
} else if(row1.getCell(2).getStringCellValue().equals("")){
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);
// examQuestion.setDefaultScore(Float.valueOf(cell.getStringCellValue()));
//单选
if (!cell.getStringCellValue().contains(",")){
examQuestion.setAnswer(row1.getCell(6).getStringCellValue());
examQuestion.setDefaultScore(Float.valueOf(row1.getCell(4).getStringCellValue()));
Cell cell1 = row1.getCell(5, Row.MissingCellPolicy.CREATE_NULL_AS_BLANK);
examQuestion.setAnswer(row1.getCell(5).getStringCellValue());
if (row1.getCell(3).getStringCellValue().isEmpty()){
examQuestion.setDefaultScore(null);
}else {
examQuestion.setDefaultScore(Float.valueOf(row1.getCell(3).getStringCellValue()));
}
Cell cell1 = row1.getCell(4, Row.MissingCellPolicy.CREATE_NULL_AS_BLANK);
cell1.setCellType(CellType.STRING);
examQuestion.setAnalysis(cell1.getStringCellValue());
List<ExamOption> examOptions = new ArrayList<>();
for (int j=7;j<=13;j++) {
for (int j=6;j<=12;j++) {
if(row1.getCell(j)!=null) {
ExamOption examOption = new ExamOption();
// 截取表头
String substring = row.getCell(j).getStringCellValue().substring(3, 4);
if (row1.getCell(6).getStringCellValue().contains(substring)) {
if (row1.getCell(5).getStringCellValue().contains(substring)) {
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 {
examOption.setIsAnswer(false);
}
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());
@@ -258,19 +269,19 @@ public class ExamQuestionApi extends ApiBaseController {
}
}
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);
examQuestion.setAnalysis(cell1.getStringCellValue());
examQuestion.setAnswer(row1.getCell(6).getStringCellValue());
examQuestion.setAnswer(row1.getCell(5).getStringCellValue());
List<ExamOption> examOptions = new ArrayList<>();
//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())){
ExamOption examOption=new ExamOption();
examOption.setOptions(row.getCell(j).getStringCellValue());
examOption.setContent(row1.getCell(j).getStringCellValue());
examOption.setIsAnswer(true);
examOption.setScore(Float.valueOf(strings[j-7]));
examOption.setScore(Float.valueOf(strings[j-6]));
if(examOption!=null && StringUtil.isNotBlank(examOption.getContent())){
examOptions.add(examOption);
}
@@ -301,45 +312,61 @@ public class ExamQuestionApi extends ApiBaseController {
if(row1.getCell(1).getStringCellValue().equals("多选题")){
examQuestion.setType(2);
}
examQuestion.setKnowledge(row1.getCell(2).getStringCellValue());
if(row1.getCell(3).getStringCellValue().equals("")){
examQuestion.setDifficulty(2f);
log.debug("row1.getCell(2) = " + row1.getCell(2));
if (row1.getCell(2)==null ||row1.getCell(2).getStringCellValue() == null || row1.getCell(2).getStringCellValue().equals("")){
examQuestion.setDifficulty(null);
}else{
if( row1.getCell(2).getStringCellValue().equals("")){
examQuestion.setDifficulty(2f);
}else if(row1.getCell(2).getStringCellValue().equals("")){
examQuestion.setDifficulty(3f);
} else if(row1.getCell(2).getStringCellValue().equals("")){
examQuestion.setDifficulty(1f);
}else if(row1.getCell(2).getStringCellValue().equals("")){
examQuestion.setDifficulty(null);
}
}
if(row1.getCell(3).getStringCellValue().equals("")){
examQuestion.setDifficulty(3f);
}
if(row1.getCell(3).getStringCellValue().equals("")){
examQuestion.setDifficulty(1f);
}
Cell cell = row1.getCell(4);
Cell cell = row1.getCell(3);
cell.setCellType(CellType.STRING);
// examQuestion.setDefaultScore(Float.valueOf(cell.getStringCellValue()));
//单选
if (!cell.getStringCellValue().contains(",")){
examQuestion.setAnswer(row1.getCell(6).getStringCellValue());
examQuestion.setDefaultScore(Float.valueOf(row1.getCell(4).getStringCellValue()));
Cell cell1 = row1.getCell(5, Row.MissingCellPolicy.CREATE_NULL_AS_BLANK);
examQuestion.setAnswer(row1.getCell(5).getStringCellValue());
if (row1.getCell(3).getStringCellValue().isEmpty()){
examQuestion.setDefaultScore(null);
}else {
examQuestion.setDefaultScore(Float.valueOf(row1.getCell(3).getStringCellValue()));
}
Cell cell1 = row1.getCell(4, Row.MissingCellPolicy.CREATE_NULL_AS_BLANK);
cell1.setCellType(CellType.STRING);
examQuestion.setAnalysis(cell1.getStringCellValue());
List<ExamOption> examOptions = new ArrayList<>();
for (int j=7;j<=13;j++) {
for (int j=6;j<=12;j++) {
if(row1.getCell(j)!=null) {
ExamOption examOption = new ExamOption();
// 截取表头
String substring = row.getCell(j).getStringCellValue().substring(3, 4);
if (row1.getCell(6).getStringCellValue().contains(substring)) {
if (row1.getCell(5).getStringCellValue().contains(substring)) {
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 {
examOption.setIsAnswer(false);
}
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());
@@ -369,19 +396,19 @@ public class ExamQuestionApi extends ApiBaseController {
}
}
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);
examQuestion.setAnalysis(cell1.getStringCellValue());
examQuestion.setAnswer(row1.getCell(6).getStringCellValue());
examQuestion.setAnswer(row1.getCell(5).getStringCellValue());
List<ExamOption> examOptions = new ArrayList<>();
//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())){
ExamOption examOption=new ExamOption();
examOption.setOptions(row.getCell(j).getStringCellValue());
examOption.setContent(row1.getCell(j).getStringCellValue());
examOption.setIsAnswer(true);
examOption.setScore(Float.valueOf(strings[j-7]));
examOption.setScore(Float.valueOf(strings[j-6]));
if(examOption!=null && StringUtil.isNotBlank(examOption.getContent())){
examOptions.add(examOption);
}
@@ -413,27 +440,30 @@ public class ExamQuestionApi extends ApiBaseController {
ExamQuestion examQuestion1 = new ExamQuestion();
examQuestion1.setTitle(row2.getCell(0).getStringCellValue());
examQuestion1.setType(3);
examQuestion1.setKnowledge(row2.getCell(1).getStringCellValue());
if(row2.getCell(2).getStringCellValue().equals("")){
System.out.println("1+++++++"+row2.getCell(1));
if(row2.getCell(1).getStringCellValue().equals("")){
examQuestion1.setDifficulty(2f);
}
if(row2.getCell(2).getStringCellValue().equals("")){
}else if(row2.getCell(1).getStringCellValue().equals("")){
examQuestion1.setDifficulty(3f);
}
if(row2.getCell(2).getStringCellValue().equals("")){
} else if(row2.getCell(1).getStringCellValue().equals("")){
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);
examQuestion1.setDefaultScore(Float.valueOf(cell1.getStringCellValue()));
if(row2.getCell(4)!=null) {
examQuestion1.setAnalysis(row2.getCell(4).getStringCellValue());
if (row2.getCell(2).getStringCellValue().isEmpty()){
examQuestion1.setDefaultScore(null);
}else {
examQuestion1.setDefaultScore(Float.valueOf(row2.getCell(2).getStringCellValue()));
}
if(row2.getCell(3)!=null) {
examQuestion1.setAnalysis(row2.getCell(3).getStringCellValue());
}else {
examQuestion1.setAnalysis("");
}
String cvalue=row2.getCell(5).getStringCellValue();
String cvalue=row2.getCell(4).getStringCellValue();
examQuestion1.setAnswer(cvalue.equals("正确")? "true":"false");
if(examQuestion1!=null){
examQuestions2.add(examQuestion1);

View File

@@ -1,7 +1,10 @@
package com.xboe.module.interaction.api;
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.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
@@ -25,18 +28,27 @@ public class CourseGradeApi extends ApiBaseController {
@Resource
private ICourseGradeService service;
@Resource
private ThirdApi thirdApi;
/**
* 评分
* */
@PostMapping("/grade")
@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.setCourseId(courseId);
courseGrade.setScores(score);
courseGrade.setStudyId(studyId);
try {
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);
}catch(Exception e) {
log.error("评分保存错误",e);

View File

@@ -1,6 +1,8 @@
package com.xboe.module.teacher.entity;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.List;
import javax.persistence.Column;
import javax.persistence.Entity;
@@ -153,7 +155,7 @@ public class Teacher extends BaseEntity {
*/
@Column(name = "courses")
private String courses;
/**
* 发薪地id
*/
@@ -206,4 +208,56 @@ public class Teacher extends BaseEntity {
@Column(name = "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;
}

View File

@@ -102,9 +102,12 @@ public class TeacherServiceImpl implements ITeacherService {
public List<Teacher> findByName(String name) {
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)";
// 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>();
try {
List<Object[]> list =dao.findListFields(hql,name);
List<Object[]> list =dao.findListFields(hql);
for(Object[] objs :list) {
Teacher t=new Teacher();
t.setId((String)objs[0]);

View File

@@ -0,0 +1,245 @@
package com.xboe.school.study.api;
import cn.hutool.core.collection.CollUtil;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.xboe.module.course.dto.CourseStudyDto;
import com.xboe.school.study.dao.PhpOnlineCourseDao;
import com.xboe.school.study.dto.PhpOnlineDto;
import com.xxl.job.core.handler.annotation.XxlJob;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.elasticsearch.action.bulk.BulkRequest;
import org.elasticsearch.action.bulk.BulkResponse;
import org.elasticsearch.action.search.SearchRequest;
import org.elasticsearch.action.search.SearchResponse;
import org.elasticsearch.action.update.UpdateRequest;
import org.elasticsearch.client.RequestOptions;
import org.elasticsearch.client.RestHighLevelClient;
import org.elasticsearch.common.unit.TimeValue;
import org.elasticsearch.common.xcontent.XContentType;
import org.elasticsearch.index.query.BoolQueryBuilder;
import org.elasticsearch.index.query.QueryBuilders;
import org.elasticsearch.search.SearchHit;
import org.elasticsearch.search.SearchHits;
import org.elasticsearch.search.builder.SearchSourceBuilder;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.io.IOException;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
import java.util.*;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
@Component
@Slf4j
public class PhpOnlineStudyRecordScheduledTasks {
@Resource
private PhpOnlineCourseDao phpOnlineCourseDao;
@Resource
RestHighLevelClient restHighLevelClient;
// todo 定时、分批、数据库名
@XxlJob("phpOnlineStudyRecordSyncEsTask")
public List<String> phpOnlineStudyRecordSyncEs(Long syncTimePointOfBegin, Long syncTimePointOfEnd, Integer isOnlyRead) throws IOException {
log.info("开始同步PHP学习记录到ES");
// 增量获取PHP中所有已完成的课程
if (syncTimePointOfBegin == null || syncTimePointOfEnd == null) {
LocalDateTime now = LocalDateTime.now();
LocalDateTime halfAnHourAgo = now.minusMinutes(30);
syncTimePointOfBegin = halfAnHourAgo.atZone(ZoneId.systemDefault()).toInstant().getEpochSecond();
syncTimePointOfEnd = now.atZone(ZoneId.systemDefault()).toInstant().getEpochSecond();
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
log.info("同步时间起点:{}", formatter.format(halfAnHourAgo));
log.info("同步时间终点:{}", formatter.format(now));
}
int pageSize = 1000;
int totalRecordsCount = phpOnlineCourseDao.selectRecentLearnRecordListOfCount(syncTimePointOfBegin, syncTimePointOfEnd); // 总记录数
int totalPages = (int) Math.ceil((double) totalRecordsCount / pageSize);
ArrayList<String> tempResultList = new ArrayList<>();
for (int pageNumber = 1; pageNumber <= totalPages; pageNumber++) {
int offset = (pageNumber - 1) * pageSize;
List<PhpOnlineDto> pageData = phpOnlineCourseDao.selectRecentLearnRecordList(syncTimePointOfBegin, syncTimePointOfEnd, offset, pageSize);
ArrayList<String> singleResultList = esDataHandle(isOnlyRead, pageData);
tempResultList.addAll(singleResultList);
}
return tempResultList;
}
private ArrayList<String> esDataHandle(Integer isOnlyRead, List<PhpOnlineDto> recentLearnRecordList) throws IOException {
ArrayList<String> tempResultList = new ArrayList<>();
// 将数据分批每批50条
int batchSize = 50;
int totalSize = recentLearnRecordList.size();
List<List<PhpOnlineDto>> batches = new ArrayList<>();
for (int i = 0; i < totalSize; i += batchSize) {
int end = Math.min(i + batchSize, totalSize);
batches.add(recentLearnRecordList.subList(i, end));
}
for (List<PhpOnlineDto> batch : batches) {
// 构建映射关系
Map<String, PhpOnlineDto> map = batch.stream()
.collect(Collectors.toMap(
phpOnlineDto -> phpOnlineDto.getUserIdOfJava() + "-" + phpOnlineDto.getCourseId(),
phpOnlineDto -> phpOnlineDto
));
// 获取ES中的数据
List<CourseStudyDto> esDataList = getEsData(batch);
// 更新ES数据
List<CourseStudyDto> toBeUpdatedEs = esDataList.stream()
.map(esDataItem -> {
String key = esDataItem.getAccountId() + "-" + esDataItem.getCourseId();
PhpOnlineDto phpOnlineDto = map.get(key);
// 如果找到相应的 PhpOnlineDto 且进度有变化,则进行更新
if (phpOnlineDto != null && !esDataItem.getProgress().equals(phpOnlineDto.getProgress())) {
esDataItem.setProgress(phpOnlineDto.getProgress());
if (phpOnlineDto.getProgress() == 100) {
esDataItem.setStatus(9); // 完成
} else {
esDataItem.setStatus(2); // 进行中
}
return esDataItem;
}
return null; // 返回 null 表示不需要更新
})
.filter(Objects::nonNull) // 去掉返回为 null 的项
.collect(Collectors.toList());
tempResultList.addAll(toBeUpdatedEs.stream().map(esDataItem -> esDataItem.getId()).collect(Collectors.toList()));
if (isOnlyRead != null && isOnlyRead == 1) {
continue;
}
// 调用批量更新方法
// toBeUpdatedEs(toBeUpdatedEs, indexName);
}
return tempResultList;
}
private List<CourseStudyDto> getEsData(List<PhpOnlineDto> finishedCourseList) throws IOException {
SearchRequest searchRequest = new SearchRequest("new_study_resource");
BoolQueryBuilder boolQuery = QueryBuilders.boolQuery();
for (PhpOnlineDto phpOnlineDto : finishedCourseList) {
if (StringUtils.isBlank(phpOnlineDto.getUserIdOfJava()) || StringUtils.isBlank(phpOnlineDto.getCourseId())) {
continue;
}
boolQuery.should(QueryBuilders.boolQuery()
.must(QueryBuilders.termQuery("courseId.keyword", phpOnlineDto.getCourseId()))
.must(QueryBuilders.termQuery("accountId.keyword", phpOnlineDto.getUserIdOfJava()))
.mustNot(QueryBuilders.termQuery("status", 9))
);
}
SearchSourceBuilder sourceBuilder = new SearchSourceBuilder().query(boolQuery).timeout(new TimeValue(60, TimeUnit.SECONDS));
searchRequest.source(sourceBuilder);
if (boolQuery.hasClauses()) {
sourceBuilder.query(boolQuery);
}
searchRequest.source(sourceBuilder);
SearchResponse response = restHighLevelClient.search(searchRequest, RequestOptions.DEFAULT);
SearchHits hits = response.getHits();
List<CourseStudyDto> courseStudyDtoList = new ArrayList<>();
ObjectMapper mapper = new ObjectMapper();
for (SearchHit hit : hits) {
String sourceAsString = hit.getSourceAsString();
try {
CourseStudyDto cft = mapper.readValue(sourceAsString, CourseStudyDto.class);
courseStudyDtoList.add(cft);
} catch (Exception e) {
log.error("转化json到对应失败", sourceAsString);
}
}
return courseStudyDtoList;
}
private void toBeUpdatedEs(List<CourseStudyDto> toBeUpdatedEsData, String indexName) {
if (CollUtil.isEmpty(toBeUpdatedEsData)) {
return;
}
BulkRequest bulkRequest = new BulkRequest();
for (CourseStudyDto courseStudyDto : toBeUpdatedEsData) {
Map<String, Object> docMap = new HashMap<>();
docMap.put("status", courseStudyDto.getStatus());
docMap.put("progress", courseStudyDto.getProgress());
// 创建更新请求并传入单一的docMap
UpdateRequest updateRequest = new UpdateRequest(indexName, courseStudyDto.getId())
.doc(docMap, XContentType.JSON);
// 将请求添加到批量请求中
bulkRequest.add(updateRequest);
}
try {
// 执行批量更新操作
BulkResponse bulkResponse = restHighLevelClient.bulk(bulkRequest, RequestOptions.DEFAULT);
// 检查是否有失败的操作
if (bulkResponse.hasFailures()) {
log.error("批量更新失败: {}", bulkResponse.buildFailureMessage());
} else {
List<String> collect = toBeUpdatedEsData.stream().map(CourseStudyDto::getId).collect(Collectors.toList());
log.info("批量更新成功更新的ES ID列表: {}", collect);
}
} catch (IOException e) {
log.error("执行批量更新时发生错误", e);
}
}
public List<String> phpOnlineStudyRecordSyncEsOfFull(Long syncTimePointOfBegin, Long syncTimePointOfEnd, Integer isOnlyRead) throws IOException {
log.info("开始同步PHP学习记录到ES");
// 增量获取PHP中所有已完成的课程
if (syncTimePointOfBegin == null || syncTimePointOfEnd == null) {
LocalDateTime now = LocalDateTime.now();
LocalDateTime halfAnHourAgo = now.minusMinutes(30);
syncTimePointOfBegin = halfAnHourAgo.atZone(ZoneId.systemDefault()).toInstant().getEpochSecond();
syncTimePointOfEnd = now.atZone(ZoneId.systemDefault()).toInstant().getEpochSecond();
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
log.info("同步时间起点:{}", formatter.format(halfAnHourAgo));
log.info("同步时间终点:{}", formatter.format(now));
}
int pageSize = 1000;
int totalRecordsCount = phpOnlineCourseDao.selectRecentRegRecordListOfCount(syncTimePointOfBegin, syncTimePointOfEnd); // 总记录数
int totalPages = (int) Math.ceil((double) totalRecordsCount / pageSize);
ArrayList<String> tempResultList = new ArrayList<>();
for (int pageNumber = 1; pageNumber <= totalPages; pageNumber++) {
int offset = (pageNumber - 1) * pageSize;
List<PhpOnlineDto> pageData = phpOnlineCourseDao.selectRecentRegRecordList(syncTimePointOfBegin, syncTimePointOfEnd, offset, pageSize);
ArrayList<String> singleResultList = esDataHandle(isOnlyRead, pageData);
tempResultList.addAll(singleResultList);
}
return tempResultList;
}
}

View File

@@ -177,7 +177,7 @@ public class StudyCourseApi extends ApiBaseController{
if (!Objects.isNull(studyCourse)){
pass = true;
}
if (Objects.isNull(studyCourse) && !courseCrowdList.isEmpty()) {
if (Objects.isNull(studyCourse) && !courseCrowdList.isEmpty() && !StringUtils.isEmpty(audiences)) {
List<String> audienceList = Arrays.asList(audiences.split(",")); // 此用户所在受众组
log.error("---------------参数------------ audienceList = " + audienceList);
for (CourseCrowd c : courseCrowdList) {
@@ -228,7 +228,7 @@ public class StudyCourseApi extends ApiBaseController{
//检查是否已报名
StudyCourse sc=service.findByCourseIdAndAid(cid, aid);
if(sc==null) {
if(pass==true && sc==null) {
//未报名,这里直接报名
StudySignup signup=new StudySignup();
signup.setCourseId(cid);
@@ -246,13 +246,13 @@ public class StudyCourseApi extends ApiBaseController{
signup.setSignTime(LocalDateTime.now());
sc=service.autoSignup(signup);
}
rs.put("signup",true);
rs.put("studyId", sc.getId());//学习id
rs.put("progress", sc.getProgress());
//查询上次学习的是什么资源。查询用户的学习情况
List<StudyCourseItem> items=studyService.findByStudyId(sc.getId());
rs.put("contentStudys",items);//学习的内容
if (sc !=null){
rs.put("studyId", sc.getId());//学习id
rs.put("progress", sc.getProgress());
//查询上次学习的是什么资源。查询用户的学习情况
List<StudyCourseItem> items=studyService.findByStudyId(sc.getId());
rs.put("contentStudys",items);//学习的内容
}
return success(rs);
}
@@ -750,18 +750,26 @@ public class StudyCourseApi extends ApiBaseController{
* @param courseId 课程id 用于删除课程报名信息和修改课程学习人数
* */
@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)){
return badRequest("参数异常");
}
//String aid = this.getCurrent().getAccountId();
try {
service.deleteSignUp(id,courseId,studentId);
return success(true);
} catch (Exception e) {
log.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);
}
/**

View File

@@ -24,6 +24,8 @@ import com.xboe.school.study.service.IStudyCourseService;
import lombok.extern.slf4j.Slf4j;
import javax.annotation.Resource;
/**
* ES的课程检索
* @author seastar
@@ -39,6 +41,10 @@ public class StudyCourseESApi extends ApiBaseController{
@Autowired
IStudyCourseService service;
@Resource
private PhpOnlineStudyRecordScheduledTasks phpOnlineStudyRecordScheduledTasks;
@RequestMapping(value="/search",method = {RequestMethod.GET,RequestMethod.POST})
public JsonResponse<PageList<CourseStudyDto>> search(Pagination page, CourseStudyDto dto){
@@ -161,4 +167,26 @@ public class StudyCourseESApi extends ApiBaseController{
return success(true);
}
/**
*
* @param syncTimePointOfBegin
* @param syncTimePointOfEnd
* @param isOnlyRead
* @return
* @throws IOException
*/
@PostMapping("/phpOnlineStudyRecordSyncEs")
public JsonResponse<List<String>> phpOnlineStudyRecordSyncEs(Long syncTimePointOfBegin, Long syncTimePointOfEnd, Integer isOnlyRead) throws IOException {
List<String> courseStudyDtoList = phpOnlineStudyRecordScheduledTasks.phpOnlineStudyRecordSyncEs(syncTimePointOfBegin, syncTimePointOfEnd, isOnlyRead);
return success(courseStudyDtoList);
}
@PostMapping("/phpOnlineStudyRecordSyncEsOfFull")
public JsonResponse<List<String>> phpOnlineStudyRecordSyncEsOfFull(Long syncTimePointOfBegin, Long syncTimePointOfEnd, Integer isOnlyRead) throws IOException {
List<String> courseStudyDtoList = phpOnlineStudyRecordScheduledTasks.phpOnlineStudyRecordSyncEsOfFull(syncTimePointOfBegin, syncTimePointOfEnd, isOnlyRead);
return success(courseStudyDtoList);
}
}

View File

@@ -0,0 +1,281 @@
package com.xboe.school.study.dao;
import cn.hutool.core.collection.CollUtil;
import com.xboe.core.orm.BaseDao;
import com.xboe.school.study.dto.PhpOnlineDto;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Repository;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@Repository
@Slf4j
public class PhpOnlineCourseDao extends BaseDao<PhpOnlineDto> {
@Value("${spring.profiles.active}")
private String activeProfile;
public List<PhpOnlineDto> selectRecentLearnRecordList(Long syncTimePointOfBegin, Long syncTimePointOfEnd, Integer offset, Integer limit) {
String sql =
"SELECT\n" +
" elc.kid AS courseId,\n" +
" elcr.user_id AS userIdOfPhp,\n" +
" ROUND((SUM(CASE WHEN elrc.kid IS NOT NULL THEN 1 ELSE 0 END) / COUNT(1)) * 100, 0) AS progress\n" +
"FROM\n" +
" elearninglms.eln_ln_course elc\n" +
" INNER JOIN elearninglms.eln_ln_course_reg elcr \n" +
" ON elc.kid = elcr.course_id\n" +
" INNER JOIN (\n" +
" SELECT\n" +
" user_id,\n" +
" course_id \n" +
" FROM\n" +
" elearninglms.eln_ln_res_complete\n" +
" WHERE\n" +
" complete_type = '1'\n" +
" AND complete_status = '2'\n" +
" AND updated_at > ?1 AND updated_at < ?2\n" +
" AND is_deleted = 0\n" +
" GROUP BY\n" +
" user_id,\n" +
" course_id\n" +
" ) recentFinishStuent \n" +
" ON recentFinishStuent.user_id = elcr.user_id \n" +
" AND recentFinishStuent.course_id = elcr.course_id\n" +
" INNER JOIN elearninglms.eln_ln_mod_res elms \n" +
" ON elms.course_id = elcr.course_id\n" +
" LEFT JOIN elearninglms.eln_ln_res_complete elrc \n" +
" ON elrc.mod_res_id = elms.kid\n" +
" AND elrc.user_id = elcr.user_id\n" +
" AND elrc.complete_type = '1'\n" +
" AND elrc.complete_status = '2'\n" +
"WHERE\n" +
" elc.is_deleted = 0\n" +
" AND elcr.is_deleted = 0\n" +
" AND elcr.reg_state = '1'\n" +
" AND elms.publish_status = '1'\n" +
" AND elms.is_deleted = '0'\n" +
"GROUP BY\n" +
" elc.kid,\n" +
" elcr.user_id\n" +
"LIMIT " + offset + "," + limit;
List<Object[]> objectList1 = this.sqlFindList(sql, syncTimePointOfBegin, syncTimePointOfEnd);
if (CollUtil.isEmpty(objectList1)) {
log.info("没有找到已完成的数据");
return null;
}
List<PhpOnlineDto> recentLearnRecordList = new ArrayList<>();
for (Object[] objects : objectList1) {
String courseId = objects[0].toString();
String userIdOfPhp = objects[1].toString();
Integer progress = ((BigDecimal) objects[2]).intValue();
PhpOnlineDto phpOnlineDto = new PhpOnlineDto();
phpOnlineDto.setCourseId(courseId);
phpOnlineDto.setUserIdOfPhp(userIdOfPhp);
phpOnlineDto.setProgress(progress);
recentLearnRecordList.add(phpOnlineDto);
}
// 拼接获取所有新系统用户id这里不选择与上面的联表查询有效率问题
String userBasicDataBase;
if (activeProfile.equals("pro")) {
userBasicDataBase = "user_basic";
} else {
userBasicDataBase = "userbasic";
}
List<String> userIds = objectList1.stream().map(objects -> String.valueOf(objects[1])).distinct().collect(Collectors.toList());
List<Object[]> objectList2 = this.sqlFindList("select kid,user_id from " + userBasicDataBase + ".user_account where kid in (?1) and deleted=0 and account_status = 0", userIds);
if (CollUtil.isEmpty(objectList1)) {
log.info("新系统用户数据不存在");
return null;
}
Map<Object, Object> userIdToKidMap = objectList2.stream().collect(Collectors.toMap(object -> object[0], object -> object[1]));
// 设置新系统用户ID
recentLearnRecordList = recentLearnRecordList.stream()
.map(phpOnlineDto -> {
Object userIdOfJavaObj = userIdToKidMap.get(phpOnlineDto.getUserIdOfPhp());
if (userIdOfJavaObj != null) {
phpOnlineDto.setUserIdOfJava(userIdOfJavaObj.toString());
}
return phpOnlineDto;
})
.filter(phpOnlineDto -> StringUtils.isNotBlank(phpOnlineDto.getUserIdOfJava()))
.collect(Collectors.toList());
return recentLearnRecordList;
}
public int selectRecentLearnRecordListOfCount(Long syncTimePointOfBegin, Long syncTimePointOfEnd) {
String sql =
"SELECT COUNT(1) \n" +
"FROM (\n" +
" SELECT elc.kid\n" +
" FROM elearninglms.eln_ln_course elc\n" +
" INNER JOIN elearninglms.eln_ln_course_reg elcr\n" +
" ON elc.kid = elcr.course_id\n" +
" INNER JOIN (\n" +
" SELECT user_id, course_id\n" +
" FROM elearninglms.eln_ln_res_complete\n" +
" WHERE complete_type = '1'\n" +
" AND complete_status = '2'\n" +
" AND updated_at > ?1\n" +
" AND updated_at < ?2\n" +
" AND is_deleted = 0\n" +
" GROUP BY user_id, course_id\n" +
" ) recentFinishStuent\n" +
" ON recentFinishStuent.user_id = elcr.user_id\n" +
" AND recentFinishStuent.course_id = elcr.course_id\n" +
" INNER JOIN elearninglms.eln_ln_mod_res elms\n" +
" ON elms.course_id = elcr.course_id\n" +
" LEFT JOIN elearninglms.eln_ln_res_complete elrc\n" +
" ON elrc.mod_res_id = elms.kid\n" +
" AND elrc.user_id = elcr.user_id\n" +
" AND elrc.complete_type = '1'\n" +
" AND elrc.complete_status = '2'\n" +
" WHERE elc.is_deleted = 0\n" +
" AND elcr.is_deleted = 0\n" +
" AND elcr.reg_state = '1'\n" +
" AND elms.publish_status = '1'\n" +
" AND elms.is_deleted = '0'\n" +
" GROUP BY elc.kid, elcr.user_id\n" +
") temp;\n"; // 每页 1000 条记录OFFSET 计算分页
int count = this.sqlCount(sql, syncTimePointOfBegin, syncTimePointOfEnd);
return count;
}
public List<PhpOnlineDto> selectRecentRegRecordList(Long syncTimePointOfBegin, Long syncTimePointOfEnd, Integer offset, Integer limit) {
String sql =
"SELECT\n" +
" elc.kid AS courseId,\n" +
" elcr.user_id AS userIdOfPhp,\n" +
" ROUND((SUM(CASE WHEN elrc.kid IS NOT NULL THEN 1 ELSE 0 END) / COUNT(1)) * 100, 0) AS progress\n" +
"FROM\n" +
" elearninglms.eln_ln_course elc\n" +
" INNER JOIN elearninglms.eln_ln_course_reg elcr ON elc.kid = elcr.course_id AND elcr.created_at > ?1 AND elcr.created_at < ?2\n" +
" INNER JOIN elearninglms.eln_ln_mod_res elms \n" +
" ON elms.course_id = elcr.course_id\n" +
" LEFT JOIN elearninglms.eln_ln_res_complete elrc \n" +
" ON elrc.mod_res_id = elms.kid\n" +
" AND elrc.user_id = elcr.user_id\n" +
" AND elrc.complete_type = '1'\n" +
" AND elrc.complete_status = '2'\n" +
"WHERE\n" +
" elc.is_deleted = 0\n" +
" AND elcr.is_deleted = 0\n" +
" AND elcr.reg_state = '1'\n" +
" AND elms.publish_status = '1'\n" +
" AND elms.is_deleted = '0'\n" +
"GROUP BY\n" +
" elc.kid,\n" +
" elcr.user_id\n" +
"LIMIT " + offset + "," + limit;
List<Object[]> objectList1 = this.sqlFindList(sql, syncTimePointOfBegin, syncTimePointOfEnd);
if (CollUtil.isEmpty(objectList1)) {
log.info("没有找到已完成的数据");
return null;
}
List<PhpOnlineDto> recentLearnRecordList = new ArrayList<>();
for (Object[] objects : objectList1) {
String courseId = objects[0].toString();
String userIdOfPhp = objects[1].toString();
Integer progress = ((BigDecimal) objects[2]).intValue();
PhpOnlineDto phpOnlineDto = new PhpOnlineDto();
phpOnlineDto.setCourseId(courseId);
phpOnlineDto.setUserIdOfPhp(userIdOfPhp);
phpOnlineDto.setProgress(progress);
recentLearnRecordList.add(phpOnlineDto);
}
// 拼接获取所有新系统用户id这里不选择与上面的联表查询有效率问题
String userBasicDataBase;
if (activeProfile.equals("pro")) {
userBasicDataBase = "user_basic";
} else {
userBasicDataBase = "userbasic";
}
List<String> userIds = objectList1.stream().map(objects -> String.valueOf(objects[1])).distinct().collect(Collectors.toList());
List<Object[]> objectList2 = this.sqlFindList("select kid,user_id from " + userBasicDataBase + ".user_account where kid in (?1) and deleted=0 and account_status = 0", userIds);
if (CollUtil.isEmpty(objectList1)) {
log.info("新系统用户数据不存在");
return null;
}
Map<Object, Object> userIdToKidMap = objectList2.stream().collect(Collectors.toMap(object -> object[0], object -> object[1]));
// 设置新系统用户ID
recentLearnRecordList = recentLearnRecordList.stream()
.map(phpOnlineDto -> {
Object userIdOfJavaObj = userIdToKidMap.get(phpOnlineDto.getUserIdOfPhp());
if (userIdOfJavaObj != null) {
phpOnlineDto.setUserIdOfJava(userIdOfJavaObj.toString());
}
return phpOnlineDto;
})
.filter(phpOnlineDto -> phpOnlineDto.getUserIdOfJava() != null)
.collect(Collectors.toList());
return recentLearnRecordList;
}
public int selectRecentRegRecordListOfCount(Long syncTimePointOfBegin, Long syncTimePointOfEnd) {
String sql =
"SELECT COUNT(1)\n" +
"FROM (\n" +
" SELECT\n" +
" elc.kid\n" +
" FROM\n" +
" elearninglms.eln_ln_course elc\n" +
" INNER JOIN elearninglms.eln_ln_course_reg elcr \n" +
" ON elc.kid = elcr.course_id\n" +
" AND elcr.created_at > ?1\n" +
" AND elcr.created_at < ?2\n" +
" INNER JOIN elearninglms.eln_ln_mod_res elms \n" +
" ON elms.course_id = elcr.course_id\n" +
" LEFT JOIN elearninglms.eln_ln_res_complete elrc \n" +
" ON elrc.mod_res_id = elms.kid\n" +
" AND elrc.user_id = elcr.user_id\n" +
" AND elrc.complete_type = '1'\n" +
" AND elrc.complete_status = '2'\n" +
" WHERE\n" +
" elc.is_deleted = 0\n" +
" AND elcr.is_deleted = 0\n" +
" AND elcr.reg_state = '1'\n" +
" AND elms.publish_status = '1'\n" +
" AND elms.is_deleted = '0'\n" +
" GROUP BY\n" +
" elc.kid,\n" +
" elcr.user_id\n" +
") temp;\n"; // 每页 1000 条记录OFFSET 计算分页
int count = this.sqlCount(sql, syncTimePointOfBegin, syncTimePointOfEnd);
return count;
}
}

View File

@@ -2,10 +2,14 @@ package com.xboe.school.study.dao;
import java.time.LocalDateTime;
import java.util.List;
import java.util.concurrent.TimeUnit;
import com.xboe.api.ThirdApi;
import com.xboe.constants.CacheName;
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.Repository;
import com.xboe.core.orm.BaseDao;
@@ -26,6 +30,9 @@ public class StudyCourseDao extends BaseDao<StudyCourse> {
@Autowired
StudyCourseItemDao scItemDao;
@Autowired
StringRedisTemplate redisTemplate;
@Resource
private ThirdApi thirdApi;
@@ -36,6 +43,11 @@ public class StudyCourseDao extends BaseDao<StudyCourse> {
* @param total
*/
public void finishCheck(String studyId,String courseId,Integer total,String token){
if(StringUtils.isNotEmpty(redisTemplate.opsForValue().get(studyId + "_" + courseId + "_" + total))){
return ;
}
log.info("------1.完成情况检查---------------studyId = " + studyId + " , courseId = " + courseId + " , total = " + total );
LocalDateTime now=LocalDateTime.now();
//已完成的内容
@@ -50,7 +62,9 @@ public class StudyCourseDao extends BaseDao<StudyCourse> {
}
log.info("------3.完成情况检查---------------studyId = " + studyId + " , courseId = " + courseId + " , total = " + total );
//以下注意float类型是否等于100对应
float percent=n*100/total;
float percent=n*100/total;
if(n>=total) {
//自主报名的课程,代表学习完成
super.updateMultiFieldById(studyId,
@@ -58,11 +72,13 @@ public class StudyCourseDao extends BaseDao<StudyCourse> {
UpdateBuilder.create("lastTime",now),
UpdateBuilder.create("finishTime",now),
UpdateBuilder.create("status",StudyCourse.STATUS_FINISH));
redisTemplate.opsForValue().set(studyId + "_" + courseId + "_" + total, "100", 24, TimeUnit.HOURS);
}else {
super.updateMultiFieldById(studyId,
UpdateBuilder.create("progress",percent),
UpdateBuilder.create("lastTime",LocalDateTime.now()),
UpdateBuilder.create("status",StudyCourse.STATUS_STUDYING));
// redisTemplate.opsForValue().set(studyId, String.valueOf(percent), 10, TimeUnit.SECONDS);
}
List<StudyCourse> allUserList = thirdApi.getStudyCourseList(studyId ,courseId, token);
@@ -116,4 +132,8 @@ public class StudyCourseDao extends BaseDao<StudyCourse> {
this.update(update.builder());
}
public StudyCourse findByCourseIdAndAid(String aid, String courseId) {
return this.findOne(FieldFilters.eq("aid",aid),FieldFilters.eq("courseId",courseId));
}
}

View File

@@ -0,0 +1,33 @@
package com.xboe.school.study.dto;
import lombok.Data;
/**
* 批量报名
*
* @author seastar
*/
@Data
public class PhpOnlineDto {
/**
* 课程id
*/
private String courseId;
/**
* 课程名称
*/
private String userIdOfPhp;
/**
* 课程名称
*/
private String userIdOfJava;
/**
* 进度
*/
private Integer progress;
}

View File

@@ -265,6 +265,7 @@ public class StudyCourseServiceImpl implements IStudyCourseService{
}
@Override
public void deleteSignUp(String id,String courseId,String aid) {
log.info("参数id"+id+"参数课程id"+courseId+"参数用户id"+aid);
//删除课程学习记录主表
studyCourseDao.deleteById(id);
//删除学习课程的评估测试结果

View File

@@ -61,7 +61,10 @@ public class StudySignupServiceImpl implements IStudySignupService{
@Override
public void selfSignup(StudySignup signup) {
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));
}

View File

@@ -26,7 +26,7 @@ logging.level.org.hibernate.SQL=DEBUG
logging.level.org.hibernate.type.descriptor.sql.BasicBinder=TRACE
# 设置logback.xml位置
logging.config=classpath:log/logback-dev.xml
logging.config=classpath:log/logback-@profileActive@.xml
## 静态文件目录默认是在static下面以后独立到nginx下面配置
spring.web.resources.static-locations=file:E:/Projects/BOE/10/static

View File

@@ -23,7 +23,7 @@ logging.level.org.hibernate.SQL=ERROR
#logging.level.org.hibernate.type.descriptor.sql.BasicBinder=TRACE
# 设置logback.xml位置
logging.config=classpath:log/logback-dev.xml
logging.config=classpath:log/logback-@profileActive@.xml
## 静态文件目录默认是在static下面以后独立到nginx下面配置
spring.web.resources.static-locations=file:E:/Projects/BOE/java/static

View File

@@ -34,7 +34,7 @@ logging.level.org.hibernate.SQL=ERROR
# logging.level.org.hibernate.type.descriptor.sql.BasicBinder=TRACE
# 设置logback.xml位置
logging.config=classpath:log/logback-dev.xml
logging.config=classpath:log/logback-@profileActive@.xml
## ???????????static????????nginx????
spring.web.resources.static-locations=file:E:/Projects/BOE/java/static
@@ -74,3 +74,12 @@ xboe.email.url=https://u.boe.com/api/b1/email/send
xboe.email.from=boeu_learning@boe.com.cn
xboe.email.user=
xboe.email.security=
xxl.job.admin.addresses=http://u.boe.com/jobAdmin
xxl.job.accessToken=65ddc683-22f5-83b4-de3a-3c97a0a29af0
xxl.job.executor.appname=java-servers-job-api
xxl.job.executor.port=9995
xxl.job.executor.address=
xxl.job.executor.ip=
xxl.job.executor.logpath=/var/log/xxl-job/dw/
xxl.job.executor.logretentiondays=30

View File

@@ -80,4 +80,13 @@ xboe.email.from=boeu_learning@boe.com.cn
xboe.email.user=
xboe.email.security=
boe.domain=https://u-pre.boe.com
boe.domain=https://u-pre.boe.com
xxl.job.admin.addresses=http://u-pre.boe.com/jobAdmin
xxl.job.accessToken=65ddc683-22f5-83b4-de3a-3c97a0a29af0
xxl.job.executor.appname=java-servers-job-api
xxl.job.executor.port=9995
xxl.job.executor.address=
xxl.job.executor.ip=
xxl.job.executor.logpath=/var/log/xxl-job/dw/
xxl.job.executor.logretentiondays=30

View File

@@ -76,3 +76,8 @@ manageApi.editExam=${boe.domain}/manageApi/admin/project/editExam
userBasic.getTeacherIds=${boe.domain}/userbasic/user/getTeacherInfo
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.updateOnLineStatua=${boe.domain}/manageApi/admin/teacherRecord/updateOnLineStatua