作者 tangxvhui

添加, 取消关注的任务列表

  1 +package command
  2 +
  3 +type CancelIgnoreCommand struct {
  4 + TaskId int `json:"taskId,string"`
  5 + UserId int `json:"-"`
  6 + CompanyId int `json:"-"`
  7 +}
@@ -8,6 +8,6 @@ type SearchTaskCommand struct { @@ -8,6 +8,6 @@ type SearchTaskCommand struct {
8 OnlyMy bool `json:"onlyMy"` //只查看我负责的任务 8 OnlyMy bool `json:"onlyMy"` //只查看我负责的任务
9 SearchWord string `json:"searchWord"` 9 SearchWord string `json:"searchWord"`
10 // TaskName string `json:"taskName"` //任务名称 10 // TaskName string `json:"taskName"` //任务名称
11 - // LevelName string `json:"levelName"` //优先级 11 + LevelName string `json:"levelName"` //任务类型
12 // LeaderName string `json:"leaderId"` //任务负责人id 12 // LeaderName string `json:"leaderId"` //任务负责人id
13 } 13 }
@@ -1014,6 +1014,7 @@ func (srv TaskService) ListTask3(param *command.SearchTaskCommand) (map[string]i @@ -1014,6 +1014,7 @@ func (srv TaskService) ListTask3(param *command.SearchTaskCommand) (map[string]i
1014 CompanyId: param.CompanyId, 1014 CompanyId: param.CompanyId,
1015 OnlyMy: param.OnlyMy, 1015 OnlyMy: param.OnlyMy,
1016 SearchWord: param.SearchWord, 1016 SearchWord: param.SearchWord,
  1017 + LevelName: param.LevelName,
1017 } 1018 }
1018 1019
1019 taskDao := dao.NewTaskDao(map[string]interface{}{ 1020 taskDao := dao.NewTaskDao(map[string]interface{}{
@@ -1029,7 +1030,7 @@ func (srv TaskService) ListTask3(param *command.SearchTaskCommand) (map[string]i @@ -1029,7 +1030,7 @@ func (srv TaskService) ListTask3(param *command.SearchTaskCommand) (map[string]i
1029 if err != nil { 1030 if err != nil {
1030 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "统计任务总数"+err.Error()) 1031 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "统计任务总数"+err.Error())
1031 } 1032 }
1032 - //里程碑异常s 1033 + //里程碑异常
1033 taskStageAnomalyCnt, err := taskDao.CountTaskStageAnomalyNotHrbp(condition) 1034 taskStageAnomalyCnt, err := taskDao.CountTaskStageAnomalyNotHrbp(condition)
1034 if err != nil { 1035 if err != nil {
1035 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "统计异常的任务里程碑总数"+err.Error()) 1036 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "统计异常的任务里程碑总数"+err.Error())
@@ -1160,6 +1161,7 @@ func (srv TaskService) listTask3ForHrbp(param *command.SearchTaskCommand) (map[s @@ -1160,6 +1161,7 @@ func (srv TaskService) listTask3ForHrbp(param *command.SearchTaskCommand) (map[s
1160 CompanyId: param.CompanyId, 1161 CompanyId: param.CompanyId,
1161 OnlyMy: param.OnlyMy, 1162 OnlyMy: param.OnlyMy,
1162 SearchWord: param.SearchWord, 1163 SearchWord: param.SearchWord,
  1164 + LevelName: param.LevelName,
1163 } 1165 }
1164 1166
1165 taskDao := dao.NewTaskDao(map[string]interface{}{ 1167 taskDao := dao.NewTaskDao(map[string]interface{}{
@@ -1309,3 +1311,174 @@ func (srv TaskService) ListTaskLevel(companyId int) (map[string]interface{}, err @@ -1309,3 +1311,174 @@ func (srv TaskService) ListTaskLevel(companyId int) (map[string]interface{}, err
1309 } 1311 }
1310 return result, nil 1312 return result, nil
1311 } 1313 }
  1314 +
  1315 +// 取消关注的任务列表
  1316 +func (srv *TaskService) ListTaskIgnore(param *command.SearchTaskCommand) (result map[string]interface{}, err error) {
  1317 + transactionContext, err := factory.CreateTransactionContext(nil)
  1318 + if err != nil {
  1319 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  1320 + }
  1321 + if err := transactionContext.StartTransaction(); err != nil {
  1322 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  1323 + }
  1324 + defer func() {
  1325 + _ = transactionContext.RollbackTransaction()
  1326 + }()
  1327 + var limit = 20
  1328 + var offset = 0
  1329 + if param.PageSize > 0 {
  1330 + limit = param.PageSize
  1331 + if param.PageNumber > 0 {
  1332 + offset = (param.PageNumber - 1) * param.PageSize
  1333 + }
  1334 + }
  1335 + param.SearchWord = strings.TrimSpace(param.SearchWord)
  1336 + if len(param.SearchWord) > 0 {
  1337 + param.SearchWord = "%" + param.SearchWord + "%"
  1338 + }
  1339 + condition := dao.ListTaskCondition{
  1340 + Limit: limit,
  1341 + Offset: offset,
  1342 + UserId: param.UserId,
  1343 + CompanyId: param.CompanyId,
  1344 + OnlyMy: param.OnlyMy,
  1345 + SearchWord: param.SearchWord,
  1346 + LevelName: param.LevelName,
  1347 + }
  1348 +
  1349 + taskDao := dao.NewTaskDao(map[string]interface{}{
  1350 + "transactionContext": transactionContext,
  1351 + })
  1352 + //任务列表数据
  1353 + taskListData, err := taskDao.ListTaskIgnore(condition)
  1354 + if err != nil {
  1355 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取任务列表"+err.Error())
  1356 + }
  1357 + //查到的任务数据总数
  1358 + taskCount, err := taskDao.CountTaskIgnore(condition)
  1359 + if err != nil {
  1360 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "统计任务总数"+err.Error())
  1361 + }
  1362 +
  1363 + taskResult := []*adapter.TaskItem{}
  1364 + taskStageRepo := factory.CreateTaskStageRepository(map[string]interface{}{
  1365 + "transactionContext": transactionContext,
  1366 + })
  1367 + nowTime := time.Now().Unix()
  1368 + for _, val := range taskListData {
  1369 + tk := adapter.TaskItem{
  1370 + Id: val.TaskId,
  1371 + Name: "",
  1372 + Alias: val.Alias,
  1373 + Leader: val.LeaderName,
  1374 + Status: val.Status,
  1375 + Level: val.Level,
  1376 + LevelName: val.LevelName,
  1377 + UpdatedAt: val.UpdatedAt.Local().Format("2006-01-02 15:04:05"),
  1378 + Anomaly: val.Anomaly,
  1379 + WarnFlag: 0,
  1380 + LastStage: adapter.TaskStage{
  1381 + Id: val.LastStage.Id,
  1382 + Name: val.LastStage.Name,
  1383 + StatusDescription: val.LastStage.StatusDescription(),
  1384 + SortBy: val.LastStage.SortBy,
  1385 + PlanCompletedAt: time.Unix(int64(val.LastStage.PlanCompletedAt), 0).Local().Format("2006-01-02"),
  1386 + RealCompletedAt: "",
  1387 + IsRef: false,
  1388 + },
  1389 + CurrentStage: adapter.TaskStage{
  1390 + Id: val.CurrentStage.Id,
  1391 + Name: val.CurrentStage.Name,
  1392 + StatusDescription: val.CurrentStage.StatusDescription(),
  1393 + SortBy: val.CurrentStage.SortBy,
  1394 + PlanCompletedAt: time.Unix(int64(val.CurrentStage.PlanCompletedAt), 0).Local().Format("2006-01-02"),
  1395 + RealCompletedAt: "",
  1396 + IsRef: false,
  1397 + },
  1398 + }
  1399 + if val.LastStage.RealCompletedAt > 0 {
  1400 + tk.LastStage.RealCompletedAt = time.Unix(int64(val.LastStage.RealCompletedAt), 0).Local().Format("2006-01-02")
  1401 + }
  1402 + if val.CurrentStage.RealCompletedAt > 0 {
  1403 + tk.CurrentStage.RealCompletedAt = time.Unix(int64(val.CurrentStage.RealCompletedAt), 0).Local().Format("2006-01-02")
  1404 + }
  1405 + if val.LastStage.Id > 0 && val.LastStage.PlanCompletedAt < val.LastStage.RealCompletedAt {
  1406 + tk.WarnFlag = int(domain.TaskWarn)
  1407 + }
  1408 + if val.CurrentStage.Id > 0 && val.CurrentStage.PlanCompletedAt < nowTime {
  1409 + tk.WarnFlag = int(domain.TaskWarn)
  1410 + }
  1411 + _, stageList, err := taskStageRepo.Find(map[string]interface{}{
  1412 + "taskId": val.TaskId,
  1413 + })
  1414 + if err != nil {
  1415 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取任务里程碑"+err.Error())
  1416 + }
  1417 +
  1418 + for _, val2 := range stageList {
  1419 + stage := adapter.TaskStage{
  1420 + Id: val2.Id,
  1421 + Name: val2.Name,
  1422 + SortBy: val2.SortBy,
  1423 + PlanCompletedAt: time.Unix(int64(val2.PlanCompletedAt), 0).Local().Format("2006-01-02"),
  1424 + RealCompletedAt: "",
  1425 + }
  1426 + if val2.RealCompletedAt > 0 {
  1427 + stage.RealCompletedAt = time.Unix(int64(val2.RealCompletedAt), 0).Local().Format("2006-01-02")
  1428 + }
  1429 + switch val2.SortBy {
  1430 + case 1:
  1431 + tk.StageA = stage
  1432 + case 2:
  1433 + tk.StageB = stage
  1434 + case 3:
  1435 + tk.StageC = stage
  1436 + case 4:
  1437 + tk.StageD = stage
  1438 + case 5:
  1439 + tk.StageE = stage
  1440 + }
  1441 + }
  1442 + taskResult = append(taskResult, &tk)
  1443 + }
  1444 +
  1445 + if err := transactionContext.CommitTransaction(); err != nil {
  1446 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  1447 + }
  1448 + result = tool_funs.SimpleWrapGridMap(int64(taskCount), taskResult)
  1449 + return
  1450 +}
  1451 +
  1452 +// 从取消关注的列表中移除数据
  1453 +func (srv *TaskService) CancleTaskIgnore(param *command.CancelIgnoreCommand) (result map[string]interface{}, err error) {
  1454 + transactionContext, err := factory.CreateTransactionContext(nil)
  1455 + if err != nil {
  1456 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  1457 + }
  1458 + if err := transactionContext.StartTransaction(); err != nil {
  1459 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  1460 + }
  1461 + defer func() {
  1462 + _ = transactionContext.RollbackTransaction()
  1463 + }()
  1464 +
  1465 + taskIgnoreRepo := factory.CreateTaskIgnoreRepository(map[string]interface{}{
  1466 + "transactionContext": transactionContext,
  1467 + })
  1468 + _, taskIgnoreList, err := taskIgnoreRepo.Find(map[string]interface{}{
  1469 + "userId": param.UserId,
  1470 + "taskId": param.TaskId,
  1471 + })
  1472 + if len(taskIgnoreList) == 0 {
  1473 + return
  1474 + }
  1475 +
  1476 + err = taskIgnoreRepo.Remove(taskIgnoreList[0].Id)
  1477 + if err != nil {
  1478 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  1479 + }
  1480 + if err := transactionContext.CommitTransaction(); err != nil {
  1481 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  1482 + }
  1483 + return nil, nil
  1484 +}
@@ -68,6 +68,7 @@ type ListTaskCondition struct { @@ -68,6 +68,7 @@ type ListTaskCondition struct {
68 CompanyId int //公司id 68 CompanyId int //公司id
69 UserId int //谁要查看任务数据 69 UserId int //谁要查看任务数据
70 OnlyMy bool //只查看我负责的任务 70 OnlyMy bool //只查看我负责的任务
  71 + LevelName string //任务类型名称
71 SearchWord string 72 SearchWord string
72 } 73 }
73 74
@@ -108,7 +109,10 @@ func (d *TaskDao) CountTaskNotHrbp(param ListTaskCondition) (int, error) { @@ -108,7 +109,10 @@ func (d *TaskDao) CountTaskNotHrbp(param ListTaskCondition) (int, error) {
108 condition = append(condition, param.SearchWord, param.SearchWord) 109 condition = append(condition, param.SearchWord, param.SearchWord)
109 whereSql += ` and (task.leader->>'name' like ? or task.alias like ?)` 110 whereSql += ` and (task.leader->>'name' like ? or task.alias like ?)`
110 } 111 }
111 - 112 + if len(param.LevelName) > 0 {
  113 + condition = append(condition, param.LevelName)
  114 + whereSql += ` and task.level_name = ? `
  115 + }
112 sqlStr := withSql + whereSql 116 sqlStr := withSql + whereSql
113 tx := d.transactionContext.PgTx 117 tx := d.transactionContext.PgTx
114 var cnt int 118 var cnt int
@@ -135,6 +139,10 @@ func (d *TaskDao) CountTaskByHrbp(param ListTaskCondition) (int, error) { @@ -135,6 +139,10 @@ func (d *TaskDao) CountTaskByHrbp(param ListTaskCondition) (int, error) {
135 condition = append(condition, param.SearchWord, param.SearchWord) 139 condition = append(condition, param.SearchWord, param.SearchWord)
136 whereSql += ` and (task.leader->>'name' like ? or task.alias like ?)` 140 whereSql += ` and (task.leader->>'name' like ? or task.alias like ?)`
137 } 141 }
  142 + if len(param.LevelName) > 0 {
  143 + condition = append(condition, param.LevelName)
  144 + whereSql += ` and task.level_name = ? `
  145 + }
138 sqlStr := withSql + whereSql 146 sqlStr := withSql + whereSql
139 tx := d.transactionContext.PgTx 147 tx := d.transactionContext.PgTx
140 var cnt int 148 var cnt int
@@ -167,6 +175,10 @@ func (d *TaskDao) CountTaskStageAnomalyNotHrbp(param ListTaskCondition) (int, er @@ -167,6 +175,10 @@ func (d *TaskDao) CountTaskStageAnomalyNotHrbp(param ListTaskCondition) (int, er
167 condition = append(condition, param.SearchWord, param.SearchWord) 175 condition = append(condition, param.SearchWord, param.SearchWord)
168 whereSql += ` and (task.leader->>'name' like ? or task.alias like ?)` 176 whereSql += ` and (task.leader->>'name' like ? or task.alias like ?)`
169 } 177 }
  178 + if len(param.LevelName) > 0 {
  179 + condition = append(condition, param.LevelName)
  180 + whereSql += ` and task.level_name = ? `
  181 + }
170 sqlStr := withSql + whereSql 182 sqlStr := withSql + whereSql
171 tx := d.transactionContext.PgTx 183 tx := d.transactionContext.PgTx
172 var cnt int 184 var cnt int
@@ -201,6 +213,10 @@ func (d *TaskDao) CountTaskStageAnomalyByHrbp(param ListTaskCondition) (int, err @@ -201,6 +213,10 @@ func (d *TaskDao) CountTaskStageAnomalyByHrbp(param ListTaskCondition) (int, err
201 condition = append(condition, param.SearchWord, param.SearchWord) 213 condition = append(condition, param.SearchWord, param.SearchWord)
202 whereSql += ` and (task.leader->>'name' like ? or task.alias like ?)` 214 whereSql += ` and (task.leader->>'name' like ? or task.alias like ?)`
203 } 215 }
  216 + if len(param.LevelName) > 0 {
  217 + condition = append(condition, param.LevelName)
  218 + whereSql += ` and task.level_name = ? `
  219 + }
204 220
205 sqlStr := withSql + whereSql 221 sqlStr := withSql + whereSql
206 tx := d.transactionContext.PgTx 222 tx := d.transactionContext.PgTx
@@ -302,6 +318,10 @@ func (d *TaskDao) CountTaskAnomalyNotHrbp(param ListTaskCondition) (int, error) @@ -302,6 +318,10 @@ func (d *TaskDao) CountTaskAnomalyNotHrbp(param ListTaskCondition) (int, error)
302 condition = append(condition, param.SearchWord, param.SearchWord) 318 condition = append(condition, param.SearchWord, param.SearchWord)
303 whereSql += ` and (task.leader->>'name' like ? or task.alias like ?)` 319 whereSql += ` and (task.leader->>'name' like ? or task.alias like ?)`
304 } 320 }
  321 + if len(param.LevelName) > 0 {
  322 + condition = append(condition, param.LevelName)
  323 + whereSql += ` and task.level_name = ? `
  324 + }
305 sqlStr := withSql + whereSql 325 sqlStr := withSql + whereSql
306 tx := d.transactionContext.PgTx 326 tx := d.transactionContext.PgTx
307 var cnt int 327 var cnt int
@@ -326,7 +346,11 @@ func (d *TaskDao) CountTaskAnomalyByHrbp(param ListTaskCondition) (int, error) { @@ -326,7 +346,11 @@ func (d *TaskDao) CountTaskAnomalyByHrbp(param ListTaskCondition) (int, error) {
326 } 346 }
327 if param.SearchWord != "" { 347 if param.SearchWord != "" {
328 condition = append(condition, param.SearchWord, param.SearchWord) 348 condition = append(condition, param.SearchWord, param.SearchWord)
329 - whereSql += ` and (task.leader->>'name' like ? or task.alias like ?)` 349 + whereSql += ` and (task.leader->>'name' like ? or task.alias like ?) `
  350 + }
  351 + if len(param.LevelName) > 0 {
  352 + condition = append(condition, param.LevelName)
  353 + whereSql += ` and task.level_name = ? `
330 } 354 }
331 sqlStr := withSql + whereSql 355 sqlStr := withSql + whereSql
332 tx := d.transactionContext.PgTx 356 tx := d.transactionContext.PgTx
@@ -453,6 +477,8 @@ type ListTask struct { @@ -453,6 +477,8 @@ type ListTask struct {
453 CreatedAt time.Time `pg:"created_at"` 477 CreatedAt time.Time `pg:"created_at"`
454 CurrentStage domain.TaskStage `pg:"current_stage"` // 当前执行的里程碑 478 CurrentStage domain.TaskStage `pg:"current_stage"` // 当前执行的里程碑
455 LastStage domain.TaskStage `pg:"last_stage"` // 上一个完成的里程碑 479 LastStage domain.TaskStage `pg:"last_stage"` // 上一个完成的里程碑
  480 + SortBy int `pg:"sort_by"`
  481 + EndTime int `pg:"end_time"`
456 } 482 }
457 483
458 // (新)获取任务,用于页面展示; 无过滤查看权限 484 // (新)获取任务,用于页面展示; 无过滤查看权限
@@ -481,6 +507,8 @@ func (d *TaskDao) ListTaskByHrbpV2(param ListTaskCondition) ([]ListTask, error) @@ -481,6 +507,8 @@ func (d *TaskDao) ListTaskByHrbpV2(param ListTaskCondition) ([]ListTask, error)
481 task.updated_at, 507 task.updated_at,
482 task.current_stage, 508 task.current_stage,
483 task.last_stage, 509 task.last_stage,
  510 + task.sort_by,
  511 + task.end_time,
484 task.created_at 512 task.created_at
485 from task 513 from task
486 left join t_task_ignore on t_task_ignore.task_id=task.id 514 left join t_task_ignore on t_task_ignore.task_id=task.id
@@ -511,14 +539,16 @@ func (d *TaskDao) ListTaskByHrbpV2(param ListTaskCondition) ([]ListTask, error) @@ -511,14 +539,16 @@ func (d *TaskDao) ListTaskByHrbpV2(param ListTaskCondition) ([]ListTask, error)
511 t_task.updated_at , 539 t_task.updated_at ,
512 t_task.current_stage, 540 t_task.current_stage,
513 t_task.last_stage, 541 t_task.last_stage,
  542 + t_task.sort_by,
  543 + t_task.end_time,
514 t_task.created_at 544 t_task.created_at
515 from t_task 545 from t_task
516 where 1=1 546 where 1=1
517 )select * 547 )select *
518 from t_task_1 548 from t_task_1
519 - order by t_task_1.sort_by_1, 549 + order by t_task_1.status, t_task_1.sort_by_1,
520 t_task_1.sort_by_2,t_task_1.anomaly desc, 550 t_task_1.sort_by_2,t_task_1.anomaly desc,
521 - t_task_1."level",t_task_1."created_at" 551 + t_task_1.sort_by,t_task_1."created_at"
522 limit ? offset ? 552 limit ? offset ?
523 ` 553 `
524 condition := []interface{}{param.UserId, param.CompanyId} 554 condition := []interface{}{param.UserId, param.CompanyId}
@@ -531,6 +561,10 @@ func (d *TaskDao) ListTaskByHrbpV2(param ListTaskCondition) ([]ListTask, error) @@ -531,6 +561,10 @@ func (d *TaskDao) ListTaskByHrbpV2(param ListTaskCondition) ([]ListTask, error)
531 condition = append(condition, param.SearchWord, param.SearchWord) 561 condition = append(condition, param.SearchWord, param.SearchWord)
532 whereSql += ` and (task.leader->>'name' like ? or task.alias like ?)` 562 whereSql += ` and (task.leader->>'name' like ? or task.alias like ?)`
533 } 563 }
  564 + if len(param.LevelName) > 0 {
  565 + condition = append(condition, param.LevelName)
  566 + whereSql += ` and task.level_name = ? `
  567 + }
534 strSql2 := fmt.Sprintf(sqlStr, whereSql) 568 strSql2 := fmt.Sprintf(sqlStr, whereSql)
535 condition = append(condition, param.Limit, param.Offset) 569 condition = append(condition, param.Limit, param.Offset)
536 result := []ListTask{} 570 result := []ListTask{}
@@ -558,6 +592,8 @@ func (d *TaskDao) ListTaskNotHrbpV2(param ListTaskCondition) ([]ListTask, error) @@ -558,6 +592,8 @@ func (d *TaskDao) ListTaskNotHrbpV2(param ListTaskCondition) ([]ListTask, error)
558 task.last_stage, 592 task.last_stage,
559 task.status , 593 task.status ,
560 task.updated_at, 594 task.updated_at,
  595 + task.sort_by,
  596 + task.end_time,
561 task.created_at 597 task.created_at
562 from task 598 from task
563 join t_task_1 on t_task_1.id=task.id 599 join t_task_1 on t_task_1.id=task.id
@@ -587,14 +623,16 @@ func (d *TaskDao) ListTaskNotHrbpV2(param ListTaskCondition) ([]ListTask, error) @@ -587,14 +623,16 @@ func (d *TaskDao) ListTaskNotHrbpV2(param ListTaskCondition) ([]ListTask, error)
587 t_task.last_stage, 623 t_task.last_stage,
588 t_task.status , 624 t_task.status ,
589 t_task.updated_at , 625 t_task.updated_at ,
  626 + t_task.sort_by,
  627 + t_task.end_time,
590 t_task.created_at 628 t_task.created_at
591 from t_task 629 from t_task
592 where 1=1 630 where 1=1
593 )select * 631 )select *
594 from tt_task_1 632 from tt_task_1
595 - order by tt_task_1.sort_by_1, 633 + order by tt_task_1.status,tt_task_1.sort_by_1,
596 tt_task_1.sort_by_2,tt_task_1.anomaly desc, 634 tt_task_1.sort_by_2,tt_task_1.anomaly desc,
597 - tt_task_1."level",tt_task_1."created_at" 635 + tt_task_1.sort_by,tt_task_1."created_at"
598 limit ? offset ? 636 limit ? offset ?
599 ` 637 `
600 condition := []interface{}{param.CompanyId} 638 condition := []interface{}{param.CompanyId}
@@ -607,6 +645,10 @@ func (d *TaskDao) ListTaskNotHrbpV2(param ListTaskCondition) ([]ListTask, error) @@ -607,6 +645,10 @@ func (d *TaskDao) ListTaskNotHrbpV2(param ListTaskCondition) ([]ListTask, error)
607 condition = append(condition, param.SearchWord, param.SearchWord) 645 condition = append(condition, param.SearchWord, param.SearchWord)
608 whereSql += ` and (task.leader->>'name' like ? or task.alias like ?)` 646 whereSql += ` and (task.leader->>'name' like ? or task.alias like ?)`
609 } 647 }
  648 + if len(param.LevelName) > 0 {
  649 + condition = append(condition, param.LevelName)
  650 + whereSql += ` and task.level_name = ? `
  651 + }
