xh 5 days ago
parent
commit
c460e11d8e
  1. 13
      cc-admin-master/yudao-module-hand-mqtt/src/main/java/cn/iocoder/yudao/module/mqtt/config/BatchProcessorConfig.java
  2. 1
      cc-admin-master/yudao-module-hand-mqtt/src/main/java/cn/iocoder/yudao/module/mqtt/config/TdengineBatchConfig.java
  3. 32
      cc-admin-master/yudao-module-hand-mqtt/src/main/java/cn/iocoder/yudao/module/mqtt/processor/BatchDeviceMessageProcessor.java
  4. 16
      cc-admin-master/yudao-module-hand-mqtt/src/main/java/cn/iocoder/yudao/module/mqtt/processor/DeviceMessageProcessor.java
  5. 25
      cc-admin-master/yudao-module-hand-mqtt/src/main/java/cn/iocoder/yudao/module/mqtt/processor/HandAlarmMessageProcess.java
  6. 4
      cc-admin-master/yudao-module-hand/src/main/java/cn/iocoder/yudao/module/hand/controller/admin/HandDetectorController.java
  7. 7
      cc-admin-master/yudao-module-hand/src/main/java/cn/iocoder/yudao/module/hand/service/impl/HandDetectorServiceImpl.java
  8. 25
      cc-admin-master/yudao-module-hand/src/main/java/cn/iocoder/yudao/module/hand/service/impl/TdengineServiceImpl.java
  9. 2
      cc-admin-master/yudao-module-hand/src/main/java/cn/iocoder/yudao/module/hand/vo/AlarmDispatchEvent.java
  10. 9
      cc-admin-master/yudao-module-hand/src/main/java/cn/iocoder/yudao/module/hand/vo/HandDataVo.java
  11. 10
      cc-admin-master/yudao-module-hand/src/main/java/cn/iocoder/yudao/module/hand/vo/TdengineDataVo.java
  12. 11
      cc-admin-master/yudao-module-hand/src/main/resources/mapper/TdengineMapper.xml
  13. 2
      cc-admin-master/yudao-server/src/main/resources/application-local.yaml
  14. 2
      cc-admin-master/yudao-server/src/main/resources/application.yaml

13
cc-admin-master/yudao-module-hand-mqtt/src/main/java/cn/iocoder/yudao/module/mqtt/config/BatchProcessorConfig.java

@ -39,17 +39,4 @@ public class BatchProcessorConfig {
5000 // 内部每 5秒 执行一次 5000 // 内部每 5秒 执行一次
); );
} }
@Bean
public TdengineBatchConfig<AlarmMessageLog> messageLogBatchProcessor() {
return new TdengineBatchConfig<>(
"messageLogBatchProcessor",
list -> tdengineService.createAlarmRecord(list),
50000,
1000,
30000 // 内部每 30秒 执行一次
);
}
} }

1
cc-admin-master/yudao-module-hand-mqtt/src/main/java/cn/iocoder/yudao/module/mqtt/config/TdengineBatchConfig.java

@ -3,6 +3,7 @@ package cn.iocoder.yudao.module.mqtt.config;
import jakarta.annotation.PostConstruct; import jakarta.annotation.PostConstruct;
import jakarta.annotation.PreDestroy; import jakarta.annotation.PreDestroy;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Configuration;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;

32
cc-admin-master/yudao-module-hand-mqtt/src/main/java/cn/iocoder/yudao/module/mqtt/processor/BatchDeviceMessageProcessor.java

