Ver código fonte

first commit

maxiaoshan 4 anos atrás
commit
e8e07770d7
12 arquivos alterados com 1895 adições e 0 exclusões
  1. 1 0
      src/code.go
  2. 35 0
      src/config.json
  3. 173 0
      src/downloadnum.go
  4. 488 0
      src/logs/task.log
  5. BIN
      src/luatask_new.exe
  6. 81 0
      src/main.go
  7. 13 0
      src/readme.txt
  8. 946 0
      src/task.go
  9. 6 0
      src/user.json
  10. 33 0
      src/util.go
  11. 103 0
      src/work.go
  12. 16 0
      src/worktime.json

+ 1 - 0
src/code.go

@@ -0,0 +1 @@
+package main

+ 35 - 0
src/config.json

@@ -0,0 +1,35 @@
+{
+	"spider":{
+    	"addr": "192.168.3.207:27092",
+		"db": "spider",
+		"size": 10
+    },
+    "editor": {
+    	"addr": "192.168.3.207:27092",
+		"db": "editor",
+		"size": 10
+    },
+    "everydaydownload": "0 0 1 ? * MON-FRI",
+    "updatestatecron": "0 0 6 ? * *",
+	"createtaskcron": "0 0 8 ? * MON-FRI",
+	"closetaskcron": "0 0 9 ? * MON-FRI",
+	"closenum": 2,
+	"daynum": 6,
+	"downloadcheck": {
+        "rule": {
+            "spidercode": [
+                "a_zgzfcgw_dfgg_new",
+				"a_gjggzyjypt_qt"
+            ],
+            "downratio": 10,
+            "upratio": 10
+        },
+        "other": {
+            "spidercode": [
+                
+            ],
+            "downratio": 40,
+            "upratio": 300
+        }
+    }
+}

+ 173 - 0
src/downloadnum.go

@@ -0,0 +1,173 @@
+package main
+
+import (
+	"math"
+	qu "qfw/util"
+	"strconv"
+	"strings"
+	"sync"
+	"time"
+
+	"github.com/donnie4w/go-logger/logger"
+)
+
+var (
+	EveryDayDownloadTime string //每天统计下载量的时间
+	DownloadCheck        map[string]*DC
+)
+
+type DC struct {
+	DownRatio float64 //下浮比例
+	UpRatio   float64 //上浮比例
+}
+
+//统计工作日(除周六周日)爬虫每天的下载量,并更新
+func GetDownloadNumber() {
+	defer qu.Catch()
+	logger.Debug("---统计爬虫每日下载量---")
+	defer func() {
+		logger.Debug("---统计爬虫每日下载量完毕---")
+	}()
+	weekDay := time.Now().Weekday().String()
+	if weekDay != "Saturday" && weekDay != "Sunday" { //周二至周五统计前一天的下载量,周一统计上周五的数据
+		yesterday := -1
+		if weekDay == "Monday" {
+			yesterday = -3
+		}
+		timeStr := time.Now().AddDate(0, 0, yesterday).Format("2006-01-02")
+		startTime := GetTime(yesterday)
+		endTime := startTime + 86400
+		spiders := getAllSpider() //获取所有爬虫
+		logger.Debug(timeStr, "上架的爬虫个数:", len(spiders))
+		lock := &sync.Mutex{}
+		wg := &sync.WaitGroup{}
+		ch := make(chan bool, 3)
+		arr := [][]map[string]interface{}{}
+		for code, reps := range spiders {
+			ch <- true
+			wg.Add(1)
+			go func(code string, reps map[string]interface{}) {
+				defer func() {
+					<-ch
+					wg.Done()
+				}()
+				update := []map[string]interface{}{}
+				update = append(update, map[string]interface{}{"code": code})
+				num := MgoS.Count("data_bak", map[string]interface{}{ //统计某个爬虫上个工作日的采集量
+					"spidercode": code,
+					"l_np_publishtime": map[string]interface{}{
+						"$gte": startTime,
+						"$lte": endTime,
+					}})
+				logger.Debug(code, timeStr+"下载量:", num)
+				numStr := strconv.Itoa(num) //数量字符串
+				//将下载量存库
+				data, _ := MgoS.FindOne("spider_download", map[string]interface{}{"code": code})
+				if data != nil && len(*data) > 0 { //已有爬虫下载量信息
+					timeAndNum := qu.ObjArrToStringArr((*data)["timeAndNum"].([]interface{}))
+					if len(timeAndNum) >= 15 { //只统计15天的量,超过15天去除第一个
+						timeAndNum = timeAndNum[1:]
+					}
+					timeAndNum = append(timeAndNum, timeStr+":"+numStr)
+					i := 0
+					y := 0
+					for _, tn := range timeAndNum {
+						nStr := strings.Split(tn, ":")[1]
+						nInt, _ := strconv.Atoi(nStr)
+						if nInt > 0 || y > 0 { //不统计下载量大于0之前的数据
+							y++
+							i += nInt
+						}
+					}
+					avFlush := float64(0)
+					if y > 0 { //不全为0
+						iF, _ := strconv.ParseFloat(strconv.Itoa(i), 64)
+						yF, _ := strconv.ParseFloat(strconv.Itoa(y), 64)
+						avFlush = math.Ceil(iF / yF) //平均值()向上取整
+					}
+					//根据浮动和平均值计算范围值
+					dr, ur := float64(0), float64(0)
+					if DownloadCheck[code] == nil {
+						dr = DownloadCheck["other"].DownRatio
+						ur = DownloadCheck["other"].UpRatio
+					} else {
+						dr = DownloadCheck[code].DownRatio
+						ur = DownloadCheck[code].UpRatio
+					}
+					min := dr * avFlush
+					max := ur * avFlush
+					numerr := float64(num) >= min && float64(num) <= max //超出范围
+					update = append(update, map[string]interface{}{
+						"$set": map[string]interface{}{
+							"timeAndNum":      timeAndNum,                   //时间下载量集合
+							"downloadNum":     map[string]int{timeStr: num}, //前一天下载量
+							"averageDownload": avFlush,                      //平均值
+							"isok":            numerr,                       //下载量是否异常
+							"min":             min,                          //采集量下限
+							"max":             max,                          //采集量上限
+							"updatetime":      time.Now().Unix(),            //更新时间
+						},
+					})
+				} else { //新增信息
+					numF, _ := strconv.ParseFloat(strconv.Itoa(num), 64)
+					update = append(update, map[string]interface{}{
+						"$set": map[string]interface{}{
+							"timeAndNum":      []string{timeStr + ":" + numStr},
+							"code":            code,
+							"averageDownload": numF,
+							"downloadNum":     map[string]int{timeStr: num},
+							"isok":            true,
+							"site":            reps["s_site"],
+							"channel":         reps["s_channel"],
+							"comeintime":      time.Now().Unix(),
+						},
+					})
+				}
+				lock.Lock()
+				if len(update) == 2 {
+					arr = append(arr, update)
+				}
+				if len(arr) > 500 {
+					tmps := arr
+					MgoS.UpSertBulk("spider_download", tmps...)
+					arr = [][]map[string]interface{}{}
+				}
+				lock.Unlock()
+			}(code, reps)
+		}
+		wg.Wait()
+		lock.Lock()
+		if len(arr) > 0 {
+			MgoS.UpSertBulk("spider_download", arr...)
+			arr = [][]map[string]interface{}{}
+		}
+		lock.Unlock()
+	} else {
+		return
+	}
+}
+
+//获取所有爬虫
+func getAllSpider() map[string]map[string]interface{} {
+	fields := map[string]interface{}{
+		"code":         1,
+		"param_common": 1,
+	}
+	luas, _ := MgoE.Find("luaconfig", map[string]interface{}{"state": 5}, nil, fields, false, -1, -1)
+	reps := map[string]map[string]interface{}{}
+	for _, lua := range *luas {
+		rep := map[string]interface{}{}
+		code := qu.ObjToString(lua["code"])
+		rep["s_code"] = code
+		if param_common, ok := lua["param_common"].([]interface{}); ok {
+			rep["s_site"] = param_common[1]
+			if len(param_common) > 2 {
+				rep["s_channel"] = param_common[2]
+			} else {
+				rep["s_channel"] = ""
+			}
+		}
+		reps[code] = rep
+	}
+	return reps
+}

+ 488 - 0
src/logs/task.log

