Merge branch 'dev-V0.4.5' into dev-V0.4.5-postgre

# Conflicts:
#	iot-starter/src/main/resources/application.yml
V0.5.x
jay 2023-08-30 19:07:53 +08:00
commit 5f68b99c90
41 changed files with 118 additions and 688 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

@ -73,17 +73,19 @@ Vertx event-bus内置、RocketMQ通过扩展模块可接入其它任意
**注:** es版本为7.15.2mysql版本为8.0+
##### 关系数据库切换为mysql方法其它数据库同理
##### H2数据库切换为mysql方法其它数据库同理
1、删掉.init、iotkit.mv.db、iotkit.trace.db文件
1、将iot-data-serviceImpl-rdb/pom.xml中的mysql驱动注释放开
2、将iot-data-serviceImpl-rdb/pom.xml中的mysql驱动注释放开
2、启动时指定active: --spring.profiles.active=mysql
3、application.yml 注释掉内置H2数据库打开mysql配置注释
##### 时序数据库切换为TDengin(版本2.6x)方法
##### es切换为TDengine(版本3.x)方法
1、删掉.init和关系数据库数据
1、注释掉iot-starter/pom.xml中的 iot-temporal-serviceImpl-es并打开iot-td-temporal-service的注释
2、注释掉iot-starter/pom.xml中的 iot-temporal-serviceImpl-es并打开iot-td-temporal-service的注释
2、application.xml中注释掉elasticsearch配置并打开td-datasource配置
3、注解掉iot-starter下application.xml中的elasticsearch配置并打开td-datasource配置
##### 消息总线切换为RocketMq方法

View File

