Commit 6071afeae863e0e867db19a6b1b6ead10439bac5
1 parent
5fbfe493
【功能优化】Bpm:设备日志的展示
Showing
9 changed files
with
69 additions
and
73 deletions
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/device/IotDeviceDataController.java
| @@ -3,10 +3,10 @@ package cn.iocoder.yudao.module.iot.controller.admin.device; | @@ -3,10 +3,10 @@ package cn.iocoder.yudao.module.iot.controller.admin.device; | ||
| 3 | import cn.iocoder.yudao.framework.common.pojo.CommonResult; | 3 | import cn.iocoder.yudao.framework.common.pojo.CommonResult; |
| 4 | import cn.iocoder.yudao.framework.common.pojo.PageResult; | 4 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 5 | import cn.iocoder.yudao.framework.common.util.object.BeanUtils; | 5 | import cn.iocoder.yudao.framework.common.util.object.BeanUtils; |
| 6 | -import cn.iocoder.yudao.module.iot.controller.admin.device.vo.deviceData.*; | ||
| 7 | -import cn.iocoder.yudao.module.iot.dal.dataobject.device.IotDeviceLogDO; | 6 | +import cn.iocoder.yudao.module.iot.controller.admin.device.vo.deviceData.IotDeviceDataPageReqVO; |
| 7 | +import cn.iocoder.yudao.module.iot.controller.admin.device.vo.deviceData.IotDeviceDataRespVO; | ||
| 8 | +import cn.iocoder.yudao.module.iot.controller.admin.device.vo.deviceData.IotTimeDataRespVO; | ||
| 8 | import cn.iocoder.yudao.module.iot.dal.dataobject.device.IotDevicePropertyDO; | 9 | import cn.iocoder.yudao.module.iot.dal.dataobject.device.IotDevicePropertyDO; |
| 9 | -import cn.iocoder.yudao.module.iot.service.device.data.IotDeviceLogService; | ||
| 10 | import cn.iocoder.yudao.module.iot.service.device.data.IotDevicePropertyService; | 10 | import cn.iocoder.yudao.module.iot.service.device.data.IotDevicePropertyService; |
| 11 | import io.swagger.v3.oas.annotations.Operation; | 11 | import io.swagger.v3.oas.annotations.Operation; |
| 12 | import io.swagger.v3.oas.annotations.tags.Tag; | 12 | import io.swagger.v3.oas.annotations.tags.Tag; |
| @@ -30,8 +30,6 @@ public class IotDeviceDataController { | @@ -30,8 +30,6 @@ public class IotDeviceDataController { | ||
| 30 | 30 | ||
| 31 | @Resource | 31 | @Resource |
| 32 | private IotDevicePropertyService deviceDataService; | 32 | private IotDevicePropertyService deviceDataService; |
| 33 | - @Resource | ||
| 34 | - private IotDeviceLogService deviceLogDataService; | ||
| 35 | 33 | ||
| 36 | // TODO @浩浩:这里的 /latest-list,包括方法名。 | 34 | // TODO @浩浩:这里的 /latest-list,包括方法名。 |
| 37 | @GetMapping("/latest") | 35 | @GetMapping("/latest") |
| @@ -49,12 +47,4 @@ public class IotDeviceDataController { | @@ -49,12 +47,4 @@ public class IotDeviceDataController { | ||
| 49 | return success(BeanUtils.toBean(list, IotTimeDataRespVO.class)); | 47 | return success(BeanUtils.toBean(list, IotTimeDataRespVO.class)); |
| 50 | } | 48 | } |
| 51 | 49 | ||
| 52 | - // TODO:功能权限 | ||
| 53 | - @GetMapping("/log/page") | ||
| 54 | - @Operation(summary = "获得设备日志分页") | ||
| 55 | - public CommonResult<PageResult<IotDeviceLogRespVO>> getDeviceLogPage(@Valid IotDeviceLogPageReqVO pageReqVO) { | ||
| 56 | - PageResult<IotDeviceLogDO> pageResult = deviceLogDataService.getDeviceLogPage(pageReqVO); | ||
| 57 | - return success(BeanUtils.toBean(pageResult, IotDeviceLogRespVO.class)); | ||
| 58 | - } | ||
| 59 | - | ||
| 60 | } | 50 | } |
| 61 | \ No newline at end of file | 51 | \ No newline at end of file |
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/device/IotDeviceLogController.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.iot.controller.admin.device; | ||
| 2 | + | ||
| 3 | +import cn.iocoder.yudao.framework.common.pojo.CommonResult; | ||
| 4 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||
| 5 | +import cn.iocoder.yudao.framework.common.util.object.BeanUtils; | ||
| 6 | +import cn.iocoder.yudao.module.iot.controller.admin.device.vo.deviceData.IotDeviceLogPageReqVO; | ||
| 7 | +import cn.iocoder.yudao.module.iot.controller.admin.device.vo.deviceData.IotDeviceLogRespVO; | ||
| 8 | +import cn.iocoder.yudao.module.iot.dal.dataobject.device.IotDeviceLogDO; | ||
| 9 | +import cn.iocoder.yudao.module.iot.service.device.data.IotDeviceLogService; | ||
| 10 | +import io.swagger.v3.oas.annotations.Operation; | ||
| 11 | +import io.swagger.v3.oas.annotations.tags.Tag; | ||
| 12 | +import jakarta.annotation.Resource; | ||
| 13 | +import jakarta.validation.Valid; | ||
| 14 | +import org.springframework.validation.annotation.Validated; | ||
| 15 | +import org.springframework.web.bind.annotation.GetMapping; | ||
| 16 | +import org.springframework.web.bind.annotation.RequestMapping; | ||
| 17 | +import org.springframework.web.bind.annotation.RestController; | ||
| 18 | + | ||
| 19 | +import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; | ||
| 20 | + | ||
| 21 | +@Tag(name = "管理后台 - IoT 设备日志") | ||
| 22 | +@RestController | ||
| 23 | +@RequestMapping("/iot/device/log") | ||
| 24 | +@Validated | ||
| 25 | +public class IotDeviceLogController { | ||
| 26 | + | ||
| 27 | + @Resource | ||
| 28 | + private IotDeviceLogService deviceLogService; | ||
| 29 | + | ||
| 30 | + // TODO:功能权限 | ||
| 31 | + @GetMapping("/page") | ||
| 32 | + @Operation(summary = "获得设备日志分页") | ||
| 33 | + public CommonResult<PageResult<IotDeviceLogRespVO>> getDeviceLogPage(@Valid IotDeviceLogPageReqVO pageReqVO) { | ||
| 34 | + PageResult<IotDeviceLogDO> pageResult = deviceLogService.getDeviceLogPage(pageReqVO); | ||
| 35 | + return success(BeanUtils.toBean(pageResult, IotDeviceLogRespVO.class)); | ||
| 36 | + } | ||
| 37 | + | ||
| 38 | +} | ||
| 0 | \ No newline at end of file | 39 | \ No newline at end of file |
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/device/vo/deviceData/IotDeviceLogPageReqVO.java
| @@ -4,11 +4,6 @@ import cn.iocoder.yudao.framework.common.pojo.PageParam; | @@ -4,11 +4,6 @@ import cn.iocoder.yudao.framework.common.pojo.PageParam; | ||
| 4 | import io.swagger.v3.oas.annotations.media.Schema; | 4 | import io.swagger.v3.oas.annotations.media.Schema; |
| 5 | import jakarta.validation.constraints.NotEmpty; | 5 | import jakarta.validation.constraints.NotEmpty; |
| 6 | import lombok.Data; | 6 | import lombok.Data; |
| 7 | -import org.springframework.format.annotation.DateTimeFormat; | ||
| 8 | - | ||
| 9 | -import java.time.LocalDateTime; | ||
| 10 | - | ||
| 11 | -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; | ||
| 12 | 7 | ||
| 13 | @Schema(description = "管理后台 - IoT 设备日志分页查询 Request VO") | 8 | @Schema(description = "管理后台 - IoT 设备日志分页查询 Request VO") |
| 14 | @Data | 9 | @Data |
| @@ -18,16 +13,10 @@ public class IotDeviceLogPageReqVO extends PageParam { | @@ -18,16 +13,10 @@ public class IotDeviceLogPageReqVO extends PageParam { | ||
| 18 | @NotEmpty(message = "设备标识不能为空") | 13 | @NotEmpty(message = "设备标识不能为空") |
| 19 | private String deviceKey; | 14 | private String deviceKey; |
| 20 | 15 | ||
| 21 | - // TODO @super:对应的枚举类 | ||
| 22 | @Schema(description = "消息类型", example = "property") | 16 | @Schema(description = "消息类型", example = "property") |
| 23 | - private String type; | 17 | + private String type; // 参见 IotDeviceMessageTypeEnum 枚举,精准匹配 |
| 24 | 18 | ||
| 25 | @Schema(description = "标识符", example = "temperature") | 19 | @Schema(description = "标识符", example = "temperature") |
| 26 | - // TODO @super:对应的枚举类 | ||
| 27 | - private String subType; | ||
| 28 | - | ||
| 29 | - @Schema(description = "创建时间") | ||
| 30 | - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) | ||
| 31 | - private LocalDateTime[] createTime; | 20 | + private String identifier; // 参见 IotDeviceMessageIdentifierEnum 枚举,模糊匹配 |
| 32 | 21 | ||
| 33 | } | 22 | } |
| 34 | \ No newline at end of file | 23 | \ No newline at end of file |
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/dal/tdengine/IotDeviceLogDataMapper.java renamed to yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/dal/tdengine/IotDeviceLogMapper.java
| @@ -4,18 +4,17 @@ import cn.iocoder.yudao.module.iot.controller.admin.device.vo.deviceData.IotDevi | @@ -4,18 +4,17 @@ import cn.iocoder.yudao.module.iot.controller.admin.device.vo.deviceData.IotDevi | ||
| 4 | import cn.iocoder.yudao.module.iot.dal.dataobject.device.IotDeviceLogDO; | 4 | import cn.iocoder.yudao.module.iot.dal.dataobject.device.IotDeviceLogDO; |
| 5 | import cn.iocoder.yudao.module.iot.framework.tdengine.core.annotation.TDengineDS; | 5 | import cn.iocoder.yudao.module.iot.framework.tdengine.core.annotation.TDengineDS; |
| 6 | import com.baomidou.mybatisplus.annotation.InterceptorIgnore; | 6 | import com.baomidou.mybatisplus.annotation.InterceptorIgnore; |
| 7 | +import com.baomidou.mybatisplus.core.metadata.IPage; | ||
| 7 | import org.apache.ibatis.annotations.Mapper; | 8 | import org.apache.ibatis.annotations.Mapper; |
| 8 | import org.apache.ibatis.annotations.Param; | 9 | import org.apache.ibatis.annotations.Param; |
| 9 | 10 | ||
| 10 | -import java.util.List; | ||
| 11 | - | ||
| 12 | /** | 11 | /** |
| 13 | * 设备日志 {@link IotDeviceLogDO} Mapper 接口 | 12 | * 设备日志 {@link IotDeviceLogDO} Mapper 接口 |
| 14 | */ | 13 | */ |
| 15 | @Mapper | 14 | @Mapper |
| 16 | @TDengineDS | 15 | @TDengineDS |
| 17 | @InterceptorIgnore(tenantLine = "true") // 避免 SQL 解析,因为 JSqlParser 对 TDengine 的 SQL 解析会报错 | 16 | @InterceptorIgnore(tenantLine = "true") // 避免 SQL 解析,因为 JSqlParser 对 TDengine 的 SQL 解析会报错 |
| 18 | -public interface IotDeviceLogDataMapper { | 17 | +public interface IotDeviceLogMapper { |
| 19 | 18 | ||
| 20 | /** | 19 | /** |
| 21 | * 创建设备日志超级表 | 20 | * 创建设备日志超级表 |
| @@ -44,7 +43,8 @@ public interface IotDeviceLogDataMapper { | @@ -44,7 +43,8 @@ public interface IotDeviceLogDataMapper { | ||
| 44 | * @param reqVO 分页查询条件 | 43 | * @param reqVO 分页查询条件 |
| 45 | * @return 设备日志列表 | 44 | * @return 设备日志列表 |
| 46 | */ | 45 | */ |
| 47 | - List<IotDeviceLogDO> selectPage(@Param("reqVO") IotDeviceLogPageReqVO reqVO); | 46 | + IPage<IotDeviceLogDO> selectPage(IPage<IotDeviceLogDO> page, |
| 47 | + @Param("reqVO") IotDeviceLogPageReqVO reqVO); | ||
| 48 | 48 | ||
| 49 | /** | 49 | /** |
| 50 | * 获得设备日志总数 | 50 | * 获得设备日志总数 |
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/dal/tdengine/IotDevicePropertyDataMapper.java renamed to yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/dal/tdengine/IotDevicePropertyMapper.java
| @@ -20,7 +20,7 @@ import java.util.stream.Collectors; | @@ -20,7 +20,7 @@ import java.util.stream.Collectors; | ||
| 20 | @Mapper | 20 | @Mapper |
| 21 | @TDengineDS | 21 | @TDengineDS |
| 22 | @InterceptorIgnore(tenantLine = "true") // 避免 SQL 解析,因为 JSqlParser 对 TDengine 的 SQL 解析会报错 | 22 | @InterceptorIgnore(tenantLine = "true") // 避免 SQL 解析,因为 JSqlParser 对 TDengine 的 SQL 解析会报错 |
| 23 | -public interface IotDevicePropertyDataMapper { | 23 | +public interface IotDevicePropertyMapper { |
| 24 | 24 | ||
| 25 | List<TDengineTableField> getProductPropertySTableFieldList(@Param("productKey") String productKey); | 25 | List<TDengineTableField> getProductPropertySTableFieldList(@Param("productKey") String productKey); |
| 26 | 26 |
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/service/device/data/IotDeviceLogServiceImpl.java
| @@ -7,15 +7,15 @@ import cn.iocoder.yudao.framework.common.util.json.JsonUtils; | @@ -7,15 +7,15 @@ import cn.iocoder.yudao.framework.common.util.json.JsonUtils; | ||
| 7 | import cn.iocoder.yudao.framework.common.util.object.BeanUtils; | 7 | import cn.iocoder.yudao.framework.common.util.object.BeanUtils; |
| 8 | import cn.iocoder.yudao.module.iot.controller.admin.device.vo.deviceData.IotDeviceLogPageReqVO; | 8 | import cn.iocoder.yudao.module.iot.controller.admin.device.vo.deviceData.IotDeviceLogPageReqVO; |
| 9 | import cn.iocoder.yudao.module.iot.dal.dataobject.device.IotDeviceLogDO; | 9 | import cn.iocoder.yudao.module.iot.dal.dataobject.device.IotDeviceLogDO; |
| 10 | -import cn.iocoder.yudao.module.iot.dal.tdengine.IotDeviceLogDataMapper; | 10 | +import cn.iocoder.yudao.module.iot.dal.tdengine.IotDeviceLogMapper; |
| 11 | import cn.iocoder.yudao.module.iot.mq.message.IotDeviceMessage; | 11 | import cn.iocoder.yudao.module.iot.mq.message.IotDeviceMessage; |
| 12 | +import com.baomidou.mybatisplus.core.metadata.IPage; | ||
| 13 | +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; | ||
| 12 | import jakarta.annotation.Resource; | 14 | import jakarta.annotation.Resource; |
| 13 | import lombok.extern.slf4j.Slf4j; | 15 | import lombok.extern.slf4j.Slf4j; |
| 14 | import org.springframework.stereotype.Service; | 16 | import org.springframework.stereotype.Service; |
| 15 | import org.springframework.validation.annotation.Validated; | 17 | import org.springframework.validation.annotation.Validated; |
| 16 | 18 | ||
| 17 | -import java.util.List; | ||
| 18 | - | ||
| 19 | /** | 19 | /** |
| 20 | * IoT 设备日志数据 Service 实现类 | 20 | * IoT 设备日志数据 Service 实现类 |
| 21 | * | 21 | * |
| @@ -27,17 +27,17 @@ import java.util.List; | @@ -27,17 +27,17 @@ import java.util.List; | ||
| 27 | public class IotDeviceLogServiceImpl implements IotDeviceLogService { | 27 | public class IotDeviceLogServiceImpl implements IotDeviceLogService { |
| 28 | 28 | ||
| 29 | @Resource | 29 | @Resource |
| 30 | - private IotDeviceLogDataMapper deviceLogDataMapper; | 30 | + private IotDeviceLogMapper deviceLogMapper; |
| 31 | 31 | ||
| 32 | @Override | 32 | @Override |
| 33 | public void defineDeviceLog() { | 33 | public void defineDeviceLog() { |
| 34 | - if (StrUtil.isNotEmpty(deviceLogDataMapper.showDeviceLogSTable())) { | 34 | + if (StrUtil.isNotEmpty(deviceLogMapper.showDeviceLogSTable())) { |
| 35 | log.info("[defineDeviceLog][设备日志超级表已存在,创建跳过]"); | 35 | log.info("[defineDeviceLog][设备日志超级表已存在,创建跳过]"); |
| 36 | return; | 36 | return; |
| 37 | } | 37 | } |
| 38 | 38 | ||
| 39 | log.info("[defineDeviceLog][设备日志超级表不存在,创建开始...]"); | 39 | log.info("[defineDeviceLog][设备日志超级表不存在,创建开始...]"); |
| 40 | - deviceLogDataMapper.createDeviceLogSTable(); | 40 | + deviceLogMapper.createDeviceLogSTable(); |
| 41 | log.info("[defineDeviceLog][设备日志超级表不存在,创建成功]"); | 41 | log.info("[defineDeviceLog][设备日志超级表不存在,创建成功]"); |
| 42 | } | 42 | } |
| 43 | 43 | ||
| @@ -46,15 +46,15 @@ public class IotDeviceLogServiceImpl implements IotDeviceLogService { | @@ -46,15 +46,15 @@ public class IotDeviceLogServiceImpl implements IotDeviceLogService { | ||
| 46 | IotDeviceLogDO log = BeanUtils.toBean(message, IotDeviceLogDO.class) | 46 | IotDeviceLogDO log = BeanUtils.toBean(message, IotDeviceLogDO.class) |
| 47 | .setId(IdUtil.fastSimpleUUID()) | 47 | .setId(IdUtil.fastSimpleUUID()) |
| 48 | .setContent(JsonUtils.toJsonString(message.getData())); | 48 | .setContent(JsonUtils.toJsonString(message.getData())); |
| 49 | - deviceLogDataMapper.insert(log); | 49 | + deviceLogMapper.insert(log); |
| 50 | } | 50 | } |
| 51 | 51 | ||
| 52 | @Override | 52 | @Override |
| 53 | public PageResult<IotDeviceLogDO> getDeviceLogPage(IotDeviceLogPageReqVO pageReqVO) { | 53 | public PageResult<IotDeviceLogDO> getDeviceLogPage(IotDeviceLogPageReqVO pageReqVO) { |
| 54 | // TODO @芋艿:增加一个表不存在的 try catch | 54 | // TODO @芋艿:增加一个表不存在的 try catch |
| 55 | - List<IotDeviceLogDO> list = deviceLogDataMapper.selectPage(pageReqVO); | ||
| 56 | - Long total = deviceLogDataMapper.selectCount(pageReqVO); | ||
| 57 | - return new PageResult<>(list, total); | 55 | + IPage<IotDeviceLogDO> page = deviceLogMapper.selectPage( |
| 56 | + new Page<>(pageReqVO.getPageNo(), pageReqVO.getPageSize()), pageReqVO); | ||
| 57 | + return new PageResult<>(page.getRecords(), page.getTotal()); | ||
| 58 | } | 58 | } |
| 59 | 59 | ||
| 60 | } | 60 | } |
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/service/device/data/IotDevicePropertyServiceImpl.java
| @@ -13,7 +13,7 @@ import cn.iocoder.yudao.module.iot.dal.dataobject.device.IotDevicePropertyDO; | @@ -13,7 +13,7 @@ import cn.iocoder.yudao.module.iot.dal.dataobject.device.IotDevicePropertyDO; | ||
| 13 | import cn.iocoder.yudao.module.iot.dal.dataobject.product.IotProductDO; | 13 | import cn.iocoder.yudao.module.iot.dal.dataobject.product.IotProductDO; |
| 14 | import cn.iocoder.yudao.module.iot.dal.dataobject.thingmodel.IotThingModelDO; | 14 | import cn.iocoder.yudao.module.iot.dal.dataobject.thingmodel.IotThingModelDO; |
| 15 | import cn.iocoder.yudao.module.iot.dal.redis.device.DevicePropertyRedisDAO; | 15 | import cn.iocoder.yudao.module.iot.dal.redis.device.DevicePropertyRedisDAO; |
| 16 | -import cn.iocoder.yudao.module.iot.dal.tdengine.IotDevicePropertyDataMapper; | 16 | +import cn.iocoder.yudao.module.iot.dal.tdengine.IotDevicePropertyMapper; |
| 17 | import cn.iocoder.yudao.module.iot.enums.thingmodel.IotDataSpecsDataTypeEnum; | 17 | import cn.iocoder.yudao.module.iot.enums.thingmodel.IotDataSpecsDataTypeEnum; |
| 18 | import cn.iocoder.yudao.module.iot.enums.thingmodel.IotThingModelTypeEnum; | 18 | import cn.iocoder.yudao.module.iot.enums.thingmodel.IotThingModelTypeEnum; |
| 19 | import cn.iocoder.yudao.module.iot.framework.tdengine.core.TDengineTableField; | 19 | import cn.iocoder.yudao.module.iot.framework.tdengine.core.TDengineTableField; |
| @@ -68,7 +68,7 @@ public class IotDevicePropertyServiceImpl implements IotDevicePropertyService { | @@ -68,7 +68,7 @@ public class IotDevicePropertyServiceImpl implements IotDevicePropertyService { | ||
| 68 | private DevicePropertyRedisDAO deviceDataRedisDAO; | 68 | private DevicePropertyRedisDAO deviceDataRedisDAO; |
| 69 | 69 | ||
| 70 | @Resource | 70 | @Resource |
| 71 | - private IotDevicePropertyDataMapper devicePropertyDataMapper; | 71 | + private IotDevicePropertyMapper devicePropertyMapper; |
| 72 | 72 | ||
| 73 | @Override | 73 | @Override |
| 74 | public void defineDevicePropertyData(Long productId) { | 74 | public void defineDevicePropertyData(Long productId) { |
| @@ -79,7 +79,7 @@ public class IotDevicePropertyServiceImpl implements IotDevicePropertyService { | @@ -79,7 +79,7 @@ public class IotDevicePropertyServiceImpl implements IotDevicePropertyService { | ||
| 79 | // 1.2 解析 DB 里的字段 | 79 | // 1.2 解析 DB 里的字段 |
| 80 | List<TDengineTableField> oldFields = new ArrayList<>(); | 80 | List<TDengineTableField> oldFields = new ArrayList<>(); |
| 81 | try { | 81 | try { |
| 82 | - oldFields.addAll(devicePropertyDataMapper.getProductPropertySTableFieldList(product.getProductKey())); | 82 | + oldFields.addAll(devicePropertyMapper.getProductPropertySTableFieldList(product.getProductKey())); |
| 83 | } catch (Exception e) { | 83 | } catch (Exception e) { |
| 84 | if (!e.getMessage().contains("Table does not exist")) { | 84 | if (!e.getMessage().contains("Table does not exist")) { |
| 85 | throw e; | 85 | throw e; |
| @@ -93,11 +93,11 @@ public class IotDevicePropertyServiceImpl implements IotDevicePropertyService { | @@ -93,11 +93,11 @@ public class IotDevicePropertyServiceImpl implements IotDevicePropertyService { | ||
| 93 | log.info("[defineDevicePropertyData][productId({}) 没有需要定义的属性]", productId); | 93 | log.info("[defineDevicePropertyData][productId({}) 没有需要定义的属性]", productId); |
| 94 | return; | 94 | return; |
| 95 | } | 95 | } |
| 96 | - devicePropertyDataMapper.createProductPropertySTable(product.getProductKey(), newFields); | 96 | + devicePropertyMapper.createProductPropertySTable(product.getProductKey(), newFields); |
| 97 | return; | 97 | return; |
| 98 | } | 98 | } |
| 99 | // 2.2 情况二:如果是修改的时候,需要更新表 | 99 | // 2.2 情况二:如果是修改的时候,需要更新表 |
| 100 | - devicePropertyDataMapper.alterProductPropertySTable(product.getProductKey(), oldFields, newFields); | 100 | + devicePropertyMapper.alterProductPropertySTable(product.getProductKey(), oldFields, newFields); |
| 101 | } | 101 | } |
| 102 | 102 | ||
| 103 | private List<TDengineTableField> buildTableFieldList(List<IotThingModelDO> thingModels) { | 103 | private List<TDengineTableField> buildTableFieldList(List<IotThingModelDO> thingModels) { |
| @@ -142,7 +142,7 @@ public class IotDevicePropertyServiceImpl implements IotDevicePropertyService { | @@ -142,7 +142,7 @@ public class IotDevicePropertyServiceImpl implements IotDevicePropertyService { | ||
| 142 | } | 142 | } |
| 143 | 143 | ||
| 144 | // 3.1 保存设备属性【数据】 | 144 | // 3.1 保存设备属性【数据】 |
| 145 | - devicePropertyDataMapper.insert(device, properties, | 145 | + devicePropertyMapper.insert(device, properties, |
| 146 | LocalDateTimeUtil.toEpochMilli(message.getReportTime())); // TODO @芋艿:后续要看看,查询的时候,能不能用 LocalDateTime | 146 | LocalDateTimeUtil.toEpochMilli(message.getReportTime())); // TODO @芋艿:后续要看看,查询的时候,能不能用 LocalDateTime |
| 147 | 147 | ||
| 148 | // 3.2 保存设备属性【日志】 | 148 | // 3.2 保存设备属性【日志】 |
yudao-module-iot/yudao-module-iot-biz/src/main/resources/mapper/device/IotDeviceLogDataMapper.xml renamed to yudao-module-iot/yudao-module-iot-biz/src/main/resources/mapper/device/IotDeviceLogMapper.xml
| @@ -2,7 +2,7 @@ | @@ -2,7 +2,7 @@ | ||
| 2 | <!DOCTYPE mapper | 2 | <!DOCTYPE mapper |
| 3 | PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" | 3 | PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" |
| 4 | "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> | 4 | "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| 5 | -<mapper namespace="cn.iocoder.yudao.module.iot.dal.tdengine.IotDeviceLogDataMapper"> | 5 | +<mapper namespace="cn.iocoder.yudao.module.iot.dal.tdengine.IotDeviceLogMapper"> |
| 6 | 6 | ||
| 7 | <update id="createDeviceLogSTable"> | 7 | <update id="createDeviceLogSTable"> |
| 8 | CREATE STABLE IF NOT EXISTS device_log ( | 8 | CREATE STABLE IF NOT EXISTS device_log ( |
| @@ -40,38 +40,17 @@ | @@ -40,38 +40,17 @@ | ||
| 40 | </insert> | 40 | </insert> |
| 41 | 41 | ||
| 42 | <select id="selectPage" resultType="cn.iocoder.yudao.module.iot.dal.dataobject.device.IotDeviceLogDO"> | 42 | <select id="selectPage" resultType="cn.iocoder.yudao.module.iot.dal.dataobject.device.IotDeviceLogDO"> |
| 43 | - SELECT ts, id, device_key, product_key, type, sub_type, content, report_time | 43 | + SELECT ts, id, device_key, product_key, type, identifier, content, report_time |
| 44 | FROM device_log_${reqVO.deviceKey} | 44 | FROM device_log_${reqVO.deviceKey} |
| 45 | <where> | 45 | <where> |
| 46 | <if test="reqVO.type != null and reqVO.type != ''"> | 46 | <if test="reqVO.type != null and reqVO.type != ''"> |
| 47 | AND type = #{reqVO.type} | 47 | AND type = #{reqVO.type} |
| 48 | </if> | 48 | </if> |
| 49 | - <if test="reqVO.subType != null and reqVO.subType != ''"> | ||
| 50 | - AND subType = #{reqVO.subType} | ||
| 51 | - </if> | ||
| 52 | - <if test="reqVO.createTime != null"> | ||
| 53 | - AND ts BETWEEN #{reqVO.createTime[0]} AND #{reqVO.createTime[1]} | 49 | + <if test="reqVO.identifier != null and reqVO.identifier != ''"> |
| 50 | + AND identifier LIKE CONCAT('%',#{reqVO.identifier},'%') | ||
| 54 | </if> | 51 | </if> |
| 55 | </where> | 52 | </where> |
| 56 | ORDER BY ts DESC | 53 | ORDER BY ts DESC |
| 57 | - LIMIT #{reqVO.pageSize} OFFSET #{reqVO.pageNo} | ||
| 58 | - </select> | ||
| 59 | - | ||
| 60 | - <!-- TODO 芋艿:看看能不能复用 mybatis-plus 的 selectCount 方法 --> | ||
| 61 | - <select id="selectCount" resultType="Long"> | ||
| 62 | - SELECT COUNT(*) | ||
| 63 | - FROM device_log_${reqVO.deviceKey} | ||
| 64 | - <where> | ||
| 65 | - <if test="reqVO.type != null and reqVO.type != ''"> | ||
| 66 | - AND type = #{reqVO.type} | ||
| 67 | - </if> | ||
| 68 | - <if test="reqVO.subType != null and reqVO.subType != ''"> | ||
| 69 | - AND subType = #{reqVO.subType} | ||
| 70 | - </if> | ||
| 71 | - <if test="reqVO.createTime != null"> | ||
| 72 | - AND ts BETWEEN #{reqVO.createTime[0]} AND #{reqVO.createTime[1]} | ||
| 73 | - </if> | ||
| 74 | - </where> | ||
| 75 | </select> | 54 | </select> |
| 76 | 55 | ||
| 77 | </mapper> | 56 | </mapper> |
| 78 | \ No newline at end of file | 57 | \ No newline at end of file |
yudao-module-iot/yudao-module-iot-biz/src/main/resources/mapper/device/IotDevicePropertyDataMapper.xml renamed to yudao-module-iot/yudao-module-iot-biz/src/main/resources/mapper/device/IotDevicePropertyMapper.xml
| @@ -2,7 +2,7 @@ | @@ -2,7 +2,7 @@ | ||
| 2 | <!DOCTYPE mapper | 2 | <!DOCTYPE mapper |
| 3 | PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" | 3 | PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" |
| 4 | "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> | 4 | "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| 5 | -<mapper namespace="cn.iocoder.yudao.module.iot.dal.tdengine.IotDevicePropertyDataMapper"> | 5 | +<mapper namespace="cn.iocoder.yudao.module.iot.dal.tdengine.IotDevicePropertyMapper"> |
| 6 | 6 | ||
| 7 | <select id="getProductPropertySTableFieldList" resultType="cn.iocoder.yudao.module.iot.framework.tdengine.core.TDengineTableField"> | 7 | <select id="getProductPropertySTableFieldList" resultType="cn.iocoder.yudao.module.iot.framework.tdengine.core.TDengineTableField"> |
| 8 | DESCRIBE product_property_${productKey} | 8 | DESCRIBE product_property_${productKey} |