作者 tangxvhui

调整 异常中心的点击操作

@@ -564,13 +564,13 @@ func (srv TaskService) ListTaskAnomaly1(param *command.ListTaskAnomalyCommand) ( @@ -564,13 +564,13 @@ func (srv TaskService) ListTaskAnomaly1(param *command.ListTaskAnomalyCommand) (
564 } 564 }
565 565
566 // 对异常记录的操作标记 566 // 对异常记录的操作标记
567 -func (srv TaskService) MarkTaskAnomaly(param *command.MarkTaskAnomalyCommand) (map[string]string, error) { 567 +func (srv TaskService) MarkTaskAnomaly(param *command.MarkTaskAnomalyCommand) (map[string]interface{}, error) {
568 transactionContext, err := factory.CreateTransactionContext(nil) 568 transactionContext, err := factory.CreateTransactionContext(nil)
569 if err != nil { 569 if err != nil {
570 - return map[string]string{}, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 570 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
571 } 571 }
572 if err := transactionContext.StartTransaction(); err != nil { 572 if err := transactionContext.StartTransaction(); err != nil {
573 - return map[string]string{}, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 573 + return map[string]interface{}{}, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
574 } 574 }
575 defer func() { 575 defer func() {
576 _ = transactionContext.RollbackTransaction() 576 _ = transactionContext.RollbackTransaction()
@@ -583,10 +583,12 @@ func (srv TaskService) MarkTaskAnomaly(param *command.MarkTaskAnomalyCommand) (m @@ -583,10 +583,12 @@ func (srv TaskService) MarkTaskAnomaly(param *command.MarkTaskAnomalyCommand) (m
583 }) 583 })
584 _, anomalyList, err := taskAnomalyRepo.Find(map[string]interface{}{"id": param.Id, "companyId": param.CompanyId, "limit": 1}) 584 _, anomalyList, err := taskAnomalyRepo.Find(map[string]interface{}{"id": param.Id, "companyId": param.CompanyId, "limit": 1})
585 if err != nil { 585 if err != nil {
586 - return map[string]string{}, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 586 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
587 } 587 }
588 if len(anomalyList) == 0 { 588 if len(anomalyList) == 0 {
589 - return map[string]string{}, nil 589 + return map[string]interface{}{
  590 + "have": false,
  591 + }, nil
590 } 592 }
591 593
592 anomalyData := anomalyList[0] 594 anomalyData := anomalyList[0]
@@ -603,10 +605,11 @@ func (srv TaskService) MarkTaskAnomaly(param *command.MarkTaskAnomalyCommand) (m @@ -603,10 +605,11 @@ func (srv TaskService) MarkTaskAnomaly(param *command.MarkTaskAnomalyCommand) (m
603 } 605 }
604 err = taskAnomalyRepo.Save(anomalyData) 606 err = taskAnomalyRepo.Save(anomalyData)
605 if err != nil { 607 if err != nil {
606 - return map[string]string{}, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 608 + return map[string]interface{}{}, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
607 } 609 }
  610 + // c :找上级 ,
608 if !(param.MarkType == "a" || param.MarkType == "b") { 611 if !(param.MarkType == "a" || param.MarkType == "b") {
609 - return map[string]string{}, nil 612 + return map[string]interface{}{"have": false}, nil
610 } 613 }
611 614
612 taskId := anomalyData.TaskId 615 taskId := anomalyData.TaskId
@@ -618,10 +621,14 @@ func (srv TaskService) MarkTaskAnomaly(param *command.MarkTaskAnomalyCommand) (m @@ -618,10 +621,14 @@ func (srv TaskService) MarkTaskAnomaly(param *command.MarkTaskAnomalyCommand) (m
618 "limit": 1, 621 "limit": 1,
619 }) 622 })
620 if err != nil { 623 if err != nil {
621 - return map[string]string{}, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 624 + return map[string]interface{}{}, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
622 } 625 }
623 if len(taskList) == 0 { 626 if len(taskList) == 0 {
624 - return map[string]string{}, nil 627 + return map[string]interface{}{"have": false}, nil
  628 + }
  629 + taskData := taskList[0]
  630 + if taskData.Leader.Id != int64(param.UserId) {
  631 + return map[string]interface{}{}, nil
625 } 632 }
626 assessReps := factory.CreateStaffAssessRepository(map[string]interface{}{"transactionContext": transactionContext}) 633 assessReps := factory.CreateStaffAssessRepository(map[string]interface{}{"transactionContext": transactionContext})
627 // 获取员工的评估 634 // 获取员工的评估
@@ -629,7 +636,7 @@ func (srv TaskService) MarkTaskAnomaly(param *command.MarkTaskAnomalyCommand) (m @@ -629,7 +636,7 @@ func (srv TaskService) MarkTaskAnomaly(param *command.MarkTaskAnomalyCommand) (m
629 636
630 _, assessList, err := assessReps.Find(map[string]interface{}{ 637 _, assessList, err := assessReps.Find(map[string]interface{}{
631 "companyId": param.CompanyId, 638 "companyId": param.CompanyId,
632 - "executorId": taskList[0].Leader.Id, 639 + "executorId": taskData.Leader.Id,
633 "beginDay": today, 640 "beginDay": today,
634 "typesList": []string{string(domain.AssessSelf)}, 641 "typesList": []string{string(domain.AssessSelf)},
635 "limit": 1, 642 "limit": 1,
@@ -637,11 +644,34 @@ func (srv TaskService) MarkTaskAnomaly(param *command.MarkTaskAnomalyCommand) (m @@ -637,11 +644,34 @@ func (srv TaskService) MarkTaskAnomaly(param *command.MarkTaskAnomalyCommand) (m
637 if err != nil { 644 if err != nil {
638 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取员工的评估"+err.Error()) 645 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取员工的评估"+err.Error())
639 } 646 }
640 - _ = assessList 647 + if len(assessList) == 0 {
  648 + return map[string]interface{}{
  649 + "have": false,
  650 + }, nil
  651 + }
  652 + taskRecordReps := factory.CreateTaskRecordRepository(map[string]interface{}{"transactionContext": transactionContext})
  653 + _, recordList, err := taskRecordReps.Find(map[string]interface{}{"staffAssessId": assessList[0].Id, "taskId": taskData.Id})
  654 + if err != nil {
  655 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取任务的评估"+err.Error())
  656 + }
  657 + if len(recordList) == 0 {
  658 + result := map[string]interface{}{
  659 + "have": true,
  660 + "cycleId": strconv.FormatInt(assessList[0].CycleId, 10),
  661 + "beginDay": today,
  662 + }
  663 + return result, nil
  664 + }
641 if err := transactionContext.CommitTransaction(); err != nil { 665 if err := transactionContext.CommitTransaction(); err != nil {
642 - return map[string]string{}, nil 666 + return map[string]interface{}{}, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  667 + }
  668 + result := map[string]interface{}{
  669 + "have": true,
  670 + "cycleId": strconv.FormatInt(assessList[0].CycleId, 10),
  671 + "beginDay": today,
  672 + "taskRecordId": recordList[0].Id,
643 } 673 }
644 - return map[string]string{}, nil 674 + return result, nil
645 } 675 }
646 676
647 // 我的下级负责任务,异常列表 数据结构变体 677 // 我的下级负责任务,异常列表 数据结构变体