Commit c57b50d9 by admin

文件说明添加

parent 35054b66
......@@ -52,6 +52,12 @@ public class ExcelReadAndWrite {
public static int port = Integer.valueOf(Config.getVal("socketPort"));
private static MongoForChenDong m = new MongoForChenDong();
/**
* 读取微信转链接的文件
*
* @param url
* @return
*/
public static List<Weixin> readExcels(String url) {
InputStream stream = null;
String str = null;
......@@ -127,6 +133,13 @@ public class ExcelReadAndWrite {
return list;
}
/**
* 写出转链接的文件
*
* @param list
* @param mail
* @throws Exception
*/
public static void write(List<Weixin> list, String mail) throws Exception {
Calendar cal = Calendar.getInstance();
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
......@@ -191,7 +204,15 @@ public class ExcelReadAndWrite {
System.out.println("发送完成");
}
public static void write2222(List<Weixin> list) throws IOException, RowsExceededException, WriteException {
/**
* 写出转链接的文件
*
* @param list
* @throws IOException
* @throws RowsExceededException
* @throws WriteException
*/
public static void write(List<Weixin> list) throws Exception {
File tempFile = new File(url);
if (!tempFile.exists()) {
tempFile.createNewFile();
......@@ -289,6 +310,13 @@ public class ExcelReadAndWrite {
}
}
/**
* 将输入流转换成byte[]
*
* @param inStream
* @return
* @throws Exception
*/
public static byte[] readStream(InputStream inStream) throws Exception {
ByteArrayOutputStream outSteam = new ByteArrayOutputStream();
byte[] buffer = new byte[1024];
......@@ -301,6 +329,11 @@ public class ExcelReadAndWrite {
return outSteam.toByteArray();
}
/**
* socket通信正常执行部分
*
* @return
*/
public static boolean so() {
boolean b = true;
int tip = 0;
......@@ -345,6 +378,11 @@ public class ExcelReadAndWrite {
return b;
}
/**
* 插队部分socket通信执行
*
* @return
*/
public static boolean cutso() {
boolean b = true;
try (Socket s = new Socket(host, port);
......@@ -405,7 +443,7 @@ public class ExcelReadAndWrite {
@Override
public void run() {
try {
save();
doChangeUrlWithCut();
} catch (Exception e) {
e.printStackTrace();
}
......@@ -442,7 +480,7 @@ public class ExcelReadAndWrite {
*
* @throws Exception
*/
public static void save() throws Exception {
public static void doChangeUrlWithCut() throws Exception {
System.out.println("插队开始处理");
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Excels excel = MainController.excel;
......@@ -494,7 +532,7 @@ public class ExcelReadAndWrite {
*
* @throws Exception
*/
public synchronized static void save2() throws Exception {
public synchronized static void doChangeUrl() throws Exception {
runStrat = true;
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
while (true) {
......@@ -587,19 +625,41 @@ public class ExcelReadAndWrite {
log.info("删除完成");
}
/**
* 转链接结束文件信息存入数据库
*
* @param ef
*/
public static void insert(ExcelFile ef) {
m.insertFile(ef);
}
/**
* 查询所有转链接的文件
*
* @return
*/
public static List<ExcelFile> findEf() {
List<ExcelFile> list = m.findFile();
return list;
}
/**
* 根据文件id去查询文件
*
* @param id
* @return
*/
public static String findById(String id) {
return m.findByid(id);
}
/**
* 读取excel
*
* @param url
* @return
*/
public static List<String> readExcel(String url) {
InputStream stream = null;
String str = null;
......@@ -625,6 +685,12 @@ public class ExcelReadAndWrite {
return list;
}
/**
* 链接重定向
*
* @param url
* @return
*/
public static String urlRedirect(String url) {
String result = null;
try {
......
......@@ -12,28 +12,35 @@ import org.springframework.stereotype.Component;
import com.zw.entity.ExcelFile;
/**
* 文件定期清除线程
*
* @author admin
*
*/
@Component
public class FileThread extends Thread{
public class FileThread extends Thread {
private static final Log log=LogFactory.getLog(FileThread.class);
private static MongoForChenDong m=new MongoForChenDong();
private static final Log log = LogFactory.getLog(FileThread.class);
private static MongoForChenDong m = new MongoForChenDong();
public FileThread(){
public FileThread() {
this.start();
}
public void run(){
SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
while(true){
@Override
public void run() {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
while (true) {
System.out.println("执行");
Calendar c=Calendar.getInstance();
if(c.get(Calendar.HOUR_OF_DAY)==1){
Calendar c = Calendar.getInstance();
if (c.get(Calendar.HOUR_OF_DAY) == 1) {
c.add(Calendar.DATE, -7);
List<String> removeList=new ArrayList<String>();
List<ExcelFile> list=m.findFile();
for(ExcelFile ex:list){
List<String> removeList = new ArrayList<String>();
List<ExcelFile> list = m.findFile();
for (ExcelFile ex : list) {
try {
if(sdf.parse(ex.getDate()).before(c.getTime())){
if (sdf.parse(ex.getDate()).before(c.getTime())) {
removeList.add(ex.getId());
ExcelReadAndWrite.delete(ex.getUrl());
}
......@@ -41,25 +48,20 @@ public class FileThread extends Thread{
log.info("时间格式转换出错{FileThread.39}");
}
}
for(String url:removeList){
for (String url : removeList) {
m.delete(url);
}
try {
Thread.sleep(1000*3600);
Thread.sleep(1000 * 3600);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
try {
Thread.sleep(1000*3500);
Thread.sleep(1000 * 3500);
} catch (InterruptedException e) {
e.printStackTrace();
}
// try {
// Thread.sleep(1000*60*30);
// } catch (InterruptedException e) {
// e.printStackTrace();
// }
}
}
}
......@@ -37,19 +37,12 @@ public class MongoForChenDong {
optionsBuilder.connectTimeout(1000 * 60 * 40); // 与数据库建立连接的超时时间
optionsBuilder.maxWaitTime(1000 * 60 * 5); // 一个线程成功获取到一个可用数据库连接之前的最大等待时间
optionsBuilder.threadsAllowedToBlockForConnectionMultiplier(100);// 等待一个连接
// //
// 允许阻塞的线程数
optionsBuilder.maxConnectionIdleTime(0);
optionsBuilder.maxConnectionLifeTime(0);
optionsBuilder.socketKeepAlive(true);
optionsBuilder.socketTimeout(1000 * 20);
MongoClientOptions options = optionsBuilder.build();
// char[] passwords = Config.getVal("password").toCharArray();
List<MongoCredential> credentials = new ArrayList<>();
// MongoCredential credential =
// MongoCredential.createCredential(Config.getVal("user"),
// Config.getVal("dbName"), passwords);
// credentials.add(credential);
List<ServerAddress> serverAddresses = new ArrayList<>();
serverAddresses.add(new ServerAddress(Config.getVal("host"), Integer.valueOf(Config.getVal("port"))));
mongoClient = new MongoClient(serverAddresses, credentials, options);
......@@ -104,6 +97,11 @@ public class MongoForChenDong {
}
}
/**
* 获取数量
*
* @return
*/
public int getNum() {
DB db = mongoClient.getDB(Config.getVal("dbName"));
DBCollection dbCollection = db.getCollection("RawUrl");
......@@ -115,6 +113,9 @@ public class MongoForChenDong {
return list.size();
}
/**
* 删除结果集的表
*/
public void remove() {
DB db = mongoClient.getDB(Config.getVal("dbName"));
DBCollection dbCollection = db.getCollection("Result");
......@@ -159,12 +160,23 @@ public class MongoForChenDong {
return list;
}
/**
* 删除保存期限已经过的文件
*
* @param id
*/
public void delete(String id) {
DB db = mongoClient.getDB(Config.getVal("dbName"));
DBCollection dbCollection = db.getCollection("changeUrlFile");
dbCollection.remove(new BasicDBObject("_id", new ObjectId(id)));
}
/**
* 根据id查询文件
*
* @param id
* @return
*/
public String findByid(String id) {
DB db = mongoClient.getDB(Config.getVal("dbName"));
DBCollection dbCollection = db.getCollection("changeUrlFile");
......
......@@ -19,10 +19,13 @@ import com.zw.entity.Weixin;
public class ReaderExcel {
private final static Log log = LogFactory.getLog(ReaderExcel.class);
public static void main(String[] args) throws IOException {
}
/**
* 根据路径读取excel,微信类
*
* @param url
* @return
* @throws IOException
*/
public static List<Weixin> getExcel(String url) throws IOException {
// String url="C:/Users/Administrator/Desktop/jd.xls";
List<Weixin> list = new ArrayList<>();
......@@ -105,39 +108,6 @@ public class ReaderExcel {
return list;
}
public static List<String> getZhUrls(String url) throws IOException {
List<String> list = new ArrayList<>();
Workbook book = null;
book = getExcelWorkbook(url);
Sheet sheet = getSheetByNum(book, 0);
int lastRowNum = sheet.getLastRowNum();
log.info("last number is " + lastRowNum);
for (int i = 1; i <= lastRowNum; i++) {
Row row = null;
row = sheet.getRow(i);
if (row != null) {
int lastCellNum = row.getLastCellNum();
Cell cell = null;
for (int j = 0; j < lastCellNum; j++) {
cell = row.getCell(j);
if (cell != null) {
cell.setCellType(Cell.CELL_TYPE_STRING);
String str = cell.getStringCellValue();
if (str != null) {
if (sheet.getRow(0).getCell(j) == null) {
continue;
}
if (sheet.getRow(0).getCell(j).getStringCellValue().equals("链接")) {
list.add(str);
}
}
}
}
}
}
return list;
}
public static Sheet getSheetByNum(Workbook book, int number) {
Sheet sheet = null;
try {
......
......@@ -73,6 +73,27 @@ public class ESUtil {
return result;
}
public static void main(String[] args) {
Client esClient = ESClient.getInstance();
SearchRequestBuilder srb = esClient.prepareSearch("mediaspider*");
BoolQueryBuilder bb = new BoolQueryBuilder();
// if (type.equals("weibo")) {
// QueryBuilder matchQuery = QueryBuilders.termQuery("messages", key);
// bb.should(matchQuery);
// srb.setQuery(bb);
// } else {
QueryBuilder matchQuery = QueryBuilders.termQuery("title", "王者荣耀:看老外是如何玩王者荣耀的?");
bb.should(matchQuery);
srb.setQuery(bb);
// }
srb.setSize(1);
SearchResponse response = srb.execute().actionGet();
SearchHits searchHits = response.getHits();
for (SearchHit hit : searchHits.getHits()) {
System.out.println(hit.getSource().get("title"));
}
}
/**
* 推送
*
......@@ -111,18 +132,11 @@ public class ESUtil {
keys = new ReadExcel().getExcel(path);
try {
for (String key : keys) {
// 搜索数据
SearchRequestBuilder srb = esClient.prepareSearch(Config.getVal("indexName." + type));
BoolQueryBuilder bb = new BoolQueryBuilder();
// if (type.equals("weibo")) {
// QueryBuilder matchQuery = QueryBuilders.termQuery("messages", key);
// bb.should(matchQuery);
// srb.setQuery(bb);
// } else {
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")
......@@ -140,21 +154,6 @@ public class ESUtil {
if (!url.contains("http")) {
url = String.valueOf(map.get("id"));
}
// if (type.equals("weibo")) {
// n.setUrl(url);
// if (map.get("roottext") == null) {
// n.setTitle(String.valueOf(map.get("text")));
// } else {
// n.setTitle(String.valueOf(map.get("roottext")));
// }
// try {
// n.setTime(map.get("time") + "");
// } catch (Exception e) {
// n.setTime("");
// }
// n.setSource(String.valueOf(map.get("username")));
// result.add(n);
// } else {
n.setUrl(url);
n.setTitle(String.valueOf(map.get("title")));
try {
......@@ -165,7 +164,6 @@ public class ESUtil {
}
n.setSource(String.valueOf(map.get("source")));
result.add(n);
// }
}
}
log.info("金融结束");
......
......@@ -18,6 +18,12 @@ import com.zw.entity.NewsResult;
import sendmail.SendMailUtil;
/**
* 金融推送执行的线程
*
* @author admin
*
*/
@Component
public class PushFinanceByTime extends Thread {
......@@ -85,6 +91,13 @@ public class PushFinanceByTime extends Thread {
}
}
/**
* 邮件发送
*
* @param cal
* @param list
* @param url
*/
private void sendsEmail(Calendar cal, List<NewsResult> list, String url) {
try {
new ExcelUtil().pushDataWithFinanceLong(list, cal.getTime(), 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;
......@@ -19,6 +17,7 @@ import com.zhiwei.util.JsonToObject;
import com.zw.entity.NewsResult;
import com.zw.entity.UserInfo;
import net.sf.json.JSONObject;
import weixin.popular.api.MessageAPI;
import weixin.popular.api.TokenAPI;
import weixin.popular.api.UserAPI;
......@@ -28,6 +27,12 @@ import weixin.popular.bean.message.templatemessage.TemplateMessageResult;
import weixin.popular.bean.token.Token;
import weixin.popular.bean.user.Group;
/**
* 微信推送
*
* @author admin
*
*/
public class WeixinSend {
private static final Logger log = LoggerFactory.getLogger(WeixinSend.class);
private static Token token;
......@@ -43,7 +48,8 @@ public class WeixinSend {
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("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);
......@@ -68,7 +74,9 @@ public class WeixinSend {
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));
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);
......
......@@ -6,6 +6,12 @@ import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.net.Socket;
/**
* 客户端
*
* @author admin
*
*/
public class Client {
public static void main(String[] args) throws IOException {
......
......@@ -18,7 +18,7 @@ import org.apache.poi.ss.usermodel.WorkbookFactory;
import com.zw.entity.ReadWechat;
/**
* 获取地址输入
* 获取地址输入excel
*
* @author Administrator
*
......
......@@ -11,6 +11,12 @@ import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.stereotype.Component;
/**
* 服务端启动
*
* @author admin
*
*/
@Component
public class ServerClient extends Thread {
......
......@@ -31,6 +31,12 @@ import jxl.write.WritableSheet;
import jxl.write.WritableWorkbook;
import sendmail.SendMailUtil;
/**
* 点赞阅读执行类
*
* @author admin
*
*/
public class WechatReadAndWrite {
private final static Log log = LogFactory.getLog(WechatReadAndWrite.class);
public static Excels e;
......
......@@ -9,6 +9,12 @@ import org.springframework.stereotype.Service;
import com.zhiwei.util.MongoConnection;
import com.zw.entity.ExcelsUrl;
/**
* 文件更新service
*
* @author admin
*
*/
@Service
public class Services {
......@@ -22,11 +28,6 @@ public class Services {
eUrl.setType(doc.getString("type"));
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;
......
......@@ -17,10 +17,15 @@ import com.alibaba.fastjson.JSON;
import com.zhiwei.service.Services;
import com.zhiwei.util.Config;
import com.zhiwei.util.ExcelUtil;
import com.zhiwei.util.ReadExcel;
import com.zhiwei.util.StringUtil;
import com.zw.entity.ExcelsUrl;
/**
* 文件更新控制器
*
* @author admin
*
*/
@Controller
@RequestMapping("/finance")
public class FianceController {
......@@ -36,6 +41,12 @@ public class FianceController {
return "showfinance";
}
/**
* 金融需要的文件存储
*
* @param file
* @return
*/
public void fileSave(MultipartFile file, String path) {
File targetFile = new File(path);
if (!targetFile.exists()) {
......@@ -49,6 +60,12 @@ public class FianceController {
}
}
/**
* 更新金融需要的金融关键词文件
*
* @param file
* @return
*/
@RequestMapping(value = "/upFinanceKey")
public String upFinanceKey(MultipartFile file) {
String fileName = file.getOriginalFilename();
......@@ -71,6 +88,12 @@ public class FianceController {
return "showfinance";
}
/**
* 更新金融需要的长来源文件
*
* @param file
* @return
*/
@RequestMapping(value = "/upFinanceLong")
public String upFinanceLong(MultipartFile file) {
String fileName = file.getOriginalFilename();
......@@ -93,6 +116,12 @@ public class FianceController {
return "showfinance";
}
/**
* 更新金融需要的微信文件
*
* @param file
* @return
*/
@RequestMapping(value = "/upFinanceWechat")
public String upFinanceWechat(MultipartFile file) {
String fileName = file.getOriginalFilename();
......@@ -115,6 +144,12 @@ public class FianceController {
return "showfinance";
}
/**
* 更新金融需要的微博文件
*
* @param file
* @return
*/
@RequestMapping(value = "/upFinanceWeibo")
public String upFinanceWeibo(MultipartFile file) {
String fileName = file.getOriginalFilename();
......@@ -137,6 +172,12 @@ public class FianceController {
return "showfinance";
}
/**
* 更新金融需要的短来源文件
*
* @param file
* @return
*/
@RequestMapping(value = "/upFinanceLess")
public String upFinanceLess(MultipartFile file) {
String fileName = file.getOriginalFilename();
......@@ -159,6 +200,12 @@ public class FianceController {
return "redirect:upExcel";
}
/**
* 获取所有文件
*
* @param file
* @return
*/
@RequestMapping(value = "/getAll", produces = "application/json;charset=utf-8")
@ResponseBody
public String getAll() {
......
......@@ -18,7 +18,6 @@ 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;
......@@ -28,6 +27,12 @@ import com.zhiwei.util.Config;
import com.zw.entity.Excels;
import com.zw.entity.Weixin;
/**
* 转链接
*
* @author admin
*
*/
@Controller
public class MainController {
......@@ -37,11 +42,23 @@ public class MainController {
public static Excels excel = null;
public static int finished = 0;
/**
* 转链接上传页面
*
* @return
*/
@RequestMapping("/scanExcel")
public String mian() {
return "test";
}
/**
* 转链接数据接口
*
* @param request
* @param response
* @throws IOException
*/
@RequestMapping(value = "/show")
public void shows(HttpServletRequest request, HttpServletResponse response) throws IOException {
System.out.println(lists.size());
......@@ -66,6 +83,12 @@ public class MainController {
}
}
/**
* 转链接下载接口
*
* @param request
* @param response
*/
@RequestMapping(value = "/downLode")
public void downLode(HttpServletRequest request, HttpServletResponse response) {
System.out.println(ExcelReadAndWrite.findEf());
......@@ -87,6 +110,13 @@ public class MainController {
}
}
/**
* 根据id下载文件
*
* @param request
* @param response
* @param id
*/
@RequestMapping(value = "/downLodeFile")
public void downFile(HttpServletRequest request, HttpServletResponse response, String id) {
System.out.println(ExcelReadAndWrite.findEf());
......@@ -110,6 +140,13 @@ public class MainController {
}
}
/**
* 删除文件
*
* @param request
* @param response
* @param id
*/
@RequestMapping(value = "/delete")
public void delete(HttpServletRequest request, HttpServletResponse response, String id) {
Map<String, Boolean> map = new HashMap<String, Boolean>();
......@@ -142,6 +179,13 @@ public class MainController {
}
}
/**
* 插队
*
* @param request
* @param response
* @param id
*/
@RequestMapping(value = "cutQ")
public void cutQ(HttpServletRequest request, HttpServletResponse response, String id) {
Map<String, Boolean> map = new HashMap<String, Boolean>();
......@@ -172,21 +216,47 @@ public class MainController {
}
}
/**
* 转链接显示进度页面
*
* @return
*/
@RequestMapping("/sh")
public String showPage() {
return "dataTable";
}
/**
* 转链接插队页面
*
* @return
*/
@RequestMapping("/admin")
public String showPageAdmin() {
return "dataTable2";
}
/**
* 转链接下载页面
*
* @return
*/
@RequestMapping("/down")
public String down() {
return "dataTable3";
}
/**
* 转链接文件上传
*
* @param req
* @param res
* @param file
* @param mail
* @param mail2
* @return
* @throws Exception
*/
@RequestMapping(value = "/up")
public String up(HttpServletRequest req, HttpServletResponse res, MultipartFile file, String mail, String mail2)
throws Exception {
......@@ -230,7 +300,7 @@ public class MainController {
@Override
public void run() {
try {
ExcelReadAndWrite.save2();
ExcelReadAndWrite.doChangeUrl();
} catch (Exception e) {
e.printStackTrace();
}
......@@ -242,15 +312,4 @@ public class MainController {
}
return "error3";
}
@RequestMapping(value = "/zhNum", produces = "application/json;charset=utf-8")
@ResponseBody
public String getzhNum() {
return JSON.toJSONString(map);
}
@RequestMapping("/zh")
public String zh() {
return "zhihu";
}
}
......@@ -25,12 +25,24 @@ import com.zhiwei.util.Config;
import com.zw.entity.Excels;
import com.zw.entity.ReadWechat;
/**
* 点赞阅读
*
* @author admin
*
*/
@Controller
public class RwController {
private final static Log log = LogFactory.getLog(RwController.class);
public static Vector<Excels> weChatList = new Vector<Excels>();
/**
* 点赞阅读下载文件接口
*
* @param request
* @param response
*/
@RequestMapping(value = "/rwdownLode")
public void downLode(HttpServletRequest request, HttpServletResponse response) {
System.out.println(ExcelReadAndWrite.findEf());
......@@ -49,6 +61,13 @@ public class RwController {
}
}
/**
* 点赞阅读文件下载
*
* @param request
* @param response
* @param id
*/
@RequestMapping(value = "/rwdownLodeFile")
public void downFile(HttpServletRequest request, HttpServletResponse response, String id) {
try {
......@@ -71,6 +90,17 @@ public class RwController {
}
}
/**
* 点赞阅读文件上传
*
* @param req
* @param res
* @param file
* @param mail
* @param mail2
* @return
* @throws Exception
*/
@RequestMapping(value = "/weChatup")
public String weChatup(HttpServletRequest req, HttpServletResponse res, MultipartFile file, String mail,
String mail2) throws Exception {
......@@ -124,21 +154,43 @@ public class RwController {
return "error3";
}
/**
* 点赞阅读上传后的显示页面
*
* @return
*/
@RequestMapping("/rwsh")
public String readshowPage() {
return "readShow";
}
/**
* 点赞阅读的下载页面
*
* @return
*/
@RequestMapping("/rwdown")
public String rwdown() {
return "readWechatDown";
}
/**
* 点赞阅读的上传文件页面
*
* @return
*/
@RequestMapping("/rwExcel")
public String rwExcel() {
return "readWechat";
}
/**
* 点赞阅读数据显示接口
*
* @param request
* @param response
* @throws IOException
*/
@RequestMapping(value = "/rwShow")
public void readShows(HttpServletRequest request, HttpServletResponse response) throws IOException {
System.out.println(weChatList.size());
......
......@@ -2,10 +2,17 @@ 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;
/**
* 加密解析aes
*
* @author admin
*
*/
public class AESUtils {
public static String encrypt(String secret, String value) {
SecretKeySpec keySpec = getKey(secret);
......
......@@ -4,20 +4,27 @@ import java.io.FileInputStream;
import java.io.InputStreamReader;
import java.util.Properties;
/**
* 配置读取
*
* @author admin
*
*/
public class Config {
public static Properties p=new Properties();
public static Properties p = new Properties();
static {
String fileurl = Config.class.getClassLoader().getResource("datasource.properties").getPath();
p = new Properties();
try {
InputStreamReader in = new InputStreamReader(new FileInputStream(fileurl),"utf-8");
InputStreamReader in = new InputStreamReader(new FileInputStream(fileurl), "utf-8");
p.load(in); /// 加载属性列表
in.close();
}catch(Exception e){
} catch (Exception e) {
}
}
public static String getVal(String key){
public static String getVal(String key) {
return p.getProperty(key);
}
}
......@@ -3,18 +3,18 @@ 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;
/**
* 数据解析
*
* @author admin
*
*/
public class JsonToObject {
public static String getToken() {
......
......@@ -4,6 +4,7 @@ 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;
......@@ -11,6 +12,12 @@ import com.mongodb.client.MongoCursor;
import com.mongodb.client.MongoDatabase;
import com.mongodb.client.model.UpdateOptions;
/**
* 文件操作mongo
*
* @author admin
*
*/
public class MongoConnection {
private MongoClient client;
......@@ -25,6 +32,7 @@ public class MongoConnection {
/**
* 更新操作,若没有则插入
*
* @param dbName
* @param collection
* @param document
......@@ -36,12 +44,13 @@ public class MongoConnection {
filter.append("name", document.get("name"));
filter.append("type", document.get("type"));
Document update = new Document();
update.append("$set", new Document("url",document.get("url")));
update.append("$set", new Document("url", document.get("url")));
col.updateOne(filter, update, new UpdateOptions().upsert(true));
}
/**
* 查询
*
* @param dbName
* @param collection
* @return
......@@ -59,30 +68,32 @@ public class MongoConnection {
return list;
}
public Document find(String dbName, String collection,Document doc) {
public Document find(String dbName, String collection, Document doc) {
MongoDatabase db = getdb(dbName);
MongoCollection<Document> col = db.getCollection(collection);
Document fid = col.find(doc).first();
return fid;
}
/**
* 条件查询
*
* @param dbName
* @param collection
* @return
*/
public String findOne(String dbName, String collection,String name) {
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()):"";
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);
// }
MongoConnection m = new MongoConnection();
// for(Document doc:m.find("financePush","excelPath")) {
// System.out.println(doc);
// }
}
}
......@@ -23,6 +23,12 @@ import com.mongodb.client.MongoDatabase;
import com.zw.entity.ExcelFile;
import com.zw.entity.ReadWechat;
/**
* 点赞阅读连接mongo
*
* @author admin
*
*/
public class ReadWechatConnect {
private MongoClient client;
......
package com.zhiwei.util;
/**
* 字符操作工具
*
* @author admin
*
*/
public class StringUtil {
public static boolean isEmpty(String str) {
return str==null||str.equals("");
return str == null || str.equals("");
}
}
package com.zw.entity;
import java.io.Serializable;
import java.util.Date;
import com.mongodb.connection.Server;
public class ExcelFile implements Serializable{
/**
* 文件类
*
* @author admin
*
*/
public class ExcelFile implements Serializable {
private String id;
private String url;
private String mail;
private String date;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getUrl() {
return url;
}
public void setUrl(String url) {
this.url = url;
}
public String getMail() {
return mail;
}
public void setMail(String mail) {
this.mail = mail;
}
public String getDate() {
return date;
}
public void setDate(String date) {
this.date = date;
}
@Override
public String toString() {
return "ExcelFile [url=" + url + ", mail=" + mail + ", date=" + date + "]";
}
}
......@@ -2,6 +2,12 @@ package com.zw.entity;
import java.io.Serializable;
/**
* 金融文件操作类
*
* @author admin
*
*/
public class Excels implements Serializable {
private String id;
......@@ -12,54 +18,69 @@ public class Excels implements Serializable {
private int site;// 当前位置
private int surplusCount;// 剩余条数
private String state;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getUrl() {
return url;
}
public void setUrl(String url) {
this.url = url;
}
public String getMail() {
return mail;
}
public void setMail(String mail) {
this.mail = mail;
}
public String getStartDate() {
return startDate;
}
public void setStartDate(String startDate) {
this.startDate = startDate;
}
public double getNeed() {
return need;
}
public void setNeed(double need) {
this.need = need;
}
public int getSite() {
return site;
}
public void setSite(int site) {
this.site = site;
}
public int getSurplusCount() {
return surplusCount;
}
public void setSurplusCount(int surplusCount) {
this.surplusCount = surplusCount;
}
public String getState() {
return state;
}
public void setState(String state) {
this.state = state;
}
}
package com.zw.entity;
/**
* 点赞阅读
*
* @author admin
*
*/
public class ReadWechat {
private String title;
......
package com.zw.entity;
/**
* 微信转链接
*
* @author admin
*
*/
public class Weixin {
private String source;
......@@ -10,7 +16,7 @@ public class Weixin {
private String conetent;
private String keyValue;
//微博
// 微博
private String read;
private String zan;
private String nickname;
......@@ -22,109 +28,142 @@ public class Weixin {
private String markname;
private String trueRead;
public String getRead() {
return read;
}
public void setRead(String read) {
this.read = read;
}
public String getZan() {
return zan;
}
public void setZan(String zan) {
this.zan = zan;
}
public String getNickname() {
return nickname;
}
public void setNickname(String nickname) {
this.nickname = nickname;
}
public String getJianjie() {
return jianjie;
}
public void setJianjie(String jianjie) {
this.jianjie = jianjie;
}
public String getHistory() {
return history;
}
public void setHistory(String history) {
this.history = history;
}
public String getLongUrl() {
return longUrl;
}
public void setLongUrl(String longUrl) {
this.longUrl = longUrl;
}
public String getMark() {
return mark;
}
public void setMark(String mark) {
this.mark = mark;
}
public String getMark_time() {
return mark_time;
}
public void setMark_time(String mark_time) {
this.mark_time = mark_time;
}
public String getMarkname() {
return markname;
}
public void setMarkname(String markname) {
this.markname = markname;
}
public String getTrueRead() {
return trueRead;
}
public void setTrueRead(String trueRead) {
this.trueRead = trueRead;
}
public String getKeyValue() {
return keyValue;
}
public void setKeyValue(String keyValue) {
this.keyValue = keyValue;
}
public String getConetent() {
return conetent;
}
public void setConetent(String conetent) {
this.conetent = conetent;
}
public String getSource() {
return source;
}
public void setSource(String source) {
this.source = source;
}
public String getUrl() {
return url;
}
public void setUrl(String url) {
this.url = url;
}
public String getGetUrl() {
return getUrl;
}
public void setGetUrl(String getUrl) {
this.getUrl = getUrl;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getTime() {
return time;
}
public void setTime(String time) {
this.time = time;
}
@Override
public String toString() {
return "Weixin [source=" + source + ", url=" + url + ", getUrl=" + getUrl + ", title=" + title + ", time="
......@@ -134,7 +173,4 @@ public class Weixin {
+ "]";
}
}
......@@ -7,10 +7,8 @@ import java.util.Properties;
import javax.activation.DataHandler;
import javax.activation.DataSource;
import javax.activation.FileDataSource;
import javax.annotation.Resource;
import javax.mail.BodyPart;
import javax.mail.Multipart;
import javax.mail.PasswordAuthentication;
import javax.mail.Session;
import javax.mail.Transport;
import javax.mail.internet.InternetAddress;
......@@ -22,7 +20,7 @@ import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
/**
* 閭欢鍙戯拷?锟藉伐鍏风被
* 邮件发送
*
* @author shenjinzhu
*/
......
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