Jianghan 1 tahun lalu
induk
melakukan
0e6e10ddb1

+ 8 - 5
src/config.json

@@ -6,10 +6,8 @@
   "dbname": "datatag",
   "uname": "",
   "upwd": "",
-  "mgodben": "192.168.3.71:29099",
-  "dbnameen": "enterprise",
-  "mongoenc": "winner_enterprise",
-  "elasticsearch": "http://127.0.0.1:9200",
+  "elasticsearch": "http://127.0.0.1:19800",
+  "elasticsearch1": "http://127.0.0.1:19800",
   "elasticsearch_index": "biddingall",
   "elasticsearch_type": "bidding",
   "elasticPoolSize": 10,
@@ -22,10 +20,15 @@
   "jymgo": {
     "jyaddr": "192.168.3.71:29099",
     "jydbsize": 5,
-    "jydbname": "qfw",
+    "jydbname": "wjh",
     "jycollname1": "bidding",
     "jycollname2": "bidding_back"
   },
+  "entmgo": {
+    "jyaddr": "192.168.3.71:29099",
+    "jydbsize": 5,
+    "jydbname": "wjh"
+  },
   "jyredis": {
     "redis_jy": "jy_log=127.0.0.1:6379",
     "redis_jy_name": "jy_log",

+ 4 - 2
src/filter/sessfilter.go

@@ -3,17 +3,18 @@ package filter
 import (
 	"github.com/go-xweb/xweb"
 	"net/http"
+	qu "qfw/util"
 	"regexp"
 )
 
-//session过滤器
+// session过滤器
 type sessfilter struct {
 	App         *xweb.App
 	SessionName string
 	MatchUrl    []*regexp.Regexp
 }
 
-//实现过滤器方法
+// 实现过滤器方法
 func (s *sessfilter) Do(w http.ResponseWriter, req *http.Request) bool {
 	requestPath := req.URL.Path
 	b := true
@@ -32,6 +33,7 @@ func (s *sessfilter) Do(w http.ResponseWriter, req *http.Request) bool {
 		}
 		break
 	}
+	qu.Debug("1")
 	if !b {
 		s.App.Redirect(w, requestPath, "/")
 	}

+ 1 - 2
src/main.go

@@ -38,7 +38,7 @@ func init() {
 	xweb.AddAction(&service.App{}) // 程序
 	xweb.AddAction(&lua.Lua{})
 	xweb.RootApp().AppConfig.SessionTimeout = 1 * time.Hour
-	xweb.RootApp().Logger.SetOutputLevel(3)
+	xweb.RootApp().Logger.SetOutputLevel(1)
 
 	//xweb.AddTmplVar("add", func(a, b int) int { return a + b })
 	//InitTask("5ecf56ed92b4ee16ffd7e21e")
@@ -54,7 +54,6 @@ func main() {
 func TimeTask() {
 
 	util.Task()
-
 	crn := cron.New()
 	ct := 0
 	_ = crn.AddFunc("0 */10 * * * ?", func() {

+ 137 - 26
src/service/repair_service.go

@@ -2,7 +2,6 @@ package service
 
 import (
 	"bytes"
-	"context"
 	"encoding/json"
 	"fmt"
 	"github.com/go-xweb/xweb"
@@ -43,6 +42,8 @@ type RepairRule struct {
 	searchJyurl   xweb.Mapper `xweb:"/service/jy/searchJyurl"`
 	searchSha     xweb.Mapper `xweb:"/service/jy/searchSha"`
 	repairEdit    xweb.Mapper `xweb:"/service/jy/edit"`
+	repairEdit1   xweb.Mapper `xweb:"/service/jy/editRepeat"`
+	repairEdit2   xweb.Mapper `xweb:"/service/jy/editRepeat/save"`
 	repairDelete  xweb.Mapper `xweb:"/service/jy/delete"`
 	repairSave    xweb.Mapper `xweb:"/service/jy/save"`
 	repairCreate  xweb.Mapper `xweb:"/service/jy/create"`
@@ -123,10 +124,11 @@ func (jy *RepairRule) RepairNewSave() {
 
 	//处理个别字段
 	(*updata)["_id"] = primitive.NewObjectID()
-	if hf := qu.ObjToString((*updata)["href"]); hf == "" || hf == "#" {
-		var Url = "https://www.jianyu360.cn/article/content/%s.html"
-		(*updata)["href"] = fmt.Sprintf(Url, qu.CommonEncodeArticle("content", mongodb.BsonIdToSId((*updata)["_id"])))
-		(*updata)["competehref"] = "#"
+	if hf := qu.ObjToString((*updata)["site"]); hf == "竞品网站" { // 竞品网站
+		//var Url = "https://www.jianyu360.cn/article/content/%s.html"
+		//(*updata)["competehref"] = fmt.Sprintf(Url, qu.CommonEncodeArticle("content", mongodb.BsonIdToSId((*updata)["_id"])))
+		(*updata)["competehref"] = qu.ObjToString((*updata)["href"])
+		(*updata)["href"] = "#"
 	}
 	// spider_code
 	(*updata)["spidercode"] = AddSpiderCode
@@ -352,6 +354,93 @@ func (jy *RepairRule) RepairEdit() {
 	jy.Render("repair/jy_edit.html", &jy.T)
 }
 
+func (jy *RepairRule) RepairEdit1() {
+	defer qu.Catch()
+	id := jy.GetString("_id")
+	coll := jy.GetString("coll")
+	data, _ := JYMgo.FindById(coll, id, bson.M{"extracttype": 1, "repeat_id": 1, "title": 1})
+	delete(*data, "_id")
+
+	jy.ServeJson(map[string]interface{}{
+		"rep":  true,
+		"data": *data,
+		"coll": coll,
+	})
+}
+
+func (jy *RepairRule) RepairEdit2() {
+	defer qu.Catch()
+	id := jy.GetString("_id")
+	coll := jy.GetString("coll")
+	et, _ := jy.GetInteger("etype")
+	data, _ := JYMgo.FindById(coll, id, bson.M{"extracttype": 1, "repeat_id": 1, "title": 1})
+	if et != 1 && et != -1 {
+		jy.ServeJson(map[string]interface{}{
+			"rep": false,
+			"msg": "修改重复标记异常",
+		})
+	} else if et == qu.IntAll((*data)["extracttype"]) {
+		jy.ServeJson(map[string]interface{}{
+			"rep": false,
+			"msg": "数据无变更",
+		})
+	} else {
+		if et == -1 {
+			rid := jy.GetString("rid")
+			if !mongodb.IsObjectIdHex(rid) {
+				jy.ServeJson(map[string]interface{}{
+					"rep": false,
+					"msg": "重复数据id异常",
+				})
+				return
+			}
+			JYMgo.UpdateById(coll, id, bson.M{"$set": bson.M{"extracttype": et, "repeat_id": rid}})
+		} else {
+			JYMgo.UpdateById(coll, id, bson.M{"$set": bson.M{"extracttype": et}})
+		}
+		if et == -1 {
+			JyEs.DelById(EsIndex, id)
+			JyEs1.DelById(EsIndex, id)
+			//JyEs1.DelById("bidding_temp", id)
+		} else if et == 1 {
+			indexNode := *qu.ObjToMap(Sysconfig["indexNode"])
+			by, _ := json.Marshal(map[string]interface{}{
+				"query": map[string]interface{}{
+					"_id": bson.M{
+						"$gte": mongodb.StringTOBsonId(id),
+						"$lte": mongodb.StringTOBsonId(id),
+					}},
+				"stype": qu.ObjToString(indexNode["stype"]),
+				"coll":  coll,
+			})
+			addr := &net.UDPAddr{
+				IP:   net.ParseIP(indexNode["addr"].(string)),
+				Port: qu.IntAll(indexNode["port"]),
+			}
+			qu.Debug("udp---1---------", string(by))
+			Udpclient.WriteUdp(by, mu.OP_TYPE_DATA, addr)
+		}
+		//日志记录
+		user := jy.GetSession("user").(map[string]interface{})
+		log_data := map[string]interface{}{
+			"s_modifyuser":   user["name"],
+			"s_type":         2,
+			"i_modifytime":   time.Now().Unix(),
+			"s_modifyreason": "判重修改",
+			"s_backupid":     id,
+			"o_oldinfo":      *data,
+			"o_newinfo":      bson.M{"extracttype": et},
+			"modifyinfo":     "extracttype",
+		}
+		Mgo.Save(JyRecord, log_data)
+
+		jy.ServeJson(map[string]interface{}{
+			"rep": true,
+		})
+	}
+
+}
+
 // 删除
 func (jy *RepairRule) RepairDelete() {
 	defer qu.Catch()
@@ -368,14 +457,9 @@ func (jy *RepairRule) RepairDelete() {
 		})
 	} else {
 		//删除es
-		client := JyEs.GetEsConn()
-		defer JyEs.DestoryEsConn(client)
-
-		_, err := client.Delete().Index(EsIndex).Id(id).Refresh("true").Do(context.TODO())
-		if err != nil {
-			log.Println("delete es err:", err)
-		}
-
+		JyEs.DelById(EsIndex, id)
+		JyEs1.DelById(EsIndex, id)
+		JyEs1.DelById("bidding_temp", id)
 		//  fmt.Sprintf("jypcdetail_%s_%s_%s_%v_%v_%v_%s", userId, stype, sid, isVip, isEntniche, isMember, nodeStr)
 		//删除redis 指定key
 		delName1 := RedisDelKey1 + "*_" + "*_" + id
@@ -512,11 +596,16 @@ func (jy *RepairRule) RepairSave() {
 				record[k] = qu.IntAll(v)
 				(updata)[k] = qu.IntAll(v)
 			} else if k == "publishtime" || k == "bidopentime" {
-				(updata)[k] = qu.Int64All(v)
+				updata[k] = qu.Int64All(v)
 				record[k] = qu.Int64All(v)
 			} else if k == "budget" || k == "bidamount" {
-				(updata)[k] = qu.Float64All(v)
+				updata[k] = qu.Float64All(v)
 				record[k] = qu.Float64All(v)
+			} else if k == "s_winner" {
+				cid := companyFun(updata)
+				if len(cid) > 0 {
+					updata["entidlist"] = cid
+				}
 			} else {
 				record[k] = v
 			}
@@ -583,6 +672,9 @@ func (jy *RepairRule) RepairSave() {
 			//删除redis 指定key
 			delName1 := RedisDelKey1 + "*_" + "*_" + id
 			redis.DelByCodePattern(RedisJYName, delName1)
+			if updata["href"] != nil {
+
+			}
 			//jyredis := redis.RedisPool[RedisJYName].Get()
 			//defer jyredis.Close()
 			//if _, err := jyredis.Do("SELECT", 0); err != nil {
@@ -638,6 +730,29 @@ func (jy *RepairRule) RepairSave() {
 	}
 }
 
+// @Description entidlist
+// @Author J 2022/6/7 2:36 PM
+func companyFun(tmp map[string]interface{}) (cid []string) {
+	sWinnerarr := strings.Split(qu.ObjToString(tmp["s_winner"]), ",")
+	for _, w := range sWinnerarr {
+		if w != "" {
+			id := redis.GetStr("qyxy_id", w)
+			if id == "" {
+				ents, _ := EntMgo.Find("qyxy_std", map[string]interface{}{"company_name": w}, map[string]interface{}{"updatetime": -1}, map[string]interface{}{"company_name": 1}, false, -1, -1)
+				if len(*ents) > 0 {
+					id = qu.ObjToString((*ents)[0]["_id"])
+					redis.PutCKV("qyxy_id", w, id)
+				}
+			}
+			if id == "" {
+				id = "-"
+			}
+			cid = append(cid, id)
+		}
+	}
+	return cid
+}
+
 // 查询
 func (jy *RepairRule) SearchID() {
 	defer qu.Catch()
@@ -710,11 +825,10 @@ var hrefMt = regexp.MustCompile("(content|bdprivate|mailprivate|entservice|bdcon
 func (jy *RepairRule) SearchJyurl() {
 	defer qu.Catch()
 	if jy.Method() == "POST" {
-
 		jyurl := jy.GetString("jyurl")
 		jyurl, _ = url.QueryUnescape(jyurl)
 		if strings.Contains(jyurl, "page_workDesktop/work-bench") {
-			jyurl = rpreUrl.ReplaceAllString(jyurl, "")
+			jyurl, _ = url.QueryUnescape(rpreUrl.ReplaceAllString(jyurl, ""))
 		}
 		new_id := ""
 		if strings.Contains(jyurl, "content") {
@@ -730,7 +844,6 @@ func (jy *RepairRule) SearchJyurl() {
 			jyurl1 = rsuf.ReplaceAllString(jyurl1, "")
 			new_id = qu.CommonDecodeArticle("mailprivate", jyurl1)[0]
 		}
-		qu.Debug(new_id)
 		if !mongodb.IsObjectIdHex(new_id) {
 			jy.ServeJson(map[string]interface{}{
 				"rep": false,
@@ -787,7 +900,7 @@ func (jy *RepairRule) RepairRecord() {
 		query := bson.M{}
 		if search != "" {
 			query["$or"] = []interface{}{
-				//bson.M{"s_customer": bson.M{"$regex": search}},
+				bson.M{"s_modifyuser": bson.M{"$regex": search}},
 				//bson.M{"s_tagname": bson.M{"$regex": search}},
 			}
 		}
@@ -1116,13 +1229,9 @@ func ModifyData1(tmp map[string]interface{}, user map[string]interface{}) (err m
 	}
 
 	//删除es
-	client := JyEs.GetEsConn()
-	defer JyEs.DestoryEsConn(client)
-	_, err1 := client.Delete().Index(EsIndex).Id(id).Refresh("true").Do(context.TODO())
-	if err1 != nil {
-		log.Println("delete es err:", err1)
-	}
-
+	JyEs.DelById(EsIndex, id)
+	JyEs1.DelById(EsIndex, id)
+	JyEs1.DelById("bidding_temp", id)
 	// udp 项目
 	nextNode := *qu.ObjToMap(Sysconfig["jy_pro_node"])
 	by, _ := json.Marshal(map[string]interface{}{
@@ -1198,6 +1307,7 @@ func (jy *RepairRule) EsDelBy() {
 	count, _ := jy.GetInt("count")
 	esquery := `{"query":{"bool":{"must":[{"term":{"` + field + `":"` + value + `"}}]}}}`
 	bol := JyEs.Del(EsIndex, EsType, esquery)
+	JyEs1.Del(EsIndex, EsType, esquery)
 	Mgo.Save("jy_es_del_log", bson.M{"type": field, "value": value, "count": count, "createtime": time.Now().Unix()})
 	jy.ServeJson(map[string]interface{}{
 		"rep": bol,
@@ -1400,6 +1510,7 @@ func (jy *RepairRule) UpFile() {
 					attsmap["attachments"] = tmp
 					updateMap := make(map[string]interface{})
 					updateMap["projectinfo"] = attsmap
+					updateMap["isValidFile"] = true
 					JYMgo.UpdateById(coll, id, map[string]interface{}{"$set": updateMap})
 				}
 			} else {

+ 24 - 4
src/util/config.go

@@ -14,14 +14,13 @@ var (
 	MgoCus          *mongodb.MongodbSim //企业服务库
 	JYMgo           *mongodb.MongodbSim
 	OprdMgo         *mongodb.MongodbSim
-	MgoEn           *mongodb.MongodbSim
+	EntMgo          *mongodb.MongodbSim
 	JyProMgo        *mongodb.MongodbSim
 	MgoS            *mongodb.MongodbSim
 	MgoPy           *mongodb.MongodbSim
 	MgoEdit         *mongodb.MongodbSim
-	JyEs            *Elastic
+	JyEs, JyEs1     *Elastic
 	EsIndex, EsType string
-	MgoEnC          string
 	JyCollNameOne   string
 	JyCollNameTwo   string
 	JyRecord        string
@@ -115,6 +114,18 @@ func initJYMgo() {
 	}
 	JyProColl = qu.ObjToString(jypro["coll"])
 	JyProMgo.InitPool()
+
+	entmgo := *qu.ObjToMap(Sysconfig["entmgo"])
+	EntMgo = &mongodb.MongodbSim{
+		MongodbAddr: qu.ObjToString(entmgo["jyaddr"]),
+		Size:        qu.IntAll(entmgo["jydbsize"]),
+		DbName:      qu.ObjToString(entmgo["jydbname"]),
+		UserName:    qu.ObjToString(Sysconfig["uname"]),
+		Password:    qu.ObjToString(Sysconfig["upwd"]),
+	}
+	EntMgo.InitPool()
+	
+
 }
 
 func initJYRedis() {
@@ -142,6 +153,8 @@ func InitOther() {
 	initEs()
 	initJYMgo()
 	initJYRedis()
+
+	redis.InitRedis1("qyxy_id=172.17.4.189:8379", 4)
 }
 
 func initCitys() {
@@ -209,6 +222,13 @@ func initEs() {
 		Username: "es_all",
 		Password: "TopJkO2E_d1x",
 	}
-
 	JyEs.InitElasticSize()
+
+	JyEs1 = &Elastic{
+		S_esurl:  qu.ObjToString(Sysconfig["elasticsearch1"]),
+		I_size:   qu.IntAllDef(qu.Int64All(Sysconfig["elasticPoolSize"]), 30),
+		Username: "jybid",
+		Password: "Top2023_JEB01i@31",
+	}
+	JyEs1.InitElasticSize()
 }

+ 6 - 6
src/util/elasticSim.go

@@ -38,7 +38,7 @@ func (e *Elastic) InitElasticSize() {
 	}
 }
 
-//关闭连接
+// 关闭连接
 func (e *Elastic) DestoryEsConn(client *es.Client) {
 	select {
 	case e.Pool <- client:
@@ -128,7 +128,7 @@ func (e *Elastic) Get(index, query string) *[]map[string]interface{} {
 	return &res
 }
 
-//关闭elastic
+// 关闭elastic
 func (e *Elastic) Close() {
 	for i := 0; i < e.I_size; i++ {
 		cli := <-e.Pool
@@ -181,14 +181,14 @@ func (e *Elastic) BulkSave(index string, obj []map[string]interface{}) {
 	}
 }
 
-//根据id删除索引对象
-func (e *Elastic) DelById(index, itype, id string) bool {
+// 根据id删除索引对象
+func (e *Elastic) DelById(index, id string) bool {
 	client := e.GetEsConn()
 	defer e.DestoryEsConn(client)
 	b := false
 	if client != nil {
 		var err error
-		_, err = client.Delete().Index(index).Type(itype).Id(id).Do(context.Background())
+		_, err = client.Delete().Index(index).Id(id).Do(context.Background())
 		if err != nil {
 			log.Println("更新检索出错:", err.Error())
 		} else {
@@ -304,7 +304,7 @@ func (e *Elastic) Count(index, itype string, query interface{}) int64 {
 	return 0
 }
 
-//删除某个索引,根据查询
+// 删除某个索引,根据查询
 func (e *Elastic) Del(index, itype string, query interface{}) bool {
 	client := e.GetEsConn()
 	defer e.DestoryEsConn(client)

+ 99 - 3
src/web/templates/repair/jy_repair.html

@@ -122,11 +122,64 @@
     </div><!-- /.modal -->
 </div>
 
+<!-- 判重修改model -->
+<div class="modal fade" id="modal-repair" tabindex="-1" role="dialog" aria-hidden="true">
+    <div class="modal-dialog" style="width: 70%">
+        <div class="modal-content">
+            <div class="modal-header">
+                <div class="modal-header">
+                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
+                    <div class="edit-form">
+                        <div class="edit-info">
+                            <span class="info"><i class="fa fa-fw fa-tags fa-lg"></i>修改数据</span>
+                        </div>
+                        <div class="content modal-content">
+                            <form class="form-horizontal">
+                                <div class="box-body">
+                                    <div class="form-group">
+                                        <div class="form-group">
+                                            <label class="col-sm-2 control-label">标题</label>
+                                            <div class="col-sm-6">
+                                                <input type="text" class="form-control" id="title" value="" readonly>
+                                            </div>
+                                        </div>
+                                    </div>
+                                    <div class="form-group">
+                                        <div class="form-group">
+                                            <label class="col-sm-2 control-label">判重结果</label>
+                                            <div class="col-sm-3">
+                                                <input type="text" class="form-control" id="repeat" placeholder="1(不重复数据), -1(重复数据)">
+                                            </div>
+                                        </div>
+                                    </div>
+                                    <div class="form-group">
+                                        <div class="form-group">
+                                            <label class="col-sm-2 control-label">重复数据ID</label>
+                                            <div class="col-sm-3">
+                                                <input type="text" class="form-control" id="repeatId" placeholder="重复数据ID">
+                                            </div>
+                                        </div>
+                                    </div>
+                                </div>
+                            </form>
+                        </div>
+                    </div>
+                </div>
+                <div class="modal-footer">
+                    <input type="button" onclick="saveModify1()" class="btn btn-primary saveBtn" value="保存">
+                    <input type="button" onclick="cancelModel()" class="btn btn-default" style="margin-left: 24px" value="取消">
+                </div>
+            </div>
+        </div>
+    </div><!-- /.modal -->
+</div>
+
 {{include "com/footer.html"}}
 <script>
     menuActive("/jy/repair");
 
     var curColl = ""
+    var curId = ""
 
     $(document).ready(function () {
         ttable = $('#dataTable').DataTable({
@@ -176,7 +229,9 @@
                     }},
                 {"data": "_id", width:"20%",render: function (val, a, row, pos) {
                         tmp = '<div>' +
-                            '<a class="btn btn-sm btn-primary" href="/service/jy/edit?id='+val+'&coll='+curColl+'">编辑</a>'+
+                            '<a class="btn btn-sm btn-primary" href="/service/jy/edit?id='+val+'&coll='+curColl+'">修改</a>'+
+                            '&nbsp'+'&nbsp'+
+                            '<a class="btn btn-sm btn-info" onclick="repair(\''+val+'\')">判重修改</a>'+
                             '&nbsp'+'&nbsp'+//href="/service/jy/edit?id='+val+'
                             '<a class="btn btn-sm btn-danger" onclick="del_repair(\''+val+'\',\''+curColl+'\')">删除</a>'+
                             '</div>';
@@ -205,11 +260,11 @@
         })
     }
     function jyurlSearch() {
-        var search_name = $('#jyurlSea').val()
+        let search_name = $('#jyurlSea').val()
         $.ajax({
             url:"/service/jy/searchJyurl",
             type:"post",
-            data:{"jyurl": search_name},
+            data:{"jyurl": encodeURIComponent(search_name)},
             success:function(r){
                 if (r.rep) {
                     curColl = r.orgColl
@@ -240,6 +295,47 @@
         })
     }
 
+    function repair(id){
+        $.ajax({
+            url:"/service/jy/editRepeat",
+            type:"post",
+            data:{"_id": id,"coll":curColl},
+            success:function(r){
+                if(r.rep){
+                    curId = id
+                    $('#title').val(r.data.title)
+                    $('#repeat').val(r.data.extracttype)
+                    $('#repeatId').val(r.data.repeat_id)
+                    $('#modal-repair').modal("show")
+                }else{
+                    alert("查询失败");
+                }
+            }
+        })
+    }
+
+    function saveModify1(){
+        const et = $('#repeat').val()
+        const rid = $('#repeatId').val()
+        $.ajax({
+            url:"/service/jy/editRepeat/save",
+            type:"post",
+            data:{"_id": curId,"coll":curColl, "etype": et, "rid": rid},
+            success:function(r){
+                if(r.rep){
+                    $('#modal-repair').modal("hide")
+                    alert("保存成功");
+                }else{
+                    alert("保存失败");
+                }
+            }
+        })
+    }
+
+    function cancelModel() {
+        $('#modal-repair').modal("hide")
+    }
+
     function del_repair(del_id,coll){
         showConfirm("确定删除?", function() {
             $.ajax({