作者 yangfu

修改 筛选历史/详情

@@ -31,34 +31,21 @@ const ( @@ -31,34 +31,21 @@ const (
31 const ( 31 const (
32 OptionYes = "是" 32 OptionYes = "是"
33 OptionNo = "否" 33 OptionNo = "否"
34 - OptionNoCertain = "不清楚" 34 + OptionUncertain = "不清楚"
35 ) 35 )
36 36
37 /*机会-自查内容*/ 37 /*机会-自查内容*/
38 var CheckOptionsCommit = []CheckOption{{Item: "是", NeedOther: false}, {Item: "否", NeedOther: false}, {Item: "不清楚", NeedOther: false}} 38 var CheckOptionsCommit = []CheckOption{{Item: "是", NeedOther: false}, {Item: "否", NeedOther: false}, {Item: "不清楚", NeedOther: false}}
39 var CheckOptionsApprove = []CheckOption{{Item: "是", NeedOther: false}, {Item: "否", NeedOther: true}, {Item: "不清楚", NeedOther: false}} 39 var CheckOptionsApprove = []CheckOption{{Item: "是", NeedOther: false}, {Item: "否", NeedOther: true}, {Item: "不清楚", NeedOther: false}}
40 40
41 -//自查结果列表 41 +/*自查结果列表*/
42 type SelfCheckResults []selfCheckResult 42 type SelfCheckResults []selfCheckResult
43 type selfCheckResult struct { 43 type selfCheckResult struct {
44 Item string `json:"item"` 44 Item string `json:"item"`
45 Total int `json:"total"` 45 Total int `json:"total"`
46 } 46 }
47 47
48 -//自查项列表  
49 -func NewSelfChecks(data string) (rsp SelfChecks) {  
50 - if len(data) == 0 {  
51 - return  
52 - }  
53 - e := json.Unmarshal([]byte(data), &rsp)  
54 - if e != nil {  
55 - log.Error(e)  
56 - }  
57 - return  
58 -}  
59 -  
60 -type SelfChecks []SelfCheck  
61 - 48 +/*自查项*/
62 type SelfCheck struct { 49 type SelfCheck struct {
63 CheckItem string `json:"checkItem"` 50 CheckItem string `json:"checkItem"`
64 GroupId int64 `json:"groupId"` //分组 51 GroupId int64 `json:"groupId"` //分组
@@ -69,10 +56,27 @@ type SelfCheck struct { @@ -69,10 +56,27 @@ type SelfCheck struct {
69 ParentId int64 `json:"parentId"` 56 ParentId int64 `json:"parentId"`
70 } 57 }
71 58
  59 +//自查项 键值
72 func (c SelfCheck) Key() string { 60 func (c SelfCheck) Key() string {
73 return fmt.Sprintf("%v-%v", c.GroupId, c.CheckItem) 61 return fmt.Sprintf("%v-%v", c.GroupId, c.CheckItem)
74 } 62 }
75 63
  64 +//新建自查项列表
  65 +//@data json格式的数据体
  66 +func NewSelfChecks(data string) (rsp SelfChecks) {
  67 + if len(data) == 0 {
  68 + return
  69 + }
  70 + e := json.Unmarshal([]byte(data), &rsp)
  71 + if e != nil {
  72 + log.Error(e)
  73 + }
  74 + return
  75 +}
  76 +
  77 +/*自查项列表*/
  78 +type SelfChecks []SelfCheck
  79 +
76 //统计自查结果 80 //统计自查结果
77 func (s SelfChecks) Static() SelfCheckResults { 81 func (s SelfChecks) Static() SelfCheckResults {
78 if len(s) == 0 { 82 if len(s) == 0 {
@@ -124,6 +128,9 @@ func (s SelfChecks) String() string { @@ -124,6 +128,9 @@ func (s SelfChecks) String() string {
124 var buf bytes.Buffer 128 var buf bytes.Buffer
125 for i := range s { 129 for i := range s {
126 c := s[i] 130 c := s[i]
  131 + if len(c.Answer) == 0 {
  132 + continue
  133 + }
127 if len(c.Reason) == 0 { 134 if len(c.Reason) == 0 {
128 buf.WriteString(fmt.Sprintf("\n%v:%v;", c.CheckItem, c.Answer)) 135 buf.WriteString(fmt.Sprintf("\n%v:%v;", c.CheckItem, c.Answer))
129 } else { 136 } else {
@@ -132,6 +139,8 @@ func (s SelfChecks) String() string { @@ -132,6 +139,8 @@ func (s SelfChecks) String() string {
132 } 139 }
133 return buf.String() 140 return buf.String()
134 } 141 }
  142 +
  143 +//比较自查内容 ,返回差级
135 func (s SelfChecks) Compare(dst string) (rspChecks SelfChecks, err error) { 144 func (s SelfChecks) Compare(dst string) (rspChecks SelfChecks, err error) {
136 var ( 145 var (
137 dstChecks SelfChecks 146 dstChecks SelfChecks
@@ -154,12 +163,12 @@ func (s SelfChecks) Compare(dst string) (rspChecks SelfChecks, err error) { @@ -154,12 +163,12 @@ func (s SelfChecks) Compare(dst string) (rspChecks SelfChecks, err error) {
154 for i := range s { 163 for i := range s {
155 c := s[i] 164 c := s[i]
156 if v, ok := mapChecks[c.Key()]; ok { 165 if v, ok := mapChecks[c.Key()]; ok {
157 - //回答不一 166 + //回答不一
158 if !strings.EqualFold(c.Answer, v.Answer) { 167 if !strings.EqualFold(c.Answer, v.Answer) {
159 rspChecks = append(rspChecks, c) 168 rspChecks = append(rspChecks, c)
160 continue 169 continue
161 } 170 }
162 - if len(c.Reason) > 0 { 171 + if len(strings.TrimSpace(c.Reason)) > 0 {
163 rspChecks = append(rspChecks, c) 172 rspChecks = append(rspChecks, c)
164 continue 173 continue
165 } 174 }
@@ -199,7 +208,7 @@ func (s SelfChecks) SetSelfChecksLevel1ByRule() (err error) { @@ -199,7 +208,7 @@ func (s SelfChecks) SetSelfChecksLevel1ByRule() (err error) {
199 cntYes++ 208 cntYes++
200 } else if strings.EqualFold(strings.TrimSpace(answer), OptionNo) { 209 } else if strings.EqualFold(strings.TrimSpace(answer), OptionNo) {
201 cntNo++ 210 cntNo++
202 - } else if strings.EqualFold(strings.TrimSpace(answer), OptionNoCertain) { 211 + } else if strings.EqualFold(strings.TrimSpace(answer), OptionUncertain) {
203 cntUncertain++ 212 cntUncertain++
204 } 213 }
205 } 214 }
@@ -210,7 +219,7 @@ func (s SelfChecks) SetSelfChecksLevel1ByRule() (err error) { @@ -210,7 +219,7 @@ func (s SelfChecks) SetSelfChecksLevel1ByRule() (err error) {
210 } else if cntNo > 0 { 219 } else if cntNo > 0 {
211 s[gIdx].Answer = OptionNo 220 s[gIdx].Answer = OptionNo
212 } else if cntUncertain > 0 { 221 } else if cntUncertain > 0 {
213 - s[gIdx].Answer = OptionNoCertain 222 + s[gIdx].Answer = OptionUncertain
214 } 223 }
215 } 224 }
216 if hasSub && cntYes == 0 && cntNo == 0 && cntUncertain == 0 { 225 if hasSub && cntYes == 0 && cntNo == 0 && cntUncertain == 0 {
@@ -223,7 +232,19 @@ func (s SelfChecks) SetSelfChecksLevel1ByRule() (err error) { @@ -223,7 +232,19 @@ func (s SelfChecks) SetSelfChecksLevel1ByRule() (err error) {
223 return 232 return
224 } 233 }
225 234
226 -//自查问题 235 +//格式化数据结构
  236 +func (s SelfChecks) Format() {
  237 + if len(s) == 0 {
  238 + return
  239 + }
  240 + for i := range s {
  241 + if strings.TrimSpace(s[i].Answer) == OptionNo {
  242 + s[i].Reason = strings.TrimSpace(s[i].Reason)
  243 + }
  244 + }
  245 +}
  246 +
  247 +//新建自查问题
227 func NewCheckQuestion(checkItem, title string, groupId int64, ops []CheckOption) *CheckQuestion { 248 func NewCheckQuestion(checkItem, title string, groupId int64, ops []CheckOption) *CheckQuestion {
228 return &CheckQuestion{ 249 return &CheckQuestion{
229 CheckItem: checkItem, 250 CheckItem: checkItem,
@@ -233,6 +254,7 @@ func NewCheckQuestion(checkItem, title string, groupId int64, ops []CheckOption) @@ -233,6 +254,7 @@ func NewCheckQuestion(checkItem, title string, groupId int64, ops []CheckOption)
233 } 254 }
234 } 255 }
235 256
  257 +/*问题*/
236 type CheckQuestion struct { 258 type CheckQuestion struct {
237 Id int64 `json:"id"` 259 Id int64 `json:"id"`
238 ParentId int64 `json:"parentId"` 260 ParentId int64 `json:"parentId"`
@@ -246,60 +268,14 @@ type CheckQuestion struct { @@ -246,60 +268,14 @@ type CheckQuestion struct {
246 268
247 Required bool `json:"required"` //是否必填 269 Required bool `json:"required"` //是否必填
248 } 270 }
  271 +
  272 +/*问题选项*/
249 type CheckOption struct { 273 type CheckOption struct {
250 Item string `json:"item"` 274 Item string `json:"item"`
251 NeedOther bool `json:"needOther"` //是否需填写其他的内容【1:需要】【2:不需要】 275 NeedOther bool `json:"needOther"` //是否需填写其他的内容【1:需要】【2:不需要】
252 } 276 }
253 277
254 -/*CheckQuestions 自查问题列表*/  
255 -type CheckQuestionsRequest struct {  
256 - Type int `json:"type"` //0.自查 1.筛选结果  
257 - ChanceId int64 `json:"chanceId" valid:"Required"`  
258 -}  
259 -type CheckQuestionsResponse struct {  
260 - Questions []*CheckQuestion `json:"questions"`  
261 -}  
262 -  
263 -//SiftingPool 筛选池  
264 -type SiftingPoolRequest struct {  
265 - PageInfo  
266 - Uid int64 `json:"uid"` //注入用户 测试使用  
267 - SubmitStatus int `json:"submitStatus"` //0:待我提交 1:提交  
268 - SiftedStatus int `-` //筛选状态 1:提交中 2:通过 3:不通过  
269 -}  
270 -type SiftingPoolResponse struct {  
271 - ChancePoolResponse  
272 -}  
273 -  
274 -/*筛选结果 SiftingResults */  
275 -type SiftingResultsRequest struct {  
276 - PageInfo  
277 - Uid int64 `json:"uid"` //注入用户 测试使用  
278 - SiftedStatus int `json:"siftingStatus"` //筛选状态 1:待处理 2:通过 3:不通过  
279 -}  
280 -type SiftingResultsResponse struct {  
281 - ChancePoolResponse  
282 -}  
283 -  
284 -/*SubmitChecks 提交自查*/  
285 -type SubmitChecksRequest struct {  
286 - //Type int `json:"type"` //1.审核人  
287 - Uid int64 `json:"uid"`  
288 - ChanceId int64 `json:"chanceId" valid:"Required"`  
289 - SelfChecks SelfChecks `json:"selfChecks"`  
290 -}  
291 -type SubmitChecksResponse struct {  
292 -}  
293 -  
294 -/*SiftingResultsItemHistory 筛选历史*/  
295 -type SiftingResultsItemHistoryRequest struct {  
296 - ChanceId int64 `json:"chanceId" valid:"Required"`  
297 -}  
298 -type SiftingResultsItemHistoryResponse struct {  
299 - SiftingResults SiftingResults `json:"siftingResults"`  
300 - TotalSubmitters int `json:"totalSubmitters"`  
301 -}  
302 - 278 +//筛选结果
303 type SiftingResult struct { 279 type SiftingResult struct {
304 CheckId int `json:"checkId"` //检查项id 280 CheckId int `json:"checkId"` //检查项id
305 CheckParentId int64 `json:"parentId"` //项父id 281 CheckParentId int64 `json:"parentId"` //项父id
@@ -315,12 +291,9 @@ type SiftingResult struct { @@ -315,12 +291,9 @@ type SiftingResult struct {
315 SubSiftingResults SiftingResults `json:"subSiftingResults"` 291 SubSiftingResults SiftingResults `json:"subSiftingResults"`
316 } 292 }
317 293
  294 +//筛选结果列表
318 type SiftingResults []SiftingResult 295 type SiftingResults []SiftingResult
319 296
320 -func (s SiftingResults) AddStatic(checkId int, answer string) {  
321 - s.addStatic(checkId, answer)  
322 -}  
323 -  
324 //清空统计结果 297 //清空统计结果
325 func (s SiftingResults) ClearStatic() { 298 func (s SiftingResults) ClearStatic() {
326 for i := range s { 299 for i := range s {
@@ -332,7 +305,43 @@ func (s SiftingResults) ClearStatic() { @@ -332,7 +305,43 @@ func (s SiftingResults) ClearStatic() {
332 } 305 }
333 } 306 }
334 307
  308 +/*
  309 +设置一级筛选结果
  310 +
  311 +单个维度显示“是”、“否”、“不清楚”的规则:
  312 + 1、所有人均选择“是”,则该维度的结果为“是”
  313 + 2、只要有一个“否”,则该维度的结果为“否” ,不需要显示理由
  314 + 3、其他情况则显示为“不清楚”
  315 +*/
  316 +func (s SiftingResults) SetSelfChecksLevel1ByRule() {
  317 + for i := range s {
  318 + tmpAnswer := ""
  319 + if s[i].TotalNo > 0 {
  320 + tmpAnswer = OptionNo
  321 + }
  322 + if s[i].TotalYes > 0 && s[i].TotalNo == 0 && s[i].TotalUncertain == 0 {
  323 + tmpAnswer = OptionYes
  324 + }
  325 + if s[i].TotalNo == 0 && s[i].TotalUncertain > 0 {
  326 + tmpAnswer = OptionUncertain
  327 + }
  328 + s[i].TotalNo = 0
  329 + s[i].TotalYes = 0
  330 + s[i].TotalUncertain = 0
  331 + if tmpAnswer == OptionNo {
  332 + s[i].TotalNo = s[i].TotalSubmitters
  333 + } else if tmpAnswer == OptionYes {
  334 + s[i].TotalYes = s[i].TotalSubmitters
  335 + } else if tmpAnswer == OptionUncertain {
  336 + s[i].TotalUncertain = s[i].TotalSubmitters
  337 + }
  338 + }
  339 +}
  340 +
335 //添加统计 341 //添加统计
  342 +func (s SiftingResults) AddStatic(checkId int, answer string) {
  343 + s.addStatic(checkId, answer)
  344 +}
336 func (s SiftingResults) addStatic(checkId int, answer string) { 345 func (s SiftingResults) addStatic(checkId int, answer string) {
337 for i := range s { 346 for i := range s {
338 if s[i].CheckId == checkId { 347 if s[i].CheckId == checkId {
@@ -344,7 +353,7 @@ func (s SiftingResults) addStatic(checkId int, answer string) { @@ -344,7 +353,7 @@ func (s SiftingResults) addStatic(checkId int, answer string) {
344 case OptionNo: 353 case OptionNo:
345 s[i].TotalNo++ 354 s[i].TotalNo++
346 break 355 break
347 - case OptionNoCertain: 356 + case OptionUncertain:
348 s[i].TotalUncertain++ 357 s[i].TotalUncertain++
349 break 358 break
350 default: 359 default:
@@ -359,16 +368,6 @@ func (s SiftingResults) addStatic(checkId int, answer string) { @@ -359,16 +368,6 @@ func (s SiftingResults) addStatic(checkId int, answer string) {
359 } 368 }
360 } 369 }
361 370
362 -/*SiftingResultsItemDetail 筛选历史详情*/  
363 -type SiftingResultsItemDetailRequest struct {  
364 - ChanceId int64 `json:"chanceId" valid:"Required"`  
365 - CheckId int `json:"checkId" valid:"Required"` //检查项id  
366 -}  
367 -type SiftingResultsItemDetailResponse struct {  
368 - SiftingResultDetails []SiftingResultDetail `json:"siftingResultDetails"`  
369 - TotalSubmitters int `json:"totalSubmitters"` //总提交人数  
370 -}  
371 -  
372 //筛选结果详情 371 //筛选结果详情
373 type SiftingResultDetail struct { 372 type SiftingResultDetail struct {
374 Option string `json:"option"` //选项:是 否 不清楚 373 Option string `json:"option"` //选项:是 否 不清楚
@@ -382,3 +381,58 @@ type SiftingCommitItem struct { @@ -382,3 +381,58 @@ type SiftingCommitItem struct {
382 Provider *BaseUserInfo `json:"provider"` 381 Provider *BaseUserInfo `json:"provider"`
383 Reason string `json:"reason"` //理由 382 Reason string `json:"reason"` //理由
384 } 383 }
  384 +
  385 +/******************REQUEST/RESPONSE (请求应答实体)*******************/
  386 +/*CheckQuestions 自查问题列表*/
  387 +type CheckQuestionsRequest struct {
  388 + Type int `json:"type"` //0.自查 1.筛选结果
  389 + ChanceId int64 `json:"chanceId" valid:"Required"`
  390 +}
  391 +type CheckQuestionsResponse struct {
  392 + Questions []*CheckQuestion `json:"questions"`
  393 +}
  394 +
  395 +//SiftingPool 筛选池
  396 +type SiftingPoolRequest struct {
  397 + PageInfo
  398 + Uid int64 `json:"uid"` //注入用户 测试使用
  399 + SubmitStatus int `json:"submitStatus"` //0:待我提交 1:提交
  400 + SiftedStatus int `-` //筛选状态 1:提交中 2:通过 3:不通过
  401 +}
  402 +type SiftingPoolResponse struct{ ChancePoolResponse }
  403 +
  404 +/*筛选结果 SiftingResults */
  405 +type SiftingResultsRequest struct {
  406 + PageInfo
  407 + Uid int64 `json:"uid"` //注入用户 测试使用
  408 + SiftedStatus int `json:"siftingStatus"` //筛选状态 1:待处理 2:通过 3:不通过
  409 +}
  410 +type SiftingResultsResponse struct{ ChancePoolResponse }
  411 +
  412 +/*SubmitChecks 提交自查*/
  413 +type SubmitChecksRequest struct {
  414 + //Type int `json:"type"` //1.审核人
  415 + Uid int64 `json:"uid"`
  416 + ChanceId int64 `json:"chanceId" valid:"Required"`
  417 + SelfChecks SelfChecks `json:"selfChecks"`
  418 +}
  419 +type SubmitChecksResponse struct{}
  420 +
  421 +/*SiftingResultsItemHistory 筛选历史*/
  422 +type SiftingResultsItemHistoryRequest struct {
  423 + ChanceId int64 `json:"chanceId" valid:"Required"`
  424 +}
  425 +type SiftingResultsItemHistoryResponse struct {
  426 + SiftingResults SiftingResults `json:"siftingResults"`
  427 + TotalSubmitters int `json:"totalSubmitters"`
  428 +}
  429 +
  430 +/*SiftingResultsItemDetail 筛选历史详情*/
  431 +type SiftingResultsItemDetailRequest struct {
  432 + ChanceId int64 `json:"chanceId" valid:"Required"`
  433 + CheckId int `json:"checkId" valid:"Required"` //检查项id
  434 +}
  435 +type SiftingResultsItemDetailResponse struct {
  436 + SiftingResultDetails []SiftingResultDetail `json:"siftingResultDetails"`
  437 + TotalSubmitters int `json:"totalSubmitters"` //总提交人数
  438 +}
  1 +package protocol
  2 +
  3 +import (
  4 + "encoding/json"
  5 + "fmt"
  6 + "testing"
  7 +)
  8 +
  9 +func TestSelfChecks(t *testing.T) {
  10 + nsc := func(id, pid int64, checkItem, answer string) SelfCheck {
  11 + item := SelfCheck{
  12 + CheckItem: checkItem, Answer: answer, Id: id, ParentId: pid,
  13 + }
  14 + item.GroupId = pid
  15 + if pid == 0 {
  16 + item.GroupId = id
  17 + }
  18 + return item
  19 + }
  20 + nscNo := func(id, pid int64, checkItem, answer, reason string) SelfCheck {
  21 + item := nsc(id, pid, checkItem, answer)
  22 + item.Reason = reason
  23 + return item
  24 + }
  25 + input := SelfChecks([]SelfCheck{
  26 + nsc(1, 0, "1", ""),
  27 + nsc(2, 1, "2", OptionYes),
  28 + nsc(3, 1, "3", OptionNo),
  29 + nsc(4, 1, "4", OptionUncertain),
  30 + nsc(5, 1, "5", ""),
  31 +
  32 + nsc(6, 0, "6", ""),
  33 + nsc(7, 6, "7", OptionUncertain),
  34 + nscNo(8, 6, "8", OptionNo, " "),
  35 + nsc(9, 6, "9", OptionUncertain),
  36 + nsc(10, 6, "10", ""),
  37 +
  38 + nsc(11, 0, "11", OptionYes),
  39 + nsc(12, 0, "12", OptionYes),
  40 + })
  41 + input.SetSelfChecksLevel1ByRule()
  42 + if input[0].Answer != OptionYes || input[5].Answer != OptionNo {
  43 + t.Fatal(fmt.Sprintf("SetSelfChecksLevel1ByRule Fail"))
  44 + }
  45 + if input.Static()[0].Total != 3 || input.Static()[0].Item != OptionYes {
  46 + t.Fatal(fmt.Sprintf("Static Fail"))
  47 + }
  48 + if input[7].Reason != " " {
  49 + t.Fatal("reason data error")
  50 + }
  51 + input.Format()
  52 + if input[7].Reason == " " {
  53 + t.Fatal("reason data error")
  54 + }
  55 + t.Log(input.String())
  56 +
  57 + inputCompare := SelfChecks([]SelfCheck{
  58 + nsc(1, 0, "1", ""),
  59 + nsc(2, 1, "2", OptionYes),
  60 + nsc(3, 1, "3", OptionNo),
  61 + nsc(4, 1, "4", OptionNo), //diff
  62 + nsc(5, 1, "5", ""),
  63 +
  64 + nsc(6, 0, "6", ""),
  65 + nsc(7, 6, "7", OptionUncertain),
  66 + nscNo(8, 6, "8", OptionNo, " "),
  67 + nsc(9, 6, "9", OptionUncertain),
  68 + nsc(10, 6, "10", ""),
  69 +
  70 + nsc(11, 0, "11", OptionYes),
  71 + nsc(12, 0, "12", OptionNo), //diff
  72 + })
  73 + inputCompare.SetSelfChecksLevel1ByRule()
  74 + inputCompare.Format()
  75 + data, err := json.Marshal(input)
  76 + if err != nil {
  77 + t.Fatal(err)
  78 + }
  79 + o, err := inputCompare.Compare(string(data))
  80 + if err != nil {
  81 + t.Fatal(err)
  82 + }
  83 + if len(o) != 2 {
  84 + t.Fatal("Compare fail")
  85 + }
  86 + t.Log("Compare:", o.String())
  87 +}
  88 +
  89 +func TestSiftingResults(t *testing.T) {
  90 +
  91 +}
@@ -566,5 +566,6 @@ func GetChanceSelfChecks(chanceInfo *models.Chance) []protocol.SelfCheck { @@ -566,5 +566,6 @@ func GetChanceSelfChecks(chanceInfo *models.Chance) []protocol.SelfCheck {
566 } 566 }
567 return lv1List 567 return lv1List
568 } 568 }
  569 + protocol.SelfChecks(selfChecks).Format()
569 return selfChecks 570 return selfChecks
570 } 571 }
@@ -51,7 +51,6 @@ func SiftingPool(header *protocol.RequestHeader, request *protocol.SiftingPoolRe @@ -51,7 +51,6 @@ func SiftingPool(header *protocol.RequestHeader, request *protocol.SiftingPoolRe
51 51
52 rsp.List = append(rsp.List, commItem) 52 rsp.List = append(rsp.List, commItem)
53 } 53 }
54 -  
55 return 54 return
56 } 55 }
57 56
@@ -289,7 +288,7 @@ func collectChanceCheckResultData(checkResultData []*models.ChanceCheckResult) p @@ -289,7 +288,7 @@ func collectChanceCheckResultData(checkResultData []*models.ChanceCheckResult) p
289 dd.Answer = protocol.OptionYes 288 dd.Answer = protocol.OptionYes
290 } 289 }
291 if checkResultSlice[i].AnswerNo == 0 && checkResultSlice[i].AnswerAny > 0 { 290 if checkResultSlice[i].AnswerNo == 0 && checkResultSlice[i].AnswerAny > 0 {
292 - dd.Answer = protocol.OptionNoCertain 291 + dd.Answer = protocol.OptionUncertain
293 } 292 }
294 selfCheckData = append(selfCheckData, dd) 293 selfCheckData = append(selfCheckData, dd)
295 for j := range checkResultSlice[i].Child { 294 for j := range checkResultSlice[i].Child {
@@ -308,7 +307,7 @@ func collectChanceCheckResultData(checkResultData []*models.ChanceCheckResult) p @@ -308,7 +307,7 @@ func collectChanceCheckResultData(checkResultData []*models.ChanceCheckResult) p
308 dd.Answer = protocol.OptionYes 307 dd.Answer = protocol.OptionYes
309 } 308 }
310 if child.AnswerNo == 0 && child.AnswerAny > 0 { 309 if child.AnswerNo == 0 && child.AnswerAny > 0 {
311 - dd.Answer = protocol.OptionNoCertain 310 + dd.Answer = protocol.OptionUncertain
312 } 311 }
313 selfCheckData = append(selfCheckData, dd) 312 selfCheckData = append(selfCheckData, dd)
314 } 313 }
@@ -339,6 +338,7 @@ func SiftingResultsItemHistory(header *protocol.RequestHeader, request *protocol @@ -339,6 +338,7 @@ func SiftingResultsItemHistory(header *protocol.RequestHeader, request *protocol
339 item := checkResults[i] 338 item := checkResults[i]
340 rsp.SiftingResults.AddStatic(item.CheckId, item.Answer) 339 rsp.SiftingResults.AddStatic(item.CheckId, item.Answer)
341 } 340 }
  341 + rsp.SiftingResults.SetSelfChecksLevel1ByRule()
342 return 342 return
343 } 343 }
344 344
@@ -389,8 +389,7 @@ func NewSiftingResults(checkResults []*models.ChanceCheckResult) protocol.Siftin @@ -389,8 +389,7 @@ func NewSiftingResults(checkResults []*models.ChanceCheckResult) protocol.Siftin
389 func SiftingResultsItemDetail(header *protocol.RequestHeader, request *protocol.SiftingResultsItemDetailRequest) (rsp *protocol.SiftingResultsItemDetailResponse, err error) { 389 func SiftingResultsItemDetail(header *protocol.RequestHeader, request *protocol.SiftingResultsItemDetailRequest) (rsp *protocol.SiftingResultsItemDetailResponse, err error) {
390 var ( 390 var (
391 checkResults []*models.ChanceCheckResult 391 checkResults []*models.ChanceCheckResult
392 - sortList []string = []string{protocol.OptionYes, protocol.OptionNo, protocol.OptionNoCertain}  
393 - ids []int64 392 + sortList []string = []string{protocol.OptionYes, protocol.OptionNo, protocol.OptionUncertain}
394 ) 393 )
395 rsp = &protocol.SiftingResultsItemDetailResponse{} 394 rsp = &protocol.SiftingResultsItemDetailResponse{}
396 if checkResults, err = models.GetCheckResultsByCheckId(request.ChanceId, request.CheckId); err != nil { 395 if checkResults, err = models.GetCheckResultsByCheckId(request.ChanceId, request.CheckId); err != nil {
@@ -401,13 +400,15 @@ func SiftingResultsItemDetail(header *protocol.RequestHeader, request *protocol. @@ -401,13 +400,15 @@ func SiftingResultsItemDetail(header *protocol.RequestHeader, request *protocol.
401 log.Error(err) 400 log.Error(err)
402 return 401 return
403 } 402 }
404 - var tmpMap = make(map[string]protocol.SiftingResultDetail) 403 + var resultsMap = make(map[string]protocol.SiftingResultDetail)
405 for i := range checkResults { 404 for i := range checkResults {
406 checkResult := checkResults[i] 405 checkResult := checkResults[i]
407 - key := strings.TrimSpace(checkResult.Answer)  
408 - if len(key) == 0 { 406 + answer := strings.TrimSpace(checkResult.Answer)
  407 + if len(answer) == 0 {
409 continue 408 continue
410 } 409 }
  410 +
  411 + /*提交人信息*/
411 var provider *protocol.BaseUserInfo 412 var provider *protocol.BaseUserInfo
412 if provider, err = agg.GetUserBaseInfo(checkResult.UserCompanyId, header.CompanyId); err != nil { 413 if provider, err = agg.GetUserBaseInfo(checkResult.UserCompanyId, header.CompanyId); err != nil {
413 log.Error(err) 414 log.Error(err)
@@ -417,24 +418,25 @@ func SiftingResultsItemDetail(header *protocol.RequestHeader, request *protocol. @@ -417,24 +418,25 @@ func SiftingResultsItemDetail(header *protocol.RequestHeader, request *protocol.
417 Provider: provider, 418 Provider: provider,
418 Reason: checkResult.Reason, 419 Reason: checkResult.Reason,
419 } 420 }
420 - if v, ok := tmpMap[key]; ok { 421 +
  422 + //追加到Map列表
  423 + if v, ok := resultsMap[answer]; ok {
421 v.Items = append(v.Items, commitItem) 424 v.Items = append(v.Items, commitItem)
422 - tmpMap[key] = v 425 + resultsMap[answer] = v
423 } else { 426 } else {
424 - tmpMap[key] = protocol.SiftingResultDetail{  
425 - Option: key, 427 + resultsMap[answer] = protocol.SiftingResultDetail{
  428 + Option: answer,
426 Items: []protocol.SiftingCommitItem{commitItem}, 429 Items: []protocol.SiftingCommitItem{commitItem},
427 } 430 }
428 } 431 }
429 } 432 }
430 for i := range sortList { 433 for i := range sortList {
431 - if v, ok := tmpMap[sortList[i]]; ok { 434 + //返回数据
  435 + if v, ok := resultsMap[sortList[i]]; ok {
432 v.TotalSubmitters = len(v.Items) 436 v.TotalSubmitters = len(v.Items)
433 rsp.SiftingResultDetails = append(rsp.SiftingResultDetails, v) 437 rsp.SiftingResultDetails = append(rsp.SiftingResultDetails, v)
  438 + rsp.TotalSubmitters += len(v.Items)
434 } 439 }
435 } 440 }
436 - if ids, err = models.GetCheckResultAllSubmitters(request.ChanceId); err == nil {  
437 - rsp.TotalSubmitters = len(ids)  
438 - }  
439 return 441 return
440 } 442 }