Commit dc4969cd by shenjinzhu

一键启动和一键停止的添加

parent 6d5dc256
......@@ -12,6 +12,7 @@ import org.springframework.data.mongodb.core.mapping.Field;
import org.springframework.stereotype.Component;
@Component
@Document(collection = "Template")
public class Template implements Serializable {
/**
......
......@@ -10,6 +10,8 @@ import javax.annotation.Resource;
import org.bson.types.ObjectId;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.stereotype.Component;
import com.mongodb.BasicDBObject;
......@@ -32,21 +34,28 @@ public class MessageDaoImpl implements MessageDao {
@Override
public String insert(Message message) {
mongo.insert(message);
return "添加成功";
Message msg = mongo.findOne(Query.query(
Criteria.where("tempName").is(message.getTempName()).andOperator(Criteria.where("handle").is(false))
.andOperator(Criteria.where("errorMsg").is(message.getErrorMsg()))),
Message.class);
if (msg == null) {
mongo.insert(message);
return "添加成功";
}
return "未添加";
}
@Override
public String update(Message message,String pt) {
public String update(Message message, String pt) {
DBCollection con = null;
if (DbDepot.dbCons.get(pt+"msg") != null) {
con = (DBCollection) DbDepot.dbCons.get(pt+"msg");
if (DbDepot.dbCons.get(pt + "msg") != null) {
con = (DBCollection) DbDepot.dbCons.get(pt + "msg");
} else {
con = dbDepot.getDBCollection("msg",pt);
con = dbDepot.getDBCollection("msg", pt);
}
if (con == null) {
return null;
}
}
DBObject obj = new BasicDBObject();
obj.put("handle", message.isHandle());
obj.put("handleDate", new Date());
......@@ -64,19 +73,19 @@ public class MessageDaoImpl implements MessageDao {
}
@Override
public List<Message> findAll(int pageNo, int pageSize,String pt) {
public List<Message> findAll(int pageNo, int pageSize, String pt) {
List<Message> msgList = new ArrayList<Message>();
DBCollection con = null;
if (DbDepot.dbCons.get(pt+"msg") != null) {
con = (DBCollection) DbDepot.dbCons.get(pt+"msg");
if (DbDepot.dbCons.get(pt + "msg") != null) {
con = (DBCollection) DbDepot.dbCons.get(pt + "msg");
} else {
con = dbDepot.getDBCollection("msg",pt);
con = dbDepot.getDBCollection("msg", pt);
}
if (con == null) {
return null;
}
DBCursor cursor = con.find(new BasicDBObject("pt", pt).append("handle", false))
.skip((pageNo - 1) * pageSize).limit(pageSize).sort(new BasicDBObject("createDate", -1));
DBCursor cursor = con.find(new BasicDBObject("pt", pt).append("handle", false)).skip((pageNo - 1) * pageSize)
.limit(pageSize).sort(new BasicDBObject("createDate", -1));
while (cursor.hasNext()) {
Map<String, Object> map = (Map<String, Object>) cursor.next();
Message msg = Change.toBean(Message.class, map);
......@@ -88,20 +97,19 @@ public class MessageDaoImpl implements MessageDao {
}
@Override
public List<Message> findByTmpName(String templateName, int pageNo, int pageSize,String pt) {
public List<Message> findByTmpName(String templateName, int pageNo, int pageSize, String pt) {
List<Message> msgList = new ArrayList<Message>();
DBCollection con = null;
if (DbDepot.dbCons.get(pt+"msg") != null) {
con = (DBCollection) DbDepot.dbCons.get(pt+"msg");
if (DbDepot.dbCons.get(pt + "msg") != null) {
con = (DBCollection) DbDepot.dbCons.get(pt + "msg");
} else {
con = dbDepot.getDBCollection("msg",pt);
con = dbDepot.getDBCollection("msg", pt);
}
if (con == null) {
return null;
}
DBCursor cursor = con
.find(new BasicDBObject("pt", pt).append("tempName",
new BasicDBObject("$regex", templateName)))
.find(new BasicDBObject("pt", pt).append("tempName", new BasicDBObject("$regex", templateName)))
.skip((pageNo - 1) * pageSize).limit(pageSize).sort(new BasicDBObject("createDate", -1));
while (cursor.hasNext()) {
Map<String, Object> map = (Map<String, Object>) cursor.next();
......@@ -114,12 +122,12 @@ public class MessageDaoImpl implements MessageDao {
}
@Override
public boolean delete(List<String> messageId,String pt) {
public boolean delete(List<String> messageId, String pt) {
DBCollection con = null;
if (DbDepot.dbCons.get(pt+"msg") != null) {
con = (DBCollection) DbDepot.dbCons.get(pt+"msg");
if (DbDepot.dbCons.get(pt + "msg") != null) {
con = (DBCollection) DbDepot.dbCons.get(pt + "msg");
} else {
con = dbDepot.getDBCollection("msg",pt);
con = dbDepot.getDBCollection("msg", pt);
}
if (con == null) {
return false;
......@@ -127,7 +135,7 @@ public class MessageDaoImpl implements MessageDao {
System.out.println(con);
for (String msg : messageId) {
WriteResult wr = con.remove(new BasicDBObject("_id", new ObjectId(msg)));
if(wr.getN()==0) {
if (wr.getN() == 0) {
return false;
}
}
......@@ -137,46 +145,47 @@ public class MessageDaoImpl implements MessageDao {
@Override
public int allCount(String pt) {
DBCollection con = null;
if (DbDepot.dbCons.get(pt+"msg") != null) {
con = (DBCollection) DbDepot.dbCons.get(pt+"msg");
if (DbDepot.dbCons.get(pt + "msg") != null) {
con = (DBCollection) DbDepot.dbCons.get(pt + "msg");
} else {
con = dbDepot.getDBCollection("msg",pt);
con = dbDepot.getDBCollection("msg", pt);
}
if (con == null) {
return 0;
}
return (int) con.count(new BasicDBObject("handle", false).append("pt",pt ));
return (int) con.count(new BasicDBObject("handle", false).append("pt", pt));
}
@Override
public int findByTmpCount(String templateName,String pt) {
public int findByTmpCount(String templateName, String pt) {
DBCollection con = null;
if (DbDepot.dbCons.get(pt+"msg") != null) {
con = (DBCollection) DbDepot.dbCons.get(pt+"msg");
if (DbDepot.dbCons.get(pt + "msg") != null) {
con = (DBCollection) DbDepot.dbCons.get(pt + "msg");
} else {
con = dbDepot.getDBCollection("msg",pt);
con = dbDepot.getDBCollection("msg", pt);
}
if (con == null) {
return 0;
}
return (int) con.count(new BasicDBObject("tempName", new BasicDBObject("$regex", templateName)).append("pt",pt ));
return (int) con
.count(new BasicDBObject("tempName", new BasicDBObject("$regex", templateName)).append("pt", pt));
}
@Override
public List<Message> findByHandle(int pageNo, int pageSize, boolean handle, String tempName,String pt) {
public List<Message> findByHandle(int pageNo, int pageSize, boolean handle, String tempName, String pt) {
DBCollection con = null;
if (DbDepot.dbCons.get(pt+"msg") != null) {
con = (DBCollection) DbDepot.dbCons.get(pt+"msg");
if (DbDepot.dbCons.get(pt + "msg") != null) {
con = (DBCollection) DbDepot.dbCons.get(pt + "msg");
} else {
con = dbDepot.getDBCollection("msg",pt);
con = dbDepot.getDBCollection("msg", pt);
}
if (con == null) {
return null;
}
List<Message> msgList = new ArrayList<Message>();
if (tempName == null || tempName.equals("")) {
DBCursor cur = con.find(new BasicDBObject("handle", handle).append("pt",pt )).sort(new BasicDBObject("createDate", -1))
.skip((pageNo - 1) * pageSize).limit(pageSize);
DBCursor cur = con.find(new BasicDBObject("handle", handle).append("pt", pt))
.sort(new BasicDBObject("createDate", -1)).skip((pageNo - 1) * pageSize).limit(pageSize);
while (cur.hasNext()) {
Map<String, Object> map = (Map<String, Object>) cur.next();
Message msg = Change.toBean(Message.class, map);
......@@ -186,8 +195,8 @@ public class MessageDaoImpl implements MessageDao {
return msgList;
} else {
DBCursor cur = con
.find(new BasicDBObject("handle", handle).append("tempName",
new BasicDBObject("$regex", tempName)).append("pt",pt))
.find(new BasicDBObject("handle", handle).append("tempName", new BasicDBObject("$regex", tempName))
.append("pt", pt))
.sort(new BasicDBObject("createDate", -1)).skip((pageNo - 1) * pageSize).limit(pageSize);
while (cur.hasNext()) {
Map<String, Object> map = (Map<String, Object>) cur.next();
......@@ -201,21 +210,21 @@ public class MessageDaoImpl implements MessageDao {
}
@Override
public int findByHandleCount(int pageNo, int pageSize, boolean handle, String tempName,String pt) {
public int findByHandleCount(int pageNo, int pageSize, boolean handle, String tempName, String pt) {
DBCollection con = null;
if (DbDepot.dbCons.get(pt+"msg") != null) {
con = (DBCollection) DbDepot.dbCons.get(pt+"msg");
if (DbDepot.dbCons.get(pt + "msg") != null) {
con = (DBCollection) DbDepot.dbCons.get(pt + "msg");
} else {
con = dbDepot.getDBCollection("msg",pt);
con = dbDepot.getDBCollection("msg", pt);
}
if (con == null) {
return 0;
}
if (tempName == null || tempName.equals("")) {
return (int) con.count(new BasicDBObject("handle", handle).append("pt",pt));
return (int) con.count(new BasicDBObject("handle", handle).append("pt", pt));
} else {
return (int) con.count(new BasicDBObject("handle", handle)
.append("tempName", new BasicDBObject("$regex",tempName)).append("pt",pt));
.append("tempName", new BasicDBObject("$regex", tempName)).append("pt", pt));
}
}
}
......@@ -13,6 +13,8 @@ public interface TemplateDao {
public boolean update(Template template);
public List<Template> findAll(int pageNo,int pageSize,String pt);
public List<Template> findAll();
public Template findById(String templateId,String pt);
......
......@@ -36,12 +36,7 @@ public class TemplateDaoImpl implements TemplateDao {
@Override
public boolean insert(Template template) {
DBCollection con = null;
if (DbDepot.dbCons.get(template.getPt()+"temp") != null) {
con = (DBCollection) DbDepot.dbCons.get(template.getPt()+"temp");
} else {
con = dbDepot.getDBCollection("msg",template.getPt());
}
DBCollection con = getCollection(template.getPt());
if (con == null) {
return false;
}
......@@ -66,13 +61,7 @@ public class TemplateDaoImpl implements TemplateDao {
@Override
public boolean update(Template template) {
System.out.println(template);
DBCollection con = null;
if (DbDepot.dbCons.get(template.getPt()+"temp") != null) {
con = (DBCollection) DbDepot.dbCons.get(template.getPt()+"temp");
} else {
con = dbDepot.getDBCollection("temp",template.getPt());
}
DBCollection con = getCollection(template.getPt());
if (con == null) {
return false;
}
......@@ -96,18 +85,12 @@ public class TemplateDaoImpl implements TemplateDao {
DBObject query = new BasicDBObject();
query.put("_id", new ObjectId(template.getTemplateId()));
WriteResult result = con.update(query, update, false, false);
System.out.println(result.getN());
return result.getN() == 1 ? true : false;
}
@Override
public Template findById(String templateId,String pt) {
DBCollection con = null;
if (DbDepot.dbCons.get(pt+"temp") != null) {
con = (DBCollection) DbDepot.dbCons.get(pt+"temp");
} else {
con = dbDepot.getDBCollection("temp",pt);
}
DBCollection con = getCollection(pt);
if (con == null) {
return null;
}
......@@ -116,23 +99,12 @@ public class TemplateDaoImpl implements TemplateDao {
temp=Change.toBean(Template.class, map);
temp.setTemplateId(String.valueOf(map.get("_id")));
return temp;
// return mongo.findOne(Query.query(Criteria.where("_id").is(templateId)
// .andOperator(Criteria.where("pt").is(DbDepot.nowPt)))
// .with(new Sort(new Order(Direction.DESC, "createDate"))), Template.class);
}
@Override
public List<Template> findByTmpName(String templateName, int pageNo, int pageSize,String pt) {
List<Template> list=new ArrayList<Template>();
DBCollection con = null;
if (DbDepot.dbCons.get(pt+"temp") != null) {
con = (DBCollection) DbDepot.dbCons.get(pt+"temp");
} else {
con = dbDepot.getDBCollection("temp",pt);
}
if (con == null) {
return null;
}
DBCollection con = getCollection(pt);
DBObject query=new BasicDBObject();
query.put("tempName", new BasicDBObject("$regex",templateName));
query.put("pt", pt);
......@@ -149,12 +121,7 @@ public class TemplateDaoImpl implements TemplateDao {
@Override
public boolean delete(String templateId,String pt) {
DBCollection con = null;
if (DbDepot.dbCons.get(pt+"temp") != null) {
con = (DBCollection) DbDepot.dbCons.get(pt+"temp");
} else {
con = dbDepot.getDBCollection("temp",pt);
}
DBCollection con = getCollection(pt);
if (con == null) {
return false;
}
......@@ -162,15 +129,12 @@ public class TemplateDaoImpl implements TemplateDao {
return result.getN() == 0 ? true : false;
}
@Override
public List<Template> findAll(int pageNo, int pageSize,String pt) {
List<Template> list=new ArrayList<Template>();
DBCollection con = null;
if (DbDepot.dbCons.get(pt+"temp") != null) {
con = (DBCollection) DbDepot.dbCons.get(pt+"temp");
} else {
con = dbDepot.getDBCollection("temp",pt);
}
DBCollection con = getCollection(pt);
if (con == null) {
return null;
}
......@@ -187,14 +151,19 @@ public class TemplateDaoImpl implements TemplateDao {
return list;
}
@Override
public int allCount(String pt) {
public DBCollection getCollection(String pt) {
DBCollection con = null;
if (DbDepot.dbCons.get(pt+"temp") != null) {
con = (DBCollection) DbDepot.dbCons.get(pt+"temp");
} else {
con = dbDepot.getDBCollection("temp",pt);
}
return con;
}
@Override
public int allCount(String pt) {
DBCollection con = getCollection(pt);
if (con == null) {
return 0;
}
......@@ -203,12 +172,7 @@ public class TemplateDaoImpl implements TemplateDao {
@Override
public int findByUserCount(String templateName,String pt) {
DBCollection con = null;
if (DbDepot.dbCons.get(pt+"temp") != null) {
con = (DBCollection) DbDepot.dbCons.get(pt+"temp");
} else {
con = dbDepot.getDBCollection("temp",pt);
}
DBCollection con = getCollection(pt);
if (con == null) {
return 0;
}
......@@ -216,4 +180,9 @@ public class TemplateDaoImpl implements TemplateDao {
.append("pt", pt));
}
@Override
public List<Template> findAll() {
return mongo.find(null, Template.class);
}
}
......@@ -176,7 +176,7 @@ public class MainThread extends Thread {
System.out.println(list.size());
for (CrawTemplate cr : list) {
count = (int) dataService.finCountByDayData(start.getTime(), end.getTime(),
chan.getPt(), cr.getId());
cr.getPt(), cr.getId());
Data data = new Data();
data.setCount(count);
data.setTempName(cr.getConfigName());
......@@ -185,7 +185,7 @@ public class MainThread extends Thread {
dataService.insert(data);
if (count == 0) {
int testCount = (int) dataService.finCountByDayData(countTest.getTime(),
end.getTime(), chan.getPt(), cr.getId());
end.getTime(), cr.getPt(), cr.getId());
if (testCount == 0) {
Message m = new Message();
m.setHandle(false);
......@@ -193,7 +193,7 @@ public class MainThread extends Thread {
m.setTemplateLv(1);
m.setTempName(cr.getConfigName());
m.setPt(cr.getPt());
m.setErrorMsg("数据为0检测:" + cr.getConfigName() + "," + chan.getId() + "数据为0");
m.setErrorMsg("数据为0检测:" + cr.getConfigName() + "," + cr.getId() + "数据为0");
msgService.insert(m);
}
}
......
package com.zhiwei.manage.service;
import java.util.List;
import com.zhiwei.manage.bean.PageEty;
import com.zhiwei.manage.bean.Template;
......@@ -10,6 +12,8 @@ public interface TemplateService {
public boolean update(Template template);
public PageEty findAll(int pageNo,int pageSize,String pt);
public List<Template> findAll();
public Template findById(String templateId,String pt);
......
......@@ -45,18 +45,18 @@ public class TemplateServiceImpl implements TemplateService {
}
@Override
public PageEty findAll(int pageNo,int pageSize,String pt) {
int count=tempDao.allCount(pt);
List<Template> data=tempDao.findAll(pageNo, pageSize,pt);
for(Template tp:data){
if(MainThread.allTmp.get(tp.getTemplateId())==null){
public PageEty findAll(int pageNo, int pageSize, String pt) {
int count = tempDao.allCount(pt);
List<Template> data = tempDao.findAll(pageNo, pageSize, pt);
for (Template tp : data) {
if (MainThread.allTmp.get(tp.getTemplateId()) == null) {
MainThread.allTmp.put(tp.getTemplateId(), tp);
}
if(MainThread.mainMap.get(tp.getTemplateId())!=null){
if (MainThread.mainMap.get(tp.getTemplateId()) != null) {
tp.setOpen(true);
}
}
PageEty page=new PageEty();
PageEty page = new PageEty();
page.setData(data);
page.setDataCount(count);
page.setPageNo(pageNo);
......@@ -69,27 +69,27 @@ public class TemplateServiceImpl implements TemplateService {
}
@Override
public Template findById(String templateId,String pt) {
return tempDao.findById(templateId,pt);
public Template findById(String templateId, String pt) {
return tempDao.findById(templateId, pt);
}
@Override
public PageEty findByTmpName(String templateName,int pageNo,int pageSize,String pt) {
public PageEty findByTmpName(String templateName, int pageNo, int pageSize, String pt) {
try {
int count=tempDao.findByUserCount(templateName,pt);
List<Template> data=tempDao.findByTmpName(templateName, pageNo, pageSize,pt);
for(Template tp:data){
if(MainThread.allTmp.get(tp.getTemplateId())==null){
int count = tempDao.findByUserCount(templateName, pt);
List<Template> data = tempDao.findByTmpName(templateName, pageNo, pageSize, pt);
for (Template tp : data) {
if (MainThread.allTmp.get(tp.getTemplateId()) == null) {
MainThread.allTmp.put(tp.getTemplateId(), tp);
}
if(MainThread.mainMap.get(tp.getTemplateId())!=null){
if (MainThread.mainMap.get(tp.getTemplateId()) != null) {
tp.setOpen(true);
}
}
PageEty page=new PageEty();
if(data.size()==0){
PageEty page = new PageEty();
if (data.size() == 0) {
page.setData(new ArrayList<>());
}else{
} else {
page.setData(data);
}
page.setPageNo(pageNo);
......@@ -107,13 +107,27 @@ public class TemplateServiceImpl implements TemplateService {
}
@Override
public boolean delete(String templateId,String pt) {
public boolean delete(String templateId, String pt) {
try {
return tempDao.delete(templateId,pt);
return tempDao.delete(templateId, pt);
} catch (Exception e) {
e.printStackTrace();
return false;
}
}
@Override
public List<Template> findAll() {
List<Template> list = tempDao.findAll();
for (Template tp : list) {
if (MainThread.allTmp.get(tp.getTemplateId()) == null) {
MainThread.allTmp.put(tp.getTemplateId(), tp);
}
if (MainThread.mainMap.get(tp.getTemplateId()) != null) {
tp.setOpen(true);
}
}
return list;
}
}
......@@ -2,9 +2,11 @@ package com.zhiwei.manage.servlet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import javax.servlet.http.HttpServletRequest;
import org.apache.commons.logging.Log;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
......@@ -13,6 +15,7 @@ import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import com.alibaba.fastjson.JSON;
import com.mysql.jdbc.log.LogFactory;
import com.zhiwei.manage.bean.FieldBean;
import com.zhiwei.manage.bean.JsonResult;
import com.zhiwei.manage.bean.PageEty;
......@@ -24,11 +27,37 @@ import com.zhiwei.manage.service.TemplateService;
@Controller
public class TemplateController {
private static final Log log=org.apache.commons.logging.LogFactory.getLog(TemplateController.class);
@Autowired
private TemplateService ts;
@Autowired
private FieldBeanService fb;
@RequestMapping(value = "/startAll", produces = "application/json;charset=utf-8")
@ResponseBody
public String startAll() {
List<Template> tpList=ts.findAll();
for(Template t:tpList) {
MainThread.pushMap(t.getTemplateId());
}
JsonResult result = new JsonResult(true, 200, "启动成功");
return JSON.toJSONString(result);
}
@RequestMapping(value = "/stopAll", produces = "application/json;charset=utf-8")
@ResponseBody
public String stopAll() {
Set<String> ids=MainThread.mainMap.keySet();
for(String id:ids) {
try {
MainThread.removeMap(id);
}catch(Exception e) {
log.error("停止失败{}",e);
}
}
JsonResult result = new JsonResult(true, 200, "停止成功");
return JSON.toJSONString(result);
}
@RequestMapping(value = "/saveTmp", produces = "application/json;charset=utf-8")
@ResponseBody
public String saveTmp(@RequestBody Template template) {
......@@ -38,7 +67,7 @@ public class TemplateController {
return JSON.toJSONString(result);
}
}
JsonResult result = new JsonResult(false, 200, "保存失败");
JsonResult result = new JsonResult(true, 200, "保存失败");
return JSON.toJSONString(result);
}
......
<!DOCTYPE html><html><head><meta charset=utf-8><meta name=viewport content="width=device-width,initial-scale=1"><title>数据管理系统</title><link rel=stylesheet href=./static/css/style.ini.css><link rel=stylesheet href=./static/datepicker/css/datepicker.css><link rel=stylesheet href=./static/datepicker/css/layout.css><link href=./static/css/app.921ce7ebf497e3e3e68ca86ac4ac8b7d.css rel=stylesheet></head><body><div id=app></div><script type=text/javascript src=./static/js/manifest.742ad85c13f695db2ef0.js></script><script type=text/javascript src=./static/js/vendor.c00def797876150978d2.js></script><script type=text/javascript src=./static/js/app.f00c0ff73ad487a928f0.js></script></body><script src=./static/js/jquery-1.12.4.min.js></script><script src=./static/js/jquery.easing-master/jquery.easing.min.js></script><script src=./static/js/jquery.transit.js></script><script src=./static/datepicker/js/datepicker.js></script><script src=./static/datepicker/js/eye.js></script><script src=./static/datepicker/js/utils.js></script></html>
\ No newline at end of file
<!DOCTYPE html><html><head><meta charset=utf-8><meta name=viewport content="width=device-width,initial-scale=1"><title>数据管理系统</title><link rel=stylesheet href=./static/css/style.ini.css><link rel=stylesheet href=./static/datepicker/css/datepicker.css><link rel=stylesheet href=./static/datepicker/css/layout.css><link href=./static/css/app.92bad3cc55dab6eb58d4f6d580131955.css rel=stylesheet></head><body><div id=app></div><script type=text/javascript src=./static/js/manifest.1f643cf06e5671b25020.js></script><script type=text/javascript src=./static/js/vendor.c00def797876150978d2.js></script><script type=text/javascript src=./static/js/app.508ffe1db26d2a077b87.js></script></body><script src=./static/js/jquery-1.12.4.min.js></script><script src=./static/js/jquery.easing-master/jquery.easing.min.js></script><script src=./static/js/jquery.transit.js></script><script src=./static/datepicker/js/datepicker.js></script><script src=./static/datepicker/js/eye.js></script><script src=./static/datepicker/js/utils.js></script></html>
\ No newline at end of file
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
!function(e){function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}var r=window.webpackJsonp;window.webpackJsonp=function(t,c,a){for(var i,u,f,s=0,l=[];s<t.length;s++)u=t[s],o[u]&&l.push(o[u][0]),o[u]=0;for(i in c)Object.prototype.hasOwnProperty.call(c,i)&&(e[i]=c[i]);for(r&&r(t,c,a);l.length;)l.shift()();if(a)for(s=0;s<a.length;s++)f=n(n.s=a[s]);return f};var t={},o={2:0};n.e=function(e){function r(){i.onerror=i.onload=null,clearTimeout(u);var n=o[e];0!==n&&(n&&n[1](new Error("Loading chunk "+e+" failed.")),o[e]=void 0)}var t=o[e];if(0===t)return new Promise(function(e){e()});if(t)return t[2];var c=new Promise(function(n,r){t=o[e]=[n,r]});t[2]=c;var a=document.getElementsByTagName("head")[0],i=document.createElement("script");i.type="text/javascript",i.charset="utf-8",i.async=!0,i.timeout=12e4,n.nc&&i.setAttribute("nonce",n.nc),i.src=n.p+"static/js/"+e+"."+{0:"c00def797876150978d2",1:"f00c0ff73ad487a928f0"}[e]+".js";var u=setTimeout(r,12e4);return i.onerror=i.onload=r,a.appendChild(i),c},n.m=e,n.c=t,n.d=function(e,r,t){n.o(e,r)||Object.defineProperty(e,r,{configurable:!1,enumerable:!0,get:t})},n.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(r,"a",r),r},n.o=function(e,n){return Object.prototype.hasOwnProperty.call(e,n)},n.p="./",n.oe=function(e){throw console.error(e),e}}([]);
//# sourceMappingURL=manifest.742ad85c13f695db2ef0.js.map
\ No newline at end of file
......@@ -157,7 +157,7 @@ export default {
},
filters: {
format1 (timestemp) {
return moment(timestemp).format('YYYY-MM-DD hh:mm')
return moment(timestemp).format('YYYY-MM-DD HH:mm')
}
}
}
......
......@@ -3,6 +3,8 @@
<div class="title">
<input type="text" name="" value="" class="searchInput" spellcheck="false" placeholder="模板名" v-model="tempName" @keydown.enter="findAllTmp()">
<div class="right">
<button type="button" class="btn1" @click="allToggle(true)" v-if="userInfo.lv>=2">一键开启</button>
<button type="button" class="btn1" @click="allToggle(false)" v-if="userInfo.lv>=2">一键停止</button>
<button type="button" class="btn1" @click="popup.checkTemplateAdd = true" v-if="userInfo.lv>=2">新建模板</button>
<button type="button" class="btn1" @click="del()" v-if="userInfo.lv>=2">删除模板</button>
</div>
......@@ -97,7 +99,7 @@
import checkTemplateDetails from '@/components/module/checkTemplateDetails'
import checkTemplateDelete from '@/components/module/checkTemplateDelete'
import checkTemplateAdd from '@/components/module/checkTemplateAdd'
import { bus, requestFindAllTmp, requestStartTmp, requestStopTmp } from '@/vuex/request.js'
import { bus, requestFindAllTmp, requestStartTmp, requestStopTmp, requestStartAll, requestStopAll } from '@/vuex/request.js'
import { getPageList } from '@/assets/js/get-page-list.js'
export default {
......@@ -131,6 +133,34 @@ export default {
this.page = 1
},
methods: {
// 一键开关
allToggle (flag) {
if (flag) {
requestStartAll({}, {}, (response) => {
if (response.data) {
if (response.data.state) {
this.findAllTmp()
} else {
bus.$emit('alert', response.data.message)
}
} else {
bus.$emit('alert', response + '.')
}
})
} else {
requestStopAll({}, {}, (response) => {
if (response.data) {
if (response.data.state) {
this.findAllTmp()
} else {
bus.$emit('alert', response.data.message)
}
} else {
bus.$emit('alert', response + '.')
}
})
}
},
clearCheckbox () {
this.checkbox = [false, false, false, false, false, false, false, false, false, false]
},
......
......@@ -166,7 +166,7 @@ export default {
},
filters: {
format1 (timestemp) {
return moment(timestemp).format('YYYY-MM-DD hh:mm')
return moment(timestemp).format('YYYY-MM-DD HH:mm')
}
}
}
......
......@@ -17,7 +17,8 @@ export const dataUrl = '/datamanage/'
// -------------------- 自动判断请求方式
const requestMethodAuto = (params, data) => {
for (let i in data) { return 'post' }
for (let i in params) { return 'get' }
// for (let i in params) { return 'get' }
return 'get'
}
// -------------------- 数据管理系统 - 用户登录 ------------------ login
......@@ -482,3 +483,29 @@ export let requestGetAllFields = (params, data, callback) => {
callback(response)
})
}
// -------------------- 数据管理系统 - 检测模板 - 一键停止 ------------------ stopAll
export let requestStopAll = (params, data, callback) => {
axios({
url: dataUrl + 'stopAll',
method: requestMethodAuto(params, data),
params: params,
data: data
}).then((response) => {
callback(response)
}).catch((response) => {
callback(response)
})
}
// -------------------- 数据管理系统 - 检测模板 - 一键开启 ------------------ startAll
export let requestStartAll = (params, data, callback) => {
axios({
url: dataUrl + 'startAll',
method: requestMethodAuto(params, data),
params: params,
data: data
}).then((response) => {
callback(response)
}).catch((response) => {
callback(response)
})
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment