Browse Source

Merge branch 'cygx_10.5.1' of http://8.136.199.33:3000/hongze/hongze_cygx into debug

xingzai 1 year ago
parent
commit
8fc7b07de2

+ 1 - 0
controllers/article.go

@@ -533,6 +533,7 @@ func (this *ArticleController) ArticleCollect() {
 		resp.Status = 1
 		// 文章收藏消息发送
 		go services.ArticleUserRemind(user, detail, 2)
+		go services.ArticleHistoryUserLabelLogAdd(articleId, user.UserId)
 	} else {
 		err = models.RemoveArticleCollect(uid, articleId)
 		if err != nil {

+ 12 - 0
models/activity.go

@@ -1212,3 +1212,15 @@ func GetActivityLabelListAllNoLimit(condition, sortTime string, pars []interface
 	_, err = o.Raw(sql, pars).QueryRows(&items)
 	return
 }
+
+// 列表
+func GetCygxActivityList(condition string, pars []interface{}, startSize, pageSize int) (items []*CygxActivity, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT * FROM cygx_activity as art WHERE 1= 1 `
+	if condition != "" {
+		sql += condition
+	}
+	sql += ` LIMIT ?,?  `
+	_, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items)
+	return
+}

+ 10 - 0
models/activity_special_trip.go

@@ -51,6 +51,16 @@ func GetCygxActivitySpecialTripList(condition string, pars []interface{}) (item
 	return
 }
 
+func GetCygxActivitySpecialmeetingDetailList(condition string, pars []interface{}) (item []*CygxActivitySpecialTripResp, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT *
+			FROM
+			cygx_activity_special_meeting_detail  
+			WHERE 1 = 1 ` + condition
+	_, err = o.Raw(sql, pars).QueryRows(&item)
+	return
+}
+
 // 获取某一用户的报名的数量
 func GetUserActivitySpecialTripCount(uid, activityId int) (count int, err error) {
 	sqlCount := `SELECT COUNT(1) AS count FROM cygx_activity_special_trip  WHERE  user_id=?  AND   activity_id =? `

+ 0 - 13
models/article_category_mapping.go

@@ -30,19 +30,6 @@ func AddCygxArticleCategoryMapping(item *CygxArticleCategoryMapping) (lastId int
 	return
 }
 
-type CygxReportMappingCygx struct {
-	Id                  int    `orm:"column(id);pk" description:"id"`
-	ChartPermissionId   int    `description:"行业ID"`
-	ChartPermissionName string `description:"行业名称"`
-	MatchTypeName       string `description:"分类名称"`
-	ReportType          int    `description:"报告类型,2产业报告,1行业报告"`
-	Sort                int    `description:"排序"`
-	IsCustom            int    `description:"是否属于自定义的匹配类型 ,1是,0否"`
-	IsSummary           int    `description:"是否是纪要库,1是,0否"`
-	IsReport            int    `description:"是否是报告,1是,0否"`
-	PermissionType      int    `description:"1主观,2客观"`
-}
-
 type CygxReportMappingGroup struct {
 	Id              int       `orm:"column(id);pk" description:"id"`
 	IdCygx          int       `description:"分类ID"`

+ 1 - 1
models/article_history_record_newpv.go

@@ -295,7 +295,7 @@ func GetCygxArticleHistoryAllTop(pars []interface{}, condition string) (items []
 // 列表
 func GetCygxArticleHistoryRecordNewpvList(condition string, pars []interface{}) (items []*CygxArticleHistoryRecordNewpv, err error) {
 	o := orm.NewOrm()
-	sql := `SELECT * FROM cygx_article_history_record_newpv as art WHERE 1= 1 `
+	sql := `SELECT * FROM cygx_article_history_record_newpv as art WHERE 1= 1  `
 	if condition != "" {
 		sql += condition
 	}

+ 1 - 0
models/db.go

@@ -150,6 +150,7 @@ func init() {
 		new(CygxUserLabel),
 		new(CygxUserLabelActivity),
 		new(CygxUserLabelArticle),
+		new(CygxUserLabelActivitySpecial),
 	)
 	// 记录ORM查询日志
 	orm.Debug = true

+ 12 - 0
models/industry_fllow.go

@@ -203,3 +203,15 @@ func GetTopIndustryFollowData(startSize, pageSize int, condition string, pars []
 	_, err = orm.NewOrm().Raw(sql, pars, startSize, pageSize).QueryRows(&list)
 	return
 }
+
+// 列表
+func GetCygxIndustryFllowListByCon(condition string, pars []interface{}, startSize, pageSize int) (items []*CygxIndustryFllow, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT * FROM cygx_industry_fllow as art WHERE 1= 1 `
+	if condition != "" {
+		sql += condition
+	}
+	//sql += ` LIMIT ?,?  `
+	_, err = o.Raw(sql, pars).QueryRows(&items)
+	return
+}

+ 31 - 0
models/report_mapping_cygx.go

@@ -0,0 +1,31 @@
+package models
+
+import (
+	"github.com/beego/beego/v2/client/orm"
+	//"time"
+)
+
+type CygxReportMappingCygx struct {
+	Id                  int    `orm:"column(id);pk" description:"id"`
+	ChartPermissionId   int    `description:"行业ID"`
+	ChartPermissionName string `description:"行业名称"`
+	MatchTypeName       string `description:"分类名称"`
+	ReportType          int    `description:"报告类型,2产业报告,1行业报告"`
+	Sort                int    `description:"排序"`
+	IsCustom            int    `description:"是否属于自定义的匹配类型 ,1是,0否"`
+	IsSummary           int    `description:"是否是纪要库,1是,0否"`
+	IsReport            int    `description:"是否是报告,1是,0否"`
+	PermissionType      int    `description:"1主观,2客观"`
+}
+
+// 列表
+func GetCygxReportMappingCygxByCon(condition string, pars []interface{}, startSize, pageSize int) (items []*CygxReportMappingCygx, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT * FROM cygx_report_mapping_cygx as art WHERE 1= 1 `
+	if condition != "" {
+		sql += condition
+	}
+	//sql += ` LIMIT ?,?  `
+	_, err = o.Raw(sql, pars).QueryRows(&items)
+	return
+}

+ 41 - 1
models/user_label.go

@@ -47,6 +47,16 @@ func AddCygxUserLabel(item *CygxUserLabel) (lastId int64, err error) {
 	return
 }
 
+// 批量添加
+func CygxUserLabelMulti(items []*CygxUserLabel) (err error) {
+	o := orm.NewOrm()
+	if len(items) > 0 {
+		//批量添加新的记录
+		_, err = o.InsertMulti(len(items), items)
+	}
+	return
+}
+
 // 修改是否关注
 func UpdateCygxUserLabelIsFollow(isFollow, sourceId, source, userId int, label string) (err error) {
 	o := orm.NewOrm()
@@ -63,13 +73,43 @@ func UpdateCygxUserLabelWeight(sourceId, source, userId int, label string) (err
 	return
 }
 
+// 把所有用户标签权重设置为0
+func UpdateCygxUserLabelWeightAll() (err error) {
+	o := orm.NewOrm()
+	sql := `UPDATE cygx_user_label SET weight = 0 `
+	_, err = o.Raw(sql).Exec()
+	return
+}
+
 // 列表
 func GetCygxUserLabelList(condition string, pars []interface{}) (items []*CygxUserLabel, err error) {
 	o := orm.NewOrm()
-	sql := `SELECT * FROM cygx_user_label as art WHERE 1= 1   AND modify_time > DATE_SUB(CURDATE(), INTERVAL 3 MONTH)	`
+	sql := `SELECT * FROM cygx_user_label as art WHERE 1= 1   	`
 	if condition != "" {
 		sql += condition
 	}
 	_, err = o.Raw(sql, pars).QueryRows(&items)
 	return
 }
+
+// UpdateCygxUserLabelMulti 批量修改用户标签权重
+func UpdateCygxUserLabelMulti(items []*CygxUserLabel) (err error) {
+	o := orm.NewOrm()
+	p, err := o.Raw(` UPDATE cygx_user_label SET weight = ? WHERE user_id = ? AND label = ? `).Prepare()
+	if err != nil {
+		return
+	}
+	defer func() {
+		_ = p.Close() // 别忘记关闭 statement
+	}()
+	for _, v := range items {
+		_, err = p.Exec(
+			v.Weight,
+			v.UserId,
+			v.Label)
+		if err != nil {
+			return
+		}
+	}
+	return
+}

+ 13 - 13
models/user_label_activity.go

@@ -6,27 +6,27 @@ import (
 )
 
 type CygxUserLabelActivity struct {
-	Id         int       `orm:"column(id);pk"`
-	UserId     int       `description:"用户ID"`
-	CompanyId  int       `description:"公司id"`
-	RealName   string    `description:"用户实际名称"`
-	Mobile     string    `description:"手机号"`
-	Email      string    `description:"邮箱"`
-	Label      string    `description:"标签内容"`
-	ActivityId int       `description:"活动ID"`
-	CreateTime time.Time `description:"创建时间"`
-	ModifyTime time.Time `description:"更新时间"`
+	Id                     int       `orm:"column(id);pk"`
+	UserId                 int       `description:"用户ID"`
+	CompanyId              int       `description:"公司id"`
+	RealName               string    `description:"用户实际名称"`
+	Mobile                 string    `description:"手机号"`
+	Email                  string    `description:"邮箱"`
+	Label                  string    `description:"标签内容"`
+	ActivityId             int       `description:"活动ID"`
+	IndustrialManagementId int       `description:"cygx_industrial_management表的主键ID"`
+	CreateTime             time.Time `description:"创建时间"`
+	ModifyTime             time.Time `description:"更新时间"`
 }
 
 // 列表
-func GetCygxUserLabelActivity(condition string, pars []interface{}, startSize, pageSize int) (items []*CygxUserLabelActivity, err error) {
+func GetCygxUserLabelActivity(condition string, pars []interface{}) (items []*CygxUserLabelActivity, err error) {
 	o := orm.NewOrm()
 	sql := `SELECT * FROM cygx_user_label_activity as art WHERE 1= 1 `
 	if condition != "" {
 		sql += condition
 	}
-	sql += ` LIMIT ?,?  `
-	_, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items)
+	_, err = o.Raw(sql, pars).QueryRows(&items)
 	return
 }
 

+ 43 - 0
models/user_label_activity_special.go

@@ -0,0 +1,43 @@
+package models
+
+import (
+	"github.com/beego/beego/v2/client/orm"
+	"time"
+)
+
+type CygxUserLabelActivitySpecial struct {
+	Id                     int       `orm:"column(id);pk"`
+	UserId                 int       `description:"用户ID"`
+	CompanyId              int       `description:"公司id"`
+	RealName               string    `description:"用户实际名称"`
+	Mobile                 string    `description:"手机号"`
+	Email                  string    `description:"邮箱"`
+	Label                  string    `description:"标签内容"`
+	ActivityId             int       `description:"活动ID"`
+	IndustrialManagementId int       `description:"cygx_industrial_management表的主键ID"`
+	CreateTime             time.Time `description:"创建时间"`
+	ModifyTime             time.Time `description:"更新时间"`
+}
+
+// 列表
+func GetCygxUserLabelActivitySpecial(condition string, pars []interface{}) (items []*CygxUserLabelActivitySpecial, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT * FROM cygx_user_label_activity_special as art WHERE 1= 1 `
+	if condition != "" {
+		sql += condition
+	}
+
+	_, err = o.Raw(sql, pars).QueryRows(&items)
+	return
+}
+
+// 批量添加
+func AddCygxUserLabelActivitySpecialList(items []*CygxUserLabelActivitySpecial) (lastId int64, err error) {
+	lenitems := len(items)
+	if lenitems == 0 {
+		return
+	}
+	o := orm.NewOrm()
+	_, err = o.InsertMulti(1, items)
+	return
+}

+ 22 - 0
models/user_label_article.go

@@ -26,3 +26,25 @@ func AddCygxUserLabelArticle(item *CygxUserLabelArticle) (lastId int64, err erro
 	lastId, err = o.Insert(item)
 	return
 }
+
+// 批量添加
+func AddCygxUserLabelArticleList(items []*CygxUserLabelArticle) (lastId int64, err error) {
+	lenitems := len(items)
+	if lenitems == 0 {
+		return
+	}
+	o := orm.NewOrm()
+	_, err = o.InsertMulti(1, items)
+	return
+}
+
+// 列表
+func GetCygxUserLabelArticleList(condition string, pars []interface{}) (items []*CygxUserLabelArticle, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT * FROM cygx_user_label_article as art WHERE 1= 1   	`
+	if condition != "" {
+		sql += condition
+	}
+	_, err = o.Raw(sql, pars).QueryRows(&items)
+	return
+}

+ 12 - 0
models/xzs_choose_category.go

@@ -27,6 +27,18 @@ func GetCygxXzsChooseCategoryList(mobile string) (items []*CygxXzsChooseCategory
 	return
 }
 
+// 列表
+func GetCygxXzsChooseCategoryListByCon(condition string, pars []interface{}, startSize, pageSize int) (items []*CygxXzsChooseCategory, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT * FROM cygx_xzs_choose_category as art WHERE 1= 1 `
+	if condition != "" {
+		sql += condition
+	}
+	//sql += ` LIMIT ?,?  `
+	_, err = o.Raw(sql, pars).QueryRows(&items)
+	return
+}
+
 // 添加
 func AddCygxCategoryFllow(item *CygxXzsChooseCategory) (lastId int64, err error) {
 	o := orm.NewOrm()

+ 447 - 0
services/init_10.5.1.go

@@ -0,0 +1,447 @@
+package services
+
+import (
+	"fmt"
+	"hongze/hongze_cygx/models"
+	"hongze/hongze_cygx/utils"
+	"time"
+)
+
+//10.5.1版本上线需要更新的数据
+
+func init5111() {
+	var condition string
+	var pars []interface{}
+	var err error
+	fmt.Print()
+
+	var topCond string
+	var topPars []interface{}
+	toplist, err := models.GetTopOneMonthArtReadNumIndustryAll(topCond, topPars)
+	if err != nil {
+		return
+	}
+
+	mapIndustryName := make(map[int]string)
+	for _, v := range toplist {
+		mapIndustryName[v.IndustrialManagementId] = v.IndustryName
+	}
+	fmt.Println(mapIndustryName)
+	//处理上周纪要汇总
+	condition = ` AND  type = 1  `
+	list, err := models.GetCygxIndustryFllowListByCon(condition, pars, 0, 100000)
+	if err != nil {
+		fmt.Println(err)
+	}
+	var items []*models.CygxUserLabel
+	for _, user := range list {
+		item := new(models.CygxUserLabel)
+		item.UserId = user.UserId
+		item.CompanyId = user.CompanyId
+		item.RealName = user.RealName
+		item.Mobile = user.Mobile
+		item.Email = user.Email
+		item.Label = mapIndustryName[user.IndustrialManagementId]
+		item.SourceId = user.IndustrialManagementId
+		item.Source = 1
+		item.IsFollow = 1
+		item.CreateTime = time.Now()
+		item.ModifyTime = time.Now()
+		items = append(items, item)
+		if len(items)%5 == 0 {
+			err = models.CygxUserLabelMulti(items)
+			fmt.Println(err)
+			items = make([]*models.CygxUserLabel, 0)
+		}
+	}
+	if len(items) > 0 {
+		err = models.CygxUserLabelMulti(items)
+		fmt.Println(err, "555")
+	}
+}
+
+func init52222() {
+	var condition string
+	var pars []interface{}
+	var err error
+	fmt.Print()
+
+	var topCond string
+	var topPars []interface{}
+	toplist, err := models.GetCygxReportMappingCygxByCon(topCond, topPars, 0, 0)
+	if err != nil {
+		return
+	}
+
+	mapIndustryName := make(map[int]string)
+	for _, v := range toplist {
+		mapIndustryName[v.Id] = v.MatchTypeName
+	}
+	fmt.Println(mapIndustryName)
+
+	condition = ` `
+	list, err := models.GetCygxXzsChooseCategoryListByCon(condition, pars, 0, 100000)
+	if err != nil {
+		fmt.Println(err)
+	}
+	var items []*models.CygxUserLabel
+	for _, user := range list {
+		item := new(models.CygxUserLabel)
+		item.UserId = user.UserId
+		item.CompanyId = user.CompanyId
+		item.RealName = user.RealName
+		item.Mobile = user.Mobile
+		item.Email = user.Email
+		item.Label = mapIndustryName[user.IdCygx]
+		item.SourceId = user.IdCygx
+		item.Source = 2
+		item.IsFollow = 1
+		item.CreateTime = time.Now()
+		item.ModifyTime = time.Now()
+		items = append(items, item)
+		if len(items)%5 == 0 {
+			err = models.CygxUserLabelMulti(items)
+			fmt.Println(err)
+			items = make([]*models.CygxUserLabel, 0)
+		}
+	}
+	if len(items) > 0 {
+		err = models.CygxUserLabelMulti(items)
+		fmt.Println(err, "555")
+	}
+}
+
+func init5333() {
+	var condition string
+	var pars []interface{}
+	var err error
+	fmt.Print()
+
+	var topCond string
+	var topPars []interface{}
+	toplist, err := models.GetTopOneMonthArtReadNumIndustryAll(topCond, topPars)
+	if err != nil {
+		return
+	}
+
+	mapIndustryName := make(map[int]string)
+	for _, v := range toplist {
+		mapIndustryName[v.IndustrialManagementId] = v.IndustryName
+	}
+	fmt.Println(mapIndustryName)
+	condition = ` AND activity_time > '2022-11-25 00:00:00' AND publish_status = 1    `
+	listAct, err := models.GetCygxActivityList(condition, pars, 0, 100000)
+	if err != nil {
+		fmt.Println(err)
+	}
+	var items []*models.CygxUserLabelActivity
+	for _, v := range listAct {
+		fmt.Println(v.ActivityTime)
+		var condition1 string
+		var pars1 []interface{}
+		condition1 = ` AND activity_id = ?  `
+		pars1 = append(pars1, v.ActivityId)
+		total, e := models.GetCygxIndustrialActivityGroupManagementCount(condition1+"  AND  source = 1 ", pars1)
+		if e != nil {
+			fmt.Println(e)
+			return
+		}
+		if total == 0 {
+			continue
+		}
+		industrialList, e := models.GetCygxIndustrialActivityGroupManagementList(condition1+"  AND  source = 1 ", pars1)
+		if e != nil {
+			fmt.Println(e)
+			return
+		}
+
+		pars = make([]interface{}, 0)
+		condition = ` AND activity_id  = ? AND is_meeting = 1  `
+		pars = append(pars, v.ActivityId)
+		signUpList, err := models.GetSignupDetailBySignup(condition, pars)
+		if err != nil && err.Error() != utils.ErrNoRow() {
+			return
+		}
+		for _, vi := range industrialList {
+			for _, user := range signUpList {
+				item := new(models.CygxUserLabelActivity)
+				item.UserId = user.UserId
+				item.CompanyId = user.CompanyId
+				item.RealName = user.RealName
+				item.Mobile = user.Mobile
+				item.Email = user.Email
+				item.ActivityId = v.ActivityId
+				item.IndustrialManagementId = vi.IndustrialManagementId
+				item.Label = mapIndustryName[vi.IndustrialManagementId]
+				item.CreateTime = utils.StrTimeToTime(v.ActivityTime)
+				item.ModifyTime = time.Now()
+				items = append(items, item)
+				if len(items)%50 == 0 {
+					_, err = models.AddCygxUserLabelActivityList(items)
+					fmt.Println(err)
+					items = make([]*models.CygxUserLabelActivity, 0)
+				}
+			}
+		}
+	}
+	fmt.Println(len(items))
+	if len(items) > 0 {
+		_, err = models.AddCygxUserLabelActivityList(items)
+		fmt.Println(err, "555")
+	}
+}
+
+func init5444() {
+	var condition string
+	var pars []interface{}
+	var err error
+	fmt.Print()
+
+	var topCond string
+	var topPars []interface{}
+	toplist, err := models.GetTopOneMonthArtReadNumIndustryAll(topCond, topPars)
+	if err != nil {
+		return
+	}
+
+	mapIndustryName := make(map[int]string)
+	for _, v := range toplist {
+		mapIndustryName[v.IndustrialManagementId] = v.IndustryName
+	}
+	fmt.Println(mapIndustryName)
+	condition = ` AND is_meeting = 1  `
+	listAct, err := models.GetCygxActivitySpecialmeetingDetailList(condition, pars)
+	if err != nil {
+		fmt.Println(err)
+	}
+	var items []*models.CygxUserLabelActivitySpecial
+	for _, user := range listAct {
+		var condition1 string
+		var pars1 []interface{}
+		condition1 = ` AND activity_id = ?  `
+		pars1 = append(pars1, user.ActivityId)
+		total, e := models.GetCygxIndustrialActivityGroupManagementCount(condition1+"  AND  source = 2 ", pars1)
+		if e != nil {
+			fmt.Println(e)
+			return
+		}
+		if total == 0 {
+			continue
+		}
+		industrialList, e := models.GetCygxIndustrialActivityGroupManagementList(condition1+"  AND  source = 2 ", pars1)
+		if e != nil {
+			fmt.Println(e)
+			return
+		}
+		for _, vi := range industrialList {
+			item := new(models.CygxUserLabelActivitySpecial)
+			item.UserId = user.UserId
+			item.CompanyId = user.CompanyId
+			item.RealName = user.RealName
+			item.Mobile = user.Mobile
+			item.Email = user.Email
+			item.ActivityId = user.ActivityId
+			item.IndustrialManagementId = vi.IndustrialManagementId
+			item.Label = mapIndustryName[vi.IndustrialManagementId]
+			item.CreateTime = utils.StrTimeToTime(user.CreateTime)
+			item.ModifyTime = time.Now()
+			items = append(items, item)
+			if len(items)%50 == 0 {
+				_, err = models.AddCygxUserLabelActivitySpecialList(items)
+				fmt.Println(err)
+				items = make([]*models.CygxUserLabelActivitySpecial, 0)
+			}
+		}
+	}
+	fmt.Println(len(items))
+	if len(items) > 0 {
+		_, err = models.AddCygxUserLabelActivitySpecialList(items)
+		fmt.Println(err, "555")
+	}
+}
+
+func init5555() {
+	var condition string
+	var pars []interface{}
+	var err error
+	fmt.Print()
+
+	var topCond string
+	var topPars []interface{}
+	toplist, err := models.GetTopOneMonthArtReadNumIndustryAll(topCond, topPars)
+	if err != nil {
+		return
+	}
+
+	mapIndustryName := make(map[int]string)
+	for _, v := range toplist {
+		mapIndustryName[v.IndustrialManagementId] = v.IndustryName
+	}
+	//fmt.Println(mapIndustryName)
+	condition = ` AND   stop_time > 4  AND create_time > '2022-11-25 00:00:00' GROUP BY article_id  `
+	//condition = `   AND   stop_time > 4   AND create_time > '2023-04-25 00:00:00' GROUP BY article_id  `
+	listArtGroup, err := models.GetCygxArticleHistoryRecordNewpvList(condition, pars)
+	if err != nil {
+		fmt.Println(err)
+	}
+	fmt.Println(len(listArtGroup))
+	var source int
+
+	itemsMap := make(map[int][]*models.CygxUserLabel)
+	for _, v := range listArtGroup {
+		fmt.Println(v.ArticleId)
+		var items []*models.CygxUserLabel
+		articleId := v.ArticleId
+		var condition string
+		var pars []interface{}
+		condition = ` AND article_id = ? `
+		pars = append(pars, v.ArticleId)
+		industrialList, e := models.GetIndustrialArticleGroupManagementList(condition, pars)
+		if e != nil && e.Error() != utils.ErrNoRow() {
+			fmt.Println(e)
+			return
+		}
+		if len(industrialList) == 0 {
+			//如果没有行产业归类就按照行业报告处理
+			source = 2
+			detailArticle, e := models.GetArticleDetailById(articleId)
+			if e != nil {
+				fmt.Println(e)
+				return
+			}
+
+			labelDetail, e := models.GetdetailByCategoryIdLabel(detailArticle.CategoryId)
+			if e != nil {
+				fmt.Println(e)
+				return
+			}
+			label := labelDetail.MatchTypeName
+			industrialManagementId := labelDetail.Id
+			item := new(models.CygxUserLabel)
+
+			item.Label = label
+			item.SourceId = industrialManagementId
+			item.Source = source
+			item.Weight = 1
+			item.CreateTime = time.Now()
+			item.ModifyTime = time.Now()
+			items = append(items, item)
+		} else {
+			//如果有行产业归类就按照产业报告处理
+			var topCond string
+			var topPars []interface{}
+			var industrialManagementIds []int
+
+			for _, v := range industrialList {
+				industrialManagementIds = append(industrialManagementIds, v.IndustrialManagementId)
+			}
+			idsLen := len(industrialManagementIds)
+			if idsLen > 0 {
+				topCond = ` AND industrial_management_id IN (` + utils.GetOrmInReplace(idsLen) + `)`
+				topPars = append(topPars, industrialManagementIds)
+			} else {
+				return
+			}
+			industrNamelist, e := models.GetTopOneMonthArtReadNumIndustryAll(topCond, topPars)
+			if e != nil {
+				fmt.Println(e)
+				return
+			}
+			source = 1
+			for _, v := range industrNamelist {
+				label := v.IndustryName
+				industrialManagementId := v.IndustrialManagementId
+
+				item := new(models.CygxUserLabel)
+				item.Label = label
+				item.SourceId = industrialManagementId
+				item.Source = source
+				item.Weight = 1
+				item.CreateTime = time.Now()
+				item.ModifyTime = time.Now()
+				items = append(items, item)
+
+			}
+
+			//for _, vi := range industrialList {
+			//	for _, user := range signUpList {
+			//		item := new(models.CygxUserLabelActivity)
+			//		item.UserId = user.UserId
+			//		item.CompanyId = user.CompanyId
+			//		item.RealName = user.RealName
+			//		item.Mobile = user.Mobile
+			//		item.Email = user.Email
+			//		item.ActivityId = v.ActivityId
+			//		item.IndustrialManagementId = vi.IndustrialManagementId
+			//		item.Label = mapIndustryName[vi.IndustrialManagementId]
+			//		item.CreateTime = utils.StrTimeToTime(v.ActivityTime)
+			//		item.ModifyTime = time.Now()
+			//		items = append(items, item)
+			//		if len(items)%50 == 0 {
+			//			_, err = models.AddCygxUserLabelActivityList(items)
+			//			fmt.Println(err)
+			//			items = make([]*models.CygxUserLabelActivity, 0)
+			//		}
+			//	}
+			//}
+			itemsMap[articleId] = items
+		}
+	}
+	condition = `   AND   stop_time > 4   AND create_time > '2022-11-25 00:00:00'   `
+	//condition = `  AND   stop_time > 4    AND create_time > '2023-4-25 00:00:00'   `
+	listArt, err := models.GetCygxArticleHistoryRecordNewpvList(condition, pars)
+	if err != nil {
+		fmt.Println(err)
+	}
+	var items []*models.CygxUserLabelArticle
+
+	for _, user := range listArt {
+		if len(itemsMap[user.ArticleId]) > 0 {
+			for k2, vlsit := range itemsMap {
+				if k2 != user.ArticleId {
+					continue
+				}
+				for _, vm := range vlsit {
+
+					//if user.ArticleId == 8365 {
+					//	fmt.Println("k", k, "_k2:", k2, "_k3:", k3)
+					//	fmt.Println(vm.Label)
+					//}
+					item := new(models.CygxUserLabelArticle)
+					item.UserId = user.UserId
+					item.ArticleId = user.ArticleId
+					item.CompanyId = user.CompanyId
+					//item.RealName = user.R
+					item.Mobile = user.Mobile
+					item.Email = user.Email
+					item.Label = vm.Label
+					item.SourceId = vm.SourceId
+					item.Source = vm.Source
+					item.CreateTime = user.CreateTime
+					item.ModifyTime = time.Now()
+					items = append(items, item)
+					if len(items)%500 == 0 {
+						_, err = models.AddCygxUserLabelArticleList(items)
+						fmt.Println(err)
+						items = make([]*models.CygxUserLabelArticle, 0)
+					}
+				}
+			}
+		}
+	}
+	//for k, vlsit := range itemsMap[8365] {
+	//	fmt.Println(k)
+	//	fmt.Println(vlsit)
+	//	//for _, vm := range vlsit {
+	//	//	fmt.Println(vm)
+	//	//}
+	//}
+	fmt.Println(len(items))
+	fmt.Println(len(itemsMap))
+	fmt.Println((itemsMap))
+	fmt.Println(len(items))
+	if len(items) > 0 {
+		_, err = models.AddCygxUserLabelArticleList(items)
+		fmt.Println(err, "555")
+	}
+}

+ 148 - 2
services/user_label.go

@@ -73,7 +73,7 @@ func ActivityUserLabelLogAdd(activityId int, mobileArr []string) (err error) {
 		if err != nil {
 			fmt.Println(err)
 			msg := fmt.Sprint("activityId:", activityId, "mobile:", mobileArr)
-			go utils.SendAlarmMsg("用户关注产业更新相关标签,写入Redis队列消息失败:"+err.Error()+msg, 2)
+			go utils.SendAlarmMsg("添加用户活动到会标签到Redis,写入Redis队列消息失败:"+err.Error()+msg, 2)
 		}
 	}()
 	var condition string
@@ -122,7 +122,7 @@ func ActivityUserLabelLogAdd(activityId int, mobileArr []string) (err error) {
 		err = errors.New("GetWxUserByOutboundMobiles" + e.Error())
 		return
 	}
-	listActivityHistory, e := models.GetCygxUserLabelActivity(condition, pars, 0, 9999)
+	listActivityHistory, e := models.GetCygxUserLabelActivity(condition, pars)
 	if e != nil {
 		err = errors.New("GetCygxUserLabelActivity" + e.Error())
 		return
@@ -153,6 +153,7 @@ func ActivityUserLabelLogAdd(activityId int, mobileArr []string) (err error) {
 			item.Mobile = user.Mobile
 			item.Email = user.Email
 			item.ActivityId = activityId
+			item.IndustrialManagementId = industr.IndustrialManagementId
 			item.Label = industr.IndustryName
 			item.CreateTime = time.Now()
 			item.ModifyTime = time.Now()
@@ -826,3 +827,148 @@ func updateUserLabelByUserId(userId int) (err error) {
 	}
 	return
 }
+
+//func init() {
+//	UpdateUserLabelWeight()
+//}
+
+// 更新用户标签权重
+func UpdateUserLabelWeight() (err error) {
+	defer func() {
+		if err != nil {
+			fmt.Println(err)
+			go utils.SendAlarmMsg("更新用户标签权重失败:"+err.Error(), 2)
+		}
+	}()
+	var condition string
+	var pars []interface{}
+	list, e := models.GetCygxUserLabelList(condition, pars)
+	if e != nil {
+		err = errors.New("GetCygxUserLabelList" + e.Error())
+		return
+	}
+	updateTime := time.Now().AddDate(0, -3, 0)
+	condition = ` AND create_time > ?`
+	pars = append(pars, updateTime)
+
+	listArticle, e := models.GetCygxUserLabelArticleList(condition, pars)
+	if e != nil {
+		err = errors.New("GetCygxUserLabelArticleList" + e.Error())
+		return
+	}
+
+	listActivity, e := models.GetCygxUserLabelActivity(condition, pars)
+	if e != nil {
+		err = errors.New("GetCygxUserLabelActivity" + e.Error())
+		return
+	}
+
+	listActivitySpecial, e := models.GetCygxUserLabelActivitySpecial(condition, pars)
+	if e != nil {
+		err = errors.New("GetCygxUserLabelActivitySpecial" + e.Error())
+		return
+	}
+	userLabel := make(map[string]bool)
+	userLabelWeight := make(map[string]int)
+	for _, v := range list {
+		userLabel[fmt.Sprint("user_id{|}", v.UserId, "{|}source_id{|}", v.SourceId, "{|}source{|}", v.Source)] = true
+	}
+	//处理文章标签
+	var items []*models.CygxUserLabel
+	for _, user := range listArticle {
+		if !userLabel[fmt.Sprint("user_id{|}", user.UserId, "{|}source_id{|}", user.SourceId, "{|}source{|}", user.Source)] {
+			item := new(models.CygxUserLabel)
+			item.UserId = user.UserId
+			item.CompanyId = user.CompanyId
+			item.RealName = user.RealName
+			item.Mobile = user.Mobile
+			item.Email = user.Email
+			item.Label = user.Label
+			item.SourceId = user.SourceId
+			item.Source = user.Source
+			item.CreateTime = user.CreateTime
+			item.ModifyTime = time.Now()
+			items = append(items, item)
+			userLabel[fmt.Sprint("user_id{|}", user.UserId, "{|}source_id{|}", user.SourceId, "{|}source{|}", user.Source)] = true
+		}
+		userLabelWeight[fmt.Sprint("user_id{|}", user.UserId, "{|}label{|}", user.Label)]++
+	}
+
+	//处理活动标签
+	for _, user := range listActivity {
+		if !userLabel[fmt.Sprint("user_id{|}", user.UserId, "{|}source_id{|}", user.IndustrialManagementId, "{|}source{|}", 1)] {
+			item := new(models.CygxUserLabel)
+			item.UserId = user.UserId
+			item.CompanyId = user.CompanyId
+			item.RealName = user.RealName
+			item.Mobile = user.Mobile
+			item.Email = user.Email
+			item.Label = user.Label
+			item.SourceId = user.IndustrialManagementId
+			item.Source = 1
+			item.CreateTime = user.CreateTime
+			item.ModifyTime = time.Now()
+			items = append(items, item)
+			userLabel[fmt.Sprint("user_id{|}", user.UserId, "{|}source_id{|}", user.IndustrialManagementId, "{|}source{|}", 1)] = true
+		}
+		userLabelWeight[fmt.Sprint("user_id{|}", user.UserId, "{|}label{|}", user.Label)]++
+	}
+
+	//处理专项调研活动标签
+	for _, user := range listActivitySpecial {
+		if !userLabel[fmt.Sprint("user_id{|}", user.UserId, "{|}source_id{|}", user.IndustrialManagementId, "{|}source{|}", 1)] {
+			item := new(models.CygxUserLabel)
+			item.UserId = user.UserId
+			item.CompanyId = user.CompanyId
+			item.RealName = user.RealName
+			item.Mobile = user.Mobile
+			item.Email = user.Email
+			item.Label = user.Label
+			item.SourceId = user.IndustrialManagementId
+			item.Source = 1
+			item.CreateTime = user.CreateTime
+			item.ModifyTime = time.Now()
+			items = append(items, item)
+			userLabel[fmt.Sprint("user_id{|}", user.UserId, "{|}source_id{|}", user.IndustrialManagementId, "{|}source{|}", 1)] = true
+		}
+		userLabelWeight[fmt.Sprint("user_id{|}", user.UserId, "{|}label{|}", user.Label)]++
+	}
+
+	if len(items) > 0 {
+		e = models.CygxUserLabelMulti(items)
+		if e != nil {
+			err = errors.New("CygxUserLabelMulti" + e.Error())
+			return
+		}
+	}
+	var itemsUpdate []*models.CygxUserLabel
+	for k, v := range userLabelWeight {
+		sliceUser := strings.Split(k, "{|}")
+		userid, _ := strconv.Atoi(sliceUser[1])
+		label := sliceUser[len(sliceUser)-1]
+		item := new(models.CygxUserLabel)
+		item.UserId = userid
+		item.Label = label
+		item.Weight = v
+		itemsUpdate = append(itemsUpdate, item)
+	}
+	e = models.UpdateCygxUserLabelMulti(itemsUpdate)
+	if e != nil {
+		err = errors.New("UpdateCygxUserLabelMulti" + e.Error())
+		return
+	}
+
+	e = models.UpdateCygxUserLabelWeightAll()
+	if e != nil {
+		err = errors.New("UpdateCygxUserLabelWeightAll" + e.Error())
+		return
+	}
+
+	pars = make([]interface{}, 0)
+	condition = ` GROUP BY user_id`
+	listUser, e := models.GetCygxUserLabelList(condition, pars)
+	for _, v := range listUser {
+		go updateUserLabelByUserId(v.UserId)
+	}
+	return
+}

+ 167 - 165
services/wx_user.go

@@ -5,7 +5,6 @@ import (
 	"fmt"
 	"hongze/hongze_cygx/models"
 	"hongze/hongze_cygx/utils"
-	"sort"
 	"strconv"
 	"strings"
 	"time"
@@ -336,170 +335,170 @@ func UpdateWxUserLabel(cont context.Context) (err error) {
 	}
 
 	//处理用户标签
-	for _, vUser := range listUser {
-		labels, err := models.GetCygxCompanyUserListSplit(strconv.Itoa(vUser.UserId))
-		if err != nil {
-			fmt.Println("GetCygxCompanyUserListSplit Err", err)
-			return err
-		}
-		mapLabels := make(map[string]string)
-		var labelsListStr []*models.UserLabel
-		mapActivityLabels := make(map[string]string)
-		labelsList := strings.Split(labels, ",")
-		for _, vL := range labelsList {
-			if mapLabels[vL] == "" && vL != "" {
-				mapLabels[vL] = vL
-				item := new(models.UserLabel)
-				item.Label = vL
-				labelsListStr = append(labelsListStr, item)
-			}
-		}
-		dateTime := time.Now().AddDate(0, -3, 0).Format(utils.FormatDate)
-		listArticlePv, err := models.GetArticlePvCount(vUser.Mobile, vUser.Email, dateTime)
-		if err != nil && err.Error() != utils.ErrNoRow() {
-			fmt.Println("GetArticlePvCount Err", err)
-			return err
-		}
-		var articleIds string
-		mapArticleIdLabelTotal := make(map[string]int)
-		mapArticleIdPv := make(map[int]int)
-		if len(listArticlePv) > 0 {
-			for _, v := range listArticlePv {
-				articleIds += strconv.Itoa(v.ArticleId) + ","
-				mapArticleIdPv[v.ArticleId] = v.Pv
-			}
-			articleIds = strings.TrimRight(articleIds, ",")
-			//产业、标的标签
-			listLabelName, err := models.GetArticleGroupyIndustryName(articleIds)
-			if err != nil && err.Error() != utils.ErrNoRow() {
-				fmt.Println("GetArticleGroupyIndustryName Err", err)
-				return err
-			}
-			if len(listLabelName) > 0 {
-				for _, v := range listLabelName {
-					labelsIndustryList := strings.Split(v.IndustryName, "/")
-					labelsSubjectList := strings.Split(v.SubjectName, "/")
-					//添加产业统计
-					if len(labelsIndustryList) > 0 {
-						for _, vIn := range labelsIndustryList {
-							if mapActivityLabels[vIn] != "" {
-								mapArticleIdLabelTotal[vIn] += mapArticleIdPv[v.ArticleId]
-							} else {
-								mapArticleIdLabelTotal[vIn] = mapArticleIdPv[v.ArticleId]
-								mapActivityLabels[vIn] = vIn
-							}
-						}
-					}
-					if len(labelsSubjectList) > 0 {
-						//添加标的统计
-						for _, vIn := range labelsSubjectList {
-							if mapActivityLabels[vIn] != "" {
-								mapArticleIdLabelTotal[vIn] += mapArticleIdPv[v.ArticleId]
-							} else {
-								mapArticleIdLabelTotal[vIn] = mapArticleIdPv[v.ArticleId]
-								mapActivityLabels[vIn] = vIn
-							}
-						}
-					}
-				}
-			}
-		}
-		articleIds, err = models.GetCygxArticleCollectId(vUser.UserId, dateTime)
-		if err != nil && err.Error() != utils.ErrNoRow() {
-			fmt.Println("GetCygxArticleCollectId Err", err)
-			return err
-		}
-		if articleIds != "" {
-			//产业、标的标签
-			listLabelName, err := models.GetArticleGroupyIndustryName(articleIds)
-			if err != nil && err.Error() != utils.ErrNoRow() {
-				fmt.Println("GetArticleGroupyIndustryName Err", err)
-				return err
-			}
-			if len(listLabelName) > 0 {
-				for _, v := range listLabelName {
-					labelsIndustryList := strings.Split(v.IndustryName, "/")
-					labelsSubjectList := strings.Split(v.SubjectName, "/")
-					//添加产业统计
-					if len(labelsIndustryList) > 0 {
-						for _, vIn := range labelsIndustryList {
-							if mapActivityLabels[vIn] != "" {
-								mapArticleIdLabelTotal[vIn] += 1
-							} else {
-								mapArticleIdLabelTotal[vIn] = 1
-								mapActivityLabels[vIn] = vIn
-							}
-						}
-					}
-					if len(labelsSubjectList) > 0 {
-						//添加标的统计
-						for _, vIn := range labelsSubjectList {
-							if mapActivityLabels[vIn] != "" {
-								mapArticleIdLabelTotal[vIn] += 1
-							} else {
-								mapArticleIdLabelTotal[vIn] = 1
-								mapActivityLabels[vIn] = vIn
-							}
-						}
-					}
-				}
-			}
-		}
-		//活动标签计算
-		listActivityPv, err := models.GetActivitySignCount(vUser.Mobile, dateTime)
-		if err != nil && err.Error() != utils.ErrNoRow() {
-			fmt.Println("GetActivitySignCount Err", err)
-			return err
-		}
-		if len(listActivityPv) > 0 {
-			for _, v := range listActivityPv {
-				labelsList := strings.Split(v.Label, "-")
-				for _, v2 := range labelsList {
-					labelsListSon := strings.Split(v2, "/")
-					for _, v3 := range labelsListSon {
-						if mapActivityLabels[v3] != "" {
-							mapArticleIdLabelTotal[v3] += 1
-						} else {
-							mapArticleIdLabelTotal[v3] = 1
-							mapActivityLabels[v3] = v3
-						}
-					}
-				}
-			}
-		}
-		//对标签数量进行排序
-		type KvPair struct {
-			Key string
-			Val int
-		}
-		tmpList := make([]KvPair, 0)
-		for k, v := range mapArticleIdLabelTotal {
-			tmpList = append(tmpList, KvPair{Key: k, Val: v})
-		}
-		sort.Slice(tmpList, func(i, j int) bool {
-			return tmpList[i].Val > tmpList[j].Val // 降序
-		})
-		for _, v := range tmpList {
-			if v.Key != "" {
-				mapLabels[v.Key] = v.Key
-				item := new(models.UserLabel)
-				item.Label = v.Key
-				labelsListStr = append(labelsListStr, item)
-			}
-		}
-		var labelNew string
-		for _, v := range labelsListStr {
-			labelNew += v.Label + ","
-		}
-		labelNew = strings.TrimRight(labelNew, ",")
-		if labelNew != "" {
-			err = models.UpdateUserLabel(labelNew, vUser.UserId)
-			if err != nil {
-				fmt.Println("UpdateUserLabel Err", err)
-				return err
-			}
-		}
-	}
+	//for _, vUser := range listUser {
+	//	labels, err := models.GetCygxCompanyUserListSplit(strconv.Itoa(vUser.UserId))
+	//	if err != nil {
+	//		fmt.Println("GetCygxCompanyUserListSplit Err", err)
+	//		return err
+	//	}
+	//	mapLabels := make(map[string]string)
+	//	var labelsListStr []*models.UserLabel
+	//	mapActivityLabels := make(map[string]string)
+	//	labelsList := strings.Split(labels, ",")
+	//	for _, vL := range labelsList {
+	//		if mapLabels[vL] == "" && vL != "" {
+	//			mapLabels[vL] = vL
+	//			item := new(models.UserLabel)
+	//			item.Label = vL
+	//			labelsListStr = append(labelsListStr, item)
+	//		}
+	//	}
+	//	dateTime := time.Now().AddDate(0, -3, 0).Format(utils.FormatDate)
+	//	listArticlePv, err := models.GetArticlePvCount(vUser.Mobile, vUser.Email, dateTime)
+	//	if err != nil && err.Error() != utils.ErrNoRow() {
+	//		fmt.Println("GetArticlePvCount Err", err)
+	//		return err
+	//	}
+	//	var articleIds string
+	//	mapArticleIdLabelTotal := make(map[string]int)
+	//	mapArticleIdPv := make(map[int]int)
+	//	if len(listArticlePv) > 0 {
+	//		for _, v := range listArticlePv {
+	//			articleIds += strconv.Itoa(v.ArticleId) + ","
+	//			mapArticleIdPv[v.ArticleId] = v.Pv
+	//		}
+	//		articleIds = strings.TrimRight(articleIds, ",")
+	//		//产业、标的标签
+	//		listLabelName, err := models.GetArticleGroupyIndustryName(articleIds)
+	//		if err != nil && err.Error() != utils.ErrNoRow() {
+	//			fmt.Println("GetArticleGroupyIndustryName Err", err)
+	//			return err
+	//		}
+	//		if len(listLabelName) > 0 {
+	//			for _, v := range listLabelName {
+	//				labelsIndustryList := strings.Split(v.IndustryName, "/")
+	//				labelsSubjectList := strings.Split(v.SubjectName, "/")
+	//				//添加产业统计
+	//				if len(labelsIndustryList) > 0 {
+	//					for _, vIn := range labelsIndustryList {
+	//						if mapActivityLabels[vIn] != "" {
+	//							mapArticleIdLabelTotal[vIn] += mapArticleIdPv[v.ArticleId]
+	//						} else {
+	//							mapArticleIdLabelTotal[vIn] = mapArticleIdPv[v.ArticleId]
+	//							mapActivityLabels[vIn] = vIn
+	//						}
+	//					}
+	//				}
+	//				if len(labelsSubjectList) > 0 {
+	//					//添加标的统计
+	//					for _, vIn := range labelsSubjectList {
+	//						if mapActivityLabels[vIn] != "" {
+	//							mapArticleIdLabelTotal[vIn] += mapArticleIdPv[v.ArticleId]
+	//						} else {
+	//							mapArticleIdLabelTotal[vIn] = mapArticleIdPv[v.ArticleId]
+	//							mapActivityLabels[vIn] = vIn
+	//						}
+	//					}
+	//				}
+	//			}
+	//		}
+	//	}
+	//	articleIds, err = models.GetCygxArticleCollectId(vUser.UserId, dateTime)
+	//	if err != nil && err.Error() != utils.ErrNoRow() {
+	//		fmt.Println("GetCygxArticleCollectId Err", err)
+	//		return err
+	//	}
+	//	if articleIds != "" {
+	//		//产业、标的标签
+	//		listLabelName, err := models.GetArticleGroupyIndustryName(articleIds)
+	//		if err != nil && err.Error() != utils.ErrNoRow() {
+	//			fmt.Println("GetArticleGroupyIndustryName Err", err)
+	//			return err
+	//		}
+	//		if len(listLabelName) > 0 {
+	//			for _, v := range listLabelName {
+	//				labelsIndustryList := strings.Split(v.IndustryName, "/")
+	//				labelsSubjectList := strings.Split(v.SubjectName, "/")
+	//				//添加产业统计
+	//				if len(labelsIndustryList) > 0 {
+	//					for _, vIn := range labelsIndustryList {
+	//						if mapActivityLabels[vIn] != "" {
+	//							mapArticleIdLabelTotal[vIn] += 1
+	//						} else {
+	//							mapArticleIdLabelTotal[vIn] = 1
+	//							mapActivityLabels[vIn] = vIn
+	//						}
+	//					}
+	//				}
+	//				if len(labelsSubjectList) > 0 {
+	//					//添加标的统计
+	//					for _, vIn := range labelsSubjectList {
+	//						if mapActivityLabels[vIn] != "" {
+	//							mapArticleIdLabelTotal[vIn] += 1
+	//						} else {
+	//							mapArticleIdLabelTotal[vIn] = 1
+	//							mapActivityLabels[vIn] = vIn
+	//						}
+	//					}
+	//				}
+	//			}
+	//		}
+	//	}
+	//	//活动标签计算
+	//	listActivityPv, err := models.GetActivitySignCount(vUser.Mobile, dateTime)
+	//	if err != nil && err.Error() != utils.ErrNoRow() {
+	//		fmt.Println("GetActivitySignCount Err", err)
+	//		return err
+	//	}
+	//	if len(listActivityPv) > 0 {
+	//		for _, v := range listActivityPv {
+	//			labelsList := strings.Split(v.Label, "-")
+	//			for _, v2 := range labelsList {
+	//				labelsListSon := strings.Split(v2, "/")
+	//				for _, v3 := range labelsListSon {
+	//					if mapActivityLabels[v3] != "" {
+	//						mapArticleIdLabelTotal[v3] += 1
+	//					} else {
+	//						mapArticleIdLabelTotal[v3] = 1
+	//						mapActivityLabels[v3] = v3
+	//					}
+	//				}
+	//			}
+	//		}
+	//	}
+	//	//对标签数量进行排序
+	//	type KvPair struct {
+	//		Key string
+	//		Val int
+	//	}
+	//	tmpList := make([]KvPair, 0)
+	//	for k, v := range mapArticleIdLabelTotal {
+	//		tmpList = append(tmpList, KvPair{Key: k, Val: v})
+	//	}
+	//	sort.Slice(tmpList, func(i, j int) bool {
+	//		return tmpList[i].Val > tmpList[j].Val // 降序
+	//	})
+	//	for _, v := range tmpList {
+	//		if v.Key != "" {
+	//			mapLabels[v.Key] = v.Key
+	//			item := new(models.UserLabel)
+	//			item.Label = v.Key
+	//			labelsListStr = append(labelsListStr, item)
+	//		}
+	//	}
+	//	var labelNew string
+	//	for _, v := range labelsListStr {
+	//		labelNew += v.Label + ","
+	//	}
+	//	labelNew = strings.TrimRight(labelNew, ",")
+	//	if labelNew != "" {
+	//		err = models.UpdateUserLabel(labelNew, vUser.UserId)
+	//		if err != nil {
+	//			fmt.Println("UpdateUserLabel Err", err)
+	//			return err
+	//		}
+	//	}
+	//}
 
 	//处理用户、机构互动量数据
 	{
@@ -754,5 +753,8 @@ func UpdateWxUserLabel(cont context.Context) (err error) {
 			}
 		}
 	}
+
+	//更新用户标签以及权重
+	go UpdateUserLabelWeight()
 	return
 }