|
@@ -4,6 +4,7 @@ import (
|
|
|
"bytes"
|
|
|
"fmt"
|
|
|
"github.com/tealeg/xlsx"
|
|
|
+ "net/http"
|
|
|
qu "qfw/util"
|
|
|
gm "qfw/util/mail"
|
|
|
"strconv"
|
|
@@ -583,3 +584,64 @@ func ConvertDataType(ratio float64) float64 {
|
|
|
ratio, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", ratio*100), 64)
|
|
|
return ratio
|
|
|
}
|
|
|
+
|
|
|
+var LuaWeeklyReport = `
|
|
|
+ 本周总结:
|
|
|
+ 完成爬虫总量:<font color=\"warning\">%d个</font>;
|
|
|
+ 开发新爬虫量:<font color=\"warning\">%d个</font>;
|
|
|
+ 维护历史爬虫量:<font color=\"warning\">%d个</font>;
|
|
|
+ 待完成爬虫总量:<font color=\"warning\">%d个</font>;
|
|
|
+ 待核实任务总量:<font color=\"warning\">%d个</font>;
|
|
|
+`
|
|
|
+
|
|
|
+func SpiderWeeklyReportForLua() {
|
|
|
+ defer qu.Catch()
|
|
|
+ //维护爬虫总量
|
|
|
+ q := map[string]interface{}{
|
|
|
+ "comeintime": map[string]interface{}{
|
|
|
+ "$gte": util.GetTime(-4),
|
|
|
+ "$lte": time.Now().Unix(),
|
|
|
+ },
|
|
|
+ "types": "审核",
|
|
|
+ }
|
|
|
+ qu.Debug(q)
|
|
|
+ allCount := util.MgoEB.Count("lua_logs_auditor", q)
|
|
|
+ //开发新爬虫数量
|
|
|
+ q["event"] = 7000
|
|
|
+ newCount := util.MgoEB.Count("lua_logs_auditor_new", q)
|
|
|
+ //待完成爬虫数量=待开发新爬虫+待维护历史任务
|
|
|
+ q1 := map[string]interface{}{
|
|
|
+ "event": 7000,
|
|
|
+ "platform": "golua平台",
|
|
|
+ "state": map[string]interface{}{
|
|
|
+ "$lte": 2, //待完成、待审核、未通过
|
|
|
+ },
|
|
|
+ }
|
|
|
+ needNewCount := util.MgoEB.Count("luaconfig", q1)
|
|
|
+ q2 := map[string]interface{}{
|
|
|
+ "i_state": map[string]interface{}{
|
|
|
+ "$in": []int{2, 3, 5}, //处理中、待审核、未通过
|
|
|
+ },
|
|
|
+ }
|
|
|
+ needHistoryCount := util.MgoEB.Count("task", q2)
|
|
|
+ //待确认爬虫数量(异常)=待分发的任务(待确认+待处理)
|
|
|
+ q = map[string]interface{}{
|
|
|
+ "i_state": map[string]interface{}{
|
|
|
+ "$lte": 1, //任务状态:待确认、待处理
|
|
|
+ },
|
|
|
+ }
|
|
|
+ taskCount := util.MgoEB.Count("task", q)
|
|
|
+ text := fmt.Sprintf(LuaWeeklyReport, allCount, newCount, allCount-newCount, needNewCount+needHistoryCount, taskCount)
|
|
|
+ msg := fmt.Sprintf(MarkdownModel, text)
|
|
|
+ qu.Debug("msg", msg)
|
|
|
+ resp, err := http.Post(
|
|
|
+ "https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=d61e5bf5-bd85-4749-996a-f2ff6b7c4177",
|
|
|
+ "application/json",
|
|
|
+ bytes.NewBuffer([]byte(msg)),
|
|
|
+ )
|
|
|
+ if err != nil {
|
|
|
+ fmt.Println("request error:", err)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ defer resp.Body.Close()
|
|
|
+}
|