|
@ -1,5 +1,6 @@
|
|
|
package com.yihu.jw.im.service;
|
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.yihu.jw.entity.base.dict.DictHospitalDeptDO;
|
|
@ -7,6 +8,7 @@ import com.yihu.jw.entity.hospital.consult.WlyyHospitalSysDictDO;
|
|
|
import com.yihu.jw.entity.knowledge.*;
|
|
|
import com.yihu.jw.im.util.ImUtil;
|
|
|
import com.yihu.jw.knowledge.dao.*;
|
|
|
import com.yihu.jw.knowledge.service.BaseKnowledgeDictService;
|
|
|
import com.yihu.jw.sms.dao.HospitalSysDictDao;
|
|
|
import com.yihu.jw.util.date.DateUtil;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
@ -49,6 +51,8 @@ public class RobotService {
|
|
|
private ImService imService;
|
|
|
@Autowired
|
|
|
private HospitalSysDictDao hospitalSysDictDao;
|
|
|
@Autowired
|
|
|
private BaseKnowledgeDictService baseKnowledgeDictService;
|
|
|
|
|
|
|
|
|
/**
|
|
@ -133,15 +137,46 @@ public class RobotService {
|
|
|
return map;
|
|
|
}
|
|
|
|
|
|
public void reply(String sessionType,String content,String consult,Integer contentType){
|
|
|
if(contentType==1||contentType==3001){
|
|
|
//常见问题
|
|
|
replyContent(sessionType,content,consult,contentType);
|
|
|
return;
|
|
|
}
|
|
|
if(contentType==3006){
|
|
|
//回复疾病
|
|
|
replyDisease(sessionType,content,null,consult,contentType+"");
|
|
|
return;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
//回复疾病
|
|
|
public void replyDisease(String sessionType,String content,String sessionId,String consult,String contentType){
|
|
|
try {
|
|
|
JSONObject jsonObject = JSON.parseObject(content);
|
|
|
String id = jsonObject.getString("id");
|
|
|
JSONArray jsonArray = baseKnowledgeDictService.findDeptById(id);
|
|
|
WlyyHospitalSysDictDO dictDO = getSender();
|
|
|
if(StringUtils.isNotEmpty(consult)){
|
|
|
imUtil.sendTopicIM(dictDO.getDictCode(), dictDO.getDictName(), consult, ImUtil.ContentType.KnowSymptomsDiseaseA.getValue(), jsonArray.toJSONString(),null);
|
|
|
}else {
|
|
|
imService.patientGuaidenceAppend(dictDO.getDictCode(),dictDO.getDictValue(),sessionId,
|
|
|
ImUtil.ContentType.KnowSymptomsDiseaseA.getValue(),jsonArray.toJSONString(),"1",null);
|
|
|
}
|
|
|
}catch (Exception e){
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
*
|
|
|
* @param type 会话类型
|
|
|
* @param sessionType 会话类型
|
|
|
* @param content 消息内容
|
|
|
* @param consult 咨询code
|
|
|
* @param contentType 消息类型 文本1 问题集3002
|
|
|
*/
|
|
|
//普通咨询常见问题匹配
|
|
|
public void replyContent(String type,String content,String consult,Integer contentType){
|
|
|
public void replyContent(String sessionType,String content,String consult,Integer contentType){
|
|
|
try {
|
|
|
WlyyHospitalSysDictDO dictDO = getSender();
|
|
|
if (contentType==3003){
|
|
@ -149,7 +184,7 @@ public class RobotService {
|
|
|
String contentMsg = selectByContentType(contentTypes,content).toJSONString();
|
|
|
imUtil.sendTopicIM(dictDO.getDictCode(), dictDO.getDictName(), consult, contentTypes, contentMsg,null);
|
|
|
}
|
|
|
BaseSystemDialogSetting setting = dialogSettingDao.findBySystemTypeAndFunctionType(sessionTypeToType(type),"7",1);
|
|
|
BaseSystemDialogSetting setting = dialogSettingDao.findBySystemTypeAndFunctionType(sessionTypeToType(sessionType),"7",1);
|
|
|
if(setting==null){
|
|
|
return;
|
|
|
}
|
|
@ -200,9 +235,14 @@ public class RobotService {
|
|
|
*/
|
|
|
public void replyGuaidenceContent(String sessionId,String type,String content,String contentType,String businessType, String extend){
|
|
|
try {
|
|
|
if(contentType.equals(ImUtil.ContentType.KnowSymptomsDiseaseQ.getValue())){
|
|
|
//回复疾病
|
|
|
replyDisease(type,content,sessionId,null,contentType);
|
|
|
return;
|
|
|
}
|
|
|
WlyyHospitalSysDictDO dictDO = getSender();
|
|
|
if (contentType.equalsIgnoreCase("3003")){
|
|
|
String contentTypes = ImUtil.ContentType.KnowCommonDict+"";
|
|
|
String contentTypes = ImUtil.ContentType.KnowCommonDict.getValue();
|
|
|
String contentMsg = selectByContentType(contentTypes,content).toJSONString();
|
|
|
imService.patientGuaidenceAppend(dictDO.getDictCode(),dictDO.getDictValue(),sessionId,
|
|
|
contentTypes+"", contentMsg, "1",null);
|
|
@ -308,6 +348,12 @@ public class RobotService {
|
|
|
try {
|
|
|
Boolean re = imUtil.sessionIsExist(session_id);
|
|
|
if(!re){
|
|
|
//系统客服tip
|
|
|
JSONObject tip = new JSONObject();
|
|
|
tip.put("content","");
|
|
|
tip.put("content_type",ImUtil.ContentType.KnowCommonCustomer.getValue());
|
|
|
tip.put("session_id",session_id);
|
|
|
map.put("0",tip);
|
|
|
//欢迎语
|
|
|
BaseSystemDialogSetting welcomeSetting = mapSetting.get("1");
|
|
|
if(welcomeSetting!=null){
|