by Robin at 20240722
This commit is contained in:
parent
2167befc4d
commit
b283c34f44
|
@ -59,7 +59,9 @@ const (
|
||||||
HvyogoSingleDistributeChargePercentageKey = "hvyogo_single_distribute_charge_percentage"
|
HvyogoSingleDistributeChargePercentageKey = "hvyogo_single_distribute_charge_percentage"
|
||||||
QuestionMapKey = "question_map"
|
QuestionMapKey = "question_map"
|
||||||
AgeScore2IQResultMapKey = "age_score_2_IQ_result_map"
|
AgeScore2IQResultMapKey = "age_score_2_IQ_result_map"
|
||||||
|
ClassScore2ClassResultMapKey = "class_score_2_class_result_map"
|
||||||
IQResultMapKey = "IQ_result_map"
|
IQResultMapKey = "IQ_result_map"
|
||||||
|
ClassResultMapKey = "class_result_map"
|
||||||
)
|
)
|
||||||
|
|
||||||
// del_flag
|
// del_flag
|
||||||
|
|
|
@ -16,9 +16,10 @@ type ApiListVO struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
type ApiClassSocreVO struct {
|
type ApiClassSocreVO struct {
|
||||||
ClassId int64 `json:"class_id"` // 大类id
|
ClassId int64 `json:"class_id"` // 大类id
|
||||||
Score int64 `json:"score"` // 得分
|
Score int64 `json:"score"` // 得分
|
||||||
Suggestions string `json:"suggestions"` // 建议
|
ClassBlockId int64 `json:"class_block_id"` // 大类得分key
|
||||||
|
Suggestions string `json:"suggestions"` // 建议
|
||||||
}
|
}
|
||||||
|
|
||||||
func (vo *ApiListVO) CopyRavenIQTest(test *dbstruct.RavenIQTest) *ApiListVO {
|
func (vo *ApiListVO) CopyRavenIQTest(test *dbstruct.RavenIQTest) *ApiListVO {
|
||||||
|
@ -33,8 +34,9 @@ func (vo *ApiListVO) CopyRavenIQTest(test *dbstruct.RavenIQTest) *ApiListVO {
|
||||||
vo.ClassScoreList = make([]*ApiClassSocreVO, 0)
|
vo.ClassScoreList = make([]*ApiClassSocreVO, 0)
|
||||||
for _, score := range test.ClassScoreList {
|
for _, score := range test.ClassScoreList {
|
||||||
vo.ClassScoreList = append(vo.ClassScoreList, &ApiClassSocreVO{
|
vo.ClassScoreList = append(vo.ClassScoreList, &ApiClassSocreVO{
|
||||||
ClassId: score.GetClassId(),
|
ClassId: score.GetClassId(),
|
||||||
Score: score.GetScore(),
|
Score: score.GetScore(),
|
||||||
|
ClassBlockId: score.GetClassBlockId(),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
return vo
|
return vo
|
||||||
|
|
|
@ -22,6 +22,19 @@ type AgeScore2IQResultMapCfg struct {
|
||||||
ScoreBlockIndex2IQBlockIdMap map[int]int64 `json:"score_block_index_2_IQ_block_id_map"` // 分数分段到IQ范围id的映射map
|
ScoreBlockIndex2IQBlockIdMap map[int]int64 `json:"score_block_index_2_IQ_block_id_map"` // 分数分段到IQ范围id的映射map
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type ClassScore2ClassResultMapCfg struct {
|
||||||
|
ClassId2ClassScoreBlockListMap map[int64][]int64 `json:"class_id_2_class_score_block_list_map" bson:"class_id_2_class_score_block_list_map"` // 大类Id到大类分数分布区域的映射map
|
||||||
|
}
|
||||||
|
|
||||||
type IQResultMapCfg struct {
|
type IQResultMapCfg struct {
|
||||||
Map map[int64]*IQResult `json:"map"`
|
Map map[int64]*IQResult `json:"map"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type ClassResult struct {
|
||||||
|
ClassId int64 `json:"class_id"` // 大类id
|
||||||
|
Description string `json:"description"` // 描述
|
||||||
|
}
|
||||||
|
|
||||||
|
type ClassResultMapCfg struct {
|
||||||
|
Map map[int64]*ClassResult `json:"map"`
|
||||||
|
}
|
||||||
|
|
|
@ -3619,17 +3619,33 @@ func (s *Service) ApiCreateRavenIQTest(ctx *gin.Context, req *Raven_IQ_testproto
|
||||||
req.TotalScore = goproto.Float64(totalScore)
|
req.TotalScore = goproto.Float64(totalScore)
|
||||||
|
|
||||||
// 换算智商及百分位
|
// 换算智商及百分位
|
||||||
cfg := apollostruct.AgeScore2IQResultMapCfg{}
|
ageScore2IQResultMapCfg := apollostruct.AgeScore2IQResultMapCfg{}
|
||||||
err = apollo.GetJson(consts.AgeScore2IQResultMapKey, &cfg, apollo.ApolloOpts().SetNamespace("Raven_IQ_test"))
|
err = apollo.GetJson(consts.AgeScore2IQResultMapKey, &ageScore2IQResultMapCfg, apollo.ApolloOpts().SetNamespace("Raven_IQ_test"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Error("Apollo read failed : %v", err)
|
logger.Error("Apollo read failed : %v", err)
|
||||||
ec = errcode.ErrCodeApolloReadFail
|
ec = errcode.ErrCodeApolloReadFail
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
ageBlockIdx := util.GetLastLessOrEqualForInt64(cfg.AgeBlockList, req.GetAge())
|
|
||||||
list := cfg.AgeBlockIndex2ScoreBlockListMap[ageBlockIdx]
|
classScore2ClassResultMapCfg := apollostruct.ClassScore2ClassResultMapCfg{}
|
||||||
|
err = apollo.GetJson(consts.ClassScore2ClassResultMapKey, &classScore2ClassResultMapCfg, apollo.ApolloOpts().SetNamespace("Raven_IQ_test"))
|
||||||
|
if err != nil {
|
||||||
|
logger.Error("Apollo read failed : %v", err)
|
||||||
|
ec = errcode.ErrCodeApolloReadFail
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
ageBlockIdx := util.GetLastLessOrEqualForInt64(ageScore2IQResultMapCfg.AgeBlockList, req.GetAge())
|
||||||
|
list := ageScore2IQResultMapCfg.AgeBlockIndex2ScoreBlockListMap[ageBlockIdx]
|
||||||
scoreBlockIdx := util.GetLastLessOrEqualForFloat64(list, req.GetTotalScore())
|
scoreBlockIdx := util.GetLastLessOrEqualForFloat64(list, req.GetTotalScore())
|
||||||
IQBlockId := cfg.ScoreBlockIndex2IQBlockIdMap[scoreBlockIdx]
|
IQBlockId := ageScore2IQResultMapCfg.ScoreBlockIndex2IQBlockIdMap[scoreBlockIdx]
|
||||||
|
|
||||||
|
for _, classScore := range req.ClassScoreList {
|
||||||
|
classScoreBlockList := classScore2ClassResultMapCfg.ClassId2ClassScoreBlockListMap[classScore.GetClassId()]
|
||||||
|
classScoreBlockIdx := util.GetLastLessOrEqualForInt64(classScoreBlockList, classScore.GetScore())
|
||||||
|
classScore.ClassBlockId = goproto.Int64(int64(classScoreBlockIdx))
|
||||||
|
}
|
||||||
|
|
||||||
req.IQBlockId = goproto.Int64(IQBlockId)
|
req.IQBlockId = goproto.Int64(IQBlockId)
|
||||||
|
|
||||||
err = _DefaultRavenIQTest.OpCreate(ctx, &Raven_IQ_testproto.OpCreateReq{
|
err = _DefaultRavenIQTest.OpCreate(ctx, &Raven_IQ_testproto.OpCreateReq{
|
||||||
|
@ -3664,16 +3680,30 @@ func (s *Service) ApiGetRavenIQTestList(ctx *gin.Context, req *Raven_IQ_testprot
|
||||||
vo.CopyRavenIQTest(test)
|
vo.CopyRavenIQTest(test)
|
||||||
|
|
||||||
// 填充业务数据
|
// 填充业务数据
|
||||||
cfg := apollostruct.IQResultMapCfg{}
|
IQResultMpcfg := apollostruct.IQResultMapCfg{}
|
||||||
err = apollo.GetJson(consts.IQResultMapKey, &cfg, apollo.ApolloOpts().SetNamespace("Raven_IQ_test"))
|
err = apollo.GetJson(consts.IQResultMapKey, &IQResultMpcfg, apollo.ApolloOpts().SetNamespace("Raven_IQ_test"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Error("Apollo read failed : %v", err)
|
logger.Error("Apollo read failed : %v", err)
|
||||||
ec = errcode.ErrCodeApolloReadFail
|
ec = errcode.ErrCodeApolloReadFail
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
IQResult := cfg.Map[vo.IQBlockId]
|
|
||||||
|
classResultMpCfg := apollostruct.ClassResultMapCfg{}
|
||||||
|
err = apollo.GetJson(consts.ClassResultMapKey, &classResultMpCfg, apollo.ApolloOpts().SetNamespace("Raven_IQ_test"))
|
||||||
|
if err != nil {
|
||||||
|
logger.Error("Apollo read failed : %v", err)
|
||||||
|
ec = errcode.ErrCodeApolloReadFail
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
IQResult := IQResultMpcfg.Map[vo.IQBlockId]
|
||||||
vo.Percentile = IQResult.Percentile
|
vo.Percentile = IQResult.Percentile
|
||||||
vo.Description = IQResult.Description
|
vo.Description = IQResult.Description
|
||||||
|
|
||||||
|
for _, classScore := range vo.ClassScoreList {
|
||||||
|
classResult := classResultMpCfg.Map[classScore.ClassBlockId]
|
||||||
|
classScore.Suggestions = classResult.Description
|
||||||
|
}
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,8 +19,9 @@ type RavenIQTestAnswer struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
type RavenIQTestClassScore struct {
|
type RavenIQTestClassScore struct {
|
||||||
ClassId *int64 `json:"class_id" bson:"class_id"` // 大类id
|
ClassId *int64 `json:"class_id" bson:"class_id"` // 大类id
|
||||||
Score *int64 `json:"score" bson:"score"` // 得分
|
Score *int64 `json:"score" bson:"score"` // 得分
|
||||||
|
ClassBlockId *int64 `json:"class_block_id" bson:"class_block_id"` // 大类得分key
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *RavenIQTest) GetId() int64 {
|
func (p *RavenIQTest) GetId() int64 {
|
||||||
|
@ -85,3 +86,10 @@ func (p *RavenIQTestClassScore) GetScore() int64 {
|
||||||
}
|
}
|
||||||
return *p.Score
|
return *p.Score
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (p *RavenIQTestClassScore) GetClassBlockId() int64 {
|
||||||
|
if p == nil || p.ClassBlockId == nil {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
return *p.ClassBlockId
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue