123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291 |
- package main
- import (
- "customer_project/config"
- "fmt"
- "jygit.jydev.jianyu360.cn/data_processing/common_utils/elastic"
- "jygit.jydev.jianyu360.cn/data_processing/common_utils/log"
- "jygit.jydev.jianyu360.cn/data_processing/common_utils/mongodb"
- "jygit.jydev.jianyu360.cn/data_processing/common_utils/mysqldb"
- "os"
- "sync"
- )
- var (
- MongoTool *mongodb.MongodbSim
- MysqlTool, MysqlEnt *mysqldb.Mysql
- Es *elastic.Elastic
- findLock sync.Mutex
- //mapPb, mapPn, mapPc map[string]*Key
- mapEnt map[int64]*EntMap
- AllIdsMapLock sync.Mutex
- AllIdsMap map[string]*ID
- //仅初始化使用
- compareNoPass = map[string]bool{}
- compareAB = map[string]bool{}
- compareAB2D = map[string]bool{}
- compareABD = map[string]bool{}
- compareAB2CD = map[string]bool{}
- compareABCD = map[string]bool{}
- )
- type EntMap struct {
- mapPb map[string]*Key
- mapPn map[string]*Key
- mapPc map[string]*Key
- }
- type ID struct {
- Id string
- Lock sync.Mutex
- P *Project
- }
- type Key struct {
- Arr []string
- Lock sync.Mutex
- }
- func init() {
- wg = sync.WaitGroup{}
- AllIdsMap = make(map[string]*ID, 5000000)
- //mapPb = make(map[string]*Key, 1500000)
- //mapPn = make(map[string]*Key, 5000000)
- //mapPc = make(map[string]*Key, 5000000)
- mapEnt = make(map[int64]*EntMap, 5000)
- //加载项目数据
- //---不能通过
- vm := []string{"C", "D"}
- for i := 0; i < 2; i++ {
- for j := 0; j < 2; j++ {
- for k := 0; k < 2; k++ {
- key := vm[i] + vm[j] + vm[k]
- compareNoPass[key] = true
- //fmt.Println(key)
- }
- }
- }
- //fmt.Println("-------------------")
- //三个元素一致 [AB][AB][AB],分值最高
- vm = []string{"A", "B"}
- for i := 0; i < 2; i++ {
- for j := 0; j < 2; j++ {
- for k := 0; k < 2; k++ {
- key := vm[i] + vm[j] + vm[k]
- compareAB[key] = true
- //fmt.Println(key)
- }
- }
- }
- //fmt.Println("-------------------", len(compareAB))
- //---至少两个一致,其他可能不存在
- //[AB][AB][ABD]
- //[AB][ABD][AB]
- vm = []string{"A", "B"}
- vm2 := []string{"A", "B", "D"}
- for i := 0; i < 2; i++ {
- for j := 0; j < 2; j++ {
- for k := 0; k < 3; k++ {
- key := vm[i] + vm[j] + vm2[k]
- if !compareAB[key] {
- compareAB2D[key] = true
- //fmt.Println(key)
- }
- }
- }
- }
- for i := 0; i < 2; i++ {
- for j := 0; j < 3; j++ {
- for k := 0; k < 2; k++ {
- key := vm[i] + vm2[j] + vm[k]
- if !compareAB[key] {
- compareAB2D[key] = true
- //fmt.Println(key)
- }
- }
- }
- }
- //fmt.Println("-------------------", len(compareAB2D))
- //---至少一个一致,其他可能不存在
- //[ABD][ABD][ABD] //已经删除DDD
- vm = []string{"A", "B", "D"}
- for i := 0; i < 3; i++ {
- for j := 0; j < 3; j++ {
- for k := 0; k < 3; k++ {
- key := vm[i] + vm[j] + vm[k]
- if !compareAB[key] && !compareAB2D[key] && !compareNoPass[key] {
- compareABD[key] = true
- //fmt.Println(key)
- }
- }
- }
- }
- //fmt.Println("-------------------", len(compareABD))
- //[AB][ABCD][AB]
- //[AB][AB][ABCD]
- vm = []string{"A", "B"}
- vm2 = []string{"A", "B", "C", "D"}
- for i := 0; i < 2; i++ {
- for j := 0; j < 4; j++ {
- for k := 0; k < 2; k++ {
- key := vm[i] + vm2[j] + vm[k]
- if !compareAB[key] && !compareAB2D[key] && !compareNoPass[key] && !compareABD[key] {
- compareAB2CD[key] = true
- //fmt.Println(key)
- }
- }
- }
- }
- for i := 0; i < 2; i++ {
- for j := 0; j < 2; j++ {
- for k := 0; k < 4; k++ {
- key := vm[i] + vm[j] + vm2[k]
- if !compareAB[key] && !compareAB2D[key] && !compareNoPass[key] && !compareABD[key] {
- compareAB2CD[key] = true
- //fmt.Println(key)
- }
- }
- }
- }
- //fmt.Println("-------------------", len(compareAB2CD))
- //[ABECD][ABECD][ABECD] //已经删除[CD][CD][CD] //这个要重点讨论
- vm = []string{"A", "B", "C", "D"}
- for i := 0; i < 4; i++ {
- for j := 0; j < 4; j++ {
- for k := 0; k < 4; k++ {
- key := vm[i] + vm[j] + vm[k]
- if !compareAB[key] && !compareAB2D[key] && !compareABD[key] && !compareNoPass[key] && !compareAB2CD[key] {
- compareABCD[key] = true
- //fmt.Println(key)
- }
- }
- }
- }
- }
- func InitMysql() {
- dbcfg := config.Conf.DB.Mysql
- MysqlTool = &mysqldb.Mysql{
- Address: dbcfg.Addr,
- DBName: dbcfg.Dbname,
- UserName: dbcfg.User,
- PassWord: dbcfg.Password,
- }
- MysqlTool.Init()
- MysqlEnt = &mysqldb.Mysql{
- Address: config.Conf.DB.Ent.Addr,
- DBName: config.Conf.DB.Ent.Dbname,
- UserName: config.Conf.DB.Ent.User,
- PassWord: config.Conf.DB.Ent.Password,
- }
- MysqlEnt.Init()
- }
- func InitLog() {
- logcfg := config.Conf.Log
- err := log.InitLog(
- log.Path(logcfg.LogPath),
- log.Level(logcfg.LogLevel),
- log.Compress(logcfg.Compress),
- log.MaxSize(logcfg.MaxSize),
- log.MaxBackups(logcfg.MaxBackups),
- log.MaxAge(logcfg.MaxAge),
- log.Format(logcfg.Format),
- )
- if err != nil {
- fmt.Printf("InitLog failed: %v\n", err)
- os.Exit(1)
- }
- }
- type Project struct {
- Id int64 `json:"msg_id"`
- EntId int64 `json:"ent_id"`
- ProjectId string `json:"projectId"`
- FirstTime string `json:"firsttime,omitempty"` //项目的最早时间
- LastTime string `json:"lasttime,omitempty"` //项目的最后时间
- ProjectName string `json:"projectname,omitempty"` //项目名称
- ProjectCode string `json:"projectcode,omitempty"` //项目代码
- Buyer string `json:"buyer,omitempty"` //采购单位
- Agency string `json:"agency"` //代理机构
- //Winners string `json:"s_winner,omitempty"` //中标人
- Area string `json:"area"` //地区
- City string `json:"city"` //地市
- District string `json:"district"` //区县
- Bidamount float64 `json:"bidamount,omitempty"` //中标金额
- Budget float64 `json:"budget,omitempty"` //预算
- Bidtype string `json:"bidtype"`
- Bidstatus string `json:"bidstatus"`
- score int
- comStr string
- resVal, pjVal int
- Topscopeclass []string `json:"topscopeclass,omitempty"`
- Subscopeclass []string `json:"subscopeclass,omitempty"` //子行业分类
- Buyerperson string `json:"buyerperson"` //采购联系人
- Buyertel string `json:"buyertel"` //采购联系人电话
- AgencyPerson string `json:"agencyperson"`
- AgencyTel string `json:"agencytel"`
- //WinnerPerson string `json:"winnerperson"`
- //WinnerTel string `json:"winnertel"`
- Buyerclass string `json:"buyerclass"` //采购单位分类
- Bidopentime int64 `json:"bidopentime,omitempty"` //开标时间
- Jgtime int64 `json:"jgtime"` //结果中标时间
- Zbtime int64 `json:"zbtime"` //招标时间
- Industry string `json:"industry"`
- Region string `json:"region"`
- WinnerTag string `json:"winner_tag"`
- TagName string `json:"tagname"` //招标单位一级标签
- TagName2 string `json:"tagname2"` //招标单位二级行业
- TagName3 string `json:"tagname3"` //中标单位行业归类
- }
- type Info struct {
- Id int64 `json:"id"`
- EntId int64 `json:"eid"`
- RuleName string `json:"rulename"`
- TagName string `json:"tagname"`
- TagName2 string `json:"tagname2"`
- TagName3 string `json:"tagname3"`
- Href string `json:"href"` //源地址
- JybxHref string `json:"jybxhref"`
- Publishtime string `json:"publishtime"`
- Title string `json:"title"`
- TopType string `json:"toptype"`
- SubType string `json:"subtype"`
- ProjectName string `json:"projectname"`
- ProjectCode string `json:"projectcode"`
- Buyer string `json:"buyer"`
- Buyerperson string `json:"buyerperson"`
- Buyertel string `json:"buyertel"`
- WinnerTel string `json:"winnertel"`
- WinnerPerson string `json:"winnerperson"`
- Agency string `json:"agency"`
- AgencyPerson string `json:"agencyperson"`
- AgencyTel string `json:"agencytel"`
- Area string `json:"area"`
- City string `json:"city"`
- District string `json:"district"`
- Buyerclass string `json:"buyerclass"`
- Budget float64 `json:"budget"`
- Bidamount float64 `json:"bidamount"`
- Region string `json:"region"`
- Industry string `json:"industry"`
- WinnerTag string `json:"winner_tag"`
- Winners []string
- pnbval int //项目名称、编号、采购单位存在的个数
- LenPC int //项目编号长度
- LenPN int //项目名称长度
- LenPTC int //标题抽的项目编号长度
- }
|