作者 郑周

1. 里程碑记录优化

... ... @@ -1146,16 +1146,13 @@ func (srv StaffAssessServeice) SaveSelfAssess(in *command.SaveSelfAssessCommand)
}
assessContentRepo := factory.CreateStaffAssessContentRepository(map[string]interface{}{"transactionContext": transactionContext})
//待更新的评估填写信息
var assessContentList []*domain.StaffAssessContent
// 已完成
// 已完成会有评估内容数据
_, assessContentList, err = assessContentRepo.Find(map[string]interface{}{"staffAssessId": assessData.Id})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取项目填写内容"+err.Error())
}
if len(assessContentList) == 0 {
// 未完成获取评估内容
if len(assessContentList) == 0 { // 未完成获取评估内容
assessContentList, err = srv.getAssessInfoUncompletedV2(transactionContext, assessData)
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取项目填写内容"+err.Error())
... ... @@ -1168,7 +1165,7 @@ func (srv StaffAssessServeice) SaveSelfAssess(in *command.SaveSelfAssessCommand)
key := fmt.Sprintf("%s-%s", v.Category, v.Name)
paramContentMap[key] = in.AssessContent[i]
}
//更新的评估填写信息
// 更新的评估填写信息
for _, v := range assessContentList {
key := fmt.Sprintf("%s-%s", v.Category, v.Name)
item, ok := paramContentMap[key]
... ... @@ -1184,8 +1181,7 @@ func (srv StaffAssessServeice) SaveSelfAssess(in *command.SaveSelfAssessCommand)
v.Value = item.Value
if len(item.Value) > 0 {
// 转换填入的评估值
err = v.TransformValue()
err = v.TransformValue() // 转换评分评级填入的评估值
if err != nil {
return nil, application.ThrowError(application.BUSINESS_ERROR, v.Category+"-"+v.Name+":"+err.Error())
}
... ... @@ -1226,19 +1222,53 @@ func (srv StaffAssessServeice) SaveSelfAssess(in *command.SaveSelfAssessCommand)
}
}
// TODO 还差调用绪旭辉接口,更新里程碑状态
if len(in.AssessTaskStages) > 0 {
tsIds := make([]int, 0)
for i := range in.AssessTaskStages {
tsId := in.AssessTaskStages[i].TaskStageId
if tsId > 0 {
tsIds = append(tsIds, tsId)
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 {
it := in.AssessTaskStages[i]
recordIds = append(recordIds, it.TaskRecordId)
recordMap[it.TaskRecordId] = it
}
// 里程碑记录
//taskRecordRepository := factory.CreateTaskRecordRepository(map[string]interface{}{"transactionContext": transactionContext})
//taskRecordRepository.Find()
if len(recordIds) > 0 {
taskRecordRepository := factory.CreateTaskRecordRepository(map[string]interface{}{"transactionContext": transactionContext})
_, taskRecords, err := taskRecordRepository.Find(map[string]interface{}{"ids": recordIds})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取里程碑数据:"+err.Error())
}
for i := range taskRecords {
it := taskRecords[i]
if v, ok := recordMap[it.Id]; ok {
it.AssistLevel = v.AssistLevel // 更新上级辅导情况
it.AssistContent = v.AssistContent // 更新上级辅导内容
if v.TaskStageId == it.TaskStageCheck.Id { // 更新里程碑状态
it.TaskStageCheck.Status = v.Status
}
for j := range it.TaskStages {
if v.TaskStageId == it.TaskStages[j].Id { // 更新里程碑状态
it.TaskStages[j].Status = v.Status
}
}
_, err := taskRecordRepository.Insert(it)
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())
... ...
... ... @@ -28,6 +28,7 @@ type RemarkText struct {
type AssessTaskStage struct {
Category string `json:"category"`
Name string `json:"name"`
TaskRecordId int `json:"taskRecordId" comment:"任务记录ID"`
TaskStageId int `json:"taskStageId" comment:"里程碑ID"`
Status TaskStageState `json:"status" comment:"里程碑完成情况"`
AssistLevel int `json:"assistLevel" comment:"上级辅导情况"`
... ...
... ... @@ -14,7 +14,7 @@ type TaskRecord struct {
Id int `json:"id,string" comment:"ID"`
CompanyId int `json:"companyId,string" comment:"公司ID"`
StaffAssessId int `json:"staffAssessId,string" comment:"每日评估的ID"`
TaskId int `json:"taskId,string" comment:"里程碑任务的ID"`
TaskId int `json:"taskId,string" comment:"任务ID"`
TaskName string `json:"taskName" comment:"任务名称"`
TaskAlias string `json:"taskAlias" comment:"任务别名"`
TaskLeader TaskLeader `json:"taskLeader" comment:"任务负责人"`
... ...
... ... @@ -11,7 +11,7 @@ type TaskRecord struct {
Id int `comment:"ID" pg:"pk:id"`
CompanyId int `comment:"公司ID"`
StaffAssessId int `comment:"每日评估的ID"`
TaskId int `comment:"里程碑任务的ID"`
TaskId int `comment:"任务ID"`
TaskName string `comment:"任务名称"`
TaskAlias string `comment:"任务别名"`
TaskLeader domain.TaskLeader `comment:"任务负责人"`
... ...