|
@@ -7,13 +7,562 @@ import (
|
|
|
"hongze/hz_crm_api/services/alarm_msg"
|
|
|
"hongze/hz_crm_api/utils"
|
|
|
"strconv"
|
|
|
+ "strings"
|
|
|
"time"
|
|
|
)
|
|
|
|
|
|
//首页最新页面数据逻辑处理
|
|
|
|
|
|
+//activity
|
|
|
+//activityspecial
|
|
|
+//activityvideo
|
|
|
+//activityvoice
|
|
|
+//article
|
|
|
+//meetingreviewchapt
|
|
|
+//minutessummary
|
|
|
+//newchart
|
|
|
+//productinterior
|
|
|
+//reportselection
|
|
|
+//researchsummary
|
|
|
+//roadshow
|
|
|
+
|
|
|
+//func init() {
|
|
|
+// UpdateArticleResourceData(1000004)
|
|
|
+//}
|
|
|
+
|
|
|
+// 更新活动
|
|
|
+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 := time.Now().Format(utils.FormatDateTime)
|
|
|
+ item := new(cygx.CygxResourceData)
|
|
|
+ item.SourceId = sourceId
|
|
|
+ item.Source = source
|
|
|
+ //分析师电话会(C类)
|
|
|
+ item.SearchTag = strings.TrimRight(detail.ActivityTypeName, "(C类)")
|
|
|
+ item.PublishDate = publishDate
|
|
|
+ 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
|
|
|
+ }
|
|
|
+
|
|
|
+ //建立首页资源表,与产业的关系
|
|
|
+ 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
|
|
|
+ }
|
|
|
+ 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.GetSubjectActivityGroupManagementList(sourceId, 1)
|
|
|
+ if e != nil && e.Error() != utils.ErrNoRow() {
|
|
|
+ err = errors.New("GetIndustrialActivityGroupManagementList, Err: " + e.Error() + "activityId:" + 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 UpdateActivitySpecialResourceData(sourceId int) {
|
|
|
+ var err error
|
|
|
+ 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_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
|
|
|
+ }
|
|
|
+ //如果取消发布了就做删除处理
|
|
|
+ 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 := time.Now().Format(utils.FormatDateTime)
|
|
|
+ item := new(cygx.CygxResourceData)
|
|
|
+ item.SourceId = sourceId
|
|
|
+ item.Source = source
|
|
|
+ //分析师电话会(C类)
|
|
|
+ item.SearchTag = ""
|
|
|
+ item.PublishDate = publishDate
|
|
|
+ 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
|
|
|
+ }
|
|
|
+
|
|
|
+ //建立首页资源表,与产业的关系
|
|
|
+ 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 := time.Now().Format(utils.FormatDateTime)
|
|
|
+ item := new(cygx.CygxResourceData)
|
|
|
+ if detail.ArticleTypeId > 0 {
|
|
|
+ item.SearchTag = detail.ArticleTypeName // 研选类型名称
|
|
|
+ } else {
|
|
|
+ item.SearchTag = detail.MatchTypeName
|
|
|
+ }
|
|
|
+ item.SourceId = sourceId
|
|
|
+ item.Source = source
|
|
|
+ item.PublishDate = publishDate
|
|
|
+ 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
|
|
|
+ }
|
|
|
+
|
|
|
+ //建立首页资源表,与产业的关系
|
|
|
+ industrialList, e := cygx.GetIndustrialArticleGroupManagementList(sourceId)
|
|
|
+ if e != nil && e.Error() != utils.ErrNoRow() {
|
|
|
+ err = errors.New("GetIndustrialArticleGroupManagementList, Err: " + e.Error() + "sourceId:" + 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 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
|
|
|
+ //}
|
|
|
+ var resourceDataId int
|
|
|
+ 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()
|
|
|
+ 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.GetProductInteriorIndustrialGroupManagementList(sourceId)
|
|
|
+ if e != nil && e.Error() != utils.ErrNoRow() {
|
|
|
+ err = errors.New("GetIndustrialArticleGroupManagementList, Err: " + e.Error() + "sourceId:" + 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.GetProductInteriorIndustrialGroupSubjecttList(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 UpdateMeetingreviewchaptResourceData(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_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
|
|
|
+ }
|
|
|
+ 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()
|
|
|
+ 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("UpdateResourceData, Err: " + e.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return
|
|
|
+}
|
|
|
+
|
|
|
// 更新报告精选(重点公司)
|
|
|
-func UpdateReportSelectionResourceData(sourceId int) (err error) {
|
|
|
+func UpdateReportSelectionResourceData(sourceId int) {
|
|
|
+ var err error
|
|
|
defer func() {
|
|
|
if err != nil {
|
|
|
fmt.Println("err:", err)
|
|
@@ -23,42 +572,165 @@ func UpdateReportSelectionResourceData(sourceId int) (err error) {
|
|
|
var source = utils.CYGX_OBJ_REPORTSELECTION
|
|
|
var condition string
|
|
|
var pars []interface{}
|
|
|
- condition = ` AND visible_range = 1 `
|
|
|
+ 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: " + err.Error())
|
|
|
+ err = errors.New("GetCygxReportSelection, Err: " + e.Error())
|
|
|
return
|
|
|
}
|
|
|
//如果取消发布了就做删除处理
|
|
|
if total == 0 {
|
|
|
e = cygx.DeleteResourceData(sourceId, source)
|
|
|
if e != nil {
|
|
|
- err = errors.New("DeleteResourceData, Err: " + err.Error())
|
|
|
+ err = errors.New("DeleteResourceData, Err: " + e.Error())
|
|
|
return
|
|
|
}
|
|
|
} else {
|
|
|
//判断是否存在,如果不存在就新增,存在就更新
|
|
|
totalData, e := cygx.GetCygxReportSelectionBySourceAndId(sourceId, source)
|
|
|
if e != nil {
|
|
|
- err = errors.New("GetCygxReportSelection, Err: " + err.Error())
|
|
|
+ err = errors.New("GetCygxReportSelectionBySourceAndId, Err: " + e.Error())
|
|
|
return
|
|
|
}
|
|
|
detail, e := cygx.GetCygxReportSelectionInfoById(sourceId)
|
|
|
if e != nil {
|
|
|
- err = errors.New("GetCygxReportSelectionInfoById, Err: " + err.Error())
|
|
|
+ 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()
|
|
|
+ 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
|
|
|
+ }
|
|
|
+ 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()
|
|
|
+ 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
|
|
|
+ }
|
|
|
+ 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()
|
|
|
if totalData == 0 {
|
|
|
- item := new(cygx.CygxResourceData)
|
|
|
- item.SourceId = sourceId
|
|
|
- item.Source = source
|
|
|
- item.SearchTag = "重点公司"
|
|
|
- item.PublishDate = publishDate
|
|
|
- item.CreateTime = time.Now()
|
|
|
- _, err = cygx.AddCygxResourceData(item)
|
|
|
+ _, e := cygx.AddCygxResourceData(item)
|
|
|
+ if e != nil {
|
|
|
+ err = errors.New("AddCygxResourceData, Err: " + e.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
} else {
|
|
|
- err = cygx.UpdateResourceData(sourceId, source, publishDate)
|
|
|
+ e = cygx.UpdateResourceDataByItem(item)
|
|
|
+ if e != nil {
|
|
|
+ err = errors.New("UpdateResourceDataByItem, Err: " + e.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
return
|