Merge branch 'feature-BOX一期' of http://47.99.132.106:10081/wulin/qiuguo-iot into feature-BOX一期

This commit is contained in:
wulin 2023-09-18 20:08:28 +08:00
commit 59e73613a7
9 changed files with 77 additions and 31 deletions

1
.gitignore vendored
View File

@ -32,3 +32,4 @@ build/
### VS Code ###
.vscode/
/logs/

View File

@ -11,7 +11,7 @@ package com.qiuguo.iot.base.enums;
// 1000秋果box android配置App 1001秋果Box iOS配置App
public enum DeviceTypeEnum {
GUO_BOX(0, "果box", "BOX"),
ELECTRIC_SOCKET(1, "智能插座", "SOC"),
ELECTRIC_SOCKET(1, "涂鸦设备", "tuya"),
BIG_LIGHT(2, "智能大灯", "BIL"),
CURTAIN_DRIVE(3, "智能窗帘驱动", "CUR"),
WINDOW_DRIVE(4, "智能窗户关闭", "WIN"),

View File

@ -40,6 +40,10 @@ public class DeviceUserBindEntity extends GenericEntity<Long> {
@Comment("设备id")
@Column(name = "device_id", nullable = false)
private Long deviceId;
@Comment("三方设备id")
@Column(name = "other_device_id", nullable = true)
private String otherDeviceId;
@Comment("设备类型0 果Box 1智能插座 2智能大灯 3智能窗帘驱动 4智能窗户关闭 5智能台灯 6智能桌子 7智能椅子 8智能风扇 9智能空调遥控器 10智能冰箱 11智能洗碗机 12智能电热水器 13温度传感器 14空气质量传感器 15光线传感器 16雨量传感器 17闭门器")
@Column(name = "device_type", nullable = false)

View File

@ -35,4 +35,5 @@ build/
.vscode/
### Mac OS ###
.DS_Store
.DS_Store
/logs/

View File

@ -9,7 +9,6 @@ import com.qiuguo.iot.data.resp.device.DeviceInfoResp;
import com.qiuguo.iot.data.service.device.DeviceBatchService;
import com.qiuguo.iot.data.service.device.DeviceInfoService;
import com.qiuguo.iot.user.api.resp.device.DeviceInitResp;
import com.qiuguo.iot.user.api.service.DeviceConnector;
import lombok.extern.slf4j.Slf4j;
import org.hswebframework.web.exception.BusinessException;
import org.springframework.beans.factory.annotation.Value;
@ -37,15 +36,6 @@ public class DeviceController {
@Resource
private DeviceBatchService deviceBatchService;
@Resource
private DeviceConnector deviceConnector;
@GetMapping("/getByid")
public Mono<Void> getByid() {
Object byid = deviceConnector.getByid("6c4a153095be2b7f8baofp");
System.out.println("byid = " + byid);
return Mono.empty();
}
private static Long timeOut = 120000l;//2分钟
@GetMapping("/init")

View File

@ -0,0 +1,20 @@
package com.qiuguo.iot.user.api.controller.tuya;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* XXX
*
* @author weiyachao
* @since 2023/9/18 17:52
*/
@RestController
@RequestMapping("/tuya")
public class TuyaDeviceController {
}

View File

@ -1,4 +1,4 @@
package com.qiuguo.iot.user.api.controller;
package com.qiuguo.iot.user.api.controller.user;
import com.alibaba.fastjson.JSONObject;
import java.util.Objects;

View File

@ -1,18 +0,0 @@
package com.qiuguo.iot.user.api.service;
import com.tuya.connector.api.annotations.GET;
import com.tuya.connector.api.annotations.Path;
/**
* XXX
*
* @author weiyachao
* @since 2023/9/18 16:41
*/
public interface DeviceConnector {
@GET("/v2.0/cloud/thing/{device_id}")
Object getByid(@Path("device_id") String deviceId);
}

View File

@ -0,0 +1,48 @@
package com.qiuguo.iot.user.api.service;
import com.alibaba.fastjson.JSONObject;
import com.tuya.connector.api.annotations.Body;
import com.tuya.connector.api.annotations.DELETE;
import com.tuya.connector.api.annotations.GET;
import com.tuya.connector.api.annotations.POST;
import com.tuya.connector.api.annotations.PUT;
import com.tuya.connector.api.annotations.Path;
import java.util.Map;
/**
* XXX
*
* @author weiyachao
* @since 2023/9/18 16:41
*/
public interface TuyaDeviceConnector {
// 查询设备信息,多个id使用,隔开
@GET("/v2.0/cloud/thing/{device_id}")
JSONObject getByid(@Path("device_id") String deviceId);
// 查询空间下设备列表
@GET("/v2.0/cloud/thing/space/device")
JSONObject getDevicesBySpaceIds(String spaces);
// 控制设备动作
@POST("/v2.0/cloud/thing/{device_id}/shadow/actions")
JSONObject controlDevice(@Path("device_id") String deviceId, @Body JSONObject commands);
// 创建空间
@POST("/v2.0/cloud/space/creation")
JSONObject creatSpace(@Body JSONObject jsonObject);
// 删除空间
@DELETE("/v2.0/cloud/space/{space_id}")
JSONObject deleteSpace(@Path("space_id") String spaceId);
// 查询空间
@GET("/v2.0/cloud/space/{space_id}")
JSONObject getSpaceInfo(@Path("space_id") String spaceId);
// 修改空间信息
@PUT("/v2.0/cloud/space/{space_id}")
JSONObject updateSpace(@Path("space_id") String spaceId, @Body JSONObject JSONObject);
}