Przeglądaj źródła

Merge branch 'master' into feature/v1.0.23

lianbingjie 1 rok temu
rodzic
commit
24ff1606ba
1 zmienionych plików z 9 dodań i 3 usunięć
  1. 9 3
      service/exprot.go

+ 9 - 3
service/exprot.go

@@ -8,6 +8,7 @@ import (
 	"math/rand"
 	"os"
 	"path/filepath"
+	"regexp"
 	"strings"
 	"time"
 
@@ -255,8 +256,8 @@ func compressFiles(filePattern []string, path, timeStr string) {
 
 // 数据导出(通用)
 func (e *ExportByDbReq) ExportDataByDb() []byte {
-
 	key := hName(e.Query)
+	log.Println("", key)
 	timeStr := time.Now().Format("20060102150405")
 	rand.Seed(time.Now().UnixNano())
 	randomInt := rand.Intn(10000) // 生成0到9999之间的随机整数
@@ -298,7 +299,12 @@ func hName(sql string) []interface{} {
 	keystr = strings.ReplaceAll(keystr, " ", "")
 	for _, s1 := range strings.Split(keystr, ",") {
 		if strings.Contains(s1, "as") {
-			key = append(key, strings.Split(s1, "as")[1])
+			a1 := strings.Split(s1, "as")
+			l1 := len(a1)
+			chiReg := regexp.MustCompile("[^\u4e00-\u9fa5]")
+			if !chiReg.MatchString(a1[l1-1]) {
+				key = append(key, a1[l1-1])
+			}
 		}
 	}
 	return key
@@ -311,7 +317,7 @@ func exportA(sql, path, timeStr string, key []interface{}) []string {
 	writer, file := InirWrite(key)
 	a := 0
 	fpath := ""
-	BiService.SelectByBath(1, func(l *[]map[string]interface{}) bool {
+	JyBiTidb.SelectByBath(1, func(l *[]map[string]interface{}) bool {
 		if a%ExportCount == 0 && a > 0 {
 			a = 0
 			//入excel处理