|
@@ -3,6 +3,7 @@ package p
|
|
|
import (
|
|
|
"encoding/json"
|
|
|
"fmt"
|
|
|
+ "net/http"
|
|
|
"reflect"
|
|
|
"sort"
|
|
|
"strconv"
|
|
@@ -212,20 +213,17 @@ func GetInfoTitle(info *map[string]interface{}) string {
|
|
|
}
|
|
|
|
|
|
//加载数据到内存中
|
|
|
-func LoadBidding(mgo *MongodbSim, dbName, coll string, startTime int64, redisCache bool) (*[]map[string]interface{}, int64) {
|
|
|
+func LoadBidding(mgo *MongodbSim, dbName, coll string, startTime int64, redisCache bool, query map[string]interface{}) (*[]map[string]interface{}, int64) {
|
|
|
defer util.Catch()
|
|
|
endTime := time.Now().Unix()
|
|
|
- query := map[string]interface{}{
|
|
|
- "pici": map[string]interface{}{
|
|
|
- "$gte": startTime,
|
|
|
- "$lt": endTime,
|
|
|
- },
|
|
|
+ if query == nil || len(query) == 0 {
|
|
|
+ query = map[string]interface{}{
|
|
|
+ "pici": map[string]interface{}{
|
|
|
+ "$gte": startTime,
|
|
|
+ "$lt": endTime,
|
|
|
+ },
|
|
|
+ }
|
|
|
}
|
|
|
- // query = map[string]interface{}{
|
|
|
- // "_id": map[string]interface{}{
|
|
|
- // "$in": ToObjectIds([]string{"5b7bd6b9a5cb26b9b7449fd7", "5b7bd6b9a5cb26b9b7449fe4", "626c4b63923488e172579d81", "5b7bd6b9a5cb26b9b7449fde"}),
|
|
|
- // },
|
|
|
- // }
|
|
|
logger.Info("开始加载", coll, "数据", query)
|
|
|
var res []map[string]interface{}
|
|
|
sess := mgo.GetMgoConn()
|
|
@@ -703,9 +701,9 @@ func IdentityByEntUserId(base, main *Mysql, entUserId int64) *IdentityInfo {
|
|
|
//格式化小时
|
|
|
func HourFormat(hour int) string {
|
|
|
if hour < 10 {
|
|
|
- return fmt.Sprintf("0%d:00")
|
|
|
+ return fmt.Sprintf("0%d:00", hour)
|
|
|
} else {
|
|
|
- return fmt.Sprintf("%d:00")
|
|
|
+ return fmt.Sprintf("%d:00", hour)
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -727,3 +725,21 @@ func TimesIsOver(times []string, hour int) (bool, time.Time, time.Time) {
|
|
|
return hour > lastHour, start, now
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+//监听超时
|
|
|
+func MonitorTimeOut(pool chan bool, timeoutWarn string, f func()) bool {
|
|
|
+ select {
|
|
|
+ case <-time.After(1 * time.Minute):
|
|
|
+ go func() {
|
|
|
+ f()
|
|
|
+ if timeoutWarn != "" {
|
|
|
+ if _, err := http.Get(timeoutWarn); err != nil {
|
|
|
+ logger.Error("发送告警邮件错误", err)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }()
|
|
|
+ return false
|
|
|
+ case pool <- true:
|
|
|
+ }
|
|
|
+ return true
|
|
|
+}
|