|
@@ -1,21 +1,22 @@
|
|
|
package util
|
|
|
|
|
|
import (
|
|
|
- "app.yhyue.com/moapp/jybase/common"
|
|
|
- "app.yhyue.com/moapp/jybase/encrypt"
|
|
|
- elastic "app.yhyue.com/moapp/jybase/es"
|
|
|
- "app.yhyue.com/moapp/jybase/go-xweb/log"
|
|
|
- "app.yhyue.com/moapp/jybase/redis"
|
|
|
"cmplatform/models"
|
|
|
sql "cmplatform/util/sqlmodel"
|
|
|
"context"
|
|
|
"encoding/json"
|
|
|
"errors"
|
|
|
"fmt"
|
|
|
- "go.mongodb.org/mongo-driver/bson"
|
|
|
+ "log"
|
|
|
"regexp"
|
|
|
"strings"
|
|
|
"time"
|
|
|
+
|
|
|
+ "app.yhyue.com/moapp/jybase/common"
|
|
|
+ "app.yhyue.com/moapp/jybase/encrypt"
|
|
|
+ elastic "app.yhyue.com/moapp/jybase/es"
|
|
|
+ "app.yhyue.com/moapp/jybase/redis"
|
|
|
+ "go.mongodb.org/mongo-driver/bson"
|
|
|
)
|
|
|
|
|
|
const (
|
|
@@ -167,7 +168,7 @@ func searchDataArr(index, esquery, sdataid, userId string, i_maxnum int64, tags
|
|
|
// } else {
|
|
|
// redis.Put("datag", "jyqyfw_es_query_times_"+userId, 1, 60)
|
|
|
// }
|
|
|
- log.Debug("es空闲,当前进程数 ", listLens)
|
|
|
+ log.Println("es空闲,当前进程数 ", listLens)
|
|
|
redis.RPUSH("datag", "jyqyfw_es_query", 1)
|
|
|
err, counts = searchData(index, esquery, sdataid, i_maxnum, tags, maths)
|
|
|
redis.LPOP("datag", "jyqyfw_es_query")
|
|
@@ -176,7 +177,7 @@ func searchDataArr(index, esquery, sdataid, userId string, i_maxnum int64, tags
|
|
|
err = errors.New("系统繁忙,请稍后再试")
|
|
|
break
|
|
|
} else {
|
|
|
- log.Error("企业级服务es进程数过多,", listLens)
|
|
|
+ log.Println("企业级服务es进程数过多,", listLens)
|
|
|
}
|
|
|
times2 += 2
|
|
|
time.Sleep(2 * time.Second)
|
|
@@ -205,8 +206,8 @@ func searchData(index, esquery, sdataid string, i_maxnum int64, tags map[string]
|
|
|
searchResult, err := client.Search(index).Query(cc).Size(int(i_maxnum)).Do(ctx)
|
|
|
if err == nil && searchResult.Hits != nil {
|
|
|
datas := make([]map[string]interface{}, 0)
|
|
|
- log.Debug("es查询到的数量:", searchResult.Hits.TotalHits.Value)
|
|
|
- log.Debug("es查询数据数量:", len(searchResult.Hits.Hits))
|
|
|
+ log.Println("es查询到的数量:", searchResult.Hits.TotalHits.Value)
|
|
|
+ log.Println("es查询数据数量:", len(searchResult.Hits.Hits))
|
|
|
for _, v := range searchResult.Hits.Hits {
|
|
|
item := make(map[string]interface{})
|
|
|
if json.Unmarshal(v.Source, &item) == nil {
|
|
@@ -298,14 +299,14 @@ func searchData(index, esquery, sdataid string, i_maxnum int64, tags map[string]
|
|
|
}
|
|
|
}
|
|
|
counts := Es.Count(index, Itype, esquery)
|
|
|
- log.Debug("esCount查询的数据量 ", counts)
|
|
|
+ log.Println("esCount查询的数据量 ", counts)
|
|
|
Mgo.Update("cuserdepartrule", bson.M{"_id": tags["_id"]}, bson.M{
|
|
|
"$set": bson.M{
|
|
|
"i_estotal": counts,
|
|
|
}}, false, false)
|
|
|
return UtilEsSaveData(sdataid, index, &datas), counts
|
|
|
} else {
|
|
|
- log.Error("err", err)
|
|
|
+ log.Println("err", err)
|
|
|
return err, 0
|
|
|
}
|
|
|
}
|
|
@@ -346,7 +347,7 @@ func FilterTimeSql(esquery string, startTime, endTime int64) (string, error) {
|
|
|
if err == nil {
|
|
|
return string(strQuery), nil
|
|
|
} else {
|
|
|
- log.Error("失败", err)
|
|
|
+ log.Println("失败", err)
|
|
|
return esquery, err
|
|
|
}
|
|
|
} else {
|
|
@@ -356,7 +357,7 @@ func FilterTimeSql(esquery string, startTime, endTime int64) (string, error) {
|
|
|
}
|
|
|
}
|
|
|
} else {
|
|
|
- log.Error(json.Unmarshal([]byte(esquery), &query), "err")
|
|
|
+ log.Println(json.Unmarshal([]byte(esquery), &query), "err")
|
|
|
return esquery, errors.New("err")
|
|
|
}
|
|
|
return esquery, nil
|
|
@@ -403,7 +404,7 @@ func UtilEsFind2(tags map[string]interface{}, n int) (error, int64) {
|
|
|
//}
|
|
|
// 获取分隔区间
|
|
|
timeList := GetTimeInterval(time.Unix(common.Int64All(tags["i_starttime"]), 0), time.Unix(common.Int64All(tags["i_endtime"]), 0), n)
|
|
|
- log.Debug(timeList, "分隔后的时间===================")
|
|
|
+ log.Println(timeList, "分隔后的时间===================")
|
|
|
esQueryList := []string{}
|
|
|
//esquery = esquery[:len(esquery)-1] + `,"size":` + fmt.Sprintf("%d", i_maxnum) + `}`
|
|
|
// log.Println(esquery)
|
|
@@ -473,8 +474,8 @@ func UtilEsFind2(tags map[string]interface{}, n int) (error, int64) {
|
|
|
}
|
|
|
searchResult, err := client.Search(index).Query(cc).Do(ctx)
|
|
|
if err == nil && searchResult.Hits != nil {
|
|
|
- log.Debug("es查询到的数量:", searchResult.Hits.TotalHits)
|
|
|
- log.Debug("开始处理")
|
|
|
+ log.Println("es查询到的数量:", searchResult.Hits.TotalHits)
|
|
|
+ log.Println("开始处理")
|
|
|
|
|
|
for _, v := range searchResult.Hits.Hits {
|
|
|
item := make(map[string]interface{})
|
|
@@ -579,12 +580,12 @@ func UtilEsFind2(tags map[string]interface{}, n int) (error, int64) {
|
|
|
|
|
|
}
|
|
|
}
|
|
|
- log.Debug("处理完成", len(datas))
|
|
|
+ log.Println("处理完成", len(datas))
|
|
|
|
|
|
count := searchResult.Hits.TotalHits.Value
|
|
|
totalCount += count
|
|
|
} else {
|
|
|
- log.Debug(err)
|
|
|
+ log.Println(err)
|
|
|
return err, 0
|
|
|
}
|
|
|
}
|