作者 郑周

1.任务记录 新增反馈内容字段

2.任务记录 新增任务创建来源字段
3.获取、编辑自评输入输出 调整
4.缓存调整
... ... @@ -22,7 +22,9 @@ type AssessInfoResp struct {
SupperUser string `json:"superUser"` //目标用户的上级
DutyTime string `json:"dutyTime"` //入职时间
AssessContent []*domain.StaffAssessContent `json:"assessContent"` //评估内容
TaskRecords []*domain.TaskRecord `json:"taskRecords"` //里程碑内容
//CategoryTaskRecords []*domain.TaskRecord `json:"categoryTaskRecords"` //类别任务反馈记录
//AssessTaskRecords []*domain.TaskRecord `json:"assessTaskRecords"` //评估任务反馈记录
TaskRecords []*domain.TaskRecord `json:"taskRecords"` //里程碑内容
}
// 周期内的每日自评小结
... ...
... ... @@ -10,6 +10,7 @@ type SaveAssessCacheCommand struct {
AssessId int64 `cname:"评估项ID" json:"assessId,string"`
AssessContent []domain.AssessContent `cname:"评估数据" json:"assessContent"`
AssessTaskStages []domain.AssessTaskStage `cname:"里程碑内容" json:"assessTaskStages"`
//CategoryTaskStages []domain.AssessTaskStage `cname:"里程碑内容" json:"categoryTaskStages"`
}
func (in *SaveAssessCacheCommand) Valid(validation *validation.Validation) {
... ...
... ... @@ -16,5 +16,5 @@ type SaveSelfAssessCommand struct {
ExecutorId int `json:"executorId" comment:"填写人ID"`
CompanyId int `json:"companyId" comment:"公司ID"`
AssessContent []domain.AssessContent `json:"assessContent" comment:"填写内容"`
AssessTaskStages []domain.AssessTaskStage `json:"assessTaskStages" comment:"里程碑内容"`
AssessTaskStages []domain.AssessTaskStage `json:"assessTaskStages" comment:"评估反馈填写内容"`
}
... ...
... ... @@ -3,6 +3,7 @@ package query
//获取评估任务详情
type AssessInfoQuery struct {
AssessId int `json:"assessId"` // 评估项ID
UserId int `json:"userId"` // 用户ID
CompanyId int `json:"companyId"` // 公司ID
AcquireCache int `json:"acquireCache"` // 0不获取缓存数据,1获取缓存数据
}
... ...
... ... @@ -2,6 +2,7 @@ package query
// 根据周期和日期,获取员工的自评内容
type GetExecutorSelfAssessQuery struct {
UserId int `json:"userId"` //
CompanyId int `json:"companyId"` //
TargetUserId int `json:"targetUserId,string"` //评估的执行人,必填
CycleId int `json:"cycleId,string"` //评估周期id 必填
... ...
... ... @@ -909,26 +909,24 @@ func (srv StaffAssessServeice) GetAssessInfo(param *query.AssessInfoQuery) (*ada
srv.recoverAssessCache(transactionContext, assessData.Id, assessContentList)
}
// 获取项目信息
projectRepository := factory.CreateEvaluationProjectRepository(map[string]interface{}{"transactionContext": transactionContext})
project, err := projectRepository.FindOne(map[string]interface{}{"id": assessData.EvaluationProjectId})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取项目错误:"+err.Error())
}
taskRecords := make([]*domain.TaskRecord, 0)
// 任务负责人才能显示里程碑数据
if project.PrincipalId == strconv.Itoa(assessData.TargetUser.UserId) {
// 获取里程碑数据
taskRecords := make([]*domain.TaskRecord, 0) // 类别任务反馈记录
//categoryTaskRecords := make([]*domain.TaskRecord, 0) // 类别任务反馈记录
//assessTaskRecords := make([]*domain.TaskRecord, 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})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取里程碑数据:"+err.Error())
}
//// 恢复缓存数据(里程碑记录)这里可以不用恢复任务里程碑数据
//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)
// }
//}
}
... ... @@ -954,7 +952,9 @@ func (srv StaffAssessServeice) GetAssessInfo(param *query.AssessInfoQuery) (*ada
SupperUser: "",
DutyTime: "",
AssessContent: assessContentList,
TaskRecords: taskRecords,
//CategoryTaskRecords: categoryTaskRecords,
//AssessTaskRecords: assessTaskRecords,
TaskRecords: taskRecords,
}
if len(assessContentList) == 0 {
result.AssessContent = []*domain.StaffAssessContent{}
... ... @@ -1255,16 +1255,6 @@ func (srv StaffAssessServeice) SaveSelfAssess(in *command.SaveSelfAssessCommand)
// 更新里程碑数据
if len(in.AssessTaskStages) > 0 {
projectRepository := factory.CreateEvaluationProjectRepository(map[string]interface{}{"transactionContext": transactionContext})
project, err := projectRepository.FindOne(map[string]interface{}{"id": assessData.EvaluationProjectId})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取项目错误:"+err.Error())
}
// 任务负责人才能提交里程碑数据
if project.PrincipalId != strconv.Itoa(in.ExecutorId) {
return nil, application.ThrowError(application.BUSINESS_ERROR, "当前用户没有里程碑提交权限")
}
recordMap := map[int]domain.AssessTaskStage{}
recordIds := make([]int, 0)
for i := range in.AssessTaskStages {
... ... @@ -1289,9 +1279,9 @@ func (srv StaffAssessServeice) SaveSelfAssess(in *command.SaveSelfAssessCommand)
var anomalyState = domain.AnomalyState0
key := fmt.Sprintf("%s-%s", v.Category, v.Name)
// 反馈内容填写
if item, ok := contentCategoryMap[key]; ok {
it.RemarkContent = append(it.RemarkContent, item.Remark...)
for _, remark := range item.Remark {
trimSpace := strings.TrimLeft(remark.RemarkText, "\n") // 去掉前换行符
trimSpace = strings.TrimRight(trimSpace, "\n") // 去掉后换行符
... ... @@ -1301,6 +1291,8 @@ func (srv StaffAssessServeice) SaveSelfAssess(in *command.SaveSelfAssessCommand)
break
}
}
} else {
it.RemarkContent = append(it.RemarkContent, v.RemarkContent...)
}
//if anomalyState == domain.AnomalyState0 {
// trimSpace := strings.TrimLeft(it.AssistContent, "\n") // 去掉前换行符
... ... @@ -1418,6 +1410,8 @@ func (srv StaffAssessServeice) recoverCacheWithTaskRecord(cache *domain.StaffAss
if item, ok := cacheMap[it.Id]; ok {
it.AssistLevel = item.AssistLevel
it.AssistContent = item.AssistContent
it.RemarkContent = make([]domain.RemarkText, 0)
it.RemarkContent = append(it.RemarkContent, item.RemarkContent...)
}
}
}
... ...
... ... @@ -707,7 +707,7 @@ func (srv StaffAssessServeice) ListExecutorSupperAssessV2(param *query.ListExecu
return result, nil
}
// 根据周期和日期,获取员工的自评内容
// 根据周期和日期,获取员工的自评内容(编辑)
func (srv StaffAssessServeice) GetAssessSelfInfoV2(param *query.GetExecutorSelfAssessQuery) (*adapter.AssessInfoResp, error) {
transactionContext, err := factory.CreateTransactionContext(nil)
if err != nil {
... ... @@ -762,27 +762,30 @@ func (srv StaffAssessServeice) GetAssessSelfInfoV2(param *query.GetExecutorSelfA
if param.AcquireCache != 0 {
cache = srv.recoverAssessCache(transactionContext, assessData.Id, assessContentList)
}
// 获取项目信息
projectRepository := factory.CreateEvaluationProjectRepository(map[string]interface{}{"transactionContext": transactionContext})
project, err := projectRepository.FindOne(map[string]interface{}{"id": assessData.EvaluationProjectId})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取项目错误:"+err.Error())
}
taskRecords := make([]*domain.TaskRecord, 0)
// 任务负责人才能显示里程碑数据
if project.PrincipalId == strconv.Itoa(param.TargetUserId) {
// 获取里程碑数据
taskRecords := make([]*domain.TaskRecord, 0) // 类别任务反馈记录
//categoryTaskRecords := make([]*domain.TaskRecord, 0) // 类别任务反馈记录
//assessTaskRecords := make([]*domain.TaskRecord, 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())
}
// 恢复缓存数据(里程碑记录)
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)
// }
//}
}
if err := transactionContext.CommitTransaction(); err != nil {
... ... @@ -807,7 +810,9 @@ func (srv StaffAssessServeice) GetAssessSelfInfoV2(param *query.GetExecutorSelfA
SupperUser: "",
DutyTime: "",
AssessContent: assessContentList,
TaskRecords: taskRecords,
//CategoryTaskRecords: categoryTaskRecords,
//AssessTaskRecords: assessTaskRecords,
TaskRecords: taskRecords,
}
if staffDesc != nil {
result.CompanyName = staffDesc.CompanyName
... ...
... ... @@ -40,6 +40,7 @@ type AssessTaskStage struct {
Check TaskStageCheck `json:"check" comment:"里程碑完成情况"`
AssistLevel int `json:"assistLevel" comment:"上级辅导情况"`
AssistContent string `json:"assistContent" comment:"上级辅导内容"`
RemarkContent []RemarkText `json:"remarkContent" comment:"填写任务进度"`
}
type StaffAssessCacheRepository interface {
... ...
... ... @@ -36,7 +36,7 @@ type TaskRecord struct {
CreatedAt time.Time `json:"createdAt" comment:"创建时间"`
UpdatedAt time.Time `json:"updatedAt" comment:"更新时间"`
DeletedAt *time.Time `json:"deletedAt" comment:"删除时间"`
TaskCreatedBy int `json:"taskCreatedBy" comment:"任务的创建方式"` // 任务的创建方式 0: 根据模板中的任务创建,1:页面主动直接创建
TaskCreatedBy int `json:"taskCreatedBy" comment:"任务的创建方式"` // 任务的创建方式 0: 模板导入创建,1:主动创建
}
type TaskRecordRepository interface {
... ...
... ... @@ -25,4 +25,5 @@ type TaskRecord struct {
CreatedAt time.Time `comment:"创建时间"`
UpdatedAt time.Time `comment:"更新时间"`
DeletedAt *time.Time `comment:"删除时间"`
TaskCreatedBy int `comment:"任务的创建来源"`
}
... ...
... ... @@ -39,6 +39,7 @@ func (repo *TaskRecordRepository) TransformToDomain(m *models.TaskRecord) domain
CreatedAt: m.CreatedAt.Local(),
UpdatedAt: m.UpdatedAt.Local(),
DeletedAt: m.DeletedAt,
TaskCreatedBy: m.TaskCreatedBy,
}
}
... ... @@ -61,6 +62,7 @@ func (repo *TaskRecordRepository) TransformToModel(d *domain.TaskRecord) models.
CreatedAt: d.CreatedAt,
UpdatedAt: d.UpdatedAt,
DeletedAt: d.DeletedAt,
TaskCreatedBy: d.TaskCreatedBy,
}
}
... ...
... ... @@ -90,9 +90,9 @@ func (c *StaffAssessController) GetAssessInfo() {
c.Response(nil, e)
return
}
// paramReq.CompanyId = 1
userReq := middlewares.GetUser(c.Ctx)
paramReq.CompanyId = int(userReq.CompanyId)
paramReq.UserId = int(userReq.UserId)
data, err := srv.GetAssessInfo(paramReq)
c.Response(data, err)
}
... ...
... ... @@ -111,6 +111,7 @@ func (c *StaffAssessControllerV2) GetAssessSelfMeInfo() {
return
}
userReq := middlewares.GetUser(c.Ctx)
paramReq.UserId = int(userReq.UserId)
paramReq.CompanyId = int(userReq.CompanyId)
paramReq.TargetUserId = int(userReq.UserId)
data, err := srv.GetAssessSelfInfoV2(paramReq)
... ... @@ -128,6 +129,7 @@ func (c *StaffAssessControllerV2) GetAssessTargetUserSelfInfo() {
return
}
userReq := middlewares.GetUser(c.Ctx)
paramReq.UserId = int(userReq.UserId)
paramReq.CompanyId = int(userReq.CompanyId)
data, err := srv.GetAssessSelfInfoV2(paramReq)
c.Response(data, err)
... ...
-- 增加任务记录字段-填写反馈进度
-- 增加任务记录字段
ALTER TABLE public.task_record
ADD remark_content jsonb NULL;
COMMENT ON COLUMN public.task_record.remark_content IS '填写反馈进度';
-- 增加任务记录字段
ALTER TABLE public.task_record
ADD task_created_by int NOT NULL DEFAULT 0;
COMMENT ON COLUMN public.task_record.task_created_by IS '任务的创建来源';
... ...