|
@@ -74,37 +74,66 @@ func (m runManager) RunColumnCron() {
|
|
|
|
|
|
func (m *runManager) RunDataSign(ctx context.Context) {
|
|
func (m *runManager) RunDataSign(ctx context.Context) {
|
|
st, et := eTime()
|
|
st, et := eTime()
|
|
- GetProjectSign(ctx, st, et)
|
|
|
|
- GetBidSign(ctx, st, et)
|
|
|
|
- return
|
|
|
|
|
|
+ GetProjectSign(ctx, st, et) //前一天拟建标签
|
|
|
|
+ GetBidSign(ctx, st, et) //前一天标讯标签
|
|
|
|
+ GetHotSign(ctx) //热门标签
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+// 热门标签统计
|
|
|
|
+func GetHotSign(ctx context.Context) {
|
|
|
|
+ var (
|
|
|
|
+ total, count int
|
|
|
|
+ )
|
|
|
|
+ //当天统计的新增热门数据
|
|
|
|
+ tm := time.Now()
|
|
|
|
+ htm := time.Date(tm.Year(), tm.Month(), tm.Day(), 0, 0, 0, 0, tm.Location())
|
|
|
|
+ data, ok := db.Mgo.Find(db.MongdbConf.Collection_hot, map[string]interface{}{
|
|
|
|
+ "createtime": map[string]interface{}{
|
|
|
|
+ "$gte": htm.Unix(),
|
|
|
|
+ },
|
|
|
|
+ }, "", "bidding_id", false, -1, -1)
|
|
|
|
+ if ok && len(*data) > 0 {
|
|
|
|
+ var ids []string
|
|
|
|
+ total = len(*data) - 1
|
|
|
|
+ for k, m := range *data {
|
|
|
|
+ ids = append(ids, fmt.Sprintf(`'%s'`, gconv.String(m["bidding_id"])))
|
|
|
|
+ if len(ids) == 100 || (k == total && len(ids) > 0) {
|
|
|
|
+ count += SaveHotSign(ctx, ids)
|
|
|
|
+ ids = []string{}
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ g.Log().Infof(ctx, "GetHotSign date :%s 总需插入%d, 实际加载%d条数据", time.Now().String(), total+1, count)
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
// 项目标签统计
|
|
// 项目标签统计
|
|
func GetProjectSign(ctx context.Context, st, et int64) {
|
|
func GetProjectSign(ctx context.Context, st, et int64) {
|
|
- sess := db.Mgo.GetMgoConn()
|
|
|
|
- defer db.Mgo.DestoryMongoConn(sess)
|
|
|
|
|
|
+ sess := db.ProposedMgo.GetMgoConn()
|
|
|
|
+ defer db.ProposedMgo.DestoryMongoConn(sess)
|
|
query := bson.M{
|
|
query := bson.M{
|
|
"nav_column": bson.M{"$exists": true},
|
|
"nav_column": bson.M{"$exists": true},
|
|
- "pici": bson.M{"$gt": st, "$lte": et},
|
|
|
|
|
|
+ "pici": bson.M{"$gte": st, "$lte": et},
|
|
}
|
|
}
|
|
- g.Log().Infof(ctx, "开始加载执行RunProjectSign:time:%v query:%v", time.Now(), query)
|
|
|
|
- it := sess.DB(db.MongdbConf.DbName).C(db.MongdbConf.Projectset_proposed).Find(query).Select(map[string]interface{}{
|
|
|
|
|
|
+ it := sess.DB(db.ProposedMgoConf.DbName).C(db.ProposedMgoConf.Collection).Find(query).Select(map[string]interface{}{
|
|
"_id": 1,
|
|
"_id": 1,
|
|
"nature_code": 1,
|
|
"nature_code": 1,
|
|
"ownerclass_code": 1,
|
|
"ownerclass_code": 1,
|
|
"category_code": 1,
|
|
"category_code": 1,
|
|
"projectname": 1,
|
|
"projectname": 1,
|
|
"nav_column": 1,
|
|
"nav_column": 1,
|
|
- "lasttime": 1,
|
|
|
|
|
|
+ "firsttime": 1,
|
|
}).Iter()
|
|
}).Iter()
|
|
var (
|
|
var (
|
|
projectSignArr []*ProjectSign
|
|
projectSignArr []*ProjectSign
|
|
|
|
+ total int
|
|
)
|
|
)
|
|
row := map[string]interface{}{}
|
|
row := map[string]interface{}{}
|
|
for it.Next(&row) {
|
|
for it.Next(&row) {
|
|
if row["nav_column"] == nil || gconv.Int(row["nav_column"]) == 0 {
|
|
if row["nav_column"] == nil || gconv.Int(row["nav_column"]) == 0 {
|
|
|
|
+ row = map[string]interface{}{}
|
|
continue
|
|
continue
|
|
}
|
|
}
|
|
|
|
+ total++
|
|
cMap := gconv.Map(gutil.Copy(row))
|
|
cMap := gconv.Map(gutil.Copy(row))
|
|
bs := &ProjectSign{
|
|
bs := &ProjectSign{
|
|
Bid_id: mongodb.BsonIdToSId(cMap["_id"]),
|
|
Bid_id: mongodb.BsonIdToSId(cMap["_id"]),
|
|
@@ -113,7 +142,7 @@ func GetProjectSign(ctx context.Context, st, et int64) {
|
|
Ownerclass: gconv.String(cMap["ownerclass_code"]),
|
|
Ownerclass: gconv.String(cMap["ownerclass_code"]),
|
|
Category: gconv.String(cMap["category_code"]),
|
|
Category: gconv.String(cMap["category_code"]),
|
|
Sign: convertToBitmap(gconv.Int(cMap["nav_column"])),
|
|
Sign: convertToBitmap(gconv.Int(cMap["nav_column"])),
|
|
- Publish_time: time.Unix(gconv.Int64(cMap["lasttime"]), 0),
|
|
|
|
|
|
+ Publish_time: time.Unix(gconv.Int64(cMap["firsttime"]), 0),
|
|
}
|
|
}
|
|
projectSignArr = append(projectSignArr, bs)
|
|
projectSignArr = append(projectSignArr, bs)
|
|
if len(projectSignArr) > 100 {
|
|
if len(projectSignArr) > 100 {
|
|
@@ -125,6 +154,7 @@ func GetProjectSign(ctx context.Context, st, et int64) {
|
|
if len(projectSignArr) > 0 {
|
|
if len(projectSignArr) > 0 {
|
|
SaveProjectSign(ctx, projectSignArr)
|
|
SaveProjectSign(ctx, projectSignArr)
|
|
}
|
|
}
|
|
|
|
+ g.Log().Infof(ctx, "GetProjectSign date :%s 总加载%d条数据", time.Now().String(), total)
|
|
}
|
|
}
|
|
|
|
|
|
// 标讯标签统计
|
|
// 标讯标签统计
|
|
@@ -134,9 +164,8 @@ func GetBidSign(ctx context.Context, st, et int64) {
|
|
defer db.Mgo.DestoryMongoConn(sess)
|
|
defer db.Mgo.DestoryMongoConn(sess)
|
|
query := bson.M{
|
|
query := bson.M{
|
|
"nav_column": bson.M{"$exists": true},
|
|
"nav_column": bson.M{"$exists": true},
|
|
- "pici": bson.M{"$gt": st, "$lte": et},
|
|
|
|
|
|
+ "pici": bson.M{"$gte": st, "$lte": et},
|
|
}
|
|
}
|
|
- g.Log().Infof(ctx, "开始加载执行RunProjectSign:time:%v query:%v", time.Now(), query)
|
|
|
|
it := sess.DB(db.MongdbConf.DbName).C(db.MongdbConf.Collection).Find(query).Select(map[string]interface{}{
|
|
it := sess.DB(db.MongdbConf.DbName).C(db.MongdbConf.Collection).Find(query).Select(map[string]interface{}{
|
|
"_id": 1,
|
|
"_id": 1,
|
|
"nature_code": 1,
|
|
"nature_code": 1,
|
|
@@ -148,10 +177,12 @@ func GetBidSign(ctx context.Context, st, et int64) {
|
|
}).Iter()
|
|
}).Iter()
|
|
var (
|
|
var (
|
|
bidSignArr []*BidSign
|
|
bidSignArr []*BidSign
|
|
|
|
+ total int
|
|
)
|
|
)
|
|
row := map[string]interface{}{}
|
|
row := map[string]interface{}{}
|
|
for it.Next(&row) {
|
|
for it.Next(&row) {
|
|
if row["nav_column"] == nil || gconv.Int(row["nav_column"]) == 0 || !(*bidListId)[mongodb.BsonIdToSId(row["_id"])] {
|
|
if row["nav_column"] == nil || gconv.Int(row["nav_column"]) == 0 || !(*bidListId)[mongodb.BsonIdToSId(row["_id"])] {
|
|
|
|
+ row = map[string]interface{}{}
|
|
continue
|
|
continue
|
|
}
|
|
}
|
|
cMap := gconv.Map(gutil.Copy(row))
|
|
cMap := gconv.Map(gutil.Copy(row))
|
|
@@ -162,6 +193,7 @@ func GetBidSign(ctx context.Context, st, et int64) {
|
|
Sign: convertToBitmap(gconv.Int(cMap["nav_column"])),
|
|
Sign: convertToBitmap(gconv.Int(cMap["nav_column"])),
|
|
Publish_time: time.Unix(gconv.Int64(cMap["publishtime"]), 0),
|
|
Publish_time: time.Unix(gconv.Int64(cMap["publishtime"]), 0),
|
|
}
|
|
}
|
|
|
|
+ total++
|
|
bidSignArr = append(bidSignArr, bs)
|
|
bidSignArr = append(bidSignArr, bs)
|
|
if len(bidSignArr) > 100 {
|
|
if len(bidSignArr) > 100 {
|
|
SaveBidSign(ctx, bidSignArr)
|
|
SaveBidSign(ctx, bidSignArr)
|
|
@@ -172,6 +204,7 @@ func GetBidSign(ctx context.Context, st, et int64) {
|
|
if len(bidSignArr) > 0 {
|
|
if len(bidSignArr) > 0 {
|
|
SaveBidSign(ctx, bidSignArr)
|
|
SaveBidSign(ctx, bidSignArr)
|
|
}
|
|
}
|
|
|
|
+ g.Log().Infof(ctx, "GetBidSign date :%s 总加载%d条数据", time.Now().String(), total)
|
|
}
|
|
}
|
|
|
|
|
|
func getNewBidList(ctx context.Context) *map[string]bool {
|
|
func getNewBidList(ctx context.Context) *map[string]bool {
|
|
@@ -248,6 +281,7 @@ func (m *runManager) RunColumnData(ctx context.Context) {
|
|
)
|
|
)
|
|
for it.Next(&row) {
|
|
for it.Next(&row) {
|
|
if gconv.Int(row["extracttype"]) == -1 {
|
|
if gconv.Int(row["extracttype"]) == -1 {
|
|
|
|
+ row = map[string]interface{}{}
|
|
continue
|
|
continue
|
|
}
|
|
}
|
|
cMap := gconv.Map(gutil.Copy(row))
|
|
cMap := gconv.Map(gutil.Copy(row))
|
|
@@ -265,7 +299,8 @@ func (m *runManager) RunColumnData(ctx context.Context) {
|
|
Subtype: gconv.String(cMap["subtype"]),
|
|
Subtype: gconv.String(cMap["subtype"]),
|
|
Publish_time: gconv.Int64(cMap["publishtime"]),
|
|
Publish_time: gconv.Int64(cMap["publishtime"]),
|
|
}
|
|
}
|
|
- if msg.IsColumnEmpty() {
|
|
|
|
|
|
+ if msg.IsColumnEmpty() || !(*bidListId)[msg.Bid_id] {
|
|
|
|
+ row = map[string]interface{}{}
|
|
continue
|
|
continue
|
|
}
|
|
}
|
|
if subs := gconv.String(cMap["s_subscopeclass"]); subs != "" {
|
|
if subs := gconv.String(cMap["s_subscopeclass"]); subs != "" {
|
|
@@ -275,7 +310,7 @@ func (m *runManager) RunColumnData(ctx context.Context) {
|
|
msg.Class2 = classArr[1]
|
|
msg.Class2 = classArr[1]
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- d := JobPkg.Match(msg, bidListId)
|
|
|
|
|
|
+ d := JobPkg.Match(msg)
|
|
if d != nil {
|
|
if d != nil {
|
|
total++
|
|
total++
|
|
dataArr = append(dataArr, *d)
|
|
dataArr = append(dataArr, *d)
|
|
@@ -294,7 +329,10 @@ func (m *runManager) RunColumnData(ctx context.Context) {
|
|
if len(dataArr) > 0 {
|
|
if len(dataArr) > 0 {
|
|
g.DB().Insert(ctx, JobPkg.tableName, dataArr)
|
|
g.DB().Insert(ctx, JobPkg.tableName, dataArr)
|
|
}
|
|
}
|
|
- g.Log().Infof(ctx, "总加载%d条数据 pici %v 插入条数:%d query :%v", total, lastId, len(TitleRemoval), query)
|
|
|
|
|
|
+ if StartSeoId > 0 {
|
|
|
|
+ g.Redis("other").Set(context.Background(), SeoRedisKey, StartSeoId)
|
|
|
|
+ }
|
|
|
|
+ g.Log().Infof(ctx, "总加载%d条数据 pici %v 插入条数:%d StartSeoId:%d query :%v", total, lastId, len(TitleRemoval), StartSeoId, query)
|
|
}
|
|
}
|
|
|
|
|
|
type ProjectSign struct {
|
|
type ProjectSign struct {
|