|
@@ -43,6 +43,7 @@ func GetResourceDataList(condition string, pars []interface{}, startSize, pageSi
|
|
|
var reportselectionIds []int // 报告精选
|
|
|
var yanxuanSpecialIds []int // 研选专栏
|
|
|
var askserieVideoIds []string //问答系列视频
|
|
|
+ var ficcreporrtIds []string //FICC研报
|
|
|
//Source string `description:"资源类型 报告 :article 、图表 :newchart、微路演 :roadshow、活动 :activity、活动视频:activityvideo、活动音频:activityvoice、专项调研活动:activityspecial 、 本周研究汇总: researchsummary 、 上周纪要汇总 :minutessummary 、晨会精华 :meetingreviewchapt "`
|
|
|
for _, v := range list {
|
|
|
if v.Source == "article" {
|
|
@@ -73,6 +74,8 @@ func GetResourceDataList(condition string, pars []interface{}, startSize, pageSi
|
|
|
yanxuanSpecialIds = append(yanxuanSpecialIds, v.SourceId)
|
|
|
} else if v.Source == utils.CYGX_OBJ_ASKSERIEVIDEO {
|
|
|
askserieVideoIds = append(askserieVideoIds, strconv.Itoa(v.SourceId))
|
|
|
+ } else if v.Source == utils.CYGX_OBJ_FICC_REPORT {
|
|
|
+ ficcreporrtIds = append(ficcreporrtIds, strconv.Itoa(v.SourceId))
|
|
|
}
|
|
|
|
|
|
}
|
|
@@ -447,10 +450,49 @@ func GetResourceDataList(condition string, pars []interface{}, startSize, pageSi
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ //处理FICC研报
|
|
|
+ if len(ficcreporrtIds) > 0 {
|
|
|
+ pars = make([]interface{}, 0)
|
|
|
+ condition = ` AND a.report_id IN (` + utils.GetOrmInReplace(len(ficcreporrtIds)) + `)`
|
|
|
+ pars = append(pars, ficcreporrtIds)
|
|
|
+
|
|
|
+ listArticle, e := models.GetHomeList(condition, pars, 0, len(ficcreporrtIds))
|
|
|
+ if e != nil {
|
|
|
+ err = errors.New("GetHomeList, Err: " + e.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ //listArticle, e = HandleArticleCategoryImg(listArticle)
|
|
|
+ //if e != nil {
|
|
|
+ // err = errors.New("HandleArticleCategoryImg, Err: " + e.Error())
|
|
|
+ // return
|
|
|
+ //}
|
|
|
+ for _, v := range listArticle {
|
|
|
+ //fmt.Println(v.ArticleId)
|
|
|
+ v.Body = ""
|
|
|
+ v.BodyHtml = ""
|
|
|
+ mapItems[fmt.Sprint("ficcreport", v.ReportId)].FiccReport = v
|
|
|
+ }
|
|
|
+
|
|
|
+ //listArticle, e = HandleArticleCategoryImg(listArticle)
|
|
|
+ //if e != nil {
|
|
|
+ // err = errors.New("HandleArticleCategoryImg, Err: " + e.Error())
|
|
|
+ // return
|
|
|
+ //}
|
|
|
+ //for _, v := range listArticle {
|
|
|
+ // //reportInfoItem := new(ficc_report.ReportDetail)
|
|
|
+ // //reportInfoItem.ReportInfo.ReportId = v.ReportId
|
|
|
+ // //reportInfoItem.ReportInfo.PublishTime = utils.StrTimeToTime(v.PublishDate)
|
|
|
+ // //reportInfoItem.ReportInfo.Title = v.Title
|
|
|
+ // mapItems[fmt.Sprint("ficcreport", v.ArticleId)].FiccReport = v
|
|
|
+ //
|
|
|
+ //}
|
|
|
+ }
|
|
|
+
|
|
|
for _, vList := range list {
|
|
|
for _, v := range mapItems {
|
|
|
//如果这些类型都为空,那么就不合并
|
|
|
- if v.Article == nil && v.Newchart == nil && v.Roadshow == nil && v.Activity == nil && v.Activityvideo == nil && v.Activityvoice == nil && v.Activityspecial == nil && v.Researchsummary == nil && v.Minutessummary == nil && v.Meetingreviewchapt == nil && v.ProductInterior == nil && v.IndustrialResource == nil && v.ReportSelection == nil && v.YanxuanSpecial == nil && v.AskserieVideo == nil {
|
|
|
+ if v.Article == nil && v.Newchart == nil && v.Roadshow == nil && v.Activity == nil && v.Activityvideo == nil && v.Activityvoice == nil && v.Activityspecial == nil && v.Researchsummary == nil && v.Minutessummary == nil && v.Meetingreviewchapt == nil && v.ProductInterior == nil && v.IndustrialResource == nil && v.ReportSelection == nil && v.YanxuanSpecial == nil && v.AskserieVideo == nil && v.FiccReport == nil {
|
|
|
continue
|
|
|
}
|
|
|
if v.SourceId == vList.SourceId && v.Source == vList.Source {
|
|
@@ -904,3 +946,159 @@ func initsql12_17() {
|
|
|
}
|
|
|
return
|
|
|
}
|
|
|
+
|
|
|
+// 更新FICC研报
|
|
|
+func UpdateFICCReportResourceData(sourceId int) {
|
|
|
+ var err error
|
|
|
+ defer func() {
|
|
|
+ if err != nil {
|
|
|
+ fmt.Println("err:", err)
|
|
|
+ go utils.SendAlarmMsg("更新文章 失败,UpdateArticleResourceData Err:"+err.Error()+"资源ID"+strconv.Itoa(sourceId), 3)
|
|
|
+ }
|
|
|
+ }()
|
|
|
+ var source = utils.CYGX_OBJ_FICC_REPORT
|
|
|
+ var condition string
|
|
|
+ var pars []interface{}
|
|
|
+ condition = ` AND publish_status = 1 AND report_id = ? `
|
|
|
+ pars = append(pars, sourceId)
|
|
|
+ total, e := models.GetCygxArticleCount(condition, pars)
|
|
|
+ if e != nil {
|
|
|
+ err = errors.New("GetCygxArticleCount, Err: " + err.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+ //如果取消发布了就做删除处理
|
|
|
+ if total == 0 {
|
|
|
+ e = models.DeleteResourceData(sourceId, source)
|
|
|
+ if e != nil {
|
|
|
+ err = errors.New("DeleteResourceData, Err: " + e.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+ //删除 cygx_resource_data 表关联的产业ID,标的ID
|
|
|
+ e = models.DeleteCygxResourceDataGroup(sourceId, source)
|
|
|
+ if e != nil {
|
|
|
+ err = errors.New("DeleteCygxResourceDataGroup, Err: " + e.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ //判断是否存在,如果不存在就新增,存在就更新
|
|
|
+ totalData, e := models.GetCygxResourceDataBySourceAndIdCount(sourceId, source)
|
|
|
+ if e != nil {
|
|
|
+ err = errors.New("GetCygxReportSelectionBySourceAndId, Err: " + e.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+ detail, e := models.GetArticleDetailByReportId(sourceId)
|
|
|
+ if e != nil {
|
|
|
+ err = errors.New("GetArticleDetailByReportId, Err: " + e.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+ var resourceDataId int
|
|
|
+ publishDate := time.Now().Format(utils.FormatDateTime)
|
|
|
+ item := new(models.CygxResourceData)
|
|
|
+ if detail.ArticleTypeId > 0 {
|
|
|
+ item.SearchTag = detail.ArticleTypeName // 研选类型名称
|
|
|
+ } else {
|
|
|
+ item.SearchTag = detail.MatchTypeName
|
|
|
+ if detail.SubCategoryName == "产业跟踪" && detail.MatchTypeName == "行业深度" { //需求池973:查研观向首页标签【深度】下,过滤【产业跟踪】系列的报告。新报告不再写入此标签下,存量报告也去掉
|
|
|
+ item.SearchTag = ""
|
|
|
+ }
|
|
|
+ //获取文章分类详情
|
|
|
+ detailCategory, _ := models.GetCygxReportMappingCelueMaxDetailByCategoryId(detail.CategoryId)
|
|
|
+ if detailCategory != nil {
|
|
|
+ item.ChartPermissionId = detailCategory.ChartPermissionId
|
|
|
+ }
|
|
|
+ }
|
|
|
+ var industrialName string
|
|
|
+ var subjectName string
|
|
|
+ //建立首页资源表,与产业的关系
|
|
|
+ industrialList, e := models.GetIndustrialArticleGroupManagementListByArticleId(sourceId)
|
|
|
+ if e != nil && e.Error() != utils.ErrNoRow() {
|
|
|
+ err = errors.New("GetIndustrialArticleGroupManagementListByArticleId, Err: " + e.Error() + "sourceId:" + strconv.Itoa(sourceId))
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ for _, v := range industrialList {
|
|
|
+ industrialName += v.IndustryName
|
|
|
+ }
|
|
|
+
|
|
|
+ //建立首页资源表,与标的 的关系
|
|
|
+ subjectList, e := models.GetSubjectArticleGroupManagementListByArtcileId(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 := models.AddCygxResourceData(item)
|
|
|
+ if e != nil {
|
|
|
+ err = errors.New("AddCygxResourceData, Err: " + e.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+ resourceDataId = int(newId)
|
|
|
+ } else {
|
|
|
+ e = models.UpdateResourceDataByItem(item)
|
|
|
+ if e != nil {
|
|
|
+ err = errors.New("UpdateResourceData, Err: " + e.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+ sourceDetail, e := models.GetCygxResourceDataByIdAndSource(sourceId, source)
|
|
|
+ if e != nil {
|
|
|
+ err = errors.New("UpdateResourceData, Err: " + e.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+ resourceDataId = sourceDetail.Id
|
|
|
+ }
|
|
|
+
|
|
|
+ //建立首页资源表,与产业的关系
|
|
|
+ var industrialItems []*models.CygxResourceDataIndustrialGroupManagement
|
|
|
+ for _, v := range industrialList {
|
|
|
+ var industrialItem = new(models.CygxResourceDataIndustrialGroupManagement)
|
|
|
+ industrialItem.SourceId = sourceId
|
|
|
+ industrialItem.Source = source
|
|
|
+ industrialItem.IndustrialManagementId = v.IndustrialManagementId
|
|
|
+ industrialItem.ResourceDataId = resourceDataId
|
|
|
+ industrialItem.CreateTime = time.Now()
|
|
|
+ industrialItems = append(industrialItems, industrialItem)
|
|
|
+ }
|
|
|
+
|
|
|
+ //建立首页资源表,与标的 的关系
|
|
|
+ var subjectItems []*models.CygxResourceDataIndustrialGroupSubject
|
|
|
+ for _, v := range subjectList {
|
|
|
+ var subjectItem = new(models.CygxResourceDataIndustrialGroupSubject)
|
|
|
+ subjectItem.SourceId = sourceId
|
|
|
+ subjectItem.Source = source
|
|
|
+ subjectItem.IndustrialSubjectId = v.IndustrialSubjectId
|
|
|
+ subjectItem.ResourceDataId = resourceDataId
|
|
|
+ subjectItem.CreateTime = time.Now()
|
|
|
+ subjectItems = append(subjectItems, subjectItem)
|
|
|
+ }
|
|
|
+
|
|
|
+ //插入关联信息
|
|
|
+ e = models.AddCygxResourceDataGroup(sourceId, source, industrialItems, subjectItems)
|
|
|
+ if e != nil {
|
|
|
+ err = errors.New("AddCygxResourceDataGroup, Err: " + e.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return
|
|
|
+}
|