作者 tangxvhui

调整数据输出

... ... @@ -18,9 +18,10 @@ type TaskAnomalyItem struct {
TaskEndTime int64 `json:"taskEndTime"` // 任务截止的时间戳,单位:秒;等于0时表示未设置时间
TaskSortBy int `json:"taskSortBy"` // 优先级排序;值越小优先级越高
RecordBegin int64 `json:"recordBegin"` //
MarkA string `json:"markA"` // 去更新
MarkB string `json:"markB"` // 去反馈
MarkC string `json:"markC"` // 去求助
MarkD string `json:"markD"` // 去辅导
AnomalyDesc string `json:"anomalyDesc"` // 异常状况描述
CreatedAt string `json:"createdAt"`
MarkA string `json:"markA"` // 去更新
MarkB string `json:"markB"` // 去反馈
MarkC string `json:"markC"` // 去求助
MarkD string `json:"markD"` // 去辅导
AnomalyDesc string `json:"anomalyDesc"` // 异常状况描述
}
... ...
package command
// 获取任务
type GetTaskAnomalyCommand struct {
Id int `json:"id,string"`
CompanyId int `json:"-"`
}
... ...
... ... @@ -3,5 +3,6 @@ package command
type MarkTaskAnomalyCommand struct {
Id int `json:"id,string"` //异常记录id
CompanyId int `json:"-"`
UserId int `json:"-"`
MarkType string `json:"markType"` //a:去更新,b:去反馈,c:去求助,d:去辅导
}
... ...
... ... @@ -73,6 +73,7 @@ func (srv TaskService) ListTaskAnomaly1(param *command.ListTaskAnomalyCommand) (
TaskAlias: val.TaskAlias,
TaskEndTime: int64(val.TaskEndTime),
TaskSortBy: val.TaskSortBy,
CreatedAt: val.CreatedAt.Local().Format("2006-01-02"),
RecordBegin: val.RecordBegin,
MarkA: "",
MarkB: "",
... ... @@ -202,6 +203,7 @@ func (srv TaskService) ListTaskAnomaly2(param *command.ListTaskAnomalyCommand) (
TaskEndTime: int64(val.TaskEndTime),
TaskSortBy: val.TaskSortBy,
RecordBegin: val.RecordBegin,
CreatedAt: val.CreatedAt.Local().Format("2006-01-02"),
MarkA: "",
MarkB: "",
MarkC: "",
... ... @@ -327,6 +329,7 @@ func (srv TaskService) ListTaskAnomaly3(param *command.ListTaskAnomalyCommand) (
TaskEndTime: int64(val.TaskEndTime),
TaskSortBy: val.TaskSortBy,
RecordBegin: val.RecordBegin,
CreatedAt: val.CreatedAt.Local().Format("2006-01-02"),
MarkA: "",
MarkB: "",
MarkC: "",
... ... @@ -392,6 +395,12 @@ func (srv TaskService) ListTaskAnomaly3(param *command.ListTaskAnomalyCommand) (
return result, nil
}
// 异常详情
// func (srv TaskService) TaskAnomalyInfo() error {
// return nil
// }
func (srv TaskService) UserSelect(param *command.UserSelectCommand) []adapter.UserItem {
transactionContext, err := factory.CreateTransactionContext(nil)
if err != nil {
... ... @@ -449,10 +458,10 @@ func (srv TaskService) UserSelect(param *command.UserSelectCommand) []adapter.Us
func (srv TaskService) MarkTaskAnomaly(param *command.MarkTaskAnomalyCommand) (map[string]string, error) {
transactionContext, err := factory.CreateTransactionContext(nil)
if err != nil {
return map[string]string{}, nil
return map[string]string{}, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
if err := transactionContext.StartTransaction(); err != nil {
return map[string]string{}, nil
return map[string]string{}, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
defer func() {
_ = transactionContext.RollbackTransaction()
... ... @@ -460,21 +469,42 @@ func (srv TaskService) MarkTaskAnomaly(param *command.MarkTaskAnomalyCommand) (m
taskAnomalyRepo := factory.CreateTaskAnomalyRepository(map[string]interface{}{
"transactionContext": transactionContext,
})
_, anomalyList, err := taskAnomalyRepo.Find(map[string]interface{}{"id": param.Id, "limit": 1})
taskRepo := factory.CreateTaskRepository(map[string]interface{}{
"transactionContext": transactionContext,
})
_, anomalyList, err := taskAnomalyRepo.Find(map[string]interface{}{"id": param.Id, "companyId": param.CompanyId, "limit": 1})
if err != nil {
return map[string]string{}, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
if len(anomalyList) == 0 {
return map[string]string{}, nil
}
_ = anomalyList
//MarkType= "a" 去更新,对应里程碑异常
//检查最新的异常记录,进行标记
//检查是否有任务相关连的每日评估
if param.MarkType == "a" {
anomalyData := anomalyList[0]
switch param.MarkType {
case "a":
anomalyData.MarkA()
case "b":
anomalyData.MarkB()
case "c":
anomalyData.MarkC()
case "d":
anomalyData.MarkD()
}
err = taskAnomalyRepo.Save(anomalyData)
if err != nil {
return map[string]string{}, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
// 或者 MarkType= "b" 去反馈,对应反馈异常
//MarkTYpe="c" //
//MarkType = "d"
//检查最新的异常记录,进行标记
if !(param.MarkType == "a" || param.MarkType == "b") {
return map[string]string{}, nil
}
taskId := anomalyData.TaskId
taskRepo.Find(map[string]interface{}{
"id": taskId,
})
//检查是否有任务相关连的最新每日评估
if err := transactionContext.CommitTransaction(); err != nil {
return map[string]string{}, nil
... ...
... ... @@ -112,12 +112,12 @@ func (t *TaskAnomaly) AnomalyDesc() (str string) {
return str
}
// 发送异常后的天数
func (t *TaskAnomaly) CountAnomalyDay() int {
t1 := t.CreatedAt
t2 := time.Unix(t.RecordBegin, 0)
return xtime.SubDayAbs(t1, t2)
}
// 发生异常后的天数
// func (t *TaskAnomaly) CountAnomalyDay() int {
// t1 := t.CreatedAt
// t2 := time.Unix(t.RecordBegin, 0)
// return xtime.SubDayAbs(t1, t2)
// }
// 存储
type TaskAnomalyRepository interface {
... ...
... ... @@ -118,6 +118,9 @@ func (repo *TaskAnomalyRepository) Find(queryOptions map[string]interface{}) (in
if val, ok := queryOptions["id"]; ok {
query.Where(" id=? ", val)
}
if val, ok := queryOptions["companyId"]; ok {
query.Where(" company_id=? ", val)
}
if val, ok := queryOptions["taskId"]; ok {
query.Where(" task_id=? ", val)
}
... ...