mirror of
https://codeup.aliyun.com/67762337eccfc218f6110e0e/per-boe/java-servers.git
synced 2025-12-08 18:36:51 +08:00
Compare commits
3 Commits
zxwy-esSyn
...
yx1101-tea
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6532cf75e3 | ||
|
|
ad357a61b7 | ||
|
|
ffe232eeb9 |
@@ -232,13 +232,6 @@
|
|||||||
<artifactId>spring-retry</artifactId>
|
<artifactId>spring-retry</artifactId>
|
||||||
<version>1.3.1</version>
|
<version>1.3.1</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.xuxueli</groupId>
|
|
||||||
<artifactId>xxl-job-core</artifactId>
|
|
||||||
<version>2.3.0</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
<build>
|
<build>
|
||||||
<resources>
|
<resources>
|
||||||
|
|||||||
@@ -1,40 +0,0 @@
|
|||||||
package com.xboe;
|
|
||||||
|
|
||||||
import com.xxl.job.core.executor.impl.XxlJobSpringExecutor;
|
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
|
||||||
import org.springframework.context.annotation.Bean;
|
|
||||||
import org.springframework.context.annotation.Configuration;
|
|
||||||
|
|
||||||
@Configuration
|
|
||||||
public class XxlJobConfig {
|
|
||||||
|
|
||||||
@Value("${xxl.job.admin.addresses}")
|
|
||||||
private String adminAddresses;
|
|
||||||
@Value("${xxl.job.executor.appname}")
|
|
||||||
private String appName;
|
|
||||||
@Value("${xxl.job.executor.ip}")
|
|
||||||
private String ip;
|
|
||||||
@Value("${xxl.job.executor.port}")
|
|
||||||
private int port;
|
|
||||||
@Value("${xxl.job.accessToken}")
|
|
||||||
private String accessToken;
|
|
||||||
@Value("${xxl.job.executor.logpath}")
|
|
||||||
private String logPath;
|
|
||||||
@Value("${xxl.job.executor.logretentiondays}")
|
|
||||||
private int logRetentionDays;
|
|
||||||
|
|
||||||
@Bean
|
|
||||||
public XxlJobSpringExecutor xxlJobExecutor() {
|
|
||||||
// 创建 XxlJobSpringExecutor 执行器
|
|
||||||
XxlJobSpringExecutor xxlJobSpringExecutor = new XxlJobSpringExecutor();
|
|
||||||
xxlJobSpringExecutor.setAdminAddresses(adminAddresses);
|
|
||||||
xxlJobSpringExecutor.setAppname(appName);
|
|
||||||
xxlJobSpringExecutor.setIp(ip);
|
|
||||||
xxlJobSpringExecutor.setPort(port);
|
|
||||||
xxlJobSpringExecutor.setAccessToken(accessToken);
|
|
||||||
xxlJobSpringExecutor.setLogPath(logPath);
|
|
||||||
xxlJobSpringExecutor.setLogRetentionDays(logRetentionDays);
|
|
||||||
// 返回
|
|
||||||
return xxlJobSpringExecutor;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -80,8 +80,8 @@ public class ThirdApi {
|
|||||||
private String syncCourseStudent;
|
private String syncCourseStudent;
|
||||||
@Value("${coursesuilt.syncOnLineScore}")
|
@Value("${coursesuilt.syncOnLineScore}")
|
||||||
private String syncOnLineScore;
|
private String syncOnLineScore;
|
||||||
@Value("${coursesuilt.updateOnLineStatua}")
|
@Value("${coursesuilt.updateOnLineStatus}")
|
||||||
private String updateOnLineStatua;
|
private String updateOnLineStatus;
|
||||||
|
|
||||||
|
|
||||||
//获取例外人员的id
|
//获取例外人员的id
|
||||||
@@ -335,9 +335,9 @@ public class ThirdApi {
|
|||||||
.body()).orElseThrow(() -> new RuntimeException("token校验失败"));
|
.body()).orElseThrow(() -> new RuntimeException("token校验失败"));
|
||||||
log.info("syncOnLineScore = " + resp);
|
log.info("syncOnLineScore = " + resp);
|
||||||
}
|
}
|
||||||
public void updateOnLineStatua(CourseParam param, String token){
|
public void updateOnLineStatus(CourseParam param, String token){
|
||||||
String resp = Optional.ofNullable(
|
String resp = Optional.ofNullable(
|
||||||
HttpRequest.post(updateOnLineStatua).body(JSONUtil.toJsonStr(param)).header("token", token).execute()
|
HttpRequest.post(updateOnLineStatus).body(JSONUtil.toJsonStr(param)).header("token", token).execute()
|
||||||
.body()).orElseThrow(() -> new RuntimeException("token校验失败"));
|
.body()).orElseThrow(() -> new RuntimeException("token校验失败"));
|
||||||
log.info("updateOrSaveCourse = " + resp);
|
log.info("updateOrSaveCourse = " + resp);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
package com.xboe.module.boecase.api;
|
package com.xboe.module.boecase.api;
|
||||||
|
|
||||||
import com.xboe.module.boecase.service.ICasesService;
|
import com.xboe.module.boecase.service.ICasesService;
|
||||||
import com.xxl.job.core.handler.annotation.XxlJob;
|
|
||||||
import org.springframework.scheduling.annotation.Scheduled;
|
import org.springframework.scheduling.annotation.Scheduled;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
@@ -17,7 +16,6 @@ public class CaseScheduledTasks {
|
|||||||
* 每月的第一天的1:00执行
|
* 每月的第一天的1:00执行
|
||||||
*/
|
*/
|
||||||
// @Scheduled(cron = "0 0 1 1 * ?")
|
// @Scheduled(cron = "0 0 1 1 * ?")
|
||||||
@XxlJob("refreshViewsRankOfMajor")
|
|
||||||
public void refreshViewsRankOfMajor() {
|
public void refreshViewsRankOfMajor() {
|
||||||
casesService.refreshViewsRankOfMajor();
|
casesService.refreshViewsRankOfMajor();
|
||||||
}
|
}
|
||||||
@@ -25,8 +23,7 @@ public class CaseScheduledTasks {
|
|||||||
/**
|
/**
|
||||||
* 季初第一天两点执行,cron表达式设置为每个季度的第一个月的第一天的特定时间。每个季度的第一个月是1月、4月、7月和10月:
|
* 季初第一天两点执行,cron表达式设置为每个季度的第一个月的第一天的特定时间。每个季度的第一个月是1月、4月、7月和10月:
|
||||||
*/
|
*/
|
||||||
// @Scheduled(cron = "0 0 2 1 1,4,7,10 ?")
|
@Scheduled(cron = "0 0 2 1 1,4,7,10 ?")
|
||||||
@XxlJob("refreshLastQuarterStatistics")
|
|
||||||
public void refreshLastQuarterStatistics() {
|
public void refreshLastQuarterStatistics() {
|
||||||
casesService.refreshLastQuarterStatistics();
|
casesService.refreshLastQuarterStatistics();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -359,7 +359,7 @@ public class CourseAuditApi extends ApiBaseController{
|
|||||||
String token = request.getHeader("Xboe-Access-Token");
|
String token = request.getHeader("Xboe-Access-Token");
|
||||||
CourseParam param = new CourseParam();
|
CourseParam param = new CourseParam();
|
||||||
param.setId(courseId);
|
param.setId(courseId);
|
||||||
thirdApi.updateOnLineStatua(param,token);
|
thirdApi.updateOnLineStatus(param,token);
|
||||||
}
|
}
|
||||||
return success(true);
|
return success(true);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|||||||
@@ -11,7 +11,6 @@ import com.xboe.core.orm.FieldFilters;
|
|||||||
import com.xboe.module.course.dto.CourseQueryDto;
|
import com.xboe.module.course.dto.CourseQueryDto;
|
||||||
import com.xboe.module.course.dto.CourseTeacherDto;
|
import com.xboe.module.course.dto.CourseTeacherDto;
|
||||||
import com.xboe.module.course.dto.RankingDto;
|
import com.xboe.module.course.dto.RankingDto;
|
||||||
import com.xboe.module.course.dto.TeacherCourseDto;
|
|
||||||
import com.xboe.module.course.entity.*;
|
import com.xboe.module.course.entity.*;
|
||||||
import com.xboe.module.course.service.ICourseContentService;
|
import com.xboe.module.course.service.ICourseContentService;
|
||||||
import com.xboe.module.course.service.ICourseSectionService;
|
import com.xboe.module.course.service.ICourseSectionService;
|
||||||
@@ -29,8 +28,6 @@ import com.xboe.school.study.entity.StudyHomeWork;
|
|||||||
import com.xboe.school.study.service.IStudyCourseService;
|
import com.xboe.school.study.service.IStudyCourseService;
|
||||||
import com.xboe.school.study.service.IStudyHomeWorkService;
|
import com.xboe.school.study.service.IStudyHomeWorkService;
|
||||||
import com.xboe.school.study.service.IStudyService;
|
import com.xboe.school.study.service.IStudyService;
|
||||||
import com.xboe.system.user.entity.User;
|
|
||||||
import com.xboe.system.user.service.IUserService;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
@@ -63,8 +60,7 @@ public class CoursePortalApi extends ApiBaseController{
|
|||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private ICourseService courseService;
|
private ICourseService courseService;
|
||||||
@Resource
|
|
||||||
private IUserService userService;
|
|
||||||
@Resource
|
@Resource
|
||||||
private ITeacherService teacherService;
|
private ITeacherService teacherService;
|
||||||
|
|
||||||
@@ -282,7 +278,7 @@ public class CoursePortalApi extends ApiBaseController{
|
|||||||
if (!Objects.isNull(studyCourse)){
|
if (!Objects.isNull(studyCourse)){
|
||||||
pass = true;
|
pass = true;
|
||||||
}
|
}
|
||||||
if (Objects.isNull(studyCourse) && !courseCrowdList.isEmpty() && !StringUtils.isEmpty(audiences)) {
|
if (Objects.isNull(studyCourse) && !courseCrowdList.isEmpty()) {
|
||||||
List<String> audienceList = Arrays.asList(audiences.split(",")); // 此用户所在受众组
|
List<String> audienceList = Arrays.asList(audiences.split(",")); // 此用户所在受众组
|
||||||
log.error("---------------参数------------ audienceList = " + audienceList);
|
log.error("---------------参数------------ audienceList = " + audienceList);
|
||||||
for (CourseCrowd c : courseCrowdList) {
|
for (CourseCrowd c : courseCrowdList) {
|
||||||
@@ -305,30 +301,17 @@ public class CoursePortalApi extends ApiBaseController{
|
|||||||
List<CourseContent> cclist=contentService.getByCourseId(id);
|
List<CourseContent> cclist=contentService.getByCourseId(id);
|
||||||
List<CourseSection> sectionlist=sectionService.getByCourseId(id);
|
List<CourseSection> sectionlist=sectionService.getByCourseId(id);
|
||||||
List<CourseTeacher> teachers=courseService.findTeachersByCourseId(id);
|
List<CourseTeacher> teachers=courseService.findTeachersByCourseId(id);
|
||||||
List<TeacherCourseDto> teacherCourseDtos = new ArrayList<>();
|
|
||||||
|
|
||||||
//获取教师的介绍信息,因为一门课程 的教师不会太多,所以这里简单直接遍历查询,后续再优化
|
//获取教师的介绍信息,因为一门课程 的教师不会太多,所以这里简单直接遍历查询,后续再优化
|
||||||
for(CourseTeacher ct : teachers) {
|
for(CourseTeacher ct : teachers) {
|
||||||
TeacherCourseDto teacherCourseDto = new TeacherCourseDto();
|
|
||||||
Teacher t = teacherService.get(ct.getTeacherId());
|
Teacher t = teacherService.get(ct.getTeacherId());
|
||||||
User user = userService.get(ct.getTeacherId());
|
|
||||||
if(t!=null) {
|
if(t!=null) {
|
||||||
ct.setRemark(t.getDescription());
|
ct.setRemark(t.getDescription());
|
||||||
if(redisTemplate.opsForValue().get(ct.getTeacherId())!=null){
|
if(redisTemplate.opsForValue().get(ct.getTeacherId())!=null){
|
||||||
if(Objects.equals(redisTemplate.opsForValue().get(ct.getTeacherId()), "1")){
|
if(Objects.equals(redisTemplate.opsForValue().get(ct.getTeacherId()), "1")){
|
||||||
ct.setTeacherName("BOE教师");
|
ct.setTeacherName("BOE教师");
|
||||||
}
|
}
|
||||||
teacherCourseDto.setCourseId(ct.getCourseId());
|
|
||||||
teacherCourseDto.setTeacherName(ct.getTeacherName());
|
|
||||||
teacherCourseDto.setTeacherId(ct.getTeacherId());
|
|
||||||
teacherCourseDto.setCode(ct.getCode());
|
|
||||||
teacherCourseDto.setRemark(ct.getRemark());
|
|
||||||
teacherCourseDto.setSysCreateAid(ct.getSysCreateAid());
|
|
||||||
teacherCourseDto.setSysCreateBy(ct.getSysCreateBy());
|
|
||||||
teacherCourseDto.setSysCreateTime(ct.getSysCreateTime());
|
|
||||||
teacherCourseDto.setId(ct.getId());
|
|
||||||
teacherCourseDto.setUserNo(user.getUserNo());
|
|
||||||
teacherCourseDtos.add(teacherCourseDto);
|
|
||||||
}else if (redisTemplate.opsForValue().get(ct.getTeacherId())==null){
|
}else if (redisTemplate.opsForValue().get(ct.getTeacherId())==null){
|
||||||
List<String> list=new ArrayList<>();
|
List<String> list=new ArrayList<>();
|
||||||
list.add(ct.getTeacherId());
|
list.add(ct.getTeacherId());
|
||||||
@@ -336,17 +319,6 @@ public class CoursePortalApi extends ApiBaseController{
|
|||||||
if(Objects.equals(redisTemplate.opsForValue().get(ct.getTeacherId()), "1")){
|
if(Objects.equals(redisTemplate.opsForValue().get(ct.getTeacherId()), "1")){
|
||||||
ct.setTeacherName("BOE教师");
|
ct.setTeacherName("BOE教师");
|
||||||
}
|
}
|
||||||
teacherCourseDto.setCourseId(ct.getCourseId());
|
|
||||||
teacherCourseDto.setTeacherName(ct.getTeacherName());
|
|
||||||
teacherCourseDto.setTeacherId(ct.getTeacherId());
|
|
||||||
teacherCourseDto.setCode(ct.getCode());
|
|
||||||
teacherCourseDto.setRemark(ct.getRemark());
|
|
||||||
teacherCourseDto.setSysCreateAid(ct.getSysCreateAid());
|
|
||||||
teacherCourseDto.setSysCreateBy(ct.getSysCreateBy());
|
|
||||||
teacherCourseDto.setSysCreateTime(ct.getSysCreateTime());
|
|
||||||
teacherCourseDto.setId(ct.getId());
|
|
||||||
teacherCourseDto.setUserNo(user.getUserNo());
|
|
||||||
teacherCourseDtos.add(teacherCourseDto);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -355,7 +327,7 @@ public class CoursePortalApi extends ApiBaseController{
|
|||||||
rs.put("isCrowd",pass);
|
rs.put("isCrowd",pass);
|
||||||
rs.put("contents", cclist);
|
rs.put("contents", cclist);
|
||||||
rs.put("sections",sectionlist);
|
rs.put("sections",sectionlist);
|
||||||
rs.put("teachers",teacherCourseDtos);
|
rs.put("teachers",teachers);
|
||||||
//查询课程
|
//查询课程
|
||||||
return success(rs);
|
return success(rs);
|
||||||
|
|
||||||
|
|||||||
@@ -1,11 +0,0 @@
|
|||||||
package com.xboe.module.course.dto;
|
|
||||||
|
|
||||||
import com.xboe.module.course.entity.CourseTeacher;
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
@Data
|
|
||||||
public class TeacherCourseDto extends CourseTeacher {
|
|
||||||
private String userNo;
|
|
||||||
}
|
|
||||||
@@ -47,7 +47,8 @@ public class CourseGradeApi extends ApiBaseController {
|
|||||||
ScoreParam param = new ScoreParam();
|
ScoreParam param = new ScoreParam();
|
||||||
param.setCourseId(Long.parseLong(courseId));
|
param.setCourseId(Long.parseLong(courseId));
|
||||||
param.setScore(score);
|
param.setScore(score);
|
||||||
thirdApi.syncOnLineScore(param,token);
|
// 同步在线课评分
|
||||||
|
// thirdApi.syncOnLineScore(param,token);
|
||||||
return success(aFloat);
|
return success(aFloat);
|
||||||
}catch(Exception e) {
|
}catch(Exception e) {
|
||||||
log.error("评分保存错误",e);
|
log.error("评分保存错误",e);
|
||||||
|
|||||||
@@ -1,260 +0,0 @@
|
|||||||
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;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 定时同步PHP数据库数据到es中,计划定时20分钟执行一次。具体实现是,
|
|
||||||
* 第一步,查询最近半小时内完成任一课件的课程学习,获取的信息有课程ID,学员ID,学习状态、学习进度。
|
|
||||||
* 第二步,根据上述得到的课程ID,学员ID,查询es中的未完成的记录。
|
|
||||||
* 第三步,比对两者学习进度,如果不一致,以数据库学习记录为准,修改ES
|
|
||||||
*/
|
|
||||||
@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);
|
|
||||||
|
|
||||||
if (CollUtil.isEmpty(esDataList)){
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 更新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);
|
|
||||||
}
|
|
||||||
return tempResultList;
|
|
||||||
}
|
|
||||||
|
|
||||||
private List<CourseStudyDto> getEsData(List<PhpOnlineDto> finishedCourseList) throws IOException {
|
|
||||||
log.info("待处理的数据:{}", finishedCourseList);
|
|
||||||
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))
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!boolQuery.hasClauses()) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
SearchSourceBuilder sourceBuilder = new SearchSourceBuilder()
|
|
||||||
.query(boolQuery)
|
|
||||||
.timeout(new TimeValue(60, TimeUnit.SECONDS))
|
|
||||||
.size(finishedCourseList.size() + 10);
|
|
||||||
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) {
|
|
||||||
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("new_study_resource", 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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 第一步,查询最近报名的学习,获取的信息有课程ID,学员ID,学习状态、学习进度。
|
|
||||||
* 第二步,根据上述得到的课程ID,学员ID,查询es中的未完成的记录。
|
|
||||||
* 第三步,比对两者学习进度,如果不一致,以数据库学习记录为准,修改ES。
|
|
||||||
*/
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -177,7 +177,7 @@ public class StudyCourseApi extends ApiBaseController{
|
|||||||
if (!Objects.isNull(studyCourse)){
|
if (!Objects.isNull(studyCourse)){
|
||||||
pass = true;
|
pass = true;
|
||||||
}
|
}
|
||||||
if (Objects.isNull(studyCourse) && !courseCrowdList.isEmpty() && !StringUtils.isEmpty(audiences)) {
|
if (Objects.isNull(studyCourse) && !courseCrowdList.isEmpty()) {
|
||||||
List<String> audienceList = Arrays.asList(audiences.split(",")); // 此用户所在受众组
|
List<String> audienceList = Arrays.asList(audiences.split(",")); // 此用户所在受众组
|
||||||
log.error("---------------参数------------ audienceList = " + audienceList);
|
log.error("---------------参数------------ audienceList = " + audienceList);
|
||||||
for (CourseCrowd c : courseCrowdList) {
|
for (CourseCrowd c : courseCrowdList) {
|
||||||
@@ -228,7 +228,7 @@ public class StudyCourseApi extends ApiBaseController{
|
|||||||
|
|
||||||
//检查是否已报名
|
//检查是否已报名
|
||||||
StudyCourse sc=service.findByCourseIdAndAid(cid, aid);
|
StudyCourse sc=service.findByCourseIdAndAid(cid, aid);
|
||||||
if(pass==true && sc==null) {
|
if(sc==null) {
|
||||||
//未报名,这里直接报名
|
//未报名,这里直接报名
|
||||||
StudySignup signup=new StudySignup();
|
StudySignup signup=new StudySignup();
|
||||||
signup.setCourseId(cid);
|
signup.setCourseId(cid);
|
||||||
@@ -246,13 +246,13 @@ public class StudyCourseApi extends ApiBaseController{
|
|||||||
signup.setSignTime(LocalDateTime.now());
|
signup.setSignTime(LocalDateTime.now());
|
||||||
sc=service.autoSignup(signup);
|
sc=service.autoSignup(signup);
|
||||||
}
|
}
|
||||||
if (sc !=null){
|
|
||||||
rs.put("studyId", sc.getId());//学习id
|
rs.put("signup",true);
|
||||||
rs.put("progress", sc.getProgress());
|
rs.put("studyId", sc.getId());//学习id
|
||||||
//查询上次学习的是什么资源。查询用户的学习情况
|
rs.put("progress", sc.getProgress());
|
||||||
List<StudyCourseItem> items=studyService.findByStudyId(sc.getId());
|
//查询上次学习的是什么资源。查询用户的学习情况
|
||||||
rs.put("contentStudys",items);//学习的内容
|
List<StudyCourseItem> items=studyService.findByStudyId(sc.getId());
|
||||||
}
|
rs.put("contentStudys",items);//学习的内容
|
||||||
|
|
||||||
return success(rs);
|
return success(rs);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,8 +24,6 @@ import com.xboe.school.study.service.IStudyCourseService;
|
|||||||
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ES的课程检索
|
* ES的课程检索
|
||||||
* @author seastar
|
* @author seastar
|
||||||
@@ -41,10 +39,6 @@ public class StudyCourseESApi extends ApiBaseController{
|
|||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
IStudyCourseService service;
|
IStudyCourseService service;
|
||||||
|
|
||||||
@Resource
|
|
||||||
private PhpOnlineStudyRecordScheduledTasks phpOnlineStudyRecordScheduledTasks;
|
|
||||||
|
|
||||||
|
|
||||||
@RequestMapping(value="/search",method = {RequestMethod.GET,RequestMethod.POST})
|
@RequestMapping(value="/search",method = {RequestMethod.GET,RequestMethod.POST})
|
||||||
public JsonResponse<PageList<CourseStudyDto>> search(Pagination page, CourseStudyDto dto){
|
public JsonResponse<PageList<CourseStudyDto>> search(Pagination page, CourseStudyDto dto){
|
||||||
@@ -167,26 +161,4 @@ public class StudyCourseESApi extends ApiBaseController{
|
|||||||
|
|
||||||
return success(true);
|
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,280 +0,0 @@
|
|||||||
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> userIdOfPhpList = 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", userIdOfPhpList);
|
|
||||||
|
|
||||||
if (CollUtil.isEmpty(objectList1)) {
|
|
||||||
log.info("新系统用户数据不存在");
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
Map<Object, Object> kidAndUserIdMap = objectList2.stream().collect(Collectors.toMap(object -> object[0], object -> object[1]));
|
|
||||||
|
|
||||||
// 设置新系统用户ID
|
|
||||||
recentLearnRecordList = recentLearnRecordList.stream()
|
|
||||||
.map(phpOnlineDto -> {
|
|
||||||
Object userIdOfJavaObj = kidAndUserIdMap.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;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -2,14 +2,10 @@ package com.xboe.school.study.dao;
|
|||||||
|
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.concurrent.TimeUnit;
|
|
||||||
|
|
||||||
import com.xboe.api.ThirdApi;
|
import com.xboe.api.ThirdApi;
|
||||||
import com.xboe.constants.CacheName;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.data.redis.core.StringRedisTemplate;
|
|
||||||
import org.springframework.stereotype.Repository;
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
import com.xboe.core.orm.BaseDao;
|
import com.xboe.core.orm.BaseDao;
|
||||||
@@ -30,9 +26,6 @@ public class StudyCourseDao extends BaseDao<StudyCourse> {
|
|||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
StudyCourseItemDao scItemDao;
|
StudyCourseItemDao scItemDao;
|
||||||
@Autowired
|
|
||||||
StringRedisTemplate redisTemplate;
|
|
||||||
|
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private ThirdApi thirdApi;
|
private ThirdApi thirdApi;
|
||||||
@@ -43,11 +36,6 @@ public class StudyCourseDao extends BaseDao<StudyCourse> {
|
|||||||
* @param total
|
* @param total
|
||||||
*/
|
*/
|
||||||
public void finishCheck(String studyId,String courseId,Integer total,String token){
|
public void finishCheck(String studyId,String courseId,Integer total,String token){
|
||||||
|
|
||||||
if(StringUtils.isNotEmpty(redisTemplate.opsForValue().get(studyId + "_" + courseId + "_" + total))){
|
|
||||||
return ;
|
|
||||||
}
|
|
||||||
|
|
||||||
log.info("------1.完成情况检查---------------studyId = " + studyId + " , courseId = " + courseId + " , total = " + total );
|
log.info("------1.完成情况检查---------------studyId = " + studyId + " , courseId = " + courseId + " , total = " + total );
|
||||||
LocalDateTime now=LocalDateTime.now();
|
LocalDateTime now=LocalDateTime.now();
|
||||||
//已完成的内容
|
//已完成的内容
|
||||||
@@ -62,9 +50,7 @@ public class StudyCourseDao extends BaseDao<StudyCourse> {
|
|||||||
}
|
}
|
||||||
log.info("------3.完成情况检查---------------studyId = " + studyId + " , courseId = " + courseId + " , total = " + total );
|
log.info("------3.完成情况检查---------------studyId = " + studyId + " , courseId = " + courseId + " , total = " + total );
|
||||||
//以下注意,float类型,是否等于100对应
|
//以下注意,float类型,是否等于100对应
|
||||||
float percent=n*100/total;
|
float percent=n*100/total;
|
||||||
|
|
||||||
|
|
||||||
if(n>=total) {
|
if(n>=total) {
|
||||||
//自主报名的课程,代表学习完成
|
//自主报名的课程,代表学习完成
|
||||||
super.updateMultiFieldById(studyId,
|
super.updateMultiFieldById(studyId,
|
||||||
@@ -72,13 +58,11 @@ public class StudyCourseDao extends BaseDao<StudyCourse> {
|
|||||||
UpdateBuilder.create("lastTime",now),
|
UpdateBuilder.create("lastTime",now),
|
||||||
UpdateBuilder.create("finishTime",now),
|
UpdateBuilder.create("finishTime",now),
|
||||||
UpdateBuilder.create("status",StudyCourse.STATUS_FINISH));
|
UpdateBuilder.create("status",StudyCourse.STATUS_FINISH));
|
||||||
redisTemplate.opsForValue().set(studyId + "_" + courseId + "_" + total, "100", 24, TimeUnit.HOURS);
|
|
||||||
}else {
|
}else {
|
||||||
super.updateMultiFieldById(studyId,
|
super.updateMultiFieldById(studyId,
|
||||||
UpdateBuilder.create("progress",percent),
|
UpdateBuilder.create("progress",percent),
|
||||||
UpdateBuilder.create("lastTime",LocalDateTime.now()),
|
UpdateBuilder.create("lastTime",LocalDateTime.now()),
|
||||||
UpdateBuilder.create("status",StudyCourse.STATUS_STUDYING));
|
UpdateBuilder.create("status",StudyCourse.STATUS_STUDYING));
|
||||||
// redisTemplate.opsForValue().set(studyId, String.valueOf(percent), 10, TimeUnit.SECONDS);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
List<StudyCourse> allUserList = thirdApi.getStudyCourseList(studyId ,courseId, token);
|
List<StudyCourse> allUserList = thirdApi.getStudyCourseList(studyId ,courseId, token);
|
||||||
|
|||||||
@@ -1,33 +0,0 @@
|
|||||||
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;
|
|
||||||
}
|
|
||||||
@@ -74,12 +74,3 @@ xboe.email.url=https://u.boe.com/api/b1/email/send
|
|||||||
xboe.email.from=boeu_learning@boe.com.cn
|
xboe.email.from=boeu_learning@boe.com.cn
|
||||||
xboe.email.user=
|
xboe.email.user=
|
||||||
xboe.email.security=
|
xboe.email.security=
|
||||||
|
|
||||||
xxl.job.admin.addresses=http://u.boe.com/jobAdmin
|
|
||||||
xxl.job.accessToken=65ddc683-22f5-83b4-de3a-3c97a0a29af0
|
|
||||||
xxl.job.executor.appname=java-servers-job-api
|
|
||||||
xxl.job.executor.port=9995
|
|
||||||
xxl.job.executor.address=
|
|
||||||
xxl.job.executor.ip=
|
|
||||||
xxl.job.executor.logpath=/var/log/xxl-job/dw/
|
|
||||||
xxl.job.executor.logretentiondays=30
|
|
||||||
@@ -80,13 +80,4 @@ xboe.email.from=boeu_learning@boe.com.cn
|
|||||||
xboe.email.user=
|
xboe.email.user=
|
||||||
xboe.email.security=
|
xboe.email.security=
|
||||||
|
|
||||||
boe.domain=https://u-pre.boe.com
|
boe.domain=https://u-pre.boe.com
|
||||||
|
|
||||||
xxl.job.admin.addresses=http://u-pre.boe.com/jobAdmin
|
|
||||||
xxl.job.accessToken=65ddc683-22f5-83b4-de3a-3c97a0a29af0
|
|
||||||
xxl.job.executor.appname=java-servers-job-api
|
|
||||||
xxl.job.executor.port=9995
|
|
||||||
xxl.job.executor.address=
|
|
||||||
xxl.job.executor.ip=
|
|
||||||
xxl.job.executor.logpath=/var/log/xxl-job/dw/
|
|
||||||
xxl.job.executor.logretentiondays=30
|
|
||||||
@@ -80,4 +80,4 @@ userBasic.getUserBasicInfo=${boe.domain}/userbasic/user/getUserBasicInfo
|
|||||||
coursesuilt.updateOrSaveCourse=${boe.domain}/manageApi/admin/teacherRecord/updateOrSaveCourse
|
coursesuilt.updateOrSaveCourse=${boe.domain}/manageApi/admin/teacherRecord/updateOrSaveCourse
|
||||||
coursesuilt.syncCourseStudent=${boe.domain}/manageApi/admin/teacherRecord/syncCourseStudent
|
coursesuilt.syncCourseStudent=${boe.domain}/manageApi/admin/teacherRecord/syncCourseStudent
|
||||||
coursesuilt.syncOnLineScore=${boe.domain}/manageApi/admin/teacherRecord/syncOnLineScore
|
coursesuilt.syncOnLineScore=${boe.domain}/manageApi/admin/teacherRecord/syncOnLineScore
|
||||||
coursesuilt.updateOnLineStatua=${boe.domain}/manageApi/admin/teacherRecord/updateOnLineStatua
|
coursesuilt.updateOnLineStatus=${boe.domain}/manageApi/admin/teacherRecord/updateOnLineStatus
|
||||||
|
|||||||
Reference in New Issue
Block a user