|
@@ -30,6 +30,7 @@ func (rs *EvaluationCycleService) Create(in *command.CreateCycleCommand) (interf |
|
@@ -30,6 +30,7 @@ func (rs *EvaluationCycleService) Create(in *command.CreateCycleCommand) (interf |
|
30
|
cycleRepository := factory.CreateEvaluationCycleRepository(map[string]interface{}{"transactionContext": transactionContext})
|
30
|
cycleRepository := factory.CreateEvaluationCycleRepository(map[string]interface{}{"transactionContext": transactionContext})
|
|
31
|
cycleTemplateRepository := factory.CreateEvaluationCycleTemplateRepository(map[string]interface{}{"transactionContext": transactionContext})
|
31
|
cycleTemplateRepository := factory.CreateEvaluationCycleTemplateRepository(map[string]interface{}{"transactionContext": transactionContext})
|
|
32
|
templateRepository := factory.CreateEvaluationTemplateRepository(map[string]interface{}{"transactionContext": transactionContext})
|
32
|
templateRepository := factory.CreateEvaluationTemplateRepository(map[string]interface{}{"transactionContext": transactionContext})
|
|
|
|
33
|
+ ruleRepository := factory.CreateEvaluationRuleRepository(map[string]interface{}{"transactionContext": transactionContext})
|
|
33
|
|
34
|
|
|
34
|
// 检测名称重复
|
35
|
// 检测名称重复
|
|
35
|
count, err := cycleRepository.Count(map[string]interface{}{"name": in.Name, "companyId": in.CompanyId})
|
36
|
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 |
|
@@ -48,6 +49,7 @@ func (rs *EvaluationCycleService) Create(in *command.CreateCycleCommand) (interf |
|
48
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "模板不存在, 请重新选择")
|
49
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "模板不存在, 请重新选择")
|
|
49
|
}
|
50
|
}
|
|
50
|
|
51
|
|
|
|
|
52
|
+ // 生成新周期数据
|
|
51
|
newCycle := &domain.EvaluationCycle{
|
53
|
newCycle := &domain.EvaluationCycle{
|
|
52
|
Id: 0,
|
54
|
Id: 0,
|
|
53
|
Name: in.Name,
|
55
|
Name: in.Name,
|
|
@@ -62,11 +64,41 @@ func (rs *EvaluationCycleService) Create(in *command.CreateCycleCommand) (interf |
|
@@ -62,11 +64,41 @@ func (rs *EvaluationCycleService) Create(in *command.CreateCycleCommand) (interf |
|
62
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
64
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
63
|
}
|
65
|
}
|
|
64
|
|
66
|
|
|
|
|
67
|
+ // 获取所有模板中的规则对象数据
|
|
|
|
68
|
+ ruleIds := make([]int64, 0)
|
|
|
|
69
|
+ ruleMap := map[int64]*domain.EvaluationRule{}
|
|
|
|
70
|
+ for i := range templates {
|
|
|
|
71
|
+ v := templates[i]
|
|
|
|
72
|
+ for j := range v.LinkNodes {
|
|
|
|
73
|
+ node := v.LinkNodes[j]
|
|
|
|
74
|
+ for k := range node.NodeContents {
|
|
|
|
75
|
+ nodeContent := node.NodeContents[k]
|
|
|
|
76
|
+ ruleIds = append(ruleIds, nodeContent.RuleId)
|
|
|
|
77
|
+ }
|
|
|
|
78
|
+ }
|
|
|
|
79
|
+ }
|
|
|
|
80
|
+ _, rules, err := ruleRepository.Find(map[string]interface{}{"ids": ruleIds, "companyId": in.CompanyId})
|
|
|
|
81
|
+ for i := range rules {
|
|
|
|
82
|
+ ruleMap[rules[i].Id] = rules[i]
|
|
|
|
83
|
+ }
|
|
|
|
84
|
+
|
|
65
|
ctAdapter := &adapter.CycleTemplateAdapter{}
|
85
|
ctAdapter := &adapter.CycleTemplateAdapter{}
|
|
66
|
ctAdapter.EvaluationCycle = cycle
|
86
|
ctAdapter.EvaluationCycle = cycle
|
|
67
|
-
|
|
|
|
68
|
for i := range templates {
|
87
|
for i := range templates {
|
|
69
|
v := templates[i]
|
88
|
v := templates[i]
|
|
|
|
89
|
+
|
|
|
|
90
|
+ // 对评估模板中的评估规则进行数据赋值
|
|
|
|
91
|
+ for j := range v.LinkNodes {
|
|
|
|
92
|
+ node := v.LinkNodes[j]
|
|
|
|
93
|
+ for k := range node.NodeContents {
|
|
|
|
94
|
+ nodeContent := node.NodeContents[k]
|
|
|
|
95
|
+ if rule, ok := ruleMap[nodeContent.RuleId]; ok {
|
|
|
|
96
|
+ nodeContent.Rule = rule
|
|
|
|
97
|
+ }
|
|
|
|
98
|
+ }
|
|
|
|
99
|
+ }
|
|
|
|
100
|
+
|
|
|
|
101
|
+ // 插入周期中的模板数据
|
|
70
|
cycleTemplate := &domain.EvaluationCycleTemplate{
|
102
|
cycleTemplate := &domain.EvaluationCycleTemplate{
|
|
71
|
Id: 0,
|
103
|
Id: 0,
|
|
72
|
Name: v.Name,
|
104
|
Name: v.Name,
|
|
@@ -78,10 +110,11 @@ func (rs *EvaluationCycleService) Create(in *command.CreateCycleCommand) (interf |
|
@@ -78,10 +110,11 @@ func (rs *EvaluationCycleService) Create(in *command.CreateCycleCommand) (interf |
|
78
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
110
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
79
|
}
|
111
|
}
|
|
80
|
|
112
|
|
|
|
|
113
|
+ // 输出模板简单信息
|
|
81
|
ctAdapter.TemplateSimples = append(ctAdapter.TemplateSimples, &domain.TemplateSimple{
|
114
|
ctAdapter.TemplateSimples = append(ctAdapter.TemplateSimples, &domain.TemplateSimple{
|
|
82
|
- Id: v.Id,
|
|
|
|
83
|
- Name: v.Name,
|
|
|
|
84
|
- CreatedAt: v.CreatedAt,
|
115
|
+ Id: cycleTemplate.Id,
|
|
|
|
116
|
+ Name: cycleTemplate.Name,
|
|
|
|
117
|
+ CreatedAt: cycleTemplate.CreatedAt,
|
|
85
|
})
|
118
|
})
|
|
86
|
}
|
119
|
}
|
|
87
|
|
120
|
|