Преглед на файлове

Merge branch 'dev' of http://192.168.1.245:11111/jinjilong/onlineEducation-fwd into dev

honorfire преди 6 месеца
родител
ревизия
56270aa4a2

+ 1 - 1
snowy-plugin/snowy-plugin-exam/snowy-plugin-exam-func/src/main/java/vip/xiaonuo/exam/domain/exam/TExamAddParam.java

@@ -62,7 +62,7 @@ public class TExamAddParam {
     @ApiModelProperty(value = "试卷ID", position = 11)
     private String paperId;
 
-    /** 考试类型 1 考试 2 章节测验 3 调查问卷  */
+    /** 考试类型 1 考试 2 章节测验 3 调查问卷  4作业 */
     @ApiModelProperty(value = "考试类型", position = 12)
     private String examType;
 

+ 19 - 0
snowy-plugin/snowy-plugin-exam/snowy-plugin-exam-func/src/main/java/vip/xiaonuo/exam/job/task/ExamJobTimerTaskRunner.java

@@ -5,9 +5,14 @@ import lombok.extern.slf4j.Slf4j;
 import org.springframework.stereotype.Component;
 import vip.xiaonuo.common.timer.CommonTimerTaskRunner;
 import vip.xiaonuo.dev.api.DevJobApi;
+import vip.xiaonuo.dev.modular.message.param.DevMessageSendParam;
+import vip.xiaonuo.dev.modular.message.service.DevMessageService;
 import vip.xiaonuo.exam.domain.TExam;
 import vip.xiaonuo.exam.mapper.TExamMapper;
+
 import javax.annotation.Resource;
+import java.util.Arrays;
+import java.util.List;
 
 /**
  * @PackageName:vip.xiaonuo.exam.job.task
@@ -26,6 +31,12 @@ public class ExamJobTimerTaskRunner implements CommonTimerTaskRunner {
     @Resource
     private TExamMapper texamMapper;
 
+
+    @Resource
+    private DevMessageService devMessageService;
+
+
+
     /**
      * 任务执行的具体内容
      *
@@ -47,6 +58,14 @@ public class ExamJobTimerTaskRunner implements CommonTimerTaskRunner {
                     if(category.contains("start")){
                         taskExam.setExamStatus(1);
                         texamMapper.updateById(taskExam);
+
+                        //给相关的学生发送站内信消息
+                        List<String> studentAccounts = Arrays.asList(taskExam.getStudentIds().split(","));
+                        DevMessageSendParam devMessageSendParam=new DevMessageSendParam();
+                        devMessageSendParam.setReceiverIdList(studentAccounts);
+                        devMessageSendParam.setSubject(taskExam.getExamName());
+                        devMessageSendParam.setContent(taskExam.getExamName()+"已开始!!!");
+                        devMessageService.send(devMessageSendParam);
                     }
                     if(category.contains("end")){
                         taskExam.setExamStatus(2);

+ 25 - 23
snowy-plugin/snowy-plugin-exam/snowy-plugin-exam-func/src/main/java/vip/xiaonuo/exam/service/impl/TExamServiceImpl.java

@@ -29,6 +29,8 @@ import vip.xiaonuo.common.exception.CommonException;
 import vip.xiaonuo.common.page.CommonPageRequest;
 import vip.xiaonuo.common.pojo.CommonResult;
 import vip.xiaonuo.dev.api.DevJobApi;
+import vip.xiaonuo.dev.modular.message.param.DevMessageSendParam;
+import vip.xiaonuo.dev.modular.message.service.DevMessageService;
 import vip.xiaonuo.disk.api.NetDiskApi;
 import vip.xiaonuo.disk.mapper.CourseOpenMapper;
 import vip.xiaonuo.exam.domain.ExamPaper;
@@ -83,7 +85,8 @@ public class TExamServiceImpl extends ServiceImpl<TExamMapper, TExam> implements
     @Resource
     private CourseOpenMapper courseOpenMapper;
 
-
+    @Resource
+    private DevMessageService devMessageService;
 
 
     @Override
@@ -112,17 +115,11 @@ public class TExamServiceImpl extends ServiceImpl<TExamMapper, TExam> implements
     @Transactional(rollbackFor = Exception.class)
     @Override
     public CommonResult<String> add(TExamAddParam tExamAddParam) {
-        ExamPaper examPaper = examPaperService.selectById(Integer.parseInt(tExamAddParam.getPaperId()));
-
         ExamPaper newExamPaper=new ExamPaper();
         newExamPaper.setId(Integer.valueOf(tExamAddParam.getPaperId()));
         newExamPaper.setIsSelect(1);
         examPaperMapper.updateByPrimaryKeySelective(newExamPaper);
 
-//        if(ExamPaperTypeEnum.TimeLimit.getCode() == examPaper.getPaperType()){
-//            tExamAddParam.setStartTime(examPaper.getLimitStartTime());
-//            tExamAddParam.setEndTime(examPaper.getLimitEndTime());
-//        }
         TExam tExam = BeanUtil.toBean(tExamAddParam, TExam.class);
 
         boolean query = false;
@@ -131,8 +128,9 @@ public class TExamServiceImpl extends ServiceImpl<TExamMapper, TExam> implements
             map.put("courseId",tExamAddParam.getCourseId());
             query = true;
         }
+        List<String> studentAccounts=new ArrayList<>();
         if(query){
-            List<String>  studentAccounts=courseOpenMapper.selectAccount(tExamAddParam.getSemesterId(),tExamAddParam.getCourseId());
+            studentAccounts=courseOpenMapper.selectAccount(tExamAddParam.getSemesterId(),tExamAddParam.getCourseId());
             if(CollectionUtil.isNotEmpty(studentAccounts)){
                 String studentIdsStr = String.join(",", studentAccounts);
                 tExam.setStudentIds(studentIdsStr);
@@ -153,6 +151,14 @@ public class TExamServiceImpl extends ServiceImpl<TExamMapper, TExam> implements
             this.addJob(tExam, "start");
             this.addJob(tExam, "end");
         }
+        //给课程下关联的学生发送站内信消息
+        if(CollectionUtil.isNotEmpty(studentAccounts)&&"1".equals(tExamAddParam.getExamStatus())){
+            DevMessageSendParam devMessageSendParam=new DevMessageSendParam();
+            devMessageSendParam.setReceiverIdList(studentAccounts);
+            devMessageSendParam.setSubject(tExamAddParam.getExamName());
+            devMessageSendParam.setContent(tExamAddParam.getExamName()+"已开始!!!");
+            devMessageService.send(devMessageSendParam);
+        }
        return CommonResult.ok();
     }
 
@@ -192,9 +198,9 @@ public class TExamServiceImpl extends ServiceImpl<TExamMapper, TExam> implements
             query = true;
         }
 
-
+        List<String>  studentAccounts=new ArrayList<>();
         if(query){
-            List<String>  studentAccounts=courseOpenMapper.selectAccount(tExamEditParam.getSemesterId(),tExamEditParam.getCourseId());
+            studentAccounts=courseOpenMapper.selectAccount(tExamEditParam.getSemesterId(),tExamEditParam.getCourseId());
             if(CollectionUtil.isNotEmpty(studentAccounts)){
                 String studentIdsStr = String.join(",", studentAccounts);
                 tExamEditParam.setStudentIds(studentIdsStr);
@@ -203,19 +209,6 @@ public class TExamServiceImpl extends ServiceImpl<TExamMapper, TExam> implements
             }
         }
 
-
-
-//        if(tExamEditParam.getPaperId() != null && !tExamEditParam.getPaperId().isEmpty()){
-//            ExamPaper examPaper = examPaperService.selectById(Integer.parseInt(tExamEditParam.getPaperId()));
-//            if(ExamPaperTypeEnum.TimeLimit.getCode() == examPaper.getPaperType()){
-//                tExamEditParam.setStartTime(examPaper.getLimitStartTime());
-//                tExamEditParam.setEndTime(examPaper.getLimitEndTime());
-//                updateJob = true;
-//            }
-//            if(ExamPaperTypeEnum.Survey.getCode() == examPaper.getPaperType()){
-//                tExam.setExamType("3"); // 3 调查问卷
-//            }
-//        }
         tExam.setExamType(tExamEditParam.getExamType());
 
 
@@ -242,6 +235,15 @@ public class TExamServiceImpl extends ServiceImpl<TExamMapper, TExam> implements
 
         BeanUtil.copyProperties(tExamEditParam, tExam);
         this.updateById(tExam);
+
+        //给课程下关联的学生发送站内信消息
+        if(CollectionUtil.isNotEmpty(studentAccounts)&&"1".equals(tExamEditParam.getExamStatus())){
+            DevMessageSendParam devMessageSendParam=new DevMessageSendParam();
+            devMessageSendParam.setReceiverIdList(studentAccounts);
+            devMessageSendParam.setSubject(tExamEditParam.getExamName());
+            devMessageSendParam.setContent(tExamEditParam.getExamName()+"已开始!!!");
+            devMessageService.send(devMessageSendParam);
+        }
         return CommonResult.ok();
     }