Bläddra i källkod

fix:修复钢联化工的文字写入,以及定时刷新

Roc 1 år sedan
förälder
incheckning
ea72a19b35
5 ändrade filer med 12 tillägg och 9 borttagningar
  1. 3 1
      init_serve/task.go
  2. 3 3
      services/index_create.go
  3. 3 2
      services/index_merge_v2.go
  4. 2 2
      watch/edb_lib.go
  5. 1 1
      watch/watch.go

+ 3 - 1
init_serve/task.go

@@ -12,7 +12,6 @@ import (
 )
 
 func InitTask() {
-
 	c := cron.New(cron.WithSeconds())
 
 	//每1分钟检测一次,指标生成
@@ -50,7 +49,10 @@ func InitTask() {
 		}
 
 	}
+
 	c.Start()
+
+	go services.AutoRefresh()
 }
 
 // CheckIndexCreate 检测指标数据是否生成

+ 3 - 3
services/index_create.go

@@ -1,7 +1,6 @@
 package services
 
 import (
-	"eta/mysteel_watch/cache"
 	"eta/mysteel_watch/global"
 	"eta/mysteel_watch/models/index"
 	"eta/mysteel_watch/utils"
@@ -89,7 +88,8 @@ func IndexCreateCheckMerge() (err error) {
 
 		templateFile.DeleteComment(sheetName, "A1")
 		templateFile.AddComment(sheetName, "A1", commentResult)
-		templateFile.SetSheetRow(sheetName, "A1", "钢联数据")
+		//templateFile.SetSheetRow(sheetName, "A1", "钢联数据")
+		templateFile.SetCellStr(sheetName, "A1", "钢联数据")
 	}
 
 	if err = templateFile.SaveAs(mergeIndexCreateFilePath); err != nil {
@@ -100,6 +100,6 @@ func IndexCreateCheckMerge() (err error) {
 
 	defer templateFile.Close()
 	time.Sleep(3 * time.Second)
-	cache.IndexAutoRefresh(mergeIndexCreateFilePath)
+	AddIndexRefreshToLpush(mergeIndexCreateFilePath)
 	return nil
 }

+ 3 - 2
services/index_merge_v2.go

@@ -128,6 +128,7 @@ func indexMergeV2(frequency, startDate, endDate, filePre string) (err error) {
 	if total <= 0 {
 		return
 	}
+	fmt.Println(frequency, "总共", total, "个指标")
 
 	fileName := filePre + ".xlsx" //保存的文件名称
 	//templatePath := global.CONFIG.Serve.IndexSaveDir + "index_template.xlsx"
@@ -192,7 +193,6 @@ func indexMergeV2(frequency, startDate, endDate, filePre string) (err error) {
 
 		//刷新数据
 		//MysteelChemicalRefresh(mergeIndexFilePath)
-		//AddIndexRefreshToLpush(mergeIndexFilePath)
 	}
 
 	//sheetList := templateFile.GetSheetList()
@@ -209,6 +209,7 @@ func indexMergeV2(frequency, startDate, endDate, filePre string) (err error) {
 	}
 	defer templateFile.Close()
 	time.Sleep(1 * time.Second)
-	MysteelChemicalRefresh(mergeIndexFilePath)
+	//MysteelChemicalRefresh(mergeIndexFilePath)
+	AddIndexRefreshToLpush(mergeIndexFilePath)
 	return
 }

+ 2 - 2
watch/edb_lib.go

@@ -3,10 +3,10 @@ package watch
 import (
 	"encoding/json"
 	"errors"
-	"fmt"
 	"eta/mysteel_watch/global"
 	"eta/mysteel_watch/models/index"
 	"eta/mysteel_watch/utils"
+	"fmt"
 	"io/ioutil"
 	"net/http"
 	"strings"
@@ -86,7 +86,7 @@ func postHandleMysteelIndex(req *HandleMysteelIndexReq) (resp *BaseResponse, err
 	if err != nil {
 		return
 	}
-	fmt.Println("postData:" + string(postData))
+	//fmt.Println("postData:" + string(postData))
 	global.LOG.Info(" postData: " + string(postData))
 	result, err := HttpPost(postUrl, string(postData), "application/json")
 	if err != nil {

+ 1 - 1
watch/watch.go

@@ -89,7 +89,7 @@ import (
 
 // WatchIndexFile 检测指标文件
 func WatchIndexFile(filePath string) {
-	fmt.Println("filePath:", filePath)
+	fmt.Println("监听文件变更:filePath:", filePath)
 	//filePath:D:\mysteel_data\CM0000568866_release.xlsx
 	time.Sleep(10 * time.Second)
 	if !utils.FileIsExist(filePath) {