Commit 3089b311 by 阮思源

修改,特殊字符优先

parent 02d91d38
......@@ -546,28 +546,31 @@ public class PersonalStageBizImpl implements PersonalStageBiz {
@ParamLog("替换用户输入内容")
private List<PersonalStageReplyItem> replaceUserSendContent(List<PersonalStageReplyItem> items, List<Long> ids, String userSendContent, String robotId, String userWxId, String ip) {
//如果用户没有输入文本
if (StringUtil.isEmpty(userSendContent)){
List<PersonalStageReplyItem> itemNew=new ArrayList<>();
//找一个不带占位符的
List<PersonalStageReplyItem> replyItems = personalStageReplyItemDao.getListByReplyIds(ids);
Map<Long,List<PersonalStageReplyItem>> map=replyItems.stream().collect(Collectors.groupingBy(PersonalStageReplyItem::getPersonalStageReplyId));
List<Long> idsNew=new ArrayList<>();
for (Long id:ids){
List<PersonalStageReplyItem> ins=map.get(id);
if (!ListUtils.isEmpty(ins)){
Boolean flag=true;
for (PersonalStageReplyItem replyItem:ins){
if (!StringUtil.isEmpty(replyItem.getContent())&&replyItem.getContent().contains(USER_SEND_CONTENT)){
flag=false;
}
}
if (flag){
idsNew.add(id);
List<PersonalStageReplyItem> replyItems = personalStageReplyItemDao.getListByReplyIds(ids);
Map<Long,List<PersonalStageReplyItem>> map=replyItems.stream().collect(Collectors.groupingBy(PersonalStageReplyItem::getPersonalStageReplyId));
List<Long> idsNotHasSpe=new ArrayList<>();
List<Long> idsHasSpe=new ArrayList<>();
for (Long id:ids){
List<PersonalStageReplyItem> ins=map.get(id);
if (!ListUtils.isEmpty(ins)){
Boolean normal=true;
for (PersonalStageReplyItem replyItem:ins){
if (!StringUtil.isEmpty(replyItem.getContent())&&replyItem.getContent().contains(USER_SEND_CONTENT)){
normal=false;
}
}
if (normal){
idsNotHasSpe.add(id);
}else {
idsHasSpe.add(id);
}
}
if (ListUtils.isEmpty(idsNew)){
}
List<PersonalStageReplyItem> itemNew=new ArrayList<>();
//如果用户没有输入文本
if (StringUtil.isEmpty(userSendContent)){
//找一个不带占位符的
if (ListUtils.isEmpty(idsNotHasSpe)){
SendTextMessageVO sendTextMessageVO = new SendTextMessageVO();
sendTextMessageVO.setContent("哎哟 ~小主,你给我的不是书名啊。输入一本正在读或者感兴趣的书名,小睿就可以给你秀一下我的独家绝技哦");
sendTextMessageVO.setAltId(robotId);
......@@ -577,16 +580,23 @@ public class PersonalStageBizImpl implements PersonalStageBiz {
WxGroupSDK.sendTextMessage(sendTextMessageVO);
}else {
Random random = new Random();
Long replyId=idsNew.get(random.nextInt(idsNew.size()));
Long replyId=idsNotHasSpe.get(random.nextInt(idsNotHasSpe.size()));
itemNew = personalStageReplyItemDao.getListByReplyIds(Arrays.asList(replyId));
}
return itemNew;
}else {
for (PersonalStageReplyItem item:items){
Integer type=item.getReplyType();
if (ReplyTypeEnum.TEXT.value.equals(type)&&item.getContent().contains(USER_SEND_CONTENT)) {
item.setContent(item.getContent().replace(USER_SEND_CONTENT,userSendContent));
//用户输入文本优先给带特殊符号的
if (!ListUtils.isEmpty(idsHasSpe)){
Random random = new Random();
Long replyId=idsHasSpe.get(random.nextInt(idsHasSpe.size()));
itemNew = personalStageReplyItemDao.getListByReplyIds(Arrays.asList(replyId));
for (PersonalStageReplyItem item:itemNew){
Integer type=item.getReplyType();
if (ReplyTypeEnum.TEXT.value.equals(type)&&item.getContent().contains(USER_SEND_CONTENT)) {
item.setContent(item.getContent().replace(USER_SEND_CONTENT,userSendContent));
}
}
return itemNew;
}
}
return items;
......
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