zhengkun 3 vuotta sitten
vanhempi
commit
f221b7a5b4

+ 9 - 8
process_ medical/src/main.go

@@ -101,6 +101,14 @@ func init()  {
 
 
 func main()  {
+	//exportSource() //导出源数据
+
+	dealWithSource()  //处理源数据
+}
+
+
+
+func dealWithSource() {
 	MysqlTool = &Mysql{
 		Address: "192.168.3.109:4000",
 		UserName: "jianyu",
@@ -121,19 +129,12 @@ func main()  {
 
 	initMySqlMgoData() //加载数据-本地
 
-
-	
-
+	dealWithBiddingSource()
 }
 
 
 
 
-
-
-
-
-
 //导出源数据-程序
 func exportSource() {
 	save_mgo = &MongodbSim{

+ 46 - 16
process_ medical/src/medical_bidding.go

@@ -8,14 +8,34 @@ import (
 	"strings"
 )
 
+//生成两个 mysql 表
+func dealWithBiddingSource() {
+   	//f_bidding    f_bidproduct
+	log.Debug("分析数据-保存两个mysql表...")
+	sess := save_mgo.GetMgoConn()
+	defer save_mgo.DestoryMongoConn(sess)
+	q,total:=map[string]interface{}{},0
+	it := sess.DB(save_mgo.DbName).C("zktest_mysql_source").Find(&q).Iter()
+	for tmp := make(map[string]interface{}); it.Next(&tmp);total++{
+		if total%10000==0 {
+			log.Debug("curent index ",total)
+		}
 
+		
 
+		tmp = make(map[string]interface{})
+	}
+	log.Debug("is over ",total)
 
 
+}
 
 
 
 
+
+
+//导出源数据...
 func exportUsefulPurchasing() {
 	sess := save_mgo.GetMgoConn()
 	defer save_mgo.DestoryMongoConn(sess)
@@ -38,25 +58,34 @@ func exportUsefulPurchasing() {
 		if len(p_list)>0 {
 			isok++
 			s_winner := qu.ObjToString(tmp["s_winner"])
+
 			new_data["yl_purchasinglist"] = p_list
+
+
 			tmpid := BsonTOStringId(tmp["_id"])
-			new_data["_id"] = tmp["_id"]
 			new_data["info_id"] = tmpid
-			new_data["subtype"] = tmp["subtype"]
-			new_data["toptype"] = tmp["toptype"]
-			new_data["projectname"] =tmp["projectname"]
-			new_data["publishtime"] =tmp["publishtime"]
-			new_data["buyer"] =tmp["buyer"]
-			new_data["buyerclass"] =tmp["buyerclass"]
-			new_data["budget"] =tmp["budget"]
-			new_data["bidamount"] = tmp["bidamount"]
+			new_data["subtype"] = qu.ObjToString(tmp["subtype"])
+			new_data["toptype"] = qu.ObjToString(tmp["toptype"])
+			new_data["projectname"] =qu.ObjToString(tmp["projectname"])
+			new_data["publishtime"] = qu.IntAll(tmp["publishtime"])
+			new_data["buyer"] =qu.ObjToString(tmp["buyer"])
+			new_data["buyerclass"] =qu.ObjToString(tmp["buyerclass"])
+			if tmp["budget"]!=nil {
+				new_data["budget"] =tmp["budget"]
+			}
+			if tmp["bidamount"]!=nil {
+				new_data["bidamount"] =tmp["bidamount"]
+			}
 			new_data["s_winner"] =s_winner
-			new_data["agency"] =tmp["agency"]
-			new_data["area"] =tmp["area"]
-			new_data["city"] =tmp["city"]
-			new_data["district"] =tmp["district"]
-			new_data["jyhref"] = fmt.Sprintf(Url, qu.CommonEncodeArticle("content", BsonTOStringId(tmp["_id"])))
-			new_data["subscopeclass"] = tmp["subscopeclass"]
+			new_data["agency"] =qu.ObjToString(tmp["agency"])
+			new_data["area"] =qu.ObjToString(tmp["area"])
+			new_data["city"] =qu.ObjToString(tmp["city"])
+			new_data["district"] =qu.ObjToString(tmp["district"])
+			new_data["jyhref"] = fmt.Sprintf(Url, qu.CommonEncodeArticle("content", tmpid))
+
+			if tmp["subscopeclass"]!=nil {
+				new_data["subscopeclass"] = tmp["subscopeclass"]
+			}
 			company_id:=""
 			//根据s_winner-关联company_id
 			if s_winner != "" && !strings.Contains(s_winner,",") {
@@ -69,7 +98,7 @@ func exportUsefulPurchasing() {
 			}
 			new_data["company_id"] = company_id
 
-			spi_mgo.Save("zktest_mysql_source",new_data)
+			save_mgo.Save("zktest_mysql_source",new_data)
 		}
 
 
@@ -81,6 +110,7 @@ func exportUsefulPurchasing() {
 	log.Debug("is over ",total,isok)
 }
 
+//暂未使用
 func getUsefulPurchasingData(arr []map[string]interface{}) []map[string]interface{} {
 	new_arr :=[]map[string]interface{}{}
 	for _,v:=range arr {

+ 0 - 5
process_ medical/src/medical_purchasing.go

@@ -1,5 +0,0 @@
-package main
-
-
-
-