14个文件已修改
90 ■■■■■ 已修改文件
src/main/java/com/ycl/jxkg/JxkgApplication.java 5 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ycl/jxkg/config/CaffeineConfig.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ycl/jxkg/domain/query/WebSocketQuery.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ycl/jxkg/domain/vo/admin/exam/ExamPaperPageRequestVO.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ycl/jxkg/enums/WebsocketCommendEnum.java 6 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ycl/jxkg/job/StudyRecordJob.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ycl/jxkg/server/WebsocketServer.java 15 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ycl/jxkg/service/impl/EducationResourceServiceImpl.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ycl/jxkg/service/impl/ExamPaperServiceImpl.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ycl/jxkg/service/impl/ExamServiceImpl.java 40 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/application-prod.yml 6 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/application.yml 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/mapper/ExamMapper.xml 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/mapper/ExamPaperMapper.xml 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ycl/jxkg/JxkgApplication.java
@@ -1,9 +1,11 @@
package com.ycl.jxkg;
import com.ycl.jxkg.config.property.SystemConfig;
import com.ycl.jxkg.server.WebsocketServer;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.transaction.annotation.EnableTransactionManagement;
@@ -25,6 +27,7 @@
     * @param args the input arguments
     */
    public static void main(String[] args) {
        SpringApplication.run(JxkgApplication.class, args);
        ConfigurableApplicationContext context = SpringApplication.run(JxkgApplication.class, args);
        WebsocketServer.setApplicationContext(context);
    }
}
src/main/java/com/ycl/jxkg/config/CaffeineConfig.java
@@ -2,12 +2,14 @@
import com.github.benmanes.caffeine.cache.Cache;
import com.github.benmanes.caffeine.cache.Caffeine;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import java.util.concurrent.TimeUnit;
@Configuration
@EnableCaching
public class CaffeineConfig {
    @Bean
src/main/java/com/ycl/jxkg/domain/query/WebSocketQuery.java
@@ -4,6 +4,6 @@
@Data
public class WebSocketQuery {
    private String commend;
    private String command;
    private Integer id;
}
src/main/java/com/ycl/jxkg/domain/vo/admin/exam/ExamPaperPageRequestVO.java
@@ -19,4 +19,6 @@
    private BigDecimal score;
    private Integer createUser;
}
src/main/java/com/ycl/jxkg/enums/WebsocketCommendEnum.java
@@ -17,12 +17,12 @@
    RECORD_STUDY_TIME("recordStudyTime", "记录学习时间"),
    ;
    private final String commend;
    private final String command;
    private final String desc;
    WebsocketCommendEnum(String commend, String desc) {
        this.commend = commend;
    WebsocketCommendEnum(String command, String desc) {
        this.command = command;
        this.desc = desc;
    }
}
src/main/java/com/ycl/jxkg/job/StudyRecordJob.java
@@ -32,7 +32,7 @@
    private final StudyRecordMapper studyRecordMapper;
    private final StudyRecordService studyRecordService;
    @Scheduled(fixedRate = 120000) // 2分钟执行一次
    @Scheduled(fixedRate = 1200000) // 2分钟执行一次
    private void updateStudyRecord() {
        log.info("开始存学习时长");
        List<StudyRecord> cacheList = new ArrayList<>();
src/main/java/com/ycl/jxkg/server/WebsocketServer.java
@@ -8,6 +8,7 @@
import com.ycl.jxkg.service.EducationResourceService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Component;
import javax.servlet.http.HttpSession;
@@ -32,8 +33,12 @@
@ServerEndpoint("/websocket/{userId}")
public class WebsocketServer {
    @Autowired
    private EducationResourceService educationResourceService;
    private static ApplicationContext applicationContext;
    public static void setApplicationContext(ApplicationContext context) {
        applicationContext = context;
    }
    /**
     * 线程安全的无序的集合
     */
@@ -68,9 +73,11 @@
    @OnMessage
    public void onMessage(String message) {
        WebSocketQuery webSocketQuery = JSONObject.parseObject(message, WebSocketQuery.class);
        String commend = webSocketQuery.getCommend();
        String command = webSocketQuery.getCommand();
        Integer userId = webSocketQuery.getId();
        if(WebsocketCommendEnum.RECORD_STUDY_TIME.getCommend().equals(commend)){
        if(WebsocketCommendEnum.RECORD_STUDY_TIME.getCommand().equals(command)){
            log.info("存消息");
            EducationResourceService educationResourceService = applicationContext.getBean(EducationResourceService.class);
            educationResourceService.recordTime(userId);
        }
        log.info("【WebSocket消息】收到客户端消息:" + message);
src/main/java/com/ycl/jxkg/service/impl/EducationResourceServiceImpl.java
@@ -15,6 +15,7 @@
import com.ycl.jxkg.mapper.SubjectMapper;
import com.ycl.jxkg.service.EducationResourceService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@@ -31,6 +32,7 @@
 */
@Service
@RequiredArgsConstructor
@Slf4j
public class EducationResourceServiceImpl implements EducationResourceService {
    private final EducationResourceMapper mapper;
src/main/java/com/ycl/jxkg/service/impl/ExamPaperServiceImpl.java
@@ -185,7 +185,7 @@
    @Override
    public PageInfo<ExamResponseVO> page(ExamPaperPageRequestVO requestVM) {
        //TODO: 数据权限
        requestVM.setCreateUser(webContext.getCurrentUser().getId());
        PageInfo<ExamPaper> page = PageHelper.startPage(requestVM.getPageIndex(), requestVM.getPageSize(), "id desc").doSelectPageInfo(() ->
                examPaperMapper.page(requestVM));
        PageInfo<ExamResponseVO> pageVO = PageInfoHelper.copyMap(page, e -> {
src/main/java/com/ycl/jxkg/service/impl/ExamServiceImpl.java
@@ -373,6 +373,24 @@
                doQuestionVO.setQuestionType(item.getQuestionType());
                //增加题目分数
                doQuestionVO.setQuestionScore(question.getScore());
                // 题目副本
                QuestionAnswerCopyVO copy = new QuestionAnswerCopyVO();
                copy.setId(question.getId());
                copy.setAnalyze(question.getAnalyze());
                copy.setDifficult(question.getDifficult());
                //填空的答案在Json里
                if (QuestionTypeEnum.GapFilling.getCode().equals(item.getQuestionType())) {
                    List<String> gapAnswer = new ArrayList<>();
                    for (QuestionItemObject questionItemObject : question.getItems()) {
                        gapAnswer.add(questionItemObject.getContent());
                    }
                    copy.setCorrect(String.join(ANSWER_SPLIT, gapAnswer));
                } else {
                    copy.setCorrect(question.getCorrect());
                }
                questionAnswerCopyVOList.add(copy);
                // 填空题需要抹除content(因为是答案)
                if (QuestionTypeEnum.GapFilling.getCode().equals(doQuestionVO.getQuestionType())) {
                    question.getItems().stream().forEach(option -> {
@@ -383,24 +401,6 @@
                doQuestionVO.setId(question.getId());
                doQuestionVO.setOriginalFile(question.getOriginalFile());
                doQuestionVO.setAudioFile(question.getAudioFile());
                // 题目副本
                QuestionAnswerCopyVO copy = new QuestionAnswerCopyVO();
                copy.setId(question.getId());
                copy.setAnalyze(question.getAnalyze());
                copy.setDifficult(question.getDifficult());
                //填空的答案在Json里
                if (QuestionTypeEnum.GapFilling.getCode().equals(item.getQuestionType())) {
                    List<String> gapAnswer = new ArrayList<>();
                    for (QuestionItemObject questionItemObject : doQuestionVO.getQuestionItemList()) {
                        gapAnswer.add(questionItemObject.getContent());
                    }
                    copy.setCorrect(String.join(ANSWER_SPLIT, gapAnswer));
                } else {
                    copy.setCorrect(question.getCorrect());
                }
                questionAnswerCopyVOList.add(copy);
                return doQuestionVO;
            }).collect(Collectors.toList());
            if (ExamPaperTypeEnum.RandomOrder.getCode().equals(examPaper.getPaperType())) {
@@ -885,7 +885,7 @@
            throw new RuntimeException("该学员不在线,无法执行该操作");
        }
        WebsocketDataVO websocket = new WebsocketDataVO();
        websocket.setCommend(WebsocketCommendEnum.DELAYED.getCommend());
        websocket.setCommend(WebsocketCommendEnum.DELAYED.getCommand());
        BigDecimal sed = BigDecimal.valueOf(60).multiply(form.getAddTimeM());
        form.setAddTimeM(sed);
        websocket.setData(form);
@@ -900,7 +900,7 @@
            throw new RuntimeException("该学员不在线,无法执行该操作");
        }
        WebsocketDataVO websocket = new WebsocketDataVO();
        websocket.setCommend(WebsocketCommendEnum.FORCE_SUBMIT.getCommend());
        websocket.setCommend(WebsocketCommendEnum.FORCE_SUBMIT.getCommand());
        websocket.setData(form);
        // 发送websocket消息
        websocketServer.sendOneMessage(form.getUserId(), JSON.toJSONString(form));
src/main/resources/application-prod.yml
@@ -3,13 +3,13 @@
upload:
  # 文件路径 示例( Windows配置D:/ruoyi/uploadPath,Linux配置 /home/ruoyi/uploadPath)
  url: /usr/local/file
  url: E:/ycl/file
spring:
  datasource:
    url: jdbc:mysql://localhost:3306/xzs?useSSL=true&useUnicode=true&serverTimezone=GMT%2B8&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&allowPublicKeyRetrieval=true&allowMultiQueries=true
    url: jdbc:mysql://42.193.1.25:3306/xzs?useSSL=true&useUnicode=true&serverTimezone=GMT%2B8&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&allowPublicKeyRetrieval=true&allowMultiQueries=true
    username: root
    password: 123456
    password: 321$YcYl@1970!
    driver-class-name: com.mysql.cj.jdbc.Driver
  rabbitmq:
    host: 101.35.247.188
src/main/resources/application.yml
@@ -80,4 +80,4 @@
  #runningtime environment
  profiles:
    active: dev
    active: prod
src/main/resources/mapper/ExamMapper.xml
@@ -98,7 +98,7 @@
        INNER JOIN t_exam_paper TEP ON TEP.id = TE.exam_paper_id AND TEP.deleted = 0
        LEFT JOIN t_exam_submit_temp TEST ON TEST.exam_id = TE.id
        WHERE
            TE.deleted = 0 and TEST.deleted !=1
            TE.deleted = 0 and (TEST.deleted =0 or TEST.deleted is null)
            <if test="query.examName != null and query.examName != ''">
                AND TE.exam_name like concat('%', #{query.examName}, '%')
            </if>
src/main/resources/mapper/ExamPaperMapper.xml
@@ -34,7 +34,7 @@
        tep.*
        FROM t_exam_paper tep
        <where>
            and tep.deleted=0
            and tep.deleted=0 and (create_user = #{createUser} or visibility = 'Public')
            <if test="id != null ">
                and tep.id= #{id}
            </if>