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
42f13c03
Commit
42f13c03
authored
Nov 17, 2026
by
wujipeng
Browse files
优化项
parent
af106c16
Changes
20
Show whitespace changes
Inline
Side-by-side
practical-api/practical-business-api/src/main/java/com/platform/business/model/dto/AccountAdminQueryDTO.java
View file @
42f13c03
...
@@ -30,6 +30,15 @@ public class AccountAdminQueryDTO {
...
@@ -30,6 +30,15 @@ public class AccountAdminQueryDTO {
@ApiModelProperty
(
"班级ID,仅学员查询使用"
)
@ApiModelProperty
(
"班级ID,仅学员查询使用"
)
private
Integer
classId
;
private
Integer
classId
;
@ApiModelProperty
(
"工种,仅学员目录树筛选使用"
)
private
String
occupation
;
@ApiModelProperty
(
"培训年度,仅学员目录树筛选使用"
)
private
Integer
trainingYear
;
@ApiModelProperty
(
"职业等级ID,仅学员目录树筛选使用"
)
private
Integer
levelId
;
@ApiModelProperty
(
"系统角色ID,仅教师和管理员查询使用"
)
@ApiModelProperty
(
"系统角色ID,仅教师和管理员查询使用"
)
private
Integer
roleId
;
private
Integer
roleId
;
...
...
practical-api/practical-business-api/src/main/java/com/platform/business/model/vo/CourseAdminImportResultVO.java
0 → 100644
View file @
42f13c03
package
com.platform.business.model.vo
;
import
lombok.Data
;
/** 管理员从Word课程安排表导入课程后的结果。 */
@Data
public
class
CourseAdminImportResultVO
{
/** 实际写入的课程记录数。 */
private
Integer
importedCount
;
/** 因课程名称为“单位实训”而按业务规则跳过的表格行数。 */
private
Integer
skippedUnitTrainingCount
;
/** 导入完成后的完整班级课程表,供页面直接刷新。 */
private
CourseAdminDetailVO
detail
;
}
practical-business/src/main/java/com/platform/business/controller/AccountAdminController.java
View file @
42f13c03
...
@@ -11,8 +11,10 @@ import com.platform.business.model.vo.AccountAdminDetailVO;
...
@@ -11,8 +11,10 @@ import com.platform.business.model.vo.AccountAdminDetailVO;
import
com.platform.business.model.vo.AccountAdminOptionsVO
;
import
com.platform.business.model.vo.AccountAdminOptionsVO
;
import
com.platform.business.model.vo.AccountAdminStatisticsVO
;
import
com.platform.business.model.vo.AccountAdminStatisticsVO
;
import
com.platform.business.model.vo.AccountImportResultVO
;
import
com.platform.business.model.vo.AccountImportResultVO
;
import
com.platform.business.model.vo.ClassAdminTreeVO
;
import
com.platform.business.service.AccountAdminService
;
import
com.platform.business.service.AccountAdminService
;
import
com.platform.business.service.AuthenticatedUserService
;
import
com.platform.business.service.AuthenticatedUserService
;
import
com.platform.business.service.ClassAdminService
;
import
com.platform.controller.BaseController
;
import
com.platform.controller.BaseController
;
import
com.platform.exception.BusinessException
;
import
com.platform.exception.BusinessException
;
import
com.platform.model.resp.Result
;
import
com.platform.model.resp.Result
;
...
@@ -32,6 +34,7 @@ import org.springframework.web.multipart.MultipartFile;
...
@@ -32,6 +34,7 @@ import org.springframework.web.multipart.MultipartFile;
import
javax.annotation.Resource
;
import
javax.annotation.Resource
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
javax.servlet.http.HttpServletResponse
;
import
java.util.List
;
/**
/**
* 管理员端“系统管理-账户管理”接口。
* 管理员端“系统管理-账户管理”接口。
...
@@ -48,6 +51,9 @@ public class AccountAdminController extends BaseController {
...
@@ -48,6 +51,9 @@ public class AccountAdminController extends BaseController {
@Resource
@Resource
private
AccountAdminService
accountAdminService
;
private
AccountAdminService
accountAdminService
;
@Resource
private
ClassAdminService
classAdminService
;
@Resource
@Resource
private
AuthenticatedUserService
authenticatedUserService
;
private
AuthenticatedUserService
authenticatedUserService
;
...
@@ -83,6 +89,16 @@ public class AccountAdminController extends BaseController {
...
@@ -83,6 +89,16 @@ public class AccountAdminController extends BaseController {
return
Result
.
data
(
accountAdminService
.
options
());
return
Result
.
data
(
accountAdminService
.
options
());
}
}
@ApiOperation
(
"学员账户工种、年度、等级和班级导航树"
)
@GetMapping
(
"/student-tree"
)
public
Result
<
List
<
ClassAdminTreeVO
>>
studentTree
(
@RequestParam
(
value
=
"keyword"
,
required
=
false
)
String
keyword
,
HttpServletRequest
request
)
{
requireAdmin
(
request
);
// 与班级管理直接复用同一棵树,保证两处的分组顺序、节点数量和关键字口径一致。
return
Result
.
data
(
classAdminService
.
tree
(
keyword
));
}
@ApiOperation
(
"账户详情"
)
@ApiOperation
(
"账户详情"
)
@GetMapping
(
"/{id}"
)
@GetMapping
(
"/{id}"
)
public
Result
<
AccountAdminDetailVO
>
detail
(
@PathVariable
(
"id"
)
String
id
,
public
Result
<
AccountAdminDetailVO
>
detail
(
@PathVariable
(
"id"
)
String
id
,
...
...
practical-business/src/main/java/com/platform/business/controller/CourseAdminController.java
View file @
42f13c03
...
@@ -9,6 +9,7 @@ import com.platform.business.model.vo.CourseAdminDetailVO;
...
@@ -9,6 +9,7 @@ import com.platform.business.model.vo.CourseAdminDetailVO;
import
com.platform.business.model.vo.CourseAdminOptionsVO
;
import
com.platform.business.model.vo.CourseAdminOptionsVO
;
import
com.platform.business.model.vo.CourseAdminScheduleVO
;
import
com.platform.business.model.vo.CourseAdminScheduleVO
;
import
com.platform.business.model.vo.CourseAdminScheduleGroupVO
;
import
com.platform.business.model.vo.CourseAdminScheduleGroupVO
;
import
com.platform.business.model.vo.CourseAdminImportResultVO
;
import
com.platform.business.service.AuthenticatedUserService
;
import
com.platform.business.service.AuthenticatedUserService
;
import
com.platform.business.service.CourseAdminService
;
import
com.platform.business.service.CourseAdminService
;
import
com.platform.model.resp.Result
;
import
com.platform.model.resp.Result
;
...
@@ -24,6 +25,7 @@ import org.springframework.web.bind.annotation.RequestBody;
...
@@ -24,6 +25,7 @@ import org.springframework.web.bind.annotation.RequestBody;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RestController
;
import
org.springframework.web.bind.annotation.RestController
;
import
org.springframework.web.multipart.MultipartFile
;
import
javax.annotation.Resource
;
import
javax.annotation.Resource
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletRequest
;
...
@@ -86,6 +88,16 @@ public class CourseAdminController {
...
@@ -86,6 +88,16 @@ public class CourseAdminController {
return
Result
.
data
(
courseAdminService
.
createBatch
(
body
));
return
Result
.
data
(
courseAdminService
.
createBatch
(
body
));
}
}
@ApiOperation
(
"从Word课程安排表导入班级课程"
)
@PostMapping
(
"/classes/{classId}/import"
)
public
Result
<
CourseAdminImportResultVO
>
importWord
(
@PathVariable
(
"classId"
)
Integer
classId
,
@RequestParam
(
"file"
)
MultipartFile
file
,
HttpServletRequest
request
)
{
requireAdmin
(
request
);
return
Result
.
data
(
courseAdminService
.
importWord
(
classId
,
file
));
}
@ApiOperation
(
"编辑单节课程"
)
@ApiOperation
(
"编辑单节课程"
)
@PutMapping
(
"/{courseId}"
)
@PutMapping
(
"/{courseId}"
)
public
Result
<
CourseAdminScheduleVO
>
update
(
@PathVariable
(
"courseId"
)
Integer
courseId
,
public
Result
<
CourseAdminScheduleVO
>
update
(
@PathVariable
(
"courseId"
)
Integer
courseId
,
...
...
practical-business/src/main/java/com/platform/business/controller/TeachingPlanAdminController.java
View file @
42f13c03
...
@@ -5,6 +5,7 @@ import com.platform.business.model.dto.TeachingPlanAdminUpdateDTO;
...
@@ -5,6 +5,7 @@ import com.platform.business.model.dto.TeachingPlanAdminUpdateDTO;
import
com.platform.business.model.entity.UserEntity
;
import
com.platform.business.model.entity.UserEntity
;
import
com.platform.business.model.vo.TeachingPlanTeacherOptionVO
;
import
com.platform.business.model.vo.TeachingPlanTeacherOptionVO
;
import
com.platform.business.model.vo.TeachingPlanVO
;
import
com.platform.business.model.vo.TeachingPlanVO
;
import
com.platform.business.model.vo.ClassAdminOptionVO
;
import
com.platform.business.service.AuthenticatedUserService
;
import
com.platform.business.service.AuthenticatedUserService
;
import
com.platform.business.service.TeachingPlanService
;
import
com.platform.business.service.TeachingPlanService
;
import
com.platform.controller.BaseController
;
import
com.platform.controller.BaseController
;
...
@@ -79,6 +80,13 @@ public class TeachingPlanAdminController extends BaseController {
...
@@ -79,6 +80,13 @@ public class TeachingPlanAdminController extends BaseController {
return
Result
.
data
(
teachingPlanService
.
adminTeacherOptions
());
return
Result
.
data
(
teachingPlanService
.
adminTeacherOptions
());
}
}
@ApiOperation
(
"查询存在有效教案的授课班级筛选选项"
)
@GetMapping
(
"/classes"
)
public
Result
<
List
<
ClassAdminOptionVO
>>
classOptions
(
HttpServletRequest
request
)
{
currentAdmin
(
request
);
return
Result
.
data
(
teachingPlanService
.
adminClassOptions
());
}
@ApiOperation
(
"按当前筛选条件导出全部教案清单Excel"
)
@ApiOperation
(
"按当前筛选条件导出全部教案清单Excel"
)
@PostMapping
(
"/export"
)
@PostMapping
(
"/export"
)
public
void
exportList
(
@RequestBody
(
required
=
false
)
TeachingPlanAdminQueryDTO
query
,
public
void
exportList
(
@RequestBody
(
required
=
false
)
TeachingPlanAdminQueryDTO
query
,
...
...
practical-business/src/main/java/com/platform/business/mapper/TeachingPlanMapper.java
View file @
42f13c03
...
@@ -5,6 +5,7 @@ import com.platform.business.model.dto.TeachingPlanAdminQueryDTO;
...
@@ -5,6 +5,7 @@ import com.platform.business.model.dto.TeachingPlanAdminQueryDTO;
import
com.platform.business.model.dto.TeachingPlanQueryDTO
;
import
com.platform.business.model.dto.TeachingPlanQueryDTO
;
import
com.platform.business.model.entity.TeachingPlanEntity
;
import
com.platform.business.model.entity.TeachingPlanEntity
;
import
com.platform.business.model.vo.TeachingPlanTeacherOptionVO
;
import
com.platform.business.model.vo.TeachingPlanTeacherOptionVO
;
import
com.platform.business.model.vo.ClassAdminOptionVO
;
import
com.platform.business.model.vo.TeachingPlanVO
;
import
com.platform.business.model.vo.TeachingPlanVO
;
import
org.apache.ibatis.annotations.Mapper
;
import
org.apache.ibatis.annotations.Mapper
;
import
org.apache.ibatis.annotations.Param
;
import
org.apache.ibatis.annotations.Param
;
...
@@ -70,4 +71,7 @@ public interface TeachingPlanMapper extends BaseMapper<TeachingPlanEntity> {
...
@@ -70,4 +71,7 @@ public interface TeachingPlanMapper extends BaseMapper<TeachingPlanEntity> {
/** 查询存在有效教案的教师,供管理端教师筛选下拉框使用。 */
/** 查询存在有效教案的教师,供管理端教师筛选下拉框使用。 */
List
<
TeachingPlanTeacherOptionVO
>
selectAdminTeacherOptions
();
List
<
TeachingPlanTeacherOptionVO
>
selectAdminTeacherOptions
();
/** 返回有效教案中实际使用过的授课班级,供管理端查询条件下拉框使用。 */
List
<
ClassAdminOptionVO
>
selectAdminClassOptions
();
}
}
practical-business/src/main/java/com/platform/business/service/CourseAdminService.java
View file @
42f13c03
...
@@ -8,6 +8,8 @@ import com.platform.business.model.vo.CourseAdminDetailVO;
...
@@ -8,6 +8,8 @@ import com.platform.business.model.vo.CourseAdminDetailVO;
import
com.platform.business.model.vo.CourseAdminOptionsVO
;
import
com.platform.business.model.vo.CourseAdminOptionsVO
;
import
com.platform.business.model.vo.CourseAdminScheduleVO
;
import
com.platform.business.model.vo.CourseAdminScheduleVO
;
import
com.platform.business.model.vo.CourseAdminScheduleGroupVO
;
import
com.platform.business.model.vo.CourseAdminScheduleGroupVO
;
import
com.platform.business.model.vo.CourseAdminImportResultVO
;
import
org.springframework.web.multipart.MultipartFile
;
import
javax.servlet.http.HttpServletResponse
;
import
javax.servlet.http.HttpServletResponse
;
import
java.io.IOException
;
import
java.io.IOException
;
...
@@ -25,6 +27,9 @@ public interface CourseAdminService {
...
@@ -25,6 +27,9 @@ public interface CourseAdminService {
CourseAdminDetailVO
createBatch
(
CourseAdminBatchSaveDTO
request
);
CourseAdminDetailVO
createBatch
(
CourseAdminBatchSaveDTO
request
);
/** 解析标准Word课程安排表并批量写入;名称为“单位实训”的行不会生成课程。 */
CourseAdminImportResultVO
importWord
(
Integer
classId
,
MultipartFile
file
);
CourseAdminScheduleVO
update
(
Integer
courseId
,
CourseAdminSaveDTO
request
);
CourseAdminScheduleVO
update
(
Integer
courseId
,
CourseAdminSaveDTO
request
);
/** 一次保存页面同一排课组内的一至一百条同日独立课程,并按实际时段检查冲突。 */
/** 一次保存页面同一排课组内的一至一百条同日独立课程,并按实际时段检查冲突。 */
...
...
practical-business/src/main/java/com/platform/business/service/TeachingPlanService.java
View file @
42f13c03
...
@@ -8,6 +8,7 @@ import com.platform.business.model.dto.TeachingPlanStatusDTO;
...
@@ -8,6 +8,7 @@ import com.platform.business.model.dto.TeachingPlanStatusDTO;
import
com.platform.business.model.vo.TeachingPlanAttachmentVO
;
import
com.platform.business.model.vo.TeachingPlanAttachmentVO
;
import
com.platform.business.model.vo.TeachingPlanTeacherOptionVO
;
import
com.platform.business.model.vo.TeachingPlanTeacherOptionVO
;
import
com.platform.business.model.vo.TeachingPlanVO
;
import
com.platform.business.model.vo.TeachingPlanVO
;
import
com.platform.business.model.vo.ClassAdminOptionVO
;
import
org.springframework.web.multipart.MultipartFile
;
import
org.springframework.web.multipart.MultipartFile
;
import
javax.servlet.http.HttpServletResponse
;
import
javax.servlet.http.HttpServletResponse
;
...
@@ -53,6 +54,9 @@ public interface TeachingPlanService {
...
@@ -53,6 +54,9 @@ public interface TeachingPlanService {
/** 返回至少拥有一份有效教案的教师筛选选项。 */
/** 返回至少拥有一份有效教案的教师筛选选项。 */
List
<
TeachingPlanTeacherOptionVO
>
adminTeacherOptions
();
List
<
TeachingPlanTeacherOptionVO
>
adminTeacherOptions
();
/** 返回当前有效教案中可用于“授课班级”查询条件的班级名称。 */
List
<
ClassAdminOptionVO
>
adminClassOptions
();
/** 按查询条件导出全部匹配教案,不应用分页参数。 */
/** 按查询条件导出全部匹配教案,不应用分页参数。 */
void
exportAdminList
(
TeachingPlanAdminQueryDTO
query
,
HttpServletResponse
response
);
void
exportAdminList
(
TeachingPlanAdminQueryDTO
query
,
HttpServletResponse
response
);
...
...
practical-business/src/main/java/com/platform/business/service/impl/AccountAdminServiceImpl.java
View file @
42f13c03
...
@@ -505,8 +505,12 @@ public class AccountAdminServiceImpl implements AccountAdminService {
...
@@ -505,8 +505,12 @@ public class AccountAdminServiceImpl implements AccountAdminService {
}
}
if
(!
AccountAdminConstants
.
TYPE_STUDENT
.
equals
(
query
.
getAccountType
()))
{
if
(!
AccountAdminConstants
.
TYPE_STUDENT
.
equals
(
query
.
getAccountType
()))
{
query
.
setClassId
(
null
);
query
.
setClassId
(
null
);
query
.
setOccupation
(
null
);
query
.
setTrainingYear
(
null
);
query
.
setLevelId
(
null
);
query
.
setArchiveOverSixMonths
(
false
);
query
.
setArchiveOverSixMonths
(
false
);
}
else
{
}
else
{
query
.
setOccupation
(
optionalText
(
query
.
getOccupation
(),
"工种"
,
50
));
query
.
setRoleId
(
null
);
query
.
setRoleId
(
null
);
}
}
return
query
;
return
query
;
...
...
practical-business/src/main/java/com/platform/business/service/impl/ClassAdminServiceImpl.java
View file @
42f13c03
...
@@ -180,8 +180,11 @@ public class ClassAdminServiceImpl implements ClassAdminService {
...
@@ -180,8 +180,11 @@ public class ClassAdminServiceImpl implements ClassAdminService {
throw
new
BusinessException
(
"班级不存在或已删除"
);
throw
new
BusinessException
(
"班级不存在或已删除"
);
}
}
String
status
=
resolveClassStatus
(
existing
.
getStartDate
(),
existing
.
getEndDate
(),
businessToday
());
String
status
=
resolveClassStatus
(
existing
.
getStartDate
(),
existing
.
getEndDate
(),
businessToday
());
if
(!
ClassAdminConstants
.
STATUS_UPCOMING
.
equals
(
status
))
{
// 进行中的班级仍可能需要修正班主任、地点、容量或培训日期等基础资料。
throw
new
BusinessException
(
"只有待开课班级可以编辑"
);
// 已结课班级继续保持只读,避免历史统计口径被事后修改。
if
(!
ClassAdminConstants
.
STATUS_UPCOMING
.
equals
(
status
)
&&
!
ClassAdminConstants
.
STATUS_ONGOING
.
equals
(
status
))
{
throw
new
BusinessException
(
"只有待开课或进行中的班级可以编辑"
);
}
}
int
actualCount
=
classMapper
.
countAdminStudents
(
classId
);
int
actualCount
=
classMapper
.
countAdminStudents
(
classId
);
validateSaveRequest
(
request
,
classId
,
actualCount
);
validateSaveRequest
(
request
,
classId
,
actualCount
);
...
...
practical-business/src/main/java/com/platform/business/service/impl/CourseAdminServiceImpl.java
View file @
42f13c03
...
@@ -14,6 +14,7 @@ import com.platform.business.model.entity.ClassSubjectEntity;
...
@@ -14,6 +14,7 @@ import com.platform.business.model.entity.ClassSubjectEntity;
import
com.platform.business.model.vo.ClassAdminOptionVO
;
import
com.platform.business.model.vo.ClassAdminOptionVO
;
import
com.platform.business.model.vo.ClassAdminTreeVO
;
import
com.platform.business.model.vo.ClassAdminTreeVO
;
import
com.platform.business.model.vo.CourseAdminDetailVO
;
import
com.platform.business.model.vo.CourseAdminDetailVO
;
import
com.platform.business.model.vo.CourseAdminImportResultVO
;
import
com.platform.business.model.vo.CourseAdminOptionsVO
;
import
com.platform.business.model.vo.CourseAdminOptionsVO
;
import
com.platform.business.model.vo.CourseAdminScheduleVO
;
import
com.platform.business.model.vo.CourseAdminScheduleVO
;
import
com.platform.business.model.vo.CourseAdminScheduleGroupVO
;
import
com.platform.business.model.vo.CourseAdminScheduleGroupVO
;
...
@@ -21,8 +22,13 @@ import com.platform.business.service.ClassAdminService;
...
@@ -21,8 +22,13 @@ import com.platform.business.service.ClassAdminService;
import
com.platform.business.service.CourseAdminService
;
import
com.platform.business.service.CourseAdminService
;
import
com.platform.exception.BusinessException
;
import
com.platform.exception.BusinessException
;
import
org.springframework.http.HttpHeaders
;
import
org.springframework.http.HttpHeaders
;
import
org.apache.poi.xwpf.usermodel.XWPFDocument
;
import
org.apache.poi.xwpf.usermodel.XWPFTable
;
import
org.apache.poi.xwpf.usermodel.XWPFTableCell
;
import
org.apache.poi.xwpf.usermodel.XWPFTableRow
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.web.multipart.MultipartFile
;
import
javax.annotation.Resource
;
import
javax.annotation.Resource
;
import
javax.servlet.http.HttpServletResponse
;
import
javax.servlet.http.HttpServletResponse
;
...
@@ -51,6 +57,8 @@ import java.util.Objects;
...
@@ -51,6 +57,8 @@ import java.util.Objects;
import
java.util.Set
;
import
java.util.Set
;
import
java.util.TreeSet
;
import
java.util.TreeSet
;
import
java.util.stream.Collectors
;
import
java.util.stream.Collectors
;
import
java.util.regex.Matcher
;
import
java.util.regex.Pattern
;
/**
/**
* 管理员端课程管理实现。
* 管理员端课程管理实现。
...
@@ -74,6 +82,27 @@ public class CourseAdminServiceImpl implements CourseAdminService {
...
@@ -74,6 +82,27 @@ public class CourseAdminServiceImpl implements CourseAdminService {
private
static
final
String
PERIOD_PM
=
"PM"
;
private
static
final
String
PERIOD_PM
=
"PM"
;
private
static
final
String
PERIOD_ALL_DAY
=
"ALL_DAY"
;
private
static
final
String
PERIOD_ALL_DAY
=
"ALL_DAY"
;
/** 附件模板个别分班行漏写下午时段时,按该模板其余行统一使用的标准时段补齐。 */
private
static
final
List
<
String
>
IMPORT_STANDARD_AM_FRAMES
=
java
.
util
.
Arrays
.
asList
(
"09:00-10:20"
,
"10:40-12:00"
);
private
static
final
List
<
String
>
IMPORT_STANDARD_PM_FRAMES
=
java
.
util
.
Arrays
.
asList
(
"13:00-14:20"
,
"14:40-16:00"
);
/** Word模板中的日期只写月/日,年份由目标班级培训年度补齐。 */
private
static
final
Pattern
IMPORT_DATE_PATTERN
=
Pattern
.
compile
(
"(\\d{1,2})\\s*[/月]\\s*(\\d{1,2})"
);
/** 同时兼容模板中的半角波浪线、短横线及Word常见的全角连接符。 */
private
static
final
Pattern
IMPORT_TIME_PATTERN
=
Pattern
.
compile
(
"(\\d{1,2}:\\d{2})\\s*[~~—–-]\\s*(\\d{1,2}:\\d{2})"
);
/** 分班实训备注示例:上午:1班,下午:2班。 */
private
static
final
Pattern
IMPORT_SHIFT_PATTERN
=
Pattern
.
compile
(
"上午\\s*[::]\\s*([一二三四五六七八九十0-9]+)班.*?下午\\s*[::]\\s*([一二三四五六七八九十0-9]+)班"
);
/** 班级名称中的班号用于选择分班实训的上午或下午时段。 */
private
static
final
Pattern
CLASS_NUMBER_PATTERN
=
Pattern
.
compile
(
"([一二三四五六七八九十0-9]+)班"
);
@Resource
@Resource
private
ClassSubjectMapper
classSubjectMapper
;
private
ClassSubjectMapper
classSubjectMapper
;
...
@@ -182,6 +211,308 @@ public class CourseAdminServiceImpl implements CourseAdminService {
...
@@ -182,6 +211,308 @@ public class CourseAdminServiceImpl implements CourseAdminService {
return
detail
(
request
.
getClassId
(),
null
,
null
);
return
detail
(
request
.
getClassId
(),
null
,
null
);
}
}
@Override
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
CourseAdminImportResultVO
importWord
(
Integer
classId
,
MultipartFile
file
)
{
requireClassId
(
classId
);
validateImportFile
(
file
);
ClassEntity
managedClass
=
classMapper
.
selectById
(
classId
);
if
(
managedClass
==
null
)
{
throw
new
BusinessException
(
"班级不存在或已删除"
);
}
ParsedImport
parsed
;
try
(
XWPFDocument
document
=
new
XWPFDocument
(
file
.
getInputStream
()))
{
parsed
=
parseImportDocument
(
document
,
managedClass
);
}
catch
(
BusinessException
e
)
{
throw
e
;
}
catch
(
Exception
e
)
{
throw
new
BusinessException
(
"课程安排表读取失败,请确认文件未损坏且格式为docx"
);
}
if
(
parsed
.
courses
.
isEmpty
())
{
throw
new
BusinessException
(
"课程安排表中没有可导入的课程"
);
}
CourseAdminBatchSaveDTO
request
=
new
CourseAdminBatchSaveDTO
();
request
.
setClassId
(
classId
);
request
.
setCourses
(
parsed
.
courses
);
CourseAdminImportResultVO
result
=
new
CourseAdminImportResultVO
();
result
.
setImportedCount
(
parsed
.
courses
.
size
());
result
.
setSkippedUnitTrainingCount
(
parsed
.
skippedUnitTrainingCount
);
result
.
setDetail
(
createBatch
(
request
));
return
result
;
}
/**
* 读取模板表格并转换为现有批量新增请求,确保手工新增与Word导入共用同一套
* 教师有效性、时段冲突、字段长度及事务回滚校验。
*/
ParsedImport
parseImportDocument
(
XWPFDocument
document
,
ClassEntity
managedClass
)
{
if
(
document
==
null
||
document
.
getTables
().
isEmpty
())
{
throw
new
BusinessException
(
"课程安排表中未找到课程表格"
);
}
XWPFTable
courseTable
=
null
;
int
headerRowIndex
=
-
1
;
for
(
XWPFTable
table
:
document
.
getTables
())
{
for
(
int
rowIndex
=
0
;
rowIndex
<
table
.
getRows
().
size
();
rowIndex
++)
{
String
rowText
=
normalizeCellText
(
table
.
getRow
(
rowIndex
).
getTableCells
().
stream
()
.
map
(
XWPFTableCell:
:
getText
).
collect
(
Collectors
.
joining
(
"|"
)));
if
(
rowText
.
contains
(
"日期"
)
&&
rowText
.
contains
(
"课程"
)
&&
rowText
.
contains
(
"授课教师"
))
{
courseTable
=
table
;
headerRowIndex
=
rowIndex
;
break
;
}
}
if
(
courseTable
!=
null
)
{
break
;
}
}
if
(
courseTable
==
null
)
{
throw
new
BusinessException
(
"课程安排表表头缺少日期、课程或授课教师列"
);
}
int
importYear
=
resolveImportYear
(
managedClass
);
Integer
targetClassNumber
=
extractClassNumber
(
managedClass
.
getName
());
Map
<
String
,
List
<
ClassAdminOptionVO
>>
teachersByName
=
options
().
getTeachers
().
stream
()
.
filter
(
option
->
trimToNull
(
option
.
getLabel
())
!=
null
)
.
collect
(
Collectors
.
groupingBy
(
option
->
option
.
getLabel
().
trim
()));
ParsedImport
result
=
new
ParsedImport
();
for
(
int
rowIndex
=
headerRowIndex
+
1
;
rowIndex
<
courseTable
.
getRows
().
size
();
rowIndex
++)
{
XWPFTableRow
row
=
courseTable
.
getRow
(
rowIndex
);
if
(
row
==
null
||
row
.
getTableCells
().
size
()
<
6
)
{
continue
;
}
String
subject
=
normalizeCellText
(
cellText
(
row
,
4
));
if
(
subject
.
isEmpty
())
{
continue
;
}
// “单位实训”是单位自行组织的线下环节,不属于系统排课;即使日期、教师为空也直接跳过。
if
(
"单位实训"
.
equals
(
subject
.
replaceAll
(
"\\s+"
,
""
)))
{
result
.
skippedUnitTrainingCount
++;
continue
;
}
try
{
CourseAdminSaveDTO
course
=
parseImportRow
(
row
,
subject
,
importYear
,
targetClassNumber
,
teachersByName
);
result
.
courses
.
add
(
course
);
}
catch
(
BusinessException
e
)
{
throw
new
BusinessException
(
"课程安排表第"
+
(
rowIndex
+
1
)
+
"行:"
+
e
.
getMessage
());
}
}
return
result
;
}
/** 将一行Word表格转换为课程保存对象,并处理上午/下午分班实训。 */
private
CourseAdminSaveDTO
parseImportRow
(
XWPFTableRow
row
,
String
originalSubject
,
int
importYear
,
Integer
targetClassNumber
,
Map
<
String
,
List
<
ClassAdminOptionVO
>>
teachersByName
)
{
CourseAdminSaveDTO
course
=
new
CourseAdminSaveDTO
();
course
.
setDate
(
parseImportDate
(
cellText
(
row
,
0
),
importYear
));
Integer
subjectTimes
=
parseImportInteger
(
cellText
(
row
,
1
),
"课次"
);
BigDecimal
subjectHours
=
parseImportDecimal
(
cellText
(
row
,
3
),
"课时"
);
List
<
String
>
allFrames
=
parseImportTimeFrames
(
cellText
(
row
,
2
));
Matcher
shiftMatcher
=
IMPORT_SHIFT_PATTERN
.
matcher
(
originalSubject
);
if
(
shiftMatcher
.
find
())
{
if
(
targetClassNumber
==
null
)
{
throw
new
BusinessException
(
"分班实训无法识别目标班号,请在班级名称中保留“1班”等班号"
);
}
int
morningClass
=
parseChineseNumber
(
shiftMatcher
.
group
(
1
));
int
afternoonClass
=
parseChineseNumber
(
shiftMatcher
.
group
(
2
));
boolean
selectMorning
=
targetClassNumber
==
morningClass
;
boolean
selectAfternoon
=
targetClassNumber
==
afternoonClass
;
if
(!
selectMorning
&&
!
selectAfternoon
)
{
throw
new
BusinessException
(
"分班实训备注中未包含目标班级“"
+
targetClassNumber
+
"班”"
);
}
List
<
String
>
selectedFrames
=
allFrames
.
stream
().
filter
(
frame
->
{
LocalTime
start
=
LocalTime
.
parse
(
frame
.
substring
(
0
,
frame
.
indexOf
(
'-'
)),
FLEXIBLE_TIME_FORMATTER
);
return
selectMorning
?
start
.
isBefore
(
NOON
)
:
!
start
.
isBefore
(
NOON
);
}).
collect
(
Collectors
.
toList
());
if
(
selectedFrames
.
isEmpty
())
{
// 实际样表的6/15分班行只写了上午两段,但课程备注仍明确安排了下午班。
// 仅在“已有时段全部位于另一半天”时使用模板标准时段,混合或异常数据仍拒绝导入。
boolean
onlyMorning
=
allFrames
.
stream
().
allMatch
(
frame
->
LocalTime
.
parse
(
frame
.
substring
(
0
,
frame
.
indexOf
(
'-'
)),
FLEXIBLE_TIME_FORMATTER
).
isBefore
(
NOON
));
boolean
onlyAfternoon
=
allFrames
.
stream
().
allMatch
(
frame
->
!
LocalTime
.
parse
(
frame
.
substring
(
0
,
frame
.
indexOf
(
'-'
)),
FLEXIBLE_TIME_FORMATTER
).
isBefore
(
NOON
));
if
(
selectAfternoon
&&
onlyMorning
)
{
selectedFrames
=
new
ArrayList
<>(
IMPORT_STANDARD_PM_FRAMES
);
}
else
if
(
selectMorning
&&
onlyAfternoon
)
{
selectedFrames
=
new
ArrayList
<>(
IMPORT_STANDARD_AM_FRAMES
);
}
else
{
throw
new
BusinessException
(
selectMorning
?
"未找到上午实训时段"
:
"未找到下午实训时段"
);
}
}
// 模板的课次和课时是全天合计,分班后按选中时段占比折算到目标班级。
int
fullDayFrameCount
=
Math
.
max
(
allFrames
.
size
(),
selectedFrames
.
size
()
*
2
);
subjectTimes
=
subjectTimes
*
selectedFrames
.
size
()
/
fullDayFrameCount
;
subjectHours
=
subjectHours
.
multiply
(
BigDecimal
.
valueOf
(
selectedFrames
.
size
()))
.
divide
(
BigDecimal
.
valueOf
(
fullDayFrameCount
))
.
stripTrailingZeros
();
allFrames
=
selectedFrames
;
originalSubject
=
(
originalSubject
.
substring
(
0
,
shiftMatcher
.
start
())
+
originalSubject
.
substring
(
shiftMatcher
.
end
()))
.
replaceAll
(
"[((\\s]+$"
,
""
).
trim
();
}
course
.
setSubjectTimes
(
subjectTimes
);
course
.
setSubjectHour
(
subjectHours
);
course
.
setTimeFrames
(
allFrames
);
course
.
setSubjectName
(
originalSubject
);
course
.
setType
(
resolveImportCourseType
(
originalSubject
));
String
teacherName
=
normalizeCellText
(
cellText
(
row
,
5
));
List
<
ClassAdminOptionVO
>
matchedTeachers
=
teachersByName
.
get
(
teacherName
);
if
(
matchedTeachers
==
null
||
matchedTeachers
.
isEmpty
())
{
throw
new
BusinessException
(
"未找到授课教师“"
+
teacherName
+
"”的有效系统账户"
);
}
if
(
matchedTeachers
.
size
()
>
1
)
{
throw
new
BusinessException
(
"授课教师“"
+
teacherName
+
"”存在多个同名账户,请先整理教师账户"
);
}
course
.
setTeacherId
(
matchedTeachers
.
get
(
0
).
getValue
());
return
course
;
}
private
void
validateImportFile
(
MultipartFile
file
)
{
if
(
file
==
null
||
file
.
isEmpty
())
{
throw
new
BusinessException
(
"请选择要导入的课程安排表"
);
}
String
filename
=
trimToNull
(
file
.
getOriginalFilename
());
if
(
filename
==
null
||
!
filename
.
toLowerCase
().
endsWith
(
".docx"
))
{
throw
new
BusinessException
(
"课程导入仅支持docx格式的Word文件"
);
}
if
(
file
.
getSize
()
>
10L
*
1024
*
1024
)
{
throw
new
BusinessException
(
"课程安排表不能超过10MB"
);
}
}
private
int
resolveImportYear
(
ClassEntity
managedClass
)
{
if
(
managedClass
.
getTrainingYear
()
!=
null
)
{
return
managedClass
.
getTrainingYear
();
}
if
(
managedClass
.
getStartDate
()
!=
null
)
{
return
toLocalDate
(
managedClass
.
getStartDate
()).
getYear
();
}
throw
new
BusinessException
(
"班级未设置培训年度,无法补全课程日期年份"
);
}
private
Date
parseImportDate
(
String
text
,
int
year
)
{
Matcher
matcher
=
IMPORT_DATE_PATTERN
.
matcher
(
normalizeCellText
(
text
));
if
(!
matcher
.
find
())
{
throw
new
BusinessException
(
"日期格式无法识别"
);
}
try
{
LocalDate
date
=
LocalDate
.
of
(
year
,
Integer
.
parseInt
(
matcher
.
group
(
1
)),
Integer
.
parseInt
(
matcher
.
group
(
2
)));
return
java
.
sql
.
Date
.
valueOf
(
date
);
}
catch
(
RuntimeException
e
)
{
throw
new
BusinessException
(
"日期不是有效自然日"
);
}
}
private
List
<
String
>
parseImportTimeFrames
(
String
text
)
{
Matcher
matcher
=
IMPORT_TIME_PATTERN
.
matcher
(
text
==
null
?
""
:
text
);
List
<
String
>
frames
=
new
ArrayList
<>();
while
(
matcher
.
find
())
{
try
{
LocalTime
start
=
LocalTime
.
parse
(
matcher
.
group
(
1
),
FLEXIBLE_TIME_FORMATTER
);
LocalTime
end
=
LocalTime
.
parse
(
matcher
.
group
(
2
),
FLEXIBLE_TIME_FORMATTER
);
frames
.
add
(
start
.
format
(
CourseAdminConstants
.
TIME_FORMATTER
)
+
"-"
+
end
.
format
(
CourseAdminConstants
.
TIME_FORMATTER
));
}
catch
(
DateTimeParseException
e
)
{
throw
new
BusinessException
(
"上课时段格式无法识别"
);
}
}
if
(
frames
.
isEmpty
())
{
throw
new
BusinessException
(
"上课时段不能为空"
);
}
return
frames
;
}
private
Integer
parseImportInteger
(
String
text
,
String
fieldName
)
{
try
{
return
Integer
.
valueOf
(
normalizeCellText
(
text
));
}
catch
(
NumberFormatException
e
)
{
throw
new
BusinessException
(
fieldName
+
"必须是整数"
);
}
}
private
BigDecimal
parseImportDecimal
(
String
text
,
String
fieldName
)
{
try
{
return
new
BigDecimal
(
normalizeCellText
(
text
));
}
catch
(
NumberFormatException
e
)
{
throw
new
BusinessException
(
fieldName
+
"必须是数字"
);
}
}
private
String
resolveImportCourseType
(
String
subject
)
{
if
(
subject
.
contains
(
"考核"
)
||
subject
.
contains
(
"考试"
))
{
return
"考核"
;
}
if
(
subject
.
contains
(
"实操"
)
||
subject
.
contains
(
"实训"
))
{
return
"实训"
;
}
return
"理论"
;
}
private
Integer
extractClassNumber
(
String
className
)
{
Matcher
matcher
=
CLASS_NUMBER_PATTERN
.
matcher
(
className
==
null
?
""
:
className
);
return
matcher
.
find
()
?
parseChineseNumber
(
matcher
.
group
(
1
))
:
null
;
}
/** 模板目前主要使用1班/2班,同时兼容一至十九的中文班号。 */
private
int
parseChineseNumber
(
String
value
)
{
if
(
value
.
matches
(
"\\d+"
))
{
return
Integer
.
parseInt
(
value
);
}
String
digits
=
"零一二三四五六七八九"
;
int
ten
=
value
.
indexOf
(
'十'
);
if
(
ten
<
0
)
{
int
number
=
digits
.
indexOf
(
value
.
charAt
(
0
));
if
(
number
>=
0
)
return
number
;
}
else
{
int
tens
=
ten
==
0
?
1
:
digits
.
indexOf
(
value
.
charAt
(
ten
-
1
));
int
ones
=
ten
==
value
.
length
()
-
1
?
0
:
digits
.
indexOf
(
value
.
charAt
(
ten
+
1
));
if
(
tens
>
0
&&
ones
>=
0
)
return
tens
*
10
+
ones
;
}
throw
new
BusinessException
(
"班号“"
+
value
+
"”无法识别"
);
}
private
String
cellText
(
XWPFTableRow
row
,
int
index
)
{
return
index
<
row
.
getTableCells
().
size
()
?
row
.
getCell
(
index
).
getText
()
:
""
;
}
private
String
normalizeCellText
(
String
value
)
{
return
value
==
null
?
""
:
value
.
replace
(
'\
u00A0
'
,
' '
)
.
replaceAll
(
"[\\r\\n\\t]+"
,
" "
).
replaceAll
(
"\\s+"
,
" "
).
trim
();
}
/** 解析阶段的内部结果,不暴露POI对象或未校验的原始文本。 */
static
final
class
ParsedImport
{
private
final
List
<
CourseAdminSaveDTO
>
courses
=
new
ArrayList
<>();
private
int
skippedUnitTrainingCount
;
List
<
CourseAdminSaveDTO
>
getCourses
()
{
return
courses
;
}
int
getSkippedUnitTrainingCount
()
{
return
skippedUnitTrainingCount
;
}
}
@Override
@Override
@Transactional
(
rollbackFor
=
Exception
.
class
)
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
CourseAdminScheduleVO
update
(
Integer
courseId
,
CourseAdminSaveDTO
request
)
{
public
CourseAdminScheduleVO
update
(
Integer
courseId
,
CourseAdminSaveDTO
request
)
{
...
...
practical-business/src/main/java/com/platform/business/service/impl/TeachingPlanServiceImpl.java
View file @
42f13c03
...
@@ -19,6 +19,7 @@ import com.platform.business.model.entity.TeachingPlanEntity;
...
@@ -19,6 +19,7 @@ import com.platform.business.model.entity.TeachingPlanEntity;
import
com.platform.business.model.entity.TeachingPlanStepEntity
;
import
com.platform.business.model.entity.TeachingPlanStepEntity
;
import
com.platform.business.model.vo.TeachingPlanAttachmentVO
;
import
com.platform.business.model.vo.TeachingPlanAttachmentVO
;
import
com.platform.business.model.vo.TeachingPlanTeacherOptionVO
;
import
com.platform.business.model.vo.TeachingPlanTeacherOptionVO
;
import
com.platform.business.model.vo.ClassAdminOptionVO
;
import
com.platform.business.model.vo.TeachingPlanVO
;
import
com.platform.business.model.vo.TeachingPlanVO
;
import
com.platform.business.model.vo.TeachingPlanStepVO
;
import
com.platform.business.model.vo.TeachingPlanStepVO
;
import
com.platform.business.service.BsFileService
;
import
com.platform.business.service.BsFileService
;
...
@@ -388,6 +389,12 @@ public class TeachingPlanServiceImpl implements TeachingPlanService {
...
@@ -388,6 +389,12 @@ public class TeachingPlanServiceImpl implements TeachingPlanService {
return
teachingPlanMapper
.
selectAdminTeacherOptions
();
return
teachingPlanMapper
.
selectAdminTeacherOptions
();
}
}
@Override
public
List
<
ClassAdminOptionVO
>
adminClassOptions
()
{
List
<
ClassAdminOptionVO
>
classes
=
teachingPlanMapper
.
selectAdminClassOptions
();
return
classes
==
null
?
Collections
.
emptyList
()
:
classes
;
}
@Override
@Override
public
void
exportAdminList
(
TeachingPlanAdminQueryDTO
query
,
HttpServletResponse
response
)
{
public
void
exportAdminList
(
TeachingPlanAdminQueryDTO
query
,
HttpServletResponse
response
)
{
TeachingPlanAdminQueryDTO
safeQuery
=
query
==
null
TeachingPlanAdminQueryDTO
safeQuery
=
query
==
null
...
...
practical-business/src/main/resources/account-management-api.md
View file @
42f13c03
...
@@ -31,6 +31,13 @@
...
@@ -31,6 +31,13 @@
状态约定:学员为
`PENDING / STUDYING / GRADUATED / ARCHIVED`
;教师和管理员为
状态约定:学员为
`PENDING / STUDYING / GRADUATED / ARCHIVED`
;教师和管理员为
`ENABLED / DISABLED`
。
`archiveOverSixMonths=true`
时只返回结业满六个月且尚未归档的学员。
`ENABLED / DISABLED`
。
`archiveOverSixMonths=true`
时只返回结业满六个月且尚未归档的学员。
### 学员目录树
`GET /account/admin/student-tree?keyword=污泥`
返回与班级管理完全一致的
`工种 → 年度 → 等级 → 班级`
目录树。学员分页和导出除
`classId`
外还支持
`occupation`
、
`trainingYear`
、
`levelId`
,因此点击任一层节点都可以查看该节点范围内的学员;
教师和管理员页签会忽略这些学员专用条件。
## 新增、编辑与状态
## 新增、编辑与状态
| 方法 | 路径 | 说明 |
| 方法 | 路径 | 说明 |
...
...
practical-business/src/main/resources/class-management-api.md
View file @
42f13c03
...
@@ -77,6 +77,9 @@
...
@@ -77,6 +77,9 @@
请求体与新增相同。编辑只更新班级基础信息,不删除或重建已有学员、排课、考试关系;计划人数
请求体与新增相同。编辑只更新班级基础信息,不删除或重建已有学员、排课、考试关系;计划人数
有值时不得小于当前实际学员数。清空班主任、地点、计划人数或备注时传
`null`
或空字符串。
有值时不得小于当前实际学员数。清空班主任、地点、计划人数或备注时传
`null`
或空字符串。
班级基础资料允许在
`UPCOMING`
(待开课)和
`ONGOING`
(进行中)状态编辑;
`ENDED`
(已结课)班级保持只读。
## 6. 班级详情
## 6. 班级详情
`GET /class/admin/{id}`
`GET /class/admin/{id}`
...
@@ -97,6 +100,9 @@
...
@@ -97,6 +100,9 @@
百分比字段以
`0~100`
的数值返回并最多保留两位小数,空值由页面展示为“—”。
百分比字段以
`0~100`
的数值返回并最多保留两位小数,空值由页面展示为“—”。
班级详情页的课程维护直接复用课程管理接口:查询、新增、Word导入、导出、整行调课和单节编辑
分别见
`course-management-api.md`
,提交的
`classId`
均取当前详情班级。
### 学员字段示例
### 学员字段示例
```
json
```
json
...
...
practical-business/src/main/resources/com/platform/business/mapper/AccountAdminMapper.xml
View file @
42f13c03
...
@@ -79,6 +79,15 @@
...
@@ -79,6 +79,15 @@
<if
test=
"query.classId != null"
>
<if
test=
"query.classId != null"
>
and c.id = #{query.classId}
and c.id = #{query.classId}
</if>
</if>
<if
test=
"query.occupation != null and query.occupation != ''"
>
and c.occupation = #{query.occupation}
</if>
<if
test=
"query.trainingYear != null"
>
and c.training_year = #{query.trainingYear}
</if>
<if
test=
"query.levelId != null"
>
and c.level = cast(#{query.levelId} as char)
</if>
<if
test=
"query.roleId != null"
>
<if
test=
"query.roleId != null"
>
and r.id = #{query.roleId}
and r.id = #{query.roleId}
</if>
</if>
...
@@ -146,6 +155,15 @@
...
@@ -146,6 +155,15 @@
<if
test=
"query.classId != null"
>
<if
test=
"query.classId != null"
>
and c.id = #{query.classId}
and c.id = #{query.classId}
</if>
</if>
<if
test=
"query.occupation != null and query.occupation != ''"
>
and c.occupation = #{query.occupation}
</if>
<if
test=
"query.trainingYear != null"
>
and c.training_year = #{query.trainingYear}
</if>
<if
test=
"query.levelId != null"
>
and c.level = cast(#{query.levelId} as char)
</if>
<if
test=
"query.status != null and query.status != ''"
>
<if
test=
"query.status != null and query.status != ''"
>
and
<include
refid=
"statusExpression"
/>
= #{query.status}
and
<include
refid=
"statusExpression"
/>
= #{query.status}
</if>
</if>
...
...
practical-business/src/main/resources/com/platform/business/mapper/TeachingPlanMapper.xml
View file @
42f13c03
...
@@ -233,4 +233,21 @@
...
@@ -233,4 +233,21 @@
GROUP BY p.teacher_id
GROUP BY p.teacher_id
ORDER BY teacherName ASC, p.teacher_id ASC
ORDER BY teacherName ASC, p.teacher_id ASC
</select>
</select>
<!--
查询条件只展示有效教案中真实存在的班级名称。value与label都使用班级名称,
可直接绑定TeachingPlanAdminQueryDTO.className并与列表的精确筛选保持一致。
-->
<select
id=
"selectAdminClassOptions"
resultType=
"com.platform.business.model.vo.ClassAdminOptionVO"
>
SELECT DISTINCT TRIM(p.class_name) AS value,
TRIM(p.class_name) AS label,
NULL AS parentValue,
NULL AS extra
FROM teaching_plan p
WHERE p.del_flag = 0
AND p.class_name IS NOT NULL
AND TRIM(p.class_name) != ''
ORDER BY value ASC
</select>
</mapper>
</mapper>
practical-business/src/main/resources/course-management-api.md
View file @
42f13c03
...
@@ -186,3 +186,19 @@ JWT解析当前用户并校验管理员角色,不接受客户端提交管理
...
@@ -186,3 +186,19 @@ JWT解析当前用户并校验管理员角色,不接受客户端提交管理
支持与列表相同的日期范围参数,返回带UTF-8 BOM的CSV。各课程按独立行输出,并包含
支持与列表相同的日期范围参数,返回带UTF-8 BOM的CSV。各课程按独立行输出,并包含
排课组ID和
`AM/PM/ALL_DAY`
期间,确保不同课程名或教师的信息不会在导出时丢失。
排课组ID和
`AM/PM/ALL_DAY`
期间,确保不同课程名或教师的信息不会在导出时丢失。
## 8. 从Word课程安排表导入
`POST /class/subject/admin/classes/{classId}/import`
,使用
`multipart/form-data`
上传
`file`
,仅支持
`.docx`
且文件不超过10MB。模板表头必须包含日期、课次、时段、课时、课程和授课教师。
导入规则:
-
月日使用目标班级的培训年度补全年份,教师姓名必须唯一匹配有效教师账户;
-
课程名含“理论”时导入为理论课,含“实操/实训”时导入为实训课,含“考核/考试”时导入为考核;
-
课程名称等于“单位实训”的行直接跳过,不校验该行日期和教师,也不生成课程记录;
-
对“上午:1班,下午:2班”一类分班备注,按目标班级名称中的班号选择上午或下午时段,
并按选中时段占比折算课次和课时;
-
全部非跳过行仍复用批量新增的教师、时段冲突及事务校验,任一行失败时整批不写入。
响应返回
`importedCount`
、
`skippedUnitTrainingCount`
以及刷新后的完整
`detail`
课程表。
practical-business/src/main/resources/teaching-plan-api.md
View file @
42f13c03
...
@@ -124,6 +124,8 @@
...
@@ -124,6 +124,8 @@
-
`keyword`
同时模糊匹配教案名称、章节和教师姓名。
-
`keyword`
同时模糊匹配教案名称、章节和教师姓名。
-
`className`
按授课班级精确筛选,
`courseType`
按理论课/实训课精确筛选。
-
`className`
按授课班级精确筛选,
`courseType`
按理论课/实训课精确筛选。
-
`GET /teaching/plan/admin/classes`
返回当前有效教案中实际存在的授课班级选项,
其
`value`
可直接提交到
`className`
查询条件。
-
`teacherId`
为空时查询全部教师。
-
`teacherId`
为空时查询全部教师。
-
`status`
为空或
`ALL`
时查询全部状态,状态值不区分大小写。
-
`status`
为空或
`ALL`
时查询全部状态,状态值不区分大小写。
-
日期范围按授课日期筛选并包含起止日。
-
日期范围按授课日期筛选并包含起止日。
...
...
practical-business/src/test/java/com/platform/business/service/impl/ClassAdminServiceImplTest.java
View file @
42f13c03
...
@@ -175,6 +175,26 @@ class ClassAdminServiceImplTest {
...
@@ -175,6 +175,26 @@ class ClassAdminServiceImplTest {
assertNull
(
captor
.
getValue
().
getRemark
());
assertNull
(
captor
.
getValue
().
getRemark
());
}
}
@Test
void
updateShouldAllowOngoingClass
()
{
LocalDate
today
=
LocalDate
.
now
(
ClassAdminConstants
.
BUSINESS_ZONE
);
ClassEntity
ongoing
=
new
ClassEntity
();
ongoing
.
setId
(
7
);
ongoing
.
setStartDate
(
Date
.
valueOf
(
today
.
minusDays
(
1
)));
ongoing
.
setEndDate
(
Date
.
valueOf
(
today
.
plusDays
(
30
)));
when
(
classMapper
.
selectById
(
7
)).
thenReturn
(
ongoing
);
when
(
classMapper
.
countAdminStudents
(
7
)).
thenReturn
(
10
);
mockValidLevel
();
when
(
classMapper
.
countAdminDuplicateName
(
2026
,
"污水处理一级三班"
,
7
)).
thenReturn
(
0
);
when
(
classMapper
.
updateAdminClass
(
any
(
ClassEntity
.
class
))).
thenReturn
(
1
);
mockEmptyDetail
(
7
,
Date
.
valueOf
(
today
.
minusDays
(
1
)),
Date
.
valueOf
(
today
.
plusDays
(
30
)));
ClassAdminDetailVO
result
=
service
.
update
(
7
,
validRequest
());
assertEquals
(
7
,
result
.
getId
());
verify
(
classMapper
).
updateAdminClass
(
any
(
ClassEntity
.
class
));
}
@Test
@Test
void
detailShouldUseLatestPublishedExamAndRealAggregates
()
{
void
detailShouldUseLatestPublishedExamAndRealAggregates
()
{
ClassAdminDetailVO
detail
=
baseDetail
(
8
,
ClassAdminDetailVO
detail
=
baseDetail
(
8
,
...
...
practical-business/src/test/java/com/platform/business/service/impl/CourseAdminServiceImplTest.java
View file @
42f13c03
...
@@ -12,6 +12,7 @@ import com.platform.business.model.entity.ClassSubjectEntity;
...
@@ -12,6 +12,7 @@ import com.platform.business.model.entity.ClassSubjectEntity;
import
com.platform.business.model.vo.CourseAdminDetailVO
;
import
com.platform.business.model.vo.CourseAdminDetailVO
;
import
com.platform.business.model.vo.CourseAdminScheduleVO
;
import
com.platform.business.model.vo.CourseAdminScheduleVO
;
import
com.platform.business.model.vo.CourseAdminScheduleGroupVO
;
import
com.platform.business.model.vo.CourseAdminScheduleGroupVO
;
import
com.platform.business.model.vo.ClassAdminOptionVO
;
import
com.platform.business.service.ClassAdminService
;
import
com.platform.business.service.ClassAdminService
;
import
com.platform.exception.BusinessException
;
import
com.platform.exception.BusinessException
;
import
org.junit.jupiter.api.Test
;
import
org.junit.jupiter.api.Test
;
...
@@ -20,6 +21,9 @@ import org.mockito.ArgumentCaptor;
...
@@ -20,6 +21,9 @@ import org.mockito.ArgumentCaptor;
import
org.mockito.InjectMocks
;
import
org.mockito.InjectMocks
;
import
org.mockito.Mock
;
import
org.mockito.Mock
;
import
org.mockito.junit.jupiter.MockitoExtension
;
import
org.mockito.junit.jupiter.MockitoExtension
;
import
org.apache.poi.xwpf.usermodel.XWPFDocument
;
import
org.apache.poi.xwpf.usermodel.XWPFTable
;
import
org.apache.poi.xwpf.usermodel.XWPFTableRow
;
import
java.math.BigDecimal
;
import
java.math.BigDecimal
;
import
java.sql.Date
;
import
java.sql.Date
;
...
@@ -383,6 +387,56 @@ class CourseAdminServiceImplTest {
...
@@ -383,6 +387,56 @@ class CourseAdminServiceImplTest {
verify
(
classSubjectMapper
,
never
()).
updateAdminCourse
(
any
(
ClassSubjectEntity
.
class
));
verify
(
classSubjectMapper
,
never
()).
updateAdminCourse
(
any
(
ClassSubjectEntity
.
class
));
}
}
@Test
void
parseImportShouldSkipUnitTrainingAndSelectTargetClassShift
()
throws
Exception
{
when
(
classSubjectMapper
.
selectAdminCourseTeacherOptions
()).
thenReturn
(
Arrays
.
asList
(
new
ClassAdminOptionVO
(
"teacher-1"
,
"张老师"
,
null
,
null
),
new
ClassAdminOptionVO
(
"teacher-2"
,
"李老师"
,
null
,
null
)));
ClassEntity
managedClass
=
new
ClassEntity
();
managedClass
.
setName
(
"污泥处理工四级1班"
);
managedClass
.
setTrainingYear
(
2026
);
try
(
XWPFDocument
document
=
new
XWPFDocument
())
{
XWPFTable
table
=
document
.
createTable
(
5
,
7
);
setImportRow
(
table
.
getRow
(
0
),
"日期"
,
"课次"
,
"时段"
,
"课时"
,
"课程"
,
"授课教师"
,
"序号"
);
setImportRow
(
table
.
getRow
(
1
),
"6/03 周三"
,
"4"
,
"09:00~10:20\n10:40~12:00\n13:00~14:20\n14:40~16:00"
,
"8"
,
"污泥干化焚烧运行案例(理论)"
,
"张老师"
,
"16"
);
setImportRow
(
table
.
getRow
(
2
),
""
,
"4"
,
"09:00~10:20\n10:40~12:00\n13:00~14:20\n14:40~16:00"
,
"8"
,
"单位实训"
,
""
,
"18"
);
setImportRow
(
table
.
getRow
(
3
),
"6/08 周一"
,
"4"
,
"09:00~10:20\n10:40~12:00\n13:00~14:20\n14:40~16:00"
,
"8"
,
"窒息剂的调配及影响因素(实操)(上午:1班,下午:2班)"
,
"李老师"
,
"19"
);
// 真实附件的6/15分班行漏写下午时段,解析器应按模板标准下午时段补齐。
setImportRow
(
table
.
getRow
(
4
),
"6/15 周一"
,
"4"
,
"09:00~10:20\n10:40~12:00"
,
"8"
,
"现场异常情况模拟演练(上午:2班,下午:1班)"
,
"李老师"
,
"25"
);
CourseAdminServiceImpl
.
ParsedImport
parsed
=
service
.
parseImportDocument
(
document
,
managedClass
);
assertEquals
(
3
,
parsed
.
getCourses
().
size
());
assertEquals
(
1
,
parsed
.
getSkippedUnitTrainingCount
());
CourseAdminSaveDTO
practical
=
parsed
.
getCourses
().
get
(
1
);
assertEquals
(
Arrays
.
asList
(
"09:00-10:20"
,
"10:40-12:00"
),
practical
.
getTimeFrames
());
assertEquals
(
2
,
practical
.
getSubjectTimes
());
assertEquals
(
0
,
new
BigDecimal
(
"4"
).
compareTo
(
practical
.
getSubjectHour
()));
assertEquals
(
"实训"
,
practical
.
getType
());
assertEquals
(
"teacher-2"
,
practical
.
getTeacherId
());
assertEquals
(
Arrays
.
asList
(
"13:00-14:20"
,
"14:40-16:00"
),
parsed
.
getCourses
().
get
(
2
).
getTimeFrames
());
}
}
/** 按模板列顺序写入测试表格,确保解析测试与真实Word导入格式一致。 */
private
void
setImportRow
(
XWPFTableRow
row
,
String
...
values
)
{
for
(
int
i
=
0
;
i
<
values
.
length
;
i
++)
{
row
.
getCell
(
i
).
setText
(
values
[
i
]);
}
}
private
void
mockWritableClass
()
{
private
void
mockWritableClass
()
{
when
(
classSubjectMapper
.
lockAdminCourseClass
(
1
)).
thenReturn
(
1
);
when
(
classSubjectMapper
.
lockAdminCourseClass
(
1
)).
thenReturn
(
1
);
ClassEntity
managedClass
=
new
ClassEntity
();
ClassEntity
managedClass
=
new
ClassEntity
();
...
...
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