涂鸦接口调整

This commit is contained in:
1378012178@qq.com 2026-04-03 09:08:50 +08:00
parent bc3463cdd3
commit 70dcf7c745
4 changed files with 17 additions and 67 deletions

View File

@ -1,5 +1,6 @@
package com.nu.modules.commonutils;
import com.alibaba.fastjson.JSONObject;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.nu.connector.AirConditionerConnector;
import com.nu.connector.DeviceConnector;
@ -173,12 +174,12 @@ public class TuyaAirconApi {
* 空调组合按键下发
* 通过组合命令控制空调
*
* @param infraredId 设备ID (infrared_id)
* @param remoteId 遥控器ID (remote_id)
* @param power 电源0-关闭1-打开必填
* @param mode 模式0-制冷1-制热2-自动3-送风4-除湿可选
* @param temp 温度可选
* @param wind 风速0-自动1-2-3-可选
* @param infraredId 设备ID (infrared_id)
* @param remoteId 遥控器ID (remote_id)
* @param power 电源0-关闭1-打开必填
* @param mode 模式0-制冷1-制热2-自动3-送风4-除湿可选
* @param temp 温度可选
* @param wind 风速0-自动1-2-3-可选
* @param remoteIndex 遥控器索引ID可选
* @param categoryId 品类ID可选
*/
@ -214,22 +215,13 @@ public class TuyaAirconApi {
}
// 调用 connector 发送命令
Map<String, Object> result = deviceConnector.sendCommandKT(infraredId, remoteId, body);
boolean result = deviceConnector.sendCommandKT2(infraredId, remoteId, body);
// 处理返回结果
if (result != null && Boolean.TRUE.equals(result.get("success"))) {
return Map.of(
"success", true,
"message", "空调控制指令发送成功",
"data", result
);
} else {
String errorMsg = result != null ? result.getOrDefault("message", "未知错误").toString() : "返回结果为空";
return Map.of(
"success", false,
"message", "空调控制指令发送失败: " + errorMsg
);
}
return Map.of(
"success", true,
"message", "空调控制指令发送成功",
"data", result
);
} catch (Exception e) {
return Map.of(
"success", false,
@ -238,47 +230,4 @@ public class TuyaAirconApi {
}
}
/**
* 空调组合按键下发使用Body方式传参
*
* @param infraredId 设备ID
* @param remoteId 遥控器ID
* @param body 请求参数体
*/
@PostMapping("/sendCommandWithBody")
public Map<String, Object> sendAirconCommandWithBody(
@RequestParam String infraredId,
@RequestParam String remoteId,
@RequestBody Map<String, Object> body) {
try {
// 验证必填参数 power
if (body == null || !body.containsKey("power")) {
return Map.of(
"success", false,
"message", "缺少必填参数: power"
);
}
Map<String, Object> result = deviceConnector.sendCommandKT(infraredId, remoteId, body);
if (result != null && Boolean.TRUE.equals(result.get("success"))) {
return Map.of(
"success", true,
"message", "空调控制指令发送成功",
"data", result
);
} else {
String errorMsg = result != null ? result.getOrDefault("message", "未知错误").toString() : "返回结果为空";
return Map.of(
"success", false,
"message", "空调控制指令发送失败: " + errorMsg
);
}
} catch (Exception e) {
return Map.of(
"success", false,
"message", "空调控制指令发送异常: " + e.getMessage()
);
}
}
}

View File

@ -1,5 +1,6 @@
package com.nu.connector;
import com.alibaba.fastjson.JSONObject;
import com.nu.entity.CommandResponse;
import com.tuya.connector.api.annotations.Body;
import com.tuya.connector.api.annotations.GET;
@ -50,9 +51,8 @@ public interface DeviceConnector {
/**
* 发送控制指令
*/
// AirConditionerConnector 中修改为
@POST("/v2.0/infrareds/{infrared_id}/air-conditioners/{remote_id}/scenes/command")
Map<String, Object> sendCommandKT(
Boolean sendCommandKT2(
@Path("infrared_id") String infraredId,
@Path("remote_id") String remoteId,
@Body Map<String, Object> body

View File

@ -37,6 +37,7 @@ public class DirectiveDateGenerateJob implements Job {
CareDirectiveEntity dto = new CareDirectiveEntity();
dto.setQueryDate(targetDate);
//查出来targetDate日期当天所有应该执行的指令
List<DirectiveOrderEntity> allDateSnapshootList = careDirectivePlanApi.queryListByDateTime(dto);
List<DirectivePlanDate> directivePlanDates = BeanUtil.copyToList(allDateSnapshootList, DirectivePlanDate.class);

View File

@ -484,7 +484,7 @@
p.cycle_type_id = '1'
-- 3: 按星期执行
OR (p.cycle_type_id = '3' AND p.cycle_value = WEEKDAY(now()))
OR (p.cycle_type_id = '3' AND p.cycle_value = WEEKDAY(#{dto.queryDate}))
-- 4: 按日期执行
OR (p.cycle_type_id = '4' AND p.cycle_value = DATE_FORMAT(#{dto.queryDate}, '%d'))