|
@@ -54,7 +54,7 @@ func buildChanceCheckResultData(checkResultData []models.ChanceCheckResult) (pro |
|
@@ -54,7 +54,7 @@ func buildChanceCheckResultData(checkResultData []models.ChanceCheckResult) (pro |
54
|
userIds := utils.NewArraySetInt64()
|
54
|
userIds := utils.NewArraySetInt64()
|
55
|
checkResultMap := map[int64]*protocol.ChanceCheckResultData{}
|
55
|
checkResultMap := map[int64]*protocol.ChanceCheckResultData{}
|
56
|
checkReusltSlice := []*protocol.ChanceCheckResultData{}
|
56
|
checkReusltSlice := []*protocol.ChanceCheckResultData{}
|
57
|
- //按人区分问题的答案
|
57
|
+ //按人区分问题的答案 user_company_id check_id
|
58
|
userAnswer := make(map[int64]map[int64]models.ChanceCheckResult)
|
58
|
userAnswer := make(map[int64]map[int64]models.ChanceCheckResult)
|
59
|
for i, resultData := range checkResultData {
|
59
|
for i, resultData := range checkResultData {
|
60
|
if _, ok := checkResultMap[resultData.CheckId]; !ok {
|
60
|
if _, ok := checkResultMap[resultData.CheckId]; !ok {
|
|
@@ -271,3 +271,97 @@ func ChanceCheckResultNoPass(chanceId int64, companyId int64) error { |
|
@@ -271,3 +271,97 @@ func ChanceCheckResultNoPass(chanceId int64, companyId int64) error { |
271
|
}
|
271
|
}
|
272
|
return nil
|
272
|
return nil
|
273
|
}
|
273
|
}
|
|
|
274
|
+
|
|
|
275
|
+type chanceCheckResultTotal struct {
|
|
|
276
|
+ GroupId int64
|
|
|
277
|
+ CheckItem string
|
|
|
278
|
+ CheckId int64
|
|
|
279
|
+ CheckPid int64
|
|
|
280
|
+ AnswerYes int
|
|
|
281
|
+ AnswerNo int
|
|
|
282
|
+ AnswerAny int
|
|
|
283
|
+ Child []*chanceCheckResultTotal
|
|
|
284
|
+}
|
|
|
285
|
+
|
|
|
286
|
+//collectChanceCheckResultData 汇总机会自查内容筛选结果
|
|
|
287
|
+func collectChanceCheckResultData(checkResultData []models.ChanceCheckResult) ([]models.ChanceSelfCheckData, error) {
|
|
|
288
|
+ checkResultMap := map[int64]*chanceCheckResultTotal{}
|
|
|
289
|
+ checkReusltSlice := []*chanceCheckResultTotal{}
|
|
|
290
|
+ for _, resultData := range checkResultData {
|
|
|
291
|
+ answerYes := 0
|
|
|
292
|
+ answerNo := 0
|
|
|
293
|
+ answerAny := 0
|
|
|
294
|
+ switch resultData.Answer {
|
|
|
295
|
+ case "是":
|
|
|
296
|
+ answerYes++
|
|
|
297
|
+ case "否":
|
|
|
298
|
+ answerNo++
|
|
|
299
|
+ case "不清楚":
|
|
|
300
|
+ answerAny++
|
|
|
301
|
+ }
|
|
|
302
|
+ if _, ok := checkResultMap[resultData.CheckId]; !ok {
|
|
|
303
|
+ r := &chanceCheckResultTotal{
|
|
|
304
|
+ CheckId: resultData.CheckId,
|
|
|
305
|
+ CheckPid: resultData.CheckPid,
|
|
|
306
|
+ CheckItem: resultData.CheckItem,
|
|
|
307
|
+ GroupId: resultData.GroupId,
|
|
|
308
|
+ AnswerYes: answerYes,
|
|
|
309
|
+ AnswerNo: answerNo,
|
|
|
310
|
+ AnswerAny: answerAny,
|
|
|
311
|
+ }
|
|
|
312
|
+ checkResultMap[resultData.CheckId] = r
|
|
|
313
|
+ checkReusltSlice = append(checkReusltSlice, r)
|
|
|
314
|
+ } else {
|
|
|
315
|
+ checkResultMap[resultData.CheckId].AnswerYes += answerYes
|
|
|
316
|
+ checkResultMap[resultData.CheckId].AnswerNo += answerNo
|
|
|
317
|
+ checkResultMap[resultData.CheckId].AnswerAny += answerAny
|
|
|
318
|
+ }
|
|
|
319
|
+ }
|
|
|
320
|
+ //构建层级关系
|
|
|
321
|
+ for i := range checkReusltSlice {
|
|
|
322
|
+ if checkReusltSlice[i].CheckPid == 0 {
|
|
|
323
|
+ continue
|
|
|
324
|
+ }
|
|
|
325
|
+ pid := checkReusltSlice[i].CheckPid
|
|
|
326
|
+ if _, ok := checkResultMap[pid]; ok {
|
|
|
327
|
+ checkResultMap[pid].Child = append(checkResultMap[pid].Child, checkResultMap[pid])
|
|
|
328
|
+ }
|
|
|
329
|
+ }
|
|
|
330
|
+ var selfCheckData []models.ChanceSelfCheckData
|
|
|
331
|
+ for i := range checkReusltSlice {
|
|
|
332
|
+ if checkReusltSlice[i].CheckPid > 0 {
|
|
|
333
|
+ continue
|
|
|
334
|
+ }
|
|
|
335
|
+ dd := models.ChanceSelfCheckData{
|
|
|
336
|
+ CheckItem: checkReusltSlice[i].CheckItem,
|
|
|
337
|
+ GroupId: checkReusltSlice[i].GroupId,
|
|
|
338
|
+ }
|
|
|
339
|
+ if checkReusltSlice[i].AnswerNo > 0 {
|
|
|
340
|
+ dd.Answer = "否"
|
|
|
341
|
+ }
|
|
|
342
|
+ if checkReusltSlice[i].AnswerYes > 0 && checkReusltSlice[i].AnswerNo == 0 && checkReusltSlice[i].AnswerAny == 0 {
|
|
|
343
|
+ dd.Answer = "是"
|
|
|
344
|
+ }
|
|
|
345
|
+ if checkReusltSlice[i].AnswerNo == 0 && checkReusltSlice[i].AnswerAny > 0 {
|
|
|
346
|
+ dd.Answer = "不清楚"
|
|
|
347
|
+ }
|
|
|
348
|
+ selfCheckData = append(selfCheckData, dd)
|
|
|
349
|
+ for _, childdata := range checkReusltSlice[i].Child {
|
|
|
350
|
+ dd := models.ChanceSelfCheckData{
|
|
|
351
|
+ CheckItem: childdata.CheckItem,
|
|
|
352
|
+ GroupId: childdata.GroupId,
|
|
|
353
|
+ }
|
|
|
354
|
+ if childdata.AnswerNo > 0 {
|
|
|
355
|
+ dd.Answer = "否"
|
|
|
356
|
+ }
|
|
|
357
|
+ if childdata.AnswerYes > 0 && childdata.AnswerNo == 0 && childdata.AnswerAny == 0 {
|
|
|
358
|
+ dd.Answer = "是"
|
|
|
359
|
+ }
|
|
|
360
|
+ if childdata.AnswerNo == 0 && childdata.AnswerAny > 0 {
|
|
|
361
|
+ dd.Answer = "不清楚"
|
|
|
362
|
+ }
|
|
|
363
|
+ selfCheckData = append(selfCheckData, dd)
|
|
|
364
|
+ }
|
|
|
365
|
+ }
|
|
|
366
|
+ return selfCheckData, nil
|
|
|
367
|
+} |