...
|
...
|
@@ -525,7 +525,9 @@ func (rs *EvaluationProjectService) Activate(in *command.ActivateProjectCommand) |
|
|
if project.State == domain.ProjectStateEnable {
|
|
|
return nil, application.ThrowError(application.BUSINESS_ERROR, "项目已启动")
|
|
|
}
|
|
|
|
|
|
if project.State == domain.ProjectStatePause {
|
|
|
return nil, application.ThrowError(application.BUSINESS_ERROR, "项目暂停中,先进行恢复")
|
|
|
}
|
|
|
// 周期内的所有项目,已启用的员工不能重复被评估
|
|
|
_, projects, err := projectRepository.Find(map[string]interface{}{"companyId": project.CompanyId, "cycleId": project.CycleId}, "template")
|
|
|
if err != nil {
|
...
|
...
|
@@ -625,7 +627,7 @@ func (rs *EvaluationProjectService) Activate(in *command.ActivateProjectCommand) |
|
|
task.NextSentAt = nil
|
|
|
}
|
|
|
|
|
|
task, err := taskRepository.Insert(task)
|
|
|
_, err := taskRepository.Insert(task)
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
...
|
...
|
@@ -871,6 +873,17 @@ func (rs *EvaluationProjectService) CheckRecipients(in *command.CheckRecipientCo |
|
|
}
|
|
|
|
|
|
func (rs *EvaluationProjectService) generateEvaluationItemUsed(transactionContext application.TransactionContext, project *domain.EvaluationProject) error {
|
|
|
itemUsedRepo := factory.CreateEvaluationItemUsedRepository(map[string]interface{}{
|
|
|
"transactionContext": transactionContext,
|
|
|
})
|
|
|
var err error
|
|
|
cnt, _, err := itemUsedRepo.Find(map[string]interface{}{"projectId": project.Id})
|
|
|
if err != nil {
|
|
|
return application.ThrowError(application.TRANSACTION_ERROR, "检查评估选项"+err.Error())
|
|
|
}
|
|
|
if cnt > 0 {
|
|
|
return nil
|
|
|
}
|
|
|
var itemUsedList []*domain.EvaluationItemUsed
|
|
|
nowTime := time.Now()
|
|
|
for _, v := range project.Template.LinkNodes {
|
...
|
...
|
@@ -901,10 +914,8 @@ func (rs *EvaluationProjectService) generateEvaluationItemUsed(transactionContex |
|
|
itemUsedList = append(itemUsedList, &item)
|
|
|
}
|
|
|
}
|
|
|
itemUsedRepo := factory.CreateEvaluationItemUsedRepository(map[string]interface{}{
|
|
|
"transactionContext": transactionContext,
|
|
|
})
|
|
|
err := itemUsedRepo.BatchInsert(itemUsedList)
|
|
|
|
|
|
err = itemUsedRepo.BatchInsert(itemUsedList)
|
|
|
if err != nil {
|
|
|
return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
...
|
...
|
|