|
@@ -7,6 +7,7 @@ import (
|
|
|
"hongze/hz_crm_api/services/alarm_msg"
|
|
|
"hongze/hz_crm_api/utils"
|
|
|
"strconv"
|
|
|
+ "strings"
|
|
|
"time"
|
|
|
)
|
|
|
|
|
@@ -1289,6 +1290,10 @@ func UpdateAskserieVideoResourceData(sourceId int) {
|
|
|
return
|
|
|
}
|
|
|
|
|
|
+//func init() {
|
|
|
+// UpdateIndustrialsourceHzResourceData(731, "HZ")
|
|
|
+//}
|
|
|
+
|
|
|
// 更新产业资源包 写入首页最新 cygx_resource_data 表
|
|
|
func UpdateIndustrialsourceHzResourceData(sourceId int, sourceType string) {
|
|
|
var err error
|
|
@@ -1299,59 +1304,81 @@ func UpdateIndustrialsourceHzResourceData(sourceId int, sourceType string) {
|
|
|
}
|
|
|
}()
|
|
|
var source string
|
|
|
- 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
|
|
|
+ var e error
|
|
|
+ var maxData string
|
|
|
+ if sourceType == "HZ" {
|
|
|
+ maxData, e = cygx.GetIndustrialManagementGroupArticleMaxPublishDateByHz(sourceId)
|
|
|
+ if e != nil {
|
|
|
+ err = errors.New("GetIndustrialManagementGroupArticleMaxPublishDateByHz, Err: " + e.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+ source = "industrialsourceHz"
|
|
|
+ } else {
|
|
|
+ maxData, e = cygx.GetIndustrialManagementGroupArticleMaxPublishDateByYx(sourceId)
|
|
|
+ if e != nil {
|
|
|
+ err = errors.New("GetIndustrialManagementGroupArticleMaxPublishDateByYx, Err: " + e.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+ source = "industrialsourceYx"
|
|
|
}
|
|
|
- //如果取消发布了就做删除处理
|
|
|
- if total == 0 {
|
|
|
+
|
|
|
+ if maxData == "" {
|
|
|
e = cygx.DeleteResourceData(sourceId, source)
|
|
|
if e != nil {
|
|
|
err = errors.New("DeleteResourceData, Err: " + e.Error())
|
|
|
return
|
|
|
}
|
|
|
+ }
|
|
|
+
|
|
|
+ industrialItem, e := cygx.GetIndustrialManagementInfo(sourceId)
|
|
|
+ if e != nil {
|
|
|
+ err = errors.New("GetIndustrialManagementInfo, Err: " + e.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ var subjectNames []string
|
|
|
+ listSub, e := cygx.GetcygxIndustrialSubject(sourceId)
|
|
|
+ if e != nil {
|
|
|
+ err = errors.New("GetcygxIndustrialSubject, Err: " + e.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+ for _, v := range listSub {
|
|
|
+ subjectNames = append(subjectNames, v.SubjectName)
|
|
|
+ }
|
|
|
+
|
|
|
+ //判断是否存在,如果不存在就新增,存在就更新
|
|
|
+ totalData, e := cygx.GetCygxResourceDataBySourceAndIdCount(sourceId, source)
|
|
|
+ if e != nil {
|
|
|
+ err = errors.New("GetCygxResourceDataBySourceAndIdCount, Err: " + e.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ item := new(cygx.CygxResourceData)
|
|
|
+ item.SourceId = sourceId
|
|
|
+ item.Source = source
|
|
|
+ item.PublishDate = maxData
|
|
|
+ item.CreateTime = time.Now()
|
|
|
+ if len(subjectNames) == 0 {
|
|
|
+ item.SearchTitle = industrialItem.IndustryName
|
|
|
} else {
|
|
|
- //判断是否存在,如果不存在就新增,存在就更新
|
|
|
- totalData, e := cygx.GetCygxResourceDataBySourceAndIdCount(sourceId, source)
|
|
|
+ item.SearchTitle = industrialItem.IndustryName + "," + strings.Join(subjectNames, ",")
|
|
|
+ }
|
|
|
+ item.SearchContent = ""
|
|
|
+ item.SearchOrderTime = maxData
|
|
|
+ fmt.Println(item)
|
|
|
+ return
|
|
|
+ if totalData == 0 {
|
|
|
+ _, e := cygx.AddCygxResourceData(item)
|
|
|
if e != nil {
|
|
|
- err = errors.New("GetCygxResourceDataBySourceAndIdCount, Err: " + e.Error())
|
|
|
+ err = errors.New("AddCygxResourceData, Err: " + e.Error())
|
|
|
return
|
|
|
}
|
|
|
- detail, e := cygx.GetCygxAskserieVideoDetail(sourceId)
|
|
|
+ } else {
|
|
|
+ e = cygx.UpdateResourceDataByItem(item)
|
|
|
if e != nil {
|
|
|
- err = errors.New("GetCygxAskserieVideoDetail, Err: " + e.Error())
|
|
|
+ err = errors.New("UpdateResourceDataByItem, 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
|
|
|
}
|