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
0e26d1b5
Commit
0e26d1b5
authored
Aug 21, 2026
by
wujipeng
Browse files
对接数字仿真-优化
parent
3ad3b803
Changes
30
Show whitespace changes
Inline
Side-by-side
practical-business/src/main/resources/exam-review-api.md
View file @
0e26d1b5
...
@@ -43,8 +43,8 @@
...
@@ -43,8 +43,8 @@
`GET /exam/review/students/{examStudentId}/paper`
`GET /exam/review/students/{examStudentId}/paper`
返回
考生信息、
试卷元数据、
各
题型
评分汇总和完整题目列表。客观题分数根据系统判题结果计算
;
返回
`examType`
和考试类型对应的互斥明细。理论考试返回
试卷元数据、题型
汇总及
`questions`
;
主观题的
`manualScoreRequired`
为
`true`
,未评分时
`actualScore`
为
`null`
。
实训考试返回第三方
`practiceItems`
,其中明细
`id`
用于后续保存评分,
`questions`
为空数组
。
## 4. 保存阅卷进度
## 4. 保存阅卷进度
...
@@ -62,15 +62,16 @@
...
@@ -62,15 +62,16 @@
}
}
```
```
可仅提交本次变化的主观题。服务端校验题目归属、题型以及
`0 <= score <= 题目满分`
;保存成功后写入审计日志,
理论考试可仅提交本次变化的主观题,并校验
`0 <= score <= 题目满分`
;实训考试可提交变化的项目,
校验单项非负且调整后汇总不超过考试总分。保存成功后写入审计日志,
但不会把暂存结果标记为正式发布。已发布的考生成绩不可再次修改。
但不会把暂存结果标记为正式发布。已发布的考生成绩不可再次修改。
## 5. 发布成绩
## 5. 发布成绩
`PUT /exam/review/tasks/{examId}/publish`
`PUT /exam/review/tasks/{examId}/publish`
发布前会锁定本场考试及全部已交卷考生
,并校验每位考生已经生成试卷、所有主观题均已评分。随后服务端重新汇总
发布前会锁定本场考试及全部已交卷考生
。理论考试校验试卷与主观题评分完整性;实训考试校验第三方明细存在并重新
客观题与主观题得分,
更新
`exam_student.score`
,最后
统一设置考生和考试的
`mark_flag=1`
。
任一步失败都会回滚。
汇总教师复核后的项目分数。随后
更新
`exam_student.score`
并
统一设置考生和考试的
`mark_flag=1`
,
任一步失败都会回滚。
## 6. 评分追溯记录
## 6. 评分追溯记录
...
...
practical-business/src/main/resources/sql/student_score_management.sql
View file @
0e26d1b5
...
@@ -2,9 +2,10 @@
...
@@ -2,9 +2,10 @@
--
--
-- 设计说明:
-- 设计说明:
-- 1. 理论成绩继续复用 exam、exam_student、theoretical_paper_student_detail,不新建重复成绩表。
-- 1. 理论成绩继续复用 exam、exam_student、theoretical_paper_student_detail,不新建重复成绩表。
-- 2. fz_grades
只
保存
逐题明细
;正式总分汇总到
exam_student
,统一供学生端和管理端读取
。
-- 2. fz_grades 保存
第三方原始逐项明细及教师复核后的当前分值
;正式总分汇总到exam_student。
-- 3. 历史环境可能已经存在重复题号,因此本脚本只增加普通索引,不自动删除或改写历史数据。
-- 3. 历史环境可能已经存在重复题号,因此本脚本只增加普通索引,不自动删除或改写历史数据。
-- 4. 应用查询按每个 exam_id + user_id + code 的最大雪花ID归并为最新记录。
-- 4. 应用查询按每个 exam_id + user_id + code 的最大雪花ID归并为最新记录。
-- 5. 存量实训明细只迁入待复核状态,绝不在迁移脚本中自动发布给学员。
CREATE
TABLE
IF
NOT
EXISTS
fz_grades
(
CREATE
TABLE
IF
NOT
EXISTS
fz_grades
(
id
VARCHAR
(
64
)
NOT
NULL
COMMENT
'雪花主键'
,
id
VARCHAR
(
64
)
NOT
NULL
COMMENT
'雪花主键'
,
...
@@ -31,7 +32,27 @@ delimiter $$
...
@@ -31,7 +32,27 @@ delimiter $$
drop
procedure
if
exists
migrate_student_score_management
$$
drop
procedure
if
exists
migrate_student_score_management
$$
create
procedure
migrate_student_score_management
()
create
procedure
migrate_student_score_management
()
begin
begin
-- 增量上报和单个学员详情均先按考试、学员、题号缩小范围。
declare
paper_column_type
varchar
(
255
);
-- 实训考试不绑定本系统试卷。沿用数据库原字段类型,仅把旧环境的非空约束放开。
if
exists
(
select
1
from
information_schema
.
columns
where
table_schema
=
database
()
and
table_name
=
'exam'
and
column_name
=
'paper_id'
and
is_nullable
=
'NO'
)
then
select
column_type
into
paper_column_type
from
information_schema
.
columns
where
table_schema
=
database
()
and
table_name
=
'exam'
and
column_name
=
'paper_id'
;
set
@
paper_nullable_sql
=
concat
(
'alter table exam modify column paper_id '
,
paper_column_type
,
' null comment
''
理论试卷ID;实训考试为空
''
'
);
prepare
paper_nullable_stmt
from
@
paper_nullable_sql
;
execute
paper_nullable_stmt
;
deallocate
prepare
paper_nullable_stmt
;
end
if
;
-- 完整成绩上报和单个学员详情均先按考试、学员、题号缩小范围。
if
not
exists
(
if
not
exists
(
select
1
from
information_schema
.
statistics
select
1
from
information_schema
.
statistics
where
table_schema
=
database
()
and
table_name
=
'fz_grades'
where
table_schema
=
database
()
and
table_name
=
'fz_grades'
...
@@ -57,8 +78,92 @@ drop procedure if exists migrate_student_score_management$$
...
@@ -57,8 +78,92 @@ drop procedure if exists migrate_student_score_management$$
delimiter
;
delimiter
;
--
-- 将旧接口已经保存、能够安全匹配的实训成绩汇总为“已交卷、待教师复核”。
-- 条件刻意排除已经发布的考试/学员以及超出考试总分的数据,脚本重复执行结果不变。
--
UPDATE
exam_student
es
INNER
JOIN
exam
e
ON
e
.
id
=
es
.
exam_id
AND
e
.
type
=
'实训'
AND
IFNULL
(
e
.
mark_flag
,
0
)
=
0
INNER
JOIN
(
SELECT
latest_grade
.
exam_id
,
latest_grade
.
user_id
,
SUM
(
IFNULL
(
latest_grade
.
score
,
0
))
AS
total_score
,
MIN
(
latest_grade
.
start_time
)
AS
first_start_time
,
MAX
(
latest_grade
.
submission_time
)
AS
last_submission_time
FROM
fz_grades
latest_grade
INNER
JOIN
(
SELECT
exam_id
,
user_id
,
code
,
MAX
(
id
)
AS
id
FROM
fz_grades
GROUP
BY
exam_id
,
user_id
,
code
)
latest
ON
latest
.
id
=
latest_grade
.
id
GROUP
BY
latest_grade
.
exam_id
,
latest_grade
.
user_id
)
legacy
ON
legacy
.
exam_id
=
es
.
exam_id
AND
legacy
.
user_id
=
es
.
student_id
SET
es
.
score
=
legacy
.
total_score
,
es
.
start_time
=
CASE
WHEN
legacy
.
first_start_time
IS
NULL
THEN
NULL
ELSE
UNIX_TIMESTAMP
(
legacy
.
first_start_time
)
*
1000
END
,
es
.
end_time
=
CASE
WHEN
legacy
.
last_submission_time
IS
NULL
THEN
NULL
ELSE
UNIX_TIMESTAMP
(
legacy
.
last_submission_time
)
*
1000
END
,
es
.
answer_time
=
CASE
WHEN
legacy
.
last_submission_time
IS
NULL
THEN
NULL
ELSE
DATE_FORMAT
(
legacy
.
last_submission_time
,
'%Y-%m-%d %H:%i:%s'
)
END
,
es
.
duration
=
CASE
WHEN
legacy
.
first_start_time
IS
NULL
OR
legacy
.
last_submission_time
IS
NULL
OR
legacy
.
last_submission_time
<
legacy
.
first_start_time
THEN
NULL
ELSE
CONCAT
(
TIMESTAMPDIFF
(
MINUTE
,
legacy
.
first_start_time
,
legacy
.
last_submission_time
),
'分钟'
)
END
,
es
.
submit
=
1
,
es
.
mark_flag
=
0
WHERE
IFNULL
(
es
.
mark_flag
,
0
)
=
0
AND
e
.
total_score
IS
NOT
NULL
AND
e
.
total_score
>
0
AND
legacy
.
total_score
BETWEEN
0
AND
e
.
total_score
;
-- 部署后可使用以下只读查询定位历史重复题号;应用会按最大ID读取最新版本,不会丢失原始记录。
-- 部署后可使用以下只读查询定位历史重复题号;应用会按最大ID读取最新版本,不会丢失原始记录。
select
exam_id
,
user_id
,
code
,
count
(
*
)
as
duplicate_count
select
exam_id
,
user_id
,
code
,
count
(
*
)
as
duplicate_count
from
fz_grades
from
fz_grades
group
by
exam_id
,
user_id
,
code
group
by
exam_id
,
user_id
,
code
having
count
(
*
)
>
1
;
having
count
(
*
)
>
1
;
-- 迁移异常核对清单:这些数据不会自动改变exam_student或发布状态,需要人工确认。
SELECT
legacy
.
exam_id
,
legacy
.
user_id
,
legacy
.
total_score
,
e
.
type
AS
exam_type
,
e
.
total_score
AS
configured_total_score
,
CASE
WHEN
e
.
id
IS
NULL
THEN
'考试不存在'
WHEN
e
.
type
<>
'实训'
THEN
'考试不是实训类型'
WHEN
es
.
id
IS
NULL
THEN
'学员不在应考名单'
WHEN
IFNULL
(
e
.
mark_flag
,
0
)
=
1
OR
IFNULL
(
es
.
mark_flag
,
0
)
=
1
THEN
'成绩已经发布'
WHEN
e
.
total_score
IS
NULL
OR
e
.
total_score
<=
0
THEN
'考试总分未配置'
WHEN
legacy
.
total_score
<
0
OR
legacy
.
total_score
>
e
.
total_score
THEN
'汇总分数超出范围'
END
AS
exception_reason
FROM
(
SELECT
latest_grade
.
exam_id
,
latest_grade
.
user_id
,
SUM
(
IFNULL
(
latest_grade
.
score
,
0
))
AS
total_score
FROM
fz_grades
latest_grade
INNER
JOIN
(
SELECT
exam_id
,
user_id
,
code
,
MAX
(
id
)
AS
id
FROM
fz_grades
GROUP
BY
exam_id
,
user_id
,
code
)
latest
ON
latest
.
id
=
latest_grade
.
id
GROUP
BY
latest_grade
.
exam_id
,
latest_grade
.
user_id
)
legacy
LEFT
JOIN
exam
e
ON
e
.
id
=
legacy
.
exam_id
LEFT
JOIN
exam_student
es
ON
es
.
exam_id
=
legacy
.
exam_id
AND
es
.
student_id
=
legacy
.
user_id
WHERE
e
.
id
IS
NULL
OR
e
.
type
<>
'实训'
OR
es
.
id
IS
NULL
OR
IFNULL
(
e
.
mark_flag
,
0
)
=
1
OR
IFNULL
(
es
.
mark_flag
,
0
)
=
1
OR
e
.
total_score
IS
NULL
OR
e
.
total_score
<=
0
OR
legacy
.
total_score
<
0
OR
legacy
.
total_score
>
e
.
total_score
ORDER
BY
legacy
.
exam_id
,
legacy
.
user_id
;
practical-business/src/main/resources/student-score-management-api.md
View file @
0e26d1b5
...
@@ -11,7 +11,7 @@ JWT解析当前用户并校验 `phone_role.role_name=管理员`。本模块只
...
@@ -11,7 +11,7 @@ JWT解析当前用户并校验 `phone_role.role_name=管理员`。本模块只
-
历史考试指
`考试开始时间 + 时长 <= 当前时间`
。
-
历史考试指
`考试开始时间 + 时长 <= 当前时间`
。
-
理论成绩必须同时满足
`exam.mark_flag=1`
、
`exam_student.mark_flag=1`
才是正式成绩。
-
理论成绩必须同时满足
`exam.mark_flag=1`
、
`exam_student.mark_flag=1`
才是正式成绩。
-
实训成绩
在
仿真系统
提交
`submissionTime`
后自动汇总并
设置上述发布标记。
-
实训成绩
由
仿真系统
整份上报后进入待复核;首席考评教师确认发布后才
设置上述发布标记。
-
待批阅场次可返回应考、实考人数,但平均分、合格率和个人分数为
`null`
。
-
待批阅场次可返回应考、实考人数,但平均分、合格率和个人分数为
`null`
。
-
合格率分母为已经实考且成绩正式发布的人数,缺考学员不计为不合格。
-
合格率分母为已经实考且成绩正式发布的人数,缺考学员不计为不合格。
...
@@ -73,7 +73,7 @@ JWT解析当前用户并校验 `phone_role.role_name=管理员`。本模块只
...
@@ -73,7 +73,7 @@ JWT解析当前用户并校验 `phone_role.role_name=管理员`。本模块只
响应类型为
`application/vnd.openxmlformats-officedocument.spreadsheetml.sheet`
,文件名通过
响应类型为
`application/vnd.openxmlformats-officedocument.spreadsheetml.sheet`
,文件名通过
RFC 5987 UTF-8编码。未发布考试禁止导出。
RFC 5987 UTF-8编码。未发布考试禁止导出。
## 6. 仿真实训
逐题增量
上报
## 6. 仿真实训
完整成绩
上报
`POST /fz/grades/receive`
`POST /fz/grades/receive`
...
@@ -96,7 +96,7 @@ RFC 5987 UTF-8编码。未发布考试禁止导出。
...
@@ -96,7 +96,7 @@ RFC 5987 UTF-8编码。未发布考试禁止导出。
]
]
```
```
-
`examId
/
userId
/code/score`
必填,考试必须为实训,学员必须属于本场应考名单
。
-
一次请求只能包含同一
`examId
+
userId
`
的一份完整成绩,
`code`
不得重复
。
-
同一
`examId
+
userId
+
code
`
再次上报会更新已有记录,不会新增业务重复题目
。
-
`examId
/
userId
/
code
/score`
必填,考试必须为实训,学员必须属于本场应考名单,汇总不得超过考试总分
。
-
未传
`submissionTime`
只保存增量明细;任一项传值时汇总该学员所有题目的最新分数并
发布。
-
首次成功后进入教师待复核,不会自动对管理员成绩页或学员端
发布。
-
已发布后
完全相同的重试返回成功;
新增题目或修改任何已发布内容会被拒绝
。
-
忽略服务端主键和数组顺序后,内容
完全相同的
网络
重试返回成功;
任何变化均被拒绝,只能由教师复核调整
。
practical-business/src/main/resources/teacher-score-management-api.md
View file @
0e26d1b5
...
@@ -56,6 +56,7 @@
...
@@ -56,6 +56,7 @@
"examId"
:
101
,
"examId"
:
101
,
"classId"
:
12
,
"classId"
:
12
,
"examName"
:
"污泥脱水工艺月考"
,
"examName"
:
"污泥脱水工艺月考"
,
"examType"
:
"实训"
,
"className"
:
"净化1班"
,
"className"
:
"净化1班"
,
"examTime"
:
"2026-08-10 09:00:00"
,
"examTime"
:
"2026-08-10 09:00:00"
,
"duration"
:
90
,
"duration"
:
90
,
...
@@ -104,6 +105,7 @@
...
@@ -104,6 +105,7 @@
"idCard"
:
"310000********0001"
,
"idCard"
:
"310000********0001"
,
"className"
:
"净化1班"
,
"className"
:
"净化1班"
,
"examName"
:
"污泥脱水工艺月考"
,
"examName"
:
"污泥脱水工艺月考"
,
"examType"
:
"实训"
,
"submitted"
:
true
,
"submitted"
:
true
,
"published"
:
true
,
"published"
:
true
,
"score"
:
88.5
,
"score"
:
88.5
,
...
...
practical-business/src/test/java/com/platform/business/mapper/ScoreAdminMapperXmlTest.java
View file @
0e26d1b5
...
@@ -33,9 +33,21 @@ class ScoreAdminMapperXmlTest {
...
@@ -33,9 +33,21 @@ class ScoreAdminMapperXmlTest {
assertTrue
(
configuration
.
hasStatement
(
assertTrue
(
configuration
.
hasStatement
(
"com.platform.business.mapper.FzGradesMapper.lockExamStudent"
));
"com.platform.business.mapper.FzGradesMapper.lockExamStudent"
));
assertTrue
(
configuration
.
hasStatement
(
assertTrue
(
configuration
.
hasStatement
(
"com.platform.business.mapper.FzGradesMapper.
updateByBusinessKey
"
));
"com.platform.business.mapper.FzGradesMapper.
lockPracticeExam
"
));
assertTrue
(
configuration
.
hasStatement
(
assertTrue
(
configuration
.
hasStatement
(
"com.platform.business.mapper.FzGradesMapper.publishPracticeStudent"
));
"com.platform.business.mapper.FzGradesMapper.submitPracticeStudent"
));
}
@Test
void
examReviewMapperShouldRegisterPracticeReviewStatements
()
throws
Exception
{
Configuration
configuration
=
parse
(
"com/platform/business/mapper/ExamReviewMapper.xml"
);
assertTrue
(
configuration
.
hasStatement
(
"com.platform.business.mapper.ExamReviewMapper.queryPracticeItems"
));
assertTrue
(
configuration
.
hasStatement
(
"com.platform.business.mapper.ExamReviewMapper.lockPracticeItems"
));
assertTrue
(
configuration
.
hasStatement
(
"com.platform.business.mapper.ExamReviewMapper.calculatePracticeScore"
));
}
}
private
Configuration
parse
(
String
resource
)
throws
Exception
{
private
Configuration
parse
(
String
resource
)
throws
Exception
{
...
...
practical-business/src/test/java/com/platform/business/service/impl/ExamAdminServiceImplTest.java
View file @
0e26d1b5
...
@@ -97,6 +97,42 @@ class ExamAdminServiceImplTest {
...
@@ -97,6 +97,42 @@ class ExamAdminServiceImplTest {
assertFalse
(
studentsCaptor
.
getValue
().
get
(
0
).
getSubmit
());
assertFalse
(
studentsCaptor
.
getValue
().
get
(
0
).
getSubmit
());
}
}
@Test
void
createPracticeShouldUseManualTotalAndKeepPaperEmpty
()
{
ExamAdminSaveDTO
request
=
validCreateRequest
();
request
.
setType
(
"实训"
);
request
.
setPaperId
(
null
);
request
.
setTotalScore
(
new
BigDecimal
(
"120"
));
request
.
setPassScore
(
null
);
mockWritableClass
();
mockValidRelationships
();
when
(
examMapper
.
countAdminExamDuplicateName
(
1
,
"测试考试"
,
null
)).
thenReturn
(
0
);
when
(
examMapper
.
selectAdminExamConflicts
(
any
(),
eq
(
90
),
eq
(
1
),
eq
(
"teacher-1"
),
eq
(
"teacher-2"
),
anyList
(),
eq
(
null
)))
.
thenReturn
(
Collections
.
emptyList
());
when
(
examMapper
.
insert
(
any
(
ExamEntity
.
class
))).
thenAnswer
(
invocation
->
{
ExamEntity
entity
=
invocation
.
getArgument
(
0
);
entity
.
setId
(
100
);
return
1
;
});
when
(
examStudentService
.
saveBatch
(
anyList
())).
thenReturn
(
true
);
ExamAdminDetailVO
detail
=
new
ExamAdminDetailVO
();
detail
.
setId
(
100
);
detail
.
setExamTime
(
request
.
getExamTime
());
detail
.
setDuration
(
90
);
when
(
examMapper
.
selectAdminExamDetail
(
100
)).
thenReturn
(
detail
);
when
(
examMapper
.
selectAdminExamStudentIds
(
100
)).
thenReturn
(
request
.
getStudentIds
());
service
.
create
(
request
);
ArgumentCaptor
<
ExamEntity
>
captor
=
ArgumentCaptor
.
forClass
(
ExamEntity
.
class
);
verify
(
examMapper
).
insert
(
captor
.
capture
());
assertEquals
(
null
,
captor
.
getValue
().
getPaperId
());
assertEquals
(
new
BigDecimal
(
"120.00"
),
captor
.
getValue
().
getTotalScore
());
assertEquals
(
new
BigDecimal
(
"72.00"
),
captor
.
getValue
().
getPassScore
());
verify
(
theoreticalPaperService
,
never
()).
getById
(
any
());
}
@Test
@Test
void
createShouldRejectPaperFromAnotherLevel
()
{
void
createShouldRejectPaperFromAnotherLevel
()
{
ExamAdminSaveDTO
request
=
validCreateRequest
();
ExamAdminSaveDTO
request
=
validCreateRequest
();
...
@@ -182,11 +218,35 @@ class ExamAdminServiceImplTest {
...
@@ -182,11 +218,35 @@ class ExamAdminServiceImplTest {
verify
(
examMapper
,
never
()).
updateAdminExam
(
any
(
ExamEntity
.
class
));
verify
(
examMapper
,
never
()).
updateAdminExam
(
any
(
ExamEntity
.
class
));
}
}
@Test
void
updateShouldRejectChangingExamType
()
{
ExamEntity
existing
=
new
ExamEntity
();
existing
.
setId
(
7
);
existing
.
setClassId
(
1
);
existing
.
setType
(
"理论"
);
existing
.
setExamTime
(
Timestamp
.
valueOf
(
"2099-09-18 09:00:00"
));
when
(
examMapper
.
selectAdminExamForUpdate
(
7
)).
thenReturn
(
existing
);
when
(
examMapper
.
countAdminExamAttempts
(
7
)).
thenReturn
(
0
);
when
(
examMapper
.
lockAdminExamClass
(
1
)).
thenReturn
(
1
);
when
(
examMapper
.
selectAdminExamClass
(
1
)).
thenReturn
(
managedClass
());
when
(
examMapper
.
selectAdminExamStudentIds
(
7
)).
thenReturn
(
Collections
.
singletonList
(
"student-1"
));
ExamAdminUpdateDTO
request
=
new
ExamAdminUpdateDTO
();
request
.
setName
(
"修改考试"
);
request
.
setType
(
"实训"
);
BusinessException
error
=
assertThrows
(
BusinessException
.
class
,
()
->
service
.
update
(
7
,
request
));
assertEquals
(
"考试类型创建后不能修改"
,
error
.
getMessage
());
verify
(
examMapper
,
never
()).
updateAdminExam
(
any
(
ExamEntity
.
class
));
}
@Test
@Test
void
updateShouldChangeOnlyEditableFieldsAndKeepScoreSnapshot
()
{
void
updateShouldChangeOnlyEditableFieldsAndKeepScoreSnapshot
()
{
ExamEntity
existing
=
new
ExamEntity
();
ExamEntity
existing
=
new
ExamEntity
();
existing
.
setId
(
7
);
existing
.
setId
(
7
);
existing
.
setClassId
(
1
);
existing
.
setClassId
(
1
);
existing
.
setType
(
"实训"
);
existing
.
setExamTime
(
Timestamp
.
valueOf
(
"2099-09-18 09:00:00"
));
existing
.
setExamTime
(
Timestamp
.
valueOf
(
"2099-09-18 09:00:00"
));
existing
.
setInvigilationId
(
"teacher-2"
);
existing
.
setInvigilationId
(
"teacher-2"
);
existing
.
setPaperId
(
"paper-1"
);
existing
.
setPaperId
(
"paper-1"
);
...
...
practical-business/src/test/java/com/platform/business/service/impl/ExamReviewServiceImplTest.java
View file @
0e26d1b5
...
@@ -8,8 +8,12 @@ import com.platform.business.model.dto.ExamReviewTaskQueryDTO;
...
@@ -8,8 +8,12 @@ import com.platform.business.model.dto.ExamReviewTaskQueryDTO;
import
com.platform.business.model.entity.ExamEntity
;
import
com.platform.business.model.entity.ExamEntity
;
import
com.platform.business.model.entity.ExamReviewScoreLogEntity
;
import
com.platform.business.model.entity.ExamReviewScoreLogEntity
;
import
com.platform.business.model.entity.ExamStudentEntity
;
import
com.platform.business.model.entity.ExamStudentEntity
;
import
com.platform.business.model.entity.FzGradesEntity
;
import
com.platform.business.model.entity.TheoreticalPaperStudentDetailEntity
;
import
com.platform.business.model.entity.TheoreticalPaperStudentDetailEntity
;
import
com.platform.business.model.vo.ExamReviewTaskVO
;
import
com.platform.business.model.vo.ExamReviewTaskVO
;
import
com.platform.business.model.vo.ExamReviewPaperVO
;
import
com.platform.business.model.vo.ExamReviewPracticeItemVO
;
import
com.platform.business.model.vo.ExamReviewStudentVO
;
import
com.platform.exception.BusinessException
;
import
com.platform.exception.BusinessException
;
import
org.junit.jupiter.api.Test
;
import
org.junit.jupiter.api.Test
;
import
org.junit.jupiter.api.extension.ExtendWith
;
import
org.junit.jupiter.api.extension.ExtendWith
;
...
@@ -90,6 +94,10 @@ class ExamReviewServiceImplTest {
...
@@ -90,6 +94,10 @@ class ExamReviewServiceImplTest {
question
.
setType
(
"主观题"
);
question
.
setType
(
"主观题"
);
question
.
setScore
(
5
D
);
question
.
setScore
(
5
D
);
when
(
examReviewMapper
.
lockStudent
(
10
,
"teacher-1"
)).
thenReturn
(
student
);
when
(
examReviewMapper
.
lockStudent
(
10
,
"teacher-1"
)).
thenReturn
(
student
);
ExamReviewTaskVO
task
=
new
ExamReviewTaskVO
();
task
.
setExamId
(
100
);
task
.
setExamType
(
"理论"
);
when
(
examReviewMapper
.
findTask
(
100
,
"teacher-1"
)).
thenReturn
(
task
);
when
(
examReviewMapper
.
lockQuestions
(
any
(),
anyInt
(),
any
()))
when
(
examReviewMapper
.
lockQuestions
(
any
(),
anyInt
(),
any
()))
.
thenReturn
(
Collections
.
singletonList
(
question
));
.
thenReturn
(
Collections
.
singletonList
(
question
));
...
@@ -186,4 +194,110 @@ class ExamReviewServiceImplTest {
...
@@ -186,4 +194,110 @@ class ExamReviewServiceImplTest {
verify
(
examReviewMapper
).
publishStudent
(
11
,
70
D
);
verify
(
examReviewMapper
).
publishStudent
(
11
,
70
D
);
}
}
@Test
void
practiceScoreAdjustmentShouldRejectProjectedTotalAboveExamTotal
()
{
ExamStudentEntity
student
=
ExamStudentEntity
.
builder
()
.
id
(
20
).
examId
(
200
).
studentId
(
"student-2"
)
.
submit
(
true
).
markFlag
(
false
).
build
();
ExamReviewTaskVO
task
=
new
ExamReviewTaskVO
();
task
.
setExamId
(
200
);
task
.
setExamType
(
"实训"
);
task
.
setPaperTotal
(
100
D
);
FzGradesEntity
locked
=
new
FzGradesEntity
();
locked
.
setId
(
"practice-1"
);
locked
.
setExamId
(
200
);
locked
.
setUserId
(
"student-2"
);
locked
.
setScore
(
20
D
);
when
(
examReviewMapper
.
lockStudent
(
20
,
"teacher-1"
)).
thenReturn
(
student
);
when
(
examReviewMapper
.
findTask
(
200
,
"teacher-1"
)).
thenReturn
(
task
);
when
(
examReviewMapper
.
lockPracticeItems
(
any
(),
anyInt
(),
any
()))
.
thenReturn
(
Collections
.
singletonList
(
locked
));
when
(
examReviewMapper
.
calculatePracticeScore
(
200
,
"student-2"
)).
thenReturn
(
90
D
);
ExamReviewScoreItemDTO
item
=
new
ExamReviewScoreItemDTO
();
item
.
setQuestionId
(
"practice-1"
);
item
.
setScore
(
new
BigDecimal
(
"31"
));
ExamReviewSaveDTO
request
=
new
ExamReviewSaveDTO
();
request
.
setScores
(
Collections
.
singletonList
(
item
));
BusinessException
error
=
assertThrows
(
BusinessException
.
class
,
()
->
examReviewService
.
saveScores
(
20
,
request
,
"teacher-1"
));
assertEquals
(
"调整后的实训总分不能超过考试总分"
,
error
.
getMessage
());
verify
(
examReviewMapper
,
never
()).
updatePracticeScore
(
any
(),
anyDouble
());
verify
(
scoreLogMapper
,
never
()).
insert
(
any
());
}
@Test
void
practiceScoreAdjustmentShouldUpdatePendingTotalAndAudit
()
{
ExamStudentEntity
student
=
ExamStudentEntity
.
builder
()
.
id
(
20
).
examId
(
200
).
studentId
(
"student-2"
)
.
submit
(
true
).
markFlag
(
false
).
build
();
ExamReviewTaskVO
task
=
new
ExamReviewTaskVO
();
task
.
setExamId
(
200
);
task
.
setExamType
(
"实训"
);
task
.
setPaperTotal
(
100
D
);
FzGradesEntity
locked
=
new
FzGradesEntity
();
locked
.
setId
(
"practice-1"
);
locked
.
setExamId
(
200
);
locked
.
setUserId
(
"student-2"
);
locked
.
setScore
(
20
D
);
when
(
examReviewMapper
.
lockStudent
(
20
,
"teacher-1"
)).
thenReturn
(
student
);
when
(
examReviewMapper
.
findTask
(
200
,
"teacher-1"
)).
thenReturn
(
task
);
when
(
examReviewMapper
.
lockPracticeItems
(
any
(),
anyInt
(),
any
()))
.
thenReturn
(
Collections
.
singletonList
(
locked
));
when
(
examReviewMapper
.
calculatePracticeScore
(
200
,
"student-2"
)).
thenReturn
(
80
D
);
when
(
examReviewMapper
.
updatePracticeScore
(
"practice-1"
,
25
D
)).
thenReturn
(
1
);
when
(
examReviewMapper
.
updatePendingPracticeTotal
(
20
,
85
D
)).
thenReturn
(
1
);
when
(
scoreLogMapper
.
insert
(
any
(
ExamReviewScoreLogEntity
.
class
))).
thenReturn
(
1
);
ExamReviewStudentVO
reviewStudent
=
new
ExamReviewStudentVO
();
reviewStudent
.
setExamStudentId
(
20
);
reviewStudent
.
setExamId
(
200
);
reviewStudent
.
setStudentId
(
"student-2"
);
when
(
examReviewMapper
.
findStudent
(
20
,
"teacher-1"
)).
thenReturn
(
reviewStudent
);
ExamReviewPracticeItemVO
responseItem
=
new
ExamReviewPracticeItemVO
();
responseItem
.
setId
(
"practice-1"
);
responseItem
.
setScore
(
25
D
);
when
(
examReviewMapper
.
queryPracticeItems
(
200
,
"student-2"
))
.
thenReturn
(
Collections
.
singletonList
(
responseItem
));
ExamReviewScoreItemDTO
item
=
new
ExamReviewScoreItemDTO
();
item
.
setQuestionId
(
"practice-1"
);
item
.
setScore
(
new
BigDecimal
(
"25"
));
item
.
setComment
(
"复核调整"
);
ExamReviewSaveDTO
request
=
new
ExamReviewSaveDTO
();
request
.
setScores
(
Collections
.
singletonList
(
item
));
ExamReviewPaperVO
result
=
examReviewService
.
saveScores
(
20
,
request
,
"teacher-1"
);
assertEquals
(
25
D
,
result
.
getCurrentTotalScore
());
verify
(
examReviewMapper
).
updatePendingPracticeTotal
(
20
,
85
D
);
verify
(
scoreLogMapper
).
insert
(
any
(
ExamReviewScoreLogEntity
.
class
));
}
@Test
void
publishPracticeShouldSumReviewedItemsWithoutTheoryQueries
()
{
ExamEntity
exam
=
new
ExamEntity
();
exam
.
setId
(
200
);
exam
.
setType
(
"实训"
);
exam
.
setTotalScore
(
new
BigDecimal
(
"100"
));
ExamStudentEntity
student
=
ExamStudentEntity
.
builder
()
.
id
(
20
).
examId
(
200
).
studentId
(
"student-2"
)
.
score
(
80
D
).
submit
(
true
).
markFlag
(
false
).
build
();
when
(
examReviewMapper
.
lockTask
(
200
,
"teacher-1"
)).
thenReturn
(
exam
);
when
(
examReviewMapper
.
lockSubmittedStudents
(
200
))
.
thenReturn
(
Collections
.
singletonList
(
student
));
when
(
examReviewMapper
.
countSubmittedWithoutPracticeItems
(
200
)).
thenReturn
(
0
);
when
(
examReviewMapper
.
calculatePracticeScore
(
200
,
"student-2"
)).
thenReturn
(
88
D
);
when
(
examReviewMapper
.
publishStudent
(
20
,
88
D
)).
thenReturn
(
1
);
when
(
examReviewMapper
.
publishTask
(
200
)).
thenReturn
(
1
);
when
(
scoreLogMapper
.
insert
(
any
(
ExamReviewScoreLogEntity
.
class
))).
thenReturn
(
1
);
assertTrue
(
examReviewService
.
publish
(
200
,
"teacher-1"
));
verify
(
examReviewMapper
).
publishStudent
(
20
,
88
D
);
verify
(
examReviewMapper
,
never
()).
countSubmittedWithoutPaper
(
200
);
verify
(
examReviewMapper
,
never
()).
countUnscoredSubjective
(
200
);
}
}
}
practical-business/src/test/java/com/platform/business/service/impl/FzGradesServiceImplTest.java
View file @
0e26d1b5
package
com.platform.business.service.impl
;
package
com.platform.business.service.impl
;
import
com.platform.business.mapper.ExamMapper
;
import
com.platform.business.mapper.FzGradesMapper
;
import
com.platform.business.mapper.FzGradesMapper
;
import
com.platform.business.model.dto.FzGradesDTO
;
import
com.platform.business.model.dto.FzGradesDTO
;
import
com.platform.business.model.entity.ExamEntity
;
import
com.platform.business.model.entity.ExamEntity
;
...
@@ -10,13 +9,14 @@ import com.platform.exception.BusinessException;
...
@@ -10,13 +9,14 @@ import com.platform.exception.BusinessException;
import
org.junit.jupiter.api.BeforeEach
;
import
org.junit.jupiter.api.BeforeEach
;
import
org.junit.jupiter.api.Test
;
import
org.junit.jupiter.api.Test
;
import
org.junit.jupiter.api.extension.ExtendWith
;
import
org.junit.jupiter.api.extension.ExtendWith
;
import
org.mockito.ArgumentCaptor
;
import
org.mockito.Mock
;
import
org.mockito.Mock
;
import
org.mockito.junit.jupiter.MockitoExtension
;
import
org.mockito.junit.jupiter.MockitoExtension
;
import
org.springframework.test.util.ReflectionTestUtils
;
import
org.springframework.test.util.ReflectionTestUtils
;
import
java.math.BigDecimal
;
import
java.math.BigDecimal
;
import
java.util.Arrays
;
import
java.util.Collections
;
import
java.util.Collections
;
import
java.util.Date
;
import
static
org
.
junit
.
jupiter
.
api
.
Assertions
.
assertEquals
;
import
static
org
.
junit
.
jupiter
.
api
.
Assertions
.
assertEquals
;
import
static
org
.
junit
.
jupiter
.
api
.
Assertions
.
assertThrows
;
import
static
org
.
junit
.
jupiter
.
api
.
Assertions
.
assertThrows
;
...
@@ -27,109 +27,133 @@ import static org.mockito.Mockito.never;
...
@@ -27,109 +27,133 @@ import static org.mockito.Mockito.never;
import
static
org
.
mockito
.
Mockito
.
verify
;
import
static
org
.
mockito
.
Mockito
.
verify
;
import
static
org
.
mockito
.
Mockito
.
when
;
import
static
org
.
mockito
.
Mockito
.
when
;
/** 仿真实训
成绩的增量保存、最终发布、幂等重试和越权校验
测试。 */
/** 仿真实训
完整成绩接收、严格幂等、待复核落账及越权边界
测试。 */
@ExtendWith
(
MockitoExtension
.
class
)
@ExtendWith
(
MockitoExtension
.
class
)
class
FzGradesServiceImplTest
{
class
FzGradesServiceImplTest
{
@Mock
@Mock
private
FzGradesMapper
fzGradesMapper
;
private
FzGradesMapper
mapper
;
@Mock
private
ExamMapper
examMapper
;
private
FzGradesServiceImpl
service
;
private
FzGradesServiceImpl
service
;
@BeforeEach
@BeforeEach
void
setUp
()
{
void
setUp
()
{
service
=
new
FzGradesServiceImpl
();
service
=
new
FzGradesServiceImpl
();
ReflectionTestUtils
.
setField
(
service
,
"baseMapper"
,
fzGradesMapper
);
ReflectionTestUtils
.
setField
(
service
,
"baseMapper"
,
mapper
);
ReflectionTestUtils
.
setField
(
service
,
"examMapper"
,
examMapper
);
}
}
@Test
@Test
void
incrementalItemShouldSaveWithoutPublishing
()
{
void
firstCompleteSnapshotShouldSaveAndRemainPendingReview
()
{
mockCandidate
(
false
);
mockWritableCandidate
();
when
(
fzGradesMapper
.
selectLatestItems
(
1
,
"student-1"
)).
thenReturn
(
Collections
.
emptyList
());
when
(
mapper
.
selectLatestItems
(
1
,
"student-1"
)).
thenReturn
(
Collections
.
emptyList
());
when
(
fzGradesMapper
.
insert
(
any
(
FzGradesEntity
.
class
))).
thenReturn
(
1
);
when
(
mapper
.
insert
(
any
(
FzGradesEntity
.
class
))).
thenReturn
(
1
);
when
(
mapper
.
submitPracticeStudent
(
eq
(
9
),
eq
(
75
D
),
any
(),
any
(),
any
(),
any
()))
.
thenReturn
(
1
);
assertTrue
(
service
.
receive
(
Collections
.
singletonList
(
item
(
null
,
2
0
D
))));
assertTrue
(
service
.
receive
(
Arrays
.
asList
(
item
(
"Q-2"
,
25
D
),
item
(
"Q-1"
,
5
0
D
))));
verify
(
fzGradesMapper
).
insert
(
any
(
FzGradesEntity
.
class
));
ArgumentCaptor
<
FzGradesEntity
>
captor
=
ArgumentCaptor
.
forClass
(
FzGradesEntity
.
class
);
verify
(
fzGradesMapper
,
never
()).
publishPracticeStudent
(
verify
(
mapper
,
org
.
mockito
.
Mockito
.
times
(
2
)).
insert
(
captor
.
capture
());
any
(),
any
(),
any
(),
any
(),
any
(),
any
());
// 服务端按code形成稳定快照,且绝不接受第三方指定本系统主键。
assertEquals
(
"Q-1"
,
captor
.
getAllValues
().
get
(
0
).
getCode
());
assertEquals
(
null
,
captor
.
getAllValues
().
get
(
0
).
getId
());
verify
(
mapper
).
submitPracticeStudent
(
eq
(
9
),
eq
(
75
D
),
any
(),
any
(),
any
(),
any
());
}
}
@Test
@Test
void
submissionTimeShouldAggregateAndPublishOfficialScore
()
{
void
identicalReplayShouldBeIdempotentWithoutWriting
()
{
mockCandidate
(
false
);
mockWritableCandidate
();
Date
start
=
new
Date
(
System
.
currentTimeMillis
()
-
60_000L
);
when
(
mapper
.
selectLatestItems
(
1
,
"student-1"
))
Date
end
=
new
Date
();
.
thenReturn
(
Collections
.
singletonList
(
persisted
(
"Q-1"
,
50
D
)));
FzGradesEntity
persisted
=
new
FzGradesEntity
();
persisted
.
setCode
(
"Q-1"
);
assertTrue
(
service
.
receive
(
Collections
.
singletonList
(
item
(
"Q-1"
,
50
D
))));
persisted
.
setStartTime
(
start
);
when
(
fzGradesMapper
.
selectLatestItems
(
1
,
"student-1"
))
verify
(
mapper
,
never
()).
insert
(
any
(
FzGradesEntity
.
class
));
.
thenReturn
(
Collections
.
emptyList
())
verify
(
mapper
,
never
()).
submitPracticeStudent
(
any
(),
any
(),
any
(),
any
(),
any
(),
any
());
.
thenReturn
(
Collections
.
singletonList
(
persisted
));
}
when
(
fzGradesMapper
.
insert
(
any
(
FzGradesEntity
.
class
))).
thenReturn
(
1
);
when
(
fzGradesMapper
.
sumLatestScores
(
1
,
"student-1"
)).
thenReturn
(
75
D
);
@Test
when
(
fzGradesMapper
.
publishPracticeStudent
(
eq
(
9
),
eq
(
75
D
),
any
(),
any
(),
any
(),
any
()))
void
changedReplayShouldBeRejectedAfterFirstReceipt
()
{
.
thenReturn
(
1
);
mockWritableCandidate
();
when
(
fzGradesMapper
.
publishPracticeExam
(
eq
(
1
),
any
(
Date
.
class
))).
thenReturn
(
1
);
when
(
mapper
.
selectLatestItems
(
1
,
"student-1"
))
.
thenReturn
(
Collections
.
singletonList
(
persisted
(
"Q-1"
,
10
D
)));
BusinessException
error
=
assertThrows
(
BusinessException
.
class
,
()
->
service
.
receive
(
Collections
.
singletonList
(
item
(
"Q-1"
,
20
D
))));
assertEquals
(
"仿真实训成绩已经接收,后续只能由教师复核调整"
,
error
.
getMessage
());
verify
(
mapper
,
never
()).
insert
(
any
(
FzGradesEntity
.
class
));
}
@Test
void
mixedStudentsShouldBeRejectedBeforeLockingDatabase
()
{
FzGradesDTO
second
=
item
(
"Q-2"
,
20
D
);
second
.
setUserId
(
"student-2"
);
assertTrue
(
service
.
receive
(
Collections
.
singletonList
(
item
(
end
,
75
D
))));
assertThrows
(
BusinessException
.
class
,
()
->
service
.
receive
(
Arrays
.
asList
(
item
(
"Q-1"
,
10
D
),
second
)));
verify
(
fzGradesMapper
).
publishPracticeExam
(
eq
(
1
),
any
(
Date
.
class
));
verify
(
mapper
,
never
()).
lockPracticeExam
(
any
(
));
}
}
@Test
@Test
void
publishedScoreShouldRejectChangedReplay
()
{
void
totalAboveConfiguredScoreShouldBeRejected
()
{
mockCandidate
(
true
);
mockWritableCandidate
();
FzGradesEntity
persisted
=
new
FzGradesEntity
();
persisted
.
setExamId
(
1
);
persisted
.
setUserId
(
"student-1"
);
persisted
.
setCode
(
"Q-1"
);
persisted
.
setScore
(
10
D
);
when
(
fzGradesMapper
.
selectLatestItems
(
1
,
"student-1"
))
.
thenReturn
(
Collections
.
singletonList
(
persisted
));
BusinessException
error
=
assertThrows
(
BusinessException
.
class
,
BusinessException
error
=
assertThrows
(
BusinessException
.
class
,
()
->
service
.
receive
(
Collections
.
singletonList
(
item
(
null
,
2
0
D
))));
()
->
service
.
receive
(
Arrays
.
asList
(
item
(
"Q-1"
,
80
D
),
item
(
"Q-2"
,
3
0
D
))));
assertEquals
(
"仿真实训成绩已经发布,不能继续修改"
,
error
.
getMessage
());
assertEquals
(
"实训成绩汇总不能超过考试总分"
,
error
.
getMessage
());
verify
(
mapper
,
never
()).
insert
(
any
(
FzGradesEntity
.
class
));
}
}
@Test
@Test
void
studentOutsideCandidateListShouldBeRejectedBeforeWriting
()
{
void
studentOutsideCandidateListShouldBeRejectedBeforeWriting
()
{
when
(
fzGradesMapper
.
lockExamStudent
(
1
,
"student-1"
)).
thenReturn
(
null
);
when
(
mapper
.
lockPracticeExam
(
1
)).
thenReturn
(
practiceExam
());
when
(
mapper
.
lockExamStudent
(
1
,
"student-1"
)).
thenReturn
(
null
);
assertThrows
(
BusinessException
.
class
,
assertThrows
(
BusinessException
.
class
,
()
->
service
.
receive
(
Collections
.
singletonList
(
item
(
null
,
10
D
))));
()
->
service
.
receive
(
Collections
.
singletonList
(
item
(
"Q-1"
,
10
D
))));
verify
(
fzGradesM
apper
,
never
()).
insert
(
any
(
FzGradesEntity
.
class
));
verify
(
m
apper
,
never
()).
insert
(
any
(
FzGradesEntity
.
class
));
}
}
private
void
mockCandidate
(
boolean
published
)
{
private
void
mockWritableCandidate
()
{
when
(
mapper
.
lockPracticeExam
(
1
)).
thenReturn
(
practiceExam
());
ExamStudentEntity
candidate
=
new
ExamStudentEntity
();
ExamStudentEntity
candidate
=
new
ExamStudentEntity
();
candidate
.
setId
(
9
);
candidate
.
setId
(
9
);
candidate
.
setExamId
(
1
);
candidate
.
setExamId
(
1
);
candidate
.
setStudentId
(
"student-1"
);
candidate
.
setStudentId
(
"student-1"
);
candidate
.
setMarkFlag
(
published
);
candidate
.
setMarkFlag
(
false
);
when
(
fzGradesMapper
.
lockExamStudent
(
1
,
"student-1"
)).
thenReturn
(
candidate
);
when
(
mapper
.
lockExamStudent
(
1
,
"student-1"
)).
thenReturn
(
candidate
);
}
private
ExamEntity
practiceExam
()
{
ExamEntity
exam
=
new
ExamEntity
();
ExamEntity
exam
=
new
ExamEntity
();
exam
.
setId
(
1
);
exam
.
setId
(
1
);
exam
.
setType
(
"实训"
);
exam
.
setType
(
"实训"
);
exam
.
setTotalScore
(
new
BigDecimal
(
"100"
));
exam
.
setTotalScore
(
new
BigDecimal
(
"100"
));
when
(
examMapper
.
selectById
(
1
)).
thenReturn
(
exam
);
exam
.
setMarkFlag
(
false
);
return
exam
;
}
}
private
FzGradesDTO
item
(
Date
submissionTim
e
,
Double
score
)
{
private
FzGradesDTO
item
(
String
cod
e
,
Double
score
)
{
FzGradesDTO
item
=
new
FzGradesDTO
();
FzGradesDTO
item
=
new
FzGradesDTO
();
item
.
setExamId
(
1
);
item
.
setExamId
(
1
);
item
.
setUserId
(
"student-1"
);
item
.
setUserId
(
"student-1"
);
item
.
setCode
(
"Q-1"
);
item
.
setCode
(
code
);
item
.
setTitle
(
"启动检查"
);
item
.
setScore
(
score
);
return
item
;
}
private
FzGradesEntity
persisted
(
String
code
,
Double
score
)
{
FzGradesEntity
item
=
new
FzGradesEntity
();
item
.
setId
(
"server-id"
);
item
.
setExamId
(
1
);
item
.
setUserId
(
"student-1"
);
item
.
setCode
(
code
);
item
.
setTitle
(
"启动检查"
);
item
.
setTitle
(
"启动检查"
);
item
.
setScore
(
score
);
item
.
setScore
(
score
);
item
.
setSubmissionTime
(
submissionTime
);
return
item
;
return
item
;
}
}
}
}
practical-business/src/test/java/com/platform/business/service/impl/TeacherScoreServiceImplTest.java
View file @
0e26d1b5
...
@@ -110,19 +110,19 @@ class TeacherScoreServiceImplTest {
...
@@ -110,19 +110,19 @@ class TeacherScoreServiceImplTest {
new
ByteArrayInputStream
(
response
.
getContentAsByteArray
())))
{
new
ByteArrayInputStream
(
response
.
getContentAsByteArray
())))
{
assertEquals
(
"成绩明细"
,
workbook
.
getSheetAt
(
0
).
getSheetName
());
assertEquals
(
"成绩明细"
,
workbook
.
getSheetAt
(
0
).
getSheetName
());
assertEquals
(
"参考状态"
,
workbook
.
getSheetAt
(
0
).
getRow
(
0
)
assertEquals
(
"参考状态"
,
workbook
.
getSheetAt
(
0
).
getRow
(
0
)
.
getCell
(
5
).
getStringCellValue
());
.
getCell
(
6
).
getStringCellValue
());
assertEquals
(
"实考"
,
workbook
.
getSheetAt
(
0
).
getRow
(
1
)
assertEquals
(
"实考"
,
workbook
.
getSheetAt
(
0
).
getRow
(
1
)
.
getCell
(
5
).
getStringCellValue
());
.
getCell
(
6
).
getStringCellValue
());
assertEquals
(
0
D
,
workbook
.
getSheetAt
(
0
).
getRow
(
1
)
assertEquals
(
0
D
,
workbook
.
getSheetAt
(
0
).
getRow
(
1
)
.
getCell
(
6
).
getNumericCellValue
());
.
getCell
(
7
).
getNumericCellValue
());
assertEquals
(
"否"
,
workbook
.
getSheetAt
(
0
).
getRow
(
1
)
assertEquals
(
"否"
,
workbook
.
getSheetAt
(
0
).
getRow
(
1
)
.
getCell
(
8
).
getStringCellValue
());
.
getCell
(
9
).
getStringCellValue
());
assertEquals
(
"缺考"
,
workbook
.
getSheetAt
(
0
).
getRow
(
2
)
assertEquals
(
"缺考"
,
workbook
.
getSheetAt
(
0
).
getRow
(
2
)
.
getCell
(
5
).
getStringCellValue
());
.
getCell
(
6
).
getStringCellValue
());
assertEquals
(
CellType
.
BLANK
,
workbook
.
getSheetAt
(
0
).
getRow
(
2
)
assertEquals
(
CellType
.
BLANK
,
workbook
.
getSheetAt
(
0
).
getRow
(
2
)
.
getCell
(
6
).
getCellType
());
.
getCell
(
7
).
getCellType
());
assertEquals
(
""
,
workbook
.
getSheetAt
(
0
).
getRow
(
2
)
assertEquals
(
""
,
workbook
.
getSheetAt
(
0
).
getRow
(
2
)
.
getCell
(
8
).
getStringCellValue
());
.
getCell
(
9
).
getStringCellValue
());
}
}
}
}
...
...
practical-business/src/test/java/com/platform/business/sql/PracticeScoreMigrationSqlTest.java
0 → 100644
View file @
0e26d1b5
package
com.platform.business.sql
;
import
org.junit.jupiter.api.Test
;
import
java.io.ByteArrayOutputStream
;
import
java.io.InputStream
;
import
java.nio.charset.StandardCharsets
;
import
static
org
.
junit
.
jupiter
.
api
.
Assertions
.
assertFalse
;
import
static
org
.
junit
.
jupiter
.
api
.
Assertions
.
assertTrue
;
/** 验证实训存量成绩只回填待复核状态,并保护已经发布或异常的数据。 */
class
PracticeScoreMigrationSqlTest
{
@Test
void
migrationShouldBackfillPendingScoresAndExposeAnomalies
()
throws
Exception
{
String
sql
=
resource
(
"sql/student_score_management.sql"
).
toLowerCase
();
assertTrue
(
sql
.
contains
(
"e.type = '实训'"
));
assertTrue
(
sql
.
contains
(
"es.mark_flag = 0"
));
assertTrue
(
sql
.
contains
(
"ifnull(e.mark_flag, 0) = 0"
));
assertTrue
(
sql
.
contains
(
"exception_reason"
));
assertTrue
(
sql
.
contains
(
"paper_id"
)
&&
sql
.
contains
(
"is_nullable = 'no'"
));
assertFalse
(
sql
.
contains
(
"delete from fz_grades"
));
}
private
String
resource
(
String
path
)
throws
Exception
{
try
(
InputStream
input
=
Thread
.
currentThread
().
getContextClassLoader
()
.
getResourceAsStream
(
path
))
{
assertTrue
(
input
!=
null
,
"迁移SQL资源必须存在:"
+
path
);
ByteArrayOutputStream
output
=
new
ByteArrayOutputStream
();
byte
[]
buffer
=
new
byte
[
4096
];
int
length
;
while
((
length
=
input
.
read
(
buffer
))
>=
0
)
{
output
.
write
(
buffer
,
0
,
length
);
}
return
new
String
(
output
.
toByteArray
(),
StandardCharsets
.
UTF_8
);
}
}
}
Prev
1
2
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