【修改】监控管理,【新增】学生端试卷接口
This commit is contained in:
@@ -27,7 +27,8 @@ import static pc.exam.pp.framework.apilog.core.enums.OperateTypeEnum.*;
|
||||
import pc.exam.pp.module.exam.controller.admin.monitor.vo.*;
|
||||
import pc.exam.pp.module.exam.dal.dataobject.monitor.MonitorDO;
|
||||
import pc.exam.pp.module.exam.service.monitor.MonitorService;
|
||||
|
||||
import static pc.exam.pp.module.infra.enums.ErrorCodeConstants.DEMO03_MONITOR_SESSION_EXISTS;
|
||||
import static pc.exam.pp.module.infra.enums.ErrorCodeConstants.DEMO03_MONITOR_TIME_EXISTS;
|
||||
|
||||
@Tag(name = "管理后台 - 监控管理")
|
||||
@RestController
|
||||
@@ -92,13 +93,18 @@ public void exportMonitorExcel(@Valid MonitorPageReqVO pageReqVO, HttpServletRes
|
||||
{
|
||||
return success("进入考试成功");
|
||||
}
|
||||
return error(100_200_300,"不在考试时间范围内!");
|
||||
return error(DEMO03_MONITOR_TIME_EXISTS);
|
||||
|
||||
}
|
||||
@PostMapping("/stuMonitorQu")
|
||||
@Operation(summary = "学生端考试过程传试题")
|
||||
public void updateStuMonitor(@Valid @RequestBody StuMonitorQuVo stuMonitorQuVo) {
|
||||
monitorService.updateStuMonitor(stuMonitorQuVo);
|
||||
public CommonResult<String> updateStuMonitor(@Valid @RequestBody StuMonitorQuVo stuMonitorQuVo) {
|
||||
Boolean stuMonitor= monitorService.updateStuMonitor(stuMonitorQuVo);
|
||||
if (!stuMonitor)
|
||||
{
|
||||
return error(DEMO03_MONITOR_SESSION_EXISTS);
|
||||
}
|
||||
return success("传值成功");
|
||||
}
|
||||
@PostMapping("/endMonitor")
|
||||
@Operation(summary = "学生端结束考试返回值")
|
||||
@@ -106,4 +112,19 @@ public void exportMonitorExcel(@Valid MonitorPageReqVO pageReqVO, HttpServletRes
|
||||
monitorService.endStuMonitor(stuMonitorPaperEndVo);
|
||||
}
|
||||
|
||||
|
||||
@GetMapping("/getPaperTaskList")
|
||||
@Operation(summary = "根据种类获得试卷任务")
|
||||
@Parameter(name = "id", description = "试卷种类", required = true, example = "1024")
|
||||
public CommonResult getPaperTaskList(@RequestParam("id") String id) {
|
||||
|
||||
return success(monitorService.getPaperTaskList(id));
|
||||
}
|
||||
|
||||
@PostMapping("/updateMonitorStatus")
|
||||
@Operation(summary = "改变考生状态")
|
||||
public CommonResult updateMonitorStatus(@Valid @RequestBody StuMonitorStatusVo stuMonitorStatusVo) {
|
||||
return success(monitorService.updateMonitorStatus(stuMonitorStatusVo));
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -1,6 +1,7 @@
|
||||
package pc.exam.pp.module.exam.controller.admin.monitor.vo;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableLogic;
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
@@ -15,6 +16,7 @@ import static pc.exam.pp.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class MonitorPageReqVO extends PageParam {
|
||||
private String [] monitorId;
|
||||
|
||||
@Schema(description = "用户账号", example = "芋艿")
|
||||
private String username;
|
||||
@@ -37,6 +39,8 @@ private String paperNum;
|
||||
@Schema(description = "场次", example = "赵六")
|
||||
private String taskName;
|
||||
|
||||
private String taskType;
|
||||
|
||||
@Schema(description = "机器ip")
|
||||
private String ip;
|
||||
|
||||
|
@@ -39,10 +39,14 @@ private String score;
|
||||
@ExcelProperty("试卷编号")
|
||||
private String paperNum;
|
||||
|
||||
@Schema(description = "场次", example = "赵六")
|
||||
@ExcelProperty("场次")
|
||||
@Schema(description = "任务名称")
|
||||
@ExcelProperty("任务名称")
|
||||
private String taskName;
|
||||
|
||||
@Schema(description = "任务类别")
|
||||
@ExcelProperty("任务类别")
|
||||
private String taskType;
|
||||
|
||||
@Schema(description = "机器ip")
|
||||
@ExcelProperty("机器ip")
|
||||
private String ip;
|
||||
|
@@ -0,0 +1,12 @@
|
||||
package pc.exam.pp.module.exam.controller.admin.monitor.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
@Schema(description = "管理后台 - 监控管理 改变学生考试状态 Request VO")
|
||||
@Data
|
||||
public class StuMonitorStatusVo {
|
||||
private List<String> monitorIds;
|
||||
private String status;
|
||||
}
|
@@ -9,6 +9,7 @@ import org.springframework.web.bind.annotation.*;
|
||||
import pc.exam.pp.framework.common.pojo.CommonResult;
|
||||
import pc.exam.pp.framework.common.pojo.PageResult;
|
||||
import pc.exam.pp.framework.common.util.object.BeanUtils;
|
||||
import pc.exam.pp.module.exam.controller.admin.paper.dto.EducationPaperStuDto;
|
||||
import pc.exam.pp.module.exam.controller.admin.paper.dto.PaperQueryRequest;
|
||||
import pc.exam.pp.module.exam.controller.admin.paper.dto.StatusDto;
|
||||
import pc.exam.pp.module.exam.controller.admin.paper.vo.PaperPageVo;
|
||||
@@ -19,6 +20,7 @@ import pc.exam.pp.module.exam.service.paper.IEducationPaperService;
|
||||
import java.util.List;
|
||||
|
||||
import static pc.exam.pp.framework.common.exception.enums.GlobalErrorCodeConstants.INTERNAL_SERVER_ERROR;
|
||||
import static pc.exam.pp.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;
|
||||
|
||||
/**
|
||||
* 试卷Controller
|
||||
@@ -152,8 +154,6 @@ public class EducationPaperController
|
||||
@PostMapping(value = "/getPaperByTaskIdByType")
|
||||
public CommonResult getPaperByTaskIdByType(@RequestBody PaperQueryRequest requestData)
|
||||
{
|
||||
|
||||
|
||||
return CommonResult.success(educationPaperService.getPaperByTaskIdByType(requestData.getTaskId(), requestData.getRows()));
|
||||
}
|
||||
|
||||
@@ -165,4 +165,14 @@ public class EducationPaperController
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@GetMapping("/stulist")
|
||||
public CommonResult<PageResult<EducationPaperStuDto>> stulist(PaperPageVo paperPageVo)
|
||||
{
|
||||
|
||||
PageResult<EducationPaperStuDto> pageResult = educationPaperService.selectStuEducationPaperList(paperPageVo);
|
||||
return CommonResult.success(pageResult);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -0,0 +1,39 @@
|
||||
package pc.exam.pp.module.exam.controller.admin.paper.dto;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import lombok.Data;
|
||||
import pc.exam.pp.module.exam.dal.dataobject.EducationPaperParam;
|
||||
|
||||
@Data
|
||||
public class EducationPaperStuDto {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 主键ID */
|
||||
@TableId
|
||||
private String paperId;
|
||||
|
||||
/** 试卷任务ID */
|
||||
// @Excel(name = "试卷任务ID")
|
||||
private String taskId;
|
||||
|
||||
private String num;
|
||||
/** 使用次数 */
|
||||
// @Excel(name = "使用次数")
|
||||
private String counts;
|
||||
|
||||
/** 抽卷方式(0固定1AB2随机) */
|
||||
//@Excel(name = "抽卷方式(0固定1AB2随机)")
|
||||
private String rollUp;
|
||||
|
||||
/** 0A1B */
|
||||
//Excel(name = "0A1B")
|
||||
private String isAb;
|
||||
|
||||
|
||||
|
||||
EducationPaperParam educationPaperParam;
|
||||
|
||||
|
||||
|
||||
}
|
@@ -5,6 +5,8 @@ import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
import pc.exam.pp.framework.common.pojo.PageParam;
|
||||
import pc.exam.pp.module.exam.dal.dataobject.EducationPaperParam;
|
||||
|
||||
@Schema(description = "试卷vo")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
|
@@ -48,6 +48,5 @@ public class EducationPaper extends TenantBaseDO
|
||||
// @Excel(name = "0启用1不启")
|
||||
private String status;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
@@ -27,6 +27,12 @@ public class EducationPaperParam
|
||||
/** 试卷任务ID */
|
||||
// @Excel(name = "试卷任务ID")
|
||||
private String taskId;
|
||||
//是否显示试卷编号
|
||||
private String isNumber;
|
||||
//是否显示试卷内容
|
||||
private String isContent;
|
||||
//是否显示答案id
|
||||
private String isAnswerId;
|
||||
|
||||
/** 是否使用监考密码验证(0是1否) */
|
||||
// @Excel(name = "是否使用监考密码验证", readConverterExp = "0=是1否")
|
||||
|
@@ -1,5 +1,6 @@
|
||||
package pc.exam.pp.module.exam.dal.dataobject;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
@@ -24,6 +25,7 @@ public class EducationPaperSession
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 主键ID */
|
||||
@TableId
|
||||
private String sessionId;
|
||||
|
||||
/** 试卷任务ID */
|
||||
|
@@ -1,6 +1,8 @@
|
||||
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.TableLogic;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
@@ -39,6 +41,8 @@ public class EducationPaperTask extends TenantBaseDO
|
||||
//@Excel(name = "试卷任务模式")
|
||||
private String taskType;
|
||||
|
||||
private String isOne;
|
||||
|
||||
/** 是否为模板 */
|
||||
//@Excel(name = "是否为模板")
|
||||
private String isTemplate;
|
||||
@@ -47,8 +51,8 @@ public class EducationPaperTask extends TenantBaseDO
|
||||
//@Excel(name = "是否启用", readConverterExp = "0=:启用,1:停用")
|
||||
private String status;
|
||||
|
||||
|
||||
|
||||
@TableField(exist = false)
|
||||
private String count;
|
||||
|
||||
|
||||
}
|
||||
|
@@ -27,6 +27,8 @@ public class MonitorDO extends BaseDO {
|
||||
*/
|
||||
@TableId(type = IdType.INPUT)
|
||||
private String monitorId;
|
||||
|
||||
private String stuId;
|
||||
/**
|
||||
* 用户账号
|
||||
*/
|
||||
@@ -51,10 +53,11 @@ private String score;
|
||||
* 试卷编号
|
||||
*/
|
||||
private String paperNum;
|
||||
/**
|
||||
* 场次
|
||||
*/
|
||||
|
||||
private String taskId;
|
||||
private String taskName;
|
||||
|
||||
private String taskType;
|
||||
/**
|
||||
* 机器ip
|
||||
*/
|
||||
|
@@ -0,0 +1,38 @@
|
||||
package pc.exam.pp.module.exam.dal.dataobject.student;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.*;
|
||||
import pc.exam.pp.framework.tenant.core.db.TenantBaseDO;
|
||||
|
||||
/**
|
||||
* 学生-试卷-文件表 DO
|
||||
*
|
||||
* @author rwb
|
||||
*/
|
||||
@TableName("exam_stu_paper_fileurl")
|
||||
@Data
|
||||
@ToString(callSuper = true)
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class StuPaperFileDO extends TenantBaseDO {
|
||||
|
||||
/**
|
||||
* Id
|
||||
*/
|
||||
@TableId
|
||||
private Long id;
|
||||
/**
|
||||
* 学生号
|
||||
*/
|
||||
private Long stuId;
|
||||
/**
|
||||
* 试卷ID
|
||||
*/
|
||||
private String paperId;
|
||||
/**
|
||||
* 学生文件URL
|
||||
*/
|
||||
private String url;
|
||||
}
|
@@ -8,6 +8,9 @@ import org.apache.ibatis.annotations.Mapper;
|
||||
import pc.exam.pp.module.exam.controller.admin.monitor.vo.MonitorPageReqVO;
|
||||
import pc.exam.pp.module.exam.dal.dataobject.monitor.MonitorDO;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
* 监控管理 Mapper
|
||||
*
|
||||
@@ -18,10 +21,12 @@ import pc.exam.pp.module.exam.dal.dataobject.monitor.MonitorDO;
|
||||
|
||||
default PageResult<MonitorDO> selectPage(MonitorPageReqVO reqVO) {
|
||||
return selectPage(reqVO, new LambdaQueryWrapperX<MonitorDO>()
|
||||
.inIfPresent(MonitorDO::getMonitorId, Optional.ofNullable(reqVO.getMonitorId()).map(Arrays::asList).orElse(null))
|
||||
.likeIfPresent(MonitorDO::getUsername, reqVO.getUsername())
|
||||
.likeIfPresent(MonitorDO::getNickname, reqVO.getNickname())
|
||||
.likeIfPresent(MonitorDO::getClassName, reqVO.getClassName())
|
||||
.eqIfPresent(MonitorDO::getExamStatus, reqVO.getExamStatus())
|
||||
.eqIfPresent(MonitorDO::getTaskType, reqVO.getTaskType())
|
||||
.eqIfPresent(MonitorDO::getScore, reqVO.getScore())
|
||||
.eqIfPresent(MonitorDO::getPaperNum, reqVO.getPaperNum())
|
||||
.likeIfPresent(MonitorDO::getTaskName, reqVO.getTaskName())
|
||||
|
@@ -8,6 +8,7 @@ import org.apache.ibatis.annotations.Param;
|
||||
import pc.exam.pp.framework.common.pojo.PageResult;
|
||||
import pc.exam.pp.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import pc.exam.pp.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import pc.exam.pp.module.exam.controller.admin.paper.dto.EducationPaperStuDto;
|
||||
import pc.exam.pp.module.exam.controller.admin.paper.vo.PaperPageVo;
|
||||
import pc.exam.pp.module.exam.controller.admin.paper.vo.PaperTaskPageVo;
|
||||
import pc.exam.pp.module.exam.dal.dataobject.EducationPaper;
|
||||
@@ -121,5 +122,12 @@ public interface EducationPaperMapper extends BaseMapperX<EducationPaper>
|
||||
int selectCountPaperList();
|
||||
|
||||
|
||||
default PageResult<EducationPaper> selectStuEducationPaperList(PaperPageVo paperPageVo) {
|
||||
return selectPage(paperPageVo, new LambdaQueryWrapperX<EducationPaper>()
|
||||
.likeIfPresent(EducationPaper::getTaskId, paperPageVo.getTaskId())
|
||||
.isNotNull(EducationPaper::getRollUp) // 改为数据库字段不为 null
|
||||
.eq(EducationPaper::getStatus, 0)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -107,4 +107,5 @@ public interface EducationPaperPersonMapper
|
||||
|
||||
List<PersonRepDto> selectEducationPaperPersonBySessionIdNotIn(SessionStuPageReqVO sessionStuPageReqVO);
|
||||
|
||||
List<String> selectStuIdByTaskId(String taskId);
|
||||
}
|
||||
|
@@ -109,4 +109,5 @@ public interface EducationPaperTaskMapper extends BaseMapperX<EducationPaperTask
|
||||
|
||||
String selectStuClassNameByClassId(Long classId);
|
||||
|
||||
List<EducationPaperTask> selectEducationPaperTaskByTaskType(String id);
|
||||
}
|
||||
|
@@ -0,0 +1,18 @@
|
||||
package pc.exam.pp.module.exam.dal.mysql.student;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import pc.exam.pp.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import pc.exam.pp.module.exam.dal.dataobject.student.StuPaperFileDO;
|
||||
|
||||
/**
|
||||
* 学生-试卷-文件 Mapper
|
||||
*
|
||||
* @author rwb
|
||||
*/
|
||||
@Mapper
|
||||
public interface StuPaperFileMapper extends BaseMapperX<StuPaperFileDO> {
|
||||
StuPaperFileDO findByStuIdAndPaperId(@Param("stuId") Long stuId, @Param("paperId") String paperId);
|
||||
|
||||
}
|
@@ -3,8 +3,11 @@ package pc.exam.pp.module.exam.service.monitor;
|
||||
import jakarta.validation.*;
|
||||
import pc.exam.pp.framework.common.pojo.PageResult;
|
||||
import pc.exam.pp.module.exam.controller.admin.monitor.vo.*;
|
||||
import pc.exam.pp.module.exam.dal.dataobject.EducationPaperTask;
|
||||
import pc.exam.pp.module.exam.dal.dataobject.monitor.MonitorDO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 监控管理 Service 接口
|
||||
*
|
||||
@@ -52,8 +55,11 @@ import pc.exam.pp.module.exam.dal.dataobject.monitor.MonitorDO;
|
||||
|
||||
Boolean getStuMonitor(StuMonitorPaperVo stuMonitorPaperVo);
|
||||
|
||||
void updateStuMonitor(StuMonitorQuVo stuMonitorQuVo);
|
||||
Boolean updateStuMonitor(StuMonitorQuVo stuMonitorQuVo);
|
||||
|
||||
void endStuMonitor(StuMonitorPaperEndVo stuMonitorPaperEndVo);
|
||||
|
||||
List<EducationPaperTask> getPaperTaskList(String id);
|
||||
|
||||
Boolean updateMonitorStatus(StuMonitorStatusVo stuMonitorStatusVo);
|
||||
}
|
@@ -108,6 +108,18 @@ public class MonitorServiceImpl implements MonitorService {
|
||||
MonitorDO info = JsonUtils.parseObject(stringRedisTemplate.opsForValue().get(key),MonitorDO.class);
|
||||
if (StringUtils.isNotBlank(stuMonitorPaperVo.getPaperId())){
|
||||
EducationPaper educationPaper = educationPaperMapper.selectEducationPaperByPaperId(stuMonitorPaperVo.getPaperId());
|
||||
String counts = educationPaper.getCounts();
|
||||
|
||||
int count = 0;
|
||||
|
||||
try {
|
||||
count = Integer.parseInt(counts);
|
||||
} catch (NumberFormatException | NullPointerException e) {
|
||||
count = 0; // 默认从 0 开始
|
||||
}
|
||||
count += 1;
|
||||
educationPaper.setCounts(String.valueOf(count));
|
||||
educationPaperMapper.updateById(educationPaper);
|
||||
info.setPaperNum(educationPaper.getNum());
|
||||
}
|
||||
|
||||
@@ -153,6 +165,9 @@ public class MonitorServiceImpl implements MonitorService {
|
||||
long remainingSeconds = ChronoUnit.SECONDS.between(LocalDateTime.now(),
|
||||
DateUtil.toLocalDateTime(endTime));
|
||||
info.setRemainingTime(remainingSeconds > 0 ? remainingSeconds : 0);
|
||||
|
||||
|
||||
//todo 考虑加点时间,或判分后删除
|
||||
stringRedisTemplate.opsForValue().set("userCache:"+stuMonitorPaperVo.getTaskId()+":"+stuMonitorPaperVo.getStuId(), JsonUtils.toJsonString(info), remainingSeconds, TimeUnit.SECONDS);
|
||||
monitorMapper.updateById(info);
|
||||
return true;
|
||||
@@ -164,10 +179,13 @@ public class MonitorServiceImpl implements MonitorService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateStuMonitor(StuMonitorQuVo stuMonitorQuVo) {
|
||||
public Boolean updateStuMonitor(StuMonitorQuVo stuMonitorQuVo) {
|
||||
String key = "userCache:"+stuMonitorQuVo.getTaskId()+":" + stuMonitorQuVo.getStuId();
|
||||
MonitorDO info = JsonUtils.parseObject(stringRedisTemplate.opsForValue().get(key),MonitorDO.class);
|
||||
if (info != null) {
|
||||
if (!("1".equals(info.getExamStatus()))){
|
||||
return false;
|
||||
}
|
||||
AtomicInteger totalScore = new AtomicInteger(); // 用于累加总分
|
||||
// 记录答题结果
|
||||
List<StuMonitorQuVo.EducationPaperSchemeMap> paperSchemeMaps = stuMonitorQuVo.getPaperSchemeMaps();
|
||||
@@ -193,6 +211,7 @@ public class MonitorServiceImpl implements MonitorService {
|
||||
redisTemplate.opsForValue().set(key, info);
|
||||
// monitorMapper.updateById(info);
|
||||
}
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
@@ -216,11 +235,57 @@ public class MonitorServiceImpl implements MonitorService {
|
||||
info.setExamStatus("0");
|
||||
}else {
|
||||
info.setExamStatus("2");
|
||||
redisTemplate.delete(key);
|
||||
}
|
||||
|
||||
redisTemplate.delete(key);
|
||||
monitorMapper.updateById(info);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<EducationPaperTask> getPaperTaskList(String id) {
|
||||
return educationPaperTaskMapper.selectEducationPaperTaskByTaskType(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean updateMonitorStatus(StuMonitorStatusVo stuMonitorStatusVo) {
|
||||
String status = stuMonitorStatusVo.getStatus();
|
||||
List<String> monitorIds = stuMonitorStatusVo.getMonitorIds();
|
||||
if ("1".equals(status)||"0".equals(status)){
|
||||
//新增或更新
|
||||
for (String monitorId : monitorIds) {
|
||||
MonitorDO monitorDO = monitorMapper.selectById(monitorId);
|
||||
String taskId = monitorDO.getTaskId();
|
||||
String stuId = monitorDO.getStuId();
|
||||
String key = "userCache:" + taskId+":" +stuId;
|
||||
monitorDO.setExamStatus(status);
|
||||
monitorMapper.updateById(monitorDO);
|
||||
MonitorDO info = JsonUtils.parseObject(stringRedisTemplate.opsForValue().get(key),MonitorDO.class);
|
||||
|
||||
info.setExamStatus(status);
|
||||
|
||||
stringRedisTemplate.opsForValue().set(key, JsonUtils.toJsonString(info));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if ("2".equals(status)){
|
||||
//删除
|
||||
for (String monitorId : monitorIds) {
|
||||
MonitorDO monitorDO = monitorMapper.selectById(monitorId);
|
||||
String taskId = monitorDO.getTaskId();
|
||||
String stuId = monitorDO.getStuId();
|
||||
String key = "userCache:" + taskId+":" +stuId;
|
||||
monitorDO.setExamStatus(status);
|
||||
monitorMapper.updateById(monitorDO);
|
||||
|
||||
redisTemplate.delete(key);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -196,7 +196,7 @@ public class EducationPaperPersonServiceImpl implements IEducationPaperPersonSer
|
||||
|
||||
|
||||
} else if (existing == null) {
|
||||
|
||||
EducationPaperTask educationPaperTask = educationPaperTaskMapper.selectEducationPaperTaskByTaskId(taskId);
|
||||
|
||||
String name= educationPaperTaskMapper.selectEducationPaperTaskNameByid(taskId);
|
||||
|
||||
@@ -206,6 +206,8 @@ public class EducationPaperPersonServiceImpl implements IEducationPaperPersonSer
|
||||
String uuid = IdUtils.simpleUUID();
|
||||
MonitorDO info = new MonitorDO();
|
||||
info.setMonitorId(uuid);
|
||||
info.setTaskId(taskId);
|
||||
info.setStuId(studentId);
|
||||
info.setUsername(personRepDto.getUsername());
|
||||
info.setNickname(personRepDto.getNickname());
|
||||
//设置学生班级
|
||||
@@ -217,6 +219,7 @@ public class EducationPaperPersonServiceImpl implements IEducationPaperPersonSer
|
||||
info.setScore("0");
|
||||
info.setPaperNum("");
|
||||
info.setTaskName(name);
|
||||
info.setTaskType(educationPaperTask.getTaskType());
|
||||
stringRedisTemplate.opsForValue().set(key, JsonUtils.toJsonString(info));
|
||||
monitorMapper.insert(info);
|
||||
|
||||
|
@@ -1,24 +1,22 @@
|
||||
package pc.exam.pp.module.exam.service.paper;
|
||||
|
||||
|
||||
import org.checkerframework.checker.units.qual.A;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import pc.exam.pp.framework.common.pojo.PageResult;
|
||||
import pc.exam.pp.framework.tenant.core.aop.TenantIgnore;
|
||||
import pc.exam.pp.framework.tenant.core.context.TenantContextHolder;
|
||||
import pc.exam.pp.module.exam.controller.admin.paper.dto.EducationPaperStuDto;
|
||||
import pc.exam.pp.module.exam.controller.admin.paper.vo.PaperPageVo;
|
||||
import pc.exam.pp.module.exam.dal.dataobject.PaperListResponseVo;
|
||||
import pc.exam.pp.module.exam.dal.dataobject.EducationPaper;
|
||||
import pc.exam.pp.module.exam.dal.dataobject.EducationPaperQu;
|
||||
import pc.exam.pp.module.exam.dal.dataobject.EducationPaperScheme;
|
||||
import pc.exam.pp.module.exam.dal.mysql.paper.EducationPaperMapper;
|
||||
import pc.exam.pp.module.exam.dal.mysql.paper.EducationPaperQuMapper;
|
||||
import pc.exam.pp.module.exam.dal.mysql.paper.EducationPaperSchemeMapper;
|
||||
import pc.exam.pp.module.exam.dal.mysql.paper.EducationPaperTaskMapper;
|
||||
import pc.exam.pp.module.exam.dal.dataobject.*;
|
||||
import pc.exam.pp.module.exam.dal.mysql.paper.*;
|
||||
import pc.exam.pp.module.exam.utils.uuid.IdUtils;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import static pc.exam.pp.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;
|
||||
|
||||
/**
|
||||
* 试卷Service业务层处理
|
||||
*
|
||||
@@ -31,12 +29,17 @@ public class EducationPaperServiceImpl implements IEducationPaperService
|
||||
@Autowired
|
||||
private EducationPaperMapper educationPaperMapper;
|
||||
@Autowired
|
||||
private EducationPaperParamMapper educationPaperParamMapper;
|
||||
@Autowired
|
||||
private EducationPaperSchemeMapper educationPaperSchemeMapper;
|
||||
@Autowired
|
||||
private EducationPaperTaskMapper educationPaperTaskMapper;
|
||||
|
||||
@Autowired
|
||||
private EducationPaperQuMapper educationPaperQuMapper;
|
||||
|
||||
@Autowired
|
||||
private EducationPaperPersonMapper educationPaperPersonMapper;
|
||||
/**
|
||||
* 查询试卷
|
||||
*
|
||||
@@ -257,6 +260,46 @@ public class EducationPaperServiceImpl implements IEducationPaperService
|
||||
return educationPaperMapper.changeStatus(paperId,status);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<EducationPaperStuDto> selectStuEducationPaperList(PaperPageVo paperPageVo) {
|
||||
String taskId = paperPageVo.getTaskId();
|
||||
List<String> stuIds=educationPaperPersonMapper.selectStuIdByTaskId(taskId);
|
||||
Long loginUserId = getLoginUserId();
|
||||
// 判断试卷任务是否包含此学生
|
||||
if (stuIds.contains(String.valueOf(loginUserId))) {
|
||||
//
|
||||
List<EducationPaperStuDto> educationPaperStuDtos=new ArrayList<>();
|
||||
PageResult<EducationPaper> educationPaperPageResult = educationPaperMapper.selectStuEducationPaperList(paperPageVo);
|
||||
List<EducationPaper> list = educationPaperPageResult.getList();
|
||||
if (list!=null&&list.size()>0){
|
||||
for (EducationPaper educationPaper : list) {
|
||||
EducationPaperStuDto educationPaperStuDto=new EducationPaperStuDto();
|
||||
|
||||
EducationPaperParam educationPaperParam = educationPaperParamMapper.selectEducationPaperParamByTaskId(educationPaper.getTaskId());
|
||||
educationPaperStuDto.setPaperId(educationPaper.getPaperId());
|
||||
educationPaperStuDto.setNum(educationPaper.getNum());
|
||||
educationPaperStuDto.setTaskId(educationPaper.getTaskId());
|
||||
educationPaperStuDto.setCounts(educationPaper.getCounts());
|
||||
educationPaperStuDto.setRollUp(educationPaper.getRollUp());
|
||||
educationPaperStuDto.setIsAb(educationPaper.getIsAb());
|
||||
educationPaperStuDto.setEducationPaperParam(educationPaperParam);
|
||||
educationPaperStuDtos.add(educationPaperStuDto);
|
||||
}
|
||||
}
|
||||
PageResult<EducationPaperStuDto> educationPaperStuDtoPageResult=new PageResult<>();
|
||||
educationPaperStuDtoPageResult.setList(educationPaperStuDtos);
|
||||
educationPaperStuDtoPageResult.setTotal(educationPaperPageResult.getTotal());
|
||||
return educationPaperStuDtoPageResult;
|
||||
|
||||
} else {
|
||||
// 不包含
|
||||
PageResult<EducationPaperStuDto> educationPaperStuDtoPageResult=new PageResult<>();
|
||||
return educationPaperStuDtoPageResult;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
@@ -68,6 +68,27 @@ public class EducationPaperTaskServiceImpl implements IEducationPaperTaskService
|
||||
@Override
|
||||
public PageResult<EducationPaperTask> selectEducationPaperTaskList(PaperTaskPageVo educationPaperTask) {
|
||||
PageResult<EducationPaperTask> educationPaperTasks = educationPaperTaskMapper.selectEducationPaperTaskList(educationPaperTask);
|
||||
List<EducationPaperTask> list = educationPaperTasks.getList();
|
||||
if (list!=null&&list.size()>0){
|
||||
for (EducationPaperTask paperTask : list) {
|
||||
int count=0;
|
||||
List<EducationPaper> educationPapers = educationPaperMapper.selectPaperListByTaskId(paperTask.getTaskId());
|
||||
if (educationPapers!=null&&educationPapers.size()>0){
|
||||
for (EducationPaper educationPaper : educationPapers) {
|
||||
try {
|
||||
count += Integer.parseInt(educationPaper.getCounts());
|
||||
} catch (NumberFormatException e) {
|
||||
// 可选:记录异常或忽略非法数字
|
||||
System.err.println("无效的 counts 值: " + educationPaper.getCounts());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
paperTask.setCount(String.valueOf(count));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return educationPaperTasks ;
|
||||
}
|
||||
|
||||
@@ -89,6 +110,11 @@ public class EducationPaperTaskServiceImpl implements IEducationPaperTaskService
|
||||
educationPaperParam.setUsb("0");
|
||||
educationPaperParam.setSaveGrades("0");
|
||||
educationPaperParam.setDriver("C");
|
||||
educationPaperParam.setIsNumber("1");
|
||||
educationPaperParam.setIsConnect("0");
|
||||
educationPaperParam.setIsAnswerId("1");
|
||||
|
||||
|
||||
educationPaperParam.setDirectory("KSWJ");
|
||||
educationPaperParam.setUploadTime("5");
|
||||
educationPaperParam.setIsDel("0");
|
||||
|
@@ -2,6 +2,7 @@ package pc.exam.pp.module.exam.service.paper;
|
||||
|
||||
|
||||
import pc.exam.pp.framework.common.pojo.PageResult;
|
||||
import pc.exam.pp.module.exam.controller.admin.paper.dto.EducationPaperStuDto;
|
||||
import pc.exam.pp.module.exam.controller.admin.paper.vo.PaperPageVo;
|
||||
import pc.exam.pp.module.exam.dal.dataobject.PaperListResponseVo;
|
||||
import pc.exam.pp.module.exam.dal.dataobject.EducationPaper;
|
||||
@@ -87,5 +88,7 @@ public interface IEducationPaperService
|
||||
int changeStatus(String paperId, String status);
|
||||
|
||||
|
||||
PageResult<EducationPaperStuDto> selectStuEducationPaperList(PaperPageVo paperPageVo);
|
||||
|
||||
}
|
||||
|
||||
|
@@ -0,0 +1,24 @@
|
||||
package pc.exam.pp.module.exam.service.stu_paper_file;
|
||||
|
||||
import jakarta.validation.Valid;
|
||||
import pc.exam.pp.framework.common.pojo.PageResult;
|
||||
import pc.exam.pp.module.exam.controller.admin.student.vo.StudentPageReqVO;
|
||||
import pc.exam.pp.module.exam.controller.admin.student.vo.StudentSaveReqVO;
|
||||
import pc.exam.pp.module.exam.dal.dataobject.student.StuPaperFileDO;
|
||||
import pc.exam.pp.module.exam.dal.dataobject.student.StudentDO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 学生-试卷-文件 Service 接口
|
||||
*
|
||||
* @author rwb
|
||||
*/
|
||||
public interface StuPaperFileService {
|
||||
|
||||
StuPaperFileDO findByStuIDAndPaperId(Long stuID, String paperID);
|
||||
|
||||
void insertStuPaperFile(StuPaperFileDO stuPaperFileDO);
|
||||
|
||||
void updateStuPaperFile(StuPaperFileDO stuPaperFileDO);
|
||||
}
|
@@ -0,0 +1,35 @@
|
||||
package pc.exam.pp.module.exam.service.stu_paper_file;
|
||||
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import pc.exam.pp.module.exam.dal.dataobject.student.StuPaperFileDO;
|
||||
import pc.exam.pp.module.exam.dal.mysql.student.StuPaperFileMapper;
|
||||
|
||||
/**
|
||||
* 学生-试卷-文件 Service 实现类
|
||||
*
|
||||
* @author rwb
|
||||
*/
|
||||
@Service
|
||||
@Validated
|
||||
public class StuPaperFileServiceImpl implements StuPaperFileService {
|
||||
|
||||
@Resource
|
||||
private StuPaperFileMapper stuPaperFileMapper;
|
||||
|
||||
@Override
|
||||
public StuPaperFileDO findByStuIDAndPaperId(Long stuID, String paperID) {
|
||||
return stuPaperFileMapper.findByStuIdAndPaperId(stuID, paperID);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void insertStuPaperFile(StuPaperFileDO stuPaperFileDO) {
|
||||
stuPaperFileMapper.insert(stuPaperFileDO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateStuPaperFile(StuPaperFileDO stuPaperFileDO) {
|
||||
stuPaperFileMapper.updateById(stuPaperFileDO);
|
||||
}
|
||||
}
|
@@ -7,6 +7,9 @@
|
||||
<resultMap type="EducationPaperParam" id="EducationPaperParamResult">
|
||||
<result property="paramId" column="param_id" />
|
||||
<result property="taskId" column="task_id" />
|
||||
<result property="isNumber" column="is_number" />
|
||||
<result property="isContent" column="is_content" />
|
||||
<result property="isAnswerId" column="is_answer_id" />
|
||||
<result property="isExamPassword" column="is_exam_password" />
|
||||
<result property="examPassword" column="exam_password" />
|
||||
<result property="usb" column="usb" />
|
||||
@@ -23,7 +26,7 @@
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectEducationPaperParamVo">
|
||||
select param_id, task_id, is_exam_password, exam_password, usb, save_grades, driver, directory, upload_time, is_del,is_repeat ,is_answer,is_look,is_connect,is_session from education_paper_param
|
||||
select param_id, task_id, is_number,is_content,is_answer_id,is_exam_password, exam_password, usb, save_grades, driver, directory, upload_time, is_del,is_repeat ,is_answer,is_look,is_connect,is_session from education_paper_param
|
||||
</sql>
|
||||
|
||||
<select id="selectEducationPaperParamList" parameterType="EducationPaperParam" resultMap="EducationPaperParamResult">
|
||||
@@ -55,6 +58,9 @@
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="paramId != null">param_id,</if>
|
||||
<if test="taskId != null">task_id,</if>
|
||||
<if test="isNumber != null">is_number,</if>
|
||||
<if test="isContent != null">is_content,</if>
|
||||
<if test="isAnswerId != null">is_answer_id,</if>
|
||||
<if test="isExamPassword != null">is_exam_password,</if>
|
||||
<if test="examPassword != null">exam_password,</if>
|
||||
<if test="usb != null">usb,</if>
|
||||
@@ -73,6 +79,9 @@
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="paramId != null">#{paramId},</if>
|
||||
<if test="taskId != null">#{taskId},</if>
|
||||
<if test="isNumber != null">#{isNumber},</if>
|
||||
<if test="isContent != null">#{isContent},</if>
|
||||
<if test="isAnswerId != null">#{isAnswerId},</if>
|
||||
<if test="isExamPassword != null">#{isExamPassword},</if>
|
||||
<if test="examPassword != null">#{examPassword},</if>
|
||||
<if test="usb != null">#{usb},</if>
|
||||
@@ -94,6 +103,9 @@
|
||||
update education_paper_param
|
||||
<trim prefix="SET" suffixOverrides=",">
|
||||
<if test="taskId != null">task_id = #{taskId},</if>
|
||||
<if test="isNumber != null">is_number = #{isNumber},</if>
|
||||
<if test="isContent != null">is_content = #{isContent},</if>
|
||||
<if test="isAnswerId != null">is_answer_id = #{isAnswerId},</if>
|
||||
<if test="isExamPassword != null">is_exam_password = #{isExamPassword},</if>
|
||||
<if test="examPassword != null">exam_password = #{examPassword},</if>
|
||||
<if test="usb != null">usb = #{usb},</if>
|
||||
|
@@ -107,6 +107,10 @@
|
||||
ORDER BY s.id DESC
|
||||
|
||||
</select>
|
||||
<select id="selectStuIdByTaskId" resultType="java.lang.String">
|
||||
|
||||
select person_id from education_paper_person where task_id=#{taskId}
|
||||
</select>
|
||||
|
||||
|
||||
<insert id="insertEducationPaperPerson" parameterType="EducationPaperPerson">
|
||||
|
@@ -113,6 +113,12 @@
|
||||
<select id="selectStuClassNameByClassId" resultType="java.lang.String">
|
||||
select name from exam_class where id=#{classId}
|
||||
</select>
|
||||
<select id="selectEducationPaperTaskByTaskType"
|
||||
resultMap="EducationPaperTaskResult">
|
||||
<include refid="selectEducationPaperTaskVo"/>
|
||||
where task_type = #{id}
|
||||
and deleted='0'
|
||||
</select>
|
||||
|
||||
|
||||
<insert id="insertEducationPaperTask" parameterType="EducationPaperTask">
|
||||
|
@@ -38,7 +38,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<where>
|
||||
<if test="quId != null "> and qu_id = #{quId}</if>
|
||||
</where>
|
||||
and (file_type = '0' or file_type ='1')
|
||||
</select>
|
||||
|
||||
<insert id="insertSysFile" parameterType="SysFileUpload">
|
||||
|
@@ -0,0 +1,15 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="pc.exam.pp.module.exam.dal.mysql.student.StuPaperFileMapper">
|
||||
|
||||
<!--
|
||||
一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。
|
||||
无法满足的场景,例如说多表关联查询,才使用 XML 编写 SQL。
|
||||
代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。
|
||||
文档可见:https://www.iocoder.cn/MyBatis/x-plugins/
|
||||
-->
|
||||
<select id="findByStuIdAndPaperId" resultType="pc.exam.pp.module.exam.dal.dataobject.student.StuPaperFileDO">
|
||||
SELECT * FROM exam_stu_paper_fileurl WHERE stu_id = #{stuId} AND paper_id = #{paperId}
|
||||
</select>
|
||||
|
||||
</mapper>
|
@@ -73,4 +73,11 @@ public interface ErrorCodeConstants {
|
||||
|
||||
// ========== 试卷参数 1-001-401-000 ==========
|
||||
ErrorCode DEMO03_PAPER_SESSION_EXISTS = new ErrorCode(1_001_401_001, "请开启考场设置");
|
||||
|
||||
|
||||
// ========== 监控管理 1-001-606-000 ==========
|
||||
ErrorCode DEMO03_MONITOR_TIME_EXISTS = new ErrorCode(1-001-606-001, "该考试不在考场时间范围内!");
|
||||
ErrorCode DEMO03_MONITOR_SESSION_EXISTS = new ErrorCode(1-001-606-002, "考生状态未在考试中!请联系管理员");
|
||||
|
||||
|
||||
}
|
||||
|
@@ -124,6 +124,12 @@
|
||||
<groupId>org.apache.tika</groupId>
|
||||
<artifactId>tika-core</artifactId> <!-- 文件客户端:文件类型的识别 -->
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>pc.exam.gg</groupId>
|
||||
<artifactId>exam-module-exam-biz</artifactId>
|
||||
<version>2.4.2-SNAPSHOT</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
|
@@ -66,6 +66,14 @@ public class FileController {
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@PostMapping("/upload_stu")
|
||||
@Operation(summary = "上传学生考试文件", description = "模式三:后端上传文件,带有学生ID")
|
||||
public CommonResult<String> uploadStuFile(StuFileUploadReqVO uploadReqVO) throws Exception {
|
||||
MultipartFile file = uploadReqVO.getFile();
|
||||
String path = uploadReqVO.getPath();
|
||||
return success(fileService.createStuFile(uploadReqVO.getStuId(), uploadReqVO.getPaperId(), file.getOriginalFilename(), path, IoUtil.readBytes(file.getInputStream())));
|
||||
}
|
||||
|
||||
@GetMapping("/{configId}/get/**")
|
||||
@PermitAll
|
||||
@Operation(summary = "下载文件")
|
||||
|
@@ -0,0 +1,25 @@
|
||||
package pc.exam.pp.module.infra.controller.admin.file.vo.file;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Data;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
@Schema(description = "管理后台 - 上传文件 Request VO")
|
||||
@Data
|
||||
public class StuFileUploadReqVO {
|
||||
|
||||
@Schema(description = "文件附件", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotNull(message = "文件附件不能为空")
|
||||
private MultipartFile file;
|
||||
|
||||
@Schema(description = "文件附件", example = "examyuanma.png")
|
||||
private String path;
|
||||
|
||||
@Schema(description = "学生ID")
|
||||
private Long stuId;
|
||||
|
||||
@Schema(description = "试卷ID")
|
||||
private String paperId;
|
||||
|
||||
}
|
@@ -31,6 +31,16 @@ public interface FileService {
|
||||
*/
|
||||
String createFile(String name, String path, byte[] content);
|
||||
|
||||
/**
|
||||
* 保存文件,并返回文件的访问路径
|
||||
*
|
||||
* @param name 文件名称
|
||||
* @param path 文件路径
|
||||
* @param content 文件内容
|
||||
* @return 文件路径
|
||||
*/
|
||||
String createStuFile(Long stuId, String paperId, String name, String path, byte[] content);
|
||||
|
||||
/**
|
||||
* 创建文件
|
||||
*
|
||||
|
@@ -5,6 +5,8 @@ import cn.hutool.core.util.StrUtil;
|
||||
import pc.exam.pp.framework.common.pojo.PageResult;
|
||||
import pc.exam.pp.framework.common.util.io.FileUtils;
|
||||
import pc.exam.pp.framework.common.util.object.BeanUtils;
|
||||
import pc.exam.pp.module.exam.dal.dataobject.student.StuPaperFileDO;
|
||||
import pc.exam.pp.module.exam.service.stu_paper_file.StuPaperFileService;
|
||||
import pc.exam.pp.module.infra.framework.file.core.client.FileClient;
|
||||
import pc.exam.pp.module.infra.framework.file.core.client.s3.FilePresignedUrlRespDTO;
|
||||
import pc.exam.pp.module.infra.framework.file.core.utils.FileTypeUtils;
|
||||
@@ -34,6 +36,9 @@ public class FileServiceImpl implements FileService {
|
||||
@Resource
|
||||
private FileMapper fileMapper;
|
||||
|
||||
@Resource
|
||||
private StuPaperFileService stuPaperFileService;
|
||||
|
||||
@Override
|
||||
public PageResult<FileDO> getFilePage(FilePageReqVO pageReqVO) {
|
||||
return fileMapper.selectPage(pageReqVO);
|
||||
@@ -69,6 +74,53 @@ public class FileServiceImpl implements FileService {
|
||||
return url;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SneakyThrows
|
||||
public String createStuFile(Long stuId, String paperId, String name, String path, byte[] content) {
|
||||
// 计算默认的 path 名
|
||||
String type = FileTypeUtils.getMineType(content, name);
|
||||
if (StrUtil.isEmpty(path)) {
|
||||
path = FileUtils.generatePath(content, name);
|
||||
}
|
||||
// 如果 name 为空,则使用 path 填充
|
||||
if (StrUtil.isEmpty(name)) {
|
||||
name = path;
|
||||
}
|
||||
|
||||
// 上传到文件存储器
|
||||
FileClient client = fileConfigService.getMasterFileClient();
|
||||
Assert.notNull(client, "客户端(master) 不能为空");
|
||||
String url = client.upload(content, path, type);
|
||||
|
||||
// 保存到数据库
|
||||
FileDO file = new FileDO();
|
||||
file.setConfigId(client.getId());
|
||||
file.setName(name);
|
||||
file.setPath(path);
|
||||
file.setUrl(url);
|
||||
file.setType(type);
|
||||
file.setSize(content.length);
|
||||
fileMapper.insert(file);
|
||||
// 需要更新学生表
|
||||
// 1、先查询学生,试卷 是否已经存在数据
|
||||
StuPaperFileDO stuPaperFileDO = stuPaperFileService.findByStuIDAndPaperId(stuId, paperId);
|
||||
if (stuPaperFileDO == null) {
|
||||
// 说明没有上传过,需要新增进去
|
||||
StuPaperFileDO stuPaperFile = new StuPaperFileDO();
|
||||
stuPaperFile.setPaperId(paperId);
|
||||
stuPaperFile.setStuId(stuId);
|
||||
stuPaperFile.setUrl(url);
|
||||
stuPaperFileService.insertStuPaperFile(stuPaperFile);
|
||||
} else {
|
||||
// 说明已经上传过,判断url是否一致,不一致得,需要进行更新操作
|
||||
if (!url.equals(stuPaperFileDO.getUrl())) {
|
||||
stuPaperFileDO.setUrl(url);
|
||||
stuPaperFileService.updateStuPaperFile(stuPaperFileDO);
|
||||
}
|
||||
}
|
||||
return url;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long createFile(FileCreateReqVO createReqVO) {
|
||||
FileDO file = BeanUtils.toBean(createReqVO, FileDO.class);
|
||||
|
@@ -1,4 +1,26 @@
|
||||
package pc.exam.pp.module.judgement.controller.admin.autoTools;
|
||||
|
||||
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
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.judgement.controller.admin.autoTools.vo.StuPaperReqVo;
|
||||
import pc.exam.pp.module.judgement.service.auto_tools.AutoToolsService;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/tool")
|
||||
@Tag( name = "测试判分")
|
||||
@Validated
|
||||
public class AutoToolsController {
|
||||
@Resource
|
||||
private AutoToolsService autoToolsService;
|
||||
|
||||
@GetMapping("/get")
|
||||
public CommonResult<Double> get(StuPaperReqVo stuPaperReqVo) {
|
||||
return autoToolsService.judgementScore(stuPaperReqVo.getStuId(),stuPaperReqVo.getPaperId());
|
||||
}
|
||||
}
|
||||
|
@@ -5,15 +5,13 @@ import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class StudentUploadFileZipReqVo {
|
||||
public class StuPaperReqVo {
|
||||
|
||||
@Schema(description = "学号")
|
||||
private Long studentId;
|
||||
private Long stuId;
|
||||
|
||||
@Schema(description = "试卷号")
|
||||
private String paperId;
|
||||
|
||||
@Schema(description = "上传文件路径")
|
||||
private String filePath;
|
||||
|
||||
}
|
@@ -1,5 +1,7 @@
|
||||
package pc.exam.pp.module.judgement.service.auto_tools;
|
||||
|
||||
import pc.exam.pp.framework.common.pojo.CommonResult;
|
||||
|
||||
public interface AutoToolsService {
|
||||
|
||||
|
||||
@@ -23,4 +25,12 @@ public interface AutoToolsService {
|
||||
* @return 解压后的目录
|
||||
*/
|
||||
String unzipToNamedFolder(String zipFilePath);
|
||||
|
||||
/**
|
||||
* 判分
|
||||
* @param stuId 学号
|
||||
* @param paperId 试卷ID
|
||||
* @return 分数
|
||||
*/
|
||||
CommonResult<Double> judgementScore(Long stuId, String paperId);
|
||||
}
|
||||
|
@@ -1,6 +1,16 @@
|
||||
package pc.exam.pp.module.judgement.service.auto_tools;
|
||||
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.stereotype.Service;
|
||||
import pc.exam.pp.framework.common.exception.ErrorCode;
|
||||
import pc.exam.pp.framework.common.pojo.CommonResult;
|
||||
import pc.exam.pp.module.exam.dal.dataobject.ExamQuestion;
|
||||
import pc.exam.pp.module.exam.dal.dataobject.student.StuPaperFileDO;
|
||||
import pc.exam.pp.module.exam.service.question.IExamQuestionService;
|
||||
import pc.exam.pp.module.exam.service.stu_paper_file.StuPaperFileService;
|
||||
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.service.c_programming.JudgementService;
|
||||
|
||||
import java.io.*;
|
||||
import java.net.MalformedURLException;
|
||||
@@ -11,6 +21,14 @@ import java.util.zip.ZipInputStream;
|
||||
|
||||
@Service
|
||||
public class AutoToolsServiceImpl implements AutoToolsService{
|
||||
@Resource
|
||||
private StuPaperFileService stuPaperFileService;
|
||||
@Resource
|
||||
ConfigService configService;
|
||||
@Resource
|
||||
IExamQuestionService examQuestionService;
|
||||
@Resource
|
||||
JudgementService judgementService;
|
||||
|
||||
@Override
|
||||
public String downloadStudentFile(String fileUrl, String filePath) {
|
||||
@@ -94,4 +112,66 @@ public class AutoToolsServiceImpl implements AutoToolsService{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommonResult<Double> judgementScore(Long stuId, String paperId) {
|
||||
double score = 0;
|
||||
// 1、通过学号,试卷ID查询文件路径
|
||||
StuPaperFileDO stuPaperFileDO = stuPaperFileService.findByStuIDAndPaperId(stuId, paperId);
|
||||
// 2、判断文件路径是否存在
|
||||
if (stuPaperFileDO == null) {
|
||||
return CommonResult.error(100031, "试题文件没有上传,无法判分!");
|
||||
}
|
||||
// 3、下载文件
|
||||
// 获取平台文件参数
|
||||
ConfigDO config = configService.getConfigByKey("file_down_path");
|
||||
String patn = downloadStudentFile(stuPaperFileDO.getUrl(), config.getValue());
|
||||
// 4、获取到得是zip文件,需要解压
|
||||
String stuFilePath = unzipToNamedFolder(patn);
|
||||
// 5、解压之后得文件获取文件夹和文件
|
||||
File folder = new File(stuFilePath);
|
||||
File[] files = folder.listFiles();
|
||||
String stu_files = null;
|
||||
// 5.1、 只查询文件夹 (学号-试卷ID-试题ID-具体内容)
|
||||
if (files == null) return CommonResult.error(100032, "1、试题文件上传,目录不正确!");
|
||||
if (files.length > 1) return CommonResult.error(100033, "2、试题文件上传,目录不正确!");
|
||||
if (!files[0].isDirectory()) return CommonResult.error(100034, "3、试题文件上传,目录不正确!");
|
||||
// 判断学号是否正确
|
||||
if (!files[0].getName().equals(stuId.toString())) return CommonResult.error(100035, "文件与学号匹配异常");
|
||||
// 5.2、查询试题ID
|
||||
File folders = new File(files[0].getPath());
|
||||
File[] filess = folders.listFiles();
|
||||
if (filess == null) return CommonResult.error(100036, "4、试卷文件上传,目录不正确!");
|
||||
if (filess.length > 1) return CommonResult.error(100037, "5、试卷文件上传,目录不正确!");
|
||||
if (!filess[0].isDirectory()) return CommonResult.error(100038, "6、试卷文件上传,目录不正确!");
|
||||
// 判断学号是否正确
|
||||
if (!files[0].getName().equals(paperId)) return CommonResult.error(100039, "文件与试卷匹配异常");
|
||||
// 5.3、查询出来所有试题
|
||||
File qu_files = new File(filess[0].getPath());
|
||||
// 所有试题文件夹
|
||||
File[] filess_qu = qu_files.listFiles();
|
||||
if (filess_qu == null) return CommonResult.error(100040, "没有试题文件!");
|
||||
for (File file : filess_qu) {
|
||||
// 6、根据试题ID查询试题详情
|
||||
ExamQuestion examQuestion = examQuestionService.selectExamQuestionByQuId(file.getName());
|
||||
// 7、进行对应得判分
|
||||
// --- 7.1、查询试题文件
|
||||
File qu_file = new File(file.getPath());
|
||||
File[] qu_file_list = qu_files.listFiles();
|
||||
if (qu_file_list == null) continue;
|
||||
// --- 7.2、通过文件名称进行判分
|
||||
for (File file_one : qu_file_list) {
|
||||
// 判断名称 类似于 C语言程序设计。
|
||||
if (file_one.getName().split("\\.")[0].equals(examQuestion.getCourseName()+examQuestion.getSubjectName())) {
|
||||
double c_score = judgementService.ProgrammingC(15.0, file.getPath(), file_one.getName(), examQuestion);
|
||||
score += c_score;
|
||||
break;
|
||||
}
|
||||
// wps 类型存在多级文文件夹,需要个性化设置
|
||||
// if ()
|
||||
}
|
||||
}
|
||||
|
||||
return CommonResult.success(score);
|
||||
}
|
||||
}
|
||||
|
@@ -12,11 +12,12 @@ public interface JudgementService {
|
||||
/**
|
||||
* 程序设计判分
|
||||
* @param examQuestion 程序设计题内容
|
||||
* @param path 文件路径
|
||||
* @param fileName 文件名称
|
||||
* @param pathC 文件路径 C语言文件
|
||||
* @param score 分数
|
||||
* @return 返回判分
|
||||
*/
|
||||
public double ProgrammingC(double score, String path, ExamQuestion examQuestion);
|
||||
public double ProgrammingC(double score, String pathC, String fileName, ExamQuestion examQuestion);
|
||||
|
||||
|
||||
/**
|
||||
|
@@ -21,11 +21,11 @@ public class JudgementServiceImpl implements JudgementService
|
||||
/**
|
||||
* 程序设计判分
|
||||
* @param examQuestion 程序设计题内容
|
||||
* @param path 文件路径
|
||||
* @param fileName 文件名称
|
||||
* @param score 分数
|
||||
* @return 返回判分
|
||||
*/
|
||||
public double ProgrammingC(double score, String path, ExamQuestion examQuestion) {
|
||||
public double ProgrammingC(double score, String pathC, String fileName, ExamQuestion examQuestion) {
|
||||
|
||||
// 关键字比对,超过权重-测试用例/运行(测试用例全对,直接满分-不全对)-结果,不超过权重只给关键字几个的分
|
||||
// 获取该题有多少分
|
||||
@@ -61,11 +61,9 @@ public class JudgementServiceImpl implements JudgementService
|
||||
// 编译分数分数占比
|
||||
double pass_score = score * is_pass_score;
|
||||
|
||||
// 试卷其中有C语言的试题
|
||||
String path_c = path + "/" + examQuestion.getQuBankName();
|
||||
// 创建log文件txt,用于记录
|
||||
LogFileUtils.createFile(path_c + "/log.txt");
|
||||
String code = JudgementCUtils.readFile(path_c, examQuestion.getQuId()+".txt");
|
||||
LogFileUtils.createFile(pathC + "/log.txt");
|
||||
String code = JudgementCUtils.readFile(pathC, fileName);
|
||||
LogFileUtils.writeLine("✅ 系统开始读取文件:" + code);
|
||||
if (code == null) {
|
||||
// 如果没有读到源码
|
||||
|
@@ -2,8 +2,10 @@ package pc.exam.pp.module.judgement.service.wps_word;
|
||||
|
||||
|
||||
|
||||
import pc.exam.pp.module.exam.dal.dataobject.ExamQuestion;
|
||||
import pc.exam.pp.module.judgement.utils.wps_word.vo.WordVO;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -20,4 +22,14 @@ public interface JudgementWpsWordService {
|
||||
* @throws Exception 异常
|
||||
*/
|
||||
public List<WordVO> ProgrammingWpsWord(String path) throws Exception;
|
||||
|
||||
/**
|
||||
* 读取考生文件,与题型中要求进行判断
|
||||
* @param path 文件路径
|
||||
* @param examQuestion 试题参数
|
||||
* @param sorce 试题分数
|
||||
* @return 得分
|
||||
* @throws Exception 异常
|
||||
*/
|
||||
public BigDecimal judgementWpsWord(BigDecimal sorce, String path, ExamQuestion examQuestion) throws Exception;
|
||||
}
|
||||
|
@@ -4,6 +4,8 @@ package pc.exam.pp.module.judgement.service.wps_word;
|
||||
|
||||
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.infra.dal.dataobject.config.ConfigDO;
|
||||
import pc.exam.pp.module.infra.service.config.ConfigService;
|
||||
import pc.exam.pp.module.judgement.controller.admin.WpsWord.vo.WordListReqVO;
|
||||
@@ -14,6 +16,8 @@ import pc.exam.pp.module.judgement.utils.wps_word.WpsWordUtils;
|
||||
import pc.exam.pp.module.judgement.utils.wps_word.vo.WordVO;
|
||||
|
||||
import java.io.File;
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
@@ -46,5 +50,31 @@ public class JudgementWpsWordServiceImpl implements JudgementWpsWordService {
|
||||
return margins1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BigDecimal judgementWpsWord(BigDecimal sorce, String path, ExamQuestion examQuestion) throws Exception {
|
||||
BigDecimal wps_word_sorce = new BigDecimal(0);
|
||||
// 1、查询Word考点tree
|
||||
WordListReqVO wordListReqVO = new WordListReqVO();
|
||||
wordListReqVO.setBelongTo(0);
|
||||
List<WpsWordLinkDO> list = wpsWordLinkMapper.selectList(wordListReqVO);
|
||||
// 2、docx文件读取并返回考点及说明信息
|
||||
List<WordVO> margins1 = WpsWordUtils.wps_word(path, list);
|
||||
// 3、获取答案得组成
|
||||
List<ExamQuestionAnswer> answerList = examQuestion.getAnswerList();
|
||||
// 4、进行关联判断
|
||||
for (ExamQuestionAnswer examQuestionAnswer : answerList) {
|
||||
for (WordVO wordVO : margins1) {
|
||||
for (String str : wordVO.getExamKeynote()) {
|
||||
if (str.equals(examQuestionAnswer.getContent())) {
|
||||
// 得分 根据权重进行得分 每个选项分值 = 总分 / 总权重
|
||||
BigDecimal one_sorce = sorce.multiply(new BigDecimal(examQuestionAnswer.getScoreRate())).setScale(2, RoundingMode.HALF_UP);
|
||||
wps_word_sorce = wps_word_sorce.add(one_sorce);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return wps_word_sorce;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@@ -185,5 +185,5 @@ public interface ErrorCodeConstants {
|
||||
ErrorCode WORD_PARENT_IS_CHILD = new ErrorCode(1_002_030_007, "不能设置自己的子WORD节点为父WORD节点");
|
||||
|
||||
|
||||
ErrorCode MONITOR_NOT_EXISTS = new ErrorCode(1_003_301_001, "id为空");
|
||||
ErrorCode MONITOR_NOT_EXISTS = new ErrorCode(1_003_301_001, "找不到值!");
|
||||
}
|
||||
|
@@ -47,7 +47,7 @@ spring:
|
||||
primary: master
|
||||
datasource:
|
||||
master:
|
||||
url: jdbc:mysql://127.0.0.1:3306/pc-exam?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true&rewriteBatchedStatements=true # MySQL Connector/J 8.X 连接的示例
|
||||
url: jdbc:mysql://rm-bp1a44uap1mm20980mo.mysql.rds.aliyuncs.com:3306/pc-exam?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true&rewriteBatchedStatements=true # MySQL Connector/J 8.X 连接的示例
|
||||
# url: jdbc:mysql://127.0.0.1:3306/ruoyi-vue-pro?useSSL=true&allowPublicKeyRetrieval=true&useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&rewriteBatchedStatements=true # MySQL Connector/J 5.X 连接的示例
|
||||
# url: jdbc:postgresql://127.0.0.1:5432/ruoyi-vue-pro # PostgreSQL 连接的示例
|
||||
# url: jdbc:oracle:thin:@127.0.0.1:1521:xe # Oracle 连接的示例
|
||||
@@ -55,8 +55,8 @@ spring:
|
||||
# url: jdbc:dm://127.0.0.1:5236?schema=RUOYI_VUE_PRO # DM 连接的示例
|
||||
# url: jdbc:kingbase8://127.0.0.1:54321/test # 人大金仓 KingbaseES 连接的示例
|
||||
# url: jdbc:postgresql://127.0.0.1:5432/postgres # OpenGauss 连接的示例
|
||||
username: root
|
||||
password: 123
|
||||
username: pc_exam
|
||||
password: Pcexam123
|
||||
# username: sa # SQL Server 连接的示例
|
||||
# password: Exam@2024 # SQL Server 连接的示例
|
||||
# username: SYSDBA # DM 连接的示例
|
||||
|
Reference in New Issue
Block a user