Jianghan 11 months ago
parent
commit
f6498fbb27
5 changed files with 118 additions and 86 deletions
  1. 11 0
      src/front/group.go
  2. 5 0
      src/main.go
  3. BIN
      src/web/model/taskexportdata.xlsx
  4. 3 3
      tools/config.json
  5. 99 83
      tools/main.go

+ 11 - 0
src/front/group.go

@@ -859,6 +859,9 @@ func (f *Front) GroupExportData() {
 			"v_baseinfo.publishtime":  1,
 			"v_baseinfo.href":         1,
 			"v_baseinfo.jybxhref":     1,
+			"v_baseinfo.budget":       1,
+			"v_baseinfo.toptype":      1,
+			"v_baseinfo.subtype":      1,
 			"tagname":                 1,
 			"tagname2":                1,
 			"v_baseinfo.is_effective": 1,
@@ -892,9 +895,12 @@ func (f *Front) GroupExportData() {
 					row.AddCell().SetValue(qu.ObjToString(baseinfo["projectcode"]))
 					row.AddCell().SetValue(qu.ObjToString(baseinfo["projectname"]))
 					row.AddCell().SetValue(qu.ObjToString(baseinfo["title"]))
+					row.AddCell().SetValue(baseinfo["budget"])
 					row.AddCell().SetValue(bidamount)
 					row.AddCell().SetValue(qu.ObjToString(baseinfo["area"]))
 					row.AddCell().SetValue(qu.ObjToString(baseinfo["city"]))
+					row.AddCell().SetValue(baseinfo["toptype"])
+					row.AddCell().SetValue(baseinfo["subtype"])
 					pb := qu.Int64All(baseinfo["publishtime"])
 					row.AddCell().SetValue(qu.FormatDateByInt64(&pb, qu.Date_Short_Layout))
 					row.AddCell().SetValue(qu.ObjToString(baseinfo["href"]))
@@ -911,9 +917,12 @@ func (f *Front) GroupExportData() {
 				row.AddCell().SetValue(qu.ObjToString(baseinfo["projectcode"]))
 				row.AddCell().SetValue(qu.ObjToString(baseinfo["projectname"]))
 				row.AddCell().SetValue(qu.ObjToString(baseinfo["title"]))
+				row.AddCell().SetValue(baseinfo["budget"])
 				row.AddCell().SetValue(baseinfo["bidamount"])
 				row.AddCell().SetValue(qu.ObjToString(baseinfo["area"]))
 				row.AddCell().SetValue(qu.ObjToString(baseinfo["city"]))
+				row.AddCell().SetValue(baseinfo["toptype"])
+				row.AddCell().SetValue(baseinfo["subtype"])
 				pb := qu.Int64All(baseinfo["publishtime"])
 				row.AddCell().SetValue(qu.FormatDateByInt64(&pb, qu.Date_Short_Layout))
 				row.AddCell().SetValue(qu.ObjToString(baseinfo["href"]))
@@ -1059,6 +1068,8 @@ func (f *Front) GroupImportData() {
 				c1 = 0
 			}
 			lastid = id
+			qu.Debug("id----", id)
+			qu.Debug("update----", update)
 			if len(del) > 0 {
 				util.Mgo.UpdateById(sourceinfo, id, bson.M{"$set": update, "$unset": del})
 			} else {

+ 5 - 0
src/main.go

@@ -5,6 +5,7 @@ import (
 	_ "filter"
 	"front"
 	"github.com/cron"
+	"log"
 	qu "qfw/util"
 	"time"
 	. "util"
@@ -13,6 +14,9 @@ import (
 )
 
 func init() {
+
+	log.Println(SE.DecodeString("QllJL2tzaAIGB1oSXxQobXA5BAMADkwN"))
+
 	qu.ReadConfig(&Sysconfig) //初始化config
 	qu.ReadConfig("./web/qua_res/qua_config.json", &Quaconfig)
 	InitConfig() //初始化连接
@@ -57,4 +61,5 @@ func cronTask() {
 func main() {
 	//go cronTask()
 	xweb.Run(":" + qu.ObjToString(Sysconfig["port"]))
+
 }

BIN
src/web/model/taskexportdata.xlsx


+ 3 - 3
tools/config.json

@@ -1,7 +1,7 @@
 {
   "addr": "127.0.0.1:27084",
-  "db": "jyqykhfw",
+  "db": "jyqyfw",
   "size": 10,
-  "jy_addr": "192.168.3.71:27082",
-  "jy_db": "jyqyfw"
+  "jy_addr": "192.168.3.71:29099",
+  "jy_db": "wjh"
 }

+ 99 - 83
tools/main.go

@@ -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{})