Skip to content

Commit

Permalink
Merge pull request #48 from rememberber/develop
Browse files Browse the repository at this point in the history
 按公众号标签导入用户时,支持导入多个标签内的用户并去重
  • Loading branch information
rememberber authored Apr 1, 2018
2 parents 6c9a04b + edc4b84 commit 4518ef1
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public class ConstantsUI {
* 软件名称,版本
*/
public final static String APP_NAME = "WePush";
public final static String APP_VERSION = "v_2.0.0_180319";
public final static String APP_VERSION = "v_2.0.1_180401";

/**
* 主窗口图标
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,10 @@
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;

/**
* 准备目标数据tab相关事件监听
Expand All @@ -44,6 +46,11 @@ public class MemberListener {

private static Map<String, Long> userTagMap = new HashMap<>();

/**
* 用于导入多个标签的用户时去重判断
*/
private static Set<String> tagUserSet;

public static void addListeners() {
// 从文件导入按钮事件
MainWindow.mainWindow.getImportFromFileButton().addActionListener(e -> new Thread(() -> {
Expand Down Expand Up @@ -161,7 +168,7 @@ public static void addListeners() {
}

} catch (WxErrorException e1) {
JOptionPane.showMessageDialog(MainWindow.mainWindow.getMemberPanel(), "刷新失败!", "失败",
JOptionPane.showMessageDialog(MainWindow.mainWindow.getMemberPanel(), "刷新失败!\n\n" + e1.getMessage(), "失败",
JOptionPane.ERROR_MESSAGE);
logger.error(e1);
e1.printStackTrace();
Expand Down Expand Up @@ -201,6 +208,7 @@ public static void addListeners() {
PushData.allUser.clear();
MainWindow.mainWindow.getMemberTabCountLabel().setText("0");
}
tagUserSet = null;
}
});

Expand Down Expand Up @@ -387,29 +395,42 @@ public static void getMpUserListByTag(Long tagId) throws WxErrorException {

MainWindow.mainWindow.getMemberTabImportProgressBar().setIndeterminate(false);
MainWindow.mainWindow.getMemberTabImportProgressBar().setMaximum((int) wxTagListUser.getCount());
int importedCount = 0;
PushData.allUser = Collections.synchronizedList(new ArrayList<>());
int progressValue = 0;

if (PushData.allUser == null) {
PushData.allUser = Collections.synchronizedList(new ArrayList<>());
}

if (tagUserSet == null) {
tagUserSet = Collections.synchronizedSet(new HashSet<>());
}

int importedCount = PushData.allUser.size();

if (wxTagListUser.getCount() == 0) {
MainWindow.mainWindow.getMemberTabCountLabel().setText(String.valueOf(importedCount));
MainWindow.mainWindow.getMemberTabImportProgressBar().setValue(importedCount);
MainWindow.mainWindow.getMemberTabImportProgressBar().setValue(progressValue);
return;
}

List<String> openIds = wxTagListUser.getData().getOpenidList();

for (String openId : openIds) {
PushData.allUser.add(new String[]{openId});
importedCount++;
MainWindow.mainWindow.getMemberTabCountLabel().setText(String.valueOf(importedCount));
MainWindow.mainWindow.getMemberTabImportProgressBar().setValue(importedCount);
if (!tagUserSet.contains(openId)) {
PushData.allUser.add(new String[]{openId});
tagUserSet.add(openId);
importedCount++;
MainWindow.mainWindow.getMemberTabCountLabel().setText(String.valueOf(importedCount));
}
progressValue++;
MainWindow.mainWindow.getMemberTabImportProgressBar().setValue(progressValue);
}

while (StringUtils.isNotEmpty(wxTagListUser.getNextOpenid())) {
wxTagListUser = wxMpService.getUserTagService().tagListUser(tagId, wxTagListUser.getNextOpenid());

MainWindow.mainWindow.getMemberTabImportProgressBar().setMaximum((int) wxTagListUser.getCount());
int progressValue = 0;
progressValue = 0;
MainWindow.mainWindow.getMemberTabImportProgressBar().setValue(progressValue);
PushManage.console("拉取的OPENID个数:" + wxTagListUser.getCount());

Expand All @@ -418,14 +439,14 @@ public static void getMpUserListByTag(Long tagId) throws WxErrorException {
}
openIds = wxTagListUser.getData().getOpenidList();
for (String openId : openIds) {
PushData.allUser.add(new String[]{openId});
importedCount++;
if (!tagUserSet.contains(openId)) {
PushData.allUser.add(new String[]{openId});
importedCount++;
MainWindow.mainWindow.getMemberTabCountLabel().setText(String.valueOf(importedCount));
}
progressValue++;
MainWindow.mainWindow.getMemberTabCountLabel().setText(String.valueOf(importedCount));
MainWindow.mainWindow.getMemberTabImportProgressBar().setValue(progressValue);
}

}

}
}
10 changes: 8 additions & 2 deletions src/main/resources/version_summary.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"currentVersion": "v_2.0.0_180319",
"currentVersion": "v_2.0.1_180401",
"versionIndex": {
"v_1.1.0_170701": "0",
"v_1.2.0_170831": "1",
Expand All @@ -11,7 +11,8 @@
"v_1.8.0_180226": "7",
"v_1.9.0_180228": "8",
"v_1.10.0_180316": "9",
"v_2.0.0_180319": "10"
"v_2.0.0_180319": "10",
"v_2.0.1_180401": "11"
},
"versionDetailList": [
{
Expand Down Expand Up @@ -68,6 +69,11 @@
"version": "v_2.0.0_180319",
"title": "新增支持通过excel导入目标用户和数据",
"log": "1.新增支持通过excel导入目标用户和数据~\n2.其他细节优化\n"
},
{
"version": "v_2.0.1_180401",
"title": "按公众号标签导入用户时,支持导入多个标签内的用户并去重",
"log": "1.新增按公众号标签导入用户时,支持导入多个标签内的用户并去重\n"
}
]
}

0 comments on commit 4518ef1

Please sign in to comment.