123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474 |
- package services
- import (
- "fmt"
- "github.com/beego/beego/v2/client/orm"
- "hongze/hongze_cygx/models"
- "hongze/hongze_cygx/utils"
- "time"
- )
- //10.5.1版本上线需要更新的数据
- func init1111() {
- 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)%5000 == 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 init123() {
- var condition string
- var pars []interface{}
- var err error
- fmt.Print()
- var topCond string
- var topPars []interface{}
- toplist, err := models.GetCygxReportMappingCygxByCon(topCond, topPars)
- 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 {
- if user.IdCygx == 0 {
- continue
- }
- 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()
- fmt.Println(item.SourceId)
- items = append(items, item)
- if len(items)%5000 == 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)%5000 == 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)%5000 == 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 > 3 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)
- continue
- //return
- }
- if len(industrialList) == 0 {
- //如果没有行产业归类就按照行业报告处理
- source = 2
- detailArticle, e := models.GetArticleDetailById(articleId)
- if e != nil {
- fmt.Println(e)
- continue
- //return
- }
- labelDetail, e := models.GetdetailByCategoryIdLabel(detailArticle.CategoryId)
- if e != nil {
- fmt.Println(e)
- continue
- //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 {
- continue
- }
- industrNamelist, e := models.GetTopOneMonthArtReadNumIndustryAll(topCond, topPars)
- if e != nil {
- fmt.Println(e)
- continue
- }
- 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 > 3 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
- fmt.Println(len(listArt))
- 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)%5000 == 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")
- }
- }
- func init10_12() {
- var condition string
- var pars []interface{}
- condition = " AND active_state = 1 "
- listAct, err := models.GetCygxActivityList(condition, pars, 0, 100000)
- fmt.Println(err)
- for _, v := range listAct {
- resultTime := utils.StrTimeToTime(v.ActivityTime) //时间字符串格式转时间格式
- cancelDeadline := resultTime.Add(-time.Hour * 1).Format(utils.FormatDateTime) //默认一小时
- o := orm.NewOrm()
- sql := `UPDATE cygx_activity SET cancel_deadline = ? WHERE activity_id = ? `
- _, err = o.Raw(sql, cancelDeadline, v.ActivityId).Exec()
- fmt.Println(err)
- }
- }
|