作者 tangxvhui

修正 下发周期自评 时出现的异常

... ... @@ -8,6 +8,7 @@ import (
"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/domain"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/infrastructure/dao"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/log"
)
... ... @@ -179,9 +180,8 @@ func sendSummaryEvaluation(project *domain.EvaluationProject,
}
}
//回填 项目的状态
evaluationProjectRepo := factory.CreateEvaluationProjectRepository(map[string]interface{}{"transactionContext": transactionContext})
project.SummaryState = domain.ProjectSummaryStateYes
_, err = evaluationProjectRepo.Insert(project)
projectDao := dao.NewEvaluationProjectDao(map[string]interface{}{"transactionContext": transactionContext})
err = projectDao.UpdateSummaryState(project.Id, domain.ProjectSummaryStateYes)
if err != nil {
return nil, err
}
... ... @@ -275,55 +275,10 @@ func TaskSendSummaryEvaluation() error {
return err
}
// 发送短信通知
// 添加待发送的短信通知
func sendSmsEvalation(param []domain.SummaryEvaluation) error {
for i := range param {
notify.AddNotifySummaryEvaluation(&param[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
// }
// 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
}
... ...
package service
import (
"errors"
"fmt"
"time"
... ... @@ -1499,6 +1500,11 @@ func (srv *SummaryEvaluationService) editEvaluationValue(
defaultItemValue []*domain.SummaryEvaluationValue,
isTemporary bool,
) error {
ok := evaluationData.EndTime.Before(time.Now())
if ok {
return errors.New("评估时间已截止")
}
evaluationItemMap := map[int]*domain.EvaluationItemUsed{}
evaluationValueMap := map[int]*domain.SummaryEvaluationValue{}
evaluationData.TotalRating = nil //清空评级数量统计
... ...
package dao
import pgTransaction "github.com/linmadan/egglib-go/transaction/pg"
import (
pgTransaction "github.com/linmadan/egglib-go/transaction/pg"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/infrastructure/pg/models"
)
type EvaluationProjectDao struct {
transactionContext *pgTransaction.TransactionContext
... ... @@ -15,3 +19,12 @@ func NewEvaluationProjectDao(options map[string]interface{}) *EvaluationProjectD
transactionContext: transactionContext,
}
}
func (d *EvaluationProjectDao) UpdateSummaryState(id int64, status domain.ProjectSummaryState) error {
db := d.transactionContext.PgTx
_, err := db.Model(&models.EvaluationProject{}).
Where("id=?", id).
Set("summary_state=?", int(status)).
Update()
return err
}
... ...