|
@@ -483,6 +483,76 @@ func UpdateResourceData(sourceId int, source, doType, publishDate string) (err e
|
|
|
return
|
|
|
}
|
|
|
|
|
|
+//func init() {
|
|
|
+// UpdateNewchartResourceData(5509)
|
|
|
+//}
|
|
|
+
|
|
|
+// 更新图表
|
|
|
+func UpdateNewchartResourceData(sourceId int) {
|
|
|
+ var err error
|
|
|
+ defer func() {
|
|
|
+ if err != nil {
|
|
|
+ go utils.SendAlarmMsg("更新图表同步到最新数据表失败,Err:"+err.Error()+"资源ID"+strconv.Itoa(sourceId)+"资源类型", 3)
|
|
|
+ }
|
|
|
+ }()
|
|
|
+ var source = utils.CYGX_OBJ_NEWCHART
|
|
|
+ var condition string
|
|
|
+ var pars []interface{}
|
|
|
+ condition = ` AND chart_id = ? `
|
|
|
+ pars = append(pars, sourceId)
|
|
|
+ total, e := models.GetChartCount(condition, pars)
|
|
|
+ if e != nil {
|
|
|
+ err = errors.New("GetChartCount, Err: " + e.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+ //如果取消发布了就做删除处理
|
|
|
+ if total == 0 {
|
|
|
+ e = models.DeleteResourceData(sourceId, source)
|
|
|
+ if e != nil {
|
|
|
+ err = errors.New("DeleteResourceData, Err: " + e.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ //判断是否存在,如果不存在就新增,存在就更新
|
|
|
+ totalData, e := models.GetCygxResourceDataBySourceAndIdCount(sourceId, source)
|
|
|
+ if e != nil {
|
|
|
+ err = errors.New("GetCygxResourceDataBySourceAndIdCount, Err: " + e.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+ detail, e := models.GetChartDetailByChartId(sourceId)
|
|
|
+ if e != nil {
|
|
|
+ err = errors.New("GetArticleDetailById, Err: " + e.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+ publishDate := time.Now().Format(utils.FormatDateTime)
|
|
|
+ item := new(models.CygxResourceData)
|
|
|
+
|
|
|
+ item.SourceId = sourceId
|
|
|
+ item.Source = source
|
|
|
+ item.PublishDate = publishDate
|
|
|
+ item.CreateTime = time.Now()
|
|
|
+ item.SearchTitle = detail.Title
|
|
|
+ item.SearchContent = ""
|
|
|
+ item.SearchOrderTime = detail.CreateDate
|
|
|
+
|
|
|
+ if totalData == 0 {
|
|
|
+ _, e = models.AddCygxResourceData(item)
|
|
|
+ if e != nil {
|
|
|
+ err = errors.New("AddCygxResourceData, Err: " + e.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ } else {
|
|
|
+ e = models.UpdateResourceDataByItem(item)
|
|
|
+ if e != nil {
|
|
|
+ err = errors.New("UpdateResourceData, Err: " + e.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return
|
|
|
+}
|
|
|
+
|
|
|
// 批量删除最新图表数据
|
|
|
func Deletenewchart(chartIdsDelete []int) (err error) {
|
|
|
defer func() {
|
|
@@ -564,10 +634,47 @@ func UpdateArticleResourceData(sourceId int) {
|
|
|
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 {
|
|
@@ -590,11 +697,6 @@ func UpdateArticleResourceData(sourceId int) {
|
|
|
}
|
|
|
|
|
|
//建立首页资源表,与产业的关系
|
|
|
- industrialList, e := models.GetIndustrialArticleGroupManagementListByArticleId(sourceId)
|
|
|
- if e != nil && e.Error() != utils.ErrNoRow() {
|
|
|
- err = errors.New("GetIndustrialArticleGroupManagementList, Err: " + e.Error() + "sourceId:" + strconv.Itoa(sourceId))
|
|
|
- return
|
|
|
- }
|
|
|
var industrialItems []*models.CygxResourceDataIndustrialGroupManagement
|
|
|
for _, v := range industrialList {
|
|
|
var industrialItem = new(models.CygxResourceDataIndustrialGroupManagement)
|
|
@@ -607,11 +709,6 @@ func UpdateArticleResourceData(sourceId int) {
|
|
|
}
|
|
|
|
|
|
//建立首页资源表,与标的 的关系
|
|
|
- subjectList, e := models.GetSubjectArticleGroupManagementListByArtcileId(sourceId)
|
|
|
- if e != nil && e.Error() != utils.ErrNoRow() {
|
|
|
- err = errors.New("GetSubjectArticleGroupManagementList, Err: " + e.Error() + "sourceId:" + strconv.Itoa(sourceId))
|
|
|
- return
|
|
|
- }
|
|
|
var subjectItems []*models.CygxResourceDataIndustrialGroupSubject
|
|
|
for _, v := range subjectList {
|
|
|
var subjectItem = new(models.CygxResourceDataIndustrialGroupSubject)
|
|
@@ -632,3 +729,110 @@ func UpdateArticleResourceData(sourceId int) {
|
|
|
}
|
|
|
return
|
|
|
}
|
|
|
+
|
|
|
+// 更新产业资源包
|
|
|
+func UpdateComprehensiveIndustrialResourceData(itemSource *ElasticComprehensiveDetail) {
|
|
|
+ var err error
|
|
|
+ defer func() {
|
|
|
+ if err != nil {
|
|
|
+ go utils.SendAlarmMsg("更新产业资源包到最新数据表失败,Err:"+err.Error()+"资源ID"+strconv.Itoa(itemSource.SourceId), 3)
|
|
|
+ }
|
|
|
+ }()
|
|
|
+ sourceId := itemSource.SourceId
|
|
|
+ var source = itemSource.Source
|
|
|
+
|
|
|
+ //判断是否存在,如果不存在就新增,存在就更新
|
|
|
+ totalData, e := models.GetCygxResourceDataBySourceAndIdCount(sourceId, source)
|
|
|
+ if e != nil {
|
|
|
+ err = errors.New("GetCygxResourceDataBySourceAndIdCount, Err: " + e.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ item := new(models.CygxResourceData)
|
|
|
+ item.SourceId = sourceId
|
|
|
+ item.Source = source
|
|
|
+ item.PublishDate = itemSource.PublishDate
|
|
|
+ item.CreateTime = time.Now()
|
|
|
+ item.SearchTitle = itemSource.IndustryName + itemSource.SubjectNames
|
|
|
+ item.SearchContent = ""
|
|
|
+ item.SearchOrderTime = itemSource.PublishDate
|
|
|
+
|
|
|
+ if totalData == 0 {
|
|
|
+ _, e = models.AddCygxResourceData(item)
|
|
|
+ if e != nil {
|
|
|
+ err = errors.New("AddCygxResourceData, Err: " + e.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ e = models.UpdateResourceDataByItem(item)
|
|
|
+ if e != nil {
|
|
|
+ err = errors.New("UpdateResourceData, Err: " + e.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return
|
|
|
+}
|
|
|
+
|
|
|
+// 更新研选专栏 写入首页最新 cygx_resource_data 表
|
|
|
+func UpdateYanxuanSpecialResourceData(sourceId int) {
|
|
|
+ var err error
|
|
|
+ defer func() {
|
|
|
+ if err != nil {
|
|
|
+ go utils.SendAlarmMsg(fmt.Sprint("更新研选专栏失败sourceId: ", sourceId, "ErrMsg", err.Error()), 2)
|
|
|
+ }
|
|
|
+ }()
|
|
|
+ var source = utils.CYGX_OBJ_YANXUANSPECIAL
|
|
|
+ var condition string
|
|
|
+ var pars []interface{}
|
|
|
+ condition = ` AND status = 3 AND id = ? `
|
|
|
+ pars = append(pars, sourceId)
|
|
|
+ total, e := models.GetCygxYanxuanSpecialCount(condition, pars)
|
|
|
+ if e != nil {
|
|
|
+ err = errors.New("GetCygxYanxuanSpecialCount, Err: " + e.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+ //如果取消发布了就做删除处理
|
|
|
+ if total == 0 {
|
|
|
+ e = models.DeleteResourceData(sourceId, source)
|
|
|
+ if e != nil {
|
|
|
+ err = errors.New("DeleteResourceData, 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.GetYanxuanSpecialBySpecialId(sourceId)
|
|
|
+ if e != nil {
|
|
|
+ err = errors.New("GetYanxuanSpecialBySpecialId, Err: " + e.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+ publishDate := detail.PublishTime
|
|
|
+ item := new(models.CygxResourceData)
|
|
|
+ item.SourceId = sourceId
|
|
|
+ item.Source = source
|
|
|
+ item.PublishDate = publishDate
|
|
|
+ item.CreateTime = time.Now()
|
|
|
+ item.SearchTitle = detail.Title
|
|
|
+ item.SearchContent = ""
|
|
|
+ item.SearchOrderTime = publishDate
|
|
|
+ if totalData == 0 {
|
|
|
+ _, e := models.AddCygxResourceData(item)
|
|
|
+ if e != nil {
|
|
|
+ err = errors.New("AddCygxResourceData, Err: " + e.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ e = models.UpdateResourceDataByItem(item)
|
|
|
+ if e != nil {
|
|
|
+ err = errors.New("UpdateResourceDataByItem, Err: " + e.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return
|
|
|
+}
|