...
|
...
|
@@ -19,9 +19,8 @@ func (srv StaffAssessServeice) CreateStaffAssessTask(transactionContext applicat |
|
|
log.Logger.Debug("CreateStaffAssessTask 获取参数", map[string]interface{}{
|
|
|
"param": param,
|
|
|
})
|
|
|
assessTaskRepo := factory.CreateStaffAssessTaskRepository(map[string]interface{}{
|
|
|
"transactionContext": transactionContext,
|
|
|
})
|
|
|
assessTaskRepo := factory.CreateStaffAssessTaskRepository(map[string]interface{}{"transactionContext": transactionContext})
|
|
|
|
|
|
taskBeginTime, err := time.ParseInLocation("2006-01-02 15:04:05", param.BeginTime, time.Local)
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.ARG_ERROR, "任务开始时间填写错误,"+param.BeginTime)
|
...
|
...
|
@@ -123,15 +122,16 @@ func (srv StaffAssessServeice) CreateStaffAssessTask(transactionContext applicat |
|
|
}
|
|
|
stepList := domain.SortTaskStep(assessTaskData.StepList)
|
|
|
sort.Sort(stepList)
|
|
|
//保存 下发的每日评估
|
|
|
_, err = assessTaskRepo.Save(assessTaskData)
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "保存评估任务"+err.Error())
|
|
|
}
|
|
|
|
|
|
//保存 员工的需要填写的每日评估
|
|
|
assessRepo := factory.CreateStaffAssessRepository(map[string]interface{}{
|
|
|
"transactionContext": transactionContext,
|
|
|
})
|
|
|
assessRepo := factory.CreateStaffAssessRepository(map[string]interface{}{"transactionContext": transactionContext})
|
|
|
//保存 员工的需要填写的每日任务型 指标项
|
|
|
taskRecordRepo := factory.CreateTaskRecordRepository(map[string]interface{}{"transactionContext": transactionContext})
|
|
|
|
|
|
for i := range assessList {
|
|
|
assessList[i].StaffAssessTaskId = assessTaskData.Id
|
|
|
_, err = assessRepo.Save(&assessList[i])
|
...
|
...
|
@@ -141,7 +141,20 @@ func (srv StaffAssessServeice) CreateStaffAssessTask(transactionContext applicat |
|
|
if assessList[i].Types == domain.AssessSelf {
|
|
|
//添加待发送的短信通知
|
|
|
notify.AddNotifyStaffAssess(&assessList[i])
|
|
|
}
|
|
|
|
|
|
if assessList[i].Types == domain.AssessSelf {
|
|
|
//添加 指标任务
|
|
|
taskRecordList, err := srv.buildTaskRecord(&assessList[i])
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "构建个人任务型指标项"+err.Error())
|
|
|
}
|
|
|
for _, val2 := range taskRecordList {
|
|
|
_, err := taskRecordRepo.Insert(val2)
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "保存个人任务型指标项"+err.Error())
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
return map[string]interface{}{
|
...
|
...
|
@@ -381,7 +394,7 @@ func (srv StaffAssessServeice) buildStaffAssessSupper( |
|
|
|
|
|
// 按照评估模板中指标类型,创建里程碑任务
|
|
|
// staffAssess 每日自评评估
|
|
|
func (srv StaffAssessCacheService) buildTaskRecord(staffAssess *domain.StaffAssess) ([]*domain.TaskRecord, error) {
|
|
|
func (srv StaffAssessServeice) buildTaskRecord(staffAssess *domain.StaffAssess) ([]*domain.TaskRecord, error) {
|
|
|
transactionContext, err := factory.CreateTransactionContext(nil)
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
...
|
...
|
@@ -398,16 +411,25 @@ func (srv StaffAssessCacheService) buildTaskRecord(staffAssess *domain.StaffAsse |
|
|
itemUsedRepo := factory.CreateEvaluationItemUsedRepository(map[string]interface{}{
|
|
|
"transactionContext": transactionContext,
|
|
|
})
|
|
|
taskRepo := factory.CreateTaskRepository(map[string]interface{}{
|
|
|
"transactionContext": transactionContext,
|
|
|
})
|
|
|
taskStageRepo := factory.CreateTaskStageRepository(map[string]interface{}{
|
|
|
"transactionContext": transactionContext,
|
|
|
})
|
|
|
|
|
|
projectData, err := projectRepo.FindOne(map[string]interface{}{"id": staffAssess.EvaluationProjectId})
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.ARG_ERROR, "获取项目EvaluationProject信息"+err.Error())
|
|
|
}
|
|
|
|
|
|
// projectData.PrincipalId
|
|
|
userIdstr := strconv.Itoa(staffAssess.Executor.UserId)
|
|
|
if projectData.PrincipalId != userIdstr {
|
|
|
return nil, nil
|
|
|
}
|
|
|
_, evaluationItem, err := itemUsedRepo.Find(map[string]interface{}{
|
|
|
// 获取指标为任务类型的评估项
|
|
|
_, evaluationItemList, err := itemUsedRepo.Find(map[string]interface{}{
|
|
|
"indicatorType": domain.IndicatorTypeTask,
|
|
|
"evaluationProjectId": projectData.Id,
|
|
|
})
|
...
|
...
|
@@ -415,11 +437,59 @@ func (srv StaffAssessCacheService) buildTaskRecord(staffAssess *domain.StaffAsse |
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.ARG_ERROR, "获取评估项EvaluationItemUsed信息"+err.Error())
|
|
|
}
|
|
|
|
|
|
_ = evaluationItem
|
|
|
if len(evaluationItemList) == 0 {
|
|
|
return nil, nil
|
|
|
}
|
|
|
taskRecordList := []*domain.TaskRecord{}
|
|
|
for _, val := range evaluationItemList {
|
|
|
_, taskList, err := taskRepo.Find(map[string]interface{}{
|
|
|
"name": val.Name,
|
|
|
"leaderId": projectData.PrincipalId,
|
|
|
})
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.ARG_ERROR, "获取评估项指标任务task信息"+err.Error())
|
|
|
}
|
|
|
if len(taskList) == 0 {
|
|
|
continue
|
|
|
}
|
|
|
//获取里程碑数据
|
|
|
_, taskStageList, err := taskStageRepo.Find(map[string]interface{}{
|
|
|
"taskId": taskList[0].Id,
|
|
|
})
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.ARG_ERROR, "获取评估项指标任务里程碑TaskStage信息"+err.Error())
|
|
|
}
|
|
|
newTaskRecord := domain.TaskRecord{
|
|
|
Id: 0,
|
|
|
CompanyId: staffAssess.CompanyId,
|
|
|
StaffAssessId: staffAssess.Id,
|
|
|
TaskId: taskList[0].Id,
|
|
|
TaskCategory: val.Category,
|
|
|
TaskName: taskList[0].Name,
|
|
|
TaskAlias: taskList[0].Alias,
|
|
|
TaskLeader: taskList[0].Leader,
|
|
|
AssistLevel: 0,
|
|
|
AssistContent: "",
|
|
|
TaskStages: []domain.TaskStage{},
|
|
|
TaskStageCheck: domain.TaskStage{},
|
|
|
}
|
|
|
sort.Slice(taskStageList, func(i, j int) bool {
|
|
|
return taskStageList[i].SortBy < taskStageList[j].SortBy
|
|
|
})
|
|
|
for i2, val2 := range taskStageList {
|
|
|
newTaskRecord.TaskStages = append(newTaskRecord.TaskStages, *taskStageList[i2])
|
|
|
if newTaskRecord.TaskStageCheck.Id == 0 {
|
|
|
//按顺序第一个未完成的里程碑
|
|
|
if val2.RealCompletedAt <= 0 {
|
|
|
newTaskRecord.TaskStageCheck = *taskStageList[i2]
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
taskRecordList = append(taskRecordList, &newTaskRecord)
|
|
|
}
|
|
|
|
|
|
if err := transactionContext.CommitTransaction(); err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
|
|
return nil, nil
|
|
|
return taskRecordList, nil
|
|
|
} |
...
|
...
|
|