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 //}