...
|
...
|
@@ -2,6 +2,7 @@ package service |
|
|
|
|
|
import (
|
|
|
"fmt"
|
|
|
"sort"
|
|
|
"strconv"
|
|
|
"strings"
|
|
|
"time"
|
...
|
...
|
@@ -732,7 +733,7 @@ func (srv TaskService) ListTreeTaskAnomaly3(param *command.ListTaskAnomalyComman |
|
|
}
|
|
|
|
|
|
// 异常任务记录的详情
|
|
|
func (srv TaskService) TaskAnomalyInfo(param command.GetTaskAnomalyCommand) (*adapter.TaskAnomalyInfo, error) {
|
|
|
func (srv TaskService) TaskAnomalyInfo(param *command.GetTaskAnomalyCommand) (*adapter.TaskAnomalyInfo, error) {
|
|
|
transactionContext, err := factory.CreateTransactionContext(nil)
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
...
|
...
|
@@ -823,14 +824,97 @@ func (srv TaskService) TaskAnomalyInfo(param command.GetTaskAnomalyCommand) (*ad |
|
|
TaskSortBy: int(taskData.SortBy),
|
|
|
RecordBegin: anomalyData.RecordBegin,
|
|
|
CreatedAt: anomalyData.CreatedAt.Local().Format("066-017"),
|
|
|
MarkA: "",
|
|
|
MarkB: "",
|
|
|
MarkC: "",
|
|
|
MarkD: "",
|
|
|
MarkA: anomalyData.Marks["a"],
|
|
|
MarkB: anomalyData.Marks["b"],
|
|
|
MarkC: anomalyData.Marks["c"],
|
|
|
MarkD: anomalyData.Marks["d"],
|
|
|
AnomalyDesc: "",
|
|
|
AnomalyDesc2: map[string]string{
|
|
|
"": "",
|
|
|
},
|
|
|
}
|
|
|
noticeWho := []string{}
|
|
|
for _, val2 := range anomalyData.NoticeWho {
|
|
|
if name, ok := val2["name"]; ok {
|
|
|
noticeWho = append(noticeWho, name)
|
|
|
}
|
|
|
}
|
|
|
switch anomalyData.Category {
|
|
|
case domain.AnomalyCategoryType1:
|
|
|
{
|
|
|
//里程碑异常
|
|
|
if anomalyData.TaskStageCheck.RealCompletedAt == 0 && anomalyData.TaskStageCheck.Id > 0 {
|
|
|
//逾期未完成
|
|
|
planCompletedAt := time.Unix(anomalyData.TaskStageCheck.PlanCompletedAt, 0)
|
|
|
subDay := xtime.SubDayAbs(anomalyData.CreatedAt, planCompletedAt)
|
|
|
result.AnomalyDesc = fmt.Sprintf("里程碑%s已逾期%d天", anomalyData.TaskStageCheck.Name, subDay)
|
|
|
result.AnomalyDesc2 = map[string]string{
|
|
|
"types": "10",
|
|
|
"stageName": anomalyData.TaskStageCheck.Name,
|
|
|
"interval": strconv.Itoa(subDay),
|
|
|
"noticeWho": strings.Join(noticeWho, ","),
|
|
|
}
|
|
|
|
|
|
} else if anomalyData.TaskStageCheck.RealCompletedAt > 0 && anomalyData.TaskStageCheck.Id > 0 {
|
|
|
//逾期完成
|
|
|
planCompletedAt := time.Unix(anomalyData.TaskStageCheck.PlanCompletedAt, 0)
|
|
|
realCompletedAt := time.Unix(anomalyData.TaskStageCheck.RealCompletedAt, 0)
|
|
|
subDay := xtime.SubDayAbs(realCompletedAt, planCompletedAt)
|
|
|
result.AnomalyDesc = fmt.Sprintf("里程碑%s逾期%d天完成", anomalyData.TaskStageCheck.Name, subDay)
|
|
|
result.AnomalyDesc2 = map[string]string{
|
|
|
"types": "11",
|
|
|
"stageName": anomalyData.TaskStageCheck.Name,
|
|
|
"interval": strconv.Itoa(subDay),
|
|
|
"noticeWho": strings.Join(noticeWho, ","),
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
case domain.AnomalyCategoryType2:
|
|
|
//反馈异常
|
|
|
{
|
|
|
recordBegin := time.Unix(anomalyData.RecordBegin, 0)
|
|
|
subDay := xtime.SubDayAbs(anomalyData.CreatedAt, recordBegin)
|
|
|
result.AnomalyDesc = fmt.Sprintf(
|
|
|
"本任务自%s未正常反馈项目进度,已异常%d天",
|
|
|
recordBegin.Local().Format("2006-01-02"),
|
|
|
subDay,
|
|
|
)
|
|
|
result.AnomalyDesc2 = map[string]string{
|
|
|
"types": "2",
|
|
|
"dayTime": recordBegin.Local().Format("2006-01-02"),
|
|
|
"interval": strconv.Itoa(subDay),
|
|
|
"noticeWho": strings.Join(noticeWho, ","),
|
|
|
}
|
|
|
}
|
|
|
case domain.AnomalyCategoryType3:
|
|
|
//辅导异常
|
|
|
{
|
|
|
recordBegin := time.Unix(anomalyData.RecordBegin, 0)
|
|
|
subDay := xtime.SubDayAbs(anomalyData.CreatedAt, recordBegin)
|
|
|
result.AnomalyDesc = fmt.Sprintf(
|
|
|
"本任务计划于%s完成辅导,已逾期%d天",
|
|
|
recordBegin.Local().Format("2006-01-02"),
|
|
|
subDay,
|
|
|
)
|
|
|
result.AnomalyDesc2 = map[string]string{
|
|
|
"types": "3",
|
|
|
"dayTime": recordBegin.Local().Format("2006-01-02"),
|
|
|
"interval": strconv.Itoa(subDay),
|
|
|
"noticeWho": strings.Join(noticeWho, ","),
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
sort.Slice(stageList, func(i, j int) bool {
|
|
|
return stageList[i].SortBy < stageList[j].SortBy
|
|
|
})
|
|
|
for _, val := range stageList {
|
|
|
result.ListStage = append(result.ListStage, adapter.TaskStage{
|
|
|
Id: val.Id,
|
|
|
Name: val.Name,
|
|
|
StatusDescription: val.StatusDescription(),
|
|
|
SortBy: val.SortBy,
|
|
|
PlanCompletedAt: time.Unix(val.PlanCompletedAt, 0).Format("2006-01-02"),
|
|
|
})
|
|
|
}
|
|
|
return result, nil
|
|
|
} |
...
|
...
|
|