|
...
|
...
|
@@ -30,6 +30,7 @@ func (rs *EvaluationCycleService) Create(in *command.CreateCycleCommand) (interf |
|
|
|
cycleRepository := factory.CreateEvaluationCycleRepository(map[string]interface{}{"transactionContext": transactionContext})
|
|
|
|
cycleTemplateRepository := factory.CreateEvaluationCycleTemplateRepository(map[string]interface{}{"transactionContext": transactionContext})
|
|
|
|
templateRepository := factory.CreateEvaluationTemplateRepository(map[string]interface{}{"transactionContext": transactionContext})
|
|
|
|
ruleRepository := factory.CreateEvaluationRuleRepository(map[string]interface{}{"transactionContext": transactionContext})
|
|
|
|
|
|
|
|
// 检测名称重复
|
|
|
|
count, err := cycleRepository.Count(map[string]interface{}{"name": in.Name, "companyId": in.CompanyId})
|
|
...
|
...
|
@@ -48,6 +49,7 @@ func (rs *EvaluationCycleService) Create(in *command.CreateCycleCommand) (interf |
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "模板不存在, 请重新选择")
|
|
|
|
}
|
|
|
|
|
|
|
|
// 生成新周期数据
|
|
|
|
newCycle := &domain.EvaluationCycle{
|
|
|
|
Id: 0,
|
|
|
|
Name: in.Name,
|
|
...
|
...
|
@@ -62,11 +64,41 @@ func (rs *EvaluationCycleService) Create(in *command.CreateCycleCommand) (interf |
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
|
}
|
|
|
|
|
|
|
|
// 获取所有模板中的规则对象数据
|
|
|
|
ruleIds := make([]int64, 0)
|
|
|
|
ruleMap := map[int64]*domain.EvaluationRule{}
|
|
|
|
for i := range templates {
|
|
|
|
v := templates[i]
|
|
|
|
for j := range v.LinkNodes {
|
|
|
|
node := v.LinkNodes[j]
|
|
|
|
for k := range node.NodeContents {
|
|
|
|
nodeContent := node.NodeContents[k]
|
|
|
|
ruleIds = append(ruleIds, nodeContent.RuleId)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
_, rules, err := ruleRepository.Find(map[string]interface{}{"ids": ruleIds, "companyId": in.CompanyId})
|
|
|
|
for i := range rules {
|
|
|
|
ruleMap[rules[i].Id] = rules[i]
|
|
|
|
}
|
|
|
|
|
|
|
|
ctAdapter := &adapter.CycleTemplateAdapter{}
|
|
|
|
ctAdapter.EvaluationCycle = cycle
|
|
|
|
|
|
|
|
for i := range templates {
|
|
|
|
v := templates[i]
|
|
|
|
|
|
|
|
// 对评估模板中的评估规则进行数据赋值
|
|
|
|
for j := range v.LinkNodes {
|
|
|
|
node := v.LinkNodes[j]
|
|
|
|
for k := range node.NodeContents {
|
|
|
|
nodeContent := node.NodeContents[k]
|
|
|
|
if rule, ok := ruleMap[nodeContent.RuleId]; ok {
|
|
|
|
nodeContent.Rule = rule
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// 插入周期中的模板数据
|
|
|
|
cycleTemplate := &domain.EvaluationCycleTemplate{
|
|
|
|
Id: 0,
|
|
|
|
Name: v.Name,
|
|
...
|
...
|
@@ -78,10 +110,11 @@ func (rs *EvaluationCycleService) Create(in *command.CreateCycleCommand) (interf |
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
|
}
|
|
|
|
|
|
|
|
// 输出模板简单信息
|
|
|
|
ctAdapter.TemplateSimples = append(ctAdapter.TemplateSimples, &domain.TemplateSimple{
|
|
|
|
Id: v.Id,
|
|
|
|
Name: v.Name,
|
|
|
|
CreatedAt: v.CreatedAt,
|
|
|
|
Id: cycleTemplate.Id,
|
|
|
|
Name: cycleTemplate.Name,
|
|
|
|
CreatedAt: cycleTemplate.CreatedAt,
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
...
|
...
|
|