123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560 |
- package cygx
- import (
- "errors"
- "fmt"
- "hongze/hz_crm_api/models/cygx"
- "hongze/hz_crm_api/services/alarm_msg"
- "hongze/hz_crm_api/utils"
- "strconv"
- "time"
- )
- //首页最新页面数据逻辑处理
- //activity
- //activityspecial
- //activityvideo
- //activityvoice
- //article
- //meetingreviewchapt
- //minutessummary
- //newchart
- //productinterior
- //reportselection
- //researchsummary
- //roadshow
- //func init() {
- // UpdateMicroRoadshowResourceData(7)
- //}
- // 更新活动
- func UpdateActivityResourceData(sourceId int) {
- var err error
- //time.Sleep(3*time.Second) // 有时候同时添加多个活动,延迟三秒
- defer func() {
- if err != nil {
- fmt.Println("err:", err)
- go alarm_msg.SendAlarmMsg("更新活动 失败,UpdateActivityResourceData Err:"+err.Error()+"资源ID"+strconv.Itoa(sourceId), 3)
- }
- }()
- var source = utils.CYGX_OBJ_ACTIVITY
- var condition string
- var pars []interface{}
- condition = ` AND publish_status = 1 AND activity_id = ? `
- pars = append(pars, sourceId)
- total, e := cygx.GetActivityCount(condition, pars)
- if e != nil {
- err = errors.New("GetCygxReportSelection, Err: " + e.Error())
- return
- }
- //如果取消发布了就做删除处理
- if total == 0 {
- e = cygx.DeleteResourceData(sourceId, source)
- if e != nil {
- err = errors.New("DeleteResourceData, Err: " + e.Error())
- return
- }
- //删除 cygx_resource_data 表关联的产业ID,标的ID
- e = cygx.DeleteCygxResourceDataGroup(sourceId, source)
- if e != nil {
- err = errors.New("DeleteCygxResourceDataGroup, Err: " + e.Error())
- return
- }
- } else {
- //判断是否存在,如果不存在就新增,存在就更新
- totalData, e := cygx.GetCygxReportSelectionBySourceAndId(sourceId, source)
- if e != nil {
- err = errors.New("GetCygxReportSelectionBySourceAndId, Err: " + e.Error())
- return
- }
- detail, e := cygx.GetAddActivityInfoById(sourceId)
- if e != nil {
- err = errors.New("GetCygxReportSelectionInfoById, Err: " + e.Error())
- return
- }
- var resourceDataId int
- publishDate := detail.CreateTime // 活动创建时间作为排序时间
- item := new(cygx.CygxResourceData)
- var industrialName string
- var subjectName string
- //建立首页资源表,与产业的关系
- industrialList, e := cygx.GetIndustrialActivityGroupManagementList(sourceId, 1)
- if e != nil && e.Error() != utils.ErrNoRow() {
- err = errors.New("GetIndustrialActivityGroupManagementList, Err: " + e.Error() + "activityId:" + strconv.Itoa(sourceId))
- return
- }
- for _, v := range industrialList {
- industrialName += v.IndustryName
- }
- //建立首页资源表,与标的 的关系
- subjectList, e := cygx.GetSubjectActivityGroupManagementList(sourceId, 1)
- if e != nil && e.Error() != utils.ErrNoRow() {
- err = errors.New("GetIndustrialActivityGroupManagementList, Err: " + e.Error() + "activityId:" + strconv.Itoa(sourceId))
- return
- }
- for _, v := range subjectList {
- subjectName += v.SubjectName
- }
- item.SourceId = sourceId
- item.Source = source
- //分析师电话会(C类)
- item.SearchTag = detail.ActivityTypeName
- item.ChartPermissionId = detail.ChartPermissionId
- item.PublishDate = publishDate
- item.SearchTitle = detail.ActivityName
- item.SearchContent = detail.Label + industrialName + subjectName
- item.SearchOrderTime = detail.ActivityTime
- item.CreateTime = time.Now()
- if totalData == 0 {
- newId, e := cygx.AddCygxResourceData(item)
- if e != nil {
- err = errors.New("AddCygxResourceData, Err: " + e.Error())
- return
- }
- resourceDataId = int(newId)
- } else {
- e = cygx.UpdateResourceDataByItem(item)
- if e != nil {
- err = errors.New("UpdateResourceData, Err: " + e.Error())
- return
- }
- sourceDetail, e := cygx.GetCygxResourceDataByIdAndSource(sourceId, source)
- if e != nil {
- err = errors.New("UpdateResourceData, Err: " + e.Error())
- return
- }
- resourceDataId = sourceDetail.Id
- }
- var industrialItems []*cygx.CygxResourceDataIndustrialGroupManagement
- for _, v := range industrialList {
- var industrialItem = new(cygx.CygxResourceDataIndustrialGroupManagement)
- industrialItem.SourceId = sourceId
- industrialItem.Source = source
- industrialItem.IndustrialManagementId = v.IndustrialManagementId
- industrialItem.ResourceDataId = resourceDataId
- industrialItem.CreateTime = time.Now()
- industrialItems = append(industrialItems, industrialItem)
- }
- //建立首页资源表,与标的 的关系
- var subjectItems []*cygx.CygxResourceDataIndustrialGroupSubject
- for _, v := range subjectList {
- var subjectItem = new(cygx.CygxResourceDataIndustrialGroupSubject)
- subjectItem.SourceId = sourceId
- subjectItem.Source = source
- subjectItem.IndustrialSubjectId = v.IndustrialSubjectId
- subjectItem.ResourceDataId = resourceDataId
- subjectItem.CreateTime = time.Now()
- subjectItems = append(subjectItems, subjectItem)
- }
- //插入关联信息
- e = cygx.AddCygxResourceDataGroup(sourceId, source, industrialItems, subjectItems)
- if e != nil {
- err = errors.New("AddCygxResourceDataGroup, Err: " + e.Error())
- return
- }
- }
- return
- }
- // 更新专项调研活动
- func UpdateActivitySpecialResourceData(sourceId int) {
- var err error
- defer func() {
- if err != nil {
- fmt.Println("err:", err)
- go alarm_msg.SendAlarmMsg("更新活动 失败,UpdateActivitySpecialResourceData Err:"+err.Error()+"资源ID"+strconv.Itoa(sourceId), 3)
- }
- }()
- var source = utils.CYGX_OBJ_ACTIVITYSPECIAL
- var condition string
- var pars []interface{}
- condition = ` AND publish_status = 1 AND activity_id = ? `
- pars = append(pars, sourceId)
- total, e := cygx.GetActivityCount(condition, pars)
- if e != nil {
- err = errors.New("GetCygxReportSelection, Err: " + e.Error())
- return
- }
- activityInfo, e := cygx.GetAddActivityInfoSpecialById(sourceId)
- if e != nil {
- err = errors.New("GetAddActivityInfoSpecialById, Err: " + e.Error())
- return
- }
- //如果取消发布了就做删除处理
- if total == 0 {
- e = cygx.DeleteResourceData(sourceId, source)
- if e != nil {
- err = errors.New("DeleteResourceData, Err: " + e.Error())
- return
- }
- //删除 cygx_resource_data 表关联的产业ID,标的ID
- e = cygx.DeleteCygxResourceDataGroup(sourceId, source)
- if e != nil {
- err = errors.New("DeleteCygxResourceDataGroup, Err: " + e.Error())
- return
- }
- } else {
- //判断是否存在,如果不存在就新增,存在就更新
- totalData, e := cygx.GetCygxReportSelectionBySourceAndId(sourceId, source)
- if e != nil {
- err = errors.New("GetCygxReportSelectionBySourceAndId, Err: " + e.Error())
- return
- }
- var resourceDataId int
- publishDate := activityInfo.PublishDate
- item := new(cygx.CygxResourceData)
- item.SourceId = sourceId
- item.Source = source
- //分析师电话会(C类)
- item.SearchTag = ""
- item.PublishDate = publishDate
- item.ChartPermissionId = activityInfo.ChartPermissionId
- item.CreateTime = time.Now()
- item.SearchTitle = activityInfo.ResearchTheme
- item.SearchContent = activityInfo.Label + activityInfo.IndustrialName + activityInfo.IndustrialSubjectName
- if activityInfo.Days > 0 {
- item.SearchOrderTime = activityInfo.ActivityTime
- } else {
- item.SearchOrderTime = activityInfo.PublishDate
- }
- if totalData == 0 {
- newId, e := cygx.AddCygxResourceData(item)
- if e != nil {
- err = errors.New("AddCygxResourceData, Err: " + e.Error())
- return
- }
- resourceDataId = int(newId)
- } else {
- e = cygx.UpdateResourceDataByItem(item)
- if e != nil {
- err = errors.New("UpdateResourceData, Err: " + e.Error())
- return
- }
- sourceDetail, e := cygx.GetCygxResourceDataByIdAndSource(sourceId, source)
- if e != nil {
- err = errors.New("UpdateResourceData, Err: " + e.Error())
- return
- }
- resourceDataId = sourceDetail.Id
- }
- //建立首页资源表,与产业的关系
- industrialList, e := cygx.GetIndustrialActivityGroupManagementList(sourceId, 2)
- if e != nil && e.Error() != utils.ErrNoRow() {
- err = errors.New("GetIndustrialActivityGroupManagementList, Err: " + e.Error() + "activityId:" + strconv.Itoa(sourceId))
- return
- }
- var industrialItems []*cygx.CygxResourceDataIndustrialGroupManagement
- for _, v := range industrialList {
- var industrialItem = new(cygx.CygxResourceDataIndustrialGroupManagement)
- industrialItem.SourceId = sourceId
- industrialItem.Source = source
- industrialItem.IndustrialManagementId = v.IndustrialManagementId
- industrialItem.ResourceDataId = resourceDataId
- industrialItem.CreateTime = time.Now()
- industrialItems = append(industrialItems, industrialItem)
- }
- //建立首页资源表,与标的 的关系
- subjectList, e := cygx.GetSubjectArticleGroupManagementList(sourceId)
- if e != nil && e.Error() != utils.ErrNoRow() {
- err = errors.New("GetSubjectArticleGroupManagementList, Err: " + e.Error() + "sourceId:" + strconv.Itoa(sourceId))
- return
- }
- var subjectItems []*cygx.CygxResourceDataIndustrialGroupSubject
- for _, v := range subjectList {
- var subjectItem = new(cygx.CygxResourceDataIndustrialGroupSubject)
- subjectItem.SourceId = sourceId
- subjectItem.Source = source
- subjectItem.IndustrialSubjectId = v.IndustrialSubjectId
- subjectItem.ResourceDataId = resourceDataId
- subjectItem.CreateTime = time.Now()
- subjectItems = append(subjectItems, subjectItem)
- }
- //插入关联信息
- e = cygx.AddCygxResourceDataGroup(sourceId, source, industrialItems, subjectItems)
- if e != nil {
- err = errors.New("AddCygxResourceDataGroup, Err: " + e.Error())
- return
- }
- }
- return
- }
- // 更新文章
- func UpdateArticleResourceData(sourceId int) {
- var err error
- defer func() {
- if err != nil {
- fmt.Println("err:", err)
- go alarm_msg.SendAlarmMsg("更新文章 失败,UpdateArticleResourceData Err:"+err.Error()+"资源ID"+strconv.Itoa(sourceId), 3)
- }
- }()
- var source = utils.CYGX_OBJ_ARTICLE
- var condition string
- var pars []interface{}
- condition = ` AND publish_status = 1 AND article_id = ? `
- pars = append(pars, sourceId)
- total, e := cygx.GetCygxArticleCount(condition, pars)
- if e != nil {
- err = errors.New("GetCygxReportSelection, Err: " + err.Error())
- return
- }
- //如果取消发布了就做删除处理
- if total == 0 {
- e = cygx.DeleteResourceData(sourceId, source)
- if e != nil {
- err = errors.New("DeleteResourceData, Err: " + e.Error())
- return
- }
- //删除 cygx_resource_data 表关联的产业ID,标的ID
- e = cygx.DeleteCygxResourceDataGroup(sourceId, source)
- if e != nil {
- err = errors.New("DeleteCygxResourceDataGroup, Err: " + e.Error())
- return
- }
- } else {
- //判断是否存在,如果不存在就新增,存在就更新
- totalData, e := cygx.GetCygxReportSelectionBySourceAndId(sourceId, source)
- if e != nil {
- err = errors.New("GetCygxReportSelectionBySourceAndId, Err: " + e.Error())
- return
- }
- detail, e := cygx.GetArticleDetailByArticleId(sourceId)
- if e != nil {
- err = errors.New("GetCygxReportSelectionInfoById, Err: " + e.Error())
- return
- }
- var resourceDataId int
- //publishDate := detail.CreateDate
- publishDate := time.Now().Format(utils.FormatDateTime)
- item := new(cygx.CygxResourceData)
- if detail.ArticleTypeId > 0 {
- item.SearchTag = detail.ArticleTypeName // 研选类型名称
- item.ChartPermissionId = utils.CHART_PERMISSION_ID_YANXUAN
- } else {
- item.SearchTag = detail.MatchTypeName
- //获取文章分类详情
- detailCategory, _ := cygx.GetCygxReportMappingCelueMaxDetailByCategoryId(detail.CategoryId)
- if detailCategory != nil {
- item.ChartPermissionId = detailCategory.ChartPermissionId
- }
- }
- var industrialName string
- var subjectName string
- //建立首页资源表,与产业的关系
- industrialList, e := cygx.GetIndustrialArticleGroupManagementList(sourceId)
- if e != nil && e.Error() != utils.ErrNoRow() {
- err = errors.New("GetIndustrialArticleGroupManagementList, Err: " + e.Error() + "sourceId:" + strconv.Itoa(sourceId))
- return
- }
- for _, v := range industrialList {
- industrialName += v.IndustryName
- }
- //建立首页资源表,与标的 的关系
- subjectList, e := cygx.GetSubjectArticleGroupManagementList(sourceId)
- if e != nil && e.Error() != utils.ErrNoRow() {
- err = errors.New("GetSubjectArticleGroupManagementList, Err: " + e.Error() + "sourceId:" + strconv.Itoa(sourceId))
- return
- }
- for _, v := range subjectList {
- subjectName += v.SubjectName
- }
- item.SourceId = sourceId
- item.Source = source
- item.PublishDate = publishDate
- item.CreateTime = time.Now()
- item.SearchTitle = detail.Title
- annotation, e := utils.GetHtmlContentText(detail.Annotation)
- if e != nil && e.Error() != utils.ErrNoRow() {
- err = errors.New("GetHtmlContentText, Err: " + e.Error() + "sourceId:" + strconv.Itoa(sourceId))
- return
- }
- abstract, e := utils.GetHtmlContentText(detail.Abstract)
- if e != nil && e.Error() != utils.ErrNoRow() {
- err = errors.New("GetHtmlContentText, Err: " + e.Error() + "sourceId:" + strconv.Itoa(sourceId))
- return
- }
- item.SearchContent = annotation + abstract + detail.FieldName + detail.Stock + industrialName + subjectName
- item.SearchOrderTime = detail.PublishDate
- if totalData == 0 {
- newId, e := cygx.AddCygxResourceData(item)
- if e != nil {
- err = errors.New("AddCygxResourceData, Err: " + e.Error())
- return
- }
- resourceDataId = int(newId)
- } else {
- e = cygx.UpdateResourceDataByItem(item)
- if e != nil {
- err = errors.New("UpdateResourceDataByItem, Err: " + e.Error())
- return
- }
- sourceDetail, e := cygx.GetCygxResourceDataByIdAndSource(sourceId, source)
- if e != nil {
- err = errors.New("GetCygxResourceDataByIdAndSource, Err: " + e.Error())
- return
- }
- resourceDataId = sourceDetail.Id
- }
- var industrialItems []*cygx.CygxResourceDataIndustrialGroupManagement
- for _, v := range industrialList {
- var industrialItem = new(cygx.CygxResourceDataIndustrialGroupManagement)
- industrialItem.SourceId = sourceId
- industrialItem.Source = source
- industrialItem.IndustrialManagementId = v.IndustrialManagementId
- industrialItem.ResourceDataId = resourceDataId
- industrialItem.CreateTime = time.Now()
- industrialItems = append(industrialItems, industrialItem)
- industrialName += v.IndustryName
- }
- var subjectItems []*cygx.CygxResourceDataIndustrialGroupSubject
- for _, v := range subjectList {
- var subjectItem = new(cygx.CygxResourceDataIndustrialGroupSubject)
- subjectItem.SourceId = sourceId
- subjectItem.Source = source
- subjectItem.IndustrialSubjectId = v.IndustrialSubjectId
- subjectItem.ResourceDataId = resourceDataId
- subjectItem.CreateTime = time.Now()
- subjectItems = append(subjectItems, subjectItem)
- subjectName += v.SubjectName
- }
- //插入关联信息
- e = cygx.AddCygxResourceDataGroup(sourceId, source, industrialItems, subjectItems)
- if e != nil {
- err = errors.New("AddCygxResourceDataGroup, Err: " + e.Error())
- return
- }
- }
- return
- }
- // 更新产品内测
- func UpdateProductInteriorResourceData(sourceId int) {
- var err error
- defer func() {
- if err != nil {
- fmt.Println("err:", err)
- go alarm_msg.SendAlarmMsg("更新产品内测 失败,UpdateProductInteriorResourceData Err:"+err.Error()+"资源ID"+strconv.Itoa(sourceId), 3)
- }
- }()
- var source = utils.CYGX_OBJ_PRODUCTINTERIOR
- var condition string
- var pars []interface{}
- condition = ` AND visible_range = 1 AND product_interior_id = ? `
- pars = append(pars, sourceId)
- total, e := cygx.GetCygxProductInteriorCount(condition, pars)
- if e != nil {
- err = errors.New("GetCygxReportSelection, Err: " + e.Error())
- return
- }
- //如果取消发布了就做删除处理
- if total == 0 {
- e = cygx.DeleteResourceData(sourceId, source)
- if e != nil {
- err = errors.New("DeleteResourceData, Err: " + e.Error())
- return
- }
- //删除 cygx_resource_data 表关联的产业ID,标的ID
- e = cygx.DeleteCygxResourceDataGroup(sourceId, source)
- if e != nil {
- err = errors.New("DeleteCygxResourceDataGroup, Err: " + e.Error())
- return
- }
- } else {
- //判断是否存在,如果不存在就新增,存在就更新
- totalData, e := cygx.GetCygxReportSelectionBySourceAndId(sourceId, source)
- if e != nil {
- err = errors.New("GetCygxReportSelectionBySourceAndId, Err: " + e.Error())
- return
- }
- detail, e := cygx.GetCygxProductInteriorDetail(sourceId)
- if e != nil {
- err = errors.New("GetCygxReportSelectionInfoById, Err: " + err.Error())
- return
- }
- mapMatchTypeName := GetCygxReportMappingCygxListMap() //报告匹配类型
- var resourceDataId int
- publishDate := detail.CreateTime
- item := new(cygx.CygxResourceData)
- var industrialName string
- var subjectName string
- //建立首页资源表,与产业的关系
- industrialList, e := cygx.GetProductInteriorIndustrialGroupManagementList(sourceId)
- if e != nil && e.Error() != utils.ErrNoRow() {
- err = errors.New("GetIndustrialArticleGroupManagementList, Err: " + e.Error() + "sourceId:" + strconv.Itoa(sourceId))
- return
- }
- for _, v := range industrialList {
- industrialName += v.IndustryName
- }
- //建立首页资源表,与标的 的关系
- subjectList, e := cygx.GetProductInteriorIndustrialGroupSubjecttList(sourceId)
- if e != nil && e.Error() != utils.ErrNoRow() {
- err = errors.New("GetSubjectArticleGroupManagementList, Err: " + e.Error() + "sourceId:" + strconv.Itoa(sourceId))
- return
- }
- for _, v := range subjectList {
- subjectName += v.SubjectName
- }
- item.SourceId = sourceId
- item.Source = source
- item.SearchTag = mapMatchTypeName[detail.MatchTypeId]
- item.PublishDate = publishDate
- if item.SearchTag != "观点周递" {
- item.ChartPermissionId = detail.ChartPermissionId //首页筛选任何行业时,无法筛选出【观点周递】类型的报告
- }
- item.CreateTime = time.Now()
- item.SearchTitle = detail.Title
- item.SearchContent = detail.Abstract + industrialName + subjectName
- item.SearchOrderTime = detail.PublishTime
- if totalData == 0 {
- newId, e := cygx.AddCygxResourceData(item)
- if e != nil {
- err = errors.New("AddCygxResourceData, Err: " + e.Error())
- return
- }
- resourceDataId = int(newId)
- } else {
- e = cygx.UpdateResourceDataByItem(item)
- if e != nil {
- err = errors.New("UpdateResourceData, Err: " + e.Error())
- return
- }
- sourceDetail, e := cygx.GetCygxResourceDataByIdAndSource(sourceId, source)
- if e != nil {
- err = errors.New("UpdateResourceData, Err: " + e.Error())
- return
- }
- resourceDataId = sourceDetail.Id
- }
- var industrialItems []*cygx.CygxResourceDataIndustrialGroupManagement
- for _, v := range industrialList {
- var industrialItem = new(cygx.CygxResourceDataIndustrialGroupManagement)
- industrialItem.SourceId = sourceId
- industrialItem.Source = source
- industrialItem.IndustrialManagementId = v.IndustrialManagementId
- industrialItem.ResourceDataId = resourceDataId
- industrialItem.CreateTime = time.Now()
- industrialItems = append(industrialItems, industrialItem)
- }
- var subjectItems []*cygx.CygxResourceDataIndustrialGroupSubject
- for _, v := range subjectList {
- var subjectItem = new(cygx.CygxResourceDataIndustrialGroupSubject)
- subjectItem.SourceId = sourceId
- subjectItem.Source = source
- subjectItem.IndustrialSubjectId = v.IndustrialSubjectId
- subjectItem.ResourceDataId = resourceDataId
- subjectItem.CreateTime = time.Now()
- subjectItems = append(subjectItems, subjectItem)
- }
- //插入关联信息
- e = cygx.AddCygxResourceDataGroup(sourceId, source, industrialItems, subjectItems)
- if e != nil {
- err = errors.New("AddCygxResourceDataGroup, Err: " + e.Error())
- return
- }
- }
- return
- }
- // 更新晨会精华 (跟踪点评)
- func UpdateMeetingreviewchaptResourceData(sourceId int) {
- var err error
- defer func() {
- if err != nil {
- fmt.Println("err:", err)
- go alarm_msg.SendAlarmMsg("更新产品内测 失败,UpdateMeetingreviewchaptResourceData Err:"+err.Error()+"资源ID"+strconv.Itoa(sourceId), 3)
- }
- }()
- var source = utils.CYGX_OBJ_MEETINGREVIEWCHAPT
- total, e := cygx.GetCygxMorningMeetingReviewChapterCount(sourceId)
- if e != nil {
- err = errors.New("GetCygxReportSelection, Err: " + e.Error())
- return
- }
- //如果取消发布了就做删除处理
- if total == 0 {
- e = cygx.DeleteResourceData(sourceId, source)
- if e != nil {
- err = errors.New("DeleteResourceData, Err: " + e.Error())
- return
- }
- //删除 cygx_resource_data 表关联的产业ID,标的ID
- e = cygx.DeleteCygxResourceDataGroup(sourceId, source)
- if e != nil {
- err = errors.New("DeleteCygxResourceDataGroup, Err: " + e.Error())
- return
- }
- } else {
- //判断是否存在,如果不存在就新增,存在就更新
- totalData, e := cygx.GetCygxReportSelectionBySourceAndId(sourceId, source)
- if e != nil {
- err = errors.New("GetCygxReportSelectionBySourceAndId, Err: " + e.Error())
- return
- }
- detail, e := cygx.GetCygxMorningMeetingReviewChapterDetail(sourceId)
- if e != nil {
- err = errors.New("GetCygxMorningMeetingReviewChapterDetail" + e.Error())
- return
- }
- var resourceDataId int
- publishDate := time.Now().Format(utils.FormatDateTime)
- item := new(cygx.CygxResourceData)
- var industrialName string
- var subjectName string
- //建立首页资源表,与产业的关系
- var condition string
- var pars []interface{}
- condition = " AND industrial_management_id = ? "
- pars = append(pars, detail.IndustryId)
- //建立首页资源表,与产业的关系
- industrialList, e := cygx.GetTopOneMonthArtReadNumIndustryAll(condition, pars)
- if e != nil && e.Error() != utils.ErrNoRow() {
- err = errors.New("GetTopOneMonthArtReadNumIndustryAll, Err: " + e.Error() + "sourceId:" + strconv.Itoa(sourceId))
- return
- }
- for _, v := range industrialList {
- industrialName += v.IndustryName
- }
- if detail.IndustrialSubjectIds != "" {
- condition = ""
- pars = make([]interface{}, 0)
- condition = " AND industrial_subject_id IN (" + detail.IndustrialSubjectIds + ") "
- //建立首页资源表,与标的 的关系
- subjectList, e := cygx.GetCygxIndustrialSubjectListCondition(condition, pars)
- if e != nil && e.Error() != utils.ErrNoRow() {
- err = errors.New("GetCygxIndustrialSubjectListCondition, Err: " + e.Error() + "sourceId:" + strconv.Itoa(sourceId))
- return
- }
- for _, v := range subjectList {
- subjectName += v.SubjectName
- }
- }
- item.SourceId = sourceId
- item.Source = source
- item.SearchTag = "晨会精华"
- item.PublishDate = publishDate
- item.ChartPermissionId = detail.ChartPermissionId
- item.CreateTime = time.Now()
- item.SearchTitle = industrialName + subjectName + "晨会精华"
- content, e := utils.GetHtmlContentText(detail.Content)
- if e != nil && e.Error() != utils.ErrNoRow() {
- err = errors.New("GetHtmlContentText, Err: " + e.Error() + "sourceId:" + strconv.Itoa(sourceId))
- return
- }
- item.SearchContent = content
- item.SearchOrderTime = detail.MeetingTime.Format(utils.FormatDateTime)
- if totalData == 0 {
- newId, e := cygx.AddCygxResourceData(item)
- if e != nil {
- err = errors.New("AddCygxResourceData, Err: " + e.Error())
- return
- }
- resourceDataId = int(newId)
- } else {
- e = cygx.UpdateResourceDataByItem(item)
- if e != nil {
- err = errors.New("UpdateResourceData, Err: " + e.Error())
- return
- }
- sourceDetail, e := cygx.GetCygxResourceDataByIdAndSource(sourceId, source)
- if e != nil {
- err = errors.New("UpdateResourceData, Err: " + e.Error())
- return
- }
- resourceDataId = sourceDetail.Id
- }
- var industrialItems []*cygx.CygxResourceDataIndustrialGroupManagement
- for _, v := range industrialList {
- var industrialItem = new(cygx.CygxResourceDataIndustrialGroupManagement)
- industrialItem.SourceId = sourceId
- industrialItem.Source = source
- industrialItem.IndustrialManagementId = v.IndustrialManagementId
- industrialItem.ResourceDataId = resourceDataId
- industrialItem.CreateTime = time.Now()
- industrialItems = append(industrialItems, industrialItem)
- }
- //return
- var subjectItems []*cygx.CygxResourceDataIndustrialGroupSubject
- //晨会精华如果关联的标的就做查询
- if detail.IndustrialSubjectIds != "" {
- condition = ""
- pars = make([]interface{}, 0)
- condition = " AND industrial_subject_id IN (" + detail.IndustrialSubjectIds + ") "
- //建立首页资源表,与标的 的关系
- subjectList, e := cygx.GetCygxIndustrialSubjectListCondition(condition, pars)
- if e != nil && e.Error() != utils.ErrNoRow() {
- err = errors.New("GetCygxIndustrialSubjectListCondition, Err: " + e.Error() + "sourceId:" + strconv.Itoa(sourceId))
- return
- }
- for _, v := range subjectList {
- var subjectItem = new(cygx.CygxResourceDataIndustrialGroupSubject)
- subjectItem.SourceId = sourceId
- subjectItem.Source = source
- subjectItem.IndustrialSubjectId = v.IndustrialSubjectId
- subjectItem.ResourceDataId = resourceDataId
- subjectItem.CreateTime = time.Now()
- subjectItems = append(subjectItems, subjectItem)
- }
- }
- //插入关联信息
- e = cygx.AddCygxResourceDataGroup(sourceId, source, industrialItems, subjectItems)
- if e != nil {
- err = errors.New("AddCygxResourceDataGroup, Err: " + e.Error())
- return
- }
- }
- return
- }
- // 更新报告精选(重点公司)
- func UpdateReportSelectionResourceData(sourceId int) {
- var err error
- defer func() {
- if err != nil {
- fmt.Println("err:", err)
- go alarm_msg.SendAlarmMsg("更新报告精选(重点公司) 失败,UpdateReportSelectionResourceData Err:"+err.Error()+"资源ID"+strconv.Itoa(sourceId), 3)
- }
- }()
- var source = utils.CYGX_OBJ_REPORTSELECTION
- var condition string
- var pars []interface{}
- condition = ` AND visible_range = 1 AND article_id = ? `
- pars = append(pars, sourceId)
- total, e := cygx.GetCygxReportSelection(condition, pars)
- if e != nil {
- err = errors.New("GetCygxReportSelection, Err: " + e.Error())
- return
- }
- //如果取消发布了就做删除处理
- if total == 0 {
- e = cygx.DeleteResourceData(sourceId, source)
- if e != nil {
- err = errors.New("DeleteResourceData, Err: " + e.Error())
- return
- }
- } else {
- //判断是否存在,如果不存在就新增,存在就更新
- totalData, e := cygx.GetCygxReportSelectionBySourceAndId(sourceId, source)
- if e != nil {
- err = errors.New("GetCygxReportSelectionBySourceAndId, Err: " + e.Error())
- return
- }
- detail, e := cygx.GetCygxReportSelectionInfoById(sourceId)
- if e != nil {
- err = errors.New("GetCygxReportSelectionInfoById, Err: " + e.Error())
- return
- }
- publishDate := detail.PublishDate
- item := new(cygx.CygxResourceData)
- item.SourceId = sourceId
- item.Source = source
- item.SearchTag = "重点公司"
- item.PublishDate = publishDate
- item.CreateTime = time.Now()
- item.SearchTitle = detail.Title
- item.SearchContent = ""
- item.SearchOrderTime = detail.PublishDate
- if totalData == 0 {
- _, e := cygx.AddCygxResourceData(item)
- if e != nil {
- err = errors.New("AddCygxResourceData, Err: " + e.Error())
- return
- }
- } else {
- e = cygx.UpdateResourceDataByItem(item)
- if e != nil {
- err = errors.New("UpdateResourceDataByItem, Err: " + e.Error())
- return
- }
- }
- }
- return
- }
- // 更新本周研究汇总
- func UpdateResearchSummaryResourceData(sourceId int) {
- var err error
- defer func() {
- if err != nil {
- fmt.Println("err:", err)
- go alarm_msg.SendAlarmMsg("更新本周研究汇总 失败,UpdateResearchSummaryResourceData Err:"+err.Error()+"资源ID"+strconv.Itoa(sourceId), 3)
- }
- }()
- var source = utils.CYGX_OBJ_RESEARCHSUMMARY
- var condition string
- var pars []interface{}
- condition = ` AND visible_range = 1 AND article_id = ? `
- pars = append(pars, sourceId)
- total, e := cygx.GetCygxResearchSummary(condition, pars)
- if e != nil {
- err = errors.New("GetCygxResearchSummary, Err: " + e.Error())
- return
- }
- //如果取消发布了就做删除处理
- if total == 0 {
- e = cygx.DeleteResourceData(sourceId, source)
- if e != nil {
- err = errors.New("DeleteResourceData, Err: " + e.Error())
- return
- }
- } else {
- //判断是否存在,如果不存在就新增,存在就更新
- totalData, e := cygx.GetCygxReportSelectionBySourceAndId(sourceId, source)
- if e != nil {
- err = errors.New("GetCygxReportSelectionBySourceAndId, Err: " + e.Error())
- return
- }
- detail, e := cygx.GetCygxResearchSummaryInfoById(sourceId)
- if e != nil {
- err = errors.New("GetCygxResearchSummaryInfoById, Err: " + e.Error())
- return
- }
- publishDate := time.Now().Format(utils.FormatDateTime)
- item := new(cygx.CygxResourceData)
- item.SourceId = sourceId
- item.Source = source
- item.SearchTag = "本周研究汇总"
- item.PublishDate = publishDate
- item.CreateTime = time.Now()
- item.SearchTitle = detail.Title
- item.SearchContent = ""
- item.SearchOrderTime = detail.PublishDate
- if totalData == 0 {
- _, e := cygx.AddCygxResourceData(item)
- if e != nil {
- err = errors.New("AddCygxResourceData, Err: " + e.Error())
- return
- }
- } else {
- e = cygx.UpdateResourceDataByItem(item)
- if e != nil {
- err = errors.New("UpdateResourceDataByItem, Err: " + e.Error())
- return
- }
- }
- }
- return
- }
- // 更新上周纪要汇总
- func UpdateMinutesSummaryResourceData(sourceId int) {
- var err error
- defer func() {
- if err != nil {
- fmt.Println("err:", err)
- go alarm_msg.SendAlarmMsg("更新上周纪要汇总 失败,UpdateMinutesSummaryResourceData Err:"+err.Error()+"资源ID"+strconv.Itoa(sourceId), 3)
- }
- }()
- var source = utils.CYGX_OBJ_MINUTESSUMMARY
- var condition string
- var pars []interface{}
- condition = ` AND visible_range = 1 AND article_id = ? `
- pars = append(pars, sourceId)
- total, e := cygx.GetCygxMinutesSummary(condition, pars)
- if e != nil {
- err = errors.New("GetCygxResearchSummary, Err: " + e.Error())
- return
- }
- //如果取消发布了就做删除处理
- if total == 0 {
- e = cygx.DeleteResourceData(sourceId, source)
- if e != nil {
- err = errors.New("DeleteResourceData, Err: " + e.Error())
- return
- }
- } else {
- //判断是否存在,如果不存在就新增,存在就更新
- totalData, e := cygx.GetCygxReportSelectionBySourceAndId(sourceId, source)
- if e != nil {
- err = errors.New("GetCygxReportSelectionBySourceAndId, Err: " + e.Error())
- return
- }
- detail, e := cygx.GetCygxMinutesSummaryInfoById(sourceId)
- if e != nil {
- err = errors.New("GetCygxMinutesSummaryInfoById, Err: " + e.Error())
- return
- }
- publishDate := time.Now().Format(utils.FormatDateTime)
- item := new(cygx.CygxResourceData)
- item.SourceId = sourceId
- item.Source = source
- item.SearchTag = "上周纪要汇总"
- item.PublishDate = publishDate
- item.CreateTime = time.Now()
- item.SearchTitle = detail.Title
- item.SearchContent = ""
- item.SearchOrderTime = detail.PublishDate
- if totalData == 0 {
- _, e := cygx.AddCygxResourceData(item)
- if e != nil {
- err = errors.New("AddCygxResourceData, Err: " + e.Error())
- return
- }
- } else {
- e = cygx.UpdateResourceDataByItem(item)
- if e != nil {
- err = errors.New("UpdateResourceDataByItem, Err: " + e.Error())
- return
- }
- }
- }
- return
- }
- // 更新活动音频
- func UpdateActivityVoiceResourceData(sourceId int) {
- time.Sleep(1 * time.Second) // 添加1秒的延迟
- var err error
- defer func() {
- if err != nil {
- fmt.Println("err:", err)
- go alarm_msg.SendAlarmMsg("更新更新活动音频 失败,UpdateActivityVoiceResourceData Err:"+err.Error()+"资源ID"+strconv.Itoa(sourceId), 3)
- }
- }()
- var source = utils.CYGX_OBJ_ACTIVITYVOICE
- var condition string
- var pars []interface{}
- condition = ` AND activity_voice_id = ? `
- pars = append(pars, sourceId)
- total, e := cygx.GetCygxActivityVoiceCount(condition, pars)
- if e != nil {
- err = errors.New("GetCygxResearchSummary, Err: " + e.Error())
- return
- }
- //如果取消发布了就做删除处理
- if total == 0 {
- e = cygx.DeleteResourceData(sourceId, source)
- if e != nil {
- err = errors.New("DeleteResourceData, Err: " + e.Error())
- return
- }
- } else {
- //获取音频详情
- voiceDetail, e := cygx.GetCygxActivityVoiceReqDetailByActivityVoiceId(sourceId)
- if e != nil {
- err = errors.New("GetCygxActivityVoiceReqDetail" + e.Error())
- return
- }
- activityId := voiceDetail.ActivityId
- //获取活动详情
- activityInfo, e := cygx.GetAddActivityInfoById(activityId)
- if e != nil {
- err = errors.New("GetAddActivityInfoById, Err: " + e.Error())
- return
- }
- //判断是否存在,如果不存在就新增,存在就更新
- totalData, e := cygx.GetCygxReportSelectionBySourceAndId(sourceId, source)
- if e != nil {
- err = errors.New("GetCygxReportSelectionBySourceAndId, Err: " + e.Error())
- return
- }
- publishDate := time.Now().Format(utils.FormatDateTime)
- item := new(cygx.CygxResourceData)
- var industrialName string
- var subjectName string
- //建立首页资源表,与产业的关系
- industrialList, e := cygx.GetIndustrialActivityGroupManagementList(activityId, 1)
- if e != nil && e.Error() != utils.ErrNoRow() {
- err = errors.New("GetIndustrialActivityGroupManagementList, Err: " + e.Error() + "activityId:" + strconv.Itoa(activityId))
- return
- }
- for _, v := range industrialList {
- industrialName += v.IndustryName
- }
- //建立首页资源表,与标的 的关系
- subjectList, e := cygx.GetSubjectActivityGroupManagementList(activityId, 1)
- if e != nil && e.Error() != utils.ErrNoRow() {
- err = errors.New("GetIndustrialActivityGroupManagementList, Err: " + e.Error() + "activityId:" + strconv.Itoa(activityId))
- return
- }
- for _, v := range subjectList {
- subjectName += v.SubjectName
- }
- item.SourceId = sourceId
- item.Source = source
- //易董办会的分析师电话会,为路演回放
- if voiceDetail.FileType == 1 {
- item.SearchTag = "路演回放"
- } else {
- item.SearchTag = "调研反馈"
- }
- item.PublishDate = publishDate
- item.ChartPermissionId = activityInfo.ChartPermissionId
- item.CreateTime = utils.StrDateToDate(activityInfo.ActivityTime)
- item.SearchTitle = voiceDetail.VoiceName
- item.SearchContent = activityInfo.Label + industrialName + subjectName
- item.SearchOrderTime = activityInfo.ActivityTime
- if totalData == 0 {
- _, e := cygx.AddCygxResourceData(item)
- if e != nil {
- err = errors.New("AddCygxResourceData, Err: " + e.Error())
- return
- }
- } else {
- e = cygx.UpdateResourceDataByItem(item)
- if e != nil {
- err = errors.New("UpdateResourceDataByItem, Err: " + e.Error())
- return
- }
- }
- }
- return
- }
- // 更新活动视频
- func UpdateActivityVideoResourceData(sourceId int) {
- time.Sleep(1 * time.Second) // 添加1秒的延迟
- var err error
- defer func() {
- if err != nil {
- fmt.Println("err:", err)
- go alarm_msg.SendAlarmMsg("更新更新活动视频 失败,UpdateActivityVideoResourceData Err:"+err.Error()+"资源ID"+strconv.Itoa(sourceId), 3)
- }
- }()
- var source = utils.CYGX_OBJ_ACTIVITYVIDEO
- var condition string
- var pars []interface{}
- condition = ` AND v.video_id = ? `
- pars = append(pars, sourceId)
- total, e := cygx.GetActivityVideoCount(condition, pars)
- if e != nil {
- err = errors.New("GetCygxResearchSummary, Err: " + e.Error())
- return
- }
- //如果取消发布了就做删除处理
- if total == 0 {
- e = cygx.DeleteResourceData(sourceId, source)
- if e != nil {
- err = errors.New("DeleteResourceData, Err: " + e.Error())
- return
- }
- } else {
- videoDetail, e := cygx.GetCygxActivityVideoReqDetailByVideoId(sourceId)
- if e != nil {
- err = errors.New("GetCygxActivityVoiceReqDetail" + e.Error())
- return
- }
- activityId := videoDetail.ActivityId
- activityInfo, e := cygx.GetAddActivityInfoById(activityId)
- if e != nil {
- err = errors.New("GetAddActivityInfoById, Err: " + e.Error())
- return
- }
- //判断是否存在,如果不存在就新增,存在就更新
- totalData, e := cygx.GetCygxReportSelectionBySourceAndId(sourceId, source)
- if e != nil {
- err = errors.New("GetCygxReportSelectionBySourceAndId, Err: " + e.Error())
- return
- }
- publishDate := time.Now().Format(utils.FormatDateTime)
- item := new(cygx.CygxResourceData)
- var industrialName string
- var subjectName string
- //建立首页资源表,与产业的关系
- industrialList, e := cygx.GetIndustrialActivityGroupManagementList(activityId, 1)
- if e != nil && e.Error() != utils.ErrNoRow() {
- err = errors.New("GetIndustrialActivityGroupManagementList, Err: " + e.Error() + "activityId:" + strconv.Itoa(activityId))
- return
- }
- for _, v := range industrialList {
- industrialName += v.IndustryName
- }
- //建立首页资源表,与标的 的关系
- subjectList, e := cygx.GetSubjectActivityGroupManagementList(activityId, 1)
- if e != nil && e.Error() != utils.ErrNoRow() {
- err = errors.New("GetIndustrialActivityGroupManagementList, Err: " + e.Error() + "activityId:" + strconv.Itoa(activityId))
- return
- }
- for _, v := range subjectList {
- subjectName += v.SubjectName
- }
- item.SourceId = sourceId
- item.Source = source
- //易董办会的分析师电话会,为路演回放
- if videoDetail.FileType == 1 {
- item.SearchTag = "路演回放"
- } else {
- item.SearchTag = "调研反馈"
- }
- item.PublishDate = publishDate
- item.ChartPermissionId = activityInfo.ChartPermissionId
- item.CreateTime = utils.StrDateToDate(activityInfo.ActivityTime)
- item.SearchTitle = videoDetail.VideoName
- item.SearchContent = activityInfo.Label + industrialName + subjectName
- item.SearchOrderTime = activityInfo.ActivityTime
- if totalData == 0 {
- _, e := cygx.AddCygxResourceData(item)
- if e != nil {
- err = errors.New("AddCygxResourceData, Err: " + e.Error())
- return
- }
- } else {
- e = cygx.UpdateResourceDataByItem(item)
- if e != nil {
- err = errors.New("UpdateResourceDataByItem, Err: " + e.Error())
- return
- }
- }
- }
- return
- }
- // 更新产业视频
- func UpdateMicroRoadshowResourceData(sourceId int) {
- var err error
- defer func() {
- if err != nil {
- fmt.Println("err:", err)
- go alarm_msg.SendAlarmMsg("更新产业视频 失败,UpdateMicroRoadshowResourceData Err:"+err.Error()+"资源ID"+strconv.Itoa(sourceId), 3)
- }
- }()
- var source = utils.CYGX_OBJ_ROADSHOW
- var condition string
- var pars []interface{}
- condition = ` AND publish_status = 1 AND video_id = ? `
- pars = append(pars, sourceId)
- total, e := cygx.GetMicroRoadshowVideoListCount(condition, pars)
- if e != nil {
- err = errors.New("GetMicroRoadshowVideoListCount, Err: " + e.Error())
- return
- }
- //如果取消发布了就做删除处理
- if total == 0 {
- e = cygx.DeleteResourceData(sourceId, source)
- if e != nil {
- err = errors.New("DeleteResourceData, Err: " + e.Error())
- return
- }
- } else {
- //判断是否存在,如果不存在就新增,存在就更新
- totalData, e := cygx.GetCygxReportSelectionBySourceAndId(sourceId, source)
- if e != nil {
- err = errors.New("GetCygxReportSelectionBySourceAndId, Err: " + e.Error())
- return
- }
- detail, e := cygx.GetMicroRoadshowVideoByVideoId(sourceId)
- if e != nil {
- err = errors.New("GetCygxReportSelectionBySourceAndId, Err: " + e.Error())
- return
- }
- publishDate := time.Now().Format(utils.FormatDateTime)
- item := new(cygx.CygxResourceData)
- item.SourceId = sourceId
- item.Source = source
- item.SearchTag = ""
- item.PublishDate = publishDate
- item.ChartPermissionId = detail.ChartPermissionId
- item.CreateTime = time.Now()
- item.SearchTitle = detail.VideoName
- item.SearchContent = detail.IndustryName
- item.SearchOrderTime = detail.PublishDate.Format(utils.FormatDateTime)
- if totalData == 0 {
- _, e := cygx.AddCygxResourceData(item)
- if e != nil {
- err = errors.New("AddCygxResourceData, Err: " + e.Error())
- return
- }
- } else {
- e = cygx.UpdateResourceDataByItem(item)
- if e != nil {
- err = errors.New("UpdateResourceDataByItem, Err: " + e.Error())
- return
- }
- }
- }
- return
- }
- //func init() {
- // UpdateAskserieVideoResourceData(7)
- //}
- // 更新问答系列 写入首页最新 cygx_resource_data 表
- func UpdateAskserieVideoResourceData(sourceId int) {
- var err error
- defer func() {
- if err != nil {
- fmt.Println(err)
- go alarm_msg.SendAlarmMsg(fmt.Sprint("更新问答系列ourceId: ", sourceId, err.Error()), 2)
- }
- }()
- var source = utils.CYGX_OBJ_ASKSERIEVIDEO
- var condition string
- var pars []interface{}
- condition = ` AND publish_status = 1 AND askserie_video_id = ? `
- pars = append(pars, sourceId)
- total, e := cygx.GetCygxAskserieVideoCount(condition, pars)
- if e != nil {
- err = errors.New("GetCygxAskserieVideoCount, Err: " + e.Error())
- return
- }
- //如果取消发布了就做删除处理
- if total == 0 {
- e = cygx.DeleteResourceData(sourceId, source)
- if e != nil {
- err = errors.New("DeleteResourceData, Err: " + e.Error())
- return
- }
- } else {
- //判断是否存在,如果不存在就新增,存在就更新
- totalData, e := cygx.GetCygxResourceDataBySourceAndIdCount(sourceId, source)
- if e != nil {
- err = errors.New("GetCygxReportSelectionBySourceAndId, Err: " + e.Error())
- return
- }
- detail, e := cygx.GetCygxAskserieVideoDetail(sourceId)
- if e != nil {
- err = errors.New("GetCygxAskserieVideoDetail, Err: " + e.Error())
- return
- }
- publishDate := time.Now().Format(utils.FormatDateTime)
- item := new(cygx.CygxResourceData)
- item.SourceId = sourceId
- item.Source = source
- item.PublishDate = publishDate
- item.ChartPermissionId = detail.ChartPermissionId
- item.CreateTime = time.Now()
- item.SearchTitle = detail.VideoName
- item.SearchContent = detail.IndustryName
- item.SearchOrderTime = detail.PublishDate
- if totalData == 0 {
- _, e := cygx.AddCygxResourceData(item)
- if e != nil {
- err = errors.New("AddCygxResourceData, Err: " + e.Error())
- return
- }
- } else {
- e = cygx.UpdateResourceDataByItem(item)
- if e != nil {
- err = errors.New("UpdateResourceDataByItem, Err: " + e.Error())
- return
- }
- }
- }
- return
- }
- func init300() {
- //var condition string
- //var pars []interface{}
- //
- //{
- // //活动
- // var condition string
- // var pars []interface{}
- // condition = " AND publish_status = 1 AND activity_id NOT IN (SELECT source_id FROM cygx_resource_data WHERE source = 'activity') "
- // list, err := cygx.GetActivityListAll(condition, pars, 0, 9999)
- // if err != nil {
- // fmt.Println(err)
- // }
- //
- // //list, err := cygx.GetCygxResourceDataListBysource(utils.CYGX_OBJ_ACTIVITY)
- // //if err != nil {
- // // fmt.Println(err)
- // //}
- // fmt.Println(len(list))
- // for _, v := range list {
- // fmt.Println(v.ActivityId)
- // UpdateActivityResourceData(v.ActivityId)
- // }
- //}
- //12.4
- //{
- // //活动
- // list, err := cygx.GetCygxResourceDataListBysource(utils.CYGX_OBJ_ACTIVITY)
- // if err != nil {
- // fmt.Println(err)
- // }
- //
- // for _, v := range list {
- // detail, e := cygx.GetAddActivityInfoById(v.SourceId)
- // if e != nil {
- // err = errors.New("GetCygxReportSelectionInfoById, Err: " + e.Error())
- // fmt.Println(err)
- // return
- // }
- // item := new(cygx.CygxResourceData)
- // item.SourceId = v.SourceId
- // item.Source = utils.CYGX_OBJ_ACTIVITY
- // item.ChartPermissionId = detail.ChartPermissionId
- // fmt.Println(v.Source)
- // err = cygx.UpdateChartPermissionIdResourceDataByItem(item)
- // if err != nil {
- // fmt.Println(err)
- // return
- // }
- // }
- //}
- //{
- // //专项调研活动
- // list, err := cygx.GetCygxResourceDataListBysource(utils.CYGX_OBJ_ACTIVITYSPECIAL)
- // if err != nil {
- // fmt.Println(err)
- // }
- // for _, v := range list {
- // fmt.Println(v.Source)
- // UpdateActivitySpecialResourceData(v.SourceId)
- // }
- //}
- //{
- // var condition string
- // var pars []interface{}
- // condition = " AND publish_status = 1 AND article_id NOT IN (SELECT source_id FROM cygx_resource_data WHERE source = 'article') "
- //
- // list, err := cygx.GetArticleRoadshowEssenceList(condition, pars, 0, 9999)
- // if err != nil {
- // fmt.Println(err)
- // return
- // }
- // fmt.Println(len(list))
- // //return
- // //文章
- // //list, err := cygx.GetCygxResourceDataListBysource(utils.CYGX_OBJ_ARTICLE)
- // //if err != nil {
- // // fmt.Println(err)
- // //}
- // for _, v := range list {
- // fmt.Println(v.ArticleId)
- // UpdateArticleResourceData(v.ArticleId)
- // }
- //}
- //{
- // //文章//12.4
- // list, err := cygx.GetCygxResourceDataListBysource(utils.CYGX_OBJ_ARTICLE)
- // if err != nil {
- // fmt.Println(err)
- // return
- // }
- // for _, v := range list {
- // detail, e := cygx.GetArticleDetailByArticleId(v.SourceId)
- // if e != nil {
- // err = errors.New("GetCygxReportSelectionInfoById, Err: " + e.Error())
- // fmt.Println(err)
- // return
- // }
- //
- // item := new(cygx.CygxResourceData)
- // if detail.ArticleTypeId > 0 {
- // //item.SearchTag = detail.ArticleTypeName // 研选类型名称
- // item.ChartPermissionId = utils.CHART_PERMISSION_ID_YANXUAN
- // } else {
- // //item.SearchTag = detail.MatchTypeName
- // //获取文章分类详情
- // detailCategory, _ := cygx.GetCygxReportMappingCelueMaxDetailByCategoryId(detail.CategoryId)
- // if detailCategory != nil {
- // item.ChartPermissionId = detailCategory.ChartPermissionId
- // }else{
- // detailCategoryTwo, _ := cygx.GetCygxReportMappingCelueMaxDetailByCategoryId(detail.CategoryIdTwo)
- // if detailCategoryTwo != nil {
- // item.ChartPermissionId = detailCategoryTwo.ChartPermissionId
- // }
- // }
- // }
- // item.SourceId = v.SourceId
- // item.Source = utils.CYGX_OBJ_ARTICLE
- // fmt.Println(v.Source)
- // err = cygx.UpdateChartPermissionIdResourceDataByItem(item)
- // if err != nil {
- // fmt.Println(err)
- // return
- // }
- // }
- //}
- //{
- // //产品内测
- // list, err := cygx.GetCygxResourceDataListBysource(utils.CYGX_OBJ_PRODUCTINTERIOR)
- // if err != nil {
- // fmt.Println(err)
- // }
- // for _, v := range list {
- // fmt.Println(v.Source)
- // UpdateProductInteriorResourceData(v.SourceId)
- // }
- //}
- //
- //{
- // //晨会精华
- // list, err := cygx.GetCygxResourceDataListBysource(utils.CYGX_OBJ_MEETINGREVIEWCHAPT)
- // if err != nil {
- // fmt.Println(err)
- // }
- // for _, v := range list {
- // fmt.Println(v.Source)
- // UpdateMeetingreviewchaptResourceData(v.SourceId)
- // }
- //}
- //
- //{
- // //重点公司
- // list, err := cygx.GetCygxResourceDataListBysource(utils.CYGX_OBJ_REPORTSELECTION)
- // if err != nil {
- // fmt.Println(err)
- // }
- // for _, v := range list {
- // fmt.Println(v.Source)
- // //UpdateReportSelectionResourceData(v.SourceId)
- // }
- //}
- //
- //{
- // //更新本周研究汇总
- // list, err := cygx.GetCygxResourceDataListBysource(utils.CYGX_OBJ_RESEARCHSUMMARY)
- // if err != nil {
- // fmt.Println(err)
- // }
- // for _, v := range list {
- // fmt.Println(v.Source)
- // //UpdateResearchSummaryResourceData(v.SourceId)
- // }
- //}
- //
- //{
- // //更新本周研究汇总
- // list, err := cygx.GetCygxResourceDataListBysource(utils.CYGX_OBJ_MINUTESSUMMARY)
- // if err != nil {
- // fmt.Println(err)
- // }
- // for _, v := range list {
- // fmt.Println(v.Source)
- // //UpdateMinutesSummaryResourceData(v.SourceId)
- // }
- //}
- //{
- // //活动音频
- // list, err := cygx.GetCygxResourceDataListBysource(utils.CYGX_OBJ_ACTIVITYVOICE)
- // if err != nil {
- // fmt.Println(err)
- // }
- // for _, v := range list {
- // fmt.Println(v.Source)
- // UpdateActivityVoiceResourceData(v.SourceId)
- // }
- //}
- //{
- // //活动视频
- // list, err := cygx.GetCygxResourceDataListBysource(utils.CYGX_OBJ_ACTIVITYVIDEO)
- // if err != nil {
- // fmt.Println(err)
- // }
- // for _, v := range list {
- // fmt.Println(v.SourceId)
- // UpdateActivityVideoResourceData(v.SourceId)
- // }
- //}
- //{
- // //活动音频
- // list, err := cygx.GetCygxResourceDataListBysource(utils.CYGX_OBJ_ROADSHOW)
- // if err != nil {
- // fmt.Println(err)
- // }
- // for _, v := range list {
- // fmt.Println(v.Source)
- // UpdateMicroRoadshowResourceData(v.SourceId)
- // }
- //}
- //{
- // //问答系列视频
- // list, err := cygx.GetCygxResourceDataListBysource(utils.CYGX_OBJ_ASKSERIEVIDEO)
- // if err != nil {
- // fmt.Println(err)
- // }
- // for _, v := range list {
- // fmt.Println(v.SourceId)
- // UpdateAskserieVideoResourceData(v.SourceId)
- // }
- //}
- //{
- // //晨会精华
- // list, err := cygx.GetCygxResourceDataListBysource(utils.CYGX_OBJ_MEETINGREVIEWCHAPT)
- // if err != nil {
- // fmt.Println(err)
- // }
- // for _, v := range list {
- // fmt.Println(v.SourceId)
- // UpdateMeetingreviewchaptResourceData(v.SourceId)
- // }
- //}
- //{
- // //研选专栏
- // list, err := cygx.GetCygxResourceDataListBysource(utils.CYGX_OBJ_YANXUANSPECIAL)
- // if err != nil {
- // fmt.Println(err)
- // }
- // for _, v := range list {
- // fmt.Println(v.SourceId)
- // UpdateYanxuanSpecialResourceData(v.SourceId)
- // }
- //}
- }
|