...
|
...
|
@@ -5,12 +5,11 @@ import ( |
|
|
"strconv"
|
|
|
"time"
|
|
|
|
|
|
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/constant"
|
|
|
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/infrastructure/serviceGateway"
|
|
|
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/log"
|
|
|
|
|
|
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/factory"
|
|
|
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/notify"
|
|
|
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/constant"
|
|
|
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain"
|
|
|
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/log"
|
|
|
)
|
|
|
|
|
|
// sendSummaryEvaluafionTask 根据评估项目设置,确认是否下发评估任务
|
...
|
...
|
@@ -272,8 +271,8 @@ func TaskSendSummaryEvaluation() error { |
|
|
if err := transactionContext.CommitTransaction(); err != nil {
|
|
|
return err
|
|
|
}
|
|
|
//发送短信通知
|
|
|
//err = sendSmsEvalation(createdEvalationList)
|
|
|
//添加待发送的短信通知
|
|
|
err = sendSmsEvalation(createdEvalationList)
|
|
|
return err
|
|
|
}
|
|
|
|
...
|
...
|
@@ -282,49 +281,53 @@ func sendSmsEvalation(param []domain.SummaryEvaluation) error { |
|
|
if constant.Env != "prd" {
|
|
|
return nil
|
|
|
}
|
|
|
for i := range param {
|
|
|
notify.AddNotifySummaryEvaluation(¶m[i])
|
|
|
}
|
|
|
|
|
|
//处理短信发送
|
|
|
//过滤去重 处理需要发送改执行人的消息 执行人id=>domain.LogSms
|
|
|
noticeMap := map[string]*domain.LogSms{}
|
|
|
for _, v := range param {
|
|
|
phone := v.Executor.Account
|
|
|
name := v.Executor.UserName
|
|
|
if _, ok := noticeMap[phone]; ok {
|
|
|
continue
|
|
|
}
|
|
|
if phone == "" {
|
|
|
continue
|
|
|
}
|
|
|
smsMessage := domain.LogSms{}
|
|
|
smsMessage.SummaryEvaluationMessage(phone, name)
|
|
|
noticeMap[phone] = &smsMessage
|
|
|
}
|
|
|
// noticeMap := map[string]*domain.LogSms{}
|
|
|
// for _, v := range param {
|
|
|
// phone := v.Executor.Account
|
|
|
// name := v.Executor.UserName
|
|
|
// if _, ok := noticeMap[phone]; ok {
|
|
|
// continue
|
|
|
// }
|
|
|
// if phone == "" {
|
|
|
// continue
|
|
|
// }
|
|
|
// smsMessage := domain.LogSms{}
|
|
|
// smsMessage.SummaryEvaluationMessage(phone, name)
|
|
|
// noticeMap[phone] = &smsMessage
|
|
|
// }
|
|
|
|
|
|
sms := serviceGateway.SmsService{}
|
|
|
for _, v := range noticeMap {
|
|
|
err := sms.SendNoticeSms(v.Phone, v.TemplateId, v.Value)
|
|
|
if err != nil {
|
|
|
v.Result = err.Error()
|
|
|
}
|
|
|
}
|
|
|
transactionContext, err := factory.CreateTransactionContext(nil)
|
|
|
if err != nil {
|
|
|
return err
|
|
|
}
|
|
|
if err := transactionContext.StartTransaction(); err != nil {
|
|
|
return err
|
|
|
}
|
|
|
defer func() {
|
|
|
_ = transactionContext.RollbackTransaction()
|
|
|
}()
|
|
|
logSmsRepo := factory.CreateLogSmsRepository(map[string]interface{}{"transactionContext": transactionContext})
|
|
|
for _, v := range noticeMap {
|
|
|
err = logSmsRepo.Insert(v)
|
|
|
if err != nil {
|
|
|
log.Logger.Error("TaskSendSummaryEvaluation 发送短信通知:" + err.Error())
|
|
|
}
|
|
|
}
|
|
|
if err := transactionContext.CommitTransaction(); err != nil {
|
|
|
return err
|
|
|
}
|
|
|
// sms := serviceGateway.SmsService{}
|
|
|
// for _, v := range noticeMap {
|
|
|
// err := sms.SendNoticeSms(v.Phone, v.TemplateId, v.Value)
|
|
|
// if err != nil {
|
|
|
// v.Result = err.Error()
|
|
|
// }
|
|
|
// }
|
|
|
// transactionContext, err := factory.CreateTransactionContext(nil)
|
|
|
// if err != nil {
|
|
|
// return err
|
|
|
// }
|
|
|
// if err := transactionContext.StartTransaction(); err != nil {
|
|
|
// return err
|
|
|
// }
|
|
|
// defer func() {
|
|
|
// _ = transactionContext.RollbackTransaction()
|
|
|
// }()
|
|
|
// logSmsRepo := factory.CreateLogSmsRepository(map[string]interface{}{"transactionContext": transactionContext})
|
|
|
// for _, v := range noticeMap {
|
|
|
// err = logSmsRepo.Insert(v)
|
|
|
// if err != nil {
|
|
|
// log.Logger.Error("TaskSendSummaryEvaluation 发送短信通知:" + err.Error())
|
|
|
// }
|
|
|
// }
|
|
|
// if err := transactionContext.CommitTransaction(); err != nil {
|
|
|
// return err
|
|
|
// }
|
|
|
return nil
|
|
|
} |
...
|
...
|
|