610 strSql2 := fmt.Sprintf(strSql, whereSql) 652 strSql2 := fmt.Sprintf(strSql, whereSql)
611 condition = append(condition, param.Limit, param.Offset) 653 condition = append(condition, param.Limit, param.Offset)
612 result := []ListTask{} 654 result := []ListTask{}
@@ -614,3 +656,84 @@ func (d *TaskDao) ListTaskNotHrbpV2(param ListTaskCondition) ([]ListTask, error) @@ -614,3 +656,84 @@ func (d *TaskDao) ListTaskNotHrbpV2(param ListTaskCondition) ([]ListTask, error)
614 _, err := tx.Query(&result, strSql2, condition...) 656 _, err := tx.Query(&result, strSql2, condition...)
615 return result, err 657 return result, err
616 } 658 }
  659 +
  660 +// 获取已取消关注的任务列表
  661 +func (d *TaskDao) ListTaskIgnore(param ListTaskCondition) ([]ListTask, error) {
  662 + sqlStr := `with
  663 + t_task_ignore as(
  664 + select task_ignore.task_id
  665 + from task_ignore
  666 + where user_id =3252522494124032
  667 + )select
  668 + task.id as task_id ,
  669 + task.alias ,
  670 + task.leader ->>'name' as leader_name,
  671 + task."level" ,
  672 + task.level_name ,
  673 + task.anomaly ,
  674 + task.status ,
  675 + task.updated_at ,
  676 + task.created_at ,
  677 + task.current_stage ,
  678 + task.last_stage ,
  679 + task.sort_by ,
  680 + task.end_time
  681 + from task
  682 + join t_task_ignore on t_task_ignore.task_id=task.id
  683 + where 1=1 and task.company_id=? and task.deleted_at isnull `
  684 + condition := []interface{}{param.CompanyId}
  685 + whereSql := ``
  686 + if param.OnlyMy {
  687 + condition = append(condition, param.UserId)
  688 + whereSql += ` and task.leader ->>'id' = '?' `
  689 + }
  690 + if param.SearchWord != "" {
  691 + condition = append(condition, param.SearchWord, param.SearchWord)
  692 + whereSql += ` and (task.leader->>'name' like ? or task.alias like ?)`
  693 + }
  694 + if len(param.LevelName) > 0 {
  695 + condition = append(condition, param.LevelName)
  696 + whereSql += ` and task.level_name = ? `
  697 + }
  698 + condition = append(condition, param.Limit, param.Offset)
  699 + sqlStr = sqlStr + whereSql + ` limit ? offset ? `
  700 +
  701 + result := []ListTask{}
  702 + tx := d.transactionContext.PgTx
  703 + _, err := tx.Query(&result, sqlStr, condition...)
  704 + return result, err
  705 +}
  706 +
  707 +func (d *TaskDao) CountTaskIgnore(param ListTaskCondition) (int, error) {
  708 + sqlStr := `with
  709 + t_task_ignore as(
  710 + select task_ignore.task_id
  711 + from task_ignore
  712 + where user_id =3252522494124032
  713 + )select
  714 + count(*) as cnt
  715 + from task
  716 + join t_task_ignore on t_task_ignore.task_id=task.id
  717 + where 1=1 and task.company_id=? and task.deleted_at isnull `
  718 + condition := []interface{}{param.CompanyId}
  719 + whereSql := ``
  720 + if param.OnlyMy {
  721 + condition = append(condition, param.UserId)
  722 + whereSql += ` and task.leader ->>'id' = '?' `
  723 + }
  724 + if param.SearchWord != "" {
  725 + condition = append(condition, param.SearchWord, param.SearchWord)
  726 + whereSql += ` and (task.leader->>'name' like ? or task.alias like ?)`
  727 + }
  728 + if len(param.LevelName) > 0 {
  729 + condition = append(condition, param.LevelName)
  730 + whereSql += ` and task.level_name = ? `
  731 + }
  732 + condition = append(condition, param.Limit, param.Offset)
  733 + sqlStr = sqlStr + whereSql + ` limit ? offset ? `
  734 +
  735 + result := 0
  736 + tx := d.transactionContext.PgTx
  737 + _, err := tx.Query(pg.Scan(&result), sqlStr, condition...)
  738 + return result, err
  739 +}
@@ -88,6 +88,12 @@ func (repo *TaskIgnoreRepository) Find(queryOptions map[string]interface{}) (int @@ -88,6 +88,12 @@ func (repo *TaskIgnoreRepository) Find(queryOptions map[string]interface{}) (int
88 tx := repo.transactionContext.PgTx 88 tx := repo.transactionContext.PgTx
89 var m []*models.TaskIgnore 89 var m []*models.TaskIgnore
90 query := tx.Model(&m) 90 query := tx.Model(&m)
  91 + if v, ok := queryOptions["userId"]; ok {
  92 + query.Where(" user_id=? ", v)
  93 + }
  94 + if v, ok := queryOptions["taskId"]; ok {
  95 + query.Where(" task_id=? ", v)
  96 + }
91 query.Order("id desc") 97 query.Order("id desc")
92 count, err := query.SelectAndCount() 98 count, err := query.SelectAndCount()
93 if err != nil { 99 if err != nil {