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
7ada3155
Commit
7ada3155
authored
Aug 11, 2026
by
wujipeng
Browse files
Merge remote-tracking branch 'origin/dev-v1.0' into dev-v1.0
parents
04355d28
a6e34844
Changes
23
Hide whitespace changes
Inline
Side-by-side
practical-api/practical-business-api/src/main/java/com/platform/business/model/dto/EvaluationBatchRevokeDTO.java
0 → 100644
View file @
7ada3155
package
com.platform.business.model.dto
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
import
java.util.List
;
/** 管理端批量撤回评价任务请求。 */
@Data
public
class
EvaluationBatchRevokeDTO
{
@ApiModelProperty
(
value
=
"待撤回任务ID列表"
,
required
=
true
)
private
List
<
String
>
taskIds
;
}
practical-api/practical-business-api/src/main/java/com/platform/business/model/dto/EvaluationSubmitDTO.java
0 → 100644
View file @
7ada3155
package
com.platform.business.model.dto
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
/** 学员提交七个必填维度及一项选填建议。 */
@Data
public
class
EvaluationSubmitDTO
{
@ApiModelProperty
(
value
=
"教学态度:GOOD/FAIR/OK/POOR"
,
required
=
true
)
private
String
teachingAttitude
;
@ApiModelProperty
(
value
=
"教学内容:GOOD/FAIR/OK/POOR"
,
required
=
true
)
private
String
teachingContent
;
@ApiModelProperty
(
value
=
"教学方法:GOOD/FAIR/OK/POOR"
,
required
=
true
)
private
String
teachingMethod
;
@ApiModelProperty
(
value
=
"教学手段:GOOD/FAIR/OK/POOR"
,
required
=
true
)
private
String
teachingMeans
;
@ApiModelProperty
(
value
=
"讲解示范:GOOD/FAIR/OK/POOR"
,
required
=
true
)
private
String
demonstration
;
@ApiModelProperty
(
value
=
"巡回指导:GOOD/FAIR/OK/POOR"
,
required
=
true
)
private
String
guidance
;
@ApiModelProperty
(
value
=
"课时完成情况:GOOD/FAIR/OK/POOR"
,
required
=
true
)
private
String
classHourCompletion
;
@ApiModelProperty
(
"意见与建议,选填,最长1000字符"
)
private
String
comment
;
}
practical-api/practical-business-api/src/main/java/com/platform/business/model/dto/EvaluationTaskCreateDTO.java
0 → 100644
View file @
7ada3155
package
com.platform.business.model.dto
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
/** 管理员发起学员评议任务请求。 */
@Data
public
class
EvaluationTaskCreateDTO
{
@ApiModelProperty
(
value
=
"班级课程ID(class_subject.id)"
,
required
=
true
)
private
Integer
subjectId
;
@ApiModelProperty
(
value
=
"评价截止日期/时间;日期会按当天23:59:59处理"
,
required
=
true
,
example
=
"2026-08-14"
)
private
String
deadline
;
}
practical-api/practical-business-api/src/main/java/com/platform/business/model/dto/EvaluationTaskQueryDTO.java
0 → 100644
View file @
7ada3155
package
com.platform.business.model.dto
;
import
com.fasterxml.jackson.annotation.JsonFormat
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
import
java.util.Date
;
/**
* 评价任务分页及导出筛选条件。
*
* <p>学员端只使用 status、pageNum 和 pageSize,且服务端会强制追加当前登录学员ID;
* 管理端可使用全部条件。</p>
*/
@Data
public
class
EvaluationTaskQueryDTO
{
@ApiModelProperty
(
"课程名称,支持模糊匹配"
)
private
String
courseName
;
@ApiModelProperty
(
"班级ID"
)
private
Integer
classId
;
@ApiModelProperty
(
"授课教师用户ID"
)
private
String
teacherId
;
@ApiModelProperty
(
"上课日期范围起点"
)
@JsonFormat
(
pattern
=
"yyyy-MM-dd"
,
timezone
=
"GMT+8"
)
private
Date
startDate
;
@ApiModelProperty
(
"上课日期范围终点"
)
@JsonFormat
(
pattern
=
"yyyy-MM-dd"
,
timezone
=
"GMT+8"
)
private
Date
endDate
;
@ApiModelProperty
(
"PENDING、COMPLETED、EXPIRED、REVOKED"
)
private
String
status
;
@ApiModelProperty
(
"课程类型,例如理论或实训"
)
private
String
type
;
private
Integer
pageNum
;
private
Integer
pageSize
;
}
practical-api/practical-business-api/src/main/java/com/platform/business/model/entity/EvaluationRecordEntity.java
0 → 100644
View file @
7ada3155
package
com.platform.business.model.entity
;
import
com.baomidou.mybatisplus.annotation.IdType
;
import
com.baomidou.mybatisplus.annotation.TableId
;
import
com.baomidou.mybatisplus.annotation.TableName
;
import
lombok.Data
;
import
java.util.Date
;
/**
* 单个目标学员的评价记录。
*
* <p>管理员发起任务时即为班级内每位有效学员建立一行 PENDING 记录。这样既能准确计算
* 待评/已评人数,也能确保后来转入班级的学员不会被错误加入历史任务。</p>
*/
@Data
@TableName
(
"evaluation_record"
)
public
class
EvaluationRecordEntity
{
@TableId
(
value
=
"id"
,
type
=
IdType
.
INPUT
)
private
String
id
;
private
String
taskId
;
private
String
studentId
;
/** PENDING 或 SUBMITTED;提交成功后禁止再次修改。 */
private
String
status
;
private
String
teachingAttitude
;
private
String
teachingContent
;
private
String
teachingMethod
;
private
String
teachingMeans
;
private
String
demonstration
;
private
String
guidance
;
private
String
classHourCompletion
;
/** 意见与建议,选填,最长1000字符。 */
private
String
comment
;
private
Date
submittedAt
;
private
Date
createdTime
;
private
Date
updateTime
;
}
practical-api/practical-business-api/src/main/java/com/platform/business/model/entity/EvaluationTaskEntity.java
0 → 100644
View file @
7ada3155
package
com.platform.business.model.entity
;
import
com.baomidou.mybatisplus.annotation.IdType
;
import
com.baomidou.mybatisplus.annotation.TableId
;
import
com.baomidou.mybatisplus.annotation.TableName
;
import
lombok.Data
;
import
java.util.Date
;
/**
* 学员评议任务主表。
*
* <p>任务只保存课程ID和状态等过程数据;课程、班级、教师名称由查询时关联业务表获取,
* 防止同一份展示信息被重复维护。目标学员则由评价记录表在发起时形成快照。</p>
*/
@Data
@TableName
(
"evaluation_task"
)
public
class
EvaluationTaskEntity
{
/** 雪花算法字符串ID,和项目现有业务主键风格保持一致。 */
@TableId
(
value
=
"id"
,
type
=
IdType
.
INPUT
)
private
String
id
;
/** 对应一节具体课程,同一课程只能发起一个有效评价任务。 */
private
Integer
subjectId
;
/** PENDING、COMPLETED、EXPIRED、REVOKED。 */
private
String
status
;
/** 学员最晚可提交时间,精确到秒。 */
private
Date
deadline
;
/** 发起任务的管理员用户ID。 */
private
String
createdBy
;
private
Date
createdTime
;
/** 状态或其他业务字段最后更新时间。 */
private
Date
updateTime
;
/** 管理员撤回任务的时间,未撤回时为空。 */
private
Date
revokedAt
;
/** 执行撤回的管理员用户ID,未撤回时为空。 */
private
String
revokedBy
;
}
practical-api/practical-business-api/src/main/java/com/platform/business/model/vo/EvaluationDimensionStatisticsVO.java
0 → 100644
View file @
7ada3155
package
com.platform.business.model.vo
;
import
lombok.Data
;
/** 管理端单个评分维度的四档数量及占比。 */
@Data
public
class
EvaluationDimensionStatisticsVO
{
/** 与提交DTO字段一致的稳定英文键。 */
private
String
dimensionKey
;
private
String
dimensionName
;
private
Integer
goodCount
;
private
Integer
fairCount
;
private
Integer
okCount
;
private
Integer
poorCount
;
private
Integer
submittedCount
;
/** GOOD=4、FAIR=3、OK=2、POOR=1计算出的平均分,暂无提交时为0。 */
private
Double
averageScore
;
}
practical-api/practical-business-api/src/main/java/com/platform/business/model/vo/EvaluationRecordVO.java
0 → 100644
View file @
7ada3155
package
com.platform.business.model.vo
;
import
com.fasterxml.jackson.annotation.JsonFormat
;
import
lombok.Data
;
import
java.util.Date
;
/** 管理员查看的实名学员评价明细。 */
@Data
public
class
EvaluationRecordVO
{
private
String
id
;
private
String
taskId
;
private
String
studentId
;
private
String
studentName
;
private
String
phoneNumber
;
private
String
status
;
private
String
teachingAttitude
;
private
String
teachingContent
;
private
String
teachingMethod
;
private
String
teachingMeans
;
private
String
demonstration
;
private
String
guidance
;
private
String
classHourCompletion
;
private
String
comment
;
@JsonFormat
(
pattern
=
"yyyy-MM-dd HH:mm:ss"
,
timezone
=
"GMT+8"
)
private
Date
submittedAt
;
}
practical-api/practical-business-api/src/main/java/com/platform/business/model/vo/EvaluationTaskDetailVO.java
0 → 100644
View file @
7ada3155
package
com.platform.business.model.vo
;
import
lombok.Data
;
import
lombok.EqualsAndHashCode
;
import
java.util.List
;
/** 管理端任务详情,包含实名评价明细和七维度汇总。 */
@Data
@EqualsAndHashCode
(
callSuper
=
true
)
public
class
EvaluationTaskDetailVO
extends
EvaluationTaskVO
{
private
List
<
EvaluationRecordVO
>
records
;
private
List
<
EvaluationDimensionStatisticsVO
>
dimensionStatistics
;
}
practical-api/practical-business-api/src/main/java/com/platform/business/model/vo/EvaluationTaskVO.java
0 → 100644
View file @
7ada3155
package
com.platform.business.model.vo
;
import
com.fasterxml.jackson.annotation.JsonFormat
;
import
lombok.Data
;
import
java.util.Date
;
/** 管理端评价任务列表和任务基础详情。 */
@Data
public
class
EvaluationTaskVO
{
private
String
id
;
private
Integer
subjectId
;
private
String
courseName
;
private
Integer
classId
;
private
String
className
;
/** 原型中的课次信息,对应 class_subject.subject_times。 */
private
Integer
subjectTimes
;
private
String
teacherId
;
private
String
teacherName
;
@JsonFormat
(
pattern
=
"yyyy-MM-dd HH:mm:ss"
,
timezone
=
"GMT+8"
)
private
Date
courseDate
;
private
String
timeFrame
;
private
String
type
;
@JsonFormat
(
pattern
=
"yyyy-MM-dd HH:mm:ss"
,
timezone
=
"GMT+8"
)
private
Date
deadline
;
private
String
status
;
private
Integer
totalCount
;
private
Integer
pendingCount
;
private
Integer
submittedCount
;
/** 已评人数 / 总人数,返回0到100之间的百分比。 */
private
Double
completionRate
;
private
String
createdBy
;
private
String
creatorName
;
@JsonFormat
(
pattern
=
"yyyy-MM-dd HH:mm:ss"
,
timezone
=
"GMT+8"
)
private
Date
createdTime
;
@JsonFormat
(
pattern
=
"yyyy-MM-dd HH:mm:ss"
,
timezone
=
"GMT+8"
)
private
Date
revokedAt
;
private
String
revokedBy
;
private
String
revokerName
;
}
practical-api/practical-business-api/src/main/java/com/platform/business/model/vo/StudentEvaluationTaskVO.java
0 → 100644
View file @
7ada3155
package
com.platform.business.model.vo
;
import
com.fasterxml.jackson.annotation.JsonFormat
;
import
lombok.Data
;
import
java.util.Date
;
/**
* 学员端“我的评价”列表及本人评价详情。
*
* <p>该对象不包含其他学员信息和汇总结果。已提交时仅返回当前学员自己的内容。</p>
*/
@Data
public
class
StudentEvaluationTaskVO
{
private
String
taskId
;
private
Integer
subjectId
;
private
String
courseName
;
private
String
teacherName
;
private
String
className
;
private
Integer
subjectTimes
;
@JsonFormat
(
pattern
=
"yyyy-MM-dd HH:mm:ss"
,
timezone
=
"GMT+8"
)
private
Date
courseDate
;
private
String
timeFrame
;
private
String
type
;
@JsonFormat
(
pattern
=
"yyyy-MM-dd HH:mm:ss"
,
timezone
=
"GMT+8"
)
private
Date
deadline
;
/** 任务最终状态;撤回任务不会出现在学员列表中。 */
private
String
taskStatus
;
private
String
recordStatus
;
private
String
teachingAttitude
;
private
String
teachingContent
;
private
String
teachingMethod
;
private
String
teachingMeans
;
private
String
demonstration
;
private
String
guidance
;
private
String
classHourCompletion
;
private
String
comment
;
@JsonFormat
(
pattern
=
"yyyy-MM-dd HH:mm:ss"
,
timezone
=
"GMT+8"
)
private
Date
submittedAt
;
}
practical-business/src/main/java/com/platform/business/constant/EvaluationConstants.java
0 → 100644
View file @
7ada3155
package
com.platform.business.constant
;
import
java.util.Arrays
;
import
java.util.Collections
;
import
java.util.HashSet
;
import
java.util.Set
;
/**
* 学员评议模块常量。
*
* <p>状态值和评分值会同时写入数据库、出现在接口报文中,因此集中定义,避免各层使用
* 不一致的大小写或中文值。数据库建表 SQL 中的字段注释也与本类保持一致。</p>
*/
public
final
class
EvaluationConstants
{
/** 任务尚可提交评价。 */
public
static
final
String
TASK_PENDING
=
"PENDING"
;
/** 任务下全部目标学员均已提交。 */
public
static
final
String
TASK_COMPLETED
=
"COMPLETED"
;
/** 到达截止时间后仍未全部完成。 */
public
static
final
String
TASK_EXPIRED
=
"EXPIRED"
;
/** 管理员主动撤回。 */
public
static
final
String
TASK_REVOKED
=
"REVOKED"
;
/** 学员尚未提交。 */
public
static
final
String
RECORD_PENDING
=
"PENDING"
;
/** 学员已提交,提交后不可修改。 */
public
static
final
String
RECORD_SUBMITTED
=
"SUBMITTED"
;
/** 原型中的四档评分值。 */
public
static
final
String
SCORE_GOOD
=
"GOOD"
;
public
static
final
String
SCORE_FAIR
=
"FAIR"
;
public
static
final
String
SCORE_OK
=
"OK"
;
public
static
final
String
SCORE_POOR
=
"POOR"
;
/** 允许写入的全部评分值,用于统一校验七个必填维度。 */
public
static
final
Set
<
String
>
ALLOWED_SCORES
=
Collections
.
unmodifiableSet
(
new
HashSet
<>(
Arrays
.
asList
(
SCORE_GOOD
,
SCORE_FAIR
,
SCORE_OK
,
SCORE_POOR
)));
/** 允许用于任务列表筛选的全部任务状态。 */
public
static
final
Set
<
String
>
ALLOWED_TASK_STATUSES
=
Collections
.
unmodifiableSet
(
new
HashSet
<>(
Arrays
.
asList
(
TASK_PENDING
,
TASK_COMPLETED
,
TASK_EXPIRED
,
TASK_REVOKED
)));
private
EvaluationConstants
()
{
}
}
practical-business/src/main/java/com/platform/business/controller/EvaluationController.java
0 → 100644
View file @
7ada3155
package
com.platform.business.controller
;
import
com.platform.business.model.dto.EvaluationBatchRevokeDTO
;
import
com.platform.business.model.dto.EvaluationSubmitDTO
;
import
com.platform.business.model.dto.EvaluationTaskCreateDTO
;
import
com.platform.business.model.dto.EvaluationTaskQueryDTO
;
import
com.platform.business.model.entity.UserEntity
;
import
com.platform.business.model.vo.EvaluationTaskDetailVO
;
import
com.platform.business.model.vo.EvaluationTaskVO
;
import
com.platform.business.model.vo.StudentEvaluationTaskVO
;
import
com.platform.business.service.AuthenticatedUserService
;
import
com.platform.business.service.EvaluationService
;
import
com.platform.controller.BaseController
;
import
com.platform.model.resp.Result
;
import
com.platform.page.TableDataInfo
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.PutMapping
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RestController
;
import
javax.annotation.Resource
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
java.util.List
;
/**
* 学员评议两端接口。
*
* <p>教师端没有对应原型,本控制器不提供任何教师查询入口。学员身份始终从JWT解析,客户端
* 无法通过传入studentId查看或提交他人评价;所有管理端接口均额外校验管理员角色。</p>
*/
@Api
(
tags
=
"学员评议"
)
@RestController
@RequestMapping
(
"/evaluation"
)
public
class
EvaluationController
extends
BaseController
{
@Resource
private
EvaluationService
evaluationService
;
@Resource
private
AuthenticatedUserService
authenticatedUserService
;
@ApiOperation
(
"学员端-分页查询本人的待评价、已评价和已过期任务"
)
@PostMapping
(
"/student/page"
)
public
TableDataInfo
studentPage
(
@RequestBody
(
required
=
false
)
EvaluationTaskQueryDTO
query
,
HttpServletRequest
request
)
{
UserEntity
student
=
authenticatedUserService
.
current
(
request
);
EvaluationTaskQueryDTO
safeQuery
=
query
==
null
?
new
EvaluationTaskQueryDTO
()
:
query
;
startEvaluationPage
(
safeQuery
);
return
getDataTable
(
evaluationService
.
queryStudentTasks
(
safeQuery
,
student
.
getId
()));
}
@ApiOperation
(
"学员端-查看本人评价表单或已提交内容"
)
@GetMapping
(
"/student/{taskId}"
)
public
Result
<
StudentEvaluationTaskVO
>
studentDetail
(
@PathVariable
String
taskId
,
HttpServletRequest
request
)
{
UserEntity
student
=
authenticatedUserService
.
current
(
request
);
return
Result
.
data
(
evaluationService
.
studentDetail
(
taskId
,
student
.
getId
()));
}
@ApiOperation
(
"学员端-提交评价(七个维度必填且仅可提交一次)"
)
@PostMapping
(
"/student/{taskId}/submit"
)
public
Result
<
StudentEvaluationTaskVO
>
submit
(
@PathVariable
String
taskId
,
@RequestBody
EvaluationSubmitDTO
body
,
HttpServletRequest
request
)
{
UserEntity
student
=
authenticatedUserService
.
current
(
request
);
return
Result
.
data
(
evaluationService
.
submit
(
taskId
,
body
,
student
.
getId
()));
}
@ApiOperation
(
"管理端-发起评价任务并推送给班级当前有效学员"
)
@PostMapping
(
"/admin/task"
)
public
Result
<
EvaluationTaskVO
>
createTask
(
@RequestBody
EvaluationTaskCreateDTO
body
,
HttpServletRequest
request
)
{
UserEntity
admin
=
requireAdmin
(
request
);
return
Result
.
data
(
evaluationService
.
createTask
(
body
,
admin
.
getId
(),
admin
.
getNickName
()));
}
@ApiOperation
(
"管理端-分页筛选评价任务"
)
@PostMapping
(
"/admin/page"
)
public
TableDataInfo
adminPage
(
@RequestBody
(
required
=
false
)
EvaluationTaskQueryDTO
query
,
HttpServletRequest
request
)
{
requireAdmin
(
request
);
EvaluationTaskQueryDTO
safeQuery
=
query
==
null
?
new
EvaluationTaskQueryDTO
()
:
query
;
startEvaluationPage
(
safeQuery
);
return
getDataTable
(
evaluationService
.
queryAdminTasks
(
safeQuery
));
}
@ApiOperation
(
"管理端-查看实名评价明细和七维度统计"
)
@GetMapping
(
"/admin/{taskId}"
)
public
Result
<
EvaluationTaskDetailVO
>
adminDetail
(
@PathVariable
String
taskId
,
@RequestParam
(
required
=
false
)
String
studentName
,
HttpServletRequest
request
)
{
requireAdmin
(
request
);
return
Result
.
data
(
evaluationService
.
adminDetail
(
taskId
,
studentName
));
}
@ApiOperation
(
"管理端-撤回一个待评价任务"
)
@PutMapping
(
"/admin/{taskId}/revoke"
)
public
Result
<
Boolean
>
revoke
(
@PathVariable
String
taskId
,
HttpServletRequest
request
)
{
UserEntity
admin
=
requireAdmin
(
request
);
return
Result
.
data
(
evaluationService
.
revoke
(
taskId
,
admin
.
getId
()));
}
@ApiOperation
(
"管理端-批量撤回待评价任务"
)
@PutMapping
(
"/admin/batch-revoke"
)
public
Result
<
Integer
>
batchRevoke
(
@RequestBody
EvaluationBatchRevokeDTO
body
,
HttpServletRequest
request
)
{
UserEntity
admin
=
requireAdmin
(
request
);
List
<
String
>
taskIds
=
body
==
null
?
null
:
body
.
getTaskIds
();
return
Result
.
data
(
evaluationService
.
batchRevoke
(
taskIds
,
admin
.
getId
()));
}
@ApiOperation
(
"管理端-按筛选条件导出评价任务汇总Excel"
)
@PostMapping
(
"/admin/export"
)
public
void
exportTasks
(
@RequestBody
(
required
=
false
)
EvaluationTaskQueryDTO
query
,
HttpServletRequest
request
,
HttpServletResponse
response
)
{
requireAdmin
(
request
);
evaluationService
.
exportAdminTasks
(
query
,
response
);
}
@ApiOperation
(
"管理端-导出单个任务实名明细及维度统计Excel"
)
@GetMapping
(
"/admin/{taskId}/export"
)
public
void
exportDetail
(
@PathVariable
String
taskId
,
HttpServletRequest
request
,
HttpServletResponse
response
)
{
requireAdmin
(
request
);
evaluationService
.
exportTaskDetail
(
taskId
,
response
);
}
/** 评价列表缺省第1页、每页10条,并限制异常的大页请求。 */
private
void
startEvaluationPage
(
EvaluationTaskQueryDTO
query
)
{
int
pageNum
=
query
.
getPageNum
()
==
null
||
query
.
getPageNum
()
<
1
?
1
:
query
.
getPageNum
();
int
pageSize
=
query
.
getPageSize
()
==
null
||
query
.
getPageSize
()
<
1
?
10
:
query
.
getPageSize
();
startPage
(
pageNum
,
Math
.
min
(
pageSize
,
100
));
}
/** 统一完成JWT用户解析和管理员角色校验。 */
private
UserEntity
requireAdmin
(
HttpServletRequest
request
)
{
UserEntity
user
=
authenticatedUserService
.
current
(
request
);
authenticatedUserService
.
requireAdmin
(
user
);
return
user
;
}
}
practical-business/src/main/java/com/platform/business/mapper/EvaluationRecordMapper.java
0 → 100644
View file @
7ada3155
package
com.platform.business.mapper
;
import
com.baomidou.mybatisplus.core.mapper.BaseMapper
;
import
com.platform.business.model.entity.EvaluationRecordEntity
;
import
com.platform.business.model.vo.EvaluationRecordVO
;
import
org.apache.ibatis.annotations.Mapper
;
import
org.apache.ibatis.annotations.Param
;
import
java.util.Date
;
import
java.util.List
;
/** 目标学员快照、评价提交和管理端实名明细的数据访问接口。 */
@Mapper
public
interface
EvaluationRecordMapper
extends
BaseMapper
<
EvaluationRecordEntity
>
{
/** 一次性写入一个班级的目标学员快照。 */
int
batchInsert
(
@Param
(
"records"
)
List
<
EvaluationRecordEntity
>
records
);
/** 学员提交前锁定本人的评价行,确保同一账号并发提交只有一次成功。 */
EvaluationRecordEntity
selectByTaskAndStudentForUpdate
(
@Param
(
"taskId"
)
String
taskId
,
@Param
(
"studentId"
)
String
studentId
);
/**
* 仅更新PENDING记录。虽然调用方已经持有行锁,SQL仍保留状态条件作为最后一道幂等保护。
*/
int
submitPending
(
@Param
(
"record"
)
EvaluationRecordEntity
record
,
@Param
(
"now"
)
Date
now
);
/** 管理端查询任务全部目标学员;可按姓名模糊筛选。 */
List
<
EvaluationRecordVO
>
queryTaskRecords
(
@Param
(
"taskId"
)
String
taskId
,
@Param
(
"studentName"
)
String
studentName
);
}
practical-business/src/main/java/com/platform/business/mapper/EvaluationTaskMapper.java
0 → 100644
View file @
7ada3155
package
com.platform.business.mapper
;
import
com.baomidou.mybatisplus.core.mapper.BaseMapper
;
import
com.platform.business.model.dto.EvaluationTaskQueryDTO
;
import
com.platform.business.model.entity.EvaluationTaskEntity
;
import
com.platform.business.model.vo.EvaluationTaskVO
;
import
com.platform.business.model.vo.StudentEvaluationTaskVO
;
import
org.apache.ibatis.annotations.Mapper
;
import
org.apache.ibatis.annotations.Param
;
import
java.util.Date
;
import
java.util.List
;
/** 评价任务查询、状态流转和目标学员快照的数据访问接口。 */
@Mapper
public
interface
EvaluationTaskMapper
extends
BaseMapper
<
EvaluationTaskEntity
>
{
/** 管理端按原型筛选条件查询全部任务及实时完成进度。 */
List
<
EvaluationTaskVO
>
queryAdminTasks
(
EvaluationTaskQueryDTO
query
);
/** 学员端仅查询已经分配给当前登录学员且未撤回的任务。 */
List
<
StudentEvaluationTaskVO
>
queryStudentTasks
(
@Param
(
"query"
)
EvaluationTaskQueryDTO
query
,
@Param
(
"studentId"
)
String
studentId
);
/** 查询管理端单个任务基础信息及实时人数统计。 */
EvaluationTaskVO
selectTaskView
(
@Param
(
"taskId"
)
String
taskId
);
/** 查询当前学员自己的单条任务;taskId和studentId必须同时匹配。 */
StudentEvaluationTaskVO
selectStudentTask
(
@Param
(
"taskId"
)
String
taskId
,
@Param
(
"studentId"
)
String
studentId
);
/**
* 锁定任务主记录。提交与撤回都先获取该锁,从而串行化两种互斥操作,
* 防止学员提交成功的同时管理员又把同一任务撤回。
*/
EvaluationTaskEntity
selectByIdForUpdate
(
@Param
(
"taskId"
)
String
taskId
);
/** 将已过截止时间的待评价任务批量推进为EXPIRED。 */
int
expireDueTasks
(
@Param
(
"now"
)
Date
now
);
/** 提交入口发现本任务已到期时,仅推进当前任务,避免额外扩大锁范围。 */
int
expirePendingTask
(
@Param
(
"taskId"
)
String
taskId
,
@Param
(
"now"
)
Date
now
);
/** 仅当任务仍为PENDING时撤回,返回0表示状态已被并发改变。 */
int
revokePending
(
@Param
(
"taskId"
)
String
taskId
,
@Param
(
"operatorId"
)
String
operatorId
,
@Param
(
"now"
)
Date
now
);
/** 最后一位学员提交后,把没有待评价记录的任务推进为COMPLETED。 */
int
completeIfAllSubmitted
(
@Param
(
"taskId"
)
String
taskId
,
@Param
(
"now"
)
Date
now
);
/** 发起任务时读取班级当前所有未删除学员,后续写入评价记录形成快照。 */
List
<
String
>
selectActiveStudentIdsByClassId
(
@Param
(
"classId"
)
Integer
classId
);
}
practical-business/src/main/java/com/platform/business/service/AuthenticatedUserService.java
View file @
7ada3155
...
@@ -55,7 +55,8 @@ public class AuthenticatedUserService {
...
@@ -55,7 +55,8 @@ public class AuthenticatedUserService {
List
<
SysPhoneRoleEntity
>
roles
=
phoneRoleService
.
queryByPhone
(
user
.
getPhoneNumber
());
List
<
SysPhoneRoleEntity
>
roles
=
phoneRoleService
.
queryByPhone
(
user
.
getPhoneNumber
());
boolean
admin
=
roles
!=
null
&&
roles
.
stream
().
anyMatch
(
role
->
"管理员"
.
equals
(
role
.
getRoleName
()));
boolean
admin
=
roles
!=
null
&&
roles
.
stream
().
anyMatch
(
role
->
"管理员"
.
equals
(
role
.
getRoleName
()));
if
(!
admin
)
{
if
(!
admin
)
{
throw
new
BusinessException
(
"只有管理员可以发布平台消息"
);
// 本方法同时被消息中心、请假、评议等管理端模块复用,因此使用通用权限提示。
throw
new
BusinessException
(
"只有管理员可以访问管理端接口"
);
}
}
}
}
...
...
practical-business/src/main/java/com/platform/business/service/EvaluationService.java
0 → 100644
View file @
7ada3155
package
com.platform.business.service
;
import
com.platform.business.model.dto.EvaluationSubmitDTO
;
import
com.platform.business.model.dto.EvaluationTaskCreateDTO
;
import
com.platform.business.model.dto.EvaluationTaskQueryDTO
;
import
com.platform.business.model.vo.EvaluationTaskDetailVO
;
import
com.platform.business.model.vo.EvaluationTaskVO
;
import
com.platform.business.model.vo.StudentEvaluationTaskVO
;
import
javax.servlet.http.HttpServletResponse
;
import
java.util.List
;
/** 学员端和管理端学员评议应用服务。 */
public
interface
EvaluationService
{
/** 管理员发起任务,并向本次固化的目标学员推送待评价消息。 */
EvaluationTaskVO
createTask
(
EvaluationTaskCreateDTO
request
,
String
adminId
,
String
adminName
);
/** 管理端按原型条件查询全部评价任务。 */
List
<
EvaluationTaskVO
>
queryAdminTasks
(
EvaluationTaskQueryDTO
query
);
/** 管理端查看任务实名明细;studentName为空时返回全部目标学员。 */
EvaluationTaskDetailVO
adminDetail
(
String
taskId
,
String
studentName
);
/** 管理员撤回一个仍处于待评价状态的任务。 */
boolean
revoke
(
String
taskId
,
String
adminId
);
/** 管理员以全有或全无的事务方式批量撤回待评价任务。 */
int
batchRevoke
(
List
<
String
>
taskIds
,
String
adminId
);
/** 学员端查询只分配给本人的待评价、已评价或已过期记录。 */
List
<
StudentEvaluationTaskVO
>
queryStudentTasks
(
EvaluationTaskQueryDTO
query
,
String
studentId
);
/** 学员查看本人的评价表单或已提交内容,不返回其他人的任何数据。 */
StudentEvaluationTaskVO
studentDetail
(
String
taskId
,
String
studentId
);
/** 学员一次性提交七个必填维度,成功后不可修改。 */
StudentEvaluationTaskVO
submit
(
String
taskId
,
EvaluationSubmitDTO
request
,
String
studentId
);
/** 按当前管理端筛选条件导出任务汇总Excel。 */
void
exportAdminTasks
(
EvaluationTaskQueryDTO
query
,
HttpServletResponse
response
);
/** 导出单个任务的实名评价明细和七维度统计Excel。 */
void
exportTaskDetail
(
String
taskId
,
HttpServletResponse
response
);
}
practical-business/src/main/java/com/platform/business/service/impl/EvaluationServiceImpl.java
0 → 100644
View file @
7ada3155
package
com.platform.business.service.impl
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.baomidou.mybatisplus.core.toolkit.IdWorker
;
import
com.platform.business.constant.EvaluationConstants
;
import
com.platform.business.mapper.EvaluationRecordMapper
;
import
com.platform.business.mapper.EvaluationTaskMapper
;
import
com.platform.business.model.dto.EvaluationSubmitDTO
;
import
com.platform.business.model.dto.EvaluationTaskCreateDTO
;
import
com.platform.business.model.dto.EvaluationTaskQueryDTO
;
import
com.platform.business.model.dto.NotificationPublishDTO
;
import
com.platform.business.model.entity.ClassSubjectEntity
;
import
com.platform.business.model.entity.EvaluationRecordEntity
;
import
com.platform.business.model.entity.EvaluationTaskEntity
;
import
com.platform.business.model.vo.EvaluationDimensionStatisticsVO
;
import
com.platform.business.model.vo.EvaluationRecordVO
;
import
com.platform.business.model.vo.EvaluationTaskDetailVO
;
import
com.platform.business.model.vo.EvaluationTaskVO
;
import
com.platform.business.model.vo.StudentEvaluationTaskVO
;
import
com.platform.business.service.BusinessNotificationPublisher
;
import
com.platform.business.service.ClassSubjectService
;
import
com.platform.business.service.EvaluationService
;
import
com.platform.business.util.ClassSubjectTimeUtils
;
import
com.platform.exception.BusinessException
;
import
org.apache.poi.ss.usermodel.Cell
;
import
org.apache.poi.ss.usermodel.CellStyle
;
import
org.apache.poi.ss.usermodel.FillPatternType
;
import
org.apache.poi.ss.usermodel.Font
;
import
org.apache.poi.ss.usermodel.IndexedColors
;
import
org.apache.poi.ss.usermodel.Row
;
import
org.apache.poi.ss.usermodel.Sheet
;
import
org.apache.poi.ss.usermodel.Workbook
;
import
org.apache.poi.xssf.usermodel.XSSFWorkbook
;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.dao.DataIntegrityViolationException
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
javax.annotation.Resource
;
import
javax.servlet.http.HttpServletResponse
;
import
java.io.IOException
;
import
java.io.OutputStream
;
import
java.net.URLEncoder
;
import
java.text.SimpleDateFormat
;
import
java.time.LocalDate
;
import
java.time.LocalDateTime
;
import
java.time.LocalTime
;
import
java.time.ZoneId
;
import
java.time.format.DateTimeFormatter
;
import
java.time.format.DateTimeParseException
;
import
java.time.format.ResolverStyle
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.Collections
;
import
java.util.Comparator
;
import
java.util.Date
;
import
java.util.LinkedHashSet
;
import
java.util.List
;
import
java.util.Locale
;
import
java.util.Set
;
import
java.util.function.Function
;
import
java.util.stream.Collectors
;
/**
* 学员评议核心业务实现。
*
* <p>本实现把“任务状态”和“单个学员提交状态”分开维护:任务反映整个班级进度,记录反映
* 当前学员是否提交。任务发起、提交、撤回都在事务中完成,并通过任务行锁统一串行化,避免
* 最后一位学员提交与管理员撤回同时发生时出现矛盾状态。</p>
*/
@Service
public
class
EvaluationServiceImpl
implements
EvaluationService
{
private
static
final
int
MAX_BATCH_REVOKE_SIZE
=
100
;
private
static
final
int
MAX_COMMENT_LENGTH
=
1000
;
@Resource
private
EvaluationTaskMapper
taskMapper
;
@Resource
private
EvaluationRecordMapper
recordMapper
;
@Resource
private
ClassSubjectService
classSubjectService
;
@Resource
private
BusinessNotificationPublisher
notificationPublisher
;
@Override
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
EvaluationTaskVO
createTask
(
EvaluationTaskCreateDTO
request
,
String
adminId
,
String
adminName
)
{
if
(
request
==
null
||
request
.
getSubjectId
()
==
null
)
{
throw
new
BusinessException
(
"课程ID不能为空"
);
}
if
(
isBlank
(
adminId
))
{
throw
new
BusinessException
(
"未获取到任务发起人"
);
}
Date
now
=
new
Date
();
Date
deadline
=
parseDeadline
(
request
.
getDeadline
());
if
(!
deadline
.
after
(
now
))
{
throw
new
BusinessException
(
"评价截止时间必须晚于当前时间"
);
}
ClassSubjectEntity
subject
=
classSubjectService
.
getById
(
request
.
getSubjectId
());
if
(
subject
==
null
)
{
throw
new
BusinessException
(
"所选课程不存在"
);
}
// 截止时间至少应晚于课程结束时间;允许管理员提前创建任务,但学员仍需等课程结束后才能提交。
Date
courseEnd
=
ClassSubjectTimeUtils
.
resolve
(
subject
).
getEnd
();
if
(!
deadline
.
after
(
courseEnd
))
{
throw
new
BusinessException
(
"评价截止时间必须晚于课程结束时间"
);
}
if
(
taskMapper
.
selectCount
(
new
LambdaQueryWrapper
<
EvaluationTaskEntity
>()
.
eq
(
EvaluationTaskEntity:
:
getSubjectId
,
request
.
getSubjectId
()))
>
0
)
{
throw
new
BusinessException
(
"该课次已经发起过评价任务,不能重复发起"
);
}
// 在任务创建时固化目标学员。调班只影响后续新任务,不改变已经发出的历史评价范围。
List
<
String
>
studentIds
=
taskMapper
.
selectActiveStudentIdsByClassId
(
subject
.
getClassId
());
if
(
studentIds
==
null
||
studentIds
.
isEmpty
())
{
throw
new
BusinessException
(
"该班级暂无有效学员,不能发起评价任务"
);
}
EvaluationTaskEntity
task
=
new
EvaluationTaskEntity
();
task
.
setId
(
IdWorker
.
getIdStr
());
task
.
setSubjectId
(
subject
.
getId
());
task
.
setStatus
(
EvaluationConstants
.
TASK_PENDING
);
task
.
setDeadline
(
deadline
);
task
.
setCreatedBy
(
adminId
);
task
.
setCreatedTime
(
now
);
task
.
setUpdateTime
(
now
);
try
{
taskMapper
.
insert
(
task
);
}
catch
(
DataIntegrityViolationException
e
)
{
// subject_id唯一键负责拦截两个管理员同时发起同一课次的竞争请求。
throw
new
BusinessException
(
"该课次已经发起过评价任务,不能重复发起"
);
}
List
<
EvaluationRecordEntity
>
records
=
new
ArrayList
<>(
studentIds
.
size
());
for
(
String
studentId
:
studentIds
)
{
EvaluationRecordEntity
record
=
new
EvaluationRecordEntity
();
record
.
setId
(
IdWorker
.
getIdStr
());
record
.
setTaskId
(
task
.
getId
());
record
.
setStudentId
(
studentId
);
record
.
setStatus
(
EvaluationConstants
.
RECORD_PENDING
);
record
.
setCreatedTime
(
now
);
record
.
setUpdateTime
(
now
);
records
.
add
(
record
);
}
recordMapper
.
batchInsert
(
records
);
// 消息使用确定性的eventId。整个事务重试时不会在消息中心产生重复通知。
NotificationPublishDTO
message
=
new
NotificationPublishDTO
();
message
.
setEventId
(
"evaluation-task:"
+
task
.
getId
());
message
.
setMessageType
(
"COURSE"
);
message
.
setTitle
(
"新的课程评价任务"
);
message
.
setSummary
(
"请在截止时间前完成“"
+
subject
.
getSubjectName
()
+
"”课程评价"
);
message
.
setContent
(
"您有一项新的课程评价任务,请进入学员端“我的评价”完成提交。"
);
message
.
setBusinessType
(
"EVALUATION"
);
message
.
setBusinessId
(
task
.
getId
());
message
.
setActionUrl
(
"/student/evaluation"
);
message
.
setPriority
(
"IMPORTANT"
);
message
.
setRecipientUserIds
(
studentIds
);
message
.
setExpiresAt
(
deadline
);
notificationPublisher
.
publish
(
message
,
adminId
,
isBlank
(
adminName
)
?
"管理员"
:
adminName
);
return
requireTaskView
(
task
.
getId
());
}
@Override
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
List
<
EvaluationTaskVO
>
queryAdminTasks
(
EvaluationTaskQueryDTO
query
)
{
refreshExpiredTasks
();
EvaluationTaskQueryDTO
safeQuery
=
normalizeQuery
(
query
,
false
);
return
taskMapper
.
queryAdminTasks
(
safeQuery
);
}
@Override
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
EvaluationTaskDetailVO
adminDetail
(
String
taskId
,
String
studentName
)
{
refreshExpiredTasks
();
EvaluationTaskVO
task
=
requireTaskView
(
taskId
);
// 维度统计始终基于完整数据集;姓名搜索只缩小返回明细,不应改变页面顶部统计口径。
List
<
EvaluationRecordVO
>
allRecords
=
recordMapper
.
queryTaskRecords
(
taskId
,
null
);
List
<
EvaluationRecordVO
>
visibleRecords
=
isBlank
(
studentName
)
?
allRecords
:
recordMapper
.
queryTaskRecords
(
taskId
,
studentName
.
trim
());
EvaluationTaskDetailVO
detail
=
new
EvaluationTaskDetailVO
();
BeanUtils
.
copyProperties
(
task
,
detail
);
detail
.
setRecords
(
visibleRecords
);
detail
.
setDimensionStatistics
(
buildDimensionStatistics
(
allRecords
));
return
detail
;
}
@Override
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
boolean
revoke
(
String
taskId
,
String
adminId
)
{
refreshExpiredTasks
();
revokeLockedTask
(
requireText
(
taskId
,
"任务ID不能为空"
),
adminId
,
new
Date
());
return
true
;
}
@Override
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
int
batchRevoke
(
List
<
String
>
taskIds
,
String
adminId
)
{
if
(
taskIds
==
null
||
taskIds
.
isEmpty
())
{
throw
new
BusinessException
(
"请至少选择一个待撤回任务"
);
}
Set
<
String
>
normalizedIds
=
taskIds
.
stream
()
.
filter
(
id
->
!
isBlank
(
id
)).
map
(
String:
:
trim
)
.
collect
(
Collectors
.
toCollection
(
LinkedHashSet:
:
new
));
if
(
normalizedIds
.
isEmpty
())
{
throw
new
BusinessException
(
"任务ID不能为空"
);
}
if
(
normalizedIds
.
size
()
>
MAX_BATCH_REVOKE_SIZE
)
{
throw
new
BusinessException
(
"单次最多撤回"
+
MAX_BATCH_REVOKE_SIZE
+
"个任务"
);
}
refreshExpiredTasks
();
Date
now
=
new
Date
();
// 固定加锁顺序,避免两个批量请求以相反顺序锁定任务时发生数据库死锁。
List
<
String
>
sortedIds
=
new
ArrayList
<>(
normalizedIds
);
sortedIds
.
sort
(
Comparator
.
naturalOrder
());
for
(
String
taskId
:
sortedIds
)
{
revokeLockedTask
(
taskId
,
adminId
,
now
);
}
return
sortedIds
.
size
();
}
@Override
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
List
<
StudentEvaluationTaskVO
>
queryStudentTasks
(
EvaluationTaskQueryDTO
query
,
String
studentId
)
{
refreshExpiredTasks
();
EvaluationTaskQueryDTO
safeQuery
=
normalizeQuery
(
query
,
true
);
return
taskMapper
.
queryStudentTasks
(
safeQuery
,
requireText
(
studentId
,
"未获取到当前学员"
));
}
@Override
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
StudentEvaluationTaskVO
studentDetail
(
String
taskId
,
String
studentId
)
{
refreshExpiredTasks
();
StudentEvaluationTaskVO
detail
=
taskMapper
.
selectStudentTask
(
requireText
(
taskId
,
"任务ID不能为空"
),
requireText
(
studentId
,
"未获取到当前学员"
));
if
(
detail
==
null
)
{
// 撤回任务也返回无权访问,避免向学员泄露已经撤回的任务内容。
throw
new
BusinessException
(
"评价任务不存在或未分配给当前学员"
);
}
return
detail
;
}
@Override
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
StudentEvaluationTaskVO
submit
(
String
taskId
,
EvaluationSubmitDTO
request
,
String
studentId
)
{
validateSubmission
(
request
);
String
normalizedTaskId
=
requireText
(
taskId
,
"任务ID不能为空"
);
String
normalizedStudentId
=
requireText
(
studentId
,
"未获取到当前学员"
);
Date
now
=
new
Date
();
// 所有提交和撤回先锁任务,再锁个人记录;全模块遵守同一锁顺序以降低死锁风险。
EvaluationTaskEntity
task
=
taskMapper
.
selectByIdForUpdate
(
normalizedTaskId
);
if
(
task
==
null
)
{
throw
new
BusinessException
(
"评价任务不存在"
);
}
if
(
task
.
getDeadline
()
==
null
||
!
task
.
getDeadline
().
after
(
now
))
{
if
(
EvaluationConstants
.
TASK_PENDING
.
equals
(
task
.
getStatus
()))
{
// 当前已持有该任务行锁,只更新当前任务,避免全表过期更新扩大锁范围。
taskMapper
.
expirePendingTask
(
normalizedTaskId
,
now
);
}
throw
new
BusinessException
(
"评价任务已过截止时间"
);
}
if
(!
EvaluationConstants
.
TASK_PENDING
.
equals
(
task
.
getStatus
()))
{
throw
new
BusinessException
(
taskStatusMessage
(
task
.
getStatus
()));
}
ClassSubjectEntity
subject
=
classSubjectService
.
getById
(
task
.
getSubjectId
());
if
(
subject
==
null
)
{
throw
new
BusinessException
(
"评价任务关联课程不存在"
);
}
if
(
ClassSubjectTimeUtils
.
resolve
(
subject
).
getEnd
().
after
(
now
))
{
throw
new
BusinessException
(
"课程尚未结束,暂不能提交评价"
);
}
EvaluationRecordEntity
record
=
recordMapper
.
selectByTaskAndStudentForUpdate
(
normalizedTaskId
,
normalizedStudentId
);
if
(
record
==
null
)
{
throw
new
BusinessException
(
"该评价任务未分配给当前学员"
);
}
if
(
EvaluationConstants
.
RECORD_SUBMITTED
.
equals
(
record
.
getStatus
()))
{
throw
new
BusinessException
(
"评价已提交,不能重复提交或修改"
);
}
copySubmission
(
request
,
record
);
if
(
recordMapper
.
submitPending
(
record
,
now
)
==
0
)
{
throw
new
BusinessException
(
"评价已提交,请勿重复操作"
);
}
// 如果当前是最后一位待评价学员,则在同一事务内关闭整个任务。
taskMapper
.
completeIfAllSubmitted
(
normalizedTaskId
,
now
);
return
studentDetailWithoutStatusRefresh
(
normalizedTaskId
,
normalizedStudentId
);
}
@Override
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
void
exportAdminTasks
(
EvaluationTaskQueryDTO
query
,
HttpServletResponse
response
)
{
refreshExpiredTasks
();
List
<
EvaluationTaskVO
>
tasks
=
taskMapper
.
queryAdminTasks
(
normalizeQuery
(
query
,
false
));
try
(
Workbook
workbook
=
new
XSSFWorkbook
())
{
Sheet
sheet
=
workbook
.
createSheet
(
"评议任务汇总"
);
String
[]
headers
=
{
"任务ID"
,
"课程"
,
"班级"
,
"课次"
,
"授课教师"
,
"上课时间"
,
"课程类型"
,
"评价截止"
,
"总人数"
,
"待评人数"
,
"已评人数"
,
"完成率"
,
"状态"
};
writeHeader
(
sheet
,
headers
,
createHeaderStyle
(
workbook
));
int
rowIndex
=
1
;
for
(
EvaluationTaskVO
task
:
tasks
)
{
Row
row
=
sheet
.
createRow
(
rowIndex
++);
writeCells
(
row
,
Arrays
.
asList
(
task
.
getId
(),
task
.
getCourseName
(),
task
.
getClassName
(),
value
(
task
.
getSubjectTimes
()),
task
.
getTeacherName
(),
formatDate
(
task
.
getCourseDate
()),
task
.
getType
(),
formatDate
(
task
.
getDeadline
()),
value
(
task
.
getTotalCount
()),
value
(
task
.
getPendingCount
()),
value
(
task
.
getSubmittedCount
()),
value
(
task
.
getCompletionRate
())
+
"%"
,
taskStatusLabel
(
task
.
getStatus
())));
}
autoSize
(
sheet
,
headers
.
length
);
writeWorkbook
(
response
,
workbook
,
"学员评议任务汇总.xlsx"
);
}
catch
(
IOException
e
)
{
throw
new
BusinessException
(
"导出评议任务失败"
);
}
}
@Override
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
void
exportTaskDetail
(
String
taskId
,
HttpServletResponse
response
)
{
refreshExpiredTasks
();
EvaluationTaskDetailVO
detail
=
adminDetail
(
taskId
,
null
);
try
(
Workbook
workbook
=
new
XSSFWorkbook
())
{
writeDetailSheet
(
workbook
,
detail
);
writeStatisticsSheet
(
workbook
,
detail
.
getDimensionStatistics
());
String
courseName
=
isBlank
(
detail
.
getCourseName
())
?
"课程"
:
detail
.
getCourseName
();
writeWorkbook
(
response
,
workbook
,
courseName
+
"-学员评议明细.xlsx"
);
}
catch
(
IOException
e
)
{
throw
new
BusinessException
(
"导出评议明细失败"
);
}
}
/** 到达截止时间后采用惰性推进;列表、详情、提交和撤回入口均会先调用。 */
private
void
refreshExpiredTasks
()
{
taskMapper
.
expireDueTasks
(
new
Date
());
}
/** 锁定并撤回单个任务,供单条和批量操作复用。 */
private
void
revokeLockedTask
(
String
taskId
,
String
adminId
,
Date
now
)
{
requireText
(
adminId
,
"未获取到当前管理员"
);
EvaluationTaskEntity
task
=
taskMapper
.
selectByIdForUpdate
(
taskId
);
if
(
task
==
null
)
{
throw
new
BusinessException
(
"评价任务不存在:"
+
taskId
);
}
if
(!
EvaluationConstants
.
TASK_PENDING
.
equals
(
task
.
getStatus
()))
{
throw
new
BusinessException
(
"只有待评价任务可以撤回:"
+
taskId
);
}
if
(
taskMapper
.
revokePending
(
taskId
,
adminId
,
now
)
==
0
)
{
throw
new
BusinessException
(
"任务状态已变化,无法撤回:"
+
taskId
);
}
}
/** 管理端和学员端共同使用的筛选校验及状态标准化。 */
private
EvaluationTaskQueryDTO
normalizeQuery
(
EvaluationTaskQueryDTO
query
,
boolean
studentSide
)
{
EvaluationTaskQueryDTO
safe
=
query
==
null
?
new
EvaluationTaskQueryDTO
()
:
query
;
if
(
safe
.
getStartDate
()
!=
null
&&
safe
.
getEndDate
()
!=
null
&&
safe
.
getStartDate
().
after
(
safe
.
getEndDate
()))
{
throw
new
BusinessException
(
"上课开始时间不能晚于结束时间"
);
}
if
(!
isBlank
(
safe
.
getStatus
()))
{
String
status
=
safe
.
getStatus
().
trim
().
toUpperCase
(
Locale
.
ROOT
);
if
(!
EvaluationConstants
.
ALLOWED_TASK_STATUSES
.
contains
(
status
)
||
(
studentSide
&&
EvaluationConstants
.
TASK_REVOKED
.
equals
(
status
)))
{
throw
new
BusinessException
(
"评价状态不正确"
);
}
safe
.
setStatus
(
status
);
}
return
safe
;
}
/** 七个维度均为必填,并统一转换为数据库使用的大写枚举值。 */
private
void
validateSubmission
(
EvaluationSubmitDTO
request
)
{
if
(
request
==
null
)
{
throw
new
BusinessException
(
"评价内容不能为空"
);
}
request
.
setTeachingAttitude
(
normalizeScore
(
request
.
getTeachingAttitude
(),
"教学态度"
));
request
.
setTeachingContent
(
normalizeScore
(
request
.
getTeachingContent
(),
"教学内容"
));
request
.
setTeachingMethod
(
normalizeScore
(
request
.
getTeachingMethod
(),
"教学方法"
));
request
.
setTeachingMeans
(
normalizeScore
(
request
.
getTeachingMeans
(),
"教学手段"
));
request
.
setDemonstration
(
normalizeScore
(
request
.
getDemonstration
(),
"讲解示范"
));
request
.
setGuidance
(
normalizeScore
(
request
.
getGuidance
(),
"巡回指导"
));
request
.
setClassHourCompletion
(
normalizeScore
(
request
.
getClassHourCompletion
(),
"课时完成情况"
));
if
(
request
.
getComment
()
!=
null
&&
request
.
getComment
().
trim
().
length
()
>
MAX_COMMENT_LENGTH
)
{
throw
new
BusinessException
(
"意见与建议不能超过"
+
MAX_COMMENT_LENGTH
+
"个字符"
);
}
}
private
String
normalizeScore
(
String
score
,
String
dimensionName
)
{
if
(
isBlank
(
score
))
{
throw
new
BusinessException
(
"请完成评分项:"
+
dimensionName
);
}
String
normalized
=
score
.
trim
().
toUpperCase
(
Locale
.
ROOT
);
if
(!
EvaluationConstants
.
ALLOWED_SCORES
.
contains
(
normalized
))
{
throw
new
BusinessException
(
dimensionName
+
"只能选择GOOD、FAIR、OK或POOR"
);
}
return
normalized
;
}
private
void
copySubmission
(
EvaluationSubmitDTO
source
,
EvaluationRecordEntity
target
)
{
target
.
setTeachingAttitude
(
source
.
getTeachingAttitude
());
target
.
setTeachingContent
(
source
.
getTeachingContent
());
target
.
setTeachingMethod
(
source
.
getTeachingMethod
());
target
.
setTeachingMeans
(
source
.
getTeachingMeans
());
target
.
setDemonstration
(
source
.
getDemonstration
());
target
.
setGuidance
(
source
.
getGuidance
());
target
.
setClassHourCompletion
(
source
.
getClassHourCompletion
());
target
.
setComment
(
isBlank
(
source
.
getComment
())
?
null
:
source
.
getComment
().
trim
());
}
private
EvaluationTaskVO
requireTaskView
(
String
taskId
)
{
EvaluationTaskVO
task
=
taskMapper
.
selectTaskView
(
requireText
(
taskId
,
"任务ID不能为空"
));
if
(
task
==
null
)
{
throw
new
BusinessException
(
"评价任务不存在"
);
}
return
task
;
}
private
StudentEvaluationTaskVO
studentDetailWithoutStatusRefresh
(
String
taskId
,
String
studentId
)
{
StudentEvaluationTaskVO
detail
=
taskMapper
.
selectStudentTask
(
taskId
,
studentId
);
if
(
detail
==
null
)
{
throw
new
BusinessException
(
"评价任务不存在或未分配给当前学员"
);
}
return
detail
;
}
/** 根据实名明细计算原型七个维度的四档分布和四分制平均值。 */
private
List
<
EvaluationDimensionStatisticsVO
>
buildDimensionStatistics
(
List
<
EvaluationRecordVO
>
records
)
{
List
<
EvaluationRecordVO
>
submitted
=
records
==
null
?
Collections
.
emptyList
()
:
records
.
stream
()
.
filter
(
record
->
EvaluationConstants
.
RECORD_SUBMITTED
.
equals
(
record
.
getStatus
()))
.
collect
(
Collectors
.
toList
());
List
<
EvaluationDimensionStatisticsVO
>
result
=
new
ArrayList
<>();
result
.
add
(
statistics
(
"teachingAttitude"
,
"教学态度"
,
submitted
,
EvaluationRecordVO:
:
getTeachingAttitude
));
result
.
add
(
statistics
(
"teachingContent"
,
"教学内容"
,
submitted
,
EvaluationRecordVO:
:
getTeachingContent
));
result
.
add
(
statistics
(
"teachingMethod"
,
"教学方法"
,
submitted
,
EvaluationRecordVO:
:
getTeachingMethod
));
result
.
add
(
statistics
(
"teachingMeans"
,
"教学手段"
,
submitted
,
EvaluationRecordVO:
:
getTeachingMeans
));
result
.
add
(
statistics
(
"demonstration"
,
"讲解示范"
,
submitted
,
EvaluationRecordVO:
:
getDemonstration
));
result
.
add
(
statistics
(
"guidance"
,
"巡回指导"
,
submitted
,
EvaluationRecordVO:
:
getGuidance
));
result
.
add
(
statistics
(
"classHourCompletion"
,
"课时完成情况"
,
submitted
,
EvaluationRecordVO:
:
getClassHourCompletion
));
return
result
;
}
private
EvaluationDimensionStatisticsVO
statistics
(
String
key
,
String
name
,
List
<
EvaluationRecordVO
>
records
,
Function
<
EvaluationRecordVO
,
String
>
getter
)
{
int
good
=
0
;
int
fair
=
0
;
int
ok
=
0
;
int
poor
=
0
;
for
(
EvaluationRecordVO
record
:
records
)
{
String
score
=
getter
.
apply
(
record
);
if
(
EvaluationConstants
.
SCORE_GOOD
.
equals
(
score
))
{
good
++;
}
else
if
(
EvaluationConstants
.
SCORE_FAIR
.
equals
(
score
))
{
fair
++;
}
else
if
(
EvaluationConstants
.
SCORE_OK
.
equals
(
score
))
{
ok
++;
}
else
if
(
EvaluationConstants
.
SCORE_POOR
.
equals
(
score
))
{
poor
++;
}
}
EvaluationDimensionStatisticsVO
item
=
new
EvaluationDimensionStatisticsVO
();
item
.
setDimensionKey
(
key
);
item
.
setDimensionName
(
name
);
item
.
setGoodCount
(
good
);
item
.
setFairCount
(
fair
);
item
.
setOkCount
(
ok
);
item
.
setPoorCount
(
poor
);
int
total
=
good
+
fair
+
ok
+
poor
;
item
.
setSubmittedCount
(
total
);
item
.
setAverageScore
(
total
==
0
?
0
D
:
round2
((
good
*
4
D
+
fair
*
3
D
+
ok
*
2
D
+
poor
)
/
total
));
return
item
;
}
private
void
writeDetailSheet
(
Workbook
workbook
,
EvaluationTaskDetailVO
detail
)
{
Sheet
sheet
=
workbook
.
createSheet
(
"评价明细"
);
String
[]
headers
=
{
"学员姓名"
,
"手机号"
,
"教学态度"
,
"教学内容"
,
"教学方法"
,
"教学手段"
,
"讲解示范"
,
"巡回指导"
,
"课时完成情况"
,
"意见与建议"
,
"提交时间"
,
"状态"
};
writeHeader
(
sheet
,
headers
,
createHeaderStyle
(
workbook
));
int
rowIndex
=
1
;
for
(
EvaluationRecordVO
record
:
detail
.
getRecords
())
{
Row
row
=
sheet
.
createRow
(
rowIndex
++);
writeCells
(
row
,
Arrays
.
asList
(
record
.
getStudentName
(),
record
.
getPhoneNumber
(),
scoreLabel
(
record
.
getTeachingAttitude
()),
scoreLabel
(
record
.
getTeachingContent
()),
scoreLabel
(
record
.
getTeachingMethod
()),
scoreLabel
(
record
.
getTeachingMeans
()),
scoreLabel
(
record
.
getDemonstration
()),
scoreLabel
(
record
.
getGuidance
()),
scoreLabel
(
record
.
getClassHourCompletion
()),
record
.
getComment
(),
formatDate
(
record
.
getSubmittedAt
()),
EvaluationConstants
.
RECORD_SUBMITTED
.
equals
(
record
.
getStatus
())
?
"已评价"
:
"待评价"
));
}
autoSize
(
sheet
,
headers
.
length
);
sheet
.
setColumnWidth
(
9
,
45
*
256
);
}
private
void
writeStatisticsSheet
(
Workbook
workbook
,
List
<
EvaluationDimensionStatisticsVO
>
statistics
)
{
Sheet
sheet
=
workbook
.
createSheet
(
"维度统计"
);
String
[]
headers
=
{
"评分维度"
,
"好"
,
"较好"
,
"尚可"
,
"差"
,
"已评人数"
,
"四分制平均分"
};
writeHeader
(
sheet
,
headers
,
createHeaderStyle
(
workbook
));
int
rowIndex
=
1
;
for
(
EvaluationDimensionStatisticsVO
item
:
statistics
)
{
Row
row
=
sheet
.
createRow
(
rowIndex
++);
writeCells
(
row
,
Arrays
.
asList
(
item
.
getDimensionName
(),
value
(
item
.
getGoodCount
()),
value
(
item
.
getFairCount
()),
value
(
item
.
getOkCount
()),
value
(
item
.
getPoorCount
()),
value
(
item
.
getSubmittedCount
()),
value
(
item
.
getAverageScore
())));
}
autoSize
(
sheet
,
headers
.
length
);
}
private
CellStyle
createHeaderStyle
(
Workbook
workbook
)
{
CellStyle
style
=
workbook
.
createCellStyle
();
style
.
setFillForegroundColor
(
IndexedColors
.
LIGHT_CORNFLOWER_BLUE
.
getIndex
());
style
.
setFillPattern
(
FillPatternType
.
SOLID_FOREGROUND
);
Font
font
=
workbook
.
createFont
();
font
.
setBold
(
true
);
style
.
setFont
(
font
);
return
style
;
}
private
void
writeHeader
(
Sheet
sheet
,
String
[]
headers
,
CellStyle
style
)
{
Row
row
=
sheet
.
createRow
(
0
);
for
(
int
i
=
0
;
i
<
headers
.
length
;
i
++)
{
Cell
cell
=
row
.
createCell
(
i
);
cell
.
setCellValue
(
headers
[
i
]);
cell
.
setCellStyle
(
style
);
}
sheet
.
createFreezePane
(
0
,
1
);
}
private
void
writeCells
(
Row
row
,
List
<
String
>
values
)
{
for
(
int
i
=
0
;
i
<
values
.
size
();
i
++)
{
row
.
createCell
(
i
).
setCellValue
(
values
.
get
(
i
)
==
null
?
""
:
values
.
get
(
i
));
}
}
private
void
autoSize
(
Sheet
sheet
,
int
columnCount
)
{
for
(
int
i
=
0
;
i
<
columnCount
;
i
++)
{
sheet
.
autoSizeColumn
(
i
);
int
width
=
Math
.
min
(
sheet
.
getColumnWidth
(
i
)
+
512
,
50
*
256
);
sheet
.
setColumnWidth
(
i
,
width
);
}
}
private
void
writeWorkbook
(
HttpServletResponse
response
,
Workbook
workbook
,
String
filename
)
throws
IOException
{
String
encoded
=
URLEncoder
.
encode
(
filename
,
"UTF-8"
).
replace
(
"+"
,
"%20"
);
response
.
setCharacterEncoding
(
"UTF-8"
);
response
.
setContentType
(
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
);
response
.
setHeader
(
"Content-Disposition"
,
"attachment; filename*=UTF-8''"
+
encoded
);
try
(
OutputStream
output
=
response
.
getOutputStream
())
{
workbook
.
write
(
output
);
output
.
flush
();
}
}
private
String
taskStatusMessage
(
String
status
)
{
if
(
EvaluationConstants
.
TASK_COMPLETED
.
equals
(
status
))
{
return
"评价任务已完成"
;
}
if
(
EvaluationConstants
.
TASK_EXPIRED
.
equals
(
status
))
{
return
"评价任务已过期"
;
}
if
(
EvaluationConstants
.
TASK_REVOKED
.
equals
(
status
))
{
return
"评价任务已撤回"
;
}
return
"评价任务当前不可提交"
;
}
private
String
taskStatusLabel
(
String
status
)
{
if
(
EvaluationConstants
.
TASK_PENDING
.
equals
(
status
))
return
"待评价"
;
if
(
EvaluationConstants
.
TASK_COMPLETED
.
equals
(
status
))
return
"已完成"
;
if
(
EvaluationConstants
.
TASK_EXPIRED
.
equals
(
status
))
return
"已过期"
;
if
(
EvaluationConstants
.
TASK_REVOKED
.
equals
(
status
))
return
"已撤回"
;
return
value
(
status
);
}
private
String
scoreLabel
(
String
score
)
{
if
(
EvaluationConstants
.
SCORE_GOOD
.
equals
(
score
))
return
"好"
;
if
(
EvaluationConstants
.
SCORE_FAIR
.
equals
(
score
))
return
"较好"
;
if
(
EvaluationConstants
.
SCORE_OK
.
equals
(
score
))
return
"尚可"
;
if
(
EvaluationConstants
.
SCORE_POOR
.
equals
(
score
))
return
"差"
;
return
""
;
}
private
String
formatDate
(
Date
date
)
{
return
date
==
null
?
""
:
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm:ss"
).
format
(
date
);
}
/**
* 兼容原型日期控件输出的yyyy-MM-dd和需要精确控制时刻的yyyy-MM-dd HH:mm:ss。
* 只传日期时按该日23:59:59处理,避免把用户选择的截止日错误解释为当天零点即过期。
*/
private
Date
parseDeadline
(
String
value
)
{
if
(
isBlank
(
value
))
{
throw
new
BusinessException
(
"评价截止时间不能为空"
);
}
String
normalized
=
value
.
trim
();
try
{
LocalDateTime
dateTime
;
if
(
normalized
.
length
()
==
10
)
{
dateTime
=
LocalDate
.
parse
(
normalized
,
DateTimeFormatter
.
ofPattern
(
"uuuu-MM-dd"
)
.
withResolverStyle
(
ResolverStyle
.
STRICT
))
.
atTime
(
LocalTime
.
of
(
23
,
59
,
59
));
}
else
{
dateTime
=
LocalDateTime
.
parse
(
normalized
,
DateTimeFormatter
.
ofPattern
(
"uuuu-MM-dd HH:mm:ss"
)
.
withResolverStyle
(
ResolverStyle
.
STRICT
));
}
return
Date
.
from
(
dateTime
.
atZone
(
ZoneId
.
systemDefault
()).
toInstant
());
}
catch
(
DateTimeParseException
e
)
{
throw
new
BusinessException
(
"评价截止时间格式应为yyyy-MM-dd或yyyy-MM-dd HH:mm:ss"
);
}
}
private
String
value
(
Object
value
)
{
return
value
==
null
?
""
:
String
.
valueOf
(
value
);
}
private
double
round2
(
double
value
)
{
return
Math
.
round
(
value
*
100
D
)
/
100
D
;
}
private
String
requireText
(
String
value
,
String
message
)
{
if
(
isBlank
(
value
))
{
throw
new
BusinessException
(
message
);
}
return
value
.
trim
();
}
private
boolean
isBlank
(
String
value
)
{
return
value
==
null
||
value
.
trim
().
isEmpty
();
}
}
practical-business/src/main/resources/com/platform/business/mapper/EvaluationRecordMapper.xml
0 → 100644
View file @
7ada3155
<?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.EvaluationRecordMapper"
>
<insert
id=
"batchInsert"
>
insert into evaluation_record (
id, task_id, student_id, status, created_time, update_time
) values
<foreach
collection=
"records"
item=
"record"
separator=
","
>
(#{record.id}, #{record.taskId}, #{record.studentId}, #{record.status},
#{record.createdTime}, #{record.updateTime})
</foreach>
</insert>
<select
id=
"selectByTaskAndStudentForUpdate"
resultType=
"com.platform.business.model.entity.EvaluationRecordEntity"
>
select id, task_id, student_id, status,
teaching_attitude, teaching_content, teaching_method, teaching_means,
demonstration, guidance, class_hour_completion, comment,
submitted_at, created_time, update_time
from evaluation_record
where task_id = #{taskId} and student_id = #{studentId}
for update
</select>
<update
id=
"submitPending"
>
update evaluation_record
set status = 'SUBMITTED',
teaching_attitude = #{record.teachingAttitude},
teaching_content = #{record.teachingContent},
teaching_method = #{record.teachingMethod},
teaching_means = #{record.teachingMeans},
demonstration = #{record.demonstration},
guidance = #{record.guidance},
class_hour_completion = #{record.classHourCompletion},
comment = #{record.comment},
submitted_at = #{now},
update_time = #{now}
where id = #{record.id} and status = 'PENDING'
</update>
<select
id=
"queryTaskRecords"
resultType=
"com.platform.business.model.vo.EvaluationRecordVO"
>
select r.id,
r.task_id as taskId,
r.student_id as studentId,
u.nick_name as studentName,
u.phone_number as phoneNumber,
r.status,
r.teaching_attitude as teachingAttitude,
r.teaching_content as teachingContent,
r.teaching_method as teachingMethod,
r.teaching_means as teachingMeans,
r.demonstration,
r.guidance,
r.class_hour_completion as classHourCompletion,
r.comment,
r.submitted_at as submittedAt
from evaluation_record r
inner join user u on u.id = r.student_id
where r.task_id = #{taskId}
<if
test=
"studentName != null and studentName.trim() != ''"
>
and u.nick_name like concat('%', #{studentName}, '%')
</if>
order by case when r.status = 'SUBMITTED' then 0 else 1 end,
r.submitted_at desc, u.nick_name asc, r.id asc
</select>
</mapper>
practical-business/src/main/resources/com/platform/business/mapper/EvaluationTaskMapper.xml
0 → 100644
View file @
7ada3155
<?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.EvaluationTaskMapper"
>
<!-- 公共展示字段:任务自身、课程/班级/教师信息以及记录表实时统计。 -->
<sql
id=
"taskViewColumns"
>
t.id,
t.subject_id as subjectId,
cs.subject_name as courseName,
cs.class_id as classId,
c.name as className,
cs.subject_times as subjectTimes,
cs.teacher_id as teacherId,
teacher.nick_name as teacherName,
cs.date as courseDate,
cs.time_frame as timeFrame,
cs.type,
t.deadline,
t.status,
coalesce(stat.total_count, 0) as totalCount,
case when t.status = 'REVOKED' then 0
else coalesce(stat.pending_count, 0) end as pendingCount,
coalesce(stat.submitted_count, 0) as submittedCount,
case when coalesce(stat.total_count, 0) = 0 then 0
else round(stat.submitted_count * 100.0 / stat.total_count, 2) end as completionRate,
t.created_by as createdBy,
creator.nick_name as creatorName,
t.created_time as createdTime,
t.revoked_at as revokedAt,
t.revoked_by as revokedBy,
revoker.nick_name as revokerName
</sql>
<sql
id=
"taskViewJoins"
>
inner join class_subject cs on cs.id = t.subject_id
inner join class c on c.id = cs.class_id
left join user teacher on teacher.id = cs.teacher_id
left join user creator on creator.id = t.created_by
left join user revoker on revoker.id = t.revoked_by
left join (
select task_id,
count(*) as total_count,
sum(case when status = 'PENDING' then 1 else 0 end) as pending_count,
sum(case when status = 'SUBMITTED' then 1 else 0 end) as submitted_count
from evaluation_record
group by task_id
) stat on stat.task_id = t.id
</sql>
<select
id=
"queryAdminTasks"
resultType=
"com.platform.business.model.vo.EvaluationTaskVO"
>
select
<include
refid=
"taskViewColumns"
/>
from evaluation_task t
<include
refid=
"taskViewJoins"
/>
<where>
<if
test=
"courseName != null and courseName.trim() != ''"
>
and cs.subject_name like concat('%', #{courseName}, '%')
</if>
<if
test=
"classId != null"
>
and cs.class_id = #{classId}
</if>
<if
test=
"teacherId != null and teacherId.trim() != ''"
>
and cs.teacher_id = #{teacherId}
</if>
<if
test=
"startDate != null"
>
and cs.date
>
= #{startDate}
</if>
<if
test=
"endDate != null"
>
and cs.date
<
date_add(#{endDate}, interval 1 day)
</if>
<if
test=
"status != null and status.trim() != ''"
>
and t.status = #{status}
</if>
<if
test=
"type != null and type.trim() != ''"
>
and cs.type = #{type}
</if>
</where>
order by t.created_time desc, t.id desc
</select>
<select
id=
"queryStudentTasks"
resultType=
"com.platform.business.model.vo.StudentEvaluationTaskVO"
>
select t.id as taskId,
t.subject_id as subjectId,
cs.subject_name as courseName,
teacher.nick_name as teacherName,
c.name as className,
cs.subject_times as subjectTimes,
cs.date as courseDate,
cs.time_frame as timeFrame,
cs.type,
t.deadline,
t.status as taskStatus,
r.status as recordStatus,
r.teaching_attitude as teachingAttitude,
r.teaching_content as teachingContent,
r.teaching_method as teachingMethod,
r.teaching_means as teachingMeans,
r.demonstration,
r.guidance,
r.class_hour_completion as classHourCompletion,
r.comment,
r.submitted_at as submittedAt
from evaluation_record r
inner join evaluation_task t on t.id = r.task_id
inner join class_subject cs on cs.id = t.subject_id
inner join class c on c.id = cs.class_id
left join user teacher on teacher.id = cs.teacher_id
where r.student_id = #{studentId}
and t.status != 'REVOKED'
<if
test=
"query != null and query.status != null and query.status.trim() != ''"
>
<choose>
<!-- 学员端“已评价”取本人提交状态,不要求整个班级均已完成。 -->
<when
test=
"query.status == 'COMPLETED'"
>
and r.status = 'SUBMITTED'
</when>
<when
test=
"query.status == 'EXPIRED'"
>
and r.status = 'PENDING' and t.status = 'EXPIRED'
</when>
<otherwise>
and r.status = 'PENDING' and t.status = 'PENDING'
</otherwise>
</choose>
</if>
order by case when t.status = 'PENDING' and r.status = 'PENDING' then 0
when r.status = 'SUBMITTED' then 1 else 2 end,
t.deadline asc, t.created_time desc
</select>
<select
id=
"selectTaskView"
resultType=
"com.platform.business.model.vo.EvaluationTaskVO"
>
select
<include
refid=
"taskViewColumns"
/>
from evaluation_task t
<include
refid=
"taskViewJoins"
/>
where t.id = #{taskId}
</select>
<select
id=
"selectStudentTask"
resultType=
"com.platform.business.model.vo.StudentEvaluationTaskVO"
>
select t.id as taskId,
t.subject_id as subjectId,
cs.subject_name as courseName,
teacher.nick_name as teacherName,
c.name as className,
cs.subject_times as subjectTimes,
cs.date as courseDate,
cs.time_frame as timeFrame,
cs.type,
t.deadline,
t.status as taskStatus,
r.status as recordStatus,
r.teaching_attitude as teachingAttitude,
r.teaching_content as teachingContent,
r.teaching_method as teachingMethod,
r.teaching_means as teachingMeans,
r.demonstration,
r.guidance,
r.class_hour_completion as classHourCompletion,
r.comment,
r.submitted_at as submittedAt
from evaluation_record r
inner join evaluation_task t on t.id = r.task_id
inner join class_subject cs on cs.id = t.subject_id
inner join class c on c.id = cs.class_id
left join user teacher on teacher.id = cs.teacher_id
where r.task_id = #{taskId}
and r.student_id = #{studentId}
and t.status != 'REVOKED'
</select>
<select
id=
"selectByIdForUpdate"
resultType=
"com.platform.business.model.entity.EvaluationTaskEntity"
>
select id, subject_id, status, deadline, created_by, created_time, update_time, revoked_at, revoked_by
from evaluation_task
where id = #{taskId}
for update
</select>
<update
id=
"expireDueTasks"
>
update evaluation_task
set status = 'EXPIRED', update_time = #{now}
where status = 'PENDING' and deadline
<
= #{now}
</update>
<update
id=
"expirePendingTask"
>
update evaluation_task
set status = 'EXPIRED', update_time = #{now}
where id = #{taskId} and status = 'PENDING' and deadline
<
= #{now}
</update>
<update
id=
"revokePending"
>
update evaluation_task
set status = 'REVOKED', revoked_at = #{now}, revoked_by = #{operatorId}, update_time = #{now}
where id = #{taskId} and status = 'PENDING'
</update>
<update
id=
"completeIfAllSubmitted"
>
update evaluation_task t
set status = 'COMPLETED', update_time = #{now}
where t.id = #{taskId}
and t.status = 'PENDING'
and not exists (
select 1 from evaluation_record r
where r.task_id = t.id and r.status = 'PENDING'
)
</update>
<select
id=
"selectActiveStudentIdsByClassId"
resultType=
"java.lang.String"
>
select distinct cs.user_id
from class_student cs
inner join user u on u.id = cs.user_id
where cs.class_id = #{classId}
and (u.del_flag is null or u.del_flag = 0)
order by cs.user_id
</select>
</mapper>
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