...
|
...
|
@@ -1114,3 +1114,162 @@ func (srv TaskService) MarkTaskAnomalyByTask(param *command.MarkTaskAnomalyComma |
|
|
}
|
|
|
return result, nil
|
|
|
}
|
|
|
|
|
|
// 搜索和我有关的异常列表
|
|
|
func (srv TaskService) ListTaskAnomaly4(param *command.ListTaskAnomalyCommand) (map[string]interface{}, error) {
|
|
|
param.TaskName = strings.TrimSpace(param.TaskName)
|
|
|
if len(param.TaskName) == 0 {
|
|
|
return tool_funs.SimpleWrapGridMap(0, []adapter.TaskAnomalyItem{}), nil
|
|
|
}
|
|
|
transactionContext, err := factory.CreateTransactionContext(nil)
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
}
|
|
|
if err := transactionContext.StartTransaction(); err != nil {
|
|
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
}
|
|
|
defer func() {
|
|
|
_ = transactionContext.RollbackTransaction()
|
|
|
}()
|
|
|
taskAnomalyDao := dao.NewTaskAnomalyDao(map[string]interface{}{
|
|
|
"transactionContext": transactionContext,
|
|
|
})
|
|
|
anomalyList, err := taskAnomalyDao.SearchForUser(param.UserId, param.CompanyId, param.TaskName)
|
|
|
if err != nil {
|
|
|
return map[string]interface{}{}, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
|
|
|
|
|
if err := transactionContext.CommitTransaction(); err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
|
|
|
|
|
listData := []adapter.TaskAnomalyItem{}
|
|
|
for _, val := range anomalyList {
|
|
|
item := adapter.TaskAnomalyItem{
|
|
|
Id: val.Id,
|
|
|
TaskId: val.TaskId,
|
|
|
TaskRecordId: val.TaskRecordId,
|
|
|
Category: val.Category,
|
|
|
Leader: val.LeaderName,
|
|
|
CurrentStage: adapter.TaskStage{
|
|
|
Id: val.CurrentStage.Id,
|
|
|
Name: val.CurrentStage.Name,
|
|
|
StatusDescription: val.CurrentStage.StatusDescription(),
|
|
|
SortBy: val.CurrentStage.SortBy,
|
|
|
PlanCompletedAt: time.Unix(val.CurrentStage.PlanCompletedAt, 0).Local().Format("2006-01-02"),
|
|
|
RealCompletedAt: "",
|
|
|
},
|
|
|
LastStage: adapter.TaskStage{
|
|
|
Id: val.LastStage.Id,
|
|
|
Name: val.LastStage.Name,
|
|
|
StatusDescription: val.LastStage.StatusDescription(),
|
|
|
SortBy: val.LastStage.SortBy,
|
|
|
PlanCompletedAt: time.Unix(val.LastStage.PlanCompletedAt, 0).Local().Format("2006-01-02"),
|
|
|
RealCompletedAt: "",
|
|
|
},
|
|
|
AssessFlag: val.AssessFlag,
|
|
|
WarnFlag: val.WarnFlag,
|
|
|
AssistFlag: val.AssistFlag,
|
|
|
TaskLevel: val.LevelName,
|
|
|
TaskName: val.TaskName,
|
|
|
TaskAlias: val.TaskAlias,
|
|
|
TaskEndTime: int64(val.TaskEndTime),
|
|
|
TaskSortBy: val.TaskSortBy,
|
|
|
CreatedAt: val.CreatedAt.Local().Format("2006-01-02"),
|
|
|
RecordBegin: val.RecordBegin,
|
|
|
MarkA: "",
|
|
|
MarkB: "",
|
|
|
MarkC: "",
|
|
|
MarkD: "",
|
|
|
AnomalyDesc2: map[string]string{},
|
|
|
}
|
|
|
if len(val.Marks) > 0 {
|
|
|
item.MarkA = val.Marks["a"]
|
|
|
item.MarkB = val.Marks["b"]
|
|
|
item.MarkC = val.Marks["c"]
|
|
|
item.MarkD = val.Marks["d"]
|
|
|
}
|
|
|
if val.CurrentStage.RealCompletedAt > 0 {
|
|
|
item.CurrentStage.RealCompletedAt = time.Unix(val.CurrentStage.RealCompletedAt, 0).Local().Format("2006-01-02")
|
|
|
}
|
|
|
if val.LastStage.RealCompletedAt > 0 {
|
|
|
item.LastStage.RealCompletedAt = time.Unix(val.LastStage.RealCompletedAt, 0).Local().Format("2006-01-02")
|
|
|
}
|
|
|
noticeWho := []string{}
|
|
|
for _, val2 := range val.NoticeWho {
|
|
|
if name, ok := val2["name"]; ok {
|
|
|
noticeWho = append(noticeWho, name)
|
|
|
}
|
|
|
}
|
|
|
switch val.Category {
|
|
|
case domain.AnomalyCategoryType1:
|
|
|
{
|
|
|
//里程碑异常
|
|
|
if val.TaskStageCheck.RealCompletedAt == 0 && val.TaskStageCheck.Id > 0 {
|
|
|
//逾期未完成
|
|
|
planCompletedAt := time.Unix(val.TaskStageCheck.PlanCompletedAt, 0)
|
|
|
subDay := xtime.SubDayAbs(val.CreatedAt, planCompletedAt)
|
|
|
item.AnomalyDesc = fmt.Sprintf("里程碑%s已逾期%d天", val.TaskStageCheck.Name, subDay)
|
|
|
item.AnomalyDesc2 = map[string]string{
|
|
|
"types": "10",
|
|
|
"stageName": val.TaskStageCheck.Name,
|
|
|
"interval": strconv.Itoa(subDay),
|
|
|
"noticeWho": strings.Join(noticeWho, ","),
|
|
|
}
|
|
|
|
|
|
} else if val.TaskStageCheck.RealCompletedAt > 0 && val.TaskStageCheck.Id > 0 {
|
|
|
//逾期完成
|
|
|
planCompletedAt := time.Unix(val.TaskStageCheck.PlanCompletedAt, 0)
|
|
|
realCompletedAt := time.Unix(val.TaskStageCheck.RealCompletedAt, 0)
|
|
|
subDay := xtime.SubDayAbs(realCompletedAt, planCompletedAt)
|
|
|
item.AnomalyDesc = fmt.Sprintf("里程碑%s逾期%d天完成", val.TaskStageCheck.Name, subDay)
|
|
|
item.AnomalyDesc2 = map[string]string{
|
|
|
"types": "11",
|
|
|
"stageName": val.TaskStageCheck.Name,
|
|
|
"interval": strconv.Itoa(subDay),
|
|
|
"noticeWho": strings.Join(noticeWho, ","),
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
case domain.AnomalyCategoryType2:
|
|
|
//反馈异常
|
|
|
{
|
|
|
recordBegin := time.Unix(val.RecordBegin, 0)
|
|
|
subDay := xtime.SubDayAbs(val.CreatedAt, recordBegin)
|
|
|
item.AnomalyDesc = fmt.Sprintf(
|
|
|
"本任务自%s未正常反馈项目进度,已异常%d天",
|
|
|
recordBegin.Local().Format("2006-01-02"),
|
|
|
subDay,
|
|
|
)
|
|
|
item.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(val.RecordBegin, 0)
|
|
|
subDay := xtime.SubDayAbs(val.CreatedAt, recordBegin)
|
|
|
item.AnomalyDesc = fmt.Sprintf(
|
|
|
"本任务计划于%s完成辅导,已逾期%d天",
|
|
|
recordBegin.Local().Format("2006-01-02"),
|
|
|
subDay,
|
|
|
)
|
|
|
item.AnomalyDesc2 = map[string]string{
|
|
|
"types": "3",
|
|
|
"dayTime": recordBegin.Local().Format("2006-01-02"),
|
|
|
"interval": strconv.Itoa(subDay),
|
|
|
"noticeWho": strings.Join(noticeWho, ","),
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
listData = append(listData, item)
|
|
|
}
|
|
|
|
|
|
result := tool_funs.SimpleWrapGridMap(int64(len(listData)), listData)
|
|
|
return result, nil
|
|
|
} |
...
|
...
|
|