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