Parcourir la source

爬虫分配及站点修改功能修改

mxs il y a 5 mois
Parent
commit
74fc129e79

+ 2 - 2
src/config.json

@@ -1,10 +1,10 @@
 {
     "webport": "8002",
-    "dbaddr": "192.168.3.166:27082",
+    "dbaddr": "172.20.45.130:27017",
     "dbname": "editor",
     "dbname2": "spider",
     "bideditor": {
-        "addr": "192.168.3.166:27082",
+        "addr": "172.20.45.130:27017",
         "db": "editor",
         "size": 5,
         "username": "",

+ 2 - 2
src/front/claim.go

@@ -238,9 +238,9 @@ func CreateRecovertime(important bool, priority int) int64 {
 }
 
 // UpdateLuaClaimtype 更新爬虫认领状态
-func UpdateLuaClaimtype(code string) {
+func UpdateLuaClaimtype(code string, claimtype int) {
 	MgoEB.Update("luaconfig", map[string]interface{}{"code": code}, map[string]interface{}{"$set": map[string]interface{}{
-		"claimtype":   CLAIMTYPEHISTORY,
+		"claimtype":   claimtype,
 		"claimtime":   int64(0),
 		"recovertime": int64(0),
 	}}, false, false)

+ 158 - 106
src/front/front.go

@@ -48,22 +48,23 @@ type Front struct {
 	tagCode         xweb.Mapper `xweb:"/center/spider/tagcode"`         //标记爬虫
 	spiderRemark    xweb.Mapper `xweb:"/center/spider/spiderremark"`    //标记爬虫
 
-	spiderModel     xweb.Mapper `xweb:"/center/model"`            //获取补充模型
-	runStep         xweb.Mapper `xweb:"/center/run"`              //方法测试
-	spiderPass      xweb.Mapper `xweb:"/center/spider/pass"`      //整体测试
-	runPinYin       xweb.Mapper `xweb:"/center/runpy"`            //获取拼音
-	saveStep        xweb.Mapper `xweb:"/center/save"`             //爬虫保存
-	saveJs          xweb.Mapper `xweb:"/center/save/js"`          //保存js
-	loadModel       xweb.Mapper `xweb:"/center/gmodel/(.*)"`      //加载模型
-	importdata      xweb.Mapper `xweb:"/center/importdata"`       //导入爬虫列表页面
-	importLua       xweb.Mapper `xweb:"/center/importlua"`        //导入爬虫
-	oldedit         xweb.Mapper `xweb:"/center/oldedit"`          //老文件编辑
-	findName        xweb.Mapper `xweb:"/center/findname"`         //即时查询名称
-	checkrepeat     xweb.Mapper `xweb:"/center/spider/isrepeat"`  //脚本代码判重
-	heart           xweb.Mapper `xweb:"/center/data/heart"`       //心跳监控
-	spiderCopy      xweb.Mapper `xweb:"/center/spider/copy"`      //补采复制爬虫
-	spiderSplitCopy xweb.Mapper `xweb:"/center/spider/splitcopy"` //拆分复制爬虫
-	spiderCloseErr  xweb.Mapper `xweb:"/center/spider/closeerr"`  //删除错误爬虫
+	spiderModel          xweb.Mapper `xweb:"/center/model"`                 //获取补充模型
+	runStep              xweb.Mapper `xweb:"/center/run"`                   //方法测试
+	spiderPass           xweb.Mapper `xweb:"/center/spider/pass"`           //整体测试
+	runPinYin            xweb.Mapper `xweb:"/center/runpy"`                 //获取拼音
+	saveStep             xweb.Mapper `xweb:"/center/save"`                  //爬虫保存
+	saveJs               xweb.Mapper `xweb:"/center/save/js"`               //保存js
+	loadModel            xweb.Mapper `xweb:"/center/gmodel/(.*)"`           //加载模型
+	importdata           xweb.Mapper `xweb:"/center/importdata"`            //导入爬虫列表页面
+	importLua            xweb.Mapper `xweb:"/center/importlua"`             //导入爬虫
+	oldedit              xweb.Mapper `xweb:"/center/oldedit"`               //老文件编辑
+	findName             xweb.Mapper `xweb:"/center/findname"`              //即时查询名称
+	checkrepeat          xweb.Mapper `xweb:"/center/spider/isrepeat"`       //脚本代码判重
+	heart                xweb.Mapper `xweb:"/center/data/heart"`            //心跳监控
+	spiderCopy           xweb.Mapper `xweb:"/center/spider/copy"`           //补采复制爬虫
+	spiderSplitCopy      xweb.Mapper `xweb:"/center/spider/splitcopy"`      //拆分复制爬虫
+	spiderCloseErr       xweb.Mapper `xweb:"/center/spider/closeerr"`       //删除错误爬虫
+	spiderUpdatePlatform xweb.Mapper `xweb:"/center/spider/updateplatform"` //修改爬虫信息
 
 	Base      Base
 	OtherBase OtherBase
@@ -719,14 +720,14 @@ func (f *Front) Assign() {
 	codesarr := strings.Split(codes, ",") //被分配的爬虫
 	user, _ := u.MgoEB.FindById("user", userid, nil)
 	if user != nil && len(*user) > 0 {
-		platform := (*user)["s_platform"]
+		//platform := (*user)["s_platform"]
 		name := qu.ObjToString((*user)["s_name"])
 		query := map[string]interface{}{
 			"code": map[string]interface{}{
 				"$in": codesarr,
 			},
 		}
-		luas, _ := u.MgoEB.Find("luaconfig", query, nil, ClaimQueryFields, false, -1, -1)
+		luas, _ := u.MgoEB.Find("luaconfig", query, nil, nil, false, -1, -1)
 		update := [][]map[string]interface{}{}
 		save := []map[string]interface{}{}
 		for _, l := range *luas {
@@ -735,75 +736,58 @@ func (f *Front) Assign() {
 			claimtype := qu.IntAll(l["claimtype"])
 			priority := qu.IntAll(l["priority"])
 			spiderimportant, _ := l["spiderimportant"].(bool)
-			if claimtype <= CLAIMTYPECLAIMED { //非历史爬虫分配
-				//recovertime := CreateRecovertime(spiderimportant, priority)
-				recovertime := time.Now().Add(24 * 5 * time.Hour).Unix()
-				set = map[string]interface{}{
-					"claimtype":       CLAIMTYPECLAIMED,
-					"claimtime":       now,
-					"recovertime":     recovertime,
-					"createuseremail": (*user)["s_email"],
-					"createuser":      name,
-					"createuserid":    userid,
-					"modifyuser":      name,
-					"modifyuserid":    userid,
-					"platform":        platform,
-				}
-				if claimtype == CLAIMTYPECLAIMED { //已认领的爬虫增加回收日志
-					//回收日志
-					recovelog := map[string]interface{}{
-						"site":             l["site"],
-						"code":             l["code"],
-						"channel":          l["channel"],
-						"modifyuser":       l["modifyuser"],
-						"priority":         priority,
-						"stype":            "回收",
-						"comeintime":       now,
-						"claimtime":        l["claimtime"],
-						"recovertime":      l["recovertime"],
-						"returntime":       int64(0),
-						"important":        spiderimportant,
-						"returnreason":     "",
-						"claimrecovertype": 0,
-						"source":           "分配爬虫回收",
-					}
-					save = append(save, recovelog)
-				}
-				//被重新分配的爬虫视为重新认领(注意:lua爬虫分配到除chrome外的平台,变为历史爬虫)
-				if platform == "golua平台" { //爬虫分配到非lua平台,不视为认领
-					//认领日志
-					claimlog := map[string]interface{}{
-						"site":             l["site"],
-						"code":             l["code"],
-						"channel":          l["channel"],
-						"modifyuser":       name,
-						"priority":         priority,
-						"stype":            "认领",
-						"comeintime":       now,
-						"claimtime":        now,
-						"recovertime":      recovertime,
-						"returntime":       int64(0),
-						"important":        spiderimportant,
-						"returnreason":     "",
-						"claimrecovertype": 0,
-						"source":           "分配爬虫认领",
-					}
-					save = append(save, claimlog)
-				} else if platform != "golua平台" && platform != "chrome" { //分配到其他平台改为历史爬虫
-					set["claimtype"] = CLAIMTYPEHISTORY
-					set["claimtime"] = 0
-					set["recovertime"] = 0
-				}
-			} else { //历史爬虫
-				set = map[string]interface{}{
-					"createuserid":    userid,
-					"createuser":      name,
-					"createuseremail": (*user)["s_email"],
-					"modifyuser":      name,
-					"modifyuserid":    userid,
-					"platform":        (*user)["s_platform"],
+			//recovertime := CreateRecovertime(spiderimportant, priority)
+			recovertime := time.Now().Add(24 * 5 * time.Hour).Unix()
+			set = map[string]interface{}{
+				//"claimtype":       CLAIMTYPECLAIMED,
+				//"claimtime":       now,
+				//"recovertime":     recovertime,
+				"createuseremail": (*user)["s_email"],
+				"createuser":      name,
+				"createuserid":    userid,
+				"modifyuser":      name,
+				"modifyuserid":    userid,
+				//"platform":        platform,
+			}
+			if claimtype == CLAIMTYPECLAIMED { //已认领的爬虫增加回收日志
+				//回收日志
+				recovelog := map[string]interface{}{
+					"site":             l["site"],
+					"code":             l["code"],
+					"channel":          l["channel"],
+					"modifyuser":       l["modifyuser"],
+					"priority":         priority,
+					"stype":            "回收",
+					"comeintime":       now,
+					"claimtime":        l["claimtime"],
+					"recovertime":      l["recovertime"],
+					"returntime":       int64(0),
+					"important":        spiderimportant,
+					"returnreason":     "",
+					"claimrecovertype": 0,
+					"source":           "分配爬虫回收",
 				}
+				save = append(save, recovelog)
+			}
+			//被重新分配的爬虫视为重新认领(注意:lua爬虫分配到除chrome外的平台,变为历史爬虫)
+			//认领日志
+			claimlog := map[string]interface{}{
+				"site":             l["site"],
+				"code":             l["code"],
+				"channel":          l["channel"],
+				"modifyuser":       name,
+				"priority":         priority,
+				"stype":            "认领",
+				"comeintime":       now,
+				"claimtime":        now,
+				"recovertime":      recovertime,
+				"returntime":       int64(0),
+				"important":        spiderimportant,
+				"returnreason":     "",
+				"claimrecovertype": 0,
+				"source":           "分配爬虫认领",
 			}
+			save = append(save, claimlog)
 			//更新爬虫
 			up := []map[string]interface{}{
 				{"code": l["code"]},
@@ -829,6 +813,85 @@ func (f *Front) Assign() {
 	}
 }
 
+// SpiderUpdatePlatform 修改平台
+func (f *Front) SpiderUpdatePlatform() {
+	defer qu.Catch()
+	codes := f.GetString("codes")
+	platform := f.GetString("platform")
+	query := map[string]interface{}{
+		"code": map[string]interface{}{
+			"$in": strings.Split(codes, ","),
+		},
+	}
+	luas, _ := u.MgoEB.Find("luaconfig", query, nil, nil, false, -1, -1)
+	arr := [][]map[string]interface{}{}
+	save := []map[string]interface{}{}
+	for _, l := range *luas {
+		code := qu.ObjToString(l["code"])
+		update := []map[string]interface{}{
+			{"code": code},
+		}
+		set := map[string]interface{}{}
+		set["platform"] = platform
+		if platform == "python" && platform == "jschrome" {
+			var err error
+			var b bool
+			b = u.MgoS.Update("spider_heart", map[string]interface{}{"code": code}, map[string]interface{}{"$set": map[string]interface{}{"del": true}}, false, true)
+			pf := qu.ObjToString(l["platform"])
+			if pf == "golua平台" || pf == "chrome" { //爬虫所属golua平台
+				b, err = spider.UpdateSpiderByCodeState(code, "6", qu.IntAll(l["event"])) //下架
+				if b && err == nil {
+					//历史节点下架为了避免线上运行爬虫待完成时改为7000采集历史,但是又转到其他平台,导致原线上运行节点爬虫并未下线,心跳异常
+					if incrementevent := l["incrementevent"]; incrementevent != nil {
+						b, err = spider.UpdateSpiderByCodeState(code, "6", qu.IntAll(incrementevent))
+					}
+				}
+			}
+			if b && err == nil {
+				//关闭任务
+				u.MgoEB.Update("task", map[string]interface{}{"s_code": code, "i_state": map[string]interface{}{"$in": []int{0, 1, 2, 3, 5}}}, map[string]interface{}{"$set": map[string]interface{}{"i_state": 6}}, false, true)
+			} else {
+				qu.Debug("修改平台爬虫下架失败", code)
+				f.Write("n")
+				return
+			}
+		}
+		//更新状态
+		set["state"] = 0
+		//爬虫认领状态更新
+		set["claimtype"] = CLAIMTYPECLAIMED
+		set["claimtime"] = time.Now().Unix()
+		set["recovertime"] = int64(0)
+		//换平台爬虫回收,保存日志
+		recovelog := map[string]interface{}{
+			"site":             l["site"],
+			"code":             l["code"],
+			"channel":          l["channel"],
+			"modifyuser":       l["modifyuser"],
+			"priority":         l["priority"],
+			"stype":            "回收",
+			"comeintime":       time.Now().Unix(),
+			"claimtime":        l["claimtime"],
+			"recovertime":      l["recovertime"],
+			"returntime":       int64(0),
+			"important":        l["spiderimportant"],
+			"returnreason":     "转平台",
+			"claimrecovertype": 0,
+			"source":           "爬虫转平台回收",
+		}
+		save = append(save, recovelog)
+		update = append(update, map[string]interface{}{"$set": set})
+		arr = append(arr, update)
+	}
+	u.MgoEB.UpdateBulk("luaconfig", arr...)
+	if len(save) > 0 {
+		u.MgoEB.SaveBulk("lua_logs_claim", save...)
+	}
+	arr = [][]map[string]interface{}{}
+	save = []map[string]interface{}{}
+	f.Write("y")
+}
+
 // 审核日志导出
 func (f *Front) AuditExport() {
 	auth := qu.IntAll(f.GetSession("auth"))
@@ -1015,12 +1078,13 @@ func (f *Front) UpdateESP() {
 	} else if w == "platform" {
 		//常规字段更新
 		set["platform"] = val
-		set["comeintime"] = time.Now().Unix()
-		if val != "golua平台" && val != "chrome" {
+		//set["comeintime"] = time.Now().Unix()
+		if val == "python" && val == "jschrome" {
 			b := u.MgoS.Update("spider_heart", map[string]interface{}{"code": code}, map[string]interface{}{"$set": map[string]interface{}{"del": true}}, false, true)
 			qu.Debug("Del Heart:", b)
 			var err error
-			if qu.ObjToString((*one)["platform"]) == "golua平台" {
+			pf := qu.ObjToString((*one)["platform"])
+			if pf == "golua平台" || pf == "chrome" { //爬虫所属golua平台
 				b, err = spider.UpdateSpiderByCodeState(code, "6", qu.IntAll((*one)["event"])) //下架
 				if b && err == nil {
 					//历史节点下架为了避免线上运行爬虫待完成时改为7000采集历史,但是又转到其他平台,导致原线上运行节点爬虫并未下线,心跳异常
@@ -1032,28 +1096,16 @@ func (f *Front) UpdateESP() {
 			if b && err == nil {
 				//关闭任务
 				u.MgoEB.Update("task", map[string]interface{}{"s_code": code, "i_state": map[string]interface{}{"$in": []int{0, 1, 2, 3, 5}}}, map[string]interface{}{"$set": map[string]interface{}{"i_state": 6}}, false, true)
-				if b && err == nil {
-					set["state"] = 0 //更新状态
-					set["luauser"] = map[string]interface{}{
-						"createuser":      (*one)["createuser"],
-						"createuserid":    (*one)["createuserid"],
-						"createuseremail": (*one)["createuseremail"],
-						"modifyuser":      (*one)["modifyuser"],
-						"modifyuserid":    (*one)["modifyuserid"],
-					}
-				} else {
-					qu.Debug("历史节点下架失败")
-					f.Write("n")
-					return
-				}
 			} else {
-				qu.Debug("增量节点下架失败")
-				f.Write("n")
-				return
+				qu.Debug("修改平台爬虫下架失败", code)
 			}
 		}
+		//更新状态
+		set["state"] = 0
 		//爬虫认领状态更新
-		UpdateLuaClaimtype(code)
+		set["claimtype"] = CLAIMTYPECLAIMED
+		set["claimtime"] = time.Now().Unix()
+		set["recovertime"] = int64(0)
 		//换平台爬虫回收,保存日志
 		recovelog := map[string]interface{}{
 			"site":             (*one)["site"],

+ 1 - 1
src/front/luamove.go

@@ -149,7 +149,7 @@ func (lm *LuaMove) UpdateToEvent() {
 	lm.ServeJson(map[string]interface{}{"ok": ok})
 }
 
-//爬虫迁移
+// 爬虫迁移
 func SpiderMoveLua(codes []string, events []string) bool {
 	defer qu.Catch()
 	msg := []string{}

+ 5 - 5
src/front/spider.go

@@ -1433,9 +1433,9 @@ func AssortOrDisablesCode(codes []string, state int, stype, reason string) (msg
 					"$nin": []int{4, 6}, //更新除审核通过和已关闭的任务
 				},
 			}, map[string]interface{}{"$set": settask}, false, true)
-			DelSpiderHeart(code)     //删除心跳
-			UpdateSiteTask(code)     //更新重点站点任务
-			UpdateLuaClaimtype(code) //更新爬虫认领状态
+			DelSpiderHeart(code)                       //删除心跳
+			UpdateSiteTask(code)                       //更新重点站点任务
+			UpdateLuaClaimtype(code, CLAIMTYPEHISTORY) //更新爬虫认领状态
 		} else {
 			msg += code + ", 更新失败;"
 		}
@@ -1654,8 +1654,8 @@ func UpStateAndUpSpider(code, id, reason, username string, state int) (bool, err
 					}
 					upset["frequencyerrtimes"] = 0 //爬虫审核通过,重置采集频率异常次数
 					upset["l_uploadtime"] = time.Now().Unix()
-					UpdateSiteTask(code)     //更新重点站点任务
-					UpdateLuaClaimtype(code) //更新爬虫认领状态
+					UpdateSiteTask(code)                       //更新重点站点任务
+					UpdateLuaClaimtype(code, CLAIMTYPEHISTORY) //更新爬虫认领状态
 				} else if state == Sp_state_2 { //打回原因
 					upset["reason"] = reason
 					//清理机检结果

+ 1 - 1
src/luaerrdata/errdata.go

@@ -276,7 +276,7 @@ func (ed *ErrorData) FindByCode() {
 	return
 }
 
-//重采
+// 重采
 func (ed *ErrorData) RegatherData() {
 	defer qu.Catch()
 	codes := ed.GetString("codes")

+ 1 - 3
src/main.go

@@ -19,8 +19,6 @@ import (
 	u "util"
 
 	codegrpc "analysiscode/client"
-	gojs "gorunjs/client"
-
 	util "spiderutil"
 	"time"
 
@@ -43,7 +41,7 @@ func init() {
 	//验证码识别client
 	codegrpc.InitCodeGrpcClient()
 	//go执行js服务
-	gojs.InitGoRunJsClient()
+	//gojs.InitGoRunJsClient()
 	//mail
 	smtp := util.Config.Smtp
 	front.Mails = util.New(smtp["addr"], qu.IntAll(smtp["port"]), smtp["user"], smtp["pwd"])

+ 34 - 5
src/spider/service.go

@@ -400,27 +400,56 @@ func CreateFile(code, script string) (string, error) {
 }
 
 // 上传脚本
-func UpdateSpiderByCodeState(code, state string, event int) (bool, error) {
+func UpdateSpiderByCodeState(code, state string, event int) (b bool, err error) {
+	istate := qu.IntAll(state)
+	defer func() {
+		if b && err == nil && istate == 6 { //下架更新
+			UpdateOnlineCode(code, istate)
+		}
+	}()
+	if istate == 5 {
+		ok := UpdateOnlineCode(code, istate) //上架更新
+		if !ok {
+			return ok, errors.New("线上表更新失败")
+		}
+	}
 	msgid := mu.UUID(8)
 	data := map[string]interface{}{}
 	data["code"] = code
 	data["state"] = state
 	rep := map[string]interface{}{}
 	var bs []byte
-	var err error
 	if util.Config.Uploadevents[fmt.Sprint(event)] == "bid" {
 		bs, err = MsclientBid.Call("", msgid, event, mu.SENDTO_TYPE_ALL_RECIVER, data, 60)
 	} else {
 		bs, err = Msclient.Call("", msgid, event, mu.SENDTO_TYPE_ALL_RECIVER, data, 60)
 	}
 	if err != nil {
-		return false, err
+		return
 	} else {
 		json.Unmarshal(bs, &rep)
-		b, _ := rep["b"].(bool)
+		b, _ = rep["b"].(bool)
 		if !b {
 			err = errors.New(qu.ObjToString(rep["err"]))
 		}
-		return b, err
+		return
+	}
+}
+
+func UpdateOnlineCode(code string, state int) bool {
+	upsert := false
+	query := map[string]interface{}{"code": code}
+	set := map[string]interface{}{}
+	if state == 6 { //下架
+		set = map[string]interface{}{"state": state}
+	} else if state == 5 { //上架
+		//time.Sleep(1 * time.Minute) //更新太多了,防止这个luaconfig_online更新动作在luaconfig之前
+		lua, _ := u.MgoEB.FindOne("luaconfig", map[string]interface{}{"code": code})
+		if len(*lua) > 0 {
+			set = *lua
+		} else {
+			return false
+		}
 	}
+	return u.MgoEB.Update("luaconfig_online", query, map[string]interface{}{"$set": set}, upsert, false)
 }

+ 1 - 4
src/web/staticres/css/style.css

@@ -163,7 +163,7 @@
 	padding:4px 10px;
 }
 
-#code-assign{
+.code-assign{
 	margin-left:20px;
 }
 
@@ -171,9 +171,6 @@
 	margin-top: -19px;
 }	
 
-#assign-style{
-	margin-left:22%;
-}
 #modal-assign .modal-header{
 	border-bottom:0px;
 }

+ 1 - 1
src/web/templates/head.html

@@ -215,7 +215,7 @@
 	                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
 					<div class="edit-form">
 						<div class="edit-info">
-							<span class="glyphicon glyphicon-briefcase" aria-hidden="true"></span>
+							<span class="glyphicon glyphicon-briefcase code-assign" aria-hidden="true"></span>
 							<span class="info">新建任务<span>
 						</div>
 						<form class="form-horizontal" role="form">

+ 100 - 13
src/web/templates/index.html

@@ -9,28 +9,28 @@
 <!--	                <button type="button" id="assign-close" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>-->
 					<!--<div class="edit-form">-->
 						<div class="edit-info">
-							<span class="glyphicon glyphicon-share-alt" id="code-assign" aria-hidden="true"></span>
+							<span class="glyphicon glyphicon-remove code-assign"aria-hidden="true"></span>
 							<span class="info">爬虫分配<span>
 						</div>
 						<form class="form-horizontal" role="form">
 							 <div class="form-group">
-							    <label for="modify" class="col-sm-2 control-label">邮箱地址:</label>
+							    <label class="col-sm-2 control-label">邮箱地址:</label>
 							    <div class="col-sm-10">
 							      <select class="form-control" id="assign-modify"></select>
 							    </div>
 								<span class="modifyCheck hide">请选择维护人员</span>
 							  </div>
 							<div class="form-group">
-								  <label for="modify" class="col-sm-2 control-label">转移内容:</label>
+								  <label  class="col-sm-2 control-label">转移内容:</label>
 							</div>
 							<div class="form-group">
 								<ul class="list-group">
 									
 								</ul>
 							</div>
-							<div class="form-group" id="assign-style">
+							<div class="form-group">
 							    <div class="col-sm-offset-2 col-sm-10">
-							      	<input type="button" onclick="assign_save()" class="btn btn-primary" value="分配">
+							      	<input type="button" onclick="assign_save()" class="btn btn-primary" value="确认">
 									<input type="button" data-dismiss="modal" class="btn btn-default" value="取消">
 							    </div>
 							</div>
@@ -41,8 +41,47 @@
         </div><!-- /.modal-content -->
     </div><!-- /.modal -->
 </div>
-
-<!-- 爬虫作废模态框(Modal) -->
+<!-- 站点分配模态框(Modal) -->
+<div class="modal fade" id="modal-platform" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
+	<div class="modal-dialog">
+		<div class="modal-content">
+			<div class="modal-header">
+				<div class="modal-header">
+					<button type="button" class="close" data-dismiss="modal" aria-hidden="true" style="margin-top: -19px">&times;</button>
+					<!--	                <button type="button" id="assign-close" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>-->
+					<!--<div class="edit-form">-->
+					<div class="edit-info">
+						<span class="glyphicon glyphicon-remove code-assign"aria-hidden="true"></span>
+						<span class="info">平台修改<span>
+					</div>
+					<form class="form-horizontal" role="form">
+						<div class="form-group">
+							<label for="modify" class="col-sm-2 control-label">平台:</label>
+							<div class="col-sm-10">
+								<select class="form-control" id="select-update-platform">
+									<option value='golua平台'>golua平台</option>
+									<option value='chrome'>chrome</option>
+									<option value='python'>python</option>
+									<option value='通用平台'>通用平台</option>
+									<option value='jschrome'>jschrome</option>
+								</select>
+							</div>
+							<span class="modifyCheck hide">请选择维护人员</span>
+						</div>
+						<div class="form-group" >
+							<div class="col-sm-offset-2 col-sm-10">
+								<input type="button" onclick="updatePlatform()" class="btn btn-primary" value="确认">
+								<input type="button" data-dismiss="modal" class="btn btn-default" value="取消">
+							</div>
+						</div>
+					</form>
+					<!--</div>	-->
+				</div>
+			</div>
+		</div><!-- /.modal-content -->
+	</div><!-- /.modal -->
+</div>
+<!-- 爬虫状态模态框(Modal) -->
 <div class="modal fade" id="modal-disables" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
     <div class="modal-dialog">
         <div class="modal-content">
@@ -74,7 +113,7 @@
 									<textarea class="form-control" id="disablereason"></textarea>
 							    </div>
 							</div>
-							<div class="form-group" id="assign-style">
+							<div class="form-group">
 							    <div class="col-sm-offset-2 col-sm-10">
 							      	<input type="button" onclick="comfirm_disables()" class="btn btn-primary" value="确定">
 									<input type="button" data-dismiss="modal" class="btn btn-default" value="取消">
@@ -96,7 +135,7 @@
 					<button type="button" class="close" data-dismiss="modal" aria-hidden="true" style="margin-top: -19px">&times;</button>
 					<!--<div class="edit-form">-->
 					<div class="edit-info">
-						<span class="fa fa-copy" id="code-assign" aria-hidden="true"></span>
+						<span class="fa fa-copy code-assign"  aria-hidden="true"></span>
 						<span class="info">爬虫归还<span>
 					</div>
 					<form class="form-horizontal" role="form">
@@ -106,7 +145,7 @@
 								<textarea id="returnreason" rows="2" cols="50" ></textarea>
 							</div>
 						</div>
-						<div class="form-group" id="assign-style">
+						<div class="form-group">
 							<div class="col-sm-offset-2 col-sm-10">
 								<input type="button" onclick="comfirm_returncode()" class="btn btn-primary" value="确定">
 								<input type="button" data-dismiss="modal" class="btn btn-default" value="取消">
@@ -128,7 +167,7 @@
 					<button type="button" class="close" data-dismiss="modal" aria-hidden="true" style="margin-top: -19px">&times;</button>
 					<!--<div class="edit-form">-->
 						<div class="edit-info">
-							<span class="fa fa-copy" id="code-assign" aria-hidden="true"></span>
+							<span class="fa fa-copy code-assign"  aria-hidden="true"></span>
 							<span class="info">补采复制<span>
 						</div>
 						<form class="form-horizontal" role="form">
@@ -138,7 +177,7 @@
 									<input class="form-control" id="spidercopy"></input>
 							    </div>
 							</div>
-							<div class="form-group" id="assign-style">
+							<div class="form-group" >
 							    <div class="col-sm-offset-2 col-sm-10">
 							      	<input type="button" onclick="comfirm_spidercopy()" class="btn btn-primary" value="确定">
 									<input type="button" data-dismiss="modal" class="btn btn-default" value="取消">
@@ -160,7 +199,7 @@
 					<button type="button" class="close" data-dismiss="modal" aria-hidden="true" style="margin-top: -19px">&times;</button>
 					<!--<div class="edit-form">-->
 					<div class="edit-info">
-						<span class="fa fa-copy" id="code-assign" aria-hidden="true"></span>
+						<span class="fa fa-copy code-assign"  aria-hidden="true"></span>
 						<span class="info">拆分复制<span>
 					</div>
 					<form class="form-horizontal" role="form">
@@ -207,6 +246,7 @@
 		<!--<a class="btn btn-default btn-sm" href="/center/spider">新建爬虫</a>-->
 		 <a class="btn btn-info btn-sm" onclick="spidercopysplit()">拆分复制</a>
 		<a class="btn btn-success btn-sm" id="assign" onclick="assign()">分配爬虫</a>
+		 <a class="btn btn-success btn-sm" id="updatePlatform" onclick="assignPlatform()">分配平台</a>
 		<a class="btn btn-warning btn-sm" id="disables" onclick="disables()">状态修改</a>
 		{{end}}
 	 </small>
@@ -1050,6 +1090,53 @@
 			})
 		}
     }
+	
+	//修改平台
+	function assignPlatform() {
+		var codes=[];
+		$("#spider td input[type=checkbox]").each(function(){
+			if($(this).prop("checked")){
+				codes.push($(this).attr("code"));
+			}
+		});
+		if(codes.length==0){
+			showTip("没有选择项或全部爬虫无法被分配!", 2000, function() {});
+			$("#selrow").prop('checked',false);
+			return;
+		}
+		$("#modal-platform").modal("show");
+	}
+	
+	function updatePlatform() {
+		$("#modal-platform").modal("hide");
+		var platform = $("#select-update-platform").val();
+		var codes=[];
+		$("#spider td input[type=checkbox]").each(function(){
+			if($(this).prop("checked")){
+				codes.push($(this).attr("code"));
+			}
+		});
+		if(codes.length == 0){
+			showTip("所选爬虫不可重新分配!", 2000, function() {});
+			return;
+		}
+		$.ajax({
+			url:"/center/spider/updateplatform",
+			type:"post",
+			data:{codes:codes.join(","),platform:platform},
+			success:function(r){
+				if(r=="y"){
+					showTip("分配成功", 500, function() {});
+					$("#selrow").prop('checked',false);
+					$('#com-alert').on('hidden.bs.modal', function () {
+						ttable.ajax.reload();
+					})
+				}else if(r=="n"){
+					showTip("分配失败", 1000, function() {});
+				}
+			}
+		})
+	}
 	//点击分配
 	function assign(){
 		var names=[];

+ 2 - 2
src/web/templates/newtasklist.html

@@ -7,7 +7,7 @@
 	                <button type="button" id="assign-close" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
 					<!--<div class="edit-form">-->
 						<div class="edit-info">
-							<span class="glyphicon glyphicon-remove" id="code-assign" aria-hidden="true"></span>
+							<span class="glyphicon glyphicon-remove code-assign"aria-hidden="true"></span>
 							<span class="info">爬虫分发<span>
 						</div>
 						<form class="form-horizontal" role="form">
@@ -17,7 +17,7 @@
 									<textarea class="form-control" id="reason"></textarea>
 							    </div>
 							</div>
-							<div class="form-group" id="assign-style">
+							<div class="form-group">
 							    <div class="col-sm-offset-2 col-sm-10">
 							      	<input type="button" onclick="comfirm_disables()" class="btn btn-primary" value="确定">
 									<input type="button" onclick="disables_cancel()" class="btn btn-default" value="取消">

+ 2 - 2
src/web/templates/task.html

@@ -7,7 +7,7 @@
 	                <button type="button" id="assign-close" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
 					<!--<div class="edit-form">-->
 						<div class="edit-info">
-							<span class="glyphicon glyphicon-remove" id="code-assign" aria-hidden="true"></span>
+							<span class="glyphicon glyphicon-remove code-assign"  aria-hidden="true"></span>
 							<span class="info">爬虫分发<span>
 						</div>
 						<form class="form-horizontal" role="form">
@@ -17,7 +17,7 @@
 									<textarea class="form-control" id="reason"></textarea>
 							    </div>
 							</div>
-							<div class="form-group" id="assign-style">
+							<div class="form-group">
 							    <div class="col-sm-offset-2 col-sm-10">
 							      	<input type="button" onclick="comfirm_disables()" class="btn btn-primary" value="确定">
 									<input type="button" onclick="disables_cancel()" class="btn btn-default" value="取消">

+ 1 - 1
src/web/templates/yesterdaycount.html

@@ -7,7 +7,7 @@
                 <div class="modal-header">
                     <button type="button" class="close" data-dismiss="modal" aria-hidden="true" style="margin-top: -19px">&times;</button>
                     <div class="edit-info">
-                        <span class="fa fa-bar-chart-o" id="code-assign" aria-hidden="true"></span>
+                        <span class="fa fa-bar-chart-o code-assign" aria-hidden="true"></span>
                         <span class="info">采集详情<span>
                     </div>
                     <div class="modal-body">