index.go 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. package index
  2. type IndexController struct {
  3. }
  4. //func (s *IndexController) ServerCheck(c *gin.Context) {
  5. // resp.OkData("检测成功", 1, c)
  6. // return
  7. //}
  8. //
  9. //// Add 生成指标
  10. //func (s *IndexController) Create(c *gin.Context) {
  11. // req := new(index.IndexAddReq)
  12. // err := c.Bind(&req)
  13. // if err != nil {
  14. // errs, ok := err.(validator.ValidationErrors)
  15. // if !ok {
  16. // resp.FailData("参数解析失败", "Err:"+err.Error(), c)
  17. // return
  18. // }
  19. // resp.FailData("参数解析失败", errs.Translate(global.Trans), c)
  20. // return
  21. // }
  22. // fmt.Println("indexCode:" + req.IndexCode)
  23. // if req.RunMode == "" {
  24. // req.RunMode = "debug"
  25. // }
  26. // //fileName := req.IndexName + "_" + req.IndexCode + ".xlsx"
  27. // var fileName string
  28. // if req.UpdateWeek != "" {
  29. // fileName = req.IndexCode + "_" + req.UpdateWeek + "_" + req.RunMode + ".xlsx" //保存的文件名称
  30. // } else {
  31. // fileName = req.IndexCode + "_" + req.RunMode + ".xlsx" //保存的文件名称
  32. // }
  33. // filePath := utils.IndexSaveDir + fileName
  34. //
  35. // templatePath := utils.IndexSaveDir + "index_template.xlsx"
  36. // templateFile, err := excelize.OpenFile(templatePath)
  37. // if err != nil {
  38. // resp.FailData("打开文件失败", "打开文件失败,Err:"+err.Error(), c)
  39. // return
  40. // }
  41. // defer func() {
  42. // templateFile.Close()
  43. // }()
  44. //
  45. // //timeTag := time.Now().UnixNano() / 1e6
  46. // //timeTagStr := fmt.Sprintf("%d", timeTag)
  47. //
  48. // //UpdateMode:1:增量更新,0:全量更新
  49. // //commentStr := `"BlankValue":"0","CanMark":true,"ChartLineType":"0","DateBlock":0,"DateBlockCount":1,"DateFormat":0,"DateTimeTag":` + timeTagStr + `,"EndDate":"",
  50. // // "ExportType":0,"HasDescription":true,"HasEmptyRows":false,"HasFrequency":true,"HasIndexID":true,"HasLastDate":true,"HasSourceName":true,"HasTimeInterval":true,
  51. // // "HasUnit":true,"HasUpdateDate":true,"IsCreateChart":false,"IsDataSort":true,"IsNewSheet":false,"IsNewWorkbook":false,
  52. // // "Models":[{"DataFormat":0,"DataStartDate":"2011-03-25","DefineName":"","DefineUnit":"","DisplayIndexCode":"` + req.IndexCode + `",
  53. // // "IndexCode":"` + req.IndexCode + `","IndexFormula":"` + req.IndexCode + `","PointValue":0,"UnionStart":""}],"Position":"A1","RangeData":"A2:B2791",
  54. // // "ShowBlankLines":false,"StartDate":"","Transpose":false,"UpdateMode":1,"lookModel":{"IsLast":false,"LookValue":0,"lookType":0},"ver":3}`
  55. //
  56. // startDate := "1990-01-01"
  57. // commentStr := `"BlankValue":"0","CanMark":true,"ChartLineType":"0","DateBlock":0,"DateBlockCount":1,"DateFormat":0,"DateTimeTag":"","EndDate":"","ExportType":0,"HasDescription":true,"HasEmptyRows":false,"HasFrequency":true,"HasIndexID":true,"HasLastDate":true,"HasSourceName":true,"HasTimeInterval":true,"HasUnit":true,"HasUpdateDate":true,"IsCreateChart":false,"IsDataSort":true,"IsNewSheet":false,"IsNewWorkbook":false,"Models":[{"DataFormat":0,"DataStartDate":"` + startDate + `","DefineName":"","DefineUnit":"","DisplayIndexCode":"` + req.IndexCode + `","IndexCode":"` + req.IndexCode + `","IndexFormula":"` + req.IndexCode + `","PointValue":0,"UnionStart":""}],"Position":"A1","RangeData":"A2:B280","ShowBlankLines":false,"StartDate":"","Transpose":false,"UpdateMode":1,"lookModel":{"IsLast":false,"LookValue":0,"lookType":0},"ver":3}
  58. //`
  59. // commentMap := make(map[string]interface{})
  60. // commentMap["author"] = "{"
  61. // commentMap["text"] = commentStr
  62. // //commentMap["text"] = commentItem
  63. //
  64. // commentJson, err := json.Marshal(commentMap)
  65. // if err != nil {
  66. // fmt.Println("json.Marshal err:" + err.Error())
  67. // }
  68. //
  69. // fmt.Println("commentJson")
  70. // fmt.Println(string(commentJson))
  71. // templateFile.DeleteComment("Sheet1", "A1")
  72. // templateFile.AddComment("Sheet1", "A1", string(commentJson))
  73. // if err := templateFile.SaveAs(filePath); err != nil {
  74. // fmt.Println(err)
  75. // resp.FailData("保存失败", "保存失败,Err:"+err.Error(), c)
  76. // return
  77. // }
  78. // time.Sleep(1 * time.Second)
  79. // fmt.Println("start MysteelChemicalRefresh")
  80. // //services.MysteelChemicalRefresh(filePath)
  81. // services.AddIndexRefreshToLpush(filePath)
  82. // resp.Ok("保存成功", c)
  83. // return
  84. //}
  85. //
  86. //// Delete 删除指标文件
  87. //func (s *IndexController) Delete(c *gin.Context) {
  88. // req := new(index.IndexAddReq)
  89. // err := c.Bind(&req)
  90. // if err != nil {
  91. // errs, ok := err.(validator.ValidationErrors)
  92. // if !ok {
  93. // resp.FailData("参数解析失败", "Err:"+err.Error(), c)
  94. // return
  95. // }
  96. // resp.FailData("参数解析失败", errs.Translate(global.Trans), c)
  97. // return
  98. // }
  99. // fmt.Println("params start")
  100. // fmt.Println(req.RunMode)
  101. // fmt.Println("params end")
  102. // var fileName string
  103. // if req.UpdateWeek != "" {
  104. // fileName = req.IndexCode + "_" + req.UpdateWeek + "_" + req.RunMode + ".xlsx" //保存的文件名称
  105. // } else {
  106. // fileName = req.IndexCode + "_" + req.RunMode + ".xlsx" //保存的文件名称
  107. // }
  108. // filePath := utils.IndexSaveDir + fileName
  109. // err = os.Remove(filePath)
  110. // if err != nil {
  111. // fmt.Println("filePath:" + filePath)
  112. // fmt.Println("err:" + err.Error())
  113. // resp.Ok("删除失败", c)
  114. // return
  115. // }
  116. // resp.Ok("删除成功", c)
  117. // return
  118. //}
  119. //
  120. //func (s *IndexController) Test(c *gin.Context) {
  121. // resp.OkData("检测成功", 1, c)
  122. // return
  123. //}
  124. //
  125. //// Add 刷新指标
  126. //func (s *IndexController) Refresh(c *gin.Context) {
  127. // req := new(index.IndexRefreshReq)
  128. // err := c.Bind(&req)
  129. // if err != nil {
  130. // errs, ok := err.(validator.ValidationErrors)
  131. // if !ok {
  132. // resp.FailData("参数解析失败", "Err:"+err.Error(), c)
  133. // return
  134. // }
  135. // resp.FailData("参数解析失败", errs.Translate(global.Trans), c)
  136. // return
  137. // }
  138. // //services.MysteelChemicalRefresh(req.MergeFilePath)
  139. // services.AddIndexRefreshToLpush(req.MergeFilePath)
  140. // resp.Ok("保存成功", c)
  141. // return
  142. //}