Commit 50779806 by admin

服务端修改延时

parent b36315fb
......@@ -9,8 +9,6 @@ import java.util.List;
import java.util.Map;
import java.util.TimeZone;
import javax.print.Doc;
import org.bson.Document;
import org.elasticsearch.action.search.SearchRequestBuilder;
import org.elasticsearch.action.search.SearchResponse;
......@@ -29,8 +27,6 @@ import com.zhiwei.util.MongoConnection;
import com.zhiwei.util.ReadExcel;
import com.zw.entity.NewsResult;
import weixin.popular.bean.menu.selfmenu.News;
/**
* es工具类
*
......@@ -40,6 +36,7 @@ import weixin.popular.bean.menu.selfmenu.News;
public class ESUtil {
private static final Logger log = LoggerFactory.getLogger(ESUtil.class);
private static MongoConnection con = new MongoConnection();
private static Client esClient = ESClient.getInstance();
/**
* 获取匹配时终止时间
......@@ -76,41 +73,6 @@ public class ESUtil {
return result;
}
public static void main(String[] args) {
// Calendar cal = Calendar.getInstance();
// cal.add(Calendar.HOUR_OF_DAY, -20);
// Calendar cal2 = Calendar.getInstance();
// cal2.add(Calendar.HOUR_OF_DAY, -4);
// List<NewsResult> list = new ESUtil().pushByKey(cal.getTime(),
// cal2.getTime());
// System.out.println(list.size());
// String str = "";
// String url = "C:\\Users\\admin\\Desktop/shenjz.xls";
// cal.add(Calendar.HOUR_OF_DAY, 9);
// try {
// new ExcelUtil().pushDataWithFinance(list, cal.getTime(), url);
// } catch (Exception e) {
// e.printStackTrace();
// }
List<String> sources = new ArrayList<String>();
String path = PushFinanceByTime.class.getClassLoader().getResource("pushFiles/weibo.xls").getPath();
// Document doc = con.find("financePush", "excelPath", new
// Document().append("name", "longSource"));
// if (doc != null) {
// if (doc.getString("url") != null) {
// path = doc.getString("url");
// }
// }
// sources = new ReadExcel().getExcel(path);
Calendar cal = Calendar.getInstance();
cal.add(Calendar.HOUR_OF_DAY, -1);
List<NewsResult> list = new ESUtil().pushByKey(cal.getTime(), new Date(), sources, "wechat");
System.out.println(list);
list = new ESUtil().pushByKey(cal.getTime(), new Date(), sources, "wechat");
System.out.println(list);
}
/**
* 推送
*
......@@ -118,7 +80,7 @@ public class ESUtil {
* @param end
* @return
*/
public List<NewsResult> pushByKey(Date start, Date end, List<String> sources, String type) {
public static List<NewsResult> pushByKey(Date start, Date end, List<String> sources, String type) {
log.info("开始执行检索" + type + ":" + Config.getVal("indexName." + type));
List<NewsResult> result = new ArrayList<>();
List<NewsResult> lists = new ArrayList<>();
......@@ -147,7 +109,6 @@ public class ESUtil {
}
}
keys = new ReadExcel().getExcel(path);
Client esClient = ESClient.getInstance();
try {
for (String key : keys) {
// 搜索数据
......
......@@ -32,8 +32,6 @@ public class PushFinanceByTime extends Thread {
public void run() {
while (true) {
List<String> sources = new ArrayList<String>();
List<String> wechat = new ArrayList<String>();
List<String> weibo = new ArrayList<String>();
log.info("推送检测");
String path = PushFinanceByTime.class.getClassLoader().getResource("pushFiles/pushSource.xls").getPath();
Document doc = con.find("financePush", "excelPath", new Document().append("name", "longSource"));
......@@ -43,30 +41,12 @@ public class PushFinanceByTime extends Thread {
}
}
sources = new ReadExcel().getExcel(path);
String path_wechat = PushFinanceByTime.class.getClassLoader().getResource("pushFiles/wechat.xls").getPath();
Document doc_wechat = con.find("financePush", "excelPath", new Document().append("name", "wechat"));
if (doc_wechat != null) {
if (doc_wechat.getString("url") != null) {
path_wechat = doc_wechat.getString("url");
}
}
wechat = new ReadExcel().getExcel(path_wechat);
System.out.println(wechat);
String path_weibo = PushFinanceByTime.class.getClassLoader().getResource("pushFiles/weibo.xls").getPath();
Document doc_weibo = con.find("financePush", "excelPath", new Document().append("name", "weibo"));
if (doc_weibo != null) {
if (doc_weibo.getString("url") != null) {
path_weibo = doc_weibo.getString("url");
}
}
weibo = new ReadExcel().getExcel(path_weibo);
System.out.println(weibo);
Calendar cal = Calendar.getInstance();
try {
if (cal.get(Calendar.HOUR_OF_DAY) == 8 && cal.get(Calendar.MINUTE) >= 30) {
cal.add(Calendar.HOUR_OF_DAY, -16);
cal.set(Calendar.MINUTE, 0);
List<NewsResult> list = new ESUtil().pushByKey(cal.getTime(), new Date(), sources, "media");
List<NewsResult> list = ESUtil.pushByKey(cal.getTime(), new Date(), sources, "media");
String url = PushFinanceByTime.class.getClassLoader().getResource("/").getPath() + "/"
+ (int) (Math.random() * 5000) + "sends.xls";
cal.add(Calendar.HOUR_OF_DAY, 16);
......@@ -74,7 +54,7 @@ public class PushFinanceByTime extends Thread {
sleep(1000 * 60 * 60);
} else if (cal.get(Calendar.HOUR_OF_DAY) == 11) {// 11
cal.add(Calendar.HOUR_OF_DAY, -3);
List<NewsResult> list = new ESUtil().pushByKey(cal.getTime(), new Date(), sources, "media");
List<NewsResult> list = ESUtil.pushByKey(cal.getTime(), new Date(), sources, "media");
String url = PushFinanceByTime.class.getClassLoader().getResource("/").getPath() + "/"
+ (int) (Math.random() * 5000) + "sends.xls";
cal.add(Calendar.HOUR_OF_DAY, 3);
......@@ -85,7 +65,7 @@ public class PushFinanceByTime extends Thread {
if (cal.get(Calendar.HOUR_OF_DAY) == 16 && cal.get(Calendar.MINUTE) >= 30) {
cal.add(Calendar.HOUR_OF_DAY, -5);
cal.set(Calendar.MINUTE, 0);
List<NewsResult> list = new ESUtil().pushByKey(cal.getTime(), new Date(), sources, "media");
List<NewsResult> list = ESUtil.pushByKey(cal.getTime(), new Date(), sources, "media");
String url = PushFinanceByTime.class.getClassLoader().getResource("/").getPath() + "/"
+ (int) (Math.random() * 5000) + "sends.xls";
cal.add(Calendar.HOUR_OF_DAY, 5);
......
......@@ -27,7 +27,6 @@ public class ServerClient extends Thread {
ServerSocket server = null;
try {
server = new ServerSocket(22222);
server.setSoTimeout(2000);
System.out.println("服务启动");
while (true) {
Socket socket = server.accept();
......
......@@ -150,7 +150,7 @@ public class WechatReadAndWrite {
while (!ServerClient.needSend) {
Thread.sleep(1000 * 30);
}
Thread.sleep(1000 * 30);
log.info("收到结束信息,开始写出文件");
Map<String, ReadWechat> map = new HashMap<>();
for (Document doc : m.findReadWechat()) {
ReadWechat rw = new ReadWechat();
......
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