123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144 |
- package index
- type IndexController struct {
- }
- //func (s *IndexController) ServerCheck(c *gin.Context) {
- // resp.OkData("检测成功", 1, c)
- // return
- //}
- //
- //// Add 生成指标
- //func (s *IndexController) Create(c *gin.Context) {
- // req := new(index.IndexAddReq)
- // err := c.Bind(&req)
- // if err != nil {
- // errs, ok := err.(validator.ValidationErrors)
- // if !ok {
- // resp.FailData("参数解析失败", "Err:"+err.Error(), c)
- // return
- // }
- // resp.FailData("参数解析失败", errs.Translate(global.Trans), c)
- // return
- // }
- // fmt.Println("indexCode:" + req.IndexCode)
- // if req.RunMode == "" {
- // req.RunMode = "debug"
- // }
- // //fileName := req.IndexName + "_" + req.IndexCode + ".xlsx"
- // var fileName string
- // if req.UpdateWeek != "" {
- // fileName = req.IndexCode + "_" + req.UpdateWeek + "_" + req.RunMode + ".xlsx" //保存的文件名称
- // } else {
- // fileName = req.IndexCode + "_" + req.RunMode + ".xlsx" //保存的文件名称
- // }
- // filePath := utils.IndexSaveDir + fileName
- //
- // templatePath := utils.IndexSaveDir + "index_template.xlsx"
- // templateFile, err := excelize.OpenFile(templatePath)
- // if err != nil {
- // resp.FailData("打开文件失败", "打开文件失败,Err:"+err.Error(), c)
- // return
- // }
- // defer func() {
- // templateFile.Close()
- // }()
- //
- // //timeTag := time.Now().UnixNano() / 1e6
- // //timeTagStr := fmt.Sprintf("%d", timeTag)
- //
- // //UpdateMode:1:增量更新,0:全量更新
- // //commentStr := `"BlankValue":"0","CanMark":true,"ChartLineType":"0","DateBlock":0,"DateBlockCount":1,"DateFormat":0,"DateTimeTag":` + timeTagStr + `,"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":"2011-03-25","DefineName":"","DefineUnit":"","DisplayIndexCode":"` + req.IndexCode + `",
- // // "IndexCode":"` + req.IndexCode + `","IndexFormula":"` + req.IndexCode + `","PointValue":0,"UnionStart":""}],"Position":"A1","RangeData":"A2:B2791",
- // // "ShowBlankLines":false,"StartDate":"","Transpose":false,"UpdateMode":1,"lookModel":{"IsLast":false,"LookValue":0,"lookType":0},"ver":3}`
- //
- // startDate := "1990-01-01"
- // 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}
- //`
- // commentMap := make(map[string]interface{})
- // commentMap["author"] = "{"
- // commentMap["text"] = commentStr
- // //commentMap["text"] = commentItem
- //
- // commentJson, err := json.Marshal(commentMap)
- // if err != nil {
- // fmt.Println("json.Marshal err:" + err.Error())
- // }
- //
- // fmt.Println("commentJson")
- // fmt.Println(string(commentJson))
- // templateFile.DeleteComment("Sheet1", "A1")
- // templateFile.AddComment("Sheet1", "A1", string(commentJson))
- // if err := templateFile.SaveAs(filePath); err != nil {
- // fmt.Println(err)
- // resp.FailData("保存失败", "保存失败,Err:"+err.Error(), c)
- // return
- // }
- // time.Sleep(1 * time.Second)
- // fmt.Println("start MysteelChemicalRefresh")
- // //services.MysteelChemicalRefresh(filePath)
- // services.AddIndexRefreshToLpush(filePath)
- // resp.Ok("保存成功", c)
- // return
- //}
- //
- //// Delete 删除指标文件
- //func (s *IndexController) Delete(c *gin.Context) {
- // req := new(index.IndexAddReq)
- // err := c.Bind(&req)
- // if err != nil {
- // errs, ok := err.(validator.ValidationErrors)
- // if !ok {
- // resp.FailData("参数解析失败", "Err:"+err.Error(), c)
- // return
- // }
- // resp.FailData("参数解析失败", errs.Translate(global.Trans), c)
- // return
- // }
- // fmt.Println("params start")
- // fmt.Println(req.RunMode)
- // fmt.Println("params end")
- // var fileName string
- // if req.UpdateWeek != "" {
- // fileName = req.IndexCode + "_" + req.UpdateWeek + "_" + req.RunMode + ".xlsx" //保存的文件名称
- // } else {
- // fileName = req.IndexCode + "_" + req.RunMode + ".xlsx" //保存的文件名称
- // }
- // filePath := utils.IndexSaveDir + fileName
- // err = os.Remove(filePath)
- // if err != nil {
- // fmt.Println("filePath:" + filePath)
- // fmt.Println("err:" + err.Error())
- // resp.Ok("删除失败", c)
- // return
- // }
- // resp.Ok("删除成功", c)
- // return
- //}
- //
- //func (s *IndexController) Test(c *gin.Context) {
- // resp.OkData("检测成功", 1, c)
- // return
- //}
- //
- //// Add 刷新指标
- //func (s *IndexController) Refresh(c *gin.Context) {
- // req := new(index.IndexRefreshReq)
- // err := c.Bind(&req)
- // if err != nil {
- // errs, ok := err.(validator.ValidationErrors)
- // if !ok {
- // resp.FailData("参数解析失败", "Err:"+err.Error(), c)
- // return
- // }
- // resp.FailData("参数解析失败", errs.Translate(global.Trans), c)
- // return
- // }
- // //services.MysteelChemicalRefresh(req.MergeFilePath)
- // services.AddIndexRefreshToLpush(req.MergeFilePath)
- // resp.Ok("保存成功", c)
- // return
- //}
|