作者 tangxvhui

Merge branch 'dev-tangxvhui' into test

@@ -5,24 +5,26 @@ import ( @@ -5,24 +5,26 @@ import (
5 ) 5 )
6 6
7 type TaskItem struct { 7 type TaskItem struct {
8 - Id int `json:"id,string"`  
9 - Name string `json:"name"` // 任务名称  
10 - Alias string `json:"alias"` // 任务别名  
11 - Leader string `json:"leader"` // 任务负责人  
12 - Status int `json:"status"` // 任务的状态  
13 - StatusDescript string `json:"statusDescript"` //任务的整体状态描述  
14 - SortBy int `json:"level"` // 优先级,值越小优先级越高  
15 - LevelName string `json:"levelName"` // 任务分类名称  
16 - StageA TaskStage `json:"stageA"` // 里程碑1  
17 - StageB TaskStage `json:"stageB"` // 里程碑2  
18 - StageC TaskStage `json:"stageC"` // 里程碑3  
19 - StageD TaskStage `json:"stageD"` // 里程碑4  
20 - StageE TaskStage `json:"stageE"` // 里程碑5  
21 - LastStage TaskStage `json:"lastStage"` //  
22 - CurrentStage TaskStage `json:"currentStage"` //  
23 - UpdatedAt string `json:"updatedAt"` //  
24 - Anomaly int `json:"anomaly"` //异常反馈情况  
25 - WarnFlag int `json:"warnFlag"` //里程碑完成时间异常标记 0:正常 1标记为异常 8 + Id int `json:"id,string"`
  9 + Name string `json:"name"` // 任务名称
  10 + Alias string `json:"alias"` // 任务别名
  11 + Leader string `json:"leader"` // 任务负责人
  12 + Status int `json:"status"` // 任务的状态
  13 + StatusDescript string `json:"statusDescript"` // 任务的整体状态描述
  14 + SortBy int `json:"level"` // 优先级,值越小优先级越高
  15 + LevelName string `json:"levelName"` // 任务分类名称
  16 + StageA TaskStage `json:"stageA"` // 里程碑1
  17 + StageB TaskStage `json:"stageB"` // 里程碑2
  18 + StageC TaskStage `json:"stageC"` // 里程碑3
  19 + StageD TaskStage `json:"stageD"` // 里程碑4
  20 + StageE TaskStage `json:"stageE"` // 里程碑5
  21 + LastStage TaskStage `json:"lastStage"` //
  22 + CurrentStage TaskStage `json:"currentStage"` //
  23 + UpdatedAt string `json:"updatedAt"` //
  24 + Anomaly int `json:"anomaly"` // 异常反馈情况
  25 + WarnFlag int `json:"warnFlag"` // 里程碑完成时间异常标记 0:正常 1标记为异常
  26 + AnomalyDesc []string `json:"anomalyDesc"` // 异常状态
  27 + Marks map[string]string `json:"marks"` // 标记
26 } 28 }
27 29
28 func (t *TaskItem) GenStatusDescript() { 30 func (t *TaskItem) GenStatusDescript() {
  1 +package adapter
  2 +
  3 +// 人员选择列表
  4 +type UserItem struct {
  5 + Id int64 `json:"id,string"`
  6 + Name string `json:"name"`
  7 + Level int `json:"level"`
  8 +}
  1 +package command
  2 +
  3 +type MarkTaskAnomalyCommand struct {
  4 + Id int `json:"id,string"`
  5 + CompanyId int `json:"-"`
  6 + MarkType string `json:"markType"`
  7 +}
  1 +package command
  2 +
  3 +type UserSelectCommand struct {
  4 + UserId int `json:"-"`
  5 + CompanyId int `json:"-"`
  6 + SubLevel int `json:"subLevel"`
  7 +}
@@ -2,6 +2,9 @@ package service @@ -2,6 +2,9 @@ package service
2 2
3 import ( 3 import (
4 "testing" 4 "testing"
  5 +
  6 + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/factory"
  7 + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/log"
5 ) 8 )
6 9
7 func TestCheckYesterdayTaskRecord(t *testing.T) { 10 func TestCheckYesterdayTaskRecord(t *testing.T) {
@@ -21,3 +24,41 @@ func TestCheckYesterdayTaskRecord(t *testing.T) { @@ -21,3 +24,41 @@ func TestCheckYesterdayTaskRecord(t *testing.T) {
21 } 24 }
22 } 25 }
23 } 26 }
  27 +
  28 +func TestCreatTaskAnamaly(t *testing.T) {
  29 + transactionContext, err := factory.CreateTransactionContext(nil)
  30 + if err != nil {
  31 + t.Error(err)
  32 + return
  33 + }
  34 + if err := transactionContext.StartTransaction(); err != nil {
  35 + t.Error(err)
  36 + return
  37 + }
  38 + defer func() {
  39 + _ = transactionContext.RollbackTransaction()
  40 + }()
  41 +
  42 + taskRecordRepo := factory.CreateTaskRecordRepository(map[string]interface{}{
  43 + "transactionContext": transactionContext,
  44 + })
  45 + _, taskRacordList, err := taskRecordRepo.Find(map[string]interface{}{
  46 + "ids": []int{1669736612939960320},
  47 + })
  48 + if err != nil {
  49 + t.Error(err)
  50 + return
  51 + }
  52 + if err := transactionContext.CommitTransaction(); err != nil {
  53 + t.Error(err)
  54 + return
  55 + }
  56 +
  57 + for _, val := range taskRacordList {
  58 + err = checkTaskRecordV2(val)
  59 + if err != nil {
  60 + log.Logger.Info("检查每日任务反馈" + err.Error())
  61 + }
  62 + }
  63 +
  64 +}
