init_10.5.1.go 12 KB

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