askserie_video.go 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285
  1. package cygx
  2. import (
  3. "errors"
  4. "fmt"
  5. "hongze/hz_crm_api/models/cygx"
  6. "hongze/hz_crm_api/services/alarm_msg"
  7. "hongze/hz_crm_api/utils"
  8. "strconv"
  9. "strings"
  10. "time"
  11. )
  12. // 获取问答系列产业列表
  13. func GetCygxAskserieVideoLabelListMap(askserieVideoIds []int) (mapResp map[int][]*cygx.IndustrialActivityGroupManagementRep) {
  14. var err error
  15. defer func() {
  16. if err != nil {
  17. fmt.Println(err)
  18. go alarm_msg.SendAlarmMsg("获取产品内测的阅读数据,信息失败,GetCygxAskserieVideoLabelListMap Err:"+err.Error(), 3)
  19. }
  20. }()
  21. lenArr := len(askserieVideoIds)
  22. if lenArr == 0 {
  23. return
  24. }
  25. industrialList, e := cygx.GetCygxIndustrialAskserieVideoGroupManagementList(askserieVideoIds)
  26. if e != nil && e.Error() != utils.ErrNoRow() {
  27. err = errors.New("获取详情失败 GetCygxIndustrialAskserieVideoGroupManagementList Err" + e.Error())
  28. return
  29. }
  30. mapResp = make(map[int][]*cygx.IndustrialActivityGroupManagementRep, 0)
  31. for _, v := range industrialList {
  32. item := new(cygx.IndustrialActivityGroupManagementRep)
  33. item.IndustryName = v.IndustryName
  34. item.IndustrialManagementId = v.IndustrialManagementId
  35. item.ChartPermissionId = v.ChartPermissionId
  36. mapResp[v.AskserieVideoId] = append(mapResp[v.AskserieVideoId], item)
  37. }
  38. return
  39. }
  40. // 获取问答系列产业列表
  41. func GetCygxAskserieVideoLabelMap(askserieVideoIds []int) (mapResp map[int]string) {
  42. var err error
  43. defer func() {
  44. if err != nil {
  45. fmt.Println(err)
  46. go alarm_msg.SendAlarmMsg("获取产品内测的阅读数据,信息失败,GetCygxAskserieVideoLabelListMap Err:"+err.Error(), 3)
  47. }
  48. }()
  49. lenArr := len(askserieVideoIds)
  50. if lenArr == 0 {
  51. return
  52. }
  53. industrialList, e := cygx.GetCygxIndustrialAskserieVideoGroupManagementList(askserieVideoIds)
  54. if e != nil && e.Error() != utils.ErrNoRow() {
  55. err = errors.New("获取详情失败 GetCygxIndustrialAskserieVideoGroupManagementList Err" + e.Error())
  56. return
  57. }
  58. mapIndustryName := make(map[int][]string)
  59. mapResp = make(map[int]string, 0)
  60. for _, v := range industrialList {
  61. mapIndustryName[v.AskserieVideoId] = append(mapIndustryName[v.AskserieVideoId], v.IndustryName)
  62. }
  63. for k, v := range mapIndustryName {
  64. mapResp[k] = strings.Join(v, ",")
  65. }
  66. return
  67. }
  68. //func init() {
  69. // UpdateAskserieVideoResourceData(75)
  70. //}
  71. func init12() {
  72. var conditionupload string
  73. var pars []interface{}
  74. conditionupload = " "
  75. listVoice, err := cygx.GetActivityVoiceListNew(conditionupload, pars)
  76. if err != nil && err.Error() != utils.ErrNoRow() {
  77. fmt.Println(err)
  78. return
  79. }
  80. for _, v := range listVoice {
  81. activityId := v.ActivityId
  82. var industrialManagementIds []string
  83. industrialList, err := cygx.GetIndustrialActivityGroupManagementList(activityId, 1)
  84. if err != nil && err.Error() != utils.ErrNoRow() {
  85. fmt.Println(v.ActivityId)
  86. fmt.Println(err)
  87. return
  88. }
  89. for _, vi := range industrialList {
  90. industrialManagementIds = append(industrialManagementIds, strconv.Itoa(vi.IndustrialManagementId))
  91. }
  92. activityInfo, err := cygx.GetAddActivityInfoById(activityId)
  93. if err != nil {
  94. fmt.Println(v.ActivityId)
  95. fmt.Println(err)
  96. return
  97. }
  98. if activityInfo != nil {
  99. item := new(cygx.CygxAskserieVideo)
  100. //item.AskserieVideoId = askserieVideoId
  101. item.VideoName = v.VoiceName
  102. item.VideoUrl = v.VoiceUrl
  103. item.VideoDuration = v.VoicePlaySeconds
  104. item.ChartPermissionId = activityInfo.ChartPermissionId
  105. item.ChartPermissionName = activityInfo.ChartPermissionName
  106. item.PublishStatus = 1
  107. item.BackgroundImg = v.BackgroundImg
  108. item.ShareImg = v.ShareImg
  109. item.ActivityId = v.ActivityId
  110. //item.AdminId = sysUser.AdminId
  111. item.ModifyDate = time.Now()
  112. item.PublishDate = utils.StrTimeToTime(activityInfo.ActivityTime)
  113. item.CreateTime = time.Now()
  114. fmt.Println(item.VideoDuration, "VideoDuration")
  115. fmt.Println(item.ShareImg, "ShareImg")
  116. fmt.Println(item.PublishDate, "PublishDate")
  117. //fmt.Println(item, strings.Join(industrialManagementIds, ","))
  118. //continue
  119. newId, err := cygx.AddCygxAskserieVideo(item, strings.Join(industrialManagementIds, ","))
  120. fmt.Println(newId)
  121. if err != nil {
  122. fmt.Println(err)
  123. return
  124. }
  125. }
  126. }
  127. }
  128. // 修改分享图片脚本
  129. func initpy() {
  130. //python3 main.py
  131. var condition string
  132. var pars []interface{}
  133. listVoice, err := cygx.GetActivityVoiceList(condition, pars)
  134. if err != nil && err.Error() != utils.ErrNoRow() {
  135. fmt.Println(err)
  136. return
  137. }
  138. for _, v := range listVoice {
  139. shareImg, _ := MakeCygxMp3HtmlImg(v.VoicePlaySeconds, 0) //生成分享图片
  140. v.ShareImg = shareImg
  141. err = cygx.UpdateCygxActivityVoice(v)
  142. if err != nil {
  143. err = errors.New("UpdateCygxActivityVoice" + err.Error())
  144. return
  145. }
  146. fmt.Println(err)
  147. }
  148. listVideo, err := cygx.GetCygxActivityVideoList(condition, pars)
  149. if err != nil && err.Error() != utils.ErrNoRow() {
  150. fmt.Println(err)
  151. return
  152. }
  153. for _, v := range listVideo {
  154. shareImg, _ := MakeCygxMp4HtmlImg(v.VideoDuration, 0) //生成分享图片
  155. v.ShareImg = shareImg
  156. err = cygx.UpdateCygxActivityVideo(v)
  157. if err != nil {
  158. err = errors.New("UpdateCygxActivityVideo" + err.Error())
  159. return
  160. }
  161. fmt.Println(err)
  162. }
  163. listVideoRoadshow, err := cygx.GetCygxMicroRoadshowVideoList(condition, pars, 0, 1000)
  164. if err != nil && err.Error() != utils.ErrNoRow() {
  165. fmt.Println(err)
  166. return
  167. }
  168. for _, v := range listVideoRoadshow {
  169. shareImg, _ := MakeCygxMp4HtmlImg(v.VideoDuration, 0) //生成分享图片
  170. v.ShareImgUrl = shareImg
  171. err = cygx.UpdateCygxMicroRoadshowVideo(v)
  172. if err != nil {
  173. err = errors.New("UpdateCygxMicroRoadshowVideo" + err.Error())
  174. return
  175. }
  176. fmt.Println(err)
  177. }
  178. listAskserVoice, err := cygx.GetCygxAskserieVideoList(condition, pars, 0, 1000)
  179. if err != nil && err.Error() != utils.ErrNoRow() {
  180. fmt.Println(err)
  181. return
  182. }
  183. for _, v := range listAskserVoice {
  184. shareImg, _ := MakeCygxMp3HtmlImg(v.VideoDuration, 0) //生成分享图片
  185. v.ShareImg = shareImg
  186. err = cygx.EditCygxAskserieVideoShareImg(shareImg, v.AskserieVideoId)
  187. if err != nil {
  188. err = errors.New("EditCygxAskserieVideoShareImg" + err.Error())
  189. return
  190. }
  191. fmt.Println(err)
  192. }
  193. return
  194. }
  195. // 去掉后缀名脚本
  196. func initFileName() {
  197. var condition string
  198. var pars []interface{}
  199. listVoice, err := cygx.GetActivityVoiceList(condition, pars)
  200. if err != nil && err.Error() != utils.ErrNoRow() {
  201. fmt.Println(err)
  202. return
  203. }
  204. for _, v := range listVoice {
  205. v.VoiceName = utils.RemoveFileSuffixName(v.VoiceName) //去掉后缀名称
  206. err = cygx.UpdateCygxActivityVoice(v)
  207. if err != nil {
  208. err = errors.New("UpdateCygxActivityVoice" + err.Error())
  209. return
  210. }
  211. fmt.Println(err)
  212. }
  213. listVideo, err := cygx.GetCygxActivityVideoList(condition, pars)
  214. if err != nil && err.Error() != utils.ErrNoRow() {
  215. fmt.Println(err)
  216. return
  217. }
  218. for _, v := range listVideo {
  219. v.VideoName = utils.RemoveFileSuffixName(v.VideoName) //去掉后缀名称
  220. err = cygx.UpdateCygxActivityVideo(v)
  221. if err != nil {
  222. err = errors.New("UpdateCygxActivityVideo" + err.Error())
  223. return
  224. }
  225. fmt.Println(err)
  226. }
  227. listVideoRoadshow, err := cygx.GetCygxMicroRoadshowVideoList(condition, pars, 0, 1000)
  228. if err != nil && err.Error() != utils.ErrNoRow() {
  229. fmt.Println(err)
  230. return
  231. }
  232. for _, v := range listVideoRoadshow {
  233. v.VideoName = utils.RemoveFileSuffixName(v.VideoName) //去掉后缀名称
  234. err = cygx.UpdateCygxMicroRoadshowVideo(v)
  235. if err != nil {
  236. err = errors.New("UpdateCygxMicroRoadshowVideo" + err.Error())
  237. return
  238. }
  239. fmt.Println(err)
  240. }
  241. listAskserVoice, err := cygx.GetCygxAskserieVideoList(condition, pars, 0, 1000)
  242. if err != nil && err.Error() != utils.ErrNoRow() {
  243. fmt.Println(err)
  244. return
  245. }
  246. for _, v := range listAskserVoice {
  247. v.VideoName = utils.RemoveFileSuffixName(v.VideoName) //去掉后缀名称
  248. err = cygx.EditCygxAskserieVideoVideoName(v.VideoName, v.AskserieVideoId)
  249. if err != nil {
  250. err = errors.New("EditCygxAskserieVideoShareImg" + err.Error())
  251. return
  252. }
  253. fmt.Println(err)
  254. }
  255. return
  256. }