|
@@ -1,12 +1,12 @@
|
|
|
package main
|
|
|
|
|
|
import (
|
|
|
- "fmt"
|
|
|
+ //"fmt"
|
|
|
"log"
|
|
|
qutil "qfw/util"
|
|
|
elastic "qfw/util/elastic"
|
|
|
|
|
|
- //"reflect"
|
|
|
+ "reflect"
|
|
|
"strings"
|
|
|
"sync"
|
|
|
|
|
@@ -222,16 +222,8 @@ func biddingAllTask(data []byte, mapInfo map[string]interface{}) {
|
|
|
for tk, tv := range update {
|
|
|
tmp[tk] = tv
|
|
|
}
|
|
|
- if tmp["supervisorrate"] != nil { //临时处理supervisorrate抽取类型为string不生索引
|
|
|
- if _, ok := tmp["supervisorrate"].(string); ok { //supervisorrate数据为string类型
|
|
|
- delete(tmp, "supervisorrate")
|
|
|
- }
|
|
|
- }
|
|
|
//对projectscope字段的索引处理
|
|
|
ps, _ := tmp["projectscope"].(string)
|
|
|
- // if ps == "" {
|
|
|
- // tmp["projectscope"] = ""
|
|
|
- // }
|
|
|
if len(ps) > ESLEN {
|
|
|
tmp["projectscope"] = string(([]rune(ps))[:4000])
|
|
|
}
|
|
@@ -245,17 +237,13 @@ func biddingAllTask(data []byte, mapInfo map[string]interface{}) {
|
|
|
if purchasinglist, ok := tmp["purchasinglist"].([]interface{}); ok && len(purchasinglist) == 0 {
|
|
|
delete(tmp, "purchasinglist")
|
|
|
}
|
|
|
- //对区域为空处理
|
|
|
- if city, ok := tmp["city"].(string); ok && city == "" { //city为空
|
|
|
- delete(tmp, "city")
|
|
|
- }
|
|
|
- if district, ok := tmp["district"].(string); ok && district == "" { //city为空
|
|
|
- delete(tmp, "district")
|
|
|
- }
|
|
|
- //栏目channel
|
|
|
- if channel, ok := tmp["channel"].(string); ok && channel == "" { //channel为空
|
|
|
- delete(tmp, "channel")
|
|
|
+ //数据为空处理
|
|
|
+ for _, f := range []string{"bidstatus", "city", "district", "channel"} {
|
|
|
+ if fVal, ok := tmp[f].(string); ok && fVal == "" {
|
|
|
+ delete(tmp, f)
|
|
|
+ }
|
|
|
}
|
|
|
+
|
|
|
//预算和中标金额
|
|
|
// if s_budget := fmt.Sprint(tmp["budget"]); s_budget == "" || s_budget == "<nil>" || s_budget == "null" {
|
|
|
// tmp["budget"] = nil
|
|
@@ -272,106 +260,32 @@ func biddingAllTask(data []byte, mapInfo map[string]interface{}) {
|
|
|
UpdatesLock.Lock()
|
|
|
if qutil.IntAll(update["extracttype"]) != -1 {
|
|
|
newTmp := map[string]interface{}{}
|
|
|
- // for field, ftype := range biddingIndexFieldsMap { //
|
|
|
- // if tmp[field] != nil && del[field] == nil { //
|
|
|
- // //qutil.Debug(field, tmp[field], reflect.TypeOf(tmp[field]).String(), ftype)
|
|
|
- // if field == "projectinfo" {
|
|
|
- // mp, _ := tmp[field].(map[string]interface{})
|
|
|
- // if mp != nil {
|
|
|
- // newmap := map[string]interface{}{}
|
|
|
- // for k, ktype := range projectinfoFieldsMap {
|
|
|
- // 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" { //标的物处理
|
|
|
- // purchasinglist_new := []map[string]interface{}{}
|
|
|
- // if pcl, _ := tmp[field].([]interface{}); len(pcl) > 0 {
|
|
|
- // for _, ls := range pcl {
|
|
|
- // lsm_new := make(map[string]interface{})
|
|
|
- // lsm := ls.(map[string]interface{})
|
|
|
- // for pf, pftype := range purchasinglistFieldsMap {
|
|
|
- // lsmv := lsm[pf]
|
|
|
- // if lsmv != nil && reflect.TypeOf(lsmv).String() == pftype {
|
|
|
- // lsm_new[pf] = lsm[pf]
|
|
|
- // }
|
|
|
- // }
|
|
|
- // if lsm_new != nil && len(lsm_new) > 0 {
|
|
|
- // purchasinglist_new = append(purchasinglist_new, lsm_new)
|
|
|
- // }
|
|
|
- // }
|
|
|
- // }
|
|
|
- // if len(purchasinglist_new) > 0 {
|
|
|
- // newTmp[field] = purchasinglist_new
|
|
|
- // }
|
|
|
- // } else if field == "winnerorder" { //中标候选
|
|
|
- // winnerorder_new := []map[string]interface{}{}
|
|
|
- // if winnerorder, _ := tmp[field].([]interface{}); len(winnerorder) > 0 {
|
|
|
- // for _, win := range winnerorder {
|
|
|
- // winMap_new := make(map[string]interface{})
|
|
|
- // winMap := win.(map[string]interface{})
|
|
|
- // for wf, wftype := range winnerorderlistFieldsMap {
|
|
|
- // wfv := winMap[wf]
|
|
|
- // if wfv != nil && reflect.TypeOf(wfv).String() == wftype {
|
|
|
- // if wf == "sort" && qutil.Int64All(wfv) > 100 {
|
|
|
- // continue
|
|
|
- // }
|
|
|
- // winMap_new[wf] = winMap[wf]
|
|
|
- // }
|
|
|
- // }
|
|
|
- // if winMap_new != nil && len(winMap_new) > 0 {
|
|
|
- // winnerorder_new = append(winnerorder_new, winMap_new)
|
|
|
- // }
|
|
|
- // }
|
|
|
- // }
|
|
|
- // if len(winnerorder_new) > 0 {
|
|
|
- // newTmp[field] = winnerorder_new
|
|
|
- // }
|
|
|
- // } else if field == "detail" { //过滤
|
|
|
- // detail, _ := tmp[field].(string)
|
|
|
- // if len([]rune(detail)) > detailLength {
|
|
|
- // detail = detail[:detailLength]
|
|
|
- // }
|
|
|
- // newTmp[field] = FilterDetail(detail)
|
|
|
- // } else if field == "_id" || field == "topscopeclass" { //不做处理
|
|
|
- // newTmp[field] = tmp[field]
|
|
|
- // } else { //其它字段判断数据类型,不正确舍弃
|
|
|
- // if fieldval := tmp[field]; reflect.TypeOf(fieldval).String() != ftype {
|
|
|
- // continue
|
|
|
- // } else {
|
|
|
- // newTmp[field] = fieldval
|
|
|
- // }
|
|
|
- // }
|
|
|
- // }
|
|
|
- // }
|
|
|
- for _, v := range biddingIndexFields { //
|
|
|
- if tmp[v] != nil && del[v] == nil { //
|
|
|
- if "projectinfo" == v {
|
|
|
- mp, _ := tmp[v].(map[string]interface{})
|
|
|
+ for field, ftype := range biddingIndexFieldsMap { //
|
|
|
+ if tmp[field] != nil && del[field] == nil { //
|
|
|
+ //qutil.Debug(field, tmp[field], reflect.TypeOf(tmp[field]).String(), ftype)
|
|
|
+ if field == "projectinfo" {
|
|
|
+ mp, _ := tmp[field].(map[string]interface{})
|
|
|
if mp != nil {
|
|
|
newmap := map[string]interface{}{}
|
|
|
- for _, v1 := range projectinfoFields {
|
|
|
- if mp[v1] != nil {
|
|
|
- newmap[v1] = fmt.Sprint(mp[v1])
|
|
|
+ for k, ktype := range projectinfoFieldsMap {
|
|
|
+ mpv := mp[k]
|
|
|
+ if mpv != nil && reflect.TypeOf(mpv).String() == ktype {
|
|
|
+ newmap[k] = mp[k]
|
|
|
}
|
|
|
}
|
|
|
if len(newmap) > 0 {
|
|
|
- newTmp[v] = newmap
|
|
|
+ newTmp[field] = newmap
|
|
|
}
|
|
|
}
|
|
|
- } else if v == "purchasinglist" { //标的物处理
|
|
|
+ } else if field == "purchasinglist" { //标的物处理
|
|
|
purchasinglist_new := []map[string]interface{}{}
|
|
|
- if pcl, _ := tmp[v].([]interface{}); len(pcl) > 0 {
|
|
|
+ if pcl, _ := tmp[field].([]interface{}); len(pcl) > 0 {
|
|
|
for _, ls := range pcl {
|
|
|
lsm_new := make(map[string]interface{})
|
|
|
lsm := ls.(map[string]interface{})
|
|
|
- for _, pf := range purchasinglistFields {
|
|
|
- if lsm[pf] != nil {
|
|
|
+ for pf, pftype := range purchasinglistFieldsMap {
|
|
|
+ lsmv := lsm[pf]
|
|
|
+ if lsmv != nil && reflect.TypeOf(lsmv).String() == pftype {
|
|
|
lsm_new[pf] = lsm[pf]
|
|
|
}
|
|
|
}
|
|
@@ -381,27 +295,101 @@ func biddingAllTask(data []byte, mapInfo map[string]interface{}) {
|
|
|
}
|
|
|
}
|
|
|
if len(purchasinglist_new) > 0 {
|
|
|
- newTmp[v] = purchasinglist_new
|
|
|
+ newTmp[field] = purchasinglist_new
|
|
|
}
|
|
|
- } else {
|
|
|
- if v == "detail" {
|
|
|
- detail, _ := tmp[v].(string)
|
|
|
- if len([]rune(detail)) > detailLength {
|
|
|
- detail = detail[:detailLength]
|
|
|
+ } else if field == "winnerorder" { //中标候选
|
|
|
+ winnerorder_new := []map[string]interface{}{}
|
|
|
+ if winnerorder, _ := tmp[field].([]interface{}); len(winnerorder) > 0 {
|
|
|
+ for _, win := range winnerorder {
|
|
|
+ winMap_new := make(map[string]interface{})
|
|
|
+ winMap := win.(map[string]interface{})
|
|
|
+ for wf, wftype := range winnerorderlistFieldsMap {
|
|
|
+ wfv := winMap[wf]
|
|
|
+ if wfv != nil && reflect.TypeOf(wfv).String() == wftype {
|
|
|
+ if wf == "sort" && qutil.Int64All(wfv) > 100 {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ winMap_new[wf] = winMap[wf]
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if winMap_new != nil && len(winMap_new) > 0 {
|
|
|
+ winnerorder_new = append(winnerorder_new, winMap_new)
|
|
|
+ }
|
|
|
}
|
|
|
- newTmp[v] = FilterDetail(detail)
|
|
|
+ }
|
|
|
+ if len(winnerorder_new) > 0 {
|
|
|
+ newTmp[field] = winnerorder_new
|
|
|
+ }
|
|
|
+ } else if field == "detail" { //过滤
|
|
|
+ detail, _ := tmp[field].(string)
|
|
|
+ if len([]rune(detail)) > detailLength {
|
|
|
+ detail = detail[:detailLength]
|
|
|
+ }
|
|
|
+ newTmp[field] = FilterDetail(detail)
|
|
|
+ } else if field == "_id" || field == "topscopeclass" { //不做处理
|
|
|
+ newTmp[field] = tmp[field]
|
|
|
+ } else { //其它字段判断数据类型,不正确舍弃
|
|
|
+ if fieldval := tmp[field]; reflect.TypeOf(fieldval).String() != ftype {
|
|
|
+ continue
|
|
|
} else {
|
|
|
- newTmp[v] = tmp[v]
|
|
|
+ newTmp[field] = fieldval
|
|
|
}
|
|
|
}
|
|
|
- } /*else if v == "budget" || v == "bidamount" {
|
|
|
- newTmp[v] = nil
|
|
|
- }*/
|
|
|
+ }
|
|
|
}
|
|
|
+ // for _, v := range biddingIndexFields { //
|
|
|
+ // if tmp[v] != nil && del[v] == nil { //
|
|
|
+ // if "projectinfo" == v {
|
|
|
+ // mp, _ := tmp[v].(map[string]interface{})
|
|
|
+ // if mp != nil {
|
|
|
+ // newmap := map[string]interface{}{}
|
|
|
+ // for _, v1 := range projectinfoFields {
|
|
|
+ // if mp[v1] != nil {
|
|
|
+ // newmap[v1] = fmt.Sprint(mp[v1])
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // if len(newmap) > 0 {
|
|
|
+ // newTmp[v] = newmap
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // } else if v == "purchasinglist" { //标的物处理
|
|
|
+ // purchasinglist_new := []map[string]interface{}{}
|
|
|
+ // if pcl, _ := tmp[v].([]interface{}); len(pcl) > 0 {
|
|
|
+ // for _, ls := range pcl {
|
|
|
+ // lsm_new := make(map[string]interface{})
|
|
|
+ // lsm := ls.(map[string]interface{})
|
|
|
+ // for _, pf := range purchasinglistFields {
|
|
|
+ // if lsm[pf] != nil {
|
|
|
+ // lsm_new[pf] = lsm[pf]
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // if lsm_new != nil && len(lsm_new) > 0 {
|
|
|
+ // purchasinglist_new = append(purchasinglist_new, lsm_new)
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // if len(purchasinglist_new) > 0 {
|
|
|
+ // newTmp[v] = purchasinglist_new
|
|
|
+ // }
|
|
|
+ // } else {
|
|
|
+ // if v == "detail" {
|
|
|
+ // detail, _ := tmp[v].(string)
|
|
|
+ // if len([]rune(detail)) > detailLength {
|
|
|
+ // detail = detail[:detailLength]
|
|
|
+ // }
|
|
|
+ // newTmp[v] = FilterDetail(detail)
|
|
|
+ // } else {
|
|
|
+ // newTmp[v] = tmp[v]
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // } /*else if v == "budget" || v == "bidamount" {
|
|
|
+ // newTmp[v] = nil
|
|
|
+ // }*/
|
|
|
+ // }
|
|
|
arrEs = append(arrEs, newTmp)
|
|
|
}
|
|
|
if len(update) > 0 {
|
|
|
- //delete(update, "winnerorder") //winnerorder不需要更新到bindding表,删除
|
|
|
+ delete(update, "winnerorder") //winnerorder不需要更新到bindding表,删除
|
|
|
queryId := map[string]interface{}{"_id": tmp["_id"]}
|
|
|
set := map[string]interface{}{"$set": update}
|
|
|
if len(del) > 0 { //删除的数据
|