master
wubin 5 years ago
parent a4d6a44960
commit b37c5331e4

@ -51,7 +51,7 @@ func GetBaseAccessTopByAreaCode(c *gin.Context) {
if directly == "1" { if directly == "1" {
//获取中省直的学校 //获取中省直的学校
schoolArr := make([]string, 0) schoolArr := make([]string, 0)
schoolInfo, err := SchoolService.PageSchoolInfoByDistrictCode(areaCode, "-1") schoolInfo, err := SchoolService.PageSchoolInfoByDistrictCode(areaCode, "-1", directly)
if err != nil { if err != nil {
c.JSON(http.StatusOK, Model.Res{ c.JSON(http.StatusOK, Model.Res{
Success: false, Success: false,
@ -312,7 +312,7 @@ func GetDistrictBaseInfo(c *gin.Context) {
schoolArr := make([]string, 0) schoolArr := make([]string, 0)
if directly == "1" { if directly == "1" {
schoolInfo, err := SchoolService.PageSchoolInfoByDistrictCode(districtCode, "-1") schoolInfo, err := SchoolService.PageSchoolInfoByDistrictCode(districtCode, "-1", directly)
if err != nil { if err != nil {
c.JSON(http.StatusOK, Model.Res{ c.JSON(http.StatusOK, Model.Res{
Success: false, Success: false,

@ -66,14 +66,12 @@ func PageEduAssistInfoByDistrictCode(districtCode string, directly string) ([]Sc
2020-06-30 2020-06-30
xxbxlxm -1 xxbxlxm -1
*/ */
func PageSchoolInfoByDistrictCode(districtCode string, xxbxlxm string) ([]SchoolModel.School, error) { func PageSchoolInfoByDistrictCode(districtCode string, xxbxlxm string, directly string) ([]SchoolModel.School, error) {
enableFlagTerm := elastic.NewTermQuery("enable_flag", 1) enableFlagTerm := elastic.NewTermQuery("enable_flag", 1)
delFlagTerm := elastic.NewTermQuery("del_flag", 0) delFlagTerm := elastic.NewTermQuery("del_flag", 0)
var districtCodeTerm *elastic.TermQuery var districtCodeTerm *elastic.TermQuery
cityFlag := 0
if strings.HasSuffix(districtCode, "00") { //市 if strings.HasSuffix(districtCode, "00") { //市
districtCodeTerm = elastic.NewTermQuery("city_code", districtCode) districtCodeTerm = elastic.NewTermQuery("city_code", districtCode)
cityFlag = 1
} else { //区 } else { //区
districtCodeTerm = elastic.NewTermQuery("district_code", districtCode) districtCodeTerm = elastic.NewTermQuery("district_code", districtCode)
} }
@ -81,7 +79,7 @@ func PageSchoolInfoByDistrictCode(districtCode string, xxbxlxm string) ([]School
orgTypeTerm := elastic.NewTermQuery("data_content.org_type", "2") orgTypeTerm := elastic.NewTermQuery("data_content.org_type", "2")
var boolQuery *elastic.BoolQuery var boolQuery *elastic.BoolQuery
if xxbxlxm == "-1" { if xxbxlxm == "-1" {
if cityFlag == 1 { if directly == "1" {
interfaceArr := CommonUtil.ConvertStringArrToInterfaceArr([]string{"360", "811", "821"}) interfaceArr := CommonUtil.ConvertStringArrToInterfaceArr([]string{"360", "811", "821"})
directlyUnderTypeTerms := elastic.NewTermsQuery("data_content.xxjbzm", interfaceArr...) directlyUnderTypeTerms := elastic.NewTermsQuery("data_content.xxjbzm", interfaceArr...)
boolQuery = elastic.NewBoolQuery().Must(enableFlagTerm, delFlagTerm, districtCodeTerm, orgTypeTerm, directlyUnderTypeTerms) boolQuery = elastic.NewBoolQuery().Must(enableFlagTerm, delFlagTerm, districtCodeTerm, orgTypeTerm, directlyUnderTypeTerms)
@ -91,7 +89,7 @@ func PageSchoolInfoByDistrictCode(districtCode string, xxbxlxm string) ([]School
} else { } else {
xxbxlxmTerm := elastic.NewTermQuery("school_type", xxbxlxm) xxbxlxmTerm := elastic.NewTermQuery("school_type", xxbxlxm)
if cityFlag == 1 { if directly == "1" {
interfaceArr := CommonUtil.ConvertStringArrToInterfaceArr([]string{"360", "811", "821"}) interfaceArr := CommonUtil.ConvertStringArrToInterfaceArr([]string{"360", "811", "821"})
directlyUnderTypeTerms := elastic.NewTermsQuery("data_content.xxjbzm", interfaceArr...) directlyUnderTypeTerms := elastic.NewTermsQuery("data_content.xxjbzm", interfaceArr...)
boolQuery = elastic.NewBoolQuery().Must(enableFlagTerm, delFlagTerm, districtCodeTerm, orgTypeTerm, xxbxlxmTerm, directlyUnderTypeTerms) boolQuery = elastic.NewBoolQuery().Must(enableFlagTerm, delFlagTerm, districtCodeTerm, orgTypeTerm, xxbxlxmTerm, directlyUnderTypeTerms)

@ -11,13 +11,13 @@ import (
2020-06-30 2020-06-30
xxbxlxm -1 xxbxlxm -1
*/ */
func PageSchoolInfoByDistrictCode(districtCode string, xxbxlxm string) ([]SchoolModel.School, error) { func PageSchoolInfoByDistrictCode(districtCode string, xxbxlxm string, directly string) ([]SchoolModel.School, error) {
arr, err := SchoolDao.PageSchoolInfoByDistrictCode(districtCode, xxbxlxm) arr, err := SchoolDao.PageSchoolInfoByDistrictCode(districtCode, xxbxlxm, directly)
return arr, err return arr, err
} }
func PageEduAssistInfoByDistrictCode(districtCode string,directly string) ([]SchoolModel.EduAssist, error) { func PageEduAssistInfoByDistrictCode(districtCode string, directly string) ([]SchoolModel.EduAssist, error) {
arr, err := SchoolDao.PageEduAssistInfoByDistrictCode(districtCode,directly) arr, err := SchoolDao.PageEduAssistInfoByDistrictCode(districtCode, directly)
return arr, err return arr, err
} }
@ -57,9 +57,10 @@ func GetOrgTotalCount(areaCode string, orgType string) (int, error) {
count, err := SchoolDao.GetOrgTotalCount(areaCode, orgType) count, err := SchoolDao.GetOrgTotalCount(areaCode, orgType)
return count, err return count, err
} }
/** /**
*/ */
func GetDirectlyUnderOrgTotalCount(areaCode string, orgType string) (int, error) { func GetDirectlyUnderOrgTotalCount(areaCode string, orgType string) (int, error) {
count, err := SchoolDao.GetDirectlyUnderOrgTotalCount(areaCode, orgType) count, err := SchoolDao.GetDirectlyUnderOrgTotalCount(areaCode, orgType)
return count, err return count, err
@ -90,7 +91,7 @@ func GetBaseAccessTop(areaCode string, topNum string) ([]SchoolModel.BaseAccessT
return arr, err return arr, err
} }
func GetBaseDirectlyUnderAccessTop(schoolIds []string, topNum string)([]SchoolModel.BaseAccessTopAggsOrgId, error) { func GetBaseDirectlyUnderAccessTop(schoolIds []string, topNum string) ([]SchoolModel.BaseAccessTopAggsOrgId, error) {
arr, err := SchoolDao.GetBaseDirectlyUnderAccessTop(schoolIds, topNum) arr, err := SchoolDao.GetBaseDirectlyUnderAccessTop(schoolIds, topNum)
return arr, err return arr, err
} }
@ -108,4 +109,4 @@ func GetCityDirectlySchoolCount(cityCode string) (int, error) {
func GetCityDirectlyEduAssistCount(cityCode string) (int, error) { func GetCityDirectlyEduAssistCount(cityCode string) (int, error) {
count, err := SchoolDao.GetCityDirectlyEduAssistCount(cityCode) count, err := SchoolDao.GetCityDirectlyEduAssistCount(cityCode)
return count, err return count, err
} }

@ -83,10 +83,14 @@ func GetStudentCountAggsOrgByDistrict(c *gin.Context) {
districtCode := c.Query("districtCode") districtCode := c.Query("districtCode")
//学校办学类型 -1为全部 //学校办学类型 -1为全部
xxbxlx := c.Query("xxbxlx") xxbxlx := c.Query("xxbxlx")
directly := ""
if strings.HasSuffix(districtCode, "00") { //市
directly = "1"
}
//获取学校的数组 //获取学校的数组
schoolArr := make([]string, 0) schoolArr := make([]string, 0)
schoolInfo, err := SchoolService.PageSchoolInfoByDistrictCode(districtCode, xxbxlx) schoolInfo, err := SchoolService.PageSchoolInfoByDistrictCode(districtCode, xxbxlx, directly)
if err != nil { if err != nil {
c.JSON(http.StatusOK, Model.Res{ c.JSON(http.StatusOK, Model.Res{
Success: false, Success: false,
@ -138,42 +142,42 @@ func GetStudentCountAggsOrgByDistrict(c *gin.Context) {
*/ */
func GetStudentCountAggsXxbxlxByArea(c *gin.Context) { func GetStudentCountAggsXxbxlxByArea(c *gin.Context) {
areaCode := c.Query("areaCode") areaCode := c.Query("areaCode")
directly := c.Query("directly") directly := c.Query("directly")
cityCode := "" cityCode := ""
districtCode := "" districtCode := ""
if strings.HasSuffix(areaCode, "00") { //市 if strings.HasSuffix(areaCode, "00") { //市
if directly == "1" { cityCode = areaCode
districtCode = areaCode
} else {
cityCode = areaCode
}
} else { //区 } else { //区
districtCode = areaCode districtCode = areaCode
} }
//获取区的数组 //获取区的数组
districtArr := make([]string, 0) districtArr := make([]string, 0)
if len(cityCode) > 0 { //directly=1说明获取的是中省市,不需要根据市编码获取区的数组
//获取区信息 if directly == "1" {
areaInfo, err := AreaService.PageDistrictByCityCode(cityCode, "-1") if len(cityCode) > 0 {
if err != nil { //获取区信息
c.JSON(http.StatusOK, Model.Res{ areaInfo, err := AreaService.PageDistrictByCityCode(cityCode, "-1")
Success: false, if err != nil {
Message: err.Error(), c.JSON(http.StatusOK, Model.Res{
}) Success: false,
return Message: err.Error(),
} })
for i := range areaInfo { return
districtArr = append(districtArr, areaInfo[i].AreaCode) }
for i := range areaInfo {
districtArr = append(districtArr, areaInfo[i].AreaCode)
}
districtArr = append(districtArr, areaCode)
} }
districtArr = append(districtArr, areaCode)
} }
//获取学校的数组 //获取学校的数组
schoolArr := make([]string, 0) schoolArr := make([]string, 0)
if len(districtCode) > 0 { if len(districtCode) > 0 {
schoolInfo, err := SchoolService.PageSchoolInfoByDistrictCode(districtCode, "-1") schoolInfo, err := SchoolService.PageSchoolInfoByDistrictCode(districtCode, "-1", directly)
if err != nil { if err != nil {
c.JSON(http.StatusOK, Model.Res{ c.JSON(http.StatusOK, Model.Res{
Success: false, Success: false,

@ -168,10 +168,14 @@ func GetTeacherCountAggsSchoolByDistrict(c *gin.Context) {
districtCode := c.Query("districtCode") districtCode := c.Query("districtCode")
//学校办学类型 -1为全部 //学校办学类型 -1为全部
xxbxlx := c.Query("xxbxlx") xxbxlx := c.Query("xxbxlx")
directly := ""
if strings.HasSuffix(districtCode, "00") { //市
directly = "1"
}
//获取学校的数组 //获取学校的数组
schoolArr := make([]string, 0) schoolArr := make([]string, 0)
schoolInfo, err := SchoolService.PageSchoolInfoByDistrictCode(districtCode, xxbxlx) schoolInfo, err := SchoolService.PageSchoolInfoByDistrictCode(districtCode, xxbxlx, directly)
if err != nil { if err != nil {
c.JSON(http.StatusOK, Model.Res{ c.JSON(http.StatusOK, Model.Res{
Success: false, Success: false,
@ -258,7 +262,7 @@ func GetTeacherCountAggsXxbxlxByArea(c *gin.Context) {
//获取学校的数组 //获取学校的数组
schoolArr := make([]string, 0) schoolArr := make([]string, 0)
if len(districtCode) > 0 { if len(districtCode) > 0 {
schoolInfo, err := SchoolService.PageSchoolInfoByDistrictCode(districtCode, "-1") schoolInfo, err := SchoolService.PageSchoolInfoByDistrictCode(districtCode, "-1", directly)
if err != nil { if err != nil {
c.JSON(http.StatusOK, Model.Res{ c.JSON(http.StatusOK, Model.Res{
Success: false, Success: false,

Loading…
Cancel
Save