mirror of
https://codeup.aliyun.com/67762337eccfc218f6110e0e/per-boe/java-servers.git
synced 2025-12-07 09:56:47 +08:00
Compare commits
22 Commits
zcwy0927-y
...
zcwy1105-l
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1250903178 | ||
|
|
d92d2fa0ba | ||
|
|
d94485d00a | ||
|
|
2a771b8d20 | ||
|
|
f07bdce34f | ||
|
|
b0f01c6300 | ||
|
|
e51d4dd8cb | ||
|
|
ea1cda25bd | ||
|
|
3d3e660e68 | ||
|
|
b509b783a1 | ||
|
|
469145d25c | ||
|
|
25d8594a2b | ||
|
|
3001c25590 | ||
|
|
95b63155cd | ||
|
|
0e897b5f14 | ||
|
|
39e336d044 | ||
|
|
4ef1b5b1e9 | ||
|
|
33df8b0831 | ||
|
|
b61923233a | ||
|
|
effb45c6d0 | ||
|
|
95aa5f7abe | ||
|
|
3af3c2eedf |
@@ -15,7 +15,7 @@ public class CaseScheduledTasks {
|
||||
/**
|
||||
* 每月的第一天的1:00执行
|
||||
*/
|
||||
@Scheduled(cron = "0 0 1 1 * ?")
|
||||
// @Scheduled(cron = "0 0 1 1 * ?")
|
||||
public void refreshViewsRankOfMajor() {
|
||||
casesService.refreshViewsRankOfMajor();
|
||||
}
|
||||
|
||||
@@ -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.*;
|
||||
@@ -1203,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);
|
||||
|
||||
@@ -1299,8 +1300,8 @@ 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());
|
||||
|
||||
@@ -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("验证错误");
|
||||
}
|
||||
|
||||
|
||||
@@ -93,6 +93,9 @@ public class CourseServiceImpl implements ICourseService {
|
||||
@Resource
|
||||
private CourseHRBPAuditDao courseHRBPAuditDao;
|
||||
|
||||
@Resource
|
||||
private StudyCourseDao scdao;
|
||||
|
||||
|
||||
@Resource
|
||||
private SysLogAuditDao logAuditDao;//审核日志记录
|
||||
@@ -1093,6 +1096,15 @@ public class CourseServiceImpl implements ICourseService {
|
||||
courseCrowdDao.saveOrUpdate(cc);
|
||||
}
|
||||
}
|
||||
if (c != null) {
|
||||
List<StudyCourse> studyCourses = scdao.findListById(c.getId());
|
||||
if (studyCourses != null && !studyCourses.isEmpty()) {
|
||||
for (StudyCourse sc : studyCourses) {
|
||||
scdao.finishCheck(sc.getId(), c.getId(), 0, aid);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//同步发布
|
||||
publishUtil.fullTextPublish(c);
|
||||
//发布事件处理
|
||||
|
||||
@@ -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");
|
||||
|
||||
@@ -312,14 +312,19 @@ public class ExamQuestionApi extends ApiBaseController {
|
||||
if(row1.getCell(1).getStringCellValue().equals("多选题")){
|
||||
examQuestion.setType(2);
|
||||
}
|
||||
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("")){
|
||||
log.debug("row1.getCell(2) = " + row1.getCell(2));
|
||||
if (row1.getCell(2)==null ||row1.getCell(2).getStringCellValue() == null || row1.getCell(2).getStringCellValue().equals("")){
|
||||
examQuestion.setDifficulty(null);
|
||||
}else{
|
||||
if( row1.getCell(2).getStringCellValue().equals("中")){
|
||||
examQuestion.setDifficulty(2f);
|
||||
}else if(row1.getCell(2).getStringCellValue().equals("难")){
|
||||
examQuestion.setDifficulty(3f);
|
||||
} else if(row1.getCell(2).getStringCellValue().equals("易")){
|
||||
examQuestion.setDifficulty(1f);
|
||||
}else if(row1.getCell(2).getStringCellValue().equals("")){
|
||||
examQuestion.setDifficulty(null);
|
||||
}
|
||||
}
|
||||
Cell cell = row1.getCell(3);
|
||||
cell.setCellType(CellType.STRING);
|
||||
|
||||
@@ -377,7 +377,7 @@ public class StudyCourseApi extends ApiBaseController{
|
||||
//更新时长
|
||||
/**追加学习时长*/
|
||||
@PostMapping("/study-append-duration")
|
||||
public JsonResponse<Boolean> appendStudyDuration(String studyId,String studyItemId,String contentId,Integer duration){
|
||||
public JsonResponse<Boolean> appendStudyDuration(String studyId,String studyItemId,String contentId,Integer duration,String courseId,HttpServletRequest request){
|
||||
if(StringUtils.isBlank(studyId)){
|
||||
return error("参数错误");
|
||||
}
|
||||
@@ -387,8 +387,12 @@ public class StudyCourseApi extends ApiBaseController{
|
||||
if(duration==null){
|
||||
return error("无学习时长");
|
||||
}
|
||||
String token = request.getHeader("Xboe-Access-Token");
|
||||
if (StringUtils.isEmpty(token)) {
|
||||
token = request.getHeader("token");
|
||||
}
|
||||
try {
|
||||
studyService.appendStudyDuration(studyId, studyItemId,contentId,duration);
|
||||
studyService.appendStudyDuration(studyId, studyItemId,contentId,duration,courseId,token);
|
||||
return success(true);
|
||||
}catch(Exception e) {
|
||||
log.error("追加学习时长错误",e);
|
||||
|
||||
@@ -4,6 +4,7 @@ import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
import com.xboe.api.ThirdApi;
|
||||
import com.xboe.school.study.entity.StudyExam;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Repository;
|
||||
@@ -116,4 +117,14 @@ 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));
|
||||
}
|
||||
|
||||
public List<StudyCourse> findListById(String courseId) {
|
||||
String hql1 = "FROM StudyCourse WHERE courseId = ?1";
|
||||
List<StudyCourse> listByHql = super.findListByHql(hql1, courseId);
|
||||
return listByHql;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -77,7 +77,8 @@ public interface IStudyService {
|
||||
* @param duration 学习时长
|
||||
*/
|
||||
void appendStudyDuration(String studyId,String studyItemId,String courseContentId, int duration);
|
||||
|
||||
void appendStudyDuration(String studyId,String studyItemId,String courseContentId, int duration,String courseId,String token);
|
||||
|
||||
/**
|
||||
* 根据学习id,得到章节的学习记录情况
|
||||
* @param studyId
|
||||
|
||||
@@ -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);
|
||||
//删除学习课程的评估测试结果
|
||||
|
||||
@@ -110,7 +110,7 @@ public class StudyServiceImpl implements IStudyService{
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public void appendStudyDuration(String studyId,String studyItemId,String courseContentId, int duration) {
|
||||
public void appendStudyDuration(String studyId,String studyItemId,String courseContentId, int duration,String courseId,String token) {
|
||||
|
||||
//增加内容的学习时长
|
||||
if(StringUtils.isNotBlank(studyItemId)) {
|
||||
@@ -140,7 +140,43 @@ public class StudyServiceImpl implements IStudyService{
|
||||
|
||||
String sql="Update boe_study_course set total_duration=total_duration+"+duration+",status=(case when status<2 then 2 else status end),progress=(case when progress=0 then 1 else progress end),last_time = '"+LocalDateTime.now()+"' where id=?1";
|
||||
scDao.sqlUpdate(sql,studyId);
|
||||
|
||||
Integer total = 0;
|
||||
scDao.finishCheck(studyId,courseId,total,token);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public void appendStudyDuration(String studyId,String studyItemId,String courseContentId, int duration) {
|
||||
|
||||
//增加内容的学习时长
|
||||
if(StringUtils.isNotBlank(studyItemId)) {
|
||||
//直接根据id更新
|
||||
// String hql="Update StudyCourseItem set studyDuration=studyDuration+"+duration+",status=(case when status<2 then 2 else status end) where id=?1";
|
||||
// scItemDao.update(hql,studyItemId);
|
||||
String sql="Update boe_study_course_item set study_duration=study_duration+"+duration+",status=(case when status<2 then 2 else status end) where id=?1";
|
||||
scItemDao.sqlUpdate(sql,studyItemId);
|
||||
//scItemDao.updateMultiFieldById(studyItemId, UpdateBuilder.create("studyDuration", "studyDuration+"+duration,FieldUpdateType.EXPRESSION));
|
||||
|
||||
}else {
|
||||
//根据学习id和课程内容id更新
|
||||
// scItemDao.update(UpdateBuilder.from(StudyCourseItem.class)
|
||||
// .addUpdateField("studyDuration", "studyDuration+"+duration,FieldUpdateType.EXPRESSION)
|
||||
// .addFilter(FieldFilters.eq("studyId", studyId))
|
||||
// .addFilter(FieldFilters.eq("contentId", courseContentId))
|
||||
// .builder());
|
||||
//
|
||||
// String hql="Update StudyCourseItem set studyDuration=studyDuration+"+duration+",status=(case when status<2 then 2 else status end) where studyId=?1 and contentId=?2";
|
||||
// scItemDao.update(hql,studyId,courseContentId);
|
||||
String sql="Update boe_study_course_item set study_duration=study_duration+"+duration+",status=(case when status<2 then 2 else status end) where study_id=?1 and content_id=?2";
|
||||
scItemDao.sqlUpdate(sql,studyId,courseContentId);
|
||||
}
|
||||
|
||||
//追加课程的学习时长
|
||||
//scDao.updateMultiFieldById(studyId, UpdateBuilder.create("totalDuration", "totalDuration+"+duration,FieldUpdateType.EXPRESSION));
|
||||
|
||||
String sql="Update boe_study_course set total_duration=total_duration+"+duration+",status=(case when status<2 then 2 else status end),progress=(case when progress=0 then 1 else progress end),last_time = '"+LocalDateTime.now()+"' where id=?1";
|
||||
scDao.sqlUpdate(sql,studyId);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user