package main

import (
	"bufio"
	"bytes"
	"encoding/json"
	"fmt"
	log "github.com/donnie4w/go-logger/logger"
	"github.com/go-ego/gse"
	"github.com/tealeg/xlsx"
	"go.mongodb.org/mongo-driver/bson"
	"go.mongodb.org/mongo-driver/bson/primitive"
	"io"
	"io/ioutil"
	"math"
	"net/http"
	"os"
	es_elastic "qfw/common/src/gopkg.in/olivere/elastic.v1"
	qu "qfw/util"
	"qfw/util/elastic"
	"qfw/util/redis"
	"reflect"
	"regexp"
	"strings"
	"sync"
	"time"
	"unicode"
	"unicode/utf8"
)

//分词
var (
	GSE                                      *gse.Segmenter = &gse.Segmenter{}
	gseReg                                   *regexp.Regexp = regexp.MustCompile("[(（）)/、]+")
	task                                     chan struct{}  = make(chan struct{}, 1)
	rpre                                     *regexp.Regexp = regexp.MustCompile("https://www.jianyu360.com/article/content/")
	rsuf                                     *regexp.Regexp = regexp.MustCompile("(.html).*")
	province, all_province, city, brief_city string
	Url                                      = "https://www.jianyu360.com/article/content/%s.html"
	wordsArr                                 = []string{}
	MysqlTool                                *Mysql
	timeLayout                               = "2006-01-02 15:04:05"
	numLock                                  sync.Mutex
)

//导出数据-bidding相关
func exportFromArrToBiddingData(coll_name string) {
	arr := []string{}
	isok := 0
	for _, v := range arr {
		data := save_mgo.FindById("bidding", v)
		if data != nil && len(data) > 2 {
			save_mgo.Save(coll_name, data)
			isok++
		} else {
			data = save_mgo.FindById("bidding_back", v)
			if data != nil && len(data) > 2 {
				save_mgo.Save(coll_name, data)
				isok++
			} else {
				log.Debug(v)
			}
		}
	}
	log.Debug("is over ~", len(arr), "~", isok)
}

//导出数据-抽取表相关
func exportFromArrToExtractData(coll_name string) {
	arr := []string{}
	for _, v := range arr {
		data := save_mgo.FindById("result_20220219", v)
		if data != nil && len(data) > 2 {
			save_mgo.Save(coll_name, data)
		}
	}
}

//导出数据-bidding相关
func exportFromMongoToBiddingData(from string, to string, uuid string) {
	sess := save_mgo.GetMgoConn()
	defer save_mgo.DestoryMongoConn(sess)
	q, total := map[string]interface{}{}, 0
	isok := 0
	it := sess.DB(save_mgo.DbName).C(from).Find(&q).Iter()
	for tmp := make(map[string]interface{}); it.Next(&tmp); total++ {
		if total%1000 == 0 {
			log.Debug("curent index ", total, "~", isok)
		}
		tmpid := BsonTOStringId(tmp["_id"])
		if uuid != "" {
			tmpid = qu.ObjToString(tmp[uuid])
		}
		data := save_mgo.FindById("bidding", tmpid)
		if data != nil && len(data) > 2 {
			save_mgo.Save(to, data)
			isok++
		} else {
			data = save_mgo.FindById("bidding_back", tmpid)
			if data != nil && len(data) > 2 {
				save_mgo.Save(to, data)
				isok++
			} else {
				log.Debug("未查询到~", tmpid)
			}
		}
		tmp = make(map[string]interface{})
	}
	log.Debug("is over ", total, "~", isok)
}

//导出数据-extract相关
func exportFromMongoToExtractData(from string, to string) {
	sess := save_mgo.GetMgoConn()
	defer save_mgo.DestoryMongoConn(sess)
	q, total := map[string]interface{}{}, 0
	it := sess.DB(save_mgo.DbName).C(from).Find(&q).Iter()
	for tmp := make(map[string]interface{}); it.Next(&tmp); total++ {
		if total%1000 == 0 {
			log.Debug("curent index ", total)
		}
		tmpid := BsonTOStringId(tmp["_id"])
		data := save_mgo.FindById("result_20220219", tmpid)
		if data != nil && len(data) > 2 {
			save_mgo.Save(to, data)
		} else {
			data = save_mgo.FindById("result_20220218", tmpid)
			if data != nil && len(data) > 2 {
				save_mgo.Save(to, data)
			}
		}
		tmp = make(map[string]interface{})
	}
	log.Debug("is over ", total)
}

//秘钥~base64
func encodeSEUrl(str string) {
	var SE = qu.SimpleEncrypt{Key: "topJYBX2019"}
	log.Debug(SE.EncodeString(str))
}

//解密~base64
func decodeSEUrl(str string) {
	var SE = qu.SimpleEncrypt{Key: "topJYBX2019"}
	log.Debug(SE.DecodeString(str))
}

//解密
func decodeJyUrl(str string) {
	test := str + "%3D"
	var Decode = qu.CommonDecodeArticle("content", test)
	log.Debug(Decode[0])
	return
}

//加密
func encodeJyUrl() {
	var Url = "https://www.jianyu360.com/article/content/%s.html"
	var Encode = fmt.Sprintf(Url, qu.CommonEncodeArticle("content", "595a08e261a0721f158d0f90"))
	log.Debug(Encode)
}

//解密数据id
func decodeFeedBackInfo() {
	arr := []string{}
	for _, v := range arr {
		decodeSEUrl(v)
	}
}

func exportErrInfo0515() {
	elastic.InitElasticSize("http://127.0.0.1:13002", 10)
	total := int64(0)
	esclient := elastic.GetEsConn()
	defer elastic.DestoryEsConn(esclient)
	if esclient == nil {
		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()
	if err != nil || cursor.Results == nil || cursor.Results.Hits == nil {
		log.Debug("异常~", err)
	}
	total += cursor.TotalHits()
	log.Debug("当前查询正常数：", cursor.TotalHits(), "总数：", total)
	numDocs, isok := 0, 0
	pool_es := make(chan bool, 10)
	wg_es := &sync.WaitGroup{}
	for {
		searchResult, err := cursor.Next()
		if err != nil {
			if err.Error() == "EOS" {
				break
			} else {
				log.Debug("cursor searchResult", err)
			}
		}
		for _, hit := range searchResult.Hits.Hits {
			tmp := make(map[string]interface{})
			err := json.Unmarshal(*hit.Source, &tmp)
			if err != nil {
				log.Debug("json Unmarshal error")
				continue
			}
			if numDocs%1000 == 0 {
				log.Debug("当前条数：", numDocs, " 符合条数：", isok)
			}
			numDocs++
			pool_es <- true
			wg_es.Add(1)
			go func(tmp map[string]interface{}) {
				defer func() {
					<-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,
				})

			}(tmp)
		}
	}
	wg_es.Wait()
	log.Debug("遍历完毕...", total, numDocs, isok)
}

//清洗医疗名称
func testCleanMedicalName() {
	dataArr, _ := save_mgo.Find("111111", nil, bson.M{"_id": 1}, nil)
	isok := 0
	var reg1 *regexp.Regexp = regexp.MustCompile("[(（].*[)）]")
	var reg2 *regexp.Regexp = regexp.MustCompile("^([\u4E00-\u9FA5]+)([A-Za-z]+)$")

	for _, v := range dataArr {
		tmpid := BsonTOStringId(v["_id"])
		new_name := qu.ObjToString(v["name"])
		new_name = strings.ReplaceAll(new_name, " ", "")
		if reg1.MatchString(new_name) {
			new_name = reg1.ReplaceAllString(new_name, "")
		}
		if reg2.MatchString(new_name) {
			new_name = reg2.ReplaceAllString(new_name, "${1}")
		}
		if utf8.RuneCountInString(new_name) > 10 {
			new_name = ""
		}
		save_mgo.UpdateById("111111", tmpid, map[string]interface{}{
			"$set": map[string]interface{}{
				"new_name": new_name,
			},
		})
		isok++
	}
	log.Debug("is over ", isok)
}

func cleanName(s string) string {
	news := ""
	isTrue := false
	for _, c := range s {
		if unicode.Is(unicode.Han, c) || unicode.IsLetter(c) {
			isTrue = true
		}
		if isTrue {
			news += string(c)
		}
	}
	return news
}

//迭代性能测试
func testMongoLevel1() {
	tmpid, total := "403655e927198cc9c10fcc49", 0
	for {
		q := bson.M{"_id": bson.M{"$gt": StringTOBsonId(tmpid)}}
		dataArr, _ := save_mgo.FindLimit("bidding", q, bson.M{"_id": 1}, nil, 5000)
		total += len(dataArr)
		if total > 3000000 {
			break
		}
		if len(dataArr) == 0 {
			break
		}
		tmpid = BsonTOStringId(dataArr[len(dataArr)-1]["_id"])
	}
	log.Debug("is page over ", total)
}
func testMongoLevel2() {
	sess := save_mgo.GetMgoConn()
	defer save_mgo.DestoryMongoConn(sess)
	q, total := bson.M{"_id": bson.M{"$gt": StringTOBsonId("403655e927198cc9c10fcc49")}}, 0
	it := sess.DB(save_mgo.DbName).C("bidding").Find(&q).Sort("_id").Iter()
	for tmp := make(map[string]interface{}); it.Next(&tmp); total++ {
		if total > 3000000 {
			break
		}
		tmp = make(map[string]interface{})
	}
	log.Debug("is iter over ", total)
}

//接口调用大模型数据
func callChatGlmApi(from string) {
	prompt := ""
	if from == "buyer" {
		prompt = "你是一名数据标注员，请抽取文中的采购单位"
	} else if from == "area" {
		prompt = "你是一名数据识别员，请识别文中的项目地区"
	} else if from == "winner" {
		prompt = "你是一名数据标注员，请抽取文中的中标单位"
	} else if from == "bidamount" {
		prompt = "你是一名数据识别员，请抽取文中的中标金额"
	} else {
		log.Debug("参数参数有误~~~")
		return
	}

	dataArr, _ := save_mgo.Find("zktest_chatglm_"+from, nil, nil, map[string]interface{}{"detail": 1, "href": 1})
	for k, v := range dataArr {
		if k%10 == 0 {
			log.Debug("cur index ", k)
		}
		detail := qu.ObjToString(v["detail"])
		new_prompt := detail + "\n" + prompt
		body := map[string]interface{}{"identity": "剑鱼chat", "prompt": new_prompt}
		data := postChatGlm("http://192.168.3.109:12001",
			body, "application/json")
		response := ""
		if qu.IntAll(data["status"]) == 200 {
			response = qu.ObjToString(data["response"])
		} else {
			response = "请求异常"
		}
		tmpid := qu.ObjToString(v["_id"])
		save_mgo.Save("111111_"+from, map[string]interface{}{
			"_id":      tmpid,
			"jyhref":   fmt.Sprintf(Url, qu.CommonEncodeArticle("content", tmpid)),
			"href":     qu.ObjToString(v["href"]),
			"detail":   detail,
			"response": response,
		})
	}
	log.Debug("is over ~~~")
}

func postChatGlm(url string, data interface{}, contentType string) map[string]interface{} {
	task <- struct{}{}
	defer func() {
		<-task
	}()
	client := &http.Client{Timeout: 10 * time.Second}
	jsonStr, _ := json.Marshal(data)
	resp, err := client.Post(url, contentType, bytes.NewBuffer(jsonStr))
	if err != nil {
		log.Debug("请求错误~", err)
		return map[string]interface{}{}
	}
	result, _ := ioutil.ReadAll(resp.Body)
	dict := make(map[string]interface{})
	json.Unmarshal(result, &dict)
	//fmt.Println("post...start")
	return dict
}

//导出无中标单位的数据
func export0427wininfo() {
	elastic.InitElasticSize("http://127.0.0.1:13002", 10)
	total := int64(0)
	esclient := elastic.GetEsConn()
	defer elastic.DestoryEsConn(esclient)
	if esclient == nil {
		log.Debug("连接池异常")
	}
	//26号当天数据
	query1 := es_elastic.NewRangeQuery("publishtime").Gte(1682438400).Lt(1682524800)
	query2 := es_elastic.NewMissingFilter("winner")
	query3 := es_elastic.NewMissingFilter("bidamount")

	cursor, err := esclient.Scan("bidding").Query(es_elastic.NewBoolQuery().Must(query1, query2, query3)).Size(200).Do()
	if err != nil || cursor.Results == nil || cursor.Results.Hits == nil {
		log.Debug("异常~", err)
	}
	total += cursor.TotalHits()
	log.Debug("当前查询正常数：", cursor.TotalHits(), "总数：", total)
	numDocs, isok := 0, 0
	//多线程 - 处理数据
	temp := map[string]int{}
	pool_es := make(chan bool, 1)
	wg_es := &sync.WaitGroup{}
	for {
		searchResult, err := cursor.Next()
		if err != nil {
			if err.Error() == "EOS" {
				break
			} else {
				log.Debug("cursor searchResult", err)
			}
		}
		for _, hit := range searchResult.Hits.Hits {
			tmp := make(map[string]interface{})
			err := json.Unmarshal(*hit.Source, &tmp)
			if err != nil {
				log.Debug("json Unmarshal error")
				continue
			}
			if numDocs%1000 == 0 {
				log.Debug("当前条数：", numDocs, " 符合条数：", isok)
			}
			numDocs++
			if isok >= 100 {
				break
			}
			pool_es <- true
			wg_es.Add(1)
			go func(tmp map[string]interface{}) {
				defer func() {
					<-pool_es
					wg_es.Done()
				}()
				site := qu.ObjToString(tmp["site"])
				subtype := qu.ObjToString(tmp["subtype"])
				if subtype == "中标" || subtype == "成交" || subtype == "合同" {
					num := qu.IntAll(temp[site])
					if num < 2 {
						isok++
						temp[site] = num + 1
						save_mgo.Save("zktest_chatglm_wininfo", tmp)
					}
				}
			}(tmp)
		}
	}
	wg_es.Wait()
	log.Debug("遍历完毕...", total, numDocs, isok)
}

//导出-大模型验证的-疑似问题-buyer与地域
func export0425buyer() {
	elastic.InitElasticSize("http://127.0.0.1:13002", 10)
	total := int64(0)
	esclient := elastic.GetEsConn()
	defer elastic.DestoryEsConn(esclient)
	if esclient == nil {
		log.Debug("连接池异常")
	}
	query1 := es_elastic.NewRangeQuery("publishtime").Gte(1682265600).Lt(1682352000)
	query2 := es_elastic.NewTermQuery("toptype", "招标")
	query4 := es_elastic.NewMissingFilter("buyer")
	cursor, err := esclient.Scan("bidding").Query(es_elastic.NewBoolQuery().Must(query1, query2, query4)).Size(200).Do()
	if err != nil || cursor.Results == nil || cursor.Results.Hits == nil {
		log.Debug("异常~", err)
	}
	total += cursor.TotalHits()
	log.Debug("当前查询正常数：", cursor.TotalHits(), "总数：", total)
	numDocs, isok := 0, 0
	//多线程 - 处理数据
	temp := map[string]int{}
	pool_es := make(chan bool, 1)
	wg_es := &sync.WaitGroup{}
	for {
		searchResult, err := cursor.Next()
		if err != nil {
			if err.Error() == "EOS" {
				break
			} else {
				log.Debug("cursor searchResult", err)
			}
		}
		for _, hit := range searchResult.Hits.Hits {
			tmp := make(map[string]interface{})
			err := json.Unmarshal(*hit.Source, &tmp)
			if err != nil {
				log.Debug("json Unmarshal error")
				continue
			}
			if numDocs%1000 == 0 {
				log.Debug("当前条数：", numDocs, " 符合条数：", isok)
			}
			numDocs++
			if isok >= 100 {
				break
			}
			pool_es <- true
			wg_es.Add(1)
			go func(tmp map[string]interface{}) {
				defer func() {
					<-pool_es
					wg_es.Done()
				}()
				site := qu.ObjToString(tmp["site"])
				num := qu.IntAll(temp[site])
				if num < 2 {
					isok++
					temp[site] = num + 1
					save_mgo.Save("zktest_chatglm_buyer", tmp)
				}
			}(tmp)
		}
	}
	wg_es.Wait()
	log.Debug("遍历完毕...", total, numDocs, isok)
}
func export0425region() {
	elastic.InitElasticSize("http://127.0.0.1:13002", 10)
	total := int64(0)
	esclient := elastic.GetEsConn()
	defer elastic.DestoryEsConn(esclient)
	if esclient == nil {
		log.Debug("连接池异常")
	}
	query1 := es_elastic.NewRangeQuery("publishtime").Gte(1682265600).Lt(1682352000)
	query4 := es_elastic.NewTermQuery("area", "全国")
	cursor, err := esclient.Scan("bidding").Query(es_elastic.NewBoolQuery().Must(query1, query4)).Size(200).Do()
	if err != nil || cursor.Results == nil || cursor.Results.Hits == nil {
		log.Debug("异常~", err)
	}
	total += cursor.TotalHits()
	log.Debug("当前查询正常数：", cursor.TotalHits(), "总数：", total)
	numDocs, isok := 0, 0
	//多线程 - 处理数据
	temp := map[string]int{}
	pool_es := make(chan bool, 1)
	wg_es := &sync.WaitGroup{}
	for {
		searchResult, err := cursor.Next()
		if err != nil {
			if err.Error() == "EOS" {
				break
			} else {
				log.Debug("cursor searchResult", err)
			}
		}
		for _, hit := range searchResult.Hits.Hits {
			tmp := make(map[string]interface{})
			err := json.Unmarshal(*hit.Source, &tmp)
			if err != nil {
				log.Debug("json Unmarshal error")
				continue
			}
			if numDocs%1000 == 0 {
				log.Debug("当前条数：", numDocs, " 符合条数：", isok)
			}
			numDocs++
			if isok >= 100 {
				break
			}
			pool_es <- true
			wg_es.Add(1)
			go func(tmp map[string]interface{}) {
				defer func() {
					<-pool_es
					wg_es.Done()
				}()
				site := qu.ObjToString(tmp["site"])
				num := qu.IntAll(temp[site])
				if num < 2 {
					isok++
					temp[site] = num + 1
					save_mgo.Save("zktest_chatglm_region", tmp)
				}
			}(tmp)
		}
	}
	wg_es.Wait()
	log.Debug("遍历完毕...", total, numDocs, isok)
}
func tongji0424() {
	var SE = qu.SimpleEncrypt{Key: "topJYBX2019"}
	temp := map[string]string{}
	fileNameArr := []string{"1.xlsx", "2.xlsx", "3.xlsx"}
	for _, filename := range fileNameArr {
		isok := 0
		ff, _ := xlsx.OpenFile("res/" + filename)
		for _, sheet := range ff.Sheets {
			for row_index, row := range sheet.Rows {
				var str []string
				for _, cell := range row.Cells {
					s := cell.String()
					s = strings.ReplaceAll(s, "　", "")
					s = strings.ReplaceAll(s, " ", "")
					str = append(str, s)
				}
				if row_index > 0 {
					area := qu.ObjToString(str[0])
					city := qu.ObjToString(str[1])
					subtype := qu.ObjToString(str[2])
					budget := qu.Float64All(str[3])
					bidamount := qu.Float64All(str[4])
					buyer := qu.ObjToString(str[5])
					s_winner := qu.ObjToString(str[6])
					encry_id := qu.ObjToString(str[7])
					tmpid := SE.DecodeString(encry_id)
					if temp[encry_id] == "" {
						temp[encry_id] = encry_id
						isok++
						data := map[string]interface{}{
							"_id":       StringTOBsonId(tmpid),
							"area":      area,
							"city":      city,
							"subtype":   subtype,
							"budget":    budget,
							"bidamount": bidamount,
							"buyer":     buyer,
							"s_winner":  s_winner,
							"encry_id":  encry_id,
						}
						if data != nil {
							save_mgo.Save("111111", data)
						}
					}
				}
			}
		}
		log.Debug("is over ", isok)
	}

}
func export0424() {
	q := map[string]interface{}{}
	dataArr, _ := save_mgo.Find("zktest_accuracy_new", q, nil, map[string]interface{}{
		"_id": 1,
	})
	for _, v := range dataArr {
		tmpid := BsonTOStringId(v["_id"])
		info := save_mgo.FindById("bidding", tmpid)
		if info != nil && len(info) > 0 {
			data := map[string]interface{}{
				"_id":       info["_id"],
				"area":      qu.ObjToString(info["area"]),
				"city":      qu.ObjToString(info["city"]),
				"subtype":   qu.ObjToString(info["subtype"]),
				"budget":    qu.Float64All(info["budget"]),
				"bidamount": qu.Float64All(info["bidamount"]),
				"buyer":     qu.ObjToString(info["buyer"]),
				"s_winner":  qu.ObjToString(info["s_winner"]),
			}
			save_mgo.Save("zktest_accuracy_info", data)
		}
	}
}
func accuracy0424() {
	q := map[string]interface{}{}
	dataArr1, _ := save_mgo.Find("zktest_accuracy_info", q, nil, nil)
	dataArr2, _ := save_mgo.Find("zktest_accuracy_new", q, nil, nil)
	temp1 := map[string]map[string]interface{}{}
	temp2 := map[string]map[string]interface{}{}
	for _, v := range dataArr1 {
		tmpid := BsonTOStringId(v["_id"])
		temp1[tmpid] = v
	}
	for _, v := range dataArr2 {
		tmpid := BsonTOStringId(v["_id"])
		temp2[tmpid] = v
	}
	log.Debug(len(temp1), "~", len(temp2))
	fieldArr := []string{"buyer", "s_winner", "budget", "bidamount", "area", "city"}
	t1, t2, t3, t4, t5, t6 := 0, 0, 0, 0, 0, 0
	c1, c2, c3, c4, c5, c6 := 0, 0, 0, 0, 0, 0
	for tmpid, info2 := range temp2 {
		info1 := temp1[tmpid]
		for _, key := range fieldArr {
			if key == "buyer" {
				t1++
				if qu.ObjToString(info1[key]) == qu.ObjToString(info2[key]) {
					c1++
				}
			} else if key == "s_winner" {
				t2++
				if qu.ObjToString(info1[key]) == qu.ObjToString(info2[key]) {
					c2++
				}
			} else if key == "budget" {
				t3++
				if qu.Float64All(info1[key]) == qu.Float64All(info2[key]) {
					c3++
				}
			} else if key == "bidamount" {
				t4++
				if qu.Float64All(info1[key]) == qu.Float64All(info2[key]) {
					c4++
				}
			} else if key == "area" {
				t5++
				if qu.ObjToString(info1[key]) == qu.ObjToString(info2[key]) {
					c5++
				}
			} else if key == "city" {
				t6++
				if qu.ObjToString(info1[key]) == qu.ObjToString(info2[key]) {
					c6++
				}
			} else {

			}
		}
	}
	log.Debug("数据数", t1, t2, t3, t4, t5, t6)
	log.Debug("正确数", c1, c2, c3, c4, c5, c6)
	log.Debug("正确率", accuracyRate(t1, c1), "~", accuracyRate(t2, c2), "~", accuracyRate(t3, c3), "~", accuracyRate(t4, c4), "~", accuracyRate(t5, c5), "~", accuracyRate(t6, c6))

}

//统计筛选数据
func statisticalScreeningDataInfo() {
	collArr := []string{
		"20230207Ldx_jsfk_qx",
		"20230207Ldx_sxsgl_qx",
		"20230207Ldx_xljk_qx",
		"20230209Ldx_xyaq",
		"20230213Ldx_zhxy_2_1",
		"20230213Ldx_zhxy_2_2",
		"20230223Ldx_zhjs",
		"20230317Ldx_zhty",
	}
	t1, t2, t3, t4, t5, t6 := 0, 0, 0, 0, 0, 0
	c1, c2, c3, c4, c5, c6 := 0, 0, 0, 0, 0, 0
	for _, coll := range collArr {
		q := map[string]interface{}{}
		dataArr, _ := save_mgo.Find(coll, q, nil, map[string]interface{}{
			"v_baseinfo.toptype": 1,
			"v_taginfo":          1,
		})
		//t1, t2, t3, t4, t5, t6 := 0, 0, 0, 0, 0, 0
		//c1, c2, c3, c4, c5, c6 := 0, 0, 0, 0, 0, 0
		for _, v := range dataArr {
			v_baseinfo := *qu.ObjToMap(v["v_baseinfo"])
			v_taginfo := *qu.ObjToMap(v["v_taginfo"])
			toptype := qu.ObjToString(v_baseinfo["toptype"])
			for k1, v1 := range v_taginfo {
				b := false
				if qu.IntAll(v1) == 1 {
					b = true
				}
				switch k1 {
				case "buyer":
					{
						t1++
						if b {
							c1++
						}
					}
				case "s_winner":
					{
						if toptype == "结果" {
							t2++
							if b {
								c2++
							}
						}
					}
				case "budget":
					{
						t3++
						if b {
							c3++
						}
					}
				case "bidamount":
					{
						if toptype == "结果" {
							t4++
							if b {
								c4++
							}
						}
					}
				case "area":
					{
						t5++
						if b {
							c5++
						}
					}
				case "city":
					{
						t6++
						if b {
							c6++
						}
					}
				default:

				}
			}
		}
		log.Debug("当前表~", coll, "~完毕~")
	}

	log.Debug("is over ~~~~~")
	log.Debug("数据数", t1, t2, t3, t4, t5, t6)
	log.Debug("正确数", c1, c2, c3, c4, c5, c6)
	log.Debug("正确率", accuracyRate(t1, c1), "~", accuracyRate(t2, c2), "~", accuracyRate(t3, c3), "~", accuracyRate(t4, c4), "~", accuracyRate(t5, c5), "~", accuracyRate(t6, c6))
}

func accuracyRate(n2 int, n1 int) string {
	str := fmt.Sprintf("%.2f", float64(n1)/float64(n2))
	return str
}

//筛选异常数据
func filterTheAbnormalInfo() {
	sess := save_mgo.GetMgoConn()
	defer save_mgo.DestoryMongoConn(sess)
	q, total := map[string]interface{}{}, 0
	isok := 0
	it := sess.DB(save_mgo.DbName).C("zzzzzzkkk_rg_info_new").Find(&q).Sort("_id").Iter()
	for tmp := make(map[string]interface{}); it.Next(&tmp); total++ {
		if total%10000 == 0 {
			log.Debug("curent index ", total, "~", isok)
		}
		subtype := qu.ObjToString(tmp["subtype"])
		s_winner := qu.ObjToString(tmp["s_winner"])
		bidamount := qu.Float64All(tmp["bidamount"])
		if subtype == "中标" || subtype == "成交" || subtype == "合同" {
			if s_winner == "" && bidamount == float64(0) {
				isok++
				if tmp["package"] != nil {
					log.Debug(tmp["_id"])
				}
			}
		}
		tmp = make(map[string]interface{})
	}
	log.Debug("is over ", total, "~", isok)
}

//解析数据
func exportErrInfo0328() {
	dataArr, _ := save_mgo.Find("zzzzzzkkk_rg_info_err", nil, nil, nil)
	for _, v := range dataArr {
		tmpid := BsonTOStringId(v["_id"])
		info := save_mgo.FindById("zzzzzzkkk_rg_source", tmpid)
		save_mgo.Save("zzzzzzkkk_rg_info", info)
	}
}

//修复数据
func repair0317() {
	//20230314Zdx_xx_new
	dataArr, _ := save_mgo.Find("20230314Zdx_xx_new", nil, nil, nil)
	isok := 0
	for _, v := range dataArr {
		id := BsonTOStringId(v["_id"])
		info := save_mgo.FindOne("20230314Zdx_xx", map[string]interface{}{
			"id": id,
		})
		if len(info) > 0 && info != nil {
			isok++
			tmpid := BsonTOStringId(info["_id"])
			update := v
			delete(update, "_id")
			save_mgo.UpdateById("20230314Zdx_xx", tmpid, map[string]interface{}{
				"$set": update,
			})
		}
	}
	log.Debug("is over ", isok)
}

//导出标注分析错误数据
func exportErrBiaoZhuDataFenXi() {

	dataArr, _ := save_mgo.Find("zzzzzzkkk_bz_info_new", nil, nil, map[string]interface{}{
		"s_winner":    1,
		"bidamount":   1,
		"href":        1,
		"jytest_href": 1,
	})

	for _, v := range dataArr {
		info := v
		tmpid := BsonTOStringId(v["_id"])
		data := save_mgo.FindById("zzzzzzkkk_bz", tmpid)
		if v_baseinfo, ok := data["v_baseinfo"].(map[string]interface{}); ok {
			for kk, vv := range v_baseinfo {
				new_key := "right_" + kk
				info[new_key] = vv
			}
		}
		save_mgo.Save("zzzzzzkkk_bz_info_err", info)
	}

	log.Debug("is over ~~~")
}

//导出人工分析错误数据
func exportErrRenGongDataFenXi() {
	dataArr, _ := save_mgo.Find("zzzzzzkkk_rg_info_new", nil, nil, map[string]interface{}{
		"s_winner":    1,
		"bidamount":   1,
		"href":        1,
		"jytest_href": 1,
	})
	temp := map[string]map[string]interface{}{}
	sourceArr, _ := save_mgo.Find("zzzzzzkkk_rg_info", nil, nil, map[string]interface{}{
		"s_winner":  1,
		"bidamount": 1,
	})
	for _, v := range sourceArr {
		key := BsonTOStringId(v["_id"])
		temp[key] = v
	}
	log.Debug("数据准备~", len(dataArr), "~", len(sourceArr))

	isok := 0
	for _, v := range dataArr {
		key := BsonTOStringId(v["_id"])
		biamount := qu.Float64All(v["biamount"])
		s_winner := qu.ObjToString(v["s_winner"])
		tmp := temp[key]
		tmp_biamount := qu.Float64All(tmp["biamount"])
		tmp_s_winner := qu.ObjToString(tmp["s_winner"])
		str := ""
		if tmp_biamount != biamount {
			str += "金额~"
		}
		if tmp_s_winner != s_winner {
			str += "单位"
		}
		if str != "" {
			isok++
			info := v
			for kk, vv := range tmp {
				if kk == "_id" {
					continue
				}
				new_key := "right_" + kk
				info[new_key] = vv
			}
			save_mgo.Save("zzzzzzkkk_rg_info_err", info)
		}
	}
	//是的是的是的
	log.Debug("最终~", isok)
}

//验证数据
func verifyCutWordsInfo() {
	//总部泰康研修院南大堂人造大理石地面维修更换项目
	GSE.LoadDict()
	var reg *regexp.Regexp = regexp.MustCompile("[ \\s].*")
	f, err := os.Open("res/pcd.txt")
	if err != nil {

	}
	defer f.Close()
	rd := bufio.NewReader(f)
	total := 0
	arr := []string{}
	for {
		total++
		line, err := rd.ReadString('\n') //以'\n'为结束符读入一行
		if line != "" {
			str := reg.ReplaceAllString(line, "")
			arr = append(arr, str)
		}
		if err != nil || io.EOF == err {
			break
		}
	}
	log.Debug("总计", total, "行", "~", len(arr))

	isok := 0
	for _, v := range arr {
		s := GSE.Cut(v)
		if len(s) > 1 {
			log.Debug(v)
			isok++
		}
	}
	log.Debug("is over ", isok)
}

//导出数据bidding
func exportData0213() {

	sess := save_mgo.GetMgoConn()
	defer save_mgo.DestoryMongoConn(sess)
	q, total := map[string]interface{}{
		"_id": map[string]interface{}{
			"$lt": StringTOBsonId("63e90d000000000000000000"),
		},
	}, 0
	isok := 0
	it := sess.DB(save_mgo.DbName).C("bidding").Find(&q).Sort("-_id").Iter()
	for tmp := make(map[string]interface{}); it.Next(&tmp); total++ {
		if total%10000 == 0 {
			log.Debug("curent index ", total, "~", isok)
		}
		toptype := qu.ObjToString(tmp["toptype"])
		area := qu.ObjToString(tmp["area"])
		extracttype := qu.IntAll(tmp["extracttype"])
		if toptype == "招标" && area == "河南" && extracttype == 1 {
			isok++
			save_mgo.Save("zktest_henan_0213", tmp)
		}
		if isok >= 150000 {
			break
		}
		tmp = make(map[string]interface{})
	}
	log.Debug("is over ", total, "~", isok)
}

//修复标讯异常地域信息
func repairBeaconMessageRegion() {
	sess := save_mgo.GetMgoConn()
	defer save_mgo.DestoryMongoConn(sess)
	q, total := map[string]interface{}{}, 0
	isok, isok1, isok2 := 0, 0, 0
	it := sess.DB(save_mgo.DbName).C("zktest_warning_regions_info_new").Find(&q).Sort("_id").Iter()
	for tmp := make(map[string]interface{}); it.Next(&tmp); total++ {
		if total%1000 == 0 {
			log.Debug("curent index ", total, "~", isok, "~", isok1, "~", isok2)
		}
		tmpid := BsonTOStringId(tmp["_id"])
		update := tmp
		delete(update, "_id")
		if len(update) > 0 {
			isok++
			data_1 := save_mgo.FindById("result_20220218", tmpid)
			if data_1 != nil && len(data_1) > 0 { //存在
				isok1++
				save_mgo.UpdateById("result_20220218", tmpid, map[string]interface{}{
					"$set": update,
				})
			}
			data_2 := save_mgo.FindById("result_20220219", tmpid)
			if data_2 != nil && len(data_2) > 0 { //存在
				isok2++
				save_mgo.UpdateById("result_20220219", tmpid, map[string]interface{}{
					"$set": update,
				})
			}
		}
		tmp = make(map[string]interface{})
	}
	log.Debug("is over ", total, "~", isok, "~", isok1, "~", isok2)
}

//修复标讯采购意向信息
func repairBeaconMessageCgyx() {
	sess := save_mgo.GetMgoConn()
	defer save_mgo.DestoryMongoConn(sess)
	q, total := map[string]interface{}{}, 0
	isok, isok1, isok2 := 0, 0, 0
	it := sess.DB(save_mgo.DbName).C("zktest_cgyx_info_new").Find(&q).Sort("_id").Iter()
	for tmp := make(map[string]interface{}); it.Next(&tmp); total++ {
		if total%1000 == 0 {
			log.Debug("curent index ", total, "~", isok, "~", isok1, "~", isok2)
		}
		tmpid := BsonTOStringId(tmp["_id"])
		update := tmp
		delete(update, "_id")
		if len(update) > 0 {
			isok++
			data_1 := save_mgo.FindById("result_20220218", tmpid)
			if data_1 != nil && len(data_1) > 0 { //存在
				isok1++
				save_mgo.UpdateById("result_20220218", tmpid, map[string]interface{}{
					"$set": update,
				})
			}
			data_2 := save_mgo.FindById("result_20220219", tmpid)
			if data_2 != nil && len(data_2) > 0 { //存在
				isok2++
				save_mgo.UpdateById("result_20220219", tmpid, map[string]interface{}{
					"$set": update,
				})
			}
		}
		tmp = make(map[string]interface{})
	}
	log.Debug("is over ", total, "~", isok, "~", isok1, "~", isok2)
}

func exportSourceCgyxData() {
	dataArr, _ := save_mgo.Find("zktest_warning_regions", nil, nil, nil)
	log.Debug("查询数量~", len(dataArr))
	pool := make(chan bool, 4)
	wg := &sync.WaitGroup{}
	for k, v := range dataArr {
		if k%10000 == 0 {
			log.Debug("cur index ", k)
		}
		tmpid := qu.ObjToString(v["id"])
		pool <- true
		wg.Add(1)
		go func(tmpid string) {
			defer func() {
				<-pool
				wg.Done()
			}()
			data := save_mgo.FindById("bidding", tmpid)
			if data != nil && len(data) > 2 {
				save_mgo.Save("zktest_warning_regions_info", data)
			} else {
				data = save_mgo.FindById("bidding_back", tmpid)
				if data != nil && len(data) > 2 {
					save_mgo.Save("zktest_warning_regions_info", data)
				} else {
					log.Debug("未查询到~", tmpid)
				}
			}
		}(tmpid)
	}
	log.Debug("is over ", len(dataArr))
}

//导出全量~采购意向数据
func exportAllDataYXT() {
	//elastic.InitElasticSize("http://172.17.4.184:19800", 10)
	elastic.InitElasticSize("http://127.0.0.1:13002", 10)
	log.Debug("开始...遍历索引...")
	total := int64(0)
	esclient := elastic.GetEsConn()
	defer elastic.DestoryEsConn(esclient)
	if esclient == nil {
		log.Debug("连接池异常")
	}
	query := es_elastic.NewTermQuery("site", "医信通")
	cursor, err := esclient.Scan("bidding").Query(es_elastic.NewBoolQuery().Must(query)).
		Size(200).Do()
	if err != nil {
		log.Debug("cursor", err)
	}
	if cursor.Results == nil {
		log.Debug("results != nil; got nil")
	}
	if cursor.Results.Hits == nil {
		log.Debug("expected results.Hits != nil; got nil")
	}
	total += cursor.TotalHits()
	log.Debug("当前查询正常数：", cursor.TotalHits(), "总数：", total)
	numDocs := 0 //多线程 - 处理数据
	pool_es := make(chan bool, 3)
	wg_es := &sync.WaitGroup{}
	for {
		searchResult, err := cursor.Next()
		if err != nil {
			if err.Error() == "EOS" {
				break
			} else {
				log.Debug("cursor searchResult", err)
			}
		}
		for _, hit := range searchResult.Hits.Hits {
			tmp := make(map[string]interface{})
			err := json.Unmarshal(*hit.Source, &tmp)
			if err != nil {
				log.Debug("json Unmarshal error")
				continue
			}
			tmpid := qu.ObjToString(tmp["_id"])
			if numDocs%1000 == 0 {
				log.Debug("当前条数~", numDocs, "~", tmpid)
			}
			numDocs++
			pool_es <- true
			wg_es.Add(1)
			go func(tmpid string) {
				defer func() {
					<-pool_es
					wg_es.Done()
				}()
				save_mgo.Save("zktest_yixintong_id", map[string]interface{}{
					"id": tmpid,
				})
			}(tmpid)
		}
	}
	wg_es.Wait()
	log.Debug("遍历完毕...", total, numDocs)
}

func exportInfo0209CGYX1() {
	dataArr, _ := save_mgo.Find("zktest_cgyx_test", nil, nil, nil)
	isok := 0
	for _, tmp := range dataArr {
		detail := qu.ObjToString(tmp["detail"])
		if strings.Contains(detail, "采购金额") {
			isok++
			save_mgo.Save("zktest_cgyx_amount", tmp)
		}
	}
	log.Debug("is over ", len(dataArr), "~", isok)
}

//导出数据采购意向相关
func exportInfo0209CGYX() {
	sess := save_mgo.GetMgoConn()
	defer save_mgo.DestoryMongoConn(sess)
	q, total := map[string]interface{}{
		"_id": map[string]interface{}{
			"$lt": StringTOBsonId("63e275800000000000000000"),
		},
	}, 0
	temp, isok := map[string]int{}, 0
	it := sess.DB(save_mgo.DbName).C("bidding").Find(&q).Sort("-_id").Iter()
	for tmp := make(map[string]interface{}); it.Next(&tmp); total++ {
		if total%10000 == 0 {
			log.Debug("curent index ", total, "~", isok, "~", len(temp))
		}
		toptype := qu.ObjToString(tmp["toptype"])
		site := qu.ObjToString(tmp["site"])
		detail := qu.ObjToString(tmp["detail"])
		if toptype == "采购意向" {
			num := qu.IntAll(temp[site])
			if num < 5 {
				if strings.Contains(detail, "采购时间") {
					temp[site] = num + 1
					isok++
					save_mgo.Save("zktest_cgyx_test", tmp)
				}
			}
		}
		if isok > 150 {
			break
		}
		tmp = make(map[string]interface{})
	}
	log.Debug("标的物分类~~ ", total, "~", isok, "~", len(temp))

}

func exportPurClassCodePath() {
	sess := save_mgo.GetMgoConn()
	defer save_mgo.DestoryMongoConn(sess)
	q, total := map[string]interface{}{}, 0
	it := sess.DB(save_mgo.DbName).C("code_purchasing").Find(&q).Sort("_id").Iter()
	//记录当前代码
	tmp_code := ""
	for tmp := make(map[string]interface{}); it.Next(&tmp); total++ {
		if total%10000 == 0 {
			log.Debug("curent index ", total)
		}
		level := qu.IntAll(tmp["level"])
		name := qu.ObjToString(tmp["name"])
		code := qu.ObjToString(tmp["code"])
		pcode := qu.ObjToString(tmp["pcode"])
		path := ""
		if level == 1 || level == 2 {
			tmp_code = ""
			path = name
			info := map[string]interface{}{}
			info["name"] = name
			info["code"] = code
			info["pcode"] = pcode
			info["level"] = level
			info["path"] = path
			save_mgo.Save("code_purchasing_new", info)
		} else {
			if tmp_code != code {
				tmp_code = code
				arr, _ := save_mgo.Find("code_purchasing", map[string]interface{}{
					"code": code,
				}, map[string]interface{}{
					"_id": 1,
				}, nil)
				pathArr := []string{}
				for _, v := range arr {
					pathArr = append(pathArr, qu.ObjToString(v["name"]))
				}
				path = strings.Join(pathArr, "~")

				info := map[string]interface{}{}
				info["name"] = name
				info["code"] = code
				info["pcode"] = pcode
				info["level"] = level
				info["path"] = path
				save_mgo.Save("code_purchasing_new", info)
			}
		}
		tmp = make(map[string]interface{})
	}
	log.Debug("标的物分类~~ ", total)
}

func exportPurClassCode() {
	ff, _ := xlsx.OpenFile("1.xlsx")
	isok := 0
	for _, sheet := range ff.Sheets {
		for _, row := range sheet.Rows {
			var str []string
			for _, cell := range row.Cells {
				s := cell.String()
				s = strings.ReplaceAll(s, "　", "")
				s = strings.ReplaceAll(s, " ", "")
				str = append(str, s)
			}
			s_1, s_2, s_3, name := str[0], str[1], str[2], str[5]
			info := map[string]interface{}{}
			level := 1
			code := ""
			pcode := ""
			if s_3 != "" { //三级
				code = s_1 + s_2 + "0" + s_3
				pcode = s_1 + s_2
				level = 3
			} else {
				if s_2 != "" { //二级
					code = s_1 + s_2
					pcode = s_1
					level = 2
				} else {
					if s_1 != "" { //一级
						code = s_1
						level = 1
					} else {
						log.Debug("异常行~~~")
						continue
					}
				}
			}
			info["name"] = name
			info["code"] = code
			info["pcode"] = pcode
			info["level"] = level
			save_mgo.Save("code_purchasing", info)
			isok++

		}
	}
	log.Debug("is over ~ ", isok)

}

//导致标的物信息数据~~~~
func exportBidPurListInfo() {
	log.Debug("导出标的物信息数据~~~")
	sess := save_mgo.GetMgoConn()
	defer save_mgo.DestoryMongoConn(sess)
	q, total := map[string]interface{}{}, 0
	purInfos := map[string]map[string]interface{}{}
	it := sess.DB(save_mgo.DbName).C("bidding").Find(&q).Sort("_id").Select(map[string]interface{}{
		"s_topscopeclass": 1,
		"purchasinglist":  1,
	}).Iter()
	for tmp := make(map[string]interface{}); it.Next(&tmp); total++ {
		if total%10000 == 0 {
			log.Debug("curent index ", total, "~", len(purInfos))
		}
		p_list := IsMarkInterfaceMap(tmp["purchasinglist"])
		if len(p_list) > 0 {
			s_topscopeclass := qu.ObjToString(tmp["s_topscopeclass"])
			classArr := []string{}
			if s_topscopeclass != "" {
				classArr = strings.Split(s_topscopeclass, ",")
			}
			for _, v := range p_list {
				itemname := qu.ObjToString(v["itemname"])
				if itemname == "" || utf8.RuneCountInString(itemname) > 30 {
					continue
				}
				info := purInfos[itemname]
				if info == nil { //新增
					purInfos[itemname] = map[string]interface{}{
						"total": 1,
						"name":  itemname,
						"class": s_topscopeclass,
					}
				} else { //补充类别
					new_info := dealWithPurInfo(info, classArr)
					purInfos[itemname] = new_info
				}
			}
		}
		tmp = make(map[string]interface{})
	}
	log.Debug("标的物数据准备完毕~~ ", total, "~", len(purInfos))
	log.Debug("~~~~~~")
	log.Debug("开始保存~标的物数据")

	isok := 0
	for k, v := range purInfos {
		if isok%10000 == 0 {
			log.Debug("is save index ", isok, "~", k)
		}
		save_mgo.Save("zktest_purchasing_info", v)
		isok++
	}

	log.Debug("is save over ", len(purInfos), "~", isok)
}

func dealWithPurInfo(info map[string]interface{}, classArr []string) map[string]interface{} {
	new_info := map[string]interface{}{}
	name := qu.ObjToString(info["name"])
	total := qu.IntAll(info["total"])
	class := qu.ObjToString(info["class"])
	newArr := []string{}
	if class != "" {
		newArr = strings.Split(class, ",")
	}
	if len(classArr) > 0 {
		for _, v := range classArr {
			isExists := false
			for _, v1 := range newArr {
				if v1 == v {
					isExists = true
					break
				}
			}
			if !isExists {
				newArr = append(newArr, v)
			}
		}
	}
	new_class := ""
	if len(newArr) > 0 {
		new_class = strings.Join(newArr, ",")
	}
	new_info["name"] = name
	new_info["total"] = total + 1
	new_info["class"] = new_class
	return new_info
}

func repairSiteData1230() {
	siteId := []string{}
	siteName := []string{}
	log.Debug("待校验~", len(siteId), "~", len(siteName))
	isExist, isRepair := 0, 0
	for k, v := range siteName {
		if k%100 == 0 {
			log.Debug("cur index ", k, "~", isExist, "~", isRepair)
		}
		data := qy_mgo.FindOne("qyxy_std", map[string]interface{}{
			"company_name": v,
		})

		if len(data) > 0 {
			isExist++
			company_area := qu.ObjToString(data["company_area"])
			if company_area != "" && company_area != "全国" {
				isRepair++

				save_mgo.UpdateById("site", siteId[k], map[string]interface{}{
					"$set": map[string]interface{}{
						"qy_area": company_area,
					},
				})
			}
		}
	}

}

//导出地域信息~进行对比
func exportSpecRegionInfo() {
	sess := save_mgo.GetMgoConn()
	defer save_mgo.DestoryMongoConn(sess)
	q, total := map[string]interface{}{}, 0
	isok, infos := 0, map[string]map[string]string{}
	it := sess.DB(save_mgo.DbName).C("zktest_regions_test").Find(&q).Sort("_id").Iter()
	for tmp := make(map[string]interface{}); it.Next(&tmp); total++ {
		if total%10000 == 0 {
			log.Debug("curent index ", total, "~", isok)
		}
		site := qu.ObjToString(tmp["site"])
		subtype := qu.ObjToString(tmp["subtype"])
		if subtype == "" {
			subtype = "空"
		}
		data := infos[site]
		if data == nil {
			data = map[string]string{}
			data[subtype] = subtype
			infos[site] = data
			isok++
			save_mgo.Save("zktest_regions_v1", tmp)
		} else {
			if data[subtype] == "" && len(data) < 4 {
				data[subtype] = subtype
				infos[site] = data
				isok++
				save_mgo.Save("zktest_regions_v1", tmp)
			}
		}
		tmp = make(map[string]interface{})
	}
	log.Debug("is over ", total, "~", isok)
}

//修复更新站点信息
func RepairUpdateSitesInfo() {
	ff, _ := xlsx.OpenFile("1.xlsx")
	isok := 0
	for _, sheet := range ff.Sheets {
		for k, row := range sheet.Rows {
			if k == 0 {
				continue
			}
			var str []string
			for _, cell := range row.Cells {
				str = append(str, cell.String())
			}
			tmpid := str[0]
			info := map[string]interface{}{
				"$set": map[string]interface{}{
					"area":     str[3],
					"city":     str[4],
					"district": str[5],
				},
			}
			save_mgo.UpdateById("site", tmpid, info)
			isok++
		}
	}
	log.Debug("is over ~ ", isok)
}

func exportdifferenceinfo() {

	newArr, _ := save_mgo.Find("zktest_regions_new", nil, nil, map[string]interface{}{
		"area":        1,
		"city":        1,
		"district":    1,
		"href":        1,
		"jytest_href": 1,
	})
	oldArr, _ := save_mgo.Find("zktest_regions_old", nil, nil, map[string]interface{}{
		"area":        1,
		"city":        1,
		"district":    1,
		"href":        1,
		"jytest_href": 1,
	})

	info := map[string]map[string]interface{}{}
	for _, v := range oldArr {
		tmpid := BsonTOStringId(v["_id"])
		info[tmpid] = v
	}
	log.Debug("init 完毕 ", len(info))
	total, isok := 0, 0
	for k, v := range newArr {
		if k%10000 == 0 {
			log.Debug("cur index ", k, "~", total, "~", isok)
		}
		data := v
		tmpid := BsonTOStringId(v["_id"])
		area := qu.ObjToString(v["area"])
		city := qu.ObjToString(v["city"])
		tmp := info[tmpid]
		if tmp == nil {
			continue
		}
		total++
		if area == qu.ObjToString(tmp["area"]) && city == qu.ObjToString(tmp["city"]) {

		} else {
			isok++
			data["old_area"] = qu.ObjToString(tmp["area"])
			data["old_city"] = qu.ObjToString(tmp["city"])
			data["old_district"] = qu.ObjToString(tmp["district"])
			data["new_area"] = qu.ObjToString(v["area"])
			data["new_city"] = qu.ObjToString(v["city"])
			data["new_district"] = qu.ObjToString(v["district"])
			delete(data, "area")
			delete(data, "city")
			delete(data, "district")

			save_mgo.Save("zktest_regions_diff", data)
		}
	}
	log.Debug("is over ", total, "~", isok)
}

//导出~1月2日的招标信息数据
func exportDataInfo1231() {
	//拉取数据
	log.Debug("拉取12月31日，全天数据......")
	sess := python_mgo.GetMgoConn()
	defer python_mgo.DestoryMongoConn(sess)
	q, total := map[string]interface{}{
		"_id": map[string]interface{}{
			"$gte": StringTOBsonId("63af0b000000000000000000"),
			"$lt":  StringTOBsonId("63b05c800000000000000000"),
		},
	}, 0
	isok := 0
	it := sess.DB(python_mgo.DbName).C("result_20220219").Find(&q).Sort("_id").Select(map[string]interface{}{
		"repeat": 1,
	}).Iter()
	for tmp := make(map[string]interface{}); it.Next(&tmp); total++ {
		if total%5000 == 0 {
			log.Debug("curent index ", total, "~", isok)
		}
		repeat := qu.IntAll(tmp["repeat"])
		if repeat == 0 {
			isok++
			tmpid := BsonTOStringId(tmp["_id"])
			data := save_mgo.FindById("bidding", tmpid)
			if data != nil && len(data) > 2 {
				save_mgo.Save("zktest_regions_test", data)
			} else {
				data = save_mgo.FindById("bidding_back", tmpid)
				if data != nil && len(data) > 2 {
					save_mgo.Save("zktest_regions_test", data)
				} else {
					log.Debug("未查询到~", tmpid)
				}
			}
		}
		tmp = make(map[string]interface{})
	}
	log.Debug("is over ", total, "~", isok)
}

func EsRepairInfo() {
	elastic.InitElasticSize("http://127.0.0.1:13002", 10)
	query := `{"query":{"filtered":{"filter":{"bool":{"must":[{"term":{"buyer":"成都东部新区管理委员会"}}]}}}},"_source":["_id","area","buyer"],"from":"0","size":"100"}`
	es_data := *elastic.Get("bidding", "bidding", query)
	log.Debug("当前查询结果：", len(es_data))
	for _, v := range es_data {
		tmpid := qu.ObjToString(v["_id"])
		log.Debug(tmpid)
	}
}

func updateNjInfo() {
	sess := save_mgo.GetMgoConn()
	defer save_mgo.DestoryMongoConn(sess)
	q, total := map[string]interface{}{}, 0
	isok := 0
	it := sess.DB(save_mgo.DbName).C("bidding_1101_nj_zd").Find(&q).Sort("_id").Select(map[string]interface{}{
		"construction_area": 1,
		"floor_area":        1,
	}).Iter()
	for tmp := make(map[string]interface{}); it.Next(&tmp); total++ {
		if total%10000 == 0 {
			log.Debug("cur index ", total, "~", isok)
		}
		floor_area := qu.ObjToString(tmp["floor_area"])
		tmpid := BsonTOStringId(tmp["_id"])
		if floor_area != "" {
			isok++
			save_mgo.UpdateById("bidding_nzj", tmpid, map[string]interface{}{
				"$set": map[string]interface{}{
					"floor_area": floor_area,
				},
			})
		}

		tmp = make(map[string]interface{})
	}
	log.Debug("is over ", total, "~", isok)

}

func loadNjInfo() (map[string]string, map[string]string) {
	sess := python_mgo.GetMgoConn()
	defer python_mgo.DestoryMongoConn(sess)
	q, total := map[string]interface{}{}, 0
	constructions := map[string]string{}
	floors := map[string]string{}
	it := sess.DB(python_mgo.DbName).C("bidding_nzj").Find(&q).Sort("-_id").Select(map[string]interface{}{
		"construction_area": 1,
		"floor_area":        1,
	}).Iter()
	for tmp := make(map[string]interface{}); it.Next(&tmp); total++ {
		if total%10000 == 0 {
			log.Debug("cur index ", total, "~", len(constructions), "~", len(floors))
		}

		construction_area := qu.ObjToString(tmp["construction_area"])
		floor_area := qu.ObjToString(tmp["floor_area"])
		tmpid := BsonTOStringId(tmp["_id"])
		if construction_area != "" {
			constructions[tmpid] = tmpid
		}
		if floor_area != "" {
			floors[tmpid] = tmpid
		}
		tmp = make(map[string]interface{})
	}
	log.Debug("is over ", total, "~", len(constructions), "~", len(floors))

	return constructions, floors
}

func exportNJ() {
	constructions, floors := loadNjInfo()
	log.Debug("加载完毕~", len(constructions), "~", len(floors))
	sess := save_mgo.GetMgoConn()
	defer save_mgo.DestoryMongoConn(sess)
	q, total := map[string]interface{}{}, 0
	nj_pool := make(chan bool, 10)
	nj_wg := &sync.WaitGroup{}

	jz_reg := regexp.MustCompile("(建筑面积)")
	zd_reg := regexp.MustCompile("(占地面积)")

	it := sess.DB("qfw").C("bidding_1101_nj").Find(&q).Sort("_id").Iter()
	for tmp := make(map[string]interface{}); it.Next(&tmp); total++ {
		if total%10000 == 0 {
			log.Debug("cur index ", total, tmp["_id"])
		}
		nj_pool <- true
		nj_wg.Add(1)
		go func(tmp map[string]interface{}) {
			defer func() {
				<-nj_pool
				nj_wg.Done()
			}()
			contenthtml := qu.ObjToString(tmp["contenthtml"])
			tmpid := BsonTOStringId(tmp["_id"])
			if jz_reg.MatchString(contenthtml) {
				if constructions[tmpid] == "" {
					save_mgo.Save("bidding_1101_nj_jz", tmp)
				}
			}
			if zd_reg.MatchString(contenthtml) {
				if floors[tmpid] == "" {
					save_mgo.Save("bidding_1101_nj_zd", tmp)
				}
			}
		}(tmp)
		tmp = make(map[string]interface{})
	}
	nj_wg.Wait()
	log.Debug("is copy over ", total)

}

//导出报名截止时间
func exportSignendtimeInfo() {
	//signendtime
	sess := save_mgo.GetMgoConn()
	defer save_mgo.DestoryMongoConn(sess)
	q, total := map[string]interface{}{}, 0
	info, isok := map[string]int{}, 0
	it := sess.DB(save_mgo.DbName).C("result_20220218").Find(&q).Sort("-_id").Select(map[string]interface{}{
		"signendtime": 1,
		"site":        1,
		"href":        1,
		"jytest_href": 1,
	}).Iter()
	for tmp := make(map[string]interface{}); it.Next(&tmp); total++ {
		if total%10000 == 0 {
			log.Debug("cur index ", total, "~", isok)
		}
		signendtime := qu.Int64All(tmp["signendtime"])
		if signendtime > 0 {
			site := qu.ObjToString(tmp["site"])
			if qu.IntAll(info[site]) < 3 && isok < 500 {
				info[site] = qu.IntAll(info[site]) + 1
				isok++
				delete(tmp, "signendtime")
				tmp["signendtime"] = time.Unix(signendtime, 0).Format(timeLayout)
				save_mgo.Save("zzzzzz", tmp)
			}
			if isok > 120 {
				break
			}
		}
		tmp = make(map[string]interface{})
	}
	log.Debug("is ext over ", total)

}

//拉取抽取数据~城市空
func exportNullRegionData() {
	sess := save_mgo.GetMgoConn()
	defer save_mgo.DestoryMongoConn(sess)
	q, total := map[string]interface{}{}, 0
	info1, info2 := map[string]int{}, map[string]int{}
	it := sess.DB(save_mgo.DbName).C("result_20220218").Find(&q).Sort("-_id").Select(map[string]interface{}{
		"title":       1,
		"area":        1,
		"city":        1,
		"district":    1,
		"site":        1,
		"spidercode":  1,
		"href":        1,
		"jytest_href": 1,
	}).Iter()
	for tmp := make(map[string]interface{}); it.Next(&tmp); total++ {
		if total%10000 == 0 {
			log.Debug("cur index ", total, "~", len(info1), "~", len(info2))
		}
		area := qu.ObjToString(tmp["area"])
		site := qu.ObjToString(tmp["site"])
		if area == "全国" {
			if qu.IntAll(info1[site]) < 1 && len(info1) < 250 {
				info1[site] = qu.IntAll(info1[site]) + 1
				save_mgo.Save("zktest_region_data", tmp)
			}
		} else {
			if qu.IntAll(info2[site]) < 1 && len(info2) < 250 {
				info2[site] = qu.IntAll(info2[site]) + 1
				save_mgo.Save("zktest_region_data", tmp)
			}
		}
		if len(info1)+len(info2) >= 500 {
			break
		}
		tmp = make(map[string]interface{})
	}
	log.Debug("is over ", total)
}

func tongjiNiJianData() {
	//采集~抽取统计
	keyArr := []string{
		"approvecode",
		"total_investment",
		"funds",
		"owner",
		"projectaddr",
		"projectperiod",
		"project_scale",
		"project_startdate",
		"project_completedate",
		"construction_area",
		"floor_area",
		"project_person",
		"project_phone",
		"approvenumber",
		"projecttype",
		"approvestatus",
	}
	ext_counts := make(map[string]int, 0)
	sess := save_mgo.GetMgoConn()
	defer save_mgo.DestoryMongoConn(sess)
	q, total := map[string]interface{}{}, 0
	it := sess.DB(save_mgo.DbName).C("zktest_nijian_1017").Find(&q).Iter()
	for tmp := make(map[string]interface{}); it.Next(&tmp); total++ {
		for _, v := range keyArr {
			if v == "construction_area" || v == "floor_area" {
				info := *qu.ObjToMap(tmp["project_scale_info"])
				if qu.ObjToString(info[v]) != "" {
					ext_counts[v] = qu.IntAll(ext_counts[v]) + 1
				}
			} else {
				if tmp[v] != nil {
					ext_counts[v] = qu.IntAll(ext_counts[v]) + 1
				}
			}
		}
		tmp = make(map[string]interface{})
	}
	log.Debug("is ext over ", total)
	for _, v := range keyArr {
		time.Sleep(time.Second * 1)
		fmt.Println(ext_counts[v])
	}

	//return
	data_counts := make(map[string]int, 0)
	q, total = map[string]interface{}{}, 0
	it = sess.DB(save_mgo.DbName).C("zktest_nijian_1017_new_new").Find(&q).Iter()
	for tmp := make(map[string]interface{}); it.Next(&tmp); total++ {
		for _, v := range keyArr {
			if tmp[v] != nil {
				data_counts[v] = qu.IntAll(data_counts[v]) + 1
			}
		}
		tmp = make(map[string]interface{})
	}
	log.Debug("is data over ", total)
	for _, v := range keyArr {
		time.Sleep(time.Second * 1)
		fmt.Println(data_counts[v])
	}

	return
}

//拉取拟建数据~
func exportNiJianData() {
	sess := save_mgo.GetMgoConn()
	defer save_mgo.DestoryMongoConn(sess)
	q, total := map[string]interface{}{
		"_id": map[string]interface{}{
			"$gte": StringTOBsonId("6342f0000000000000000000"),
			"$lt":  StringTOBsonId("634836000000000000000000"),
		},
	}, 0
	isok := 0
	it := sess.DB(save_mgo.DbName).C("bidding").Find(&q).Sort("-_id").Iter()
	for tmp := make(map[string]interface{}); it.Next(&tmp); total++ {
		if total%5000 == 0 {
			log.Debug("curent index ", total, "~", isok)
		}
		subtype := qu.ObjToString(tmp["subtype"])
		if subtype == "拟建" {
			isok++
			save_mgo.Save("zktest_nijian_1017", tmp)
		}
		tmp = make(map[string]interface{})
	}
	log.Debug("is over ", total, "~", isok)
}

//拉取一批数据~拟建类型~每种站点5条 200个站点即可
func exportNiJianUnSiteData() {
	sess := save_mgo.GetMgoConn()
	defer save_mgo.DestoryMongoConn(sess)
	q, total := map[string]interface{}{
		"_id": map[string]interface{}{
			"$lt": StringTOBsonId("6342f0000000000000000000"),
		},
	}, 0
	dicts := map[string]int{}
	isok := 0
	it := sess.DB(save_mgo.DbName).C("bidding").Find(&q).Sort("-_id").Iter()
	for tmp := make(map[string]interface{}); it.Next(&tmp); total++ {
		if total%5000 == 0 {
			log.Debug("curent index ", total, "~", len(dicts), "~", isok)
		}
		subtype := qu.ObjToString(tmp["subtype"])
		site := qu.ObjToString(tmp["site"])
		if subtype == "拟建" && qu.IntAll(dicts[site]) < 5 {
			dicts[site] = qu.IntAll(dicts[site]) + 1
			isok++
			save_mgo.Save("zktest_nijian_data", tmp)
		}
		if isok >= 300 {
			break
		}
		tmp = make(map[string]interface{})
	}
	log.Debug("is over ", total, "~", len(dicts), "~", isok)
}

//筛选不同重复数据
func filterDiffRepeatData(coll_1 string, coll_2 string) {
	dataArr_1, _ := save_mgo.Find(coll_1, map[string]interface{}{
		"repeat": 1,
	}, nil, map[string]interface{}{
		"repeat_id": 1,
	})
	dataArr_2, _ := save_mgo.Find(coll_2, map[string]interface{}{
		"repeat": 1,
	}, nil, map[string]interface{}{
		"repeat_id": 1,
	})
	dict := map[string]string{}
	for _, v := range dataArr_1 {
		tmpid := BsonTOStringId(v["_id"])
		repeat_id := qu.ObjToString(v["repeat_id"])
		dict[tmpid] = repeat_id
	}

	log.Debug("准备数据~", len(dict))
	is_err := 0
	for _, v := range dataArr_2 {
		tmpid := BsonTOStringId(v["_id"])
		repeat_id := qu.ObjToString(v["repeat_id"])
		if dict[tmpid] != "" && dict[tmpid] == repeat_id {

		} else {
			is_err++
			data_1 := save_mgo.FindById("result_20220219", tmpid)
			data_2 := save_mgo.FindById("result_20220219", repeat_id)
			reason_data := save_mgo.FindById(coll_2, tmpid)
			save_mgo.Save("zzzzz_chayi_data", map[string]interface{}{
				"id_1":   tmpid,
				"id_2":   repeat_id,
				"href_1": qu.ObjToString(data_1["href"]),
				"href_2": qu.ObjToString(data_2["href"]),
				"reason": reason_data["repeat_reason"],
			})
		}
	}
	log.Debug("最终差异数据~", is_err)
}

//计算异常数据~统计
func calculateWarningData() {
	sess := save_mgo.GetMgoConn()
	defer save_mgo.DestoryMongoConn(sess)
	q, total, isok := map[string]interface{}{}, 0, 0
	it := sess.DB(save_mgo.DbName).C("extract_budget_data_new").Find(&q).Select(map[string]interface{}{
		"budget": 1,
	}).Iter()
	for tmp := make(map[string]interface{}); it.Next(&tmp); total++ {
		if total%10000 == 0 {
			log.Debug("cur index ", total, "~", isok)
		}
		budget := qu.Float64All(tmp["budget"])
		tmpid := BsonTOStringId(tmp["_id"])
		data := save_mgo.FindById("extract_budget_data", tmpid)
		old_budget := qu.Float64All(data["budget"])
		if budget != old_budget {
			isok++
			//log.Debug(fmt.Sprintf("%.2f", old_budget), "~", fmt.Sprintf("%.2f", budget), "~", tmpid)
			save_mgo.Save("zktest_repair_1", tmp)
		}
		tmp = make(map[string]interface{})
	}
	log.Debug("is over ", total, "~", isok)
}

//构建信息
func createWinnerDatas(winner_datas *map[string]string) {
	sess := python_mgo.GetMgoConn()
	defer python_mgo.DestoryMongoConn(sess)
	q, total := map[string]interface{}{}, 0
	it := sess.DB(python_mgo.DbName).C("winner_err").Find(&q).Select(map[string]interface{}{
		"name": 1,
	}).Iter()
	for tmp := make(map[string]interface{}); it.Next(&tmp); total++ {
		if total%10000 == 0 {
			log.Debug("cur index ", total, "~", len(*winner_datas))
		}
		name := qu.ObjToString(tmp["name"])
		if name != "" {
			(*winner_datas)[name] = name
		}
		tmp = make(map[string]interface{})
	}
	log.Debug("is over ", total, len(*winner_datas))

	//total := int64(0)
	//esclient := elastic.GetEsConn()
	//defer elastic.DestoryEsConn(esclient)
	//if esclient == nil {
	//	log.Debug("连接池异常")
	//}
	//cursor, err := esclient.Scan("winner").Query(es_elastic.NewBoolQuery().Must()).
	//	Size(200).Do()
	//if err != nil {
	//	log.Debug("cursor", err)
	//}
	//if cursor.Results == nil {
	//	log.Debug("results != nil; got nil")
	//}
	//if cursor.Results.Hits == nil {
	//	log.Debug("expected results.Hits != nil; got nil")
	//}
	//total += cursor.TotalHits()
	//log.Debug("当前查询正常数：", cursor.TotalHits(), "总数：", total)
	//numDocs := 0
	//isExists := 0
	//for {
	//	searchResult, err := cursor.Next()
	//	if err != nil {
	//		if err.Error() == "EOS" {
	//			break
	//		} else {
	//			log.Debug("cursor searchResult", err)
	//		}
	//	}
	//	for _, hit := range searchResult.Hits.Hits {
	//		tmp := make(map[string]interface{})
	//		err := json.Unmarshal(*hit.Source, &tmp)
	//		if err != nil {
	//			log.Debug("json Unmarshal error")
	//			continue
	//		}
	//		if numDocs%10000 == 0 {
	//			log.Debug("当前条数~", numDocs, "~集合数~", len(*winner_datas))
	//		}
	//		numDocs++
	//		name := qu.ObjToString(tmp["name"])
	//		if name != "" {
	//			(*winner_datas)[name] = name
	//		}
	//	}
	//}
	//log.Debug("遍历准备数据完毕...", total, numDocs, isExists)
}

//计算海南企业的数量
func exportHaiNanData() {

	elastic.InitElasticSize("http://172.17.4.184:19800", 10)
	//elastic.InitElasticSize("http://127.0.0.1:13002", 10)
	winner_datas := map[string]string{}
	createWinnerDatas(&winner_datas)
	log.Debug("开始...遍历索引...")
	total := int64(0)
	esclient := elastic.GetEsConn()
	defer elastic.DestoryEsConn(esclient)
	if esclient == nil {
		log.Debug("连接池异常")
	}
	query := es_elastic.NewTermQuery("company_area", "海南")
	cursor, err := esclient.Scan("qyxy").Query(es_elastic.NewBoolQuery().Must(query)).
		Size(200).Do()
	if err != nil {
		log.Debug("cursor", err)
	}
	if cursor.Results == nil {
		log.Debug("results != nil; got nil")
	}
	if cursor.Results.Hits == nil {
		log.Debug("expected results.Hits != nil; got nil")
	}
	total += cursor.TotalHits()
	log.Debug("当前查询正常数：", cursor.TotalHits(), "总数：", total)
	numDocs := 0
	isExists := 0
	//多线程 - 处理数据
	pool_es := make(chan bool, 1)
	wg_es := &sync.WaitGroup{}
	for {
		searchResult, err := cursor.Next()
		if err != nil {
			if err.Error() == "EOS" {
				break
			} else {
				log.Debug("cursor searchResult", err)
			}
		}
		for _, hit := range searchResult.Hits.Hits {
			tmp := make(map[string]interface{})
			err := json.Unmarshal(*hit.Source, &tmp)
			if err != nil {
				log.Debug("json Unmarshal error")
				continue
			}
			if numDocs%1000 == 0 {
				log.Debug("当前条数~", numDocs, "~存在数量~", isExists, "~Es数据~", tmp["_id"])
			}
			numDocs++
			company_name := qu.ObjToString(tmp["company_name"])
			if winner_datas[company_name] != "" {
				isExists++
				pool_es <- true
				wg_es.Add(1)
				go func(company_name string) {
					defer func() {
						<-pool_es
						wg_es.Done()
					}()
					save_mgo.Save("zktest_hainan_data", map[string]interface{}{
						"name": company_name,
					})
				}(company_name)
			}
		}
	}
	wg_es.Wait()

	log.Debug("遍历完毕...", total, numDocs, isExists)

}

//计算标讯信息数量
func calculateHaiNanDataNums() {
	sess := save_mgo.GetMgoConn()
	defer save_mgo.DestoryMongoConn(sess)
	datas := map[string]string{}
	q, total := map[string]interface{}{}, 0
	it := sess.DB(save_mgo.DbName).C("zktest_hainan_data").Find(&q).Select(map[string]interface{}{
		"name": 1,
	}).Iter()
	for tmp := make(map[string]interface{}); it.Next(&tmp); total++ {
		if total%1000 == 0 {
			log.Debug("cur index ", total)
		}
		name := qu.ObjToString(tmp["name"])
		if name != "" {
			datas[name] = name
		}
		tmp = make(map[string]interface{})
	}
	log.Debug("is over ", total, len(datas))

	elastic.InitElasticSize("http://172.17.4.184:19800", 10)
	//elastic.InitElasticSize("http://127.0.0.1:13002", 10)
	esclient := elastic.GetEsConn()
	defer elastic.DestoryEsConn(esclient)
	totl_nums := int64(0)
	index := 0
	//多线程 - 处理数据
	pool_es := make(chan bool, 10)
	wg_es := &sync.WaitGroup{}

	data_ids := map[string]string{}

	for name, _ := range datas {
		if index%100 == 0 {
			log.Debug("cur index ", index, "~", totl_nums, "~", len(data_ids))
		}
		index++
		//多线程~
		pool_es <- true
		wg_es.Add(1)
		go func(name string) {
			defer func() {
				<-pool_es
				wg_es.Done()
			}()
			//query := fmt.Sprintf(`{"query":{"filtered":{"filter":{"bool":{"must":[{"terms":{"subtype":["成交","中标","合同"]}},{"term":{"winner":"%s"}}]}}}},"_source":["_id"]}`, name)
			query := fmt.Sprintf(`{"query":{"filtered":{"filter":{"bool":{"must":[{"terms":{"subtype":["成交","中标","合同"]}}]}},"query":{"bool":{"should":[{"multi_match":{"query":"%s","type":"phrase","fields":["s_winner"]}}]}}}},"_source":["_id"]}`, name)

			res, _ := esclient.Search().Index("bidding").Type("bidding").Source(query).Do()
			num := res.Hits.TotalHits
			numLock.Lock()
			totl_nums += num
			numLock.Unlock()

			//res := *elastic.Get("bidding", "bidding", query)
			//for _, v := range res {
			//	numLock.Lock()
			//	key := qu.ObjToString(v["_id"])
			//	data_ids[key] = key
			//	numLock.Unlock()
			//}
		}(name)
	}
	wg_es.Wait()
	log.Debug("最终有效企业数量~", len(datas), "标讯数量~", totl_nums, "~去重后数量~", len(data_ids))
}

//导出~需要替换数据的所有id
func exportReplaceDataID(gteid string, lteid string) {
	log.Debug("开始导出~待~替换~数据~")
	sess := save_mgo.GetMgoConn()
	defer save_mgo.DestoryMongoConn(sess)
	collName := "result_20220218"
	q, total, isok, isreplace := map[string]interface{}{
		"_id": map[string]interface{}{
			"$gte": StringTOBsonId(gteid),
			"$lte": StringTOBsonId(lteid),
		},
	}, 0, 0, 0
	it := sess.DB(save_mgo.DbName).C(collName).Find(&q).Select(map[string]interface{}{
		"href":   1,
		"repeat": 1,
	}).Iter()
	for tmp := make(map[string]interface{}); it.Next(&tmp); total++ {
		if total%10000 == 0 {
			log.Debug("cur index ", total, "~", isok, "~", isreplace)
		}
		repeat := qu.IntAll(tmp["repeat"])
		href := qu.ObjToString(tmp["href"])
		tmpid := BsonTOStringId(tmp["_id"])
		if repeat == 0 && strings.Contains(href, "https://www.jianyu360.cn") {
			isok++
			dataArr, _ := save_mgo.Find(collName, map[string]interface{}{"repeat_id": tmpid}, nil, map[string]interface{}{
				"href":   1,
				"repeat": 1,
			})
			for _, v := range dataArr {
				new_repeat := qu.IntAll(v["repeat"])
				new_href := qu.ObjToString(v["href"])
				if new_repeat == 1 && new_href != "" && !strings.Contains(new_href, "https://www.jianyu360.cn") {
					//有效
					isreplace++
					save_mgo.Save("result_replace_repair_log", map[string]interface{}{
						"_id":        v["_id"],
						"replace_id": tmpid,
					})
					break
				}
			}
		}
		tmp = make(map[string]interface{})
	}
	log.Debug("is over ", total, "~", isok, "~", isreplace)

}

//替换数据~俩抽取表~bidding表
func createReplaceData(collName string) {
	log.Debug("开始替换~数据~")
	sess := save_mgo.GetMgoConn()
	defer save_mgo.DestoryMongoConn(sess)
	q, total := map[string]interface{}{}, 0
	it := sess.DB(save_mgo.DbName).C(collName).Find(&q).Sort("_id").Iter()
	for tmp := make(map[string]interface{}); it.Next(&tmp); total++ {
		if total%10000 == 0 {
			log.Debug("cur index ", total, tmp["_id"])
		}
		info_id := BsonTOStringId(tmp["_id"])
		source_id := qu.ObjToString(tmp["replace_id"])
		//查询两条抽取数据
		is_log, ext_s_data, ext_i_data := confrimHistoryExtractData(source_id, info_id)
		is_bid, bid_s_data, bid_i_data := confrimBiddingData(source_id, info_id)
		if is_log && is_bid {
			is_save := save_mgo.Save("result_replace_log", map[string]interface{}{
				"_id":        StringTOBsonId(info_id),
				"replace_id": source_id,
				"is_history": 2,
			})
			if is_save == nil {
				log.Debug("新增log错误~", info_id, "~", source_id)
				tmp = make(map[string]interface{})
				continue
			}

			repeat_reason := qu.ObjToString(ext_s_data["repeat_reason"])
			delete(ext_s_data, "repeat_id")
			delete(ext_s_data, "repeat_reason")
			ext_s_data["repeat"] = 0

			ext_i_data["repeat"] = 1
			ext_i_data["repeat_id"] = source_id
			ext_i_data["repeat_reason"] = repeat_reason

			save_mgo.DeleteById("result_20220218", source_id)
			save_mgo.Save("result_20220218", ext_s_data)
			is_del_source := save_mgo.DeleteById("result_20220219", source_id)
			if is_del_source > 0 {
				save_mgo.Save("result_20220219", ext_s_data)
			}
			save_mgo.DeleteById("result_20220218", info_id)
			save_mgo.Save("result_20220218", ext_i_data)
			is_del_info := save_mgo.DeleteById("result_20220219", info_id)
			if is_del_info > 0 {
				save_mgo.Save("result_20220219", ext_i_data)
			}

			python_mgo.DeleteById("bidding", source_id)
			python_mgo.Save("bidding", bid_s_data)
			python_mgo.DeleteById("bidding", info_id)
			python_mgo.Save("bidding", bid_i_data)
		} else {
			log.Debug("替换~相关表~未查询到数据~", source_id, "~", info_id)
		}

		tmp = make(map[string]interface{})
	}
	log.Debug("is over ", total)
}

//替换数据~从
func createReplaceDataFromArr() {
	arr := []string{}
	for _, v := range arr {
		tmp := save_mgo.FindById("result_replace_repair_log", v)
		info_id := BsonTOStringId(tmp["_id"])
		source_id := qu.ObjToString(tmp["replace_id"])
		if info_id != "" && source_id != "" { //能查到数据~更新一下
			save_mgo.UpdateById("result_replace_log", info_id, map[string]interface{}{
				"$set": map[string]interface{}{
					"replace_id": source_id,
					"is_history": 2,
				},
			})
		} else {
			log.Debug("关联id~异常~")
		}
	}

}

//查询历史抽取表数据
func confrimHistoryExtractData(source_id string, info_id string) (bool, map[string]interface{}, map[string]interface{}) {
	source_data := map[string]interface{}{}
	info_data := map[string]interface{}{}
	isvalid := false
	source_data = save_mgo.FindById("result_20220218", source_id)
	info_data = save_mgo.FindById("result_20220218", info_id)
	if len(source_data) > 2 && len(info_data) > 2 {
		isvalid = true
		ts_id := source_data["_id"]
		ti_id := info_data["_id"]
		source_data["_id"] = ti_id
		info_data["_id"] = ts_id
	}
	return isvalid, info_data, source_data
}

//查询bidding表数据
func confrimBiddingData(source_id string, info_id string) (bool, map[string]interface{}, map[string]interface{}) {
	source_data := map[string]interface{}{}
	info_data := map[string]interface{}{}
	isvalid := false
	source_data = python_mgo.FindById("bidding", source_id)
	info_data = python_mgo.FindById("bidding", info_id)
	if len(source_data) > 2 && len(info_data) > 2 {
		isvalid = true
		ts_id := source_data["_id"]
		ti_id := info_data["_id"]
		source_data["_id"] = ti_id
		info_data["_id"] = ts_id
	}
	return isvalid, info_data, source_data
}

//更新剑鱼链接
func updateJyhref() {
	sess := save_mgo.GetMgoConn()
	defer save_mgo.DestoryMongoConn(sess)
	q, total := map[string]interface{}{}, 0
	it := sess.DB(save_mgo.DbName).C("zktest_exists_addr").Find(&q).Iter()
	for tmp := make(map[string]interface{}); it.Next(&tmp); total++ {
		if total%10000 == 0 {
			log.Debug("cur index ", total)
		}
		tmpid := BsonTOStringId(tmp["_id"])
		jytest_href := fmt.Sprintf(Url, qu.CommonEncodeArticle("content", tmpid))
		save_mgo.UpdateById("zktest_exists_addr", tmpid, map[string]interface{}{
			"$set": map[string]interface{}{
				"jytest_href": jytest_href,
			},
		})
		tmp = make(map[string]interface{})
	}
	log.Debug("is over ...", total)
}

//bidding数据 导出空城市 site 区分数量
func dealWithAreaCityData() {
	sess := save_mgo.GetMgoConn()
	defer save_mgo.DestoryMongoConn(sess)
	q, total := map[string]interface{}{
		"comeintime": map[string]interface{}{
			"$gte": 1654012800,
			"$lt":  1655568000,
		},
	}, 0
	dict_1 := map[string]int{}
	dict_2 := map[string]int{}
	dict_3 := map[string]int{}
	dict_4 := map[string]int{}
	isok1, isok2, isok3, isok4 := 0, 0, 0, 0
	it := sess.DB(save_mgo.DbName).C("bidding").Find(&q).Iter()
	for tmp := make(map[string]interface{}); it.Next(&tmp); total++ {
		if total%10000 == 0 {
			log.Debug("cur index ", total, isok1, isok2, isok3, isok4)
		}
		if isok1 == 500 && isok2 == 500 && isok3 == 500 && isok4 == 500 {
			break
		}
		area := qu.ObjToString(tmp["area"])
		city := qu.ObjToString(tmp["city"])
		detail := qu.ObjToString(tmp["detail"])
		site := qu.ObjToString(tmp["site"])
		if strings.Contains(detail, "地址") {
			if city == "" {
				if area != "全国" {
					if qu.IntAll(dict_1[site]) < 3 && isok1 < 500 {
						dict_1[site] = qu.IntAll(dict_1[site]) + 1
						isok1++
						save_mgo.Save("zktest_exists_addr", tmp)
					}
				} else {
					if qu.IntAll(dict_2[site]) < 3 && isok2 < 500 {
						dict_2[site] = qu.IntAll(dict_2[site]) + 1
						isok2++
						save_mgo.Save("zktest_exists_addr", tmp)
					}
				}
			}
		} else {
			if city == "" {
				if area != "全国" {
					if qu.IntAll(dict_3[site]) < 3 && isok3 < 500 {
						dict_3[site] = qu.IntAll(dict_3[site]) + 1
						isok3++
						save_mgo.Save("zktest_unexists_addr", tmp)
					}
				} else {
					if qu.IntAll(dict_4[site]) < 3 && isok4 < 500 {
						dict_4[site] = qu.IntAll(dict_4[site]) + 1
						isok4++
						save_mgo.Save("zktest_unexists_addr", tmp)
					}
				}
			}
		}

		tmp = make(map[string]interface{})
	}
	log.Debug("is over ...", total, isok1, isok2, isok3, isok4)
}

//大金额数据
func dealWithMuchMoneyData() {
	sess := save_mgo.GetMgoConn()
	defer save_mgo.DestoryMongoConn(sess)
	q, total := map[string]interface{}{}, 0
	it := sess.DB(save_mgo.DbName).C("22222").Find(&q).Iter()
	for tmp := make(map[string]interface{}); it.Next(&tmp); total++ {
		if total%10000 == 0 {
			log.Debug("cur index ", total)
		}
		save_mgo.Save("zkzkzk", map[string]interface{}{
			"_id": StringTOBsonId(qu.ObjToString(tmp["_id"])),
		})
		tmp = make(map[string]interface{})
	}
	log.Debug("is over ...", total)
}

//导出错误中标单位数据
func exportWinnerErrData() {
	elastic.InitElasticSize("http://127.0.0.1:13001", 10)
	//es_data:=*elastic.Get("bidding","bidding",query)
	num := 0
	arr := make([]string, 0)
	for i := 0; i < 2; i++ {
		str := ""
		if i == 0 {
			str = fmt.Sprintf("%d", 0)
		} else {
			str = fmt.Sprintf("%d", i*200+1)
		}
		query := `{"query":{"bool":{"must":[{"term":{"bidding.winner":"注册地在国家级贫困县域内物业公司"}}],"must_not":[],"should":[]}},` + `"from":"` + str + `","size":"200","sort":[],"facets":{},"_source":["_id"]}`
		es_data := *elastic.Get("bidding", "bidding", query)
		log.Debug("当前查询结果：", len(es_data))
		for _, v := range es_data {
			num++
			tmpid := qu.ObjToString(v["_id"])
			arr = append(arr, tmpid)
		}
		if num%1000 == 0 {
			log.Debug("cur index ", num, "~", len(arr))
		}
		if es_data == nil || len(es_data) == 0 {
			break
		}
	}
	log.Debug("is over ", num, "~", len(arr))
	for _, v := range arr {
		save_mgo.Save("1111", map[string]interface{}{
			"bidding_id": v,
		})
	}
}

//导出新标注~数据 字段验证
func exportNewMarkedata() {
	sess := save_mgo.GetMgoConn()
	defer save_mgo.DestoryMongoConn(sess)
	q, total, isok := map[string]interface{}{}, 0, 0
	it := sess.DB(save_mgo.DbName).C("marked_new").Find(&q).Iter()
	key_map, key_arr := map[string]interface{}{
		"area":         1,
		"city":         1,
		"buyer":        1,
		"agency":       1,
		"s_winner":     1,
		"budget":       1,
		"bidamount":    1,
		"projectcode":  1,
		"contractcode": 1,
	}, []string{
		"area",
		"city",
		"buyer",
		"agency",
		"s_winner",
		"budget",
		"bidamount",
		"projectcode",
		"contractcode",
	}
	os.Remove("111111.xlsx")
	f := xlsx.NewFile()
	sheet, _ := f.AddSheet("新标注~验证~")
	row := sheet.AddRow()
	row.AddCell().Value = "唯一标识"
	for i := 0; i < len(key_arr); i++ {
		row.AddCell().Value = key_arr[i]
	}
	row.AddCell().Value = "原文链接"
	row.AddCell().Value = "剑鱼链接"
	for tmp := make(map[string]interface{}); it.Next(&tmp); total++ {
		if total%10000 == 0 {
			log.Debug("cur index ", total, isok)
		}
		v_baseinfo := *qu.ObjToMap(tmp["v_baseinfo"])
		v_taginfo := *qu.ObjToMap(tmp["v_taginfo"])
		dict := map[string]interface{}{}
		for k, v := range v_taginfo {
			if qu.IntAll(v) > 1 && key_map[k] != nil {
				dict[k] = v_baseinfo[k]
			}
		}
		if len(dict) > 0 {
			isok++
			row := sheet.AddRow()
			row.AddCell().Value = BsonTOStringId(tmp["_id"])
			for _, v := range key_arr {
				if v == "budget" || v == "bidamount" {
					if v_baseinfo[v] != nil {
						row.AddCell().SetString(fmt.Sprintf("%f", qu.Float64All(v_baseinfo[v])))
					} else {
						row.AddCell().Value = ""
					}
				} else {
					row.AddCell().Value = qu.ObjToString(v_baseinfo[v])
				}
			}
			row.AddCell().Value = qu.ObjToString(v_baseinfo["href"])
			jyhref := fmt.Sprintf(Url, qu.CommonEncodeArticle("content", BsonTOStringId(tmp["_id"])))
			row.AddCell().Value = jyhref
		}
		tmp = make(map[string]interface{})
	}
	log.Debug("is over ...", total, isok)

	err := f.Save("111111.xlsx")
	if err != nil {
		log.Debug("保存xlsx失败:", err)
		return
	} else {
		log.Debug("保存xlsx成功:", err)
	}

}

//导出当前标签~
func exportTagInfo() {
	sess := save_mgo.GetMgoConn()
	defer save_mgo.DestoryMongoConn(sess)
	q, total, isok := map[string]interface{}{}, 0, 0
	it := sess.DB(save_mgo.DbName).C("zktest_tag_info").Find(&q).Iter()

	for tmp := make(map[string]interface{}); it.Next(&tmp); total++ {
		if total%10000 == 0 {
			log.Debug("cur index ", total, isok)
		}
		content := []string{}
		if list, ok := tmp["content"].(primitive.A); ok {
			content = qu.ObjArrToStringArr(list)
		} else {
			if list, ok := tmp["content"].([]interface{}); ok {
				content = qu.ObjArrToStringArr(list)
			}
		}
		s_name := qu.ObjToString(tmp["s_name"])
		s_field := qu.ObjToString(tmp["s_field"])
		for _, v := range content {
			isok++
			save_mgo.Save("zktest_tag_unique", map[string]interface{}{
				"s_name":  s_name,
				"s_field": s_field,
				"t_name":  v,
			})
		}

		tmp = make(map[string]interface{})
	}
	log.Debug("is over ...", total, isok)
}

//对比数据...
func comparativedata() {
	sess := save_mgo.GetMgoConn()
	defer save_mgo.DestoryMongoConn(sess)
	q, total, isok := map[string]interface{}{}, 0, 0
	it := sess.DB(save_mgo.DbName).C("zktest_alpha_bidding_new").Find(&q).Iter()
	for tmp := make(map[string]interface{}); it.Next(&tmp); total++ {
		if total%10000 == 0 {
			log.Debug("cur index ", total, isok)
		}
		tmpid := BsonTOStringId(tmp["_id"])
		winner := qu.ObjToString(tmp["winner"])
		data := save_mgo.FindById("zktest_alpha_data", tmpid)
		if data != nil && len(data) > 2 {
			winner_ys := qu.ObjToString(data["winner_ys"])
			is_ys := false
			if ys, ok := data["is_ys"].(bool); ok {
				is_ys = ys
			}
			if is_ys && winner == winner_ys {
				isok++
			}
		} else {
			log.Debug("异常~", tmpid)
		}
		tmp = make(map[string]interface{})
	}
	log.Debug("is over ...", total, isok)
}

//对疑似单位打标记
func playtagYswinner() {
	sess := save_mgo.GetMgoConn()
	defer save_mgo.DestoryMongoConn(sess)
	q, total, isok := map[string]interface{}{}, 0, 0
	it := sess.DB(save_mgo.DbName).C("zktest_alpha_data").Find(&q).Iter()
	for tmp := make(map[string]interface{}); it.Next(&tmp); total++ {
		if total%10000 == 0 {
			log.Debug("cur index ", total, isok)
		}
		tmpid := BsonTOStringId(tmp["_id"])
		winner_ys := qu.ObjToString(tmp["winner_ys"])
		data := save_mgo.FindOne("qyxy_std", map[string]interface{}{
			"company_name": winner_ys,
		})
		if data != nil && len(data) > 2 {
			save_mgo.UpdateById("zktest_alpha_data", tmpid, map[string]interface{}{
				"$set": map[string]interface{}{
					"is_ys": true,
				},
			})
			isok++
		}
		tmp = make(map[string]interface{})
	}
	log.Debug("is over ...", total, isok)
}

//导出~正文可能含有的单位数据
func exportAZwinnerdata() {
	sess := save_mgo.GetMgoConn()
	defer save_mgo.DestoryMongoConn(sess)
	q, total, isok := map[string]interface{}{
		"_id": map[string]interface{}{
			"$lt": StringTOBsonId("626d5d000000000000000000"),
		},
	}, 0, 0
	it := sess.DB(save_mgo.DbName).C("bidding").Find(&q).Sort("-_id").Select(map[string]interface{}{
		"subtype": 1,
		"detail":  1,
		"winner":  1,
	}).Iter()
	var reg_str = regexp.MustCompile("[\u4E00-\u9FA5]{1,10}[A-Za-z]{1,5}[\u4E00-\u9FA5]{1,10}(公司|集团|单位|机构|企业|厂|场|院|所|店|中心|市|局|站|城|处|行|部|队|联合[会|体])")
	for tmp := make(map[string]interface{}); it.Next(&tmp); total++ {
		if total%10000 == 0 {
			log.Debug("cur index ", total, isok)
		}
		subtype := qu.ObjToString(tmp["subtype"])
		detail := qu.ObjToString(tmp["detail"])
		winner := qu.ObjToString(tmp["winner"])
		tmpid := BsonTOStringId(tmp["_id"])
		if (subtype == "中标" || subtype == "成交" || subtype == "合同" || subtype == "单一") &&
			winner != "" {
			str := reg_str.FindString(detail)
			if str != "" {
				if isHeadWordEqual(winner, str) {
					total, hit := dealWithWordsRules(winner, str)
					if hit >= total/2 {
						isok++
						log.Debug(tmpid, "~", str, "~", winner)
						save_mgo.Save("zktest_alpha_data", map[string]interface{}{
							"_id":       tmp["_id"],
							"winner":    winner,
							"winner_ys": str,
						})
					}
				}
			}
		}
		tmp = make(map[string]interface{})
	}
	log.Debug("is over ...", total, isok)
}

//计算首部词语是否一致
func isHeadWordEqual(a string, b string) bool {
	namea, nameb := []rune(a), []rune(b)
	new_a := string(namea[:2])
	new_b := string(nameb[:2])
	if new_a == new_b {
		return true
	}
	return false
}

//击中数量以及比例
func dealWithWordsRules(info_name string, source_name string) (int, int) {
	total, hit := 0, 0
	nameArr, _ := calculateWordCount(info_name)
	_, total = calculateWordCount(source_name)
	for _, v1 := range nameArr {
		if strings.Contains(source_name, v1) {
			hit++
		}
	}
	return total, hit
}

//分词结果
func calculateWordCount(name string) ([]string, int) {
	arr, space := make([]string, 0), 2
	total := utf8.RuneCountInString(name) - (space - 1)
	if name == "" || total <= 0 {
		return arr, 0
	}
	nameRune := []rune(name)
	for i := 0; i < total; i++ {
		new_str := string(nameRune[i : space+i])
		arr = append(arr, new_str)
	}
	return arr, len(arr)
}

//更新大金额数据~
func updateToMuchMoneyData() {
	sess := save_mgo.GetMgoConn()
	defer save_mgo.DestoryMongoConn(sess)
	q, total, isok := map[string]interface{}{}, 0, 0
	it := sess.DB(save_mgo.DbName).C("20220406_bidamount_data").Find(&q).Sort("_id").Iter()

	for tmp := make(map[string]interface{}); it.Next(&tmp); total++ {
		if total%10000 == 0 {
			log.Debug("cur index ", total, isok)
		}
		p_list := []string{}
		if list, ok := tmp["data_flag_list"].(primitive.A); ok {
			p_list = qu.ObjArrToStringArr(list)
		} else {
			if list, ok := tmp["data_flag_list"].([]interface{}); ok {
				p_list = qu.ObjArrToStringArr(list)
			}
		}
		if isConformWrong(p_list) {
			bidamount := qu.Float64All(tmp["bidamount"])
			new_bidamount := bidamount / float64(10000)
			save_mgo.Save("00000", map[string]interface{}{
				"bidamount": new_bidamount,
				"_id":       StringTOBsonId(qu.ObjToString(tmp["_id"])),
			})
			isok++
		}

		tmp = make(map[string]interface{})
	}
	log.Debug("is over ...", total, isok)
}

func isConformWrong(arr []string) bool {
	if len(arr) > 0 {
		for _, v := range arr {
			if v == "wrong_2" || v == "wrong_3" || v == "wrong_4" {

			} else {
				return false
			}
		}
		return true
	}
	return false
}

//导出新版标注数据
func exportMarkNewData() {
	sess := save_mgo.GetMgoConn()
	defer save_mgo.DestoryMongoConn(sess)
	q, total, isok := map[string]interface{}{
		"comeintime": map[string]interface{}{
			"$gte": 1653494400,
			"$lt":  1653580800,
		},
		"publishtime": map[string]interface{}{
			"$gte": 1653494400,
			"$lt":  1653580800,
		},
	}, 0, 0
	limit := 500
	dict := make(map[string]map[string]interface{}, 0)
	log.Debug("准备遍历数据...")
	it := sess.DB(save_mgo.DbName).C("result_20220219").Find(&q).Select(map[string]interface{}{
		"site":    1,
		"subtype": 1,
		"toptype": 1,
		"repeat":  1,
	}).Sort("-_id").Iter()
	for tmp := make(map[string]interface{}); it.Next(&tmp); total++ {
		if total%10000 == 0 {
			log.Debug("cur index ", total, isok)
			s := ""
			s1 := ""
			for k, v := range dict {
				if len(v) <= limit {
					s1 += k + ","
				} else {
					s += k + ","
				}
			}
			log.Debug("满足~", s)
			log.Debug("不满足~", s1)
		}
		repeat := qu.IntAll(tmp["repeat"])
		if repeat == 1 {
			tmp = make(map[string]interface{})
			continue
		}
		tmpid := BsonTOStringId(tmp["_id"])
		subtype := qu.ObjToString(tmp["subtype"])
		toptype := qu.ObjToString(tmp["toptype"])
		site := qu.ObjToString(tmp["site"])
		if toptype == "招标" || subtype == "中标" || subtype == "成交" || subtype == "合同" {
			isNext := true
			if subtype == "招标" || subtype == "中标" || subtype == "竞谈" || subtype == "成交" {
				if total%3 != 0 {
					isNext = false
				}
			}
			if isNext {
				if dict[subtype] == nil { //无数据
					dict[subtype] = map[string]interface{}{
						site: tmpid,
					}
					isok++
					save_mgo.Save("zktest_data", map[string]interface{}{
						"_id": tmp["_id"],
					})
				} else {
					d := dict[subtype]
					if d[site] == nil && len(d) <= limit {
						d[site] = tmpid
						dict[subtype] = d
						isok++
						save_mgo.Save("zktest_data", map[string]interface{}{
							"_id": tmp["_id"],
						})
					}
				}
			}

		}

		if isok > 10000 {
			log.Debug("超过限制~结束")
			break
		}
		tmp = make(map[string]interface{})
	}
	log.Debug("is over ...", total, isok)

	for k, v := range dict {
		log.Debug(k, "~", len(v))
	}

}

//分析中标单位 不同数据
func fenxiDiffWinnerData() {
	sess := save_mgo.GetMgoConn()
	defer save_mgo.DestoryMongoConn(sess)
	q, total, isok := map[string]interface{}{}, 0, 0
	it := sess.DB(save_mgo.DbName).C("222222").Find(&q).Iter()
	for tmp := make(map[string]interface{}); it.Next(&tmp); total++ {
		if total%10000 == 0 {
			log.Debug("cur index ", total, isok)
		}
		tmpid := BsonTOStringId(tmp["_id"])
		winner := qu.ObjToString(tmp["winner"])

		data := save_mgo.FindById("111111", tmpid)
		if data != nil && len(data) > 2 {
			if winner != qu.ObjToString(data["winner"]) {
				isok++

				save_mgo.Save("333333", map[string]interface{}{
					"_id":         tmp["_id"],
					"new_winner":  winner,
					"old_winner":  qu.ObjToString(data["winner"]),
					"href":        tmp["href"],
					"jytest_href": tmp["jytest_href"],
				})
			}
		} else {
			log.Debug("异常...", tmp["_id"])
		}

		tmp = make(map[string]interface{})
	}
	log.Debug("is over ...", total, isok)
}

func update0519Data() {
	sess := save_mgo.GetMgoConn()
	defer save_mgo.DestoryMongoConn(sess)
	q, total, isok := map[string]interface{}{}, 0, 0
	it := sess.DB(save_mgo.DbName).C("a_repair_bidding_data_new").Find(&q).Iter()
	for tmp := make(map[string]interface{}); it.Next(&tmp); total++ {
		if total%10000 == 0 {
			log.Debug("cur index ", total)
		}
		update := map[string]interface{}{}
		if tmp["bidamount"] != nil {
			update["bidamount"] = tmp["bidamount"]
		}
		if tmp["biddiscount"] != nil {
			update["biddiscount"] = tmp["biddiscount"]
		}

		if len(update) > 0 {
			isok++
			python_mgo.UpdateQueryData("20220505Hs_kcsj", map[string]interface{}{
				"id": BsonTOStringId(tmp["_id"]),
			}, map[string]interface{}{
				"$set": update,
			})
		}

		tmp = make(map[string]interface{})
	}
	log.Debug("is over ...", total, isok)
}

//导出空数据
func exportBidamountKongData() {
	sess := save_mgo.GetMgoConn()
	defer save_mgo.DestoryMongoConn(sess)
	q, total := map[string]interface{}{}, 0
	dict := map[string]interface{}{}
	it := sess.DB(save_mgo.DbName).C("111111111").Find(&q).Iter()
	for tmp := make(map[string]interface{}); it.Next(&tmp); total++ {
		if total%10000 == 0 {
			log.Debug("cur index ", total)
		}
		site := qu.ObjToString(tmp["site"])
		if dict[site] != nil {
			num := qu.IntAll(dict[site]) + 1
			dict[site] = num
		} else {
			dict[site] = 1
		}
		tmp = make(map[string]interface{})
	}
	log.Debug("is over buyer...", total)
	rankArr := []int{}
	siteArr := []string{}
	for k, v := range dict {
		siteArr = append(siteArr, k)
		rankArr = append(rankArr, qu.IntAll(v))
	}
	rankArr, siteArr = preMethodSort(rankArr, siteArr)
	log.Debug(len(rankArr), len(siteArr))
	for k, v := range rankArr {
		save_mgo.Save("aaaaaa", map[string]interface{}{
			"rank":  k + 1,
			"total": v,
			"site":  siteArr[k],
		})
	}

}

func preMethodSort(slice []int, site []string) ([]int, []string) {
	for n := 0; n <= len(slice); n++ {
		for i := 1; i < len(slice)-n; i++ {
			if slice[i] > slice[i-1] {
				slice[i], slice[i-1] = slice[i-1], slice[i]
				site[i], site[i-1] = site[i-1], site[i]
			}
		}
	}
	return slice, site
}

//更新
func updateBuyerCGYX() {
	sess := save_mgo.GetMgoConn()
	defer save_mgo.DestoryMongoConn(sess)
	q, total, isok := map[string]interface{}{}, 0, 0
	it := sess.DB(save_mgo.DbName).C("aaaaaaa").Find(&q).Select(map[string]interface{}{
		"buyer": 1,
	}).Iter()
	for tmp := make(map[string]interface{}); it.Next(&tmp); total++ {
		if total%10000 == 0 {
			log.Debug("cur index ", total, isok)
		}
		tmpid := BsonTOStringId(tmp["_id"])
		buyer := qu.ObjToString(tmp["buyer"])
		if buyer != "" {
			save_mgo.UpdateById("20220514_Rj_bidding", tmpid, map[string]interface{}{
				"$set": map[string]interface{}{
					"buyer": buyer,
				},
			})
		}
		tmp = make(map[string]interface{})
	}
	log.Debug("is over buyer...", total, isok)
}

//处理错误异常数据...
func dealWithErrWordata() {

	str_arr := qu.ObjArrToStringArr(sysconfig["rp_blacklist"].([]interface{}))
	strs := strings.Join(str_arr, "|")
	strs = "(" + strs + ")"
	var reg = regexp.MustCompile(strs)

	sess := save_mgo.GetMgoConn()
	defer save_mgo.DestoryMongoConn(sess)
	q, total := map[string]interface{}{}, 0
	is_err := 0

	dict := map[string][]string{}
	it := sess.DB(save_mgo.DbName).C("winner_err").Find(&q).Sort("_id").Iter()
	for tmp := make(map[string]interface{}); it.Next(&tmp); total++ {
		if total%10000 == 0 {
			log.Debug("cur index ", total, is_err)
		}
		name := qu.ObjToString(tmp["name"])
		s := reg.FindString(name)
		if s != "" {
			//log.Debug(reg.FindString(name),"~",name)
			if dict[s] == nil {
				dict[s] = []string{name}
			} else {
				arr := dict[s]
				arr = append(arr, name)
				dict[s] = arr
			}
			is_err++
		}
		tmp = make(map[string]interface{})
	}

	for k, v := range dict {
		save_mgo.Save("winner_err_data", map[string]interface{}{
			"word": k,
			"name": v,
		})
	}

	log.Debug(len(dict))
	log.Debug("is over ", total, is_err)

}

func exportNewCityFieldData() {
	sess := save_mgo.GetMgoConn()
	defer save_mgo.DestoryMongoConn(sess)
	q, total := map[string]interface{}{
		"_id": map[string]interface{}{
			"$lte": StringTOBsonId("6245d0000000000000000000"),
		},
	}, 0
	isok := 0
	site_data := map[string]int{}
	it := sess.DB(save_mgo.DbName).C("bidding").Find(&q).Sort("-_id").Iter()
	for tmp := make(map[string]interface{}); it.Next(&tmp); total++ {
		if total%10000 == 0 {
			log.Debug("cur index ", total, isok)
		}
		site := qu.ObjToString(tmp["site"])
		area := qu.ObjToString(tmp["area"])
		city := qu.ObjToString(tmp["city"])
		if area != "全国" && area != "" && city == "" {
			num := qu.IntAll(site_data[site]) + 1
			if num < 10 {
				site_data[site] = num
				isok++
				save_mgo.Save("zktest_city_field_test", tmp)
			}
		}
		if isok >= 1000 {
			break
		}
		tmp = make(map[string]interface{})
	}
	log.Debug("is over ", total, isok)

}

//导出-bidding-新字段数据
func exportNewFieldData() {
	sess := save_mgo.GetMgoConn()
	defer save_mgo.DestoryMongoConn(sess)
	q, total := map[string]interface{}{
		"_id": map[string]interface{}{
			"$lte": StringTOBsonId("61cf29000000000000000000"),
		},
	}, 0
	isok := 0
	var reg_str = regexp.MustCompile("(递交开始)")

	it := sess.DB(save_mgo.DbName).C("bidding").Find(&q).Sort("-_id").Iter()
	for tmp := make(map[string]interface{}); it.Next(&tmp); total++ {
		if total%10000 == 0 {
			log.Debug("cur index ", total, isok)
		}
		toptype := qu.ObjToString(tmp["toptype"])
		if toptype != "招标" {
			tmp = make(map[string]interface{})
			continue
		}
		detail := qu.ObjToString(tmp["detail"])
		if reg_str.MatchString(detail) {
			isok++
			save_mgo.Save("zktest_extract_field", tmp)
		}
		if isok >= 200 {
			break
		}
		tmp = make(map[string]interface{})
	}
	log.Debug("is over ", total, isok)

}

//万倍金额标记
func isMarkMuchMoney() {
	var reg1 = regexp.MustCompile("0000.000000$")
	sess := save_mgo.GetMgoConn()
	defer save_mgo.DestoryMongoConn(sess)
	q, total := map[string]interface{}{}, 0
	isok := 0
	it := sess.DB(save_mgo.DbName).C("20220406_bidamount_data").Find(&q).Select(map[string]interface{}{
		"bidamount": 1,
	}).Iter()
	for tmp := make(map[string]interface{}); it.Next(&tmp); total++ {
		if total%1000 == 0 {
			log.Debug("cur index ", total, isok)
		}
		bidamount := qu.Float64All(tmp["bidamount"])
		money_str := fmt.Sprintf("%f", bidamount)
		if reg1.MatchString(money_str) {
			isok++
			save_mgo.UpdateStrId("20220406_bidamount_data", qu.ObjToString(tmp["_id"]), map[string]interface{}{
				"$set": map[string]interface{}{
					"is_wan": 1,
				},
			})
		}
		tmp = make(map[string]interface{})
	}
	log.Debug("is over ", total, isok)

}

//导出模板数据
func expMoBanShuJu() {
	sess := save_mgo.GetMgoConn()
	defer save_mgo.DestoryMongoConn(sess)
	q, total := map[string]interface{}{}, 0
	ok_1, ok_2 := 0, 0
	it := sess.DB(save_mgo.DbName).C("zktest_marked").Find(&q).Iter()
	for tmp := make(map[string]interface{}); it.Next(&tmp); total++ {
		if total%1000 == 0 {
			log.Debug("cur index ", total, ok_1, ok_2)
		}
		if total%3 != 0 {
			tmp = make(map[string]interface{})
			continue
		}
		//预计1200  4800拉取数据
		ck_buyer := qu.Int64All(tmp["ck_buyer"])
		ck_s_winner := qu.Int64All(tmp["ck_s_winner"])
		ck_agency := qu.Int64All(tmp["ck_agency"])
		ck_budget := qu.Int64All(tmp["ck_budget"])
		ck_bidamount := qu.Int64All(tmp["ck_bidamount"])
		if ck_buyer > 1 || ck_s_winner > 1 || ck_agency > 1 || ck_budget > 1 || ck_bidamount > 1 {
			ok_1++
			save_mgo.Save("zktest_ext_example", tmp)
		} else {
			ok_2++
			save_mgo.Save("zktest_ext_example", tmp)
		}

		tmp = make(map[string]interface{})
	}
	log.Debug("is over ", total, ok_1, ok_2)
}

//修复城市数据
func repairExtCity() {
	sess := save_mgo.GetMgoConn()
	defer save_mgo.DestoryMongoConn(sess)
	q, total := map[string]interface{}{}, 0
	ok_1, ok_2 := 0, 0
	it := sess.DB("qfw").C("zktest_yixintong_info_new").Find(&q).Select(map[string]interface{}{
		"area":     1,
		"city":     1,
		"district": 1,
	}).Iter()
	for tmp := make(map[string]interface{}); it.Next(&tmp); total++ {
		if total%1000 == 0 {
			log.Debug("cur index ", total, ok_1, ok_2)
		}
		tmpid := BsonTOStringId(tmp["_id"])
		new_area := qu.ObjToString(tmp["area"])
		new_city := qu.ObjToString(tmp["city"])
		new_district := qu.ObjToString(tmp["district"])
		data_1 := save_mgo.FindById("result_20220218", tmpid)
		if data_1 != nil && len(data_1) > 2 {
			ok_1++
			save_mgo.UpdateById("result_20220218", tmpid, map[string]interface{}{
				"$set": map[string]interface{}{
					"area":     new_area,
					"city":     new_city,
					"district": new_district,
				},
			})
		}
		data_2 := save_mgo.FindById("result_20220219", tmpid)
		if data_2 != nil && len(data_2) > 2 {
			ok_2++
			save_mgo.UpdateById("result_20220219", tmpid, map[string]interface{}{
				"$set": map[string]interface{}{
					"area":     new_area,
					"city":     new_city,
					"district": new_district,
				},
			})
		}
		tmp = make(map[string]interface{})
	}
	log.Debug("is over ", total, ok_1, ok_2)
}

func repairRepeatData0308() {
	sess := save_mgo.GetMgoConn()
	defer save_mgo.DestoryMongoConn(sess)
	q, total := map[string]interface{}{}, 0
	ok_1, ok_2 := 0, 0
	it := sess.DB("qfw").C("zktest_repeat_test").Find(&q).Iter()
	for tmp := make(map[string]interface{}); it.Next(&tmp); total++ {
		if total%1000 == 0 {
			log.Debug("cur index ", total, ok_1, ok_2)
		}

		tmpid := BsonTOStringId(tmp["_id"])
		repeat_id := qu.ObjToString(tmp["repeat_id"])
		repeat_reason := qu.ObjToString(tmp["repeat_reason"])

		bidding_data := python_mgo.FindById("bidding", tmpid)
		if bidding_data != nil && len(bidding_data) > 2 {
			publishtime := qu.Int64All(bidding_data["publishtime"])
			data_1 := save_mgo.FindById("result_20220218", tmpid)
			if data_1 != nil && len(data_1) > 2 {
				if publishtime < 0 {
					log.Debug(tmpid)
					ok_1++
					save_mgo.UpdateById("result_20220218", tmpid, map[string]interface{}{
						"$set": map[string]interface{}{
							"repeat":        1,
							"repeat_id":     repeat_id,
							"repeat_reason": repeat_reason,
							"publishtime":   publishtime,
						},
					})
				}
			}
			data_2 := save_mgo.FindById("result_20220219", tmpid)
			if data_2 != nil && len(data_2) > 2 {
				if publishtime < 0 {
					log.Debug(tmpid)
					ok_2++
					save_mgo.UpdateById("result_20220219", tmpid, map[string]interface{}{
						"$set": map[string]interface{}{
							"repeat":        1,
							"repeat_id":     repeat_id,
							"repeat_reason": repeat_reason,
							"publishtime":   publishtime,
						},
					})
				}
			}
		} else {
			log.Debug("异常-需要处理...", tmpid)
			//data_1 := save_mgo.FindById("result_20220218",tmpid)
			//if data_1!=nil && len(data_1)>2  {
			//	save_mgo.DeleteById("result_20220218",tmpid)
			//}
			//data_2 := save_mgo.FindById("result_20220219",tmpid)
			//if data_2!=nil && len(data_2)>2 {
			//	save_mgo.DeleteById("result_20220219",tmpid)
			//}
		}

		tmp = make(map[string]interface{})
	}

	log.Debug("is over ", total, ok_1, ok_2)

}

//修复抽取数据
func addCityXinXingExt() {
	/*
			"code" : "650109004002",
		    "pcode" : "650109004",
		    "province" : "新疆",
		    "city" : "乌鲁木齐市",
		    "district" : "米东区",
		    "town" : "古牧地东路街道",
		    "village" : "北苑社区居委会"
	*/
	sess := save_mgo.GetMgoConn()
	defer save_mgo.DestoryMongoConn(sess)
	q, total := map[string]interface{}{}, 0
	it := sess.DB("mixdata").C("111222").Find(&q).Sort("_id").Iter()
	for tmp := make(map[string]interface{}); it.Next(&tmp); total++ {
		province := qu.ObjToString(tmp["province"])
		city := qu.ObjToString(tmp["city"])
		district := qu.ObjToString(tmp["district"])
		town := qu.ObjToString(tmp["town"])
		village := qu.ObjToString(tmp["village"])

		city_code := fmt.Sprintf("%d", qu.IntAll(tmp["city_code"]))
		district_code := fmt.Sprintf("%d", qu.IntAll(tmp["district_code"]))
		town_code := fmt.Sprintf("%d", qu.IntAll(tmp["town_code"]))
		village_code := fmt.Sprintf("%d", qu.IntAll(tmp["village_code"]))

		data := map[string]interface{}{}
		data["province"] = province
		data["city"] = city
		data["district"] = district

		if village != "" { //五级
			data["town"] = town
			data["village"] = village
			data["code"] = village_code
			data["pcode"] = town_code
		} else {
			if town != "" { //四级
				data["town"] = town
				data["code"] = town_code
				data["pcode"] = district_code
			} else {
				if city != "" { //三级
					data["code"] = district_code
					data["pcode"] = city_code
				} else {
					log.Debug("异常")
				}
			}
		}

		tmp = make(map[string]interface{})
	}

	log.Debug("is over ", total)
}

//copy数据 2022-02-19之后
func repairCopyNextData() {
	sess := save_mgo.GetMgoConn()
	defer save_mgo.DestoryMongoConn(sess)
	q := map[string]interface{}{
		"_id": map[string]interface{}{
			"$lte": StringTOBsonId("621508800000000000000000"),
		},
	}
	log.Debug("查询条件~", q)
	total, isok := 0, 0
	repair_pool := make(chan bool, 10)
	repair_wg := &sync.WaitGroup{}
	it := sess.DB("qfw").C("result_20220218").Find(&q).Sort("_id").Iter()
	for tmp := make(map[string]interface{}); it.Next(&tmp); total++ {
		if total%10000 == 0 {
			log.Debug("curent index ", total, isok, tmp["_id"])
		}
		repair_pool <- true
		repair_wg.Add(1)
		go func(tmp map[string]interface{}) {
			defer func() {
				<-repair_pool
				repair_wg.Done()
			}()
			tmpid := BsonTOStringId(tmp["_id"])
			update_dict := map[string]interface{}{}
			data := save_mgo.FindById("result_20210108", tmpid)
			if data != nil && len(data) > 2 {
				if data["buyerclass"] != nil {
					update_dict["buyerclass"] = data["buyerclass"]
				}
				if data["subscopeclass"] != nil {
					update_dict["subscopeclass"] = data["subscopeclass"]
				}
				if data["topscopeclass"] != nil {
					update_dict["topscopeclass"] = data["topscopeclass"]
				}

				if len(update_dict) > 0 {
					isok++
					save_mgo.UpdateById("result_20220218", tmpid, map[string]interface{}{
						"$set": update_dict,
					})
				} else {
					//log.Debug("未分类~~",tmpid)
				}
			} else {
				//log.Debug("未关联~~",tmpid)
			}
		}(tmp)
		tmp = make(map[string]interface{})
	}
	repair_wg.Wait()
	log.Debug("is copy over ", total, isok)

}

//补-标的物数据
func consummatePurlist() {
	sess := save_mgo.GetMgoConn()
	defer save_mgo.DestoryMongoConn(sess)
	q, total := map[string]interface{}{}, 0

	it := sess.DB("qfw").C("zktest_cgyx_data").Find(&q).Sort("_id").Iter()
	for tmp := make(map[string]interface{}); it.Next(&tmp); total++ {
		if total%1000 == 0 {
			log.Debug("curent index ", total, tmp["_id"])
		}
		tttid := qu.ObjToString(tmp["id"])
		data := save_mgo.FindById("bidding", tttid)

		if data == nil || len(data) < 2 {
			log.Debug("异常", tttid)
		} else {
			updateid := BsonTOStringId(tmp["_id"])
			save_mgo.UpdateById("zktest_cgyx_data", updateid, map[string]interface{}{
				"$set": map[string]interface{}{
					"purchasinglist": data["purchasinglist"],
				},
			})
		}
		tmp = make(map[string]interface{})
	}

	log.Debug("is set bdw over ", total)
}

//敏感词修复标记
func repairSensitiveTag() {

	//从11月30号开始  61a4f9000000000000000000
	sess := save_mgo.GetMgoConn()
	defer save_mgo.DestoryMongoConn(sess)
	q := map[string]interface{}{
		"_id": map[string]interface{}{
			"$gte": StringTOBsonId("620fc2800000000000000000"),
			"$lte": StringTOBsonId("620fd0900000000000000000"),
		},
	}
	total, isok1, isok2 := 0, 0, 0
	it := sess.DB("qfw").C("result_20210108").Find(&q).Sort("_id").Iter()
	//多线程处理
	repair_pool := make(chan bool, 1)
	repair_wg := &sync.WaitGroup{}
	for tmp := make(map[string]interface{}); it.Next(&tmp); total++ {
		if total%10000 == 0 {
			log.Debug("curent index ", total, tmp["_id"], isok1, isok2)
		}
		repair_pool <- true
		repair_wg.Add(1)
		go func(tmp map[string]interface{}) {
			defer func() {
				<-repair_pool
				repair_wg.Done()
			}()

			tmpid := BsonTOStringId(tmp["_id"])
			if tmp["log"] != nil {
				isok1++
				data := save_mgo.FindById("result_20220218", tmpid)
				if data != nil && len(data) > 2 {
					log_dict := *qu.ObjToMap(tmp["log"])
					if len(log_dict) > 0 {
						isok2++
						update_dict := map[string]interface{}{}
						for k, _ := range log_dict {
							update_dict[k] = qu.ObjToString(tmp[k])
						}
						update_dict["log"] = log_dict

						save_mgo.UpdateById("result_20220218", tmpid, map[string]interface{}{
							"$set": update_dict,
						})
					}
				} else {
					log.Debug("异常-未查询到数据", tmp["_id"])
				}
			}
		}(tmp)

		tmp = make(map[string]interface{})
	}
	repair_wg.Wait()
	log.Debug("is sensitive over ", total, isok1, isok2)

}

//修复重复标记
func repairRepeatTag() {
	sess := save_mgo.GetMgoConn()
	defer save_mgo.DestoryMongoConn(sess)
	q := map[string]interface{}{
		"_id": map[string]interface{}{
			"$gte": StringTOBsonId("620fc2800000000000000000"),
			"$lte": StringTOBsonId("620fd0900000000000000000"),
		},
	}
	total := 0
	it := sess.DB("qfw").C("result_20220218").Find(&q).Sort("_id").Select(map[string]interface{}{
		"_id": 1,
	}).Iter()

	//多线程处理
	repair_pool := make(chan bool, 5)
	repair_wg := &sync.WaitGroup{}
	for tmp := make(map[string]interface{}); it.Next(&tmp); total++ {
		if total%10000 == 0 {
			log.Debug("curent index ", total, tmp["_id"])
		}
		tmpid := BsonTOStringId(tmp["_id"])
		repair_pool <- true
		repair_wg.Add(1)
		go func(tmpid string) {
			defer func() {
				<-repair_pool
				repair_wg.Done()
			}()

			data := save_mgo.FindById("result_20210108", tmpid)
			if data != nil && len(data) > 2 {
				repeat := qu.IntAll(data["repeat"])
				if repeat == 1 {
					update := map[string]interface{}{
						"repeat": 1,
					}
					if data["repeat_id"] != "" {
						update["repeat_id"] = data["repeat_id"]
					}
					if data["repeat_reason"] != "" {
						update["repeat_reason"] = data["repeat_reason"]
					}
					save_mgo.UpdateById("result_20220218", tmpid, map[string]interface{}{
						"$set": update,
					})
				} else {
					if data["repeat_ids"] != nil {
						save_mgo.UpdateById("result_20220218", tmpid, map[string]interface{}{
							"$set": map[string]interface{}{
								"repeat_ids": data["repeat_ids"],
							},
						})
					}
				}
			}
		}(tmpid)

		tmp = make(map[string]interface{})
	}
	repair_wg.Wait()
	log.Debug("is city over ", total)

}

//统计医疗器械数据
func tongjiYLQX() {
	//ylhydata
	sess := save_mgo.GetMgoConn()
	defer save_mgo.DestoryMongoConn(sess)
	q, total := map[string]interface{}{}, 0
	ok1, ok2, ok3 := 0, 0, 0
	it := sess.DB("qfw").C("ylhydata").Find(&q).Sort("_id").Iter()
	for tmp := make(map[string]interface{}); it.Next(&tmp); total++ {
		if total%10000 == 0 {
			log.Debug("curent index ", total, "~", ok1, ok2, ok3)
		}
		p_list := []map[string]interface{}{}
		yl_list := []map[string]interface{}{}
		if purchasinglist, ok := tmp["purchasinglist"].(primitive.A); ok {
			p_list = qu.ObjArrToMapArr(purchasinglist)
		} else {
			if purchasinglist, ok := tmp["purchasinglist"].([]interface{}); ok {
				p_list = qu.ObjArrToMapArr(purchasinglist)
			}
		}
		if yl_purchasinglist, ok := tmp["yl_purchasinglist"].(primitive.A); ok {
			yl_list = qu.ObjArrToMapArr(yl_purchasinglist)
		} else {
			if yl_purchasinglist, ok := tmp["yl_purchasinglist"].([]interface{}); ok {
				yl_list = qu.ObjArrToMapArr(yl_purchasinglist)
			}
		}

		if len(yl_list) > 0 {
			ok1++
		}
		ok2 += len(p_list)
		ok3 += len(yl_list)
		tmp = make(map[string]interface{})
	}

	log.Debug("is bidding over ", total, ok1, ok2, ok3)

}

//处理新疆兵团数据
func dealWithBingTuanData() {
	f, err := os.Open("1.txt")
	if err != nil {

	}
	defer f.Close()
	rd := bufio.NewReader(f)
	total := 0
	isHead := false
	savedata := map[string]interface{}{}
	for {
		total++
		line, err := rd.ReadString('\n') //以'\n'为结束符读入一行
		if err != nil || io.EOF == err {
			break
		}
		if line == "\n" {
			isHead = true
			continue
		}
		line = strings.ReplaceAll(line, "\n", "")
		strArr := strings.Split(line, "，")

		if isHead {
			if len(savedata) > 2 {
				save_mgo.Save("111", savedata)
			}
			savedata = map[string]interface{}{}
			pre1 := "新疆生产建设兵团" + strArr[0]
			pre2 := "新疆生产建设兵团" + strArr[1]
			isHead = false
			savedata["name"] = pre1
			savedata["alias"] = pre2
			savedata["area"] = "新疆"
			savedata["city"] = strArr[2]
			savedata["district"] = strArr[3]
		} else {
			list := []map[string]interface{}{}
			if res, ok := savedata["list"].([]map[string]interface{}); ok {
				list = res
			}
			list = append(list, map[string]interface{}{
				"name":     strArr[0],
				"area":     "新疆",
				"city":     strArr[1],
				"district": strArr[2],
			})
			savedata["list"] = list
		}
	}

	if len(savedata) > 2 {
		save_mgo.Save("area_xjbt", savedata)
	}
	log.Debug("总计", total, "行")
}

//导出相关数据
func exporToptypeRealData() {
	os.Remove("类别字段统计.xlsx")
	f := xlsx.NewFile()
	//招标 结果 其它
	classArr := []string{
		"招标",
		"结果",
		"其它",
	}
	//准确率-比对-个站点-相关准确率统计
	fieldArr := []string{
		"projectname",
		"projectcode",
		"area",
		"city",
		"district",
		"budget",
		"bidamount",
		"buyer",
		"agency",
		"s_winner",
		"winnerperson",
		"winnertel",
		"winneraddr",
		"agencyperson",
		"agencytel",
		"agencyaddr",
		"buyerperson",
		"buyertel",
		"buyeraddr",
		"projectscope",
	}
	fieldCh_AnArr := []string{
		"项目名称",
		"项目编号",
		"省份",
		"城市",
		"区县",
		"预算",
		"中标金额",
		"采购单位",
		"代理机构",
		"中标单位",
		"中标联系人",
		"中标联系人电话",
		"中标联系人地址",
		"代理机构联系人",
		"代理机构联系人电话",
		"代理机构联系人地址",
		"采购单位联系人",
		"采购单位联系人电话",
		"采购单位联系人地址",
		"项目范围",
	}
	sess := save_mgo.GetMgoConn()
	defer save_mgo.DestoryMongoConn(sess)
	q, total := map[string]interface{}{}, 0
	tagDict := map[string]map[string]interface{}{}
	it := sess.DB(save_mgo.DbName).C("f_sourceinfo_extract").Find(&q).Select(map[string]interface{}{
		"v_baseinfo": 1,
		"v_taginfo":  1,
	}).Iter()
	for tmp := make(map[string]interface{}); it.Next(&tmp); total++ {
		if total%1000 == 0 {
			log.Debug("curent index ", total)
		}
		v_baseinfo := *qu.ObjToMap(tmp["v_baseinfo"])
		toptype := qu.ObjToString(v_baseinfo["toptype"])
		v_taginfo := *qu.ObjToMap(tmp["v_taginfo"])

		dictInfo := map[string]interface{}{}
		if tagDict[toptype] != nil {
			dictInfo = tagDict[toptype]
		}
		for _, field := range fieldArr {
			info := map[string]interface{}{}
			if dictInfo[field] != nil {
				info = *qu.ObjToMap(dictInfo[field])
			}
			ok, err, all := qu.IntAll(info["ok"]), qu.IntAll(info["err"]), qu.IntAll(info["all"])
			if qu.IntAll(v_taginfo[field]) == 1 {
				ok++
			} else {
				err++
			}
			all++
			dictInfo[field] = map[string]interface{}{
				"ok":  ok,
				"err": err,
				"all": all,
			}
		}
		tagDict[toptype] = dictInfo
		tmp = make(map[string]interface{})
	}

	for _, v := range classArr {
		infoData := tagDict[v]
		str := v + "统计"
		sheet, _ := f.AddSheet(str)
		row := sheet.AddRow()
		row.AddCell().Value = "字段"
		row.AddCell().Value = "正确数"
		row.AddCell().Value = "错误数"
		row.AddCell().Value = "准确率"
		for index, field := range fieldArr {
			info := *qu.ObjToMap(infoData[field])
			row = sheet.AddRow()
			row.AddCell().Value = fieldCh_AnArr[index]
			ok, err := qu.IntAll(info["ok"]), qu.IntAll(info["err"])
			all := ok + err
			row.AddCell().Value = fmt.Sprintf("%d", ok)
			row.AddCell().Value = fmt.Sprintf("%d", err)
			str := fmt.Sprintf("%.2f", 100*qu.Float64All(ok)/qu.Float64All(all))
			row.AddCell().Value = str + "%"
		}
	}
	f.Save("类别字段统计.xlsx")
}

//导出相关数据
func exportNumberSiteData() {
	//招标 结果 其它
	siteArr := []string{
		"国家公共资源交易平台",
		"中国政府采购网",
		"广东省政府采购网",
		"中国招标投标公共服务平台",
		"湖南省政府采购电子卖场",
		"中国山东政府采购网",
		"湖北省政府采购网",
		"浙江政府采购网",
		"中国华能集团公司",
		"河南省政府采购网",
		"广西壮族自治区政府采购网",
		"四川政府采购",
		"基建云采购",
		"中国电信阳光采购网",
		"中国大唐集团公司电子商务平台",
		"新疆维吾尔自治区政府采购网",
		"机电产品招标投标电子交易平台",
		"中国国际招标网",
		"广东省网上中介服务超市",
		"中国山西政府采购网",
		"国家能源e购",
		"必联电子招标投标平台",
		"安徽省招标投标信息网",
		"广东省电子化采购执行平台",
		"安徽省政府采购网",
		"云南省政府采购网",
		"浙江省公共资源交易服务平台",
		"江西省公共资源交易网",
		"中央政府采购网",
		"中国移动采购与招标网",
	}
	dataDict := map[string]map[string]interface{}{}
	sess := save_mgo.GetMgoConn()
	defer save_mgo.DestoryMongoConn(sess)
	q, total := map[string]interface{}{}, 0
	it := sess.DB(save_mgo.DbName).C("zktest_allfield_extract_data").Find(&q).Iter()
	for tmp := make(map[string]interface{}); it.Next(&tmp); total++ {
		if total%1000 == 0 {
			log.Debug("curent index ", total)
		}
		site := qu.ObjToString(tmp["site"])
		toptype := qu.ObjToString(tmp["toptype"])
		dict := map[string]interface{}{}
		if dataDict[site] != nil {
			dict = dataDict[site]
		}
		num := qu.IntAll(dict[toptype])
		dict[toptype] = num + 1
		dataDict[site] = dict
		tmp = make(map[string]interface{})
	}

	os.Remove("抽取结果统计.xlsx")
	f := xlsx.NewFile()
	sheet, _ := f.AddSheet("站点统计")
	row := sheet.AddRow()
	row.AddCell().Value = "站点"
	row.AddCell().Value = "招标"
	row.AddCell().Value = "结果"
	row.AddCell().Value = "其它"
	row.AddCell().Value = "合计"

	t, t1, t2, t3 := 0, 0, 0, 0
	for _, site := range siteArr {
		data := dataDict[site]
		num := qu.IntAll(data["招标"]) + qu.IntAll(data["结果"]) + qu.IntAll(data["其它"])
		t += num
		t1 += qu.IntAll(data["招标"])
		t2 += qu.IntAll(data["结果"])
		t3 += qu.IntAll(data["其它"])

		row = sheet.AddRow()
		row.AddCell().Value = site
		row.AddCell().Value = fmt.Sprintf("%d", qu.IntAll(data["招标"]))
		row.AddCell().Value = fmt.Sprintf("%d", qu.IntAll(data["结果"]))
		row.AddCell().Value = fmt.Sprintf("%d", qu.IntAll(data["其它"]))
		row.AddCell().Value = fmt.Sprintf("%d", num)
	}
	row = sheet.AddRow()
	row = sheet.AddRow()
	row.AddCell().Value = "总计"
	row.AddCell().Value = fmt.Sprintf("%d", t1)
	row.AddCell().Value = fmt.Sprintf("%d", t2)
	row.AddCell().Value = fmt.Sprintf("%d", t3)
	row.AddCell().Value = fmt.Sprintf("%d", t)

	//准确率-比对-个站点-相关准确率统计
	fieldArr := []string{
		"projectname",
		"projectcode",
		"area",
		"city",
		"district",
		"budget",
		"bidamount",
		"buyer",
		"agency",
		"s_winner",
		"winnerperson",
		"winnertel",
		"winneraddr",
		"agencyperson",
		"agencytel",
		"agencyaddr",
		"buyerperson",
		"buyertel",
		"buyeraddr",
		"projectscope",
	}
	fieldCh_AnArr := []string{
		"项目名称",
		"项目编号",
		"省份",
		"城市",
		"区县",
		"预算",
		"中标金额",
		"采购单位",
		"代理机构",
		"中标单位",
		"中标联系人",
		"中标联系人电话",
		"中标联系人地址",
		"代理机构联系人",
		"代理机构联系人电话",
		"代理机构联系人地址",
		"采购单位联系人",
		"采购单位联系人电话",
		"采购单位联系人地址",
		"项目范围",
	}
	tagDict := map[string]map[string]interface{}{}
	sheet_1, _ := f.AddSheet("字段准确率统计")
	row_1 := sheet_1.AddRow()
	row_1.AddCell().Value = "站点/准确率"
	row_1.AddCell().Value = "数量"
	for index, _ := range fieldArr {
		row_1.AddCell().Value = fieldCh_AnArr[index]
	}
	it = sess.DB(save_mgo.DbName).C("f_sourceinfo_extract").Find(&q).Select(map[string]interface{}{
		"v_baseinfo": 1,
		"v_taginfo":  1,
	}).Iter()
	for tmp := make(map[string]interface{}); it.Next(&tmp); total++ {
		if total%1000 == 0 {
			log.Debug("curent index ", total)
		}
		v_baseinfo := *qu.ObjToMap(tmp["v_baseinfo"])
		site := qu.ObjToString(v_baseinfo["site"])
		v_taginfo := *qu.ObjToMap(tmp["v_taginfo"])
		dictInfo := map[string]interface{}{}
		if tagDict[site] != nil {
			dictInfo = tagDict[site]
		}
		for _, field := range fieldArr {
			info := map[string]interface{}{}
			if dictInfo[field] != nil {
				info = *qu.ObjToMap(dictInfo[field])
			}
			ok, err, all := qu.IntAll(info["ok"]), qu.IntAll(info["err"]), qu.IntAll(info["all"])

			if qu.IntAll(v_taginfo[field]) == 1 { //正确-
				ok++
			} else {
				err++
			}
			all++
			dictInfo[field] = map[string]interface{}{
				"ok":  ok,
				"err": err,
				"all": all,
			}
		}
		tagDict[site] = dictInfo
		tmp = make(map[string]interface{})
	}

	for _, site := range siteArr {
		dataInfo := tagDict[site]
		num := qu.IntAll(dataDict[site]["招标"]) + qu.IntAll(dataDict[site]["结果"]) + qu.IntAll(dataDict[site]["其它"])
		row_1 := sheet_1.AddRow()
		row_1.AddCell().Value = site
		row_1.AddCell().Value = fmt.Sprintf("%d", num)
		for _, field := range fieldArr {
			info := *qu.ObjToMap(dataInfo[field])
			ok := qu.Float64All(info["ok"])
			all := qu.Float64All(info["all"])
			str := fmt.Sprintf("%.2f", 100*ok/all)
			row_1.AddCell().Value = str + "%"
		}
	}

	//整体准确率
	sheet_2, _ := f.AddSheet("整体准确率统计")
	row_2 := sheet_2.AddRow()
	row_2.AddCell().Value = "字段"
	row_2.AddCell().Value = "正确数"
	row_2.AddCell().Value = "错误数"
	row_2.AddCell().Value = "准确率"

	for index, field := range fieldArr {
		ok, err := 0, 0
		row_2 = sheet_2.AddRow()
		row_2.AddCell().Value = fieldCh_AnArr[index]
		for _, v := range tagDict {
			info := *qu.ObjToMap(v[field])
			ok += qu.IntAll(info["ok"])
			err += qu.IntAll(info["err"])
		}
		row_2.AddCell().Value = fmt.Sprintf("%d", ok)
		row_2.AddCell().Value = fmt.Sprintf("%d", err)
		str := fmt.Sprintf("%.2f", 100*qu.Float64All(ok)/qu.Float64All(t))
		row_2.AddCell().Value = str + "%"
	}
	f.Save("抽取结果统计.xlsx")

	/*
		备注：
		1、排行前30站点的数据
		2、分类分别为：招标,结果,其它
		3、总计1899条,经过人基础字段标注统计如下

		类别为：招标，结果，其它排行前30站点
		经过人工标注

	*/
}

//更新标注数据
func updateMarkData() {
	elastic.InitElasticSize("http://127.0.0.1:12003", 10)
	sess := save_mgo.GetMgoConn()
	defer save_mgo.DestoryMongoConn(sess)
	q, total := map[string]interface{}{}, 0
	it := sess.DB(save_mgo.DbName).C("zktest_allfield_extract_data").Find(&q).Iter()
	for tmp := make(map[string]interface{}); it.Next(&tmp); total++ {
		if total%100 == 0 {
			log.Debug("curent index ", total)
		}
		tmpid := BsonTOStringId(tmp["_id"])
		data := save_mgo.FindById("zktest_allfield_bidding", tmpid)
		es_data := *elastic.GetById("bidding", "bidding", tmpid)
		dict := map[string]interface{}{
			"projectinfo": data["projectinfo"],
			"attach_text": data["attach_text"],
			"detail":      data["detail"],
			"contenthtml": data["contenthtml"],
		}
		if len(es_data) > 0 {
			dict["filetext"] = es_data[0]["filetext"]
		}
		save_mgo.UpdateById("zktest_allfield_extract_data", tmpid, map[string]interface{}{
			"$set": dict,
		})
		tmp = make(map[string]interface{})
	}
	log.Debug("is over ", total)
}

//导出标注数据-id
func exportAllFieldBiaoZhuData() {
	elastic.InitElasticSize("http://127.0.0.1:12003", 10)
	//elastic.InitElasticSize("http://172.17.145.170:9800", 10)
	sum_other_doc_count, total := float64(0), float64(2000)
	siteDataArr := []map[string]interface{}{
		{
			"key":       "国家公共资源交易平台",
			"doc_count": 5977861,
		},
		{
			"key":       "中国政府采购网",
			"doc_count": 5570412,
		},
		{
			"key":       "广东省政府采购网",
			"doc_count": 3666294,
		},
		{
			"key":       "中国招标投标公共服务平台",
			"doc_count": 2956079,
		},
		{
			"key":       "湖南省政府采购电子卖场",
			"doc_count": 2570453,
		},
		{
			"key":       "中国山东政府采购网",
			"doc_count": 1725388,
		},
		{
			"key":       "湖北省政府采购网",
			"doc_count": 1183525,
		},
		{
			"key":       "浙江政府采购网",
			"doc_count": 1094312,
		},
		{
			"key":       "中国华能集团公司",
			"doc_count": 991555,
		},
		{
			"key":       "河南省政府采购网",
			"doc_count": 943729,
		},
		{
			"key":       "广西壮族自治区政府采购网",
			"doc_count": 915851,
		},
		{
			"key":       "四川政府采购",
			"doc_count": 910203,
		},
		{
			"key":       "基建云采购",
			"doc_count": 907328,
		},
		{
			"key":       "中国电信阳光采购网",
			"doc_count": 804175,
		},
		{
			"key":       "中国大唐集团公司电子商务平台",
			"doc_count": 793013,
		},
		{
			"key":       "新疆维吾尔自治区政府采购网",
			"doc_count": 729870,
		},
		{
			"key":       "机电产品招标投标电子交易平台",
			"doc_count": 647304,
		},
		{
			"key":       "中国国际招标网",
			"doc_count": 615161,
		},
		{
			"key":       "广东省网上中介服务超市",
			"doc_count": 606003,
		},
		{
			"key":       "中国山西政府采购网",
			"doc_count": 590924,
		},
		{
			"key":       "国家能源e购",
			"doc_count": 579500,
		},
		{
			"key":       "必联电子招标投标平台",
			"doc_count": 573694,
		},
		{
			"key":       "安徽省招标投标信息网",
			"doc_count": 565450,
		},
		{
			"key":       "广东省电子化采购执行平台",
			"doc_count": 533442,
		},
		{
			"key":       "安徽省政府采购网",
			"doc_count": 531645,
		},
		{
			"key":       "云南省政府采购网",
			"doc_count": 524362,
		},
		{
			"key":       "浙江省公共资源交易服务平台",
			"doc_count": 486627,
		},
		{
			"key":       "江西省公共资源交易网",
			"doc_count": 470338,
		},
		{
			"key":       "中央政府采购网",
			"doc_count": 468231,
		},
		{
			"key":       "中国移动采购与招标网",
			"doc_count": 458486,
		},
	}
	//目标数据量 -	站点比例
	for _, v := range siteDataArr {
		sum_other_doc_count += qu.Float64All(v["doc_count"])
	}
	typeMap := map[string]float64{
		"其它": 0.1,
		"招标": 0.5,
		"结果": 0.4,
	}
	isok := 0
	for k, s_data := range siteDataArr {
		site := qu.ObjToString(s_data["key"])
		doc_count := qu.Float64All(s_data["doc_count"])
		space := doc_count / sum_other_doc_count
		//其它+招标+结果
		query := ``
		for toptype, proportion := range typeMap {
			size := total * space * proportion
			cur_size := qu.IntAll(math.Ceil(size))
			if toptype == "其它" {
				query = fmt.Sprintf(`{"query":{"bool":{"must":[{"term":{"bidding.toptype":"%s"}},{"term":{"bidding.site":"%s"}},{"range":{"bidding.publishtime":{"from":"1546272000"}}},{"term":{"bidding.subtype":"合同"}}],"must_not":[],"should":[]}},"from":"0","size":"%s","sort":[],"_source":["_id"],"facets":{}}`, toptype, site, fmt.Sprintf("%d", cur_size))
			} else {
				query = fmt.Sprintf(`{"query":{"bool":{"must":[{"term":{"bidding.toptype":"%s"}},{"term":{"bidding.site":"%s"}},{"range":{"bidding.publishtime":{"from":"1622476800"}}}],"must_not":[],"should":[]}},"from":"0","size":"%s","sort":[],"_source":["_id"],"facets":{}}`, toptype, site, fmt.Sprintf("%d", cur_size))
			}
			resArr := *elastic.Get("bidding", "bidding", query)
			if len(resArr) > 0 {
				for _, v := range resArr {
					isok++
					tmpid := qu.ObjToString(v["_id"])
					save_mgo.Save("zktest_allfield_mark_id", map[string]interface{}{
						"_id": StringTOBsonId(tmpid),
					})
				}
			}
		}
		log.Debug("第", k, "~", site, "~", isok)
	}
	log.Debug("is over ", isok)
}

//导出错误数据
func exportErrWrongBuyerData() {
	sess := save_mgo.GetMgoConn()
	defer save_mgo.DestoryMongoConn(sess)
	q, total := map[string]interface{}{}, 0
	it := sess.DB(save_mgo.DbName).C("zktest_works_test_new_0107").Find(&q).Sort("_id").Select(map[string]interface{}{
		"buyer":          1,
		"wrong_key_item": 1,
	}).Iter()

	for tmp := make(map[string]interface{}); it.Next(&tmp); total++ {
		if total%1000 == 0 {
			log.Debug("cur index ", total)
		}
		wrong_key_item := []string{}
		if res, ok := tmp["wrong_key_item"].(primitive.A); ok {
			wrong_key_item = qu.ObjArrToStringArr(res)
		} else {
			if res, ok := tmp["wrong_key_item"].([]interface{}); ok {
				wrong_key_item = qu.ObjArrToStringArr(res)
			}
		}
		isWrong := false
		for _, v := range wrong_key_item {
			if qu.ObjToString(v) == "buyer" {
				isWrong = true
				break
			}
		}

		if isWrong {
			data := save_mgo.FindById("zktest_works_test_new", BsonTOStringId(tmp["_id"]))
			wrong_key_item_old := []string{}
			if res, ok := data["wrong_key_item"].(primitive.A); ok {
				wrong_key_item_old = qu.ObjArrToStringArr(res)
			} else {
				if res, ok := data["wrong_key_item"].([]interface{}); ok {
					wrong_key_item_old = qu.ObjArrToStringArr(res)
				}
			}
			isExist := false
			for _, v := range wrong_key_item_old {
				if qu.ObjToString(v) == "buyer" {
					isExist = true
					break
				}
			}
			if !isExist {
				log.Debug(BsonTOStringId(tmp["_id"]))
				log.Debug(tmp["buyer"], "~", data["buyer"])
			}
		}

		tmp = make(map[string]interface{})
	}
	log.Debug("is over ", total)
}

func cleanClassStringData() {
	log.Debug("清理特殊数据...")
	sess := save_mgo.GetMgoConn()
	defer save_mgo.DestoryMongoConn(sess)
	q, total := map[string]interface{}{}, 0
	isok := 0
	strReg := regexp.MustCompile(`([ⅡIⅢ]-[0-9]+([\\s ]+)?|^[0-9][0-9]|[ \n]+|^[-])`)
	it := sess.DB(save_mgo.DbName).C("nmpa_product").Find(&q).Sort("_id").Select(map[string]interface{}{
		"product_class_1": 1,
		"product_class_2": 1,
	}).Iter()
	for tmp := make(map[string]interface{}); it.Next(&tmp); total++ {
		if total%1000 == 0 {
			log.Debug("cur index ", total, "~", isok)
		}
		product_class_1 := qu.ObjToString(tmp["product_class_1"])
		product_class_2 := qu.ObjToString(tmp["product_class_2"])
		isUpdate := false
		update := map[string]interface{}{}
		if strReg.MatchString(product_class_1) {
			isUpdate = true
			product_class_1 = strReg.ReplaceAllString(product_class_1, "")
			update["product_class_1"] = product_class_1
		}
		if strReg.MatchString(product_class_2) {
			isUpdate = true
			product_class_2 = strReg.ReplaceAllString(product_class_2, "")
			update["product_class_2"] = product_class_2
		}

		if isUpdate {
			isok++
			log.Debug(tmp["product_class_1"], tmp["product_class_2"])
			save_mgo.UpdateById("nmpa_product", BsonTOStringId(tmp["_id"]), map[string]interface{}{
				"$set": update,
			})
		}
		tmp = make(map[string]interface{})
	}
	log.Debug("is over ", total, "~", isok)

}

//修复等级数据`class`
func repairYiXieChaNewCategoryData() {
	log.Debug("开始补......数据")
	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_zcyl_fl").Find(&q).Sort("_id").Select(map[string]interface{}{
		"registNum": 1,
		"category":  1,
	}).Iter()
	for tmp := make(map[string]interface{}); it.Next(&tmp); total++ {
		if total%1000 == 0 {
			log.Debug("cur index ", total, "~", isok)
		}
		registNum := qu.ObjToString(tmp["registNum"])
		category := qu.ObjToString(tmp["category"])
		if registNum != "" {
			data := save_mgo.FindOne("nmpa_product", map[string]interface{}{
				"reg_no": registNum,
			})
			if data != nil && len(data) > 2 {
				isok++
				save_mgo.UpdateById("nmpa_product", BsonTOStringId(data["_id"]), map[string]interface{}{
					"$set": map[string]interface{}{
						"class": category,
					},
				})
			}
		}
		tmp = make(map[string]interface{})
	}
	log.Debug("is over ", total, "~", isok)

}

//修复数据-new  nmpa_zcyl_fl
func repairYiXieChaNewData() {
	//医械查
	log.Debug("开始补......数据")
	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_zcyl_fl").Find(&q).Sort("_id").Select(map[string]interface{}{
		"registNum":       1,
		"largeClassName":  1,
		"oneProdCategory": 1,
		"twoProdCategory": 1,
	}).Iter()
	//a:=`Ⅱ-11 用于其他生理、生化或免疫功能指标检测的试剂`
	//b:=`I-2 样本处理用产品`
	//c:=`Ⅲ-9 与流式技术相关的试剂`
	strReg := regexp.MustCompile(`([ⅡIⅢ]-[0-9]+[\\s ]+|^[0-9][0-9]|[ \n]+)`)
	for tmp := make(map[string]interface{}); it.Next(&tmp); total++ {
		if total%1000 == 0 {
			log.Debug("cur index ", total, "~", isok)
		}

		largeClassName := qu.ObjToString(tmp["largeClassName"])
		oneProdCategory := qu.ObjToString(tmp["oneProdCategory"])
		twoProdCategory := qu.ObjToString(tmp["twoProdCategory"])
		oneProdCategory = strReg.ReplaceAllString(oneProdCategory, "")
		twoProdCategory = strReg.ReplaceAllString(twoProdCategory, "")

		//计算有效数
		old_ok := effectiveStringOf(largeClassName, oneProdCategory, twoProdCategory)
		update := map[string]interface{}{
			"product_class":   largeClassName,
			"product_class_1": oneProdCategory,
			"product_class_2": twoProdCategory,
			"isYiXieUpdate":   true,
		}
		registNum := qu.ObjToString(tmp["registNum"])
		if registNum != "" && largeClassName != "" {
			data := save_mgo.FindOne("nmpa_product", map[string]interface{}{
				"reg_no": registNum,
			})
			if data != nil && len(data) > 2 {
				product_class := qu.ObjToString(data["product_class"])
				product_class_1 := qu.ObjToString(data["product_class_1"])
				product_class_2 := qu.ObjToString(data["product_class_2"])
				new_ok := effectiveStringOf(product_class, product_class_1, product_class_2)
				if old_ok > new_ok {
					isok++
					save_mgo.UpdateById("nmpa_product", BsonTOStringId(data["_id"]), map[string]interface{}{
						"$set": update,
					})
				}
			}
		}
		tmp = make(map[string]interface{})
	}

	log.Debug("is over ", total, "~", isok)
}

func effectiveStringOf(str1, str2, str3 string) int {
	isok := 0
	if str1 != "" {
		isok++
	}
	if str2 != "" {
		isok++
	}
	if str3 != "" {
		isok++
	}
	return isok
}

func exportErrMarkCkData() {
	sess := save_mgo.GetMgoConn()
	defer save_mgo.DestoryMongoConn(sess)
	q, total := map[string]interface{}{}, 0
	arr := []string{
		"ck_agency",
		"ck_bidamount",
		"ck_budget",
		"ck_buyer",
		"ck_projectcode",
		"ck_projectname",
		"ck_s_winner",
	}
	isErr := 0
	it := sess.DB(save_mgo.DbName).C("zktest_mark_extdata").Find(&q).Iter()
	for tmp := make(map[string]interface{}); it.Next(&tmp); total++ {
		str := ""
		for _, v := range arr {
			if qu.IntAll(tmp[v]) > 1 {
				new_v := strings.ReplaceAll(v, "ck_", "")
				str += new_v + ","
			}
		}
		if str != "" {
			isErr++
			save_mgo.Save("1111", map[string]interface{}{
				"_id":     tmp["_id"],
				"href":    tmp["href"],
				"jy_href": tmp["jytest_href"],
				"field":   str,
			})
		}
		tmp = make(map[string]interface{})
	}

	log.Debug("is over ", total, "~", isErr)
}

//根据产品-公司导出68xx 16-01 相关数据-待定...
func exportNewClassCompanyData() {
	sess := save_mgo.GetMgoConn()
	defer save_mgo.DestoryMongoConn(sess)
	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,
	}).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": "临床检验器械",
		"27": "中医器械",
		"28": "医用成像器械",
		"32": "放射治疗器械",
		"34": "医用成像器械",
		"40": "体外诊断试剂",
		"41": "临床检验器械",
		"45": "输血、透析和体外循环器械",
		"55": "口腔科器械",
		"57": "医疗器械消毒灭菌器械",
		"63": "口腔科器械",
		"64": "注输、护理和防护器械",
		"70": "医用软件",
	}
	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)
		}
		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,
			})

			oldArr := []string{}
			oldMap := map[string]string{}
			for _, v := range dataArr {
				range_str := ""
				business_range := qu.ObjToString(v["business_range"])
				product_range := qu.ObjToString(v["product_range"])
				if business_range != "" {
					range_str = business_range
				} else {
					range_str = product_range
				}
				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 != "" {
						//映射值
						oldArr = append(oldArr, vvvv)
						oldMap[vvvv] = vvvv
					}
				}
			}

			if len(oldArr) > 0 {
				isok++
				class_str := strings.Join(oldArr, ",")
				save_mgo.Save("zzzzzkkkkk", map[string]interface{}{
					"_id":          tmp["_id"],
					"class_str":    class_str,
					"product_name": product_name,
				})
			}
		}
		tmp = make(map[string]interface{})
	}

	log.Debug("is over ", total, "~", isok)
}

//统计数量
func vitalWinnerBidamountData() {
	sess := save_mgo.GetMgoConn()
	defer save_mgo.DestoryMongoConn(sess)
	q, total := map[string]interface{}{}, 0
	rank_data := map[string]map[string]interface{}{}
	it := sess.DB(save_mgo.DbName).C("zktest_purchasing_3_data_new").Find(&q).Sort("_id").Iter()
	for tmp := make(map[string]interface{}); it.Next(&tmp); total++ {
		if total%1000 == 0 {
			log.Debug("cur index ", total, "~", len(rank_data))
		}
		winner := qu.ObjToString(tmp["winner"])
		bidamount := qu.Float64All(tmp["bidamount"])
		p_list := []map[string]interface{}{}
		if purchasinglist, ok := tmp["purchasinglist"].(primitive.A); ok {
			p_list = qu.ObjArrToMapArr(purchasinglist)
		} else {
			if purchasinglist, ok := tmp["purchasinglist"].([]interface{}); ok {
				p_list = qu.ObjArrToMapArr(purchasinglist)
			}
		}
		cur_price := totalPrice(p_list)
		if rank_data[winner] == nil {
			rank_data[winner] = map[string]interface{}{
				"total":      1,
				"totalmoney": bidamount,
				"totalprice": cur_price,
			}
		} else {
			data := rank_data[winner]
			total := qu.IntAll(data["total"])
			totalmoney := qu.Float64All(data["totalmoney"])
			totalprice := qu.Float64All(data["totalprice"])
			total++
			totalmoney += bidamount
			totalprice += cur_price
			rank_data[winner] = map[string]interface{}{
				"total":      total,
				"totalmoney": totalmoney,
				"totalprice": totalprice,
			}
		}
		tmp = make(map[string]interface{})
	}
	log.Debug("is over ", len(rank_data))

	//arr := []map[string]interface{}{}
	rankList := RankList{}
	for k, v := range rank_data {
		rankList = append(rankList, &Rank{
			TotalMoney: qu.Float64All(v["totalmoney"]),
			TotalPrice: qu.Float64All(v["totalprice"]),
			Total:      qu.IntAll(v["total"]),
			Name:       k,
		})
	}
	//开始map排序
	log.Debug("开始排序...")
	rankList.sortsUp(false)

	os.Remove("1.xlsx")
	f := xlsx.NewFile()
	sheet, _ := f.AddSheet("金额排行")
	row := sheet.AddRow()
	row.AddCell().Value = "金额排名"
	row.AddCell().Value = "中标单位"
	row.AddCell().Value = "标的金额"
	row.AddCell().Value = "项目金额"
	logRank := rankList[0:50]
	for k, v := range logRank {
		row = sheet.AddRow()
		row.AddCell().Value = fmt.Sprintf("%d", k+1)
		row.AddCell().Value = fmt.Sprintf("%s", v.Name)
		row.AddCell().Value = fmt.Sprintf("%f", v.TotalPrice)
		row.AddCell().Value = fmt.Sprintf("%f", v.TotalMoney)
	}
	f.Save("1.xlsx")
}

type RankList []*Rank

type Rank struct {
	TotalMoney float64
	TotalPrice float64
	Total      int
	Name       string
}

func (list RankList) len() int {
	return len(list)
}
func (list RankList) swap(i, j int) {
	list[i], list[j] = list[j], list[i]
}
func (list RankList) sortsUp(isUp bool) {
	len := list.len()
	for i := 0; i < len; i++ {
		for j := i + 1; j < len; j++ {
			if isUp {
				if list.compare(i, j) {
					list.swap(i, j)
				}
			} else {
				if !list.compare(i, j) {
					list.swap(i, j)
				}
			}
		}
	}
}
func (list RankList) compare(i, j int) bool {
	if list[i].TotalPrice > list[j].TotalPrice {
		return true
	} else {
		return false
	}
}

func totalPrice(arr []map[string]interface{}) float64 {
	money := qu.Float64All(0)
	for _, v := range arr {
		if qu.Float64All(v["totalprice"]) <= 1000000 {
			money += qu.Float64All(v["totalprice"])
		}
	}
	return money
}

//读取excle数据 并导出
func exportExcleData() {
	ff, _ := xlsx.OpenFile("table.xlsx")
	strReg := regexp.MustCompile(`(^[0-9][0-9]|[ \n]+)`)
	for _, sheet := range ff.Sheets {
		v := sheet
		class := v.Name
		for k, row := range sheet.Rows {
			if k == 0 {
				continue
			}

			var str []string
			for _, cell := range row.Cells {
				str = append(str, cell.String())
			}

			if !strReg.MatchString(str[2]) {
				log.Debug("~~~~~~~~~", str)
			}

			new_str_1 := str[1]
			new_str_2 := str[2]
			new_str_1 = strReg.ReplaceAllString(new_str_1, "")
			new_str_2 = strReg.ReplaceAllString(new_str_2, "")

			new_str_6 := str[6]
			if new_str_6 == "I" || new_str_6 == "Ⅰ" {
				new_str_6 = "I"
			}
			if new_str_6 == "II" || new_str_6 == "Ⅱ" {
				new_str_6 = "II"
			}
			if new_str_6 == "Ⅲ" || new_str_6 == "III" || new_str_6 == "Ⅲ（药械组合产品）" {
				new_str_6 = "III"
			}

			dict := map[string]interface{}{
				"product_class": class,
				//"product_sort":str[0],
				"product_class_1":  new_str_1,
				"product_class_2":  new_str_2,
				"product_describe": str[3],
				"product_effect":   str[4],
				"product_example":  str[5],
				"product_level":    new_str_6,
			}
			save_mgo.Save("nmpa_class_example", dict)
		}
		log.Debug("目录：", class)
	}
}

//统计数量
func exportBdwTotal() {
	sess := save_mgo.GetMgoConn()
	defer save_mgo.DestoryMongoConn(sess)
	q, total := map[string]interface{}{}, 0
	productArr := []string{
		"sanger测序仪器",
		"X辐射放射治疗立体定向系统",
		"X射线发生、限束装置",
		"X射线附属及辅助设备",
		"X射线感光胶片",
		"X射线高压发生器",
		"X射线骨密度仪",
		"X射线管",
		"X射线管组件",
		"X射线计算机体层摄影设备",
		"X射线胶片显影剂、定影剂",
		"X射线胶片自动洗片机",
		"X射线摄影暗盒",
		"X射线摄影患者支撑装置",
		"X射线摄影用影像板成像装置",
		"X射线探测器、X射线探测器及其影像系统",
		"X射线影像接收处理装置",
		"X射线影像增强器、X射线影像增强器电视系统",
		"疤痕修复材料",
		"拔罐器具",
		"拔罐设备",
		"包扎敷料",
		"保护器",
		"绷带",
		"鼻部护理器械",
		"鼻氧管",
		"鼻阻力测量设备",
		"笔式注射器",
		"闭合夹",
		"避孕凝胶",
		"标记器",
		"表面检查灯",
		"髌骨爪",
		"冰冻红细胞洗涤机用管路",
		"丙烯酸树脂骨水泥",
		"病理分析前样本处理仪器",
		"病人护理防护用品",
		"病人监护设备",
		"玻璃注射器",
		"剥离保护器",
		"剥离器",
		"不可吸收缝合线",
		"不可吸收外科敷料",
		"步态训练设备",
		"材料输送器具",
		"采血笔",
		"采样设备和器具",
		"测量器",
		"测量器械",
		"测试刺激电极",
		"测试刺激器",
		"测试延伸导线",
		"测压导管",
		"产床",
		"肠道水疗机",
		"肠营养泵",
		"肠营养袋",
		"肠营养器",
		"常导型磁共振成像系统",
		"超导型磁共振成像系统",
		"超声电子内窥镜",
		"超声多普勒胎儿监护设备",
		"超声多普勒胎儿心率设备",
		"超声多普勒血流分析设备",
		"超声回波多普勒成像设备",
		"超声脉冲回波成像设备",
		"超声耦合垫",
		"超声耦合剂",
		"超声人体组织测量设备",
		"超声生理参数测量、分析设备",
		"超声手术设备",
		"超声手术设备附件",
		"超声手术设备及附件",
		"超声水囊",
		"超声探头",
		"超声探头穿刺架",
		"超声影像引导系统",
		"超声影像诊断附属设备",
		"超声影像诊断设备",
		"超声治疗设备",
		"超声治疗设备附件",
		"超声治疗设备及附件",
		"车载X射线机",
		"撑开钳",
		"持续正压通气用面罩、口罩、鼻罩",
		"冲击波手术设备",
		"冲击波碎石机",
		"冲击波治疗设备",
		"冲头",
		"冲吸器",
		"冲洗器械",
		"臭氧消毒器",
		"臭氧治疗设备",
		"除颤电极",
		"穿刺定位引导装置",
		"穿刺器",
		"穿刺器械",
		"穿刺针",
		"穿孔针",
		"创面敷料",
		"创面敷贴",
		"创伤外科辅助器械",
		"磁共振成像设备",
		"磁共振定位装置",
		"磁共振辅助刺激系统",
		"磁共振辅助设备",
		"磁共振造影注射装置",
		"磁疗设备/器具",
		"打拔器",
		"打孔器",
		"打磨抛光清洁器具",
		"带环及颊面管",
		"单/多部件记忆合金骨固定器械",
		"单/多部件金属骨固定器械及附件",
		"单/多部件可吸收骨固定器械",
		"单/多部件颅颌面固定器械及附件",
		"单/多部件预制颅骨成形术板及紧固件",
		"单光子发射及X射线计算机断层成像系统",
		"单光子发射计算机断层成像设备",
		"单一气体检测器",
		"导电膏",
		"导管床",
		"导管鞘",
		"导管消毒连接器",
		"导尿管",
		"导丝",
		"导引导管",
		"导引器",
		"导引套管",
		"导钻",
		"锝气体发生器",
		"低温储存设备",
		"低中频治疗设备",
		"电磁定位系统",
		"电导分析仪",
		"电动病床",
		"电动防压疮垫",
		"电动患者手术位置固定辅助器械",
		"电动手术台",
		"电动推车、担架等器械",
		"电动吻合器",
		"电动诊疗台及诊疗椅",
		"电解质分析仪器",
		"电解质及血气分析设备",
		"电解质血气分析仪器",
		"电解质血气检测电极",
		"电疗设备/器具",
		"电生理标测导管",
		"电声门图仪",
		"电声学测量、分析设备",
		"电位治疗设备",
		"电泳仪器",
		"电子内窥镜",
		"电子内窥镜图像处理器",
		"电子射野成像系统",
		"垫单",
		"定位、导向、测量器械",
		"定位导向器械",
		"定位导引针",
		"定位针",
		"定制式义齿",
		"动磁场治疗设备",
		"动静脉采血针及连接件",
		"动静脉穿刺器",
		"动脉瘤夹",
		"动态血糖/葡萄糖监测设备",
		"短波治疗仪",
		"耳鼻喉植入物",
		"耳内假体",
		"耳声发射仪",
		"耳声阻抗测量仪",
		"二氧化碳吸收器",
		"反光器具",
		"防护服",
		"防护口罩",
		"防护器具",
		"防龋材料",
		"防散射滤线栅",
		"防压疮垫",
		"放射免疫γ计数器",
		"放射性层析扫描装置",
		"放射性核素标本测定装置",
		"放射性核素成像辅助设备",
		"放射性核素成像设备",
		"放射性核素骨密度测量设备",
		"放射性核素扫描装置",
		"放射性核素诊断设备",
		"放射性粒籽防护植入器",
		"放射性粒籽植入治疗系统",
		"放射治疗辅助软件",
		"放射治疗患者摆位系统",
		"放射治疗患者用固定装置",
		"放射治疗激光定位系统",
		"放射治疗计划系统软件",
		"放射治疗模拟及图像引导系统",
		"放射治疗模拟系统",
		"放射治疗配套器械",
		"放射治疗设备",
		"放射治疗用X射线图像引导系统",
		"放射治疗准直限束装置",
		"非血管内导管",
		"非血管内导管充盈装置",
		"非血管内输液器械",
		"非血管支架",
		"肺功能测试设备",
		"分离控制盒",
		"分离钳",
		"分流栓",
		"分子生物学分析设备",
		"粪便分析仪器",
		"封堵球囊",
		"缝合针",
		"孵育器",
		"浮针",
		"辅助生殖穿刺取卵/取精针",
		"辅助生殖导管",
		"辅助生殖器械",
		"辅助生殖微型工具",
		"辅助生殖专用仪器",
		"辅助位听觉调控设备",
		"辅助位听觉设备",
		"负压引流封闭膜",
		"负压引流海绵",
		"负压引流器及组件",
		"负压治疗设备",
		"妇产科测量、监护设备",
		"妇产科承载器械",
		"妇产科手术器械",
		"妇产科用刀",
		"妇产科用剪",
		"妇产科用扩张器、牵开器",
		"妇产科用镊、夹、钩、针",
		"妇产科用钳",
		"妇产科诊断器械",
		"妇产科治疗器械",
		"妇科剥离器械",
		"妇科采样器械",
		"妇科超声诊断设备",
		"妇科假体器械",
		"妇科检查器械",
		"妇科内窥镜",
		"妇科手术/检查床",
		"妇科物理治疗器械",
		"妇科压板",
		"附件、耗材",
		"复合内窥镜",
		"复合树脂",
		"复合体",
		"富血小板血浆制备器",
		"腹膜透析辅助设备",
		"腹膜透析器具",
		"腹膜透析设备",
		"腹水超滤浓缩回输设备",
		"伽玛射束远距离治疗机",
		"伽玛射线探测装置",
		"伽玛照相机",
		"钙盐类骨填充植入物",
		"盖髓材料",
		"干化学尿液分析仪器",
		"干热消毒灭菌设备",
		"干眼检测仪",
		"肛瘘塞",
		"肛门镜",
		"高频/射频手术设备及附件",
		"高频/射频用电极及导管",
		"高频呼吸机",
		"高频手术设备",
		"高频治疗设备",
		"高强度超声治疗设备",
		"隔离敷料",
		"隔离护罩",
		"隔离及赋形材料",
		"隔离衣帽",
		"根管充填封闭材料",
		"根管预备辅助材料",
		"攻丝用锥",
		"供氧、排氧器",
		"宫内节育器及取放器械",
		"宫腔负压吸引设备及附件",
		"骨把持器",
		"骨钩",
		"骨及组织用剪",
		"骨接合植入物",
		"骨锯",
		"骨科动力手术设备",
		"骨科内窥镜用刀",
		"骨科内窥镜用刮匙",
		"骨科内窥镜用剪",
		"骨科内窥镜用钳",
		"骨科其他手术器械",
		"骨科牵引床及配件",
		"骨科手术体位固定架",
		"骨科填充和修复材料",
		"骨科用刀",
		"骨科用钩",
		"骨科用刮",
		"骨科用剪",
		"骨科用锯",
		"骨科用钳",
		"骨科用有源器械",
		"骨科用凿",
		"骨科用针",
		"骨科用锥",
		"骨科用钻",
		"骨科组织保护器具",
		"骨蜡",
		"骨水泥定型模具",
		"骨水泥器械",
		"骨填充及修复材料",
		"骨凿",
		"骨折复位器",
		"固定针",
		"固位器",
		"固位桩",
		"刮痧器具",
		"刮匙",
		"关节镜配套工具",
		"关节外科辅助器械",
		"关节训练设备",
		"关节置换植入物",
		"灌注导管",
		"光动力激光治疗设备",
		"光动力治疗设备",
		"光面或带螺纹的金属骨固定紧固件",
		"光相干断层成像系统",
		"光学成像诊断设备",
		"光学定位引导系统",
		"光学内窥镜",
		"光学相干断层扫描仪",
		"光治疗设备",
		"光治疗设备附件",
		"硅胶环扎带",
		"滚针",
		"过氧化氢灭菌器",
		"海水鼻腔清洗液",
		"毫米波治疗设备",
		"合拢器",
		"核酸分子杂交仪器",
		"核酸扩增分析仪器",
		"核酸扩增仪器",
		"核酸提取纯化仪",
		"颌面部赝复及修复重建材料及制品",
		"颌面固定植入物",
		"红外热像仪",
		"红外线乳腺诊断仪",
		"红细胞沉降仪器",
		"喉罩",
		"呼气流量测量设备",
		"呼吸、麻醉、急救设备辅助装置",
		"呼吸、麻醉用管路、面罩",
		"呼吸道用吸引导管",
		"呼吸功能及气体分析测定装置",
		"呼吸管路",
		"呼吸管路辅助器械",
		"呼吸门控系统",
		"呼吸面罩",
		"呼吸热量监测设备",
		"呼吸设备",
		"呼吸系统过滤器",
		"呼吸训练器",
		"呼吸压力测量设备",
		"化学发光免疫分析仪器",
		"化学消毒灭菌设备",
		"踝关节假体",
		"环柄注射器",
		"环氧乙烷灭菌器",
		"患者体位固定装置",
		"患者位置固定辅助器械",
		"患者运送隔离器械",
		"患者转运器械",
		"活检枪",
		"活检针",
		"基础通用辅助器械",
		"基台定制材料",
		"基台及附件",
		"基因测序仪器",
		"激光采血仪",
		"激光手术设备",
		"激光手术设备及附件",
		"激光治疗设备",
		"急救和转运用呼吸机",
		"急救设备",
		"急救毯",
		"棘突植入物",
		"脊柱外科辅助器械",
		"脊柱植入物",
		"脊柱椎板间固定系统",
		"脊柱椎弓根系统",
		"脊柱椎体间固定/置换系统",
		"计数板",
		"计算机辅助诊断/分析软件",
		"加压治疗设备",
		"夹板及固定带",
		"夹持、固定器械",
		"夹持/复位用钳",
		"夹子装置",
		"家用呼吸机",
		"家用呼吸支持设备",
		"甲醛灭菌器",
		"间接免疫荧光分析仪器",
		"肩关节假体",
		"监护软件",
		"监护设备",
		"检验及其他辅助设备",
		"简易转移器械",
		"胶带",
		"胶囊内窥镜姿态控制器",
		"胶囊式内窥镜系统",
		"胶片观察装置",
		"胶片扫描仪",
		"角膜地形图仪",
		"角膜共焦显微镜",
		"角膜基质环",
		"角膜基质片",
		"角膜内皮细胞显微镜",
		"矫治器具及附件",
		"接触镜",
		"接触镜护理产品",
		"洁净工作台",
		"洁净屏",
		"洁治器具",
		"结扎手术器械",
		"截骨用刀",
		"介入术用骨锥",
		"金属固定环扎装置",
		"金属髓内装置",
		"金属填充物",
		"紧固、支撑工具",
		"近距离后装治疗设备",
		"经鼻肠营养导管",
		"经皮肠营养导管",
		"精子分析仪器",
		"静磁场治疗器具",
		"静电贴敷器具",
		"静脉尿路造影腹压器",
		"静脉输液针",
		"静脉血样采血管",
		"灸疗器具",
		"灸疗设备",
		"决策支持软件",
		"菌斑/龋齿指示剂",
		"开口器械",
		"开口用锥",
		"康复训练床",
		"康复训练软件",
		"抗鼻腔过敏凝胶",
		"可吸收缝合线",
		"可吸收外科防粘连敷料",
		"可吸收外科敷料",
		"可吸收外科止血材料",
		"口腔X射线机",
		"口腔车针、钻",
		"口腔成像辅助器具",
		"口腔成像设备",
		"口腔充填修复材料",
		"口腔分离牵开用具",
		"口腔隔离器具",
		"口腔洁治清洗设备及附件",
		"口腔溃疡、组织创面愈合治疗辅助材料",
		"口腔麻醉推注设备",
		"口腔清洗器具",
		"口腔手术刀、凿",
		"口腔手术剪",
		"口腔义齿制作材料",
		"口腔用镜",
		"口腔用镊、夹",
		"口腔用钳",
		"口腔照明设备",
		"口腔针",
		"口腔诊察器具",
		"口腔诊察设备",
		"口腔正畸材料及制品",
		"口腔植入及组织重建材料",
		"口腔治疗辅助材料",
		"口腔治疗器具",
		"口腔治疗设备",
		"口腔注射用具",
		"口腔综合治疗设备配件",
		"口咽/鼻咽通气道",
		"叩诊锤",
		"髋关节假体",
		"扩孔用刀",
		"扩髓器",
		"扩髓用钻",
		"扩张导管",
		"扩张器",
		"扩张钳",
		"拉钩",
		"蜡",
		"蓝光治疗设备",
		"泪道管",
		"泪点塞",
		"冷冻手术设备",
		"冷冻手术设备及附件",
		"冷冻消融针及导管",
		"离心泵泵头",
		"离心式血液成分分离器",
		"力疗设备/器具",
		"连接阀",
		"连接器套筒",
		"连续性血液净化设备",
		"临时充填材料",
		"临时起搏电极导线",
		"临时起搏器",
		"流式点阵仪器",
		"流式细胞分析仪器",
		"流式细胞术样本裂解仪",
		"漏斗胸成形系统",
		"颅骨夹/锁",
		"颅骨矫形器械",
		"颅脑外引流收集装置",
		"颅内弹簧圈系统",
		"颅内动脉瘤血流导向装置",
		"颅内栓塞器械",
		"颅内支架系统",
		"麻醉储气囊",
		"麻醉穿刺针",
		"麻醉废气吸附器",
		"麻醉机",
		"麻醉面罩",
		"麻醉气体净化传递和收集系统",
		"麻醉器械",
		"麻醉蒸发器",
		"埋线针",
		"脉搏血氧测量设备",
		"脉搏血氧传感器",
		"酶联免疫分析仪器",
		"泌尿、消化动力学测量、分析设备",
		"泌尿X射线机",
		"免缝闭合器械",
		"免疫层析分析仪器",
		"免疫分析设备",
		"免疫分析一体机",
		"免疫散射浊度分析仪器",
		"免疫印迹仪器",
		"模型材料",
		"末梢采血管",
		"末梢采血针",
		"末梢血采集容器",
		"囊袋张力环",
		"囊袋张力环植入器械",
		"脑磁图设备",
		"脑积水分流器及组件",
		"内窥镜插入形状观测系统",
		"内窥镜冲洗吸引器",
		"内窥镜辅助用品",
		"内窥镜功能供给装置",
		"内窥镜膨腔泵",
		"内窥镜气囊控制器",
		"内窥镜切口牵开保护器",
		"内窥镜取样针",
		"内窥镜润滑剂",
		"内窥镜摄像系统",
		"内窥镜手术用有源设备",
		"内窥镜送气装置",
		"内窥镜先端帽",
		"内窥镜咬口、套管",
		"内窥镜用剥离器",
		"内窥镜用导引器",
		"内窥镜用分离钳",
		"内窥镜用给物器",
		"内窥镜用钩",
		"内窥镜用活检袋",
		"内窥镜用剪",
		"内窥镜用冷光源",
		"内窥镜用气囊导管",
		"内窥镜用气囊扩张器",
		"内窥镜用器械钳",
		"内窥镜用牵开器",
		"内窥镜用取石器械",
		"内窥镜用取石球囊导管",
		"内窥镜用取样钳",
		"内窥镜用套扎器",
		"内窥镜用推结器",
		"内窥镜用吻",
		"内窥镜用细胞刷",
		"内窥镜用异物钳",
		"内窥镜用组织刮匙",
		"内窥镜用组织钳",
		"尿液分析系统",
		"尿液及其他样本分析设备",
		"尿液有形成分分析仪器",
		"颞下颌关节假体",
		"凝胶",
		"凝血分析仪器",
		"排气针",
		"排线器",
		"排龈材料",
		"刨骨器",
		"培养与孵育设备",
		"配套工具",
		"盆底肌肉训练设备",
		"皮肤针",
		"皮内针",
		"平衡测试设备",
		"平衡训练设备",
		"屏障式避孕器械",
		"其他测量、分析设备",
		"其他化学消毒灭菌器",
		"其他口腔材料",
		"其他手术设备",
		"其他体液分析仪器",
		"其他体液形态学分析仪器",
		"其他物理治疗设备",
		"其他眼科治疗和手术设备",
		"其他样本采集器具",
		"其他医用分析设备",
		"其他转移器械",
		"其它器械",
		"起搏系统分析设备",
		"气道过敏反应测试设备",
		"气动急救复苏器",
		"气管插管用喉镜",
		"气管内插管/气管套管",
		"气囊式体外反搏装置",
		"气体测定设备",
		"器械夹",
		"器械剪",
		"器械镊",
		"器械钳",
		"牵开器",
		"牵引器",
		"牵引器具",
		"牵引钳",
		"牵引针",
		"牵引治疗设备",
		"腔静脉滤器",
		"腔静脉滤器回收装置",
		"强脉冲光治疗设备",
		"敲拔器械",
		"切/取骨钻",
		"切割球囊",
		"切割针",
		"青光眼引流装置",
		"清洁器",
		"清洗、灌洗、吸引、给药器械",
		"清洗消毒器",
		"清洗消毒设备",
		"球囊扩张导管",
		"球囊扩张导管用球囊充压装置",
		"取、植皮设备",
		"取片机",
		"取样器械",
		"取样钳",
		"龋齿探测设备",
		"去冠器",
		"热传导治疗设备",
		"热辐射灭菌器",
		"热辐射治疗设备",
		"热交换设备",
		"热空气灭菌器",
		"热空气消毒器",
		"热湿交换器",
		"人工玻璃体球囊",
		"人工复苏器",
		"人工肝设备",
		"人工晶状体",
		"人工晶状体、人工玻璃体植入器械",
		"人工颅骨",
		"人工心脏瓣膜及瓣膜修复器械",
		"人工血管",
		"人体阻抗测量、分析设备",
		"认知言语视听障碍康复设备",
		"认知障碍康复设备",
		"韧带手术器械",
		"妊娠控制器械",
		"乳房植入物",
		"乳腺X射线机",
		"软骨整形器械",
		"软组织扩张器",
		"润滑剂及载体",
		"三棱针",
		"扫描图像分析系统",
		"色谱柱",
		"筛查、分析软件",
		"烧烫伤浸浴装置",
		"舌肌康复训练器",
		"射频浅表治疗设备",
		"射频热疗设备",
		"射频消融设备",
		"射频消融设备用灌注泵",
		"射线束扫描测量系统",
		"摄影X射线机",
		"神经调控程控设备",
		"神经调控充电设备",
		"神经调控设备",
		"神经和肌肉刺激器用电极",
		"神经和心血管手术器械-剥离器",
		"神经和心血管手术器械-冲吸器",
		"神经和心血管手术器械-穿刺导引器",
		"神经和心血管手术器械-刀",
		"神经和心血管手术器械-钩",
		"神经和心血管手术器械-刮匙",
		"神经和心血管手术器械-夹",
		"神经和心血管手术器械-剪",
		"神经和心血管手术器械-镊",
		"神经和心血管手术器械-其他器械",
		"神经和心血管手术器械-牵开器",
		"神经和心血管手术器械-钳",
		"神经和心血管手术器械-心血管介入器械",
		"神经和心血管手术器械-针",
		"神经监护设备",
		"神经内/外科植入物",
		"神经修复材料",
		"肾及甲状腺功能测量设备",
		"渗透压测定仪器",
		"生化分析设备",
		"生化分析仪器",
		"生化免疫分析仪器",
		"生理参数分析测量设备",
		"生理参数诱发诊断设备",
		"生理信号处理软件",
		"生物安全柜",
		"生物反馈治疗设备",
		"生物芯片分析仪器",
		"生殖道分泌物分析仪器",
		"施夹器",
		"施源器",
		"湿热消毒灭菌设备",
		"石膏拆除器械",
		"石膏锯",
		"石膏切割器具",
		"石膏切割用刀",
		"食道气管插管",
		"试模",
		"视功能检查设备和器具",
		"视光设备和器具",
		"视觉康复设备",
		"视觉治疗设备",
		"手柄",
		"手部防护用品",
		"手动病床",
		"手动测量器械",
		"手动测量用器械",
		"手动防压疮垫",
		"手动手术台",
		"手动推车、担架等器械",
		"手动诊疗台及诊疗椅",
		"手术叉",
		"手术锉",
		"手术单",
		"手术刀",
		"手术导航、控制系统",
		"手术导航系统",
		"手术定位系统",
		"手术动力系统",
		"手术钩",
		"手术刮匙",
		"手术环",
		"手术计划软件",
		"手术锯",
		"手术控制系统",
		"手术膜",
		"手术器械-剥离器",
		"手术器械-冲吸器",
		"手术器械-穿刺导引器",
		"手术器械-钩",
		"手术器械-刮匙",
		"手术器械-夹",
		"手术器械-剪",
		"手术器械-镊",
		"手术器械-其他器械",
		"手术器械-牵开器",
		"手术器械-钳",
		"手术器械-吻合器械及材料",
		"手术器械-针",
		"手术室感染控制用品",
		"手术室用衣帽",
		"手术台",
		"手术显微镜",
		"手术针",
		"输卵管封闭器械",
		"输尿管支架",
		"输送导引器",
		"输血器",
		"输氧面罩",
		"输液、输血用连接件及附件",
		"输液泵",
		"输液袋",
		"输液辅助电子设备",
		"输液连接管路",
		"输液器",
		"输液信息采集系统",
		"输液用放气针",
		"术中牵引架及配件",
		"数据处理软件",
		"水刀",
		"水门汀",
		"睡眠呼吸监测设备",
		"睡眠呼吸暂停治疗设备",
		"塑形工具",
		"酸碱度检测设备",
		"酸蚀剂",
		"酸性氧化电位水生成器",
		"探针",
		"套扎器",
		"套针外周导管",
		"体表电极",
		"体表器械固定装置",
		"体表色素测量设备",
		"体外除颤设备",
		"体外辅助生殖用液",
		"体外声音处理器",
		"体外心肺支持辅助系统",
		"体外心肺支持用升温仪",
		"体外引流、吸引管",
		"体外诊断类软件",
		"体温测量设备",
		"听觉检查音叉",
		"听觉康复设备",
		"听力计",
		"听小骨假体",
		"听诊器",
		"通气辅助器械",
		"通条",
		"同种异体骨修复材料",
		"头皮夹",
		"透视X射线机",
		"透视摄影X射线机",
		"透视摄影床",
		"透视荧光屏",
		"图像分析仪器",
		"图像扫描仪器",
		"图像显示、处理、传输及打印设备",
		"图像显示处理工作站",
		"涂抹及吸液材料",
		"推结器",
		"托槽",
		"脱敏剂",
		"脱细胞皮肤",
		"脱细胞真皮基质",
		"外固定及牵引器械",
		"外固定支架",
		"外科补片/外科修补网",
		"外科非织造布敷料",
		"外科海绵敷料",
		"外科口罩",
		"外科手套",
		"外科织造布类敷料",
		"腕关节假体",
		"微波手术设备",
		"微波治疗设备",
		"微创骨导引器",
		"微创入路装置",
		"微导管",
		"微量元素分析仪器",
		"微生物比浊仪器",
		"微生物分析设备",
		"微生物鉴定药敏分析仪器",
		"微生物鉴定仪器",
		"微生物培养监测仪器",
		"微生物药敏培养监测仪器",
		"微生物质谱鉴定仪器",
		"微栓过滤器",
		"微循环显微镜",
		"胃肠X射线检查用品",
		"胃肠超声显像粉",
		"胃隐血采集器具",
		"温热治疗设备/器具",
		"温针治疗设备",
		"吻合器",
		"无创血流分析设备",
		"无创血压测量设备",
		"无创血压袖带",
		"无菌接管机",
		"无菌注射器",
		"无源患者手术位置固定辅助器械",
		"无源输注泵",
		"无源止血带",
		"无源止血器",
		"无针注射器",
		"五官科检查镜",
		"物理降温设备",
		"雾化面罩",
		"雾化设备/雾化装置",
		"吸潮纸尖",
		"吸入镇痛装置",
		"吸氧头罩",
		"吸引器",
		"膝关节假体",
		"洗板机",
		"细菌内毒素/真菌葡聚糖检测仪器",
		"限束装置",
		"小针刀",
		"携带式X射线机",
		"心电测量、分析设备",
		"心电导联线",
		"心肺复苏设备",
		"心肺转流监测设备",
		"心肺转流器具",
		"心肺转流设备",
		"心肺转流用泵",
		"心肺转流用管路及接头",
		"心血管补片",
		"心血管功能检测设备",
		"心血管栓塞器械",
		"心血管植入物",
		"心脏电生理标测设备",
		"心脏封堵器",
		"心脏封堵器输送线缆",
		"心脏封堵器装载器",
		"心脏节律管理程控设备",
		"心脏节律管理设备",
		"心脏停跳液",
		"心脏停跳液灌注器",
		"芯钻",
		"形态学分析前样本处理设备",
		"胸骨捆扎/抓扣固定系统",
		"胸腔引流装置",
		"修补固定器",
		"修整用钻",
		"悬吊、支撑装置",
		"穴位磁疗器具",
		"穴位电刺激设备",
		"穴位激光刺激设备",
		"穴位微波刺激设备",
		"穴位压力刺激器具",
		"血袋",
		"血管缝合装置",
		"血管内回收装置",
		"血管内假体",
		"血管内留置针",
		"血管内皮功能测试设备",
		"血管内输液器械",
		"血管显像设备",
		"血管硬度测量设备",
		"血管造影X射线机",
		"血管支架",
		"血浆病毒灭活设备",
		"血浆管路",
		"血流变分析仪器",
		"血气分析仪器",
		"血栓抽吸导管",
		"血糖及血糖相关参数分析仪器",
		"血细胞处理设备",
		"血细胞分析前样本处理仪器",
		"血细胞分析仪器",
		"血细胞形态分析仪器",
		"血小板分析仪器",
		"血小板振荡器",
		"血型分析仪器",
		"血液采集卡",
		"血液成分分离设备",
		"血液分离、处理、贮存器具",
		"血液分离、处理、贮存设备",
		"血液辐照设备",
		"血液灌流器具",
		"血液灌流设备",
		"血液净化辅助器具",
		"血液净化及腹膜透析器具",
		"血液净化及腹膜透析设备",
		"血液浓缩器",
		"血液融化设备",
		"血液透析辅助设备",
		"血液透析器具",
		"血液透析设备",
		"血液学分析设备",
		"血脂分离器具",
		"血脂分离设备",
		"熏蒸治疗设备",
		"循环肿瘤细胞分析仪器",
		"压力绷带",
		"压力蒸汽灭菌器",
		"压迫器",
		"压器",
		"压舌板",
		"压缩钳",
		"牙本质测量设备",
		"牙齿漂白材料",
		"牙科锉",
		"牙科分离剂",
		"牙科膜片",
		"牙科手机及附件",
		"牙科用椅",
		"牙科治疗机",
		"牙髓活力测试剂",
		"牙髓活力测试设备",
		"牙挺",
		"牙托梗",
		"牙种植体",
		"牙周袋探测设备",
		"牙周塞治剂",
		"氩保护气凝设备",
		"延长管",
		"言语障碍测量设备",
		"言语障碍康复设备",
		"研磨抛光材料",
		"眼科测量诊断设备和器具",
		"眼科超声手术设备",
		"眼科超声诊断设备",
		"眼科激光治疗设备",
		"眼科矫治和防护器具",
		"眼科冷冻治疗设备",
		"眼科内窥镜及附件",
		"眼科无源手术器械",
		"眼科诊断辅助器具",
		"眼科植入物及辅助器械",
		"眼科治疗和手术辅助器具",
		"眼科治疗和手术设备、辅助器具",
		"眼内填充物",
		"眼贴",
		"眼用剥离器",
		"眼用铲",
		"眼用冲吸器",
		"眼用刀",
		"眼用钩",
		"眼用刮匙",
		"眼用夹",
		"眼用剪",
		"眼用锯",
		"眼用扩张器",
		"眼用镊",
		"眼用牵开器",
		"眼用钳",
		"眼用凿",
		"眼用粘弹剂",
		"眼用针",
		"眼用钻",
		"眼震电图设备",
		"厌氧培养系统",
		"验光设备和器具",
		"氧合器",
		"氧气发生器",
		"氧气吸入器",
		"样本处理系统",
		"样本分离设备",
		"遥测和中央监护设备",
		"遥测监护设备",
		"咬骨钳",
		"咬合关系记录/检查材料",
		"咬口",
		"药物导入设备",
		"药液用转移、配药器具",
		"液体闪烁计数器",
		"液相色谱分析仪器",
		"医护人员防护用品",
		"医学显微影像分析软件",
		"医学影像处理软件",
		"医学影像存储与传输系统软件",
		"医用X射线治疗设备",
		"医用病床",
		"医用导管夹",
		"医用电动吸引器械",
		"医用电子加速器",
		"医用防护衬垫",
		"医用分子筛制氧机",
		"医用分子筛制氧系统",
		"医用妇科护垫",
		"医用供气排气相关设备",
		"医用光学放大器具",
		"医用呼吸道湿化器",
		"医用激光光纤",
		"医用空气压缩机",
		"医用离心机",
		"医用轮椅车",
		"医用膜分离制氧机",
		"医用膜分离制氧系统",
		"医用内窥镜",
		"医用培养/恒温箱",
		"医用气体报警系统",
		"医用气体汇流排",
		"医用气体混合器",
		"医用轻离子治疗系统",
		"医用清洗器",
		"医用人工驱动吸引器械",
		"医用射线防护设备",
		"医用射线防护用具",
		"医用射线防护装置",
		"医用生物防护设备",
		"医用图像打印机",
		"医用显微镜",
		"医用压缩气体供应系统",
		"医用氧舱",
		"医用婴儿床",
		"医用增感屏",
		"医用制氧设备",
		"医用中心吸引系统",
		"胰岛素泵",
		"胰岛素泵用储液器",
		"胰岛素泵用皮下输液器",
		"移动式C形臂X射线机",
		"以负压源或压力源为动力吸引器械",
		"义齿试用材料",
		"义齿用高分子材料及制品",
		"义齿用金属材料及制品",
		"义齿用陶瓷材料及制品",
		"义眼片",
		"义眼台",
		"异物钳",
		"阴道镜",
		"阴道填塞材料",
		"阴道洗涤器/给药器",
		"阴茎假体",
		"银汞合金",
		"引流袋（容器）/收集袋（容器）、粪便管理器械",
		"引流袋、粪便管理器械",
		"引流导管",
		"印模材料",
		"婴儿辐射保暖台",
		"婴儿光疗防护眼罩",
		"婴儿培养箱",
		"荧光免疫分析仪器",
		"影像板",
		"影像处理软件",
		"影像记录介质",
		"硬膜外麻醉导管",
		"硬脑膜补片",
		"永磁型磁共振成像系统",
		"幽门螺旋杆菌分析仪器",
		"有创颅内压设备",
		"有创血压传感器",
		"有源止血器",
		"与非血管内导管配套用体外器械",
		"预充式导管冲洗器",
		"预处理剂",
		"远程监护设备",
		"远端保护器",
		"运动康复训练器械",
		"运动损伤软组织修复重建及置换植入物",
		"运动损伤软组织修复重建植入物",
		"运动损伤软组织置换植入物",
		"造口、疤痕护理用品",
		"造口护理及辅助器械",
		"造影导管",
		"造影剂注射装置",
		"造影球囊",
		"摘除镊",
		"粘堵剂",
		"粘合剂",
		"粘接剂",
		"针灸针",
		"真耳测试仪",
		"真空负压机",
		"诊察辅助器械",
		"诊断X射线机",
		"诊疗台",
		"振动训练设备",
		"蒸汽消毒器",
		"整形及普通外科植入物",
		"整形填充材料",
		"整形用注射填充物",
		"正电子发射断层成像设备",
		"正电子发射及X射线计算机断层成像系统",
		"正电子发射及磁共振成像系统",
		"正畸材料处理器械",
		"正畸弹簧",
		"正畸弹性体附件",
		"正畸基托聚合物",
		"正畸丝",
		"支气管堵塞器",
		"支气管内活瓣",
		"肢体数字化体层摄影X射线机",
		"直肠管",
		"直流电治疗设备",
		"植骨器械",
		"植皮器",
		"植入取出工具",
		"植入式电极导线补件",
		"植入式电极导线适配工具",
		"植入式电极导线移除工具",
		"植入式封堵工具",
		"植入式给药器械",
		"植入式神经刺激电极",
		"植入式神经刺激器",
		"植入式位听觉设备",
		"植入式心律转复除颤器",
		"植入式心脏除颤电极导线",
		"植入式心脏起搏电极导线",
		"植入式心脏起搏器",
		"植入式心脏事件监测设备",
		"植入式心脏收缩力调节设备",
		"植入式循环辅助设备",
		"植入式药物输注设备",
		"植入物或石膏用剪",
		"植入物塑形用钳",
		"植入性止鼾装置",
		"止血夹",
		"止血器具",
		"止血钳",
		"指关节假体",
		"质谱检测系统",
		"治疗辅助器具",
		"治疗呼吸机",
		"治疗机用X射线管",
		"治疗计划软件",
		"中心静脉导管",
		"中央监护系统",
		"中医器具",
		"中医治疗设备",
		"种植辅助材料",
		"种植体安装辅助器械",
		"种植体密封材料",
		"种植支抗",
		"肘关节假体",
		"煮沸消毒器",
		"助产器械",
		"助讲器",
		"助视器",
		"助听器",
		"助行器械",
		"贮血滤血器",
		"注射、穿刺器械",
		"注射泵",
		"注射器辅助推动装置",
		"注射针",
		"铸造包埋材料",
		"椎间盘假体",
		"椎间融合器",
		"椎体成形器械",
		"椎体后缘处理器",
		"准直限束装置",
		"子宫操纵器",
		"子宫输卵管造影、输卵管通液器械",
		"紫外线消毒器",
		"紫外线消毒设备",
		"紫外治疗设备",
		"自动给药系统",
		"自动加样系统",
		"自体血液处理器具",
		"自体血液回收设备",
		"足部隔离用品",
		"足跟采血器",
		"组合功能融合成像器械",
		"组织工程生物羊膜",
		"组织工程支架材料",
		"组织剪",
		"组织镊",
		"组织钳",
		"组织用钳",
		"钻孔用钻",
	}
	it := sess.DB(save_mgo.DbName).C("zktest_bdw_words").Find(&q).Sort("_id").Iter()
	for tmp := make(map[string]interface{}); it.Next(&tmp); total++ {
		productArr = append(productArr, qu.ObjToString(tmp["product_name"]))
		tmp = make(map[string]interface{})
	}
	log.Debug("产品名称~", len(productArr))
	productDict := map[string]interface{}{}
	total = 0
	it = sess.DB(save_mgo.DbName).C("zktest_purchasing_3_data_new").Find(&q).Sort("_id").Iter()
	for tmp := make(map[string]interface{}); it.Next(&tmp); total++ {
		if total%1000 == 0 {
			log.Debug("cur index ", total, "~", len(productDict))
		}
		p_list := []map[string]interface{}{}
		if purchasinglist, ok := tmp["purchasinglist"].(primitive.A); ok {
			p_list = qu.ObjArrToMapArr(purchasinglist)
		} else {
			if purchasinglist, ok := tmp["purchasinglist"].([]interface{}); ok {
				p_list = qu.ObjArrToMapArr(purchasinglist)
			}
		}

		for _, v := range p_list {
			itemname := qu.ObjToString(v["itemname"])
			isExist := false
			isExistName := ""
			for _, v := range productArr {
				product_name := qu.ObjToString(v)
				if strings.Contains(itemname, product_name) ||
					strings.Contains(product_name, itemname) {
					isExist = true
					isExistName = product_name
					break
				}
			}
			if isExist {
				productDict[isExistName] = 1
			}
		}

		tmp = make(map[string]interface{})
	}
	log.Debug("is over ", total, "~", len(productDict))
}

//修复-classLevel
func repairClassLevelData() {
	sess := save_mgo.GetMgoConn()
	defer save_mgo.DestoryMongoConn(sess)
	q, total := map[string]interface{}{}, 0
	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++ {
		product_level := qu.ObjToString(tmp["product_level"])
		new_str := ""
		if product_level == "I" || product_level == "Ⅰ" {
			new_str = "I"
		}
		if product_level == "II" || product_level == "Ⅱ" {
			new_str = "II"
		}
		if product_level == "Ⅲ" || product_level == "III" || product_level == "Ⅲ（药械组合产品）" {
			new_str = "III"
		}

		if new_str == "" {
			log.Debug(product_level, "~", BsonTOStringId(tmp["_id"]))
		}
		save_mgo.UpdateById("nmpa_class_example", BsonTOStringId(tmp["_id"]), map[string]interface{}{
			"$set": map[string]interface{}{
				"product_level": new_str,
			},
		})
		tmp = make(map[string]interface{})
	}
	log.Debug("加载完毕~", total)
}

//修复有效标的物数据
func repairEnableBdwData() {
	sess := save_mgo.GetMgoConn()
	defer save_mgo.DestoryMongoConn(sess)
	q, total := map[string]interface{}{}, 0
	productArr := []string{
		"sanger测序仪器",
		"X辐射放射治疗立体定向系统",
		"X射线发生、限束装置",
		"X射线附属及辅助设备",
		"X射线感光胶片",
		"X射线高压发生器",
		"X射线骨密度仪",
		"X射线管",
		"X射线管组件",
		"X射线计算机体层摄影设备",
		"X射线胶片显影剂、定影剂",
		"X射线胶片自动洗片机",
		"X射线摄影暗盒",
		"X射线摄影患者支撑装置",
		"X射线摄影用影像板成像装置",
		"X射线探测器、X射线探测器及其影像系统",
		"X射线影像接收处理装置",
		"X射线影像增强器、X射线影像增强器电视系统",
		"疤痕修复材料",
		"拔罐器具",
		"拔罐设备",
		"包扎敷料",
		"保护器",
		"绷带",
		"鼻部护理器械",
		"鼻氧管",
		"鼻阻力测量设备",
		"笔式注射器",
		"闭合夹",
		"避孕凝胶",
		"标记器",
		"表面检查灯",
		"髌骨爪",
		"冰冻红细胞洗涤机用管路",
		"丙烯酸树脂骨水泥",
		"病理分析前样本处理仪器",
		"病人护理防护用品",
		"病人监护设备",
		"玻璃注射器",
		"剥离保护器",
		"剥离器",
		"不可吸收缝合线",
		"不可吸收外科敷料",
		"步态训练设备",
		"材料输送器具",
		"采血笔",
		"采样设备和器具",
		"测量器",
		"测量器械",
		"测试刺激电极",
		"测试刺激器",
		"测试延伸导线",
		"测压导管",
		"产床",
		"肠道水疗机",
		"肠营养泵",
		"肠营养袋",
		"肠营养器",
		"常导型磁共振成像系统",
		"超导型磁共振成像系统",
		"超声电子内窥镜",
		"超声多普勒胎儿监护设备",
		"超声多普勒胎儿心率设备",
		"超声多普勒血流分析设备",
		"超声回波多普勒成像设备",
		"超声脉冲回波成像设备",
		"超声耦合垫",
		"超声耦合剂",
		"超声人体组织测量设备",
		"超声生理参数测量、分析设备",
		"超声手术设备",
		"超声手术设备附件",
		"超声手术设备及附件",
		"超声水囊",
		"超声探头",
		"超声探头穿刺架",
		"超声影像引导系统",
		"超声影像诊断附属设备",
		"超声影像诊断设备",
		"超声治疗设备",
		"超声治疗设备附件",
		"超声治疗设备及附件",
		"车载X射线机",
		"撑开钳",
		"持续正压通气用面罩、口罩、鼻罩",
		"冲击波手术设备",
		"冲击波碎石机",
		"冲击波治疗设备",
		"冲头",
		"冲吸器",
		"冲洗器械",
		"臭氧消毒器",
		"臭氧治疗设备",
		"除颤电极",
		"穿刺定位引导装置",
		"穿刺器",
		"穿刺器械",
		"穿刺针",
		"穿孔针",
		"创面敷料",
		"创面敷贴",
		"创伤外科辅助器械",
		"磁共振成像设备",
		"磁共振定位装置",
		"磁共振辅助刺激系统",
		"磁共振辅助设备",
		"磁共振造影注射装置",
		"磁疗设备/器具",
		"打拔器",
		"打孔器",
		"打磨抛光清洁器具",
		"带环及颊面管",
		"单/多部件记忆合金骨固定器械",
		"单/多部件金属骨固定器械及附件",
		"单/多部件可吸收骨固定器械",
		"单/多部件颅颌面固定器械及附件",
		"单/多部件预制颅骨成形术板及紧固件",
		"单光子发射及X射线计算机断层成像系统",
		"单光子发射计算机断层成像设备",
		"单一气体检测器",
		"导电膏",
		"导管床",
		"导管鞘",
		"导管消毒连接器",
		"导尿管",
		"导丝",
		"导引导管",
		"导引器",
		"导引套管",
		"导钻",
		"锝气体发生器",
		"低温储存设备",
		"低中频治疗设备",
		"电磁定位系统",
		"电导分析仪",
		"电动病床",
		"电动防压疮垫",
		"电动患者手术位置固定辅助器械",
		"电动手术台",
		"电动推车、担架等器械",
		"电动吻合器",
		"电动诊疗台及诊疗椅",
		"电解质分析仪器",
		"电解质及血气分析设备",
		"电解质血气分析仪器",
		"电解质血气检测电极",
		"电疗设备/器具",
		"电生理标测导管",
		"电声门图仪",
		"电声学测量、分析设备",
		"电位治疗设备",
		"电泳仪器",
		"电子内窥镜",
		"电子内窥镜图像处理器",
		"电子射野成像系统",
		"垫单",
		"定位、导向、测量器械",
		"定位导向器械",
		"定位导引针",
		"定位针",
		"定制式义齿",
		"动磁场治疗设备",
		"动静脉采血针及连接件",
		"动静脉穿刺器",
		"动脉瘤夹",
		"动态血糖/葡萄糖监测设备",
		"短波治疗仪",
		"耳鼻喉植入物",
		"耳内假体",
		"耳声发射仪",
		"耳声阻抗测量仪",
		"二氧化碳吸收器",
		"反光器具",
		"防护服",
		"防护口罩",
		"防护器具",
		"防龋材料",
		"防散射滤线栅",
		"防压疮垫",
		"放射免疫γ计数器",
		"放射性层析扫描装置",
		"放射性核素标本测定装置",
		"放射性核素成像辅助设备",
		"放射性核素成像设备",
		"放射性核素骨密度测量设备",
		"放射性核素扫描装置",
		"放射性核素诊断设备",
		"放射性粒籽防护植入器",
		"放射性粒籽植入治疗系统",
		"放射治疗辅助软件",
		"放射治疗患者摆位系统",
		"放射治疗患者用固定装置",
		"放射治疗激光定位系统",
		"放射治疗计划系统软件",
		"放射治疗模拟及图像引导系统",
		"放射治疗模拟系统",
		"放射治疗配套器械",
		"放射治疗设备",
		"放射治疗用X射线图像引导系统",
		"放射治疗准直限束装置",
		"非血管内导管",
		"非血管内导管充盈装置",
		"非血管内输液器械",
		"非血管支架",
		"肺功能测试设备",
		"分离控制盒",
		"分离钳",
		"分流栓",
		"分子生物学分析设备",
		"粪便分析仪器",
		"封堵球囊",
		"缝合针",
		"孵育器",
		"浮针",
		"辅助生殖穿刺取卵/取精针",
		"辅助生殖导管",
		"辅助生殖器械",
		"辅助生殖微型工具",
		"辅助生殖专用仪器",
		"辅助位听觉调控设备",
		"辅助位听觉设备",
		"负压引流封闭膜",
		"负压引流海绵",
		"负压引流器及组件",
		"负压治疗设备",
		"妇产科测量、监护设备",
		"妇产科承载器械",
		"妇产科手术器械",
		"妇产科用刀",
		"妇产科用剪",
		"妇产科用扩张器、牵开器",
		"妇产科用镊、夹、钩、针",
		"妇产科用钳",
		"妇产科诊断器械",
		"妇产科治疗器械",
		"妇科剥离器械",
		"妇科采样器械",
		"妇科超声诊断设备",
		"妇科假体器械",
		"妇科检查器械",
		"妇科内窥镜",
		"妇科手术/检查床",
		"妇科物理治疗器械",
		"妇科压板",
		"附件、耗材",
		"复合内窥镜",
		"复合树脂",
		"复合体",
		"富血小板血浆制备器",
		"腹膜透析辅助设备",
		"腹膜透析器具",
		"腹膜透析设备",
		"腹水超滤浓缩回输设备",
		"伽玛射束远距离治疗机",
		"伽玛射线探测装置",
		"伽玛照相机",
		"钙盐类骨填充植入物",
		"盖髓材料",
		"干化学尿液分析仪器",
		"干热消毒灭菌设备",
		"干眼检测仪",
		"肛瘘塞",
		"肛门镜",
		"高频/射频手术设备及附件",
		"高频/射频用电极及导管",
		"高频呼吸机",
		"高频手术设备",
		"高频治疗设备",
		"高强度超声治疗设备",
		"隔离敷料",
		"隔离护罩",
		"隔离及赋形材料",
		"隔离衣帽",
		"根管充填封闭材料",
		"根管预备辅助材料",
		"攻丝用锥",
		"供氧、排氧器",
		"宫内节育器及取放器械",
		"宫腔负压吸引设备及附件",
		"骨把持器",
		"骨钩",
		"骨及组织用剪",
		"骨接合植入物",
		"骨锯",
		"骨科动力手术设备",
		"骨科内窥镜用刀",
		"骨科内窥镜用刮匙",
		"骨科内窥镜用剪",
		"骨科内窥镜用钳",
		"骨科其他手术器械",
		"骨科牵引床及配件",
		"骨科手术体位固定架",
		"骨科填充和修复材料",
		"骨科用刀",
		"骨科用钩",
		"骨科用刮",
		"骨科用剪",
		"骨科用锯",
		"骨科用钳",
		"骨科用有源器械",
		"骨科用凿",
		"骨科用针",
		"骨科用锥",
		"骨科用钻",
		"骨科组织保护器具",
		"骨蜡",
		"骨水泥定型模具",
		"骨水泥器械",
		"骨填充及修复材料",
		"骨凿",
		"骨折复位器",
		"固定针",
		"固位器",
		"固位桩",
		"刮痧器具",
		"刮匙",
		"关节镜配套工具",
		"关节外科辅助器械",
		"关节训练设备",
		"关节置换植入物",
		"灌注导管",
		"光动力激光治疗设备",
		"光动力治疗设备",
		"光面或带螺纹的金属骨固定紧固件",
		"光相干断层成像系统",
		"光学成像诊断设备",
		"光学定位引导系统",
		"光学内窥镜",
		"光学相干断层扫描仪",
		"光治疗设备",
		"光治疗设备附件",
		"硅胶环扎带",
		"滚针",
		"过氧化氢灭菌器",
		"海水鼻腔清洗液",
		"毫米波治疗设备",
		"合拢器",
		"核酸分子杂交仪器",
		"核酸扩增分析仪器",
		"核酸扩增仪器",
		"核酸提取纯化仪",
		"颌面部赝复及修复重建材料及制品",
		"颌面固定植入物",
		"红外热像仪",
		"红外线乳腺诊断仪",
		"红细胞沉降仪器",
		"喉罩",
		"呼气流量测量设备",
		"呼吸、麻醉、急救设备辅助装置",
		"呼吸、麻醉用管路、面罩",
		"呼吸道用吸引导管",
		"呼吸功能及气体分析测定装置",
		"呼吸管路",
		"呼吸管路辅助器械",
		"呼吸门控系统",
		"呼吸面罩",
		"呼吸热量监测设备",
		"呼吸设备",
		"呼吸系统过滤器",
		"呼吸训练器",
		"呼吸压力测量设备",
		"化学发光免疫分析仪器",
		"化学消毒灭菌设备",
		"踝关节假体",
		"环柄注射器",
		"环氧乙烷灭菌器",
		"患者体位固定装置",
		"患者位置固定辅助器械",
		"患者运送隔离器械",
		"患者转运器械",
		"活检枪",
		"活检针",
		"基础通用辅助器械",
		"基台定制材料",
		"基台及附件",
		"基因测序仪器",
		"激光采血仪",
		"激光手术设备",
		"激光手术设备及附件",
		"激光治疗设备",
		"急救和转运用呼吸机",
		"急救设备",
		"急救毯",
		"棘突植入物",
		"脊柱外科辅助器械",
		"脊柱植入物",
		"脊柱椎板间固定系统",
		"脊柱椎弓根系统",
		"脊柱椎体间固定/置换系统",
		"计数板",
		"计算机辅助诊断/分析软件",
		"加压治疗设备",
		"夹板及固定带",
		"夹持、固定器械",
		"夹持/复位用钳",
		"夹子装置",
		"家用呼吸机",
		"家用呼吸支持设备",
		"甲醛灭菌器",
		"间接免疫荧光分析仪器",
		"肩关节假体",
		"监护软件",
		"监护设备",
		"检验及其他辅助设备",
		"简易转移器械",
		"胶带",
		"胶囊内窥镜姿态控制器",
		"胶囊式内窥镜系统",
		"胶片观察装置",
		"胶片扫描仪",
		"角膜地形图仪",
		"角膜共焦显微镜",
		"角膜基质环",
		"角膜基质片",
		"角膜内皮细胞显微镜",
		"矫治器具及附件",
		"接触镜",
		"接触镜护理产品",
		"洁净工作台",
		"洁净屏",
		"洁治器具",
		"结扎手术器械",
		"截骨用刀",
		"介入术用骨锥",
		"金属固定环扎装置",
		"金属髓内装置",
		"金属填充物",
		"紧固、支撑工具",
		"近距离后装治疗设备",
		"经鼻肠营养导管",
		"经皮肠营养导管",
		"精子分析仪器",
		"静磁场治疗器具",
		"静电贴敷器具",
		"静脉尿路造影腹压器",
		"静脉输液针",
		"静脉血样采血管",
		"灸疗器具",
		"灸疗设备",
		"决策支持软件",
		"菌斑/龋齿指示剂",
		"开口器械",
		"开口用锥",
		"康复训练床",
		"康复训练软件",
		"抗鼻腔过敏凝胶",
		"可吸收缝合线",
		"可吸收外科防粘连敷料",
		"可吸收外科敷料",
		"可吸收外科止血材料",
		"口腔X射线机",
		"口腔车针、钻",
		"口腔成像辅助器具",
		"口腔成像设备",
		"口腔充填修复材料",
		"口腔分离牵开用具",
		"口腔隔离器具",
		"口腔洁治清洗设备及附件",
		"口腔溃疡、组织创面愈合治疗辅助材料",
		"口腔麻醉推注设备",
		"口腔清洗器具",
		"口腔手术刀、凿",
		"口腔手术剪",
		"口腔义齿制作材料",
		"口腔用镜",
		"口腔用镊、夹",
		"口腔用钳",
		"口腔照明设备",
		"口腔针",
		"口腔诊察器具",
		"口腔诊察设备",
		"口腔正畸材料及制品",
		"口腔植入及组织重建材料",
		"口腔治疗辅助材料",
		"口腔治疗器具",
		"口腔治疗设备",
		"口腔注射用具",
		"口腔综合治疗设备配件",
		"口咽/鼻咽通气道",
		"叩诊锤",
		"髋关节假体",
		"扩孔用刀",
		"扩髓器",
		"扩髓用钻",
		"扩张导管",
		"扩张器",
		"扩张钳",
		"拉钩",
		"蜡",
		"蓝光治疗设备",
		"泪道管",
		"泪点塞",
		"冷冻手术设备",
		"冷冻手术设备及附件",
		"冷冻消融针及导管",
		"离心泵泵头",
		"离心式血液成分分离器",
		"力疗设备/器具",
		"连接阀",
		"连接器套筒",
		"连续性血液净化设备",
		"临时充填材料",
		"临时起搏电极导线",
		"临时起搏器",
		"流式点阵仪器",
		"流式细胞分析仪器",
		"流式细胞术样本裂解仪",
		"漏斗胸成形系统",
		"颅骨夹/锁",
		"颅骨矫形器械",
		"颅脑外引流收集装置",
		"颅内弹簧圈系统",
		"颅内动脉瘤血流导向装置",
		"颅内栓塞器械",
		"颅内支架系统",
		"麻醉储气囊",
		"麻醉穿刺针",
		"麻醉废气吸附器",
		"麻醉机",
		"麻醉面罩",
		"麻醉气体净化传递和收集系统",
		"麻醉器械",
		"麻醉蒸发器",
		"埋线针",
		"脉搏血氧测量设备",
		"脉搏血氧传感器",
		"酶联免疫分析仪器",
		"泌尿、消化动力学测量、分析设备",
		"泌尿X射线机",
		"免缝闭合器械",
		"免疫层析分析仪器",
		"免疫分析设备",
		"免疫分析一体机",
		"免疫散射浊度分析仪器",
		"免疫印迹仪器",
		"模型材料",
		"末梢采血管",
		"末梢采血针",
		"末梢血采集容器",
		"囊袋张力环",
		"囊袋张力环植入器械",
		"脑磁图设备",
		"脑积水分流器及组件",
		"内窥镜插入形状观测系统",
		"内窥镜冲洗吸引器",
		"内窥镜辅助用品",
		"内窥镜功能供给装置",
		"内窥镜膨腔泵",
		"内窥镜气囊控制器",
		"内窥镜切口牵开保护器",
		"内窥镜取样针",
		"内窥镜润滑剂",
		"内窥镜摄像系统",
		"内窥镜手术用有源设备",
		"内窥镜送气装置",
		"内窥镜先端帽",
		"内窥镜咬口、套管",
		"内窥镜用剥离器",
		"内窥镜用导引器",
		"内窥镜用分离钳",
		"内窥镜用给物器",
		"内窥镜用钩",
		"内窥镜用活检袋",
		"内窥镜用剪",
		"内窥镜用冷光源",
		"内窥镜用气囊导管",
		"内窥镜用气囊扩张器",
		"内窥镜用器械钳",
		"内窥镜用牵开器",
		"内窥镜用取石器械",
		"内窥镜用取石球囊导管",
		"内窥镜用取样钳",
		"内窥镜用套扎器",
		"内窥镜用推结器",
		"内窥镜用吻",
		"内窥镜用细胞刷",
		"内窥镜用异物钳",
		"内窥镜用组织刮匙",
		"内窥镜用组织钳",
		"尿液分析系统",
		"尿液及其他样本分析设备",
		"尿液有形成分分析仪器",
		"颞下颌关节假体",
		"凝胶",
		"凝血分析仪器",
		"排气针",
		"排线器",
		"排龈材料",
		"刨骨器",
		"培养与孵育设备",
		"配套工具",
		"盆底肌肉训练设备",
		"皮肤针",
		"皮内针",
		"平衡测试设备",
		"平衡训练设备",
		"屏障式避孕器械",
		"其他测量、分析设备",
		"其他化学消毒灭菌器",
		"其他口腔材料",
		"其他手术设备",
		"其他体液分析仪器",
		"其他体液形态学分析仪器",
		"其他物理治疗设备",
		"其他眼科治疗和手术设备",
		"其他样本采集器具",
		"其他医用分析设备",
		"其他转移器械",
		"其它器械",
		"起搏系统分析设备",
		"气道过敏反应测试设备",
		"气动急救复苏器",
		"气管插管用喉镜",
		"气管内插管/气管套管",
		"气囊式体外反搏装置",
		"气体测定设备",
		"器械夹",
		"器械剪",
		"器械镊",
		"器械钳",
		"牵开器",
		"牵引器",
		"牵引器具",
		"牵引钳",
		"牵引针",
		"牵引治疗设备",
		"腔静脉滤器",
		"腔静脉滤器回收装置",
		"强脉冲光治疗设备",
		"敲拔器械",
		"切/取骨钻",
		"切割球囊",
		"切割针",
		"青光眼引流装置",
		"清洁器",
		"清洗、灌洗、吸引、给药器械",
		"清洗消毒器",
		"清洗消毒设备",
		"球囊扩张导管",
		"球囊扩张导管用球囊充压装置",
		"取、植皮设备",
		"取片机",
		"取样器械",
		"取样钳",
		"龋齿探测设备",
		"去冠器",
		"热传导治疗设备",
		"热辐射灭菌器",
		"热辐射治疗设备",
		"热交换设备",
		"热空气灭菌器",
		"热空气消毒器",
		"热湿交换器",
		"人工玻璃体球囊",
		"人工复苏器",
		"人工肝设备",
		"人工晶状体",
		"人工晶状体、人工玻璃体植入器械",
		"人工颅骨",
		"人工心脏瓣膜及瓣膜修复器械",
		"人工血管",
		"人体阻抗测量、分析设备",
		"认知言语视听障碍康复设备",
		"认知障碍康复设备",
		"韧带手术器械",
		"妊娠控制器械",
		"乳房植入物",
		"乳腺X射线机",
		"软骨整形器械",
		"软组织扩张器",
		"润滑剂及载体",
		"三棱针",
		"扫描图像分析系统",
		"色谱柱",
		"筛查、分析软件",
		"烧烫伤浸浴装置",
		"舌肌康复训练器",
		"射频浅表治疗设备",
		"射频热疗设备",
		"射频消融设备",
		"射频消融设备用灌注泵",
		"射线束扫描测量系统",
		"摄影X射线机",
		"神经调控程控设备",
		"神经调控充电设备",
		"神经调控设备",
		"神经和肌肉刺激器用电极",
		"神经和心血管手术器械-剥离器",
		"神经和心血管手术器械-冲吸器",
		"神经和心血管手术器械-穿刺导引器",
		"神经和心血管手术器械-刀",
		"神经和心血管手术器械-钩",
		"神经和心血管手术器械-刮匙",
		"神经和心血管手术器械-夹",
		"神经和心血管手术器械-剪",
		"神经和心血管手术器械-镊",
		"神经和心血管手术器械-其他器械",
		"神经和心血管手术器械-牵开器",
		"神经和心血管手术器械-钳",
		"神经和心血管手术器械-心血管介入器械",
		"神经和心血管手术器械-针",
		"神经监护设备",
		"神经内/外科植入物",
		"神经修复材料",
		"肾及甲状腺功能测量设备",
		"渗透压测定仪器",
		"生化分析设备",
		"生化分析仪器",
		"生化免疫分析仪器",
		"生理参数分析测量设备",
		"生理参数诱发诊断设备",
		"生理信号处理软件",
		"生物安全柜",
		"生物反馈治疗设备",
		"生物芯片分析仪器",
		"生殖道分泌物分析仪器",
		"施夹器",
		"施源器",
		"湿热消毒灭菌设备",
		"石膏拆除器械",
		"石膏锯",
		"石膏切割器具",
		"石膏切割用刀",
		"食道气管插管",
		"试模",
		"视功能检查设备和器具",
		"视光设备和器具",
		"视觉康复设备",
		"视觉治疗设备",
		"手柄",
		"手部防护用品",
		"手动病床",
		"手动测量器械",
		"手动测量用器械",
		"手动防压疮垫",
		"手动手术台",
		"手动推车、担架等器械",
		"手动诊疗台及诊疗椅",
		"手术叉",
		"手术锉",
		"手术单",
		"手术刀",
		"手术导航、控制系统",
		"手术导航系统",
		"手术定位系统",
		"手术动力系统",
		"手术钩",
		"手术刮匙",
		"手术环",
		"手术计划软件",
		"手术锯",
		"手术控制系统",
		"手术膜",
		"手术器械-剥离器",
		"手术器械-冲吸器",
		"手术器械-穿刺导引器",
		"手术器械-钩",
		"手术器械-刮匙",
		"手术器械-夹",
		"手术器械-剪",
		"手术器械-镊",
		"手术器械-其他器械",
		"手术器械-牵开器",
		"手术器械-钳",
		"手术器械-吻合器械及材料",
		"手术器械-针",
		"手术室感染控制用品",
		"手术室用衣帽",
		"手术台",
		"手术显微镜",
		"手术针",
		"输卵管封闭器械",
		"输尿管支架",
		"输送导引器",
		"输血器",
		"输氧面罩",
		"输液、输血用连接件及附件",
		"输液泵",
		"输液袋",
		"输液辅助电子设备",
		"输液连接管路",
		"输液器",
		"输液信息采集系统",
		"输液用放气针",
		"术中牵引架及配件",
		"数据处理软件",
		"水刀",
		"水门汀",
		"睡眠呼吸监测设备",
		"睡眠呼吸暂停治疗设备",
		"塑形工具",
		"酸碱度检测设备",
		"酸蚀剂",
		"酸性氧化电位水生成器",
		"探针",
		"套扎器",
		"套针外周导管",
		"体表电极",
		"体表器械固定装置",
		"体表色素测量设备",
		"体外除颤设备",
		"体外辅助生殖用液",
		"体外声音处理器",
		"体外心肺支持辅助系统",
		"体外心肺支持用升温仪",
		"体外引流、吸引管",
		"体外诊断类软件",
		"体温测量设备",
		"听觉检查音叉",
		"听觉康复设备",
		"听力计",
		"听小骨假体",
		"听诊器",
		"通气辅助器械",
		"通条",
		"同种异体骨修复材料",
		"头皮夹",
		"透视X射线机",
		"透视摄影X射线机",
		"透视摄影床",
		"透视荧光屏",
		"图像分析仪器",
		"图像扫描仪器",
		"图像显示、处理、传输及打印设备",
		"图像显示处理工作站",
		"涂抹及吸液材料",
		"推结器",
		"托槽",
		"脱敏剂",
		"脱细胞皮肤",
		"脱细胞真皮基质",
		"外固定及牵引器械",
		"外固定支架",
		"外科补片/外科修补网",
		"外科非织造布敷料",
		"外科海绵敷料",
		"外科口罩",
		"外科手套",
		"外科织造布类敷料",
		"腕关节假体",
		"微波手术设备",
		"微波治疗设备",
		"微创骨导引器",
		"微创入路装置",
		"微导管",
		"微量元素分析仪器",
		"微生物比浊仪器",
		"微生物分析设备",
		"微生物鉴定药敏分析仪器",
		"微生物鉴定仪器",
		"微生物培养监测仪器",
		"微生物药敏培养监测仪器",
		"微生物质谱鉴定仪器",
		"微栓过滤器",
		"微循环显微镜",
		"胃肠X射线检查用品",
		"胃肠超声显像粉",
		"胃隐血采集器具",
		"温热治疗设备/器具",
		"温针治疗设备",
		"吻合器",
		"无创血流分析设备",
		"无创血压测量设备",
		"无创血压袖带",
		"无菌接管机",
		"无菌注射器",
		"无源患者手术位置固定辅助器械",
		"无源输注泵",
		"无源止血带",
		"无源止血器",
		"无针注射器",
		"五官科检查镜",
		"物理降温设备",
		"雾化面罩",
		"雾化设备/雾化装置",
		"吸潮纸尖",
		"吸入镇痛装置",
		"吸氧头罩",
		"吸引器",
		"膝关节假体",
		"洗板机",
		"细菌内毒素/真菌葡聚糖检测仪器",
		"限束装置",
		"小针刀",
		"携带式X射线机",
		"心电测量、分析设备",
		"心电导联线",
		"心肺复苏设备",
		"心肺转流监测设备",
		"心肺转流器具",
		"心肺转流设备",
		"心肺转流用泵",
		"心肺转流用管路及接头",
		"心血管补片",
		"心血管功能检测设备",
		"心血管栓塞器械",
		"心血管植入物",
		"心脏电生理标测设备",
		"心脏封堵器",
		"心脏封堵器输送线缆",
		"心脏封堵器装载器",
		"心脏节律管理程控设备",
		"心脏节律管理设备",
		"心脏停跳液",
		"心脏停跳液灌注器",
		"芯钻",
		"形态学分析前样本处理设备",
		"胸骨捆扎/抓扣固定系统",
		"胸腔引流装置",
		"修补固定器",
		"修整用钻",
		"悬吊、支撑装置",
		"穴位磁疗器具",
		"穴位电刺激设备",
		"穴位激光刺激设备",
		"穴位微波刺激设备",
		"穴位压力刺激器具",
		"血袋",
		"血管缝合装置",
		"血管内回收装置",
		"血管内假体",
		"血管内留置针",
		"血管内皮功能测试设备",
		"血管内输液器械",
		"血管显像设备",
		"血管硬度测量设备",
		"血管造影X射线机",
		"血管支架",
		"血浆病毒灭活设备",
		"血浆管路",
		"血流变分析仪器",
		"血气分析仪器",
		"血栓抽吸导管",
		"血糖及血糖相关参数分析仪器",
		"血细胞处理设备",
		"血细胞分析前样本处理仪器",
		"血细胞分析仪器",
		"血细胞形态分析仪器",
		"血小板分析仪器",
		"血小板振荡器",
		"血型分析仪器",
		"血液采集卡",
		"血液成分分离设备",
		"血液分离、处理、贮存器具",
		"血液分离、处理、贮存设备",
		"血液辐照设备",
		"血液灌流器具",
		"血液灌流设备",
		"血液净化辅助器具",
		"血液净化及腹膜透析器具",
		"血液净化及腹膜透析设备",
		"血液浓缩器",
		"血液融化设备",
		"血液透析辅助设备",
		"血液透析器具",
		"血液透析设备",
		"血液学分析设备",
		"血脂分离器具",
		"血脂分离设备",
		"熏蒸治疗设备",
		"循环肿瘤细胞分析仪器",
		"压力绷带",
		"压力蒸汽灭菌器",
		"压迫器",
		"压器",
		"压舌板",
		"压缩钳",
		"牙本质测量设备",
		"牙齿漂白材料",
		"牙科锉",
		"牙科分离剂",
		"牙科膜片",
		"牙科手机及附件",
		"牙科用椅",
		"牙科治疗机",
		"牙髓活力测试剂",
		"牙髓活力测试设备",
		"牙挺",
		"牙托梗",
		"牙种植体",
		"牙周袋探测设备",
		"牙周塞治剂",
		"氩保护气凝设备",
		"延长管",
		"言语障碍测量设备",
		"言语障碍康复设备",
		"研磨抛光材料",
		"眼科测量诊断设备和器具",
		"眼科超声手术设备",
		"眼科超声诊断设备",
		"眼科激光治疗设备",
		"眼科矫治和防护器具",
		"眼科冷冻治疗设备",
		"眼科内窥镜及附件",
		"眼科无源手术器械",
		"眼科诊断辅助器具",
		"眼科植入物及辅助器械",
		"眼科治疗和手术辅助器具",
		"眼科治疗和手术设备、辅助器具",
		"眼内填充物",
		"眼贴",
		"眼用剥离器",
		"眼用铲",
		"眼用冲吸器",
		"眼用刀",
		"眼用钩",
		"眼用刮匙",
		"眼用夹",
		"眼用剪",
		"眼用锯",
		"眼用扩张器",
		"眼用镊",
		"眼用牵开器",
		"眼用钳",
		"眼用凿",
		"眼用粘弹剂",
		"眼用针",
		"眼用钻",
		"眼震电图设备",
		"厌氧培养系统",
		"验光设备和器具",
		"氧合器",
		"氧气发生器",
		"氧气吸入器",
		"样本处理系统",
		"样本分离设备",
		"遥测和中央监护设备",
		"遥测监护设备",
		"咬骨钳",
		"咬合关系记录/检查材料",
		"咬口",
		"药物导入设备",
		"药液用转移、配药器具",
		"液体闪烁计数器",
		"液相色谱分析仪器",
		"医护人员防护用品",
		"医学显微影像分析软件",
		"医学影像处理软件",
		"医学影像存储与传输系统软件",
		"医用X射线治疗设备",
		"医用病床",
		"医用导管夹",
		"医用电动吸引器械",
		"医用电子加速器",
		"医用防护衬垫",
		"医用分子筛制氧机",
		"医用分子筛制氧系统",
		"医用妇科护垫",
		"医用供气排气相关设备",
		"医用光学放大器具",
		"医用呼吸道湿化器",
		"医用激光光纤",
		"医用空气压缩机",
		"医用离心机",
		"医用轮椅车",
		"医用膜分离制氧机",
		"医用膜分离制氧系统",
		"医用内窥镜",
		"医用培养/恒温箱",
		"医用气体报警系统",
		"医用气体汇流排",
		"医用气体混合器",
		"医用轻离子治疗系统",
		"医用清洗器",
		"医用人工驱动吸引器械",
		"医用射线防护设备",
		"医用射线防护用具",
		"医用射线防护装置",
		"医用生物防护设备",
		"医用图像打印机",
		"医用显微镜",
		"医用压缩气体供应系统",
		"医用氧舱",
		"医用婴儿床",
		"医用增感屏",
		"医用制氧设备",
		"医用中心吸引系统",
		"胰岛素泵",
		"胰岛素泵用储液器",
		"胰岛素泵用皮下输液器",
		"移动式C形臂X射线机",
		"以负压源或压力源为动力吸引器械",
		"义齿试用材料",
		"义齿用高分子材料及制品",
		"义齿用金属材料及制品",
		"义齿用陶瓷材料及制品",
		"义眼片",
		"义眼台",
		"异物钳",
		"阴道镜",
		"阴道填塞材料",
		"阴道洗涤器/给药器",
		"阴茎假体",
		"银汞合金",
		"引流袋（容器）/收集袋（容器）、粪便管理器械",
		"引流袋、粪便管理器械",
		"引流导管",
		"印模材料",
		"婴儿辐射保暖台",
		"婴儿光疗防护眼罩",
		"婴儿培养箱",
		"荧光免疫分析仪器",
		"影像板",
		"影像处理软件",
		"影像记录介质",
		"硬膜外麻醉导管",
		"硬脑膜补片",
		"永磁型磁共振成像系统",
		"幽门螺旋杆菌分析仪器",
		"有创颅内压设备",
		"有创血压传感器",
		"有源止血器",
		"与非血管内导管配套用体外器械",
		"预充式导管冲洗器",
		"预处理剂",
		"远程监护设备",
		"远端保护器",
		"运动康复训练器械",
		"运动损伤软组织修复重建及置换植入物",
		"运动损伤软组织修复重建植入物",
		"运动损伤软组织置换植入物",
		"造口、疤痕护理用品",
		"造口护理及辅助器械",
		"造影导管",
		"造影剂注射装置",
		"造影球囊",
		"摘除镊",
		"粘堵剂",
		"粘合剂",
		"粘接剂",
		"针灸针",
		"真耳测试仪",
		"真空负压机",
		"诊察辅助器械",
		"诊断X射线机",
		"诊疗台",
		"振动训练设备",
		"蒸汽消毒器",
		"整形及普通外科植入物",
		"整形填充材料",
		"整形用注射填充物",
		"正电子发射断层成像设备",
		"正电子发射及X射线计算机断层成像系统",
		"正电子发射及磁共振成像系统",
		"正畸材料处理器械",
		"正畸弹簧",
		"正畸弹性体附件",
		"正畸基托聚合物",
		"正畸丝",
		"支气管堵塞器",
		"支气管内活瓣",
		"肢体数字化体层摄影X射线机",
		"直肠管",
		"直流电治疗设备",
		"植骨器械",
		"植皮器",
		"植入取出工具",
		"植入式电极导线补件",
		"植入式电极导线适配工具",
		"植入式电极导线移除工具",
		"植入式封堵工具",
		"植入式给药器械",
		"植入式神经刺激电极",
		"植入式神经刺激器",
		"植入式位听觉设备",
		"植入式心律转复除颤器",
		"植入式心脏除颤电极导线",
		"植入式心脏起搏电极导线",
		"植入式心脏起搏器",
		"植入式心脏事件监测设备",
		"植入式心脏收缩力调节设备",
		"植入式循环辅助设备",
		"植入式药物输注设备",
		"植入物或石膏用剪",
		"植入物塑形用钳",
		"植入性止鼾装置",
		"止血夹",
		"止血器具",
		"止血钳",
		"指关节假体",
		"质谱检测系统",
		"治疗辅助器具",
		"治疗呼吸机",
		"治疗机用X射线管",
		"治疗计划软件",
		"中心静脉导管",
		"中央监护系统",
		"中医器具",
		"中医治疗设备",
		"种植辅助材料",
		"种植体安装辅助器械",
		"种植体密封材料",
		"种植支抗",
		"肘关节假体",
		"煮沸消毒器",
		"助产器械",
		"助讲器",
		"助视器",
		"助听器",
		"助行器械",
		"贮血滤血器",
		"注射、穿刺器械",
		"注射泵",
		"注射器辅助推动装置",
		"注射针",
		"铸造包埋材料",
		"椎间盘假体",
		"椎间融合器",
		"椎体成形器械",
		"椎体后缘处理器",
		"准直限束装置",
		"子宫操纵器",
		"子宫输卵管造影、输卵管通液器械",
		"紫外线消毒器",
		"紫外线消毒设备",
		"紫外治疗设备",
		"自动给药系统",
		"自动加样系统",
		"自体血液处理器具",
		"自体血液回收设备",
		"足部隔离用品",
		"足跟采血器",
		"组合功能融合成像器械",
		"组织工程生物羊膜",
		"组织工程支架材料",
		"组织剪",
		"组织镊",
		"组织钳",
		"组织用钳",
		"钻孔用钻",
	}
	it := sess.DB(save_mgo.DbName).C("zktest_bdw_words").Find(&q).Sort("_id").Iter()
	for tmp := make(map[string]interface{}); it.Next(&tmp); total++ {
		productArr = append(productArr, qu.ObjToString(tmp["product_name"]))
		tmp = make(map[string]interface{})
	}
	log.Debug("产品名称~", len(productArr))

	total = 0
	it = sess.DB(save_mgo.DbName).C("zktest_purchasing_3_data").Find(&q).Sort("_id").Iter()
	for tmp := make(map[string]interface{}); it.Next(&tmp); total++ {
		if total%1000 == 0 {
			log.Debug("cur index ", total)
		}
		//是否存在标的物
		p_list := []map[string]interface{}{}
		if purchasinglist, ok := tmp["purchasinglist"].(primitive.A); ok {
			p_list = qu.ObjArrToMapArr(purchasinglist)
		} else {
			if purchasinglist, ok := tmp["purchasinglist"].([]interface{}); ok {
				p_list = qu.ObjArrToMapArr(purchasinglist)
			}
		}
		new_p_list := []map[string]interface{}{}
		if len(p_list) > 0 { //筛选有效信息
			for _, v := range p_list {
				itemname := qu.ObjToString(v["itemname"])
				isExist := false
				for _, v := range productArr {
					product_name := qu.ObjToString(v)
					if strings.Contains(itemname, product_name) ||
						strings.Contains(product_name, itemname) {
						isExist = true
						break
					}
				}
				if isExist {
					new_p_list = append(new_p_list, v)
				}
			}
		}
		delete(tmp, "purchasinglist")
		if len(new_p_list) > 0 {
			tmp["purchasinglist"] = new_p_list
		}

		save_mgo.Save("zktest_purchasing_3_data_new", tmp)

		tmp = make(map[string]interface{})
	}

	log.Debug("is over ... ")
}

//补标的物的数据
func repairWinnerBdwData() {
	//elastic.InitElasticSize("http://127.0.0.1:12003",10)
	elastic.InitElasticSize("http://172.17.145.170:9800", 10)
	sess := save_mgo.GetMgoConn()
	defer save_mgo.DestoryMongoConn(sess)
	q, total := map[string]interface{}{}, 0
	it := sess.DB(save_mgo.DbName).C("zktest_purchasing_3_data").Find(&q).Sort("_id").Iter()
	for tmp := make(map[string]interface{}); it.Next(&tmp); total++ {
		tmpid := BsonTOStringId(tmp["_id"])
		if total%1000 == 0 {
			log.Debug("cur index ", total, "~", tmpid)
		}
		data := *elastic.GetByIdField("bidding", "bidding", tmpid, `"area","city","buyer","budget"`)
		if data != nil && len(data) > 0 {
			save_mgo.UpdateById("zktest_purchasing_3_data", tmpid, map[string]interface{}{
				"$set": data,
			})
		}
		tmp = make(map[string]interface{})
	}
}

func exportProductWinnerData() {
	//elastic.InitElasticSize("http://127.0.0.1:12003",10)
	elastic.InitElasticSize("http://172.17.145.170:9800", 10)
	sess := save_mgo.GetMgoConn()
	defer save_mgo.DestoryMongoConn(sess)
	q, total := map[string]interface{}{}, 0
	it := sess.DB(save_mgo.DbName).C("20211223test1").Find(&q).Iter()
	for tmp := make(map[string]interface{}); it.Next(&tmp); total++ {
		company := qu.ObjToString(tmp["_id"])
		query := fmt.Sprintf(`{"query":{"filtered":{"filter":{"bool":{"must":[{"terms":{"subtype":["单一","成交","中标","合同"]}},{"range":{"publishtime":{"gte":1546272000}}},{"term":{"winner":"%s"}}]}}}},"_source":["bidamount","_id","href","purchasinglist"],"size":"1000000"}`, company)
		if total%100 == 0 {
			log.Debug("cur index ", query)
		}

		resArr := *elastic.GetNoLimit("bidding", "bidding", query)
		log.Debug("第", total, "组~查询~", len(resArr))
		if len(resArr) > 0 {
			for _, v := range resArr {
				tmpid := qu.ObjToString(v["_id"])
				delete(v, "_id")
				v["_id"] = StringTOBsonId(tmpid)
				v["winner"] = company
				v["jyhref"] = fmt.Sprintf(Url, qu.CommonEncodeArticle("content", tmpid))
				save_mgo.Save("zktest_purchasing_3_data", v)
			}
		}
		tmp = make(map[string]interface{})
	}

	log.Debug("is over ", total)
}

//处理-企业-金额数据-zktest_purchasing_1
func dealWithQyBidData() {
	sess := save_mgo.GetMgoConn()
	defer save_mgo.DestoryMongoConn(sess)
	q, total := map[string]interface{}{}, 0
	it := sess.DB(save_mgo.DbName).C("zktest_qy_product_data").Find(&q).Iter()
	for tmp := make(map[string]interface{}); it.Next(&tmp); total++ {
		if total%10000 == 0 {
			log.Debug("cur index ", total)
		}
		company := qu.ObjToString(tmp["company"])
		dataArr, _ := save_mgo.Find("zktest_purchasing_1", map[string]interface{}{"winner": company}, nil, map[string]interface{}{
			"_id":            1,
			"budget":         1,
			"bidamount":      1,
			"buyer":          1,
			"purchasinglist": 1,
			"site":           1,
			"title":          1,
			"href":           1,
		})
		if len(dataArr) > 0 {
			for _, v := range dataArr {
				tmpid := BsonTOStringId(v["_id"])
				jyhref := fmt.Sprintf(Url, qu.CommonEncodeArticle("content", tmpid))
				delete(v, "_id")
				v["source_id"] = tmpid
				v["company"] = company
				v["jyhref"] = jyhref
				save_mgo.Save("zktest_purchasing_1_data", v)
			}
		}

		tmp = make(map[string]interface{})
	}

	log.Debug("is over ", total)
}

//处理-企业-标的物-金额数据-zktest_purchasing_2
func dealWithQyBdwBidData() {
	sess := save_mgo.GetMgoConn()
	defer save_mgo.DestoryMongoConn(sess)
	q, total := map[string]interface{}{}, 0
	it := sess.DB(save_mgo.DbName).C("zktest_qy_product_data").Find(&q).Iter()
	for tmp := make(map[string]interface{}); it.Next(&tmp); total++ {
		if total%10000 == 0 {
			log.Debug("cur index ", total)
		}
		company := qu.ObjToString(tmp["company"])
		productArr := []interface{}{}
		if arr, ok := tmp["product"].(primitive.A); ok {
			productArr = arr
		} else {
			if arr, ok := tmp["product"].([]interface{}); ok {
				productArr = arr
			}
		}
		dataArr, _ := save_mgo.Find("zktest_purchasing_2", map[string]interface{}{"winner": company}, nil, map[string]interface{}{
			"_id":            1,
			"purchasinglist": 1,
			"bidamount":      1,
			"href":           1,
		})

		if len(dataArr) > 0 {
			save_data := dealWithProductEnable(productArr, dataArr)
			if len(save_data) > 0 {
				for _, v := range save_data {
					tmpid := BsonTOStringId(v["_id"])
					jyhref := fmt.Sprintf(Url, qu.CommonEncodeArticle("content", tmpid))
					delete(v, "_id")
					v["source_id"] = tmpid
					v["company"] = company
					v["jyhref"] = jyhref
					save_mgo.Save("zktest_purchasing_2_data", v)
				}
			}
		}

		tmp = make(map[string]interface{})
	}

	log.Debug("is over ", total)
}

//有效产品数据-整理
func dealWithProductEnable(productArr []interface{}, dataArr []map[string]interface{}) []map[string]interface{} {
	save_data := []map[string]interface{}{}
	for _, tmp := range dataArr {
		p_list := []map[string]interface{}{}
		if purchasinglist, ok := tmp["purchasinglist"].(primitive.A); ok {
			p_list = qu.ObjArrToMapArr(purchasinglist)
		} else {
			if purchasinglist, ok := tmp["purchasinglist"].([]interface{}); ok {
				p_list = qu.ObjArrToMapArr(purchasinglist)
			}
		}

		new_p_list := []map[string]interface{}{}
		if len(p_list) > 0 { //筛选有效信息
			for _, v := range p_list {
				itemname := qu.ObjToString(v["itemname"])
				isExist := false
				for _, v := range productArr {
					product_name := qu.ObjToString(v)
					if strings.Contains(itemname, product_name) ||
						strings.Contains(product_name, itemname) {
						isExist = true
						break
					}
				}

				if isExist {
					new_p_list = append(new_p_list, v)
				}
			}
		}
		delete(tmp, "purchasinglist")
		if len(new_p_list) > 0 {
			tmp["purchasinglist"] = new_p_list
			save_data = append(save_data, tmp)
		}
	}
	return save_data
}

//处理企业数据-
func dealWithNmpData() {
	sess := save_mgo.GetMgoConn()
	defer save_mgo.DestoryMongoConn(sess)
	q, total := map[string]interface{}{}, 0
	it := sess.DB(save_mgo.DbName).C("nmp_qy").Find(&q).Iter()
	for tmp := make(map[string]interface{}); it.Next(&tmp); total++ {
		if total%1000 == 0 {
			log.Debug("cur index ", total)
		}
		company := qu.ObjToString(tmp["company"])
		product := []interface{}{}
		dataArr, _ := save_mgo.Find("nmp_detail", map[string]interface{}{"reg_company": company}, nil, nil)
		if len(dataArr) > 0 {
			product = dealWithProductName(dataArr)
		}
		save_mgo.Save("zktest_qy_product_data", map[string]interface{}{
			"company": company,
			"product": product,
		})

		tmp = make(map[string]interface{})
	}

	log.Debug("is over ...")
}
func dealWithProductName(data []map[string]interface{}) []interface{} {
	productArr := []interface{}{}
	dict := map[string]interface{}{}
	for _, v := range data {
		product_name := qu.ObjToString(v["product_name"])
		if dict[product_name] == nil {
			productArr = append(productArr, product_name)
			dict[product_name] = 1
		}
	}
	return productArr
}

//导出es数据标的物
func exportAllPurchasingData() {
	//elastic.InitElasticSize("http://127.0.0.1:12003",10)
	elastic.InitElasticSize("http://172.17.145.170:9800", 10)
	words := []string{}
	//sess := save_mgo.GetMgoConn()
	//defer save_mgo.DestoryMongoConn(sess)
	//q,total:=map[string]interface{}{},0
	//it := sess.DB(save_mgo.DbName).C("zktest_bdw_new_words").Find(&q).Iter()
	//for tmp := make(map[string]interface{}); it.Next(&tmp);total++{
	//	word := qu.ObjToString(tmp["product_name"])
	//	if !strings.Contains(word,`"`) &&!strings.Contains(word,`\`) {
	//		words = append(words,qu.ObjToString(tmp["product_name"]))
	//	}
	//	tmp = make(map[string]interface{})
	//}
	log.Debug("搜索词~", len(words))

	total_1, total_2 := 0, 0
	upsertArr_1, upsertArr_2 := [][]map[string]interface{}{}, [][]map[string]interface{}{}
	for k, v := range words {

		query_1 := fmt.Sprintf(`{"query":{"filtered":{"filter":{"bool":{"must":[{"terms":{"subtype":["单一","成交","中标","合同"]}},{"range":{"publishtime":{"gte":1546272000}}}]}},"query":{"bool":{"should":[{"multi_match":{"query":"%s","type":"phrase","fields":["purchasing","title","detail"]}}]}}}},"size": "1000000","_source":{"exclude":["detail","filetext"]}}`, v)
		query_2 := fmt.Sprintf(`{"query":{"filtered":{"filter":{"bool":{"must":[{"terms":{"subtype":["单一","成交","中标","合同"]}},{"range":{"publishtime":{"gte":1546272000}}}]}},"query":{"bool":{"should":[{"multi_match":{"query":"%s","type":"phrase","fields":["purchasing"]}}]}}}},"size": "1000000","_source":{"exclude":["detail","filetext"]}}`, v)
		resArr_1 := *elastic.GetNoLimit("bidding", "bidding", query_1)
		resArr_2 := *elastic.GetNoLimit("bidding", "bidding", query_2)
		num_1, num_2 := len(resArr_1), len(resArr_2)
		total_1 += num_1
		total_2 += num_2

		for _, v := range resArr_1 {
			tmpid := qu.ObjToString(v["_id"])
			delete(v, "_id")
			v["_id"] = StringTOBsonId(tmpid)
			if len(upsertArr_1) >= 200 {
				save_mgo.UpSertBulk("zktest_purchasing_1", upsertArr_1...)
				upsertArr_1 = [][]map[string]interface{}{}
			} else {
				upsertArr_1 = append(upsertArr_1, []map[string]interface{}{
					map[string]interface{}{
						"_id": StringTOBsonId(tmpid),
					},
					v,
				})
			}
		}

		for _, v := range resArr_2 {
			tmpid := qu.ObjToString(v["_id"])
			delete(v, "_id")
			if len(upsertArr_2) >= 200 {
				save_mgo.UpSertBulk("zktest_purchasing_2", upsertArr_2...)
				upsertArr_2 = [][]map[string]interface{}{}
			} else {
				upsertArr_2 = append(upsertArr_2, []map[string]interface{}{
					map[string]interface{}{
						"_id": StringTOBsonId(tmpid),
					},
					v,
				})
			}
		}
		if len(upsertArr_1) > 0 {
			save_mgo.UpSertBulk("zktest_purchasing_1", upsertArr_1...)
			upsertArr_1 = [][]map[string]interface{}{}
		}
		if len(upsertArr_2) > 0 {
			save_mgo.UpSertBulk("zktest_purchasing_2", upsertArr_2...)
			upsertArr_2 = [][]map[string]interface{}{}
		}
		log.Debug("第", k, "组", "~", v, "~查询量:", num_1, "~", num_2, "~总计:", total_1, total_2)
	}

	if len(upsertArr_1) > 0 {
		save_mgo.UpSertBulk("zktest_purchasing_1", upsertArr_1...)
	}
	if len(upsertArr_2) > 0 {
		save_mgo.UpSertBulk("zktest_purchasing_2", upsertArr_2...)
	}

	time.Sleep(10 * time.Second)
	log.Debug("is over ... ...")
}

//导出标的物-相关数据
func exportNewPurchasingList() {
	sess := save_mgo.GetMgoConn()
	defer save_mgo.DestoryMongoConn(sess)
	q, total := map[string]interface{}{
		"total": map[string]interface{}{
			"$gt": 0,
		},
	}, 0
	it_word := sess.DB(save_mgo.DbName).C("product_all").Find(&q).Iter()
	for tmp := make(map[string]interface{}); it_word.Next(&tmp); total++ {
		word := qu.ObjToString(tmp["product_name"])
		wordsArr = append(wordsArr, word)
		tmp = make(map[string]interface{})
	}
	log.Debug("准备搜索词完毕： ", total, len(wordsArr))

	total, q = 0, map[string]interface{}{}
	isExist, isUnExist := 0, 0

	//写邮件
	os.Remove("新整体统计.xlsx")
	f := xlsx.NewFile()
	sheet_1, _ := f.AddSheet("标的物存在")
	sheet_2, _ := f.AddSheet("标的物不存在")
	row_1 := sheet_1.AddRow()
	row_2 := sheet_2.AddRow()

	//存在
	row_1.AddCell().Value = "标识"
	row_1.AddCell().Value = "匹配词"
	row_1.AddCell().Value = "产品名称"
	row_1.AddCell().Value = "品牌"
	row_1.AddCell().Value = "型号"
	row_1.AddCell().Value = "单位"
	row_1.AddCell().Value = "数量"
	row_1.AddCell().Value = "单价"
	row_1.AddCell().Value = "原文链接"
	row_1.AddCell().Value = "剑鱼链接"

	row_2.AddCell().Value = "标识"
	row_2.AddCell().Value = "发布时间"
	row_2.AddCell().Value = "标的内容"
	row_2.AddCell().Value = "原文链接"
	row_2.AddCell().Value = "剑鱼链接"

	timeLayout := "2006-01-02"

	it := sess.DB(save_mgo.DbName).C("bidding_all").Find(&q).Iter()
	for tmp := make(map[string]interface{}); it.Next(&tmp); total++ {
		if total%10000 == 0 {
			log.Debug("cur index ", total, "~", isExist, "~", isUnExist)
		}
		newArr := []map[string]interface{}{}
		tmpid := qu.ObjToString(tmp["_id"])
		publishtime := qu.Int64All(tmp["publishtime"])
		pt_str := time.Unix(publishtime, 0).Format(timeLayout)
		purchasing := qu.ObjToString(tmp["purchasing"])
		href := qu.ObjToString(tmp["href"])
		jyhref := fmt.Sprintf(Url, qu.CommonEncodeArticle("content", tmpid))
		if purchasinglist, ok := tmp["purchasinglist"].(primitive.A); ok {
			newArr = qu.ObjArrToMapArr(purchasinglist)
		} else {
			if purchasinglist, ok := tmp["purchasinglist"].([]interface{}); ok {
				newArr = qu.ObjArrToMapArr(purchasinglist)
			}
		}

		if len(newArr) > 0 {
			b, arr := dealWithPList(newArr)
			if b {
				isExist++
				for k, v := range arr {
					row_1 = sheet_1.AddRow()
					for word, list_data := range v {
						if k == 0 {
							row_1.AddCell().Value = tmpid
							row_1.AddCell().Value = word
							row_1.AddCell().Value = fmt.Sprintf("%s", list_data["itemname"])
							row_1.AddCell().Value = fmt.Sprintf("%s", list_data["brandname"])
							row_1.AddCell().Value = fmt.Sprintf("%s", list_data["model"])
							row_1.AddCell().Value = fmt.Sprintf("%s", list_data["unitname"])
							row_1.AddCell().Value = fmt.Sprintf("%f", list_data["number"])
							row_1.AddCell().Value = fmt.Sprintf("%f", list_data["unitprice"])
							row_1.AddCell().Value = href
							row_1.AddCell().Value = jyhref
						} else {
							row_1.AddCell().Value = ""
							row_1.AddCell().Value = word
							row_1.AddCell().Value = fmt.Sprintf("%s", list_data["itemname"])
							row_1.AddCell().Value = fmt.Sprintf("%s", list_data["brandname"])
							row_1.AddCell().Value = fmt.Sprintf("%s", list_data["model"])
							row_1.AddCell().Value = fmt.Sprintf("%s", list_data["unitname"])
							row_1.AddCell().Value = fmt.Sprintf("%f", list_data["number"])
							row_1.AddCell().Value = fmt.Sprintf("%f", list_data["unitprice"])
							row_1.AddCell().Value = href
							row_1.AddCell().Value = jyhref
						}
					}
				}
			} else {
				isUnExist++
				row_2 = sheet_2.AddRow()
				row_2.AddCell().Value = tmpid
				row_2.AddCell().Value = pt_str
				row_2.AddCell().Value = purchasing
				row_2.AddCell().Value = href
				row_2.AddCell().Value = jyhref
			}
		} else {
			isUnExist++
			row_2 = sheet_2.AddRow()
			row_2.AddCell().Value = tmpid
			row_2.AddCell().Value = pt_str
			row_2.AddCell().Value = purchasing
			row_2.AddCell().Value = href
			row_2.AddCell().Value = jyhref
		}

		tmp = make(map[string]interface{})
	}

	err := f.Save("新整体统计.xlsx")
	if err != nil {
		log.Debug("保存xlsx失败:", err)
	} else {
		log.Debug("保存xlsx成功:", err)
	}

	log.Debug("is over ", total, "~", isExist, "~", isUnExist)

}
func dealWithPList(list []map[string]interface{}) (bool, []map[string]map[string]interface{}) {
	isok := false
	arr := []map[string]map[string]interface{}{}

	for _, v := range list {
		itemname := qu.ObjToString(v["itemname"])
		for _, word := range wordsArr {
			if strings.Contains(itemname, word) {
				isok = true
				arr = append(arr, map[string]map[string]interface{}{
					word: v,
				})
			}
		}
	}

	return isok, arr
}

func updateBidopenAddressData() {
	sess := save_mgo.GetMgoConn()
	defer save_mgo.DestoryMongoConn(sess)
	q, total := map[string]interface{}{}, 0
	it := sess.DB(save_mgo.DbName).C("zktest_bidopenaddr_test").Find(&q).Iter()
	for tmp := make(map[string]interface{}); it.Next(&tmp); total++ {
		if total%1000 == 0 {
			log.Debug("curent index ", total)
		}
		tmpid := BsonTOStringId(tmp["_id"])
		jyhref := fmt.Sprintf(Url, qu.CommonEncodeArticle("content", tmpid))
		save_mgo.UpdateById("zktest_bidopenaddr_test", tmpid, map[string]interface{}{
			"$set": map[string]interface{}{
				"jyhref": jyhref,
			},
		})
		tmp = make(map[string]interface{})
	}
	log.Debug("is over ", total)
}
func exportNewAddressData() {
	sess := save_mgo.GetMgoConn()
	defer save_mgo.DestoryMongoConn(sess)
	q, total := map[string]interface{}{}, 0
	it := sess.DB(save_mgo.DbName).C("111111").Find(&q).Iter()
	for tmp := make(map[string]interface{}); it.Next(&tmp); total++ {
		if total%1000 == 0 {
			log.Debug("curent index ", total)
		}
		tmpid := BsonTOStringId(tmp["_id"])
		data := save_mgo.FindById("bidding", tmpid)
		if data != nil && len(data) > 2 {
			save_mgo.Save("1212121212", data)
		} else {
			data = save_mgo.FindById("bidding_back", tmpid)
			if data != nil && len(data) > 2 {
				save_mgo.Save("1212121212", data)
			}
		}
		tmp = make(map[string]interface{})
	}
	log.Debug("is over ", total)

	return
	elastic.InitElasticSize("http://127.0.0.1:12003", 10)
	query := `{"query":{"bool":{"must":[{"prefix":{"bidding.bidopenaddress":""}},{"term":{"bidding.area":"全国"}},{"range":{"bidding.comeintime":{"from":"1630425600"}}}],"must_not":[],"should":[]}},"_source":["_id"],"sort":[],"facets":{},"size":"5000"}`
	arr := *elastic.Get("bidding", "bidding", query)
	if len(arr) > 0 {
		for _, v := range arr {
			save_mgo.Save("111111", map[string]interface{}{
				"_id": StringTOBsonId(qu.ObjToString(v["_id"])),
			})
		}
	}
	log.Debug("is over ", len(arr))
}
func updateListData() {
	elastic.InitElasticSize("http://172.17.145.170:9800", 10)
	//elastic.InitElasticSize("http://127.0.0.1:12003",10)
	sess := save_mgo.GetMgoConn()
	defer save_mgo.DestoryMongoConn(sess)
	q, total := map[string]interface{}{}, 0
	it := sess.DB(save_mgo.DbName).C("zktext_unexists").Find(&q).Iter()
	for tmp := make(map[string]interface{}); it.Next(&tmp); total++ {
		if total%1000 == 0 {
			log.Debug(total, "~", tmp["tmpid"])
		}
		tmpid := qu.ObjToString(tmp["tmpid"])
		data := *elastic.GetByIdField("bidding", "bidding", tmpid, `"area","city","district","projectname","buyer","budget","winner","bidamount"`)
		if len(data) > 0 {
			area := qu.ObjToString(data["area"])
			city := qu.ObjToString(data["city"])
			district := qu.ObjToString(data["district"])
			new_acd := area
			if city != "" {
				new_acd = new_acd + "~" + city
			}
			if district != "" {
				new_acd = new_acd + "~" + district
			}
			delete(data, "area")
			delete(data, "city")
			delete(data, "district")
			data["acd"] = new_acd
			save_mgo.UpdateById("zktext_unexists", BsonTOStringId(tmp["_id"]), map[string]interface{}{
				"$set": data,
			})
		}
		tmp = make(map[string]interface{})
	}
	log.Debug("is over", total)
}
func exportListExcelData() {
	sess := save_mgo.GetMgoConn()
	defer save_mgo.DestoryMongoConn(sess)
	q, total := map[string]interface{}{}, 0
	it := sess.DB(save_mgo.DbName).C("words_list").Find(&q).Iter()
	//写邮件
	os.Remove("111.xlsx")
	f := xlsx.NewFile()
	sheet, _ := f.AddSheet("标的物列表")
	row := sheet.AddRow()
	row.AddCell().Value = "标识"
	row.AddCell().Value = "搜索词"
	row.AddCell().Value = "产品名称"
	row.AddCell().Value = "品牌"
	row.AddCell().Value = "型号"
	row.AddCell().Value = "单位"
	row.AddCell().Value = "数量"
	row.AddCell().Value = "单价"
	row.AddCell().Value = "原文链接"
	row.AddCell().Value = "剑鱼链接"

	for tmp := make(map[string]interface{}); it.Next(&tmp); total++ {
		if total%1000 == 0 {
			log.Debug(total)
		}
		newArr := []map[string]interface{}{}
		if purchasinglist, ok := tmp["purchasinglist"].(primitive.A); ok {
			newArr = qu.ObjArrToMapArr(purchasinglist)
		} else {
			if purchasinglist, ok := tmp["purchasinglist"].([]interface{}); ok {
				newArr = qu.ObjArrToMapArr(purchasinglist)
			}
		}
		for k, v := range newArr {
			row = sheet.AddRow()
			if k == 0 {
				row.AddCell().Value = qu.ObjToString(tmp["tmpid"])
				row.AddCell().Value = qu.ObjToString(tmp["word"])
				row.AddCell().Value = fmt.Sprintf("%s", v["itemname"])
				row.AddCell().Value = fmt.Sprintf("%s", v["brandname"])
				row.AddCell().Value = fmt.Sprintf("%s", v["model"])
				row.AddCell().Value = fmt.Sprintf("%s", v["unitname"])
				row.AddCell().Value = fmt.Sprintf("%f", v["number"])
				row.AddCell().Value = fmt.Sprintf("%f", v["unitprice"])
				row.AddCell().Value = qu.ObjToString(tmp["href"])
				row.AddCell().Value = qu.ObjToString(tmp["jyhref"])
			} else {

				row.AddCell().Value = ""
				row.AddCell().Value = ""
				row.AddCell().Value = fmt.Sprintf("%s", v["itemname"])
				row.AddCell().Value = fmt.Sprintf("%s", v["brandname"])
				row.AddCell().Value = fmt.Sprintf("%s", v["model"])
				row.AddCell().Value = fmt.Sprintf("%s", v["unitname"])
				row.AddCell().Value = fmt.Sprintf("%f", v["number"])
				row.AddCell().Value = fmt.Sprintf("%f", v["unitprice"])
				row.AddCell().Value = ""
				row.AddCell().Value = ""
			}
		}

		tmp = make(map[string]interface{})
	}

	err := f.Save("111.xlsx")
	if err != nil {
		log.Debug("保存xlsx失败:", err)
	} else {
		log.Debug("保存xlsx成功:", err)
	}

}
func exportPurchasingListData() {
	elastic.InitElasticSize("http://172.17.145.170:9800", 10)
	sess := save_mgo.GetMgoConn()
	defer save_mgo.DestoryMongoConn(sess)
	q, total := map[string]interface{}{}, 0
	/*
		"purchasinglist":map[string]interface{}{
					"$exists":0,
				},
	*/
	it := sess.DB(save_mgo.DbName).C("words_list").Find(&q).Iter()

	pool := make(chan bool, 2)
	wg := &sync.WaitGroup{}

	for tmp := make(map[string]interface{}); it.Next(&tmp); total++ {

		if total%100 == 0 {
			log.Debug(total, tmp["tmpid"])
		}
		//开始多线程查询
		pool <- true
		wg.Add(1)
		go func(dict map[string]interface{}) {
			defer func() {
				<-pool
				wg.Done()
			}()
			tmpid := qu.ObjToString(dict["tmpid"])
			word := qu.ObjToString(dict["word"])
			data := *elastic.GetByIdField("bidding", "bidding", tmpid, `"purchasinglist"`)
			newArr := []map[string]interface{}{}
			if purchasinglist, ok := data["purchasinglist"].(primitive.A); ok {
				newArr = dealWithNewList(qu.ObjArrToMapArr(purchasinglist), word)
			} else {
				if purchasinglist, ok := data["purchasinglist"].([]interface{}); ok {
					newArr = dealWithNewList(qu.ObjArrToMapArr(purchasinglist), word)
				}
			}
			if len(newArr) > 0 {
				save_mgo.UpdateById("words_list", BsonTOStringId(dict["_id"]), map[string]interface{}{
					"$set": map[string]interface{}{
						"purchasinglist": newArr,
					},
				})
			}
		}(tmp)

		tmp = make(map[string]interface{})
	}
	wg.Wait()
	log.Debug("is over", total)
}
func dealWithNewList(oldArr []map[string]interface{}, word string) []map[string]interface{} {
	newArr := []map[string]interface{}{}
	for _, v := range oldArr {
		itemname := qu.ObjToString(v["itemname"])
		if strings.Contains(itemname, word) {
			newArr = append(newArr, v)
		}
	}
	return newArr
}

//导出es数据标的物
func exportWarningPurchasingData() {
	//elastic.InitElasticSize("http://127.0.0.1:12003",10)
	elastic.InitElasticSize("http://172.17.145.170:9800", 10)
	esclient := elastic.GetEsConn()
	defer elastic.DestoryEsConn(esclient)
	words := []string{}
	sess := save_mgo.GetMgoConn()
	defer save_mgo.DestoryMongoConn(sess)
	q, total := map[string]interface{}{}, 0
	it := sess.DB(save_mgo.DbName).C("words").Find(&q).Iter()
	for tmp := make(map[string]interface{}); it.Next(&tmp); total++ {
		words = append(words, qu.ObjToString(tmp["word"]))
		tmp = make(map[string]interface{})
	}
	log.Debug("搜索词~", len(words))
	//words =[]string{"鼻氧管"}

	os.Remove("标的物-统计.xlsx")

	f := xlsx.NewFile()
	sheet_1, _ := f.AddSheet("标的物存在")
	sheet_2, _ := f.AddSheet("标的物不存在")
	sheet_3, _ := f.AddSheet("索引总数")
	row_1 := sheet_1.AddRow()
	row_2 := sheet_2.AddRow()
	row_3 := sheet_3.AddRow()

	row_1.AddCell().Value = "标识"
	row_1.AddCell().Value = "标题"
	row_1.AddCell().Value = "发布时间"
	row_1.AddCell().Value = "站点"
	row_1.AddCell().Value = "搜索词"
	row_1.AddCell().Value = "标的内容"
	row_1.AddCell().Value = "原文链接"
	row_1.AddCell().Value = "剑鱼链接"

	row_2.AddCell().Value = "标识"
	row_2.AddCell().Value = "标题"
	row_2.AddCell().Value = "发布时间"
	row_2.AddCell().Value = "站点"
	row_2.AddCell().Value = "搜索词"
	row_2.AddCell().Value = "标的内容"
	row_2.AddCell().Value = "原文链接"
	row_2.AddCell().Value = "剑鱼链接"

	row_3.AddCell().Value = "搜索词/索引数"
	row_3.AddCell().Value = "单字段"
	row_3.AddCell().Value = "多字段"

	num_1, num_2 := 0, 0
	for k, v := range words {
		//query_1 :全字段    query_2 : 标的物字段
		query_1 := fmt.Sprintf(`{"query":{"filtered":{"filter":{"bool":{"must":[{"terms":{"subtype":["单一","成交","中标","合同"]}},{"range":{"publishtime":{"gte":1546272000}}}]}},"query":{"bool":{"should":[{"multi_match":{"query":"%s","type":"phrase","fields":["purchasing","title","detail"]}}]}}}},"_source":["_id","publishtime","title","purchasing","href","site"],"size":"100"}`, v)
		query_2 := fmt.Sprintf(`{"query":{"filtered":{"filter":{"bool":{"must":[{"terms":{"subtype":["单一","成交","中标","合同"]}},{"range":{"publishtime":{"gte":1546272000}}}]}},"query":{"bool":{"should":[{"multi_match":{"query":"%s","type":"phrase","fields":["purchasing"]}}]}}}},"_source":["_id","publishtime","title","purchasing","href","site"],"size":"100"}`, v)

		query_3 := fmt.Sprintf(`{"query":{"filtered":{"filter":{"bool":{"must":[{"terms":{"subtype":["单一","成交","中标","合同"]}},{"range":{"publishtime":{"gte":1546272000}}}]}},"query":{"bool":{"should":[{"multi_match":{"query":"%s","type":"phrase","fields":["purchasing","title","detail"]}}]}}}},"_source":["_id"],"size":"100000000"}`, v)
		query_4 := fmt.Sprintf(`{"query":{"filtered":{"filter":{"bool":{"must":[{"terms":{"subtype":["单一","成交","中标","合同"]}},{"range":{"publishtime":{"gte":1546272000}}}]}},"query":{"bool":{"should":[{"multi_match":{"query":"%s","type":"phrase","fields":["purchasing"]}}]}}}},"_source":["_id"],"size":"100000000"}`, v)
		res_3, _ := esclient.Search().Index("bidding").Type("bidding").Source(query_3).Do()
		res_4, _ := esclient.Search().Index("bidding").Type("bidding").Source(query_4).Do()
		resNum_3 := len(res_3.Hits.Hits)
		resNum_4 := len(res_4.Hits.Hits)
		data_1 := elastic.Get("bidding", "bidding", query_1)
		data_2 := elastic.Get("bidding", "bidding", query_2)
		//去重区分组数据
		newArr_1, newArr_2 := dealWithBlockData(*data_1, *data_2, v)
		for _, v := range newArr_1 {
			row_1 = sheet_1.AddRow()
			row_1.AddCell().Value = v["id"]
			row_1.AddCell().Value = v["title"]
			row_1.AddCell().Value = v["publishtime"]
			row_1.AddCell().Value = v["site"]
			row_1.AddCell().Value = v["word"]
			row_1.AddCell().Value = v["purchasing"]
			row_1.AddCell().Value = v["href"]
			row_1.AddCell().Value = v["jyhref"]
		}

		for _, v := range newArr_2 {
			row_2 = sheet_2.AddRow()
			row_2.AddCell().Value = v["id"]
			row_2.AddCell().Value = v["title"]
			row_2.AddCell().Value = v["publishtime"]
			row_2.AddCell().Value = v["site"]
			row_2.AddCell().Value = v["word"]
			row_2.AddCell().Value = v["purchasing"]
			row_2.AddCell().Value = v["href"]
			row_2.AddCell().Value = v["jyhref"]
		}
		row_3 = sheet_3.AddRow()
		row_3.AddCell().Value = v
		row_3.AddCell().Value = fmt.Sprintf("%d", resNum_3)
		row_3.AddCell().Value = fmt.Sprintf("%d", resNum_4)

		num_1 += resNum_3
		num_2 += resNum_4

		log.Debug("第", k, "组:", v, "总计:", num_1, "~", num_2)
	}

	err := f.Save("标的物-统计.xlsx")
	if err != nil {
		log.Debug("保存xlsx失败:", err)
	} else {
		log.Debug("保存xlsx成功:", err)
	}

	log.Debug("is over")
}
func dealWithBlockData(data_1, data_2 []map[string]interface{}, word string) ([]map[string]string, []map[string]string) {
	newArr_1, newArr_2 := []map[string]string{}, []map[string]string{}
	timeLayout := "2006-01-02"
	for _, v := range data_2 {
		cur_id := qu.ObjToString(v["_id"])
		publishtime := qu.Int64All(v["publishtime"])
		pt_str := time.Unix(publishtime, 0).Format(timeLayout)
		jyhref := fmt.Sprintf(Url, qu.CommonEncodeArticle("content", cur_id))
		newArr_1 = append(newArr_1, map[string]string{
			"id":          cur_id,
			"publishtime": pt_str,
			"word":        word,
			"purchasing":  qu.ObjToString(v["purchasing"]),
			"href":        qu.ObjToString(v["href"]),
			"jyhref":      jyhref,
			"title":       qu.ObjToString(v["title"]),
			"site":        qu.ObjToString(v["site"]),
		})
	}

	for _, v := range data_1 {
		cur_id := qu.ObjToString(v["_id"])
		publishtime := qu.Int64All(v["publishtime"])
		pt_str := time.Unix(publishtime, 0).Format(timeLayout)
		jyhref := fmt.Sprintf(Url, qu.CommonEncodeArticle("content", cur_id))

		isExists := false
		for _, v1 := range data_2 {
			new_id := qu.ObjToString(v1["_id"])
			if cur_id == new_id {
				isExists = true
				break
			}
		}
		if !isExists {
			newArr_2 = append(newArr_2, map[string]string{
				"id":          cur_id,
				"publishtime": pt_str,
				"word":        word,
				"purchasing":  qu.ObjToString(v["purchasing"]),
				"href":        qu.ObjToString(v["href"]),
				"jyhref":      jyhref,
				"title":       qu.ObjToString(v["title"]),
				"site":        qu.ObjToString(v["site"]),
			})
		}
	}

	return newArr_1, newArr_2
}

//导出错误数据-
func exportErrSpecsData() {
	sess := save_mgo.GetMgoConn()
	defer save_mgo.DestoryMongoConn(sess)
	q, total, isok := map[string]interface{}{}, 0, 0
	it := sess.DB(save_mgo.DbName).C("zktest_works_test").Find(&q).Iter()
	for tmp := make(map[string]interface{}); it.Next(&tmp); total++ {
		ck_s_winner := qu.IntAll(tmp["ck_s_winner"])
		ck_bidamount := qu.IntAll(tmp["ck_bidamount"])
		if ck_s_winner > 0 || ck_bidamount > 0 {
			isok++
			save_mgo.Save("zkzkzkzkzkzk", tmp)
		}
		tmp = make(map[string]interface{})
	}

	log.Debug("is over ", total, isok)
}

//导出错误数据-
func exportErrTagData() {
	sess := save_mgo.GetMgoConn()
	defer save_mgo.DestoryMongoConn(sess)
	q, total := map[string]interface{}{}, 0
	it := sess.DB(save_mgo.DbName).C("zktest_errtag_data").Find(&q).Iter()
	for tmp := make(map[string]interface{}); it.Next(&tmp); total++ {
		tmpid := qu.ObjToString(tmp["_id"])
		key_items := qu.ObjToString(tmp["key_items"])
		key_items = strings.TrimSuffix(key_items, "，")
		keysArr := strings.Split(key_items, "，")

		if len(keysArr) > 0 {
			savedict := tmp
			data := save_mgo.FindById("zktest_errtag_bidding", tmpid)
			for _, v := range keysArr {
				savedict[v] = data[v]
			}
			savedict["href"] = data["href"]
			jyhref := fmt.Sprintf(Url, qu.CommonEncodeArticle("content", tmpid))
			savedict["jyhref"] = jyhref
			save_mgo.Save("zktest_errtag_data_new", savedict)
		}

		//data := save_mgo.FindById("zktest_errtag_bidding",tmpid)

		tmp = make(map[string]interface{})
	}

	log.Debug("is over ", total)
}

//导出错误数据-
func exportErrWorksData() {
	sess := save_mgo.GetMgoConn()
	defer save_mgo.DestoryMongoConn(sess)
	q, total, isok := map[string]interface{}{}, 0, 0
	it := sess.DB(save_mgo.DbName).C("zktest_works_test_new").Find(&q).Sort("_id").Iter()
	for tmp := make(map[string]interface{}); it.Next(&tmp); total++ {
		if total%1000 == 0 {
			log.Debug("current index", total, isok)
		}
		if wrong_key_item, ok := tmp["wrong_key_item"].(primitive.A); ok {
			if len(wrong_key_item) > 0 {
				isSave := false
				wrong_key, wrong_arr := "", []string{}
				for _, v := range wrong_key_item {
					if v == "bidamount" {
						isSave = true
						wrong_key += qu.ObjToString(v) + ","
						wrong_arr = append(wrong_arr, qu.ObjToString(v))
					}
				}
				if isSave && wrong_key != "" {
					isok++
					data := save_mgo.FindById("zktest_works_test", BsonTOStringId(tmp["_id"]))
					dict := map[string]interface{}{
						"_id":         data["_id"],
						"wrong_key":   wrong_key,
						"href":        data["href"],
						"jytest_href": tmp["jytest_href"],
					}
					for _, v := range wrong_arr {
						dict[v] = data[v]
					}
					save_mgo.Save("zktest_wrong_bidamount_data", dict)
				}
			}
		}
		tmp = make(map[string]interface{})
	}

	log.Debug("is over ", total, isok)
}

//导出全量-标注表2合一
func exportAllWorksData() {
	//works_1  works_2
	sess := save_mgo.GetMgoConn()
	defer save_mgo.DestoryMongoConn(sess)
	q, total := map[string]interface{}{}, 0
	it := sess.DB(save_mgo.DbName).C("works_1").Find(&q).Iter()
	for tmp := make(map[string]interface{}); it.Next(&tmp); total++ {
		save_mgo.Save("works_test", tmp)
		tmp = make(map[string]interface{})
	}
	log.Debug("is over works_1 ", total)

	total = 0
	it = sess.DB(save_mgo.DbName).C("works_2").Find(&q).Iter()
	for tmp := make(map[string]interface{}); it.Next(&tmp); total++ {
		save_mgo.Save("works_test", tmp)
		tmp = make(map[string]interface{})
	}
	log.Debug("is over works_2 ", total)
}

//数据导出-1122-markwork_wb_zcz_zhong
func exportRepair1122Data() {
	sess := save_mgo.GetMgoConn()
	defer save_mgo.DestoryMongoConn(sess)
	q, total := map[string]interface{}{}, 0
	it := sess.DB(save_mgo.DbName).C("markwork_wb_zcz_zhong").Find(&q).Iter()
	for tmp := make(map[string]interface{}); it.Next(&tmp); total++ {
		if total%1000 == 0 {
			log.Debug("current index", total, tmp["_id"])
		}
		ck_s_winner := qu.Int64All(tmp["ck_s_winner"])
		ck_bidamount := qu.Int64All(tmp["ck_bidamount"])
		ck_package := qu.Int64All(tmp["ck_package"])

		if ck_s_winner > 1 || ck_bidamount > 1 || ck_package > 1 {
			save_mgo.Save("zktest_err_data", tmp)

		}
		tmp = make(map[string]interface{})
	}
	log.Debug("is over", total)

}

//导出-插件任务
func exportNoPluginTask() {
	arr := []string{
		"a_bqgyjtgscgdzswpt_zbhxrgs",
		"a_bqgyjtgscgdzswpt_zbjggg",
		"a_bqgyjtgscgdzswpt_bgcqgg",
		"sc_ybsggzyjyxxw_qtxm",
		"sc_ybsggzyjyxxw_gqzb",
		"hb_whsggzyjypt_zgysgs",
		"a_zgnfdwdzcgjypt_zbcggg",
		"a_hcxcdzcgpt_cggg",
		"hb_hbsggzyjyzx_zfcg_bggg",
		"hb_hbsggzyjyzx_zfcg_qtgg",
		"hb_hbsggzyjyzx_zfcg_cggg",
		"hb_hbsggzyjyzx_zfcg_xqgg",
		"hb_hbsggzyjyzx_zfcg_jggg",
		"js_szszfcgwssc_jjjggg",
		"js_szszfcgwssc_jjxqgg",
		"a_zgnfhkcgzbw_zbgg",
		"a_zgnfhkcgzbw_cggg",
		"a_zgnfhkcgzbw_zhbgg",
		"a_zgnfhkcgzbw_pbgs",
		"a_zgnfhkcgzbw_cgjg",
		"a_zgnfhkcgzbw_fzbcg_cggg",
		"a_zgnfhkcgzbw_qtgg",
		"sz_szsjzsczhcxpt_xmxx_zbxx",
	}
	dict := make(map[string]interface{}, 0)
	for _, v := range arr {
		dict[v] = 1
	}

	return
	sess := save_mgo.GetMgoConn()
	defer save_mgo.DestoryMongoConn(sess)
	q, total, isok := map[string]interface{}{}, 0, 0
	it := sess.DB(save_mgo.DbName).C("plugin_task").Find(&q).Iter()

	taskData := make(map[string]interface{}, 0)
	for tmp := make(map[string]interface{}); it.Next(&tmp); total++ {
		if total%1000 == 0 {
			log.Debug("current index", total, isok, tmp["_id"])
		}
		code := qu.ObjToString(tmp["code"])
		if dict[code] != nil {
			isok++
		} else {
			taskData[code] = 1
		}

		tmp = make(map[string]interface{})
	}
	log.Debug("is over", total, isok, len(taskData))

	for k, _ := range taskData {
		log.Debug(k)
	}
}

//导出过大金额数据es - 1亿
func exportToMuchBidamountData() {
	//elastic.InitElasticSize("http://127.0.0.1:12003",10)
	elastic.InitElasticSize("http://172.17.145.170:9800", 10)

	log.Debug("开始...遍历索引...")
	total := int64(0)
	esclient := elastic.GetEsConn()
	defer elastic.DestoryEsConn(esclient)
	if esclient == nil {
		log.Debug("连接池异常")
	}
	query := es_elastic.NewRangeQuery("bidamount").Gte(100000000).Lt(1000000000000)
	cursor, err := esclient.Scan("bidding").Query(es_elastic.NewBoolQuery().Must(query)).
		Size(200).Do()
	if err != nil {
		log.Debug("cursor", err)
	}
	if cursor.Results == nil {
		log.Debug("results != nil; got nil")
	}
	if cursor.Results.Hits == nil {
		log.Debug("expected results.Hits != nil; got nil")
	}
	total += cursor.TotalHits()
	log.Debug("当前查询正常数：", cursor.TotalHits(), "总数：", total)
	numDocs := 0
	//多线程 - 处理数据
	pool_es := make(chan bool, 4)
	wg_es := &sync.WaitGroup{}
	for {
		searchResult, err := cursor.Next()
		if err != nil {
			if err.Error() == "EOS" {
				break
			} else {
				log.Debug("cursor searchResult", err)
			}
		}
		for _, hit := range searchResult.Hits.Hits {
			tmp := make(map[string]interface{})
			err := json.Unmarshal(*hit.Source, &tmp)
			if err != nil {
				log.Debug("json Unmarshal error")
				continue
			}
			if numDocs%1000 == 0 {
				log.Debug("当前条数：", numDocs, "Es数据：", tmp["_id"])
			}
			numDocs++
			tmpid := qu.ObjToString(tmp["_id"])
			pool_es <- true
			wg_es.Add(1)
			go func(tmpid string) {
				defer func() {
					<-pool_es
					wg_es.Done()
				}()
				//根据id查询-bidding-并保存
				data := save_mgo.FindById("bidding", tmpid)
				if data != nil && len(data) > 2 {
					save_mgo.Save("zk_to_much_bidamount_data", data)
				} else {
					data = save_mgo.FindById("bidding_back", tmpid)
					if data != nil && len(data) > 2 {
						save_mgo.Save("zk_to_much_bidamount_data", data)
					}
				}
			}(tmpid)
		}
	}
	wg_es.Wait()

	log.Debug("遍历完毕...", total, numDocs)
}

//根据jyurl- 导出具体数据
func exportFromUrlToDataArr() {
	arr := []string{}
	for _, v := range arr {
		var Decode = qu.CommonDecodeArticle("content", v)
		tmpid := Decode[0]
		data := save_mgo.FindById("bidding", tmpid)
		if data != nil && len(data) > 2 {
			save_mgo.Save("zk_jjyh_err_data_two", data)
		} else {
			data = save_mgo.FindById("bidding_back", tmpid)
			if data != nil && len(data) > 2 {
				save_mgo.Save("zk_jjyh_err_data_two", data)
			}
		}
	}
}

//刷数据
func exportRepairNewStandData() {
	sess := save_mgo.GetMgoConn()
	defer save_mgo.DestoryMongoConn(sess)
	q, total, isok := map[string]interface{}{}, 0, 0
	it := sess.DB(save_mgo.DbName).C("zktest_new_sssttt_data").Find(&q).Iter()
	for tmp := make(map[string]interface{}); it.Next(&tmp); total++ {
		if total%1000 == 0 {
			log.Debug("current index", total, isok, tmp["_id"])
		}
		buyer_name := qu.ObjToString(tmp["buyer"])
		buyerclass := qu.ObjToString(tmp["buyerclass"])
		data := python_mgo.FindOne("buyer_enterprise", map[string]interface{}{
			"buyer_name": buyer_name,
		})
		if data != nil {
			isok++
			python_mgo.UpdateById("buyer_enterprise", BsonTOStringId(data["_id"]), map[string]interface{}{
				"$set": map[string]interface{}{
					"buyerclass": buyerclass,
				},
			})

		}

		tmp = make(map[string]interface{})
	}
	log.Debug("is over", total, isok)
}

//导出数据
func exportNewStandData() {
	//zktest_new_buyerstand_data
	//elastic.InitElasticSize("http://127.0.0.1:12003",10)
	elastic.InitElasticSize("http://172.17.145.170:9800", 10)
	sess := python_mgo.GetMgoConn()
	defer python_mgo.DestoryMongoConn(sess)
	q, total, isok := map[string]interface{}{}, 0, 0
	it := sess.DB(python_mgo.DbName).C("zktest_new_buyerstand_data").Find(&q).Iter()
	for tmp := make(map[string]interface{}); it.Next(&tmp); total++ {
		if total%1000 == 0 {
			log.Debug("current index", total, isok, tmp["_id"])
		}
		buyer_name := qu.ObjToString(tmp["buyer_name"])
		query := `{"query":{"bool":{"must":[{"term":{"bidding.buyer":` + `"` + buyer_name + `"` + `}}],"must_not":[],"should":[]}},"from":"0","size":"1","sort":[],"facets":{}}`
		arr := *elastic.Get("bidding", "bidding", query)
		if arr != nil && len(arr) > 0 {
			source_id := qu.ObjToString(arr[0]["_id"])
			if source_id != "" {
				data := save_mgo.FindById("result_20210108", source_id)
				if data != nil && len(data) > 2 {
					isok++
					save_mgo.Save("zktest_new_stand_data", data)
				} else {
					isok++
					save_mgo.Save("zktest_new_stand_data", map[string]interface{}{
						"buyer": buyer_name,
					})
				}
			}
		} else {
			isok++
			save_mgo.Save("zktest_new_stand_data", map[string]interface{}{
				"buyer": buyer_name,
			})
		}
		tmp = make(map[string]interface{})
	}
	log.Debug("is over", total, isok)
}

//导出-err标准数据
func exportOtherErrStandardataTwo() {
	sess := python_mgo.GetMgoConn()
	defer python_mgo.DestoryMongoConn(sess)
	q, total, isok := map[string]interface{}{}, 0, 0
	it := sess.DB(python_mgo.DbName).C("buyer_enterprise_new").Find(&q).Select(map[string]interface{}{
		"buyer_name": 1,
	}).Iter()
	pool_data := make(chan bool, 8)
	wg_data := &sync.WaitGroup{}
	for tmp := make(map[string]interface{}); it.Next(&tmp); total++ {
		if total%10000 == 0 {
			log.Debug("current index", total, isok, tmp["_id"])
		}
		buyer_name := qu.ObjToString(tmp["buyer_name"])
		if utf8.RuneCountInString(buyer_name) < 4 {
			continue
			tmp = make(map[string]interface{})
		}
		tmpid := BsonTOStringId(tmp["_id"])
		pool_data <- true
		wg_data.Add(1)
		go func(buyer_name string, tmpid string) {
			defer func() {
				<-pool_data
				wg_data.Done()
			}()
			stand_data := python_mgo.FindOne("buyer_enterprise", map[string]interface{}{
				"buyer_name": buyer_name,
			})
			if len(stand_data) > 2 && stand_data != nil {

			} else {
				//查询企业库是否存在
				qy_data := python_mgo.FindOne("qyxy_std", map[string]interface{}{
					"company_name": buyer_name,
				})
				if len(qy_data) > 2 && qy_data != nil {
					//企业库存在-真实有效-看标准库是否存在
					isok++
					dict := map[string]interface{}{
						"buyer_name": buyer_name,
					}
					python_mgo.Save("zktest_new_buyerstand_data", dict)
				}
			}
		}(buyer_name, tmpid)
		tmp = make(map[string]interface{})
	}
	wg_data.Wait()

	log.Debug("is over", total, isok)
}
func exportOtherErrStandardataOne() {
	sess := python_mgo.GetMgoConn()
	defer python_mgo.DestoryMongoConn(sess)
	q, total, isok := map[string]interface{}{}, 0, 0
	it := sess.DB(python_mgo.DbName).C("buyer_err").Find(&q).Select(map[string]interface{}{
		"name": 1,
	}).Iter()
	pool_data := make(chan bool, 8)
	wg_data := &sync.WaitGroup{}
	for tmp := make(map[string]interface{}); it.Next(&tmp); total++ {
		if total%10000 == 0 {
			log.Debug("current index", total, isok, tmp["_id"])
		}
		buyer_name := qu.ObjToString(tmp["name"])
		if utf8.RuneCountInString(buyer_name) < 4 {
			continue
			tmp = make(map[string]interface{})
		}
		tmpid := BsonTOStringId(tmp["_id"])
		pool_data <- true
		wg_data.Add(1)
		go func(buyer_name string, tmpid string) {
			defer func() {
				<-pool_data
				wg_data.Done()
			}()

			//查询企业库是否存在
			qy_data := python_mgo.FindOne("qyxy_std", map[string]interface{}{
				"company_name": buyer_name,
			})
			if len(qy_data) > 2 && qy_data != nil {
				//企业库存在-真实有效-看标准库是否存在
				stand_data := python_mgo.FindOne("buyer_enterprise", map[string]interface{}{
					"buyer_name": buyer_name,
				})
				if len(stand_data) > 2 && stand_data != nil {
					python_mgo.DeleteById("buyer_err", BsonTOStringId(tmp["_id"]))
				} else {
					isok++
					dict := map[string]interface{}{
						"buyer_name": buyer_name,
					}
					python_mgo.Save("zktest_new_buyerstand_data", dict)
					python_mgo.DeleteById("buyer_err", BsonTOStringId(tmp["_id"]))
				}
			}
		}(buyer_name, tmpid)
		tmp = make(map[string]interface{})
	}
	wg_data.Wait()

	log.Debug("is over", total, isok)
}

//导出数据
func filterDataBuyerWinnerLength() {
	reg := regexp.MustCompile(`^.{2}([大|小|中|学][学|院]|公司)$`)
	sess := save_mgo.GetMgoConn()
	defer save_mgo.DestoryMongoConn(sess)
	q, total, isok := map[string]interface{}{}, 0, 0
	it := sess.DB(save_mgo.DbName).C("zktest_buyer_stand_data").Find(&q).Iter()
	for tmp := make(map[string]interface{}); it.Next(&tmp); total++ {
		if total%1000 == 0 {
			log.Debug("current index", total, isok, tmp["_id"])
		}
		buyer := qu.ObjToString(tmp["buyer"])
		winner := qu.ObjToString(tmp["winner"])
		if (reg.MatchString(buyer) && utf8.RuneCountInString(buyer) == 4) ||
			(reg.MatchString(winner) && utf8.RuneCountInString(winner) == 4) {
			//符合
			isok++
			save_mgo.Save("zktest_buyerstand_data_repair", tmp)
		}
		tmp = make(map[string]interface{})
	}
	log.Debug("export unit is over", total, isok)
}

//遍历es 导出异常数据
func exportErrQuanGuoData() {
	elastic.InitElasticSize("http://127.0.0.1:12003", 10)
	//elastic.InitElasticSize("http://172.17.145.170:9800", 10)

	log.Debug("开始导出......")
	//遍历索引
	esclient := elastic.GetEsConn()
	defer elastic.DestoryEsConn(esclient)

	if esclient == nil {
		log.Debug("连接池异常")
	}
	//q :=es_elastic.NewTermQuery("area","全国")

	arr := []map[string]interface{}{
		{"key": "广东", "count": 9793435, "aaabbb": "1"},
		{"key": "广州市", "count": 1753303},
		{"key": "深圳市", "count": 943391},
		{"key": "佛山市", "count": 878137},
		{"key": "惠州市", "count": 588756},
		{"key": "中山市", "count": 511753},
		{"key": "清远市", "count": 408415},
		{"key": "韶关市", "count": 401834},
		{"key": "东莞市", "count": 399658},
		{"key": "肇庆市", "count": 371789},
		{"key": "茂名市", "count": 355259},
		{"key": "珠海市", "count": 352554},
		{"key": "湛江市", "count": 348396},
		{"key": "汕头市", "count": 330634},
		{"key": "梅州市", "count": 280759},
		{"key": "江门市", "count": 234517},
		{"key": "潮州市", "count": 190182},
		{"key": "云浮市", "count": 190009},
		{"key": "河源市", "count": 173828},
		{"key": "汕尾市", "count": 160951},
		{"key": "阳江市", "count": 159198},
		{"key": "揭阳市", "count": 152241},
		{"key": "佛山", "count": 104},
		{"key": "中山", "count": 15},
		{"key": "深圳", "count": 14},
		{"key": "东莞", "count": 13},
		{"key": "江门", "count": 9},
		{"key": "广东省", "count": 8},
		{"key": "广州", "count": 4},
		{"key": "惠州", "count": 3},
		{"key": "北京市", "count": 1},
		{"key": "珠海", "count": 1},
		{"key": "阳江", "count": 1},
		{"key": "山东", "count": 6269916, "aaabbb": "1"},
		{"key": "济南市", "count": 1215749},
		{"key": "青岛市", "count": 783079},
		{"key": "潍坊市", "count": 493730},
		{"key": "临沂市", "count": 407297},
		{"key": "济宁市", "count": 367980},
		{"key": "烟台市", "count": 337735},
		{"key": "聊城市", "count": 317560},
		{"key": "淄博市", "count": 292306},
		{"key": "日照市", "count": 279839},
		{"key": "德州市", "count": 254100},
		{"key": "泰安市", "count": 243043},
		{"key": "滨州市", "count": 229494},
		{"key": "威海市", "count": 224879},
		{"key": "菏泽市", "count": 215532},
		{"key": "东营市", "count": 150344},
		{"key": "枣庄市", "count": 136861},
		{"key": "莱芜市", "count": 9186},
		{"key": "寿光市", "count": 137},
		{"key": "济南", "count": 30},
		{"key": "潍坊", "count": 20},
		{"key": "山东省", "count": 14},
		{"key": "东营", "count": 12},
		{"key": "莱芜", "count": 12},
		{"key": "威海", "count": 8},
		{"key": "济宁", "count": 5},
		{"key": "聊城", "count": 5},
		{"key": "北京市", "count": 3},
		{"key": "青岛", "count": 2},
		{"key": "曲阜市", "count": 1},
		{"key": "西安市", "count": 1},
		{"key": "全国", "count": 5483318, "aaabbb": "1"},
		{"key": "哈密地区", "count": 12},
		{"key": "唐山市", "count": 11},
		{"key": "绍兴市", "count": 10},
		{"key": "泰州市", "count": 9},
		{"key": "石家庄市", "count": 8},
		{"key": "台湾省", "count": 6},
		{"key": "合肥市", "count": 6},
		{"key": "广州市", "count": 6},
		{"key": "舟山市", "count": 6},
		{"key": "黄冈市", "count": 6},
		{"key": "福州市", "count": 5},
		{"key": "仙桃市", "count": 3},
		{"key": "北京市", "count": 3},
		{"key": "廊坊市", "count": 3},
		{"key": "成都市", "count": 3},
		{"key": "十堰市", "count": 2},
		{"key": "南宁市", "count": 2},
		{"key": "日照市", "count": 2},
		{"key": "沧州市", "count": 2},
		{"key": "六盘水市", "count": 1},
		{"key": "南京市", "count": 1},
		{"key": "南昌市", "count": 1},
		{"key": "周口市", "count": 1},
		{"key": "呼伦贝尔市", "count": 1},
		{"key": "大连市", "count": 1},
		{"key": "太原市", "count": 1},
		{"key": "宁波市", "count": 1},
		{"key": "宜昌市", "count": 1},
		{"key": "宣城市", "count": 1},
		{"key": "宿迁市", "count": 1},
		{"key": "崇左市", "count": 1},
		{"key": "张家口市", "count": 1},
		{"key": "承德市", "count": 1},
		{"key": "无锡市", "count": 1},
		{"key": "池州市", "count": 1},
		{"key": "泉州市", "count": 1},
		{"key": "泸州市", "count": 1},
		{"key": "济南市", "count": 1},
		{"key": "深圳市", "count": 1},
		{"key": "湘潭市", "count": 1},
		{"key": "滁州市", "count": 1},
		{"key": "漳州市", "count": 1},
		{"key": "盐城市", "count": 1},
		{"key": "秦皇岛市", "count": 1},
		{"key": "西安市", "count": 1},
		{"key": "贺州市", "count": 1},
		{"key": "金华市", "count": 1},
		{"key": "铜陵市", "count": 1},
		{"key": "防城港市", "count": 1},
		{"key": "香港", "count": 1},
		{"key": "黄山市", "count": 1},
		{"key": "安徽", "count": 4632338, "aaabbb": "1"},
		{"key": "合肥市", "count": 1141306},
		{"key": "芜湖市", "count": 353318},
		{"key": "滁州市", "count": 338535},
		{"key": "安庆市", "count": 300115},
		{"key": "阜阳市", "count": 284622},
		{"key": "蚌埠市", "count": 272222},
		{"key": "六安市", "count": 264551},
		{"key": "马鞍山市", "count": 198801},
		{"key": "淮南市", "count": 167301},
		{"key": "宣城市", "count": 166202},
		{"key": "宿州市", "count": 159114},
		{"key": "淮北市", "count": 147424},
		{"key": "铜陵市", "count": 139928},
		{"key": "亳州市", "count": 130658},
		{"key": "黄山市", "count": 112832},
		{"key": "池州市", "count": 106672},
		{"key": "安徽省", "count": 40},
		{"key": "六安", "count": 11},
		{"key": "明光市", "count": 6},
		{"key": "北京市", "count": 5},
		{"key": "成都市", "count": 5},
		{"key": "池州", "count": 5},
		{"key": "芜湖", "count": 3},
		{"key": "铜陵", "count": 3},
		{"key": "宁国市", "count": 2},
		{"key": "宿州", "count": 2},
		{"key": "巢湖市", "count": 2},
		{"key": "桐城市", "count": 2},
		{"key": "天长市", "count": 1},
		{"key": "宁波市", "count": 1},
		{"key": "淮南", "count": 1},
		{"key": "江苏", "count": 4435667, "aaabbb": "1"},
		{"key": "苏州市", "count": 842243},
		{"key": "南京市", "count": 824043},
		{"key": "南通市", "count": 403431},
		{"key": "无锡市", "count": 317612},
		{"key": "徐州市", "count": 299127},
		{"key": "盐城市", "count": 258593},
		{"key": "泰州市", "count": 251034},
		{"key": "常州市", "count": 214472},
		{"key": "扬州市", "count": 187995},
		{"key": "淮安市", "count": 175585},
		{"key": "宿迁市", "count": 163395},
		{"key": "连云港市", "count": 133076},
		{"key": "镇江市", "count": 107756},
		{"key": "南通", "count": 51},
		{"key": "徐州", "count": 25},
		{"key": "盐城", "count": 14},
		{"key": "江苏省", "count": 8},
		{"key": "张家港市", "count": 6},
		{"key": "苏州", "count": 6},
		{"key": "泰州", "count": 4},
		{"key": "淮安", "count": 3},
		{"key": "启东市", "count": 2},
		{"key": "常州", "count": 2},
		{"key": "省级", "count": 2},
		{"key": "南昌市", "count": 1},
		{"key": "宿迁", "count": 1},
		{"key": "扬州", "count": 1},
		{"key": "昆山市", "count": 1},
		{"key": "深圳市", "count": 1},
		{"key": "浙江", "count": 4401850, "aaabbb": "1"},
		{"key": "杭州市", "count": 992043},
		{"key": "宁波市", "count": 700214},
		{"key": "温州市", "count": 414879},
		{"key": "绍兴市", "count": 352198},
		{"key": "金华市", "count": 324588},
		{"key": "台州市", "count": 316565},
		{"key": "嘉兴市", "count": 310341},
		{"key": "湖州市", "count": 271288},
		{"key": "衢州市", "count": 201524},
		{"key": "丽水市", "count": 152489},
		{"key": "舟山市", "count": 107685},
		{"key": "浙江省", "count": 46},
		{"key": "杭州", "count": 11},
		{"key": "舟山", "count": 9},
		{"key": "西安市", "count": 9},
		{"key": "湖州", "count": 5},
		{"key": "嘉兴", "count": 4},
		{"key": "温州", "count": 4},
		{"key": "市辖区", "count": 3},
		{"key": "宁波", "count": 2},
		{"key": "北京市", "count": 1},
		{"key": "台州", "count": 1},
		{"key": "金华", "count": 1},
		{"key": "河南", "count": 3666362, "aaabbb": "1"},
		{"key": "郑州市", "count": 673491},
		{"key": "洛阳市", "count": 328491},
		{"key": "新乡市", "count": 237255},
		{"key": "南阳市", "count": 223247},
		{"key": "安阳市", "count": 218754},
		{"key": "驻马店市", "count": 217813},
		{"key": "平顶山市", "count": 186979},
		{"key": "三门峡市", "count": 167211},
		{"key": "信阳市", "count": 154336},
		{"key": "商丘市", "count": 153689},
		{"key": "焦作市", "count": 149721},
		{"key": "周口市", "count": 144066},
		{"key": "许昌市", "count": 135852},
		{"key": "开封市", "count": 118859},
		{"key": "漯河市", "count": 94887},
		{"key": "濮阳市", "count": 88297},
		{"key": "鹤壁市", "count": 76808},
		{"key": "济源市", "count": 43054},
		{"key": "河南省直辖县", "count": 863},
		{"key": "安阳", "count": 4},
		{"key": "新乡", "count": 4},
		{"key": "开封", "count": 3},
		{"key": "焦作", "count": 3},
		{"key": "郑州", "count": 3},
		{"key": "商丘", "count": 2},
		{"key": "平顶山", "count": 2},
		{"key": "河南省", "count": 2},
		{"key": "北京市", "count": 1},
		{"key": "湖北", "count": 3654839, "aaabbb": "1"},
		{"key": "武汉市", "count": 1258813},
		{"key": "宜昌市", "count": 279842},
		{"key": "黄冈市", "count": 254597},
		{"key": "襄阳市", "count": 193143},
		{"key": "荆州市", "count": 165337},
		{"key": "十堰市", "count": 161218},
		{"key": "黄石市", "count": 160628},
		{"key": "荆门市", "count": 149306},
		{"key": "恩施土家族苗族自治州", "count": 148460},
		{"key": "孝感市", "count": 135179},
		{"key": "咸宁市", "count": 89598},
		{"key": "鄂州市", "count": 66172},
		{"key": "随州市", "count": 65980},
		{"key": "潜江市", "count": 29670},
		{"key": "仙桃市", "count": 28311},
		{"key": "天门市", "count": 20242},
		{"key": "神农架林区", "count": 10130},
		{"key": "湖北省直辖县", "count": 2865},
		{"key": "湖北省", "count": 70},
		{"key": "武汉", "count": 65},
		{"key": "宜昌", "count": 18},
		{"key": "常德市", "count": 12},
		{"key": "恩施市", "count": 11},
		{"key": "绍兴市", "count": 5},
		{"key": "恩施", "count": 4},
		{"key": "汉川市", "count": 3},
		{"key": "荆州", "count": 3},
		{"key": "北京市", "count": 2},
		{"key": "黄冈", "count": 2},
		{"key": "无锡", "count": 1},
		{"key": "四川", "count": 3470092, "aaabbb": "1"},
		{"key": "成都市", "count": 1064778},
		{"key": "绵阳市", "count": 185539},
		{"key": "宜宾市", "count": 170502},
		{"key": "凉山彝族自治州", "count": 143691},
		{"key": "泸州市", "count": 135888},
		{"key": "乐山市", "count": 131874},
		{"key": "广安市", "count": 131567},
		{"key": "德阳市", "count": 129990},
		{"key": "攀枝花市", "count": 121624},
		{"key": "阿坝藏族羌族自治州", "count": 117478},
		{"key": "南充市", "count": 109340},
		{"key": "达州市", "count": 108798},
		{"key": "内江市", "count": 103166},
		{"key": "遂宁市", "count": 91889},
		{"key": "雅安市", "count": 88964},
		{"key": "巴中市", "count": 86702},
		{"key": "眉山市", "count": 80066},
		{"key": "甘孜藏族自治州", "count": 74544},
		{"key": "广元市", "count": 73446},
		{"key": "自贡市", "count": 69646},
		{"key": "资阳市", "count": 53426},
		{"key": "赣州市", "count": 15},
		{"key": "泸州", "count": 11},
		{"key": "成都", "count": 3},
		{"key": "乐山", "count": 2},
		{"key": "内江", "count": 2},
		{"key": "四川省", "count": 2},
		{"key": "重庆市", "count": 2},
		{"key": "阿坝", "count": 2},
		{"key": " 阿坝藏族羌族自治州", "count": 1},
		{"key": "康定市", "count": 1},
		{"key": "达州", "count": 1},
		{"key": "河北", "count": 3294115, "aaabbb": "1"},
		{"key": "石家庄市", "count": 543675},
		{"key": "唐山市", "count": 417066},
		{"key": "保定市", "count": 330757},
		{"key": "邯郸市", "count": 278732},
		{"key": "张家口市", "count": 267044},
		{"key": "邢台市", "count": 250413},
		{"key": "沧州市", "count": 240797},
		{"key": "廊坊市", "count": 193701},
		{"key": "承德市", "count": 168829},
		{"key": "衡水市", "count": 144723},
		{"key": "秦皇岛市", "count": 139254},
		{"key": "雄安新区", "count": 624},
		{"key": "中国", "count": 254},
		{"key": "定州市", "count": 238},
		{"key": "辛集市", "count": 176},
		{"key": "河北省", "count": 80},
		{"key": "衡水", "count": 35},
		{"key": "保定", "count": 22},
		{"key": "天津市", "count": 12},
		{"key": "沧州", "count": 8},
		{"key": "北京市", "count": 7},
		{"key": "鄂尔多斯市", "count": 7},
		{"key": "通辽市", "count": 5},
		{"key": "宣化区", "count": 4},
		{"key": "阿克苏地区", "count": 3},
		{"key": "吕梁市", "count": 2},
		{"key": "曹妃甸区", "count": 2},
		{"key": "赤峰市", "count": 2},
		{"key": "兴安盟", "count": 1},
		{"key": "内蒙古自治区", "count": 1},
		{"key": "山西省", "count": 1},
		{"key": "晋中市", "count": 1},
		{"key": "景德镇市", "count": 1},
		{"key": "芜湖市", "count": 1},
		{"key": "锡林郭勒盟", "count": 1},
		{"key": "北京", "count": 3124715, "aaabbb": "1"},
		{"key": "北京市", "count": 2845500},
		{"key": "北京", "count": 175},
		{"key": "台湾省", "count": 1},
		{"key": "湖南", "count": 3107662, "aaabbb": "1"},
		{"key": "长沙市", "count": 420310},
		{"key": "常德市", "count": 346770},
		{"key": "衡阳市", "count": 236878},
		{"key": "岳阳市", "count": 228627},
		{"key": "株洲市", "count": 216311},
		{"key": "邵阳市", "count": 211242},
		{"key": "郴州市", "count": 204226},
		{"key": "永州市", "count": 187618},
		{"key": "湘潭市", "count": 184341},
		{"key": "娄底市", "count": 160831},
		{"key": "怀化市", "count": 158138},
		{"key": "益阳市", "count": 153986},
		{"key": "湘西土家族苗族自治州", "count": 85236},
		{"key": "张家界市", "count": 68379},
		{"key": "常德", "count": 47},
		{"key": "湖南省", "count": 10},
		{"key": "郴州", "count": 7},
		{"key": "长沙", "count": 6},
		{"key": "株洲", "count": 5},
		{"key": "岳阳", "count": 4},
		{"key": "北京市", "count": 1},
		{"key": "广西", "count": 2763650, "aaabbb": "1"},
		{"key": "南宁市", "count": 577313},
		{"key": "柳州市", "count": 263512},
		{"key": "桂林市", "count": 226579},
		{"key": "玉林市", "count": 218418},
		{"key": "百色市", "count": 209251},
		{"key": "河池市", "count": 138393},
		{"key": "梧州市", "count": 127526},
		{"key": "贵港市", "count": 121144},
		{"key": "贺州市", "count": 118424},
		{"key": "崇左市", "count": 118201},
		{"key": "钦州市", "count": 113341},
		{"key": "北海市", "count": 108664},
		{"key": "来宾市", "count": 88909},
		{"key": "防城港市", "count": 72234},
		{"key": "南宁", "count": 22},
		{"key": "柳州", "count": 18},
		{"key": "桂林", "count": 13},
		{"key": "崇左", "count": 4},
		{"key": "贵港", "count": 3},
		{"key": "北京市", "count": 2},
		{"key": "广西壮族自治区", "count": 2},
		{"key": "云南", "count": 2170568, "aaabbb": "1"},
		{"key": "昆明市", "count": 629160},
		{"key": "红河哈尼族彝族自治州", "count": 167863},
		{"key": "曲靖市", "count": 136756},
		{"key": "大理白族自治州", "count": 127998},
		{"key": "文山壮族苗族自治州", "count": 116749},
		{"key": "玉溪市", "count": 109365},
		{"key": "保山市", "count": 100408},
		{"key": "昭通市", "count": 89061},
		{"key": "楚雄彝族自治州", "count": 88131},
		{"key": "德宏傣族景颇族自治州", "count": 77106},
		{"key": "普洱市", "count": 70504},
		{"key": "临沧市", "count": 64399},
		{"key": "丽江市", "count": 60618},
		{"key": "西双版纳傣族自治州", "count": 39556},
		{"key": "怒江傈僳族自治州", "count": 33019},
		{"key": "迪庆藏族自治州", "count": 27329},
		{"key": "云南省", "count": 18},
		{"key": "昆明", "count": 9},
		{"key": "德宏市", "count": 1},
		{"key": "怒江", "count": 1},
		{"key": "红河州", "count": 1},
		{"key": "黔南布依族苗族自治州", "count": 1},
		{"key": "内蒙古", "count": 2103716, "aaabbb": "1"},
		{"key": "呼和浩特市", "count": 328682},
		{"key": "包头市", "count": 317351},
		{"key": "鄂尔多斯市", "count": 235804},
		{"key": "呼伦贝尔市", "count": 221260},
		{"key": "赤峰市", "count": 181006},
		{"key": "通辽市", "count": 154464},
		{"key": "锡林郭勒盟", "count": 135571},
		{"key": "乌兰察布市", "count": 82661},
		{"key": "巴彦淖尔市", "count": 77601},
		{"key": "乌海市", "count": 77036},
		{"key": "兴安盟", "count": 57710},
		{"key": "阿拉善盟", "count": 43380},
		{"key": "内蒙古自治区", "count": 8},
		{"key": "鄂尔多斯", "count": 6},
		{"key": "乌兰察布市本级", "count": 2},
		{"key": "巴彦淖尔", "count": 2},
		{"key": "丰镇市", "count": 1},
		{"key": "山西", "count": 2096988, "aaabbb": "1"},
		{"key": "太原市", "count": 429754},
		{"key": "运城市", "count": 223795},
		{"key": "长治市", "count": 203082},
		{"key": "大同市", "count": 181022},
		{"key": "临汾市", "count": 158430},
		{"key": "忻州市", "count": 155193},
		{"key": "晋中市", "count": 142101},
		{"key": "吕梁市", "count": 126085},
		{"key": "晋城市", "count": 109804},
		{"key": "阳泉市", "count": 81033},
		{"key": "朔州市", "count": 77921},
		{"key": "山西省", "count": 16},
		{"key": "运城", "count": 8},
		{"key": "河北省", "count": 5},
		{"key": "海南省", "count": 4},
		{"key": "综改示范区", "count": 4},
		{"key": "吕梁", "count": 2},
		{"key": "忻州", "count": 2},
		{"key": "应县", "count": 1},
		{"key": "福建", "count": 2070469, "aaabbb": "1"},
		{"key": "福州市", "count": 564782},
		{"key": "厦门市", "count": 352850},
		{"key": "漳州市", "count": 225186},
		{"key": "泉州市", "count": 198332},
		{"key": "南平市", "count": 129467},
		{"key": "龙岩市", "count": 128762},
		{"key": "宁德市", "count": 127930},
		{"key": "三明市", "count": 114405},
		{"key": "莆田市", "count": 107855},
		{"key": "包头市", "count": 52},
		{"key": "龙岩", "count": 12},
		{"key": "福州", "count": 8},
		{"key": "福建省", "count": 4},
		{"key": "宁德", "count": 2},
		{"key": "平潭综合实验区", "count": 1},
		{"key": "陕西", "count": 1902928, "aaabbb": "1"},
		{"key": "西安市", "count": 675710},
		{"key": "榆林市", "count": 178579},
		{"key": "延安市", "count": 146406},
		{"key": "咸阳市", "count": 113056},
		{"key": "宝鸡市", "count": 111059},
		{"key": "安康市", "count": 106603},
		{"key": "渭南市", "count": 96026},
		{"key": "汉中市", "count": 86647},
		{"key": "铜川市", "count": 43244},
		{"key": "商洛市", "count": 39509},
		{"key": "陕西省市", "count": 1944},
		{"key": "陕西省", "count": 40},
		{"key": "西安", "count": 10},
		{"key": "榆林", "count": 2},
		{"key": "北京市", "count": 1},
		{"key": "渭南", "count": 1},
		{"key": "辽宁", "count": 1851028, "aaabbb": "1"},
		{"key": "沈阳市", "count": 556549},
		{"key": "大连市", "count": 328224},
		{"key": "鞍山市", "count": 127900},
		{"key": "锦州市", "count": 91088},
		{"key": "朝阳市", "count": 87185},
		{"key": "阜新市", "count": 74302},
		{"key": "抚顺市", "count": 74102},
		{"key": "丹东市", "count": 70618},
		{"key": "营口市", "count": 69206},
		{"key": "葫芦岛市", "count": 60550},
		{"key": "铁岭市", "count": 57758},
		{"key": "盘锦市", "count": 57059},
		{"key": "辽阳市", "count": 55859},
		{"key": "本溪市", "count": 41575},
		{"key": "沈阳市铁西区", "count": 20},
		{"key": "沈阳", "count": 9},
		{"key": "凌源市", "count": 4},
		{"key": "沈阳市辽中区", "count": 4},
		{"key": "葫芦岛", "count": 4},
		{"key": "大连", "count": 3},
		{"key": "沈阳市沈河区", "count": 2},
		{"key": "沈阳市法库县", "count": 2},
		{"key": "沈阳市浑南区", "count": 2},
		{"key": "辽阳", "count": 2},
		{"key": "北京市", "count": 1},
		{"key": "沈阳市于洪区", "count": 1},
		{"key": "沈阳市和平区", "count": 1},
		{"key": "沈阳市康平县", "count": 1},
		{"key": "沈阳市新民市", "count": 1},
		{"key": "沈阳市皇姑区", "count": 1},
		{"key": "沈阳市经济技术开发区", "count": 1},
		{"key": "沈阳市自贸区", "count": 1},
		{"key": "深圳市", "count": 1},
		{"key": "鞍山", "count": 1},
		{"key": "天津", "count": 1802752, "aaabbb": "1"},
		{"key": "天津市", "count": 1771141},
		{"key": "天津", "count": 67},
		{"key": "市辖区", "count": 2},
		{"key": "江西", "count": 1756655, "aaabbb": "1"},
		{"key": "南昌市", "count": 343937},
		{"key": "赣州市", "count": 321017},
		{"key": "九江市", "count": 170996},
		{"key": "上饶市", "count": 167291},
		{"key": "吉安市", "count": 114272},
		{"key": "宜春市", "count": 108016},
		{"key": "抚州市", "count": 96319},
		{"key": "新余市", "count": 69877},
		{"key": "景德镇市", "count": 54104},
		{"key": "萍乡市", "count": 52328},
		{"key": "鹰潭市", "count": 46340},
		{"key": "赣州", "count": 8},
		{"key": "南昌", "count": 6},
		{"key": "jx_srsqsxrmzfw_zt_ggzyjyzx", "count": 2},
		{"key": "江西省", "count": 2},
		{"key": "吉安", "count": 1},
		{"key": "宜春", "count": 1},
		{"key": "上海", "count": 1743476, "aaabbb": "1"},
		{"key": "上海市", "count": 1704903},
		{"key": "上海", "count": 20},
		{"key": "甘肃", "count": 1617088, "aaabbb": "1"},
		{"key": "兰州市", "count": 361451},
		{"key": "酒泉市", "count": 135240},
		{"key": "临夏回族自治州", "count": 131968},
		{"key": "天水市", "count": 114734},
		{"key": "张掖市", "count": 109374},
		{"key": "平凉市", "count": 108370},
		{"key": "庆阳市", "count": 90630},
		{"key": "白银市", "count": 82210},
		{"key": "陇南市", "count": 76131},
		{"key": "武威市", "count": 75513},
		{"key": "定西市", "count": 71037},
		{"key": "甘南藏族自治州", "count": 56897},
		{"key": "嘉峪关市", "count": 40115},
		{"key": "金昌市", "count": 27609},
		{"key": "张掖", "count": 15},
		{"key": "甘肃省", "count": 6},
		{"key": "厦门市", "count": 3},
		{"key": "北京市", "count": 1},
		{"key": "西安", "count": 1},
		{"key": "新疆", "count": 1610315, "aaabbb": "1"},
		{"key": "乌鲁木齐市", "count": 323937},
		{"key": "喀什地区", "count": 167416},
		{"key": "巴音郭楞蒙古自治州", "count": 144437},
		{"key": "阿克苏地区", "count": 119623},
		{"key": "昌吉回族自治州", "count": 106320},
		{"key": "伊犁哈萨克自治州", "count": 86560},
		{"key": "阿勒泰地区", "count": 79443},
		{"key": "克拉玛依市", "count": 60455},
		{"key": "塔城地区", "count": 59067},
		{"key": "和田地区", "count": 55855},
		{"key": "哈密市", "count": 50247},
		{"key": "克孜勒苏柯尔克孜自治州", "count": 34835},
		{"key": "博尔塔拉蒙古自治州", "count": 33795},
		{"key": "石河子市", "count": 33203},
		{"key": "吐鲁番市", "count": 28939},
		{"key": "阿拉尔市", "count": 19590},
		{"key": "五家渠市", "count": 8152},
		{"key": "图木舒克市", "count": 8006},
		{"key": "铁门关市", "count": 7600},
		{"key": "新疆自治区", "count": 4025},
		{"key": "哈密地区", "count": 1796},
		{"key": "北屯市", "count": 1360},
		{"key": "双河市", "count": 1238},
		{"key": "阿克苏地区市", "count": 1081},
		{"key": "新疆自治区直辖县", "count": 1020},
		{"key": "昆玉市", "count": 943},
		{"key": "可克达拉市", "count": 920},
		{"key": "库车市", "count": 455},
		{"key": "胡杨河市", "count": 35},
		{"key": "北京市", "count": 5},
		{"key": "自治区直辖县级行政区划", "count": 3},
		{"key": "伊犁州市", "count": 1},
		{"key": "和田", "count": 1},
		{"key": "重庆", "count": 1459563, "aaabbb": "1"},
		{"key": "重庆市", "count": 1436528},
		{"key": "彭水县", "count": 94},
		{"key": "垫江县", "count": 16},
		{"key": "重庆", "count": 9},
		{"key": "石柱土家族自治县", "count": 7},
		{"key": "丰都县", "count": 5},
		{"key": "巫溪县", "count": 5},
		{"key": "城口县", "count": 3},
		{"key": "奉节县", "count": 2},
		{"key": "云阳县", "count": 1},
		{"key": "巫山县", "count": 1},
		{"key": "忠县", "count": 1},
		{"key": "秀山土家族苗族自治县", "count": 1},
		{"key": "贵州", "count": 1448229, "aaabbb": "1"},
		{"key": "贵阳市", "count": 331903},
		{"key": "遵义市", "count": 189588},
		{"key": "黔南布依族苗族自治州", "count": 147396},
		{"key": "黔东南苗族侗族自治州", "count": 138726},
		{"key": "毕节市", "count": 132889},
		{"key": "六盘水市", "count": 98443},
		{"key": "铜仁市", "count": 88046},
		{"key": "黔西南布依族苗族自治州", "count": 83106},
		{"key": "安顺市", "count": 73824},
		{"key": "贵州市", "count": 2659},
		{"key": "凯里市", "count": 24},
		{"key": " 黔西南布依族苗族自治州", "count": 11},
		{"key": "贵州省", "count": 8},
		{"key": "黑龙江", "count": 1164337, "aaabbb": "1"},
		{"key": "哈尔滨市", "count": 377749},
		{"key": "大庆市", "count": 149320},
		{"key": "齐齐哈尔市", "count": 91197},
		{"key": "牡丹江市", "count": 69058},
		{"key": "佳木斯市", "count": 62370},
		{"key": "绥化市", "count": 61667},
		{"key": "鸡西市", "count": 59334},
		{"key": "七台河市", "count": 44406},
		{"key": "鹤岗市", "count": 43695},
		{"key": "黑河市", "count": 42376},
		{"key": "双鸭山市", "count": 40651},
		{"key": "伊春市", "count": 32857},
		{"key": "大兴安岭地区", "count": 16792},
		{"key": "大兴安岭市", "count": 15},
		{"key": "哈尔滨", "count": 7},
		{"key": "黑龙江省", "count": 6},
		{"key": "绥化", "count": 5},
		{"key": "农垦总局市", "count": 3},
		{"key": "双鸭山", "count": 2},
		{"key": "大庆", "count": 2},
		{"key": "牡丹江", "count": 1},
		{"key": "吉林", "count": 954260, "aaabbb": "1"},
		{"key": "长春市", "count": 339720},
		{"key": "吉林市", "count": 126511},
		{"key": "通化市", "count": 68217},
		{"key": "延边朝鲜族自治州", "count": 63886},
		{"key": "松原市", "count": 62519},
		{"key": "白城市", "count": 60969},
		{"key": "白山市", "count": 55340},
		{"key": "四平市", "count": 53381},
		{"key": "辽源市", "count": 36715},
		{"key": "吉林", "count": 16},
		{"key": "白城", "count": 4},
		{"key": "吉林省", "count": 2},
		{"key": "延边州", "count": 2},
		{"key": "延吉", "count": 1},
		{"key": "松原", "count": 1},
		{"key": "辽源", "count": 1},
		{"key": "海南", "count": 720772, "aaabbb": "1"},
		{"key": "海口市", "count": 179605},
		{"key": "东方市", "count": 98845},
		{"key": "三亚市", "count": 77256},
		{"key": "儋州市", "count": 31381},
		{"key": "文昌市", "count": 26727},
		{"key": "琼海市", "count": 18232},
		{"key": "陵水黎族自治县", "count": 17549},
		{"key": "白沙黎族自治县", "count": 15966},
		{"key": "乐东黎族自治县", "count": 15217},
		{"key": "万宁市", "count": 14035},
		{"key": "临高县", "count": 13624},
		{"key": "昌江黎族自治县", "count": 13506},
		{"key": "澄迈县", "count": 13403},
		{"key": "五指山市", "count": 13253},
		{"key": "定安县", "count": 10738},
		{"key": "琼中黎族苗族自治县", "count": 9320},
		{"key": "保亭黎族苗族自治县", "count": 8862},
		{"key": "屯昌县", "count": 8232},
		{"key": "三沙市", "count": 6276},
		{"key": "海南省直辖县", "count": 2383},
		{"key": "海南省", "count": 168},
		{"key": "长沙", "count": 40},
		{"key": "海口", "count": 6},
		{"key": "青海", "count": 577879, "aaabbb": "1"},
		{"key": "西宁市", "count": 198423},
		{"key": "海西蒙古族藏族自治州", "count": 68038},
		{"key": "海东市", "count": 61490},
		{"key": "海南藏族自治州", "count": 45547},
		{"key": "玉树藏族自治州", "count": 36160},
		{"key": "海北藏族自治州", "count": 32598},
		{"key": "黄南藏族自治州", "count": 29613},
		{"key": "果洛藏族自治州", "count": 29166},
		{"key": "海西州", "count": 427},
		{"key": "北京市", "count": 2},
		{"key": "宁夏", "count": 568655, "aaabbb": "1"},
		{"key": "银川市", "count": 214652},
		{"key": "吴忠市", "count": 94042},
		{"key": "固原市", "count": 58146},
		{"key": "中卫市", "count": 49298},
		{"key": "石嘴山市", "count": 40393},
		{"key": "宁夏回族自治区", "count": 4},
		{"key": "固原", "count": 2},
		{"key": "北京市", "count": 1},
		{"key": "西藏", "count": 237494, "aaabbb": "1"},
		{"key": "拉萨市", "count": 63551},
		{"key": "日喀则市", "count": 43698},
		{"key": "林芝市", "count": 24358},
		{"key": "昌都市", "count": 23398},
		{"key": "山南市", "count": 21746},
		{"key": "那曲市", "count": 21672},
		{"key": "阿里地区", "count": 13523},
		{"key": "日喀则", "count": 15},
		{"key": "昌都", "count": 9},
		{"key": "那曲", "count": 8},
		{"key": "山南", "count": 6},
		{"key": "拉萨", "count": 3},
		{"key": "阿里", "count": 2},
		{"key": "香港", "count": 534, "aaabbb": "1"},
		{"key": "香港岛", "count": 7},
		{"key": "新界区", "count": 2},
		{"key": "澳门", "count": 211, "aaabbb": "1"},
		{"key": "澳门半岛", "count": 2},
		{"key": "台湾", "count": 126, "aaabbb": "1"},
		{"key": "河北省", "count": 22, "aaabbb": "1"},
		{"key": "唐山市", "count": 16},
		{"key": "邯郸市", "count": 2},
		{"key": "石家庄市", "count": 1},
		{"key": "广东省", "count": 21, "aaabbb": "1"},
		{"key": "佛山市", "count": 7},
		{"key": "湛江市", "count": 3},
		{"key": "广州市", "count": 2},
		{"key": "韶关市", "count": 2},
		{"key": "中山市", "count": 1},
		{"key": "揭阳市", "count": 1},
		{"key": "汕尾市", "count": 1},
		{"key": "深圳市", "count": 1},
		{"key": "潮州市", "count": 1},
		{"key": "山东省", "count": 18, "aaabbb": "1"},
		{"key": "济宁市", "count": 11},
		{"key": "威海市", "count": 2},
		{"key": "临沂市", "count": 1},
		{"key": "泰安市", "count": 1},
		{"key": "潍坊市", "count": 1},
		{"key": "青岛市", "count": 1},
		{"key": "江苏省", "count": 17, "aaabbb": "1"},
		{"key": "苏州市", "count": 6},
		{"key": "扬州市", "count": 5},
		{"key": "南京市", "count": 1},
		{"key": "南通市", "count": 1},
		{"key": "泰州市", "count": 1},
		{"key": "石家庄市", "count": 1},
		{"key": "河南省", "count": 14, "aaabbb": "1"},
		{"key": "郑州市", "count": 5},
		{"key": "三门峡市", "count": 2},
		{"key": "信阳市", "count": 2},
		{"key": "商丘市", "count": 1},
		{"key": "济源市", "count": 1},
		{"key": "濮阳市", "count": 1},
		{"key": "驻马店市", "count": 1},
		{"key": "安徽省", "count": 11, "aaabbb": "1"},
		{"key": "安庆市", "count": 3},
		{"key": "滁州市", "count": 2},
		{"key": "芜湖市", "count": 2},
		{"key": "合肥市", "count": 1},
		{"key": "池州市", "count": 1},
		{"key": "蚌埠市", "count": 1},
		{"key": "甘肃省", "count": 9, "aaabbb": "1"},
		{"key": "平凉市", "count": 3},
		{"key": "甘南藏族自治州", "count": 2},
		{"key": "酒泉市", "count": 2},
		{"key": "庆阳市", "count": 1},
		{"key": "白银市", "count": 1},
		{"key": "陕西省", "count": 9, "aaabbb": "1"},
		{"key": "榆林市", "count": 3},
		{"key": "西安市", "count": 2},
		{"key": "宝鸡市", "count": 1},
		{"key": "延安市", "count": 1},
		{"key": "汉中市", "count": 1},
		{"key": "辽宁省", "count": 8, "aaabbb": "1"},
		{"key": "辽阳市", "count": 3},
		{"key": "朝阳市", "count": 2},
		{"key": "本溪市", "count": 2},
		{"key": "葫芦岛市", "count": 1},
		{"key": "吉林省", "count": 7, "aaabbb": "1"},
		{"key": "松原市", "count": 2},
		{"key": "通化市", "count": 2},
		{"key": "长春市", "count": 2},
		{"key": "吉林市", "count": 1},
		{"key": "四川省", "count": 7, "aaabbb": "1"},
		{"key": "内江市", "count": 2},
		{"key": "达州市", "count": 2},
		{"key": "巴中市", "count": 1},
		{"key": "广安市", "count": 1},
		{"key": "成都市", "count": 1},
		{"key": "浙江省", "count": 7, "aaabbb": "1"},
		{"key": "温州市", "count": 3},
		{"key": "嘉兴市", "count": 1},
		{"key": "成都市", "count": 1},
		{"key": "衢州市", "count": 1},
		{"key": "铜陵市", "count": 1},
		{"key": "山西省", "count": 6, "aaabbb": "1"},
		{"key": "晋中市", "count": 2},
		{"key": "太原市", "count": 1},
		{"key": "忻州市", "count": 1},
		{"key": "晋城市", "count": 1},
		{"key": "运城市", "count": 1},
		{"key": "江西省", "count": 6, "aaabbb": "1"},
		{"key": "萍乡市", "count": 3},
		{"key": "南昌市", "count": 1},
		{"key": "宜春市", "count": 1},
		{"key": "赣州市", "count": 1},
		{"key": "湖南省", "count": 6, "aaabbb": "1"},
		{"key": "益阳市", "count": 2},
		{"key": "长沙市", "count": 2},
		{"key": "常德市", "count": 1},
		{"key": "福建省", "count": 6, "aaabbb": "1"},
		{"key": "厦门市", "count": 2},
		{"key": "漳州市", "count": 2},
		{"key": "南平市", "count": 1},
		{"key": "宁德市", "count": 1},
		{"key": "北京市", "count": 5, "aaabbb": "1"},
		{"key": "北京市", "count": 5},
		{"key": "湖北省", "count": 5, "aaabbb": "1"},
		{"key": "宜昌市", "count": 2},
		{"key": "武汉市", "count": 2},
		{"key": "荆门市", "count": 1},
		{"key": "贵州省", "count": 5, "aaabbb": "1"},
		{"key": "铜仁市", "count": 1},
		{"key": "重庆市", "count": 5, "aaabbb": "1"},
		{"key": "重庆市", "count": 5},
		{"key": "云南省", "count": 3, "aaabbb": "1"},
		{"key": "保山市", "count": 1},
		{"key": "大理白族自治州", "count": 1},
		{"key": "玉溪市", "count": 1},
		{"key": "海南省", "count": 3, "aaabbb": "1"},
		{"key": "海口市", "count": 1},
		{"key": "黑龙江省", "count": 2, "aaabbb": "1"},
		{"key": "哈尔滨市", "count": 1},
		{"key": "绥化市", "count": 1},
	}

	arr = []map[string]interface{}{
		{"key": "贵州省", "aaabbb": "2"},
		{"key": "河北省", "aaabbb": "2"},
		{"key": "广东省", "aaabbb": "2"},
		{"key": "江苏省", "aaabbb": "2"},
		{"key": "海南省", "aaabbb": "2"},
		{"key": "黑龙江省", "aaabbb": "2"},
		{"key": "哈尔滨市"},
		{"key": "绥化市"},
		{"key": "安徽省", "aaabbb": "1"},
		{"key": "山东省", "aaabbb": "1"},
		{"key": "河南省", "aaabbb": "1"},
		{"key": "湖南省", "aaabbb": "1"},
		{"key": "陕西省", "aaabbb": "1"},
	}
	all_data := make(map[string]map[string]string, 0)
	data := make(map[string]string, 0)
	area := ""
	for _, v := range arr {
		tmp := *qu.ObjToMap(v)
		isArea := qu.IntAll(tmp["aaabbb"])
		if isArea > 0 {
			if len(data) > 0 {
				all_data[area] = data
			}
			data = make(map[string]string, 0)
			area = qu.ObjToString(tmp["key"])
		} else {
			key := qu.ObjToString(tmp["key"])
			count := qu.IntAll(tmp["count"])
			if count < 10000 {
				data[key] = ""
			}
		}
	}

	log.Debug(all_data)
	return
	total := int64(0)
	for area, cityArr := range all_data {
		for city, _ := range cityArr {
			cursor, err := esclient.Scan("bidding_v1").Query(es_elastic.NewBoolQuery().Must(es_elastic.NewTermQuery("area", area), es_elastic.NewTermQuery("city", city))).
				Size(200).Do()
			if err != nil {
				log.Debug("cursor", err)
			}
			if cursor.Results == nil {
				log.Debug("results != nil; got nil")
			}
			if cursor.Results.Hits == nil {
				log.Debug("expected results.Hits != nil; got nil")
			}
			total += cursor.TotalHits()
			log.Debug("当前查询正常数：", cursor.TotalHits(), "总数：", total)

			//多线程 - 处理数据
			pool_es := make(chan bool, 5)
			wg_es := &sync.WaitGroup{}
			pages, numDocs := 0, 0
			for {
				searchResult, err := cursor.Next()
				if err != nil {
					if err.Error() == "EOS" {
						break
					} else {
						log.Debug("cursor searchResult", err)
					}
				}
				pages++
				isLog := false
				for _, hit := range searchResult.Hits.Hits {
					tmp := make(map[string]interface{})
					err := json.Unmarshal(*hit.Source, &tmp)
					if err != nil {
						log.Debug("json Unmarshal error")
						continue
					}
					if !isLog && numDocs%10000 == 0 {
						//log.Debug("当前条数：", numDocs, "Es数据：", tmp["_id"])
						isLog = true
					}

					numDocs++
					area := qu.ObjToString(tmp["area"])
					city := qu.ObjToString(tmp["city"])
					district := qu.ObjToString(tmp["district"])
					tmpid := qu.ObjToString(tmp["_id"])
					pool_es <- true
					wg_es.Add(1)
					go func(area string, city string, district string, tmpid string) {
						defer func() {
							<-pool_es
							wg_es.Done()
						}()
						if city != "" || district != "" {
							save_mgo.Save("zktest_err_err_data", map[string]interface{}{
								"_id":      StringTOBsonId(tmpid),
								"area":     area,
								"city":     city,
								"district": district,
							})
						}
					}(area, city, district, tmpid)
				}
			}
			wg_es.Wait()
		}
	}

	log.Debug("is all over ：", total)

}

//导出差额数据--省市区 bidding 与 85
func exportErrAreaCityDistrictData() {

	//导出相关-分包数据-ck!=1 , 包含,
	sess := python_mgo.GetMgoConn()
	defer python_mgo.DestoryMongoConn(sess)
	q, total, iserr := map[string]interface{}{}, 0, 0
	is_pool := make(chan bool, 20)
	is_wg := &sync.WaitGroup{}
	//repair_acd_data
	it := sess.DB(python_mgo.DbName).C("bidding_back").Find(&q).Select(map[string]interface{}{
		"area":        1,
		"city":        1,
		"district":    1,
		"extracttype": 1,
	}).Iter()
	for tmp := make(map[string]interface{}); it.Next(&tmp); total++ {
		if total%10000 == 0 {
			log.Debug("index", total, iserr, tmp["_id"])
		}
		extracttype := qu.IntAll(tmp["extracttype"])
		if extracttype == -1 {
			tmp = make(map[string]interface{})
			continue
		}
		//开线程-去校验
		is_pool <- true
		is_wg.Add(1)
		go func(tmp map[string]interface{}) {
			defer func() {
				<-is_pool
				is_wg.Done()
			}()
			//更新-
			area_old := qu.ObjToString(tmp["area"])
			city_old := qu.ObjToString(tmp["city"])
			district_old := qu.ObjToString(tmp["district"])
			tmpid := BsonTOStringId(tmp["_id"])

			data := save_mgo.FindById("result_20210108", tmpid)
			if data != nil && len(data) > 2 {
				new_area := qu.ObjToString(data["area"])
				new_city := qu.ObjToString(data["city"])
				new_district := qu.ObjToString(data["district"])
				if area_old != new_area || city_old != new_city || district_old != new_district {
					iserr++
					save_mgo.Save("zktest_acd_data", tmp)
				}
			}
		}(tmp)
		tmp = make(map[string]interface{})
	}
	log.Debug("is over ", total, iserr)
}

//导出-长度数据
func exportBuyerWinnerLengthData() {
	sess := save_mgo.GetMgoConn()
	defer save_mgo.DestoryMongoConn(sess)
	q, total, isok := map[string]interface{}{
		"_id": map[string]interface{}{
			"$gte": StringTOBsonId("610573800000000000000000"),
		},
	}, 0, 0
	it := sess.DB(save_mgo.DbName).C("result_20210108").Find(&q).Iter()
	for tmp := make(map[string]interface{}); it.Next(&tmp); total++ {
		if total%10000 == 0 {
			log.Debug("current index", total, isok, tmp["_id"])
		}
		repeat := qu.IntAll(tmp["repeat"])
		if repeat > 0 {
			tmp = make(map[string]interface{})
			continue
		}
		buyer := qu.ObjToString(tmp["buyer"])
		winner := qu.ObjToString(tmp["winner"])
		if (utf8.RuneCountInString(buyer) < 5 && buyer != "") ||
			(utf8.RuneCountInString(winner) < 5 && winner != "") {
			isok++
			save_mgo.Save("zktest_buyer_stand_data", tmp)
		}
		tmp = make(map[string]interface{})
	}
	log.Debug("export unit is over", total, isok)
}

//导出新城市数据
func exportNewCKPackageData() {
	//导出相关-分包数据-ck!=1 , 包含,
	sess := save_mgo.GetMgoConn()
	defer save_mgo.DestoryMongoConn(sess)
	q, total := map[string]interface{}{
		"ck_s_winner": map[string]interface{}{
			"$ne": 1,
		},
	}, 0
	isok := 0
	it := sess.DB(save_mgo.DbName).C("zktest_package_data").Find(&q).Select(map[string]interface{}{
		"s_winner": 1,
		"href":     1,
	}).Iter()
	for tmp := make(map[string]interface{}); it.Next(&tmp); total++ {
		s_winner := qu.ObjToString(tmp["s_winner"])
		if strings.Contains(s_winner, ",") {
			data := save_mgo.FindById("zktest_package_data_old", BsonTOStringId(tmp["_id"]))
			old_s_winner := qu.ObjToString(data["s_winner"])
			if old_s_winner != s_winner {
				dict := tmp
				jyhref := fmt.Sprintf(Url, qu.CommonEncodeArticle("content", BsonTOStringId(tmp["_id"])))
				dict["jyhref"] = jyhref
				dict["old_s_winner"] = old_s_winner
				save_mgo.Save("111222", dict)
			}
		}
		tmp = make(map[string]interface{})
	}

	log.Debug("is over ", total, isok)
}

//根据id 导出指定数据
func exportFieldScoreIDBIdding() {
	sess := save_mgo.GetMgoConn()
	defer save_mgo.DestoryMongoConn(sess)
	q, total := map[string]interface{}{}, 0
	ck_data := make(map[string]map[string]interface{}, 0)
	it := sess.DB(save_mgo.DbName).C("zktest_fieldscore_data_new_ck").Find(&q).Iter()
	for tmp := make(map[string]interface{}); it.Next(&tmp); total++ {
		key_id := BsonTOStringId(tmp["_id"])
		ck_data[key_id] = tmp
		tmp = make(map[string]interface{})
	}
	log.Debug("结束：", total, len(ck_data))

	fieldArr := []string{"buyer", "s_winner", "budget", "bidamount", "projectname", "projectcode"}
	total = 0
	it = sess.DB(save_mgo.DbName).C("zktest_fieldscore_data_new").Find(&q).Iter()
	for tmp := make(map[string]interface{}); it.Next(&tmp); total++ {
		key_id := BsonTOStringId(tmp["_id"])
		field_score := *qu.ObjToMap(tmp["field_score"])
		dict := make(map[string]interface{})
		dict["_id"] = tmp["_id"]
		dict["href"] = tmp["href"]
		dict["subtype"] = tmp["subtype"]
		for _, v := range fieldArr {

			//当前字段分
			score := int64(-1)
			score_data := *qu.ObjToMap(field_score[v])
			if score_data != nil {
				score = qu.Int64All(score_data["score"])
			}

			isOK := 0
			if v == "budget" || v == "bidamount" {
				value := qu.Int64All(tmp[v])
				ck_key := fmt.Sprintf("ck_%s", v)
				ck_num := qu.Int64All(ck_data[key_id][ck_key])
				if ck_num > 0 { //比对两边的值
					if value == qu.Int64All(ck_data[key_id][v]) {
						isOK = 1
					} else {
						isOK = -1
					}
				}
			} else {
				value := qu.ObjToString(tmp[v])
				ck_key := fmt.Sprintf("ck_%s", v)
				ck_num := qu.Int64All(ck_data[key_id][ck_key])
				if ck_num > 0 { //比对两边的值
					if value == qu.ObjToString(ck_data[key_id][v]) {
						isOK = 1
					} else {
						isOK = -1
					}
				}
			}

			key_1 := fmt.Sprintf("%s_s", v)
			key_2 := fmt.Sprintf("%s_r", v)
			desc := "未标"
			if isOK == 1 {
				desc = "正确"
			} else if isOK == -1 {
				desc = "错误"
			}
			if score == -1 {
				desc = ""
			}
			dict[key_1] = score
			dict[key_2] = desc
		}

		save_mgo.Save("111", dict)
		tmp = make(map[string]interface{})
	}
	log.Debug("结束：", total, len(ck_data))

}

//导出多站点数据
func exporMulSiteData() {
	sess := save_mgo.GetMgoConn()
	defer save_mgo.DestoryMongoConn(sess)
	q, total := map[string]interface{}{}, 0
	it := sess.DB(save_mgo.DbName).C("bidding").Find(&q).Sort("-_id").Iter()
	siteMap, isok, isZhao, isZhong := make(map[string]int, 0), 0, 0, 0
	for tmp := make(map[string]interface{}); it.Next(&tmp); total++ {
		if total%1000 == 0 {
			log.Debug("current index", total)
		}

		if isok >= 500 {
			break
		}
		site := qu.ObjToString(tmp["site"])
		tmpid := BsonTOStringId(tmp["_id"])
		subtype := qu.ObjToString(tmp["subtype"])
		jyhref := fmt.Sprintf(Url, qu.CommonEncodeArticle("content", tmpid))
		dict := tmp
		dict["jyhref"] = jyhref
		if subtype == "中标" || subtype == "成交" || subtype == "合同" {
			num_site := qu.IntAll(siteMap[site])
			if num_site < 2 && isZhong < 300 {
				isok++
				isZhong++
				siteMap[site] = num_site + 1
				save_mgo.Save("zktest_fieldscore_data", dict)
			}
		} else if subtype == "招标" || subtype == "邀标" || subtype == "询价" ||
			subtype == "竞谈" || subtype == "单一" || subtype == "竞价" {
			num_site := qu.IntAll(siteMap[site])
			if num_site < 2 && isZhao < 200 {
				isok++
				siteMap[site] = num_site + 1
				save_mgo.Save("zktest_fieldscore_data", dict)
			}
		}
		tmp = make(map[string]interface{})
	}

	log.Debug("is over ", total)
	log.Debug("is site ", len(siteMap))
}

//记录字段-来源
func dealWithFieldSourceData() {
	dict1 := make(map[string]interface{}, 0)
	dict2 := make(map[string]interface{}, 0)
	sess := save_mgo.GetMgoConn()
	defer save_mgo.DestoryMongoConn(sess)
	q, total := map[string]interface{}{}, 0
	it := sess.DB(save_mgo.DbName).C("zk_field_score_data").Find(&q).Iter()
	for tmp := make(map[string]interface{}); it.Next(&tmp); total++ {
		source := *qu.ObjToMap(tmp["field_source"])
		for _, v := range source {
			if v == nil {
				continue
			}
			source_data := *qu.ObjToMap(v)
			ext_type := qu.ObjToString(source_data["ext_type"])
			ext_from := qu.ObjToString(source_data["ext_from"])

			if dict1[ext_type] == nil {
				dict1[ext_type] = 1
			}

			if dict2[ext_from] == nil {
				dict2[ext_from] = 1
			}
		}
		tmp = make(map[string]interface{})
	}
	log.Debug("结束：", total, dict1, dict2)

}
func repairDataBWA1019() {
	sess := save_mgo.GetMgoConn()
	defer save_mgo.DestoryMongoConn(sess)
	q, total := map[string]interface{}{}, 0
	it := sess.DB(save_mgo.DbName).C("zktest_extract_bwa_data").Find(&q).Iter()
	for tmp := make(map[string]interface{}); it.Next(&tmp); total++ {
		if total%1000 == 0 {
			log.Debug("current index", total)
		}
		buyer := qu.ObjToString(tmp["buyer"])
		agency := qu.ObjToString(tmp["agency"])
		winner := qu.ObjToString(tmp["winner"])
		s_winner := qu.ObjToString(tmp["s_winner"])
		dict := map[string]interface{}{
			"buyer":    buyer,
			"agency":   agency,
			"winner":   winner,
			"s_winner": s_winner,
		}
		tmpid := BsonTOStringId(tmp["_id"])
		save_mgo.UpdateById("result_20210108", tmpid, map[string]interface{}{
			"$set": dict,
		})
		tmp = make(map[string]interface{})
	}
	log.Debug("结束：", total)
}

//导出sh_shsggzyjyzx_zfcg 相关异常数据-准备修复
func dealWithSpiderDataBWA() {
	//任意俩字段一致的数据-重新抽取
	log.Debug("导出sh_shsggzyjyzx_zfcg下，异常数据")
	sess := save_mgo.GetMgoConn()
	defer save_mgo.DestoryMongoConn(sess)
	q, total, isok := map[string]interface{}{}, 0, 0
	it := sess.DB(save_mgo.DbName).C("zktest_spider_data").Find(&q).Iter()
	for tmp := make(map[string]interface{}); it.Next(&tmp); total++ {
		//模型：行政级别-项目名称-物品-数量-总金额
		if total%10000 == 0 {
			log.Debug("current index ", total, "~", isok)
		}
		tmpid := BsonTOStringId(tmp["_id"])
		data := save_mgo.FindById("bidding", tmpid)
		if data != nil && len(data) > 2 {
			isok++
			save_mgo.Save("zktest_extract_spider_data", data)
		}

		//save_mgo.Save("zktest_spider_data", map[string]interface{}{
		//	"_id":tmp["_id"],
		//})
		//buyer:=qu.ObjToString(tmp["buyer"])
		//agency:=qu.ObjToString(tmp["agency"])
		//winner:=qu.ObjToString(tmp["winner"])
		//
		//if buyer!=""&&agency!=""&&(strings.Contains(buyer,agency) || strings.Contains(agency,buyer)){
		//	isok++
		//	tmp = make(map[string]interface{})
		//	continue
		//}
		//
		//if buyer!=""&&winner!=""&&(strings.Contains(buyer,winner) || strings.Contains(winner,buyer)){
		//	isok++
		//	tmp = make(map[string]interface{})
		//	continue
		//}
		//
		//if winner!=""&&agency!=""&&(strings.Contains(winner,agency) || strings.Contains(agency,winner)){
		//	isok++
		//	tmp = make(map[string]interface{})
		//	continue
		//}

		tmp = make(map[string]interface{})
	}
	log.Debug("is over ", " 总计：", total, isok)
}

//导出训练模型-分数，数据
func exportModelScoreData() {
	sess := save_mgo.GetMgoConn()
	defer save_mgo.DestoryMongoConn(sess)
	q, total, isok := map[string]interface{}{}, 0, 0

	it := sess.DB(save_mgo.DbName).C("zktest_model_data").Find(&q).Iter()
	for tmp := make(map[string]interface{}); it.Next(&tmp); total++ {
		//模型：行政级别-项目名称-物品-数量-总金额
		if total%22 == 0 {
			if purchasinglist, ok := tmp["purchasinglist"].(primitive.A); ok {
				if len(purchasinglist) > 0 { //验证标的物
					items, numbers, moneys, istrue := "", int64(0), int64(0), true
					lists := qu.ObjArrToMapArr(purchasinglist)
					for k, v := range lists {
						item := qu.ObjToString(v["itemname"])
						number := qu.Int64All(v["number"])
						money := qu.Int64All(v["totalprice"])
						if item == "" || number == 0 {
							istrue = false
							break
						}
						if k == 0 {
							items = item
							numbers = number
							moneys = money
						} else {
							items = items + " " + item
							numbers = numbers + number
							moneys = moneys + money
						}
					}
					if istrue {
						if qu.Int64All(tmp["bidamount"]) != 0 {
							moneys = qu.Int64All(tmp["bidamount"])
						}

						if moneys > 0 {
							isok++
							save_mgo.Save("zk_zk_zk_model", map[string]interface{}{
								"buyer":   tmp["buyer"],
								"name":    tmp["projectname"],
								"items":   items,
								"numbers": numbers,
								"money":   moneys,
								"href":    tmp["href"],
								"_id":     tmp["_id"],
							})
						}
					}
				} else {

					if qu.Int64All(tmp["bidamount"]) != 0 {
						isok++
						save_mgo.Save("zk_zk_zk_model", map[string]interface{}{
							"buyer":   tmp["buyer"],
							"name":    tmp["projectname"],
							"items":   "",
							"numbers": 1,
							"money":   qu.Int64All(tmp["bidamount"]),
							"href":    tmp["href"],
							"_id":     tmp["_id"],
						})
					}
				}
			}
		}
		tmp = make(map[string]interface{})
	}
	log.Debug("is over ", " 总计：", total, isok)
}

//刷站点类型数据
func updateSiteTypeData() {
	sess := save_mgo.GetMgoConn()
	defer save_mgo.DestoryMongoConn(sess)
	q, total := map[string]interface{}{}, 0
	isok := 0
	it := sess.DB(save_mgo.DbName).C("zktest_score_data").Find(&q).Iter()
	for tmp := make(map[string]interface{}); it.Next(&tmp); total++ {
		if total%1000 == 0 {
			log.Debug("current index ", total)
		}
		data := save_mgo.FindOne("spider_site", map[string]interface{}{
			"site": qu.ObjToString(tmp["site"]),
		})
		if data != nil {
			isok++
			save_mgo.UpdateById("zktest_score_data", BsonTOStringId(tmp["_id"]), map[string]interface{}{
				"$set": map[string]interface{}{
					"site_type": qu.ObjToString(data["site_type"]),
				},
			})
		}

		tmp = make(map[string]interface{})
	}
	log.Debug("is over ", " 总计：", total, isok)
}

//分析打分
func analysisScoreData() {
	sess := save_mgo.GetMgoConn()
	defer save_mgo.DestoryMongoConn(sess)
	total, iserr, isok := 0, 0, 0
	err_data := map[string]int{
		"ck_buyer":       0,
		"ck_s_winner":    0,
		"ck_budget":      0,
		"ck_bidamount":   0,
		"ck_projectcode": 0,
	}
	q := map[string]interface{}{
		"core_score": map[string]interface{}{
			"$gte": 60,
		},
		"error_score": map[string]interface{}{
			"$lte": 0,
		},
		"abnormal_score": map[string]interface{}{
			"$lte": 0,
		},
	}
	ck_arr := []string{"ck_buyer", "ck_s_winner", "ck_budget", "ck_bidamount", "ck_projectcode"}
	site_type_arr := []string{
		"公共资源",
		"其他",
		"政府采购",
		"社会采购类",
		"企业门户/平台",
		"银行",
		"代理机构",
		"政府门户",
		"",
		"军队",
		"学校",
		"人民政府网",
		"医疗机构",
		"工程建设类",
		"证券",
		"保险",
	}
	isType := true
	if isType {
		for _, site_type := range site_type_arr {
			q["site_type"] = site_type
			total, iserr = 0, 0
			it := sess.DB(save_mgo.DbName).C("zktest_score_data").Find(&q).Iter()
			for tmp := make(map[string]interface{}); it.Next(&tmp); total++ {
				tmpid := BsonTOStringId(tmp["_id"])
				isck := false
				data := save_mgo.FindOne("zktest_markwork_data", map[string]interface{}{
					"id": tmpid,
				})
				if data != nil && len(data) > 2 {
					for _, v := range ck_arr {
						ck := qu.Int64All(data[v])
						if ck > 1 && v != "ck_budget" {
							isck = true
						}
					}
				}
				if isck {
					iserr++
				}
				tmp = make(map[string]interface{})
			}
			if total > 0 {
				fmt.Println("is over ", site_type, " 总计：", total, iserr)
			}
		}
	} else {
		it := sess.DB(save_mgo.DbName).C("zktest_score_data").Find(&q).Iter()
		for tmp := make(map[string]interface{}); it.Next(&tmp); total++ {
			tmpid := BsonTOStringId(tmp["_id"])
			isck := false
			data := save_mgo.FindOne("zktest_markwork_data", map[string]interface{}{
				"id": tmpid,
			})
			if data != nil && len(data) > 2 {
				for _, v := range ck_arr {
					ck := qu.Int64All(data[v])
					if ck > 1 {
						isck = true
						err_data[v] = err_data[v] + int(1)
					}
				}
			}
			if isck {
				iserr++
			} else {
				isok++
			}
			tmp = make(map[string]interface{})
		}
		log.Debug("is over ", " 总计：", total, isok, iserr, err_data)
	}

}

//导出人工标注原始抽取数据
func exportMarkWorkData() {
	sess := save_mgo.GetMgoConn()
	defer save_mgo.DestoryMongoConn(sess)
	q, total := map[string]interface{}{}, 0
	it := sess.DB(save_mgo.DbName).C("zktest_markwork_id").Find(&q).Iter()
	for tmp := make(map[string]interface{}); it.Next(&tmp); total++ {
		tmpid := qu.ObjToString(tmp["id"])
		data := save_mgo.FindById("result_20210108", tmpid)
		if data != nil && len(data) > 2 {
			save_mgo.Save("zktest_markwork_data", data)
		}
		tmp = make(map[string]interface{})
	}
	log.Debug("is over ", " 总计：", total)
}

//合并人工标注数据
func mergeMarkWorkData() {
	sess := save_mgo.GetMgoConn()
	defer save_mgo.DestoryMongoConn(sess)
	var Url = "https://www.jianyu360.com/article/content/%s.html"

	arr := []string{
		"20210924Shdx_mf",
		"markwork_wb",
		"markwork_wb_2_shdx",
		"20210924Shdx_nb",
		"20210928Shdx_nb_1",
		"markwork_wb_mf",
		"markwork_jy_lx",
		"markwork_wb_mf_bz",
	}
	for _, coll := range arr {
		q, total := map[string]interface{}{}, 0
		it := sess.DB(save_mgo.DbName).C(coll).Find(&q).Iter()
		for tmp := make(map[string]interface{}); it.Next(&tmp); total++ {
			tmpid := BsonTOStringId(tmp["_id"])
			jyhref := fmt.Sprintf(Url, qu.CommonEncodeArticle("content", tmpid))
			dict := tmp
			delete(dict, "_id")
			dict["jyhref"] = jyhref
			save_mgo.Save("zktest_mark_data", dict)
			tmp = make(map[string]interface{})
		}
		log.Debug("is over ", coll, " 总计：", total)
	}
}

//导出九江银行数据
func exportJJYHwinerdata() {
	sess := save_mgo.GetMgoConn()
	defer save_mgo.DestoryMongoConn(sess)
	q, total, isok := map[string]interface{}{}, 0, 0
	it := sess.DB(save_mgo.DbName).C("zktest_jjyhwinner_data").Find(&q).Iter()
	var Url = "https://www.jianyu360.com/article/content/%s.html"
	for tmp := make(map[string]interface{}); it.Next(&tmp); total++ {
		tmpid := BsonTOStringId(tmp["_id"])
		jyhref := fmt.Sprintf(Url, qu.CommonEncodeArticle("content", tmpid))
		save_mgo.UpdateById("zktest_jjyhwinner_data", tmpid, map[string]interface{}{
			"$set": map[string]interface{}{
				"jyhref": jyhref,
			},
		})
		tmp = make(map[string]interface{})
	}
	log.Debug("is over ", total, isok)
}

//整合buyer敏感词库
func finishingEnableBuyerData() {
	sess := save_mgo.GetMgoConn()
	defer save_mgo.DestoryMongoConn(sess)
	q, total := map[string]interface{}{
		"enabled": 1,
	}, 0
	it := sess.DB(save_mgo.DbName).C("zk_sensitive_buyer_new_err").Find(&q).Iter()
	for tmp := make(map[string]interface{}); it.Next(&tmp); total++ {
		if total%10000 == 0 {
			log.Debug("current index ", total)
		}
		name := qu.ObjToString(tmp["name"])
		save_mgo.Save("zk_sensitive_buyer", map[string]interface{}{
			"name":    name,
			"enabled": 1,
		})
		tmp = make(map[string]interface{})
	}
	log.Debug("zk_sensitive_buyer is over ", total)
}

//规则筛选出，异常单位
func isHan(s string) bool {
	for _, c := range s {
		if unicode.Is(unicode.Han, c) || unicode.IsNumber(c) || unicode.IsLetter(c) || c == '(' || c == ')' || c == '（' || c == '）' || c == '《' || c == '》' || c == '·' || c == '“' || c == '”' {
			continue
		} else {
			return false
		}
	}
	return true
}
func chooseUnEnableData() {
	var unstart *regexp.Regexp = regexp.MustCompile("^([\u4e00-\u9fa5])")
	var uncon *regexp.Regexp = regexp.MustCompile("(园|政府|集团|公司|有限|合伙|企|院|学|局|处)")
	var unlen *regexp.Regexp = regexp.MustCompile("^(.{4,})$")
	var unReg *regexp.Regexp = regexp.MustCompile("^.*(公司|学(校)?|博物馆|联合社|合作社|监狱|办公厅|电视台|集团|机构|企业|办公室|委员会|联社|厂|场|院|所|店|中心|局|站|城|处|行|科|部|队|联合(会|体)|工作室)$")
	var unhead *regexp.Regexp = regexp.MustCompile("^(某部|省|市|区|县|州|自治区|自治州|街道|名称)")

	var unenableReg1 *regexp.Regexp = regexp.MustCompile("^([\u4e00-\u9fa5]{1,2}(责任|有限|有限股份|有限责任|实业)公司|.*(某部|先生|女士|小姐)|工程技术处)$")
	var unenableReg2 *regexp.Regexp = regexp.MustCompile("(\\?|？|单位|#|xxxx|\\*\\*|%|万元|设计企业|免费|代表|代码标识|盖电子|测试测试|删除|错误|吊销|注销|发起人|待清理|&#|护照号|身份证号|\" +\n\t\"法人|&nbsp|国家拨入|借款|积累资金|认股人|--|、|&|`|美元)")
	sess := save_mgo.GetMgoConn()
	defer save_mgo.DestoryMongoConn(sess)
	q, total, isok := map[string]interface{}{}, 0, 0
	pool := make(chan bool, 1)
	wg := &sync.WaitGroup{}
	collection := "zk_sensitive_buyer_new_err"
	it := sess.DB(save_mgo.DbName).C(collection).Find(&q).Iter()
	for tmp := make(map[string]interface{}); it.Next(&tmp); total++ {
		if total%10000 == 0 {
			log.Debug("current index ", total, isok)
		}
		name := qu.ObjToString(tmp["name"])
		tmpid := BsonTOStringId(tmp["_id"])
		pool <- true //开线程
		wg.Add(1)
		go func(name string, tmpid string) {
			defer func() {
				<-pool
				wg.Done()
			}()
			//if isHan(name) {
			//	if unenableReg1.MatchString(name)||unhead.MatchString(name) {
			//		save_mgo.UpdateById(collection,tmpid, map[string]interface{}{
			//			"$set": map[string]interface{}{
			//				"enabled":0,
			//			},
			//		})
			//	}else {
			//		isok++
			//	}
			//}else {
			//	save_mgo.UpdateById(collection,tmpid, map[string]interface{}{
			//		"$set": map[string]interface{}{
			//			"enabled":0,
			//		},
			//	})
			//}
			//return
			//打印不全为中卫的name
			if isHan(name) {
				if unstart.MatchString(name) && unlen.MatchString(name) &&
					(uncon.MatchString(name) || unReg.MatchString(name)) &&
					!unhead.MatchString(name) {
					if unenableReg1.MatchString(name) || unenableReg2.MatchString(name) {
						save_mgo.UpdateById(collection, tmpid, map[string]interface{}{
							"$set": map[string]interface{}{
								"enabled": 0,
							},
						})
					} else {
						isok++
					}
				} else {
					save_mgo.UpdateById(collection, tmpid, map[string]interface{}{
						"$set": map[string]interface{}{
							"enabled": 0,
						},
					})
				}
			} else {
				save_mgo.UpdateById(collection, tmpid, map[string]interface{}{
					"$set": map[string]interface{}{
						"enabled": 0,
					},
				})
			}
		}(name, tmpid)
		tmp = make(map[string]interface{})
	}

	wg.Wait()
	log.Debug(collection, " is over ", total, isok)
}

//处理修复金额相关数据
func modifyTheBidamountData() {
	sess := save_mgo.GetMgoConn()
	defer save_mgo.DestoryMongoConn(sess)
	q, total, isok := map[string]interface{}{}, 0, 0
	it := sess.DB(save_mgo.DbName).C("1111").Find(&q).Iter()

	for tmp := make(map[string]interface{}); it.Next(&tmp); total++ {
		if total%1000 == 0 {
			log.Debug("current index ", total, isok)
		}
		jyhref := qu.ObjToString(tmp["jybxhref"])
		new_url := strings.ReplaceAll(jyhref, "https://www.jianyu360.cn/article/content/", "")
		new_url = strings.ReplaceAll(new_url, ".html", "")
		var Decode = qu.CommonDecodeArticle("content", new_url)
		tmpid := Decode[0]
		if tmpid != "" {
			save_mgo.FindById("zk_0926_bidamount_data_new", tmpid)
		}
		tmp = make(map[string]interface{})
	}
	log.Debug("is over ", total, isok)
}

//导出敏感词库-验证数据
func exportSensitiveTestData() {
	sess := save_mgo.GetMgoConn()
	defer save_mgo.DestoryMongoConn(sess)
	q, total, isok := map[string]interface{}{}, 0, 0
	var Url = "https://www.jianyu360.com/article/content/%s.html"
	it := sess.DB(save_mgo.DbName).C("data_tongji_20210916_bidding_new").Find(&q).Iter()
	for tmp := make(map[string]interface{}); it.Next(&tmp); total++ {
		if total%1000 == 0 {
			log.Debug("current index ", total, isok)
		}
		tmpid := BsonTOStringId(tmp["_id"])
		buyer := qu.ObjToString(tmp["buyer"])
		jyhref := fmt.Sprintf(Url, qu.CommonEncodeArticle("content", BsonTOStringId(tmp["_id"])))

		if buyer == "" {
			data := save_mgo.FindById("data_tongji_20210916", tmpid)
			if data != nil && len(data) > 2 {
				isok++
				save_mgo.Save("zk_sensitive_test_data", map[string]interface{}{
					"_id":          tmp["_id"],
					"detail":       data["detail"],
					"title":        data["title"],
					"href":         tmp["href"],
					"jyhref":       jyhref,
					"source_buyer": data["buyer"],
				})
			}
		}

		tmp = make(map[string]interface{})
	}
	log.Debug("is over ", total, isok)
}

//导出-用于敏感词库识别的采购表
func exportSensitiveBuyerData() {
	sess := save_mgo.GetMgoConn()
	defer save_mgo.DestoryMongoConn(sess)
	q, total := map[string]interface{}{}, 0
	it := sess.DB(save_mgo.DbName).C("buyer_err").Find(&q).Select(map[string]interface{}{
		"name": 1,
	}).Iter()
	for tmp := make(map[string]interface{}); it.Next(&tmp); total++ {
		if total%10000 == 0 {
			log.Debug("current index ", total)
		}
		name := qu.ObjToString(tmp["name"])
		save_mgo.Save("zk_sensitive_buyer_new_err", map[string]interface{}{
			"name":    name,
			"enabled": 0,
		})
		tmp = make(map[string]interface{})
	}
	log.Debug("buyer_err is over ", total)
}

//筛选历史名字
func chooseEnableHistoryData() {
	tmp_mgo := &MongodbSim{
		MongodbAddr: "172.17.4.181:27001",
		DbName:      "mixdata",
		Size:        10,
		UserName:    "",
		Password:    "",
	}
	tmp_mgo.InitPool()

	sess := save_mgo.GetMgoConn()
	defer save_mgo.DestoryMongoConn(sess)
	q, total, isok := map[string]interface{}{
		"enabled": 0,
	}, 0, 0
	pool := make(chan bool, 8)
	wg := &sync.WaitGroup{}
	it := sess.DB(save_mgo.DbName).C("zk_sensitive_buyer").Find(&q).Iter()
	for tmp := make(map[string]interface{}); it.Next(&tmp); total++ {
		if total%10000 == 0 {
			log.Debug("current index ", total, isok)
		}
		name := qu.ObjToString(tmp["name"])
		tmpid := BsonTOStringId(tmp["_id"])
		pool <- true //开线程
		wg.Add(1)
		go func(name string, tmpid string) {
			defer func() {
				<-pool
				wg.Done()
			}()
			data := tmp_mgo.FindOne("company_history_name", map[string]interface{}{
				"history_name": name,
			})
			if data != nil && len(data) > 2 {
				isok++
				save_mgo.UpdateById("zk_sensitive_buyer", tmpid, map[string]interface{}{
					"$set": map[string]interface{}{
						"enabled": 1,
					},
				})
			}
		}(name, tmpid)
		tmp = make(map[string]interface{})
	}

	wg.Wait()
	log.Debug("is over ", total, "-", isok)

}

//筛选异常buyer数据
func chooseEnableBuyerData() {
	//去除 zk_sensitive_buyer 空格
	sess := save_mgo.GetMgoConn()
	defer save_mgo.DestoryMongoConn(sess)
	q, total, isok := map[string]interface{}{}, 0, 0
	pool := make(chan bool, 15)
	wg := &sync.WaitGroup{}
	it := sess.DB(save_mgo.DbName).C("zk_sensitive_buyer").Find(&q).Iter()
	for tmp := make(map[string]interface{}); it.Next(&tmp); total++ {
		if total%10000 == 0 {
			log.Debug("current index ", total, isok)
		}
		name := qu.ObjToString(tmp["name"])
		enabled := qu.Int64All(tmp["enabled"])
		tmpid := BsonTOStringId(tmp["_id"])
		if enabled == 1 {
			//开线程
			pool <- true
			wg.Add(1)
			go func(name string, tmpid string) {
				defer func() {
					<-pool
					wg.Done()
				}()
				data := save_mgo.FindOne("qyxy_std", map[string]interface{}{
					"company_name": name,
				})
				if data == nil || len(data) <= 0 {
					isok++
					save_mgo.UpdateById("zk_sensitive_buyer", tmpid, map[string]interface{}{
						"$set": map[string]interface{}{
							"enabled": 0,
						},
					})
				}
			}(name, tmpid)
		} else {
			isok++
		}
		tmp = make(map[string]interface{})
	}

	wg.Wait()
	log.Debug("is over ", total, "-", isok)
}

//导出特殊日期-数据
func exportSpecifiedTimeData() {

	sess := save_mgo.GetMgoConn()
	defer save_mgo.DestoryMongoConn(sess)
	q, total := map[string]interface{}{}, 0
	var Url = "https://www.jianyu360.com/article/content/%s.html"
	//jyhref:= fmt.Sprintf(Url, qu.CommonEncodeArticle("content", BsonTOStringId(tmp["_id"])))

	it := sess.DB(save_mgo.DbName).C("zktest_bidtime_data").Find(&q).Sort("_id").Iter()
	for tmp := make(map[string]interface{}); it.Next(&tmp); total++ {
		if total%1000 == 0 {
			log.Debug("current index", total)
		}
		dict := make(map[string]interface{}, 0)
		dict["_id"] = tmp["_id"]
		dict["href"] = qu.ObjToString(tmp["href"])
		jyhref := fmt.Sprintf(Url, qu.CommonEncodeArticle("content", BsonTOStringId(tmp["_id"])))
		dict["jyhref"] = jyhref
		bidopentime := qu.Int64All(tmp["bidopentime"])
		bidendtime := qu.Int64All(tmp["bidendtime"])
		timeLayout := "2006-01-02 15:04:05"
		if bidopentime > 0 {
			bidopentime_str := time.Unix(bidopentime, 0).Format(timeLayout) //设置时间戳 使用模板格式化为日期字符串
			dict["bidopentime"] = bidopentime_str
		}
		if bidendtime > 0 {
			bidendtime_str := time.Unix(bidendtime, 0).Format(timeLayout) //设置时间戳 使用模板格式化为日期字符串
			dict["bidendtime"] = bidendtime_str
		}

		save_mgo.Save("zktest_bidtime_errdata", dict)

		tmp = make(map[string]interface{})
	}

	log.Debug("is over ", total)
}

//导出-错误数据
func exportErrBidtimeData() {
	sess := save_mgo.GetMgoConn()
	defer save_mgo.DestoryMongoConn(sess)
	q, total, isopen, isend := map[string]interface{}{}, 0, 0, 0
	it := sess.DB(save_mgo.DbName).C("data_tongji_20210916_bidding_new").Find(&q).Sort("_id").Iter()
	siteMap := make(map[string]int, 0)
	for tmp := make(map[string]interface{}); it.Next(&tmp); total++ {
		if total%1000 == 0 {
			log.Debug("current index", total, isopen, isend)
		}
		isSave := false
		site := qu.ObjToString(tmp["site"])
		tmpid := BsonTOStringId(tmp["_id"])
		if wrong_key_item, ok := tmp["wrong_key_item"].(primitive.A); ok {
			if len(wrong_key_item) > 0 {
				for _, v := range wrong_key_item {
					if v == "bidopentime" {
						num_site := qu.IntAll(siteMap[site])
						if num_site < 3 {
							isSave = true
							siteMap[site] = num_site + 1
							isopen++
							//保存
							data := save_mgo.FindById("data_tongji_20210916", tmpid)
							if data != nil && len(data) > 2 {
								save_mgo.Save("zktest_bidtime_data", data)
							}
						}
						break
					}
				}

				if !isSave {
					for _, v := range wrong_key_item {
						if v == "bidendtime" {
							num_site := qu.IntAll(siteMap[site])
							if num_site < 3 {
								siteMap[site] = num_site + 1
								isend++
								data := save_mgo.FindById("data_tongji_20210916", tmpid)
								if data != nil && len(data) > 2 {
									save_mgo.Save("zktest_bidtime_data", data)
								}
							}
							break
						}
					}
				}
			}
		}
		tmp = make(map[string]interface{})
	}

	log.Debug("is over ", total, "~opentime:", isopen, "~endtime", isend)
	log.Debug("is site ", len(siteMap))
}

//修复bidding + 抽取表信息-城市相关
func repairExtractBiddingData() {
	sess := save_mgo.GetMgoConn()
	defer save_mgo.DestoryMongoConn(sess)
	q, total, isok := map[string]interface{}{}, 0, 0
	it := sess.DB(save_mgo.DbName).C("zkrepair_city_data").Find(&q).Sort("_id").Iter()
	for tmp := make(map[string]interface{}); it.Next(&tmp); total++ {
		if total%1000 == 0 {
			log.Debug("current index", total, isok)
		}
		area := qu.ObjToString(tmp["area"])
		city := qu.ObjToString(tmp["city"])
		district := qu.ObjToString(tmp["district"])
		dict := map[string]interface{}{
			"area":     area,
			"city":     city,
			"district": district,
		}
		tmpid := BsonTOStringId(tmp["_id"])
		if area != "浙江" && area != "全国" {
			isok++
			mgo_data := save_mgo.FindById("result_20210108", tmpid)
			if mgo_data != nil && len(mgo_data) > 2 {
				save_mgo.UpdateById("result_20210108", tmpid, map[string]interface{}{
					"$set": dict,
				})
			}
		}
		tmp = make(map[string]interface{})
	}
	log.Debug("结束：", total, isok)
}

//修复索引信息-城市相关
func repairEsCityData() {
	elastic.InitElasticSize("http://127.0.0.1:12003", 10)
	//测试
	//area:="云南"
	//city := ""
	//district:=""
	//updateStr := `ctx._source.area=`+ `"`+area+`"`+`;`+`ctx._source.city=`+ `"`+city+`"`+`;`+`ctx._source.district=`+ `"`+district+`"`+`;`
	//elastic.Update("bidding","bidding","5d8978a9a5cb26b9b795bdf7", updateStr)
	//return
	sess := save_mgo.GetMgoConn()
	defer save_mgo.DestoryMongoConn(sess)
	q, total, isok := map[string]interface{}{}, 0, 0
	it := sess.DB(save_mgo.DbName).C("zk_repair_city_data_0917").Find(&q).Sort("_id").Iter()
	for tmp := make(map[string]interface{}); it.Next(&tmp); total++ {
		if total%1000 == 0 {
			log.Debug("current index", total, isok)
		}
		area := qu.ObjToString(tmp["area"])
		city := qu.ObjToString(tmp["city"])
		district := qu.ObjToString(tmp["district"])
		tmpid := BsonTOStringId(tmp["_id"])
		if area != "浙江" && area != "全国" {
			dataArr := *elastic.GetById("bidding", "bidding", tmpid)
			if len(dataArr) > 0 {
				isok++
				updateStr := `ctx._source.area=` + `"` + area + `"` + `;` + `ctx._source.city=` + `"` + city + `"` + `;` + `ctx._source.district=` + `"` + district + `"` + `;`
				elastic.Update("bidding", "bidding", tmpid, updateStr)
			}
		}
		tmp = make(map[string]interface{})
	}

	log.Debug("结束：", total, isok)
}

//导出日期相关数据
func exportBidOpenEndtimeData() {
	sess := save_mgo.GetMgoConn()
	defer save_mgo.DestoryMongoConn(sess)
	q, total, isok := map[string]interface{}{
		"comeintime": map[string]interface{}{
			"$gt":  1630425600,
			"$lte": 1631635200,
		},
	}, 0, 0
	isSave := false
	var Url = "https://www.jianyu360.com/article/content/%s.html"
	it := sess.DB(save_mgo.DbName).C("bidding").Find(&q).Iter()
	for tmp := make(map[string]interface{}); it.Next(&tmp); total++ {
		if isok >= 400 {
			break
		}
		if total%2000 == 0 {
			isSave = false
			log.Debug("current index", total, isok)
		} else {
			if isSave {
				tmp = make(map[string]interface{})
				continue
			}
		}
		jyhref := fmt.Sprintf(Url, qu.CommonEncodeArticle("content", BsonTOStringId(tmp["_id"])))
		tmp["jyhref"] = jyhref
		subtype := qu.ObjToString(tmp["subtype"])
		bidopentime := qu.Int64All(tmp["bidopentime"])
		bidendtime := qu.Int64All(tmp["bidendtime"])
		if isok < 400 && !strings.Contains(qu.ObjToString(tmp["href"]), "www.gdydb2b.com") && bidopentime == 0 && bidendtime == 0 &&
			(subtype == "招标" || subtype == "邀标" || subtype == "询价" || subtype == "竞谈" || subtype == "单一" || subtype == "竞价" || subtype == "变更") {
			isok++
			isSave = true
			save_mgo.Save("zktest_bidtime_data", tmp)
		}
		tmp = make(map[string]interface{})
	}
	log.Debug("export date is over", total, isok)
}

//根据-表-导出相关抽取数据
func exportRepairCityData0917() {
	log.Debug("导出相关城市-获取数据")
	sess := save_mgo.GetMgoConn()
	defer save_mgo.DestoryMongoConn(sess)
	q, total, isok := map[string]interface{}{}, 0, 0
	it := sess.DB(save_mgo.DbName).C("zk_repair_city_id_0917").Find(&q).Iter()
	for tmp := make(map[string]interface{}); it.Next(&tmp); total++ {
		if total%10000 == 0 {
			log.Debug("current index", total, isok)
		}
		tmpid := BsonTOStringId(tmp["_id"])
		dict := save_mgo.FindById("bidding", tmpid)
		if dict != nil && len(dict) > 2 {
			save_mgo.Save("zk_repair_city_data_0917", dict)
			isok++
		}
		tmp = make(map[string]interface{})
	}
	log.Debug("export unit is over", total, isok)
}

//导出-单位相关数据-间隔
func exportUnitBuyerWinnerData() {
	sess := save_mgo.GetMgoConn()
	defer save_mgo.DestoryMongoConn(sess)
	q, total := map[string]interface{}{
		"_id": map[string]interface{}{
			"$gt":  StringTOBsonId("6117e8800000000000000000"),
			"$lte": StringTOBsonId("612baf000000000000000000"),
		},
	}, 0

	isWinner, isBuyer, isUnit := 0, 0, 0
	var Url = "https://www.jianyu360.com/article/content/%s.html"
	it := sess.DB(save_mgo.DbName).C("bidding").Find(&q).Iter()
	for tmp := make(map[string]interface{}); it.Next(&tmp); total++ {
		if total%200 == 0 {
			log.Debug("current index", total)
		} else {
			tmp = make(map[string]interface{})
			continue
		}

		subtype := qu.ObjToString(tmp["subtype"])
		winner := qu.ObjToString(tmp["winner"])
		buyer := qu.ObjToString(tmp["buyer"])

		jyhref := fmt.Sprintf(Url, qu.CommonEncodeArticle("content", BsonTOStringId(tmp["_id"])))
		tmp["jyhref"] = jyhref
		if isWinner >= 150 && isBuyer >= 150 && isUnit >= 200 {
			break
		}
		if isWinner < 150 && winner == "" && (subtype == "中标" || subtype == "成交" || subtype == "合同") {
			isWinner++
			save_mgo.Save("zktest_unit_data", tmp)
			tmp = make(map[string]interface{})
			continue
		}
		if isBuyer < 150 && buyer == "" && (subtype == "招标" || subtype == "邀标" || subtype == "询价" || subtype == "竞谈" || subtype == "单一" || subtype == "竞价" || subtype == "其他") {
			isBuyer++
			save_mgo.Save("zktest_unit_data", tmp)
			tmp = make(map[string]interface{})
			continue
		}

		if isUnit < 200 && buyer != "" && winner != "" {
			isUnit++
			save_mgo.Save("zktest_unit_data", tmp)
			tmp = make(map[string]interface{})
			continue
		}
		tmp = make(map[string]interface{})
	}
	log.Debug("export unit is over", total, isBuyer+isWinner+isUnit)
}

//导出异常采购单位 - 数据
func exportErrBuyerRepeatData() {
	sess := save_mgo.GetMgoConn()
	defer save_mgo.DestoryMongoConn(sess)
	q, total := map[string]interface{}{}, 0
	it := sess.DB(save_mgo.DbName).C("zk_repeat_errbuyer_data_0908").Find(&q).Iter()
	for tmp := make(map[string]interface{}); it.Next(&tmp); total++ {
		if total%1000 == 0 {
			log.Debug("current index", total)
		}
		repeat_id := qu.ObjToString(tmp["repeat_id"])
		data := save_mgo.FindById("result_20210108", repeat_id)
		if qu.ObjToString(data["buyer"]) != qu.ObjToString(tmp["buyer"]) {
			dict := map[string]interface{}{
				"buyer_1": qu.ObjToString(data["buyer"]),
				"href_1":  qu.ObjToString(data["href"]),
				"title_1": qu.ObjToString(data["title"]),
			}
			save_mgo.UpdateById("zk_repeat_errbuyer_data_0908", BsonTOStringId(tmp["_id"]), map[string]interface{}{
				"$set": dict,
			})
		}
		tmp = make(map[string]interface{})
	}
}

//修复城市数据
func repairExtractCityData() {
	sess := save_mgo.GetMgoConn()
	defer save_mgo.DestoryMongoConn(sess)
	q, total, ok_1, ok_2 := map[string]interface{}{}, 0, 0, 0
	it := sess.DB(save_mgo.DbName).C("zk_repair_city_data_0902_0907").Find(&q).Select(map[string]interface{}{
		"area":     1,
		"city":     1,
		"district": 1,
	}).Iter()
	for tmp := make(map[string]interface{}); it.Next(&tmp); total++ {
		if total%1000 == 0 {
			log.Debug("current index", total, ok_1, ok_2)
		}
		area := qu.ObjToString(tmp["area"])
		city := qu.ObjToString(tmp["city"])
		district := qu.ObjToString(tmp["district"])
		dict := map[string]interface{}{
			"area":     area,
			"city":     city,
			"district": district,
		}
		tmpid := BsonTOStringId(tmp["_id"])
		data_1 := save_mgo.FindById("result_20210108", tmpid)
		if data_1 != nil && len(data_1) > 0 {
			ok_1++
			save_mgo.UpdateById("result_20210108", tmpid, map[string]interface{}{
				"$set": dict,
			})
		} else {
			data_2 := save_mgo.FindById("result_20210109", tmpid)
			if data_2 != nil && len(data_2) > 0 {
				ok_2++
				save_mgo.UpdateById("result_20210109", tmpid, map[string]interface{}{
					"$set": dict,
				})
			}
		}
		tmp = make(map[string]interface{})
	}
	log.Debug("is over ", total, ok_1, ok_2)
}

//根据id 导出相关数据
func exportBiddingTestData() {
	log.Debug("导出相关-获取数据")
	arr := []string{}
	for _, tmpid := range arr {
		dict := save_mgo.FindById("bidding", tmpid)
		if dict != nil && len(dict) > 2 {
			save_mgo.Save("zktest_allext_data", dict)
		} else {
			dict_back := save_mgo.FindById("bidding_back", tmpid)
			if dict_back != nil && len(dict_back) > 2 {
				save_mgo.Save("zktest_allext_data", dict_back)
			}
		}
	}
	log.Debug("is over ", len(arr))
}

//分析 es ,标签包含
func analyTagData() {
	elastic.InitElasticSize("http://127.0.0.1:12003", 10)
	//elastic.InitElasticSize("http://172.17.145.170:9800", 10)
	//elastic.InitElasticSize("http://ela.spdata.jianyu360.com",10)
	//query:=`{"query":{"filtered":{"filter":{"bool":{"must":[{}]}},"query":{"bool":{"should":[{"multi_match":{"query":"牵头","type":"phrase","fields":["detail","filetext"]}}]}}}},"from":0,"size":1}`

	arr := []string{}
	for k, value := range arr {
		if k%10 == 0 {
			log.Debug("当前：", k)
		}
		query := `{"query":{"filtered":{"filter":{"bool":{"must":[{}]}},"query":{"bool":{"should":[{"multi_match":{"query":` + `"` + value + `"` + `,"type":"phrase","fields":["detail","filetext"]}}]}}}},"from":0,"size":10}`

		dataArr := *elastic.Get("bidding", "bidding", query)
		if len(dataArr) > 0 {
			//for _,data :=range dataArr {
			//	log.Debug("存在",data["_id"])
			//}
		} else {
			log.Debug("不存在:", value)
		}
	}
	log.Debug("结束")
}

//导出biding 相关数据
func exportProjectperiodData() {
	log.Debug("导出-系数数据")
	//elastic.InitElasticSize("http://127.0.0.1:12003",10)
	elastic.InitElasticSize("http://172.17.145.170:9800", 10)
	//不同年限数据
	timeArr := []string{
		`"from":"1483200000","to":"1514736000"`,
		`"from":"1514736000","to":"1546272000"`,
		`"from":"1546272000","to":"1577808000"`,
		`"from":"1577808000","to":"1609430400"`,
		`"from":"1609430400","to":"1640966400"`,
	}
	idArr := make([]string, 0)

	//无金额
	for _, v := range timeArr {
		query := `{"query":{"bool":{"must":[{"term":{"bidding.toptype":"结果"}},{"range":{"bidding.publishtime":{` + v + `}}},{"constant_score":{"filter":{"missing":{"field":"bidding.bidamount"}}}}],"must_not":[],"should":[]}},"from":0,"size":100,"_source":["_id"],"sort":[],"facets":{}}`
		dataArr := *elastic.Get("bidding", "bidding", query)
		for _, tmp := range dataArr {
			tmp_id := qu.ObjToString(tmp["_id"])
			idArr = append(idArr, tmp_id)
		}
	}
	log.Debug("无金额:", len(idArr))
	//1000以内
	for _, v := range timeArr {
		query := `{"query":{"bool":{"must":[{"term":{"bidding.toptype":"结果"}},{"range":{"bidding.publishtime":{` + v + `}}},{"range":{"bidding.bidamount":{"from":"0","to":"1000"}}}],"must_not":[],"should":[]}},"from":0,"size":100,"_source":["_id"],"sort":[],"facets":{}}`
		dataArr := *elastic.Get("bidding", "bidding", query)
		for _, tmp := range dataArr {
			tmp_id := qu.ObjToString(tmp["_id"])
			idArr = append(idArr, tmp_id)
		}
	}
	log.Debug("1000金额:", len(idArr))
	//100亿以上
	for _, v := range timeArr {
		query := `{"query":{"bool":{"must":[{"term":{"bidding.toptype":"结果"}},{"range":{"bidding.publishtime":{` + v + `}}},{"range":{"bidding.bidamount":{"from":"10000000000","to":"5000000000000"}}}],"must_not":[],"should":[]}},"from":0,"size":100,"_source":["_id"],"sort":[],"facets":{}}`
		dataArr := *elastic.Get("bidding", "bidding", query)
		for _, tmp := range dataArr {
			tmp_id := qu.ObjToString(tmp["_id"])
			idArr = append(idArr, tmp_id)
		}
	}
	log.Debug("100亿金额:", len(idArr))

	isOK := 0
	for _, tmpid := range idArr {
		dict := save_mgo.FindById("bidding", tmpid)
		if dict != nil && len(dict) > 2 {
			save_mgo.Save("zktest_bidamount", dict)
			isOK++
		} else {
			dict_back := save_mgo.FindById("bidding_back", tmpid)
			if dict_back != nil && len(dict_back) > 2 {
				save_mgo.Save("zktest_bidamount", dict_back)
				isOK++
			}
		}
	}
	log.Debug("is over ", len(idArr), isOK)
}

//修复城市
func repairCityData() {
	log.Debug("待修复-相关数据 172.17.4.85:27080")
	sess := save_mgo.GetMgoConn()
	defer save_mgo.DestoryMongoConn(sess)
	q, total, isOK := map[string]interface{}{}, 0, 0
	it := sess.DB(save_mgo.DbName).C("zk_repair_gatcity_0712").Find(&q).Select(map[string]interface{}{
		"area":     1,
		"city":     1,
		"district": 1,
	}).Iter()
	for tmp := make(map[string]interface{}); it.Next(&tmp); total++ {
		area := qu.ObjToString(tmp["area"])
		city := qu.ObjToString(tmp["city"])
		district := qu.ObjToString(tmp["district"])
		dict := map[string]interface{}{
			"area":     area,
			"city":     city,
			"district": district,
		}
		tmpid := BsonTOStringId(tmp["_id"])
		data_1 := save_mgo.FindById("result_20210108", tmpid)
		if data_1 != nil && len(data_1) > 0 {
			isOK++
			save_mgo.UpdateById("result_20210108", tmpid, map[string]interface{}{
				"$set": dict,
			})
		} else {
			data_2 := save_mgo.FindById("result_20210109", tmpid)
			if data_2 != nil && len(data_2) > 0 {
				isOK++
				save_mgo.UpdateById("result_20210109", tmpid, map[string]interface{}{
					"$set": dict,
				})
			}
		}
		tmp = make(map[string]interface{})
	}
	log.Debug("is over ", total, isOK)
}

//获取港澳台数据
func getGATCityData() {
	log.Debug("港澳台-获取数据")
	arr := []string{}
	for _, tmpid := range arr {
		dict := save_mgo.FindById("bidding", tmpid)
		if dict != nil && len(dict) > 2 {
			delete(dict, "area")
			delete(dict, "city")
			delete(dict, "district")
			save_mgo.Save("gat_bidding_data", dict)
		} else {
			dict_back := save_mgo.FindById("bidding_back", tmpid)
			if dict_back != nil && len(dict_back) > 2 {
				delete(dict_back, "area")
				delete(dict_back, "city")
				delete(dict_back, "district")
				save_mgo.Save("gat_bidding_data", dict_back)
			}
		}
	}
	log.Debug("is over ", len(arr))
}

//处理kvtext数据
func dealWithKVtextData() {
	sess := save_mgo.GetMgoConn()
	defer save_mgo.DestoryMongoConn(sess)
	q, total, isOK := map[string]interface{}{}, 0, 0
	it := sess.DB(save_mgo.DbName).C("kvtext_test").Find(&q).Select(map[string]interface{}{
		"kvtext": 1,
	}).Iter()
	data := make(map[string]interface{}, 0)
	for tmp := make(map[string]interface{}); it.Next(&tmp); total++ {
		if total%10000 == 0 {
			log.Debug("cur index ", total, isOK)
		}
		kvtext := qu.ObjToString(tmp["kvtext"])
		if kvtext != "" {
			arr := strings.Split(kvtext, "\n")
			for _, v := range arr {
				kvArr := strings.Split(v, ":")
				key := kvArr[0]
				value := ""
				if len(kvArr) > 1 {
					value = kvArr[1]
				} else {
					continue
				}
				if data[key] == nil && key != "" {
					isOK++
					data[key] = 1
					save_mgo.Save("kvtext_data", map[string]interface{}{
						"key":     key,
						"value":   value,
						"kv":      v,
						"info_id": BsonTOStringId(tmp["_id"]),
					})
				}
			}
		}
		tmp = make(map[string]interface{})
	}
	log.Debug("over ", total, len(data), isOK)
}

//处理重复...港澳台
func dealWithRepeatGATData() {
	log.Debug("处理重复...港澳台数据")
	sess := save_mgo.GetMgoConn()
	defer save_mgo.DestoryMongoConn(sess)
	q, total := map[string]interface{}{
		"province": "台湾",
	}, 0
	it := sess.DB(save_mgo.DbName).C("address_new_2020").Find(&q).Select(map[string]interface{}{
		"city":     1,
		"district": 1,
	}).Iter()

	infoCityArr := map[string]interface{}{}
	infoDistrictArr := map[string]interface{}{}
	for tmp := make(map[string]interface{}); it.Next(&tmp); total++ {
		if total%1000 == 0 {
			log.Debug("cur index ", total)
		}
		city := qu.ObjToString(tmp["city"])
		district := qu.ObjToString(tmp["district"])
		if city != "" && infoCityArr[city] == nil {
			infoCityArr[city] = 1
		}
		if district != "" && infoDistrictArr[district] == nil {
			infoDistrictArr[district] = 1
		}

		tmp = make(map[string]interface{})
	}

	log.Debug("over ", len(infoCityArr), len(infoDistrictArr))

	log.Debug("加载目标city数据")
	//加载所有数据
	for k, _ := range infoCityArr {
		data, err := save_mgo.Find("address_new_2020", map[string]interface{}{
			"$or": []map[string]interface{}{
				{
					"city": k,
				},
				{
					"district": k,
				},
			},
		}, nil, nil)
		if err == nil && len(data) > 0 {
			for _, value := range data {
				province := qu.ObjToString(value["province"])
				city := qu.ObjToString(value["city"])
				district := qu.ObjToString(value["district"])
				if province == "台湾" {
					continue
				}
				if city == k || district == k {
					log.Debug("有相关重复：", k, value["_id"])
					break
				}
			}
		}
	}
	log.Debug("加载目标district数据")
	for k, _ := range infoDistrictArr {
		data, err := save_mgo.Find("address_new_2020", map[string]interface{}{
			"$or": []map[string]interface{}{
				{
					"city": k,
				},
				{
					"district": k,
				},
			},
		}, nil, nil)
		if err == nil && len(data) > 0 {
			for _, value := range data {
				province := qu.ObjToString(value["province"])
				city := qu.ObjToString(value["city"])
				district := qu.ObjToString(value["district"])
				if province == "台湾" {
					continue
				}
				if city == k || district == k {
					log.Debug("有相关重复：", k, value["_id"])
					break
				}
			}
		}
	}

}

//导出...港澳台
func exportGATCityData() {
	log.Debug("导出...港澳台数据")
	//777989+421
	f, err := os.Open("gat.txt")
	if err != nil {

	}
	defer f.Close()
	rd := bufio.NewReader(f)
	total := 0
	for {
		total++
		line, err := rd.ReadString('\n') //以'\n'为结束符读入一行
		dict := dealWithGATLine(line)
		if len(dict) != 0 {
			save_mgo.Save("address_copy", dict)
		}
		if err != nil || io.EOF == err {
			break
		}
	}
	log.Debug("总计", total, "行")

}
func dealWithGATLine(line string) map[string]interface{} {
	/*
		710000, 台湾, 100000, 台湾, 1, , , 中国,台湾, 121.509, 25.0443, Taiwan
		710100, 台北市, 710000, 台北, 2, 02, 1, 中国,台湾,台北市, 121.565, 25.0378, Taipei
		710101, 松山区, 710100, 松山, 3, 02, 105, 中国,台湾,台北市,松山区, 121.577, 25.0497, Songshan
	*/
	arr := strings.Split(line, ",")
	//记录当前省份，城市
	dict := make(map[string]interface{}, 0)
	if arr[0][:2] == "71" {
		province = "台湾"
		all_province = "台湾省"
	} else if arr[0][:2] == "81" {
		province = "香港"
		all_province = "香港特别行政区"
	} else {
		province = "澳门"
		all_province = "澳门特别行政区"
	}

	if len(arr) == 12 { //省份

	} else if len(arr) == 13 { //市区 - 二级结构
		city = arr[1]
		brief_city = arr[3]
		dict = map[string]interface{}{
			"province":     province,
			"all_province": all_province,
			"brief_city":   brief_city,
			"city":         city,
			"pcode":        arr[0][:2],
			"code":         arr[0][:4],
		}

	} else if len(arr) == 14 { //县  三级结构
		dict = map[string]interface{}{
			"province":       province,
			"all_province":   all_province,
			"brief_city":     brief_city,
			"city":           city,
			"brief_district": arr[3],
			"district":       arr[1],
			"pcode":          arr[0][:4],
			"code":           arr[0][:6],
		}
	} else {
		log.Debug("异常")
	}
	return dict
}
func dealWithBaiduYunData() {
	sess := save_mgo.GetMgoConn()
	defer save_mgo.DestoryMongoConn(sess)
	q, total, isOK, exist, un_exist := map[string]interface{}{}, 0, 0, 0, 0
	arr := make([]map[string]string, 0)
	it := sess.DB(save_mgo.DbName).C("bidding_test").Find(&q).Select(map[string]interface{}{
		"detail": 1,
		"buyer":  1,
	}).Iter()
	for tmp := make(map[string]interface{}); it.Next(&tmp); total++ {
		if total%1000 == 0 {
			log.Debug("cur index ", total, isOK, exist, un_exist, tmp["_id"])
		}
		detail := trimHtml(qu.ObjToString(tmp["detail"]))
		buyer := qu.ObjToString(tmp["buyer"])
		length := utf8.RuneCountInString(detail)
		if length > 50 && buyer != "" {
			isOK++
			new_buyer := getBaiduYunBuyer(detail)
			if new_buyer != "" {
				exist++
				//log.Debug("原值:",buyer,"  最终匹配：",new_buyer)
			} else {
				un_exist++
				//log.Debug("未匹配：",tmp["_id"])
			}
			arr = append(arr, map[string]string{
				"source": buyer,
				"buyer":  new_buyer,
			})
		}
		if total > 200 {
			break
		}
		tmp = make(map[string]interface{})
	}

	log.Debug("处理完毕over......", total, isOK, exist, un_exist)
	log.Debug("准备写入xlsx...", len(arr))
	os.Remove("百度云统计.xlsx")
	f := xlsx.NewFile()
	sheet, _ := f.AddSheet("训练")
	row := sheet.AddRow()
	row.AddCell().Value = "原采购"
	row.AddCell().Value = "结果"
	row.AddCell().Value = "新采购等"
	for _, v := range arr {
		row := sheet.AddRow()
		buyer := v["source"]
		new_buyer := v["buyer"]
		row.AddCell().SetString(buyer)
		buyerArr := strings.Split(new_buyer, "~")
		isTrue := false
		for _, name := range buyerArr {
			if name == buyer {
				isTrue = true
				break
			}
		}
		if isTrue {
			row.AddCell().Value = "正确"
		} else {
			if new_buyer != "" {
				row.AddCell().Value = "异常"
			} else {
				row.AddCell().Value = ""
			}
		}
		row.AddCell().SetString(new_buyer)
	}
	err := f.Save("百度云统计.xlsx")
	if err != nil {
		log.Debug("保存xlsx失败:", err)
	} else {
		log.Debug("保存xlsx成功:", err)
	}
}

//百度云相关
func getBaiduYunBuyer(detail string) string {
	//fmt.Println("runing...")
	buyer := ""
	body := map[string]interface{}{"text": detail}
	data := postBaiDuYun("https://aip.baidubce.com/rpc/2.0/ai_custom/v1/entity_xtr/allbuyer?access_token=24.595a79beb92df28ae44081d8c069e32c.2592000.1627033355.282335-24414386",
		body, "application/json")
	//fmt.Println("post...end")
	if results, ok := data["results"].([]interface{}); ok {
		for _, v := range results {
			tmp := *qu.ObjToMap(v)
			span := qu.ObjToString(tmp["span"])
			if span != "" {
				if buyer == "" {
					buyer = span
				} else {
					buyer = buyer + "~" + qu.ObjToString(tmp["span"])
				}
			}
		}
	} else {
		log.Debug("异常：", reflect.TypeOf(data["results"]), data["results"])
	}

	return buyer
}
func postBaiDuYun(url string, data interface{}, contentType string) map[string]interface{} {
	task <- struct{}{}
	defer func() {
		<-task
	}()
	client := &http.Client{Timeout: 15 * time.Second}
	jsonStr, _ := json.Marshal(data)
	resp, err := client.Post(url, contentType, bytes.NewBuffer(jsonStr))
	if err != nil {

	}
	defer resp.Body.Close()
	result, _ := ioutil.ReadAll(resp.Body)
	dict := make(map[string]interface{})
	json.Unmarshal(result, &dict)
	//fmt.Println("post...start")
	return dict
}

//修复全量-指定字段数据
func dealWithFullData() {
	log.Debug("......处理全量数据")

	sess := save_mgo.GetMgoConn()
	defer save_mgo.DestoryMongoConn(sess)
	q := map[string]interface{}{}
	total, isOK := 0, 0
	pool := make(chan bool, 10)
	wg := &sync.WaitGroup{}
	it := sess.DB(save_mgo.DbName).C("result_dis_0618").Find(&q).Select(map[string]interface{}{
		"bidmode":      1,
		"getdocmethod": 1,
		"agencyfee":    1,
		"agencyrate":   1,
		"docamount":    1,
	}).Iter()
	for tmp := make(map[string]interface{}); it.Next(&tmp); total++ {
		if total%100000 == 0 {
			log.Debug("cur index ", total, isOK, tmp["_id"])
		}
		b, dict := fieldValidValue(tmp)
		curID := BsonTOStringId(tmp["_id"])
		if b {
			source := save_mgo.FindById("result_20210108", curID)
			if source != nil && len(source) > 2 {
				isOK++ //符合条件-可以更新
				pool <- true
				wg.Add(1)
				go func(dict map[string]interface{}, curID string) {
					defer func() {
						<-pool
						wg.Done()
					}()
					//更新方法
					save_mgo.UpdateById("result_20210108", curID, map[string]interface{}{
						"$set": dict,
					})
				}(dict, curID)
			}
		}
		tmp = make(map[string]interface{})
	}

	wg.Wait()
	time.Sleep(30 * time.Second)
	log.Debug("处理完毕over......", total, isOK)
}
func fieldValidValue(data map[string]interface{}) (bool, map[string]interface{}) {
	b := false
	dict := make(map[string]interface{}, 0)
	bidmode := qu.IntAll(data["bidmode"])
	if bidmode == 1 {
		b = true
		dict["bidway"] = "纸质投标"
	} else if bidmode == 2 {
		b = true
		dict["bidway"] = "电子投标"
	}
	getdocmethod := qu.ObjToString(data["getdocmethod"])
	if getdocmethod != "" {
		b = true
		dict["getdocmethod"] = getdocmethod
	}
	agencyfee := qu.Float64All(data["agencyfee"])
	if agencyfee > float64(0) {
		b = true
		dict["agencyfee"] = agencyfee
	}
	agencyrate := qu.Float64All(data["agencyrate"])
	if agencyrate > float64(0) {
		b = true
		dict["agencyrate"] = agencyrate
	}
	docamount := qu.Float64All(data["docamount"])
	if docamount > float64(0) {
		b = true
		dict["docamount"] = docamount
	}
	return b, dict
}

//导出实体数据
func exportEntityData() {
	log.Debug("......导出数据")
	sess := save_mgo.GetMgoConn()
	defer save_mgo.DestoryMongoConn(sess)
	q := map[string]interface{}{}
	arr := make([]map[string]string, 0)
	total := 0
	it := sess.DB(save_mgo.DbName).C("bidding_buyer_test").Find(&q).Iter()
	for tmp := make(map[string]interface{}); it.Next(&tmp); total++ {
		if total%1000 == 0 {
			log.Debug("cur index ", total, tmp["_id"])
		}

		detail := trimHtml(qu.ObjToString(tmp["detail"]))
		buyer := qu.ObjToString(tmp["buyer"])
		//buyer不能有符号
		buyer = strings.ReplaceAll(buyer, "（", "(")
		buyer = strings.ReplaceAll(buyer, "）", ")")

		length := utf8.RuneCountInString(detail)
		if length > 50 && buyer != "" {
			if length > 500 {
				detail = string([]rune(detail)[0:500])
			}
			if strings.Contains(detail, buyer) {
				arr = append(arr, map[string]string{
					"detail": detail,
					"buyer":  buyer,
				})
				//log.Debug("长度：",len(detail),utf8.RuneCountInString(detail))
			}
		}
		tmp = make(map[string]interface{})
	}
	log.Debug("准备完毕......", len(arr))

	maxTag := 0
	indexArrStr := make([]map[string]string, 0)
	for _, v := range arr {
		detail := v["detail"]
		buyer := v["buyer"]
		reg := regexp.MustCompile(buyer)
		indexArr := reg.FindAllStringIndex(detail, -1)
		//log.Debug(indexArr)
		if len(indexArr) > maxTag {
			maxTag = len(indexArr)
		}
		//处理下标 [7,8],LOC   [[3 30] [48 75] [304 331]]
		str := ""
		for _, index := range indexArr {
			first_index := index[0]
			tempStr := detail[0:first_index]
			head, length := utf8.RuneCountInString(tempStr), utf8.RuneCountInString(buyer)
			if str == "" {
				str = fmt.Sprintf("[%d,%d],采购单位", head, head+length)
			} else {
				str = str + fmt.Sprintf(":[%d,%d],采购单位", head, head+length)
			}
		}
		indexArrStr = append(indexArrStr, map[string]string{
			"detail": string(detail),
			"index":  str,
		})
		//log.Debug(str)
	}
	os.Remove("训练模型.xlsx")
	f := xlsx.NewFile()
	sheet, _ := f.AddSheet("extract")
	row := sheet.AddRow()
	row.AddCell().Value = "文本内容"
	for i := 1; i <= maxTag; i++ {
		row.AddCell().SetString(fmt.Sprintf("实体标注%d", i))
	}
	for _, tmp := range indexArrStr {
		row = sheet.AddRow()
		row.AddCell().SetString(fmt.Sprintf("%s入库量", tmp["detail"]))
		indexArr := strings.Split(tmp["index"], ":")
		for _, str := range indexArr {
			row.AddCell().SetString(fmt.Sprintf("%s", str))
		}
	}
	err := f.Save("训练模型.xlsx")
	if err != nil {
		log.Debug("保存xlsx失败:", err)
		return
	} else {
		log.Debug("保存xlsx成功:", err)
	}

}
func trimHtml(src string) string {
	//将HTML标签全转换成小写
	re, _ := regexp.Compile("\\<[\\S\\s]+?\\>")
	src = re.ReplaceAllStringFunc(src, strings.ToLower)
	//去除STYLE
	re, _ = regexp.Compile("\\<style[\\S\\s]+?\\</style\\>")
	src = re.ReplaceAllString(src, "")
	//去除SCRIPT
	re, _ = regexp.Compile("\\<script[\\S\\s]+?\\</script\\>")
	src = re.ReplaceAllString(src, "")
	//去除所有尖括号内的HTML代码，并换成换行符
	re, _ = regexp.Compile("\\<[\\S\\s]+?\\>")
	src = re.ReplaceAllString(src, "\n")
	//去除连续的换行符
	re, _ = regexp.Compile("\\s{2,}")
	src = re.ReplaceAllString(src, "\n")
	return strings.TrimSpace(src)
}
func escape(s string) string {
	news := ""
	for _, c := range s {
		if unicode.Is(unicode.Han, c) || unicode.IsNumber(c) || unicode.IsLetter(c) {
			news = news + string(c)
		} else if c == '\\' || c == '+' || c == '-' || c == '!' || c == '(' || c == ')' || c == ':' || c == '^' || c == '[' || c == ']' || c == '"' || c == '{' || c == '}' || c == '~' || c == '*' || c == '?' || c == '|' || c == '&' || c == '/' || c == '#' || c == '@' || c == '（' || c == '）' || c == '>' || c == '<' || c == '“' || c == '”' || c == '？' || c == '、' || c == '.' {
			a := string([]rune{os.PathSeparator, '\\'})
			news = news + a + string(c)
		} else {
			return ""
		}
	}
	return news
}

//抽取试验方式
func extract_test() {

	//reg := regexp.MustCompile(`^.{2}([大|小|中|学][学|院]|公司)$`)
	//bol:= reg.MatchString("一名司公")
	//log.Debug(bol)
	//
	//
	//return

	//text := `采购公告期：2020年04月13日
	//		品目分类: 货物
	//		采购项目包组: A
	//		供应商组织机构代码: 9113012955331793XL
	//		供应商名称: 河北金谷粮食机械有限公司
	//		供应商地址: 赞皇县赞皇镇东白草坪村
	//		主要标的名称: 高邑县金达粮油购销有限责任公司使用构建粮食延伸收购服务网点工程
	//		金额（元）: 685448.43元
	//		优惠率: 无
	//		服务要求: 详见文件`
	//var MultiReg = regexp.MustCompile("(([一二三四五六七八九十0-9A-Za-zⅠⅡⅢⅣⅤⅥⅦⅧⅨⅩⅪⅫ\\-])+(包|标段|分标))[:：]?|(?:^|\\n)([一二三四五六七八九十0-9A-Za-zⅠⅡⅢⅣⅤⅥⅦⅧⅨⅩⅪⅫ\\-]+(包))|([第]?([一二三四五六七八九十0-9A-Za-zⅠⅡⅢⅣⅤⅥⅦⅧⅨⅩⅪⅫ\\-]+)#?((子|合同|分|施工|监理)?(标段?|合同段|标包)))|(((子|分|合同|施工|监理|标包|标|包)(标|包段|项|组)?)[ 　　  ]*([一二三四五六七八九十0-9A-Za-zⅠⅡⅢⅣⅤⅥⅦⅧⅨⅩⅪⅫ\\-]+))[:：]?|(子项目[0-9]+)|采购项目(包组)[:：\\s]+?([一二三四五六七八九十0-9A-Za-zⅠⅡⅢⅣⅤⅥⅦⅧⅨⅩⅪⅫ\\-]+)")
	//b:=MultiReg.MatchString(text)
	//log.Debug(b)
	//res := MultiReg.FindAllStringSubmatch(text, -1)
	//log.Debug(res)
	var winnerReg20 = regexp.MustCompile("(中标单位候选人名称)[\\s]+(.*)[\\s]+(中标候选人单位名次)[\\s]+([弟|第][一二三四五六七八九十0-9]中标人)")
	text := `1 中标单位候选人名称
	   四川兴荣祺商贸有限公司
       中标候选人单位名次
	   第一中标人
	   序号
	   2 中标单位候选人名称
	   乐山万美商贸有限公司
	   中标候选人单位名次
	   第二中标人
	   序号
	   3 中标单位候选人名称
	   四川睿鑫宇商贸有限公司
	   中标候选人单位名次
	   第三中标人`

	b := winnerReg20.MatchString(text)
	log.Debug(b)
	text = winnerReg20.ReplaceAllString(text, "\n${4}:${2}\n")
	log.Debug(text)

	var winnerReg0 = regexp.MustCompile("(中标候选人第\\d名|第[0-9一二三四五](中选|中标|成交)候选人|中标人[1-9]|第[一二三四五0-9]中标人)")
	tttt := `第一中标人:四川兴荣祺商贸有限公司`
	array := winnerReg0.FindAllStringSubmatchIndex(`第一中标人:四川兴荣祺商贸有限公司`, -1)
	dddd := array[0]
	log.Debug(tttt[(dddd[1]):])
	//str := `
	//	中标信息:
	//	一标段：中标内容：大型干湿两用扫地车2台
	//	中标供应商：烟台海德专用汽车有限公司
	//	中标金额：壹佰叁拾肆万圆整
	//	：1340000元`
	//var mmm = regexp.MustCompile("(第[0-9]包)|([（]?第[0-9]包[）]?)")
	//res := mmm.FindAllStringSubmatch("工程监理项目（第4包）第三包", -1)
	//log.Debug(res)
	//pretreated.CheckMultiPackage(str, "中标信息") //找pkg分包包名
}

func IsMarkInterfaceArr(t interface{}) []string {
	sub_list := []string{}
	if list_3, ok_3 := t.([]string); ok_3 {
		sub_list = list_3
		return sub_list
	}

	if list_1, ok_1 := t.(primitive.A); ok_1 {
		sub_list = qu.ObjArrToStringArr(list_1)
	} else {
		if list_2, ok_2 := t.([]interface{}); ok_2 {
			sub_list = qu.ObjArrToStringArr(list_2)
		}
	}
	return sub_list
}

func IsMarkInterfaceMap(t interface{}) []map[string]interface{} {
	p_list := []map[string]interface{}{}
	if yl_list_1, ok_1 := t.(primitive.A); ok_1 {
		p_list = qu.ObjArrToMapArr(yl_list_1)
	} else {
		if yl_list_2, ok_2 := t.([]interface{}); ok_2 {
			p_list = qu.ObjArrToMapArr(yl_list_2)
		}
	}
	return p_list
}

//临时测试方法
func testMethod() {
	qu.Catch()
	log.Debug("处理数据...")

	redis.InitRedis("test=127.0.0.1:6379")
	//elastic.InitElasticSize("http://ela.spdata.jianyu360.com",10)

	var Url = "https://www.jianyu360.com/article/content/%s.html"
	var Encode = fmt.Sprintf(Url, qu.CommonEncodeArticle("content", "60b9bf4a8a2adb30a5a25000"))
	var Decode = qu.CommonDecodeArticle("content", "AKSY1wJZDweAj07GXd6Z3IzJicvASJgdnxxPygFLCFFcFVzeSNUCZ4%3D") //[0]
	log.Debug(Encode)
	log.Debug(Decode[0])
}

var reg_alias = regexp.MustCompile("(税务局|工商行政管理局|文化广播电视新闻出版局|外国专家局|" +
	"中医药管理局|市场监督管理局|广播电视局|医疗保障局|机关事务管理局|粮食和物资储备局|" +
	"监狱管理局|畜牧兽医局|食品药品监督管理局|城市管理行政执法局|城市管理局|国家保密局|密码管理局|" +
	"地方金融监督管理局|住房保障和房屋管理局|质量技术监督局|人力资源与社会保障局|公路管理局|国土资源局|" +
	"卫生和计划生育局|民事政务局|公众安全局|交通管理局|人力资源和社会保障局|劳动和社会保障局|" +
	"住房和城乡建设局|就业服务局|文物管理局|环境保护局|粮食和物资储备局|教育体育局|" +
	"体育局|教育局|招商局|农业局|农机局|水务局|林业局|财政局|审计局|统计局|商务局)$")
var reglen *regexp.Regexp = regexp.MustCompile("^(.{1,3}|.{40,})$")
var strReg *regexp.Regexp = regexp.MustCompile("^(.{0,3}工程队|.{0,3}总公司|_+|.{0,2}设备安装公司|.{0,2}装[饰修潢]公司|.{0,2}开发公司|.{0,4}有限公司|.{0,4}有限责任公司|.{0,4}设计院|建筑设计研?究?院|省文物考古研究所|经济开发区|省.*|镇人民政府|.{0,2}服务公司|" +
	".{0,2}工程质量监督站|.{0,3}经[营销]部|.{0,3}事务所|.{0,4}工程公司|.{0,4}责任公司|.*勘测|.{0,4}研究院|.*能源建|.{0,2}安装工程|.*[市省]{1}|.{0,4}中心|.*区.?|" +
	".{0,3}税务局|.{0,3}财政局|.{0,3}商行|.{0,2}公安处|.{0,2}测绘院|.{0,3}开发|.{0,2}建设局|.{0,2}经销部|.{0,3}委员会|.{0,2}分公司|.{0,2}管理站|.{0,2}事务管理局|" +
	".*资料|.{0,2}办公用品.{1,2}|.*唯亭|.*设备|.+安装|.{0,2}技术服务|市.+[台院社局司]|城?区.+[府局室院]|县.+[院台局]|.{0,2}发展公司|经济技术开发|" +
	"发展和改革局|贵州有色地质|铝塑门窗加工|生产力促进中心|特殊普通合伙|工业集团公司|人民调解协会|人民政府办公厅|机电设备公司|房地产开发有限公司|.{0,4}商店|中等专业学校|" +
	"农村信用联社|.{0,4}经营部|.{0,4}销售部|驾驶员培训学校|.{2}县.{2}镇|保安服务总公司|住房和城乡建设局|地产评估事务所|生产资料门市部|×+|.{0,3}[0-9]{15}|.*[0-9]+|.*路|.*无字号名称.*|.*车|.*[,，]{1}.*|.*个体工商户|.*运输户)$")

//非中文开头...
var unstart_strReg *regexp.Regexp = regexp.MustCompile("^([\u4e00-\u9fa5])")

//开头
var start_strReg *regexp.Regexp = regexp.MustCompile("^([a-zA-Z]{1,2}[\u4e00-\u9fa5]{6,}|省|市|县|区|业绩|资格|中标|项目|预算单位)")

//结尾
var end_strReg *regexp.Regexp = regexp.MustCompile("(\\.|\\.\\.|餐馆|店|腻子|肉庄|画社|美发屋|发廊|网吧|网咖|零售点|新街|包子铺|奶茶铺|（株）|先生|女士|小姐|" +
	"资格|业绩|中标|项目|预算单位|摊位号|号|厅|室|部|点|馆|场|厂|床|所|处|站|行|中心|合作社|ATMS|" +
	"吧|楼|摊|摊位|廊|茶社|坊|圃|汤锅|园|民宿|美容院|房|排挡|府|庄|栈|队|批发|苑|养殖户|棋牌|农家乐|货运|" +
	"城|社|基地|会|服务|娱乐|种植|百货|汽修|农家菜|亭|小吃|快餐|粮库|卫生院|书画院|面|门窗|鸡排|屋|橱|堂|肉铺|服务|服饰|/＊)$")

//包含
var con_strReg *regexp.Regexp = regexp.MustCompile("(\\?|？|%|代码标识|删除|错误|吊销|注销|发起人|待清理|&#|护照号|身份证号|" +
	"法人|&nbsp|国家拨入|借款|积累资金|单位自有|认股人|--|、|&|`|美元|[\u4e00-\u9fa5]{2,6}·[\u4e00-\u9fa5]{2,6})|" +
	"[a-zA-Z]{5,}")

var uncon_strReg *regexp.Regexp = regexp.MustCompile("(园|政府|集团|公司|有限|合伙|企|院|学|局|处)")

var startWordReg_1 *regexp.Regexp = regexp.MustCompile("^(.{1,5})(省|市|县|州|自治区|特别行政区)")
var startWordReg_2 *regexp.Regexp = regexp.MustCompile("^(北京|天津|重庆|上海|河北|山西|" +
	"浙江|江西|湖北|吉林|海南|甘肃|广东|陕西|辽宁|山东|河南|云南|黑龙江|福建|贵州|江苏|安徽|" +
	"湖南|四川|青海|台湾|新疆|内蒙古|宁夏|西藏|广西|澳门|香港)")
var startWordReg_3 *regexp.Regexp = regexp.MustCompile("^(北京市|天津市|重庆市|上海市|河北省|山西省|" +
	"浙江省|江西省|湖北省|吉林省|海南省|甘肃省|广东省|陕西省|辽宁省|山东省|河南省|云南省|黑龙江省|福建省|贵州省|江苏省|安徽省|" +
	"湖南省|四川省|青海省|台湾省|新疆维吾尔自治区|内蒙古自治区|宁夏回族自治区|西藏自治区|广西壮族自治区|澳门特别行政区|香港特别行政区)")

var endWordReg *regexp.Regexp = regexp.MustCompile("(有限公司|有限责任公司)$")
