|
@@ -10,6 +10,7 @@ import (
|
|
|
"strings"
|
|
|
"sync"
|
|
|
"time"
|
|
|
+ "util"
|
|
|
)
|
|
|
|
|
|
var (
|
|
@@ -90,14 +91,14 @@ func main() {
|
|
|
}
|
|
|
|
|
|
var FieldsMap = map[string]string{
|
|
|
- "是否优选": "is_push",
|
|
|
- "是否有效标识": "is_effective",
|
|
|
- "运营商中标标签": "tagname",
|
|
|
- "主体公司": "tagname2",
|
|
|
- "中标人": "s_winner",
|
|
|
- "招标人": "buyer",
|
|
|
- "中标金额": "bidamount",
|
|
|
- "是否为多标多包数据": "multipackage",
|
|
|
+ "是否优选": "is_push",
|
|
|
+ //"是否有效标识": "is_effective",
|
|
|
+ //"运营商中标标签": "tagname",
|
|
|
+ //"主体公司": "tagname2",
|
|
|
+ //"中标人": "s_winner",
|
|
|
+ //"招标人": "buyer",
|
|
|
+ //"中标金额": "bidamount",
|
|
|
+ //"是否为多标多包数据": "multipackage",
|
|
|
}
|
|
|
|
|
|
func task1(coll string) {
|
|
@@ -239,10 +240,11 @@ func task3(coll, path string) {
|
|
|
count := 0
|
|
|
idcolnum := -1
|
|
|
cellFieldName := map[int]string{}
|
|
|
- lastid := ""
|
|
|
- c1 := 0 // 多包第n条数据
|
|
|
+ //lastid := ""
|
|
|
+ //c1 := 0 // 多包第n条数据
|
|
|
+ repeatMap := make(map[string]bool)
|
|
|
for rn, row := range sheet.Rows {
|
|
|
- update := make(map[string]interface{})
|
|
|
+ //update := make(map[string]interface{})
|
|
|
if rn == 0 {
|
|
|
for index, cell := range row.Cells {
|
|
|
if cell.Value == "唯一标识" || cell.Value == "标讯编码(infoID)" { //id所在列
|
|
@@ -257,75 +259,84 @@ func task3(coll, path string) {
|
|
|
}
|
|
|
continue
|
|
|
} else {
|
|
|
- id := row.Cells[idcolnum].String()
|
|
|
- for i, f := range cellFieldName {
|
|
|
- if val := row.Cells[i].Value; val != "" {
|
|
|
- if f == "is_push" {
|
|
|
- update[f] = qu.IntAll(val)
|
|
|
- } else if f == "multipackage" {
|
|
|
- update[fmt.Sprintf("v_baseinfo.%s", f)] = qu.IntAll(val)
|
|
|
- } else if f == "bidamount" {
|
|
|
- update[fmt.Sprintf("v_baseinfo.%s", f)] = qu.Float64All(val)
|
|
|
- } else {
|
|
|
- update[fmt.Sprintf("v_baseinfo.%s", f)] = val
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- if qu.IntAll(update["v_baseinfo.multipackage"]) == 1 {
|
|
|
- if c1 == 0 {
|
|
|
- count++
|
|
|
- }
|
|
|
- if c1 > 0 && lastid == id {
|
|
|
- info, _ := Mgo.FindById("f_sourceinfo_chinaunicom_zb_data", id, bson.M{"v_baseinfo.tagname": 1, "v_baseinfo.tagname2": 1, "v_baseinfo.s_winner": 1,
|
|
|
- "v_baseinfo.bidamount": 1, "v_baseinfo.package": 1})
|
|
|
- if len(*info) > 0 {
|
|
|
- baseinfo := (*info)["v_baseinfo"].(map[string]interface{})
|
|
|
- if baseinfo["package"] != nil {
|
|
|
- packageM := baseinfo["package"].(map[string]interface{})
|
|
|
- m := make(map[string]interface{})
|
|
|
- if update["v_baseinfo.bidamount"] != nil {
|
|
|
- m["bidamount"] = qu.Float64All(update["v_baseinfo.bidamount"])
|
|
|
- }
|
|
|
- if update["v_baseinfo.s_winner"] != nil {
|
|
|
- m["s_winner"] = qu.ObjToString(update["v_baseinfo.s_winner"])
|
|
|
- }
|
|
|
- packageM[fmt.Sprint(c1)] = map[string]interface{}{"winner_all": append([]interface{}{}, m)}
|
|
|
- update["v_baseinfo.package"] = packageM
|
|
|
- }
|
|
|
- if s := qu.ObjToString(baseinfo["tagname"]); s != "" {
|
|
|
- update["v_baseinfo.tagname"] = s + "," + qu.ObjToString(update["v_baseinfo.tagname"])
|
|
|
- }
|
|
|
- if s := qu.ObjToString(baseinfo["tagname2"]); s != "" {
|
|
|
- update["v_baseinfo.tagname2"] = s + "," + qu.ObjToString(update["v_baseinfo.tagname2"])
|
|
|
- }
|
|
|
- if s := qu.ObjToString(baseinfo["s_winner"]); s != "" {
|
|
|
- update["v_baseinfo.s_winner"] = s + "," + qu.ObjToString(update["v_baseinfo.s_winner"])
|
|
|
- }
|
|
|
- update["v_baseinfo.bidamount"] = qu.Float64All(update["v_baseinfo.bidamount"]) + qu.Float64All(baseinfo["bidamount"])
|
|
|
- c1++
|
|
|
- }
|
|
|
- } else {
|
|
|
- c1 = 0
|
|
|
- packageM := make(map[string]interface{})
|
|
|
- m := make(map[string]interface{})
|
|
|
- if update["v_baseinfo.bidamount"] != nil {
|
|
|
- m["bidamount"] = qu.Float64All(update["v_baseinfo.bidamount"])
|
|
|
- }
|
|
|
- if update["v_baseinfo.s_winner"] != nil {
|
|
|
- m["s_winner"] = qu.ObjToString(update["v_baseinfo.s_winner"])
|
|
|
- }
|
|
|
- packageM[fmt.Sprint(c1)] = map[string]interface{}{"winner_all": append([]interface{}{}, m)}
|
|
|
- update["v_baseinfo.package"] = packageM
|
|
|
- c1++
|
|
|
+ id := util.SE.DecodeString(row.Cells[idcolnum].String())
|
|
|
+ if !repeatMap[id] {
|
|
|
+ info, b := Mgo.FindOne(coll, bson.M{"id": id})
|
|
|
+ if b && len(*info) > 0 && qu.IntAll((*info)["is_push"]) != 1 {
|
|
|
+ qu.Debug("id----", id)
|
|
|
+ MgoJy.Save("tmp_02", *info)
|
|
|
}
|
|
|
- } else {
|
|
|
- count++
|
|
|
- c1 = 0
|
|
|
+ repeatMap[id] = true
|
|
|
}
|
|
|
- lastid = id
|
|
|
- Mgo.Update(coll, bson.M{"id": id}, bson.M{"$set": update}, false, false)
|
|
|
+ //for i, f := range cellFieldName {
|
|
|
+ // if val := row.Cells[i].Value; val != "" {
|
|
|
+ // if f == "is_push" {
|
|
|
+ // update[f] = qu.IntAll(val)
|
|
|
+ // } else if f == "multipackage" {
|
|
|
+ // update[fmt.Sprintf("v_baseinfo.%s", f)] = qu.IntAll(val)
|
|
|
+ // } else if f == "bidamount" {
|
|
|
+ // update[fmt.Sprintf("v_baseinfo.%s", f)] = qu.Float64All(val)
|
|
|
+ // } else {
|
|
|
+ // update[fmt.Sprintf("v_baseinfo.%s", f)] = val
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ //}
|
|
|
+ //if qu.IntAll(update["v_baseinfo.multipackage"]) == 1 {
|
|
|
+ // if c1 == 0 {
|
|
|
+ // count++
|
|
|
+ // }
|
|
|
+ // if c1 > 0 && lastid == id {
|
|
|
+ // info, _ := Mgo.FindById("f_sourceinfo_chinaunicom_zb_data", id, bson.M{"v_baseinfo.tagname": 1, "v_baseinfo.tagname2": 1, "v_baseinfo.s_winner": 1,
|
|
|
+ // "v_baseinfo.bidamount": 1, "v_baseinfo.package": 1})
|
|
|
+ // if len(*info) > 0 {
|
|
|
+ // baseinfo := (*info)["v_baseinfo"].(map[string]interface{})
|
|
|
+ // if baseinfo["package"] != nil {
|
|
|
+ // packageM := baseinfo["package"].(map[string]interface{})
|
|
|
+ // m := make(map[string]interface{})
|
|
|
+ // if update["v_baseinfo.bidamount"] != nil {
|
|
|
+ // m["bidamount"] = qu.Float64All(update["v_baseinfo.bidamount"])
|
|
|
+ // }
|
|
|
+ // if update["v_baseinfo.s_winner"] != nil {
|
|
|
+ // m["s_winner"] = qu.ObjToString(update["v_baseinfo.s_winner"])
|
|
|
+ // }
|
|
|
+ // packageM[fmt.Sprint(c1)] = map[string]interface{}{"winner_all": append([]interface{}{}, m)}
|
|
|
+ // update["v_baseinfo.package"] = packageM
|
|
|
+ // }
|
|
|
+ // if s := qu.ObjToString(baseinfo["tagname"]); s != "" {
|
|
|
+ // update["v_baseinfo.tagname"] = s + "," + qu.ObjToString(update["v_baseinfo.tagname"])
|
|
|
+ // }
|
|
|
+ // if s := qu.ObjToString(baseinfo["tagname2"]); s != "" {
|
|
|
+ // update["v_baseinfo.tagname2"] = s + "," + qu.ObjToString(update["v_baseinfo.tagname2"])
|
|
|
+ // }
|
|
|
+ // if s := qu.ObjToString(baseinfo["s_winner"]); s != "" {
|
|
|
+ // update["v_baseinfo.s_winner"] = s + "," + qu.ObjToString(update["v_baseinfo.s_winner"])
|
|
|
+ // }
|
|
|
+ // update["v_baseinfo.bidamount"] = qu.Float64All(update["v_baseinfo.bidamount"]) + qu.Float64All(baseinfo["bidamount"])
|
|
|
+ // c1++
|
|
|
+ // }
|
|
|
+ // } else {
|
|
|
+ // c1 = 0
|
|
|
+ // packageM := make(map[string]interface{})
|
|
|
+ // m := make(map[string]interface{})
|
|
|
+ // if update["v_baseinfo.bidamount"] != nil {
|
|
|
+ // m["bidamount"] = qu.Float64All(update["v_baseinfo.bidamount"])
|
|
|
+ // }
|
|
|
+ // if update["v_baseinfo.s_winner"] != nil {
|
|
|
+ // m["s_winner"] = qu.ObjToString(update["v_baseinfo.s_winner"])
|
|
|
+ // }
|
|
|
+ // packageM[fmt.Sprint(c1)] = map[string]interface{}{"winner_all": append([]interface{}{}, m)}
|
|
|
+ // update["v_baseinfo.package"] = packageM
|
|
|
+ // c1++
|
|
|
+ // }
|
|
|
+ //} else {
|
|
|
+ // count++
|
|
|
+ // c1 = 0
|
|
|
+ //}
|
|
|
+ //lastid = id
|
|
|
+ //Mgo.Update(coll, bson.M{"id": id}, bson.M{"$set": update}, false, false)
|
|
|
}
|
|
|
}
|
|
|
+ qu.Debug("over----", len(repeatMap))
|
|
|
qu.Debug(fmt.Sprintf("更新数据成功,更新: %d条", count))
|
|
|
} else {
|
|
|
qu.Debug(coll, path)
|
|
@@ -334,17 +345,17 @@ func task3(coll, path string) {
|
|
|
}
|
|
|
|
|
|
func task4(coll string) {
|
|
|
- sess := Mgo.GetMgoConn()
|
|
|
- defer Mgo.DestoryMongoConn(sess)
|
|
|
+ sess := MgoJy.GetMgoConn()
|
|
|
+ defer MgoJy.DestoryMongoConn(sess)
|
|
|
|
|
|
ch := make(chan bool, 5)
|
|
|
wg := &sync.WaitGroup{}
|
|
|
|
|
|
- var q bson.M
|
|
|
+ //var q bson.M
|
|
|
count := 0
|
|
|
// 联通中标数据 特殊处理
|
|
|
- q = bson.M{"is_push": 1}
|
|
|
- query := sess.DB(Mgo.DbName).C(coll).Find(q).Select(nil).Iter()
|
|
|
+ //q = bson.M{"is_push": 1}
|
|
|
+ query := sess.DB("wjh").C(coll).Find(nil).Select(nil).Iter()
|
|
|
for tmp := make(map[string]interface{}); query.Next(&tmp); count++ {
|
|
|
ch <- true
|
|
|
wg.Add(1)
|
|
@@ -353,6 +364,11 @@ func task4(coll string) {
|
|
|
<-ch
|
|
|
wg.Done()
|
|
|
}()
|
|
|
+ //binfo, b := Mgo.FindOne("usermail", bson.M{"id": qu.ObjToString(tmp["id"]), "appid": "jyGQ1XQQsEAwNeSENOFR9D"})
|
|
|
+ //if b && len(*binfo) > 0 {
|
|
|
+ // qu.Debug(qu.ObjToString(tmp["id"]))
|
|
|
+ // return
|
|
|
+ //}
|
|
|
info := tmp["v_baseinfo"].(map[string]interface{})
|
|
|
info["createtime"] = time.Now().Unix()
|
|
|
if qu.ObjToString(info["id"]) == "" {
|
|
@@ -360,8 +376,8 @@ func task4(coll string) {
|
|
|
}
|
|
|
info["isOptimization"] = 1
|
|
|
info["ispanchong"] = 1
|
|
|
- Mgo.Save("tmp_usermail", info)
|
|
|
- Mgo.UpdateById(coll, tmp["_id"], bson.M{"$set": bson.M{"sendflag": true}})
|
|
|
+ Mgo.Save("usermail", info)
|
|
|
+ //MgoJy.UpdateById(coll, tmp["_id"], bson.M{"$set": bson.M{"sendflag": true}})
|
|
|
|
|
|
}(tmp)
|
|
|
tmp = make(map[string]interface{})
|