Jianghan преди 5 години
родител
ревизия
f641102dbe

+ 2 - 1
.gitignore

@@ -5,4 +5,5 @@ bin
 *.log
 */src/src
 *.data
-*/bin
+*/bin
+tp

+ 112 - 0
fullproject/modifyMoney/src/main.go

@@ -0,0 +1,112 @@
+package main
+
+import (
+	"encoding/json"
+	"flag"
+	"github.com/tealeg/xlsx"
+	"io/ioutil"
+	"log"
+	mu "mfw/util"
+	"net"
+	qu "qfw/util"
+	"time"
+)
+
+var itype, p int
+var id, ip, budget, bidamount, file string
+func main()  {
+	flag.IntVar(&itype, "itype", 0, "类型")
+	flag.StringVar(&ip, "ip", "127.0.0.1", "ip")
+	flag.IntVar(&p, "p", 0, "端口")
+	flag.StringVar(&id, "id", "", "id")
+	flag.StringVar(&budget, "budget", "", "预算")
+	flag.StringVar(&bidamount, "bidamount", "", "中标金额")
+	flag.StringVar(&file, "file", "", "文件路径")
+	flag.Parse()
+
+	addr := &net.UDPAddr{
+		IP:   net.ParseIP(ip),
+		Port: p,
+	}
+	udp := mu.UdpClient{Local: ":50010", BufSize: 1024}
+	udp.Listen(func(b byte, data []byte, add *net.UDPAddr) {
+		switch b {
+		case mu.OP_NOOP:
+			//os.Exit(0)
+		}
+	})
+	if itype == 0 {
+		if ip != "" && p > 0 && (budget != "" || bidamount != "") && id != "" {
+			SendUdp(*addr, udp)
+		}else {
+			flag.PrintDefaults()
+			log.Println("参数错误.")
+		}
+	}else {
+		if file != "" {
+			binary, err := ioutil.ReadFile(file)
+			if err == nil {
+				data, _ := ParsData(binary)
+				if len(data) > 0 {
+					for _, v := range data{
+						if qu.ObjToString(v["_id"]) != "" {
+							id = qu.ObjToString(v["_id"])
+							budget = qu.ObjToString(v["budget"])
+							bidamount = qu.ObjToString(v["bidamount"])
+							SendUdp(*addr, udp)
+						}
+					}
+				}
+			}else {
+				qu.Debug("文件解析失败")
+			}
+		}else {
+			flag.PrintDefaults()
+			log.Println("参数错误.")
+		}
+	}
+}
+
+func SendUdp(addr net.UDPAddr, udp mu.UdpClient)  {
+
+	m1 := map[string]interface{}{
+		"id":  id,
+		"stype": "updateMoney",
+	}
+	if budget != "" {
+		m1["budget"] = budget
+	}
+	if bidamount != "" {
+		m1["bidamount"] = bidamount
+	}
+	by, _ := json.Marshal(m1)
+	log.Println(string(by))
+	_ = udp.WriteUdp(by, mu.OP_TYPE_DATA, &addr)
+	time.Sleep(1 * time.Second)
+}
+
+func ParsData(filebyte []byte) ([]map[string]interface{}, error) {
+	var data []map[string]interface{}
+	var keyName []string
+	file, err := xlsx.OpenBinary(filebyte)
+	if err != nil {
+		return data, err
+	}
+
+	for i, v := range file.Sheets[0].Rows {
+		info := make(map[string]interface{})
+		for ii, vv := range v.Cells {
+			if i == 0 {
+				keyName = append(keyName, vv.Value)
+			} else {
+				if vv.Value != "" {
+					info[keyName[ii]] = vv.Value
+				}
+			}
+		}
+		if len(info) > 0 {
+			data = append(data, info)
+		}
+	}
+	return data, nil
+}

+ 0 - 0
fullproject/src/config.json → fullproject/src_back/config.json


+ 0 - 0
fullproject/src/init.go → fullproject/src_back/init.go


