Răsfoiți Sursa

数据查询功能修改

maxiaoshan 2 ani în urmă
părinte
comite
34210850ef
2 a modificat fișierele cu 64 adăugiri și 19 ștergeri
  1. 32 0
      src/lua/data.go
  2. 32 19
      src/web/templates/lua/datafind.html

+ 32 - 0
src/lua/data.go

@@ -1,7 +1,9 @@
 package lua
 
 import (
+	"mongodb"
 	qu "qfw/util"
+	"qfw/util/elastic"
 	"strings"
 	"util"
 )
@@ -40,13 +42,43 @@ func (l *Lua) SearchData() {
 	query := map[string]interface{}{
 		stype: text,
 	}
+	//bidding、索引分析
 	if stype == "title" { //根据title找bidding(bidding表有title索引,无href索引)
 		query = map[string]interface{}{
 			"title": text,
 		}
 		//1、根据title找bidding
 		list_bid, _ := util.JYMgo.Find("bidding", query, nil, nil, false, -1, -1)
+		for _, l := range *list_bid {
+			id := mongodb.BsonIdToSId(l["_id"])
+			es_query := `{"query":{"bool":{"must":[{"term":{"id":"` + id + `"}}]}}}`
+			if elastic.Count(util.EsIndex, util.EsType, es_query) > 0 {
+				l["es"] = "已生成"
+			} else {
+				extracttype := qu.IntAll(l["extracttype"])
+				if extracttype == -1 {
+					l["es"] = "被判重"
+				} else if extracttype == 1 {
+					l["es"] = "ES异常"
+				} else {
+					l["es"] = "未生成"
+				}
+			}
+		}
 		AddVal(*list_bid, "bidding", &data)
+	} else if stype == "href" { //根据href查索引数据,反推bidding
+		es_query := `{"query":{"bool":{"must":[{"term":{"href":"` + text + `"}}]}},"_source":["_id"]}`
+		list := elastic.Get(util.EsIndex, util.EsType, es_query)
+		for _, l := range *list {
+			id := qu.ObjToString(l["_id"])
+			qu.Debug(id)
+			tmp, _ := util.JYMgo.FindById("bidding", id, nil)
+			if tmp != nil && len(*tmp) > 0 {
+				(*tmp)["es"] = "已生成"
+				(*tmp)["by"] = "bidding"
+				data = append(data, *tmp)
+			}
+		}
 	}
 	//2、找bidding_file附件信息
 	list_file, _ := util.JYMgo.Find("bidding_file", query, nil, nil, false, -1, -1)

+ 32 - 19
src/web/templates/lua/datafind.html

@@ -65,7 +65,7 @@
                                 <th>编号</th>
                                 <th>id</th>
                                 <th>标题</th>
-                                <th>链接</th>
+                                <th>发布时间</th>
                                 <th>来源</th>
                                 <th>索引</th>
                                 <th>操作</th>
@@ -112,26 +112,39 @@
             "columns": [
                 {"data": null,width:"5%"},
                 {"data": "_id"},
-                {"data": "title", width: "50%"},
-                {"data": function (row) {
-                        if (row.href) {
-                            var str = "链接地址"
-                            tmp = '<a class="" target="_blank" href=' + row.href + '>' + str + '</a>';
-                            return tmp
-                        } else {
-                            return ""
-                        }
-                    },  width: "10%"},
+                {"data": function(v,a,row){
+                        tmp = '<a class="" target="_blank" href=' + v.href + '>' + v.title + '</a>';
+                        return tmp
+                    }},
+                {"data":  function(v,a,row){
+                    var publishtime
+                    if (v.by == "spider_warn"){
+                        publishtime = v.data.publishtime
+                    }else{
+                        publishtime = v.publishtime
+                    }
+                    if (typeof publishtime == "number") {
+                        var dt = new Date()
+                        dt.setTime(parseInt(publishtime) * 1000);
+                        return dt.format("yyyy-MM-dd hh:mm:ss");
+                    }
+                    return publishtime
+                }},
                 {"data": "by"},
                 {"data": function (row) {
-                        if(row.extracttype == -1){
-                            return "被判重"
-                        }else if(row.extracttype == 1){
-                            return "已生成"
-                        }else{
-                            return "未生成"
-                        }
-                    }},
+                    if (row.by == "bidding"){
+                        return row.es
+                    }else{
+                        return "未生成"
+                    }
+                    // if(row.extracttype == -1){
+                    //     return "被判重"
+                    // }else if(row.extracttype == 1){
+                    //     return "已生成"
+                    // }else{
+                    //     return "未生成"
+                    // }
+                }},
                 {"data": function (row) {
                         return "<a href='/lua/dataview?coll="+row.by+"&id="+row._id+"' target='_blank' class='btn btn-sm btn-primary'>详情</a>"
                     }},