作者 tangxvhui

日常保存

@@ -580,7 +580,7 @@ func (srv *MessagePersonalService) TodayMessageTaskStageModifyV2(param *command. @@ -580,7 +580,7 @@ func (srv *MessagePersonalService) TodayMessageTaskStageModifyV2(param *command.
580 return resp, nil 580 return resp, nil
581 } 581 }
582 582
583 -func (srv *MessagePersonalService) TodayMessageTaskAnomaly() (map[string]interface{}, error) { 583 +func (srv *MessagePersonalService) TodayMessageTaskAnomaly(param *command.GetUserMessageCommand) (map[string]interface{}, error) {
584 584
585 transactionContext, err := factory.CreateTransactionContext(nil) 585 transactionContext, err := factory.CreateTransactionContext(nil)
586 if err != nil { 586 if err != nil {
@@ -593,6 +593,26 @@ func (srv *MessagePersonalService) TodayMessageTaskAnomaly() (map[string]interfa @@ -593,6 +593,26 @@ func (srv *MessagePersonalService) TodayMessageTaskAnomaly() (map[string]interfa
593 _ = transactionContext.RollbackTransaction() 593 _ = transactionContext.RollbackTransaction()
594 }() 594 }()
595 595
  596 + messageRepo := factory.CreateMessagePersonalRepository(map[string]interface{}{
  597 + "transactionContext": transactionContext,
  598 + })
  599 + nowDay := time.Now().Format("2006-01-02")
  600 + cnt, _, err := messageRepo.Find(map[string]interface{}{
  601 + "types": domain.MessageTypesTaskRecord,
  602 + "targetUserId": param.UserId,
  603 + "createdAtDay": nowDay,
  604 + "limit": 1,
  605 + })
  606 + if err != nil {
  607 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "检查任务里程碑异常的消息"+err.Error())
  608 + }
  609 + if cnt > 0 {
  610 + resp := map[string]interface{}{
  611 + "needNotify": false,
  612 + "list": []adapter.MessageListAdapter{},
  613 + }
  614 + return resp, nil
  615 + }
596 if err := transactionContext.CommitTransaction(); err != nil { 616 if err := transactionContext.CommitTransaction(); err != nil {
597 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 617 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
598 } 618 }
@@ -748,3 +748,56 @@ func (d *TaskDao) CountTaskIgnore(param ListTaskCondition) (int, error) { @@ -748,3 +748,56 @@ func (d *TaskDao) CountTaskIgnore(param ListTaskCondition) (int, error) {
748 _, err := tx.Query(pg.Scan(&result), sqlStr, condition...) 748 _, err := tx.Query(pg.Scan(&result), sqlStr, condition...)
749 return result, err 749 return result, err
750 } 750 }
  751 +
  752 +type TaskData6 struct {
  753 + TaskId int `pg:"task_id"`
  754 + TaskName string `pg:"task_name"`
  755 + TaskAlias string `pg:"task_alias"`
  756 + LeaderName string `pg:"leader_name"`
  757 + LeaderId string `pg:"leader_id"`
  758 + WarnFlag int `pg:"warn_flag"`
  759 + AssistFlag int `pg:"assist_flag"`
  760 + Anomaly int `pg:"anomaly"`
  761 +}
  762 +
  763 +func (d *TaskDao) TaskIsAnomalyByLeader(leaderId []string) ([]TaskData6, error) {
  764 + sqlStr := `select
  765 + task.id as task_id,
  766 + task."name" as task_name ,
  767 + task.alias as task_alias,
  768 + task.leader ->>'id' as leader_id,
  769 + task.leader ->>'name' as leader_name,
  770 + task.assist_flag ,
  771 + task.warn_flag ,
  772 + task.anomaly
  773 +from task where 1=1
  774 +and task.deleted_at isnull
  775 +and (task.assist_flag+task.warn_flag +task.anomaly)>0
  776 +and task.leader ->>'id' in(?) `
  777 + result := []TaskData6{}
  778 + tx := d.transactionContext.PgTx
  779 + _, err := tx.Query(&result, sqlStr, pg.In(leaderId))
  780 + return result, err
  781 +}
  782 +
  783 +func (d *TaskDao) TaskIsAnomalyByRelatedUser(relatedUserId int) ([]TaskData6, error) {
  784 + sqlStr := `select
  785 + task.id as task_id,
  786 + task."name" as task_name ,
  787 + task.alias as task_alias,
  788 + task.leader ->>'id' as leader_id,
  789 + task.leader ->>'name' as leader_name,
  790 + task.assist_flag ,
  791 + task.warn_flag ,
  792 + task.anomaly
  793 +from task where 1=1
  794 +and task.deleted_at isnull
  795 +and (task.assist_flag+task.warn_flag +task.anomaly)>0
  796 +and task.related_user @>? `
  797 +
  798 + relatedUser := fmt.Sprintf("[%d]", relatedUserId)
  799 + result := []TaskData6{}
  800 + tx := d.transactionContext.PgTx
  801 + _, err := tx.Query(&result, sqlStr, relatedUser)
  802 + return result, err
  803 +}