Эх сурвалжийг харах

Merge branch 'cygx_4.3' of http://8.136.199.33:3000/hongze/hongze_cygx into debug

xingzai 3 жил өмнө
parent
commit
48de4ee678

+ 117 - 0
controllers/report.go

@@ -1901,6 +1901,21 @@ func (this *ReportController) IndustryListByDepartmentPc() {
 		} else if articleIdSub == "" && articleIdInd == "" {
 			articleIdGroup = articleIdInd
 		}
+		slice := strings.Split(keyWord, "/")
+		if len(slice) > 1 {
+			for _, v := range slice {
+				subjectId, err := models.GetcygxIndustrialSubjectByName(v)
+				if err != nil {
+					br.Msg = "获取信息失败"
+					br.ErrMsg = "获取客户信息失败,Err:" + err.Error()
+					return
+				}
+				if subjectId != "" {
+
+				}
+				fmt.Println(v)
+			}
+		}
 	}
 
 	if articleIdGroup != "" {
@@ -1989,3 +2004,105 @@ func (this *ReportController) IndustryListByDepartmentPc() {
 	br.Msg = "获取成功"
 	br.Data = resp
 }
+
+// @Title 产业文章列表接口Pc端
+// @Description 获取产业文章列表接口Pc端
+// @Param   KeyWord   query   string  true       "搜索关键词"
+// @Success 200 {object} models.CygxIndustrySearchListPc
+// @router /industryAndArticle/listPc [get]
+func (this *ReportController) IndustryAndArticleListPc() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		this.Data["json"] = br
+		this.ServeJSON()
+	}()
+	user := this.User
+	if user == nil {
+		br.Msg = "请重新登录"
+		br.Ret = 408
+		return
+	}
+	uid := user.UserId
+	keyWord := this.GetString("KeyWord")
+	resp := new(models.CygxIndustrySearchListPc)
+	orderSrt := "update_time DESC"
+	condition := ` AND  subject_names LIKE '%` + keyWord + `%'`
+	list, err := models.GetIndustrialManagementAll(uid, condition, orderSrt, 0, 100)
+	if err != nil {
+		br.Msg = "获取信息失败"
+		br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
+		return
+	}
+	for k, v := range list {
+		industrialSubjectList, err := models.GetIndustrialSubjectAll(v.IndustrialManagementId)
+		if err != nil {
+			br.Msg = "获取信息失败"
+			br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
+			return
+		}
+		list[k].IndustrialSubjectList = industrialSubjectList
+		//list[k].LayoutTime = utils.TimeRemoveHms(v.LayoutTime)
+		newArtinfo, err := models.GetIndustrialNewArticleDetail(v.IndustrialManagementId)
+		if err != nil {
+			br.Msg = "获取信息失败"
+			br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
+			return
+		}
+		list[k].UpdateTime = utils.TimeRemoveHms(newArtinfo.PublishDate)
+	}
+	artList, err := models.GetCygxIndustryAndArticleList(keyWord)
+	if err != nil {
+		br.Msg = "获取失败"
+		br.ErrMsg = "获取失败,Err:" + err.Error()
+		return
+	}
+	if len(artList) > 0 {
+		var articleIds string
+		for _, v := range artList {
+			articleIds += strconv.Itoa(v.ArticleId) + ","
+		}
+		articleIds = strings.TrimRight(articleIds, ",")
+		if articleIds != "" {
+			condition = `  AND a.article_id IN (` + articleIds + `)`
+			DepartmentList, err := models.GetCygxArticleDepartmentListPc(0, 20, condition, uid)
+			if err != nil {
+				br.Msg = "获取信息失败"
+				br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
+				return
+			}
+			for k, v := range DepartmentList {
+				artList, err := models.GetArticleByDepartmentIdPc(v.DepartmentId, articleIds)
+				if err != nil {
+					br.Msg = "获取信息失败"
+					br.ErrMsg = "获取文章信息失败,Err:" + err.Error()
+					return
+				}
+				for k2, v2 := range artList {
+					if artList[k2].IsReport == "1" {
+						artList[k2].Title = "【研选观点】" + v2.Title
+					} else {
+						artList[k2].Title = "【研选纪要】" + v2.Title
+					}
+				}
+				DepartmentList[k].List = artList
+				if v.FollowNum > 0 {
+					DepartmentList[k].IsMyFollow = true
+				}
+			}
+			resp.DepartmentList = DepartmentList
+		}
+	}
+	if keyWord != "" {
+		keyWordItem := new(models.CygxUserSearchKeyWord)
+		keyWordItem.UserId = user.UserId
+		keyWordItem.KeyWord = keyWord
+		keyWordItem.PageType = "ReortSearch"
+		keyWordItem.CreateTime = time.Now()
+		go models.AddUserSearchKeyWord(keyWordItem)
+	}
+	resp.IndList = list
+	br.Ret = 200
+	br.Success = true
+	br.Msg = "获取成功"
+	br.Data = resp
+}

