|
@@ -0,0 +1,904 @@
|
|
|
+package cygx
|
|
|
+
|
|
|
+import (
|
|
|
+ "errors"
|
|
|
+ "fmt"
|
|
|
+ "hongze/hz_crm_api/models/cygx"
|
|
|
+ "hongze/hz_crm_api/services/alarm_msg"
|
|
|
+ "hongze/hz_crm_api/utils"
|
|
|
+ "strconv"
|
|
|
+ "time"
|
|
|
+)
|
|
|
+
|
|
|
+//首页最新页面数据逻辑处理
|
|
|
+
|
|
|
+//activity
|
|
|
+//activityspecial
|
|
|
+//activityvideo
|
|
|
+//activityvoice
|
|
|
+//article
|
|
|
+//meetingreviewchapt
|
|
|
+//minutessummary
|
|
|
+//newchart
|
|
|
+//productinterior
|
|
|
+//reportselection
|
|
|
+//researchsummary
|
|
|
+//roadshow
|
|
|
+
|
|
|
+//func init() {
|
|
|
+// UpdateMeetingreviewchaptResourceData(141)
|
|
|
+//}
|
|
|
+
|
|
|
+// 更新活动
|
|
|
+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 = detail.ActivityTypeName
|
|
|
+ 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("更新活动 失败,UpdateActivitySpecialResourceData 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
|
|
|
+ }
|
|
|
+ mapMatchTypeName := GetCygxReportMappingCygxListMap() //报告匹配类型
|
|
|
+ var resourceDataId int
|
|
|
+ publishDate := time.Now().Format(utils.FormatDateTime)
|
|
|
+ item := new(cygx.CygxResourceData)
|
|
|
+ item.SourceId = sourceId
|
|
|
+ item.Source = source
|
|
|
+ item.SearchTag = mapMatchTypeName[detail.MatchTypeId]
|
|
|
+ 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("更新产品内测 失败,UpdateMeetingreviewchaptResourceData 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
|
|
|
+ }
|
|
|
+ detail, e := cygx.GetCygxMorningMeetingReviewChapterDetail(sourceId)
|
|
|
+ if e != nil {
|
|
|
+ err = errors.New("GetCygxMorningMeetingReviewChapterDetail" + e.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
|
|
|
+ }
|
|
|
+ var condition string
|
|
|
+ var pars []interface{}
|
|
|
+ condition = " AND industrial_management_id = ? "
|
|
|
+ pars = append(pars, detail.IndustryId)
|
|
|
+ //建立首页资源表,与产业的关系
|
|
|
+ industrialList, e := cygx.GetTopOneMonthArtReadNumIndustryAll(condition, pars)
|
|
|
+ if e != nil && e.Error() != utils.ErrNoRow() {
|
|
|
+ err = errors.New("GetTopOneMonthArtReadNumIndustryAll, 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)
|
|
|
+ }
|
|
|
+ //return
|
|
|
+ var subjectItems []*cygx.CygxResourceDataIndustrialGroupSubject
|
|
|
+ //晨会精华如果关联的标的就做查询
|
|
|
+ if detail.IndustrialSubjectIds != "" {
|
|
|
+ condition = ""
|
|
|
+ pars = make([]interface{}, 0)
|
|
|
+ condition = " AND industrial_subject_id IN (" + detail.IndustrialSubjectIds + ") "
|
|
|
+ //建立首页资源表,与标的 的关系
|
|
|
+ subjectList, e := cygx.GetCygxIndustrialSubjectListCondition(condition, pars)
|
|
|
+ if e != nil && e.Error() != utils.ErrNoRow() {
|
|
|
+ err = errors.New("GetCygxIndustrialSubjectListCondition, Err: " + e.Error() + "sourceId:" + strconv.Itoa(sourceId))
|
|
|
+ return
|
|
|
+ }
|
|
|
+ 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 UpdateReportSelectionResourceData(sourceId int) {
|
|
|
+ var err error
|
|
|
+ defer func() {
|
|
|
+ if err != nil {
|
|
|
+ fmt.Println("err:", err)
|
|
|
+ go alarm_msg.SendAlarmMsg("更新报告精选(重点公司) 失败,UpdateReportSelectionResourceData Err:"+err.Error()+"资源ID"+strconv.Itoa(sourceId), 3)
|
|
|
+ }
|
|
|
+ }()
|
|
|
+ var source = utils.CYGX_OBJ_REPORTSELECTION
|
|
|
+ var condition string
|
|
|
+ var pars []interface{}
|
|
|
+ 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: " + 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
|
|
|
+ }
|
|
|
+ detail, e := cygx.GetCygxReportSelectionInfoById(sourceId)
|
|
|
+ if e != nil {
|
|
|
+ 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 {
|
|
|
+ _, 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 init1123232() {
|
|
|
+ //var condition string
|
|
|
+ //var pars []interface{}
|
|
|
+ //
|
|
|
+ //{
|
|
|
+ // //活动
|
|
|
+ // list, err := cygx.GetCygxResourceDataListBysource(utils.CYGX_OBJ_ACTIVITY)
|
|
|
+ // if err != nil {
|
|
|
+ // fmt.Println(err)
|
|
|
+ // }
|
|
|
+ // for _, v := range list {
|
|
|
+ // fmt.Println(v.Source)
|
|
|
+ // //UpdateActivityResourceData(v.SourceId)
|
|
|
+ // }
|
|
|
+ //}
|
|
|
+
|
|
|
+ //{
|
|
|
+ // //专项调研活动
|
|
|
+ // list, err := cygx.GetCygxResourceDataListBysource(utils.CYGX_OBJ_ACTIVITYSPECIAL)
|
|
|
+ // if err != nil {
|
|
|
+ // fmt.Println(err)
|
|
|
+ // }
|
|
|
+ // for _, v := range list {
|
|
|
+ // fmt.Println(v.Source)
|
|
|
+ // UpdateActivitySpecialResourceData(v.SourceId)
|
|
|
+ // }
|
|
|
+ //}
|
|
|
+
|
|
|
+ //{
|
|
|
+ // //文章
|
|
|
+ // list, err := cygx.GetCygxResourceDataListBysource(utils.CYGX_OBJ_ARTICLE)
|
|
|
+ // if err != nil {
|
|
|
+ // fmt.Println(err)
|
|
|
+ // }
|
|
|
+ // for _, v := range list {
|
|
|
+ // fmt.Println(v.Source)
|
|
|
+ // UpdateArticleResourceData(v.SourceId)
|
|
|
+ // }
|
|
|
+ //}
|
|
|
+
|
|
|
+ //{
|
|
|
+ // //产品内测
|
|
|
+ // list, err := cygx.GetCygxResourceDataListBysource(utils.CYGX_OBJ_PRODUCTINTERIOR)
|
|
|
+ // if err != nil {
|
|
|
+ // fmt.Println(err)
|
|
|
+ // }
|
|
|
+ // for _, v := range list {
|
|
|
+ // fmt.Println(v.Source)
|
|
|
+ // //UpdateProductInteriorResourceData(v.SourceId)
|
|
|
+ // }
|
|
|
+ //}
|
|
|
+ //
|
|
|
+
|
|
|
+ //{
|
|
|
+ // //晨会精华
|
|
|
+ // list, err := cygx.GetCygxResourceDataListBysource(utils.CYGX_OBJ_MEETINGREVIEWCHAPT)
|
|
|
+ // if err != nil {
|
|
|
+ // fmt.Println(err)
|
|
|
+ // }
|
|
|
+ // for _, v := range list {
|
|
|
+ // fmt.Println(v.Source)
|
|
|
+ // UpdateMeetingreviewchaptResourceData(v.SourceId)
|
|
|
+ // }
|
|
|
+ //}
|
|
|
+
|
|
|
+ //
|
|
|
+ //{
|
|
|
+ // //重点公司
|
|
|
+ // list, err := cygx.GetCygxResourceDataListBysource(utils.CYGX_OBJ_REPORTSELECTION)
|
|
|
+ // if err != nil {
|
|
|
+ // fmt.Println(err)
|
|
|
+ // }
|
|
|
+ // for _, v := range list {
|
|
|
+ // fmt.Println(v.Source)
|
|
|
+ // //UpdateReportSelectionResourceData(v.SourceId)
|
|
|
+ // }
|
|
|
+ //}
|
|
|
+ //
|
|
|
+ //{
|
|
|
+ // //更新本周研究汇总
|
|
|
+ // list, err := cygx.GetCygxResourceDataListBysource(utils.CYGX_OBJ_RESEARCHSUMMARY)
|
|
|
+ // if err != nil {
|
|
|
+ // fmt.Println(err)
|
|
|
+ // }
|
|
|
+ // for _, v := range list {
|
|
|
+ // fmt.Println(v.Source)
|
|
|
+ // //UpdateResearchSummaryResourceData(v.SourceId)
|
|
|
+ // }
|
|
|
+ //}
|
|
|
+ //
|
|
|
+ {
|
|
|
+ //更新本周研究汇总
|
|
|
+ list, err := cygx.GetCygxResourceDataListBysource(utils.CYGX_OBJ_MINUTESSUMMARY)
|
|
|
+ if err != nil {
|
|
|
+ fmt.Println(err)
|
|
|
+ }
|
|
|
+ for _, v := range list {
|
|
|
+ fmt.Println(v.Source)
|
|
|
+ //UpdateMinutesSummaryResourceData(v.SourceId)
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|