作者 tangxvhui

更新

... ... @@ -414,5 +414,4 @@ func (srv *MessagePersonalService) TodayMessageTaskRecordAnomaly(param *command.
resp["needNotify"] = false
}
return resp, nil
}
... ...
package adapter
type TaskRecordAdapter struct {
Id int `json:"id,string" ` //comment:"记录ID"
StaffAssessId int `json:"staffAssessId,string" ` //comment:"每日评估的ID"
TaskId int `json:"taskId,string" ` //comment:"任务ID"
TaskCategory string `json:"taskCategory" ` //comment:"任务类别"
TaskName string `json:"taskName" ` //comment:"任务名称"
TaskAlias string `json:"taskAlias" ` //comment:"任务别名"
TaskLeader string `json:"taskLeader"` //comment:"任务负责人"
AssistLevel int `json:"assistLevel" ` //comment:"上级辅导情况"
AssistContent string `json:"assistContent" ` //comment:"上级辅导内容"
TaskStageCheck TaskStage `json:"taskStageCheck" ` //comment:"提交的里程碑"
CreatedAt string `json:"createdAt" ` //格式2006-01-02comment:"创建时间"
}
... ...
package command
type ListTaskRecordCommand struct {
TaskId int `json:"taskId,string"`
CompanyId int `json:"-"`
}
... ...
... ... @@ -704,7 +704,7 @@ func (srv TaskService) ListTask2(param *command.SearchTaskCommand) (map[string]i
}
// 以hrbp角色权限获取任务列表
// TODO 统计里程碑异常数,反馈异常数
// 统计里程碑异常数,反馈异常数
func (srv TaskService) listTask2ForHrbp(param *command.SearchTaskCommand) (map[string]interface{}, error) {
var limit = 20
var offset = 0
... ... @@ -848,3 +848,62 @@ func (srv TaskService) ReplyTaskStage(transactionContext application.Transaction
}
return nil
}
// 获取任务的反馈
func (srv TaskService) ListTaskRecord(param *command.ListTaskRecordCommand) (map[string]interface{}, error) {
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()
}()
taskRecordRepo := factory.CreateTaskRecordRepository(map[string]interface{}{
"transactionContext": transactionContext,
})
cnt, taskRecordList, err := taskRecordRepo.Find(map[string]interface{}{
"companyId": param.CompanyId,
"taskId": param.TaskId,
})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取任务反馈数据"+err.Error())
}
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
resultList := []adapter.TaskRecordAdapter{}
for _, val := range taskRecordList {
item := adapter.TaskRecordAdapter{
Id: val.Id,
StaffAssessId: val.StaffAssessId,
TaskId: val.TaskId,
TaskCategory: val.TaskCategory,
TaskName: val.TaskName,
TaskAlias: val.TaskAlias,
TaskLeader: val.TaskLeader.Name,
AssistLevel: val.AssistLevel,
AssistContent: val.AssistContent,
TaskStageCheck: adapter.TaskStage{
Id: val.Id,
Name: val.TaskStageCheck.Name,
StatusDescription: val.TaskStageCheck.StatusDescription(),
SortBy: val.TaskStageCheck.SortBy,
PlanCompletedAt: "",
RealCompletedAt: "",
},
CreatedAt: val.CreatedAt.Local().Format("2006-01-02"),
}
t1 := time.Unix(val.TaskStageCheck.PlanCompletedAt, 0).Local().Format("2006-01-02")
item.TaskStageCheck.PlanCompletedAt = t1
if val.TaskStageCheck.RealCompletedAt > 0 {
t2 := time.Unix(val.TaskStageCheck.RealCompletedAt, 0).Local().Format("2006-01-02")
item.TaskStageCheck.RealCompletedAt = t2
}
resultList = append(resultList, item)
}
result := tool_funs.SimpleWrapGridMap(int64(cnt), resultList)
return result, nil
}
... ...
... ... @@ -22,6 +22,7 @@ const (
MessageTypesOther MessageTypes = "other" //综合自评开启时,消息通知
MessageTypesTaskStage MessageTypes = "task_stage" //任务里程碑未按时完成
MessageTypesTaskRecord MessageTypes = "task_record" //任务每日反馈异常
MessageTypesTaskModify MessageTypes = "task_modify" //修改任务
)
type MessageReadFlag string
... ...
... ... @@ -3,12 +3,13 @@ package repository
import (
"errors"
"fmt"
"time"
"github.com/go-pg/pg/v10"
pgTransaction "github.com/linmadan/egglib-go/transaction/pg"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/infrastructure/pg/models"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/utils"
"time"
)
type TaskRecordRepository struct {
... ... @@ -146,6 +147,9 @@ func (repo *TaskRecordRepository) Find(queryOptions map[string]interface{}) (int
query.Where("staff_assess_id = ?", v)
}
if v, ok := queryOptions["taskId"]; ok {
query.Where("task_id = ?", v)
}
if v, ok := queryOptions["limit"].(int64); ok {
query.Limit(int(v))
}
... ...