Commit 9cab1b25 by admin

添加了金融的推送部分

parent 22f655ad
/target/
/.settings/
/logs/
.classpath
.project
.svn
.settings/
target/
\ No newline at end of file
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.zhiwei</groupId>
<artifactId>change4weixin</artifactId>
<version>3.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<dependencies>
<!-- https://mvnrepository.com/artifact/com.sun.mail/javax.mail -->
<dependency>
<groupId>com.sun.mail</groupId>
<artifactId>javax.mail</artifactId>
<version>1.5.6</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.springframework/spring-aop -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-aop</artifactId>
<version>4.3.7.RELEASE</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.springframework/spring-beans -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
<version>4.3.7.RELEASE</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.springframework/spring-context -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>4.3.7.RELEASE</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.springframework/spring-core -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>4.3.7.RELEASE</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.springframework/spring-expression -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-expression</artifactId>
<version>4.3.7.RELEASE</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.springframework/spring-web -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>4.3.7.RELEASE</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.springframework/spring-webmvc -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>4.3.7.RELEASE</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.slf4j/slf4j-api -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.24</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.slf4j/slf4j-log4j12 -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>1.7.24</version>
</dependency>
<!-- https://mvnrepository.com/artifact/log4j/log4j -->
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.17</version>
</dependency>
<!-- https://mvnrepository.com/artifact/commons-logging/commons-logging -->
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>1.2</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
<version>2.7</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>2.7</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.alibaba/fastjson -->
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>1.2.29</version>
</dependency>
<dependency>
<groupId>net.sf.json-lib</groupId>
<artifactId>json-lib</artifactId>
<version>2.4</version>
<classifier>jdk15</classifier>
</dependency>
<dependency>
<groupId>com.github.liyiorg</groupId>
<artifactId>weixin-popular</artifactId>
<version>2.8.10</version>
</dependency>
<dependency>
<groupId>org.elasticsearch.client</groupId>
<artifactId>transport</artifactId>
<version>5.2.2</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
<version>2.7</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>2.7</version>
</dependency>
<!-- https://mvnrepository.com/artifact/net.sourceforge.jexcelapi/jxl -->
<dependency>
<groupId>net.sourceforge.jexcelapi</groupId>
<artifactId>jxl</artifactId>
<version>2.6.12</version>
</dependency>
<!-- mongodb -->
<dependency>
<groupId>org.mongodb</groupId>
<artifactId>mongo-java-driver</artifactId>
<version>3.0.4</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.poi/poi -->
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>3.9</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.poi/poi-ooxml -->
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>3.9</version>
</dependency>
<!-- https://mvnrepository.com/artifact/commons-fileupload/commons-fileupload -->
<dependency>
<groupId>commons-fileupload</groupId>
<artifactId>commons-fileupload</artifactId>
<version>1.3.1</version>
</dependency>
<!-- https://mvnrepository.com/artifact/commons-io/commons-io -->
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.4</version>
</dependency>
<dependency>
<groupId>org.apache.tomcat</groupId>
<artifactId>tomcat-servlet-api</artifactId>
<scope>provided</scope>
<version>7.0.47</version>
</dependency>
<dependency>
<groupId>org.apache.tomcat</groupId>
<artifactId>catalina</artifactId>
<scope>provided</scope>
<version>6.0.37</version>
</dependency>
<dependency>
<groupId>org.apache.tomcat</groupId>
<artifactId>tomcat-coyote</artifactId>
<scope>provided</scope>
<version>7.0.47</version>
</dependency>
<dependency>
<groupId>com.zhiwei.pro</groupId>
<artifactId>getzhihudata</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
</dependencies>
</project>
\ No newline at end of file
basefile=/home/nbzhiwei/upload/
#basefile=C:/Users/Administrator/Desktop/news222.xls
timefileUrl=/home/nbzhiwei/upload
#timefileUrl=C:/Users/Administrator/Desktop
#host=106.14.249.240
#port=26807
#password=1q2w3e4r
#user=zhiweidata
dbName=TmpData
host=192.168.0.36
port=26017
socketIp=192.168.0.11
socketPort=10201
\ No newline at end of file
appender.console.type = Console
appender.console.name = console
appender.console.layout.type = PatternLayout
rootLogger.level = info
rootLogger.appenderRef.console.ref = console
\ No newline at end of file
<!DOCTYPE html>
<html>
<head>
<title>Table</title>
<meta charset="utf-8">
<link rel="stylesheet" href="https://cdn.bootcss.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/1.4.3/jquery.min.js"></script>
<!-- <script src="https://cdn.bootcss.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script> -->
<style>
body {
background-image: url("./2.jpg");
}
#timeCanvas {
position: absolute;
top: 3%;
right: 3%;
height: 30px;
width: 210px;
}
.table {
position: absolute;
left: 15%;
top: 7%;
width: 70%;
z-index: 100;
}
.table tr {
background-color: transparent !important;
}
.table tr td {
border-color: #000 !important;
}
</style>
</head>
<body>
<table class="table table-striped">
<thead>
<tr>
<td>编号</td>
<td>提交者</td>
<td>运行需要时间</td>
<td>开始时间</td>
<td>状态</td>
<td>当前剩余的条数</td>
</tr>
</thead>
<tbody class="data"></tbody>
</table>
<script>
$(function () {
var tbody = $('.data')
var d = []
function getData() {
$(tbody).empty();
d = []
$.ajax({
type: 'get',
datatype: 'json',
url: 'http://192.168.0.245:8080/change4weixin/show',
success: function (data) {
data = JSON.parse(data)
d = data
data.forEach((e, index) => {
tbody.append("<tr class='TR'>"
+"<td class='id'>"+e.id+"</td>"
+"<td>"+e.mail+"</td>"
+"<td>"+e.surplusCount/12+"</td>"
+"<td>"+e.startDate+"</td>"
+"<td>"+e.state+"</td>"
+"<td>"+e.surplusCount+"</td>"
+"</td></tr>")
})
}
})
}
// getData()
})
</script>
</body>
</html>
<%@ page language="java" contentType="text/html; charset=utf-8"
pageEncoding="utf-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Insert title here</title>
<link rel="stylesheet"
href="https://cdn.bootcss.com/bootstrap/4.0.0-beta.2/css/bootstrap.min.css"
integrity="sha384-PsH8R72JQ3SOdhVi3uxftmaW6Vc51MKb0q5P2rRUpPvrszuE4W1povHYgTpBfshb"
crossorigin="anonymous">
<script
src="https://cdn.bootcss.com/bootstrap/4.0.0-beta.2/js/bootstrap.min.js"
integrity="sha384-alpBpkh1PFOepccYVYDB4do5UnbKysX5WZXm3XxPqe5iKTfUKjNkCk9SaVuEZflJ"
crossorigin="anonymous"></script>
<script src="js/jquery-2.1.4.min.js"></script>
<script type="text/javascript">
$(function() {
getTime();
setInterval("getTime()", 10 * 1000);
});
function getTime() {
var time = $('#time').empty();
$.ajax({
url : '/change4weixin/show',
success : function(result) {
var list = JSON.parse(result);
if (list.length > 0) {
console.log(list);
console.log(list.length);
var t = 0;
var tab = $('#tab')
tab.empty();
var head = '<thead><tr>'
+'<th>编号</th>'
+ '<th>提交者</th>'
+ '<th>运行需要时间</th>'
+ '<th>开始时间</th>'
+ '<th>当前剩余转的条数</th>'
+ '<th>操作</th>'
+ '</tr>'
+ '</thead>';
tab.append(head);
var tbody = $('tbody');
for (var i = 0; i < list.length; i++) {
var addem = '<tr class="success">'
+ '<td>'+list[i].site+'</td>'
+ '<td>'+list[i].mail+'</td>'
+ '<td>'+list[i].need+'</td>'
+ '<td>'+list[i].startDate+'</td>'
+ '<td>'+list[i].surplusCount+'</td>'
+ '<td>删除,插队</td>'
+ '</tr>';
tbody.append(addem);
}
tab.append(tbody);
} else {
var time = $('#time').empty();
var addem = '暂无运行的文件';
time.append(addem);
}
}
});
}
</script>
</head>
<body>
<div>
<span>有时候显示有点问题,耐心等待</span>
</div>
<div id="time"></div>
<div class="container">
<div class="row clearfix">
<div class="col-md-12 column">
<table class="table" id="tab">
<thead>
<tr>
<th>编号</th>
<th>提交者</th>
<th>运行需要时间</th>
<th>开始时间</th>
<th>当前剩余转的条数</th>
<th>操作</th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td>TB - Monthly</td>
<td>01/04/2012</td>
<td>Default</td>
</tr>
<tr class="success">
<td>1</td>
<td>TB - Monthly</td>
<td>01/04/2012</td>
<td>Approved</td>
</tr>
<tr class="error">
<td>2</td>
<td>TB - Monthly</td>
<td>02/04/2012</td>
<td>Declined</td>
</tr>
<tr class="warning">
<td>3</td>
<td>TB - Monthly</td>
<td>03/04/2012</td>
<td>Pending</td>
</tr>
<tr class="info">
<td>4</td>
<td>TB - Monthly</td>
<td>04/04/2012</td>
<td>Call in to confirm</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</body>
</html>
\ No newline at end of file
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.zhiwei</groupId>
......@@ -97,8 +98,6 @@
<artifactId>log4j-core</artifactId>
<version>2.7</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.alibaba/fastjson -->
<dependency>
<groupId>com.alibaba</groupId>
......@@ -155,54 +154,30 @@
<artifactId>poi</artifactId>
<version>3.9</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.poi/poi-ooxml -->
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>3.9</version>
</dependency>
<!-- https://mvnrepository.com/artifact/commons-fileupload/commons-fileupload -->
<dependency>
<groupId>commons-fileupload</groupId>
<artifactId>commons-fileupload</artifactId>
<version>1.3.1</version>
</dependency>
<!-- https://mvnrepository.com/artifact/commons-io/commons-io -->
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.4</version>
</dependency>
<dependency>
<groupId>org.apache.tomcat</groupId>
<artifactId>tomcat-servlet-api</artifactId>
<scope>provided</scope>
<version>7.0.47</version>
</dependency>
<dependency>
<groupId>org.apache.tomcat</groupId>
<artifactId>catalina</artifactId>
<scope>provided</scope>
<version>6.0.37</version>
</dependency>
<dependency>
<groupId>org.apache.tomcat</groupId>
<artifactId>tomcat-coyote</artifactId>
<scope>provided</scope>
<version>7.0.47</version>
</dependency>
<dependency>
<groupId>com.zhiwei.pro</groupId>
<artifactId>getzhihudata</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
</dependencies>
......
......@@ -4,11 +4,9 @@ import java.io.BufferedReader;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.net.Socket;
import java.text.SimpleDateFormat;
......@@ -16,21 +14,14 @@ import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Queue;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.poi.hssf.usermodel.HSSFCell;
import org.apache.poi.hssf.usermodel.HSSFRow;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import com.zhiwei.entity.Zhihu;
import com.zhiwei.servlet.MainController;
import com.zhiwei.util.Config;
import com.zw.entity.ExcelFile;
......@@ -537,6 +528,8 @@ public class ExcelReadAndWrite {
continue;
}
}
System.out.println("list:"+list.size());
System.out.println(urls.size());
m.insert(urls);// 存储
Thread.sleep(1000 * 80);
while (so()) {
......@@ -618,89 +611,6 @@ public class ExcelReadAndWrite {
return m.findByid(id);
}
public static void writeZhihu(List<Zhihu> list, String mail) throws Exception {
Calendar cal = Calendar.getInstance();
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
String inurl = "C:\\Users\\Administrator\\Desktop/" + (int) (Math.random() * 99) + sdf.format(cal.getTime())
+ ".xls";
File tempFile = new File(inurl);
// 若是文件不存在就创建新文件
if (!tempFile.exists()) {
tempFile.createNewFile();
}
WritableWorkbook workbook = Workbook.createWorkbook(tempFile);
WritableSheet sheet = workbook.createSheet("table1", 0);
// 一些临时变量,用于写到excel中
Label l = null;
// 标题格式
WritableFont titleFont = new WritableFont(WritableFont.ARIAL, 14, WritableFont.NO_BOLD, false,
UnderlineStyle.NO_UNDERLINE, jxl.format.Colour.BLACK);
WritableCellFormat titleFormat = new WritableCellFormat(titleFont);
titleFormat.setAlignment(Alignment.CENTRE);
// 正文字体
WritableFont detFont = new WritableFont(WritableFont.ARIAL, 13, WritableFont.NO_BOLD, false,
UnderlineStyle.NO_UNDERLINE, jxl.format.Colour.BLACK);
WritableCellFormat detFormat = new WritableCellFormat(detFont);
detFormat.setVerticalAlignment(VerticalAlignment.CENTRE);
// 财新小字
WritableFont detFont2 = new WritableFont(WritableFont.ARIAL, 10, WritableFont.NO_BOLD, false,
UnderlineStyle.NO_UNDERLINE, Colour.WHITE);
WritableCellFormat detFormat2 = new WritableCellFormat(detFont2);
detFormat2.setBackground(Colour.BLUE_GREY);
WritableCellFormat detFormat3 = new WritableCellFormat(detFont2);
detFormat3.setBackground(Colour.BLUE_GREY);
detFormat3.setAlignment(Alignment.CENTRE);
WritableFont urlf = new WritableFont(WritableFont.ARIAL, 11, WritableFont.NO_BOLD, false,
UnderlineStyle.NO_UNDERLINE, Colour.BLUE);
WritableCellFormat urlFormat = new WritableCellFormat(urlf);
urlFormat.setVerticalAlignment(VerticalAlignment.CENTRE);
int seq = 0;
l = new Label(0, seq, "地址");
sheet.addCell(l);
l = new Label(1, seq, "标题");
sheet.addCell(l);
l = new Label(2, seq, "内容");
sheet.addCell(l);
l = new Label(3, seq, "回答者");
sheet.addCell(l);
l = new Label(4, seq, "回答时间");
sheet.addCell(l);
l = new Label(5, seq, "作者地址");
sheet.addCell(l);
l = new Label(6, seq, "点赞数");
sheet.addCell(l);
for (Zhihu w : list) {
seq++;
l = new Label(0, seq, w.getId());
sheet.addCell(l);
l = new Label(1, seq, w.getTitle());
sheet.addCell(l);
l = new Label(2, seq, w.getContent());
sheet.addCell(l);
l = new Label(3, seq, w.getAuthor());
sheet.addCell(l);
l = new Label(4, seq, w.getTime());
sheet.addCell(l);
l = new Label(5, seq, w.getAuthorUrl());
sheet.addCell(l);
l = new Label(6, seq, w.getPointLikeNumber());
sheet.addCell(l);
}
int column = 0;
sheet.setColumnView(column++, 20);
sheet.setColumnView(column++, 25);
sheet.setColumnView(column++, 25);
sheet.setColumnView(column++, 25);
sheet.setColumnView(column++, 30);
sheet.setColumnView(column++, 80);
sheet.setColumnView(column++, 90);
workbook.write();
workbook.close();
log.info("内容写入成功");
SendMailUtil.sendMessage(mail, inurl, "zhihu");
System.out.println("发送完成");
}
public static List<String> readExcel(String url) {
InputStream stream = null;
String str = null;
......
......@@ -50,6 +50,11 @@ public class FileThread extends Thread{
e.printStackTrace();
}
}
try {
Thread.sleep(1000*3500);
} catch (InterruptedException e) {
e.printStackTrace();
}
// try {
// Thread.sleep(1000*60*30);
// } catch (InterruptedException e) {
......
......@@ -22,11 +22,8 @@ public class ReaderExcel {
private final static Log log = LogFactory.getLog(ReaderExcel.class);
public static void main(String[] args) throws IOException {
for (String w : getZhUrls("C:\\Users\\Administrator\\Desktop/新闻源栏目.xlsx")) {
Matcher m=Pattern.compile("[\\S]+").matcher(w);
if(m.find()) {
System.out.println(m.group().replace("java.util.regex.Matcher[pattern=[\\S]+ region=0,3 lastmatch=", ""));
}
for (Weixin w : getExcel("C:\\Users\\admin\\Desktop/微信-山西三维0419.xlsx")) {
System.out.println(w);
}
}
......
package com.zhiwei.finance;
import java.net.InetAddress;
import java.net.UnknownHostException;
import org.elasticsearch.client.transport.TransportClient;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.transport.InetSocketTransportAddress;
import org.elasticsearch.transport.client.PreBuiltTransportClient;
import com.zhiwei.util.Config;
/**
* es连接类
*
* @author shenjinzhu
*
*/
public class ESClient {
private static String esIp;
private static int esPort;
private static String clusterName;
private static class ESClientHolder {
static TransportClient client = initESClient();
private static TransportClient initESClient() {
esIp=Config.getVal("esIp");
clusterName=Config.getVal("clusterName");
esPort=Integer.valueOf(Config.getVal("esPort"));
Settings esSettings = Settings.builder().put("cluster.name", clusterName) // 设置ES实例的名称
// 自动嗅探整个集群的状态,把集群中其他ES节点的ip添加到本地的客户端列表中
.put("client.transport.sniff", false).build();
TransportClient client = new PreBuiltTransportClient(esSettings);
try {
client.addTransportAddress(new InetSocketTransportAddress(InetAddress.getByName(esIp), esPort));
} catch (UnknownHostException e) {
e.printStackTrace();
}
return client;
}
}
public static TransportClient getInstance() {
return ESClientHolder.client;
}
}
package com.zhiwei.finance;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.List;
import java.util.Map;
import java.util.TimeZone;
import org.elasticsearch.action.search.SearchRequestBuilder;
import org.elasticsearch.action.search.SearchResponse;
import org.elasticsearch.client.Client;
import org.elasticsearch.index.query.BoolQueryBuilder;
import org.elasticsearch.index.query.QueryBuilder;
import org.elasticsearch.index.query.QueryBuilders;
import org.elasticsearch.search.SearchHit;
import org.elasticsearch.search.SearchHits;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
import com.zhiwei.util.Config;
import com.zhiwei.util.ReadExcel;
import com.zw.entity.NewsResult;
/**
* es工具类
*
* @author admin
*/
@Component
public class ESUtil {
private static final Logger log = LoggerFactory.getLogger(ESUtil.class);
private static String indexName;
private static String type;
static {
indexName = Config.getVal("indexName");
type = Config.getVal("type");
}
/**
* 获取匹配时终止时间
*
* @param hour
* @return
*/
public static String getTimeMax(int hour) {
SimpleDateFormat smf = new SimpleDateFormat("yyyy-MM-dd");
Date date = new Date();
String time = "";
time = smf.format(date) + "T0" + (hour - 8) + ":00:00.000Z";
return time;
}
/**
* 格林尼治时间转换成标准时间
*
* @param date
* @return
*/
public static Calendar getStringToCal(String date) {
final String year = date.substring(0, 4);
final String month = date.substring(5, 7);
final String day = date.substring(8, 10);
final String hour = date.substring(11, 13);
final String minute = date.substring(14, 16);
final String second = date.substring(17, 19);
final int millisecond = Integer.valueOf(date.substring(20, 23));
Calendar result = new GregorianCalendar(Integer.valueOf(year), Integer.valueOf(month) - 1, Integer.valueOf(day),
Integer.valueOf(hour), Integer.valueOf(minute), Integer.valueOf(second));
result.set(Calendar.MILLISECOND, millisecond);
result.setTimeZone(TimeZone.getTimeZone("Etc/UTC"));
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();
// }
// SendMailUtil.sendMessage("949131080@qq.com", url, "金融");
}
/**
* 推送
*
* @param start
* @param end
* @return
*/
public List<NewsResult> pushByKey(Date start, Date end,List<String> sources) {
log.info("开始执行检索");
List<NewsResult> result = new ArrayList<>();
List<NewsResult> lists = new ArrayList<>();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
Calendar startTime = Calendar.getInstance();
startTime.setTime(start);
startTime.add(Calendar.HOUR, -8);
Calendar endTime = Calendar.getInstance();
endTime.setTime(end);
endTime.add(Calendar.HOUR, -8);
System.out.println("===============");
int startHour=startTime.get(Calendar.HOUR_OF_DAY);
int endHour=endTime.get(Calendar.HOUR_OF_DAY);
System.out.println();
System.out.println(sdf.format(startTime.getTime()) + "T"
+ (startHour>10?startHour:"0"+startHour)
+ ":00:00.000Z");
System.out.println(sdf.format(endTime.getTime()) + "T"
+ (endHour>10?endHour:"0"+endHour)
+ ":00:00.000Z");
System.out.println("===============");
try {
log.info("推送检索开始");
Client esClient = ESClient.getInstance();
List<String> keys = new ReadExcel()
.getExcel(ESUtil.class.getClassLoader().getResource("pushFiles/pushkey.xls").getPath());
for (String key : keys) {
// 搜索数据
SearchRequestBuilder srb = esClient.prepareSearch(indexName).setTypes(type);
BoolQueryBuilder bb = new BoolQueryBuilder();
QueryBuilder matchQuery = QueryBuilders.termQuery("content", key);
bb.should(matchQuery);
srb.setQuery(bb);
srb.setPostFilter(QueryBuilders.rangeQuery("time")
.gte(sdf.format(startTime.getTime()) + "T"
+ (startHour>10?startHour:"0"+startHour)
+ ":00:00.000Z")
.lte(sdf.format(endTime.getTime()) + "T"
+ (endHour>10?endHour:"0"+endHour)
+ ":00:00.000Z"));
srb.setSize(200);
SearchResponse response = srb.execute().actionGet();
SearchHits searchHits = response.getHits();
for (SearchHit hit : searchHits.getHits()) {
Map<String, Object> map = hit.getSource();
NewsResult n = new NewsResult();
String url = hit.getSource().get("url") != null ? String.valueOf(hit.getSource().get("url"))
: String.valueOf(hit.getId());
n.setUrl(url);
n.setTitle(String.valueOf(map.get("title")));
SimpleDateFormat myFmt = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
try {
Calendar cal = getStringToCal(map.get("time").toString());
n.setTime(myFmt.format(cal.getTime()));
} catch (Exception e) {
n.setTime("");
}
n.setSource(String.valueOf(map.get("source")));
result.add(n);
}
}
log.info("金融结束");
} catch (Exception e) {
log.error("es检索出错,错误信息【{}】", e);
}
for (String source : sources) {
for (NewsResult news : result) {
if (news.getSource().contains(source)) {
lists.add(news);
}
}
}
result = new ArrayList<>();
String str = "";
for (NewsResult news : lists) {
if (str.contains(news.getTitle())) {
} else {
str += news.getTitle() + ",";
result.add(news);
}
}
// List<String> reduce = excelUtil
// .getExcel(ESUtil.class.getClassLoader().getResource("files/reduceIndex.xls").getPath());
// List<String> fm =
// excelUtil.getExcel(ESUtil.class.getClassLoader().getResource("files/fmindex.xls").getPath());
// for (NewsResult news : lists) {
// boolean b = false;
// String title = news.getTitle();
// for (String rt : reduce) {
// if (StringUtil.replaceMis(title).contains(rt)) {
// b = true;
// break;
// }
// }
// if (b) {
// continue;
// }
// b = true;
// for (String f : fm) {
// if (title.contains(f)) {
// b = false;
// break;
// }
// }
// if (b) {
// continue;
// }
// result.add(news);
// }
return result;
}
}
package com.zhiwei.finance;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.stereotype.Component;
import com.zhiwei.orm.BeanFactory;
import com.zhiwei.service.Services;
import com.zhiwei.util.ExcelUtil;
import com.zhiwei.util.MongoConnection;
import com.zhiwei.util.ReadExcel;
import com.zhiwei.util.StringUtil;
import com.zw.entity.NewsResult;
import sendmail.SendMailUtil;
@Component
public class PushFinanceByTime extends Thread {
private static final Log log = LogFactory.getLog(PushFinanceByTime.class);
private static final MongoConnection con=new MongoConnection();
public PushFinanceByTime() {
this.start();
}
public void run() {
Services service=BeanFactory.getBean(Services.class);
if(!StringUtil.isEmpty(service.getPath("longSource"))) {
}
List<String> sources = new ReadExcel()
.getExcel(ESUtil.class.getClassLoader().getResource("pushFiles/pushSource.xls").getPath());
while (true) {
log.info("推送检测");
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);
String url = PushFinanceByTime.class.getClassLoader().getResource("/").getPath() + "/"
+ (int) (Math.random() * 5000) + "sends.xls";
cal.add(Calendar.HOUR_OF_DAY, 16);
sendsEmail(cal, list, url);
sleep(1000 * 60 * 60);
} else if (cal.get(Calendar.HOUR_OF_DAY) == 11) {
cal.add(Calendar.HOUR_OF_DAY, -3);
List<NewsResult> list = new ESUtil().pushByKey(cal.getTime(), new Date(), sources);
String url = PushFinanceByTime.class.getClassLoader().getResource("/").getPath() + "/"
+ (int) (Math.random() * 5000) + "sends.xls";
cal.add(Calendar.HOUR_OF_DAY, 3);
sendsEmail(cal, list, url);
sleep(1000 * 60 * 60);
}
if (cal.get(Calendar.DAY_OF_WEEK) == 1 || cal.get(Calendar.DAY_OF_WEEK) == 7) {
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);
String url = PushFinanceByTime.class.getClassLoader().getResource("/").getPath() + "/"
+ (int) (Math.random() * 5000) + "sends.xls";
cal.add(Calendar.HOUR_OF_DAY, 5);
sendsEmail(cal, list, url);
sleep(1000 * 60 * 60);
}
}
sleep(1000 * 60 * 5);
} catch (Exception e) {
log.error("推送错误信息", e);
}
}
}
private void sendsEmail(Calendar cal, List<NewsResult> list, String url) throws Exception {
new ExcelUtil().pushDataWithFinance(list, cal.getTime(), url);
SendMailUtil.sendMessage("949131080@qq.com", url, "金融");
SendMailUtil.sendMessage("yuhualong@zhiweidata.com", url, "金融");
SendMailUtil.sendMessage("ligaodie@zhiweidata.com", url, "金融");
ExcelUtil.delete(url);
}
}
package com.zhiwei.finance;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.stereotype.Component;
import com.zhiwei.util.ExcelUtil;
import com.zhiwei.util.ReadExcel;
import com.zw.entity.NewsResult;
import sendmail.SendMailUtil;
@Component
public class PushFinanceByTimeLess extends Thread {
private static final Log log = LogFactory.getLog(PushFinanceByTimeLess.class);
public PushFinanceByTimeLess() {
this.start();
}
public void run() {
List<String> sources = new ReadExcel()
.getExcel(ESUtil.class.getClassLoader().getResource("pushFiles/pushFinanceless.xls").getPath());
while (true) {
log.info("推送检测");
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);
String url = PushFinanceByTimeLess.class.getClassLoader().getResource("/").getPath() + "/"
+ (int) (Math.random() * 5000) + "sends.xls";
cal.add(Calendar.HOUR_OF_DAY, 16);
sendsEmail(cal, list, url);
sleep(1000 * 60 * 60);
} else if (cal.get(Calendar.HOUR_OF_DAY) == 11) {
cal.add(Calendar.HOUR_OF_DAY, -3);
List<NewsResult> list = new ESUtil().pushByKey(cal.getTime(), new Date(), sources);
String url = PushFinanceByTimeLess.class.getClassLoader().getResource("/").getPath() + "/"
+ (int) (Math.random() * 5000) + "sends.xls";
cal.add(Calendar.HOUR_OF_DAY, 3);
sendsEmail(cal, list, url);
sleep(1000 * 60 * 60);
}
if (cal.get(Calendar.DAY_OF_WEEK) == 1 || cal.get(Calendar.DAY_OF_WEEK) == 7) {
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);
String url = PushFinanceByTimeLess.class.getClassLoader().getResource("/").getPath() + "/"
+ (int) (Math.random() * 5000) + "sends.xls";
cal.add(Calendar.HOUR_OF_DAY, 5);
sendsEmail(cal, list, url);
sleep(1000 * 60 * 60);
}
}
sleep(1000 * 60 * 5);
} catch (Exception e) {
log.error("推送错误信息", e);
}
}
}
private void sendsEmail(Calendar cal, List<NewsResult> list, String url) throws Exception {
new ExcelUtil().pushDataWithFinance(list, cal.getTime(), url);
SendMailUtil.sendMessage("949131080@qq.com", url, "金融");
SendMailUtil.sendMessage("yuhualong@zhiweidata.com", url, "金融");
SendMailUtil.sendMessage("ligaodie@zhiweidata.com", url, "金融");
ExcelUtil.delete(url);
}
}
package com.zhiwei.finance;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintStream;
import java.net.URL;
import java.net.URLConnection;
import java.text.ParseException;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import net.sf.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.zhiwei.util.JsonToObject;
import com.zw.entity.NewsResult;
import com.zw.entity.UserInfo;
import weixin.popular.api.MessageAPI;
import weixin.popular.api.TokenAPI;
import weixin.popular.api.UserAPI;
import weixin.popular.bean.message.templatemessage.TemplateMessage;
import weixin.popular.bean.message.templatemessage.TemplateMessageItem;
import weixin.popular.bean.message.templatemessage.TemplateMessageResult;
import weixin.popular.bean.token.Token;
import weixin.popular.bean.user.Group;
public class WeixinSend {
private static final Logger log = LoggerFactory.getLogger(WeixinSend.class);
private static Token token;
public WeixinSend(String appId, String appSecret) {
token = TokenAPI.token(appId, appSecret);
}
public synchronized void sendUseTemp(String temp_id, NewsResult news, List<String> openids) {
String access_token = JsonToObject.getToken();
for (String openid : openids) {
TemplateMessage templateMessage = new TemplateMessage();
templateMessage.setTemplate_id(temp_id);
templateMessage.setUrl(news.getUrl());
LinkedHashMap<String, TemplateMessageItem> datamap = new LinkedHashMap<>();
datamap.put("first", new TemplateMessageItem(news.getTime()+"|"+news.getSource()+"|"+"关联:"+news.getShortName(), "RED"));
datamap.put("keyword1", new TemplateMessageItem(" 标题:" + news.getTitle(), null));
datamap.put("keyword2", new TemplateMessageItem(news.getContent(), null));
templateMessage.setTouser(openid);
templateMessage.setData(datamap);
TemplateMessageResult result = MessageAPI.messageTemplateSend(access_token, templateMessage);
if ((result.getErrmsg() == null) || (!"ok".equals(result.getErrmsg()))) {
log.debug("发送触发消息失败," + result.getErrmsg());
}
try {
Thread.sleep(50L);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
public synchronized void sendUseTemp(String temp_id, NewsResult news, String openid) {
String access_token = JsonToObject.getToken();
TemplateMessage templateMessage = new TemplateMessage();
templateMessage.setTemplate_id(temp_id);
templateMessage.setUrl(news.getUrl());
LinkedHashMap<String, TemplateMessageItem> datamap = new LinkedHashMap<>();
datamap.put("first", new TemplateMessageItem("", null));
datamap.put("keyword1", new TemplateMessageItem(" 标题:" + news.getTitle(), null));
datamap.put("keyword2", new TemplateMessageItem(news.getContent() + "\n" + news.getTime()+"|"+news.getSource()+"|"+"关联:"+news.getShortName(), null));
templateMessage.setTouser(openid);
templateMessage.setData(datamap);
TemplateMessageResult result = MessageAPI.messageTemplateSend(access_token, templateMessage);
if ((result.getErrmsg() == null) || (!"ok".equals(result.getErrmsg()))) {
log.debug("发送触发消息失败," + result.getErrmsg());
}
try {
Thread.sleep(50L);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
public List<String> getOpenid(String access_token, String idNum) {
List<String> list = new ArrayList<>();
String[] openid = null;
try {
String result = "";
BufferedReader in = null;
URL url = new URL(
"https://api.weixin.qq.com/cgi-bin/user/get?access_token=" + access_token + "&next_openid");
URLConnection connection = url.openConnection();
connection.connect();
in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
String line;
while ((line = in.readLine()) != null) {
result = result + line;
}
JSONObject jsonObject = JSONObject.fromObject(result);
String data = jsonObject.getString("data");
log.debug(result);
String[] info = data.split(":");
openid = info[1].replace("[", "").replace("]", "").replace("}", "").split(",");
String[] arrayOfString1 = openid;
int i = arrayOfString1.length;
int j = 0;
if (j < i) {
String o = arrayOfString1[j];
o = o.replace("\"", "");
Group gorp = UserAPI.groupsGetid(access_token, o.replace("\"", ""));
if (idNum.equals(String.valueOf(gorp.getGroupid()))) {
list.add(o);
}
}
} catch (Exception e) {
e.printStackTrace();
}
return list;
}
public List<String> getOpenid(String access_token) {
List<String> list = new ArrayList<>();
String[] openid = null;
try {
String result = "";
BufferedReader in = null;
URL url = new URL(
"https://api.weixin.qq.com/cgi-bin/user/get?access_token=" + access_token + "&next_openid");
URLConnection connection = url.openConnection();
connection.connect();
in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
String line;
while ((line = in.readLine()) != null) {
result = result + line;
}
JSONObject jsonObject = JSONObject.fromObject(result);
String data = jsonObject.getString("data");
log.debug(result);
String[] info = data.split(":");
openid = info[1].replace("[", "").replace("]", "").replace("}", "").split(",");
for (String o : openid) {
o = o.replace("\"", "");
list.add(o);
}
} catch (Exception e) {
log.info("openid获取失败 ");
}
return list;
}
public UserInfo getUserMessage(String access_token, String openid) {
UserInfo user = new UserInfo();
try {
String result = "";
BufferedReader in = null;
URL url = new URL("https://api.weixin.qq.com/cgi-bin/user/info?access_token=" + access_token + "&openid="
+ openid + "&lang=zh_CN");
URLConnection connection = url.openConnection();
connection.connect();
in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
String line;
while ((line = in.readLine()) != null) {
result = result + line;
}
JSONObject jsonObject = JSONObject.fromObject(result);
log.debug(jsonObject.toString());
System.out.println(jsonObject);
try {
user.setSubscribe(jsonObject.getString("subscribe"));
user.setOpenid(jsonObject.getString("openid"));
user.setNickname(jsonObject.getString("nickname"));
user.setSex(jsonObject.getString("sex"));
user.setLanguage(jsonObject.getString("language"));
user.setCity(jsonObject.getString("city"));
user.setProvince(jsonObject.getString("province"));
user.setCountry(jsonObject.getString("country"));
user.setHeadimgurl(jsonObject.getString("headimgurl"));
user.setSubscribe_time(jsonObject.getString("subscribe_time"));
user.setRemark(jsonObject.getString("remark"));
user.setGroupid(jsonObject.getString("groupid"));
user.setTagid_list(jsonObject.getString("tagid_list"));
} catch (Exception e) {
}
} catch (IOException e) {
e.printStackTrace();
}
return user;
}
public static void main(String[] args) throws ParseException {
WeixinSend w = new WeixinSend("wx92c35fbf3a418be8", "474e30858801615f0edf61215ea24305");
w.sendUseTemp("2jWpk0N1CC-fQQdJnXJQuc2WOh7yh_Ozn0-T0K9mExQ", new NewsResult(), new ArrayList<>());
}
}
/**
* Copyright © 2017宁波知微瑞驰信息科技有限公司. All rights reserved.
* @Title: SpringContextListener.java
* @Package com.zhiwei.stock.listener
* @author 0xFF
* @date 2017年3月18日 上午9:46:10
*/
package com.zhiwei.listener;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import org.springframework.web.context.WebApplicationContext;
import org.springframework.web.context.support.WebApplicationContextUtils;
import com.zhiwei.orm.BeanFactory;
/**
* @ClassName: SpringContextListener
* @Description: 获取spring初始化上下文,用来构建对象
* @author 0xFF
* @date 2017年3月18日 上午9:46:10
*/
public class SpringContextListener implements ServletContextListener {
@Override
public void contextDestroyed(ServletContextEvent contentEvent) {}
@Override
public void contextInitialized(ServletContextEvent contentEvent) {
WebApplicationContext content = WebApplicationContextUtils.getWebApplicationContext(contentEvent.getServletContext());
BeanFactory.setSpringContent(content);
}
}
/**
* Copyright © 2017宁波知微瑞驰信息科技有限公司. All rights reserved.
* @Title: BeanFactory.java
* @Package com.zhiwei.stock.orm
* @author 0xFF
* @date 2017年3月18日 上午10:01:17
*/
package com.zhiwei.orm;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.context.WebApplicationContext;
import com.zhiwei.util.Tools;
/**
* @ClassName: BeanFactory
* @Description: Spring托管的Bean对象的创建工厂
* @author 0xFF
* @date 2017年3月18日 上午10:01:17
*/
public class BeanFactory {
private static final Logger log = LoggerFactory.getLogger(BeanFactory.class);
private static WebApplicationContext springContext;
/**
* 设置Spring上下文
* @param content
* @return void
*/
public static void setSpringContent(WebApplicationContext content) {
springContext = content;
}
/**
* 根据类获取Bean对象
* @param clazz
* @return T
*/
public static <T> T getBean(Class<T> clazz) {
T result = null;
if(clazz != null) {
waitUntilInitialized();
result = springContext.getBean(clazz);
}
return result;
}
/**
* 根据bean名字获取Bean对象
* @param beanName
* @return Object
*/
public static Object getBean(String beanName) {
Object result = null;
if(beanName != null) {
waitUntilInitialized();
result = springContext.getBean(beanName);
}
return result;
}
/**
* 等待Spring上下文初始化
* @Title waitUntilInitialized
* @return void
*/
private static void waitUntilInitialized() {
if(springContext == null) {
boolean print = false;
while(springContext == null) {
if(!print) {
log.info("等待BeanFactory初始化...");
print = true;
}
Tools.sleep(1);
}
if(print) {
log.info("BeanFactory初始化完毕,退出等待");
}
}
}
}
package com.zhiwei.service;
import java.util.ArrayList;
import java.util.List;
import org.bson.Document;
import org.springframework.stereotype.Service;
import com.zhiwei.util.MongoConnection;
import com.zw.entity.ExcelsUrl;
@Service
public class Services {
private static MongoConnection con = new MongoConnection();
public List<ExcelsUrl> findAll() {
List<Document> list = con.find("financePush", "excelPath");
List<ExcelsUrl> result = new ArrayList<>();
for (Document doc : list) {
ExcelsUrl eUrl = new ExcelsUrl();
eUrl.setName(doc.getString("name"));
eUrl.setUrl(doc.getString("url"));
switch (doc.getString("name")) {
case "key":eUrl.setGo("http://192.168.0.245:8080/change4weixin/finance/upExcel");;
case "longSource":eUrl.setGo("http://192.168.0.245:8080/change4weixin/finance/upExcel");
case "lessSource":eUrl.setGo("http://192.168.0.245:8080/change4weixin/finance/upExcel");
}
result.add(eUrl);
}
return result;
}
public void insert(ExcelsUrl eUrl) {
Document doc = new Document();
doc.append("name", eUrl.getName());
doc.append("url", eUrl.getUrl());
con.insertDb("financePush", "excelPath", doc);
}
public String getPath(String name) {
return con.findOne("financePush", "excelPath", name);
}
}
package com.zhiwei.servlet;
import java.text.SimpleDateFormat;
import java.util.Date;
import javax.annotation.Resource;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;
import com.alibaba.fastjson.JSON;
import com.zhiwei.service.Services;
import com.zhiwei.util.Config;
import com.zhiwei.util.ExcelUtil;
import com.zhiwei.util.StringUtil;
import com.zw.entity.ExcelsUrl;
@Controller
@RequestMapping("/finance")
public class FianceController {
@Resource
private Services service;
private static final Log log = LogFactory.getLog(FianceController.class);
private SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
@RequestMapping(value = "/upExcel")
public String upFinance() {
return "showfinance";
}
@RequestMapping(value = "/upFinanceKey")
public String upFinanceKey(MultipartFile file) {
String fileName = file.getOriginalFilename();
if (fileName.endsWith(".xls") || fileName.endsWith(".xlsx")) {// 是否是excel结尾的
String path = Config.getVal("timefileUrl") + "/" + sdf.format(new Date()) + fileName;
log.info(path);
String beforeUrl=service.getPath("key");
if(!StringUtil.isEmpty(beforeUrl)) {
ExcelUtil.delete(beforeUrl);
}
ExcelsUrl eUrl = new ExcelsUrl();
eUrl.setName("key");
eUrl.setUrl(path);
service.insert(eUrl);
} else {
return "";
}
return "upExcelWithFinance";
}
@RequestMapping(value = "/upFinanceLong")
public String upFinanceLong(MultipartFile file) {
String fileName = file.getOriginalFilename();
if (fileName.endsWith(".xls") || fileName.endsWith(".xlsx")) {// 是否是excel结尾的
String path = Config.getVal("timefileUrl") + "/" + sdf.format(new Date()) + fileName;
log.info(path);
String beforeUrl=service.getPath("longSource");
if(!StringUtil.isEmpty(beforeUrl)) {
ExcelUtil.delete(beforeUrl);
}
ExcelsUrl eUrl = new ExcelsUrl();
eUrl.setName("longSource");
eUrl.setUrl(path);
service.insert(eUrl);
} else {
return "";
}
return "upExcelWithFinance";
}
@RequestMapping(value = "/upFinanceLess")
public String upFinanceLess(MultipartFile file) {
String fileName = file.getOriginalFilename();
if (fileName.endsWith(".xls") || fileName.endsWith(".xlsx")) {// 是否是excel结尾的
String path = Config.getVal("timefileUrl") + "/" + sdf.format(new Date()) + fileName;
log.info(path);
String beforeUrl=service.getPath("lessSource");
if(!StringUtil.isEmpty(beforeUrl)) {
ExcelUtil.delete(beforeUrl);
}
ExcelsUrl eUrl = new ExcelsUrl();
eUrl.setName("lessSource");
eUrl.setUrl(path);
service.insert(eUrl);
} else {
return "excelError";
}
return "upExcelWithFinance";
}
@RequestMapping(value="/getAll")
@ResponseBody
public String getAll() {
return JSON.toJSONString(service.findAll());
}
}
......@@ -32,9 +32,7 @@ import org.springframework.web.multipart.MultipartFile;
import com.alibaba.fastjson.JSON;
import com.zhiwei.chendong.ExcelReadAndWrite;
import com.zhiwei.chendong.ReaderExcel;
import com.zhiwei.entity.Zhihu;
import com.zhiwei.util.Config;
import com.zhiwei.util.Craw;
import com.zw.entity.Excels;
import com.zw.entity.Weixin;
......@@ -250,69 +248,12 @@ public class MainController {
return "error3";
}
@RequestMapping(value = "/zhup", produces = "application/json;charset=utf-8")
public String getScan(String mail, MultipartFile file, String start, String end) {
String fileName = file.getOriginalFilename();
String path = "C:\\Users\\Administrator\\Desktop/" + "/" + fileName;
log.info(path);
File targetFile = new File(path);
if (!targetFile.exists()) {
targetFile.mkdirs();
}
// 保存
try {
file.transferTo(targetFile);
} catch (Exception e) {
e.printStackTrace();
}
List<String> urls = new ArrayList<>();
try {
urls = ReaderExcel.getZhUrls(path);
} catch (IOException e1) {
e1.printStackTrace();
}
Craw any = new Craw();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
try {
SocketAddress addr = new InetSocketAddress("120.237.55.23", 8888);
Proxy proxy = new Proxy(Proxy.Type.HTTP, addr);
List<Zhihu> list = any.getQuestionAndAnswerByUrl(urls, proxy, 50, sdf.parse(start), sdf.parse(end), "",
mail);
ExcelReadAndWrite.writeZhihu(list, mail);
} catch (Exception e) {
e.printStackTrace();
}
ExcelReadAndWrite.delete(path);
return "zhihu";
}
@RequestMapping(value = "/zhNum", produces = "application/json;charset=utf-8")
@ResponseBody
public String getzhNum() {
return JSON.toJSONString(map);
}
public static void main(String[] args) throws Exception {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
Date st = new Date();
st.setDate(st.getDate() - 2);
List<String> urls = new ArrayList<>();
urls.add("https://www.zhihu.com/question/268337678");
SocketAddress addr = new InetSocketAddress("120.237.55.23", 8888);
Proxy proxy = new Proxy(Proxy.Type.HTTP, addr);
Craw any = new Craw();
// urls = new ArrayList<>();
// try {
// urls = ReaderExcel.getZhUrls("C:\\Users\\Administrator\\Desktop/知乎(2).xlsx");
// } catch (IOException e1) {
// e1.printStackTrace();
// }
List<Zhihu> list = any.getQuestionAndAnswerByUrl(urls, null, 50, sdf.parse("2018-03-07 16:00"),
sdf.parse("2018-03-08 16:00"), "", "");
for (Zhihu l : list) {
System.out.println(l);
}
ExcelReadAndWrite.writeZhihu(list, "949131080@qq.com");
}
@RequestMapping("/zh")
public String zh() {
......
package com.zhiwei.util;
import java.io.UnsupportedEncodingException;
import java.util.Arrays;
import javax.crypto.Cipher;
import javax.crypto.spec.IvParameterSpec;
import javax.crypto.spec.SecretKeySpec;
public class AESUtils {
public static String encrypt(String secret, String value) {
SecretKeySpec keySpec = getKey(secret);
IvParameterSpec iv = new IvParameterSpec("0102030405060708".getBytes());
try {
Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
cipher.init(1, keySpec, iv);
byte[] encrypted = cipher.doFinal(value.getBytes("UTF-8"));
return parseByte2HexStr(encrypted);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
public static String decrypt(String secret, String value) {
SecretKeySpec keySpec = getKey(secret);
IvParameterSpec iv = new IvParameterSpec("0102030405060708".getBytes());
try {
Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
cipher.init(2, keySpec, iv);
byte[] encrypted1 = parseHexStr2Byte(value);
byte[] original = cipher.doFinal(encrypted1);
return new String(original, "UTF-8");
} catch (Exception e) {
throw new RuntimeException(e);
}
}
private static SecretKeySpec getKey(String secret) {
try {
byte[] bytes = secret.getBytes("UTF-8");
return new SecretKeySpec(Arrays.copyOf(bytes, 16), "AES");
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
return null;
}
public static String parseByte2HexStr(byte[] buf) {
StringBuffer sb = new StringBuffer();
for (int i = 0; i < buf.length; i++) {
String hex = Integer.toHexString(buf[i] & 0xFF);
if (hex.length() == 1) {
hex = '0' + hex;
}
sb.append(hex.toUpperCase());
}
return sb.toString();
}
public static byte[] parseHexStr2Byte(String hexStr) {
if (hexStr.length() < 1) {
return null;
}
byte[] result = new byte[hexStr.length() / 2];
for (int i = 0; i < hexStr.length() / 2; i++) {
int high = Integer.parseInt(hexStr.substring(i * 2, i * 2 + 1), 16);
int low = Integer.parseInt(hexStr.substring(i * 2 + 1, i * 2 + 2), 16);
result[i] = ((byte) (high * 16 + low));
}
return result;
}
}
package com.zhiwei.util;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.InetSocketAddress;
import java.net.Proxy;
import java.net.Proxy.Type;
import java.net.SocketAddress;
import java.net.URL;
import java.net.URLConnection;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import java.util.Locale;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import com.jayway.jsonpath.JsonPath;
import com.zhiwei.entity.Zhihu;
import com.zhiwei.servlet.MainController;
public class Craw {
static List<String> ips = new ArrayList<>();
static int nums = 0;
static {
ips.add("80.211.190.76:3128");
ips.add("187.32.172.65:3128");
ips.add("80.211.162.17:8888");
ips.add("80.211.11.229:80");
}
public static void craw() {
}
public synchronized List<Zhihu> getQuestionAndAnswerByUrl(List<String> list, Proxy proxy, int num, Date start,
Date end, String cookie, String mail) {
List<Zhihu> zhList = new ArrayList<Zhihu>();
int nowRun = 1;
for (String ul : list) {
MainController.map.put(mail, nowRun++);
try {
Thread.sleep(3000);
} catch (InterruptedException e1) {
e1.printStackTrace();
}
try {
int ns = 0;
String title = "";
try {
BufferedReader in_0 = null;
URL url_0;
String result_0 = "";
url_0 = new URL(ul);
URLConnection con = null;
// if (proxy == null) {
con = url_0.openConnection();
// } else {
Proxy p = new Proxy(Type.HTTP, new InetSocketAddress(ips.get(nums % ips.size()).split(":")[0],
Integer.valueOf(ips.get(nums % ips.size()).split(":")[1])));
nums++;
// con = url_0.openConnection(p);
// }
con.setConnectTimeout(6000);
con.setRequestProperty("User-Agent",
"Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36");
con.setRequestProperty("Cookie", cookie);
con.setRequestProperty("authorization", "oauth c3cef7c66a1843f8b3a9e6a1e3160e20");
in_0 = new BufferedReader(new InputStreamReader(con.getInputStream()));
String line;
while ((line = in_0.readLine()) != null) {
result_0 += line + "\n";
}
Document doc = Jsoup.parse(result_0);
Element e = doc.select("title").first();
title = e.ownText();
} catch (Exception eee) {
System.out.println(eee.getMessage());
}
ul = ul.replace("question", "questions");
ul = ul.replace("http://www.zhihu.com", "").replace("https://www.zhihu.com", "");
int tip = 0;
while (true) {
int bean = zhList.size();
BufferedReader in = null;
URL url;
String result = "";
System.out.println(ul);
try {
url = new URL("https://www.zhihu.com/api/v4" + ul
+ "/answers?include=data%5B*%5D.is_normal%2Cadmin_closed_comment%2Creward_info%2Cis_collapsed%2Cannotation_action%2Cannotation_detail%2Ccollapse_reason%2Cis_sticky%2Ccollapsed_by%2Csuggest_edit%2Ccomment_count%2Ccan_comment%2Ccontent%2Ceditable_content%2Cvoteup_count%2Creshipment_settings%2Ccomment_permission%2Ccreated_time%2Cupdated_time%2Creview_info%2Cquestion%2Cexcerpt%2Crelationship.is_authorized%2Cis_author%2Cvoting%2Cis_thanked%2Cis_nothelp%2Cupvoted_followees%3Bdata%5B*%5D.mark_infos%5B*%5D.url%3Bdata%5B*%5D.author.follower_count%2Cbadge%5B%3F(type%3Dbest_answerer)%5D.topics&offset="
+ ns + "&limit=20&sort_by=created");
URLConnection conn = null;
// if (proxy == null) {
conn = url.openConnection();
// } else {
Proxy p = new Proxy(Type.HTTP, new InetSocketAddress(ips.get(nums % ips.size()).split(":")[0],
Integer.valueOf(ips.get(nums % ips.size()).split(":")[1])));
nums++;
// conn = url.openConnection(p);
// }
conn.setConnectTimeout(6000);
conn.setRequestProperty("User-Agent",
"Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36");
conn.setRequestProperty("Cookie", cookie);
conn.setRequestProperty("X-Za-Experiment",
"ge3:ge3_10,ge2:ge2_1,search_section_style:loosen,android_pass_through_push:all,new_more:new,nwebQAGrowth:experiment,nweb_feed_ad:experiment,qaweb_related_readings_content_control:open,market_tab_banner:market_tab_banner_show,live_store:ls_a2_b1_c1_f1,qaweb_thumbnail_abtest:new,nweb_search:nweb_search_heifetz,recommend_ebook_ac:ebook_old,enable_vote_down_reason_menu:enable,show_video_upload_attention:true,is_office:false,enable_tts_play:post,new_question_diversion:true,recom_answer_rec:recom_answer_ratio,wechat_share_modal:wechat_share_modal_show,new_live_feed_mediacard:old,nweb_feed_ui:expand,search_hybrid_tabs:without-tabs,hybrid_zhmore_video:no,recommend_live_guess_like:live_guess_es,nweb_growth_people:default,qrcode_login:qrcode,is_show_unicom_free_entry:unicom_free_entry_off,new_mobile_column_appheader:new_header,android_db_comment_with_repin_record:open,feed_hybrid_topic_recom_button_icon:yes,android_db_recommend_action:open,zcm-lighting:zcm,android_db_feed_hash_tag_style:button,app_store_rate_dialog:close,recommend_question:rec_question_old,top_weight_search:new_top_search,default:None,recommendation_abtest:new,is_new_noti_panel:no,android_db_repin_selection:open,nweb_related_advert:default,android_profile_panel:panel_b,nweb_write_answer:experiment,recommend_live_detail:live_detail_no_rerank_v2");
conn.setRequestProperty("X-Req-SSL", "proto=TLSv1.2,sni=,cipher=ECDHE-RSA-AES256-GCM-SHA384");
conn.setRequestProperty("authorization", "oauth c3cef7c66a1843f8b3a9e6a1e3160e20");
in = new BufferedReader(new InputStreamReader(conn.getInputStream()));
String line;
while ((line = in.readLine()) != null) {
result += line + "\n";
}
List<Object> json = JsonPath.read(result, "$.data.*");
Calendar cal = Calendar.getInstance();
for (Object obj : json) {
Matcher m = Pattern.compile(", content=(.+),").matcher(obj.toString());
String content = "";
if (m.find()) {
content = m.group(1);
content = content.split(",")[0];
}
Matcher m2 = Pattern.compile(", id=(.+), voteup").matcher(obj.toString());
String id = "";
if (m2.find()) {
id = m2.group(1);
}
String name = "";
String userUrl = "";
Matcher m4 = Pattern.compile(", name=(.+), is_").matcher(obj.toString());
if (m4.find()) {
name = m4.group(1);
name = name.split(",")[0];
if (name.equals("匿名用户")) {
} else {
Matcher m5 = Pattern.compile("url_token=(.+),").matcher(obj.toString());
if (m5.find()) {
userUrl = m5.group(1);
userUrl = userUrl.split(",")[0];
}
}
}
Matcher m5 = Pattern.compile("url_token=(.+), id").matcher(obj.toString());
if (m5.find()) {
userUrl = m5.group(1);
userUrl = userUrl.split(",")[0];
}
String questionId = "";
Matcher m6 = Pattern.compile("tion, id=(.+), upda").matcher(obj.toString());
if (m6.find()) {
questionId = m6.group(1);
questionId = questionId.split(",")[0];
}
String time = "";
Matcher m7 = Pattern.compile("created_time=(.+), id").matcher(obj.toString());
if (m7.find()) {
time = m7.group(1);
time = time.split(",")[0];
}
String pointLikeNumber = "0";
Matcher mn = Pattern.compile("voteup_count=(.+), col").matcher(obj.toString());
if (mn.find()) {
pointLikeNumber = mn.group(1);
pointLikeNumber = pointLikeNumber.split(",")[0];
}
String idUrl = "https://www.zhihu.com/question/" + questionId + "/answer/" + id;
Zhihu zhihu = new Zhihu();
zhihu.setContent(content.replaceAll("<[\\S\\s]+?>", ""));
zhihu.setTitle(title);
zhihu.setId(idUrl);
zhihu.setAuthor(name);
zhihu.setAuthorUrl("https://www.zhihu.com/people/" + userUrl);
zhihu.setPointLikeNumber(pointLikeNumber);
Long timestamp = Long.valueOf(time) * 1000l;
String date = new SimpleDateFormat("yyyy-MM-dd HH:mm", Locale.CHINA)
.format(new Date(timestamp));
zhihu.setTime(date);
try {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
if (sdf.parse(date).before(start) || end.before(sdf.parse(date))) {
cal.setTime(sdf.parse(date));
continue;
}
} catch (Exception e) {
e.printStackTrace();
}
zhList.add(zhihu);
}
// if (end.before(cal.getTime())) {
//
// } else {
if (zhList.size() == bean) {
break;
}
// }
ns += 20;
if (ns > num * 20) {
break;
}
} catch (Exception e) {
tip++;
if (tip > 3) {
break;
}
e.printStackTrace();
}
// Thread.sleep(500);
}
} catch (Exception e) {
e.printStackTrace();
}
}
MainController.map.remove(mail);
return zhList;
}
}
package com.zhiwei.util;
import java.net.InetAddress;
import java.net.UnknownHostException;
import org.elasticsearch.client.transport.TransportClient;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.transport.InetSocketTransportAddress;
import org.elasticsearch.transport.client.PreBuiltTransportClient;
/**
* es连接类
*
* @author shenjinzhu
*
*/
public class ESClient {
private static String esIp;
private static int esPort;
private static String clusterName;
private static class ESClientHolder {
static TransportClient client = initESClient();
private static TransportClient initESClient() {
esIp=Config.getVal("esIp");
clusterName=Config.getVal("clusterName");
esPort=Integer.valueOf(Config.getVal("esPort"));
Settings esSettings = Settings.builder().put("cluster.name", clusterName) // 设置ES实例的名称
// 自动嗅探整个集群的状态,把集群中其他ES节点的ip添加到本地的客户端列表中
.put("client.transport.sniff", false).build();
TransportClient client = new PreBuiltTransportClient(esSettings);
try {
client.addTransportAddress(new InetSocketTransportAddress(InetAddress.getByName(esIp), esPort));
} catch (UnknownHostException e) {
e.printStackTrace();
}
return client;
}
}
public static TransportClient getInstance() {
return ESClientHolder.client;
}
}
package com.zhiwei.util;
import java.io.IOException;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.TimeZone;
import org.elasticsearch.action.search.SearchRequestBuilder;
import org.elasticsearch.action.search.SearchResponse;
import org.elasticsearch.action.search.SearchType;
import org.elasticsearch.client.Client;
import org.elasticsearch.client.transport.TransportClient;
import org.elasticsearch.common.unit.TimeValue;
import org.elasticsearch.index.query.BoolQueryBuilder;
import org.elasticsearch.index.query.QueryBuilder;
import org.elasticsearch.index.query.QueryBuilders;
import org.elasticsearch.search.SearchHit;
import org.elasticsearch.search.SearchHits;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
import com.alibaba.fastjson.JSONObject;
import weixin.popular.bean.menu.selfmenu.News;
/**
* es工具类
*
* @author admin
*/
public class ESUtil {
private static final Logger log = LoggerFactory.getLogger(ESUtil.class);
private static String indexName;
private static String type;
private static String endWithTime = "T01:00:00.000Z";
static {
indexName = Config.getVal("indexName");
type = Config.getVal("type");
}
/**
* 获取匹配时起始时间
*
* @param hour
* @return
*/
public static String getTimeMin(int hour) {
SimpleDateFormat smf = new SimpleDateFormat("yyyy-MM-dd");
Date date1 = new Date();
String time = "";
if (hour == 9) {
date1.setDate(date1.getDate() - 1);
time = smf.format(date1) + "T08:00:00.000Z";
}
if (hour == 12) {
time = smf.format(date1) + "T01:00:00.000Z";
}
if (hour == 16) {
time = smf.format(date1) + "T04:00:00.000Z";
}
return time;
}
public static String getWedTimeByCj(int hour) {
SimpleDateFormat smf = new SimpleDateFormat("yyyy-MM-dd");
Date date1 = new Date();
String time = "";
date1.setDate(date1.getDate() - 1);
time = smf.format(date1) + "T08:00:00.000Z";
return time;
}
/**
* 获取匹配时终止时间
*
* @param hour
* @return
*/
public static String getTimeMax(int hour) {
SimpleDateFormat smf = new SimpleDateFormat("yyyy-MM-dd");
Date date = new Date();
String time = "";
time = smf.format(date) + "T0" + (hour - 8) + ":00:00.000Z";
return time;
}
// public List<NewsResult> getNewsForWechatWithMechanism(Date start,Date end){
// SimpleDateFormat sdf= new SimpleDateFormat("yyyy-MM-dd日HH:mm:ss");
// Calendar startTime=Calendar.getInstance();
// startTime.setTime(start);
// startTime.add(Calendar.HOUR, -8);
// Calendar endTime=Calendar.getInstance();
// endTime.setTime(end);
// endTime.add(Calendar.HOUR, -8);
// List<Mechanism> list = new ReadExcel()
// .getInstitution(SendEmail.class.getClassLoader().getResource("files/jrjg.xls").getPath());
// List<NewsResult> mechanism = new ArrayList<NewsResult>();
// try {
// log.info("金融检索开始");
// Client esClient = ESClient.getInstance();
// List<String> snByNeedFull = excelUtil
// .getOrgName(ESUtil.class.getClassLoader().getResource("files/matchOrgName.xls").getPath());
// Map<String, String> maps = new HashMap<String, String>();
// for (String sn : snByNeedFull) {// 需要全称匹配的
// maps.put(sn, "yes");
// }
// for (Mechanism scan : list) {
// // 搜索数据
// SearchRequestBuilder srb = esClient.prepareSearch(indexName).setTypes(type);
// BoolQueryBuilder bb = new BoolQueryBuilder();
// if (maps.get(scan.getShortName()) != null) {
// if (scan.getFullName() == null) {
// continue;
// }
// } else {
// QueryBuilder matchQuery = QueryBuilders.matchPhraseQuery("title", scan.getShortName());
// QueryBuilder matchQuery1 = QueryBuilders.matchPhraseQuery("content", scan.getShortName());
// bb.should(matchQuery);
// bb.should(matchQuery1);
// }
// if (scan.getFullName() != null) {
// QueryBuilder matchQuery2 = QueryBuilders.matchPhraseQuery("content", scan.getFullName());
// bb.should(matchQuery2);
// }
// srb.setQuery(bb);
// srb.setPostFilter(QueryBuilders.rangeQuery("time").gte(sdf.format(startTime.getTime()).replace("日", "T")+".000Z")
// .lte(sdf.format(endTime.getTime()).replace("日", "T")+".000Z"));
// srb.setSize(500);
// SearchResponse response = srb.execute().actionGet();
// SearchHits searchHits = response.getHits();
// for (SearchHit hit : searchHits.getHits()) {
// Map<String, Object> map = hit.getSource();
// NewsResult n = new NewsResult();
// n.setCode(scan.getCodeAndP());
// n.setShortName(scan.getShortName());
// String url = hit.getSource().get("url") != null ? String.valueOf(hit.getSource().get("url"))
// : String.valueOf(hit.getId());
// n.setUrl(url);
// n.setRsid(String.valueOf(map.get("rsid")));
// n.setTitle(String.valueOf(map.get("title")));
// n.setContent(String.valueOf(map.get("content")));
// SimpleDateFormat myFmt = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
// try {
// Calendar cal = getStringToCal(map.get("time").toString());
// Date date = new Date(cal.getTimeInMillis());
// n.setTime(myFmt.format(date));
// } catch (Exception e) {
// n.setTime("");
// }
// n.setPt(String.valueOf(map.get("pt")));
// n.setSource(String.valueOf(map.get("source")));
// n.setOrgChiName(scan.getFullName() == null ? "" : scan.getFullName());
// n.setType(scan.getType());
// mechanism.add(n);
// }
// }
// mechanism = getFmNews(mechanism);
// log.info("金融结束");
// } catch (Exception e) {
// log.error("es检索出错,错误信息【{}】", e);
// }
// return mechanism;
// }
}
package com.zhiwei.util;
import java.io.File;//引入类
import java.net.URL;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
import com.zw.entity.NewsResult;
import jxl.Workbook;
import jxl.format.Alignment;
import jxl.format.Colour;
import jxl.format.UnderlineStyle;
import jxl.format.VerticalAlignment;
import jxl.write.Label;
import jxl.write.WritableCellFormat;
import jxl.write.WritableFont;
import jxl.write.WritableHyperlink;
import jxl.write.WritableSheet;
import jxl.write.WritableWorkbook;
/**
* excel操作类
*
* @author admin
*
*/
@Component
public class ExcelUtil {
private static final Logger log = LoggerFactory.getLogger(ExcelUtil.class);
/**
* 删除文件
* @param url
* 文件的路径
*/
public static void delete(String url) {
File file = new File(url);
if (file.isFile()) {
file.delete();
}
log.info("删除完成");
}
/**
* 日匹配所有新闻数据写入excel
* @param list
* @param time
* @param fileName
* @throws Exception
*/
public void pushDataWithFinance(List<NewsResult> list, Date time, String fileName) throws Exception {
File tempFile = new File(fileName);
// 若是文件不存在就创建新文件
if (!tempFile.exists()) {
tempFile.createNewFile();
}
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
WritableWorkbook workbook = Workbook.createWorkbook(tempFile);
WritableSheet sheet = workbook.createSheet("table1", 0);
// 一些临时变量,用于写到excel中
Label l = null;
// 预定义的一些字体和格式,格式: 字形 大小 加粗 倾斜 下划线 颜色
WritableFont font1 = new WritableFont(WritableFont.ARIAL, 14, WritableFont.BOLD, false,
UnderlineStyle.NO_UNDERLINE, Colour.WHITE);
WritableFont font2 = new WritableFont(WritableFont.ARIAL, 18, WritableFont.BOLD, false,
UnderlineStyle.NO_UNDERLINE, Colour.WHITE);
WritableCellFormat MainTitle = new WritableCellFormat(font2);
MainTitle.setAlignment(Alignment.CENTRE);
MainTitle.setBackground(Colour.BLUE_GREY);
MainTitle.setVerticalAlignment(VerticalAlignment.CENTRE);
// 财新数据标题格式
WritableCellFormat mainTitle = new WritableCellFormat(font1);
mainTitle.setAlignment(Alignment.CENTRE);
mainTitle.setBackground(Colour.BLUE_GREY);
// 标题格式
WritableFont titleFont = new WritableFont(WritableFont.ARIAL, 14, WritableFont.NO_BOLD, false,
UnderlineStyle.NO_UNDERLINE, jxl.format.Colour.BLACK);
WritableCellFormat titleFormat = new WritableCellFormat(titleFont);
titleFormat.setAlignment(Alignment.CENTRE);
// 正文字体
WritableFont detFont = new WritableFont(WritableFont.ARIAL, 13, WritableFont.NO_BOLD, false,
UnderlineStyle.NO_UNDERLINE, jxl.format.Colour.BLACK);
WritableCellFormat detFormat = new WritableCellFormat(detFont);
detFormat.setVerticalAlignment(VerticalAlignment.CENTRE);
WritableFont urlf = new WritableFont(WritableFont.ARIAL, 11, WritableFont.NO_BOLD, false,
UnderlineStyle.NO_UNDERLINE, Colour.BLUE);
WritableCellFormat urlFormat = new WritableCellFormat(urlf);
urlFormat.setVerticalAlignment(VerticalAlignment.CENTRE);
int seq = 0;
seq = 0;
sheet.mergeCells(0, seq, 7, seq + 2);
l = new Label(0, seq, "金融负面新闻数据", MainTitle);
sheet.addCell(l);
// 上方3个单位合并
seq += 3;
l = new Label(0, seq, "时间");
sheet.addCell(l);
l = new Label(1, seq, sdf.format(time));
sheet.addCell(l);
sheet.mergeCells(2, seq, 4, seq);
l = new Label(2, seq, "");
sheet.addCell(l);
sheet.mergeCells(5, seq, 7, seq);
l = new Label(5, seq, "推送");
sheet.addCell(l);
seq += 2;
sheet.mergeCells(0, seq, 7, seq + 1);
l = new Label(0, seq, "概览", mainTitle);
sheet.addCell(l);
seq += 3;
seq += 3;
sheet.mergeCells(0, seq, 7, seq + 1);
l = new Label(0, seq, "", mainTitle);
sheet.addCell(l);
seq += 2;
int row = seq++;
l = new Label(0, row, "序号", titleFormat);
sheet.addCell(l);
l = new Label(1, row, "标题", titleFormat);
sheet.addCell(l);
l = new Label(2, row, "时间", titleFormat);
sheet.addCell(l);
l = new Label(3, row, "来源", titleFormat);
sheet.addCell(l);
int num = 1;
for (NewsResult news : list) {
row = seq++;
l = new Label(0, row, String.valueOf(num++), detFormat);// 序号
sheet.addCell(l);
try {
WritableHyperlink link = new WritableHyperlink(1, row, 1, row, new URL(news.getUrl()), news.getTitle());
sheet.addHyperlink(link);
} catch (Exception e) {
log.error("获取url失败,错误信息{}", e);
}
l = new Label(1, row, news.getTitle(), urlFormat);// 标题
sheet.addCell(l);
l = new Label(2, row, news.getTime(), detFormat);// 时间
sheet.addCell(l);
l = new Label(3, row, news.getSource(), detFormat);// 时间
sheet.addCell(l);
}
int column = 0;
sheet.setColumnView(column++, 10);
sheet.setColumnView(column++, 25);
sheet.setColumnView(column++, 20);
sheet.setColumnView(column++, 22);
sheet.setColumnView(column++, 22);
workbook.write();
workbook.close();
log.info("内容写入成功");
}
}
package com.zhiwei.util;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintStream;
import java.io.UnsupportedEncodingException;
import java.net.URL;
import java.net.URLConnection;
import java.net.URLEncoder;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Iterator;
import java.util.List;
import net.sf.json.JSONObject;
public class JsonToObject {
public static String getToken() {
String token = "";
String appId = "wxd1f40dde7e15845f";
String jmAppId = AESUtils.encrypt("wechat", appId);
String path = "http://yuqing.zhiweidata.com/WechatPublic/common/getToken?appId=" + jmAppId;
BufferedReader in = null;
try {
String result = "";
URL url = new URL(path);
URLConnection connection = url.openConnection();
connection.setConnectTimeout(3000);
connection.connect();
in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
String line;
while ((line = in.readLine()) != null) {
result = result + line;
}
JSONObject jsonObject = JSONObject.fromObject(result);
JSONObject inJson = JSONObject.fromObject(jsonObject.getString("data"));
token = inJson.getString("accessToken");
} catch (IOException e) {
e.printStackTrace();
} finally {
try {
in.close();
} catch (IOException e) {
e.printStackTrace();
}
}
return token;
}
public static void main(String[] args) throws UnsupportedEncodingException {
System.out.println(getToken());
}
}
package com.zhiwei.util;
import java.util.ArrayList;
import java.util.List;
import org.bson.Document;
import com.mongodb.MongoClient;
import com.mongodb.client.FindIterable;
import com.mongodb.client.MongoCollection;
import com.mongodb.client.MongoCursor;
import com.mongodb.client.MongoDatabase;
import com.mongodb.client.model.UpdateOptions;
public class MongoConnection {
private MongoClient client;
public MongoConnection() {
client = new MongoClient("192.168.0.36", 26017);
}
public MongoDatabase getdb(String dbName) {
return client.getDatabase(dbName);
}
/**
* 更新操作,若没有则插入
* @param dbName
* @param collection
* @param document
*/
public void insertDb(String dbName, String collection, Document document) {
MongoDatabase db = getdb(dbName);
MongoCollection<Document> col = db.getCollection(collection);
Document filter = new Document();
filter.append("name", document.get("name"));
Document update = new Document();
update.append("$set", new Document("url",document.get("url")));
col.updateOne(filter, update, new UpdateOptions().upsert(true));
}
/**
* 查询
* @param dbName
* @param collection
* @return
*/
public List<Document> find(String dbName, String collection) {
List<Document> list = new ArrayList<>();
MongoDatabase db = getdb(dbName);
MongoCollection<Document> col = db.getCollection(collection);
FindIterable<Document> fid = col.find();
MongoCursor<Document> cur = fid.iterator();
while (cur.hasNext()) {
list.add(cur.next());
}
cur.close();
return list;
}
/**
* 条件查询
* @param dbName
* @param collection
* @return
*/
public String findOne(String dbName, String collection,String name) {
MongoDatabase db = getdb(dbName);
MongoCollection<Document> col = db.getCollection(collection);
FindIterable<Document> fid = col.find(new Document().append("name", name));
return fid.first()==null?String.valueOf(fid.first()):"";
}
public static void main(String[] args) {
MongoConnection m=new MongoConnection();
// for(Document doc:m.find("financePush","excelPath")) {
// System.out.println(doc);
// }
}
}
package com.zhiwei.util;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.ss.usermodel.WorkbookFactory;
/**
* excel文件读取类
*
* @author Administrator
*
*/
public class ReadExcel {
private final static Log log = LogFactory.getLog(ReadExcel.class);
/**
* 噪音词的获取
*
* @param url
* @return
* @throws IOException
*/
public List<String> getExcel(String url) {
List<String> list = new ArrayList<>();
Workbook book = null;
try {
book = getExcelWorkbook(url);
} catch (IOException e) {
e.printStackTrace();
}
Sheet sheet = getSheetByNum(book, 0);
int lastRowNum = sheet.getLastRowNum();
for (int i = 1; i <= lastRowNum; i++) {
Row row = null;
row = sheet.getRow(i);
if (row != null) {
int lastCellNum = row.getLastCellNum();
Cell cell = null;
String content = "";
for (int j = 0; j < lastCellNum; j++) {
cell = row.getCell(j);
if (cell != null) {
String str = cell.getStringCellValue();
if (str != null) {
content = str;
break;
}
}
}
if (content != null)
list.add(content);
}
}
return list;
}
public static Sheet getSheetByNum(Workbook book, int number) {
Sheet sheet = null;
try {
sheet = book.getSheetAt(number);
} catch (Exception e) {
throw new RuntimeException(e.getMessage());
}
return sheet;
}
public static Workbook getExcelWorkbook(String filePath) throws IOException {
Workbook book = null;
File file = null;
FileInputStream fis = null;
try {
file = new File(filePath);
if (!file.exists()) {
throw new RuntimeException("文件不存在");
} else {
fis = new FileInputStream(file);
book = WorkbookFactory.create(fis);
}
} catch (Exception e) {
throw new RuntimeException(e.getMessage());
} finally {
if (fis != null) {
fis.close();
}
}
return book;
}
}
package com.zhiwei.util;
public class StringUtil {
public static boolean isEmpty(String str) {
return str==null||str.equals("");
}
}
package com.zhiwei.util;
/**
* Copyright © 2017宁波知微瑞驰信息科技有限公司. All rights reserved.
* @Title: Tools.java
* @Package
* @author 0xFF
* @date 2017年4月7日 上午11:11:59
*/
/**
* @ClassName: Tools
* @Description: 工具方法封装
* @author 0xFF
* @date 2017年4月7日 上午11:11:59
*/
public class Tools {
/**
* 线程等待,忽略异常
* @Title: sleep
* @param millis
* @return void
*/
public static void sleep(long millis) {
try {
Thread.sleep(millis);
} catch (InterruptedException e) {}
}
}
package com.zw.entity;
import java.io.Serializable;
import java.util.Date;
public class Excels implements Serializable {
......
package com.zw.entity;
public class ExcelsUrl {
private String url;
private String name;
private String go;
public String getGo() {
return go;
}
public void setGo(String go) {
this.go = go;
}
public String getUrl() {
return url;
}
public void setUrl(String url) {
this.url = url;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
@Override
public String toString() {
return "ExcelsUrl [url=" + url + ", name=" + name + "]";
}
}
package com.zw.entity;
import java.io.Serializable;
import java.util.Date;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
/**
* 新闻信息索引结果信息
* @author sjz
*/
@Component
@Scope("prototype")
public class NewsResult implements Serializable{
private static final long serialVersionUID = 8646767260773431431L;
/**
* 新闻地址
*/
private String url;//新闻链接
/**
* 新闻标题
*/
private String title;//新闻标题
/**
* 新闻内容
*/
private String content;//新闻内容
/**
* 新闻来源
*/
private String source;//新闻来源
/**
* rsid
*/
private String rsid;//rsid
/**
* 新闻日期
*/
private String time;//新闻日期
/**
* 新闻类型
*/
private String pt;//新闻类型
/**
* 债券统一代码
*/
private Long bondUniCode;//唯一债券
/**
* 股票统一代码
*/
private Long stkUniCode;//唯一股票
/**
* 代码
*/
private String code;//证券代码
/**
* 简称
*/
private String shortName;//股票证券简称
/**
* 关联组合
*/
private String combination;//关联组合
/**
* 关联证券
*/
private String orgSec;//关联证券
/**
* 关联机构
*/
private String OrgChiName;//关联机构
/**
* 发债人
*/
private String fzr;//excel中读取的发债人
/**
* type字段
*/
private String type;//新闻类型
/**
* 负面关键词
*/
private String keyValue;//负面关键字
/**
* 新闻类型(持仓、机构、行业等)
*/
private String key;//属于什么新闻(持仓、机构、行业)
private String mainType;
private String rootSource;
public String getRootSource() {
return rootSource;
}
public void setRootSource(String rootSource) {
this.rootSource = rootSource;
}
public String getMainType() {
return mainType;
}
public void setMainType(String mainType) {
this.mainType = mainType;
}
public String getFzr() {
return fzr;
}
public String getKey() {
return key;
}
public void setKey(String key) {
this.key = key;
}
public void setFzr(String fzr) {
this.fzr = fzr;
}
public String getKeyValue() {
return keyValue;
}
public void setKeyValue(String keyValue) {
this.keyValue = keyValue;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public String getUrl() {
return url;
}
public void setUrl(String url) {
this.url = url;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getContent() {
return content;
}
public void setContent(String content) {
this.content = content;
}
public String getSource() {
return source;
}
public void setSource(String source) {
this.source = source;
}
public String getRsid() {
return rsid;
}
public void setRsid(String rsid) {
this.rsid = rsid;
}
public String getTime() {
return time;
}
public void setTime(String time) {
this.time = time;
}
public String getPt() {
return pt;
}
public void setPt(String pt) {
this.pt = pt;
}
public String getShortName() {
return shortName;
}
public void setShortName(String shortName) {
this.shortName = shortName;
}
public String getCombination() {
return combination;
}
public void setCombination(String combination) {
this.combination = combination;
}
public String getOrgSec() {
return orgSec;
}
public void setOrgSec(String orgSec) {
this.orgSec = orgSec;
}
public String getOrgChiName() {
return OrgChiName;
}
public void setOrgChiName(String orgChiName) {
OrgChiName = orgChiName;
}
public static long getSerialversionuid() {
return serialVersionUID;
}
public Long getBondUniCode() {
return bondUniCode;
}
public void setBondUniCode(Long bondUniCode) {
this.bondUniCode = bondUniCode;
}
public Long getStkUniCode() {
return stkUniCode;
}
public void setStkUniCode(Long stkUniCode) {
this.stkUniCode = stkUniCode;
}
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
@Override
public String toString() {
return "NewsResult [url=" + url + ", title=" + title + ", content=" + content + ", source=" + source + ", rsid="
+ rsid + ", time=" + time + ", pt=" + pt + ", bondUniCode=" + bondUniCode + ", stkUniCode=" + stkUniCode
+ ", code=" + code + ", shortName=" + shortName + ", combination=" + combination + ", orgSec=" + orgSec
+ ", OrgChiName=" + OrgChiName + ", fzr=" + fzr + ", type=" + type + ", keyValue=" + keyValue + ", key="
+ key + "]";
}
}
......@@ -11,6 +11,7 @@
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-4.3.xsd
">
<!-- 开启注解处理器 -->
<context:annotation-config />
<!-- 开启组件自动扫描,扫描路径由base-package属性指定 -->
......@@ -18,7 +19,6 @@
<context:exclude-filter type="annotation"
expression="org.springframework.stereotype.Controller" />
</context:component-scan>
<context:property-placeholder
ignore-unresolvable="true" location="classpath:datasource.properties" />
......
......@@ -12,3 +12,13 @@ port=26017
socketIp=192.168.0.11
socketPort=10201
######### ES ############# 金融部分 ##############
esPort=9300
esIp=1.119.44.201
clusterName=Media-University
indexName=mediaspider*
type=media
openid=oTc_rssM56GjwdRgwTD2dfQMq4Rg
#,oTc_rsju0ZJsEnzFX3WRgZihNWpc,oTc_rsme_NjN1tVh3GSHLdHtq1o8
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" version="2.5">
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
version="2.5">
<display-name>change4weixin</display-name>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:applicationContext.xml</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<listener>
<listener-class>com.zhiwei.listener.SpringContextListener</listener-class>
</listener>
<servlet>
<servlet-name>java</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
......
......@@ -56,7 +56,7 @@ h5 {
style="position: fixed; top: 0px; right: 0px;z-index: -1;"></canvas>
<script src="./time.js"></script>
<script src="./canvas.js"></script>
<h5>如需插队运行,请联系------陈栋(674945328)/沈金柱(949131080)</h5>
<h5>如需插队运行,请联系------沈金柱(949131080)</h5>
<table class="table table-striped">
<thead>
<tr>
......
......@@ -53,7 +53,7 @@ body {
<script src="./time.js"></script>
<script src="./canvas.js"></script>
<h5>如需插队运行,请联系------陈栋(674945328)/沈金柱(949131080)</h5>
<h5>如需插队运行,请联系------沈金柱(949131080)</h5>
<table class="table table-striped">
<thead>
<tr>
......
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
<h3>Excel错误,请确认</h3>
</body>
</html>
\ No newline at end of file
<!DOCTYPE html>
<html>
<head>
<meta name="viewport">
<meta charset="utf-8">
<title>测试</title>
<script src="https://cdn.bootcss.com/vue/2.5.14/vue.min.js"></script>
<script src="https://cdn.bootcss.com/axios/0.18.0/axios.min.js"></script>
<link href="https://cdn.bootcss.com/bootstrap/4.1.0/css/bootstrap.min.css" rel="stylesheet">
<style>
.table {
width: 80%;
margin: 200px auto;
}
</style>
</head>
<body>
<div id="app">
<table class="table table-bordered">
<thead>
<tr>
<th v-for="head in headList">{{head}}</th>
</tr>
</thead>
<tbody>
<tr v-for="el in tbodyList">
<td>{{el.name}}</td>
<td>{{el.url}}</td>
<td @click="() => window.location.href = el.go">点击上传</td>
</tr>
</tbody>
</table>
</div>
<script>
(function () {
new Vue({
el: '#app',
data: {
headList: ['文件', '地址', '上传'],
tbodyList: []
},
created() {
console.log('create')
axios.get('/change4weixin/finance/getAll').then((res) => {
this.tbodyList = res.data
})
}
})
})()
</script>
</body>
</html>
\ No newline at end of file
......@@ -67,7 +67,7 @@ form {
</head>
<body>
<h4>如需插队,请联系陈栋(674945328)/沈金柱(949131080)</h4>
<h4>如需插队,请联系沈金柱(949131080)</h4>
<div class="example-div">
<span class="example-title ck" id="show" data-toggle="modal"data-target="#showModal">使用说明</span>
<span class="example-title" id="img" data-toggle="modal" data-target="#imgModal">上传文件要求</span>
......
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Insert title here</title>
<link rel="stylesheet"
href="https://cdn.bootcss.com/bootstrap/3.3.7/css/bootstrap.min.css"
integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u"
crossorigin="anonymous">
<script src="https://cdn.bootcss.com/jquery/3.3.1/jquery.min.js"></script>
<script
src="https://cdn.bootcss.com/bootstrap/3.3.7/js/bootstrap.min.js"
integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa"
crossorigin="anonymous">
</script>
<style type="text/css">
body {
background-image: url("../2.jpg");
display: flex;
flex-flow: column nowrap;
justify-content: center;
align-items: center;
padding-top: 200px; -
-imgwidth: 0px;
}
form {
margin-top: 3%;
width: 20%;
}
.form-group {
margin-top: 20px;
}
#submit:hover {
color: #66afe9;
}
.example {
position: absolute;
}
.example-title {
display: inline-block;
font-size: 16px;
margin: 20px 5px 10px;
font-weight: bold;
cursor: pointer;
}
.example-title:hover {
color: #66afe9;
}
.ck{
color:red;
}
#imgModal, #fileModal ,#showModal,#errorModal{
padding: 10% calc(50% - 480px);
text-align: center;
}
</style>
</head>
<body>
<form action="/change4weixin/finance/upFinanceKey" enctype="multipart/form-data"
method="post">
<span>关键词文件</span> <input type="file" name="file" />
<div class="form-group">
<input type="submit" value="提交" class="form-control" id="submit" />
</div>
</form>
<form action="/change4weixin/finance/upFinanceSource" enctype="multipart/form-data"
method="post">
<span>长来源文件</span> <input type="file" name="file" />
<div class="form-group">
<input type="submit" value="提交" class="form-control" id="submit" />
</div>
</form>
<form action="/change4weixin/finance/upFinanceSourceLess" enctype="multipart/form-data"
method="post">
<span>短来源文件</span> <input type="file" name="file" />
<div class="form-group">
<input type="submit" value="提交" class="form-control" id="submit" />
</div>
</form>
</body>
</html>
......@@ -11,6 +11,7 @@
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-4.3.xsd
">
<!-- 开启注解处理器 -->
<context:annotation-config />
<!-- 开启组件自动扫描,扫描路径由base-package属性指定 -->
......@@ -18,7 +19,6 @@
<context:exclude-filter type="annotation"
expression="org.springframework.stereotype.Controller" />
</context:component-scan>
<context:property-placeholder
ignore-unresolvable="true" location="classpath:datasource.properties" />
......
......@@ -12,3 +12,13 @@ port=26017
socketIp=192.168.0.11
socketPort=10201
######### ES ############# 金融部分 ##############
esPort=9300
esIp=1.119.44.201
clusterName=Media-University
indexName=mediaspider*
type=media
openid=oTc_rssM56GjwdRgwTD2dfQMq4Rg
#,oTc_rsju0ZJsEnzFX3WRgZihNWpc,oTc_rsme_NjN1tVh3GSHLdHtq1o8
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