【修改】表格修改项

This commit is contained in:
huababa1
2025-10-18 15:28:35 +08:00
parent a7fd185889
commit 24210dd1b7
42 changed files with 943 additions and 99 deletions

View File

@@ -78,7 +78,8 @@ public class AppCheckController {
appCheckDO.setTaskId(taskId);
appCheckDO.setAppName(exams.getRoles());
// 判断是否在数组中存在
boolean exists = appCheckDOList.contains(appCheckDO);
boolean exists = appCheckDOList.stream()
.anyMatch(a -> exams.getRoles().equals(a.getAppName())); // 根据 appName 判断
if (!exists) {
appCheckDOList.add(appCheckDO);
}

View File

@@ -57,6 +57,8 @@ public class MonitorPageReqVO extends PageParam {
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private LocalDateTime[] createTime;
@Schema(description = "更新时间")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private LocalDateTime[] updateTime;
}

View File

@@ -51,8 +51,11 @@ public class MonitorRespVO {
@ExcelProperty(value = "剩余时间", converter = SecondsToTimeConverter.class)
private String remainingTime;
private LocalDateTime createTime;
private LocalDateTime updateTime;
@ExcelProperty("开始时间")
private String startTime;

View File

@@ -1,6 +1,7 @@
package pc.exam.pp.module.exam.controller.admin.paper;
import cn.hutool.core.bean.BeanUtil;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.security.PermitAll;
@@ -22,6 +23,8 @@ import pc.exam.pp.module.exam.service.paper.IEducationPaperTaskService;
import static pc.exam.pp.framework.common.exception.enums.GlobalErrorCodeConstants.INTERNAL_SERVER_ERROR;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
@@ -46,7 +49,15 @@ public class EducationPaperTaskController {
PageResult<EducationPaperTask> pageResult = educationPaperTaskService.selectEducationPaperTaskList(educationPaperTask);
return CommonResult.success(BeanUtils.toBean(pageResult, EducationPaperTask.class));
}
/**
* 查询试卷任务列表(服务器端)
*/
@Operation(summary = "查询试卷任务列表(服务器端)")
@GetMapping("/listMoBan")
public CommonResult<PageResult<EducationPaperTask>> listMoBan(PaperTaskPageVo educationPaperTask) {
PageResult<EducationPaperTask> pageResult = educationPaperTaskService.selectEducationPaperTaskListlistMoBan(educationPaperTask);
return CommonResult.success(BeanUtils.toBean(pageResult, EducationPaperTask.class));
}
@Operation(summary = "查询试卷任务列表(带试卷)")
@GetMapping("/listPaper")
public CommonResult<PageResult<EducationPaperTask>> taskAndPaperlist(PaperTaskPageVo educationPaperTask) {
@@ -59,9 +70,18 @@ public class EducationPaperTaskController {
*/
@Operation(summary = "查询试卷任务列表(学生端)")
@GetMapping("/stulist")
public CommonResult<PageResult<EducationPaperTask>> stulist(PaperTaskPageVo educationPaperTask) {
public CommonResult<PageResult<Map<String, Object>>> stulist(PaperTaskPageVo educationPaperTask) {
PageResult<EducationPaperTask> pageResult = educationPaperTaskService.selectEducationPaperTaskListByStu(educationPaperTask);
return CommonResult.success(BeanUtils.toBean(pageResult, EducationPaperTask.class));
List<Map<String, Object>> newList = pageResult.getList().stream()
.map(task -> {
Map<String, Object> map = BeanUtil.beanToMap(task, false, true);
map.put("status", task.getStatus() == null ? "" : String.valueOf(task.getStatus()));
return map;
})
.collect(Collectors.toList());
PageResult<Map<String, Object>> newPage = new PageResult<>(newList, pageResult.getTotal());
return CommonResult.success(newPage);
}

View File

@@ -43,6 +43,7 @@ public class PaperTaskPageVo extends PageParam {
private String status;
private String creator;
@Schema(description = "创建时间", example = "[2022-07-01 00:00:00, 2022-07-01 23:59:59]")

View File

@@ -171,7 +171,8 @@ public class ExamSpecialtyController {
public CommonResult getRole(@PathVariable("id") String id) {
String roles = examSpecialtyService.getRoleById(id);
if (roles != null) {
return success(Integer.parseInt(roles));
// return success(Integer.parseInt(roles));
return success(roles);
}
return success("");
}

View File

@@ -0,0 +1,129 @@
package pc.exam.pp.module.exam.dal.dataobject;
import com.baomidou.mybatisplus.annotation.KeySequence;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler;
import lombok.*;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import pc.exam.pp.framework.common.enums.CommonStatusEnum;
import pc.exam.pp.framework.tenant.core.db.TenantBaseDO;
import pc.exam.pp.module.system.enums.common.SexEnum;
import java.time.LocalDateTime;
import java.util.Set;
/**
* 管理后台的用户 DO
*
* @author 朋辰
*/
@TableName(value = "system_users", autoResultMap = true) // 由于 SQL Server 的 system_user 是关键字,所以使用 system_users
@KeySequence("system_users_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
@Data
@EqualsAndHashCode(callSuper = true)
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class AdminUser extends TenantBaseDO {
/**
* 用户ID
*/
@TableId
private Long id;
/**
* 用户账号
*/
private String username;
/**
* 加密后的密码
*
* 因为目前使用 {@link BCryptPasswordEncoder} 加密器,所以无需自己处理 salt 盐
*/
private String password;
/**
* 身份证
*/
private String sfz;
/**
* 用户昵称
*/
private String nickname;
/**
* 学校名称
*/
private String schoolName;
/**
* 备注
*/
private String remark;
/**
* 部门 ID
*/
private Long deptId;
/**
* 班级 ID
*/
private Long classId;
/**
* 岗位编号数组
*/
@TableField(typeHandler = JacksonTypeHandler.class)
private Set<Long> postIds;
/**
* 班级编号数组
*/
@TableField(typeHandler = JacksonTypeHandler.class)
private Set<Long> classIds;
/**
* 专业编号数组
*/
@TableField(typeHandler = JacksonTypeHandler.class)
private Set<Long> specialtyIds;
/**
* 用户类型
*/
private String userType;
/**
* 用户邮箱
*/
private String email;
/**
* 手机号码
*/
private String mobile;
/**
* 用户性别
*
* 枚举类 {@link SexEnum}
*/
private Integer sex;
/**
* 用户头像
*/
private String avatar;
/**
* 帐号状态
*
* 枚举 {@link CommonStatusEnum}
*/
private Integer status;
/**
* 最后登录IP
*/
private String loginIp;
/**
* 最后登录时间
*/
private LocalDateTime loginDate;
private String queueName;
}

View File

@@ -46,6 +46,8 @@ public class EducationPaperTask extends TenantBaseDO
private String taskType;
private String isOne;
/** 是否共享 */
private Integer share;
/** 是否为模板 */
//@Excel(name = "是否为模板")

View File

@@ -0,0 +1,24 @@
package pc.exam.pp.module.exam.dal.dataobject;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.*;
@TableName(value = "exam_tenant_specialty")
@Data
@ToString(callSuper = true)
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class TenantSpcialty {
@TableId(value = "id")
private Long id;
private Long tenantId;
private Long specialtyId;
private String points;
}

View File

@@ -49,10 +49,28 @@ public interface EducationPaperTaskMapper extends BaseMapperX<EducationPaperTask
.likeIfPresent(EducationPaperTask::getTaskSpecialty , pageReqVO.getTaskSpecialty())
.likeIfPresent(EducationPaperTask::getIsTemplate , pageReqVO.getIsTemplate())
.betweenIfPresent(EducationPaperTask::getCreateTime, pageReqVO.getCreateTime())
.and(wrapper ->
wrapper
// 自己创建的
.eq(EducationPaperTask::getCreator, pageReqVO.getCreator())
// 或者被共享的share=0
.or()
.eq(EducationPaperTask::getShare, 0)
)
);
}
default PageResult<EducationPaperTask> selectEducationPaperTaskStuList(PaperTaskPageVo pageReqVO) {
return selectPage(pageReqVO, new LambdaQueryWrapperX<EducationPaperTask>()
.likeIfPresent(EducationPaperTask::getTaskType, pageReqVO.getTaskType())
.likeIfPresent(EducationPaperTask::getTaskName , pageReqVO.getTaskName())
.likeIfPresent(EducationPaperTask::getStatus , pageReqVO.getStatus())
.likeIfPresent(EducationPaperTask::getTaskNum , pageReqVO.getTaskNum())
.likeIfPresent(EducationPaperTask::getTaskSpecialty , pageReqVO.getTaskSpecialty())
.likeIfPresent(EducationPaperTask::getIsTemplate , pageReqVO.getIsTemplate())
.betweenIfPresent(EducationPaperTask::getCreateTime, pageReqVO.getCreateTime())
);
}
/**
* 新增试卷任务
*
@@ -171,6 +189,14 @@ public interface EducationPaperTaskMapper extends BaseMapperX<EducationPaperTask
.likeIfPresent(EducationPaperTask::getTaskSpecialty , pageReqVO.getTaskSpecialty())
.likeIfPresent(EducationPaperTask::getIsTemplate , pageReqVO.getIsTemplate())
.betweenIfPresent(EducationPaperTask::getCreateTime, pageReqVO.getCreateTime())
.and(wrapper ->
wrapper
// 自己创建的
.eq(EducationPaperTask::getCreator, pageReqVO.getCreator())
// 或者被共享的share=1
.or()
.eq(EducationPaperTask::getShare, 0)
)
).getTotal();
}

View File

@@ -7,6 +7,8 @@ import pc.exam.pp.framework.mybatis.core.mapper.BaseMapperX;
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.controller.admin.specialty.vo.TenantSpcialtyVo;
import pc.exam.pp.module.exam.dal.dataobject.AdminUser;
import pc.exam.pp.module.exam.dal.dataobject.TenantSpcialty;
import pc.exam.pp.module.exam.dal.dataobject.knowledge.ExamKnowledgePoints;
import pc.exam.pp.module.exam.dal.dataobject.monitor.TentSpecialy;
import pc.exam.pp.module.exam.dal.dataobject.specialty.ExamSpecialty;
@@ -145,4 +147,7 @@ public interface ExamSpecialtyMapper extends BaseMapperX<ExamSpecialty> {
List<IdParentPair> selectAllIdToParent(Long loginTenantId);
List<TenantSpcialty> getSpecialtyPoints(Long tenantId);
AdminUser selectUserById(Long id);
}

View File

@@ -125,8 +125,8 @@ public class MonitorServiceImpl implements MonitorService {
public PageResult<MonitorDO> getMonitorPage(MonitorPageReqVO pageReqVO) {
PageResult<MonitorDO> page = monitorMapper.selectPage(pageReqVO);
page.getList().forEach(monitor -> {
// 获取考试状态
if (!monitor.getExamStatus().equals("0")) {
// 获取考试状态,结束的考试 starttime归零了这里只取正在考试的时间
if ("1".equals(monitor.getExamStatus())) {
String startTime = monitor.getStartTime();
LocalDateTime nowTime = LocalDateTime.now();
LocalDateTime endTime = LocalDateTime.parse(startTime, DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));

View File

@@ -6,6 +6,7 @@ import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;
import pc.exam.pp.framework.common.pojo.PageResult;
import pc.exam.pp.framework.security.core.util.SecurityFrameworkUtils;
import pc.exam.pp.module.exam.controller.admin.monitor.vo.MonitorPageReqVO;
import pc.exam.pp.module.exam.controller.admin.paper.vo.PaperTaskPageVo;
import pc.exam.pp.module.exam.dal.dataobject.EducationPaper;
@@ -40,7 +41,9 @@ public class MonitorTaskServiceImpl implements MonitorTaskService{
private EducationPaperQuMapper educationPaperQuMapper;
@Override
public PageResult<MonitorTaskDO> getMonitorPage(PaperTaskPageVo pageReqVO) {
//获取创建人
Long loginUserId = SecurityFrameworkUtils.getLoginUserId();
pageReqVO.setCreator(String.valueOf(loginUserId));
PageResult<EducationPaperTask> educationPaperTasks = educationPaperTaskMapper.selectEducationPaperTaskList(pageReqVO);
long total= educationPaperTaskMapper.selectEducationPaperTaskTotal(pageReqVO);
List<EducationPaperTask> list = educationPaperTasks.getList();

View File

@@ -1,10 +1,16 @@
package pc.exam.pp.module.exam.service.paper;
import jakarta.annotation.Resource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import pc.exam.pp.module.exam.dal.dataobject.EducationPaperScheme;
import pc.exam.pp.module.exam.dal.dataobject.app.AppCheckDO;
import pc.exam.pp.module.exam.dal.dataobject.specialty.ExamSpecialty;
import pc.exam.pp.module.exam.dal.mysql.paper.EducationPaperSchemeMapper;
import pc.exam.pp.module.exam.dal.mysql.specialty.ExamSpecialtyMapper;
import pc.exam.pp.module.exam.service.app.AppCheckService;
import pc.exam.pp.module.exam.service.specialty.ExamSpecialtyService;
import pc.exam.pp.module.exam.utils.uuid.IdUtils;
import java.util.List;
@@ -20,7 +26,10 @@ import java.util.stream.Collectors;
public class EducationPaperSchemeServiceImpl implements IEducationPaperSchemeService {
@Autowired
private EducationPaperSchemeMapper educationPaperSchemeMapper;
@Autowired
private ExamSpecialtyMapper examSpecialtyMapper;
@Resource
AppCheckService appCheckService;
/**
* 查询试卷方案
*
@@ -68,6 +77,25 @@ public class EducationPaperSchemeServiceImpl implements IEducationPaperSchemeSer
educationPaperScheme.setKeywords(keywordStr);
educationPaperScheme.setPointNames(pointNameStr);
List<AppCheckDO> appCheckDOList = appCheckService.getAppList(educationPaperScheme.getTaskId());
// 根据题型名称查询软件环境
List<ExamSpecialty> examSpecialty = examSpecialtyMapper.selectExamSpecialtyBySpName(educationPaperScheme.getSpName());
if (examSpecialty != null && !examSpecialty.isEmpty()) {
ExamSpecialty exams = examSpecialty.get(0);
if (exams.getRoles() != null && !exams.getRoles().isEmpty()) {
// 判断是否在数组中存在
boolean exists = appCheckDOList.stream()
.anyMatch(a -> exams.getRoles().equals(a.getAppName())); // 根据 appName 判断
if (!exists) {
AppCheckDO appCheckDO = new AppCheckDO();
appCheckDO.setTaskId(educationPaperScheme.getTaskId());
appCheckDO.setAppName(exams.getRoles());
appCheckService.insertAppCheck(appCheckDO);
}
}
}
// 然后插入到数据库
return educationPaperSchemeMapper.insertEducationPaperScheme(educationPaperScheme);

View File

@@ -163,6 +163,8 @@ public class EducationPaperServiceImpl implements IEducationPaperService
public int addPaperList(Integer num, String taskid,String taskSpecialty) {
//根据试卷任务id查找方案集合
List<EducationPaperScheme> educationPaperSchemeList= educationPaperSchemeMapper.selectEducationPaperTaskByTaskId(taskid);
//根据任务查找任务里面是否有试卷,如果没有给新创建的试卷 抽卷方式为 随机
List<EducationPaper> educationPapers = educationPaperMapper.selectPaperListByTaskId(taskid);
for (int i = 0; i <num ; i++) {
List<String> examQuestionIds = new ArrayList<>();
int totalScore = 0;
@@ -211,8 +213,6 @@ public class EducationPaperServiceImpl implements IEducationPaperService
// 格式化为8位不足前面补0
String formattedNumber = String.format("%08d", ++number);
//根据任务查找任务里面是否有试卷,如果没有给新创建的试卷 抽卷方式为 随机
List<EducationPaper> educationPapers = educationPaperMapper.selectPaperListByTaskId(taskid);
//构建试卷

View File

@@ -60,6 +60,12 @@ public class EducationPaperSessionServiceImpl implements IEducationPaperSessionS
{
String uuid = IdUtils.simpleUUID();
educationPaperSession.setSessionId(uuid);
List<EducationPaperSession> educationPaperSessions = educationPaperSessionMapper.selectEducationPaperSessionByTaskId(educationPaperSession.getTaskId());
int size = educationPaperSessions.size()+1;
String batch= ""+size+"";
educationPaperSession.setBatch(batch);
return educationPaperSessionMapper.insertEducationPaperSession(educationPaperSession);
}

View File

@@ -1,7 +1,9 @@
package pc.exam.pp.module.exam.service.paper;
import cn.hutool.core.collection.CollUtil;
import com.alibaba.excel.util.StringUtils;
import jakarta.annotation.Resource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@@ -9,6 +11,7 @@ import pc.exam.pp.framework.common.pojo.PageResult;
import pc.exam.pp.framework.security.core.util.SecurityFrameworkUtils;
import pc.exam.pp.framework.tenant.core.aop.TenantIgnore;
import pc.exam.pp.framework.tenant.core.context.TenantContextHolder;
import pc.exam.pp.framework.web.core.util.WebFrameworkUtils;
import pc.exam.pp.module.exam.controller.admin.exception.QueTypeException;
import pc.exam.pp.module.exam.controller.admin.paper.dto.PaperQueUpdateDTO;
import pc.exam.pp.module.exam.controller.admin.paper.dto.SchemeParam;
@@ -16,11 +19,16 @@ import pc.exam.pp.module.exam.controller.admin.paper.dto.TempDto;
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.controller.admin.specialty.vo.SpecialtyQueryVo;
import pc.exam.pp.module.exam.dal.dataobject.*;
import pc.exam.pp.module.exam.dal.dataobject.app.AppCheckDO;
import pc.exam.pp.module.exam.dal.dataobject.specialty.ExamSpecialty;
import pc.exam.pp.module.exam.dal.mysql.app.AppCheckMapper;
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.ExamQuestionFileMapper;
import pc.exam.pp.module.exam.dal.mysql.specialty.ExamSpecialtyMapper;
import pc.exam.pp.module.exam.utils.date.DateUtils;
import pc.exam.pp.module.exam.utils.uuid.IdUtils;
@@ -31,6 +39,8 @@ import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;
import static pc.exam.pp.framework.common.util.collection.CollectionUtils.convertSet;
/**
* 试卷任务Service业务层处理
*
@@ -65,9 +75,12 @@ public class EducationPaperTaskServiceImpl implements IEducationPaperTaskService
private MonitorMapper monitorMapper;
//@Autowired
//private ExamQuestionMapper
@Resource
private ExamSpecialtyMapper examSpecialtyMapper;
@Autowired
private ExamQuestionMapper examQuestionMapper;
@Resource
AppCheckMapper appCheckMapper;
/**
* 查询试卷任务
@@ -88,6 +101,9 @@ public class EducationPaperTaskServiceImpl implements IEducationPaperTaskService
*/
@Override
public PageResult<EducationPaperTask> selectEducationPaperTaskList(PaperTaskPageVo educationPaperTask) {
//获取创建人
Long loginUserId = SecurityFrameworkUtils.getLoginUserId();
educationPaperTask.setCreator(String.valueOf(loginUserId));
PageResult<EducationPaperTask> educationPaperTasks = educationPaperTaskMapper.selectEducationPaperTaskList(educationPaperTask);
List<EducationPaperTask> list = educationPaperTasks.getList();
if (list != null && list.size() > 0) {
@@ -144,7 +160,6 @@ public class EducationPaperTaskServiceImpl implements IEducationPaperTaskService
educationPaperParam.setIsConnect("0");
educationPaperParam.setIsAnswerId("1");
educationPaperParam.setIsTime("0");
educationPaperParam.setIsDelete("0");
educationPaperParam.setDirectory("KSWJ");
educationPaperParam.setUploadTime("5");
educationPaperParam.setIsCopy("1");
@@ -161,7 +176,9 @@ public class EducationPaperTaskServiceImpl implements IEducationPaperTaskService
educationPaperParam.setIsConnect("30");
educationPaperParam.setIsScore("1");
educationPaperParam.setIsScoreDetail("1");
educationPaperParam.setIsDelete("1");
} else {
educationPaperParam.setIsDelete("0");
educationPaperParam.setIsRepeat("0");
educationPaperParam.setIsAnswer("0");
educationPaperParam.setIsLook("0");
@@ -176,7 +193,7 @@ public class EducationPaperTaskServiceImpl implements IEducationPaperTaskService
// 新增任务参数
educationPaperParamMapper.insertEducationPaperParam(educationPaperParam);
// 新增任务
return educationPaperTaskMapper.insertEducationPaperTask(educationPaperTask);
return educationPaperTaskMapper.insert(educationPaperTask);
}
/**
@@ -326,7 +343,122 @@ public class EducationPaperTaskServiceImpl implements IEducationPaperTaskService
@Override
public List<String> getCourseList() {
return educationPaperTaskMapper.getCourseList();
Long userId = WebFrameworkUtils.getLoginUserId();
// 获取考点ID
Long tenantId = TenantContextHolder.getTenantId();
AdminUser adminUserDO = getUser(userId);
List<SpecialtyQueryVo> specialtyQueryVos = new ArrayList<>();
// 判断是否是中心服务器,如果是中心服务器的话直接返回所有,如果不是查询对应的授权数据
if (tenantId == 1) {
// 判断用户类型 管理员所有专业
if (adminUserDO.getUserType().equals("0")) {
// 查询所有专业数据
specialtyQueryVos = examSpecialtyMapper.selectExamSpecialtyAll();
} else {
// 判断专业是否为空,为空的话查询所有
if (adminUserDO.getSpecialtyIds() == null) {
// 查询所有数据
specialtyQueryVos = examSpecialtyMapper.selectExamSpecialtyAll();
} else {
// 查询部分数据
specialtyQueryVos = examSpecialtyMapper.selectExamSpecialtyByids(adminUserDO.getSpecialtyIds());
}
}
} else {
// 需要先界定 数据范围通过考点服务器ID进行查询考点服务器的授权范围
List<TenantSpcialty> tenantSpcialtyDOS = examSpecialtyMapper.getSpecialtyPoints(tenantId);
// 通过ID查询对应的科目信息
for (TenantSpcialty spcialtyDO : tenantSpcialtyDOS) {
ExamSpecialty examSpecialty = examSpecialtyMapper.selectExamSpecialtyBySpId(spcialtyDO.getSpecialtyId());
// 获取对应的父级参数
ExamSpecialty examSpecialtyForUp = examSpecialtyMapper.selectExamSpecialtyBySpId(examSpecialty.getParentId());
if (examSpecialty.getParentId() == 0) {
// 说明是整个专业下面所有的
List<ExamSpecialty> examSpecialties = getChildExamSpecialtyList(Collections.singleton(examSpecialtyForUp.getSpId()));
for (ExamSpecialty examSpecialtyInfo : examSpecialties) {
// 检查是否已存在相同ID的元素
boolean exists = specialtyQueryVos.stream()
.anyMatch(v -> v.getId().equals(examSpecialtyInfo.getSpId()));
if (!exists) {
SpecialtyQueryVo specialtyQueryVo = new SpecialtyQueryVo();
specialtyQueryVo.setStatus(examSpecialtyInfo.getStatus());
specialtyQueryVo.setName(examSpecialtyInfo.getSpName());
specialtyQueryVo.setAncestors(examSpecialtyInfo.getAncestors());
specialtyQueryVo.setOrderNum(examSpecialtyInfo.getOrderNum());
specialtyQueryVo.setId(examSpecialtyInfo.getSpId());
specialtyQueryVo.setRoles(examSpecialtyInfo.getRoles());
specialtyQueryVo.setParentId(examSpecialtyInfo.getParentId());
specialtyQueryVo.setAncestors(examSpecialtyInfo.getAncestors());
specialtyQueryVos.add(specialtyQueryVo);
}
}
} else {
// 检查是否已存在相同ID的元素
boolean exists = specialtyQueryVos.stream()
.anyMatch(v -> v.getId().equals(examSpecialty.getSpId()));
if (!exists) {
SpecialtyQueryVo specialtyQueryVo = new SpecialtyQueryVo();
specialtyQueryVo.setStatus(examSpecialty.getStatus());
specialtyQueryVo.setName(examSpecialty.getSpName());
specialtyQueryVo.setAncestors(examSpecialty.getAncestors());
specialtyQueryVo.setOrderNum(examSpecialty.getOrderNum());
specialtyQueryVo.setId(examSpecialty.getSpId());
specialtyQueryVo.setRoles(examSpecialty.getRoles());
specialtyQueryVo.setParentId(examSpecialty.getParentId());
specialtyQueryVo.setAncestors(examSpecialty.getAncestors());
specialtyQueryVos.add(specialtyQueryVo);
}
boolean existsUp = specialtyQueryVos.stream()
.anyMatch(v -> v.getId().equals(examSpecialtyForUp.getSpId()));
if (!existsUp) {
SpecialtyQueryVo specialtyQueryVo = new SpecialtyQueryVo();
specialtyQueryVo.setStatus(examSpecialtyForUp.getStatus());
specialtyQueryVo.setName(examSpecialtyForUp.getSpName());
specialtyQueryVo.setAncestors(examSpecialtyForUp.getAncestors());
specialtyQueryVo.setOrderNum(examSpecialtyForUp.getOrderNum());
specialtyQueryVo.setId(examSpecialtyForUp.getSpId());
specialtyQueryVo.setRoles(examSpecialtyForUp.getRoles());
specialtyQueryVo.setParentId(examSpecialtyForUp.getParentId());
specialtyQueryVo.setAncestors(examSpecialtyForUp.getAncestors());
specialtyQueryVos.add(specialtyQueryVo);
}
List<ExamSpecialty> examSpecialties = getChildExamSpecialtyList(Collections.singleton(examSpecialty.getSpId()));
for (ExamSpecialty examSpecialtyInfo : examSpecialties) {
// 检查是否已存在相同ID的元素
boolean existsDown = specialtyQueryVos.stream()
.anyMatch(v -> v.getId().equals(examSpecialtyInfo.getSpId()));
if (!existsDown) {
SpecialtyQueryVo specialtyQueryVo = new SpecialtyQueryVo();
specialtyQueryVo.setStatus(examSpecialtyInfo.getStatus());
specialtyQueryVo.setName(examSpecialtyInfo.getSpName());
specialtyQueryVo.setAncestors(examSpecialtyInfo.getAncestors());
specialtyQueryVo.setOrderNum(examSpecialtyInfo.getOrderNum());
specialtyQueryVo.setId(examSpecialtyInfo.getSpId());
specialtyQueryVo.setRoles(examSpecialtyInfo.getRoles());
specialtyQueryVo.setParentId(examSpecialtyInfo.getParentId());
specialtyQueryVo.setAncestors(examSpecialtyInfo.getAncestors());
specialtyQueryVos.add(specialtyQueryVo);
}
}
}
}
// 通过ID查询下面的参数
// 判断用户类型 管理员所有专业 , 不是管理员的话需要筛选
if (!adminUserDO.getUserType().equals("0")) {
// 判断专业是否为空,为空的话查询所有
if (adminUserDO.getSpecialtyIds() == null) {
// 查询所有数据
specialtyQueryVos = examSpecialtyMapper.selectExamSpecialtyAll();
} else {
// 查询部分数据
specialtyQueryVos = examSpecialtyMapper.selectExamSpecialtyByids(adminUserDO.getSpecialtyIds());
}
}
}
List<String> courseNames = getThirdLevelNames(specialtyQueryVos);
return courseNames;
}
@Override
@@ -405,7 +537,7 @@ public class EducationPaperTaskServiceImpl implements IEducationPaperTaskService
// 格式化时间为字符串
String timeString = now.format(formatter);
educationPaperTask.setTaskName(educationPaperTask.getTaskName() + timeString);
educationPaperTask.setCreateTime(now);
educationPaperTask.setIsTemplate(1);
educationPaperTaskMapper.insertEducationPaperTask(educationPaperTask);
@@ -419,6 +551,17 @@ public class EducationPaperTaskServiceImpl implements IEducationPaperTaskService
educationPaperSchemeList.forEach(scheme -> scheme.setTaskId(newtaskId));
//构建新方案
educationPaperSchemeMapper.insertEducationPaperSchemeList(educationPaperSchemeList);
List<AppCheckDO> appCheckDOList = new ArrayList<>();
List<AppCheckDO> appCheckDOS = appCheckMapper.selectList(taskId);
if (appCheckDOS!=null&&appCheckDOS.size()>0){
for (AppCheckDO appCheckDO : appCheckDOS) {
AppCheckDO newAppCheckDO = new AppCheckDO();
newAppCheckDO.setTaskId(newtaskId);
newAppCheckDO.setAppName(appCheckDO.getAppName());
appCheckDOList.add(newAppCheckDO);
}
appCheckMapper.insert(appCheckDOList);
}
}
@@ -464,6 +607,18 @@ public class EducationPaperTaskServiceImpl implements IEducationPaperTaskService
EducationPaperParam educationPaperParam = educationPaperParamMapper.selectEducationPaperParamByTaskId(taskId);
educationPaperParam.setTaskId(newtaskId);
educationPaperParam.setParamId(IdUtils.simpleUUID());
//考试不删除学生文件
String taskType = educationPaperTask.getTaskType();
if ("1".equals(taskType)){
educationPaperParam.setIsDelete("1");
educationPaperParam.setIsRepeat("1");
educationPaperParam.setIsAnswer("1");
educationPaperParam.setIsLook("1");
educationPaperParam.setIsConnect("30");
educationPaperParam.setIsScore("1");
educationPaperParam.setIsScoreDetail("1");
educationPaperParam.setIsDelete("1");
}
educationPaperParamMapper.insertEducationPaperParam(educationPaperParam);
}
@@ -618,7 +773,7 @@ public class EducationPaperTaskServiceImpl implements IEducationPaperTaskService
public PageResult<EducationPaperTask> selectEducationPaperTaskListByStu(PaperTaskPageVo educationPaperTask) {
String taskType = educationPaperTask.getTaskType();
PageResult<EducationPaperTask> educationPaperTasks = educationPaperTaskMapper.selectEducationPaperTaskList(educationPaperTask);
PageResult<EducationPaperTask> educationPaperTasks = educationPaperTaskMapper.selectEducationPaperTaskStuList(educationPaperTask);
Long stuId = SecurityFrameworkUtils.getLoginUserId();
List<EducationPaperTask> list = educationPaperTasks.getList();
List<String> taskIds = educationPaperPersonMapper.selectTaskIdByStuid(stuId);
@@ -671,11 +826,12 @@ public class EducationPaperTaskServiceImpl implements IEducationPaperTaskService
//查找 考试状态还没结束的 任务id ,取 交集
List<String> taskNoEndIds = monitorMapper.selectByStuIdAndTaskId(stuId);
if (taskType.equals("1")) {
if ("1".equals(taskType)) {
if (list != null && list.size() > 0 && taskNoEndIds != null && taskNoEndIds.size() > 0) {
list = list.stream()
.filter(task -> taskNoEndIds.contains(task.getTaskId()))
.collect(Collectors.toList());
}
}
@@ -729,4 +885,95 @@ public class EducationPaperTaskServiceImpl implements IEducationPaperTaskService
}
}
@Override
public PageResult<EducationPaperTask> selectEducationPaperTaskListlistMoBan(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));
EducationPaperParam educationPaperParam = educationPaperParamMapper.selectEducationPaperParamByTaskId(paperTask.getTaskId());
paperTask.setEducationPaperParam(educationPaperParam);
}
}
return educationPaperTasks;
}
public List<ExamSpecialty> getChildExamSpecialtyList(Collection<Long> ids) {
List<ExamSpecialty> children = new LinkedList<>();
// 遍历每一层
Collection<Long> parentIds = ids;
for (int i = 0; i < Short.MAX_VALUE; i++) { // 使用 Short.MAX_VALUE 避免 bug 场景下,存在死循环
// 查询当前层所有的子Xlsx考点
List<ExamSpecialty> Xlsxs = examSpecialtyMapper.selectListByParentId(parentIds);
// 1. 如果没有子Xlsx考点则结束遍历
if (CollUtil.isEmpty(Xlsxs)) {
break;
}
// 2. 如果有子Xlsx考点继续遍历
children.addAll(Xlsxs);
parentIds = convertSet(Xlsxs, ExamSpecialty::getSpId);
}
return children;
}
public static List<String> getThirdLevelNames(List<SpecialtyQueryVo> list) {
// ✅ 判空
if (list == null || list.isEmpty()) {
return Collections.emptyList();
}
// 第1层专业parentId = 0
Set<Long> level1Ids = list.stream()
.filter(Objects::nonNull)
.filter(item -> item.getParentId() != null && item.getParentId() == 0)
.map(SpecialtyQueryVo::getId)
.filter(Objects::nonNull)
.collect(Collectors.toSet());
if (level1Ids.isEmpty()) {
return Collections.emptyList();
}
// 第2层课程父节点是专业
Set<Long> level2Ids = list.stream()
.filter(Objects::nonNull)
.filter(item -> item.getParentId() != null && level1Ids.contains(item.getParentId()))
.map(SpecialtyQueryVo::getId)
.filter(Objects::nonNull)
.collect(Collectors.toSet());
if (level2Ids.isEmpty()) {
return Collections.emptyList();
}
// 第3层题型父节点是课程
return list.stream()
.filter(Objects::nonNull)
.filter(item -> item.getParentId() != null && level2Ids.contains(item.getParentId()))
.map(SpecialtyQueryVo::getName) // ✅ 只返回 name
.filter(Objects::nonNull)
.distinct() // 去重(可选)
.collect(Collectors.toList());
}
public AdminUser getUser(Long id) {
return examSpecialtyMapper.selectUserById(id);
}
}

View File

@@ -119,5 +119,7 @@ public interface IEducationPaperTaskService
void checkType(PaperQueUpdateDTO dto);
PageResult<EducationPaperTask> selectEducationPaperTaskListlistMoBan(PaperTaskPageVo educationPaperTask);
}

View File

@@ -31,6 +31,7 @@
<select id="selectEducationPaperSessionByTaskId" resultMap="EducationPaperSessionResult">
<include refid="selectEducationPaperSessionVo"/>
where task_id =#{taskId}
and status = '0'
</select>
<select id="getAnswerTime" resultType="java.sql.Time">
select exam_time from education_paper_param where task_id =#{taskId}

View File

@@ -11,6 +11,7 @@
<result property="taskSpecialty" column="task_specialty" />
<result property="taskType" column="task_type" />
<result property="isOne" column="is_one" />
<result property="share" column="share" />
<result property="isTemplate" column="is_template" />
<result property="status" column="status" />
<result property="createTime" column="create_time" />
@@ -31,7 +32,7 @@
<result property="treeNum" column="tree_num" />
</resultMap>
<sql id="selectEducationPaperTaskVo">
select task_id, task_name,task_num, task_specialty, task_type,is_one, is_template, status, create_time, update_time, creator, updater, deleted,tenant_id from education_paper_task
select task_id, task_name,task_num, task_specialty, task_type,is_one, is_template, status,share, create_time, update_time, creator, updater, deleted,tenant_id from education_paper_task
</sql>
@@ -215,6 +216,7 @@
<if test="taskSpecialty != null">task_specialty,</if>
<if test="taskType != null">task_type,</if>
<if test="isOne != null">is_one,</if>
<if test="share != null">share,</if>
<if test="isTemplate != null">is_template,</if>
<if test="status != null">status,</if>
<if test="createTime != null">create_time,</if>
@@ -231,6 +233,7 @@
<if test="taskSpecialty != null">#{taskSpecialty},</if>
<if test="taskType != null">#{taskType},</if>
<if test="isOne != null">#{isOne},</if>
<if test="share != null">#{share},</if>
<if test="isTemplate != null">#{isTemplate},</if>
<if test="status != null">#{status},</if>
<if test="createTime != null">#{createTime},</if>
@@ -250,6 +253,7 @@
<if test="taskSpecialty != null">task_specialty = #{taskSpecialty},</if>
<if test="taskType != null">task_type = #{taskType},</if>
<if test="isOne != null">is_one = #{isOne},</if>
<if test="share != null">share = #{share},</if>
<if test="isTemplate != null">is_template = #{isTemplate},</if>
<if test="status != null">status = #{status},</if>
<if test="createTime != null">create_time = #{createTime},</if>

View File

@@ -73,7 +73,6 @@
where stu_id =#{stuId}
and task_id = #{taskId}
and deleted = '0'
and exam_status = '0'
</select>

View File

@@ -194,6 +194,16 @@
and status = '0'
and tenant_id = #{loginTenantId}
</select>
<select id="getSpecialtyPoints" resultType="pc.exam.pp.module.exam.dal.dataobject.TenantSpcialty">
SELECT *
FROM exam_tenant_specialty
WHERE tenant_id = #{tenantId}
</select>
<select id="selectUserById" resultType="pc.exam.pp.module.exam.dal.dataobject.AdminUser">
SELECT *
FROM system_users
WHERE id = #{id}
</select>
<update id="deleteExamSpecialtyBySpId" parameterType="Long">