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
01fec03f
Commit
01fec03f
authored
Aug 20, 2025
by
何金镒
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
窗帘、空调、新风、地暖的设备同步与mcp控制
parent
86cc6c62
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
138 additions
and
65 deletions
+138
-65
src/main/java/com/ikonke/konkeaialibabamcp/aitools/DeviceTools.java
...ava/com/ikonke/konkeaialibabamcp/aitools/DeviceTools.java
+39
-35
src/main/java/com/ikonke/konkeaialibabamcp/constant/DeviceConstant.java
...com/ikonke/konkeaialibabamcp/constant/DeviceConstant.java
+62
-0
src/main/java/com/ikonke/konkeaialibabamcp/entity/mysql/SynDevice.java
.../com/ikonke/konkeaialibabamcp/entity/mysql/SynDevice.java
+4
-0
src/main/java/com/ikonke/konkeaialibabamcp/service/SycDeviceService.java
...om/ikonke/konkeaialibabamcp/service/SycDeviceService.java
+21
-13
src/main/java/com/ikonke/konkeaialibabamcp/utils/KonkeIotUtils.java
...ava/com/ikonke/konkeaialibabamcp/utils/KonkeIotUtils.java
+12
-17
No files found.
src/main/java/com/ikonke/konkeaialibabamcp/aitools/DeviceTools.java
View file @
01fec03f
...
@@ -37,80 +37,84 @@ public class DeviceTools {
...
@@ -37,80 +37,84 @@ public class DeviceTools {
return
sycDeviceService
.
synchronousDevice
(
CcuUtils
.
getCcuName
(
ccuName
));
return
sycDeviceService
.
synchronousDevice
(
CcuUtils
.
getCcuName
(
ccuName
));
}
}
@Tool
(
description
=
"根据主机号和设备ID控制打开设备"
)
//==============================设备控制=============================================
@Tool
(
description
=
"根据主机号和设备ID控制:打开设备"
)
public
String
optDeviceOpen
(
@ToolParam
(
description
=
"主机号"
)
String
ccuName
,
public
String
optDeviceOpen
(
@ToolParam
(
description
=
"主机号"
)
String
ccuName
,
@ToolParam
(
description
=
"设备ID"
)
String
devId
,
@ToolParam
(
description
=
"设备ID"
)
String
devId
,
@ToolParam
(
description
=
"设备类型
"
)
String
type
){
@ToolParam
(
description
=
"设备类型
ID"
)
String
typeId
){
log
.
info
(
"mcp调用--->根据主机号和设备ID控制打开设备....ccuName:{},devId:{},type:{}"
,
ccuName
,
devId
,
type
);
log
.
info
(
"mcp调用--->根据主机号和设备ID控制打开设备....ccuName:{},devId:{},type:{}"
,
ccuName
,
devId
,
type
Id
);
return
konkeIotServer
.
optDeviceOpen
(
CcuUtils
.
getCcuName
(
ccuName
),
devId
,
type
);
return
konkeIotServer
.
optDeviceOpen
(
CcuUtils
.
getCcuName
(
ccuName
),
devId
,
type
Id
);
}
}
@Tool
(
description
=
"根据主机号和设备ID控制关闭设备"
)
@Tool
(
description
=
"根据主机号和设备ID控制
:
关闭设备"
)
public
String
optDeviceClosed
(
@ToolParam
(
description
=
"主机号"
)
String
ccuName
,
public
String
optDeviceClosed
(
@ToolParam
(
description
=
"主机号"
)
String
ccuName
,
@ToolParam
(
description
=
"设备ID"
)
String
devId
,
@ToolParam
(
description
=
"设备ID"
)
String
devId
,
@ToolParam
(
description
=
"设备类型
"
)
String
type
){
@ToolParam
(
description
=
"设备类型
ID"
)
String
typeId
){
log
.
info
(
"mcp调用--->根据主机号和设备ID控制关闭设备....ccuName:{},devId:{},type:{}"
,
ccuName
,
devId
,
type
);
log
.
info
(
"mcp调用--->根据主机号和设备ID控制关闭设备....ccuName:{},devId:{},type:{}"
,
ccuName
,
devId
,
type
Id
);
return
konkeIotServer
.
optDeviceClosed
(
CcuUtils
.
getCcuName
(
ccuName
),
devId
,
type
);
return
konkeIotServer
.
optDeviceClosed
(
CcuUtils
.
getCcuName
(
ccuName
),
devId
,
type
Id
);
}
}
@Tool
(
description
=
"根据主机号和设备ID控制
暂停设备
"
)
@Tool
(
description
=
"根据主机号和设备ID控制
:暂停设备.只支持窗帘类型
"
)
public
String
setPause
(
@ToolParam
(
description
=
"主机号"
)
String
ccuName
,
public
String
setPause
(
@ToolParam
(
description
=
"主机号"
)
String
ccuName
,
@ToolParam
(
description
=
"设备ID"
)
String
devId
,
@ToolParam
(
description
=
"设备ID"
)
String
devId
,
@ToolParam
(
description
=
"设备类型
"
)
String
type
){
@ToolParam
(
description
=
"设备类型
ID"
)
String
typeId
){
log
.
info
(
"mcp调用--->根据主机号和设备ID控制暂停设备....ccuName:{},devId:{},type:{}"
,
ccuName
,
devId
,
type
);
log
.
info
(
"mcp调用--->根据主机号和设备ID控制暂停设备....ccuName:{},devId:{},type:{}"
,
ccuName
,
devId
,
type
Id
);
return
konkeIotServer
.
setPause
(
CcuUtils
.
getCcuName
(
ccuName
),
devId
,
type
);
return
konkeIotServer
.
setPause
(
CcuUtils
.
getCcuName
(
ccuName
),
devId
,
type
Id
);
}
}
@Tool
(
description
=
"根据主机号和设备ID控制设备
移动位置
"
)
@Tool
(
description
=
"根据主机号和设备ID控制设备
:移动位置.只支持窗帘电机(CURTAIN_MOTOR)类型
"
)
public
String
setMove
(
@ToolParam
(
description
=
"主机号"
)
String
ccuName
,
public
String
setMove
(
@ToolParam
(
description
=
"主机号"
)
String
ccuName
,
@ToolParam
(
description
=
"设备ID"
)
String
devId
,
@ToolParam
(
description
=
"设备ID"
)
String
devId
,
@ToolParam
(
description
=
"设备类型
"
)
String
type
,
@ToolParam
(
description
=
"设备类型
ID"
)
String
typeId
,
@ToolParam
(
description
=
"移动的距离,范围是0-100"
)
int
progress
){
@ToolParam
(
description
=
"移动的距离,范围是0-100"
)
int
progress
){
log
.
info
(
"mcp调用--->根据主机号和设备ID控制其移动位置....ccuName:{},devId:{},type:{},progress:{}"
,
ccuName
,
devId
,
type
,
progress
);
log
.
info
(
"mcp调用--->根据主机号和设备ID控制其移动位置....ccuName:{},devId:{},type:{},progress:{}"
,
ccuName
,
devId
,
type
Id
,
progress
);
return
konkeIotServer
.
setMove
(
CcuUtils
.
getCcuName
(
ccuName
),
devId
,
type
,
progress
);
return
konkeIotServer
.
setMove
(
CcuUtils
.
getCcuName
(
ccuName
),
devId
,
type
Id
,
progress
);
}
}
@Tool
(
description
=
"根据主机号和设备ID控制设备
延时关机
"
)
@Tool
(
description
=
"根据主机号和设备ID控制设备
:延时关机.只支持新风、地暖、空调
"
)
public
String
setDelayedShutdown
(
@ToolParam
(
description
=
"主机号"
)
String
ccuName
,
public
String
setDelayedShutdown
(
@ToolParam
(
description
=
"主机号"
)
String
ccuName
,
@ToolParam
(
description
=
"设备ID"
)
String
devId
,
@ToolParam
(
description
=
"设备ID"
)
String
devId
,
@ToolParam
(
description
=
"设备类型
"
)
String
type
,
@ToolParam
(
description
=
"设备类型
ID"
)
String
typeId
,
@ToolParam
(
description
=
"多少分钟后关机,范围1-1440"
)
int
delayTime
){
@ToolParam
(
description
=
"多少分钟后关机,范围1-1440"
)
int
delayTime
){
log
.
info
(
"mcp调用--->根据主机号和设备ID控制设备延时关机....ccuName:{},devId:{},type:{},delayTime:{}"
,
ccuName
,
devId
,
type
,
delayTime
);
log
.
info
(
"mcp调用--->根据主机号和设备ID控制设备延时关机....ccuName:{},devId:{},type:{},delayTime:{}"
,
ccuName
,
devId
,
type
Id
,
delayTime
);
return
konkeIotServer
.
setDelayedShutdown
(
CcuUtils
.
getCcuName
(
ccuName
),
devId
,
type
,
delayTime
);
return
konkeIotServer
.
setDelayedShutdown
(
CcuUtils
.
getCcuName
(
ccuName
),
devId
,
type
Id
,
delayTime
);
}
}
@Tool
(
description
=
"根据主机号和设备ID设置设备的工作温度"
)
@Tool
(
description
=
"根据主机号和设备ID设置设备的工作温度
.只支持空调、地暖
"
)
public
String
setTemperature
(
@ToolParam
(
description
=
"主机号"
)
String
ccuName
,
public
String
setTemperature
(
@ToolParam
(
description
=
"主机号"
)
String
ccuName
,
@ToolParam
(
description
=
"设备ID"
)
String
devId
,
@ToolParam
(
description
=
"设备ID"
)
String
devId
,
@ToolParam
(
description
=
"设备类型
"
)
String
type
,
@ToolParam
(
description
=
"设备类型
ID"
)
String
typeId
,
@ToolParam
(
description
=
"设置的温度大小,范围是5-35"
)
double
temperature
){
@ToolParam
(
description
=
"设置的温度大小,范围是5-35"
)
double
temperature
){
log
.
info
(
"mcp调用--->根据主机号和设备ID设置设备的工作温度....ccuName:{},devId:{},type:{},temperature:{}"
,
ccuName
,
devId
,
type
,
temperature
);
log
.
info
(
"mcp调用--->根据主机号和设备ID设置设备的工作温度....ccuName:{},devId:{},type:{},temperature:{}"
,
ccuName
,
devId
,
type
Id
,
temperature
);
return
konkeIotServer
.
setTemperature
(
CcuUtils
.
getCcuName
(
ccuName
),
devId
,
type
,
temperature
);
return
konkeIotServer
.
setTemperature
(
CcuUtils
.
getCcuName
(
ccuName
),
devId
,
type
Id
,
temperature
);
}
}
@Tool
(
description
=
"根据主机号和设备ID设置设备的工作模式"
)
@Tool
(
description
=
"根据主机号和设备ID设置设备的工作模式
.只支持地暖、空调、新风
"
)
public
String
setModel
(
@ToolParam
(
description
=
"主机号"
)
String
ccuName
,
public
String
setModel
(
@ToolParam
(
description
=
"主机号"
)
String
ccuName
,
@ToolParam
(
description
=
"设备ID"
)
String
devId
,
@ToolParam
(
description
=
"设备ID"
)
String
devId
,
@ToolParam
(
description
=
"设备类型
"
)
String
type
,
@ToolParam
(
description
=
"设备类型
ID"
)
String
typeId
,
@ToolParam
(
description
=
"设置的工作模式,枚举值:WIND、HOT、COLD、DEHUMIDIFICATION、AUTO、MANUAL"
)
String
mode
){
@ToolParam
(
description
=
"设置的工作模式,枚举值:WIND、HOT、COLD、DEHUMIDIFICATION、AUTO、MANUAL"
)
String
mode
){
log
.
info
(
"mcp调用--->根据主机号和设备ID设置设备的工作模式....ccuName:{},devId:{},type:{},mode:{}"
,
ccuName
,
devId
,
type
,
mode
);
log
.
info
(
"mcp调用--->根据主机号和设备ID设置设备的工作模式....ccuName:{},devId:{},type:{},mode:{}"
,
ccuName
,
devId
,
type
Id
,
mode
);
return
konkeIotServer
.
setModel
(
CcuUtils
.
getCcuName
(
ccuName
),
devId
,
type
,
mode
);
return
konkeIotServer
.
setModel
(
CcuUtils
.
getCcuName
(
ccuName
),
devId
,
type
Id
,
mode
);
}
}
@Tool
(
description
=
"根据主机号和设备ID设置设备的工作风速"
)
@Tool
(
description
=
"根据主机号和设备ID设置设备的工作风速
.只支持空调、新风
"
)
public
String
setSpeed
(
@ToolParam
(
description
=
"主机号"
)
String
ccuName
,
public
String
setSpeed
(
@ToolParam
(
description
=
"主机号"
)
String
ccuName
,
@ToolParam
(
description
=
"设备ID"
)
String
devId
,
@ToolParam
(
description
=
"设备ID"
)
String
devId
,
@ToolParam
(
description
=
"设备类型
"
)
String
type
,
@ToolParam
(
description
=
"设备类型
ID"
)
String
typeId
,
@ToolParam
(
description
=
"设置的工作风速,枚举值:LOW、MID、HIGH、AUTO、STOP"
)
String
speed
){
@ToolParam
(
description
=
"设置的工作风速,枚举值:LOW、MID、HIGH、AUTO、STOP"
)
String
speed
){
log
.
info
(
"mcp调用--->根据主机号和设备ID设置设备的工作风速....ccuName:{},devId:{},type:{},mode:{}"
,
ccuName
,
devId
,
type
,
speed
);
log
.
info
(
"mcp调用--->根据主机号和设备ID设置设备的工作风速....ccuName:{},devId:{},type:{},mode:{}"
,
ccuName
,
devId
,
type
Id
,
speed
);
return
konkeIotServer
.
setSpeed
(
CcuUtils
.
getCcuName
(
ccuName
),
devId
,
type
,
speed
);
return
konkeIotServer
.
setSpeed
(
CcuUtils
.
getCcuName
(
ccuName
),
devId
,
type
Id
,
speed
);
}
}
@Tool
(
description
=
"根据主机号和场景ID控制触发场景"
)
@Tool
(
description
=
"根据主机号和场景ID:触发场景"
)
public
String
triggerScene
(
@ToolParam
(
description
=
"主机号"
)
String
ccuName
,
public
String
triggerScene
(
@ToolParam
(
description
=
"主机号"
)
String
ccuName
,
@ToolParam
(
description
=
"场景ID"
)
String
devId
,
@ToolParam
(
description
=
"场景ID"
)
String
devId
,
@ToolParam
(
description
=
"场景类型
,type等于scene"
)
String
type
){
@ToolParam
(
description
=
"场景类型
ID,type等于scene"
)
String
typeId
){
log
.
info
(
"mcp调用--->根据主机号和场景ID触发场景....ccuName:{},devId:{},type:{}"
,
ccuName
,
devId
,
type
);
log
.
info
(
"mcp调用--->根据主机号和场景ID触发场景....ccuName:{},devId:{},type:{}"
,
ccuName
,
devId
,
type
Id
);
return
konkeIotServer
.
optScene
(
CcuUtils
.
getCcuName
(
ccuName
),
devId
);
return
konkeIotServer
.
optScene
(
CcuUtils
.
getCcuName
(
ccuName
),
devId
);
}
}
//===================================================================================================
}
}
src/main/java/com/ikonke/konkeaialibabamcp/constant/DeviceConstant.java
0 → 100644
View file @
01fec03f
package
com.ikonke.konkeaialibabamcp.constant
;
import
java.util.List
;
import
java.util.Map
;
public
class
DeviceConstant
{
public
final
static
List
<
String
>
speed_15005
=
List
.
of
(
"LOW"
,
"MID"
,
"HIGH"
,
"AUTO"
);
public
final
static
List
<
String
>
speed_12505
=
List
.
of
(
"LOW"
,
"MID"
,
"HIGH"
,
"STOP"
);
public
final
static
List
<
String
>
mode_15005
=
List
.
of
(
"WIND"
,
"HOT"
,
"COLD"
,
"DEHUMIDIFICATION"
);
public
final
static
List
<
String
>
mode_12505
=
List
.
of
(
"AUTO"
,
"MANUAL"
);
/**
* 设备类型 -- OID
*/
public
final
static
Map
<
String
,
List
<
Integer
>>
device_model
=
Map
.
of
(
"LIGHT"
,
List
.
of
(
1
,
3
,
4
,
5
,
7
,
8
,
9
,
10
,
11
,
12
,
13
,
14
,
15
,
16
,
17
,
18
,
20
,
201
,
201
,
492
,
493
,
501
,
502
,
503
,
504
,
505
,
506
,
507
,
508
,
509
,
510
,
511
,
513
,
514
,
515
,
516
,
517
,
518
,
519
),
// "DIMMING_LIGHT",List.of(),
// "SWITCH",List.of(),//
"SOCKET"
,
List
.
of
(
2006
),
//插座
"CURTAIN"
,
List
.
of
(
1008
),
//窗帘
"CURTAIN_MOTOR"
,
List
.
of
(
1003
,
1012
,
1016
,
1017
),
//窗帘电机
"AIR_CONDITION"
,
List
.
of
(
15005
),
//空调
"FLOOR_HEATER"
,
List
.
of
(
12505
),
//地暖
"AIR_FRESHER"
,
List
.
of
(
14003
)
//新风
// "TV_SET",List.of(),
// "AIR_PURIFIER",List.of(),
// "FAN",List.of(),
// "WATER_HEATER",List.of(),
// "HEATER",List.of(),
// "WASHING_MACHINE",List.of(),
// "GAS_STOVE",List.of(),
// "RANGE_HOOD",List.of(),
// "OVEN",List.of(),
// "MICROWAVE_OVEN",List.of(),
// "PRESSURE_COOKER",List.of(),
// "RICE_COOKER",List.of(),
// "INDUCTION_COOKER",List.of(),
// "HIGH_SPEED_BLENDER",List.of(),
// "SWEEPING_ROBOT",List.of(),
// "FRIDGE",List.of(),
// "HUMIDIFIER",List.of(),
);
public
static
String
getDeviceType
(
Integer
devId
)
{
for
(
Map
.
Entry
<
String
,
List
<
Integer
>>
entry
:
device_model
.
entrySet
())
{
if
(
entry
.
getValue
().
contains
(
devId
))
{
return
entry
.
getKey
();
}
}
return
"UNKNOWN"
;
}
}
src/main/java/com/ikonke/konkeaialibabamcp/entity/mysql/SynDevice.java
View file @
01fec03f
...
@@ -37,4 +37,8 @@ public class SynDevice implements Serializable {
...
@@ -37,4 +37,8 @@ public class SynDevice implements Serializable {
private
Integer
type
;
private
Integer
type
;
@TableField
(
"ccuId"
)
@TableField
(
"ccuId"
)
private
String
ccuId
;
private
String
ccuId
;
@TableField
(
"mac"
)
private
String
mac
;
@TableField
(
"model"
)
private
String
model
;
}
}
src/main/java/com/ikonke/konkeaialibabamcp/service/SycDeviceService.java
View file @
01fec03f
...
@@ -5,6 +5,7 @@ import cn.hutool.json.JSONArray;
...
@@ -5,6 +5,7 @@ import cn.hutool.json.JSONArray;
import
cn.hutool.json.JSONObject
;
import
cn.hutool.json.JSONObject
;
import
cn.hutool.json.JSONUtil
;
import
cn.hutool.json.JSONUtil
;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
com.ikonke.konkeaialibabamcp.constant.DeviceConstant
;
import
com.ikonke.konkeaialibabamcp.entity.mongodb.Device
;
import
com.ikonke.konkeaialibabamcp.entity.mongodb.Device
;
import
com.ikonke.konkeaialibabamcp.entity.mongodb.Region
;
import
com.ikonke.konkeaialibabamcp.entity.mongodb.Region
;
import
com.ikonke.konkeaialibabamcp.entity.mongodb.Room
;
import
com.ikonke.konkeaialibabamcp.entity.mongodb.Room
;
...
@@ -49,7 +50,8 @@ public class SycDeviceService {
...
@@ -49,7 +50,8 @@ public class SycDeviceService {
jsonObject
.
set
(
"deviceName"
,
synDevice
.
getDeviceName
());
jsonObject
.
set
(
"deviceName"
,
synDevice
.
getDeviceName
());
jsonObject
.
set
(
"roomId"
,
synDevice
.
getRoomId
());
jsonObject
.
set
(
"roomId"
,
synDevice
.
getRoomId
());
jsonObject
.
set
(
"roomName"
,
synDevice
.
getRoomName
());
jsonObject
.
set
(
"roomName"
,
synDevice
.
getRoomName
());
jsonObject
.
set
(
"type"
,
synDevice
.
getOperateId
());
jsonObject
.
set
(
"typeId"
,
synDevice
.
getOperateId
());
jsonObject
.
set
(
"model"
,
synDevice
.
getModel
());
jsonArray
.
set
(
jsonObject
);
jsonArray
.
set
(
jsonObject
);
}
}
...
@@ -94,20 +96,25 @@ public class SycDeviceService {
...
@@ -94,20 +96,25 @@ public class SycDeviceService {
if
(
d
.
getRoomId
()
==
-
1
){
if
(
d
.
getRoomId
()
==
-
1
){
continue
;
continue
;
}
}
SynDevice
synDevice
=
new
SynDevice
();
String
model
=
DeviceConstant
.
getDeviceType
(
d
.
getRealType
());
synDevice
.
setDeviceId
(
d
.
getDevId
());
if
(!
"UNKNOWN"
.
equals
(
model
)){
synDevice
.
setDeviceName
(
d
.
getName
());
SynDevice
synDevice
=
new
SynDevice
();
synDevice
.
setOperateId
(
String
.
valueOf
(
d
.
getRealType
()));
synDevice
.
setDeviceId
(
d
.
getDevId
());
synDevice
.
setRoomId
(
d
.
getRoomId
());
synDevice
.
setDeviceName
(
d
.
getName
());
for
(
Room
room
:
rooms
){
synDevice
.
setOperateId
(
String
.
valueOf
(
d
.
getRealType
()));
if
(
room
.
getId
().
equals
(
d
.
getRoomId
())){
synDevice
.
setRoomId
(
d
.
getRoomId
());
synDevice
.
setRoomName
(
room
.
getName
());
for
(
Room
room
:
rooms
){
if
(
room
.
getId
().
equals
(
d
.
getRoomId
())){
synDevice
.
setRoomName
(
room
.
getName
());
}
}
}
}
synDevice
.
setType
(
1
);
synDevice
.
setType
(
1
);
synDevice
.
setCcuId
(
ccuName
);
synDevice
.
setCcuId
(
ccuName
);
synDevice
.
setMac
(
d
.
getMac
());
synDevice
.
setModel
(
model
);
synDeviceList
.
add
(
synDevice
);
synDeviceList
.
add
(
synDevice
);
}
}
}
if
(
scenes
!=
null
&&
!
scenes
.
isEmpty
()){
if
(
scenes
!=
null
&&
!
scenes
.
isEmpty
()){
for
(
Scene
scene
:
scenes
){
for
(
Scene
scene
:
scenes
){
...
@@ -126,6 +133,7 @@ public class SycDeviceService {
...
@@ -126,6 +133,7 @@ public class SycDeviceService {
}
}
synDevice
.
setType
(
2
);
synDevice
.
setType
(
2
);
synDevice
.
setCcuId
(
ccuName
);
synDevice
.
setCcuId
(
ccuName
);
synDevice
.
setModel
(
"scene"
);
synDeviceList
.
add
(
synDevice
);
synDeviceList
.
add
(
synDevice
);
}
}
...
...
src/main/java/com/ikonke/konkeaialibabamcp/utils/KonkeIotUtils.java
View file @
01fec03f
...
@@ -4,6 +4,7 @@ import cn.hutool.core.exceptions.StatefulException;
...
@@ -4,6 +4,7 @@ import cn.hutool.core.exceptions.StatefulException;
import
cn.hutool.http.HttpRequest
;
import
cn.hutool.http.HttpRequest
;
import
cn.hutool.json.JSONObject
;
import
cn.hutool.json.JSONObject
;
import
cn.hutool.json.JSONUtil
;
import
cn.hutool.json.JSONUtil
;
import
com.ikonke.konkeaialibabamcp.constant.DeviceConstant
;
import
com.ikonke.konkeaialibabamcp.entity.mongodb.DeviceStatus
;
import
com.ikonke.konkeaialibabamcp.entity.mongodb.DeviceStatus
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.beans.factory.annotation.Value
;
...
@@ -21,6 +22,8 @@ import java.util.Map;
...
@@ -21,6 +22,8 @@ import java.util.Map;
@Component
@Component
public
class
KonkeIotUtils
{
public
class
KonkeIotUtils
{
@Value
(
"${konke.deviceCloud.baseUrl}"
)
@Value
(
"${konke.deviceCloud.baseUrl}"
)
private
String
baseUrl
;
private
String
baseUrl
;
@Value
(
"${konke.deviceCloud.appId}"
)
@Value
(
"${konke.deviceCloud.appId}"
)
...
@@ -96,6 +99,7 @@ public class KonkeIotUtils {
...
@@ -96,6 +99,7 @@ public class KonkeIotUtils {
case
"518"
:
case
"518"
:
case
"519"
:
case
"519"
:
case
"701"
:
case
"701"
:
case
"2006"
:
case
"15005"
:
case
"15005"
:
case
"12505"
:
case
"12505"
:
action
=
"SwitchOpt"
;
action
=
"SwitchOpt"
;
...
@@ -168,6 +172,7 @@ public class KonkeIotUtils {
...
@@ -168,6 +172,7 @@ public class KonkeIotUtils {
case
"518"
:
case
"518"
:
case
"519"
:
case
"519"
:
case
"701"
:
case
"701"
:
case
"2006"
:
case
"15005"
:
case
"15005"
:
case
"12505"
:
case
"12505"
:
action
=
"SwitchOpt"
;
action
=
"SwitchOpt"
;
...
@@ -361,12 +366,7 @@ public class KonkeIotUtils {
...
@@ -361,12 +366,7 @@ public class KonkeIotUtils {
}
}
public
final
static
List
<
String
>
mode_15005
=
List
.
of
(
"WIND"
,
"HOT"
,
"COLD"
,
"DEHUMIDIFICATION"
);
public
final
static
List
<
String
>
mode_12505
=
List
.
of
(
"AUTO"
,
"MANUAL"
);
/**
/**
* 设置模式
* 设置模式
...
@@ -379,19 +379,19 @@ public class KonkeIotUtils {
...
@@ -379,19 +379,19 @@ public class KonkeIotUtils {
switch
(
operateId
)
{
switch
(
operateId
)
{
case
"15005"
:
//空调
case
"15005"
:
//空调
action
=
"FancoilSetRunModel"
;
//WIND HOT COLD DEHUMIDIFICATION
action
=
"FancoilSetRunModel"
;
//WIND HOT COLD DEHUMIDIFICATION
if
(!
mode_15005
.
contains
(
mode
)){
if
(!
DeviceConstant
.
mode_15005
.
contains
(
mode
)){
throw
new
StatefulException
(-
32
,
"不支持的模式"
);
throw
new
StatefulException
(-
32
,
"不支持的模式"
);
}
}
break
;
break
;
case
"12505"
:
//地暖
case
"12505"
:
//地暖
action
=
"SetFloorheatingWorkMode"
;
//AUTO MANUAL
action
=
"SetFloorheatingWorkMode"
;
//AUTO MANUAL
if
(!
mode_12505
.
contains
(
mode
)){
if
(!
DeviceConstant
.
mode_12505
.
contains
(
mode
)){
throw
new
StatefulException
(-
32
,
"不支持的模式"
);
throw
new
StatefulException
(-
32
,
"不支持的模式"
);
}
}
break
;
break
;
case
"14003"
:
//新风
case
"14003"
:
//新风
action
=
"FreshAirSetRunModel"
;
//AUTO MANUAL
action
=
"FreshAirSetRunModel"
;
//AUTO MANUAL
if
(!
mode_12505
.
contains
(
mode
)){
if
(!
DeviceConstant
.
mode_12505
.
contains
(
mode
)){
throw
new
StatefulException
(-
32
,
"不支持的模式"
);
throw
new
StatefulException
(-
32
,
"不支持的模式"
);
}
}
break
;
break
;
...
@@ -414,12 +414,7 @@ public class KonkeIotUtils {
...
@@ -414,12 +414,7 @@ public class KonkeIotUtils {
return
optAIDevice
(
ccuName
,
devId
,
action
,
opt
.
toString
());
return
optAIDevice
(
ccuName
,
devId
,
action
,
opt
.
toString
());
}
}
public
final
static
List
<
String
>
speed_15005
=
List
.
of
(
"LOW"
,
"MID"
,
"HIGH"
,
"AUTO"
);
public
final
static
List
<
String
>
speed_12505
=
List
.
of
(
"LOW"
,
"MID"
,
"HIGH"
,
"STOP"
);
/**
/**
* 设置风速
* 设置风速
*/
*/
...
@@ -431,13 +426,13 @@ public class KonkeIotUtils {
...
@@ -431,13 +426,13 @@ public class KonkeIotUtils {
switch
(
operateId
)
{
switch
(
operateId
)
{
case
"15005"
:
//空调
case
"15005"
:
//空调
action
=
"FancoilSetFanSpeed"
;
//LOW MID HIGH AUTO
action
=
"FancoilSetFanSpeed"
;
//LOW MID HIGH AUTO
if
(!
speed_15005
.
contains
(
speed
)){
if
(!
DeviceConstant
.
speed_15005
.
contains
(
speed
)){
throw
new
StatefulException
(-
32
,
"不支持的风速"
);
throw
new
StatefulException
(-
32
,
"不支持的风速"
);
}
}
break
;
break
;
case
"14003"
:
//新风
case
"14003"
:
//新风
action
=
"FreshAirSetSpeed"
;
//LOW MID HIGH STOP
action
=
"FreshAirSetSpeed"
;
//LOW MID HIGH STOP
if
(!
speed_12505
.
contains
(
speed
)){
if
(!
DeviceConstant
.
speed_12505
.
contains
(
speed
)){
throw
new
StatefulException
(-
32
,
"不支持的风速"
);
throw
new
StatefulException
(-
32
,
"不支持的风速"
);
}
}
break
;
break
;
...
...
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