resource_data.go 37 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109
  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. v.Source = 0 //配合前端这里强制改为 0
  443. v.ArticleResponse = 0 //配合前端这里强制改为 0
  444. //v.Source = utils.CYGX_OBJ_YANXUANSPECIAL
  445. mapItems[fmt.Sprint("ficcreport", v.ReportId)].FiccReport = v
  446. }
  447. //listArticle, e = HandleArticleCategoryImg(listArticle)
  448. //if e != nil {
  449. // err = errors.New("HandleArticleCategoryImg, Err: " + e.Error())
  450. // return
  451. //}
  452. //for _, v := range listArticle {
  453. // //reportInfoItem := new(ficc_report.ReportDetail)
  454. // //reportInfoItem.ReportInfo.ReportId = v.ReportId
  455. // //reportInfoItem.ReportInfo.PublishTime = utils.StrTimeToTime(v.PublishDate)
  456. // //reportInfoItem.ReportInfo.Title = v.Title
  457. // mapItems[fmt.Sprint("ficcreport", v.ArticleId)].FiccReport = v
  458. //
  459. //}
  460. }
  461. for _, vList := range list {
  462. for _, v := range mapItems {
  463. //如果这些类型都为空,那么就不合并
  464. 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 {
  465. continue
  466. }
  467. if v.SourceId == vList.SourceId && v.Source == vList.Source {
  468. items = append(items, v)
  469. }
  470. }
  471. }
  472. return
  473. }
  474. // 同步活动到最新数据表
  475. func UpdateResourceData(sourceId int, source, doType, publishDate string) (err error) {
  476. defer func() {
  477. if err != nil {
  478. go utils.SendAlarmMsg("同步到最新数据表失败,Err:"+err.Error()+"资源ID"+strconv.Itoa(sourceId)+"资源类型"+source+"操作方式"+doType, 3)
  479. }
  480. }()
  481. if doType == "add" {
  482. item := new(models.CygxResourceData)
  483. item.SourceId = sourceId
  484. item.Source = source
  485. item.PublishDate = publishDate
  486. item.CreateTime = time.Now()
  487. _, err = models.AddCygxResourceData(item)
  488. } else if doType == "delete" {
  489. err = models.DeleteResourceData(sourceId, source)
  490. } else if doType == "update" {
  491. err = models.UpdateResourceData(sourceId, source, publishDate)
  492. }
  493. return
  494. }
  495. //func init130() {
  496. // //UpdateNewchartResourceData(5509)
  497. //
  498. // var condition string
  499. // var pars []interface{}
  500. // condition += ` AND publish_status = 1 `
  501. //
  502. // list, e := models.GetChartList(condition, pars, 0, 1000000)
  503. // if e != nil {
  504. // fmt.Println(e)
  505. // return
  506. // }
  507. //
  508. // for _, v := range list {
  509. // fmt.Println(v.ChartId)
  510. // UpdateNewchartResourceData(v.ChartId)
  511. // }
  512. //}
  513. // 更新图表
  514. func UpdateNewchartResourceData(sourceId int) {
  515. var err error
  516. defer func() {
  517. if err != nil {
  518. go utils.SendAlarmMsg("更新图表同步到最新数据表失败,Err:"+err.Error()+"资源ID"+strconv.Itoa(sourceId)+"资源类型", 3)
  519. }
  520. }()
  521. var source = utils.CYGX_OBJ_NEWCHART
  522. var condition string
  523. var pars []interface{}
  524. condition = ` AND chart_id = ? `
  525. pars = append(pars, sourceId)
  526. total, e := models.GetChartCount(condition, pars)
  527. if e != nil {
  528. err = errors.New("GetChartCount, Err: " + e.Error())
  529. return
  530. }
  531. //如果取消发布了就做删除处理
  532. if total == 0 {
  533. e = models.DeleteResourceData(sourceId, source)
  534. if e != nil {
  535. err = errors.New("DeleteResourceData, Err: " + e.Error())
  536. return
  537. }
  538. } else {
  539. //判断是否存在,如果不存在就新增,存在就更新
  540. totalData, e := models.GetCygxResourceDataBySourceAndIdCount(sourceId, source)
  541. if e != nil {
  542. err = errors.New("GetCygxResourceDataBySourceAndIdCount, Err: " + e.Error())
  543. return
  544. }
  545. detail, e := models.GetChartDetailByChartId(sourceId)
  546. if e != nil {
  547. err = errors.New("GetArticleDetailById, Err: " + e.Error())
  548. return
  549. }
  550. publishDate := detail.CreateDate
  551. item := new(models.CygxResourceData)
  552. item.SourceId = sourceId
  553. item.Source = source
  554. item.PublishDate = publishDate
  555. item.CreateTime = time.Now()
  556. item.SearchTitle = detail.Title
  557. item.SearchContent = ""
  558. item.SearchOrderTime = detail.CreateDate
  559. if totalData == 0 {
  560. _, e = models.AddCygxResourceData(item)
  561. if e != nil {
  562. err = errors.New("AddCygxResourceData, Err: " + e.Error())
  563. return
  564. }
  565. } else {
  566. e = models.UpdateResourceDataByItem(item)
  567. if e != nil {
  568. err = errors.New("UpdateResourceData, Err: " + e.Error())
  569. return
  570. }
  571. }
  572. }
  573. return
  574. }
  575. // 批量删除最新图表数据
  576. func Deletenewchart(chartIdsDelete []int) (err error) {
  577. defer func() {
  578. if err != nil {
  579. fmt.Println(err)
  580. go utils.SendAlarmMsg("批量删除最新图表数据,Err:"+err.Error(), 3)
  581. }
  582. }()
  583. lenchartIdsDelete := len(chartIdsDelete)
  584. if lenchartIdsDelete == 0 {
  585. return
  586. }
  587. var condition string
  588. var pars []interface{}
  589. condition += ` AND source = 'newchart' AND source_id IN (` + utils.GetOrmInReplace(lenchartIdsDelete) + `) `
  590. pars = append(pars, chartIdsDelete)
  591. err = models.DeleteResourceDataList(condition, pars)
  592. return
  593. }
  594. //func init() {
  595. // UpdateArticleResourceData(9050)
  596. //}
  597. // 更新文章
  598. func UpdateArticleResourceData(sourceId int) {
  599. var err error
  600. defer func() {
  601. if err != nil {
  602. fmt.Println("err:", err)
  603. go utils.SendAlarmMsg("更新文章 失败,UpdateArticleResourceData Err:"+err.Error()+"资源ID"+strconv.Itoa(sourceId), 3)
  604. }
  605. }()
  606. var source = utils.CYGX_OBJ_ARTICLE
  607. var condition string
  608. var pars []interface{}
  609. condition = ` AND publish_status = 1 AND article_id = ? `
  610. pars = append(pars, sourceId)
  611. total, e := models.GetCygxArticleCount(condition, pars)
  612. if e != nil {
  613. err = errors.New("GetCygxReportSelection, Err: " + err.Error())
  614. return
  615. }
  616. //如果取消发布了就做删除处理
  617. if total == 0 {
  618. e = models.DeleteResourceData(sourceId, source)
  619. if e != nil {
  620. err = errors.New("DeleteResourceData, Err: " + e.Error())
  621. return
  622. }
  623. //删除 cygx_resource_data 表关联的产业ID,标的ID
  624. e = models.DeleteCygxResourceDataGroup(sourceId, source)
  625. if e != nil {
  626. err = errors.New("DeleteCygxResourceDataGroup, Err: " + e.Error())
  627. return
  628. }
  629. } else {
  630. //判断是否存在,如果不存在就新增,存在就更新
  631. totalData, e := models.GetCygxResourceDataBySourceAndIdCount(sourceId, source)
  632. if e != nil {
  633. err = errors.New("GetCygxReportSelectionBySourceAndId, Err: " + e.Error())
  634. return
  635. }
  636. detail, e := models.GetArticleDetailById(sourceId)
  637. if e != nil {
  638. err = errors.New("GetCygxReportSelectionInfoById, Err: " + e.Error())
  639. return
  640. }
  641. var resourceDataId int
  642. publishDate := time.Now().Format(utils.FormatDateTime)
  643. item := new(models.CygxResourceData)
  644. if detail.ArticleTypeId > 0 {
  645. item.SearchTag = detail.ArticleTypeName // 研选类型名称
  646. } else {
  647. item.SearchTag = detail.MatchTypeName
  648. if detail.SubCategoryName == "产业跟踪" && detail.MatchTypeName == "行业深度" { //需求池973:查研观向首页标签【深度】下,过滤【产业跟踪】系列的报告。新报告不再写入此标签下,存量报告也去掉
  649. item.SearchTag = ""
  650. }
  651. //获取文章分类详情
  652. detailCategory, _ := models.GetCygxReportMappingCelueMaxDetailByCategoryId(detail.CategoryId)
  653. if detailCategory != nil {
  654. item.ChartPermissionId = detailCategory.ChartPermissionId
  655. }
  656. }
  657. var industrialName string
  658. var subjectName string
  659. //建立首页资源表,与产业的关系
  660. industrialList, e := models.GetIndustrialArticleGroupManagementListByArticleId(sourceId)
  661. if e != nil && e.Error() != utils.ErrNoRow() {
  662. err = errors.New("GetIndustrialArticleGroupManagementListByArticleId, Err: " + e.Error() + "sourceId:" + strconv.Itoa(sourceId))
  663. return
  664. }
  665. for _, v := range industrialList {
  666. industrialName += v.IndustryName
  667. }
  668. //建立首页资源表,与标的 的关系
  669. subjectList, e := models.GetSubjectArticleGroupManagementListByArtcileId(sourceId)
  670. if e != nil && e.Error() != utils.ErrNoRow() {
  671. err = errors.New("GetSubjectArticleGroupManagementList, Err: " + e.Error() + "sourceId:" + strconv.Itoa(sourceId))
  672. return
  673. }
  674. for _, v := range subjectList {
  675. subjectName += v.SubjectName
  676. }
  677. item.SourceId = sourceId
  678. item.Source = source
  679. item.PublishDate = publishDate
  680. item.CreateTime = time.Now()
  681. item.SearchTitle = detail.Title
  682. annotation, e := utils.GetHtmlContentText(detail.Annotation)
  683. if e != nil && e.Error() != utils.ErrNoRow() {
  684. err = errors.New("GetHtmlContentText, Err: " + e.Error() + "sourceId:" + strconv.Itoa(sourceId))
  685. return
  686. }
  687. abstract, e := utils.GetHtmlContentText(detail.Abstract)
  688. if e != nil && e.Error() != utils.ErrNoRow() {
  689. err = errors.New("GetHtmlContentText, Err: " + e.Error() + "sourceId:" + strconv.Itoa(sourceId))
  690. return
  691. }
  692. item.SearchContent = annotation + abstract + detail.FieldName + detail.Stock + industrialName + subjectName
  693. item.SearchOrderTime = detail.PublishDate
  694. if totalData == 0 {
  695. newId, e := models.AddCygxResourceData(item)
  696. if e != nil {
  697. err = errors.New("AddCygxResourceData, Err: " + e.Error())
  698. return
  699. }
  700. resourceDataId = int(newId)
  701. } else {
  702. e = models.UpdateResourceDataByItem(item)
  703. if e != nil {
  704. err = errors.New("UpdateResourceData, Err: " + e.Error())
  705. return
  706. }
  707. sourceDetail, e := models.GetCygxResourceDataByIdAndSource(sourceId, source)
  708. if e != nil {
  709. err = errors.New("UpdateResourceData, Err: " + e.Error())
  710. return
  711. }
  712. resourceDataId = sourceDetail.Id
  713. }
  714. //建立首页资源表,与产业的关系
  715. var industrialItems []*models.CygxResourceDataIndustrialGroupManagement
  716. for _, v := range industrialList {
  717. var industrialItem = new(models.CygxResourceDataIndustrialGroupManagement)
  718. industrialItem.SourceId = sourceId
  719. industrialItem.Source = source
  720. industrialItem.IndustrialManagementId = v.IndustrialManagementId
  721. industrialItem.ResourceDataId = resourceDataId
  722. industrialItem.CreateTime = time.Now()
  723. industrialItems = append(industrialItems, industrialItem)
  724. }
  725. //建立首页资源表,与标的 的关系
  726. var subjectItems []*models.CygxResourceDataIndustrialGroupSubject
  727. for _, v := range subjectList {
  728. var subjectItem = new(models.CygxResourceDataIndustrialGroupSubject)
  729. subjectItem.SourceId = sourceId
  730. subjectItem.Source = source
  731. subjectItem.IndustrialSubjectId = v.IndustrialSubjectId
  732. subjectItem.ResourceDataId = resourceDataId
  733. subjectItem.CreateTime = time.Now()
  734. subjectItems = append(subjectItems, subjectItem)
  735. }
  736. //插入关联信息
  737. e = models.AddCygxResourceDataGroup(sourceId, source, industrialItems, subjectItems)
  738. if e != nil {
  739. err = errors.New("AddCygxResourceDataGroup, Err: " + e.Error())
  740. return
  741. }
  742. }
  743. return
  744. }
  745. // 更新产业资源包
  746. func UpdateComprehensiveIndustrialResourceData(itemSource *ElasticComprehensiveDetail) {
  747. var err error
  748. defer func() {
  749. if err != nil {
  750. go utils.SendAlarmMsg("更新产业资源包到最新数据表失败,Err:"+err.Error()+"资源ID"+strconv.Itoa(itemSource.SourceId), 3)
  751. }
  752. }()
  753. sourceId := itemSource.SourceId
  754. var source = itemSource.Source
  755. //判断是否存在,如果不存在就新增,存在就更新
  756. totalData, e := models.GetCygxResourceDataBySourceAndIdCount(sourceId, source)
  757. if e != nil {
  758. err = errors.New("GetCygxResourceDataBySourceAndIdCount, Err: " + e.Error())
  759. return
  760. }
  761. item := new(models.CygxResourceData)
  762. item.SourceId = sourceId
  763. item.Source = source
  764. item.PublishDate = itemSource.PublishDate
  765. item.CreateTime = time.Now()
  766. item.SearchTitle = itemSource.IndustryName + itemSource.SubjectNames
  767. item.SearchContent = ""
  768. item.SearchOrderTime = itemSource.PublishDate
  769. if totalData == 0 {
  770. _, e = models.AddCygxResourceData(item)
  771. if e != nil {
  772. err = errors.New("AddCygxResourceData, Err: " + e.Error())
  773. return
  774. }
  775. } else {
  776. e = models.UpdateResourceDataByItem(item)
  777. if e != nil {
  778. err = errors.New("UpdateResourceData, Err: " + e.Error())
  779. return
  780. }
  781. }
  782. return
  783. }
  784. // 更新研选专栏 写入首页最新 cygx_resource_data 表
  785. func UpdateYanxuanSpecialResourceData(sourceId int) {
  786. var err error
  787. defer func() {
  788. if err != nil {
  789. go utils.SendAlarmMsg(fmt.Sprint("更新研选专栏失败sourceId: ", sourceId, "ErrMsg", err.Error()), 2)
  790. }
  791. }()
  792. var source = utils.CYGX_OBJ_YANXUANSPECIAL
  793. var condition string
  794. var pars []interface{}
  795. condition = ` AND status = 3 AND id = ? `
  796. pars = append(pars, sourceId)
  797. total, e := models.GetCygxYanxuanSpecialCount(condition, pars)
  798. if e != nil {
  799. err = errors.New("GetCygxYanxuanSpecialCount, Err: " + e.Error())
  800. return
  801. }
  802. //如果取消发布了就做删除处理
  803. if total == 0 {
  804. e = models.DeleteResourceData(sourceId, source)
  805. if e != nil {
  806. err = errors.New("DeleteResourceData, Err: " + e.Error())
  807. return
  808. }
  809. } else {
  810. //判断是否存在,如果不存在就新增,存在就更新
  811. totalData, e := models.GetCygxResourceDataBySourceAndIdCount(sourceId, source)
  812. if e != nil {
  813. err = errors.New("GetCygxReportSelectionBySourceAndId, Err: " + e.Error())
  814. return
  815. }
  816. detail, e := models.GetYanxuanSpecialBySpecialId(sourceId)
  817. if e != nil {
  818. err = errors.New("GetYanxuanSpecialBySpecialId, Err: " + e.Error())
  819. return
  820. }
  821. publishDate := detail.PublishTime
  822. item := new(models.CygxResourceData)
  823. item.SourceId = sourceId
  824. item.Source = source
  825. item.PublishDate = publishDate
  826. item.CreateTime = time.Now()
  827. item.SearchTitle = detail.Title
  828. item.SearchContent = ""
  829. item.SearchOrderTime = publishDate
  830. item.ChartPermissionId = utils.CHART_PERMISSION_ID_YANXUAN
  831. if totalData == 0 {
  832. _, e := models.AddCygxResourceData(item)
  833. if e != nil {
  834. err = errors.New("AddCygxResourceData, Err: " + e.Error())
  835. return
  836. }
  837. } else {
  838. e = models.UpdateResourceDataByItem(item)
  839. if e != nil {
  840. err = errors.New("UpdateResourceDataByItem, Err: " + e.Error())
  841. return
  842. }
  843. }
  844. }
  845. return
  846. }
  847. func initsql12_17() {
  848. listIndustrialResourceIds, e := models.GetSearchResourceList(0, " AND article_type_id > 0 ", 0, 9999)
  849. if e != nil {
  850. fmt.Println(e)
  851. return
  852. }
  853. var industrialResourceIdsHz []int
  854. for _, v := range listIndustrialResourceIds {
  855. industrialResourceIdsHz = append(industrialResourceIdsHz, v.IndustrialManagementId)
  856. }
  857. //date_format( MAX( a.publish_date ), '%Y-%m-%d' ) AS publish_date,
  858. //合并产业关联的标的
  859. listSubjcet, e := models.GetIndustrialSubjectAllByIndustrialId(industrialResourceIdsHz)
  860. if e != nil {
  861. fmt.Println(e)
  862. return
  863. }
  864. mapIndustrial := make(map[string]int)
  865. for _, v := range listSubjcet {
  866. for k2, v2 := range listIndustrialResourceIds {
  867. if v2.IndustrialManagementId == v.IndustrialManagementId && mapIndustrial[fmt.Sprint(v2.IndustrialManagementId, "Hz", v.SubjectName)] == 0 {
  868. listIndustrialResourceIds[k2].IndustrialSubjectList = append(listIndustrialResourceIds[k2].IndustrialSubjectList, v)
  869. }
  870. }
  871. }
  872. //industrialsource := "industrialsourceHz"
  873. industrialsource := "industrialsourceYx"
  874. for _, v := range listIndustrialResourceIds {
  875. item := new(ElasticComprehensiveDetail)
  876. item.SourceId = v.IndustrialManagementId
  877. item.Source = industrialsource
  878. item.IndustryName = v.IndustryName
  879. var SubjectName []string
  880. for _, vN := range v.IndustrialSubjectList {
  881. SubjectName = append(SubjectName, vN.SubjectName)
  882. }
  883. item.SubjectNames = strings.Join(SubjectName, ",")
  884. item.PublishDate = v.PublishDate
  885. fmt.Println(item)
  886. UpdateComprehensiveIndustrialResourceData(item)
  887. }
  888. return
  889. }
  890. // 更新FICC研报
  891. func UpdateFICCReportResourceData(sourceId int) {
  892. var err error
  893. defer func() {
  894. if err != nil {
  895. fmt.Println("err:", err)
  896. go utils.SendAlarmMsg("更新文章 失败,UpdateArticleResourceData Err:"+err.Error()+"资源ID"+strconv.Itoa(sourceId), 3)
  897. }
  898. }()
  899. var source = utils.CYGX_OBJ_FICC_REPORT
  900. var condition string
  901. var pars []interface{}
  902. condition = ` AND publish_status = 1 AND report_id = ? `
  903. pars = append(pars, sourceId)
  904. total, e := models.GetCygxArticleCount(condition, pars)
  905. if e != nil {
  906. err = errors.New("GetCygxArticleCount, Err: " + err.Error())
  907. return
  908. }
  909. //如果取消发布了就做删除处理
  910. if total == 0 {
  911. e = models.DeleteResourceData(sourceId, source)
  912. if e != nil {
  913. err = errors.New("DeleteResourceData, Err: " + e.Error())
  914. return
  915. }
  916. //删除 cygx_resource_data 表关联的产业ID,标的ID
  917. e = models.DeleteCygxResourceDataGroup(sourceId, source)
  918. if e != nil {
  919. err = errors.New("DeleteCygxResourceDataGroup, Err: " + e.Error())
  920. return
  921. }
  922. } else {
  923. //判断是否存在,如果不存在就新增,存在就更新
  924. totalData, e := models.GetCygxResourceDataBySourceAndIdCount(sourceId, source)
  925. if e != nil {
  926. err = errors.New("GetCygxReportSelectionBySourceAndId, Err: " + e.Error())
  927. return
  928. }
  929. detail, e := models.GetArticleDetailByReportId(sourceId)
  930. if e != nil {
  931. err = errors.New("GetArticleDetailByReportId, Err: " + e.Error())
  932. return
  933. }
  934. var resourceDataId int
  935. publishDate := time.Now().Format(utils.FormatDateTime)
  936. item := new(models.CygxResourceData)
  937. if detail.ArticleTypeId > 0 {
  938. item.SearchTag = detail.ArticleTypeName // 研选类型名称
  939. } else {
  940. item.SearchTag = detail.MatchTypeName
  941. if detail.SubCategoryName == "产业跟踪" && detail.MatchTypeName == "行业深度" { //需求池973:查研观向首页标签【深度】下,过滤【产业跟踪】系列的报告。新报告不再写入此标签下,存量报告也去掉
  942. item.SearchTag = ""
  943. }
  944. //获取文章分类详情
  945. detailCategory, _ := models.GetCygxReportMappingCelueMaxDetailByCategoryId(detail.CategoryId)
  946. if detailCategory != nil {
  947. item.ChartPermissionId = detailCategory.ChartPermissionId
  948. }
  949. }
  950. var industrialName string
  951. var subjectName string
  952. //建立首页资源表,与产业的关系
  953. industrialList, e := models.GetIndustrialArticleGroupManagementListByArticleId(sourceId)
  954. if e != nil && e.Error() != utils.ErrNoRow() {
  955. err = errors.New("GetIndustrialArticleGroupManagementListByArticleId, Err: " + e.Error() + "sourceId:" + strconv.Itoa(sourceId))
  956. return
  957. }
  958. for _, v := range industrialList {
  959. industrialName += v.IndustryName
  960. }
  961. //建立首页资源表,与标的 的关系
  962. subjectList, e := models.GetSubjectArticleGroupManagementListByArtcileId(sourceId)
  963. if e != nil && e.Error() != utils.ErrNoRow() {
  964. err = errors.New("GetSubjectArticleGroupManagementList, Err: " + e.Error() + "sourceId:" + strconv.Itoa(sourceId))
  965. return
  966. }
  967. for _, v := range subjectList {
  968. subjectName += v.SubjectName
  969. }
  970. item.SourceId = sourceId
  971. item.Source = source
  972. item.PublishDate = publishDate
  973. item.CreateTime = time.Now()
  974. item.SearchTitle = detail.Title
  975. annotation, e := utils.GetHtmlContentText(detail.Annotation)
  976. if e != nil && e.Error() != utils.ErrNoRow() {
  977. err = errors.New("GetHtmlContentText, Err: " + e.Error() + "sourceId:" + strconv.Itoa(sourceId))
  978. return
  979. }
  980. abstract, e := utils.GetHtmlContentText(detail.Abstract)
  981. if e != nil && e.Error() != utils.ErrNoRow() {
  982. err = errors.New("GetHtmlContentText, Err: " + e.Error() + "sourceId:" + strconv.Itoa(sourceId))
  983. return
  984. }
  985. item.SearchContent = annotation + abstract + detail.FieldName + detail.Stock + industrialName + subjectName
  986. item.SearchOrderTime = detail.PublishDate
  987. if totalData == 0 {
  988. newId, e := models.AddCygxResourceData(item)
  989. if e != nil {
  990. err = errors.New("AddCygxResourceData, Err: " + e.Error())
  991. return
  992. }
  993. resourceDataId = int(newId)
  994. } else {
  995. sourceDetail, e := models.GetCygxResourceDataByIdAndSource(sourceId, source)
  996. if e != nil {
  997. err = errors.New("UpdateResourceData, Err: " + e.Error())
  998. return
  999. }
  1000. item.PublishDate = sourceDetail.PublishDate
  1001. item.SearchOrderTime = sourceDetail.SearchOrderTime
  1002. e = models.UpdateResourceDataByItem(item)
  1003. if e != nil {
  1004. err = errors.New("UpdateResourceData, Err: " + e.Error())
  1005. return
  1006. }
  1007. resourceDataId = sourceDetail.Id
  1008. }
  1009. //建立首页资源表,与产业的关系
  1010. var industrialItems []*models.CygxResourceDataIndustrialGroupManagement
  1011. for _, v := range industrialList {
  1012. var industrialItem = new(models.CygxResourceDataIndustrialGroupManagement)
  1013. industrialItem.SourceId = sourceId
  1014. industrialItem.Source = source
  1015. industrialItem.IndustrialManagementId = v.IndustrialManagementId
  1016. industrialItem.ResourceDataId = resourceDataId
  1017. industrialItem.CreateTime = time.Now()
  1018. industrialItems = append(industrialItems, industrialItem)
  1019. }
  1020. //建立首页资源表,与标的 的关系
  1021. var subjectItems []*models.CygxResourceDataIndustrialGroupSubject
  1022. for _, v := range subjectList {
  1023. var subjectItem = new(models.CygxResourceDataIndustrialGroupSubject)
  1024. subjectItem.SourceId = sourceId
  1025. subjectItem.Source = source
  1026. subjectItem.IndustrialSubjectId = v.IndustrialSubjectId
  1027. subjectItem.ResourceDataId = resourceDataId
  1028. subjectItem.CreateTime = time.Now()
  1029. subjectItems = append(subjectItems, subjectItem)
  1030. }
  1031. //插入关联信息
  1032. e = models.AddCygxResourceDataGroup(sourceId, source, industrialItems, subjectItems)
  1033. if e != nil {
  1034. err = errors.New("AddCygxResourceDataGroup, Err: " + e.Error())
  1035. return
  1036. }
  1037. }
  1038. return
  1039. }