Commit ecc78325 by 田超

欢迎语的问题

parent f9e0f08a
...@@ -40,10 +40,7 @@ import org.springframework.stereotype.Component; ...@@ -40,10 +40,7 @@ import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.ArrayList; import java.util.*;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/** /**
* @author lily * @author lily
...@@ -187,13 +184,19 @@ public class GroupQrcodeBizImpl implements GroupQrcodeBiz { ...@@ -187,13 +184,19 @@ public class GroupQrcodeBizImpl implements GroupQrcodeBiz {
//将二维码修改为已满群状态 //将二维码修改为已满群状态
changeToOverNumber(groupQrcodeDTO.getWeixinQrcodeId(), groupQrcodeDTO.getId()); changeToOverNumber(groupQrcodeDTO.getWeixinQrcodeId(), groupQrcodeDTO.getId());
} }
// List<String> nickNames = JedisClusterUtils.getJsonList("BOOK:WEIXINGROUP:GUIDEUSER" + weixinGroupId, String.class);
// if(ListUtils.isEmpty(nickNames) && !StringUtil.isEmpty(nickName)){ Map<String,Integer> nickNames = JedisClusterUtils.getJson("BOOK:WEIXINGROUP:GUIDEUSER" + weixinGroupId, Map.class);
// nickNames = new ArrayList<>(); if(nickNames==null){
// nickNames.add(nickName); nickNames = new HashMap<>();
// JedisClusterUtils.setJsonList("BOOK:WEIXINGROUP:GUIDEUSER" + weixinGroupId, nickNames, 600); nickNames.put(nickName,0);
// } JedisClusterUtils.setJson("BOOK:WEIXINGROUP:GUIDEUSER" + weixinGroupId, nickNames, 600);
}else{
nickNames.put(nickName,0);
}
String value = JedisClusterUtils.getJson("BOOK:WEIXINGROUP:GUIDE" + weixinGroupId, String.class); String value = JedisClusterUtils.getJson("BOOK:WEIXINGROUP:GUIDE" + weixinGroupId, String.class);
if (StringUtil.isEmpty(value)) { if (StringUtil.isEmpty(value)) {
JedisClusterUtils.setJson("BOOK:WEIXINGROUP:GUIDE" + weixinGroupId, weixinGroupId, 5); JedisClusterUtils.setJson("BOOK:WEIXINGROUP:GUIDE" + weixinGroupId, weixinGroupId, 5);
} else { } else {
......
...@@ -25,8 +25,7 @@ import org.apache.commons.lang3.StringUtils; ...@@ -25,8 +25,7 @@ import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import java.util.ArrayList; import java.util.*;
import java.util.List;
/** /**
* @author lily * @author lily
...@@ -284,17 +283,33 @@ public class SendWeixinRequestTools { ...@@ -284,17 +283,33 @@ public class SendWeixinRequestTools {
public static void sendDefaultMessage(String groupName, String robotId, String weixinGroupId) { public static void sendDefaultMessage(String groupName, String robotId, String weixinGroupId) {
String content = ""; String content = "";
// List<String> nickNames = JedisClusterUtils.getJsonList("BOOK:WEIXINGROUP:GUIDEUSER" + weixinGroupId, String.class); Map<String,Integer> nickNames = JedisClusterUtils.getJson("BOOK:WEIXINGROUP:GUIDEUSER" + weixinGroupId, Map.class);
// if(!ListUtils.isEmpty(nickNames)){ int i=0;
// JedisClusterUtils.del("BOOK:WEIXINGROUP:GUIDEUSER" + weixinGroupId); List<String>names = new ArrayList<>();
// } Set<Map.Entry<String, Integer>> entries = nickNames.entrySet();
// for (String nickName : nickNames) { for(Iterator<Map.Entry<String, Integer>> iterator = entries.iterator(); iterator.hasNext();){
// content = content + "@" + nickName + " "; if(i==5){
// } break;
}
Map.Entry<String, Integer> entry = iterator.next();
String key=entry.getKey();
Integer value=entry.getValue();
if(value==1){
continue;
}
names.add(key);
i++;
}
for (String nickName : names) {
nickNames.remove(nickName);
content = content + "@" + nickName + " ";
}
JedisClusterUtils.setJson("BOOK:WEIXINGROUP:GUIDEUSER" + weixinGroupId,nickNames);
if (StringUtil.isEmpty(groupName)) { if (StringUtil.isEmpty(groupName)) {
content = "欢迎加入本群,凭以下关键词领取任务或资源:"; content += ",欢迎加入本群,凭以下关键词领取任务或资源:";
} else { } else {
content = "欢迎加入" + groupName + "!凭以下关键词领取任务或资源:"; content += ",欢迎加入" + groupName + "!凭以下关键词领取任务或资源:";
} }
SendTextMessageVO sendTextMessageVO = new SendTextMessageVO(); SendTextMessageVO sendTextMessageVO = new SendTextMessageVO();
sendTextMessageVO.setContent(content); sendTextMessageVO.setContent(content);
......
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