1.增加按“时间”、“标题”、“企微状态”查询 2.增加数据统计在列表顶部 3.增加分页功能
This commit is contained in:
1 parent
0c471efb9f
commit
9d4092bc7f
14 files changed
+447
-108
No files matched your search
@@ -883,17 +883,17 @@ func (s *trainingService) rotateSignCode(ctx context.Context, tenantID uint64, c
|
||||
}
|
||||
|
||||
// Checkin performs the scan sign-in with rule-based anti-fraud checks:
|
||||
// token/expiry, same-day, roster membership, employee-no match, nonce replay,
|
||||
// token/expiry, same-day, employee-no match, nonce replay,
|
||||
// duplicate scan, late arrival, geo fence.
|
||||
// 一期为确定性规则引擎,不调 LLM;规则参数来自 sign_policy 配置。
|
||||
// 2026-11 企微扫码需求增强:
|
||||
// - 培训当天校验:非当天扫码签到直接友好提示(提前扫/过期补扫分文案);
|
||||
// - 工号严格校验(in.EmployeeNo 非空时):须与登录账号档案工号一致,且必须在
|
||||
// 该场次「参加人员」名单中 —— 名单外直接拒绝(不再仅标记待复核);
|
||||
// - 工号严格校验(in.EmployeeNo 非空时):须与登录账号档案工号一致;
|
||||
// - nonce 防重放 + client_ts 时钟偏差校验;
|
||||
// - 轮换宽限:token 未命中当前码时接受 prev_token 在宽限期内签到。
|
||||
// 既有登录态签到(不带 employee_no/nonce)行为不变:名单外仍标记 not_in_roster
|
||||
// 进待复核,不硬拒。
|
||||
// 2026-11-28 签到规则调整:签到不再限定发布培训计划时所选「参加人员」——
|
||||
// 员工档案(org_employees)全员均可凭工号签到;是否要求培训人员不再拦截/进
|
||||
// 异常待复核,由签到明细按名册实时标注(ListSignRecords 联查 in_roster)。
|
||||
func (s *trainingService) Checkin(ctx context.Context, tenantID uint64, userID string, in *types.CheckinInput) (*types.TrainingSignRecord, error) {
|
||||
if in == nil || in.Token == "" {
|
||||
return nil, errors.NewBadRequestError("签到码无效")
|
||||
@@ -922,23 +922,10 @@ func (s *trainingService) Checkin(ctx context.Context, tenantID uint64, userID s
|
||||
return nil, errors.NewForbiddenError("未建立培训档案,无法签到")
|
||||
}
|
||||
|
||||
// 名单校验(名单外人员自动标记;严格模式下直接拒绝,见下)。
|
||||
roster, err := s.repo.ListEnrollments(ctx, tenantID, session.ID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
inRoster := false
|
||||
for _, e := range roster {
|
||||
if e.MemberID == member.ID {
|
||||
inRoster = true
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
now := time.Now()
|
||||
|
||||
// 严格扫码链路(employee_no 非空,即 2026-11 新签到页):当天校验/工号+名单
|
||||
// 硬拒/nonce 防重放/时钟偏差仅作用于此链路。既有路径(登录态直签、代录补签)
|
||||
// 严格扫码链路(employee_no 非空,即 2026-11 新签到页):当天校验/工号一致
|
||||
// 校验/nonce 防重放/时钟偏差仅作用于此链路。既有路径(登录态直签、代录补签)
|
||||
// 行为不变 —— 尤其代录补签常发生在非当天,当天校验不得拦截。
|
||||
strictScan := strings.TrimSpace(in.EmployeeNo) != ""
|
||||
|
||||
@@ -953,15 +940,12 @@ func (s *trainingService) Checkin(ctx context.Context, tenantID uint64, userID s
|
||||
return nil, errors.NewBadRequestError("本课程签到已结束,无法补签")
|
||||
}
|
||||
|
||||
// 工号严格校验(2026-11 需求规则 2 + 补充规则):工号须与档案一致,且必须在
|
||||
// 「参加人员」名单中,名单外直接拒绝。
|
||||
// 工号严格校验(2026-11 需求规则 2):工号须与档案一致。2026-11-28 规则调整
|
||||
// 后不再要求在「参加人员」名单中,名单外人员照常签到,由明细标注区分。
|
||||
if strictScan {
|
||||
if !strings.EqualFold(strings.TrimSpace(member.EmployeeNo), strings.TrimSpace(in.EmployeeNo)) {
|
||||
return nil, errors.NewForbiddenError("录入工号与当前账号的档案工号不一致,请确认后重试")
|
||||
}
|
||||
if !inRoster {
|
||||
return nil, errors.NewForbiddenError("您不在该课程的「参加人员」名单中,请联系讲师或人事确认")
|
||||
}
|
||||
}
|
||||
|
||||
// nonce 防重放 + 时钟偏差(仅扫码链路携带;同 nonce 二次提交直接拒绝)。
|
||||
@@ -998,12 +982,6 @@ func (s *trainingService) Checkin(ctx context.Context, tenantID uint64, userID s
|
||||
}
|
||||
}
|
||||
|
||||
// 名单外人员标记(工号严格链路已在上方硬拒,此处仅既有登录态路径可达)。
|
||||
if !inRoster {
|
||||
flags = append(flags, "not_in_roster")
|
||||
status = types.TrainingSignAbnormal
|
||||
}
|
||||
|
||||
// 重复扫码直接拒绝(唯一约束兜底)。
|
||||
if _, err := s.repo.GetSignRecord(ctx, tenantID, session.ID, member.ID); err == nil {
|
||||
return nil, errors.NewBadRequestError("您已签到,请勿重复扫码")
|
||||
@@ -1031,11 +1009,6 @@ func (s *trainingService) Checkin(ctx context.Context, tenantID uint64, userID s
|
||||
if err := s.repo.UpsertSignRecord(ctx, record); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
// 软性提示:名单外人员进入待复核队列。
|
||||
if !inRoster {
|
||||
_ = s.Notify(ctx, tenantID, userID, "signin_review",
|
||||
"签到待复核", "您的签到因名单校验未通过已进入待复核队列。", "session", session.ID)
|
||||
}
|
||||
return record, nil
|
||||
}
|
||||
|
||||
@@ -1114,14 +1087,19 @@ func (s *trainingService) ExportEvidence(ctx context.Context, tenantID uint64, s
|
||||
f := excelize.NewFile()
|
||||
sheet := "佐证包"
|
||||
f.SetSheetName("Sheet1", sheet)
|
||||
headers := []string{"部门", "工号", "姓名", "签到时间", "讲师姓名", "课程名称", "上课时间", "学员考试成绩"}
|
||||
// 2026-11-28 签到规则调整配套:全员可签到,佐证包标注要求/非要求培训人员。
|
||||
headers := []string{"部门", "工号", "姓名", "签到时间", "讲师姓名", "课程名称", "上课时间", "学员考试成绩", "人员类型"}
|
||||
for i, h := range headers {
|
||||
cell, _ := excelize.CoordinatesToCellName(i+1, 1)
|
||||
_ = f.SetCellValue(sheet, cell, h)
|
||||
}
|
||||
for r, row := range rows {
|
||||
rosterLabel := "非要求培训人员"
|
||||
if row.InRoster {
|
||||
rosterLabel = "要求培训人员"
|
||||
}
|
||||
values := []string{row.DeptName, row.EmployeeNo, row.MemberName, row.SignedAt,
|
||||
row.LecturerName, row.CourseName, row.SessionTime, row.ExamScore}
|
||||
row.LecturerName, row.CourseName, row.SessionTime, row.ExamScore, rosterLabel}
|
||||
for i, v := range values {
|
||||
cell, _ := excelize.CoordinatesToCellName(i+1, r+2)
|
||||
_ = f.SetCellValue(sheet, cell, v)
|
||||
|
||||
Reference in new issue
Block a user