|
@@ -7,6 +7,7 @@ import (
|
|
|
"hongze/hz_crm_api/services/alarm_msg"
|
|
|
"hongze/hz_crm_api/utils"
|
|
|
"strconv"
|
|
|
+ "strings"
|
|
|
"time"
|
|
|
)
|
|
|
|
|
@@ -1289,6 +1290,113 @@ func UpdateAskserieVideoResourceData(sourceId int) {
|
|
|
return
|
|
|
}
|
|
|
|
|
|
+//func init() {
|
|
|
+// UpdateIndustrialsourceHzResourceData(731, "HZ")
|
|
|
+//}
|
|
|
+
|
|
|
+func UpdateIndustrialsourceHzResourceDataById(industrialManagementIds []string, sourceType string) {
|
|
|
+ for _, v := range industrialManagementIds {
|
|
|
+ if v == "" {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ industrialManagementId, _ := strconv.Atoi(v)
|
|
|
+ if industrialManagementId < 1 {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ UpdateIndustrialsourceHzResourceData(industrialManagementId, sourceType)
|
|
|
+ }
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+// 更新产业资源包 写入首页最新 cygx_resource_data 表
|
|
|
+func UpdateIndustrialsourceHzResourceData(sourceId int, sourceType string) {
|
|
|
+ var err error
|
|
|
+ defer func() {
|
|
|
+ if err != nil {
|
|
|
+ fmt.Println(err)
|
|
|
+ go alarm_msg.SendAlarmMsg(fmt.Sprint("UpdateIndustrialsourceHzResourceData 失败: ", sourceId, err.Error()), 2)
|
|
|
+ }
|
|
|
+ }()
|
|
|
+ var source string
|
|
|
+ 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 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 {
|
|
|
+ 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("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{}
|