feat:td3.0支持调整
parent
162c18b9c6
commit
def1852011
|
@ -28,3 +28,6 @@ data/elasticsearch
|
||||||
.init
|
.init
|
||||||
*.db
|
*.db
|
||||||
.flattened-pom.xml
|
.flattened-pom.xml
|
||||||
|
|
||||||
|
.DS_Store
|
||||||
|
dependency-reduced-pom.xml
|
||||||
|
|
|
@ -72,7 +72,7 @@ public class DeviceInfo implements Owned<String> {
|
||||||
/**
|
/**
|
||||||
* 设备属性
|
* 设备属性
|
||||||
*/
|
*/
|
||||||
private Map<String, Object> property = new HashMap<>();
|
private Map<String, ?> property = new HashMap<>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 设备标签
|
* 设备标签
|
||||||
|
|
|
@ -21,10 +21,14 @@ import java.util.Map;
|
||||||
public class DevicePropertyCache {
|
public class DevicePropertyCache {
|
||||||
|
|
||||||
|
|
||||||
// 属性值
|
/**
|
||||||
|
* 属性值
|
||||||
|
*/
|
||||||
private Object value;
|
private Object value;
|
||||||
|
|
||||||
// 属性值时间: 设备上报时间
|
/**
|
||||||
|
* 属性值时间: 设备上报时间
|
||||||
|
*/
|
||||||
private Long occurred;
|
private Long occurred;
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -12,6 +12,7 @@ package cc.iotkit.data.manager;
|
||||||
import cc.iotkit.common.api.Paging;
|
import cc.iotkit.common.api.Paging;
|
||||||
import cc.iotkit.data.IOwnedData;
|
import cc.iotkit.data.IOwnedData;
|
||||||
import cc.iotkit.model.device.DeviceInfo;
|
import cc.iotkit.model.device.DeviceInfo;
|
||||||
|
import cc.iotkit.model.device.message.DevicePropertyCache;
|
||||||
import cc.iotkit.model.stats.DataItem;
|
import cc.iotkit.model.stats.DataItem;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -25,14 +26,14 @@ public interface IDeviceInfoData extends IOwnedData<DeviceInfo, String> {
|
||||||
* @param deviceId 设备id
|
* @param deviceId 设备id
|
||||||
* @param properties 设备属性map
|
* @param properties 设备属性map
|
||||||
*/
|
*/
|
||||||
void saveProperties(String deviceId, Map<String, Object> properties);
|
void saveProperties(String deviceId, Map<String, DevicePropertyCache> properties);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取设备属性map
|
* 获取设备属性map
|
||||||
*
|
*
|
||||||
* @param deviceId 设备id
|
* @param deviceId 设备id
|
||||||
*/
|
*/
|
||||||
Map<String, Object> getProperties(String deviceId);
|
Map<String, DevicePropertyCache> getProperties(String deviceId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据设备ID取设备信息
|
* 根据设备ID取设备信息
|
||||||
|
|
|
@ -17,7 +17,9 @@ import cc.iotkit.data.cache.DeviceInfoCacheEvict;
|
||||||
import cc.iotkit.data.cache.DeviceInfoCachePut;
|
import cc.iotkit.data.cache.DeviceInfoCachePut;
|
||||||
import cc.iotkit.data.manager.IDeviceInfoData;
|
import cc.iotkit.data.manager.IDeviceInfoData;
|
||||||
import cc.iotkit.model.device.DeviceInfo;
|
import cc.iotkit.model.device.DeviceInfo;
|
||||||
|
import cc.iotkit.model.device.message.DevicePropertyCache;
|
||||||
import cc.iotkit.model.stats.DataItem;
|
import cc.iotkit.model.stats.DataItem;
|
||||||
|
import com.fasterxml.jackson.core.type.TypeReference;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.springframework.beans.factory.SmartInitializingSingleton;
|
import org.springframework.beans.factory.SmartInitializingSingleton;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
@ -91,8 +93,8 @@ public class DeviceInfoDataCache implements IDeviceInfoData, SmartInitializingSi
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void saveProperties(String deviceId, Map<String, Object> properties) {
|
public void saveProperties(String deviceId, Map<String, DevicePropertyCache> properties) {
|
||||||
Map<String, Object> old = getProperties(deviceId);
|
Map<String, DevicePropertyCache> old = getProperties(deviceId);
|
||||||
old.putAll(properties);
|
old.putAll(properties);
|
||||||
redisTemplate.opsForValue().set(getPropertyCacheKey(deviceId), JsonUtils.toJsonString(old));
|
redisTemplate.opsForValue().set(getPropertyCacheKey(deviceId), JsonUtils.toJsonString(old));
|
||||||
}
|
}
|
||||||
|
@ -105,12 +107,13 @@ public class DeviceInfoDataCache implements IDeviceInfoData, SmartInitializingSi
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map<String, Object> getProperties(String deviceId) {
|
public Map<String, DevicePropertyCache> getProperties(String deviceId) {
|
||||||
String json = redisTemplate.opsForValue().get(getPropertyCacheKey(deviceId));
|
String json = redisTemplate.opsForValue().get(getPropertyCacheKey(deviceId));
|
||||||
if (StringUtils.isBlank(json)) {
|
if (StringUtils.isBlank(json)) {
|
||||||
return new HashMap<>();
|
return new HashMap<>();
|
||||||
}
|
}
|
||||||
return JsonUtils.parseObject(json, Map.class);
|
return JsonUtils.parseObject(json, new TypeReference<>() {
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -13,6 +13,7 @@ import cc.iotkit.common.api.PageRequest;
|
||||||
import cc.iotkit.common.api.Paging;
|
import cc.iotkit.common.api.Paging;
|
||||||
import cc.iotkit.data.manager.IDeviceInfoData;
|
import cc.iotkit.data.manager.IDeviceInfoData;
|
||||||
import cc.iotkit.model.device.DeviceInfo;
|
import cc.iotkit.model.device.DeviceInfo;
|
||||||
|
import cc.iotkit.model.device.message.DevicePropertyCache;
|
||||||
import cc.iotkit.model.stats.DataItem;
|
import cc.iotkit.model.stats.DataItem;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.beans.factory.annotation.Qualifier;
|
import org.springframework.beans.factory.annotation.Qualifier;
|
||||||
|
@ -90,12 +91,12 @@ public class DeviceInfoPropertyDataCache implements IDeviceInfoData {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void saveProperties(String deviceId, Map<String, Object> properties) {
|
public void saveProperties(String deviceId, Map<String, DevicePropertyCache> properties) {
|
||||||
deviceInfoData.saveProperties(deviceId, properties);
|
deviceInfoData.saveProperties(deviceId, properties);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map<String, Object> getProperties(String deviceId) {
|
public Map<String, DevicePropertyCache> getProperties(String deviceId) {
|
||||||
return deviceInfoData.getProperties(deviceId);
|
return deviceInfoData.getProperties(deviceId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,13 +10,11 @@ import cc.iotkit.data.manager.IDeviceInfoData;
|
||||||
import cc.iotkit.data.manager.IProductData;
|
import cc.iotkit.data.manager.IProductData;
|
||||||
import cc.iotkit.data.model.*;
|
import cc.iotkit.data.model.*;
|
||||||
import cc.iotkit.data.util.PageBuilder;
|
import cc.iotkit.data.util.PageBuilder;
|
||||||
import cc.iotkit.data.util.PredicateBuilder;
|
|
||||||
import cc.iotkit.model.device.DeviceInfo;
|
import cc.iotkit.model.device.DeviceInfo;
|
||||||
|
import cc.iotkit.model.device.message.DevicePropertyCache;
|
||||||
import cc.iotkit.model.product.Category;
|
import cc.iotkit.model.product.Category;
|
||||||
import cc.iotkit.model.product.Product;
|
import cc.iotkit.model.product.Product;
|
||||||
import cc.iotkit.model.stats.DataItem;
|
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.core.types.Projections;
|
||||||
import com.querydsl.jpa.impl.JPAQuery;
|
import com.querydsl.jpa.impl.JPAQuery;
|
||||||
import com.querydsl.jpa.impl.JPAQueryFactory;
|
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.context.annotation.Primary;
|
||||||
import org.springframework.data.domain.Page;
|
import org.springframework.data.domain.Page;
|
||||||
import org.springframework.data.jpa.repository.JpaRepository;
|
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.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.stream.Collectors;
|
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.QTbDeviceGroupMapping.tbDeviceGroupMapping;
|
||||||
import static cc.iotkit.data.model.QTbDeviceInfo.tbDeviceInfo;
|
import static cc.iotkit.data.model.QTbDeviceInfo.tbDeviceInfo;
|
||||||
import static cc.iotkit.data.model.QTbDeviceSubUser.tbDeviceSubUser;
|
import static cc.iotkit.data.model.QTbDeviceSubUser.tbDeviceSubUser;
|
||||||
|
@ -81,11 +76,11 @@ public class DeviceInfoDataImpl implements IDeviceInfoData, IJPACommData<DeviceI
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void saveProperties(String deviceId, Map<String, Object> properties) {
|
public void saveProperties(String deviceId, Map<String, DevicePropertyCache> properties) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map<String, Object> getProperties(String deviceId) {
|
public Map<String, DevicePropertyCache> getProperties(String deviceId) {
|
||||||
return new HashMap<>();
|
return new HashMap<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -11,6 +11,7 @@ package cc.iotkit.temporal;
|
||||||
|
|
||||||
|
|
||||||
import cc.iotkit.model.device.message.DeviceProperty;
|
import cc.iotkit.model.device.message.DeviceProperty;
|
||||||
|
import cc.iotkit.model.device.message.DevicePropertyCache;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
@ -27,8 +28,9 @@ public interface IDevicePropertyData {
|
||||||
* @param name 属性名称
|
* @param name 属性名称
|
||||||
* @param start 开始时间戳
|
* @param start 开始时间戳
|
||||||
* @param end 结束时间戳
|
* @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 properties 属性
|
||||||
* @param time 属性上报时间
|
* @param time 属性上报时间
|
||||||
*/
|
*/
|
||||||
void addProperties(String deviceId, Map<String, Object> properties, long time);
|
void addProperties(String deviceId, Map<String, DevicePropertyCache> properties, long time);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,6 +21,7 @@ import org.elasticsearch.search.sort.FieldSortBuilder;
|
||||||
import org.elasticsearch.search.sort.SortOrder;
|
import org.elasticsearch.search.sort.SortOrder;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.beans.factory.annotation.Qualifier;
|
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.ElasticsearchRestTemplate;
|
||||||
import org.springframework.data.elasticsearch.core.SearchHits;
|
import org.springframework.data.elasticsearch.core.SearchHits;
|
||||||
import org.springframework.data.elasticsearch.core.document.Document;
|
import org.springframework.data.elasticsearch.core.document.Document;
|
||||||
|
@ -44,7 +45,8 @@ public class DevicePropertyDataImpl implements IDevicePropertyData {
|
||||||
|
|
||||||
private final Set<String> indexSet = new HashSet<>();
|
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);
|
String index = getIndex(deviceId, name);
|
||||||
NativeSearchQuery query = new NativeSearchQueryBuilder()
|
NativeSearchQuery query = new NativeSearchQueryBuilder()
|
||||||
.withQuery(
|
.withQuery(
|
||||||
|
@ -54,6 +56,7 @@ public class DevicePropertyDataImpl implements IDevicePropertyData {
|
||||||
.from(start, true).to(end, true))
|
.from(start, true).to(end, true))
|
||||||
)
|
)
|
||||||
.withSorts(new FieldSortBuilder("time").order(SortOrder.ASC))
|
.withSorts(new FieldSortBuilder("time").order(SortOrder.ASC))
|
||||||
|
.withPageable(Pageable.ofSize(size))
|
||||||
.build();
|
.build();
|
||||||
SearchHits<DocDeviceProperty> result = template.search(query, DocDeviceProperty.class, IndexCoordinates.of(index));
|
SearchHits<DocDeviceProperty> result = template.search(query, DocDeviceProperty.class, IndexCoordinates.of(index));
|
||||||
return result.getSearchHits().stream()
|
return result.getSearchHits().stream()
|
||||||
|
@ -62,11 +65,11 @@ public class DevicePropertyDataImpl implements IDevicePropertyData {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@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) -> {
|
properties.forEach((key, val) -> {
|
||||||
DevicePropertyCache propertyCache = (DevicePropertyCache) val;
|
DevicePropertyCache propertyCache = (DevicePropertyCache) val;
|
||||||
String index = getIndex(deviceId, key);
|
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(
|
template.save(
|
||||||
new DocDeviceProperty(UUID.randomUUID().toString(), deviceId, key, propertyCache.getValue(), occurred),
|
new DocDeviceProperty(UUID.randomUUID().toString(), deviceId, key, propertyCache.getValue(), occurred),
|
||||||
IndexCoordinates.of(index)
|
IndexCoordinates.of(index)
|
||||||
|
|
|
@ -40,7 +40,7 @@ public class RuleLogDataImpl implements IRuleLogData {
|
||||||
@Override
|
@Override
|
||||||
public void deleteByRuleId(String ruleId) {
|
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
|
@Override
|
||||||
|
|
|
@ -39,7 +39,7 @@ public class TaskLogDataImpl implements ITaskLogData {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void deleteByTaskId(String taskId) {
|
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
|
@Override
|
||||||
|
|
|
@ -13,11 +13,9 @@
|
||||||
|
|
||||||
<description>
|
<description>
|
||||||
时序数据库服务接口的TDengine实现
|
时序数据库服务接口的TDengine实现
|
||||||
支持版本:v0.4.1
|
TDengine版本:3.x
|
||||||
TDengine版本:2.6.0.12
|
|
||||||
</description>
|
</description>
|
||||||
|
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
|
@ -45,7 +43,7 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.taosdata.jdbc</groupId>
|
<groupId>com.taosdata.jdbc</groupId>
|
||||||
<artifactId>taos-jdbcdriver</artifactId>
|
<artifactId>taos-jdbcdriver</artifactId>
|
||||||
<version>2.0.40</version>
|
<version>3.2.4</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
|
|
|
@ -128,6 +128,8 @@ public class DbStructureDataImpl implements IDbStructureData {
|
||||||
@Override
|
@Override
|
||||||
@PostConstruct
|
@PostConstruct
|
||||||
public void initDbStructure() {
|
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(
|
String sql = TableManager.getCreateSTableSql("rule_log", List.of(
|
||||||
new TdField("state1", "NCHAR", 32),
|
new TdField("state1", "NCHAR", 32),
|
||||||
|
|
|
@ -36,7 +36,8 @@ public class DevicePropertyDataImpl implements IDevicePropertyData {
|
||||||
@Qualifier("deviceInfoDataCache")
|
@Qualifier("deviceInfoDataCache")
|
||||||
private IDeviceInfoData deviceInfoData;
|
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);
|
DeviceInfo device = deviceInfoData.findByDeviceId(deviceId);
|
||||||
if (device == null) {
|
if (device == null) {
|
||||||
return new ArrayList<>();
|
return new ArrayList<>();
|
||||||
|
@ -44,7 +45,8 @@ public class DevicePropertyDataImpl implements IDevicePropertyData {
|
||||||
|
|
||||||
String tbName = Constants.getProductPropertySTableName(device.getProductKey());
|
String tbName = Constants.getProductPropertySTableName(device.getProductKey());
|
||||||
List<TbDeviceProperty> deviceProperties = tdTemplate.query(String.format(
|
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),
|
name.toLowerCase(), tbName),
|
||||||
new BeanPropertyRowMapper<>(TbDeviceProperty.class),
|
new BeanPropertyRowMapper<>(TbDeviceProperty.class),
|
||||||
deviceId, start, end
|
deviceId, start, end
|
||||||
|
@ -59,20 +61,15 @@ public class DevicePropertyDataImpl implements IDevicePropertyData {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@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);
|
DeviceInfo device = deviceInfoData.findByDeviceId(deviceId);
|
||||||
if (device == null) {
|
if (device == null) {
|
||||||
return;
|
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 sbFieldNames = new StringBuilder();
|
||||||
StringBuilder sbFieldPlaces = new StringBuilder();
|
StringBuilder sbFieldPlaces = new StringBuilder();
|
||||||
|
@ -84,7 +81,7 @@ public class DevicePropertyDataImpl implements IDevicePropertyData {
|
||||||
sbFieldNames.append(key)
|
sbFieldNames.append(key)
|
||||||
.append(",");
|
.append(",");
|
||||||
sbFieldPlaces.append("?,");
|
sbFieldPlaces.append("?,");
|
||||||
args.add(val);
|
args.add(val.getValue());
|
||||||
});
|
});
|
||||||
sbFieldNames.deleteCharAt(sbFieldNames.length() - 1);
|
sbFieldNames.deleteCharAt(sbFieldNames.length() - 1);
|
||||||
sbFieldPlaces.deleteCharAt(sbFieldPlaces.length() - 1);
|
sbFieldPlaces.deleteCharAt(sbFieldPlaces.length() - 1);
|
||||||
|
|
|
@ -30,7 +30,7 @@ public class RuleLogDataImpl implements IRuleLogData {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void deleteByRuleId(String ruleId) {
|
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
|
@Override
|
||||||
|
|
|
@ -30,7 +30,7 @@ public class TaskLogDataImpl implements ITaskLogData {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void deleteByTaskId(String taskId) {
|
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
|
@Override
|
||||||
|
|
|
@ -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>
|
|
|
@ -25,9 +25,9 @@ public class Device {
|
||||||
|
|
||||||
private String model;
|
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<>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 是否透传
|
* 是否透传
|
||||||
|
|
|
@ -78,7 +78,7 @@ public class DevicePropertyConsumer implements ConsumerHandler<ThingModelMessage
|
||||||
getProperties().stream().collect(Collectors.toMap(
|
getProperties().stream().collect(Collectors.toMap(
|
||||||
ThingModel.Property::getIdentifier, ThingModel.Property::getDataType));
|
ThingModel.Property::getIdentifier, ThingModel.Property::getDataType));
|
||||||
|
|
||||||
Map<String, Object> addProperties = new HashMap<>();
|
Map<String, DevicePropertyCache> addProperties = new HashMap<>();
|
||||||
Long occurred = msg.getOccurred();
|
Long occurred = msg.getOccurred();
|
||||||
//删除非属性字段
|
//删除非属性字段
|
||||||
properties.forEach((key,val)->{
|
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 {
|
try {
|
||||||
log.info("save device property,deviceId:{},property:{}", deviceId, JsonUtils.toJsonString(properties));
|
log.info("save device property,deviceId:{},property:{}", deviceId, JsonUtils.toJsonString(properties));
|
||||||
deviceInfoData.saveProperties(deviceId, properties);
|
deviceInfoData.saveProperties(deviceId, properties);
|
||||||
|
|
|
@ -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>
|
|
|
@ -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>
|
|
|
@ -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>
|
|
|
@ -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>
|
|
|
@ -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>
|
|
|
@ -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>
|
|
|
@ -153,7 +153,7 @@ public class DeviceController {
|
||||||
return deviceServiceImpl.logs(request);
|
return deviceServiceImpl.logs(request);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiOperation("设备属性日志")
|
@ApiOperation("获取设备属性历史数据")
|
||||||
@SaCheckPermission("iot:deviceLog:query")
|
@SaCheckPermission("iot:deviceLog:query")
|
||||||
@PostMapping("/deviceProperty/log/list")
|
@PostMapping("/deviceProperty/log/list")
|
||||||
public List<DeviceProperty> getPropertyHistory(@Validated @RequestBody
|
public List<DeviceProperty> getPropertyHistory(@Validated @RequestBody
|
||||||
|
@ -163,7 +163,7 @@ public class DeviceController {
|
||||||
String name = data.getName();
|
String name = data.getName();
|
||||||
long start = data.getStart();
|
long start = data.getStart();
|
||||||
long end = data.getEnd();
|
long end = data.getEnd();
|
||||||
return deviceServiceImpl.getPropertyHistory(deviceId, name, start, end);
|
return deviceServiceImpl.getPropertyHistory(deviceId, name, start, end, 10000);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiOperation("设备解绑")
|
@ApiOperation("设备解绑")
|
||||||
|
|
|
@ -68,7 +68,7 @@ public class SpaceDeviceVo {
|
||||||
/**
|
/**
|
||||||
* 设备属性
|
* 设备属性
|
||||||
*/
|
*/
|
||||||
private Map<String, Object> property = new HashMap<>();
|
private Map<String, ?> property = new HashMap<>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 产品key
|
* 产品key
|
||||||
|
|
|
@ -260,7 +260,6 @@ public class ExampleDataInit implements SmartInitializingSingleton {
|
||||||
initData("sys_oper_log", sysOperLogData, new TypeReference<List<SysOperLog>>() {
|
initData("sys_oper_log", sysOperLogData, new TypeReference<List<SysOperLog>>() {
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
initData("sys_oss", sysOssData, new TypeReference<List<SysOss>>() {
|
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);
|
log.info("init {} data...", name);
|
||||||
if (service.count() > 0) {
|
if (service.count() > 0) {
|
||||||
new RuntimeException("原数据库已存在" + name + "的旧数据,请清除后再重新初始化!").printStackTrace();
|
new RuntimeException("原数据库已存在" + name + "的旧数据,请清除后再重新初始化!").printStackTrace();
|
||||||
|
@ -306,6 +306,10 @@ public class ExampleDataInit implements SmartInitializingSingleton {
|
||||||
service.save((Id) obj);
|
service.save((Id) obj);
|
||||||
}
|
}
|
||||||
return (T) list;
|
return (T) list;
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("initData error", e);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,7 +46,7 @@ public interface IDeviceService {
|
||||||
|
|
||||||
Paging<ThingModelMessage> logs(PageRequest<DeviceLogQueryBo> request);
|
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);
|
boolean unbindDevice(String data);
|
||||||
|
|
||||||
|
|
|
@ -141,7 +141,7 @@ public class DeviceServiceImpl implements IDeviceService {
|
||||||
device.setDeviceName(deviceName);
|
device.setDeviceName(deviceName);
|
||||||
device.setSecret(secret.toString());
|
device.setSecret(secret.toString());
|
||||||
device.setState(new DeviceInfo.State(false, null, null));
|
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());
|
device.setCreateAt(System.currentTimeMillis());
|
||||||
if (StringUtils.isNotBlank(parentId)) {
|
if (StringUtils.isNotBlank(parentId)) {
|
||||||
device.setParentId(parentId);
|
device.setParentId(parentId);
|
||||||
|
@ -168,7 +168,7 @@ public class DeviceServiceImpl implements IDeviceService {
|
||||||
if (!AuthUtil.isAdmin()) {
|
if (!AuthUtil.isAdmin()) {
|
||||||
uid = AuthUtil.getUserId();
|
uid = AuthUtil.getUserId();
|
||||||
}
|
}
|
||||||
List<DeviceInfo> ret=deviceInfoData.findByProductNodeType(uid);
|
List<DeviceInfo> ret = deviceInfoData.findByProductNodeType(uid);
|
||||||
if (!ret.isEmpty()) {
|
if (!ret.isEmpty()) {
|
||||||
pdv = ret.stream().map(r -> ParentDeviceVo.builder().id(r.getId()).deviceName(r.getDeviceName()).build()).collect(Collectors.toList());
|
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
|
@Override
|
||||||
public List<DeviceProperty> getPropertyHistory(String deviceId, String name, long start, long end) {
|
public List<DeviceProperty> getPropertyHistory(String deviceId, String name, long start, long end, int size) {
|
||||||
return devicePropertyData.findDevicePropertyHistory(deviceId, name, start, end);
|
return devicePropertyData.findDevicePropertyHistory(deviceId, name, start, end, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -412,15 +412,15 @@ public class DeviceServiceImpl implements IDeviceService {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean saveDevice(DeviceInfoBo data) {
|
public boolean saveDevice(DeviceInfoBo data) {
|
||||||
DeviceInfo di=data.to(DeviceInfo.class);
|
DeviceInfo di = data.to(DeviceInfo.class);
|
||||||
di.setLocate(new DeviceInfo.Locate(data.getLongitude(),data.getLatitude()));
|
di.setLocate(new DeviceInfo.Locate(data.getLongitude(), data.getLatitude()));
|
||||||
di.setState(data.getState());
|
di.setState(data.getState());
|
||||||
//同产品不可重复设备名
|
//同产品不可重复设备名
|
||||||
DeviceInfo deviceRepetition = deviceInfoData.findByProductKeyAndDeviceName(data.getProductKey(), data.getDeviceName());
|
DeviceInfo deviceRepetition = deviceInfoData.findByProductKeyAndDeviceName(data.getProductKey(), data.getDeviceName());
|
||||||
if (deviceRepetition != null && !deviceRepetition.getDeviceId().equals(di.getDeviceId())) {
|
if (deviceRepetition != null && !deviceRepetition.getDeviceId().equals(di.getDeviceId())) {
|
||||||
throw new BizException(ErrCode.MODEL_DEVICE_ALREADY);
|
throw new BizException(ErrCode.MODEL_DEVICE_ALREADY);
|
||||||
}
|
}
|
||||||
return deviceInfoData.save(di)!=null;
|
return deviceInfoData.save(di) != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -118,7 +118,7 @@ public class OpenDeviceServiceImpl implements OpenDeviceService {
|
||||||
DeviceInfo deviceInfo = deviceInfoData.findByProductKeyAndDeviceName(bo.getProductKey(), bo.getDeviceName());
|
DeviceInfo deviceInfo = deviceInfoData.findByProductKeyAndDeviceName(bo.getProductKey(), bo.getDeviceName());
|
||||||
List<OpenPropertyVo> openPropertyVos = new ArrayList<>();
|
List<OpenPropertyVo> openPropertyVos = new ArrayList<>();
|
||||||
if (propertyVo != null){
|
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()) {
|
for (ThingModel.Property property : propertyVo.getModel().getProperties()) {
|
||||||
OpenPropertyVo openPropertyVo = new OpenPropertyVo(property.getIdentifier(), property.getDataType(), property.getName(), property.getAccessMode(), property.getDescription(), property.getUnit());
|
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());
|
Map<String,Object> map = (Map<String, Object>) properties.get(openPropertyVo.getIdentifier());
|
||||||
|
|
|
@ -54,7 +54,7 @@ public class DeviceCondition {
|
||||||
}
|
}
|
||||||
Object left = null;
|
Object left = null;
|
||||||
if ("property".equals(type)) {
|
if ("property".equals(type)) {
|
||||||
Map<String, Object> properties = deviceInfo.getProperty();
|
Map<String, ?> properties = deviceInfo.getProperty();
|
||||||
left = properties.get(identifier);
|
left = properties.get(identifier);
|
||||||
} else if ("state".equals(type)) {
|
} else if ("state".equals(type)) {
|
||||||
DeviceInfo.State state = deviceInfo.getState();
|
DeviceInfo.State state = deviceInfo.getState();
|
||||||
|
|
Binary file not shown.
|
@ -92,7 +92,7 @@
|
||||||
<!-- </dependency>-->
|
<!-- </dependency>-->
|
||||||
|
|
||||||
<!--打开注释 启用tdengine数据库-->
|
<!--打开注释 启用tdengine数据库-->
|
||||||
<!-- <dependency>-->
|
<!-- <dependency>-->
|
||||||
<!-- <groupId>cc.iotkit</groupId>-->
|
<!-- <groupId>cc.iotkit</groupId>-->
|
||||||
<!-- <artifactId>iot-temproal-serviceImpl-td</artifactId>-->
|
<!-- <artifactId>iot-temproal-serviceImpl-td</artifactId>-->
|
||||||
<!-- </dependency>-->
|
<!-- </dependency>-->
|
||||||
|
|
|
@ -88,25 +88,24 @@ spring:
|
||||||
# ============mysql配置结束============>>
|
# ============mysql配置结束============>>
|
||||||
|
|
||||||
#<<================es时序数据配置开始===============
|
#<<================es时序数据配置开始===============
|
||||||
elasticsearch:
|
# elasticsearch:
|
||||||
rest:
|
# rest:
|
||||||
#使用内置es的配置
|
# #使用内置es的配置
|
||||||
#uris: http://elasticsearch:9200
|
# #uris: http://elasticsearch:9200
|
||||||
uris: http://127.0.0.1:9200
|
# uris: http://127.0.0.1:9200
|
||||||
username:
|
# username:
|
||||||
password:
|
# password:
|
||||||
connection-timeout: 10s
|
# connection-timeout: 10s
|
||||||
#================es时序数据配置结束===============>>
|
#================es时序数据配置结束===============>>
|
||||||
|
|
||||||
#<<===========tdengine时序数据库配置开始============
|
#<<===========tdengine时序数据库配置开始============
|
||||||
# td-datasource:
|
td-datasource:
|
||||||
# url: jdbc:TAOS-RS://127.0.0.1:6041/iotkit?timezone=UTC-8&charset=UTF-8&locale=en_US.UTF-8
|
url: jdbc:TAOS-RS://127.0.0.1:6041/iotkit?timezone=UTC-8&charset=UTF-8&locale=en_US.UTF-8
|
||||||
# username: root
|
username: root
|
||||||
# password: taosdata
|
password: taosdata
|
||||||
# driverClassName: com.taosdata.jdbc.rs.RestfulDriver
|
driverClassName: com.taosdata.jdbc.rs.RestfulDriver
|
||||||
#===========tdengine时序数据库配置开始============>>
|
#===========tdengine时序数据库配置开始============>>
|
||||||
|
|
||||||
|
|
||||||
redis:
|
redis:
|
||||||
#使用内置redis的配置
|
#使用内置redis的配置
|
||||||
#host: redis
|
#host: redis
|
||||||
|
|
Loading…
Reference in New Issue