balance_table.go 48 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717
  1. package excel
  2. import (
  3. "archive/zip"
  4. "encoding/json"
  5. "errors"
  6. "eta_gn/eta_api/models"
  7. "eta_gn/eta_api/models/data_manage"
  8. "eta_gn/eta_api/models/data_manage/excel"
  9. "eta_gn/eta_api/models/data_manage/excel/request"
  10. "eta_gn/eta_api/models/data_manage/excel/response"
  11. "eta_gn/eta_api/models/system"
  12. "eta_gn/eta_api/services/data"
  13. "eta_gn/eta_api/services/data/data_manage_permission"
  14. excelService "eta_gn/eta_api/services/data/excel"
  15. excel2 "eta_gn/eta_api/services/excel"
  16. "eta_gn/eta_api/utils"
  17. "fmt"
  18. "io/ioutil"
  19. "os"
  20. "sort"
  21. "strconv"
  22. "strings"
  23. "time"
  24. "github.com/tealeg/xlsx"
  25. )
  26. // GetChildTable
  27. // @Title 获取子表
  28. // @Description 获取子表
  29. // @Param request body request.MixedTableCellDataReq true "type json string"
  30. // @router /excel_info/child_table [get]
  31. func (c *ExcelInfoController) GetChildTable() {
  32. br := new(models.BaseResponse).Init()
  33. defer func() {
  34. c.Data["json"] = br
  35. c.ServeJSON()
  36. }()
  37. sysUser := c.SysUser
  38. if sysUser == nil {
  39. br.Msg = "请登录"
  40. br.ErrMsg = "请登录,SysUser Is Empty"
  41. br.Ret = 408
  42. return
  43. }
  44. parentId, _ := c.GetInt("ParentId")
  45. if parentId <= 0 {
  46. br.Msg = "请选择父表"
  47. return
  48. }
  49. list := make([]*excel.ExcelInfo, 0)
  50. // 查询所有子表
  51. childList, err := excel.GetChildExcelInfoByParentId(parentId)
  52. if err != nil {
  53. br.Msg = "查询子表失败"
  54. return
  55. }
  56. if len(childList) > 0 {
  57. list = childList
  58. }
  59. resp := &response.BalanceChildTableResp{List: list}
  60. br.Ret = 200
  61. br.Success = true
  62. br.Msg = "查询成功"
  63. br.Data = resp
  64. }
  65. // Rename
  66. // @Title 表格重命名接口
  67. // @Description 表格重命名接口
  68. // @Param request body request.EditExcelInfoReq true "type json string"
  69. // @Success 200 {object} response.AddExcelInfoResp
  70. // @router /excel_info/rename [post]
  71. func (c *ExcelInfoController) Rename() {
  72. br := new(models.BaseResponse).Init()
  73. defer func() {
  74. c.Data["json"] = br
  75. c.ServeJSON()
  76. }()
  77. sysUser := c.SysUser
  78. if sysUser == nil {
  79. br.Msg = "请登录"
  80. br.ErrMsg = "请登录,SysUser Is Empty"
  81. br.Ret = 408
  82. return
  83. }
  84. var req request.RenameExcelInfoReq
  85. err := json.Unmarshal(c.Ctx.Input.RequestBody, &req)
  86. if err != nil {
  87. br.Msg = "参数解析异常!"
  88. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  89. return
  90. }
  91. if req.ExcelInfoId <= 0 {
  92. br.Msg = "请传入ETA表格标识!"
  93. return
  94. }
  95. req.ExcelName = strings.Trim(req.ExcelName, " ")
  96. if req.ExcelName == "" {
  97. br.Msg = "请填写表格名称!"
  98. br.IsSendEmail = false
  99. return
  100. }
  101. excelInfo, err := excel.GetExcelInfoById(req.ExcelInfoId)
  102. if err != nil {
  103. br.Msg = "获取ETA表格失败"
  104. br.ErrMsg = "获取ETA表格失败,Err:" + err.Error()
  105. return
  106. }
  107. //判断表格是否存在
  108. var condition string
  109. var pars []interface{}
  110. condition += " AND excel_info_id != ? AND excel_classify_id=? AND excel_name=? AND parent_id=?"
  111. pars = append(pars, req.ExcelInfoId, excelInfo.ExcelClassifyId, req.ExcelName, excelInfo.ParentId)
  112. // 获取分类下是否存在该表格名称
  113. count, err := excel.GetExcelInfoCountByCondition(condition, pars)
  114. if err != nil {
  115. br.Msg = "ETA判断表格名称是否存在失败"
  116. br.ErrMsg = "判断ETA表格名称是否存在失败,Err:" + err.Error()
  117. return
  118. }
  119. if count > 0 {
  120. br.Msg = "ETA表格名称已存在,请重新填写"
  121. br.IsSendEmail = false
  122. return
  123. }
  124. // 操作权限校验, 增加协作人判断
  125. {
  126. checkExcelInfo := excelInfo
  127. if excelInfo.Source == utils.BALANCE_TABLE {
  128. checkExcelInfoId := excelInfo.ExcelInfoId
  129. if excelInfo.BalanceType == 1 {
  130. checkExcelInfoId = excelInfo.RelExcelInfoId
  131. } else {
  132. if excelInfo.ParentId > 0 {
  133. checkExcelInfoId = excelInfo.ParentId
  134. }
  135. }
  136. if checkExcelInfoId != excelInfo.ExcelInfoId {
  137. checkExcelInfo, err = excel.GetExcelInfoById(checkExcelInfoId)
  138. if err != nil {
  139. br.Msg = "获取平衡表格信息失败"
  140. br.ErrMsg = "获取平衡表格信息失败,Err:" + err.Error()
  141. return
  142. }
  143. }
  144. }
  145. // 数据权限
  146. haveOperaAuth, e := data_manage_permission.CheckExcelPermissionByExcelInfoId(checkExcelInfo.ExcelInfoId, checkExcelInfo.ExcelClassifyId, checkExcelInfo.IsJoinPermission, c.SysUser.AdminId)
  147. if e != nil {
  148. br.Msg = "获取ETA表格权限失败"
  149. br.ErrMsg = "获取表格权限信息失败,Err" + e.Error()
  150. return
  151. }
  152. button := excelService.GetBalanceExcelInfoOpButton(sysUser.AdminId, checkExcelInfo.SysUserId, haveOperaAuth, checkExcelInfo.ExcelInfoId)
  153. if !button.OpButton {
  154. br.Msg = "无操作权限"
  155. br.IsSendEmail = false
  156. return
  157. }
  158. }
  159. excelInfo.ModifyTime = time.Now()
  160. excelInfo.ExcelName = req.ExcelName
  161. excelInfo.UpdateUserId = sysUser.AdminId
  162. excelInfo.UpdateUserRealName = sysUser.RealName
  163. // 自动保存时不会传缩略图,也就不更新这个字段
  164. updateExcelInfoParams := []string{"ModifyTime", "ExcelName", "UpdateUserId", "UpdateUserRealName"}
  165. err = excelInfo.Update(updateExcelInfoParams)
  166. if err != nil {
  167. br.Msg = "保存失败"
  168. br.ErrMsg = "保存失败,Err:" + err.Error()
  169. return
  170. }
  171. resp := response.AddExcelInfoResp{
  172. ExcelInfoId: excelInfo.ExcelInfoId,
  173. UniqueCode: excelInfo.UniqueCode,
  174. }
  175. //删除公共图库那边的缓存
  176. _ = utils.Rc.Delete(utils.HZ_CHART_LIB_EXCEL_TABLE_DETAIL + ":" + excelInfo.UniqueCode)
  177. br.Ret = 200
  178. br.Success = true
  179. br.Msg = "修改成功"
  180. br.Data = resp
  181. br.IsAddLog = true
  182. }
  183. // SaveExcelWorker
  184. // @Title 新增编辑表格协作人接口
  185. // @Description 新增编辑表格协作人接口
  186. // @Param request body request.EditExcelInfoReq true "type json string"
  187. // @Success 200 {object} response.AddExcelInfoResp
  188. // @router /excel_info/worker/save [post]
  189. func (c *ExcelInfoController) SaveExcelWorker() {
  190. br := new(models.BaseResponse).Init()
  191. defer func() {
  192. c.Data["json"] = br
  193. c.ServeJSON()
  194. }()
  195. sysUser := c.SysUser
  196. if sysUser == nil {
  197. br.Msg = "请登录"
  198. br.ErrMsg = "请登录,SysUser Is Empty"
  199. br.Ret = 408
  200. return
  201. }
  202. var req request.SaveExcelInfoWorkerReq
  203. err := json.Unmarshal(c.Ctx.Input.RequestBody, &req)
  204. if err != nil {
  205. br.Msg = "参数解析异常!"
  206. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  207. return
  208. }
  209. if req.ExcelInfoId <= 0 {
  210. br.Msg = "请传入ETA表格标识!"
  211. return
  212. }
  213. excelInfo, err := excel.GetExcelInfoById(req.ExcelInfoId)
  214. if err != nil {
  215. br.Msg = "获取ETA表格失败"
  216. br.ErrMsg = "获取ETA表格失败,Err:" + err.Error()
  217. return
  218. }
  219. if excelInfo.SysUserId != sysUser.AdminId {
  220. br.Msg = "您没有权限操作!"
  221. br.ErrMsg = "您没有权限操作!"
  222. return
  223. }
  224. // 操作权限校验, 增加协作人判断
  225. {
  226. // 数据权限
  227. haveOperaAuth, err := data_manage_permission.CheckExcelPermissionByExcelInfoId(excelInfo.ExcelInfoId, excelInfo.ExcelClassifyId, excelInfo.IsJoinPermission, c.SysUser.AdminId)
  228. if err != nil {
  229. br.Msg = "获取ETA表格失败"
  230. br.ErrMsg = "获取ETA表格权限失败,Err:" + err.Error()
  231. return
  232. }
  233. button := excelService.GetExcelInfoOpButton(sysUser, excelInfo.SysUserId, excelInfo.Source, haveOperaAuth)
  234. if !button.OpButton {
  235. br.Msg = "无操作权限"
  236. br.IsSendEmail = false
  237. return
  238. }
  239. }
  240. obj := new(excel.ExcelWorker)
  241. notDeleteWorkerIds := make([]string, 0)
  242. workerMap := make(map[int]struct{})
  243. if req.SysUserIds != "" {
  244. notDeleteWorkerIds = strings.Split(req.SysUserIds, ",")
  245. }
  246. existList, err := obj.GetByExcelInfoId(req.ExcelInfoId)
  247. if err != nil {
  248. br.Msg = "获取表格协作人失败!"
  249. br.ErrMsg = "获取表格协作人失败,Err:" + err.Error()
  250. return
  251. }
  252. for _, v := range existList {
  253. workerMap[v.SysUserId] = struct{}{}
  254. }
  255. addIds := make([]int, 0)
  256. for _, v := range notDeleteWorkerIds {
  257. id, _ := strconv.Atoi(v)
  258. if _, ok := workerMap[id]; !ok {
  259. addIds = append(addIds, id)
  260. }
  261. }
  262. // 查询协作人姓名
  263. adminList, err := system.GetAdminListByIdListWithoutEnable(addIds)
  264. addList := make([]*excel.ExcelWorker, 0)
  265. for _, v := range adminList {
  266. addList = append(addList, &excel.ExcelWorker{
  267. ExcelInfoId: req.ExcelInfoId,
  268. SysUserId: v.AdminId,
  269. SysUserRealName: v.RealName,
  270. CreateTime: time.Now(),
  271. ModifyTime: time.Now(),
  272. })
  273. }
  274. // 保存协作人
  275. err = obj.AddWorker(req.ExcelInfoId, addList, notDeleteWorkerIds)
  276. if err != nil {
  277. br.Msg = "保存失败"
  278. br.ErrMsg = "保存失败,Err:" + err.Error()
  279. return
  280. }
  281. br.Ret = 200
  282. br.Success = true
  283. br.Msg = "操作成功"
  284. }
  285. // GetWorker
  286. // @Title 查询协作人接口
  287. // @Description 新增编辑表格协作人接口
  288. // @Param request body request.EditExcelInfoReq true "type json string"
  289. // @Success 200 {object} response.AddExcelInfoResp
  290. // @router /excel_info/worker [get]
  291. func (c *ExcelInfoController) GetWorker() {
  292. br := new(models.BaseResponse).Init()
  293. defer func() {
  294. c.Data["json"] = br
  295. c.ServeJSON()
  296. }()
  297. sysUser := c.SysUser
  298. if sysUser == nil {
  299. br.Msg = "请登录"
  300. br.ErrMsg = "请登录,SysUser Is Empty"
  301. br.Ret = 408
  302. return
  303. }
  304. excelInfoId, _ := c.GetInt("ExcelInfoId")
  305. if excelInfoId <= 0 {
  306. br.Msg = "请选择表格"
  307. br.ErrMsg = "ExcelInfoId未传"
  308. br.IsSendEmail = false
  309. return
  310. }
  311. obj := new(excel.ExcelWorker)
  312. list, err := obj.GetByExcelInfoId(excelInfoId)
  313. if err != nil {
  314. br.Msg = "获取表格协作人失败!"
  315. br.ErrMsg = "获取表格协作人失败,Err:" + err.Error()
  316. return
  317. }
  318. ret := &response.BalanceTableWorkerResp{List: list}
  319. br.Data = ret
  320. br.Ret = 200
  321. br.Success = true
  322. br.Msg = "操作成功"
  323. }
  324. // BalanceChartInfoAdd
  325. // @Title 新增图表接口
  326. // @Description 新增图表接口
  327. // @Param request body data_manage.AddChartInfoReq true "type json string"
  328. // @Success 200 {object} data_manage.AddChartInfoResp
  329. // @router /excel_info/balance/chart_add [post]
  330. func (c *ExcelInfoController) BalanceChartInfoAdd() {
  331. br := new(models.BaseResponse).Init()
  332. defer func() {
  333. c.Data["json"] = br
  334. c.ServeJSON()
  335. }()
  336. sysUser := c.SysUser
  337. if sysUser == nil {
  338. br.Msg = "请登录"
  339. br.ErrMsg = "请登录,SysUser Is Empty"
  340. br.Ret = 408
  341. return
  342. }
  343. deleteCache := true
  344. cacheKey := "CACHE_EXCEL_CHART_INFO_ADD_" + strconv.Itoa(sysUser.AdminId)
  345. defer func() {
  346. if deleteCache {
  347. utils.Rc.Delete(cacheKey)
  348. }
  349. }()
  350. if !utils.Rc.SetNX(cacheKey, 1, 30*time.Second) {
  351. deleteCache = false
  352. br.Msg = "系统处理中,请稍后重试!"
  353. br.ErrMsg = "系统处理中,请稍后重试!" + sysUser.RealName + ";data:" + string(c.Ctx.Input.RequestBody)
  354. return
  355. }
  356. var req request.AddBalanceTableChartReq
  357. err := json.Unmarshal(c.Ctx.Input.RequestBody, &req)
  358. if err != nil {
  359. br.Msg = "参数解析异常!"
  360. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  361. return
  362. }
  363. req.ChartName = strings.Trim(req.ChartName, " ")
  364. if req.ChartName == "" {
  365. br.Msg = "请填写图表名称!"
  366. return
  367. }
  368. // 获取表格信息
  369. excelInfo, err := excel.GetExcelInfoById(req.ExcelInfoId)
  370. if err != nil {
  371. br.Msg = "获取ETA表格失败"
  372. return
  373. }
  374. if excelInfo.Source != utils.BALANCE_TABLE {
  375. br.Msg = "EXCEL类型错误!"
  376. return
  377. }
  378. // 操作权限校验, 增加协作人判断
  379. {
  380. checkExcelInfo := excelInfo
  381. if excelInfo.Source == utils.BALANCE_TABLE {
  382. checkExcelInfoId := excelInfo.ExcelInfoId
  383. if excelInfo.BalanceType == 1 {
  384. checkExcelInfoId = excelInfo.RelExcelInfoId
  385. } else {
  386. if excelInfo.ParentId > 0 {
  387. checkExcelInfoId = excelInfo.ParentId
  388. }
  389. }
  390. if checkExcelInfoId != excelInfo.ExcelInfoId {
  391. checkExcelInfo, err = excel.GetExcelInfoById(checkExcelInfoId)
  392. if err != nil {
  393. br.Msg = "获取平衡表格信息失败"
  394. br.ErrMsg = "获取平衡表格信息失败,Err:" + err.Error()
  395. return
  396. }
  397. }
  398. }
  399. // 数据权限
  400. haveOperaAuth, e := data_manage_permission.CheckExcelPermissionByExcelInfoId(checkExcelInfo.ExcelInfoId, checkExcelInfo.ExcelClassifyId, checkExcelInfo.IsJoinPermission, c.SysUser.AdminId)
  401. if e != nil {
  402. br.Msg = "获取ETA表格权限失败"
  403. br.ErrMsg = "获取表格权限信息失败,Err" + e.Error()
  404. return
  405. }
  406. button := excelService.GetBalanceExcelInfoOpButton(sysUser.AdminId, checkExcelInfo.SysUserId, haveOperaAuth, checkExcelInfo.ExcelInfoId)
  407. if !button.OpButton {
  408. br.Msg = "无操作权限"
  409. br.IsSendEmail = false
  410. return
  411. }
  412. }
  413. // 判断如果是静态表,则查询表数据,落库
  414. dataListMap := make(map[int][]*data_manage.EdbDataList)
  415. if excelInfo.BalanceType == 1 {
  416. newExcelDataMap, excelAllRows, excelAllCols, e, errMsg := excelService.GetBalanceExcelData(excelInfo, c.Lang)
  417. if e != nil {
  418. br.Msg = "获取表格数据失败"
  419. if errMsg != "" {
  420. br.Msg = errMsg
  421. }
  422. br.ErrMsg = "获取表格数据失败,Err:" + e.Error()
  423. return
  424. }
  425. for k, mapping := range req.ChartEdbInfoList {
  426. tmpMapping := &excel.ExcelChartEdb{
  427. ExcelChartEdbId: k,
  428. DateSequence: mapping.DateSequenceStr,
  429. DataSequence: mapping.DataSequenceStr,
  430. }
  431. er, msg := excelService.GetBalanceExcelEdbData(tmpMapping, newExcelDataMap, dataListMap, excelAllRows, excelAllCols)
  432. if er != nil {
  433. utils.FileLog.Info(fmt.Sprintf(" 获取图表,指标信息失败 Err:%s, %s", msg, er.Error()))
  434. continue
  435. }
  436. }
  437. }
  438. chartInfo, err, errMsg, isSendEmail := data.AddBalanceExcelChart(excelInfo, req, sysUser, dataListMap)
  439. if err != nil {
  440. br.Msg = "保存失败"
  441. if errMsg != `` {
  442. br.Msg = errMsg
  443. }
  444. br.ErrMsg = err.Error()
  445. br.IsSendEmail = isSendEmail
  446. return
  447. }
  448. resp := new(data_manage.AddChartInfoResp)
  449. resp.ChartInfoId = chartInfo.ChartInfoId
  450. resp.UniqueCode = chartInfo.UniqueCode
  451. resp.ChartType = req.ChartType
  452. //新增操作日志
  453. {
  454. chartLog := new(data_manage.ChartInfoLog)
  455. chartLog.ChartInfoId = chartInfo.ChartInfoId
  456. chartLog.ChartName = req.ChartName
  457. chartLog.ChartClassifyId = 0
  458. chartLog.SysUserId = sysUser.AdminId
  459. chartLog.SysUserRealName = sysUser.RealName
  460. chartLog.UniqueCode = chartInfo.UniqueCode
  461. chartLog.CreateTime = time.Now()
  462. chartLog.Content = string(c.Ctx.Input.RequestBody)
  463. chartLog.Status = "新增图表"
  464. chartLog.Method = c.Ctx.Input.URI()
  465. go data_manage.AddChartInfoLog(chartLog)
  466. }
  467. br.Ret = 200
  468. br.Success = true
  469. br.Msg = "保存成功"
  470. br.Data = resp
  471. br.IsAddLog = true
  472. }
  473. // BalanceChartInfoEdit
  474. // @Title 编辑图表接口
  475. // @Description 新增图表接口
  476. // @Param request body data_manage.AddChartInfoReq true "type json string"
  477. // @Success 200 {object} data_manage.AddChartInfoResp
  478. // @router /excel_info/balance/chart_edit [post]
  479. func (c *ExcelInfoController) BalanceChartInfoEdit() {
  480. br := new(models.BaseResponse).Init()
  481. defer func() {
  482. c.Data["json"] = br
  483. c.ServeJSON()
  484. }()
  485. sysUser := c.SysUser
  486. if sysUser == nil {
  487. br.Msg = "请登录"
  488. br.ErrMsg = "请登录,SysUser Is Empty"
  489. br.Ret = 408
  490. return
  491. }
  492. deleteCache := true
  493. cacheKey := "CACHE_EXCEL_CHART_INFO_ADD_" + strconv.Itoa(sysUser.AdminId)
  494. defer func() {
  495. if deleteCache {
  496. utils.Rc.Delete(cacheKey)
  497. }
  498. }()
  499. if !utils.Rc.SetNX(cacheKey, 1, 30*time.Second) {
  500. deleteCache = false
  501. br.Msg = "系统处理中,请稍后重试!"
  502. br.ErrMsg = "系统处理中,请稍后重试!" + sysUser.RealName + ";data:" + string(c.Ctx.Input.RequestBody)
  503. return
  504. }
  505. var req request.AddBalanceTableChartReq
  506. err := json.Unmarshal(c.Ctx.Input.RequestBody, &req)
  507. if err != nil {
  508. br.Msg = "参数解析异常!"
  509. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  510. return
  511. }
  512. req.ChartName = strings.Trim(req.ChartName, " ")
  513. if req.ChartName == "" {
  514. br.Msg = "请填写图表名称!"
  515. return
  516. }
  517. if req.ChartInfoId <= 0 {
  518. br.Msg = "请选择图表"
  519. return
  520. }
  521. // 获取表格信息
  522. excelInfo, err := excel.GetExcelInfoById(req.ExcelInfoId)
  523. if err != nil {
  524. br.Msg = "获取ETA表格失败"
  525. return
  526. }
  527. if excelInfo.Source != utils.BALANCE_TABLE {
  528. br.Msg = "EXCEL类型错误!"
  529. return
  530. }
  531. // 操作权限校验, 增加协作人判断
  532. {
  533. checkExcelInfo := excelInfo
  534. if excelInfo.Source == utils.BALANCE_TABLE {
  535. checkExcelInfoId := excelInfo.ExcelInfoId
  536. if excelInfo.BalanceType == 1 {
  537. checkExcelInfoId = excelInfo.RelExcelInfoId
  538. } else {
  539. if excelInfo.ParentId > 0 {
  540. checkExcelInfoId = excelInfo.ParentId
  541. }
  542. }
  543. if checkExcelInfoId != excelInfo.ExcelInfoId {
  544. checkExcelInfo, err = excel.GetExcelInfoById(checkExcelInfoId)
  545. if err != nil {
  546. br.Msg = "获取平衡表格信息失败"
  547. br.ErrMsg = "获取平衡表格信息失败,Err:" + err.Error()
  548. return
  549. }
  550. }
  551. }
  552. // 数据权限
  553. haveOperaAuth, e := data_manage_permission.CheckExcelPermissionByExcelInfoId(checkExcelInfo.ExcelInfoId, checkExcelInfo.ExcelClassifyId, checkExcelInfo.IsJoinPermission, c.SysUser.AdminId)
  554. if e != nil {
  555. br.Msg = "获取ETA表格权限失败"
  556. br.ErrMsg = "获取表格权限信息失败,Err" + e.Error()
  557. return
  558. }
  559. button := excelService.GetBalanceExcelInfoOpButton(sysUser.AdminId, checkExcelInfo.SysUserId, haveOperaAuth, checkExcelInfo.ExcelInfoId)
  560. if !button.OpButton {
  561. br.Msg = "无操作权限"
  562. br.IsSendEmail = false
  563. return
  564. }
  565. }
  566. // 判断如果是静态表,则查询表数据,落库
  567. dataListMap := make(map[int][]*data_manage.EdbDataList)
  568. if excelInfo.BalanceType == 1 {
  569. newExcelDataMap, excelAllRows, excelAllCols, e, errMsg := excelService.GetBalanceExcelData(excelInfo, c.Lang)
  570. if e != nil {
  571. br.Msg = "获取表格数据失败"
  572. if errMsg != "" {
  573. br.Msg = errMsg
  574. }
  575. br.ErrMsg = "获取表格数据失败,Err:" + e.Error()
  576. return
  577. }
  578. for k, mapping := range req.ChartEdbInfoList {
  579. tmpMapping := &excel.ExcelChartEdb{
  580. ExcelChartEdbId: k,
  581. DateSequence: mapping.DateSequenceStr,
  582. DataSequence: mapping.DataSequenceStr,
  583. }
  584. er, msg := excelService.GetBalanceExcelEdbData(tmpMapping, newExcelDataMap, dataListMap, excelAllRows, excelAllCols)
  585. if er != nil {
  586. utils.FileLog.Info(fmt.Sprintf(" 获取图表,指标信息失败 Err:%s, %s", msg, er.Error()))
  587. continue
  588. }
  589. }
  590. }
  591. chartItem, err, errMsg, isSendEmail := data.EditBalanceExcelChart(excelInfo, req, sysUser, dataListMap)
  592. if err != nil {
  593. br.Msg = "保存失败"
  594. if errMsg != `` {
  595. br.Msg = errMsg
  596. }
  597. br.ErrMsg = err.Error()
  598. br.IsSendEmail = isSendEmail
  599. return
  600. }
  601. resp := new(data_manage.AddChartInfoResp)
  602. resp.ChartInfoId = chartItem.ChartInfoId
  603. resp.UniqueCode = chartItem.UniqueCode
  604. resp.ChartType = req.ChartType
  605. //新增操作日志
  606. {
  607. chartLog := new(data_manage.ChartInfoLog)
  608. chartLog.ChartName = chartItem.ChartName
  609. chartLog.ChartInfoId = req.ChartInfoId
  610. chartLog.ChartClassifyId = chartItem.ChartClassifyId
  611. chartLog.SysUserId = sysUser.AdminId
  612. chartLog.SysUserRealName = sysUser.RealName
  613. chartLog.UniqueCode = chartItem.UniqueCode
  614. chartLog.CreateTime = time.Now()
  615. chartLog.Content = string(c.Ctx.Input.RequestBody)
  616. chartLog.Status = "编辑图表"
  617. chartLog.Method = c.Ctx.Input.URL()
  618. go data_manage.AddChartInfoLog(chartLog)
  619. }
  620. br.Ret = 200
  621. br.Success = true
  622. br.Msg = "保存成功"
  623. br.Data = resp
  624. br.IsAddLog = true
  625. }
  626. // GetBalanceChartList
  627. // @Title 获取平衡表表关联的图表
  628. // @Description 获取平衡表表关联的图表
  629. // @Param request body request.MixedTableCellDataReq true "type json string"
  630. // @router /excel_info/balance/chart_list [get]
  631. func (c *ExcelInfoController) GetBalanceChartList() {
  632. br := new(models.BaseResponse).Init()
  633. defer func() {
  634. c.Data["json"] = br
  635. c.ServeJSON()
  636. }()
  637. sysUser := c.SysUser
  638. if sysUser == nil {
  639. br.Msg = "请登录"
  640. br.ErrMsg = "请登录,SysUser Is Empty"
  641. br.Ret = 408
  642. return
  643. }
  644. excelInfoId, _ := c.GetInt("ExcelInfoId")
  645. if excelInfoId <= 0 {
  646. br.Msg = "请选择平衡表"
  647. return
  648. }
  649. // 查询所有子表
  650. excelInfo, err := excel.GetExcelInfoById(excelInfoId)
  651. if err != nil {
  652. if utils.IsErrNoRow(err) {
  653. br.Msg = "表格不存在"
  654. return
  655. }
  656. br.Msg = "查询子表失败"
  657. br.ErrMsg = "查询子表失败,Err:" + err.Error()
  658. return
  659. }
  660. list := make([]*data_manage.BalanceChartInfoDetailResp, 0)
  661. chartInfoList, mappingListMap, dataListMap, err, errMsg := excelService.GetBalanceExcelChartList(excelInfo, "")
  662. if err != nil {
  663. if errMsg != "" {
  664. br.Msg = errMsg
  665. br.ErrMsg = err.Error()
  666. return
  667. } else {
  668. br.Msg = "查询图表失败"
  669. br.ErrMsg = "查询图表失败,Err:" + err.Error()
  670. }
  671. return
  672. }
  673. for _, chartInfo := range chartInfoList {
  674. mappingList, ok := mappingListMap[chartInfo.ChartInfoId]
  675. if !ok {
  676. br.Msg = "未找到图表关联的指标信息"
  677. return
  678. }
  679. var chartInfoResp *data_manage.ChartInfoDetailResp
  680. chartInfoResp, err, errMsg = data.GetBalanceExcelChartDetail(chartInfo, mappingList, sysUser, dataListMap)
  681. if err != nil {
  682. br.Msg = "查询图表详情失败"
  683. br.ErrMsg = "查询图表详情失败,Err:" + err.Error()
  684. return
  685. }
  686. chartEdbList := make([]*data_manage.ExcelChartEdbView, 0)
  687. for _, v := range mappingList {
  688. tmp := &data_manage.ExcelChartEdbView{
  689. ExcelChartEdbId: v.ExcelChartEdbId,
  690. DateSequenceStr: v.DateSequence,
  691. DataSequenceStr: v.DataSequence,
  692. FromTag: v.FromTag,
  693. }
  694. chartEdbList = append(chartEdbList, tmp)
  695. }
  696. balanceChartInfoResp := &data_manage.BalanceChartInfoDetailResp{
  697. ChartInfoDetailResp: chartInfoResp,
  698. ExcelEdbList: chartEdbList,
  699. }
  700. list = append(list, balanceChartInfoResp)
  701. }
  702. ret := &data_manage.BalanceTableChartListResp{List: list}
  703. br.Ret = 200
  704. br.Success = true
  705. br.Msg = "查询成功"
  706. br.Data = ret
  707. }
  708. // DeleteBalanceChart
  709. // @Title 删除平衡表图表
  710. // @Description 删除平衡表图表
  711. // @Param request body data_manage.DeleteChartClassifyReq true "type json string"
  712. // @Success 200 Ret=200 删除成功
  713. // @router /excel_info/balance/chart_del [post]
  714. func (c *ExcelInfoController) DeleteBalanceChart() {
  715. br := new(models.BaseResponse).Init()
  716. defer func() {
  717. c.Data["json"] = br
  718. c.ServeJSON()
  719. }()
  720. sysUser := c.SysUser
  721. if sysUser == nil {
  722. br.Msg = "请登录"
  723. br.ErrMsg = "请登录,SysUser Is Empty"
  724. br.Ret = 408
  725. return
  726. }
  727. var req data_manage.DeleteChartClassifyReq
  728. err := json.Unmarshal(c.Ctx.Input.RequestBody, &req)
  729. if err != nil {
  730. br.Msg = "参数解析异常!"
  731. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  732. return
  733. }
  734. if req.ChartInfoId <= 0 {
  735. br.Msg = "参数错误"
  736. br.IsSendEmail = false
  737. return
  738. }
  739. //删除图表
  740. if req.ChartInfoId > 0 {
  741. chartInfo, err := data_manage.GetChartInfoById(req.ChartInfoId)
  742. if err != nil {
  743. if utils.IsErrNoRow(err) {
  744. br.Msg = "图表已删除,请刷新页面"
  745. br.ErrMsg = "指标不存在,Err:" + err.Error()
  746. return
  747. } else {
  748. br.Msg = "删除失败"
  749. br.ErrMsg = "删除失败,获取指标信息失败,Err:" + err.Error()
  750. return
  751. }
  752. }
  753. if chartInfo == nil {
  754. br.Msg = "图表已删除,请刷新页面"
  755. return
  756. }
  757. // 操作权限校验, 增加协作人判断
  758. {
  759. // 获取表格信息
  760. excelInfo, e := excel.GetExcelInfoByChartInfoId(req.ChartInfoId)
  761. if e != nil {
  762. br.Msg = "获取ETA表格失败"
  763. return
  764. }
  765. checkExcelInfo := excelInfo
  766. if excelInfo.Source == utils.BALANCE_TABLE {
  767. checkExcelInfoId := excelInfo.ExcelInfoId
  768. if excelInfo.BalanceType == 1 {
  769. checkExcelInfoId = excelInfo.RelExcelInfoId
  770. } else {
  771. if excelInfo.ParentId > 0 {
  772. checkExcelInfoId = excelInfo.ParentId
  773. }
  774. }
  775. if checkExcelInfoId != excelInfo.ExcelInfoId {
  776. checkExcelInfo, e = excel.GetExcelInfoById(checkExcelInfoId)
  777. if e != nil {
  778. br.Msg = "获取平衡表格信息失败"
  779. br.ErrMsg = "获取平衡表格信息失败,Err:" + e.Error()
  780. return
  781. }
  782. }
  783. }
  784. // 数据权限
  785. haveOperaAuth, e := data_manage_permission.CheckExcelPermissionByExcelInfoId(checkExcelInfo.ExcelInfoId, checkExcelInfo.ExcelClassifyId, checkExcelInfo.IsJoinPermission, c.SysUser.AdminId)
  786. if e != nil {
  787. br.Msg = "获取ETA表格权限失败"
  788. br.ErrMsg = "获取表格权限信息失败,Err" + e.Error()
  789. return
  790. }
  791. button := excelService.GetBalanceExcelInfoOpButton(sysUser.AdminId, checkExcelInfo.SysUserId, haveOperaAuth, checkExcelInfo.ExcelInfoId)
  792. if !button.OpButton {
  793. br.Msg = "无操作权限"
  794. br.IsSendEmail = false
  795. return
  796. }
  797. }
  798. // 获取引用该图表的MyCharts, 用于ES删除
  799. var myCond string
  800. var myPars []interface{}
  801. myCond += ` AND a.chart_info_id = ? `
  802. myPars = append(myPars, req.ChartInfoId)
  803. myCharts, e := data_manage.GetMyChartListGroupByCharyInfoIdAndAdminIdByCondition(myCond, myPars)
  804. if e != nil {
  805. br.Msg = "删除失败"
  806. br.ErrMsg = "获取引用图表的MyChats失败, Err: " + e.Error()
  807. return
  808. }
  809. myIds := make([]int, 0)
  810. for _, m := range myCharts {
  811. myIds = append(myIds, m.MyChartId)
  812. }
  813. //删除图表及关联指标
  814. e = excel.DeleteBalanceExcelChartInfoAndData(req.ChartInfoId)
  815. if e != nil {
  816. br.Msg = "删除失败"
  817. br.ErrMsg = "删除失败,Err:" + e.Error()
  818. return
  819. }
  820. //删除ES
  821. {
  822. go data.DeleteChartInfoToEs(req.ChartInfoId)
  823. // 删除MY ETA 图表 es数据
  824. //go data.EsDeleteMyChartInfoByChartInfoId(req.ChartInfoId)
  825. go data.EsDeleteMyChartInfoByMyChartIds(myIds)
  826. }
  827. //新增操作日志
  828. {
  829. chartLog := new(data_manage.ChartInfoLog)
  830. chartLog.ChartName = chartInfo.ChartName
  831. chartLog.ChartInfoId = req.ChartInfoId
  832. chartLog.ChartClassifyId = chartInfo.ChartClassifyId
  833. chartLog.SysUserId = sysUser.AdminId
  834. chartLog.SysUserRealName = sysUser.RealName
  835. chartLog.UniqueCode = chartInfo.UniqueCode
  836. chartLog.CreateTime = time.Now()
  837. chartLog.Content = string(c.Ctx.Input.RequestBody)
  838. chartLog.Status = "删除图表"
  839. chartLog.Method = c.Ctx.Input.URI()
  840. go data_manage.AddChartInfoLog(chartLog)
  841. }
  842. }
  843. br.Ret = 200
  844. br.Msg = "删除成功"
  845. br.Success = true
  846. br.IsAddLog = true
  847. }
  848. // BalanceSeasonChartLegendPreview
  849. // @Title 季节性图例预览接口
  850. // @Description 季节性图例预览接口
  851. // @Param request body request.BalanceSeasonChartLegendPreviewReq true "type json string"
  852. // @Success 200 {object} data_manage.BalanceSeasonChartLegendPreviewResp
  853. // @router /excel_info/balance/chartLegend/preview [post]
  854. func (c *ExcelInfoController) BalanceSeasonChartLegendPreview() {
  855. br := new(models.BaseResponse).Init()
  856. defer func() {
  857. c.Data["json"] = br
  858. c.ServeJSON()
  859. }()
  860. sysUser := c.SysUser
  861. if sysUser == nil {
  862. br.Msg = "请登录"
  863. br.ErrMsg = "请登录,SysUser Is Empty"
  864. br.Ret = 408
  865. return
  866. }
  867. var req request.BalanceSeasonChartLegendPreviewReq
  868. err := json.Unmarshal(c.Ctx.Input.RequestBody, &req)
  869. if err != nil {
  870. br.Msg = "参数解析异常!"
  871. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  872. return
  873. }
  874. if len(req.DateArr) == 0 || len(req.DateArr) == 0 || len(req.DateArr) != len(req.DataArr) {
  875. br.Msg = "请输入正确的日期和数据"
  876. return
  877. }
  878. newDataMap := make(map[int]float64)
  879. for i, v := range req.DataArr {
  880. fv, e := strconv.ParseFloat(v, 64)
  881. if e != nil {
  882. br.Msg = "数据格式错误"
  883. return
  884. }
  885. newDataMap[i] = fv
  886. }
  887. //组装成excelEdbData
  888. dataList := make([]*data_manage.EdbDataList, 0)
  889. for i, v := range req.DateArr {
  890. dataTime, e := time.ParseInLocation(utils.FormatDate, v, time.Local)
  891. if e != nil {
  892. br.Msg = "日期格式错误"
  893. br.ErrMsg = v + "日期格式错误,Err:" + e.Error()
  894. return
  895. }
  896. timestamp := dataTime.UnixNano() / 1e6
  897. tmp := &data_manage.EdbDataList{
  898. EdbDataId: i,
  899. DataTime: v,
  900. DataTimestamp: timestamp,
  901. Value: newDataMap[i],
  902. }
  903. dataList = append(dataList, tmp)
  904. }
  905. // 对dataList 根据dataTimestamp 进行排序
  906. sort.Slice(dataList, func(i, j int) bool {
  907. return dataList[i].DataTimestamp < dataList[j].DataTimestamp
  908. })
  909. list, err, errMsg := data.GetBalanceExcelSeasonChartLegendPreview(dataList, req.Calendar, req.SeasonExtraConfig)
  910. if err != nil {
  911. if errMsg != "" {
  912. br.Msg = errMsg
  913. } else {
  914. br.Msg = "预览失败"
  915. }
  916. br.ErrMsg = err.Error()
  917. return
  918. }
  919. ret := &data_manage.BalanceSeasonChartLegendPreviewResp{List: list}
  920. br.Data = ret
  921. br.Ret = 200
  922. br.Success = true
  923. br.Msg = "操作成功"
  924. }
  925. // AddStaticExcel
  926. // @Title 新增静态表
  927. // @Description 新增静态表
  928. // @Param request body request.EditExcelInfoReq true "type json string"
  929. // @Success 200 {object} response.AddExcelInfoResp
  930. // @router /excel_info/balance/static/add [post]
  931. func (c *ExcelInfoController) AddStaticExcel() {
  932. br := new(models.BaseResponse).Init()
  933. defer func() {
  934. c.Data["json"] = br
  935. c.ServeJSON()
  936. }()
  937. sysUser := c.SysUser
  938. if sysUser == nil {
  939. br.Msg = "请登录"
  940. br.ErrMsg = "请登录,SysUser Is Empty"
  941. br.Ret = 408
  942. return
  943. }
  944. var req request.AddBalanceStaticExcelInfoReq
  945. err := json.Unmarshal(c.Ctx.Input.RequestBody, &req)
  946. if err != nil {
  947. br.Msg = "参数解析异常!"
  948. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  949. return
  950. }
  951. if req.ExcelInfoId <= 0 {
  952. br.Msg = "请传入ETA表格标识!"
  953. return
  954. }
  955. cacheKey := "CACHE_TABLE_INFO_BALANCE_STATIC_ADD_" + strconv.Itoa(req.ExcelInfoId)
  956. if !utils.Rc.SetNX(cacheKey, 1, 30*time.Second) {
  957. br.Msg = "系统处理中,请稍后重试!"
  958. br.ErrMsg = "系统处理中,请稍后重试!"
  959. return
  960. }
  961. defer func() {
  962. _ = utils.Rc.Delete(cacheKey)
  963. }()
  964. req.VersionName = strings.Trim(req.VersionName, " ")
  965. if req.VersionName == "" {
  966. br.Msg = "请填写版本名称!"
  967. br.IsSendEmail = false
  968. return
  969. }
  970. // 获取原ETA表格信息
  971. oldExcelInfo, err := excel.GetExcelInfoById(req.ExcelInfoId)
  972. if err != nil {
  973. br.Msg = "获取ETA表格失败"
  974. return
  975. }
  976. // 操作权限校验, 增加协作人判断
  977. {
  978. // 数据权限
  979. haveOperaAuth, err := data_manage_permission.CheckExcelPermissionByExcelInfoId(oldExcelInfo.ExcelInfoId, oldExcelInfo.ExcelClassifyId, oldExcelInfo.IsJoinPermission, c.SysUser.AdminId)
  980. if err != nil {
  981. br.Msg = "获取ETA表格失败"
  982. br.ErrMsg = "获取ETA表格权限失败,Err:" + err.Error()
  983. return
  984. }
  985. button := excelService.GetExcelInfoOpButton(sysUser, oldExcelInfo.SysUserId, oldExcelInfo.Source, haveOperaAuth)
  986. if !button.OpButton {
  987. br.Msg = "无操作权限"
  988. br.IsSendEmail = false
  989. return
  990. }
  991. }
  992. // 查询出每个子表的内容,并将内容转为静态版本
  993. excelDataMap := make(map[int]map[int][]*data_manage.EdbDataList)
  994. //查询动态表所有的子表,并复制为静态表
  995. condition := " AND parent_id = ? AND balance_type = 0 "
  996. var pars []interface{}
  997. pars = append(pars, req.ExcelInfoId)
  998. childExcelList, err := excel.GetExcelInfoListByCondition(condition, pars)
  999. if err != nil {
  1000. br.Msg = "获取子表失败"
  1001. br.ErrMsg = fmt.Sprintf("获取子表失败 %s", err.Error())
  1002. return
  1003. }
  1004. for k, childExcelInfo := range childExcelList {
  1005. //得到表格数据并落库
  1006. newExcelDataMap, excelAllRows, excelAllCols, e, errMsg := excelService.GetBalanceExcelData(childExcelInfo, c.Lang)
  1007. if e != nil {
  1008. br.Msg = "获取表格数据失败"
  1009. if errMsg != "" {
  1010. br.Msg = errMsg
  1011. }
  1012. br.ErrMsg = "获取表格数据失败,Err:" + e.Error()
  1013. return
  1014. }
  1015. tmpMappingList, e := excel.GetExcelChartEdbMappingByExcelInfoId(childExcelInfo.ExcelInfoId)
  1016. if e != nil {
  1017. br.Msg = "获取图表,指标信息失败"
  1018. br.ErrMsg = fmt.Sprintf(" 获取图表,指标信息失败 Err:%s", err.Error())
  1019. return
  1020. }
  1021. if len(tmpMappingList) > 0 {
  1022. for _, mapping := range tmpMappingList {
  1023. child, ok := excelDataMap[mapping.ChartInfoId]
  1024. if !ok {
  1025. child = make(map[int][]*data_manage.EdbDataList)
  1026. }
  1027. er, msg := excelService.GetBalanceExcelEdbData(mapping, newExcelDataMap, child, excelAllRows, excelAllCols)
  1028. if er != nil {
  1029. utils.FileLog.Info(fmt.Sprintf(" 获取图表,指标信息失败 Err:%s, %s", msg, er.Error()))
  1030. continue
  1031. }
  1032. excelDataMap[mapping.ChartInfoId] = child
  1033. }
  1034. }
  1035. content, e := excelService.TransferBalanceExcelContentToStatic(childExcelInfo, c.Lang)
  1036. if e != nil {
  1037. br.Msg = "动态内容转成静态失败"
  1038. br.ErrMsg = fmt.Sprintf("动态内容转成静态失败 %s", e.Error())
  1039. return
  1040. }
  1041. childExcelList[k].Content = content
  1042. }
  1043. excelInfo, err, errMsg, isSendEmail := data.AddBalanceStaticExcel(oldExcelInfo, oldExcelInfo.ExcelClassifyId, req.VersionName, sysUser, 0, req.ExcelInfoId, 1, childExcelList, true, excelDataMap)
  1044. if err != nil {
  1045. br.Msg = "复制失败"
  1046. if errMsg != `` {
  1047. br.Msg = errMsg
  1048. }
  1049. br.ErrMsg = "复制失败,Err:" + err.Error()
  1050. br.IsSendEmail = isSendEmail
  1051. return
  1052. }
  1053. resp := new(response.AddExcelInfoResp)
  1054. resp.ExcelInfoId = excelInfo.ExcelInfoId
  1055. resp.UniqueCode = excelInfo.UniqueCode
  1056. br.Ret = 200
  1057. br.Success = true
  1058. br.Msg = "保存成功"
  1059. br.Data = resp
  1060. br.IsAddLog = true
  1061. }
  1062. // BalanceVersionList
  1063. // @Title 查询平衡表版本号列表
  1064. // @Description 查询平衡表版本号列表
  1065. // @Param request body request.EditExcelInfoReq true "type json string"
  1066. // @Success 200 {object} response.AddExcelInfoResp
  1067. // @router /excel_info/balance/version [get]
  1068. func (c *ExcelInfoController) BalanceVersionList() {
  1069. br := new(models.BaseResponse).Init()
  1070. defer func() {
  1071. c.Data["json"] = br
  1072. c.ServeJSON()
  1073. }()
  1074. sysUser := c.SysUser
  1075. if sysUser == nil {
  1076. br.Msg = "请登录"
  1077. br.ErrMsg = "请登录,SysUser Is Empty"
  1078. br.Ret = 408
  1079. return
  1080. }
  1081. excelInfoId, _ := c.GetInt("ExcelInfoId")
  1082. if excelInfoId <= 0 {
  1083. br.Msg = "请选择表格"
  1084. br.ErrMsg = "ExcelInfoId未传"
  1085. br.IsSendEmail = false
  1086. return
  1087. }
  1088. excelInfo, err := excel.GetExcelInfoById(excelInfoId)
  1089. if err != nil {
  1090. br.Msg = "获取ETA表格失败"
  1091. br.ErrMsg = "获取ETA表格失败,Err:" + err.Error()
  1092. return
  1093. }
  1094. if excelInfo.Source != utils.BALANCE_TABLE {
  1095. br.Msg = "请选择平衡表"
  1096. return
  1097. }
  1098. if excelInfo.BalanceType != 0 && excelInfo.ParentId != 0 {
  1099. br.Msg = "请选择动态平衡表"
  1100. return
  1101. }
  1102. list := make([]*response.BalanceTableVersionListItem, 0)
  1103. list = append(list, &response.BalanceTableVersionListItem{
  1104. ExcelInfoId: excelInfo.ExcelInfoId,
  1105. UniqueCode: excelInfo.UniqueCode,
  1106. BalanceType: excelInfo.BalanceType,
  1107. RelExcelInfoId: excelInfo.RelExcelInfoId,
  1108. VersionName: "动态表", //todo 有个默认的版本名称
  1109. })
  1110. //查询动态表所有的子表,并复制为静态表
  1111. condition := " AND rel_excel_info_id=? AND parent_id = 0 AND balance_type = 1 "
  1112. var pars []interface{}
  1113. pars = append(pars, excelInfoId)
  1114. staticList, err := excel.GetNoContentExcelInfoListByConditionNoPage(condition, pars)
  1115. if err != nil {
  1116. br.Msg = "获取子表失败"
  1117. br.ErrMsg = fmt.Sprintf("获取子表失败 %s", err.Error())
  1118. return
  1119. }
  1120. for _, staticInfo := range staticList {
  1121. tmp := &response.BalanceTableVersionListItem{
  1122. ExcelInfoId: staticInfo.ExcelInfoId,
  1123. UniqueCode: staticInfo.UniqueCode,
  1124. BalanceType: staticInfo.BalanceType,
  1125. RelExcelInfoId: staticInfo.RelExcelInfoId,
  1126. VersionName: staticInfo.VersionName,
  1127. }
  1128. list = append(list, tmp)
  1129. }
  1130. ret := &response.BalanceTableVersionListResp{List: list}
  1131. br.Data = ret
  1132. br.Ret = 200
  1133. br.Success = true
  1134. br.Msg = "操作成功"
  1135. }
  1136. // ModifyBalanceExcelVersion
  1137. // @Title 版本号重命名
  1138. // @Description 版本号重命名
  1139. // @Param request body request.AddBalanceStaticExcelInfoReq true "type json string"
  1140. // @Success 200 {object} response.AddExcelInfoResp
  1141. // @router /excel_info/balance/version/modify [post]
  1142. func (c *ExcelInfoController) ModifyBalanceExcelVersion() {
  1143. br := new(models.BaseResponse).Init()
  1144. defer func() {
  1145. c.Data["json"] = br
  1146. c.ServeJSON()
  1147. }()
  1148. sysUser := c.SysUser
  1149. if sysUser == nil {
  1150. br.Msg = "请登录"
  1151. br.ErrMsg = "请登录,SysUser Is Empty"
  1152. br.Ret = 408
  1153. return
  1154. }
  1155. var req request.AddBalanceStaticExcelInfoReq
  1156. err := json.Unmarshal(c.Ctx.Input.RequestBody, &req)
  1157. if err != nil {
  1158. br.Msg = "参数解析异常!"
  1159. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  1160. return
  1161. }
  1162. if req.ExcelInfoId <= 0 {
  1163. br.Msg = "请传入ETA表格标识!"
  1164. return
  1165. }
  1166. req.VersionName = strings.Trim(req.VersionName, " ")
  1167. if req.VersionName == "" {
  1168. br.Msg = "请填写版本名称!"
  1169. br.IsSendEmail = false
  1170. return
  1171. }
  1172. excelInfo, err := excel.GetExcelInfoById(req.ExcelInfoId)
  1173. if err != nil {
  1174. br.Msg = "获取ETA表格失败"
  1175. br.ErrMsg = "获取ETA表格失败,Err:" + err.Error()
  1176. return
  1177. }
  1178. if excelInfo.Source != utils.BALANCE_TABLE {
  1179. br.Msg = "请选择平衡表"
  1180. return
  1181. }
  1182. if excelInfo.BalanceType != 1 && excelInfo.ParentId != 0 {
  1183. br.Msg = "请选择静态表"
  1184. return
  1185. }
  1186. // 操作权限校验, 增加协作人判断
  1187. {
  1188. checkExcelInfo := excelInfo
  1189. if excelInfo.Source == utils.BALANCE_TABLE {
  1190. checkExcelInfoId := excelInfo.ExcelInfoId
  1191. if excelInfo.BalanceType == 1 {
  1192. checkExcelInfoId = excelInfo.RelExcelInfoId
  1193. } else {
  1194. if excelInfo.ParentId > 0 {
  1195. checkExcelInfoId = excelInfo.ParentId
  1196. }
  1197. }
  1198. if checkExcelInfoId != excelInfo.ExcelInfoId {
  1199. checkExcelInfo, err = excel.GetExcelInfoById(checkExcelInfoId)
  1200. if err != nil {
  1201. br.Msg = "获取平衡表格信息失败"
  1202. br.ErrMsg = "获取平衡表格信息失败,Err:" + err.Error()
  1203. return
  1204. }
  1205. }
  1206. }
  1207. // 数据权限
  1208. haveOperaAuth, e := data_manage_permission.CheckExcelPermissionByExcelInfoId(checkExcelInfo.ExcelInfoId, checkExcelInfo.ExcelClassifyId, checkExcelInfo.IsJoinPermission, c.SysUser.AdminId)
  1209. if e != nil {
  1210. br.Msg = "获取ETA表格权限失败"
  1211. br.ErrMsg = "获取表格权限信息失败,Err" + e.Error()
  1212. return
  1213. }
  1214. button := excelService.GetBalanceExcelInfoOpButton(sysUser.AdminId, checkExcelInfo.SysUserId, haveOperaAuth, checkExcelInfo.ExcelInfoId)
  1215. if !button.OpButton {
  1216. br.Msg = "无操作权限"
  1217. br.IsSendEmail = false
  1218. return
  1219. }
  1220. }
  1221. // 检验分类下是否存在该版本号
  1222. {
  1223. var condition string
  1224. var pars []interface{}
  1225. condition += " AND rel_excel_info_id=? AND parent_id=0"
  1226. pars = append(pars, req.ExcelInfoId)
  1227. condition += " AND version_name=? "
  1228. pars = append(pars, req.VersionName)
  1229. count, tmpErr := excel.GetExcelInfoCountByCondition(condition, pars)
  1230. if tmpErr != nil {
  1231. br.Msg = "查询版本名称失败"
  1232. br.ErrMsg = tmpErr.Error()
  1233. return
  1234. }
  1235. if count > 0 {
  1236. br.Msg = "表格版本名称已存在,请重新填写版本名称"
  1237. br.IsSendEmail = false
  1238. return
  1239. }
  1240. }
  1241. excelInfo.ModifyTime = time.Now()
  1242. excelInfo.VersionName = req.VersionName
  1243. updateExcelInfoParams := []string{"ModifyTime", "VersionName"}
  1244. // todo 同步修改静态表中的图表和指标名称
  1245. // ETA表格信息变更
  1246. err = excelInfo.Update(updateExcelInfoParams)
  1247. if err != nil {
  1248. br.Msg = "操作失败"
  1249. br.ErrMsg = "操作失败,Err:" + err.Error()
  1250. return
  1251. }
  1252. br.Ret = 200
  1253. br.Success = true
  1254. br.Msg = "操作成功"
  1255. br.IsAddLog = true
  1256. }
  1257. func downloadBalanceTable(excelInfo *excel.ExcelInfo, lang string) (savePath, zipName string, uploadDir string, err error, errMsg string) {
  1258. dateDir := time.Now().Format("20060102")
  1259. randStr := time.Now().Format(utils.FormatDateTimeUnSpace)
  1260. uploadDir = "static/xls/" + dateDir + "/" + randStr
  1261. err = os.MkdirAll(uploadDir, utils.DIR_MOD)
  1262. if err != nil {
  1263. return
  1264. }
  1265. fileList := make([]string, 0)
  1266. if excelInfo.ParentId != 0 && excelInfo.BalanceType != 0 {
  1267. errMsg = "平衡表类型错误"
  1268. err = fmt.Errorf("平衡表类型错误 ")
  1269. return
  1270. }
  1271. //复制静态表
  1272. staticCondition := " AND parent_id = 0 AND balance_type = 1 AND rel_excel_info_id=? "
  1273. var staticPars []interface{}
  1274. staticPars = append(staticPars, excelInfo.ExcelInfoId)
  1275. excelList, err := excel.GetExcelInfoListByCondition(staticCondition, staticPars)
  1276. if err != nil {
  1277. errMsg = "获取表格失败"
  1278. err = fmt.Errorf("获取表格失败 %s", err.Error())
  1279. return
  1280. }
  1281. excelList = append(excelList, excelInfo)
  1282. for _, staticExcelInfo := range excelList {
  1283. cCondition := " AND parent_id = ?"
  1284. var cPars []interface{}
  1285. cPars = append(cPars, staticExcelInfo.ExcelInfoId)
  1286. childList, e := excel.GetExcelInfoListByCondition(cCondition, cPars)
  1287. if e != nil {
  1288. errMsg = "获取子表失败"
  1289. err = fmt.Errorf("获取子表失败 %s", err.Error())
  1290. return
  1291. }
  1292. xlsxFile := xlsx.NewFile()
  1293. fileName := staticExcelInfo.ExcelName + ".xlsx"
  1294. fpath := uploadDir + "/" + fileName
  1295. for _, childExcelInfo := range childList {
  1296. var result request.MixedTableReq
  1297. err = json.Unmarshal([]byte(childExcelInfo.Content), &result)
  1298. if err != nil {
  1299. errMsg = "获取失败"
  1300. err = fmt.Errorf("表格json转结构体失败,Err:" + err.Error())
  1301. return
  1302. }
  1303. newResult, er, msg := excelService.GetMixedTableCellData(result, lang)
  1304. if er != nil {
  1305. err = er
  1306. errMsg = msg
  1307. return
  1308. }
  1309. tableData, er := excel2.GetTableDataByMixedTableData(newResult, false, childExcelInfo.ExcelInfoId)
  1310. if er != nil {
  1311. errMsg = "获取失败"
  1312. err = fmt.Errorf("转换成table失败,Err:" + err.Error())
  1313. return
  1314. }
  1315. // 将单个sheet的数据写入到excel
  1316. err = tableData.WriteExcelSheetData(xlsxFile, childExcelInfo.ExcelName)
  1317. if err != nil {
  1318. return
  1319. }
  1320. }
  1321. //处理excel文件
  1322. //return
  1323. err = xlsxFile.Save(fpath)
  1324. if err != nil {
  1325. return
  1326. }
  1327. fileList = append(fileList, fileName)
  1328. }
  1329. // 创建zip
  1330. zipName = excelInfo.ExcelName + ".zip"
  1331. savePath = uploadDir + "/" + zipName
  1332. fmt.Println(savePath)
  1333. zipFile, err := os.Create(savePath)
  1334. if err != nil {
  1335. return
  1336. }
  1337. zipWriter := zip.NewWriter(zipFile)
  1338. // 生成zip过程中报错关闭
  1339. defer func() {
  1340. if err != nil {
  1341. zipWriter.Close()
  1342. zipFile.Close()
  1343. }
  1344. //os.Remove(savePath)
  1345. }()
  1346. //写入zip
  1347. for i := 0; i < len(fileList); i++ {
  1348. ioWriter, e := zipWriter.Create(fileList[i])
  1349. if e != nil {
  1350. err = fmt.Errorf("创建zip失败,Err:" + e.Error())
  1351. if os.IsPermission(e) {
  1352. fmt.Println("权限不足: ", e)
  1353. return
  1354. }
  1355. return
  1356. }
  1357. fullPath := uploadDir + "/" + fileList[i]
  1358. content, e := ioutil.ReadFile(fullPath)
  1359. if e != nil {
  1360. err = fmt.Errorf("读取文件失败,Err:" + e.Error())
  1361. return
  1362. }
  1363. ioWriter.Write(content)
  1364. }
  1365. // 生成zip后关闭,否则下载文件会损坏
  1366. zipWriter.Close()
  1367. zipFile.Close()
  1368. //this.Ctx.Output.Download(downLoadnFilePath, downloadFileName)
  1369. return
  1370. }
  1371. func refreshBalanceTable(excelDetail response.ExcelInfoDetail, lang string) (err error) {
  1372. edbInfoIds := make([]int, 0)
  1373. edbInfoIdExist := make(map[int]bool)
  1374. if excelDetail.ParentId > 0 {
  1375. newResult := excelDetail.TableData.(request.MixedTableReq)
  1376. newData := newResult.Data
  1377. if len(newData) > 0 {
  1378. for _, t := range newData {
  1379. for _, v := range t {
  1380. if v.EdbInfoId > 0 && !edbInfoIdExist[v.EdbInfoId] {
  1381. edbInfoIdExist[v.EdbInfoId] = true
  1382. edbInfoIds = append(edbInfoIds, v.EdbInfoId)
  1383. }
  1384. }
  1385. }
  1386. }
  1387. // 清除缓存
  1388. key := utils.HZ_CHART_LIB_EXCEL_TABLE_DETAIL + ":" + excelDetail.UniqueCode
  1389. if utils.Re == nil {
  1390. _ = utils.Rc.Delete(key)
  1391. }
  1392. } else {
  1393. //查询父表和子表
  1394. cCondition := " AND parent_id = ? AND balance_type=0"
  1395. var cPars []interface{}
  1396. cPars = append(cPars, excelDetail.ExcelInfoId)
  1397. childList, e := excel.GetExcelInfoListByCondition(cCondition, cPars)
  1398. if e != nil {
  1399. err = fmt.Errorf("获取子表失败 %s", err.Error())
  1400. return
  1401. }
  1402. // 遍历
  1403. for _, child := range childList {
  1404. var result request.MixedTableReq
  1405. err = json.Unmarshal([]byte(child.Content), &result)
  1406. if err != nil {
  1407. err = errors.New("表格json转结构体失败,Err:" + err.Error())
  1408. return
  1409. }
  1410. var newData [][]request.MixedTableCellDataReq
  1411. newData, err, _ = excelService.GetMixedTableCellData(result, lang)
  1412. if err != nil {
  1413. return
  1414. }
  1415. if len(newData) > 0 {
  1416. for _, t := range newData {
  1417. for _, v := range t {
  1418. if v.EdbInfoId > 0 && !edbInfoIdExist[v.EdbInfoId] {
  1419. edbInfoIdExist[v.EdbInfoId] = true
  1420. edbInfoIds = append(edbInfoIds, v.EdbInfoId)
  1421. }
  1422. }
  1423. }
  1424. }
  1425. // 清除缓存
  1426. key := utils.HZ_CHART_LIB_EXCEL_TABLE_DETAIL + ":" + child.UniqueCode
  1427. if utils.Re == nil {
  1428. _ = utils.Rc.Delete(key)
  1429. }
  1430. }
  1431. }
  1432. if len(edbInfoIds) > 0 {
  1433. err, _ = data.EdbInfoRefreshAllFromBaseV3(edbInfoIds, false, true, false)
  1434. if err != nil {
  1435. err = fmt.Errorf("刷新混合表格数据失败, Err: " + err.Error())
  1436. return
  1437. }
  1438. }
  1439. return
  1440. }
  1441. // BalanceChartInfoBaseEdit
  1442. // @Title 编辑图表基础信息接口
  1443. // @Description 编辑图表基础信息接口
  1444. // @Param request body data_manage.EditChartEnInfoBaseReq true "type json string"
  1445. // @Success Ret=200 编辑成功
  1446. // @router /excel_info/balance/chart_base_edit [post]
  1447. func (this *ExcelInfoController) BalanceChartInfoBaseEdit() {
  1448. br := new(models.BaseResponse).Init()
  1449. defer func() {
  1450. this.Data["json"] = br
  1451. this.ServeJSON()
  1452. }()
  1453. sysUser := this.SysUser
  1454. if sysUser == nil {
  1455. br.Msg = "请登录"
  1456. br.ErrMsg = "请登录,SysUser Is Empty"
  1457. br.Ret = 408
  1458. return
  1459. }
  1460. var req data_manage.EditChartInfoBaseReq
  1461. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  1462. if err != nil {
  1463. br.Msg = "参数解析异常!"
  1464. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  1465. return
  1466. }
  1467. req.ChartName = strings.Trim(req.ChartName, " ")
  1468. if req.ChartInfoId <= 0 {
  1469. br.Msg = "请选择图表"
  1470. return
  1471. }
  1472. //判断指标名称是否存在
  1473. chartItem, err := data_manage.GetChartInfoById(req.ChartInfoId)
  1474. if err != nil {
  1475. if utils.IsErrNoRow(err) {
  1476. br.Msg = "图表已被删除,请刷新页面"
  1477. br.ErrMsg = "图表已被删除,请刷新页面"
  1478. return
  1479. }
  1480. br.Msg = "获取图表信息失败"
  1481. br.ErrMsg = "获取图表信息失败,Err:" + err.Error()
  1482. return
  1483. }
  1484. // 判断是否有传入对应的指标配置
  1485. noEdbInfoType := []int{10}
  1486. if len(req.ChartEdbInfoList) <= 0 && !utils.InArrayByInt(noEdbInfoType, chartItem.ChartType) {
  1487. br.Msg = "请选择指标!"
  1488. return
  1489. }
  1490. var edbCondition string
  1491. var edbPars []interface{}
  1492. for _, v := range req.ChartEdbInfoList {
  1493. edbInfoId := v.EdbInfoId
  1494. edbInfo, err := excel.GetExcelChartEdbById(edbInfoId)
  1495. if err != nil {
  1496. if utils.IsErrNoRow(err) {
  1497. br.Msg = "图表不存在!"
  1498. br.ErrMsg = "图表指标不存在,ChartInfoId:" + strconv.Itoa(edbInfoId)
  1499. return
  1500. } else {
  1501. br.Msg = "获取图表信息失败!"
  1502. br.ErrMsg = "获取图表的指标信息失败,Err:" + err.Error()
  1503. return
  1504. }
  1505. }
  1506. if edbInfo == nil {
  1507. br.Msg = "指标不存在!"
  1508. br.ErrMsg = "指标不存在,ChartInfoId:" + strconv.Itoa(edbInfoId)
  1509. return
  1510. }
  1511. //判断指标名称是否重复
  1512. if v.EdbName != "" {
  1513. edbCondition = ""
  1514. edbPars = make([]interface{}, 0)
  1515. edbCondition += " AND excel_chart_edb_id<>? AND chart_info_id=?"
  1516. edbPars = append(edbPars, edbInfo.ExcelChartEdbId, chartItem.ChartInfoId)
  1517. switch this.Lang {
  1518. case utils.EnLangVersion:
  1519. edbCondition += " AND edb_name_en =? "
  1520. default:
  1521. edbCondition += " AND edb_name =? "
  1522. }
  1523. edbPars = append(edbPars, v.EdbName)
  1524. edbExist, err := excel.GetBalanceChartEdbByCondition(edbCondition, edbPars)
  1525. if err != nil {
  1526. if !utils.IsErrNoRow(err) {
  1527. br.Msg = "判断英文指标名称是否存在失败"
  1528. br.ErrMsg = "判断英文指标名称是否存在失败,Err:" + err.Error()
  1529. return
  1530. }
  1531. }
  1532. if err == nil && edbExist.ExcelChartEdbId > 0 {
  1533. br.Msg = edbExist.EdbName + ":" + v.EdbName + "指标名称已存在"
  1534. br.ErrMsg = "指标名称已存在,请重新填写"
  1535. br.IsSendEmail = false
  1536. return
  1537. }
  1538. }
  1539. }
  1540. if req.ChartName != "" || req.ExtraConfig != `` {
  1541. var condition string
  1542. var pars []interface{}
  1543. condition += " AND chart_info_id<>? "
  1544. pars = append(pars, req.ChartInfoId)
  1545. switch this.Lang {
  1546. case utils.EnLangVersion:
  1547. condition += " AND chart_name_en = ? "
  1548. default:
  1549. condition += " AND chart_name = ? "
  1550. }
  1551. pars = append(pars, req.ChartName)
  1552. existItem, err := data_manage.GetChartInfoByCondition(condition, pars)
  1553. if err != nil {
  1554. if !utils.IsErrNoRow(err) {
  1555. br.Msg = "判断英文图表名称是否存在失败"
  1556. br.ErrMsg = "判断英文图表名称是否存在失败,Err:" + err.Error()
  1557. return
  1558. }
  1559. }
  1560. if err == nil && existItem.ChartInfoId > 0 {
  1561. br.Msg = existItem.ChartName + ":" + req.ChartName + "图表名称已存在"
  1562. return
  1563. }
  1564. }
  1565. err = excel.EditBalanceChartBaseInfoAndEdbEnInfo(&req, chartItem, this.Lang)
  1566. if err != nil {
  1567. br.Msg = "保存失败"
  1568. br.ErrMsg = "保存失败,Err:" + err.Error()
  1569. return
  1570. }
  1571. //添加es数据
  1572. go data.AddOrEditChartInfoToEs(chartItem.ChartInfoId)
  1573. //修改my eta es数据
  1574. go data.EsAddOrEditMyChartInfoByChartInfoId(chartItem.ChartInfoId)
  1575. //新增操作日志
  1576. {
  1577. chartLog := new(data_manage.ChartInfoLog)
  1578. chartLog.ChartName = chartItem.ChartName
  1579. chartLog.ChartInfoId = req.ChartInfoId
  1580. chartLog.ChartClassifyId = chartItem.ChartClassifyId
  1581. chartLog.SysUserId = sysUser.AdminId
  1582. chartLog.SysUserRealName = sysUser.RealName
  1583. chartLog.UniqueCode = chartItem.UniqueCode
  1584. chartLog.CreateTime = time.Now()
  1585. chartLog.Content = string(this.Ctx.Input.RequestBody)
  1586. chartLog.Status = "编辑图表英文信息"
  1587. chartLog.Method = this.Ctx.Input.URL()
  1588. go data_manage.AddChartInfoLog(chartLog)
  1589. }
  1590. //清除缓存
  1591. if utils.Re == nil && utils.Rc != nil {
  1592. utils.Rc.Delete(utils.HZ_CHART_LIB_DETAIL + chartItem.UniqueCode) //图表分享链接缓存
  1593. utils.Rc.Delete(data.GetChartInfoDataKey(req.ChartInfoId))
  1594. }
  1595. br.Ret = 200
  1596. br.Success = true
  1597. br.Msg = "编辑成功"
  1598. br.IsAddLog = true
  1599. }