|
@@ -6,8 +6,10 @@ import (
|
|
|
"go.mongodb.org/mongo-driver/bson/primitive"
|
|
|
qu "qfw/util"
|
|
|
"strings"
|
|
|
+ "time"
|
|
|
)
|
|
|
|
|
|
+
|
|
|
//生成两个 mysql 表
|
|
|
func dealWithBiddingSource() {
|
|
|
//f_bidding f_bidproduct
|
|
@@ -17,20 +19,157 @@ func dealWithBiddingSource() {
|
|
|
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 {
|
|
|
+ if total%100==0 {
|
|
|
log.Debug("curent index ",total)
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
+ saveBidMysqlData(tmp)
|
|
|
+ savePurMysqlData(tmp)
|
|
|
tmp = make(map[string]interface{})
|
|
|
}
|
|
|
+
|
|
|
log.Debug("is over ",total)
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
+//导出招标-mysql
|
|
|
+func saveBidMysqlData(tmp map[string]interface{}){
|
|
|
+ data := map[string]interface{}{}
|
|
|
+ data["info_id"] = tmp["info_id"]
|
|
|
+ data["projectname"] = tmp["projectname"]
|
|
|
+ publishtime := qu.Int64All(tmp["publishtime"])
|
|
|
+ new_publishtime := ""//转日期
|
|
|
+ if publishtime>0 {
|
|
|
+ new_publishtime = time.Unix(publishtime, 0).Format(timeLayout)
|
|
|
+ data["publishtime"] = new_publishtime
|
|
|
+ }
|
|
|
+ data["buyer_name"] = qu.ObjToString(tmp["buyer"])
|
|
|
+ data["buyer_depart"] = ""
|
|
|
+ if tmp["budget"]!=nil {
|
|
|
+ data["budget"] = qu.Float64All(tmp["budget"])
|
|
|
+ }
|
|
|
+ if tmp["bidamount"]!=nil {
|
|
|
+ data["bidamount"] = qu.Float64All(tmp["bidamount"])
|
|
|
+ }
|
|
|
+ data["agency_name"] = qu.ObjToString(tmp["agency"])
|
|
|
+ data["winner_name"] = qu.ObjToString(tmp["s_winner"])
|
|
|
+ data["jy_href"] = qu.ObjToString(tmp["jyhref"])
|
|
|
+ updatetime := time.Unix(time.Now().Unix(), 0).Format(timeLayout)
|
|
|
+ data["updatetime"] = updatetime
|
|
|
+
|
|
|
+ // info_type buyer_classcode area_code industry_code
|
|
|
+ info_type_key :=qu.ObjToString(tmp["toptype"])+"_"+qu.ObjToString(tmp["subtype"])
|
|
|
+ data["info_type"] = bidclass_dict[info_type_key]
|
|
|
+
|
|
|
+ buyerclass := qu.ObjToString(tmp["buyerclass"])
|
|
|
+ data["buyer_classcode"] =buyerclass_dict[buyerclass]
|
|
|
+
|
|
|
+ area_key := qu.ObjToString(tmp["area"])+"_"+qu.ObjToString(tmp["city"])+"_"+qu.ObjToString(tmp["district"])
|
|
|
+ data["area_code"] =area_dict[area_key]
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ subscopeclass := []string{}
|
|
|
+ if res, ok := tmp["subscopeclass"].(primitive.A); ok {
|
|
|
+ subscopeclass = qu.ObjArrToStringArr(res)
|
|
|
+ }else {
|
|
|
+ if res, ok := tmp["subscopeclass"].([]interface{}); ok {
|
|
|
+ subscopeclass = qu.ObjArrToStringArr(res)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ industry_code,industry_code_other:="",""
|
|
|
+ for _,v := range subscopeclass{
|
|
|
+ if strings.Contains(v,"医疗卫生") {
|
|
|
+ industry_code = industry_dict[v]
|
|
|
+ }else {
|
|
|
+ if industry_code_other!="" {
|
|
|
+ industry_code_other = industry_code_other+","+industry_dict[v]
|
|
|
+ }else {
|
|
|
+ industry_code_other = industry_dict[v]
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ data["industry_code"] = industry_code
|
|
|
+ data["industry_code_other"] = industry_code_other
|
|
|
+
|
|
|
+ //保存mysql
|
|
|
+ MysqlTool.Insert("f_bidding",data)
|
|
|
+}
|
|
|
+
|
|
|
+//导出标的物-mysql
|
|
|
+func savePurMysqlData(tmp map[string]interface{}){
|
|
|
+ p_list := []map[string]interface{}{}
|
|
|
+ if yl_purchasinglist, ok := tmp["yl_purchasinglist"].(primitive.A); ok {
|
|
|
+ p_list = qu.ObjArrToMapArr(yl_purchasinglist)
|
|
|
+ }else {
|
|
|
+ if yl_purchasinglist, ok := tmp["yl_purchasinglist"].([]interface{}); ok {
|
|
|
+ p_list = qu.ObjArrToMapArr(yl_purchasinglist)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ info_id := qu.ObjToString(tmp["info_id"])
|
|
|
+ s_winner := qu.ObjToString(tmp["s_winner"])
|
|
|
+ for _,v:=range p_list{
|
|
|
+ data := map[string]interface{}{}
|
|
|
+
|
|
|
+ product_name := qu.ObjToString(v["product_name"])
|
|
|
+ data["info_id"] = info_id
|
|
|
+ data["bid_name"] = qu.ObjToString(v["itemname"])
|
|
|
+ data["product_name"] = product_name
|
|
|
+ data["product_brand"] = qu.ObjToString(v["brandname"])
|
|
|
+ data["product_model"] = qu.ObjToString(v["model"])
|
|
|
+ data["product_specs"] = ""
|
|
|
+
|
|
|
+ if v["unitprice"]!=nil {
|
|
|
+ data["product_price"] = qu.Float64All(v["unitprice"])
|
|
|
+ }
|
|
|
+ if v["number"]!=nil {
|
|
|
+ data["product_num"] = qu.Float64All(v["number"])
|
|
|
+ }
|
|
|
+ if v["totalprice"]!=nil {
|
|
|
+ data["product_totalprice"] = qu.Float64All(v["totalprice"])
|
|
|
+ }
|
|
|
+
|
|
|
+ if v["unitname"]!=nil {
|
|
|
+ data["product_unit"] = qu.ObjToString(v["unitname"])
|
|
|
+ }
|
|
|
+
|
|
|
+ if !strings.Contains(s_winner,",") {
|
|
|
+ data["bid_company_id"] = qu.ObjToString(tmp["company_id"])
|
|
|
+ data["bid_company_name"] = s_winner
|
|
|
+ }else {
|
|
|
+ data["bid_company_id"] = ""
|
|
|
+ data["bid_company_name"] = ""
|
|
|
+ }
|
|
|
+ data["bid_company_ysname"] = ""
|
|
|
+ data["make_company_id"] = ""
|
|
|
+ data["make_company_name"] = ""
|
|
|
+ data["make_company_ysname"] = ""
|
|
|
+
|
|
|
+ //product_code分类
|
|
|
+ product_class_1 := qu.ObjToString(v["product_class_1"])
|
|
|
+ product_class_2 := qu.ObjToString(v["product_class_2"])
|
|
|
+ product_class_3 := qu.ObjToString(v["product_class_3"])
|
|
|
+
|
|
|
+ key_4 := "四级_"+product_name
|
|
|
+ if proclass_dict[key_4]!="" {
|
|
|
+ data["product_code"] = proclass_dict[key_4]
|
|
|
+ }else {
|
|
|
+ pro_key := fmt.Sprintf("%s_%s_%s",product_class_1,product_class_2,product_class_3)
|
|
|
+ data["product_code"] = proclass_dict[pro_key]
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ //保存mysql
|
|
|
+ MysqlTool.Insert("f_bidproduct",data)
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+}
|
|
|
|
|
|
|
|
|
|