+ 0 - 0
fullproject/src/load_data.go → fullproject/src_back/load_data.go


+ 0 - 0
fullproject/src/main.go → fullproject/src_back/main.go


+ 0 - 0
fullproject/src/merge_comparepnc.go → fullproject/src_back/merge_comparepnc.go


+ 0 - 0
fullproject/src/merge_select.go → fullproject/src_back/merge_select.go


+ 0 - 0
fullproject/src/project.go → fullproject/src_back/project.go


+ 0 - 0
fullproject/src/task.go → fullproject/src_back/task.go


+ 18 - 2
fullproject/src_v1/config.json

@@ -1,5 +1,5 @@
 {
-    "loadStart": 0,
+    "loadStart": 1,
 	"validdays":150,
     "statusdays": 15,
 	"mongodbServers": "192.168.3.207:27092",
@@ -15,7 +15,23 @@
         "to": "wangjianghan@topnet.net.cn",
         "api": "http://10.171.112.160:19281/_send/_mail"
     },
-    "udpport": "1182",
+    "es": {
+        "addr": "http://192.168.3.128:9800",
+        "index": "projectset_v3",
+        "itype": "projectset",
+        "pool": 10
+    },
+    "udpport": ":1482",
     "nextNode": [
+        {
+            "addr": "192.168.20.104",
+            "port": 1483,
+            "memo": "创建项目索引new"
+        },
+        {
+            "addr": "127.0.0.1",
+            "port": 14833,
+            "memo": "修改项目创建new"
+        }
     ]
 }

+ 1 - 1
fullproject/src_v1/init.go

@@ -302,7 +302,7 @@ type ProjectInfo struct {
 	score         int
 	comStr        string
 	resVal, pjVal int
-	InfoFiled     map[string]InfoField `json:"infofiled"`    //逻辑处理需要的info字段
+	InfoFiled     map[string]InfoField `json:"infofield"`    //逻辑处理需要的info字段
 	Budgettag     int                  `json:"budgettag"`    //预算是否有效标记
 	Bidamounttag  int                  `json:"bidamounttag"` //中标金额是否有效标记
 }

+ 51 - 6
fullproject/src_v1/main.go

@@ -8,6 +8,7 @@ import (
 	"os"
 	"os/signal"
 	"qfw/util"
+	"qfw/util/elastic"
 	"syscall"
 	"time"
 )
@@ -18,6 +19,9 @@ var (
 	SingleClear  = 0
 	toaddr       = []*net.UDPAddr{} //下节点对象
 	ChSign       = make(chan os.Signal)
+	Es 			 *elastic.Elastic
+	Index        string
+	Itype        string
 
 	sid, eid string //测试使用
 )
@@ -32,6 +36,15 @@ func init() {
 			Port: util.IntAll(m["port"]),
 		})
 	}
+
+	es := Sysconfig["es"].(map[string]interface{})
+	Es = &elastic.Elastic{
+		S_esurl: util.ObjToString(es["addr"]),
+		I_size:  util.IntAllDef(es["pool"], 10),
+	}
+	Index = util.ObjToString(es["index"])
+	Itype = util.ObjToString(es["itype"])
+	Es.InitElasticSize()
 }
 
 var queryClose = make(chan bool)
