Commit f27b6933 by admin

提交注释和文件

parent 515b4bc9
......@@ -6,6 +6,12 @@ import java.util.Map;
import org.springframework.data.mongodb.core.mapping.Document;
import org.springframework.data.mongodb.core.mapping.Field;
/**
* 采集模板
*
* @author admin
*
*/
@Document(collection = "spyderInfo")
public class CrawTemplate {
......
......@@ -6,6 +6,7 @@ import java.util.Date;
import org.springframework.stereotype.Component;
/**
* 部分的数据字段
*
* @author admin
*
......
......@@ -4,12 +4,35 @@ import java.util.List;
import com.zhiwei.manage.bean.CrawTemplate;
/**
* 采集模板
*
* @author admin
*
*/
public interface CrawTemplateDao {
/**
* 获取全部
*
* @return
*/
public List<CrawTemplate> findAll();
/**
* 获取采集的主键
*
* @param tempName
* @return
*/
public String getSpIdByConfigName(String tempName);
/**
* 根据采集主键获取采集模板
*
* @param sypId
* @return
*/
public CrawTemplate getPt(String sypId);
}
......@@ -6,17 +6,23 @@ import javax.annotation.Resource;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.CriteriaDefinition;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.stereotype.Component;
import com.zhiwei.manage.bean.CrawTemplate;
/**
* 采集模板实现部分
*
* @author admin
*
*/
@Component
public class CrawTemplateDaoImpl implements CrawTemplateDao{
public class CrawTemplateDaoImpl implements CrawTemplateDao {
@Resource(name="newmongoTemplate")
@Resource(name = "newmongoTemplate")
private MongoTemplate mongo;
@Override
public List<CrawTemplate> findAll() {
return mongo.find(Query.query(Criteria.where("websitetype").is("main")), CrawTemplate.class);
......
......@@ -5,17 +5,66 @@ import java.util.List;
import com.zhiwei.manage.bean.Data;
/**
* 数据部分的获取接口
*
* @author admin
*
*/
public interface DataDao {
/**
* 渠道日数据的获取
*
* @param startTime
* @param endTime
* @param pt
* @return
*/
public List<Data> findByPt(Date startTime, Date endTime, String pt);
/**
* 插入数据
*
* @param data
*/
public void insert(Data data);
/**
* 根据日期获取数据信息
*
* @param startTime
* @param endTime
* @param pt
* @return
*/
public List<Data> findByPtDay(Date startTime, Date endTime, String pt);
public List<Data> findByPt(Date startTime, Date endTime, String pt);
/**
* 根据来源获取数据
*
* @param startTime
* @param endTime
* @param source
* @return
*/
public List<Data> findBySource(Date startTime, Date endTime, String source);
/**
* 根据模板名获取数据
*
* @param startTime
* @param endTime
* @param tempName
* @return
*/
public List<Data> findBytempName(Date startTime, Date endTime, String tempName);
/**
* 根据参数获取信息
*
* @param param
* @return
*/
public List<String> findTmpNameByLikeParam(String param);
}
......@@ -3,17 +3,12 @@ package com.zhiwei.manage.dao;
import java.lang.reflect.Field;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import javax.annotation.Resource;
import org.bson.Document;
import org.bson.conversions.Bson;
import org.springframework.data.domain.Sort;
import org.springframework.data.domain.Sort.Direction;
import org.springframework.data.mongodb.core.MongoTemplate;
......@@ -25,29 +20,9 @@ import org.springframework.stereotype.Component;
import com.mongodb.BasicDBObject;
import com.mongodb.DB;
import com.mongodb.DBCollection;
import com.mongodb.DBCursor;
import com.mongodb.DBObject;
import com.mongodb.Mongo;
import com.mongodb.MongoClient;
import com.mongodb.MongoClientOptions;
import com.mongodb.MongoClientURI;
import com.mongodb.MongoCredential;
import com.mongodb.ServerAddress;
import com.mongodb.WriteResult;
import com.mongodb.client.FindIterable;
import com.mongodb.client.MongoCollection;
import com.mongodb.client.MongoCursor;
import com.mongodb.client.MongoDatabase;
import com.mongodb.connection.Server;
import com.zhiwei.manage.bean.Data;
import com.zhiwei.manage.bean.EasyNews;
import com.zhiwei.manage.bean.News;
import com.zhiwei.manage.bean.ServerBean;
import com.zhiwei.manage.bean.Template;
import com.zhiwei.manage.bean.Weibo;
import com.zhiwei.manage.handle.DbDepot;
import com.zhiwei.manage.util.Change;
import com.zhiwei.manage.util.MongoConnect;
@SuppressWarnings({ "all" })
@Component
......@@ -65,13 +40,15 @@ public class DataDaoImpl implements DataDao {
criteria.and("tempName").exists(false);
return mongo.find(Query.query(criteria), Data.class, "Data");
}
@Override
public List<Data> findByPtDay(Date startTime, Date endTime, String pt) {
Criteria criteria = new Criteria();
criteria.and("pt").is(pt);
criteria.and("time").gt(startTime).lt(endTime);
return mongo.find(Query.query(criteria).with(new Sort(Direction.ASC,"time")), Data.class, "DayData");
return mongo.find(Query.query(criteria).with(new Sort(Direction.ASC, "time")), Data.class, "DayData");
}
@Override
public List<Data> findBySource(Date startTime, Date endTime, String source) {
Criteria criteria = new Criteria();
......@@ -127,7 +104,7 @@ public class DataDaoImpl implements DataDao {
}
}
mongo.updateFirst(Query.query(Criteria.where("_id").is(d.getDataId())), update, Data.class);
Calendar cal=Calendar.getInstance();
Calendar cal = Calendar.getInstance();
try {
data.setTime(sdf2.parse(sdf2.format(cal.getTime())));
} catch (ParseException e) {
......@@ -140,136 +117,147 @@ public class DataDaoImpl implements DataDao {
public void insertTest(Data data) {
mongo.insert(data, "DayData");
}
// @Override
// public long finCountByDayData(Date startTime, Date endTime, String pt) {
// String end = "";
// Calendar cal = Calendar.getInstance();
// cal.setTime(startTime);
// MongoCollection<Document> col = null;
// if (pt.equals("知乎")) {
// if (DbDepot.dataCol != null) {
// if (DbDepot.dataCol.get(pt) != null && DbDepot.month ==
// cal.get(Calendar.MONTH)) {
// col = (MongoCollection<Document>) DbDepot.dataCol.get(pt);
// }
// }
// int resultCount = 0;
// if (col == null) {
// MongoClient mongoClient = null;
// ServerBean ser = mongo.findOne(
// Query.query(Criteria.where("pt").is(pt).andOperator(Criteria.where("other").is("data"))),
// ServerBean.class);
// mongoClient = new MongoClient(new MongoClientURI(
// "mongodb://sjzno:sjzno1q2w3e4r@" + ser.getDbHost() + ":" + ser.getDbPort() +
// "/admin"));
// // 连接到数据库
// MongoDatabase mongo = mongoClient.getDatabase(ser.getDbName());
// for (int i = 1; i < 6; i++) {
// col = mongo.getCollection(ser.getCollection() + i);
// Bson query = new BasicDBObject("update_at",
// new BasicDBObject("$gte", startTime).append("$lte", endTime));
// resultCount += col.count(query);
// }
// }
// return resultCount;
// }
// col = getcol(startTime, endTime, pt);
// long count = 0;
// if (pt.equals("微博")) {
// SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
// Bson query = new BasicDBObject("time",
// new BasicDBObject("$gte", sdf.format(startTime)).append("$lte",
// sdf.format(endTime)));
// count = col.count(query);
// } else if (pt.equals("微信") || pt.equals("网媒") || pt.equals("论坛") ||
// pt.equals("贴吧") || pt.equals("平媒")) {
// Bson query = new BasicDBObject("time", new BasicDBObject("$gte",
// startTime).append("$lte", endTime))
// .append("pt", pt);
// count = col.count(query);
// } else {
// Bson query = new BasicDBObject("time", new BasicDBObject("$gte",
// startTime).append("$lte", endTime));
// count = col.count(query);
// }
// return count;
// }
// @Override
// public long finCountByDayData(Date startTime, Date endTime, String pt) {
// String end = "";
// Calendar cal = Calendar.getInstance();
// cal.setTime(startTime);
// MongoCollection<Document> col = null;
// if (pt.equals("知乎")) {
// if (DbDepot.dataCol != null) {
// if (DbDepot.dataCol.get(pt) != null && DbDepot.month == cal.get(Calendar.MONTH)) {
// col = (MongoCollection<Document>) DbDepot.dataCol.get(pt);
// }
// }
// int resultCount = 0;
// if (col == null) {
// MongoClient mongoClient = null;
// ServerBean ser = mongo.findOne(
// Query.query(Criteria.where("pt").is(pt).andOperator(Criteria.where("other").is("data"))),
// ServerBean.class);
// mongoClient = new MongoClient(new MongoClientURI(
// "mongodb://sjzno:sjzno1q2w3e4r@" + ser.getDbHost() + ":" + ser.getDbPort() + "/admin"));
// // 连接到数据库
// MongoDatabase mongo = mongoClient.getDatabase(ser.getDbName());
// for (int i = 1; i < 6; i++) {
// col = mongo.getCollection(ser.getCollection() + i);
// Bson query = new BasicDBObject("update_at",
// new BasicDBObject("$gte", startTime).append("$lte", endTime));
// resultCount += col.count(query);
// }
// }
// return resultCount;
// }
// col = getcol(startTime, endTime, pt);
// long count = 0;
// if (pt.equals("微博")) {
// SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
// Bson query = new BasicDBObject("time",
// new BasicDBObject("$gte", sdf.format(startTime)).append("$lte", sdf.format(endTime)));
// count = col.count(query);
// } else if (pt.equals("微信") || pt.equals("网媒") || pt.equals("论坛") || pt.equals("贴吧") || pt.equals("平媒")) {
// Bson query = new BasicDBObject("time", new BasicDBObject("$gte", startTime).append("$lte", endTime))
// .append("pt", pt);
// count = col.count(query);
// } else {
// Bson query = new BasicDBObject("time", new BasicDBObject("$gte", startTime).append("$lte", endTime));
// count = col.count(query);
// }
// return count;
// }
// @Override
// public long finCountByDayData(Date startTime, Date endTime, Template temp) {
// String end = "";
// Calendar cal = Calendar.getInstance();
// String pt = temp.getPt();
// cal.setTime(startTime);
// MongoCollection<Document> col = getcol(startTime, endTime, pt);
// Bson query = new BasicDBObject("time", new BasicDBObject("$gte",
// startTime).append("$lte", endTime))
// .append("spyderInfoId", temp.getSpyderInfoId());
// return col.count(query);
// }
// @Override
// public long finCountByDayData(Date startTime, Date endTime, Template temp) {
// String end = "";
// Calendar cal = Calendar.getInstance();
// String pt = temp.getPt();
// cal.setTime(startTime);
// MongoCollection<Document> col = getcol(startTime, endTime, pt);
// Bson query = new BasicDBObject("time", new BasicDBObject("$gte", startTime).append("$lte", endTime))
// .append("spyderInfoId", temp.getSpyderInfoId());
// return col.count(query);
// }
// public MongoCollection<Document> getcol(Date startTime, Date endTime, String pt) {
// String end = "";
// Calendar cal = Calendar.getInstance();
// cal.setTime(startTime);
// if (DbDepot.dataCol != null) {
// if (DbDepot.dataCol.get(pt) != null && DbDepot.month == cal.get(Calendar.MONTH)) {
// return (MongoCollection<Document>) DbDepot.dataCol.get(pt);
// } else {
// ServerBean ser = mongo.findOne(
// Query.query(Criteria.where("pt").is(pt).andOperator(Criteria.where("other").is("data"))),
// ServerBean.class);
// if (ser.isTable()) {
// int month = cal.get(Calendar.MONTH) + 1;
// end = cal.get(Calendar.YEAR) + "" + (month > 9 ? "" + month : "0" + month);
// System.out.println(end);
// }
// MongoClient mongoClient = null;
// if (ser.getPt().equals("微信全量")) {
// mongoClient = new MongoClient(new MongoClientURI(
// "mongodb://sjzzc:sjzzc1q2w3e4r@" + ser.getDbHost() + ":" + ser.getDbPort() + "/admin"));
// } else {
// mongoClient = new MongoClient(new MongoClientURI(
// "mongodb://sjzno:sjzno1q2w3e4r@" + ser.getDbHost() + ":" + ser.getDbPort() + "/admin"));
// }
// // if (ser.getDbUsername() != null &&
// // ser.getDbUsername().length() > 2) {
// // ServerAddress sa = new ServerAddress(ser.getDbHost(),
// // ser.getDbPort());
// // List<MongoCredential> mongoCredentialList = new
// // ArrayList<MongoCredential>();
// // mongoCredentialList.add(MongoCredential.createMongoCRCredential(ser.getDbUsername(),
// // ser.getDbName(), ser.getDbPassword().toCharArray()));
// // new MongoClient(sa, mongoCredentialList);
// // mongoClient = new MongoClient(sa, mongoCredentialList);
// // } else
// // mongoClient = new MongoClient(ser.getDbHost(),
// // ser.getDbPort());
// // 连接到数据库
// MongoDatabase mongo = mongoClient.getDatabase(ser.getDbName());
// DbDepot.dataCol.put(pt, mongo.getCollection(ser.getCollection() + end));
// DbDepot.month = cal.get(Calendar.MONTH);
// return mongo.getCollection(ser.getCollection() + end);
// }
// } else {
// DbDepot.dataCol = new ConcurrentHashMap<String, Object>();
// ServerBean ser = mongo.findOne(
// Query.query(Criteria.where("pt").is(pt).andOperator(Criteria.where("other").is("data"))),
// ServerBean.class);
// if (ser.isTable()) {
// int month = cal.get(Calendar.MONTH) + 1;
// end = cal.get(Calendar.YEAR) + "" + (month > 9 ? "" + month : "0" + month);
// }
// MongoClient mongoClient = null;
// if (ser.getDbUsername() != null) {
// ServerAddress sa = new ServerAddress(ser.getDbHost(), ser.getDbPort());
// List<MongoCredential> mongoCredentialList = new ArrayList<MongoCredential>();
// mongoCredentialList.add(MongoCredential.createMongoCRCredential(ser.getDbUsername(), ser.getDbName(),
// ser.getDbPassword().toCharArray()));
// mongoClient = new MongoClient(sa, mongoCredentialList);
// } else
// mongoClient = new MongoClient(ser.getDbHost(), ser.getDbPort());
// MongoDatabase mongo = mongoClient.getDatabase(ser.getDbName());
// DbDepot.dataCol.put(pt, mongo.getCollection(ser.getCollection() + end));
// return mongo.getCollection(ser.getCollection() + end);
// }
// }
// public MongoCollection<Document> getcol(Date startTime, Date endTime, String
// pt) {
// String end = "";
// Calendar cal = Calendar.getInstance();
// cal.setTime(startTime);
// if (DbDepot.dataCol != null) {
// if (DbDepot.dataCol.get(pt) != null && DbDepot.month ==
// cal.get(Calendar.MONTH)) {
// return (MongoCollection<Document>) DbDepot.dataCol.get(pt);
// } else {
// ServerBean ser = mongo.findOne(
// Query.query(Criteria.where("pt").is(pt).andOperator(Criteria.where("other").is("data"))),
// ServerBean.class);
// if (ser.isTable()) {
// int month = cal.get(Calendar.MONTH) + 1;
// end = cal.get(Calendar.YEAR) + "" + (month > 9 ? "" + month : "0" + month);
// System.out.println(end);
// }
// MongoClient mongoClient = null;
// if (ser.getPt().equals("微信全量")) {
// mongoClient = new MongoClient(new MongoClientURI(
// "mongodb://sjzzc:sjzzc1q2w3e4r@" + ser.getDbHost() + ":" + ser.getDbPort() +
// "/admin"));
// } else {
// mongoClient = new MongoClient(new MongoClientURI(
// "mongodb://sjzno:sjzno1q2w3e4r@" + ser.getDbHost() + ":" + ser.getDbPort() +
// "/admin"));
// }
// // if (ser.getDbUsername() != null &&
// // ser.getDbUsername().length() > 2) {
// // ServerAddress sa = new ServerAddress(ser.getDbHost(),
// // ser.getDbPort());
// // List<MongoCredential> mongoCredentialList = new
// // ArrayList<MongoCredential>();
// //
// mongoCredentialList.add(MongoCredential.createMongoCRCredential(ser.getDbUsername(),
// // ser.getDbName(), ser.getDbPassword().toCharArray()));
// // new MongoClient(sa, mongoCredentialList);
// // mongoClient = new MongoClient(sa, mongoCredentialList);
// // } else
// // mongoClient = new MongoClient(ser.getDbHost(),
// // ser.getDbPort());
// // 连接到数据库
// MongoDatabase mongo = mongoClient.getDatabase(ser.getDbName());
// DbDepot.dataCol.put(pt, mongo.getCollection(ser.getCollection() + end));
// DbDepot.month = cal.get(Calendar.MONTH);
// return mongo.getCollection(ser.getCollection() + end);
// }
// } else {
// DbDepot.dataCol = new ConcurrentHashMap<String, Object>();
// ServerBean ser = mongo.findOne(
// Query.query(Criteria.where("pt").is(pt).andOperator(Criteria.where("other").is("data"))),
// ServerBean.class);
// if (ser.isTable()) {
// int month = cal.get(Calendar.MONTH) + 1;
// end = cal.get(Calendar.YEAR) + "" + (month > 9 ? "" + month : "0" + month);
// }
// MongoClient mongoClient = null;
// if (ser.getDbUsername() != null) {
// ServerAddress sa = new ServerAddress(ser.getDbHost(), ser.getDbPort());
// List<MongoCredential> mongoCredentialList = new ArrayList<MongoCredential>();
// mongoCredentialList.add(MongoCredential.createMongoCRCredential(ser.getDbUsername(),
// ser.getDbName(),
// ser.getDbPassword().toCharArray()));
// mongoClient = new MongoClient(sa, mongoCredentialList);
// } else
// mongoClient = new MongoClient(ser.getDbHost(), ser.getDbPort());
// MongoDatabase mongo = mongoClient.getDatabase(ser.getDbName());
// DbDepot.dataCol.put(pt, mongo.getCollection(ser.getCollection() + end));
// return mongo.getCollection(ser.getCollection() + end);
// }
// }
public static void main(String[] args) {
MongoClient mongoClient = new MongoClient(
......@@ -294,52 +282,55 @@ public class DataDaoImpl implements DataDao {
}
}
// @Override
// public List<Data> findByMethod(Date startTime, Date endTime, String method, Object value) {
// List<Data> list = new ArrayList<Data>();
// if (DbDepot.dbCons.get("data") != null) {
// DBCollection coll = (DBCollection) DbDepot.dbCons.get("data");
// DBObject obj = new BasicDBObject();
// if (method != null) {
// obj.put(method, value);
// obj.put("time", new BasicDBObject("$gte", startTime).append("$lt", endTime));
// } else {
// obj.put("time", new BasicDBObject("$gte", startTime).append("$lt", endTime));
// }
// DBCursor cursor = coll.find(obj).sort(new BasicDBObject("time", -1));
// while (cursor.hasNext()) {
// Map<String, Object> map = (Map<String, Object>) cursor.next();
// Data d = Change.toBean(Data.class, map);
// list.add(d);
// }
// cursor.close();
// } else {
// ServerBean sb = mongo.findOne(Query.query(Criteria.where("other").is("data")), ServerBean.class);
// DBCollection coll = null;
// if (sb.getDbUsername() == null || sb.getDbUsername().equals("")) {
// coll = new MongoConnect(sb.getDbHost(), sb.getDbPort(), sb.getDbName())
// .getCollection(sb.getCollection());
// } else {
// coll = new MongoConnect(sb.getDbHost(), sb.getDbPort(), sb.getDbUsername(), sb.getDbPassword(),
// sb.getDbName()).getCollection(sb.getCollection());
// DbDepot.dbCons.put(sb.getOther(), coll);
// }
// DBObject obj = new BasicDBObject();
// if (method != null) {
// obj.put(method, value);
// obj.put("time", new BasicDBObject("$gte", startTime).append("$lt", endTime));
// } else {
// obj.put("time", new BasicDBObject("$gte", startTime).append("$lt", endTime));
// }
// DBCursor cursor = coll.find(obj).sort(new BasicDBObject("time", -1));
// while (cursor.hasNext()) {
// Map<String, Object> map = (Map<String, Object>) cursor.next();
// Data d = Change.toBean(Data.class, map);
// list.add(d);
// }
// cursor.close();
// }
// return list;
// }
// @Override
// public List<Data> findByMethod(Date startTime, Date endTime, String method,
// Object value) {
// List<Data> list = new ArrayList<Data>();
// if (DbDepot.dbCons.get("data") != null) {
// DBCollection coll = (DBCollection) DbDepot.dbCons.get("data");
// DBObject obj = new BasicDBObject();
// if (method != null) {
// obj.put(method, value);
// obj.put("time", new BasicDBObject("$gte", startTime).append("$lt", endTime));
// } else {
// obj.put("time", new BasicDBObject("$gte", startTime).append("$lt", endTime));
// }
// DBCursor cursor = coll.find(obj).sort(new BasicDBObject("time", -1));
// while (cursor.hasNext()) {
// Map<String, Object> map = (Map<String, Object>) cursor.next();
// Data d = Change.toBean(Data.class, map);
// list.add(d);
// }
// cursor.close();
// } else {
// ServerBean sb =
// mongo.findOne(Query.query(Criteria.where("other").is("data")),
// ServerBean.class);
// DBCollection coll = null;
// if (sb.getDbUsername() == null || sb.getDbUsername().equals("")) {
// coll = new MongoConnect(sb.getDbHost(), sb.getDbPort(), sb.getDbName())
// .getCollection(sb.getCollection());
// } else {
// coll = new MongoConnect(sb.getDbHost(), sb.getDbPort(), sb.getDbUsername(),
// sb.getDbPassword(),
// sb.getDbName()).getCollection(sb.getCollection());
// DbDepot.dbCons.put(sb.getOther(), coll);
// }
// DBObject obj = new BasicDBObject();
// if (method != null) {
// obj.put(method, value);
// obj.put("time", new BasicDBObject("$gte", startTime).append("$lt", endTime));
// } else {
// obj.put("time", new BasicDBObject("$gte", startTime).append("$lt", endTime));
// }
// DBCursor cursor = coll.find(obj).sort(new BasicDBObject("time", -1));
// while (cursor.hasNext()) {
// Map<String, Object> map = (Map<String, Object>) cursor.next();
// Data d = Change.toBean(Data.class, map);
// list.add(d);
// }
// cursor.close();
// }
// return list;
// }
}
......@@ -4,18 +4,61 @@ import java.util.List;
import com.zhiwei.manage.bean.FieldBean;
/**
* 字段信息获取
*
* @author admin
*
*/
public interface FieldBeanDao {
/**
* 根据pt获取字段信息
*
* @param pt
* @return
*/
public FieldBean getFieldsByPt(String pt);
/**
* 插入数据
*
* @param fieldBean
*/
public void insert(FieldBean fieldBean);
/**
* 修改数据
*
* @param fieldBean
* @return
*/
public boolean update(FieldBean fieldBean);
/**
* 删除数据
*
* @param id
* @return
*/
public boolean delete(List<String> id);
/**
* 根据pt查询数据量
*
* @param pt
* @return
*/
public int findFieldCount(String pt);
public List<FieldBean> findAllFields(int pageNo,int pageSize,String pt);
/**
* 分页查询数据
*
* @param pageNo
* @param pageSize
* @param pt
* @return
*/
public List<FieldBean> findAllFields(int pageNo, int pageSize, String pt);
}
......@@ -4,26 +4,109 @@ import java.util.List;
import com.zhiwei.manage.bean.Message;
/**
* 处理信息的获取
*
* @author admin
*
*/
public interface MessageDao {
/**
* 信息插入
*
* @param message
* @return
*/
public String insert(Message message);
/**
* 信息删除
*
* @param message
* @param pt
* @return
*/
public String update(Message message, String pt);
/**
* 查找所有的信息
*
* @param pageNo
* @param pageSize
* @param pt
* @return
*/
public List<Message> findAll(int pageNo, int pageSize, String pt);
/**
* 根据模板名称分页查询信息
*
* @param templateName
* @param pageNo
* @param pageSize
* @param pt
* @return
*/
public List<Message> findByTmpName(String templateName, int pageNo, int pageSize, String pt);
/**
* 删除信息
*
* @param MessageId
* @param pt
* @return
*/
public boolean delete(List<String> MessageId, String pt);
/**
* 获取数据条数
*
* @param pt
* @return
*/
public int allCount(String pt);
/**
* 根据模板名获取数据条数
*
* @param templateName
* @param pt
* @return
*/
public int findByTmpCount(String templateName, String pt);
/**
* 分页获取模板的信息
*
* @param pageNo
* @param pageSize
* @param handle
* @param tempName
* @param pt
* @return
*/
public List<Message> findByHandle(int pageNo, int pageSize, boolean handle, String tempName, String pt);
/**
* 获取处理过的信息
*
* @param pageNo
* @param pageSize
* @param handle
* @param tempName
* @param pt
* @return
*/
public int findByHandleCount(int pageNo, int pageSize, boolean handle, String tempName, String pt);
/**
* 获取信息根据模板名和错误信息
*
* @param tempName
* @param errorType
* @return
*/
public Message findMsg(String tempName, String errorType);
}
......@@ -2,24 +2,74 @@ package com.zhiwei.manage.dao;
import java.util.Date;
import java.util.List;
import java.util.Map;
import com.zhiwei.manage.bean.EasyNews;
import com.zhiwei.manage.bean.News;
/**
* 新闻获取
*
* @author admin
*
*/
public interface NewsDao {
public List<News> findByNew(int delayedCount,String type,String source);
public List<News> findByFiled(int filedCount,String type,String source);
public long findCount(String spyId,Date start,Date end);
/**
* 根据来源和type获取新闻数据
*
* @param delayedCount
* @param type
* @param source
* @return
*/
public List<News> findByNew(int delayedCount, String type, String source);
/**
* 根据来源和type获取新闻数据
*
* @param filedCount
* @param type
* @param source
* @return
*/
public List<News> findByFiled(int filedCount, String type, String source);
/**
* 根据采集主键获取新闻
*
* @param spyId
* @param start
* @param end
* @return
*/
public long findCount(String spyId, Date start, Date end);
/**
* 获取所有的来源数据
*
* @return
*/
public List<Object> findSource();
public int findBySource(String source,Date start,Date end);
public List<EasyNews> finAllNews(Date start,Date end);
// public List<Map<String,Object>> findNews(String host,int port,String dbNamel,String collection,int count,String id,String pt);
/**
* 根据来源获取数据
*
* @param source
* @param start
* @param end
* @return
*/
public int findBySource(String source, Date start, Date end);
/**
* 根据时间获取数据
*
* @param start
* @param end
* @return
*/
public List<EasyNews> finAllNews(Date start, Date end);
// public List<Map<String,Object>> findNews(String host,int port,String
// dbNamel,String collection,int count,String id,String pt);
}
......@@ -4,23 +4,84 @@ import java.util.List;
import com.zhiwei.manage.bean.Person;
/**
* 用户数据部分
*
* @author admin
*
*/
public interface PersonDao {
/**
* 插入
*
* @param person
*/
public void insert(Person person);
/**
* 更新
*
* @param person
* @return
*/
public boolean update(Person person);
public List<Person> findAll(int pageNo,int pageSize);
/**
* 分页查询所有用户
*
* @param pageNo
* @param pageSize
* @return
*/
public List<Person> findAll(int pageNo, int pageSize);
/**
* 根据id获取用户信息
*
* @param personId
* @return
*/
public Person findById(String personId);
/**
* 根据用户名获取用户
*
* @param username
* @return
*/
public Person findByUsername(String username);
/**
* 删除用户信息
*
* @param personId
* @return
*/
public boolean delete(List<String> personId);
public List<Person> findAllByUsername(String username,int pageNo,int pageSize);
/**
* 分页获取用户
*
* @param username
* @param pageNo
* @param pageSize
* @return
*/
public List<Person> findAllByUsername(String username, int pageNo, int pageSize);
/**
* 数据条数
*
* @return
*/
public int findAllCount();
/**
* 用户名包含该字段的条数
*
* @param username
* @return
*/
public int findUserCount(String username);
}
......@@ -5,36 +5,115 @@ import java.util.List;
import com.zhiwei.manage.bean.Channel;
import com.zhiwei.manage.bean.ServerBean;
/**
* 库名等信息的获取
*
* @author admin
*
*/
public interface ServerDao {
/**
* 插入
*
* @param serverBean
*/
public void insert(ServerBean serverBean);
/**
* 分页获取库表信息
*
* @param pageNo
* @param pageSize
* @param dbName
* @return
*/
public List<ServerBean> findDb(int pageNo, int pageSize, String dbName);
/**
* 更新库表信息
*
* @param serverBean
* @return
*/
public boolean update(ServerBean serverBean);
/**
* 删除库表信息
*
* @param id
* @return
*/
public boolean delete(List<String> id);
public void findPt(String pt);
/**
* 渠道信息
*
* @return
*/
public List<Channel> findChannels();
/**
* 分页获取渠道信息
*
* @param pageNo
* @param pageSize
* @return
*/
public List<Channel> findAllChannels(int pageNo, int pageSize);
/**
* 插入渠道信
*
* @param channels
*/
public void insertChannels(Channel channels);
/**
* 更新渠道信息
*
* @param channel
* @return
*/
public boolean updateChannel(Channel channel);
/**
* 删除渠道信息
*
* @param id
* @return
*/
public boolean deleteChannel(List<String> id);
/**
* 获取库表数据根据库名
*
* @param dbName
* @return
*/
public int findServerCount(String dbName);
/**
* 获取渠道数量
*
* @return
*/
public int findChannelsCount();
/**
* 获取所有的渠道
*
* @return
*/
public List<Channel> findDisChannels();
/**
* 获取渠道名
*
* @return
*/
public List<String> findDisChan();
public ServerBean findServerBean(String pt);
}
......@@ -2,24 +2,18 @@ package com.zhiwei.manage.dao;
import java.lang.reflect.Field;
import java.util.List;
import java.util.concurrent.ConcurrentHashMap;
import javax.annotation.Resource;
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.data.mongodb.core.query.Update;
import org.springframework.stereotype.Component;
import com.mongodb.BasicDBObject;
import com.mongodb.DBCollection;
import com.mongodb.WriteResult;
import com.zhiwei.manage.bean.Channel;
import com.zhiwei.manage.bean.ServerBean;
import com.zhiwei.manage.handle.DbDepot;
import com.zhiwei.manage.util.MongoConnect;
@Component
public class ServerDaoImpl implements ServerDao {
......@@ -74,28 +68,6 @@ public class ServerDaoImpl implements ServerDao {
}
@Override
public void findPt(String pt) {
// List<ServerBean> list = mongo.find(Query.query(Criteria.where("pt").is(pt)),
// ServerBean.class);
// for (ServerBean sb : list) {
// if (sb.getDbType().equals("mongo")) {
// if (sb.getDbUsername() != null && !sb.getDbUsername().equals("")) {
// DBCollection con = new MongoConnect(sb.getDbHost(), sb.getDbPort(),
// sb.getDbUsername(),
// sb.getDbPassword(), sb.getDbName()).getCollection(sb.getCollection());
// DbDepot.dbCons.put(sb.getOther(), con);
// } else {
// DBCollection con = new MongoConnect(sb.getDbHost(), sb.getDbPort(),
// sb.getDbName())
// .getCollection(sb.getCollection());
// DbDepot.dbCons.put(sb.getOther(), con);
// }
// }
// }
// DbDepot.nowPt = pt;
}
@Override
public List<Channel> findAllChannels(int pageNo, int pageSize) {
Query query = new Query();
query.skip((pageNo - 1) * pageSize).limit(pageSize);
......@@ -168,7 +140,8 @@ public class ServerDaoImpl implements ServerDao {
@Override
public ServerBean findServerBean(String pt) {
return mongo.findOne(Query.query(Criteria.where("pt").is(pt).andOperator(Criteria.where("dbType").is("Elasticsearch"))),
return mongo.findOne(
Query.query(Criteria.where("pt").is(pt).andOperator(Criteria.where("dbType").is("Elasticsearch"))),
ServerBean.class);
}
......
......@@ -5,25 +5,92 @@ import java.util.List;
import org.springframework.stereotype.Component;
import com.zhiwei.manage.bean.Template;
/**
* 模板信息获取
*
* @author admin
*
*/
@Component
public interface TemplateDao {
/**
* 插入
*
* @param template
* @return
*/
public boolean insert(Template template);
/**
* 更新
*
* @param template
* @return
*/
public boolean update(Template template);
public List<Template> findAll(int pageNo,int pageSize,String pt);
/**
* 分页获取所有的模板
*
* @param pageNo
* @param pageSize
* @param pt
* @return
*/
public List<Template> findAll(int pageNo, int pageSize, String pt);
/**
* 获取所有的模板
*
* @return
*/
public List<Template> findAll();
public Template findById(String templateId,String pt);
/**
* 根据的模板id获取
*
* @param templateId
* @param pt
* @return
*/
public Template findById(String templateId, String pt);
public List<Template> findByTmpName(String templateName,int pageNo,int pageSize,String pt);
/**
* 分页获取模板信息
*
* @param templateName
* @param pageNo
* @param pageSize
* @param pt
* @return
*/
public List<Template> findByTmpName(String templateName, int pageNo, int pageSize, String pt);
public boolean delete(String templateId,String pt);
/**
* 删除模板信息
*
* @param templateId
* @param pt
* @return
*/
public boolean delete(String templateId, String pt);
/**
* 根据pt获取所有的条数
*
* @param pt
* @return
*/
public int allCount(String pt);
public int findByUserCount(String templateName,String pt);
/**
* 根据模板名获取数据条数
*
* @param templateName
* @param pt
* @return
*/
public int findByUserCount(String templateName, String pt);
}
......@@ -9,25 +9,24 @@ public interface DataService {
public void insert(Data data);
public List<Data> findByPt(Date startTime, Date endTime, String pt);
public List<Data> findByPtDay(Date startTime, Date endTime, String pt);
public List<Data> findBySource(Date startTime, Date endTime,String source);
public List<Data> findBySource(Date startTime, Date endTime, String source);
public List<Data> findBytempName(Date startTime, Date endTime, String tempName);
// public List<Data> findByMethod(Date startTime, Date endTime, String method, Object value);
public List<Data> findByPt(Date startTime, Date endTime, String pt);
// public List<Data> findByMethod(Date startTime, Date endTime, String method,
// Object value);
// public int findBySourceFromLibrary(Date startTime, Date endTime, String source);
// public int findBySourceFromLibrary(Date startTime, Date endTime, String
// source);
public List<Data> findByPtDay(Date startTime, Date endTime, String pt);
public List<Data> findByMethodAndParam(Date startTime, Date endTime,String method,String param);
public List<Data> findByMethodAndParam(Date startTime, Date endTime, String method, String param);
public List<String> findTmpNameByLikeParam(String param);
// 根据配置获取数据
// public long finCountByDayData(Date startDate, Date endDate, Template temp);
//
// public long finCountByDayData(Date startDate, Date endDate, String pt);
// public long finCountByDayData(Date startDate, Date endDate, Template temp);
//
// public long finCountByDayData(Date startDate, Date endDate, String pt);
}
......@@ -7,23 +7,20 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.zhiwei.manage.bean.Data;
import com.zhiwei.manage.bean.EasyNews;
import com.zhiwei.manage.bean.Template;
import com.zhiwei.manage.dao.DataDao;
import com.zhiwei.manage.dao.ServerDao;
import com.zhiwei.manage.util.ESUtil;
@Service
public class DataServiceImpl implements DataService {
@Autowired
private DataDao dataDao;
@Autowired
private ServerDao serverDao;
@Autowired
private CrawTemplateService crService;
private ESUtil es=new ESUtil();
private ESUtil es = new ESUtil();
@Override
public void insert(Data data) {
dataDao.insert(data);
......@@ -44,6 +41,29 @@ public class DataServiceImpl implements DataService {
return dataDao.findBytempName(startTime, endTime, tempName);
}
// @Override
// public List<EasyNews> findByAccurateSource(String startTime, String endTime,
// String source) {
// return dataDao.findByAccurateSource(startTime, endTime, source);
// }
//
// @Override
// public List<EasyNews> findByAccurateSpId(String startTime, String endTime,
// String SpId) {
// return dataDao.findByAccurateSpId(startTime, endTime, SpId);
// }
//
// @Override
// public int findBySourceFromLibrary(Date startTime, Date endTime, String
// source) {
// return dataDao.findBySourceFromLibrary(startTime, endTime, source);
// }
// @Override
// public List<String> findSourceByLikeParam(String param) {
// return dataDao.findSourceByLikeParam(param);
// }
@Override
public List<String> findTmpNameByLikeParam(String param) {
return dataDao.findTmpNameByLikeParam(param);
......@@ -56,7 +76,38 @@ public class DataServiceImpl implements DataService {
@Override
public List<Data> findByMethodAndParam(Date startTime, Date endTime, String method, String param) {
return es.findByMethodAndParam(crService,startTime, endTime, method,param,serverDao.findServerBean("网媒"));
return es.findByMethodAndParam(crService, startTime, endTime, method, param, serverDao.findServerBean("网媒"));
}
// @Override
// public int findByAccurateType(Date startTime, Date endTime, String type) {
// return dataDao.findByAccurateType(startTime, endTime, type);
// }
//
// @Override
// public List<String> findTypeByLikeParam(String param) {
// return dataDao.findTypeByLikeParam(param);
// }
//
// @Override
// public List<Data> findByMethod(Date startTime, Date endTime, String method,
// Object value) {
// return dataDao.findByMethod(startTime, endTime, method, value);
// }
//
// @Override
// public long finCountByDayData(Date startTime, Date endTime, Template temp) {
// return dataDao.finCountByDayData(startTime, endTime, temp);
// }
//
// @Override
// public int findByTempName(Date startTime, Date endTime, String tempName) {
// return dataDao.findBySpId(startTime, endTime, tempName);
// }
//
// @Override
// public long finCountByDayData(Date startDate, Date endDate, String pt) {
// return dataDao.finCountByDayData(startDate, endDate, pt);
// }
}
......@@ -5,6 +5,12 @@ import java.util.List;
import com.zhiwei.manage.bean.FieldBean;
import com.zhiwei.manage.bean.PageEty;
/**
* 字段服务
*
* @author admin
*
*/
public interface FieldBeanService {
public FieldBean getFieldsByPt(String pt);
......@@ -14,7 +20,7 @@ public interface FieldBeanService {
public boolean update(FieldBean fieldBean);
public boolean delete(List<String> id);
public PageEty findAllFields(int pageNo,int pageSize,String pt);
public PageEty findAllFields(int pageNo, int pageSize, String pt);
}
......@@ -5,19 +5,78 @@ import java.util.List;
import com.zhiwei.manage.bean.Message;
import com.zhiwei.manage.bean.PageEty;
/**
* 信息服务部分
*
* @author admin
*
*/
public interface MessageService {
/**
* 插入
*
* @param message
*/
public void insert(Message message);
/**
* 更新
*
* @param message
* @param pt
* @return
*/
public String update(Message message, String pt);
/**
* 分页查询全部
*
* @param pageNo
* @param pageSize
* @param pt
* @return
*/
public PageEty findAll(int pageNo, int pageSize, String pt);
/**
* 分页模板名查询
*
* @param templateName
* @param pageNo
* @param pageSize
* @param pt
* @return
*/
public PageEty findByTmpName(String templateName, int pageNo, int pageSize, String pt);
/**
* 根据id删除
*
* @param MessageId
* @param pt
* @return
*/
public boolean delete(List<String> MessageId, String pt);
/**
* 分页查询模板名信息
*
* @param pageNo
* @param pageSize
* @param handle
* @param tempName
* @param pt
* @return
*/
public PageEty findByHandle(int pageNo, int pageSize, boolean handle, String tempName, String pt);
/**
* 查询错误信息
*
* @param tempName
* @param errorType
* @return
*/
public Message findMsg(String tempName, String errorType);
}
......@@ -7,20 +7,56 @@ import java.util.Map;
import com.zhiwei.manage.bean.EasyNews;
import com.zhiwei.manage.bean.News;
/**
* 新闻
*
* @author admin
*
*/
public interface NewsService {
/**
* 根据来源和type获取新闻数据
*
* @param delayedCount
* @param type
* @param source
* @return
*/
public List<News> findByNew(int delayedCount, String type, String source);
/**
* 根据来源和type获取新闻数据
*
* @param filedCount
* @param type
* @param source
* @return
*/
public List<News> findByFiled(int filedCount, String type, String source);
public int findCount(String spyId,Date start,Date end);
/**
* 根据采集主键获取新闻
*
* @param spyId
* @param start
* @param end
* @return
*/
public int findCount(String spyId, Date start, Date end);
/**
* 获取所有的来源
*
* @return
*/
public List<Object> findAllSource();
public int findCountBySource(String source,Date start,Date end);
public List<EasyNews> findAllNews(Date start,Date end);
public List<Map<String,Object>> findNews(String host,int port,String dbNamel,String collection,int count,String id,String pt);
public int findCountBySource(String source, Date start, Date end);
public List<EasyNews> findAllNews(Date start, Date end);
public List<Map<String, Object>> findNews(String host, int port, String dbNamel, String collection, int count,
String id, String pt);
}
......@@ -6,6 +6,7 @@ import org.springframework.stereotype.Component;
import com.zhiwei.manage.bean.PageEty;
import com.zhiwei.manage.bean.Person;
@Component
public interface PersonService {
......@@ -13,15 +14,50 @@ public interface PersonService {
public boolean update(Person person);
public PageEty findAll(int pageNo,int pageSize,int lv);
/**
* 分页查询用户信息
*
* @param pageNo
* @param pageSize
* @param lv
* @return
*/
public PageEty findAll(int pageNo, int pageSize, int lv);
/**
* 根据用户id查询用户信息
*
* @param personId
* @return
*/
public Person findById(String personId);
/**
* 删除用户信息
*
* @param personId
* @return
*/
public boolean delete(List<String> personId);
public Person login(String username,String password);
public PageEty findByUserName(String username,int pageNo,int pageSize,int lv);
/**
* 登录操作,验证用户名密码
*
* @param username
* @param password
* @return
*/
public Person login(String username, String password);
/**
* 根据用户名分页查询
*
* @param username
* @param pageNo
* @param pageSize
* @param lv
* @return
*/
public PageEty findByUserName(String username, int pageNo, int pageSize, int lv);
}
......@@ -10,28 +10,79 @@ public interface ServerService {
public void insert(ServerBean serverBean);
/**
* 分页查询库信息
*
* @param pageNo
* @param pageSize
* @param dbName
* @return
*/
public PageEty findDb(int pageNo, int pageSize, String dbName);
public boolean update(ServerBean serverBean);
public boolean delete(List<String> id);
/**
* 插入渠道
*
* @param channels
*/
public void insertChannels(Channel channels);
public void findPt(String pt);
/**
* 修改渠道信息
*
* @param channel
* @return
*/
public boolean updateChannel(Channel channel);
/**
* 删除渠道信息
*
* @param id
* @return
*/
public boolean deleteChannel(List<String> id);
/**
* 查询渠道信息
*
* @return
*/
public List<Channel> findChannels();
/**
* 分页查询渠道
*
* @param pageNo
* @param pageSize
* @return
*/
public PageEty findChannel(int pageNo, int pageSize);
/**
* 查询所有的渠道
*
* @return
*/
public List<Channel> findDisChannel();
/**
* 获取渠道名
*
* @return
*/
public List<String> findDisChan();
/**
* 根据pt获取库的配置
*
* @param pt
* @return
*/
public ServerBean findServer(String pt);
}
......@@ -49,18 +49,12 @@ public class ServerServiceImpl implements ServerService {
return sd.delete(id);
}
@Override
public void insertChannels(Channel channels) {
sd.insertChannels(channels);
}
@Override
public void findPt(String pt) {
sd.findPt(pt);
}
@Override
public boolean updateChannel(Channel channel) {
return sd.updateChannel(channel);
}
......@@ -71,8 +65,8 @@ public class ServerServiceImpl implements ServerService {
}
@Override
public PageEty findChannel(int pageNo,int pageSize) {
List<Channel> list= sd.findAllChannels(pageNo,pageSize);
public PageEty findChannel(int pageNo, int pageSize) {
List<Channel> list = sd.findAllChannels(pageNo, pageSize);
PageEty page = new PageEty();
page.setData(list);
page.setPageNo(pageNo);
......
......@@ -11,14 +11,43 @@ public interface TemplateService {
public boolean update(Template template);
public PageEty findAll(int pageNo,int pageSize,String pt);
/**
* 分页查询所有
*
* @param pageNo
* @param pageSize
* @param pt
* @return
*/
public PageEty findAll(int pageNo, int pageSize, String pt);
/**
* 查询所有的模板信息
*
* @return
*/
public List<Template> findAll();
public Template findById(String templateId,String pt);
/**
* 根据id查询模板
*
* @param templateId
* @param pt
* @return
*/
public Template findById(String templateId, String pt);
/**
* 根据模板名分页查询模板
*
* @param templateName
* @param pageNo
* @param pageSize
* @param pt
* @return
*/
public PageEty findByTmpName(String templateName, int pageNo, int pageSize, String pt);
public boolean delete(String templateId, String pt);
public PageEty findByTmpName(String templateName,int pageNo,int pageSize,String pt);
public boolean delete(String templateId,String pt);
}
......@@ -60,7 +60,7 @@ public class DataController {
}
/**
* 根据来源获取数据
* 根据来源获取数据
*
* @param request
* @param response
......
......@@ -104,20 +104,21 @@ public class ServerController {
return JSON.toJSONString(result);
}
/**
* 更改平台
*
* @param map
* @return
*/
@RequestMapping(value = "/changePt", produces = "application/json;charset=utf-8")
@ResponseBody
public String changePt(@RequestBody Map<String, Object> map) {
String pt = (String) map.get("pt");
ss.findPt(pt);
JsonResult result = new JsonResult(true, 200, "源改变成功");
return JSON.toJSONString(result);
}
// /**
// * 更改平台
// *
// * @param map
// * @return
// */
// @RequestMapping(value = "/changePt", produces =
// "application/json;charset=utf-8")
// @ResponseBody
// public String changePt(@RequestBody Map<String, Object> map) {
// String pt = (String) map.get("pt");
// ss.findPt(pt);
// JsonResult result = new JsonResult(true, 200, "源改变成功");
// return JSON.toJSONString(result);
// }
/**
* 插入渠道信息
......
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