瀏覽代碼

分包信息处理

wcc 2 年之前
父節點
當前提交
687752a840

+ 85 - 10
createEsIndex/bidding_es.go

@@ -67,7 +67,7 @@ func biddingTask(mapInfo map[string]interface{}) {
 	for tmp := make(map[string]interface{}); it.Next(tmp); c1++ {
 		if c1%1000 == 0 {
 			log.Info("biddingTask", zap.Int("current:", c1))
-			log.Info("biddingAllTask", zap.Any("current:_id =>", tmp["_id"]))
+			log.Info("biddingTask", zap.Any("current:_id =>", tmp["_id"]))
 		}
 		ch <- true
 		wg.Add(1)
@@ -353,6 +353,7 @@ func biddingTaskById(mapInfo map[string]interface{}) {
 		}
 		saveEsPool <- newTmp
 	}
+	log.Info("biddingTaskById over", zap.Any("mapInfo", mapInfo))
 }
 
 // GetEsField @Description ES字段
@@ -360,8 +361,9 @@ func biddingTaskById(mapInfo map[string]interface{}) {
 func GetEsField(tmp map[string]interface{}, stype string) (map[string]interface{}, map[string]interface{}) {
 	newTmp := make(map[string]interface{})
 	update := make(map[string]interface{}) // bidding 修改字段
-	saveErr := make(map[string]interface{})
-	for field, ftype := range config.Conf.DB.Es.FieldEs {
+	//saveErr := make(map[string]interface{})
+	//for field, ftype := range config.Conf.DB.Es.FieldEs {
+	for field, ftype := range BiddingField {
 		if tmp[field] != nil { //
 			if field == "purchasinglist" { //标的物处理
 				purchasinglist_new := []map[string]interface{}{}
@@ -369,7 +371,7 @@ func GetEsField(tmp map[string]interface{}, stype string) (map[string]interface{
 					for _, ls := range pcl {
 						lsm_new := make(map[string]interface{})
 						lsm := ls.(map[string]interface{})
-						for pf, pftype := range config.Conf.DB.Es.FieldPurchasingList {
+						for pf, pftype := range BiddingLevelField[field] {
 							lsmv := lsm[pf]
 							if lsmv != nil && reflect.TypeOf(lsmv).String() == pftype {
 								lsm_new[pf] = lsm[pf]
@@ -390,7 +392,7 @@ func GetEsField(tmp map[string]interface{}, stype string) (map[string]interface{
 					for _, p := range plist {
 						p1 := p.(map[string]interface{})
 						p2 := make(map[string]interface{})
-						for k, v := range config.Conf.DB.Es.FieldProcurementList {
+						for k, v := range BiddingLevelField[field] {
 							if k == "projectname" && util.ObjToString(p1[k]) == "" {
 								p2[k] = util.ObjToString(tmp["projectname"])
 							} else if k == "buyer" && util.ObjToString(p1[k]) == "" && util.ObjToString(tmp["buyer"]) != "" {
@@ -425,7 +427,7 @@ func GetEsField(tmp map[string]interface{}, stype string) (map[string]interface{
 					for _, win := range winnerorder {
 						winMap_new := make(map[string]interface{})
 						winMap := win.(map[string]interface{})
-						for wf, wftype := range config.Conf.DB.Es.FieldWinnerOrder {
+						for wf, wftype := range BiddingLevelField[field] {
 							wfv := winMap[wf]
 							if wfv != nil && reflect.TypeOf(wfv).String() == wftype {
 								if wf == "sort" && util.Int64All(wfv) > 100 {
@@ -496,6 +498,13 @@ func GetEsField(tmp map[string]interface{}, stype string) (map[string]interface{
 				if tmp[field] != nil && util.Int64All(tmp[field]) > 0 {
 					newTmp[field] = util.Int64All(tmp[field])
 				}
+			} else if field == "package" {
+				//分包信息处理
+				packages := dealPackage(tmp)
+				if len(packages) > 0 {
+					newTmp["package"] = packages
+					newTmp["subpackage"] = 1
+				}
 			} else { //其它字段判断数据类型,不正确舍弃
 				if fieldval := tmp[field]; reflect.TypeOf(fieldval).String() != ftype {
 					continue
@@ -523,10 +532,10 @@ func GetEsField(tmp map[string]interface{}, stype string) (map[string]interface{
 		update["pici"] = time.Now().Unix()
 	}
 
-	if len(saveErr) > 0 {
-		saveErr["infoid"] = mongodb.BsonIdToSId(tmp["_id"])
-		saveErrBidPool <- saveErr
-	}
+	//if len(saveErr) > 0 {
+	//	saveErr["infoid"] = mongodb.BsonIdToSId(tmp["_id"])
+	//	saveErrBidPool <- saveErr
+	//}
 	return newTmp, update
 }
 
@@ -749,3 +758,69 @@ func MatchService(tmp map[string]interface{}) (res string) {
 
 	return
 }
+
+//dealPackage 处理package 字段
+func dealPackage(tmp map[string]interface{}) (newpackages []map[string]interface{}) {
+	package1, ok1 := tmp["package"]
+	s_winner, ok2 := tmp["s_winner"]
+	bidamount, ok3 := tmp["bidamount"]
+	var innerWinners = make([]string, 0)
+	var biaoAmounts = make([]float64, 0)
+	// 三个字段都存在
+	if ok3 && ok2 && ok1 {
+		packageMap, ok := package1.(map[string]interface{})
+		if ok {
+			if len(packageMap) > 2 {
+				var packages = make([]map[string]interface{}, 0)
+				//var newTmp = make(map[string]interface{})
+				winner_amount_count := 0
+				for _, pack := range packageMap {
+					var newPackage = make(map[string]interface{})
+					pac, okk := pack.(map[string]interface{})
+					if okk {
+						_, okk1 := pac["winner"]
+						_, okk2 := pac["bidamount"]
+						_, okk3 := pac["name"]
+
+						if okk1 {
+							innerWinners = append(innerWinners, util.ObjToString(pac["winner"]))
+						}
+						if okk2 {
+							biaoAmounts = append(biaoAmounts, util.Float64All(pac["bidamount"]))
+						}
+						//winner bidamount 二个字段都存在
+						if okk1 && okk2 {
+							winner_amount_count++
+							newPackage["winner"] = pac["winner"]
+							newPackage["bidamount"] = pac["bidamount"]
+							if okk3 {
+								newPackage["name"] = pac["name"]
+							}
+							packages = append(packages, newPackage)
+						}
+
+					}
+
+				}
+
+				//出现次数大于1
+				if winner_amount_count > 1 {
+					swinner := util.ObjToString(s_winner)
+					swinners := strings.Split(swinner, ",")
+					//判断里外 winner 是否相等
+					eq := StringSliceValuesEqual(swinners, innerWinners)
+					if eq {
+						//判断金额相等
+						if Float64Equal1Precision(Float64SliceSum(biaoAmounts), util.Float64All(bidamount)) {
+							newpackages = packages
+						}
+					}
+				}
+
+			}
+
+		}
+	}
+
+	return
+}

+ 133 - 127
createEsIndex/common.toml

@@ -5,10 +5,10 @@
 
 [db]
 [db.mongoB]
-#    addr = "127.0.0.1:27017"
-    addr = "192.168.3.207:29099"    ## 测试环境
+    addr = "127.0.0.1:27017"
+#    addr = "192.168.3.207:29099"    ## 测试环境
     dbname = "wcc"
-    coll = "bidding_wcc_random2"
+    coll = "bidding"
     size = 15
 #    user = "root"
 #    password = "root"
@@ -42,13 +42,13 @@
 #    password = "123456"
     size = 5
     indexb = "wcc_test"
-    typeb = "bidding"
-    indexp = "projectset_v1"
-    typep = "projectset"
+#    typeb = "bidding"
+    indexp = "projectset"
+#    typep = "projectset"
     indexwinner = "winner"
-    typewinner = "winner"
-    indexbuyer = "buyer_v2"
-    typebuyer = "buyer"
+#    typewinner = "winner"
+    indexbuyer = "buyer"
+#    typebuyer = "buyer"
 detailfilter = ["(招标网|千里马|采招网|招标采购导航网|招标与采购网|中国招投标网|中国采购与招标网|中国采购与招标|优质采)[\\w\\W]{0,15}[http|https|htpps]?[a-z0-9:\\/\\/.]{0,20}(qianlima|zhaobiao|okcis|zbytb|infobidding|bidcenter|youzhicai|chinabidding|Chinabidding|CHINABIDDING)[a-z0-9.\\/\\/]{0,40}",
     "招标网[\\w\\W]{0,15}[http|https|htpps]?[a-z0-9:\\/\\/.]{0,20}zhaobiao[a-z0-9.\\/\\/]{0,40}",
     "千里马[\\w\\W]{0,15}[a-z0-9:\\/\\/.]{0,20}qianlima[a-z0-9.\\/\\/]{0,10}",
@@ -79,121 +79,127 @@ loglevel  = "debug"
 # text or json output
 format = "text"
 
-[db.es.fieldes]
-"_id" = ""
-"buyerzipcode" = "string"
-"winnertel" = "string"
-"winnerperson" = "string"
-"contractcode" = "string"
-"winneraddr" = "string"
-"agencyaddr" = "string"
-"buyeraddr" = "string"
-"signaturedate" = "int64"
-"projectperiod" = "string"
-"projectaddr" = "string"
-"agencytel" = "string"
-"agencyperson" = "string"
-"buyerperson" = "string"
-"agency" = "string"
-"projectscope" = "string"
-"projectcode" = "string"
-"bidopentime" = "int64"
-"supervisorrate" = "float64"
-"buyertel" = "string"
-"bidamount" = "float64"
-"winner" = "string"
-"buyer" = "string"
-"budget" = "float64"
-"projectname" = "string"
-"bidstatus" = "string"
-"buyerclass" = "string"
-"topscopeclass" = ""
-"s_topscopeclass" = "string"
-"s_subscopeclass" = "string"
-"area" = "string"
-"city" = "string"
-"district" = "string"
-"s_winner" = "string"
-"title" = "string"
-"detail" = "string"
-"site" = "string"
-"comeintime" = "int64"
-"href" = "string"
-"infoformat" = "int32"
-"publishtime" = "int64"
-"s_sha" = "string"
-"spidercode" = "string"
-"subtype" = "string"
-"toptype" = "string"
-"projectinfo" = ""
-"purchasing" = "string"
-"purchasinglist" = ""
-"channel" = "string"
-"winnerorder" = ""
-"project_scale" = "string"
-"project_duration" = "int32"
-"project_timeunit" = "string"
-"project_startdate" = "int64"
-"project_completedate" = "int64"
-"payway" = "string"
-"contract_guarantee" = "bool"
-"bid_guarantee" = "bool"
-"qualifies" = ""
-"entidlist" = ""
-"funds" = "string"
-"review_experts" = "string"
-"bidmethod" = "string"
-"bidendtime" = "int64"
-"bidopenaddress" = "string"
-"docamount" = "float64"
-"agencyrate" = "float64"
-"agencyfee" = "float64"
-"bidway" = "string"
-"getdocmethod" = "string"
-"china_bidding" = "string"
-"purchasing_tag" = "string"
-"multipackage" = "int32"
-"isValidFile" = "bool"
-"bid_field" = "string"
-"bidstarttime" = "int64"
-"docendtime" = "int64"
-"docstarttime" = "int64"
-"signendtime" = "int64"
-"signstarttime" = "int64"
-"issue_quota" = "float64"
-"bidopen_shape" = "string"
-"quote_mode" = "string"
-"is_acquire_tender" = "bool"
-"is_payment_deposit" = "bool"
-"is_joint_bidding" = "bool"
-"procurementlist" = ""
-"object_type"="string"  ##针对中国政府采购网,添加字段,区分货物、服务和工程
-[db.es.fieldprojectinfo]
-"approvecode" = "string"
-"approvecontent" = "string"
-"approvestatus" = "string"
-"approvetime" = "string"
-"approvedept" = "string"
-"approvenumber" = "string"
-"projecttype" = "string"
-"approvecity" = "string"
-[db.es.fieldpurchasinglist]
-"itemname" = "string"
-"item" = "string"
-"brandname" = "string"
-"model" = "string"
-"unitname" = "string"
-"number" = "float64"
-"unitprice" = "float64"
-"totalprice" = "float64"
-[db.es.fieldprocurementlist]
-"projectname" = "string"
-"buyer" = "string"
-"item" = "string"
-"projectscope" = "string"
-"expurasingtime" = "int64"
-"totalprice" = "float64"
-[db.es.fieldwinnerorder]
-"sort" = "int"
-"sortstr" = "string"
-"entname" = "string"
+#[db.es.fieldes]
+#"_id" = ""
+#"buyerzipcode" = "string"
+#"winnertel" = "string"
+#"winnerperson" = "string"
+#"contractcode" = "string"
+#"winneraddr" = "string"
+#"agencyaddr" = "string"
+#"buyeraddr" = "string"
+#"signaturedate" = "int64"
+#"projectperiod" = "string"
+#"projectaddr" = "string"
+#"agencytel" = "string"
+#"agencyperson" = "string"
+#"buyerperson" = "string"
+#"agency" = "string"
+#"projectscope" = "string"
+#"projectcode" = "string"
+#"bidopentime" = "int64"
+#"supervisorrate" = "float64"
+#"buyertel" = "string"
+#"bidamount" = "float64"
+#"winner" = "string"
+#"buyer" = "string"
+#"budget" = "float64"
+#"projectname" = "string"
+#"bidstatus" = "string"
+#"buyerclass" = "string"
+#"topscopeclass" = ""
+#"s_topscopeclass" = "string"
+#"s_subscopeclass" = "string"
+#"area" = "string"
+#"city" = "string"
+#"district" = "string"
+#"s_winner" = "string"
+#"title" = "string"
+#"detail" = "string"
+#"site" = "string"
+#"comeintime" = "int64"
+#"href" = "string"
+#"infoformat" = "int32"
+#"publishtime" = "int64"
+#"s_sha" = "string"
+#"spidercode" = "string"
+#"subtype" = "string"
+#"toptype" = "string"
+#"projectinfo" = ""
+#"purchasing" = "string"
+#"purchasinglist" = ""
+#"channel" = "string"
+#"winnerorder" = ""
+#"project_scale" = "string"
+#"project_duration" = "int32"
+#"project_timeunit" = "string"
+#"project_startdate" = "int64"
+#"project_completedate" = "int64"
+#"payway" = "string"
+#"contract_guarantee" = "bool"
+#"bid_guarantee" = "bool"
+#"qualifies" = ""
+#"entidlist" = ""
+#"funds" = "string"
+#"review_experts" = "string"
+#"bidmethod" = "string"
+#"bidendtime" = "int64"
+#"bidopenaddress" = "string"
+#"docamount" = "float64"
+#"agencyrate" = "float64"
+#"agencyfee" = "float64"
+#"bidway" = "string"
+#"getdocmethod" = "string"
+#"china_bidding" = "string"
+#"purchasing_tag" = "string"
+#"multipackage" = "int32"
+#"isValidFile" = "bool"
+#"bid_field" = "string"
+#"bidstarttime" = "int64"
+#"docendtime" = "int64"
+#"docstarttime" = "int64"
+#"signendtime" = "int64"
+#"signstarttime" = "int64"
+#"issue_quota" = "float64"
+#"bidopen_shape" = "string"
+#"quote_mode" = "string"
+#"is_acquire_tender" = "bool"
+#"is_payment_deposit" = "bool"
+#"is_joint_bidding" = "bool"
+#"procurementlist" = ""
+#"object_type" = "string"  ##针对中国政府采购网,添加字段,区分货物、服务和工程
+#"subpackage" = "int64"
+#"package" = ""          ## 分包信息
+#[db.es.fieldprojectinfo] ## 作废不再使用
+#"approvecode" = "string"
+#"approvecontent" = "string"
+#"approvestatus" = "string"
+#"approvetime" = "string"
+#"approvedept" = "string"
+#"approvenumber" = "string"
+#"projecttype" = "string"
+#"approvecity" = "string"
+#[db.es.fieldpurchasinglist]
+#"itemname" = "string"
+#"item" = "string"
+#"brandname" = "string"
+#"model" = "string"
+#"unitname" = "string"
+#"number" = "float64"
+#"unitprice" = "float64"
+#"totalprice" = "float64"
+#[db.es.fieldprocurementlist]
+#"projectname" = "string"
+#"buyer" = "string"
+#"item" = "string"
+#"projectscope" = "string"
+#"expurasingtime" = "int64"
+#"totalprice" = "float64"
+#[db.es.fieldwinnerorder]
+#"sort" = "int"
+#"sortstr" = "string"
+#"entname" = "string"
+#[db.es.package] ## 分包新增字段
+#"winner" = "string"
+#"bidamount" = "float64"
+#"name" = "string"

+ 19 - 18
createEsIndex/config/conf.go

@@ -84,24 +84,25 @@ type mgo struct {
 }
 
 type es struct {
-	Addr                 string
-	AddrP                string
-	Size                 int
-	Username             string
-	Password             string
-	IndexB               string
-	TypeB                string
-	IndexP               string
-	TypeP                string
-	IndexWinner          string
-	TypeWinner           string
-	IndexBuyer           string
-	TypeBuyer            string
-	FieldEs              map[string]interface{}
-	FieldPurchasingList  map[string]interface{}
-	FieldProcurementList map[string]interface{}
-	FieldWinnerOrder     map[string]interface{}
-	DetailFilter         []string
+	Addr         string
+	AddrP        string
+	Size         int
+	Username     string
+	Password     string
+	IndexB       string
+	TypeB        string
+	IndexP       string
+	TypeP        string
+	IndexWinner  string
+	TypeWinner   string
+	IndexBuyer   string
+	TypeBuyer    string
+	DetailFilter []string
+	//FieldEs              map[string]interface{}
+	//FieldPurchasingist  map[string]interface{}
+	//FieldProcurementList map[string]interface{}
+	//FieldWinnerOrder     map[string]interface{}
+	//Package              map[string]interface{}
 }
 
 type duration struct {

+ 2 - 2
createEsIndex/config/conf_test.go

@@ -179,7 +179,7 @@ format = "text"
 "projectscope" = "string"
 "expurasingtime" = "string"
 "totalprice" = "float64"
-[db.es.fieldwinnerorder]
+[db.es.fieldwinneroLrder]
 "sort" = "int"
 "sortstr" = "string"
 "entname" = "string"
@@ -189,6 +189,6 @@ func TestInit(t *testing.T) {
 	testfile := "/tmp/crocodile.toml"
 	ioutil.WriteFile(testfile, []byte(confs), 0644)
 	Init(testfile)
-	t.Logf("%+v", Conf.DB.Es.FieldPurchasingList)
+	//t.Logf("%+v", Conf.DB.Es.FieldPurchasingList)
 	os.Remove(testfile)
 }

+ 89 - 0
createEsIndex/es_test.go

@@ -1,8 +1,11 @@
 package main
 
 import (
+	"context"
 	"encoding/json"
 	"fmt"
+	"github.com/olivere/elastic/v7"
+	"reflect"
 	"testing"
 )
 
@@ -31,3 +34,89 @@ func TestMatchService(t *testing.T) {
 	objectType := MatchService(obj)
 	fmt.Println("objectType=>", objectType)
 }
+
+func TestGetMappting(t *testing.T) {
+	client, _ := elastic.NewClient(
+		elastic.SetURL("http://192.168.3.149:9200"),
+		elastic.SetSniff(false),
+	)
+
+	index := "wcc_test"
+	// 获取 Elasticsearch 索引的 mapping 信息
+	mapping, err := client.GetMapping().Index(index).Do(context.Background())
+	if err != nil {
+		fmt.Println("Error getting Elasticsearch mapping:", err)
+		return
+	}
+
+	properties := mapping[index].(map[string]interface{})["mappings"].(map[string]interface{})["properties"].(map[string]interface{})
+	fmt.Println(properties)
+
+	var errField = make([]string, 0)
+
+	//for _, v := range BiddingField {
+	//	if v != "" {
+	//
+	//	}
+	//}
+	for k, v := range properties {
+		b, ok := BiddingField[k]
+		if ok {
+			mappingType := v.(map[string]interface{})["type"].(string)
+			analyzer := v.(map[string]interface{})["analyzer"].(string)
+			//分词器不为空
+			if analyzer != "" {
+
+			}
+
+			//="",表示二级
+			if b == "" {
+
+				fmt.Println(111)
+			} else {
+				if mappingType == "keyword" || mappingType == "text" {
+					if b != "string" {
+						errField = append(errField, k)
+					}
+				} else if mappingType == "boolean" {
+					if b != "bool" {
+						errField = append(errField, k)
+					}
+				} else if mappingType == "" {
+
+				}
+				fmt.Println(222)
+			}
+
+		}
+	}
+}
+
+func getGoVarType(esMappingType string) reflect.Type {
+	var goVarType reflect.Type
+
+	switch esMappingType {
+	case "text", "keyword", "ip", "geo_point", "date", "binary":
+		goVarType = reflect.TypeOf("")
+	case "long":
+		goVarType = reflect.TypeOf(int64(0))
+	case "integer":
+		goVarType = reflect.TypeOf(int32(0))
+	case "short":
+		goVarType = reflect.TypeOf(int16(0))
+	case "byte":
+		goVarType = reflect.TypeOf(int8(0))
+	case "double":
+		goVarType = reflect.TypeOf(0.0)
+	case "float":
+		goVarType = reflect.TypeOf(float32(0.0))
+	case "boolean":
+		goVarType = reflect.TypeOf(false)
+	case "nested":
+		goVarType = reflect.TypeOf(make(map[string]interface{}))
+	default:
+		goVarType = reflect.TypeOf(nil)
+	}
+
+	return goVarType
+}

+ 25 - 2
createEsIndex/init.go

@@ -12,8 +12,10 @@ import (
 )
 
 var (
-	ProjectField = make(map[string]string, 500)
-	ProjectListF = make(map[string]string, 200)
+	ProjectField      = make(map[string]string, 500) //项目字段
+	ProjectListF      = make(map[string]string, 200)
+	BiddingField      = make(map[string]string, 200)       //bidding_processing_field, level=1 最外层字段,
+	BiddingLevelField = make(map[string]map[string]string) //level=2 的第二层字段
 )
 
 // InitLog @Description
@@ -94,3 +96,24 @@ func InitField() {
 	}
 	log.Info("InitField", zap.Int("ProjectField", len(ProjectField)), zap.Int("ProjectListF", len(ProjectListF)))
 }
+
+func InitEsBiddingField() {
+	info, _ := MgoB.Find("bidding_processing_field", `{"stype": "bidding"}`, nil, nil, false, -1, -1)
+	if len(*info) > 0 {
+		for _, m := range *info {
+			if util.IntAll(m["level"]) == 1 {
+				BiddingField[util.ObjToString(m["field"])] = util.ObjToString(m["ftype"])
+			} else if util.IntAll(m["level"]) == 2 {
+				pfield := util.ObjToString(m["pfield"])
+				pfieldMap := BiddingLevelField[pfield]
+				if pfieldMap == nil {
+					pfieldMap = make(map[string]string, 0)
+				}
+				pfieldMap[util.ObjToString(m["field"])] = util.ObjToString(m["ftype"])
+				BiddingLevelField[pfield] = pfieldMap
+			}
+		}
+	}
+	log.Info("InitEsBiddingField", zap.Int("BiddingField es 一级字段数量", len(BiddingField)))
+	log.Info("InitEsBiddingField", zap.Int("BiddingLevelField es 二级字段数量", len(BiddingLevelField)))
+}

+ 37 - 36
createEsIndex/main.go

@@ -40,8 +40,8 @@ var (
 	saveEsAllPool     = make(chan map[string]interface{}, 5000)
 	saveEsAllSp       = make(chan bool, 5)
 
-	saveErrBidPool = make(chan map[string]interface{}, 5000)
-	saveBidSp      = make(chan bool, 5)
+	//saveErrBidPool = make(chan map[string]interface{}, 5000)
+	//saveBidSp      = make(chan bool, 5)
 
 	//detailLength = 50000 // es保存detail长度
 	fileLength = 50000 // es保存附件文本长度
@@ -55,6 +55,7 @@ func init() {
 	InitMgo()
 	InitEs()
 	InitField()
+	InitEsBiddingField()
 	oss.InitOss()
 
 	JyUdpAddr = &net.UDPAddr{
@@ -247,40 +248,40 @@ func UpdateBidding() {
 	}
 }
 
-func SaveBidErr() {
-	arru := make([]map[string]interface{}, 200)
-	indexu := 0
-	for {
-		select {
-		case v := <-saveErrBidPool:
-			arru[indexu] = v
-			indexu++
-			if indexu == 200 {
-				saveBidSp <- true
-				go func(arru []map[string]interface{}) {
-					defer func() {
-						<-saveBidSp
-					}()
-					MgoB.SaveBulk("bidding_es_err_record", arru...)
-				}(arru)
-				arru = make([]map[string]interface{}, 200)
-				indexu = 0
-			}
-		case <-time.After(1000 * time.Millisecond):
-			if indexu > 0 {
-				saveBidSp <- true
-				go func(arru []map[string]interface{}) {
-					defer func() {
-						<-saveBidSp
-					}()
-					MgoB.SaveBulk("bidding_es_err_record", arru...)
-				}(arru[:indexu])
-				arru = make([]map[string]interface{}, 200)
-				indexu = 0
-			}
-		}
-	}
-}
+//func SaveBidErr() {
+//	arru := make([]map[string]interface{}, 200)
+//	indexu := 0
+//	for {
+//		select {
+//		case v := <-saveErrBidPool:
+//			arru[indexu] = v
+//			indexu++
+//			if indexu == 200 {
+//				saveBidSp <- true
+//				go func(arru []map[string]interface{}) {
+//					defer func() {
+//						<-saveBidSp
+//					}()
+//					MgoB.SaveBulk("bidding_es_err_record", arru...)
+//				}(arru)
+//				arru = make([]map[string]interface{}, 200)
+//				indexu = 0
+//			}
+//		case <-time.After(1000 * time.Millisecond):
+//			if indexu > 0 {
+//				saveBidSp <- true
+//				go func(arru []map[string]interface{}) {
+//					defer func() {
+//						<-saveBidSp
+//					}()
+//					MgoB.SaveBulk("bidding_es_err_record", arru...)
+//				}(arru[:indexu])
+//				arru = make([]map[string]interface{}, 200)
+//				indexu = 0
+//			}
+//		}
+//	}
+//}
 
 //SaveEsMethod 保存到es
 func SaveEsMethod() {

+ 33 - 0
createEsIndex/utils.go

@@ -2,6 +2,8 @@ package main
 
 import (
 	"app.yhyue.com/data_processing/common_utils/mongodb"
+	"math"
+	"sort"
 )
 
 //convertToMongoID convertToMongoID
@@ -24,3 +26,34 @@ func convertToMongoID(query map[string]interface{}) map[string]interface{} {
 
 	return result
 }
+
+//StringSliceValuesEqual  判断切片相等
+func StringSliceValuesEqual(a, b []string) bool {
+	if len(a) != len(b) {
+		return false
+	}
+
+	sort.Strings(a)
+	sort.Strings(b)
+
+	for i := range a {
+		if a[i] != b[i] {
+			return false
+		}
+	}
+
+	return true
+}
+
+//Float64SliceSum float64 数据求和
+func Float64SliceSum(nums []float64) float64 {
+	sum := 0.0
+	for _, num := range nums {
+		sum += num
+	}
+	return sum
+}
+
+func Float64Equal1Precision(a, b float64) bool {
+	return int(math.Round(a*10)) == int(math.Round(b*10))
+}