Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
邬吉朋
practical_train
Commits
66392f2e
Commit
66392f2e
authored
Sep 15, 2026
by
wujipeng
Browse files
bug修复
parent
4e10634c
Changes
46
Expand all
Hide whitespace changes
Inline
Side-by-side
practical-business/src/main/java/com/platform/business/mapper/ExamTeacherAssignmentMapper.java
0 → 100644
View file @
66392f2e
package
com.platform.business.mapper
;
import
com.baomidou.mybatisplus.core.mapper.BaseMapper
;
import
com.platform.business.model.entity.ExamTeacherAssignmentEntity
;
import
org.apache.ibatis.annotations.Mapper
;
import
org.apache.ibatis.annotations.Param
;
import
java.util.List
;
/** 考试教师多角色关系数据访问层。 */
@Mapper
public
interface
ExamTeacherAssignmentMapper
extends
BaseMapper
<
ExamTeacherAssignmentEntity
>
{
int
insertBatch
(
@Param
(
"assignments"
)
List
<
ExamTeacherAssignmentEntity
>
assignments
);
int
deleteByExamId
(
@Param
(
"examId"
)
Integer
examId
);
List
<
ExamTeacherAssignmentEntity
>
selectByExamIds
(
@Param
(
"examIds"
)
List
<
Integer
>
examIds
);
}
practical-business/src/main/java/com/platform/business/mapper/PracticePaperRuleMapper.java
View file @
66392f2e
...
...
@@ -2,6 +2,12 @@ package com.platform.business.mapper;
import
com.baomidou.mybatisplus.core.mapper.BaseMapper
;
import
com.platform.business.model.entity.PracticePaperRuleEntity
;
import
com.platform.business.model.entity.PracticePaperRuleDefinitionEntity
;
import
com.platform.business.model.entity.PracticePaperRuleDetailEntity
;
import
com.platform.business.model.dto.PracticePaperRuleQueryDTO
;
import
com.platform.business.model.vo.ClassAdminOptionVO
;
import
com.platform.business.model.vo.PracticePaperRuleConfigurationVO
;
import
com.platform.business.model.vo.PracticePaperRuleItemVO
;
import
org.apache.ibatis.annotations.Mapper
;
import
org.apache.ibatis.annotations.Param
;
...
...
@@ -11,11 +17,37 @@ import java.util.List;
@Mapper
public
interface
PracticePaperRuleMapper
extends
BaseMapper
<
PracticePaperRuleEntity
>
{
/**
* 按稳定ID顺序锁定一个等级的全部规则。
*
* <p>整套配置保存前加行锁,保证两个管理员同时保存时不会分别通过“五题上限”
* 校验后交叉覆盖,最终产生一套从未被任何请求完整校验过的组合。</p>
*/
List
<
PracticePaperRuleEntity
>
selectByGradeForUpdate
(
@Param
(
"grade"
)
String
grade
);
List
<
PracticePaperRuleConfigurationVO
>
pageDefinitions
(
@Param
(
"query"
)
PracticePaperRuleQueryDTO
query
);
PracticePaperRuleDefinitionEntity
selectDefinition
(
@Param
(
"ruleId"
)
Integer
ruleId
);
PracticePaperRuleDefinitionEntity
lockDefinition
(
@Param
(
"ruleId"
)
Integer
ruleId
);
List
<
PracticePaperRuleItemVO
>
selectDefinitionDetails
(
@Param
(
"ruleId"
)
Integer
ruleId
);
int
countDuplicateDefinition
(
@Param
(
"grade"
)
String
grade
,
@Param
(
"name"
)
String
name
,
@Param
(
"excludeId"
)
Integer
excludeId
);
int
insertDefinition
(
PracticePaperRuleDefinitionEntity
definition
);
int
updateDefinition
(
PracticePaperRuleDefinitionEntity
definition
);
int
updateDefinitionStatus
(
@Param
(
"ruleId"
)
Integer
ruleId
,
@Param
(
"status"
)
String
status
,
@Param
(
"updatedBy"
)
String
updatedBy
,
@Param
(
"updatedTime"
)
java
.
util
.
Date
updatedTime
);
int
insertDefinitionDetails
(
@Param
(
"items"
)
List
<
PracticePaperRuleDetailEntity
>
items
);
int
deleteDefinitionDetails
(
@Param
(
"ruleId"
)
Integer
ruleId
);
int
deleteDefinition
(
@Param
(
"ruleId"
)
Integer
ruleId
);
int
countDefinitionUsage
(
@Param
(
"ruleId"
)
Integer
ruleId
);
List
<
ClassAdminOptionVO
>
selectPublishedOptions
(
@Param
(
"grade"
)
String
grade
);
PracticePaperRuleDefinitionEntity
selectPublishedDefinition
(
@Param
(
"ruleId"
)
Integer
ruleId
);
}
practical-business/src/main/java/com/platform/business/mapper/TeacherScoreMapper.java
View file @
66392f2e
...
...
@@ -13,8 +13,9 @@ import java.util.List;
/**
* 教师端成绩管理专用查询。
*
* <p>所有涉及考试内容的方法都显式接收 teacherId,并在 SQL 中使用 exam.chief_id
* 校验归属。该限制不能只放在 Controller 中,否则猜测 examId 仍可能造成越权读取。</p>
* <p>所有涉及考试内容的方法都显式接收 teacherId,并在 SQL 中优先通过教师关系表校验
* 首席考评员身份;尚未迁移的历史考试才回退到 exam.chief_id。该限制不能只放在
* Controller 中,否则猜测 examId 仍可能造成越权读取。</p>
*/
@Mapper
public
interface
TeacherScoreMapper
{
...
...
practical-business/src/main/java/com/platform/business/service/PracticePaperRuleService.java
View file @
66392f2e
package
com.platform.business.service
;
import
com.baomidou.mybatisplus.extension.service.IService
;
import
com.platform.business.model.dto.PracticePaperRuleSaveDTO
;
import
com.platform.business.model.entity.PracticePaperRuleEntity
;
import
com.platform.business.model.dto.PracticePaperRuleQueryDTO
;
import
com.platform.business.model.entity.PracticePaperRuleDefinitionEntity
;
import
com.platform.business.model.vo.ClassAdminOptionVO
;
import
com.platform.business.model.vo.PracticePaperRuleConfigurationVO
;
import
com.platform.business.model.vo.PracticePaperRuleItemVO
;
/** 实操自动组卷规则的查询和整套保存服务。 */
public
interface
PracticePaperRuleService
extends
IService
<
PracticePaperRuleEntity
>
{
import
java.util.List
;
/** 管理页面读取全部标准类目,包括题量为0的未选类目
。 */
PracticePaperRule
ConfigurationVO
configuration
(
String
level
);
/** 具名实操试卷规则的目录、查询、保存、发布和删除服务
。 */
public
interface
PracticePaperRule
Service
{
/** recent接口仅读取题量大于0的当前生效配分规则。 */
PracticePaperRuleConfigurationVO
effectiveConfiguration
(
String
level
);
List
<
PracticePaperRuleConfigurationVO
>
queryPage
(
PracticePaperRuleQueryDTO
query
);
/** 管理员整套保存一个等级的配置。 */
PracticePaperRuleConfigurationVO
saveConfiguration
(
PracticePaperRuleSaveDTO
request
,
String
updaterId
);
List
<
PracticePaperRuleItemVO
>
catalog
(
String
level
);
PracticePaperRuleConfigurationVO
detail
(
Integer
ruleId
);
PracticePaperRuleConfigurationVO
create
(
PracticePaperRuleSaveDTO
request
,
String
operatorId
);
PracticePaperRuleConfigurationVO
update
(
Integer
ruleId
,
PracticePaperRuleSaveDTO
request
,
String
operatorId
);
PracticePaperRuleConfigurationVO
publish
(
Integer
ruleId
,
String
status
,
String
operatorId
);
boolean
delete
(
Integer
ruleId
);
/** 按考试保存的规则ID读取不可变的已发布规则,仅返回题量大于0的明细。 */
PracticePaperRuleConfigurationVO
effectiveConfiguration
(
Integer
ruleId
);
List
<
ClassAdminOptionVO
>
publishedOptions
(
String
level
);
PracticePaperRuleDefinitionEntity
requirePublishedDefinition
(
Integer
ruleId
,
String
level
);
}
practical-business/src/main/java/com/platform/business/service/impl/ExamAdminServiceImpl.java
View file @
66392f2e
This diff is collapsed.
Click to expand it.
practical-business/src/main/java/com/platform/business/service/impl/ExamStaudentServiceImpl.java
View file @
66392f2e
...
...
@@ -48,12 +48,14 @@ public class ExamStaudentServiceImpl extends ServiceImpl<ExamStudentMapper, Exam
return
null
;
}
/*
*
为保持现有扩展字段兼容,不固化实操规则快照:每次请求都根据学生
职级读取
*
当前
最新配置
,无论最近一场考试的实际类型为何,字段结构均保持不变。
*
规则服务会把“污水一级”“污泥一级”统一匹配为Excel中的“一级”
。
*
实训规则必须来自考试创建时选择的不可变已发布规则,不能再按学生当前
职级读取
*
“
最新配置
”,否则学生调级或管理员新增规则都会改变既有考试内容。理论考试不
*
返回该扩展字段;历史实训考试由迁移脚本回填默认规则ID
。
*/
examStudentVO
.
setPracticeRule
(
practicePaperRuleService
.
effectiveConfiguration
(
examStudentVO
.
getLev
()));
if
(
"实训"
.
equals
(
examStudentVO
.
getType
())
&&
examStudentVO
.
getPracticeRuleId
()
!=
null
)
{
examStudentVO
.
setPracticeRule
(
practicePaperRuleService
.
effectiveConfiguration
(
examStudentVO
.
getPracticeRuleId
()));
}
//获取同一场考试的学生
List
<
ExamStudentVO
>
data
=
baseMapper
.
theSameEvent
(
examStudentVO
.
getExamId
());
examStudentVO
.
setData
(
data
);
...
...
practical-business/src/main/java/com/platform/business/service/impl/PracticePaperRuleServiceImpl.java
View file @
66392f2e
This diff is collapsed.
Click to expand it.
practical-business/src/main/java/com/platform/business/service/impl/TeacherScoreServiceImpl.java
View file @
66392f2e
...
...
@@ -37,7 +37,8 @@ import java.util.Set;
* 教师端成绩查询与导出实现。
*
* <p>权限采用“双层保护”:Controller 负责校验当前用户确实具有教师角色,本服务传递
* JWT 中的教师 ID,Mapper 的每一条考试查询再通过 exam.chief_id 校验业务归属。</p>
* JWT 中的教师 ID,Mapper 的每一条考试查询再通过首席考评员关系校验业务归属;没有
* 关系记录的历史考试才回退到 exam.chief_id。</p>
*/
@Service
public
class
TeacherScoreServiceImpl
implements
TeacherScoreService
{
...
...
practical-business/src/main/resources/com/platform/business/mapper/ExamMapper.xml
View file @
66392f2e
...
...
@@ -201,6 +201,8 @@
coalesce(nullif(invigilator.nick_name, ''), invigilator.username) as invigilatorName,
e.paper_id as paperId,
paper.name as paperName,
e.practice_rule_id as practiceRuleId,
practice_rule.name as practiceRuleName,
e.location,
(select count(*)
from exam_student attempt
...
...
@@ -218,6 +220,7 @@
left join user chief_user on chief_user.id = e.chief_id
left join user invigilator on invigilator.id = e.invigilation_id
left join theoretical_paper paper on paper.id = e.paper_id
left join practice_paper_rule_definition practice_rule on practice_rule.id = e.practice_rule_id
where e.class_id = #{classId}
<!--
考试管理需要保留已结束场次供管理员追溯,不能再按“开始时间+时长”过滤历史数据。
...
...
@@ -233,6 +236,7 @@
left join user chief_user on chief_user.id = e.chief_id
left join user invigilator on invigilator.id = e.invigilation_id
left join theoretical_paper paper on paper.id = e.paper_id
left join practice_paper_rule_definition practice_rule on practice_rule.id = e.practice_rule_id
where e.id = #{examId}
</select>
...
...
@@ -318,6 +322,19 @@
and coalesce(teacher.del_flag, 0) = 0
</select>
<select
id=
"selectAdminExamActiveTeacherIds"
resultType=
"java.lang.String"
>
select distinct teacher.id
from user teacher
inner join phone_role role_info
on role_info.phone = teacher.phone_number and role_info.role_name = '教师'
where coalesce(teacher.del_flag, 0) = 0
and teacher.id in
<foreach
collection=
"teacherIds"
item=
"teacherId"
open=
"("
separator=
","
close=
")"
>
#{teacherId}
</foreach>
order by teacher.id
</select>
<select
id=
"countAdminExamDuplicateName"
resultType=
"java.lang.Integer"
>
select count(*)
from exam
...
...
@@ -336,6 +353,7 @@
left join user chief_user on chief_user.id = e.chief_id
left join user invigilator on invigilator.id = e.invigilation_id
left join theoretical_paper paper on paper.id = e.paper_id
left join practice_paper_rule_definition practice_rule on practice_rule.id = e.practice_rule_id
where e.exam_time
<
timestampadd(minute, #{duration}, #{startTime})
and timestampadd(minute, coalesce(e.duration, 0), e.exam_time)
>
#{startTime}
<if
test=
"excludeId != null"
>
...
...
@@ -343,9 +361,38 @@
</if>
and (
e.class_id = #{classId}
or e.chief_id in (#{chiefId}, #{invigilatorId})
or find_in_set(#{chiefId}, replace(coalesce(e.invigilation_id, ''), ' ', ''))
>
0
or find_in_set(#{invigilatorId}, replace(coalesce(e.invigilation_id, ''), ' ', ''))
>
0
or (
not exists (
select 1 from exam_teacher_assignment any_chief
where any_chief.exam_id = e.id and any_chief.role = 'CHIEF'
)
and e.chief_id in
<foreach
collection=
"teacherIds"
item=
"teacherId"
open=
"("
separator=
","
close=
")"
>
#{teacherId}
</foreach>
)
or exists (
select 1
from exam_teacher_assignment teacher_assignment
where teacher_assignment.exam_id = e.id
and teacher_assignment.teacher_id in
<foreach
collection=
"teacherIds"
item=
"teacherId"
open=
"("
separator=
","
close=
")"
>
#{teacherId}
</foreach>
)
or (
not exists (
select 1 from exam_teacher_assignment any_invigilator
where any_invigilator.exam_id = e.id
and any_invigilator.role = 'INVIGILATOR'
)
and (
<foreach
collection=
"teacherIds"
item=
"teacherId"
separator=
" or "
>
find_in_set(#{teacherId},
replace(coalesce(e.invigilation_id, ''), ' ', ''))
>
0
</foreach>
)
)
or exists (
select 1
from exam_student conflict_student
...
...
@@ -363,7 +410,7 @@
resultType=
"com.platform.business.model.entity.ExamEntity"
>
select
id, class_id, name, exam_time, type, duration, forbid, chief_id,
invigilation_id, paper_id, location, total_score, pass_score,
invigilation_id, paper_id,
practice_rule_id,
location, total_score, pass_score,
create_time, update_time, mark_flag
from exam
where id = #{examId}
...
...
@@ -395,6 +442,9 @@
exam_time = #{examTime},
duration = #{duration},
chief_id = #{chiefId},
invigilation_id = #{invigilationId},
practice_rule_id = #{practiceRuleId,jdbcType=INTEGER},
total_score = #{totalScore},
location = #{location,jdbcType=VARCHAR},
pass_score = #{passScore},
update_time = #{updateTime}
...
...
practical-business/src/main/resources/com/platform/business/mapper/ExamReviewMapper.xml
View file @
66392f2e
...
...
@@ -3,6 +3,22 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper
namespace=
"com.platform.business.mapper.ExamReviewMapper"
>
<!-- 新关系表是事实来源,旧chief_id精确匹配仅用于尚未迁移的历史考试。 -->
<sql
id=
"chiefPermission"
>
(exists (
select 1 from exam_teacher_assignment chief_assignment
where chief_assignment.exam_id = e.id
and chief_assignment.teacher_id = #{teacherId}
and chief_assignment.role = 'CHIEF'
) or (
not exists (
select 1 from exam_teacher_assignment any_chief
where any_chief.exam_id = e.id and any_chief.role = 'CHIEF'
)
and e.chief_id = #{teacherId}
))
</sql>
<!--
教师只能看到本人作为首席考评员的考试。任务状态按已交卷考生的 mark_flag 聚合:
任意一份已交试卷尚未发布即为 PENDING,全部发布后才是 COMPLETED。
...
...
@@ -32,7 +48,7 @@
INNER JOIN exam_student es ON es.exam_id = e.id
LEFT JOIN class c ON c.id = e.class_id
LEFT JOIN theoretical_paper tp ON tp.id = e.paper_id
WHERE
e.chi
ef
_
id
= #{teacherId}
WHERE
<include
r
efid
=
"chiefPermission"
/>
<if
test=
"query.keyword != null and query.keyword != ''"
>
AND e.name LIKE CONCAT('%', #{query.keyword}, '%')
</if>
...
...
@@ -75,7 +91,7 @@
LEFT JOIN class c ON c.id = e.class_id
LEFT JOIN theoretical_paper tp ON tp.id = e.paper_id
WHERE e.id = #{examId}
AND
e.chi
ef
_
id
= #{teacherId}
AND
<include
r
efid
=
"chiefPermission"
/>
GROUP BY e.id, e.class_id, e.name, c.name, e.type, e.paper_id, tp.name,
e.total_score, e.exam_time, e.duration
</select>
...
...
@@ -85,7 +101,7 @@
SELECT e.*
FROM exam e
WHERE e.id = #{examId}
AND
e.chi
ef
_
id
= #{teacherId}
AND
<include
r
efid
=
"chiefPermission"
/>
FOR UPDATE
</select>
...
...
@@ -116,7 +132,7 @@
AND d.actual_score IS NOT NULL) AS scoredSubjectiveCount,
CASE WHEN IFNULL(es.mark_flag, 0) = 1 THEN TRUE ELSE FALSE END AS published
FROM exam_student es
INNER JOIN exam e ON e.id = es.exam_id AND
e.chi
ef
_
id
= #{teacherId}
INNER JOIN exam e ON e.id = es.exam_id AND
<include
r
efid
=
"chiefPermission"
/>
LEFT JOIN user u ON u.id = es.student_id
LEFT JOIN class c ON c.id = es.class_id
WHERE es.exam_id = #{query.examId}
...
...
@@ -159,7 +175,7 @@
AND d.actual_score IS NOT NULL) AS scoredSubjectiveCount,
CASE WHEN IFNULL(es.mark_flag, 0) = 1 THEN TRUE ELSE FALSE END AS published
FROM exam_student es
INNER JOIN exam e ON e.id = es.exam_id AND
e.chi
ef
_
id
= #{teacherId}
INNER JOIN exam e ON e.id = es.exam_id AND
<include
r
efid
=
"chiefPermission"
/>
LEFT JOIN user u ON u.id = es.student_id
LEFT JOIN class c ON c.id = es.class_id
WHERE es.id = #{examStudentId}
...
...
@@ -170,7 +186,7 @@
<select
id=
"lockStudent"
resultType=
"com.platform.business.model.entity.ExamStudentEntity"
>
SELECT es.*
FROM exam_student es
INNER JOIN exam e ON e.id = es.exam_id AND
e.chi
ef
_
id
= #{teacherId}
INNER JOIN exam e ON e.id = es.exam_id AND
<include
r
efid
=
"chiefPermission"
/>
WHERE es.id = #{examStudentId}
AND es.submit = 1
FOR UPDATE
...
...
practical-business/src/main/resources/com/platform/business/mapper/ExamStudentMapper.xml
View file @
66392f2e
...
...
@@ -72,9 +72,24 @@
from exam_student es
left join exam e on es.exam_id = e.id
left join class c on c.id = e.class_id
where es.submit = false and (
e.chief_id = #{userId} or e.invigilation_id like concat('%',#{userId},'%')
);
where es.submit = false
and (
exists (
select 1 from exam_teacher_assignment assignment
where assignment.exam_id = e.id and assignment.teacher_id = #{userId}
)
or (
not exists (select 1 from exam_teacher_assignment a
where a.exam_id = e.id and a.role = 'CHIEF')
and e.chief_id = #{userId}
)
or (
not exists (select 1 from exam_teacher_assignment a
where a.exam_id = e.id and a.role = 'INVIGILATOR')
and find_in_set(#{userId},
replace(coalesce(e.invigilation_id, ''), ' ', ''))
>
0
)
);
</select>
<select
id=
"recent"
resultType=
"com.platform.business.model.vo.RecentExamStudentVO"
>
select u.level as lev,
...
...
@@ -85,6 +100,7 @@
e.forbid,
e.chief_id as chiefId,
e.invigilation_id as invigilationId,
e.practice_rule_id as practiceRuleId,
es.exam_id as examId,
c.name as className
from exam_student es
...
...
practical-business/src/main/resources/com/platform/business/mapper/ExamTeacherAssignmentMapper.xml
0 → 100644
View file @
66392f2e
<?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=
"com.platform.business.mapper.ExamTeacherAssignmentMapper"
>
<insert
id=
"insertBatch"
>
insert into exam_teacher_assignment (exam_id, teacher_id, role, display_order)
values
<foreach
collection=
"assignments"
item=
"item"
separator=
","
>
(#{item.examId}, #{item.teacherId}, #{item.role}, #{item.displayOrder})
</foreach>
</insert>
<delete
id=
"deleteByExamId"
>
delete from exam_teacher_assignment where exam_id = #{examId}
</delete>
<select
id=
"selectByExamIds"
resultType=
"com.platform.business.model.entity.ExamTeacherAssignmentEntity"
>
select assignment.id,
assignment.exam_id as examId,
assignment.teacher_id as teacherId,
assignment.role,
assignment.display_order as displayOrder,
coalesce(nullif(teacher.nick_name, ''), teacher.username) as teacherName
from exam_teacher_assignment assignment
left join user teacher on teacher.id = assignment.teacher_id
where assignment.exam_id in
<foreach
collection=
"examIds"
item=
"examId"
open=
"("
separator=
","
close=
")"
>
#{examId}
</foreach>
order by assignment.exam_id, assignment.role, assignment.display_order, assignment.id
</select>
</mapper>
practical-business/src/main/resources/com/platform/business/mapper/PracticePaperRuleMapper.xml
View file @
66392f2e
...
...
@@ -3,21 +3,151 @@
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper
namespace=
"com.platform.business.mapper.PracticePaperRuleMapper"
>
<select
id=
"selectByGradeForUpdate"
resultType=
"com.platform.business.model.entity.PracticePaperRuleEntity"
>
select id,
level_grade,
project_name,
unit_content,
assessment_duration,
score,
question_count,
created_time,
updated_time,
updated_by
from practice_paper_rule
where level_grade = #{grade}
order by id asc
<!--
列表只读主表快照总计,避免每页对明细重复聚合。保存规则时主表和明细在同一事务
更新,因此这些快照与明细始终一致;usageCount则实时统计,确保删除按钮不会过期。
-->
<select
id=
"pageDefinitions"
resultType=
"com.platform.business.model.vo.PracticePaperRuleConfigurationVO"
>
select rule.id,
rule.name,
rule.level_grade as grade,
rule.level_grade as lev,
rule.question_count as totalQuestionCount,
rule.total_duration as totalDuration,
rule.total_score as totalScore,
rule.status,
rule.created_time as createdTime,
rule.updated_time as updatedTime,
(select count(*) from exam e where e.practice_rule_id = rule.id) as usageCount
from practice_paper_rule_definition rule
<where>
<if
test=
"query != null and query.name != null and query.name != ''"
>
rule.name like concat('%', #{query.name}, '%')
</if>
<if
test=
"query != null and query.lev != null and query.lev != ''"
>
and rule.level_grade = #{query.lev}
</if>
<if
test=
"query != null and query.status != null and query.status != ''"
>
and rule.status = #{query.status}
</if>
</where>
order by rule.updated_time desc, rule.id desc
</select>
<select
id=
"selectDefinition"
resultType=
"com.platform.business.model.entity.PracticePaperRuleDefinitionEntity"
>
select id, name, level_grade, question_count, total_duration, total_score, status,
created_by, created_time, updated_by, updated_time
from practice_paper_rule_definition
where id = #{ruleId}
</select>
<select
id=
"lockDefinition"
resultType=
"com.platform.business.model.entity.PracticePaperRuleDefinitionEntity"
>
select id, name, level_grade, question_count, total_duration, total_score, status,
created_by, created_time, updated_by, updated_time
from practice_paper_rule_definition
where id = #{ruleId}
for update
</select>
<select
id=
"selectDefinitionDetails"
resultType=
"com.platform.business.model.vo.PracticePaperRuleItemVO"
>
select detail.id,
detail.catalog_id as catalogId,
catalog.project_name as projectName,
catalog.unit_content as unitContent,
detail.assessment_duration as assessmentDuration,
detail.score,
detail.question_count as questionCount,
detail.assessment_duration * detail.question_count as subtotalDuration,
detail.score * detail.question_count as subtotalScore
from practice_paper_rule_detail detail
inner join practice_paper_rule catalog on catalog.id = detail.catalog_id
where detail.rule_id = #{ruleId}
order by catalog.id asc
</select>
<select
id=
"countDuplicateDefinition"
resultType=
"java.lang.Integer"
>
select count(*)
from practice_paper_rule_definition
where level_grade = #{grade}
and name = #{name}
<if
test=
"excludeId != null"
>
and id
<>
#{excludeId}
</if>
</select>
<insert
id=
"insertDefinition"
useGeneratedKeys=
"true"
keyProperty=
"id"
>
insert into practice_paper_rule_definition
(name, level_grade, question_count, total_duration, total_score, status,
created_by, created_time, updated_by, updated_time)
values
(#{name}, #{levelGrade}, #{questionCount}, #{totalDuration}, #{totalScore}, #{status},
#{createdBy}, #{createdTime}, #{updatedBy}, #{updatedTime})
</insert>
<update
id=
"updateDefinition"
>
update practice_paper_rule_definition
set name = #{name},
level_grade = #{levelGrade},
question_count = #{questionCount},
total_duration = #{totalDuration},
total_score = #{totalScore},
updated_by = #{updatedBy},
updated_time = #{updatedTime}
where id = #{id}
and status = 'DRAFT'
</update>
<update
id=
"updateDefinitionStatus"
>
update practice_paper_rule_definition
set status = #{status}, updated_by = #{updatedBy}, updated_time = #{updatedTime}
where id = #{ruleId}
and status = 'DRAFT'
</update>
<insert
id=
"insertDefinitionDetails"
>
insert into practice_paper_rule_detail
(rule_id, catalog_id, assessment_duration, score, question_count)
values
<foreach
collection=
"items"
item=
"item"
separator=
","
>
(#{item.ruleId}, #{item.catalogId}, #{item.assessmentDuration},
#{item.score}, #{item.questionCount})
</foreach>
</insert>
<delete
id=
"deleteDefinitionDetails"
>
delete from practice_paper_rule_detail where rule_id = #{ruleId}
</delete>
<delete
id=
"deleteDefinition"
>
delete from practice_paper_rule_definition where id = #{ruleId}
</delete>
<select
id=
"countDefinitionUsage"
resultType=
"java.lang.Integer"
>
select count(*) from exam where practice_rule_id = #{ruleId}
</select>
<select
id=
"selectPublishedOptions"
resultType=
"com.platform.business.model.vo.ClassAdminOptionVO"
>
select cast(id as char) as value,
name as label,
level_grade as parentValue,
concat(question_count, '题 · ', total_score, '分') as extra
from practice_paper_rule_definition
where level_grade = #{grade}
and status = 'PUBLISHED'
order by updated_time desc, id desc
</select>
<select
id=
"selectPublishedDefinition"
resultType=
"com.platform.business.model.entity.PracticePaperRuleDefinitionEntity"
>
select id, name, level_grade, question_count, total_duration, total_score, status,
created_by, created_time, updated_by, updated_time
from practice_paper_rule_definition
where id = #{ruleId}
and status = 'PUBLISHED'
</select>
</mapper>
practical-business/src/main/resources/com/platform/business/mapper/TeacherHomeMapper.xml
View file @
66392f2e
...
...
@@ -3,6 +3,34 @@
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper
namespace=
"com.platform.business.mapper.TeacherHomeMapper"
>
<sql
id=
"chiefPermission"
>
(exists (
select 1 from exam_teacher_assignment chief_assignment
where chief_assignment.exam_id = e.id
and chief_assignment.teacher_id = #{teacherId}
and chief_assignment.role = 'CHIEF'
) or (
not exists (select 1 from exam_teacher_assignment any_chief
where any_chief.exam_id = e.id and any_chief.role = 'CHIEF')
and e.chief_id = #{teacherId}
))
</sql>
<sql
id=
"participantPermission"
>
(exists (
select 1 from exam_teacher_assignment assignment
where assignment.exam_id = e.id and assignment.teacher_id = #{teacherId}
) or (
not exists (select 1 from exam_teacher_assignment any_chief
where any_chief.exam_id = e.id and any_chief.role = 'CHIEF')
and e.chief_id = #{teacherId}
) or (
not exists (select 1 from exam_teacher_assignment any_invigilator
where any_invigilator.exam_id = e.id and any_invigilator.role = 'INVIGILATOR')
and find_in_set(#{teacherId}, replace(coalesce(e.invigilation_id, ''), ' ', ''))
>
0
))
</sql>
<select
id=
"selectCourseNames"
resultType=
"java.lang.String"
>
select distinct subject.subject_name
from class_subject subject
...
...
@@ -42,15 +70,14 @@
(select count(distinct e.id)
from exam e
inner join exam_student attempt on attempt.exam_id = e.id
where
e.chi
ef
_
id
= #{teacherId}
where
<include
r
efid
=
"chiefPermission"
/>
and coalesce(attempt.submit, 0) = 1
and coalesce(attempt.mark_flag, 0) = 0) as pendingReviewCount,
(select count(distinct e.id)
from exam e
where e.exam_time
>
= #{monthStart}
and e.exam_time
<
#{nextMonthStart}
and (e.chief_id = #{teacherId}
or find_in_set(#{teacherId}, replace(coalesce(e.invigilation_id, ''), ' ', ''))
>
0))
and
<include
refid=
"participantPermission"
/>
)
as monthlyExamCount
</select>
...
...
@@ -68,7 +95,7 @@
from exam e
inner join exam_student attempt on attempt.exam_id = e.id
left join `class` c on c.id = e.class_id
where
e.chi
ef
_
id
= #{teacherId}
where
<include
r
efid
=
"chiefPermission"
/>
group by e.id, e.name, e.class_id, c.name, e.type, e.exam_time
having sum(case when coalesce(attempt.submit, 0) = 1
and coalesce(attempt.mark_flag, 0) = 0 then 1 else 0 end)
>
0
...
...
@@ -89,8 +116,7 @@
left join `class` c on c.id = e.class_id
where e.exam_time
>
= #{startTime}
and e.exam_time
<
#{endTime}
and (e.chief_id = #{teacherId}
or find_in_set(#{teacherId}, replace(coalesce(e.invigilation_id, ''), ' ', ''))
>
0)
and
<include
refid=
"participantPermission"
/>
order by e.exam_time asc, e.id asc
</select>
...
...
practical-business/src/main/resources/com/platform/business/mapper/TeacherScoreMapper.xml
View file @
66392f2e
...
...
@@ -3,13 +3,25 @@
<mapper
namespace=
"com.platform.business.mapper.TeacherScoreMapper"
>
<!--
管理端创建考试时会把负责教师写入 exam.chief_id。成绩管理按该字段判断业务归属,
管理端创建考试时会把所有首席考评员写入关系表,exam.chief_id只保留第一人兼容旧端。
成绩管理优先按关系表判断业务归属,并让没有关系记录的历史考试回退到旧字段;
不再用考试结束时间限制列表可见性,确保未来场次创建成功后也能立即同步到负责教师端。
未开始、未交卷或未发布的场次仍由下方统计列返回空成绩,并由服务层禁止导出,
因而提前展示考试计划不会泄露成绩,也不会把暂存分当成正式成绩。
-->
<sql
id=
"visibleExamCondition"
>
e.chief_id = #{teacherId}
(exists (
select 1 from exam_teacher_assignment chief_assignment
where chief_assignment.exam_id = e.id
and chief_assignment.teacher_id = #{teacherId}
and chief_assignment.role = 'CHIEF'
) or (
not exists (
select 1 from exam_teacher_assignment any_chief
where any_chief.exam_id = e.id and any_chief.role = 'CHIEF'
)
and e.chief_id = #{teacherId}
))
</sql>
<!--
...
...
practical-business/src/main/resources/exam-management-api.md
View file @
66392f2e
...
...
@@ -33,6 +33,7 @@
-
`teachers`
:未删除且具有教师角色的用户,首席考评员和监考教师共用。
-
`papers`
:
`theoretical_paper.lev`
与班级等级名称完全一致的理论试卷;实训考试不使用。
-
`practiceRules`
:班级等级末尾与规则的一级至五级匹配、且状态为已发布的实操规则。
-
`students`
:当前班级有效学员,包含身份证号、性别、手机号、单位和个人出勤率。
出勤率按
`NORMAL/LATE`
占
`NORMAL/LATE/ABSENT/LEAVE`
的百分比计算;没有有效记录时为
...
...
@@ -57,8 +58,8 @@
"examTime"
:
"2026-09-18 09:00:00"
,
"duration"
:
90
,
"forbid"
:
30
,
"chiefExaminerId"
:
"1900000000000000001"
,
"invigilatorId"
:
"1900000000000000002"
,
"chiefExaminerId
s
"
:
[
"1900000000000000001"
,
"1900000000000000003"
],
"invigilatorId
s
"
:
[
"1900000000000000002"
]
,
"paperId"
:
"1900000000000000100"
,
"location"
:
"教学楼A-301"
,
"passScore"
:
60
,
...
...
@@ -69,8 +70,10 @@
-
类型只支持“理论”“实训”;考试日期必须位于班级培训起止日期内。
-
时长为15~600分钟;
`forbid`
为0~考试时长。
-
理论考试必须选择与班级等级一致的试卷,总分从试卷复制,不能提交
`totalScore`
。
-
实训考试不传
`paperId`
,必须提交
`totalScore`
;试卷由第三方仿真系统创建
。
-
实训考试不传
`paperId`
和
`totalScore`
,必须提交已发布的
`practiceRuleId`
;总分从规则复制
。
-
两类考试的
`passScore`
不传时均默认为总分的60%。
-
两组教师各至少一人、组内自动去重,允许同一教师同时承担两个角色;任一首席考评员
均可阅卷和发布成绩。
-
至少选择1名、最多500名班级学员,ID不得重复。
-
同班级、首席考评员、监考教师或任一应考学员的考试时间不能重叠。
-
同一班级内考试名称不能重复。
...
...
@@ -87,14 +90,21 @@
"type"
:
"理论"
,
"examTime"
:
"2026-09-18 09:30:00"
,
"duration"
:
90
,
"chiefExaminerId"
:
"1900000000000000001"
,
"chiefExaminerIds"
:
[
"1900000000000000001"
,
"1900000000000000003"
],
"invigilatorIds"
:
[
"1900000000000000002"
],
"practiceRuleId"
:
5
,
"location"
:
"教学楼A-302"
,
"passScore"
:
60
}
```
编辑不允许切换考试类型,也不改变试卷、总分快照、监考教师、禁止交卷时间或应考学员。考试已到开始时间,或任一
考生已开始、交卷、产生分数后禁止编辑。新的时间和教师安排仍会执行完整冲突校验。
编辑不允许切换考试类型,也不改变理论试卷、禁止交卷时间或应考学员;实训考试可切换
已发布规则并刷新总分快照,两组教师均可重新多选。考试已到开始时间,或任一考生已开始、
交卷、产生分数后禁止编辑。新的时间和任一教师安排仍会执行完整冲突校验。
新数组字段非null时优先;没有数组字段的旧客户端仍可提交
`chiefExaminerId`
和
`invigilatorId`
。响应旧字段返回列表第一人,同时通过
`chiefExaminerIds/chiefExaminers`
及
`invigilatorIds/invigilators`
返回完整人员。
## 7. 删除考试
...
...
practical-business/src/main/resources/practice-paper-rule-api.md
View file @
66392f2e
# 管理员端实操
自动组
卷规则接口
# 管理员端实操
试
卷规则接口
页面位置为“管理员 → 智能考评 → 试卷管理 → 自动组卷 → 实操”。实操与理论的
行为不同:这里只配置类目、考核时间、配分和题量,不生成正式试卷。
页面位置为“管理员 → 智能考评 → 试卷管理 → 实操试卷规则”。部署时先执行
`sql/exam_management.sql`
,再执行
`sql/practice_paper_rule.sql`
。后者会创建规则主表、
明细表和考试教师关系表,并把原一级至五级配置迁移成五条已发布默认规则。
部署前执行:
状态仅有
`DRAFT`
(草稿)和
`PUBLISHED`
(已发布)。草稿可编辑、发布和删除;已发布
规则不可编辑或退回草稿,但未被考试使用时仍可删除。任何被考试引用的规则均不可删除。
```
text
practical-business/src/main/resources/sql/practice_paper_rule.sql
```
## 1. 规则列表
## 1. 查询配置
`POST /theoretical/paper/admin/practice/page`
`GET /theoretical/paper/admin/practice/auto-configuration?lev=污水一级`
```
json
{
"pageNum"
:
1
,
"pageSize"
:
10
,
"name"
:
"默认"
,
"lev"
:
"污水一级"
,
"status"
:
"PUBLISHED"
}
```
`污水一级
`
、
`
污泥一级
`
和
`一级`
都会匹配 Excel 中的
`一级`
类目。返回全部标准类目,
包括当前题量为0的未选类目。初始考核时间和配分均为20;每个等级按 Excel 顺序默认
启用前5项各1题,其余类目题量为0,因此初始总时间100分钟、总分100分
。
`
lev`
会归一化为一级至五级,因此
污水一级
与
污泥一级
查询同一组共享规则。列表返回
`id/name/lev/grade/totalQuestionCount/totalDuration/totalScore/status/statusLabel/usageCount`
以及
`publishable/editable/deletable`
,页面应直接依据这三个布尔值显示操作按钮
。
## 2.
保存配置
## 2.
新建、详情和编辑
`PUT /theoretical/paper/admin/practice/auto-configuration`
-
`GET /theoretical/paper/admin/practice/catalog?lev=污水一级`
:返回该标准等级的全部类目、
`catalogId`
和默认数值,供新建表单初始化。
-
`POST /theoretical/paper/admin/practice`
:创建草稿。
-
`GET /theoretical/paper/admin/practice/{ruleId}`
:返回主表和全部标准类目明细。
-
`PUT /theoretical/paper/admin/practice/{ruleId}`
:仅允许编辑草稿。
新建和编辑请求示例:
```
json
{
"lev"
:
"污水五级"
,
"name"
:
"一级实操规则A"
,
"lev"
:
"污水一级"
,
"ruleList"
:
[
{
"id"
:
1
,
"assessmentDuration"
:
20
,
"score"
:
20
,
"questionCount"
:
1
},
{
"id"
:
2
,
"assessmentDuration"
:
20
,
"score"
:
20
,
"questionCount"
:
1
},
{
"id"
:
3
,
"assessmentDuration"
:
20
,
"score"
:
20
,
"questionCount"
:
1
},
{
"id"
:
4
,
"assessmentDuration"
:
20
,
"score"
:
20
,
"questionCount"
:
1
},
{
"id"
:
5
,
"assessmentDuration"
:
20
,
"score"
:
20
,
"questionCount"
:
1
},
{
"id"
:
6
,
"assessmentDuration"
:
20
,
"score"
:
20
,
"questionCount"
:
0
}
{
"catalogId"
:
1
,
"assessmentDuration"
:
20
,
"score"
:
20
,
"questionCount"
:
1
},
{
"catalogId"
:
2
,
"assessmentDuration"
:
20
,
"score"
:
20
,
"questionCount"
:
0
}
]
}
```
必须回传查询接口返回的该等级全部类目。服务端只按ID更新考核时间、配分和题量,不能
修改 Excel 标准项目与单元内容。所有类目的
`questionCount`
合计必须为1至5。
必须回传详情中该等级的全部标准类目,不能跨等级混用
`catalogId`
。每项时间为1~600
分钟、配分大于0且不超过99999.99,所有类目的题量合计必须为1~5。题量、总时间和总分
由服务端计算,客户端提交同名字段不会作为事实来源。同一等级内规则名称不能重复。
## 3.
学员最近考试
## 3.
发布与删除
`GET /exam/student/recent/{studentId}`
按最近一场考试返回数据库中的实际
`type`
,并在
原有字段基础上新增
`practiceRule`
:
-
`PUT /theoretical/paper/admin/practice/{ruleId}/status`
,请求体固定为
`{"status":"PUBLISHED"}`
;只有草稿可以发布。
-
`DELETE /theoretical/paper/admin/practice/{ruleId}`
;草稿和已发布规则均可调用,但使用次数
必须为0。
```
json
{
"practiceRule"
:
{
"lev"
:
"五级"
,
"grade"
:
"五级"
,
"totalQuestionCount"
:
5
,
"totalDuration"
:
100
,
"totalScore"
:
100.00
,
"ruleList"
:
[
{
"id"
:
1
,
"projectName"
:
"运行管理"
,
"unitContent"
:
"日常运行管理"
,
"assessmentDuration"
:
20
,
"score"
:
20.00
,
"questionCount"
:
1
,
"subtotalDuration"
:
20
,
"subtotalScore"
:
20.00
}
]
}
}
```
旧版
`/practice/auto-configuration`
GET/PUT 已移除,不再按职级覆盖唯一配置。
## 4. 考试使用
该字段每次请求读取管理员当前最新配置,不固化到考试快照。
`ruleList`
只包含题量大于0
的当前生效规则。
`GET /exam/admin/classes/{classId}/options`
的
`practiceRules`
只包含与班级等级后缀匹配的
已发布规则。实训考试提交
`practiceRuleId`
,服务端从规则复制总分到考试快照。学员最近
考试的
`practiceRule`
也按考试保存的规则ID读取,不会随新增规则或学员职级变化。
practical-business/src/main/resources/sql/practice_paper_rule.sql
View file @
66392f2e
-- 管理员端“智能考评-试卷管理-自动组卷(实操)”规则配置(MySQL 5.7+/8.0)。
--
-- 业务口径:
-- 1.
实操自动组卷只保存规则
,不生成theoretical_paper
或正式试卷明细
。
-- 1.
practice_paper_rule保留为一级至五级标准类目目录
,不生成theoretical_paper。
-- 2. level_grade使用Excel中的一级至五级;污水一级、污泥一级等职级在服务层统一匹配一级。
-- 3. 考核时间和单题配分默认20;
每级默认启用Excel顺序前5项各1题,整套题量1至5由服务层校验
。
-- 4. INSERT IGNORE只补充缺失类目,重复执行不会覆盖
管理员已经保存的时间、配分和题量
。
-- 3. 考核时间和单题配分默认20;
目录数值会迁移成每级一条已发布默认规则
。
-- 4. INSERT IGNORE只补充缺失类目,重复执行不会覆盖
已经迁移的具名规则
。
create
table
if
not
exists
practice_paper_rule
(
id
int
not
null
auto_increment
comment
'规则ID'
,
...
...
@@ -89,3 +89,135 @@ select level_grade, count(*) as category_count
from
practice_paper_rule
group
by
level_grade
order
by
field
(
level_grade
,
'五级'
,
'四级'
,
'三级'
,
'二级'
,
'一级'
);
-- ==================== 具名规则主表与明细 ====================
create
table
if
not
exists
practice_paper_rule_definition
(
id
int
not
null
auto_increment
comment
'实操试卷规则ID'
,
name
varchar
(
200
)
not
null
comment
'规则名称'
,
level_grade
varchar
(
8
)
not
null
comment
'共享标准等级:一级至五级'
,
question_count
int
not
null
comment
'规则总题量快照'
,
total_duration
int
not
null
comment
'规则总考核时间(分钟)'
,
total_score
decimal
(
8
,
2
)
not
null
comment
'规则总分快照'
,
status
varchar
(
16
)
not
null
default
'DRAFT'
comment
'DRAFT/PUBLISHED'
,
created_by
varchar
(
64
)
null
comment
'创建管理员ID'
,
created_time
datetime
not
null
default
current_timestamp
comment
'创建时间'
,
updated_by
varchar
(
64
)
null
comment
'最后更新管理员ID'
,
updated_time
datetime
not
null
default
current_timestamp
comment
'更新时间'
,
primary
key
(
id
),
unique
key
uk_practice_definition_grade_name
(
level_grade
,
name
),
key
idx_practice_definition_grade_status
(
level_grade
,
status
,
updated_time
,
id
)
)
engine
=
InnoDB
default
charset
=
utf8mb4
collate
=
utf8mb4_unicode_ci
comment
=
'具名实操试卷规则主表'
;
create
table
if
not
exists
practice_paper_rule_detail
(
id
int
not
null
auto_increment
comment
'规则明细ID'
,
rule_id
int
not
null
comment
'实操试卷规则ID'
,
catalog_id
int
not
null
comment
'标准类目ID'
,
assessment_duration
int
not
null
comment
'单题考核时间(分钟)'
,
score
decimal
(
8
,
2
)
not
null
comment
'单题配分'
,
question_count
int
not
null
default
0
comment
'该类目考核题量'
,
primary
key
(
id
),
unique
key
uk_practice_detail_rule_catalog
(
rule_id
,
catalog_id
),
key
idx_practice_detail_rule
(
rule_id
,
id
)
)
engine
=
InnoDB
default
charset
=
utf8mb4
collate
=
utf8mb4_unicode_ci
comment
=
'具名实操试卷规则明细'
;
-- 把升级前每个等级的唯一配置固化成已发布默认规则;唯一键保证脚本可重复执行。
insert
ignore
into
practice_paper_rule_definition
(
name
,
level_grade
,
question_count
,
total_duration
,
total_score
,
status
,
created_by
,
created_time
,
updated_by
,
updated_time
)
select
concat
(
catalog
.
level_grade
,
'实操默认规则'
),
catalog
.
level_grade
,
sum
(
catalog
.
question_count
),
sum
(
catalog
.
assessment_duration
*
catalog
.
question_count
),
sum
(
catalog
.
score
*
catalog
.
question_count
),
'PUBLISHED'
,
null
,
now
(),
null
,
now
()
from
practice_paper_rule
catalog
group
by
catalog
.
level_grade
;
insert
ignore
into
practice_paper_rule_detail
(
rule_id
,
catalog_id
,
assessment_duration
,
score
,
question_count
)
select
definition
.
id
,
catalog
.
id
,
catalog
.
assessment_duration
,
catalog
.
score
,
catalog
.
question_count
from
practice_paper_rule
catalog
inner
join
practice_paper_rule_definition
definition
on
definition
.
level_grade
=
catalog
.
level_grade
and
definition
.
name
=
concat
(
catalog
.
level_grade
,
'实操默认规则'
);
-- ==================== 考试规则引用与教师多选关系 ====================
create
table
if
not
exists
exam_teacher_assignment
(
id
int
not
null
auto_increment
comment
'关系ID'
,
exam_id
int
not
null
comment
'考试ID'
,
teacher_id
varchar
(
64
)
not
null
comment
'教师用户ID'
,
role
varchar
(
16
)
not
null
comment
'CHIEF/INVIGILATOR'
,
display_order
int
not
null
default
0
comment
'表单选择顺序'
,
primary
key
(
id
),
unique
key
uk_exam_teacher_role
(
exam_id
,
teacher_id
,
role
),
key
idx_exam_teacher_permission
(
teacher_id
,
role
,
exam_id
),
key
idx_exam_teacher_exam
(
exam_id
,
role
,
display_order
,
id
)
)
engine
=
InnoDB
default
charset
=
utf8mb4
collate
=
utf8mb4_unicode_ci
comment
=
'考试首席考评员与监考教师多选关系'
;
delimiter
$$
drop
procedure
if
exists
migrate_exam_practice_rule
$$
create
procedure
migrate_exam_practice_rule
()
begin
if
not
exists
(
select
1
from
information_schema
.
columns
where
table_schema
=
database
()
and
table_name
=
'exam'
and
column_name
=
'practice_rule_id'
)
then
alter
table
exam
add
column
practice_rule_id
int
null
comment
'实训试卷规则ID'
after
paper_id
;
end
if
;
if
not
exists
(
select
1
from
information_schema
.
statistics
where
table_schema
=
database
()
and
table_name
=
'exam'
and
index_name
=
'idx_exam_practice_rule'
)
then
alter
table
exam
add
index
idx_exam_practice_rule
(
practice_rule_id
,
id
);
end
if
;
end
$$
call
migrate_exam_practice_rule
()
$$
drop
procedure
if
exists
migrate_exam_practice_rule
$$
delimiter
;
-- 首席考评员历史字段为单值,可直接迁移;空值不会生成无效关系。
insert
ignore
into
exam_teacher_assignment
(
exam_id
,
teacher_id
,
role
,
display_order
)
select
e
.
id
,
trim
(
e
.
chief_id
),
'CHIEF'
,
0
from
exam
e
where
e
.
chief_id
is
not
null
and
trim
(
e
.
chief_id
)
<>
''
;
-- 监考教师历史字段可能是逗号分隔值。MySQL 5.7没有JSON_TABLE,因此使用有限序列表拆分;
-- 现有业务不会超过20名监考教师,超过部分仍可由查询端旧字段回退逻辑识别。
insert
ignore
into
exam_teacher_assignment
(
exam_id
,
teacher_id
,
role
,
display_order
)
select
e
.
id
,
trim
(
substring_index
(
substring_index
(
e
.
invigilation_id
,
','
,
seq_table
.
seq
),
','
,
-
1
)),
'INVIGILATOR'
,
seq_table
.
seq
-
1
from
exam
e
inner
join
(
select
1
seq
union
all
select
2
union
all
select
3
union
all
select
4
union
all
select
5
union
all
select
6
union
all
select
7
union
all
select
8
union
all
select
9
union
all
select
10
union
all
select
11
union
all
select
12
union
all
select
13
union
all
select
14
union
all
select
15
union
all
select
16
union
all
select
17
union
all
select
18
union
all
select
19
union
all
select
20
)
seq_table
on
seq_table
.
seq
<=
1
+
length
(
e
.
invigilation_id
)
-
length
(
replace
(
e
.
invigilation_id
,
','
,
''
))
where
e
.
invigilation_id
is
not
null
and
trim
(
substring_index
(
substring_index
(
e
.
invigilation_id
,
','
,
seq_table
.
seq
),
','
,
-
1
))
<>
''
;
-- 历史实训考试按班级职级末尾的一级至五级匹配默认规则,延续原先跨工种共享规则的口径。
update
exam
e
inner
join
`class`
c
on
c
.
id
=
e
.
class_id
inner
join
sys_level
level_info
on
cast
(
level_info
.
id
as
char
)
=
c
.
level
inner
join
practice_paper_rule_definition
definition
on
right
(
trim
(
level_info
.
name
),
char_length
(
definition
.
level_grade
))
=
definition
.
level_grade
and
definition
.
name
=
concat
(
definition
.
level_grade
,
'实操默认规则'
)
set
e
.
practice_rule_id
=
definition
.
id
,
e
.
total_score
=
coalesce
(
e
.
total_score
,
definition
.
total_score
),
e
.
pass_score
=
coalesce
(
e
.
pass_score
,
round
(
definition
.
total_score
*
0
.
60
,
2
))
where
e
.
type
=
'实训'
and
e
.
practice_rule_id
is
null
;
practical-business/src/test/java/com/platform/business/controller/TheoreticalPaperAdminControllerTest.java
View file @
66392f2e
...
...
@@ -2,6 +2,8 @@ package com.platform.business.controller;
import
com.platform.business.model.dto.TheoreticalPaperAutoSaveDTO
;
import
com.platform.business.model.dto.PracticePaperRuleSaveDTO
;
import
com.platform.business.model.dto.PracticePaperRuleQueryDTO
;
import
com.platform.business.model.dto.PracticePaperRuleStatusDTO
;
import
com.platform.business.model.dto.TheoreticalPaperDTO
;
import
com.platform.business.model.dto.TheoreticalPaperManualSaveDTO
;
import
com.platform.business.model.dto.TheoreticalPaperStatusDTO
;
...
...
@@ -63,18 +65,27 @@ class TheoreticalPaperAdminControllerTest {
when
(
authenticatedUserService
.
current
(
request
)).
thenReturn
(
administrator
);
when
(
paperAdminService
.
page
(
org
.
mockito
.
ArgumentMatchers
.
any
()))
.
thenReturn
(
Collections
.
emptyList
());
when
(
practicePaperRuleService
.
queryPage
(
org
.
mockito
.
ArgumentMatchers
.
any
()))
.
thenReturn
(
Collections
.
emptyList
());
TheoreticalPaperDTO
query
=
new
TheoreticalPaperDTO
();
TheoreticalPaperAutoSaveDTO
automatic
=
new
TheoreticalPaperAutoSaveDTO
();
TheoreticalPaperManualSaveDTO
manual
=
new
TheoreticalPaperManualSaveDTO
();
TheoreticalPaperStatusDTO
status
=
new
TheoreticalPaperStatusDTO
();
PracticePaperRuleSaveDTO
practiceRule
=
new
PracticePaperRuleSaveDTO
();
PracticePaperRuleStatusDTO
practiceStatus
=
new
PracticePaperRuleStatusDTO
();
practiceStatus
.
setStatus
(
"PUBLISHED"
);
status
.
setStatus
(
"ARCHIVED"
);
controller
.
page
(
query
,
request
);
controller
.
autoConfiguration
(
"污水一级"
,
request
);
controller
.
practiceAutoConfiguration
(
"污水一级"
,
request
);
controller
.
savePracticeAutoConfiguration
(
practiceRule
,
request
);
controller
.
practicePage
(
new
PracticePaperRuleQueryDTO
(),
request
);
controller
.
createPracticeRule
(
practiceRule
,
request
);
controller
.
practiceCatalog
(
"污水一级"
,
request
);
controller
.
practiceRuleDetail
(
1
,
request
);
controller
.
updatePracticeRule
(
1
,
practiceRule
,
request
);
controller
.
publishPracticeRule
(
1
,
practiceStatus
,
request
);
controller
.
deletePracticeRule
(
1
,
request
);
controller
.
createAutomatic
(
automatic
,
request
);
controller
.
createManual
(
manual
,
request
);
controller
.
detail
(
"paper-1"
,
request
);
...
...
@@ -85,9 +96,13 @@ class TheoreticalPaperAdminControllerTest {
controller
.
export
(
"paper-1"
,
request
,
response
);
controller
.
exportWithAnswer
(
"paper-1"
,
request
,
response
);
verify
(
authenticatedUserService
,
times
(
13
)).
requireAdmin
(
administrator
);
verify
(
practicePaperRuleService
).
configuration
(
"污水一级"
);
verify
(
practicePaperRuleService
).
saveConfiguration
(
practiceRule
,
"admin-1"
);
verify
(
authenticatedUserService
,
times
(
18
)).
requireAdmin
(
administrator
);
verify
(
practicePaperRuleService
).
create
(
practiceRule
,
"admin-1"
);
verify
(
practicePaperRuleService
).
catalog
(
"污水一级"
);
verify
(
practicePaperRuleService
).
detail
(
1
);
verify
(
practicePaperRuleService
).
update
(
1
,
practiceRule
,
"admin-1"
);
verify
(
practicePaperRuleService
).
publish
(
1
,
"PUBLISHED"
,
"admin-1"
);
verify
(
practicePaperRuleService
).
delete
(
1
);
verify
(
paperAdminService
).
createAutomatic
(
automatic
,
"管理员甲"
);
verify
(
paperAdminService
).
createManual
(
manual
,
"管理员甲"
);
verify
(
paperAdminService
).
copy
(
"paper-1"
,
"管理员甲"
);
...
...
practical-business/src/test/java/com/platform/business/mapper/ExamMapperXmlTest.java
View file @
66392f2e
...
...
@@ -42,8 +42,7 @@ class ExamMapperXmlTest {
conflictParameters
.
put
(
"startTime"
,
Timestamp
.
valueOf
(
"2026-09-18 09:00:00"
));
conflictParameters
.
put
(
"duration"
,
90
);
conflictParameters
.
put
(
"classId"
,
1
);
conflictParameters
.
put
(
"chiefId"
,
"teacher-1"
);
conflictParameters
.
put
(
"invigilatorId"
,
"teacher-2"
);
conflictParameters
.
put
(
"teacherIds"
,
Arrays
.
asList
(
"teacher-1"
,
"teacher-2"
));
conflictParameters
.
put
(
"studentIds"
,
Arrays
.
asList
(
"student-1"
,
"student-2"
));
conflictParameters
.
put
(
"excludeId"
,
null
);
String
conflictSql
=
configuration
.
getMappedStatement
(
...
...
@@ -61,6 +60,7 @@ class ExamMapperXmlTest {
"timestampadd(minute, coalesce(e.duration, 0), e.exam_time) > ?"
));
assertTrue
(
conflictSql
.
contains
(
"from exam_student conflict_student"
));
assertTrue
(
conflictSql
.
contains
(
"conflict_student.student_id in"
));
assertTrue
(
conflictSql
.
contains
(
"from exam_teacher_assignment teacher_assignment"
));
/*
* 通用考试分页必须查出时长供服务层计算三态;顶部汇总则必须独立统计全表,
...
...
Prev
1
2
3
Next
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment