|
@@ -56,6 +56,7 @@ const (
|
|
|
|
|
|
func UtilEsSaveData(sdataid string, datas *[]map[string]interface{}) error {
|
|
|
defer qu.Catch()
|
|
|
+ log.Println("保存数据---", sdataid)
|
|
|
if !Mgo.Del("tagsdata", bson.M{"s_dataid": sdataid}) {
|
|
|
return errors.New("mongo del err")
|
|
|
}
|
|
@@ -80,9 +81,11 @@ func (m *MySource) Source() (interface{}, error) {
|
|
|
return mp["query"], nil
|
|
|
}
|
|
|
|
|
|
+// data_result, 0: 数据生成中,1: 成功,-1: 失败
|
|
|
// 客户规则
|
|
|
-func UtilEsFind1(tags map[string]interface{}) (error, int64) {
|
|
|
+func UtilEsFind1(tags map[string]interface{}) {
|
|
|
defer qu.Catch()
|
|
|
+ Mgo.UpdateById("entniche_rule", tags["_id"], bson.M{"$set": bson.M{"data_result": 0}})
|
|
|
ch := make(chan bool, 20)
|
|
|
wg := &sync.WaitGroup{}
|
|
|
arrsync := &sync.RWMutex{}
|
|
@@ -94,7 +97,9 @@ func UtilEsFind1(tags map[string]interface{}) (error, int64) {
|
|
|
clearKey := qu.ObjToString(tags["s_globalclearkey"])
|
|
|
clearKeyMatch := qu.ObjToString(tags["s_globalclearkeymatch"])
|
|
|
if len(esquery) < 1 || len(sdataid) < 1 {
|
|
|
- return errors.New("s_esquery or s_dataid no found"), 0
|
|
|
+ log.Println("s_esquery or s_dataid no found")
|
|
|
+ Mgo.UpdateById("entniche_rule", tags["_id"], bson.M{"$set": bson.M{"data_result": -1}})
|
|
|
+ return
|
|
|
}
|
|
|
i_maxnum := qu.Int64All(tags["i_maxnum"])
|
|
|
if i_maxnum <= 0 {
|
|
@@ -118,7 +123,9 @@ func UtilEsFind1(tags map[string]interface{}) (error, int64) {
|
|
|
})
|
|
|
}
|
|
|
} else {
|
|
|
- return errors.New("o_rules no found"), 0
|
|
|
+ log.Println("o_rules no found")
|
|
|
+ Mgo.UpdateById("entniche_rule", tags["_id"], bson.M{"$set": bson.M{"data_result": -1}})
|
|
|
+ return
|
|
|
}
|
|
|
ctx, _ := context.WithTimeout(context.Background(), 1*time.Hour)
|
|
|
esCon := elastic.VarEs.(*elastic.EsV7)
|
|
@@ -139,10 +146,8 @@ func UtilEsFind1(tags map[string]interface{}) (error, int64) {
|
|
|
go func(tmpHit *es.SearchHit) {
|
|
|
defer func() {
|
|
|
<-ch
|
|
|
- arrsync.Unlock()
|
|
|
wg.Done()
|
|
|
}()
|
|
|
- arrsync.Lock()
|
|
|
item := make(map[string]interface{})
|
|
|
if json.Unmarshal(tmpHit.Source, &item) == nil {
|
|
|
item["appid"] = tags["appid"]
|
|
@@ -150,8 +155,6 @@ func UtilEsFind1(tags map[string]interface{}) (error, int64) {
|
|
|
info_id := qu.ObjToString(item["id"])
|
|
|
item["info_id"] = info_id
|
|
|
item["s_dataid"] = sdataid
|
|
|
- // item["s_jyhref"] = fmt.Sprintf(Url, util.CommonEncodeArticle("content", info_id))
|
|
|
- //
|
|
|
subType := qu.ObjToString(item["subtype"])
|
|
|
subTypeStr := "拟建,采购意向,预告,预审,预审结果,论证意见,需求公示"
|
|
|
if strings.Contains(subTypeStr, subType) {
|
|
@@ -223,8 +226,8 @@ func UtilEsFind1(tags map[string]interface{}) (error, int64) {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- //匹配公告附件
|
|
|
- info, _ := MgoBidding.FindOne("bidding", bson.M{"_id": mongodb.StringTOBsonId(info_id)})
|
|
|
+ //匹配公告附件和链接
|
|
|
+ info, _ := MgoBidding.FindOneByField("bidding", bson.M{"_id": mongodb.StringTOBsonId(info_id)}, bson.M{"projectinfo": 1, "competehref": 1})
|
|
|
if info != nil {
|
|
|
log.Println("匹配附件, id-", item["info_id"])
|
|
|
if (*info)["projectinfo"] != nil {
|
|
@@ -261,6 +264,13 @@ func UtilEsFind1(tags map[string]interface{}) (error, int64) {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+ if (*info)["competehref"] != nil {
|
|
|
+ if href := qu.ObjToString(item["href"]); strings.Contains(href, "https://www.jianyu360.cn") {
|
|
|
+ if qu.ObjToString(item["competehref"]) != "" && qu.ObjToString(item["competehref"]) != "#" {
|
|
|
+ item["href"] = qu.ObjToString(item["competehref"])
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
} else {
|
|
|
log.Println("id", item["info_id"], "bidding为空")
|
|
|
}
|
|
@@ -269,7 +279,10 @@ func UtilEsFind1(tags map[string]interface{}) (error, int64) {
|
|
|
//if projectId != "" {
|
|
|
// item["projectId"] = SE2.EncodeString(projectId)
|
|
|
//}
|
|
|
+
|
|
|
+ arrsync.Lock()
|
|
|
datas = append(datas, item)
|
|
|
+ arrsync.Unlock()
|
|
|
} else {
|
|
|
log.Println("id", item["_id"], "信息为空")
|
|
|
}
|
|
@@ -282,10 +295,11 @@ func UtilEsFind1(tags map[string]interface{}) (error, int64) {
|
|
|
"$set": bson.M{
|
|
|
"i_estotal": count,
|
|
|
}}, false, false)
|
|
|
- return UtilEsSaveData(sdataid, &datas), count
|
|
|
+ UtilEsSaveData(sdataid, &datas)
|
|
|
+ Mgo.UpdateById("entniche_rule", tags["_id"], bson.M{"$set": bson.M{"data_result": 1}})
|
|
|
} else {
|
|
|
log.Println(err)
|
|
|
- return err, 0
|
|
|
+ Mgo.UpdateById("entniche_rule", tags["_id"], bson.M{"$set": bson.M{"data_result": -1}})
|
|
|
}
|
|
|
}
|
|
|
|