作者 tangxvhui

bug 修复

... ... @@ -55,8 +55,8 @@ func buildChanceCheckResultData(checkResultData []models.ChanceCheckResult) (pro
checkResultMap := map[int64]*protocol.ChanceCheckResultData{}
checkReusltSlice := []*protocol.ChanceCheckResultData{}
//按人区分问题的答案
userAnswer := make(map[int64]map[int64]string)
for _, resultData := range checkResultData {
userAnswer := make(map[int64]map[int64]models.ChanceCheckResult)
for i, resultData := range checkResultData {
if _, ok := checkResultMap[resultData.CheckId]; !ok {
r := &protocol.ChanceCheckResultData{
CheckId: resultData.CheckId,
... ... @@ -68,10 +68,10 @@ func buildChanceCheckResultData(checkResultData []models.ChanceCheckResult) (pro
}
userIds.Add(resultData.UserCompanyId)
if _, ok := userAnswer[resultData.UserCompanyId]; ok {
userAnswer[resultData.UserCompanyId][resultData.CheckId] = resultData.Answer
userAnswer[resultData.UserCompanyId][resultData.CheckId] = checkResultData[i]
} else {
userAnswer[resultData.UserCompanyId] = map[int64]string{
resultData.CheckId: resultData.Answer,
userAnswer[resultData.UserCompanyId] = map[int64]models.ChanceCheckResult{
resultData.CheckId: checkResultData[i],
}
}
}
... ... @@ -91,15 +91,18 @@ func buildChanceCheckResultData(checkResultData []models.ChanceCheckResult) (pro
customItemsData := map[string]string{}
for uid := range userAnswer {
if answer, ok := userAnswer[uid][checkReusltSlice[i].CheckId]; ok {
switch answer {
switch answer.Answer {
case "是":
checkReusltSlice[i].AnswerYes++
customItemsData[usernameMap[uid]] = answer.Answer
case "否":
checkReusltSlice[i].AnswerNo++
customItemsData[usernameMap[uid]] = fmt.Sprintf("%s,理由:%s", answer.Answer, answer.Reason)
case "不清楚":
checkReusltSlice[i].AnswerAny++
customItemsData[usernameMap[uid]] = answer.Answer
}
customItemsData[usernameMap[uid]] = answer
} else {
customItemsData[usernameMap[uid]] = ""
}
... ...