Commit f8ceb414 by 阮思源

1002577

parent b82e49ca
......@@ -301,4 +301,22 @@ public class BookConstant {
}
}
public static final Integer REPLACE_CODE_BOOK_NAME = 1;
public static final String SPECPATTEN = "^[_`~!@#$%^&*()+=|{}':;',\\[\\].·<>/?~!@#¥%……&*()——+|{}【】‘;:”“’。,、?]+$";
public static final String SPECPATTEN_1 ="^[\\[\\]❤❥웃유♋☮✌☏☢☠✔☑♚▲♪✈✞÷↑↓◆◇⊙■□△▽¿─│♥❣♂♀☿Ⓐ✍✉☣☤✘☒♛▼♫⌘☪≈←→◈◎☉★☆⊿※¡━┃" +
"♡ღツ☼☁❅♒✎©®™Σ✪✯☭➳卐√↖↗●◐Θ◤◥︻〖〗┄┆℃℉°✿ϟ☃☂✄¢€£∞✫★½✡×↙↘○◑⊕◣◢︼【】┅┇☽☾✚〓▂▃▄▅▆▇█▉▊▋▌▍▎▏↔↕☽☾の•▸◂▴▾┈┊" +
"①②③④⑤⑥⑦⑧⑨⑩ⅠⅡⅢⅣⅤⅥⅦⅧⅨⅩ㍿▓♨♛❖♓☪✙┉┋☹☺☻تヅツッシÜϡﭢ™℠℗©®♥❤❥❣❦❧♡۵웃유ღ♋♂♀☿☼☀☁☂☄☾☽❄☃☈⊙☉℃℉❅✺ϟ☇♤♧♡♢♠♣♥♦☜☞☝✍☚" +
"☛☟✌✽✾✿❁❃❋❀⚘☑✓✔√☐☒✗✘ㄨ✕✖✖⋆✢✣✤✥❋✦✧✩✰✪✫✬✭✮✯❂✡★✱✲✳✴✵✶✷✸✹✺✻✼❄❅❆❇❈❉❊†☨✞✝☥☦☓☩☯☧☬☸✡♁✙♆。,、':∶" +
";?‘’“”〝〞ˆˇ﹕︰﹔﹖﹑•¨….¸;!´?!~—ˉ|‖"〃`@﹫¡¿﹏﹋﹌︴々﹟#﹩$﹠&﹪%*﹡﹢﹦﹤‐ ̄¯―﹨ˆ˜﹍﹎+=<__-\\ˇ~﹉﹊()〈〉‹›﹛﹜" +
"『』〖〗[]《》〔〕{}「」【】︵︷︿︹︽_﹁﹃︻︶︸﹀︺︾ˉ﹂﹄︼☩☨☦✞✛✜✝✙✠✚†‡◉○◌◍◎●◐◑◒◓◔◕◖◗❂☢⊗⊙◘◙◍⅟½⅓⅕⅙⅛⅔⅖⅚⅜¾⅗⅝⅞⅘≂" +
"≃≄≅≆≇≈≉≊≋≌≍≎≏≐≑≒≓≔≕≖≗≘≙≚≛≜≝≞≟≠≡≢≣≤≥≦≧≨≩⊰⊱⋛⋚∫∬∭∮∯∰∱∲∳%℅‰‱㊣㊎㊍㊌㊋㊏㊐㊊㊚㊛㊤㊥㊦㊧㊨㊒" +
"㊞㊑㊒㊓㊔㊕㊖㊗㊘㊜㊝㊟㊠㊡㊢㊩㊪㊫㊬㊭㊮㊯㊰㊙㉿囍♔♕♖♗♘♙♚♛♜♝♞♟ℂℍℕℙℚℝℤℬℰℯℱℊℋℎℐℒℓℳℴ℘ℛℭ℮ℌℑℜℨ♪♫♩♬" +
"♭♮♯°øⒶ☮✌☪✡☭✯卐✐✎✏✑✒✍✉✁✂✃✄✆✉☎☏➟➡➢➣➤➥➦➧➨➚➘➙➛➜➝➞➸♐➲➳⏎➴➵➶➷➸➹➺➻➼➽←↑→↓↔↕↖↗↘" +
"↙↚↛↜↝↞↟↠↡↢↣↤↥↦↧↨➫➬➩➪➭➮➯➱↩↪↫↬↭↮↯↰↱↲↳↴↵↶↷↸↹↺↻↼↽↾↿⇀⇁⇂⇃⇄⇅⇆⇇⇈⇉⇊⇋⇌⇍⇎⇏⇐⇑⇒⇓⇔⇕⇖⇗⇘⇙⇚⇛⇜⇝⇞" +
"⇟⇠⇡⇢⇣⇤⇥⇦⇧⇨⇩⇪➀➁➂➃➄➅➆➇➈➉➊➋➌➍➎➏➐➑➒➓㊀㊁㊂㊃㊄㊅㊆㊇㊈㊉ⒶⒷⒸⒹⒺⒻⒼⒽⒾⒿⓀⓁⓂⓃⓄⓅⓆⓇⓈⓉⓊⓋⓌⓍⓎⓏⓐⓑⓒⓓⓔⓕⓖⓗⓘ" +
"ⓙⓚⓛⓜⓝⓞⓟⓠⓡⓢⓣⓤⓥⓦⓧⓨⓩ⒜⒝⒞⒟⒠⒡⒢⒣⒤⒥⒦⒧⒨⒩⒪⒫⒬⒭⒮⒯⒰⒱⒲⒳⒴⒵ⅠⅡⅢⅣⅤⅥⅦⅧⅨⅩⅪⅫⅬⅭⅮⅯⅰⅱⅲⅳⅴⅵⅶⅷⅸ" +
"ⅹⅺⅻⅼⅽⅾⅿ┌┍┎┏┐┑┒┓└┕┖┗┘┙┚┛├┝┞┟┠┡┢┣┤┥┦┧┨┩┪┫┬┭┮┯┰┱┲┳┴┵┶┷┸┹┺┻┼┽┾┿╀╁╂╃╄╅╆╇╈╉╊╋╌╍╎╏═║╒╓╔╕╖╗╘╙╚╛╜╝╞╟╠╡╢╣╤╥╦╧╨╩╪╫╬◤◥◄►▶◀◣◢▲▼◥▸◂" +
"▴▾△▽▷◁⊿▻◅▵▿▹◃❏❐❑❒▀▁▂▃▄▅▆▇▉▊▋█▌▍▎▏▐░▒▓▔▕■□▢▣▤▥▦▧▨▩▪▫▬▭▮▯㋀㋁㋂㋃㋄㋅㋆㋇㋈㋉㋊㋋]+$";
}
......@@ -3,6 +3,7 @@ package com.pcloud.book.personalstage.biz.impl;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.pcloud.book.base.exception.BookBizException;
import com.pcloud.book.book.constant.BookConstant;
import com.pcloud.book.consumer.content.ResourceConsr;
import com.pcloud.book.consumer.wechatgroup.WechatGroupConsr;
import com.pcloud.book.custom.mapper.CustomPlanModuleSuggestionMapper;
......@@ -68,6 +69,8 @@ import com.sdk.wxgroup.SendTextMessageVO;
import com.sdk.wxgroup.WxGroupSDK;
import com.sdk.wxgroup.im.mimc.BusinessConstant;
import com.sdk.wxgroup.im.mimc.dto.SendMomentsDTO;
import com.sun.org.apache.xpath.internal.operations.Bool;
import org.apache.commons.collections.MapUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
......@@ -204,6 +207,7 @@ public class PersonalStageBizImpl implements PersonalStageBiz {
}
}
personalStage.setStageNotKeywordReplies(replies.stream().filter(s->StageReplyRelevEnum.STAGE_NOT_KEYWORD.value.equals(s.getRelevanceType())).collect(Collectors.toList()));
personalStage.setBookStageNotKeywordReplies(replies.stream().filter(s->StageReplyRelevEnum.BOOK_STAGE_NOT_KEYWORD.value.equals(s.getRelevanceType())).collect(Collectors.toList()));
personalStage.setFusingNotKeywordReplies(replies.stream().filter(s->StageReplyRelevEnum.FUSING_NOT_KEYWORD.value.equals(s.getRelevanceType())).collect(Collectors.toList()));
List<PersonalStageReply> wakeupReplies=replies.stream().filter(s->StageReplyRelevEnum.WAKEUP.value.equals(s.getRelevanceType())).collect(Collectors.toList());
wakeupReplyMap=wakeupReplies.stream().collect(Collectors.groupingBy(PersonalStageReply::getRelevanceId));
......@@ -288,6 +292,14 @@ public class PersonalStageBizImpl implements PersonalStageBiz {
reply.setRelevanceId(personalStageId);
}
allReply.addAll(personalStage.getStageNotKeywordReplies());
if (!ListUtils.isEmpty(personalStage.getBookStageNotKeywordReplies())){
for (PersonalStageReply reply:personalStage.getBookStageNotKeywordReplies()){
reply.setRelevanceType(StageReplyRelevEnum.BOOK_STAGE_NOT_KEYWORD.value);
reply.setPersonalStageId(personalStageId);
reply.setRelevanceId(personalStageId);
}
allReply.addAll(personalStage.getBookStageNotKeywordReplies());
}
for (PersonalStageReply reply:personalStage.getFusingNotKeywordReplies()){
reply.setRelevanceType(StageReplyRelevEnum.FUSING_NOT_KEYWORD.value);
reply.setPersonalStageId(personalStageId);
......@@ -633,40 +645,57 @@ public class PersonalStageBizImpl implements PersonalStageBiz {
LOGGER.info("人工客服服务中,userWxId="+userWxId+"+robotId+"+robotId);
return;
}
PersonalStageReply personalStageReply = null;
List<Long> ids = personalStageReplyDao.getIdsByRelevance(StageReplyRelevEnum.STAGE_NOT_KEYWORD.value, personalStageId);
Long replyId = null;
if (ListUtils.isEmpty(ids)){
return;
PersonalStage personalStage = personalStageDao.getById(personalStageId);
List<PersonalStageReplyItem> items = new ArrayList<>();
//确认是图书获取阶段 判断是否是特殊符号
Boolean isSpecial = false;
List<Long> ids = new ArrayList<>();
if (null != personalStage && null != personalStage.getReplaceCodeId() && BookConstant.REPLACE_CODE_BOOK_NAME.equals(personalStage.getReplaceCodeId().intValue())
&& ((!StringUtil.isEmpty(userSendContent) && userSendContent.matches(BookConstant.SPECPATTEN)) || StringUtil.isEmpty(userSendContent))){
ids = personalStageReplyDao.getIdsByRelevance(StageReplyRelevEnum.BOOK_STAGE_NOT_KEYWORD.value, personalStageId);
if (!ListUtils.isEmpty(ids)){
isSpecial = true;
}
}
if (SendModeEnum.RADOM.value.equals(sendMode)){
Random random = new Random();
replyId=ids.get(random.nextInt(ids.size()));
personalStageReply = personalStageReplyDao.getById(replyId);
}else {
if (null != count){
if ((count).intValue() >= ids.size()){
count = ids.size() -1;
}
LOGGER.info(StageReplyRelevEnum.STAGE_NOT_KEYWORD.value +":"+ personalStageId+":"+count);
personalStageReply = personalStageReplyDao.personalStageReply4Order(StageReplyRelevEnum.STAGE_NOT_KEYWORD.value, personalStageId,count);
replyId = personalStageReply.getId();
if (isSpecial){
items = personalStageReplyItemDao.getListByReplyIds(ids);
} else {
PersonalStageReply personalStageReply = null;
ids = personalStageReplyDao.getIdsByRelevance(StageReplyRelevEnum.STAGE_NOT_KEYWORD.value, personalStageId);
Long replyId = null;
if (ListUtils.isEmpty(ids)){
return;
}
if (SendModeEnum.RADOM.value.equals(sendMode)){
Random random = new Random();
replyId=ids.get(random.nextInt(ids.size()));
personalStageReply = personalStageReplyDao.getById(replyId);
}else {
throw new BookBizException(BookBizException.ERROR,"查询到用户发送的非关键词数量为0");
if (null != count){
if ((count).intValue() >= ids.size()){
count = ids.size() -1;
}
LOGGER.info(StageReplyRelevEnum.STAGE_NOT_KEYWORD.value +":"+ personalStageId+":"+count);
personalStageReply = personalStageReplyDao.personalStageReply4Order(StageReplyRelevEnum.STAGE_NOT_KEYWORD.value, personalStageId,count);
replyId = personalStageReply.getId();
}else {
throw new BookBizException(BookBizException.ERROR,"查询到用户发送的非关键词数量为0");
}
ids = Lists.newArrayList(replyId);
}
ids = Lists.newArrayList(replyId);
}
List<PersonalStageReplyItem> items = personalStageReplyItemDao.getListByReplyIds(Arrays.asList(replyId));
if (ListUtils.isEmpty(items)){
return;
}
//替换用户输入内容
items=replaceUserSendContent(items,ids, userSendContent,robotId,userWxId,ip);
if (ListUtils.isEmpty(items)){
return;
items = personalStageReplyItemDao.getListByReplyIds(Arrays.asList(replyId));
if (ListUtils.isEmpty(items)){
return;
}
//替换用户输入内容
items=replaceUserSendContent(items,ids, userSendContent,robotId,userWxId,ip);
if (ListUtils.isEmpty(items)){
return;
}
//替换需求定制单链接
this.replacePaperUrl(items, robotId, userWxId, personalStageReply.getPaperId(),ip);
}
//替换需求定制单链接
this.replacePaperUrl(items, robotId, userWxId, personalStageReply.getPaperId(),ip);
sendReplyItems(items,robotId,userWxId,ip,personalStageUserId);
}
......
......@@ -51,4 +51,7 @@ public class PersonalStage extends BaseEntity {
@ApiModelProperty("替换字符串id")
private Long replaceCodeId;
@ApiModelProperty("书籍阶段非关键词回复集合")
private List<PersonalStageReply> bookStageNotKeywordReplies;
}
\ No newline at end of file
......@@ -13,7 +13,11 @@ public enum StageReplyRelevEnum {
/**
* 唤醒
*/
WAKEUP(3);
WAKEUP(3),
/**
* 书籍阶段非关键词回复
*/
BOOK_STAGE_NOT_KEYWORD(4);
public final Integer value;
......
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