|
@@ -1,7 +1,6 @@
|
|
|
package main
|
|
|
|
|
|
import (
|
|
|
- "fmt"
|
|
|
"log"
|
|
|
qutil "qfw/util"
|
|
|
elastic "qfw/util/elastic"
|
|
@@ -67,7 +66,11 @@ func biddingAllTask(data []byte, mapInfo map[string]interface{}) {
|
|
|
var compare bson.M
|
|
|
bnil := false
|
|
|
for tmp := make(map[string]interface{}); query.Next(tmp); n++ {
|
|
|
+ if deldata := qutil.IntAll(tmp["del"]); deldata == 1 { //临时:重复数据不生索引
|
|
|
+ continue
|
|
|
+ }
|
|
|
update := map[string]interface{}{}
|
|
|
+ del := map[string]interface{}{} //记录extract没有值而bidding中有值的字段
|
|
|
//对比方法----------------
|
|
|
for {
|
|
|
if compare == nil {
|
|
@@ -84,20 +87,22 @@ func biddingAllTask(data []byte, mapInfo map[string]interface{}) {
|
|
|
bnil = false
|
|
|
//更新bidding表,生成索引
|
|
|
for _, k := range fields { //fields更新到mongo的字段
|
|
|
- v1 := compare[k]
|
|
|
- v2 := tmp[k]
|
|
|
+ v1 := compare[k] //extract
|
|
|
+ v2 := tmp[k] //bidding
|
|
|
if v2 == nil && v1 != nil {
|
|
|
update[k] = v1
|
|
|
} else if v2 != nil && v1 != nil {
|
|
|
- //update[k+"_b"] = v2
|
|
|
update[k] = v1
|
|
|
- } else if v2 != nil && v1 == nil {
|
|
|
- //update[k+"_b"] = v2
|
|
|
+ } else if v2 != nil && v1 == nil { //
|
|
|
+ if k == "s_subscopeclass" && del["subscopeclass"] == nil {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ del[k] = 1
|
|
|
+ //qutil.Debug("抽取结果没有值,bidding有值:field--", k, "val--", v2)
|
|
|
}
|
|
|
}
|
|
|
if qutil.IntAll(compare["repeat"]) == 1 {
|
|
|
update["extracttype"] = -1
|
|
|
- //} else if qutil.IntAll(tmp["extracttype"]) == -1 {
|
|
|
} else {
|
|
|
update["extracttype"] = 1
|
|
|
}
|
|
@@ -120,21 +125,19 @@ func biddingAllTask(data []byte, mapInfo map[string]interface{}) {
|
|
|
//下面可以多线程跑的--->
|
|
|
//处理分类
|
|
|
mpool <- true
|
|
|
- go func(tmp, update, compare map[string]interface{}, bnil bool) {
|
|
|
+ go func(tmp, update, compare, del map[string]interface{}, bnil bool) {
|
|
|
defer func() {
|
|
|
<-mpool
|
|
|
}()
|
|
|
if !bnil && compare != nil {
|
|
|
subscopeclass, _ := compare["subscopeclass"].([]interface{})
|
|
|
if subscopeclass != nil {
|
|
|
- //str := ","
|
|
|
m1 := map[string]bool{}
|
|
|
newclass := []string{}
|
|
|
for _, sc := range subscopeclass {
|
|
|
sclass, _ := sc.(string)
|
|
|
if !m1[sclass] {
|
|
|
m1[sclass] = true
|
|
|
- //str += sclass + ","
|
|
|
newclass = append(newclass, sclass)
|
|
|
}
|
|
|
}
|
|
@@ -142,72 +145,65 @@ func biddingAllTask(data []byte, mapInfo map[string]interface{}) {
|
|
|
update["subscopeclass"] = newclass
|
|
|
}
|
|
|
//处理中标企业
|
|
|
- winner, _ := compare["winner"].(string)
|
|
|
- m1 := map[string]bool{}
|
|
|
- if winner != "" {
|
|
|
- m1[winner] = true
|
|
|
- }
|
|
|
- package1 := compare["package"]
|
|
|
- if package1 != nil {
|
|
|
- packageM, _ := package1.(map[string]interface{})
|
|
|
- for _, p := range packageM {
|
|
|
- pm, _ := p.(map[string]interface{})
|
|
|
- pw, _ := pm["winner"].(string)
|
|
|
- if pw != "" {
|
|
|
- m1[pw] = true
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
+ // winner, _ := compare["winner"].(string)
|
|
|
+ // m1 := map[string]bool{}
|
|
|
+ // if winner != "" {
|
|
|
+ // m1[winner] = true
|
|
|
+ // }
|
|
|
+ // package1 := compare["package"]
|
|
|
+ // if package1 != nil {
|
|
|
+ // packageM, _ := package1.(map[string]interface{})
|
|
|
+ // for _, p := range packageM {
|
|
|
+ // pm, _ := p.(map[string]interface{})
|
|
|
+ // pw, _ := pm["winner"].(string)
|
|
|
+ // if pw != "" {
|
|
|
+ // m1[pw] = true
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // }
|
|
|
compare = nil
|
|
|
- if len(m1) > 0 {
|
|
|
- //str := ","
|
|
|
- winnerarr := []string{}
|
|
|
- for k, _ := range m1 {
|
|
|
- //str += k + ","
|
|
|
- winnerarr = append(winnerarr, k)
|
|
|
- }
|
|
|
- update["s_winner"] = strings.Join(winnerarr, ",")
|
|
|
- }
|
|
|
+ // if len(m1) > 0 {
|
|
|
+ // //str := ","
|
|
|
+ // winnerarr := []string{}
|
|
|
+ // for k, _ := range m1 {
|
|
|
+ // //str += k + ","
|
|
|
+ // winnerarr = append(winnerarr, k)
|
|
|
+ // }
|
|
|
+ // update["s_winner"] = strings.Join(winnerarr, ",")
|
|
|
+ // }
|
|
|
}
|
|
|
//------------------对比结束
|
|
|
-
|
|
|
- //处理key descript
|
|
|
- // if bkey == "" {
|
|
|
- // DealInfo(&tmp, &update)
|
|
|
- // }
|
|
|
//同时保存到elastic
|
|
|
for tk, tv := range update {
|
|
|
tmp[tk] = tv
|
|
|
}
|
|
|
//对projectscope字段的索引处理
|
|
|
ps, _ := tmp["projectscope"].(string)
|
|
|
- if ps == "" {
|
|
|
- tmp["projectscope"] = "" //= tmp["detail"]
|
|
|
- }
|
|
|
+ // if ps == "" {
|
|
|
+ // tmp["projectscope"] = ""
|
|
|
+ // }
|
|
|
if len(ps) > ESLEN {
|
|
|
tmp["projectscope"] = string(([]rune(ps))[:4000])
|
|
|
}
|
|
|
- if s_budget := fmt.Sprint(tmp["budget"]); s_budget == "" || s_budget == "<nil>" || s_budget == "null" {
|
|
|
- tmp["budget"] = nil
|
|
|
- } else if sbd, ok := tmp["budget"].(string); ok {
|
|
|
- tmp["budget"] = ObjToMoney([]interface{}{sbd, sbd})[0]
|
|
|
- }
|
|
|
- if s_bidamount := fmt.Sprint(tmp["bidamount"]); s_bidamount == "" || s_bidamount == "<nil>" || s_bidamount == "null" {
|
|
|
- tmp["bidamount"] = nil
|
|
|
- } else if sbd, ok := tmp["bidamount"].(string); ok {
|
|
|
- tmp["bidamount"] = ObjToMoney([]interface{}{sbd, sbd})[0]
|
|
|
- }
|
|
|
- // for k1, _ := range tmp {
|
|
|
- // if strings.HasSuffix(k1, "_b") || k1 == "contenthtml" {
|
|
|
- // delete(tmp, k1)
|
|
|
+
|
|
|
+ //预算和中标金额
|
|
|
+ // if s_budget := fmt.Sprint(tmp["budget"]); s_budget == "" || s_budget == "<nil>" || s_budget == "null" {
|
|
|
+ // tmp["budget"] = nil
|
|
|
+ // } else if sbd, ok := tmp["budget"].(string); ok {
|
|
|
+ // tmp["budget"] = ObjToMoney([]interface{}{sbd, sbd})[0]
|
|
|
// }
|
|
|
- // }
|
|
|
+ // if s_bidamount := fmt.Sprint(tmp["bidamount"]); s_bidamount == "" || s_bidamount == "<nil>" || s_bidamount == "null" {
|
|
|
+ // tmp["bidamount"] = nil
|
|
|
+ // } else if sbd, ok := tmp["bidamount"].(string); ok {
|
|
|
+ // tmp["bidamount"] = ObjToMoney([]interface{}{sbd, sbd})[0]
|
|
|
+ // }
|
|
|
+
|
|
|
//go IS.Add("bidding")
|
|
|
UpdatesLock.Lock()
|
|
|
if qutil.IntAll(update["extracttype"]) != -1 {
|
|
|
newTmp := map[string]interface{}{}
|
|
|
for _, v := range biddingIndexFields { //
|
|
|
- if tmp[v] != nil {
|
|
|
+ if tmp[v] != nil && del[v] == nil { //
|
|
|
if "projectinfo" == v {
|
|
|
mp, _ := tmp[v].(map[string]interface{})
|
|
|
if mp != nil {
|
|
@@ -232,8 +228,8 @@ func biddingAllTask(data []byte, mapInfo map[string]interface{}) {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+ con = FilterDetailSpace(con)
|
|
|
if con != "" {
|
|
|
- con = FilterDetailSpace(con)
|
|
|
newTmp["attachments"] = con
|
|
|
}
|
|
|
}
|
|
@@ -245,21 +241,19 @@ func biddingAllTask(data []byte, mapInfo map[string]interface{}) {
|
|
|
newTmp[v] = tmp[v]
|
|
|
}
|
|
|
}
|
|
|
- } else if v == "budget" || v == "bidamount" {
|
|
|
+ } /*else if v == "budget" || v == "bidamount" {
|
|
|
newTmp[v] = nil
|
|
|
- }
|
|
|
+ }*/
|
|
|
}
|
|
|
arrEs = append(arrEs, newTmp)
|
|
|
}
|
|
|
if len(update) > 0 {
|
|
|
- arr = append(arr, []map[string]interface{}{
|
|
|
- map[string]interface{}{
|
|
|
- "_id": tmp["_id"],
|
|
|
- },
|
|
|
- map[string]interface{}{
|
|
|
- "$set": update,
|
|
|
- },
|
|
|
- })
|
|
|
+ queryId := map[string]interface{}{"_id": tmp["_id"]}
|
|
|
+ set := map[string]interface{}{"$set": update}
|
|
|
+ if len(del) > 0 { //删除的数据
|
|
|
+ set["$unset"] = del
|
|
|
+ }
|
|
|
+ arr = append(arr, []map[string]interface{}{queryId, set})
|
|
|
}
|
|
|
if len(arr) >= BulkSize {
|
|
|
mgo.UpdateBulkAll(db, c, arr...)
|
|
@@ -274,9 +268,9 @@ func biddingAllTask(data []byte, mapInfo map[string]interface{}) {
|
|
|
arrEs = []map[string]interface{}{}
|
|
|
}
|
|
|
UpdatesLock.Unlock()
|
|
|
- }(tmp, update, compare, bnil)
|
|
|
- if n%100 == 0 {
|
|
|
- log.Println("current:", n)
|
|
|
+ }(tmp, update, compare, del, bnil)
|
|
|
+ if n%1000 == 0 {
|
|
|
+ log.Println("current:", n, tmp["_id"])
|
|
|
}
|
|
|
tmp = make(map[string]interface{})
|
|
|
}
|