Commit f96b6266 by shenjinzhu

提交最新

parent ddcd0fc0
...@@ -8,17 +8,17 @@ public interface MessageDao { ...@@ -8,17 +8,17 @@ public interface MessageDao {
public String insert(Message message); public String insert(Message message);
public String update(Message message); public String update(Message message,String pt);
public List<Message> findAll(int pageNo,int pageSize,String pt); public List<Message> findAll(int pageNo,int pageSize,String pt);
public List<Message> findByTmpName(String templateName,int pageNo,int pageSize,String pt); public List<Message> findByTmpName(String templateName,int pageNo,int pageSize,String pt);
public boolean delete(List<String> MessageId); public boolean delete(List<String> MessageId,String pt);
public int allCount(); public int allCount(String pt);
public int findByTmpCount(String templateName); public int findByTmpCount(String templateName,String pt);
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);
......
...@@ -37,12 +37,12 @@ public class MessageDaoImpl implements MessageDao { ...@@ -37,12 +37,12 @@ public class MessageDaoImpl implements MessageDao {
} }
@Override @Override
public String update(Message message) { public String update(Message message,String pt) {
DBCollection con = null; DBCollection con = null;
if (DbDepot.dbCons.get("msg") != null) { if (DbDepot.dbCons.get(pt+"msg") != null) {
con = (DBCollection) DbDepot.dbCons.get("msg"); con = (DBCollection) DbDepot.dbCons.get(pt+"msg");
} else { } else {
con = dbDepot.getDBCollection("msg"); con = dbDepot.getDBCollection("msg",pt);
} }
if (con == null) { if (con == null) {
return null; return null;
...@@ -66,14 +66,15 @@ public class MessageDaoImpl implements MessageDao { ...@@ -66,14 +66,15 @@ public class MessageDaoImpl implements MessageDao {
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>(); List<Message> msgList = new ArrayList<Message>();
DBCollection con = null; DBCollection con = null;
if (DbDepot.dbCons.get("msg") != null) { if (DbDepot.dbCons.get(pt+"msg") != null) {
con = (DBCollection) DbDepot.dbCons.get("msg"); con = (DBCollection) DbDepot.dbCons.get(pt+"msg");
} else { } else {
con = dbDepot.getDBCollection("msg"); con = dbDepot.getDBCollection("msg",pt);
} }
if (con == null) { if (con == null) {
return null; return null;
} }
System.out.println(pt);
DBCursor cursor = con.find(new BasicDBObject("pt", pt).append("handle", false)) DBCursor cursor = con.find(new BasicDBObject("pt", pt).append("handle", false))
.skip((pageNo - 1) * pageSize).limit(pageSize).sort(new BasicDBObject("createDate", -1)); .skip((pageNo - 1) * pageSize).limit(pageSize).sort(new BasicDBObject("createDate", -1));
while (cursor.hasNext()) { while (cursor.hasNext()) {
...@@ -89,10 +90,10 @@ public class MessageDaoImpl implements MessageDao { ...@@ -89,10 +90,10 @@ public class MessageDaoImpl implements MessageDao {
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>(); List<Message> msgList = new ArrayList<Message>();
DBCollection con = null; DBCollection con = null;
if (DbDepot.dbCons.get("msg") != null) { if (DbDepot.dbCons.get(pt+"msg") != null) {
con = (DBCollection) DbDepot.dbCons.get("msg"); con = (DBCollection) DbDepot.dbCons.get(pt+"msg");
} else { } else {
con = dbDepot.getDBCollection("msg"); con = dbDepot.getDBCollection("msg",pt);
} }
if (con == null) { if (con == null) {
return null; return null;
...@@ -116,12 +117,12 @@ public class MessageDaoImpl implements MessageDao { ...@@ -116,12 +117,12 @@ public class MessageDaoImpl implements MessageDao {
} }
@Override @Override
public boolean delete(List<String> messageId) { public boolean delete(List<String> messageId,String pt) {
DBCollection con = null; DBCollection con = null;
if (DbDepot.dbCons.get("msg") != null) { if (DbDepot.dbCons.get(pt+"msg") != null) {
con = (DBCollection) DbDepot.dbCons.get("msg"); con = (DBCollection) DbDepot.dbCons.get(pt+"msg");
} else { } else {
con = dbDepot.getDBCollection("msg"); con = dbDepot.getDBCollection("msg",pt);
} }
if (con == null) { if (con == null) {
return false; return false;
...@@ -133,34 +134,34 @@ public class MessageDaoImpl implements MessageDao { ...@@ -133,34 +134,34 @@ public class MessageDaoImpl implements MessageDao {
} }
@Override @Override
public int allCount() { public int allCount(String pt) {
DBCollection con = null; DBCollection con = null;
if (DbDepot.dbCons.get("msg") != null) { if (DbDepot.dbCons.get(pt+"msg") != null) {
con = (DBCollection) DbDepot.dbCons.get("msg"); con = (DBCollection) DbDepot.dbCons.get(pt+"msg");
} else { } else {
con = dbDepot.getDBCollection("msg"); con = dbDepot.getDBCollection("msg",pt);
} }
if (con == null) { if (con == null) {
return 0; return 0;
} }
return (int) con.count(new BasicDBObject("handle", false).append("pt",DbDepot.nowPt )); return (int) con.count(new BasicDBObject("handle", false).append("pt",pt ));
// return (int) // return (int)
// mongo.count(Query.query(Criteria.where("handle").is(false)), // mongo.count(Query.query(Criteria.where("handle").is(false)),
// Message.class); // Message.class);
} }
@Override @Override
public int findByTmpCount(String templateName) { public int findByTmpCount(String templateName,String pt) {
DBCollection con = null; DBCollection con = null;
if (DbDepot.dbCons.get("msg") != null) { if (DbDepot.dbCons.get(pt+"msg") != null) {
con = (DBCollection) DbDepot.dbCons.get("msg"); con = (DBCollection) DbDepot.dbCons.get(pt+"msg");
} else { } else {
con = dbDepot.getDBCollection("msg"); con = dbDepot.getDBCollection("msg",pt);
} }
if (con == null) { if (con == null) {
return 0; return 0;
} }
return (int) con.count(new BasicDBObject("templateName", new BasicDBObject("$regex", templateName)).append("pt",DbDepot.nowPt )); return (int) con.count(new BasicDBObject("templateName", new BasicDBObject("$regex", templateName)).append("pt",pt ));
// return (int) // return (int)
// mongo.count(Query.query(Criteria.where("templateName").regex(templateName)), // mongo.count(Query.query(Criteria.where("templateName").regex(templateName)),
// Message.class); // Message.class);
...@@ -169,10 +170,10 @@ public class MessageDaoImpl implements MessageDao { ...@@ -169,10 +170,10 @@ public class MessageDaoImpl implements MessageDao {
@Override @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; DBCollection con = null;
if (DbDepot.dbCons.get("msg") != null) { if (DbDepot.dbCons.get(pt+"msg") != null) {
con = (DBCollection) DbDepot.dbCons.get("msg"); con = (DBCollection) DbDepot.dbCons.get(pt+"msg");
} else { } else {
con = dbDepot.getDBCollection("msg"); con = dbDepot.getDBCollection("msg",pt);
} }
if (con == null) { if (con == null) {
return null; return null;
...@@ -207,10 +208,10 @@ public class MessageDaoImpl implements MessageDao { ...@@ -207,10 +208,10 @@ public class MessageDaoImpl implements MessageDao {
@Override @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; DBCollection con = null;
if (DbDepot.dbCons.get("msg") != null) { if (DbDepot.dbCons.get(pt+"msg") != null) {
con = (DBCollection) DbDepot.dbCons.get("msg"); con = (DBCollection) DbDepot.dbCons.get(pt+"msg");
} else { } else {
con = dbDepot.getDBCollection("msg"); con = dbDepot.getDBCollection("msg",pt);
} }
if (con == null) { if (con == null) {
return 0; return 0;
......
...@@ -14,13 +14,13 @@ public interface TemplateDao { ...@@ -14,13 +14,13 @@ public interface TemplateDao {
public List<Template> findAll(int pageNo,int pageSize,String pt); public List<Template> findAll(int pageNo,int pageSize,String pt);
public Template findById(String templateId); public Template findById(String templateId,String pt);
public List<Template> findByTmpName(String templateName,int pageNo,int pageSize,String pt); public List<Template> findByTmpName(String templateName,int pageNo,int pageSize,String pt);
public boolean delete(String templateId); public boolean delete(String templateId,String pt);
public int allCount(); public int allCount(String pt);
public int findByUserCount(String templateName,String pt); public int findByUserCount(String templateName,String pt);
......
...@@ -37,10 +37,10 @@ public class TemplateDaoImpl implements TemplateDao { ...@@ -37,10 +37,10 @@ public class TemplateDaoImpl implements TemplateDao {
@Override @Override
public boolean insert(Template template) { public boolean insert(Template template) {
DBCollection con = null; DBCollection con = null;
if (DbDepot.dbCons.get("temp") != null) { if (DbDepot.dbCons.get(template.getPt()+"msg") != null) {
con = (DBCollection) DbDepot.dbCons.get("temp"); con = (DBCollection) DbDepot.dbCons.get(template.getPt()+"msg");
} else { } else {
con = dbDepot.getDBCollection("temp"); con = dbDepot.getDBCollection("msg",template.getPt());
} }
if (con == null) { if (con == null) {
return false; return false;
...@@ -61,17 +61,16 @@ public class TemplateDaoImpl implements TemplateDao { ...@@ -61,17 +61,16 @@ public class TemplateDaoImpl implements TemplateDao {
} }
} }
con.insert(obj); con.insert(obj);
// mongo.insert(template);
return true; return true;
} }
@Override @Override
public boolean update(Template template) { public boolean update(Template template) {
DBCollection con = null; DBCollection con = null;
if (DbDepot.dbCons.get("temp") != null) { if (DbDepot.dbCons.get(template.getPt()+"temp") != null) {
con = (DBCollection) DbDepot.dbCons.get("temp"); con = (DBCollection) DbDepot.dbCons.get(template.getPt()+"temp");
} else { } else {
con = dbDepot.getDBCollection("temp"); con = dbDepot.getDBCollection("temp",template.getPt());
} }
if (con == null) { if (con == null) {
return false; return false;
...@@ -101,17 +100,17 @@ public class TemplateDaoImpl implements TemplateDao { ...@@ -101,17 +100,17 @@ public class TemplateDaoImpl implements TemplateDao {
} }
@Override @Override
public Template findById(String templateId) { public Template findById(String templateId,String pt) {
DBCollection con = null; DBCollection con = null;
if (DbDepot.dbCons.get("temp") != null) { if (DbDepot.dbCons.get(pt+"temp") != null) {
con = (DBCollection) DbDepot.dbCons.get("temp"); con = (DBCollection) DbDepot.dbCons.get(pt+"temp");
} else { } else {
con = dbDepot.getDBCollection("temp"); con = dbDepot.getDBCollection("temp",pt);
} }
if (con == null) { if (con == null) {
return null; return null;
} }
Map<String,Object> map=(Map<String, Object>) con.findOne(new BasicDBObject("_id",new ObjectId(templateId)).append("pt", DbDepot.nowPt)); Map<String,Object> map=(Map<String, Object>) con.findOne(new BasicDBObject("_id",new ObjectId(templateId)).append("pt", pt));
Template temp=new Template(); Template temp=new Template();
temp=Change.toBean(Template.class, map); temp=Change.toBean(Template.class, map);
temp.setTemplateId(String.valueOf(map.get("_id"))); temp.setTemplateId(String.valueOf(map.get("_id")));
...@@ -125,10 +124,10 @@ public class TemplateDaoImpl implements TemplateDao { ...@@ -125,10 +124,10 @@ public class TemplateDaoImpl implements TemplateDao {
public List<Template> findByTmpName(String templateName, int pageNo, int pageSize,String pt) { public List<Template> findByTmpName(String templateName, int pageNo, int pageSize,String pt) {
List<Template> list=new ArrayList<Template>(); List<Template> list=new ArrayList<Template>();
DBCollection con = null; DBCollection con = null;
if (DbDepot.dbCons.get("temp") != null) { if (DbDepot.dbCons.get(pt+"temp") != null) {
con = (DBCollection) DbDepot.dbCons.get("temp"); con = (DBCollection) DbDepot.dbCons.get(pt+"temp");
} else { } else {
con = dbDepot.getDBCollection("temp"); con = dbDepot.getDBCollection("temp",pt);
} }
if (con == null) { if (con == null) {
return null; return null;
...@@ -145,26 +144,20 @@ public class TemplateDaoImpl implements TemplateDao { ...@@ -145,26 +144,20 @@ public class TemplateDaoImpl implements TemplateDao {
list.add(temp); list.add(temp);
} }
return list; return list;
// return mongo.find(Query
// .query(Criteria.where("templateName").is(templateName)
// .orOperator(Criteria.where("pt").is(DbDepot.nowPt)))
// .skip(pageNo).limit(pageSize).with(new Sort(new Order(Direction.ASC, "createDate"))), Template.class);
} }
@Override @Override
public boolean delete(String templateId) { public boolean delete(String templateId,String pt) {
DBCollection con = null; DBCollection con = null;
if (DbDepot.dbCons.get("temp") != null) { if (DbDepot.dbCons.get(pt+"temp") != null) {
con = (DBCollection) DbDepot.dbCons.get("temp"); con = (DBCollection) DbDepot.dbCons.get(pt+"temp");
} else { } else {
con = dbDepot.getDBCollection("temp"); con = dbDepot.getDBCollection("temp",pt);
} }
if (con == null) { if (con == null) {
return false; return false;
} }
WriteResult result=con.remove(new BasicDBObject("_id",new ObjectId(templateId))); WriteResult result=con.remove(new BasicDBObject("_id",new ObjectId(templateId)));
// WriteResult wr = mongo.remove(Query.query(Criteria.where("_id").is(templateId)), Template.class);
return result.getN() == 0 ? true : false; return result.getN() == 0 ? true : false;
} }
...@@ -172,10 +165,10 @@ public class TemplateDaoImpl implements TemplateDao { ...@@ -172,10 +165,10 @@ public class TemplateDaoImpl implements TemplateDao {
public List<Template> findAll(int pageNo, int pageSize,String pt) { public List<Template> findAll(int pageNo, int pageSize,String pt) {
List<Template> list=new ArrayList<Template>(); List<Template> list=new ArrayList<Template>();
DBCollection con = null; DBCollection con = null;
if (DbDepot.dbCons.get("temp") != null) { if (DbDepot.dbCons.get(pt+"temp") != null) {
con = (DBCollection) DbDepot.dbCons.get("temp"); con = (DBCollection) DbDepot.dbCons.get(pt+"temp");
} else { } else {
con = dbDepot.getDBCollection("temp"); con = dbDepot.getDBCollection("temp",pt);
} }
if (con == null) { if (con == null) {
return null; return null;
...@@ -188,43 +181,32 @@ public class TemplateDaoImpl implements TemplateDao { ...@@ -188,43 +181,32 @@ public class TemplateDaoImpl implements TemplateDao {
Template temp=new Template(); Template temp=new Template();
temp=Change.toBean(Template.class, map); temp=Change.toBean(Template.class, map);
temp.setTemplateId(String.valueOf(map.get("_id"))); temp.setTemplateId(String.valueOf(map.get("_id")));
// temp.setNeedPing((boolean)(map.get("isNeedPing")));
// temp.setNeedField((boolean)(map.get("isNeedField")));
// temp.setNeedDelayed((boolean)(map.get("isNeedDelayed")));
System.out.println(temp);
list.add(temp); list.add(temp);
} }
return list; return list;
// return mongo.find(
// Query.query(Criteria.where("pt").is(DbDepot.nowPt))
// .with(new Sort(new Order(Direction.ASC, "createDate"))).skip((pageNo - 1) * 10).limit(pageSize),
// Template.class);
} }
@Override @Override
public int allCount() { public int allCount(String pt) {
DBCollection con = null; DBCollection con = null;
if (DbDepot.dbCons.get("temp") != null) { if (DbDepot.dbCons.get(pt+"temp") != null) {
con = (DBCollection) DbDepot.dbCons.get("temp"); con = (DBCollection) DbDepot.dbCons.get(pt+"temp");
} else { } else {
con = dbDepot.getDBCollection("temp"); con = dbDepot.getDBCollection("temp",pt);
} }
if (con == null) { if (con == null) {
return 0; return 0;
} }
return (int) con.count(new BasicDBObject("pt",DbDepot.nowPt)); return (int) con.count(new BasicDBObject("pt",pt));
// return (int) mongo.count(Query.query(Criteria.where("pt").is(DbDepot.nowPt)), Template.class);
} }
@Override @Override
public int findByUserCount(String templateName,String pt) { public int findByUserCount(String templateName,String pt) {
DBCollection con = null; DBCollection con = null;
if (DbDepot.dbCons.get("temp") != null) { if (DbDepot.dbCons.get(pt+"temp") != null) {
con = (DBCollection) DbDepot.dbCons.get("temp"); con = (DBCollection) DbDepot.dbCons.get(pt+"temp");
} else { } else {
con = dbDepot.getDBCollection("temp"); con = dbDepot.getDBCollection("temp",pt);
} }
if (con == null) { if (con == null) {
return 0; return 0;
......
...@@ -53,25 +53,24 @@ public class DbDepot { ...@@ -53,25 +53,24 @@ public class DbDepot {
if (sb.getDbUsername() != null && !sb.getDbUsername().trim().equals("")) { if (sb.getDbUsername() != null && !sb.getDbUsername().trim().equals("")) {
DBCollection con = new MongoConnect(sb.getDbHost(), sb.getDbPort(), sb.getDbUsername(), DBCollection con = new MongoConnect(sb.getDbHost(), sb.getDbPort(), sb.getDbUsername(),
sb.getDbPassword(), sb.getDbName()).getCollection(sb.getCollection() + end); sb.getDbPassword(), sb.getDbName()).getCollection(sb.getCollection() + end);
dbCons.put(sb.getOther(), con); dbCons.put(sb.getPt()+sb.getOther(), con);
} else { } else {
DBCollection con = new MongoConnect(sb.getDbHost(), sb.getDbPort(), sb.getDbName()) DBCollection con = new MongoConnect(sb.getDbHost(), sb.getDbPort(), sb.getDbName())
.getCollection(sb.getCollection() + end); .getCollection(sb.getCollection() + end);
dbCons.put(sb.getOther(), con); dbCons.put(sb.getPt()+sb.getOther(), con);
} }
} }
} }
System.out.println("连接初始化成功"); System.out.println("连接初始化成功");
} }
public DBCollection getDBCollection(String other) { public DBCollection getDBCollection(String other,String pt) {
DBCollection con = null; DBCollection con = null;
ServerBean sb = mongo.findOne( ServerBean sb = mongo.findOne(
Query.query(Criteria.where("pt").is(nowPt).orOperator(Criteria.where("other").is(other))), Query.query(Criteria.where("pt").is(pt).orOperator(Criteria.where("other").is(other))),
ServerBean.class); ServerBean.class);
Calendar cal=Calendar.getInstance(); Calendar cal=Calendar.getInstance();
month=cal.get(Calendar.MONTH+1); month=cal.get(Calendar.MONTH+1);
if (sb != null) { if (sb != null) {
if (sb.getDbType().equals("mongo")) { if (sb.getDbType().equals("mongo")) {
...@@ -86,11 +85,11 @@ public class DbDepot { ...@@ -86,11 +85,11 @@ public class DbDepot {
if (sb.getDbUsername() != null && !sb.getDbUsername().equals("")) { if (sb.getDbUsername() != null && !sb.getDbUsername().equals("")) {
con = new MongoConnect(sb.getDbHost(), sb.getDbPort(), sb.getDbUsername(), sb.getDbPassword(), con = new MongoConnect(sb.getDbHost(), sb.getDbPort(), sb.getDbUsername(), sb.getDbPassword(),
sb.getDbName()).getCollection(sb.getCollection()+end); sb.getDbName()).getCollection(sb.getCollection()+end);
dbCons.put(sb.getOther(), con); dbCons.put(pt+sb.getOther(), con);
} else { } else {
con = new MongoConnect(sb.getDbHost(), sb.getDbPort(), sb.getDbName()) con = new MongoConnect(sb.getDbHost(), sb.getDbPort(), sb.getDbName())
.getCollection(sb.getCollection()+end); .getCollection(sb.getCollection()+end);
dbCons.put(sb.getOther(), con); dbCons.put(pt+sb.getOther(), con);
} }
} }
} }
......
package com.zhiwei.manage.handle; package com.zhiwei.manage.handle;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar; import java.util.Calendar;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
...@@ -17,6 +19,7 @@ import com.zhiwei.manage.bean.CrawTemplate; ...@@ -17,6 +19,7 @@ import com.zhiwei.manage.bean.CrawTemplate;
import com.zhiwei.manage.bean.Data; import com.zhiwei.manage.bean.Data;
import com.zhiwei.manage.bean.FieldBean; import com.zhiwei.manage.bean.FieldBean;
import com.zhiwei.manage.bean.FieldIntegerity; import com.zhiwei.manage.bean.FieldIntegerity;
import com.zhiwei.manage.bean.Message;
import com.zhiwei.manage.bean.NewsDelayed; import com.zhiwei.manage.bean.NewsDelayed;
import com.zhiwei.manage.bean.PingUrl; import com.zhiwei.manage.bean.PingUrl;
import com.zhiwei.manage.bean.RunMsg; import com.zhiwei.manage.bean.RunMsg;
...@@ -24,6 +27,7 @@ import com.zhiwei.manage.bean.Template; ...@@ -24,6 +27,7 @@ import com.zhiwei.manage.bean.Template;
import com.zhiwei.manage.orm.BeanFactory; import com.zhiwei.manage.orm.BeanFactory;
import com.zhiwei.manage.service.CrawTemplateServiceImpl; import com.zhiwei.manage.service.CrawTemplateServiceImpl;
import com.zhiwei.manage.service.DataServiceImpl; import com.zhiwei.manage.service.DataServiceImpl;
import com.zhiwei.manage.service.MessageServiceImpl;
import com.zhiwei.manage.service.NewsServiceImpl; import com.zhiwei.manage.service.NewsServiceImpl;
import com.zhiwei.manage.service.ServerServiceImpl; import com.zhiwei.manage.service.ServerServiceImpl;
import com.zhiwei.manage.util.TimeUtil; import com.zhiwei.manage.util.TimeUtil;
...@@ -141,14 +145,26 @@ public class MainThread extends Thread { ...@@ -141,14 +145,26 @@ public class MainThread extends Thread {
CrawTemplateServiceImpl crawService = BeanFactory.getBean(CrawTemplateServiceImpl.class); CrawTemplateServiceImpl crawService = BeanFactory.getBean(CrawTemplateServiceImpl.class);
DataServiceImpl dataService = BeanFactory.getBean(DataServiceImpl.class); DataServiceImpl dataService = BeanFactory.getBean(DataServiceImpl.class);
ServerServiceImpl serverService = BeanFactory.getBean(ServerServiceImpl.class); ServerServiceImpl serverService = BeanFactory.getBean(ServerServiceImpl.class);
// while (true) { MessageServiceImpl msgService = BeanFactory.getBean(MessageServiceImpl.class);
Calendar start = Calendar.getInstance(); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
start.set(Calendar.HOUR_OF_DAY, 0); int num = 1;
Calendar end = Calendar.getInstance(); while (true) {
end.set(Calendar.HOUR_OF_DAY, 0); Calendar countTest = Calendar.getInstance();
if (start.get(Calendar.HOUR_OF_DAY) <= 1) Calendar start = Calendar.getInstance();
for (int i = 0; i < 19; i++) { Calendar end = Calendar.getInstance();
// start.set(Calendar.HOUR_OF_DAY, 0);
// end.set(Calendar.HOUR_OF_DAY, 0);
if (start.get(Calendar.HOUR_OF_DAY) < 1) {
try {
countTest.setTime(sdf.parse(sdf.format(countTest.getTime())));
start.setTime(sdf.parse(sdf.format(countTest.getTime())));
end.setTime(sdf.parse(sdf.format(countTest.getTime())));
} catch (ParseException e1) {
e1.printStackTrace();
}
// for (int i = 0; i < 19; i++) {
start.add(Calendar.DATE, -1); start.add(Calendar.DATE, -1);
countTest.add(Calendar.DATE, -3);
try { try {
mainLock.lock(); mainLock.lock();
int count = 0; int count = 0;
...@@ -167,6 +183,20 @@ public class MainThread extends Thread { ...@@ -167,6 +183,20 @@ public class MainThread extends Thread {
data.setTime(start.getTime()); data.setTime(start.getTime());
data.setSpyderInfoId(cr.getId()); data.setSpyderInfoId(cr.getId());
dataService.insert(data); dataService.insert(data);
if (count == 0) {
int testCount = (int) dataService.finCountByDayData(countTest.getTime(),
end.getTime(), chan.getPt(), cr.getId());
if (testCount == 0) {
Message m = new Message();
m.setHandle(false);
m.setCreateDate(start.getTime());
m.setTemplateLv(1);
m.setTemplateName("未定义");
m.setPt("网媒");
m.setErrorMsg("未定义," + cr.getConfigName() + "," + chan.getId() + "数据为0");
msgService.insert(m);
}
}
log.info(TimeUtil.yearToDay(start.getTime()) + "|" + data.getTempName() + "|入库"); log.info(TimeUtil.yearToDay(start.getTime()) + "|" + data.getTempName() + "|入库");
} }
count = (int) dataService.finCountByDayData(start.getTime(), end.getTime(), chan.getPt(), count = (int) dataService.finCountByDayData(start.getTime(), end.getTime(), chan.getPt(),
...@@ -192,9 +222,12 @@ public class MainThread extends Thread { ...@@ -192,9 +222,12 @@ public class MainThread extends Thread {
} finally { } finally {
mainLock.unlock(); mainLock.unlock();
} }
Tools.sleep(1000*3); // end.add(Calendar.DATE, -1);
end.add(Calendar.DATE, -1); // }
Tools.sleep(1000 * 60*60);
} }
Tools.sleep(1000 * 30);
}
} }
} }
...@@ -9,13 +9,13 @@ public interface MessageService { ...@@ -9,13 +9,13 @@ public interface MessageService {
public void insert(Message message); public void insert(Message message);
public String update(Message message); public String update(Message message,String pt);
public PageEty findAll(int pageNo,int pageSize,String pt); public PageEty findAll(int pageNo,int pageSize,String pt);
public PageEty findByTmpName(String templateName,int pageNo,int pageSize,String pt); public PageEty findByTmpName(String templateName,int pageNo,int pageSize,String pt);
public boolean delete(List<String> MessageId); public boolean delete(List<String> MessageId,String pt);
public PageEty findByHandle(int pageNo,int pageSize,boolean handle,String tempName,String pt); public PageEty findByHandle(int pageNo,int pageSize,boolean handle,String tempName,String pt);
} }
...@@ -24,9 +24,9 @@ public class MessageServiceImpl implements MessageService { ...@@ -24,9 +24,9 @@ public class MessageServiceImpl implements MessageService {
} }
@Override @Override
public String update(Message message) { public String update(Message message,String pt) {
try { try {
String str=messageDao.update(message); String str=messageDao.update(message,pt);
return str; return str;
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
...@@ -38,7 +38,7 @@ public class MessageServiceImpl implements MessageService { ...@@ -38,7 +38,7 @@ public class MessageServiceImpl implements MessageService {
public PageEty findAll(int pageNo, int pageSize,String pt) { public PageEty findAll(int pageNo, int pageSize,String pt) {
PageEty page = new PageEty(); PageEty page = new PageEty();
List<Message> data = messageDao.findAll(pageNo, pageSize,pt); List<Message> data = messageDao.findAll(pageNo, pageSize,pt);
int count = messageDao.allCount(); int count = messageDao.allCount(pt);
if (count % pageSize == 0) { if (count % pageSize == 0) {
page.setPageCount(count / pageSize); page.setPageCount(count / pageSize);
} else } else
...@@ -54,7 +54,7 @@ public class MessageServiceImpl implements MessageService { ...@@ -54,7 +54,7 @@ public class MessageServiceImpl implements MessageService {
public PageEty findByTmpName(String templateName, int pageNo, int pageSize,String pt) { public PageEty findByTmpName(String templateName, int pageNo, int pageSize,String pt) {
PageEty page = new PageEty(); PageEty page = new PageEty();
List<Message> data = messageDao.findByTmpName(templateName, pageNo, pageSize,pt); List<Message> data = messageDao.findByTmpName(templateName, pageNo, pageSize,pt);
int count = messageDao.findByTmpCount(templateName); int count = messageDao.findByTmpCount(templateName,pt);
if(data.size()==0){ if(data.size()==0){
page.setData(new ArrayList<>()); page.setData(new ArrayList<>());
page.setDataCount(1); page.setDataCount(1);
...@@ -72,8 +72,8 @@ public class MessageServiceImpl implements MessageService { ...@@ -72,8 +72,8 @@ public class MessageServiceImpl implements MessageService {
} }
@Override @Override
public boolean delete(List<String> MessageId) { public boolean delete(List<String> MessageId,String pt) {
return messageDao.delete(MessageId); return messageDao.delete(MessageId,pt);
} }
@Override @Override
......
...@@ -11,10 +11,10 @@ public interface TemplateService { ...@@ -11,10 +11,10 @@ public interface TemplateService {
public PageEty findAll(int pageNo,int pageSize,String pt); public PageEty findAll(int pageNo,int pageSize,String pt);
public Template findById(String templateId); public Template findById(String templateId,String pt);
public PageEty findByTmpName(String templateName,int pageNo,int pageSize,String pt); public PageEty findByTmpName(String templateName,int pageNo,int pageSize,String pt);
public boolean delete(String templateId); public boolean delete(String templateId,String pt);
} }
...@@ -46,7 +46,7 @@ public class TemplateServiceImpl implements TemplateService { ...@@ -46,7 +46,7 @@ public class TemplateServiceImpl implements TemplateService {
@Override @Override
public PageEty findAll(int pageNo,int pageSize,String pt) { public PageEty findAll(int pageNo,int pageSize,String pt) {
int count=tempDao.allCount(); int count=tempDao.allCount(pt);
List<Template> data=tempDao.findAll(pageNo, pageSize,pt); List<Template> data=tempDao.findAll(pageNo, pageSize,pt);
for(Template tp:data){ for(Template tp:data){
if(MainThread.allTmp.get(tp.getTemplateId())==null){ if(MainThread.allTmp.get(tp.getTemplateId())==null){
...@@ -69,8 +69,8 @@ public class TemplateServiceImpl implements TemplateService { ...@@ -69,8 +69,8 @@ public class TemplateServiceImpl implements TemplateService {
} }
@Override @Override
public Template findById(String templateId) { public Template findById(String templateId,String pt) {
return tempDao.findById(templateId); return tempDao.findById(templateId,pt);
} }
@Override @Override
...@@ -99,14 +99,9 @@ public class TemplateServiceImpl implements TemplateService { ...@@ -99,14 +99,9 @@ public class TemplateServiceImpl implements TemplateService {
} }
@Override @Override
public boolean delete(String templateId) { public boolean delete(String templateId,String pt) {
try { try {
// Template tp = MainThread.mainMap.get(templateId); return tempDao.delete(templateId,pt);
// PingThread.runMap.remove(tp.getTempName());
// FieldThread.runMap.remove(tp.getTempName());
// DelayedThread.runMap.remove(tp.getTempName());
// MainThread.mainMap.remove(templateId);
return tempDao.delete(templateId);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
return false; return false;
......
...@@ -23,7 +23,8 @@ public class MessageConteoller { ...@@ -23,7 +23,8 @@ public class MessageConteoller {
@RequestMapping(value = "/findAllMsg", produces = "application/json;charset=utf-8") @RequestMapping(value = "/findAllMsg", produces = "application/json;charset=utf-8")
@ResponseBody @ResponseBody
public String getAllMessage(@RequestParam(value = "pageNo", defaultValue = "1") int pageNo, public String getAllMessage(@RequestParam(value = "pageNo", defaultValue = "1") int pageNo,
@RequestParam(value = "pageSize", defaultValue = "10") int pageSize, String tempName,String pt) { @RequestParam(value = "pageSize", defaultValue = "10") int pageSize, String tempName,
@RequestParam(value = "pt", defaultValue = "网媒")String pt) {
if (tempName == null || tempName.equals("")) { if (tempName == null || tempName.equals("")) {
PageEty page = msgService.findAll(pageNo, pageSize,pt); PageEty page = msgService.findAll(pageNo, pageSize,pt);
JsonResult result = new JsonResult(true, 200, "请求成功", page); JsonResult result = new JsonResult(true, 200, "请求成功", page);
...@@ -37,16 +38,17 @@ public class MessageConteoller { ...@@ -37,16 +38,17 @@ public class MessageConteoller {
@RequestMapping(value = "/handle", produces = "application/json;charset=utf-8") @RequestMapping(value = "/handle", produces = "application/json;charset=utf-8")
@ResponseBody @ResponseBody
public String handle(Message message) { public String handle(Message message,@RequestParam(value = "pt", defaultValue = "网媒")String pt) {
String str = msgService.update(message); String str = msgService.update(message,pt);
JsonResult result = new JsonResult(true, 200, str, ""); JsonResult result = new JsonResult(true, 200, str, "");
return JSON.toJSONString(result); return JSON.toJSONString(result);
} }
@RequestMapping(value = "/deleteMsg", produces = "application/json;charset=utf-8") @RequestMapping(value = "/deleteMsg", produces = "application/json;charset=utf-8")
@ResponseBody @ResponseBody
public String delete(@RequestParam(value = "messageId[]") List<String> messageId) { public String delete(@RequestParam(value = "messageId[]") List<String> messageId,
msgService.delete(messageId); @RequestParam(value = "pt", defaultValue = "网媒")String pt) {
msgService.delete(messageId,pt);
JsonResult result = new JsonResult(true, 200, "删除成功", ""); JsonResult result = new JsonResult(true, 200, "删除成功", "");
return JSON.toJSONString(result); return JSON.toJSONString(result);
} }
......
...@@ -55,12 +55,13 @@ public class TemplateController { ...@@ -55,12 +55,13 @@ public class TemplateController {
@RequestMapping(value = "/deleteTmp", produces = "application/json;charset=utf-8") @RequestMapping(value = "/deleteTmp", produces = "application/json;charset=utf-8")
@ResponseBody @ResponseBody
public String deleteTmp(@RequestParam(value = "templateId[]") String[] templateId) { public String deleteTmp(@RequestParam(value = "templateId[]") String[] templateId,
@RequestParam(value = "pt", defaultValue = "网媒")String pt) {
boolean isDelete = false; boolean isDelete = false;
String results=""; String results="";
for (String l : templateId) { for (String l : templateId) {
System.out.println(l); System.out.println(l);
isDelete = ts.delete(l); isDelete = ts.delete(l,pt);
MainThread.delete(l); MainThread.delete(l);
results+=l+"\n"; results+=l+"\n";
} }
......
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