@ -1562,17 +1562,7 @@
"name": "水温度",
"accessMode": "r"
},
{
"identifier": "query",
"dataType": {
"type": "text",
"specs": {
"length": "255"
}
},
"name": "查询",
"accessMode": "rw"
},
{
"identifier": "McuStatus",
"dataType": {
@ -1838,17 +1828,7 @@
"name": "实时运行状态",
"accessMode": "rw"
},
{
"identifier": "Time",
"dataType": {
"type": "text",
"specs": {
"length": "255"
}
},
"name": "时间戳",
"accessMode": "rw"
},
{
"identifier": "TimeModeSet",
"dataType": {

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

@ -173,6 +173,7 @@ public class SysMenuDataImpl implements ISysMenuData, IJPACommData<SysMenu, Long
tbSysMenu.parentId, tbSysMenu.menuName, tbSysMenu.path, tbSysMenu.component, tbSysMenu.queryParam,
tbSysMenu.visible, tbSysMenu.status, tbSysMenu.perms, tbSysMenu.isFrame, tbSysMenu.isCache, tbSysMenu.menuType,
tbSysMenu.icon, tbSysMenu.orderNum, tbSysMenu.createTime))
.distinct()
.from(tbSysMenu)
.leftJoin(tbSysRoleMenu).on(tbSysMenu.id.eq(tbSysRoleMenu.menuId))
.leftJoin(tbSysUserRole).on(tbSysRoleMenu.roleId.eq(tbSysUserRole.roleId))

View File

@ -54,7 +54,7 @@ public class PageBuilder {
Map<String,String> sortMap = pageRequest.getSortMap();
if (CollUtil.isNotEmpty(sortMap)){
sortMap.forEach((k,v) -> {
orders.add(new Order(Direction.ASC, k));
orders.add(new Order(Direction.fromString("desc"), k));
});
}
return orders;

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

@ -52,19 +52,13 @@ public class JavaScriptEngine implements IScriptEngine {
public <T> T invokeMethod(TypeReference<T> type, String methodName, Object... args) {
Value member = jsScript.getMember("invoke");
StringBuilder sbArgs = new StringBuilder("[");
//将入参转成json
for (int i = 0; i < args.length; i++) {
args[i] = JsonUtils.toJsonString(args[i]);
sbArgs.append(i == args.length - 1 ? "," : "").append(args[i]);
}
sbArgs.append("]");
StringBuilder sbArgs = formatArgs(args);
//通过调用invoke方法将目标方法返回结果转成json
Value rst = member.execute(methodName, args);
String json = rst.asString();
log.info("invoke script {},args:{}, result:{}", methodName, sbArgs, json);
log.info("invoke script={}, args={}, result={}", methodName, sbArgs, json);
//没有返回值
if (json == null || "null".equals(json)) {
@ -74,4 +68,15 @@ public class JavaScriptEngine implements IScriptEngine {
return JsonUtils.parseObject(json, type);
}
private static StringBuilder formatArgs(Object[] args) {
StringBuilder sbArgs = new StringBuilder("[");
//将入参转成json
for (int i = 0; i < args.length; i++) {
args[i] = JsonUtils.toJsonString(args[i]);
sbArgs.append(args[i]).append(i != args.length - 1 ? "," : "");
}
sbArgs.append("]");
return sbArgs;
}
}

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

@ -71,7 +71,7 @@ public class DeviceController {
@ApiOperation(value = "属性获取", notes = "属性获取", httpMethod = "POST")
@SaCheckPermission("iot:device:ctrl")
@PostMapping("/service/property/get")
public InvokeResult invokeServicePropertySet(@RequestBody @Validated Request<GetDeviceServicePorpertyBo> request) {
public InvokeResult invokeServicePropertySet(@RequestBody @Validated Request<GetDeviceServicePorpertyBo> request) {
return new InvokeResult(deviceService.getProperty(request.getData().getDeviceId(), request.getData().getPropertyNames(), true));
}
@ -153,17 +153,17 @@ public class DeviceController {
return deviceServiceImpl.logs(request);
}
@ApiOperation("设备属性日志")
@ApiOperation("获取设备属性历史数据")
@SaCheckPermission("iot:deviceLog:query")
@PostMapping("/deviceProperty/log/list")
public List<DeviceProperty> getPropertyHistory(@Validated @RequestBody
Request<DevicePropertyLogQueryBo> query) {
Request<DevicePropertyLogQueryBo> query) {
DevicePropertyLogQueryBo data = query.getData();
String deviceId = data.getDeviceId();
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("设备解绑")
@ -283,7 +283,7 @@ public class DeviceController {
@PostMapping("/group/removeDevices")
public boolean removeDevices(@Validated @RequestBody Request<DeviceAddGroupBo> bo) {
DeviceAddGroupBo data = bo.getData();
return deviceServiceImpl.removeDevices(data.getGroup(), data.getDevices());
return deviceServiceImpl.removeDevices(data.getGroup(), data.getDevices());
}
/**

View File

@ -1,6 +1,6 @@
package cc.iotkit.manager.dto.vo.ruleinfo;
import cc.iotkit.model.rule.RuleInfo;
import cc.iotkit.model.rule.RuleLog;
import io.github.linpeilie.annotations.AutoMapper;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
@ -10,27 +10,23 @@ import java.io.Serializable;
@ApiModel(value = "RuleLogVo")
@Data
@AutoMapper(target = RuleInfo.class)
@AutoMapper(target = RuleLog.class)
public class RuleLogVo implements Serializable {
private static final long serialVersionUID = -1L;
@ApiModelProperty(value = "时间")
private Long time;
private Long logAt;
@ApiModelProperty(value = "规则id")
private String ruleId;
@ApiModelProperty(value = "状态")
private String state1;
private String state;
@ApiModelProperty(value = "内容")
private String content;
@ApiModelProperty(value = "是否成功")
private Boolean success;
}

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,18 +293,23 @@ public class ExampleDataInit implements SmartInitializingSingleton {
});
}
private <T> T initData(String name, ICommonData service, TypeReference<T> type) throws IOException {
log.info("init {} data...", name);
if (service.count() > 0) {
new RuntimeException("原数据库已存在" + name + "的旧数据,请清除后再重新初始化!").printStackTrace();
System.exit(0);
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();
System.exit(0);
}
String json = FileUtils.readFileToString(new File("./data/init/" + name + ".json"), StandardCharsets.UTF_8);
List list = (List) JsonUtils.parseObject(json, type);
for (Object obj : list) {
service.save((Id) obj);
}
return (T) list;
} catch (Exception e) {
log.error("initData error", e);
return null;
}
String json = FileUtils.readFileToString(new File("./data/init/" + name + ".json"), StandardCharsets.UTF_8);
List list = (List) JsonUtils.parseObject(json, type);
for (Object obj : list) {
service.save((Id) obj);
}
return (T) list;
}
}

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>-->