Przeglądaj źródła

铁塔,管理日志

xuzhiheng 1 rok temu
rodzic
commit
b6ff7a0eea

+ 27 - 0
CMPlatform/history/historytask.go

@@ -25,6 +25,7 @@ type HistoryData struct {
 	*xweb.Action
 	historyTask      xweb.Mapper `xweb:"/service/history/(.*)"`
 	historyList      xweb.Mapper `xweb:"/service/historylog/list"`
+	historyListAdmin xweb.Mapper `xweb:"/service/log/adminlist"`
 	historyClone     xweb.Mapper `xweb:"/service/historyClone/(.*)"`
 	historyRuleEdit  xweb.Mapper `xweb:"/service/historyRule/edit"`
 	productData      xweb.Mapper `xweb:"/service/history/produce"` //历史数据生成预览数据
@@ -214,6 +215,32 @@ func (this *HistoryData) HistoryList() {
 	}
 }
 
+func (this *HistoryData) HistoryListAdmin() {
+	if this.Method() == "POST" {
+		start, _ := this.GetInt("start")
+		limit, _ := this.GetInt("length")
+		draw, _ := this.GetInt("draw")
+		searchStr := this.GetString("search[value]")
+		search := strings.TrimSpace(searchStr)
+		query := map[string]interface{}{}
+		if search != "" {
+			query["$or"] = []interface{}{
+				bson.M{"s_name": bson.M{"$regex": search}},
+			}
+		}
+		data, _ := util.Mgo.Find("historylog", query, `{"_id":-1}`, nil, false, int(start), int(limit))
+		count := util.Mgo.Count("historylog", query)
+		this.ServeJson(map[string]interface{}{
+			"draw":            draw,
+			"data":            data,
+			"recordsFiltered": count,
+			"recordsTotal":    count,
+		})
+	} else {
+		this.Render("private/historylog_list_admin.html", &this.T)
+	}
+}
+
 func UpdateHistoryState(state int, history_id string, count int) {
 	if state == 2 {
 		util.Mgo.Update("historylog", map[string]interface{}{"_id": mongodb.StringTOBsonId(history_id)}, map[string]interface{}{

+ 2 - 0
CMPlatform/history/util_history.go

@@ -1545,6 +1545,8 @@ func GetXlsxs(mMap []map[string]interface{}, i_contact int, fn, email, id string
 			//var err error
 			if dataSource == 1 {
 				xf, err := xlsx.OpenFile("web/res/fields.xlsx")
+				xf := xlsx.NewFile()
+				sh, _ := xf.AddSheet("sheet")
 				if err != nil {
 					log.Println("fields file not foud", err.Error())
 				}

+ 22 - 21
CMPlatform/service/second_push.go

@@ -1,23 +1,24 @@
 package service
 
 import (
-	"app.yhyue.com/moapp/jybase/common"
-	"app.yhyue.com/moapp/jybase/encrypt"
-	"app.yhyue.com/moapp/jybase/go-xweb/log"
-	"app.yhyue.com/moapp/jybase/go-xweb/xweb"
-	"app.yhyue.com/moapp/jybase/mail"
-	"app.yhyue.com/moapp/jybase/mongodb"
 	"cmplatform/history"
 	"cmplatform/util"
 	"encoding/json"
 	"fmt"
-	"github.com/tealeg/xlsx"
-	"go.mongodb.org/mongo-driver/bson"
-	"go.mongodb.org/mongo-driver/bson/primitive"
+	"log"
 	"os"
 	"strconv"
 	"strings"
 	"time"
+
+	"app.yhyue.com/moapp/jybase/common"
+	"app.yhyue.com/moapp/jybase/encrypt"
+	"app.yhyue.com/moapp/jybase/go-xweb/xweb"
+	"app.yhyue.com/moapp/jybase/mail"
+	"app.yhyue.com/moapp/jybase/mongodb"
+	"github.com/tealeg/xlsx"
+	"go.mongodb.org/mongo-driver/bson"
+	"go.mongodb.org/mongo-driver/bson/primitive"
 )
 
 var (
@@ -222,7 +223,7 @@ func (s *SecondPush) SaveSpushRule() {
 }
 
 func (s *SecondPush) SecondPushTask() {
-	log.Debug("开始二次推送任务...")
+	log.Println("开始二次推送任务...")
 	s_pushid := s.GetString("s_pushid")
 	if s_pushid != "" {
 		customer, _ := util.Mgo.Find("second_push", map[string]interface{}{"_id": mongodb.StringTOBsonId(s_pushid)}, nil, nil, false, -1, -1)
@@ -238,7 +239,7 @@ func (s *SecondPush) SecondPushTask() {
 				if c["dep_rules"] != nil && len(c["dep_rules"].([]interface{})) != 0 {
 					idMap := map[primitive.ObjectID]bool{}
 					for _, m := range c["dep_rules"].([]interface{}) {
-						log.Debug("ruleid", mongodb.BsonIdToSId(m.(map[string]interface{})["_id"]))
+						log.Println("ruleid", mongodb.BsonIdToSId(m.(map[string]interface{})["_id"]))
 						q := bson.M{
 							"ruleid": bson.M{"$regex": mongodb.BsonIdToSId(m.(map[string]interface{})["_id"])},
 							"bget":   1,
@@ -274,7 +275,7 @@ func (s *SecondPush) SecondPushTask() {
 							"$lte": endtime,
 						},
 					}
-					d, _ := util.MgoCus.Find("usermail", q, nil, nil, false, 0, 0)
+					d, _ := util.MgoCus.Find("usermail", q, nil, nil, false, -1, -1)
 					for _, l := range *d {
 						// 项目匹配为"1" 以及项目id为空时进行项目id匹配   同时更新数据库
 						if projectIdSearch == "1" && (l["projectId"] == "" || l["projectId"] == nil) {
@@ -287,9 +288,9 @@ func (s *SecondPush) SecondPushTask() {
 					}
 				}
 				if len(xlsxArr) == 0 {
-					log.Debug("查询数据为空")
+					log.Println("查询数据为空")
 				} else {
-					log.Debug(len(xlsxArr))
+					log.Println(len(xlsxArr))
 					GetXlsxs(xlsxArr, customer_name, email, s_pushid, common.ObjToString(c["s_appid"]))
 					go UpdateHistoryState(2, s_pushid, len(xlsxArr))
 					s.ServeJson(map[string]interface{}{
@@ -299,7 +300,7 @@ func (s *SecondPush) SecondPushTask() {
 				}
 			}
 		} else {
-			log.Debug("初始化客户信息失败")
+			log.Println("初始化客户信息失败")
 		}
 
 	}
@@ -342,7 +343,7 @@ func GetProjectId(id string) string {
 			projectIdArr = append(projectIdArr, common.ObjToString(v["_id"]))
 		}
 		projectId = strings.Join(projectIdArr, ",")
-		log.Debug("id", id, "projectId", projectId)
+		log.Println("id", id, "projectId", projectId)
 	}
 	return projectId
 }
@@ -465,7 +466,7 @@ func GetXlsxs(mMap []map[string]interface{}, fn, email, id, appid string) {
 			dataType := common.IntAll((*data)["i_extfieldstype"])
 			xf, err := xlsx.OpenFile("web/res/fields.xlsx")
 			if err != nil {
-				log.Debug("fields file not foud", err.Error())
+				log.Println("fields file not foud", err.Error())
 			}
 			newFile := xlsx.NewFile()
 			style := xlsx.NewStyle()
@@ -1028,20 +1029,20 @@ func GetXlsxs(mMap []map[string]interface{}, fn, email, id, appid string) {
 			if b, _ := history.PathExists(dir); !b {
 				err1 := os.MkdirAll(dir, os.ModePerm)
 				if err1 != nil {
-					log.Debug("mkdir err", dir)
+					log.Println("mkdir err", dir)
 				}
 			}
 			fname := fmt.Sprintf("%s_%s_%s.xlsx", fn, t, common.GetRandom(4))
-			log.Debug("fname", fname)
+			log.Println("fname", fname)
 			err = newFile.Save(dir + fname)
 			if err != nil {
-				log.Debug("xls error", err, fname)
+				log.Println("xls error", err, fname)
 			} else {
 				for i := 0; i < len(history.Gmails); i++ {
 					gmail := history.Gmails[i]
 					status := mail.GSendMail_q("剑鱼标讯", email, "", "", fn, "", dir+fname, fname, gmail)
 					if status {
-						log.Debug("send mail success", fname, email)
+						log.Println("send mail success", fname, email)
 						break
 					}
 				}

+ 0 - 4
CMPlatform/web/templates/private/historylog_list.html

@@ -216,7 +216,6 @@
                                 '<a style="margin-left:10px" class="btn btn-sm btn-success" disabled>完成</a>' +
                                 '<a style="margin-left:10px" class="btn btn-sm btn-info" eid="' + val + '" onclick="cloneWork(this)">克隆</a>' +
                                 '<a style="margin-left:10px" class="btn btn-sm btn-success">判重完成</a>' +
-                                '<a style="margin-left:10px;background-color:red;border-color:red;" class="btn btn-sm btn-info" eid="' + val + '" onclick="deleteWork(this)">删除</a>' +
                                 '</div>';
                         } else if (row.state === 2) {
                             tmp = '<div>' +
@@ -224,21 +223,18 @@
                                 '<a style="margin-left:10px" class="btn btn-sm btn-success" disabled>完成</a>' +
                                 '<a style="margin-left:10px" class="btn btn-sm btn-info" eid="' + val + '" onclick="cloneWork(this)">克隆</a>' +
                                 '<a style="margin-left:10px" class="btn btn-sm btn-info" eid="' + val + '" onclick="biddingRepeat(this)">公告判重</a>' +
-                                '<a style="margin-left:10px;background-color:red;border-color:red;" class="btn btn-sm btn-info" eid="' + val + '" onclick="deleteWork(this)">删除</a>' +
                                 '</div>';
                         } else if (row.state === 1) {
                             tmp = '<div>' +
                                 '<a class="btn btn-sm btn-primary" href="/service/customer/history?id=' + row.user_id + '&hid=' + val + '&check=true&aid=' + row.s_appid + '">查看</a>' +
                                 '<a style="margin-left:10px" class="btn btn-sm btn-info">进行</a>' +
                                 '<a style="margin-left:10px" class="btn btn-sm btn-info" eid="' + val + '" onclick="cloneWork(this)">克隆</a>' +
-                                '<a style="margin-left:10px;background-color:red;border-color:red;" class="btn btn-sm btn-info" eid="' + val + '" onclick="deleteWork(this)">删除</a>' +
                                 '</div>';
                         } else {
                             tmp = '<div>' +
                                 '<a class="btn btn-sm btn-primary" href="/service/customer/history?id=' + row.user_id + '&hid=' + val + '&aid=' + row.s_appid + '">编辑</a>' +
                                 '<a style="margin-left:10px" class="btn btn-sm btn-default" eid="' + val + '" onclick="historyWork(this)">执行</a>' +
                                 '<a style="margin-left:10px" class="btn btn-sm btn-info" eid="' + val + '" onclick="cloneWork(this)">克隆</a>' +
-                                '<a style="margin-left:10px;background-color:red;border-color:red;" class="btn btn-sm btn-info" eid="' + val + '" onclick="deleteWork(this)">删除</a>' +
                                 '</div>';
                         }
                         return tmp

+ 198 - 0
CMPlatform/web/templates/private/historylog_list_admin.html

@@ -0,0 +1,198 @@
+{{include "com/inc.html"}}
+<!-- Main Header -->
+{{include "com/header.html"}}
+
+<div class="content-wrapper" id="showbtn">
+    <!-- Main content -->
+    <section class="content">
+        <div class="tab-content">
+            <div class="nav-tabs-custom">
+                <ul class="nav nav-tabs edit-step">
+                    <li class="active" data-mode="guide" id="showHistory"><a href="#tab_1" data-toggle="tab"
+                                                                             aria-expanded="true">历史任务</a></li>
+                </ul>
+                <div class="row" id="history-task-list">
+                    <div class="col-xs-12">
+                        <div class="box">
+                            <div class="box-body">
+                                <table id="dataTable" class="table table-bordered table-hover">
+                                    <thead>
+                                    <tr>
+                                        <th>序号</th>
+                                        <th>ID</th>
+                                        <th>客户名称</th>
+                                        <th>操作人</th>
+                                        <th>状态</th>
+                                        <th>数据总量</th>
+                                        <th>完成时间</th>
+                                        <th>推送方式</th>
+                                        <th>备注</th>
+                                    </tr>
+                                    </thead>
+                                </table>
+                            </div>
+                            <!-- /.box-body -->
+                        </div>
+                        <!-- /.box -->
+                    </div>
+                </div>
+                <div class="row" id="second-push-list" hidden>
+                    <div class="col-xs-12">
+                        <div class="box">
+                            <div class="box-body">
+                                <table id="sdataTable" class="table table-bordered table-hover">
+                                    <thead>
+                                    <tr>
+                                        <th>序号</th>
+                                        <th>ID</th>
+                                        <th>操作人</th>
+                                        <th>状态</th>
+                                        <th>数据总量</th>
+                                        <th>创建时间</th>
+                                        <th>完成时间</th>
+                                    </tr>
+                                    </thead>
+                                </table>
+                            </div>
+                            <!-- /.box-body -->
+                        </div>
+                        <!-- /.box -->
+                    </div>
+                </div>
+            </div>
+        </div>
+
+    </section>
+</div>
+{{include "com/footer.html"}}
+<script>
+    var historyId = "";
+    var goon;
+    function cancelModel() {
+        $('#modal-whether-filter').modal("hide");
+    }
+
+    $(function () {
+        ttable = $('#dataTable').DataTable({
+            "paging": true,
+            "lengthChange": false,
+            "searching": true,
+            "ordering": true,
+            "info": true,
+            "autoWidth": false,
+            "serverSide": true,
+            "ajax": {
+                "url": "/service/log/adminlist",
+                "type": "post",
+                "data": {
+                   
+                }
+            },
+            "language": {
+                "url": "/dist/js/dataTables.chinese.lang"
+            },
+            "fnDrawCallback": function () {
+                $("#dataTable_paginate ul.pagination").prepend(
+                    "&nbsp;&nbsp;&nbsp;转到第 <input type='text' id='changePage'   style='width:20px;'> 页    <a type='text' href='javascript:void(0);' id='dataTable-btn' style='text-align:center'>GO</a>"
+                );
+                $('#dataTable-btn').click(function (e) {
+                    var redirectpage = 0
+                    if ($("#changePage").val() && $("#changePage").val() > 0) {
+                        var redirectpage = $("#changePage").val() - 1;
+                    }
+                    ttable.page(redirectpage).draw(false);
+                });
+                this.api().column(0).nodes().each(function (cell, i) {
+                    cell.innerHTML = i + 1;
+                });
+            },
+            "columns": [{
+                "data": null,
+                width: "2%"
+            },
+                {
+                    "data": "_id"
+                },
+                {
+                    "data": "s_name",
+                    render: function (val) {
+                        if (val === undefined) {
+                            return ""
+                        } else {
+                            return val
+                        }
+                    }
+                },
+                {
+                    "data": "create_user",
+                    render: function (val) {
+                        if (val === undefined) {
+                            return ""
+                        } else {
+                            return val
+                        }
+                    }
+                },
+                {
+                    "data": "state",
+                    render: function (val) {
+                        var str = "";
+                        if (val === 0 || val === undefined) {
+                            str = "未执行";
+                        } else if (val === 1) {
+                            str = "未完成";
+                        } else if (val === 2) {
+                            str = "已完成";
+                        }
+                        return str
+                    }
+                },
+                {
+                    "data": "result_count",
+                    render: function (val) {
+                        if (val === undefined || val === null || val === "") {
+                            return "未执行"
+                        } else {
+                            return val
+                        }
+                    }
+                },
+
+                {
+                    "data": "finishtime",
+                    render: function (val) {
+                        if (val === undefined) {
+                            return "未执行"
+                        }
+                        var dt = new Date()
+                        dt.setTime(parseInt(val) * 1000)
+                        return dt.format("yyyy-MM-dd hh:mm:ss")
+                    }
+                },
+                {
+                    "data": "i_pushtype",
+                    render: function (val) {
+                        if (val == 0) {
+                            return "邮箱"
+                        } else {
+                            return "API"
+                        }
+                    }
+                },
+                {
+                    "data": "remarks",
+                    render: function (val) {
+                        if (val === undefined) {
+                            return ""
+                        } else {
+                            if (val.length > 10) {
+                                val = val.slice(0, 10) + "..."
+                            }
+                            return val
+                        }
+                    }
+                },
+            ]
+        });
+    });
+</script>