diff --git a/smart-switch-ruoyi/smart-switch-common/src/main/java/com/ruoyi/common/enums/UserType.java b/smart-switch-ruoyi/smart-switch-common/src/main/java/com/ruoyi/common/enums/UserType.java index 1a424fa7..3db456f2 100644 --- a/smart-switch-ruoyi/smart-switch-common/src/main/java/com/ruoyi/common/enums/UserType.java +++ b/smart-switch-ruoyi/smart-switch-common/src/main/java/com/ruoyi/common/enums/UserType.java @@ -16,7 +16,7 @@ import java.util.Objects; public enum UserType { TENANT("00", "租户"), - LANDLORD("01", "房东"); + LANDLORD("01", "商户"); private final String type; private final String name; diff --git a/smart-switch-service/src/main/java/com/ruoyi/iot/constants/ReceiveConstants.java b/smart-switch-service/src/main/java/com/ruoyi/iot/constants/ReceiveConstants.java new file mode 100644 index 00000000..1f45c4f6 --- /dev/null +++ b/smart-switch-service/src/main/java/com/ruoyi/iot/constants/ReceiveConstants.java @@ -0,0 +1,15 @@ +package com.ruoyi.iot.constants; + +/** + * @author wjh + * 2024/5/6 + */ +public class ReceiveConstants { + + // 数据点ID:SSID + public static final String DS_SSID = "ssid"; + + // 数据点ID:SSID的值:创特 + public static final String DSV_SSID_CT = "ChangteA"; + +} diff --git a/smart-switch-service/src/main/java/com/ruoyi/iot/domain/CurrentDeviceData.java b/smart-switch-service/src/main/java/com/ruoyi/iot/domain/CurrentDeviceData.java index 7838a40d..721afec3 100644 --- a/smart-switch-service/src/main/java/com/ruoyi/iot/domain/CurrentDeviceData.java +++ b/smart-switch-service/src/main/java/com/ruoyi/iot/domain/CurrentDeviceData.java @@ -29,10 +29,10 @@ public class CurrentDeviceData { device.setAt(new Date()); device.setMac(title); device.setId(id); - if (CollectionUtils.isEmpty(datastreams)) { return device; } + for (CurrentDatastream stream : datastreams) { String value = stream.getValue().toString(); switch (stream.getId()) { @@ -46,13 +46,13 @@ public class CurrentDeviceData { device.setA(NumberUtils.nonNullDecimal(value)); break; case "W": - device.setW(NumberUtils.nonNullDecimal(value).divide(new BigDecimal(1000), RoundingMode.HALF_UP)); + device.setW(NumberUtils.nonNullDecimal(value).divide(new BigDecimal(1000), 2, RoundingMode.HALF_UP)); break; case "S": device.setS(value); break; case "M": - device.setM(NumberUtils.nonNullDecimal(value).divide(new BigDecimal(1000), RoundingMode.HALF_UP)); + device.setM(NumberUtils.nonNullDecimal(value).divide(new BigDecimal(1000), 2, RoundingMode.HALF_UP)); break; case "SET": DeviceOutageWay deviceOutageWay = DeviceOutageWay.parse(value); diff --git a/smart-switch-service/src/main/java/com/ruoyi/iot/domain/IotDeviceDetail.java b/smart-switch-service/src/main/java/com/ruoyi/iot/domain/IotDeviceDetail.java index 3ee7ef62..6d752a08 100644 --- a/smart-switch-service/src/main/java/com/ruoyi/iot/domain/IotDeviceDetail.java +++ b/smart-switch-service/src/main/java/com/ruoyi/iot/domain/IotDeviceDetail.java @@ -1,9 +1,7 @@ package com.ruoyi.iot.domain; -import com.alibaba.fastjson2.annotation.JSONField; import com.fasterxml.jackson.annotation.JsonProperty; import lombok.Data; -import org.springframework.format.annotation.DateTimeFormat; import java.util.Date; import java.util.List; diff --git a/smart-switch-service/src/main/java/com/ruoyi/iot/domain/BodyObj.java b/smart-switch-service/src/main/java/com/ruoyi/iot/domain/ReceiveBody.java similarity index 95% rename from smart-switch-service/src/main/java/com/ruoyi/iot/domain/BodyObj.java rename to smart-switch-service/src/main/java/com/ruoyi/iot/domain/ReceiveBody.java index 16cea5f8..d24151db 100644 --- a/smart-switch-service/src/main/java/com/ruoyi/iot/domain/BodyObj.java +++ b/smart-switch-service/src/main/java/com/ruoyi/iot/domain/ReceiveBody.java @@ -9,7 +9,7 @@ import lombok.Data; */ @Data -public class BodyObj { +public class ReceiveBody { /** 设备推送数据,包括设备的生命周期,数据点,物模型属性、事件、服务等 */ private Object msg; diff --git a/smart-switch-service/src/main/java/com/ruoyi/iot/domain/ReceiveMsg.java b/smart-switch-service/src/main/java/com/ruoyi/iot/domain/ReceiveMsg.java new file mode 100644 index 00000000..038a99a0 --- /dev/null +++ b/smart-switch-service/src/main/java/com/ruoyi/iot/domain/ReceiveMsg.java @@ -0,0 +1,40 @@ +package com.ruoyi.iot.domain; + +import com.alibaba.fastjson2.annotation.JSONField; +import lombok.Data; + +/** + * @author wjh + * 2024/5/6 + */ +@Data +public class ReceiveMsg { + + + // 类型 1数据点 2生命周期 + private Integer type; + + // 设备名称:mac + @JSONField(name = "dev_name") + private String devName; + + // 设备上报的时间戳 + private Long at; + + // 产品id + @JSONField(name ="pid") + private String pid; + + // 生命周期状态:0离线,1在线 + private Integer status; + + // 数据点id + @JSONField(name = "ds_id") + private String dsId; + + // 具体数据部分,为设备上传至平台或触发的相关数据 + private Object value; + + // LwM2M协议设备的IMEI号 + private String imei; +} diff --git a/smart-switch-service/src/main/java/com/ruoyi/iot/enums/ReceiveType.java b/smart-switch-service/src/main/java/com/ruoyi/iot/enums/ReceiveType.java new file mode 100644 index 00000000..4ca60d8b --- /dev/null +++ b/smart-switch-service/src/main/java/com/ruoyi/iot/enums/ReceiveType.java @@ -0,0 +1,19 @@ +package com.ruoyi.iot.enums; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +/** + * @author wjh + * 2024/5/6 + */ +@Getter +@AllArgsConstructor +public enum ReceiveType { + + DATA_POINT(1), // 数据点 + DEVICE_STATUS(2); // 生命周期 + + private final Integer type; + +} diff --git a/smart-switch-service/src/main/java/com/ruoyi/iot/receive/ReceiveController.java b/smart-switch-service/src/main/java/com/ruoyi/iot/receive/ReceiveController.java index dfb02e2b..63d9e7f7 100644 --- a/smart-switch-service/src/main/java/com/ruoyi/iot/receive/ReceiveController.java +++ b/smart-switch-service/src/main/java/com/ruoyi/iot/receive/ReceiveController.java @@ -2,9 +2,11 @@ package com.ruoyi.iot.receive; import com.alibaba.fastjson2.JSON; import com.ruoyi.common.annotation.Anonymous; -import com.ruoyi.iot.util.Util; -import com.ruoyi.iot.domain.BodyObj; +import com.ruoyi.iot.domain.ReceiveBody; +import com.ruoyi.iot.domain.ReceiveMsg; +import com.ruoyi.iot.service.IotReceiveService; import com.ruoyi.iot.service.IotService; +import com.ruoyi.iot.util.Util; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -32,6 +34,9 @@ public class ReceiveController { @Autowired private IotService iotService; + @Autowired + private IotReceiveService iotReceiveService; + /** * 功能描述:第三方平台数据接收。

*