正在显示
3 个修改的文件
包含
171 行增加
和
0 行删除
@@ -922,3 +922,65 @@ func (srv StaffAssessServeice) SelectAssessInviteUserV2(param *query.SelectAsses | @@ -922,3 +922,65 @@ func (srv StaffAssessServeice) SelectAssessInviteUserV2(param *query.SelectAsses | ||
922 | } | 922 | } |
923 | return tool_funs.SimpleWrapGridMap(int64(cnt), listData), nil | 923 | return tool_funs.SimpleWrapGridMap(int64(cnt), listData), nil |
924 | } | 924 | } |
925 | + | ||
926 | +// 获取未完成的员工评估内容 | ||
927 | +// func (srv StaffAssessServeice) getAssessInfoUncompletedV2(transactionContext application.TransactionContext, | ||
928 | +// assess *domain.StaffAssess) ([]*domain.StaffAssessContent, error) { | ||
929 | +// evaluationItemRepo := factory.CreateEvaluationItemUsedRepository(map[string]interface{}{ | ||
930 | +// "transactionContext": transactionContext, | ||
931 | +// }) | ||
932 | +// var evaluationItemList []*domain.EvaluationItemUsed | ||
933 | +// var err error | ||
934 | +// _, evaluationItemList, err = evaluationItemRepo.Find(map[string]interface{}{ | ||
935 | +// "evaluationProjectId": assess.EvaluationProjectId, | ||
936 | +// "nodeId": assess.LinkNodeId, | ||
937 | +// }) | ||
938 | +// if err != nil { | ||
939 | +// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取项目填写内容"+err.Error()) | ||
940 | +// } | ||
941 | +// if len(evaluationItemList) == 0 { | ||
942 | +// //如果当前节点没有评估内容,就去 使用自评节点的评估内容 | ||
943 | +// _, evaluationItemList, err = evaluationItemRepo.Find(map[string]interface{}{ | ||
944 | +// "evaluationProjectId": assess.EvaluationProjectId, | ||
945 | +// "nodeType": domain.LinkNodeSelfAssessment, | ||
946 | +// }) | ||
947 | +// if err != nil { | ||
948 | +// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取自评项目填写内容"+err.Error()) | ||
949 | +// } | ||
950 | +// } | ||
951 | +// var contentList []*domain.StaffAssessContent | ||
952 | +// nowTime := time.Now() | ||
953 | +// for i, v := range evaluationItemList { | ||
954 | +// item := &domain.StaffAssessContent{ | ||
955 | +// Id: 0, | ||
956 | +// StaffAssessId: assess.Id, | ||
957 | +// SortBy: i + 1, | ||
958 | +// Category: v.Category, | ||
959 | +// Name: v.Name, | ||
960 | +// PromptTitle: v.PromptTitle, | ||
961 | +// PromptText: v.PromptText, | ||
962 | +// Remark: nil, | ||
963 | +// Value: "", | ||
964 | +// ReteResult: "", | ||
965 | +// CreatedAt: nowTime, | ||
966 | +// Weight: v.Weight, | ||
967 | +// Required: v.Required, | ||
968 | +// UpdatedAt: nowTime, | ||
969 | +// DeletedAt: nil, | ||
970 | +// Rule: v.Rule, | ||
971 | +// } | ||
972 | +// var remarks []domain.AssessContemtRemark | ||
973 | +// for _, vv := range v.EntryItems { | ||
974 | +// ritem := domain.AssessContemtRemark{ | ||
975 | +// Title: vv.Title, | ||
976 | +// HintText: vv.HintText, | ||
977 | +// Definition: vv.Definition, | ||
978 | +// RemarkText: "", | ||
979 | +// } | ||
980 | +// remarks = append(remarks, ritem) | ||
981 | +// } | ||
982 | +// item.Remark = remarks | ||
983 | +// contentList = append(contentList, item) | ||
984 | +// } | ||
985 | +// return contentList, nil | ||
986 | +// } |
@@ -93,6 +93,10 @@ func (repo *EvaluationItemUsedRepository) Find(queryOptions map[string]interface | @@ -93,6 +93,10 @@ func (repo *EvaluationItemUsedRepository) Find(queryOptions map[string]interface | ||
93 | query.Where("node_type=?", v) | 93 | query.Where("node_type=?", v) |
94 | } | 94 | } |
95 | 95 | ||
96 | + if v, ok := queryOptions["nodeId"]; ok { | ||
97 | + query.Where("node_id=?", v) | ||
98 | + } | ||
99 | + | ||
96 | if v, ok := queryOptions["evaluatorId"]; ok { | 100 | if v, ok := queryOptions["evaluatorId"]; ok { |
97 | query.Where("evaluator_id=?", v) | 101 | query.Where("evaluator_id=?", v) |
98 | } | 102 | } |
sql/2023-04-01.sql
0 → 100644
1 | +-- 数据修复 | ||
2 | +-- 需备份 evaluation_item_used 表数据 | ||
3 | + | ||
4 | +WITH t1 AS ( | ||
5 | + SELECT | ||
6 | + evaluation_project.company_id, | ||
7 | + evaluation_project.id AS project_id, | ||
8 | + jsonb_array_elements(evaluation_project."template" #> '{linkNodes}') AS nodes | ||
9 | + FROM | ||
10 | + evaluation_project | ||
11 | + WHERE evaluation_project."template" #> '{linkNodes}'<>'null' | ||
12 | + ORDER BY | ||
13 | + id | ||
14 | +), | ||
15 | +t2 AS ( | ||
16 | + SELECT | ||
17 | + t1.company_id, | ||
18 | + t1.project_id, | ||
19 | + t1.nodes ->> 'id' AS node_id, | ||
20 | + t1.nodes ->> 'type' AS node_type, | ||
21 | + jsonb_array_elements(t1.nodes #> '{nodeContents}') AS node_contents | ||
22 | + FROM | ||
23 | + t1 | ||
24 | + WHERE t1.nodes #> '{nodeContents}'<>'null' | ||
25 | + ), | ||
26 | +t3 AS( | ||
27 | + SELECT | ||
28 | + t2.company_id, | ||
29 | + t2.project_id, | ||
30 | + cast(t2.node_id AS int8) AS node_id, | ||
31 | + cast(t2.node_type AS int8) AS node_type, | ||
32 | + t2.node_contents ->> 'category' AS "category", | ||
33 | + t2.node_contents ->> 'name' AS "name", | ||
34 | + cast(t2.node_contents ->> 'ruleId' AS int8) AS "rule_id" | ||
35 | + FROM | ||
36 | + t2 | ||
37 | +), | ||
38 | +t4 as ( | ||
39 | + SELECT | ||
40 | + t3.project_id, | ||
41 | + t3.node_type, | ||
42 | + t3."category", | ||
43 | + t3."name", | ||
44 | + row_to_json( "evaluation_rule".*) as "rule", | ||
45 | + "evaluation_rule"."type" as rule_type | ||
46 | + FROM t3 | ||
47 | + join "evaluation_rule" on t3.rule_id= "evaluation_rule".id | ||
48 | +), | ||
49 | +t5 as ( | ||
50 | + SELECT | ||
51 | + evaluation_item_used."id", | ||
52 | + evaluation_item_used.evaluation_project_id, | ||
53 | + evaluation_item_used.node_type, | ||
54 | + evaluation_item_used.category, | ||
55 | + evaluation_item_used."name" | ||
56 | + FROM evaluation_item_used | ||
57 | + WHERE "rule"='{}' or "rule" ISNULL | ||
58 | +), | ||
59 | +t6 as ( | ||
60 | + SELECT t5."id" , | ||
61 | + t4."rule", | ||
62 | + t4.rule_type | ||
63 | + FROM t5 ,t4 | ||
64 | + WHERE t5.evaluation_project_id=t4.project_id | ||
65 | + and t5.node_type=t4.node_type | ||
66 | + and t5.category=t4.category | ||
67 | + and t5."name"=t4."name" | ||
68 | +) | ||
69 | +update evaluation_item_used | ||
70 | +set "rule"=t6."rule", | ||
71 | +rule_type=t6."rule_type" | ||
72 | +FROM t6 | ||
73 | +WHERE evaluation_item_used."id"=t6."id" | ||
74 | +; | ||
75 | + | ||
76 | +-- 修复数据 | ||
77 | + | ||
78 | +with t1 as | ||
79 | +( SELECT | ||
80 | +evaluation_rule.id::TEXT, | ||
81 | +evaluation_rule."name", | ||
82 | +evaluation_rule.remark, | ||
83 | +evaluation_rule.company_id::TEXT as "companyId", | ||
84 | +evaluation_rule.creator_id::TEXT as "creatorId", | ||
85 | +evaluation_rule."type", | ||
86 | +evaluation_rule.rating, | ||
87 | +evaluation_rule.score, | ||
88 | +evaluation_rule.sys_type as "sysType" | ||
89 | +FROM evaluation_rule | ||
90 | +), | ||
91 | +t2 as ( | ||
92 | +SELECT t1.id, row_to_json(t1.*) as row_j FROM t1 | ||
93 | +), | ||
94 | +t3 as ( | ||
95 | +SELECT evaluation_item_used.id, t2.row_j | ||
96 | +FROM evaluation_item_used | ||
97 | +join t2 on t2.id= evaluation_item_used."rule"->>'id' | ||
98 | +WHERE evaluation_item_used."rule"->'companyId' ISNULL | ||
99 | +and evaluation_item_used."rule"->'id' is not null | ||
100 | +) | ||
101 | +update evaluation_item_used | ||
102 | +SET "rule"=t3.row_j | ||
103 | +FROM t3 | ||
104 | +WHERE evaluation_item_used.id = t3.id | ||
105 | +; |
-
请 注册 或 登录 后发表评论