@@ -95,7 +95,7 @@ func isNotWarnFlag(transactionContext application.TransactionContext, taskData * @@ -95,7 +95,7 @@ func isNotWarnFlag(transactionContext application.TransactionContext, taskData *
95 }) 95 })
96 _, oldAnomaly, err := taskAnomalyRepo.Find(map[string]interface{}{ 96 _, oldAnomaly, err := taskAnomalyRepo.Find(map[string]interface{}{
97 "isLast": 1, 97 "isLast": 1,
98 - "category": 2, 98 + "category": domain.AnomalyCategoryType1,
99 "limit": 1, 99 "limit": 1,
100 "taskId": taskData.Id, 100 "taskId": taskData.Id,
101 "taskStageCheck": fmt.Sprintf(`{"id":"%d"}`, taskRecord.TaskStageCheck.Id), 101 "taskStageCheck": fmt.Sprintf(`{"id":"%d"}`, taskRecord.TaskStageCheck.Id),
@@ -108,7 +108,10 @@ func isNotWarnFlag(transactionContext application.TransactionContext, taskData * @@ -108,7 +108,10 @@ func isNotWarnFlag(transactionContext application.TransactionContext, taskData *
108 } 108 }
109 oldAnomaly[0].IsLast = 2 109 oldAnomaly[0].IsLast = 2
110 err = taskAnomalyRepo.Save(oldAnomaly[0]) 110 err = taskAnomalyRepo.Save(oldAnomaly[0])
111 - return fmt.Errorf("取消里程碑异常:%s", err) 111 + if err != nil {
  112 + return fmt.Errorf("取消里程碑异常:%s", err)
  113 + }
  114 + return nil
112 } 115 }
113 116
114 // 处理里程碑异常的情况 117 // 处理里程碑异常的情况
@@ -123,7 +126,7 @@ func isWarnFlag(transactionContext application.TransactionContext, taskData *dom @@ -123,7 +126,7 @@ func isWarnFlag(transactionContext application.TransactionContext, taskData *dom
123 126
124 _, oldAnomaly, err := taskAnomalyRepo.Find(map[string]interface{}{ 127 _, oldAnomaly, err := taskAnomalyRepo.Find(map[string]interface{}{
125 "isLast": 1, 128 "isLast": 1,
126 - "category": 2, 129 + "category": domain.AnomalyCategoryType1,
127 "limit": 1, 130 "limit": 1,
128 "taskId": taskData.Id, 131 "taskId": taskData.Id,
129 "taskStageCheck": fmt.Sprintf(`{"id":"%d"}`, taskRecord.TaskStageCheck.Id), 132 "taskStageCheck": fmt.Sprintf(`{"id":"%d"}`, taskRecord.TaskStageCheck.Id),
@@ -133,13 +136,13 @@ func isWarnFlag(transactionContext application.TransactionContext, taskData *dom @@ -133,13 +136,13 @@ func isWarnFlag(transactionContext application.TransactionContext, taskData *dom
133 } 136 }
134 137
135 anomalyDataTmp := domain.TaskAnomaly{ 138 anomalyDataTmp := domain.TaskAnomaly{
136 - Id: taskData.Id, 139 + Id: 0,
137 CreatedAt: time.Now(), 140 CreatedAt: time.Now(),
138 UpdatedAt: time.Now(), 141 UpdatedAt: time.Now(),
139 CompanyId: taskData.CompanyId, 142 CompanyId: taskData.CompanyId,
140 TaskId: taskData.Id, 143 TaskId: taskData.Id,
141 TaskRecordId: taskRecord.Id, 144 TaskRecordId: taskRecord.Id,
142 - Category: 1, 145 + Category: domain.AnomalyCategoryType1,
143 CurrentStage: taskData.CurrentStage, 146 CurrentStage: taskData.CurrentStage,
144 LastStage: taskData.LastStage, 147 LastStage: taskData.LastStage,
145 TaskStageCheck: taskRecord.TaskStageCheck, 148 TaskStageCheck: taskRecord.TaskStageCheck,
@@ -150,7 +153,7 @@ func isWarnFlag(transactionContext application.TransactionContext, taskData *dom @@ -150,7 +153,7 @@ func isWarnFlag(transactionContext application.TransactionContext, taskData *dom
150 RecordBegin: taskRecord.CreatedAt.Unix(), 153 RecordBegin: taskRecord.CreatedAt.Unix(),
151 NoticeWho: []map[string]string{}, 154 NoticeWho: []map[string]string{},
152 Marks: map[string]string{ 155 Marks: map[string]string{
153 - "a": "", "b": "", "c": "", "d": "", 156 + "a": "去更新", "b": "去反馈", "c": "找上级", "d": "去辅导",
154 }, 157 },
155 } 158 }
156 if len(oldAnomaly) > 0 { 159 if len(oldAnomaly) > 0 {
@@ -162,6 +165,7 @@ func isWarnFlag(transactionContext application.TransactionContext, taskData *dom @@ -162,6 +165,7 @@ func isWarnFlag(transactionContext application.TransactionContext, taskData *dom
162 return fmt.Errorf("更新里程碑异常记录:%s", err) 165 return fmt.Errorf("更新里程碑异常记录:%s", err)
163 } 166 }
164 } 167 }
  168 + _ = anomalyDataTmp.AnomalyDesc()
165 // 异常就通知自己和上级 169 // 异常就通知自己和上级
166 //获取任务Leader的数据 170 //获取任务Leader的数据
167 _, useList, err := userRepo.Find(map[string]interface{}{"id": taskData.Leader.Id, "limit": 1}) 171 _, useList, err := userRepo.Find(map[string]interface{}{"id": taskData.Leader.Id, "limit": 1})
@@ -199,7 +203,7 @@ func isNotAssistFlag(transactionContext application.TransactionContext, taskData @@ -199,7 +203,7 @@ func isNotAssistFlag(transactionContext application.TransactionContext, taskData
199 203
200 _, oldAnomaly, err := taskAnomalyRepo.Find(map[string]interface{}{ 204 _, oldAnomaly, err := taskAnomalyRepo.Find(map[string]interface{}{
201 "isLast": 1, 205 "isLast": 1,
202 - "category": 3, 206 + "category": domain.AnomalyCategoryType3,
203 "limit": 1, 207 "limit": 1,
204 "taskId": taskData.Id, 208 "taskId": taskData.Id,
205 }) 209 })
@@ -211,7 +215,10 @@ func isNotAssistFlag(transactionContext application.TransactionContext, taskData @@ -211,7 +215,10 @@ func isNotAssistFlag(transactionContext application.TransactionContext, taskData
211 } 215 }
212 oldAnomaly[0].IsLast = 2 216 oldAnomaly[0].IsLast = 2
213 err = taskAnomalyRepo.Save(oldAnomaly[0]) 217 err = taskAnomalyRepo.Save(oldAnomaly[0])
214 - return fmt.Errorf("取消辅导异常:%s", err) 218 + if err != nil {
  219 + return fmt.Errorf("取消辅导异常:%s", err)
  220 + }
  221 + return nil
215 } 222 }
216 223
217 // 处理辅导异常的情况 224 // 处理辅导异常的情况
@@ -226,7 +233,7 @@ func isAssistFlag(transactionContext application.TransactionContext, taskData *d @@ -226,7 +233,7 @@ func isAssistFlag(transactionContext application.TransactionContext, taskData *d
226 233
227 _, oldAnomaly, err := taskAnomalyRepo.Find(map[string]interface{}{ 234 _, oldAnomaly, err := taskAnomalyRepo.Find(map[string]interface{}{
228 "isLast": 1, 235 "isLast": 1,
229 - "category": 3, 236 + "category": domain.AnomalyCategoryType3,
230 "limit": 1, 237 "limit": 1,
231 "taskId": taskData.Id, 238 "taskId": taskData.Id,
232 }) 239 })
@@ -235,12 +242,12 @@ func isAssistFlag(transactionContext application.TransactionContext, taskData *d @@ -235,12 +242,12 @@ func isAssistFlag(transactionContext application.TransactionContext, taskData *d
235 } 242 }
236 // 辅导异常通知该条任务负责人的上级;辅导异常超过N天,通知任务负责人的上上级 243 // 辅导异常通知该条任务负责人的上级;辅导异常超过N天,通知任务负责人的上上级
237 anomalyDataTmp := domain.TaskAnomaly{ 244 anomalyDataTmp := domain.TaskAnomaly{
238 - Id: taskData.Id, 245 + Id: 0,
239 CreatedAt: time.Now(), 246 CreatedAt: time.Now(),
240 UpdatedAt: time.Now(), 247 UpdatedAt: time.Now(),
241 CompanyId: taskData.CompanyId, 248 CompanyId: taskData.CompanyId,
242 TaskId: taskData.Id, 249 TaskId: taskData.Id,
243 - Category: 3, 250 + Category: domain.AnomalyCategoryType3,
244 CurrentStage: taskData.CurrentStage, 251 CurrentStage: taskData.CurrentStage,
245 LastStage: taskData.LastStage, 252 LastStage: taskData.LastStage,
246 TaskStageCheck: taskRecord.TaskStageCheck, 253 TaskStageCheck: taskRecord.TaskStageCheck,
@@ -251,7 +258,7 @@ func isAssistFlag(transactionContext application.TransactionContext, taskData *d @@ -251,7 +258,7 @@ func isAssistFlag(transactionContext application.TransactionContext, taskData *d
251 RecordBegin: taskRecord.CreatedAt.Unix(), 258 RecordBegin: taskRecord.CreatedAt.Unix(),
252 NoticeWho: []map[string]string{}, 259 NoticeWho: []map[string]string{},
253 Marks: map[string]string{ 260 Marks: map[string]string{
254 - "a": "", "b": "", "c": "", "d": "", 261 + "a": "去更新", "b": "去反馈", "c": "找上级", "d": "去辅导",
255 }, 262 },
256 } 263 }
257 264
@@ -263,6 +270,7 @@ func isAssistFlag(transactionContext application.TransactionContext, taskData *d @@ -263,6 +270,7 @@ func isAssistFlag(transactionContext application.TransactionContext, taskData *d
263 return fmt.Errorf("更新里程碑异常记录:%s", err) 270 return fmt.Errorf("更新里程碑异常记录:%s", err)
264 } 271 }
265 } 272 }
  273 + _ = anomalyDataTmp.AnomalyDesc()
266 //获取任务Leader的数据 274 //获取任务Leader的数据
267 _, useList, err := userRepo.Find(map[string]interface{}{"id": taskData.Leader.Id, "limit": 1}) 275 _, useList, err := userRepo.Find(map[string]interface{}{"id": taskData.Leader.Id, "limit": 1})
268 if err != nil { 276 if err != nil {
@@ -311,7 +319,7 @@ func isNotAssessFlag(transactionContext application.TransactionContext, taskData @@ -311,7 +319,7 @@ func isNotAssessFlag(transactionContext application.TransactionContext, taskData
311 319
312 _, oldAnomaly, err := taskAnomalyRepo.Find(map[string]interface{}{ 320 _, oldAnomaly, err := taskAnomalyRepo.Find(map[string]interface{}{
313 "isLast": 1, 321 "isLast": 1,
314 - "category": 3, 322 + "category": domain.AnomalyCategoryType2,
315 "limit": 1, 323 "limit": 1,
316 "taskId": taskData.Id, 324 "taskId": taskData.Id,
317 }) 325 })
@@ -323,8 +331,10 @@ func isNotAssessFlag(transactionContext application.TransactionContext, taskData @@ -323,8 +331,10 @@ func isNotAssessFlag(transactionContext application.TransactionContext, taskData
323 } 331 }
324 oldAnomaly[0].IsLast = 2 332 oldAnomaly[0].IsLast = 2
325 err = taskAnomalyRepo.Save(oldAnomaly[0]) 333 err = taskAnomalyRepo.Save(oldAnomaly[0])
326 - return fmt.Errorf("取消辅导异常:%s", err)  
327 - 334 + if err != nil {
  335 + return fmt.Errorf("取消辅导异常:%s", err)
  336 + }
  337 + return nil
328 } 338 }
329 339
330 // 处理反馈异常的情况 340 // 处理反馈异常的情况
@@ -337,7 +347,7 @@ func isAssessFlag(transactionContext application.TransactionContext, taskData *d @@ -337,7 +347,7 @@ func isAssessFlag(transactionContext application.TransactionContext, taskData *d
337 }) 347 })
338 _, oldAnomaly, err := taskAnomalyRepo.Find(map[string]interface{}{ 348 _, oldAnomaly, err := taskAnomalyRepo.Find(map[string]interface{}{
339 "isLast": 1, 349 "isLast": 1,
340 - "category": 2, 350 + "category": domain.AnomalyCategoryType2,
341 "limit": 1, 351 "limit": 1,
342 "taskId": taskData.Id, 352 "taskId": taskData.Id,
343 }) 353 })
@@ -346,12 +356,12 @@ func isAssessFlag(transactionContext application.TransactionContext, taskData *d @@ -346,12 +356,12 @@ func isAssessFlag(transactionContext application.TransactionContext, taskData *d
346 } 356 }
347 // 357 //
348 anomalyDataTmp := domain.TaskAnomaly{ 358 anomalyDataTmp := domain.TaskAnomaly{
349 - Id: taskData.Id, 359 + Id: 0,
350 CreatedAt: time.Now(), 360 CreatedAt: time.Now(),
351 UpdatedAt: time.Now(), 361 UpdatedAt: time.Now(),
352 CompanyId: taskData.CompanyId, 362 CompanyId: taskData.CompanyId,
353 TaskId: taskData.Id, 363 TaskId: taskData.Id,
354 - Category: 3, 364 + Category: domain.AnomalyCategoryType2,
355 CurrentStage: taskData.CurrentStage, 365 CurrentStage: taskData.CurrentStage,
356 LastStage: taskData.LastStage, 366 LastStage: taskData.LastStage,
357 TaskStageCheck: taskRecord.TaskStageCheck, 367 TaskStageCheck: taskRecord.TaskStageCheck,
@@ -362,7 +372,7 @@ func isAssessFlag(transactionContext application.TransactionContext, taskData *d @@ -362,7 +372,7 @@ func isAssessFlag(transactionContext application.TransactionContext, taskData *d
362 RecordBegin: taskRecord.CreatedAt.Unix(), 372 RecordBegin: taskRecord.CreatedAt.Unix(),
363 NoticeWho: []map[string]string{}, 373 NoticeWho: []map[string]string{},
364 Marks: map[string]string{ 374 Marks: map[string]string{
365 - "a": "", "b": "", "c": "", "d": "", 375 + "a": "去更新", "b": "去反馈", "c": "找上级", "d": "去辅导",
366 }, 376 },
367 } 377 }
368 if len(oldAnomaly) > 0 { 378 if len(oldAnomaly) > 0 {
@@ -373,6 +383,7 @@ func isAssessFlag(transactionContext application.TransactionContext, taskData *d @@ -373,6 +383,7 @@ func isAssessFlag(transactionContext application.TransactionContext, taskData *d
373 return fmt.Errorf("更新里程碑异常记录:%s", err) 383 return fmt.Errorf("更新里程碑异常记录:%s", err)
374 } 384 }
375 } 385 }
  386 + _ = anomalyDataTmp.AnomalyDesc()
376 // 2天未反馈通知被评估人自己;3天通知上级 387 // 2天未反馈通知被评估人自己;3天通知上级
377 // 获取任务Leader的数据 388 // 获取任务Leader的数据
378 _, useList, err := userRepo.Find(map[string]interface{}{"id": taskData.Leader.Id, "limit": 1}) 389 _, useList, err := userRepo.Find(map[string]interface{}{"id": taskData.Leader.Id, "limit": 1})
@@ -1141,7 +1141,20 @@ func (srv TaskService) ListTask3(param *command.SearchTaskCommand) (map[string]i @@ -1141,7 +1141,20 @@ func (srv TaskService) ListTask3(param *command.SearchTaskCommand) (map[string]i
1141 if err != nil { 1141 if err != nil {
1142 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "统计任务反馈异常总数"+err.Error()) 1142 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "统计任务反馈异常总数"+err.Error())
1143 } 1143 }
1144 - 1144 + var taskAnomalyList []*domain.TaskAnomaly
  1145 + //获取异常的任务反馈记录
  1146 + taskAnomalyRepo := factory.CreateTaskAnomalyRepository(map[string]interface{}{
  1147 + "transactionContext": transactionContext,
  1148 + })
  1149 + for _, val := range taskListData {
  1150 + _, listData, err := taskAnomalyRepo.Find(map[string]interface{}{
  1151 + "taskId": val.TaskId,
  1152 + "is_last": 1,
  1153 + })
  1154 + if err == nil {
  1155 + taskAnomalyList = append(taskAnomalyList, listData...)
  1156 + }
  1157 + }
1145 taskResult := []*adapter.TaskItem{} 1158 taskResult := []*adapter.TaskItem{}
1146 taskStageRepo := factory.CreateTaskStageRepository(map[string]interface{}{ 1159 taskStageRepo := factory.CreateTaskStageRepository(map[string]interface{}{
1147 "transactionContext": transactionContext, 1160 "transactionContext": transactionContext,
@@ -1177,6 +1190,8 @@ func (srv TaskService) ListTask3(param *command.SearchTaskCommand) (map[string]i @@ -1177,6 +1190,8 @@ func (srv TaskService) ListTask3(param *command.SearchTaskCommand) (map[string]i
1177 RealCompletedAt: "", 1190 RealCompletedAt: "",
1178 IsRef: false, 1191 IsRef: false,
1179 }, 1192 },
  1193 + AnomalyDesc: []string{},
  1194 + Marks: map[string]string{},
1180 } 1195 }
1181 if val.LastStage.RealCompletedAt > 0 { 1196 if val.LastStage.RealCompletedAt > 0 {
1182 tk.LastStage.RealCompletedAt = time.Unix(int64(val.LastStage.RealCompletedAt), 0).Local().Format("2006-01-02") 1197 tk.LastStage.RealCompletedAt = time.Unix(int64(val.LastStage.RealCompletedAt), 0).Local().Format("2006-01-02")
@@ -1221,6 +1236,28 @@ func (srv TaskService) ListTask3(param *command.SearchTaskCommand) (map[string]i @@ -1221,6 +1236,28 @@ func (srv TaskService) ListTask3(param *command.SearchTaskCommand) (map[string]i
1221 } 1236 }
1222 } 1237 }
1223 tk.GenStatusDescript() 1238 tk.GenStatusDescript()
  1239 + for _, val := range taskAnomalyList {
  1240 + if tk.Id != val.TaskId {
  1241 + continue
  1242 + }
  1243 + if val.Marks == nil {
  1244 + val.Marks = map[string]string{}
  1245 + }
  1246 + r := val.Remark + ",该条异常已通知"
  1247 + for _, val2 := range val.NoticeWho {
  1248 + r += val2["name"] + " "
  1249 + }
  1250 + tk.AnomalyDesc = append(tk.AnomalyDesc, r)
  1251 + switch val.Category {
  1252 + case domain.AnomalyCategoryType1:
  1253 + tk.Marks["a"] = val.Marks["a"]
  1254 + tk.Marks["c"] = val.Marks["c"]
  1255 + case domain.AnomalyCategoryType2:
  1256 + tk.Marks["b"] = val.Marks["b"]
  1257 + case domain.AnomalyCategoryType3:
  1258 + tk.Marks["d"] = val.Marks["d"]
  1259 + }
  1260 + }
1224 taskResult = append(taskResult, &tk) 1261 taskResult = append(taskResult, &tk)
1225 } 1262 }
1226 result := tool_funs.SimpleWrapGridMap(int64(taskCount), taskResult) 1263 result := tool_funs.SimpleWrapGridMap(int64(taskCount), taskResult)
@@ -392,7 +392,61 @@ func (srv TaskService) ListTaskAnomaly3(param *command.ListTaskAnomalyCommand) ( @@ -392,7 +392,61 @@ func (srv TaskService) ListTaskAnomaly3(param *command.ListTaskAnomalyCommand) (
392 return result, nil 392 return result, nil
393 } 393 }
394 394
  395 +func (srv TaskService) UserSelect(param *command.UserSelectCommand) []adapter.UserItem {
  396 + transactionContext, err := factory.CreateTransactionContext(nil)
  397 + if err != nil {
  398 + return nil
  399 + }
  400 + if err := transactionContext.StartTransaction(); err != nil {
  401 + return nil
  402 + }
  403 + defer func() {
  404 + _ = transactionContext.RollbackTransaction()
  405 + }()
  406 +
  407 + if param.SubLevel == 0 {
  408 + userRepo := factory.CreateUserRepository(map[string]interface{}{
  409 + "transactionContext": transactionContext,
  410 + })
  411 + _, userList, err := userRepo.Find(map[string]interface{}{
  412 + "companyId": param.CompanyId,
  413 + })
  414 + selectList := []adapter.UserItem{}
  415 + if err != nil {
  416 + return selectList
  417 + }
  418 + for _, val := range userList {
  419 + selectList = append(selectList, adapter.UserItem{
  420 + Id: val.Id,
  421 + Name: val.Name,
  422 + })
  423 + }
  424 + return selectList
  425 + }
  426 +
  427 + userDao := dao.NewUserDao(map[string]interface{}{
  428 + "transactionContext": transactionContext,
  429 + })
  430 + userList, err := userDao.AllChildUser(param.UserId)
  431 + selectList := []adapter.UserItem{}
  432 + if err != nil {
  433 + return selectList
  434 + }
  435 + for _, val := range userList {
  436 + selectList = append(selectList, adapter.UserItem{
  437 + Id: int64(val.Id),
  438 + Name: val.Name,
  439 + Level: val.Level,
  440 + })
  441 + }
  442 + if err := transactionContext.CommitTransaction(); err != nil {
  443 + return selectList
  444 + }
  445 + return selectList
  446 +}
  447 +
395 // 对异常记录的操作标记 448 // 对异常记录的操作标记
396 -func (srv TaskService) MarkTaskAnomaly() error {  
397 - return nil 449 +func (srv TaskService) MarkTaskAnomaly(param *command.MarkTaskAnomalyCommand) (map[string]string, error) {
  450 +
  451 + return nil, nil
398 } 452 }
@@ -8,6 +8,12 @@ import ( @@ -8,6 +8,12 @@ import (
8 "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/utils/xtime" 8 "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/utils/xtime"
9 ) 9 )
10 10
  11 +const (
  12 + AnomalyCategoryType1 int = 1 //里程碑异常
  13 + AnomalyCategoryType2 int = 2 //反馈异常
  14 + AnomalyCategoryType3 int = 3 //辅导异常
  15 +)
  16 +
11 // 任务的异常记录 17 // 任务的异常记录
12 type TaskAnomaly struct { 18 type TaskAnomaly struct {
13 Id int 19 Id int
@@ -16,7 +22,7 @@ type TaskAnomaly struct { @@ -16,7 +22,7 @@ type TaskAnomaly struct {
16 CompanyId int `json:"companyId,string"` 22 CompanyId int `json:"companyId,string"`
17 TaskId int `json:"taskId,string"` // 任务id 23 TaskId int `json:"taskId,string"` // 任务id
18 TaskRecordId int `json:"taskRecordId,string"` // 任务反馈的进度 24 TaskRecordId int `json:"taskRecordId,string"` // 任务反馈的进度
19 - Category int `json:"category"` // 异常记录的分类 1 里程碑异常;2反馈异常 ;3 辅导异常 25 + Category int `json:"category"` // 异常记录的分类 1里程碑异常;2反馈异常;3 辅导异常
20 CurrentStage TaskStage `json:"currentStage"` // 计划进度的里程碑 26 CurrentStage TaskStage `json:"currentStage"` // 计划进度的里程碑
21 LastStage TaskStage `json:"lastStage"` // 实际进度完成的里程碑 27 LastStage TaskStage `json:"lastStage"` // 实际进度完成的里程碑
22 TaskStageCheck TaskStage `json:"taskStageCheck"` // 当天任务反馈操作里程碑记录 28 TaskStageCheck TaskStage `json:"taskStageCheck"` // 当天任务反馈操作里程碑记录
@@ -27,6 +33,7 @@ type TaskAnomaly struct { @@ -27,6 +33,7 @@ type TaskAnomaly struct {
27 RecordBegin int64 `json:"recordBegin"` // 异常记录的开始时间 33 RecordBegin int64 `json:"recordBegin"` // 异常记录的开始时间
28 NoticeWho []map[string]string `json:"noticeWho"` // 异常记录消息通知的人 34 NoticeWho []map[string]string `json:"noticeWho"` // 异常记录消息通知的人
29 Marks map[string]string `json:"marks"` // 已经操作的标记 35 Marks map[string]string `json:"marks"` // 已经操作的标记
  36 + Remark string `json:"remark"`
30 } 37 }
31 38
32 // 已点击“去更新” 39 // 已点击“去更新”
@@ -57,7 +64,7 @@ func (t *TaskAnomaly) SetNoticeWho(u *User) { @@ -57,7 +64,7 @@ func (t *TaskAnomaly) SetNoticeWho(u *User) {
57 64
58 // 异常状况描述 65 // 异常状况描述
59 func (t *TaskAnomaly) AnomalyDesc() (str string) { 66 func (t *TaskAnomaly) AnomalyDesc() (str string) {
60 - nowTime := time.Now() 67 + nowTime := t.CreatedAt
61 switch t.Category { 68 switch t.Category {
62 case 1: 69 case 1:
63 //里程碑异常 70 //里程碑异常
@@ -101,6 +108,7 @@ func (t *TaskAnomaly) AnomalyDesc() (str string) { @@ -101,6 +108,7 @@ func (t *TaskAnomaly) AnomalyDesc() (str string) {
101 108
102 } 109 }
103 } 110 }
  111 + t.Remark = str
104 return str 112 return str
105 } 113 }
106 114
@@ -50,7 +50,7 @@ type TaskRecordRepository interface { @@ -50,7 +50,7 @@ type TaskRecordRepository interface {
50 // 是否是辅导异常 50 // 是否是辅导异常
51 func (r *TaskRecord) IsAssistAnomaly() bool { 51 func (r *TaskRecord) IsAssistAnomaly() bool {
52 r.AssistContent = strings.TrimSpace(r.AssistContent) 52 r.AssistContent = strings.TrimSpace(r.AssistContent)
53 - if r.AssistLevel == AssistLevel1 || r.AssistContent == "无" { 53 + if r.AssistLevel == AssistLevel1 || r.AssistContent == "无" || len(r.AssistContent) == 0 {
54 return true 54 return true
55 } 55 }
56 return false 56 return false
@@ -9,11 +9,12 @@ import ( @@ -9,11 +9,12 @@ import (
9 // 任务的异常记录 9 // 任务的异常记录
10 type TaskAnomaly struct { 10 type TaskAnomaly struct {
11 tableName struct{} `comment:"任务的异常记录" pg:"task_anomaly"` 11 tableName struct{} `comment:"任务的异常记录" pg:"task_anomaly"`
12 - Id int `pg:"id"` // 12 + Id int `pg:"id,pk"` //
13 CreatedAt time.Time `pg:"created_at"` // 13 CreatedAt time.Time `pg:"created_at"` //
14 UpdatedAt time.Time `pg:"updated_at"` // 14 UpdatedAt time.Time `pg:"updated_at"` //
15 CompanyId int `pg:"company_id"` // 15 CompanyId int `pg:"company_id"` //
16 TaskId int `pg:"task_id"` // 任务id 16 TaskId int `pg:"task_id"` // 任务id
  17 + TaskRecordId int `pg:"task_record_id"` //
17 Category int `pg:"category"` // 异常任务的分类 18 Category int `pg:"category"` // 异常任务的分类
18 CurrentStage domain.TaskStage `pg:"current_stage"` // 计划完成的里程碑 19 CurrentStage domain.TaskStage `pg:"current_stage"` // 计划完成的里程碑
19 LastStage domain.TaskStage `pg:"last_stage"` // 实际完成的里程碑 20 LastStage domain.TaskStage `pg:"last_stage"` // 实际完成的里程碑
@@ -25,4 +26,5 @@ type TaskAnomaly struct { @@ -25,4 +26,5 @@ type TaskAnomaly struct {
25 RecordBegin int64 `pg:"record_begin"` // 异常记录的开始时间 26 RecordBegin int64 `pg:"record_begin"` // 异常记录的开始时间
26 NoticeWho []map[string]string `pg:"notice_who"` // 异常记录消息通知的人 27 NoticeWho []map[string]string `pg:"notice_who"` // 异常记录消息通知的人
27 Marks map[string]string `pg:"marks"` // 已经操作的标记 28 Marks map[string]string `pg:"marks"` // 已经操作的标记
  29 + Remark string `pg:"remark,use_zero"`
28 } 30 }
@@ -30,6 +30,7 @@ func (repo *TaskAnomalyRepository) TransformToDomain(d *models.TaskAnomaly) *dom @@ -30,6 +30,7 @@ func (repo *TaskAnomalyRepository) TransformToDomain(d *models.TaskAnomaly) *dom
30 UpdatedAt: d.UpdatedAt, 30 UpdatedAt: d.UpdatedAt,
31 CompanyId: d.CompanyId, 31 CompanyId: d.CompanyId,
32 TaskId: d.TaskId, 32 TaskId: d.TaskId,
  33 + TaskRecordId: d.TaskRecordId,
33 Category: d.Category, 34 Category: d.Category,
34 CurrentStage: d.CurrentStage, 35 CurrentStage: d.CurrentStage,
35 LastStage: d.LastStage, 36 LastStage: d.LastStage,
@@ -41,6 +42,7 @@ func (repo *TaskAnomalyRepository) TransformToDomain(d *models.TaskAnomaly) *dom @@ -41,6 +42,7 @@ func (repo *TaskAnomalyRepository) TransformToDomain(d *models.TaskAnomaly) *dom
41 RecordBegin: d.RecordBegin, 42 RecordBegin: d.RecordBegin,
42 NoticeWho: d.NoticeWho, 43 NoticeWho: d.NoticeWho,
43 Marks: d.Marks, 44 Marks: d.Marks,
  45 + Remark: d.Remark,
44 } 46 }
45 } 47 }
46 48
@@ -51,6 +53,7 @@ func (repo *TaskAnomalyRepository) Save(param *domain.TaskAnomaly) error { @@ -51,6 +53,7 @@ func (repo *TaskAnomalyRepository) Save(param *domain.TaskAnomaly) error {
51 UpdatedAt: param.UpdatedAt, 53 UpdatedAt: param.UpdatedAt,
52 CompanyId: param.CompanyId, 54 CompanyId: param.CompanyId,
53 TaskId: param.TaskId, 55 TaskId: param.TaskId,
  56 + TaskRecordId: param.TaskRecordId,
54 Category: param.Category, 57 Category: param.Category,
55 CurrentStage: param.CurrentStage, 58 CurrentStage: param.CurrentStage,
56 LastStage: param.LastStage, 59 LastStage: param.LastStage,
@@ -62,6 +65,7 @@ func (repo *TaskAnomalyRepository) Save(param *domain.TaskAnomaly) error { @@ -62,6 +65,7 @@ func (repo *TaskAnomalyRepository) Save(param *domain.TaskAnomaly) error {
62 RecordBegin: param.RecordBegin, 65 RecordBegin: param.RecordBegin,
63 NoticeWho: param.NoticeWho, 66 NoticeWho: param.NoticeWho,
64 Marks: param.Marks, 67 Marks: param.Marks,
  68 + Remark: param.Remark,
65 } 69 }
66 db := repo.transactionContext.PgTx 70 db := repo.transactionContext.PgTx
67 if m.Id == 0 { 71 if m.Id == 0 {
@@ -301,3 +301,37 @@ func (c *TaskController) TaskAnomalyList2() { @@ -301,3 +301,37 @@ func (c *TaskController) TaskAnomalyList2() {
301 resp, err := srv.ListTaskAnomaly2(paramReq) 301 resp, err := srv.ListTaskAnomaly2(paramReq)
302 c.Response(resp, err) 302 c.Response(resp, err)
303 } 303 }
  304 +
  305 +// UserSelect 人员下拉选择
  306 +func (c *TaskController) UserSelect() {
  307 + srv := service.NewTaskService()
  308 + paramReq := &command.UserSelectCommand{}
  309 + err := c.BindJSON(paramReq)
  310 + if err != nil {
  311 + e := application.ThrowError(application.ARG_ERROR, "json 解析错误"+err.Error())
  312 + c.Response(nil, e)
  313 + return
  314 + }
  315 + userReq := middlewares.GetUser(c.Ctx)
  316 + paramReq.CompanyId = int(userReq.CompanyId)
  317 + paramReq.UserId = int(userReq.UserId)
  318 + resp := srv.UserSelect(paramReq)
  319 + c.Response(resp, nil)
  320 +}
  321 +
  322 +// 点击操作
  323 +func (c *TaskController) TaskAnomalyMark() {
  324 + srv := service.NewTaskService()
  325 + paramReq := &command.MarkTaskAnomalyCommand{}
  326 + err := c.BindJSON(paramReq)
  327 + if err != nil {
  328 + e := application.ThrowError(application.ARG_ERROR, "json 解析错误"+err.Error())
  329 + c.Response(nil, e)
  330 + return
  331 + }
  332 + userReq := middlewares.GetUser(c.Ctx)
  333 + paramReq.CompanyId = int(userReq.CompanyId)
  334 + resp, err := srv.MarkTaskAnomaly(paramReq)
  335 + c.Response(resp, err)
  336 +
  337 +}
@@ -36,9 +36,11 @@ func init() { @@ -36,9 +36,11 @@ func init() {
36 web.AddNamespace(taskFontNS) 36 web.AddNamespace(taskFontNS)
37 taskAnomalyNS := web.NewNamespace("/v1/font", 37 taskAnomalyNS := web.NewNamespace("/v1/font",
38 web.NSBefore(filters.AllowCors(), middlewares.CheckFontToken()), 38 web.NSBefore(filters.AllowCors(), middlewares.CheckFontToken()),
39 - web.NSCtrlPost("/task_anomaly/my_task", (*controllers.TaskController).TaskAnomalyList1),  
40 - web.NSCtrlPost("/task_anomaly/my_relation", (*controllers.TaskController).TaskAnomalyList3),  
41 - web.NSCtrlPost("/task_anomaly/my_sub", (*controllers.TaskController).TaskAnomalyList2), 39 + web.NSCtrlPost("/task_anomaly/my_task", (*controllers.TaskController).TaskAnomalyList1), //我负责的任务
  40 + web.NSCtrlPost("/task_anomaly/my_relation", (*controllers.TaskController).TaskAnomalyList3), //和我有关的任务
  41 + web.NSCtrlPost("/task_anomaly/my_sub", (*controllers.TaskController).TaskAnomalyList2), //我的下级负责的任务
  42 + web.NSCtrlPost("/task_anomaly/select/user", (*controllers.TaskController).UserSelect), //人员下拉选择列表
  43 + web.NSCtrlPost("/task_anomaly/marks", (*controllers.TaskController).TaskAnomalyMark),
42 ) 44 )
43 web.AddNamespace(taskAnomalyNS) 45 web.AddNamespace(taskAnomalyNS)
44 } 46 }