@@ -0,0 +1,488 @@
+2021/04/19 10:55:11 task.go:44: debug  ---开始统计重采失败信息---
+2021/04/19 10:55:11 task.go:125: debug  ---统计重采失败信息完成---
+2021/04/19 11:00:54 task.go:44: debug  ---开始统计重采失败信息---
+2021/04/19 11:00:54 task.go:125: debug  ---统计重采失败信息完成---
+2021/04/19 11:01:32 task.go:44: debug  ---开始统计重采失败信息---
+2021/04/19 11:05:39 task.go:44: debug  ---开始统计重采失败信息---
+2021/04/19 11:05:56 task.go:44: debug  ---开始统计重采失败信息---
+2021/04/19 11:06:18 task.go:44: debug  ---开始统计重采失败信息---
+2021/04/19 11:06:18 task.go:131: debug  ---统计重采失败信息完成---
+2021/04/19 11:07:29 task.go:44: debug  ---开始统计重采失败信息---
+2021/04/19 11:07:29 task.go:131: debug  ---统计重采失败信息完成---
+2021/04/19 11:07:45 task.go:44: debug  ---开始统计重采失败信息---
+2021/04/19 11:07:45 task.go:131: debug  ---统计重采失败信息完成---
+2021/04/19 11:09:25 task.go:44: debug  ---开始统计重采失败信息---
+2021/04/19 11:09:25 task.go:131: debug  ---统计重采失败信息完成---
+2021/04/19 13:56:41 task.go:45: debug  ---开始统计重采失败信息---
+2021/04/19 13:56:42 task.go:132: debug  ---统计重采失败信息完成---
+2021/04/19 13:56:42 task.go:138: debug  ---开始统计下载失败信息---
+2021/04/19 13:56:42 task.go:252: debug  ---统计下载失败信息完成---
+2021/04/19 13:59:52 task.go:45: debug  ---开始统计重采失败信息---
+2021/04/19 13:59:53 task.go:132: debug  ---统计重采失败信息完成---
+2021/04/19 13:59:53 task.go:138: debug  ---开始统计下载失败信息---
+2021/04/19 13:59:53 task.go:252: debug  ---统计下载失败信息完成---
+2021/04/19 14:00:17 task.go:45: debug  ---开始统计重采失败信息---
+2021/04/19 14:00:17 task.go:132: debug  ---统计重采失败信息完成---
+2021/04/19 14:00:17 task.go:138: debug  ---开始统计下载失败信息---
+2021/04/19 14:00:17 task.go:252: debug  ---统计下载失败信息完成---
+2021/04/19 14:00:34 task.go:45: debug  ---开始统计重采失败信息---
+2021/04/19 14:00:34 task.go:132: debug  ---统计重采失败信息完成---
+2021/04/19 14:00:34 task.go:138: debug  ---开始统计下载失败信息---
+2021/04/19 14:00:34 task.go:252: debug  ---统计下载失败信息完成---
+2021/04/19 14:00:52 task.go:45: debug  ---开始统计重采失败信息---
+2021/04/19 14:00:52 task.go:132: debug  ---统计重采失败信息完成---
+2021/04/19 14:00:52 task.go:138: debug  ---开始统计下载失败信息---
+2021/04/19 14:00:52 task.go:252: debug  ---统计下载失败信息完成---
+2021/04/19 14:01:19 task.go:45: debug  ---开始统计重采失败信息---
+2021/04/19 14:01:19 task.go:132: debug  ---统计重采失败信息完成---
+2021/04/19 14:01:19 task.go:138: debug  ---开始统计下载失败信息---
+2021/04/19 14:01:19 task.go:252: debug  ---统计下载失败信息完成---
+2021/04/19 14:02:08 task.go:45: debug  ---开始统计重采失败信息---
+2021/04/19 14:02:08 task.go:132: debug  ---统计重采失败信息完成---
+2021/04/19 14:02:08 task.go:138: debug  ---开始统计下载失败信息---
+2021/04/19 14:02:08 task.go:252: debug  ---统计下载失败信息完成---
+2021/04/19 14:02:17 task.go:45: debug  ---开始统计重采失败信息---
+2021/04/19 14:02:17 task.go:132: debug  ---统计重采失败信息完成---
+2021/04/19 14:02:17 task.go:138: debug  ---开始统计下载失败信息---
+2021/04/19 14:02:18 task.go:252: debug  ---统计下载失败信息完成---
+2021/04/19 14:02:21 task.go:45: debug  ---开始统计重采失败信息---
+2021/04/19 14:02:22 task.go:132: debug  ---统计重采失败信息完成---
+2021/04/19 14:02:22 task.go:138: debug  ---开始统计下载失败信息---
+2021/04/19 14:02:22 task.go:252: debug  ---统计下载失败信息完成---
+2021/04/19 14:03:46 task.go:45: debug  ---开始统计重采失败信息---
+2021/04/19 14:03:46 task.go:132: debug  ---统计重采失败信息完成---
+2021/04/19 14:03:46 task.go:138: debug  ---开始统计下载失败信息---
+2021/04/19 14:03:46 task.go:252: debug  ---统计下载失败信息完成---
+2021/04/19 14:03:58 task.go:45: debug  ---开始统计重采失败信息---
+2021/04/19 14:03:58 task.go:132: debug  ---统计重采失败信息完成---
+2021/04/19 14:03:58 task.go:138: debug  ---开始统计下载失败信息---
+2021/04/19 14:03:58 task.go:252: debug  ---统计下载失败信息完成---
+2021/04/19 14:04:12 task.go:45: debug  ---开始统计重采失败信息---
+2021/04/19 14:04:14 task.go:132: debug  ---统计重采失败信息完成---
+2021/04/19 14:04:14 task.go:138: debug  ---开始统计下载失败信息---
+2021/04/19 14:04:14 task.go:252: debug  ---统计下载失败信息完成---
+2021/04/19 14:04:20 task.go:45: debug  ---开始统计重采失败信息---
+2021/04/19 14:04:21 task.go:132: debug  ---统计重采失败信息完成---
+2021/04/19 14:04:21 task.go:138: debug  ---开始统计下载失败信息---
+2021/04/19 14:04:21 task.go:252: debug  ---统计下载失败信息完成---
+2021/04/19 14:16:45 task.go:45: debug  ---开始统计重采失败信息---
+2021/04/19 14:18:19 task.go:45: debug  ---开始统计重采失败信息---
+2021/04/19 14:18:20 task.go:135: debug  ---统计重采失败信息完成---
+2021/04/19 14:18:20 task.go:141: debug  ---开始统计下载失败信息---
+2021/04/19 14:18:20 task.go:255: debug  ---统计下载失败信息完成---
+2021/04/19 14:27:56 task.go:45: debug  ---开始统计重采失败信息---
+2021/04/19 14:27:56 task.go:135: debug  ---统计重采失败信息完成---
+2021/04/19 14:27:56 task.go:141: debug  ---开始统计下载失败信息---
+2021/04/19 14:27:56 task.go:255: debug  ---统计下载失败信息完成---
+2021/04/19 14:28:06 task.go:45: debug  ---开始统计重采失败信息---
+2021/04/19 14:28:06 task.go:135: debug  ---统计重采失败信息完成---
+2021/04/19 14:28:06 task.go:141: debug  ---开始统计下载失败信息---
+2021/04/19 14:28:06 task.go:255: debug  ---统计下载失败信息完成---
+2021/04/19 14:35:12 task.go:45: debug  ---开始统计重采失败信息---
+2021/04/19 14:35:15 task.go:136: debug  ---统计重采失败信息完成---
+2021/04/19 14:35:15 task.go:142: debug  ---开始统计下载失败信息---
+2021/04/19 14:35:16 task.go:256: debug  ---统计下载失败信息完成---
+2021/04/19 14:57:50 task.go:45: debug  ---开始统计重采失败信息---
+2021/04/19 14:57:50 task.go:136: debug  ---统计重采失败信息完成---
+2021/04/19 14:57:50 task.go:142: debug  ---开始统计下载失败信息---
+2021/04/19 14:57:50 task.go:256: debug  ---统计下载失败信息完成---
+2021/04/19 15:14:43 task.go:44: debug  ---开始统计重采失败信息---
+2021/04/19 15:14:44 task.go:127: debug  ---统计重采失败信息完成---
+2021/04/19 15:14:44 task.go:133: debug  ---开始统计下载失败信息---
+2021/04/19 15:14:44 task.go:241: debug  ---统计下载失败信息完成---
+2021/04/19 15:14:57 task.go:44: debug  ---开始统计重采失败信息---
+2021/04/19 15:14:57 task.go:127: debug  ---统计重采失败信息完成---
+2021/04/19 15:14:57 task.go:133: debug  ---开始统计下载失败信息---
+2021/04/19 15:14:57 task.go:241: debug  ---统计下载失败信息完成---
+2021/04/19 15:15:05 task.go:44: debug  ---开始统计重采失败信息---
+2021/04/19 15:15:05 task.go:127: debug  ---统计重采失败信息完成---
+2021/04/19 15:15:05 task.go:133: debug  ---开始统计下载失败信息---
+2021/04/19 15:15:05 task.go:241: debug  ---统计下载失败信息完成---
+2021/04/19 15:15:18 task.go:44: debug  ---开始统计重采失败信息---
+2021/04/19 15:15:18 task.go:127: debug  ---统计重采失败信息完成---
+2021/04/19 15:15:18 task.go:133: debug  ---开始统计下载失败信息---
+2021/04/19 15:15:18 task.go:241: debug  ---统计下载失败信息完成---
+2021/04/19 15:16:53 task.go:44: debug  ---开始统计重采失败信息---
+2021/04/19 15:16:55 task.go:127: debug  ---统计重采失败信息完成---
+2021/04/19 15:16:55 task.go:133: debug  ---开始统计下载失败信息---
+2021/04/19 15:16:56 task.go:241: debug  ---统计下载失败信息完成---
+2021/04/19 15:17:48 task.go:44: debug  ---开始统计重采失败信息---
+2021/04/19 15:17:48 task.go:127: debug  ---统计重采失败信息完成---
+2021/04/19 15:17:48 task.go:133: debug  ---开始统计下载失败信息---
+2021/04/19 15:17:49 task.go:241: debug  ---统计下载失败信息完成---
+2021/04/19 15:19:17 task.go:44: debug  ---开始统计重采失败信息---
+2021/04/19 15:19:17 task.go:127: debug  ---统计重采失败信息完成---
+2021/04/19 15:19:17 task.go:133: debug  ---开始统计下载失败信息---
+2021/04/19 15:19:17 task.go:241: debug  ---统计下载失败信息完成---
+2021/04/19 15:20:05 task.go:44: debug  ---开始统计重采失败信息---
+2021/04/19 15:20:05 task.go:127: debug  ---统计重采失败信息完成---
+2021/04/19 15:20:05 task.go:133: debug  ---开始统计下载失败信息---
+2021/04/19 15:20:06 task.go:241: debug  ---统计下载失败信息完成---
+2021/04/19 15:23:19 task.go:44: debug  ---开始统计重采失败信息---
+2021/04/19 15:23:19 task.go:127: debug  ---统计重采失败信息完成---
+2021/04/19 15:23:19 task.go:133: debug  ---开始统计下载失败信息---
+2021/04/19 15:23:19 task.go:239: debug  ---统计下载失败信息完成---
+2021/04/20 09:58:28 task.go:48: debug  ---开始统计重采失败信息---
+2021/04/20 09:58:28 task.go:131: debug  ---统计重采失败信息完成---
+2021/04/20 09:58:28 task.go:137: debug  ---开始统计下载失败信息---
+2021/04/20 09:58:29 task.go:243: debug  ---统计下载失败信息完成---
+2021/04/20 10:00:28 task.go:48: debug  ---开始统计重采失败信息---
+2021/04/20 10:00:36 task.go:132: debug  ---统计重采失败信息完成---
+2021/04/20 10:00:36 task.go:138: debug  ---开始统计下载失败信息---
+2021/04/20 10:00:37 task.go:245: debug  ---统计下载失败信息完成---
+2021/04/20 10:02:00 task.go:48: debug  ---开始统计重采失败信息---
+2021/04/20 10:02:07 task.go:132: debug  ---统计重采失败信息完成---
+2021/04/20 10:02:07 task.go:138: debug  ---开始统计下载失败信息---
+2021/04/20 10:02:07 task.go:245: debug  ---统计下载失败信息完成---
+2021/04/20 10:02:24 task.go:48: debug  ---开始统计重采失败信息---
+2021/04/20 10:02:25 task.go:132: debug  ---统计重采失败信息完成---
+2021/04/20 10:02:25 task.go:138: debug  ---开始统计下载失败信息---
+2021/04/20 10:02:25 task.go:245: debug  ---统计下载失败信息完成---
+2021/04/20 10:06:49 task.go:49: debug  ---开始统计重采失败信息---
+2021/04/20 10:06:49 task.go:136: debug  ---统计重采失败信息完成---
+2021/04/20 10:06:49 task.go:142: debug  ---开始统计下载失败信息---
+2021/04/20 10:06:49 task.go:249: debug  ---统计下载失败信息完成---
+2021/04/20 10:07:37 task.go:49: debug  ---开始统计重采失败信息---
+2021/04/20 10:07:37 task.go:136: debug  ---统计重采失败信息完成---
+2021/04/20 10:07:37 task.go:142: debug  ---开始统计下载失败信息---
+2021/04/20 10:07:37 task.go:252: debug  ---统计下载失败信息完成---
+2021/04/20 10:11:27 task.go:49: debug  ---开始统计重采失败信息---
+2021/04/20 10:11:27 task.go:136: debug  ---统计重采失败信息完成---
+2021/04/20 10:11:27 task.go:142: debug  ---开始统计下载失败信息---
+2021/04/20 10:11:27 task.go:252: debug  ---统计下载失败信息完成---
+2021/04/20 10:22:19 task.go:49: debug  ---开始统计重采失败信息---
+2021/04/20 10:22:19 task.go:136: debug  ---统计重采失败信息完成---
+2021/04/20 10:22:19 task.go:142: debug  ---开始统计下载失败信息---
+2021/04/20 10:22:19 task.go:252: debug  ---统计下载失败信息完成---
+2021/04/20 10:22:19 task.go:258: debug  ---开始统计信息异常数据---
+2021/04/20 10:22:20 task.go:358: debug  ---统计信息异常数据完成---
+2021/04/20 10:38:41 task.go:49: debug  ---开始统计重采失败信息---
+2021/04/20 10:38:41 task.go:136: debug  ---统计重采失败信息完成---
+2021/04/20 10:38:41 task.go:142: debug  ---开始统计下载失败信息---
+2021/04/20 10:38:41 task.go:252: debug  ---统计下载失败信息完成---
+2021/04/20 10:38:41 task.go:258: debug  ---开始统计信息异常数据---
+2021/04/20 10:38:41 task.go:358: debug  ---统计信息异常数据完成---
+2021/04/20 10:38:41 task.go:364: debug  ---开始统计栏目地址404数据---
+2021/04/20 10:38:44 task.go:420: debug  ---统计栏目地址404数据完成---
+2021/04/20 10:46:47 task.go:49: debug  ---开始统计重采失败信息---
+2021/04/20 10:46:48 task.go:136: debug  ---统计重采失败信息完成---
+2021/04/20 10:46:48 task.go:142: debug  ---开始统计下载失败信息---
+2021/04/20 10:46:48 task.go:252: debug  ---统计下载失败信息完成---
+2021/04/20 10:46:48 task.go:258: debug  ---开始统计信息异常数据---
+2021/04/20 10:46:48 task.go:358: debug  ---统计信息异常数据完成---
+2021/04/20 10:46:48 task.go:364: debug  ---开始统计栏目地址404数据---
+2021/04/20 10:46:48 task.go:420: debug  ---统计栏目地址404数据完成---
+2021/04/20 10:49:05 task.go:49: debug  ---开始统计重采失败信息---
+2021/04/20 10:49:05 task.go:136: debug  ---统计重采失败信息完成---
+2021/04/20 10:49:05 task.go:142: debug  ---开始统计下载失败信息---
+2021/04/20 10:49:05 task.go:252: debug  ---统计下载失败信息完成---
+2021/04/20 10:49:05 task.go:258: debug  ---开始统计信息异常数据---
+2021/04/20 10:49:05 task.go:358: debug  ---统计信息异常数据完成---
+2021/04/20 10:49:05 task.go:364: debug  ---开始统计栏目地址404数据---
+2021/04/20 10:49:06 task.go:420: debug  ---统计栏目地址404数据完成---
+2021/04/20 10:52:30 task.go:49: debug  ---开始统计重采失败信息---
+2021/04/20 10:52:30 task.go:136: debug  ---统计重采失败信息完成---
+2021/04/20 10:52:30 task.go:142: debug  ---开始统计下载失败信息---
+2021/04/20 10:52:30 task.go:252: debug  ---统计下载失败信息完成---
+2021/04/20 10:52:30 task.go:258: debug  ---开始统计信息异常数据---
+2021/04/20 10:52:30 task.go:358: debug  ---统计信息异常数据完成---
+2021/04/20 10:52:30 task.go:364: debug  ---开始统计栏目地址404数据---
+2021/04/20 10:52:31 task.go:421: debug  ---统计栏目地址404数据完成---
+2021/04/20 10:53:05 task.go:49: debug  ---开始统计重采失败信息---
+2021/04/20 10:53:05 task.go:136: debug  ---统计重采失败信息完成---
+2021/04/20 10:53:05 task.go:142: debug  ---开始统计下载失败信息---
+2021/04/20 10:53:05 task.go:252: debug  ---统计下载失败信息完成---
+2021/04/20 10:53:05 task.go:258: debug  ---开始统计信息异常数据---
+2021/04/20 10:53:06 task.go:358: debug  ---统计信息异常数据完成---
+2021/04/20 10:53:06 task.go:364: debug  ---开始统计栏目地址404数据---
+2021/04/20 10:53:06 task.go:422: debug  ---统计栏目地址404数据完成---
+2021/04/20 10:53:14 task.go:49: debug  ---开始统计重采失败信息---
+2021/04/20 10:53:14 task.go:136: debug  ---统计重采失败信息完成---
+2021/04/20 10:53:14 task.go:142: debug  ---开始统计下载失败信息---
+2021/04/20 10:53:14 task.go:252: debug  ---统计下载失败信息完成---
+2021/04/20 10:53:14 task.go:258: debug  ---开始统计信息异常数据---
+2021/04/20 10:53:14 task.go:358: debug  ---统计信息异常数据完成---
+2021/04/20 10:53:14 task.go:364: debug  ---开始统计栏目地址404数据---
+2021/04/20 10:53:16 task.go:422: debug  ---统计栏目地址404数据完成---
+2021/04/20 11:19:39 task.go:49: debug  ---开始统计重采失败信息---
+2021/04/20 11:19:39 task.go:136: debug  ---统计重采失败信息完成---
+2021/04/20 11:19:39 task.go:142: debug  ---开始统计下载失败信息---
+2021/04/20 11:19:39 task.go:252: debug  ---统计下载失败信息完成---
+2021/04/20 11:19:39 task.go:258: debug  ---开始统计信息异常数据---
+2021/04/20 11:19:39 task.go:358: debug  ---统计信息异常数据完成---
+2021/04/20 11:19:39 task.go:364: debug  ---开始统计栏目地址404数据---
+2021/04/20 11:19:40 task.go:422: debug  ---统计栏目地址404数据完成---
+2021/04/20 11:19:40 task.go:428: debug  ---开始统计下载量异常数据---
+2021/04/20 11:20:49 task.go:49: debug  ---开始统计重采失败信息---
+2021/04/20 11:20:49 task.go:136: debug  ---统计重采失败信息完成---
+2021/04/20 11:20:49 task.go:142: debug  ---开始统计下载失败信息---
+2021/04/20 11:20:49 task.go:252: debug  ---统计下载失败信息完成---
+2021/04/20 11:20:49 task.go:258: debug  ---开始统计信息异常数据---
+2021/04/20 11:20:49 task.go:358: debug  ---统计信息异常数据完成---
+2021/04/20 11:20:49 task.go:364: debug  ---开始统计栏目地址404数据---
+2021/04/20 11:20:50 task.go:422: debug  ---统计栏目地址404数据完成---
+2021/04/20 11:20:50 task.go:428: debug  ---开始统计下载量异常数据---
+2021/04/20 11:21:10 task.go:530: debug  ---统计下载量异常数据完成---
+2021/04/20 14:03:27 task.go:46: debug  ---开始统计重采失败信息---
+2021/04/20 14:03:27 task.go:132: debug  ---统计重采失败信息完成---
+2021/04/20 14:03:27 task.go:138: debug  ---开始统计下载失败信息---
+2021/04/20 14:03:27 task.go:235: debug  ---统计下载失败信息完成---
+2021/04/20 14:03:27 task.go:241: debug  ---开始统计信息异常数据---
+2021/04/20 14:03:27 task.go:328: debug  ---统计信息异常数据完成---
+2021/04/20 14:03:27 task.go:334: debug  ---开始统计栏目地址404数据---
+2021/04/20 14:03:27 task.go:379: debug  ---统计栏目地址404数据完成---
+2021/04/20 14:03:27 task.go:385: debug  ---开始统计下载量异常数据---
+2021/04/20 14:03:29 task.go:474: debug  ---统计下载量异常数据完成---
+2021/04/20 14:56:49 task.go:48: debug  ---开始统计下载失败信息---
+2021/04/20 14:56:49 task.go:145: debug  ---统计下载失败信息完成---
+2021/04/20 14:56:49 task.go:151: debug  ---开始统计重采失败信息---
+2021/04/20 14:56:49 task.go:245: debug  ---统计重采失败信息完成---
+2021/04/20 15:02:13 task.go:47: debug  ---开始统计下载失败信息---
+2021/04/20 15:02:13 task.go:144: debug  ---统计下载失败信息完成---
+2021/04/20 15:02:13 task.go:150: debug  ---开始统计重采失败信息---
+2021/04/20 15:02:13 task.go:244: debug  ---统计重采失败信息完成---
+2021/04/20 15:02:13 task.go:250: debug  ---开始统计信息异常数据---
+2021/04/20 15:02:13 task.go:337: debug  ---统计信息异常数据完成---
+2021/04/20 15:02:13 task.go:343: debug  ---开始统计栏目地址404数据---
+2021/04/20 15:02:13 task.go:388: debug  ---统计栏目地址404数据完成---
+2021/04/20 15:02:13 task.go:394: debug  ---开始统计下载量异常数据---
+2021/04/20 15:02:13 task.go:483: debug  ---统计下载量异常数据完成---
+2021/04/20 15:02:13 task.go:489: debug  ---开始保存信息---
+2021/04/20 15:02:13 task.go:533: debug  ---保存信息完成---
+2021/04/20 15:07:56 task.go:48: debug  ---开始统计下载失败信息---
+2021/04/20 15:07:56 task.go:145: debug  ---统计下载失败信息完成---
+2021/04/20 15:07:56 task.go:151: debug  ---开始统计重采失败信息---
+2021/04/20 15:07:56 task.go:245: debug  ---统计重采失败信息完成---
+2021/04/20 15:07:56 task.go:251: debug  ---开始统计信息异常数据---
+2021/04/20 15:07:56 task.go:338: debug  ---统计信息异常数据完成---
+2021/04/20 15:07:56 task.go:344: debug  ---开始统计栏目地址404数据---
+2021/04/20 15:07:56 task.go:389: debug  ---统计栏目地址404数据完成---
+2021/04/20 15:07:56 task.go:395: debug  ---开始统计下载量异常数据---
+2021/04/20 15:07:57 task.go:484: debug  ---统计下载量异常数据完成---
+2021/04/20 15:07:57 task.go:490: debug  ---开始保存信息---
+2021/04/20 15:07:57 task.go:536: debug  ---保存信息完成---
+2021/04/20 15:23:06 task.go:47: debug  ---开始统计下载失败信息---
+2021/04/20 15:23:06 task.go:144: debug  ---统计下载失败信息完成---
+2021/04/20 15:23:06 task.go:150: debug  ---开始统计重采失败信息---
+2021/04/20 15:23:06 task.go:244: debug  ---统计重采失败信息完成---
+2021/04/20 15:23:06 task.go:250: debug  ---开始统计信息异常数据---
+2021/04/20 15:23:06 task.go:337: debug  ---统计信息异常数据完成---
+2021/04/20 15:23:06 task.go:343: debug  ---开始统计栏目地址404数据---
+2021/04/20 15:23:06 task.go:388: debug  ---统计栏目地址404数据完成---
+2021/04/20 15:23:06 task.go:394: debug  ---开始统计下载量异常数据---
+2021/04/20 15:23:07 task.go:483: debug  ---统计下载量异常数据完成---
+2021/04/20 15:23:07 task.go:489: debug  ---开始保存信息---
+2021/04/20 15:23:07 task.go:531: debug  ---保存信息完成---
+2021/04/20 15:30:44 task.go:47: debug  ---开始统计下载失败信息---
+2021/04/20 15:30:44 task.go:144: debug  ---统计下载失败信息完成---
+2021/04/20 15:30:44 task.go:150: debug  ---开始统计重采失败信息---
+2021/04/20 15:30:44 task.go:244: debug  ---统计重采失败信息完成---
+2021/04/20 15:30:44 task.go:250: debug  ---开始统计信息异常数据---
+2021/04/20 15:30:44 task.go:337: debug  ---统计信息异常数据完成---
+2021/04/20 15:30:44 task.go:343: debug  ---开始统计栏目地址404数据---
+2021/04/20 15:30:44 task.go:388: debug  ---统计栏目地址404数据完成---
+2021/04/20 15:30:44 task.go:394: debug  ---开始统计下载量异常数据---
+2021/04/20 15:30:45 task.go:483: debug  ---统计下载量异常数据完成---
+2021/04/20 15:30:45 task.go:489: debug  ---开始保存信息---
+2021/04/20 15:30:46 task.go:531: debug  ---保存信息完成---
+2021/04/21 10:02:14 task.go:543: debug  ---开始创建任务---
+2021/04/21 10:02:14 task.go:652: debug  ---统计下载失败信息完成---
+2021/04/21 10:02:50 task.go:543: debug  ---开始创建任务---
+2021/04/21 10:02:50 task.go:652: debug  ---统计下载失败信息完成---
+2021/04/21 10:03:29 task.go:543: debug  ---开始创建任务---
+2021/04/21 10:03:29 task.go:653: debug  ---统计下载失败信息完成---
+2021/04/21 10:04:07 task.go:543: debug  ---开始创建任务---
+2021/04/21 10:04:07 task.go:653: debug  ---统计下载失败信息完成---
+2021/04/21 10:16:25 task.go:543: debug  ---开始创建任务---
+2021/04/21 10:16:25 task.go:657: debug  ---统计下载失败信息完成---
+2021/04/21 10:16:54 task.go:543: debug  ---开始创建任务---
+2021/04/21 10:16:54 task.go:657: debug  ---统计下载失败信息完成---
+2021/04/21 10:18:32 task.go:543: debug  ---开始创建任务---
+2021/04/21 10:18:32 task.go:657: debug  ---统计下载失败信息完成---
+2021/04/21 14:46:56 task.go:560: debug  ---开始创建任务---
+2021/04/21 14:46:56 task.go:717: debug  ---统计下载失败信息完成---
+2021/04/21 14:52:48 task.go:560: debug  ---开始创建任务---
+2021/04/21 14:52:48 task.go:717: debug  ---统计下载失败信息完成---
+2021/04/21 14:53:34 task.go:560: debug  ---开始创建任务---
+2021/04/21 14:53:34 task.go:717: debug  ---统计下载失败信息完成---
+2021/04/21 14:54:01 task.go:560: debug  ---开始创建任务---
+2021/04/21 14:54:01 task.go:717: debug  ---统计下载失败信息完成---
+2021/04/21 15:00:11 task.go:560: debug  ---开始创建任务---
+2021/04/21 15:00:11 task.go:721: debug  ---统计下载失败信息完成---
+2021/04/21 15:01:18 task.go:560: debug  ---开始创建任务---
+2021/04/21 15:01:18 task.go:721: debug  ---统计下载失败信息完成---
+2021/04/21 15:01:29 task.go:560: debug  ---开始创建任务---
+2021/04/21 15:01:29 task.go:721: debug  ---统计下载失败信息完成---
+2021/04/21 15:02:26 task.go:560: debug  ---开始创建任务---
+2021/04/21 15:02:26 task.go:721: debug  ---统计下载失败信息完成---
+2021/04/21 15:02:43 task.go:560: debug  ---开始创建任务---
+2021/04/21 15:02:43 task.go:721: debug  ---统计下载失败信息完成---
+2021/04/21 15:04:23 task.go:560: debug  ---开始创建任务---
+2021/04/21 15:04:23 task.go:721: debug  ---统计下载失败信息完成---
+2021/04/21 15:05:39 task.go:560: debug  ---开始创建任务---
+2021/04/21 15:05:39 task.go:721: debug  ---统计下载失败信息完成---
+2021/04/21 15:06:27 task.go:560: debug  ---开始创建任务---
+2021/04/21 15:06:27 task.go:721: debug  ---统计下载失败信息完成---
+2021/04/21 15:07:05 task.go:560: debug  ---开始创建任务---
+2021/04/21 15:07:05 task.go:721: debug  ---统计下载失败信息完成---
+2021/04/21 15:08:07 task.go:560: debug  ---开始创建任务---
+2021/04/21 15:08:07 task.go:721: debug  ---统计下载失败信息完成---
+2021/04/21 15:09:03 task.go:560: debug  ---开始创建任务---
+2021/04/21 15:09:04 task.go:721: debug  ---统计下载失败信息完成---
+2021/04/21 15:09:52 task.go:560: debug  ---开始创建任务---
+2021/04/21 15:09:52 task.go:721: debug  ---统计下载失败信息完成---
+2021/04/21 15:10:57 task.go:560: debug  ---开始创建任务---
+2021/04/21 15:10:57 task.go:721: debug  ---统计下载失败信息完成---
+2021/04/21 15:17:33 task.go:560: debug  ---开始创建任务---
+2021/04/21 15:17:33 task.go:724: debug  ---统计下载失败信息完成---
+2021/04/21 15:17:54 task.go:560: debug  ---开始创建任务---
+2021/04/21 15:17:55 task.go:724: debug  ---统计下载失败信息完成---
+2021/04/21 15:18:08 task.go:560: debug  ---开始创建任务---
+2021/04/21 15:18:08 task.go:724: debug  ---统计下载失败信息完成---
+2021/04/21 15:20:35 task.go:560: debug  ---开始创建任务---
+2021/04/21 15:20:35 task.go:723: debug  ---统计下载失败信息完成---
+2021/04/21 15:20:54 task.go:560: debug  ---开始创建任务---
+2021/04/21 15:20:54 task.go:723: debug  ---统计下载失败信息完成---
+2021/04/21 15:21:08 task.go:560: debug  ---开始创建任务---
+2021/04/21 15:21:08 task.go:723: debug  ---统计下载失败信息完成---
+2021/04/21 15:21:53 task.go:560: debug  ---开始创建任务---
+2021/04/21 15:21:53 task.go:723: debug  ---统计下载失败信息完成---
+2021/04/21 15:22:39 task.go:560: debug  ---开始创建任务---
+2021/04/21 15:22:39 task.go:723: debug  ---统计下载失败信息完成---
+2021/04/21 15:22:42 task.go:560: debug  ---开始创建任务---
+2021/04/21 15:22:42 task.go:723: debug  ---统计下载失败信息完成---
+2021/04/21 15:23:21 task.go:560: debug  ---开始创建任务---
+2021/04/21 15:23:21 task.go:723: debug  ---统计下载失败信息完成---
+2021/04/21 15:23:40 task.go:560: debug  ---开始创建任务---
+2021/04/21 15:23:40 task.go:723: debug  ---统计下载失败信息完成---
+2021/04/22 10:59:39 task.go:49: debug  ---开始统计下载失败信息---
+2021/04/22 10:59:39 task.go:146: debug  ---统计下载失败信息完成---
+2021/04/22 10:59:39 task.go:152: debug  ---开始统计重采失败信息---
+2021/04/22 10:59:39 task.go:246: debug  ---统计重采失败信息完成---
+2021/04/22 10:59:39 task.go:252: debug  ---开始统计信息异常数据---
+2021/04/22 10:59:39 task.go:339: debug  ---统计信息异常数据完成---
+2021/04/22 10:59:39 task.go:345: debug  ---开始统计栏目地址404数据---
+2021/04/22 10:59:39 task.go:390: debug  ---统计栏目地址404数据完成---
+2021/04/22 10:59:39 task.go:396: debug  ---开始统计下载量异常数据---
+2021/04/22 10:59:41 task.go:485: debug  ---统计下载量异常数据完成---
+2021/04/22 10:59:41 task.go:491: debug  ---开始保存信息---
+2021/04/22 11:00:31 task.go:539: debug  ---保存信息完成---
+2021/04/22 11:05:52 task.go:781: debug  ---开始创建任务---
+2021/04/22 11:05:53 task.go:988: debug  ---统计下载失败信息完成---
+2021/04/22 11:10:33 task.go:781: debug  ---开始创建任务---
+2021/04/22 11:10:33 task.go:988: debug  ---统计下载失败信息完成---
+2021/04/22 11:11:21 task.go:781: debug  ---开始创建任务---
+2021/04/22 11:11:21 task.go:988: debug  ---统计下载失败信息完成---
+2021/04/22 11:12:19 task.go:781: debug  ---开始创建任务---
+2021/04/22 11:12:19 task.go:988: debug  ---统计下载失败信息完成---
+2021/04/22 11:13:07 task.go:781: debug  ---开始创建任务---
+2021/04/22 11:13:07 task.go:988: debug  ---统计下载失败信息完成---
+2021/04/22 11:13:45 task.go:781: debug  ---开始创建任务---
+2021/04/22 11:13:46 task.go:988: debug  ---统计下载失败信息完成---
+2021/04/22 11:14:52 task.go:781: debug  ---开始创建任务---
+2021/04/22 11:14:52 task.go:988: debug  ---统计下载失败信息完成---
+2021/04/22 11:15:58 task.go:781: debug  ---开始创建任务---
+2021/04/22 11:15:58 task.go:988: debug  ---统计下载失败信息完成---
+2021/04/22 11:16:08 task.go:781: debug  ---开始创建任务---
+2021/04/22 11:16:08 task.go:988: debug  ---统计下载失败信息完成---
+2021/04/22 11:16:15 task.go:781: debug  ---开始创建任务---
+2021/04/22 11:16:15 task.go:988: debug  ---统计下载失败信息完成---
+2021/04/22 11:16:19 task.go:781: debug  ---开始创建任务---
+2021/04/22 11:16:20 task.go:988: debug  ---统计下载失败信息完成---
+2021/04/22 11:16:23 task.go:781: debug  ---开始创建任务---
+2021/04/22 11:16:24 task.go:988: debug  ---统计下载失败信息完成---
+2021/04/22 11:16:28 task.go:781: debug  ---开始创建任务---
+2021/04/22 11:16:28 task.go:988: debug  ---统计下载失败信息完成---
+2021/04/22 11:18:02 task.go:781: debug  ---开始创建任务---
+2021/04/22 11:18:02 task.go:988: debug  ---统计下载失败信息完成---
+2021/04/22 11:19:01 task.go:781: debug  ---开始创建任务---
+2021/04/22 11:19:01 task.go:988: debug  ---统计下载失败信息完成---
+2021/04/22 11:19:42 task.go:781: debug  ---开始创建任务---
+2021/04/22 11:19:42 task.go:988: debug  ---统计下载失败信息完成---
+2021/04/22 11:21:09 task.go:781: debug  ---开始创建任务---
+2021/04/22 11:21:09 task.go:990: debug  ---统计下载失败信息完成---
+2021/04/22 11:21:41 task.go:781: debug  ---开始创建任务---
+2021/04/22 11:21:42 task.go:990: debug  ---统计下载失败信息完成---
+2021/04/22 11:21:48 task.go:781: debug  ---开始创建任务---
+2021/04/22 11:21:48 task.go:990: debug  ---统计下载失败信息完成---
+2021/04/22 11:21:55 task.go:781: debug  ---开始创建任务---
+2021/04/22 11:21:55 task.go:990: debug  ---统计下载失败信息完成---
+2021/04/22 11:22:00 task.go:781: debug  ---开始创建任务---
+2021/04/22 11:22:00 task.go:990: debug  ---统计下载失败信息完成---
+2021/04/22 11:22:08 task.go:781: debug  ---开始创建任务---
+2021/04/22 11:22:08 task.go:990: debug  ---统计下载失败信息完成---
+2021/04/22 11:22:13 task.go:781: debug  ---开始创建任务---
+2021/04/22 11:22:13 task.go:990: debug  ---统计下载失败信息完成---
+2021/04/22 11:22:18 task.go:781: debug  ---开始创建任务---
+2021/04/22 11:22:18 task.go:990: debug  ---统计下载失败信息完成---
+2021/04/22 11:22:22 task.go:781: debug  ---开始创建任务---
+2021/04/22 11:22:22 task.go:990: debug  ---统计下载失败信息完成---
+2021/04/22 11:24:29 task.go:781: debug  ---开始创建任务---
+2021/04/22 11:24:29 task.go:991: debug  ---统计下载失败信息完成---
+2021/04/22 13:20:57 task.go:781: debug  ---开始创建任务---
+2021/04/22 13:20:57 task.go:997: debug  ---统计下载失败信息完成---
+2021/04/22 13:22:41 task.go:781: debug  ---开始创建任务---
+2021/04/22 13:22:41 task.go:997: debug  ---统计下载失败信息完成---
+2021/04/22 13:23:14 task.go:781: debug  ---开始创建任务---
+2021/04/22 13:23:14 task.go:997: debug  ---统计下载失败信息完成---
+2021/04/22 13:23:39 task.go:781: debug  ---开始创建任务---
+2021/04/22 13:23:40 task.go:997: debug  ---统计下载失败信息完成---
+2021/04/22 13:31:02 task.go:781: debug  ---开始创建任务---
+2021/04/22 13:31:02 task.go:1000: debug  ---统计下载失败信息完成---
+2021/04/22 13:31:15 task.go:781: debug  ---开始创建任务---
+2021/04/22 13:31:15 task.go:1000: debug  ---统计下载失败信息完成---
+2021/04/22 13:38:12 task.go:781: debug  ---开始创建任务---
+2021/04/22 13:38:12 task.go:1004: debug  ---统计下载失败信息完成---
+2021/04/22 13:41:40 task.go:560: debug  ---开始创建任务---
+2021/04/22 13:41:40 task.go:783: debug  ---统计下载失败信息完成---
+2021/04/22 13:47:56 task.go:560: debug  ---开始创建任务---
+2021/04/22 13:47:56 task.go:783: debug  ---统计下载失败信息完成---
+2021/04/22 14:19:47 task.go:560: debug  ---开始创建任务---
+2021/04/22 14:20:11 task.go:783: debug  ---统计下载失败信息完成---
+2021/04/22 15:34:36 task.go:49: debug  ---开始统计下载失败信息---
+2021/04/22 15:34:36 task.go:146: debug  ---统计下载失败信息完成---
+2021/04/22 15:34:36 task.go:152: debug  ---开始统计重采失败信息---
+2021/04/22 15:34:36 task.go:246: debug  ---统计重采失败信息完成---
+2021/04/22 15:34:36 task.go:252: debug  ---开始统计信息异常数据---
+2021/04/22 15:34:36 task.go:339: debug  ---统计信息异常数据完成---
+2021/04/22 15:34:36 task.go:345: debug  ---开始统计栏目地址404数据---
+2021/04/22 15:34:36 task.go:390: debug  ---统计栏目地址404数据完成---
+2021/04/22 15:34:36 task.go:396: debug  ---开始统计下载量异常数据---
+2021/04/22 15:34:36 task.go:485: debug  ---统计下载量异常数据完成---
+2021/04/22 15:34:36 task.go:491: debug  ---开始保存信息---
+2021/04/22 15:35:08 task.go:49: debug  ---开始统计下载失败信息---
+2021/04/22 15:35:10 task.go:146: debug  ---统计下载失败信息完成---
+2021/04/22 15:35:10 task.go:152: debug  ---开始统计重采失败信息---
+2021/04/22 15:35:11 task.go:246: debug  ---统计重采失败信息完成---
+2021/04/22 15:35:11 task.go:252: debug  ---开始统计信息异常数据---
+2021/04/22 15:35:11 task.go:339: debug  ---统计信息异常数据完成---
+2021/04/22 15:35:11 task.go:345: debug  ---开始统计栏目地址404数据---
+2021/04/22 15:35:11 task.go:390: debug  ---统计栏目地址404数据完成---
+2021/04/22 15:35:11 task.go:396: debug  ---开始统计下载量异常数据---
+2021/04/22 15:35:12 task.go:485: debug  ---统计下载量异常数据完成---
+2021/04/22 15:35:12 task.go:491: debug  ---开始保存信息---
+2021/04/22 15:35:40 task.go:539: debug  ---保存信息完成---
+2021/04/25 13:15:32 task.go:89: debug  ---开始统计下载失败信息---
+2021/04/25 13:15:32 task.go:110: debug  共有下载失败数据 15 条
+2021/04/25 13:15:32 task.go:186: debug  ---统计下载失败信息完成---
+2021/04/25 13:15:32 task.go:192: debug  ---开始统计重采失败信息---
+2021/04/25 13:15:32 task.go:214: debug  共有重采失败数据 5 条
+2021/04/25 13:15:32 task.go:286: debug  ---统计重采失败信息完成---
+2021/04/25 13:15:32 task.go:292: debug  ---开始统计信息异常数据---
+2021/04/25 13:15:32 task.go:314: debug  共有信息异常数据 12 条
+2021/04/25 13:15:32 task.go:379: debug  ---统计信息异常数据完成---
+2021/04/25 13:15:32 task.go:385: debug  ---开始统计栏目地址404数据---
+2021/04/25 13:15:32 task.go:400: debug  共有404地址 121 条
+2021/04/25 13:15:32 task.go:430: debug  ---统计栏目地址404数据完成---
+2021/04/25 13:15:32 task.go:436: debug  ---开始统计下载量异常数据---
+2021/04/25 13:15:32 task.go:454: debug  共有下载量异常数据 2029 条
+2021/04/25 13:15:33 task.go:525: debug  ---统计下载量异常数据完成---
+2021/04/25 13:15:33 task.go:531: debug  ---开始保存信息---
+2021/04/25 13:15:52 task.go:579: debug  ---保存信息完成---
+2021/04/25 13:32:52 task.go:600: debug  ---开始创建任务---
+2021/04/25 13:32:52 task.go:616: debug  共有异常爬虫数据量 2147 条
+2021/04/25 13:32:52 task.go:824: debug  ---任务创建完成---
+2021/04/25 13:34:08 task.go:600: debug  ---开始创建任务---
+2021/04/25 13:34:08 task.go:616: debug  共有异常爬虫数据量 2147 条
+2021/04/25 13:35:30 task.go:824: debug  ---任务创建完成---
+2021/05/21 15:58:05 task.go:895: info  -----更新数据状态-----

