Răsfoiți Sursa

备份 - 医疗23版 准备

zhengkun 2 ani în urmă
părinte
comite
3f52f22324

+ 100 - 26
data_ylqx/src/dealer.go

@@ -3,12 +3,12 @@ package main
 import (
 	log "github.com/donnie4w/go-logger/logger"
 	"github.com/uuid"
-	"go.mongodb.org/mongo-driver/bson"
 	qu "qfw/util"
 	"strings"
+	"time"
 )
 
-//企业信息处理
+//经销商-非重复信息全部入库
 func exportDealerBaseInfo() {
 	//企业信息去重
 	dataArr := repeatNameQyxyInfo()
@@ -16,31 +16,41 @@ func exportDealerBaseInfo() {
 		if index%10000 == 0 {
 			log.Debug("curent index ", index)
 		}
-		for k, v := range tmp {
-			infoArr, _ := Qyxy_Mgo.Find("qyxy_std", map[string]interface{}{
-				"company_name": k,
-			}, nil, map[string]interface{}{
-				"company_name":     1,
-				"company_area":     1,
-				"company_city":     1,
-				"company_district": 1,
-				"company_address":  1,
-				"capital":          1,
-			})
-			if len(infoArr) > 0 { //选取最优-企业信息
-				ind := getOneBaseCompany(infoArr)
-				info := infoArr[ind]
-				new_info := createDealerInfo(info, v)
-				Save_Mgo.Save("nmpa_company_dealer", new_info)
-			} else {
-				Save_Mgo.Save("nmpa_company_dealer_err", map[string]interface{}{
-					"dealer_name":    k,
-					"business_model": v,
+		pool_mgo <- true
+		wg_mgo.Add(1)
+		go func(tmp map[string]string) {
+			defer func() {
+				<-pool_mgo
+				wg_mgo.Done()
+			}()
+			for k, v := range tmp {
+				infoArr, _ := Qyxy_Mgo.Find("qyxy_std", map[string]interface{}{
+					"company_name": k,
+				}, nil, map[string]interface{}{
+					"company_name":     1,
+					"company_area":     1,
+					"company_city":     1,
+					"company_district": 1,
+					"company_address":  1,
+					"capital":          1,
 				})
+				if len(infoArr) > 0 { //选取最优-企业信息
+					ind := getOneBaseCompany(infoArr)
+					info := infoArr[ind]
+					new_info := createDealerInfo(info, v)
+					Save_Mgo.Save("nmpa_company_dealer", new_info)
+				} else {
+					Save_Mgo.Save("nmpa_company_dealer_err", map[string]interface{}{
+						"dealer_name":    k,
+						"business_model": v,
+					})
+				}
 			}
-		}
+		}(tmp)
 	}
+	wg_mgo.Wait()
 	log.Debug("经销商处理~~~", len(dataArr))
+	time.Sleep(time.Second * 2)
 }
 
 //构建更新数据
@@ -70,8 +80,8 @@ func createDealerInfo(tmp map[string]interface{}, business_model string) map[str
 	info["district_code"] = district_code
 	info["business_model"] = qu.IntAll(business_model)
 	info["company_address"] = qu.ObjToString(tmp["company_address"])
-	data := Spi_Mgo.FindOne("company_base", bson.M{"company_id": company_id})
-	new_capital := qu.ObjToString(data["capital"])
+	//data := Spi_Mgo.FindOne("company_base", bson.M{"company_id": company_id})
+	//new_capital := qu.ObjToString(data["capital"])
 	capital, capital_code := qu.Float64All(tmp["capital"]), 1
 	if capital >= float64(0) && capital < float64(100) {
 		capital_code = 1
@@ -82,7 +92,7 @@ func createDealerInfo(tmp map[string]interface{}, business_model string) map[str
 	} else {
 		capital_code = 4
 	}
-	info["capital"] = new_capital
+	info["capital"] = capital
 	info["capital_code"] = capital_code
 	return info
 }
@@ -201,5 +211,69 @@ func dealWithRegionCode(area string, city string, district string) (area_code st
 }
 
 func testDealerTag() {
+	sess := Save_Mgo.GetMgoConn()
+	defer Save_Mgo.DestoryMongoConn(sess)
+	q, total := map[string]interface{}{}, 0
+	it := sess.DB(Save_Mgo.DbName).C("nmpa_company_dealer").Find(&q).Select(map[string]interface{}{
+		"name_id": 1,
+	}).Iter()
+	for tmp := make(map[string]interface{}); it.Next(&tmp); total++ {
+		if total%10000 == 0 {
+			log.Debug("curent index ", total)
+		}
+		pool_mgo <- true
+		wg_mgo.Add(1)
+		go func(tmp map[string]interface{}) {
+			defer func() {
+				<-pool_mgo
+				wg_mgo.Done()
+			}()
+			tmpid := BsonTOStringId(tmp["_id"])
+			name_id := qu.ObjToString(tmp["name_id"])
+			info := MysqlSubjectTool.FindOne("dwd_f_yl_dealer_baseinfo", map[string]interface{}{
+				"name_id": name_id,
+			}, "", "")
+			isAdd := 1
+			if info != nil {
+				isAdd = 0
+			}
+			Save_Mgo.UpdateById("nmpa_company_dealer", tmpid, map[string]interface{}{
+				"$set": map[string]interface{}{"isAdd": isAdd},
+			})
+		}(tmp)
+		tmp = make(map[string]interface{})
+	}
+	wg_mgo.Wait()
+	log.Debug("is over ... ")
+	time.Sleep(time.Second * 2)
+}
 
+//导入tidb数据
+func importDealerBaseInfoTidb() {
+	sess := Save_Mgo.GetMgoConn()
+	defer Save_Mgo.DestoryMongoConn(sess)
+	q, total := map[string]interface{}{}, 0
+	it := sess.DB(Save_Mgo.DbName).C("nmpa_company_dealer").Find(&q).Iter()
+	for tmp := make(map[string]interface{}); it.Next(&tmp); total++ {
+		if total%1000 == 0 {
+			log.Debug("curent index ", total)
+		}
+		if qu.IntAll(tmp["isAdd"]) == 1 {
+			pool_mgo <- true
+			wg_mgo.Add(1)
+			go func(tmp map[string]interface{}) {
+				defer func() {
+					<-pool_mgo
+					wg_mgo.Done()
+				}()
+				tmpid := BsonTOStringId(tmp["_id"])
+				deleteField(&tmp, "_id", "isAdd")
+				InsertMysqlSubjectData("zktest_dwd_f_yl_dealer_baseinfo", tmp, tmpid)
+			}(tmp)
+		}
+		tmp = make(map[string]interface{})
+	}
+	wg_mgo.Wait()
+	log.Debug("is over ... ")
+	time.Sleep(time.Second * 2)
 }

+ 78 - 4
data_ylqx/src/dealer_register.go

@@ -5,6 +5,7 @@ import (
 	"go.mongodb.org/mongo-driver/bson"
 	qu "qfw/util"
 	"strings"
+	"time"
 )
 
 //导出经销商注册备案信息
@@ -12,20 +13,22 @@ func exportDealerRegisterInfo() {
 	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_dealer").Find(&q).Select(map[string]interface{}{
 		"name_id":        1,
 		"dealer_name":    1,
 		"business_model": 1,
 	}).Iter()
-	for tmp := make(map[string]interface{}); it.Next(&tmp); {
+	for tmp := make(map[string]interface{}); it.Next(&tmp); total++ {
 		if total%10000 == 0 {
-			log.Debug("curent index ", total)
+			log.Debug("curent index ", total, "~", isok)
 		}
 		num := createDealerRegisterInfo(tmp)
-		total += num
+		isok += num
 		tmp = make(map[string]interface{})
 	}
-	log.Debug("经销商信息~~~", total)
+	log.Debug("经销商信息~~~", total, "~", isok)
+	time.Sleep(time.Second * 2)
 }
 
 //构建注册备案基本信息
@@ -36,6 +39,9 @@ func createDealerRegisterInfo(tmp map[string]interface{}) int {
 	infoArr, _ := Save_Mgo.Find("nmpa_company_new", bson.M{"company": company_name}, bson.M{"_id": 1}, nil)
 	num := 0
 	for _, v := range infoArr {
+		if qu.ObjToString(v["reg_no"]) == "" {
+			continue
+		}
 		num++
 		info := map[string]interface{}{}
 		info["dealer_id"] = dealer_id
@@ -69,3 +75,71 @@ func pickfirst(s1 string, s2 string) string {
 	}
 	return s2
 }
+
+func testDealerRegisterTag() {
+	sess := Save_Mgo.GetMgoConn()
+	defer Save_Mgo.DestoryMongoConn(sess)
+	q, total := map[string]interface{}{}, 0
+	it := sess.DB(Save_Mgo.DbName).C("nmpa_company_register").Find(&q).Sort("_id").Select(map[string]interface{}{
+		"regnum": 1,
+	}).Iter()
+	for tmp := make(map[string]interface{}); it.Next(&tmp); total++ {
+		if total%10000 == 0 {
+			log.Debug("curent index ", total)
+		}
+		pool_mgo <- true
+		wg_mgo.Add(1)
+		go func(tmp map[string]interface{}) {
+			defer func() {
+				<-pool_mgo
+				wg_mgo.Done()
+			}()
+			tmpid := BsonTOStringId(tmp["_id"])
+			regnum := qu.ObjToString(tmp["regnum"])
+			info := MysqlSubjectTool.FindOne("dwd_f_yl_dealer_register", map[string]interface{}{
+				"regnum": regnum,
+			}, "", "")
+			isAdd := 1
+			if info != nil {
+				isAdd = 0
+			}
+			Save_Mgo.UpdateById("nmpa_company_register", tmpid, map[string]interface{}{
+				"$set": map[string]interface{}{"isAdd": isAdd},
+			})
+		}(tmp)
+		tmp = make(map[string]interface{})
+	}
+	wg_mgo.Wait()
+	log.Debug("is over ... ")
+	time.Sleep(time.Second * 2)
+}
+
+//导入tidb数据
+func importDealerRegisterInfoTidb() {
+	sess := Save_Mgo.GetMgoConn()
+	defer Save_Mgo.DestoryMongoConn(sess)
+	q, total := map[string]interface{}{}, 0
+	it := sess.DB(Save_Mgo.DbName).C("nmpa_company_register").Find(&q).Iter()
+	for tmp := make(map[string]interface{}); it.Next(&tmp); total++ {
+		if total%1000 == 0 {
+			log.Debug("curent index ", total)
+		}
+		if qu.IntAll(tmp["isAdd"]) == 1 {
+			pool_mgo <- true
+			wg_mgo.Add(1)
+			go func(tmp map[string]interface{}) {
+				defer func() {
+					<-pool_mgo
+					wg_mgo.Done()
+				}()
+				tmpid := BsonTOStringId(tmp["_id"])
+				deleteField(&tmp, "_id", "isAdd")
+				InsertMysqlSubjectData("zktest_dwd_f_yl_dealer_register", tmp, tmpid)
+			}(tmp)
+		}
+		tmp = make(map[string]interface{})
+	}
+	wg_mgo.Wait()
+	log.Debug("is over ... ")
+	time.Sleep(time.Second * 2)
+}

+ 93 - 0
data_ylqx/src/dealer_scope.go

@@ -0,0 +1,93 @@
+package main
+
+import (
+	log "github.com/donnie4w/go-logger/logger"
+	qu "qfw/util"
+	"strings"
+	"time"
+)
+
+//经销商能力标签表
+func importDealerScopeInfoTidb() {
+	sess := Save_Mgo.GetMgoConn()
+	defer Save_Mgo.DestoryMongoConn(sess)
+	q, total := map[string]interface{}{}, 0
+	ScopeInfos, ScopeIndexs := map[string][]string{}, []string{}
+	it := sess.DB(Save_Mgo.DbName).C("nmpa_company_register").Find(&q).Iter()
+	for tmp := make(map[string]interface{}); it.Next(&tmp); total++ {
+		if total%10000 == 0 {
+			log.Debug("curent index ", total)
+		}
+		if qu.IntAll(tmp["isAdd"]) == 1 {
+			dealer_id := qu.ObjToString(tmp["dealer_id"])
+			scope := qu.ObjToString(tmp["scope"])
+			infos := ScopeInfos[dealer_id]
+			if infos == nil {
+				ScopeInfos[dealer_id] = []string{scope}
+				ScopeIndexs = append(ScopeIndexs, dealer_id)
+			} else {
+				infos = append(infos, scope)
+				ScopeInfos[dealer_id] = infos
+			}
+		}
+		tmp = make(map[string]interface{})
+	}
+	if len(ScopeInfos) != len(ScopeIndexs) {
+		log.Fatal("异常 ... ", len(ScopeInfos), "~", len(ScopeIndexs))
+	}
+	num := 0
+	for _, v := range ScopeInfos {
+		num += len(v)
+	}
+	log.Debug("经营范围数量~", len(ScopeInfos), "~", num)
+	for k, v := range ScopeIndexs {
+		if k%1000 == 0 {
+			log.Debug("cur index ", k)
+		}
+		pool_mgo <- true
+		wg_mgo.Add(1)
+		go func(v string) {
+			defer func() {
+				<-pool_mgo
+				wg_mgo.Done()
+			}()
+			scopeArr := ScopeInfos[v]
+			if len(scopeArr) > 0 {
+				createScopeTagInfo(v, scopeArr)
+			}
+		}(v)
+	}
+	wg_mgo.Wait()
+	log.Debug("is over ... ")
+	time.Sleep(time.Second * 2)
+}
+
+func createScopeTagInfo(dealer_id string, scopeArr []string) {
+	a, b, c := false, false, false
+	for _, v := range scopeArr {
+		if !a && strings.Contains(v, "Ⅰ") {
+			a = true
+		}
+		if !b && strings.Contains(v, "Ⅱ") {
+			b = true
+		}
+		if !c && strings.Contains(v, "Ⅲ") {
+			c = true
+		}
+	}
+	info := map[string]interface{}{}
+	info["dealer_id"] = dealer_id
+	info["createtime"] = time.Unix(time.Now().Unix(), 0).Format(TimeLayout)
+	if a {
+		info["labelvalues"] = "01"
+		InsertMysqlSubjectData("zktesr_dwd_f_yl_dealer_busclass_tags", info, dealer_id)
+	}
+	if b {
+		info["labelvalues"] = "02"
+		InsertMysqlSubjectData("zktesr_dwd_f_yl_dealer_busclass_tags", info, dealer_id)
+	}
+	if c {
+		info["labelvalues"] = "03"
+		InsertMysqlSubjectData("zktesr_dwd_f_yl_dealer_busclass_tags", info, dealer_id)
+	}
+}

+ 68 - 11
data_ylqx/src/init.go

@@ -3,17 +3,21 @@ package main
 import (
 	log "github.com/donnie4w/go-logger/logger"
 	qu "qfw/util"
+	"sync"
+	"time"
 )
 
 var (
-	Old_Mgo, Save_Mgo                 *MongodbSim
-	Spi_Mgo, Qyxy_Mgo                 *MongodbSim
-	MysqlMedicalTool, MysqlGlobalTool *Mysql
-	IsLocal                           bool
-	TimeLayout                        = "2006-01-02 15:04:05"
-	TimeTmeplate                      = "2006-01-02"
-	RegionCodeData                    = map[string]string{}
+	Old_Mgo, Save_Mgo                                   *MongodbSim
+	Spi_Mgo, Qyxy_Mgo                                   *MongodbSim
+	MysqlMedicalTool, MysqlGlobalTool, MysqlSubjectTool *Mysql
+	IsLocal                                             bool
+	TimeLayout                                          = "2006-01-02 15:04:05"
+	TimeTmeplate                                        = "2006-01-02"
+	RegionCodeData                                      = map[string]string{}
 )
+var pool_mgo = make(chan bool, 10)
+var wg_mgo = &sync.WaitGroup{}
 
 func initClass() {
 	initMgo()
@@ -23,14 +27,14 @@ func initClass() {
 
 //初始化mgo
 func initMgo() {
-	//Spi_Mgo = &MongodbSim{
-	//	MongodbAddr: "127.0.0.1:12004",
-	//	DbName:      "mixdata",
+	//Old_Mgo = &MongodbSim{
+	//	MongodbAddr: "127.0.0.1:12003",
+	//	DbName:      "py_theme",
 	//	Size:        10,
 	//	UserName:    "",
 	//	Password:    "",
 	//}
-	//Spi_Mgo.InitPool()
+	//Old_Mgo.InitPool()
 	//return
 
 	if IsLocal {
@@ -130,6 +134,14 @@ func initMysql() {
 	}
 	MysqlGlobalTool.Init()
 
+	MysqlSubjectTool = &Mysql{
+		Address:  address,
+		UserName: username,
+		PassWord: password,
+		DBName:   "Jianyu_subjectdb",
+	}
+	MysqlSubjectTool.Init()
+
 }
 
 func initCode() {
@@ -145,3 +157,48 @@ func initCode() {
 	}
 	log.Debug("地域信息数量~", len(RegionCodeData))
 }
+
+//插入数据
+func InsertMysqlGlobalData(name string, data map[string]interface{}, mark string) int64 {
+	inb := MysqlGlobalTool.Insert(name, data)
+	if inb == -1 {
+		log.Debug("插入数据异常...", name, "~", mark)
+	}
+	return inb
+}
+
+//插入数据
+func InsertMysqlSubjectData(name string, data map[string]interface{}, mark string) int64 {
+	inb := MysqlSubjectTool.Insert(name, data)
+	if inb == -1 {
+		log.Debug("插入数据异常...", name, "~", mark)
+	}
+	return inb
+}
+
+//插入数据
+func InsertMysqlMedicalData(name string, data map[string]interface{}, mark string) int64 {
+	inb := MysqlMedicalTool.Insert(name, data)
+	if inb == -1 {
+		log.Debug("插入数据异常...", name, "~", mark)
+	}
+	return inb
+}
+
+//删除字段
+func deleteField(data *map[string]interface{}, fieldArr ...string) {
+	//针对时间类进行清理
+	dateFields := []string{"validity_date", "approve_date", "establish_date", "issue_date", "cancel_date", "revoke_date"}
+	for _, v := range dateFields {
+		if qu.ObjToString((*data)[v]) == "" {
+			delete(*data, v)
+		}
+	}
+	for _, v := range fieldArr {
+		if v != "" {
+			delete(*data, v)
+		}
+	}
+	//新增一个创建时间
+	(*data)["createtime"] = time.Unix(time.Now().Unix(), 0).Format(TimeLayout)
+}

+ 55 - 12
data_ylqx/src/legal.go

@@ -4,6 +4,7 @@ import (
 	log "github.com/donnie4w/go-logger/logger"
 	"go.mongodb.org/mongo-driver/bson"
 	qu "qfw/util"
+	"time"
 )
 
 //法人基础信息表
@@ -14,18 +15,30 @@ func exportLegalBaseInfo() {
 	it := sess.DB(Save_Mgo.DbName).C("nmpa_company_dealer").Find(&q).Sort("_id").Select(map[string]interface{}{
 		"company_id":  1,
 		"dealer_name": 1,
+		"isAdd":       1,
 	}).Iter()
-	for tmp := make(map[string]interface{}); it.Next(&tmp); {
-		if total%10000 == 0 {
+	for tmp := make(map[string]interface{}); it.Next(&tmp); total++ {
+		if total%1000 == 0 {
 			log.Debug("curent index ", total)
 		}
-		company_id := qu.ObjToString(tmp["company_id"])
-		dealer_name := qu.ObjToString(tmp["dealer_name"])
-		createLegalBaseInfo(dealer_name, company_id)
-
+		if qu.IntAll(tmp["isAdd"]) == 1 {
+			pool_mgo <- true
+			wg_mgo.Add(1)
+			go func(tmp map[string]interface{}) {
+				defer func() {
+					<-pool_mgo
+					wg_mgo.Done()
+				}()
+				company_id := qu.ObjToString(tmp["company_id"])
+				dealer_name := qu.ObjToString(tmp["dealer_name"])
+				createLegalBaseInfo(dealer_name, company_id)
+			}(tmp)
+		}
 		tmp = make(map[string]interface{})
 	}
-	log.Debug("经销商信息~~~", total)
+	wg_mgo.Wait()
+	log.Debug("is over ... ")
+	time.Sleep(time.Second * 2)
 }
 
 func createLegalBaseInfo(company_name string, company_id string) {
@@ -60,21 +73,51 @@ func createLegalBaseInfo(company_name string, company_id string) {
 		info["cancel_reason"] = qu.ObjToString(tmp["cancel_reason"])
 		info["revoke_date"] = qu.ObjToString(tmp["revoke_date"])
 		info["revoke_reason"] = qu.ObjToString(tmp["revoke_reason"])
-		info["legal_person_type"] = qu.IntAll(tmp["legal_person_type"])
 		info["real_capital"] = qu.ObjToString(tmp["real_capital"])
 		info["list_code"] = qu.ObjToString(tmp["list_code"])
 
+		if tmp["legal_person_type"] != nil {
+			info["legal_person_type"] = qu.IntAll(tmp["legal_person_type"])
+		}
+		if tmp["employee_num"] != nil {
+			info["employee_no"] = qu.IntAll(tmp["employee_num"])
+			info["insurance_amount"] = qu.IntAll(tmp["employee_num"])
+		}
 		//区域代码
 		area_code, _, _ := dealWithRegionCode(qu.ObjToString(tmp["company_area"]), qu.ObjToString(tmp["company_city"]), qu.ObjToString(tmp["company_district"]))
 		info["area_code"] = area_code
-
-		info["employee_no"] = qu.IntAll(tmp["employee_num"])
 		info["company_phone"] = qu.ObjToString(tmp["company_phone"])
-		info["insurance_amount"] = qu.ObjToString(tmp["employee_num"])
 		info["company_email"] = qu.ObjToString(tmp["company_email"])
 		info["website"] = qu.ObjToString(tmp["website_url"])
 		info["sourcetype"] = 1
-
 		Save_Mgo.Save("nmpa_legal_baseinfo", info)
 	}
 }
+
+//导入tidb数据
+func importLegalBaseInfoTidb() {
+	sess := Save_Mgo.GetMgoConn()
+	defer Save_Mgo.DestoryMongoConn(sess)
+	q, total := map[string]interface{}{}, 0
+	it := sess.DB(Save_Mgo.DbName).C("nmpa_legal_baseinfo").Find(&q).Iter()
+	for tmp := make(map[string]interface{}); it.Next(&tmp); total++ {
+		if total%1000 == 0 {
+			log.Debug("curent index ", total)
+		}
+		pool_mgo <- true
+		wg_mgo.Add(1)
+		go func(tmp map[string]interface{}) {
+			defer func() {
+				<-pool_mgo
+				wg_mgo.Done()
+			}()
+			tmpid := BsonTOStringId(tmp["_id"])
+			deleteField(&tmp, "_id")
+			InsertMysqlSubjectData("zktest_dwd_f_ent_pa_baseinfo", tmp, tmpid)
+		}(tmp)
+		tmp = make(map[string]interface{})
+	}
+	wg_mgo.Wait()
+	log.Debug("is over ... ")
+	time.Sleep(time.Second * 2)
+}

+ 17 - 15
data_ylqx/src/main.go

@@ -1,10 +1,5 @@
 package main
 
-import (
-	log "github.com/donnie4w/go-logger/logger"
-	elastic_v7 "qfw/util/elastic_v7"
-)
-
 func init() {
 	IsLocal = true
 	initClass()
@@ -15,26 +10,33 @@ func main() {
 	//splitMergeMedicalInfo("nmpa_ylqx_2022")
 	//splitMergeMedicalInfo("nmpa_ylqx_2023")
 
-	//临时处理
-
+	//经销商基本信息
 	//exportDealerBaseInfo()
+	//testDealerTag()
+	//经销商注册备案信息
 	//exportDealerRegisterInfo()
+	//testDealerRegisterTag()
+	//产品基本信息
 	//exportProductBaseInfo()
+	//exportHistoryProductBaseInfo()
+	//testProductBaseInfoTag()
+	//法人基本信息
 	//exportLegalBaseInfo()
 
 	//确认分类
-	confirmYlqxInfoClass()
+	//confirmYlqxInfoClass()
 
 	//临时邮件
 	//testInvestInfo()
 
+	//导入mysql-tidb数据
+	//importDealerBaseInfoTidb()
+	//importDealerRegisterInfoTidb()
+	//importProductBaseInfoTidb()
+	//importLegalBaseInfoTidb()
+	//importDealerScopeInfoTidb()
+
+	//保持活性
 	lock := make(chan bool)
 	<-lock
 }
-
-func test() {
-	elastic_v7.InitElasticSize("http://127.0.0.1:13002", 10, "es_all", "TopJkO2E_d1x")
-	query := `{"query":{"filtered":{"filter":{"bool":{"must":[{"term":{"buyer":"成都东部新区管理委员会"}}]}}}},"_source":["_id","area","buyer"],"from":"0","size":"10"}`
-	es_data := *elastic_v7.Get("bidding", "bidding", query)
-	log.Debug("当前查询结果:", len(es_data))
-}

+ 121 - 5
data_ylqx/src/product.go

@@ -5,6 +5,7 @@ import (
 	"go.mongodb.org/mongo-driver/bson"
 	qu "qfw/util"
 	"strings"
+	"time"
 )
 
 //导出产品信息相关
@@ -12,20 +13,22 @@ func exportProductBaseInfo() {
 	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_dealer").Find(&q).Select(map[string]interface{}{
 		"dealer_name": 1,
 		"company_id":  1,
 		"name_id":     1,
 	}).Iter()
-	for tmp := make(map[string]interface{}); it.Next(&tmp); {
+	for tmp := make(map[string]interface{}); it.Next(&tmp); total++ {
 		if total%10000 == 0 {
-			log.Debug("curent index ", total)
+			log.Debug("curent index ", total, "~", isok)
 		}
 		num := createProductBaseInfo(tmp)
-		total += num
+		isok += num
 		tmp = make(map[string]interface{})
 	}
-	log.Debug("产品信息~~~", total)
+	log.Debug("产品信息~~~", total, "~", isok)
+	time.Sleep(time.Second * 2)
 }
 
 func createProductBaseInfo(dealerInfo map[string]interface{}) int {
@@ -40,7 +43,7 @@ func createProductBaseInfo(dealerInfo map[string]interface{}) int {
 	return num
 }
 
-//信息处理
+//根据新经销商信息~暂时补充的数量
 func dealWithProductInfo(tmp map[string]interface{}, dealerInfo map[string]interface{}) map[string]interface{} {
 	info := map[string]interface{}{}
 	info["dealer_id"] = qu.ObjToString(dealerInfo["name_id"])
@@ -96,3 +99,116 @@ func dealWithProductInfo(tmp map[string]interface{}, dealerInfo map[string]inter
 
 	return info
 }
+
+//根据剩余产品信息-是否属于历史经销商的产品数据
+func exportHistoryProductBaseInfo() {
+	temp := map[string]string{}
+	infosArr, _ := Save_Mgo.Find("nmpa_product_baseinfo", nil, nil, map[string]interface{}{
+		"regno": 1,
+	})
+	for _, v := range infosArr {
+		regno := qu.ObjToString(v["regno"])
+		temp[regno] = regno
+	}
+	log.Debug("当前产品信息数量~", len(temp))
+
+	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_product_new").Find(&q).Iter()
+	for tmp := make(map[string]interface{}); it.Next(&tmp); total++ {
+		if total%1000 == 0 {
+			log.Debug("curent index ", total, "~", isok)
+		}
+		reg_no := qu.ObjToString(tmp["reg_no"])
+		reg_company := qu.ObjToString(tmp["reg_company"])
+		if temp[reg_no] == "" {
+			isok++
+			//计算历史数据是否有相关的经销商企业信息:
+			data := MysqlSubjectTool.FindOne("dwd_f_yl_dealer_baseinfo", map[string]interface{}{
+				"dealer_name": reg_company,
+			}, "", "")
+			if data != nil {
+				dealerInfo := map[string]interface{}{}
+				dealerInfo["name_id"] = qu.ObjToString((*data)["name_id"])
+				dealerInfo["company_id"] = qu.ObjToString((*data)["company_id"])
+				dealerInfo["dealer_name"] = qu.ObjToString((*data)["dealer_name"])
+				info := dealWithProductInfo(tmp, dealerInfo)
+				Save_Mgo.Save("nmpa_product_baseinfo", info)
+			}
+		}
+		tmp = make(map[string]interface{})
+	}
+	log.Debug("补充产品信息~~~", total, "~", isok)
+	time.Sleep(time.Second * 2)
+}
+
+//
+func testProductBaseInfoTag() {
+	sess := Save_Mgo.GetMgoConn()
+	defer Save_Mgo.DestoryMongoConn(sess)
+	q, total := map[string]interface{}{}, 0
+	it := sess.DB(Save_Mgo.DbName).C("nmpa_product_baseinfo").Find(&q).Sort("_id").Select(map[string]interface{}{
+		"regno": 1,
+	}).Iter()
+	for tmp := make(map[string]interface{}); it.Next(&tmp); total++ {
+		if total%10000 == 0 {
+			log.Debug("curent index ", total)
+		}
+		pool_mgo <- true
+		wg_mgo.Add(1)
+		go func(tmp map[string]interface{}) {
+			defer func() {
+				<-pool_mgo
+				wg_mgo.Done()
+			}()
+			tmpid := BsonTOStringId(tmp["_id"])
+			regno := qu.ObjToString(tmp["regno"])
+			info := MysqlSubjectTool.FindOne("dwd_f_yl_dealer_pro_baseinfo", map[string]interface{}{
+				"regno": regno,
+			}, "", "")
+			isAdd := 1
+			if info != nil {
+				isAdd = 0
+			}
+			Save_Mgo.UpdateById("nmpa_product_baseinfo", tmpid, map[string]interface{}{
+				"$set": map[string]interface{}{"isAdd": isAdd},
+			})
+		}(tmp)
+		tmp = make(map[string]interface{})
+	}
+	wg_mgo.Wait()
+	log.Debug("is over ... ")
+	time.Sleep(time.Second * 2)
+}
+
+//导入tidb数据
+func importProductBaseInfoTidb() {
+	sess := Save_Mgo.GetMgoConn()
+	defer Save_Mgo.DestoryMongoConn(sess)
+	q, total := map[string]interface{}{}, 0
+	it := sess.DB(Save_Mgo.DbName).C("nmpa_product_baseinfo").Find(&q).Iter()
+	for tmp := make(map[string]interface{}); it.Next(&tmp); total++ {
+		if total%1000 == 0 {
+			log.Debug("curent index ", total)
+		}
+		if qu.IntAll(tmp["isAdd"]) == 1 {
+			pool_mgo <- true
+			wg_mgo.Add(1)
+			go func(tmp map[string]interface{}) {
+				defer func() {
+					<-pool_mgo
+					wg_mgo.Done()
+				}()
+				tmpid := BsonTOStringId(tmp["_id"])
+				deleteField(&tmp, "_id", "isAdd")
+				InsertMysqlSubjectData("zktest_dwd_f_yl_dealer_pro_baseinfo", tmp, tmpid)
+			}(tmp)
+		}
+		tmp = make(map[string]interface{})
+	}
+	wg_mgo.Wait()
+	log.Debug("is over ... ")
+	time.Sleep(time.Second * 2)
+}

+ 39 - 2
data_ylqx/src/remarks.go

@@ -18,6 +18,7 @@ func confirmYlqxInfoClass() {
 	confirmFifth()
 	confirmSixth()
 	confirmSeventh()
+	confirmEighth()
 	log.Debug("彻底结束~~~")
 }
 
@@ -183,7 +184,6 @@ func confirmFifth() {
 func confirmSixth() {
 	isok := 0
 	dataArr, _ := Save_Mgo.Find("nmpa_product_new", nil, nil, bson.M{
-		"reg_company":        1,
 		"product_name":       1,
 		"product_class_1":    1,
 		"product_class_2":    1,
@@ -217,7 +217,6 @@ func confirmSixth() {
 func confirmSeventh() {
 	isok := 0
 	dataArr, _ := Save_Mgo.Find("nmpa_product_new", nil, nil, bson.M{
-		"reg_company":     1,
 		"product_name":    1,
 		"product_class_1": 1,
 		"product_class_2": 1,
@@ -274,3 +273,41 @@ func confirmSeventh() {
 	log.Debug("is over ... ", isok)
 	time.Sleep(time.Second * 2)
 }
+func confirmEighth() {
+	loadLastClassInfo()
+	isok := 0
+	dataArr, _ := Save_Mgo.Find("nmpa_product_new", nil, nil, bson.M{
+		"product_name":       1,
+		"product_class_1":    1,
+		"product_class_2":    1,
+		"product_class_code": 1,
+		"isFlag":             1,
+	})
+	for _, v := range dataArr {
+		tmpid := BsonTOStringId(v["_id"])
+		product_name := qu.ObjToString(v["product_name"])
+		product_class_code := qu.ObjToString(v["product_class_code"])
+		product_class_1 := qu.ObjToString(v["product_class_1"])
+		product_class_2 := qu.ObjToString(v["product_class_2"])
+		res := LastProductInfo[product_name]
+		if product_class_2 == "" && LastProductInfo[product_name] != nil {
+			res_class_1 := res["product_class_1"]
+			res_class_code := res["product_class_code"]
+			if (product_class_1 == res_class_1 || product_class_1 == "") && len(res_class_code) > len(product_class_code) {
+				isok++
+				Save_Mgo.UpdateById("nmpa_product_new", tmpid, map[string]interface{}{
+					"$set": map[string]interface{}{
+						"isFlag":             flagTagLog(qu.ObjToString(v["isFlag"]), "8"),
+						"product_class_1":    qu.ObjToString(res["product_class_1"]),
+						"product_class_2":    qu.ObjToString(res["product_class_2"]),
+						"product_class_3":    qu.ObjToString(res["product_class_3"]),
+						"product_class_4":    qu.ObjToString(res["product_class_4"]),
+						"product_class_code": qu.ObjToString(res["product_class_code"]),
+					},
+				})
+			}
+		}
+	}
+	log.Debug("is over ... ", isok)
+	time.Sleep(time.Second * 2)
+}

+ 34 - 9
data_ylqx/src/remarks_method.go

@@ -82,11 +82,12 @@ var (
 	YlqxCodeName = map[string]string{}
 	YlqxNameCode = map[string]string{}
 
-	ScRangeReg1   = regexp.MustCompile("(\\d{2}|\\d{4})-(\\d{2}|\\d{1})([\\s -::]+)?([\u4e00-\u9fa5()、()/\\s ]+)")
-	ScRangeReg2   = regexp.MustCompile("\\d{2}([\\s -::]+)?([\u4e00-\u9fa5()、()/\\s ]+)")
-	ScRangeClean1 = regexp.MustCompile("[\\s ]+")
-	ScRangeClean2 = regexp.MustCompile("(生产范围).*")
-	SpecRangeReg  = regexp.MustCompile("(检测试剂|试剂盒|抗体试剂|保存试剂|提取试剂)")
+	LastProductInfo = map[string]map[string]string{}
+	ScRangeReg1     = regexp.MustCompile("(\\d{2}|\\d{4})-(\\d{2}|\\d{1})([\\s -::]+)?([\u4e00-\u9fa5()、()/\\s ]+)")
+	ScRangeReg2     = regexp.MustCompile("\\d{2}([\\s -::]+)?([\u4e00-\u9fa5()、()/\\s ]+)")
+	ScRangeClean1   = regexp.MustCompile("[\\s ]+")
+	ScRangeClean2   = regexp.MustCompile("(生产范围).*")
+	SpecRangeReg    = regexp.MustCompile("(检测试剂|试剂盒|抗体试剂|保存试剂|提取试剂)")
 )
 
 var cleanPN0 = regexp.MustCompile("[ \\s]+")
@@ -1247,6 +1248,30 @@ func loadFifthInfo() map[string]string {
 	log.Debug("加载数量~", len(info))
 	return info
 }
+func loadLastClassInfo() {
+	dataArr, _ := Save_Mgo.Find("zktest_mysql_product_info", nil, nil, map[string]interface{}{
+		"product_class1": 1,
+		"product_class2": 1,
+		"product_class3": 1,
+		"product_class4": 1,
+		"product_code":   1,
+		"product_name":   1,
+	})
+	for _, v := range dataArr {
+		key := qu.ObjToString(v["product_name"])
+		if qu.ObjToString(v["product_class1"]) != "" {
+			LastProductInfo[key] = map[string]string{
+				"product_class_1":    qu.ObjToString(v["product_class1"]),
+				"product_class_2":    qu.ObjToString(v["product_class2"]),
+				"product_class_3":    qu.ObjToString(v["product_class3"]),
+				"product_class_4":    qu.ObjToString(v["product_class4"]),
+				"product_class_code": qu.ObjToString(v["product_code"]),
+				"product_name":       qu.ObjToString(v["product_name"]),
+			}
+		}
+	}
+	log.Debug("产品数量~", len(LastProductInfo))
+}
 
 //具体方法
 func calculationYlqxCode(yl_code string) (bool, map[string]interface{}) {
@@ -1468,7 +1493,7 @@ func splitMergeMedicalInfo(coll string) {
 	it := sess.DB(Old_Mgo.DbName).C(coll).Find(&q).Sort("_id").Iter()
 	for tmp := make(map[string]interface{}); it.Next(&tmp); total++ {
 		if total%10000 == 0 {
-			log.Debug("cur index ", total)
+			log.Debug("cur index ", total, "~", len(companyTemp), "~", len(productTemp))
 		}
 		classify := qu.ObjToString(tmp["classify"])
 		reg_no := qu.ObjToString(tmp["reg_no"])
@@ -1482,7 +1507,7 @@ func splitMergeMedicalInfo(coll string) {
 			if company != "" {
 				if companyTemp[reg_no] == "" {
 					companyTemp[reg_no] = company
-					Save_Mgo.Save("nmpa_company_new", tmp)
+					//Save_Mgo.Save("nmpa_company_new", tmp)
 				}
 			}
 		} else {
@@ -1490,11 +1515,11 @@ func splitMergeMedicalInfo(coll string) {
 			if product_name != "" {
 				if productTemp[reg_no] == "" {
 					productTemp[reg_no] = product_name
-					Save_Mgo.Save("nmpa_product_new", tmp)
+					//Save_Mgo.Save("nmpa_product_new", tmp)
 				}
 			}
 		}
 		tmp = make(map[string]interface{})
 	}
-	log.Debug("is over ", total)
+	log.Debug("is over ", total, "~", len(companyTemp), "~", len(productTemp))
 }

+ 15 - 14
listen_data/src/main.go

@@ -115,24 +115,24 @@ func main() {
 	//}
 	//save_mgo.InitPool()
 
-	//save_mgo = &MongodbSim{
-	//	MongodbAddr: "172.17.145.163:27083,172.17.4.187:27082",
-	//	DbName:      "qfw",
-	//	Size:        10,
-	//	UserName:    "zhengkun",
-	//	Password:    "zk@123123",
-	//}
-	//save_mgo.InitPool()
-
 	save_mgo = &MongodbSim{
-		MongodbAddr: "127.0.0.1:27017",
-		DbName:      "zhengkun",
+		MongodbAddr: "172.17.145.163:27083,172.17.4.187:27082",
+		DbName:      "qfw",
 		Size:        10,
-		UserName:    "",
-		Password:    "",
+		UserName:    "zhengkun",
+		Password:    "zk@123123",
 	}
 	save_mgo.InitPool()
 
+	//save_mgo = &MongodbSim{
+	//	MongodbAddr: "127.0.0.1:27017",
+	//	DbName:      "zhengkun",
+	//	Size:        10,
+	//	UserName:    "",
+	//	Password:    "",
+	//}
+	//save_mgo.InitPool()
+
 	//decodeJyUrl("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx")
 	//decodeSEUrl("QltDeTokbwUCBA0WV0V6anBgCwIGW0VZ")
 	//decodeFeedBackInfo()
@@ -140,7 +140,8 @@ func main() {
 
 	//decodeSEUrl("QltFK2gnbAIIUFwVV0dybyZpVAkEWkNb")
 	//decodeSEUrl("QltFK2h2OQMIUFwVV0dybyZpVAkFWEdY")
-	exportErrInfo0515()
+	//exportErrInfo0515()
+
 	return
 
 	/*

+ 3 - 7
listen_data/src/zkmethod.go

@@ -178,9 +178,8 @@ func exportErrInfo0515() {
 		log.Debug("连接池异常")
 	}
 	//26号当天数据
-	query1 := es_elastic.NewTermQuery("area", "广西")
-	query2 := es_elastic.NewQueryStringQuery("兵团").DefaultField("buyer.mbuyer")
-	cursor, err := esclient.Scan("bidding").Query(es_elastic.NewBoolQuery().Must(query1, query2)).Size(200).Do()
+	query1 := es_elastic.NewTermQuery("site", "服务采购数字化平台")
+	cursor, err := esclient.Scan("bidding").Query(es_elastic.NewBoolQuery().Must(query1)).Size(200).Do()
 	if err != nil || cursor.Results == nil || cursor.Results.Hits == nil {
 		log.Debug("异常~", err)
 	}
@@ -216,12 +215,9 @@ func exportErrInfo0515() {
 					<-pool_es
 					wg_es.Done()
 				}()
-				site := qu.ObjToString(tmp["site"])
 				save_mgo.Save("111111", map[string]interface{}{
-					"_id":  StringTOBsonId(qu.ObjToString(tmp["_id"])),
-					"site": site,
+					"_id": StringTOBsonId(qu.ObjToString(tmp["_id"])),
 				})
-
 			}(tmp)
 		}
 	}

+ 307 - 308
process_medical/src/medical_yx_class.go

@@ -8,56 +8,55 @@ import (
 	"regexp"
 	"strings"
 )
+
 //分词
-var GSE *gse.Segmenter  = &gse.Segmenter{}
+var GSE *gse.Segmenter = &gse.Segmenter{}
 var gseReg *regexp.Regexp = regexp.MustCompile("[(())/、]+")
 
-
-
 //分类-医械查
-func repairYiXieChaData(){
+func repairYiXieChaData() {
 	log.Debug("开始补......数据")
 	sess := save_mgo.GetMgoConn()
 	defer save_mgo.DestoryMongoConn(sess)
 	q := map[string]interface{}{}
-	total,isok:=0,0
+	total, isok := 0, 0
 	it := sess.DB(save_mgo.DbName).C("nmpa_zcyl_search").Find(&q).Sort("_id").Select(map[string]interface{}{
-		"records":1,
+		"records": 1,
 	}).Iter()
 	strReg := regexp.MustCompile(`(^[0-9][0-9]|[ \n]+)`)
-	for tmp := make(map[string]interface{}); it.Next(&tmp);total++{
-		if total%10000==0 {
-			log.Debug("cur index ", total,"~",isok)
+	for tmp := make(map[string]interface{}); it.Next(&tmp); total++ {
+		if total%10000 == 0 {
+			log.Debug("cur index ", total, "~", isok)
 		}
 		records := []map[string]interface{}{}
 		if res, ok := tmp["records"].(primitive.A); ok {
 			records = qu.ObjArrToMapArr(res)
-		}else {
+		} else {
 			if res, ok := tmp["records"].([]interface{}); ok {
 				records = qu.ObjArrToMapArr(res)
 			}
 		}
 		//采用对方数据
-		for _,v := range records {
+		for _, v := range records {
 			largeClassName := qu.ObjToString(v["largeClassName"])
 			oneProdCategory := qu.ObjToString(v["oneProdCategory"])
 			twoProdCategory := qu.ObjToString(v["twoProdCategory"])
-			oneProdCategory = strReg.ReplaceAllString(oneProdCategory,"")
-			twoProdCategory = strReg.ReplaceAllString(twoProdCategory,"")
-			update:=map[string]interface{}{
-				"product_class":largeClassName,
-				"product_class_1":oneProdCategory,
-				"product_class_2":twoProdCategory,
-				"isYiXieUpdate":true,
+			oneProdCategory = strReg.ReplaceAllString(oneProdCategory, "")
+			twoProdCategory = strReg.ReplaceAllString(twoProdCategory, "")
+			update := map[string]interface{}{
+				"product_class":   largeClassName,
+				"product_class_1": oneProdCategory,
+				"product_class_2": twoProdCategory,
+				"isYiXieUpdate":   true,
 			}
 			registNum := qu.ObjToString(v["registNum"])
-			if registNum!="" && largeClassName !="" {
+			if registNum != "" && largeClassName != "" {
 				data := save_mgo.FindOne("nmpa_product", map[string]interface{}{
-					"reg_no" : registNum,
+					"reg_no": registNum,
 				})
-				if data!=nil && len(data)>2 {
+				if data != nil && len(data) > 2 {
 					isok++
-					save_mgo.UpdateById("nmpa_product",BsonTOStringId(data["_id"]), map[string]interface{}{
+					save_mgo.UpdateById("nmpa_product", BsonTOStringId(data["_id"]), map[string]interface{}{
 						"$set": update,
 					})
 				}
@@ -65,10 +64,11 @@ func repairYiXieChaData(){
 		}
 		tmp = make(map[string]interface{})
 	}
-	log.Debug("is over ",total,"~",isok)
+	log.Debug("is over ", total, "~", isok)
 }
+
 //处理分类-AB  C待定
-func dealWithClassData(product_name string,classArr []map[string]interface{}) map[string]interface{}{
+func dealWithClassData(product_name string, classArr []map[string]interface{}) map[string]interface{} {
 	/*
 		a产品名称和品名举例(或二分类名称)绝对值相等;如果只有一个品名举例对应上,直接打上分类,如有多个,冗余字段记录
 		b产品名称和品名分类,存在包含关系;如果只有一个分类对应上,直接打上分类,如有多个,冗余字段记录
@@ -134,33 +134,32 @@ func dealWithClassData(product_name string,classArr []map[string]interface{}) ma
 	//}
 	//return updateC
 
-
 	isA := false
 	updateA := map[string]interface{}{}
-	okMap :=map[string]map[string]interface{}{}
-	for _,v :=range classArr { //先对比class_2 在对比 品名举例
+	okMap := map[string]map[string]interface{}{}
+	for _, v := range classArr { //先对比class_2 在对比 品名举例
 		example := qu.ObjToString(v["product_example"])
 		product_class := qu.ObjToString(v["product_class"])
 		product_class_1 := qu.ObjToString(v["product_class_1"])
 		product_class_2 := qu.ObjToString(v["product_class_2"])
 		dict := map[string]interface{}{
-			"product_class":product_class,
-			"product_class_1":product_class_1,
-			"product_class_2":product_class_2,
+			"product_class":   product_class,
+			"product_class_1": product_class_1,
+			"product_class_2": product_class_2,
 		}
-		if product_class_2==product_name{
-			okey := product_class+"~"+product_class_1+"~"+product_class_2
-			if okMap[okey]==nil {
+		if product_class_2 == product_name {
+			okey := product_class + "~" + product_class_1 + "~" + product_class_2
+			if okMap[okey] == nil {
 				okMap[okey] = dict
 			}
 			continue
 		}
 
-		exampleArr := strings.Split(example,"、")
-		for _,name := range exampleArr { //对比品名举例
-			if name==product_name {
-				okey := product_class+"~"+product_class_1+"~"+product_class_2
-				if okMap[okey]==nil {
+		exampleArr := strings.Split(example, "、")
+		for _, name := range exampleArr { //对比品名举例
+			if name == product_name {
+				okey := product_class + "~" + product_class_1 + "~" + product_class_2
+				if okMap[okey] == nil {
 					okMap[okey] = dict
 				}
 				break
@@ -168,27 +167,27 @@ func dealWithClassData(product_name string,classArr []map[string]interface{}) ma
 		}
 	}
 
-	if len(okMap)==1 { //匹配
+	if len(okMap) == 1 { //匹配
 		isA = true
-		for _,v := range okMap{
+		for _, v := range okMap {
 			updateA = map[string]interface{}{
-				"product_class":v["product_class"],
-				"product_class_1":v["product_class_1"],
-				"product_class_2":v["product_class_2"],
-				"isMustUpdate":true,
+				"product_class":   v["product_class"],
+				"product_class_1": v["product_class_1"],
+				"product_class_2": v["product_class_2"],
+				"isMustUpdate":    true,
 			}
 		}
-	}else if len(okMap)>1 { //冗余
+	} else if len(okMap) > 1 { //冗余
 		isA = true
 		arr := []map[string]interface{}{}
-		for _,v := range okMap{
-			arr = append(arr,v)
+		for _, v := range okMap {
+			arr = append(arr, v)
 		}
 		updateA = map[string]interface{}{
-			"isMustClass":arr,
-			"isMustUpdate":true,
+			"isMustClass":  arr,
+			"isMustUpdate": true,
 		}
-	}else {
+	} else {
 
 	}
 	if isA {
@@ -197,93 +196,93 @@ func dealWithClassData(product_name string,classArr []map[string]interface{}) ma
 
 	isB := false
 	updateB := map[string]interface{}{}
-	okMap =map[string]map[string]interface{}{}
-	for _,v :=range classArr {
+	okMap = map[string]map[string]interface{}{}
+	for _, v := range classArr {
 		product_class := qu.ObjToString(v["product_class"])
 		product_class_1 := qu.ObjToString(v["product_class_1"])
 		product_class_2 := qu.ObjToString(v["product_class_2"])
 		dict := map[string]interface{}{
-			"product_class":product_class,
-			"product_class_1":product_class_1,
-			"product_class_2":product_class_2,
-		}
-		if strings.Contains(product_class_2,product_name)||
-			strings.Contains(product_name,product_class_2) {
-			okey := product_class+"~"+product_class_1+"~"+product_class_2
-			if okMap[okey]==nil {
+			"product_class":   product_class,
+			"product_class_1": product_class_1,
+			"product_class_2": product_class_2,
+		}
+		if strings.Contains(product_class_2, product_name) ||
+			strings.Contains(product_name, product_class_2) {
+			okey := product_class + "~" + product_class_1 + "~" + product_class_2
+			if okMap[okey] == nil {
 				okMap[okey] = dict
 			}
 		}
 	}
 
-	if len(okMap)==1 { //匹配
+	if len(okMap) == 1 { //匹配
 		isB = true
-		for _,v := range okMap{
+		for _, v := range okMap {
 			updateB = map[string]interface{}{
-				"product_class":v["product_class"],
-				"product_class_1":v["product_class_1"],
-				"product_class_2":v["product_class_2"],
-				"isContainsUpdate":true,
+				"product_class":    v["product_class"],
+				"product_class_1":  v["product_class_1"],
+				"product_class_2":  v["product_class_2"],
+				"isContainsUpdate": true,
 			}
 		}
-	}else if len(okMap)>1 { //冗余
+	} else if len(okMap) > 1 { //冗余
 		isB = true
 		arr := []map[string]interface{}{}
-		for _,v := range okMap{
-			arr = append(arr,v)
+		for _, v := range okMap {
+			arr = append(arr, v)
 		}
 		updateB = map[string]interface{}{
-			"isContainsClass":arr,
-			"isContainsUpdate":true,
+			"isContainsClass":  arr,
+			"isContainsUpdate": true,
 		}
-	}else {
+	} else {
 
 	}
 
-
 	if isB {
 		return updateB
 	}
 	return map[string]interface{}{}
 }
+
 //修复数据reg_no截取
-func repairEqRegNoClassData(){
+func repairEqRegNoClassData() {
 	sess := save_mgo.GetMgoConn()
 	defer save_mgo.DestoryMongoConn(sess)
-	q,total:=map[string]interface{}{},0
+	q, total := map[string]interface{}{}, 0
 	it := sess.DB(save_mgo.DbName).C("nmpa_product").Find(&q).Sort("_id").Select(map[string]interface{}{
-		"reg_no":1,
-		"product_class":1,
+		"reg_no":        1,
+		"product_class": 1,
 	}).Iter()
-	isok:=0
-	dict:=map[string]string{
-		"01":"有源手术器械",
-		"02":"无源手术器械",
-		"03":"神经和心血管手术器械",
-		"04":"骨科手术器械",
-		"05":"放射治疗器械",
-		"06":"医用成像器械",
-		"07":"医用诊察和监护器械",
-		"08":"呼吸、麻醉和急救器械",
-		"09":"物理治疗器械",
-		"10":"输血、透析和体外循环器械",
-		"11":"医疗器械消毒灭菌器械",
-		"12":"有源植入器械",
-		"13":"无源植入器械",
-		"14":"注输、护理和防护器械",
-		"15":"患者承载器械",
-		"16":"眼科器械",
-		"17":"口腔科器械",
-		"18":"妇产科、辅助生殖和避孕器械",
-		"19":"医用康复器械",
-		"20":"中医器械",
-		"21":"医用软件",
-		"22":"临床检验器械",
+	isok := 0
+	dict := map[string]string{
+		"01": "有源手术器械",
+		"02": "无源手术器械",
+		"03": "神经和心血管手术器械",
+		"04": "骨科手术器械",
+		"05": "放射治疗器械",
+		"06": "医用成像器械",
+		"07": "医用诊察和监护器械",
+		"08": "呼吸、麻醉和急救器械",
+		"09": "物理治疗器械",
+		"10": "输血、透析和体外循环器械",
+		"11": "医疗器械消毒灭菌器械",
+		"12": "有源植入器械",
+		"13": "无源植入器械",
+		"14": "注输、护理和防护器械",
+		"15": "患者承载器械",
+		"16": "眼科器械",
+		"17": "口腔科器械",
+		"18": "妇产科、辅助生殖和避孕器械",
+		"19": "医用康复器械",
+		"20": "中医器械",
+		"21": "医用软件",
+		"22": "临床检验器械",
 		"27": "中医器械",
 		"28": "医用成像器械",
 		"32": "放射治疗器械",
 		"34": "医用成像器械",
-		"40":"体外诊断试剂",
+		"40": "体外诊断试剂",
 		"41": "临床检验器械",
 		"45": "输血、透析和体外循环器械",
 		"55": "口腔科器械",
@@ -297,151 +296,152 @@ func repairEqRegNoClassData(){
 	//""沪食药监械(准)字2013第2401942号(变更文件)""
 	reg_reg_1 := regexp.MustCompile("[\u4e00-\u9fa5]{2}20\\d{9}")
 	reg_reg_2 := regexp.MustCompile("\\d{7}号")
-	for tmp := make(map[string]interface{}); it.Next(&tmp);total++{
-		if total % 10000 == 0 {
-			log.Debug("cur index ",total,"~",isok)
+	for tmp := make(map[string]interface{}); it.Next(&tmp); total++ {
+		if total%10000 == 0 {
+			log.Debug("cur index ", total, "~", isok)
 		}
-		tmpid:=BsonTOStringId(tmp["_id"])
+		tmpid := BsonTOStringId(tmp["_id"])
 		product_class := qu.ObjToString(tmp["product_class"])
 		reg_no := qu.ObjToString(tmp["reg_no"])
 		str := reg_reg_1.FindString(reg_no)
-		if str=="" {
+		if str == "" {
 			str = reg_reg_2.FindString(reg_no)
 		}
-		if product_class=="" && str!=""{
+		if product_class == "" && str != "" {
 			new_no := str[11:13]
 			//new_no := str[1:3]
-			if dict[new_no]!=""{
+			if dict[new_no] != "" {
 				isok++
-				save_mgo.UpdateById("nmpa_product",tmpid, map[string]interface{}{
+				save_mgo.UpdateById("nmpa_product", tmpid, map[string]interface{}{
 					"$set": map[string]interface{}{
-						"product_class":dict[new_no],
+						"product_class": dict[new_no],
 					},
 				})
 			}
 
 			num := qu.IntAll(dict_num[new_no])
-			dict_num[new_no] = num+1
+			dict_num[new_no] = num + 1
 
 		}
 		tmp = make(map[string]interface{})
 	}
-	log.Debug("is over ",total,"~",isok)
+	log.Debug("is over ", total, "~", isok)
 	log.Debug(dict_num)
 }
+
 //补充同分类数据
-func repairEqClassData(){
+func repairEqClassData() {
 
 	sess := save_mgo.GetMgoConn()
 	defer save_mgo.DestoryMongoConn(sess)
-	q,total:=map[string]interface{}{},0
+	q, total := map[string]interface{}{}, 0
 	it := sess.DB(save_mgo.DbName).C("nmpa_product").Find(&q).Sort("_id").Select(map[string]interface{}{
-		"product_class":1,
-		"product_class_1":1,
-		"product_class_2":1,
-		"class":1,
-		"product_name":1,
+		"product_class":   1,
+		"product_class_1": 1,
+		"product_class_2": 1,
+		"class":           1,
+		"product_name":    1,
 	}).Iter()
 	P_Name_Dict := map[string][]map[string]interface{}{}
-	for tmp := make(map[string]interface{}); it.Next(&tmp);total++{
-		if total % 10000 == 0 {
-			log.Debug("cur index ",total)
+	for tmp := make(map[string]interface{}); it.Next(&tmp); total++ {
+		if total%10000 == 0 {
+			log.Debug("cur index ", total)
 		}
 		product_name := qu.ObjToString(tmp["product_name"])
 		arr := []map[string]interface{}{}
-		if P_Name_Dict[product_name]!=nil {
+		if P_Name_Dict[product_name] != nil {
 			arr = P_Name_Dict[product_name]
 		}
-		arr = append(arr,tmp)
+		arr = append(arr, tmp)
 		P_Name_Dict[product_name] = arr
 		tmp = make(map[string]interface{})
 	}
-	log.Debug("分组完毕~",len(P_Name_Dict),"~开始处理分组数据")
-	istotal,isok:=0,0
-	for pn,arr:=range P_Name_Dict {
+	log.Debug("分组完毕~", len(P_Name_Dict), "~开始处理分组数据")
+	istotal, isok := 0, 0
+	for pn, arr := range P_Name_Dict {
 		istotal++
-		if istotal%5000==0 {
-			log.Debug("第",istotal,"组~",isok,"~",pn)
+		if istotal%5000 == 0 {
+			log.Debug("第", istotal, "组~", isok, "~", pn)
 		}
-		if len(arr)==1 {
+		if len(arr) == 1 {
 			continue
 		}
-		usedArr,unUsedArr:=breakUpUsedata(arr)
-		for _,v:=range unUsedArr{
-			update:= breakUpdateData(usedArr,v)
-			if len(update)>0 {
+		usedArr, unUsedArr := breakUpUsedata(arr)
+		for _, v := range unUsedArr {
+			update := breakUpdateData(usedArr, v)
+			if len(update) > 0 {
 				isok++
-				save_mgo.UpdateById("nmpa_product",BsonTOStringId(v["_id"]), map[string]interface{}{
+				save_mgo.UpdateById("nmpa_product", BsonTOStringId(v["_id"]), map[string]interface{}{
 					"$set": update,
 				})
 			}
 		}
 	}
-	log.Debug("is over ",isok)
+	log.Debug("is over ", isok)
 }
-func breakUpUsedata(tmpArr []map[string]interface{}) ([]map[string]interface{},[]map[string]interface{}) {
-	UsedArr,UnUsedArr:=[]map[string]interface{}{},[]map[string]interface{}{}
-	for _,v:=range tmpArr {
-		product_class:=qu.ObjToString(v["product_class"])
-		product_class_1:=qu.ObjToString(v["product_class_1"])
-		product_class_2:=qu.ObjToString(v["product_class_2"])
-		isok:=0
-		if product_class!="" {
+func breakUpUsedata(tmpArr []map[string]interface{}) ([]map[string]interface{}, []map[string]interface{}) {
+	UsedArr, UnUsedArr := []map[string]interface{}{}, []map[string]interface{}{}
+	for _, v := range tmpArr {
+		product_class := qu.ObjToString(v["product_class"])
+		product_class_1 := qu.ObjToString(v["product_class_1"])
+		product_class_2 := qu.ObjToString(v["product_class_2"])
+		isok := 0
+		if product_class != "" {
 			isok++
 		}
-		if product_class_1!="" {
+		if product_class_1 != "" {
 			isok++
 		}
-		if product_class_2!="" {
+		if product_class_2 != "" {
 			isok++
 		}
-		if isok>2 {
-			UsedArr = append(UsedArr,v)
-		}else {
-			UnUsedArr = append(UnUsedArr,v)
+		if isok > 2 {
+			UsedArr = append(UsedArr, v)
+		} else {
+			UnUsedArr = append(UnUsedArr, v)
 		}
 	}
-	return UsedArr,UnUsedArr
+	return UsedArr, UnUsedArr
 }
-func dealWithYiXieClassData(classArr []map[string]interface{},largeClassName string) map[string]interface{}{
+func dealWithYiXieClassData(classArr []map[string]interface{}, largeClassName string) map[string]interface{} {
 	update := map[string]interface{}{}
 	okMap := map[string]map[string]interface{}{}
-	for _,v :=range classArr { //先对比class_2 在对比 品名举例
+	for _, v := range classArr { //先对比class_2 在对比 品名举例
 		product_class := qu.ObjToString(v["product_class"])
 		product_class_1 := qu.ObjToString(v["product_class_1"])
 		product_class_2 := qu.ObjToString(v["product_class_2"])
 		dict := map[string]interface{}{
-			"product_class":product_class,
-			"product_class_1":product_class_1,
-			"product_class_2":product_class_2,
+			"product_class":   product_class,
+			"product_class_1": product_class_1,
+			"product_class_2": product_class_2,
 		}
-		if product_class_2==largeClassName{
-			okey := product_class+"~"+product_class_1+"~"+product_class_2
-			if okMap[okey]==nil {
+		if product_class_2 == largeClassName {
+			okey := product_class + "~" + product_class_1 + "~" + product_class_2
+			if okMap[okey] == nil {
 				okMap[okey] = dict
 			}
 			continue
 		}
 	}
-	if len(okMap)==1 {
-		for _,v := range okMap{
+	if len(okMap) == 1 {
+		for _, v := range okMap {
 			update = map[string]interface{}{
-				"product_class":v["product_class"],
-				"product_class_1":v["product_class_1"],
-				"product_class_2":v["product_class_2"],
-				"isYiXieUpdate":true,
+				"product_class":   v["product_class"],
+				"product_class_1": v["product_class_1"],
+				"product_class_2": v["product_class_2"],
+				"isYiXieUpdate":   true,
 			}
 		}
-	}else if len(okMap)>1 { //冗余
+	} else if len(okMap) > 1 { //冗余
 		arr := []map[string]interface{}{}
-		for _,v := range okMap{
-			arr = append(arr,v)
+		for _, v := range okMap {
+			arr = append(arr, v)
 		}
 		update = map[string]interface{}{
-			"isYiXieClass":arr,
-			"isYiXieUpdate":true,
+			"isYiXieClass":  arr,
+			"isYiXieUpdate": true,
 		}
-	}else {
+	} else {
 
 	}
 	return update
@@ -452,128 +452,130 @@ func exportWordRepairSpec() {
 
 	sess := save_mgo.GetMgoConn()
 	defer save_mgo.DestoryMongoConn(sess)
-	q,total:=map[string]interface{}{},0
+	q, total := map[string]interface{}{}, 0
 	it := sess.DB(save_mgo.DbName).C("zzzzzkkkkk").Find(&q).Sort("_id").Iter()
-	for tmp := make(map[string]interface{}); it.Next(&tmp);total++{
+	for tmp := make(map[string]interface{}); it.Next(&tmp); total++ {
 		tmpid := BsonTOStringId(tmp["_id"])
-		if tmpid=="" {
+		if tmpid == "" {
 
 		}
 		product_name := qu.ObjToString(tmp["product_name"])
-		new_p_name:=gseReg.ReplaceAllString(product_name,"")
+		new_p_name := gseReg.ReplaceAllString(product_name, "")
 		//new_p_name =  strings.ReplaceAll(new_p_name,"一次性","")
 		//new_p_name =  strings.ReplaceAll(new_p_name,"使用","")
 		nameArr := GSE.Cut(new_p_name, true)
 
 		class_str := qu.ObjToString(tmp["class_str"])
-		classArr := strings.Split(class_str,",")
-		if len(classArr)>1 { //多分类
+		classArr := strings.Split(class_str, ",")
+		if len(classArr) > 1 { //多分类
 			ok_class_arr := []string{}
-			for _,cs := range classArr{
-				new_class_name :=  gseReg.ReplaceAllString(cs,"")
+			for _, cs := range classArr {
+				new_class_name := gseReg.ReplaceAllString(cs, "")
 				new_class_Arr := GSE.Cut(new_class_name, true)
-				b := cutWordThanData(nameArr,new_class_Arr)
+				b := cutWordThanData(nameArr, new_class_Arr)
 				if b {
-					ok_class_arr = append(ok_class_arr,cs)
+					ok_class_arr = append(ok_class_arr, cs)
 				}
 			}
 
-			if len(ok_class_arr)>1 {
-				ok_class_str := strings.Join(ok_class_arr,",")
-				save_mgo.UpdateById("zzzzzkkkkk",tmpid, map[string]interface{}{
+			if len(ok_class_arr) > 1 {
+				ok_class_str := strings.Join(ok_class_arr, ",")
+				save_mgo.UpdateById("zzzzzkkkkk", tmpid, map[string]interface{}{
 					"$set": map[string]interface{}{
-						"ok_class_more":ok_class_str,
+						"ok_class_more": ok_class_str,
 					},
 				})
-			}else {
-				ok_class_str := strings.Join(ok_class_arr,",")
-				save_mgo.UpdateById("zzzzzkkkkk",tmpid, map[string]interface{}{
+			} else {
+				ok_class_str := strings.Join(ok_class_arr, ",")
+				save_mgo.UpdateById("zzzzzkkkkk", tmpid, map[string]interface{}{
 					"$set": map[string]interface{}{
-						"ok_class_one":ok_class_str,
+						"ok_class_one": ok_class_str,
 					},
 				})
 			}
-		}else {
+		} else {
 			ok_class_str := qu.ObjToString(tmp["class_str"])
-			save_mgo.UpdateById("zzzzzkkkkk",tmpid, map[string]interface{}{
+			save_mgo.UpdateById("zzzzzkkkkk", tmpid, map[string]interface{}{
 				"$set": map[string]interface{}{
-					"ok_class_one":ok_class_str,
+					"ok_class_one": ok_class_str,
 				},
 			})
 		}
 
 		tmp = make(map[string]interface{})
 	}
-	log.Debug("加载完毕~",total)
+	log.Debug("加载完毕~", total)
 }
+
 //对比是否有效
-func breakUpdateData(usedArr []map[string]interface{},tmp map[string]interface{}) map[string]interface{} {
+func breakUpdateData(usedArr []map[string]interface{}, tmp map[string]interface{}) map[string]interface{} {
 	update := map[string]interface{}{}
 	class := qu.ObjToString(tmp["class"])
-	for _,v:=range usedArr {
+	for _, v := range usedArr {
 		used_class := qu.ObjToString(v["class"])
-		if used_class==class && class!="" {
+		if used_class == class && class != "" {
 			update = map[string]interface{}{
-				"product_class":qu.ObjToString(v["product_class"]),
-				"product_class_1":qu.ObjToString(v["product_class_1"]),
-				"product_class_2":qu.ObjToString(v["product_class_2"]),
+				"product_class":   qu.ObjToString(v["product_class"]),
+				"product_class_1": qu.ObjToString(v["product_class_1"]),
+				"product_class_2": qu.ObjToString(v["product_class_2"]),
 			}
 			break
 		}
 	}
 	return update
 }
+
 //对比-未分类-切词比对
-func exportThanWordClassData()  {
+func exportThanWordClassData() {
 	log.Debug("匹配分词-比对......")
 	GSE.LoadDict("./dictionary.txt")
 
 	sess := save_mgo.GetMgoConn()
 	defer save_mgo.DestoryMongoConn(sess)
-	q,total:=map[string]interface{}{},0
+	q, total := map[string]interface{}{}, 0
 	classArr := []map[string]interface{}{}
 	it := sess.DB(save_mgo.DbName).C("nmpa_class_example").Find(&q).Sort("_id").Select(map[string]interface{}{
-		"product_class":1,
-		"product_class_1":1,
-		"product_class_2":1,
-		"product_example":1,
+		"product_class":   1,
+		"product_class_1": 1,
+		"product_class_2": 1,
+		"product_example": 1,
 	}).Iter()
-	for tmp := make(map[string]interface{}); it.Next(&tmp);total++{
-		delete(tmp,"_id")
-		classArr = append(classArr,tmp)
+	for tmp := make(map[string]interface{}); it.Next(&tmp); total++ {
+		delete(tmp, "_id")
+		classArr = append(classArr, tmp)
 		tmp = make(map[string]interface{})
 	}
-	log.Debug("加载完毕~",len(classArr))
+	log.Debug("加载完毕~", len(classArr))
 
-	isok,isup :=0,0
+	isok, isup := 0, 0
 	it = sess.DB(save_mgo.DbName).C("nmpa_product").Find(&q).Sort("_id").Select(map[string]interface{}{
-		"product_name":1,
-		"isContainsUpdate":1,
-		"isMustUpdate":1,
-		"isYiXieUpdate":1,
+		"product_name":     1,
+		"isContainsUpdate": 1,
+		"isMustUpdate":     1,
+		"isYiXieUpdate":    1,
 	}).Iter()
-	for tmp := make(map[string]interface{}); it.Next(&tmp);total++{
-		if total%1000==0 {
-			log.Debug("cur index ", total,"~",isok,"~",isup)
+	for tmp := make(map[string]interface{}); it.Next(&tmp); total++ {
+		if total%1000 == 0 {
+			log.Debug("cur index ", total, "~", isok, "~", isup)
 		}
 		tmpid := BsonTOStringId(tmp["_id"])
-		isMust ,isContains,isYiXie:= false,false,false
-		if is,ok := tmp["isMustUpdate"].(bool);ok {
+		isMust, isContains, isYiXie := false, false, false
+		if is, ok := tmp["isMustUpdate"].(bool); ok {
 			isMust = is
 		}
-		if is,ok := tmp["isContainsUpdate"].(bool);ok {
+		if is, ok := tmp["isContainsUpdate"].(bool); ok {
 			isContains = is
 		}
-		if is,ok := tmp["isYiXieUpdate"].(bool);ok {
+		if is, ok := tmp["isYiXieUpdate"].(bool); ok {
 			isYiXie = is
 		}
 		if !isContains && !isMust && !isYiXie {
 			isok++
 			product_name := qu.ObjToString(tmp["product_name"])
-			update := dealWithClassData(product_name,classArr)
-			if len(update)>0 {
+			update := dealWithClassData(product_name, classArr)
+			if len(update) > 0 {
 				isup++
-				save_mgo.UpdateById("nmpa_product",tmpid, map[string]interface{}{
+				save_mgo.UpdateById("nmpa_product", tmpid, map[string]interface{}{
 					"$set": update,
 				})
 			}
@@ -581,47 +583,44 @@ func exportThanWordClassData()  {
 		tmp = make(map[string]interface{})
 	}
 
-	log.Debug("is over ", total,"~",isok,"~",isup)
+	log.Debug("is over ", total, "~", isok, "~", isup)
 }
+
 //比对打标签
 func exportOtherClassData() {
 
 	sess := save_mgo.GetMgoConn()
 	defer save_mgo.DestoryMongoConn(sess)
-	q,total:=map[string]interface{}{},0
+	q, total := map[string]interface{}{}, 0
 	classArr := []map[string]interface{}{}
 	it := sess.DB(save_mgo.DbName).C("nmpa_class_example").Find(&q).Sort("_id").Iter()
-	for tmp := make(map[string]interface{}); it.Next(&tmp);total++{
-		delete(tmp,"_id")
-		delete(tmp,"product_level")
-		delete(tmp,"product_describe")
-		delete(tmp,"product_effect")
-		classArr = append(classArr,tmp)
+	for tmp := make(map[string]interface{}); it.Next(&tmp); total++ {
+		delete(tmp, "_id")
+		delete(tmp, "product_level")
+		delete(tmp, "product_describe")
+		delete(tmp, "product_effect")
+		classArr = append(classArr, tmp)
 		tmp = make(map[string]interface{})
 	}
-	log.Debug("加载完毕~",len(classArr))
+	log.Debug("加载完毕~", len(classArr))
 	log.Debug("开始数据处理...")
 
-
-
 	it = sess.DB(save_mgo.DbName).C("nmpa_product").Find(&q).Sort("_id").Select(map[string]interface{}{
-		"product_name":1,
+		"product_name": 1,
 	}).Iter()
-	for tmp := make(map[string]interface{}); it.Next(&tmp);total++{
-		if total%1000==0 {
+	for tmp := make(map[string]interface{}); it.Next(&tmp); total++ {
+		if total%1000 == 0 {
 			log.Debug("cur index ", total)
 		}
 		product_name := qu.ObjToString(tmp["product_name"])
 		tmpid := BsonTOStringId(tmp["_id"])
-		update := dealWithClassData(product_name,classArr)
-		save_mgo.UpdateById("nmpa_product",tmpid, map[string]interface{}{
+		update := dealWithClassData(product_name, classArr)
+		save_mgo.UpdateById("nmpa_product", tmpid, map[string]interface{}{
 			"$set": update,
 		})
 		tmp = make(map[string]interface{})
 	}
 
-
-
 	/*
 		统计A:
 		1、有效分类:109582
@@ -636,22 +635,21 @@ func exportOtherClassData() {
 		2、疑似分类(包含有效):161906
 	*/
 
-
 	log.Debug("is over ... ...")
 }
+
 //切词比对
-func cutWordThanData(nameArr []string,classArr []string) bool {
-	isok:=0
-	for _,v := range nameArr {
-		for _,v1:=range classArr {
-			if v==v1 {
+func cutWordThanData(nameArr []string, classArr []string) bool {
+	isok := 0
+	for _, v := range nameArr {
+		for _, v1 := range classArr {
+			if v == v1 {
 				isok++
 			}
 		}
 	}
 
-
-	if isok>0 {
+	if isok > 0 {
 		return true
 	}
 	//if isok>0 && isok > len(nameArr)/2 && isok > len(classArr)/2{
@@ -659,47 +657,48 @@ func cutWordThanData(nameArr []string,classArr []string) bool {
 	//}
 	return false
 }
+
 //根据产品-公司导出68xx 16-01 相关数据-待定...
-func exportNewClassCompanyData()  {
+func exportNewClassCompanyData() {
 	sess := save_mgo.GetMgoConn()
 	defer save_mgo.DestoryMongoConn(sess)
-	q,total:=map[string]interface{}{},0
+	q, total := map[string]interface{}{}, 0
 	it := sess.DB(save_mgo.DbName).C("nmpa_product").Find(&q).Sort("_id").Select(map[string]interface{}{
-		"reg_company":1,
-		"product_class":1,
-		"product_class_1":1,
-		"product_class_2":1,
-		"product_name":1,
+		"reg_company":     1,
+		"product_class":   1,
+		"product_class_1": 1,
+		"product_class_2": 1,
+		"product_name":    1,
 	}).Iter()
-	isok:=0
-	dict:=map[string]string{
-		"01":"有源手术器械",
-		"02":"无源手术器械",
-		"03":"神经和心血管手术器械",
-		"04":"骨科手术器械",
-		"05":"放射治疗器械",
-		"06":"医用成像器械",
-		"07":"医用诊察和监护器械",
-		"08":"呼吸、麻醉和急救器械",
-		"09":"物理治疗器械",
-		"10":"输血、透析和体外循环器械",
-		"11":"医疗器械消毒灭菌器械",
-		"12":"有源植入器械",
-		"13":"无源植入器械",
-		"14":"注输、护理和防护器械",
-		"15":"患者承载器械",
-		"16":"眼科器械",
-		"17":"口腔科器械",
-		"18":"妇产科、辅助生殖和避孕器械",
-		"19":"医用康复器械",
-		"20":"中医器械",
-		"21":"医用软件",
-		"22":"临床检验器械",
+	isok := 0
+	dict := map[string]string{
+		"01": "有源手术器械",
+		"02": "无源手术器械",
+		"03": "神经和心血管手术器械",
+		"04": "骨科手术器械",
+		"05": "放射治疗器械",
+		"06": "医用成像器械",
+		"07": "医用诊察和监护器械",
+		"08": "呼吸、麻醉和急救器械",
+		"09": "物理治疗器械",
+		"10": "输血、透析和体外循环器械",
+		"11": "医疗器械消毒灭菌器械",
+		"12": "有源植入器械",
+		"13": "无源植入器械",
+		"14": "注输、护理和防护器械",
+		"15": "患者承载器械",
+		"16": "眼科器械",
+		"17": "口腔科器械",
+		"18": "妇产科、辅助生殖和避孕器械",
+		"19": "医用康复器械",
+		"20": "中医器械",
+		"21": "医用软件",
+		"22": "临床检验器械",
 		"27": "中医器械",
 		"28": "医用成像器械",
 		"32": "放射治疗器械",
 		"34": "医用成像器械",
-		"40":"体外诊断试剂",
+		"40": "体外诊断试剂",
 		"41": "临床检验器械",
 		"45": "输血、透析和体外循环器械",
 		"55": "口腔科器械",
@@ -710,63 +709,63 @@ func exportNewClassCompanyData()  {
 	}
 	reg_reg := regexp.MustCompile("[,,::][0-1][0-9]-[0-9]+")
 	clear_reg := regexp.MustCompile("[,,::]")
-	for tmp := make(map[string]interface{}); it.Next(&tmp);total++{
-		if total % 10000 == 0 {
-			log.Debug("cur index ",total,"~",isok)
+	for tmp := make(map[string]interface{}); it.Next(&tmp); total++ {
+		if total%10000 == 0 {
+			log.Debug("cur index ", total, "~", isok)
 		}
 		product_name := qu.ObjToString(tmp["product_name"])
 		product_class := qu.ObjToString(tmp["product_class"])
 		product_class_1 := qu.ObjToString(tmp["product_class"])
 		product_class_2 := qu.ObjToString(tmp["product_class"])
 		reg_company := qu.ObjToString(tmp["reg_company"])
-		if product_class=="" ||product_class_1==""||product_class_2==""  {
-			dataArr,_ := save_mgo.Find("nmpa_company", map[string]interface{}{
-				"company" : reg_company,
-				"class":"生产型",
-			},nil,map[string]interface{}{
-				"business_range":1,
-				"product_range":1,
+		if product_class == "" || product_class_1 == "" || product_class_2 == "" {
+			dataArr, _ := save_mgo.Find("nmpa_company", map[string]interface{}{
+				"company": reg_company,
+				"class":   "生产型",
+			}, nil, map[string]interface{}{
+				"business_range": 1,
+				"product_range":  1,
 			})
 
 			oldArr := []string{}
 			oldMap := map[string]string{}
-			for _,v := range dataArr {
+			for _, v := range dataArr {
 				range_str := ""
 				business_range := qu.ObjToString(v["business_range"])
-				product_range :=  qu.ObjToString(v["product_range"])
-				if business_range!="" {
+				product_range := qu.ObjToString(v["product_range"])
+				if business_range != "" {
 					range_str = business_range
-				}else {
+				} else {
 					range_str = product_range
 				}
-				arr := reg_reg.FindAllString(range_str,-1)
-				for _,v1:=range arr{
-					new_v1 := clear_reg.ReplaceAllString(v1,"")
+				arr := reg_reg.FindAllString(range_str, -1)
+				for _, v1 := range arr {
+					new_v1 := clear_reg.ReplaceAllString(v1, "")
 					new_v1 = new_v1[:2]
 					vvvv := dict[new_v1]
 					//去重拼接
-					if oldMap[vvvv]=="" && vvvv!=""{
+					if oldMap[vvvv] == "" && vvvv != "" {
 						//映射值
-						oldArr = append(oldArr,vvvv)
+						oldArr = append(oldArr, vvvv)
 						oldMap[vvvv] = vvvv
 					}
 				}
 			}
 
-			if len(oldArr)>0 {
+			if len(oldArr) > 0 {
 				isok++
-				class_str := strings.Join(oldArr,",")
+				class_str := strings.Join(oldArr, ",")
 				save_mgo.Save("zzzzzkkkkk", map[string]interface{}{
-					"_id":tmp["_id"],
-					"class_str":class_str,
-					"product_name":product_name,
+					"_id":          tmp["_id"],
+					"class_str":    class_str,
+					"product_name": product_name,
 				})
 			}
 		}
 		tmp = make(map[string]interface{})
 	}
 
-	log.Debug("is over ",total,"~",isok)
+	log.Debug("is over ", total, "~", isok)
 }