涂鸦接口调整
This commit is contained in:
parent
bc3463cdd3
commit
70dcf7c745
|
|
@ -1,5 +1,6 @@
|
||||||
package com.nu.modules.commonutils;
|
package com.nu.modules.commonutils;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import com.nu.connector.AirConditionerConnector;
|
import com.nu.connector.AirConditionerConnector;
|
||||||
import com.nu.connector.DeviceConnector;
|
import com.nu.connector.DeviceConnector;
|
||||||
|
|
@ -214,22 +215,13 @@ public class TuyaAirconApi {
|
||||||
}
|
}
|
||||||
|
|
||||||
// 调用 connector 发送命令
|
// 调用 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(
|
return Map.of(
|
||||||
"success", true,
|
"success", true,
|
||||||
"message", "空调控制指令发送成功",
|
"message", "空调控制指令发送成功",
|
||||||
"data", result
|
"data", result
|
||||||
);
|
);
|
||||||
} else {
|
|
||||||
String errorMsg = result != null ? result.getOrDefault("message", "未知错误").toString() : "返回结果为空";
|
|
||||||
return Map.of(
|
|
||||||
"success", false,
|
|
||||||
"message", "空调控制指令发送失败: " + errorMsg
|
|
||||||
);
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
return Map.of(
|
return Map.of(
|
||||||
"success", false,
|
"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;
|
package com.nu.connector;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import com.nu.entity.CommandResponse;
|
import com.nu.entity.CommandResponse;
|
||||||
import com.tuya.connector.api.annotations.Body;
|
import com.tuya.connector.api.annotations.Body;
|
||||||
import com.tuya.connector.api.annotations.GET;
|
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")
|
@POST("/v2.0/infrareds/{infrared_id}/air-conditioners/{remote_id}/scenes/command")
|
||||||
Map<String, Object> sendCommandKT(
|
Boolean sendCommandKT2(
|
||||||
@Path("infrared_id") String infraredId,
|
@Path("infrared_id") String infraredId,
|
||||||
@Path("remote_id") String remoteId,
|
@Path("remote_id") String remoteId,
|
||||||
@Body Map<String, Object> body
|
@Body Map<String, Object> body
|
||||||
|
|
|
||||||
|
|
@ -37,6 +37,7 @@ public class DirectiveDateGenerateJob implements Job {
|
||||||
|
|
||||||
CareDirectiveEntity dto = new CareDirectiveEntity();
|
CareDirectiveEntity dto = new CareDirectiveEntity();
|
||||||
dto.setQueryDate(targetDate);
|
dto.setQueryDate(targetDate);
|
||||||
|
//查出来targetDate日期当天所有应该执行的指令
|
||||||
List<DirectiveOrderEntity> allDateSnapshootList = careDirectivePlanApi.queryListByDateTime(dto);
|
List<DirectiveOrderEntity> allDateSnapshootList = careDirectivePlanApi.queryListByDateTime(dto);
|
||||||
|
|
||||||
List<DirectivePlanDate> directivePlanDates = BeanUtil.copyToList(allDateSnapshootList, DirectivePlanDate.class);
|
List<DirectivePlanDate> directivePlanDates = BeanUtil.copyToList(allDateSnapshootList, DirectivePlanDate.class);
|
||||||
|
|
|
||||||
|
|
@ -484,7 +484,7 @@
|
||||||
p.cycle_type_id = '1'
|
p.cycle_type_id = '1'
|
||||||
|
|
||||||
-- 3: 按星期执行
|
-- 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: 按日期执行
|
-- 4: 按日期执行
|
||||||
OR (p.cycle_type_id = '4' AND p.cycle_value = DATE_FORMAT(#{dto.queryDate}, '%d'))
|
OR (p.cycle_type_id = '4' AND p.cycle_value = DATE_FORMAT(#{dto.queryDate}, '%d'))
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue