作者 tangxvhui

日常保存

... ... @@ -34,3 +34,33 @@ type TaskAnomalyItem2 struct {
Leader map[string]string `json:"leader"`
TaskAnomaly []TaskAnomalyItem `json:"taskAnomaly"`
}
// 任务异常记录详情
type TaskAnomalyInfo struct {
Id int `json:"id,string"`
TaskId int `json:"taskId,string"` // 任务id
TaskRecordId int `json:"taskRecordId,string"` // 任务反馈记录id
Category int `json:"category"` // 异常分类
Leader string `json:"leader"` // 任务负责人
LeaderId string `json:"leaderId"` // 任务负责人
CurrentStage TaskStage `json:"currentStage"` // 计划进度的里程碑
LastStage TaskStage `json:"lastStage"` // 实际进度完成的里程碑
TaskStageCheck TaskStage `json:"taskStageCheck"` // 实际进度完成的里程碑
ListStage []TaskStage `json:"listStage"` // 实际进度完成的里程碑
AssessFlag int `json:"assessFlag"` // 异常反馈的次数
WarnFlag int `json:"warnFlag"` // 里程碑异常次数
AssistFlag int `json:"assistFlag"` // 辅导异常次数
TaskLevel string `json:"taskLevel"` // 任务类型
TaskName string `json:"taskName"` // 任务名称
TaskAlias string `json:"taskAlias"` // 任务别名
TaskEndTime int64 `json:"taskEndTime"` // 任务截止的时间戳,单位:秒;等于0时表示未设置时间
TaskSortBy int `json:"taskSortBy"` // 优先级排序;值越小优先级越高
RecordBegin int64 `json:"recordBegin"` //
CreatedAt string `json:"createdAt"` //
MarkA string `json:"markA"` // 去更新
MarkB string `json:"markB"` // 去反馈
MarkC string `json:"markC"` // 去求助
MarkD string `json:"markD"` // 去辅导
AnomalyDesc string `json:"anomalyDesc"` // 异常状况描述
AnomalyDesc2 map[string]string `json:"anomalyDesc2"`
}
... ...
... ... @@ -643,10 +643,10 @@ func (srv TaskService) MarkTaskAnomaly(param *command.MarkTaskAnomalyCommand) (m
return map[string]string{}, nil
}
// 我的下级负责任务,异常列表
// 我的下级负责任务,异常列表 数据结构变体
// 按任务负责人归类,列表整理成树形结构
func (srv TaskService) ListTreeTaskAnomaly2(param *command.ListTaskAnomalyCommand) (map[string]interface{}, error) {
_, taskAnomalyList, err := srv.listTaskAnomaly2(param)
total, taskAnomalyList, err := srv.listTaskAnomaly2(param)
if err != nil {
return map[string]interface{}{
"list": []adapter.TaskAnomalyItem2{},
... ... @@ -682,14 +682,15 @@ func (srv TaskService) ListTreeTaskAnomaly2(param *command.ListTaskAnomalyComman
result := map[string]interface{}{
"list": treeList,
"leader": leaderList,
"total": total,
}
return result, nil
}
// 我相关的任务,异常列表
// 我相关的任务,异常列表 数据结构变体
// 按任务负责人归类,列表整理成树形结构
func (srv TaskService) ListTreeTaskAnomaly3(param *command.ListTaskAnomalyCommand) (map[string]interface{}, error) {
_, taskAnomalyList, err := srv.listTaskAnomaly3(param)
total, taskAnomalyList, err := srv.listTaskAnomaly3(param)
if err != nil {
return map[string]interface{}{
"list": []adapter.TaskAnomalyItem2{},
... ... @@ -725,6 +726,111 @@ func (srv TaskService) ListTreeTaskAnomaly3(param *command.ListTaskAnomalyComman
result := map[string]interface{}{
"list": treeList,
"leader": leaderList,
"total": total,
}
return result, nil
}
// 异常任务记录的详情
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())
}
if err := transactionContext.StartTransaction(); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
defer func() {
_ = transactionContext.RollbackTransaction()
}()
taskAnomalyRepo := factory.CreateTaskAnomalyRepository(map[string]interface{}{
"transactionContext": transactionContext,
})
taskRepo := factory.CreateTaskRepository(map[string]interface{}{
"transactionContext": transactionContext,
})
taskStatgeRepo := factory.CreateTaskStageRepository(map[string]interface{}{
"transactionContext": transactionContext,
})
_, anomalyList, err := taskAnomalyRepo.Find(map[string]interface{}{"id": param.Id, "companyId": param.CompanyId, "limit": 1})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
if len(anomalyList) == 0 {
return &adapter.TaskAnomalyInfo{}, nil
}
anomalyData := anomalyList[0]
_, taskList, err := taskRepo.Find(map[string]interface{}{"id": anomalyData.TaskId, "companyId": anomalyData.CompanyId, "limit": 1})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
if len(taskList) == 0 {
return &adapter.TaskAnomalyInfo{}, nil
}
taskData := taskList[0]
_, stageList, err := taskStatgeRepo.Find(map[string]interface{}{"taskId": taskData.Id})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
if err := transactionContext.CommitTransaction(); err != nil {
return nil, nil
}
if len(anomalyData.Marks) == 0 {
anomalyData.Marks = map[string]string{}
}
result := &adapter.TaskAnomalyInfo{
Id: anomalyData.Id,
TaskId: anomalyData.TaskId,
TaskRecordId: anomalyData.TaskRecordId,
Category: anomalyData.Category,
Leader: taskData.Leader.Name,
LeaderId: strconv.FormatInt(taskData.Leader.Id, 10),
CurrentStage: adapter.TaskStage{
Id: anomalyData.CurrentStage.Id,
Name: anomalyData.CurrentStage.Name,
StatusDescription: anomalyData.CurrentStage.StatusDescription(),
SortBy: anomalyData.CurrentStage.SortBy,
PlanCompletedAt: time.Unix(anomalyData.CurrentStage.PlanCompletedAt, 0).Format("2006-01-02"),
RealCompletedAt: "",
},
LastStage: adapter.TaskStage{
Id: anomalyData.LastStage.Id,
Name: anomalyData.LastStage.Name,
StatusDescription: anomalyData.LastStage.StatusDescription(),
SortBy: anomalyData.LastStage.SortBy,
PlanCompletedAt: time.Unix(anomalyData.LastStage.PlanCompletedAt, 0).Format("2006-01-02"),
RealCompletedAt: "",
},
TaskStageCheck: adapter.TaskStage{
Id: anomalyData.TaskStageCheck.Id,
Name: anomalyData.TaskStageCheck.Name,
StatusDescription: anomalyData.TaskStageCheck.StatusDescription(),
SortBy: anomalyData.TaskStageCheck.SortBy,
PlanCompletedAt: time.Unix(anomalyData.TaskStageCheck.PlanCompletedAt, 0).Format("2006-01-02"),
RealCompletedAt: "",
},
ListStage: []adapter.TaskStage{},
AssessFlag: anomalyData.AssessFlag,
WarnFlag: anomalyData.WarnFlag,
AssistFlag: anomalyData.AssistFlag,
TaskLevel: taskData.LevelName,
TaskName: taskData.Name,
TaskAlias: taskData.Alias,
TaskEndTime: taskData.EndTime,
TaskSortBy: int(taskData.SortBy),
RecordBegin: anomalyData.RecordBegin,
CreatedAt: anomalyData.CreatedAt.Local().Format("066-017"),
MarkA: "",
MarkB: "",
MarkC: "",
MarkD: "",
AnomalyDesc: "",
AnomalyDesc2: map[string]string{
"": "",
},
}
return result, nil
}
... ...