Commit 332baa98 by shenjinzhu

模糊查询修改

parent 19a369e9
...@@ -60,7 +60,7 @@ public class DataDaoImpl implements DataDao { ...@@ -60,7 +60,7 @@ public class DataDaoImpl implements DataDao {
@Override @Override
public List<Data> findBySource(Date startTime, Date endTime, String source) { public List<Data> findBySource(Date startTime, Date endTime, String source) {
Criteria criteria = new Criteria(); Criteria criteria = new Criteria();
criteria.and("source").is(source); criteria.and("source").regex(source);
criteria.and("time").gte(startTime).lt(endTime); criteria.and("time").gte(startTime).lt(endTime);
return mongo.find(Query.query(criteria), Data.class, "Data"); return mongo.find(Query.query(criteria), Data.class, "Data");
} }
...@@ -68,7 +68,7 @@ public class DataDaoImpl implements DataDao { ...@@ -68,7 +68,7 @@ public class DataDaoImpl implements DataDao {
@Override @Override
public List<Data> findBytempName(Date startTime, Date endTime, String tempName) { public List<Data> findBytempName(Date startTime, Date endTime, String tempName) {
Criteria criteria = new Criteria(); Criteria criteria = new Criteria();
criteria.and("tempName").is(tempName); criteria.and("tempName").regex(tempName);
criteria.and("time").gte(startTime).lt(endTime); criteria.and("time").gte(startTime).lt(endTime);
return mongo.find(Query.query(criteria), Data.class, "Data"); return mongo.find(Query.query(criteria), Data.class, "Data");
} }
...@@ -84,7 +84,7 @@ public class DataDaoImpl implements DataDao { ...@@ -84,7 +84,7 @@ public class DataDaoImpl implements DataDao {
int month = c.get(Calendar.MONTH) + 1; int month = c.get(Calendar.MONTH) + 1;
int year = c.get(Calendar.YEAR); int year = c.get(Calendar.YEAR);
Criteria criteria = new Criteria(); Criteria criteria = new Criteria();
criteria.and("source").is(source); criteria.and("source").regex(source);
criteria.and("time").gte(startTime).lt(endTime); criteria.and("time").gte(startTime).lt(endTime);
return mongo2.find(Query.query(criteria), EasyNews.class, "net_media_" + year + (month>9?""+month:"0"+month)); return mongo2.find(Query.query(criteria), EasyNews.class, "net_media_" + year + (month>9?""+month:"0"+month));
} }
......
...@@ -152,8 +152,6 @@ public class MainThread extends Thread { ...@@ -152,8 +152,6 @@ public class MainThread extends Thread {
Calendar countTest = Calendar.getInstance(); Calendar countTest = Calendar.getInstance();
Calendar start = Calendar.getInstance(); Calendar start = Calendar.getInstance();
Calendar end = Calendar.getInstance(); 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) { if (start.get(Calendar.HOUR_OF_DAY) < 1) {
try { try {
countTest.setTime(sdf.parse(sdf.format(countTest.getTime()))); countTest.setTime(sdf.parse(sdf.format(countTest.getTime())));
...@@ -174,7 +172,6 @@ public class MainThread extends Thread { ...@@ -174,7 +172,6 @@ public class MainThread extends Thread {
if (chan.getPt().equals("网媒")) { if (chan.getPt().equals("网媒")) {
List<CrawTemplate> list = crawService.findAll(); List<CrawTemplate> list = crawService.findAll();
// 每日的数据量入库(对应模板) // 每日的数据量入库(对应模板)
System.out.println(list.size());
for (CrawTemplate cr : list) { for (CrawTemplate cr : list) {
count = (int) dataService.finCountByDayData(start.getTime(), end.getTime(), cr.getPt(), count = (int) dataService.finCountByDayData(start.getTime(), end.getTime(), cr.getPt(),
cr.getId()); cr.getId());
......
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