@@ -41,7 +54,7 @@ func DealSign() {
 	for {
 		select {
 		case sign := <-ChSign:
-			log.Println("receive:", sign)
+			//log.Println("receive:", sign)
 			if v, ok := sign.(syscall.Signal); ok && v == os.Interrupt {
 				log.Println("receice signal..,start close iter")
 				if P_QL.Brun {
@@ -58,7 +71,7 @@ func DealSign() {
 	}
 }
 
-func mainT() {
+func main() {
 	//udp跑增量  id段   project
 	//udp跑全量			qlT
 	//udp跑历史数据  信息id1,id2/或id段  ls
@@ -77,9 +90,9 @@ func mainT() {
 }
 
 //测试组人员使用
-func main() {
-	sid = "5c90370ca5cb26b9b72b3d0a"
-	eid = "5d3a88ffa5cb26b9b7755564"
+func mainT() {
+	sid = "56388138af53745d9a000001"
+	eid = "5b671f32a5cb26b9b76ddbb6"
 	//flag.StringVar(&sid, "sid", "", "开始id")
 	//flag.StringVar(&eid, "eid", "", "结束id")
 	//flag.Parse()
@@ -107,6 +120,28 @@ func main() {
 	time.Sleep(20 * time.Second)
 }
 
+func mainS() {
+	id := "5987e5e85d11e1c745d36c4c"
+	mapinfo := map[string]interface{}{}
+	mapinfo["id"] = id
+	mapinfo["stype"] = "updateMoney"
+	mapinfo["budget"] = "12345"
+	mapinfo["ip"] = "127.0.0.1"
+	mapinfo["port"] = Sysconfig["udpport"]
+	if Sysconfig["loadStart"] != nil {
+		loadStart := util.Int64All(Sysconfig["loadStart"])
+		if loadStart > -1 {
+			P_QL.loadData(loadStart)
+		}
+	}
+	P_QL.loadSite()
+	P_QL.currentType = mapinfo["stype"].(string)
+	P_QL.pici = time.Now().Unix()
+	P_QL.taskUpdateMoney(mapinfo)
+	P_QL.Brun = true
+	time.Sleep(20 * time.Second)
+}
+
 //udp调用信号
 func processUdpMsg(act byte, data []byte, ra *net.UDPAddr) {
 	switch act {
@@ -124,7 +159,6 @@ func processUdpMsg(act byte, data []byte, ra *net.UDPAddr) {
 			go udpclient.WriteUdp([]byte(key), mu.OP_NOOP, ra)
 			SingleThread <- true
 			tasktype, _ := mapInfo["stype"].(string)
-			log.Println("tasktype:", tasktype)
 			switch tasktype {
 			case "ql": //全量合并
 				go func() {
@@ -154,12 +188,23 @@ func processUdpMsg(act byte, data []byte, ra *net.UDPAddr) {
 					P_QL.pici = time.Now().Unix()
 					P_QL.taskUpdateInfo(mapInfo)
 				}()
+			case "updateMoney": //修改金额
+				go func() {
+					defer func() {
+						<-SingleThread
+					}()
+					P_QL.currentType = tasktype
+					P_QL.pici = time.Now().Unix()
+					P_QL.taskUpdateMoney(mapInfo)
+				}()
 			case "history": //历史数据合并,暂时不写
 				go func() {
 					defer func() {
 						<-SingleThread
 					}()
 				}()
+			default:
+				<-SingleThread
 			}
 		}
 	case mu.OP_NOOP: //下个节点回应

+ 16 - 14
fullproject/src_v1/project.go

@@ -567,7 +567,7 @@ func (p *ProjectTask) NewProject(tmp map[string]interface{}, thisinfo *Info) (st
 	}
 
 	p1.InfoFiled = make(map[string]InfoField)
-	infofiled := InfoField{
+	infofield := InfoField{
 		Budget:       thisinfo.Budget,
 		Bidamount:    thisinfo.Bidamount,
 		ContractCode: thisinfo.ContractCode,
@@ -575,8 +575,8 @@ func (p *ProjectTask) NewProject(tmp map[string]interface{}, thisinfo *Info) (st
 		ProjectCode:  thisinfo.ProjectCode,
 		Bidstatus:    bs,
 	}
-	p1.InfoFiled[thisinfo.Id] = infofiled
-	res := StructToMap(infofiled)
+	p1.InfoFiled[thisinfo.Id] = infofield
+	res := StructToMap(infofield)
 	set["infofield"] = map[string]interface{}{
 		thisinfo.Id: res,
 	}
@@ -680,7 +680,7 @@ func (p *ProjectTask) NewCachePinfo(id primitive.ObjectID, thisinfo *Info, bidty
 
 //更新项目
 func (p *ProjectTask) UpdateProject(tmp map[string]interface{}, thisinfo *Info, pInfo *ProjectInfo, weight int, comStr string, ex int) {
-	if p.currentType != "ql" && p.currentType != "updateInfo" {
+	if p.currentType != "updateInfo" {
 		if BinarySearch(pInfo.Ids, thisinfo.Id) > -1 {
 			log.Println("repeat", thisinfo.Id)
 			return
@@ -727,12 +727,12 @@ func (p *ProjectTask) UpdateProject(tmp map[string]interface{}, thisinfo *Info,
 			}
 		}
 	} else if thisinfo.SubType == "合同" {
-		if pInfo.Bidstatus == "中标" || pInfo.Bidstatus == "成交" {
+		if pInfo.Bidstatus == "中标" || pInfo.Bidstatus == "成交" || pInfo.Bidstatus == "" {
 			//中标、成交不更新jgtime
-			return
+		}else {
+			set["jgtime"] = tmp["publishtime"]
+			pInfo.Jgtime = thisinfo.Publishtime
 		}
-		set["jgtime"] = tmp["publishtime"]
-		pInfo.Jgtime = thisinfo.Publishtime
 	}
 	if thisinfo.Bidopentime > pInfo.Bidopentime {
 		pInfo.Bidopentime = thisinfo.Bidopentime
@@ -759,9 +759,11 @@ func (p *ProjectTask) UpdateProject(tmp map[string]interface{}, thisinfo *Info,
 		} else if thisinfo.Infoformat == 2 {
 			set["bidstatus"] = "拟建"
 			pInfo.Bidstatus = "拟建"
-		} else if bs == "" {
-			set["bidstatus"] = ""
-			pInfo.Bidstatus = ""
+		}else if bs == "" && bt == "结果" {
+			if pInfo.Bidstatus == "招标" {
+				set["bidstatus"] = ""
+				pInfo.Bidstatus = ""
+			}
 		} else {
 			set["bidstatus"] = "其它"
 			pInfo.Bidstatus = "其它"
@@ -900,7 +902,7 @@ func (p *ProjectTask) UpdateProject(tmp map[string]interface{}, thisinfo *Info,
 		set["sortprice"] = pInfo.Budget
 	}
 
-	infofiled := InfoField{
+	infofield := InfoField{
 		Budget:       thisinfo.Budget,
 		Bidamount:    thisinfo.Bidamount,
 		ContractCode: thisinfo.ContractCode,
@@ -909,12 +911,12 @@ func (p *ProjectTask) UpdateProject(tmp map[string]interface{}, thisinfo *Info,
 		Bidstatus:    bs,
 	}
 	copyMap := Copy(pInfo.InfoFiled).(map[string]InfoField)
-	copyMap[thisinfo.Id] = infofiled
+	copyMap[thisinfo.Id] = infofield
 	tmpMap := make(map[string]interface{})
 	for k, v := range copyMap {
 		tmpMap[k] = StructToMap(v)
 	}
-	tmpMap[thisinfo.Id] = StructToMap(infofiled)
+	tmpMap[thisinfo.Id] = StructToMap(infofield)
 	pInfo.InfoFiled = copyMap
 	set["infofield"] = tmpMap
 

+ 177 - 16
fullproject/src_v1/task.go

@@ -3,11 +3,12 @@ package main
 import (
 	"encoding/json"
 	"fmt"
+	"gopkg.in/mgo.v2/bson"
 	"log"
 	mu "mfw/util"
-
 	"qfw/util"
 	"regexp"
+	"strconv"
 	"strings"
 	"sync"
 	"time"
@@ -229,25 +230,12 @@ func (p *ProjectTask) clearMem() {
 		}
 	})
 	c.Start()
-	select {}
 }
 
 //全量合并
 func (p *ProjectTask) taskQl(udpInfo map[string]interface{}) {
 	defer util.Catch()
-	//1、检查pubilshtime索引
-	db, _ := udpInfo["db"].(string)
-	if db == "" {
-		db = MongoTool.DbName
-	}
-	coll, _ := udpInfo["coll"].(string)
-	if coll == "" {
-		coll = ExtractColl
-	}
-	thread := util.IntAllDef(Thread, 4)
-	if thread > 0 {
-		p.thread = thread
-	}
+	p.thread = util.IntAllDef(Thread, 4)
 	q, _ := udpInfo["query"].(map[string]interface{})
 	if q == nil {
 		q = map[string]interface{}{}
@@ -271,7 +259,7 @@ func (p *ProjectTask) taskQl(udpInfo map[string]interface{}) {
 	}
 	//生成查询语句执行
 	log.Println("查询语句:", q)
-	p.enter(db, coll, q)
+	p.enter(MongoTool.DbName, ExtractColl, q)
 
 }
 
@@ -351,6 +339,179 @@ func (p *ProjectTask) taskUpdateInfo(udpInfo map[string]interface{}) {
 	p.enter(db, coll, q)
 }
 
+//修改公告信息的预算/中标金额
+func (p *ProjectTask) taskUpdateMoney(udpInfo map[string]interface{}) {
+	defer util.Catch()
+	id := udpInfo["id"].(string)
+	budget := util.ObjToString(udpInfo["budget"])
+	bidamount := util.ObjToString(udpInfo["bidamount"])
+	if budget == "" && bidamount == "" {
+		util.Debug("")
+		return
+	}
+
+	client := Es.GetEsConn()
+	defer Es.DestoryEsConn(client)
+	esquery := `{"query": {"bool": {"must": [{"term": {"list.infoid": "`+id+`"}}]}}}`
+	data := Es.Get(Index, Itype, esquery)
+	util.Debug(*data)
+	if data != nil {
+		pid := util.ObjToString((*data)[0]["_id"])
+		pro := MongoTool.FindById(ProjectColl, pid)
+		var info *map[string]interface{}
+		for _, v := range []interface{}(pro["list"].(primitive.A)){
+			v1 := v.(map[string]interface{})
+			if util.ObjToString(v1["infoid"]) == id {
+				info = util.ObjToMap(v)
+				infoField := util.ObjToMap(pro["infofield"])
+				if budget != "" {
+					if budget != "del" {
+						newBudget, _ := strconv.ParseFloat(budget, 64)
+						if pro["budget"] == (*info)["budget"] {
+							pro["budget"] = newBudget
+						}
+						if util.IntAll(pro["multipackage"]) == 1 {
+							if packages, ok := pro["package"].(map[string]interface{}); ok {
+							M :
+									for _, v := range packages{
+										v1 := []interface{}(v.(primitive.A))
+										for _, v2 := range v1{
+											v3 := v2.(map[string]interface{})
+											if util.ObjToString(v3["infoid"]) == id {
+												if v3["budget"] != nil {
+													v3["budget"] = newBudget
+												}
+											}else {
+												break M
+											}
+										}
+									}
+							}
+						}
+						if pro["sortprice"] == (*info)["budget"] {
+							pro["sortprice"] = newBudget
+						}
+						(*info)["budget"] = newBudget
+						(*util.ObjToMap((*infoField)[id]))["budget"] = newBudget
+					}else {
+						delete(*info, "budget")
+						delete(*util.ObjToMap((*infoField)[id]), "budget")
+						if pro["budget"] == (*info)["budget"] {
+							money := FindMoney("budget", pro)
+							if money >= 0 {
+								pro["budget"] = money
+							}
+						}
+					}
+				}
+				if bidamount != "" {
+					if bidamount != "del" {
+						newBidamount, _ := strconv.ParseFloat(bidamount, 64)
+						if pro["bidamount"] == (*info)["bidamount"] {
+							pro["bidamount"] = newBidamount
+						}
+						if util.IntAll(pro["multipackage"]) == 1 {
+							if packages, ok := pro["package"].(map[string]interface{}); ok {
+							N :
+								for _, v := range packages{
+									v1 := []interface{}(v.(primitive.A))
+									for _, v2 := range v1{
+										v3 := v2.(map[string]interface{})
+										if util.ObjToString(v3["infoid"]) == id {
+											if v3["bidamount"] != nil {
+												v3["bidamount"] = newBidamount
+											}
+										}else {
+											break N
+										}
+									}
+								}
+							}
+						}
+						if pro["sortprice"] == (*info)["bidamount"] {
+							pro["sortprice"] = newBidamount
+						}
+						(*info)["bidamount"] = newBidamount
+						(*util.ObjToMap((*infoField)[id]))["bidamount"] = newBidamount
+					}else {
+						delete((*info), "bidamount")
+						delete((*util.ObjToMap((*infoField)[id])), "bidamount")
+						if pro["bidamount"] == (*info)["bidamount"] {
+							money := FindMoney("bidamount", pro)
+							if money >= 0 {
+								pro["bidamount"] = money
+							}
+						}
+					}
+				}
+				break
+			}
+		}
+		var project *ProjectInfo
+		var pInfo *Info
+		bys, _ := json.Marshal(pro)
+		_ = json.Unmarshal(bys, &project)
+		bys1, _ := json.Marshal(info)
+		_ = json.Unmarshal(bys1, &pInfo)
+		CountAmount(project, pInfo, *info)
+
+		if project.Budget > 0 {
+			util.Debug(project.Budget)
+			pro["budget"] = project.Budget
+			pro["budgettag"] = 0
+		}
+		if project.Bidamount > 0 {
+			util.Debug(project.Bidamount)
+			pro["bidamount"] = project.Bidamount
+			pro["bidamounttag"] = 0
+		}
+		set := map[string]interface{}{
+			"$set": pro,
+		}
+		MongoTool.UpdateById(ProjectColl, pid, set)
+
+		loadStart := util.Int64All(Sysconfig["loadStart"])
+		if loadStart > -1 && project.LastTime >loadStart {
+			util.Debug("内存中存在该项目信息", project.Id)
+			p.AllIdsMapLock.Lock()
+			p.AllIdsMap[pid].P = project
+			p.AllIdsMapLock.Unlock()
+		}
+
+		bol := Es.DelById(Index, Itype, pid)
+		if bol {
+			util.Debug("删除es索引, pid------", pid)
+			//调udp生索引
+			by, _ := json.Marshal(map[string]interface{}{
+				"query": map[string]interface{}{
+					"_id": bson.M{
+						"$gte": pid,
+						"$lte": pid,
+					}},
+				"stype": "project",
+			})
+			_ = udpclient.WriteUdp(by, mu.OP_TYPE_DATA, toaddr[1])
+		}
+	}
+}
+
+func FindMoney(key string, project map[string]interface{}) float64 {
+	money := -0.1
+	for i, v := range []interface{}(project["list"].(primitive.A)){
+		v1 := v.(map[string]interface{})
+		if i == 0 {
+			if v1[key] != nil {
+				money = util.Float64All(v1[key])
+			}
+		}else {
+			if v1[key] != nil && util.Float64All(v1[key]) > money {
+				money = util.Float64All(v1[key])
+			}
+		}
+	}
+	return money
+}
+
 func StringTOBsonId(id string) primitive.ObjectID {
 	objectId, _ := primitive.ObjectIDFromHex(id)
 	return objectId

+ 7 - 7
fullproject/src_v1/update.go

@@ -15,7 +15,7 @@ func (p *ProjectTask) modifyUpdate(pInfoId string, index int, info *Info, tmp ma
 	infoList := []interface{}(tmpPro["list"].(primitive.A))
 	infoMap := infoList[index].(map[string]interface{})
 	infoList[index] = updateValue(infoMap, modifyMap)
-	infofiled := InfoField{
+	infofield := InfoField{
 		Budget:       info.Budget,
 		Bidamount:    info.Bidamount,
 		ContractCode: info.ContractCode,
@@ -23,8 +23,8 @@ func (p *ProjectTask) modifyUpdate(pInfoId string, index int, info *Info, tmp ma
 		ProjectCode:  info.ProjectCode,
 		Bidstatus:    info.SubType,
 	}
-	mapTmp, _ := tmpPro["infofiled"].(map[string]interface{})
-	mapTmp[info.Id] = StructToMap(infofiled)
+	mapTmp, _ := tmpPro["infofield"].(map[string]interface{})
+	mapTmp[info.Id] = StructToMap(infofield)
 	set := map[string]interface{}{
 		"$set": tmpPro,
 	}
@@ -70,7 +70,7 @@ func (p *ProjectTask) mergeAndModify(pInfoId string, index int, info *Info, tmp
 				infoList := []interface{}(tmpPro["list"].(primitive.A))
 				infoMap := infoList[index].(map[string]interface{})
 				infoList[index] = updateValue(infoMap, modifyMap)
-				infofiled := InfoField{
+				infofield := InfoField{
 					Budget:       info.Budget,
 					Bidamount:    info.Bidamount,
 					ContractCode: info.ContractCode,
@@ -78,8 +78,8 @@ func (p *ProjectTask) mergeAndModify(pInfoId string, index int, info *Info, tmp
 					ProjectCode:  info.ProjectCode,
 					Bidstatus:    info.SubType,
 				}
-				mapTmp, _ := tmpPro["infofiled"].(map[string]interface{})
-				mapTmp[info.Id] = StructToMap(infofiled)
+				mapTmp, _ := tmpPro["infofield"].(map[string]interface{})
+				mapTmp[info.Id] = StructToMap(infofield)
 				set := map[string]interface{}{
 					"$set": tmpPro,
 				}
@@ -271,7 +271,7 @@ func (p *ProjectTask) innerMerge(pInfo *ProjectInfo, info *Info, tmp map[string]
 		}
 		mergeProject(p, pInfo, info, tmpPro, tmp)
 	}
-	mapTmp, _ := tmpPro["infofiled"].(map[string]interface{})
+	mapTmp, _ := tmpPro["infofield"].(map[string]interface{})
 	delete(mapTmp, info.Id)
 	set := map[string]interface{}{
 		"$set": tmpPro,

+ 52 - 0
fullproject/udp/src/main.go

@@ -0,0 +1,52 @@
+package main
+
+import (
+	"encoding/json"
+	"flag"
+	"log"
+	mu "mfw/util"
+	"net"
+	"os"
+	"time"
+)
+
+var ip, sid, eid, stype string
+var p int
+
+func main() {
+
+	flag.StringVar(&sid, "sid", "", "开始id")
+	flag.StringVar(&eid, "eid", "", "结束id")
+	flag.StringVar(&ip, "ip", "127.0.0.1", "ip")
+	flag.IntVar(&p, "p", 1482, "端口")
+	flag.StringVar(&stype, "stype", "", "stype")
+	flag.Parse()
+
+	if ip != "" && p > 0 && sid != "" && eid != "" {
+		addr := &net.UDPAddr{
+			IP:   net.ParseIP(ip),
+			Port: p,
+		}
+		udp := mu.UdpClient{Local: ":50010", BufSize: 1024}
+		udp.Listen(func(b byte, data []byte, add *net.UDPAddr) {
+			switch b {
+			case mu.OP_NOOP:
+				log.Println(string(data))
+				os.Exit(0)
+			}
+		})
+		m1 := map[string]interface{}{
+			"gtid":  sid,
+			"lteid": eid,
+			"stype": stype,
+		}
+
+		by, _ := json.Marshal(m1)
+		log.Println(string(by))
+		udp.WriteUdp(by, mu.OP_TYPE_DATA, addr)
+		time.Sleep(30 * time.Second)
+	} else {
+		flag.PrintDefaults()
+		log.Println("参数错误.")
+	}
+}