Commit 317ab450 authored by 何金镒's avatar 何金镒

token、思必驰的兜底技能、模糊查询等

parent ddfd8ce4
# 肖邦系列Z3S窗帘面板(单控,双路)使用手册&保修卡
## 包装清单
打开产品包装后,请先确认产品和使用说明是否完好,确认配件是否齐全。
配件包含:螺钉×4、安装板×2、2ct 测试针×1。
## 产品介绍
向邦系列Z3S窗帘面板(单路/双路)采用ZigBee无线通信协议的控制面板,采用稳定的长久供电方式,安全可靠等。通过“智慧家生活”,用户可在特定的APP上实现远程控制、定时开关、场景联动、语音控制(注:需搭配智能音箱等设备)等功能。
## 产品参数
- 产品尺寸:86×86×35(mm)
- 工作温度:-10~50℃
- 工作湿度:≤85%RH,无冷凝
- 额定电压:220V~ 50Hz
- 额定功率:4000W/路
- 待机功耗:≤0.5W
- 操作电压:220V交流电供电
- 材质:V0级阻燃PC
- 控制方式:按键控制开关,智能控制(需适配智能场景等)
- 无线协议:ZigBee 3.0(IEEE 802.15.4)
- 发射功率:+10dBm
- 接收灵敏度:-93dBm(实验室性能)
- 最大通讯距离:-1000m(户外)
## 安装说明
### 步骤
1. 用一字螺丝刀松开开关面盖。
2. 用螺丝刀打开开关底盒的接线柱螺丝。
3. 扣上开关底盒即可。
### 安装提示
- 请在面板安装前检查暗装底盒好坏;如环境中有多个智能控制,需保证已将所有控制的相线分在同一零组回路中。
- 将相线电线接入L孔,中性线连接在N线柱上,零线接在L2柱。
- 智能面板底盒暗装时,内径不小于70×70×50(mm),底盒盖底盖60mm。
- 请勿在高温、污染、腐蚀的环境中使用。
- 请专业人员和施工商按照产品说明书或要求进行安装、调试。
## 专家手册
### 如何将设备加入到系统网络?
- 确保智能窗帘客户端已经运行,进行过设备登录,用针插入Set孔5秒放开。
- 若听到设备发出“滴”声,说明设备进入待添加状态,此时在客户端软件中点击“添加设备”,系统会自动搜索设备,当搜索到设备时,会提示加入新设备,开关面板指示灯立即变化。
### 如何在已授权的设备上添加密码?
- 用针插入Set孔1秒(短按),听到“滴”声后松开,此时设备处于待添加密码状态,再次用针插入Set孔4秒(长按),听到“滴”声后5秒内松开设备,设备会发出连续短促的提示音,设置密码成功后关闭指示灯并熄灭,3秒后变化。
### 指示灯状态说明
| 状态 | 说明 |
| ---- | ---- |
| 未加入系统网络时 | 设备关闭时,指示灯(红灯)快闪2次后常亮;设备关闭时,指示灯(红灯)快闪3次后常亮 |
| 加入系统网络后 | 设备关闭时,指示灯(红灯)常亮;设备关闭时,指示灯(红灯)常灭 |
| 主机加入新设备过程中 | 所有开关指示灯(红灯)、快闪 |
| 退出系统网络过程中 | 指示灯状态参考退出系统网络时的说明 |
## 窗帘面板保修卡
### 保修说明
1. 下列情况不属于免费修理范围,如需维修收取维修费,修复后请与当地经销商联系,将产品送回维修中心。
- 因不可抗力(如火灾、地震、洪水等)造成的损坏。
- 因用户使用不当(如进水、进尘等)造成的损坏。
- 擅自拆动、改装产品造成的损坏。
2. 在保修期内,若产品发生非人为损坏,经确认后免费维修。
3. 若产品经维修后,在原保修期内又出现故障,仍可免费维修。
4. 若产品超出保修期,需收取维修费,修复后请与当地经销商联系,将产品送回维修中心。
### 售后服务承诺列表
| 产品系列/类型 | 承诺政策 | 服务方式 |
| ---- | ---- | ---- |
| 常见系列(单路、双路) | 一个月包换;一年保修 | 客户送修 |
### 特别说明
- 本保修卡仅适用于中国大陆地区。
- 本保修卡自购买之日起生效。
package com.ikonke.konkeaialibabamcp.aitools; //package com.ikonke.konkeaialibabamcp.aitools;
//
//
import lombok.extern.slf4j.Slf4j; //import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service; //import org.springframework.stereotype.Service;
//
//
/** ///**
* 智能社区活动相关 // * 智能社区活动相关
*/ // */
@Slf4j //@Slf4j
@Service //@Service
public class CDCActivityTools { //public class CDCActivityTools {
} //}
package com.ikonke.konkeaialibabamcp.aitools; //package com.ikonke.konkeaialibabamcp.aitools;
//
//
import com.ikonke.konkeaialibabamcp.service.cdc.property.Property; //import com.ikonke.konkeaialibabamcp.service.cdc.property.Property;
import lombok.extern.slf4j.Slf4j; //import lombok.extern.slf4j.Slf4j;
import org.springframework.ai.tool.annotation.Tool; //import org.springframework.ai.tool.annotation.Tool;
import org.springframework.ai.tool.annotation.ToolParam; //import org.springframework.ai.tool.annotation.ToolParam;
import org.springframework.stereotype.Service; //import org.springframework.stereotype.Service;
//
/** ///**
* 物业相关 // * 物业相关
*/ // */
@Slf4j //@Slf4j
@Service //@Service
public class CDCPropertyTools { //public class CDCPropertyTools {
//
private final Property property; // private final Property property;
//
public CDCPropertyTools(Property property) { // public CDCPropertyTools(Property property) {
this.property = property; // this.property = property;
} // }
//
//
//
@Tool(description = "社区物业相关:新增物业工单") // @Tool(description = "社区物业相关:新增物业工单")
public String addWorkOrder(@ToolParam(description = "设备的sn号,如:00226DA86A12")String sn, // public String addWorkOrder(@ToolParam(description = "设备的sn号,如:00226DA86A12")String sn,
@ToolParam(description = "工单描述,如:3楼楼道的灯坏了,维修一下。")String description){ // @ToolParam(description = "工单描述,如:3楼楼道的灯坏了,维修一下。")String description){
log.info("mcp调用--->社区物业相关:新增物业工单:sn:{},description:{}",sn,description); // log.info("mcp调用--->社区物业相关:新增物业工单:sn:{},description:{}",sn,description);
return property.addWorkOrder(sn,description); // return property.addWorkOrder(sn,description);
} // }
} //}
package com.ikonke.konkeaialibabamcp.aitools; //package com.ikonke.konkeaialibabamcp.aitools;
//
import com.ikonke.konkeaialibabamcp.service.cdc.robot.CommunityRobot; //import com.ikonke.konkeaialibabamcp.service.cdc.robot.CommunityRobot;
import lombok.extern.slf4j.Slf4j; //import lombok.extern.slf4j.Slf4j;
import org.springframework.ai.tool.annotation.Tool; //import org.springframework.ai.tool.annotation.Tool;
import org.springframework.ai.tool.annotation.ToolParam; //import org.springframework.ai.tool.annotation.ToolParam;
import org.springframework.stereotype.Service; //import org.springframework.stereotype.Service;
//
//
/** ///**
* 机器人相关 // * 机器人相关
*/ // */
@Slf4j //@Slf4j
@Service //@Service
public class CDCRobotTools { //public class CDCRobotTools {
//
private final CommunityRobot robot; // private final CommunityRobot robot;
//
public CDCRobotTools(CommunityRobot robot) { // public CDCRobotTools(CommunityRobot robot) {
this.robot = robot; // this.robot = robot;
} // }
//
/** // /**
* 预约垃圾机器人 // * 预约垃圾机器人
* // *
*/ // */
@Tool(description = "社区机器人相关:预约垃圾回收机器人:垃圾回收机器人上门回收垃圾") // @Tool(description = "社区机器人相关:预约垃圾回收机器人:垃圾回收机器人上门回收垃圾")
public String bookingLitterRobot(@ToolParam(description = "设备的sn号,如:00226DA86A12")String sn){ // public String bookingLitterRobot(@ToolParam(description = "设备的sn号,如:00226DA86A12")String sn){
log.info("mcp调用--->预约垃圾机器人:垃圾代收下单:sn:{}",sn); // log.info("mcp调用--->预约垃圾机器人:垃圾代收下单:sn:{}",sn);
return robot.bookingLitterRobot(sn); // return robot.bookingLitterRobot(sn);
} // }
//
//
/** // /**
* 预约配送机器人 // * 预约配送机器人
*/ // */
@Tool(description = "社区机器人相关:预约配送机器人:配送机器人上门取件配送") // @Tool(description = "社区机器人相关:预约配送机器人:配送机器人上门取件配送")
public String bookingDeliveryRobot(@ToolParam(description = "设备的sn号,如:00226DA86A12")String sn){ // public String bookingDeliveryRobot(@ToolParam(description = "设备的sn号,如:00226DA86A12")String sn){
log.info("mcp调用--->预约配送机器人:机器人配送下单:sn:{}",sn); // log.info("mcp调用--->预约配送机器人:机器人配送下单:sn:{}",sn);
return robot.bookingDeliveryRobot(sn); // return robot.bookingDeliveryRobot(sn);
} // }
} //}
package com.ikonke.konkeaialibabamcp.controller; package com.ikonke.konkeaialibabamcp.controller;
import cn.hutool.core.util.StrUtil;
import cn.hutool.json.JSONArray; import cn.hutool.json.JSONArray;
import cn.hutool.json.JSONObject; import cn.hutool.json.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.ikonke.konkeaialibabamcp.entity.mysql.CDCToken; import com.ikonke.konkeaialibabamcp.entity.mysql.CDCToken;
import com.ikonke.konkeaialibabamcp.entity.mysql.SynDevice;
import com.ikonke.konkeaialibabamcp.service.cdc.CdcHttpUtils; import com.ikonke.konkeaialibabamcp.service.cdc.CdcHttpUtils;
import com.ikonke.konkeaialibabamcp.service.cdc.robot.CommunityRobot;
import com.ikonke.konkeaialibabamcp.service.cdc.spaces.SpacesService; import com.ikonke.konkeaialibabamcp.service.cdc.spaces.SpacesService;
import com.ikonke.konkeaialibabamcp.service.mysqlservice.ICDCTokenService; import com.ikonke.konkeaialibabamcp.service.mysqlservice.ICDCTokenService;
import com.ikonke.konkeaialibabamcp.utils.CcuUtils; import com.ikonke.konkeaialibabamcp.utils.CcuUtils;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.ai.tool.annotation.ToolParam;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.List;
@Slf4j @Slf4j
@RestController @RestController
...@@ -26,6 +29,57 @@ public class CDCController { ...@@ -26,6 +29,57 @@ public class CDCController {
private ICDCTokenService tokenService; private ICDCTokenService tokenService;
@Autowired @Autowired
private SpacesService spacesService; private SpacesService spacesService;
@Autowired
private CommunityRobot robot;
@Autowired
private CdcHttpUtils cdcHttpUtils;
@PostMapping("/getCDCToken")
public JSONObject getCDCToken(@RequestBody JSONObject actions){
String sn = actions.getStr("sn");
String ccuId = actions.getStr("ccuId");
String ownerId = actions.getStr("ownerId");
if(StrUtil.isBlank(sn) || StrUtil.isBlank(ccuId)){
JSONObject result = new JSONObject();
result.set("msg", "参数不能为空");
result.set("code", 500);
return result;
}
log.info("getCDCToken..获取CDCToken..sn:{},ccuId:{},ownerId:{}",sn,ccuId,ownerId);
QueryWrapper<CDCToken> wrapper = new QueryWrapper<>();
wrapper.eq("state", 1);
if(StrUtil.isNotBlank(ownerId)){
wrapper.eq("CDCOwnerId", ownerId);
}else{
wrapper.eq("ccuId", ccuId);
wrapper.eq("sn", sn);
}
String cdc_token = null;
List<CDCToken> list = tokenService.list(wrapper);
if(list.size() == 1){
CDCToken token = list.get(0);
if(StrUtil.isNotBlank(token.getSn()) && !token.getSn().equalsIgnoreCase(sn)){
//更新sn
token.setSn(sn);
tokenService.save(token);
}
cdc_token = token.getAccessToken();
}else if(list.size() > 1){
log.error("获取CDCToken失败,CDCToken数量大于1");
return null;
}else{
//去建发获取CDCToken
cdc_token = cdcHttpUtils.getCDCToken(ccuId, ownerId);
}
JSONObject result = new JSONObject();
result.set("msg", "操作成功");
result.set("code", 200);
result.set("token", cdc_token);
return result;
}
@GetMapping("/synCDCToken") @GetMapping("/synCDCToken")
public boolean synCDCToken(@RequestParam(name = "token") String token, public boolean synCDCToken(@RequestParam(name = "token") String token,
...@@ -90,4 +144,18 @@ public class CDCController { ...@@ -90,4 +144,18 @@ public class CDCController {
return spacesService.getAppointmentTimeByRoomId(sn,time,roomId,roomSubspaceId); return spacesService.getAppointmentTimeByRoomId(sn,time,roomId,roomSubspaceId);
} }
//----------------------------
@GetMapping("/bookingLitterRobot")
public String bookingLitterRobot(@RequestParam(name = "sn")String sn){
log.info("bookingLitterRobot--->预约垃圾机器人:垃圾代收下单:sn:{}",sn);
return robot.bookingLitterRobot(sn);
}
@GetMapping("/bookingDeliveryRobot")
public String bookingDeliveryRobot(@RequestParam(name = "sn")String sn){
log.info("bookingDeliveryRobot--->预约配送机器人:机器人配送下单:sn:{}",sn);
return robot.bookingDeliveryRobot(sn);
}
} }
...@@ -29,6 +29,14 @@ public class DeviceController { ...@@ -29,6 +29,14 @@ public class DeviceController {
return sycDeviceService.findByCcu(ccuName,type,capabilities); return sycDeviceService.findByCcu(ccuName,type,capabilities);
} }
@GetMapping("/findDeviceByName")
public JSONArray findDeviceByName(@RequestParam(name = "ccuName") String ccuName,
@RequestParam(name = "deviceName", required = false) String deviceName,
@RequestParam(name = "roomName", required = false) String roomName){
log.info("findDeviceByName..根据主机号和设备名称模糊查询设备..ccuName:{},deviceName:{},roomName:{}",ccuName,deviceName,roomName);
return sycDeviceService.findDeviceByName(ccuName,deviceName,roomName);
}
@GetMapping("/synchronousDevice") @GetMapping("/synchronousDevice")
public Boolean synchronousDevice(@RequestParam(value = "ccuName") String ccuName) { public Boolean synchronousDevice(@RequestParam(value = "ccuName") String ccuName) {
log.info("synchronousDevice..同步设备..ccuName:{}",ccuName); log.info("synchronousDevice..同步设备..ccuName:{}",ccuName);
......
...@@ -7,6 +7,7 @@ import cn.hutool.http.HttpRequest; ...@@ -7,6 +7,7 @@ import cn.hutool.http.HttpRequest;
import cn.hutool.json.JSONArray; 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.ikonke.konkeaialibabamcp.constant.RedisKeys; import com.ikonke.konkeaialibabamcp.constant.RedisKeys;
import com.ikonke.konkeaialibabamcp.controller.param.DifyStreamResponse; import com.ikonke.konkeaialibabamcp.controller.param.DifyStreamResponse;
import com.ikonke.konkeaialibabamcp.entity.mysql.CDCToken; import com.ikonke.konkeaialibabamcp.entity.mysql.CDCToken;
...@@ -21,8 +22,11 @@ import org.springframework.http.MediaType; ...@@ -21,8 +22,11 @@ import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.springframework.web.reactive.function.client.WebClient; import org.springframework.web.reactive.function.client.WebClient;
import reactor.core.publisher.Flux; import reactor.core.publisher.Flux;
import reactor.core.scheduler.Schedulers;
import java.time.Duration;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.List;
@Slf4j @Slf4j
@RestController @RestController
...@@ -52,6 +56,81 @@ public class DifyController { ...@@ -52,6 +56,81 @@ public class DifyController {
} }
} }
@RequestMapping(value = "/demo", method = RequestMethod.POST, consumes = "application/json")
@ResponseBody
public JSONObject demo(@RequestBody JSONObject jsonObject) {
log.info("demo..请求参数:{}",jsonObject.toString());
JSONObject result = jsonObject.getJSONObject("request");
JSONObject context = jsonObject.getJSONObject("context");
JSONObject device = context.getJSONObject("device");
String deviceName = device.getStr("deviceName");
JSONObject user = context.getJSONObject("user");
String userId = user.getStr("userId");
String type = result.get("type").toString();
String input; //请求文本
String res = "{'version': '1.0','response': {'speak': {'type': 'text','text': '%s','ssml': 'SSML markup text string to speak'}},'shouldEndSession': %b}"; //忽略了部分DSK协议字段,shouldEndSession字段决定是否结束本轮对话
JSONObject response = JSONUtil.parseObj(String.format(res, "error", true)); // 响应报文
JSONArray slots;
String ai_result = "";
try {
slots = result.getJSONArray("inputs");
input = slots.getJSONObject(0).get("input").toString();
// if (type.equals("start")) { //唤醒
// res = String.format(res, "已唤醒", false);
// log.info("新一轮对话开始...........");
//
// response = JSONUtil.parseObj(res);
// } else { //继续对话
// if (input.equals("helloworld") || input.equals("你好世界") || input.equals("世界你好")) { //根据关键词返回内容
// res = String.format(res, String.format("这是第%d次helloworld", 2), false);
// } else if (input.equals("再见") || type.equals("end")) { //结束对话,退出说法可以根据产品自行设定
// res = String.format(res, "结束对话", true);
// } else {
// res = String.format(res, "我听不懂你在说什么", false);
// }
// response = JSONUtil.parseObj(res);
// }
//根据userId获取到对应的主机号等信息
QueryWrapper<CDCToken> wrapper = new QueryWrapper<>();
wrapper.eq("aiSpeechUserId", userId);
List<CDCToken> list = tokenService.list(wrapper);
if(list.size() == 1){
CDCToken token = list.get(0);
String url = "http://172.17.12.12:9998/dify/chatSteamMessages?query="+input;
ai_result = HttpRequest.get(url)
.header("ccuName", token.getCcuId() )
.header("token", token.getAccessToken())
.header("sn",token.getSn())
.timeout(1000000)
.execute().body();
log.info("dify请求返回:{}",ai_result);
String result_end = ai_result.replaceAll("(?m)^\\s*$[\r\n]*", "").replaceAll("[\r\n]+", "\n").replaceAll("[\r\n]", "").trim();
log.info("dify请求返回2--->:{}",result_end);
res = String.format(res, result_end, false);
response = JSONUtil.parseObj(res);
}else if(list.size() > 1){
log.error("获取CDCToken失败,CDCToken数量大于1");
res = String.format(res, "绑定异常", false);
response = JSONUtil.parseObj(res);
}else{
res = String.format(res, "未绑定主机绑定", false);
response = JSONUtil.parseObj(res);
}
} catch (Exception e) {
res = String.format(res, "服务器异常,稍后重试.", false);
response = JSONUtil.parseObj(res);
e.printStackTrace();
} finally {
return response;
}
}
@GetMapping("/chatMessages") @GetMapping("/chatMessages")
public String chatMessages(@RequestParam(name = "query") String query, public String chatMessages(@RequestParam(name = "query") String query,
...@@ -90,7 +169,7 @@ public class DifyController { ...@@ -90,7 +169,7 @@ public class DifyController {
body.set("conversation_id",conversationId); body.set("conversation_id",conversationId);
} }
log.info("dify 对话 body:{}",body); log.info("dify 普通对话 body:{}",body);
String body1 = HttpRequest.post(url) String body1 = HttpRequest.post(url)
.header("Authorization", "Bearer " + dify_api_key) .header("Authorization", "Bearer " + dify_api_key)
...@@ -104,6 +183,7 @@ public class DifyController { ...@@ -104,6 +183,7 @@ public class DifyController {
if(redis_conversationId == null){//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);
bySn = tokenService.findBySn(sn);
if(bySn!=null){ if(bySn!=null){
bySn.setConversationId(conversationId); bySn.setConversationId(conversationId);
tokenService.updateById(bySn); tokenService.updateById(bySn);
...@@ -122,6 +202,63 @@ public class DifyController { ...@@ -122,6 +202,63 @@ public class DifyController {
return jsonObject.getStr("answer"); return jsonObject.getStr("answer");
} }
@GetMapping("/chatSteamMessages2")
public Flux<String> chatSteamMessages2(@RequestParam(name = "query") String query,
@RequestParam("ccuName") String ccuName,
@RequestParam("sn") String sn,
@RequestParam("token") String token){
log.info("开始 流式 对话 sn:{},ccuName:{}, query:{}",sn,ccuName,query);
//workflows/run
String url = "http://172.17.12.12:8088/v1/chat-messages";
JSONObject inputs = new JSONObject();
inputs.set("ccuName",ccuName);
inputs.set("sn",sn);
inputs.set("token",token);
JSONObject body = new JSONObject();
body.set("inputs",inputs);
body.set("query",query);
body.set("response_mode","streaming");//blocking 阻塞模式,streaming 流式模式
body.set("user",sn);
String redis_key = RedisKeys.KONKE_DIFY_CONVERSATION_ID+ sn;
Object redis_conversationId =redisTemplate.opsForValue().get(redis_key);
String conversationId = null;
if(redis_conversationId!=null){
conversationId = redis_conversationId.toString();
}
CDCToken bySn = null;
if(StrUtil.isBlank(conversationId)){
bySn = tokenService.findBySn(sn);
if(bySn!=null && StrUtil.isNotBlank(bySn.getConversationId())){
conversationId = bySn.getConversationId();
body.set("conversation_id",conversationId);//一个user一个会话
}
}else{
body.set("conversation_id",conversationId);
}
log.info("dify key:{} , 对话 body:{}",dify_api_key,body);
return webClient.post()
.uri(url)
.headers(httpHeaders -> {
httpHeaders.setContentType(MediaType.APPLICATION_JSON);
httpHeaders.setBearerAuth(dify_api_key);
})
.bodyValue(body)
.retrieve()
.bodyToFlux(DifyStreamResponse.class)//实体转换
.filter(this::shouldInclude) // 过滤掉不需要的数据【根据需求增加】
.map((DifyStreamResponse difyStreamResponse) -> convertToCustomResponseAsync(difyStreamResponse, sn, ccuName, token, redis_conversationId)) // 异步转换【如果返回格式自定义则通过异步转换实现】
.onErrorResume(throwable -> {
log.info("异常输出:"+throwable.getMessage());
return null;
});
}
@GetMapping("/chatSteamMessages") @GetMapping("/chatSteamMessages")
public Flux<String> chatSteamMessages(@RequestParam(name = "query") String query, public Flux<String> chatSteamMessages(@RequestParam(name = "query") String query,
@RequestHeader("ccuName") String ccuName, @RequestHeader("ccuName") String ccuName,
......
...@@ -33,6 +33,10 @@ public class CDCToken implements Serializable { ...@@ -33,6 +33,10 @@ public class CDCToken implements Serializable {
private Integer state; private Integer state;
@TableField("conversationId") @TableField("conversationId")
private String conversationId; private String conversationId;
@TableField("CDCOwnerId")
private String CDCOwnerId;
@TableField("aiSpeechUserId")
private String aiSpeechUserId;
public static final Integer STATE_DISABLED = 0; // 不可用 public static final Integer STATE_DISABLED = 0; // 不可用
......
...@@ -41,6 +41,35 @@ public class SycDeviceService { ...@@ -41,6 +41,35 @@ public class SycDeviceService {
@Autowired @Autowired
private IDeviceModelService deviceModelService; private IDeviceModelService deviceModelService;
public JSONArray findDeviceByName(String ccuName,String deviceName,String roomName){
long start = System.currentTimeMillis();
QueryWrapper<SynDevice> wrapper = new QueryWrapper<>();
wrapper.eq("ccuId", ccuName);
if(StrUtil.isNotBlank(roomName)){
wrapper.like("roomName", roomName);
}
if(StrUtil.isNotBlank(deviceName)){
wrapper.like("deviceName", 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 findByCcu(String ccuName,Integer type,Integer capabilities){ public JSONArray findByCcu(String ccuName,Integer type,Integer capabilities){
long start = System.currentTimeMillis(); long start = System.currentTimeMillis();
log.info("findByCcu..根据主机号查询设备..ccuName:{}",ccuName); log.info("findByCcu..根据主机号查询设备..ccuName:{}",ccuName);
......
...@@ -22,6 +22,9 @@ public class CdcHttpUtils { ...@@ -22,6 +22,9 @@ public class CdcHttpUtils {
@Value("${cdc.getOwnerUrl}") @Value("${cdc.getOwnerUrl}")
private String getOwnerUrl; private String getOwnerUrl;
@Value("${cdc.ownerLoginUrl}")
private String ownerLoginUrl;
@Value("${cdc.timeout}") @Value("${cdc.timeout}")
private Integer timeout; private Integer timeout;
...@@ -34,6 +37,23 @@ public class CdcHttpUtils { ...@@ -34,6 +37,23 @@ public class CdcHttpUtils {
return getOwner(bySn); return getOwner(bySn);
} }
public String getCDCToken(String ccuId,String ownerId){
log.info("去建发登录业主获取token,ccuId:{},ownerId:{}",ccuId,ownerId);
JSONObject body = new JSONObject();
body.set("loginType",6);
body.set("gateway", ccuId);
body.set("ownerId", ownerId);
String body1 = HttpRequest.post(ownerLoginUrl)
.body(body.toString())
.timeout(timeout)
.execute().body();
JSONObject jsonObject = JSONUtil.parseObj(body1);
if(jsonObject.getInt("code") == 200){
return jsonObject.getStr("token");
}
return null;
}
/** /**
* 获取用户信息 * 获取用户信息
* *
......
...@@ -28,9 +28,9 @@ public class Property { ...@@ -28,9 +28,9 @@ public class Property {
JSONObject body = new JSONObject(); JSONObject body = new JSONObject();
body.set("communityId",userEntity.getCommunityId()); body.set("communityId",userEntity.getCommunityId());
body.set("serviceName",); // body.set("serviceName",);
body.set("serviceSubType",); // body.set("serviceSubType",);
body.set("description",description); // body.set("description",description);
String post = cdcHttpUtils.post(addWorkOrderUrl, sn, body.toString()); String post = cdcHttpUtils.post(addWorkOrderUrl, sn, body.toString());
JSONObject jsonObject = JSONUtil.parseObj( post); JSONObject jsonObject = JSONUtil.parseObj( post);
......
package com.ikonke.konkeaialibabamcp.service.cdc.robot; package com.ikonke.konkeaialibabamcp.service.cdc.robot;
import cn.hutool.core.util.StrUtil;
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.ikonke.konkeaialibabamcp.entity.cdc.UserEntity; import com.ikonke.konkeaialibabamcp.entity.cdc.UserEntity;
...@@ -27,7 +29,7 @@ public class CommunityRobot { ...@@ -27,7 +29,7 @@ public class CommunityRobot {
JSONObject body = new JSONObject(); JSONObject body = new JSONObject();
body.set("buildingId",userEntity.getOwnerRoom().getBuildingId()); body.set("buildingId",userEntity.getOwnerRoom().getBuildingId());
body.set("roomId",userEntity.getOwnerRoom().getRoomId(); body.set("roomId",userEntity.getOwnerRoom().getRoomId());
String post = cdcHttpUtils.post(bookingLitterRobotUrl, sn, body.toString()); String post = cdcHttpUtils.post(bookingLitterRobotUrl, sn, body.toString());
JSONObject jsonObject = JSONUtil.parseObj( post); JSONObject jsonObject = JSONUtil.parseObj( post);
...@@ -42,12 +44,20 @@ public class CommunityRobot { ...@@ -42,12 +44,20 @@ public class CommunityRobot {
public String bookingDeliveryRobot(String sn){ public String bookingDeliveryRobot(String sn){
UserEntity userEntity = cdcHttpUtils.getOwner(sn); UserEntity userEntity = cdcHttpUtils.getOwner(sn);
//1、获取初始点位:发货人
//2、获取业主的点位:收货人
JSONObject body = new JSONObject(); JSONObject body = new JSONObject();
body.set(); body.set("senderId","");
body.set(); body.set("senderName","");
body.set(); body.set("senderPhone","");
body.set(); body.set("startAddress","");
body.set(); body.set("startAddressId","");
body.set("consigneeName","");
body.set("consigneePhone","");
body.set("endAddress","");
body.set("endAddressId","");
body.set("waitTime","");
String post = cdcHttpUtils.post(bookingDeliveryRobotUrl, sn, body.toString()); String post = cdcHttpUtils.post(bookingDeliveryRobotUrl, sn, body.toString());
JSONObject jsonObject = JSONUtil.parseObj( post); JSONObject jsonObject = JSONUtil.parseObj( post);
...@@ -59,4 +69,27 @@ public class CommunityRobot { ...@@ -59,4 +69,27 @@ public class CommunityRobot {
} }
} }
/**
* 获取机器人配送的点位
* thirdType:PT表示普通点位,ROBOT_STANDBY起始点
*/
public String getPoints(String sn,String ownerId,String thirdType,String type){
if(StrUtil.isBlank(thirdType)){
thirdType = "PT";
}
String url = bookingDeliveryRobotUrl + "?thirdType="+thirdType;
if(StrUtil.isNotBlank(ownerId)){
url = url + "&ownerId=" + ownerId;
}
if(StrUtil.isNotBlank(type)){
url = url + "&type=" + type;
}
String s = cdcHttpUtils.get(url, sn);
JSONObject jsonObject = JSONUtil.parseObj(s);
if(jsonObject.getInt("code") == 200){
JSONArray data = jsonObject.getJSONArray("data");
}
return "";
}
} }
package com.ikonke.konkeaialibabamcp.service.mysqlservice.impl; package com.ikonke.konkeaialibabamcp.service.mysqlservice.impl;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ikonke.konkeaialibabamcp.entity.mysql.CDCToken; import com.ikonke.konkeaialibabamcp.entity.mysql.CDCToken;
import com.ikonke.konkeaialibabamcp.entity.mysql.SynDevice;
import com.ikonke.konkeaialibabamcp.mapper.mysql.CDCTokenMapper; import com.ikonke.konkeaialibabamcp.mapper.mysql.CDCTokenMapper;
import com.ikonke.konkeaialibabamcp.service.mysqlservice.ICDCTokenService; import com.ikonke.konkeaialibabamcp.service.mysqlservice.ICDCTokenService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.List;
@Service @Service
...@@ -24,4 +28,6 @@ public class ICDCTokenServiceImpl extends ServiceImpl<CDCTokenMapper, CDCToken> ...@@ -24,4 +28,6 @@ public class ICDCTokenServiceImpl extends ServiceImpl<CDCTokenMapper, CDCToken>
public CDCToken findBySn(String sn,Integer state) { public CDCToken findBySn(String sn,Integer state) {
return baseMapper.findBySnAndState(sn, state); return baseMapper.findBySnAndState(sn, state);
} }
} }
...@@ -21,6 +21,7 @@ spring: ...@@ -21,6 +21,7 @@ spring:
enabled: true enabled: true
cdc: cdc:
ownerLoginUrl: ${cdc.url}/auth/owner/login
getOwnerUrl: ${cdc.url}/system/screen/owner/info getOwnerUrl: ${cdc.url}/system/screen/owner/info
getListSpacesRoomUrl: ${cdc.url}/third/screen/spaces/rooms getListSpacesRoomUrl: ${cdc.url}/third/screen/spaces/rooms
getSpacesRoomDetailUrl: ${cdc.url}/third/screen/spaces/room/ getSpacesRoomDetailUrl: ${cdc.url}/third/screen/spaces/room/
......
...@@ -30,6 +30,21 @@ class KonkeAiAlibabaMcpApplicationTests { ...@@ -30,6 +30,21 @@ class KonkeAiAlibabaMcpApplicationTests {
public static String subspaceId = null; public static String subspaceId = null;
// @Test
// void testHttp(){
// String url = "http://172.17.12.12:9998/dify/chatSteamMessages?query=现在是不是已经秋天了";
// String body1 = HttpRequest.get(url)
// .header("ccuName", "CCU_321410" )
// .header("token", "eyJhbGciOiJIUzUxMiJ9.eyJ1c2VyX2lkIjoiMDA3NjdkOTAzZDU0NDY1YmE4YjdjMjY3MTMzZmFkZTAiLCJ1c2VyX2tleSI6IjA3MWY5NzE1LTYxZjQtNDYwYS05ZjA5LWY1NDAxYTEwNGM2OCIsInVzZXJuYW1lIjoiSXgrNk5RUno1ZE1vNnFqMndrN2twQT09In0.FbMce1Zoe_Xkeoo9v1S04swrIP3Wb-WZw9FwS3k60UBBM25fbCgZFlUaJo08X4xcxgAbEmYFpXUG2lopFXsCng")
// .header("sn","00226DA86ABB")
// .timeout(1000000)
// .execute().body();
// System.out.println("====================");
// System.out.println(body1);
// System.out.println("=======================");
// }
// @Test // @Test
// void testThread(){ // void testThread(){
// int threadCount = 60; // int threadCount = 60;
......
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