فهرست منبع

Merge branch 'cygx/cygx_need_959' of http://8.136.199.33:3000/hongze/hz_crm_api

zhangchuanxing 5 ماه پیش
والد
کامیت
476788912d

+ 61 - 0
controllers/cygx/industrial_subject.go

@@ -628,3 +628,64 @@ func (this *IndustrialSubjectController) CountDetail() {
 	br.Msg = "获取成功"
 	br.Data = resp
 }
+
+// @Title 通过行业获取关联标的列表
+// @Description 通过行业获取关联标的列表接口
+// @Param   KeyWord   query   string  false       "搜索关键词"
+// @Param   ChartPermissionId   query   int  true       "分类ID"
+// @Success Ret=200  {object} cygx.CygxIndustrialSubjectList
+// @router /industrialAndSubject/search [get]
+func (this *IndustrialSubjectController) IndustrialAndSubjectSearch() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		this.Data["json"] = br
+		this.ServeJSON()
+	}()
+	sysUser := this.SysUser
+	if sysUser == nil {
+		br.Msg = "请登录"
+		br.ErrMsg = "请登录,SysUser Is Empty"
+		br.Ret = 408
+		return
+	}
+	var condition string
+	keyWord := this.GetString("KeyWord")
+	chartPermissionId, _ := this.GetInt("ChartPermissionId")
+	if keyWord != "" {
+		condition = ` AND s.subject_name LIKE '%` + keyWord + `%'  `
+	}
+	if chartPermissionId > 0 {
+		condition += ` AND m.chart_permission_id = ` + strconv.Itoa(chartPermissionId)
+	}
+	listSubject, err := cygx.GetIndustrialSubjectListNameByChartId(condition)
+	if err != nil {
+		br.Msg = "获取失败"
+		br.ErrMsg = "获取失败,Err:" + err.Error()
+		return
+	}
+	condition = ` AND industry_name LIKE '%` + keyWord + `%'  AND  chart_permission_id = ` + strconv.Itoa(chartPermissionId)
+	listIndustrial, err := cygx.GetIndustrialManagement(condition)
+	if err != nil {
+		br.Msg = "获取失败"
+		br.ErrMsg = "获取失败,Err:" + err.Error()
+		return
+	}
+	listResp := make([]*cygx.CygxIndustrialSubjectListRep, 0)
+	for _, v := range listIndustrial {
+		item := new(cygx.CygxIndustrialSubjectListRep)
+		item.IndustryName = v.IndustryName
+		item.IndustrialManagementId = v.IndustrialManagementId
+		item.ShowName = v.IndustryName
+		listResp = append(listResp, item)
+	}
+	for _, v := range listSubject {
+		v.ShowName = v.SubjectName
+		listResp = append(listResp, v)
+	}
+	resp := new(cygx.CygxIndustrialSubjectList)
+	resp.List = listResp
+	br.Ret = 200
+	br.Success = true
+	br.Msg = "获取成功"
+	br.Data = resp
+}

+ 66 - 42
controllers/cygx/report_selection.go

