Kaynağa Gözat

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

zhangjinkun 5 yıl önce
ebeveyn
işleme
4b85dd5479

+ 2 - 2
fullproject/src_v1/merge_comparepnc.go

@@ -39,8 +39,8 @@ func comparePNC(info *Info, compareProject *ProjectInfo) (compareStr string, sco
 					if buyer != "" {
 						v = strings.Replace(v, buyer, "", -1)
 					}
-					v1 := CosineSimilar(pn, v)
-					if retv == 2 || v1 > 0.81 {
+					//v1 := CosineSimilar(pn, v)
+					if retv == 2 {
 						templen = len([]rune(v))
 						ifind = 2
 					} else if ifind == 0 {

+ 2 - 2
fullproject/src_v1/project.go

@@ -292,8 +292,8 @@ func (p *ProjectTask) compareBCTABB(info *Info, cp *ProjectInfo, diffTime int64,
 			compareBuyer = "A"
 			score += 3
 		} else {
-			v1 := CosineSimilar(info.Buyer, cp.Buyer)
-			if v == 2 || v1 > 0.8 {
+			//v1 := CosineSimilar(info.Buyer, cp.Buyer)
+			if v == 2 {
 				compareBuyer = "B"
 				score += 1
 			} else {

+ 21 - 20
src/jy/admin/resulttrack.go

@@ -97,26 +97,27 @@ func ClearColl(c *gin.Context) {
 
 //根据版本查询启用的字段
 func GetVersionInfo(c *gin.Context) {
-	version, _ := c.GetPostForm("version")
-	v, _ := Mgo.FindOne("version", `{"version":"`+version+`","delete":false}`)
-	if v != nil && len(*v) > 0 {
-		vid := (*v)["_id"].(bson.ObjectId).Hex()
-		query := map[string]interface{}{
-			"vid":    vid,
-			"isuse":  true,
-			"delete": false,
-		}
-		versioninfo, _ := Mgo.Find("versioninfo", query, nil, `{"s_field":1}`, false, -1, -1)
-		if len(*versioninfo) > 0 {
-			for _, val := range *versioninfo {
-				s_field := val["s_field"].(string)
-				f, _ := Mgo.FindOne("fields", `{"s_field":"`+s_field+`"}`)
-				val["s_name"] = (*f)["s_name"]
-			}
-		}
+	//version, _ := c.GetPostForm("version")
+	//v, _ := Mgo.FindOne("version", `{"version":"`+version+`","delete":false}`)
+	versioninfo,_ := Mgo.Find("fields",bson.M{},nil,nil,false,-1,-1)
+	//if v != nil && len(*v) > 0 {
+		//vid := (*v)["_id"].(bson.ObjectId).Hex()
+		//query := map[string]interface{}{
+		//	"vid":    vid,
+		//	"isuse":  true,
+		//	"delete": false,
+		//}
+		//versioninfo, _ := Mgo.Find("versioninfo", query, nil, `{"s_field":1}`, false, -1, -1)
+		//if len(*versioninfo) > 0 {
+		//	for _, val := range *v {
+		//		s_field := val["s_field"].(string)
+		//		f, _ := Mgo.FindOne("fields", `{"s_field":"`+s_field+`"}`)
+		//		val["s_name"] = (*f)["s_name"]
+		//	}
+		//}
 		c.JSON(200, gin.H{"versioninfo": versioninfo})
-	} else {
-		c.JSON(200, gin.H{"versioninfo": map[string]interface{}{}})
-	}
+	//} else {
+	//	c.JSON(200, gin.H{"versioninfo": map[string]interface{}{}})
+	//}
 
 }

+ 16 - 1
src/jy/admin/site_management.go

@@ -83,7 +83,21 @@ func init() {
 		if _id == "" || !bson.IsObjectIdHex(_id) {
 			c.JSON(400, gin.H{"rep": false})
 		} else {
+			vstmp,_:=Mgo.FindById("site_management",_id,bson.M{"vid":1})
 			Mgo.Del("site_management", bson.M{"_id": bson.ObjectIdHex(_id)})
+			vinfotmp,_:=Mgo.FindOne("site_versioninfo",bson.M{"pid": _id,"vid":util.ObjToString((*vstmp)["vid"])})
+			if len(*vinfotmp) > 0 {
+				go Mgo.Del("site_rule_code", bson.M{"pid": (*vinfotmp)["_id"].(bson.ObjectId).Hex(),"vid":util.ObjToString((*vstmp)["vid"])})
+				go Mgo.Del("site_rule_logic", bson.M{"pid": (*vinfotmp)["_id"].(bson.ObjectId).Hex(),"vid":util.ObjToString((*vstmp)["vid"])})
+				go Mgo.Del("site_rule_logicback", bson.M{"pid": (*vinfotmp)["_id"].(bson.ObjectId).Hex(),"vid":util.ObjToString((*vstmp)["vid"])})
+				go Mgo.Del("site_rule_logicore", bson.M{"pid": (*vinfotmp)["_id"].(bson.ObjectId).Hex(),"vid":util.ObjToString((*vstmp)["vid"])})
+				go Mgo.Del("site_rule_logicpre", bson.M{"pid": (*vinfotmp)["_id"].(bson.ObjectId).Hex(),"vid":util.ObjToString((*vstmp)["vid"])})
+			}
+			go Mgo.Del("site_versioninfo", bson.M{"pid": _id,"vid":util.ObjToString((*vstmp)["vid"])})
+			go Mgo.Del("site_cleanup", bson.M{"pid": _id,"vid":util.ObjToString((*vstmp)["vid"])})
+			go Mgo.Del("site_rule_back", bson.M{"pid": _id,"vid":util.ObjToString((*vstmp)["vid"])})
+			go Mgo.Del("site_tag", bson.M{"pid": _id,"vid":util.ObjToString((*vstmp)["vid"])})
+			go Mgo.Del("site_tagdetailinfo", bson.M{"pid": _id,"vid":util.ObjToString((*vstmp)["vid"])})
 			c.JSON(200, gin.H{"rep": true})
 		}
 	})
@@ -120,7 +134,8 @@ func init() {
 		} else {
 			s_field, _ := c.GetPostForm("s_field")
 			vid, _ := c.GetPostForm("vid")
-			tmp, _ := Mgo.FindOne("site_versioninfo", `{"s_field":"`+s_field+`","vid":"`+vid+`","delete":false}`)
+			pid, _ := c.GetPostForm("pid")
+			tmp, _ := Mgo.FindOne("site_versioninfo", `{"s_field":"`+s_field+`","vid":"`+vid+`","pid":"`+pid+`","delete":false}`)
 			if len(*tmp) > 0 {
 				c.JSON(200, gin.H{"rep": false})
 			} else {

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

@@ -658,7 +658,7 @@ func ExtRuleCore(doc map[string]interface{}, e *ExtractTask, vc *RuleCore, j *ju
 	}
 	for _, v := range vc.RuleCores {
 		if v.IsLua {
-			ExtRuleCoreByKv(vc.ExtFrom, doc, j, v, kvMap)
+			ExtRuleCoreByKv(vc.ExtFrom, doc, j, v, kvMap,e)
 		} else if extByReg {
 			ExtRuleCoreByReg(vc.ExtFrom, doc, j, v, e)
 		}
@@ -728,7 +728,7 @@ func ExtRuleCore(doc map[string]interface{}, e *ExtractTask, vc *RuleCore, j *ju
 }
 
 //抽取-规则-kv
-func ExtRuleCoreByKv(extfrom string, doc map[string]interface{}, j *ju.Job, in *RegLuaInfo, kvMap map[string][]map[string]interface{}) {
+func ExtRuleCoreByKv(extfrom string, doc map[string]interface{}, j *ju.Job, in *RegLuaInfo, kvMap map[string][]map[string]interface{}, et *ExtractTask) {
 	defer qu.Catch()
 	if extfrom == "title" || !in.IsLua {
 		return
@@ -743,6 +743,9 @@ func ExtRuleCoreByKv(extfrom string, doc map[string]interface{}, j *ju.Job, in *
 		}
 		kvMap[in.Field] = tmps
 	}
+	if len(extinfo) > 0 {
+		AddExtLog("extract", j.SourceMid, nil, extinfo, in, et.TaskInfo) //抽取日志
+	}
 }
 
 //抽取-规则-正则

+ 48 - 22
src/jy/extract/extractInit.go

@@ -343,6 +343,10 @@ func (e *ExtractTask) InitRuleBacks(isSite bool) {
 		}
 		if isSite {
 			sm, _ := db.Mgo.FindById("site_management", qu.ObjToString(v["pid"]), bson.M{"site_script": 1})
+			if (*sm) == nil || len(*sm) <= 0{
+				eSiteRuleBacks = []*RegLuaInfo{}
+				continue
+			}
 			for _, v2 := range (*sm)["site_script"].([]interface{}) {
 				if mdpvalue, ok := Luacodes.Load(v2); ok {
 					if mdpvalue.(map[string]interface{})["e.SiteRuleBacks"] == nil{
@@ -545,43 +549,53 @@ func (e *ExtractTask) InitRuleCore(isSite bool) {
 			}
 			fieldrules[s_field] = append(fieldrules[s_field], rcore)
 		}
+		infolist, _ := db.Mgo.Find("infotype", `{}`, `{}`, `{}`, false, -1, -1)
+		for _, v := range *infolist {
+			topclass := qu.ObjToString(v["topclass"])
+			if v["subclass"] == nil {
+				eSiteRuleCores[topclass] = make(map[string][]*RuleCore)
+				for attr, _ := range v["fields"].(map[string]interface{}) {
+					if fieldrules[attr]!=nil{
+						eSiteRuleCores[topclass][attr] = fieldrules[attr]
+					}
+				}
+			} else {
+				for ca, fs := range v["subclass"].(map[string]interface{}) {
+					eSiteRuleCores[topclass+"_"+ca] = make(map[string][]*RuleCore)
+					for field, _ := range fs.(map[string]interface{}) {
+						if fieldrules[field] !=nil{
+							eSiteRuleCores[topclass+"_"+ca][field] = fieldrules[field]
+						}
+					}
+				}
+			}
+		}
 		if isSite {
 			sm, _ := db.Mgo.FindById("site_management", qu.ObjToString(vinfo["pid"]), bson.M{"site_script": 1})
+			if (*sm) == nil || len(*sm) <=0{
+				eSiteRuleCores = make(map[string]map[string][]*RuleCore)
+				fieldrules = map[string][]*RuleCore{}
+				continue
+			}
 			for _, v2 := range (*sm)["site_script"].([]interface{}) {
 				if mdpvalue, ok := Luacodes.Load(v2); ok {
 					//属性配置
-					infolist, _ := db.Mgo.Find("infotype", `{}`, `{}`, `{}`, false, -1, -1)
-					for _, v := range *infolist {
-						topclass := qu.ObjToString(v["topclass"])
-						if v["subclass"] == nil {
-							eSiteRuleCores[topclass] = make(map[string][]*RuleCore)
-							for attr, _ := range v["fields"].(map[string]interface{}) {
-								if fieldrules[attr]!=nil{
-									eSiteRuleCores[topclass][attr] = fieldrules[attr]
-								}
-							}
-						} else {
-							for ca, fs := range v["subclass"].(map[string]interface{}) {
-								eSiteRuleCores[topclass+"_"+ca] = make(map[string][]*RuleCore)
-								for field, _ := range fs.(map[string]interface{}) {
-									if fieldrules[field] !=nil{
-										eSiteRuleCores[topclass+"_"+ca][field] = fieldrules[field]
-									}
-								}
-							}
-						}
-					}
 					if mdpvalue.(map[string]interface{})["e.SiteRuleCores"] == nil{
 						mdpvalue.(map[string]interface{})["e.SiteRuleCores"] = eSiteRuleCores
 					}else {
 						for k2,v2 :=range eSiteRuleCores{
-							mdpvalue.(map[string]interface{})["e.SiteRuleCores"].(map[string]map[string][]*RuleCore )[k2] = v2
+							tmpv := mdpvalue.(map[string]interface{})["e.SiteRuleCores"].(map[string]map[string][]*RuleCore)[k2]
+							for kkkk,vvv:=range v2{
+								tmpv[kkkk]=vvv
+							}
+							mdpvalue.(map[string]interface{})["e.SiteRuleCores"].(map[string]map[string][]*RuleCore )[k2] = tmpv
 						}
 					}
 					Luacodes.Store(v2, mdpvalue)
 				}
 			}
 			eSiteRuleCores = make(map[string]map[string][]*RuleCore)
+			fieldrules = map[string][]*RuleCore{}
 		}
 	}
 	if !isSite {
@@ -706,6 +720,10 @@ func (e *ExtractTask) InitTag(isSite bool) {
 			//ju.TagdbTable[fname] = &tab
 			if isSite {
 				sm, _ := db.Mgo.FindById("site_management", qu.ObjToString(v["pid"]), bson.M{"site_script": 1})
+				if (*sm) == nil||len(*sm) <= 0{
+					eSiteTag = map[string][]*Tag{}
+					continue
+				}
 				for _, v2 := range (*sm)["site_script"].([]interface{}) {
 					if  v2 == nil || v2 == "" {
 						continue
@@ -775,6 +793,10 @@ func (e *ExtractTask) InitTag(isSite bool) {
 		}
 		if isSite {
 			sm, _ := db.Mgo.FindById("site_management", qu.ObjToString(v["pid"]), bson.M{"site_script": 1})
+			if (*sm) == nil || len(*sm)<=0{
+				eSiteTag = map[string][]*Tag{}
+				continue
+			}
 			for _, v2 := range (*sm)["site_script"].([]interface{}) {
 				if mdpvalue, ok := Luacodes.Load(v2); ok {
 					if mdpvalue.(map[string]interface{})["e.SiteTag"] == nil{
@@ -825,6 +847,10 @@ func (e *ExtractTask) InitClearFn(isSite bool) {
 		}
 		if isSite {
 			sm, _ := db.Mgo.FindById("site_management", qu.ObjToString(tmp["pid"]), bson.M{"site_script": 1})
+			if (*sm) == nil|| len(*sm) <=0{
+				fn = map[string][]string{}
+				continue
+			}
 			for _, v2 := range (*sm)["site_script"].([]interface{}) {
 				if mdpvalue, ok := Luacodes.Load(v2); ok {
 					if mdpvalue.(map[string]interface{})["e.SiteClearFn"]== nil{

+ 22 - 2
src/jy/pretreated/division.go

@@ -3,11 +3,13 @@ package pretreated
 import (
 	"fmt"
 	"jy/util"
+
 	qutil "qfw/util"
 	"regexp"
 	"sort"
 	"strconv"
 	"strings"
+	"unicode/utf8"
 )
 
 //分块、分段功能
@@ -53,6 +55,7 @@ var (
 	regStartWrap       = regexp.MustCompile("^[\r\n]")
 	regEndWrap         = regexp.MustCompile("[\r\n]$")
 	regMoreWrap        = regexp.MustCompile("[\r\n]{2,}")
+	regStrWrap        = regexp.MustCompile("分包名称[::]")
 	replSerial         = regexp.MustCompile("(\r\n|^)([\\d一二三四五六七八九十][、..::,])+\\d")
 	moreColonReg       = regexp.MustCompile("[::]+")
 	regFilter          = regexp.MustCompile("等$")
@@ -578,6 +581,7 @@ func FindPackageFromText(title string, content string,isSite bool,codeSite strin
 //分块之后分包
 func divisionPackageChild(blockPackage *map[string]*util.BlockPackage, content, title string, isFindWinnerOrder, accuracy bool,isSite bool,codeSite string) (bool, string) {
 	//查找知否有分包
+	content = regStrWrap.ReplaceAllString(content, "\n")
 	content = regMoreWrap.ReplaceAllString(content, "\n")
 	content = regEndWrap.ReplaceAllString(content, "")
 	con, pkg, flag := CheckMultiPackage(content, title)
@@ -781,12 +785,28 @@ func interceptText(indexs []int, indexPkgMap map[int]string, pkgIndexMap map[str
 		} else {
 			text = con[iv:]
 		}
+		tmptext := text
 		if strings.Contains(text, "、") {
 			text = strings.Split(text, "、")[0]
 		} else if strings.Contains(text, "\n") {
-			text = strings.Split(text, "\n")[0]
+			texts := strings.Split(text, "\n")
+			text2 :=""
+			if ik+1 < len(indexs)-1 {
+				if startEndMap[indexs[ik+1+1]] != 0 {
+					text2 = con[startEndMap[indexs[ik+1]]:startEndMap[indexs[ik+1+1]]]
+				} else {
+					text2 = con[indexs[ik+1]:indexs[ik+1+1]]
+				}
+				if texts[len(texts)-1] == text2{
+					text = texts[0]
+				}
+			}
+		}
+		if utf8.RuneCountInString(text)<5{
+			indexTextMap[iv] = tmptext
+		}else {
+			indexTextMap[iv] = text
 		}
-		indexTextMap[iv] = text
 		warpCount := len(regSpliteSegment.FindAllStringIndex(text, -1))
 		if warpCount > maxWarpCount {
 			maxWarpCount = warpCount

+ 56 - 52
src/web/templates/admin/site_management.html

@@ -97,7 +97,7 @@
                         <label for="code" id="fieldname" class="col-sm-2 control-label myred">启用:</label>
                         <div class="col-sm-10">
                             <input id="isuse" name="isuse" type="radio" checked="checked" value="true"><label  for="isuse">启用</label>
-                            <input id="isuse" name="isuse" type="radio" value="false"><label  for="isuse">停用</label>
+                            <input id="isuse" name="isuse" type="radio" value="false"><label for="isuse">停用</label>
                         </div>
                     </div>
                 </div>
@@ -159,10 +159,10 @@
                 {
                     "data": "_id", render: function (val, a, row) {
                         tmp = '<div class="btn-group">' +
-                            '<a class="btn btn-sm btn-success" href="/admin/site_management/info?vid=' + row.vid + '&pid='+row._id+'" >属性</a>' +
-                            '<a class="btn btn-sm btn-info" href="/admin/site_management/ruleback?version=' + row.version + '&vid='+row.vid+'&pid='+row._id+'">后置规则</a>' +
-                            '<a class="btn btn-sm btn-warning" href="/admin/site_management/tag?version=' + row.version + '&vid='+row.vid+'&pid='+row._id+'">标签库</a>' +
-                            '<a class="btn btn-sm btn-danger" href="/admin/site_management/clear?version=' + row.version + '&vid='+row.vid+'&pid='+row._id+'">函数清理</a>' +
+                            '<a class="btn btn-sm btn-success" href="/admin/site_management/info?vid=' + row.vid + '&pid=' + row._id + '" >属性</a>' +
+                            '<a class="btn btn-sm btn-info" href="/admin/site_management/ruleback?version=' + row.version + '&vid=' + row.vid + '&pid=' + row._id + '">后置规则</a>' +
+                            '<a class="btn btn-sm btn-warning" href="/admin/site_management/tag?version=' + row.version + '&vid=' + row.vid + '&pid=' + row._id + '">标签库</a>' +
+                            '<a class="btn btn-sm btn-danger" href="/admin/site_management/clear?version=' + row.version + '&vid=' + row.vid + '&pid=' + row._id + '">函数清理</a>' +
                             '</div>';
                         return tmp
                     }
@@ -207,17 +207,17 @@
             alert("站点填写不完整!");
             return false;
         }
-/*
-        console.log({
-            "_id": _id,
-            "site_name": site_name,
-            "site_descript": site_descript,
-            "site_href": site_href,
-            "site_script": site_script,
-            "vid": vid,
-            "isuse":isuse
-        })
-*/
+        /*
+                console.log({
+                    "_id": _id,
+                    "site_name": site_name,
+                    "site_descript": site_descript,
+                    "site_href": site_href,
+                    "site_script": site_script,
+                    "vid": vid,
+                    "isuse":isuse
+                })
+        */
         // {{/*data:{"_id":_id,"s_descript":s_descript,"version":version,"clearJsonStr":clearJsonStr,"username":{{index (session "user") "name" }}},*/}}
         $.ajax({
             url: "/admin/site_management/save",
@@ -229,7 +229,7 @@
                 "site_href": site_href,
                 "site_script": site_script,
                 "vid": vid,
-                "isuse":isuse
+                "isuse": isuse
             },
             success: function (r) {
                 if (r.rep) {
@@ -240,24 +240,26 @@
             }
         })
     }
+
     //use
-    function use(_id,isuse){
-        smg=""
-        if(isuse){
-            smg="确定启用?"
-        }else{
-            smg="确定停用?"
+    function use(_id, isuse) {
+        smg = ""
+        if (isuse) {
+            smg = "确定启用?"
+        } else {
+            smg = "确定停用?"
         }
-        showConfirm(smg, function() {
+        showConfirm(smg, function () {
             $.ajax({
-                url:"/admin/site_management/use",
-                type:"post",
-                data:{"_id":_id,"isuse":isuse},
-                success:function(r){
-                    if(r.rep){
+                url: "/admin/site_management/use",
+                type: "post",
+                data: {"_id": _id, "isuse": isuse},
+                success: function (r) {
+                    if (r.rep) {
                         window.location.href = "/admin/site_management?vid=" + vid
-                    }else{
-                        showTip("启用失败", 1000, function() {});
+                    } else {
+                        showTip("启用失败", 1000, function () {
+                        });
                     }
                 }
             })
@@ -285,9 +287,9 @@
                     $("#site_descript").val(r.data.site_descript);
                     $("#site_href").val(r.data.site_href);
                     $("#site_script").val(r.data.site_script);
-                    if (!r.data.isuse){
-                        $("input[name='isuse'][value='true']").attr("checked",false);
-                        $("input[name='isuse'][value='false']").attr("checked",true);
+                    if (!r.data.isuse) {
+                        $("input[name='isuse'][value='true']").attr("checked", false);
+                        $("input[name='isuse'][value='false']").attr("checked", true);
                     }
                     $("#modal-info-version").modal("show");
                 } else {
@@ -299,25 +301,27 @@
 
     //删除站点
     function delete_table_btn(obj) {
-        if (obj == "") {
-            showTip("id不存在!", 1500)
-            return
-        }
-        $.ajax({
-            url: "/admin/site_management/delete",
-            type: "post",
-            data: {
-                "_id": obj,
-            },
-            success: function (r) {
-                if (r.rep) {
-                    window.location.href = "/admin/site_management?vid=" + vid
-                } else {
-                    showTip("删除失败", 1000, function () {
-                    });
-                }
+        showConfirm("确定删除?", function () {
+            if (obj == "") {
+                showTip("id不存在!", 1500)
+                return
             }
-        })
+            $.ajax({
+                url: "/admin/site_management/delete",
+                type: "post",
+                data: {
+                    "_id": obj,
+                },
+                success: function (r) {
+                    if (r.rep) {
+                        window.location.href = "/admin/site_management?vid=" + vid
+                    } else {
+                        showTip("删除失败", 1000, function () {
+                        });
+                    }
+                }
+            })
+        });
     }
 
 </script>

+ 13 - 4
udp_ocr_conter/main.go

@@ -41,12 +41,19 @@ func main() {
 			}))
 		}
 	}
-	for _, v := range cluster.CID {
-		log.Println("通知udp来取数据2:", v, config.Sysconfig["broadcast_port"], config.Udpclient.WriteUdp([]byte{}, mu.OP_TYPE_DATA, &net.UDPAddr{
-			IP:   net.ParseIP(v),
+	//for _, v := range cluster.CID {
+	//	log.Println("通知udp来取数据2:", v, config.Sysconfig["broadcast_port"], config.Udpclient.WriteUdp([]byte{}, mu.OP_TYPE_DATA, &net.UDPAddr{
+	//		IP:   net.ParseIP(v),
+	//		Port: qu.IntAll(config.Sysconfig["broadcast_port"]),
+	//	}))
+	//}
+	cluster.CID.Range(func(key, value interface{}) bool {
+		log.Println("通知udp来取数据2:", value, config.Sysconfig["broadcast_port"], config.Udpclient.WriteUdp([]byte{}, mu.OP_TYPE_DATA, &net.UDPAddr{
+			IP:   net.ParseIP(qu.ObjToString(value)),
 			Port: qu.IntAll(config.Sysconfig["broadcast_port"]),
 		}))
-	}
+		return true
+	})
 	mux := http.NewServeMux()
 	mux.HandleFunc("/", func(writer http.ResponseWriter, request *http.Request) {
 		http.Redirect(writer, request, "/login", http.StatusFound)
@@ -250,7 +257,9 @@ func main() {
 
 	})
 	c.AddFunc("0 */1 * * * *", func() {
+		config.Sys.Lock()
 		qu.ReadConfig(&config.Sysconfig)
+		config.Sys.Unlock()
 		//log.Println(111)
 		//log.Println(config.Sysconfig)
 	})

+ 8 - 5
udp_ocr_conter/src/cluster/aliecs.go

@@ -21,6 +21,7 @@ import (
 	"qfw/util/mongodb"
 	"sort"
 	"strings"
+	"sync"
 	"time"
 )
 
@@ -99,7 +100,8 @@ func runInstances(kv map[string]interface{}, taskName, widthOut, computer string
 	}
 	//log.Println(res)
 }
-var CID = map[string]string{}
+//var CID = map[string]string{}
+var CID sync.Map
 
 //查询多台实例的详细信息
 func DescribeInstances() {
@@ -108,7 +110,7 @@ func DescribeInstances() {
 		[]string{"InstanceChargeType", "PostPaid"},
 		[]string{"PageSize", "100"},
 	})
-	CID = make(map[string]string)
+	//CID = make(map[string]string)
 	for _, ins := range res["Instances"].(map[string]interface{}) {
 		for _, val := range ins.([]interface{}) {
 			if tmp, ok := val.(map[string]interface{}); ok {
@@ -125,9 +127,10 @@ func DescribeInstances() {
 				}
 				if strings.Contains(qu.ObjToString(tmp["InstanceName"]), "ocr_task") {
 					log.Println("更新申请实例", tmp["InstanceId"], "内网ip", tmp["ip_nw"])
-					config.Sys.Lock()
-					CID[qu.ObjToString(tmp["InstanceId"])] = qu.ObjToString(tmp["ip_nw"])
-					config.Sys.Unlock()
+					//config.Sys.Lock()
+					//CID[qu.ObjToString(tmp["InstanceId"])] = qu.ObjToString(tmp["ip_nw"])
+					//config.Sys.Unlock()
+					CID.Store(qu.ObjToString(tmp["InstanceId"]),qu.ObjToString(tmp["ip_nw"]))
 					//更新实例信息
 					mongodb.Update("ocr_ecs", `{"InstanceId":"`+qu.ObjToString(tmp["InstanceId"])+`"}`, map[string]interface{}{"$set": tmp}, true, false)
 					mongodb.Update("ocr_ecs_bak", `{"InstanceId":"`+qu.ObjToString(tmp["InstanceId"])+`"}`, map[string]interface{}{"$set": tmp}, true, false)

+ 1 - 1
udp_ocr_conter/src/config/send_email.go

@@ -41,7 +41,7 @@ func check() bool {
 	var sumNum int = 0
 	for _, v := range *taskArr {
 		sumNum += mongodb.Count("bidding", bson.M{"_id": bson.M{
-			"$gte": bson.ObjectIdHex(util.ObjToString(v["start"])),
+			"$gte": bson.ObjectIdHex(util.ObjToString(v["gtid"])),
 			"$lte": bson.ObjectIdHex(util.ObjToString(v[util.ObjToString(EidField)])),
 		}})
 	}

+ 100 - 20
udp_ocr_conter/src/corntask/task_corn.go

@@ -21,6 +21,12 @@ var Auto = func() {
 	}
 	nowday := time.Date(d.Year(), d.Month(), d.Day(), 0, 0, 0, 0, d.Location())
 	cluster.DescribeInstances() //查询多台实例的详细信息
+	tnum:=0
+	cluster.CID.Range(func(key, value interface{}) bool {
+		tnum +=1
+		return true
+	})
+	log.Println("实例数量:",tnum)
 	ocrescs := mongodb.Find("ocr_ecs", bson.M{}, nil, bson.M{"AutoReleaseTime": 1}, false, -1, -1)
 	if ocrescs != nil || len(*ocrescs) > 0 {
 		for _, v := range (*ocrescs) {
@@ -44,9 +50,12 @@ var Auto = func() {
 	//if taskNum <= 0 {
 	//计算释放,发送udp
 	ccnum := compute()
-	log.Println("ccnum:", ccnum, ", len(config.CID):", len(cluster.CID), cluster.CID)
+	log.Println("ccnum:", ccnum, ", len(config.CID):", tnum, cluster.CID)
+	escObject := mongodb.Find("ocr_ecs", bson.M{"TaskName": "ocr_task_arr", "OcrTaskStatus": "none"}, bson.M{"_id": -1}, nil, false, -1, -1)
+	log.Println("实例未部署数量", len(*escObject))
+	//释放实例
 	if ccnum <= 0 {
-		if len(cluster.CID) == 0 {
+		if tnum == 0 {
 			log.Println("当前实例为空,无需释放", cluster.CID, )
 			return
 		}
@@ -56,9 +65,9 @@ var Auto = func() {
 		xwa := time.Date(d.Year(), d.Month(), d.Day(), util.IntAll(config.Sysconfig["xwa"]), 0, 0, 0, d.Location())
 		xwb := time.Date(d.Year(), d.Month(), d.Day(), util.IntAll(config.Sysconfig["xwb"]), 0, 0, 0, d.Location())
 		if !((zsa.Before(d) && zsb.After(d)) || (xwa.Before(d) && xwb.After(d))){
-			if ccnum == 0 && len(cluster.CID) > 0 {
+			if ccnum == 0 && tnum > 0 {
 				log.Println("释放所有实例", cluster.CID)
-				for tmpIid, _ := range cluster.CID {
+				cluster.CID.Range(func(tmpIid, value interface{}) bool {
 					ttt := mongodb.FindOne("ocr_ecs", bson.M{"InstanceId": tmpIid})
 					log.Println("5分钟后释放实例", tmpIid)
 					go func(tmpIid string,ttt *map[string]interface{}) {
@@ -69,16 +78,51 @@ var Auto = func() {
 						})
 						mongodb.Del("ocr_ecs", bson.M{"InstanceId": tmpIid})
 						cluster.DeleteInstance(tmpIid)
+						cluster.CID.Delete(tmpIid)
 						log.Println("5分钟后释放实例完成", tmpIid)
-					}(tmpIid,ttt)
-				}
+					}(util.ObjToString(tmpIid),ttt)
+					return true
+				})
+				//for tmpIid, _ := range cluster.CID {
+				//	ttt := mongodb.FindOne("ocr_ecs", bson.M{"InstanceId": tmpIid})
+				//	log.Println("5分钟后释放实例", tmpIid)
+				//	go func(tmpIid string,ttt *map[string]interface{}) {
+				//		time.Sleep(time.Minute * 5)
+				//		config.Udpclient.WriteUdp([]byte("5分钟后释放实例"), mu.OP_DELETE_DOWNLOADERCODES, &net.UDPAddr{
+				//			IP:   net.ParseIP(util.ObjToString((*ttt)["ip_nw"])),
+				//			Port: util.IntAll(config.Sysconfig["broadcast_port"]),
+				//		})
+				//		mongodb.Del("ocr_ecs", bson.M{"InstanceId": tmpIid})
+				//		cluster.DeleteInstance(tmpIid)
+				//		log.Println("5分钟后释放实例完成", tmpIid)
+				//	}(tmpIid,ttt)
+				//}
 			} else {
 				var tmpnum int
-				for k, _ := range cluster.CID {
+				//for k, _ := range cluster.CID {
+				//	if ccnum >= tmpnum {
+				//		return
+				//	}
+				//	tmpIid := k
+				//	ttt := mongodb.FindOne("ocr_ecs", bson.M{"InstanceId": tmpIid})
+				//	log.Println("5分钟后释放实例", tmpIid)
+				//	go func(tmpIid string,ttt *map[string]interface{}) {
+				//		time.Sleep(time.Minute * 5)
+				//		config.Udpclient.WriteUdp([]byte("5分钟后释放实例"), mu.OP_DELETE_DOWNLOADERCODES, &net.UDPAddr{
+				//			IP:   net.ParseIP(util.ObjToString((*ttt)["ip_nw"])),
+				//			Port: util.IntAll(config.Sysconfig["broadcast_port"]),
+				//		})
+				//		mongodb.Del("ocr_ecs", bson.M{"InstanceId": tmpIid})
+				//		cluster.DeleteInstance(tmpIid)
+				//		log.Println("5分钟后释放实例完成", tmpIid)
+				//	}(tmpIid,ttt)
+				//	tmpnum--
+				//}
+				cluster.CID.Range(func(k, value interface{}) bool {
 					if ccnum >= tmpnum {
-						return
+						return false
 					}
-					tmpIid := k
+					tmpIid := util.ObjToString(k)
 					ttt := mongodb.FindOne("ocr_ecs", bson.M{"InstanceId": tmpIid})
 					log.Println("5分钟后释放实例", tmpIid)
 					go func(tmpIid string,ttt *map[string]interface{}) {
@@ -89,19 +133,50 @@ var Auto = func() {
 						})
 						mongodb.Del("ocr_ecs", bson.M{"InstanceId": tmpIid})
 						cluster.DeleteInstance(tmpIid)
+						cluster.CID.Delete(tmpIid)
 						log.Println("5分钟后释放实例完成", tmpIid)
 					}(tmpIid,ttt)
 					tmpnum--
-				}
+					return true
+				})
 			}
 		}
 		cluster.DescribeInstances()
+		escObject := mongodb.Find("ocr_ecs", bson.M{"TaskName": "ocr_task_arr", "OcrTaskStatus": "none"}, bson.M{"_id": -1}, nil, false, -1, -1)
+		log.Println("实例未部署数量", len(*escObject))
+		if escObject != nil || len(*escObject) > 0 {
+			for i, v := range (*escObject) {
+				if tmpip := util.ObjToString(v["ip_nw"]); tmpip == "" {
+					log.Println("没用获取到ip,实例ip异常", tmpip)
+				} else {
+					go func(tmpip, InstanceId string, i int) {
+						if DoCMD(tmpip) {
+							var tmpstr string
+							isok2, udpstr := cluster.SshPgrep(tmpip, "pgrep udp2019")
+							tmpstr += udpstr + ";&nbsp;&nbsp;"
+							isok3, fil2textstr := cluster.SshPgrep(tmpip, "pgrep file2text")
+							tmpstr += fil2textstr
+							if isok2 && isok3 {
+								(*escObject)[i]["OcrTaskStatus"] = "successful"
+								mongodb.Update("ocr_ecs", bson.M{"_id": (*escObject)[i]["_id"]}, (*escObject)[i], true, false)
+								log.Println((*escObject)[i]["_id"], tmpip, "部署成功")
+							} else {
+								log.Println(tmpip, "部署异常,"+tmpstr)
+							}
+						} else {
+							log.Println(tmpip, "部署失败")
+						}
+					}(tmpip, util.ObjToString(v["InstanceId"]), i)
+				}
+			}
+		}
 		return
 	}
 	//}
-	if len(cluster.CID) >= util.IntAll(config.Sysconfig["pernum"]) {
+	//重新部署未完成实例
+	log.Println("tnum >= util.IntAll(config.Sysconfig[pernum])",tnum ,util.IntAll(config.Sysconfig["pernum"]))
+	if tnum >= util.IntAll(config.Sysconfig["pernum"]) {
 		log.Println("实例申请上限,当前实例:", cluster.CID)
-		escObject := mongodb.Find("ocr_ecs", bson.M{"TaskName": "ocr_task_arr", "OcrTaskStatus": "none"}, bson.M{"_id": -1}, nil, false, -1, -1)
 		log.Println("实例未部署数量", len(*escObject))
 		if escObject != nil || len(*escObject) > 0 {
 			for i, v := range (*escObject) {
@@ -132,6 +207,7 @@ var Auto = func() {
 		return
 	}
 	//if taskNum > 1 {
+	//申请实例
 	log.Println("申请实例")
 	now := time.Now()
 	hours := time.Date(now.Year(), now.Month(), now.Day(), 20, 0, 0, 0, now.Location()).Sub(now).Hours()
@@ -150,7 +226,7 @@ func DoCMD(ip string) bool {
 	return cluster.RunSsh(ip)
 }
 func DynamicTask() {
-	time.Sleep(time.Second * 25)
+	time.Sleep(time.Second * 35)
 	cluster.DescribeInstances() //查询多台实例的详细信息
 	escObject := mongodb.Find("ocr_ecs", bson.M{"TaskName": "ocr_task_arr", "OcrTaskStatus": "none"}, bson.M{"_id": -1}, nil, false, -1, -1)
 	log.Println("实例未部署数量", len(*escObject))
@@ -171,11 +247,14 @@ func DynamicTask() {
 						if isok2 && isok3 {
 							(*escObject)[i]["OcrTaskStatus"] = "successful"
 							mongodb.Update("ocr_ecs", bson.M{"_id": (*escObject)[i]["_id"]}, (*escObject)[i], true, false)
-							config.Sys.Lock()
-							if cluster.CID[InstanceId] == "" && InstanceId != "" {
-								cluster.CID[InstanceId] = tmpip
+							//config.Sys.Lock()
+							//if cluster.CID[InstanceId] == "" && InstanceId != "" {
+							//	cluster.CID[InstanceId] = tmpip
+							//}
+							if cv,ok :=cluster.CID.Load(InstanceId);ok && cv =="" &&InstanceId != ""{
+									cluster.CID.Store(InstanceId, tmpip)
 							}
-							config.Sys.Unlock()
+							//config.Sys.Unlock()
 							log.Println((*escObject)[i]["_id"], tmpip, "部署成功")
 						} else {
 							log.Println(tmpip, "部署异常,"+tmpstr)
@@ -231,12 +310,13 @@ func compute() int {
 			log.Println(496, sum, "<=", util.IntAll(config.Sysconfig["accumulated_task_lowlimit"]))
 			return 0
 		}
-		mtmm := float64(overNum) / float64(nowtime-stime) / float64(len(cluster.CID)+util.IntAll(config.Sysconfig["gdts"])) //每台每秒
+		tnum :=mongodb.Count("ocr_ecs",bson.M{"OcrTaskStatus":"successful"})
+		mtmm := float64(overNum) / float64(nowtime-stime) / float64(tnum+util.IntAll(config.Sysconfig["gdts"])) //每台每秒
 		if mtmm <= 0 {
-			log.Println(501, overNum, int(nowtime-stime), (len(cluster.CID) + util.IntAll(config.Sysconfig["gdts"])))
+			log.Println(501, overNum, int(nowtime-stime), (tnum + util.IntAll(config.Sysconfig["gdts"])))
 			return 0
 		}
-		cc := float64(sum)/float64(util.IntAll(config.Sysconfig["corntime_consuming"]))/mtmm - float64(len(cluster.CID)) - float64(util.IntAll(config.Sysconfig["gdts"]))
+		cc := float64(sum)/float64(util.IntAll(config.Sysconfig["corntime_consuming"]))/mtmm - float64(tnum) - float64(util.IntAll(config.Sysconfig["gdts"]))
 		log.Println("overNum:", overNum, ",hs:", int(nowtime-stime), ",mtms:", mtmm, ",sum:", sum, cc)
 		if cc > util.Float64All(config.Sysconfig["pernum"]) {
 			return util.IntAll(config.Sysconfig["pernum"])

+ 10 - 5
udp_ocr_conter/src/info/taskinfo.go

@@ -13,9 +13,9 @@ import (
 func QueryInfo() map[string]interface{} {
 	now := time.Now()
 	data := make(map[string]interface{})
-	config.Sys.Lock()
+	//config.Sys.Lock()
 	//data["isrun"] = config.IsRun
-	config.Sys.Unlock()
+	//config.Sys.Unlock()
 	taskArr := mongodb.Find("ocr_task", bson.M{"isrun":bson.M{
 		"$ne":"stop",
 	}}, `{_id:1}`, nil, false, -1, -1)
@@ -63,12 +63,17 @@ func QueryInfo() map[string]interface{} {
 	data["executionTime"] = since.String()
 	//log.Println(now.Sub(stime).Seconds())
 	cluster.DescribeInstances()
-	mtmm := float64(overNum) / now.Sub(stime).Seconds() / float64(3+len(cluster.CID))
+	cnum:=0
+	cluster.CID.Range(func(key, value interface{}) bool {
+		cnum+=1
+		return true
+	})
+	mtmm := float64(overNum) / now.Sub(stime).Seconds() / float64(3+cnum)
 	//log.Println(overNum ,now.Sub(stime).Seconds(),3+len(config.CID),mtmm)
-	tmpf := float64(nowSumNum) / mtmm / float64(3+len(cluster.CID))
+	tmpf := float64(nowSumNum) / mtmm / float64(3+cnum)
 	//log.Println(nowSumNum,mtmm,tmpf)
 	data["estimatedFinishTime"] = now.Add(time.Second*time.Duration(tmpf)).String()
-	data["esc"] = fmt.Sprint(3 ,"+", len(cluster.CID))
+	data["esc"] = fmt.Sprint(3 ,"+", cnum)
 	data["resultInfos"] = resultInfos
 	//log.Println(resultInfos)
 	return data

+ 19 - 12
udpfilterdup/src/datamap.go

@@ -62,7 +62,7 @@ func NewDatamap(days int, lastid string) *datamap {
 	n, continuSum := 0, 0
 	for tmp := make(map[string]interface{}); it.Next(&tmp); n++ {
 		//|| qutil.ObjToString(tmp["subtype"]) == "变更"
-		if qutil.IntAll(tmp["repeat"]) == 1  {
+		if qutil.IntAll(tmp["repeat"]) == 1 || qutil.IntAll(tmp["repeat"]) == -1{
 			continuSum++
 		} else {
 			cm := tmp["comeintime"] //时间单位
@@ -172,8 +172,10 @@ L:
 						//同城判定有效
 						first_judge:= false
 						if (v.projectcode != ""&&v.projectcode==info.projectcode&&v.projectname != ""&&v.projectname==info.projectname)||
-							(v.title != ""&&v.title==info.title&&v.bidopentime != 0&&v.bidopentime==info.bidopentime&&v.detail != ""&&v.detail==info.detail) {
+							(v.projectcode != ""&&v.projectcode==info.projectcode&&v.bidopentime != 0&&v.bidopentime==info.bidopentime)||
+							(v.title != ""&&v.title==info.title&&v.agencyaddr != ""&&v.agencyaddr==info.agencyaddr&&v.bidopentime != 0&&v.bidopentime==info.bidopentime) {
 							first_judge = true
+
 						}
 						//3/6等判断
 						n := 0
@@ -197,11 +199,9 @@ L:
 						}
 						t:= judgeCityType(v.area,info.area,v.city,info.city)
 						if n>=3||first_judge==true {
-							if t==2 {
-								//同城
+							if t==2 {//同城
 								b = true
 								id = v.id
-								//log.Print("同城满足的",info.id)
 								break L
 							}
 						}
@@ -230,7 +230,8 @@ L:
 						t:= judgeCityType(v.area,info.area,v.city,info.city)
 						c_1 :=conditionTitle(v.title,info.title) //标题满足
 						c_2 :=conditionNum(v.projectcode,info.projectcode) //编号满足
-						c_3 :=conditionTAB(v.title,info.title,v.buyer,info.buyer) //标题+采购单位
+						c_3 :=conditionTitleBuyer(v.title,info.title,v.buyer,info.buyer) //标题+采购单位
+						c_4 :=conditionCodeTime(v.bidopentime,info.bidopentime,v.projectcode,info.projectcode) //编号+开标时间
 
 
 						site_b := false
@@ -256,8 +257,8 @@ L:
 							if v.projectcode != info.projectcode&&len([]rune(info.projectcode)) >=10&&v.projectcode!=""{
 								continue
 							}
-							//先决条件满足三要素
-							if n==3{
+							//先决条件满足三要素,条件4
+							if n==3||c_4{
 								b = true
 								id = v.id
 								break L
@@ -335,9 +336,6 @@ L:
 				//		break L
 				//	}
 				//}
-
-
-
 			}
 		}
 	}
@@ -404,13 +402,22 @@ func conditionNum(c1 string ,c2 string) bool {
 	return false
 }
 //条件三 采购单位+标题
-func conditionTAB(t1 string ,t2 string,b1 string,b2 string) bool {
+func conditionTitleBuyer(t1 string ,t2 string,b1 string,b2 string) bool {
 
 	if t1==t2&&b1==b2 {
 		return true
 	}
 	return false
 }
+//条件四 编号+开标时间
+func conditionCodeTime(t1 int64 ,t2 int64,c1 string,c2 string) bool {
+
+	if c1 != ""&&c1==c2&&t1 != 0&&t1==t2&&len([]rune(c1)) >=10 {
+		return true
+	}
+	return false
+}
+
 
 
 func (d *datamap) update(t int64) {

+ 108 - 73
udpfilterdup/src/main.go

@@ -7,6 +7,7 @@ package main
 import (
 	"encoding/json"
 	"fmt"
+	"gopkg.in/mgo.v2/bson"
 	"log"
 	mu "mfw/util"
 	"net"
@@ -22,7 +23,7 @@ var (
 	mconf        map[string]interface{} //mongodb配置信息
 	mgo          *mongodb.MongodbSim    //mongodb操作对象
 
-	mgoTest          *mongodb.MongodbSim    //mongodb操作对象
+	//mgoTest          *mongodb.MongodbSim    //mongodb操作对象
 
 	extract      string
 	extract_copy string
@@ -36,7 +37,7 @@ var (
 
 	//5d767728a5cb26b9b7748868  //9万
 	//5da3f2c5a5cb26b9b79847fc  //76万
-	FilterRegTitle = regexp.MustCompile("[0-9一二三四五六七八九十零123456789](次|包|标段)")
+	FilterRegTitle = regexp.MustCompile("[0-9a-zA-Z一二三四五六七八九十零123456789](次|包|标段|标包)")
 	inV_n int   //无效数据数量
 	siteArr     []map[string]interface{} //站点
 	//56404035af5374672e00059c
@@ -65,32 +66,32 @@ func init() {
 
 
 	//测试临时注释
-	dupdays = util.IntAllDef(Sysconfig["dupdays"], 3)
-	//加载数据
-	DM = NewDatamap(dupdays, lastid)
-	sw := util.ObjToString(Sysconfig["specialwords"])
-	if sw != "" {
-		FilterRegexp = regexp.MustCompile(sw)
-	}
+	//dupdays = util.IntAllDef(Sysconfig["dupdays"], 3)
+	////加载数据
+	//DM = NewDatamap(dupdays, lastid)
+	//sw := util.ObjToString(Sysconfig["specialwords"])
+	//if sw != "" {
+	//	FilterRegexp = regexp.MustCompile(sw)
+	//}
 
 
 	//数据库
 	//mongodb.InitMongodbPool(5, "192.168.3.207:27081", "")
 
-	mgoTest = &mongodb.MongodbSim{
-		MongodbAddr: "192.168.3.207:27081",
-		Size:        5,
-		DbName:      "qfw",
-	}
-	mgoTest.InitPool()
+	//mgoTest = &mongodb.MongodbSim{
+	//	MongodbAddr: "192.168.3.207:27081",
+	//	Size:        5,
+	//	DbName:      "qfw",
+	//}
+	//mgoTest.InitPool()
 
 
 }
 
 //新增一个方法 判断
-func main22()  {
+func main()  {
 	//log.Println("1")
-
+	//代码copy数据
 	//sessTest :=mgoTest.GetMgoConn()
 	//defer sessTest.Close()
 	//
@@ -123,68 +124,102 @@ func main22()  {
 
 
 
-	//sess := mgo.GetMgoConn()
-	//defer mgo.DestoryMongoConn(sess)
-	//res, _ := mgo.Find(extract_copy, nil, nil, nil, false, -1, -1)
-	//res_copy, _ := mgo.Find(extract, nil, nil, nil, false, -1, -1)
-
-	//m1 :=map[string]int{} //老版本
-	//m2 :=map[string]int{} //新版本
-	//for _,v:=range *res{
-	//	m1[(v["_id"].(bson.ObjectId).Hex())]= util.IntAll(v["repeat"])
-	//}
-	//for _,v:=range *res_copy{
-	//	m2[(v["_id"].(bson.ObjectId).Hex())]= util.IntAll(v["repeat"])
-	//}
-	//fmt.Println(len(m1),len(m2))
-	//n1:=0
-	//n2:=0
-	//var arr1 []string
-	//var arr2 []string
-	//for k,v:=range m1{
-	//	if m2[k]!=v{
-	//		if m2[k]==0{ //1:0
-	//			n1++
-	//			arr1 = append(arr1,fmt.Sprintf("目标_id:%s",k))
-	//		}
-	//		if m2[k]==1{//0:1
-	//			n2++
-	//		}
-	//	}
-	//}
-	//for _,v:=range arr1 {
-	//	log.Println(v)
-	//}
-	//log.Println("V1版本:1:0 对应数量",n1)
-	//log.Println("V1版本:0:1 对应数量",n2)
-	//
-	//
-	//n1=0
-	//n2=0
-	//for k,v:=range m2{
-	//	if m1[k]!=v{
-	//		if m1[k]==0{
-	//			n1++
-	//		}
-	//		if m1[k]==1{
-	//			n2++
-	//			arr2 = append(arr2,fmt.Sprintf("目标_id:%s",k))
-	//		}
-	//	}
-	//}
-	//for _,v:=range arr2 {
-	//	log.Println(v)
-	//}
-	//log.Println("V2版本:0:1 对应数量",n1)
-	//log.Println("V2版本:1:0 对应数量",n2)
+	sess := mgo.GetMgoConn()
+	defer mgo.DestoryMongoConn(sess)
+	res_copy := sess.DB("extract_kf").C(extract_copy).Find(nil).Iter()
+
+	m1 :=map[string]int{} //老版本
+	m2 :=map[string]int{} //新版本
+
+	i:=0
+	j:=0
+	for v1 := make(map[string]interface{}); res_copy.Next(&v1); i++{
+		if i%2000==0 {
+			log.Println("当前i:",i)
+		}
+		//if i>10000 {
+		//	break
+		//}
+		m1[(v1["_id"].(bson.ObjectId).Hex())]= util.IntAll(v1["repeat"])
+	}
+
+	sesss := mgo.GetMgoConn()
+	defer mgo.DestoryMongoConn(sesss)
+	res := sesss.DB("extract_kf").C(extract).Find(nil).Iter()
+
+
+	for v2 := make(map[string]interface{}); res.Next(&v2); j++{
+		if j%2000==0 {
+			log.Println("当前j:",j)
+		}
+		//if j>10000 {
+		//	break
+		//}
+		m2[(v2["_id"].(bson.ObjectId).Hex())]= util.IntAll(v2["repeat"])
+	}
+
+	fmt.Println(len(m1),len(m2))
+	n1:=0
+	n2:=0
+	n3:=0
+	n4:=0
+
+	var arr1 []string
+	var arr2 []string
+	for k,v:=range m1{
+		if m2[k]==1&&v==0{//0:1
+			n1++
+			arr2 = append(arr2,fmt.Sprintf("目标_id:%s",k))
+		}
+		if m2[k]==0&&v==1{ //1:0
+			n2++
+			arr1 = append(arr1,fmt.Sprintf("目标_id:%s",k))
+		}
+		if m2[k]==0&&v==0{ //0:0
+			n3++
+		}
+		if m2[k]==1&&v==1{//1:1
+			n4++
+		}
+	}
+	//打印 1:0情况 少打印 300条    38841
+
+	mm:=0
+	for _,v:=range arr1 {
+		mm++
+		if mm%130==0 {
+			log.Println(v)
+		}
+	}
+
+	log.Println("分割线---------------")
+	log.Println("分割线---------------")
+	log.Println("分割线---------------")
+	log.Println("分割线---------------")
+	log.Println("分割线---------------")
+
+
+	//打印 1:0情况 少打印  1000条   15518
+	nn:=0
+	for _,v:=range arr2 {
+		nn++
+		if nn%30==0 {
+			log.Println(v)
+		}
+	}
+
+	log.Println("V1 0:1---",n1)
+	log.Println("V1 1:0---",n2)
+	log.Println("V1 0:0---",n3)
+	log.Println("V1 1:1---",n4)
+
 
-	// 10-14   10-25   1571025600  1571976000
 
 }
 
 
 
-func main() {
+func main22() {
 	go checkMapJob()
 
 	updport := Sysconfig["udpport"].(string)