report_v2.go 73 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343
  1. package controllers
  2. import (
  3. "encoding/json"
  4. "eta/eta_api/cache"
  5. "eta/eta_api/models"
  6. "eta/eta_api/models/report"
  7. "eta/eta_api/models/report_approve"
  8. "eta/eta_api/models/smart_report"
  9. "eta/eta_api/models/system"
  10. "eta/eta_api/services"
  11. "eta/eta_api/services/alarm_msg"
  12. "eta/eta_api/services/data"
  13. "eta/eta_api/utils"
  14. "fmt"
  15. "html"
  16. "io"
  17. "os"
  18. "strconv"
  19. "strings"
  20. "time"
  21. "github.com/rdlucklib/rdluck_tools/paging"
  22. )
  23. // ListReport
  24. // @Title 获取报告列表接口
  25. // @Description 获取报告列表
  26. // @Param PageSize query int true "每页数据条数"
  27. // @Param CurrentIndex query int true "当前页页码,从1开始"
  28. // @Param TimeType query string true "筛选的时间类别:publish_time(发布时间),modify_time(更新时间);approve_time(审批时间)"
  29. // @Param StartDate query string true "开始时间"
  30. // @Param EndDate query string true "结束时间"
  31. // @Param Frequency query string true "频度"
  32. // @Param ClassifyIdFirst query int true "一级分类id"
  33. // @Param ClassifyIdSecond query int true "二级分类id"
  34. // @Param ClassifyIdThird query int true "三级分类id"
  35. // @Param State query int true "状态"
  36. // @Param KeyWord query string true "搜索关键词"
  37. // @Param PublishSort query string true "desc:降序,asc 升序(预留)"
  38. // @Param FilterReportType query string true "筛选报告类型,1:公共研报,2:共享研报,3:我的研报"
  39. // @Success 200 {object} models.ReportListResp
  40. // @router /list [get]
  41. func (this *ReportController) ListReport() {
  42. br := new(models.BaseResponse).Init()
  43. defer func() {
  44. this.Data["json"] = br
  45. this.ServeJSON()
  46. }()
  47. pageSize, _ := this.GetInt("PageSize")
  48. currentIndex, _ := this.GetInt("CurrentIndex")
  49. timeType := this.GetString("TimeType")
  50. startDate := this.GetString("StartDate")
  51. endDate := this.GetString("EndDate")
  52. frequency := this.GetString("Frequency")
  53. classifyIdFirst, _ := this.GetInt("ClassifyIdFirst", 0)
  54. classifyIdSecond, _ := this.GetInt("ClassifyIdSecond", 0)
  55. classifyIdThird, _ := this.GetInt("ClassifyIdThird", 0)
  56. state, _ := this.GetInt("State")
  57. keyWord := this.GetString("KeyWord")
  58. msgIsSend, _ := this.GetInt("MsgIsSend")
  59. filterReportType, _ := this.GetInt("FilterReportType", 1)
  60. var startSize int
  61. if pageSize <= 0 {
  62. pageSize = utils.PageSize20
  63. }
  64. if currentIndex <= 0 {
  65. currentIndex = 1
  66. }
  67. startSize = utils.StartIndex(currentIndex, pageSize)
  68. if timeType == "" {
  69. timeType = "publish_time"
  70. }
  71. if timeType != "publish_time" && timeType != "modify_time" && timeType != "approve_time" {
  72. br.Msg = "请选择正确的时间"
  73. br.ErrMsg = "请选择正确的时间"
  74. return
  75. }
  76. var condition string
  77. var pars []interface{}
  78. if keyWord != "" {
  79. condition += ` AND (a.title LIKE ? OR a.admin_real_name LIKE ? ) `
  80. pars = utils.GetLikeKeywordPars(pars, keyWord, 2)
  81. }
  82. if startDate != "" {
  83. condition += ` AND a.` + timeType + ` >= ? `
  84. pars = append(pars, startDate)
  85. }
  86. if endDate != "" {
  87. condition += ` AND a.` + timeType + ` <= ? `
  88. pars = append(pars, endDate)
  89. }
  90. if frequency != "" {
  91. condition += ` AND a.frequency = ? `
  92. pars = append(pars, frequency)
  93. }
  94. if classifyIdFirst > 0 {
  95. condition += ` AND a.classify_id_first = ? `
  96. pars = append(pars, classifyIdFirst)
  97. }
  98. if classifyIdSecond > 0 {
  99. condition += ` AND a.classify_id_second = ? `
  100. pars = append(pars, classifyIdSecond)
  101. }
  102. if classifyIdThird > 0 {
  103. condition += ` AND a.classify_id_third = ? `
  104. pars = append(pars, classifyIdThird)
  105. }
  106. if state > 0 {
  107. condition += ` AND a.state = ? `
  108. pars = append(pars, state)
  109. }
  110. // 消息是否已推送 1-未推送; 2-已推送
  111. if msgIsSend == 1 {
  112. condition += ` AND (a.msg_is_send = 0 OR a.ths_msg_is_send = 0) `
  113. }
  114. if msgIsSend == 2 {
  115. condition += ` AND a.msg_is_send = 1 AND a.ths_msg_is_send = 1 `
  116. }
  117. var err error
  118. var total int
  119. var list []*models.ReportList
  120. switch filterReportType {
  121. // 筛选报告类型,1:公共研报,2:共享研报,3:我的研报
  122. case 1:
  123. condition += ` AND a.is_public_publish = ? `
  124. pars = append(pars, 1)
  125. condition += ` AND a.state in (2,6) `
  126. case 3:
  127. // 如果不是超管,那么就看自己有权限的
  128. if !utils.IsAdminRole(this.SysUser.RoleTypeCode) {
  129. condition += ` AND a.admin_id = ? `
  130. pars = append(pars, this.SysUser.AdminId)
  131. }
  132. case 2:
  133. // 如果不是超管,那么就看自己有权限的
  134. if !utils.IsAdminRole(this.SysUser.RoleTypeCode) {
  135. condition += ` AND (a.admin_id = ? or b.admin_id = ?) `
  136. pars = append(pars, this.SysUser.AdminId, this.SysUser.AdminId)
  137. }
  138. }
  139. // 共享报告需要连表查询,所以需要单独写
  140. if filterReportType == 2 {
  141. total, err = models.GetReportListCountByGrant(condition, pars)
  142. if err != nil {
  143. br.Msg = "获取失败"
  144. br.ErrMsg = "获取失败,Err:" + err.Error()
  145. return
  146. }
  147. list, err = models.GetReportListByGrant(condition, pars, startSize, pageSize)
  148. if err != nil {
  149. br.Msg = "获取失败"
  150. br.ErrMsg = "获取失败,Err:" + err.Error()
  151. return
  152. }
  153. } else {
  154. total, err = models.GetReportListCountV1(condition, pars)
  155. if err != nil {
  156. br.Msg = "获取失败"
  157. br.ErrMsg = "获取失败,Err:" + err.Error()
  158. return
  159. }
  160. list, err = models.GetReportListV1(condition, pars, startSize, pageSize)
  161. if err != nil {
  162. br.Msg = "获取失败"
  163. br.ErrMsg = "获取失败,Err:" + err.Error()
  164. return
  165. }
  166. }
  167. listLen := len(list)
  168. if listLen > 0 {
  169. pvMap := make(map[int]int)
  170. uvMap := make(map[int]int)
  171. reportIdArr := make([]int, 0)
  172. syncReportIdArr := make([]string, 0) // 同步过来的报告IDs
  173. oldAndNewReportIdMap := make(map[int]int) // 旧报告和新报告的id对应关系
  174. classifyIdList := make([]int, 0) // 关联的指标分类id
  175. classifyIdMap := make(map[int]bool) // 分类id map
  176. classifyMap := make(map[int]*models.Classify) // 分类map
  177. for i := 0; i < listLen; i++ {
  178. reportIdArr = append(reportIdArr, list[i].Id)
  179. if list[i].OldReportId > 0 && list[i].ReportLayout == 1 {
  180. syncReportIdArr = append(syncReportIdArr, strconv.Itoa(list[i].OldReportId))
  181. oldAndNewReportIdMap[list[i].OldReportId] = list[i].Id
  182. }
  183. pvMap[list[i].Id] = list[i].Pv
  184. uvMap[list[i].Id] = list[i].Uv
  185. if list[i].ClassifyIdFirst > 0 {
  186. if _, ok := classifyIdMap[list[i].ClassifyIdFirst]; !ok {
  187. classifyIdList = append(classifyIdList, list[i].ClassifyIdFirst)
  188. }
  189. }
  190. if list[i].ClassifyIdSecond > 0 {
  191. if _, ok := classifyIdMap[list[i].ClassifyIdSecond]; !ok {
  192. classifyIdList = append(classifyIdList, list[i].ClassifyIdSecond)
  193. }
  194. }
  195. if list[i].ClassifyIdThird > 0 {
  196. if _, ok := classifyIdMap[list[i].ClassifyIdThird]; !ok {
  197. classifyIdList = append(classifyIdList, list[i].ClassifyIdThird)
  198. }
  199. }
  200. }
  201. // 当下报告的pv,uv
  202. if len(reportIdArr) > 0 {
  203. pvList, e := models.GetReportPvUvByReportIdList(reportIdArr)
  204. if e != nil {
  205. br.Msg = "获取失败"
  206. br.ErrMsg = "获取同步报告对应的PV、UV失败, Err: " + e.Error()
  207. return
  208. }
  209. for _, v := range pvList {
  210. pv := pvMap[v.ReportId]
  211. uv := uvMap[v.ReportId]
  212. pvMap[v.ReportId] = v.PvTotal + pv
  213. uvMap[v.ReportId] = v.UvTotal + uv
  214. }
  215. }
  216. if len(classifyIdList) > 0 {
  217. classifyList, e := models.GetClassifyListByIdList(classifyIdList)
  218. if e != nil {
  219. br.Msg = "获取失败"
  220. br.ErrMsg = "获取报告分类失败, Err: " + e.Error()
  221. return
  222. }
  223. for _, v := range classifyList {
  224. classifyMap[v.Id] = v
  225. }
  226. }
  227. //reportIds := strings.Join(reportIdArr, ",")
  228. //syncReportIds := strings.Join(syncReportIdArr, ",")
  229. // 查询同步过来的报告对应的老报告PV+UV
  230. if len(syncReportIdArr) > 0 {
  231. puvList, e := models.GetPUVByResearchReportIds(syncReportIdArr)
  232. if e != nil {
  233. br.Msg = "获取失败"
  234. br.ErrMsg = "获取同步报告对应的PV、UV失败, Err: " + e.Error()
  235. return
  236. }
  237. puvLen := len(puvList)
  238. for i := 0; i < puvLen; i++ {
  239. newReportId, ok := oldAndNewReportIdMap[puvList[i].ResearchReportId]
  240. if ok {
  241. pv := pvMap[newReportId]
  242. uv := uvMap[newReportId]
  243. pvMap[newReportId] = puvList[i].Pv + pv
  244. uvMap[newReportId] = puvList[i].Uv + uv
  245. }
  246. }
  247. }
  248. // 晨周报音频列表
  249. videoList, err := models.GetReportChapterVideoListByReportIds(reportIdArr)
  250. if err != nil {
  251. br.Msg = "获取失败"
  252. br.ErrMsg = "获取报告音频文件失败,Err:" + err.Error()
  253. return
  254. }
  255. for i := 0; i < listLen; i++ {
  256. list[i].Content = html.UnescapeString(list[i].Content)
  257. list[i].ContentSub = html.UnescapeString(list[i].ContentSub)
  258. // 除周报外其余报告均可推送客群
  259. list[i].NeedThsMsg = 1
  260. //if list[i].HasChapter == 1 && list[i].ChapterType == utils.REPORT_TYPE_WEEK {
  261. // list[i].NeedThsMsg = 0
  262. //}
  263. chapterList := make([]*models.ReportChapterVideoList, 0)
  264. for ii := 0; ii < len(videoList); ii++ {
  265. if list[i].Id == videoList[ii].ReportId {
  266. chapterList = append(chapterList, videoList[ii])
  267. }
  268. }
  269. list[i].ChapterVideoList = chapterList
  270. list[i].Pv = pvMap[list[i].Id]
  271. list[i].Uv = uvMap[list[i].Id]
  272. if list[i].ClassifyIdThird > 0 {
  273. if classify, ok := classifyMap[list[i].ClassifyIdThird]; ok {
  274. if classify.Enabled == 1 {
  275. list[i].ClassifyEnabled = true
  276. }
  277. }
  278. } else if list[i].ClassifyIdSecond > 0 {
  279. if classify, ok := classifyMap[list[i].ClassifyIdSecond]; ok {
  280. if classify.Enabled == 1 {
  281. list[i].ClassifyEnabled = true
  282. }
  283. }
  284. } else if list[i].ClassifyIdFirst > 0 {
  285. if classify, ok := classifyMap[list[i].ClassifyIdFirst]; ok {
  286. if classify.Enabled == 1 {
  287. list[i].ClassifyEnabled = true
  288. }
  289. }
  290. }
  291. }
  292. // 多人协作的协作报告,需要判断是否可编辑
  293. {
  294. grantObj := report.ReportGrant{}
  295. grantList, err := grantObj.GetGrantListByIdList(reportIdArr)
  296. if err != nil {
  297. br.Msg = "获取失败"
  298. br.ErrMsg = "获取报告授权失败,Err:" + err.Error()
  299. return
  300. }
  301. //grantMap := make(map[报告id]map[用户id]bool)
  302. grantMap := make(map[int]map[int]bool)
  303. for _, v := range grantList {
  304. grantUserMap, ok := grantMap[v.ReportId]
  305. if !ok {
  306. grantUserMap = make(map[int]bool)
  307. }
  308. grantUserMap[v.AdminId] = true
  309. grantMap[v.ReportId] = grantUserMap
  310. }
  311. for i, item := range list {
  312. if item.AdminId == this.SysUser.AdminId {
  313. list[i].HasAuth = true
  314. continue
  315. }
  316. // 如果是超管,那么有权限
  317. if utils.IsAdminRole(this.SysUser.RoleTypeCode) {
  318. list[i].HasAuth = true
  319. continue
  320. }
  321. // 查找授权
  322. var hasAuth bool
  323. grantUserMap, ok := grantMap[item.Id]
  324. // 如果报告根本没有授权用户,说明没有授权当前用户
  325. if !ok {
  326. continue
  327. }
  328. _, ok = grantUserMap[this.SysUser.AdminId]
  329. list[i].HasAuth = hasAuth
  330. // 如果报告关联用户找到,说明有授权当前用户
  331. if ok {
  332. list[i].HasAuth = true
  333. }
  334. }
  335. }
  336. }
  337. for _, item := range list {
  338. /*key := fmt.Sprint(`crm:report:edit:`, item.Id)
  339. opUserId, _ := utils.Rc.RedisInt(key)
  340. //如果当前没有人操作,获取当前操作人是本人,那么编辑按钮可用
  341. if opUserId <= 0 || (opUserId == this.SysUser.AdminId) || item.ClassifyNameFirst == "周报" || item.ClassifyNameFirst == "晨报" {
  342. item.CanEdit = true
  343. } else {
  344. adminInfo, errAdmin := system.GetSysUserById(opUserId)
  345. if errAdmin != nil {
  346. br.Msg = "获取失败"
  347. br.ErrMsg = "获取失败,Err:" + errAdmin.Error()
  348. return
  349. }
  350. item.Editor = adminInfo.RealName
  351. }*/
  352. if item.HasChapter == 1 {
  353. item.CanEdit = true
  354. continue
  355. }
  356. markStatus, err := services.UpdateReportEditMark(item.Id, 0, this.SysUser.AdminId, 2, this.SysUser.RealName, this.Lang)
  357. if err != nil {
  358. br.Msg = "查询标记状态失败"
  359. br.ErrMsg = "查询标记状态失败,Err:" + err.Error()
  360. return
  361. }
  362. if markStatus.Status == 0 {
  363. item.CanEdit = true
  364. } else {
  365. item.Editor = markStatus.Editor
  366. }
  367. }
  368. page := paging.GetPaging(currentIndex, pageSize, total)
  369. resp := new(models.ReportListResp)
  370. resp.Paging = page
  371. resp.List = list
  372. br.Ret = 200
  373. br.Success = true
  374. br.Msg = "获取成功"
  375. br.Data = resp
  376. }
  377. // Add
  378. // @Title 新增报告接口
  379. // @Description 新增报告(不区分报告类型)
  380. // @Param request body models.AddReq true "type json string"
  381. // @Success 200 {object} models.AddResp
  382. // @router /add [post]
  383. func (this *ReportController) Add() {
  384. br := new(models.BaseResponse).Init()
  385. defer func() {
  386. this.Data["json"] = br
  387. this.ServeJSON()
  388. }()
  389. sysUser := this.SysUser
  390. if sysUser == nil {
  391. br.Msg = "请登录"
  392. br.ErrMsg = "请登录,SysUser Is Empty"
  393. br.Ret = 408
  394. return
  395. }
  396. var req models.AddReq
  397. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  398. if err != nil {
  399. br.Msg = "参数解析异常!"
  400. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  401. return
  402. }
  403. if req.Title == `` {
  404. br.Msg = "标题不能为空"
  405. br.ErrMsg = "标题不能为空"
  406. br.IsSendEmail = false
  407. return
  408. }
  409. if req.ClassifyIdFirst <= 0 {
  410. br.Msg = "分类必填"
  411. br.ErrMsg = "分类必填"
  412. br.IsSendEmail = false
  413. return
  414. }
  415. var contentSub string
  416. if req.Content != "" {
  417. req.Content = services.HandleReportContent(req.Content, "del", nil)
  418. e := utils.ContentXssCheck(req.Content)
  419. if e != nil {
  420. br.Msg = "存在非法标签"
  421. br.ErrMsg = "存在非法标签, Err: " + e.Error()
  422. return
  423. }
  424. content, e := services.FilterReportContentBr(req.Content)
  425. if e != nil {
  426. br.Msg = "内容去除前后空格失败"
  427. br.ErrMsg = "内容去除前后空格失败, Err: " + e.Error()
  428. return
  429. }
  430. req.Content = content
  431. contentSub, err = services.GetReportContentSub(req.Content)
  432. if err != nil {
  433. go alarm_msg.SendAlarmMsg("ContentSub 失败,Err:"+err.Error(), 3)
  434. //utils.SendEmail(utils.APPNAME+"失败提醒", "解析 ContentSub 失败,Err:"+err.Error(), utils.EmailSendToUsers)
  435. }
  436. }
  437. if req.ContentStruct != `` {
  438. req.ContentStruct = services.HandleReportContentStruct(req.ContentStruct, "del", nil)
  439. }
  440. // 报告期数
  441. maxStage, err := models.GetReportStage(req.ClassifyIdFirst, req.ClassifyIdSecond, req.ClassifyIdThird)
  442. if err != nil {
  443. br.Msg = "期数获取失败!"
  444. br.ErrMsg = "期数获取失败,Err:" + err.Error()
  445. return
  446. }
  447. // 根据审批开关及审批流判断当前报告状态
  448. state, e := services.CheckReportCurrState(report_approve.FlowReportTypeChinese, req.ClassifyIdFirst, req.ClassifyIdSecond, req.ClassifyIdThird, models.ReportOperateAdd)
  449. if e != nil {
  450. br.Msg = "操作失败"
  451. br.ErrMsg = "校验报告当前状态失败, Err: " + e.Error()
  452. return
  453. }
  454. // 协作方式,1:个人,2:多人协作。默认:1
  455. if req.CollaborateType == 0 {
  456. req.CollaborateType = 1
  457. }
  458. // 报告布局,1:常规布局,2:智能布局。默认:1
  459. if req.ReportLayout == 0 {
  460. req.ReportLayout = 1
  461. }
  462. // 是否公开发布,1:是,2:否
  463. if req.IsPublicPublish == 0 {
  464. req.IsPublicPublish = 1
  465. }
  466. classifyItemList, err := models.GetClassifyListByIdList([]int{req.ClassifyIdFirst, req.ClassifyIdSecond, req.ClassifyIdThird})
  467. classifyMap := make(map[int]string)
  468. for _, v := range classifyItemList {
  469. classifyMap[v.Id] = v.ClassifyName
  470. }
  471. item := new(models.Report)
  472. item.AddType = req.AddType
  473. item.ReportVersion = 2
  474. item.ClassifyIdFirst = req.ClassifyIdFirst
  475. item.ClassifyNameFirst = classifyMap[req.ClassifyIdFirst]
  476. item.ClassifyIdSecond = req.ClassifyIdSecond
  477. item.ClassifyNameSecond = classifyMap[req.ClassifyIdSecond]
  478. item.Title = req.Title
  479. item.Abstract = req.Abstract
  480. item.Author = req.Author
  481. item.Frequency = req.Frequency
  482. item.State = state
  483. item.Content = html.EscapeString(req.Content)
  484. item.Stage = maxStage + 1
  485. item.ContentSub = html.EscapeString(contentSub)
  486. item.CreateTime = req.CreateTime
  487. item.ModifyTime = time.Now()
  488. item.ReportVersion = req.ReportVersion
  489. item.AdminId = sysUser.AdminId
  490. item.AdminRealName = sysUser.RealName
  491. item.ClassifyIdThird = req.ClassifyIdThird
  492. item.ClassifyNameThird = classifyMap[req.ClassifyIdThird]
  493. // 产品要求,如果是多人协作,那么就是章节类型的报告
  494. if req.CollaborateType == 2 {
  495. item.HasChapter = 1
  496. item.ChapterType = ""
  497. }
  498. item.LastModifyAdminId = sysUser.AdminId
  499. item.LastModifyAdminName = sysUser.RealName
  500. item.ContentModifyTime = time.Now()
  501. item.NeedSplice = 1
  502. item.ContentStruct = html.EscapeString(req.ContentStruct)
  503. item.HeadImg = req.HeadImg
  504. item.EndImg = req.EndImg
  505. item.CanvasColor = req.CanvasColor
  506. item.HeadResourceId = req.HeadResourceId
  507. item.EndResourceId = req.EndResourceId
  508. item.CollaborateType = req.CollaborateType
  509. item.ReportLayout = req.ReportLayout
  510. item.IsPublicPublish = req.IsPublicPublish
  511. item.ReportCreateTime = time.Now()
  512. reportDate := time.Now()
  513. t, _ := time.ParseInLocation(utils.FormatDate, req.CreateTime, time.Local)
  514. if !t.IsZero() {
  515. reportDate = t
  516. }
  517. err, errMsg := services.AddReportAndChapter(item, req.InheritReportId, req.GrantAdminIdList, reportDate)
  518. if err != nil {
  519. br.Msg = "保存失败"
  520. if errMsg != "" {
  521. br.Msg = errMsg
  522. }
  523. br.ErrMsg = "保存失败,Err:" + err.Error()
  524. return
  525. }
  526. recordItem := &models.ReportStateRecord{
  527. ReportId: item.Id,
  528. ReportType: 1,
  529. State: 1,
  530. AdminId: this.SysUser.AdminId,
  531. AdminName: this.SysUser.AdminName,
  532. CreateTime: time.Now(),
  533. }
  534. go func() {
  535. _, _ = models.AddReportStateRecord(recordItem)
  536. }()
  537. resp := new(models.AddResp)
  538. resp.ReportId = int64(item.Id)
  539. resp.ReportCode = item.ReportCode
  540. br.Ret = 200
  541. br.Success = true
  542. br.Msg = "保存成功"
  543. br.Data = resp
  544. }
  545. // Edit
  546. // @Title 编辑报告基础信息接口
  547. // @Description 编辑报告基础信息(不区分报告类型)
  548. // @Param request body models.EditReq true "type json string"
  549. // @Success 200 {object} models.EditResp
  550. // @router /edit [post]
  551. func (this *ReportController) Edit() {
  552. br := new(models.BaseResponse).Init()
  553. defer func() {
  554. this.Data["json"] = br
  555. this.ServeJSON()
  556. }()
  557. sysUser := this.SysUser
  558. if sysUser == nil {
  559. br.Msg = "请登录"
  560. br.ErrMsg = "请登录,SysUser Is Empty"
  561. br.Ret = 408
  562. return
  563. }
  564. var req models.EditReq
  565. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  566. if err != nil {
  567. br.Msg = "参数解析异常!"
  568. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  569. return
  570. }
  571. //if req.Content == "" {
  572. // br.Msg = "报告内容不能为空"
  573. // return
  574. //}
  575. //更新标记key
  576. markStatus, err := services.UpdateReportEditMark(int(req.ReportId), 0, sysUser.AdminId, 1, sysUser.RealName, this.Lang)
  577. if err != nil {
  578. br.Msg = err.Error()
  579. return
  580. }
  581. if markStatus.Status == 1 {
  582. br.Msg = markStatus.Msg
  583. //br.Ret = 202 //202 服务器已接受请求,但尚未处理。
  584. return
  585. }
  586. reportInfo, e := models.GetReportByReportId(int(req.ReportId))
  587. if e != nil {
  588. if utils.IsErrNoRow(e) {
  589. br.Msg = "报告已被删除, 请刷新页面"
  590. return
  591. }
  592. br.Msg = "操作失败"
  593. br.ErrMsg = "获取报告失败, Err: " + e.Error()
  594. return
  595. }
  596. if reportInfo.State == models.ReportStatePublished || reportInfo.State == models.ReportStatePass {
  597. br.Msg = "该报告已发布,不允许编辑"
  598. br.ErrMsg = "该报告已发布,不允许编辑"
  599. br.IsSendEmail = false
  600. return
  601. }
  602. req.Content = services.HandleReportContentTable(int(req.ReportId), req.Content)
  603. req.ContentStruct = services.HandleReportContentStructTable(int(req.ReportId), req.ContentStruct)
  604. req.Content = services.HandleReportContent(req.Content, "del", nil)
  605. req.ContentStruct = services.HandleReportContentStruct(req.ContentStruct, "del", nil)
  606. // 编辑报告信息
  607. err, errMsg := services.EditReport(reportInfo, req, sysUser)
  608. if err != nil {
  609. br.Msg = "保存失败"
  610. if errMsg != "" {
  611. br.Msg = errMsg
  612. }
  613. br.ErrMsg = "保存失败,Err:" + err.Error()
  614. return
  615. }
  616. reportCode := utils.MD5(strconv.Itoa(int(req.ReportId)))
  617. resp := new(models.EditResp)
  618. resp.ReportId = req.ReportId
  619. resp.ReportCode = reportCode
  620. br.Ret = 200
  621. br.Success = true
  622. br.Msg = "保存成功"
  623. br.Data = resp
  624. }
  625. // Detail
  626. // @Title 获取报告详情接口
  627. // @Description 获取报告详情
  628. // @Param request body models.ReportDetailReq true "type json string"
  629. // @Success 200 {object} models.Report
  630. // @router /detail [get]
  631. func (this *ReportController) Detail() {
  632. br := new(models.BaseResponse).Init()
  633. defer func() {
  634. this.Data["json"] = br
  635. this.ServeJSON()
  636. }()
  637. /*var req models.ReportDetailReq
  638. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  639. if err != nil {
  640. br.Msg = "参数解析异常!"
  641. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  642. return
  643. }
  644. if req.ReportId <= 0 {
  645. br.Msg = "参数错误"
  646. return
  647. }*/
  648. reportId, err := this.GetInt("ReportId")
  649. if err != nil {
  650. br.Msg = "获取参数失败!"
  651. br.ErrMsg = "获取参数失败,Err:" + err.Error()
  652. return
  653. }
  654. if reportId <= 0 {
  655. br.Msg = "参数错误"
  656. return
  657. }
  658. item, err := models.GetReportById(reportId)
  659. if err != nil {
  660. if utils.IsErrNoRow(err) {
  661. br.Msg = "报告已被删除"
  662. return
  663. }
  664. br.Msg = "获取失败"
  665. br.ErrMsg = "获取失败,Err:" + err.Error()
  666. return
  667. }
  668. chapterList := make([]*models.ReportChapter, 0)
  669. if item.HasChapter == 1 {
  670. // 获取章节内容
  671. tmpChapterList, err := models.GetPublishedChapterListByReportId(item.Id)
  672. if err != nil {
  673. br.Msg = "获取失败"
  674. br.ErrMsg = "获取晨/周报章节列表失败, Err: " + err.Error()
  675. return
  676. }
  677. if len(tmpChapterList) > 0 {
  678. // 章节类型的字段赋值
  679. for _, item := range tmpChapterList {
  680. item.Content = html.UnescapeString(item.Content)
  681. item.ContentSub = html.UnescapeString(item.ContentSub)
  682. chapterList = append(chapterList, item)
  683. }
  684. }
  685. //item.Abstract = item.Title
  686. }
  687. item.Content = html.UnescapeString(item.Content)
  688. item.ContentSub = html.UnescapeString(item.ContentSub)
  689. item.ContentStruct = html.UnescapeString(item.ContentStruct)
  690. utils.FileLog.Info(item.ContentStruct)
  691. if item.HeadResourceId > 0 {
  692. headResource, err := smart_report.GetResourceItemById(item.HeadResourceId)
  693. if err != nil && err.Error() != utils.ErrNoRow() {
  694. br.Msg = "操作失败"
  695. br.ErrMsg = "获取资源库版头失败, Err: " + err.Error()
  696. return
  697. }
  698. if headResource != nil && headResource.ResourceId > 0 {
  699. item.HeadImg = headResource.ImgUrl
  700. item.HeadStyle = headResource.Style
  701. }
  702. }
  703. if item.EndResourceId > 0 {
  704. endResource, err := smart_report.GetResourceItemById(item.EndResourceId)
  705. if err != nil && err.Error() != utils.ErrNoRow() {
  706. br.Msg = "操作失败"
  707. br.ErrMsg = "获取资源库版尾失败, Err: " + err.Error()
  708. return
  709. }
  710. if endResource != nil && endResource.ResourceId > 0 {
  711. item.EndImg = endResource.ImgUrl
  712. item.EndStyle = endResource.Style
  713. }
  714. }
  715. item.Content = services.HandleReportContentTable(item.Id, item.Content)
  716. item.ContentStruct = services.HandleReportContentStructTable(item.Id, item.ContentStruct)
  717. utils.FileLog.Info(item.ContentStruct)
  718. fmt.Println("chapterList:", len(chapterList))
  719. for _, v := range chapterList {
  720. utils.FileLog.Info("chapterList")
  721. v.Content = services.HandleReportContentTable(item.Id, v.Content)
  722. v.ContentStruct = services.HandleReportContentStructTable(item.Id, v.ContentStruct)
  723. }
  724. businessConf, err := models.GetBusinessConfByKey(models.BusinessConfIsOpenChartExpired)
  725. if err != nil {
  726. br.Msg = "获取失败"
  727. br.ErrMsg = "获取配置失败,Err:" + err.Error()
  728. return
  729. }
  730. if businessConf.ConfVal == `true` {
  731. tokenMap := make(map[string]string)
  732. item.Content = services.HandleReportContent(item.Content, "add", tokenMap)
  733. item.ContentStruct = services.HandleReportContentStruct(item.ContentStruct, "add", tokenMap)
  734. for _, v := range chapterList {
  735. v.Content = services.HandleReportContent(v.Content, "add", tokenMap)
  736. v.ContentStruct = services.HandleReportContentStruct(v.ContentStruct, "add", tokenMap)
  737. }
  738. }
  739. classifyMap := make(map[int]*models.Classify) // 分类map
  740. classifyIdList := make([]int, 0)
  741. if item.ClassifyIdFirst > 0 {
  742. classifyIdList = append(classifyIdList, item.ClassifyIdFirst)
  743. }
  744. if item.ClassifyIdSecond > 0 {
  745. classifyIdList = append(classifyIdList, item.ClassifyIdSecond)
  746. }
  747. if item.ClassifyIdThird > 0 {
  748. classifyIdList = append(classifyIdList, item.ClassifyIdThird)
  749. }
  750. if len(classifyIdList) > 0 {
  751. classifyList, e := models.GetClassifyListByIdList(classifyIdList)
  752. if e != nil {
  753. br.Msg = "获取失败"
  754. br.ErrMsg = "获取报告分类失败, Err: " + e.Error()
  755. return
  756. }
  757. for _, v := range classifyList {
  758. classifyMap[v.Id] = v
  759. }
  760. if item.ClassifyIdThird > 0 {
  761. if classify, ok := classifyMap[item.ClassifyIdThird]; ok {
  762. if classify.Enabled == 1 {
  763. item.ClassifyEnabled = true
  764. }
  765. }
  766. } else if item.ClassifyIdSecond > 0 {
  767. if classify, ok := classifyMap[item.ClassifyIdSecond]; ok {
  768. if classify.Enabled == 1 {
  769. item.ClassifyEnabled = true
  770. }
  771. }
  772. } else if item.ClassifyIdFirst > 0 {
  773. if classify, ok := classifyMap[item.ClassifyIdFirst]; ok {
  774. if classify.Enabled == 1 {
  775. item.ClassifyEnabled = true
  776. }
  777. }
  778. }
  779. }
  780. resp := &models.ReportDetailView{
  781. ReportDetail: item,
  782. ChapterList: chapterList,
  783. }
  784. br.Ret = 200
  785. br.Success = true
  786. br.Msg = "获取成功"
  787. br.Data = resp
  788. }
  789. // SaveReportContent
  790. // @Title 保存草稿
  791. // @Description 保存草稿
  792. // @Param request body models.SaveReportContent true "type json string"
  793. // @Success 200 {object} models.ReportAuthorResp
  794. // @router /saveReportContent [post]
  795. func (this *ReportController) SaveReportContent() {
  796. fmt.Println("saveReportContent")
  797. br := new(models.BaseResponse).Init()
  798. br.IsSendEmail = false
  799. defer func() {
  800. this.Data["json"] = br
  801. this.ServeJSON()
  802. }()
  803. sysUser := this.SysUser
  804. if sysUser == nil {
  805. br.Msg = "请登录"
  806. br.ErrMsg = "请登录,SysUser Is Empty"
  807. br.Ret = 408
  808. return
  809. }
  810. var req models.SaveReportContent
  811. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  812. if err != nil {
  813. br.Msg = "参数解析异常!"
  814. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  815. return
  816. }
  817. reportId := req.ReportId
  818. noChangeFlag := req.NoChange
  819. if reportId <= 0 {
  820. resp := new(models.SaveReportContentResp)
  821. resp.ReportId = reportId
  822. br.Ret = 200
  823. br.Success = true
  824. br.Msg = "保存成功"
  825. br.Data = resp
  826. return
  827. }
  828. // 获取报告详情
  829. reportInfo, _ := models.GetReportByReportId(req.ReportId)
  830. if reportInfo != nil && reportInfo.State == 2 {
  831. br.Msg = "该报告已发布,不允许编辑"
  832. br.ErrMsg = "该报告已发布,不允许编辑"
  833. br.IsSendEmail = false
  834. return
  835. }
  836. // 标记更新中
  837. {
  838. markStatus, err := services.UpdateReportEditMark(req.ReportId, 0, sysUser.AdminId, 1, sysUser.RealName, this.Lang)
  839. if err != nil {
  840. br.Msg = err.Error()
  841. return
  842. }
  843. if markStatus.Status == 1 {
  844. br.Msg = markStatus.Msg
  845. return
  846. }
  847. }
  848. fmt.Println(req.ContentStruct)
  849. // 内容有过修改的话,那么逻辑处理
  850. if noChangeFlag != 1 {
  851. content := req.Content
  852. if content == "" {
  853. content = this.GetString("Content")
  854. }
  855. fmt.Println("line 833")
  856. fmt.Println(content)
  857. fmt.Println("line 835")
  858. content = services.HandleReportContent(content, "del", nil)
  859. fmt.Println("line 839")
  860. fmt.Println(content)
  861. fmt.Println("line 841")
  862. if content != "" {
  863. e := utils.ContentXssCheck(content)
  864. if e != nil {
  865. br.Msg = "存在非法标签"
  866. br.ErrMsg = "存在非法标签, Err: " + e.Error()
  867. return
  868. }
  869. //contentClean, e := services.FilterReportContentBr(content)
  870. //if e != nil {
  871. // br.Msg = "内容去除前后空格失败"
  872. // br.ErrMsg = "内容去除前后空格失败, Err: " + e.Error()
  873. // return
  874. //}
  875. //content = contentClean
  876. req.ContentStruct = services.HandleReportContentStruct(req.ContentStruct, "del", nil)
  877. contentSub, err := services.GetReportContentSub(content)
  878. if err != nil {
  879. go alarm_msg.SendAlarmMsg("解析 ContentSub 失败,Err:"+err.Error(), 3)
  880. //utils.SendEmail(utils.APPNAME+"失败提醒", "解析 ContentSub 失败,Err:"+err.Error(), utils.EmailSendToUsers)
  881. }
  882. //reportInfo.Content = html.EscapeString(req.Content) //html.EscapeString(content)
  883. reportInfo.Content = html.EscapeString(content)
  884. reportInfo.ContentSub = html.EscapeString(contentSub)
  885. reportInfo.ContentStruct = html.EscapeString(req.ContentStruct)
  886. reportInfo.HeadImg = req.HeadImg
  887. reportInfo.EndImg = req.EndImg
  888. reportInfo.CanvasColor = req.CanvasColor
  889. reportInfo.HeadResourceId = req.HeadResourceId
  890. reportInfo.EndResourceId = req.EndResourceId
  891. reportInfo.ModifyTime = time.Now()
  892. reportInfo.ContentModifyTime = time.Now()
  893. updateCols := []string{"Content", "ContentSub", "ContentStruct", "HeadImg", "EndImg", "CanvasColor", "HeadResourceId", "EndResourceId", "ModifyTime", "ContentModifyTime"}
  894. fmt.Println(reportInfo.ContentStruct)
  895. err = reportInfo.UpdateReport(updateCols)
  896. if err != nil {
  897. br.Msg = "保存失败"
  898. br.ErrMsg = "保存失败,Err:" + err.Error()
  899. return
  900. }
  901. go models.AddReportSaveLog(reportId, this.SysUser.AdminId, reportInfo.Content, reportInfo.ContentSub, reportInfo.ContentStruct, reportInfo.CanvasColor, this.SysUser.AdminName, reportInfo.HeadResourceId, reportInfo.EndResourceId)
  902. }
  903. }
  904. resp := new(models.SaveReportContentResp)
  905. resp.ReportId = reportId
  906. br.Ret = 200
  907. br.Success = true
  908. br.Msg = "保存成功"
  909. br.Data = resp
  910. }
  911. // AuthorizedListReport
  912. // @Title 获取有权限的报告列表接口
  913. // @Description 获取有权限的报告列表接口
  914. // @Param PageSize query int true "每页数据条数"
  915. // @Param CurrentIndex query int true "当前页页码,从1开始"
  916. // @Param Keyword query string true "搜索关键词"
  917. // @Param ClassifyIdFirst query int true "一级分类id"
  918. // @Param ClassifyIdSecond query int true "二级分类id"
  919. // @Param ClassifyIdThird query int true "三级分类id"
  920. // @Param State query string true "报告状态,多状态用英文,隔开"
  921. // @Success 200 {object} models.ReportListResp
  922. // @router /list/authorized [get]
  923. func (this *ReportController) AuthorizedListReport() {
  924. br := new(models.BaseResponse).Init()
  925. defer func() {
  926. this.Data["json"] = br
  927. this.ServeJSON()
  928. }()
  929. pageSize, _ := this.GetInt("PageSize")
  930. currentIndex, _ := this.GetInt("CurrentIndex")
  931. keyword := this.GetString("Keyword")
  932. classifyIdFirst, _ := this.GetInt("ClassifyIdFirst", 0)
  933. classifyIdSecond, _ := this.GetInt("ClassifyIdSecond", 0)
  934. classifyIdThird, _ := this.GetInt("ClassifyIdThird", 0)
  935. stateStr := this.GetString("State")
  936. var startSize int
  937. if pageSize <= 0 {
  938. pageSize = utils.PageSize20
  939. }
  940. if currentIndex <= 0 {
  941. currentIndex = 1
  942. }
  943. startSize = utils.StartIndex(currentIndex, pageSize)
  944. var list []*models.ReportList
  945. // 没有输入信息,那就不展示
  946. //if keyword == `` && classifyIdFirst <= 0 {
  947. // page := paging.GetPaging(currentIndex, pageSize, 0)
  948. // resp := new(models.ReportListResp)
  949. // resp.Paging = page
  950. // resp.List = list
  951. // br.Ret = 200
  952. // br.Success = true
  953. // br.Msg = "获取成功"
  954. // br.Data = resp
  955. // return
  956. //}
  957. // 当前用户有权限的报告id列表
  958. grantReportIdList := make([]int, 0)
  959. {
  960. obj := report.ReportGrant{}
  961. grantList, err := obj.GetGrantListByAdminId(this.SysUser.AdminId)
  962. if err != nil {
  963. br.Msg = "获取失败"
  964. br.ErrMsg = "获取授权报告id失败,Err:" + err.Error()
  965. return
  966. }
  967. for _, v := range grantList {
  968. grantReportIdList = append(grantReportIdList, v.ReportId)
  969. }
  970. }
  971. var condition string
  972. var pars []interface{}
  973. if classifyIdFirst > 0 {
  974. condition += ` AND a.classify_id_first = ? `
  975. pars = append(pars, classifyIdFirst)
  976. }
  977. if classifyIdSecond > 0 {
  978. condition += ` AND a.classify_id_second = ? `
  979. pars = append(pars, classifyIdSecond)
  980. }
  981. if classifyIdThird > 0 {
  982. condition += ` AND a.classify_id_third = ? `
  983. pars = append(pars, classifyIdThird)
  984. }
  985. if keyword != `` {
  986. condition += ` AND a.title LIKE ? `
  987. pars = utils.GetLikeKeywordPars(pars, keyword, 1)
  988. }
  989. if stateStr != `` {
  990. stateStrList := strings.Split(stateStr, ",")
  991. condition += ` AND a.state in (` + utils.GetOrmInReplace(len(stateStrList)) + `) `
  992. pars = append(pars, stateStrList)
  993. }
  994. var err error
  995. var total int
  996. // 如果不是超管,那么只能看到有权限的报告
  997. if !utils.IsAdminRole(this.SysUser.RoleTypeCode) {
  998. orCondition := `AND ( (a.is_public_publish = ? AND a.state in (2,6)) or a.admin_id = ? `
  999. pars = append(pars, 1, this.SysUser.AdminId)
  1000. // 当前用户有权限的报告id列表
  1001. num := len(grantReportIdList)
  1002. if num > 0 {
  1003. orCondition += ` OR a.id in (` + utils.GetOrmInReplace(num) + `)`
  1004. pars = append(pars, grantReportIdList)
  1005. }
  1006. orCondition += ` ) `
  1007. condition += orCondition
  1008. }
  1009. // 获取所有启用的分类
  1010. classifyList, err := models.GetAllEnabledClassify()
  1011. if err != nil {
  1012. br.Msg = "获取失败"
  1013. br.ErrMsg = "获取失败,Err:" + err.Error()
  1014. return
  1015. }
  1016. classifyIdNum := len(classifyList)
  1017. if classifyIdNum > 0 {
  1018. classifyIdList := make([]int, 0)
  1019. for _, v := range classifyList {
  1020. classifyIdList = append(classifyIdList, v.Id)
  1021. }
  1022. condition += ` AND a.classify_id_first in (` + utils.GetOrmInReplace(classifyIdNum) + `) AND a.classify_id_second in (` + utils.GetOrmInReplace(classifyIdNum) + `) AND a.classify_id_third in (` + utils.GetOrmInReplace(classifyIdNum) + `) `
  1023. pars = append(pars, classifyIdList, classifyIdList, classifyIdList)
  1024. }
  1025. total, err = models.GetReportListCountByAuthorized(condition, pars)
  1026. if err != nil {
  1027. br.Msg = "获取失败"
  1028. br.ErrMsg = "获取失败,Err:" + err.Error()
  1029. return
  1030. }
  1031. list, err = models.GetReportListByAuthorized(condition, pars, startSize, pageSize)
  1032. if err != nil {
  1033. br.Msg = "获取失败"
  1034. br.ErrMsg = "获取失败,Err:" + err.Error()
  1035. return
  1036. }
  1037. //for _, item := range list {
  1038. // if item.HasChapter == 1 {
  1039. // item.CanEdit = true
  1040. // } else {
  1041. // markStatus, err := services.UpdateReportEditMark(item.Id, this.SysUser.AdminId, 2, this.SysUser.RealName, this.Lang)
  1042. // if err != nil {
  1043. // br.Msg = "查询标记状态失败"
  1044. // br.ErrMsg = "查询标记状态失败,Err:" + err.Error()
  1045. // return
  1046. // }
  1047. // if markStatus.Status == 0 {
  1048. // item.CanEdit = true
  1049. // } else {
  1050. // item.Editor = markStatus.Editor
  1051. // }
  1052. // }
  1053. //}
  1054. page := paging.GetPaging(currentIndex, pageSize, total)
  1055. resp := new(models.ReportListResp)
  1056. resp.Paging = page
  1057. resp.List = list
  1058. br.Ret = 200
  1059. br.Success = true
  1060. br.Msg = "获取成功"
  1061. br.Data = resp
  1062. }
  1063. // BaseDetail
  1064. // @Title 获取报告基础信息详情接口
  1065. // @Description 获取报告基础信息详情接口
  1066. // @Param request body models.ReportDetailReq true "type json string"
  1067. // @Success 200 {object} models.Report
  1068. // @router /detail/base [get]
  1069. func (this *ReportController) BaseDetail() {
  1070. br := new(models.BaseResponse).Init()
  1071. defer func() {
  1072. this.Data["json"] = br
  1073. this.ServeJSON()
  1074. }()
  1075. /*var req models.ReportDetailReq
  1076. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  1077. if err != nil {
  1078. br.Msg = "参数解析异常!"
  1079. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  1080. return
  1081. }
  1082. if req.ReportId <= 0 {
  1083. br.Msg = "参数错误"
  1084. return
  1085. }*/
  1086. reportId, err := this.GetInt("ReportId")
  1087. if err != nil {
  1088. br.Msg = "获取参数失败!"
  1089. br.ErrMsg = "获取参数失败,Err:" + err.Error()
  1090. return
  1091. }
  1092. if reportId <= 0 {
  1093. br.Msg = "参数错误"
  1094. return
  1095. }
  1096. reportInfo, err := models.GetReportById(reportId)
  1097. if err != nil {
  1098. if utils.IsErrNoRow(err) {
  1099. br.Msg = "报告已被删除"
  1100. return
  1101. }
  1102. br.Msg = "获取失败"
  1103. br.ErrMsg = "获取失败,Err:" + err.Error()
  1104. return
  1105. }
  1106. // 基础信息就不获取章节信息了
  1107. chapterList := make([]*models.ReportChapter, 0)
  1108. reportInfo.Content = html.UnescapeString(reportInfo.Content)
  1109. reportInfo.ContentSub = html.UnescapeString(reportInfo.ContentSub)
  1110. grandAdminList := make([]models.ReportDetailViewAdmin, 0)
  1111. permissionList := make([]models.ReportDetailViewPermission, 0)
  1112. // 处理报告授权用户列表
  1113. {
  1114. obj := report.ReportGrant{}
  1115. grantList, tmpErr := obj.GetGrantListById(reportId)
  1116. if tmpErr != nil {
  1117. br.Msg = "获取章节id授权用户列表失败"
  1118. br.ErrMsg = "获取章节id授权用户列表失败, Err: " + tmpErr.Error()
  1119. return
  1120. }
  1121. if len(grantList) > 0 {
  1122. grandAdminIdList := make([]int, 0)
  1123. for _, v := range grantList {
  1124. grandAdminIdList = append(grandAdminIdList, v.AdminId)
  1125. }
  1126. adminList, tmpErr := system.GetAdminListByIdList(grandAdminIdList)
  1127. if tmpErr != nil {
  1128. br.Msg = "获取章节id授权用户列表失败"
  1129. br.ErrMsg = "获取章节id授权用户列表失败, Err: " + tmpErr.Error()
  1130. return
  1131. }
  1132. for _, v := range adminList {
  1133. grandAdminList = append(grandAdminList, models.ReportDetailViewAdmin{
  1134. AdminId: v.AdminId,
  1135. AdminName: v.RealName,
  1136. })
  1137. }
  1138. }
  1139. }
  1140. // 处理章节id关联品种id列表
  1141. {
  1142. minClassifyId := reportInfo.ClassifyIdThird
  1143. if minClassifyId <= 0 {
  1144. minClassifyId = reportInfo.ClassifyIdSecond
  1145. }
  1146. if minClassifyId <= 0 {
  1147. minClassifyId = reportInfo.ClassifyIdFirst
  1148. }
  1149. if minClassifyId <= 0 {
  1150. br.Msg = "分类异常"
  1151. br.ErrMsg = "分类异常"
  1152. return
  1153. }
  1154. // 获取分类关联的品种id
  1155. classifyPermissionList, tmpErr := models.GetPermission(minClassifyId)
  1156. if tmpErr != nil {
  1157. br.Msg = "获取分类信息失败"
  1158. br.ErrMsg = "获取失败,Err:" + tmpErr.Error()
  1159. return
  1160. }
  1161. if len(classifyPermissionList) > 0 {
  1162. permissionIdList := make([]int, 0)
  1163. for _, v := range classifyPermissionList {
  1164. permissionIdList = append(permissionIdList, v.ChartPermissionId)
  1165. }
  1166. adminList, tmpErr := models.GetChartPermissionByIdList(permissionIdList)
  1167. if tmpErr != nil {
  1168. br.Msg = "获取章节id授权用户列表失败"
  1169. br.ErrMsg = "获取章节id授权用户列表失败, Err: " + tmpErr.Error()
  1170. return
  1171. }
  1172. for _, v := range adminList {
  1173. permissionList = append(permissionList, models.ReportDetailViewPermission{
  1174. PermissionId: v.ChartPermissionId,
  1175. PermissionName: v.PermissionName,
  1176. })
  1177. }
  1178. }
  1179. }
  1180. resp := &models.ReportDetailView{
  1181. ReportDetail: reportInfo,
  1182. ChapterList: chapterList,
  1183. GrandAdminList: grandAdminList,
  1184. PermissionList: permissionList,
  1185. }
  1186. br.Ret = 200
  1187. br.Success = true
  1188. br.Msg = "获取成功"
  1189. br.Data = resp
  1190. }
  1191. // EditLayoutImg
  1192. // @Title 版图设置接口
  1193. // @Description 版图设置接口
  1194. // @Param request body models.EditLayoutImgReq true "type json string"
  1195. // @Success 200 {object} models.EditResp
  1196. // @router /layout_img/edit [post]
  1197. func (this *ReportController) EditLayoutImg() {
  1198. br := new(models.BaseResponse).Init()
  1199. defer func() {
  1200. this.Data["json"] = br
  1201. this.ServeJSON()
  1202. }()
  1203. sysUser := this.SysUser
  1204. if sysUser == nil {
  1205. br.Msg = "请登录"
  1206. br.ErrMsg = "请登录,SysUser Is Empty"
  1207. br.Ret = 408
  1208. return
  1209. }
  1210. var req models.EditLayoutImgReq
  1211. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  1212. if err != nil {
  1213. br.Msg = "参数解析异常!"
  1214. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  1215. return
  1216. }
  1217. //if req.Content == "" {
  1218. // br.Msg = "报告内容不能为空"
  1219. // return
  1220. //}
  1221. //更新标记key
  1222. markStatus, err := services.UpdateReportEditMark(int(req.ReportId), 0, sysUser.AdminId, 1, sysUser.RealName, this.Lang)
  1223. if err != nil {
  1224. br.Msg = err.Error()
  1225. return
  1226. }
  1227. if markStatus.Status == 1 {
  1228. br.Msg = markStatus.Msg
  1229. //br.Ret = 202 //202 服务器已接受请求,但尚未处理。
  1230. return
  1231. }
  1232. reportInfo, e := models.GetReportByReportId(int(req.ReportId))
  1233. if e != nil {
  1234. if utils.IsErrNoRow(e) {
  1235. br.Msg = "报告已被删除, 请刷新页面"
  1236. return
  1237. }
  1238. br.Msg = "操作失败"
  1239. br.ErrMsg = "获取报告失败, Err: " + e.Error()
  1240. return
  1241. }
  1242. if reportInfo.State == models.ReportStatePublished || reportInfo.State == models.ReportStatePass {
  1243. br.Msg = "该报告已发布,不允许编辑"
  1244. br.ErrMsg = "该报告已发布,不允许编辑"
  1245. br.IsSendEmail = false
  1246. return
  1247. }
  1248. // 编辑报告信息
  1249. err, errMsg := services.EditReportLayoutImg(reportInfo, req, sysUser)
  1250. if err != nil {
  1251. br.Msg = "保存失败"
  1252. if errMsg != "" {
  1253. br.Msg = errMsg
  1254. }
  1255. br.ErrMsg = "保存失败,Err:" + err.Error()
  1256. return
  1257. }
  1258. reportCode := utils.MD5(strconv.Itoa(int(req.ReportId)))
  1259. resp := new(models.EditResp)
  1260. resp.ReportId = req.ReportId
  1261. resp.ReportCode = reportCode
  1262. br.Ret = 200
  1263. br.Success = true
  1264. br.Msg = "保存成功"
  1265. br.Data = resp
  1266. }
  1267. // PublishReport
  1268. // @Title 发布报告接口
  1269. // @Description 发布报告
  1270. // @Param request body models.PublishReq true "type json string"
  1271. // @Success 200 Ret=200 发布成功
  1272. // @router /publish [post]
  1273. func (this *ReportController) PublishReport() {
  1274. br := new(models.BaseResponse).Init()
  1275. defer func() {
  1276. this.Data["json"] = br
  1277. this.ServeJSON()
  1278. }()
  1279. var req models.PublishReq
  1280. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  1281. if err != nil {
  1282. br.Msg = "参数解析异常!"
  1283. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  1284. return
  1285. }
  1286. reportIds := req.ReportIds
  1287. if reportIds == "" {
  1288. br.Msg = "参数错误"
  1289. br.ErrMsg = "参数错误,报告id不可为空"
  1290. return
  1291. }
  1292. // 这里实际上不会批量发布了...
  1293. reportArr := strings.Split(reportIds, ",")
  1294. tips := ""
  1295. for _, v := range reportArr {
  1296. vint, err := strconv.Atoi(v)
  1297. if err != nil {
  1298. br.Msg = "参数错误"
  1299. br.ErrMsg = "参数错误,Err:" + err.Error()
  1300. return
  1301. }
  1302. // 报告的图表刷新状态校验
  1303. refreshResult := data.CheckBatchChartRefreshResult("report", vint, 0)
  1304. if !refreshResult {
  1305. br.Msg = "图表刷新未完成,请稍后操作"
  1306. br.ErrMsg = "图表刷新未完成,请稍后操作"
  1307. br.IsSendEmail = false
  1308. return
  1309. }
  1310. // 报告发布
  1311. tmpTips, err, errMsg := services.PublishReport(vint, req.ReportUrl, this.SysUser)
  1312. if err != nil {
  1313. br.Msg = errMsg
  1314. br.ErrMsg = "报告发布失败,Err:" + err.Error()
  1315. return
  1316. }
  1317. tips = tmpTips
  1318. }
  1319. // 发布晨周报部分章节未发布的提示
  1320. if tips != "" {
  1321. br.Data = tips
  1322. }
  1323. br.Ret = 200
  1324. br.Success = true
  1325. br.Msg = "发布成功"
  1326. }
  1327. // PublishCancelReport
  1328. // @Title 取消发布报告接口
  1329. // @Description 取消发布报告
  1330. // @Param request body models.PublishCancelReq true "type json string"
  1331. // @Success 200 Ret=200 取消发布成功
  1332. // @router /publish/cancle [post]
  1333. func (this *ReportController) PublishCancelReport() {
  1334. br := new(models.BaseResponse).Init()
  1335. defer func() {
  1336. this.Data["json"] = br
  1337. this.ServeJSON()
  1338. }()
  1339. var req models.PublishCancelReq
  1340. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  1341. if err != nil {
  1342. br.Msg = "参数解析异常!"
  1343. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  1344. return
  1345. }
  1346. if req.ReportIds <= 0 {
  1347. br.Msg = "参数错误"
  1348. br.ErrMsg = "参数错误,报告id不可为空"
  1349. return
  1350. }
  1351. publishTimeNullFlag := true
  1352. reportInfo, err := models.GetReportById(req.ReportIds)
  1353. if err != nil {
  1354. br.Msg = "获取报告信息失败"
  1355. br.ErrMsg = "获取报告信息失败,Err:" + err.Error()
  1356. return
  1357. }
  1358. if reportInfo.MsgIsSend == 1 {
  1359. publishTimeNullFlag = false
  1360. }
  1361. // 根据审批开关及审批流判断当前报告状态
  1362. state, e := services.CheckReportCurrState(report_approve.FlowReportTypeChinese, reportInfo.ClassifyIdFirst, reportInfo.ClassifyIdSecond, reportInfo.ClassifyIdThird, models.ReportOperateCancelPublish)
  1363. if e != nil {
  1364. br.Msg = "操作失败"
  1365. br.ErrMsg = "校验报告当前状态失败, Err: " + e.Error()
  1366. return
  1367. }
  1368. err = models.PublishCancelReport(req.ReportIds, state, publishTimeNullFlag, this.SysUser.AdminId, this.SysUser.RealName)
  1369. if err != nil {
  1370. br.Msg = "取消发布失败"
  1371. br.ErrMsg = "取消发布失败,Err:" + err.Error()
  1372. return
  1373. }
  1374. // 更新ES禁用
  1375. {
  1376. go services.UpdateReportEs(req.ReportIds, 1)
  1377. }
  1378. //// 获取审批流设置
  1379. //confKey := "approval_flow"
  1380. //confTmp, e := company.GetConfigDetailByCode(confKey)
  1381. //if e != nil {
  1382. // br.Msg = "获取审批流配置失败"
  1383. // br.ErrMsg = "获取审批流配置失败, Err: " + e.Error()
  1384. // return
  1385. //}
  1386. //if confTmp.ConfigValue == "1" || confTmp.ConfigValue == "2" || confTmp.ConfigValue == "3" {
  1387. // br.Msg = "撤销成功"
  1388. //} else {
  1389. // br.Msg = "取消发布成功"
  1390. //}
  1391. recordItem := &models.ReportStateRecord{
  1392. ReportId: req.ReportIds,
  1393. ReportType: 1,
  1394. State: state,
  1395. AdminId: this.SysUser.AdminId,
  1396. AdminName: this.SysUser.AdminName,
  1397. CreateTime: time.Now(),
  1398. }
  1399. go func() {
  1400. _, _ = models.AddReportStateRecord(recordItem)
  1401. // 重置小程序详情页海报
  1402. _ = services.ResetMiniProgramReportDetailCover(reportInfo.Id)
  1403. }()
  1404. // 报告取消发布成功后,需要将相关信息入知识库
  1405. go cache.RagEtaReportOpToCache(reportInfo.Id, 0, `un_publish`)
  1406. br.Ret = 200
  1407. br.Success = true
  1408. }
  1409. // PrePublishReport
  1410. // @Title 设置定时发布接口
  1411. // @Description 设置定时发布接口
  1412. // @Param request body models.PrePublishReq true "type json string"
  1413. // @Success 200 Ret=200 发布成功
  1414. // @router /pre_publish [post]
  1415. func (this *ReportController) PrePublishReport() {
  1416. br := new(models.BaseResponse).Init()
  1417. defer func() {
  1418. this.Data["json"] = br
  1419. this.ServeJSON()
  1420. }()
  1421. var req models.PrePublishReq
  1422. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  1423. if err != nil {
  1424. br.Msg = "参数解析异常!"
  1425. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  1426. return
  1427. }
  1428. reportId := req.ReportId
  1429. if reportId == 0 {
  1430. br.Msg = "参数错误"
  1431. br.ErrMsg = "参数错误,报告id不可为空"
  1432. return
  1433. }
  1434. if req.PrePublishTime == "" {
  1435. br.Msg = "发布时间不能为空"
  1436. return
  1437. }
  1438. if req.PreMsgSend != 0 && req.PreMsgSend != 1 {
  1439. br.Msg = "参数错误"
  1440. br.ErrMsg = "是否发送模版消息标识错误"
  1441. return
  1442. }
  1443. prePublishTime, err := time.ParseInLocation(utils.FormatDateTime, req.PrePublishTime, time.Local)
  1444. if err != nil {
  1445. br.Msg = "发布时间格式错误"
  1446. br.ErrMsg = "发布时间格式错误,Err:" + err.Error()
  1447. return
  1448. }
  1449. if prePublishTime.Before(time.Now()) {
  1450. br.Msg = "发布时间不允许选择过去时间"
  1451. return
  1452. }
  1453. if prePublishTime.Before(time.Now().Add(2 * time.Minute)) {
  1454. br.Msg = "发布时间距离当前时间太近了"
  1455. return
  1456. }
  1457. reportDetail, err := models.GetReportById(reportId)
  1458. if err != nil {
  1459. br.Msg = "获取报告信息失败"
  1460. br.ErrMsg = "获取报告信息失败,Err:" + err.Error()
  1461. return
  1462. }
  1463. if reportDetail == nil {
  1464. br.Msg = "报告不存在"
  1465. return
  1466. }
  1467. // 如果是章节类型的报告,那么需要确认所有章节已发布
  1468. if reportDetail.HasChapter == 1 {
  1469. chapterList, err := models.GetChapterListByReportId(reportId)
  1470. if err != nil {
  1471. return
  1472. }
  1473. for _, chapter := range chapterList {
  1474. if chapter.PublishState == 1 {
  1475. br.Msg = "还存在未发布的章节"
  1476. br.ErrMsg = "还存在未发布的章节"
  1477. return
  1478. }
  1479. }
  1480. } else {
  1481. if reportDetail.Content == "" {
  1482. br.Msg = "报告内容为空,不可设置定时发布"
  1483. br.ErrMsg = "报告内容为空,不可设置定时发布,report_id:" + strconv.Itoa(reportDetail.Id)
  1484. return
  1485. }
  1486. }
  1487. if reportDetail.State == 2 {
  1488. br.Msg = "报告已发布,不可设置定时发布"
  1489. return
  1490. }
  1491. // 校验是否开启了审批流
  1492. opening, e := services.CheckReportOpenApprove(report_approve.FlowReportTypeChinese, reportDetail.ClassifyIdFirst, reportDetail.ClassifyIdSecond, reportDetail.ClassifyIdThird)
  1493. if e != nil {
  1494. br.Msg = "操作失败"
  1495. br.ErrMsg = "校验报告是否开启审批流失败, Err: " + e.Error()
  1496. return
  1497. }
  1498. if opening {
  1499. br.Msg = "报告已开启审批流, 不可设置定时发布"
  1500. return
  1501. }
  1502. var tmpErr error
  1503. if tmpErr = models.SetPrePublishReportById(reportDetail.Id, req.PrePublishTime, req.PreMsgSend); tmpErr != nil {
  1504. br.Msg = "设置定时发布失败"
  1505. br.ErrMsg = "设置定时发布失败, Err:" + tmpErr.Error() + ", report_id:" + strconv.Itoa(reportDetail.Id)
  1506. return
  1507. }
  1508. // 生成报告pdf和长图
  1509. {
  1510. reportPdfUrl := services.GetGeneralPdfUrl(reportDetail.Id, reportDetail.ReportCode, reportDetail.ClassifyNameFirst, reportDetail.ReportLayout)
  1511. go services.Report2pdfAndJpeg(reportPdfUrl, reportDetail.Id, 1)
  1512. }
  1513. br.Ret = 200
  1514. br.Success = true
  1515. br.Msg = "定时发布成功"
  1516. }
  1517. // SubmitApprove
  1518. // @Title 提交审批
  1519. // @Description 提交审批接口
  1520. // @Param request body models.ReportSubmitApproveReq true "type json string"
  1521. // @Success 200 Ret=200 操作成功
  1522. // @router /approve/submit [post]
  1523. func (this *ReportController) SubmitApprove() {
  1524. br := new(models.BaseResponse).Init()
  1525. defer func() {
  1526. if br.ErrMsg == "" {
  1527. br.IsSendEmail = false
  1528. }
  1529. this.Data["json"] = br
  1530. this.ServeJSON()
  1531. }()
  1532. sysUser := this.SysUser
  1533. if sysUser == nil {
  1534. br.Msg = "请登录"
  1535. br.ErrMsg = "请登录,SysUser Is Empty"
  1536. return
  1537. }
  1538. var req models.ReportSubmitApproveReq
  1539. if e := json.Unmarshal(this.Ctx.Input.RequestBody, &req); e != nil {
  1540. br.Msg = "参数有误"
  1541. br.ErrMsg = "参数解析失败, Err: " + e.Error()
  1542. return
  1543. }
  1544. reportId := req.ReportId
  1545. if reportId <= 0 {
  1546. br.Msg = "参数有误"
  1547. br.ErrMsg = fmt.Sprintf("参数有误, ReportId: %d", req.ReportId)
  1548. return
  1549. }
  1550. reportOb := new(models.Report)
  1551. reportItem, e := reportOb.GetItemById(reportId)
  1552. if e != nil {
  1553. if utils.IsErrNoRow(e) {
  1554. br.Msg = "报告已被删除, 请刷新页面"
  1555. return
  1556. }
  1557. br.Msg = "操作失败"
  1558. br.ErrMsg = "获取报告失败, Err: " + e.Error()
  1559. return
  1560. }
  1561. // 如果是章节类型的报告,那么需要确认所有章节已发布
  1562. if reportItem.HasChapter == 1 {
  1563. chapterList, err := models.GetChapterListByReportId(reportId)
  1564. if err != nil {
  1565. return
  1566. }
  1567. for _, chapter := range chapterList {
  1568. if chapter.PublishState == 1 {
  1569. br.Msg = "还存在未发布的章节"
  1570. br.ErrMsg = "还存在未发布的章节"
  1571. return
  1572. }
  1573. }
  1574. } else {
  1575. if reportItem.Content == "" {
  1576. br.Msg = "报告内容为空,不可提交"
  1577. br.ErrMsg = "报告内容为空,不可提交,report_id:" + strconv.Itoa(reportItem.Id)
  1578. return
  1579. }
  1580. }
  1581. // 校验当前审批配置, 返回下一个状态
  1582. state, e := services.CheckReportCurrState(report_approve.FlowReportTypeChinese, reportItem.ClassifyIdFirst, reportItem.ClassifyIdSecond, reportItem.ClassifyIdThird, models.ReportOperateSubmitApprove)
  1583. if e != nil {
  1584. br.Msg = "操作失败"
  1585. br.ErrMsg = "校验报告状态失败, Err: " + e.Error()
  1586. return
  1587. }
  1588. // 下一个状态不为待审批时, 仅更新状态
  1589. if state != models.ReportStateWaitApprove {
  1590. reportItem.State = state
  1591. e = reportItem.UpdateReport([]string{"State"})
  1592. if e != nil {
  1593. br.Msg = "操作失败"
  1594. br.ErrMsg = "更新报告状态失败, Err: " + e.Error()
  1595. return
  1596. }
  1597. br.Ret = 200
  1598. br.Success = true
  1599. br.Msg = "操作成功"
  1600. return
  1601. }
  1602. // 提交审批
  1603. approveId, e := services.SubmitReportApprove(report_approve.FlowReportTypeChinese, reportItem.Id, reportItem.Title, reportItem.ClassifyIdFirst, reportItem.ClassifyIdSecond, reportItem.ClassifyIdThird, sysUser.AdminId, sysUser.RealName)
  1604. if e != nil {
  1605. br.Msg = "操作失败"
  1606. br.ErrMsg = "提交审批失败, Err: " + e.Error()
  1607. return
  1608. }
  1609. reportItem.ApproveId = approveId
  1610. reportItem.State = models.ReportStateWaitApprove
  1611. reportItem.ModifyTime = time.Now().Local()
  1612. e = reportItem.UpdateReport([]string{"ApproveId", "State", "ModifyTime"})
  1613. if e != nil {
  1614. br.Msg = "操作失败"
  1615. br.ErrMsg = "更新报告状态失败, Err: " + e.Error()
  1616. return
  1617. }
  1618. // 报告权限处理
  1619. {
  1620. go services.HandleReportPermission(reportItem)
  1621. }
  1622. br.Ret = 200
  1623. br.Success = true
  1624. br.Msg = "操作成功"
  1625. }
  1626. // CancelApprove
  1627. // @Title 撤销审批
  1628. // @Description 撤销审批
  1629. // @Param request body models.ReportCancelApproveReq true "type json string"
  1630. // @Success 200 Ret=200 操作成功
  1631. // @router /approve/cancel [post]
  1632. func (this *ReportController) CancelApprove() {
  1633. br := new(models.BaseResponse).Init()
  1634. defer func() {
  1635. if br.ErrMsg == "" {
  1636. br.IsSendEmail = false
  1637. }
  1638. this.Data["json"] = br
  1639. this.ServeJSON()
  1640. }()
  1641. sysUser := this.SysUser
  1642. if sysUser == nil {
  1643. br.Msg = "请登录"
  1644. br.ErrMsg = "请登录,SysUser Is Empty"
  1645. return
  1646. }
  1647. var req models.ReportCancelApproveReq
  1648. if e := json.Unmarshal(this.Ctx.Input.RequestBody, &req); e != nil {
  1649. br.Msg = "参数有误"
  1650. br.ErrMsg = "参数解析失败, Err: " + e.Error()
  1651. return
  1652. }
  1653. reportId := req.ReportId
  1654. if reportId <= 0 {
  1655. br.Msg = "参数有误"
  1656. br.ErrMsg = fmt.Sprintf("参数有误, ReportId: %d", req.ReportId)
  1657. return
  1658. }
  1659. reportOb := new(models.Report)
  1660. reportItem, e := reportOb.GetItemById(reportId)
  1661. if e != nil {
  1662. if utils.IsErrNoRow(e) {
  1663. br.Msg = "报告已被删除, 请刷新页面"
  1664. return
  1665. }
  1666. br.Msg = "操作失败"
  1667. br.ErrMsg = "获取报告失败, Err: " + e.Error()
  1668. return
  1669. }
  1670. // 校验当前审批配置, 返回下一个状态
  1671. state, e := services.CheckReportCurrState(report_approve.FlowReportTypeChinese, reportItem.ClassifyIdFirst, reportItem.ClassifyIdSecond, reportItem.ClassifyIdThird, models.ReportOperateCancelApprove)
  1672. if e != nil {
  1673. br.Msg = "操作失败"
  1674. br.ErrMsg = "校验报告状态失败, Err: " + e.Error()
  1675. return
  1676. }
  1677. // 下一个状态不为待提交时, 仅更新状态
  1678. if state != models.ReportStateWaitSubmit {
  1679. reportItem.State = state
  1680. e = reportItem.UpdateReport([]string{"State"})
  1681. if e != nil {
  1682. br.Msg = "操作失败"
  1683. br.ErrMsg = "更新报告状态失败, Err: " + e.Error()
  1684. return
  1685. }
  1686. br.Ret = 200
  1687. br.Success = true
  1688. br.Msg = "操作成功"
  1689. return
  1690. }
  1691. //if reportItem.ApproveId <= 0 {
  1692. // br.Msg = "报告审批不存在"
  1693. // br.ErrMsg = fmt.Sprintf("报告审批不存在, ApproveId: %d", reportItem.ApproveId)
  1694. // return
  1695. //}
  1696. // 撤销审批
  1697. e = services.CancelReportApprove(report_approve.FlowReportTypeChinese, reportItem.Id, reportItem.ApproveId, sysUser.AdminId, sysUser.RealName)
  1698. if e != nil {
  1699. br.Msg = "操作失败"
  1700. br.ErrMsg = "撤销审批失败, Err: " + e.Error()
  1701. return
  1702. }
  1703. //reportItem.ApproveId = 0
  1704. //reportItem.State = models.ReportStateWaitSubmit
  1705. //reportItem.ModifyTime = time.Now().Local()
  1706. //e = reportItem.UpdateReport([]string{"ApproveId", "State", "ModifyTime"})
  1707. //if e != nil {
  1708. // br.Msg = "操作失败"
  1709. // br.ErrMsg = "更新报告状态失败, Err: " + e.Error()
  1710. // return
  1711. //}
  1712. // 重置小程序详情页海报
  1713. go func() {
  1714. _ = services.ResetMiniProgramReportDetailCover(reportItem.Id)
  1715. }()
  1716. // 报告发布成功后,需要将相关信息入知识库
  1717. go cache.RagEtaReportOpToCache(reportItem.Id, 0, `un_publish`)
  1718. br.Ret = 200
  1719. br.Success = true
  1720. br.Msg = "操作成功"
  1721. }
  1722. // ShareGenerate
  1723. // @Title 获取复制链接
  1724. // @Description 获取复制链接
  1725. // @Param request body models.ReportShartLinkReq true "type json string"
  1726. // @Success 200 Ret=200 操作成功
  1727. // @router /share/generate [post]
  1728. func (this *ReportController) ShareGenerate() {
  1729. br := new(models.BaseResponse).Init()
  1730. defer func() {
  1731. this.Data["json"] = br
  1732. this.ServeJSON()
  1733. }()
  1734. var req models.ReportShartUrlReq
  1735. if e := json.Unmarshal(this.Ctx.Input.RequestBody, &req); e != nil {
  1736. br.Msg = "参数有误"
  1737. br.ErrMsg = "参数解析失败, Err: " + e.Error()
  1738. return
  1739. }
  1740. var title string
  1741. reportItem, _ := models.GetReportByReportId(req.ReportId)
  1742. if reportItem != nil && reportItem.Title != "" {
  1743. title = reportItem.Title
  1744. }
  1745. link, err := services.GetReportShareUrlToken(req, this.SysUser.AdminId)
  1746. if err != nil || link == "" {
  1747. br.Msg = "复制链接失败"
  1748. br.ErrMsg = "获取复制链接失败, Err: " + err.Error()
  1749. return
  1750. }
  1751. resp := new(models.ReportShartUrlResp)
  1752. resp.UrlToken = fmt.Sprint(link, " ", title)
  1753. br.Ret = 200
  1754. br.Success = true
  1755. br.Msg = "获取成功"
  1756. br.Data = resp
  1757. }
  1758. // ShareTransform
  1759. // @Title 获取原始链接
  1760. // @Description 获取原始链接
  1761. // @Param Token query string true "复制链接的token"
  1762. // @Success 200 Ret=200 操作成功
  1763. // @router /share/link [get]
  1764. func (this *ReportCommonController) ShareTransform() {
  1765. br := new(models.BaseResponse).Init()
  1766. defer func() {
  1767. this.Data["json"] = br
  1768. this.ServeJSON()
  1769. }()
  1770. token := this.GetString("Token")
  1771. tokenArr := strings.Split(token, " ")
  1772. if len(tokenArr) > 0 {
  1773. token = tokenArr[0]
  1774. }
  1775. link, msg, err := services.TransfromToOriginUrl(token)
  1776. if err != nil {
  1777. if msg == "" {
  1778. msg = "获取失败"
  1779. }
  1780. htmlTpl := `
  1781. <!DOCTYPE html>
  1782. <html lang="zh">
  1783. <head>
  1784. <meta charset="UTF-8">
  1785. <title>链接失效</title>
  1786. </head>
  1787. <body>
  1788. <h1>链接失效</h1>
  1789. <p>%s</p>
  1790. </body>
  1791. </html>
  1792. `
  1793. htmlTpl = fmt.Sprintf(htmlTpl, msg)
  1794. this.Ctx.Output.SetStatus(404)
  1795. this.Ctx.Output.Body([]byte(htmlTpl))
  1796. utils.FileLog.Info("获取复制链接失败, Err: " + err.Error())
  1797. return
  1798. }
  1799. this.Ctx.Redirect(302, link)
  1800. br.Ret = 200
  1801. br.Success = true
  1802. br.Msg = "获取成功"
  1803. }
  1804. // init
  1805. // @Description: 修复历史报告数据
  1806. // @author: Roc
  1807. // @datetime 2024-06-21 09:19:05
  1808. func init() {
  1809. //fixApproveRecord()
  1810. //fixChapterPermission()
  1811. //fixReportEs()
  1812. //fixSmartReport()
  1813. }
  1814. // 修复研报审批数据
  1815. func fixApproveRecord() {
  1816. recordOb := new(report_approve.ReportApproveRecord)
  1817. recordCond := fmt.Sprintf(` AND %s = ? AND %s in (?,?)`, report_approve.ReportApproveRecordCols.NodeType, report_approve.ReportApproveRecordCols.State)
  1818. recordPars := make([]interface{}, 0)
  1819. recordPars = append(recordPars, 0, report_approve.ReportApproveStatePass, report_approve.ReportApproveStateRefuse)
  1820. list, e := recordOb.GetItemsByCondition(recordCond, recordPars, []string{}, "")
  1821. if e != nil {
  1822. fmt.Println("查找审批记录失败,Err:", e.Error())
  1823. return
  1824. }
  1825. for _, recordItem := range list {
  1826. //fmt.Println(recordItem)
  1827. recordItem.NodeState = recordItem.State
  1828. recordItem.NodeApproveUserId = recordItem.ApproveUserId
  1829. recordItem.NodeApproveUserName = recordItem.ApproveUserName
  1830. recordItem.NodeApproveTime = recordItem.ApproveTime
  1831. // 如果不是或签,那么只需要修复自己就好了
  1832. if recordItem.ApproveType != report_approve.NodeApproveTypeAny {
  1833. recordCols := []string{"State", "ApproveTime", "ModifyTime", "NodeState", "NodeApproveUserId", "NodeApproveUserName", "NodeApproveTime"}
  1834. if e = recordItem.Update(recordCols); e != nil {
  1835. fmt.Println("更新审批记录状态失败,Err:", e.Error())
  1836. }
  1837. continue
  1838. }
  1839. // 或签
  1840. // 需要将该审批的同一个节点的记录标记为已审批
  1841. if e := recordItem.UpdateNodeState(recordItem.ReportApproveId, recordItem.NodeId, recordItem.NodeState, recordItem.NodeApproveUserId, recordItem.NodeApproveUserName, recordItem.NodeApproveTime); e != nil {
  1842. fmt.Println("更新同一节点的其他审批记录状态失败,Err:", e.Error())
  1843. }
  1844. }
  1845. fmt.Println("审批数据修复完成")
  1846. }
  1847. // fixChapterPermission
  1848. // @Description: 修复章节关联的品种权限
  1849. // @author: Roc
  1850. // @datetime 2024-06-20 18:08:34
  1851. func fixChapterPermission() {
  1852. allChapterTypePermissionList, err := models.GetAllChapterTypePermission()
  1853. if err != nil {
  1854. fmt.Println("获取所有章节类型ID获取章节类型权限列表失败,Err:", err.Error())
  1855. return
  1856. }
  1857. currChapterTypePermissionIdListMap := make(map[int][]int)
  1858. hasPermissionMap := make(map[string]bool)
  1859. for _, v := range allChapterTypePermissionList {
  1860. tmpChapterTypePermissionList, ok := currChapterTypePermissionIdListMap[v.ReportChapterTypeId]
  1861. if !ok {
  1862. tmpChapterTypePermissionList = make([]int, 0)
  1863. }
  1864. key := fmt.Sprint(v.ReportChapterTypeId, "-", v.ChartPermissionId)
  1865. if _, has := hasPermissionMap[key]; !has {
  1866. hasPermissionMap[key] = true
  1867. currChapterTypePermissionIdListMap[v.ReportChapterTypeId] = append(tmpChapterTypePermissionList, v.ChartPermissionId)
  1868. }
  1869. }
  1870. //notIdList := []int{9675, 9675, 9740, 9749, 9768, 9773, 9791, 9792, 9793, 9850, 9851, 9852, 9852, 9852, 9853, 9854, 9856, 9857, 9857, 9858, 9859, 9860, 9861, 9862, 9862, 9863, 9866}
  1871. notIdList := []int{}
  1872. allReportChapterList, err := models.GetAllReportChapter()
  1873. if err != nil {
  1874. fmt.Println("获取所有章节失败,Err:", err.Error())
  1875. return
  1876. }
  1877. addList := make([]*report.ReportChapterPermissionMapping, 0)
  1878. for _, v := range allReportChapterList {
  1879. // 如果是上面的章节id,那么就过滤掉,因为已经入库了
  1880. if utils.InArrayByInt(notIdList, v.ReportChapterId) {
  1881. continue
  1882. }
  1883. permissionIdList, ok := currChapterTypePermissionIdListMap[v.TypeId]
  1884. if !ok {
  1885. continue
  1886. }
  1887. for _, permissionId := range permissionIdList {
  1888. addList = append(addList, &report.ReportChapterPermissionMapping{
  1889. ReportChapterPermissionMappingId: 0,
  1890. ReportChapterId: v.ReportChapterId,
  1891. ChartPermissionId: permissionId,
  1892. CreateTime: v.ModifyTime,
  1893. })
  1894. }
  1895. }
  1896. obj := report.ReportChapterPermissionMapping{}
  1897. err = obj.MultiAdd(addList)
  1898. if err != nil {
  1899. fmt.Println("批量添加报章节的品种权限失败,Err:", err.Error())
  1900. }
  1901. return
  1902. }
  1903. // fixReportEs
  1904. // @Description: 修复报告es数据
  1905. // @author: Roc
  1906. // @datetime 2024-06-20 18:08:34
  1907. func fixReportEs() {
  1908. //reportInfo, err := models.GetReportByReportId(3941)
  1909. //if err != nil {
  1910. // fmt.Println("查询信息失败,", err)
  1911. // return
  1912. //}
  1913. //content := utils.TrimHtml(html.UnescapeString(reportInfo.Content))
  1914. //fmt.Println(content)
  1915. //
  1916. //fmt.Println("=========================")
  1917. //
  1918. //chapterInfo, err := models.GetReportChapterInfoById(9637)
  1919. //if err != nil {
  1920. // fmt.Println("查询信息失败2,", err)
  1921. // return
  1922. //}
  1923. //
  1924. //content = utils.TrimHtml(html.UnescapeString(chapterInfo.Content))
  1925. //fmt.Println(content)
  1926. //
  1927. //services.UpdateReportChapterEs(9637)
  1928. //return
  1929. var condition string
  1930. var pars []interface{}
  1931. condition += " AND state in (2,6) "
  1932. list, err := models.GetReportListV1(condition, pars, 0, 100000)
  1933. if err != nil {
  1934. fmt.Println("查询信息失败,", err)
  1935. return
  1936. }
  1937. num := len(list)
  1938. fmt.Println(num, "条待修复报告es数据")
  1939. for k, v := range list {
  1940. fmt.Println("剩余", num-k, "条")
  1941. services.UpdateReportEs(v.Id, 2)
  1942. }
  1943. fmt.Println("报告ES数据修复完成")
  1944. return
  1945. }
  1946. // fixSmartReport
  1947. // @Description: 修复智能研报的数据
  1948. // @author: Roc
  1949. // @datetime 2024-06-27 16:54:41
  1950. func fixSmartReport() {
  1951. fmt.Println("修复智能研报开始")
  1952. // 先判断是否已经修复过数据,如果修复过,那么就不用修复了
  1953. {
  1954. condition := ` AND report_layout=2 and old_report_id>0 `
  1955. list, err := models.GetReportByCondition(condition, []interface{}{}, []string{}, " order by id asc ", false, 0, 0)
  1956. if err != nil {
  1957. fmt.Println("获取已修复的报告列表失败, Err:" + err.Error())
  1958. return
  1959. }
  1960. if len(list) > 0 {
  1961. fmt.Println("智能研报已经修复过数据,不需要再次修复")
  1962. return
  1963. }
  1964. }
  1965. var condition string
  1966. var pars []interface{}
  1967. reportOB := new(smart_report.SmartReport)
  1968. list, e := reportOB.GetItemsByCondition(condition, pars, []string{}, " smart_report_id asc ")
  1969. if e != nil {
  1970. fmt.Println("获取智能报告列表失败, Err:" + e.Error())
  1971. return
  1972. }
  1973. addList := make([]*models.Report, 0)
  1974. for _, v := range list {
  1975. fmt.Println(v)
  1976. addList = append(addList, &models.Report{
  1977. //Id: 0,
  1978. AddType: 1,
  1979. ClassifyIdFirst: v.ClassifyIdFirst,
  1980. ClassifyNameFirst: v.ClassifyNameFirst,
  1981. ClassifyIdSecond: v.ClassifyIdSecond,
  1982. ClassifyNameSecond: v.ClassifyNameSecond,
  1983. Title: v.Title,
  1984. Abstract: v.Abstract,
  1985. Author: v.Author,
  1986. Frequency: v.Frequency,
  1987. CreateTime: v.CreateTime.Format(utils.FormatDateTime),
  1988. ModifyTime: v.ModifyTime,
  1989. State: v.State,
  1990. PublishTime: v.PublishTime,
  1991. Stage: v.Stage,
  1992. MsgIsSend: v.MsgIsSend,
  1993. //ThsMsgIsSend: v.Tha,
  1994. Content: v.Content,
  1995. VideoUrl: v.VideoUrl,
  1996. VideoName: v.VideoName,
  1997. VideoPlaySeconds: fmt.Sprint(v.VideoPlaySeconds),
  1998. VideoSize: v.VideoSize,
  1999. ContentSub: v.ContentSub,
  2000. ReportCode: fmt.Sprint(v.SmartReportId),
  2001. ReportVersion: 1,
  2002. HasChapter: 0,
  2003. ChapterType: "",
  2004. OldReportId: v.SmartReportId,
  2005. MsgSendTime: v.MsgSendTime,
  2006. AdminId: v.AdminId,
  2007. AdminRealName: v.AdminRealName,
  2008. ApproveTime: v.ApproveTime,
  2009. ApproveId: v.ApproveId,
  2010. DetailImgUrl: v.DetailImgUrl,
  2011. DetailPdfUrl: v.DetailPdfUrl,
  2012. ContentStruct: v.ContentStruct,
  2013. LastModifyAdminId: v.LastModifyAdminId,
  2014. LastModifyAdminName: v.LastModifyAdminName,
  2015. ContentModifyTime: v.ContentModifyTime,
  2016. Pv: v.Pv,
  2017. Uv: v.Uv,
  2018. HeadImg: v.HeadImg,
  2019. EndImg: v.EndImg,
  2020. CanvasColor: v.CanvasColor,
  2021. NeedSplice: v.NeedSplice,
  2022. HeadResourceId: v.HeadResourceId,
  2023. EndResourceId: v.EndResourceId,
  2024. ClassifyIdThird: 0,
  2025. ClassifyNameThird: "",
  2026. CollaborateType: 1,
  2027. ReportLayout: 2,
  2028. IsPublicPublish: 1,
  2029. ReportCreateTime: v.CreateTime,
  2030. InheritReportId: 0,
  2031. })
  2032. }
  2033. if len(addList) > 0 {
  2034. err := models.InsertMultiReport(addList)
  2035. if err != nil {
  2036. fmt.Println("新增智能研报失败")
  2037. return
  2038. }
  2039. reportMap := make(map[int]*models.Report)
  2040. // 找出已经修复过的新的研报
  2041. {
  2042. reportList, tmpErr := models.GetReportByCondition(` AND report_layout=2 and old_report_id>0 `, []interface{}{}, []string{}, " order by id asc ", false, 0, 0)
  2043. if tmpErr != nil {
  2044. fmt.Println("获取已修复的报告列表失败, Err:" + tmpErr.Error())
  2045. return
  2046. }
  2047. for _, v := range reportList {
  2048. v.ReportCode = utils.MD5(strconv.Itoa(v.Id))
  2049. v.Update([]string{"ReportCode"})
  2050. reportMap[v.OldReportId] = v
  2051. }
  2052. }
  2053. // 找出智能研报的审批单并处理
  2054. {
  2055. // 智能研报走审批单的
  2056. reportApproveObj := new(report_approve.ReportApprove)
  2057. approveList, tmpErr := reportApproveObj.GetItemsByCondition(` AND report_type=3 `, []interface{}{}, []string{}, " report_approve_id asc ")
  2058. if tmpErr != nil {
  2059. fmt.Println("获取已修复的报告列表失败, Err:" + tmpErr.Error())
  2060. return
  2061. }
  2062. for _, v := range approveList {
  2063. reportInfo, ok := reportMap[v.ReportId]
  2064. if ok {
  2065. v.ReportId = reportInfo.Id
  2066. v.ReportType = 1
  2067. err = v.Update([]string{"ReportType", "ReportId"})
  2068. if err != nil {
  2069. fmt.Println(v.ReportApproveId, "数据修复失败,其对应的报告ID是:", v.ReportId, ";新的报告ID是:", reportInfo.Id)
  2070. }
  2071. } else {
  2072. fmt.Println(v.ReportApproveId, "找不到对应的报告,其对应的报告ID是:", v.ReportId)
  2073. }
  2074. }
  2075. }
  2076. }
  2077. fmt.Println("修复智能研报完成")
  2078. }
  2079. func initPdf() {
  2080. inFile := "anNNgk3Bbi4LRULwcJgNOPrREYh5.pdf"
  2081. f2, err := services.GeneralWaterMarkPdf(inFile, "颜鹏 - 18170239278")
  2082. //f2, err := services.GeneralWaterMarkPdf(inFile, "上周美国馏分油库存累库95万桶,馏分油表需环比下降(-25.6万桶/日)。本期馏分油产量继续抬升,在供增需减的环比变动下库存持续累库。馏分油供应的增加我们认为可能和进口的油种有关,今年以来美国进口的中重质原油占比不断走高,尤其是5")
  2083. if err != nil {
  2084. fmt.Println("生成失败,ERR:", err)
  2085. return
  2086. }
  2087. // 创建一个新的文件
  2088. newPdf, err := os.Create("new0555.pdf")
  2089. if err != nil {
  2090. fmt.Println("创建临时文件失败,Err:", err)
  2091. return
  2092. }
  2093. defer func() {
  2094. _ = newPdf.Close()
  2095. }()
  2096. _, _ = io.Copy(newPdf, f2)
  2097. }
  2098. //
  2099. //func init() {
  2100. // fmt.Println("start")
  2101. // contentStr := `[
  2102. // {
  2103. // &#34;child&#34;: [],
  2104. // &#34;compId&#34;: 1,
  2105. // &#34;compType&#34;: &#34;text&#34;,
  2106. // &#34;content&#34;: &#34;\u003cp style=\&#34;text-align: left; line-height: 2;\&#34;\u003e大青蛙低级趣味ID就ID几千万ID就wqjddwqdok qwopdk opdkwqop dkoqwpdkw opdwq\u003c/p\u003e\u003cp style=\&#34;text-align: left; line-height: 2;\&#34;\u003edqwk odpwkqdop kopwdkwoqdk \u0026nbsp;odqwkd okodpqwkdo pkopqwdk wkqd kwqdk dkowqkd opwqkdpwq大武口区打排位恐怕奎文区哦顶空瓶科维奇皮卡斗气网卡带\u003c/p\u003e\u003cp style=\&#34;text-align: left; line-height: 2;\&#34;\u003e\u003cbr\u003e\u003c/p\u003e\u003cp style=\&#34;text-align: left; line-height: 2;\&#34;\u003e\u003cspan style=&#39;color: rgb(0, 0, 0); font-family: \&#34;Helvetica Neue\&#34;, Helvetica, \&#34;PingFang SC\&#34;, \&#34;Hiragino Sans GB\&#34;, \&#34;Microsoft YaHei\&#34;, SimSun, sans-serif; font-size: 14px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(236, 242, 254); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial; display: inline !important; float: none;&#39;\u003eodpwkqdop kopwdkwoqdk \u0026nbsp;odqwkd oko\u003c/span\u003e\u003c/p\u003e\u003cp style=\&#34;text-align: left; line-height: 2;\&#34;\u003e\u003cbr\u003e\u003c/p\u003e\u003cp style=\&#34;text-align: left; line-height: 2;\&#34;\u003e\u003cspan style=&#39;color: rgb(0, 0, 0); font-family: \&#34;Helvetica Neue\&#34;, Helvetica, \&#34;PingFang SC\&#34;, \&#34;Hiragino Sans GB\&#34;, \&#34;Microsoft YaHei\&#34;, SimSun, sans-serif; font-size: 14px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(236, 242, 254); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial; display: inline !important; float: none;&#39;\u003eodpwkqdop kopwdkwoqdk \u0026nbsp;odqwkd oko\u003c/span\u003e\u003c/p\u003e&#34;,
  2107. // &#34;id&#34;: &#34;text1740624561014&#34;,
  2108. // &#34;style&#34;: &#34;&#34;,
  2109. // &#34;titleText&#34;: &#34;&#34;
  2110. // },
  2111. // {
  2112. // &#34;child&#34;: [],
  2113. // &#34;compId&#34;: 3,
  2114. // &#34;compType&#34;: &#34;chart&#34;,
  2115. // &#34;content&#34;: &#34;https://charttest.hzinsights.com/chartshow?code=3d349241d79f1030cf775131b5e9567c\u0026lang=zh\u0026sourceId=6433&#34;,
  2116. // &#34;id&#34;: &#34;chart1741856089441&#34;,
  2117. // &#34;style&#34;: &#34;height:350px&#34;,
  2118. // &#34;titleText&#34;: &#34;&#34;
  2119. // },
  2120. // {
  2121. // &#34;child&#34;: [],
  2122. // &#34;compId&#34;: 1,
  2123. // &#34;compType&#34;: &#34;text&#34;,
  2124. // &#34;content&#34;: &#34;\u003cp\u003e\u003cspan style=&#39;color: rgb(0, 0, 0); font-family: \&#34;Helvetica Neue\&#34;, Helvetica, \&#34;PingFang SC\&#34;, \&#34;Hiragino Sans GB\&#34;, \&#34;Microsoft YaHei\&#34;, SimSun, sans-serif; font-size: 14px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(236, 242, 254); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial; display: inline !important; float: none;&#39;\u003eodpwkqdop kopwdkwoqdk \u0026nbsp;odqwkd oko\u003c/span\u003e \u003cspan style=&#39;color: rgb(0, 0, 0); font-family: \&#34;Helvetica Neue\&#34;, Helvetica, \&#34;PingFang SC\&#34;, \&#34;Hiragino Sans GB\&#34;, \&#34;Microsoft YaHei\&#34;, SimSun, sans-serif; font-size: 14px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(236, 242, 254); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial; display: inline !important; float: none;&#39;\u003eodpwkqdop kopwdkwoqdk \u0026nbsp;odqwkd oko\u003c/span\u003e \u003c/p\u003e&#34;,
  2125. // &#34;id&#34;: &#34;text1744076936151&#34;,
  2126. // &#34;style&#34;: &#34;&#34;,
  2127. // &#34;titleText&#34;: &#34;&#34;
  2128. // }
  2129. //]`
  2130. //
  2131. // contentStr = `\u003cp\u003e\u003cspan style='color: rgb(0, 0, 0); font-family: \"Helvetica Neue\", Helvetica, \"PingFang SC\", \"Hiragino Sans GB\", \"Microsoft YaHei\", SimSun, sans-serif; font-size: 14px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(236, 242, 254); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial; display: inline !important; float: none;'\u003eodpwkqdop kopwdkwoqdk \u0026nbsp;odqwkd oko\u003c/span\u003e \u003cspan style='color: rgb(0, 0, 0); font-family: \"Helvetica Neue\", Helvetica, \"PingFang SC\", \"Hiragino Sans GB\", \"Microsoft YaHei\", SimSun, sans-serif; font-size: 14px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(236, 242, 254); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial; display: inline !important; float: none;'\u003eodpwkqdop kopwdkwoqdk \u0026nbsp;odqwkd oko\u003c/span\u003e \u003c/p\u003e`
  2132. // newStr := html.UnescapeString(contentStr)
  2133. // fmt.Println(newStr)
  2134. // //utils.FileLog.Info(newStr)
  2135. // //services.HandleReportContentStruct(req.ContentStruct, "del", nil)
  2136. //
  2137. // utils.FileLog.Info("$$$$$$$$$$$$$$$$")
  2138. // //tableStr := services.HandleReportContentStructTable(6433, newStr)
  2139. //
  2140. // utils.FileLog.Info(newStr)
  2141. // utils.FileLog.Info("$$$$$$$$$$$$$$$$")
  2142. // fmt.Println("end")
  2143. //}