Commit 7bcc53c4 by 裴大威

feat 1002405

parent 8ed18d7d
......@@ -66,12 +66,14 @@ import com.pcloud.book.keywords.vo.UpdateKeywordVO;
import com.pcloud.book.pcloudkeyword.biz.PcloudRobotBiz;
import com.pcloud.book.pcloudkeyword.dao.PcloudKeywordClassifyDao;
import com.pcloud.book.pcloudkeyword.dao.PcloudKeywordDao;
import com.pcloud.book.pcloudkeyword.dao.PcloudKeywordNameDao;
import com.pcloud.book.pcloudkeyword.dao.PcloudKeywordReplyDao;
import com.pcloud.book.pcloudkeyword.dao.PcloudNotKeywordDao;
import com.pcloud.book.pcloudkeyword.dao.PcloudRobotClassifyDao;
import com.pcloud.book.pcloudkeyword.dao.PcloudRobotDao;
import com.pcloud.book.pcloudkeyword.entity.PcloudKeyword;
import com.pcloud.book.pcloudkeyword.entity.PcloudKeywordClassify;
import com.pcloud.book.pcloudkeyword.entity.PcloudKeywordName;
import com.pcloud.book.pcloudkeyword.entity.PcloudKeywordReply;
import com.pcloud.book.pcloudkeyword.entity.PcloudNotKeyword;
import com.pcloud.book.pcloudkeyword.entity.PcloudRobot;
......@@ -113,6 +115,7 @@ import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
import javax.annotation.Resource;
import java.math.BigDecimal;
......@@ -202,6 +205,8 @@ public class BookKeywordBizImpl implements BookKeywordBiz {
private ChannelConsr channelConsr;
@Autowired
private SelfRobotBookRecordDao selfRobotBookRecordDao;
@Autowired
private PcloudKeywordNameDao pcloudKeywordNameDao;
@Autowired
private ReadingActivityBiz readingActivityBiz;
......@@ -699,8 +704,22 @@ public class BookKeywordBizImpl implements BookKeywordBiz {
//精准
PcloudKeyword pcloudKeyword=pcloudKeywordDao.getByClassifyIdAndName(KeywordTypeEnum.ACCURATE.value,pcloudClassifyId,content);
if (pcloudKeyword==null){
//模糊
// 正向模糊
pcloudKeyword=pcloudKeywordDao.getByClassifyIdAndName(KeywordTypeEnum.LIKE.value,pcloudClassifyId,content);
// 反向模糊
if (Objects.isNull(pcloudKeyword)) {
List<PcloudKeyword> pcloudKeywords = pcloudKeywordDao.listAllBlurryKeyword(pcloudClassifyId);
if (!CollectionUtils.isEmpty(pcloudKeywords)) {
Map<Long, PcloudKeyword> collect = pcloudKeywords.stream().collect(Collectors.toMap(PcloudKeyword::getId, p -> p));
List<PcloudKeywordName> names = pcloudKeywordNameDao.getByPcloudKeywordIds(pcloudKeywords.stream().map(PcloudKeyword::getId).collect(Collectors.toList()));
for (PcloudKeywordName name : names) {
if (!StringUtils.isEmpty(name.getName()) && content.contains(name.getName())) {
pcloudKeyword = collect.get(name.getPcloudKeywordId());
break;
}
}
}
}
}
if (pcloudKeyword!=null){
//走关键词
......@@ -743,6 +762,7 @@ public class BookKeywordBizImpl implements BookKeywordBiz {
}
@ParamLog("平台端个人号关键词回复")
public void sendPcloudKeywordReply(PcloudKeywordReply reply, String robotId, String userWxId, String ip, Integer code){
Integer type = reply.getType();
......
......@@ -14,5 +14,11 @@ public interface PcloudKeywordDao extends BaseDao<PcloudKeyword> {
PcloudKeyword getByClassifyIdAndName(Integer type, Long pcloudClassifyId, String name);
/**
* 1002405 反向模糊匹配
* @return
*/
List<PcloudKeyword> listAllBlurryKeyword(Long pcloudClassifyId);
Boolean skillExist(Long skillId);
}
......@@ -33,6 +33,11 @@ public class PcloudKeywordDaoImpl extends BaseDaoImpl<PcloudKeyword> implements
}
@Override
public List<PcloudKeyword> listAllBlurryKeyword(Long pcloudClassifyId) {
return this.getSqlSession().selectList("listAllBlurryKeyword", pcloudClassifyId);
}
@Override
public Boolean skillExist(Long skillId) {
Map<String,Object> map= new HashMap<>();
map.put("skillId", skillId);
......
......@@ -105,6 +105,15 @@
limit 1
</select>
<select id="listAllBlurryKeyword" parameterType="long" resultMap="BaseResultMap">
select t1.id, t1.keyword_classify_id, t1.type,t1.method, t1.create_time, t1.skill_ids
from pcloud_keyword t1
inner join pcloud_keyword_name t2 on t1.id=t2.pcloud_keyword_id
where t1.keyword_classify_id=#{pcloudClassifyId}
and t1.type=2
group by t1.id
</select>
<select id="skillExist" resultType="Boolean" parameterType="map">
SELECT
EXISTS (
......
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