作者 tangxvhui

修改 异常记录操作边标记的记录方式

package adapter
type AssessCycleDescResp struct {
CycleId int `json:"cycleId"`
CycleId int `json:"cycleId,string"`
CycleName string `json:"cycleName"` //周期名称
BeginDay string `json:"beginDay"` //开始的日期
StepList []AssessTaskStep `json:"stepList"` //考评流程
... ...
... ... @@ -657,7 +657,7 @@ func (srv TaskService) MarkTaskAnomaly(param *command.MarkTaskAnomalyCommand) (m
}
if len(recordList) == 0 {
result := map[string]interface{}{
"have": true,
"have": false,
"cycleId": strconv.FormatInt(assessList[0].CycleId, 10),
"beginDay": today,
}
... ... @@ -952,7 +952,7 @@ func (srv TaskService) TaskAnomalyInfo(param *command.GetTaskAnomalyCommand) (*a
// 任务列表中,对异常记录的操作标记
// 按照任务id 实则操作标记
func (srv TaskService) MarkTaskAnomalyByTask(param command.MarkTaskAnomalyCommand) (map[string]interface{}, error) {
func (srv TaskService) MarkTaskAnomalyByTask(param *command.MarkTaskAnomalyCommand) (map[string]interface{}, error) {
transactionContext, err := factory.CreateTransactionContext(nil)
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
... ... @@ -963,8 +963,88 @@ func (srv TaskService) MarkTaskAnomalyByTask(param command.MarkTaskAnomalyComman
defer func() {
_ = transactionContext.RollbackTransaction()
}()
taskAnomalyRepo := factory.CreateTaskAnomalyRepository(map[string]interface{}{
"transactionContext": transactionContext,
})
taskRepo := factory.CreateTaskRepository(map[string]interface{}{
"transactionContext": transactionContext,
})
_, taskList, err := taskRepo.Find(map[string]interface{}{"id": param.Id, "limit": 1})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
if len(taskList) == 0 {
return map[string]interface{}{
"have": false,
}, nil
}
taskData := taskList[0]
_, anomalyList, err := taskAnomalyRepo.Find(map[string]interface{}{"isLast": 1, "companyId": param.CompanyId, "taskId": taskData.Id})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
if len(anomalyList) == 0 {
return map[string]interface{}{
"have": false,
}, nil
}
for _, val := range anomalyList {
switch param.MarkType {
case "a":
val.MarkA()
case "b":
val.MarkB()
case "c":
val.MarkC()
case "d":
val.MarkD()
}
err = taskAnomalyRepo.Save(val)
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
}
// 检查今天是否有任务有没有对应的每日评估
assessReps := factory.CreateStaffAssessRepository(map[string]interface{}{"transactionContext": transactionContext})
// 获取员工的评估
today := time.Now().Format("2006-01-02")
_, assessList, err := assessReps.Find(map[string]interface{}{
"companyId": param.CompanyId,
"executorId": taskData.Leader.Id,
"beginDay": today,
"typesList": []string{string(domain.AssessSelf)},
"limit": 1,
})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取员工的评估"+err.Error())
}
if len(assessList) == 0 {
return map[string]interface{}{
"have": false,
}, nil
}
taskRecordReps := factory.CreateTaskRecordRepository(map[string]interface{}{"transactionContext": transactionContext})
_, recordList, err := taskRecordReps.Find(map[string]interface{}{"staffAssessId": assessList[0].Id, "taskId": taskData.Id})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取任务的评估"+err.Error())
}
if len(recordList) == 0 {
result := map[string]interface{}{
"have": false,
"cycleId": strconv.FormatInt(assessList[0].CycleId, 10),
"beginDay": today,
}
return result, nil
}
if err := transactionContext.CommitTransaction(); err != nil {
return map[string]interface{}{}, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
return nil, nil
result := map[string]interface{}{
"have": true,
"cycleId": strconv.FormatInt(assessList[0].CycleId, 10),
"beginDay": today,
"taskRecordId": recordList[0].Id,
}
return result, nil
}
... ...
package domain
import (
"time"
)
// 对异常记录的操作标记
type TaskAnomalyMark struct {
Id int
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
CompanyId int `json:"companyId,string"` // 公司id
UserId int `json:"userId,string"` // 操作人id
TaskId int `json:"taskId,string"` // 任务id
TaskAnomalyId int `json:"taskAnomalyId,string"` // 异常记录id
Marks string `json:"marks"` // 已经操作的标记
}
// 已点击“去更新”
func (t *TaskAnomalyMark) MarkA() {
t.Marks = "已更新"
}
// 已点击 "去反馈"
func (t *TaskAnomalyMark) MarkB() {
t.Marks = "已反馈"
}
// 已点击 "找上级"
func (t *TaskAnomalyMark) MarkC() {
t.Marks = "已求助"
}
// 已点击 "去辅导"
func (t *TaskAnomalyMark) MarkD() {
t.Marks = "已辅导"
}
type TaskAnomalyMarkRepository interface {
Save(param *TaskAnomalyMark) error
FindOne(queryOptions map[string]interface{}) (*TaskAnomalyMark, error)
Find(queryOptions map[string]interface{}) (int, []*TaskAnomalyMark, error)
}
... ...
... ... @@ -386,3 +386,20 @@ func (c *TaskController) TaskAnomalyInfo() {
resp, err := srv.TaskAnomalyInfo(paramReq)
c.Response(resp, err)
}
// 任务管理列表,对异常点击操作
func (c *TaskController) TaskAnomalyMarkByTask() {
srv := service.NewTaskService()
paramReq := &command.MarkTaskAnomalyCommand{}
err := c.BindJSON(paramReq)
if err != nil {
e := application.ThrowError(application.ARG_ERROR, "json 解析错误"+err.Error())
c.Response(nil, e)
return
}
userReq := middlewares.GetUser(c.Ctx)
paramReq.CompanyId = int(userReq.CompanyId)
resp, err := srv.MarkTaskAnomalyByTask(paramReq)
c.Response(resp, err)
}
... ...
... ... @@ -32,6 +32,7 @@ func init() {
web.NSCtrlPost("/info", (*controllers.TaskController).GetTaskInfo),
web.NSCtrlPost("/ignore/list", (*controllers.TaskController).ListTaskIgnore),
web.NSCtrlPost("/ignore/cancel", (*controllers.TaskController).CancelIgnore),
web.NSCtrlPost("/mark_anomaly", (*controllers.TaskController).TaskAnomalyMarkByTask),
)
web.AddNamespace(taskFontNS)
taskAnomalyNS := web.NewNamespace("/v1/font/task_anomaly",
... ...