From 5ee530e494247fc96c5df8dca9b72676c2f1c306 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A2=A8=E5=A4=A7=E5=8F=94?= <494979559@qq.com> Date: Mon, 6 May 2024 18:06:58 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BC=82=E5=B8=B8=E4=B8=8A=E6=8A=A5=E3=80=81SN?= =?UTF-8?q?=E7=BB=91=E5=AE=9A=E3=80=81=E8=AE=BE=E5=A4=87=E6=8E=A8=E9=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/ruoyi/common/enums/UserType.java | 2 +- .../ruoyi/iot/constants/ReceiveConstants.java | 15 +++ .../ruoyi/iot/domain/CurrentDeviceData.java | 6 +- .../com/ruoyi/iot/domain/IotDeviceDetail.java | 2 - .../domain/{BodyObj.java => ReceiveBody.java} | 2 +- .../java/com/ruoyi/iot/domain/ReceiveMsg.java | 40 +++++++ .../java/com/ruoyi/iot/enums/ReceiveType.java | 19 ++++ .../ruoyi/iot/receive/ReceiveController.java | 37 ++++--- .../ruoyi/iot/service/IotReceiveService.java | 13 +++ .../iot/service/IotReceiveServiceImpl.java | 41 +++++++ .../com/ruoyi/iot/service/IotService.java | 1 + .../main/java/com/ruoyi/iot/util/Util.java | 14 +-- .../ss/abnormal/domain/AbnormalQuery.java | 5 + .../ss/abnormal/mapper/AbnormalMapper.xml | 9 ++ .../service/SmBusinessRecordServiceImpl.java | 2 +- .../java/com/ruoyi/ss/dashboard/BriefVo.java | 2 +- .../com/ruoyi/ss/device/domain/SmDevice.java | 18 +-- .../ruoyi/ss/device/domain/SmDeviceQuery.java | 2 +- .../ss/device/domain/enums/DeviceStatus.java | 6 +- .../ruoyi/ss/device/domain/vo/SmDeviceVo.java | 16 ++- .../ss/device/mapper/SmDeviceMapper.java | 18 ++- .../ruoyi/ss/device/mapper/SmDeviceMapper.xml | 16 ++- .../ss/device/service/DeviceAssembler.java | 8 +- .../device/service/DeviceAssemblerImpl.java | 34 +++++- .../ss/device/service/DeviceValidator.java | 3 + .../ss/device/service/ISmDeviceService.java | 23 +++- .../device/service/SmDeviceServiceImpl.java | 104 +++++++++++------- .../service/impl/DeviceValidatorImpl.java | 4 + .../ss/resetRecord/domain/SmResetRecord.java | 18 ++- .../resetRecord/domain/SmResetRecordVo.java | 4 +- .../mapper/SmResetRecordMapper.xml | 35 +++--- .../com/ruoyi/ss/store/domain/StoreVo.java | 4 + .../ruoyi/ss/store/service/IStoreService.java | 13 +++ .../ss/store/service/StoreAssembler.java | 6 + .../ss/store/service/StoreValidator.java | 5 + .../service/impl/StoreAssemblerImpl.java | 24 ++++ .../store/service/impl/StoreServiceImpl.java | 32 +++++- .../service/impl/StoreValidatorImpl.java | 18 +++ .../java/com/ruoyi/ss/suit/domain/Suit.java | 2 +- .../domain/TransactionBill.java | 2 +- .../domain/TransactionBillQuery.java | 2 +- .../service/TransactionBillService.java | 2 +- .../impl/TransactionBillServiceImpl.java | 6 +- .../impl/TransactionBillValidatorImpl.java | 2 +- .../controller/app/AppDeviceController.java | 58 +++++----- .../app/AppResetRecordController.java | 2 +- .../controller/app/AppStoreController.java | 19 +++- .../app/AppTransactionBillController.java | 2 +- .../web/controller/ss/SmDeviceController.java | 8 +- 49 files changed, 546 insertions(+), 180 deletions(-) create mode 100644 smart-switch-service/src/main/java/com/ruoyi/iot/constants/ReceiveConstants.java rename smart-switch-service/src/main/java/com/ruoyi/iot/domain/{BodyObj.java => ReceiveBody.java} (95%) create mode 100644 smart-switch-service/src/main/java/com/ruoyi/iot/domain/ReceiveMsg.java create mode 100644 smart-switch-service/src/main/java/com/ruoyi/iot/enums/ReceiveType.java create mode 100644 smart-switch-service/src/main/java/com/ruoyi/iot/service/IotReceiveService.java create mode 100644 smart-switch-service/src/main/java/com/ruoyi/iot/service/IotReceiveServiceImpl.java 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; + /** * 功能描述:第三方平台数据接收。

*