BIN
src/luatask_new.exe


+ 81 - 0
src/main.go

@@ -0,0 +1,81 @@
+package main
+
+import (
+	mgo "mongodb"
+	qu "qfw/util"
+
+	"github.com/cron"
+
+	"github.com/donnie4w/go-logger/logger"
+)
+
+var (
+	Config map[string]interface{}
+	//User   map[string]string
+	MgoE *mgo.MongodbSim //editor
+	MgoS *mgo.MongodbSim //spider
+)
+
+func init() {
+	qu.ReadConfig(&Config)
+	//qu.ReadConfig("./user.json", &User)
+	//mgo
+	spider := Config["spider"].(map[string]interface{})
+	MgoS = &mgo.MongodbSim{
+		MongodbAddr: qu.ObjToString(spider["addr"]),
+		DbName:      qu.ObjToString(spider["db"]),
+		Size:        qu.IntAll(spider["size"]),
+	}
+	MgoS.InitPool()
+	editor := Config["editor"].(map[string]interface{})
+	MgoE = &mgo.MongodbSim{
+		MongodbAddr: qu.ObjToString(editor["addr"]),
+		DbName:      qu.ObjToString(editor["db"]),
+		Size:        qu.IntAll(editor["size"]),
+	}
+	MgoE.InitPool()
+	//logs
+	logger.SetRollingDaily("./logs", "task.log")
+	//爬虫上下浮动率
+	DownloadCheck = make(map[string]*DC)
+	downloadcheck := Config["downloadcheck"].(map[string]interface{})
+	for _, tmp := range downloadcheck {
+		tmpMap := tmp.(map[string]interface{})
+		downratio := qu.Float64All(tmpMap["downratio"])
+		uptatio := qu.Float64All(tmpMap["upratio"])
+		codes := tmpMap["spidercode"].([]interface{})
+		if len(codes) > 0 {
+			for _, code := range codes {
+				c := qu.ObjToString(code)
+				DownloadCheck[c] = &DC{
+					DownRatio: 1.0 - downratio/100.0,
+					UpRatio:   1.0 + uptatio/100.0,
+				}
+			}
+		} else {
+			DownloadCheck["other"] = &DC{
+				DownRatio: 1.0 - downratio/100.0,
+				UpRatio:   1.0 + uptatio/100.0,
+			}
+		}
+	}
+	EveryDayDownloadTime = qu.ObjToString(Config["everydaydownload"])
+	UpdateStateCron = qu.ObjToString(Config["updatestatecron"])
+	CreateTaskCron = qu.ObjToString(Config["createtaskcron"])
+	CloseTaskCron = qu.ObjToString(Config["closetaskcron"])
+	CloseNum = qu.IntAll(Config["closenum"])
+	DayNum = qu.IntAll(Config["daynum"])
+}
+
+func main() {
+	c := cron.New()
+	c.Start()
+	c.AddFunc(EveryDayDownloadTime, GetDownloadNumber) //统计下载量
+	c.AddFunc(UpdateStateCron, ResetDataState)         //更新数据状态
+	c.AddFunc(CreateTaskCron, CreateTaskProcess)       //创建任务
+	c.AddFunc(CloseTaskCron, CloseTask)                //关闭任务
+
+	defer c.Stop()
+	ch := make(chan bool, 1)
+	<-ch
+}

