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
25e14727
Commit
25e14727
authored
Sep 12, 2025
by
何金镒
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
思必驰的兜底技能3,批量控制设备等
parent
0957bbba
Changes
11
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
512 additions
and
3 deletions
+512
-3
RAG/设备.md
RAG/设备.md
+35
-0
pom.xml
pom.xml
+6
-0
src/main/java/com/ikonke/konkeaialibabamcp/KonkeAiAlibabaMcpApplication.java
...konke/konkeaialibabamcp/KonkeAiAlibabaMcpApplication.java
+2
-2
src/main/java/com/ikonke/konkeaialibabamcp/aitools/BatchDeviceTools.java
...om/ikonke/konkeaialibabamcp/aitools/BatchDeviceTools.java
+136
-0
src/main/java/com/ikonke/konkeaialibabamcp/aitools/DeviceTools.java
...ava/com/ikonke/konkeaialibabamcp/aitools/DeviceTools.java
+6
-0
src/main/java/com/ikonke/konkeaialibabamcp/controller/DeviceController.java
...ikonke/konkeaialibabamcp/controller/DeviceController.java
+6
-0
src/main/java/com/ikonke/konkeaialibabamcp/controller/DifyController.java
...m/ikonke/konkeaialibabamcp/controller/DifyController.java
+2
-0
src/main/java/com/ikonke/konkeaialibabamcp/service/SycDeviceService.java
...om/ikonke/konkeaialibabamcp/service/SycDeviceService.java
+48
-0
src/main/java/com/ikonke/konkeaialibabamcp/utils/KonkeIotUtils.java
...ava/com/ikonke/konkeaialibabamcp/utils/KonkeIotUtils.java
+258
-0
src/main/resources/application-prod.yml
src/main/resources/application-prod.yml
+5
-1
src/main/resources/application.yml
src/main/resources/application.yml
+8
-0
No files found.
RAG/设备.md
0 → 100644
View file @
25e14727
RAG
1、温湿度传感器:3048
2、智能燃气机械臂控制器Z3S:3072
3、水浸传感器-HZ3S版 (3039)
4、燃气报警器-HZ3S版 (3080)
5、水浸传感器 (3055)
6、燃气报警器 (3082)
7、燃气报警器-HS版 (3040)
8、k门窗磁(25)
9、新凯普乐人体感应(77)
10、凯普乐水浸(76)
11、k烟雾报警器(27)
12、KPL燃气报警器(1015)
13、豪恩烟雾传感器(1025)
14、SOS按钮(1033)
15、燃气报警器KZ3S (3106)
16、锁(37)
17、单相电表(39)
18、臻享智能指纹锁(欧莱斯顿m8/m5)(35)
19、零火线单路门禁面板经典版Z3S (3117)
20、MooreX(5005)
21、零火线单路灯控面板Z3S (3001)
22、人体传感器 (3053)
23、灯控继电器【moore 4s】(5004)
24、三路零火面板 (铂金)(4)
25、零火线单路窗帘面板 (3088)
26、零火线单路灯控面板 (3085)
27、风机盘管面板Z3S (3031)
28、水地暖面板Z3S (3029)
29、
D:
\招
标
\建
发招标
\d
ify
\1
0.产品说明书
\A
2面板系列
\光
年系列
pom.xml
View file @
25e14727
...
...
@@ -128,6 +128,12 @@
<!-- <artifactId>spring-webflux</artifactId>-->
<!-- <version>6.1.14</version>-->
<!-- </dependency>-->
<dependency>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-actuator
</artifactId>
</dependency>
</dependencies>
<build>
...
...
src/main/java/com/ikonke/konkeaialibabamcp/KonkeAiAlibabaMcpApplication.java
View file @
25e14727
package
com.ikonke.konkeaialibabamcp
;
import
com.ikonke.konkeaialibabamcp.aitools.BatchDeviceTools
;
import
com.ikonke.konkeaialibabamcp.aitools.CDCSpacesTools
;
import
com.ikonke.konkeaialibabamcp.aitools.DeviceTools
;
import
com.ikonke.konkeaialibabamcp.aitools.WeatherTools
;
import
org.mybatis.spring.annotation.MapperScan
;
import
org.springframework.ai.tool.ToolCallbackProvider
;
...
...
@@ -19,7 +19,7 @@ public class KonkeAiAlibabaMcpApplication {
}
@Bean
public
ToolCallbackProvider
tools
(
DeviceTools
deviceTools
,
WeatherTools
weatherTools
,
CDCSpacesTools
cdcSpacesTools
)
{
public
ToolCallbackProvider
tools
(
Batch
DeviceTools
deviceTools
,
WeatherTools
weatherTools
,
CDCSpacesTools
cdcSpacesTools
)
{
return
MethodToolCallbackProvider
.
builder
()
.
toolObjects
(
deviceTools
,
weatherTools
,
cdcSpacesTools
)
.
build
();
...
...
src/main/java/com/ikonke/konkeaialibabamcp/aitools/BatchDeviceTools.java
0 → 100644
View file @
25e14727
package
com.ikonke.konkeaialibabamcp.aitools
;
import
com.ikonke.konkeaialibabamcp.entity.mongodb.DeviceStatus
;
import
com.ikonke.konkeaialibabamcp.service.SycDeviceService
;
import
com.ikonke.konkeaialibabamcp.service.mongdbservice.DeviceStatusService
;
import
com.ikonke.konkeaialibabamcp.utils.CcuUtils
;
import
com.ikonke.konkeaialibabamcp.utils.KonkeIotUtils
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.ai.tool.annotation.Tool
;
import
org.springframework.ai.tool.annotation.ToolParam
;
import
org.springframework.stereotype.Service
;
@Slf4j
@Service
public
class
BatchDeviceTools
{
private
final
DeviceStatusService
deviceStatusUtil
;
private
final
KonkeIotUtils
konkeIotServer
;
private
final
SycDeviceService
sycDeviceService
;
public
BatchDeviceTools
(
DeviceStatusService
deviceStatusUtil
,
KonkeIotUtils
konkeIotServer
,
SycDeviceService
sycDeviceService
){
this
.
deviceStatusUtil
=
deviceStatusUtil
;
this
.
konkeIotServer
=
konkeIotServer
;
this
.
sycDeviceService
=
sycDeviceService
;
}
@Tool
(
description
=
"智能家居相关:根据主机号和设备ID查询设备状态信息."
)
public
DeviceStatus
findDeviceState
(
@ToolParam
(
description
=
"主机号"
)
String
ccuName
,
@ToolParam
(
description
=
"设备ID"
)
Integer
devId
)
{
log
.
info
(
"mcp调用--->根据主机号和设备ID查询设备状态信息....ccuName:{},devId:{}"
,
ccuName
,
devId
);
return
deviceStatusUtil
.
findUserByUserId
(
CcuUtils
.
getCcuName
(
ccuName
),
devId
);
}
@Tool
(
description
=
"智能家居相关:根据主机号同步设备"
)
public
boolean
synchronousDevice
(
@ToolParam
(
description
=
"主机号"
)
String
ccuName
){
log
.
info
(
"mcp调用--->根据主机号同步设备....ccuName:{}"
,
ccuName
);
return
sycDeviceService
.
synchronousDevice
(
CcuUtils
.
getCcuName
(
ccuName
));
}
//==============================设备控制=============================================
@Tool
(
description
=
"智能家居相关:根据主机号和设备ID控制:打开设备"
)
public
String
optDeviceOpen
(
@ToolParam
(
description
=
"主机号"
)
String
ccuName
,
@ToolParam
(
description
=
"设备ID,多个使用逗号隔开"
)
String
devId
){
log
.
info
(
"mcp调用--->根据主机号和多个设备ID与设备类型ID批量控制....ccuName:{},devIds:{}"
,
ccuName
,
devId
);
return
konkeIotServer
.
batchOptDeviceOpen
(
CcuUtils
.
getCcuName
(
ccuName
),
devId
);
}
@Tool
(
description
=
"智能家居相关:根据主机号和设备ID控制:关闭设备"
)
public
String
optDeviceClosed
(
@ToolParam
(
description
=
"主机号"
)
String
ccuName
,
@ToolParam
(
description
=
"设备ID,多个使用逗号隔开"
)
String
devId
){
log
.
info
(
"mcp调用--->根据主机号和设备ID控制关闭设备..批量控制..ccuName:{},devId:{},"
,
ccuName
,
devId
);
return
konkeIotServer
.
batchOptDeviceClosed
(
CcuUtils
.
getCcuName
(
ccuName
),
devId
);
}
@Tool
(
description
=
"智能家居相关:根据主机号和设备ID控制:设置亮度"
)
public
String
setBrightness
(
@ToolParam
(
description
=
"主机号"
)
String
ccuName
,
@ToolParam
(
description
=
"设备ID,多个使用逗号隔开"
)
String
devId
,
@ToolParam
(
description
=
"设置的亮度百分比大小,范围是0-100"
)
int
brightness
){
log
.
info
(
"mcp调用--->根据主机号和设备ID控制设备亮度..批量控制..ccuName:{},devId:{},brightness:{}"
,
ccuName
,
devId
,
brightness
);
return
konkeIotServer
.
batchSetBrightness
(
CcuUtils
.
getCcuName
(
ccuName
),
devId
,
brightness
);
}
@Tool
(
description
=
"智能家居相关:根据主机号和设备ID控制:设置色温"
)
public
String
setColourTemperature
(
@ToolParam
(
description
=
"主机号"
)
String
ccuName
,
@ToolParam
(
description
=
"设备ID,多个使用逗号隔开"
)
String
devId
,
@ToolParam
(
description
=
"设置的色温百分比大小,范围是0-100"
)
int
colourTemperature
){
log
.
info
(
"mcp调用--->根据主机号和设备ID控制设备的色温..批量控制..ccuName:{},devId:{},colourTemperature:{}"
,
ccuName
,
devId
,
colourTemperature
);
return
konkeIotServer
.
batchSetColourTemperature
(
CcuUtils
.
getCcuName
(
ccuName
),
devId
,
colourTemperature
);
}
@Tool
(
description
=
"智能家居相关:根据主机号和设备ID控制:设置显示的颜色"
)
public
String
setColor
(
@ToolParam
(
description
=
"主机号"
)
String
ccuName
,
@ToolParam
(
description
=
"设备ID,多个使用逗号隔开"
)
String
devId
,
@ToolParam
(
description
=
"要设置的颜色,支持的颜色:Red,Yellow,Blue,Green,White,Black,Cyan,Purple,Orange,Pink,Violet,Magenta,Indigo,SlateBlue,DarkBlue,SkyBlue,DarkCyan,Beige,Brown"
)
String
color
){
log
.
info
(
"mcp调用--->根据主机号和设备ID控制设备的颜色..批量控制..ccuName:{},devId:{},color:{}"
,
ccuName
,
devId
,
color
);
return
konkeIotServer
.
batchSetColor
(
CcuUtils
.
getCcuName
(
ccuName
),
devId
,
color
);
}
@Tool
(
description
=
"智能家居相关:根据主机号和设备ID控制:暂停设备.只支持窗帘类型"
)
public
String
setPause
(
@ToolParam
(
description
=
"主机号"
)
String
ccuName
,
@ToolParam
(
description
=
"设备ID,多个使用逗号隔开"
)
String
devId
){
log
.
info
(
"mcp调用--->根据主机号和设备ID控制暂停设备..批量控制..ccuName:{},devId:{}"
,
ccuName
,
devId
);
return
konkeIotServer
.
batchSetPause
(
CcuUtils
.
getCcuName
(
ccuName
),
devId
);
}
@Tool
(
description
=
"智能家居相关:根据主机号和设备ID控制设备:移动位置.只支持窗帘电机(CURTAIN_MOTOR)类型"
)
public
String
setMove
(
@ToolParam
(
description
=
"主机号"
)
String
ccuName
,
@ToolParam
(
description
=
"设备ID,多个使用逗号隔开"
)
String
devId
,
@ToolParam
(
description
=
"移动的距离,范围是0-100"
)
int
progress
){
log
.
info
(
"mcp调用--->根据主机号和设备ID控制其移动位置..批量控制..ccuName:{},devId:{},progress:{}"
,
ccuName
,
devId
,
progress
);
return
konkeIotServer
.
batchSetMove
(
CcuUtils
.
getCcuName
(
ccuName
),
devId
,
progress
);
}
@Tool
(
description
=
"智能家居相关:根据主机号和设备ID控制设备:延时关机.只支持新风、地暖、空调"
)
public
String
setDelayedShutdown
(
@ToolParam
(
description
=
"主机号"
)
String
ccuName
,
@ToolParam
(
description
=
"设备ID,多个使用逗号隔开"
)
String
devId
,
@ToolParam
(
description
=
"多少分钟后关机,范围30-1440,必须是30的倍数,最小是半小时"
)
int
delayTime
){
log
.
info
(
"mcp调用--->根据主机号和设备ID控制设备延时关机..批量控制..ccuName:{},devId:{},delayTime:{}"
,
ccuName
,
devId
,
delayTime
);
return
konkeIotServer
.
batchSetDelayedShutdown
(
CcuUtils
.
getCcuName
(
ccuName
),
devId
,
delayTime
);
}
@Tool
(
description
=
"智能家居相关:根据主机号和设备ID设置设备的工作温度.只支持空调、地暖"
)
public
String
setTemperature
(
@ToolParam
(
description
=
"主机号"
)
String
ccuName
,
@ToolParam
(
description
=
"设备ID,多个使用逗号隔开"
)
String
devId
,
@ToolParam
(
description
=
"设置的温度大小,范围是5-35"
)
double
temperature
){
log
.
info
(
"mcp调用--->根据主机号和设备ID设置设备的工作温度..批量控制..ccuName:{},devId:{},temperature:{}"
,
ccuName
,
devId
,
temperature
);
return
konkeIotServer
.
batchSetTemperature
(
CcuUtils
.
getCcuName
(
ccuName
),
devId
,
temperature
);
}
@Tool
(
description
=
"智能家居相关:根据主机号和设备ID设置设备的工作模式.只支持地暖、空调、新风"
)
public
String
setModel
(
@ToolParam
(
description
=
"主机号"
)
String
ccuName
,
@ToolParam
(
description
=
"设备ID,多个使用逗号隔开"
)
String
devId
,
@ToolParam
(
description
=
"设置的工作模式,枚举值:WIND、HOT、COLD、DEHUMIDIFICATION、AUTO、MANUAL"
)
String
mode
){
log
.
info
(
"mcp调用--->根据主机号和设备ID设置设备的工作模式..批量控制..ccuName:{},devId:{},mode:{}"
,
ccuName
,
devId
,
mode
);
return
konkeIotServer
.
batchSetModel
(
CcuUtils
.
getCcuName
(
ccuName
),
devId
,
mode
);
}
@Tool
(
description
=
"智能家居相关:根据主机号和设备ID设置设备的工作风速.只支持空调、新风"
)
public
String
setSpeed
(
@ToolParam
(
description
=
"主机号"
)
String
ccuName
,
@ToolParam
(
description
=
"设备ID,多个使用逗号隔开"
)
String
devId
,
@ToolParam
(
description
=
"设置的工作风速,枚举值:LOW、MID、HIGH、AUTO、STOP"
)
String
speed
){
log
.
info
(
"mcp调用--->根据主机号和设备ID设置设备的工作风速..批量控制..ccuName:{},devId:{},mode:{}"
,
ccuName
,
devId
,
speed
);
return
konkeIotServer
.
batchSetSpeed
(
CcuUtils
.
getCcuName
(
ccuName
),
devId
,
speed
);
}
@Tool
(
description
=
"智能家居相关:根据主机号和场景ID:触发场景"
)
public
String
triggerScene
(
@ToolParam
(
description
=
"主机号"
)
String
ccuName
,
@ToolParam
(
description
=
"场景ID"
)
String
devId
,
@ToolParam
(
description
=
"场景类型ID,type等于scene"
)
String
typeId
){
log
.
info
(
"mcp调用--->根据主机号和场景ID触发场景....ccuName:{},devId:{},type:{}"
,
ccuName
,
devId
,
typeId
);
return
konkeIotServer
.
optScene
(
CcuUtils
.
getCcuName
(
ccuName
),
devId
);
}
//===================================================================================================
}
src/main/java/com/ikonke/konkeaialibabamcp/aitools/DeviceTools.java
View file @
25e14727
...
...
@@ -45,6 +45,12 @@ public class DeviceTools {
log
.
info
(
"mcp调用--->根据主机号和设备ID控制打开设备....ccuName:{},devId:{},type:{}"
,
ccuName
,
devId
,
typeId
);
return
konkeIotServer
.
optDeviceOpen
(
CcuUtils
.
getCcuName
(
ccuName
),
devId
,
typeId
);
}
@Tool
(
description
=
"智能家居相关:根据主机号和多个设备ID批量控制:打开设备"
)
public
String
batchOptDeviceOpen
(
@ToolParam
(
description
=
"主机号"
)
String
ccuName
,
@ToolParam
(
description
=
"设备ID,多个使用逗号隔开"
)
String
devIds
){
log
.
info
(
"mcp调用--->根据主机号和多个设备ID与设备类型ID批量控制....ccuName:{},devIds:{}"
,
ccuName
,
devIds
);
return
konkeIotServer
.
batchOptDeviceOpen
(
CcuUtils
.
getCcuName
(
ccuName
),
devIds
);
}
@Tool
(
description
=
"智能家居相关:根据主机号和设备ID控制:关闭设备"
)
public
String
optDeviceClosed
(
@ToolParam
(
description
=
"主机号"
)
String
ccuName
,
@ToolParam
(
description
=
"设备ID"
)
String
devId
,
...
...
src/main/java/com/ikonke/konkeaialibabamcp/controller/DeviceController.java
View file @
25e14727
...
...
@@ -36,6 +36,12 @@ public class DeviceController {
log
.
info
(
"findDeviceByName..根据主机号和设备名称模糊查询设备..ccuName:{},deviceName:{},roomName:{}"
,
ccuName
,
deviceName
,
roomName
);
return
sycDeviceService
.
findDeviceByName
(
ccuName
,
deviceName
,
roomName
);
}
@PostMapping
(
"/findDeviceByName"
)
public
JSONArray
findDeviceByName
(
@RequestParam
(
name
=
"ccuName"
)
String
ccuName
,
@RequestBody
JSONArray
param
){
log
.
info
(
"findDeviceByName..根据主机号和设备名称模糊查询设备.2..ccuName:{},param:{}"
,
ccuName
,
param
);
return
sycDeviceService
.
findDeviceByName2
(
ccuName
,
param
);
}
@GetMapping
(
"/synchronousDevice"
)
public
Boolean
synchronousDevice
(
@RequestParam
(
value
=
"ccuName"
)
String
ccuName
)
{
...
...
src/main/java/com/ikonke/konkeaialibabamcp/controller/DifyController.java
View file @
25e14727
...
...
@@ -265,6 +265,7 @@ public class DifyController {
.
bodyValue
(
body
)
.
retrieve
()
.
bodyToFlux
(
DifyStreamResponse
.
class
)
//实体转换
.
timeout
(
Duration
.
ofMinutes
(
1
))
//设置超时时间1分钟
.
filter
(
this
::
shouldInclude
)
// 过滤掉不需要的数据【根据需求增加】
.
map
((
DifyStreamResponse
difyStreamResponse
)
->
convertToCustomResponseAsync
(
difyStreamResponse
,
sn
,
ccuName
,
token
,
redis_conversationId
))
// 异步转换【如果返回格式自定义则通过异步转换实现】
.
onErrorResume
(
throwable
->
{
...
...
@@ -322,6 +323,7 @@ public class DifyController {
.
bodyValue
(
body
)
.
retrieve
()
.
bodyToFlux
(
DifyStreamResponse
.
class
)
//实体转换
.
timeout
(
Duration
.
ofMinutes
(
1
))
//设置超时时间1分钟
.
filter
(
this
::
shouldInclude
)
// 过滤掉不需要的数据【根据需求增加】
.
map
((
DifyStreamResponse
difyStreamResponse
)
->
convertToCustomResponseAsync
(
difyStreamResponse
,
sn
,
ccuName
,
token
,
redis_conversationId
))
// 异步转换【如果返回格式自定义则通过异步转换实现】
.
onErrorResume
(
throwable
->
{
...
...
src/main/java/com/ikonke/konkeaialibabamcp/service/SycDeviceService.java
View file @
25e14727
...
...
@@ -41,6 +41,54 @@ public class SycDeviceService {
@Autowired
private
IDeviceModelService
deviceModelService
;
public
SynDevice
findById
(
String
ccuName
,
String
deviceId
){
QueryWrapper
<
SynDevice
>
wrapper
=
new
QueryWrapper
<>();
wrapper
.
eq
(
"ccuId"
,
ccuName
);
wrapper
.
eq
(
"deviceId"
,
deviceId
);
List
<
SynDevice
>
list
=
synDeviceService
.
list
(
wrapper
);
return
list
.
isEmpty
()?
null
:
list
.
get
(
0
);
}
public
JSONArray
findDeviceByName2
(
String
ccuName
,
JSONArray
param
){
long
start
=
System
.
currentTimeMillis
();
QueryWrapper
<
SynDevice
>
wrapper
=
new
QueryWrapper
<>();
wrapper
.
eq
(
"ccuId"
,
ccuName
);
wrapper
.
and
(
wrapper1
->
{
// 处理第一个条件
JSONObject
first
=
param
.
getJSONObject
(
0
);
wrapper1
.
like
(
"roomName"
,
first
.
get
(
"roomName"
))
.
like
(
"deviceName"
,
first
.
get
(
"deviceName"
));
// 处理剩余条件
for
(
int
i
=
1
;
i
<
param
.
size
();
i
++)
{
JSONObject
condition
=
param
.
getJSONObject
(
i
);
wrapper1
.
or
()
.
like
(
"roomName"
,
condition
.
get
(
"roomName"
))
.
like
(
"deviceName"
,
condition
.
get
(
"deviceName"
));
}
});
List
<
SynDevice
>
list
=
synDeviceService
.
list
(
wrapper
);
JSONArray
jsonArray
=
new
JSONArray
();
if
(!
list
.
isEmpty
()){
for
(
SynDevice
synDevice
:
list
)
{
JSONObject
jsonObject
=
new
JSONObject
();
String
operateId
=
synDevice
.
getOperateId
();
jsonObject
.
set
(
"deviceId"
,
synDevice
.
getDeviceId
());
jsonObject
.
set
(
"deviceName"
,
synDevice
.
getDeviceName
());
jsonObject
.
set
(
"roomId"
,
synDevice
.
getRoomId
());
jsonObject
.
set
(
"roomName"
,
synDevice
.
getRoomName
());
jsonObject
.
set
(
"typeId"
,
operateId
);
jsonObject
.
set
(
"model"
,
synDevice
.
getModel
());
jsonArray
.
set
(
jsonObject
);
}
}
log
.
info
(
"findDeviceByName..耗时:{}"
,
System
.
currentTimeMillis
()-
start
);
return
jsonArray
;
}
public
JSONArray
findDeviceByName
(
String
ccuName
,
String
deviceName
,
String
roomName
){
long
start
=
System
.
currentTimeMillis
();
QueryWrapper
<
SynDevice
>
wrapper
=
new
QueryWrapper
<>();
...
...
src/main/java/com/ikonke/konkeaialibabamcp/utils/KonkeIotUtils.java
View file @
25e14727
...
...
@@ -73,6 +73,30 @@ public class KonkeIotUtils {
return
one
!=
null
&&
one
.
getStatus
().
containsKey
(
"online"
)
&&
"1"
.
equals
(
one
.
getStatus
().
get
(
"online"
).
toString
());
}
public
String
batchOptDeviceOpen
(
String
ccuName
,
String
devIds
){
try
{
if
(
StrUtil
.
isBlank
(
ccuName
)
||
StrUtil
.
isBlank
(
devIds
)){
throw
new
StatefulException
(-
20
,
"参数不能为空"
);
}
List
<
String
>
devIdList
=
List
.
of
(
devIds
.
split
(
","
));
for
(
String
devId
:
devIdList
){
if
(
getDeviceOnline
(
ccuName
,
devId
))
{
throw
new
StatefulException
(-
30
,
"设备已离线"
);
}
SynDevice
byId
=
sycDeviceService
.
findById
(
ccuName
,
devId
);
if
(
byId
==
null
){
continue
;
}
this
.
optDeviceOpen
(
ccuName
,
devId
,
byId
.
getOperateId
());
}
return
"控制成功"
;
}
catch
(
Exception
e
){
e
.
printStackTrace
();
return
"控制失败"
;
}
}
public
String
optDeviceOpen
(
String
ccuName
,
String
devId
,
String
operateId
){
if
(
StrUtil
.
isBlank
(
ccuName
)
||
StrUtil
.
isBlank
(
devId
)
||
StrUtil
.
isBlank
(
operateId
)){
throw
new
StatefulException
(-
20
,
"参数不能为空"
);
...
...
@@ -106,6 +130,30 @@ public class KonkeIotUtils {
}
return
optAIDevice
(
ccuName
,
devId
,
action
,
opt
.
toString
());
}
public
String
batchOptDeviceClosed
(
String
ccuName
,
String
devIds
){
try
{
if
(
StrUtil
.
isBlank
(
ccuName
)
||
StrUtil
.
isBlank
(
devIds
)){
throw
new
StatefulException
(-
20
,
"参数不能为空"
);
}
List
<
String
>
devIdList
=
List
.
of
(
devIds
.
split
(
","
));
for
(
String
devId
:
devIdList
){
if
(
getDeviceOnline
(
ccuName
,
devId
))
{
throw
new
StatefulException
(-
30
,
"设备已离线"
);
}
SynDevice
byId
=
sycDeviceService
.
findById
(
ccuName
,
devId
);
if
(
byId
==
null
){
continue
;
}
this
.
optDeviceClosed
(
ccuName
,
devId
,
byId
.
getOperateId
());
}
return
"控制成功"
;
}
catch
(
Exception
e
){
e
.
printStackTrace
();
return
"控制失败"
;
}
}
public
String
optDeviceClosed
(
String
ccuName
,
String
devId
,
String
operateId
){
if
(
StrUtil
.
isBlank
(
ccuName
)
||
StrUtil
.
isBlank
(
devId
)
||
StrUtil
.
isBlank
(
operateId
)){
throw
new
StatefulException
(-
20
,
"参数不能为空"
);
...
...
@@ -142,6 +190,30 @@ public class KonkeIotUtils {
return
optAIDevice
(
ccuName
,
devId
,
action
,
opt
.
toString
());
}
public
String
batchSetBrightness
(
String
ccuName
,
String
devIds
,
int
brightness
){
try
{
if
(
StrUtil
.
isBlank
(
ccuName
)
||
StrUtil
.
isBlank
(
devIds
)){
throw
new
StatefulException
(-
20
,
"参数不能为空"
);
}
List
<
String
>
devIdList
=
List
.
of
(
devIds
.
split
(
","
));
for
(
String
devId
:
devIdList
){
if
(
getDeviceOnline
(
ccuName
,
devId
))
{
throw
new
StatefulException
(-
30
,
"设备已离线"
);
}
SynDevice
byId
=
sycDeviceService
.
findById
(
ccuName
,
devId
);
if
(
byId
==
null
){
continue
;
}
this
.
setBrightness
(
ccuName
,
devId
,
byId
.
getOperateId
(),
brightness
);
}
return
"控制成功"
;
}
catch
(
Exception
e
){
e
.
printStackTrace
();
return
"控制失败"
;
}
}
/**
* 设置亮度
*/
...
...
@@ -174,6 +246,30 @@ public class KonkeIotUtils {
return
optAIDevice
(
ccuName
,
devId
,
action
,
opt
.
toString
());
}
public
String
batchSetColourTemperature
(
String
ccuName
,
String
devIds
,
int
colourTemperature
){
try
{
if
(
StrUtil
.
isBlank
(
ccuName
)
||
StrUtil
.
isBlank
(
devIds
)){
throw
new
StatefulException
(-
20
,
"参数不能为空"
);
}
List
<
String
>
devIdList
=
List
.
of
(
devIds
.
split
(
","
));
for
(
String
devId
:
devIdList
){
if
(
getDeviceOnline
(
ccuName
,
devId
))
{
throw
new
StatefulException
(-
30
,
"设备已离线"
);
}
SynDevice
byId
=
sycDeviceService
.
findById
(
ccuName
,
devId
);
if
(
byId
==
null
){
continue
;
}
this
.
setColourTemperature
(
ccuName
,
devId
,
byId
.
getOperateId
(),
colourTemperature
);
}
return
"控制成功"
;
}
catch
(
Exception
e
){
e
.
printStackTrace
();
return
"控制失败"
;
}
}
/**
* 设置色温
*/
...
...
@@ -205,6 +301,30 @@ public class KonkeIotUtils {
return
optAIDevice
(
ccuName
,
devId
,
action
,
opt
.
toString
());
}
public
String
batchSetColor
(
String
ccuName
,
String
devIds
,
String
color
){
try
{
if
(
StrUtil
.
isBlank
(
ccuName
)
||
StrUtil
.
isBlank
(
devIds
)){
throw
new
StatefulException
(-
20
,
"参数不能为空"
);
}
List
<
String
>
devIdList
=
List
.
of
(
devIds
.
split
(
","
));
for
(
String
devId
:
devIdList
){
if
(
getDeviceOnline
(
ccuName
,
devId
))
{
throw
new
StatefulException
(-
30
,
"设备已离线"
);
}
SynDevice
byId
=
sycDeviceService
.
findById
(
ccuName
,
devId
);
if
(
byId
==
null
){
continue
;
}
this
.
setColor
(
ccuName
,
devId
,
byId
.
getOperateId
(),
color
);
}
return
"控制成功"
;
}
catch
(
Exception
e
){
e
.
printStackTrace
();
return
"控制失败"
;
}
}
/**
* 设置颜色
*/
...
...
@@ -239,6 +359,30 @@ public class KonkeIotUtils {
return
optAIDevice
(
ccuName
,
devId
,
action
,
opt
.
toString
());
}
public
String
batchSetPause
(
String
ccuName
,
String
devIds
){
try
{
if
(
StrUtil
.
isBlank
(
ccuName
)
||
StrUtil
.
isBlank
(
devIds
)){
throw
new
StatefulException
(-
20
,
"参数不能为空"
);
}
List
<
String
>
devIdList
=
List
.
of
(
devIds
.
split
(
","
));
for
(
String
devId
:
devIdList
){
if
(
getDeviceOnline
(
ccuName
,
devId
))
{
throw
new
StatefulException
(-
30
,
"设备已离线"
);
}
SynDevice
byId
=
sycDeviceService
.
findById
(
ccuName
,
devId
);
if
(
byId
==
null
){
continue
;
}
this
.
setPause
(
ccuName
,
devId
,
byId
.
getOperateId
());
}
return
"控制成功"
;
}
catch
(
Exception
e
){
e
.
printStackTrace
();
return
"控制失败"
;
}
}
/**
* 暂停-目前只有窗帘才支持暂停
*/
...
...
@@ -269,6 +413,29 @@ public class KonkeIotUtils {
return
optAIDevice
(
ccuName
,
devId
,
action
,
opt
.
toString
());
}
public
String
batchSetMove
(
String
ccuName
,
String
devIds
,
int
progress
){
try
{
if
(
StrUtil
.
isBlank
(
ccuName
)
||
StrUtil
.
isBlank
(
devIds
)){
throw
new
StatefulException
(-
20
,
"参数不能为空"
);
}
List
<
String
>
devIdList
=
List
.
of
(
devIds
.
split
(
","
));
for
(
String
devId
:
devIdList
){
if
(
getDeviceOnline
(
ccuName
,
devId
))
{
throw
new
StatefulException
(-
30
,
"设备已离线"
);
}
SynDevice
byId
=
sycDeviceService
.
findById
(
ccuName
,
devId
);
if
(
byId
==
null
){
continue
;
}
this
.
setMove
(
ccuName
,
devId
,
byId
.
getOperateId
(),
progress
);
}
return
"控制成功"
;
}
catch
(
Exception
e
){
e
.
printStackTrace
();
return
"控制失败"
;
}
}
/**
* 移动位置-目前只有窗帘电机才支持移动位置
*/
...
...
@@ -302,6 +469,29 @@ public class KonkeIotUtils {
return
optAIDevice
(
ccuName
,
devId
,
action
,
opt
.
toString
());
}
public
String
batchSetDelayedShutdown
(
String
ccuName
,
String
devIds
,
int
delayTime
){
try
{
if
(
StrUtil
.
isBlank
(
ccuName
)
||
StrUtil
.
isBlank
(
devIds
)){
throw
new
StatefulException
(-
20
,
"参数不能为空"
);
}
List
<
String
>
devIdList
=
List
.
of
(
devIds
.
split
(
","
));
for
(
String
devId
:
devIdList
){
if
(
getDeviceOnline
(
ccuName
,
devId
))
{
throw
new
StatefulException
(-
30
,
"设备已离线"
);
}
SynDevice
byId
=
sycDeviceService
.
findById
(
ccuName
,
devId
);
if
(
byId
==
null
){
continue
;
}
this
.
setDelayedShutdown
(
ccuName
,
devId
,
byId
.
getOperateId
(),
delayTime
);
}
return
"控制成功"
;
}
catch
(
Exception
e
){
e
.
printStackTrace
();
return
"控制失败"
;
}
}
/**
* 设置延时关机
...
...
@@ -371,6 +561,29 @@ public class KonkeIotUtils {
return
String
.
format
(
"%02d:%02d"
,
hours
,
mins
);
}
public
String
batchSetTemperature
(
String
ccuName
,
String
devIds
,
double
temperature
){
try
{
if
(
StrUtil
.
isBlank
(
ccuName
)
||
StrUtil
.
isBlank
(
devIds
)){
throw
new
StatefulException
(-
20
,
"参数不能为空"
);
}
List
<
String
>
devIdList
=
List
.
of
(
devIds
.
split
(
","
));
for
(
String
devId
:
devIdList
){
if
(
getDeviceOnline
(
ccuName
,
devId
))
{
throw
new
StatefulException
(-
30
,
"设备已离线"
);
}
SynDevice
byId
=
sycDeviceService
.
findById
(
ccuName
,
devId
);
if
(
byId
==
null
){
continue
;
}
this
.
setTemperature
(
ccuName
,
devId
,
byId
.
getOperateId
(),
temperature
);
}
return
"控制成功"
;
}
catch
(
Exception
e
){
e
.
printStackTrace
();
return
"控制失败"
;
}
}
/**
* 设置温度
...
...
@@ -410,7 +623,29 @@ public class KonkeIotUtils {
}
public
String
batchSetModel
(
String
ccuName
,
String
devIds
,
String
mode
){
try
{
if
(
StrUtil
.
isBlank
(
ccuName
)
||
StrUtil
.
isBlank
(
devIds
)){
throw
new
StatefulException
(-
20
,
"参数不能为空"
);
}
List
<
String
>
devIdList
=
List
.
of
(
devIds
.
split
(
","
));
for
(
String
devId
:
devIdList
){
if
(
getDeviceOnline
(
ccuName
,
devId
))
{
throw
new
StatefulException
(-
30
,
"设备已离线"
);
}
SynDevice
byId
=
sycDeviceService
.
findById
(
ccuName
,
devId
);
if
(
byId
==
null
){
continue
;
}
this
.
setModel
(
ccuName
,
devId
,
byId
.
getOperateId
(),
mode
);
}
return
"控制成功"
;
}
catch
(
Exception
e
){
e
.
printStackTrace
();
return
"控制失败"
;
}
}
/**
* 设置模式
...
...
@@ -469,6 +704,29 @@ public class KonkeIotUtils {
return
optAIDevice
(
ccuName
,
devId
,
action
,
opt
.
toString
());
}
public
String
batchSetSpeed
(
String
ccuName
,
String
devIds
,
String
speed
){
try
{
if
(
StrUtil
.
isBlank
(
ccuName
)
||
StrUtil
.
isBlank
(
devIds
)){
throw
new
StatefulException
(-
20
,
"参数不能为空"
);
}
List
<
String
>
devIdList
=
List
.
of
(
devIds
.
split
(
","
));
for
(
String
devId
:
devIdList
){
if
(
getDeviceOnline
(
ccuName
,
devId
))
{
throw
new
StatefulException
(-
30
,
"设备已离线"
);
}
SynDevice
byId
=
sycDeviceService
.
findById
(
ccuName
,
devId
);
if
(
byId
==
null
){
continue
;
}
this
.
setSpeed
(
ccuName
,
devId
,
byId
.
getOperateId
(),
speed
);
}
return
"控制成功"
;
}
catch
(
Exception
e
){
e
.
printStackTrace
();
return
"控制失败"
;
}
}
/**
* 设置风速
...
...
src/main/resources/application-prod.yml
View file @
25e14727
...
...
@@ -23,11 +23,14 @@ spring:
mybatis-plus
:
configuration
:
log-impl
:
org.apache.ibatis.logging.stdout.StdOutImpl
mapper-locations
:
classpath*:/mapper/**/*.xml
type-aliases-package
:
com.ikonke.konkeaialibabamcp.entity.mysql
logging
:
level
:
com.baomidou.mybatisplus
:
DEBUG
org.springframework.cloud.sleuth
:
DEBUG
root
:
info
file
:
...
...
@@ -41,6 +44,7 @@ logging:
max-history
:
30
konke
:
weather
:
clientId
:
da4c19db2be64671
...
...
@@ -51,6 +55,6 @@ konke:
cdc
:
timeout
:
20000
url
:
http
://community.jfzhtest.com/prod-api
url
:
http
s://sqdn.cndmega.com/prod-v2.0.1
difyChatSteamMessages
:
http://127.0.0.1:${server.port}
src/main/resources/application.yml
View file @
25e14727
...
...
@@ -20,6 +20,14 @@ spring:
completion
:
true
enabled
:
true
management
:
endpoints
:
health
:
show-details
:
always
web
:
exposure
:
include
:
metrics,health,prometheus
cdc
:
ownerLoginUrl
:
${cdc.url}/auth/owner/login
getOwnerUrl
:
${cdc.url}/system/screen/owner/info
...
...
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