正在显示
2 个修改的文件
包含
98 行增加
和
60 行删除
@@ -45,15 +45,15 @@ func messageTaskStageAnomaly() ([]*domain.MessagePersonal, error) { | @@ -45,15 +45,15 @@ func messageTaskStageAnomaly() ([]*domain.MessagePersonal, error) { | ||
45 | if len(userList) == 0 { | 45 | if len(userList) == 0 { |
46 | continue | 46 | continue |
47 | } | 47 | } |
48 | - //通知相关人员 | ||
49 | - // 【您关注的【%s】里程碑未按时完成,请知晓。】 | ||
50 | 48 | ||
49 | + var leaderParentId int | ||
51 | //通知负责人 | 50 | //通知负责人 |
52 | for _, val2 := range userList { | 51 | for _, val2 := range userList { |
53 | content := "" | 52 | content := "" |
54 | if val2.Level == 1 { | 53 | if val2.Level == 1 { |
55 | content = fmt.Sprintf("【您负责的项目【%s】里程碑未按时完成,请重点关注,积极寻找上级辅导。】", val.TaskName) | 54 | content = fmt.Sprintf("【您负责的项目【%s】里程碑未按时完成,请重点关注,积极寻找上级辅导。】", val.TaskName) |
56 | } else if val2.Level == 2 { | 55 | } else if val2.Level == 2 { |
56 | + leaderParentId = val2.Id | ||
57 | content = fmt.Sprintf("【您下级%s负责的项目【%s】里程碑未按时完成,请前往辅导。】", val.LeaderName, val.TaskName) | 57 | content = fmt.Sprintf("【您下级%s负责的项目【%s】里程碑未按时完成,请前往辅导。】", val.LeaderName, val.TaskName) |
58 | } else if val2.Level >= 3 { | 58 | } else if val2.Level >= 3 { |
59 | content = fmt.Sprintf("【您下级%s关注的项目【%s】里程碑未按时完成,请前往辅导。】", val.LeaderName, val.TaskName) | 59 | content = fmt.Sprintf("【您下级%s关注的项目【%s】里程碑未按时完成,请前往辅导。】", val.LeaderName, val.TaskName) |
@@ -80,6 +80,35 @@ func messageTaskStageAnomaly() ([]*domain.MessagePersonal, error) { | @@ -80,6 +80,35 @@ func messageTaskStageAnomaly() ([]*domain.MessagePersonal, error) { | ||
80 | } | 80 | } |
81 | allMessage = append(allMessage, &newMessage) | 81 | allMessage = append(allMessage, &newMessage) |
82 | } | 82 | } |
83 | + //通知相关人员 | ||
84 | + //【您关注的【%s】里程碑未按时完成,请知晓。】 | ||
85 | + for _, val2 := range val.RelatedUser { | ||
86 | + if val2 == val.LeaderId { | ||
87 | + continue | ||
88 | + } | ||
89 | + if val2 == leaderParentId { | ||
90 | + continue | ||
91 | + } | ||
92 | + payload := map[string]string{ | ||
93 | + "taskId": strconv.Itoa(val.TaskId), | ||
94 | + "taskAlias": val.TaskAlias, | ||
95 | + "taskName": val.TaskName, | ||
96 | + } | ||
97 | + payloadStr, _ := json.Marshal(payload) | ||
98 | + content := fmt.Sprintf("【您关注的【%s】里程碑未按时完成,请知晓。】", val.TaskAlias) | ||
99 | + newMessage := domain.MessagePersonal{ | ||
100 | + Id: 0, | ||
101 | + Types: domain.MessageTypesTaskStageApp, | ||
102 | + TargetUserId: val2, | ||
103 | + ReadFlag: domain.MessageIsRead, | ||
104 | + Title: content, | ||
105 | + Content: content, | ||
106 | + CreatedAt: time.Time{}, | ||
107 | + UpdatedAt: time.Time{}, | ||
108 | + Payload: string(payloadStr), | ||
109 | + } | ||
110 | + allMessage = append(allMessage, &newMessage) | ||
111 | + } | ||
83 | } | 112 | } |
84 | if err := transactionContext.CommitTransaction(); err != nil { | 113 | if err := transactionContext.CommitTransaction(); err != nil { |
85 | return nil, err | 114 | return nil, err |
@@ -99,65 +128,69 @@ func messageTaskRecordAnomaly() ([]*domain.MessagePersonal, error) { | @@ -99,65 +128,69 @@ func messageTaskRecordAnomaly() ([]*domain.MessagePersonal, error) { | ||
99 | defer func() { | 128 | defer func() { |
100 | _ = transactionContext.RollbackTransaction() | 129 | _ = transactionContext.RollbackTransaction() |
101 | }() | 130 | }() |
102 | - // taskDao := dao.NewTaskDao(map[string]interface{}{"transactionContext": transactionContext}) | ||
103 | - // userDao := dao.NewUserDao(map[string]interface{}{"transactionContext": transactionContext}) | ||
104 | - // taskData, err := taskDao.TaskRecordAnomalyAll() | ||
105 | - // if err != nil { | ||
106 | - // return nil, fmt.Errorf("获取任务信息%s", err) | ||
107 | - // } | ||
108 | - // if len(taskData) == 0 { | ||
109 | - // return nil, nil | ||
110 | - // } | ||
111 | - // var allMessage []*domain.MessagePersonal | ||
112 | - // for _, val := range taskData { | ||
113 | - // //获取我全上级 | ||
114 | - // userList, err := userDao.AllParentUser(val.LeaderId) | ||
115 | - // if err != nil { | ||
116 | - // return nil, fmt.Errorf("获取上级人员信息%s", err) | ||
117 | - // } | ||
118 | - // if len(userList) == 0 { | ||
119 | - // continue | ||
120 | - // } | ||
121 | - // //通知相关人员 | ||
122 | - | ||
123 | - // //通知负责人 | ||
124 | - // for _, val2 := range userList { | ||
125 | - // content := "" | ||
126 | - // if val2.Level == 1 { | ||
127 | - // content = fmt.Sprintf("【您负责的项目【%s】已超过%s日未反馈进度,请前往该战略任务进行反馈。】", val.TaskName) | ||
128 | - // } else if val2.Level == 2 { | ||
129 | - // content = fmt.Sprintf("【您下级%s负责的项目【%s】已超过%s日未反馈进度,请前往辅导。】", val.LeaderName, val.TaskName) | ||
130 | - // } else if val2.Level == 3 { | ||
131 | - // content = fmt.Sprintf("【您下级%s关注的项目【%s】已超过%s日未反馈进度,请前往辅导。】", val.LeaderName, val.TaskName) | ||
132 | - // } | ||
133 | - // if content == "" { | ||
134 | - // continue | ||
135 | - // } | ||
136 | - // payload := map[string]string{ | ||
137 | - // "task_id": strconv.Itoa(val.TaskId), | ||
138 | - // "task_alias": val.TaskAlias, | ||
139 | - // "task_name": val.TaskName, | ||
140 | - // } | ||
141 | - // payloadStr, _ := json.Marshal(payload) | ||
142 | - // newMessage := domain.MessagePersonal{ | ||
143 | - // Id: 0, | ||
144 | - // Types: domain.MessageTypesTaskStageApp, | ||
145 | - // TargetUserId: val2.Id, | ||
146 | - // ReadFlag: domain.MessageIsRead, | ||
147 | - // Title: content, | ||
148 | - // Content: content, | ||
149 | - // CreatedAt: time.Time{}, | ||
150 | - // UpdatedAt: time.Time{}, | ||
151 | - // Payload: string(payloadStr), | ||
152 | - // } | ||
153 | - // allMessage = append(allMessage, &newMessage) | ||
154 | - // } | ||
155 | - // } | 131 | + taskDao := dao.NewTaskDao(map[string]interface{}{"transactionContext": transactionContext}) |
132 | + userDao := dao.NewUserDao(map[string]interface{}{"transactionContext": transactionContext}) | ||
133 | + taskData, err := taskDao.TaskRecordAnomalyAll() | ||
134 | + if err != nil { | ||
135 | + return nil, fmt.Errorf("获取任务信息%s", err) | ||
136 | + } | ||
137 | + if len(taskData) == 0 { | ||
138 | + return nil, nil | ||
139 | + } | ||
140 | + var allMessage []*domain.MessagePersonal | ||
141 | + for _, val := range taskData { | ||
142 | + //获取我全上级 | ||
143 | + userList, err := userDao.AllParentUser(val.LeaderId) | ||
144 | + if err != nil { | ||
145 | + return nil, fmt.Errorf("获取上级人员信息%s", err) | ||
146 | + } | ||
147 | + if len(userList) == 0 { | ||
148 | + continue | ||
149 | + } | ||
150 | + //通知负责人 | ||
151 | + for _, val2 := range userList { | ||
152 | + payload := map[string]string{ | ||
153 | + "taskId": strconv.Itoa(val.TaskId), | ||
154 | + "taskAlias": val.TaskAlias, | ||
155 | + "taskName": val.TaskName, | ||
156 | + } | ||
157 | + payloadStr, _ := json.Marshal(payload) | ||
158 | + newMessage := domain.MessagePersonal{ | ||
159 | + Id: 0, | ||
160 | + Types: domain.MessageTypesTaskStageApp, | ||
161 | + TargetUserId: val2.Id, | ||
162 | + ReadFlag: domain.MessageIsRead, | ||
163 | + Title: "", | ||
164 | + Content: "", | ||
165 | + CreatedAt: time.Time{}, | ||
166 | + UpdatedAt: time.Time{}, | ||
167 | + Payload: string(payloadStr), | ||
168 | + } | ||
169 | + content := "" | ||
170 | + if val2.Level == 1 { | ||
171 | + content = fmt.Sprintf("【您负责的项目【%s】已超过%d日未反馈进度,请前往该战略任务进行反馈。】", val.TaskName, val.Anomaly) | ||
172 | + newMessage.Content = content | ||
173 | + newMessage.Title = content | ||
174 | + allMessage = append(allMessage, &newMessage) | ||
175 | + } | ||
176 | + if val2.Level == 2 && val.Anomaly > 3 { | ||
177 | + content = fmt.Sprintf("【您下级%s负责的项目【%s】已超过%d日未反馈进度,请前往辅导。】", val.LeaderName, val.TaskName, val.Anomaly) | ||
178 | + newMessage.Content = content | ||
179 | + newMessage.Title = content | ||
180 | + allMessage = append(allMessage, &newMessage) | ||
181 | + } | ||
182 | + if val2.Level == 3 && val.Anomaly > 5 { | ||
183 | + content = fmt.Sprintf("【您下级%s关注的项目【%s】已超过%d日未反馈进度,请前往辅导。】", val.LeaderName, val.TaskName, val.Anomaly) | ||
184 | + newMessage.Content = content | ||
185 | + newMessage.Title = content | ||
186 | + allMessage = append(allMessage, &newMessage) | ||
187 | + } | ||
188 | + } | ||
189 | + } | ||
156 | if err := transactionContext.CommitTransaction(); err != nil { | 190 | if err := transactionContext.CommitTransaction(); err != nil { |
157 | return nil, err | 191 | return nil, err |
158 | } | 192 | } |
159 | - // return allMessage, nil | ||
160 | - return nil, nil | 193 | + return allMessage, nil |
161 | } | 194 | } |
162 | 195 | ||
163 | func saveAllMessagePersonal(msgList []*domain.MessagePersonal) error { | 196 | func saveAllMessagePersonal(msgList []*domain.MessagePersonal) error { |
@@ -194,6 +227,11 @@ func appMessageSend() error { | @@ -194,6 +227,11 @@ func appMessageSend() error { | ||
194 | return fmt.Errorf("生成里程碑异常的消息通知失败%s", err) | 227 | return fmt.Errorf("生成里程碑异常的消息通知失败%s", err) |
195 | } | 228 | } |
196 | appMessage = append(appMessage, messageList...) | 229 | appMessage = append(appMessage, messageList...) |
230 | + messageList2, err := messageTaskRecordAnomaly() | ||
231 | + if err != nil { | ||
232 | + return fmt.Errorf("生成任务反馈异常的消息通知失败%s", err) | ||
233 | + } | ||
234 | + appMessage = append(appMessage, messageList2...) | ||
197 | openApi := serviceGateway.NewHttplibMmmOpenApiServiceGateway() | 235 | openApi := serviceGateway.NewHttplibMmmOpenApiServiceGateway() |
198 | for _, val := range appMessage { | 236 | for _, val := range appMessage { |
199 | _, err := openApi.PushInfo(1, constant.APP_MESSAGE_KEY, []int64{int64(val.TargetUserId)}, val.Title, val.Content) | 237 | _, err := openApi.PushInfo(1, constant.APP_MESSAGE_KEY, []int64{int64(val.TargetUserId)}, val.Title, val.Content) |
@@ -9,8 +9,8 @@ import ( | @@ -9,8 +9,8 @@ import ( | ||
9 | func TestGenerateToken(t *testing.T) { | 9 | func TestGenerateToken(t *testing.T) { |
10 | ut := UserAuth{ | 10 | ut := UserAuth{ |
11 | CompanyId: 8, | 11 | CompanyId: 8, |
12 | - UserId: 3422174102828544, | ||
13 | - Phone: "17708397664", | 12 | + UserId: 3422185340122624, |
13 | + Phone: "13066667710", | ||
14 | PlatformId: 29, | 14 | PlatformId: 29, |
15 | AdminType: 1, | 15 | AdminType: 1, |
16 | } | 16 | } |
-
请 注册 或 登录 后发表评论