Browse Source

拆库~表明调整~程序调整~完毕 (目前:代码表+医院关联功能均正常)

zhengkun 3 years ago
parent
commit
3b63a29540

+ 14 - 14
fieldproject_medical/data_preparation/src/class/initcode.go

@@ -7,7 +7,7 @@ import (
 
 //加载地域
 func initRegion() {
-	data_region := MysqlTool.Find("code_area", nil, "", "", -1, -1)
+	data_region := MysqlGlobalTool.Find(V_Code_Area, nil, "", "", -1, -1)
 	for _, v := range *data_region {
 		code := qu.ObjToString(v["code"])
 		area := qu.ObjToString(v["area"])
@@ -30,18 +30,18 @@ func initRegion() {
 
 //加载等级代码表~level
 func initLevel() {
-	data_level := MysqlTool.Find("code_medical_institution_level", nil, "name,code", "", -1, -1)
+	data_level := MysqlMedicalTool.Find(V_Code_Level, nil, "name,code", "", -1, -1)
 	for _, v := range *data_level {
 		name := qu.ObjToString(v["name"])
 		code := qu.ObjToString(v["code"])
-		Medical_Level_Code[name] = code
+		Medical_Level_Datas[name] = code
 	}
-	log.Debug("医疗等级表~", len(Medical_Level_Code))
+	log.Debug("医疗等级表~", len(Medical_Level_Datas))
 }
 
 //加载类型代码表~type
 func initType() {
-	data_type := MysqlTool.Find("code_medical_institution_type", nil, "", "", -1, -1)
+	data_type := MysqlMedicalTool.Find(V_Code_Type, nil, "", "", -1, -1)
 	for _, v := range *data_type {
 		code := qu.ObjToString(v["code"])
 		pcode := qu.ObjToString(v["pcode"])
@@ -50,7 +50,7 @@ func initType() {
 		if qu.IntAll(v["level"]) == 1 {
 			key = name + "~"
 		} else if qu.IntAll(v["level"]) == 2 {
-			data := *MysqlTool.FindOne("code_medical_institution_type", map[string]interface{}{
+			data := *MysqlMedicalTool.FindOne(V_Code_Type, map[string]interface{}{
 				"code": pcode,
 			}, "name", "")
 			pname := qu.ObjToString(data["name"])
@@ -58,20 +58,20 @@ func initType() {
 		} else {
 
 		}
-		Medical_Type_Code[key] = code
+		Medical_Type_Datas[key] = code
 	}
-	log.Debug("医疗类型表表~", len(Medical_Type_Code))
+	log.Debug("医疗类型表表~", len(Medical_Type_Datas))
 }
 
 //加载科室代码表
 func initDeparts() {
-	data_departs := MysqlTool.Find("code_medical_institution_department", nil, "", "", -1, -1)
+	data_departs := MysqlMedicalTool.Find(V_Code_Department, nil, "", "", -1, -1)
 	//先构建所有一级数据
 	for _, v := range *data_departs {
 		name := qu.ObjToString(v["name"])
 		code := qu.ObjToString(v["code"])
 		if qu.IntAll(v["level"]) == 1 {
-			Medical_Departs_Code[name] = map[string]string{
+			Medical_Departs_Datas[name] = map[string]string{
 				"departs_code": code,
 			}
 		}
@@ -82,16 +82,16 @@ func initDeparts() {
 		name := qu.ObjToString(v["name"])
 		if qu.IntAll(v["level"]) == 2 {
 			match_name := ""
-			for k, v := range Medical_Departs_Code {
+			for k, v := range Medical_Departs_Datas {
 				if v["departs_code"] == pcode {
 					match_name = k
 					break
 				}
 			}
-			data := Medical_Departs_Code[match_name]
+			data := Medical_Departs_Datas[match_name]
 			data[name] = code
-			Medical_Departs_Code[match_name] = data
+			Medical_Departs_Datas[match_name] = data
 		}
 	}
-	log.Debug("医疗科室表~", len(Medical_Departs_Code))
+	log.Debug("医疗科室表~", len(Medical_Departs_Datas))
 }

+ 66 - 23
fieldproject_medical/data_preparation/src/class/initdata.go

@@ -4,17 +4,45 @@ import (
 	log "github.com/donnie4w/go-logger/logger"
 )
 
+const (
+	V_Product_Baseinfo       = "product_baseinfo"
+	V_Company_Makeproduct    = "company_makeproduct"
+	V_Company_Bussproduct    = "company_bussproduct"
+	V_Institution_Baseinfo   = "institution_baseinfo"
+	V_Institution_Department = "institution_department"
+	V_Institution_Alias      = "institution_alias"
+	V_Institution_Departtags = "institution_departtags"
+	V_Institution_Typetags   = "institution_typetags"
+	V_Code_Level             = "code_level"
+	V_Code_Department        = "code_department"
+	V_Code_Productclass      = "code_productclass"
+	V_Code_Type              = "code_type "
+	V_Code_Sdleveltypeequip  = "code_sdleveltypeequip"
+
+	V_Code_Bidfield      = "code_bidfield"
+	V_Code_Bidscope      = "code_bidscope"
+	V_Code_Bidtopsubtype = "code_bidtopsubtype"
+	V_Code_Area          = "code_area"
+
+	V_Code_Buyerfield = "code_buyerfield"
+	V_Code_Buyerclass = "code_buyerclass"
+
+	S_Product_Coll = "zktest_mysql_product_info"
+	S_Company_Coll = "zktest_mysql_company_info"
+	S_Region_Coll  = "zktest_mysql_area_new"
+)
+
 var (
-	Save_Mgo, Spi_Mgo *MongodbSim
-	MysqlTool         *Mysql
-	Config            map[string]interface{}
+	Save_Mgo, Spi_Mgo                 *MongodbSim
+	MysqlMedicalTool, MysqlGlobalTool *Mysql
+	Config                            map[string]interface{}
 	//类型规则
 	Medical_RuleType = []map[string]interface{}{}
 	//涉及的代码表
-	Medical_Type_Code    = map[string]string{}
-	Medical_Level_Code   = map[string]string{}
-	Medical_BusType_Code = map[string]int{"公立": 1, "民营": 2, "其它": 3}
-	Medical_Departs_Code = map[string]map[string]string{}
+	Medical_Type_Datas    = map[string]string{}
+	Medical_Level_Datas   = map[string]string{}
+	Medical_BusType_Datas = map[string]int{"公立": 1, "民营": 2, "其它": 3}
+	Medical_Departs_Datas = map[string]map[string]string{}
 	//医学百科相关数据
 	Medical_YiXue_Data = map[string]map[string]interface{}{}
 	//地域相关
@@ -29,25 +57,16 @@ var (
 func InitClass() {
 	isLocal = true //本地
 	initMgo()
+	initLocalData()
 	initMysql()
 	initVCode()
-	initLocalData()
 }
 
 //初始化mgo
 func initMgo() {
 	if isLocal {
-		Save_Mgo = &MongodbSim{
-			MongodbAddr: "127.0.0.1:27017",
-			DbName:      "zhengkun",
-			Size:        10,
-			UserName:    "",
-			Password:    "",
-		}
-		Save_Mgo.InitPool()
-
 		//Save_Mgo = &MongodbSim{
-		//	MongodbAddr: "192.168.3.207:27092",
+		//	MongodbAddr: "127.0.0.1:27017",
 		//	DbName:      "zhengkun",
 		//	Size:        10,
 		//	UserName:    "",
@@ -55,6 +74,15 @@ func initMgo() {
 		//}
 		//Save_Mgo.InitPool()
 
+		Save_Mgo = &MongodbSim{
+			MongodbAddr: "192.168.3.207:27092",
+			DbName:      "zhengkun",
+			Size:        10,
+			UserName:    "",
+			Password:    "",
+		}
+		Save_Mgo.InitPool()
+
 		Spi_Mgo = &MongodbSim{
 			MongodbAddr: "127.0.0.1:27017",
 			DbName:      "zhengkun",
@@ -85,13 +113,21 @@ func initMgo() {
 }
 
 func initMysql() {
-	MysqlTool = &Mysql{
+	MysqlMedicalTool = &Mysql{
 		Address:  "192.168.3.217:4000",
 		UserName: "root",
 		PassWord: "=PDT49#80Z!RVv52_z",
-		DBName:   "field_medical_data",
+		DBName:   "medical_fileld_data",
 	}
-	MysqlTool.Init()
+	MysqlMedicalTool.Init()
+
+	MysqlGlobalTool = &Mysql{
+		Address:  "192.168.3.217:4000",
+		UserName: "root",
+		PassWord: "=PDT49#80Z!RVv52_z",
+		DBName:   "global_common_data",
+	}
+	MysqlGlobalTool.Init()
 }
 
 //加载代码表~
@@ -108,8 +144,15 @@ func initLocalData() {
 }
 
 //插入数据
-func InsertMysqlData(name string, data map[string]interface{}, mark string) int64 {
-	inb := MysqlTool.Insert(name, data)
+func InsertMedicalMysqlData(name string, data map[string]interface{}, mark string) int64 {
+	inb := MysqlMedicalTool.Insert(name, data)
+	if inb == -1 {
+		log.Debug("插入数据异常...", name, "~", mark)
+	}
+	return inb
+}
+func InsertGlobalMysqlData(name string, data map[string]interface{}, mark string) int64 {
+	inb := MysqlGlobalTool.Insert(name, data)
 	if inb == -1 {
 		log.Debug("插入数据异常...", name, "~", mark)
 	}

+ 6 - 6
fieldproject_medical/data_preparation/src/company/company.go

@@ -22,7 +22,7 @@ func dealWithCompanyProductInfo() {
 	sess := class.Save_Mgo.GetMgoConn()
 	defer class.Save_Mgo.DestoryMongoConn(sess)
 	q := map[string]interface{}{}
-	it := sess.DB(class.Save_Mgo.DbName).C("zktest_mysql_company_info").Find(&q).Sort("_id").Iter()
+	it := sess.DB(class.Save_Mgo.DbName).C(class.S_Company_Coll).Find(&q).Sort("_id").Iter()
 	pool := make(chan bool, 6)
 	wg := &sync.WaitGroup{}
 	total, isok1, isok2 := 0, 0, 0
@@ -47,13 +47,13 @@ func dealWithCompanyProductInfo() {
 			companylock.Unlock()
 			for _, info := range sc_info_arr {
 				info["comeintime"] = time.Unix(time.Now().Unix(), 0).Format(class.TimeLayout)
-				//插入sql company_makeproduct
-				class.InsertMysqlData("company_makeproduct", info, company_id)
+				//插入sql
+				class.InsertMedicalMysqlData(class.V_Company_Makeproduct, info, company_id)
 			}
 			for _, info := range jy_info_arr {
 				info["comeintime"] = time.Unix(time.Now().Unix(), 0).Format(class.TimeLayout)
-				//插入sql company_bussproduct
-				class.InsertMysqlData("company_bussproduct", info, company_id)
+				//插入sql
+				class.InsertMedicalMysqlData(class.V_Company_Bussproduct, info, company_id)
 			}
 
 		}(tmp)
@@ -70,7 +70,7 @@ func treatCompanyTypeInfo(company_type string, company_id string) ([]map[string]
 	jy_info := []map[string]interface{}{}
 
 	//关联的有product.id 需要生成产品表
-	dataArr := *class.MysqlTool.Find("medical_equipment_productinfo", map[string]interface{}{
+	dataArr := *class.MysqlMedicalTool.Find(class.V_Product_Baseinfo, map[string]interface{}{
 		"company_id": company_id,
 	}, "product_id,product_name,approve_date,medical_equipment_code", "", -1, -1)
 	if len(dataArr) == 0 || dataArr == nil {

+ 1 - 1
fieldproject_medical/data_preparation/src/hospital/hospital_repair.go

@@ -19,7 +19,7 @@ func RunRepairHospitalInfo() {
 	wg := &sync.WaitGroup{}
 	total := 0
 	for tmp := make(map[string]interface{}); it.Next(&tmp); total++ {
-		if total%100 == 0 {
+		if total%1000 == 0 {
 			log.Debug("cur index ", total)
 		}
 		pool <- true

+ 11 - 11
fieldproject_medical/data_preparation/src/hospital/hospital_sql.go

@@ -97,16 +97,16 @@ func createBaseInfo(tmp map[string]interface{}) string {
 	data_info["mark_id"] = qu.IntAll(tmp["mark_id"])
 	data_info["comeintime"] = time.Unix(time.Now().Unix(), 0).Format(class.TimeLayout)
 	data_info["updatetime"] = time.Unix(time.Now().Unix(), 0).Format(class.TimeLayout)
-	//插入sql  medical_institution_info
-	class.InsertMysqlData("medical_institution_info", data_info, name)
+	//插入sql
+	class.InsertMedicalMysqlData(class.V_Institution_Baseinfo, data_info, name)
 
 	//类型标签
 	data_tag := map[string]interface{}{}
 	data_tag["company_id"] = qu.ObjToString(tmp["company_id"])
 	data_tag["labelcode"] = new_type
 	data_tag["comeintime"] = time.Unix(time.Now().Unix(), 0).Format(class.TimeLayout)
-	//插入sql  medical_institution_typetags
-	class.InsertMysqlData("medical_institution_typetags", data_tag, name)
+	//插入sql
+	class.InsertMedicalMysqlData(class.V_Institution_Typetags, data_tag, name)
 
 	return new_level
 }
@@ -126,8 +126,8 @@ func createAliasInfo(tmp map[string]interface{}) {
 		data["alias_type"] = 2
 		data["source_type"] = 2
 		data["comeintime"] = time.Unix(time.Now().Unix(), 0).Format(class.TimeLayout)
-		//插入~sql medical_institution_alias
-		class.InsertMysqlData("medical_institution_alias", data, name)
+		//插入~sql
+		class.InsertMedicalMysqlData(class.V_Institution_Alias, data, name)
 
 	}
 }
@@ -157,23 +157,23 @@ func createDepartsInfo(tmp map[string]interface{}, level string) {
 		data["comeintime"] = time.Unix(time.Now().Unix(), 0).Format(class.TimeLayout)
 		data["updatetime"] = time.Unix(time.Now().Unix(), 0).Format(class.TimeLayout)
 		//插入~sql  medical_institution_department
-		class.InsertMysqlData("medical_institution_department", data, name)
+		class.InsertMedicalMysqlData(class.V_Institution_Department, data, name)
 
 		data_tag := map[string]interface{}{}
 		data_tag["company_id"] = qu.ObjToString(tmp["company_id"])
 		data_tag["labelcode"] = depart_code
 		data_tag["comeintime"] = time.Unix(time.Now().Unix(), 0).Format(class.TimeLayout)
 		//插入~sql  medical_institution_departtags
-		class.InsertMysqlData("medical_institution_departtags", data_tag, name)
+		class.InsertMedicalMysqlData(class.V_Institution_Departtags, data_tag, name)
 
 	}
 }
 
 //等级,类型,性质代码化
 func codificationOfInfo(med_level string, med_type string, med_bustype string) (string, string, int, string) {
-	new_level := class.Medical_Level_Code[med_level]
-	new_bustype := class.Medical_BusType_Code[med_bustype]
-	new_type := class.Medical_Type_Code[med_type]
+	new_level := class.Medical_Level_Datas[med_level]
+	new_bustype := class.Medical_BusType_Datas[med_bustype]
+	new_type := class.Medical_Type_Datas[med_type]
 	new_sdequipment := new_level[:2] + new_type
 	return new_level, new_type, new_bustype, new_sdequipment
 }

+ 3 - 3
fieldproject_medical/data_preparation/src/hospital/hospital_ways.go

@@ -198,7 +198,7 @@ func confirmDepartNameCode(class1 string, class2 string) (string, string) {
 	new_name := ""
 	new_code := "" //默认其它~
 	//一系列对比~
-	departs := class.Medical_Departs_Code[class1]
+	departs := class.Medical_Departs_Datas[class1]
 	if departs != nil { //一级科室能匹配上
 		new_name = class1
 		new_code = departs["departs_code"]
@@ -213,7 +213,7 @@ func confirmDepartNameCode(class1 string, class2 string) (string, string) {
 		}
 	} else {
 		new_name = "其它"
-		new_code = class.Medical_Departs_Code[new_name]["departs_code"]
+		new_code = class.Medical_Departs_Datas[new_name]["departs_code"]
 	}
 	return new_name, new_code
 }
@@ -322,7 +322,7 @@ func relevanceLevel(med_level string) string {
 	if med_lev_Reg2.MatchString(med_level) {
 		med_level = med_lev_Reg2.ReplaceAllString(med_level, "${1}${2}其它")
 	}
-	if class.Medical_Level_Code[med_level] != "" {
+	if class.Medical_Level_Datas[med_level] != "" {
 		new_level = med_level
 	}
 	return new_level

+ 4 - 2
fieldproject_medical/data_preparation/src/main.go

@@ -12,19 +12,21 @@ func init() {
 	class.InitClass()
 }
 func main() {
+	log.Debug("run main ... ")
+
 	//医院基本信息整合~线下~加载代码表~临时
 	//hospital.RunBuildHospitalInfo()
 	//hospital.RunCleanHospitalInfo()
 	//hospital.RunMergeHospitalInfo()
 	//暂时需要线上补充~数据
 	//hospital.RunRepairHospitalInfo()
-	//导入信息~医疗六张表
+	//导入信息~医疗六张sql
 	//hospital.ExportHospitalInfoToMysql()
 
 	//产品基本信息
 	//product.RunMedicalProductInfo()
 
-	//企业产品~信息
+	//企业生产经营产品~信息
 	//company.RunCompanyProductInfo()
 
 	//代码表构建

+ 2 - 20
fieldproject_medical/data_preparation/src/product/product.go

@@ -22,7 +22,7 @@ func dealWithMedicalProductInfo() {
 	sess := class.Save_Mgo.GetMgoConn()
 	defer class.Save_Mgo.DestoryMongoConn(sess)
 	q := map[string]interface{}{}
-	it := sess.DB(class.Save_Mgo.DbName).C("zktest_mysql_product_info").Find(&q).Sort("_id").Iter()
+	it := sess.DB(class.Save_Mgo.DbName).C(class.S_Product_Coll).Find(&q).Sort("_id").Iter()
 	pool := make(chan bool, 5)
 	wg := &sync.WaitGroup{}
 	total := 0
@@ -41,7 +41,7 @@ func dealWithMedicalProductInfo() {
 			dict := treatProductInfo(tmp)
 			tmpid := class.BsonTOStringId(tmp["_id"])
 			//插入sql
-			class.InsertMysqlData("medical_equipment_productinfo", dict, tmpid)
+			class.InsertMedicalMysqlData(class.V_Product_Baseinfo, dict, tmpid)
 		}(tmp)
 		tmp = make(map[string]interface{})
 	}
@@ -99,9 +99,6 @@ func treatProductInfo(tmp map[string]interface{}) map[string]interface{} {
 
 //清洗日期~
 func cleanErrDateTime(datetime string) bool {
-	/*
-		1、有效年1900 ~  2200年
-	*/
 	arr := strings.Split(datetime, "-")
 	if len(arr) > 0 {
 		year := qu.IntAll(arr[0])
@@ -111,18 +108,3 @@ func cleanErrDateTime(datetime string) bool {
 	}
 	return false
 }
-
-func temporaryRepair() {
-	arr := []string{
-		"61f0eb909c2559e454683bba",
-		"61f0eb949c2559e4546840e7",
-		"61f0eb999c2559e45468486c",
-	}
-
-	for _, tmpid := range arr {
-		tmp := class.Save_Mgo.FindById("zktest_mysql_product_info", tmpid)
-		dict := treatProductInfo(tmp)
-		//插入sql
-		class.InsertMysqlData("medical_equipment_productinfo", dict, tmpid)
-	}
-}

+ 97 - 26
fieldproject_medical/data_preparation/src/repair/repairclass.go

@@ -2,47 +2,118 @@ package repair
 
 import (
 	"class"
+	"fmt"
 	log "github.com/donnie4w/go-logger/logger"
+	qu "qfw/util"
 )
 
-//修复体外诊断试剂的code  207表
-func repairTwzdsjCode() {
-	//加载新版本分类目录
+var (
+	NameLevelPcode = map[string]map[string]string{}
+)
+
+//修复全量表数 新版本分类目录
+func RpairProductAllCodeName() {
+	//构建分类目录
+	datas := *class.MysqlMedicalTool.Find(class.V_Code_Productclass, nil, "", "", -1, -1)
+	for _, v := range datas {
+		name := qu.ObjToString(v["name"])
+		level := fmt.Sprintf("%d", v["level"])
+		pcode := qu.ObjToString(v["pcode"])
+		code := qu.ObjToString(v["code"])
+
+		key := name + "~" + level + "~" + pcode
+		if NameLevelPcode[key] == nil {
+			NameLevelPcode[key] = map[string]string{
+				"name": name,
+				"code": code,
+			}
+		}
+	}
+	log.Debug("分类目录准备~", len(NameLevelPcode))
+
 	sess := class.Save_Mgo.GetMgoConn()
 	defer class.Save_Mgo.DestoryMongoConn(sess)
 	q := map[string]interface{}{}
-	it := sess.DB(class.Save_Mgo.DbName).C("zktest_mysql_product_info").Find(&q).Select(map[string]interface{}{
+	it := sess.DB(class.Save_Mgo.DbName).C(class.S_Product_Coll).Find(&q).Select(map[string]interface{}{
+		"product_code":   1,
 		"product_class1": 1,
 		"product_class2": 1,
 		"product_class3": 1,
 		"product_class4": 1,
 	}).Sort("_id").Iter()
-	total := 0
+	total, is_err := 0, 0
 	for tmp := make(map[string]interface{}); it.Next(&tmp); total++ {
 		if total%10000 == 0 {
-			log.Debug("cur index ", total)
+			log.Debug("cur index ", total, "~", is_err)
 		}
-		//new_dict := map[string]interface{}{
-		//	"product_class1": "",
-		//	"product_class2": "",
-		//	"product_class3": "",
-		//	"product_class4": "",
-		//	"product_code":   "",
-		//}
-		//
-		////刷数据
-		//product_class1 := qu.ObjToString(tmp["product_class1"])
-		//product_class2 := qu.ObjToString(tmp["product_class2"])
-		//product_class3 := qu.ObjToString(tmp["product_class3"])
-		//product_class4 := qu.ObjToString(tmp["product_class4"])
-		//
-		//if product_class1 != "" {
-		//
-		//}
-
-		//code_medical_equipment_product
+		//刷数据
+		product_code := qu.ObjToString(tmp["product_code"])
+		product_class1 := qu.ObjToString(tmp["product_class1"])
+		product_class2 := qu.ObjToString(tmp["product_class2"])
+		product_class3 := qu.ObjToString(tmp["product_class3"])
+		product_class4 := qu.ObjToString(tmp["product_class4"])
+		update := map[string]interface{}{
+			"product_class1": "",
+			"product_class2": "",
+			"product_class3": "",
+			"product_class4": "",
+			"product_code":   "",
+			"before_class": map[string]interface{}{
+				"product_code":   product_code,
+				"product_class1": product_class1,
+				"product_class2": product_class2,
+				"product_class3": product_class3,
+				"product_class4": product_class4,
+			},
+		}
+		if product_class1 != "" {
+			name_1, code_1 := acquireMedicalClassData(product_class1, "1", "")
+			if name_1 != "" && code_1 != "" {
+				update["product_class1"] = name_1
+				update["product_code"] = code_1
+				if product_class2 != "" {
+					name_2, code_2 := acquireMedicalClassData(product_class2, "2", code_1)
+					if name_2 != "" && code_2 != "" {
+						update["product_class2"] = name_2
+						update["product_code"] = code_2
+						if product_class3 != "" {
+							name_3, code_3 := acquireMedicalClassData(product_class3, "3", code_2)
+							if name_3 != "" && code_3 != "" {
+								update["product_class3"] = name_3
+								update["product_code"] = code_3
+								if product_class4 != "" {
+									name_4, code_4 := acquireMedicalClassData(product_class4, "4", code_3)
+									if name_4 != "" && code_4 != "" {
+										update["product_class4"] = name_4
+										update["product_code"] = code_4
+									}
+								}
+							}
+						}
+					}
+				}
+			}
+		}
+		if qu.ObjToString(update["product_code"]) != product_code {
+			is_err++
+		}
+		tmpid := class.BsonTOStringId(tmp["_id"])
+		class.Save_Mgo.UpdateById(class.S_Product_Coll, tmpid, map[string]interface{}{
+			"$set": update,
+		})
 		tmp = make(map[string]interface{})
 	}
 
-	log.Debug("is over ", total)
+	log.Debug("is over ", total, "~", is_err)
+}
+
+func acquireMedicalClassData(name string, level string, pcode string) (string, string) {
+	new_name, new_code := "", ""
+	key := name + "~" + level + "~" + pcode
+	data := NameLevelPcode[key]
+	if data != nil {
+		new_name = qu.ObjToString(data["name"])
+		new_code = qu.ObjToString(data["code"])
+	}
+	return new_name, new_code
 }

+ 88 - 77
fieldproject_medical/data_preparation/src/vcode/vcode.go

@@ -8,11 +8,26 @@ import (
 
 //构建所有类型数据
 func RunVCodeData() {
-	log.Debug("代码表数据准备完毕~~~")
+	//g_code_bidfield()
+	//g_code_bidscope()
+	//g_code_bidtopsubtype()
+	//g_code_area()
+	log.Debug("代码表数据准备完毕~g")
+
+	//y_code_level()
+	//y_code_department()
+	//y_code_type()
+	//y_code_sdleveltypeequip()
+	//y_code_productclass()
+	log.Debug("代码表数据准备完毕~y")
+
+	//b_code_buyerclass()
+	//b_code_buyerfield()
+	log.Debug("代码表数据准备完毕~b")
 }
 
 //标讯信息领域代码表 code_bidfield
-func bx_fieldcode() {
+func g_code_bidfield() {
 	code := []string{"01", "0101"}
 	pcode := []string{"", "01"}
 	level := []string{"1", "2"}
@@ -26,12 +41,12 @@ func bx_fieldcode() {
 			"name":   name[k],
 			"remark": "",
 		}
-		class.InsertMysqlData("code_bidfield", dict, "")
+		class.InsertGlobalMysqlData(class.V_Code_Bidfield, dict, "")
 	}
 }
 
-//标讯信息行业代码表 code_bidindustry
-func bx_hangyecode() {
+//标讯信息行业代码表 code_bidscope
+func g_code_bidscope() {
 	code := []string{"01", "0101", "0102", "0103", "0104", "0105", "02", "0201", "0202", "0203", "0204", "0205", "03", "0301", "0302", "0303", "0304", "0305", "04", "0401", "0402", "0403", "05", "0501", "0502", "0503", "0504", "06", "0601", "0602", "0603", "0604", "07", "0701", "0702", "0703", "08", "0801", "0802", "0803", "0804", "0805", "0806", "0807", "0808", "09", "0901", "0902", "0903", "0904", "0905", "10", "1001", "1002", "1003", "1004", "1005", "1006", "11", "1101", "1102", "1103", "12", "1201", "1202", "1203", "1204"}
 	pcode := []string{"", "01", "01", "01", "01", "01", "", "02", "02", "02", "02", "02", "", "03", "03", "03", "03", "03", "", "04", "04", "04", "", "05", "05", "05", "05", "", "06", "06", "06", "06", "", "07", "07", "07", "", "08", "08", "08", "08", "08", "08", "08", "08", "", "09", "09", "09", "09", "09", "", "10", "10", "10", "10", "10", "10", "", "11", "11", "11", "", "12", "12", "12", "12"}
 	level := []string{"1", "2", "2", "2", "2", "2", "1", "2", "2", "2", "2", "2", "1", "2", "2", "2", "2", "2", "1", "2", "2", "2", "1", "2", "2", "2", "2", "1", "2", "2", "2", "2", "1", "2", "2", "2", "1", "2", "2", "2", "2", "2", "2", "2", "2", "1", "2", "2", "2", "2", "2", "1", "2", "2", "2", "2", "2", "2", "1", "2", "2", "2", "1", "2", "2", "2", "2"}
@@ -45,12 +60,12 @@ func bx_hangyecode() {
 			"name":   name[k],
 			"remark": "",
 		}
-		class.InsertMysqlData("code_bidindustry", dict, "")
+		class.InsertGlobalMysqlData(class.V_Code_Bidscope, dict, "")
 	}
 }
 
 //标讯信息分类代码表 code_bidtopsubtype
-func bx_fenleicode() {
+func g_code_bidtopsubtype() {
 	code := []string{"01", "02", "03", "04", "05", "0101", "0102", "0103", "0104", "0105", "0106", "0201", "0202", "0203", "0204", "0205", "0206", "0207", "0208", "0301", "0302", "0303", "0304", "0305", "0306", "0401", "0402", "0403", "0404", "0501"}
 	pcode := []string{"", "", "", "", "", "01", "01", "01", "01", "01", "01", "02", "02", "02", "02", "02", "02", "02", "02", "03", "03", "03", "03", "03", "03", "04", "04", "04", "04", "05"}
 	level := []string{"1", "1", "1", "1", "1", "2", "2", "2", "2", "2", "2", "2", "2", "2", "2", "2", "2", "2", "2", "2", "2", "2", "2", "2", "2", "2", "2", "2", "2", "2"}
@@ -65,12 +80,28 @@ func bx_fenleicode() {
 			"name":   name[k],
 			"remark": "",
 		}
-		class.InsertMysqlData("code_bidtopsubtype", dict, "")
+		class.InsertGlobalMysqlData(class.V_Code_Bidtopsubtype, dict, "")
+	}
+}
+
+//全国行政区域代码表 code_area
+func g_code_area() {
+
+	sess := class.Save_Mgo.GetMgoConn()
+	defer class.Save_Mgo.DestoryMongoConn(sess)
+	q := map[string]interface{}{}
+	it := sess.DB(class.Save_Mgo.DbName).C(class.S_Region_Coll).Find(&q).Sort("_id").Iter()
+	total := 0
+	for tmp := make(map[string]interface{}); it.Next(&tmp); total++ {
+		delete(tmp, "_id")
+		class.InsertGlobalMysqlData(class.V_Code_Area, tmp, "")
+		tmp = make(map[string]interface{})
 	}
+	log.Debug("is region over ", total)
 }
 
-//医疗机构等级代码表 code_medical_institution_level
-func yl_levelcode() {
+//医疗机构等级代码表 code_level
+func y_code_level() {
 	code := []string{"01", "0101", "0102", "0103", "0104", "02", "0201", "0202", "0203", "0204", "03", "0301", "0302", "0303", "0304", "0305", "04"}
 	pcode := []string{"", "01", "01", "01", "01", "", "02", "02", "02", "02", "", "03", "03", "03", "03", "03", ""}
 	level := []string{"1", "2", "2", "2", "2", "1", "2", "2", "2", "2", "1", "2", "2", "2", "2", "2", "1"}
@@ -84,12 +115,12 @@ func yl_levelcode() {
 			"name":   name[k],
 			"remark": "",
 		}
-		class.InsertMysqlData("code_medical_institution_level", dict, "")
+		class.InsertMedicalMysqlData(class.V_Code_Level, dict, "")
 	}
 }
 
-//医疗机构科室代码表 code_medical_institution_department
-func yl_departcode() {
+//医疗机构科室代码表 code_department
+func y_code_department() {
 	code := []string{"01", "02", "03", "0301", "0302", "0303", "0304", "0305", "0306", "0307", "0308", "0309", "0310", "0300", "04", "0401", "040101", "040102", "040103", "0402", "0403", "0404", "040401", "0405", "040501", "0406", "040601", "0407", "0408", "0400", "05", "0501", "0502", "0503", "0504", "0505", "0500", "06", "0601", "0602", "0603", "0604", "0605", "0600", "07", "0701", "0702", "0703", "0704", "0705", "0706", "0707", "0708", "0709", "0710", "0711", "0700", "08", "0801", "0802", "0803", "0804", "0805", "0800", "09", "0901", "0902", "0903", "0904", "0905", "0900", "10", "11", "1101", "1102", "1103", "1100", "12", "1201", "1202", "1203", "1204", "1205", "1200", "13", "1301", "1302", "1300", "14", "15", "1501", "1502", "1503", "1504", "1505", "1506", "1507", "1500", "16", "1601", "1602", "1603", "1604", "1605", "1606", "1600", "17", "18", "19", "20", "21", "22", "23", "2301", "2302", "2303", "2304", "2305", "2300", "24", "25", "26", "27", "28", "30", "3001", "3002", "3003", "3004", "3005", "3000", "31", "32", "3201", "3202", "3203", "3204", "3205", "3206", "3207", "3208", "3209", "3210", "3200", "50", "5001", "5002", "5003", "5004", "5005", "5006", "5007", "5008", "5009", "5010", "5011", "5012", "5013", "5014", "5015", "5016", "5017", "5000", "51", "5101", "5102", "5103", "5104", "5105", "5100", "52", "00"}
 	pcode := []string{"", "", "", "03", "03", "03", "03", "03", "03", "03", "03", "03", "03", "03", "", "04", "0401", "0401", "0401", "04", "04", "04", "0404", "04", "0405", "04", "0406", "04", "04", "04", "", "05", "05", "05", "05", "05", "05", "", "06", "06", "06", "06", "06", "06", "", "07", "07", "07", "07", "07", "07", "07", "07", "07", "07", "07", "07", "", "08", "08", "08", "08", "08", "08", "", "09", "09", "09", "09", "09", "09", "", "", "11", "11", "11", "11", "", "12", "12", "12", "12", "12", "12", "", "13", "13", "13", "", "", "15", "15", "15", "15", "15", "15", "15", "15", "", "16", "16", "16", "16", "16", "16", "16", "", "", "", "", "", "", "", "23", "23", "23", "23", "23", "23", "", "", "", "", "", "", "30", "30", "30", "30", "30", "30", "", "", "32", "32", "32", "32", "32", "32", "32", "32", "32", "32", "32", "", "50", "50", "50", "50", "50", "50", "50", "50", "50", "50", "50", "50", "50", "50", "50", "50", "50", "50", "", "51", "51", "51", "51", "51", "51", "", ""}
 	level := []string{"1", "1", "1", "2", "2", "2", "2", "2", "2", "2", "2", "2", "2", "2", "1", "2", "3", "3", "3", "2", "2", "2", "3", "2", "3", "2", "3", "2", "2", "2", "1", "2", "2", "2", "2", "2", "2", "1", "2", "2", "2", "2", "2", "2", "1", "2", "2", "2", "2", "2", "2", "2", "2", "2", "2", "2", "2", "1", "2", "2", "2", "2", "2", "2", "1", "2", "2", "2", "2", "2", "2", "1", "1", "2", "2", "2", "2", "1", "2", "2", "2", "2", "2", "2", "1", "2", "2", "2", "1", "1", "2", "2", "2", "2", "2", "2", "2", "2", "1", "2", "2", "2", "2", "2", "2", "2", "1", "1", "1", "1", "1", "1", "1", "2", "2", "2", "2", "2", "2", "1", "1", "1", "1", "1", "1", "2", "2", "2", "2", "2", "2", "1", "1", "2", "2", "2", "2", "2", "2", "2", "2", "2", "2", "2", "1", "2", "2", "2", "2", "2", "2", "2", "2", "2", "2", "2", "2", "2", "2", "2", "2", "2", "2", "1", "2", "2", "2", "2", "2", "2", "1", "1"}
@@ -105,51 +136,12 @@ func yl_departcode() {
 			"name":   name[k],
 			"remark": "",
 		}
-		class.InsertMysqlData("code_medical_institution_department", dict, "")
-	}
-}
-
-//采购单位类型代码表 code_buyerclass
-func buyer_typecode() {
-	code := []string{"01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31", "32", "33", "34", "35", "36", "37", "38", "39", "40", "41", "42", "43", "44", "45", "46", "47", "48", "49", "50", "51", "52", "53", "54", "55", "56", "57", "58", "59", "60", "61", "62", "63", "64", "65", "66", "67", "68", "69", "70"}
-	name := []string{"检察院", "组织", "宣传", "纪委", "统战", "党委办", "发改", "教育", "科技", "工信", "公安", "民政", "司法", "财政", "人社", "国土", "环保", "住建", "交通", "水利", "农业", "商务", "文化", "卫生", "人行", "审计", "国资委", "海关", "税务", "工商", "质监", "出版广电", "体育", "安监", "食药", "统计", "林业", "机关事务", "人大", "政协", "法院", "军队", "传媒", "医疗", "学校", "地震", "气象", "银监", "证监", "保监", "公共资源交易", "城管", "市政", "档案", "旅游", "社会团体", "政务中心", "农林牧渔", "能源化工", "采矿业", "制造业", "建筑业", "运输物流", "电信行业", "信息技术", "住宿餐饮", "批发零售", "金融业", "政府办", "民宗"}
-	log.Debug(len(code), len(name))
-	for k, _ := range code {
-		dict := map[string]interface{}{
-			"code":   code[k],
-			"pcode":  "",
-			"level":  1,
-			"name":   name[k],
-			"remark": "",
-		}
-		class.InsertMysqlData("code_buyerclass", dict, "")
+		class.InsertMedicalMysqlData(class.V_Code_Department, dict, "")
 	}
-
 }
 
-//采购单位领域代码表 code_buyerfield
-func buyer_fieldcode() {
-	code := []string{"01", "0101", "0102", "0103", "0104"}
-	pcode := []string{"", "01", "01", "01", "01"}
-	level := []string{"1", "2", "2", "2", "2"}
-	name := []string{"医疗行业", "医疗机构", "卫生行政部门", "企业", "其它"}
-	remark := []string{"", "", "卫生管理部门", "购买医疗相关产品的企业", ""}
-	log.Debug(len(code), len(name))
-	for k, _ := range code {
-		dict := map[string]interface{}{
-			"code":   code[k],
-			"pcode":  pcode[k],
-			"level":  qu.IntAll(level[k]),
-			"name":   name[k],
-			"remark": remark[k],
-		}
-		class.InsertMysqlData("code_buyerfield", dict, "")
-	}
-
-}
-
-//医疗机构类型代码表 code_medical_institution_type
-func yl_typecode() {
+//医疗机构类型代码表 code_type
+func y_code_type() {
 	code := []string{"01", "02", "0201", "0202", "0203", "0204", "0205", "0206", "0207", "0208", "0209", "0210", "0211", "0212", "03", "04", "05", "0501", "0502", "06", "07", "08", "09", "0901", "0902", "0903", "0904", "0905", "0906", "0907", "10", "1001", "1002", "1003", "1004", "1005", "1006", "1007", "1008", "1009", "1010", "1011", "1012", "11", "12", "1201", "1202", "1203", "13", "1301", "1302", "1303", "14", "15", "16", "17"}
 	pcode := []string{"", "", "02", "02", "02", "02", "02", "02", "02", "02", "02", "02", "02", "02", "", "", "", "05", "05", "", "", "", "", "09", "09", "09", "09", "09", "09", "09", "", "10", "10", "10", "10", "10", "10", "10", "10", "10", "10", "10", "10", "", "", "12", "12", "12", "", "13", "13", "13", "", "", "", ""}
 	level := []string{"1", "1", "2", "2", "2", "2", "2", "2", "2", "2", "2", "2", "2", "2", "1", "1", "1", "2", "2", "1", "1", "1", "1", "2", "2", "2", "2", "2", "2", "2", "1", "2", "2", "2", "2", "2", "2", "2", "2", "2", "2", "2", "2", "1", "1", "2", "2", "2", "1", "2", "2", "2", "1", "1", "1", "1"}
@@ -163,12 +155,12 @@ func yl_typecode() {
 			"name":   name[k],
 			"remark": "",
 		}
-		class.InsertMysqlData("code_medical_institution_type", dict, "")
+		class.InsertMedicalMysqlData(class.V_Code_Type, dict, "")
 	}
 }
 
-//医疗标准设备 code_medical_institution_sdleveltypeequip
-func yl_shebeicode() {
+//医疗标准设备 code_sdleveltypeequip
+func y_code_sdleveltypeequip() {
 	code := []string{"0101", "0201", "0301", "0103", "0203", "0303", "0116", "0216", "0316", "020201", "030201", "020202", "030202", "010203", "020203", "030203", "010204", "020204", "030204", "020205", "030205", "030206", "030207", "030208", "030209", "030210", "040211", "0408", "0105", "0205", "0305", "0407", "040901", "040902", "040903", "040904", "040905", "040906", "041001", "041003", "041004", "041006", "041007", "041008", "041009", "041010", "041011", "0411", "041301", "021301", "031301", "041302", "041303", "041201", "041202", "0415"}
 	equipment := []string{
 		"心电图机,洗胃器,电动吸引器,呼吸球囊,妇科检查床,气管插管,万能手术床,显微镜,离心机,X光机,恒温培养箱,高压灭菌设备,紫外线灯",
@@ -235,12 +227,12 @@ func yl_shebeicode() {
 			"equipment": equipment[k],
 			"remark":    "",
 		}
-		class.InsertMysqlData("code_medical_institution_sdleveltypeequip", dict, "")
+		class.InsertMedicalMysqlData(class.V_Code_Sdleveltypeequip, dict, "")
 	}
 }
 
-//医疗分类代码表 code_medical_equipment_product
-func yl_classcode() {
+//医疗分类代码表 code_productclass
+func y_code_productclass() {
 	code := []string{
 		"01",
 		"0101",
@@ -31894,26 +31886,45 @@ func yl_classcode() {
 			"name":   name[k],
 			"remark": "",
 		}
-		class.InsertMysqlData("code_medical_equipment_product", dict, "")
-		class.Save_Mgo.Save("zktest_mysql_ylqxclass", dict)
+		class.InsertMedicalMysqlData(class.V_Code_Productclass, dict, "")
 	}
 }
 
-//全国行政区域代码表 code_area
-func areacode() {
-	sess := class.Save_Mgo.GetMgoConn()
-	defer class.Save_Mgo.DestoryMongoConn(sess)
-	q := map[string]interface{}{}
-	it := sess.DB(class.Save_Mgo.DbName).C("zktest_mysql_area_new").Find(&q).Sort("_id").Iter()
-	total := 0
-	for tmp := make(map[string]interface{}); it.Next(&tmp); total++ {
-		if total%1000 == 0 {
-			log.Debug("cur index ", total)
+//采购单位类型代码表 code_buyerclass
+func b_code_buyerclass() {
+	code := []string{"01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31", "32", "33", "34", "35", "36", "37", "38", "39", "40", "41", "42", "43", "44", "45", "46", "47", "48", "49", "50", "51", "52", "53", "54", "55", "56", "57", "58", "59", "60", "61", "62", "63", "64", "65", "66", "67", "68", "69", "70"}
+	name := []string{"检察院", "组织", "宣传", "纪委", "统战", "党委办", "发改", "教育", "科技", "工信", "公安", "民政", "司法", "财政", "人社", "国土", "环保", "住建", "交通", "水利", "农业", "商务", "文化", "卫生", "人行", "审计", "国资委", "海关", "税务", "工商", "质监", "出版广电", "体育", "安监", "食药", "统计", "林业", "机关事务", "人大", "政协", "法院", "军队", "传媒", "医疗", "学校", "地震", "气象", "银监", "证监", "保监", "公共资源交易", "城管", "市政", "档案", "旅游", "社会团体", "政务中心", "农林牧渔", "能源化工", "采矿业", "制造业", "建筑业", "运输物流", "电信行业", "信息技术", "住宿餐饮", "批发零售", "金融业", "政府办", "民宗"}
+	log.Debug(len(code), len(name))
+	for k, _ := range code {
+		dict := map[string]interface{}{
+			"code":   code[k],
+			"pcode":  "",
+			"level":  1,
+			"name":   name[k],
+			"remark": "",
 		}
-		delete(tmp, "_id")
-		class.InsertMysqlData("code_area", tmp, "")
+		class.InsertGlobalMysqlData(class.V_Code_Buyerclass, dict, "")
+	}
 
-		tmp = make(map[string]interface{})
+}
+
+//采购单位领域代码表 code_buyerfield
+func b_code_buyerfield() {
+	code := []string{"01", "0101", "0102", "0103", "0104"}
+	pcode := []string{"", "01", "01", "01", "01"}
+	level := []string{"1", "2", "2", "2", "2"}
+	name := []string{"医疗行业", "医疗机构", "卫生行政部门", "企业", "其它"}
+	remark := []string{"", "", "卫生管理部门", "购买医疗相关产品的企业", ""}
+	log.Debug(len(code), len(name))
+	for k, _ := range code {
+		dict := map[string]interface{}{
+			"code":   code[k],
+			"pcode":  pcode[k],
+			"level":  qu.IntAll(level[k]),
+			"name":   name[k],
+			"remark": remark[k],
+		}
+		class.InsertGlobalMysqlData(class.V_Code_Buyerfield, dict, "")
 	}
-	log.Debug("is over ", total)
+
 }

+ 1 - 1
fieldproject_medical/data_service/src/bidding/bidding.go

@@ -62,7 +62,7 @@ func createBaseInfo(tmp map[string]interface{}) {
 	b, industry_code, new_plist := checkWhetherValidInfo(p_list, sub_list)
 	if b {
 		//标的物基本信息~记录标签
-		//insertBaseInfo(new_plist, infoid, bid_topsubtype_code)
+		insertBaseInfo(new_plist, infoid, bid_topsubtype_code)
 		//招标信息领域标签
 		//insertFiledTag(infoid)
 		//招标信息行业标签

+ 4 - 4
fieldproject_medical/data_service/src/bidding/bidsql.go

@@ -14,7 +14,7 @@ func insertBaseInfo(p_list []map[string]interface{}, infoid string, bid_topsubty
 		info["infoid"] = infoid
 		info["bid_topsubtype_code"] = bid_topsubtype_code
 		info["comeintime"] = time.Unix(time.Now().Unix(), 0).Format(ul.TimeLayout)
-		pur_id := ul.InsertMysqlData("bid_purchasinginfo", info, infoid)
+		pur_id := ul.InsertGlobalMysqlData(ul.V_Bid_Purchasinginfo, info, infoid)
 		if pur_id != -1 { //构建有效
 			if medical_equipment_code != "" { //记录标签
 				info_tag := map[string]interface{}{}
@@ -22,7 +22,7 @@ func insertBaseInfo(p_list []map[string]interface{}, infoid string, bid_topsubty
 				info_tag["medical_equipment_code"] = medical_equipment_code
 				info_tag["product_field_code"] = "0101"
 				info_tag["comeintime"] = time.Unix(time.Now().Unix(), 0).Format(ul.TimeLayout)
-				ul.InsertMysqlData("bid_purchasing_field_record", info_tag, infoid)
+				ul.InsertGlobalMysqlData(ul.V_Bid_Purchasing_Field_Record, info_tag, infoid)
 			}
 		}
 
@@ -35,7 +35,7 @@ func insertFiledTag(infoid string) {
 	data["infoid"] = infoid
 	data["labelcode"] = "0101"
 	data["comeintime"] = time.Unix(time.Now().Unix(), 0).Format(ul.TimeLayout)
-	ul.InsertMysqlData("bid_fieldtags", data, infoid)
+	ul.InsertGlobalMysqlData(ul.V_Bid_Fieldtags, data, infoid)
 	//更新bidding~
 
 }
@@ -46,5 +46,5 @@ func insertIndustryTag(industry_code string, infoid string) {
 	data["infoid"] = infoid
 	data["labelcode"] = industry_code
 	data["comeintime"] = time.Unix(time.Now().Unix(), 0).Format(ul.TimeLayout)
-	ul.InsertMysqlData("bid_industrytags", data, infoid)
+	ul.InsertGlobalMysqlData(ul.V_Bid_Scopetags, data, infoid)
 }

+ 1 - 1
fieldproject_medical/data_service/src/bidding/purchasing.go

@@ -189,7 +189,7 @@ func completeMatching(name string) (bool, string) {
 	class_code, pro_code := "", ""
 	//分类目录~完全匹配
 	for i := 4; i > 0; i-- {
-		data := ul.Medical_Class[i]
+		data := ul.Medical_Level_Class[i]
 		if data != nil {
 			if data[name] != "" {
 				med_code = data[name]

+ 2 - 1
fieldproject_medical/data_service/src/main.go

@@ -1,6 +1,7 @@
 package main
 
 import (
+	log "github.com/donnie4w/go-logger/logger"
 	"net/http"
 	"service"
 	"time"
@@ -8,12 +9,12 @@ import (
 )
 
 func init() {
-
 	ul.InitClass()
 	service.InitService()
 }
 
 func main() {
+	log.Debug("run main ... ")
 	//bidding.RunPurchasingInfo(
 	//	"100000000000000000000000",
 	//	"900000000000000000000000")

+ 42 - 14
fieldproject_medical/data_service/src/util/initcfg.go

@@ -4,18 +4,30 @@ import (
 	log "github.com/donnie4w/go-logger/logger"
 )
 
-var (
-	Mgo          *MongodbSim
-	TimeLayout   = "2006-01-02 15:04:05"
-	TimeTmeplate = "2006-01-02"
-	MysqlTool    *Mysql
+const (
+	V_Bid_Purchasinginfo          = "bid_purchasinginfo"
+	V_Bid_Purchasing_Field_Record = "bid_purchasing_field_record"
+	V_Bid_Fieldtags               = "bid_fieldtags"
+	V_Bid_Scopetags               = "bid_scopetags"
+
+	V_Code_Bidfield      = "code_bidfield" //采用默认code
+	V_Code_Bidscope      = "code_bidscope"
+	V_Code_Bidtopsubtype = "code_bidtopsubtype"
+	V_Code_Productclass  = "code_productclass"
+	V_Product_Baseinfo   = "product_baseinfo"
+)
 
+var (
+	Mgo                               *MongodbSim
+	TimeLayout                        = "2006-01-02 15:04:05"
+	TimeTmeplate                      = "2006-01-02"
+	MysqlMedicalTool, MysqlGlobalTool *Mysql
 	//标讯相关
 	Bid_TopSubtype = map[string]map[string]string{}
 	Bid_Industry   = map[string]map[string]string{}
 
 	//不同等级~不同名称~对应代码
-	Medical_Class = map[int]map[string]string{}
+	Medical_Level_Class = map[int]map[string]string{}
 	//标准产品名~对应编号
 	ProductDocText = map[string]string{}
 
@@ -62,28 +74,44 @@ func initMgo() {
 }
 
 func initMysql() {
-	MysqlTool = &Mysql{
+	MysqlMedicalTool = &Mysql{
+		Address:  "192.168.3.217:4000",
+		UserName: "root",
+		PassWord: "=PDT49#80Z!RVv52_z",
+		DBName:   "field_medical_data",
+	}
+	MysqlMedicalTool.Init()
+
+	MysqlGlobalTool = &Mysql{
 		Address:  "192.168.3.217:4000",
 		UserName: "root",
 		PassWord: "=PDT49#80Z!RVv52_z",
 		DBName:   "field_medical_data",
 	}
-	MysqlTool.Init()
+	MysqlGlobalTool.Init()
+
 }
 
 //加载代码表~
 func initVCode() {
-	//initBidInfoClass()     //招标信息分类
-	//initBidIndustryClass() //行业分类
+	initBidInfoClass()     //招标信息分类
+	initBidIndustryClass() //行业分类
 
 	GSE.LoadDict("./dictionary.txt")
-	initMedicalClass()   //标准分类表
-	initMedicalProduct() //分类产品
+	initMedicalLevelClass() //标准分类表
+	initMedicalProduct()    //分类产品
 }
 
 //插入数据
-func InsertMysqlData(name string, data map[string]interface{}, mark string) int64 {
-	inb := MysqlTool.Insert(name, data)
+func InsertMedicalMysqlData(name string, data map[string]interface{}, mark string) int64 {
+	inb := MysqlMedicalTool.Insert(name, data)
+	if inb == -1 {
+		log.Debug("插入数据异常...", name, "~", mark)
+	}
+	return inb
+}
+func InsertGlobalMysqlData(name string, data map[string]interface{}, mark string) int64 {
+	inb := MysqlGlobalTool.Insert(name, data)
 	if inb == -1 {
 		log.Debug("插入数据异常...", name, "~", mark)
 	}

+ 2 - 2
fieldproject_medical/data_service/src/util/initmed.go

@@ -15,9 +15,9 @@ var (
 	NgrmText = map[string][]int{}
 )
 
-//加载产品分类~
+//加载产品信息数据~
 func initMedicalProduct() {
-	datas_product := MysqlTool.Find("medical_equipment_productinfo", map[string]interface{}{
+	datas_product := MysqlMedicalTool.Find(V_Product_Baseinfo, map[string]interface{}{
 		"medical_equipment_code": map[string]interface{}{
 			"ne": "",
 		},

+ 10 - 9
fieldproject_medical/data_service/src/util/initvcode.go

@@ -5,9 +5,9 @@ import (
 	qu "qfw/util"
 )
 
-//加载招标信息分类
+//加载招标信息~分类
 func initBidInfoClass() {
-	data_types := MysqlTool.Find("code_bidtopsubtype", nil, "", "", -1, -1)
+	data_types := MysqlMedicalTool.Find(V_Code_Bidtopsubtype, nil, "", "", -1, -1)
 	//先构建所有一级数据
 	for _, v := range *data_types {
 		name := qu.ObjToString(v["name"])
@@ -38,7 +38,7 @@ func initBidInfoClass() {
 
 //加载招标行业分类
 func initBidIndustryClass() {
-	data_types := MysqlTool.Find("code_bidindustry", nil, "", "", -1, -1)
+	data_types := MysqlGlobalTool.Find(V_Code_Bidscope, nil, "", "", -1, -1)
 	//先构建所有一级数据
 	for _, v := range *data_types {
 		name := qu.ObjToString(v["name"])
@@ -67,21 +67,22 @@ func initBidIndustryClass() {
 	log.Debug("招标行业分类表~", len(Bid_Industry))
 }
 
-func initMedicalClass() {
-	data_class := MysqlTool.Find("code_medical_equipment_product", nil, "", "", -1, -1)
+//加载医械目录分类
+func initMedicalLevelClass() {
+	data_class := MysqlMedicalTool.Find(V_Code_Productclass, nil, "", "", -1, -1)
 	for _, v := range *data_class {
 		level := qu.IntAll(v["level"])
 		name := qu.ObjToString(v["name"])
 		code := qu.ObjToString(v["code"])
 		data := map[string]string{}
-		if Medical_Class[level] != nil {
-			data = Medical_Class[level]
+		if Medical_Level_Class[level] != nil {
+			data = Medical_Level_Class[level]
 		}
 		if data[name] == "" {
 			data[name] = code
 		}
-		Medical_Class[level] = data
+		Medical_Level_Class[level] = data
 	}
-	log.Debug("医疗分类~加载~完毕~", len(Medical_Class))
+	log.Debug("医疗分类~加载~完毕~", len(Medical_Level_Class))
 	loadNgrmCatalogData(*data_class)
 }