|
@@ -2,6 +2,7 @@ package service |
|
@@ -2,6 +2,7 @@ package service |
2
|
|
2
|
|
3
|
import (
|
3
|
import (
|
4
|
"fmt"
|
4
|
"fmt"
|
|
|
5
|
+ "sort"
|
5
|
"strconv"
|
6
|
"strconv"
|
6
|
"strings"
|
7
|
"strings"
|
7
|
"time"
|
8
|
"time"
|
|
@@ -732,7 +733,7 @@ func (srv TaskService) ListTreeTaskAnomaly3(param *command.ListTaskAnomalyComman |
|
@@ -732,7 +733,7 @@ func (srv TaskService) ListTreeTaskAnomaly3(param *command.ListTaskAnomalyComman |
732
|
}
|
733
|
}
|
733
|
|
734
|
|
734
|
// 异常任务记录的详情
|
735
|
// 异常任务记录的详情
|
735
|
-func (srv TaskService) TaskAnomalyInfo(param command.GetTaskAnomalyCommand) (*adapter.TaskAnomalyInfo, error) {
|
736
|
+func (srv TaskService) TaskAnomalyInfo(param *command.GetTaskAnomalyCommand) (*adapter.TaskAnomalyInfo, error) {
|
736
|
transactionContext, err := factory.CreateTransactionContext(nil)
|
737
|
transactionContext, err := factory.CreateTransactionContext(nil)
|
737
|
if err != nil {
|
738
|
if err != nil {
|
738
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
739
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
@@ -823,14 +824,97 @@ func (srv TaskService) TaskAnomalyInfo(param command.GetTaskAnomalyCommand) (*ad |
|
@@ -823,14 +824,97 @@ func (srv TaskService) TaskAnomalyInfo(param command.GetTaskAnomalyCommand) (*ad |
823
|
TaskSortBy: int(taskData.SortBy),
|
824
|
TaskSortBy: int(taskData.SortBy),
|
824
|
RecordBegin: anomalyData.RecordBegin,
|
825
|
RecordBegin: anomalyData.RecordBegin,
|
825
|
CreatedAt: anomalyData.CreatedAt.Local().Format("066-017"),
|
826
|
CreatedAt: anomalyData.CreatedAt.Local().Format("066-017"),
|
826
|
- MarkA: "",
|
|
|
827
|
- MarkB: "",
|
|
|
828
|
- MarkC: "",
|
|
|
829
|
- MarkD: "",
|
827
|
+ MarkA: anomalyData.Marks["a"],
|
|
|
828
|
+ MarkB: anomalyData.Marks["b"],
|
|
|
829
|
+ MarkC: anomalyData.Marks["c"],
|
|
|
830
|
+ MarkD: anomalyData.Marks["d"],
|
830
|
AnomalyDesc: "",
|
831
|
AnomalyDesc: "",
|
831
|
AnomalyDesc2: map[string]string{
|
832
|
AnomalyDesc2: map[string]string{
|
832
|
"": "",
|
833
|
"": "",
|
833
|
},
|
834
|
},
|
834
|
}
|
835
|
}
|
|
|
836
|
+ noticeWho := []string{}
|
|
|
837
|
+ for _, val2 := range anomalyData.NoticeWho {
|
|
|
838
|
+ if name, ok := val2["name"]; ok {
|
|
|
839
|
+ noticeWho = append(noticeWho, name)
|
|
|
840
|
+ }
|
|
|
841
|
+ }
|
|
|
842
|
+ switch anomalyData.Category {
|
|
|
843
|
+ case domain.AnomalyCategoryType1:
|
|
|
844
|
+ {
|
|
|
845
|
+ //里程碑异常
|
|
|
846
|
+ if anomalyData.TaskStageCheck.RealCompletedAt == 0 && anomalyData.TaskStageCheck.Id > 0 {
|
|
|
847
|
+ //逾期未完成
|
|
|
848
|
+ planCompletedAt := time.Unix(anomalyData.TaskStageCheck.PlanCompletedAt, 0)
|
|
|
849
|
+ subDay := xtime.SubDayAbs(anomalyData.CreatedAt, planCompletedAt)
|
|
|
850
|
+ result.AnomalyDesc = fmt.Sprintf("里程碑%s已逾期%d天", anomalyData.TaskStageCheck.Name, subDay)
|
|
|
851
|
+ result.AnomalyDesc2 = map[string]string{
|
|
|
852
|
+ "types": "10",
|
|
|
853
|
+ "stageName": anomalyData.TaskStageCheck.Name,
|
|
|
854
|
+ "interval": strconv.Itoa(subDay),
|
|
|
855
|
+ "noticeWho": strings.Join(noticeWho, ","),
|
|
|
856
|
+ }
|
|
|
857
|
+
|
|
|
858
|
+ } else if anomalyData.TaskStageCheck.RealCompletedAt > 0 && anomalyData.TaskStageCheck.Id > 0 {
|
|
|
859
|
+ //逾期完成
|
|
|
860
|
+ planCompletedAt := time.Unix(anomalyData.TaskStageCheck.PlanCompletedAt, 0)
|
|
|
861
|
+ realCompletedAt := time.Unix(anomalyData.TaskStageCheck.RealCompletedAt, 0)
|
|
|
862
|
+ subDay := xtime.SubDayAbs(realCompletedAt, planCompletedAt)
|
|
|
863
|
+ result.AnomalyDesc = fmt.Sprintf("里程碑%s逾期%d天完成", anomalyData.TaskStageCheck.Name, subDay)
|
|
|
864
|
+ result.AnomalyDesc2 = map[string]string{
|
|
|
865
|
+ "types": "11",
|
|
|
866
|
+ "stageName": anomalyData.TaskStageCheck.Name,
|
|
|
867
|
+ "interval": strconv.Itoa(subDay),
|
|
|
868
|
+ "noticeWho": strings.Join(noticeWho, ","),
|
|
|
869
|
+ }
|
|
|
870
|
+ }
|
|
|
871
|
+ }
|
|
|
872
|
+ case domain.AnomalyCategoryType2:
|
|
|
873
|
+ //反馈异常
|
|
|
874
|
+ {
|
|
|
875
|
+ recordBegin := time.Unix(anomalyData.RecordBegin, 0)
|
|
|
876
|
+ subDay := xtime.SubDayAbs(anomalyData.CreatedAt, recordBegin)
|
|
|
877
|
+ result.AnomalyDesc = fmt.Sprintf(
|
|
|
878
|
+ "本任务自%s未正常反馈项目进度,已异常%d天",
|
|
|
879
|
+ recordBegin.Local().Format("2006-01-02"),
|
|
|
880
|
+ subDay,
|
|
|
881
|
+ )
|
|
|
882
|
+ result.AnomalyDesc2 = map[string]string{
|
|
|
883
|
+ "types": "2",
|
|
|
884
|
+ "dayTime": recordBegin.Local().Format("2006-01-02"),
|
|
|
885
|
+ "interval": strconv.Itoa(subDay),
|
|
|
886
|
+ "noticeWho": strings.Join(noticeWho, ","),
|
|
|
887
|
+ }
|
|
|
888
|
+ }
|
|
|
889
|
+ case domain.AnomalyCategoryType3:
|
|
|
890
|
+ //辅导异常
|
|
|
891
|
+ {
|
|
|
892
|
+ recordBegin := time.Unix(anomalyData.RecordBegin, 0)
|
|
|
893
|
+ subDay := xtime.SubDayAbs(anomalyData.CreatedAt, recordBegin)
|
|
|
894
|
+ result.AnomalyDesc = fmt.Sprintf(
|
|
|
895
|
+ "本任务计划于%s完成辅导,已逾期%d天",
|
|
|
896
|
+ recordBegin.Local().Format("2006-01-02"),
|
|
|
897
|
+ subDay,
|
|
|
898
|
+ )
|
|
|
899
|
+ result.AnomalyDesc2 = map[string]string{
|
|
|
900
|
+ "types": "3",
|
|
|
901
|
+ "dayTime": recordBegin.Local().Format("2006-01-02"),
|
|
|
902
|
+ "interval": strconv.Itoa(subDay),
|
|
|
903
|
+ "noticeWho": strings.Join(noticeWho, ","),
|
|
|
904
|
+ }
|
|
|
905
|
+ }
|
|
|
906
|
+ }
|
|
|
907
|
+ sort.Slice(stageList, func(i, j int) bool {
|
|
|
908
|
+ return stageList[i].SortBy < stageList[j].SortBy
|
|
|
909
|
+ })
|
|
|
910
|
+ for _, val := range stageList {
|
|
|
911
|
+ result.ListStage = append(result.ListStage, adapter.TaskStage{
|
|
|
912
|
+ Id: val.Id,
|
|
|
913
|
+ Name: val.Name,
|
|
|
914
|
+ StatusDescription: val.StatusDescription(),
|
|
|
915
|
+ SortBy: val.SortBy,
|
|
|
916
|
+ PlanCompletedAt: time.Unix(val.PlanCompletedAt, 0).Format("2006-01-02"),
|
|
|
917
|
+ })
|
|
|
918
|
+ }
|
835
|
return result, nil
|
919
|
return result, nil
|
836
|
} |
920
|
} |