+ 13 - 0
src/readme.txt

@@ -0,0 +1,13 @@
+爬虫编辑器建任务流程
+
+一、定时任务:
+1、1点开始统计前一天爬虫的下载量
+2、6点开始流程
+3、8点关闭最迟完成时间在两天前的任务
+
+二、流程:
+1、统计spider_highlistdata前一天下载失败的爬虫数据(统计完成后修改状态state:0)
+2、统计regatherdata前一天重采失败的爬虫数据
+3、统计spider_warn异常数据(发布时间异常、乱码)
+4、统计spider_sitecheck 站点异常爬虫(404)
+5、统计download前一天下载量异常的爬虫数据(每天1点统计下载量,目前统计完成需要1个小时)

+ 946 - 0
src/task.go

@@ -0,0 +1,946 @@
+package main
+
+import (
+	"fmt"
+	mgo "mongodb"
+	qu "qfw/util"
+	"strconv"
+	"sync"
+	"time"
+
+	"github.com/donnie4w/go-logger/logger"
+)
+
+type Task struct {
+	Code        string                            //爬虫代码
+	Site        string                            //站点
+	Channel     string                            //栏目
+	ErrType     string                            //异常类型:6:运行异常;5:下载异常;4:发布时间异常;3:乱码;2:状态码异常;1:数据量异常
+	ErrInfo     map[string]map[string]interface{} //异常集合
+	Description string                            //描述
+}
+
+var (
+	StartTime       int64                     //上一个工作日的起始时间
+	EndTime         int64                     //上一个工作日的结束时间
+	TaskMap         map[string]*Task          //任务集合
+	UpdateStateCron string                    //每天关闭任务的时间
+	CreateTaskCron  string                    //每天创建任务的时间
+	CloseTaskCron   string                    //每天关闭任务的时间
+	CloseNum        int                       //关闭几天的任务
+	DayNum          int                       //更新数据天数
+	UserTaskNum     map[string]map[string]int //记录每人每天新建任务量
+)
+
+//创建任务
+func CreateTaskProcess() {
+	InitInfo()               //初始化
+	GetDownloadFailedData()  //1、统计spider_highlistdata前一天下载失败的爬虫数据(统计完成后修改状态state:0)
+	GetRegatherFailedData()  //2、统计regatherdata前一天重采失败的爬虫数据
+	GetDTPErrData()          //3、统计spider_warn异常数据(发布时间异常、乱码)
+	GetStatusCodeErrorData() //4、统计spider_sitecheck 站点异常爬虫(404)
+	GetDownloadNumErrData()  //5、统计download前一天下载量异常的爬虫数据(每天1点统计下载量,目前统计完成需要1个小时)
+	SaveResult()             //保存统计信息
+	CreateLuaTask()          //创建任务
+	SaveUserCreateTaskNum()  //保存每人创建的任务量
+}
+
+//初始化
+func InitInfo() {
+	defer qu.Catch()
+	TaskMap = map[string]*Task{}
+	UserTaskNum = map[string]map[string]int{}
+	InitTime() //初始化时间
+}
+
+//关闭任务
+func CloseTask() {
+	qu.Catch()
+	logger.Debug("---清理未更新任务---")
+	decreaseDay, day := 0, 0
+	var cleanDay string
+	for {
+		decreaseDay--
+		weekDay := time.Now().AddDate(0, 0, decreaseDay).Weekday().String()
+		if weekDay != "Saturday" && weekDay != "Sunday" {
+			day++
+		}
+		if day == CloseNum {
+			cleanDay = time.Now().AddDate(0, 0, decreaseDay).Format("2006-01-02")
+			break
+		}
+	}
+	the_time, _ := time.ParseInLocation(qu.Date_Short_Layout, cleanDay, time.Local)
+	unix_time := the_time.Unix() //凌晨时间戳
+	query := map[string]interface{}{
+		"i_state": 0,
+		"l_complete": map[string]interface{}{
+			"$lt": unix_time + 86400,
+		},
+	}
+	logger.Debug("query:", query)
+	set := map[string]interface{}{
+		"$set": map[string]interface{}{
+			"i_state": 6,
+		},
+	}
+	MgoE.Update("task", query, set, false, true)
+	logger.Debug("---清理未更新任务完毕---")
+}
+
+//1、统计三级页下载失败数据
+func GetDownloadFailedData() {
+	defer qu.Catch()
+	logger.Debug("---开始统计下载失败信息---")
+	sess := MgoS.GetMgoConn()
+	defer MgoS.DestoryMongoConn(sess)
+	ch := make(chan bool, 5)
+	wg := &sync.WaitGroup{}
+	lock := &sync.Mutex{}
+	field := map[string]interface{}{
+		"spidercode": 1,
+		"href":       1,
+		"site":       1,
+		"channel":    1,
+	}
+	query := map[string]interface{}{
+		"comeintime": map[string]interface{}{
+			"$gte": StartTime,
+			"$lte": EndTime,
+		},
+		"state": -1,
+	}
+	it := sess.DB("spider").C("spider_highlistdata").Find(&query).Select(&field).Iter()
+	count, _ := sess.DB("spider").C("spider_highlistdata").Find(&query).Count()
+	logger.Debug("共有下载失败数据", count, "条")
+	n := 0
+	//arr := [][]map[string]interface{}{}
+	for tmp := make(map[string]interface{}); it.Next(tmp); n++ {
+		ch <- true
+		wg.Add(1)
+		go func(tmp map[string]interface{}) {
+			defer func() {
+				<-ch
+				wg.Done()
+			}()
+			code := qu.ObjToString(tmp["spidercode"])
+			href := qu.ObjToString(tmp["href"])
+			site := qu.ObjToString(tmp["site"])
+			channel := qu.ObjToString(tmp["channel"])
+			lock.Lock()
+			if t := TaskMap[code]; t != nil {
+				if info := t.ErrInfo["6"]; info != nil {
+					num := qu.IntAll(info["num"])
+					num++
+					info["num"] = num
+					hrefs := info["hrefs"].([]string)
+					if len(hrefs) < 3 {
+						hrefs = append(hrefs, href)
+						info["hrefs"] = hrefs
+						t.Description += href + "\n"
+					}
+				} else {
+					t.ErrInfo["6"] = map[string]interface{}{ //ErrInfo新增下载异常信息
+						"num":   1,
+						"hrefs": []string{href},
+					}
+					t.Description += "下载异常:\n" + href + "\n"
+				}
+			} else {
+				t := &Task{
+					Code:        code,
+					Site:        site,
+					Channel:     channel,
+					ErrType:     "6",
+					ErrInfo:     map[string]map[string]interface{}{},
+					Description: "下载异常:\n" + href + "\n",
+				}
+				t.ErrInfo = map[string]map[string]interface{}{
+					"6": map[string]interface{}{
+						"num":   1,
+						"hrefs": []string{href},
+					},
+				}
+				TaskMap[code] = t
+			}
+
+			//更新state状态重新下载
+			// update := []map[string]interface{}{}
+			// update = append(update, map[string]interface{}{"_id": tmp["_id"]})
+			// update = append(update, map[string]interface{}{"$set": map[string]interface{}{"state": 0, "times": 0}})
+			// arr = append(arr, update)
+			// if len(arr) > 500 {
+			// 	tmps := arr
+			// 	MgoS.UpdateBulk("spider_highlistdata", tmps...)
+			// 	arr = [][]map[string]interface{}{}
+			// }
+			lock.Unlock()
+		}(tmp)
+		if n%100 == 0 {
+			qu.Debug("current:", n)
+		}
+		tmp = map[string]interface{}{}
+	}
+	wg.Wait()
+	// lock.Lock()
+	// if len(arr) > 0 {
+	// 	MgoS.UpdateBulk("spider_highlistdata", arr...)
+	// 	arr = [][]map[string]interface{}{}
+	// }
+	// lock.Unlock()
+	logger.Debug("---统计下载失败信息完成---")
+}
+
+//2、统计重采失败数据
+func GetRegatherFailedData() {
+	defer qu.Catch()
+	logger.Debug("---开始统计重采失败信息---")
+	sess := MgoS.GetMgoConn()
+	defer MgoS.DestoryMongoConn(sess)
+	ch := make(chan bool, 5)
+	wg := &sync.WaitGroup{}
+	lock := &sync.Mutex{}
+	field := map[string]interface{}{
+		"spidercode": 1,
+		"href":       1,
+		"site":       1,
+		"channel":    1,
+	}
+	query := map[string]interface{}{
+		"state": 1,
+		"from":  "lua",
+		"comeintime": map[string]interface{}{
+			"$gte": StartTime,
+			"$lte": EndTime,
+		},
+	}
+	it := sess.DB("spider").C("regatherdata").Find(&query).Select(&field).Iter()
+	count, _ := sess.DB("spider").C("regatherdata").Find(&query).Count()
+	logger.Debug("共有重采失败数据", count, "条")
+	n := 0
+	for tmp := make(map[string]interface{}); it.Next(tmp); n++ {
+		ch <- true
+		wg.Add(1)
+		go func(tmp map[string]interface{}) {
+			defer func() {
+				<-ch
+				wg.Done()
+			}()
+			code := qu.ObjToString(tmp["spidercode"])
+			href := qu.ObjToString(tmp["href"])
+			site := qu.ObjToString(tmp["site"])
+			channel := qu.ObjToString(tmp["channel"])
+			lock.Lock()
+			if t := TaskMap[code]; t != nil {
+				if info := t.ErrInfo["5"]; info != nil {
+					num := qu.IntAll(info["num"])
+					num++
+					info["num"] = num
+					hrefs := info["hrefs"].([]string)
+					if len(hrefs) < 3 {
+						hrefs = append(hrefs, href)
+						info["hrefs"] = hrefs
+						t.Description += href + "\n"
+					}
+				} else {
+					t.ErrInfo["5"] = map[string]interface{}{ //ErrInfo新增下载异常信息
+						"num":   1,
+						"hrefs": []string{href},
+					}
+					t.Description += "运行报错:\n" + href + "\n"
+				}
+
+			} else {
+				t := &Task{
+					Code:        code,
+					Site:        site,
+					Channel:     channel,
+					ErrType:     "5",
+					ErrInfo:     map[string]map[string]interface{}{},
+					Description: "运行报错:\n" + href + "\n",
+				}
+				t.ErrInfo = map[string]map[string]interface{}{
+					"5": map[string]interface{}{
+						"num":   1,
+						"hrefs": []string{href},
+					},
+				}
+				TaskMap[code] = t
+			}
+			lock.Unlock()
+		}(tmp)
+		if n%100 == 0 {
+			qu.Debug("current:", n)
+		}
+		tmp = map[string]interface{}{}
+	}
+	wg.Wait()
+	// for _, task := range TaskMap {
+	// 	qu.Debug("code:", task.Code)
+	// 	qu.Debug("site:", task.Site)
+	// 	qu.Debug("channel:", task.Channel)
+	// 	qu.Debug("errtype:", task.ErrType)
+	// 	qu.Debug("description:", task.Description)
+	// 	qu.Debug("info:", task.ErrInfo)
+	// 	qu.Debug("-------------------------------------------")
+	// 	tmap := map[string]interface{}{}
+	// 	ab, _ := json.Marshal(&task)
+	// 	json.Unmarshal(ab, &tmap)
+	// 	MgoE.Save("save_aa", tmap)
+	// }
+	logger.Debug("---统计重采失败信息完成---")
+}
+
+//3、统计detail、title、publishtime异常数据
+func GetDTPErrData() {
+	defer qu.Catch()
+	logger.Debug("---开始统计信息异常数据---")
+	sess := MgoS.GetMgoConn()
+	defer MgoS.DestoryMongoConn(sess)
+	ch := make(chan bool, 5)
+	wg := &sync.WaitGroup{}
+	lock := &sync.Mutex{}
+	field := map[string]interface{}{
+		"code":    1,
+		"href":    1,
+		"site":    1,
+		"channel": 1,
+		"field":   1,
+	}
+	query := map[string]interface{}{
+		"comeintime": map[string]interface{}{
+			"$gte": StartTime,
+			"$lte": EndTime,
+		},
+		"level": 2, //2:error数据 1:warn数据
+	}
+	it := sess.DB("spider").C("spider_warn").Find(&query).Select(&field).Iter()
+	count, _ := sess.DB("spider").C("spider_warn").Find(&query).Count()
+	logger.Debug("共有信息异常数据", count, "条")
+	n := 0
+	for tmp := make(map[string]interface{}); it.Next(tmp); n++ {
+		ch <- true
+		wg.Add(1)
+		go func(tmp map[string]interface{}) {
+			defer func() {
+				<-ch
+				wg.Done()
+			}()
+			code := qu.ObjToString(tmp["code"])
+			href := qu.ObjToString(tmp["href"])
+			site := qu.ObjToString(tmp["site"])
+			channel := qu.ObjToString(tmp["channel"])
+			field := qu.ObjToString(tmp["field"])
+			errnum := "3" //detail、 title异常
+			destmp := "正文标题异常:\n"
+			if field == "publishtime" { //发布时间异常
+				errnum = "4"
+				destmp = "发布时间异常:\n"
+			}
+			lock.Lock()
+			if t := TaskMap[code]; t != nil {
+				if info := t.ErrInfo[errnum]; info != nil {
+					num := qu.IntAll(info["num"])
+					num++
+					info["num"] = num
+					hrefs := info["hrefs"].([]string)
+					if len(hrefs) < 3 {
+						hrefs = append(hrefs, href)
+						info["hrefs"] = hrefs
+						t.Description += href + "\n"
+					}
+				} else {
+					t.ErrInfo[errnum] = map[string]interface{}{
+						"num":   1,
+						"hrefs": []string{href},
+					}
+					t.Description += destmp + href + "\n"
+				}
+			} else {
+				t := &Task{
+					Code:        code,
+					Site:        site,
+					Channel:     channel,
+					ErrType:     errnum,
+					ErrInfo:     map[string]map[string]interface{}{},
+					Description: destmp + href + "\n",
+				}
+				t.ErrInfo = map[string]map[string]interface{}{
+					errnum: map[string]interface{}{
+						"num":   1,
+						"hrefs": []string{href},
+					},
+				}
+				TaskMap[code] = t
+			}
+			lock.Unlock()
+		}(tmp)
+		if n%100 == 0 {
+			qu.Debug("current:", n)
+		}
+		tmp = map[string]interface{}{}
+	}
+	wg.Wait()
+	logger.Debug("---统计信息异常数据完成---")
+}
+
+//4、状态码404
+func GetStatusCodeErrorData() {
+	defer qu.Catch()
+	logger.Debug("---开始统计栏目地址404数据---")
+	field := map[string]interface{}{
+		"url":     1,
+		"code":    1,
+		"site":    1,
+		"channel": 1,
+	}
+	query := map[string]interface{}{
+		"comeintime": map[string]interface{}{
+			"$gte": StartTime,
+			"$lte": EndTime,
+		},
+		"statuscode": 404,
+	}
+	list, _ := MgoS.Find("spider_sitecheck", query, nil, field, false, -1, -1)
+	logger.Debug("共有404地址", len(*list), "条")
+	for _, tmp := range *list {
+		code := qu.ObjToString(tmp["code"])
+		href := qu.ObjToString(tmp["url"])
+		site := qu.ObjToString(tmp["site"])
+		channel := qu.ObjToString(tmp["channel"])
+		if t := TaskMap[code]; t != nil {
+			t.ErrInfo["2"] = map[string]interface{}{ //ErrInfo新增下载异常信息
+				"num":   404,
+				"hrefs": []string{href},
+			}
+			t.Description += "网站监测:404\n" + href + "\n"
+		} else {
+			t := &Task{
+				Code:        code,
+				Site:        site,
+				Channel:     channel,
+				ErrType:     "2",
+				ErrInfo:     map[string]map[string]interface{}{},
+				Description: "网站监测:404\n" + href + "\n",
+			}
+			t.ErrInfo = map[string]map[string]interface{}{
+				"2": map[string]interface{}{
+					"num":   404,
+					"hrefs": []string{href},
+				},
+			}
+			TaskMap[code] = t
+		}
+	}
+	logger.Debug("---统计栏目地址404数据完成---")
+}
+
+//5、统计下载量异常数据
+func GetDownloadNumErrData() {
+	defer qu.Catch()
+	logger.Debug("---开始统计下载量异常数据---")
+	sess := MgoS.GetMgoConn()
+	defer MgoS.DestoryMongoConn(sess)
+	ch := make(chan bool, 5)
+	wg := &sync.WaitGroup{}
+	lock := &sync.Mutex{}
+	field := map[string]interface{}{
+		"downloadNum":     1,
+		"code":            1,
+		"averageDownload": 1,
+		"site":            1,
+		"channel":         1,
+	}
+	query := map[string]interface{}{
+		"isok": false,
+	}
+	it := sess.DB("spider").C("spider_download").Find(&query).Select(&field).Iter()
+	count, _ := sess.DB("spider").C("spider_download").Find(&query).Count()
+	logger.Debug("共有下载量异常数据", count, "条")
+	n := 0
+	arr := [][]map[string]interface{}{}
+	for tmp := make(map[string]interface{}); it.Next(tmp); n++ {
+		ch <- true
+		wg.Add(1)
+		go func(tmp map[string]interface{}) {
+			defer func() {
+				<-ch
+				wg.Done()
+			}()
+			code := qu.ObjToString(tmp["code"])
+			site := qu.ObjToString(tmp["site"])
+			channel := qu.ObjToString(tmp["channel"])
+			average := qu.IntAll(tmp["averageDownload"])
+			date := "" //日期
+			dnum := 0  //下载量
+			for d, n := range tmp["downloadNum"].(map[string]interface{}) {
+				date = d
+				dnum = qu.IntAll(n)
+			}
+			lock.Lock()
+			if t := TaskMap[code]; t != nil {
+				t.ErrInfo["1"] = map[string]interface{}{ //ErrInfo新增下载异常信息
+					"num":     dnum,
+					"date":    date,
+					"average": average,
+				}
+				t.Description += "下载量异常:\n" + date + ":" + fmt.Sprint(dnum) + "\n"
+			} else {
+				t := &Task{
+					Code:        code,
+					Site:        site,
+					Channel:     channel,
+					ErrType:     "1",
+					ErrInfo:     map[string]map[string]interface{}{},
+					Description: "下载量异常:\n" + date + ":" + fmt.Sprint(dnum) + "\n",
+				}
+				t.ErrInfo = map[string]map[string]interface{}{
+					"1": map[string]interface{}{
+						"num":     dnum,
+						"date":    date,
+						"average": average,
+					},
+				}
+				TaskMap[code] = t
+			}
+			//更新isok
+			update := []map[string]interface{}{}
+			update = append(update, map[string]interface{}{"_id": tmp["_id"]})
+			update = append(update, map[string]interface{}{"$set": map[string]interface{}{"isok": true}})
+			arr = append(arr, update)
+			if len(arr) > 500 {
+				tmps := arr
+				MgoS.UpdateBulk("spider_download", tmps...)
+				arr = [][]map[string]interface{}{}
+			}
+			lock.Unlock()
+		}(tmp)
+		if n%100 == 0 {
+			qu.Debug("current:", n)
+		}
+		tmp = map[string]interface{}{}
+	}
+	wg.Wait()
+	lock.Lock()
+	if len(arr) > 0 {
+		MgoS.UpdateBulk("spider_download", arr...)
+		arr = [][]map[string]interface{}{}
+	}
+	lock.Unlock()
+	logger.Debug("---统计下载量异常数据完成---")
+}
+
+//保存统计信息
+func SaveResult() {
+	defer qu.Catch()
+	logger.Debug("---开始保存信息---")
+	wg := &sync.WaitGroup{}
+	lock := &sync.Mutex{}
+	ch := make(chan bool, 10)
+	savearr := []map[string]interface{}{}
+	for _, task := range TaskMap {
+		wg.Add(1)
+		ch <- true
+		go func(t *Task) {
+			defer func() {
+				<-ch
+				wg.Done()
+			}()
+			result := map[string]interface{}{}
+			result["code"] = t.Code
+			result["site"] = t.Site
+			result["channel"] = t.Channel
+			result["errtype"] = t.ErrType
+			result["errinfo"] = t.ErrInfo
+			result["description"] = t.Description
+			result["comeintime"] = time.Now().Unix()
+			result["updatetime"] = time.Now().Unix()
+			lua, _ := MgoE.FindOne("luaconfig", map[string]interface{}{"code": t.Code})
+			if lua != nil && len(*lua) > 0 {
+				result["modifyid"] = (*lua)["createuserid"]
+				result["modify"] = (*lua)["createuser"]
+				result["event"] = (*lua)["event"]
+			}
+			lock.Lock()
+			if len(result) > 0 {
+				savearr = append(savearr, result)
+			}
+			if len(savearr) > 500 {
+				tmps := savearr
+				MgoE.SaveBulk("luataskinfo", tmps...)
+				savearr = []map[string]interface{}{}
+			}
+			lock.Unlock()
+		}(task)
+	}
+	wg.Wait()
+	lock.Lock()
+	if len(savearr) > 0 {
+		MgoE.SaveBulk("luataskinfo", savearr...)
+		savearr = []map[string]interface{}{}
+	}
+	lock.Unlock()
+	TaskMap = map[string]*Task{} //重置
+	logger.Debug("---保存信息完成---")
+}
+
+//创建任务
+/*
+1、新任务待确认
+	1.原任务待确认-->更新原待确认任务的紧急度、最迟完成时间、times;如果times>5则更新为待处理任务;追加信息description、addinfoid
+	2.原任务待处理-->description、addinfoid信息更新到原任务
+	3.原任务处理中-->description、addinfoid信息更新到原任务
+	3.原任务待审核-->新建待确认任务
+	3.原任务未通过-->更新信息后改为待处理;爬虫状态改为待完成;追加信息description、addinfoid
+
+2、新任务待处理
+	1.原任务待确认-->关闭原任务;新建待处理任务,追加信息description、addinfoid;
+	2.原任务待处理-->description、addinfoid信息更新到原任务
+	3.原任务处理中-->description、addinfoid信息更新到原任务
+	3.原任务待审核-->新建待确认任务;
+	3.原任务未通过-->更新信息后改为待处理;爬虫状态改为待完成;追加信息description、addinfoid
+*/
+func CreateLuaTask() {
+	defer qu.Catch()
+	logger.Debug("---开始创建任务---")
+	sess := MgoE.GetMgoConn()
+	defer MgoE.DestoryMongoConn(sess)
+	ch := make(chan bool, 1)
+	wg := &sync.WaitGroup{}
+	field := map[string]interface{}{
+		"comeintime": 0,
+		"updatetime": 0,
+	}
+	query := map[string]interface{}{
+		"comeintime": map[string]interface{}{
+			"$gte": GetTime(0),
+		},
+	}
+	it := sess.DB("editor").C("luataskinfo").Find(&query).Select(&field).Iter()
+	count, _ := sess.DB("editor").C("luataskinfo").Find(&query).Count()
+	logger.Debug("共有异常爬虫数据量", count, "条")
+	n := 0
+	for tmp := make(map[string]interface{}); it.Next(tmp); n++ {
+		ch <- true
+		wg.Add(1)
+		func(tmp map[string]interface{}) { //目前不用多线程
+			defer func() {
+				<-ch
+				wg.Done()
+			}()
+			id := mgo.BsonIdToSId(tmp["_id"])
+			code := qu.ObjToString(tmp["code"])
+			site := qu.ObjToString(tmp["site"])
+			channel := qu.ObjToString(tmp["channel"])
+			description := qu.ObjToString(tmp["description"])
+			errtype := qu.ObjToString(tmp["errtype"])
+			errinfo := tmp["errinfo"].(map[string]interface{})
+			modifyid := qu.ObjToString(tmp["modifyid"])
+			modify := qu.ObjToString(tmp["modify"])
+			event := qu.IntAll(tmp["event"])
+			//初始化一些任务的变量
+			n_istate := 0     //当前任务的状态(默认待处理)
+			n_imin := 0       //最小下载量
+			n_itimes := 0     //任务出现特别紧急的次数
+			n_idn := 0        //下载量
+			n_sdt := ""       //下载量对应的日期
+			n_surgency := "1" //紧急程度
+			//
+			dnerr := errinfo["1"]
+			if errtype == "1" && dnerr != nil { //只有任务类型是数据量异常时,才记录数据量信息
+				info := errinfo["1"].(map[string]interface{})
+				n_imin = qu.IntAll(info["average"])
+				n_idn = qu.IntAll(info["num"])
+				n_sdt = qu.ObjToString(info["date"])
+			}
+			switch errtype {
+			case "6", "5": //下载异常、重采异常
+				info := errinfo[errtype].(map[string]interface{})
+				num := qu.IntAll(info["num"])
+				if num > 5 || (len(errinfo) == 2 && dnerr == nil) || len(errinfo) >= 3 {
+					n_istate = 1
+					n_surgency = "4"
+				}
+			case "4", "3", "2": //下载报错、发布时间异常、detail、title异常、404
+				n_istate = 1
+				n_surgency = "4"
+			case "1": //下载量异常
+				n_istate = 0
+				n_surgency = "1"
+			}
+			query := map[string]interface{}{
+				"s_code": code,
+				"i_state": map[string]interface{}{
+					"$in": []int{0, 1, 2, 3, 5},
+				},
+			}
+			list, _ := MgoE.Find("task", query, nil, nil, false, -1, -1)
+			if list != nil && len(*list) > 0 { //已有任务
+				task := (*list)[0]  //记录已有任务的集合
+				if len(*list) > 2 { //一个爬虫不能同时存在状态为0,1,2,3,5的超过2个任务
+					logger.Error("Code:", code, "任务异常")
+					MgoE.Save("luacreatetaskerr", map[string]interface{}{
+						"code":       code,
+						"comeintime": time.Now().Unix(),
+						"tasknum":    len(*list),
+					})
+					return
+				} else if len(*list) == 2 { //会出现一个爬虫既有待审核的任务也有待确认的任务,此情况只处理待确认的任务即可
+					tmpstate := qu.IntAll(task["i_state"])
+					if n_istate == 0 { //新建任务为待确认
+						if tmpstate == 3 || tmpstate == 5 { //如果task=(*list)[0]取的是待审核或未通过的任务,则将task替换为待确认任务数据集
+							task = map[string]interface{}{}
+							task = (*list)[1]
+						}
+					} else if n_istate == 1 { //新建任务为待处理
+						if tmpstate == 0 { //如果task=(*list)[0]取的是待确认任务,则将task替换为待审核或未通过的任务数据集
+							task = map[string]interface{}{}
+							task = (*list)[1]
+						}
+					}
+				}
+				//已有任务部分变量
+				o_istate := qu.IntAll(task["i_state"]) //已有任务的状态
+				addinfoid := []string{}                //记录追加信息的infoid
+				if addinfoidtmp, ok := task["addinfoid"].([]interface{}); ok {
+					addinfoid = qu.ObjArrToStringArr(addinfoidtmp)
+				}
+				o_stype := qu.ObjToString(task["s_type"]) //已有任务的类型
+				if errtype > o_stype {                    //任务类型替换为权重最高的
+					o_stype = errtype
+				}
+				o_sdescript := qu.ObjToString(task["s_descript"]) //已有任务的描述
+				o_lcomplete := qu.Int64All(task["l_complete"])    //已有任务的最迟完成时间
+				o_surgency := qu.ObjToString(task["s_urgency"])   //已有任务的紧急度
+				o_iurgency, _ := strconv.Atoi(o_surgency)         //已有任务的紧急度int类型
+				o_itimes := qu.IntAll(task["i_times"])            //已有任务出现特别紧急的次数
+				//处理任务流程
+				switch o_istate {
+				case 0: //原任务为待确认
+					// ctask := true //是否创建新任务(只针对原任务为待确认新任务为待处理)
+					// if n_istate == 0 || (n_istate == 1 && len(*list) == 2) {
+					o_iurgency++         //紧急度加一级
+					if o_iurgency >= 4 { //出现特别紧急的状态,记录次数itimes
+						o_itimes++
+						o_iurgency = 4
+					}
+					o_surgency = fmt.Sprint(o_iurgency)
+					o_lcomplete = CompleteTime(o_surgency)                                                                         //更新完成时间
+					o_sdescript += time.Now().Format(qu.Date_Short_Layout) + "追加描述:------------------------------\n" + description //更新描述
+					addinfoid = append(addinfoid, id)                                                                              //记录追加infoid
+					//ctask = false //n_istate==1&&len(*list)==2为true:新任务为待处理,已有任务除了有待确认还有其他类型任务,此时更新已有的待确认任务
+					//}
+					if n_istate == 0 { //新任务为待确认
+						if o_itimes >= 5 && len(*list) == 1 { //特别紧急的次数出现5次,自动创建待处理的任务(排除有待审核任务的可能)
+							o_istate = 1
+						}
+						q := map[string]interface{}{
+							"_id": task["_id"],
+						}
+						s := map[string]interface{}{
+							"$set": map[string]interface{}{
+								"addinfoid":      addinfoid,
+								"i_state":        o_istate,
+								"s_descript":     o_sdescript,
+								"l_complete":     o_lcomplete,
+								"s_urgency":      o_surgency,
+								"i_times":        o_itimes,
+								"s_type":         o_stype,
+								"i_min":          n_imin,
+								"i_num":          n_idn,
+								"s_downloadtime": n_sdt,
+							},
+						}
+						//更新task
+						MgoE.Update("task", q, s, false, false)
+					} else if n_istate == 1 { //新任务为待处理
+						if len(*list) == 1 { //已有任务只有待确认,新建待处理任务,关闭原任务
+							//新建任务(这里使用o_sdescript而不是description,是为了追加描述信息)
+							SaveTask(code, site, channel, modifyid, modify, o_sdescript, n_surgency, n_sdt, errtype, n_istate, n_imin, n_idn, event, n_itimes, addinfoid)
+							//关闭原任务
+							MgoE.Update("task", map[string]interface{}{"_id": task["_id"]}, map[string]interface{}{"$set": map[string]interface{}{"i_state": 6}}, false, false)
+						} else { //除了待确认有其他状态的任务,更新待确认任务
+							q := map[string]interface{}{
+								"_id": task["_id"],
+							}
+							s := map[string]interface{}{
+								"$set": map[string]interface{}{
+									"addinfoid": addinfoid,
+									//"i_state":    o_istate,
+									"s_descript":     o_sdescript,
+									"l_complete":     o_lcomplete,
+									"s_urgency":      o_surgency,
+									"i_times":        o_itimes,
+									"s_type":         o_stype,
+									"i_min":          n_imin,
+									"i_num":          n_idn,
+									"s_downloadtime": n_sdt,
+								},
+							}
+							//更新task
+							MgoE.Update("task", q, s, false, false)
+						}
+					}
+				case 1, 2: //原任务为待处理、处理中
+					//信息更新
+					o_sdescript += time.Now().Format(qu.Date_Short_Layout) + "追加描述:------------------------------\n" + description //更新描述
+					addinfoid = append(addinfoid, id)
+					q := map[string]interface{}{
+						"_id": task["_id"],
+					}
+					s := map[string]interface{}{
+						"$set": map[string]interface{}{
+							"addinfoid":      addinfoid,
+							"s_descript":     o_sdescript,
+							"s_type":         o_stype,
+							"i_min":          n_imin,
+							"i_num":          n_idn,
+							"s_downloadtime": n_sdt,
+						},
+					}
+					//更新task
+					MgoE.Update("task", q, s, false, false)
+				case 3: //原任务为待审核
+					//新建待确认任务
+					n_istate = 0
+					SaveTask(code, site, channel, modifyid, modify, description, n_surgency, n_sdt, errtype, n_istate, n_imin, n_idn, event, n_itimes, []string{id})
+				case 5: //原任务为未通过
+					//信息更新
+					o_sdescript += time.Now().Format(qu.Date_Short_Layout) + "追加描述:------------------------------\n" + description //更新描述
+					addinfoid = append(addinfoid, id)                                                                              //记录追加infoid
+					o_istate = 1
+					q := map[string]interface{}{
+						"_id": task["_id"],
+					}
+					s := map[string]interface{}{
+						"$set": map[string]interface{}{
+							"addinfoid":      addinfoid,
+							"i_state":        o_istate,
+							"s_descript":     o_sdescript,
+							"s_type":         o_stype,
+							"i_min":          n_imin,
+							"i_num":          n_idn,
+							"s_downloadtime": n_sdt,
+						},
+					}
+					//更新task
+					MgoE.Update("task", q, s, false, false)
+					//更新lua
+					MgoE.Update("luaconfig", map[string]interface{}{"code": code}, map[string]interface{}{"$set": map[string]interface{}{"state": 0}}, false, false)
+				}
+			} else { //没有任务新建
+				SaveTask(code, site, channel, modifyid, modify, description, n_surgency, n_sdt, errtype, n_istate, n_imin, n_idn, event, n_itimes, []string{id})
+			}
+		}(tmp)
+		if n%100 == 0 {
+			qu.Debug("current:", n)
+		}
+		tmp = map[string]interface{}{}
+	}
+	wg.Wait()
+	logger.Debug("---任务创建完成---")
+}
+
+func SaveTask(code, site, channel, modifyid, modify, description, urgency, downloadtime, errtype string, state, min, downloadnum, event, times int, addinfoid []string) {
+	defer qu.Catch()
+	result := map[string]interface{}{}
+	if stateNum := UserTaskNum[modify]; stateNum == nil {
+		tmp := map[string]int{fmt.Sprint(state): 1}
+		UserTaskNum[modify] = tmp
+	} else {
+		stateNum[fmt.Sprint(state)]++
+	}
+	if state == 1 { //待处理任务,紧急程度定为特别紧急
+		urgency = "4"
+	}
+	result["s_code"] = code
+	result["s_site"] = site
+	result["s_channel"] = channel
+	result["s_modifyid"] = modifyid
+	result["s_modify"] = modify
+	result["s_descript"] = description
+	result["i_min"] = min
+	result["i_num"] = downloadnum //下载量
+	result["s_urgency"] = urgency
+	result["i_state"] = state
+	result["i_event"] = event
+	result["s_downloadtime"] = downloadtime //下载量对应的日期
+	result["l_comeintime"] = time.Now().Unix()
+	result["l_complete"] = CompleteTime(urgency)
+	//result["s_date"] = time.Now().Format(qu.Date_Short_Layout) //任务创建字符串日期
+	result["i_times"] = times       //为了方便编辑器对次数的排序,记录当前的次数
+	result["s_type"] = errtype      //任务类型
+	result["addinfoid"] = addinfoid //信息id
+	result["s_source"] = "程序"
+	MgoE.Save("task", result)
+}
+
+func SaveUserCreateTaskNum() {
+	defer qu.Catch()
+	for user, sn := range UserTaskNum {
+		save := map[string]interface{}{}
+		save["user"] = user
+		save["comeintime"] = time.Now().Unix()
+		for s, n := range sn {
+			save[s] = n
+		}
+		MgoE.Save("luausertask", save)
+	}
+	UserTaskNum = map[string]map[string]int{}
+}
+
+//重置前一周内未下载成功的数据(一天3次未下成功的数据可以连续下一周)
+func ResetDataState() {
+	defer qu.Catch()
+	logger.Info("-----更新数据状态-----")
+	sess := MgoS.GetMgoConn()
+	defer MgoS.DestoryMongoConn(sess)
+	ch := make(chan bool, 3)
+	wg := &sync.WaitGroup{}
+	lock := &sync.Mutex{}
+	query := map[string]interface{}{
+		"comeintime": map[string]interface{}{
+			"$gte": GetTime(-DayNum),
+			"$lt":  GetTime(0),
+		},
+		"state": -1,
+	}
+	field := map[string]interface{}{
+		"_id": 1,
+	}
+	it := sess.DB("spider").C("spider_highlistdata").Find(&query).Select(&field).Iter()
+	count, _ := sess.DB("spider").C("spider_highlistdata").Find(&query).Count()
+	logger.Info("更新数据状态数量:", count)
+	n := 0
+	arr := [][]map[string]interface{}{}
+	for tmp := make(map[string]interface{}); it.Next(tmp); n++ {
+		ch <- true
+		wg.Add(1)
+		go func(tmp map[string]interface{}) {
+			defer func() {
+				<-ch
+				wg.Done()
+			}()
+			update := []map[string]interface{}{}
+			update = append(update, map[string]interface{}{"_id": tmp["_id"]})
+			update = append(update, map[string]interface{}{"$set": map[string]interface{}{"times": 0, "state": 0}})
+			lock.Lock()
+			arr = append(arr, update)
+			if len(arr) > 500 {
+				tmps := arr
+				MgoS.UpdateBulk("spider_highlistdata", tmps...)
+				arr = [][]map[string]interface{}{}
+			}
+			lock.Unlock()
+		}(tmp)
+		tmp = map[string]interface{}{}
+	}
+	wg.Wait()
+	lock.Lock()
+	if len(arr) > 0 {
+		MgoS.UpdateBulk("spider_highlistdata", arr...)
+		arr = [][]map[string]interface{}{}
+	}
+	lock.Unlock()
+	logger.Info("-----更新数据状态完毕-----")
+}

