作者 tangxvhui

更新

... ... @@ -569,3 +569,58 @@ func (srv *MessagePersonalService) TodayMessageTaskAnomaly(param *command.GetUse
}
return resp, nil
}
// 提醒人员去确认周期评估的成绩
func (srv *MessagePersonalService) SummaartEvaluationScore(userId int) (msg map[string]interface{}, err error) {
msg = map[string]interface{}{
"needNotify": false,
"cycleId": "0",
"cycleName": "",
"targetUserId": "0",
"targetUserName": "",
}
transactionContext, err := factory.CreateTransactionContext(nil)
if err != nil {
return msg, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
if err := transactionContext.StartTransaction(); err != nil {
return msg, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
defer func() {
_ = transactionContext.RollbackTransaction()
}()
evaluationRepo := factory.CreateSummaryEvaluationRepository(map[string]interface{}{
"transactionContext": transactionContext,
})
_, evaluationList, err := evaluationRepo.Find(map[string]interface{}{
"targetUserId": userId,
"checkResult": domain.EvaluationCheckUncompleted,
"types": 5,
})
if err != nil {
return msg, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
if len(evaluationList) == 0 {
return msg, nil
}
nowTime := time.Now()
for _, val := range evaluationList {
if nowTime.After(val.EndTime) {
msg = map[string]interface{}{
"needNotify": true,
"cycleId": strconv.FormatInt(val.CycleId, 10),
"cycleName": val.CycleName,
"targetUserId": strconv.Itoa(val.TargetUser.UserId),
"targetUserName": val.TargetUser.UserName,
}
break
}
}
if err := transactionContext.CommitTransaction(); err != nil {
return msg, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
return msg, nil
}
... ...
... ... @@ -151,6 +151,11 @@ func (repo *SummaryEvaluationRepository) Find(queryOptions map[string]interface{
if v, ok := queryOptions["status"]; ok {
query.Where("status=?", v)
}
if v, ok := queryOptions["checkResult"]; ok {
query.Where("check_result=?", v)
}
if v, ok := queryOptions["targetUserId"]; ok {
query.Where(`summary_evaluation.target_user->>'userId'='?'`, v)
}
... ...
... ... @@ -49,3 +49,11 @@ func (c *MessagePersonalController) TodayMessageTaskStageModify() {
data, err := srv.TodayMessageTaskStageModifyV2(&param)
c.Response(data, err)
}
func (c *MessagePersonalController) TodayMessageSummaryEvaluationFinishScore() {
srv := service.NewMessagePersonalService()
userReq := middlewares.GetUser(c.Ctx)
userId := int(userReq.UserId)
data, err := srv.SummaartEvaluationScore(userId)
c.Response(data, err)
}
... ...
... ... @@ -14,7 +14,7 @@ func init() {
web.NSCtrlGet("/summary-evaluation/task_stage/today", (*controllers.MessagePersonalController).TodayMessageTaskStageAnomaly),
web.NSCtrlGet("/summary-evaluation/task_record/today", (*controllers.MessagePersonalController).TodayMessageTaskRecordAnomaly),
web.NSCtrlGet("/summary-evaluation/task_modify/today", (*controllers.MessagePersonalController).TodayMessageTaskStageModify),
//
web.NSCtrlGet("/summary-evaluation-finish/confim-score", (*controllers.MessagePersonalController).TodayMessageSummaryEvaluationFinishScore),
)
web.AddNamespace(ns)
}
... ...