wanghuidong 5 年之前
父节点
当前提交
c11aada942
共有 5 个文件被更改,包括 36 次插入11 次删除
  1. 28 0
      customerdata/src/test/data_test.go
  2. 4 4
      customerdata/src/util.go
  3. 2 3
      src/config.json
  4. 2 2
      src/history/util_history.go
  5. 0 2
      src/util/config.go

+ 28 - 0
customerdata/src/test/data_test.go

@@ -0,0 +1,28 @@
+package test
+
+import (
+	"fmt"
+	"testing"
+	"time"
+)
+
+func Test_Data1(t *testing.T) {
+	//fmt.Println("888")
+	var saveCache = make(chan int, 10)
+	go func() {
+		time.AfterFunc(10*time.Second, func() {
+			for i := 0; i < 10; i++ {
+				saveCache <- i
+				time.Sleep(1 * time.Second)
+			}
+		})
+	}()
+	for {
+		select {
+		case v := <-saveCache:
+			fmt.Println("保存:", v)
+		case <-time.After(1000 * time.Millisecond):
+			fmt.Println("111")
+		}
+	}
+}

+ 4 - 4
customerdata/src/util.go

@@ -339,7 +339,7 @@ func RegMatch(fieldText map[string]interface{}, matchType []string, matchReg *Re
 				for n, arc := range ar.AndRegKid { //ar.AndRegKid若有值必不小于2
 					if indexArr := arc.CrVal.FindAllStringIndex(text, -1); len(indexArr) < 1 { //匹配失败(ar.AndRegKid中任意一个未匹配则失败)
 						break
-					} else { //匹配成功,判断字母
+					} else {                                                         //匹配成功,判断字母
 						if arc.IsLetter && !CheckLetter(text, arc.CrVal, indexArr) { //reg有字母,判断是否是包含关系(AAAIBBB or AI)
 							break
 						}
@@ -722,7 +722,7 @@ func RegMatchTest(fieldText map[string]interface{}, matchType []string, matchReg
 					qu.Debug("nnnn---", n, arc.CrVal, arc.IsLetter)
 					if indexArr := arc.CrVal.FindAllStringIndex(text, -1); len(indexArr) < 1 { //匹配失败(ar.AndRegKid中任意一个未匹配则失败)
 						break
-					} else { //匹配成功,判断字母
+					} else {                                                         //匹配成功,判断字母
 						if arc.IsLetter && !CheckLetter(text, arc.CrVal, indexArr) { //reg有字母,判断是否是包含关系(AAAIBBB or AI)
 							break
 						}
@@ -753,8 +753,8 @@ func RegMatchTest(fieldText map[string]interface{}, matchType []string, matchReg
 //发布时间不在范围内(7天)不要这条数据
 func SkipData(tmp map[string]interface{}) bool {
 	comeIn := qu.Int64All(tmp["comeintime"])
-	if qu.Int64All(tmp["publishtime"]) > (comeIn - 7*24*60*60 ) {
+	if qu.Int64All(tmp["publishtime"]) > (comeIn - 7*24*60*60) {
 		return true
 	}
 	return false
-}
+}

+ 2 - 3
src/config.json

@@ -45,9 +45,8 @@
 	"save": {
 		"addr": "192.168.3.207:27092",
 		"size": 15,
-		"db": "mxs",
-		"coll": "usermail",
-		"coll_test": "usermail_history"
+		"db": "datatag_ent",
+		"coll": "usermail_history"
 	},
 	"es": {
 		"addr": "http://192.168.3.128:9800",

+ 2 - 2
src/history/util_history.go

@@ -564,7 +564,7 @@ func SaveMgo() {
 					defer func() {
 						<-SP
 					}()
-					MgoSave.SaveBulk(SaveColl_test, arru...)
+					MgoSave.SaveBulk(SaveColl, arru...)
 				}(arru)
 				arru = make([]map[string]interface{}, 500)
 				indexu = 0
@@ -576,7 +576,7 @@ func SaveMgo() {
 					defer func() {
 						<-SP
 					}()
-					MgoSave.SaveBulk(SaveColl_test, arru...)
+					MgoSave.SaveBulk(SaveColl, arru...)
 				}(arru[:indexu])
 				arru = make([]map[string]interface{}, 500)
 				indexu = 0

+ 0 - 2
src/util/config.go

@@ -34,7 +34,6 @@ var (
 	SId           string
 	EId           string
 	CustomerName  string
-	SaveColl_test string
 )
 
 var (
@@ -186,7 +185,6 @@ func initdb() {
 	//mgo save
 	save := Sysconfig["save"].(map[string]interface{})
 	SaveColl = qu.ObjToString(save["coll"])
-	SaveColl_test = qu.ObjToString(save["coll_test"])
 	MgoSave = &mgo.MongodbSim{
 		MongodbAddr: qu.ObjToString(save["addr"]),
 		DbName:      qu.ObjToString(save["db"]),