diff --git a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/getpoints/GetPointsController.java b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/getpoints/GetPointsController.java deleted file mode 100644 index 2a1b3624..00000000 --- a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/getpoints/GetPointsController.java +++ /dev/null @@ -1,33 +0,0 @@ -package pc.exam.pp.module.exam.controller.admin.getpoints; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; -import pc.exam.pp.framework.common.pojo.CommonResult; -import pc.exam.pp.module.exam.service.getpoints.ExamGetPointsService; - -import java.io.IOException; - -@RestController -@RequestMapping("/exam/getopints") -public class GetPointsController { - - @Autowired - private ExamGetPointsService examGetPointsService; - - /** - * 得出文件操作考点 - * @return 得分 - */ - @PostMapping("/get_filePoint") - //todo 后期需要素材文件和答案文件的 父目录 如:D:/exam/3/shucai,D:/exam/3/win - public CommonResult get_file_point() throws IOException { - return CommonResult.success(examGetPointsService.get_file_point()); - } - @PostMapping("/get_mysql_point") - //todo 后期需要素材文件和答案文件的 父目录 如:D:/exam/3/shucai,D:/exam/3/win - public CommonResult get_mysql_point() throws IOException { - return CommonResult.success(examGetPointsService.get_mysql_point()); - } -} diff --git a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/paper/vo/PaperTaskPageVo.java b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/paper/vo/PaperTaskPageVo.java index 6c4cd0a1..144978cc 100644 --- a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/paper/vo/PaperTaskPageVo.java +++ b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/paper/vo/PaperTaskPageVo.java @@ -1,5 +1,6 @@ package pc.exam.pp.module.exam.controller.admin.paper.vo; +import com.baomidou.mybatisplus.annotation.TableField; import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; import lombok.EqualsAndHashCode; diff --git a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/specialty/ExamSpecialtyController.java b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/specialty/ExamSpecialtyController.java index 59984cde..ee3fc1fb 100644 --- a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/specialty/ExamSpecialtyController.java +++ b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/specialty/ExamSpecialtyController.java @@ -6,6 +6,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; import pc.exam.pp.framework.common.pojo.CommonResult; import pc.exam.pp.framework.common.util.object.BeanUtils; +import pc.exam.pp.module.exam.controller.admin.specialty.vo.SpecialRolesVo; import pc.exam.pp.module.exam.controller.admin.specialty.vo.SpecialtListReqVo; import pc.exam.pp.module.exam.controller.admin.specialty.vo.SpecialtyQueryVo; import pc.exam.pp.module.exam.dal.dataobject.knowledge.ExamKnowledgePoints; @@ -154,4 +155,19 @@ public class ExamSpecialtyController{ } return success(examSpecialtyService.deleteExamSpecialtyBySpIds(spIds)); } + @PostMapping("/setRole") + public CommonResult setRole(@RequestBody SpecialRolesVo specialRolesVo) { + System.out.println(specialRolesVo); + ExamSpecialty examSpecialty = examSpecialtyService.selectExamSpecialtyBySpId(Long.valueOf(specialRolesVo.getId())); + examSpecialty.setRoles(specialRolesVo.getRoles()); + examSpecialtyService.updateExamSpecialty(examSpecialty); + return success("设置成功"); + } + @GetMapping(value = "/getRole/{id}") + public CommonResult getRole(@PathVariable("id") String id) { + String roles= examSpecialtyService.getRoleById(id); + + return success(Integer.parseInt(roles)); + } + } diff --git a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/specialty/vo/SpecialRolesVo.java b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/specialty/vo/SpecialRolesVo.java new file mode 100644 index 00000000..47bf3295 --- /dev/null +++ b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/specialty/vo/SpecialRolesVo.java @@ -0,0 +1,13 @@ +package pc.exam.pp.module.exam.controller.admin.specialty.vo; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@AllArgsConstructor +@NoArgsConstructor +public class SpecialRolesVo { + private String id; + private String roles; +} diff --git a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/specialty/vo/SpecialtyQueryVo.java b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/specialty/vo/SpecialtyQueryVo.java index 3746a950..6911bc0d 100644 --- a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/specialty/vo/SpecialtyQueryVo.java +++ b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/specialty/vo/SpecialtyQueryVo.java @@ -22,4 +22,6 @@ public class SpecialtyQueryVo { private Integer orderNum; private LocalDateTime createTime; + + private String roles; } diff --git a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/dal/dataobject/EducationPaperTask.java b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/dal/dataobject/EducationPaperTask.java index 6cf3a6a5..3668b19f 100644 --- a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/dal/dataobject/EducationPaperTask.java +++ b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/dal/dataobject/EducationPaperTask.java @@ -59,4 +59,6 @@ public class EducationPaperTask extends TenantBaseDO @TableField(exist = false) EducationPaperParam educationPaperParam; + @TableField(exist = false) + private String score; } diff --git a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/dal/dataobject/ExamQuestionAnswer.java b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/dal/dataobject/ExamQuestionAnswer.java index ac7c5e88..2413a0d3 100644 --- a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/dal/dataobject/ExamQuestionAnswer.java +++ b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/dal/dataobject/ExamQuestionAnswer.java @@ -1,9 +1,11 @@ package pc.exam.pp.module.exam.dal.dataobject; +import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; import com.fasterxml.jackson.annotation.JsonInclude; import io.swagger.v3.oas.annotations.info.Contact; +import jdk.dynalink.linker.LinkerServices; import lombok.AllArgsConstructor; import lombok.Data; import lombok.EqualsAndHashCode; @@ -13,6 +15,8 @@ import org.apache.commons.lang3.builder.ToStringBuilder; import org.apache.commons.lang3.builder.ToStringStyle; import pc.exam.pp.framework.mybatis.core.dataobject.BaseDO; +import java.util.List; + /** * 试题答案选项(hyc)对象 exam_question_answer * @@ -61,6 +65,18 @@ public class ExamQuestionAnswer // @Excel(name = "排序") private String sort; + @TableField(exist = false) + @JsonInclude(value = JsonInclude.Include.NON_EMPTY) + private List examMysqlKeywordList; - + public ExamQuestionAnswer(String answerId, String quId, String isRight, String image, String content, String contentIn, String scoreRate, String sort) { + this.answerId = answerId; + this.quId = quId; + this.isRight = isRight; + this.image = image; + this.content = content; + this.contentIn = contentIn; + this.scoreRate = scoreRate; + this.sort = sort; + } } diff --git a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/dal/dataobject/specialty/ExamSpecialty.java b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/dal/dataobject/specialty/ExamSpecialty.java index a18ec255..0ba55cfb 100644 --- a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/dal/dataobject/specialty/ExamSpecialty.java +++ b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/dal/dataobject/specialty/ExamSpecialty.java @@ -34,4 +34,7 @@ public class ExamSpecialty extends TenantBaseDO { /** 子树数量 */ private Long treeNum; + + /** 判分规则*/ + private String roles; } diff --git a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/dal/mysql/monitor/MonitorMapper.java b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/dal/mysql/monitor/MonitorMapper.java index 2dde6519..7043e6a8 100644 --- a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/dal/mysql/monitor/MonitorMapper.java +++ b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/dal/mysql/monitor/MonitorMapper.java @@ -1,6 +1,7 @@ package pc.exam.pp.module.exam.dal.mysql.monitor; +import org.apache.ibatis.annotations.Param; import pc.exam.pp.framework.common.pojo.PageResult; import pc.exam.pp.framework.mybatis.core.query.LambdaQueryWrapperX; import pc.exam.pp.framework.mybatis.core.mapper.BaseMapperX; @@ -49,4 +50,8 @@ return selectPage(reqVO, new LambdaQueryWrapperX() } + String selectByStuIdAndTaskIdTop(@Param("stuId")Long stuId, @Param("taskId") String taskId); + + String selectByStuIdAndTaskIdNew(Long stuId, String taskId); + } \ No newline at end of file diff --git a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/dal/mysql/mysqlkeyword/MysqlKeywordMapper.java b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/dal/mysql/mysqlkeyword/MysqlKeywordMapper.java new file mode 100644 index 00000000..c2924665 --- /dev/null +++ b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/dal/mysql/mysqlkeyword/MysqlKeywordMapper.java @@ -0,0 +1,20 @@ +package pc.exam.pp.module.exam.dal.mysql.mysqlkeyword; + +import pc.exam.pp.framework.mybatis.core.mapper.BaseMapperX; +import pc.exam.pp.module.exam.dal.dataobject.ExamMysqlKeyword; +import org.apache.ibatis.annotations.Mapper; + +import java.util.List; + +/** + * MYSQL判分关键字考点 Mapper + * + * @author 管理员 + */ +@Mapper +public interface MysqlKeywordMapper extends BaseMapperX { + + + void deleteByAnswerId(String answerId); + +} \ No newline at end of file diff --git a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/dal/mysql/question/ExamQuestionAnswerMapper.java b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/dal/mysql/question/ExamQuestionAnswerMapper.java index 10005443..09b1d4ed 100644 --- a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/dal/mysql/question/ExamQuestionAnswerMapper.java +++ b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/dal/mysql/question/ExamQuestionAnswerMapper.java @@ -71,4 +71,8 @@ public interface ExamQuestionAnswerMapper extends BaseMapperX selectExamQuestionAnswerIdByQuId(String quId); + + } diff --git a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/dal/mysql/question/ExamQuestionMapper.java b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/dal/mysql/question/ExamQuestionMapper.java index 975120b1..ddd6926a 100644 --- a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/dal/mysql/question/ExamQuestionMapper.java +++ b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/dal/mysql/question/ExamQuestionMapper.java @@ -122,4 +122,8 @@ public interface ExamQuestionMapper extends BaseMapperX int selectExamQuestionCountByQuId(String quId); List getSchoolNameNaPage(); + + long selectTenantId(); + + } diff --git a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/dal/mysql/specialty/ExamSpecialtyMapper.java b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/dal/mysql/specialty/ExamSpecialtyMapper.java index ba9b1284..dc7cb6e7 100644 --- a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/dal/mysql/specialty/ExamSpecialtyMapper.java +++ b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/dal/mysql/specialty/ExamSpecialtyMapper.java @@ -96,4 +96,6 @@ public interface ExamSpecialtyMapper extends BaseMapperX public int deleteExamSpecialtyBySpIds(Long[] spIds); + String getRoleById(String id); + } diff --git a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/job/QuestionDownJob.java b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/job/QuestionDownJob.java index b23585c7..df0484e5 100644 --- a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/job/QuestionDownJob.java +++ b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/job/QuestionDownJob.java @@ -2,9 +2,12 @@ package pc.exam.pp.module.exam.job; import jakarta.annotation.Resource; import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.stereotype.Component; import pc.exam.pp.framework.quartz.core.handler.JobHandler; import pc.exam.pp.framework.security.core.util.SecurityFrameworkUtils; +import pc.exam.pp.framework.tenant.core.aop.TenantIgnore; import pc.exam.pp.module.exam.dal.mysql.question.ExamQuestionMapper; import pc.exam.pp.module.exam.service.question.IExamQuestionService; import pc.exam.pp.module.exam.utils.rabbitmq.RabbitmqUtils; @@ -21,44 +24,55 @@ public class QuestionDownJob implements JobHandler { private ExamQuestionMapper examQuestionMapper; @Resource private IExamQuestionService examQuestionService; + @Value("${server.role}") + private String serverRole; + @Override public String execute(String param) throws Exception { + if ("center".equals(serverRole)){ + List queueNames= examQuestionMapper.seleAllQueueName(); + log.info(queueNames.toString()+"所有学校队列名"); + if (queueNames!=null){ + List failedQueues = new ArrayList<>(); + List successQueues = new ArrayList<>(); + List failedQueues1 = new ArrayList<>(); + List successQueues2 = new ArrayList<>(); + for (String queueName : queueNames) { + boolean examQuestionToRabbitMQ = rabbitMqService.connectSchool(queueName); + if (!examQuestionToRabbitMQ) { + failedQueues.add(queueName); + }else { + successQueues.add(queueName); + } + } + for (String queueName : successQueues) { + try { + boolean examQuestionToRabbitMQ = examQuestionService.getExamQuestionToRabbitMQ(queueName); + if (!examQuestionToRabbitMQ) { + failedQueues1.add(queueName); + } else { + successQueues2.add(queueName); + } + } catch (Exception e) { + log.error("拉取队列 {} 时异常:{}", queueName, e.getMessage()); + failedQueues1.add(queueName); + } + } + log.info(failedQueues.toString()+"连接失败的学校"); + log.info(successQueues.toString()+"连接成功的学校"); + log.info(failedQueues1.toString()+"拉取失败的学校"); + log.info(successQueues2.toString()+"拉取成功的学校"); + rabbitMqService.disconnect(); + } + }else { + System.out.println("不走定时任务测试=========================="); + + } + + + - List queueNames= examQuestionMapper.seleAllQueueName(); - log.info(queueNames.toString()+"所有学校队列名"); - if (queueNames!=null){ - List failedQueues = new ArrayList<>(); - List successQueues = new ArrayList<>(); - List failedQueues1 = new ArrayList<>(); - List successQueues2 = new ArrayList<>(); - for (String queueName : queueNames) { - boolean examQuestionToRabbitMQ = rabbitMqService.connectSchool(queueName); - if (!examQuestionToRabbitMQ) { - failedQueues.add(queueName); - }else { - successQueues.add(queueName); - } - } - for (String queueName : successQueues) { - try { - boolean examQuestionToRabbitMQ = examQuestionService.getExamQuestionToRabbitMQ(queueName); - if (!examQuestionToRabbitMQ) { - failedQueues1.add(queueName); - } else { - successQueues2.add(queueName); - } - } catch (Exception e) { - log.error("拉取队列 {} 时异常:{}", queueName, e.getMessage()); - failedQueues1.add(queueName); - } - } - log.info(failedQueues.toString()+"连接失败的学校"); - log.info(successQueues.toString()+"连接成功的学校"); - log.info(failedQueues1.toString()+"拉取失败的学校"); - log.info(successQueues2.toString()+"拉取成功的学校"); - rabbitMqService.disconnect(); - } return null; } diff --git a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/getpoints/ExamGetPointsService.java b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/getpoints/ExamGetPointsService.java deleted file mode 100644 index 6a1f300c..00000000 --- a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/getpoints/ExamGetPointsService.java +++ /dev/null @@ -1,15 +0,0 @@ -package pc.exam.pp.module.exam.service.getpoints; - -import pc.exam.pp.module.exam.dal.dataobject.ExamQuestionAnswer; - -import java.io.IOException; -import java.util.List; - -public interface ExamGetPointsService { - - - - List get_file_point() throws IOException; - - List get_mysql_point(); -} diff --git a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/getpoints/ExamGetPointsServiceImpl.java b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/getpoints/ExamGetPointsServiceImpl.java deleted file mode 100644 index 2465682a..00000000 --- a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/getpoints/ExamGetPointsServiceImpl.java +++ /dev/null @@ -1,62 +0,0 @@ -package pc.exam.pp.module.exam.service.getpoints; - -import org.springframework.stereotype.Service; -import pc.exam.pp.module.exam.dal.dataobject.ExamQuestionAnswer; -import pc.exam.pp.module.exam.utils.file.GetDifferencesBetweenFolders; - -import java.io.IOException; -import java.util.ArrayList; -import java.util.Comparator; -import java.util.List; -import java.util.Map; -import java.util.concurrent.atomic.AtomicInteger; -import java.util.stream.Collectors; - -@Service -public class ExamGetPointsServiceImpl implements ExamGetPointsService{ - - static final String BASE_DIR = "D:/exam/3/"; - @Override - public List get_file_point() throws IOException { - List answerList = new ArrayList<>(); - AtomicInteger sortCounter = new AtomicInteger(1); // 计数器 - String path1 = BASE_DIR + "shucai"; - String path2 = BASE_DIR + "win"; - - // 获取 shucai 和 win 文件夹的差异 - Map differences = GetDifferencesBetweenFolders.getDifferencesBetweenFolders(path1, path2); - - List formattedDifferences = differences.entrySet().stream() - .map(entry -> { - String key = entry.getKey(); - String value = entry.getValue(); - ExamQuestionAnswer answer = new ExamQuestionAnswer(); - answer.setContent(key); // 设置文件路径 - answer.setScoreRate("1"); - //这里设置answer的排序,按照循环次数来 - answer.setSort(String.valueOf(sortCounter.getAndIncrement())); // 按顺序设置排序值 - if (value.startsWith("仅存在于 "+path1)) { - answer.setContentIn("考察删除"); - } else if (value.startsWith("仅存在于 "+path2)) { - answer.setContentIn("考察名称"); - } else if (value.startsWith("属性不同")) { - answer.setContentIn("考察属性"); -// answer.setContent(key + " -> " + value.split(" vs ")[1]); // 设置属性信息 - } - return answer; - }) - .sorted(Comparator.comparingInt(answer -> Integer.parseInt(answer.getSort()))) // 按 sort 排序 - .collect(Collectors.toList()); - answerList.addAll(formattedDifferences); - - return answerList; - } - - @Override - public List get_mysql_point() { - - - - return null; - } -} diff --git a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/monitor/MonitorServiceImpl.java b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/monitor/MonitorServiceImpl.java index 08d20d93..3cbdecee 100644 --- a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/monitor/MonitorServiceImpl.java +++ b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/monitor/MonitorServiceImpl.java @@ -177,7 +177,7 @@ public class MonitorServiceImpl implements MonitorService { info.setRemainingTime(remainingSeconds > 0 ? remainingSeconds : 0); - //todo 考虑加点时间,或判分后删除 + //判分后删除 // stringRedisTemplate.opsForValue().set("userCache:"+stuMonitorPaperVo.getTaskId()+":"+stuMonitorPaperVo.getStuId(), JsonUtils.toJsonString(info), remainingSeconds, TimeUnit.SECONDS); stringRedisTemplate.opsForValue().set("userCache:"+stuMonitorPaperVo.getTaskId()+":"+stuMonitorPaperVo.getStuId(), JsonUtils.toJsonString(info)); diff --git a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/paper/EducationPaperPersonServiceImpl.java b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/paper/EducationPaperPersonServiceImpl.java index 16dffda0..70a5b39e 100644 --- a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/paper/EducationPaperPersonServiceImpl.java +++ b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/paper/EducationPaperPersonServiceImpl.java @@ -1,4 +1,5 @@ package pc.exam.pp.module.exam.service.paper; +import java.sql.Time; import java.time.Duration; import java.time.Instant; import java.time.LocalDateTime; @@ -19,12 +20,14 @@ import pc.exam.pp.module.exam.controller.admin.paper.vo.ExamPersonVo; import pc.exam.pp.module.exam.controller.admin.paper.vo.SessionStuPageReqVO; import pc.exam.pp.module.exam.controller.admin.paper.vo.StudentSessionReqVO; import pc.exam.pp.module.exam.controller.admin.student.vo.StudentPageReqVO; +import pc.exam.pp.module.exam.dal.dataobject.EducationPaperParam; import pc.exam.pp.module.exam.dal.dataobject.EducationPaperPerson; import pc.exam.pp.module.exam.dal.dataobject.EducationPaperSession; import pc.exam.pp.module.exam.dal.dataobject.EducationPaperTask; import pc.exam.pp.module.exam.dal.dataobject.monitor.MonitorDO; import pc.exam.pp.module.exam.dal.dataobject.student.StudentDO; import pc.exam.pp.module.exam.dal.mysql.monitor.MonitorMapper; +import pc.exam.pp.module.exam.dal.mysql.paper.EducationPaperParamMapper; import pc.exam.pp.module.exam.dal.mysql.paper.EducationPaperPersonMapper; import pc.exam.pp.module.exam.dal.mysql.paper.EducationPaperSessionMapper; import pc.exam.pp.module.exam.dal.mysql.paper.EducationPaperTaskMapper; @@ -57,6 +60,8 @@ public class EducationPaperPersonServiceImpl implements IEducationPaperPersonSer private EducationPaperSessionMapper educationPaperSessionMapper; @Resource private MonitorMapper monitorMapper; + @Resource + private EducationPaperParamMapper educationPaperParamMapper; @Autowired private RedisTemplate redisTemplate; /** @@ -200,10 +205,11 @@ public class EducationPaperPersonServiceImpl implements IEducationPaperPersonSer monitorMapper.updateById(info); - } else if (existing == null) { + } + if (existing == null) { EducationPaperTask educationPaperTask = educationPaperTaskMapper.selectEducationPaperTaskByTaskId(taskId); - String name= educationPaperTaskMapper.selectEducationPaperTaskNameByid(taskId); + EducationPaperParam educationPaperParam = educationPaperParamMapper.selectEducationPaperParamByTaskId(taskId); EducationPaperPerson educationPaperPerson=new EducationPaperPerson(); String key = "userCache:" + taskId+":"+studentId; @@ -215,6 +221,11 @@ public class EducationPaperPersonServiceImpl implements IEducationPaperPersonSer info.setStuId(studentId); info.setUsername(personRepDto.getUsername()); info.setNickname(personRepDto.getNickname()); + //判断是否开启测评时长限制 + if ("0".equals(educationPaperParam.getIsTime())){ + Time examTime = educationPaperParam.getExamTime(); + info.setRemainingTime((long) examTime.toLocalTime().toSecondOfDay()); + } //设置学生班级 if (StringUtils.isNotBlank(personRepDto.getClassId().toString())){ String className=educationPaperTaskMapper.selectStuClassNameByClassId(personRepDto.getClassId()); diff --git a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/paper/EducationPaperTaskServiceImpl.java b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/paper/EducationPaperTaskServiceImpl.java index c8d8f7b1..4fdbd9f9 100644 --- a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/paper/EducationPaperTaskServiceImpl.java +++ b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/paper/EducationPaperTaskServiceImpl.java @@ -16,6 +16,7 @@ import pc.exam.pp.module.exam.controller.admin.paper.vo.ExamPaperVo; import pc.exam.pp.module.exam.controller.admin.paper.vo.PaperTaskPageVo; import pc.exam.pp.module.exam.controller.admin.paper.vo.StuInfoPaper; import pc.exam.pp.module.exam.dal.dataobject.*; +import pc.exam.pp.module.exam.dal.mysql.monitor.MonitorMapper; import pc.exam.pp.module.exam.dal.mysql.paper.*; import pc.exam.pp.module.exam.dal.mysql.question.ExamQuestionMapper; import pc.exam.pp.module.exam.dal.mysql.question.SysFileMapper; @@ -58,6 +59,8 @@ public class EducationPaperTaskServiceImpl implements IEducationPaperTaskService @Autowired private SysFileMapper sysFileMapper; + @Autowired + private MonitorMapper monitorMapper; //@Autowired //private ExamQuestionMapper @@ -441,6 +444,8 @@ public class EducationPaperTaskServiceImpl implements IEducationPaperTaskService @Override public PageResult selectEducationPaperTaskListByStu(PaperTaskPageVo educationPaperTask) { + String taskType = educationPaperTask.getTaskType(); + PageResult educationPaperTasks = educationPaperTaskMapper.selectEducationPaperTaskList(educationPaperTask); Long loginUserId = SecurityFrameworkUtils.getLoginUserId(); @@ -450,6 +455,32 @@ public class EducationPaperTaskServiceImpl implements IEducationPaperTaskService list = list.stream() .filter(task -> taskIds.contains(task.getTaskId())) .collect(Collectors.toList()); + if ("0".equals(taskType)){ + for (EducationPaperTask paperTask : list) { + String taskId = paperTask.getTaskId(); + EducationPaperParam educationPaperParam = educationPaperParamMapper.selectEducationPaperParamByTaskId(taskId); + //最高成绩 + Long stuId= SecurityFrameworkUtils.getLoginUserId(); + if ("0".equals(educationPaperParam.getSaveGrades())){ + + String score= monitorMapper.selectByStuIdAndTaskIdTop(stuId,taskId); + if (StringUtils.isNotBlank(score)){ + paperTask.setScore(score); + }else { + paperTask.setScore("0.0"); + } + }else { + String score= monitorMapper.selectByStuIdAndTaskIdNew(stuId,taskId); + if (StringUtils.isNotBlank(score)){ + paperTask.setScore(score); + }else { + paperTask.setScore("0.0"); + } + } + + } + } + educationPaperTasks.setList(list); return educationPaperTasks; }else { diff --git a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/specialty/ExamSpecialtyService.java b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/specialty/ExamSpecialtyService.java index 38e5ef24..28056b2c 100644 --- a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/specialty/ExamSpecialtyService.java +++ b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/specialty/ExamSpecialtyService.java @@ -77,4 +77,6 @@ public interface ExamSpecialtyService * @return 结果 */ public int deleteExamSpecialtyBySpId(Long spId); + + String getRoleById(String id); } \ No newline at end of file diff --git a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/specialty/ExamSpecialtyServiceImpl.java b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/specialty/ExamSpecialtyServiceImpl.java index aefe3375..bac6a219 100644 --- a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/specialty/ExamSpecialtyServiceImpl.java +++ b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/specialty/ExamSpecialtyServiceImpl.java @@ -120,4 +120,9 @@ public class ExamSpecialtyServiceImpl implements ExamSpecialtyService { { return examSpecialtyMapper.deleteExamSpecialtyBySpId(spId); } + + @Override + public String getRoleById(String id) { + return examSpecialtyMapper.getRoleById(id); + } } diff --git a/exam-module-exam/exam-module-exam-biz/src/main/resources/mapper/exam/ExamQuestionAnswerMapper.xml b/exam-module-exam/exam-module-exam-biz/src/main/resources/mapper/exam/ExamQuestionAnswerMapper.xml index faebc37b..7f92677a 100644 --- a/exam-module-exam/exam-module-exam-biz/src/main/resources/mapper/exam/ExamQuestionAnswerMapper.xml +++ b/exam-module-exam/exam-module-exam-biz/src/main/resources/mapper/exam/ExamQuestionAnswerMapper.xml @@ -89,6 +89,9 @@ ORDER BY sort ASC + insert into exam_question_answer (answer_id, qu_id, is_right, image, content,contentIn,score_rate,sort) diff --git a/exam-module-exam/exam-module-exam-biz/src/main/resources/mapper/exam/ExamQuestionMapper.xml b/exam-module-exam/exam-module-exam-biz/src/main/resources/mapper/exam/ExamQuestionMapper.xml index fcbe6907..116ec265 100644 --- a/exam-module-exam/exam-module-exam-biz/src/main/resources/mapper/exam/ExamQuestionMapper.xml +++ b/exam-module-exam/exam-module-exam-biz/src/main/resources/mapper/exam/ExamQuestionMapper.xml @@ -115,6 +115,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" FROM system_tenant WHERE deleted = 0 + diff --git a/exam-module-exam/exam-module-exam-biz/src/main/resources/mapper/monitor/MonitorMapper.xml b/exam-module-exam/exam-module-exam-biz/src/main/resources/mapper/monitor/MonitorMapper.xml new file mode 100644 index 00000000..a72836a0 --- /dev/null +++ b/exam-module-exam/exam-module-exam-biz/src/main/resources/mapper/monitor/MonitorMapper.xml @@ -0,0 +1,15 @@ + + + + + + + diff --git a/exam-module-exam/exam-module-exam-biz/src/main/resources/mapper/mysqlkeyword/MysqlKeywordMapper.xml b/exam-module-exam/exam-module-exam-biz/src/main/resources/mapper/mysqlkeyword/MysqlKeywordMapper.xml new file mode 100644 index 00000000..0d04eea0 --- /dev/null +++ b/exam-module-exam/exam-module-exam-biz/src/main/resources/mapper/mysqlkeyword/MysqlKeywordMapper.xml @@ -0,0 +1,12 @@ + + + + + + + delete from exam_mysql_keyword where answer_id=#{answerId} + + + diff --git a/exam-module-exam/exam-module-exam-biz/src/main/resources/mapper/specialty/ExamSpecialtyMapper.xml b/exam-module-exam/exam-module-exam-biz/src/main/resources/mapper/specialty/ExamSpecialtyMapper.xml index 8ea8e2ba..8e75dcfc 100644 --- a/exam-module-exam/exam-module-exam-biz/src/main/resources/mapper/specialty/ExamSpecialtyMapper.xml +++ b/exam-module-exam/exam-module-exam-biz/src/main/resources/mapper/specialty/ExamSpecialtyMapper.xml @@ -13,14 +13,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + - select sp_id, parent_id, ancestors, sp_name, order_num, status, creator, create_time, updater, update_time, unite, tree_num, tenant_id from exam_specialty + select sp_id, parent_id, ancestors, sp_name, order_num, status, creator, create_time, updater, update_time, unite, tree_num, roles,tenant_id from exam_specialty + update exam_specialty diff --git a/exam-module-infra/exam-module-infra-biz/src/main/java/pc/exam/pp/module/infra/framework/security/config/SecurityConfiguration.java b/exam-module-infra/exam-module-infra-biz/src/main/java/pc/exam/pp/module/infra/framework/security/config/SecurityConfiguration.java index cf5cd22f..39108c07 100644 --- a/exam-module-infra/exam-module-infra-biz/src/main/java/pc/exam/pp/module/infra/framework/security/config/SecurityConfiguration.java +++ b/exam-module-infra/exam-module-infra-biz/src/main/java/pc/exam/pp/module/infra/framework/security/config/SecurityConfiguration.java @@ -29,7 +29,8 @@ public class SecurityConfiguration { .requestMatchers("/swagger-ui/**").permitAll(); // Spring Boot Actuator 的安全配置 registry.requestMatchers("/actuator").permitAll() - .requestMatchers("/actuator/**").permitAll(); + .requestMatchers("/actuator/**").permitAll() + .requestMatchers("/admin-api/test/test").permitAll(); // Druid 监控 registry.requestMatchers("/druid/**").permitAll(); // Spring Boot Admin Server 的安全配置 diff --git a/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/controller/admin/getpoints/GetPointsController.java b/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/controller/admin/getpoints/GetPointsController.java new file mode 100644 index 00000000..075b9b1e --- /dev/null +++ b/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/controller/admin/getpoints/GetPointsController.java @@ -0,0 +1,67 @@ +package pc.exam.pp.module.judgement.controller.admin.getpoints; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; +import pc.exam.pp.framework.common.pojo.CommonResult; +import pc.exam.pp.module.exam.dal.dataobject.ExamQuestionAnswer; +import pc.exam.pp.module.judgement.controller.admin.getpoints.vo.Points; +import pc.exam.pp.module.judgement.controller.admin.getpoints.vo.PointsVo; +import pc.exam.pp.module.judgement.controller.service.getpoints.ExamGetPointsService; + +import java.io.IOException; +import java.util.List; + +@RestController +@RequestMapping("/exam/getPoints") +public class GetPointsController { + + @Autowired + private ExamGetPointsService examGetPointsService; + + /** + * 得出文件操作考点 + * @return 得分 + */ + @PostMapping("/get_filePoint") + public CommonResult get_file_point(@RequestBody PointsVo pointsVo) throws IOException { + return CommonResult.success(examGetPointsService.get_file_point(pointsVo)); + } + /** + * 得出MYSQL操作考点 + * @return 得分 + */ + @PostMapping("/get_mysql_point") + public CommonResult get_mysql_point(@RequestBody PointsVo pointsVo) throws IOException { + return CommonResult.success(examGetPointsService.get_mysql_point(pointsVo)); + } + /** + * 新增MYSQL操作考点 + * @return 得分 + */ + @PostMapping("/set_mysql_point") + public CommonResult set_mysql_point(@RequestBody Points points) { + return CommonResult.success(examGetPointsService.set_mysql_point(points)); + } + /** + * 更新MYSQL操作考点 + * @return 得分 + */ + @PostMapping("/update_mysql_point") + public CommonResult update_mysql_point(@RequestBody Points points) { + return CommonResult.success(examGetPointsService.update_mysql_point(points)); + } + + @GetMapping("/get_Point_id/{quId}") + public CommonResult getPointById(@PathVariable("quId") String quId) { + return CommonResult.success(examGetPointsService.getPointById(quId)); + } + /** + * 得出浏览器操作考点 + * @return 得分 + */ + @PostMapping("/get_browser_point") + //todo 老师自己设置,不读文件 + public CommonResult get_browser_point(@RequestBody List examQuestionAnswers) throws IOException { + return CommonResult.success(examGetPointsService.get_browser_point()); + } +} diff --git a/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/controller/admin/getpoints/vo/Points.java b/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/controller/admin/getpoints/vo/Points.java new file mode 100644 index 00000000..4b5733b2 --- /dev/null +++ b/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/controller/admin/getpoints/vo/Points.java @@ -0,0 +1,16 @@ +package pc.exam.pp.module.judgement.controller.admin.getpoints.vo; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; +import pc.exam.pp.module.exam.dal.dataobject.ExamQuestionAnswer; + +import java.util.List; + +@Data +@AllArgsConstructor +@NoArgsConstructor +public class Points { + private String quId; + private List questionAnswerList; +} diff --git a/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/controller/admin/getpoints/vo/PointsVo.java b/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/controller/admin/getpoints/vo/PointsVo.java new file mode 100644 index 00000000..f320c9ab --- /dev/null +++ b/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/controller/admin/getpoints/vo/PointsVo.java @@ -0,0 +1,14 @@ +package pc.exam.pp.module.judgement.controller.admin.getpoints.vo; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@AllArgsConstructor +@NoArgsConstructor +public class PointsVo { + private String shucaiPath; + private String answerPath; + +} diff --git a/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/controller/service/browser/BrowserServericeImpl.java b/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/controller/service/browser/BrowserServericeImpl.java index 72fced7e..14ca40e0 100644 --- a/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/controller/service/browser/BrowserServericeImpl.java +++ b/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/controller/service/browser/BrowserServericeImpl.java @@ -1,8 +1,10 @@ package pc.exam.pp.module.judgement.controller.service.browser; +import jakarta.annotation.Resource; import org.springframework.stereotype.Service; import pc.exam.pp.module.exam.dal.dataobject.ExamQuestion; import pc.exam.pp.module.exam.dal.dataobject.ExamQuestionAnswer; +import pc.exam.pp.module.exam.dal.mysql.question.ExamQuestionAnswerMapper; import pc.exam.pp.module.judgement.controller.utils.brower.BookmarkChecker; import pc.exam.pp.module.judgement.controller.utils.brower.BookmarkDeleter; import pc.exam.pp.module.exam.utils.file.GetDifferencesBetweenFolders; @@ -15,10 +17,13 @@ import java.nio.file.Paths; import java.util.ArrayList; import java.util.List; import java.util.Map; +import java.util.stream.Collectors; @Service public class BrowserServericeImpl implements IBrowserServerice { static String answerLogPath ; // 文件路径 + @Resource + private ExamQuestionAnswerMapper examQuestionAnswerMapper; //考生试题文件夹 // static final String BASE_DIR = "D:/exam/4/"; //谷歌浏览器 @@ -31,16 +36,19 @@ public class BrowserServericeImpl implements IBrowserServerice { //Net得分点 文件类型 文件名 考点权值 // 添加到文件夹 1 // 添加到收藏夹 2 - List answerList=new ArrayList<>(); - answerList.add(new ExamQuestionAnswer("","","","","1", "人民大学", "1", "1")); - answerList.add(new ExamQuestionAnswer("","","","","1", "校情", "1", "2")); - answerList.add(new ExamQuestionAnswer("","","","","1", "机构", "1", "3")); +// List answerList=new ArrayList<>(); +// answerList.add(new ExamQuestionAnswer("","","","","人民大学", "添加到文件夹 ", "1", "1")); +// answerList.add(new ExamQuestionAnswer("","","","","校情", "添加到文件夹", "1", "2")); +// answerList.add(new ExamQuestionAnswer("","","","","机构", "添加到文件夹", "1", "3")); + + List answerList = examQuestionAnswerMapper.selectExamQuestionAnswerByQuId(question.getQuId()); + //判断如果类型为1,为添加到文件夹的html,后缀加 .html for (ExamQuestionAnswer answer : answerList) { - if ("1".equals(answer.getContent())) { - String fileName = answer.getContentIn(); + if ("添加到文件夹".equals(answer.getContentIn())) { + String fileName = answer.getContent(); if (!fileName.endsWith(".html")) { - answer.setContentIn(fileName + ".html"); + answer.setContent(fileName + ".html"); } } } @@ -70,16 +78,20 @@ public class BrowserServericeImpl implements IBrowserServerice { for (ExamQuestionAnswer examQuestionAnswer : answerList) { int currentScore = Integer.parseInt(examQuestionAnswer.getScoreRate()); // 当前得分 - if ( examQuestionAnswer.getContent().equals("2")){ - String bookmarkNameToDelete = examQuestionAnswer.getContentIn(); + if ( "添加到收藏夹".equals(examQuestionAnswer.getContentIn())){ + String bookmarkNameToDelete = examQuestionAnswer.getContent(); //检查收藏夹是否有书签 - if (BookmarkChecker.bookmarkExists(chromeBookmarkPath, bookmarkNameToDelete)) { - //如果有 +权值 + boolean isCorrect = BookmarkChecker.bookmarkExists(chromeBookmarkPath, bookmarkNameToDelete); + if (isCorrect) { + //如果有 +权值 studentScore += currentScore; - System.out.println("📌 发现书签,准备删除..."); + appendToFile(answerLogPath,"考点"+bookmarkNameToDelete + " -> 得分权值:" + currentScore+"-> 是否得分:"+isCorrect+"✅"); //删除此书签 BookmarkDeleter.deleteBookmarkByName(chromeBookmarkPath, bookmarkNameToDelete); } + else { + appendToFile(answerLogPath,"考点"+bookmarkNameToDelete + " -> 得分权值:" + currentScore+"-> 是否得分:"+isCorrect+"❌"); + } } } @@ -100,7 +112,8 @@ public class BrowserServericeImpl implements IBrowserServerice { static Integer compareStuAndTestFiles(List answerList, Map stuFiles) { int totalScore = 0; // 记录总得分 for (ExamQuestionAnswer answer : answerList) { - String filePath = answer.getContentIn(); // 试题文件路径 + if ("添加到文件夹".equals(answer.getContentIn())) { + String filePath = answer.getContent(); // 试题文件路径 int currentScore = Integer.parseInt(answer.getScoreRate()); // 当前得分 boolean isCorrect = false; // 如果学生提交中存在该文件,则得分 @@ -109,12 +122,13 @@ public class BrowserServericeImpl implements IBrowserServerice { if (isCorrect) { totalScore += currentScore; - appendToFile(answerLogPath,"考点"+answer.getContentIn() + " -> 得分权值:" + answer.getScoreRate()+"-> 是否得分:"+isCorrect+"✅"); + appendToFile(answerLogPath,"考点"+answer.getContent() + " -> 得分权值:" + answer.getScoreRate()+"-> 是否得分:"+isCorrect+"✅"); }else { - appendToFile(answerLogPath,"考点"+answer.getContentIn() + " -> 得分权值:" + answer.getScoreRate()+"-> 是否得分:"+isCorrect+"❌"); + appendToFile(answerLogPath,"考点"+answer.getContent() + " -> 得分权值:" + answer.getScoreRate()+"-> 是否得分:"+isCorrect+"❌"); } + } } //返回累加的得分点 return totalScore; diff --git a/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/controller/service/file/FileServericeImpl.java b/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/controller/service/file/FileServericeImpl.java index 1cb23808..58276752 100644 --- a/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/controller/service/file/FileServericeImpl.java +++ b/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/controller/service/file/FileServericeImpl.java @@ -1,8 +1,10 @@ package pc.exam.pp.module.judgement.controller.service.file; +import jakarta.annotation.Resource; import org.springframework.stereotype.Service; import pc.exam.pp.module.exam.dal.dataobject.ExamQuestion; import pc.exam.pp.module.exam.dal.dataobject.ExamQuestionAnswer; +import pc.exam.pp.module.exam.dal.mysql.question.ExamQuestionAnswerMapper; import pc.exam.pp.module.exam.utils.file.GetDifferencesBetweenFolders; import java.io.BufferedWriter; @@ -18,20 +20,22 @@ import java.util.Map; @Service public class FileServericeImpl implements IFileServerice { - static final String BASE_DIR = "D:/exam/3/"; static String answerLogPath ; // 文件路径 - + @Resource + private ExamQuestionAnswerMapper examQuestionAnswerMapper; @Override public double run_file_point(double score,File file, ExamQuestion question) throws IOException { - //todo 得到学生的考题答案 - List answerList=new ArrayList<>(); - answerList.add(new ExamQuestionAnswer("","","","","HGACYL\\RLQM.MEM", "考察删除", "1", "1")); - answerList.add(new ExamQuestionAnswer("","","","","TING\\XYU\\AUTOE.BAT", "考察删除", "1", "2")); - answerList.add(new ExamQuestionAnswer("","","","","AHEWL\\KMENS", "考察名称", "1", "3")); - answerList.add(new ExamQuestionAnswer("","","","","EDZK\\RONGHE.COM", "考察名称", "1", "4")); - answerList.add(new ExamQuestionAnswer("","","","","HGACYL\\PLAY.MEM", "考察名称", "1", "5")); - answerList.add(new ExamQuestionAnswer("","","","","WUE\\PB6.txt", "考察名称", "1", "6")); + List answerList = examQuestionAnswerMapper.selectExamQuestionAnswerByQuId(question.getQuId()); + + //todo 得到学生的考题答案 +// List answerList=new ArrayList<>(); +// answerList.add(new ExamQuestionAnswer("","","","","HGACYL\\RLQM.MEM", "考察删除", "1", "1")); +// answerList.add(new ExamQuestionAnswer("","","","","TING\\XYU\\AUTOE.BAT", "考察删除", "1", "2")); +// answerList.add(new ExamQuestionAnswer("","","","","AHEWL\\KMENS", "考察名称", "1", "3")); +// answerList.add(new ExamQuestionAnswer("","","","","EDZK\\RONGHE.COM", "考察名称", "1", "4")); +// answerList.add(new ExamQuestionAnswer("","","","","HGACYL\\PLAY.MEM", "考察名称", "1", "5")); +// answerList.add(new ExamQuestionAnswer("","","","","WUE\\PB6.txt", "考察名称", "1", "6")); File stuPath = file; diff --git a/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/controller/service/getpoints/ExamGetPointsService.java b/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/controller/service/getpoints/ExamGetPointsService.java new file mode 100644 index 00000000..1a3b6897 --- /dev/null +++ b/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/controller/service/getpoints/ExamGetPointsService.java @@ -0,0 +1,25 @@ +package pc.exam.pp.module.judgement.controller.service.getpoints; + +import pc.exam.pp.module.exam.dal.dataobject.ExamQuestionAnswer; +import pc.exam.pp.module.judgement.controller.admin.getpoints.vo.Points; +import pc.exam.pp.module.judgement.controller.admin.getpoints.vo.PointsVo; + +import java.io.IOException; +import java.util.List; + +public interface ExamGetPointsService { + + + + List get_file_point(PointsVo pointsVo) throws IOException; + + List get_mysql_point(PointsVo pointsVo) throws IOException; + + List get_browser_point(); + + boolean set_mysql_point(Points points); + + boolean update_mysql_point(Points points); + + List getPointById(String quId); +} diff --git a/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/controller/service/getpoints/ExamGetPointsServiceImpl.java b/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/controller/service/getpoints/ExamGetPointsServiceImpl.java new file mode 100644 index 00000000..18e8bf94 --- /dev/null +++ b/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/controller/service/getpoints/ExamGetPointsServiceImpl.java @@ -0,0 +1,274 @@ +package pc.exam.pp.module.judgement.controller.service.getpoints; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import jakarta.annotation.Resource; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.collections4.CollectionUtils; +import org.springframework.stereotype.Service; +import pc.exam.pp.module.exam.dal.dataobject.ExamMysqlKeyword; +import pc.exam.pp.module.exam.dal.dataobject.ExamQuestionAnswer; +import pc.exam.pp.module.exam.dal.mysql.mysqlkeyword.MysqlKeywordMapper; +import pc.exam.pp.module.exam.dal.mysql.question.ExamQuestionAnswerMapper; +import pc.exam.pp.module.exam.dal.mysql.question.ExamQuestionMapper; +import pc.exam.pp.module.exam.utils.file.GetDifferencesBetweenFolders; +import pc.exam.pp.module.exam.utils.uuid.IdUtils; +import pc.exam.pp.module.infra.dal.dataobject.config.ConfigDO; +import pc.exam.pp.module.infra.service.config.ConfigService; +import pc.exam.pp.module.judgement.controller.admin.getpoints.vo.Points; +import pc.exam.pp.module.judgement.controller.admin.getpoints.vo.PointsVo; +import pc.exam.pp.module.judgement.controller.utils.zip.ZipUtil; + +import java.io.File; +import java.io.IOException; +import java.nio.charset.Charset; +import java.nio.charset.MalformedInputException; +import java.nio.file.Files; +import java.nio.file.Paths; +import java.util.*; +import java.util.concurrent.atomic.AtomicInteger; +import java.util.stream.Collectors; + +@Service +@Slf4j +public class ExamGetPointsServiceImpl implements ExamGetPointsService{ + @Resource + ConfigService configService; + + @Resource + MysqlKeywordMapper mysqlKeywordMapper; + @Resource + private ExamQuestionAnswerMapper examQuestionAnswerMapper; + + + @Override + public List get_file_point(PointsVo pointsVo) throws IOException { + + // 获取平台文件参数 + ConfigDO config = configService.getConfigByKey("file_down_path"); + + String sthPath = ZipUtil.downloadStudentFile(pointsVo.getShucaiPath(), config.getValue()); + String answerPath = ZipUtil.downloadStudentFile(pointsVo.getAnswerPath(), config.getValue()); + File zip_file_sth = new File(sthPath); + File zip_file_answer= new File(answerPath); + + //获取到得是zip文件,需要解压 + String stuFilePath = ZipUtil.unzipToNamedFolder(sthPath); + String answerFilePath = ZipUtil.unzipToNamedFolder(answerPath); + + //解压之后得文件获取文件夹和文件 + File folderStu = new File(stuFilePath); + + File folderAnswer = new File(stuFilePath); + + + + + List answerList = new ArrayList<>(); + AtomicInteger sortCounter = new AtomicInteger(1); // 计数器 + + // 获取 shucai 和 win 文件夹的差异 + Map differences = GetDifferencesBetweenFolders.getDifferencesBetweenFolders(stuFilePath, answerFilePath); + + List formattedDifferences = differences.entrySet().stream() + .map(entry -> { + String key = entry.getKey(); + String value = entry.getValue(); + ExamQuestionAnswer answer = new ExamQuestionAnswer(); + answer.setContent(key); // 设置文件路径 + answer.setScoreRate("1"); + //这里设置answer的排序,按照循环次数来 + answer.setSort(String.valueOf(sortCounter.getAndIncrement())); // 按顺序设置排序值 + if (value.startsWith("仅存在于 "+stuFilePath)) { + answer.setContentIn("考察删除"); + } else if (value.startsWith("仅存在于 "+answerFilePath)) { + answer.setContentIn("考察名称"); + } else if (value.startsWith("属性不同")) { + answer.setContentIn("考察属性"); +// answer.setContent(key + " -> " + value.split(" vs ")[1]); // 设置属性信息 + } + return answer; + }) + .sorted(Comparator.comparingInt(answer -> Integer.parseInt(answer.getSort()))) // 按 sort 排序 + .collect(Collectors.toList()); + answerList.addAll(formattedDifferences); +// zip_file_sth.delete(); +// zip_file_answer.delete(); +// folderStu.delete(); +// folderAnswer.delete(); + + return answerList; + } + + @Override + public List get_mysql_point(PointsVo pointsVo) throws IOException { + + String answerPath = pointsVo.getAnswerPath(); + // 获取平台文件参数 + ConfigDO config = configService.getConfigByKey("file_down_path"); + + String sthPath = ZipUtil.downloadStudentFile(pointsVo.getAnswerPath(), config.getValue()); + System.out.println(sthPath); + List sqlStatements = readSQLFromFile(sthPath); + return sqlStatements; + } + private static List readSQLFromFile(String filePath) throws IOException { + + + List lines = readFileAutoCharset(filePath); + List sqlList = parseSql(lines); + + for (String sql : sqlList) { + System.out.println(sql); + System.out.println("-------"); + } + + return sqlList; + } + + // 自动识别 UTF-8 or GBK + private static List readFileAutoCharset(String filePath) throws IOException { + try { + // 优先尝试 UTF-8 + return Files.readAllLines(Paths.get(filePath), Charset.forName("UTF-8")); + } catch (MalformedInputException e) { + // 如果UTF-8失败,再尝试GBK + System.out.println("文件不是UTF-8编码,尝试使用GBK编码读取..."); + return Files.readAllLines(Paths.get(filePath), Charset.forName("GBK")); + } + } + // 解析SQL:去掉注释,只保留SQL语句 + private static List parseSql(List lines) { + List sqlList = new ArrayList<>(); + StringBuilder currentSql = new StringBuilder(); + + for (String line : lines) { + line = line.trim(); + if (line.startsWith("--")) { + // 遇到新的注释(比如 -- 1.),先把之前的SQL收进去 + if (currentSql.length() > 0) { + sqlList.add(currentSql.toString().trim()); + currentSql.setLength(0); + } + continue; // 注释行不用管 + } + + // 累加 SQL 内容 + currentSql.append(line).append("\n"); + } + + if (currentSql.length() > 0) { + sqlList.add(currentSql.toString().trim()); + } + + return sqlList; + } + @Override + public List get_browser_point() { + return null; + } + + @Override + public boolean set_mysql_point(Points points) { + try { + List questionAnswerList = points.getQuestionAnswerList(); + if (CollectionUtils.isEmpty(questionAnswerList)) { + return true; + } + List allKeywords = new ArrayList<>(); + + for (ExamQuestionAnswer examQuestionAnswer : questionAnswerList) { + String answerId = IdUtils.simpleUUID(); + examQuestionAnswer.setAnswerId(answerId); + examQuestionAnswer.setQuId(points.getQuId()); + List keywordList = examQuestionAnswer.getExamMysqlKeywordList(); + if (!CollectionUtils.isEmpty(keywordList)) { + for (ExamMysqlKeyword keyword : keywordList) { + keyword.setAnswerId(answerId); + keyword.setKeywordId(IdUtils.simpleUUID()); + } + allKeywords.addAll(keywordList); + } + } + + if (!CollectionUtils.isEmpty(allKeywords)) { + mysqlKeywordMapper.insertOrUpdate(allKeywords); + } + + examQuestionAnswerMapper.insertOrUpdate(questionAnswerList); + return true; + } catch (Exception e) { + log.error("保存考试点信息失败", e); + return false; + } + } + + @Override + public boolean update_mysql_point(Points points) { + try { + String quId = points.getQuId(); + List questionAnswerList = points.getQuestionAnswerList(); + // 查询旧 answerId + List oldAnswerIds = examQuestionAnswerMapper.selectExamQuestionAnswerIdByQuId(quId); + + // 删除旧关键字 + if (!CollectionUtils.isEmpty(oldAnswerIds)) { + for (String aid : oldAnswerIds) { + mysqlKeywordMapper.deleteByAnswerId(aid); + } + } + + // 删除旧答案 + examQuestionAnswerMapper.deleteExamQuestionAnswerByQuesId(quId); + + // 如果没有新数据就返回 + if (CollectionUtils.isEmpty(questionAnswerList)) { + return true; + } + + // 新的 keyword 收集 + List newKeywordList = new ArrayList<>(); + for (ExamQuestionAnswer answer : questionAnswerList) { + String answerId = IdUtils.simpleUUID(); + answer.setAnswerId(answerId); + answer.setQuId(quId); // 以防前端未传 + + List keywordList = answer.getExamMysqlKeywordList(); + if (!CollectionUtils.isEmpty(keywordList)) { + for (ExamMysqlKeyword keyword : keywordList) { + keyword.setAnswerId(answerId); + keyword.setKeywordId(IdUtils.simpleUUID()); + } + newKeywordList.addAll(keywordList); + } + } + + // 插入新答案和关键词 + examQuestionAnswerMapper.insertOrUpdate(questionAnswerList); + if (!CollectionUtils.isEmpty(newKeywordList)) { + mysqlKeywordMapper.insertOrUpdate(newKeywordList); + } + + return true; + } catch (Exception e) { + log.error("更新考试点信息失败", e); + return false; + } + } + + @Override + public List getPointById(String quId) { + List examQuestionAnswers = examQuestionAnswerMapper.selectExamQuestionAnswerByQuId(quId); + if (!CollectionUtils.isEmpty(examQuestionAnswers)) { + for (ExamQuestionAnswer examQuestionAnswer : examQuestionAnswers) { + String answerId = examQuestionAnswer.getAnswerId(); + List newKeywordList = mysqlKeywordMapper.selectList( + new QueryWrapper().eq("answer_id", answerId) + ); + examQuestionAnswer.setExamMysqlKeywordList(newKeywordList); + } + } + return examQuestionAnswers; + } + + +} diff --git a/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/controller/utils/zip/ZipUtil.java b/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/controller/utils/zip/ZipUtil.java new file mode 100644 index 00000000..5c1f8978 --- /dev/null +++ b/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/controller/utils/zip/ZipUtil.java @@ -0,0 +1,117 @@ +package pc.exam.pp.module.judgement.controller.utils.zip; + +import org.apache.commons.compress.archivers.zip.ZipArchiveEntry; +import org.apache.commons.compress.archivers.zip.ZipFile; + +import java.io.*; +import java.net.URL; +import java.net.URLConnection; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.attribute.DosFileAttributeView; +import java.util.Enumeration; + +public class ZipUtil { + + public static String unzipToNamedFolder(String zipFilePath) { + File zipFile = new File(zipFilePath); + + if (!zipFile.exists() || !zipFile.getName().toLowerCase().endsWith(".zip")) { + System.err.println("❌ 无效 zip 文件: " + zipFilePath); + return null; + } + + String fileNameNoExt = zipFile.getName().replaceAll("(?i)\\.zip$", ""); + File extractDir = new File(zipFile.getParentFile(), fileNameNoExt); + if (!extractDir.exists()) extractDir.mkdirs(); + + // 指定编码(GBK 用于支持中文文件名,UTF-8 用于通用 ZIP) + try (ZipFile zf = new ZipFile(zipFile, "GBK")) { + Enumeration entries = zf.getEntries(); + while (entries.hasMoreElements()) { + ZipArchiveEntry entry = entries.nextElement(); + File outFile = new File(extractDir, entry.getName()); + + // 防止 Zip 穿越攻击 + if (!outFile.getCanonicalPath().startsWith(extractDir.getCanonicalPath())) { + throw new IOException("非法路径: " + entry.getName()); + } + + if (entry.isDirectory()) { + outFile.mkdirs(); + } else { + File parent = outFile.getParentFile(); + if (!parent.exists()) parent.mkdirs(); + + try (InputStream is = zf.getInputStream(entry); + OutputStream os = new FileOutputStream(outFile)) { + + byte[] buffer = new byte[4096]; + int len; + while ((len = is.read(buffer)) > 0) { + os.write(buffer, 0, len); + } + } + } + + // 读取 Zip 中的外部文件属性(低16位,DOS属性) + int externalAttrs = (int) (entry.getExternalAttributes() & 0xFFFF); + + // DOS隐藏属性是第二位(0x02) + boolean hidden = (externalAttrs & 0x02) != 0; + // DOS只读属性是第一位(0x01) + boolean readOnly = (externalAttrs & 0x01) != 0; + + Path outPath = outFile.toPath(); + DosFileAttributeView view = Files.getFileAttributeView(outPath, DosFileAttributeView.class); + + if (view != null) { + try { + // 设置隐藏属性 + view.setHidden(hidden); + // 设置只读属性,需要用Files.setAttribute + Files.setAttribute(outPath, "dos:readonly", readOnly); + } catch (IOException e) { + System.err.println("设置文件属性失败: " + e.getMessage()); + } + } + } + System.out.println("✅ 解压完成,目录:" + extractDir.getAbsolutePath()); + return extractDir.getAbsolutePath(); + + } catch (IOException e) { + System.err.println("❌ 解压失败: " + e.getMessage()); + return null; + } + } + + + public static String downloadStudentFile(String fileUrl, String filePath) { + try { + URL url = new URL(fileUrl); + URLConnection connection = url.openConnection(); + + String fileName = new File(url.getPath()).getName(); + File dir = new File(filePath); + if (!dir.exists()) dir.mkdirs(); + + File saveFile = new File(dir, fileName); + + try (InputStream in = connection.getInputStream(); + FileOutputStream out = new FileOutputStream(saveFile)) { + + byte[] buffer = new byte[4096]; + int bytesRead; + while ((bytesRead = in.read(buffer)) != -1) { + out.write(buffer, 0, bytesRead); + } + + System.out.println("✅ 下载成功: " + saveFile.getAbsolutePath()); + return saveFile.getAbsolutePath(); + } + } catch (IOException e) { + System.err.println("❌ 下载失败: " + e.getMessage()); + return null; + } + } +} diff --git a/exam-server/src/main/resources/application.yaml b/exam-server/src/main/resources/application.yaml index e0a97337..0358131c 100644 --- a/exam-server/src/main/resources/application.yaml +++ b/exam-server/src/main/resources/application.yaml @@ -30,6 +30,7 @@ spring: time-to-live: 1h # 设置过期时间为 1 小时 server: + role: center servlet: encoding: enabled: true