hsun 8 месяцев назад
Родитель
Сommit
7d8279d264
2 измененных файлов с 9 добавлено и 3 удалено
  1. 2 1
      controllers/data_init.go
  2. 7 2
      services/init_pcsg_bloomberg.go

+ 2 - 1
controllers/data_init.go

@@ -216,10 +216,11 @@ func (this *DataInitController) InitPCSGBloomberg() {
 		br.Msg = "文件名称不能为空"
 		return
 	}
+	isVCode := this.GetString("VCode", "")
 
 	filePath := "/docs/" + fileName
 	fmt.Println("filePath:" + filePath)
-	services.InitPCSGBloombergData(filePath)
+	services.InitPCSGBloombergData(filePath, isVCode)
 
 	br.Ret = 200
 	br.Msg = "初始化成功"

+ 7 - 2
services/init_pcsg_bloomberg.go

@@ -14,7 +14,7 @@ import (
 )
 
 // InitPCSGBloombergData 初始化中石油新加坡Bloomberg指标
-func InitPCSGBloombergData(dataPath string) {
+func InitPCSGBloombergData(dataPath, vCode string) {
 	var err error
 	defer func() {
 		if err != nil {
@@ -32,7 +32,7 @@ func InitPCSGBloombergData(dataPath string) {
 
 	dir := filepath.Dir(path)
 	dataPath = dir + dataPath
-	//dataPath = "docs/HistorySample_0508.xlsx"
+	//dataPath = "docs/dailyHistory-u6J9B5mVFY9p-20240619.xlsx"
 	f, e := excelize.OpenFile(dataPath)
 	if e != nil {
 		err = fmt.Errorf("open file err: %s", e.Error())
@@ -126,6 +126,10 @@ func InitPCSGBloombergData(dataPath string) {
 
 	// 请求接口导入数据
 	method := "bloomberg/pcsg/import_history_data"
+	var isVCode bool
+	if vCode == "true" {
+		isVCode = true
+	}
 	for _, v := range indexMap {
 		if v.IndexCode == "" {
 			continue
@@ -133,6 +137,7 @@ func InitPCSGBloombergData(dataPath string) {
 		requestMap := make(map[string]interface{})
 		requestMap["IndexCode"] = v.IndexCode
 		requestMap["DataMap"] = v.DataMap
+		requestMap["IsVCode"] = isVCode
 		indexRes, e := PostEdbLib(requestMap, method)
 		if e != nil {
 			fmt.Printf("post edb lib err: %s; result: %s", e.Error(), string(indexRes))