作者 郑周

1. 增加 任务截止时间

... ... @@ -22,9 +22,12 @@ type AssessInfoResp struct {
SupperUser string `json:"superUser"` //目标用户的上级
DutyTime string `json:"dutyTime"` //入职时间
AssessContent []*domain.StaffAssessContent `json:"assessContent"` //评估内容
//CategoryTaskRecords []*domain.TaskRecord `json:"categoryTaskRecords"` //类别任务反馈记录
//AssessTaskRecords []*domain.TaskRecord `json:"assessTaskRecords"` //评估任务反馈记录
TaskRecords []*domain.TaskRecord `json:"taskRecords"` //里程碑内容
TaskRecords []*TaskRecordAdapter `json:"taskRecords"` //里程碑内容
}
type TaskRecordAdapter struct {
*domain.TaskRecord
EndTime int64 `json:"endTime"` // 任务截止的时间戳,单位:秒;等于0时表示未设置时间
}
// 周期内的每日自评小结
... ...
... ... @@ -909,25 +909,42 @@ func (srv StaffAssessServeice) GetAssessInfo(param *query.AssessInfoQuery) (*ada
srv.recoverAssessCache(transactionContext, assessData.Id, assessContentList)
}
taskRecords := make([]*domain.TaskRecord, 0) // 类别任务反馈记录
//categoryTaskRecords := make([]*domain.TaskRecord, 0) // 类别任务反馈记录
//assessTaskRecords := make([]*domain.TaskRecord, 0) // 评估项任务反馈记录
taskRecordAdapter := make([]*adapter.TaskRecordAdapter, 0) // 类别任务反馈记录
// 如果评估类型为自评、目标是登录用户时,获取所有任务记录数据
if assessData.Types == domain.AssessSelf || param.UserId == assessData.TargetUser.UserId {
taskRecordRepository := factory.CreateTaskRecordRepository(map[string]interface{}{"transactionContext": transactionContext})
_, taskRecords, err = taskRecordRepository.Find(map[string]interface{}{"staffAssessId": assessData.Id})
_, taskRecords, err := taskRecordRepository.Find(map[string]interface{}{"staffAssessId": assessData.Id})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取里程碑数据:"+err.Error())
}
//// 区分任务来源分类
//for i := range taskRecords {
// it := taskRecords[i]
// if it.TaskCreatedBy == 0 {
// categoryTaskRecords = append(categoryTaskRecords, it)
// } else {
// assessTaskRecords = append(assessTaskRecords, it)
// }
//}
taskIdMap := map[int]int{}
taskIdArray := make([]int, 0)
for _, v := range taskRecords {
taskIdMap[v.TaskId] = v.TaskId
}
for _, v := range taskIdMap {
taskIdArray = append(taskIdArray, v)
}
taskMap := map[int]*domain.Task{}
taskRepository := factory.CreateTaskRepository(map[string]interface{}{"transactionContext": transactionContext})
_, tasks, err := taskRepository.Find(map[string]interface{}{"ids": taskIdArray, "limit": len(taskIdArray)})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取里程碑数据:"+err.Error())
}
for i := range tasks {
taskMap[tasks[i].Id] = tasks[i]
}
for i := range taskRecords {
it := taskRecords[i]
a := &adapter.TaskRecordAdapter{}
a.TaskRecord = it
if v, ok := taskMap[it.TaskId]; ok {
a.EndTime = v.EndTime
}
taskRecordAdapter = append(taskRecordAdapter, a)
}
}
if err := transactionContext.CommitTransaction(); err != nil {
... ... @@ -952,9 +969,7 @@ func (srv StaffAssessServeice) GetAssessInfo(param *query.AssessInfoQuery) (*ada
SupperUser: "",
DutyTime: "",
AssessContent: assessContentList,
//CategoryTaskRecords: categoryTaskRecords,
//AssessTaskRecords: assessTaskRecords,
TaskRecords: taskRecords,
TaskRecords: taskRecordAdapter,
}
if len(assessContentList) == 0 {
result.AssessContent = []*domain.StaffAssessContent{}
... ...
... ... @@ -763,13 +763,11 @@ func (srv StaffAssessServeice) GetAssessSelfInfoV2(param *query.GetExecutorSelfA
cache = srv.recoverAssessCache(transactionContext, assessData.Id, assessContentList)
}
taskRecords := make([]*domain.TaskRecord, 0) // 类别任务反馈记录
//categoryTaskRecords := make([]*domain.TaskRecord, 0) // 类别任务反馈记录
//assessTaskRecords := make([]*domain.TaskRecord, 0) // 评估项任务反馈记录
taskRecordAdapter := make([]*adapter.TaskRecordAdapter, 0) // 类别任务反馈记录
// 如果评估类型为自评、目标是登录用户时,获取所有任务记录数据
if param.UserId == param.TargetUserId {
taskRecordRepository := factory.CreateTaskRecordRepository(map[string]interface{}{"transactionContext": transactionContext})
_, taskRecords, err = taskRecordRepository.Find(map[string]interface{}{"staffAssessId": assessData.Id})
_, taskRecords, err := taskRecordRepository.Find(map[string]interface{}{"staffAssessId": assessData.Id})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取里程碑数据:"+err.Error())
}
... ... @@ -777,15 +775,35 @@ func (srv StaffAssessServeice) GetAssessSelfInfoV2(param *query.GetExecutorSelfA
if param.AcquireCache != 0 {
srv.recoverCacheWithTaskRecord(cache, taskRecords)
}
//// 区分任务来源分类
//for i := range taskRecords {
// it := taskRecords[i]
// if it.TaskCreatedBy == 0 {
// categoryTaskRecords = append(categoryTaskRecords, it)
// } else {
// assessTaskRecords = append(assessTaskRecords, it)
// }
//}
taskIdMap := map[int]int{}
taskIdArray := make([]int, 0)
for _, v := range taskRecords {
taskIdMap[v.TaskId] = v.TaskId
}
for _, v := range taskIdMap {
taskIdArray = append(taskIdArray, v)
}
taskMap := map[int]*domain.Task{}
taskRepository := factory.CreateTaskRepository(map[string]interface{}{"transactionContext": transactionContext})
_, tasks, err := taskRepository.Find(map[string]interface{}{"ids": taskIdArray, "limit": len(taskIdArray)})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取里程碑数据:"+err.Error())
}
for i := range tasks {
taskMap[tasks[i].Id] = tasks[i]
}
for i := range taskRecords {
it := taskRecords[i]
a := &adapter.TaskRecordAdapter{}
a.TaskRecord = it
if v, ok := taskMap[it.TaskId]; ok {
a.EndTime = v.EndTime
}
taskRecordAdapter = append(taskRecordAdapter, a)
}
}
if err := transactionContext.CommitTransaction(); err != nil {
... ... @@ -810,9 +828,7 @@ func (srv StaffAssessServeice) GetAssessSelfInfoV2(param *query.GetExecutorSelfA
SupperUser: "",
DutyTime: "",
AssessContent: assessContentList,
//CategoryTaskRecords: categoryTaskRecords,
//AssessTaskRecords: assessTaskRecords,
TaskRecords: taskRecords,
TaskRecords: taskRecordAdapter,
}
if staffDesc != nil {
result.CompanyName = staffDesc.CompanyName
... ...
... ... @@ -145,6 +145,9 @@ func (repo *TaskRepository) Find(queryOptions map[string]interface{}) (int, []*d
if val, ok := queryOptions["id"]; ok {
query.Where("task.id=?", val)
}
if val, ok := queryOptions["ids"]; ok {
query.Where("task.id in(?)", pg.In(val))
}
if val, ok := queryOptions["leaderId"]; ok {
query.Where("task.leader->>'id'=?", val)
}
... ...