|
@@ -8,6 +8,7 @@ import (
|
|
"encoding/json"
|
|
"encoding/json"
|
|
"esindex/config"
|
|
"esindex/config"
|
|
"esindex/oss"
|
|
"esindex/oss"
|
|
|
|
+ "go.mongodb.org/mongo-driver/bson"
|
|
"go.uber.org/zap"
|
|
"go.uber.org/zap"
|
|
"reflect"
|
|
"reflect"
|
|
"regexp"
|
|
"regexp"
|
|
@@ -15,7 +16,6 @@ import (
|
|
"strings"
|
|
"strings"
|
|
"sync"
|
|
"sync"
|
|
"time"
|
|
"time"
|
|
- "unicode/utf8"
|
|
|
|
)
|
|
)
|
|
|
|
|
|
var (
|
|
var (
|
|
@@ -24,12 +24,18 @@ var (
|
|
TimeClear = regexp.MustCompile("[年|月|/|.|-]")
|
|
TimeClear = regexp.MustCompile("[年|月|/|.|-]")
|
|
filterSpace = regexp.MustCompile("<[^>]*?>|[\\s\u3000\u2003\u00a0]")
|
|
filterSpace = regexp.MustCompile("<[^>]*?>|[\\s\u3000\u2003\u00a0]")
|
|
date1 = regexp.MustCompile("20[0-2][0-9][年|\\-/.][0-9]{1,2}[月|\\-/.][0-9]{1,2}[日]?")
|
|
date1 = regexp.MustCompile("20[0-2][0-9][年|\\-/.][0-9]{1,2}[月|\\-/.][0-9]{1,2}[日]?")
|
|
|
|
+ HtmlReg = regexp.MustCompile("<[^>]+>")
|
|
)
|
|
)
|
|
|
|
|
|
func biddingTask(mapInfo map[string]interface{}) {
|
|
func biddingTask(mapInfo map[string]interface{}) {
|
|
defer util.Catch()
|
|
defer util.Catch()
|
|
|
|
|
|
stype := util.ObjToString(mapInfo["stype"])
|
|
stype := util.ObjToString(mapInfo["stype"])
|
|
|
|
+ if stype == "bidding" {
|
|
|
|
+ uq := bson.M{"gtid": bson.M{"$gte": util.ObjToString(mapInfo["gtid"])},
|
|
|
|
+ "lteid": bson.M{"$lte": util.ObjToString(mapInfo["lteid"])}}
|
|
|
|
+ MgoB.Update("bidding_processing_ids", uq, bson.M{"$set": bson.M{"dataprocess": 8, "updatetime": time.Now().Unix()}}, false, false)
|
|
|
|
+ }
|
|
q, _ := mapInfo["query"].(map[string]interface{})
|
|
q, _ := mapInfo["query"].(map[string]interface{})
|
|
if q == nil {
|
|
if q == nil {
|
|
q = map[string]interface{}{
|
|
q = map[string]interface{}{
|
|
@@ -53,7 +59,7 @@ func biddingTask(mapInfo map[string]interface{}) {
|
|
c1, index := 0, 0
|
|
c1, index := 0, 0
|
|
var indexLock sync.Mutex
|
|
var indexLock sync.Mutex
|
|
for tmp := make(map[string]interface{}); it.Next(tmp); c1++ {
|
|
for tmp := make(map[string]interface{}); it.Next(tmp); c1++ {
|
|
- if count%1000 == 0 {
|
|
|
|
|
|
+ if c1%1000 == 0 {
|
|
log.Info("biddingTask", zap.Int("current:", c1))
|
|
log.Info("biddingTask", zap.Int("current:", c1))
|
|
}
|
|
}
|
|
ch <- true
|
|
ch <- true
|
|
@@ -67,25 +73,29 @@ func biddingTask(mapInfo map[string]interface{}) {
|
|
tmp = make(map[string]interface{})
|
|
tmp = make(map[string]interface{})
|
|
return
|
|
return
|
|
}
|
|
}
|
|
- if util.IntAll(tmp["dataprocess"]) == 8 {
|
|
|
|
- indexLock.Lock()
|
|
|
|
- index++
|
|
|
|
- indexLock.Unlock()
|
|
|
|
- newTmp, update := GetEsField(tmp, stype)
|
|
|
|
- newTmp["dataweight"] = 0 //索引数据新增 jy置顶字段
|
|
|
|
- if len(update) > 0 {
|
|
|
|
- updateBiddingPool <- []map[string]interface{}{{
|
|
|
|
- "_id": tmp["_id"],
|
|
|
|
- },
|
|
|
|
- {"$set": update},
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- if util.ObjToString(newTmp["spidercode"]) == "a_jyxxfbpt_gg" {
|
|
|
|
- // 剑鱼信息发布数据 通过udp通知信息发布程序
|
|
|
|
- go UdpMethod(mongodb.BsonIdToSId(newTmp["_id"]))
|
|
|
|
|
|
+ if util.IntAll(tmp["dataprocess"]) != 8 {
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ if stype == "bidding_history" && tmp["history_updatetime"] == nil {
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ indexLock.Lock()
|
|
|
|
+ index++
|
|
|
|
+ indexLock.Unlock()
|
|
|
|
+ newTmp, update := GetEsField(tmp, stype)
|
|
|
|
+ newTmp["dataweight"] = 0 //索引数据新增 jy置顶字段
|
|
|
|
+ if len(update) > 0 {
|
|
|
|
+ updateBiddingPool <- []map[string]interface{}{{
|
|
|
|
+ "_id": tmp["_id"],
|
|
|
|
+ },
|
|
|
|
+ {"$set": update},
|
|
}
|
|
}
|
|
- saveEsPool <- newTmp
|
|
|
|
}
|
|
}
|
|
|
|
+ if util.ObjToString(newTmp["spidercode"]) == "a_jyxxfbpt_gg" {
|
|
|
|
+ // 剑鱼信息发布数据 通过udp通知信息发布程序
|
|
|
|
+ go UdpMethod(mongodb.BsonIdToSId(newTmp["_id"]))
|
|
|
|
+ }
|
|
|
|
+ saveEsPool <- newTmp
|
|
}(tmp)
|
|
}(tmp)
|
|
tmp = map[string]interface{}{}
|
|
tmp = map[string]interface{}{}
|
|
}
|
|
}
|
|
@@ -93,6 +103,68 @@ func biddingTask(mapInfo map[string]interface{}) {
|
|
log.Info("biddingTask over", zap.Int("count", c1), zap.Int("index", index))
|
|
log.Info("biddingTask over", zap.Int("count", c1), zap.Int("index", index))
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+func biddingAllTask(mapInfo map[string]interface{}) {
|
|
|
|
+ defer util.Catch()
|
|
|
|
+
|
|
|
|
+ stype := util.ObjToString(mapInfo["stype"])
|
|
|
|
+ q, _ := mapInfo["query"].(map[string]interface{})
|
|
|
|
+ if q == nil {
|
|
|
|
+ q = map[string]interface{}{
|
|
|
|
+ "_id": map[string]interface{}{
|
|
|
|
+ "$gt": mongodb.StringTOBsonId(mapInfo["gtid"].(string)),
|
|
|
|
+ "$lte": mongodb.StringTOBsonId(mapInfo["lteid"].(string)),
|
|
|
|
+ },
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ ch := make(chan bool, 20)
|
|
|
|
+ wg := &sync.WaitGroup{}
|
|
|
|
+
|
|
|
|
+ //bidding库
|
|
|
|
+ biddingConn := MgoB.GetMgoConn()
|
|
|
|
+ it := biddingConn.DB(config.Conf.DB.MongoB.Dbname).C(config.Conf.DB.MongoB.Coll).Find(&q).Select(map[string]interface{}{
|
|
|
|
+ "contenthtml": 0,
|
|
|
|
+ }).Sort("-_id").Iter()
|
|
|
|
+ c1, index := 0, 0
|
|
|
|
+ var indexLock sync.Mutex
|
|
|
|
+ for tmp := make(map[string]interface{}); it.Next(tmp); c1++ {
|
|
|
|
+ if c1%20000 == 0 {
|
|
|
|
+ log.Info("biddingAllTask", zap.Int("current:", c1))
|
|
|
|
+ }
|
|
|
|
+ ch <- true
|
|
|
|
+ wg.Add(1)
|
|
|
|
+ go func(tmp map[string]interface{}) {
|
|
|
|
+ defer func() {
|
|
|
|
+ <-ch
|
|
|
|
+ wg.Done()
|
|
|
|
+ }()
|
|
|
|
+ if sensitive := util.ObjToString(tmp["sensitive"]); sensitive == "测试" { //bidding中有敏感词,不生索引
|
|
|
|
+ tmp = make(map[string]interface{})
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ if util.IntAll(tmp["extracttype"]) == -1 {
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ indexLock.Lock()
|
|
|
|
+ index++
|
|
|
|
+ indexLock.Unlock()
|
|
|
|
+ newTmp, update := GetEsField(tmp, stype)
|
|
|
|
+ newTmp["dataweight"] = 0 //索引数据新增 jy置顶字段
|
|
|
|
+ if len(update) > 0 {
|
|
|
|
+ updateBiddingPool <- []map[string]interface{}{{
|
|
|
|
+ "_id": tmp["_id"],
|
|
|
|
+ },
|
|
|
|
+ {"$set": update},
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ saveEsPool <- newTmp
|
|
|
|
+ }(tmp)
|
|
|
|
+ tmp = map[string]interface{}{}
|
|
|
|
+ }
|
|
|
|
+ wg.Wait()
|
|
|
|
+ log.Info("biddingAllTask over", zap.Int("count", c1), zap.Int("index", index))
|
|
|
|
+}
|
|
|
|
+
|
|
func biddingTaskById(mapInfo map[string]interface{}) {
|
|
func biddingTaskById(mapInfo map[string]interface{}) {
|
|
defer util.Catch()
|
|
defer util.Catch()
|
|
|
|
|
|
@@ -121,23 +193,10 @@ func biddingTaskById(mapInfo map[string]interface{}) {
|
|
func GetEsField(tmp map[string]interface{}, stype string) (map[string]interface{}, map[string]interface{}) {
|
|
func GetEsField(tmp map[string]interface{}, stype string) (map[string]interface{}, map[string]interface{}) {
|
|
newTmp := make(map[string]interface{})
|
|
newTmp := make(map[string]interface{})
|
|
update := make(map[string]interface{}) // bidding 修改字段
|
|
update := make(map[string]interface{}) // bidding 修改字段
|
|
|
|
+ saveErr := make(map[string]interface{})
|
|
for field, ftype := range config.Conf.DB.Es.FieldEs {
|
|
for field, ftype := range config.Conf.DB.Es.FieldEs {
|
|
if tmp[field] != nil { //
|
|
if tmp[field] != nil { //
|
|
- if field == "projectinfo" {
|
|
|
|
- mp, _ := tmp[field].(map[string]interface{})
|
|
|
|
- if mp != nil {
|
|
|
|
- newmap := map[string]interface{}{}
|
|
|
|
- for k, ktype := range config.Conf.DB.Es.FieldProjectInfo {
|
|
|
|
- mpv := mp[k]
|
|
|
|
- if mpv != nil && reflect.TypeOf(mpv).String() == ktype {
|
|
|
|
- newmap[k] = mp[k]
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- if len(newmap) > 0 {
|
|
|
|
- newTmp[field] = newmap
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- } else if field == "purchasinglist" { //标的物处理
|
|
|
|
|
|
+ if field == "purchasinglist" { //标的物处理
|
|
purchasinglist_new := []map[string]interface{}{}
|
|
purchasinglist_new := []map[string]interface{}{}
|
|
if pcl, _ := tmp[field].([]interface{}); len(pcl) > 0 {
|
|
if pcl, _ := tmp[field].([]interface{}); len(pcl) > 0 {
|
|
for _, ls := range pcl {
|
|
for _, ls := range pcl {
|
|
@@ -169,14 +228,16 @@ func GetEsField(tmp map[string]interface{}, stype string) (map[string]interface{
|
|
p2[k] = util.ObjToString(tmp["projectname"])
|
|
p2[k] = util.ObjToString(tmp["projectname"])
|
|
} else if k == "buyer" && util.ObjToString(p1[k]) == "" && util.ObjToString(tmp["buyer"]) != "" {
|
|
} else if k == "buyer" && util.ObjToString(p1[k]) == "" && util.ObjToString(tmp["buyer"]) != "" {
|
|
p2[k] = util.ObjToString(tmp["buyer"])
|
|
p2[k] = util.ObjToString(tmp["buyer"])
|
|
- } else if k == "expurasingtime" && util.ObjToString(p1[k]) != "" {
|
|
|
|
- res := getMethod(util.ObjToString(p1[k]))
|
|
|
|
- if res != 0 {
|
|
|
|
- p2[k] = res
|
|
|
|
- }
|
|
|
|
} else if p1[k] != nil && reflect.TypeOf(p1[k]).String() == v {
|
|
} else if p1[k] != nil && reflect.TypeOf(p1[k]).String() == v {
|
|
p2[k] = p1[k]
|
|
p2[k] = p1[k]
|
|
}
|
|
}
|
|
|
|
+ //else if k == "expurasingtime" && util.ObjToString(p1[k]) != "" {
|
|
|
|
+ // res := getMethod(util.ObjToString(p1[k]))
|
|
|
|
+ // if res != 0 {
|
|
|
|
+ // p2[k] = res
|
|
|
|
+ // }
|
|
|
|
+ //}
|
|
|
|
+
|
|
}
|
|
}
|
|
arr = append(arr, p2)
|
|
arr = append(arr, p2)
|
|
}
|
|
}
|
|
@@ -186,10 +247,10 @@ func GetEsField(tmp map[string]interface{}, stype string) (map[string]interface{
|
|
}
|
|
}
|
|
} else if field == "projectscope" {
|
|
} else if field == "projectscope" {
|
|
ps, _ := tmp["projectscope"].(string)
|
|
ps, _ := tmp["projectscope"].(string)
|
|
|
|
+ newTmp["projectscope"] = ps
|
|
if len(ps) > pscopeLength {
|
|
if len(ps) > pscopeLength {
|
|
- newTmp["projectscope"] = string(([]rune(ps))[:pscopeLength])
|
|
|
|
- } else {
|
|
|
|
- newTmp["projectscope"] = ps
|
|
|
|
|
|
+ saveErr["projectscope"] = ps
|
|
|
|
+ saveErr["projectscope_length"] = len(ps)
|
|
}
|
|
}
|
|
} else if field == "winnerorder" { //中标候选
|
|
} else if field == "winnerorder" { //中标候选
|
|
winnerorder_new := []map[string]interface{}{}
|
|
winnerorder_new := []map[string]interface{}{}
|
|
@@ -240,10 +301,11 @@ func GetEsField(tmp map[string]interface{}, stype string) (map[string]interface{
|
|
}
|
|
}
|
|
} else if field == "detail" { //过滤
|
|
} else if field == "detail" { //过滤
|
|
detail, _ := tmp[field].(string)
|
|
detail, _ := tmp[field].(string)
|
|
- if len([]rune(detail)) > detailLength {
|
|
|
|
- detail = detail[:detailLength]
|
|
|
|
- }
|
|
|
|
detail = filterSpace.ReplaceAllString(detail, "")
|
|
detail = filterSpace.ReplaceAllString(detail, "")
|
|
|
|
+ if len(detail) > pscopeLength {
|
|
|
|
+ saveErr["detail"] = detail
|
|
|
|
+ saveErr["detail_length"] = len(detail)
|
|
|
|
+ }
|
|
if tmp["cleartag"] != nil {
|
|
if tmp["cleartag"] != nil {
|
|
if tmp["cleartag"].(bool) {
|
|
if tmp["cleartag"].(bool) {
|
|
text, _ := FilterDetail(detail)
|
|
text, _ := FilterDetail(detail)
|
|
@@ -277,11 +339,20 @@ func GetEsField(tmp map[string]interface{}, stype string) (map[string]interface{
|
|
filetext := getFileText(tmp)
|
|
filetext := getFileText(tmp)
|
|
if len([]rune(filetext)) > 10 {
|
|
if len([]rune(filetext)) > 10 {
|
|
newTmp["filetext"] = filetext
|
|
newTmp["filetext"] = filetext
|
|
|
|
+ if len(filetext) > pscopeLength {
|
|
|
|
+ saveErr["filetext"] = filetext
|
|
|
|
+ saveErr["filetext_length"] = len(filetext)
|
|
|
|
+ }
|
|
}
|
|
}
|
|
YuceEndtime(newTmp) // 预测结果时间
|
|
YuceEndtime(newTmp) // 预测结果时间
|
|
- if stype == "bidding" {
|
|
|
|
|
|
+ if stype == "bidding" || stype == "bidding_history" {
|
|
newTmp["createtime"] = time.Now().Unix() // es库数据创建时间,只有增量数据有
|
|
newTmp["createtime"] = time.Now().Unix() // es库数据创建时间,只有增量数据有
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ if len(saveErr) > 0 {
|
|
|
|
+ saveErr["infoid"] = mongodb.BsonIdToSId(tmp["_id"])
|
|
|
|
+ saveErrBidPool <- saveErr
|
|
|
|
+ }
|
|
return newTmp, update
|
|
return newTmp, update
|
|
}
|
|
}
|
|
|
|
|
|
@@ -333,18 +404,25 @@ func getFileText(tmp map[string]interface{}) (filetext string) {
|
|
for _, result := range tmpData2 {
|
|
for _, result := range tmpData2 {
|
|
if resultMap, ok := result.(map[string]interface{}); resultMap != nil && ok {
|
|
if resultMap, ok := result.(map[string]interface{}); resultMap != nil && ok {
|
|
if attach_url := util.ObjToString(resultMap["attach_url"]); attach_url != "" {
|
|
if attach_url := util.ObjToString(resultMap["attach_url"]); attach_url != "" {
|
|
- bs := oss.OssGetObject(attach_url) //oss读数据
|
|
|
|
- if utf8.RuneCountInString(filetext+bs) < fileLength {
|
|
|
|
- filetext += bs + "\n"
|
|
|
|
|
|
+ bs := oss.OssGetObject(attach_url, mongodb.BsonIdToSId(tmp["_id"])) //oss读数据
|
|
|
|
+ //if utf8.RuneCountInString(filetext+bs) < fileLength {
|
|
|
|
+ // filetext += bs + "\n"
|
|
|
|
+ //} else {
|
|
|
|
+ // if utf8.RuneCountInString(bs) > fileLength {
|
|
|
|
+ // filetext = bs[0:fileLength]
|
|
|
|
+ // } else {
|
|
|
|
+ // filetext = bs
|
|
|
|
+ // }
|
|
|
|
+ // break
|
|
|
|
+ //}
|
|
|
|
+ if len(filetext) > 500000 {
|
|
|
|
+ filetext = filetext[0:500000]
|
|
|
|
+ break
|
|
} else {
|
|
} else {
|
|
- if utf8.RuneCountInString(bs) > fileLength {
|
|
|
|
- filetext = bs[0:fileLength]
|
|
|
|
- } else {
|
|
|
|
- filetext = bs
|
|
|
|
|
|
+ if len(bs) <= 500000 {
|
|
|
|
+ filetext += bs + "\n"
|
|
}
|
|
}
|
|
- break
|
|
|
|
}
|
|
}
|
|
- //filetext += bs + "\n"
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|