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
72c5471e
Commit
72c5471e
authored
Sep 08, 2026
by
wujipeng
Browse files
Merge remote-tracking branch 'origin/dev-v1.0' into dev-v1.0
parents
b49e611e
fd2d782a
Changes
5
Show whitespace changes
Inline
Side-by-side
practical-business/src/main/java/com/platform/business/service/TrainingRoomBookingService.java
View file @
72c5471e
...
@@ -34,7 +34,7 @@ public interface TrainingRoomBookingService extends IService<TrainingRoomBooking
...
@@ -34,7 +34,7 @@ public interface TrainingRoomBookingService extends IService<TrainingRoomBooking
/** 管理员查看指定日期和时段的机位状态,已停用实训室也可查看。 */
/** 管理员查看指定日期和时段的机位状态,已停用实训室也可查看。 */
List
<
TrainingRoomSeatVO
>
adminAvailability
(
String
roomId
,
String
bookingDate
,
Integer
slotCode
);
List
<
TrainingRoomSeatVO
>
adminAvailability
(
String
roomId
,
String
bookingDate
,
Integer
slotCode
);
/** 学员查看运行中实训室
在可预约
日期、时段
下的全部机位状态
。 */
/** 学员查看运行中实训室
指定
日期、时段
的布局和机位状态,不执行创建预约时的时间限制
。 */
List
<
TrainingRoomSeatVO
>
availability
(
String
roomId
,
String
bookingDate
,
Integer
slotCode
);
List
<
TrainingRoomSeatVO
>
availability
(
String
roomId
,
String
bookingDate
,
Integer
slotCode
);
/** 获取系统支持的五个固定预约时段。 */
/** 获取系统支持的五个固定预约时段。 */
...
...
practical-business/src/main/java/com/platform/business/service/impl/TrainingRoomBookingServiceImpl.java
View file @
72c5471e
...
@@ -127,10 +127,11 @@ public class TrainingRoomBookingServiceImpl
...
@@ -127,10 +127,11 @@ public class TrainingRoomBookingServiceImpl
@Transactional
(
rollbackFor
=
Exception
.
class
)
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
List
<
TrainingRoomSeatVO
>
availability
(
String
roomId
,
String
bookingDate
,
Integer
slotCode
)
{
public
List
<
TrainingRoomSeatVO
>
availability
(
String
roomId
,
String
bookingDate
,
Integer
slotCode
)
{
synchronizeBookingStatuses
();
synchronizeBookingStatuses
();
TrainingRoomEntity
room
=
requireRunningRoom
(
roomId
);
requireRunningRoom
(
roomId
);
BookingTime
bookingTime
=
validateBookingTime
(
room
,
bookingDate
,
slotCode
);
LocalDate
date
=
parseDate
(
bookingDate
);
return
trainingRoomSeatMapper
.
selectAvailability
(
roomId
,
// 本接口只负责查询布局和机位状态;日期范围、开放时间和时段是否开始仅在创建预约时校验。
bookingTime
.
date
.
format
(
DATE_FORMATTER
),
slotCode
);
TrainingRoomTimeSlot
.
fromCode
(
slotCode
);
return
trainingRoomSeatMapper
.
selectAvailability
(
roomId
,
date
.
format
(
DATE_FORMATTER
),
slotCode
);
}
}
@Override
@Override
...
...
practical-business/src/main/resources/training-room-layout-api.md
View file @
72c5471e
...
@@ -63,6 +63,9 @@
...
@@ -63,6 +63,9 @@
`GET /training/room/student/{roomId}/seats?bookingDate=2026-08-31&slotCode=1`
`GET /training/room/student/{roomId}/seats?bookingDate=2026-08-31&slotCode=1`
学员端接口同样用于查看实验室布局和机位状态。只要实训室处于运行中,即使所选时段
已经开始或结束也会正常返回;日期范围、开放时间和时段是否开始仅在提交创建预约时校验。
机位位置由服务端返回,前端不再解析布局文本:
机位位置由服务端返回,前端不再解析布局文本:
```
json
```
json
...
...
practical-business/src/test/java/com/platform/business/service/impl/EvaluationServiceImplTest.java
View file @
72c5471e
...
@@ -130,6 +130,40 @@ class EvaluationServiceImplTest {
...
@@ -130,6 +130,40 @@ class EvaluationServiceImplTest {
verify
(
taskMapper
).
countNonRevokedBySubjectId
(
101
);
verify
(
taskMapper
).
countNonRevokedBySubjectId
(
101
);
}
}
@Test
void
revokedTaskShouldAllowSameSubjectToBeCreatedAgain
()
{
EvaluationTaskEntity
revokedTask
=
pendingTask
();
when
(
taskMapper
.
expireDueTasks
(
any
(
Date
.
class
))).
thenReturn
(
0
);
when
(
taskMapper
.
selectByIdForUpdate
(
"T1"
)).
thenReturn
(
revokedTask
);
when
(
taskMapper
.
revokePending
(
eq
(
"T1"
),
eq
(
"A1"
),
any
(
Date
.
class
))).
thenReturn
(
1
);
// 第一次任务撤回后仍保留为历史记录;重新发起时,防重查询必须忽略这条已撤回记录。
service
.
revoke
(
"T1"
,
"A1"
);
EvaluationTaskCreateDTO
request
=
new
EvaluationTaskCreateDTO
();
request
.
setSubjectId
(
101
);
Calendar
deadline
=
Calendar
.
getInstance
();
deadline
.
add
(
Calendar
.
DAY_OF_MONTH
,
2
);
request
.
setDeadline
(
new
SimpleDateFormat
(
"yyyy-MM-dd"
).
format
(
deadline
.
getTime
()));
when
(
classSubjectService
.
getById
(
101
)).
thenReturn
(
endedSubject
);
when
(
taskMapper
.
countNonRevokedBySubjectId
(
101
)).
thenReturn
(
0
);
when
(
taskMapper
.
selectActiveStudentIdsByClassId
(
10
)).
thenReturn
(
Collections
.
singletonList
(
"S1"
));
when
(
taskMapper
.
insert
(
any
(
EvaluationTaskEntity
.
class
))).
thenReturn
(
1
);
when
(
recordMapper
.
batchInsert
(
any
())).
thenReturn
(
1
);
when
(
notificationPublisher
.
publish
(
any
(
NotificationPublishDTO
.
class
),
eq
(
"A1"
),
eq
(
"管理员甲"
)))
.
thenReturn
(
"event-id"
);
EvaluationTaskVO
newTask
=
new
EvaluationTaskVO
();
newTask
.
setId
(
"T2"
);
when
(
taskMapper
.
selectTaskView
(
any
())).
thenReturn
(
newTask
);
EvaluationTaskVO
result
=
service
.
createTask
(
request
,
"A1"
,
"管理员甲"
);
// 重新发起必须创建全新的任务及学员记录,不能恢复或覆盖已经撤回的历史任务。
assertEquals
(
"T2"
,
result
.
getId
());
verify
(
taskMapper
).
insert
(
any
(
EvaluationTaskEntity
.
class
));
verify
(
recordMapper
).
batchInsert
(
any
());
}
@Test
@Test
void
submitShouldPersistScoresAndTryToCompleteTask
()
{
void
submitShouldPersistScoresAndTryToCompleteTask
()
{
EvaluationTaskEntity
task
=
pendingTask
();
EvaluationTaskEntity
task
=
pendingTask
();
...
...
practical-business/src/test/java/com/platform/business/service/impl/TrainingRoomBookingServiceImplTest.java
View file @
72c5471e
...
@@ -21,7 +21,7 @@ import static org.junit.jupiter.api.Assertions.assertSame;
...
@@ -21,7 +21,7 @@ import static org.junit.jupiter.api.Assertions.assertSame;
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
TrainingRoomBookingServiceImplTest
{
class
TrainingRoomBookingServiceImplTest
{
...
@@ -65,4 +65,23 @@ class TrainingRoomBookingServiceImplTest {
...
@@ -65,4 +65,23 @@ class TrainingRoomBookingServiceImplTest {
assertSame
(
expected
,
result
);
assertSame
(
expected
,
result
);
verify
(
seatMapper
).
selectAvailability
(
roomId
,
endedDate
,
1
);
verify
(
seatMapper
).
selectAvailability
(
roomId
,
endedDate
,
1
);
}
}
@Test
void
studentAvailabilityShouldReturnLayoutForEndedSlot
()
{
String
roomId
=
"room-1"
;
// 使用昨天可以稳定覆盖已结束时段,不依赖测试实际运行在当天几点。
String
endedDate
=
LocalDate
.
now
(
ZoneId
.
of
(
"Asia/Shanghai"
)).
minusDays
(
1
).
toString
();
TrainingRoomEntity
room
=
new
TrainingRoomEntity
();
room
.
setId
(
roomId
);
room
.
setStatus
(
"running"
);
List
<
TrainingRoomSeatVO
>
expected
=
Collections
.
singletonList
(
new
TrainingRoomSeatVO
());
when
(
roomService
.
getById
(
roomId
)).
thenReturn
(
room
);
when
(
seatMapper
.
selectAvailability
(
roomId
,
endedDate
,
1
)).
thenReturn
(
expected
);
List
<
TrainingRoomSeatVO
>
result
=
service
.
availability
(
roomId
,
endedDate
,
1
);
// 查询接口必须返回布局;“时段不可预约”的限制由createBooking统一执行。
assertSame
(
expected
,
result
);
verify
(
seatMapper
).
selectAvailability
(
roomId
,
endedDate
,
1
);
}
}
}
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