From e55fb5a0068474baa846057cf42c2dd02fce723f Mon Sep 17 00:00:00 2001 From: zhouy Date: Mon, 25 Sep 2017 12:16:54 +0800 Subject: [PATCH 01/14] =?UTF-8?q?MIT=20license=E5=BE=BD=E6=A0=87=E6=B5=8B?= =?UTF-8?q?=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- readme.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/readme.md b/readme.md index 2d097a7c..a3e55eaf 100644 --- a/readme.md +++ b/readme.md @@ -4,7 +4,7 @@

-# WePush [![Build Status](https://travis-ci.org/rememberber/WePush.svg?branch=master)](https://travis-ci.org/rememberber/WePush) +# WePush [![Build Status](https://travis-ci.org/rememberber/WePush.svg?branch=master)](https://travis-ci.org/rememberber/WePush)![](https://img.shields.io/badge/license-MIT-000000.svg) ### 功能 自定义消息并批量推送 From 18c4388b5dbba6740e900b93f8bb6fb8fa669d2b Mon Sep 17 00:00:00 2001 From: zhouy Date: Mon, 25 Sep 2017 12:19:49 +0800 Subject: [PATCH 02/14] =?UTF-8?q?MIT=20license=E5=BE=BD=E6=A0=87=E6=B5=8B?= =?UTF-8?q?=E8=AF=95=20=E5=86=B3=E5=AE=9A=E5=8F=96=E6=B6=88=E6=94=BE?= =?UTF-8?q?=E7=BD=AE=E8=AF=A5=E5=BE=BD=E7=AB=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- readme.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/readme.md b/readme.md index a3e55eaf..2d097a7c 100644 --- a/readme.md +++ b/readme.md @@ -4,7 +4,7 @@

