...
|
...
|
@@ -352,21 +352,89 @@ func (srv StaffAssessServeice) CreateStaffAssessTask(transactionContext applicat |
|
|
}
|
|
|
nowTime := time.Now()
|
|
|
|
|
|
_, assassessTaskList, err := assessTaskRepo.Find(map[string]interface{}{
|
|
|
"evaluationProjectId": param.EvaluationProjectId,
|
|
|
"beginDay": taskBeginTime.Local().Format("2006-01-02"),
|
|
|
})
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "查询同日期同项目已存在的评估任务"+err.Error())
|
|
|
}
|
|
|
var assessTaskData *domain.StaffAssessTask
|
|
|
//更新旧数据或者新建数据
|
|
|
if len(assassessTaskList) > 0 {
|
|
|
assessTaskData = assassessTaskList[0]
|
|
|
assessTaskData.UpdatedAt = nowTime
|
|
|
} else {
|
|
|
//建立新的评估任务
|
|
|
assessTaskData = &domain.StaffAssessTask{
|
|
|
// _, assassessTaskList, err := assessTaskRepo.Find(map[string]interface{}{
|
|
|
// "evaluationProjectId": param.EvaluationProjectId,
|
|
|
// "beginDay": taskBeginTime.Local().Format("2006-01-02"),
|
|
|
// })
|
|
|
// if err != nil {
|
|
|
// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "查询同日期同项目已存在的评估任务"+err.Error())
|
|
|
// }
|
|
|
// var assessTaskData *domain.StaffAssessTask
|
|
|
// //更新旧数据或者新建数据
|
|
|
// if len(assassessTaskList) > 0 {
|
|
|
// assessTaskData = assassessTaskList[0]
|
|
|
// assessTaskData.UpdatedAt = nowTime
|
|
|
// } else {
|
|
|
// //建立新的评估任务
|
|
|
// assessTaskData = &domain.StaffAssessTask{
|
|
|
// Id: 0,
|
|
|
// CompanyId: param.CompanyId,
|
|
|
// EvaluationProjectId: param.EvaluationProjectId,
|
|
|
// EvaluationProjectName: param.EvaluationProjectName,
|
|
|
// CycleId: param.CycleId,
|
|
|
// CycleName: param.CycleName,
|
|
|
// BeginTime: taskBeginTime,
|
|
|
// EndTime: taskEndTime,
|
|
|
// StepList: []domain.AssessTaskStep{},
|
|
|
// ExecutorId: []int{},
|
|
|
// CreatedAt: nowTime,
|
|
|
// UpdatedAt: nowTime,
|
|
|
// DeletedAt: nil,
|
|
|
// BeginDay: taskBeginTime.Local().Format("2006-01-02"),
|
|
|
// }
|
|
|
// }
|
|
|
// executorIds := []int{} //提取评估的参与人id
|
|
|
// executorIdMap := map[int]struct{}{} //过滤重复的用户
|
|
|
// //从入参中提取参与人
|
|
|
// for _, v := range param.ExecutorId {
|
|
|
// if _, ok := executorIdMap[v]; ok {
|
|
|
// continue
|
|
|
// }
|
|
|
// executorIdMap[v] = struct{}{}
|
|
|
// executorIds = append(executorIds, v)
|
|
|
// }
|
|
|
// //就数据中提取参与人
|
|
|
// for _, v := range assessTaskData.ExecutorId {
|
|
|
// if _, ok := executorIdMap[v]; ok {
|
|
|
// continue
|
|
|
// }
|
|
|
// executorIdMap[v] = struct{}{}
|
|
|
// executorIds = append(executorIds, v)
|
|
|
// }
|
|
|
// //填入新的参与人id
|
|
|
// assessTaskData.ExecutorId = executorIds
|
|
|
// //填充新的评估环节
|
|
|
// loop:
|
|
|
// for _, v := range param.StepList {
|
|
|
// for _, vv := range assessTaskData.StepList {
|
|
|
// if vv.LinkNodeId == v.LinkNodeId {
|
|
|
// continue loop
|
|
|
// }
|
|
|
// }
|
|
|
// stepBeginTime, 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)
|
|
|
// }
|
|
|
// stepEndTime, err := time.ParseInLocation("2006-01-02 15:04:05", param.EndTime, time.Local)
|
|
|
// if err != nil {
|
|
|
// return nil, application.ThrowError(application.ARG_ERROR, "评估环节结束时间填写错误,"+param.EndTime)
|
|
|
// }
|
|
|
// step := domain.AssessTaskStep{
|
|
|
// SortBy: v.SortBy,
|
|
|
// LinkNodeId: v.LinkNodeId,
|
|
|
// LinkNodeName: v.LinkNodeName,
|
|
|
// LinkNodeType: v.LinkNodeType,
|
|
|
// BeginTime: stepBeginTime,
|
|
|
// EndTime: stepEndTime,
|
|
|
// }
|
|
|
// assessTaskData.StepList = append(assessTaskData.StepList, step)
|
|
|
// }
|
|
|
// //排序流程环节
|
|
|
// stepList := domain.SortTaskStep(assessTaskData.StepList)
|
|
|
// sort.Sort(stepList)
|
|
|
// assessTaskData.StepList = stepList
|
|
|
|
|
|
assessTaskData := &domain.StaffAssessTask{
|
|
|
Id: 0,
|
|
|
CompanyId: param.CompanyId,
|
|
|
EvaluationProjectId: param.EvaluationProjectId,
|
...
|
...
|
@@ -382,7 +450,6 @@ func (srv StaffAssessServeice) CreateStaffAssessTask(transactionContext applicat |
|
|
DeletedAt: nil,
|
|
|
BeginDay: taskBeginTime.Local().Format("2006-01-02"),
|
|
|
}
|
|
|
}
|
|
|
executorIds := []int{} //提取评估的参与人id
|
|
|
executorIdMap := map[int]struct{}{} //过滤重复的用户
|
|
|
//从入参中提取参与人
|
...
|
...
|
@@ -393,24 +460,8 @@ func (srv StaffAssessServeice) CreateStaffAssessTask(transactionContext applicat |
|
|
executorIdMap[v] = struct{}{}
|
|
|
executorIds = append(executorIds, v)
|
|
|
}
|
|
|
//就数据中提取参与人
|
|
|
for _, v := range assessTaskData.ExecutorId {
|
|
|
if _, ok := executorIdMap[v]; ok {
|
|
|
continue
|
|
|
}
|
|
|
executorIdMap[v] = struct{}{}
|
|
|
executorIds = append(executorIds, v)
|
|
|
}
|
|
|
//填入新的参与人id
|
|
|
assessTaskData.ExecutorId = executorIds
|
|
|
//填充新的评估环节
|
|
|
loop:
|
|
|
for _, v := range param.StepList {
|
|
|
for _, vv := range assessTaskData.StepList {
|
|
|
if vv.LinkNodeId == v.LinkNodeId {
|
|
|
continue loop
|
|
|
}
|
|
|
}
|
|
|
stepBeginTime, 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)
|
...
|
...
|
@@ -429,20 +480,45 @@ loop: |
|
|
}
|
|
|
assessTaskData.StepList = append(assessTaskData.StepList, step)
|
|
|
}
|
|
|
//排序流程环节
|
|
|
stepList := domain.SortTaskStep(assessTaskData.StepList)
|
|
|
sort.Sort(stepList)
|
|
|
assessTaskData.StepList = stepList
|
|
|
//添加员工的节点任务
|
|
|
assessList, err := srv.createStaffAssess(transactionContext, assessTaskData)
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "生成个人评估项"+err.Error())
|
|
|
}
|
|
|
|
|
|
//合并项目评估的新旧数据
|
|
|
_, assassessTaskList, err := assessTaskRepo.Find(map[string]interface{}{
|
|
|
"evaluationProjectId": param.EvaluationProjectId,
|
|
|
"beginDay": taskBeginTime.Local().Format("2006-01-02"),
|
|
|
})
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "查询同日期同项目已存在的评估任务"+err.Error())
|
|
|
}
|
|
|
|
|
|
if len(assassessTaskList) > 0 {
|
|
|
//就数据中提取参与人
|
|
|
for _, v := range assessTaskData.ExecutorId {
|
|
|
if _, ok := executorIdMap[v]; ok {
|
|
|
continue
|
|
|
}
|
|
|
executorIdMap[v] = struct{}{}
|
|
|
executorIds = append(executorIds, v)
|
|
|
}
|
|
|
assassessTaskList[0].UpdatedAt = time.Now()
|
|
|
assassessTaskList[0].ExecutorId = executorIds
|
|
|
//更新步骤
|
|
|
assassessTaskList[0].StepList = append(assassessTaskList[0].StepList, assessTaskData.StepList...)\
|
|
|
asassessTaskData=asassassessTaskList[0]
|
|
|
//排序流程环节
|
|
|
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,
|
|
|
})
|
...
|
...
|
@@ -453,6 +529,9 @@ loop: |
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "保存个人评估项"+err.Error())
|
|
|
}
|
|
|
}
|
|
|
|
|
|
//处理生成的项目评估
|
|
|
|
|
|
return map[string]interface{}{
|
|
|
"assessTaskId": assessTaskData.Id,
|
|
|
}, nil
|
...
|
...
|
|