|
@@ -7,6 +7,7 @@ import (
|
|
"hongze/mysteel_watch/models/index"
|
|
"hongze/mysteel_watch/models/index"
|
|
"hongze/mysteel_watch/utils"
|
|
"hongze/mysteel_watch/utils"
|
|
"hongze/mysteel_watch/watch"
|
|
"hongze/mysteel_watch/watch"
|
|
|
|
+ "os"
|
|
"strconv"
|
|
"strconv"
|
|
"strings"
|
|
"strings"
|
|
"time"
|
|
"time"
|
|
@@ -667,7 +668,7 @@ func indexMerge(frequency, filePre string, pageSize int) (err error) {
|
|
time.Sleep(1 * time.Second)
|
|
time.Sleep(1 * time.Second)
|
|
|
|
|
|
|
|
|
|
- AddIndexRefreshToLpush(mergeIndexFilePath)
|
|
+
|
|
}
|
|
}
|
|
return
|
|
return
|
|
}
|
|
}
|
|
@@ -782,51 +783,60 @@ func indexMerge(frequency, filePre string, pageSize int) (err error) {
|
|
|
|
|
|
|
|
|
|
func GetIndexCommentV2(indexFilePath string, list []index.BaseFromMysteelChemicalIndex, fileIndex int) (commentResult string, err error) {
|
|
func GetIndexCommentV2(indexFilePath string, list []index.BaseFromMysteelChemicalIndex, fileIndex int) (commentResult string, err error) {
|
|
|
|
+ fmt.Println("GetIndexCommentV2 start")
|
|
|
|
+ fmt.Println(indexFilePath)
|
|
|
|
+ fmt.Println("GetIndexCommentV2 end")
|
|
|
|
|
|
indexInfo := new(IndexObj)
|
|
indexInfo := new(IndexObj)
|
|
if utils.FileIsExist(indexFilePath) {
|
|
if utils.FileIsExist(indexFilePath) {
|
|
- fmt.Println("utils.FileIsExist")
|
|
+
|
|
- getCommentStr := GetComment(indexFilePath)
|
|
+
|
|
- fmt.Println(getCommentStr)
|
|
+
|
|
-
|
|
+
|
|
- err = json.Unmarshal([]byte(getCommentStr), &indexInfo)
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ err = os.Remove(indexFilePath)
|
|
if err != nil {
|
|
if err != nil {
|
|
- fmt.Println("json.Unmarshal err:" + err.Error())
|
|
+ fmt.Println("os.Remove Err:" + err.Error() + ";indexFilePath:" + indexFilePath)
|
|
return
|
|
return
|
|
}
|
|
}
|
|
- } else {
|
|
|
|
- indexInfo.BlankValue = "0"
|
|
|
|
- indexInfo.CanMark = true
|
|
|
|
- indexInfo.ChartLineType = "0"
|
|
|
|
- indexInfo.DateBlock = 0
|
|
|
|
- indexInfo.DateBlockCount = 1
|
|
|
|
- indexInfo.DateFormat = 0
|
|
|
|
- indexInfo.DateTimeTag = "637973605613980000"
|
|
|
|
- indexInfo.EndDate = ""
|
|
|
|
- indexInfo.ExportType = 0
|
|
|
|
- indexInfo.HasDescription = true
|
|
|
|
- indexInfo.HasEmptyRows = false
|
|
|
|
- indexInfo.HasFrequency = true
|
|
|
|
- indexInfo.HasIndexID = true
|
|
|
|
- indexInfo.HasLastDate = true
|
|
|
|
- indexInfo.HasSourceName = true
|
|
|
|
- indexInfo.HasTimeInterval = true
|
|
|
|
- indexInfo.HasUnit = true
|
|
|
|
- indexInfo.HasUpdateDate = true
|
|
|
|
- indexInfo.IsCreateChart = false
|
|
|
|
- indexInfo.IsDataSort = true
|
|
|
|
- indexInfo.IsNewSheet = false
|
|
|
|
- indexInfo.IsNewWorkbook = false
|
|
|
|
- indexInfo.Position = "A1"
|
|
|
|
- indexInfo.ShowBlankLines = false
|
|
|
|
- indexInfo.StartDate = ""
|
|
|
|
- indexInfo.Transpose = false
|
|
|
|
- indexInfo.UpdateMode = 1
|
|
|
|
- indexInfo.LookModel.IsLast = false
|
|
|
|
- indexInfo.LookModel.LookValue = 0
|
|
|
|
- indexInfo.LookModel.LookType = 0
|
|
|
|
- indexInfo.Ver = 3
|
|
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ indexInfo.BlankValue = "0"
|
|
|
|
+ indexInfo.CanMark = true
|
|
|
|
+ indexInfo.ChartLineType = "0"
|
|
|
|
+ indexInfo.DateBlock = 0
|
|
|
|
+ indexInfo.DateBlockCount = 1
|
|
|
|
+ indexInfo.DateFormat = 0
|
|
|
|
+ indexInfo.DateTimeTag = "637973605613980000"
|
|
|
|
+ indexInfo.EndDate = ""
|
|
|
|
+ indexInfo.ExportType = 0
|
|
|
|
+ indexInfo.HasDescription = true
|
|
|
|
+ indexInfo.HasEmptyRows = false
|
|
|
|
+ indexInfo.HasFrequency = true
|
|
|
|
+ indexInfo.HasIndexID = true
|
|
|
|
+ indexInfo.HasLastDate = true
|
|
|
|
+ indexInfo.HasSourceName = true
|
|
|
|
+ indexInfo.HasTimeInterval = true
|
|
|
|
+ indexInfo.HasUnit = true
|
|
|
|
+ indexInfo.HasUpdateDate = true
|
|
|
|
+ indexInfo.IsCreateChart = false
|
|
|
|
+ indexInfo.IsDataSort = true
|
|
|
|
+ indexInfo.IsNewSheet = false
|
|
|
|
+ indexInfo.IsNewWorkbook = false
|
|
|
|
+ indexInfo.Position = "A1"
|
|
|
|
+ indexInfo.ShowBlankLines = false
|
|
|
|
+ indexInfo.StartDate = time.Now().AddDate(0, 0, -6).Format(utils.FormatDate)
|
|
|
|
+ indexInfo.Transpose = false
|
|
|
|
+ indexInfo.UpdateMode = 1
|
|
|
|
+ indexInfo.LookModel.IsLast = false
|
|
|
|
+ indexInfo.LookModel.LookValue = 0
|
|
|
|
+ indexInfo.LookModel.LookType = 0
|
|
|
|
+ indexInfo.Ver = 3
|
|
|
|
+
|
|
modelsList := make([]IndexModels, 0)
|
|
modelsList := make([]IndexModels, 0)
|
|
startDate := "1990-01-01"
|
|
startDate := "1990-01-01"
|
|
|
|
|
|
@@ -835,14 +845,14 @@ func GetIndexCommentV2(indexFilePath string, list []index.BaseFromMysteelChemica
|
|
|
|
|
|
modelsList = append(modelsList, indexInfo.Models...)
|
|
modelsList = append(modelsList, indexInfo.Models...)
|
|
|
|
|
|
- for k, v := range list {
|
|
+ for _, v := range list {
|
|
- fmt.Println(k, v)
|
|
+
|
|
item := new(IndexModels)
|
|
item := new(IndexModels)
|
|
item.DataFormat = 0
|
|
item.DataFormat = 0
|
|
if v.IndexName == "" {
|
|
if v.IndexName == "" {
|
|
item.DataStartDate = startDate
|
|
item.DataStartDate = startDate
|
|
} else {
|
|
} else {
|
|
- item.DataStartDate = v.StartDate.Format(utils.FormatDate)
|
|
+ item.DataStartDate = v.EndDate.AddDate(0, 0, -7).Format(utils.FormatDate)
|
|
}
|
|
}
|
|
item.DefineName = ""
|
|
item.DefineName = ""
|
|
item.DefineUnit = ""
|
|
item.DefineUnit = ""
|
|
@@ -896,6 +906,129 @@ func GetIndexCommentV2(indexFilePath string, list []index.BaseFromMysteelChemica
|
|
return
|
|
return
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+func GetIndexCommentV3(indexFilePath, StartDate string, list []index.BaseFromMysteelChemicalIndex) (commentResult string, err error) {
|
|
|
|
+ fmt.Println("GetIndexCommentV2 start")
|
|
|
|
+ fmt.Println(indexFilePath)
|
|
|
|
+ fmt.Println("GetIndexCommentV2 end")
|
|
|
|
+
|
|
|
|
+ indexInfo := new(IndexObj)
|
|
|
|
+ if utils.FileIsExist(indexFilePath) {
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ err = os.Remove(indexFilePath)
|
|
|
|
+ if err != nil {
|
|
|
|
+ fmt.Println("os.Remove Err:" + err.Error() + ";indexFilePath:" + indexFilePath)
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ indexInfo.BlankValue = "0"
|
|
|
|
+ indexInfo.CanMark = true
|
|
|
|
+ indexInfo.ChartLineType = "0"
|
|
|
|
+ indexInfo.DateBlock = 0
|
|
|
|
+ indexInfo.DateBlockCount = 1
|
|
|
|
+ indexInfo.DateFormat = 0
|
|
|
|
+ indexInfo.DateTimeTag = "637973605613980000"
|
|
|
|
+ indexInfo.EndDate = ""
|
|
|
|
+ indexInfo.ExportType = 0
|
|
|
|
+ indexInfo.HasDescription = true
|
|
|
|
+ indexInfo.HasEmptyRows = false
|
|
|
|
+ indexInfo.HasFrequency = true
|
|
|
|
+ indexInfo.HasIndexID = true
|
|
|
|
+ indexInfo.HasLastDate = true
|
|
|
|
+ indexInfo.HasSourceName = true
|
|
|
|
+ indexInfo.HasTimeInterval = true
|
|
|
|
+ indexInfo.HasUnit = true
|
|
|
|
+ indexInfo.HasUpdateDate = true
|
|
|
|
+ indexInfo.IsCreateChart = false
|
|
|
|
+ indexInfo.IsDataSort = true
|
|
|
|
+ indexInfo.IsNewSheet = false
|
|
|
|
+ indexInfo.IsNewWorkbook = false
|
|
|
|
+ indexInfo.Position = "A1"
|
|
|
|
+ indexInfo.ShowBlankLines = false
|
|
|
|
+ indexInfo.StartDate = StartDate
|
|
|
|
+ indexInfo.Transpose = false
|
|
|
|
+ indexInfo.UpdateMode = 1
|
|
|
|
+ indexInfo.LookModel.IsLast = false
|
|
|
|
+ indexInfo.LookModel.LookValue = 0
|
|
|
|
+ indexInfo.LookModel.LookType = 0
|
|
|
|
+ indexInfo.Ver = 3
|
|
|
|
+
|
|
|
|
+ modelsList := make([]IndexModels, 0)
|
|
|
|
+ startDate := "1990-01-01"
|
|
|
|
+
|
|
|
|
+ updateIndexes := make([]watch.UpdateIndexReq, 0)
|
|
|
|
+ updateCols := []string{"merge_file_path", "file_index"}
|
|
|
|
+
|
|
|
|
+ modelsList = append(modelsList, indexInfo.Models...)
|
|
|
|
+
|
|
|
|
+ for _, v := range list {
|
|
|
|
+
|
|
|
|
+ item := new(IndexModels)
|
|
|
|
+ item.DataFormat = 0
|
|
|
|
+ if v.IndexName == "" {
|
|
|
|
+ item.DataStartDate = startDate
|
|
|
|
+ } else {
|
|
|
|
+ item.DataStartDate = v.EndDate.AddDate(0, 0, -7).Format(utils.FormatDate)
|
|
|
|
+ }
|
|
|
|
+ item.DefineName = ""
|
|
|
|
+ item.DefineUnit = ""
|
|
|
|
+ item.DisplayIndexCode = v.IndexCode
|
|
|
|
+ item.IndexCode = v.IndexCode
|
|
|
|
+ item.IndexFormula = v.IndexCode
|
|
|
|
+ item.PointValue = 0
|
|
|
|
+ item.UnionStart = ""
|
|
|
|
+ modelsList = append(modelsList, *item)
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ var req watch.UpdateIndexReq
|
|
|
|
+ req.Item = new(index.BaseFromMysteelChemicalIndex)
|
|
|
|
+ req.Item.BaseFromMysteelChemicalIndexId = v.BaseFromMysteelChemicalIndexId
|
|
|
|
+ req.Item.IndexCode = v.IndexCode
|
|
|
|
+ req.Item.MergeFilePath = indexFilePath
|
|
|
|
+ req.UpdateCols = updateCols
|
|
|
|
+ updateIndexes = append(updateIndexes, req)
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ if len(updateIndexes) > 0 {
|
|
|
|
+ e := watch.MultiUpdateIndex(updateIndexes)
|
|
|
|
+ if e != nil {
|
|
|
|
+ fmt.Println("UpdateIndexByIndexCode err: " + e.Error())
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ indexInfo.Models = modelsList
|
|
|
|
+
|
|
|
|
+ indexStr, err := json.Marshal(indexInfo)
|
|
|
|
+ if err != nil {
|
|
|
|
+ fmt.Println("json.Marshal err:" + err.Error())
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ text := string(indexStr)
|
|
|
|
+ text = strings.Trim(text, "{")
|
|
|
|
+
|
|
|
|
+ commentMap := make(map[string]interface{})
|
|
|
|
+ commentMap["author"] = "{"
|
|
|
|
+ commentMap["text"] = text
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ commentJson, err := json.Marshal(commentMap)
|
|
|
|
+ if err != nil {
|
|
|
|
+ fmt.Println("json.Marshal err:" + err.Error())
|
|
|
|
+ }
|
|
|
|
+ commentResult = string(commentJson)
|
|
|
|
+ return
|
|
|
|
+}
|
|
|
|
+
|
|
type IndexObj struct {
|
|
type IndexObj struct {
|
|
BlankValue string `json:"BlankValue"`
|
|
BlankValue string `json:"BlankValue"`
|
|
CanMark bool `json:"CanMark"`
|
|
CanMark bool `json:"CanMark"`
|