package main import ( "fmt" "go.mongodb.org/mongo-driver/bson/primitive" "jygit.jydev.jianyu360.cn/data_processing/common_utils/log" "jygit.jydev.jianyu360.cn/data_processing/common_utils/mongodb" "medical_project/config" "os" "regexp" "sync" ) var ( MongoBid, MongoPro *mongodb.MongodbSim //mongodb连接 wg sync.WaitGroup findLock sync.Mutex //采购单位、项目名称、项目编号 mapPb, mapPn, mapPc map[string]*Key AllIdsMapLock sync.Mutex AllIdsMap map[string]*ID //bidtype、bidstatus 锁 mapBidLock sync.Mutex updatePool chan []map[string]interface{} updateSp chan bool saveSize int currentType string currentTime int64 pici int64 validTime int64 statusTime int64 jgTime int64 compareNoPass = map[string]bool{} compareAB = map[string]bool{} compareAB2D = map[string]bool{} compareABD = map[string]bool{} compareAB2CD = map[string]bool{} compareABCD = map[string]bool{} _datereg = regexp.MustCompile("20[0-2][0-9][年-][0-9]{1,2}[月-][0-9]{1,2}[日-]([0-9]{1,2}时[0-9]{0,2})?") replaceStr = regexp.MustCompile("(工程|采购|项目|[?!、【】()—()--]|栏标价|中标候选人|招标代理)") //纯数字或纯字母 StrOrNum2 = regexp.MustCompile("^[0-9_-]+$|^[a-zA-Z_-]+$") //含分包词,招标未识别分包 合并到一个项目 KeyPackage = regexp.MustCompile("[0-9a-zA-Z一二三四五六七八九十ⅠⅡⅢⅣⅤⅥⅦⅧⅨⅩ]+.{0,2}(包|段)|(包|段)[0-9a-zA-Z一二三四五六七八九十ⅠⅡⅢⅣⅤⅥⅦⅧⅨⅩ]+.{0,2}") titleGetPc = regexp.MustCompile("^([-0-9a-zA-Z第号采招政询电审竞#]{8,}[-0-9a-zA-Z#]+)") titleGetPc1 = regexp.MustCompile("[\\[【((](.{0,6}(编号|编码|项号|包号|代码|标段?号)[::为])?([-0-9a-zA-Z第号采招政询电审竞#]{5,}([\\[\\]()()][-0-9a-zA-Z第号采招审竞#]+[\\[\\]()()][-0-9a-zA-Z第号采招审竞#]+)?)[\\]】))]") titleGetPc2 = regexp.MustCompile("([-0-9a-zA-Z第号采政招询电审竞#]{8,}[-0-9a-zA-Z#]+)(.{0,5}公告)?$") numCheckPc = regexp.MustCompile("^[0-9-]{1,10}$") StrOrNum = regexp.MustCompile("^[0-9_-]{1,4}$|^[a-zA-Z_-]{1,4}$") _zimureg1 = regexp.MustCompile("^[a-zA-Z-]{1,7}$") ) func init() { config.Init("./common.toml") InitLog() InitMgo() updatePool = make(chan []map[string]interface{}, 5000) updateSp = make(chan bool, 1) saveSize = 200 wg = sync.WaitGroup{} mapPn = make(map[string]*Key, 5000000) AllIdsMap = make(map[string]*ID, 5000000) mapPb = make(map[string]*Key, 1500000) mapPn = make(map[string]*Key, 5000000) mapPc = make(map[string]*Key, 5000000) validTime = int64(config.Conf.Server.ValidTime * 86400) statusTime = int64(config.Conf.Server.StatusDays * 86400) jgTime = int64(7 * 86400) //加载项目数据 //---不能通过 vm := []string{"C", "D"} //三个元素一致 [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 } } } } 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) } } func InitMgo() { MongoBid = &mongodb.MongodbSim{ MongodbAddr: config.Conf.DB.MongoB.Addr, DbName: config.Conf.DB.MongoB.Dbname, Size: config.Conf.DB.MongoB.Size, UserName: config.Conf.DB.MongoB.User, Password: config.Conf.DB.MongoB.Password, } MongoBid.InitPool() MongoPro = &mongodb.MongodbSim{ MongodbAddr: config.Conf.DB.MongoP.Addr, DbName: config.Conf.DB.MongoP.Dbname, Size: config.Conf.DB.MongoP.Size, UserName: config.Conf.DB.MongoP.User, Password: config.Conf.DB.MongoP.Password, } MongoPro.InitPool() } //招标信息实体类 type Info struct { Id string `json:"_id"` Href string `json:"href"` //源地址 Publishtime int64 `json:"publishtime"` Comeintime int64 `json:"comeintime"` Title string `json:"title"` TopType string `json:"toptype"` SubType string `json:"subtype"` ProjectName string `json:"projectname"` ProjectCode string `json:"projectcode"` ProjectScope string `json:"projectscope"` ContractCode string `json:"contractcode"` Buyer string `json:"buyer"` Buyerperson string `json:"buyerperson"` Buyertel string `json:"buyertel"` Agency string `json:"agency"` Area string `json:"area"` City string `json:"city"` District string `json:"district"` Infoformat int `json:"infoformat"` ReviewExperts []string `json:"review_experts"` Purchasing string `json:"purchasing"` WinnerOrder []map[string]interface{} `json:"winnerorder"` ProjectScale string `json:"project_scale"` ProjectDuration int `json:"project_duration"` ProjectTimeUnit string `json:"project_timeunit"` ProjectStartDate int64 `json:"project_startdate"` ProjectCompleteDate int64 `json:"project_completedate"` Payway string `json:"payway"` ContractGuarantee bool `json:"contract_guarantee"` BidGuarantee bool `json:"bid_guarantee"` Qualifies []map[string]interface{} `json:"qualifies"` EntIdList []string `json:"entidlist"` HasPackage bool // `json:"haspackage"` Package map[string]interface{} `json:"package"` Topscopeclass []string `json:"topscopeclass"` Subscopeclass []string `json:"subscopeclass"` Buyerclass string `json:"buyerclass"` Bidopentime int64 `json:"bidopentime"` Budget float64 `json:"budget"` Bidamount float64 `json:"bidamount"` Winners []string dealtype int PTC string //从标题中抽的项目编号 pnbval int //项目名称、编号、采购单位存在的个数 LenPC int //项目编号长度 LenPN int //项目名称长度 LenPTC int //标题抽的项目编号长度 //以下三个元素做对比,计算包含时候使用 PNBH int //0初始,+包含,-被包含 PCBH int PTCBH int } // 内存 项目信息 type Project struct { Id primitive.ObjectID `json:"_id"` Ids []string `json:"ids,omitempty"` FirstTime int64 `json:"firsttime,omitempty"` //项目的最早时间 LastTime int64 `json:"lasttime,omitempty"` //项目的最后时间 ProjectName string `json:"projectname,omitempty"` //项目名称 ProjectCode string `json:"projectcode,omitempty"` //项目代码唯一(纯数字的权重低) Buyer string `json:"buyer,omitempty"` //采购单位唯一 Agency string `json:"agency"` //代理机构 Area string `json:"area"` //地区 City string `json:"city"` //地市 District string `json:"district"` //区县 Bidamount float64 `json:"bidamount,omitempty"` //中标金额 Budget float64 `json:"budget,omitempty"` //预算 score int comStr string MPN []string `json:"mpn,omitempty"` //合并后多余的项目名称 MPC []string `json:"mpc,omitempty"` //合并后多余的项目编号 resVal, pjVal int Topscopeclass []string `json:"topscopeclass,omitempty"` Subscopeclass []string `json:"subscopeclass,omitempty"` //子行业分类 Winners string `json:"s_winner,omitempty"` //中标人 ContractCode string `json:"contractcode,omitempty"` //合同编号 Buyerperson string `json:"buyerperson"` //采购联系人 Buyertel string `json:"buyertel"` //采购联系人电话 Bidstatus string `json:"bidstatus"` // Bidtype string `json:"bidtype"` // ReviewExperts []string `json:"review_experts"` // 项目评审专家 Purchasing string `json:"purchasing"` // 标的物 Package map[string]interface{} `json:"package,omitempty"` //分包的对比对象 Buyerclass string `json:"buyerclass"` //采购单位分类 Bidopentime int64 `json:"bidopentime,omitempty"` //开标时间 Jgtime int64 `json:"jgtime"` //结果中标时间 Zbtime int64 `json:"zbtime"` //招标时间 Winnerorder []string `json:"winnerorder"` //中标候选人 ProjectScale string `json:"project_scale"` //项目规模 ProjectDuration int `json:"project_duration"` //工期时长 ProjectTimeunit string `json:"project_timeunit"` //工期时长单位 ProjectStartDate int64 `json:"project_startdate"` //开工日期 ProjctCompleteDate int64 `json:"projct_completedate"` //竣工日期 Payway string `json:"payway"` //付款方式 ContractGuarantee bool `json:"contract_guarantee"` //履约保证金 是否支持包含 BidGuarantee bool `json:"bid_guarantee"` //投标保证金 是否支持包含 Qualifies string `json:"qualifies"` //资质条件 EntIdList []string `json:"entidlist"` //企业id //FirstCooperation []string `json:"first_cooperation"` //first_cooperation InfoFiled map[string]InfoField `json:"infofield"` //逻辑处理需要的info字段 Budgettag int `json:"budgettag"` //预算是否有效标记 Bidamounttag int `json:"bidamounttag"` //中标金额是否有效标记 } //存储部分招标信息字段,业务逻辑处理需要 type InfoField struct { Budget float64 `json:"budget"` Bidamount float64 `json:"bidamount"` ContractCode string `json:"contractcode"` ProjectName string `json:"projectname"` ProjectCode string `json:"projectcode"` Bidstatus string `json:"bidstatus"` } type ID struct { Id string Lock sync.Mutex P *Project } type Key struct { Arr []string Lock sync.Mutex }