+ 6 - 0
src/user.json

@@ -0,0 +1,6 @@
+{
+	"weixingyue": "weixingyue",
+	"jiaoyubo": "jiaoyubo",
+	"ssc": "ssc",
+	"lyf": "lyf"
+}

+ 33 - 0
src/util.go

@@ -0,0 +1,33 @@
+package main
+
+import (
+	qu "qfw/util"
+	"time"
+)
+
+//初始化时间
+func InitTime() {
+	defer qu.Catch()
+	StartTime, EndTime = GetWorkDayTimeUnix()
+}
+
+//获取第day天凌晨的时间戳
+func GetTime(day int) int64 {
+	defer qu.Catch()
+	nowTime := time.Now().AddDate(0, 0, day)
+	timeStr := qu.FormatDate(&nowTime, qu.Date_Short_Layout)
+	t, _ := time.ParseInLocation(qu.Date_Short_Layout, timeStr, time.Local)
+	return t.Unix()
+}
+
+//获取上一个工作日的0时和24时的时间戳
+func GetWorkDayTimeUnix() (stime, etime int64) {
+	defer qu.Catch()
+	before := -1
+	weekday := time.Now().Weekday().String()
+	if weekday == "Monday" { //周一
+		before = -3
+	}
+	t := GetTime(before)
+	return t, t + 86400
+}

