作者 tangxvhui

暂存

... ... @@ -11,6 +11,7 @@ func RunTaskSmsNotify() {
taskSmsNotify.init()
taskSmsNotify.regist(notifyStaffAssess{})
taskSmsNotify.regist(notifySummaryEvaluation{})
taskSmsNotify.regist(notifyConfirmEvaluationScore{})
taskSmsNotify.runTask()
}
... ...
... ... @@ -47,6 +47,9 @@ func (notices *notifySms) addTask(task *domain.LogSms) {
// RunTask 执行短信通知任务
func (notices *notifySms) runTask() {
if constant.Env != "prd" {
return
}
timer := time.NewTimer(notices.interval)
for {
select {
... ... @@ -130,9 +133,7 @@ func (notices *notifySms) checkSendSms() error {
// sendSms 发送短信消息
func (notices *notifySms) sendSms(param *domain.LogSms) error {
if constant.Env != "prd" {
return nil
}
//单开处理 数据保存操作,发一条短信更新一条数据
transactionContext, err := factory.CreateTransactionContext(nil)
if err != nil {
... ...
package notify
import (
"time"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain"
)
// 短信提醒确认周期评估成绩
// 条件:上级提交评估后 到10号晚23:59前,对未确认的被评估人每隔6个小时进行提醒(23:00-7:00期间不提醒),直到确认
type notifyConfirmEvaluationScore struct {
}
var _ notifySendOrNot = (*notifyConfirmEvaluationScore)(nil)
func (notices notifyConfirmEvaluationScore) from() string {
return "ConfirmEvaluationScore"
}
func (notices notifyConfirmEvaluationScore) makeNotify(param *domain.SummaryEvaluation) *domain.LogSms {
newSms := domain.LogSms{
Id: 0,
Phone: param.Executor.Account,
TemplateId: 5475050,
Template: "您好,#name#,#periodName#成绩已出,请前往绩效系统PC端进行确认哦,逾期未确认可能会影响当月绩效工资哦~ ",
Value: map[string]string{
"name": param.Executor.UserName,
"periodName": param.CycleName,
},
Result: "",
Status: domain.SmsWait,
From: notices.from(),
Index: param.Id,
ExecuteAt: notices.getTimeExecuteAt(time.Now()),
CreatedAt: time.Now(),
}
return &newSms
}
func (notices notifyConfirmEvaluationScore) ifSend(index int) (bool, error) {
//检查时间
//适配规则:上级提交评估后 到10号晚23:59前,可以发送
//检查数据 SummaryEvaluation ,types=5,并添加短信数据
//适配规则 对未确认的被评估人每隔6个小时进行提醒(23:00-7:00期间不提醒),直到确认
return true, nil
}
// 输入的时间为基础微调短信的执行时间
// 适配规则 :(23:00-7:00期间不提醒)
func (notices notifyConfirmEvaluationScore) getTimeExecuteAt(nowTime time.Time) time.Time {
nowHour := nowTime.Local().Hour()
if nowHour < 23 && nowHour > 7 {
return nowTime
}
year, month, day := nowTime.Local().Date()
//微调执行时间
if nowHour >= 23 {
//第二天:7:00
t1 := time.Date(year, month, day, 23, 59, 59, 0, time.Local)
return t1.Add(7 * time.Hour)
}
if nowHour <= 7 {
//当天 7:00
t1 := time.Date(year, month, day, 0, 0, 0, 0, time.Local)
return t1.Add(7 * time.Hour)
}
return nowTime
}
... ...
... ... @@ -11,6 +11,8 @@ import (
type notifyStaffAssess struct {
}
var _ notifySendOrNot = (*notifyStaffAssess)(nil)
func (notices notifyStaffAssess) from() string {
return "StaffAssess"
}
... ...
... ... @@ -12,6 +12,8 @@ import (
type notifySummaryEvaluation struct {
}
var _ notifySendOrNot = (*notifySummaryEvaluation)(nil)
func (notices notifySummaryEvaluation) from() string {
return "SummaryEvaluation"
}
... ...
... ... @@ -7,6 +7,7 @@ type EvaluationSuperListAdapter struct {
EvaluationStatus string `json:"evaluationStatus"` //上级评估完成状态
EndTime string `json:"endTime"` //截止时间
TotalScoreSelf string `json:"totalScoreSelf"` //综合自评总分
TotalScoreSuper string `json:"totalScoreSuper"` //综合自评总分
Department string `json:"department"` //部门
Position string `json:"position"` //职位
EntryTime string `json:"entryTime"` //入职时间
... ...
... ... @@ -821,6 +821,7 @@ func (srv *SummaryEvaluationService) AfterCompletedEvaluationSuper(param *domain
return application.ThrowError(application.INTERNAL_SERVER_ERROR, "保存考核结果,"+err.Error())
}
}
//添加确认绩效成绩提醒短信提醒
if err := transactionContext.CommitTransaction(); err != nil {
return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
... ... @@ -1572,6 +1573,7 @@ func (srv *SummaryEvaluationService) ListExecutorEvaluationSuper(param *command.
Department: "",
Position: "",
EntryTime: "",
TotalScoreSuper: v.TotalScore,
}
for _, dep := range v.TargetDepartment {
item.Department += dep.DepartmentName + " "
... ...
... ... @@ -7,7 +7,7 @@ func TestPushInfo(t *testing.T) {
c := NewHttplibMmmOpenApiServiceGateway()
//3436890424617728
//3422173870118400
resp, err := c.PushInfo(0, "mmm.ability.performance", []int64{3436890424617728}, "ceshi推送一个消息233", "消息内容xxxx332")
resp, err := c.PushInfo(0, "mmm.ability.performance", []int64{3422173870118400}, "ceshi推送一个消息233", "消息内容xxxx332")
if err != nil {
t.Error(err)
}
... ...