zhangjinkun 5 lat temu
rodzic
commit
636e8e1323

+ 46 - 46
fullproject/src_v1/init.go

@@ -18,10 +18,10 @@ const (
 )
 
 var (
-	Sysconfig                map[string]interface{} //读取配置文件
-	MongoTool                *MongodbSim            //mongodb连接
-	ExtractColl, ProjectColl, BackupColl, SiteColl string	//抽取表、项目表、项目快照表、站点表
-	Thread					 int				    //配置项线程数
+	Sysconfig                                      map[string]interface{} //读取配置文件
+	MongoTool                                      *MongodbSim            //mongodb连接
+	ExtractColl, ProjectColl, BackupColl, SiteColl string                 //抽取表、项目表、项目快照表、站点表
+	Thread                                         int                    //配置项线程数
 	//NextNode                 []interface{}
 )
 
@@ -63,7 +63,7 @@ func init() {
 
 	ExtractColl = Sysconfig["extractColl"].(string)
 	ProjectColl = Sysconfig["projectColl"].(string)
-	BackupColl = Sysconfig["projectColl"].(string)+"_back"
+	BackupColl = Sysconfig["projectColl"].(string) + "_back"
 	SiteColl = Sysconfig["siteColl"].(string)
 	Thread = util.IntAll(Sysconfig["thread"])
 	//NextNode = Sysconfig["nextNode"].([]interface{})
@@ -222,27 +222,27 @@ func NewKeyMap() *KeyMap {
 
 //招标信息实体类
 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"`
-	HasPackage  bool                   // `json:"haspackage"`
-	Package     map[string]interface{} `json:"package"`
+	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"`
+	HasPackage   bool                   // `json:"haspackage"`
+	Package      map[string]interface{} `json:"package"`
 	//PNum          string                 `json:"pnum"`
 	Topscopeclass []string `json:"topscopeclass"`
 	Subscopeclass []string `json:"subscopeclass"`
@@ -274,10 +274,10 @@ type ProjectInfo struct {
 	Ids           []string           `json:"ids,omitempty"`
 	Topscopeclass []string           `json:"topscopeclass,omitempty"`
 	Subscopeclass []string           `json:"subscopeclass,omitempty"` //子行业分类
-	Winners       []string           `json:"s_winner,omitempty"`       //中标人
+	Winners       []string           `json:"s_winner,omitempty"`      //中标人
 	ProjectName   string             `json:"projectname,omitempty"`   //项目名称
 	ProjectCode   string             `json:"projectcode,omitempty"`   //项目代码唯一(纯数字的权重低)
-	ContractCode  string			 `json:"contractcode,omitempty"`  //项目编号
+	ContractCode  string             `json:"contractcode,omitempty"`  //项目编号
 	Buyer         string             `json:"buyer,omitempty"`         //采购单位唯一
 	MPN           []string           `json:"mpn,omitempty"`           //合并后多余的项目名称
 	MPC           []string           `json:"mpc,omitempty"`           //合并后多余的项目编号
@@ -287,43 +287,43 @@ type ProjectInfo struct {
 	Area          string             `json:"area"`                    //地区
 	City          string             `json:"city"`                    //地市
 	District      string             `json:"district"`                //区县
-	Bidstatus     string			 `json:"bidstatus"`				  //
-	Bidtype		  string			 `json:"bidtype"`				  //
+	Bidstatus     string             `json:"bidstatus"`               //
+	Bidtype       string             `json:"bidtype"`                 //
 	//HasPackage    bool                   `json:"haspackage"`              //是否有分包
 	Package     map[string]interface{} `json:"package,omitempty"`     //分包的对比对象
 	Buyerclass  string                 `json:"buyerclass"`            //采购单位分类
 	Bidopentime int64                  `json:"bidopentime,omitempty"` //开标时间
 	//	Zbtime        int64                  `json:"zbtime"`        //招标时间
-	Jgtime        int64              `json:"jgtime"`        //结果中标时间
+	Jgtime    int64   `json:"jgtime"`              //结果中标时间
 	Bidamount float64 `json:"bidamount,omitempty"` //中标金额
 	Budget    float64 `json:"budget,omitempty"`    //预算
 	//Winnerorder []string `json:"winnerorder"` //中标候选人
 	score         int
 	comStr        string
 	resVal, pjVal int
-	InfoFiled	map[string]InfoField	`json:"infofiled"`			//逻辑处理需要的info字段
-	Budgettag		int					`json:"budgettag"`			//预算是否有效标记
-	Bidamounttag	int					`json:"bidamounttag"`		//中标金额是否有效标记
+	InfoFiled     map[string]InfoField `json:"infofiled"`    //逻辑处理需要的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"`
+	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 Site struct {
-	Id			string				`json:"_id"`
-	Site		string				`json:"site"`			//站点名字
-	Area 		string				`json:"area"`			//省
-	City		string				`json:"city"`			//市
-	District	string				`json:"district"`		//区、县
-	Domain		string				`json:"domain"`			//地址
+	Id       string `json:"_id"`
+	Site     string `json:"site"`     //站点名字
+	Area     string `json:"area"`     //省
+	City     string `json:"city"`     //市
+	District string `json:"district"` //区、县
+	Domain   string `json:"domain"`   //地址
 }
 
 //二分字符串查找

+ 5 - 5
fullproject/src_v1/main.go

@@ -16,10 +16,11 @@ import (
 var (
 	udpclient    mu.UdpClient //udp对象
 	SingleThread = make(chan bool, 1)
+	SingleClear  = 0
 	toaddr       = []*net.UDPAddr{} //下节点对象
 	ChSign       = make(chan os.Signal)
 
-	sid, eid string 	//测试使用
+	sid, eid string //测试使用
 )
 
 func init() {
@@ -58,7 +59,7 @@ func DealSign() {
 	}
 }
 
-func mainT() {
+func main() {
 	//udp跑增量  id段   project
 	//udp跑全量			ql
 	//udp跑历史数据  信息id1,id2/或id段  ls
@@ -77,7 +78,7 @@ func mainT() {
 }
 
 //测试组人员使用
-func main() {
+func mainT() {
 	//sid = "5649a0fcaf5374672e005704"
 	//eid = "5e169e5250b5ea296ec896f0"
 
@@ -108,7 +109,6 @@ func main() {
 	time.Sleep(20 * time.Second)
 }
 
-
 //udp调用信号
 func processUdpMsg(act byte, data []byte, ra *net.UDPAddr) {
 	switch act {
@@ -147,7 +147,7 @@ func processUdpMsg(act byte, data []byte, ra *net.UDPAddr) {
 					P_QL.pici = time.Now().Unix()
 					P_QL.taskZl(mapInfo)
 				}()
-			case "updateInfo":		//招标字段变更
+			case "updateInfo": //招标字段变更
 				go func() {
 					defer func() {
 						<-SingleThread

+ 47 - 47
fullproject/src_v1/project.go

@@ -429,11 +429,11 @@ var FIELDS = []string{
 
 var bidtype = map[string]string{
 	"招标": "招标",
-	"邀标":	"邀标",
-	"询价":	"询价",
-	"单一":	"单一",
-	"竞价":	"竞价",
-	"竞谈":	"竞谈",
+	"邀标": "邀标",
+	"询价": "询价",
+	"单一": "单一",
+	"竞价": "竞价",
+	"竞谈": "竞谈",
 }
 
 var bidstatus = map[string]string{
@@ -483,13 +483,13 @@ func (p *ProjectTask) NewProject(tmp map[string]interface{}, thisinfo *Info) (st
 	if bt == "招标" {
 		set["projectscope"] = qu.ObjToString(tmp["projectscope"])
 		set["bidstatus"] = bt
-	}else {
+	} else {
 		if bidstatus[bs] != "" {
 			set["bidstatus"] = thisinfo.SubType
 		} else if tmp["infoformat"] == 2 {
 			set["bidstatus"] = "拟建"
-		}else if bs == "" {
-			set["bidstatus"] =  ""
+		} else if bs == "" {
+			set["bidstatus"] = ""
 		} else {
 			set["bidstatus"] = "其它"
 		}
@@ -524,7 +524,7 @@ func (p *ProjectTask) NewProject(tmp map[string]interface{}, thisinfo *Info) (st
 		set["budget"] = thisinfo.Budget
 		p1.Budgettag = 0
 		set["budgettag"] = 0
-	}else {
+	} else {
 		p1.Budgettag = 1
 		set["budgettag"] = 1
 	}
@@ -532,7 +532,7 @@ func (p *ProjectTask) NewProject(tmp map[string]interface{}, thisinfo *Info) (st
 		set["bidamount"] = thisinfo.Bidamount
 		p1.Bidamounttag = 0
 		set["bidamounttag"] = 0
-	}else {
+	} else {
 		p1.Bidamounttag = 1
 		set["bidamounttag"] = 1
 	}
@@ -656,7 +656,7 @@ func (p *ProjectTask) NewCachePinfo(id primitive.ObjectID, thisinfo *Info, bidty
 		Bidamount:     thisinfo.Bidamount,
 		Bidstatus:     thisinfo.SubType,
 		Bidtype:       bidtype,
-		Winners: 	   thisinfo.Winners,
+		Winners:       thisinfo.Winners,
 	}
 	if thisinfo.LenPTC > 5 {
 		p1.MPC = append(p1.MPC, thisinfo.PTC)
@@ -690,7 +690,7 @@ func (p *ProjectTask) UpdateProject(tmp map[string]interface{}, thisinfo *Info,
 			pInfo.Jgtime = int64(0)
 			set["jgtime"] = int64(0)
 		}
-	}else if thisinfo.TopType == "结果" {
+	} else if thisinfo.TopType == "结果" {
 		pInfo.Jgtime = thisinfo.Publishtime
 		set["jgtime"] = thisinfo.Publishtime
 	} else if thisinfo.SubType == "合同" {
@@ -718,19 +718,19 @@ func (p *ProjectTask) UpdateProject(tmp map[string]interface{}, thisinfo *Info,
 		}
 		set["bidstatus"] = bt
 		pInfo.Bidstatus = bt
-	}else {
+	} else {
 		if bidstatus[bs] != "" {
 			set["bidstatus"] = thisinfo.SubType
 			pInfo.Bidstatus = thisinfo.SubType
 		} else if tmp["infoformat"] == 2 {
 			set["bidstatus"] = "拟建"
 			pInfo.Bidstatus = "拟建"
-		}else if bs == "" {
-			set["bidstatus"] =  ""
+		} else if bs == "" {
+			set["bidstatus"] = ""
 			pInfo.Bidstatus = ""
-		}else {
+		} else {
 			set["bidstatus"] = "其它"
-			pInfo.Bidstatus =  "其它"
+			pInfo.Bidstatus = "其它"
 		}
 	}
 	p.mapBidLock.Unlock()
@@ -780,7 +780,7 @@ func (p *ProjectTask) UpdateProject(tmp map[string]interface{}, thisinfo *Info,
 		set["buyerclass"] = ""
 	}
 	if thisinfo.ContractCode != "" {
-		set["contractcode"] = pInfo.ContractCode + ","+thisinfo.ContractCode
+		set["contractcode"] = pInfo.ContractCode + "," + thisinfo.ContractCode
 	}
 
 	//8--代理机构
@@ -849,13 +849,13 @@ func (p *ProjectTask) UpdateProject(tmp map[string]interface{}, thisinfo *Info,
 	if pInfo.Budget >= 0 && pInfo.Budgettag != 1 {
 		set["budget"] = pInfo.Budget
 		set["budgettag"] = 0
-	}else {
+	} else {
 		set["budgettag"] = 1
 	}
 	if pInfo.Bidamount >= 0 && pInfo.Bidamounttag != 1 {
 		set["bidamount"] = pInfo.Bidamount
 		set["bidamounttag"] = 0
-	}else {
+	} else {
 		set["bidamounttag"] = 1
 	}
 
@@ -870,7 +870,7 @@ func (p *ProjectTask) UpdateProject(tmp map[string]interface{}, thisinfo *Info,
 	copyMap := Copy(pInfo.InfoFiled).(map[string]InfoField)
 	copyMap[thisinfo.Id] = infofiled
 	tmpMap := make(map[string]interface{})
-	for k, v := range copyMap{
+	for k, v := range copyMap {
 		tmpMap[k] = StructToMap(v)
 	}
 	tmpMap[thisinfo.Id] = StructToMap(infofiled)
@@ -917,15 +917,15 @@ func (p *ProjectTask) CompareStatus(project *ProjectInfo, info *Info) (bool, int
 	if info.TopType == "拟建" || info.TopType == "预告" || info.TopType == "招标" {
 		if project.Bidstatus == "拟建" || project.Bidstatus == "预告" || project.Bidstatus == "招标" {
 			return false, 0
-		}else if project.Bidstatus == "废标" || project.Bidstatus == "流标" {
+		} else if project.Bidstatus == "废标" || project.Bidstatus == "流标" {
 			return false, 0
-		}else {
+		} else {
 			return true, 0
 		}
 	} else if info.TopType == "结果" {
 		if project.Bidstatus == "拟建" || project.Bidstatus == "预告" || project.Bidstatus == "招标" {
 			return false, 0
-		}  else if project.Bidstatus == info.SubType {
+		} else if project.Bidstatus == info.SubType {
 			//状态一样,根据发布时间判断是否合并
 			if (info.Publishtime - project.FirstTime) > p.statusTime {
 				return true, 0
@@ -1048,16 +1048,16 @@ func PackageFormat(info *Info, project *ProjectInfo) map[string]interface{} {
 func CountAmount(project *ProjectInfo, info *Info, tmp map[string]interface{}) {
 	if info.HasPackage {
 		budget := 0.0
-		for _, v := range project.Package{
+		for _, v := range project.Package {
 			v1, _ := v.([]map[string]interface{})
-			for _, v2 := range v1{
+			for _, v2 := range v1 {
 				if v2["budget"] != nil {
 					b1 := qu.Float64All(v2["budget"])
 					if b1 > 0 {
 						budget = budget + b1
 						break
 					}
-				}else {
+				} else {
 					project.Budgettag = 1
 				}
 
@@ -1066,11 +1066,11 @@ func CountAmount(project *ProjectInfo, info *Info, tmp map[string]interface{}) {
 		if budget > 0 {
 			project.Budget = budget
 			project.Budgettag = 0
-		}else if budget == 0 && info.Budget > 0 {
+		} else if budget == 0 && info.Budget > 0 {
 			project.Budget = info.Budget
 			project.Budgettag = 0
 		}
-	}else {
+	} else {
 		//招标没有多包
 		k := KeyPackage.FindStringSubmatch(info.ProjectName)
 		if len(k) > 0 {
@@ -1078,7 +1078,7 @@ func CountAmount(project *ProjectInfo, info *Info, tmp map[string]interface{}) {
 			if len(project.Package) > 0 {
 				//项目有多包
 				flag := false
-				for _, v := range project.Package{
+				for _, v := range project.Package {
 					v1, _ := v.([]map[string]interface{})
 					if len(v1) > 0 && v1[0]["name"] == info.ProjectName {
 						flag = true
@@ -1088,18 +1088,18 @@ func CountAmount(project *ProjectInfo, info *Info, tmp map[string]interface{}) {
 					project.Budget = project.Budget + info.Budget
 					project.Budgettag = 0
 				}
-			}else {
+			} else {
 				//项目没有多包
 				if info.Budget > 0 {
 					project.Budget = project.Budget + info.Budget
 					project.Budgettag = 0
-				}else if info.Budget == 0 && tmp["budget"] != nil {
+				} else if info.Budget == 0 && tmp["budget"] != nil {
 					project.Budgettag = 0
-				}else {
+				} else {
 					project.Budgettag = 1
 				}
 			}
-		}else {
+		} else {
 			if project.Budget < info.Budget {
 				project.Budget = info.Budget
 				project.Budgettag = 0
@@ -1112,16 +1112,16 @@ func CountAmount(project *ProjectInfo, info *Info, tmp map[string]interface{}) {
 	if info.SubType == "中标" || info.SubType == "成交" || info.SubType == "合同" {
 		if info.HasPackage {
 			bidamount := 0.0
-			for _, v := range project.Package{
+			for _, v := range project.Package {
 				v1, _ := v.([]map[string]interface{})
-				for _, v2 := range v1{
+				for _, v2 := range v1 {
 					if tmp["bidamount"] != nil {
 						b1 := qu.Float64All(v2["bidamount"])
 						if b1 > 0 {
 							bidamount = bidamount + b1
 							break
 						}
-					}else {
+					} else {
 						project.Bidamount = 1
 					}
 				}
@@ -1129,11 +1129,11 @@ func CountAmount(project *ProjectInfo, info *Info, tmp map[string]interface{}) {
 			if bidamount > 0 {
 				project.Bidamount = bidamount
 				project.Bidamounttag = 0
-			}else if bidamount == 0 && info.Budget > 0 {
+			} else if bidamount == 0 && info.Budget > 0 {
 				project.Bidamount = info.Bidamount
 				project.Bidamounttag = 0
 			}
-		}else {
+		} else {
 			//招标没有多包
 			k := KeyPackage.FindStringSubmatch(info.ProjectName)
 			if len(k) > 0 {
@@ -1141,7 +1141,7 @@ func CountAmount(project *ProjectInfo, info *Info, tmp map[string]interface{}) {
 				if len(project.Package) > 0 {
 					//项目有多包
 					flag := false
-					for _, v := range project.Package{
+					for _, v := range project.Package {
 						v1, _ := v.([]map[string]interface{})
 						if len(v1) > 0 && v1[0]["name"] == info.ProjectName {
 							flag = true
@@ -1151,23 +1151,23 @@ func CountAmount(project *ProjectInfo, info *Info, tmp map[string]interface{}) {
 						project.Bidamount = project.Bidamount + info.Bidamount
 						project.Bidamounttag = 0
 					}
-				}else {
+				} else {
 					//项目没有多包
 					if info.Bidamount > 0 {
 						project.Bidamount = project.Bidamount + info.Bidamount
 						project.Bidamounttag = 0
-					}else if info.Bidamount == 0 && tmp["bidamount"] != nil {
+					} else if info.Bidamount == 0 && tmp["bidamount"] != nil {
 						project.Bidamounttag = 0
-					}else {
+					} else {
 						project.Bidamounttag = 1
 					}
 				}
-			}else {
+			} else {
 				if info.SubType == "中标" || info.SubType == "成交" {
 					if project.Bidamount < info.Bidamount {
 						project.Bidamount = info.Bidamount
 						project.Bidamounttag = 0
-					}else {
+					} else {
 						flag := false
 						if project.InfoFiled != nil && len(project.InfoFiled) > 0 {
 							for _, res := range project.InfoFiled {
@@ -1183,7 +1183,7 @@ func CountAmount(project *ProjectInfo, info *Info, tmp map[string]interface{}) {
 							if !flag {
 								project.Bidamount = project.Bidamount + info.Bidamount
 								project.Bidamounttag = 0
-							}else {
+							} else {
 								if project.Bidamount < info.Bidamount {
 									project.Bidamount = info.Bidamount
 									project.Bidamounttag = 0
@@ -1197,7 +1197,7 @@ func CountAmount(project *ProjectInfo, info *Info, tmp map[string]interface{}) {
 				}
 			}
 		}
-	}else {
+	} else {
 		project.Bidamounttag = 1
 	}
 

+ 46 - 21
fullproject/src_v1/task.go

@@ -58,9 +58,9 @@ type ProjectTask struct {
 	//当前时间
 	currentTime int64
 	//保存长度
-	saveSize  int
-	pici      int64
-	validTime int64
+	saveSize   int
+	pici       int64
+	validTime  int64
 	statusTime int64
 	//	LockPool     chan *sync.Mutex
 	//	LockPoolLock sync.Mutex
@@ -87,8 +87,8 @@ func NewPT() *ProjectTask {
 
 		//saveSign:   make(chan bool, 1),
 		//updateSign: make(chan bool, 1),
-		coll:      ProjectColl,
-		validTime: int64(util.IntAllDef(Sysconfig["validdays"], 150) * 86400),
+		coll:       ProjectColl,
+		validTime:  int64(util.IntAllDef(Sysconfig["validdays"], 150) * 86400),
 		statusTime: int64(util.IntAllDef(Sysconfig["statusdays"], 7) * 86400),
 	}
 	return p
@@ -96,6 +96,7 @@ func NewPT() *ProjectTask {
 
 var P_QL *ProjectTask
 var sp = make(chan bool, 5)
+
 //初始化全量合并对象
 func init() {
 	P_QL = NewPT()
@@ -143,9 +144,10 @@ func (p *ProjectTask) updateAllQueue() {
 func (p *ProjectTask) clearMem() {
 	c := cron.New()
 	//在内存中保留最近6个月的信息
-	//跑全量时每4分钟跑一次,跑增量时400分钟跑一次
-	_ = c.AddFunc("50 0/15 * * * *", func() {
-		if p.currentType == "ql" || p.clearContimes >= 60 {
+	//跑全量时每5分钟跑一次,跑增量时400分钟跑一次
+	_ = c.AddFunc("50 0/5 * * * *", func() {
+		if (p.currentType == "ql" && SingleClear == 0) || p.clearContimes >= 80 {
+			SingleClear = 1
 			//跳过的次数清零
 			p.clearContimes = 0
 			//信息进入查找对比全局锁
@@ -157,9 +159,15 @@ func (p *ProjectTask) clearMem() {
 			//所有内存中的项目信息
 			p.AllIdsMapLock.Lock()
 			p.mapHrefLock.Lock()
-
+			log.Println("清除开始")
 			//清除计数
 			clearNum := 0
+			for kHref, pid := range p.mapHref { //删除mapHref,p.AllIdsMap删除之前执行
+				v := p.AllIdsMap[pid]
+				if p.currentTime-v.P.LastTime > p.validTime {
+					delete(p.mapHref, kHref)
+				}
+			}
 			for k, v := range p.AllIdsMap {
 				if p.currentTime-v.P.LastTime > p.validTime {
 					clearNum++
@@ -170,7 +178,7 @@ func (p *ProjectTask) clearMem() {
 						ids := p.mapPb[v.P.Buyer]
 						if ids != nil {
 							ids.Lock.Lock()
-							ids.Arr = deleteSlice(ids.Arr, k)
+							ids.Arr = deleteSlice(ids.Arr, k, "pb")
 							if len(ids.Arr) == 0 {
 								delete(p.mapPb, v.P.Buyer)
 							}
@@ -183,7 +191,7 @@ func (p *ProjectTask) clearMem() {
 							ids := p.mapPn[vn]
 							if ids != nil {
 								ids.Lock.Lock()
-								ids.Arr = deleteSlice(ids.Arr, k)
+								ids.Arr = deleteSlice(ids.Arr, k, "pn")
 								if len(ids.Arr) == 0 {
 									delete(p.mapPn, vn)
 								}
@@ -197,7 +205,7 @@ func (p *ProjectTask) clearMem() {
 							ids := p.mapPc[vn]
 							if ids != nil {
 								ids.Lock.Lock()
-								ids.Arr = deleteSlice(ids.Arr, k)
+								ids.Arr = deleteSlice(ids.Arr, k, "pc")
 								if len(ids.Arr) == 0 {
 									delete(p.mapPc, vn)
 								}
@@ -205,17 +213,13 @@ func (p *ProjectTask) clearMem() {
 							}
 						}
 					}
-					for kHref, pid := range p.mapHref {
-						if pid == k {
-							delete(p.mapHref, kHref)
-						}
-					}
 					v = nil
 				}
 			}
 			p.mapHrefLock.Unlock()
 			p.AllIdsMapLock.Unlock()
 			p.findLock.Unlock()
+			SingleClear = 0
 			log.Println("清除完成:", clearNum, len(p.AllIdsMap), len(p.mapPn), len(p.mapPc), len(p.mapPb), len(p.mapHref))
 		} else {
 			p.clearContimes++
@@ -334,7 +338,7 @@ func (p *ProjectTask) taskUpdateInfo(udpInfo map[string]interface{}) {
 	if q == nil {
 		q = map[string]interface{}{
 			"_id": map[string]interface{}{
-				"$gte":  StringTOBsonId(gtid),
+				"$gte": StringTOBsonId(gtid),
 				"$lte": StringTOBsonId(lteid),
 			},
 			"is_m": 1,
@@ -416,6 +420,7 @@ func (p *ProjectTask) enter(db, coll string, q map[string]interface{}) {
 		ms.Hint(Sysconfig["hints"])
 	}
 	query := ms.Iter()
+	//query := sess.DB(db).C(coll).Find(q).Sort("publishtime").Iter()
 	var lastid interface{}
 L:
 	for {
@@ -591,6 +596,20 @@ func ParseInfo(tmp map[string]interface{}) (info *Info) {
 	thisinfo.LenPC = len([]rune(thisinfo.ProjectCode))
 	thisinfo.LenPTC = len([]rune(thisinfo.PTC))
 	thisinfo.LenPN = len([]rune(thisinfo.ProjectName))
+
+	//处理分包中数据异常问题
+	for k, tmp := range thisinfo.Package {
+		if ps, ok := tmp.([]map[string]interface{}); ok {
+			for i, p := range ps {
+				name, _ := p["name"].(string)
+				if len([]rune(name)) > 100 {
+					p["name"] = fmt.Sprint([]rune(name[:100]))
+				}
+				ps[i] = p
+			}
+			thisinfo.Package[k] = ps
+		}
+	}
 	return thisinfo
 }
 
@@ -718,7 +737,7 @@ func (p *ProjectTask) fillInPlace(tmp map[string]interface{}) {
 					tmp["city"] = site.City
 					tmp["district"] = site.District
 					return
-				}else if site.City == "" {
+				} else if site.City == "" {
 					return
 				}
 			}
@@ -732,10 +751,16 @@ func (p *ProjectTask) fillInPlace(tmp map[string]interface{}) {
 }
 
 //从数组中删除元素
-func deleteSlice(arr []string, v string) []string {
+func deleteSlice(arr []string, v, stype string) []string {
 	for k, v1 := range arr {
 		if v1 == v {
-			return append(arr[:k], arr[k+1:]...)
+			ts := time.Now().Unix()
+			arr = append(arr[:k], arr[k+1:]...)
+			rt := time.Now().Unix() - ts
+			if rt > 0 {
+				log.Println("deleteSlice", stype, rt, v, len(arr))
+			}
+			return arr
 		}
 	}
 	return arr