feat:td3.0支持调整

V0.5.x
xiwa 2023-08-13 09:01:25 +08:00
parent 162c18b9c6
commit def1852011
36 changed files with 102 additions and 657 deletions

BIN
.DS_Store vendored

Binary file not shown.

3
.gitignore vendored
View File

@ -28,3 +28,6 @@ data/elasticsearch
.init
*.db
.flattened-pom.xml
.DS_Store
dependency-reduced-pom.xml

View File

@ -72,7 +72,7 @@ public class DeviceInfo implements Owned<String> {
/**
*
*/
private Map<String, Object> property = new HashMap<>();
private Map<String, ?> property = new HashMap<>();
/**
*

View File

@ -21,10 +21,14 @@ import java.util.Map;
public class DevicePropertyCache {
// 属性值
/**
*
*/
private Object value;
// 属性值时间: 设备上报时间
/**
* :
*/
private Long occurred;

View File

@ -12,6 +12,7 @@ package cc.iotkit.data.manager;
import cc.iotkit.common.api.Paging;
import cc.iotkit.data.IOwnedData;
import cc.iotkit.model.device.DeviceInfo;
import cc.iotkit.model.device.message.DevicePropertyCache;
import cc.iotkit.model.stats.DataItem;
import java.util.List;
@ -25,14 +26,14 @@ public interface IDeviceInfoData extends IOwnedData<DeviceInfo, String> {
* @param deviceId id
* @param properties map
*/
void saveProperties(String deviceId, Map<String, Object> properties);
void saveProperties(String deviceId, Map<String, DevicePropertyCache> properties);
/**
* map
*
* @param deviceId id
*/
Map<String, Object> getProperties(String deviceId);
Map<String, DevicePropertyCache> getProperties(String deviceId);
/**
* ID

View File

@ -17,7 +17,9 @@ import cc.iotkit.data.cache.DeviceInfoCacheEvict;
import cc.iotkit.data.cache.DeviceInfoCachePut;
import cc.iotkit.data.manager.IDeviceInfoData;
import cc.iotkit.model.device.DeviceInfo;
import cc.iotkit.model.device.message.DevicePropertyCache;
import cc.iotkit.model.stats.DataItem;
import com.fasterxml.jackson.core.type.TypeReference;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.SmartInitializingSingleton;
import org.springframework.beans.factory.annotation.Autowired;
@ -91,8 +93,8 @@ public class DeviceInfoDataCache implements IDeviceInfoData, SmartInitializingSi
}
@Override
public void saveProperties(String deviceId, Map<String, Object> properties) {
Map<String, Object> old = getProperties(deviceId);
public void saveProperties(String deviceId, Map<String, DevicePropertyCache> properties) {
Map<String, DevicePropertyCache> old = getProperties(deviceId);
old.putAll(properties);
redisTemplate.opsForValue().set(getPropertyCacheKey(deviceId), JsonUtils.toJsonString(old));
}
@ -105,12 +107,13 @@ public class DeviceInfoDataCache implements IDeviceInfoData, SmartInitializingSi
}
@Override
public Map<String, Object> getProperties(String deviceId) {
public Map<String, DevicePropertyCache> getProperties(String deviceId) {
String json = redisTemplate.opsForValue().get(getPropertyCacheKey(deviceId));
if (StringUtils.isBlank(json)) {
return new HashMap<>();
}
return JsonUtils.parseObject(json, Map.class);
return JsonUtils.parseObject(json, new TypeReference<>() {
});
}
@Override

View File

@ -13,6 +13,7 @@ import cc.iotkit.common.api.PageRequest;
import cc.iotkit.common.api.Paging;
import cc.iotkit.data.manager.IDeviceInfoData;
import cc.iotkit.model.device.DeviceInfo;
import cc.iotkit.model.device.message.DevicePropertyCache;
import cc.iotkit.model.stats.DataItem;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
@ -90,12 +91,12 @@ public class DeviceInfoPropertyDataCache implements IDeviceInfoData {
}
@Override
public void saveProperties(String deviceId, Map<String, Object> properties) {
public void saveProperties(String deviceId, Map<String, DevicePropertyCache> properties) {
deviceInfoData.saveProperties(deviceId, properties);
}
@Override
public Map<String, Object> getProperties(String deviceId) {
public Map<String, DevicePropertyCache> getProperties(String deviceId) {
return deviceInfoData.getProperties(deviceId);
}

View File

@ -10,13 +10,11 @@ import cc.iotkit.data.manager.IDeviceInfoData;
import cc.iotkit.data.manager.IProductData;
import cc.iotkit.data.model.*;
import cc.iotkit.data.util.PageBuilder;
import cc.iotkit.data.util.PredicateBuilder;
import cc.iotkit.model.device.DeviceInfo;
import cc.iotkit.model.device.message.DevicePropertyCache;
import cc.iotkit.model.product.Category;
import cc.iotkit.model.product.Product;
import cc.iotkit.model.stats.DataItem;
import cn.hutool.core.collection.CollectionUtil;
import com.querydsl.core.types.Predicate;
import com.querydsl.core.types.Projections;
import com.querydsl.jpa.impl.JPAQuery;
import com.querydsl.jpa.impl.JPAQueryFactory;
@ -26,15 +24,12 @@ import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Primary;
import org.springframework.data.domain.Page;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.*;
import java.util.stream.Collectors;
import static cc.iotkit.data.model.QTbDeviceGroup.tbDeviceGroup;
import static cc.iotkit.data.model.QTbDeviceGroupMapping.tbDeviceGroupMapping;
import static cc.iotkit.data.model.QTbDeviceInfo.tbDeviceInfo;
import static cc.iotkit.data.model.QTbDeviceSubUser.tbDeviceSubUser;
@ -81,11 +76,11 @@ public class DeviceInfoDataImpl implements IDeviceInfoData, IJPACommData<DeviceI
}
@Override
public void saveProperties(String deviceId, Map<String, Object> properties) {
public void saveProperties(String deviceId, Map<String, DevicePropertyCache> properties) {
}
@Override
public Map<String, Object> getProperties(String deviceId) {
public Map<String, DevicePropertyCache> getProperties(String deviceId) {
return new HashMap<>();
}

View File

@ -11,6 +11,7 @@ package cc.iotkit.temporal;
import cc.iotkit.model.device.message.DeviceProperty;
import cc.iotkit.model.device.message.DevicePropertyCache;
import java.util.List;
import java.util.Map;
@ -27,8 +28,9 @@ public interface IDevicePropertyData {
* @param name
* @param start
* @param end
* @param size
*/
List<DeviceProperty> findDevicePropertyHistory(String deviceId, String name, long start, long end);
List<DeviceProperty> findDevicePropertyHistory(String deviceId, String name, long start, long end, int size);
/**
*
@ -37,6 +39,6 @@ public interface IDevicePropertyData {
* @param properties
* @param time
*/
void addProperties(String deviceId, Map<String, Object> properties, long time);
void addProperties(String deviceId, Map<String, DevicePropertyCache> properties, long time);
}

View File

@ -21,6 +21,7 @@ import org.elasticsearch.search.sort.FieldSortBuilder;
import org.elasticsearch.search.sort.SortOrder;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.data.domain.Pageable;
import org.springframework.data.elasticsearch.core.ElasticsearchRestTemplate;
import org.springframework.data.elasticsearch.core.SearchHits;
import org.springframework.data.elasticsearch.core.document.Document;
@ -44,7 +45,8 @@ public class DevicePropertyDataImpl implements IDevicePropertyData {
private final Set<String> indexSet = new HashSet<>();
public List<DeviceProperty> findDevicePropertyHistory(String deviceId, String name, long start, long end) {
@Override
public List<DeviceProperty> findDevicePropertyHistory(String deviceId, String name, long start, long end, int size) {
String index = getIndex(deviceId, name);
NativeSearchQuery query = new NativeSearchQueryBuilder()
.withQuery(
@ -54,6 +56,7 @@ public class DevicePropertyDataImpl implements IDevicePropertyData {
.from(start, true).to(end, true))
)
.withSorts(new FieldSortBuilder("time").order(SortOrder.ASC))
.withPageable(Pageable.ofSize(size))
.build();
SearchHits<DocDeviceProperty> result = template.search(query, DocDeviceProperty.class, IndexCoordinates.of(index));
return result.getSearchHits().stream()
@ -62,11 +65,11 @@ public class DevicePropertyDataImpl implements IDevicePropertyData {
}
@Override
public void addProperties(String deviceId, Map<String, Object> properties, long time) {
public void addProperties(String deviceId, Map<String, DevicePropertyCache> properties, long time) {
properties.forEach((key, val) -> {
DevicePropertyCache propertyCache = (DevicePropertyCache) val;
String index = getIndex(deviceId, key);
long occurred = Objects.nonNull( propertyCache.getOccurred() )? propertyCache.getOccurred() : time;
long occurred = Objects.nonNull(propertyCache.getOccurred()) ? propertyCache.getOccurred() : time;
template.save(
new DocDeviceProperty(UUID.randomUUID().toString(), deviceId, key, propertyCache.getValue(), occurred),
IndexCoordinates.of(index)

View File

@ -40,7 +40,7 @@ public class RuleLogDataImpl implements IRuleLogData {
@Override
public void deleteByRuleId(String ruleId) {
tsTemplate.update("delete from rule_log where rule_id=?", ruleId);
tsTemplate.update("delete from rule_log where rule_id=? and time<=NOW()", ruleId);
}
@Override

View File

@ -39,7 +39,7 @@ public class TaskLogDataImpl implements ITaskLogData {
@Override
public void deleteByTaskId(String taskId) {
tsTemplate.update("delete from task_log where task_id=?", taskId);
tsTemplate.update("delete from task_log where task_id=? and time<=NOW()", taskId);
}
@Override

View File

@ -13,11 +13,9 @@
<description>
时序数据库服务接口的TDengine实现
支持版本v0.4.1
TDengine版本2.6.0.12
TDengine版本3.x
</description>
<dependencies>
<dependency>
@ -45,7 +43,7 @@
<dependency>
<groupId>com.taosdata.jdbc</groupId>
<artifactId>taos-jdbcdriver</artifactId>
<version>2.0.40</version>
<version>3.2.4</version>
</dependency>
<dependency>

View File

@ -128,6 +128,8 @@ public class DbStructureDataImpl implements IDbStructureData {
@Override
@PostConstruct
public void initDbStructure() {
tdRestApi.execSql("CREATE DATABASEIF NOT EXISTS iotkit KEEP 365 DURATION 10 BUFFER 16 WAL_LEVEL 1;");
//创建规则日志超级表
String sql = TableManager.getCreateSTableSql("rule_log", List.of(
new TdField("state1", "NCHAR", 32),

View File

@ -36,7 +36,8 @@ public class DevicePropertyDataImpl implements IDevicePropertyData {
@Qualifier("deviceInfoDataCache")
private IDeviceInfoData deviceInfoData;
public List<DeviceProperty> findDevicePropertyHistory(String deviceId, String name, long start, long end) {
@Override
public List<DeviceProperty> findDevicePropertyHistory(String deviceId, String name, long start, long end, int size) {
DeviceInfo device = deviceInfoData.findByDeviceId(deviceId);
if (device == null) {
return new ArrayList<>();
@ -44,7 +45,8 @@ public class DevicePropertyDataImpl implements IDevicePropertyData {
String tbName = Constants.getProductPropertySTableName(device.getProductKey());
List<TbDeviceProperty> deviceProperties = tdTemplate.query(String.format(
"select time,%s as value,device_id from %s where device_id=? and time>=? and time<=?",
"select time,%s as `value`,device_id from %s where device_id=? and time>=? and time<=? " +
"order by time asc limit 0," + size,
name.toLowerCase(), tbName),
new BeanPropertyRowMapper<>(TbDeviceProperty.class),
deviceId, start, end
@ -59,20 +61,15 @@ public class DevicePropertyDataImpl implements IDevicePropertyData {
}
@Override
public void addProperties(String deviceId, Map<String, Object> properties, long time) {
public void addProperties(String deviceId, Map<String, DevicePropertyCache> properties, long time) {
DeviceInfo device = deviceInfoData.findByDeviceId(deviceId);
if (device == null) {
return;
}
Map<String, Object> propertiesMap = new HashMap<>();
properties.forEach((key, val) -> {
DevicePropertyCache propertyCache = (DevicePropertyCache) val;
propertiesMap.put(key, propertyCache.getValue());
});
//获取设备旧属性
Map<String, Object> oldProperties = deviceInfoData.getProperties(deviceId);
Map<String, DevicePropertyCache> oldProperties = deviceInfoData.getProperties(deviceId);
//用新属性覆盖
oldProperties.putAll(propertiesMap);
oldProperties.putAll(properties);
StringBuilder sbFieldNames = new StringBuilder();
StringBuilder sbFieldPlaces = new StringBuilder();
@ -84,7 +81,7 @@ public class DevicePropertyDataImpl implements IDevicePropertyData {
sbFieldNames.append(key)
.append(",");
sbFieldPlaces.append("?,");
args.add(val);
args.add(val.getValue());
});
sbFieldNames.deleteCharAt(sbFieldNames.length() - 1);
sbFieldPlaces.deleteCharAt(sbFieldPlaces.length() - 1);

View File

@ -30,7 +30,7 @@ public class RuleLogDataImpl implements IRuleLogData {
@Override
public void deleteByRuleId(String ruleId) {
tdTemplate.update("delete from rule_log where rule_id=?", ruleId);
tdTemplate.update("delete from rule_log where rule_id=? and time<=NOW()", ruleId);
}
@Override

View File

@ -30,7 +30,7 @@ public class TaskLogDataImpl implements ITaskLogData {
@Override
public void deleteByTaskId(String taskId) {
tdTemplate.update("delete from task_log where task_id=?", taskId);
tdTemplate.update("delete from task_log where task_id=? and time<=NOW()", taskId);
}
@Override

View File

@ -1,72 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<parent>
<artifactId>iot-components</artifactId>
<groupId>cc.iotkit</groupId>
<version>${revision}</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>iot-DLT645-component</artifactId>
<build>
<plugins>
<plugin>
<artifactId>maven-shade-plugin</artifactId>
<version>3.2.4</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
</execution>
</executions>
<configuration>
<artifactSet>
<includes>
<include>io.vertx:vertx-web-proxy</include>
<include>io.vertx:vertx-web</include>
<include>io.vertx:vertx-bridge-common</include>
<include>io.vertx:vertx-http-proxy</include>
<include>io.vertx:vertx-core</include>
<include>io.netty:netty-codec-http2</include>
</includes>
</artifactSet>
</configuration>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>11</source>
<target>11</target>
<encoding>utf8</encoding>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.26</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>cc.iotkit</groupId>
<artifactId>iot-component-base</artifactId>
<version>0.4.5-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>cc.iotkit</groupId>
<artifactId>iot-common-core</artifactId>
<version>0.4.5-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>cn.hutool</groupId>
<artifactId>hutool-core</artifactId>
<version>5.8.3</version>
<scope>compile</scope>
</dependency>
</dependencies>
</project>

View File

@ -25,9 +25,9 @@ public class Device {
private String model;
private Map<String, Object> property = new HashMap<>();
private Map<String, ?> property = new HashMap<>();
private Map<String, Object> tag = new HashMap<>();
private Map<String, ?> tag = new HashMap<>();
/**
*

View File

@ -78,7 +78,7 @@ public class DevicePropertyConsumer implements ConsumerHandler<ThingModelMessage
getProperties().stream().collect(Collectors.toMap(
ThingModel.Property::getIdentifier, ThingModel.Property::getDataType));
Map<String, Object> addProperties = new HashMap<>();
Map<String, DevicePropertyCache> addProperties = new HashMap<>();
Long occurred = msg.getOccurred();
//删除非属性字段
properties.forEach((key,val)->{
@ -131,7 +131,7 @@ public class DevicePropertyConsumer implements ConsumerHandler<ThingModelMessage
/**
*
*/
private void updateDeviceCurrentProperties(String deviceId, Map<String, Object> properties) {
private void updateDeviceCurrentProperties(String deviceId, Map<String, DevicePropertyCache> properties) {
try {
log.info("save device property,deviceId:{},property:{}", deviceId, JsonUtils.toJsonString(properties));
deviceInfoData.saveProperties(deviceId, properties);

View File

@ -1,99 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<parent>
<artifactId>iot-components</artifactId>
<groupId>cc.iotkit</groupId>
<version>${revision}</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>iot-component-tcp</artifactId>
<build>
<plugins>
<plugin>
<artifactId>maven-shade-plugin</artifactId>
<version>3.2.4</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
</execution>
</executions>
<configuration>
<artifactSet>
<includes>
<include>io.vertx:vertx-core</include>
</includes>
</artifactSet>
</configuration>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
<forceJavacCompilerUse>true</forceJavacCompilerUse>
<useIncrementalCompilation>false</useIncrementalCompilation>
<encoding>utf8</encoding>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13.2</version>
<scope>test</scope>
<exclusions>
<exclusion>
<artifactId>hamcrest-core</artifactId>
<groupId>org.hamcrest</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>io.projectreactor</groupId>
<artifactId>reactor-core</artifactId>
<version>3.4.29</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.26</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.36</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>cc.iotkit</groupId>
<artifactId>iot-common-core</artifactId>
<version>0.4.5-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>cc.iotkit</groupId>
<artifactId>iot-component-base</artifactId>
<version>0.4.5-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>cc.iotkit</groupId>
<artifactId>iot-data-service</artifactId>
<version>0.4.5-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>cc.iotkit</groupId>
<artifactId>iot-script-engine</artifactId>
<version>0.4.5-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
</dependencies>
</project>

View File

@ -1,92 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<parent>
<artifactId>iot-components</artifactId>
<groupId>cc.iotkit</groupId>
<version>${revision}</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>iot-emqx-component</artifactId>
<build>
<plugins>
<plugin>
<artifactId>maven-shade-plugin</artifactId>
<version>3.2.4</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
</execution>
</executions>
<configuration>
<artifactSet>
<includes>
<include>io.vertx:vertx-core</include>
<include>io.vertx:vertx-web-proxy</include>
<include>io.vertx:vertx-mqtt</include>
<include>io.vertx:vertx-web</include>
<include>io.vertx:vertx-http-proxy</include>
<include>org.luaj:luaj-jse</include>
<include>io.netty:netty-common</include>
<include>io.netty:netty-transport</include>
<include>io.netty:netty-handler</include>
<include>io.netty:netty-resolver</include>
<include>io.netty:netty-buffer</include>
<include>io.netty:netty-handler</include>
<include>io.netty:netty-proxy</include>
<include>io.netty:netty-codec</include>
<include>io.netty:netty-codec-mqtt</include>
<include>io.netty:netty-codec-dns</include>
<include>io.netty:netty-resolver-dns</include>
<include>io.netty:netty-tcnative-boringssl-static</include>
</includes>
</artifactSet>
</configuration>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
<forceJavacCompilerUse>true</forceJavacCompilerUse>
<useIncrementalCompilation>false</useIncrementalCompilation>
<encoding>utf8</encoding>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>cc.iotkit</groupId>
<artifactId>iot-common-model</artifactId>
<version>0.4.5-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>cc.iotkit</groupId>
<artifactId>iot-common-core</artifactId>
<version>0.4.5-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>cc.iotkit</groupId>
<artifactId>iot-component-base</artifactId>
<version>0.4.5-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>cc.iotkit</groupId>
<artifactId>iot-data-service</artifactId>
<version>0.4.5-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>cc.iotkit</groupId>
<artifactId>iot-script-engine</artifactId>
<version>0.4.5-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
</dependencies>
</project>

View File

@ -1,66 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<parent>
<artifactId>iot-components</artifactId>
<groupId>cc.iotkit</groupId>
<version>${revision}</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>iot-http-biz-component</artifactId>
<build>
<plugins>
<plugin>
<artifactId>maven-shade-plugin</artifactId>
<version>3.2.4</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
</execution>
</executions>
<configuration>
<artifactSet>
<includes>
<include>io.vertx:vertx-web-proxy</include>
<include>io.vertx:vertx-web</include>
<include>io.vertx:vertx-bridge-common</include>
<include>io.vertx:vertx-http-proxy</include>
<include>io.vertx:vertx-core</include>
<include>io.netty:netty-codec-http2</include>
</includes>
</artifactSet>
</configuration>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
<encoding>utf8</encoding>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.26</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>cc.iotkit</groupId>
<artifactId>iot-component-base</artifactId>
<version>0.4.5-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>cc.iotkit</groupId>
<artifactId>iot-script-engine</artifactId>
<version>0.4.5-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
</dependencies>
</project>

View File

@ -1,84 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<parent>
<artifactId>iot-components</artifactId>
<groupId>cc.iotkit</groupId>
<version>${revision}</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>iot-mqtt-component</artifactId>
<build>
<plugins>
<plugin>
<artifactId>maven-shade-plugin</artifactId>
<version>3.2.4</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
</execution>
</executions>
<configuration>
<artifactSet>
<includes>
<include>io.vertx:vertx-core</include>
<include>io.vertx:vertx-mqtt</include>
<include>io.netty:netty-codec-mqtt</include>
<include>org.luaj:luaj-jse</include>
</includes>
</artifactSet>
</configuration>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
<forceJavacCompilerUse>true</forceJavacCompilerUse>
<useIncrementalCompilation>false</useIncrementalCompilation>
<encoding>utf8</encoding>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.26</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.36</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>cc.iotkit</groupId>
<artifactId>iot-common-core</artifactId>
<version>0.4.5-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>cc.iotkit</groupId>
<artifactId>iot-component-base</artifactId>
<version>0.4.5-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>cc.iotkit</groupId>
<artifactId>iot-data-service</artifactId>
<version>0.4.5-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>cc.iotkit</groupId>
<artifactId>iot-script-engine</artifactId>
<version>0.4.5-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
</dependencies>
</project>

View File

@ -1,84 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<parent>
<artifactId>iot-components</artifactId>
<groupId>cc.iotkit</groupId>
<version>${revision}</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>iot-nb-component</artifactId>
<build>
<plugins>
<plugin>
<artifactId>maven-shade-plugin</artifactId>
<version>3.2.4</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
</execution>
</executions>
<configuration>
<artifactSet>
<includes>
<include>io.vertx:vertx-core</include>
<include>io.vertx:vertx-mqtt</include>
<include>io.netty:netty-codec-mqtt</include>
<include>org.luaj:luaj-jse</include>
</includes>
</artifactSet>
</configuration>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
<forceJavacCompilerUse>true</forceJavacCompilerUse>
<useIncrementalCompilation>false</useIncrementalCompilation>
<encoding>utf8</encoding>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.26</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.36</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>cc.iotkit</groupId>
<artifactId>iot-common-core</artifactId>
<version>0.4.5-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>cc.iotkit</groupId>
<artifactId>iot-component-base</artifactId>
<version>0.4.5-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>cc.iotkit</groupId>
<artifactId>iot-data-service</artifactId>
<version>0.4.5-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>cc.iotkit</groupId>
<artifactId>iot-script-engine</artifactId>
<version>0.4.5-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
</dependencies>
</project>

View File

@ -1,70 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<parent>
<artifactId>iot-components</artifactId>
<groupId>cc.iotkit</groupId>
<version>${revision}</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>iot-websocket-component</artifactId>
<build>
<plugins>
<plugin>
<artifactId>maven-shade-plugin</artifactId>
<version>3.2.4</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
</execution>
</executions>
<configuration>
<artifactSet>
<includes>
<include>io.vertx:vertx-core</include>
<include>org.luaj:luaj-jse</include>
</includes>
</artifactSet>
</configuration>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
<forceJavacCompilerUse>true</forceJavacCompilerUse>
<useIncrementalCompilation>false</useIncrementalCompilation>
<encoding>utf8</encoding>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.26</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>cc.iotkit</groupId>
<artifactId>iot-common-core</artifactId>
<version>0.4.5-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.36</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>cc.iotkit</groupId>
<artifactId>iot-component-base</artifactId>
<version>0.4.5-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
</dependencies>
</project>

View File

@ -153,7 +153,7 @@ public class DeviceController {
return deviceServiceImpl.logs(request);
}
@ApiOperation("设备属性日志")
@ApiOperation("获取设备属性历史数据")
@SaCheckPermission("iot:deviceLog:query")
@PostMapping("/deviceProperty/log/list")
public List<DeviceProperty> getPropertyHistory(@Validated @RequestBody
@ -163,7 +163,7 @@ public class DeviceController {
String name = data.getName();
long start = data.getStart();
long end = data.getEnd();
return deviceServiceImpl.getPropertyHistory(deviceId, name, start, end);
return deviceServiceImpl.getPropertyHistory(deviceId, name, start, end, 10000);
}
@ApiOperation("设备解绑")

View File

@ -68,7 +68,7 @@ public class SpaceDeviceVo {
/**
*
*/
private Map<String, Object> property = new HashMap<>();
private Map<String, ?> property = new HashMap<>();
/**
* key

View File

@ -260,7 +260,6 @@ public class ExampleDataInit implements SmartInitializingSingleton {
initData("sys_oper_log", sysOperLogData, new TypeReference<List<SysOperLog>>() {
});
initData("sys_oss", sysOssData, new TypeReference<List<SysOss>>() {
});
@ -294,7 +293,8 @@ public class ExampleDataInit implements SmartInitializingSingleton {
});
}
private <T> T initData(String name, ICommonData service, TypeReference<T> type) throws IOException {
private <T> T initData(String name, ICommonData service, TypeReference<T> type) {
try {
log.info("init {} data...", name);
if (service.count() > 0) {
new RuntimeException("原数据库已存在" + name + "的旧数据,请清除后再重新初始化!").printStackTrace();
@ -306,6 +306,10 @@ public class ExampleDataInit implements SmartInitializingSingleton {
service.save((Id) obj);
}
return (T) list;
} catch (Exception e) {
log.error("initData error", e);
return null;
}
}
}

View File

@ -46,7 +46,7 @@ public interface IDeviceService {
Paging<ThingModelMessage> logs(PageRequest<DeviceLogQueryBo> request);
List<DeviceProperty> getPropertyHistory(String deviceId, String name, long start, long end);
List<DeviceProperty> getPropertyHistory(String deviceId, String name, long start, long end,int size);
boolean unbindDevice(String data);

View File

@ -141,7 +141,7 @@ public class DeviceServiceImpl implements IDeviceService {
device.setDeviceName(deviceName);
device.setSecret(secret.toString());
device.setState(new DeviceInfo.State(false, null, null));
device.setLocate(new DeviceInfo.Locate(deviceInfo.getLongitude(),deviceInfo.getLatitude()));
device.setLocate(new DeviceInfo.Locate(deviceInfo.getLongitude(), deviceInfo.getLatitude()));
device.setCreateAt(System.currentTimeMillis());
if (StringUtils.isNotBlank(parentId)) {
device.setParentId(parentId);
@ -168,7 +168,7 @@ public class DeviceServiceImpl implements IDeviceService {
if (!AuthUtil.isAdmin()) {
uid = AuthUtil.getUserId();
}
List<DeviceInfo> ret=deviceInfoData.findByProductNodeType(uid);
List<DeviceInfo> ret = deviceInfoData.findByProductNodeType(uid);
if (!ret.isEmpty()) {
pdv = ret.stream().map(r -> ParentDeviceVo.builder().id(r.getId()).deviceName(r.getDeviceName()).build()).collect(Collectors.toList());
}
@ -211,8 +211,8 @@ public class DeviceServiceImpl implements IDeviceService {
}
@Override
public List<DeviceProperty> getPropertyHistory(String deviceId, String name, long start, long end) {
return devicePropertyData.findDevicePropertyHistory(deviceId, name, start, end);
public List<DeviceProperty> getPropertyHistory(String deviceId, String name, long start, long end, int size) {
return devicePropertyData.findDevicePropertyHistory(deviceId, name, start, end, size);
}
@Override
@ -412,15 +412,15 @@ public class DeviceServiceImpl implements IDeviceService {
@Override
public boolean saveDevice(DeviceInfoBo data) {
DeviceInfo di=data.to(DeviceInfo.class);
di.setLocate(new DeviceInfo.Locate(data.getLongitude(),data.getLatitude()));
DeviceInfo di = data.to(DeviceInfo.class);
di.setLocate(new DeviceInfo.Locate(data.getLongitude(), data.getLatitude()));
di.setState(data.getState());
//同产品不可重复设备名
DeviceInfo deviceRepetition = deviceInfoData.findByProductKeyAndDeviceName(data.getProductKey(), data.getDeviceName());
if (deviceRepetition != null && !deviceRepetition.getDeviceId().equals(di.getDeviceId())) {
throw new BizException(ErrCode.MODEL_DEVICE_ALREADY);
}
return deviceInfoData.save(di)!=null;
return deviceInfoData.save(di) != null;
}

View File

@ -118,7 +118,7 @@ public class OpenDeviceServiceImpl implements OpenDeviceService {
DeviceInfo deviceInfo = deviceInfoData.findByProductKeyAndDeviceName(bo.getProductKey(), bo.getDeviceName());
List<OpenPropertyVo> openPropertyVos = new ArrayList<>();
if (propertyVo != null){
Map<String, Object> properties = deviceInfoData.getProperties(deviceInfo.getDeviceId());
Map<String, ?> properties = deviceInfoData.getProperties(deviceInfo.getDeviceId());
for (ThingModel.Property property : propertyVo.getModel().getProperties()) {
OpenPropertyVo openPropertyVo = new OpenPropertyVo(property.getIdentifier(), property.getDataType(), property.getName(), property.getAccessMode(), property.getDescription(), property.getUnit());
Map<String,Object> map = (Map<String, Object>) properties.get(openPropertyVo.getIdentifier());

View File

@ -54,7 +54,7 @@ public class DeviceCondition {
}
Object left = null;
if ("property".equals(type)) {
Map<String, Object> properties = deviceInfo.getProperty();
Map<String, ?> properties = deviceInfo.getProperty();
left = properties.get(identifier);
} else if ("state".equals(type)) {
DeviceInfo.State state = deviceInfo.getState();

BIN
iot-starter/.DS_Store vendored

Binary file not shown.

View File

@ -92,7 +92,7 @@
<!-- </dependency>-->
<!--打开注释 启用tdengine数据库-->
<!-- <dependency>-->
<!-- <dependency>-->
<!-- <groupId>cc.iotkit</groupId>-->
<!-- <artifactId>iot-temproal-serviceImpl-td</artifactId>-->
<!-- </dependency>-->

View File

@ -88,25 +88,24 @@ spring:
# ============mysql配置结束============>>
#<<================es时序数据配置开始===============
elasticsearch:
rest:
#使用内置es的配置
#uris: http://elasticsearch:9200
uris: http://127.0.0.1:9200
username:
password:
connection-timeout: 10s
# elasticsearch:
# rest:
# #使用内置es的配置
# #uris: http://elasticsearch:9200
# uris: http://127.0.0.1:9200
# username:
# password:
# connection-timeout: 10s
#================es时序数据配置结束===============>>
#<<===========tdengine时序数据库配置开始============
# td-datasource:
# url: jdbc:TAOS-RS://127.0.0.1:6041/iotkit?timezone=UTC-8&charset=UTF-8&locale=en_US.UTF-8
# username: root
# password: taosdata
# driverClassName: com.taosdata.jdbc.rs.RestfulDriver
td-datasource:
url: jdbc:TAOS-RS://127.0.0.1:6041/iotkit?timezone=UTC-8&charset=UTF-8&locale=en_US.UTF-8
username: root
password: taosdata
driverClassName: com.taosdata.jdbc.rs.RestfulDriver
#===========tdengine时序数据库配置开始============>>
redis:
#使用内置redis的配置
#host: redis