若依微服务1.1.0版本:
1、tdengine服务增加获取在线设备信息接口 2、字典数据完善 3、数据处理服务:完成数据解析保存(判断base64),另外电子围栏判断保存dev 1.1.0
parent
631970c21c
commit
0af59e14d2
@ -0,0 +1,63 @@
|
||||
package com.ruoyi.tdengine.api.domain;
|
||||
|
||||
import com.ruoyi.common.core.web.domain.BaseEntity;
|
||||
|
||||
/**
|
||||
* @Description: 设备状态对象
|
||||
* @ClassName: DeviceStatus
|
||||
* @Author : xins
|
||||
* @Date :2023-09-05 11:35
|
||||
* @Version :1.0
|
||||
*/
|
||||
public class DeviceStatus extends BaseEntity {
|
||||
|
||||
private Long ts;
|
||||
|
||||
private String deviceCode;
|
||||
|
||||
private int deviceType;
|
||||
|
||||
private int onlineStatus;
|
||||
|
||||
private Long sceneId;
|
||||
|
||||
public Long getTs() {
|
||||
return ts;
|
||||
}
|
||||
|
||||
public void setTs(Long ts) {
|
||||
this.ts = ts;
|
||||
}
|
||||
|
||||
public String getDeviceCode() {
|
||||
return deviceCode;
|
||||
}
|
||||
|
||||
public void setDeviceCode(String deviceCode) {
|
||||
this.deviceCode = deviceCode;
|
||||
}
|
||||
|
||||
public int getDeviceType() {
|
||||
return deviceType;
|
||||
}
|
||||
|
||||
public void setDeviceType(int deviceType) {
|
||||
this.deviceType = deviceType;
|
||||
}
|
||||
|
||||
public int getOnlineStatus() {
|
||||
return onlineStatus;
|
||||
}
|
||||
|
||||
public void setOnlineStatus(int onlineStatus) {
|
||||
this.onlineStatus = onlineStatus;
|
||||
}
|
||||
|
||||
public Long getSceneId() {
|
||||
return sceneId;
|
||||
}
|
||||
|
||||
public void setSceneId(Long sceneId) {
|
||||
this.sceneId = sceneId;
|
||||
}
|
||||
}
|
@ -0,0 +1,35 @@
|
||||
package com.ruoyi.common.core.enums;
|
||||
/**
|
||||
* @Description: 返回结果枚举
|
||||
* @ClassName: ResultEnums
|
||||
* @Author : xins
|
||||
* @Date :2023-09-01 13:40
|
||||
* @Version :1.0
|
||||
*/
|
||||
public enum ResultEnums {
|
||||
|
||||
SUCCESS(200,"成功"),FAIL(500,"失败");
|
||||
public Integer code;
|
||||
public String message;
|
||||
|
||||
ResultEnums(Integer code, String message) {
|
||||
this.code = code;
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
public Integer getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public void setCode(Integer code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
|
||||
public void setMessage(String message) {
|
||||
this.message = message;
|
||||
}
|
||||
}
|
@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<groupId>com.ruoyi</groupId>
|
||||
<artifactId>ruoyi-modules</artifactId>
|
||||
<version>3.6.3</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>ruoyi-modules-dataprocess</artifactId>
|
||||
|
||||
<description>
|
||||
ruoyi-modules-dataprocess数据处理模块
|
||||
</description>
|
||||
|
||||
<dependencies>
|
||||
|
||||
<!-- SpringCloud Alibaba Nacos -->
|
||||
<dependency>
|
||||
<groupId>com.alibaba.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- SpringCloud Alibaba Nacos Config -->
|
||||
<dependency>
|
||||
<groupId>com.alibaba.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- SpringCloud Alibaba Sentinel -->
|
||||
<dependency>
|
||||
<groupId>com.alibaba.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-alibaba-sentinel</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- SpringBoot Actuator -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-actuator</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- Swagger UI -->
|
||||
<dependency>
|
||||
<groupId>io.springfox</groupId>
|
||||
<artifactId>springfox-swagger-ui</artifactId>
|
||||
<version>${swagger.fox.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Mysql Connector -->
|
||||
<dependency>
|
||||
<groupId>com.mysql</groupId>
|
||||
<artifactId>mysql-connector-j</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- RuoYi Common DataSource -->
|
||||
<dependency>
|
||||
<groupId>com.ruoyi</groupId>
|
||||
<artifactId>ruoyi-common-datasource</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- RuoYi Common DataScope -->
|
||||
<dependency>
|
||||
<groupId>com.ruoyi</groupId>
|
||||
<artifactId>ruoyi-common-datascope</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- RuoYi Common Log -->
|
||||
<dependency>
|
||||
<groupId>com.ruoyi</groupId>
|
||||
<artifactId>ruoyi-common-log</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- RuoYi Common Swagger -->
|
||||
<dependency>
|
||||
<groupId>com.ruoyi</groupId>
|
||||
<artifactId>ruoyi-common-swagger</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!--Mica-Mqtt-->
|
||||
<dependency>
|
||||
<groupId>net.dreamlu</groupId>
|
||||
<artifactId>mica-mqtt-client-spring-boot-starter</artifactId>
|
||||
<version>2.1.0</version>
|
||||
</dependency>
|
||||
|
||||
<!-- HW API TDENGINE-->
|
||||
<dependency>
|
||||
<groupId>com.ruoyi</groupId>
|
||||
<artifactId>hw-api-tdengine</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.locationtech.jts</groupId>
|
||||
<artifactId>jts-core</artifactId>
|
||||
<version>1.19.0</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<finalName>${project.artifactId}</finalName>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
<goal>repackage</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
</project>
|
@ -0,0 +1,34 @@
|
||||
package com.ruoyi.dataprocess;
|
||||
|
||||
import com.ruoyi.common.security.annotation.EnableCustomConfig;
|
||||
import com.ruoyi.common.security.annotation.EnableRyFeignClients;
|
||||
import com.ruoyi.common.swagger.annotation.EnableCustomSwagger2;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
||||
/**
|
||||
* 系统模块
|
||||
*
|
||||
* @author xins
|
||||
*/
|
||||
@EnableCustomConfig
|
||||
@EnableCustomSwagger2
|
||||
@EnableRyFeignClients
|
||||
@SpringBootApplication
|
||||
public class HwDataProcessApplication
|
||||
{
|
||||
public static void main(String[] args)
|
||||
{
|
||||
SpringApplication.run(HwDataProcessApplication.class, args);
|
||||
System.out.println("(♥◠‿◠)ノ゙ 数据处理模块启动成功 ლ(´ڡ`ლ)゙ \n" +
|
||||
" .-------. ____ __ \n" +
|
||||
" | _ _ \\ \\ \\ / / \n" +
|
||||
" | ( ' ) | \\ _. / ' \n" +
|
||||
" |(_ o _) / _( )_ .' \n" +
|
||||
" | (_,_).' __ ___(_ o _)' \n" +
|
||||
" | |\\ \\ | || |(_,_)' \n" +
|
||||
" | | \\ `' /| `-' / \n" +
|
||||
" | | \\ / \\ / \n" +
|
||||
" ''-' `'-' `-..-' ");
|
||||
}
|
||||
}
|
@ -0,0 +1,24 @@
|
||||
package com.ruoyi.dataprocess.amap;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* @Description: 要判断的点的实体类
|
||||
* @ClassName: PositionUtils.Postion
|
||||
* @Author : xins
|
||||
* @Date :2023-09-02 12:11
|
||||
* @Version :1.0
|
||||
*/
|
||||
@Data
|
||||
public class PositionVo{
|
||||
private BigDecimal longitude;
|
||||
|
||||
private BigDecimal latitude;
|
||||
|
||||
public PositionVo(BigDecimal longitude, BigDecimal latitude) {
|
||||
this.longitude = longitude;
|
||||
this.latitude = latitude;
|
||||
}
|
||||
}
|
@ -0,0 +1,77 @@
|
||||
package com.ruoyi.dataprocess.common;
|
||||
|
||||
import org.springframework.beans.factory.DisposableBean;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.ApplicationContextAware;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class SpringBeanUtils implements ApplicationContextAware, DisposableBean {
|
||||
private static ApplicationContext applicationContext = null;
|
||||
|
||||
|
||||
/**
|
||||
* 取得存储在静态变量中的ApplicationContext.
|
||||
*/
|
||||
public static ApplicationContext getApplicationContext() {
|
||||
assertContextInjected();
|
||||
return applicationContext;
|
||||
}
|
||||
|
||||
/**
|
||||
* 从静态变量applicationContext中取得Bean, 自动转型为所赋值对象的类型.
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public static <T> T getBean(String name) {
|
||||
// log.debug("从SpringContextHolder中取出Bean:" + name);
|
||||
assertContextInjected();
|
||||
return (T) applicationContext.getBean(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* 从静态变量applicationContext中取得Bean, 自动转型为所赋值对象的类型.
|
||||
*/
|
||||
public static <T> T getBean(Class<T> requiredType) {
|
||||
assertContextInjected();
|
||||
return applicationContext.getBean(requiredType);
|
||||
}
|
||||
|
||||
/**
|
||||
* 清除SpringContextHolder中的ApplicationContext为Null.
|
||||
*/
|
||||
public static void clearHolder() {
|
||||
// log.debug("清除SpringContextHolder中的ApplicationContext:"
|
||||
// + applicationContext);
|
||||
applicationContext = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 实现ApplicationContextAware接口, 注入Context到静态变量中.
|
||||
*/
|
||||
@Override
|
||||
public void setApplicationContext(ApplicationContext applicationContext) {
|
||||
|
||||
if (SpringBeanUtils.applicationContext != null) {
|
||||
// log.warn("SpringContextHolder中的ApplicationContext被覆盖, 原有ApplicationContext为:" + SpringContextHolder.applicationContext);
|
||||
}
|
||||
|
||||
SpringBeanUtils.applicationContext = applicationContext; // NOSONAR
|
||||
}
|
||||
|
||||
/**
|
||||
* 实现DisposableBean接口, 在Context关闭时清理静态变量.
|
||||
*/
|
||||
@Override
|
||||
public void destroy() throws Exception {
|
||||
SpringBeanUtils.clearHolder();
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查ApplicationContext不为空.
|
||||
*/
|
||||
private static void assertContextInjected() {
|
||||
if (applicationContext == null) {
|
||||
throw new IllegalStateException("applicaitonContext属性未注入, 请在applicationContext.xml中定义SpringBeanUtils.");
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,38 @@
|
||||
package com.ruoyi.dataprocess.config;
|
||||
|
||||
import com.ruoyi.dataprocess.listener.RedisMessageListener;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.data.redis.connection.RedisConnectionFactory;
|
||||
import org.springframework.data.redis.listener.PatternTopic;
|
||||
import org.springframework.data.redis.listener.RedisMessageListenerContainer;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
@Configuration
|
||||
public class RedisMessageListenerConfig {
|
||||
|
||||
@Autowired
|
||||
private RedisMessageListener redisMessageListener;
|
||||
@Autowired
|
||||
private RedisConnectionFactory redisConnectionFactory;
|
||||
|
||||
/**
|
||||
* 配置订阅关系
|
||||
*/
|
||||
@Bean
|
||||
public RedisMessageListenerContainer container() {
|
||||
RedisMessageListenerContainer container = new RedisMessageListenerContainer();
|
||||
container.setConnectionFactory(redisConnectionFactory);
|
||||
|
||||
//订阅频道
|
||||
List<PatternTopic> topicList = Arrays.asList(new PatternTopic("life.*"),new PatternTopic("*.life"));
|
||||
container.addMessageListener(redisMessageListener, topicList);
|
||||
|
||||
return container;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,30 @@
|
||||
package com.ruoyi.dataprocess.listener;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.redis.connection.Message;
|
||||
import org.springframework.data.redis.connection.MessageListener;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.data.redis.serializer.RedisSerializer;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
@Slf4j
|
||||
public class RedisMessageListener implements MessageListener {
|
||||
|
||||
@Autowired
|
||||
private RedisTemplate redisTemplate;
|
||||
|
||||
@Override
|
||||
public void onMessage(Message message, byte[] pattern) {
|
||||
|
||||
RedisSerializer keySerializer = redisTemplate.getKeySerializer();
|
||||
RedisSerializer valueSerializer = redisTemplate.getValueSerializer();
|
||||
|
||||
log.info("----------Life接收到发布者消息----------");
|
||||
log.info("|频道:{}",keySerializer.deserialize(message.getChannel()));
|
||||
log.info("|当前监听器绑定的pattern:{}",new String(pattern));
|
||||
log.info("|消息内容:{}",valueSerializer.deserialize(message.getBody()));
|
||||
log.info("---------------------------------");
|
||||
}
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
package com.ruoyi.dataprocess.mapper;
|
||||
|
||||
import com.ruoyi.dataprocess.domain.HwAlarmInfo;
|
||||
|
||||
/**
|
||||
* 报警信息Mapper接口
|
||||
*
|
||||
* @author xins
|
||||
* @date 2023-09-04
|
||||
*/
|
||||
public interface HwAlarmInfoMapper {
|
||||
/**
|
||||
* 新增报警信息
|
||||
*
|
||||
* @param hwAlarmInfo 报警信息
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertHwAlarmInfo(HwAlarmInfo hwAlarmInfo);
|
||||
|
||||
}
|
@ -0,0 +1,50 @@
|
||||
package com.ruoyi.dataprocess.mapper;
|
||||
|
||||
|
||||
import com.ruoyi.dataprocess.domain.HwElectronicFence;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Description: 电子围栏实体类
|
||||
* @ClassName: HwElectronicFenceMapper
|
||||
* @Author : xins
|
||||
* @Date :2023-09-03 11:48
|
||||
* @Version :1.0
|
||||
*/
|
||||
public interface HwElectronicFenceMapper {
|
||||
|
||||
public List<HwElectronicFence> selectSuitableElectronicFenceList(@Param("deviceId") Long deviceId,
|
||||
@Param("monitorUnitId") Long monitorUnitId,
|
||||
@Param("sceneId") Long sceneId);
|
||||
|
||||
/**
|
||||
* @param: deviceId
|
||||
* @description 根据设备ID获取电子围栏配置
|
||||
* @author xins
|
||||
* @date 2023-09-03 12:10
|
||||
* @return List<HwElectronicFence>
|
||||
*/
|
||||
public List<HwElectronicFence> selectElectronicFencesByDeviceId(Long deviceId);
|
||||
|
||||
/**
|
||||
* @param: monitorUnitId
|
||||
* @description 根据监控单元ID获取电子围栏配置
|
||||
* @author xins
|
||||
* @date 2023-09-03 12:11
|
||||
* @return List<HwElectronicFence>
|
||||
*/
|
||||
public List<HwElectronicFence> selectElectronicFencesByMonitorUnitId(Long monitorUnitId);
|
||||
|
||||
/**
|
||||
* @param: sceneId
|
||||
* @description 根据场景Id获取电子围栏配置
|
||||
* @author xins
|
||||
* @date 2023-09-03 12:11
|
||||
* @return List<HwElectronicFence>
|
||||
*/
|
||||
public List<HwElectronicFence> selectElectronicFencesBySceneId(Long sceneId);
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,29 @@
|
||||
//package com.ruoyi.dataprocess.mqtt.client.controller;
|
||||
//
|
||||
//import com.ruoyi.dataprocess.mqtt.client.service.ClientService;
|
||||
//import io.swagger.v3.oas.annotations.Operation;
|
||||
//import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
//import org.springframework.beans.factory.annotation.Autowired;
|
||||
//import org.springframework.web.bind.annotation.*;
|
||||
//
|
||||
//@Tag(name = "Mqtt::客户端")
|
||||
//@RequestMapping("/mqtt/client")
|
||||
//@RestController
|
||||
//public class ClientController {
|
||||
//
|
||||
// @Autowired
|
||||
// private ClientService service;
|
||||
//
|
||||
// @Operation(summary = "publish")
|
||||
// @PostMapping("/publish")
|
||||
// public boolean publish(@RequestBody String body) {
|
||||
// return service.publish(body);
|
||||
// }
|
||||
//
|
||||
// @Operation(summary = "sub")
|
||||
// @GetMapping("/sub")
|
||||
// public boolean sub() {
|
||||
// return service.sub();
|
||||
// }
|
||||
//
|
||||
//}
|
@ -0,0 +1,48 @@
|
||||
/*
|
||||
* Copyright (c) 2019-2029, Dreamlu 卢春梦 (596392912@qq.com & dreamlu.net).
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.ruoyi.dataprocess.mqtt.client.listener;
|
||||
|
||||
import net.dreamlu.iot.mqtt.core.client.IMqttClientConnectListener;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.tio.core.ChannelContext;
|
||||
|
||||
/**
|
||||
* 客户端连接状态监听
|
||||
*
|
||||
* @author L.cm
|
||||
*/
|
||||
@Service
|
||||
public class MqttClientConnectListener implements IMqttClientConnectListener {
|
||||
private static final Logger logger = LoggerFactory.getLogger(MqttClientConnectListener.class);
|
||||
|
||||
@Override
|
||||
public void onConnected(ChannelContext context, boolean isReconnect) {
|
||||
if (isReconnect) {
|
||||
logger.info("重连 mqtt 服务器重连成功...");
|
||||
} else {
|
||||
logger.info("连接 mqtt 服务器成功...");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisconnect(ChannelContext channelContext, Throwable throwable, String remark, boolean isRemove) {
|
||||
logger.error("mqtt 链接断开 remark:{} isRemove:{}", remark, isRemove, throwable);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,67 @@
|
||||
//package com.ruoyi.dataprocess.mqtt.client.listener;
|
||||
//
|
||||
//import com.alibaba.fastjson.JSONArray;
|
||||
//import com.alibaba.fastjson.JSONObject;
|
||||
//import com.ruoyi.common.core.constant.TdEngineConstants;
|
||||
//import com.ruoyi.common.core.domain.R;
|
||||
//import com.ruoyi.common.core.enums.ResultEnums;
|
||||
//import com.ruoyi.common.core.utils.SpringUtils;
|
||||
//import com.ruoyi.common.core.utils.StringUtils;
|
||||
//import com.ruoyi.dataprocess.common.SpringBeanUtils;
|
||||
//import com.ruoyi.dataprocess.mapper.HwDeviceMapper;
|
||||
//import com.ruoyi.dataprocess.mqtt.client.config.MqttConfiguration;
|
||||
//import com.ruoyi.dataprocess.service.IDataProcessService;
|
||||
//import com.ruoyi.system.api.RemoteFileService;
|
||||
//import com.ruoyi.system.api.factory.RemoteFileFallbackFactory;
|
||||
//import com.ruoyi.tdengine.api.RemoteTdEngineService;
|
||||
//import com.ruoyi.tdengine.api.domain.TdField;
|
||||
//import net.dreamlu.iot.mqtt.codec.MqttPublishMessage;
|
||||
//import net.dreamlu.iot.mqtt.core.client.IMqttClientMessageListener;
|
||||
//import org.slf4j.Logger;
|
||||
//import org.slf4j.LoggerFactory;
|
||||
//import org.springframework.beans.factory.annotation.Autowired;
|
||||
//import org.springframework.stereotype.Component;
|
||||
//import org.springframework.stereotype.Controller;
|
||||
//import org.springframework.stereotype.Service;
|
||||
//import org.tio.core.ChannelContext;
|
||||
//
|
||||
//import javax.annotation.PostConstruct;
|
||||
//import javax.annotation.Resource;
|
||||
//import java.nio.ByteBuffer;
|
||||
//import java.nio.charset.StandardCharsets;
|
||||
//import java.util.List;
|
||||
//
|
||||
///**
|
||||
// * 客户端消息监听的另一种方式
|
||||
// *
|
||||
// * @author L.cm
|
||||
// */
|
||||
//@Service
|
||||
//public class MqttClientMessageListener implements IMqttClientMessageListener {
|
||||
// private static final Logger logger = LoggerFactory.getLogger(MqttClientMessageListener.class);
|
||||
//
|
||||
// private IDataProcessService dataProcessService;
|
||||
//
|
||||
//// @PostConstruct
|
||||
//// public void init() {
|
||||
//// remoteTdEngineService = SpringBeanUtils.getBean(RemoteTdEngineService.class);
|
||||
//// System.out.println("--***-"+remoteTdEngineService);
|
||||
////
|
||||
//// }
|
||||
//
|
||||
// @Override
|
||||
// public void onMessage(ChannelContext context, String topic, MqttPublishMessage message, ByteBuffer payload) {
|
||||
// String payloadString = new String(payload.array(), StandardCharsets.UTF_8);
|
||||
// System.out.println("paa:" + topic);
|
||||
//// System.out.println("data"+dataProcessService);
|
||||
// if(dataProcessService == null){
|
||||
// dataProcessService = SpringBeanUtils.getBean(IDataProcessService.class);
|
||||
// }
|
||||
//// if(topic.startsWith(MqttConfiguration))
|
||||
// dataProcessService.processBusinessData(payloadString);
|
||||
// logger.info("topic:{} payload:{}", topic, payloadString);
|
||||
// }
|
||||
//
|
||||
//
|
||||
//}
|
||||
//
|
@ -0,0 +1,45 @@
|
||||
//package com.ruoyi.dataprocess.mqtt.client.service;
|
||||
//
|
||||
//import com.ruoyi.dataprocess.mqtt.client.config.MqttConfiguration;
|
||||
//import com.ruoyi.dataprocess.mqtt.client.listener.MqttClientConnectListener;
|
||||
//import com.ruoyi.dataprocess.mqtt.client.listener.MqttClientMessageListener;
|
||||
//import net.dreamlu.iot.mqtt.codec.MqttQoS;
|
||||
//import net.dreamlu.iot.mqtt.core.client.MqttClient;
|
||||
//import net.dreamlu.iot.mqtt.spring.client.MqttClientTemplate;
|
||||
//import org.slf4j.Logger;
|
||||
//import org.slf4j.LoggerFactory;
|
||||
//import org.springframework.beans.factory.annotation.Autowired;
|
||||
//import org.springframework.stereotype.Component;
|
||||
//import org.springframework.stereotype.Service;
|
||||
//
|
||||
//import javax.annotation.PostConstruct;
|
||||
//import java.nio.charset.StandardCharsets;
|
||||
//import java.util.Arrays;
|
||||
//
|
||||
///**
|
||||
// * @Description: MQTT客户端服务
|
||||
// * @ClassName: ClientService
|
||||
// * @Author : xins
|
||||
// * @Date :2023-08-31 14:33
|
||||
// * @Version :1.0
|
||||
// */
|
||||
//public class ClientService {
|
||||
// private static final Logger logger = LoggerFactory.getLogger(ClientService.class);
|
||||
//
|
||||
// private MqttClientTemplate client;
|
||||
//
|
||||
// public boolean publish(String body) {
|
||||
// client.publish("/test/client", body.getBytes(StandardCharsets.UTF_8));
|
||||
// return true;
|
||||
// }
|
||||
//
|
||||
// public boolean sub(String topic) {
|
||||
// client.subQos0(topic, new MqttClientMessageListener());
|
||||
//// String[] topicsArr = topics.split(",");
|
||||
//// Arrays.asList(topicsArr).forEach(topicFilter ->
|
||||
//// client.subQos0(topicFilter, new MqttClientMessageListener())
|
||||
//// );
|
||||
// return true;
|
||||
// }
|
||||
//
|
||||
//}
|
@ -0,0 +1,15 @@
|
||||
package com.ruoyi.dataprocess.service;
|
||||
|
||||
public interface IDataProcessService {
|
||||
|
||||
/**
|
||||
* @param: jsonData
|
||||
* @param imagePath
|
||||
* @param imagePatterns
|
||||
* @description 处理业务数据
|
||||
* @author xins
|
||||
* @date 2023-08-31 16:16
|
||||
*/
|
||||
public void processBusinessData(String jsonData,String imagePath,String imagePatterns);
|
||||
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
package com.ruoyi.dataprocess.service;
|
||||
|
||||
/**
|
||||
* @Description: 设备状态处理接口
|
||||
* @ClassName: IDeviceStatusService
|
||||
* @Author : xins
|
||||
* @Date :2023-09-04 15:32
|
||||
* @Version :1.0
|
||||
*/
|
||||
public interface IDeviceStatusService {
|
||||
|
||||
public void handleDeviceStatus();
|
||||
}
|
@ -0,0 +1,27 @@
|
||||
package com.ruoyi.dataprocess.service.impl;
|
||||
|
||||
import com.ruoyi.dataprocess.service.IDeviceStatusService;
|
||||
import com.ruoyi.tdengine.api.RemoteTdEngineService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
* @Description: 设备状态处理服务
|
||||
* @ClassName: DeviceStatusServiceImpl
|
||||
* @Author : xins
|
||||
* @Date :2023-09-04 15:31
|
||||
* @Version :1.0
|
||||
*/
|
||||
@Service
|
||||
public class DeviceStatusServiceImpl implements IDeviceStatusService {
|
||||
|
||||
@Resource
|
||||
private RemoteTdEngineService remoteTdEngineService;
|
||||
|
||||
@Override
|
||||
public void handleDeviceStatus(){
|
||||
|
||||
System.out.println("handleDeviceStatus");
|
||||
}
|
||||
}
|
@ -0,0 +1,32 @@
|
||||
package com.ruoyi.dataprocess.mqtt.client.service;
|
||||
|
||||
import net.dreamlu.iot.mqtt.spring.client.MqttClientTemplate;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
/**
|
||||
* @author wsq
|
||||
*/
|
||||
@Service
|
||||
public class ClientService {
|
||||
private static final Logger logger = LoggerFactory.getLogger(ClientService.class);
|
||||
@Autowired
|
||||
private MqttClientTemplate client;
|
||||
|
||||
public boolean publish(String body) {
|
||||
client.publish("/test/client", body.getBytes(StandardCharsets.UTF_8));
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean sub() {
|
||||
client.subQos0("/test/#", (context, topic, message, payload) -> {
|
||||
logger.info(topic + '\t' + new String(payload, StandardCharsets.UTF_8));
|
||||
});
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,54 @@
|
||||
/*
|
||||
* Copyright (c) 2019-2029, Dreamlu 卢春梦 (596392912@qq.com & dreamlu.net).
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.ruoyi.dataprocess.mqtt.client.listener;
|
||||
|
||||
import net.dreamlu.iot.mqtt.core.client.MqttClientCreator;
|
||||
import net.dreamlu.iot.mqtt.spring.client.event.MqttConnectedEvent;
|
||||
import net.dreamlu.iot.mqtt.spring.client.event.MqttDisconnectEvent;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.event.EventListener;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* 客户端连接状态监听
|
||||
*
|
||||
* @author L.cm
|
||||
*/
|
||||
@Service
|
||||
public class MqttClientConnectListener {
|
||||
private static final Logger logger = LoggerFactory.getLogger(MqttClientConnectListener.class);
|
||||
|
||||
@Autowired
|
||||
private MqttClientCreator mqttClientCreator;
|
||||
|
||||
@EventListener
|
||||
public void onConnected(MqttConnectedEvent event) {
|
||||
logger.info("MqttConnectedEvent:{}", event);
|
||||
}
|
||||
|
||||
@EventListener
|
||||
public void onDisconnect(MqttDisconnectEvent event) {
|
||||
logger.info("MqttDisconnectEvent:{}", event);
|
||||
// 在断线时更新 clientId、username、password
|
||||
mqttClientCreator.clientId("newClient" + System.currentTimeMillis())
|
||||
.username("newUserName")
|
||||
.password("newPassword");
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,10 @@
|
||||
Spring Boot Version: ${spring-boot.version}
|
||||
Spring Application Name: ${spring.application.name}
|
||||
_ _
|
||||
(_) | |
|
||||
_ __ _ _ ___ _ _ _ ______ ___ _ _ ___ | |_ ___ _ __ ___
|
||||
| '__|| | | | / _ \ | | | || ||______|/ __|| | | |/ __|| __| / _ \| '_ ` _ \
|
||||
| | | |_| || (_) || |_| || | \__ \| |_| |\__ \| |_ | __/| | | | | |
|
||||
|_| \__,_| \___/ \__, ||_| |___/ \__, ||___/ \__| \___||_| |_| |_|
|
||||
__/ | __/ |
|
||||
|___/ |___/
|
@ -0,0 +1,25 @@
|
||||
# Tomcat
|
||||
server:
|
||||
port: 9603
|
||||
|
||||
# Spring
|
||||
spring:
|
||||
application:
|
||||
# 应用名称
|
||||
name: hw-data-process
|
||||
profiles:
|
||||
# 环境配置
|
||||
active: dev
|
||||
cloud:
|
||||
nacos:
|
||||
discovery:
|
||||
# 服务注册地址
|
||||
server-addr: 127.0.0.1:8848
|
||||
config:
|
||||
# 配置中心地址
|
||||
server-addr: 127.0.0.1:8848
|
||||
# 配置文件格式
|
||||
file-extension: yml
|
||||
# 共享配置
|
||||
shared-configs:
|
||||
- application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
|
@ -0,0 +1,74 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<configuration scan="true" scanPeriod="60 seconds" debug="false">
|
||||
<!-- 日志存放路径 -->
|
||||
<property name="log.path" value="logs/hw-data-process" />
|
||||
<!-- 日志输出格式 -->
|
||||
<property name="log.pattern" value="%d{HH:mm:ss.SSS} [%thread] %-5level %logger{20} - [%method,%line] - %msg%n" />
|
||||
|
||||
<!-- 控制台输出 -->
|
||||
<appender name="console" class="ch.qos.logback.core.ConsoleAppender">
|
||||
<encoder>
|
||||
<pattern>${log.pattern}</pattern>
|
||||
</encoder>
|
||||
</appender>
|
||||
|
||||
<!-- 系统日志输出 -->
|
||||
<appender name="file_info" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||
<file>${log.path}/info.log</file>
|
||||
<!-- 循环政策:基于时间创建日志文件 -->
|
||||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
||||
<!-- 日志文件名格式 -->
|
||||
<fileNamePattern>${log.path}/info.%d{yyyy-MM-dd}.log</fileNamePattern>
|
||||
<!-- 日志最大的历史 60天 -->
|
||||
<maxHistory>60</maxHistory>
|
||||
</rollingPolicy>
|
||||
<encoder>
|
||||
<pattern>${log.pattern}</pattern>
|
||||
</encoder>
|
||||
<filter class="ch.qos.logback.classic.filter.LevelFilter">
|
||||
<!-- 过滤的级别 -->
|
||||
<level>INFO</level>
|
||||
<!-- 匹配时的操作:接收(记录) -->
|
||||
<onMatch>ACCEPT</onMatch>
|
||||
<!-- 不匹配时的操作:拒绝(不记录) -->
|
||||
<onMismatch>DENY</onMismatch>
|
||||
</filter>
|
||||
</appender>
|
||||
|
||||
<appender name="file_error" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||
<file>${log.path}/error.log</file>
|
||||
<!-- 循环政策:基于时间创建日志文件 -->
|
||||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
||||
<!-- 日志文件名格式 -->
|
||||
<fileNamePattern>${log.path}/error.%d{yyyy-MM-dd}.log</fileNamePattern>
|
||||
<!-- 日志最大的历史 60天 -->
|
||||
<maxHistory>60</maxHistory>
|
||||
</rollingPolicy>
|
||||
<encoder>
|
||||
<pattern>${log.pattern}</pattern>
|
||||
</encoder>
|
||||
<filter class="ch.qos.logback.classic.filter.LevelFilter">
|
||||
<!-- 过滤的级别 -->
|
||||
<level>ERROR</level>
|
||||
<!-- 匹配时的操作:接收(记录) -->
|
||||
<onMatch>ACCEPT</onMatch>
|
||||
<!-- 不匹配时的操作:拒绝(不记录) -->
|
||||
<onMismatch>DENY</onMismatch>
|
||||
</filter>
|
||||
</appender>
|
||||
|
||||
<!-- 系统模块日志级别控制 -->
|
||||
<logger name="com.ruoyi" level="info" />
|
||||
<!-- Spring日志级别控制 -->
|
||||
<logger name="org.springframework" level="warn" />
|
||||
|
||||
<root level="info">
|
||||
<appender-ref ref="console" />
|
||||
</root>
|
||||
|
||||
<!--系统操作日志-->
|
||||
<root level="info">
|
||||
<appender-ref ref="file_info" />
|
||||
<appender-ref ref="file_error" />
|
||||
</root>
|
||||
</configuration>
|
@ -0,0 +1,75 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.ruoyi.dataprocess.mapper.HwAlarmInfoMapper">
|
||||
|
||||
<resultMap type="HwAlarmInfo" id="HwAlarmInfoResult">
|
||||
<result property="alarmInfoId" column="alarm_info_id" />
|
||||
<result property="alarmInfoType" column="alarm_info_type" />
|
||||
<result property="alarmReleatedId" column="alarm_releated_id" />
|
||||
<result property="deviceId" column="device_id" />
|
||||
<result property="monitorUnitId" column="monitor_unit_id" />
|
||||
<result property="sceneId" column="scene_id" />
|
||||
<result property="alarmLevelId" column="alarm_level_id" />
|
||||
<result property="alarmTypeId" column="alarm_type_id" />
|
||||
<result property="modeFunctionId" column="mode_function_id" />
|
||||
<result property="functionName" column="function_name" />
|
||||
<result property="functionIdentifier" column="function_identifier" />
|
||||
<result property="functionValue" column="function_value" />
|
||||
<result property="triggerStatus" column="trigger_status" />
|
||||
<result property="handleStatus" column="handle_status" />
|
||||
<result property="alarmTime" column="alarm_time" />
|
||||
<result property="createTime" column="create_time" />
|
||||
<result property="updateBy" column="update_by" />
|
||||
<result property="updateTime" column="update_time" />
|
||||
<result property="alarmInfoField" column="alarm_info_field" />
|
||||
</resultMap>
|
||||
|
||||
|
||||
<insert id="insertHwAlarmInfo" parameterType="HwAlarmInfo" useGeneratedKeys="true" keyProperty="alarmInfoId">
|
||||
insert into hw_alarm_info
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="alarmInfoType != null and alarmInfoType != ''">alarm_info_type,</if>
|
||||
<if test="alarmReleatedId != null">alarm_releated_id,</if>
|
||||
<if test="deviceId != null">device_id,</if>
|
||||
<if test="monitorUnitId != null">monitor_unit_id,</if>
|
||||
<if test="sceneId != null">scene_id,</if>
|
||||
<if test="alarmLevelId != null">alarm_level_id,</if>
|
||||
<if test="alarmTypeId != null">alarm_type_id,</if>
|
||||
<if test="modeFunctionId != null">mode_function_id,</if>
|
||||
<if test="functionName != null">function_name,</if>
|
||||
<if test="functionIdentifier != null">function_identifier,</if>
|
||||
<if test="functionValue != null">function_value,</if>
|
||||
<if test="triggerStatus != null">trigger_status,</if>
|
||||
<if test="handleStatus != null and handleStatus != ''">handle_status,</if>
|
||||
<if test="alarmTime != null">alarm_time,</if>
|
||||
<if test="createTime != null">create_time,</if>
|
||||
<if test="updateBy != null">update_by,</if>
|
||||
<if test="updateTime != null">update_time,</if>
|
||||
<if test="alarmInfoField != null">alarm_info_field,</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="alarmInfoType != null and alarmInfoType != ''">#{alarmInfoType},</if>
|
||||
<if test="alarmReleatedId != null">#{alarmReleatedId},</if>
|
||||
<if test="deviceId != null">#{deviceId},</if>
|
||||
<if test="monitorUnitId != null">#{monitorUnitId},</if>
|
||||
<if test="sceneId != null">#{sceneId},</if>
|
||||
<if test="alarmLevelId != null">#{alarmLevelId},</if>
|
||||
<if test="alarmTypeId != null">#{alarmTypeId},</if>
|
||||
<if test="modeFunctionId != null">#{modeFunctionId},</if>
|
||||
<if test="functionName != null">#{functionName},</if>
|
||||
<if test="functionIdentifier != null">#{functionIdentifier},</if>
|
||||
<if test="functionValue != null">#{functionValue},</if>
|
||||
<if test="triggerStatus != null">#{triggerStatus},</if>
|
||||
<if test="handleStatus != null and handleStatus != ''">#{handleStatus},</if>
|
||||
<if test="alarmTime != null">#{alarmTime},</if>
|
||||
<if test="createTime != null">#{createTime},</if>
|
||||
<if test="updateBy != null">#{updateBy},</if>
|
||||
<if test="updateTime != null">#{updateTime},</if>
|
||||
<if test="alarmInfoField != null">#{alarmInfoField},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
|
||||
</mapper>
|
@ -0,0 +1,47 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.ruoyi.dataprocess.mapper.HwDeviceMapper">
|
||||
|
||||
<resultMap type="com.ruoyi.dataprocess.domain.HwDevice" id="HwDeviceResult">
|
||||
<result property="deviceId" column="device_id" />
|
||||
<result property="deviceCode" column="device_code" />
|
||||
<result property="deviceName" column="device_name" />
|
||||
<result property="sceneId" column="scene_id" />
|
||||
<result property="monitorUnitId" column="monitor_unit_id" />
|
||||
<result property="deviceType" column="device_type" />
|
||||
<result property="networkingMode" column="networking_mode" />
|
||||
<result property="accessProtocol" column="access_protocol" />
|
||||
<result property="dataFormat" column="data_format" />
|
||||
<result property="releatedDeviceId" column="releated_device_id" />
|
||||
<result property="deviceModeId" column="device_mode_id" />
|
||||
<result property="accessGwProtocol" column="access_gw_protocol" />
|
||||
<result property="activeStatus" column="active_status" />
|
||||
<result property="deviceStatus" column="device_status" />
|
||||
<result property="activeTime" column="active_time" />
|
||||
<result property="devicePic" column="device_pic" />
|
||||
<result property="ipAddress" column="ip_address" />
|
||||
<result property="areaId" column="area_id" />
|
||||
<result property="deviceLocation" column="device_location" />
|
||||
<result property="currentModuleVersion" column="current_module_version" />
|
||||
<result property="currentSinglechipVersion" column="current_singlechip_version" />
|
||||
<result property="remark" column="remark" />
|
||||
<result property="createBy" column="create_by" />
|
||||
<result property="createTime" column="create_time" />
|
||||
<result property="updateBy" column="update_by" />
|
||||
<result property="updateTime" column="update_time" />
|
||||
<result property="deviceField" column="device_field" />
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectHwDeviceVo">
|
||||
select device_id, device_code, scene_id, monitor_unit_id, device_type, device_mode_id, device_status from hw_device
|
||||
</sql>
|
||||
|
||||
<select id="selectHwDeviceByDeviceCode" parameterType="String" resultMap="HwDeviceResult">
|
||||
<include refid="selectHwDeviceVo"/>
|
||||
where device_code = #{deviceCode} limit 1
|
||||
</select>
|
||||
|
||||
|
||||
</mapper>
|
@ -0,0 +1,57 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.ruoyi.dataprocess.mapper.HwElectronicFenceMapper">
|
||||
|
||||
<resultMap type="HwElectronicFence" id="HwElectronicFenceResult">
|
||||
<result property="electronicFenceId" column="electronic_fence_id" />
|
||||
<result property="electronicFenceName" column="electronic_fence_name" />
|
||||
<result property="sceneId" column="scene_id" />
|
||||
<result property="fenceType" column="fence_type" />
|
||||
<result property="effectiveTimeFlag" column="effective_time_flag" />
|
||||
<result property="effectiveTime" column="effective_time" />
|
||||
<result property="triggerStatus" column="trigger_status" />
|
||||
<result property="areaShapeFlag" column="area_shape_flag" />
|
||||
<result property="areaRange" column="area_range" />
|
||||
<result property="fencePushFlag" column="fence_push_flag" />
|
||||
<result property="fencePushContent" column="fence_push_content" />
|
||||
<result property="fenceRecoverContent" column="fence_recover_content" />
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectElectronicFenceVo">
|
||||
select electronic_fence_id, electronic_fence_name, scene_id, fence_type, effective_time_flag, effective_time, trigger_status, area_shape_flag,
|
||||
area_range, fence_push_flag, fence_push_content, fence_recover_content
|
||||
from hw_electronic_fence hef
|
||||
</sql>
|
||||
|
||||
<select id="selectSuitableElectronicFenceList" resultMap="HwElectronicFenceResult">
|
||||
<include refid="selectElectronicFenceVo"/>
|
||||
where (exists (select 1 from hw_fence_target hft where
|
||||
hft.electronic_fence_id = hef.electronic_fence_id
|
||||
and ((hft.target_id=#{deviceId} and hft.target_type=1) or (hft.target_id=#{monitorUnitId} and hft.target_type=2))))
|
||||
or (fence_type=3 and scene_id = #{sceneId}) and hef.trigger_status!=0
|
||||
</select>
|
||||
|
||||
<select id="selectElectronicFencesByDeviceId" resultMap="HwElectronicFenceResult">
|
||||
<include refid="selectElectronicFenceVo"/>
|
||||
where exists (select 1 from hw_fence_target hft where
|
||||
hft.electronic_fence_id = hef.electronic_fence_id
|
||||
and hft.target_id=#{deviceId} and hft.target_type=1)
|
||||
and hef.fence_type=1 and hef.trigger_status!=0
|
||||
</select>
|
||||
|
||||
<select id="selectElectronicFencesByMonitorUnitId" resultMap="HwElectronicFenceResult">
|
||||
<include refid="selectElectronicFenceVo"/>
|
||||
where exists (select 1 from hw_fence_target hft where
|
||||
hft.electronic_fence_id = hef.electronic_fence_id
|
||||
and hft.target_id=#{deviceId} and hft.target_type=2)
|
||||
and hef.fence_type=2 and hef.trigger_status!=0
|
||||
</select>
|
||||
|
||||
<select id="selectElectronicFencesBySceneId" resultMap="HwElectronicFenceResult">
|
||||
<include refid="selectElectronicFenceVo"/>
|
||||
where scene_id=#{sceneId} and hef.fence_type=3 and hef.trigger_status!=0
|
||||
</select>
|
||||
|
||||
</mapper>
|
@ -0,0 +1,24 @@
|
||||
package com.ruoyi.tdengine.mapper;
|
||||
|
||||
import com.ruoyi.tdengine.api.domain.DeviceStatus;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Description:TDengine设备状态信息交互接口
|
||||
* @ClassName: DeviceStatusMapper
|
||||
* @Author : xins
|
||||
* @Date :2023-09-05 13:20
|
||||
* @Version :1.0
|
||||
*/
|
||||
public interface DeviceStatusMapper {
|
||||
|
||||
/**
|
||||
* @param: deviceStatus
|
||||
* @description 获取每天在线设备列表
|
||||
* @author xins
|
||||
* @date 2023-09-05 11:43
|
||||
* @return List<DeviceStatus>
|
||||
*/
|
||||
List<DeviceStatus> getOnlineDevicesGroupByDay(DeviceStatus deviceStatus);
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
package com.ruoyi.tdengine.service;
|
||||
|
||||
import com.ruoyi.tdengine.api.domain.DeviceStatus;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface IDeviceStatusService {
|
||||
|
||||
/**
|
||||
* @param: DeviceStatus
|
||||
* @description 获取时间范围内每天的在线设备
|
||||
* @author xins
|
||||
* @date 2023-09-05 13:23
|
||||
* @return List<DeviceStatus>
|
||||
*/
|
||||
public List<DeviceStatus> getOnlineDevicesGroupByDay(DeviceStatus queryDeviceStatus);
|
||||
}
|
@ -0,0 +1,52 @@
|
||||
package com.ruoyi.tdengine.service.impl;
|
||||
|
||||
import com.ruoyi.common.core.constant.TdEngineConstants;
|
||||
import com.ruoyi.tdengine.api.domain.DeviceStatus;
|
||||
import com.ruoyi.tdengine.mapper.DeviceStatusMapper;
|
||||
import com.ruoyi.tdengine.service.IDeviceStatusService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
/**
|
||||
* @Description: 设备状态信息业务服务
|
||||
* @ClassName: DeviceStatusServiceImpl
|
||||
* @Author : xins
|
||||
* @Date :2023-09-05 13:27
|
||||
* @Version :1.0
|
||||
*/
|
||||
@Service
|
||||
public class DeviceStatusServiceImpl implements IDeviceStatusService {
|
||||
|
||||
@Autowired
|
||||
private DeviceStatusMapper deviceStatusMapper;
|
||||
|
||||
/**
|
||||
* @param: DeviceStatus
|
||||
* @description 获取时间范围内每天的在线设备
|
||||
* @author xins
|
||||
* @date 2023-09-05 13:23
|
||||
* @return List<DeviceStatus>
|
||||
*/
|
||||
@Override
|
||||
public List<DeviceStatus> getOnlineDevicesGroupByDay(DeviceStatus queryDeviceStatus) {
|
||||
// Map<String, Object> params = new HashMap<>();
|
||||
// DeviceStatus queryDeviceStatus = new DeviceStatus();
|
||||
// String databaseName = TdEngineConstants.getDatabaseName(sceneId);
|
||||
// String superTableName = TdEngineConstants.getDeviceStatusSuperTableName(sceneId);
|
||||
// params.put("databaseName", databaseName);
|
||||
// params.put("superTableName", superTableName);
|
||||
// params.put("beginTime", beginTime);
|
||||
// params.put("endTime", endTime);
|
||||
// queryDeviceStatus.setParams(params);
|
||||
// if (sceneId != null) {
|
||||
// queryDeviceStatus.setSceneId(sceneId);
|
||||
// }
|
||||
|
||||
List<DeviceStatus> deviceStatuses = deviceStatusMapper.getOnlineDevicesGroupByDay(queryDeviceStatus);
|
||||
|
||||
return deviceStatuses;
|
||||
}
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
|
||||
<mapper namespace="com.ruoyi.tdengine.mapper.DeviceStatusMapper">
|
||||
|
||||
<select id="getOnlineDevicesGroupByDay" parameterType="com.ruoyi.tdengine.api.domain.DeviceStatus" resultType="com.ruoyi.tdengine.api.domain.DeviceStatus" >
|
||||
select timetruncate(ts,1d) ts,devicetype,onlinestatus,devicecode from #{params.databaseName}.#{params.superTableName}
|
||||
where onlinestatus=1
|
||||
<if test="{params.beginTime}!= null and {params.endTime} != null">
|
||||
and ts BETWEEN #{params.beginTime} AND #{params.endTime}
|
||||
</if>
|
||||
<if test="sceneId != null "> and scene_id = #{sceneId}</if>
|
||||
group by timetruncate(ts,1d),devicetype,onlinestatus,devicecode
|
||||
order by ts
|
||||
</select>
|
||||
|
||||
|
||||
</mapper>
|
Loading…
Reference in New Issue