作者 tangxvhui

微调

@@ -116,8 +116,8 @@ type ChanceSelfCheckData struct { @@ -116,8 +116,8 @@ type ChanceSelfCheckData struct {
116 CheckItem string `json:"checkItem"` 116 CheckItem string `json:"checkItem"`
117 GroupId int64 `json:"groupId"` 117 GroupId int64 `json:"groupId"`
118 Answer string `json::"answer"` 118 Answer string `json::"answer"`
119 - Id int `json:"id"`  
120 - ParentId int `json:"parentId"` 119 + Id int64 `json:"id"`
  120 + ParentId int64 `json:"parentId"`
121 } 121 }
122 122
123 func (m *Chance) GetSelfCheckData() []ChanceSelfCheckData { 123 func (m *Chance) GetSelfCheckData() []ChanceSelfCheckData {
@@ -318,21 +318,23 @@ func collectChanceCheckResultData(checkResultData []models.ChanceCheckResult) [] @@ -318,21 +318,23 @@ func collectChanceCheckResultData(checkResultData []models.ChanceCheckResult) []
318 } 318 }
319 } 319 }
320 //构建层级关系 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, checkReusltSlice[i])  
328 - // }  
329 - // } 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, checkReusltSlice[i])
  328 + }
  329 + }
330 var selfCheckData []models.ChanceSelfCheckData 330 var selfCheckData []models.ChanceSelfCheckData
331 for i := range checkReusltSlice { 331 for i := range checkReusltSlice {
332 if checkReusltSlice[i].CheckPid > 0 { 332 if checkReusltSlice[i].CheckPid > 0 {
333 continue 333 continue
334 } 334 }
335 dd := models.ChanceSelfCheckData{ 335 dd := models.ChanceSelfCheckData{
  336 + Id: checkReusltSlice[i].CheckId,
  337 + ParentId: checkReusltSlice[i].CheckPid,
336 CheckItem: checkReusltSlice[i].CheckItem, 338 CheckItem: checkReusltSlice[i].CheckItem,
337 GroupId: checkReusltSlice[i].GroupId, 339 GroupId: checkReusltSlice[i].GroupId,
338 } 340 }
@@ -346,22 +348,24 @@ func collectChanceCheckResultData(checkResultData []models.ChanceCheckResult) [] @@ -346,22 +348,24 @@ func collectChanceCheckResultData(checkResultData []models.ChanceCheckResult) []
346 dd.Answer = "不清楚" 348 dd.Answer = "不清楚"
347 } 349 }
348 selfCheckData = append(selfCheckData, dd) 350 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 - // } 351 + for _, childdata := range checkReusltSlice[i].Child {
  352 + dd := models.ChanceSelfCheckData{
  353 + Id: childdata.CheckId,
  354 + ParentId: childdata.CheckPid,
  355 + CheckItem: childdata.CheckItem,
  356 + GroupId: childdata.GroupId,
  357 + }
  358 + if childdata.AnswerNo > 0 {
  359 + dd.Answer = "否"
  360 + }
  361 + if childdata.AnswerYes > 0 && childdata.AnswerNo == 0 && childdata.AnswerAny == 0 {
  362 + dd.Answer = "是"
  363 + }
  364 + if childdata.AnswerNo == 0 && childdata.AnswerAny > 0 {
  365 + dd.Answer = "不清楚"
  366 + }
  367 + selfCheckData = append(selfCheckData, dd)
  368 + }
365 } 369 }
366 return selfCheckData 370 return selfCheckData
367 } 371 }