|
@@ -415,7 +415,7 @@ func (f *Front) SaveStep() {
|
|
param["code"] = (*one)["code"]
|
|
param["code"] = (*one)["code"]
|
|
//开发员关联任务修改爬虫状态
|
|
//开发员关联任务修改爬虫状态
|
|
state = qu.IntAll((*one)["state"])
|
|
state = qu.IntAll((*one)["state"])
|
|
- if auth == u.Role_Dev && state >= Sp_state_3 && restate != 1 { //开发员修改,已经审核通过(不包含已上架),状态重置为待完成(restate!=1判断,重采修改保存爬虫时不修改爬虫状态)
|
|
|
|
|
|
+ if auth == u.Role_Dev && state >= u.Sp_state_3 && restate != 1 { //开发员修改,已经审核通过(不包含已上架),状态重置为待完成(restate!=1判断,重采修改保存爬虫时不修改爬虫状态)
|
|
param["state"] = 0
|
|
param["state"] = 0
|
|
} else {
|
|
} else {
|
|
param["state"] = state
|
|
param["state"] = state
|
|
@@ -1451,14 +1451,14 @@ func (f *Front) BatchShelves() {
|
|
errCode := []string{}
|
|
errCode := []string{}
|
|
var err error
|
|
var err error
|
|
b := false
|
|
b := false
|
|
- if IsHasUpState(auth, Sp_state_5) {
|
|
|
|
|
|
+ if IsHasUpState(auth, u.Sp_state_5) {
|
|
if state == 5 { //批量上架
|
|
if state == 5 { //批量上架
|
|
for _, code := range codes {
|
|
for _, code := range codes {
|
|
if _, ok := u.CodeTimeCache.Get(code); ok { //避免短时间内重复上架
|
|
if _, ok := u.CodeTimeCache.Get(code); ok { //避免短时间内重复上架
|
|
errCode = append(errCode, code+"重复上架")
|
|
errCode = append(errCode, code+"重复上架")
|
|
} else {
|
|
} else {
|
|
u.CodeTimeCache.Set(code, "", time.Minute*2) //上架时,内存记录上架爬虫
|
|
u.CodeTimeCache.Set(code, "", time.Minute*2) //上架时,内存记录上架爬虫
|
|
- _, err = UpStateAndUpSpider(code, "", "", "", Sp_state_5)
|
|
|
|
|
|
+ _, err = UpStateAndUpSpider(code, "", "", "", u.Sp_state_5)
|
|
if err != nil {
|
|
if err != nil {
|
|
errCode = append(errCode, code)
|
|
errCode = append(errCode, code)
|
|
} else {
|
|
} else {
|
|
@@ -1468,7 +1468,7 @@ func (f *Front) BatchShelves() {
|
|
}
|
|
}
|
|
} else { //批量下架
|
|
} else { //批量下架
|
|
for _, code := range codes {
|
|
for _, code := range codes {
|
|
- b, err = UpStateAndUpSpider(code, "", "", "", Sp_state_6)
|
|
|
|
|
|
+ b, err = UpStateAndUpSpider(code, "", "", "", u.Sp_state_6)
|
|
if !b || err != nil {
|
|
if !b || err != nil {
|
|
errCode = append(errCode, code)
|
|
errCode = append(errCode, code)
|
|
}
|
|
}
|
|
@@ -1489,7 +1489,7 @@ func (f *Front) BatchShelves() {
|
|
func (f *Front) UpState() error {
|
|
func (f *Front) UpState() error {
|
|
username := f.GetSession("username").(string)
|
|
username := f.GetSession("username").(string)
|
|
code := f.GetString("code")
|
|
code := f.GetString("code")
|
|
- state, _ := f.GetInt("state")
|
|
|
|
|
|
+ state, _ := f.GetInteger("state")
|
|
id := f.GetString("taskId")
|
|
id := f.GetString("taskId")
|
|
reason := f.GetString("reason")
|
|
reason := f.GetString("reason")
|
|
auth := qu.IntAll(f.GetSession("auth"))
|
|
auth := qu.IntAll(f.GetSession("auth"))
|
|
@@ -1512,34 +1512,34 @@ func (f *Front) UpState() error {
|
|
xgTime = xgTimeTmp.Unix()
|
|
xgTime = xgTimeTmp.Unix()
|
|
}
|
|
}
|
|
f.DelSession(id)
|
|
f.DelSession(id)
|
|
- if IsHasUpState(auth, int(state)) {
|
|
|
|
- b, err := UpStateAndUpSpider(code, "", reason, username, int(state)) //更新爬虫状态
|
|
|
|
- if b && state == Sp_state_1 { //提交审核
|
|
|
|
|
|
+ if IsHasUpState(auth, state) {
|
|
|
|
+ b, err := UpStateAndUpSpider(code, "", reason, username, state) //更新爬虫状态
|
|
|
|
+ if b && state == u.Sp_state_1 { //提交审核
|
|
//有对应任务跳转提交记录页
|
|
//有对应任务跳转提交记录页
|
|
taskid = CheckTask(codeArr, 1)
|
|
taskid = CheckTask(codeArr, 1)
|
|
if len(taskid) > 0 {
|
|
if len(taskid) > 0 {
|
|
res["istotask"] = true
|
|
res["istotask"] = true
|
|
res["taskid"] = taskid[0]
|
|
res["taskid"] = taskid[0]
|
|
}
|
|
}
|
|
- } else if b && state == Sp_state_2 { //打回
|
|
|
|
|
|
+ } else if b && state == u.Sp_state_2 { //打回
|
|
taskid = CheckTask(codeArr, 2)
|
|
taskid = CheckTask(codeArr, 2)
|
|
if len(taskid) > 0 {
|
|
if len(taskid) > 0 {
|
|
//UpTaskState([]string{taskid}, 2) //修改状态
|
|
//UpTaskState([]string{taskid}, 2) //修改状态
|
|
UpTaskState(taskid, 2, "", int64(0)) //修改任务状态
|
|
UpTaskState(taskid, 2, "", int64(0)) //修改任务状态
|
|
SaveRemark(taskid, reason, username) //保存记录信息
|
|
SaveRemark(taskid, reason, username) //保存记录信息
|
|
}
|
|
}
|
|
- } else if b && state == Sp_state_3 { //审核通过
|
|
|
|
|
|
+ } else if b && state == u.Sp_state_3 { //审核通过
|
|
taskid = CheckTask(codeArr, 3)
|
|
taskid = CheckTask(codeArr, 3)
|
|
if len(taskid) > 0 {
|
|
if len(taskid) > 0 {
|
|
//UpTaskState([]string{taskid}, 3)
|
|
//UpTaskState([]string{taskid}, 3)
|
|
UpTaskState(taskid, 3, "", int64(0))
|
|
UpTaskState(taskid, 3, "", int64(0))
|
|
SaveRemark(taskid, "", username)
|
|
SaveRemark(taskid, "", username)
|
|
}
|
|
}
|
|
- } else if b && state == Sp_state_6 { //下架
|
|
|
|
|
|
+ } else if b && state == u.Sp_state_6 { //下架
|
|
//下架成功删除心跳数据
|
|
//下架成功删除心跳数据
|
|
flag := DelSpiderHeart(code)
|
|
flag := DelSpiderHeart(code)
|
|
log.Println(code, "---下架删除download数据:", flag)
|
|
log.Println(code, "---下架删除download数据:", flag)
|
|
- } else if b && state == Sp_state_7 { //反馈
|
|
|
|
|
|
+ } else if b && state == u.Sp_state_7 { //反馈
|
|
taskid = CheckTask(codeArr, 7)
|
|
taskid = CheckTask(codeArr, 7)
|
|
if len(taskid) > 0 {
|
|
if len(taskid) > 0 {
|
|
UpTaskState(taskid, 7, reason, xgTime)
|
|
UpTaskState(taskid, 7, reason, xgTime)
|
|
@@ -1587,16 +1587,16 @@ func UpStateAndUpSpider(code, id, reason, username string, state int) (bool, err
|
|
}
|
|
}
|
|
//oldstate := qu.IntAll(one["state"])
|
|
//oldstate := qu.IntAll(one["state"])
|
|
switch state {
|
|
switch state {
|
|
- case Sp_state_4, Sp_state_6: //作废、下架
|
|
|
|
|
|
+ case u.Sp_state_4, u.Sp_state_6: //作废、下架
|
|
// if oldstate == Sp_state_5 {
|
|
// if oldstate == Sp_state_5 {
|
|
// upresult = false
|
|
// upresult = false
|
|
// err = errors.New("已上架不允许作废")
|
|
// err = errors.New("已上架不允许作废")
|
|
// } else {
|
|
// } else {
|
|
// upresult = true
|
|
// upresult = true
|
|
// }
|
|
// }
|
|
- upresult, err = spider.UpdateSpiderByCodeState(code, fmt.Sprint(state), event) //下架
|
|
|
|
|
|
+ upresult, err = spider.UpdateSpiderByCodeState(code, "6", event) //下架
|
|
qu.Debug("下架:", upresult, code)
|
|
qu.Debug("下架:", upresult, code)
|
|
- case Sp_state_5: //上架(爬虫端在更新上架的时候为了更新内存中字段,采用先下架上架)
|
|
|
|
|
|
+ case u.Sp_state_5: //上架(爬虫端在更新上架的时候为了更新内存中字段,采用先下架上架)
|
|
if downevent := qu.IntAll((*one)["downevent"]); downevent != 0 { //爬虫开发修改爬虫节点,审核人员上架爬虫时,原来爬虫所在节点下架
|
|
if downevent := qu.IntAll((*one)["downevent"]); downevent != 0 { //爬虫开发修改爬虫节点,审核人员上架爬虫时,原来爬虫所在节点下架
|
|
upresult, err = spider.UpdateSpiderByCodeState(code, "6", downevent)
|
|
upresult, err = spider.UpdateSpiderByCodeState(code, "6", downevent)
|
|
qu.Debug(code, "下架历史节点:", downevent)
|
|
qu.Debug(code, "下架历史节点:", downevent)
|
|
@@ -1611,7 +1611,7 @@ func UpStateAndUpSpider(code, id, reason, username string, state int) (bool, err
|
|
upresult, err = spider.UpdateSpiderByCodeState(code, fmt.Sprint(state), event)
|
|
upresult, err = spider.UpdateSpiderByCodeState(code, fmt.Sprint(state), event)
|
|
qu.Debug("上架:", upresult, code, event)
|
|
qu.Debug("上架:", upresult, code, event)
|
|
}
|
|
}
|
|
- case Sp_state_3: //审核通过
|
|
|
|
|
|
+ case u.Sp_state_3: //审核通过
|
|
//校验爬虫三级页是否有附件下载方法
|
|
//校验爬虫三级页是否有附件下载方法
|
|
str_content := qu.ObjToString((*one)["str_content"])
|
|
str_content := qu.ObjToString((*one)["str_content"])
|
|
if !strings.Contains(str_content, "downloadFile") && !strings.Contains(str_content, "getFileAttachmentsArrayWithTag") {
|
|
if !strings.Contains(str_content, "downloadFile") && !strings.Contains(str_content, "getFileAttachmentsArrayWithTag") {
|
|
@@ -1640,14 +1640,14 @@ func UpStateAndUpSpider(code, id, reason, username string, state int) (bool, err
|
|
}
|
|
}
|
|
upresult = u.MgoEB.Update("luaconfig", map[string]interface{}{"code": code}, up, true, false)
|
|
upresult = u.MgoEB.Update("luaconfig", map[string]interface{}{"code": code}, up, true, false)
|
|
} else {
|
|
} else {
|
|
- if state == Sp_state_1 { //提交审核
|
|
|
|
|
|
+ if state == u.Sp_state_1 { //提交审核
|
|
upset["l_complete"] = time.Now().Unix()
|
|
upset["l_complete"] = time.Now().Unix()
|
|
upset["report"] = ""
|
|
upset["report"] = ""
|
|
- } else if state == Sp_state_7 { //反馈问题
|
|
|
|
|
|
+ } else if state == u.Sp_state_7 { //反馈问题
|
|
upset["report"] = reason
|
|
upset["report"] = reason
|
|
upset["state"] = 1 //反馈后爬虫改为待审核
|
|
upset["state"] = 1 //反馈后爬虫改为待审核
|
|
upset["l_complete"] = time.Now().Unix()
|
|
upset["l_complete"] = time.Now().Unix()
|
|
- } else if state == Sp_state_3 { //审核通过
|
|
|
|
|
|
+ } else if state == u.Sp_state_3 { //审核通过
|
|
if (*one)["event"] == nil {
|
|
if (*one)["event"] == nil {
|
|
upset["event"] = event
|
|
upset["event"] = event
|
|
//upset["modifytime"] = time.Now().Unix()
|
|
//upset["modifytime"] = time.Now().Unix()
|
|
@@ -1656,14 +1656,14 @@ func UpStateAndUpSpider(code, id, reason, username string, state int) (bool, err
|
|
upset["l_uploadtime"] = time.Now().Unix()
|
|
upset["l_uploadtime"] = time.Now().Unix()
|
|
UpdateSiteTask(code) //更新重点站点任务
|
|
UpdateSiteTask(code) //更新重点站点任务
|
|
UpdateLuaClaimtype(code, CLAIMTYPEHISTORY) //更新爬虫认领状态
|
|
UpdateLuaClaimtype(code, CLAIMTYPEHISTORY) //更新爬虫认领状态
|
|
- } else if state == Sp_state_2 { //打回原因
|
|
|
|
|
|
+ } else if state == u.Sp_state_2 { //打回原因
|
|
upset["reason"] = reason
|
|
upset["reason"] = reason
|
|
//清理机检结果
|
|
//清理机检结果
|
|
unset["check"] = ""
|
|
unset["check"] = ""
|
|
unset["checkok"] = ""
|
|
unset["checkok"] = ""
|
|
unset["checktime"] = ""
|
|
unset["checktime"] = ""
|
|
LuaCheckSaveLog(one) //保存机检日志
|
|
LuaCheckSaveLog(one) //保存机检日志
|
|
- } else if state == Sp_state_5 { //上架
|
|
|
|
|
|
+ } else if state == u.Sp_state_5 { //上架
|
|
upset["l_checktime"] = 0 //核对时间重置
|
|
upset["l_checktime"] = 0 //核对时间重置
|
|
//清理机检结果
|
|
//清理机检结果
|
|
unset["check"] = ""
|
|
unset["check"] = ""
|
|
@@ -1672,7 +1672,7 @@ func UpStateAndUpSpider(code, id, reason, username string, state int) (bool, err
|
|
LuaCheckSaveLog(one) //保存机检日志
|
|
LuaCheckSaveLog(one) //保存机检日志
|
|
LuaSaveLog(code, username, one, 1)
|
|
LuaSaveLog(code, username, one, 1)
|
|
go ModifyLogs_SaveCodeLogs(code, *one)
|
|
go ModifyLogs_SaveCodeLogs(code, *one)
|
|
- } else if state == Sp_state_4 { //作废,作废原因
|
|
|
|
|
|
+ } else if state == u.Sp_state_4 { //作废,作废原因
|
|
upset["disablereason"] = reason
|
|
upset["disablereason"] = reason
|
|
//upset["modifytime"] = time.Now().Unix()
|
|
//upset["modifytime"] = time.Now().Unix()
|
|
upset["l_uploadtime"] = time.Now().Unix() //l_complete爬虫完成时间
|
|
upset["l_uploadtime"] = time.Now().Unix() //l_complete爬虫完成时间
|
|
@@ -1686,9 +1686,9 @@ func UpStateAndUpSpider(code, id, reason, username string, state int) (bool, err
|
|
//upresult = u.MgoE.Update("luaconfig", map[string]interface{}{"code": code}, map[string]interface{}{"$set": upset}, false, false)
|
|
//upresult = u.MgoE.Update("luaconfig", map[string]interface{}{"code": code}, map[string]interface{}{"$set": upset}, false, false)
|
|
upresult = u.MgoEB.Update("luaconfig", map[string]interface{}{"code": code}, up, false, false)
|
|
upresult = u.MgoEB.Update("luaconfig", map[string]interface{}{"code": code}, up, false, false)
|
|
qu.Debug("提交日志:", code, upset, upresult)
|
|
qu.Debug("提交日志:", code, upset, upresult)
|
|
- if upresult && (state == Sp_state_2 || state == Sp_state_3) { //打回、审核记录日志
|
|
|
|
|
|
+ if upresult && (state == u.Sp_state_2 || state == u.Sp_state_3) { //打回、审核记录日志
|
|
types := "打回"
|
|
types := "打回"
|
|
- if state == Sp_state_3 {
|
|
|
|
|
|
+ if state == u.Sp_state_3 {
|
|
types = "审核"
|
|
types = "审核"
|
|
}
|
|
}
|
|
event := qu.IntAll((*one)["event"])
|
|
event := qu.IntAll((*one)["event"])
|
|
@@ -1706,7 +1706,7 @@ func UpStateAndUpSpider(code, id, reason, username string, state int) (bool, err
|
|
}
|
|
}
|
|
if !strings.HasSuffix(code, u.Bu) { //凡是以_bu结尾的爬虫一律不计入审核记录
|
|
if !strings.HasSuffix(code, u.Bu) { //凡是以_bu结尾的爬虫一律不计入审核记录
|
|
//新爬虫审核记录表
|
|
//新爬虫审核记录表
|
|
- if event == 7000 && (state == Sp_state_3 || state == Sp_state_2) {
|
|
|
|
|
|
+ if event == 7000 && (state == u.Sp_state_3 || state == u.Sp_state_2) {
|
|
count := u.MgoEB.Count("lua_logs_auditor", map[string]interface{}{"code": code, "types": "审核"})
|
|
count := u.MgoEB.Count("lua_logs_auditor", map[string]interface{}{"code": code, "types": "审核"})
|
|
if count == 0 { //新爬虫审核记录
|
|
if count == 0 { //新爬虫审核记录
|
|
u.MgoEB.Save("lua_logs_auditor_new", obj)
|
|
u.MgoEB.Save("lua_logs_auditor_new", obj)
|
|
@@ -1841,13 +1841,13 @@ func (f *Front) ChangeEvent() {
|
|
info, _ := u.MgoEB.FindOne("luaconfig", map[string]interface{}{"code": code})
|
|
info, _ := u.MgoEB.FindOne("luaconfig", map[string]interface{}{"code": code})
|
|
if len(*info) > 0 {
|
|
if len(*info) > 0 {
|
|
oldevent := qu.IntAll((*info)["event"])
|
|
oldevent := qu.IntAll((*info)["event"])
|
|
- if qu.IntAll((*info)["state"]) == Sp_state_5 {
|
|
|
|
|
|
+ if qu.IntAll((*info)["state"]) == u.Sp_state_5 {
|
|
//源节点下架
|
|
//源节点下架
|
|
- _, err := spider.UpdateSpiderByCodeState(code, fmt.Sprint(Sp_state_6), oldevent)
|
|
|
|
|
|
+ _, err := spider.UpdateSpiderByCodeState(code, fmt.Sprint(u.Sp_state_6), oldevent)
|
|
set := map[string]interface{}{
|
|
set := map[string]interface{}{
|
|
"$set": map[string]interface{}{
|
|
"$set": map[string]interface{}{
|
|
"event": qu.IntAll(event),
|
|
"event": qu.IntAll(event),
|
|
- "state": Sp_state_6,
|
|
|
|
|
|
+ "state": u.Sp_state_6,
|
|
},
|
|
},
|
|
}
|
|
}
|
|
//u.MgoE.Update("luaconfig", map[string]interface{}{"code": code}, set, true, false)
|
|
//u.MgoE.Update("luaconfig", map[string]interface{}{"code": code}, set, true, false)
|
|
@@ -1876,11 +1876,11 @@ func IsHasUpState(auth, state int) bool {
|
|
rep := false
|
|
rep := false
|
|
switch auth {
|
|
switch auth {
|
|
case u.Role_Dev:
|
|
case u.Role_Dev:
|
|
- if state == Sp_state_1 || state == Sp_state_7 {
|
|
|
|
|
|
+ if state == u.Sp_state_1 || state == u.Sp_state_7 {
|
|
rep = true
|
|
rep = true
|
|
}
|
|
}
|
|
case u.Role_Examine:
|
|
case u.Role_Examine:
|
|
- if state == Sp_state_2 || state == Sp_state_3 {
|
|
|
|
|
|
+ if state == u.Sp_state_2 || state == u.Sp_state_3 {
|
|
rep = true
|
|
rep = true
|
|
}
|
|
}
|
|
case u.Role_Admin:
|
|
case u.Role_Admin:
|
|
@@ -1928,7 +1928,7 @@ func (f *Front) MonitorCenter() {
|
|
} else {
|
|
} else {
|
|
q2 = map[string]interface{}{
|
|
q2 = map[string]interface{}{
|
|
"state": map[string]interface{}{
|
|
"state": map[string]interface{}{
|
|
- "$in": []int{Sp_state_3, Sp_state_5, Sp_state_6},
|
|
|
|
|
|
+ "$in": []int{u.Sp_state_3, u.Sp_state_5, u.Sp_state_6},
|
|
},
|
|
},
|
|
}
|
|
}
|
|
}
|
|
}
|