zhengkun 2 роки тому
батько
коміт
cf1eee2b77

+ 3 - 4
fieldproject_medical/data_service/src/bidding/bidding.go

@@ -37,11 +37,11 @@ func RunPurchasingInfo(gtid string, lteid string, obj_id bool) {
 		}
 	}
 	it := sess.DB(ul.Mgo.DbName).C(ul.S_Bidding_Coll).Find(&q).Sort("_id").Select(BidFields).Iter()
-	pool := make(chan bool, 8)
+	pool := make(chan bool, 4)
 	wg := &sync.WaitGroup{}
 	total, isok := 0, 0
 	for tmp := make(map[string]interface{}); it.Next(&tmp); total++ {
-		if total%1000 == 0 {
+		if total%10000 == 0 {
 			log.Debug("cur index ", total, "~", isok)
 		}
 		if qu.IntAll(tmp["extracttype"]) != 1 {
@@ -76,8 +76,7 @@ func RunPurchasingInfo(gtid string, lteid string, obj_id bool) {
 		tmp = make(map[string]interface{})
 	}
 	wg.Wait()
-
-	log.Debug("is over ", total, "~", isok)
+	log.Debug("is over ~ ", total, "~", isok)
 }
 
 //构建标的物基本信息~模式一~规则型

+ 4 - 1
fieldproject_medical/data_service/src/main.go

@@ -2,17 +2,19 @@ package main
 
 import (
 	"bidding"
+	log "github.com/donnie4w/go-logger/logger"
 	"udp"
 	ul "util"
 )
 
 func init() {
+	//ul.IsLocal = true
 	udp.InitUdpMsg()
 	ul.InitClass()
+	log.Debug("~~~~准备完毕~~~~")
 }
 
 func main() {
-	//Test()
 	lock := make(chan bool)
 	<-lock
 }
@@ -21,4 +23,5 @@ func Test() {
 	gtid := "630e34000000000000000000"
 	lteid := "6314cb800000000000000000"
 	bidding.RunPurchasingInfo(gtid, lteid, true)
+
 }

+ 22 - 4
fieldproject_medical/data_service/src/udp/udp.go

@@ -7,20 +7,21 @@ import (
 	mu "mfw/util"
 	"net"
 	qu "qfw/util"
+	"sync"
 )
 
 var (
 	udpclient mu.UdpClient
+	udpLock   sync.Mutex
 )
 
 func InitUdpMsg() {
-	port := ":5550"
-	udpclient = mu.UdpClient{Local: ":5550", BufSize: 1024}
+	port := ":1581"
+	udpclient = mu.UdpClient{Local: port, BufSize: 1024}
 	udpclient.Listen(processUdpMsg)
 	log.Debug("监听~", port)
 }
 
-//udp接收
 func processUdpMsg(act byte, data []byte, ra *net.UDPAddr) {
 	switch act {
 	case mu.OP_TYPE_DATA:
@@ -35,13 +36,30 @@ func processUdpMsg(act byte, data []byte, ra *net.UDPAddr) {
 			} else {
 				key := sid + "-" + eid + "-" + qu.ObjToString(mapInfo["stype"])
 				udpclient.WriteUdp([]byte(key), mu.OP_NOOP, ra)
+				udpLock.Lock()
 				bidding.RunPurchasingInfo(sid, eid, true)
+				udpLock.Unlock()
+				//处理完毕~发送
+				processNextNode(sid, eid, key)
 			}
 		}
 	case mu.OP_NOOP: //下个节点回应
 		ok := string(data)
 		if ok != "" {
-			log.Debug("ok:", ok)
+			log.Debug("接收~", ok)
 		}
 	}
 }
+
+func processNextNode(sid string, eid string, key string) {
+	by, _ := json.Marshal(map[string]interface{}{
+		"gtid":  sid,
+		"lteid": eid,
+		"key":   key,
+	})
+	addr := &net.UDPAddr{
+		IP:   net.ParseIP("172.17.4.189"),
+		Port: 1582,
+	}
+	udpclient.WriteUdp(by, mu.OP_TYPE_DATA, addr)
+}

+ 14 - 13
fieldproject_medical/data_service/src/util/initcfg.go

@@ -49,27 +49,28 @@ func InitClass() {
 //初始化mgo
 func initMgo() {
 	if IsLocal {
+		Mgo = &MongodbSim{
+			MongodbAddr: "192.168.3.207:27001",
+			DbName:      "qfw_data",
+			Size:        10,
+			UserName:    "root",
+			Password:    "root",
+		}
+		Mgo.InitPool()
+
 		//Mgo = &MongodbSim{
-		//	MongodbAddr: "192.168.3.207:27001",
-		//	DbName:      "qfw_data",
+		//	MongodbAddr: "127.0.0.1:27017",
+		//	DbName:      "zhengkun",
 		//	Size:        10,
-		//	UserName:    "root",
-		//	Password:    "root",
+		//	UserName:    "",
+		//	Password:    "",
 		//}
 		//Mgo.InitPool()
-		Mgo = &MongodbSim{
-			MongodbAddr: "127.0.0.1:27017",
-			DbName:      "zhengkun",
-			Size:        30,
-			UserName:    "",
-			Password:    "",
-		}
-		Mgo.InitPool()
 	} else {
 		Mgo = &MongodbSim{
 			MongodbAddr: "172.17.145.163:27083,172.17.4.187:27082",
 			DbName:      "qfw",
-			Size:        30,
+			Size:        10,
 			UserName:    "zhengkun",
 			Password:    "zk@123123",
 		}