Kaynağa Gözat

Merge branch 'dev3.2' of http://192.168.3.207:10080/qmx/jy-data-extract into dev3.2

wangji 6 yıl önce
ebeveyn
işleme
f881082fab

+ 2 - 2
src/jy/extract/exportask.go

@@ -66,9 +66,9 @@ func extractAndExport(v string, t map[string]interface{}) {
 		if qu.ObjToString(v["sensitive"]) != "" { //去除含敏感词数据
 			continue
 		}
-		j := PreInfo(v)
+		j, jf := PreInfo(v, false)
 		e.TaskInfo.ProcessPool <- true
-		go e.ExtractProcess(j)
+		go e.ExtractProcess(j, jf)
 	}
 }
 

+ 27 - 10
src/jy/extract/extract.go

@@ -78,9 +78,9 @@ func RunExtractTestTask(ext *ExtractTask, startId, num string) bool {
 				continue
 			}
 			//log.Println(v["_id"])
-			j := PreInfo(v)
+			j, jf := PreInfo(v, false)
 			ext.TaskInfo.ProcessPool <- true
-			go ext.ExtractProcess(j)
+			go ext.ExtractProcess(j, jf)
 		}
 		return true
 	} else {
@@ -171,9 +171,9 @@ func RunExtractTask(taskId string) {
 			if !ext.IsRun {
 				break
 			}
-			j := PreInfo(v)
+			j, jf := PreInfo(v, false)
 			ext.TaskInfo.ProcessPool <- true
-			go ext.ExtractProcess(j)
+			go ext.ExtractProcess(j, jf)
 			ext.TaskInfo.LastExtId = _id
 		}
 		db.Mgo.UpdateById("task", ext.Id, `{"$set":{"s_extlastid":"`+ext.TaskInfo.LastExtId+`"}}`)
@@ -186,7 +186,7 @@ func RunExtractTask(taskId string) {
 }
 
 //信息预处理
-func PreInfo(doc map[string]interface{}) *ju.Job {
+func PreInfo(doc map[string]interface{}, isextFile bool) (j, jf *ju.Job) {
 	defer qu.Catch()
 	detail := ""
 	d1, _ := doc["detail"].(string)
@@ -199,6 +199,7 @@ func PreInfo(doc map[string]interface{}) *ju.Job {
 	detail = ju.CutLableStr(detail)
 	detail = cut.ClearHtml(detail)
 	doc["detail"] = detail
+	doc["detailfile"] = "" //附件文本堆一起(后期可以考虑,分开处理)
 	toptype := qu.ObjToString(doc["toptype"])
 	if qu.ObjToString(doc["type"]) == "bid" {
 		toptype = "结果"
@@ -206,7 +207,7 @@ func PreInfo(doc map[string]interface{}) *ju.Job {
 	if toptype == "" {
 		toptype = "*"
 	}
-	j := &ju.Job{
+	j = &ju.Job{
 		SourceMid:  qu.BsonIdToSId(doc["_id"]),
 		Category:   toptype,
 		Content:    qu.ObjToString(doc["detail"]),
@@ -220,17 +221,33 @@ func PreInfo(doc map[string]interface{}) *ju.Job {
 		Result:    map[string][]*ju.ExtField{},
 		BuyerAddr: qu.ObjToString(doc["buyeraddr"]),
 	}
+	if isextFile {
+		jf = &ju.Job{
+			SourceMid:  qu.BsonIdToSId(doc["_id"]),
+			Category:   toptype,
+			Content:    qu.ObjToString(doc["detailfile"]),
+			SpiderCode: qu.ObjToString(doc["spidercode"]),
+			Title:      qu.ObjToString(doc["title"]),
+			Data:       &doc,
+			City:       qu.ObjToString(doc["city"]),
+			Province:   qu.ObjToString(doc["area"]),
+			Result:     map[string][]*ju.ExtField{},
+			BuyerAddr:  qu.ObjToString(doc["buyeraddr"]),
+		}
+	}
 	qu.Try(func() {
-
 		pretreated.AnalyStart(j)
+		if isextFile {
+			pretreated.AnalyStart(jf)
+		}
 	}, func(err interface{}) {
 		log.Println("pretreated.AnalyStart", err)
 	})
-	return j
+	return j, jf
 }
 
 //抽取
-func (e *ExtractTask) ExtractProcess(j *ju.Job) {
+func (e *ExtractTask) ExtractProcess(j, jf *ju.Job) {
 	qu.Try(func() {
 		doc := *j.Data
 		//全局前置规则,结果覆盖doc属性
@@ -885,7 +902,7 @@ func AnalysisSaveResult(j *ju.Job, e *ExtractTask) {
 				"haskey":   j.HasKey,
 			}
 			if len(j.BrandData) > 0 {
-				tmp["brand"] = j.BrandData
+				tmp["tablebrand"] = j.BrandData
 			}
 			//log.Println("============", j.HasBrand, j.HasGoods, j.HasKey, j.HasTable, j.BrandData)
 		}

+ 6 - 6
src/jy/extract/extractudp.go

@@ -145,9 +145,9 @@ func ExtractByUdp(sid, eid string, instanceId ...string) {
 					}
 					_id := qu.BsonIdToSId(v["_id"])
 					log.Println(_id)
-					j := PreInfo(v)
+					j, jf := PreInfo(v, false)
 					ext.TaskInfo.ProcessPool <- true
-					go ext.ExtractProcess(j)
+					go ext.ExtractProcess(j, jf)
 					sid = _id
 				}
 				db.Mgo.Update("ecs", `{"InstanceId":"`+instanceId[0]+`"}`,
@@ -165,9 +165,9 @@ func ExtractByUdp(sid, eid string, instanceId ...string) {
 					}
 					_id := qu.BsonIdToSId(v["_id"])
 					log.Println(_id)
-					j := PreInfo(v)
+					j, jf := PreInfo(v, false)
 					ext.TaskInfo.ProcessPool <- true
-					go ext.ExtractProcess(j)
+					go ext.ExtractProcess(j, jf)
 					sidback = _id
 				}
 				db.Mgo.Update("ecs", `{"InstanceId":"`+instanceId[0]+`"}`,
@@ -199,9 +199,9 @@ func ExtractByUdp(sid, eid string, instanceId ...string) {
 				}
 				_id := qu.BsonIdToSId(v["_id"])
 				log.Println(_id)
-				j := PreInfo(v)
+				j, jf := PreInfo(v, false)
 				ext.TaskInfo.ProcessPool <- true
-				go ext.ExtractProcess(j)
+				go ext.ExtractProcess(j, jf)
 				sid = _id
 			}
 

+ 59 - 326
src/jy/pretreated/analytable.go

@@ -2686,37 +2686,39 @@ func (table *Table) analyBrand() {
 					"商品":["",""],
 					"商品_"["",""],
 				}
-
 			*/
-			valArr, f := filterval(realTypeVal...) //过滤数据
-			if f {
+			valArr, allempty := filterVal(realTypeVal...) //过滤数据
+			if allempty {
 				continue
 			}
 			realTypeVal = valArr
 			line := underline.FindString(key)
 			lineValMap1 := lineMapArr[line]
-			i := 1
-		L:
-			for { //去除数组空数据
-				last := realTypeVal[len(realTypeVal)-i]
-				if last == "" {
-					i++
-					if i > len(realTypeVal) {
-						break
-					}
-					goto L
+			//			i := 1
+			//		L:
+			//			for { //去除数组空数据
+			//				last := realTypeVal[len(realTypeVal)-i]
+			//				if last == "" {
+			//					i++
+			//					if i > len(realTypeVal) {
+			//						break
+			//					}
+			//					goto L
+			//				} else {
+			//					break
+			//				}
+			//			}
+			//			dislodgeNull := realTypeVal[:(len(realTypeVal) - i + 1)] //去除数组中空数据
+			if len(realTypeVal) > 0 {
+				if lineValMap1 == nil {
+					tmp := NewSortMap()
+					tmp.AddKey(key, realTypeVal)
+					lineMapArr[line] = tmp
 				} else {
-					break
+					lineValMap1.AddKey(key, realTypeVal)
 				}
 			}
-			dislodgeNull := realTypeVal[:(len(realTypeVal) - i + 1)] //去除数组中空数据
-			if lineValMap1 == nil && len(realTypeVal) != 0 {
-				tmp := NewSortMap()
-				tmp.AddKey(key, dislodgeNull)
-				lineMapArr[line] = tmp
-			} else {
-				lineValMap1.AddKey(key, dislodgeNull)
-			}
+
 			//qutil.Debug("lineMapArr---", lineMapArr[line].Keys, lineMapArr[line].Map)
 		} else if realTypeVal, b := val.(string); b { //val为字符串 {"数量":"1"}
 			/*
@@ -2726,19 +2728,19 @@ func (table *Table) analyBrand() {
 					"商品__:"",名称__:"",
 				}
 			*/
-			valArr, f := filterval(realTypeVal) //过滤数据
-			if f {
+			valArr, allempty := filterVal(realTypeVal) //过滤数据
+			if allempty {
 				continue
 			}
 			realTypeVal = valArr[0]
 			line := underline.FindString(key)
-			lineValMap1 := lineMap[line]
-			if lineValMap1 == nil {
+			lineValMap2 := lineMap[line]
+			if lineValMap2 == nil {
 				tmp := NewSortMap()
 				tmp.AddKey(key, realTypeVal)
 				lineMap[line] = tmp
 			} else {
-				lineValMap1.AddKey(key, realTypeVal)
+				lineValMap2.AddKey(key, realTypeVal)
 			}
 			//qutil.Debug("lineMap---", lineMap[line].Keys, lineMap[line].Map)
 		} else {
@@ -2770,7 +2772,7 @@ func (table *Table) analyBrand() {
 						if nameM == "itemname" || nameM == "modal" {
 							hasGoods(table, v0...) //判断itemname和modal中有没有商品
 							if nameM == "itemname" {
-								v0tmp1 = filteritem(v0...) //过滤itemname
+								v0tmp1 = filterItem(v0...) //过滤itemname
 							}
 						}
 						if nameM == "brandname" || nameM == "modal" {
@@ -2876,7 +2878,7 @@ func (table *Table) analyBrand() {
 						if nameM == "itemname" || nameM == "modal" { //特殊处理itemname
 							hasGoods(table, v1)
 							if nameM == "itemname" {
-								v1tmp1 = filteritem(v1)[0] //过滤itemname
+								v1tmp1 = filterItem(v1)[0] //过滤itemname
 								if v1tmp1 == "" {
 									break
 								}
@@ -3005,11 +3007,9 @@ func assembleData(m interface{}, n int) []map[string]string {
 						data[k4] = v4[i]
 					} else {
 						delete(data, k4)
-						//continue
 					}
 				} else {
 					fmt.Println("err table")
-					//continue
 				}
 			}
 			datas[i] = data
@@ -3101,7 +3101,7 @@ func convert(key, r string) bool {
 	reg, err := regexp.Compile(r)
 	if err != nil {
 		fmt.Println("reg err:", err)
-		return flag
+		return false
 	}
 	flag = reg.MatchString(key)
 	return flag
@@ -3136,6 +3136,24 @@ func hasGoods(table *Table, data ...string) {
 		}
 	}
 }
+
+//func hasBrand(table *Table, data ...string) {
+//	defer qutil.Catch()
+//	if table.TableResult.HasBrand == 1 {
+//		return
+//	}
+//	for i, d := range data {
+//		if d != "" {
+//			brand := u.BrandGet.CheckSensitiveWord(d)
+//			qutil.Debug(d, brand)
+//			if brand != "" {
+//				table.TableResult.HasBrand = 1
+//				break
+//			}
+//		}
+//	}
+//}
+
 func hasBrand(table *Table, data ...string) ([]string, bool) {
 	defer qutil.Catch()
 	//fmt.Println("table.TableResult.HasBrand---------", table.TableResult.HasBrand)
@@ -3161,24 +3179,26 @@ func hasBrand(table *Table, data ...string) ([]string, bool) {
 }
 
 //过滤td值
-func filterval(val ...string) ([]string, bool) {
+func filterVal(val ...string) ([]string, bool) {
 	defer qutil.Catch()
-	flag := false
+	n := 0 //记录被过滤的个数
 	for i, v := range val {
 		afterFilter := tabletdclear.ReplaceAllString(v, "")
 		afterFilter = NullVal.ReplaceAllString(afterFilter, "")
 		if afterFilter == "" {
-			flag = true
-		} else {
-			flag = false
+			n++
 		}
 		val[i] = afterFilter
 	}
-	return val, flag
+	allempty := false
+	if n == len(val) { //所有都被过滤掉
+		allempty = true
+	}
+	return val, allempty
 }
 
 //过滤itemname全是数字
-func filteritem(itemval ...string) []string {
+func filterItem(itemval ...string) []string {
 	defer qutil.Catch()
 	result := []string{}
 	for _, v := range itemval {
@@ -3227,290 +3247,3 @@ func dealNumber(val ...string) ([]string, []string) {
 	}
 	return result, unitnameArr
 }
-
-//func (table *Table) analyBrand() {
-//	//5c2d8c05a5cb26b9b782572b
-//	//产品名称 品牌 规格 单价 单位 数量  小计 质保期
-//	lineMap := make(map[string]map[string]string)
-//	lineMapArr := make(map[string]map[string][]string)
-//	brandRule := u.BrandRules
-//	//将val为数组和string的分开
-//	//qutil.Debug("table.SortKV.Map====", table.SortKV.Map)
-//	for key, val := range table.SortKV.Map {
-//		key = regReplAllSpace.ReplaceAllString(key, "")
-//		key = strings.Replace(key, "", "", -1)    //处理一个特殊的采购量 经上层处理空格后未处理掉
-//		if realTypeVal, ok := val.([]string); ok { //val为数组 {"数量":["1","2","3"]}
-//			/*
-//				{
-//					"商品":["",""],
-//					"商品_"["",""],
-//				}
-
-//			*/
-//			//			valArr, f := filterval(realTypeVal...)
-//			//			if f {
-//			//				qutil.Debug("----", key, valArr)
-//			//				continue
-//			//			}
-//			//			realTypeVal = valArr
-//			//hasGoods1(table, realTypeVal) //判断val中是否含产品
-//			//hasBrand1(table, realTypeVal) //判断val中是否含品牌
-//			line := underline.FindString(key)
-//			lineValMap := lineMapArr[line]
-//			//qutil.Debug("----", key, line, lineValMap)
-//			i := 1
-//		L:
-//			for { //去除数组空数据
-//				last := realTypeVal[len(realTypeVal)-i]
-//				if last == "" {
-//					i++
-//					if i > len(realTypeVal) {
-//						break
-//					}
-//					goto L
-//				} else {
-//					break
-//				}
-//			}
-//			dislodgeNull := realTypeVal[:(len(realTypeVal) - i + 1)] //去除数组中空数据
-//			if len(lineValMap) == 0 && len(realTypeVal) != 0 {       //没有数据
-//				lineMapArr[line] = map[string][]string{key: dislodgeNull}
-//			} else { //新增数据
-//				if len(dislodgeNull) != 0 {
-//					lineValMap[key] = dislodgeNull
-//				}
-//			}
-//			//qutil.Debug("lineMapArr---", lineMapArr)
-//		} else if realTypeVal, b := val.(string); b { //val为字符串 {"数量":"1"}
-//			/*
-//				{
-//					"商品:"",名称:"",
-//					"商品_:"",名称_:"",
-//					"商品__:"",名称__:"",
-//				}
-//			*/
-//			//			valArr, f := filterval(realTypeVal)
-//			//			if f {
-//			//				continue
-//			//			}
-//			//			realTypeVal = valArr[0]
-//			//hasGoods1(table, realTypeVal) //判断val中是否含产品
-//			//hasBrand1(table, realTypeVal) //判断val中是否含品牌
-//			line := underline.FindString(key)
-//			lineValMap := lineMap[line]
-//			if len(lineValMap) == 0 { //没有数据
-//				lineMap[line] = map[string]string{key: realTypeVal}
-//			} else {
-//				lineValMap[key] = realTypeVal
-//			}
-//		} else {
-//			// "_id" : ObjectId("5c2c3802a5cb26b9b78646c4")
-//			//成交供应商排名 [map[entname:昆明合优科技有限公司 sortstr:第一中标候选人 sort:1] map[sort:2 entname:昆明厚起科技有限公司 sortstr:第二中标候选人] map[entname:云南远安科技发展有限公司 sortstr:第三中标候选人 sort:3]]
-//			//fmt.Println("err data:", key, val)
-//		}
-//	}
-
-//	//处理数组数据后,匹配必须title和替换要保存的title
-//	if len(lineMapArr) > 0 {
-//		for _, aMap := range lineMapArr {
-//			maxNum := 0
-//			arrcount1 := 0 //记录key是否存在必须title(数组数据)
-//			arrcount2 := 0
-//			ka := make(map[string][]string) //最终存储数据
-//			//fmt.Println("++++++++++++", aMap)
-//			for k0, v0 := range aMap {
-//				//qutil.Debug("k0:", k0, "v0:", v0, len(v0))
-//				//匹配必须title
-//				for nameM, r := range brandRule["must"] {
-//					if convert(k0, r) { //匹配成功
-//						if len(ka[nameM]) != 0 && strings.Contains(k0, "描述") { //防止k0匹配到多次 和特殊情况 物料名称 物料描述同时出现
-//							continue
-//						}
-//						if nameM == "itemname" || nameM == "modal" {
-//							if nameM == "itemname" {
-//								varr, f := filteritem(v0...) //过滤品目
-//								if f {
-//									break
-//								}
-//								v0 = varr
-//							}
-//							hasGoods(table, v0...) //判断itemname和modal中有没有商品
-//						}
-//						if nameM == "brandname" || nameM == "modal" {
-//							//qutil.Debug(nameM, "++++++", len(ka["brandname"]), len(v0))
-//							if len(ka["brandname"]) == 0 {
-//								brand, allNull := hasBrand(table, v0...)
-//								//qutil.Debug(len(brand), "-------", nameM, brand)
-//								if !allNull {
-//									ka["brandname"] = brand
-//								}
-//								//qutil.Debug("brandname====", len(ka["brandname"]), ka["brandname"])
-//							}
-//						}
-//						if nameM != "brandname" {
-//							ka[nameM] = v0
-//						}
-//						arrcount1++
-//					}
-//				}
-//				//替换其它要保存字段
-//				for nameR, r := range brandRule["replace"] {
-//					if convert(k0, r) { //匹配成功
-//						ka[nameR] = v0
-//						arrcount2++
-//					}
-//				}
-//			}
-//			//找最终存储数据的最小len(arr)
-//			//			for _, vf := range ka {
-//			//				//找最短的数组
-//			//				lenVal := len(vf)
-//			//				if minNum == 0 || minNum > lenVal { //maxNum = len(最短数组)
-//			//					minNum = lenVal
-//			//				}
-//			//			}
-//			//找最终存储数据的最大len(arr),小的补空
-//			//fmt.Println("ka==============", ka)
-//			for _, vf1 := range ka {
-//				lenVal := len(vf1)
-//				if lenVal > maxNum {
-//					maxNum = lenVal
-//				}
-//			}
-//			finishKa := make(map[string][]string)
-//			for vf2K, vf2 := range ka {
-//				if len(vf2) < maxNum {
-//					lenMv := maxNum - len(vf2)
-//					for i := 0; i < lenMv; i++ {
-//						vf2 = append(vf2, "")
-//					}
-//				}
-//				finishKa[vf2K] = vf2
-//			}
-//			hasKey(table, arrcount1) //是否匹配到table中的标题
-//			if arrcount1 >= 1 {
-//				if arrcount1+arrcount2 == 1 { //删除只匹配到一个价钱(总价)
-//					delete(finishKa, "unitprice")
-//				}
-//				finishData := dealArrData(maxNum, finishKa)
-//				table.BrandData = append(table.BrandData, finishData)
-//			}
-//		}
-//	}
-//	//处理string数据后,匹配必须title和替换要保存的title
-//	if len(lineMap) > 0 {
-//		for _, sMap := range lineMap {
-//			strcount1 := 0 //记录key是否存在必须title(字符串数据)
-//			strcount2 := 0
-//			endStrMap := make(map[string]string)
-//			for k1, v1 := range sMap {
-//				//qutil.Debug(k1, "++++++++++", v1)
-//				//匹配必须title
-//				for nameM, r := range brandRule["must"] {
-//					if convert(k1, r) { //匹配成功
-//						if nameM == "itemname" || nameM == "modal" { //特殊处理itemname
-//							if nameM == "itemname" {
-//								varr, f := filteritem(v1) //过滤品目
-//								if f {
-//									break
-//								}
-//								v1 = varr[0]
-//							}
-//							hasGoods(table, v1)
-//						}
-//						if nameM == "brandname" || nameM == "modal" { //特殊处理brandname
-//							if len(endStrMap["brandname"]) == 0 {
-//								brand, allNull := hasBrand(table, v1)
-//								if !allNull {
-//									endStrMap["brandname"] = brand[0]
-//								}
-//							}
-//						}
-//						if nameM != "brandname" {
-//							endStrMap[nameM] = v1
-//						}
-//						strcount1++
-//					}
-//				}
-//				//替换其它要保存字段
-//				for nameR, r := range brandRule["replace"] {
-//					if convert(k1, r) { //匹配成功
-//						endStrMap[nameR] = v1
-//						strcount2++
-//					}
-//				}
-//			}
-//			//原始字符串数据处理
-//			hasKey(table, strcount1) //是否匹配到table中的标题
-//			if strcount1 >= 1 {
-//				if strcount1+strcount2 == 1 { //删除只匹配到一个价钱(总价)
-//					delete(endStrMap, "unitprice")
-//				}
-//				finishData := dealStrData(endStrMap) //处理数据
-//				if len(finishData) > 0 {
-//					table.BrandData = append(table.BrandData, finishData)
-//				}
-//			}
-//		}
-//	}
-//}
-
-////是否有商品
-//func hasGoods1(table *Table, data interface{}) {
-//	if table.TableResult.HasGoods == 1 {
-//		return
-//	}
-//	sData, ok := data.(string)
-//	proFlag := ""
-//	if ok { //string数据检查goods
-//		if sData != "" {
-//			proFlag = u.GoodsGet.CheckSensitiveWord(sData)
-//			if len(proFlag) > 0 {
-//				table.TableResult.HasGoods = 1
-//			}
-//		}
-//	} else { //arr数据检查goods
-//		arrData := data.([]string)
-//		if len(arrData) > 0 {
-//			for _, src := range arrData {
-//				if src != "" {
-//					proFlag = u.GoodsGet.CheckSensitiveWord(src)
-//					if len(proFlag) > 0 {
-//						table.TableResult.HasGoods = 1
-//						break
-//					}
-//				}
-//			}
-//		}
-//	}
-//}
-
-////是否有品牌
-//func hasBrand1(table *Table, data interface{}) {
-//	if table.TableResult.HasBrand == 1 {
-//		return
-//	}
-//	sData, ok := data.(string)
-//	if ok { //string数据检查brand
-//		if sData != "" {
-//			brand := u.BrandGet.CheckSensitiveWord(sData)
-//			if len(brand) > 0 {
-//				fmt.Println("brand:", brand, sData)
-//				table.TableResult.HasBrand = 1
-//			}
-//		}
-//	} else { //arr数据检查brand
-//		arrData := data.([]string)
-//		if len(arrData) > 0 {
-//			for _, src := range arrData {
-//				if src != "" {
-//					brand := u.BrandGet.CheckSensitiveWord(src)
-//					if len(brand) > 0 {
-//						table.TableResult.HasBrand = 1
-//						break
-//					}
-//				}
-//			}
-//		}
-//	}
-//}

+ 2 - 2
src/res/brandrule.json

@@ -1,6 +1,6 @@
 {
 	"must":{
-		"itemname":"((^(货物|品目|产品|标项|商品|物资|印刷品|物料|材料|设备|成交标(的)?)(名称|种类|内容|服务)+|服务产品|(采购|机械)(目录|设备)|^(品名|品目)$)和?)+",
+		"itemname":"(^(货物|品目|产品|标项|商品|物资|印刷品|物料|材料|设备)(名称|种类|内容|服务)?|服务产品|(采购|机械)(目录|设备))+",
 		"brandname":"^(品牌(名称)?|厂家)",
 		"modal":"^(规格)?(型号|参数)|规格$|技术规格", 
 		"unitprice":"单价|^价格|(预算|采购预算)(金额)?$|(单个商品|包件)最高限价|(中标成交|单次服务|控制)+金额|^金额$"
@@ -8,7 +8,7 @@
 	"replace":{	
 		"unitname":"(产品|计量|数量)单位|^单位",
 		"number":"(采购|需求|预估)(数)?量|^数量|服务次数",
-		"totalprice":"小计|总价|预算总价|合计|报价总金额",
+		"totalprice":"小计|(报价|预算)?总(价|金额)|合计",
 		"guaranteetime":"(免费)?质保期|服务期(限)?|服务时间"
 	}	
 }

+ 16 - 8
udps/main.go

@@ -15,29 +15,37 @@ import (
 var udpclient mu.UdpClient //udp对象
 var nextNodes []map[string]interface{}
 
-var startDate, endDate, ip, port, stype string
+var startDate, endDate, ip, port, stype, sid, eid string
 
 func main() {
 	//2015-11-03,2017-04-01
 	//2017-04-01,2017-06-01
 	//2017-06-01,2018-06-01
 	//2018-06-01,2019-02-20
+	flag.StringVar(&sid, "sid", "", "开始id")
+	flag.StringVar(&eid, "eid", "", "结束id")
 	flag.StringVar(&startDate, "start", "", "开始日期2006-01-02")
 	flag.StringVar(&endDate, "end", "", "结束日期2006-01-02")
 	flag.StringVar(&ip, "ip", "127.0.0.1", "ip")
 	flag.StringVar(&port, "port", "", "dup端口")
 	flag.StringVar(&stype, "stype", "", "stype")
 	flag.Parse()
-	log.Println(startDate, endDate, ip, port, stype)
-	start, _ := time.ParseInLocation(qu.Date_Short_Layout, startDate, time.Local)
-	end, _ := time.ParseInLocation(qu.Date_Short_Layout, endDate, time.Local)
-	sid := bson.NewObjectIdWithTime(start)
-	eid := bson.NewObjectIdWithTime(end)
+	var startid, endid bson.ObjectId
+	if sid != "" && eid != "" {
+		startid = qu.StringTOBsonId(sid)
+		endid = qu.StringTOBsonId(eid)
+	} else {
+		start, _ := time.ParseInLocation(qu.Date_Short_Layout, startDate, time.Local)
+		end, _ := time.ParseInLocation(qu.Date_Short_Layout, endDate, time.Local)
+		startid = bson.NewObjectIdWithTime(start)
+		endid = bson.NewObjectIdWithTime(end)
+	}
+	log.Println(startid, startid, ip, port, stype)
 	udpclient = mu.UdpClient{Local: ":1470", BufSize: 1024}
 	udpclient.Listen(processUdpMsg)
 	by, _ := json.Marshal(map[string]interface{}{
-		"gtid":  sid,
-		"lteid": eid,
+		"gtid":  startid,
+		"lteid": endid,
 		"stype": stype,
 	})
 	udpclient.WriteUdp(by, mu.OP_TYPE_DATA, &net.UDPAddr{