|
@@ -2,7 +2,6 @@ package service
|
|
|
|
|
|
import (
|
|
import (
|
|
"bytes"
|
|
"bytes"
|
|
- "context"
|
|
|
|
"encoding/json"
|
|
"encoding/json"
|
|
"fmt"
|
|
"fmt"
|
|
"github.com/go-xweb/xweb"
|
|
"github.com/go-xweb/xweb"
|
|
@@ -43,6 +42,8 @@ type RepairRule struct {
|
|
searchJyurl xweb.Mapper `xweb:"/service/jy/searchJyurl"`
|
|
searchJyurl xweb.Mapper `xweb:"/service/jy/searchJyurl"`
|
|
searchSha xweb.Mapper `xweb:"/service/jy/searchSha"`
|
|
searchSha xweb.Mapper `xweb:"/service/jy/searchSha"`
|
|
repairEdit xweb.Mapper `xweb:"/service/jy/edit"`
|
|
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"`
|
|
repairDelete xweb.Mapper `xweb:"/service/jy/delete"`
|
|
repairSave xweb.Mapper `xweb:"/service/jy/save"`
|
|
repairSave xweb.Mapper `xweb:"/service/jy/save"`
|
|
repairCreate xweb.Mapper `xweb:"/service/jy/create"`
|
|
repairCreate xweb.Mapper `xweb:"/service/jy/create"`
|
|
@@ -123,10 +124,11 @@ func (jy *RepairRule) RepairNewSave() {
|
|
|
|
|
|
//处理个别字段
|
|
//处理个别字段
|
|
(*updata)["_id"] = primitive.NewObjectID()
|
|
(*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
|
|
// spider_code
|
|
(*updata)["spidercode"] = AddSpiderCode
|
|
(*updata)["spidercode"] = AddSpiderCode
|
|
@@ -352,6 +354,93 @@ func (jy *RepairRule) RepairEdit() {
|
|
jy.Render("repair/jy_edit.html", &jy.T)
|
|
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() {
|
|
func (jy *RepairRule) RepairDelete() {
|
|
defer qu.Catch()
|
|
defer qu.Catch()
|
|
@@ -368,14 +457,9 @@ func (jy *RepairRule) RepairDelete() {
|
|
})
|
|
})
|
|
} else {
|
|
} else {
|
|
//删除es
|
|
//删除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)
|
|
// fmt.Sprintf("jypcdetail_%s_%s_%s_%v_%v_%v_%s", userId, stype, sid, isVip, isEntniche, isMember, nodeStr)
|
|
//删除redis 指定key
|
|
//删除redis 指定key
|
|
delName1 := RedisDelKey1 + "*_" + "*_" + id
|
|
delName1 := RedisDelKey1 + "*_" + "*_" + id
|
|
@@ -512,11 +596,16 @@ func (jy *RepairRule) RepairSave() {
|
|
record[k] = qu.IntAll(v)
|
|
record[k] = qu.IntAll(v)
|
|
(updata)[k] = qu.IntAll(v)
|
|
(updata)[k] = qu.IntAll(v)
|
|
} else if k == "publishtime" || k == "bidopentime" {
|
|
} else if k == "publishtime" || k == "bidopentime" {
|
|
- (updata)[k] = qu.Int64All(v)
|
|
|
|
|
|
+ updata[k] = qu.Int64All(v)
|
|
record[k] = qu.Int64All(v)
|
|
record[k] = qu.Int64All(v)
|
|
} else if k == "budget" || k == "bidamount" {
|
|
} else if k == "budget" || k == "bidamount" {
|
|
- (updata)[k] = qu.Float64All(v)
|
|
|
|
|
|
+ updata[k] = qu.Float64All(v)
|
|
record[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 {
|
|
} else {
|
|
record[k] = v
|
|
record[k] = v
|
|
}
|
|
}
|
|
@@ -583,6 +672,9 @@ func (jy *RepairRule) RepairSave() {
|
|
//删除redis 指定key
|
|
//删除redis 指定key
|
|
delName1 := RedisDelKey1 + "*_" + "*_" + id
|
|
delName1 := RedisDelKey1 + "*_" + "*_" + id
|
|
redis.DelByCodePattern(RedisJYName, delName1)
|
|
redis.DelByCodePattern(RedisJYName, delName1)
|
|
|
|
+ if updata["href"] != nil {
|
|
|
|
+
|
|
|
|
+ }
|
|
//jyredis := redis.RedisPool[RedisJYName].Get()
|
|
//jyredis := redis.RedisPool[RedisJYName].Get()
|
|
//defer jyredis.Close()
|
|
//defer jyredis.Close()
|
|
//if _, err := jyredis.Do("SELECT", 0); err != nil {
|
|
//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() {
|
|
func (jy *RepairRule) SearchID() {
|
|
defer qu.Catch()
|
|
defer qu.Catch()
|
|
@@ -710,11 +825,10 @@ var hrefMt = regexp.MustCompile("(content|bdprivate|mailprivate|entservice|bdcon
|
|
func (jy *RepairRule) SearchJyurl() {
|
|
func (jy *RepairRule) SearchJyurl() {
|
|
defer qu.Catch()
|
|
defer qu.Catch()
|
|
if jy.Method() == "POST" {
|
|
if jy.Method() == "POST" {
|
|
-
|
|
|
|
jyurl := jy.GetString("jyurl")
|
|
jyurl := jy.GetString("jyurl")
|
|
jyurl, _ = url.QueryUnescape(jyurl)
|
|
jyurl, _ = url.QueryUnescape(jyurl)
|
|
if strings.Contains(jyurl, "page_workDesktop/work-bench") {
|
|
if strings.Contains(jyurl, "page_workDesktop/work-bench") {
|
|
- jyurl = rpreUrl.ReplaceAllString(jyurl, "")
|
|
|
|
|
|
+ jyurl, _ = url.QueryUnescape(rpreUrl.ReplaceAllString(jyurl, ""))
|
|
}
|
|
}
|
|
new_id := ""
|
|
new_id := ""
|
|
if strings.Contains(jyurl, "content") {
|
|
if strings.Contains(jyurl, "content") {
|
|
@@ -730,7 +844,6 @@ func (jy *RepairRule) SearchJyurl() {
|
|
jyurl1 = rsuf.ReplaceAllString(jyurl1, "")
|
|
jyurl1 = rsuf.ReplaceAllString(jyurl1, "")
|
|
new_id = qu.CommonDecodeArticle("mailprivate", jyurl1)[0]
|
|
new_id = qu.CommonDecodeArticle("mailprivate", jyurl1)[0]
|
|
}
|
|
}
|
|
- qu.Debug(new_id)
|
|
|
|
if !mongodb.IsObjectIdHex(new_id) {
|
|
if !mongodb.IsObjectIdHex(new_id) {
|
|
jy.ServeJson(map[string]interface{}{
|
|
jy.ServeJson(map[string]interface{}{
|
|
"rep": false,
|
|
"rep": false,
|
|
@@ -787,7 +900,7 @@ func (jy *RepairRule) RepairRecord() {
|
|
query := bson.M{}
|
|
query := bson.M{}
|
|
if search != "" {
|
|
if search != "" {
|
|
query["$or"] = []interface{}{
|
|
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}},
|
|
//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
|
|
//删除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 项目
|
|
// udp 项目
|
|
nextNode := *qu.ObjToMap(Sysconfig["jy_pro_node"])
|
|
nextNode := *qu.ObjToMap(Sysconfig["jy_pro_node"])
|
|
by, _ := json.Marshal(map[string]interface{}{
|
|
by, _ := json.Marshal(map[string]interface{}{
|
|
@@ -1198,6 +1307,7 @@ func (jy *RepairRule) EsDelBy() {
|
|
count, _ := jy.GetInt("count")
|
|
count, _ := jy.GetInt("count")
|
|
esquery := `{"query":{"bool":{"must":[{"term":{"` + field + `":"` + value + `"}}]}}}`
|
|
esquery := `{"query":{"bool":{"must":[{"term":{"` + field + `":"` + value + `"}}]}}}`
|
|
bol := JyEs.Del(EsIndex, EsType, esquery)
|
|
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()})
|
|
Mgo.Save("jy_es_del_log", bson.M{"type": field, "value": value, "count": count, "createtime": time.Now().Unix()})
|
|
jy.ServeJson(map[string]interface{}{
|
|
jy.ServeJson(map[string]interface{}{
|
|
"rep": bol,
|
|
"rep": bol,
|
|
@@ -1400,6 +1510,7 @@ func (jy *RepairRule) UpFile() {
|
|
attsmap["attachments"] = tmp
|
|
attsmap["attachments"] = tmp
|
|
updateMap := make(map[string]interface{})
|
|
updateMap := make(map[string]interface{})
|
|
updateMap["projectinfo"] = attsmap
|
|
updateMap["projectinfo"] = attsmap
|
|
|
|
+ updateMap["isValidFile"] = true
|
|
JYMgo.UpdateById(coll, id, map[string]interface{}{"$set": updateMap})
|
|
JYMgo.UpdateById(coll, id, map[string]interface{}{"$set": updateMap})
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|