+ 7 - 0
models/industrial_management.go

@@ -262,6 +262,13 @@ func GetcygxIndustrialSubject(industrialManagementId int) (items []*IndustrialSu
 	return
 }
 
+func GetcygxIndustrialSubjectByName(name string) (industrial_management_id string, err error) {
+	o := orm.NewOrm()
+	sql := `	SELECT industrial_subject_id FROM cygx_industrial_subject  WHERE subject_name = ?`
+	err = o.Raw(sql, name).QueryRow(&industrial_management_id)
+	return
+}
+
 func UpdateIndustrialManagementSubjectNames(nameStr string, industrialManagementId int) (err error) {
 	o := orm.NewOrm()
 	sql := `UPDATE cygx_industrial_management SET subject_names = ? WHERE industrial_management_id = ?`

+ 5 - 0
models/report.go

@@ -269,6 +269,11 @@ type CygxIndustrySearchList struct {
 	IndList []*IndustrialManagement       `description:"产业列表"`
 }
 
+type CygxIndustrySearchListPc struct {
+	DepartmentList []*CygxArticleDepartmentRepPc
+	IndList        []*IndustrialManagement `description:"产业列表"`
+}
+
 //列表
 func GetCygxIndustryAndArticleList(keyWord string) (items []*CygxIndustryAndArticleList, err error) {
 	o := orm.NewOrm()

+ 9 - 0
routers/commentsRouter_controllers.go

@@ -367,6 +367,15 @@ func init() {
             Filters: nil,
             Params: nil})
 
+    beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:ReportController"] = append(beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:ReportController"],
+        beego.ControllerComments{
+            Method: "IndustryAndArticleListPc",
+            Router: "/industryAndArticle/listPc",
+            AllowHTTPMethods: []string{"get"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
     beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:ReportController"] = append(beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:ReportController"],
         beego.ControllerComments{
             Method: "IndustryListByDepartment",

+ 8 - 2
services/tactics.go

@@ -692,8 +692,14 @@ func BodyAnalysis2(body string) (expertNumStr, expertContentStr, interviewDateSt
 				numEnd := strings.Index(v, ".pdf")
 				fileLink = v[numStar : numEnd+4]
 			}
-			if strings.Index(v, ".pdf") > 0 {
-				body = strings.Replace(body, v, "", -1)
+			//处理a标签中的PDF
+			numStarAcount := strings.Index(v, "<a")
+			numEndAcount := strings.Index(v, "<img")
+			if numStarAcount < numEndAcount && strings.Index(fileLink, ".pdf") > 0 {
+				Acount := v[numStarAcount:numEndAcount]
+				if Acount != "" {
+					body = strings.Replace(body, Acount, "", -1)
+				}
 			}
 		}
 		if !strings.HasPrefix(fileLink, "https") && len(fileLink) > 0 {