浏览代码

Merge branch 'dev3.3' of http://192.168.3.207:10080/qmx/jy-data-extract into dev3.3

fengweiqiang 5 年之前
父节点
当前提交
dce531ff79

+ 62 - 3
dataprocess/src/front/front.go

@@ -2,6 +2,7 @@ package front
 
 import (
 	qu "qfw/util"
+	"strconv"
 	"time"
 
 	. "../util"
@@ -10,6 +11,11 @@ import (
 	"gopkg.in/mgo.v2/bson"
 )
 
+var UserMenu map[string][]map[string]interface{} //存储菜单
+func init() {
+	UserMenu = make(map[string][]map[string]interface{})
+}
+
 type Front struct {
 	*xweb.Action
 	login     xweb.Mapper `xweb:"/"`                //登录页面
@@ -27,6 +33,15 @@ type Front struct {
 	menuSecond     xweb.Mapper `xweb:"/front/menuSecond"`      //查二级菜单
 	menuSecondSave xweb.Mapper `xweb:"/front/menuSecond/save"` //保存二级菜单
 	menuSecondDel  xweb.Mapper `xweb:"/front/menuSecond/del"`  //删除二级菜单
+	personalMenu   xweb.Mapper `xweb:"/front/personalMenu"`
+	//role
+	roleManager    xweb.Mapper `xweb:"/front/role"`             //角色权限管理
+	roleEdit       xweb.Mapper `xweb:"/front/role/edit/(.*)"`   //角色权限查看
+	roleFirst      xweb.Mapper `xweb:"/front/role/first"`       //一级权限的查看
+	roleSecond     xweb.Mapper `xweb:"/front/role/second"`      //二级权限的查看
+	roleSave       xweb.Mapper `xweb:"/front/role/edit/save"`   //权限编辑保存
+	roleDel        xweb.Mapper `xweb:"/front/role/edit/del"`    //权限编辑删除
+	roleSecondEdit xweb.Mapper `xweb:"/front/role/second/edit"` //二级权限编辑
 
 }
 
@@ -43,7 +58,7 @@ func (f *Front) Login() {
 		}
 		user, _ := Mgo.FindOne("user", query)
 		checked := false
-		if (*user) != nil {
+		if user != nil && len(*user) > 0 {
 			checked = true
 			f.SetSession("user", map[string]interface{}{
 				"name":  (*user)["s_name"],
@@ -52,6 +67,7 @@ func (f *Front) Login() {
 				"email": email,
 				"id":    qu.BsonIdToSId((*user)["_id"]),
 			})
+			UserMenu[email] = GetUserMenu(qu.ObjToString((*user)["s_role"]))
 		}
 		f.ServeJson(map[string]interface{}{
 			"checked": checked,
@@ -59,7 +75,6 @@ func (f *Front) Login() {
 	} else {
 		f.Render("login.html")
 	}
-
 }
 
 func (f *Front) Index() {
@@ -92,7 +107,12 @@ func (f *Front) UpdatePwd() {
 func (f *Front) User() {
 	defer qu.Catch()
 	if f.Method() == "POST" {
-		data, _ := Mgo.Find("user", nil, `{"_id":1}`, nil, false, -1, -1)
+		query := bson.M{
+			"s_role": bson.M{
+				"$ne": "0",
+			},
+		}
+		data, _ := Mgo.Find("user", query, `{"_id":1}`, nil, false, -1, -1)
 		for _, d := range *data {
 			d["s_pwd"] = qu.SE.DecodeString(qu.ObjToString(d["s_pwd"]))
 		}
@@ -146,3 +166,42 @@ func (f *Front) UserSave() {
 		"rep": b,
 	})
 }
+
+func (f *Front) PersonalMenu() {
+	user := f.GetSession("user").(map[string]interface{})
+	list := UserMenu[qu.ObjToString(user["email"])]
+	f.ServeJson(map[string]interface{}{
+		"data": list,
+	})
+}
+
+func GetUserMenu(role string) []map[string]interface{} {
+	list := []map[string]interface{}{}
+	maps := map[string]interface{}{
+		"delete": false,
+	}
+	if role != "0" {
+		maps["role."+role] = true
+	}
+	data, _ := Mgo.Find("menu_first", maps, nil, nil, false, -1, -1)
+	for _, d := range *data {
+		_id := d["_id"]
+		maps = map[string]interface{}{
+			"delete": false,
+			"s_pid":  qu.BsonIdToSId(_id),
+		}
+		if role != "0" {
+			maps["role."+role] = true
+		}
+		secdatas, _ := Mgo.Find("menu_second", maps, nil, nil, false, -1, -1)
+		secmenumap := map[string]interface{}{}
+		for index, secdata := range *secdatas {
+			secmenumap[strconv.Itoa(index+1)] = secdata
+		}
+		if len(secmenumap) != 0 {
+			d["secondmenu"] = secmenumap
+		}
+		list = append(list, d)
+	}
+	return list
+}

+ 3 - 1
dataprocess/src/front/memu.go → dataprocess/src/front/menu.go

@@ -65,6 +65,9 @@ func (f *Front) MenuDel() {
 		},
 	}
 	b := Mgo.Update("menu_first", query, set, false, false)
+	if b { //删除一级菜单下的二级菜单
+		Mgo.Update("menu_second", `{"s_pid":"`+_id+`"}`, set, false, true)
+	}
 	f.ServeJson(map[string]interface{}{
 		"rep": b,
 	})
@@ -82,7 +85,6 @@ func (f *Front) MenuSecond() {
 		f.T["id"] = id
 		f.Render("com/menu_second.html", &f.T)
 	}
-
 }
 
 func (f *Front) MenuSecondSave() {

+ 183 - 0
dataprocess/src/front/role.go

@@ -1 +1,184 @@
 package front
+
+import (
+	"encoding/json"
+	qu "qfw/util"
+
+	. "../util"
+
+	"gopkg.in/mgo.v2/bson"
+)
+
+func (f *Front) RoleManager() {
+	defer qu.Catch()
+	f.Render("com/role.html")
+}
+
+func (f *Front) RoleEdit(role string) {
+	defer qu.Catch()
+	if f.Method() == "POST" {
+		maps := map[string]interface{}{
+			"role." + role: true,
+		}
+		data, _ := Mgo.Find("menu_first", maps, nil, nil, false, -1, -1)
+		f.ServeJson(map[string]interface{}{
+			"data": data,
+		})
+	} else {
+		f.T["role"] = role
+		f.Render("com/role_edit.html", &f.T)
+	}
+}
+
+func (f *Front) RoleFirst() {
+	defer qu.Catch()
+	data, _ := Mgo.Find("menu_first", `{"delete":false}`, nil, nil, false, -1, -1)
+	f.ServeJson(map[string]interface{}{
+		"data": data,
+	})
+}
+
+func (f *Front) RoleSecond() {
+	defer qu.Catch()
+	pid := f.GetString("_pid")
+	query := bson.M{
+		"s_pid": pid,
+	}
+	data, _ := Mgo.Find("menu_second", query, nil, nil, false, -1, -1)
+	f.ServeJson(map[string]interface{}{
+		"data": data,
+	})
+}
+
+func (f *Front) RoleSave() {
+	defer qu.Catch()
+	pid := f.GetString("_id")
+	role := f.GetString("role")
+	secondStr := f.GetString("secondStr")   //右边 选中的
+	secondStr1 := f.GetString("secondStr1") //左边 未选中的
+
+	secondmenus := make([]string, 0)
+	secondmenus1 := make([]string, 0)
+	s_id := json.Unmarshal([]byte(secondStr), &secondmenus)
+	s_id1 := json.Unmarshal([]byte(secondStr1), &secondmenus1)
+
+	if s_id == nil && s_id1 == nil {
+		for _, v := range secondmenus {
+			maps := map[string]interface{}{
+				"_id": bson.ObjectIdHex(v),
+			}
+			data := map[string]interface{}{
+				"role." + role: true,
+			}
+			data1 := map[string]interface{}{
+				"$set": data,
+			}
+			Mgo.Update("menu_second", maps, data1, true, false)
+		}
+		for _, v := range secondmenus1 {
+			maps := map[string]interface{}{
+				"_id": bson.ObjectIdHex(v),
+			}
+			data := map[string]interface{}{
+				"role." + role: false,
+			}
+			data1 := map[string]interface{}{
+				"$set": data,
+			}
+			Mgo.Update("menu_second", maps, data1, true, false)
+		}
+	}
+	b := false
+	if (len(secondmenus) == 0 && len(secondmenus1) == 0) || (len(secondmenus) > 0) {
+		maps := map[string]interface{}{
+			"_id": bson.ObjectIdHex(pid),
+		}
+		data := map[string]interface{}{
+			"role." + role: true,
+		}
+		data1 := map[string]interface{}{
+			"$set": data,
+		}
+		b = Mgo.Update("menu_first", maps, data1, true, false)
+	}
+	if len(secondmenus) == 0 && len(secondmenus1) > 0 {
+		maps := map[string]interface{}{
+			"_id": bson.ObjectIdHex(pid),
+		}
+		data := map[string]interface{}{
+			"role." + role: false,
+		}
+		data1 := map[string]interface{}{
+			"$set": data,
+		}
+		b = Mgo.Update("menu_first", maps, data1, true, false)
+	}
+	f.ServeJson(map[string]interface{}{
+		"rep": b,
+	})
+}
+
+func (f *Front) RoleDel() {
+	defer qu.Catch()
+	_id := f.GetString("_id")
+	role := f.GetString("role")
+	maps := map[string]interface{}{
+		"_id": bson.ObjectIdHex(_id),
+	}
+	data := map[string]interface{}{
+		"role." + role: false,
+	}
+	data1 := map[string]interface{}{
+		"$set": data,
+	}
+	b := Mgo.Update("menu_first", maps, data1, true, false)
+	maps = map[string]interface{}{
+		"s_pid": _id,
+	}
+	count, _ := Mgo.Find("menu_second", maps, nil, nil, false, -1, -1)
+	if len(*count) != 0 {
+		for _, c := range *count {
+			maps = map[string]interface{}{
+				"_id": c["_id"],
+			}
+			Mgo.Update("menu_second", maps, data1, true, false)
+		}
+	}
+	f.ServeJson(map[string]interface{}{
+		"rep": b,
+	})
+}
+
+func (f *Front) RoleSecondEdit() {
+	defer qu.Catch()
+	menuid := f.GetString("_id")
+	mark := f.GetString("mark")
+	role := f.GetString("role")
+	if mark == "" {
+		maps := map[string]interface{}{
+			"s_pid": menuid,
+		}
+		datas, _ := Mgo.Find("menu_second", maps, nil, nil, false, -1, -1)
+		f.ServeJson(map[string]interface{}{
+			"data": datas,
+		})
+	} else {
+		maps := map[string]interface{}{
+			"s_pid":        menuid,
+			"role." + role: true,
+		}
+		data, _ := Mgo.Find("menu_second", maps, nil, nil, false, -1, -1)
+		maps1 := map[string]interface{}{
+			"s_pid":        menuid,
+			"role." + role: false,
+		}
+		name, _ := Mgo.FindById("menu_first", menuid, `{s_name:1}`)
+		s_name := (*name)["s_name"]
+		data1, _ := Mgo.Find("menu_second", maps1, nil, nil, false, -1, -1)
+		f.ServeJson(map[string]interface{}{
+			"name":  s_name,
+			"data":  data,
+			"data1": data1,
+		})
+	}
+}

+ 27 - 0
dataprocess/src/logic/logic.go

@@ -0,0 +1,27 @@
+package logic
+
+import (
+	qu "qfw/util"
+
+	. "../util"
+
+	"github.com/go-xweb/xweb"
+)
+
+type Logic struct {
+	*xweb.Action
+	logicList xweb.Mapper `xweb:"/logic/list"` //查询所有任务
+
+}
+
+func (l *Logic) LogicList() {
+	defer qu.Catch()
+	if l.Method() == "POST" {
+		data, _ := Mgo.Find("task", `{"delete":false}`, nil, nil, false, -1, -1)
+		l.ServeJson(map[string]interface{}{
+			"data": data,
+		})
+	} else {
+		l.Render("com/logic_list.html")
+	}
+}

+ 7 - 2
dataprocess/src/main.go

@@ -4,9 +4,11 @@ import (
 	qu "qfw/util"
 	"time"
 
-	. "./util"
-
 	"./front"
+	"./logic"
+	"./microservice"
+	"./task"
+	. "./util"
 
 	"github.com/go-xweb/xweb"
 )
@@ -27,6 +29,9 @@ func init() {
 	xweb.RootApp().AppConfig.Mode = xweb.Product
 	xweb.RootApp().AppConfig.CacheTemplates = false
 	xweb.AddAction(&front.Front{})
+	xweb.AddAction(&task.Task{})
+	xweb.AddAction(&logic.Logic{})
+	xweb.AddAction(&microservice.Service{})
 	xweb.RootApp().AppConfig.SessionTimeout = 1 * time.Hour
 	xweb.RootApp().Logger.SetOutputLevel(4)
 	//xweb.AddTmplVar("add", func(a, b int) int { return a + b })

+ 27 - 0
dataprocess/src/microservice/microservice.go

@@ -0,0 +1,27 @@
+package microservice
+
+import (
+	qu "qfw/util"
+
+	. "../util"
+
+	"github.com/go-xweb/xweb"
+)
+
+type Service struct {
+	*xweb.Action
+	serviceList xweb.Mapper `xweb:"/microservice/list"` //查询所有任务
+
+}
+
+func (s *Service) ServiceList() {
+	defer qu.Catch()
+	if s.Method() == "POST" {
+		data, _ := Mgo.Find("task", `{"delete":false}`, nil, nil, false, -1, -1)
+		s.ServeJson(map[string]interface{}{
+			"data": data,
+		})
+	} else {
+		s.Render("com/microservice_list.html")
+	}
+}

+ 83 - 0
dataprocess/src/task/task.go

@@ -0,0 +1,83 @@
+package task
+
+import (
+	qu "qfw/util"
+	"strings"
+	"time"
+
+	. "../util"
+
+	"github.com/go-xweb/xweb"
+	"gopkg.in/mgo.v2/bson"
+)
+
+type Task struct {
+	*xweb.Action
+	taskList  xweb.Mapper `xweb:"/task/list"`  //查询所有任务
+	taskSave  xweb.Mapper `xweb:"/task/save"`  //保存任务
+	taskDel   xweb.Mapper `xweb:"/task/del"`   //删除任务
+	taskStope xweb.Mapper `xweb:"/task/start"` //启动任务
+	taskStop  xweb.Mapper `xweb:"/task/stop"`  //停止任务
+}
+
+func (t *Task) TaskList() {
+	defer qu.Catch()
+	if t.Method() == "POST" {
+		data, _ := Mgo.Find("task", `{"delete":false}`, nil, nil, false, -1, -1)
+		t.ServeJson(map[string]interface{}{
+			"data": data,
+		})
+	} else {
+		t.Render("com/task_list.html")
+	}
+}
+
+func (t *Task) TaskSave() {
+	//判断存储配置是否完整
+	s_mgosavecoll := t.GetString("s_mgosavecoll")
+	strs := strings.Split(s_mgosavecoll, "/")
+	if len(strs) < 3 {
+		t.ServeJson(map[string]interface{}{
+			"rep": false,
+			"msg": "保存表输入地址不正确!",
+		})
+		return
+	}
+	_id := t.GetString("_id")
+	data := GetPostForm(t.Request)
+	b := false
+	if _id == "" {
+		data["delete"] = false
+		data["l_comeintime"] = time.Now().Unix()
+		session := t.GetSession("user").(map[string]interface{})
+		data["s_username"] = session["name"].(string)
+		data["s_userid"] = session["id"].(string)
+		data["i_runstate"] = 0
+		b = Mgo.Save("task", data) != ""
+	} else {
+		data["l_lasttime"] = time.Now().Unix()
+		b = Mgo.Update("task", `{"_id":"`+_id+`"}`, map[string]interface{}{
+			"$set": data,
+		}, false, false)
+	}
+	t.ServeJson(map[string]interface{}{
+		"rep": b,
+	})
+}
+
+func (t *Task) TaskDel() {
+	_id := t.GetString("_id")
+	query := bson.M{
+		"_id": qu.StringTOBsonId(_id),
+	}
+	set := bson.M{
+		"$set": bson.M{
+			"delete": true,
+		},
+	}
+	b := Mgo.Update("task", query, set, false, false)
+	t.ServeJson(map[string]interface{}{
+		"rep": b,
+	})
+
+}

+ 35 - 0
dataprocess/src/util/util.go

@@ -0,0 +1,35 @@
+package util
+
+import (
+	"net/http"
+	"strconv"
+)
+
+//数据类型转换
+func GetPostForm(r *http.Request) map[string]interface{} {
+	val := map[string]interface{}{}
+	for k, _ := range r.Form {
+		if len(k) < 2 {
+			continue
+		}
+		if k != "_id" {
+			v := r.FormValue(k)
+			switch k[:2] {
+			case "s_": //string型
+				val[k] = v
+			case "l_": //int64位
+				val[k], _ = strconv.ParseInt(v, 10, 64)
+			case "i_": //int型
+				val[k], _ = strconv.Atoi(v)
+			default:
+				if v == "true" || v == "false" {
+					b, _ := strconv.ParseBool(v)
+					val[k] = b
+				} else {
+					val[k] = v
+				}
+			}
+		}
+	}
+	return val
+}

+ 1 - 3
dataprocess/src/web/templates/com/dialog.html

@@ -1,4 +1,3 @@
-{{ define "dialog" }}
 <div class="modal fade" id="myModal" tabindex="-1" role="dialog" 
    aria-labelledby="myModalLabel" aria-hidden="true" data-backdrop="static" data-keyboard="false">
    <div class="modal-dialog">
@@ -24,5 +23,4 @@
       </div><!-- /.modal-content -->
    </div><!-- /.modal-dialog -->
 </div><!-- /.modal -->
-<script src="./js/dialog.js"></script>
-{{end}}
+<script src="/js/dialog.js"></script>

+ 3 - 3
dataprocess/src/web/templates/com/header.html

@@ -84,13 +84,13 @@
 				     	<select id="t_role" class="form-control" disabled>
 							<option value={{(session "user").role}}>
 							<script>
-								role={{session "role"}}
+								role={{(session "user").role}};
 								if(role=="2"){
 									document.write("开发员")
 								}else if(role=="1"){
-									document.write("审核员")
-								}else{
 									document.write("管理员")
+								}else{
+									document.write("系统管理员")
 								}
 							</script>
 							</option>

+ 251 - 0
dataprocess/src/web/templates/com/logic_list.html

@@ -0,0 +1,251 @@
+{{include "com/inc.html"}}
+<!-- Main Header -->
+{{include "com/header.html"}}
+<!-- Left side column. 权限菜单 -->
+{{include "com/menu.html"}}
+
+<div class="content-wrapper" id="showbtn">
+	<section class="content-header">
+		<h1>
+			<small><a class="btn btn-primary opr" opr="new">新增任务</a></small>
+		</h1>
+		<ol class="breadcrumb">
+		  <li><a href="/admin/task/list"><i class="fa fa-dashboard"></i> 任务管理</a></li>		  
+		</ol>
+    </section>
+  <!-- Main content -->
+  <section class="content">
+      <div class="row">
+	      <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>创建时间</th> <th>创建人</th> <th>描述</th><th>运行状态</th> <th>操作</th>
+		              </tr>
+		              </thead>
+		            </table>
+		        </div>
+	          <!-- /.box-body -->
+	        </div>
+        <!-- /.box -->
+		</div>
+	</div>
+  </section>
+</div>
+{{include "com/dialog.html"}}
+{{include "com/footer.html"}}
+<script>
+menuActive("list")
+$(function () {
+	ttable=$('#dataTable').DataTable({
+		"paging"      : false,
+		"lengthChange": false,
+		"searching"   : false,
+		"ordering"    : false,
+		"info"        : true,
+		"autoWidth"   : false,
+		"ajax": {
+			"url": "/logic/list",
+			"type": "post",
+			"data":{}
+		 },
+		"language": {
+            "url": "/dist/js/dataTables.chinese.lang"
+        },
+		"columns": [
+            { "data": "s_taskname"},
+			{ "data": "l_comeintime",render:function(val){
+				var dt=new Date()
+				dt.setTime(parseInt(val)*1000)
+				return dt.format("yyyy-MM-dd hh:mm:ss")
+			}},
+			{ "data": "s_username"},
+			{ "data": "s_descript","width":"25%"},
+			{ "data": "i_runstate",render:function(val){
+				if(val==1){
+					return "<i class='fa fa-fw fa-circle text-green'></i>运行中"
+				}else{
+					return "<i class='fa fa-fw fa-circle text-danger'></i>未启动"
+				}
+			}},
+			{ "data":"_id","width":"25%",render:function(val,a,row,pos){
+				tmp = '<div>'+
+					'<a class="btn btn-sm btn-primary opr" opr="edit" row="'+pos.row+'" >编辑</a> '+
+					'<a class="btn btn-sm btn-success opr" opr="start" onclick="start(\''+row._id+'\')">启动</a> '+
+					'<a class="btn btn-sm btn-info opr" opr="stop" onclick="stop(\''+row._id+'\')">停止</a> '+
+					'<a class="btn btn-sm btn-danger opr" opr="del" onclick="del(\''+val+'\')">删除</a>'+
+					'</div>';
+				return  tmp
+			}}
+       	]
+	});
+	ttable.on('init.dt', function () {
+		$("#showbtn").on('click','a.opr',function(){
+			var n=$(this).attr("opr");
+			var taskid=$(this).attr("taskid");
+			var htmlObj={},obj,tag=[],bts=[];
+			var _tit="";
+			switch(n){
+			case "edit":			
+				obj=ttable.row($(this).closest("tr")).data();	
+			case "new":
+				/*表单*/
+				addtask=[
+					{label:"任务名称",s_label:"s_taskname",placeholder:"数据清洗",must:true},
+					{label:"源库连接",s_label:"s_mgoaddr",must:true},
+					{label:"源数据库",s_label:"s_mgodb",must:true},
+					{label:"源表",s_label:"s_mgocoll",must:true},
+					{label:"保存表",s_label:"s_mgosavecoll",placeholder:"127.0.0.1:27080/dataprocess/bidding(数据库地址/数据库/表)",must:true},
+					{label:"描述",s_label:"s_descript",type:"tpl_text"},
+					/*
+					{label:"是否追踪",s_label:"i_track",type:"tpl_list_local",must:true,list:[{"s_name":"是","_id":1},{"s_name":"否","_id":0}],default:0,fun:function(){
+						var to=$("#i_track")					
+						to.val($(this).attr("_id"))
+						$("#s_show",to.closest("div")).val($(this).text())
+						//追踪表样式
+						$("#s_trackcoll").attr("must",$(this).attr("_id")==1)
+						$("#s_trackcoll").closest("div.row").find("label").css("color",$(this).attr("_id")==1?"red":"")
+					}},
+					{label:"追踪记录表",s_label:"s_trackcoll",must:function(){
+						return  obj&&obj.i_track
+					}()},
+					{label:"是否统计",s_label:"i_count",type:"tpl_list_local",must:true,list:[{"s_name":"是","_id":1},{"s_name":"否","_id":0}],default:0},
+					*/
+					//{label:"使用版本",s_label:"s_version",type:"tpl_list_local",must:true,url:"/admin/task/getversion"},
+					{label:"并发数量",s_label:"i_process",placeholder:"5",must:true},
+					{label:"预处理逻辑",s_label:"s_preprocesslogic",type:"tpl_list_local",url:""},
+					{label:"匹配逻辑",s_label:"s_class",type:"tpl_list_ajax",url:"",fun:function(){
+						var ids=$("#s_class").data("ids")
+						var parentDiv=$("#s_class").closest("div")
+						ids=ids||{}
+						var tid=$(this).attr("_id")
+						if(!ids[tid]){
+							ids[tid]=true
+							$("#s_class").data("ids",ids)
+							var tpl1=$('<div class="alert alert-dismissible alert-success" style="min-width:50px;max-width:250px;font-size:10px;padding:3px;margin:5px;display:inline-block"><button type="button" class="close" data-dismiss="alert" style="right:0px;">&times;</button><span></span></div>')
+							tpl1.find("span").text($(this).text())							
+							tpl1.attr("tid",tid)
+							tpl1.find("button").click(function(){
+								var ttid=$(this).closest(".alert").attr("tid");
+								var iids=$("#s_class").data("ids")
+								delete iids[ttid]
+								$("#s_class").val(function(){
+									var strid=[]
+									for(var k in iids){
+										strid.push(k)
+									}
+									return strid.join(",")
+								}())
+							})
+							$("#s_show",parentDiv).append(tpl1)
+							$("#s_class").val(function(){
+								var strid=[]
+								for(var k in ids){
+									strid.push(k)
+								}
+								return strid.join(",")
+							}())
+						}
+					}},
+					//{label:"匹配逻辑",s_label:"s_matchlogic",type:"tpl_list_local",url:""},
+					{label:"字段",s_label:"s_field",placeholder:"title"},
+					{label:"起始id",s_label:"s_extlastid",must:true},
+					{s_label:"_id",type:"tpl_hidden"},
+				];
+				/*testtask=[
+					{label:"起始id",s_label:"s_startid",must:true},
+					{label:"数据数量",s_label:"s_datanum",placeholder:"5",must:true}
+				];*/
+				/*按钮*/
+				//新增保存按钮
+				addtaskbtn=[
+					{label:"保存",class:"btn-primary",
+						fun:function(){
+							var obj={}
+							var bcon=true
+							$("#_con").find("input[id!=s_show],textarea").each(function(i,el){
+								var val=$(el).val();
+								if(el.id!="_id"&&$(el).attr("must")&&!val){
+									bcon=false
+									return false
+								}
+								obj[el.id]=$(el).val()
+							})
+							if (bcon){								
+								$.post("/task/save",obj,function(data){
+									if(data&&data.rep){
+										//window.location.href="/task/list"
+										$('#myModal').modal('hide');
+										ttable.ajax.reload();
+									}else{
+										alert(data.msg)
+									}
+								},'json')
+							}else{
+								alert("红色标签的表单不能为空!")
+							}
+						}
+					}
+				];
+				if(n == "new"){
+					_tit="新增抽取任务";
+					tag = com.pushArry(tag,addtask);
+					bts = com.pushArry(bts,addtaskbtn);
+				}else if(n == "edit"){
+					_tit="编辑-"+obj.s_taskname;
+					tag = com.pushArry(tag,addtask);
+					bts = com.pushArry(bts,addtaskbtn);
+				}
+				htmlObj={
+					title:_tit,
+					tag:tag,
+					bts:bts
+				}
+			OpenDialog(htmlObj,obj)
+			break;
+			}
+		});
+	})
+	
+})
+function start(_id){
+	showConfirm("确定启动?", function() {
+		$.ajax({
+			url:"/task/start",
+			type:"post",
+			data:{"_id":_id},
+			success:function(r){
+				//window.location.reload();
+				ttable.ajax.reload();
+			}
+		})
+	});
+}
+function stop(_id){
+	showConfirm("确定停止?", function() {
+		$.ajax({
+			url:"/task/stop",
+			type:"post",
+			data:{"_id":_id},
+			success:function(r){
+				//window.location.reload()
+				ttable.ajax.reload();
+			}
+		})
+	});
+}
+function del(_id){
+	showConfirm("确定启动?", function() {
+		$.ajax({
+			url:"/task/del",
+			type:"post",
+			data:{"_id":_id},
+			success:function(r){
+				ttable.ajax.reload();
+			}
+		})
+	});
+}
+</script>

+ 12 - 11
dataprocess/src/web/templates/com/menu.html

@@ -3,7 +3,8 @@
       <ul id="menu" class="sidebar-menu" data-widget="tree">
         <li class="header">HEADER</li>
         <!-- Optionally, you can add icons to the links -->
-        <li class="treeview">
+        <!--
+		<li class="treeview">
           	<a href="#"><i class="fa fa-clock-o"></i> <span>任务管理</span>
             <span class="pull-right-container">
                 <i class="fa fa-angle-left pull-right"></i>
@@ -38,26 +39,26 @@
 				<li><a href="/admin/rule/pre"><i class="fa fa-circle-o"></i>角色管理</a></li>
 				<li><a href="/front/menu"><i class="fa fa-circle-o"></i>菜单管理</a></li>
 			</ul>
-		</li>
+		</li>-->
       </ul>
     </section>
-	<!--<span id="role" class="hidden">{{session "role"}}</span>-->
+	<span id="role" class="hidden">{{(session "user").role}}</span>
 </aside>
 <script>
-/**$(function () {
-	$.post('/admin/menu','',function (data,status) {
+$(function () {
+	$.post('/front/personalMenu','',function (data,status) {
 		for(var a=0;a<data.data.length;a++) {
             var info=data.data[a]
 		    if (info.secondmenu){
                 var str=""
-                for(var sec=1;sec<=Object.keys(info.secondmenu).length;sec++){
+               	for(var sec=1;sec<=Object.keys(info.secondmenu).length;sec++){
                     var ro=$("#role").text()
-                    if(ro=="3" || info.secondmenu[sec.toString(10)].role[ro] ) {
-                        str = str + '<li><a href=' + info.secondmenu[sec.toString(10)].href + '><i class="' + info.secondmenu[sec.toString(10)].pic + '"></i>' + info.secondmenu[sec.toString(10)].name + '</a></li>'
+                    if(ro=="0" || info.secondmenu[sec.toString(10)].role[ro] ) {
+                        str = str + '<li><a href=' + info.secondmenu[sec.toString(10)].s_href + '><i class="' + info.secondmenu[sec.toString(10)].s_css + '"></i>' + info.secondmenu[sec.toString(10)].s_name + '</a></li>'
                     }
                 }
                 $('#menu').append('<li class="treeview">' +
-                        '          <a href="#"><i class="'+info.pic+'"></i> <span>'+info.name+'</span>' +
+                        '          <a href="#"><i class="'+info.s_css+'"></i> <span>'+info.s_name+'</span>' +
                         '            <span class="pull-right-container">' +
                         '                <i class="fa fa-angle-left pull-right"></i>' +
                         '            </span>' +
@@ -65,11 +66,11 @@
                         '          <ul class="treeview-menu">' + str+ '</ul>' +
                         '        </li>')
 			}else{
-                $('#menu').append('<li><a href='+info.href+'><i class="'+info.pic+'"></i> <span>'+info.name+'</span></a></li>')
+                $('#menu').append('<li><a href='+info.s_href+'><i class="'+info.s_css+'"></i> <span>'+info.s_name+'</span></a></li>')
 			}
         }
     })
-})*/
+})
 function menuActive(name){
     setTimeout(function(){
         $(".sidebar-menu").tree();

+ 1 - 1
dataprocess/src/web/templates/com/menu_first.html

@@ -144,7 +144,7 @@
 		var name=$("#modal-info #name").val();
 		var href=$("#modal-info #href").val();
 		var css=$("#modal-info #css").val();
-		if(name==""||href==""||css==""){
+		if(name==""||css==""){
 			alert("表单填写不完整!")
 			return false;
 		}

+ 251 - 0
dataprocess/src/web/templates/com/microservice_list.html

@@ -0,0 +1,251 @@
+{{include "com/inc.html"}}
+<!-- Main Header -->
+{{include "com/header.html"}}
+<!-- Left side column. 权限菜单 -->
+{{include "com/menu.html"}}
+
+<div class="content-wrapper" id="showbtn">
+	<section class="content-header">
+		<h1>
+			<small><a class="btn btn-primary opr" opr="new">新增任务</a></small>
+		</h1>
+		<ol class="breadcrumb">
+		  <li><a href="/admin/task/list"><i class="fa fa-dashboard"></i> 任务管理</a></li>		  
+		</ol>
+    </section>
+  <!-- Main content -->
+  <section class="content">
+      <div class="row">
+	      <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>创建时间</th> <th>创建人</th> <th>描述</th><th>运行状态</th> <th>操作</th>
+		              </tr>
+		              </thead>
+		            </table>
+		        </div>
+	          <!-- /.box-body -->
+	        </div>
+        <!-- /.box -->
+		</div>
+	</div>
+  </section>
+</div>
+{{include "com/dialog.html"}}
+{{include "com/footer.html"}}
+<script>
+menuActive("list")
+$(function () {
+	ttable=$('#dataTable').DataTable({
+		"paging"      : false,
+		"lengthChange": false,
+		"searching"   : false,
+		"ordering"    : false,
+		"info"        : true,
+		"autoWidth"   : false,
+		"ajax": {
+			"url": "/microservice/list",
+			"type": "post",
+			"data":{}
+		 },
+		"language": {
+            "url": "/dist/js/dataTables.chinese.lang"
+        },
+		"columns": [
+            { "data": "s_taskname"},
+			{ "data": "l_comeintime",render:function(val){
+				var dt=new Date()
+				dt.setTime(parseInt(val)*1000)
+				return dt.format("yyyy-MM-dd hh:mm:ss")
+			}},
+			{ "data": "s_username"},
+			{ "data": "s_descript","width":"25%"},
+			{ "data": "i_runstate",render:function(val){
+				if(val==1){
+					return "<i class='fa fa-fw fa-circle text-green'></i>运行中"
+				}else{
+					return "<i class='fa fa-fw fa-circle text-danger'></i>未启动"
+				}
+			}},
+			{ "data":"_id","width":"25%",render:function(val,a,row,pos){
+				tmp = '<div>'+
+					'<a class="btn btn-sm btn-primary opr" opr="edit" row="'+pos.row+'" >编辑</a> '+
+					'<a class="btn btn-sm btn-success opr" opr="start" onclick="start(\''+row._id+'\')">启动</a> '+
+					'<a class="btn btn-sm btn-info opr" opr="stop" onclick="stop(\''+row._id+'\')">停止</a> '+
+					'<a class="btn btn-sm btn-danger opr" opr="del" onclick="del(\''+val+'\')">删除</a>'+
+					'</div>';
+				return  tmp
+			}}
+       	]
+	});
+	ttable.on('init.dt', function () {
+		$("#showbtn").on('click','a.opr',function(){
+			var n=$(this).attr("opr");
+			var taskid=$(this).attr("taskid");
+			var htmlObj={},obj,tag=[],bts=[];
+			var _tit="";
+			switch(n){
+			case "edit":			
+				obj=ttable.row($(this).closest("tr")).data();	
+			case "new":
+				/*表单*/
+				addtask=[
+					{label:"任务名称",s_label:"s_taskname",placeholder:"数据清洗",must:true},
+					{label:"源库连接",s_label:"s_mgoaddr",must:true},
+					{label:"源数据库",s_label:"s_mgodb",must:true},
+					{label:"源表",s_label:"s_mgocoll",must:true},
+					{label:"保存表",s_label:"s_mgosavecoll",placeholder:"127.0.0.1:27080/dataprocess/bidding(数据库地址/数据库/表)",must:true},
+					{label:"描述",s_label:"s_descript",type:"tpl_text"},
+					/*
+					{label:"是否追踪",s_label:"i_track",type:"tpl_list_local",must:true,list:[{"s_name":"是","_id":1},{"s_name":"否","_id":0}],default:0,fun:function(){
+						var to=$("#i_track")					
+						to.val($(this).attr("_id"))
+						$("#s_show",to.closest("div")).val($(this).text())
+						//追踪表样式
+						$("#s_trackcoll").attr("must",$(this).attr("_id")==1)
+						$("#s_trackcoll").closest("div.row").find("label").css("color",$(this).attr("_id")==1?"red":"")
+					}},
+					{label:"追踪记录表",s_label:"s_trackcoll",must:function(){
+						return  obj&&obj.i_track
+					}()},
+					{label:"是否统计",s_label:"i_count",type:"tpl_list_local",must:true,list:[{"s_name":"是","_id":1},{"s_name":"否","_id":0}],default:0},
+					*/
+					//{label:"使用版本",s_label:"s_version",type:"tpl_list_local",must:true,url:"/admin/task/getversion"},
+					{label:"并发数量",s_label:"i_process",placeholder:"5",must:true},
+					{label:"预处理逻辑",s_label:"s_preprocesslogic",type:"tpl_list_local",url:""},
+					{label:"匹配逻辑",s_label:"s_class",type:"tpl_list_ajax",url:"",fun:function(){
+						var ids=$("#s_class").data("ids")
+						var parentDiv=$("#s_class").closest("div")
+						ids=ids||{}
+						var tid=$(this).attr("_id")
+						if(!ids[tid]){
+							ids[tid]=true
+							$("#s_class").data("ids",ids)
+							var tpl1=$('<div class="alert alert-dismissible alert-success" style="min-width:50px;max-width:250px;font-size:10px;padding:3px;margin:5px;display:inline-block"><button type="button" class="close" data-dismiss="alert" style="right:0px;">&times;</button><span></span></div>')
+							tpl1.find("span").text($(this).text())							
+							tpl1.attr("tid",tid)
+							tpl1.find("button").click(function(){
+								var ttid=$(this).closest(".alert").attr("tid");
+								var iids=$("#s_class").data("ids")
+								delete iids[ttid]
+								$("#s_class").val(function(){
+									var strid=[]
+									for(var k in iids){
+										strid.push(k)
+									}
+									return strid.join(",")
+								}())
+							})
+							$("#s_show",parentDiv).append(tpl1)
+							$("#s_class").val(function(){
+								var strid=[]
+								for(var k in ids){
+									strid.push(k)
+								}
+								return strid.join(",")
+							}())
+						}
+					}},
+					//{label:"匹配逻辑",s_label:"s_matchlogic",type:"tpl_list_local",url:""},
+					{label:"字段",s_label:"s_field",placeholder:"title"},
+					{label:"起始id",s_label:"s_extlastid",must:true},
+					{s_label:"_id",type:"tpl_hidden"},
+				];
+				/*testtask=[
+					{label:"起始id",s_label:"s_startid",must:true},
+					{label:"数据数量",s_label:"s_datanum",placeholder:"5",must:true}
+				];*/
+				/*按钮*/
+				//新增保存按钮
+				addtaskbtn=[
+					{label:"保存",class:"btn-primary",
+						fun:function(){
+							var obj={}
+							var bcon=true
+							$("#_con").find("input[id!=s_show],textarea").each(function(i,el){
+								var val=$(el).val();
+								if(el.id!="_id"&&$(el).attr("must")&&!val){
+									bcon=false
+									return false
+								}
+								obj[el.id]=$(el).val()
+							})
+							if (bcon){								
+								$.post("/task/save",obj,function(data){
+									if(data&&data.rep){
+										//window.location.href="/task/list"
+										$('#myModal').modal('hide');
+										ttable.ajax.reload();
+									}else{
+										alert(data.msg)
+									}
+								},'json')
+							}else{
+								alert("红色标签的表单不能为空!")
+							}
+						}
+					}
+				];
+				if(n == "new"){
+					_tit="新增抽取任务";
+					tag = com.pushArry(tag,addtask);
+					bts = com.pushArry(bts,addtaskbtn);
+				}else if(n == "edit"){
+					_tit="编辑-"+obj.s_taskname;
+					tag = com.pushArry(tag,addtask);
+					bts = com.pushArry(bts,addtaskbtn);
+				}
+				htmlObj={
+					title:_tit,
+					tag:tag,
+					bts:bts
+				}
+			OpenDialog(htmlObj,obj)
+			break;
+			}
+		});
+	})
+	
+})
+function start(_id){
+	showConfirm("确定启动?", function() {
+		$.ajax({
+			url:"/task/start",
+			type:"post",
+			data:{"_id":_id},
+			success:function(r){
+				//window.location.reload();
+				ttable.ajax.reload();
+			}
+		})
+	});
+}
+function stop(_id){
+	showConfirm("确定停止?", function() {
+		$.ajax({
+			url:"/task/stop",
+			type:"post",
+			data:{"_id":_id},
+			success:function(r){
+				//window.location.reload()
+				ttable.ajax.reload();
+			}
+		})
+	});
+}
+function del(_id){
+	showConfirm("确定启动?", function() {
+		$.ajax({
+			url:"/task/del",
+			type:"post",
+			data:{"_id":_id},
+			success:function(r){
+				ttable.ajax.reload();
+			}
+		})
+	});
+}
+</script>

+ 58 - 0
dataprocess/src/web/templates/com/role.html

@@ -0,0 +1,58 @@
+{{include "com/inc.html"}}
+<!-- Main Header -->
+{{include "com/header.html"}}
+<!-- Left side column. 权限菜单 -->
+{{include "com/menu.html"}}
+
+<!-- Content Wrapper. Contains page content -->
+<div class="content-wrapper">
+    <section class="content-header">
+        <ol class="breadcrumb">
+            <li><a href="/front/role"><i class="fa fa-dashboard"></i> 角色管理</a></li>
+        </ol>
+    </section>
+    <!-- Main content -->
+    <section class="content">
+        <br>
+        <div class="row">
+            <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>编辑</th>
+                            </tr>
+                            </thead>
+                            <tbody>
+                                <tr>
+                                    <td>系统管理员</td>
+                                    <td><a class="btn btn-sm btn-success" href="/front/role/edit/0">编辑</a></td>
+                                </tr>
+                                <tr>
+                                    <td>管理员</td>
+                                    <td><a class="btn btn-sm btn-success" href="/front/role/edit/1">编辑</a></td>
+                                </tr>
+                                <tr>
+                                    <td>开发员</td>
+                                    <td><a class="btn btn-sm btn-success" href="/front/role/edit/2">编辑</a></td>
+                                </tr>
+                            </tbody>
+                        </table>
+                    </div>
+                    <!-- /.box-body -->
+                </div>
+                <!-- /.box -->
+            </div>
+        </div>
+    </section>
+</div>
+<script>
+    menuActive("role")
+</script>
+<!-- /.modal -->
+
+<!-- footer -->
+{{include "com/footer.html"}}

+ 280 - 0
dataprocess/src/web/templates/com/role_edit.html

@@ -0,0 +1,280 @@
+{{include "com/inc.html"}}
+<!-- Main Header -->
+{{include "com/header.html"}}
+<!-- Left side column. 权限菜单 -->
+{{include "com/menu.html"}}
+
+<head>
+    <style>
+
+        #selectclear2 select {
+            width:190px;
+            height:167px;
+            padding:5px;
+        }
+        #selectclear2{
+            display: flex;
+            flex-direction: row;
+        }
+        #selectclear2 .move{
+            display: flex;
+            flex-direction: column;
+            margin: 20px 25px
+        }
+        #selectclear2 .move button{
+            margin: 1px 0px;
+            padding: 4px 6px;
+        }
+        #selectclear2 .doublebox {
+            text-align:center;
+        }
+
+
+    </style>
+</head>
+
+<!-- Content Wrapper. Contains page content -->
+<div class="content-wrapper">
+    <section class="content-header">
+        <h1>
+            <small><button type="button" class="btn btn-primary" data-toggle="modal" data-target="#modal-info" onclick="formReset()">新增角色菜单</button></small>
+        </h1>
+        <ol class="breadcrumb">
+            <li><a href="/front/role"><i class="fa fa-dashboard"></i> 角色管理</a></li>
+            <li><a href="/front/role/edit/{{.T.role}}"><i class="fa fa-dashboard"></i> 角色菜单管理</a></li>
+        </ol>
+    </section>
+    <!-- Main content -->
+    <section class="content">
+        <div class="row">
+            <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>操作</th>
+                            </tr>
+                            </thead>
+                        </table>
+                    </div>
+                    <!-- /.box-body -->
+                </div>
+                <!-- /.box -->
+            </div>
+        </div>
+    </section>
+</div>
+
+<div class="modal fade" id="modal-info">
+    <div class="modal-dialog">
+        <form id="userform" class="form-horizontal" role="form">
+            <div class="modal-content">
+                <div class="modal-header">
+                    <button type="button" class="close" data-dismiss="modal" aria-label="Close">
+                        <span aria-hidden="true">&times;</span></button>
+                    <h4 class="modal-title">菜单信息</h4>
+                </div>
+                <div class="modal-body">
+                    <div class="form-group">
+                        <label for="code" class="col-sm-2 control-label">菜单名称:</label>
+                        <div class="col-sm-10">
+                            <select id="menu2" name="role" class="form-control" onchange="menu()">
+                            </select>
+                        </div>
+                    </div>
+                    <div class="form-group">
+                        <label for="code" class="col-sm-2 control-label">二级菜单:</label>
+                        <div class="col-sm-10" id="selectclear2">
+                            <div class="doublebox">
+                                <select multiple="multiple" id="select3" style="overflow-x: scroll;"></select>
+                            </div>
+                            <div class="move">
+                                <button type="button" id="up2" class="btn btn-primary">上移</button>
+                                <button type="button" id="right2" class="btn btn-primary">右移</button>
+                                <button type="button" id="left2" class="btn btn-primary">左移</button>
+                                <button type="button" id="down2" class="btn btn-primary">下移</button>
+                            </div>
+                            <div class="doublebox">
+                                <select multiple="multiple" id="select4" style="overflow-x: scroll;"></select>
+                            </div>
+                        </div>
+                    </div>
+                    <!--<div class="form-group">
+                        <label for="modify" class="col-sm-2 control-label">二级菜单:</label>
+                        <div id="secondmenu" class="col-sm-10">
+                            <input type="button" value="+" onclick="append()"></input>
+                        </div>
+                    </div>-->
+                </div>
+                <div class="modal-footer">
+                    <button type="button" class="btn btn-default" data-dismiss="modal" onclick="formReset()">取消</button>
+                    <button type="button" class="btn btn-primary" onclick="save()">保存</button>
+                </div>
+            </div>
+            <!-- /.modal-content -->
+        </form>
+        <input type="hidden" id="_id">
+    </div>
+    <!-- /.modal-dialog -->
+</div>
+<!-- /.modal -->
+
+<!-- footer -->
+{{include "com/footer.html"}}
+
+<script>
+    menuActive("role")
+    $(function () {
+        ttable=$('#dataTable').DataTable({
+            "paging"      : true,
+            "lengthChange": false,
+            "searching"   : true,
+            "ordering"    : true,
+            "info"        : true,
+            "autoWidth"   : false,
+            "ajax": {
+                "url": "/front/role/edit/{{.T.role}}",
+                "type": "post",
+                "data": {}
+            },
+            "language": {
+                "url": "/dist/js/dataTables.chinese.lang"
+            },
+            "columns": [
+                { "data": "s_name",render:function(val,a,row){
+                        return row.s_name}},
+                {"data":"_id",render:function(val,a,row){
+                        return "<a href='#' onclick='edit(\""+val+"\")'><i class='fa fa-fw fa-edit text-yellow'></i></a> &nbsp;"+
+                        "<a href='#' onclick='del(\""+val+"\")'><i class='fa fa-fw fa-trash text-red'></i></a>"
+                    }}
+            ]
+        });
+        //ttable.on('init.dt', function () {});
+    })
+    function formReset(){
+        $("#_id").val("")
+        $("#menu2").empty()
+        $("#select3").empty();
+        $("#select4").empty();
+        $("#menu2").append("<option value=''>--请选择--</option>")
+        $("#menu2").attr("disabled",false);
+        $.post("/front/role/first",'',function (data, status) {
+            for(var a=0;a<data.data.length;a++) {
+                $("#menu2").append("<option value="+data.data[a]._id+">"+data.data[a].s_name+"</option>")
+            }
+        })
+        $("#modal-info-addclear").modal("show");
+    }
+    function menu() {
+        $("#select3").empty();
+        $("#select4").empty();
+        $.post("/front/role/second",{"_pid":$("#menu2").val()},function (data,status) {
+            if(data.data){
+                for(var a=0;a<data.data.length;a++){
+                    $("#select3").append("<option title='"+data.data[a].s_name+"' value='"+data.data[a]._id+"'>"+data.data[a].s_name+"</option>");
+                }
+            }
+        })
+    }
+    function save(){
+        pid=$("#menu2").val()
+        var clearArr = [];
+        var clearArr1 = [];
+        $("#select4 option").each(function(i,val){
+            clearArr[i] = this.value
+        })
+        $("#select3 option").each(function(i,val){
+            clearArr1[i] = this.value
+        })
+        var secondStr = JSON.stringify(clearArr)
+        var secondStr1 = JSON.stringify(clearArr1)
+       if(pid == ""){
+            alert("表单填写不完整!");
+            return false;
+        }
+        $.ajax({
+            url:"/front/role/edit/save",
+            type:"post",
+            data:{"role":{{.T.role}},"_id":pid,"secondStr":secondStr,"secondStr1":secondStr1},
+            success:function(r){
+                if(r.rep){
+                    $("#userform")[0].reset();
+                    $("#modal-info").modal("hide");
+                    ttable.ajax.reload();
+                }else{
+                    alert("保存失败");
+                }
+            }
+        })
+    }
+    function del(_id){
+        showConfirm("确定删除?", function() {
+            $.ajax({
+                url:"/front/role/edit/del",
+                type:"post",
+                data:{"_id":_id,"role":{{.T.role}}},
+                success:function(r){
+                    if(r.rep){
+                        ttable.ajax.reload();
+                    }else{
+                        showTip("删除失败", 1000, function() {});
+                    }
+                }
+            })
+        });
+    }
+    function edit(_id){
+        $("#menu2").empty()
+        $("#select3").empty();
+        $("#select4").empty();
+        $("#_id").val(_id)
+        mark=$("#_id").val()
+        $.ajax({
+            url:"/front/role/second/edit",
+            type:"post",
+            data:{"_id":_id,"mark":mark,"role":{{.T.role}}},
+            success:function(r){
+                if(r){
+                    $("#menu2").append("<option value="+_id+">"+r.name+"</option>")
+                    $("#menu2").attr("disabled",true);
+                    for(var a=0;a<r.data1.length;a++){
+                        $("#select3").append("<option title='"+r.data1[a].s_name+"' value='"+r.data1[a]._id+"'>"+r.data1[a].s_name+"</option>");
+                    }
+                    for(var a=0;a<r.data.length;a++){
+                        $("#select4").append("<option title='"+r.data[a].s_name+"' value='"+r.data[a]._id+"'>"+r.data[a].s_name+"</option>");
+                    }
+                }
+            }
+        })
+        $("#modal-info").modal("show");
+    }
+
+    $("#selectclear2 #right2").click(function(){
+        $("#select3 option:selected").appendTo("#select4");
+    });
+    //左移
+    $("#selectclear2 #left2").click(function(){
+        $("#select4 option:selected").appendTo("#select3");
+    });
+    $("#selectclear2 #up2,#selectclear2 #down2").click(function() {
+        var $opt = $("#select4 option:selected:first");
+        if (!$opt.length){
+            return;
+        }
+        if (this.id == "up2"){
+            $opt.prev().before($opt);
+        }else{
+            $opt.next().after($opt);
+        }
+    });
+    //双击右移
+    $("#selectclear2 #select3").dblclick(function(){
+        $("#selectclear2 #select3 option:selected").appendTo("#select4");
+    });
+    //双击左移
+    $("#selectclear2 #select4").dblclick(function(){
+        $("#selectclear2 #select4 option:selected").appendTo("#select3");
+    });
+</script>

+ 251 - 0
dataprocess/src/web/templates/com/task_list.html

@@ -0,0 +1,251 @@
+{{include "com/inc.html"}}
+<!-- Main Header -->
+{{include "com/header.html"}}
+<!-- Left side column. 权限菜单 -->
+{{include "com/menu.html"}}
+
+<div class="content-wrapper" id="showbtn">
+	<section class="content-header">
+		<h1>
+			<small><a class="btn btn-primary opr" opr="new">新增任务</a></small>
+		</h1>
+		<ol class="breadcrumb">
+		  <li><a href="/admin/task/list"><i class="fa fa-dashboard"></i> 任务管理</a></li>		  
+		</ol>
+    </section>
+  <!-- Main content -->
+  <section class="content">
+      <div class="row">
+	      <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>创建时间</th> <th>创建人</th> <th>描述</th><th>运行状态</th> <th>操作</th>
+		              </tr>
+		              </thead>
+		            </table>
+		        </div>
+	          <!-- /.box-body -->
+	        </div>
+        <!-- /.box -->
+		</div>
+	</div>
+  </section>
+</div>
+{{include "com/dialog.html"}}
+{{include "com/footer.html"}}
+<script>
+menuActive("list")
+$(function () {
+	ttable=$('#dataTable').DataTable({
+		"paging"      : false,
+		"lengthChange": false,
+		"searching"   : false,
+		"ordering"    : false,
+		"info"        : true,
+		"autoWidth"   : false,
+		"ajax": {
+			"url": "/task/list",
+			"type": "post",
+			"data":{}
+		 },
+		"language": {
+            "url": "/dist/js/dataTables.chinese.lang"
+        },
+		"columns": [
+            { "data": "s_taskname"},
+			{ "data": "l_comeintime",render:function(val){
+				var dt=new Date()
+				dt.setTime(parseInt(val)*1000)
+				return dt.format("yyyy-MM-dd hh:mm:ss")
+			}},
+			{ "data": "s_username"},
+			{ "data": "s_descript","width":"25%"},
+			{ "data": "i_runstate",render:function(val){
+				if(val==1){
+					return "<i class='fa fa-fw fa-circle text-green'></i>运行中"
+				}else{
+					return "<i class='fa fa-fw fa-circle text-danger'></i>未启动"
+				}
+			}},
+			{ "data":"_id","width":"25%",render:function(val,a,row,pos){
+				tmp = '<div>'+
+					'<a class="btn btn-sm btn-primary opr" opr="edit" row="'+pos.row+'" >编辑</a> '+
+					'<a class="btn btn-sm btn-success opr" opr="start" onclick="start(\''+row._id+'\')">启动</a> '+
+					'<a class="btn btn-sm btn-info opr" opr="stop" onclick="stop(\''+row._id+'\')">停止</a> '+
+					'<a class="btn btn-sm btn-danger opr" opr="del" onclick="del(\''+val+'\')">删除</a>'+
+					'</div>';
+				return  tmp
+			}}
+       	]
+	});
+	ttable.on('init.dt', function () {
+		$("#showbtn").on('click','a.opr',function(){
+			var n=$(this).attr("opr");
+			var taskid=$(this).attr("taskid");
+			var htmlObj={},obj,tag=[],bts=[];
+			var _tit="";
+			switch(n){
+			case "edit":			
+				obj=ttable.row($(this).closest("tr")).data();	
+			case "new":
+				/*表单*/
+				addtask=[
+					{label:"任务名称",s_label:"s_taskname",placeholder:"数据清洗",must:true},
+					{label:"源库连接",s_label:"s_mgoaddr",must:true},
+					{label:"源数据库",s_label:"s_mgodb",must:true},
+					{label:"源表",s_label:"s_mgocoll",must:true},
+					{label:"保存表",s_label:"s_mgosavecoll",placeholder:"127.0.0.1:27080/dataprocess/bidding(数据库地址/数据库/表)",must:true},
+					{label:"描述",s_label:"s_descript",type:"tpl_text"},
+					/*
+					{label:"是否追踪",s_label:"i_track",type:"tpl_list_local",must:true,list:[{"s_name":"是","_id":1},{"s_name":"否","_id":0}],default:0,fun:function(){
+						var to=$("#i_track")					
+						to.val($(this).attr("_id"))
+						$("#s_show",to.closest("div")).val($(this).text())
+						//追踪表样式
+						$("#s_trackcoll").attr("must",$(this).attr("_id")==1)
+						$("#s_trackcoll").closest("div.row").find("label").css("color",$(this).attr("_id")==1?"red":"")
+					}},
+					{label:"追踪记录表",s_label:"s_trackcoll",must:function(){
+						return  obj&&obj.i_track
+					}()},
+					{label:"是否统计",s_label:"i_count",type:"tpl_list_local",must:true,list:[{"s_name":"是","_id":1},{"s_name":"否","_id":0}],default:0},
+					*/
+					//{label:"使用版本",s_label:"s_version",type:"tpl_list_local",must:true,url:"/admin/task/getversion"},
+					{label:"并发数量",s_label:"i_process",placeholder:"5",must:true},
+					{label:"预处理逻辑",s_label:"s_preprocesslogic",type:"tpl_list_local",url:""},
+					{label:"匹配逻辑",s_label:"s_class",type:"tpl_list_ajax",url:"",fun:function(){
+						var ids=$("#s_class").data("ids")
+						var parentDiv=$("#s_class").closest("div")
+						ids=ids||{}
+						var tid=$(this).attr("_id")
+						if(!ids[tid]){
+							ids[tid]=true
+							$("#s_class").data("ids",ids)
+							var tpl1=$('<div class="alert alert-dismissible alert-success" style="min-width:50px;max-width:250px;font-size:10px;padding:3px;margin:5px;display:inline-block"><button type="button" class="close" data-dismiss="alert" style="right:0px;">&times;</button><span></span></div>')
+							tpl1.find("span").text($(this).text())							
+							tpl1.attr("tid",tid)
+							tpl1.find("button").click(function(){
+								var ttid=$(this).closest(".alert").attr("tid");
+								var iids=$("#s_class").data("ids")
+								delete iids[ttid]
+								$("#s_class").val(function(){
+									var strid=[]
+									for(var k in iids){
+										strid.push(k)
+									}
+									return strid.join(",")
+								}())
+							})
+							$("#s_show",parentDiv).append(tpl1)
+							$("#s_class").val(function(){
+								var strid=[]
+								for(var k in ids){
+									strid.push(k)
+								}
+								return strid.join(",")
+							}())
+						}
+					}},
+					//{label:"匹配逻辑",s_label:"s_matchlogic",type:"tpl_list_local",url:""},
+					{label:"字段",s_label:"s_field",placeholder:"title"},
+					{label:"起始id",s_label:"s_extlastid",must:true},
+					{s_label:"_id",type:"tpl_hidden"},
+				];
+				/*testtask=[
+					{label:"起始id",s_label:"s_startid",must:true},
+					{label:"数据数量",s_label:"s_datanum",placeholder:"5",must:true}
+				];*/
+				/*按钮*/
+				//新增保存按钮
+				addtaskbtn=[
+					{label:"保存",class:"btn-primary",
+						fun:function(){
+							var obj={}
+							var bcon=true
+							$("#_con").find("input[id!=s_show],textarea").each(function(i,el){
+								var val=$(el).val();
+								if(el.id!="_id"&&$(el).attr("must")&&!val){
+									bcon=false
+									return false
+								}
+								obj[el.id]=$(el).val()
+							})
+							if (bcon){								
+								$.post("/task/save",obj,function(data){
+									if(data&&data.rep){
+										//window.location.href="/task/list"
+										$('#myModal').modal('hide');
+										ttable.ajax.reload();
+									}else{
+										alert(data.msg)
+									}
+								},'json')
+							}else{
+								alert("红色标签的表单不能为空!")
+							}
+						}
+					}
+				];
+				if(n == "new"){
+					_tit="新增抽取任务";
+					tag = com.pushArry(tag,addtask);
+					bts = com.pushArry(bts,addtaskbtn);
+				}else if(n == "edit"){
+					_tit="编辑-"+obj.s_taskname;
+					tag = com.pushArry(tag,addtask);
+					bts = com.pushArry(bts,addtaskbtn);
+				}
+				htmlObj={
+					title:_tit,
+					tag:tag,
+					bts:bts
+				}
+			OpenDialog(htmlObj,obj)
+			break;
+			}
+		});
+	})
+	
+})
+function start(_id){
+	showConfirm("确定启动?", function() {
+		$.ajax({
+			url:"/task/start",
+			type:"post",
+			data:{"_id":_id},
+			success:function(r){
+				//window.location.reload();
+				ttable.ajax.reload();
+			}
+		})
+	});
+}
+function stop(_id){
+	showConfirm("确定停止?", function() {
+		$.ajax({
+			url:"/task/stop",
+			type:"post",
+			data:{"_id":_id},
+			success:function(r){
+				//window.location.reload()
+				ttable.ajax.reload();
+			}
+		})
+	});
+}
+function del(_id){
+	showConfirm("确定启动?", function() {
+		$.ajax({
+			url:"/task/del",
+			type:"post",
+			data:{"_id":_id},
+			success:function(r){
+				ttable.ajax.reload();
+			}
+		})
+	});
+}
+</script>

+ 5 - 7
dataprocess/src/web/templates/com/user.html

@@ -73,8 +73,8 @@
 				    <div class="col-sm-10">
 				     	<select id="role" name="role" class="form-control">
 							<option value="2">开发员</option>
-							<option value="1">审核员</option>
-					  		<option value="0">管理员</option>
+							<option value="1">管理员</option>
+					  		<option value="0">系统管理员</option>
 						</select>
 				    </div>
 				</div>	
@@ -124,12 +124,10 @@ $(function () {
 				if(val==2){
 					role="开发员"
 				}else if(val==1){
-					role="审核员"
+					role="管理员"
 				}else if(val==0){
-                    role="管理员"
-                }else{
-					role="超级管理员"
-				}
+                    role="系统管理员"
+                }
 				return role
 			}},
 			{ "data":"_id",render:function(val,a,row){

+ 9 - 2
dataprocess/src/web/templates/login.html

@@ -48,7 +48,7 @@
       <div class="row">
         <!-- /.col -->
         <div class="col-xs-12">
-          <button type="button" class="btn btn-primary btn-block btn-flat" onclick="login()">登录</button>
+          <button type="button" id="logina" class="btn btn-primary btn-block btn-flat" onclick="login()">登录</button>
         </div>
         <!-- /.col -->
       </div>
@@ -71,8 +71,15 @@ $(function () {
     	radioClass: 'iradio_square-blue',
     	increaseArea: '20%' /* optional */
  	});
+	
+	document.onkeydown = function (event) {
+        var e = event || window.event;
+        if (e && e.keyCode == 13) { //回车键的键值为13
+           login();
+        }
+    }; 
 });
-
+	
 function login(){
 	var email = $("#email").val().trim().replace(/\s/g,"");
 	var pwd = $("#pwd").val().trim().replace(/\s/g,"");

+ 12 - 1
fullproject/src_v1/merge_comparepnc.go

@@ -17,6 +17,14 @@ func comparePNC(info *Info, compareProject *ProjectInfo) (compareStr string, sco
 		}
 		ifind := 0
 		templen := 0
+		buyer := info.Buyer
+		if buyer == "" {
+			buyer = compareProject.Buyer
+		}
+		pn := info.ProjectName
+		if buyer != "" {
+			pn = strings.Replace(pn, buyer, "", -1)
+		}
 		for _, v := range pns {
 			if info.ProjectName == v {
 				ifind = 1
@@ -28,7 +36,10 @@ func comparePNC(info *Info, compareProject *ProjectInfo) (compareStr string, sco
 					ifind = 1
 					break
 				} else {
-					v1 := CosineSimilar(info.ProjectName, v)
+					if buyer != "" {
+						v = strings.Replace(v, buyer, "", -1)
+					}
+					v1 := CosineSimilar(pn, v)
 					if retv == 2 || v1 > 0.81 {
 						templen = len([]rune(v))
 						ifind = 2

二进制
fullproject/src_v1/src_v1


+ 23 - 13
fullproject/src_v1/task.go

@@ -39,9 +39,9 @@ type ProjectTask struct {
 	mapPb, mapPn, mapPc map[string]*Key
 	//	mapPbLock, mapPnLock, mapPcLock sync.Mutex
 	//更新或新增通道
-	updatePool           chan []map[string]interface{}
-	savePool             chan map[string]interface{}
-	saveSign, updateSign chan bool
+	updatePool chan []map[string]interface{}
+	//savePool   chan map[string]interface{}
+	//saveSign, updateSign chan bool
 	//表名
 	coll string
 	//当前状态是全量还是增量
@@ -67,16 +67,17 @@ func NewPT() *ProjectTask {
 		thread:      4,
 		updatePool:  make(chan []map[string]interface{}, 5000),
 		//savePool:    make(chan map[string]interface{}, 2000),
-		wg:         sync.WaitGroup{},
-		AllIdsMap:  make(map[string]*ID, 5000000),
-		mapPb:      make(map[string]*Key, 1500000),
-		mapPn:      make(map[string]*Key, 5000000),
-		mapPc:      make(map[string]*Key, 5000000),
-		saveSize:   400,
-		saveSign:   make(chan bool, 1),
-		updateSign: make(chan bool, 1),
-		coll:       ProjectColl,
-		validTime:  int64(util.IntAllDef(Sysconfig["validdays"], 150) * 86400),
+		wg:        sync.WaitGroup{},
+		AllIdsMap: make(map[string]*ID, 5000000),
+		mapPb:     make(map[string]*Key, 1500000),
+		mapPn:     make(map[string]*Key, 5000000),
+		mapPc:     make(map[string]*Key, 5000000),
+		saveSize:  400,
+
+		//saveSign:   make(chan bool, 1),
+		//updateSign: make(chan bool, 1),
+		coll:      ProjectColl,
+		validTime: int64(util.IntAllDef(Sysconfig["validdays"], 150) * 86400),
 	}
 	return p
 }
@@ -86,6 +87,7 @@ var P_QL *ProjectTask
 //初始化全量合并对象
 func init() {
 	P_QL = NewPT()
+	log.Println(len(P_QL.updatePool))
 	go P_QL.updateAllQueue()
 	go P_QL.clearMem()
 }
@@ -280,6 +282,14 @@ func (p *ProjectTask) taskZl(udpInfo map[string]interface{}) {
 		//生成查询语句执行
 		p.enter(db, coll, q)
 	}
+	for {
+		if len(P_QL.updatePool) > 0 {
+			log.Println("等待调用udp", len(P_QL.updatePool))
+			time.Sleep(1 * time.Second)
+		} else {
+			break
+		}
+	}
 	if udpInfo["stop"] == nil {
 		nextNode(udpInfo, p.pici)
 	}

+ 3 - 0
udpfilterdup/src/main.go

@@ -32,6 +32,9 @@ var (
 )
 
 func init() {
+
+	//。。。
+	
 	flag.StringVar(&lastid, "id", "", "最后加载id") //以小于等于此id开始加载最近几天的数据
 	flag.Parse()
 	util.ReadConfig(&Sysconfig)