-# WePush [![Build Status](https://travis-ci.org/rememberber/WePush.svg?branch=master)](https://travis-ci.org/rememberber/WePush)![](https://img.shields.io/badge/license-MIT-000000.svg) +# WePush [![Build Status](https://travis-ci.org/rememberber/WePush.svg?branch=master)](https://travis-ci.org/rememberber/WePush) ### 功能 自定义消息并批量推送 From 74a686b95377fc82952ee58a4a12252fd299f9d9 Mon Sep 17 00:00:00 2001 From: zhouy Date: Tue, 6 Feb 2018 18:17:04 +0800 Subject: [PATCH 03/14] =?UTF-8?q?=E6=94=AF=E6=8C=81=E6=AF=8F=E6=9D=A1?= =?UTF-8?q?=E6=B6=88=E6=81=AF=E8=87=AA=E5=AE=9A=E4=B9=89=E5=86=85=E5=AE=B9?= =?UTF-8?q?-=E5=AF=BC=E5=85=A5=E6=95=B0=E6=8D=AE=E7=BB=93=E6=9E=84?= =?UTF-8?q?=E5=8F=98=E6=9B=B4=E4=B8=BA=E6=95=B0=E7=BB=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../logic/AliTemplateMsgServiceThread.java | 10 +++---- .../push/logic/BaseMsgServiceThread.java | 2 +- .../push/logic/KeFuMsgServiceThread.java | 6 ++--- .../push/logic/KeFuPriorMsgServiceThread.java | 6 ++--- .../tool/wechat/push/logic/PushData.java | 8 +++--- .../tool/wechat/push/logic/PushManage.java | 22 ++++++---------- .../push/logic/TemplateMsgServiceThread.java | 6 ++--- .../push/ui/listener/MemberListener.java | 26 +++++++++++++------ 8 files changed, 45 insertions(+), 41 deletions(-) diff --git a/src/main/java/com/fangxuele/tool/wechat/push/logic/AliTemplateMsgServiceThread.java b/src/main/java/com/fangxuele/tool/wechat/push/logic/AliTemplateMsgServiceThread.java index 502a7c49..00ad1233 100644 --- a/src/main/java/com/fangxuele/tool/wechat/push/logic/AliTemplateMsgServiceThread.java +++ b/src/main/java/com/fangxuele/tool/wechat/push/logic/AliTemplateMsgServiceThread.java @@ -44,7 +44,7 @@ public void run() { return; } - String telNum = list.get(i); + String telNum = list.get(i)[0]; try { alibabaAliqinFcSmsNumSendRequest.setRecNum(telNum); @@ -61,14 +61,14 @@ public void run() { tableModel.setValueAt(currentThreadSuccessCount, tableRow, 2); // 保存发送成功 - PushData.sendSuccessList.add(telNum); + PushData.sendSuccessList.add(list.get(i)); } else { // 总发送失败+1 PushData.increaseFail(); MainWindow.mainWindow.getPushFailCount().setText(String.valueOf(PushData.failRecords)); // 保存发送失败 - PushData.sendFailList.add(telNum); + PushData.sendFailList.add(list.get(i)); // 失败异常信息输出控制台 PushManage.console(new StringBuffer().append("发送失败:").append(response.getBody()).append(";ErrorCode:") @@ -88,7 +88,7 @@ public void run() { tableModel.setValueAt(currentThreadSuccessCount, tableRow, 2); // 保存发送成功 - PushData.sendSuccessList.add(telNum); + PushData.sendSuccessList.add(list.get(i)); } } catch (Exception e) { @@ -97,7 +97,7 @@ public void run() { MainWindow.mainWindow.getPushFailCount().setText(String.valueOf(PushData.failRecords)); // 保存发送失败 - PushData.sendFailList.add(telNum); + PushData.sendFailList.add(list.get(i)); // 失败异常信息输出控制台 PushManage.console(new StringBuffer().append("发送失败:").append(e.getMessage()).append(";telNum:").append(telNum).toString()); diff --git a/src/main/java/com/fangxuele/tool/wechat/push/logic/BaseMsgServiceThread.java b/src/main/java/com/fangxuele/tool/wechat/push/logic/BaseMsgServiceThread.java index 30fe877c..75a892bd 100644 --- a/src/main/java/com/fangxuele/tool/wechat/push/logic/BaseMsgServiceThread.java +++ b/src/main/java/com/fangxuele/tool/wechat/push/logic/BaseMsgServiceThread.java @@ -34,7 +34,7 @@ public class BaseMsgServiceThread extends Thread { /** * 当前线程要发送的list */ - public List list; + public List list; /** * 微信工具服务 diff --git a/src/main/java/com/fangxuele/tool/wechat/push/logic/KeFuMsgServiceThread.java b/src/main/java/com/fangxuele/tool/wechat/push/logic/KeFuMsgServiceThread.java index 748854d7..4f847a42 100644 --- a/src/main/java/com/fangxuele/tool/wechat/push/logic/KeFuMsgServiceThread.java +++ b/src/main/java/com/fangxuele/tool/wechat/push/logic/KeFuMsgServiceThread.java @@ -35,7 +35,7 @@ public void run() { return; } - String openId = list.get(i); + String openId = list.get(i)[0]; try { wxMpKefuMessage.setToUser(openId); @@ -53,14 +53,14 @@ public void run() { tableModel.setValueAt(currentThreadSuccessCount, tableRow, 2); // 保存发送成功 - PushData.sendSuccessList.add(openId); + PushData.sendSuccessList.add(list.get(i)); } catch (Exception e) { // 总发送失败+1 PushData.increaseFail(); MainWindow.mainWindow.getPushFailCount().setText(String.valueOf(PushData.failRecords)); // 保存发送失败 - PushData.sendFailList.add(openId); + PushData.sendFailList.add(list.get(i)); // 失败异常信息输出控制台 PushManage.console(new StringBuffer().append("发送失败:").append(e.getMessage()).append(";openid:").append(openId).toString()); diff --git a/src/main/java/com/fangxuele/tool/wechat/push/logic/KeFuPriorMsgServiceThread.java b/src/main/java/com/fangxuele/tool/wechat/push/logic/KeFuPriorMsgServiceThread.java index ed398f86..89089c70 100644 --- a/src/main/java/com/fangxuele/tool/wechat/push/logic/KeFuPriorMsgServiceThread.java +++ b/src/main/java/com/fangxuele/tool/wechat/push/logic/KeFuPriorMsgServiceThread.java @@ -37,7 +37,7 @@ public void run() { return; } - String openId = list.get(i); + String openId = list.get(i)[0]; try { wxMpKefuMessage.setToUser(openId); wxMpTemplateMessage.setToUser(openId); @@ -60,14 +60,14 @@ public void run() { tableModel.setValueAt(currentThreadSuccessCount, tableRow, 2); // 保存发送成功 - PushData.sendSuccessList.add(openId); + PushData.sendSuccessList.add(list.get(i)); } catch (Exception e) { // 总发送失败+1 PushData.increaseFail(); MainWindow.mainWindow.getPushFailCount().setText(String.valueOf(PushData.failRecords)); // 保存发送失败 - PushData.sendFailList.add(openId); + PushData.sendFailList.add(list.get(i)); // 失败异常信息输出控制台 PushManage.console(new StringBuffer().append("发送失败:").append(e.getMessage()).append(";openid:").append(openId).toString()); diff --git a/src/main/java/com/fangxuele/tool/wechat/push/logic/PushData.java b/src/main/java/com/fangxuele/tool/wechat/push/logic/PushData.java index 257a758b..1b23e073 100644 --- a/src/main/java/com/fangxuele/tool/wechat/push/logic/PushData.java +++ b/src/main/java/com/fangxuele/tool/wechat/push/logic/PushData.java @@ -12,7 +12,7 @@ public class PushData { /** * 导入的用户 */ - public static List allUser; + public static List allUser; /** * 总记录数 @@ -32,17 +32,17 @@ public class PushData { /** * 准备发送的列表 */ - public static List toSendList; + public static List toSendList; /** * 发送成功的列表 */ - public static List sendSuccessList; + public static List sendSuccessList; /** * 发送失败的列表 */ - public static List sendFailList; + public static List sendFailList; /** * 停止标志 diff --git a/src/main/java/com/fangxuele/tool/wechat/push/logic/PushManage.java b/src/main/java/com/fangxuele/tool/wechat/push/logic/PushManage.java index 90c35b29..56b16f3a 100644 --- a/src/main/java/com/fangxuele/tool/wechat/push/logic/PushManage.java +++ b/src/main/java/com/fangxuele/tool/wechat/push/logic/PushManage.java @@ -226,19 +226,17 @@ public static void savePushData() throws IOException { } writer = new CSVWriter(new FileWriter(toSendFile)); - for (String str : PushData.sendSuccessList) { - strArray = new String[1]; - strArray[0] = str; - writer.writeNext(strArray); + for (String[] str : PushData.sendSuccessList) { + writer.writeNext(str); } writer.close(); } // 保存未发送 - for (String str : PushData.sendSuccessList) { + for (String[] str : PushData.sendSuccessList) { PushData.toSendList.remove(str); } - for (String str : PushData.sendFailList) { + for (String[] str : PushData.sendFailList) { PushData.toSendList.remove(str); } if (PushData.toSendList.size() > 0) { @@ -247,10 +245,8 @@ public static void savePushData() throws IOException { unSendFile.createNewFile(); } writer = new CSVWriter(new FileWriter(unSendFile)); - for (String str : PushData.toSendList) { - strArray = new String[1]; - strArray[0] = str; - writer.writeNext(strArray); + for (String[] str : PushData.toSendList) { + writer.writeNext(str); } writer.close(); } @@ -262,10 +258,8 @@ public static void savePushData() throws IOException { failSendFile.createNewFile(); } writer = new CSVWriter(new FileWriter(failSendFile)); - for (String str : PushData.sendFailList) { - strArray = new String[1]; - strArray[0] = str; - writer.writeNext(strArray); + for (String[] str : PushData.sendFailList) { + writer.writeNext(str); } writer.close(); } diff --git a/src/main/java/com/fangxuele/tool/wechat/push/logic/TemplateMsgServiceThread.java b/src/main/java/com/fangxuele/tool/wechat/push/logic/TemplateMsgServiceThread.java index 34581cc3..ed6c7fe3 100644 --- a/src/main/java/com/fangxuele/tool/wechat/push/logic/TemplateMsgServiceThread.java +++ b/src/main/java/com/fangxuele/tool/wechat/push/logic/TemplateMsgServiceThread.java @@ -36,7 +36,7 @@ public void run() { return; } - String openId = list.get(i); + String openId = list.get(i)[0]; try { wxMessageTemplate.setToUser(openId); @@ -54,14 +54,14 @@ public void run() { tableModel.setValueAt(currentThreadSuccessCount, tableRow, 2); // 保存发送成功 - PushData.sendSuccessList.add(openId); + PushData.sendSuccessList.add(list.get(i)); } catch (Exception e) { // 总发送失败+1 PushData.increaseFail(); MainWindow.mainWindow.getPushFailCount().setText(String.valueOf(PushData.failRecords)); // 保存发送失败 - PushData.sendFailList.add(openId); + PushData.sendFailList.add(list.get(i)); // 失败异常信息输出控制台 PushManage.console(new StringBuffer().append("发送失败:").append(e.getMessage()).append(";openid:").append(openId).toString()); diff --git a/src/main/java/com/fangxuele/tool/wechat/push/ui/listener/MemberListener.java b/src/main/java/com/fangxuele/tool/wechat/push/ui/listener/MemberListener.java index 14bc190a..180b5027 100644 --- a/src/main/java/com/fangxuele/tool/wechat/push/ui/listener/MemberListener.java +++ b/src/main/java/com/fangxuele/tool/wechat/push/ui/listener/MemberListener.java @@ -17,6 +17,7 @@ import javax.swing.JOptionPane; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; +import java.io.BufferedReader; import java.io.File; import java.io.IOException; import java.sql.ResultSet; @@ -47,7 +48,7 @@ public static void addListeners() { String[] nextLine; PushData.allUser = Collections.synchronizedList(new ArrayList<>()); while ((nextLine = reader.readNext()) != null) { - PushData.allUser.add(nextLine[0].trim()); + PushData.allUser.add(nextLine); currentImported++; MainWindow.mainWindow.getMemberTabCountLabel().setText(String.valueOf(currentImported)); MainWindow.mainWindow.getMemberTabImportProgressBar().setValue(currentImported); @@ -55,8 +56,14 @@ public static void addListeners() { } else { fileReader = new FileReader(file); PushData.allUser = Collections.synchronizedList(new ArrayList<>()); - PushData.allUser.addAll(fileReader.readLines()); - MainWindow.mainWindow.getMemberTabCountLabel().setText(String.valueOf(PushData.allUser.size())); + BufferedReader br = fileReader.getReader(); + String line; + while ((line = br.readLine()) != null) { + PushData.allUser.add(line.split(",")); + currentImported++; + MainWindow.mainWindow.getMemberTabCountLabel().setText(String.valueOf(currentImported)); + MainWindow.mainWindow.getMemberTabImportProgressBar().setValue(currentImported); + } } MainWindow.mainWindow.getMemberTabImportProgressBar().setIndeterminate(false); JOptionPane.showMessageDialog(MainWindow.mainWindow.getMemberPanel(), "导入完成!", "完成", @@ -124,7 +131,7 @@ public static void addListeners() { String[] nextLine; PushData.allUser = Collections.synchronizedList(new ArrayList<>()); while ((nextLine = reader.readNext()) != null) { - PushData.allUser.add(nextLine[0].trim()); + PushData.allUser.add(nextLine); currentImported++; MainWindow.mainWindow.getMemberTabCountLabel().setText(String.valueOf(currentImported)); MainWindow.mainWindow.getMemberTabImportProgressBar().setValue(currentImported); @@ -167,7 +174,7 @@ public static void addListeners() { int currentImported = 0; while (rs.next()) { - PushData.allUser.add(rs.getString(1).trim()); + PushData.allUser.add(new String[]{rs.getString(1).trim()}); currentImported++; MainWindow.mainWindow.getMemberTabCountLabel().setText(String.valueOf(currentImported)); MainWindow.mainWindow.getMemberTabImportProgressBar().setValue(currentImported); @@ -212,7 +219,9 @@ public static void getMpUserList() throws WxErrorException { List openIds = wxMpUserList.getOpenids(); PushData.allUser = Collections.synchronizedList(new ArrayList<>()); - PushData.allUser.addAll(openIds); + for (String openId : openIds) { + PushData.allUser.add(new String[]{openId}); + } importedCount += wxMpUserList.getCount(); MainWindow.mainWindow.getMemberTabCountLabel().setText(String.valueOf(importedCount)); @@ -227,8 +236,9 @@ public static void getMpUserList() throws WxErrorException { break; } openIds = wxMpUserList.getOpenids(); - - PushData.allUser.addAll(openIds); + for (String openId : openIds) { + PushData.allUser.add(new String[]{openId}); + } importedCount += wxMpUserList.getCount(); MainWindow.mainWindow.getMemberTabCountLabel().setText(String.valueOf(importedCount)); MainWindow.mainWindow.getMemberTabImportProgressBar().setValue(importedCount); From 151a044884022274b3033b8527b90c5ad74603fb Mon Sep 17 00:00:00 2001 From: zhouy Date: Tue, 6 Feb 2018 19:07:10 +0800 Subject: [PATCH 04/14] =?UTF-8?q?=E6=94=AF=E6=8C=81=E6=AF=8F=E6=9D=A1?= =?UTF-8?q?=E6=B6=88=E6=81=AF=E8=87=AA=E5=AE=9A=E4=B9=89=E5=86=85=E5=AE=B9?= =?UTF-8?q?-=E5=88=9D=E6=AD=A5=E5=AE=8C=E6=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../logic/AliTemplateMsgServiceThread.java | 15 +-- .../push/logic/KeFuMsgServiceThread.java | 11 +- .../push/logic/KeFuPriorMsgServiceThread.java | 15 ++- .../tool/wechat/push/logic/PushManage.java | 102 +++++++++++++----- .../push/logic/TemplateMsgServiceThread.java | 12 ++- 5 files changed, 110 insertions(+), 45 deletions(-) diff --git a/src/main/java/com/fangxuele/tool/wechat/push/logic/AliTemplateMsgServiceThread.java b/src/main/java/com/fangxuele/tool/wechat/push/logic/AliTemplateMsgServiceThread.java index 00ad1233..8ae93519 100644 --- a/src/main/java/com/fangxuele/tool/wechat/push/logic/AliTemplateMsgServiceThread.java +++ b/src/main/java/com/fangxuele/tool/wechat/push/logic/AliTemplateMsgServiceThread.java @@ -33,7 +33,7 @@ public void run() { TaobaoClient client = new DefaultTaobaoClient(Init.configer.getAliServerUrl(), Init.configer.getAliAppKey(), Init.configer.getAliAppSecret()); // 组织模板消息 - AlibabaAliqinFcSmsNumSendRequest alibabaAliqinFcSmsNumSendRequest = PushManage.makeAliTemplateMessage(); + AlibabaAliqinFcSmsNumSendRequest alibabaAliqinFcSmsNumSendRequest; AlibabaAliqinFcSmsNumSendResponse response; @@ -44,8 +44,11 @@ public void run() { return; } - String telNum = list.get(i)[0]; + // 本条消息所需的数据 + String[] msgData = list.get(i); + String telNum = msgData[0]; try { + alibabaAliqinFcSmsNumSendRequest = PushManage.makeAliTemplateMessage(msgData); alibabaAliqinFcSmsNumSendRequest.setRecNum(telNum); // 空跑控制 @@ -61,14 +64,14 @@ public void run() { tableModel.setValueAt(currentThreadSuccessCount, tableRow, 2); // 保存发送成功 - PushData.sendSuccessList.add(list.get(i)); + PushData.sendSuccessList.add(msgData); } else { // 总发送失败+1 PushData.increaseFail(); MainWindow.mainWindow.getPushFailCount().setText(String.valueOf(PushData.failRecords)); // 保存发送失败 - PushData.sendFailList.add(list.get(i)); + PushData.sendFailList.add(msgData); // 失败异常信息输出控制台 PushManage.console(new StringBuffer().append("发送失败:").append(response.getBody()).append(";ErrorCode:") @@ -88,7 +91,7 @@ public void run() { tableModel.setValueAt(currentThreadSuccessCount, tableRow, 2); // 保存发送成功 - PushData.sendSuccessList.add(list.get(i)); + PushData.sendSuccessList.add(msgData); } } catch (Exception e) { @@ -97,7 +100,7 @@ public void run() { MainWindow.mainWindow.getPushFailCount().setText(String.valueOf(PushData.failRecords)); // 保存发送失败 - PushData.sendFailList.add(list.get(i)); + PushData.sendFailList.add(msgData); // 失败异常信息输出控制台 PushManage.console(new StringBuffer().append("发送失败:").append(e.getMessage()).append(";telNum:").append(telNum).toString()); diff --git a/src/main/java/com/fangxuele/tool/wechat/push/logic/KeFuMsgServiceThread.java b/src/main/java/com/fangxuele/tool/wechat/push/logic/KeFuMsgServiceThread.java index 4f847a42..baddd535 100644 --- a/src/main/java/com/fangxuele/tool/wechat/push/logic/KeFuMsgServiceThread.java +++ b/src/main/java/com/fangxuele/tool/wechat/push/logic/KeFuMsgServiceThread.java @@ -26,7 +26,7 @@ public void run() { // 初始化当前线程 initCurrentThread(); - WxMpKefuMessage wxMpKefuMessage = PushManage.makeKefuMessage(); + WxMpKefuMessage wxMpKefuMessage; for (int i = 0; i < list.size(); i++) { if (!PushData.running) { @@ -35,8 +35,11 @@ public void run() { return; } - String openId = list.get(i)[0]; + // 本条消息所需的数据 + String[] msgData = list.get(i); + String openId = msgData[0]; try { + wxMpKefuMessage = PushManage.makeKefuMessage(msgData); wxMpKefuMessage.setToUser(openId); // 空跑控制 @@ -53,14 +56,14 @@ public void run() { tableModel.setValueAt(currentThreadSuccessCount, tableRow, 2); // 保存发送成功 - PushData.sendSuccessList.add(list.get(i)); + PushData.sendSuccessList.add(msgData); } catch (Exception e) { // 总发送失败+1 PushData.increaseFail(); MainWindow.mainWindow.getPushFailCount().setText(String.valueOf(PushData.failRecords)); // 保存发送失败 - PushData.sendFailList.add(list.get(i)); + PushData.sendFailList.add(msgData); // 失败异常信息输出控制台 PushManage.console(new StringBuffer().append("发送失败:").append(e.getMessage()).append(";openid:").append(openId).toString()); diff --git a/src/main/java/com/fangxuele/tool/wechat/push/logic/KeFuPriorMsgServiceThread.java b/src/main/java/com/fangxuele/tool/wechat/push/logic/KeFuPriorMsgServiceThread.java index 89089c70..51822486 100644 --- a/src/main/java/com/fangxuele/tool/wechat/push/logic/KeFuPriorMsgServiceThread.java +++ b/src/main/java/com/fangxuele/tool/wechat/push/logic/KeFuPriorMsgServiceThread.java @@ -27,8 +27,8 @@ public void run() { // 初始化当前线程 initCurrentThread(); - WxMpKefuMessage wxMpKefuMessage = PushManage.makeKefuMessage(); - WxMpTemplateMessage wxMpTemplateMessage = PushManage.makeTemplateMessage(); + WxMpKefuMessage wxMpKefuMessage; + WxMpTemplateMessage wxMpTemplateMessage; for (int i = 0; i < list.size(); i++) { if (!PushData.running) { @@ -37,8 +37,13 @@ public void run() { return; } - String openId = list.get(i)[0]; + // 本条消息所需的数据 + String[] msgData = list.get(i); + String openId = msgData[0]; try { + wxMpKefuMessage = PushManage.makeKefuMessage(msgData); + wxMpTemplateMessage = PushManage.makeTemplateMessage(msgData); + wxMpKefuMessage.setToUser(openId); wxMpTemplateMessage.setToUser(openId); try {// 空跑控制 @@ -60,14 +65,14 @@ public void run() { tableModel.setValueAt(currentThreadSuccessCount, tableRow, 2); // 保存发送成功 - PushData.sendSuccessList.add(list.get(i)); + PushData.sendSuccessList.add(msgData); } catch (Exception e) { // 总发送失败+1 PushData.increaseFail(); MainWindow.mainWindow.getPushFailCount().setText(String.valueOf(PushData.failRecords)); // 保存发送失败 - PushData.sendFailList.add(list.get(i)); + PushData.sendFailList.add(msgData); // 失败异常信息输出控制台 PushManage.console(new StringBuffer().append("发送失败:").append(e.getMessage()).append(";openid:").append(openId).toString()); diff --git a/src/main/java/com/fangxuele/tool/wechat/push/logic/PushManage.java b/src/main/java/com/fangxuele/tool/wechat/push/logic/PushManage.java index 56b16f3a..ec841a15 100644 --- a/src/main/java/com/fangxuele/tool/wechat/push/logic/PushManage.java +++ b/src/main/java/com/fangxuele/tool/wechat/push/logic/PushManage.java @@ -23,8 +23,12 @@ import java.io.File; import java.io.FileWriter; import java.io.IOException; +import java.util.ArrayList; import java.util.HashMap; +import java.util.List; import java.util.Map; +import java.util.regex.Matcher; +import java.util.regex.Pattern; /** * 推送管理 @@ -40,38 +44,43 @@ public class PushManage { * @throws Exception */ public static void preview() throws Exception { + List msgDataList = new ArrayList<>(); - WxMpTemplateMessage wxMessageTemplate = makeTemplateMessage(); - WxMpKefuMessage wxMpKefuMessage = makeKefuMessage(); + WxMpTemplateMessage wxMessageTemplate; + WxMpKefuMessage wxMpKefuMessage; WxMpService wxMpService = getWxMpService(); + for (String data : MainWindow.mainWindow.getPreviewUserField().getText().split(";")) { + msgDataList.add(data.split(",")); + } switch (MainWindow.mainWindow.getMsgTypeComboBox().getSelectedItem().toString()) { case "模板消息": - String[] toUsers = MainWindow.mainWindow.getPreviewUserField().getText().split(";"); - for (String toUser : toUsers) { - wxMessageTemplate.setToUser(toUser); + for (String[] msgData : msgDataList) { + wxMessageTemplate = makeTemplateMessage(msgData); + wxMessageTemplate.setToUser(msgData[0].trim()); // !!!发送模板消息!!! wxMpService.getTemplateMsgService().sendTemplateMsg(wxMessageTemplate); } break; case "客服消息": - toUsers = MainWindow.mainWindow.getPreviewUserField().getText().split(";"); - for (String toUser : toUsers) { - wxMpKefuMessage.setToUser(toUser); + for (String[] msgData : msgDataList) { + wxMpKefuMessage = makeKefuMessage(msgData); + wxMpKefuMessage.setToUser(msgData[0]); // !!!发送客服消息!!! wxMpService.getKefuService().sendKefuMessage(wxMpKefuMessage); } break; case "客服消息优先": - toUsers = MainWindow.mainWindow.getPreviewUserField().getText().split(";"); - for (String toUser : toUsers) { + for (String[] msgData : msgDataList) { try { - wxMpKefuMessage.setToUser(toUser); + wxMpKefuMessage = makeKefuMessage(msgData); + wxMpKefuMessage.setToUser(msgData[0]); // !!!发送客服消息!!! wxMpService.getKefuService().sendKefuMessage(wxMpKefuMessage); } catch (Exception e) { - wxMessageTemplate.setToUser(toUser); + wxMessageTemplate = makeTemplateMessage(msgData); + wxMessageTemplate.setToUser(msgData[0].trim()); // !!!发送模板消息!!! wxMpService.getTemplateMsgService().sendTemplateMsg(wxMessageTemplate); } @@ -79,14 +88,13 @@ public static void preview() throws Exception { break; case "阿里大于模板短信": TaobaoClient client = new DefaultTaobaoClient(Init.configer.getAliServerUrl(), Init.configer.getAliAppKey(), Init.configer.getAliAppSecret()); - AlibabaAliqinFcSmsNumSendRequest request = makeAliTemplateMessage(); - toUsers = MainWindow.mainWindow.getPreviewUserField().getText().split(";"); - for (String toUser : toUsers) { - request.setRecNum(toUser); + for (String[] msgData : msgDataList) { + AlibabaAliqinFcSmsNumSendRequest request = makeAliTemplateMessage(msgData); + request.setRecNum(msgData[0]); AlibabaAliqinFcSmsNumSendResponse response = client.execute(request); if (response.getResult() == null || !response.getResult().getSuccess()) { throw new Exception(new StringBuffer().append(response.getBody()).append(";\n\nErrorCode:") - .append(response.getErrorCode()).append(";\n\ntelNum:").append(toUser).toString()); + .append(response.getErrorCode()).append(";\n\ntelNum:").append(msgData[0]).toString()); } } break; @@ -98,9 +106,10 @@ public static void preview() throws Exception { /** * 组织模板消息 * + * @param msgData * @return */ - synchronized public static WxMpTemplateMessage makeTemplateMessage() { + synchronized public static WxMpTemplateMessage makeTemplateMessage(String[] msgData) { // 拼模板 WxMpTemplateMessage wxMessageTemplate = new WxMpTemplateMessage(); wxMessageTemplate.setTemplateId(MainWindow.mainWindow.getMsgTemplateIdTextField().getText()); @@ -112,7 +121,17 @@ synchronized public static WxMpTemplateMessage makeTemplateMessage() { DefaultTableModel tableModel = (DefaultTableModel) MainWindow.mainWindow.getTemplateMsgDataTable().getModel(); int rowCount = tableModel.getRowCount(); for (int i = 0; i < rowCount; i++) { - WxMpTemplateData templateData = new WxMpTemplateData((String) tableModel.getValueAt(i, 0), ((String) tableModel.getValueAt(i, 1)).replaceAll("#ENTER#", "\n"), ((String) tableModel.getValueAt(i, 2)).trim()); + String name = ((String) tableModel.getValueAt(i, 0)).trim(); + + String value = ((String) tableModel.getValueAt(i, 1)).replaceAll("#ENTER#", "\n"); + Pattern p = Pattern.compile("\\{([^{}]+)\\}"); + Matcher matcher = p.matcher(value); + while (matcher.find()) { + value = value.replace(matcher.group(0), msgData[Integer.parseInt(matcher.group(1).trim())]); + } + + String color = ((String) tableModel.getValueAt(i, 2)).trim(); + WxMpTemplateData templateData = new WxMpTemplateData(name, value, color); wxMessageTemplate.addWxMpTemplateData(templateData); } @@ -122,21 +141,43 @@ synchronized public static WxMpTemplateMessage makeTemplateMessage() { /** * 组织客服消息 * + * @param msgData * @return */ - synchronized public static WxMpKefuMessage makeKefuMessage() { + synchronized public static WxMpKefuMessage makeKefuMessage(String[] msgData) { WxMpKefuMessage kefuMessage = null; if ("图文消息".equals(MainWindow.mainWindow.getMsgKefuMsgTypeComboBox().getSelectedItem().toString())) { WxMpKefuMessage.WxArticle article = new WxMpKefuMessage.WxArticle(); - article.setTitle(MainWindow.mainWindow.getMsgKefuMsgTitleTextField().getText()); + + // 标题 + String title = MainWindow.mainWindow.getMsgKefuMsgTitleTextField().getText(); + Pattern p = Pattern.compile("\\{([^{}]+)\\}"); + Matcher matcher = p.matcher(title); + while (matcher.find()) { + title = title.replace(matcher.group(0), msgData[Integer.parseInt(matcher.group(1).trim())]); + } + article.setTitle(title); + + // 图片url article.setPicUrl(MainWindow.mainWindow.getMsgKefuPicUrlTextField().getText()); - article.setDescription(MainWindow.mainWindow.getMsgKefuDescTextField().getText()); + + // 描述 + String description = MainWindow.mainWindow.getMsgKefuDescTextField().getText(); + p = Pattern.compile("\\{([^{}]+)\\}"); + matcher = p.matcher(description); + while (matcher.find()) { + description = description.replace(matcher.group(0), msgData[Integer.parseInt(matcher.group(1).trim())]); + } + article.setDescription(description); + + // 跳转url article.setUrl(MainWindow.mainWindow.getMsgKefuUrlTextField().getText()); + kefuMessage = WxMpKefuMessage.NEWS().addArticle(article).build(); } else if ("文本消息".equals(MainWindow.mainWindow.getMsgKefuMsgTypeComboBox().getSelectedItem().toString())) { - kefuMessage = WxMpKefuMessage.TEXT() - .content(MainWindow.mainWindow.getMsgKefuMsgTitleTextField().getText()).build(); + String content = MainWindow.mainWindow.getMsgKefuMsgTitleTextField().getText(); + kefuMessage = WxMpKefuMessage.TEXT().content(content).build(); } return kefuMessage; @@ -145,9 +186,10 @@ synchronized public static WxMpKefuMessage makeKefuMessage() { /** * 组织阿里大于模板短信消息 * + * @param msgData * @return */ - synchronized public static AlibabaAliqinFcSmsNumSendRequest makeAliTemplateMessage() { + synchronized public static AlibabaAliqinFcSmsNumSendRequest makeAliTemplateMessage(String[] msgData) { AlibabaAliqinFcSmsNumSendRequest request = new AlibabaAliqinFcSmsNumSendRequest(); // 用户可以根据该会员ID识别是哪位会员使用了你的应用 request.setExtend("WePush"); @@ -164,7 +206,15 @@ synchronized public static AlibabaAliqinFcSmsNumSendRequest makeAliTemplateMessa DefaultTableModel tableModel = (DefaultTableModel) MainWindow.mainWindow.getTemplateMsgDataTable().getModel(); int rowCount = tableModel.getRowCount(); for (int i = 0; i < rowCount; i++) { - paramMap.put((String) tableModel.getValueAt(i, 0), ((String) tableModel.getValueAt(i, 1)).replaceAll("#ENTER#", "\n")); + String key = (String) tableModel.getValueAt(i, 0); + String value = ((String) tableModel.getValueAt(i, 1)).replaceAll("#ENTER#", "\n"); + Pattern p = Pattern.compile("\\{([^{}]+)\\}"); + Matcher matcher = p.matcher(value); + while (matcher.find()) { + value = value.replace(matcher.group(0), msgData[Integer.parseInt(matcher.group(1).trim())]); + } + + paramMap.put(key, value); } request.setSmsParamString(JSONUtil.parseFromMap(paramMap).toJSONString(0)); diff --git a/src/main/java/com/fangxuele/tool/wechat/push/logic/TemplateMsgServiceThread.java b/src/main/java/com/fangxuele/tool/wechat/push/logic/TemplateMsgServiceThread.java index ed6c7fe3..94cee0ed 100644 --- a/src/main/java/com/fangxuele/tool/wechat/push/logic/TemplateMsgServiceThread.java +++ b/src/main/java/com/fangxuele/tool/wechat/push/logic/TemplateMsgServiceThread.java @@ -27,7 +27,7 @@ public void run() { initCurrentThread(); // 组织模板消息 - WxMpTemplateMessage wxMessageTemplate = PushManage.makeTemplateMessage(); + WxMpTemplateMessage wxMessageTemplate; for (int i = 0; i < list.size(); i++) { if (!PushData.running) { @@ -36,8 +36,12 @@ public void run() { return; } - String openId = list.get(i)[0]; + // 本条消息所需的数据 + String[] msgData = list.get(i); + String openId = msgData[0]; try { + wxMessageTemplate = PushManage.makeTemplateMessage(msgData); + wxMessageTemplate.setToUser(openId); // 空跑控制 @@ -54,14 +58,14 @@ public void run() { tableModel.setValueAt(currentThreadSuccessCount, tableRow, 2); // 保存发送成功 - PushData.sendSuccessList.add(list.get(i)); + PushData.sendSuccessList.add(msgData); } catch (Exception e) { // 总发送失败+1 PushData.increaseFail(); MainWindow.mainWindow.getPushFailCount().setText(String.valueOf(PushData.failRecords)); // 保存发送失败 - PushData.sendFailList.add(list.get(i)); + PushData.sendFailList.add(msgData); // 失败异常信息输出控制台 PushManage.console(new StringBuffer().append("发送失败:").append(e.getMessage()).append(";openid:").append(openId).toString()); From 6f879b309057b8856dc1c6335334794e1c0f5bf2 Mon Sep 17 00:00:00 2001 From: zhouy Date: Wed, 7 Feb 2018 11:13:27 +0800 Subject: [PATCH 05/14] =?UTF-8?q?=E6=8D=A2=E8=A1=8C=E7=AC=A6=E8=A7=84?= =?UTF-8?q?=E5=88=99=E5=8F=98=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/fangxuele/tool/wechat/push/logic/PushManage.java | 4 ++-- .../java/com/fangxuele/tool/wechat/push/ui/MainWindow.form | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/fangxuele/tool/wechat/push/logic/PushManage.java b/src/main/java/com/fangxuele/tool/wechat/push/logic/PushManage.java index ec841a15..28b0c64f 100644 --- a/src/main/java/com/fangxuele/tool/wechat/push/logic/PushManage.java +++ b/src/main/java/com/fangxuele/tool/wechat/push/logic/PushManage.java @@ -123,7 +123,7 @@ synchronized public static WxMpTemplateMessage makeTemplateMessage(String[] msgD for (int i = 0; i < rowCount; i++) { String name = ((String) tableModel.getValueAt(i, 0)).trim(); - String value = ((String) tableModel.getValueAt(i, 1)).replaceAll("#ENTER#", "\n"); + String value = ((String) tableModel.getValueAt(i, 1)).replaceAll("$ENTER$", "\n"); Pattern p = Pattern.compile("\\{([^{}]+)\\}"); Matcher matcher = p.matcher(value); while (matcher.find()) { @@ -207,7 +207,7 @@ synchronized public static AlibabaAliqinFcSmsNumSendRequest makeAliTemplateMessa int rowCount = tableModel.getRowCount(); for (int i = 0; i < rowCount; i++) { String key = (String) tableModel.getValueAt(i, 0); - String value = ((String) tableModel.getValueAt(i, 1)).replaceAll("#ENTER#", "\n"); + String value = ((String) tableModel.getValueAt(i, 1)).replaceAll("$ENTER$", "\n"); Pattern p = Pattern.compile("\\{([^{}]+)\\}"); Matcher matcher = p.matcher(value); while (matcher.find()) { diff --git a/src/main/java/com/fangxuele/tool/wechat/push/ui/MainWindow.form b/src/main/java/com/fangxuele/tool/wechat/push/ui/MainWindow.form index 5f499562..6b479a44 100644 --- a/src/main/java/com/fangxuele/tool/wechat/push/ui/MainWindow.form +++ b/src/main/java/com/fangxuele/tool/wechat/push/ui/MainWindow.form @@ -3,7 +3,7 @@ - + @@ -264,7 +264,7 @@ - + From 111f3a0f2fdff84cf58530e1d96d20f0fc8914a2 Mon Sep 17 00:00:00 2001 From: zhouy Date: Wed, 7 Feb 2018 11:32:35 +0800 Subject: [PATCH 06/14] =?UTF-8?q?=E6=A8=A1=E6=9D=BF=E6=B6=88=E6=81=AF?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0NickName=E5=85=AC=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../tool/wechat/push/logic/PushManage.java | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/fangxuele/tool/wechat/push/logic/PushManage.java b/src/main/java/com/fangxuele/tool/wechat/push/logic/PushManage.java index 28b0c64f..fb9636a7 100644 --- a/src/main/java/com/fangxuele/tool/wechat/push/logic/PushManage.java +++ b/src/main/java/com/fangxuele/tool/wechat/push/logic/PushManage.java @@ -11,6 +11,7 @@ import com.xiaoleilu.hutool.json.JSONUtil; import com.xiaoleilu.hutool.log.Log; import com.xiaoleilu.hutool.log.LogFactory; +import me.chanjar.weixin.common.exception.WxErrorException; import me.chanjar.weixin.mp.api.WxMpConfigStorage; import me.chanjar.weixin.mp.api.WxMpInMemoryConfigStorage; import me.chanjar.weixin.mp.api.WxMpService; @@ -109,7 +110,7 @@ public static void preview() throws Exception { * @param msgData * @return */ - synchronized public static WxMpTemplateMessage makeTemplateMessage(String[] msgData) { + synchronized public static WxMpTemplateMessage makeTemplateMessage(String[] msgData) throws WxErrorException { // 拼模板 WxMpTemplateMessage wxMessageTemplate = new WxMpTemplateMessage(); wxMessageTemplate.setTemplateId(MainWindow.mainWindow.getMsgTemplateIdTextField().getText()); @@ -123,13 +124,24 @@ synchronized public static WxMpTemplateMessage makeTemplateMessage(String[] msgD for (int i = 0; i < rowCount; i++) { String name = ((String) tableModel.getValueAt(i, 0)).trim(); - String value = ((String) tableModel.getValueAt(i, 1)).replaceAll("$ENTER$", "\n"); + String value = ((String) tableModel.getValueAt(i, 1)).replaceAll("\\$ENTER\\$", "\n"); Pattern p = Pattern.compile("\\{([^{}]+)\\}"); Matcher matcher = p.matcher(value); while (matcher.find()) { value = value.replace(matcher.group(0), msgData[Integer.parseInt(matcher.group(1).trim())]); } + p = Pattern.compile("\\$([^$]+)\\$"); + matcher = p.matcher(value); + while (matcher.find()) { + String str = matcher.group(0); + if (str.startsWith("$NICK_NAME")) { + WxMpService wxMpService = getWxMpService(); + String nickName = wxMpService.getUserService().userInfo(msgData[0]).getNickname(); + value = value.replace(str, nickName); + } + } + String color = ((String) tableModel.getValueAt(i, 2)).trim(); WxMpTemplateData templateData = new WxMpTemplateData(name, value, color); wxMessageTemplate.addWxMpTemplateData(templateData); From 560c9952d79e137adac67140ad9127bec7936027 Mon Sep 17 00:00:00 2001 From: zhouy Date: Wed, 7 Feb 2018 13:59:17 +0800 Subject: [PATCH 07/14] =?UTF-8?q?=E5=AE=A2=E6=9C=8D=E6=B6=88=E6=81=AF?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0NickName=E5=85=AC=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../tool/wechat/push/logic/PushManage.java | 41 ++++++++++++++++++- 1 file changed, 39 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/fangxuele/tool/wechat/push/logic/PushManage.java b/src/main/java/com/fangxuele/tool/wechat/push/logic/PushManage.java index fb9636a7..9e60d81d 100644 --- a/src/main/java/com/fangxuele/tool/wechat/push/logic/PushManage.java +++ b/src/main/java/com/fangxuele/tool/wechat/push/logic/PushManage.java @@ -110,7 +110,7 @@ public static void preview() throws Exception { * @param msgData * @return */ - synchronized public static WxMpTemplateMessage makeTemplateMessage(String[] msgData) throws WxErrorException { + synchronized public static WxMpTemplateMessage makeTemplateMessage(String[] msgData) { // 拼模板 WxMpTemplateMessage wxMessageTemplate = new WxMpTemplateMessage(); wxMessageTemplate.setTemplateId(MainWindow.mainWindow.getMsgTemplateIdTextField().getText()); @@ -137,7 +137,12 @@ synchronized public static WxMpTemplateMessage makeTemplateMessage(String[] msgD String str = matcher.group(0); if (str.startsWith("$NICK_NAME")) { WxMpService wxMpService = getWxMpService(); - String nickName = wxMpService.getUserService().userInfo(msgData[0]).getNickname(); + String nickName = ""; + try { + nickName = wxMpService.getUserService().userInfo(msgData[0]).getNickname(); + } catch (WxErrorException e) { + e.printStackTrace(); + } value = value.replace(str, nickName); } } @@ -169,6 +174,22 @@ synchronized public static WxMpKefuMessage makeKefuMessage(String[] msgData) { while (matcher.find()) { title = title.replace(matcher.group(0), msgData[Integer.parseInt(matcher.group(1).trim())]); } + + p = Pattern.compile("\\$([^$]+)\\$"); + matcher = p.matcher(title); + while (matcher.find()) { + String str = matcher.group(0); + if (str.startsWith("$NICK_NAME")) { + WxMpService wxMpService = getWxMpService(); + String nickName = null; + try { + nickName = wxMpService.getUserService().userInfo(msgData[0]).getNickname(); + } catch (WxErrorException e) { + e.printStackTrace(); + } + title = title.replace(str, nickName); + } + } article.setTitle(title); // 图片url @@ -181,6 +202,22 @@ synchronized public static WxMpKefuMessage makeKefuMessage(String[] msgData) { while (matcher.find()) { description = description.replace(matcher.group(0), msgData[Integer.parseInt(matcher.group(1).trim())]); } + + p = Pattern.compile("\\$([^$]+)\\$"); + matcher = p.matcher(description); + while (matcher.find()) { + String str = matcher.group(0); + if (str.startsWith("$NICK_NAME")) { + WxMpService wxMpService = getWxMpService(); + String nickName = null; + try { + nickName = wxMpService.getUserService().userInfo(msgData[0]).getNickname(); + } catch (WxErrorException e) { + e.printStackTrace(); + } + description = description.replace(str, nickName); + } + } article.setDescription(description); // 跳转url From 8e07cabf2ba6a2065bd835dabae5dd7ad8022204 Mon Sep 17 00:00:00 2001 From: zhouy Date: Wed, 7 Feb 2018 14:11:12 +0800 Subject: [PATCH 08/14] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E4=BB=8Ecsv=E5=AF=BC?= =?UTF-8?q?=E5=85=A5=E6=95=B0=E6=8D=AE=E4=B8=AD=E6=96=87=E4=B9=B1=E7=A0=81?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../tool/wechat/push/ui/listener/MemberListener.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/fangxuele/tool/wechat/push/ui/listener/MemberListener.java b/src/main/java/com/fangxuele/tool/wechat/push/ui/listener/MemberListener.java index 180b5027..7ca64f6b 100644 --- a/src/main/java/com/fangxuele/tool/wechat/push/ui/listener/MemberListener.java +++ b/src/main/java/com/fangxuele/tool/wechat/push/ui/listener/MemberListener.java @@ -18,8 +18,11 @@ import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.io.BufferedReader; +import java.io.DataInputStream; import java.io.File; +import java.io.FileInputStream; import java.io.IOException; +import java.io.InputStreamReader; import java.sql.ResultSet; import java.util.ArrayList; import java.util.Collections; @@ -44,7 +47,9 @@ public static void addListeners() { try { MainWindow.mainWindow.getMemberTabImportProgressBar().setIndeterminate(true); if (file.getName().endsWith(".csv")) { - reader = new CSVReader(new java.io.FileReader(file)); + // 可以解决中文乱码问题 + DataInputStream in = new DataInputStream(new FileInputStream(file)); + reader = new CSVReader(new InputStreamReader(in, "utf-8")); String[] nextLine; PushData.allUser = Collections.synchronizedList(new ArrayList<>()); while ((nextLine = reader.readNext()) != null) { From e790b1d43c343b15b1a9d33145d9a5db50719a6b Mon Sep 17 00:00:00 2001 From: zhouy Date: Wed, 7 Feb 2018 14:30:19 +0800 Subject: [PATCH 09/14] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E4=BB=8Ecsv=E5=AF=BC?= =?UTF-8?q?=E5=85=A5=E6=95=B0=E6=8D=AE=E4=B8=AD=E6=96=87=E4=B9=B1=E7=A0=81?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../tool/wechat/push/ui/listener/MemberListener.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/fangxuele/tool/wechat/push/ui/listener/MemberListener.java b/src/main/java/com/fangxuele/tool/wechat/push/ui/listener/MemberListener.java index 7ca64f6b..c2525364 100644 --- a/src/main/java/com/fangxuele/tool/wechat/push/ui/listener/MemberListener.java +++ b/src/main/java/com/fangxuele/tool/wechat/push/ui/listener/MemberListener.java @@ -132,7 +132,9 @@ public static void addListeners() { try { MainWindow.mainWindow.getMemberTabImportProgressBar().setIndeterminate(true); - reader = new CSVReader(new java.io.FileReader(file)); + // 可以解决中文乱码问题 + DataInputStream in = new DataInputStream(new FileInputStream(file)); + reader = new CSVReader(new InputStreamReader(in, "utf-8")); String[] nextLine; PushData.allUser = Collections.synchronizedList(new ArrayList<>()); while ((nextLine = reader.readNext()) != null) { From 68261341191bea8d44180ca333088345c9fa87d3 Mon Sep 17 00:00:00 2001 From: zhouy Date: Wed, 7 Feb 2018 15:23:03 +0800 Subject: [PATCH 10/14] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=AE=A2=E6=9C=8D?= =?UTF-8?q?=E6=B6=88=E6=81=AF=E5=92=8C=E6=A8=A1=E6=9D=BF=E6=B6=88=E6=81=AF?= =?UTF-8?q?=E7=9A=84=E7=A9=BA=E8=B7=91=E6=A8=A1=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../tool/wechat/push/logic/KeFuMsgServiceThread.java | 5 ++--- .../tool/wechat/push/logic/TemplateMsgServiceThread.java | 6 ++---- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/fangxuele/tool/wechat/push/logic/KeFuMsgServiceThread.java b/src/main/java/com/fangxuele/tool/wechat/push/logic/KeFuMsgServiceThread.java index baddd535..99495101 100644 --- a/src/main/java/com/fangxuele/tool/wechat/push/logic/KeFuMsgServiceThread.java +++ b/src/main/java/com/fangxuele/tool/wechat/push/logic/KeFuMsgServiceThread.java @@ -39,11 +39,10 @@ public void run() { String[] msgData = list.get(i); String openId = msgData[0]; try { - wxMpKefuMessage = PushManage.makeKefuMessage(msgData); - wxMpKefuMessage.setToUser(openId); - // 空跑控制 if (!MainWindow.mainWindow.getDryRunCheckBox().isSelected()) { + wxMpKefuMessage = PushManage.makeKefuMessage(msgData); + wxMpKefuMessage.setToUser(openId); wxMpService.getKefuService().sendKefuMessage(wxMpKefuMessage); } diff --git a/src/main/java/com/fangxuele/tool/wechat/push/logic/TemplateMsgServiceThread.java b/src/main/java/com/fangxuele/tool/wechat/push/logic/TemplateMsgServiceThread.java index 94cee0ed..3ab960e6 100644 --- a/src/main/java/com/fangxuele/tool/wechat/push/logic/TemplateMsgServiceThread.java +++ b/src/main/java/com/fangxuele/tool/wechat/push/logic/TemplateMsgServiceThread.java @@ -40,12 +40,10 @@ public void run() { String[] msgData = list.get(i); String openId = msgData[0]; try { - wxMessageTemplate = PushManage.makeTemplateMessage(msgData); - - wxMessageTemplate.setToUser(openId); - // 空跑控制 if (!MainWindow.mainWindow.getDryRunCheckBox().isSelected()) { + wxMessageTemplate = PushManage.makeTemplateMessage(msgData); + wxMessageTemplate.setToUser(openId); wxMpService.getTemplateMsgService().sendTemplateMsg(wxMessageTemplate); } From 07cdea5ed86bb8a8e4c4ff551dff3b4fa64a657d Mon Sep 17 00:00:00 2001 From: zhouy Date: Wed, 7 Feb 2018 15:37:40 +0800 Subject: [PATCH 11/14] =?UTF-8?q?=E5=AF=BC=E5=85=A5=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E8=BF=9B=E5=BA=A6=E6=9D=A1=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../wechat/push/ui/listener/MemberListener.java | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/fangxuele/tool/wechat/push/ui/listener/MemberListener.java b/src/main/java/com/fangxuele/tool/wechat/push/ui/listener/MemberListener.java index c2525364..3e2d3e62 100644 --- a/src/main/java/com/fangxuele/tool/wechat/push/ui/listener/MemberListener.java +++ b/src/main/java/com/fangxuele/tool/wechat/push/ui/listener/MemberListener.java @@ -56,7 +56,6 @@ public static void addListeners() { PushData.allUser.add(nextLine); currentImported++; MainWindow.mainWindow.getMemberTabCountLabel().setText(String.valueOf(currentImported)); - MainWindow.mainWindow.getMemberTabImportProgressBar().setValue(currentImported); } } else { fileReader = new FileReader(file); @@ -67,9 +66,10 @@ public static void addListeners() { PushData.allUser.add(line.split(",")); currentImported++; MainWindow.mainWindow.getMemberTabCountLabel().setText(String.valueOf(currentImported)); - MainWindow.mainWindow.getMemberTabImportProgressBar().setValue(currentImported); } } + MainWindow.mainWindow.getMemberTabImportProgressBar().setMaximum(100); + MainWindow.mainWindow.getMemberTabImportProgressBar().setValue(100); MainWindow.mainWindow.getMemberTabImportProgressBar().setIndeterminate(false); JOptionPane.showMessageDialog(MainWindow.mainWindow.getMemberPanel(), "导入完成!", "完成", JOptionPane.INFORMATION_MESSAGE); @@ -82,6 +82,8 @@ public static void addListeners() { logger.error(e1); e1.printStackTrace(); } finally { + MainWindow.mainWindow.getMemberTabImportProgressBar().setMaximum(100); + MainWindow.mainWindow.getMemberTabImportProgressBar().setValue(100); MainWindow.mainWindow.getMemberTabImportProgressBar().setIndeterminate(false); if (reader != null) { try { @@ -141,8 +143,9 @@ public static void addListeners() { PushData.allUser.add(nextLine); currentImported++; MainWindow.mainWindow.getMemberTabCountLabel().setText(String.valueOf(currentImported)); - MainWindow.mainWindow.getMemberTabImportProgressBar().setValue(currentImported); } + MainWindow.mainWindow.getMemberTabImportProgressBar().setMaximum(100); + MainWindow.mainWindow.getMemberTabImportProgressBar().setValue(100); MainWindow.mainWindow.getMemberTabImportProgressBar().setIndeterminate(false); JOptionPane.showMessageDialog(MainWindow.mainWindow.getMemberPanel(), "导入完成!", "完成", JOptionPane.INFORMATION_MESSAGE); @@ -152,6 +155,8 @@ public static void addListeners() { logger.error(e1); e1.printStackTrace(); } finally { + MainWindow.mainWindow.getMemberTabImportProgressBar().setMaximum(100); + MainWindow.mainWindow.getMemberTabImportProgressBar().setValue(100); MainWindow.mainWindow.getMemberTabImportProgressBar().setIndeterminate(false); if (reader != null) { try { @@ -184,7 +189,6 @@ public static void addListeners() { PushData.allUser.add(new String[]{rs.getString(1).trim()}); currentImported++; MainWindow.mainWindow.getMemberTabCountLabel().setText(String.valueOf(currentImported)); - MainWindow.mainWindow.getMemberTabImportProgressBar().setValue(currentImported); } JOptionPane.showMessageDialog(MainWindow.mainWindow.getMemberPanel(), "导入完成!", "完成", @@ -200,6 +204,8 @@ public static void addListeners() { } finally { MainWindow.mainWindow.getImportFromSqlButton().setEnabled(true); MainWindow.mainWindow.getImportFromSqlButton().updateUI(); + MainWindow.mainWindow.getMemberTabImportProgressBar().setMaximum(100); + MainWindow.mainWindow.getMemberTabImportProgressBar().setValue(100); MainWindow.mainWindow.getMemberTabImportProgressBar().setIndeterminate(false); } } From a0ae843a2da6113611ccb37d76d4152970f5f1db Mon Sep 17 00:00:00 2001 From: zhouy Date: Wed, 7 Feb 2018 17:54:34 +0800 Subject: [PATCH 12/14] =?UTF-8?q?=E6=96=B0=E7=89=88=E6=89=93=E5=8C=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From fc031d297fb81904a5931df625c0bef2b07b9620 Mon Sep 17 00:00:00 2001 From: zhouy Date: Wed, 7 Feb 2018 17:57:19 +0800 Subject: [PATCH 13/14] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E7=89=88=E6=9C=AC?= =?UTF-8?q?=E5=8F=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/fangxuele/tool/wechat/push/ui/ConstantsUI.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/fangxuele/tool/wechat/push/ui/ConstantsUI.java b/src/main/java/com/fangxuele/tool/wechat/push/ui/ConstantsUI.java index 9a81c1d8..48dc0d09 100644 --- a/src/main/java/com/fangxuele/tool/wechat/push/ui/ConstantsUI.java +++ b/src/main/java/com/fangxuele/tool/wechat/push/ui/ConstantsUI.java @@ -14,7 +14,7 @@ public class ConstantsUI { * 软件名称,版本 */ public final static String APP_NAME = "WePush"; - public final static String APP_VERSION = "v_1.2.0_170831"; + public final static String APP_VERSION = "v_1.3.0_180207"; /** * 主窗口图标 From 82d0e6a175ad9dd20b25a8a85ca9519286a514f1 Mon Sep 17 00:00:00 2001 From: zhouy Date: Wed, 7 Feb 2018 18:22:04 +0800 Subject: [PATCH 14/14] =?UTF-8?q?=E6=96=B0=E7=89=88=E6=89=93=E5=8C=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit