init_10.5.1.go 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457
  1. package services
  2. import (
  3. "fmt"
  4. "hongze/hongze_cygx/models"
  5. "hongze/hongze_cygx/utils"
  6. "time"
  7. )
  8. //10.5.1版本上线需要更新的数据
  9. func init1111() {
  10. var condition string
  11. var pars []interface{}
  12. var err error
  13. fmt.Print()
  14. var topCond string
  15. var topPars []interface{}
  16. toplist, err := models.GetTopOneMonthArtReadNumIndustryAll(topCond, topPars)
  17. if err != nil {
  18. return
  19. }
  20. mapIndustryName := make(map[int]string)
  21. for _, v := range toplist {
  22. mapIndustryName[v.IndustrialManagementId] = v.IndustryName
  23. }
  24. fmt.Println(mapIndustryName)
  25. //处理上周纪要汇总
  26. condition = ` AND type = 1 `
  27. list, err := models.GetCygxIndustryFllowListByCon(condition, pars, 0, 100000)
  28. if err != nil {
  29. fmt.Println(err)
  30. }
  31. var items []*models.CygxUserLabel
  32. for _, user := range list {
  33. item := new(models.CygxUserLabel)
  34. item.UserId = user.UserId
  35. item.CompanyId = user.CompanyId
  36. item.RealName = user.RealName
  37. item.Mobile = user.Mobile
  38. item.Email = user.Email
  39. item.Label = mapIndustryName[user.IndustrialManagementId]
  40. item.SourceId = user.IndustrialManagementId
  41. item.Source = 1
  42. item.IsFollow = 1
  43. item.CreateTime = time.Now()
  44. item.ModifyTime = time.Now()
  45. items = append(items, item)
  46. if len(items)%5000 == 0 {
  47. err = models.CygxUserLabelMulti(items)
  48. fmt.Println(err)
  49. items = make([]*models.CygxUserLabel, 0)
  50. }
  51. }
  52. if len(items) > 0 {
  53. err = models.CygxUserLabelMulti(items)
  54. fmt.Println(err, "555")
  55. }
  56. }
  57. func init123() {
  58. var condition string
  59. var pars []interface{}
  60. var err error
  61. fmt.Print()
  62. var topCond string
  63. var topPars []interface{}
  64. toplist, err := models.GetCygxReportMappingCygxByCon(topCond, topPars, 0, 0)
  65. if err != nil {
  66. return
  67. }
  68. mapIndustryName := make(map[int]string)
  69. for _, v := range toplist {
  70. mapIndustryName[v.Id] = v.MatchTypeName
  71. }
  72. fmt.Println(mapIndustryName)
  73. condition = ` `
  74. list, err := models.GetCygxXzsChooseCategoryListByCon(condition, pars, 0, 100000)
  75. if err != nil {
  76. fmt.Println(err)
  77. }
  78. var items []*models.CygxUserLabel
  79. for _, user := range list {
  80. if user.IdCygx == 0 {
  81. continue
  82. }
  83. item := new(models.CygxUserLabel)
  84. item.UserId = user.UserId
  85. item.CompanyId = user.CompanyId
  86. item.RealName = user.RealName
  87. item.Mobile = user.Mobile
  88. item.Email = user.Email
  89. item.Label = mapIndustryName[user.IdCygx]
  90. item.SourceId = user.IdCygx
  91. item.Source = 2
  92. item.IsFollow = 1
  93. item.CreateTime = time.Now()
  94. item.ModifyTime = time.Now()
  95. fmt.Println(item.SourceId)
  96. items = append(items, item)
  97. if len(items)%5000 == 0 {
  98. err = models.CygxUserLabelMulti(items)
  99. fmt.Println(err)
  100. items = make([]*models.CygxUserLabel, 0)
  101. }
  102. }
  103. if len(items) > 0 {
  104. err = models.CygxUserLabelMulti(items)
  105. fmt.Println(err, "555")
  106. }
  107. }
  108. func init5333() {
  109. var condition string
  110. var pars []interface{}
  111. var err error
  112. fmt.Print()
  113. var topCond string
  114. var topPars []interface{}
  115. toplist, err := models.GetTopOneMonthArtReadNumIndustryAll(topCond, topPars)
  116. if err != nil {
  117. return
  118. }
  119. mapIndustryName := make(map[int]string)
  120. for _, v := range toplist {
  121. mapIndustryName[v.IndustrialManagementId] = v.IndustryName
  122. }
  123. fmt.Println(mapIndustryName)
  124. condition = ` AND activity_time > '2022-11-25 00:00:00' AND publish_status = 1 `
  125. listAct, err := models.GetCygxActivityList(condition, pars, 0, 100000)
  126. if err != nil {
  127. fmt.Println(err)
  128. }
  129. var items []*models.CygxUserLabelActivity
  130. for _, v := range listAct {
  131. fmt.Println(v.ActivityTime)
  132. var condition1 string
  133. var pars1 []interface{}
  134. condition1 = ` AND activity_id = ? `
  135. pars1 = append(pars1, v.ActivityId)
  136. total, e := models.GetCygxIndustrialActivityGroupManagementCount(condition1+" AND source = 1 ", pars1)
  137. if e != nil {
  138. fmt.Println(e)
  139. return
  140. }
  141. if total == 0 {
  142. continue
  143. }
  144. industrialList, e := models.GetCygxIndustrialActivityGroupManagementList(condition1+" AND source = 1 ", pars1)
  145. if e != nil {
  146. fmt.Println(e)
  147. return
  148. }
  149. pars = make([]interface{}, 0)
  150. condition = ` AND activity_id = ? AND is_meeting = 1 `
  151. pars = append(pars, v.ActivityId)
  152. signUpList, err := models.GetSignupDetailBySignup(condition, pars)
  153. if err != nil && err.Error() != utils.ErrNoRow() {
  154. return
  155. }
  156. for _, vi := range industrialList {
  157. for _, user := range signUpList {
  158. item := new(models.CygxUserLabelActivity)
  159. item.UserId = user.UserId
  160. item.CompanyId = user.CompanyId
  161. item.RealName = user.RealName
  162. item.Mobile = user.Mobile
  163. item.Email = user.Email
  164. item.ActivityId = v.ActivityId
  165. item.IndustrialManagementId = vi.IndustrialManagementId
  166. item.Label = mapIndustryName[vi.IndustrialManagementId]
  167. item.CreateTime = utils.StrTimeToTime(v.ActivityTime)
  168. item.ModifyTime = time.Now()
  169. items = append(items, item)
  170. if len(items)%5000 == 0 {
  171. _, err = models.AddCygxUserLabelActivityList(items)
  172. fmt.Println(err)
  173. items = make([]*models.CygxUserLabelActivity, 0)
  174. }
  175. }
  176. }
  177. }
  178. fmt.Println(len(items))
  179. if len(items) > 0 {
  180. _, err = models.AddCygxUserLabelActivityList(items)
  181. fmt.Println(err, "555")
  182. }
  183. }
  184. func init5444() {
  185. var condition string
  186. var pars []interface{}
  187. var err error
  188. fmt.Print()
  189. var topCond string
  190. var topPars []interface{}
  191. toplist, err := models.GetTopOneMonthArtReadNumIndustryAll(topCond, topPars)
  192. if err != nil {
  193. return
  194. }
  195. mapIndustryName := make(map[int]string)
  196. for _, v := range toplist {
  197. mapIndustryName[v.IndustrialManagementId] = v.IndustryName
  198. }
  199. fmt.Println(mapIndustryName)
  200. condition = ` AND is_meeting = 1 `
  201. listAct, err := models.GetCygxActivitySpecialmeetingDetailList(condition, pars)
  202. if err != nil {
  203. fmt.Println(err)
  204. }
  205. var items []*models.CygxUserLabelActivitySpecial
  206. for _, user := range listAct {
  207. var condition1 string
  208. var pars1 []interface{}
  209. condition1 = ` AND activity_id = ? `
  210. pars1 = append(pars1, user.ActivityId)
  211. total, e := models.GetCygxIndustrialActivityGroupManagementCount(condition1+" AND source = 2 ", pars1)
  212. if e != nil {
  213. fmt.Println(e)
  214. return
  215. }
  216. if total == 0 {
  217. continue
  218. }
  219. industrialList, e := models.GetCygxIndustrialActivityGroupManagementList(condition1+" AND source = 2 ", pars1)
  220. if e != nil {
  221. fmt.Println(e)
  222. return
  223. }
  224. for _, vi := range industrialList {
  225. item := new(models.CygxUserLabelActivitySpecial)
  226. item.UserId = user.UserId
  227. item.CompanyId = user.CompanyId
  228. item.RealName = user.RealName
  229. item.Mobile = user.Mobile
  230. item.Email = user.Email
  231. item.ActivityId = user.ActivityId
  232. item.IndustrialManagementId = vi.IndustrialManagementId
  233. item.Label = mapIndustryName[vi.IndustrialManagementId]
  234. item.CreateTime = utils.StrTimeToTime(user.CreateTime)
  235. item.ModifyTime = time.Now()
  236. items = append(items, item)
  237. if len(items)%5000 == 0 {
  238. _, err = models.AddCygxUserLabelActivitySpecialList(items)
  239. fmt.Println(err)
  240. items = make([]*models.CygxUserLabelActivitySpecial, 0)
  241. }
  242. }
  243. }
  244. fmt.Println(len(items))
  245. if len(items) > 0 {
  246. _, err = models.AddCygxUserLabelActivitySpecialList(items)
  247. fmt.Println(err, "555")
  248. }
  249. }
  250. func init5555() {
  251. var condition string
  252. var pars []interface{}
  253. var err error
  254. fmt.Print()
  255. var topCond string
  256. var topPars []interface{}
  257. toplist, err := models.GetTopOneMonthArtReadNumIndustryAll(topCond, topPars)
  258. if err != nil {
  259. return
  260. }
  261. mapIndustryName := make(map[int]string)
  262. for _, v := range toplist {
  263. mapIndustryName[v.IndustrialManagementId] = v.IndustryName
  264. }
  265. //fmt.Println(mapIndustryName)
  266. condition = ` AND stop_time > 3 AND create_time > '2022-11-25 00:00:00' GROUP BY article_id `
  267. //condition = ` AND stop_time > 4 AND create_time > '2023-04-25 00:00:00' GROUP BY article_id `
  268. listArtGroup, err := models.GetCygxArticleHistoryRecordNewpvList(condition, pars)
  269. if err != nil {
  270. fmt.Println(err)
  271. }
  272. fmt.Println(len(listArtGroup))
  273. var source int
  274. itemsMap := make(map[int][]*models.CygxUserLabel)
  275. for _, v := range listArtGroup {
  276. fmt.Println(v.ArticleId)
  277. var items []*models.CygxUserLabel
  278. articleId := v.ArticleId
  279. var condition string
  280. var pars []interface{}
  281. condition = ` AND article_id = ? `
  282. pars = append(pars, v.ArticleId)
  283. industrialList, e := models.GetIndustrialArticleGroupManagementList(condition, pars)
  284. if e != nil && e.Error() != utils.ErrNoRow() {
  285. fmt.Println(e)
  286. continue
  287. //return
  288. }
  289. if len(industrialList) == 0 {
  290. //如果没有行产业归类就按照行业报告处理
  291. source = 2
  292. detailArticle, e := models.GetArticleDetailById(articleId)
  293. if e != nil {
  294. fmt.Println(e)
  295. continue
  296. //return
  297. }
  298. labelDetail, e := models.GetdetailByCategoryIdLabel(detailArticle.CategoryId)
  299. if e != nil {
  300. fmt.Println(e)
  301. continue
  302. //return
  303. }
  304. label := labelDetail.MatchTypeName
  305. industrialManagementId := labelDetail.Id
  306. item := new(models.CygxUserLabel)
  307. item.Label = label
  308. item.SourceId = industrialManagementId
  309. item.Source = source
  310. item.Weight = 1
  311. item.CreateTime = time.Now()
  312. item.ModifyTime = time.Now()
  313. items = append(items, item)
  314. } else {
  315. //如果有行产业归类就按照产业报告处理
  316. var topCond string
  317. var topPars []interface{}
  318. var industrialManagementIds []int
  319. for _, v := range industrialList {
  320. industrialManagementIds = append(industrialManagementIds, v.IndustrialManagementId)
  321. }
  322. idsLen := len(industrialManagementIds)
  323. if idsLen > 0 {
  324. topCond = ` AND industrial_management_id IN (` + utils.GetOrmInReplace(idsLen) + `)`
  325. topPars = append(topPars, industrialManagementIds)
  326. } else {
  327. continue
  328. }
  329. industrNamelist, e := models.GetTopOneMonthArtReadNumIndustryAll(topCond, topPars)
  330. if e != nil {
  331. fmt.Println(e)
  332. continue
  333. }
  334. source = 1
  335. for _, v := range industrNamelist {
  336. label := v.IndustryName
  337. industrialManagementId := v.IndustrialManagementId
  338. item := new(models.CygxUserLabel)
  339. item.Label = label
  340. item.SourceId = industrialManagementId
  341. item.Source = source
  342. item.Weight = 1
  343. item.CreateTime = time.Now()
  344. item.ModifyTime = time.Now()
  345. items = append(items, item)
  346. }
  347. //for _, vi := range industrialList {
  348. // for _, user := range signUpList {
  349. // item := new(models.CygxUserLabelActivity)
  350. // item.UserId = user.UserId
  351. // item.CompanyId = user.CompanyId
  352. // item.RealName = user.RealName
  353. // item.Mobile = user.Mobile
  354. // item.Email = user.Email
  355. // item.ActivityId = v.ActivityId
  356. // item.IndustrialManagementId = vi.IndustrialManagementId
  357. // item.Label = mapIndustryName[vi.IndustrialManagementId]
  358. // item.CreateTime = utils.StrTimeToTime(v.ActivityTime)
  359. // item.ModifyTime = time.Now()
  360. // items = append(items, item)
  361. // if len(items)%50 == 0 {
  362. // _, err = models.AddCygxUserLabelActivityList(items)
  363. // fmt.Println(err)
  364. // items = make([]*models.CygxUserLabelActivity, 0)
  365. // }
  366. // }
  367. //}
  368. itemsMap[articleId] = items
  369. }
  370. }
  371. condition = ` AND stop_time > 3 AND create_time > '2022-11-25 00:00:00' `
  372. //condition = ` AND stop_time > 4 AND create_time > '2023-4-25 00:00:00' `
  373. listArt, err := models.GetCygxArticleHistoryRecordNewpvList(condition, pars)
  374. if err != nil {
  375. fmt.Println(err)
  376. }
  377. var items []*models.CygxUserLabelArticle
  378. fmt.Println(len(listArt))
  379. for _, user := range listArt {
  380. if len(itemsMap[user.ArticleId]) > 0 {
  381. for k2, vlsit := range itemsMap {
  382. if k2 != user.ArticleId {
  383. continue
  384. }
  385. for _, vm := range vlsit {
  386. //if user.ArticleId == 8365 {
  387. // fmt.Println("k", k, "_k2:", k2, "_k3:", k3)
  388. // fmt.Println(vm.Label)
  389. //}
  390. item := new(models.CygxUserLabelArticle)
  391. item.UserId = user.UserId
  392. item.ArticleId = user.ArticleId
  393. item.CompanyId = user.CompanyId
  394. //item.RealName = user.R
  395. item.Mobile = user.Mobile
  396. item.Email = user.Email
  397. item.Label = vm.Label
  398. item.SourceId = vm.SourceId
  399. item.Source = vm.Source
  400. item.CreateTime = user.CreateTime
  401. item.ModifyTime = time.Now()
  402. items = append(items, item)
  403. if len(items)%5000 == 0 {
  404. _, err = models.AddCygxUserLabelArticleList(items)
  405. fmt.Println(err)
  406. items = make([]*models.CygxUserLabelArticle, 0)
  407. }
  408. }
  409. }
  410. }
  411. }
  412. //for k, vlsit := range itemsMap[8365] {
  413. // fmt.Println(k)
  414. // fmt.Println(vlsit)
  415. // //for _, vm := range vlsit {
  416. // // fmt.Println(vm)
  417. // //}
  418. //}
  419. fmt.Println(len(items))
  420. fmt.Println(len(itemsMap))
  421. fmt.Println((itemsMap))
  422. fmt.Println(len(items))
  423. if len(items) > 0 {
  424. _, err = models.AddCygxUserLabelArticleList(items)
  425. fmt.Println(err, "555")
  426. }
  427. }