Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Q
qk_backend
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
quanku
qk_backend
Commits
eb9fd413
Commit
eb9fd413
authored
Oct 25, 2023
by
shiyu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
查询ai默认问题
parent
f0acbe1b
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
42 additions
and
6 deletions
+42
-6
ch-core/src/main/java/com/wwdz/ch/core/entity/im/IMChatMsg.java
...e/src/main/java/com/wwdz/ch/core/entity/im/IMChatMsg.java
+5
-0
ch-core/src/main/java/com/wwdz/ch/core/entity/im/SendChatMsgRequestDto.java
...ava/com/wwdz/ch/core/entity/im/SendChatMsgRequestDto.java
+17
-0
ch-core/src/main/java/com/wwdz/ch/core/im/api/ConversationApi.java
...rc/main/java/com/wwdz/ch/core/im/api/ConversationApi.java
+2
-0
ch-core/src/main/java/com/wwdz/ch/core/util/IMUtil.java
ch-core/src/main/java/com/wwdz/ch/core/util/IMUtil.java
+6
-0
ch-wx-api/src/main/java/com/wwdz/ch/wx/api/IMCallbackController.java
...rc/main/java/com/wwdz/ch/wx/api/IMCallbackController.java
+2
-3
ch-wx-api/src/main/java/com/wwdz/ch/wx/impl/AiDefaultQuestionServiceImpl.java
...ava/com/wwdz/ch/wx/impl/AiDefaultQuestionServiceImpl.java
+3
-0
ch-wx-api/src/test/java/com/wwdz/ch/wx/api/ChatApiTest.java
ch-wx-api/src/test/java/com/wwdz/ch/wx/api/ChatApiTest.java
+7
-3
No files found.
ch-core/src/main/java/com/wwdz/ch/core/entity/im/IMChatMsg.java
View file @
eb9fd413
...
...
@@ -57,6 +57,11 @@ public class IMChatMsg implements Entity {
*/
private
List
MsgBody
;
/**
* 消息自定义数据(云端保存,会发送到对端,程序卸载重装后还能拉取到)
*/
private
String
CloudCustomData
;
...
...
ch-core/src/main/java/com/wwdz/ch/core/entity/im/SendChatMsgRequestDto.java
View file @
eb9fd413
...
...
@@ -60,4 +60,21 @@ public class SendChatMsgRequestDto implements Entity {
*/
private
Object
msgContent
;
/**
* 是否真人回答
* 0否 ,1是
*/
private
Integer
isRealPersonAnswer
;
/**
* 人工的系统id
*/
private
String
realPersonId
;
/**
* 消息自定义数据(云端保存,会发送到对端,程序卸载重装后还能拉取到)
* 格式 {realPersonId:xxxx}
*/
private
String
CloudCustomData
;
}
ch-core/src/main/java/com/wwdz/ch/core/im/api/ConversationApi.java
View file @
eb9fd413
...
...
@@ -211,4 +211,6 @@ public class ConversationApi {
return
Result
.
failed
();
}
}
ch-core/src/main/java/com/wwdz/ch/core/util/IMUtil.java
View file @
eb9fd413
...
...
@@ -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.IMChatMsg
;
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.Value
;
import
org.springframework.stereotype.Component
;
...
...
@@ -70,6 +72,10 @@ public class IMUtil {
msgContentMap
.
put
(
"MsgType"
,
IMEnum
.
MsgTypeEnum
.
getValueByCode
(
dto
.
getMsgType
()));
msgContentMap
.
put
(
"MsgContent"
,
new
HashMap
(){{
put
(
"Text"
,
dto
.
getMsgContent
());}});
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
;
}
...
...
ch-wx-api/src/main/java/com/wwdz/ch/wx/api/IMCallbackController.java
View file @
eb9fd413
...
...
@@ -104,9 +104,8 @@ public class IMCallbackController {
"\"MsgContent\":{\"Text\":\"秦始皇并没有发行货币,而是统一了货币。他颁布了统一的货币,即圆形方孔钱,也称为“秦钱”。这种货币由铜制成,大小不一,但一般都呈圆形,中间有一个孔,方便钱货交流。\"}}],"
+
"\"UnreadMsgNum\":151,\"MsgVersion\":0,\"MsgRandom\":730361011,\"EventTime\":1698131421787,\"MsgSeq\":164841877,\"MsgKey\":\"164841877_730361011_1698131421\","
+
"\"From_Account\":\"cjxc-applet-dev_ai10002\",\"MsgTime\":1698131421}"
;
long
MsgTime
=
Long
.
valueOf
(
JsonUtils
.
getValueByPath
(
jsonStr
,
"MsgTime"
));
System
.
out
.
println
(
new
Date
(
MsgTime
));
System
.
out
.
println
(
new
Date
(
MsgTime
*
1000L
));
long
msgTime
=
Long
.
valueOf
(
JsonUtils
.
getValueByPath
(
jsonStr
,
"MsgTime"
));
System
.
out
.
println
(
new
Date
(
msgTime
*
1000L
));
//消息体
String
msgBody
=
JsonUtils
.
getValueByPath
(
jsonStr
,
"MsgBody"
);
...
...
ch-wx-api/src/main/java/com/wwdz/ch/wx/impl/AiDefaultQuestionServiceImpl.java
View file @
eb9fd413
...
...
@@ -52,6 +52,9 @@ public class AiDefaultQuestionServiceImpl implements AiDefaultQuestionService {
}
//查询机器人信息
AiAssistant
aiAssistant
=
aiAssistantDao
.
findByCode
(
imUtil
.
revertAppletUserId
(
dto
.
getCode
()));
if
(
aiAssistant
==
null
)
{
return
Result
.
success
();
}
dto
.
setType
(
aiAssistant
.
getType
());
List
<
AiDefaultQuestion
>
aiDefaultQuestionList
=
aiDefaultQuestionDao
.
findList
(
dto
);
...
...
ch-wx-api/src/test/java/com/wwdz/ch/wx/api/ChatApiTest.java
View file @
eb9fd413
...
...
@@ -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.ConversationApi
;
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.UserDao
;
import
com.wwdz.ch.db.domain.AiAssistant
;
...
...
@@ -44,7 +45,7 @@ public class ChatApiTest {
@Test
public
void
chatWithModel
()
{
String
question
=
"
刀币的由来
"
;
String
question
=
"
伟伟伟伟伟伟伟伟伟伟伟伟伟伟伟伟伟伟小伟伟
"
;
chatApi
.
chatWithModel
(
question
);
}
...
...
@@ -90,12 +91,15 @@ public class ChatApiTest {
public
void
sendChatMsg
()
{
SendChatMsgRequestDto
sendChatMsgRequestDto
=
new
SendChatMsgRequestDto
();
sendChatMsgRequestDto
.
setToAccount
(
"241"
);
sendChatMsgRequestDto
.
setFromAccount
(
"
273
"
);
sendChatMsgRequestDto
.
setFromAccount
(
"
ai10001
"
);
sendChatMsgRequestDto
.
setMsgType
(
IMEnum
.
MsgTypeEnum
.
TIMTextElem
.
getCode
());
long
timestamp
=
System
.
currentTimeMillis
();
String
msgContent
=
timestamp
+
" >> ai测试消息的数据, 是否可以接收到"
;
sendChatMsgRequestDto
.
setMsgContent
(
msgContent
);
conversationApi
.
sendChatMsg
(
sendChatMsgRequestDto
);
Result
<
String
>
result
=
conversationApi
.
sendChatMsg
(
sendChatMsgRequestDto
);
String
msgKey
=
result
.
getData
();
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment