From e730c51be5a7fde9d8dd016b80a239bb0d197aef Mon Sep 17 00:00:00 2001 From: zhuangtianxiang <2913129173@qq.com> Date: Thu, 13 Mar 2025 16:34:25 +0800 Subject: [PATCH] =?UTF-8?q?refactor(iot):=20=E9=87=8D=E6=9E=84=E4=BA=8B?= =?UTF-8?q?=E4=BB=B6=E7=9B=B8=E5=85=B3=E6=8E=A5=E5=8F=A3=E5=92=8C=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E5=BA=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 修改 Event 实体类,将 outputs 字段类型从 List 改为 List - 更新 EventMapper.xml,增加新的 resultMap配置 - 调整 EventRepository 接口,修改查询方法的 resultMap - 修改数据库结构,为 iot_param 表添加 default_value 字段并调整其类型 - 更新 ParamDto 类,增加 compareType 和 defaultValue 字段 - 修改 RecordDataServiceImpl 中的 processParam 方法,使用 ParamDto 作为参数 --- .../service/impl/RecordDataServiceImpl.java | 7 +++++- .../gateway/modules/iot/tsl/dto/ParamDto.java | 4 ++++ .../gateway/modules/iot/tsl/entity/Event.java | 2 +- .../modules/iot/tsl/repo/EventRepository.java | 1 - src/main/resources/db/gateway.sql | 4 +++- .../resources/mappers/iot/EventMapper.xml | 24 +++++++++++++++++-- 6 files changed, 36 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/zsc/edu/gateway/modules/iot/record/service/impl/RecordDataServiceImpl.java b/src/main/java/com/zsc/edu/gateway/modules/iot/record/service/impl/RecordDataServiceImpl.java index 33ce8f9..c3606a9 100644 --- a/src/main/java/com/zsc/edu/gateway/modules/iot/record/service/impl/RecordDataServiceImpl.java +++ b/src/main/java/com/zsc/edu/gateway/modules/iot/record/service/impl/RecordDataServiceImpl.java @@ -14,8 +14,10 @@ import com.zsc.edu.gateway.modules.iot.record.entity.RecordDataStatusVo; import com.zsc.edu.gateway.framework.springEvent.TemperatureExceededEvent; import com.zsc.edu.gateway.modules.iot.record.repo.RecordDataRepository; import com.zsc.edu.gateway.modules.iot.record.service.RecordDataService; +import com.zsc.edu.gateway.modules.iot.tsl.dto.ParamDto; import com.zsc.edu.gateway.modules.iot.tsl.entity.Event; import com.zsc.edu.gateway.modules.iot.tsl.entity.Param; +import com.zsc.edu.gateway.modules.iot.tsl.mapper.ParamMapper; import com.zsc.edu.gateway.modules.iot.tsl.repo.EventRepository; import jakarta.annotation.Resource; import lombok.AllArgsConstructor; @@ -38,6 +40,8 @@ public class RecordDataServiceImpl extends ServiceImpl outputs; + private List outputs; public enum Type implements IEnum, IState { /** diff --git a/src/main/java/com/zsc/edu/gateway/modules/iot/tsl/repo/EventRepository.java b/src/main/java/com/zsc/edu/gateway/modules/iot/tsl/repo/EventRepository.java index 36d5f13..da4d22f 100644 --- a/src/main/java/com/zsc/edu/gateway/modules/iot/tsl/repo/EventRepository.java +++ b/src/main/java/com/zsc/edu/gateway/modules/iot/tsl/repo/EventRepository.java @@ -25,6 +25,5 @@ public interface EventRepository extends BaseMapper { Event selectById(@Param("id") Long id); - List selectByProductId(@Param("productId") Long id); } diff --git a/src/main/resources/db/gateway.sql b/src/main/resources/db/gateway.sql index 150d6c7..968f005 100644 --- a/src/main/resources/db/gateway.sql +++ b/src/main/resources/db/gateway.sql @@ -938,6 +938,8 @@ ALTER TABLE iot_param ALTER COLUMN contrast_type SET DEFAULT NULL; ALTER TABLE iot_param - ALTER COLUMN "default_value " SET DEFAULT NULL; + ALTER COLUMN default_value SET DEFAULT NULL; +ALTER TABLE iot_param + ADD COLUMN default_value DOUBLE PRECISION; diff --git a/src/main/resources/mappers/iot/EventMapper.xml b/src/main/resources/mappers/iot/EventMapper.xml index 39f5e2a..1c68713 100644 --- a/src/main/resources/mappers/iot/EventMapper.xml +++ b/src/main/resources/mappers/iot/EventMapper.xml @@ -26,6 +26,26 @@ + + + + + + + + + + + + + + + + + + + - select e.*, ip.id as param_id, ip.data_type as param_data_type, @@ -50,7 +70,7 @@ ip.name as param_name, ip.remark as param_remark, ip.compare_type as param_compare_type, - ip."default_value " as param_default_value + ip.default_value as param_default_value from iot_event e left join iot_param ip on e.id = ip.foreign_id and ip.foreign_type = 1