涂鸦接口调整
This commit is contained in:
parent
bc3463cdd3
commit
70dcf7c745
|
|
@ -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()
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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'))
|
||||
|
|
|
|||
Loading…
Reference in New Issue