|
@@ -0,0 +1,175 @@
|
|
|
+package main
|
|
|
+
|
|
|
+import (
|
|
|
+ log "github.com/donnie4w/go-logger/logger"
|
|
|
+ qu "qfw/util"
|
|
|
+ "strings"
|
|
|
+)
|
|
|
+
|
|
|
+var fieldArr = []string{
|
|
|
+ "company_id",
|
|
|
+ "province_short",
|
|
|
+ "company_name",
|
|
|
+ "company_code",
|
|
|
+ "credit_no",
|
|
|
+ "org_code",
|
|
|
+ "tax_code",
|
|
|
+ "establish_date",
|
|
|
+ "legal_person",
|
|
|
+ "legal_person_caption",
|
|
|
+ "company_status",
|
|
|
+ "company_type",
|
|
|
+ "authority",
|
|
|
+ "issue_date",
|
|
|
+ "operation_startdate",
|
|
|
+ "operation_enddate",
|
|
|
+ "capital",
|
|
|
+ "company_address",
|
|
|
+ "business_scope",
|
|
|
+ "cancel_date",
|
|
|
+ "cancel_reason",
|
|
|
+ "revoke_date",
|
|
|
+ "revoke_reason",
|
|
|
+ "use_flag",
|
|
|
+ "create_time",
|
|
|
+ "update_time",
|
|
|
+ "legal_person_type",
|
|
|
+ "real_capital",
|
|
|
+ "en_name",
|
|
|
+ "list_code",
|
|
|
+}
|
|
|
+
|
|
|
+func companySaveMysql() {
|
|
|
+ sess := save_mgo.GetMgoConn()
|
|
|
+ defer save_mgo.DestoryMongoConn(sess)
|
|
|
+ q,total:=map[string]interface{}{},0
|
|
|
+ it := sess.DB(save_mgo.DbName).C("zktest_mysql_company").Find(&q).Iter()
|
|
|
+ for tmp := make(map[string]interface{}); it.Next(&tmp);total++{
|
|
|
+ if total%10000==0 {
|
|
|
+ log.Debug("curent index ",total)
|
|
|
+ }
|
|
|
+ delete(tmp,"_id")
|
|
|
+ MysqlTool.Insert("f_company",tmp)
|
|
|
+ tmp = make(map[string]interface{})
|
|
|
+ }
|
|
|
+
|
|
|
+ log.Debug("is over ",total)
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+//关联企业信息-升数据
|
|
|
+func dealWithCompanyData() {
|
|
|
+ sess := save_mgo.GetMgoConn()
|
|
|
+ defer save_mgo.DestoryMongoConn(sess)
|
|
|
+ q,total:=map[string]interface{}{},0
|
|
|
+ isok:=0
|
|
|
+ it := sess.DB(save_mgo.DbName).C("zktest_nmpa_cpmpany").Find(&q).Iter()
|
|
|
+ for tmp := make(map[string]interface{}); it.Next(&tmp);total++{
|
|
|
+ if total%10000==0 {
|
|
|
+ log.Debug("curent index ",total,isok)
|
|
|
+ }
|
|
|
+ company:= qu.ObjToString(tmp["name"])
|
|
|
+ type_str := qu.ObjToString(tmp["type"])
|
|
|
+ dataArr,_ :=spi_mgo.Find("company_base", map[string]interface{}{
|
|
|
+ "company_name":company,
|
|
|
+ },nil,nil)
|
|
|
+
|
|
|
+ for _,v := range dataArr {
|
|
|
+ isok++
|
|
|
+ data := updateData(v,type_str)
|
|
|
+ if len(data)>2 && data!=nil {
|
|
|
+ save_mgo.Save("111111111111111",data)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ tmp = make(map[string]interface{})
|
|
|
+ }
|
|
|
+
|
|
|
+ log.Debug("is over ",total,isok)
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+func updateData(tmp map[string]interface{},type_str string) map[string]interface{} {
|
|
|
+ update := map[string]interface{}{}
|
|
|
+ for _,v := range fieldArr{
|
|
|
+ if tmp[v]!=nil {
|
|
|
+ update[v] = tmp[v]
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ company_id := qu.ObjToString(update["company_id"])
|
|
|
+ if company_id=="" {
|
|
|
+ return map[string]interface{}{}
|
|
|
+ }
|
|
|
+
|
|
|
+ qy_data := qy_mgo.FindByStrId("qyxy_std",company_id)
|
|
|
+ update["area"] = ""
|
|
|
+ update["city"] = ""
|
|
|
+ update["district"] = ""
|
|
|
+ if qy_data!=nil && len(qy_data)>2 {
|
|
|
+ update["area"] = qu.ObjToString(qy_data["company_area"])
|
|
|
+ update["city"] = qu.ObjToString(qy_data["company_city"])
|
|
|
+ update["district"] = qu.ObjToString(qy_data["company_district"])
|
|
|
+ }
|
|
|
+
|
|
|
+ if strings.Contains(type_str,"&") {
|
|
|
+ update["business_type"] = "3"
|
|
|
+ }else {
|
|
|
+ if strings.Contains(type_str,"生产") {
|
|
|
+ update["business_type"] = "1"
|
|
|
+ }else if strings.Contains(type_str,"经营") {
|
|
|
+ update["business_type"] = "2"
|
|
|
+ }else {
|
|
|
+ update["business_type"] = ""
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return update
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+//已结束
|
|
|
+func exportCompany() {
|
|
|
+ dict := map[string]string{}
|
|
|
+ sess := save_mgo.GetMgoConn()
|
|
|
+ defer save_mgo.DestoryMongoConn(sess)
|
|
|
+ q,total:=map[string]interface{}{},0
|
|
|
+ isok:=0
|
|
|
+ it := sess.DB(save_mgo.DbName).C("nmpa_company").Find(&q).Iter()
|
|
|
+ for tmp := make(map[string]interface{}); it.Next(&tmp);total++{
|
|
|
+ if total%10000==0 {
|
|
|
+ log.Debug("curent index ",total,isok)
|
|
|
+ }
|
|
|
+ company:= qu.ObjToString(tmp["company"])
|
|
|
+ class := qu.ObjToString(tmp["class"])
|
|
|
+ if company!="" {
|
|
|
+ if dict[company]=="" {
|
|
|
+ isok++
|
|
|
+ dict[company] = class
|
|
|
+ }else {
|
|
|
+ pre_class := dict[company]
|
|
|
+ if pre_class!=class && !strings.Contains(pre_class,"&") {
|
|
|
+ dict[company] = pre_class+"&"+class
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ tmp = make(map[string]interface{})
|
|
|
+ }
|
|
|
+ log.Debug("is over ",total,isok)
|
|
|
+
|
|
|
+ for k,v := range dict {
|
|
|
+ save_mgo.Save("zktest_nmpa_cpmpany", map[string]interface{}{
|
|
|
+ "name":k,
|
|
|
+ "type":v,
|
|
|
+ })
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+
|