+ 103 - 0
src/work.go

@@ -0,0 +1,103 @@
+package main
+
+import (
+	qu "qfw/util"
+	"strings"
+	"time"
+)
+
+var workfig map[string]map[string]string
+var morning_on, morning_off, afternoon_on, afternoon_off string
+
+func init() {
+	qu.ReadConfig("./worktime.json", &workfig)
+	morning_on = workfig["morning"]["on"]
+	morning_off = workfig["morning"]["off"]
+	afternoon_on = workfig["afternoon"]["on"]
+	afternoon_off = workfig["afternoon"]["off"]
+}
+
+//获取完成时间
+func CompleteTime(urgent string) int64 {
+	duration := workfig["urgency"][urgent]
+	do := int64(0)
+	if strings.Contains(duration, "h") { //单位为小时,需要计算
+		do = qu.Int64All(strings.Replace(duration, "h", "", -1)) * int64(3600)
+	} else {
+		return 0
+	}
+	endtime := time.Now()
+	for i := 0; i < 100; i++ { //轮询调度直到,剩余工时为零
+		if do > 0 {
+			do, endtime = getWorkTime(do, endtime)
+		} else {
+			break
+		}
+	}
+	return endtime.Unix()
+}
+
+/*计算剩余工时,和完成时间
+do:工时
+t:时间
+spare:剩余工时
+endtime:完成时间
+*/
+func getWorkTime(do int64, t time.Time) (spare int64, endtime time.Time) {
+	mon, _ := time.ParseInLocation(qu.Date_Full_Layout, t.Format(qu.Date_Short_Layout)+" "+morning_on+":00", time.Local)
+	moff, _ := time.ParseInLocation(qu.Date_Full_Layout, t.Format(qu.Date_Short_Layout)+" "+morning_off+":00", time.Local)
+	aon, _ := time.ParseInLocation(qu.Date_Full_Layout, t.Format(qu.Date_Short_Layout)+" "+afternoon_on+":00", time.Local)
+	aoff, _ := time.ParseInLocation(qu.Date_Full_Layout, t.Format(qu.Date_Short_Layout)+" "+afternoon_off+":00", time.Local)
+	if t.Unix() <= mon.Unix() {
+		//早上上班前
+		work := moff.Unix() - mon.Unix()
+		if work >= do {
+			spare = 0
+			endtime = mon.Add(time.Duration(do) * time.Second)
+		} else {
+			spare = do - work
+			endtime = moff
+		}
+	} else if t.Unix() >= mon.Unix() && t.Unix() < moff.Unix() {
+		//中午下班前
+		work := moff.Unix() - t.Unix()
+		if work >= do {
+			spare = 0
+			endtime = t.Add(time.Duration(do) * time.Second)
+		} else {
+			spare = do - work
+			endtime = moff
+		}
+	} else if t.Unix() >= moff.Unix() && t.Unix() < aon.Unix() {
+		//下午上班前
+		work := aoff.Unix() - aon.Unix()
+		if work >= do {
+			spare = 0
+			endtime = aon.Add(time.Duration(do) * time.Second)
+		} else {
+			spare = do - work
+			endtime = aoff
+		}
+	} else if t.Unix() >= aon.Unix() && t.Unix() <= aoff.Unix() {
+		//下午下班前
+		work := aoff.Unix() - t.Unix()
+		if work >= do {
+			spare = 0
+			endtime = t.Add(time.Duration(do) * time.Second)
+		} else {
+			spare = do - work
+			endtime = mon.AddDate(0, 0, 1)
+		}
+	} else {
+		//下午下班
+		endtime = mon.AddDate(0, 0, 1)
+	}
+
+	//判断星期天
+	if endtime.Weekday().String() == "Sunday" {
+		endtime = endtime.AddDate(0, 0, 1)
+	} else if endtime.Weekday().String() == "Saturday" {
+		endtime = endtime.AddDate(0, 0, 2)
+	}
+	return spare, endtime
+}

+ 16 - 0
src/worktime.json

@@ -0,0 +1,16 @@
+{
+    "morning": {
+        "on": "08:50",
+        "off": "11:50"
+    },
+    "afternoon": {
+        "on": "13:10",
+        "off": "17:40"
+    },
+    "urgency": {
+        "4": "2h",
+        "3": "6h",
+        "2": "16h",
+        "1": "40h"
+    }
+}