Commit 4a2013da by shenjinzhu

更新

parent 4ec6ab5c
......@@ -13,6 +13,7 @@ import java.io.PrintWriter;
import java.net.Socket;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.LinkedList;
......@@ -139,7 +140,10 @@ public class ExcelReadAndWrite {
}
public static void write(List<Weixin> list, String mail) throws Exception {
File tempFile = new File(url);
Calendar cal = Calendar.getInstance();
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
String inurl = url + (int) (Math.random() * 99) + sdf.format(cal.getTime()) + ".xls";
File tempFile = new File(inurl);
// 若是文件不存在就创建新文件
if (!tempFile.exists()) {
tempFile.createNewFile();
......@@ -148,12 +152,6 @@ public class ExcelReadAndWrite {
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);
// 标题格式
WritableFont titleFont = new WritableFont(WritableFont.ARIAL, 14, WritableFont.NO_BOLD, false,
UnderlineStyle.NO_UNDERLINE, jxl.format.Colour.BLACK);
......@@ -219,10 +217,10 @@ public class ExcelReadAndWrite {
workbook.write();
workbook.close();
log.info("内容写入成功");
SendMailUtil.sendMessage(mail, url, "ccxe");
ExcelFile ef=new ExcelFile();
SendMailUtil.sendMessage(mail, inurl, "ccxe");
ExcelFile ef = new ExcelFile();
ef.setMail(mail);
ef.setUrl(url);
ef.setUrl(inurl);
insert(ef);
System.out.println("发送完成");
}
......@@ -327,6 +325,8 @@ public class ExcelReadAndWrite {
public static boolean so() {
boolean b = true;
int tip = 0;
int now = 999;
int before = 0;
try {
Thread.sleep(1000 * 5);
while (cut) {// cut=true,插队中
......@@ -340,18 +340,6 @@ public class ExcelReadAndWrite {
MainController.lists.get(0).setState("运行中···");
tip = 0;
}
// Socket s = new Socket(host, port);
// InputStream in = s.getInputStream();
// BufferedReader reader = new BufferedReader(new
// InputStreamReader(in, "utf-8"));
// String str = reader.readLine();
// log.info(str);
//
// if (str.equals("{num:1}") || str.equals("{num:0}")) {
// b = false;
// }
// in.close();
// s.close();
try (Socket s = new Socket(host, port);
PrintWriter pw = new PrintWriter(s.getOutputStream());
BufferedReader bufferedReader = new BufferedReader(
......@@ -359,13 +347,15 @@ public class ExcelReadAndWrite {
pw.println("getnum");
pw.flush();
String str = bufferedReader.readLine();
System.out.println("正常运行"+str);
Matcher macher = Pattern.compile("num:([0-9]+?)\\}").matcher(str);
System.out.println("正常运行" + str);
Matcher macher = Pattern.compile("num:([0-9]+)\\}").matcher(str);
if (macher.find()) {
if (Integer.valueOf(macher.group(1)) != 0)
MainController.lists.get(0).setSurplusCount(Integer.valueOf(macher.group(1)));
if (Integer.valueOf(macher.group(1)) != 0) {
now = Integer.valueOf(macher.group(1));
MainController.lists.get(0).setSurplusCount(now);
}
if (str.contains("0")) {
}
if (now == 0) {
b = false;
}
} catch (Exception e) {
......@@ -387,7 +377,7 @@ public class ExcelReadAndWrite {
pw.println("getnum");
pw.flush();
String str = bufferedReader.readLine();
System.out.println("插队运行"+str);
System.out.println("插队运行" + str);
if (str.contains("0")) {
b = false;
}
......@@ -555,10 +545,15 @@ public class ExcelReadAndWrite {
}
Map<String, String> map = new HashMap<>();
for (Map<String, Object> ma : m.find()) {
try {
if (ma != null && ma.get("url") != null)
map.put(ma.get("_id").toString(), ma.get("url").toString());
} catch (Exception e) {
log.info("错误信息+560{}" + e.getMessage());
}
}
for (Weixin w : list) {
try {
if (null != w.getUrl() && w.getUrl().startsWith("https://mp.weixin.qq.com/s")
|| w.getUrl().startsWith("http://mp.weixin.qq.com/s")) {
if (map.get(w.getUrl()) != null) {
......@@ -567,10 +562,13 @@ public class ExcelReadAndWrite {
} else {
w.setGetUrl(w.getUrl() == null ? "" : w.getUrl());
}
} catch (Exception e) {
log.info("错误信息+574{}" + e.getMessage());
}
}
write(list, e.getMail());
// delete(e.getUrl());
// delete(e.getUrl());
MainController.lists.remove(MainController.lists.get(0));
e = null;
}
......@@ -590,6 +588,7 @@ public class ExcelReadAndWrite {
/**
* 删除文件
*
* @param url
* 文件的路径
*/
......@@ -601,16 +600,16 @@ public class ExcelReadAndWrite {
log.info("删除完成");
}
public static void insert(ExcelFile ef){
public static void insert(ExcelFile ef) {
m.insertFile(ef);
}
public static List<ExcelFile> findEf(){
List<ExcelFile> list=m.findFile();
public static List<ExcelFile> findEf() {
List<ExcelFile> list = m.findFile();
return list;
}
public static String findById(String id){
public static String findById(String id) {
return m.findByid(id);
}
......
basefile=/home/nbzhiwei/upload/new.xls
basefile=/home/nbzhiwei/upload/
#basefile=C:/Users/Administrator/Desktop/news222.xls
timefileUrl=/home/nbzhiwei/upload
#timefileUrl=C:/Users/Administrator/Desktop
......
basefile=/home/nbzhiwei/upload/new.xls
basefile=/home/nbzhiwei/upload/
#basefile=C:/Users/Administrator/Desktop/news222.xls
timefileUrl=/home/nbzhiwei/upload
#timefileUrl=C:/Users/Administrator/Desktop
......
......@@ -14,7 +14,7 @@
z: o(v, "zIndex", 1),
o: o(v, "opacity", 1),
c: o(v, "color", "255,255,153"),
n: o(v, "count", 200)
n: o(v, "count", 190)
}
}
function k() {
......
No preview for this file type
basefile=/home/nbzhiwei/upload/new.xls
basefile=/home/nbzhiwei/upload/
#basefile=C:/Users/Administrator/Desktop/news222.xls
timefileUrl=/home/nbzhiwei/upload
#timefileUrl=C:/Users/Administrator/Desktop
......
#Generated by Maven
#Tue Dec 19 14:45:48 CST 2017
#Wed Dec 20 12:02:17 CST 2017
version=3.0.1-SNAPSHOT
groupId=com.zhiwei
artifactId=change4weixin
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