作者 tangxvhui

日常保存

... ... @@ -580,7 +580,7 @@ func (srv *MessagePersonalService) TodayMessageTaskStageModifyV2(param *command.
return resp, nil
}
func (srv *MessagePersonalService) TodayMessageTaskAnomaly() (map[string]interface{}, error) {
func (srv *MessagePersonalService) TodayMessageTaskAnomaly(param *command.GetUserMessageCommand) (map[string]interface{}, error) {
transactionContext, err := factory.CreateTransactionContext(nil)
if err != nil {
... ... @@ -593,6 +593,26 @@ func (srv *MessagePersonalService) TodayMessageTaskAnomaly() (map[string]interfa
_ = transactionContext.RollbackTransaction()
}()
messageRepo := factory.CreateMessagePersonalRepository(map[string]interface{}{
"transactionContext": transactionContext,
})
nowDay := time.Now().Format("2006-01-02")
cnt, _, err := messageRepo.Find(map[string]interface{}{
"types": domain.MessageTypesTaskRecord,
"targetUserId": param.UserId,
"createdAtDay": nowDay,
"limit": 1,
})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "检查任务里程碑异常的消息"+err.Error())
}
if cnt > 0 {
resp := map[string]interface{}{
"needNotify": false,
"list": []adapter.MessageListAdapter{},
}
return resp, nil
}
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
... ...
... ... @@ -748,3 +748,56 @@ func (d *TaskDao) CountTaskIgnore(param ListTaskCondition) (int, error) {
_, err := tx.Query(pg.Scan(&result), sqlStr, condition...)
return result, err
}
type TaskData6 struct {
TaskId int `pg:"task_id"`
TaskName string `pg:"task_name"`
TaskAlias string `pg:"task_alias"`
LeaderName string `pg:"leader_name"`
LeaderId string `pg:"leader_id"`
WarnFlag int `pg:"warn_flag"`
AssistFlag int `pg:"assist_flag"`
Anomaly int `pg:"anomaly"`
}
func (d *TaskDao) TaskIsAnomalyByLeader(leaderId []string) ([]TaskData6, error) {
sqlStr := `select
task.id as task_id,
task."name" as task_name ,
task.alias as task_alias,
task.leader ->>'id' as leader_id,
task.leader ->>'name' as leader_name,
task.assist_flag ,
task.warn_flag ,
task.anomaly
from task where 1=1
and task.deleted_at isnull
and (task.assist_flag+task.warn_flag +task.anomaly)>0
and task.leader ->>'id' in(?) `
result := []TaskData6{}
tx := d.transactionContext.PgTx
_, err := tx.Query(&result, sqlStr, pg.In(leaderId))
return result, err
}
func (d *TaskDao) TaskIsAnomalyByRelatedUser(relatedUserId int) ([]TaskData6, error) {
sqlStr := `select
task.id as task_id,
task."name" as task_name ,
task.alias as task_alias,
task.leader ->>'id' as leader_id,
task.leader ->>'name' as leader_name,
task.assist_flag ,
task.warn_flag ,
task.anomaly
from task where 1=1
and task.deleted_at isnull
and (task.assist_flag+task.warn_flag +task.anomaly)>0
and task.related_user @>? `
relatedUser := fmt.Sprintf("[%d]", relatedUserId)
result := []TaskData6{}
tx := d.transactionContext.PgTx
_, err := tx.Query(&result, sqlStr, relatedUser)
return result, err
}
... ...