@ -25,6 +25,7 @@ import org.springframework.core.task.TaskExecutor;
import org.springframework.kafka.core.KafkaTemplate; import org.springframework.kafka.core.KafkaTemplate;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.math.BigInteger;
import java.sql.Timestamp; import java.sql.Timestamp;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.*; import java.util.*;
@ -42,8 +43,6 @@ public class BatchDeviceMessageProcessor {
@Resource @Resource
private TdengineBatchConfig<TdengineDataVo> tdengineBatchConfig; private TdengineBatchConfig<TdengineDataVo> tdengineBatchConfig;
@Resource @Resource
private TdengineBatchConfig<AlarmMessageLog> alarmProcessor;
@Resource
private HandDetectorService handDetectorService; private HandDetectorService handDetectorService;
@Resource @Resource
private HandAlarmService handAlarmService; private HandAlarmService handAlarmService;
@ -207,11 +206,6 @@ public class BatchDeviceMessageProcessor {
log.debug("[批量持久化] 处理日志: {} 条", context.processedLogs.size()); log.debug("[批量持久化] 处理日志: {} 条", context.processedLogs.size());
} }
// 3. 批量保存报警消息日志
if (!context.alarmMessageLogs.isEmpty()) {
alarmProcessor.addToBatch(context.alarmMessageLogs);
log.debug("[批量持久化] 报警消息: {} 条", context.alarmMessageLogs.size());
}
// 4. 批量创建气体报警 // 4. 批量创建气体报警
if (!context.gasAlarmsToCreate.isEmpty()) { if (!context.gasAlarmsToCreate.isEmpty()) {
// 2. 批量保存 // 2. 批量保存
@ -450,6 +444,15 @@ public class BatchDeviceMessageProcessor {
String battery = json.getStr("battery"); String battery = json.getStr("battery");
String user = json.getStr("user"); String user = json.getStr("user");
Integer boot = json.getInt("boot");
String sig = json.getStr("sig");
Long mem = json.getLong("mem");
device.setBoot(boot);
device.setSig(sig);
device.setMem(mem);
device.setUserName(user); device.setUserName(user);
device.setValue(gasValue); device.setValue(gasValue);
device.setSn(sn); device.setSn(sn);
@ -851,25 +854,16 @@ public class BatchDeviceMessageProcessor {
String msgContent = String.format("%s%s,%s气体浓度为%s", String msgContent = String.format("%s%s,%s气体浓度为%s",
handVo.getUserName(), statusText, gasName, valueStr); handVo.getUserName(), statusText, gasName, valueStr);
// 记录报警消息日志
AlarmMessageLog alarmMessageLog = new AlarmMessageLog();
alarmMessageLog.setDetectorId(handVo.getId());
alarmMessageLog.setHolderName(handVo.getUserName());
alarmMessageLog.setSn(handVo.getSn());
alarmMessageLog.setDeptId(handVo.getDeptId());
alarmMessageLog.setTenantId(handVo.getTenantId());
alarmMessageLog.setMessage(msgContent);
alarmMessageLog.setRemark("系统自动触发报警推送");
try { try {
AlarmDispatchEvent event = new AlarmDispatchEvent( AlarmDispatchEvent event = new AlarmDispatchEvent(
handVo.getId(),
handVo.getDeptId(), handVo.getDeptId(),
handVo.getTenantId(), handVo.getTenantId(),
handVo.getSn(), handVo.getSn(),
handVo.getUserName(),
msgContent msgContent
); );
// 使用 sourceSn 作为 Key,保证同一个部门/设备的报警排队有序处理 // 使用 sourceSn 作为 Key,保证同一个部门/设备的报警排队有序处理
String key = handVo.getSn(); String key = handVo.getSn();
String json = JsonUtils.toJsonString(event); String json = JsonUtils.toJsonString(event);
@ -878,7 +872,6 @@ public class BatchDeviceMessageProcessor {
log.error("[报警推送] 准备推送数据失败", e); log.error("[报警推送] 准备推送数据失败", e);
} }
context.alarmMessageLogs.add(alarmMessageLog);
} }
@ -942,7 +935,6 @@ public class BatchDeviceMessageProcessor {
// 待保存的日志 // 待保存的日志
List<HandOriginalLog> originalLogs = new ArrayList<>(); List<HandOriginalLog> originalLogs = new ArrayList<>();
List<TdengineDataVo> processedLogs = new ArrayList<>(); List<TdengineDataVo> processedLogs = new ArrayList<>();
List<AlarmMessageLog> alarmMessageLogs = new ArrayList<>();
// 待保存的报警 // 待保存的报警
List<HandAlarmDO> gasAlarmsToCreate = new ArrayList<>(); List<HandAlarmDO> gasAlarmsToCreate = new ArrayList<>();

16
cc-admin-master/yudao-module-hand-mqtt/src/main/java/cn/iocoder/yudao/module/mqtt/processor/DeviceMessageProcessor.java

@ -42,16 +42,12 @@ public class DeviceMessageProcessor {
private TdengineBatchConfig<TdengineDataVo> tdengineBatchConfig; private TdengineBatchConfig<TdengineDataVo> tdengineBatchConfig;
@Resource @Resource
private TdengineBatchConfig<AlarmMessageLog> alarmProcessor;
@Resource
private HandDetectorService handDetectorService; private HandDetectorService handDetectorService;
@Resource @Resource
private HandAlarmService handAlarmService; private HandAlarmService handAlarmService;
@Resource @Resource
private AlarmRuleService alarmRuleService; private AlarmRuleService alarmRuleService;
@Resource @Resource
private RedissonClient redissonClient;
@Resource
private FenceService fenceService; private FenceService fenceService;
@Resource @Resource
private FenceAlarmService fenceAlarmService; private FenceAlarmService fenceAlarmService;
@ -554,18 +550,6 @@ public class DeviceMessageProcessor {
} }
} }
}); });
//报警推送消息
AlarmMessageLog alarmMessageLog = new AlarmMessageLog();
alarmMessageLog.setDetectorId(redisData.getId());
alarmMessageLog.setHolderName(redisData.getName());
alarmMessageLog.setSn(redisData.getSn());
alarmMessageLog.setDeptId(redisData.getDeptId());
alarmMessageLog.setTenantId(redisData.getTenantId());
alarmMessageLog.setMessage(msgContent);
alarmMessageLog.setPushSnList(StringUtils.join(listAll, ","));
alarmMessageLog.setMessage(msgContent);
alarmMessageLog.setRemark("系统自动触发报警推送");
alarmProcessor.addToBatch(alarmMessageLog);
} }
/** /**

25
cc-admin-master/yudao-module-hand-mqtt/src/main/java/cn/iocoder/yudao/module/mqtt/processor/HandAlarmMessageProcess.java

@ -2,7 +2,9 @@ package cn.iocoder.yudao.module.mqtt.processor;
import cn.iocoder.yudao.framework.common.util.json.JsonUtils; import cn.iocoder.yudao.framework.common.util.json.JsonUtils;
import cn.iocoder.yudao.module.hand.service.HandDetectorService; import cn.iocoder.yudao.module.hand.service.HandDetectorService;
import cn.iocoder.yudao.module.hand.service.TdengineService;
import cn.iocoder.yudao.module.hand.vo.AlarmDispatchEvent; import cn.iocoder.yudao.module.hand.vo.AlarmDispatchEvent;
import cn.iocoder.yudao.module.hand.vo.AlarmMessageLog;
import cn.iocoder.yudao.module.mqtt.mqtt.Client; import cn.iocoder.yudao.module.mqtt.mqtt.Client;
import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonProcessingException;
import com.google.common.util.concurrent.RateLimiter; import com.google.common.util.concurrent.RateLimiter;
@ -11,18 +13,22 @@ import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.util.ArrayList;
import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@Slf4j @Slf4j
@Component @Component
public class HandAlarmMessageProcess { public class HandAlarmMessageProcess {
private final RateLimiter mqttRateLimiter = RateLimiter.create(3000.0);
@Resource @Resource
private Client mqttClient; private Client mqttClient;
@Resource @Resource
private HandDetectorService handDetectorService; private HandDetectorService handDetectorService;
private final RateLimiter mqttRateLimiter = RateLimiter.create(3000.0);
@Resource
private TdengineService tdengineService;
public void processSingle(String jsonValue) { public void processSingle(String jsonValue) {
// 1. 解析 Kafka 消息 // 1. 解析 Kafka 消息
@ -47,6 +53,21 @@ public class HandAlarmMessageProcess {
// 3. 执行推送逻辑 // 3. 执行推送逻辑
this.publishAlarmToMqtt(targetSns, event.getMsgContent()); this.publishAlarmToMqtt(targetSns, event.getMsgContent());
// 记录报警消息日志
AlarmMessageLog alarmMessageLog = new AlarmMessageLog();
alarmMessageLog.setDetectorId(event.getId());
alarmMessageLog.setHolderName(event.getUserName());
alarmMessageLog.setSn(event.getSourceSn());
alarmMessageLog.setDeptId(event.getDeptId());
alarmMessageLog.setTenantId(event.getTenantId());
alarmMessageLog.setMessage(event.getMsgContent());
alarmMessageLog.setRemark("系统自动触发报警推送");
alarmMessageLog.setPushSnList(StringUtils.join(targetSns, ","));
ArrayList<AlarmMessageLog> objects = new ArrayList<>();
objects.add(alarmMessageLog);
tdengineService.createAlarmRecord(objects);
} catch (Exception e) { } catch (Exception e) {
log.error("[报警推送] 处理异常 SourceSN: {}", event.getSourceSn(), e); log.error("[报警推送] 处理异常 SourceSN: {}", event.getSourceSn(), e);
} }

4
cc-admin-master/yudao-module-hand/src/main/java/cn/iocoder/yudao/module/hand/controller/admin/HandDetectorController.java

@ -1,6 +1,7 @@
package cn.iocoder.yudao.module.hand.controller.admin; package cn.iocoder.yudao.module.hand.controller.admin;
import cn.iocoder.yudao.framework.security.core.LoginUser; import cn.iocoder.yudao.framework.security.core.LoginUser;
import cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder;
import cn.iocoder.yudao.module.hand.dal.HandDetectorDO; import cn.iocoder.yudao.module.hand.dal.HandDetectorDO;
import cn.iocoder.yudao.module.hand.service.HandDetectorService; import cn.iocoder.yudao.module.hand.service.HandDetectorService;
import cn.iocoder.yudao.module.hand.util.RedisKeyUtil; import cn.iocoder.yudao.module.hand.util.RedisKeyUtil;
@ -139,7 +140,8 @@ public class HandDetectorController {
if (null == loginUser) { if (null == loginUser) {
throw exception(HAND_DETECTOR_REDIS_NOT_EXISTS); throw exception(HAND_DETECTOR_REDIS_NOT_EXISTS);
} }
String tenantDeviceHashKey = RedisKeyUtil.getTenantDeviceHashKey(loginUser.getTenantId());
Long tenantId = TenantContextHolder.getTenantId();
String tenantDeviceHashKey = RedisKeyUtil.getTenantDeviceHashKey(tenantId);
Map<Object, Object> handData = handDetectorService.getHandData(tenantDeviceHashKey); Map<Object, Object> handData = handDetectorService.getHandData(tenantDeviceHashKey);
return CommonResult.success(handData); return CommonResult.success(handData);
} }

7
cc-admin-master/yudao-module-hand/src/main/java/cn/iocoder/yudao/module/hand/service/impl/HandDetectorServiceImpl.java

@ -267,21 +267,17 @@ public class HandDetectorServiceImpl implements HandDetectorService {
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
@TenantIgnore @TenantIgnore
public void dataMigrate(HandDetectorSaveReqVO migrateReqVO) { public void dataMigrate(HandDetectorSaveReqVO migrateReqVO) {
// 1. --- 输入校验 ---
if (CollectionUtils.isEmpty(migrateReqVO.getIdList()) || migrateReqVO.getTenantId() == null) { if (CollectionUtils.isEmpty(migrateReqVO.getIdList()) || migrateReqVO.getTenantId() == null) {
// 如果没有提供设备ID或目标租户ID,则直接返回或抛出异常
return; return;
} }
// 2. --- 数据准备 ---
// 一次性查询出所有待迁移的设备实体 // 一次性查询出所有待迁移的设备实体
List<HandDetectorDO> devicesToMigrate = handDetectorMapper.selectByIds(migrateReqVO.getIdList()); List<HandDetectorDO> devicesToMigrate = handDetectorMapper.selectByIds(migrateReqVO.getIdList());
if (CollectionUtils.isEmpty(devicesToMigrate)) { if (CollectionUtils.isEmpty(devicesToMigrate)) {
// 如果根据ID没有查到任何设备,直接返回
return; return;
} }
// 获取旧的租户ID(假设一批迁移的设备都来自同一个租户)
// 获取旧的租户ID
Integer oldTenantId = devicesToMigrate.get(0).getTenantId(); Integer oldTenantId = devicesToMigrate.get(0).getTenantId();
// 新的租户ID // 新的租户ID
Integer newTenantId = migrateReqVO.getTenantId(); Integer newTenantId = migrateReqVO.getTenantId();
@ -296,7 +292,6 @@ public class HandDetectorServiceImpl implements HandDetectorService {
.map(HandDetectorDO::getSn) .map(HandDetectorDO::getSn)
.toList(); .toList();
// 3. --- 数据库更新 ---
// 遍历设备列表,更新租户ID并清空特定于旧租户的关联数据 // 遍历设备列表,更新租户ID并清空特定于旧租户的关联数据
for (HandDetectorDO device : devicesToMigrate) { for (HandDetectorDO device : devicesToMigrate) {
device.setTenantId(newTenantId); device.setTenantId(newTenantId);

25
cc-admin-master/yudao-module-hand/src/main/java/cn/iocoder/yudao/module/hand/service/impl/TdengineServiceImpl.java

@ -4,6 +4,7 @@ import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.security.core.LoginUser; import cn.iocoder.yudao.framework.security.core.LoginUser;
import cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder;
import cn.iocoder.yudao.module.hand.vo.AlarmMessageLog; import cn.iocoder.yudao.module.hand.vo.AlarmMessageLog;
import cn.iocoder.yudao.module.hand.dal.HandDetectorDO; import cn.iocoder.yudao.module.hand.dal.HandDetectorDO;
import cn.iocoder.yudao.module.hand.mapper.TdengineMapper; import cn.iocoder.yudao.module.hand.mapper.TdengineMapper;
@ -77,10 +78,8 @@ public class TdengineServiceImpl implements TdengineService {
@Override @Override
public PageResult<TdengineDataVo> getHandDataLog(HandTdenginePageVO pageReqVO) { public PageResult<TdengineDataVo> getHandDataLog(HandTdenginePageVO pageReqVO) {
IPage<TdengineDataVo> page = new Page<>(pageReqVO.getPageNo(), pageReqVO.getPageSize()); IPage<TdengineDataVo> page = new Page<>(pageReqVO.getPageNo(), pageReqVO.getPageSize());
LoginUser loginUser = getLoginUser();
if (loginUser != null){
pageReqVO.setTenantId(loginUser.getTenantId());
}
Long tenantId = TenantContextHolder.getTenantId();
pageReqVO.setTenantId(tenantId);
IPage<TdengineDataVo> resultPage = tdengineMapper.selectPage(page, pageReqVO); IPage<TdengineDataVo> resultPage = tdengineMapper.selectPage(page, pageReqVO);
List<TdengineDataVo> doList = resultPage.getRecords(); List<TdengineDataVo> doList = resultPage.getRecords();
@ -96,10 +95,8 @@ public class TdengineServiceImpl implements TdengineService {
public PageResult<HandOriginalLog> getOriginalLogPage(HandTdenginePageVO pageReqVO) { public PageResult<HandOriginalLog> getOriginalLogPage(HandTdenginePageVO pageReqVO) {
IPage<HandOriginalLog> page = new Page<>(pageReqVO.getPageNo(), pageReqVO.getPageSize()); IPage<HandOriginalLog> page = new Page<>(pageReqVO.getPageNo(), pageReqVO.getPageSize());
LoginUser loginUser = getLoginUser();
if (loginUser != null){
pageReqVO.setTenantId(loginUser.getTenantId());
}
Long tenantId = TenantContextHolder.getTenantId();
pageReqVO.setTenantId(tenantId);
IPage<HandOriginalLog> resultPage = tdengineMapper.selectOriginalPage(page, pageReqVO); IPage<HandOriginalLog> resultPage = tdengineMapper.selectOriginalPage(page, pageReqVO);
List<HandOriginalLog> doList = resultPage.getRecords(); List<HandOriginalLog> doList = resultPage.getRecords();
@ -113,10 +110,8 @@ public class TdengineServiceImpl implements TdengineService {
@Override @Override
public List<TdengineDataVo> HistoricalSn(HandTdenginePo po) { public List<TdengineDataVo> HistoricalSn(HandTdenginePo po) {
LoginUser loginUser = getLoginUser();
if (loginUser != null){
po.setTenantId(loginUser.getTenantId());
}
Long tenantId = TenantContextHolder.getTenantId();
po.setTenantId(tenantId);
return tdengineMapper.HistoricalSn(po); return tdengineMapper.HistoricalSn(po);
} }
@ -134,10 +129,8 @@ public class TdengineServiceImpl implements TdengineService {
IPage<AlarmMessageLog> page = new Page<>(pageReqVO.getPageNo(), pageReqVO.getPageSize()); IPage<AlarmMessageLog> page = new Page<>(pageReqVO.getPageNo(), pageReqVO.getPageSize());
LoginUser loginUser = getLoginUser();
if (loginUser != null){
pageReqVO.setTenantId(loginUser.getTenantId());
}
Long tenantId = TenantContextHolder.getTenantId();
pageReqVO.setTenantId(tenantId);
IPage<AlarmMessageLog> resultPage = tdengineMapper.selectMessagePage(page, pageReqVO); IPage<AlarmMessageLog> resultPage = tdengineMapper.selectMessagePage(page, pageReqVO);
List<AlarmMessageLog> doList = resultPage.getRecords(); List<AlarmMessageLog> doList = resultPage.getRecords();

2
cc-admin-master/yudao-module-hand/src/main/java/cn/iocoder/yudao/module/hand/vo/AlarmDispatchEvent.java

@ -8,9 +8,11 @@ import lombok.NoArgsConstructor;
@NoArgsConstructor @NoArgsConstructor
@AllArgsConstructor @AllArgsConstructor
public class AlarmDispatchEvent { public class AlarmDispatchEvent {
private Long id; //设备id
private Long deptId; private Long deptId;
private Long tenantId; private Long tenantId;
private String sourceSn; private String sourceSn;
private String userName;
// 消息内容 // 消息内容
private String msgContent; private String msgContent;

9
cc-admin-master/yudao-module-hand/src/main/java/cn/iocoder/yudao/module/hand/vo/HandDataVo.java

@ -118,4 +118,13 @@ public class HandDataVo {
@Schema(description = "最后推送等级") @Schema(description = "最后推送等级")
private Double lastPushValue; private Double lastPushValue;
@Schema(description = "开机时间(秒)")
private Integer boot;
@Schema(description = "信号强度")
private String sig;
@Schema(description = "内存")
private Long mem;
} }

10
cc-admin-master/yudao-module-hand/src/main/java/cn/iocoder/yudao/module/hand/vo/TdengineDataVo.java

@ -34,6 +34,16 @@ public class TdengineDataVo {
@Schema(description = "持有人姓名") @Schema(description = "持有人姓名")
private String name; private String name;
@Schema(description = "开机时间(秒)")
private Integer boot;
@Schema(description = "信号强度")
private String sig;
@Schema(description = "内存")
private Long mem;
@Schema(description = "租户id") @Schema(description = "租户id")
private Long tenantId; private Long tenantId;

11
cc-admin-master/yudao-module-hand/src/main/resources/mapper/TdengineMapper.xml

@ -37,14 +37,16 @@
<!-- 3. 标签 --> <!-- 3. 标签 -->
TAGS(#{log.sn}, #{log.tenantId}) TAGS(#{log.sn}, #{log.tenantId})
(ts,battery,value,longitude,latitude,name,boot_seconds,signal_str,mem_bytes)
VALUES VALUES
(#{log.ts}, #{log.battery}, #{log.value}, #{log.longitude}, #{log.latitude}, #{log.name})
(#{log.ts}, #{log.battery}, #{log.value}, #{log.longitude}, #{log.latitude}, #{log.name}, #{log.boot}, #{log.sig},#{log.mem})
</foreach> </foreach>
</insert> </insert>
<select id="selectPage" resultType="cn.iocoder.yudao.module.hand.vo.TdengineDataVo"> <select id="selectPage" resultType="cn.iocoder.yudao.module.hand.vo.TdengineDataVo">
SELECT SELECT
ts, sn, battery, `value`, longitude, latitude, `name`,tenantId
ts, sn, battery, `value`, longitude, latitude, `name`,boot_seconds as boot,signal_str as sig,mem_bytes as mem,tenantId
FROM FROM
device_data_log device_data_log
<where> <where>
@ -97,7 +99,10 @@
LAST(`value`) as `value`, LAST(`value`) as `value`,
LAST(`battery`) as `battery`, LAST(`battery`) as `battery`,
LAST(longitude) as longitude, LAST(longitude) as longitude,
LAST(latitude) as latitude
LAST(latitude) as latitude,
LAST(boot_seconds) as boot,
LAST(signal_str) as sig,
LAST(mem_bytes) as mem
FROM FROM
device_data_log device_data_log
<where> <where>

2
cc-admin-master/yudao-server/src/main/resources/application-local.yaml

@ -48,7 +48,7 @@ spring:
primary: master primary: master
datasource: datasource:
master: master:
url: jdbc:mysql://192.168.0.180:3306/hand_alarm?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true&rewriteBatchedStatements=true # MySQL Connector/J 8.X 连接的示例
url: jdbc:mysql://192.168.0.180:3306/hand_alarm_dev?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true&rewriteBatchedStatements=true # MySQL Connector/J 8.X 连接的示例
username: root username: root
password: Gsking164411 password: Gsking164411
driver-class-name: com.mysql.cj.jdbc.Driver # MySQL Connector/J 8.X 连接的示例 driver-class-name: com.mysql.cj.jdbc.Driver # MySQL Connector/J 8.X 连接的示例

2
cc-admin-master/yudao-server/src/main/resources/application.yaml

@ -2,7 +2,7 @@ spring:
application: application:
name: gas_mobile name: gas_mobile
profiles: profiles:
active: prod
active: local
main: main:
allow-circular-references: true # 允许循环依赖,因为项目是三层架构,无法避免这个情况。 allow-circular-references: true # 允许循环依赖,因为项目是三层架构,无法避免这个情况。

Loading…
Cancel
Save