resource_data.go 37 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104
  1. package services
  2. import (
  3. "errors"
  4. "fmt"
  5. "hongze/hongze_cygx/models"
  6. "hongze/hongze_cygx/utils"
  7. "strconv"
  8. "strings"
  9. "time"
  10. )
  11. func GetResourceDataList(condition string, pars []interface{}, startSize, pageSize int, user *models.WxUserItem) (items []*models.CygxResourceDataResp, err error) {
  12. uid := user.UserId
  13. list, e := models.GetResourceDataList(condition, pars, startSize, pageSize)
  14. if e != nil {
  15. err = errors.New("GetResourceDataList, Err: " + e.Error())
  16. return
  17. }
  18. mapItems := make(map[string]*models.CygxResourceDataResp)
  19. for _, v := range list {
  20. //预处理文章
  21. item := new(models.CygxResourceDataResp)
  22. item.Id = v.Id
  23. item.SourceId = v.SourceId
  24. item.Source = v.Source
  25. item.PublishDate = utils.TimeRemoveHms2(v.PublishDate)
  26. mapItems[fmt.Sprint(v.Source, v.SourceId)] = item
  27. }
  28. var articleIds []int
  29. var newchartIds []int
  30. var roadshowIds []string
  31. var activityIds []int
  32. var activityvideoIds []string
  33. var activityvoiceIds []string
  34. var activityspecialIds []int
  35. var researchsummaryIds []int
  36. var minutessummaryIds []int
  37. var meetingreviewchaptIds []int
  38. var productinteriorIds []int
  39. var reportselectionIds []int // 报告精选
  40. var yanxuanSpecialIds []int // 研选专栏
  41. var askserieVideoIds []string //问答系列视频
  42. var ficcreporrtIds []string //FICC研报
  43. //Source string `description:"资源类型 报告 :article 、图表 :newchart、微路演 :roadshow、活动 :activity、活动视频:activityvideo、活动音频:activityvoice、专项调研活动:activityspecial 、 本周研究汇总: researchsummary 、 上周纪要汇总 :minutessummary 、晨会精华 :meetingreviewchapt "`
  44. for _, v := range list {
  45. if v.Source == "article" {
  46. articleIds = append(articleIds, v.SourceId)
  47. } else if v.Source == "newchart" {
  48. newchartIds = append(newchartIds, v.SourceId)
  49. } else if v.Source == "roadshow" {
  50. roadshowIds = append(roadshowIds, strconv.Itoa(v.SourceId))
  51. } else if v.Source == "activity" {
  52. activityIds = append(activityIds, v.SourceId)
  53. } else if v.Source == "activityvideo" {
  54. activityvideoIds = append(activityvideoIds, strconv.Itoa(v.SourceId))
  55. } else if v.Source == "activityvoice" {
  56. activityvoiceIds = append(activityvoiceIds, strconv.Itoa(v.SourceId))
  57. } else if v.Source == "activityspecial" {
  58. activityspecialIds = append(activityspecialIds, v.SourceId)
  59. } else if v.Source == "researchsummary" {
  60. researchsummaryIds = append(researchsummaryIds, v.SourceId)
  61. } else if v.Source == "minutessummary" {
  62. minutessummaryIds = append(minutessummaryIds, v.SourceId)
  63. } else if v.Source == "meetingreviewchapt" {
  64. meetingreviewchaptIds = append(meetingreviewchaptIds, v.SourceId)
  65. } else if v.Source == "productinterior" {
  66. productinteriorIds = append(productinteriorIds, v.SourceId)
  67. } else if v.Source == "reportselection" {
  68. reportselectionIds = append(reportselectionIds, v.SourceId)
  69. } else if v.Source == utils.CYGX_OBJ_YANXUANSPECIAL {
  70. yanxuanSpecialIds = append(yanxuanSpecialIds, v.SourceId)
  71. } else if v.Source == utils.CYGX_OBJ_ASKSERIEVIDEO {
  72. askserieVideoIds = append(askserieVideoIds, strconv.Itoa(v.SourceId))
  73. } else if v.Source == utils.CYGX_OBJ_FICC_REPORT {
  74. ficcreporrtIds = append(ficcreporrtIds, strconv.Itoa(v.SourceId))
  75. }
  76. }
  77. //处理文章
  78. if len(articleIds) > 0 {
  79. pars = make([]interface{}, 0)
  80. condition = ` AND a.article_id IN (` + utils.GetOrmInReplace(len(articleIds)) + `)`
  81. pars = append(pars, articleIds)
  82. listArticle, e := models.GetHomeList(condition, pars, 0, len(articleIds))
  83. if e != nil {
  84. err = errors.New("GetResourceDataList, Err: " + e.Error())
  85. return
  86. }
  87. listArticle, e = HandleArticleCategoryImg(listArticle)
  88. if e != nil {
  89. err = errors.New("HandleArticleCategoryImg, Err: " + e.Error())
  90. return
  91. }
  92. for _, v := range listArticle {
  93. v.Body = ""
  94. v.BodyHtml = ""
  95. mapItems[fmt.Sprint("article", v.ArticleId)].Article = v
  96. }
  97. }
  98. //处理晨会精华
  99. if len(meetingreviewchaptIds) > 0 {
  100. //pars = make([]interface{}, 0)
  101. //condition = ` AND c.id IN (` + utils.GetOrmInReplace(len(meetingreviewchaptIds)) + `)`
  102. //pars = append(pars, meetingreviewchaptIds)
  103. listrMeet, e := GetCygxMorningMeetingReviewChapterListByIds(meetingreviewchaptIds)
  104. if e != nil {
  105. err = errors.New("GetCygxMorningMeetingReviewChapterListByIds, Err: " + e.Error())
  106. return
  107. }
  108. for _, v := range listrMeet {
  109. v.Content = AnnotationHtml(v.Content)
  110. v.PublishTime = utils.TimeRemoveHms2(v.PublishTime)
  111. mapItems[fmt.Sprint("meetingreviewchapt", v.Id)].Meetingreviewchapt = v
  112. }
  113. }
  114. //处理上周纪要汇总
  115. if len(minutessummaryIds) > 0 {
  116. pars = make([]interface{}, 0)
  117. condition = ` AND article_id IN (` + utils.GetOrmInReplace(len(minutessummaryIds)) + `)`
  118. pars = append(pars, minutessummaryIds)
  119. listresearchsummary, e := models.GetReportSelectionListHome(condition, "cygx_minutes_summary", pars, 0, len(minutessummaryIds))
  120. if e != nil {
  121. err = errors.New("GetResourceDataList, Err: " + e.Error())
  122. return
  123. }
  124. mapPv := GetCygxReportHistoryRecordListMap(minutessummaryIds, "szjyhz")
  125. for _, v := range listresearchsummary {
  126. v.Pv = mapPv[v.ArticleId]
  127. v.PublishDate = utils.TimeRemoveHms2(v.PublishDate)
  128. mapItems[fmt.Sprint("minutessummary", v.ArticleId)].Minutessummary = v
  129. }
  130. }
  131. //处理本周纪要汇总
  132. if len(researchsummaryIds) > 0 {
  133. pars = make([]interface{}, 0)
  134. condition = ` AND article_id IN (` + utils.GetOrmInReplace(len(researchsummaryIds)) + `)`
  135. pars = append(pars, researchsummaryIds)
  136. listresearchsummary, e := models.GetReportSelectionListHome(condition, "cygx_research_summary", pars, 0, len(researchsummaryIds))
  137. if e != nil {
  138. err = errors.New("GetReportSelectionListHome, Err: " + e.Error())
  139. return
  140. }
  141. mapPv := GetCygxReportHistoryRecordListMap(researchsummaryIds, "bzyjhz")
  142. for _, v := range listresearchsummary {
  143. v.Pv = mapPv[v.ArticleId]
  144. v.PublishDate = utils.TimeRemoveHms2(v.PublishDate)
  145. mapItems[fmt.Sprint("researchsummary", v.ArticleId)].Researchsummary = v
  146. }
  147. }
  148. //处理产品内测
  149. if len(productinteriorIds) > 0 {
  150. pars = make([]interface{}, 0)
  151. condition = ` AND art.status = 1 AND art.product_interior_id IN (` + utils.GetOrmInReplace(len(productinteriorIds)) + `)`
  152. pars = append(pars, productinteriorIds)
  153. listProductInterior, e := models.GetCygxProductInteriorList(condition, pars, 0, len(productinteriorIds))
  154. if e != nil {
  155. err = errors.New("GetCygxProductInteriorList, Err: " + e.Error())
  156. return
  157. }
  158. ProductInteriorHistoryMap := GetCygxProductInteriorHistoryListPvMap(productinteriorIds)
  159. for _, v := range listProductInterior {
  160. v.Body = ProductInteriorHtml(v.Body)
  161. v.Pv = ProductInteriorHistoryMap[v.ProductInteriorId]
  162. v.PublishTime = utils.TimeRemoveHms2(v.PublishTime)
  163. mapItems[fmt.Sprint("productinterior", v.ProductInteriorId)].ProductInterior = v
  164. }
  165. }
  166. detail, e := models.GetConfigByCode("city_img_url")
  167. if e != nil {
  168. err = errors.New("GetResourceDataList, Err: " + e.Error())
  169. return
  170. }
  171. detailChart, e := models.GetConfigByCode("chart_img_url")
  172. if e != nil {
  173. err = errors.New("GetResourceDataList, Err: " + e.Error())
  174. return
  175. }
  176. addressList := strings.Split(detail.ConfigValue, "{|}")
  177. mapAddress := make(map[string]string)
  178. chartList := strings.Split(detailChart.ConfigValue, "{|}")
  179. mapChart := make(map[string]string)
  180. var cityName string
  181. var chartName string
  182. var imgUrl string
  183. var imgUrlChart string
  184. for _, v := range addressList {
  185. vslice := strings.Split(v, "_")
  186. cityName = vslice[0]
  187. imgUrl = vslice[len(vslice)-1]
  188. mapAddress[cityName] = imgUrl
  189. }
  190. for _, v := range chartList {
  191. vslice := strings.Split(v, "_")
  192. chartName = vslice[0]
  193. imgUrlChart = vslice[len(vslice)-1]
  194. mapChart[chartName] = imgUrlChart
  195. }
  196. var imgUrlResp string
  197. //处理活动
  198. if len(activityIds) > 0 {
  199. for _, vss := range activityIds {
  200. imgUrlResp += strconv.Itoa(vss) + ","
  201. }
  202. pars = make([]interface{}, 0)
  203. condition = ` AND art.activity_id IN (` + utils.GetOrmInReplace(len(activityIds)) + `)`
  204. pars = append(pars, activityIds)
  205. activityList, e := models.GetActivityListNew(condition, pars, uid, 0, len(activityIds), 0, 0, "")
  206. if e != nil {
  207. err = errors.New("GetResourceDataList, Err: " + e.Error())
  208. return
  209. }
  210. //处理不同的报名方式按钮回显
  211. mapActivitySignup, e := GetActivitySignupResp(activityIds, user)
  212. if e != nil {
  213. e = errors.New("GetActivitySignupResp, Err: " + e.Error())
  214. return
  215. }
  216. var activityListRersp []*models.ActivityDetail
  217. for _, v := range activityList {
  218. v.SignupType = mapActivitySignup[v.ActivityId]
  219. //activityListRersp = append(activityListRersp, ActivityButtonShow(v))
  220. }
  221. activityListRersp = ActivityArrButtonShow(activityList)
  222. for _, v := range activityListRersp {
  223. if v == nil {
  224. continue
  225. }
  226. if v.ActivityType == 0 {
  227. if mapAddress[v.City] != "" {
  228. imgUrlResp = mapAddress[v.City]
  229. } else {
  230. imgUrlResp = mapAddress["其它"]
  231. }
  232. } else {
  233. if mapChart[v.ChartPermissionName] != "" {
  234. imgUrlResp = mapChart[v.ChartPermissionName]
  235. }
  236. }
  237. v.SourceType = 1
  238. v.Expert, _ = GetReportContentTextSub(v.Expert)
  239. mapItems[fmt.Sprint("activity", v.ActivityId)].Activity = v
  240. }
  241. }
  242. //处理图表
  243. if len(newchartIds) > 0 {
  244. pars = make([]interface{}, 0)
  245. condition = ` AND a.chart_id IN (` + utils.GetOrmInReplace(len(newchartIds)) + `)`
  246. pars = append(pars, newchartIds)
  247. chartDateList, e := models.GetChartListCollectionNew(condition, pars, uid, 0, len(newchartIds))
  248. if e != nil {
  249. err = errors.New("GetResourceDataList, Err: " + e.Error())
  250. return
  251. }
  252. for _, v := range chartDateList {
  253. mapItems[fmt.Sprint("newchart", v.ChartId)].Newchart = v
  254. }
  255. }
  256. //处理专项调研
  257. if len(activityspecialIds) > 0 {
  258. pars = make([]interface{}, 0)
  259. condition = ` AND art.activity_id IN (` + utils.GetOrmInReplace(len(activityspecialIds)) + `)`
  260. pars = append(pars, activityspecialIds)
  261. activitySpeciallist, e := models.GetCygxActivitySpecialDetailList(condition, pars, user.UserId, 0, len(activityspecialIds))
  262. if e != nil {
  263. err = errors.New("GetCygxActivitySpecialDetailList, Err: " + e.Error())
  264. return
  265. }
  266. UserMap, e := GetSpecialTripUserMap(activityIds, user.UserId)
  267. if e != nil {
  268. err = errors.New("GetSpecialTripUserMap, Err: " + e.Error())
  269. return
  270. }
  271. for _, v := range activitySpeciallist {
  272. if mapChart[v.ChartPermissionName] != "" {
  273. imgUrlResp = mapChart[v.ChartPermissionName]
  274. }
  275. if _, ok := UserMap[v.ActivityId]; ok {
  276. v.IsTrip = 1
  277. }
  278. if v.Days == 0 {
  279. v.TripStatus = 1
  280. v.TripImgLink = v.TripImgLink
  281. } else {
  282. v.TripStatus = 2
  283. v.TripImgLink = v.TripImgLinkFix
  284. v.ActivityTimeText = v.ActivityTimeTextByDay
  285. }
  286. resultTimeStart := utils.StrTimeToTime(v.ActivityTime) //时间字符串格式转时间格式
  287. resultTimeEnd := utils.StrTimeToTime(v.ActivityTimeEnd) //时间字符串格式转时间格式
  288. if resultTimeStart.After(time.Now()) {
  289. v.ActiveState = 1
  290. } else if time.Now().After(resultTimeEnd) {
  291. v.ActiveState = 3
  292. } else {
  293. v.ActiveState = 2
  294. }
  295. v.ImgUrl = imgUrlResp
  296. mapItems[fmt.Sprint("activityspecial", v.ActivityId)].Activityspecial = v
  297. }
  298. }
  299. if len(roadshowIds)+len(activityvideoIds)+len(activityvoiceIds)+len(askserieVideoIds) > 0 {
  300. audioIdstr := strings.Join(activityvoiceIds, ",")
  301. activityVideoIdsStr := strings.Join(activityvideoIds, ",")
  302. roadshowIdsStr := strings.Join(roadshowIds, ",")
  303. askserieVideoIdsStr := strings.Join(askserieVideoIds, ",")
  304. list, _, e := GetMicroRoadShowMycollectV12(len(roadshowIds)+len(activityvideoIds)+len(activityvoiceIds)+len(askserieVideoIds), 0, audioIdstr, activityVideoIdsStr, roadshowIdsStr, askserieVideoIdsStr, user)
  305. if e != nil {
  306. err = errors.New("GetMicroRoadShowMycollect, Err: " + e.Error())
  307. return
  308. }
  309. // 用户权限
  310. authInfo, permissionArr, e := GetUserRaiPermissionInfo(user.UserId, user.CompanyId)
  311. if e != nil {
  312. err = errors.New("GetUserRaiPermissionInfo, Err: " + e.Error())
  313. return
  314. }
  315. // 获取默认图配置
  316. audioMap, videoMap, audioShareMap, videoShareMap, e := GetMicroRoadShowDefaultImgConfig()
  317. if e != nil {
  318. err = errors.New("GetMicroRoadShowDefaultImgConfig, Err: " + e.Error())
  319. return
  320. }
  321. //Source string `description:"资源类型 报告 :article 、图表 :newchart、微路演 :roadshow、活动 :activity、活动视频:activityvideo、活动音频:activityvoice、专项调研活动:activityspecial"`
  322. for i := range list {
  323. // 权限
  324. au := new(models.UserPermissionAuthInfo)
  325. au.SellerName = authInfo.SellerName
  326. au.SellerMobile = authInfo.SellerMobile
  327. au.HasPermission = authInfo.HasPermission
  328. au.OperationMode = authInfo.OperationMode
  329. if au.HasPermission == 1 {
  330. // 非宏观权限进一步判断是否有权限
  331. if list[i].ChartPermissionId != utils.HONG_GUAN_ID && !utils.InArrayByStr(permissionArr, list[i].ChartPermissionName) {
  332. au.HasPermission = 2
  333. }
  334. }
  335. // 无权限的弹框提示
  336. if au.HasPermission != 1 {
  337. if au.OperationMode == UserPermissionOperationModeCall {
  338. if list[i].Type == 1 {
  339. au.PopupMsg = UserPermissionPopupMsgCallActivity
  340. } else {
  341. au.PopupMsg = UserPermissionPopupMsgCallMicroVideo
  342. }
  343. } else {
  344. if list[i].Type == 1 {
  345. au.PopupMsg = UserPermissionPopupMsgApplyActivity
  346. } else {
  347. au.PopupMsg = UserPermissionPopupMsgApplyMicroVideo
  348. }
  349. }
  350. }
  351. list[i].AuthInfo = au
  352. list[i].PublishTime = utils.StrTimeToTime(list[i].PublishTime).Format(utils.FormatDate)
  353. // 默认图
  354. if list[i].BackgroundImg == "" {
  355. if list[i].Type == 1 {
  356. list[i].BackgroundImg = audioMap[list[i].ChartPermissionId]
  357. } else {
  358. list[i].BackgroundImg = videoMap[list[i].ChartPermissionId]
  359. }
  360. }
  361. // 分享图
  362. if list[i].ShareImg == "" {
  363. if list[i].Type == 1 {
  364. list[i].ShareImg = audioShareMap[list[i].ChartPermissionId]
  365. } else {
  366. list[i].ShareImg = videoShareMap[list[i].ChartPermissionId]
  367. }
  368. }
  369. }
  370. //Type int `description:"类型: 1-音频; 2-活动视频; 3-产业视频"`
  371. for _, item := range list {
  372. if item.Type == 1 {
  373. mapItems[fmt.Sprint("activityvoice", item.Id)].Activityvoice = item
  374. } else if item.Type == 2 {
  375. mapItems[fmt.Sprint("activityvideo", item.Id)].Activityvideo = item
  376. } else if item.Type == 3 {
  377. mapItems[fmt.Sprint("roadshow", item.Id)].Roadshow = item
  378. } else if item.Type == 4 {
  379. mapItems[fmt.Sprint(utils.CYGX_OBJ_ASKSERIEVIDEO, item.Id)].AskserieVideo = item
  380. }
  381. }
  382. }
  383. //处理报告精选
  384. lenreportselectionIds := len(reportselectionIds)
  385. if lenreportselectionIds > 0 {
  386. pars = make([]interface{}, 0)
  387. condition = ` AND article_id IN (` + utils.GetOrmInReplace(lenreportselectionIds) + `)`
  388. pars = append(pars, reportselectionIds)
  389. listreportselection, e := models.GetReportSelectionList(condition, pars, 0, lenreportselectionIds)
  390. if e != nil {
  391. err = errors.New("GetReportSelectionList, Err: " + e.Error())
  392. return
  393. }
  394. mapPv := GetCygxReportHistoryRecordListMap(reportselectionIds, "bgjx")
  395. for _, v := range listreportselection {
  396. v.Title += "(第" + v.Periods + "期)"
  397. v.MarketStrategy = AnnotationHtml(v.MarketStrategy)
  398. v.PublishDate = utils.TimeRemoveHms2(v.PublishDate)
  399. v.Pv = mapPv[v.ArticleId]
  400. mapItems[fmt.Sprint("reportselection", v.ArticleId)].ReportSelection = v
  401. }
  402. }
  403. //处理研选专栏
  404. lenyanxuanSpecialIds := len(yanxuanSpecialIds)
  405. if lenyanxuanSpecialIds > 0 {
  406. pars = make([]interface{}, 0)
  407. condition = ` AND a.id IN (` + utils.GetOrmInReplace(lenyanxuanSpecialIds) + `) `
  408. pars = append(pars, yanxuanSpecialIds)
  409. listyanxuanSpecial, e := models.GetYanxuanSpecialList(user.UserId, condition, pars, 0, 0)
  410. if e != nil {
  411. err = errors.New("GetYanxuanSpecialList, Err: " + e.Error())
  412. return
  413. }
  414. for _, v := range listyanxuanSpecial {
  415. v.PublishTime = utils.TimeRemoveHms2(v.PublishTime)
  416. v.Annotation, _ = GetReportContentTextSubNew(v.Content)
  417. // Source PublishDate 字段兼容前端样式
  418. v.Source = utils.CYGX_OBJ_YANXUANSPECIAL
  419. v.PublishDate = v.PublishTime
  420. mapItems[fmt.Sprint(utils.CYGX_OBJ_YANXUANSPECIAL, v.Id)].YanxuanSpecial = v
  421. }
  422. }
  423. //处理FICC研报
  424. if len(ficcreporrtIds) > 0 {
  425. pars = make([]interface{}, 0)
  426. condition = ` AND a.report_id IN (` + utils.GetOrmInReplace(len(ficcreporrtIds)) + `)`
  427. pars = append(pars, ficcreporrtIds)
  428. listArticle, e := models.GetHomeList(condition, pars, 0, len(ficcreporrtIds))
  429. if e != nil {
  430. err = errors.New("GetHomeList, Err: " + e.Error())
  431. return
  432. }
  433. //listArticle, e = HandleArticleCategoryImg(listArticle)
  434. //if e != nil {
  435. // err = errors.New("HandleArticleCategoryImg, Err: " + e.Error())
  436. // return
  437. //}
  438. for _, v := range listArticle {
  439. //fmt.Println(v.ArticleId)
  440. v.Body = ""
  441. v.BodyHtml = ""
  442. mapItems[fmt.Sprint("ficcreport", v.ReportId)].FiccReport = v
  443. }
  444. //listArticle, e = HandleArticleCategoryImg(listArticle)
  445. //if e != nil {
  446. // err = errors.New("HandleArticleCategoryImg, Err: " + e.Error())
  447. // return
  448. //}
  449. //for _, v := range listArticle {
  450. // //reportInfoItem := new(ficc_report.ReportDetail)
  451. // //reportInfoItem.ReportInfo.ReportId = v.ReportId
  452. // //reportInfoItem.ReportInfo.PublishTime = utils.StrTimeToTime(v.PublishDate)
  453. // //reportInfoItem.ReportInfo.Title = v.Title
  454. // mapItems[fmt.Sprint("ficcreport", v.ArticleId)].FiccReport = v
  455. //
  456. //}
  457. }
  458. for _, vList := range list {
  459. for _, v := range mapItems {
  460. //如果这些类型都为空,那么就不合并
  461. if v.Article == nil && v.Newchart == nil && v.Roadshow == nil && v.Activity == nil && v.Activityvideo == nil && v.Activityvoice == nil && v.Activityspecial == nil && v.Researchsummary == nil && v.Minutessummary == nil && v.Meetingreviewchapt == nil && v.ProductInterior == nil && v.IndustrialResource == nil && v.ReportSelection == nil && v.YanxuanSpecial == nil && v.AskserieVideo == nil && v.FiccReport == nil {
  462. continue
  463. }
  464. if v.SourceId == vList.SourceId && v.Source == vList.Source {
  465. items = append(items, v)
  466. }
  467. }
  468. }
  469. return
  470. }
  471. // 同步活动到最新数据表
  472. func UpdateResourceData(sourceId int, source, doType, publishDate string) (err error) {
  473. defer func() {
  474. if err != nil {
  475. go utils.SendAlarmMsg("同步到最新数据表失败,Err:"+err.Error()+"资源ID"+strconv.Itoa(sourceId)+"资源类型"+source+"操作方式"+doType, 3)
  476. }
  477. }()
  478. if doType == "add" {
  479. item := new(models.CygxResourceData)
  480. item.SourceId = sourceId
  481. item.Source = source
  482. item.PublishDate = publishDate
  483. item.CreateTime = time.Now()
  484. _, err = models.AddCygxResourceData(item)
  485. } else if doType == "delete" {
  486. err = models.DeleteResourceData(sourceId, source)
  487. } else if doType == "update" {
  488. err = models.UpdateResourceData(sourceId, source, publishDate)
  489. }
  490. return
  491. }
  492. //func init130() {
  493. // //UpdateNewchartResourceData(5509)
  494. //
  495. // var condition string
  496. // var pars []interface{}
  497. // condition += ` AND publish_status = 1 `
  498. //
  499. // list, e := models.GetChartList(condition, pars, 0, 1000000)
  500. // if e != nil {
  501. // fmt.Println(e)
  502. // return
  503. // }
  504. //
  505. // for _, v := range list {
  506. // fmt.Println(v.ChartId)
  507. // UpdateNewchartResourceData(v.ChartId)
  508. // }
  509. //}
  510. // 更新图表
  511. func UpdateNewchartResourceData(sourceId int) {
  512. var err error
  513. defer func() {
  514. if err != nil {
  515. go utils.SendAlarmMsg("更新图表同步到最新数据表失败,Err:"+err.Error()+"资源ID"+strconv.Itoa(sourceId)+"资源类型", 3)
  516. }
  517. }()
  518. var source = utils.CYGX_OBJ_NEWCHART
  519. var condition string
  520. var pars []interface{}
  521. condition = ` AND chart_id = ? `
  522. pars = append(pars, sourceId)
  523. total, e := models.GetChartCount(condition, pars)
  524. if e != nil {
  525. err = errors.New("GetChartCount, Err: " + e.Error())
  526. return
  527. }
  528. //如果取消发布了就做删除处理
  529. if total == 0 {
  530. e = models.DeleteResourceData(sourceId, source)
  531. if e != nil {
  532. err = errors.New("DeleteResourceData, Err: " + e.Error())
  533. return
  534. }
  535. } else {
  536. //判断是否存在,如果不存在就新增,存在就更新
  537. totalData, e := models.GetCygxResourceDataBySourceAndIdCount(sourceId, source)
  538. if e != nil {
  539. err = errors.New("GetCygxResourceDataBySourceAndIdCount, Err: " + e.Error())
  540. return
  541. }
  542. detail, e := models.GetChartDetailByChartId(sourceId)
  543. if e != nil {
  544. err = errors.New("GetArticleDetailById, Err: " + e.Error())
  545. return
  546. }
  547. publishDate := detail.CreateDate
  548. item := new(models.CygxResourceData)
  549. item.SourceId = sourceId
  550. item.Source = source
  551. item.PublishDate = publishDate
  552. item.CreateTime = time.Now()
  553. item.SearchTitle = detail.Title
  554. item.SearchContent = ""
  555. item.SearchOrderTime = detail.CreateDate
  556. if totalData == 0 {
  557. _, e = models.AddCygxResourceData(item)
  558. if e != nil {
  559. err = errors.New("AddCygxResourceData, Err: " + e.Error())
  560. return
  561. }
  562. } else {
  563. e = models.UpdateResourceDataByItem(item)
  564. if e != nil {
  565. err = errors.New("UpdateResourceData, Err: " + e.Error())
  566. return
  567. }
  568. }
  569. }
  570. return
  571. }
  572. // 批量删除最新图表数据
  573. func Deletenewchart(chartIdsDelete []int) (err error) {
  574. defer func() {
  575. if err != nil {
  576. fmt.Println(err)
  577. go utils.SendAlarmMsg("批量删除最新图表数据,Err:"+err.Error(), 3)
  578. }
  579. }()
  580. lenchartIdsDelete := len(chartIdsDelete)
  581. if lenchartIdsDelete == 0 {
  582. return
  583. }
  584. var condition string
  585. var pars []interface{}
  586. condition += ` AND source = 'newchart' AND source_id IN (` + utils.GetOrmInReplace(lenchartIdsDelete) + `) `
  587. pars = append(pars, chartIdsDelete)
  588. err = models.DeleteResourceDataList(condition, pars)
  589. return
  590. }
  591. //func init() {
  592. // UpdateArticleResourceData(9050)
  593. //}
  594. // 更新文章
  595. func UpdateArticleResourceData(sourceId int) {
  596. var err error
  597. defer func() {
  598. if err != nil {
  599. fmt.Println("err:", err)
  600. go utils.SendAlarmMsg("更新文章 失败,UpdateArticleResourceData Err:"+err.Error()+"资源ID"+strconv.Itoa(sourceId), 3)
  601. }
  602. }()
  603. var source = utils.CYGX_OBJ_ARTICLE
  604. var condition string
  605. var pars []interface{}
  606. condition = ` AND publish_status = 1 AND article_id = ? `
  607. pars = append(pars, sourceId)
  608. total, e := models.GetCygxArticleCount(condition, pars)
  609. if e != nil {
  610. err = errors.New("GetCygxReportSelection, Err: " + err.Error())
  611. return
  612. }
  613. //如果取消发布了就做删除处理
  614. if total == 0 {
  615. e = models.DeleteResourceData(sourceId, source)
  616. if e != nil {
  617. err = errors.New("DeleteResourceData, Err: " + e.Error())
  618. return
  619. }
  620. //删除 cygx_resource_data 表关联的产业ID,标的ID
  621. e = models.DeleteCygxResourceDataGroup(sourceId, source)
  622. if e != nil {
  623. err = errors.New("DeleteCygxResourceDataGroup, Err: " + e.Error())
  624. return
  625. }
  626. } else {
  627. //判断是否存在,如果不存在就新增,存在就更新
  628. totalData, e := models.GetCygxResourceDataBySourceAndIdCount(sourceId, source)
  629. if e != nil {
  630. err = errors.New("GetCygxReportSelectionBySourceAndId, Err: " + e.Error())
  631. return
  632. }
  633. detail, e := models.GetArticleDetailById(sourceId)
  634. if e != nil {
  635. err = errors.New("GetCygxReportSelectionInfoById, Err: " + e.Error())
  636. return
  637. }
  638. var resourceDataId int
  639. publishDate := time.Now().Format(utils.FormatDateTime)
  640. item := new(models.CygxResourceData)
  641. if detail.ArticleTypeId > 0 {
  642. item.SearchTag = detail.ArticleTypeName // 研选类型名称
  643. } else {
  644. item.SearchTag = detail.MatchTypeName
  645. if detail.SubCategoryName == "产业跟踪" && detail.MatchTypeName == "行业深度" { //需求池973:查研观向首页标签【深度】下,过滤【产业跟踪】系列的报告。新报告不再写入此标签下,存量报告也去掉
  646. item.SearchTag = ""
  647. }
  648. //获取文章分类详情
  649. detailCategory, _ := models.GetCygxReportMappingCelueMaxDetailByCategoryId(detail.CategoryId)
  650. if detailCategory != nil {
  651. item.ChartPermissionId = detailCategory.ChartPermissionId
  652. }
  653. }
  654. var industrialName string
  655. var subjectName string
  656. //建立首页资源表,与产业的关系
  657. industrialList, e := models.GetIndustrialArticleGroupManagementListByArticleId(sourceId)
  658. if e != nil && e.Error() != utils.ErrNoRow() {
  659. err = errors.New("GetIndustrialArticleGroupManagementListByArticleId, Err: " + e.Error() + "sourceId:" + strconv.Itoa(sourceId))
  660. return
  661. }
  662. for _, v := range industrialList {
  663. industrialName += v.IndustryName
  664. }
  665. //建立首页资源表,与标的 的关系
  666. subjectList, e := models.GetSubjectArticleGroupManagementListByArtcileId(sourceId)
  667. if e != nil && e.Error() != utils.ErrNoRow() {
  668. err = errors.New("GetSubjectArticleGroupManagementList, Err: " + e.Error() + "sourceId:" + strconv.Itoa(sourceId))
  669. return
  670. }
  671. for _, v := range subjectList {
  672. subjectName += v.SubjectName
  673. }
  674. item.SourceId = sourceId
  675. item.Source = source
  676. item.PublishDate = publishDate
  677. item.CreateTime = time.Now()
  678. item.SearchTitle = detail.Title
  679. annotation, e := utils.GetHtmlContentText(detail.Annotation)
  680. if e != nil && e.Error() != utils.ErrNoRow() {
  681. err = errors.New("GetHtmlContentText, Err: " + e.Error() + "sourceId:" + strconv.Itoa(sourceId))
  682. return
  683. }
  684. abstract, e := utils.GetHtmlContentText(detail.Abstract)
  685. if e != nil && e.Error() != utils.ErrNoRow() {
  686. err = errors.New("GetHtmlContentText, Err: " + e.Error() + "sourceId:" + strconv.Itoa(sourceId))
  687. return
  688. }
  689. item.SearchContent = annotation + abstract + detail.FieldName + detail.Stock + industrialName + subjectName
  690. item.SearchOrderTime = detail.PublishDate
  691. if totalData == 0 {
  692. newId, e := models.AddCygxResourceData(item)
  693. if e != nil {
  694. err = errors.New("AddCygxResourceData, Err: " + e.Error())
  695. return
  696. }
  697. resourceDataId = int(newId)
  698. } else {
  699. e = models.UpdateResourceDataByItem(item)
  700. if e != nil {
  701. err = errors.New("UpdateResourceData, Err: " + e.Error())
  702. return
  703. }
  704. sourceDetail, e := models.GetCygxResourceDataByIdAndSource(sourceId, source)
  705. if e != nil {
  706. err = errors.New("UpdateResourceData, Err: " + e.Error())
  707. return
  708. }
  709. resourceDataId = sourceDetail.Id
  710. }
  711. //建立首页资源表,与产业的关系
  712. var industrialItems []*models.CygxResourceDataIndustrialGroupManagement
  713. for _, v := range industrialList {
  714. var industrialItem = new(models.CygxResourceDataIndustrialGroupManagement)
  715. industrialItem.SourceId = sourceId
  716. industrialItem.Source = source
  717. industrialItem.IndustrialManagementId = v.IndustrialManagementId
  718. industrialItem.ResourceDataId = resourceDataId
  719. industrialItem.CreateTime = time.Now()
  720. industrialItems = append(industrialItems, industrialItem)
  721. }
  722. //建立首页资源表,与标的 的关系
  723. var subjectItems []*models.CygxResourceDataIndustrialGroupSubject
  724. for _, v := range subjectList {
  725. var subjectItem = new(models.CygxResourceDataIndustrialGroupSubject)
  726. subjectItem.SourceId = sourceId
  727. subjectItem.Source = source
  728. subjectItem.IndustrialSubjectId = v.IndustrialSubjectId
  729. subjectItem.ResourceDataId = resourceDataId
  730. subjectItem.CreateTime = time.Now()
  731. subjectItems = append(subjectItems, subjectItem)
  732. }
  733. //插入关联信息
  734. e = models.AddCygxResourceDataGroup(sourceId, source, industrialItems, subjectItems)
  735. if e != nil {
  736. err = errors.New("AddCygxResourceDataGroup, Err: " + e.Error())
  737. return
  738. }
  739. }
  740. return
  741. }
  742. // 更新产业资源包
  743. func UpdateComprehensiveIndustrialResourceData(itemSource *ElasticComprehensiveDetail) {
  744. var err error
  745. defer func() {
  746. if err != nil {
  747. go utils.SendAlarmMsg("更新产业资源包到最新数据表失败,Err:"+err.Error()+"资源ID"+strconv.Itoa(itemSource.SourceId), 3)
  748. }
  749. }()
  750. sourceId := itemSource.SourceId
  751. var source = itemSource.Source
  752. //判断是否存在,如果不存在就新增,存在就更新
  753. totalData, e := models.GetCygxResourceDataBySourceAndIdCount(sourceId, source)
  754. if e != nil {
  755. err = errors.New("GetCygxResourceDataBySourceAndIdCount, Err: " + e.Error())
  756. return
  757. }
  758. item := new(models.CygxResourceData)
  759. item.SourceId = sourceId
  760. item.Source = source
  761. item.PublishDate = itemSource.PublishDate
  762. item.CreateTime = time.Now()
  763. item.SearchTitle = itemSource.IndustryName + itemSource.SubjectNames
  764. item.SearchContent = ""
  765. item.SearchOrderTime = itemSource.PublishDate
  766. if totalData == 0 {
  767. _, e = models.AddCygxResourceData(item)
  768. if e != nil {
  769. err = errors.New("AddCygxResourceData, Err: " + e.Error())
  770. return
  771. }
  772. } else {
  773. e = models.UpdateResourceDataByItem(item)
  774. if e != nil {
  775. err = errors.New("UpdateResourceData, Err: " + e.Error())
  776. return
  777. }
  778. }
  779. return
  780. }
  781. // 更新研选专栏 写入首页最新 cygx_resource_data 表
  782. func UpdateYanxuanSpecialResourceData(sourceId int) {
  783. var err error
  784. defer func() {
  785. if err != nil {
  786. go utils.SendAlarmMsg(fmt.Sprint("更新研选专栏失败sourceId: ", sourceId, "ErrMsg", err.Error()), 2)
  787. }
  788. }()
  789. var source = utils.CYGX_OBJ_YANXUANSPECIAL
  790. var condition string
  791. var pars []interface{}
  792. condition = ` AND status = 3 AND id = ? `
  793. pars = append(pars, sourceId)
  794. total, e := models.GetCygxYanxuanSpecialCount(condition, pars)
  795. if e != nil {
  796. err = errors.New("GetCygxYanxuanSpecialCount, Err: " + e.Error())
  797. return
  798. }
  799. //如果取消发布了就做删除处理
  800. if total == 0 {
  801. e = models.DeleteResourceData(sourceId, source)
  802. if e != nil {
  803. err = errors.New("DeleteResourceData, Err: " + e.Error())
  804. return
  805. }
  806. } else {
  807. //判断是否存在,如果不存在就新增,存在就更新
  808. totalData, e := models.GetCygxResourceDataBySourceAndIdCount(sourceId, source)
  809. if e != nil {
  810. err = errors.New("GetCygxReportSelectionBySourceAndId, Err: " + e.Error())
  811. return
  812. }
  813. detail, e := models.GetYanxuanSpecialBySpecialId(sourceId)
  814. if e != nil {
  815. err = errors.New("GetYanxuanSpecialBySpecialId, Err: " + e.Error())
  816. return
  817. }
  818. publishDate := detail.PublishTime
  819. item := new(models.CygxResourceData)
  820. item.SourceId = sourceId
  821. item.Source = source
  822. item.PublishDate = publishDate
  823. item.CreateTime = time.Now()
  824. item.SearchTitle = detail.Title
  825. item.SearchContent = ""
  826. item.SearchOrderTime = publishDate
  827. item.ChartPermissionId = utils.CHART_PERMISSION_ID_YANXUAN
  828. if totalData == 0 {
  829. _, e := models.AddCygxResourceData(item)
  830. if e != nil {
  831. err = errors.New("AddCygxResourceData, Err: " + e.Error())
  832. return
  833. }
  834. } else {
  835. e = models.UpdateResourceDataByItem(item)
  836. if e != nil {
  837. err = errors.New("UpdateResourceDataByItem, Err: " + e.Error())
  838. return
  839. }
  840. }
  841. }
  842. return
  843. }
  844. func initsql12_17() {
  845. listIndustrialResourceIds, e := models.GetSearchResourceList(0, " AND article_type_id > 0 ", 0, 9999)
  846. if e != nil {
  847. fmt.Println(e)
  848. return
  849. }
  850. var industrialResourceIdsHz []int
  851. for _, v := range listIndustrialResourceIds {
  852. industrialResourceIdsHz = append(industrialResourceIdsHz, v.IndustrialManagementId)
  853. }
  854. //date_format( MAX( a.publish_date ), '%Y-%m-%d' ) AS publish_date,
  855. //合并产业关联的标的
  856. listSubjcet, e := models.GetIndustrialSubjectAllByIndustrialId(industrialResourceIdsHz)
  857. if e != nil {
  858. fmt.Println(e)
  859. return
  860. }
  861. mapIndustrial := make(map[string]int)
  862. for _, v := range listSubjcet {
  863. for k2, v2 := range listIndustrialResourceIds {
  864. if v2.IndustrialManagementId == v.IndustrialManagementId && mapIndustrial[fmt.Sprint(v2.IndustrialManagementId, "Hz", v.SubjectName)] == 0 {
  865. listIndustrialResourceIds[k2].IndustrialSubjectList = append(listIndustrialResourceIds[k2].IndustrialSubjectList, v)
  866. }
  867. }
  868. }
  869. //industrialsource := "industrialsourceHz"
  870. industrialsource := "industrialsourceYx"
  871. for _, v := range listIndustrialResourceIds {
  872. item := new(ElasticComprehensiveDetail)
  873. item.SourceId = v.IndustrialManagementId
  874. item.Source = industrialsource
  875. item.IndustryName = v.IndustryName
  876. var SubjectName []string
  877. for _, vN := range v.IndustrialSubjectList {
  878. SubjectName = append(SubjectName, vN.SubjectName)
  879. }
  880. item.SubjectNames = strings.Join(SubjectName, ",")
  881. item.PublishDate = v.PublishDate
  882. fmt.Println(item)
  883. UpdateComprehensiveIndustrialResourceData(item)
  884. }
  885. return
  886. }
  887. // 更新FICC研报
  888. func UpdateFICCReportResourceData(sourceId int) {
  889. var err error
  890. defer func() {
  891. if err != nil {
  892. fmt.Println("err:", err)
  893. go utils.SendAlarmMsg("更新文章 失败,UpdateArticleResourceData Err:"+err.Error()+"资源ID"+strconv.Itoa(sourceId), 3)
  894. }
  895. }()
  896. var source = utils.CYGX_OBJ_FICC_REPORT
  897. var condition string
  898. var pars []interface{}
  899. condition = ` AND publish_status = 1 AND report_id = ? `
  900. pars = append(pars, sourceId)
  901. total, e := models.GetCygxArticleCount(condition, pars)
  902. if e != nil {
  903. err = errors.New("GetCygxArticleCount, Err: " + err.Error())
  904. return
  905. }
  906. //如果取消发布了就做删除处理
  907. if total == 0 {
  908. e = models.DeleteResourceData(sourceId, source)
  909. if e != nil {
  910. err = errors.New("DeleteResourceData, Err: " + e.Error())
  911. return
  912. }
  913. //删除 cygx_resource_data 表关联的产业ID,标的ID
  914. e = models.DeleteCygxResourceDataGroup(sourceId, source)
  915. if e != nil {
  916. err = errors.New("DeleteCygxResourceDataGroup, Err: " + e.Error())
  917. return
  918. }
  919. } else {
  920. //判断是否存在,如果不存在就新增,存在就更新
  921. totalData, e := models.GetCygxResourceDataBySourceAndIdCount(sourceId, source)
  922. if e != nil {
  923. err = errors.New("GetCygxReportSelectionBySourceAndId, Err: " + e.Error())
  924. return
  925. }
  926. detail, e := models.GetArticleDetailByReportId(sourceId)
  927. if e != nil {
  928. err = errors.New("GetArticleDetailByReportId, Err: " + e.Error())
  929. return
  930. }
  931. var resourceDataId int
  932. publishDate := time.Now().Format(utils.FormatDateTime)
  933. item := new(models.CygxResourceData)
  934. if detail.ArticleTypeId > 0 {
  935. item.SearchTag = detail.ArticleTypeName // 研选类型名称
  936. } else {
  937. item.SearchTag = detail.MatchTypeName
  938. if detail.SubCategoryName == "产业跟踪" && detail.MatchTypeName == "行业深度" { //需求池973:查研观向首页标签【深度】下,过滤【产业跟踪】系列的报告。新报告不再写入此标签下,存量报告也去掉
  939. item.SearchTag = ""
  940. }
  941. //获取文章分类详情
  942. detailCategory, _ := models.GetCygxReportMappingCelueMaxDetailByCategoryId(detail.CategoryId)
  943. if detailCategory != nil {
  944. item.ChartPermissionId = detailCategory.ChartPermissionId
  945. }
  946. }
  947. var industrialName string
  948. var subjectName string
  949. //建立首页资源表,与产业的关系
  950. industrialList, e := models.GetIndustrialArticleGroupManagementListByArticleId(sourceId)
  951. if e != nil && e.Error() != utils.ErrNoRow() {
  952. err = errors.New("GetIndustrialArticleGroupManagementListByArticleId, Err: " + e.Error() + "sourceId:" + strconv.Itoa(sourceId))
  953. return
  954. }
  955. for _, v := range industrialList {
  956. industrialName += v.IndustryName
  957. }
  958. //建立首页资源表,与标的 的关系
  959. subjectList, e := models.GetSubjectArticleGroupManagementListByArtcileId(sourceId)
  960. if e != nil && e.Error() != utils.ErrNoRow() {
  961. err = errors.New("GetSubjectArticleGroupManagementList, Err: " + e.Error() + "sourceId:" + strconv.Itoa(sourceId))
  962. return
  963. }
  964. for _, v := range subjectList {
  965. subjectName += v.SubjectName
  966. }
  967. item.SourceId = sourceId
  968. item.Source = source
  969. item.PublishDate = publishDate
  970. item.CreateTime = time.Now()
  971. item.SearchTitle = detail.Title
  972. annotation, e := utils.GetHtmlContentText(detail.Annotation)
  973. if e != nil && e.Error() != utils.ErrNoRow() {
  974. err = errors.New("GetHtmlContentText, Err: " + e.Error() + "sourceId:" + strconv.Itoa(sourceId))
  975. return
  976. }
  977. abstract, e := utils.GetHtmlContentText(detail.Abstract)
  978. if e != nil && e.Error() != utils.ErrNoRow() {
  979. err = errors.New("GetHtmlContentText, Err: " + e.Error() + "sourceId:" + strconv.Itoa(sourceId))
  980. return
  981. }
  982. item.SearchContent = annotation + abstract + detail.FieldName + detail.Stock + industrialName + subjectName
  983. item.SearchOrderTime = detail.PublishDate
  984. if totalData == 0 {
  985. newId, e := models.AddCygxResourceData(item)
  986. if e != nil {
  987. err = errors.New("AddCygxResourceData, Err: " + e.Error())
  988. return
  989. }
  990. resourceDataId = int(newId)
  991. } else {
  992. e = models.UpdateResourceDataByItem(item)
  993. if e != nil {
  994. err = errors.New("UpdateResourceData, Err: " + e.Error())
  995. return
  996. }
  997. sourceDetail, e := models.GetCygxResourceDataByIdAndSource(sourceId, source)
  998. if e != nil {
  999. err = errors.New("UpdateResourceData, Err: " + e.Error())
  1000. return
  1001. }
  1002. resourceDataId = sourceDetail.Id
  1003. }
  1004. //建立首页资源表,与产业的关系
  1005. var industrialItems []*models.CygxResourceDataIndustrialGroupManagement
  1006. for _, v := range industrialList {
  1007. var industrialItem = new(models.CygxResourceDataIndustrialGroupManagement)
  1008. industrialItem.SourceId = sourceId
  1009. industrialItem.Source = source
  1010. industrialItem.IndustrialManagementId = v.IndustrialManagementId
  1011. industrialItem.ResourceDataId = resourceDataId
  1012. industrialItem.CreateTime = time.Now()
  1013. industrialItems = append(industrialItems, industrialItem)
  1014. }
  1015. //建立首页资源表,与标的 的关系
  1016. var subjectItems []*models.CygxResourceDataIndustrialGroupSubject
  1017. for _, v := range subjectList {
  1018. var subjectItem = new(models.CygxResourceDataIndustrialGroupSubject)
  1019. subjectItem.SourceId = sourceId
  1020. subjectItem.Source = source
  1021. subjectItem.IndustrialSubjectId = v.IndustrialSubjectId
  1022. subjectItem.ResourceDataId = resourceDataId
  1023. subjectItem.CreateTime = time.Now()
  1024. subjectItems = append(subjectItems, subjectItem)
  1025. }
  1026. //插入关联信息
  1027. e = models.AddCygxResourceDataGroup(sourceId, source, industrialItems, subjectItems)
  1028. if e != nil {
  1029. err = errors.New("AddCygxResourceDataGroup, Err: " + e.Error())
  1030. return
  1031. }
  1032. }
  1033. return
  1034. }