ppt.go 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650
  1. package services
  2. import (
  3. "encoding/json"
  4. "errors"
  5. "eta/eta_api/models"
  6. "eta/eta_api/models/data_manage/excel"
  7. "eta/eta_api/models/ppt_english"
  8. "eta/eta_api/models/system"
  9. "eta/eta_api/services/alarm_msg"
  10. "eta/eta_api/services/ppt2img"
  11. "eta/eta_api/utils"
  12. "fmt"
  13. "html"
  14. "sort"
  15. "strings"
  16. "time"
  17. )
  18. const (
  19. ElementsTypeText = "text"
  20. ElementsTypeImage = "image"
  21. ElementsTypeChart = "chart"
  22. ElementsTypeSheet = "sheet"
  23. )
  24. type PPTContent struct {
  25. //Id int `json:"id" description:"此处因目录改版类型有int也有string且并没有使用到该字段所以注释掉"`
  26. Key int `json:"key"`
  27. ModelId int `json:"modelId"`
  28. Title string `json:"title"`
  29. Elements []PPTContentElements `json:"elements"`
  30. }
  31. type PPTContentElements struct {
  32. Type string `json:"type"`
  33. Position int `json:"position"`
  34. Content string `json:"content"`
  35. RichContent string `json:"richContent"`
  36. ChartId string `json:"chartId"`
  37. SheetId string `json:"sheetId"`
  38. SheetHeight string `json:"sheetHeight"`
  39. Src string `json:"src"`
  40. Uid string `json:"uid"`
  41. }
  42. // SavePPTReport 保存PPT报告
  43. func SavePPTReport(pptId, classifyId int, title string, adminInfo *system.Admin) (reportId int, reportCode, errMsg string, err error) {
  44. defer func() {
  45. if err != nil {
  46. utils.FileLog.Info("%s", err.Error())
  47. go alarm_msg.SendAlarmMsg("PPT转报告失败, SavePPTReport Msg: "+errMsg+", Err: "+err.Error(), 3)
  48. }
  49. }()
  50. if pptId == 0 {
  51. errMsg = "参数有误"
  52. err = errors.New("参数有误")
  53. return
  54. }
  55. item, e := models.GetPptV2ById(pptId)
  56. if e != nil {
  57. errMsg = "获取PPT失败"
  58. err = errors.New("获取PPT失败, Err: " + e.Error())
  59. return
  60. }
  61. // PPT内容转HTML
  62. htm, e := pptContent2Html(item.Content, false)
  63. if e != nil {
  64. errMsg = "转换失败"
  65. err = e
  66. return
  67. }
  68. // 2023-02-21 PPT可多次转为报告, 不做关联
  69. if classifyId == 0 {
  70. errMsg = "请选择报告类型"
  71. err = errors.New("请选择报告类型")
  72. return
  73. }
  74. if title == "" {
  75. errMsg = "标题不能为空"
  76. err = errors.New("标题不能为空")
  77. return
  78. }
  79. // 获取分类及父级分类
  80. classifyList, e := models.GetAllClassify()
  81. if e != nil {
  82. errMsg = "转换失败"
  83. err = errors.New("获取分类列表失败, Err: " + e.Error())
  84. return
  85. }
  86. classifyMap := make(map[int]*models.Classify, 0)
  87. for _, v := range classifyList {
  88. classifyMap[v.Id] = v
  89. }
  90. classifyIdFirst := 0
  91. classifyIdSecond := 0
  92. classifyIdThird := 0
  93. classifyNameFirst := ""
  94. classifyNameSecond := ""
  95. classifyNameThird := ""
  96. // 最小单元分类,第二级别的分类 ,最大的分类
  97. var baseClassify, twoClassify, threeClassify *models.Classify
  98. var hasTwo, hasThird bool
  99. baseClassify, ok := classifyMap[classifyId]
  100. if !ok {
  101. errMsg = "分类异常"
  102. err = errors.New("获取分类失败 ")
  103. return
  104. }
  105. twoClassify, hasTwo = classifyMap[baseClassify.ParentId]
  106. if hasTwo {
  107. threeClassify, hasThird = classifyMap[twoClassify.ParentId]
  108. }
  109. if hasThird { // 如果确实是有三级分类
  110. classifyIdFirst = threeClassify.Id
  111. classifyNameFirst = threeClassify.ClassifyName
  112. classifyIdSecond = twoClassify.Id
  113. classifyNameSecond = twoClassify.ClassifyName
  114. classifyIdThird = baseClassify.Id
  115. classifyNameThird = baseClassify.ClassifyName
  116. } else if hasTwo {
  117. classifyIdFirst = twoClassify.Id
  118. classifyNameFirst = twoClassify.ClassifyName
  119. classifyIdSecond = baseClassify.Id
  120. classifyNameSecond = baseClassify.ClassifyName
  121. } else {
  122. classifyIdFirst = baseClassify.Id
  123. classifyNameFirst = baseClassify.ClassifyName
  124. }
  125. // 新增报告
  126. nowTime := time.Now().Local()
  127. reportReq := &models.AddReq{
  128. AddType: 1,
  129. ClassifyIdFirst: classifyIdFirst,
  130. ClassifyNameFirst: classifyNameFirst,
  131. ClassifyIdSecond: classifyIdSecond,
  132. ClassifyNameSecond: classifyNameSecond,
  133. ClassifyIdThird: classifyIdThird,
  134. ClassifyNameThird: classifyNameThird,
  135. Title: title,
  136. Abstract: "",
  137. Author: "",
  138. Frequency: utils.ReportFrequencyDefault,
  139. State: 1,
  140. Content: htm,
  141. CreateTime: nowTime.Format(utils.FormatDateTime),
  142. ReportVersion: 2,
  143. CollaborateType: 1, // 协作方式,1:个人,2:多人协作。默认:1
  144. ReportLayout: 1, // 报告布局,1:常规布局,2:智能布局。默认:1
  145. IsPublicPublish: 1, // 是否公开发布,1:是,2:否
  146. }
  147. // 如果PPT是公开的,则报告也公开发布
  148. if item.IsShare == 1 {
  149. reportReq.IsPublicPublish = 1
  150. }
  151. newReportInfo, _, e := CreateNewReport(*reportReq, adminInfo)
  152. if e != nil {
  153. errMsg = "转换失败"
  154. err = errors.New("新增报告失败, Err: " + e.Error())
  155. return
  156. }
  157. reportId = newReportInfo.Id
  158. reportCode = newReportInfo.ReportCode
  159. // ppt转报告后,将ppt的表格关系做处理
  160. handlerPptToReportTableReferenced(pptId, newReportInfo.Id)
  161. // 更新报告中的ppt图片
  162. go saveReportPptImg(pptId, reportId, item.PptxUrl)
  163. return
  164. }
  165. // PPT2内容转HTML
  166. func pptContent2Html(content string, isEnglish bool) (htm string, err error) {
  167. contents := make([]PPTContent, 0)
  168. if e := json.Unmarshal([]byte(content), &contents); e != nil {
  169. err = errors.New("PPT内容转换失败")
  170. return
  171. }
  172. pageLen := len(contents)
  173. htmlContent := ``
  174. // iframe图表/表格域名
  175. // 获取基础配置, 若未配置则直接返回
  176. // 获取配置好的短信模版
  177. smsCond := ` AND conf_key = ? `
  178. smsPars := make([]interface{}, 0)
  179. smsPars = append(smsPars, "ChartViewUrl")
  180. conf := new(models.BusinessConf)
  181. conf, e := conf.GetItemByCondition(smsCond, smsPars)
  182. if e != nil {
  183. if e.Error() == utils.ErrNoRow() {
  184. err = fmt.Errorf("请先配置公共图库的地址")
  185. return
  186. }
  187. err = fmt.Errorf("获取聚合短信配置信息失败, Err: %s", e.Error())
  188. return
  189. }
  190. if conf.ConfVal == "" {
  191. err = fmt.Errorf("请先配置公共图库的地址")
  192. return
  193. }
  194. chartRoot := conf.ConfVal
  195. if pageLen > 0 {
  196. htmlPrefix := `<p style="text-align: left; margin-top: 10px; font-size: 16px;">`
  197. htmlSuffix := `</p>`
  198. htmlBr := `<br>`
  199. for i := 0; i < pageLen; i++ {
  200. // 每页标题加粗居中
  201. title := contents[i].Title
  202. if title != "" {
  203. htmlContent += `<p style="font-size: 16px; text-align: left;"><strong>`
  204. htmlContent += title
  205. htmlContent += `</strong></p>`
  206. }
  207. ele := contents[i].Elements
  208. // 每页元素按照Position升序排序
  209. sort.Slice(ele, func(k, j int) bool {
  210. return ele[k].Position < ele[j].Position
  211. })
  212. for _, v := range ele {
  213. // 根据不同的Type拼接不同的内容
  214. htmlContent += htmlPrefix
  215. switch v.Type {
  216. case ElementsTypeText:
  217. htmlContent += v.RichContent
  218. case ElementsTypeImage:
  219. htmlContent += fmt.Sprint(`<img src="`, v.Src, `" class="fr-fic fr-dib fr-draggable">`)
  220. case ElementsTypeChart:
  221. if isEnglish {
  222. // 英文研报图表src多加一个fromPage=en, 表格暂时没有区分
  223. if strings.HasPrefix(v.ChartId, "isETAForumChart_") {
  224. chartIdInfo := strings.Split(v.ChartId, "_")
  225. if len(chartIdInfo) == 2 {
  226. v.ChartId = chartIdInfo[1]
  227. }
  228. htmlContent += fmt.Sprintf(`<iframe src="%s/chartshow?code=%s&fromPage=en&isETAForumChart=true&uid=%s" width="100%%" height="350" style="border-width:0px; min-height:350px;" class="iframe%s"></iframe>`, chartRoot, v.ChartId, v.Uid, v.Uid)
  229. break
  230. }
  231. htmlContent += fmt.Sprintf(`<iframe src="%s/chartshow?code=%s&fromPage=en&uid=%s" width="100%%" height="350" style="border-width:0px; min-height:350px;" class="iframe%s"></iframe>`, chartRoot, v.ChartId, v.Uid, v.Uid)
  232. break
  233. }
  234. if strings.HasPrefix(v.ChartId, "isETAForumChart_") {
  235. chartIdInfo := strings.Split(v.ChartId, "_")
  236. if len(chartIdInfo) == 2 {
  237. v.ChartId = chartIdInfo[1]
  238. }
  239. htmlContent += fmt.Sprintf(`<iframe src="%s/chartshow?code=%s&isETAForumChart=true&uid=%s" width="100%%" height="350" style="border-width:0px; min-height:350px;" class="iframe%s"></iframe>`, chartRoot, v.ChartId, v.Uid, v.Uid)
  240. break
  241. }
  242. htmlContent += fmt.Sprintf(`<iframe src="%s/chartshow?code=%s&uid=%s" width="100%%" height="350" style="border-width:0px; min-height:350px;" class="iframe%s"></iframe>`, chartRoot, v.ChartId, v.Uid, v.Uid)
  243. case ElementsTypeSheet:
  244. htmlContent += fmt.Sprintf(`<iframe src="%s/sheetshow?code=%s&uid=%s" class="iframe%s" width="100%%" height="%s" style="border-width:0px;"></iframe>`, chartRoot, v.SheetId, v.Uid, v.Uid, v.SheetHeight)
  245. }
  246. htmlContent += htmlSuffix
  247. }
  248. // 每页中间插入一个换行符, 最后一页不插入
  249. currentPage := i + 1
  250. if currentPage != pageLen {
  251. htmlContent += htmlPrefix + htmlBr + htmlSuffix
  252. }
  253. }
  254. }
  255. htm = htmlContent
  256. return
  257. }
  258. // ResetPPTReport 重置PPT关联的报告(如删除关联的报告后)
  259. func ResetPPTReport(reportId int, isEnglish bool) (err error) {
  260. defer func() {
  261. if err != nil {
  262. utils.FileLog.Info("%s", err.Error())
  263. go alarm_msg.SendAlarmMsg("重置PPT关联报告失败, ResetPPTReport Err: "+err.Error(), 3)
  264. }
  265. }()
  266. // 英文报告
  267. if isEnglish {
  268. en, e := ppt_english.GetPptEnglishByReportId(reportId)
  269. if e != nil && e.Error() != utils.ErrNoRow() {
  270. err = errors.New("获取英文PPT失败, Err: " + e.Error())
  271. return
  272. }
  273. if en != nil {
  274. updateCols := []string{"ReportId", "ReportCode"}
  275. en.ReportId = 0
  276. en.ReportCode = ""
  277. if e = en.Update(updateCols); e != nil {
  278. err = errors.New("更新英文PPT关联报告失败, Err: " + e.Error())
  279. return
  280. }
  281. }
  282. return
  283. }
  284. // 中文报告
  285. item, e := models.GetPptV2ByReportId(reportId)
  286. if e != nil && e.Error() != utils.ErrNoRow() {
  287. err = errors.New("获取PPT失败, Err: " + e.Error())
  288. return
  289. }
  290. if item != nil {
  291. updateCols := []string{"ReportId", "ReportCode"}
  292. item.ReportId = 0
  293. item.ReportCode = ""
  294. if e = item.Update(updateCols); e != nil {
  295. err = errors.New("更新PPT关联报告失败, Err: " + e.Error())
  296. return
  297. }
  298. }
  299. return
  300. }
  301. // saveReportPptImg ppt转报告后,需要再次将ppt转图片
  302. func saveReportPptImg(pptId, reportId int, pptUrl string) {
  303. var err error
  304. defer func() {
  305. if err != nil {
  306. utils.FileLog.Info(fmt.Sprintf("将ppt转图片失败, saveReportPptImg Err:%s", err.Error()))
  307. go alarm_msg.SendAlarmMsg("将ppt转图片失败, saveReportPptImg Err: "+err.Error(), 3)
  308. }
  309. }()
  310. // 更新报告内容
  311. report, e := models.GetReportByReportId(reportId)
  312. if e != nil && e.Error() != utils.ErrNoRow() {
  313. err = errors.New("获取报告失败, Err: " + e.Error())
  314. return
  315. }
  316. if report == nil {
  317. return
  318. }
  319. // 获取ppt转图片的结果
  320. list, err := ppt2img.Ppt2Img(pptUrl)
  321. if err != nil {
  322. return
  323. }
  324. reportPptImgList := make([]*models.ReportPptImg, 0)
  325. for _, v := range list {
  326. reportPptImg := &models.ReportPptImg{
  327. //ReportPptImgId: 0,
  328. PptId: pptId,
  329. ReportId: reportId,
  330. ReportChapterId: 0,
  331. ImgUrl: v,
  332. CreateTime: time.Now(),
  333. }
  334. reportPptImgList = append(reportPptImgList, reportPptImg)
  335. }
  336. //批量添加Ppt转报告的图片记录
  337. err = models.AddAndEditMultiReportPptImg(pptId, reportPptImgList)
  338. return
  339. }
  340. // SaveEnglishPPTReport 保存英文PPT报告
  341. func SaveEnglishPPTReport(pptId, classifyIdFirst, classifyIdSecond int, title, abstract string, adminInfo *system.Admin) (reportId int, reportCode, errMsg string, err error) {
  342. defer func() {
  343. if err != nil {
  344. utils.FileLog.Info("%s", err.Error())
  345. go alarm_msg.SendAlarmMsg("PPT转报告失败, SavePPTReport Msg: "+errMsg+", Err: "+err.Error(), 3)
  346. }
  347. }()
  348. if pptId == 0 {
  349. errMsg = "参数有误"
  350. err = errors.New("参数有误")
  351. return
  352. }
  353. item, e := ppt_english.GetPptEnglishById(pptId)
  354. if e != nil {
  355. errMsg = "获取PPT失败"
  356. err = errors.New("获取PPT失败, Err: " + e.Error())
  357. return
  358. }
  359. // PPT内容转HTML
  360. htm, e := pptContent2Html(item.Content, true)
  361. if e != nil {
  362. errMsg = "转换失败"
  363. err = e
  364. return
  365. }
  366. // 2023-02-21 PPT可多次转为报告, 不做关联
  367. if title == "" {
  368. errMsg = "标题不能为空"
  369. err = errors.New("标题不能为空")
  370. return
  371. }
  372. if classifyIdFirst <= 0 {
  373. errMsg = "请选择报告分类"
  374. err = errors.New("报告分类不能为空")
  375. return
  376. }
  377. // 分类
  378. classifyList, e := models.GetAllEnglishClassify()
  379. if e != nil {
  380. errMsg = "转换失败"
  381. err = errors.New("获取分类列表失败, Err: " + e.Error())
  382. return
  383. }
  384. classifyMap := make(map[int]string, 0)
  385. for _, v := range classifyList {
  386. classifyMap[v.Id] = v.ClassifyName
  387. }
  388. classifyNameFirst := classifyMap[classifyIdFirst]
  389. classifyNameSecond := classifyMap[classifyIdSecond]
  390. // 新增报告
  391. nowTime := time.Now().Local()
  392. reportReq := &models.AddEnglishReportReq{
  393. AddType: 1,
  394. ClassifyIdFirst: classifyIdFirst,
  395. ClassifyNameFirst: classifyNameFirst,
  396. ClassifyIdSecond: classifyIdSecond,
  397. ClassifyNameSecond: classifyNameSecond,
  398. Title: title,
  399. Abstract: abstract,
  400. Author: "Horizon Insights FICC Team",
  401. Frequency: utils.ReportFrequencyDefault,
  402. State: 1,
  403. Content: htm,
  404. CreateTime: nowTime.Format(utils.FormatDateTime),
  405. }
  406. newReportId, newCode, e := CreateNewEnglishReport(*reportReq, adminInfo)
  407. if e != nil {
  408. errMsg = "转换失败"
  409. err = errors.New("新增报告失败, Err: " + e.Error())
  410. return
  411. }
  412. reportId = int(newReportId)
  413. reportCode = newCode
  414. // 英文ppt转英文报告后,将英文报告的表格关系做处理
  415. handlerPptToEnReportTableReferenced(pptId, reportId)
  416. return
  417. }
  418. // UpdatePptEditing 更新PPT编辑状态
  419. func UpdatePptEditing(pptId, status, userId int, userName string, isEn bool) (ret ppt_english.PPTEditingCache, err error) {
  420. if pptId <= 0 {
  421. return
  422. }
  423. cacheKey := ""
  424. if isEn {
  425. cacheKey = fmt.Sprint(utils.CACHE_EN_PPT_EDITING, pptId)
  426. } else {
  427. cacheKey = fmt.Sprint(utils.CACHE_PPT_EDITING, pptId)
  428. }
  429. // 完成编辑
  430. if status == 2 {
  431. _ = utils.Rc.Delete(cacheKey)
  432. return
  433. }
  434. // 读取缓存中的结果
  435. var editor ppt_english.PPTEditingCache
  436. strCache, _ := utils.Rc.RedisString(cacheKey)
  437. fmt.Println(strCache)
  438. if strCache != "" {
  439. e := json.Unmarshal([]byte(strCache), &editor)
  440. if e != nil {
  441. err = fmt.Errorf("解析缓存内容失败: %s", e.Error())
  442. return
  443. }
  444. }
  445. // 标记编辑中
  446. if status == 1 {
  447. // 无人编辑, 写入缓存
  448. if !editor.IsEditing {
  449. ret.IsEditing = true
  450. ret.AdminId = userId
  451. ret.Editor = userName
  452. ret.Tips = fmt.Sprintf("当前%s正在编辑PPT", userName)
  453. b, _ := json.Marshal(ret)
  454. utils.Rc.SetNX(cacheKey, string(b), utils.ReportPptEditingWait*time.Second)
  455. return
  456. }
  457. // 有人编辑
  458. if editor.IsEditing {
  459. // 编辑用户与当前用户不一致, 返回编辑用户, 一致则更新缓存
  460. if userId == editor.AdminId {
  461. b, _ := json.Marshal(editor)
  462. utils.Rc.Do("SETEX", cacheKey, int64(utils.ReportPptEditingWait), string(b))
  463. }
  464. ret = editor
  465. return
  466. }
  467. } else {
  468. // 默认查询
  469. ret = editor
  470. }
  471. return
  472. }
  473. // handlerPptToReportTableReferenced
  474. // @Description: ppt转报告后,需要同时继承原来ppt中表格的拖动数据逻辑
  475. // @author: Roc
  476. // @datetime 2025-01-09 16:51:11
  477. // @param pptId int
  478. // @param reportId int
  479. func handlerPptToReportTableReferenced(pptId, reportId int) {
  480. var err error
  481. defer func() {
  482. if err != nil {
  483. utils.FileLog.Error("ppt转报告后,报告与动态表格关联处理失败,PPT的ID:%d,新报告ID:%d,Err:%s", pptId, reportId, err.Error())
  484. }
  485. }()
  486. reportInfo, err := models.GetReportByReportId(reportId)
  487. if err != nil {
  488. return
  489. }
  490. newFromScene := utils.TableReferencedByReport
  491. addList, err := excel.CopyReferencedExcelConfigByReferencedIdAndFromScene(pptId, utils.TableReferencedByPPT, reportInfo.Id, newFromScene, reportInfo.AdminId, reportInfo.AdminRealName)
  492. if err != nil {
  493. return
  494. }
  495. if len(addList) > 0 {
  496. // 修改内容
  497. content := HandleReportContentTableAndScene(reportInfo.Id, newFromScene, html.UnescapeString(reportInfo.Content))
  498. reportInfo.Content = html.EscapeString(content)
  499. reportInfo.ContentStruct = HandleReportContentStructTableAndScene(reportInfo.Id, newFromScene, reportInfo.ContentStruct)
  500. err = reportInfo.Update([]string{"Content", "ContentStruct"})
  501. if err != nil {
  502. return
  503. }
  504. if reportInfo.HasChapter == 1 {
  505. chapterList, tmpErr := models.GetChapterListByReportId(reportInfo.Id)
  506. if tmpErr != nil {
  507. err = tmpErr
  508. return
  509. }
  510. for _, v := range chapterList {
  511. chapterContent := HandleReportContentTableAndScene(reportInfo.Id, newFromScene, html.UnescapeString(v.Content))
  512. v.Content = html.EscapeString(chapterContent)
  513. v.ContentStruct = HandleReportContentStructTableAndScene(reportInfo.Id, newFromScene, v.ContentStruct)
  514. err = v.Update([]string{"Content", "ContentStruct"})
  515. if err != nil {
  516. return
  517. }
  518. }
  519. }
  520. }
  521. }
  522. // HandlerPptToEnPptTableReferenced
  523. // @Description: ppt转英文ppt后,需要同时继承原来ppt中表格的拖动数据逻辑
  524. // @author: Roc
  525. // @datetime 2025-01-09 16:51:03
  526. // @param pptId int
  527. // @param enPptId int
  528. // @param sysUserId int
  529. // @param sysUserName string
  530. func HandlerPptToEnPptTableReferenced(pptId, enPptId, sysUserId int, sysUserName string) {
  531. var err error
  532. defer func() {
  533. if err != nil {
  534. utils.FileLog.Error("ppt转英文PPT后,英文PPT与动态表格关联处理失败,PPT的ID:%d,英文ppt的ID:%d,Err:%s", pptId, enPptId, err.Error())
  535. }
  536. }()
  537. _, err = excel.CopyReferencedExcelConfigByReferencedIdAndFromScene(pptId, utils.TableReferencedByPPT, enPptId, utils.TableReferencedByEnPPT, sysUserId, sysUserName)
  538. if err != nil {
  539. return
  540. }
  541. }
  542. // HandlerMergePptTableReferenced
  543. // @Description: 多ppt合并生成新的ppt,需要同时继承原来所有ppt中表格的拖动数据逻辑
  544. // @author: Roc
  545. // @datetime 2025-01-09 16:51:03
  546. // @param pptId int
  547. // @param enPptId int
  548. // @param sysUserId int
  549. // @param sysUserName string
  550. // @param fromScene int
  551. func HandlerMergePptTableReferenced(oldPptIdList []int, pptId, sysUserId int, sysUserName string, fromScene int) {
  552. var err error
  553. defer func() {
  554. if err != nil {
  555. utils.FileLog.Error("ppt转英文PPT后,英文PPT与动态表格关联处理失败,待合并的PPT的ID:%v,英文ppt的ID:%d,Err:%s", oldPptIdList, pptId, err.Error())
  556. }
  557. }()
  558. _, err = excel.CopyReferencedExcelConfigByReferencedIdListAndFromScene(oldPptIdList, fromScene, pptId, fromScene, sysUserId, sysUserName)
  559. if err != nil {
  560. return
  561. }
  562. }
  563. // handlerPptToEnReportTableReferenced
  564. // @Description: 英文ppt转报告后,需要同时继承原来英文ppt中表格的拖动数据逻辑
  565. // @author: Roc
  566. // @datetime 2025-01-09 17:04:49
  567. // @param enPptId int
  568. // @param enReportId int
  569. func handlerPptToEnReportTableReferenced(enPptId, enReportId int) {
  570. var err error
  571. defer func() {
  572. if err != nil {
  573. utils.FileLog.Error("ppt转英文报告后,英文报告与动态表格关联处理失败,PPT的ID:%d,英文报告ID:%d,Err:%s", enPptId, enReportId, err.Error())
  574. }
  575. }()
  576. reportInfo, err := models.GetEnglishReportItemById(enReportId)
  577. if err != nil {
  578. return
  579. }
  580. newFromScene := utils.TableReferencedByEnReport
  581. addList, err := excel.CopyReferencedExcelConfigByReferencedIdAndFromScene(enPptId, utils.TableReferencedByEnPPT, enReportId, newFromScene, reportInfo.AdminId, reportInfo.AdminRealName)
  582. if err != nil {
  583. return
  584. }
  585. if len(addList) > 0 {
  586. // 修改内容
  587. content := HandleReportContentTableAndScene(reportInfo.Id, newFromScene, html.UnescapeString(reportInfo.Content))
  588. reportInfo.Content = html.EscapeString(content)
  589. err = reportInfo.Update([]string{"Content"})
  590. if err != nil {
  591. return
  592. }
  593. }
  594. }