Browse Source

no message

xingzai 7 months ago
parent
commit
f464a3f4f3
3 changed files with 182 additions and 33 deletions
  1. 131 1
      controllers/cygx/report_article.go
  2. 33 32
      models/cygx/report_article.go
  3. 18 0
      models/cygx/summary_manage.go

+ 131 - 1
controllers/cygx/report_article.go

@@ -1978,7 +1978,7 @@ func (this *IndustrialSubjectController) ReportMappingAdd() {
 }
 
 //func init() {
-//	initAct()
+//	initarta()
 //}
 
 func initart() {
@@ -2349,3 +2349,133 @@ func initAct() {
 	}
 
 }
+
+func initarta() {
+	//行业
+	var condition string
+	var pars []interface{}
+	condition += `	AND share_seller_id In (702,703,704,707) `
+	listProduct, err := company.GetCompanyProductList(condition, pars)
+
+	if err != nil {
+		fmt.Println(err)
+		return
+	}
+	var companyIds []int
+	mapSeller := make(map[int]string)
+	for _, v := range listProduct {
+		companyIds = append(companyIds, v.CompanyId)
+		mapSeller[v.CompanyId] = v.ShareSeller
+	}
+	//报告匹配类型
+	pars = make([]interface{}, 0)
+	condition = ` AND re.chart_permission_id IN  (23,53)  `
+	listart, err := cygx.GetReportArticleList(condition, pars, 0, 4000, 1)
+	if err != nil {
+		fmt.Println(err)
+		return
+	}
+
+	mapArticleTitle := make(map[int]string)
+	mapchart_permission_name := make(map[int]string)
+	var articleIds []int
+	for _, v := range listart {
+		mapArticleTitle[v.ArticleId] = v.Title
+		mapchart_permission_name[v.ArticleId] = v.ChartPermissionName
+		articleIds = append(articleIds, v.ArticleId)
+	}
+
+	//创建excel
+	dir, err := os.Executable()
+	exPath := filepath.Dir(dir)
+	downLoadnFilePath := exPath + "/" + time.Now().Format(utils.FormatDateTimeUnSpace) + ".xlsx"
+	xlsxFile := xlsx.NewFile()
+	if err != nil {
+		fmt.Println(err)
+		return
+	}
+	style := xlsx.NewStyle()
+	alignment := xlsx.Alignment{
+		Horizontal: "center",
+		Vertical:   "center",
+		WrapText:   true,
+	}
+	style.Alignment = alignment
+	style.ApplyAlignment = true
+
+	redStyle := xlsx.NewStyle()
+	redStyle.Alignment = alignment
+	redStyle.ApplyAlignment = true
+	redStyle.Font.Color = "ff0000"
+	//定义底色需要标黄的 单元格颜色
+	redFill := xlsx.Fill{"solid", "ffff00", "ffff00"}
+	redStyle.Fill = redFill
+	//redStyle.Border = *border
+
+	var sheetName string
+	sheetName = "PV"
+	sheet, err := xlsxFile.AddSheet(sheetName)
+	if err != nil {
+		fmt.Println(err)
+		return
+	}
+	//标头
+	rowTitle := sheet.AddRow()
+	cellA := rowTitle.AddCell()
+	cellA.Value = "姓名"
+	cellB := rowTitle.AddCell()
+	cellB.Value = "手机号"
+	cellC := rowTitle.AddCell()
+	cellC.Value = "公司名称"
+	cellD := rowTitle.AddCell()
+	cellD.Value = "服务销售"
+
+	cellDCreatedTime := rowTitle.AddCell()
+	cellDCreatedTime.Value = "最近阅读时间"
+
+	cellE := rowTitle.AddCell()
+	cellE.Value = "行业"
+
+	cellF := rowTitle.AddCell()
+	cellF.Value = "报告标题"
+
+	//articleId := v.ArticleId
+	//condition = ` AND h.company_id != ` + strconv.Itoa(utils.HZ_COMPANY_ID) // 过滤弘则
+	list, err := cygx.GetArticleHistoryListInit(articleIds, companyIds)
+	if err != nil {
+		fmt.Println(err)
+		return
+	}
+
+	mapMobile := make(map[string]bool)
+	for _, item := range list {
+		if mapMobile[item.Mobile] {
+			continue
+		}
+		row := sheet.AddRow()
+		cellAData := row.AddCell()
+		cellAData.Value = item.RealName
+		cellBData := row.AddCell()
+		cellBData.Value = item.Mobile
+		cellCData := row.AddCell()
+		cellCData.Value = item.CompanyName
+		cellDData := row.AddCell()
+		cellDData.Value = mapSeller[item.CompanyId]
+		cellEData := row.AddCell()
+		cellEData.Value = item.CreateTime
+
+		cellEcData := row.AddCell()
+		cellEcData.Value = mapchart_permission_name[item.ArticleId]
+
+		cellFData := row.AddCell()
+		cellFData.Value = mapArticleTitle[item.ArticleId]
+		mapMobile[item.Mobile] = true
+	}
+
+	err = xlsxFile.Save(downLoadnFilePath)
+	if err != nil {
+		fmt.Println(err)
+		return
+	}
+
+}

+ 33 - 32
models/cygx/report_article.go

