fix(bug):1.帮我检查一下平台中有多少处显示部门地方这种“e10-、、、、”字样拿掉不要显示
deploy-hxtesting / build-and-deploy (push) Successful in 1m28s
deploy-hxtesting / build-and-deploy (push) Successful in 1m28s
2.月培训计划发布时授课时间默认空着点击【发布】时提示先维护授课时间,(不要默认年培训计划) 3.授课地点默认“年度计划”所设置的授课地点,如果年培训计划没有维护发布时也要必填 4.点击【发布】时要校验参加人员不能为空!默认为所属部门下的人员~ 认真阅读相关代码~
This commit is contained in:
1 parent
6cdcc4f221
commit
858c352991
16 files changed
+421
-89
No files matched your search
@@ -13,6 +13,7 @@ import (
|
||||
"academy/internal/logger"
|
||||
"academy/internal/types"
|
||||
"academy/internal/types/interfaces"
|
||||
"academy/internal/utils"
|
||||
"github.com/xuri/excelize/v2"
|
||||
)
|
||||
|
||||
@@ -474,15 +475,17 @@ func (s *trainingService) PublishCourse(ctx context.Context, tenantID uint64, id
|
||||
return nil, errors.NewBadRequestError("线上课程发布前需先登记课件资料(上传课件/从课件库选择/仅登记名称)")
|
||||
}
|
||||
}
|
||||
// 参加人员:适用人员非空或场次学员名单有人(跨场次)任一满足即可。
|
||||
if strings.TrimSpace(course.PostScope) == "" {
|
||||
enrolled, enrolledErr := s.repo.CountEnrolledMembersByCourseID(ctx, tenantID, course.ID)
|
||||
if enrolledErr != nil {
|
||||
return nil, enrolledErr
|
||||
}
|
||||
if enrolled == 0 {
|
||||
return nil, errors.NewBadRequestError("发布前需先设置参加人员")
|
||||
}
|
||||
// 参加人员(2026-11 需求收紧:发布时校验参加人员不能为空):场次学员名单
|
||||
// 有人(跨场次)即已设置;否则 post_scope 姓名须至少一人匹配到员工名册 ——
|
||||
// 需求确认同步的 post_scope 是「适合人员」部门名串(匹配不到任何员工),
|
||||
// 不能视为已设置,防止名单为空的计划带空应培名单发布。
|
||||
enrolled, enrolledErr := s.repo.CountEnrolledMembersByCourseID(ctx, tenantID, course.ID)
|
||||
if enrolledErr != nil {
|
||||
return nil, enrolledErr
|
||||
}
|
||||
if enrolled == 0 && !s.postScopeHasMember(ctx, tenantID, course.PostScope) {
|
||||
return nil, errors.NewBadRequestError("发布前需先设置参加人员").
|
||||
WithDetails("参加人员不能为空;可在月培训计划「调整」中确认(默认为所属部门下的人员)后保存再发布")
|
||||
}
|
||||
if course.Mode != types.TrainingCourseModeOnline {
|
||||
// 授课时间/地点与列表展示同口径(场次排期优先,2026-11-26 复测修复):
|
||||
@@ -530,6 +533,46 @@ func (s *trainingService) PublishCourse(ctx context.Context, tenantID uint64, id
|
||||
return course, nil
|
||||
}
|
||||
|
||||
// postScopeHasMember post_scope 姓名串(、/,/,/;/;/空格分隔)至少一人匹配到员工
|
||||
// 名册(姓名或工号)即认为已设置参加人员(2026-11 需求:需求确认同步的 post_scope
|
||||
// 是「适合人员」部门名串,匹配不到任何员工,不算已设置)。名册查询失败时返回
|
||||
// false,交由上层按「未设置参加人员」统一拦截,不放行空名单。
|
||||
func (s *trainingService) postScopeHasMember(ctx context.Context, tenantID uint64, postScope string) bool {
|
||||
names := map[string]struct{}{}
|
||||
for _, part := range strings.FieldsFunc(postScope, func(r rune) bool {
|
||||
return r == '、' || r == ',' || r == ',' || r == ';' || r == ';' || r == ' ' || r == '\t'
|
||||
}) {
|
||||
if part = strings.TrimSpace(part); part != "" {
|
||||
names[part] = struct{}{}
|
||||
}
|
||||
}
|
||||
if len(names) == 0 {
|
||||
return false
|
||||
}
|
||||
if s.org == nil {
|
||||
return false
|
||||
}
|
||||
members, _, err := s.org.ListEmployees(ctx, tenantID, types.OrgModuleTraining, &types.OrgListQuery{Page: 1, PageSize: 2000})
|
||||
if err != nil {
|
||||
logger.Error(ctx, "Failed to list members for publish participant check", err)
|
||||
return false
|
||||
}
|
||||
for _, m := range members {
|
||||
if m == nil {
|
||||
continue
|
||||
}
|
||||
if _, ok := names[m.UserName]; ok {
|
||||
return true
|
||||
}
|
||||
if m.EmployeeNo != "" {
|
||||
if _, ok := names[m.EmployeeNo]; ok {
|
||||
return true
|
||||
}
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// ListSessions returns sessions.
|
||||
func (s *trainingService) ListSessions(ctx context.Context, tenantID uint64, q *interfaces.TrainingListQuery) ([]*types.TrainingCourseSession, error) {
|
||||
return s.repo.ListSessions(ctx, tenantID, q)
|
||||
@@ -1091,7 +1134,8 @@ func (s *trainingService) ExportEvidence(ctx context.Context, tenantID uint64, s
|
||||
if row.InRoster {
|
||||
rosterLabel = "要求培训人员"
|
||||
}
|
||||
values := []string{row.DeptName, row.EmployeeNo, row.MemberName, row.SignedAt,
|
||||
// 2026-11 需求:部门列剥离企微同步残留的「e10-<ID>」字样
|
||||
values := []string{utils.CleanDeptName(row.DeptName), row.EmployeeNo, row.MemberName, row.SignedAt,
|
||||
row.LecturerName, row.CourseName, row.SessionTime, row.ExamScore, rosterLabel}
|
||||
for i, v := range values {
|
||||
cell, _ := excelize.CoordinatesToCellName(i+1, r+2)
|
||||
|
||||
@@ -19,6 +19,7 @@ import (
|
||||
"academy/internal/errors"
|
||||
"academy/internal/logger"
|
||||
"academy/internal/types"
|
||||
"academy/internal/utils"
|
||||
)
|
||||
|
||||
// 手动推送默认文案(前端弹窗预填同款,后端对空值兜底)。
|
||||
@@ -245,10 +246,14 @@ func (s *trainingService) deptNames(ctx context.Context, tenantID uint64, ids []
|
||||
}
|
||||
out := make([]string, 0, len(ids))
|
||||
for _, id := range ids {
|
||||
if name := byID[id]; name != "" {
|
||||
out = append(out, name)
|
||||
} else {
|
||||
out = append(out, id)
|
||||
name := byID[id]
|
||||
if name == "" {
|
||||
out = append(out, id) // 组织中心不可用或部门已删,回落 id 原文,不阻断列表
|
||||
continue
|
||||
}
|
||||
// 2026-11 需求:推送文案剥离企微同步残留的「e10-<ID>」部门名字样
|
||||
if cleaned := utils.CleanDeptName(name); cleaned != "" {
|
||||
out = append(out, cleaned)
|
||||
}
|
||||
}
|
||||
return out
|
||||
|
||||
@@ -847,10 +847,8 @@ func (h *Handler) syncDemandCourse(ctx context.Context, tenantID uint64, demand
|
||||
}
|
||||
}
|
||||
}
|
||||
// 授课时间默认取需求「期望月份」(YYYY-MM,课程管理侧可修改并留版本记录)。
|
||||
if demand.Year > 0 && demand.ExpectMonth >= 1 && demand.ExpectMonth <= 12 {
|
||||
course.TeachTime = fmt.Sprintf("%04d-%02d", demand.Year, demand.ExpectMonth)
|
||||
}
|
||||
// 2026-11 需求:授课时间不再默认取需求「期望月份」,同步草稿留空,
|
||||
// 由计划侧在「调整」中维护,发布时强制校验「发布前需先设置授课时间」。
|
||||
// 计划培训月份:需求侧为「YYYY-M」(如 2027-1),归一为课程口径 YYYY-MM;
|
||||
// 旧日期格式(YYYY-MM-DD 等)原样同步。
|
||||
course.PlannedTime = demandPlannedMonthOf(trimSpace(demand.PlannedTime))
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
package utils
|
||||
|
||||
import (
|
||||
"regexp"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// e10DeptTokenRe 匹配企微同步残留的「e10-<企微部门ID>」部门名片段:
|
||||
// Casdoor 上游未映射企微部门名时,部门以该形态落库 org_depts.name /
|
||||
// users.dept_name,展示层(Excel 导出、推送文案等)统一剥离(2026-11 需求)。
|
||||
var e10DeptTokenRe = regexp.MustCompile(`(?i)e10-\d+`)
|
||||
|
||||
// CleanDeptName 剥离部门名中残留的「e10-数字」字样并去首尾空白。
|
||||
func CleanDeptName(name string) string {
|
||||
return strings.TrimSpace(e10DeptTokenRe.ReplaceAllString(name, ""))
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package utils
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestCleanDeptName(t *testing.T) {
|
||||
cases := []struct {
|
||||
in string
|
||||
want string
|
||||
}{
|
||||
{"e10-1115765553620631553", ""},
|
||||
{"研发技术课", "研发技术课"},
|
||||
{"研发组 e10-1172161210096713736", "研发组"},
|
||||
{"E10-1172161210096713736", ""},
|
||||
{"", ""},
|
||||
}
|
||||
for _, c := range cases {
|
||||
if got := CleanDeptName(c.in); got != c.want {
|
||||
t.Errorf("CleanDeptName(%q) = %q, want %q", c.in, got, c.want)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user