@@ -123,6 +123,10 @@ func (this *ReportSelectionController) PreserveAndPublish() {
 		item.IndustrialSubjectId = v.IndustrialSubjectId
 		item.SubjectName = v.IndustrialSubjectName
 		item.IndustrialManagementId = v.IndustrialManagementId
+		item.IndustrialManagementNames = v.IndustrialManagementName
+		if v.IndustrialManagementNames != "" {
+			item.IndustrialManagementNames = v.IndustrialManagementNames
+		}
 		item.OverviewArticleId = v.OverviewArticleId
 		item.IsNew = v.IsNew
 		item.IsShowOverviewArticle = v.IsShowOverviewArticle
@@ -394,23 +398,35 @@ func (this *ReportSelectionController) Detail() {
 			return
 		}
 		for kIndustrial, vIndustrial := range listSon {
+			var industrialNames string
 			//如果报告精选关联的产业被删除了 则做以下处理
-			//if vIndustrial.IndustrialManagementName == "" {
-			industrialNames, err := cygx.GetindustrialManagementNamesBySubjectName(vIndustrial.IndustrialSubjectName, vIndustrial.ChartPermissionId)
-			if err != nil {
-				br.Msg = "获取失败!"
-				br.ErrMsg = "获取删除删除之后的产业失败,Err:" + err.Error() + vIndustrial.IndustrialSubjectId
-				return
+			if vIndustrial.IndustrialSubjectName == "" {
+				industrialNames = vIndustrial.IndustrialManagementNames
+			} else {
+				industrialNames, err = cygx.GetindustrialManagementNamesBySubjectName(vIndustrial.IndustrialSubjectName, vIndustrial.ChartPermissionId)
+				if err != nil {
+					br.Msg = "获取失败!"
+					br.ErrMsg = "获取删除删除之后的产业失败,Err:" + err.Error() + vIndustrial.IndustrialSubjectId
+					return
+				}
 			}
+
 			if vIndustrial.Label != "" {
 				vIndustrial.CompanyLabel = strings.Split(vIndustrial.Label, "{|}")
 			}
 			listSon[kIndustrial].IndustrialManagementName = industrialNames
+			listSon[kIndustrial].IndustrialManagementNames = industrialNames
 			listSon[kIndustrial].OverviewArticleId = articleStockMap[vIndustrial.IndustrialSubjectName]
 			listSon[kIndustrial].OverviewArticleTitle = mapArticle[listSon[kIndustrial].OverviewArticleId]
 			if periods != "" {
 				listSon[kIndustrial].IsNew = 0
 			}
+
+			if vIndustrial.SubjectName == "" {
+				listSon[kIndustrial].ShowName = vIndustrial.IndustrialManagementNames
+			} else {
+				listSon[kIndustrial].ShowName = vIndustrial.SubjectName
+			}
 		}
 		list[k].List = listSon
 		list[k].BodyChartSummary = mapChartLog[v.ChartPermissionName]
@@ -849,41 +865,40 @@ func (this *ReportSelectionController) GetArticle() {
 		br.ErrMsg = "请登录,SysUser Is Empty"
 		return
 	}
-	industrialSubjectId, _ := this.GetInt("IndustrialSubjectId")
-	if industrialSubjectId < 1 {
-		br.Msg = "请输入标的ID"
-		return
-	}
-	detailSubjecj, err := cygx.GetIndustrialSubjectDetailById(industrialSubjectId)
-	if err != nil && err.Error() != utils.ErrNoRow() {
-		br.Msg = "获取信息失败"
-		br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
-		return
-	}
 	resp := new(cygx.OverviewArticle)
-	if detailSubjecj != nil {
-		var pars []interface{}
-		conditionArticle := `  AND type_name = '综述报告'  AND  stock LIKE ? `
-		subjectName := "%" + detailSubjecj.SubjectName + "%"
-		pars = append(pars, subjectName)
-		articleList, err := cygx.GetCygxArticleList(conditionArticle, pars, 0, 10)
-		if err != nil {
-			br.Msg = "获取失败"
-			br.ErrMsg = "GetCygxArticleList,Err:" + err.Error()
+	industrialSubjectId, _ := this.GetInt("IndustrialSubjectId")
+	if industrialSubjectId > 0 {
+		detailSubjecj, err := cygx.GetIndustrialSubjectDetailById(industrialSubjectId)
+		if err != nil && err.Error() != utils.ErrNoRow() {
+			br.Msg = "获取信息失败"
+			br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
 			return
 		}
-		//一对一精准匹配
-		for _, v := range articleList {
-			sliceSubjects := strings.Split(v.Stock, "/")
-			if len(sliceSubjects) > 0 {
-				for _, vSubject := range sliceSubjects {
-					sliceKuohao := strings.Split(vSubject, "(")           //过滤括号
-					sliceXiahuaxian := strings.Split(sliceKuohao[0], "-") //过滤下划线
-					subject := sliceXiahuaxian[0]
-					if subject == detailSubjecj.SubjectName {
-						resp.ArticleId = v.ArticleId
-						resp.Title = v.Title
-						continue
+
+		if detailSubjecj != nil {
+			var pars []interface{}
+			conditionArticle := `  AND type_name = '综述报告'  AND  stock LIKE ? `
+			subjectName := "%" + detailSubjecj.SubjectName + "%"
+			pars = append(pars, subjectName)
+			articleList, err := cygx.GetCygxArticleList(conditionArticle, pars, 0, 10)
+			if err != nil {
+				br.Msg = "获取失败"
+				br.ErrMsg = "GetCygxArticleList,Err:" + err.Error()
+				return
+			}
+			//一对一精准匹配
+			for _, v := range articleList {
+				sliceSubjects := strings.Split(v.Stock, "/")
+				if len(sliceSubjects) > 0 {
+					for _, vSubject := range sliceSubjects {
+						sliceKuohao := strings.Split(vSubject, "(")           //过滤括号
+						sliceXiahuaxian := strings.Split(sliceKuohao[0], "-") //过滤下划线
+						subject := sliceXiahuaxian[0]
+						if subject == detailSubjecj.SubjectName {
+							resp.ArticleId = v.ArticleId
+							resp.Title = v.Title
+							continue
+						}
 					}
 				}
 			}
@@ -1009,9 +1024,13 @@ func (this *ReportSelectionController) History() {
 		br.ErrMsg = "GetCygxReportSelectionSubjectHistoryList,Err:" + err.Error()
 		return
 	}
-	mapSubjectHistory := make(map[string]int)
+	mapSubjectHistory := make(map[string]int)    // 标的点击数量
+	mapIndustrialHistory := make(map[string]int) // 产业点击数量
 	for _, v := range listSelectionSubjectHistory {
 		mapSubjectHistory[v.IndustrialSubjectId]++
+		if v.IndustrialSubjectId == "0" && v.IndustrialManagementId > 0 {
+			mapIndustrialHistory[strconv.Itoa(v.IndustrialManagementId)]++
+		}
 	}
 
 	//排序方式修改
@@ -1021,10 +1040,15 @@ func (this *ReportSelectionController) History() {
 		for _, v2 := range listSelectionLog {
 			if v.ChartPermissionName == v2.PermissionName {
 				item := new(cygx.HistoryReportSelectionLogResp)
-				item.SubjectName = v2.SubjectName
-				item.IndustrialSubjectId = v2.IndustrialSubjectId
+				if (v2.IndustrialSubjectId == "" || v2.IndustrialSubjectId == "0") && v2.IndustrialManagementId != "" {
+					item.SubjectName = v2.IndustrialManagementNames
+					item.Count = mapIndustrialHistory[v2.IndustrialManagementId]
+				} else {
+					item.SubjectName = v2.SubjectName
+					item.IndustrialSubjectId = v2.IndustrialSubjectId
+					item.Count = mapSubjectHistory[v2.IndustrialSubjectId]
+				}
 				item.IsNew = v2.IsNew
-				item.Count = mapSubjectHistory[v2.IndustrialSubjectId]
 				resp.Count += item.Count
 				v.List = append(v.List, item)
 			}

+ 1 - 0
models/cygx/industrial_subject.go

@@ -230,6 +230,7 @@ type CygxIndustrialSubjectListRep struct {
 	IndustrialManagementId int    `description:"产业id"`
 	SubjectName            string `description:"标的名称"`
 	IndustryName           string `description:"分析师名称"`
+	ShowName               string `description:"产业与标的展示名称"`
 }
 
 type CygxIndustrialSubjectList struct {

+ 55 - 51
models/cygx/report_selection_log.go

@@ -6,18 +6,19 @@ import (
 )
 
 type CygxReportSelectionLog struct {
-	ArticleSunId           int       `orm:"column(article_sun_id);pk"description:"子级报告id"`
-	ArticleId              int       `description:"父级报告Id"`
-	ChartPermissionId      int       `description:"行业ID"`
-	CreateTime             time.Time `description:"创建时间"`
-	Body                   string    `description:"内容"`
-	IndustrialSubjectId    string    `description:"标的ID"`
-	SubjectName            string    `description:"标的名称"`
-	IndustrialManagementId string    `description:"产业资源包Id  多个用 , 隔开"`
-	CompanyLabel           string    `description:"公司标签多个用{|}隔开"`
-	OverviewArticleId      int       `description:"关联的综述报告ID"`
-	IsNew                  int       `description:"是否为New标签"`
-	IsShowOverviewArticle  int       `description:"是否展示综述报告 1展示,0隐藏"`
+	ArticleSunId              int       `orm:"column(article_sun_id);pk"description:"子级报告id"`
+	ArticleId                 int       `description:"父级报告Id"`
+	ChartPermissionId         int       `description:"行业ID"`
+	CreateTime                time.Time `description:"创建时间"`
+	Body                      string    `description:"内容"`
+	IndustrialSubjectId       string    `description:"标的ID"`
+	SubjectName               string    `description:"标的名称"`
+	IndustrialManagementId    string    `description:"产业资源包Id  多个用 , 隔开"`
+	IndustrialManagementNames string    `description:"产业资源包名称  多个用 , 隔开"`
+	CompanyLabel              string    `description:"公司标签多个用{|}隔开"`
+	OverviewArticleId         int       `description:"关联的综述报告ID"`
+	IsNew                     int       `description:"是否为New标签"`
+	IsShowOverviewArticle     int       `description:"是否展示综述报告 1展示,0隐藏"`
 }
 
 type CygxReportSelectionLogRep struct {
@@ -31,35 +32,38 @@ type CygxReportSelectionLogRep struct {
 }
 
 type AddCygxReportSelectionLog struct {
-	ChartPermissionId        int      `description:"行业ID"`
-	IndustrialSubjectId      string   `description:"标的ID"`
-	SubjectName              string   `description:"标的名称"`
-	IndustrialSubjectName    string   `description:"标的ID"`
-	Body                     string   `description:"内容"`
-	IndustrialManagementId   string   `description:"产业资源包Id  多个用 , 隔开"`
-	IndustrialManagementName string   `description:"产业资源包Id  多个用 , 隔开"`
-	CompanyLabel             []string `description:"公司标签"`
-	Label                    string   `description:"公司标签"`
-	OverviewArticleId        int      `description:"综述报告Id"`
-	IsNew                    int      `description:"是否为New标签"`
-	IsShowOverviewArticle    int      `description:"是否展示综述报告 1展示,0隐藏"`
+	ChartPermissionId         int      `description:"行业ID"`
+	IndustrialSubjectId       string   `description:"标的ID"`
+	SubjectName               string   `description:"标的名称"`
+	IndustrialSubjectName     string   `description:"标的ID"`
+	Body                      string   `description:"内容"`
+	IndustrialManagementId    string   `description:"产业资源包Id  多个用 , 隔开"`
+	IndustrialManagementName  string   `description:"产业资源包Id  多个用 , 隔开"`
+	IndustrialManagementNames string   `description:"产业资源包Id  多个用 , 隔开"`
+	CompanyLabel              []string `description:"公司标签"`
+	Label                     string   `description:"公司标签"`
+	OverviewArticleId         int      `description:"综述报告Id"`
+	IsNew                     int      `description:"是否为New标签"`
+	IsShowOverviewArticle     int      `description:"是否展示综述报告 1展示,0隐藏"`
 }
 
 type CygxReportSelectionLogResp struct {
-	ChartPermissionId        int      `description:"行业ID"`
-	IndustrialSubjectId      string   `description:"标的ID"`
-	SubjectName              string   `description:"标的名称"`
-	IndustrialSubjectName    string   `description:"标的ID"`
-	Body                     string   `description:"内容"`
-	IndustrialManagementId   string   `description:"产业资源包Id  多个用 , 隔开"`
-	IndustrialManagementName string   `description:"产业资源包Id  多个用 , 隔开"`
-	CompanyLabel             []string `description:"公司标签"`
-	Label                    string   `description:"公司标签"`
-	OverviewArticleId        int      `description:"综述报告Id"`
-	OverviewArticleTitle     string   `description:"综述报告标题"`
-	IsNew                    int      `description:"是否为New标签"`
-	IsShowOverviewArticle    int      `description:"是否展示综述报告 1展示,0隐藏"`
-	ChartPermissionSort      int      `description:"品种排序"`
+	ChartPermissionId         int      `description:"行业ID"`
+	IndustrialSubjectId       string   `description:"标的ID"`
+	SubjectName               string   `description:"标的名称"`
+	ShowName                  string   `description:"产业与标的展示名称"`
+	IndustrialSubjectName     string   `description:"标的ID"`
+	Body                      string   `description:"内容"`
+	IndustrialManagementId    string   `description:"产业资源包Id  多个用 , 隔开"`
+	IndustrialManagementName  string   `description:"产业资源包Id  多个用 , 隔开"`
+	IndustrialManagementNames string   `description:"产业资源包Id  多个用 , 隔开"`
+	CompanyLabel              []string `description:"公司标签"`
+	Label                     string   `description:"公司标签"`
+	OverviewArticleId         int      `description:"综述报告Id"`
+	OverviewArticleTitle      string   `description:"综述报告标题"`
+	IsNew                     int      `description:"是否为New标签"`
+	IsShowOverviewArticle     int      `description:"是否展示综述报告 1展示,0隐藏"`
+	ChartPermissionSort       int      `description:"品种排序"`
 }
 
 type CygxReportSelectionChart struct {
@@ -92,18 +96,19 @@ func GetCygxReportSelectionSjdpList(articleId int, typeStr string) (items []*Cyg
 }
 
 type CygxReportSelectionLoglist struct {
-	ArticleSunId           int       `description:"子级报告id"`
-	ArticleId              int       `description:"父级报告Id"`
-	ChartPermissionId      int       `description:"行业ID"`
-	PermissionName         string    `description:"行业ID"`
-	CreateTime             time.Time `description:"创建时间"`
-	Body                   string    `description:"内容"`
-	IndustrialSubjectId    string    `description:"标的ID"`
-	IndustrialManagementId string    `description:"产业资源包Id  多个用 , 隔开"`
-	SubjectName            string    `description:"标的名称"`
-	IcoLink                string    `orm:"column(image_url)"description:"图标链接"`
-	OverviewArticleId      int       `description:"关联的综述报告ID"`
-	IsNew                  int       `description:"是否为New标签"`
+	ArticleSunId              int       `description:"子级报告id"`
+	ArticleId                 int       `description:"父级报告Id"`
+	ChartPermissionId         int       `description:"行业ID"`
+	PermissionName            string    `description:"行业ID"`
+	CreateTime                time.Time `description:"创建时间"`
+	Body                      string    `description:"内容"`
+	IndustrialSubjectId       string    `description:"标的ID"`
+	IndustrialManagementId    string    `description:"产业资源包Id  多个用 , 隔开"`
+	IndustrialManagementNames string    `description:"产业资源包名称  多个用 , 隔开"`
+	SubjectName               string    `description:"标的名称"`
+	IcoLink                   string    `orm:"column(image_url)"description:"图标链接"`
+	OverviewArticleId         int       `description:"关联的综述报告ID"`
+	IsNew                     int       `description:"是否为New标签"`
 }
 
 // 列表
@@ -112,7 +117,6 @@ func GetReportSelectionlogListAll(articleId int) (items []*CygxReportSelectionLo
 	sql := `SELECT  l.* 
 			FROM
 			cygx_report_selection_log AS l
-			INNER JOIN cygx_industrial_subject AS s ON s.industrial_subject_id = l.industrial_subject_id 
 			WHERE l.article_id = ? `
 	_, err = o.Raw(sql, articleId).QueryRows(&items)
 	return

+ 11 - 10
models/cygx/report_selection_subject_history.go

@@ -6,16 +6,17 @@ import (
 )
 
 type CygxReportSelectionSubjectHistory struct {
-	Id                  int       `orm:"column(id);pk"`
-	ArticleId           int       `description:"文章ID"`
-	UserId              int       `description:"用户ID"`
-	CreateTime          time.Time `description:"创建时间"`
-	ModifyTime          time.Time `description:"修改时间"`
-	Mobile              string    `description:"手机号"`
-	Email               string    `description:"邮箱"`
-	CompanyId           int       `description:"公司id"`
-	CompanyName         string    `description:"公司名称"`
-	IndustrialSubjectId string    `description:"标的ID"`
+	Id                     int       `orm:"column(id);pk"`
+	ArticleId              int       `description:"文章ID"`
+	UserId                 int       `description:"用户ID"`
+	CreateTime             time.Time `description:"创建时间"`
+	ModifyTime             time.Time `description:"修改时间"`
+	Mobile                 string    `description:"手机号"`
+	Email                  string    `description:"邮箱"`
+	CompanyId              int       `description:"公司id"`
+	CompanyName            string    `description:"公司名称"`
+	IndustrialSubjectId    string    `description:"标的ID"`
+	IndustrialManagementId int       `description:"产业ID"`
 }
 
 // 列表

+ 9 - 0
routers/commentsRouter.go

@@ -1708,6 +1708,15 @@ func init() {
             Filters: nil,
             Params: nil})
 
+    beego.GlobalControllerRouter["hongze/hz_crm_api/controllers/cygx:IndustrialSubjectController"] = append(beego.GlobalControllerRouter["hongze/hz_crm_api/controllers/cygx:IndustrialSubjectController"],
+        beego.ControllerComments{
+            Method: "IndustrialAndSubjectSearch",
+            Router: `/industrialAndSubject/search`,
+            AllowHTTPMethods: []string{"get"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
     beego.GlobalControllerRouter["hongze/hz_crm_api/controllers/cygx:IndustrialSubjectController"] = append(beego.GlobalControllerRouter["hongze/hz_crm_api/controllers/cygx:IndustrialSubjectController"],
         beego.ControllerComments{
             Method: "IndustrialSubjectAdd",