|
@@ -41,7 +41,10 @@ func getChanceCheckResultData(chanceId int64) (protocol.ReponseChanceCheckResult |
|
@@ -41,7 +41,10 @@ func getChanceCheckResultData(chanceId int64) (protocol.ReponseChanceCheckResult |
41
|
checkResultData []models.ChanceCheckResult
|
41
|
checkResultData []models.ChanceCheckResult
|
42
|
err error
|
42
|
err error
|
43
|
)
|
43
|
)
|
44
|
- rsp := protocol.ReponseChanceCheckResult{}
|
44
|
+ rsp := protocol.ReponseChanceCheckResult{
|
|
|
45
|
+ CustomItem: []string{},
|
|
|
46
|
+ CheckData: []protocol.ChanceCheckResultData{},
|
|
|
47
|
+ }
|
45
|
checkResultData, err = models.GetChanceCheckResultByChancce(chanceId)
|
48
|
checkResultData, err = models.GetChanceCheckResultByChancce(chanceId)
|
46
|
if err != nil {
|
49
|
if err != nil {
|
47
|
log.Error("未获得指定的机会自查内容筛选结果,err;%s", err)
|
50
|
log.Error("未获得指定的机会自查内容筛选结果,err;%s", err)
|
|
@@ -50,24 +53,96 @@ func getChanceCheckResultData(chanceId int64) (protocol.ReponseChanceCheckResult |
|
@@ -50,24 +53,96 @@ func getChanceCheckResultData(chanceId int64) (protocol.ReponseChanceCheckResult |
50
|
//组装响应数据
|
53
|
//组装响应数据
|
51
|
//自查内容中的用户id
|
54
|
//自查内容中的用户id
|
52
|
userIds := utils.NewArraySetInt64()
|
55
|
userIds := utils.NewArraySetInt64()
|
53
|
- //自查内容项
|
|
|
54
|
- checkItems := utils.NewArraySetString()
|
|
|
55
|
- checkResultMap := make(map[string]*protocol.ChanceCheckResultData)
|
56
|
+ //一维自查内容项
|
|
|
57
|
+ checkItemsLv1 := utils.NewArraySetInt64()
|
|
|
58
|
+ checkItemsLv2 := map[int64]*utils.ArraySetInt64{}
|
|
|
59
|
+ checkResultMap := make(map[int64]*protocol.ChanceCheckResultData)
|
|
|
60
|
+ //处理一维自查内容数据
|
56
|
for _, v := range checkResultData {
|
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
|
57
|
userIds.Add(v.UserCompanyId)
|
94
|
userIds.Add(v.UserCompanyId)
|
58
|
- checkItems.Add(v.CheckItem)
|
|
|
59
|
- if _, ok := checkResultMap[v.CheckItem]; ok {
|
|
|
60
|
- checkResultMap[v.CheckItem].CustomItemData[fmt.Sprint(v.UserCompanyId)] = v.Answer
|
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 {
|
61
|
continue
|
105
|
continue
|
62
|
}
|
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 {
|
63
|
userAnswer := map[string]string{
|
119
|
userAnswer := map[string]string{
|
64
|
fmt.Sprint(v.UserCompanyId): v.Answer,
|
120
|
fmt.Sprint(v.UserCompanyId): v.Answer,
|
65
|
}
|
121
|
}
|
66
|
- checkResultMap[v.CheckItem] = &protocol.ChanceCheckResultData{
|
122
|
+ r := &protocol.ChanceCheckResultData{
|
|
|
123
|
+ CheckPid: v.CheckPid,
|
|
|
124
|
+ CheckId: v.CheckId,
|
67
|
CheckItem: v.CheckItem,
|
125
|
CheckItem: v.CheckItem,
|
68
|
CustomItemData: userAnswer,
|
126
|
CustomItemData: userAnswer,
|
69
|
}
|
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 {
|
70
|
|
141
|
|
|
|
142
|
+ checkItemsLv2[v.CheckPid] = utils.NewArraySetInt64()
|
|
|
143
|
+ checkItemsLv2[v.CheckPid].Add(v.CheckId)
|
|
|
144
|
+ }
|
|
|
145
|
+ }
|
71
|
}
|
146
|
}
|
72
|
usernameMap := make(map[string]string)
|
147
|
usernameMap := make(map[string]string)
|
73
|
for _, v := range userIds.ToSlice() {
|
148
|
for _, v := range userIds.ToSlice() {
|
|
@@ -80,31 +155,38 @@ func getChanceCheckResultData(chanceId int64) (protocol.ReponseChanceCheckResult |
|
@@ -80,31 +155,38 @@ func getChanceCheckResultData(chanceId int64) (protocol.ReponseChanceCheckResult |
80
|
}
|
155
|
}
|
81
|
rsp.CustomItem = append(rsp.CustomItem, usernameMap[idString])
|
156
|
rsp.CustomItem = append(rsp.CustomItem, usernameMap[idString])
|
82
|
}
|
157
|
}
|
83
|
- for _, v := range checkItems.ToSlice() {
|
158
|
+ for _, Lv1 := range checkItemsLv1.ToSlice() {
|
|
|
159
|
+ // 处理一级数据
|
84
|
newCustomItemData := map[string]string{}
|
160
|
newCustomItemData := map[string]string{}
|
85
|
- for kk, vv := range usernameMap {
|
|
|
86
|
- if answer, ok := checkResultMap[v].CustomItemData[kk]; ok {
|
|
|
87
|
- newCustomItemData[vv] = answer
|
161
|
+ for uid, uname := range usernameMap {
|
|
|
162
|
+ if answer, ok := checkResultMap[Lv1].CustomItemData[uid]; ok {
|
|
|
163
|
+ newCustomItemData[uname] = answer
|
88
|
} else {
|
164
|
} else {
|
89
|
- newCustomItemData[vv] = ""
|
165
|
+ newCustomItemData[uname] = ""
|
90
|
}
|
166
|
}
|
91
|
}
|
167
|
}
|
92
|
- answerYes := 0 //回答:是
|
|
|
93
|
- answerNo := 0 //回答:否
|
|
|
94
|
- answerAny := 0 //回答:不清楚
|
|
|
95
|
- checkResultMap[v].CustomItemData = newCustomItemData
|
|
|
96
|
- for _, answerData := range checkResultMap[v].CustomItemData {
|
|
|
97
|
- switch answerData {
|
|
|
98
|
- case "是":
|
|
|
99
|
- answerYes++
|
|
|
100
|
- case "否":
|
|
|
101
|
- answerNo++
|
|
|
102
|
- case "不清楚":
|
|
|
103
|
- answerAny++
|
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])
|
104
|
}
|
188
|
}
|
105
|
}
|
189
|
}
|
106
|
- checkResultMap[v].Total = fmt.Sprintf("是:%d 否:%d 不清楚:%d", answerYes, answerNo, answerAny)
|
|
|
107
|
- rsp.CheckData = append(rsp.CheckData, *checkResultMap[v])
|
|
|
108
|
}
|
190
|
}
|
109
|
return rsp, nil
|
191
|
return rsp, nil
|
110
|
}
|
192
|
}
|