|
@@ -36,6 +36,162 @@ func GetChanceCheckResultInfo(chanceId int64, companyid int64) (protocol.Reponse |
|
@@ -36,6 +36,162 @@ func GetChanceCheckResultInfo(chanceId int64, companyid int64) (protocol.Reponse |
36
|
}
|
36
|
}
|
37
|
|
37
|
|
38
|
//getChanceCheckResultData 机会自查内容筛选详情数据输出
|
38
|
//getChanceCheckResultData 机会自查内容筛选详情数据输出
|
|
|
39
|
+// func getChanceCheckResultData(chanceId int64) (protocol.ReponseChanceCheckResult, error) {
|
|
|
40
|
+// var (
|
|
|
41
|
+// checkResultData []models.ChanceCheckResult
|
|
|
42
|
+// err error
|
|
|
43
|
+// )
|
|
|
44
|
+// rsp := protocol.ReponseChanceCheckResult{
|
|
|
45
|
+// CustomItem: []string{},
|
|
|
46
|
+// CheckData: []protocol.ChanceCheckResultData{},
|
|
|
47
|
+// }
|
|
|
48
|
+// checkResultData, err = models.GetChanceCheckResultByChancce(chanceId)
|
|
|
49
|
+// if err != nil {
|
|
|
50
|
+// log.Error("未获得指定的机会自查内容筛选结果,err;%s", err)
|
|
|
51
|
+// return rsp, nil
|
|
|
52
|
+// }
|
|
|
53
|
+// //组装响应数据
|
|
|
54
|
+// //自查内容中的用户id
|
|
|
55
|
+// userIds := utils.NewArraySetInt64()
|
|
|
56
|
+// //一维自查内容项
|
|
|
57
|
+// checkItemsLv1 := utils.NewArraySetInt64()
|
|
|
58
|
+// checkItemsLv2 := map[int64]*utils.ArraySetInt64{}
|
|
|
59
|
+// checkResultMap := make(map[int64]*protocol.ChanceCheckResultData)
|
|
|
60
|
+// //处理一维自查内容数据
|
|
|
61
|
+// for _, v := range checkResultData {
|
|
|
62
|
+// if v.CheckPid > 0 {
|
|
|
63
|
+// continue
|
|
|
64
|
+// }
|
|
|
65
|
+// if _, ok := checkResultMap[v.CheckId]; ok {
|
|
|
66
|
+// checkResultMap[v.CheckId].CustomItemData[fmt.Sprint(v.UserCompanyId)] = v.Answer
|
|
|
67
|
+// switch v.Answer {
|
|
|
68
|
+// case "是":
|
|
|
69
|
+// checkResultMap[v.CheckId].AnswerYes++
|
|
|
70
|
+// case "否":
|
|
|
71
|
+// checkResultMap[v.CheckId].AnswerNo++
|
|
|
72
|
+// case "不清楚":
|
|
|
73
|
+// checkResultMap[v.CheckId].AnswerAny++
|
|
|
74
|
+// }
|
|
|
75
|
+// } else {
|
|
|
76
|
+// userAnswer := map[string]string{
|
|
|
77
|
+// fmt.Sprint(v.UserCompanyId): v.Answer,
|
|
|
78
|
+// }
|
|
|
79
|
+// r := &protocol.ChanceCheckResultData{
|
|
|
80
|
+// CheckPid: v.CheckPid,
|
|
|
81
|
+// CheckId: v.CheckId,
|
|
|
82
|
+// CheckItem: v.CheckItem,
|
|
|
83
|
+// CustomItemData: userAnswer,
|
|
|
84
|
+// }
|
|
|
85
|
+// switch v.Answer {
|
|
|
86
|
+// case "是":
|
|
|
87
|
+// r.AnswerYes++
|
|
|
88
|
+// case "否":
|
|
|
89
|
+// r.AnswerNo++
|
|
|
90
|
+// case "不清楚":
|
|
|
91
|
+// r.AnswerAny++
|
|
|
92
|
+// }
|
|
|
93
|
+// checkResultMap[v.CheckId] = r
|
|
|
94
|
+// userIds.Add(v.UserCompanyId)
|
|
|
95
|
+// checkItemsLv1.Add(v.CheckId)
|
|
|
96
|
+// }
|
|
|
97
|
+// }
|
|
|
98
|
+// //处理二维自查内容数据
|
|
|
99
|
+// for _, v := range checkResultData {
|
|
|
100
|
+// if v.CheckPid == 0 {
|
|
|
101
|
+// continue
|
|
|
102
|
+// }
|
|
|
103
|
+// _, ok := checkResultMap[v.CheckPid]
|
|
|
104
|
+// if !ok {
|
|
|
105
|
+// continue
|
|
|
106
|
+// }
|
|
|
107
|
+// _, ok = checkResultMap[v.CheckPid].Child[v.CheckId]
|
|
|
108
|
+// if ok {
|
|
|
109
|
+// checkResultMap[v.CheckPid].Child[v.CheckId].CustomItemData[fmt.Sprint(v.UserCompanyId)] = v.Answer
|
|
|
110
|
+// switch v.Answer {
|
|
|
111
|
+// case "是":
|
|
|
112
|
+// checkResultMap[v.CheckId].AnswerYes++
|
|
|
113
|
+// case "否":
|
|
|
114
|
+// checkResultMap[v.CheckId].AnswerNo++
|
|
|
115
|
+// case "不清楚":
|
|
|
116
|
+// checkResultMap[v.CheckId].AnswerAny++
|
|
|
117
|
+// }
|
|
|
118
|
+// } else {
|
|
|
119
|
+// userAnswer := map[string]string{
|
|
|
120
|
+// fmt.Sprint(v.UserCompanyId): v.Answer,
|
|
|
121
|
+// }
|
|
|
122
|
+// r := &protocol.ChanceCheckResultData{
|
|
|
123
|
+// CheckPid: v.CheckPid,
|
|
|
124
|
+// CheckId: v.CheckId,
|
|
|
125
|
+// CheckItem: v.CheckItem,
|
|
|
126
|
+// CustomItemData: userAnswer,
|
|
|
127
|
+// }
|
|
|
128
|
+// switch v.Answer {
|
|
|
129
|
+// case "是":
|
|
|
130
|
+// r.AnswerYes++
|
|
|
131
|
+// case "否":
|
|
|
132
|
+// r.AnswerNo++
|
|
|
133
|
+// case "不清楚":
|
|
|
134
|
+// r.AnswerAny++
|
|
|
135
|
+// }
|
|
|
136
|
+// checkResultMap[v.CheckPid].Child[v.CheckId] = r
|
|
|
137
|
+// userIds.Add(v.UserCompanyId)
|
|
|
138
|
+// if _, ok := checkItemsLv2[v.CheckPid]; ok {
|
|
|
139
|
+// checkItemsLv2[v.CheckPid].Add(v.CheckId)
|
|
|
140
|
+// } else {
|
|
|
141
|
+
|
|
|
142
|
+// checkItemsLv2[v.CheckPid] = utils.NewArraySetInt64()
|
|
|
143
|
+// checkItemsLv2[v.CheckPid].Add(v.CheckId)
|
|
|
144
|
+// }
|
|
|
145
|
+// }
|
|
|
146
|
+// }
|
|
|
147
|
+// usernameMap := make(map[string]string)
|
|
|
148
|
+// for _, v := range userIds.ToSlice() {
|
|
|
149
|
+// idString := fmt.Sprint(v)
|
|
|
150
|
+// u, err := models.GetUserCompanyById(v)
|
|
|
151
|
+// if err == nil {
|
|
|
152
|
+// usernameMap[idString] = u.NickName
|
|
|
153
|
+// } else {
|
|
|
154
|
+// usernameMap[idString] = idString
|
|
|
155
|
+// }
|
|
|
156
|
+// rsp.CustomItem = append(rsp.CustomItem, usernameMap[idString])
|
|
|
157
|
+// }
|
|
|
158
|
+// for _, Lv1 := range checkItemsLv1.ToSlice() {
|
|
|
159
|
+// // 处理一级数据
|
|
|
160
|
+// newCustomItemData := map[string]string{}
|
|
|
161
|
+// for uid, uname := range usernameMap {
|
|
|
162
|
+// if answer, ok := checkResultMap[Lv1].CustomItemData[uid]; ok {
|
|
|
163
|
+// newCustomItemData[uname] = answer
|
|
|
164
|
+// } else {
|
|
|
165
|
+// newCustomItemData[uname] = ""
|
|
|
166
|
+// }
|
|
|
167
|
+// }
|
|
|
168
|
+// checkResultMap[Lv1].CustomItemData = newCustomItemData
|
|
|
169
|
+// checkResultMap[Lv1].Total = fmt.Sprintf("是:%d 否:%d 不清楚:%d",
|
|
|
170
|
+// checkResultMap[Lv1].AnswerYes, checkResultMap[Lv1].AnswerNo, checkResultMap[Lv1].AnswerAny)
|
|
|
171
|
+// rsp.CheckData = append(rsp.CheckData, *checkResultMap[Lv1])
|
|
|
172
|
+// if _, ok := checkItemsLv2[Lv1]; ok {
|
|
|
173
|
+// //处理二级数据
|
|
|
174
|
+// for _, Lv2 := range checkItemsLv2[Lv1].ToSlice() {
|
|
|
175
|
+// newCustomItemData := map[string]string{}
|
|
|
176
|
+// for uid, uname := range usernameMap {
|
|
|
177
|
+// if answer, ok := checkResultMap[Lv1].Child[Lv2].CustomItemData[uid]; ok {
|
|
|
178
|
+// newCustomItemData[uname] = answer
|
|
|
179
|
+// } else {
|
|
|
180
|
+// newCustomItemData[uname] = ""
|
|
|
181
|
+// }
|
|
|
182
|
+// }
|
|
|
183
|
+// checkResultMap[Lv1].Child[Lv2].CustomItemData = newCustomItemData
|
|
|
184
|
+// // checkResultMap[Lv1].Child[Lv2].Total = fmt.Sprintf("是:%d 否:%d 不清楚:%d",
|
|
|
185
|
+// // checkResultMap[Lv1].Child[Lv2].AnswerYes, checkResultMap[Lv1].Child[Lv2].AnswerNo,
|
|
|
186
|
+// // checkResultMap[Lv1].Child[Lv2].AnswerAny)
|
|
|
187
|
+// rsp.CheckData = append(rsp.CheckData, *checkResultMap[Lv1].Child[Lv2])
|
|
|
188
|
+// }
|
|
|
189
|
+// }
|
|
|
190
|
+// }
|
|
|
191
|
+// return rsp, nil
|
|
|
192
|
+// }
|
|
|
193
|
+
|
|
|
194
|
+//getChanceCheckResultData 机会自查内容筛选详情数据输出
|
39
|
func getChanceCheckResultData(chanceId int64) (protocol.ReponseChanceCheckResult, error) {
|
195
|
func getChanceCheckResultData(chanceId int64) (protocol.ReponseChanceCheckResult, error) {
|
40
|
var (
|
196
|
var (
|
41
|
checkResultData []models.ChanceCheckResult
|
197
|
checkResultData []models.ChanceCheckResult
|
|
@@ -50,142 +206,78 @@ func getChanceCheckResultData(chanceId int64) (protocol.ReponseChanceCheckResult |
|
@@ -50,142 +206,78 @@ func getChanceCheckResultData(chanceId int64) (protocol.ReponseChanceCheckResult |
50
|
log.Error("未获得指定的机会自查内容筛选结果,err;%s", err)
|
206
|
log.Error("未获得指定的机会自查内容筛选结果,err;%s", err)
|
51
|
return rsp, nil
|
207
|
return rsp, nil
|
52
|
}
|
208
|
}
|
53
|
- //组装响应数据
|
|
|
54
|
- //自查内容中的用户id
|
209
|
+ //人的id
|
55
|
userIds := utils.NewArraySetInt64()
|
210
|
userIds := utils.NewArraySetInt64()
|
56
|
- //一维自查内容项
|
|
|
57
|
- checkItemsLv1 := utils.NewArraySetInt64()
|
|
|
58
|
- checkItemsLv2 := map[int64]*utils.ArraySetInt64{}
|
|
|
59
|
- checkResultMap := make(map[int64]*protocol.ChanceCheckResultData)
|
|
|
60
|
- //处理一维自查内容数据
|
|
|
61
|
- for _, v := range checkResultData {
|
|
|
62
|
- if v.CheckPid > 0 {
|
|
|
63
|
- continue
|
|
|
64
|
- }
|
|
|
65
|
- if _, ok := checkResultMap[v.CheckId]; ok {
|
|
|
66
|
- checkResultMap[v.CheckId].CustomItemData[fmt.Sprint(v.UserCompanyId)] = v.Answer
|
|
|
67
|
- switch v.Answer {
|
|
|
68
|
- case "是":
|
|
|
69
|
- checkResultMap[v.CheckId].AnswerYes++
|
|
|
70
|
- case "否":
|
|
|
71
|
- checkResultMap[v.CheckId].AnswerNo++
|
|
|
72
|
- case "不清楚":
|
|
|
73
|
- checkResultMap[v.CheckId].AnswerAny++
|
|
|
74
|
- }
|
|
|
75
|
- } else {
|
|
|
76
|
- userAnswer := map[string]string{
|
|
|
77
|
- fmt.Sprint(v.UserCompanyId): v.Answer,
|
|
|
78
|
- }
|
211
|
+ checkResultMap := map[int64]*protocol.ChanceCheckResultData{}
|
|
|
212
|
+ checkReusltSlice := []*protocol.ChanceCheckResultData{}
|
|
|
213
|
+ //按人区分问题的答案
|
|
|
214
|
+ userAnswer := make(map[int64]map[int64]string)
|
|
|
215
|
+ for _, resultData := range checkResultData {
|
|
|
216
|
+ if _, ok := checkResultMap[resultData.CheckId]; !ok {
|
79
|
r := &protocol.ChanceCheckResultData{
|
217
|
r := &protocol.ChanceCheckResultData{
|
80
|
- CheckPid: v.CheckPid,
|
|
|
81
|
- CheckId: v.CheckId,
|
|
|
82
|
- CheckItem: v.CheckItem,
|
|
|
83
|
- CustomItemData: userAnswer,
|
|
|
84
|
- }
|
|
|
85
|
- switch v.Answer {
|
|
|
86
|
- case "是":
|
|
|
87
|
- r.AnswerYes++
|
|
|
88
|
- case "否":
|
|
|
89
|
- r.AnswerNo++
|
|
|
90
|
- case "不清楚":
|
|
|
91
|
- r.AnswerAny++
|
218
|
+ CheckId: resultData.CheckId,
|
|
|
219
|
+ CheckPid: resultData.CheckPid,
|
|
|
220
|
+ CheckItem: resultData.CheckItem,
|
92
|
}
|
221
|
}
|
93
|
- checkResultMap[v.CheckId] = r
|
|
|
94
|
- userIds.Add(v.UserCompanyId)
|
|
|
95
|
- checkItemsLv1.Add(v.CheckId)
|
222
|
+ checkResultMap[resultData.CheckId] = r
|
|
|
223
|
+ checkReusltSlice = append(checkReusltSlice, r)
|
96
|
}
|
224
|
}
|
|
|
225
|
+ userIds.Add(resultData.UserCompanyId)
|
|
|
226
|
+ if _, ok := userAnswer[resultData.UserCompanyId]; ok {
|
|
|
227
|
+ userAnswer[resultData.UserCompanyId][resultData.CheckId] = resultData.Answer
|
|
|
228
|
+ } else {
|
|
|
229
|
+ userAnswer[resultData.UserCompanyId] = map[int64]string{
|
|
|
230
|
+ resultData.CheckId: resultData.Answer,
|
97
|
}
|
231
|
}
|
98
|
- //处理二维自查内容数据
|
|
|
99
|
- for _, v := range checkResultData {
|
|
|
100
|
- if v.CheckPid == 0 {
|
|
|
101
|
- continue
|
|
|
102
|
- }
|
|
|
103
|
- _, ok := checkResultMap[v.CheckPid]
|
|
|
104
|
- if !ok {
|
|
|
105
|
- continue
|
|
|
106
|
}
|
232
|
}
|
107
|
- _, ok = checkResultMap[v.CheckPid].Child[v.CheckId]
|
|
|
108
|
- if ok {
|
|
|
109
|
- checkResultMap[v.CheckPid].Child[v.CheckId].CustomItemData[fmt.Sprint(v.UserCompanyId)] = v.Answer
|
|
|
110
|
- switch v.Answer {
|
|
|
111
|
- case "是":
|
|
|
112
|
- checkResultMap[v.CheckId].AnswerYes++
|
|
|
113
|
- case "否":
|
|
|
114
|
- checkResultMap[v.CheckId].AnswerNo++
|
|
|
115
|
- case "不清楚":
|
|
|
116
|
- checkResultMap[v.CheckId].AnswerAny++
|
|
|
117
|
}
|
233
|
}
|
|
|
234
|
+ usernameMap := make(map[int64]string)
|
|
|
235
|
+ customItems := []string{}
|
|
|
236
|
+ for _, v := range userIds.ToSlice() {
|
|
|
237
|
+ idString := fmt.Sprint(v)
|
|
|
238
|
+ u, err := models.GetUserCompanyById(v)
|
|
|
239
|
+ if err == nil {
|
|
|
240
|
+ usernameMap[v] = u.NickName
|
118
|
} else {
|
241
|
} else {
|
119
|
- userAnswer := map[string]string{
|
|
|
120
|
- fmt.Sprint(v.UserCompanyId): v.Answer,
|
242
|
+ usernameMap[v] = idString
|
121
|
}
|
243
|
}
|
122
|
- r := &protocol.ChanceCheckResultData{
|
|
|
123
|
- CheckPid: v.CheckPid,
|
|
|
124
|
- CheckId: v.CheckId,
|
|
|
125
|
- CheckItem: v.CheckItem,
|
|
|
126
|
- CustomItemData: userAnswer,
|
244
|
+ customItems = append(customItems, usernameMap[v])
|
127
|
}
|
245
|
}
|
128
|
- switch v.Answer {
|
246
|
+ for i := range checkReusltSlice {
|
|
|
247
|
+ customItemsData := map[string]string{}
|
|
|
248
|
+ for uid := range userAnswer {
|
|
|
249
|
+ if answer, ok := userAnswer[uid][checkReusltSlice[i].CheckId]; ok {
|
|
|
250
|
+ switch answer {
|
129
|
case "是":
|
251
|
case "是":
|
130
|
- r.AnswerYes++
|
252
|
+ checkReusltSlice[i].AnswerYes++
|
131
|
case "否":
|
253
|
case "否":
|
132
|
- r.AnswerNo++
|
254
|
+ checkReusltSlice[i].AnswerNo++
|
133
|
case "不清楚":
|
255
|
case "不清楚":
|
134
|
- r.AnswerAny++
|
256
|
+ checkReusltSlice[i].AnswerAny++
|
135
|
}
|
257
|
}
|
136
|
- checkResultMap[v.CheckPid].Child[v.CheckId] = r
|
|
|
137
|
- userIds.Add(v.UserCompanyId)
|
|
|
138
|
- if _, ok := checkItemsLv2[v.CheckPid]; ok {
|
|
|
139
|
- checkItemsLv2[v.CheckPid].Add(v.CheckId)
|
258
|
+ customItemsData[usernameMap[uid]] = answer
|
140
|
} else {
|
259
|
} else {
|
141
|
-
|
|
|
142
|
- checkItemsLv2[v.CheckPid] = utils.NewArraySetInt64()
|
|
|
143
|
- checkItemsLv2[v.CheckPid].Add(v.CheckId)
|
260
|
+ customItemsData[usernameMap[uid]] = ""
|
144
|
}
|
261
|
}
|
145
|
}
|
262
|
}
|
|
|
263
|
+ checkReusltSlice[i].CustomItemData = customItemsData
|
|
|
264
|
+ if checkReusltSlice[i].CheckPid == 0 {
|
|
|
265
|
+ checkReusltSlice[i].Total = fmt.Sprintf("是:%d 否:%d 不清楚:%d",
|
|
|
266
|
+ checkReusltSlice[i].AnswerYes, checkReusltSlice[i].AnswerNo, checkReusltSlice[i].AnswerAny)
|
146
|
}
|
267
|
}
|
147
|
- usernameMap := make(map[string]string)
|
|
|
148
|
- for _, v := range userIds.ToSlice() {
|
|
|
149
|
- idString := fmt.Sprint(v)
|
|
|
150
|
- u, err := models.GetUserCompanyById(v)
|
|
|
151
|
- if err == nil {
|
|
|
152
|
- usernameMap[idString] = u.NickName
|
|
|
153
|
- } else {
|
|
|
154
|
- usernameMap[idString] = idString
|
268
|
+ if checkReusltSlice[i].CheckPid > 0 {
|
|
|
269
|
+ pid := checkReusltSlice[i].CheckPid
|
|
|
270
|
+ checkResultMap[pid].Child = append(checkResultMap[pid].Child, checkReusltSlice[i])
|
155
|
}
|
271
|
}
|
156
|
- rsp.CustomItem = append(rsp.CustomItem, usernameMap[idString])
|
|
|
157
|
}
|
272
|
}
|
158
|
- for _, Lv1 := range checkItemsLv1.ToSlice() {
|
|
|
159
|
- // 处理一级数据
|
|
|
160
|
- newCustomItemData := map[string]string{}
|
|
|
161
|
- for uid, uname := range usernameMap {
|
|
|
162
|
- if answer, ok := checkResultMap[Lv1].CustomItemData[uid]; ok {
|
|
|
163
|
- newCustomItemData[uname] = answer
|
|
|
164
|
- } else {
|
|
|
165
|
- newCustomItemData[uname] = ""
|
|
|
166
|
- }
|
|
|
167
|
- }
|
|
|
168
|
- checkResultMap[Lv1].CustomItemData = newCustomItemData
|
|
|
169
|
- checkResultMap[Lv1].Total = fmt.Sprintf("是:%d 否:%d 不清楚:%d",
|
|
|
170
|
- checkResultMap[Lv1].AnswerYes, checkResultMap[Lv1].AnswerNo, checkResultMap[Lv1].AnswerAny)
|
|
|
171
|
- rsp.CheckData = append(rsp.CheckData, *checkResultMap[Lv1])
|
|
|
172
|
- if _, ok := checkItemsLv2[Lv1]; ok {
|
|
|
173
|
- //处理二级数据
|
|
|
174
|
- for _, Lv2 := range checkItemsLv2[Lv1].ToSlice() {
|
|
|
175
|
- newCustomItemData := map[string]string{}
|
|
|
176
|
- for uid, uname := range usernameMap {
|
|
|
177
|
- if answer, ok := checkResultMap[Lv1].Child[Lv2].CustomItemData[uid]; ok {
|
|
|
178
|
- newCustomItemData[uname] = answer
|
|
|
179
|
- } else {
|
|
|
180
|
- newCustomItemData[uname] = ""
|
|
|
181
|
- }
|
|
|
182
|
- }
|
|
|
183
|
- checkResultMap[Lv1].Child[Lv2].CustomItemData = newCustomItemData
|
|
|
184
|
- // checkResultMap[Lv1].Child[Lv2].Total = fmt.Sprintf("是:%d 否:%d 不清楚:%d",
|
|
|
185
|
- // checkResultMap[Lv1].Child[Lv2].AnswerYes, checkResultMap[Lv1].Child[Lv2].AnswerNo,
|
|
|
186
|
- // checkResultMap[Lv1].Child[Lv2].AnswerAny)
|
|
|
187
|
- rsp.CheckData = append(rsp.CheckData, *checkResultMap[Lv1].Child[Lv2])
|
273
|
+ rsp.CustomItem = customItems
|
|
|
274
|
+ for i := range checkReusltSlice {
|
|
|
275
|
+ if checkReusltSlice[i].CheckPid > 0 {
|
|
|
276
|
+ continue
|
188
|
}
|
277
|
}
|
|
|
278
|
+ rsp.CheckData = append(rsp.CheckData, *checkReusltSlice[i])
|
|
|
279
|
+ for ii := range checkReusltSlice[i].Child {
|
|
|
280
|
+ rsp.CheckData = append(rsp.CheckData, *checkReusltSlice[i].Child[ii])
|
189
|
}
|
281
|
}
|
190
|
}
|
282
|
}
|
191
|
return rsp, nil
|
283
|
return rsp, nil
|