作者 tangxvhui

修复sql错误

@@ -106,228 +106,6 @@ func (srv *MessagePersonalService) TodayMessageSummaryEvaluationSelf(param *comm @@ -106,228 +106,6 @@ func (srv *MessagePersonalService) TodayMessageSummaryEvaluationSelf(param *comm
106 return resp, nil 106 return resp, nil
107 } 107 }
108 108
109 -// 获取关于任务里程碑异常的消息  
110 -// 每日一次  
111 -func (srv *MessagePersonalService) TodayMessageTaskStageAnomaly(param *command.GetUserMessageCommand) (map[string]interface{}, error) {  
112 - transactionContext, err := factory.CreateTransactionContext(nil)  
113 - if err != nil {  
114 - return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())  
115 - }  
116 - if err := transactionContext.StartTransaction(); err != nil {  
117 - return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())  
118 - }  
119 - defer func() {  
120 - _ = transactionContext.RollbackTransaction()  
121 - }()  
122 -  
123 - messageRepo := factory.CreateMessagePersonalRepository(map[string]interface{}{  
124 - "transactionContext": transactionContext,  
125 - })  
126 - nowDay := time.Now().Format("2006-01-02")  
127 - cnt, _, err := messageRepo.Find(map[string]interface{}{  
128 - "types": domain.MessageTypesTaskStage,  
129 - "targetUserId": param.UserId,  
130 - "createdAtDay": nowDay,  
131 - "limit": 1,  
132 - })  
133 - if err != nil {  
134 - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "检查任务里程碑异常的消息"+err.Error())  
135 - }  
136 - if cnt > 0 {  
137 - resp := map[string]interface{}{  
138 - "needNotify": false,  
139 - "list": []adapter.MessageListAdapter{},  
140 - }  
141 - return resp, nil  
142 - }  
143 - userDao := dao.NewUserDao(map[string]interface{}{"transactionContext": transactionContext})  
144 -  
145 - taskDao := dao.NewTaskDao(map[string]interface{}{"transactionContext": transactionContext})  
146 - // 我作为任务负责人的提醒  
147 - leaderIds := []string{strconv.Itoa(param.UserId)}  
148 - taskStageList, err := taskDao.TaskStageAnomalyByLeader(leaderIds)  
149 - if err != nil {  
150 - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "检查任务里程碑异常的消息"+err.Error())  
151 - }  
152 - // 我作为任务相关方  
153 - taskStageList0, err := taskDao.TaskStageAnomalyByRelatedUser(param.UserId)  
154 - if err != nil {  
155 - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "检查任务里程碑异常的消息"+err.Error())  
156 - }  
157 - childUser, err := userDao.AllChildUser(param.UserId)  
158 - if err != nil {  
159 - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取下级员工"+err.Error())  
160 - }  
161 - //我的直属下级人员  
162 - childUserId := []string{}  
163 - for _, val := range childUser {  
164 - if val.Level == 2 {  
165 - childUserId = append(childUserId, strconv.Itoa(val.Id))  
166 - }  
167 - }  
168 - // 作为上级,我的下级员工的异常里程碑  
169 - var taskList2 []dao.TaskData3  
170 - if len(childUserId) > 0 {  
171 - taskList2, err = taskDao.TaskStageAnomalyByLeader(childUserId)  
172 - if err != nil {  
173 - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "检查任务里程碑异常的消息"+err.Error())  
174 - }  
175 - }  
176 - //我的下下级人员  
177 - childUserId2 := []string{}  
178 - for _, val := range childUser {  
179 - if val.Level >= 3 {  
180 - childUserId2 = append(childUserId2, strconv.Itoa(val.Id))  
181 - }  
182 - }  
183 - // 作为上级, 我的下下级员工的异常里程碑  
184 - var taskList3 []dao.TaskData3  
185 - if len(childUserId2) > 0 {  
186 - taskList3, err = taskDao.TaskStageAnomalyByLeader(childUserId2)  
187 - if err != nil {  
188 - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "检查任务里程碑异常的消息"+err.Error())  
189 - }  
190 - }  
191 -  
192 - msgList := []adapter.MessageListAdapter{}  
193 - for _, val := range taskStageList {  
194 - s := fmt.Sprintf("【您负责的项目【%s】里程碑未按时完成,请重点关注,积极寻找上级辅导。】", val.TaskAlias)  
195 - msgList = append(msgList, adapter.MessageListAdapter{  
196 - Content: s,  
197 - })  
198 - payload := map[string]string{  
199 - "taskId": strconv.Itoa(val.TaskId),  
200 - "taskAlias": val.TaskAlias,  
201 - "taskName": val.TaskName,  
202 - }  
203 - payloadStr, _ := json.Marshal(payload)  
204 - newMessage := domain.MessagePersonal{  
205 - Id: 0,  
206 - Types: domain.MessageTypesTaskStage,  
207 - TargetUserId: param.UserId,  
208 - ReadFlag: domain.MessageIsRead,  
209 - Title: s,  
210 - Content: s,  
211 - CreatedAt: time.Time{},  
212 - UpdatedAt: time.Time{},  
213 - Payload: string(payloadStr),  
214 - }  
215 - err = messageRepo.Save(&newMessage)  
216 - if err != nil {  
217 - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())  
218 - }  
219 - }  
220 - for _, val := range taskList2 {  
221 - s := fmt.Sprintf("【您下级%s负责的项目【%s】里程碑未按时完成,请前往辅导。】", val.LeaderName, val.TaskAlias)  
222 - msgList = append(msgList, adapter.MessageListAdapter{  
223 - Content: s,  
224 - })  
225 - payload := map[string]string{  
226 - "taskId": strconv.Itoa(val.TaskId),  
227 - "taskAlias": val.TaskAlias,  
228 - "taskName": val.TaskName,  
229 - }  
230 - payloadStr, _ := json.Marshal(payload)  
231 - newMessage := domain.MessagePersonal{  
232 - Id: 0,  
233 - Types: domain.MessageTypesTaskStage,  
234 - TargetUserId: param.UserId,  
235 - ReadFlag: domain.MessageIsRead,  
236 - Title: s,  
237 - Content: s,  
238 - CreatedAt: time.Time{},  
239 - UpdatedAt: time.Time{},  
240 - Payload: string(payloadStr),  
241 - }  
242 - err = messageRepo.Save(&newMessage)  
243 - if err != nil {  
244 - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())  
245 - }  
246 - }  
247 - for _, val := range taskList3 {  
248 - s := fmt.Sprintf("【您下级%s关注的项目【%s】里程碑未按时完成,请前往辅导。】", val.LeaderName, val.TaskAlias)  
249 - msgList = append(msgList, adapter.MessageListAdapter{  
250 - Content: s,  
251 - })  
252 - payload := map[string]string{  
253 - "taskId": strconv.Itoa(val.TaskId),  
254 - "taskAlias": val.TaskAlias,  
255 - "taskName": val.TaskName,  
256 - }  
257 - payloadStr, _ := json.Marshal(payload)  
258 - newMessage := domain.MessagePersonal{  
259 - Id: 0,  
260 - Types: domain.MessageTypesTaskStage,  
261 - TargetUserId: param.UserId,  
262 - ReadFlag: domain.MessageIsRead,  
263 - Title: s,  
264 - Content: s,  
265 - CreatedAt: time.Time{},  
266 - UpdatedAt: time.Time{},  
267 - Payload: string(payloadStr),  
268 - }  
269 - err = messageRepo.Save(&newMessage)  
270 - if err != nil {  
271 - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())  
272 - }  
273 - }  
274 - uidStr := strconv.Itoa(param.UserId)  
275 - //我作为任务相关人  
276 -loop:  
277 - for _, val := range taskStageList0 {  
278 - // 排除 我就是负责人,  
279 - if val.LeaderId == uidStr {  
280 - continue  
281 - }  
282 -  
283 - //排除 我是任务负责人的直属上级  
284 - for _, val2 := range childUserId {  
285 - if val.LeaderId == val2 {  
286 - continue loop  
287 - }  
288 - }  
289 -  
290 - s := fmt.Sprintf("【您关注的【%s】里程碑未按时完成,请知晓。】", val.TaskAlias)  
291 - msgList = append(msgList, adapter.MessageListAdapter{  
292 - Content: s,  
293 - })  
294 - payload := map[string]string{  
295 - "taskId": strconv.Itoa(val.TaskId),  
296 - "taskAlias": val.TaskAlias,  
297 - "taskName": val.TaskName,  
298 - }  
299 -  
300 - payloadStr, _ := json.Marshal(payload)  
301 - newMessage := domain.MessagePersonal{  
302 - Id: 0,  
303 - Types: domain.MessageTypesTaskStage,  
304 - TargetUserId: param.UserId,  
305 - ReadFlag: domain.MessageIsRead,  
306 - Title: s,  
307 - Content: s,  
308 - CreatedAt: time.Time{},  
309 - UpdatedAt: time.Time{},  
310 - Payload: string(payloadStr),  
311 - }  
312 - err = messageRepo.Save(&newMessage)  
313 - if err != nil {  
314 - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())  
315 - }  
316 - }  
317 - if err := transactionContext.CommitTransaction(); err != nil {  
318 - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())  
319 - }  
320 -  
321 - resp := map[string]interface{}{  
322 - "needNotify": true,  
323 - "list": msgList,  
324 - }  
325 - if len(msgList) == 0 {  
326 - resp["needNotify"] = false  
327 - }  
328 - return resp, nil  
329 -}  
330 -  
331 // 获取关于任务反馈碑异常的消息 109 // 获取关于任务反馈碑异常的消息
332 // 每日一次 110 // 每日一次
333 func (srv *MessagePersonalService) TodayMessageTaskRecordAnomaly(param *command.GetUserMessageCommand) (map[string]interface{}, error) { 111 func (srv *MessagePersonalService) TodayMessageTaskRecordAnomaly(param *command.GetUserMessageCommand) (map[string]interface{}, error) {
@@ -2,7 +2,6 @@ package dao @@ -2,7 +2,6 @@ package dao
2 2
3 import ( 3 import (
4 "fmt" 4 "fmt"
5 - "strconv"  
6 "time" 5 "time"
7 6
8 "github.com/go-pg/pg/v10" 7 "github.com/go-pg/pg/v10"
@@ -400,7 +399,7 @@ func (d *TaskAnomalyDao) List3(userId int, companyId int, taskName string, categ @@ -400,7 +399,7 @@ func (d *TaskAnomalyDao) List3(userId int, companyId int, taskName string, categ
400 and task_anomaly.is_last=1 399 and task_anomaly.is_last=1
401 ` 400 `
402 401
403 - condition := []interface{}{userId, userId, companyId, fmt.Sprintf("[%d]", userId), strconv.Itoa(userId)} 402 + condition := []interface{}{userId, userId, companyId, fmt.Sprintf("[%d]", userId)}
404 if len(dayTime) > 0 { 403 if len(dayTime) > 0 {
405 condition = append(condition, dayTime) 404 condition = append(condition, dayTime)
406 sqlStr2 += ` and to_char(task_anomaly.created_at,'yyyy-MM-dd') =? ` 405 sqlStr2 += ` and to_char(task_anomaly.created_at,'yyyy-MM-dd') =? `
@@ -412,9 +411,6 @@ func (d *TaskAnomalyDao) List3(userId int, companyId int, taskName string, categ @@ -412,9 +411,6 @@ func (d *TaskAnomalyDao) List3(userId int, companyId int, taskName string, categ
412 case domain.AnomalyCategoryType2: 411 case domain.AnomalyCategoryType2:
413 sqlStr2 += " and task_anomaly.assess_flag=1 " 412 sqlStr2 += " and task_anomaly.assess_flag=1 "
414 sqlStr1 += " and task_anomaly.assess_flag=1 " 413 sqlStr1 += " and task_anomaly.assess_flag=1 "
415 - // case domain.AnomalyCategoryType3:  
416 - // sqlStr2 += " and task_anomaly.assist_flag=1 "  
417 - // sqlStr1 += " and task_anomaly.assist_flag=1 "  
418 } 414 }
419 } 415 }
420 if len(taskName) > 0 { 416 if len(taskName) > 0 {