12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277 |
- package services
- import (
- "context"
- "encoding/json"
- "errors"
- "fmt"
- "golang.org/x/net/html"
- "hongze/hongze_cygx/models"
- "hongze/hongze_cygx/utils"
- "strconv"
- "strings"
- "time"
- )
- // 修改标签状态
- func UpdateIndustrialManagementLabel(cont context.Context) (err error) {
- defer func() {
- if err != nil {
- fmt.Println("修改失败,Err:", err.Error())
- }
- }()
- fmt.Println("修改状态0000")
- go models.UpdateIndustrialIsNewLabel()
- list, err := models.GetIndustrialMorethan10()
- if err != nil {
- return err
- }
- if len(list) == 0 {
- return
- }
- var idStr string
- for _, v := range list {
- idStr += v.IndustrialManagementId + ","
- }
- idStr = strings.TrimRight(idStr, ",")
- go models.UpdateIndustrialIsDeepLabel(idStr)
- //fmt.Println(idStr)
- //go models.UpdateActivitySattusToComplete()
- fmt.Println("修改状态完成")
- return
- }
- // 修改状态
- func UpdateIndustrialManagementSubjectNnames() (err error) {
- defer func() {
- if err != nil {
- fmt.Println("修改失败,Err:", err.Error())
- }
- }()
- fmt.Println("修改产业关联标的")
- list, err := models.GetIndustrialManagementIds()
- if err != nil {
- return err
- }
- for _, v := range list {
- //fmt.Println(v.IndustrialManagementId)
- var nameSub string
- listSub, errdSub := models.GetcygxIndustrialSubject(v.IndustrialManagementId)
- if errdSub != nil {
- return errdSub
- }
- for _, v2 := range listSub {
- fmt.Println(v2.SubjectName)
- nameSub += v2.SubjectName + ","
- }
- nameSub += v.IndustryName
- go models.UpdateIndustrialManagementSubjectNames(nameSub, v.IndustrialManagementId)
- }
- if len(list) == 0 {
- return
- }
- fmt.Println("修改状态完成")
- return
- }
- func ChageIndustrialArticleNum(cont context.Context) (err error) {
- IndustrialHzArticleNumUpdate()
- IndustrialYxArticleNumUpdate()
- IndustrialActivityNumUpdate()
- return
- }
- //func init() {
- // IndustrialHzArticleNumUpdate()
- // IndustrialYxArticleNumUpdate()
- // IndustrialActivityNumUpdate()
- //}
- // 更改弘则对应的报告关联产业近一个月的阅读量
- func IndustrialHzArticleNumUpdate() (err error) {
- defer func() {
- if err != nil {
- //fmt.Println(err)
- go utils.SendAlarmMsg("更改弘则对应的报告关联产业近一个月的阅读量失败"+err.Error(), 2)
- go utils.SendEmail(utils.APPNAME+"【"+utils.RunMode+"】"+"更改弘则对应的报告关联产业近一个月的阅读量失败失败提醒", err.Error(), utils.EmailSendToUsers)
- }
- }()
- err = models.UpdateIndustrialManagementArtticleReadNum()
- if err != nil {
- return
- }
- articleTypeIds, err := GetYanXuanArticleTypeIds()
- if err != nil {
- return
- }
- var condition string
- if articleTypeIds == "" {
- return
- }
- condition = ` AND a.article_type_id NOT IN (` + articleTypeIds + `) `
- list, err := models.GetIndustrialManagementArtHistoryCount(condition)
- if err != nil {
- return
- }
- for _, v := range list {
- err = models.UpdateIndustrialManagementArtReadNum(v.Count, v.IndustrialManagementId)
- if err != nil {
- return
- }
- }
- return err
- }
- // 更改研选对应的报告关联产业近一个月的阅读量
- func IndustrialYxArticleNumUpdate() (err error) {
- defer func() {
- if err != nil {
- //fmt.Println(err)
- go utils.SendAlarmMsg("更改研选对应的报告关联产业近一个月的阅读量失败"+err.Error(), 2)
- go utils.SendEmail(utils.APPNAME+"【"+utils.RunMode+"】"+"更改研选对应的报告关联产业近一个月的阅读量失败提醒", err.Error(), utils.EmailSendToUsers)
- }
- }()
- articleTypeIds, err := GetYanXuanArticleTypeIds()
- if err != nil {
- return
- }
- var condition string
- if articleTypeIds == "" {
- return
- }
- condition = ` AND a.article_type_id IN (` + articleTypeIds + `) `
- list, err := models.GetIndustrialManagementArtHistoryCount(condition)
- if err != nil {
- return
- }
- for _, v := range list {
- err = models.UpdateIndustrialManagementArtYanXuanReadNum(v.Count, v.IndustrialManagementId)
- if err != nil {
- return
- }
- }
- return err
- }
- // 更改活动关联产业近一个月的到会量
- func IndustrialActivityNumUpdate() (err error) {
- defer func() {
- if err != nil {
- //fmt.Println(err)
- go utils.SendAlarmMsg("更改活动关联产业近一个月的到会量失败"+err.Error(), 2)
- go utils.SendEmail(utils.APPNAME+"【"+utils.RunMode+"】"+"更改活动关联产业近一个月的到会量失败", err.Error(), utils.EmailSendToUsers)
- }
- }()
- list, err := models.GetIndustrialManagementActivityHistoryCount()
- if err != nil {
- return
- }
- for _, v := range list {
- err = models.UpdateIndustrialManagementActivityNum(v.Count, v.IndustrialManagementId)
- if err != nil {
- return
- }
- }
- return err
- }
- func ReportBillboardUpdate(cont context.Context) (err error) {
- //修改产业关注数量
- go IndustryFllowCountUpdate()
- //修改文章收藏数量
- go ArticleCollectCountUpdate()
- return
- }
- // 修改产业关注数量
- func IndustryFllowCountUpdate() (err error) {
- defer func() {
- if err != nil {
- go utils.SendAlarmMsg("修改产业关注数量信息失败"+err.Error(), 2)
- go utils.SendEmail(utils.APPNAME+"【"+utils.RunMode+"】"+"失败提醒", "GetCeLueArticlePv ErrMsg:"+err.Error(), utils.EmailSendToUsers)
- }
- }()
- fllowList, err := models.GetUserFllowIndustrialCountList()
- if err != nil {
- return
- }
- for _, v := range fllowList {
- err = models.UpdateIndustrialManagementFllowNum(v.Num, v.IndustrialManagementId)
- if err != nil {
- return
- }
- }
- return err
- }
- // 修改文章收藏数量
- func ArticleCollectCountUpdate() (err error) {
- defer func() {
- if err != nil {
- go utils.SendAlarmMsg("修改文章收藏数量信息失败"+err.Error(), 2)
- go utils.SendEmail(utils.APPNAME+"【"+utils.RunMode+"】"+"失败提醒", "修改文章收藏数量信息失败 ErrMsg:"+err.Error(), utils.EmailSendToUsers)
- }
- }()
- collectList, err := models.GetUserArticleCollectList()
- if err != nil {
- return
- }
- for _, v := range collectList {
- err = models.UpdateArticleCollectCountNum(v.Num, v.ArticleId)
- if err != nil {
- return
- }
- }
- return err
- }
- // 根据行业处理所选的全部赛道字段
- func DoXzsChooseSend(chartPermissionName string) string {
- var allIn string
- if chartPermissionName == utils.YI_YAO_NAME {
- allIn = "all_in_yi_yao"
- } else if chartPermissionName == utils.XIAO_FEI_NAME {
- allIn = "all_in_xiao_fei"
- } else if chartPermissionName == utils.KE_JI_NAME {
- allIn = "all_in_ke_ji"
- } else if chartPermissionName == utils.ZHI_ZAO_NAME {
- allIn = "all_in_zhi_zao"
- } else if chartPermissionName == utils.CHART_PERMISSION_NAME_MF_YANXUAN {
- allIn = "all_in_yan_xuan"
- }
- return allIn
- }
- // 行业关注或者取消关注的时候,对于用户全部赛道的影响
- func IndustryFllowWithTrack(industrialManagementId, count, uid int) (err error) {
- defer func() {
- if err != nil {
- fmt.Println(err)
- go utils.SendAlarmMsg("修改行业关注或者取消关注的时候,对于用户全部赛道的影响信息失败"+err.Error(), 2)
- go utils.SendEmail(utils.APPNAME+"【"+utils.RunMode+"】"+"失败提醒", "修改行业关注或者取消关注的时候,对于用户全部赛道的影响信息失败 ErrMsg:"+err.Error(), utils.EmailSendToUsers)
- }
- }()
- detail, err := models.GetIndustrialManagementDetail(industrialManagementId)
- if err != nil {
- return err
- }
- categoryinfo, err := models.GetChartPermissionById(detail.ChartPermissionId)
- if err != nil {
- return err
- }
- var allIn string
- allIn = DoXzsChooseSend(categoryinfo.PermissionName)
- if allIn != "" {
- //如果取消关注就把该赛道设置为非全部赛道
- if count == 1 {
- err = models.UpdateCygxXzsChooseSendIsAllIn(allIn, 0, uid)
- if err != nil {
- return err
- }
- } else {
- //医药、消费、科技、智造、研选下的产业赛道
- mapIndustrial := make(map[int][]*models.IndustrialManagementRep)
- industrialList, err := models.GetindustrialManagement()
- if err != nil {
- return err
- }
- for _, v := range industrialList {
- mapIndustrial[v.ChartPermissionId] = append(mapIndustrial[v.ChartPermissionId], v)
- }
- fllowNum, err := models.GetCountCygxIndustryFllowByUidAndChartPermissionId(uid, detail.ChartPermissionId)
- if err != nil {
- return err
- }
- if fllowNum == len(mapIndustrial[detail.ChartPermissionId]) {
- err = models.UpdateCygxXzsChooseSendIsAllIn(allIn, 1, uid)
- if err != nil {
- return err
- }
- }
- }
- }
- return err
- }
- //func init() {
- //IndustryFllowUserLabel(136, 16, 5660)
- //UserLabelLogReduce()
- //}
- // GetIndustryNewLabelMap 获取产业【新】标签Map
- func GetIndustryNewLabelMap(industryIds []int) (labelMap map[int]bool, err error) {
- labelMap = make(map[int]bool, 0)
- industryIdLen := len(industryIds)
- if industryIdLen == 0 {
- return
- }
- // 获取产业关联的报告最早发布时间及最近的发布时间
- var timeCond string
- var timePars []interface{}
- timeCond += ` AND b.publish_status = 1`
- if industryIdLen > 0 {
- timeCond += ` AND a.industrial_management_id IN (` + utils.GetOrmInReplace(industryIdLen) + `)`
- timePars = append(timePars, industryIds)
- }
- //只要弘则报告,不要研选报告
- timeCond += ` AND b.article_id < ? `
- timePars = append(timePars, utils.SummaryArticleId)
- industryTimeList, e := models.GetIndustryArticleMinMaxPublishTime(timeCond, timePars)
- if e != nil {
- err = errors.New("获取产业文章最大最小发布时间失败, Err: " + e.Error())
- return
- }
- // 判断产业是否为新
- nowTime := time.Now().Local()
- threeMonthBefore := nowTime.AddDate(0, -3, 0)
- nullTime, _ := time.ParseInLocation(utils.FormatDateTime, "0001-01-01 00:00:00", time.Local)
- industryMap := make(map[int]*models.IndustryArticleMinMaxPublishTime, 0)
- for i := range industryTimeList {
- industryMap[industryTimeList[i].IndustrialManagementId] = industryTimeList[i]
- }
- for i := range industryIds {
- iid := industryIds[i]
- item := industryMap[iid]
- if item != nil {
- // 最早发布时间为空 / 最早发布时间在三个月前之后
- if item.MinPublishTime.Equal(nullTime) || (item.MinPublishTime.After(threeMonthBefore)) {
- labelMap[iid] = true
- }
- } else {
- // 产业无报告, 则为新产业
- labelMap[iid] = true
- }
- }
- return
- }
- //func init() {
- // GetIndustrialManagementArticleNewPublishData()
- //}
- // 批量修改获取产业关联文章的最新发布时间
- func GetIndustrialManagementArticleNewPublishData() (err error) {
- defer func() {
- if err != nil {
- go utils.SendAlarmMsg("批量修改获取产业关联文章的最新发布时间"+"GetIndustrialManagementArticleNewPublishData ErrMsg:"+err.Error(), 2)
- }
- }()
- articleNewPublishDataList, e := models.GetIndustrialManagementArticleNewPublishData()
- if e != nil {
- err = errors.New("获取客户剩余报名次数失败 GetIndustrialManagementArticleNewPublishData, Err: " + e.Error())
- return
- }
- mapUPdateTime := make(map[int]string)
- var industrialManagementIds []int
- for _, v := range articleNewPublishDataList {
- if v.IndustrialManagementId > 0 {
- industrialManagementIds = append(industrialManagementIds, v.IndustrialManagementId)
- }
- mapUPdateTime[v.IndustrialManagementId] = v.UpdateTime
- }
- //时间线的更新时间
- listtimelinePublishdate, err := models.GetTimeLineReportIndustrialPublishdateList(industrialManagementIds)
- if err != nil && err.Error() != utils.ErrNoRow() {
- return
- }
- for _, v := range listtimelinePublishdate {
- if mapUPdateTime[v.IndustrialManagementId] != "" {
- if utils.StrTimeToTime(v.PublishDate).After(utils.StrTimeToTime(mapUPdateTime[v.IndustrialManagementId])) {
- mapUPdateTime[v.IndustrialManagementId] = v.PublishDate
- }
- }
- }
- err = models.UpdateIndustrialManagementArticleNewPublishData(mapUPdateTime)
- return
- }
- // HandleIndustryList预处理产业列表字段
- func HandleIndustryList(list []*models.IndustrialManagement, user *models.WxUserItem) (items []*models.IndustrialManagement, err error) {
- userId := user.UserId
- fllowList, err := models.GetUserFllowIndustrialList(userId)
- if err != nil {
- return
- }
- fllowMap := make(map[int]int)
- if len(fllowList) > 0 {
- for _, v := range fllowList {
- fllowMap[v.IndustrialManagementId] = v.IndustrialManagementId
- }
- }
- mapindustrialId, e := GetMicroRoadshowVideoMap()
- if e != nil {
- err = e
- return
- }
- followTypeMap := GetCygxIndustryFllowListTypeMapByMobile(user.Mobile) // 关注的对应状态
- //合并产业关联的标的
- listSubjcet, err := models.GetThemeHeatSubjectList("")
- if err != nil {
- return
- }
- industrialIdArr := make([]int, 0)
- for k, v := range list {
- list[k].Source = 1
- if fllowMap[v.IndustrialManagementId] > 0 {
- list[k].IsFollow = 1
- }
- list[k].FollowType = followTypeMap[v.IndustrialManagementId]
- industrialIdArr = append(industrialIdArr, v.IndustrialManagementId)
- if _, ok := mapindustrialId[v.IndustrialManagementId]; !ok {
- continue
- }
- videoSimple, au, e := GetindustryVideo(user, v.IndustrialManagementId)
- if e != nil {
- err = errors.New("获取产业关联的视频失败,GetindustryVideo " + e.Error())
- return
- }
- if videoSimple != nil && videoSimple.Id > 0 {
- v.IndustryVideo = videoSimple
- }
- v.AuthInfo = au
- }
- if len(industrialIdArr) > 0 {
- //合并产业关联的标的
- listSubjcet, err = models.GetIndustrialSubjectAllByIndustrialId(industrialIdArr)
- if err != nil {
- return
- }
- mapIndustrial := make(map[string]int)
- for _, v := range listSubjcet {
- for k2, v2 := range list {
- if v2.IndustrialManagementId == v.IndustrialManagementId && mapIndustrial[fmt.Sprint(v2.IndustrialManagementId, "Hz", v.SubjectName)] == 0 {
- list[k2].IndustrialSubjectList = append(list[k2].IndustrialSubjectList, v)
- mapIndustrial[fmt.Sprint(v2.IndustrialManagementId, "Hz", v.SubjectName)] = v2.IndustrialManagementId
- }
- }
- }
- }
- mapUPdateTime := make(map[int]string)
- articleIdArr := make([]int, 0)
- //获取这些产业下最新更新的文章
- listUpdateTime, err := models.GetNewArticleDetailByIndustrialIds(industrialIdArr)
- if err != nil && err.Error() != utils.ErrNoRow() {
- return
- }
- for _, v := range listUpdateTime {
- mapUPdateTime[v.IndustrialManagementId] = v.PublishDate
- articleIdArr = append(articleIdArr, v.ArticleId)
- }
- //时间线的更新时间
- // maptimelineUPdateTime := make(map[int]string)
- listtimelinePublishdate, err := models.GetTimeLineReportIndustrialPublishdateList(industrialIdArr)
- if err != nil && err.Error() != utils.ErrNoRow() {
- return
- }
- for _, v := range listtimelinePublishdate {
- if mapUPdateTime[v.IndustrialManagementId] != "" {
- if utils.StrTimeToTime(v.PublishDate).After(utils.StrTimeToTime(mapUPdateTime[v.IndustrialManagementId])) {
- mapUPdateTime[v.IndustrialManagementId] = v.PublishDate
- }
- }
- }
- //产品内测的更新时间线
- listtProductInterior, err := models.GetNewProductInteriorByIndustrialIds(industrialIdArr)
- if err != nil && err.Error() != utils.ErrNoRow() {
- return
- }
- for _, v := range listtProductInterior {
- if mapUPdateTime[v.IndustrialManagementId] != "" {
- if utils.StrTimeToTime(v.PublishDate).After(utils.StrTimeToTime(mapUPdateTime[v.IndustrialManagementId])) {
- mapUPdateTime[v.IndustrialManagementId] = v.PublishDate
- }
- }
- }
- //mapHistroyArticleId := make(map[int]int)
- //if userId > 0 {
- // listArticleHistory, e := models.GetUserToArticleHistory(userId, articleIdArr)
- // if e != nil && e.Error() != utils.ErrNoRow() {
- // err = errors.New("获取产业关联的视频失败,GetindustryVideo " + e.Error())
- // return
- // }
- // for _, v := range listArticleHistory {
- // mapHistroyArticleId[v.ArticleId] = v.ArticleId
- // }
- //}
- var industrialIds string
- for _, id := range industrialIdArr {
- industrialIds += strconv.Itoa(id) + ","
- }
- industrialIds = strings.TrimRight(industrialIds, ",")
- articleList, err := models.GetReportIndustrialReadNumList(userId, industrialIds, user.CreatedTime)
- mapHistroyindustrialId := make(map[int]int)
- for _, v := range articleList {
- mapHistroyindustrialId[v.IndustrialManagementId] = v.Readnum
- }
- nowTime := time.Now().Local()
- threeMonBefore := nowTime.AddDate(0, -3, 0)
- //查询用户今天是否看过时间线
- //haveMorningMeeting := false
- //var morningMeetingTime string
- recrodList, err := models.GetCygxTimelineLogCount(user.UserId, industrialIdArr)
- if err != nil && err.Error() != utils.ErrNoRow() {
- return
- }
- var industrialManagementIdstr string
- industrialIdMap := make(map[string]time.Time)
- for _, v := range recrodList {
- industrialManagementIdstr = strconv.Itoa(v.IndustrialManagementId)
- industrialIdMap[industrialManagementIdstr] = v.ModifyTime
- //industrialManagementIdstr = strings.TrimLeft(v.Parameter, "PageSize=10&CurrentIndex=1&CategoryId=99999&IndustrialManagementId=")
- //if createTime, ok := industrialIdMap[industrialManagementIdstr]; ok {
- // if createTime.Before(v.CreateTime) {
- // industrialIdMap[industrialManagementIdstr] = v.CreateTime
- // }
- //} else {
- // industrialIdMap[industrialManagementIdstr] = v.CreateTime
- //}
- }
- mmList, err := models.GetCygxMorningMeetingReviewsListByIndustrialIds(industrialIds)
- if err != nil {
- return
- }
- morningMeetingTimeMap := make(map[int]time.Time)
- for _, v := range mmList {
- morningMeetingTimeMap[v.IndustryId] = v.CreateTime
- }
- timeLineRedMap := make(map[int]bool, 0)
- for _, industrialId := range industrialIdArr {
- if createTime, ok := industrialIdMap[strconv.Itoa(industrialId)]; ok {
- if createTime.Before(morningMeetingTimeMap[industrialId]) {
- timeLineRedMap[industrialId] = true
- }
- }
- }
- hotMapindustrial, err := IndustrialManagementHotMapGropuPermission()
- if err != nil {
- return
- }
- for k, v := range list {
- list[k].UpdateTime = utils.TimeRemoveHms(mapUPdateTime[v.IndustrialManagementId])
- list[k].IsHot = hotMapindustrial[v.IndustrialManagementId]
- if userId > 0 {
- //如果文章没有阅读,而且,文章的发布时间晚于项目的上线时间,而且文章的发布时间晚于用户的注册时间,就进行标红处理
- if mapHistroyindustrialId[v.IndustrialManagementId] == 0 || timeLineRedMap[v.IndustrialManagementId] {
- if user.CreatedTime.Before(utils.StrTimeToTime(mapUPdateTime[v.IndustrialManagementId])) && utils.StrTimeToTime(utils.OnlineTime).Before(utils.StrTimeToTime(mapUPdateTime[v.IndustrialManagementId])) {
- list[k].IsRed = true
- }
- }
- } else {
- if utils.StrTimeToTime(utils.OnlineTime).Before(utils.StrTimeToTime(mapUPdateTime[v.IndustrialManagementId])) {
- list[k].IsRed = true
- }
- list[k].IsFollow = 0
- }
- list[k].UpdateTime = utils.TimeRemoveHms(mapUPdateTime[v.IndustrialManagementId])
- if userId > 0 {
- //如果文章没有阅读,而且,文章的发布时间晚于项目的上线时间,而且文章的发布时间晚于用户的注册时间,就进行标红处理
- if mapHistroyindustrialId[v.IndustrialManagementId] == 0 || timeLineRedMap[v.IndustrialManagementId] {
- if user.CreatedTime.Before(utils.StrTimeToTime(mapUPdateTime[v.IndustrialManagementId])) && utils.StrTimeToTime(utils.OnlineTime).Before(utils.StrTimeToTime(mapUPdateTime[v.IndustrialManagementId])) {
- list[k].IsRed = true
- }
- }
- } else {
- if utils.StrTimeToTime(utils.OnlineTime).Before(utils.StrTimeToTime(mapUPdateTime[v.IndustrialManagementId])) {
- list[k].IsRed = true
- }
- list[k].IsFollow = 0
- }
- // 关联报告发布时间均在3个月内则标记New
- if v.MinReportTime != "" {
- t, e := time.Parse(utils.FormatDateTime, v.MinReportTime)
- if e != nil {
- err = errors.New("报告最早发布时间有误,GetindustryVideo " + e.Error())
- return
- }
- if t.After(threeMonBefore) {
- list[k].IsNew = true
- }
- }
- }
- items = list
- return
- }
- // HandleIndustryList预处理产业列表字段
- func HandleIndustryListResource(list []*models.IndustrialManagement, user *models.WxUserItem, resource string) (items []*models.IndustrialManagement, err error) {
- userId := user.UserId
- fllowList, err := models.GetUserFllowIndustrialList(userId)
- if err != nil {
- return
- }
- fllowMap := make(map[int]int)
- if len(fllowList) > 0 {
- for _, v := range fllowList {
- fllowMap[v.IndustrialManagementId] = v.IndustrialManagementId
- }
- }
- hotMap, e := IndustrialManagementHotMapGropuPermission()
- if e != nil {
- err = errors.New("获取hot标签失败,IndustrialManagementHotMapGropuPermission " + e.Error())
- return
- }
- var condition string
- var pars []interface{}
- articleTypeIds, _ := GetYanXuanArticleTypeIds()
- //给默认值
- if resource != "Yx" {
- resource = "Hz"
- }
- if articleTypeIds != "" {
- if resource == "Yx" {
- condition = ` AND a.publish_status = 1 AND a.article_type_id IN (` + articleTypeIds + `) `
- } else {
- condition = ` AND a.article_type_id NOT IN (` + articleTypeIds + `) `
- }
- }
- mapindustrialId, e := GetMicroRoadshowVideoMap()
- if e != nil {
- err = e
- return
- }
- //合并产业关联的标的
- listSubjcet, err := models.GetThemeHeatSubjectList("")
- if err != nil {
- return
- }
- industrialIdArr := make([]int, 0)
- for k, v := range list {
- list[k].Source = 1
- if fllowMap[v.IndustrialManagementId] > 0 {
- list[k].IsFollow = 1
- }
- v.IsHot = hotMap[v.IndustrialManagementId]
- industrialIdArr = append(industrialIdArr, v.IndustrialManagementId)
- if _, ok := mapindustrialId[v.IndustrialManagementId]; !ok {
- continue
- }
- videoSimple, au, e := GetindustryVideo(user, v.IndustrialManagementId)
- if e != nil {
- err = errors.New("获取产业关联的视频失败,GetindustryVideo " + e.Error())
- return
- }
- if videoSimple != nil && videoSimple.Id > 0 {
- v.IndustryVideo = videoSimple
- }
- v.AuthInfo = au
- }
- if len(industrialIdArr) > 0 {
- //合并产业关联的标的
- conditionSubject := condition + ` AND m.industrial_management_id IN (` + utils.GetOrmInReplace(len(industrialIdArr)) + `)`
- pars = append(pars, industrialIdArr)
- listSubjcet, err = models.GetIndustrialSubjectAllByIndustrialIdcondition(pars, conditionSubject)
- if err != nil {
- return
- }
- mapIndustrial := make(map[string]int)
- for _, v := range listSubjcet {
- for k2, v2 := range list {
- if v2.IndustrialManagementId == v.IndustrialManagementId && mapIndustrial[fmt.Sprint(v2.IndustrialManagementId, "Hz", v.SubjectName)] == 0 {
- list[k2].IndustrialSubjectList = append(list[k2].IndustrialSubjectList, v)
- mapIndustrial[fmt.Sprint(v2.IndustrialManagementId, "Hz", v.SubjectName)] = v2.IndustrialManagementId
- }
- }
- }
- }
- //获取产业关联的的文章用户是否阅读
- mapIndustrialArticleHistory, err := GetUserArticleHistoryIndustrialNewPublishDate(user, industrialIdArr, articleTypeIds, resource)
- if err != nil {
- err = errors.New("获取产业关联的的文章用户是否阅读失败 " + err.Error())
- return
- }
- mapUPdateTime := make(map[int]string)
- articleIdArr := make([]int, 0)
- //获取这些产业下最新更新的文章
- var conditionindustrial string
- var parsindustrial []interface{}
- var industrialIds string
- if len(industrialIdArr) > 0 {
- conditionindustrial = condition + ` AND mg.industrial_management_id IN (` + utils.GetOrmInReplace(len(industrialIdArr)) + `)`
- parsindustrial = append(parsindustrial, industrialIdArr)
- listUpdateTime, e := models.GetNewArticleDetailByIndustrialIdscondition(parsindustrial, conditionindustrial)
- if e != nil && e.Error() != utils.ErrNoRow() {
- err = errors.New("GetNewArticleDetailByIndustrialIds Err " + e.Error())
- return
- }
- for _, v := range listUpdateTime {
- mapUPdateTime[v.IndustrialManagementId] = v.PublishDate
- articleIdArr = append(articleIdArr, v.ArticleId)
- }
- //时间线的更新时间
- // maptimelineUPdateTime := make(map[int]string)
- listtimelinePublishdate, e := models.GetTimeLineReportIndustrialPublishdateList(industrialIdArr)
- if e != nil && e.Error() != utils.ErrNoRow() {
- err = e
- return
- }
- for _, v := range listtimelinePublishdate {
- if mapUPdateTime[v.IndustrialManagementId] != "" {
- if utils.StrTimeToTime(v.PublishDate).After(utils.StrTimeToTime(mapUPdateTime[v.IndustrialManagementId])) {
- mapUPdateTime[v.IndustrialManagementId] = v.PublishDate
- }
- }
- }
- //产品内测的更新时间线
- listtProductInterior, e := models.GetNewProductInteriorByIndustrialIds(industrialIdArr)
- if e != nil && e.Error() != utils.ErrNoRow() {
- err = e
- return
- }
- for _, v := range listtProductInterior {
- if mapUPdateTime[v.IndustrialManagementId] != "" {
- if utils.StrTimeToTime(v.PublishDate).After(utils.StrTimeToTime(mapUPdateTime[v.IndustrialManagementId])) {
- mapUPdateTime[v.IndustrialManagementId] = v.PublishDate
- }
- }
- }
- for _, id := range industrialIdArr {
- industrialIds += strconv.Itoa(id) + ","
- }
- industrialIds = strings.TrimRight(industrialIds, ",")
- articleList, e := models.GetReportIndustrialReadNumList(userId, industrialIds, user.CreatedTime)
- if e != nil && e.Error() != utils.ErrNoRow() {
- err = e
- return
- }
- mapHistroyindustrialId := make(map[int]int)
- for _, v := range articleList {
- mapHistroyindustrialId[v.IndustrialManagementId] = v.Readnum
- }
- }
- nowTime := time.Now().Local()
- threeMonBefore := nowTime.AddDate(0, -3, 0)
- //查询用户今天是否看过时间线
- //haveMorningMeeting := false
- //var morningMeetingTime string
- recrodList, err := models.GetCygxTimelineLogCount(user.UserId, industrialIdArr)
- if err != nil && err.Error() != utils.ErrNoRow() {
- return
- }
- var industrialManagementIdstr string
- industrialIdMap := make(map[string]time.Time)
- for _, v := range recrodList {
- //fmt.Println(v.Router)
- //sliceindustrial := strings.Split(v.Router, "=")
- //industrialManagementIdstr = strings.TrimLeft(v.Router, utils.TIME_LINE_ROUTE)
- industrialManagementIdstr = strconv.Itoa(v.IndustrialManagementId)
- industrialIdMap[industrialManagementIdstr] = v.ModifyTime
- //fmt.Println(industrialManagementIdstr)
- //if createTime, ok := industrialIdMap[industrialManagementIdstr]; ok {
- // if createTime.Before(v.CreateTime) {
- // industrialIdMap[industrialManagementIdstr] = v.CreateTime
- // }
- //} else {
- // industrialIdMap[industrialManagementIdstr] = v.CreateTime
- //}
- }
- morningMeetingTimeMap := make(map[int]time.Time)
- if industrialIds != "" {
- mmList, e := models.GetCygxMorningMeetingReviewsListByIndustrialIds(industrialIds)
- if e != nil {
- err = e
- return
- }
- for _, v := range mmList {
- morningMeetingTimeMap[v.IndustryId] = v.CreateTime
- }
- }
- timeLineRedMap := make(map[int]bool, 0)
- for _, industrialId := range industrialIdArr {
- //if createTime, ok := industrialIdMap[strconv.Itoa(industrialId)]; ok {
- // if createTime.Before(morningMeetingTimeMap[industrialId]) {
- // timeLineRedMap[industrialId] = true
- // }
- //}
- if industrialIdMap[strconv.Itoa(industrialId)].Before(morningMeetingTimeMap[industrialId]) {
- timeLineRedMap[industrialId] = true
- }
- }
- //fmt.Println(industrialIdMap["90"])
- //fmt.Println(timeLineRedMap[90])
- //fmt.Println(mapIndustrialArticleHistory[90])
- for k, v := range list {
- list[k].UpdateTime = utils.TimeRemoveHms(mapUPdateTime[v.IndustrialManagementId])
- if userId > 0 {
- //如果文章没有阅读,而且,文章的发布时间晚于项目的上线时间,而且文章的发布时间晚于用户的注册时间,就进行标红处理
- if mapIndustrialArticleHistory[v.IndustrialManagementId] || timeLineRedMap[v.IndustrialManagementId] {
- //if mapHistroyindustrialId[v.IndustrialManagementId] == 0 || timeLineRedMap[v.IndustrialManagementId] {
- if user.CreatedTime.Before(utils.StrTimeToTime(mapUPdateTime[v.IndustrialManagementId])) && utils.StrTimeToTime(utils.OnlineTime).Before(utils.StrTimeToTime(mapUPdateTime[v.IndustrialManagementId])) {
- list[k].IsRed = true
- }
- }
- } else {
- if utils.StrTimeToTime(utils.OnlineTime).Before(utils.StrTimeToTime(mapUPdateTime[v.IndustrialManagementId])) {
- list[k].IsRed = true
- }
- list[k].IsFollow = 1
- }
- list[k].UpdateTime = utils.TimeRemoveHms(mapUPdateTime[v.IndustrialManagementId])
- if resource == "Yx" {
- list[k].IsRed = false
- }
- // 关联报告发布时间均在3个月内则标记New
- if v.MinReportTime != "" {
- t, e := time.Parse(utils.FormatDateTime, v.MinReportTime)
- if e != nil {
- err = errors.New("报告最早发布时间有误,GetindustryVideo " + e.Error())
- return
- }
- if t.After(threeMonBefore) {
- list[k].IsNew = true
- }
- }
- if v.ChartPermissionId == utils.CHART_PERMISSION_ID_YANXUAN {
- v.Source = 2
- } else {
- v.Source = 1
- }
- if v.TimeLineData == "" {
- v.ListTimeLine = make([]models.TimeLineReportResp, 0)
- } else {
- if err = json.Unmarshal([]byte(v.TimeLineData), &v.ListTimeLine); err != nil {
- e = errors.New("Unmarshal, Err: " + e.Error())
- return
- }
- }
- }
- items = list
- return
- }
- func HandleIndustryListHzAndYx(list []*models.IndustrialManagement, user *models.WxUserItem, resource string) (items []*models.IndustrialManagement, err error) {
- var listHz []*models.IndustrialManagement
- var lisYx []*models.IndustrialManagement
- for _, v := range list {
- if v.ChartPermissionId == utils.CHART_PERMISSION_ID_YANXUAN {
- lisYx = append(lisYx, v)
- } else {
- listHz = append(listHz, v)
- }
- }
- listHz, err = HandleIndustryListResource(listHz, user, "Hz")
- if err != nil {
- return
- }
- lisYx, err = HandleIndustryListResource(lisYx, user, "Yx")
- if err != nil {
- return
- }
- maplistHz := make(map[int]*models.IndustrialManagement)
- maplistYx := make(map[int]*models.IndustrialManagement)
- for _, v := range listHz {
- maplistHz[v.IndustrialManagementId] = v
- }
- for _, v := range lisYx {
- maplistYx[v.IndustrialManagementId] = v
- }
- for _, v := range list {
- if maplistHz[v.IndustrialManagementId] != nil {
- items = append(items, maplistHz[v.IndustrialManagementId])
- }
- if maplistYx[v.IndustrialManagementId] != nil {
- items = append(items, maplistYx[v.IndustrialManagementId])
- }
- }
- return
- }
- // 通过文章ID获取文章所关联的产业
- func GetArticleIndustrialByArticleId(articleIds []int) (itemMap map[int][]*models.IndustrialManagementResp, err error) {
- lenarticleIds := len(articleIds)
- if lenarticleIds == 0 {
- return
- }
- var condition string
- var pars []interface{}
- condition = ` AND mg.article_id IN (` + utils.GetOrmInReplace(lenarticleIds) + `)`
- pars = append(pars, articleIds)
- industrialList, err := models.GetIndustrialListByarticleId(pars, condition)
- if err != nil {
- return
- }
- industrialMap := make(map[int][]*models.IndustrialManagementResp)
- if len(industrialList) > 0 {
- for _, v := range industrialList {
- item := new(models.IndustrialManagementResp)
- item.IndustrialManagementId = v.IndustrialManagementId
- item.IndustryName = v.IndustryName
- item.ChartPermissionId = v.ChartPermissionId
- industrialMap[v.ArticleId] = append(industrialMap[v.ArticleId], item)
- }
- }
- itemMap = industrialMap
- return
- }
- func GetArticleTypeMap() (nameMapResp map[int]string, buttonStyleMapResp map[int]string, err error) {
- condition := " AND is_show_yanx = 1 "
- list, e := models.GetCygxArticleTypeListCondition(condition)
- if e != nil {
- err = errors.New("报告最早发布时间有误,GetindustryVideo " + e.Error())
- return
- }
- nameMap := make(map[int]string)
- buttonStyleMap := make(map[int]string)
- if len(list) > 0 {
- for _, v := range list {
- nameMap[v.ArticleTypeId] = v.ArticleTypeName
- buttonStyleMap[v.ArticleTypeId] = v.ButtonStyle
- }
- }
- nameMapResp = nameMap
- buttonStyleMapResp = buttonStyleMap
- return
- }
- // IndustrialManagementHotMapGropuPermission获取近一个月报告阅读数量最多的产业信息 根据行业分组
- func IndustrialManagementHotMapGropuPermission() (mapResp map[int]bool, err error) {
- var topCond string
- var topPars []interface{}
- toplist, err := models.GetTopOneMonthArtReadNumIndustryAll(topCond, topPars)
- if err != nil {
- return
- }
- mapPermission := make(map[int][]*models.IndustrialManagement)
- mapPermissionMax := make(map[int]int)
- for _, v := range toplist {
- item := new(models.IndustrialManagement)
- item.ChartPermissionId = v.ChartPermissionId
- item.IndustrialManagementId = v.IndustrialManagementId
- item.ArticleReadNum = v.ArticleReadNum
- mapPermission[v.ChartPermissionId] = append(mapPermission[v.ChartPermissionId], item)
- }
- for k, v := range mapPermission {
- for _, item := range v {
- //mapPermissionMax[k] = item.ArticleReadNum
- if item.ArticleReadNum > mapPermissionMax[k] {
- mapPermissionMax[k] = item.ArticleReadNum
- }
- }
- }
- mapResp = make(map[int]bool, 0)
- for _, v := range toplist {
- if v.ArticleReadNum == mapPermissionMax[v.ChartPermissionId] {
- mapResp[v.IndustrialManagementId] = true
- }
- }
- return
- }
- // GetLyjhTypeMap 获取路演精华对应分类ID
- func GetLyjhTypeMap() (mapResp map[int]int, err error) {
- defer func() {
- if err != nil {
- go utils.SendAlarmMsg("获取路演精华对应分类ID失败 ErrMsg:"+err.Error(), 2)
- }
- }()
- condition := " AND match_type_name = '路演精华' "
- var pars []interface{}
- list, e := models.GetReportMappingList(condition, pars)
- if e != nil && e.Error() != utils.ErrNoRow() {
- err = errors.New("报告最早发布时间有误,GetindustryVideo " + e.Error())
- return
- }
- mapResp = make(map[int]int, 0)
- if len(list) > 0 {
- for _, v := range list {
- mapResp[v.CategoryId] = v.CategoryId
- }
- }
- return
- }
- // GetLyjhArticleMap 获取路演精华对应文章ID
- func GetLyjhArticleMap() (mapResp map[int]bool, err error) {
- defer func() {
- if err != nil {
- go utils.SendAlarmMsg("获取路演精华对应文章ID失败 ErrMsg:"+err.Error(), 2)
- }
- }()
- condition := " AND match_type_name = '路演精华' "
- var pars []interface{}
- list, e := models.GetReportMappingList(condition, pars)
- if e != nil && e.Error() != utils.ErrNoRow() {
- err = errors.New("报告最早发布时间有误,GetindustryVideo " + e.Error())
- return
- }
- var categoryId []int
- mapResp = make(map[int]bool, 0)
- if len(list) > 0 {
- for _, v := range list {
- categoryId = append(categoryId, v.CategoryId)
- }
- }
- lencategoryId := len(categoryId)
- if lencategoryId > 0 {
- pars = make([]interface{}, 0)
- condition = ` AND a.category_id IN (` + utils.GetOrmInReplace(lencategoryId) + `)`
- pars = append(pars, categoryId)
- listArticle, e := models.GetHomeList(condition, pars, 0, 1000)
- if e != nil && e.Error() != utils.ErrNoRow() {
- err = errors.New("GetResourceDataList, Err: " + e.Error())
- return
- }
- for _, v := range listArticle {
- mapResp[v.ArticleId] = true
- }
- }
- return
- }
- // 获取所有的产业id与名称的map关联
- func GetIndustrialManagementRespMap() (itemMap map[int]string, err error) {
- defer func() {
- if err != nil {
- go utils.SendAlarmMsg("GetIndustrialManagementRespMap ErrMsg:"+err.Error(), 2)
- }
- }()
- var condition string
- var pars []interface{}
- itemMap = make(map[int]string, 0)
- industrialList, e := models.GetIndustrialManagementRepList(condition, pars, 0, 999999)
- if e != nil {
- err = errors.New("GetIndustrialManagementRepList, Err: " + e.Error())
- return
- }
- if len(industrialList) > 0 {
- for _, v := range industrialList {
- itemMap[v.IndustrialManagementId] = v.IndustryName
- }
- }
- return
- }
- // 获取所有的标的id与名称的map关联
- func GetCygxIndustrialSubjectMap() (itemMap map[int]string, err error) {
- defer func() {
- if err != nil {
- go utils.SendAlarmMsg("GetCygxIndustrialSubjectMap ErrMsg:"+err.Error(), 2)
- }
- }()
- var condition string
- var pars []interface{}
- itemMap = make(map[int]string, 0)
- list, e := models.GetCygxIndustrialSubjectListCondition(condition, pars)
- if e != nil {
- err = errors.New("GetIndustrialManagementRepList, Err: " + e.Error())
- return
- }
- if len(list) > 0 {
- for _, v := range list {
- itemMap[v.IndustrialSubjectId] = v.SubjectName
- }
- }
- return
- }
- //func init() {
- // UpdateIndustrialManagementOneMonthFollowNum()
- //}
- // UpdateIndustrialManagementOneMonthFollowNum 更新产业近一个月被关注的数量
- func UpdateIndustrialManagementOneMonthFollowNum(cont context.Context) (err error) {
- //var err error
- defer func() {
- if err != nil {
- fmt.Println(err)
- go utils.SendAlarmMsg("UpdateIndustrialManagementOneMonthFollowNum ErrMsg:"+err.Error(), 2)
- }
- }()
- listNum, e := models.GetIndustrialManagementOneMonthFollowNum()
- if e != nil {
- err = errors.New("GetIndustrialManagementOneMonthFollowNum, Err: " + e.Error())
- return
- }
- e = models.UpdateIndustrialManagementInit() //初始化每月产业用户关注数量
- if e != nil {
- err = errors.New("UpdateIndustrialManagementInit, Err: " + e.Error())
- return
- }
- var items []*models.CygxIndustryFllowNumResp
- for _, v := range listNum {
- item := new(models.CygxIndustryFllowNumResp)
- item.IndustrialManagementId = v.IndustrialManagementId
- item.Total = v.Total
- items = append(items, item)
- //一次最多插入五百条
- if len(items)%500 == 0 {
- e = models.UpdateIndustrialManagementOneMonthFollowNumMulti(items)
- if e != nil {
- err = errors.New("UpdateIndustrialManagementOneMonthFollowNumMulti, Err: " + e.Error())
- return
- }
- }
- }
- if len(items) > 0 {
- e = models.UpdateIndustrialManagementOneMonthFollowNumMulti(items)
- if e != nil {
- err = errors.New("UpdateIndustrialManagementOneMonthFollowNumMulti, Err: " + e.Error())
- return
- }
- }
- return
- }
- // GetCygxIndustryFllowListTypeMapByMobile 根据手机号获取产业关注的信息
- func GetCygxIndustryFllowListTypeMapByMobile(mobile string) (mapFollowTypeResp map[int]int) {
- if mobile == "" {
- return
- }
- var err error
- defer func() {
- if err != nil {
- fmt.Println("err:", err)
- go utils.SendAlarmMsg(fmt.Sprint("根据手机号获取产业关注的信息 失败,GetCygxIndustryFllowListTypeMapByMobile Err:"+err.Error()+"mobile", mobile), 3)
- }
- }()
- mapFollowTypeResp = make(map[int]int, 0)
- fllowList, e := models.GetCygxIndustryFllowListByMobile(mobile)
- //策略的处理
- if e != nil {
- err = errors.New("GetUserFllowIndustrialList, Err: " + e.Error())
- return
- }
- for _, v := range fllowList {
- mapFollowTypeResp[v.IndustrialManagementId] = v.FollowType
- }
- return
- }
- //func init_14-2() {
- // //IndustrialManagementTimeLineDateList3(127)
- //
- // list, err := models.IndustrialManagementAll()
- // if err != nil {
- // fmt.Println("Error marshaling to JSON:", err)
- // return
- // }
- // fmt.Println(len(list))
- // for k, v := range list {
- // fmt.Println(k)
- // time.Sleep(200 * time.Millisecond)
- // if v.ChartPermissionId == utils.CHART_PERMISSION_ID_YANXUAN {
- // continue
- // }
- // IndustrialManagementTimeLineDateList3(v.IndustrialManagementId)
- // }
- //}
- // 时间线关联文章的三条数据
- func IndustrialManagementTimeLineDateList3(industrialManagementId int) (err error) {
- defer func() {
- if err != nil {
- fmt.Println(err)
- go utils.SendAlarmMsg("修改时间线关联文章的三条数据信息失败"+err.Error(), 2)
- }
- }()
- list, e := models.GetTimeLineReportIndustrialList(0, industrialManagementId, 0, 3)
- if e != nil {
- err = errors.New("GetCompanySellerAndShareMobileByRai, Err: " + e.Error())
- return
- }
- type TimeLineReportItem struct {
- Title string `description:"标题"`
- PublishDate string `description:"发布时间"`
- }
- var listData []*TimeLineReportItem
- for _, v := range list {
- item := new(TimeLineReportItem)
- if v.Resource == 3 {
- item.Title, _ = extractTextBeforePeriodOrNewline(v.Content)
- fmt.Println("Title", item.Title)
- } else {
- item.Title = v.Title
- }
- item.PublishDate = utils.TimeRemoveHms2(v.PublishTime)
- listData = append(listData, item)
- }
- jsonData, err := json.Marshal(listData)
- if err != nil {
- fmt.Println("Error marshaling to JSON:", err)
- return
- }
- err = models.UpdateIndustrialManagementTimeLineData(industrialManagementId, string(jsonData))
- return err
- }
- func extractTextBeforePeriodOrNewline(htmlContent string) (string, error) {
- var builder strings.Builder
- reader := strings.NewReader(htmlContent)
- z := html.NewTokenizer(reader)
- for {
- tokenType := z.Next()
- switch tokenType {
- case html.ErrorToken:
- // End of document
- return builder.String(), nil
- case html.TextToken:
- text := string(z.Text())
- //fmt.Println("text", text)
- if idx := strings.Index(text, "。"); idx != -1 {
- builder.WriteString(text[:idx+len("。")])
- return builder.String(), nil
- } else {
- return text, nil
- }
- builder.WriteString(text)
- }
- }
- }
- // 处理产业管理时间线相关内容的数据
- func UpdateIndustrialManagementTimeLineDateList3ByRedis() (err error) {
- for {
- utils.Rc.Brpop(utils.CYGX_ARTICLE_TIME_LINE_KEY, func(b []byte) {
- var log models.IndustrialManagementCount
- if err := json.Unmarshal(b, &log); err != nil {
- fmt.Println("json unmarshal wrong!")
- go utils.SendAlarmMsg("处理产业管理时间线相关内容的数据处理Redis队列消息失败: UpdateIndustrialManagementTimeLineDateList3ByRedis "+err.Error()+string(b), 2)
- }
- IndustrialManagementTimeLineDateList3(log.IndustrialManagementId)
- })
- }
- }
- //func init_14_2() {
- //SELECT * FROM cygx_resource_data WHERE source_id IN (SELECT article_id FROM cygx_article WHERE series_name IN ('行业深度','季度策略') ) AND source = 'article'
- //}
|