|
@@ -7,8 +7,9 @@ import (
|
|
|
"go.mongodb.org/mongo-driver/bson/primitive"
|
|
|
"mongodb"
|
|
|
qu "qfw/util"
|
|
|
- "strings"
|
|
|
+ "qfw/util/redis"
|
|
|
"time"
|
|
|
+ "udptask"
|
|
|
. "util"
|
|
|
)
|
|
|
|
|
@@ -91,11 +92,10 @@ func (l *Lua) SpiderEdit() {
|
|
|
l.T["summary"] = summary
|
|
|
qu.Debug("id:", id, " sha:", sha)
|
|
|
/*
|
|
|
- 1、如果field中出现一个以上字段表示spider_warn_err表在汇总spider_warn数据时出现一条数据多个异常信息(两个错误异常数据不可能是同条数据)
|
|
|
- 且该异常信息的原信息已经入bidding库,需要通过sha找bidding信息id
|
|
|
+ 1、异常类型为错误时,原信息未入bidding库
|
|
|
2、异常类型为警告时,原信息也已经入bidding库
|
|
|
*/
|
|
|
- if qu.IntAll((*one)["level"]) == 1 || len(strings.Split(qu.ObjToString((*one)["field"]), ",")) > 1 {
|
|
|
+ if qu.IntAll((*one)["level"]) == 1 {
|
|
|
bidData, _ := JYMgo.FindOne("bidding", map[string]interface{}{"s_sha": sha})
|
|
|
if bidData != nil && len(*bidData) > 0 {
|
|
|
bidId = mongodb.BsonIdToSId((*bidData)["_id"])
|
|
@@ -114,6 +114,7 @@ func (l *Lua) SpiderEdit() {
|
|
|
delete(data, "T")
|
|
|
delete(data, "publishdept")
|
|
|
delete(data, "l_np_publishtime")
|
|
|
+ //delete(data, "iscompete")
|
|
|
}
|
|
|
l.T["id"] = id //spider_warn_err id
|
|
|
l.T["bid"] = bidId //bidding id
|
|
@@ -129,7 +130,7 @@ func (l *Lua) SpiderSave() {
|
|
|
stype, _ := l.GetInteger("stype")
|
|
|
qu.Debug("id:", id, "stype:", stype)
|
|
|
if stype == 2 { //无需更新:只在spider_warn_err上打标记
|
|
|
- TagToSpiderWarnErr(stype, id, "无需修改", map[string]interface{}{})
|
|
|
+ TagToSpiderWarnErr(stype, id, "无需修改或发布", map[string]interface{}{})
|
|
|
success = true
|
|
|
} else {
|
|
|
bid := l.GetString("bid")
|
|
@@ -147,7 +148,7 @@ func (l *Lua) SpiderSave() {
|
|
|
}
|
|
|
if len(update) > 0 { //处理字段
|
|
|
for k, v := range update {
|
|
|
- if k == "extracttype" || k == "dataging" {
|
|
|
+ if k == "extracttype" || k == "dataging" || k == "infoformat" {
|
|
|
(update)[k] = qu.IntAll(v)
|
|
|
} else if k == "publishtime" || k == "bidopentime" {
|
|
|
(update)[k] = qu.Int64All(v)
|
|
@@ -183,12 +184,12 @@ func (l *Lua) SpiderSave() {
|
|
|
b := JYMgo.UpdateById("bidding", bid, map[string]interface{}{"$set": update}) //更新
|
|
|
if b { //更新成功 //更新成功 重生bidding索引 项目合并
|
|
|
qu.Debug("更新成功")
|
|
|
- //udptask.BiddingIndexUdp(bid, "bidding") //coll:bidding 是因为调用此方法的数据都是增量数据
|
|
|
- //if IsModifyPro(modifyinfo) { //修改了影响项目合并的字段 进行项目合并
|
|
|
- // udptask.ProjectSetUdp(bid, "bidding")
|
|
|
- //}
|
|
|
- //delName1 := RedisDelKey1 + bid + "_*"
|
|
|
- //redis.DelByCodePattern(RedisJYName, delName1)
|
|
|
+ udptask.BiddingIndexUdp(bid, "bidding") //coll:bidding 是因为调用此方法的数据都是增量数据
|
|
|
+ if IsModifyPro(modifyinfo) { //修改了影响项目合并的字段 进行项目合并
|
|
|
+ udptask.ProjectSetUdp(bid, "bidding")
|
|
|
+ }
|
|
|
+ delName1 := RedisDelKey1 + bid + "_*"
|
|
|
+ redis.DelByCodePattern(RedisJYName, delName1)
|
|
|
delete(update, "modifyinfo")
|
|
|
l.SaveUpdateLog(2, reasons, bid, *old_data, update, modifyinfo) //标签日志
|
|
|
TagToSpiderWarnErr(stype, id, reasons, update) //spider_warn_err日志
|
|
@@ -212,8 +213,10 @@ func (l *Lua) SpiderSave() {
|
|
|
} else if iscompete { //新爬虫
|
|
|
update["competehref"] = "#"
|
|
|
}
|
|
|
- PutHrefRedis(href, shaid, newSid) //添加href进redis
|
|
|
- update["comeintime"] = time.Now().Unix() //更新入库时间
|
|
|
+ delete(update, "iscompete")
|
|
|
+ update["comeintime"] = time.Now().Unix() //更新入库时间
|
|
|
+ update["modifyinfo"] = map[string]interface{}{} //添加空modifyinfo作为标识
|
|
|
+ PutHrefRedis(href, shaid, newSid) //添加href进redis
|
|
|
qu.Debug(update)
|
|
|
JYMgo.SaveByOriID("bidding", update) //入bidding
|
|
|
l.SaveUpdateLog(1, reasons, newSid, map[string]interface{}{}, update, map[string]interface{}{}) //标签日志
|