...
|
...
|
@@ -54,7 +54,7 @@ func buildChanceCheckResultData(checkResultData []models.ChanceCheckResult) (pro |
|
|
userIds := utils.NewArraySetInt64()
|
|
|
checkResultMap := map[int64]*protocol.ChanceCheckResultData{}
|
|
|
checkReusltSlice := []*protocol.ChanceCheckResultData{}
|
|
|
//按人区分问题的答案
|
|
|
//按人区分问题的答案 user_company_id check_id
|
|
|
userAnswer := make(map[int64]map[int64]models.ChanceCheckResult)
|
|
|
for i, resultData := range checkResultData {
|
|
|
if _, ok := checkResultMap[resultData.CheckId]; !ok {
|
...
|
...
|
@@ -271,3 +271,97 @@ func ChanceCheckResultNoPass(chanceId int64, companyId int64) error { |
|
|
}
|
|
|
return nil
|
|
|
}
|
|
|
|
|
|
type chanceCheckResultTotal struct {
|
|
|
GroupId int64
|
|
|
CheckItem string
|
|
|
CheckId int64
|
|
|
CheckPid int64
|
|
|
AnswerYes int
|
|
|
AnswerNo int
|
|
|
AnswerAny int
|
|
|
Child []*chanceCheckResultTotal
|
|
|
}
|
|
|
|
|
|
//collectChanceCheckResultData 汇总机会自查内容筛选结果
|
|
|
func collectChanceCheckResultData(checkResultData []models.ChanceCheckResult) ([]models.ChanceSelfCheckData, error) {
|
|
|
checkResultMap := map[int64]*chanceCheckResultTotal{}
|
|
|
checkReusltSlice := []*chanceCheckResultTotal{}
|
|
|
for _, resultData := range checkResultData {
|
|
|
answerYes := 0
|
|
|
answerNo := 0
|
|
|
answerAny := 0
|
|
|
switch resultData.Answer {
|
|
|
case "是":
|
|
|
answerYes++
|
|
|
case "否":
|
|
|
answerNo++
|
|
|
case "不清楚":
|
|
|
answerAny++
|
|
|
}
|
|
|
if _, ok := checkResultMap[resultData.CheckId]; !ok {
|
|
|
r := &chanceCheckResultTotal{
|
|
|
CheckId: resultData.CheckId,
|
|
|
CheckPid: resultData.CheckPid,
|
|
|
CheckItem: resultData.CheckItem,
|
|
|
GroupId: resultData.GroupId,
|
|
|
AnswerYes: answerYes,
|
|
|
AnswerNo: answerNo,
|
|
|
AnswerAny: answerAny,
|
|
|
}
|
|
|
checkResultMap[resultData.CheckId] = r
|
|
|
checkReusltSlice = append(checkReusltSlice, r)
|
|
|
} else {
|
|
|
checkResultMap[resultData.CheckId].AnswerYes += answerYes
|
|
|
checkResultMap[resultData.CheckId].AnswerNo += answerNo
|
|
|
checkResultMap[resultData.CheckId].AnswerAny += answerAny
|
|
|
}
|
|
|
}
|
|
|
//构建层级关系
|
|
|
for i := range checkReusltSlice {
|
|
|
if checkReusltSlice[i].CheckPid == 0 {
|
|
|
continue
|
|
|
}
|
|
|
pid := checkReusltSlice[i].CheckPid
|
|
|
if _, ok := checkResultMap[pid]; ok {
|
|
|
checkResultMap[pid].Child = append(checkResultMap[pid].Child, checkResultMap[pid])
|
|
|
}
|
|
|
}
|
|
|
var selfCheckData []models.ChanceSelfCheckData
|
|
|
for i := range checkReusltSlice {
|
|
|
if checkReusltSlice[i].CheckPid > 0 {
|
|
|
continue
|
|
|
}
|
|
|
dd := models.ChanceSelfCheckData{
|
|
|
CheckItem: checkReusltSlice[i].CheckItem,
|
|
|
GroupId: checkReusltSlice[i].GroupId,
|
|
|
}
|
|
|
if checkReusltSlice[i].AnswerNo > 0 {
|
|
|
dd.Answer = "否"
|
|
|
}
|
|
|
if checkReusltSlice[i].AnswerYes > 0 && checkReusltSlice[i].AnswerNo == 0 && checkReusltSlice[i].AnswerAny == 0 {
|
|
|
dd.Answer = "是"
|
|
|
}
|
|
|
if checkReusltSlice[i].AnswerNo == 0 && checkReusltSlice[i].AnswerAny > 0 {
|
|
|
dd.Answer = "不清楚"
|
|
|
}
|
|
|
selfCheckData = append(selfCheckData, dd)
|
|
|
for _, childdata := range checkReusltSlice[i].Child {
|
|
|
dd := models.ChanceSelfCheckData{
|
|
|
CheckItem: childdata.CheckItem,
|
|
|
GroupId: childdata.GroupId,
|
|
|
}
|
|
|
if childdata.AnswerNo > 0 {
|
|
|
dd.Answer = "否"
|
|
|
}
|
|
|
if childdata.AnswerYes > 0 && childdata.AnswerNo == 0 && childdata.AnswerAny == 0 {
|
|
|
dd.Answer = "是"
|
|
|
}
|
|
|
if childdata.AnswerNo == 0 && childdata.AnswerAny > 0 {
|
|
|
dd.Answer = "不清楚"
|
|
|
}
|
|
|
selfCheckData = append(selfCheckData, dd)
|
|
|
}
|
|
|
}
|
|
|
return selfCheckData, nil
|
|
|
} |
...
|
...
|
|