@@ -32,38 +32,39 @@ type CygxReportArticleID struct {
 }
 
 type CygxReportArticle struct {
-	ReportId          int    `orm:"column(id);pk"description:"报告id"`
-	ArticleId         int    `description:"文章id"`
-	Title             string `description:"标题"`
-	PublishDate       string `description:"发布时间"`
-	CreateDate        string `description:"创建时间"`
-	LastUpdatedTime   string `description:"更新时间"`
-	PermissionName    string `orm:"column(chart_permission_name);" description:"行业"`
-	ChartPermissionId int    `description:"行业id"`
-	SubCategoryName   string `description:"主题"`
-	MatchTypeName     string `description:"匹配类型"`
-	IndustryName      string `description:"产业名称"`
-	IndustryIdStr     string `description:"产业ID"`
-	SubjectNameStr    string `description:"关联标的"`
-	SubjectIdStr      string `description:"关联Id"`
-	IsClass           int    `description:"是否归类  1是、0否"`
-	IsFilter          int    `description:"是否过滤 1是、0否"`
-	ArticleIdMd5      string `description:"文章加密ID"`
-	CategoryId        int    `description:"文章分类id"`
-	ShowButton        bool   `description:"是否展示过滤归类按钮"`
-	Pv                int    `description:"PV"`
-	Uv                int    `description:"UV"`
-	ClPv              int    `description:"策略平台PV"`
-	ClUv              int    `description:"策略平台UV"`
-	PublishStatus     int    `description:"发布状态,0未发布 ,1已发布"`
-	CommentNum        int    `description:"留言数量"`
-	NickName          string `description:"作者昵称"`
-	CollectionNum     int    `description:"收藏"`
-	Stock             string `description:"个股标签(上海策略品台同步)"`
-	FieldName         string `description:"产业标签(上海策略品台同步)"`
-	Label             string `description:"标签"`
-	ListIndustrial    []*IndustrialActivityGroupManagementRep
-	ListSubject       []*SubjectActivityGroupManagementRep
+	ReportId            int    `orm:"column(id);pk"description:"报告id"`
+	ArticleId           int    `description:"文章id"`
+	Title               string `description:"标题"`
+	PublishDate         string `description:"发布时间"`
+	CreateDate          string `description:"创建时间"`
+	LastUpdatedTime     string `description:"更新时间"`
+	PermissionName      string `orm:"column(chart_permission_name);" description:"行业"`
+	ChartPermissionId   int    `description:"行业id"`
+	SubCategoryName     string `description:"主题"`
+	MatchTypeName       string `description:"匹配类型"`
+	ChartPermissionName string `description:"匹配类型"`
+	IndustryName        string `description:"产业名称"`
+	IndustryIdStr       string `description:"产业ID"`
+	SubjectNameStr      string `description:"关联标的"`
+	SubjectIdStr        string `description:"关联Id"`
+	IsClass             int    `description:"是否归类  1是、0否"`
+	IsFilter            int    `description:"是否过滤 1是、0否"`
+	ArticleIdMd5        string `description:"文章加密ID"`
+	CategoryId          int    `description:"文章分类id"`
+	ShowButton          bool   `description:"是否展示过滤归类按钮"`
+	Pv                  int    `description:"PV"`
+	Uv                  int    `description:"UV"`
+	ClPv                int    `description:"策略平台PV"`
+	ClUv                int    `description:"策略平台UV"`
+	PublishStatus       int    `description:"发布状态,0未发布 ,1已发布"`
+	CommentNum          int    `description:"留言数量"`
+	NickName            string `description:"作者昵称"`
+	CollectionNum       int    `description:"收藏"`
+	Stock               string `description:"个股标签(上海策略品台同步)"`
+	FieldName           string `description:"产业标签(上海策略品台同步)"`
+	Label               string `description:"标签"`
+	ListIndustrial      []*IndustrialActivityGroupManagementRep
+	ListSubject         []*SubjectActivityGroupManagementRep
 }
 
 type GetReportArticleListRep struct {

+ 18 - 0
models/cygx/summary_manage.go

@@ -522,6 +522,7 @@ type ArticleHistoryRep struct {
 	RealName    string `description:"姓名"`
 	Mobile      string `description:"手机号"`
 	CompanyName string `description:"公司名称"`
+	CompanyId   int    `description:"文章ID"`
 	SellerName  string `description:"所属销售"`
 	StopTime    string `description:"阅读停留时间"`
 	CreateTime  string `description:"创建时间"`
@@ -546,6 +547,23 @@ func GetArticleHistoryList(articleId int, condition string) (items []*ArticleHis
 	return
 }
 
+// 列表
+func GetArticleHistoryListInit(ArticleIds, companyIds []int) (items []*ArticleHistoryRep, err error) {
+	o := orm.NewOrmUsingDB("hz_cygx")
+	sql := `SELECT
+			h.*
+			FROM
+				cygx_article_history_record_all AS h
+			WHERE
+1=1
+				AND h.platfor = 1  AND create_time >= '2023.09.01' AND create_time < '2024.09.02'  AND h.is_del = 0   AND article_id IN (` + utils.GetOrmInReplace(len(ArticleIds)) + `)  AND company_id IN (` + utils.GetOrmInReplace(len(companyIds)) + `)  `
+
+	sql += ` ORDER BY id DESC  `
+
+	_, err = o.Raw(sql, ArticleIds, companyIds).QueryRows(&items)
+	return
+}
+
 // 用户阅读记录,不过滤弘则内部的
 func GetArticleHistoryListOld(articleId int, condition string) (items []*ArticleHistoryRep, err error) {
 	o := orm.NewOrmUsingDB("hz_cygx")