Commit ecc78325 by 田超

欢迎语的问题

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