Commit 25e14727 authored by 何金镒's avatar 何金镒

思必驰的兜底技能3,批量控制设备等

parent 0957bbba
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:\招\建发招标\dify\10.产品说明书\A2面板系列\光年系列
...@@ -128,6 +128,12 @@ ...@@ -128,6 +128,12 @@
<!-- <artifactId>spring-webflux</artifactId>--> <!-- <artifactId>spring-webflux</artifactId>-->
<!-- <version>6.1.14</version>--> <!-- <version>6.1.14</version>-->
<!-- </dependency>--> <!-- </dependency>-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
</dependencies> </dependencies>
<build> <build>
......
package com.ikonke.konkeaialibabamcp; package com.ikonke.konkeaialibabamcp;
import com.ikonke.konkeaialibabamcp.aitools.BatchDeviceTools;
import com.ikonke.konkeaialibabamcp.aitools.CDCSpacesTools; import com.ikonke.konkeaialibabamcp.aitools.CDCSpacesTools;
import com.ikonke.konkeaialibabamcp.aitools.DeviceTools;
import com.ikonke.konkeaialibabamcp.aitools.WeatherTools; import com.ikonke.konkeaialibabamcp.aitools.WeatherTools;
import org.mybatis.spring.annotation.MapperScan; import org.mybatis.spring.annotation.MapperScan;
import org.springframework.ai.tool.ToolCallbackProvider; import org.springframework.ai.tool.ToolCallbackProvider;
...@@ -19,7 +19,7 @@ public class KonkeAiAlibabaMcpApplication { ...@@ -19,7 +19,7 @@ public class KonkeAiAlibabaMcpApplication {
} }
@Bean @Bean
public ToolCallbackProvider tools(DeviceTools deviceTools, WeatherTools weatherTools, CDCSpacesTools cdcSpacesTools) { public ToolCallbackProvider tools(BatchDeviceTools deviceTools, WeatherTools weatherTools, CDCSpacesTools cdcSpacesTools) {
return MethodToolCallbackProvider.builder() return MethodToolCallbackProvider.builder()
.toolObjects(deviceTools, weatherTools, cdcSpacesTools) .toolObjects(deviceTools, weatherTools, cdcSpacesTools)
.build(); .build();
......
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);
}
//===================================================================================================
}
...@@ -45,6 +45,12 @@ public class DeviceTools { ...@@ -45,6 +45,12 @@ public class DeviceTools {
log.info("mcp调用--->根据主机号和设备ID控制打开设备....ccuName:{},devId:{},type:{}",ccuName,devId,typeId); log.info("mcp调用--->根据主机号和设备ID控制打开设备....ccuName:{},devId:{},type:{}",ccuName,devId,typeId);
return konkeIotServer.optDeviceOpen(CcuUtils.getCcuName(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控制:关闭设备") @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,
......
...@@ -36,6 +36,12 @@ public class DeviceController { ...@@ -36,6 +36,12 @@ public class DeviceController {
log.info("findDeviceByName..根据主机号和设备名称模糊查询设备..ccuName:{},deviceName:{},roomName:{}",ccuName,deviceName,roomName); log.info("findDeviceByName..根据主机号和设备名称模糊查询设备..ccuName:{},deviceName:{},roomName:{}",ccuName,deviceName,roomName);
return sycDeviceService.findDeviceByName(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") @GetMapping("/synchronousDevice")
public Boolean synchronousDevice(@RequestParam(value = "ccuName") String ccuName) { public Boolean synchronousDevice(@RequestParam(value = "ccuName") String ccuName) {
......
...@@ -265,6 +265,7 @@ public class DifyController { ...@@ -265,6 +265,7 @@ public class DifyController {
.bodyValue(body) .bodyValue(body)
.retrieve() .retrieve()
.bodyToFlux(DifyStreamResponse.class)//实体转换 .bodyToFlux(DifyStreamResponse.class)//实体转换
.timeout(Duration.ofMinutes(1))//设置超时时间1分钟
.filter(this::shouldInclude) // 过滤掉不需要的数据【根据需求增加】 .filter(this::shouldInclude) // 过滤掉不需要的数据【根据需求增加】
.map((DifyStreamResponse difyStreamResponse) -> convertToCustomResponseAsync(difyStreamResponse, sn, ccuName, token, redis_conversationId)) // 异步转换【如果返回格式自定义则通过异步转换实现】 .map((DifyStreamResponse difyStreamResponse) -> convertToCustomResponseAsync(difyStreamResponse, sn, ccuName, token, redis_conversationId)) // 异步转换【如果返回格式自定义则通过异步转换实现】
.onErrorResume(throwable -> { .onErrorResume(throwable -> {
...@@ -322,6 +323,7 @@ public class DifyController { ...@@ -322,6 +323,7 @@ public class DifyController {
.bodyValue(body) .bodyValue(body)
.retrieve() .retrieve()
.bodyToFlux(DifyStreamResponse.class)//实体转换 .bodyToFlux(DifyStreamResponse.class)//实体转换
.timeout(Duration.ofMinutes(1))//设置超时时间1分钟
.filter(this::shouldInclude) // 过滤掉不需要的数据【根据需求增加】 .filter(this::shouldInclude) // 过滤掉不需要的数据【根据需求增加】
.map((DifyStreamResponse difyStreamResponse) -> convertToCustomResponseAsync(difyStreamResponse, sn, ccuName, token, redis_conversationId)) // 异步转换【如果返回格式自定义则通过异步转换实现】 .map((DifyStreamResponse difyStreamResponse) -> convertToCustomResponseAsync(difyStreamResponse, sn, ccuName, token, redis_conversationId)) // 异步转换【如果返回格式自定义则通过异步转换实现】
.onErrorResume(throwable -> { .onErrorResume(throwable -> {
......
...@@ -41,6 +41,54 @@ public class SycDeviceService { ...@@ -41,6 +41,54 @@ public class SycDeviceService {
@Autowired @Autowired
private IDeviceModelService deviceModelService; 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){ public JSONArray findDeviceByName(String ccuName,String deviceName,String roomName){
long start = System.currentTimeMillis(); long start = System.currentTimeMillis();
QueryWrapper<SynDevice> wrapper = new QueryWrapper<>(); QueryWrapper<SynDevice> wrapper = new QueryWrapper<>();
......
...@@ -73,6 +73,30 @@ public class KonkeIotUtils { ...@@ -73,6 +73,30 @@ public class KonkeIotUtils {
return one != null && one.getStatus().containsKey("online") && "1".equals(one.getStatus().get("online").toString()); 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){ public String optDeviceOpen(String ccuName, String devId,String operateId){
if(StrUtil.isBlank(ccuName) || StrUtil.isBlank(devId) || StrUtil.isBlank(operateId)){ if(StrUtil.isBlank(ccuName) || StrUtil.isBlank(devId) || StrUtil.isBlank(operateId)){
throw new StatefulException(-20, "参数不能为空"); throw new StatefulException(-20, "参数不能为空");
...@@ -106,6 +130,30 @@ public class KonkeIotUtils { ...@@ -106,6 +130,30 @@ public class KonkeIotUtils {
} }
return optAIDevice(ccuName, devId, action,opt.toString()); 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){ public String optDeviceClosed(String ccuName, String devId,String operateId){
if(StrUtil.isBlank(ccuName) || StrUtil.isBlank(devId) || StrUtil.isBlank(operateId)){ if(StrUtil.isBlank(ccuName) || StrUtil.isBlank(devId) || StrUtil.isBlank(operateId)){
throw new StatefulException(-20, "参数不能为空"); throw new StatefulException(-20, "参数不能为空");
...@@ -142,6 +190,30 @@ public class KonkeIotUtils { ...@@ -142,6 +190,30 @@ public class KonkeIotUtils {
return optAIDevice(ccuName, devId, action,opt.toString()); 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 { ...@@ -174,6 +246,30 @@ public class KonkeIotUtils {
return optAIDevice(ccuName, devId, action,opt.toString()); 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 { ...@@ -205,6 +301,30 @@ public class KonkeIotUtils {
return optAIDevice(ccuName, devId, action,opt.toString()); 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 { ...@@ -239,6 +359,30 @@ public class KonkeIotUtils {
return optAIDevice(ccuName, devId, action,opt.toString()); 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 { ...@@ -269,6 +413,29 @@ public class KonkeIotUtils {
return optAIDevice(ccuName, devId, action,opt.toString()); 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 { ...@@ -302,6 +469,29 @@ public class KonkeIotUtils {
return optAIDevice(ccuName, devId, action,opt.toString()); 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 { ...@@ -371,6 +561,29 @@ public class KonkeIotUtils {
return String.format("%02d:%02d", hours, mins); 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 { ...@@ -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 { ...@@ -469,6 +704,29 @@ public class KonkeIotUtils {
return optAIDevice(ccuName, devId, action,opt.toString()); 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 "控制失败";
}
}
/** /**
* 设置风速 * 设置风速
......
...@@ -23,11 +23,14 @@ spring: ...@@ -23,11 +23,14 @@ spring:
mybatis-plus: mybatis-plus:
configuration:
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
mapper-locations: classpath*:/mapper/**/*.xml mapper-locations: classpath*:/mapper/**/*.xml
type-aliases-package: com.ikonke.konkeaialibabamcp.entity.mysql type-aliases-package: com.ikonke.konkeaialibabamcp.entity.mysql
logging: logging:
level: level:
com.baomidou.mybatisplus: DEBUG
org.springframework.cloud.sleuth: DEBUG org.springframework.cloud.sleuth: DEBUG
root: info root: info
file: file:
...@@ -41,6 +44,7 @@ logging: ...@@ -41,6 +44,7 @@ logging:
max-history: 30 max-history: 30
konke: konke:
weather: weather:
clientId: da4c19db2be64671 clientId: da4c19db2be64671
...@@ -51,6 +55,6 @@ konke: ...@@ -51,6 +55,6 @@ konke:
cdc: cdc:
timeout: 20000 timeout: 20000
url: http://community.jfzhtest.com/prod-api url: https://sqdn.cndmega.com/prod-v2.0.1
difyChatSteamMessages: http://127.0.0.1:${server.port} difyChatSteamMessages: http://127.0.0.1:${server.port}
...@@ -20,6 +20,14 @@ spring: ...@@ -20,6 +20,14 @@ spring:
completion: true completion: true
enabled: true enabled: true
management:
endpoints:
health:
show-details: always
web:
exposure:
include: metrics,health,prometheus
cdc: cdc:
ownerLoginUrl: ${cdc.url}/auth/owner/login ownerLoginUrl: ${cdc.url}/auth/owner/login
getOwnerUrl: ${cdc.url}/system/screen/owner/info getOwnerUrl: ${cdc.url}/system/screen/owner/info
......
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