feat(培训推送):“资讯组 新导入7条年度培训需求(课程:A(培训课程测试1、AI培训课程测试2、AI培训课程测试3、AI培训课程测试4、AI培训课程测试5、AI培训课程测试6、AI培训课程测试7)。请登录和信智汇学院 → 企业培训 一 年培训计划,逐条核验并【确认】,确认后将自动转入月培训计划。”
deploy-hxtesting / build-and-deploy (push) Successful in 1m20s

This commit is contained in:
runny committed 2026-11-30 17:04:06 +08:00
1 parent 858c352991
commit 0a4471f5e4
7 files changed
+286 -11

No files matched your search

@@ -122,6 +122,14 @@ type notifyTextTemplates struct {
// 年培训计划收集推送(scene=demand_collect):广播空标题/内容回落渲染
DemandCollectTitle string `json:"demand_collect_title"`
DemandCollectContent string `json:"demand_collect_content"`
// 需求导入核验提醒(scene=demand_verify):按部门聚合通知部门经理核验【确认】。
// 占位符:{year} 年度 / {dept} 部门名 / {count} 导入条数 / {courses} 课程名(、连接)
DemandVerifyTitle string `json:"demand_verify_title"`
DemandVerifyContent string `json:"demand_verify_content"`
// 需求确认转月计划提醒(scene=demand_confirmed):通知讲师与部门课长维护
// 授课安排。占位符:{year} 年度 / {course} 课程名
DemandConfirmedTitle string `json:"demand_confirmed_title"`
DemandConfirmedContent string `json:"demand_confirmed_content"`
}
// 内置默认文案(与历史硬编码逐字一致;{lecturer} 缺讲师时渲染为「待定」)。
@@ -137,6 +145,12 @@ const (
// 年培训计划收集推送默认文案(与前端收集弹窗历史硬编码逐字一致;{year} 渲染收集年度)
defaultDemandCollectTitle = "【培训需求收集】{year}年度培训计划收集"
defaultDemandCollectContent = "请各部门于 {year} 年 1 月 31 日前提报 {year} 年度培训需求:可点击消息中的「教育训练需求表模板」链接直接下载批量填写后导入,或登录和信智汇学院 → 企业培训 → 培训计划 → 年度需求收集在线逐条提报。"
// 需求导入核验提醒默认文案(与历史硬编码逐字一致;{dept}/{count}/{courses}/{year})
defaultDemandVerifyTitle = "【年度培训需求核验】{year}年度 {dept} 培训需求待核验"
defaultDemandVerifyContent = "{dept} 新导入 {count} 条年度培训需求(课程:{courses})。请登录和信智汇学院 → 企业培训 → 年培训计划,逐条核验并【确认】,确认后将自动转入月培训计划。"
// 需求确认转月计划提醒默认文案(与历史硬编码逐字一致;{year}/{course})
defaultDemandConfirmedTitle = "【培训计划维护】{course} 已确认转入月培训计划"
defaultDemandConfirmedContent = "{year}年度需求「{course}」已核验确认并自动转入月培训计划:请讲师维护课程信息(课件/试题),课长安排授课时间/地点与学员名单。入口:和信智汇学院 → 企业培训 → 月培训计划。"
)
func defaultNotifyTextTemplates() notifyTextTemplates {
@@ -151,6 +165,10 @@ func defaultNotifyTextTemplates() notifyTextTemplates {
WeeklyContent: defaultWeeklyContent,
DemandCollectTitle: defaultDemandCollectTitle,
DemandCollectContent: defaultDemandCollectContent,
DemandVerifyTitle: defaultDemandVerifyTitle,
DemandVerifyContent: defaultDemandVerifyContent,
DemandConfirmedTitle: defaultDemandConfirmedTitle,
DemandConfirmedContent: defaultDemandConfirmedContent,
}
}
@@ -177,6 +195,10 @@ func parseNotifyTextTemplates(raw []byte) notifyTextTemplates {
fill(&t.WeeklyContent, saved.WeeklyContent)
fill(&t.DemandCollectTitle, saved.DemandCollectTitle)
fill(&t.DemandCollectContent, saved.DemandCollectContent)
fill(&t.DemandVerifyTitle, saved.DemandVerifyTitle)
fill(&t.DemandVerifyContent, saved.DemandVerifyContent)
fill(&t.DemandConfirmedTitle, saved.DemandConfirmedTitle)
fill(&t.DemandConfirmedContent, saved.DemandConfirmedContent)
return t
}
@@ -206,6 +228,28 @@ func renderNotifyTemplate(tpl string, vars map[string]string) string {
return strings.NewReplacer(pairs...).Replace(tpl)
}
// DemandVerifyNoticeText 需求核验提醒文案(批量导入与在线提报创建共用,2026-11
// 需求:模板入配置中心「提醒推送文案」demand_verify_*,空字段回落内置默认)。
// 占位符:{year} 年度 / {dept} 部门名 / {count} 条数 / {courses} 课程名(、连接)。
func (s *trainingService) DemandVerifyNoticeText(ctx context.Context, tenantID uint64, year int, dept string, courses []string) (string, string) {
tpl := s.loadNotifyTextTemplates(ctx, tenantID)
vars := map[string]string{
"year": strconv.Itoa(year),
"dept": dept,
"count": strconv.Itoa(len(courses)),
"courses": strings.Join(courses, "、"),
}
return renderNotifyTemplate(tpl.DemandVerifyTitle, vars), renderNotifyTemplate(tpl.DemandVerifyContent, vars)
}
// DemandConfirmedNoticeText 需求确认转月计划维护提醒文案(demand_confirmed_* 可编辑,
// 空字段回落内置默认)。占位符:{year} 年度 / {course} 课程名。
func (s *trainingService) DemandConfirmedNoticeText(ctx context.Context, tenantID uint64, year int, course string) (string, string) {
tpl := s.loadNotifyTextTemplates(ctx, tenantID)
vars := map[string]string{"year": strconv.Itoa(year), "course": course}
return renderNotifyTemplate(tpl.DemandConfirmedTitle, vars), renderNotifyTemplate(tpl.DemandConfirmedContent, vars)
}
// ---------------------------------------------------------------------------
// 学员开课通知(immediate 立即推 / day_before 调度器推,共用 scene 幂等)
// ---------------------------------------------------------------------------
@@ -252,6 +296,10 @@ func (s *trainingService) sessionNoticeText(ctx context.Context, tenantID uint64
lecturerName := "待定"
// 讲师解析兜底(000165 复测):场次未指定讲师时回退课程管理主数据的讲师,
// 避免课程已设讲师但通知仍显示「待定」(场次先建、讲师后补的场景)。
// [2026-11 根因修复] 名册讲师解析不到姓名时再回退课程的外部讲师姓名 ——
// 发布校验允许「仅外部讲师」(lecturer_id 空、lecturer_external 有值)的线下课
// 发布,此前通知不认 external,这类课程推给学员的开课通知讲师恒显示「待定」;
// 讲师 id 在名册查无此人(员工已删等)时同样落此兜底。
lecturerID := session.LecturerID
if strings.TrimSpace(lecturerID) == "" {
if course, err := s.repo.GetCourse(ctx, tenantID, session.CourseID); err == nil && course != nil {
@@ -260,6 +308,10 @@ func (s *trainingService) sessionNoticeText(ctx context.Context, tenantID uint64
}
if lecturer, err := s.repo.GetMember(ctx, tenantID, lecturerID); err == nil && lecturer != nil && lecturer.UserName != "" {
lecturerName = lecturer.UserName
} else if course, err := s.repo.GetCourse(ctx, tenantID, session.CourseID); err == nil && course != nil {
if external := strings.TrimSpace(course.LecturerExternal); external != "" {
lecturerName = external
}
}
tpl := s.loadNotifyTextTemplates(ctx, tenantID)
title := renderNotifyTemplate(tpl.StudentNoticeTitle, map[string]string{"course": courseName})