Commit eb9fd413 authored by shiyu's avatar shiyu

查询ai默认问题

parent f0acbe1b
...@@ -57,6 +57,11 @@ public class IMChatMsg implements Entity { ...@@ -57,6 +57,11 @@ public class IMChatMsg implements Entity {
*/ */
private List MsgBody; private List MsgBody;
/**
* 消息自定义数据(云端保存,会发送到对端,程序卸载重装后还能拉取到)
*/
private String CloudCustomData;
......
...@@ -60,4 +60,21 @@ public class SendChatMsgRequestDto implements Entity { ...@@ -60,4 +60,21 @@ public class SendChatMsgRequestDto implements Entity {
*/ */
private Object msgContent; private Object msgContent;
/**
* 是否真人回答
* 0否 ,1是
*/
private Integer isRealPersonAnswer;
/**
* 人工的系统id
*/
private String realPersonId;
/**
* 消息自定义数据(云端保存,会发送到对端,程序卸载重装后还能拉取到)
* 格式 {realPersonId:xxxx}
*/
private String CloudCustomData;
} }
...@@ -211,4 +211,6 @@ public class ConversationApi { ...@@ -211,4 +211,6 @@ public class ConversationApi {
return Result.failed(); return Result.failed();
} }
} }
...@@ -4,6 +4,8 @@ import com.wwdz.ch.core.consts.IMEnum; ...@@ -4,6 +4,8 @@ import com.wwdz.ch.core.consts.IMEnum;
import com.wwdz.ch.core.entity.im.SendChatMsgRequestDto; import com.wwdz.ch.core.entity.im.SendChatMsgRequestDto;
import com.wwdz.ch.core.entity.im.IMChatMsg; import com.wwdz.ch.core.entity.im.IMChatMsg;
import com.wwdz.ch.core.im.api.TLSSigApi; import com.wwdz.ch.core.im.api.TLSSigApi;
import com.xxdxxs.utils.JsonUtils;
import com.xxdxxs.utils.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
...@@ -70,6 +72,10 @@ public class IMUtil { ...@@ -70,6 +72,10 @@ public class IMUtil {
msgContentMap.put("MsgType", IMEnum.MsgTypeEnum.getValueByCode(dto.getMsgType())); msgContentMap.put("MsgType", IMEnum.MsgTypeEnum.getValueByCode(dto.getMsgType()));
msgContentMap.put("MsgContent", new HashMap(){{put("Text", dto.getMsgContent());}}); msgContentMap.put("MsgContent", new HashMap(){{put("Text", dto.getMsgContent());}});
imChatMsg.setMsgBody(Arrays.asList(msgContentMap)); imChatMsg.setMsgBody(Arrays.asList(msgContentMap));
//转人工需要设置人工的id,放入自定义数据字段中
if (dto.getIsRealPersonAnswer() != null && dto.getIsRealPersonAnswer() == 1) {
imChatMsg.setCloudCustomData(JsonUtils.fromMap(new HashMap<String, Object>(){{put("realPersonId", dto.getRealPersonId());}}));
}
return imChatMsg; return imChatMsg;
} }
......
...@@ -104,9 +104,8 @@ public class IMCallbackController { ...@@ -104,9 +104,8 @@ public class IMCallbackController {
"\"MsgContent\":{\"Text\":\"秦始皇并没有发行货币,而是统一了货币。他颁布了统一的货币,即圆形方孔钱,也称为“秦钱”。这种货币由铜制成,大小不一,但一般都呈圆形,中间有一个孔,方便钱货交流。\"}}]," + "\"MsgContent\":{\"Text\":\"秦始皇并没有发行货币,而是统一了货币。他颁布了统一的货币,即圆形方孔钱,也称为“秦钱”。这种货币由铜制成,大小不一,但一般都呈圆形,中间有一个孔,方便钱货交流。\"}}]," +
"\"UnreadMsgNum\":151,\"MsgVersion\":0,\"MsgRandom\":730361011,\"EventTime\":1698131421787,\"MsgSeq\":164841877,\"MsgKey\":\"164841877_730361011_1698131421\"," + "\"UnreadMsgNum\":151,\"MsgVersion\":0,\"MsgRandom\":730361011,\"EventTime\":1698131421787,\"MsgSeq\":164841877,\"MsgKey\":\"164841877_730361011_1698131421\"," +
"\"From_Account\":\"cjxc-applet-dev_ai10002\",\"MsgTime\":1698131421}"; "\"From_Account\":\"cjxc-applet-dev_ai10002\",\"MsgTime\":1698131421}";
long MsgTime = Long.valueOf(JsonUtils.getValueByPath(jsonStr, "MsgTime")); long msgTime = Long.valueOf(JsonUtils.getValueByPath(jsonStr, "MsgTime"));
System.out.println(new Date(MsgTime)); System.out.println(new Date(msgTime * 1000L));
System.out.println(new Date(MsgTime * 1000L));
//消息体 //消息体
String msgBody = JsonUtils.getValueByPath(jsonStr, "MsgBody"); String msgBody = JsonUtils.getValueByPath(jsonStr, "MsgBody");
......
...@@ -52,6 +52,9 @@ public class AiDefaultQuestionServiceImpl implements AiDefaultQuestionService { ...@@ -52,6 +52,9 @@ public class AiDefaultQuestionServiceImpl implements AiDefaultQuestionService {
} }
//查询机器人信息 //查询机器人信息
AiAssistant aiAssistant = aiAssistantDao.findByCode(imUtil.revertAppletUserId(dto.getCode())); AiAssistant aiAssistant = aiAssistantDao.findByCode(imUtil.revertAppletUserId(dto.getCode()));
if (aiAssistant == null) {
return Result.success();
}
dto.setType(aiAssistant.getType()); dto.setType(aiAssistant.getType());
List<AiDefaultQuestion> aiDefaultQuestionList = aiDefaultQuestionDao.findList(dto); List<AiDefaultQuestion> aiDefaultQuestionList = aiDefaultQuestionDao.findList(dto);
......
...@@ -6,6 +6,7 @@ import com.wwdz.ch.core.entity.im.SendChatMsgRequestDto; ...@@ -6,6 +6,7 @@ import com.wwdz.ch.core.entity.im.SendChatMsgRequestDto;
import com.wwdz.ch.core.im.api.ChatUserApi; import com.wwdz.ch.core.im.api.ChatUserApi;
import com.wwdz.ch.core.im.api.ConversationApi; import com.wwdz.ch.core.im.api.ConversationApi;
import com.wwdz.ch.core.im.api.TLSSigApi; import com.wwdz.ch.core.im.api.TLSSigApi;
import com.wwdz.ch.core.type.Result;
import com.wwdz.ch.db.dao.AiAssistantDao; import com.wwdz.ch.db.dao.AiAssistantDao;
import com.wwdz.ch.db.dao.UserDao; import com.wwdz.ch.db.dao.UserDao;
import com.wwdz.ch.db.domain.AiAssistant; import com.wwdz.ch.db.domain.AiAssistant;
...@@ -44,7 +45,7 @@ public class ChatApiTest { ...@@ -44,7 +45,7 @@ public class ChatApiTest {
@Test @Test
public void chatWithModel() { public void chatWithModel() {
String question = "刀币的由来"; String question = "伟伟伟伟伟伟伟伟伟伟伟伟伟伟伟伟伟伟小伟伟";
chatApi.chatWithModel(question); chatApi.chatWithModel(question);
} }
...@@ -90,12 +91,15 @@ public class ChatApiTest { ...@@ -90,12 +91,15 @@ public class ChatApiTest {
public void sendChatMsg() { public void sendChatMsg() {
SendChatMsgRequestDto sendChatMsgRequestDto = new SendChatMsgRequestDto(); SendChatMsgRequestDto sendChatMsgRequestDto = new SendChatMsgRequestDto();
sendChatMsgRequestDto.setToAccount("241"); sendChatMsgRequestDto.setToAccount("241");
sendChatMsgRequestDto.setFromAccount("273"); sendChatMsgRequestDto.setFromAccount("ai10001");
sendChatMsgRequestDto.setMsgType(IMEnum.MsgTypeEnum.TIMTextElem.getCode()); sendChatMsgRequestDto.setMsgType(IMEnum.MsgTypeEnum.TIMTextElem.getCode());
long timestamp = System.currentTimeMillis(); long timestamp = System.currentTimeMillis();
String msgContent = timestamp + " >> ai测试消息的数据, 是否可以接收到"; String msgContent = timestamp + " >> ai测试消息的数据, 是否可以接收到";
sendChatMsgRequestDto.setMsgContent(msgContent); sendChatMsgRequestDto.setMsgContent(msgContent);
conversationApi.sendChatMsg(sendChatMsgRequestDto); Result<String> result = conversationApi.sendChatMsg(sendChatMsgRequestDto);
String msgKey = result.getData();
} }
......
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