balance_table.go 48 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716
  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. "github.com/tealeg/xlsx"
  19. "io/ioutil"
  20. "os"
  21. "sort"
  22. "strconv"
  23. "strings"
  24. "time"
  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.EsDeleteChartInfo(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)
  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.EsAddOrEditChartInfo(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. }