Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
K
konke-ai-alibaba-mcp
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
何金镒
konke-ai-alibaba-mcp
Commits
64de612b
Commit
64de612b
authored
Sep 01, 2025
by
何金镒
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dify 接口 2
parent
5f0fb9ed
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
37 additions
and
28 deletions
+37
-28
src/main/java/com/ikonke/konkeaialibabamcp/controller/CDCController.java
...om/ikonke/konkeaialibabamcp/controller/CDCController.java
+30
-21
src/main/java/com/ikonke/konkeaialibabamcp/controller/DifyController.java
...m/ikonke/konkeaialibabamcp/controller/DifyController.java
+5
-7
src/main/java/com/ikonke/konkeaialibabamcp/service/SycDeviceService.java
...om/ikonke/konkeaialibabamcp/service/SycDeviceService.java
+2
-0
No files found.
src/main/java/com/ikonke/konkeaialibabamcp/controller/CDCController.java
View file @
64de612b
...
@@ -31,33 +31,42 @@ public class CDCController {
...
@@ -31,33 +31,42 @@ public class CDCController {
public
boolean
synCDCToken
(
@RequestParam
(
name
=
"token"
)
String
token
,
public
boolean
synCDCToken
(
@RequestParam
(
name
=
"token"
)
String
token
,
@RequestParam
(
name
=
"sn"
)
String
sn
,
@RequestParam
(
name
=
"sn"
)
String
sn
,
@RequestParam
(
name
=
"ccuName"
)
String
ccuName
){
@RequestParam
(
name
=
"ccuName"
)
String
ccuName
){
long
time
=
System
.
currentTimeMillis
();
log
.
info
(
"synCDCToken..同步CDCToken..token:{},sn:{},ccuName:{}"
,
token
,
sn
,
ccuName
);
log
.
info
(
"synCDCToken..同步CDCToken..token:{},sn:{},ccuName:{}"
,
token
,
sn
,
ccuName
);
CDCToken
bySn
=
tokenService
.
findBySn
(
sn
);
try
{
if
(
bySn
==
null
){
CDCToken
bySn
=
tokenService
.
findBySn
(
sn
);
bySn
=
new
CDCToken
();
if
(
bySn
==
null
){
bySn
.
setSn
(
sn
);
bySn
=
new
CDCToken
();
bySn
.
setAccessToken
(
token
);
bySn
.
setSn
(
sn
);
bySn
.
setState
(
CDCToken
.
STATE_ENABLED
);
bySn
.
setCcuId
(
CcuUtils
.
getCcuName
(
ccuName
));
bySn
.
setCreateTime
(
LocalDateTime
.
now
());
tokenService
.
save
(
bySn
);
}
else
{
if
(
bySn
.
getAccessToken
().
equals
(
token
)
&&
bySn
.
getSn
().
equals
(
sn
)
&&
bySn
.
getCcuId
().
equals
(
CcuUtils
.
getCcuName
(
ccuName
))){
return
true
;
}
else
{
CdcHttpUtils
.
CDCTokenCache
.
remove
(
sn
);
bySn
.
setAccessToken
(
token
);
bySn
.
setAccessToken
(
token
);
bySn
.
setRefreshToken
(
bySn
.
getAccessToken
());
bySn
.
setState
(
CDCToken
.
STATE_ENABLED
);
bySn
.
setState
(
CDCToken
.
STATE_ENABLED
);
bySn
.
setCreateTime
(
LocalDateTime
.
now
());
bySn
.
setCcuId
(
CcuUtils
.
getCcuName
(
ccuName
));
bySn
.
setCcuId
(
CcuUtils
.
getCcuName
(
ccuName
));
tokenService
.
updateById
(
bySn
);
bySn
.
setCreateTime
(
LocalDateTime
.
now
());
tokenService
.
save
(
bySn
);
}
else
{
if
(
bySn
.
getAccessToken
().
equals
(
token
)
&&
bySn
.
getSn
().
equals
(
sn
)
&&
bySn
.
getCcuId
().
equals
(
CcuUtils
.
getCcuName
(
ccuName
))){
log
.
info
(
"synCDCToken..不需要同步CDCToken..耗时:{}ms"
,
System
.
currentTimeMillis
()-
time
);
return
true
;
}
else
{
CdcHttpUtils
.
CDCTokenCache
.
remove
(
sn
);
bySn
.
setAccessToken
(
token
);
bySn
.
setRefreshToken
(
bySn
.
getAccessToken
());
bySn
.
setState
(
CDCToken
.
STATE_ENABLED
);
bySn
.
setCreateTime
(
LocalDateTime
.
now
());
bySn
.
setCcuId
(
CcuUtils
.
getCcuName
(
ccuName
));
tokenService
.
updateById
(
bySn
);
}
}
}
log
.
info
(
"synCDCToken..同步CDCToken成功..耗时:{}ms"
,
System
.
currentTimeMillis
()-
time
);
return
true
;
}
catch
(
Exception
e
)
{
log
.
error
(
"synCDCToken..同步CDCToken失败..token:{},sn:{},ccuName:{}"
,
token
,
sn
,
ccuName
);
e
.
printStackTrace
();
return
false
;
}
}
return
true
;
}
}
@GetMapping
(
"/getSpacesList"
)
@GetMapping
(
"/getSpacesList"
)
...
...
src/main/java/com/ikonke/konkeaialibabamcp/controller/DifyController.java
View file @
64de612b
...
@@ -85,7 +85,7 @@ public class DifyController {
...
@@ -85,7 +85,7 @@ public class DifyController {
JSONObject
jsonObject
=
new
JSONObject
(
body1
);
JSONObject
jsonObject
=
new
JSONObject
(
body1
);
if
(
StrUtil
.
isBlank
(
conversationId
)
){
//conversationId为null表示第一次对话
if
(
redis_conversationId
==
null
){
//conversationId为null表示第一次对话
conversationId
=
jsonObject
.
getStr
(
"conversation_id"
);
conversationId
=
jsonObject
.
getStr
(
"conversation_id"
);
redisTemplate
.
opsForValue
().
set
(
redis_key
,
conversationId
);
redisTemplate
.
opsForValue
().
set
(
redis_key
,
conversationId
);
if
(
bySn
!=
null
){
if
(
bySn
!=
null
){
...
@@ -146,7 +146,6 @@ public class DifyController {
...
@@ -146,7 +146,6 @@ public class DifyController {
log
.
info
(
"dify 对话 body:{}"
,
body
);
log
.
info
(
"dify 对话 body:{}"
,
body
);
String
finalConversationId
=
conversationId
;
return
webClient
.
post
()
return
webClient
.
post
()
.
uri
(
url
)
.
uri
(
url
)
.
headers
(
httpHeaders
->
{
.
headers
(
httpHeaders
->
{
...
@@ -157,17 +156,16 @@ public class DifyController {
...
@@ -157,17 +156,16 @@ public class DifyController {
.
retrieve
()
.
retrieve
()
.
bodyToFlux
(
DifyStreamResponse
.
class
)
//实体转换
.
bodyToFlux
(
DifyStreamResponse
.
class
)
//实体转换
.
filter
(
this
::
shouldInclude
)
// 过滤掉不需要的数据【根据需求增加】
.
filter
(
this
::
shouldInclude
)
// 过滤掉不需要的数据【根据需求增加】
.
map
((
DifyStreamResponse
difyStreamResponse
)
->
convertToCustomResponseAsync
(
difyStreamResponse
,
sn
,
ccuName
,
token
,
finalC
onversationId
))
// 异步转换【如果返回格式自定义则通过异步转换实现】
.
map
((
DifyStreamResponse
difyStreamResponse
)
->
convertToCustomResponseAsync
(
difyStreamResponse
,
sn
,
ccuName
,
token
,
redis_c
onversationId
))
// 异步转换【如果返回格式自定义则通过异步转换实现】
.
onErrorResume
(
throwable
->
{
.
onErrorResume
(
throwable
->
{
log
.
info
(
"异常输出:"
+
throwable
.
getMessage
());
log
.
info
(
"异常输出:"
+
throwable
.
getMessage
());
return
null
;
return
null
;
});
});
}
}
private
String
convertToCustomResponseAsync
(
DifyStreamResponse
difyStreamResponse
,
String
sn
,
String
ccuName
,
String
token
,
String
conversationId
)
{
private
String
convertToCustomResponseAsync
(
DifyStreamResponse
difyStreamResponse
,
String
sn
,
String
ccuName
,
String
token
,
Object
redis_conversationId
)
{
System
.
out
.
println
(
"---->"
+
difyStreamResponse
.
getConversation_id
());
if
(
redis_conversationId
==
null
&&
StrUtil
.
isNotBlank
(
difyStreamResponse
.
getConversation_id
())){
//conversationId为null表示第一次对话
if
(
StrUtil
.
isBlank
(
conversationId
)
&&
StrUtil
.
isNotBlank
(
difyStreamResponse
.
getConversation_id
())){
//conversationId为null表示第一次对话
String
conversationId
=
difyStreamResponse
.
getConversation_id
();
conversationId
=
difyStreamResponse
.
getConversation_id
();
String
redis_key
=
RedisKeys
.
KONKE_DIFY_CONVERSATION_ID
+
sn
;
String
redis_key
=
RedisKeys
.
KONKE_DIFY_CONVERSATION_ID
+
sn
;
redisTemplate
.
opsForValue
().
set
(
redis_key
,
conversationId
);
redisTemplate
.
opsForValue
().
set
(
redis_key
,
conversationId
);
...
...
src/main/java/com/ikonke/konkeaialibabamcp/service/SycDeviceService.java
View file @
64de612b
...
@@ -42,6 +42,7 @@ public class SycDeviceService {
...
@@ -42,6 +42,7 @@ public class SycDeviceService {
private
IDeviceModelService
deviceModelService
;
private
IDeviceModelService
deviceModelService
;
public
JSONArray
findByCcu
(
String
ccuName
,
Integer
type
,
Integer
capabilities
){
public
JSONArray
findByCcu
(
String
ccuName
,
Integer
type
,
Integer
capabilities
){
long
start
=
System
.
currentTimeMillis
();
log
.
info
(
"findByCcu..根据主机号查询设备..ccuName:{}"
,
ccuName
);
log
.
info
(
"findByCcu..根据主机号查询设备..ccuName:{}"
,
ccuName
);
QueryWrapper
<
SynDevice
>
wrapper
=
new
QueryWrapper
<>();
QueryWrapper
<
SynDevice
>
wrapper
=
new
QueryWrapper
<>();
wrapper
.
eq
(
"ccuId"
,
ccuName
);
wrapper
.
eq
(
"ccuId"
,
ccuName
);
...
@@ -82,6 +83,7 @@ public class SycDeviceService {
...
@@ -82,6 +83,7 @@ public class SycDeviceService {
jsonArray
.
set
(
jsonObject
);
jsonArray
.
set
(
jsonObject
);
}
}
}
}
log
.
info
(
"findByCcu..根据主机号查询设备..耗时:{}"
,
System
.
currentTimeMillis
()-
start
);
return
jsonArray
;
return
jsonArray
;
}
}
...
...
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