Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
mqttsnet
thinglinks
提交
2d09434e
thinglinks
项目概览
mqttsnet
/
thinglinks
通知
1
Star
2
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
thinglinks
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
2d09434e
编写于
4月 27, 2022
作者:
xiaonannet
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
子设备管理功能
上级
99cafb24
变更
36
展开全部
隐藏空白更改
内联
并排
Showing
36 changed file
with
1342 addition
and
232 deletion
+1342
-232
thinglinks-api/thinglinks-api-link/src/main/java/com/mqttsnet/thinglinks/link/api/domain/device/entity/Device.java
...snet/thinglinks/link/api/domain/device/entity/Device.java
+4
-10
thinglinks-api/thinglinks-api-link/src/main/java/com/mqttsnet/thinglinks/link/api/domain/device/entity/DeviceInfo.java
.../thinglinks/link/api/domain/device/entity/DeviceInfo.java
+139
-0
thinglinks-api/thinglinks-api-link/src/main/java/com/mqttsnet/thinglinks/link/api/domain/device/entity/model/DeviceInfos.java
...inks/link/api/domain/device/entity/model/DeviceInfos.java
+24
-0
thinglinks-api/thinglinks-api-link/src/main/java/com/mqttsnet/thinglinks/link/api/domain/device/entity/model/TopoAddDatas.java
...nks/link/api/domain/device/entity/model/TopoAddDatas.java
+23
-0
thinglinks-auth/src/main/resources/bootstrap.yml
thinglinks-auth/src/main/resources/bootstrap.yml
+1
-0
thinglinks-common/thinglinks-common-rocketmq/src/main/java/com/mqttsnet/thinglinks/common/rocketmq/constant/ConsumerTopicConstant.java
...links/common/rocketmq/constant/ConsumerTopicConstant.java
+5
-0
thinglinks-gateway/src/main/resources/bootstrap.yml
thinglinks-gateway/src/main/resources/bootstrap.yml
+1
-0
thinglinks-modules/thinglinks-modules-broker/src/main/resources/bootstrap.yml
...hinglinks-modules-broker/src/main/resources/bootstrap.yml
+1
-0
thinglinks-modules/thinglinks-modules-file/src/main/resources/bootstrap.yml
.../thinglinks-modules-file/src/main/resources/bootstrap.yml
+1
-0
thinglinks-modules/thinglinks-modules-gen/src/main/resources/bootstrap.yml
...s/thinglinks-modules-gen/src/main/resources/bootstrap.yml
+1
-0
thinglinks-modules/thinglinks-modules-job/src/main/resources/bootstrap.yml
...s/thinglinks-modules-job/src/main/resources/bootstrap.yml
+1
-0
thinglinks-modules/thinglinks-modules-link/src/main/java/com/mqttsnet/thinglinks/link/common/rockermq/consumer/DeviceActionMessageConsumer.java
...common/rockermq/consumer/DeviceActionMessageConsumer.java
+18
-13
thinglinks-modules/thinglinks-modules-link/src/main/java/com/mqttsnet/thinglinks/link/controller/product/ProductController.java
...thinglinks/link/controller/product/ProductController.java
+5
-23
thinglinks-modules/thinglinks-modules-link/src/main/java/com/mqttsnet/thinglinks/link/mapper/device/DeviceInfoMapper.java
...tsnet/thinglinks/link/mapper/device/DeviceInfoMapper.java
+70
-0
thinglinks-modules/thinglinks-modules-link/src/main/java/com/mqttsnet/thinglinks/link/mapper/product/ProductMapper.java
...qttsnet/thinglinks/link/mapper/product/ProductMapper.java
+6
-0
thinglinks-modules/thinglinks-modules-link/src/main/java/com/mqttsnet/thinglinks/link/service/device/DeviceDatasService.java
...et/thinglinks/link/service/device/DeviceDatasService.java
+33
-1
thinglinks-modules/thinglinks-modules-link/src/main/java/com/mqttsnet/thinglinks/link/service/device/DeviceInfoService.java
...net/thinglinks/link/service/device/DeviceInfoService.java
+42
-0
thinglinks-modules/thinglinks-modules-link/src/main/java/com/mqttsnet/thinglinks/link/service/device/impl/DeviceDatasServiceImpl.java
...inks/link/service/device/impl/DeviceDatasServiceImpl.java
+158
-9
thinglinks-modules/thinglinks-modules-link/src/main/java/com/mqttsnet/thinglinks/link/service/device/impl/DeviceInfoServiceImpl.java
...links/link/service/device/impl/DeviceInfoServiceImpl.java
+79
-0
thinglinks-modules/thinglinks-modules-link/src/main/java/com/mqttsnet/thinglinks/link/service/device/impl/DeviceServiceImpl.java
...hinglinks/link/service/device/impl/DeviceServiceImpl.java
+0
-38
thinglinks-modules/thinglinks-modules-link/src/main/java/com/mqttsnet/thinglinks/link/service/product/ProductService.java
...tsnet/thinglinks/link/service/product/ProductService.java
+8
-2
thinglinks-modules/thinglinks-modules-link/src/main/java/com/mqttsnet/thinglinks/link/service/product/impl/ProductServiceImpl.java
...nglinks/link/service/product/impl/ProductServiceImpl.java
+24
-24
thinglinks-modules/thinglinks-modules-link/src/main/resources/bootstrap.yml
.../thinglinks-modules-link/src/main/resources/bootstrap.yml
+1
-0
thinglinks-modules/thinglinks-modules-link/src/main/resources/mapper/link/device/DeviceInfoMapper.xml
...rc/main/resources/mapper/link/device/DeviceInfoMapper.xml
+607
-0
thinglinks-modules/thinglinks-modules-link/src/main/resources/mapper/link/device/DeviceMapper.xml
...nk/src/main/resources/mapper/link/device/DeviceMapper.xml
+36
-78
thinglinks-modules/thinglinks-modules-link/src/main/resources/mapper/link/product/ProductMapper.xml
.../src/main/resources/mapper/link/product/ProductMapper.xml
+34
-0
thinglinks-modules/thinglinks-modules-protocolAnalysis/src/main/java/com/mqttsnet/thinglinks/protocolAnalysis/tcpServer/TcpServer.java
...snet/thinglinks/protocolAnalysis/tcpServer/TcpServer.java
+1
-0
thinglinks-modules/thinglinks-modules-protocolAnalysis/src/main/resources/bootstrap.yml
...modules-protocolAnalysis/src/main/resources/bootstrap.yml
+1
-0
thinglinks-modules/thinglinks-modules-system/src/main/resources/bootstrap.yml
...hinglinks-modules-system/src/main/resources/bootstrap.yml
+1
-0
thinglinks-modules/thinglinks-modules-tdengine/readme.md
thinglinks-modules/thinglinks-modules-tdengine/readme.md
+1
-1
thinglinks-modules/thinglinks-modules-tdengine/src/main/java/com/mqttsnet/thinglinks/tdengine/common/consumer/ProductCreateSuperTableMessageConsumer.java
...mmon/consumer/ProductCreateSuperTableMessageConsumer.java
+1
-1
thinglinks-modules/thinglinks-modules-tdengine/src/main/java/com/mqttsnet/thinglinks/tdengine/service/impl/TdEngineServiceImpl.java
...thinglinks/tdengine/service/impl/TdEngineServiceImpl.java
+2
-2
thinglinks-modules/thinglinks-modules-tdengine/src/main/resources/bootstrap.yml
...nglinks-modules-tdengine/src/main/resources/bootstrap.yml
+1
-0
thinglinks-ui/src/views/link/device/index.vue
thinglinks-ui/src/views/link/device/index.vue
+10
-30
thinglinks-visual/thinglinks-visual-collection/src/main/resources/bootstrap.yml
...glinks-visual-collection/src/main/resources/bootstrap.yml
+1
-0
thinglinks-visual/thinglinks-visual-monitor/src/main/resources/bootstrap.yml
...hinglinks-visual-monitor/src/main/resources/bootstrap.yml
+1
-0
未找到文件。
thinglinks-api/thinglinks-api-link/src/main/java/com/mqttsnet/thinglinks/link/api/domain/device/entity/Device.java
浏览文件 @
2d09434e
...
...
@@ -127,18 +127,12 @@ public class Device extends BaseEntity implements Serializable{
private
String
deviceTags
;
/**
* 产品
型号
* 产品
标识
*/
@Excel
(
name
=
"产品
型号
"
)
@ApiModelProperty
(
value
=
"产品
型号
"
)
private
String
productId
;
@Excel
(
name
=
"产品
标识
"
)
@ApiModelProperty
(
value
=
"产品
标识
"
)
private
String
productId
entification
;
/**
* 厂商ID
*/
@Excel
(
name
=
"厂商ID"
)
@ApiModelProperty
(
value
=
"厂商ID"
)
private
String
manufacturerId
;
/**
* 产品协议类型 :mqtt || coap || modbus || http
...
...
thinglinks-api/thinglinks-api-link/src/main/java/com/mqttsnet/thinglinks/link/api/domain/device/entity/DeviceInfo.java
0 → 100644
浏览文件 @
2d09434e
package
com.mqttsnet.thinglinks.link.api.domain.device.entity
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
java.io.Serializable
;
import
java.time.LocalDateTime
;
import
lombok.AllArgsConstructor
;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
/**
* @Description: java类作用描述
* @Author: ShiHuan SUN
* @E-mail: 13733918655@163.com
* @Website: http://thinglinks.mqttsnet.com
* @CreateDate: 2022/4/25$ 12:48$
* @UpdateUser: ShiHuan SUN
* @UpdateDate: 2022/4/25$ 12:48$
* @UpdateRemark: 修改内容
* @Version: V1.0
*/
/**
* 子设备档案表
*/
@ApiModel
(
value
=
"子设备档案表"
)
@Data
@AllArgsConstructor
@NoArgsConstructor
public
class
DeviceInfo
implements
Serializable
{
/**
* 主键
*/
@ApiModelProperty
(
value
=
"主键"
)
private
Long
id
;
/**
* 边设备档案主键
*/
@ApiModelProperty
(
value
=
"边设备档案主键"
)
private
Long
dId
;
/**
* 应用ID
*/
@ApiModelProperty
(
value
=
"应用ID"
)
private
String
appId
;
/**
* 设备自身的唯一标识
*/
@ApiModelProperty
(
value
=
"设备自身的唯一标识"
)
private
String
nodeId
;
/**
* 设备名称
*/
@ApiModelProperty
(
value
=
"设备名称"
)
private
String
nodeName
;
/**
* 平台生成的设备唯一标识
*/
@ApiModelProperty
(
value
=
"平台生成的设备唯一标识"
)
private
String
deviceId
;
/**
* 设备描述
*/
@ApiModelProperty
(
value
=
"设备描述"
)
private
String
description
;
/**
* 厂商ID
*/
@ApiModelProperty
(
value
=
"厂商ID"
)
private
String
manufacturerId
;
/**
* 设备型号
*/
@ApiModelProperty
(
value
=
"设备型号"
)
private
String
model
;
/**
* 子设备连接状态 : 在线:ONLINE || 离线:OFFLINE || 未连接:INIT
*/
@ApiModelProperty
(
value
=
"子设备连接状态 : 在线:ONLINE || 离线:OFFLINE || 未连接:INIT"
)
private
String
connectStatus
;
/**
* 是否支持设备影子TRUE:1、FALSE :0
*/
@ApiModelProperty
(
value
=
"是否支持设备影子TRUE:1、FALSE :0"
)
private
Boolean
shadowEnable
;
/**
* 设备影子数据表名
*/
@ApiModelProperty
(
value
=
"设备影子数据表名"
)
private
String
shadowTableName
;
/**
* 状态(字典值:0启用 1停用)
*/
@ApiModelProperty
(
value
=
"状态(字典值:0启用 1停用)"
)
private
String
status
;
/**
* 创建者
*/
@ApiModelProperty
(
value
=
"创建者"
)
private
String
createBy
;
/**
* 创建时间
*/
@ApiModelProperty
(
value
=
"创建时间"
)
private
LocalDateTime
createTime
;
/**
* 更新者
*/
@ApiModelProperty
(
value
=
"更新者"
)
private
String
updateBy
;
/**
* 更新时间
*/
@ApiModelProperty
(
value
=
"更新时间"
)
private
LocalDateTime
updateTime
;
/**
* 备注
*/
@ApiModelProperty
(
value
=
"备注"
)
private
String
remark
;
private
static
final
long
serialVersionUID
=
1L
;
}
\ No newline at end of file
thinglinks-api/thinglinks-api-link/src/main/java/com/mqttsnet/thinglinks/link/api/domain/device/entity/model/DeviceInfos.java
0 → 100644
浏览文件 @
2d09434e
package
com.mqttsnet.thinglinks.link.api.domain.device.entity.model
;
import
lombok.Data
;
/**
* @Description: 边设备添加子设备详情数据模型
* @Author: ShiHuan SUN
* @E-mail: 13733918655@163.com
* @Website: http://thinglinks.mqttsnet.com
* @CreateDate: 2022/4/25$ 12:54$
* @UpdateUser: ShiHuan SUN
* @UpdateDate: 2022/4/25$ 12:54$
* @UpdateRemark: 修改内容
* @Version: V1.0
*/
@Data
public
class
DeviceInfos
{
private
static
final
long
serialVersionUID
=
1L
;
private
String
nodeId
;
private
String
name
;
private
String
description
;
private
String
manufacturerId
;
private
String
model
;
}
thinglinks-api/thinglinks-api-link/src/main/java/com/mqttsnet/thinglinks/link/api/domain/device/entity/model/TopoAddDatas.java
0 → 100644
浏览文件 @
2d09434e
package
com.mqttsnet.thinglinks.link.api.domain.device.entity.model
;
import
lombok.Data
;
import
java.util.List
;
/**
* @Description: 边设备添加子设备数据模型
* @Author: ShiHuan SUN
* @E-mail: 13733918655@163.com
* @Website: http://thinglinks.mqttsnet.com
* @CreateDate: 2022/4/25$ 12:52$
* @UpdateUser: ShiHuan SUN
* @UpdateDate: 2022/4/25$ 12:52$
* @UpdateRemark: 修改内容
* @Version: V1.0
*/
@Data
public
class
TopoAddDatas
{
private
static
final
long
serialVersionUID
=
1L
;
private
Integer
mid
;
private
List
<
DeviceInfos
>
deviceInfos
;
}
thinglinks-auth/src/main/resources/bootstrap.yml
浏览文件 @
2d09434e
...
...
@@ -11,6 +11,7 @@ spring:
# 环境配置
active
:
dev
main
:
allow-circular-references
:
true
allow-bean-definition-overriding
:
true
cloud
:
nacos
:
...
...
thinglinks-common/thinglinks-common-rocketmq/src/main/java/com/mqttsnet/thinglinks/common/rocketmq/constant/ConsumerTopicConstant.java
浏览文件 @
2d09434e
...
...
@@ -16,6 +16,11 @@ import lombok.Data;
@Data
public
class
ConsumerTopicConstant
{
/**
* MQTT设备消息监听主题
*/
public
static
final
String
THINGLINKS_LINK_MQTT_MSG
=
"thinglinks-link-mqttMsg"
;
/**
* TDengine超级表创键修改动作监听主题
*/
...
...
thinglinks-gateway/src/main/resources/bootstrap.yml
浏览文件 @
2d09434e
...
...
@@ -11,6 +11,7 @@ spring:
# 环境配置
active
:
dev
main
:
allow-circular-references
:
true
allow-bean-definition-overriding
:
true
cloud
:
nacos
:
...
...
thinglinks-modules/thinglinks-modules-broker/src/main/resources/bootstrap.yml
浏览文件 @
2d09434e
...
...
@@ -11,6 +11,7 @@ spring:
# 环境配置
active
:
dev
main
:
allow-circular-references
:
true
allow-bean-definition-overriding
:
true
cloud
:
nacos
:
...
...
thinglinks-modules/thinglinks-modules-file/src/main/resources/bootstrap.yml
浏览文件 @
2d09434e
...
...
@@ -11,6 +11,7 @@ spring:
# 环境配置
active
:
dev
main
:
allow-circular-references
:
true
allow-bean-definition-overriding
:
true
cloud
:
nacos
:
...
...
thinglinks-modules/thinglinks-modules-gen/src/main/resources/bootstrap.yml
浏览文件 @
2d09434e
...
...
@@ -11,6 +11,7 @@ spring:
# 环境配置
active
:
dev
main
:
allow-circular-references
:
true
allow-bean-definition-overriding
:
true
cloud
:
nacos
:
...
...
thinglinks-modules/thinglinks-modules-job/src/main/resources/bootstrap.yml
浏览文件 @
2d09434e
...
...
@@ -11,6 +11,7 @@ spring:
# 环境配置
active
:
dev
main
:
allow-circular-references
:
true
allow-bean-definition-overriding
:
true
cloud
:
nacos
:
...
...
thinglinks-modules/thinglinks-modules-link/src/main/java/com/mqttsnet/thinglinks/link/common/rockermq/consumer/DeviceActionMessageConsumer.java
浏览文件 @
2d09434e
...
...
@@ -2,6 +2,7 @@ package com.mqttsnet.thinglinks.link.common.rockermq.consumer;
import
com.alibaba.fastjson.JSONObject
;
import
com.mqttsnet.thinglinks.common.rocketmq.constant.ConsumerGroupConstant
;
import
com.mqttsnet.thinglinks.common.rocketmq.constant.ConsumerTopicConstant
;
import
lombok.extern.slf4j.Slf4j
;
import
com.mqttsnet.thinglinks.link.service.device.DeviceActionService
;
import
com.mqttsnet.thinglinks.link.service.device.DeviceDatasService
;
...
...
@@ -23,7 +24,7 @@ import org.springframework.stereotype.Component;
*/
@Slf4j
@Component
@RocketMQMessageListener
(
consumerGroup
=
ConsumerGroupConstant
.
THINGLINKS_GROUP
,
topic
=
"thinglinks-link"
)
@RocketMQMessageListener
(
consumerGroup
=
ConsumerGroupConstant
.
THINGLINKS_GROUP
,
topic
=
ConsumerTopicConstant
.
THINGLINKS_LINK_MQTT_MSG
)
public
class
DeviceActionMessageConsumer
implements
RocketMQListener
{
@Autowired
private
DeviceActionService
deviceActionService
;
...
...
@@ -35,18 +36,22 @@ public class DeviceActionMessageConsumer implements RocketMQListener {
assert
message
!=
null
:
"message cannot be empty"
;
log
.
info
(
"ThingLinks物联网平台数据消费-->Received message={}"
,
message
);
JSONObject
thinglinksMessage
=
JSONObject
.
parseObject
(
String
.
valueOf
(
message
));
/**
* TODO 设备上下线处理
* $event/close 设备断开事件
* $event/connect 设备连接事件
* ${topic} 其他为业务数据自行处理
*/
if
(
"$event/connect"
.
equals
(
thinglinksMessage
.
get
(
"topic"
))){
deviceActionService
.
connectEvent
(
String
.
valueOf
(
thinglinksMessage
.
getString
(
"msg"
)));
}
else
if
(
"$event/close"
.
equals
(
thinglinksMessage
.
get
(
"topic"
))){
deviceActionService
.
closeEvent
(
String
.
valueOf
(
thinglinksMessage
.
getString
(
"msg"
)));
}
else
{
deviceDatasService
.
insertBaseDatas
(
thinglinksMessage
);
try
{
/**
* TODO 设备上下线处理
* $event/close 设备断开事件
* $event/connect 设备连接事件
* ${topic} 其他为业务数据自行处理
*/
if
(
"$event/connect"
.
equals
(
thinglinksMessage
.
get
(
"topic"
))){
deviceActionService
.
connectEvent
(
String
.
valueOf
(
thinglinksMessage
.
getString
(
"msg"
)));
}
else
if
(
"$event/close"
.
equals
(
thinglinksMessage
.
get
(
"topic"
))){
deviceActionService
.
closeEvent
(
String
.
valueOf
(
thinglinksMessage
.
getString
(
"msg"
)));
}
else
{
deviceDatasService
.
insertBaseDatas
(
thinglinksMessage
);
}
}
catch
(
Exception
e
){
log
.
error
(
"ThingLinks物联网平台数据消费-->消费失败,失败原因:{}"
,
e
.
getMessage
());
}
}
}
thinglinks-modules/thinglinks-modules-link/src/main/java/com/mqttsnet/thinglinks/link/controller/product/ProductController.java
浏览文件 @
2d09434e
...
...
@@ -51,25 +51,6 @@ public class ProductController extends BaseController {
return
productService
.
selectByPrimaryKey
(
id
);
}
/* *//**
* 新增产品模型
*//*
@PreAuthorize(hasPermi = "link:product:add")
@Log(title = "产品模型", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody JSONObject content) {
JSONObject tokenObj = new JSONObject();
try {
// AjaxResult ajaxResult = productService.insert(content);
return null;
} catch (JSONException e) {
return new AjaxResult(HttpStatus.ERROR, "文件数据的json格式错误", tokenObj);
} catch (Exception e) {
log.error("新增产品模型异常:", e);
return new AjaxResult(HttpStatus.ERROR, "快捷生成失败", tokenObj);
}
}*/
/**
* 导入产品模型json数据
* @param file json文件
...
...
@@ -183,14 +164,15 @@ public class ProductController extends BaseController {
/**
* 初始化生成超级表模型
* @param productId productId==null 初始化所有产品:productId!=null 初始化指定产品
* @param productIds 产品ID集合
* @param initializeOrNot 是否初始化
* @return
* @throws Exception
*/
@GetMapping
(
value
=
"/findCreateSuperTableDataModel/{productId}"
)
public
AjaxResult
findCreateSuperTableDataModel
(
@PathVariable
(
"productId
"
)
Long
productId
)
throws
Exception
{
@GetMapping
(
value
=
"/findCreateSuperTableDataModel/{productId
s}/{initializeOrNot
}"
)
public
AjaxResult
findCreateSuperTableDataModel
(
@PathVariable
(
"productId
s"
)
Long
[]
productIds
,
@PathVariable
(
"initializeOrNot"
)
Boolean
initializeOrNot
)
throws
Exception
{
try
{
final
List
<
SuperTableDto
>
superTableDataModel
=
productService
.
createSuperTableDataModel
(
productId
,
false
);
final
List
<
SuperTableDto
>
superTableDataModel
=
productService
.
createSuperTableDataModel
(
productId
s
,
initializeOrNot
);
return
AjaxResult
.
success
(
superTableDataModel
);
}
catch
(
Exception
e
){
log
.
error
(
e
.
getMessage
());
...
...
thinglinks-modules/thinglinks-modules-link/src/main/java/com/mqttsnet/thinglinks/link/mapper/device/DeviceInfoMapper.java
0 → 100644
浏览文件 @
2d09434e
package
com.mqttsnet.thinglinks.link.mapper.device
;
import
com.mqttsnet.thinglinks.link.api.domain.device.entity.DeviceInfo
;
import
java.util.List
;
import
org.apache.ibatis.annotations.Mapper
;
import
org.apache.ibatis.annotations.Param
;
/**
* @Description: java类作用描述
* @Author: ShiHuan SUN
* @E-mail: 13733918655@163.com
* @Website: http://thinglinks.mqttsnet.com
* @CreateDate: 2022/4/25$ 12:48$
* @UpdateUser: ShiHuan SUN
* @UpdateDate: 2022/4/25$ 12:48$
* @UpdateRemark: 修改内容
* @Version: V1.0
*/
@Mapper
public
interface
DeviceInfoMapper
{
/**
* delete by primary key
* @param id primaryKey
* @return deleteCount
*/
int
deleteByPrimaryKey
(
Long
id
);
/**
* insert record to table
* @param record the record
* @return insert count
*/
int
insert
(
DeviceInfo
record
);
int
insertOrUpdate
(
DeviceInfo
record
);
int
insertOrUpdateSelective
(
DeviceInfo
record
);
/**
* insert record to table selective
* @param record the record
* @return insert count
*/
int
insertSelective
(
DeviceInfo
record
);
/**
* select by primary key
* @param id primary key
* @return object by primary key
*/
DeviceInfo
selectByPrimaryKey
(
Long
id
);
/**
* update record selective
* @param record the updated record
* @return update count
*/
int
updateByPrimaryKeySelective
(
DeviceInfo
record
);
/**
* update record
* @param record the updated record
* @return update count
*/
int
updateByPrimaryKey
(
DeviceInfo
record
);
int
updateBatch
(
List
<
DeviceInfo
>
list
);
int
batchInsert
(
@Param
(
"list"
)
List
<
DeviceInfo
>
list
);
}
\ No newline at end of file
thinglinks-modules/thinglinks-modules-link/src/main/java/com/mqttsnet/thinglinks/link/mapper/product/ProductMapper.java
浏览文件 @
2d09434e
package
com.mqttsnet.thinglinks.link.mapper.product
;
import
java.util.Collection
;
import
com.mqttsnet.thinglinks.link.api.domain.product.entity.Product
;
...
...
@@ -140,6 +141,11 @@ public interface ProductMapper {
Product
findOneByIdAndStatus
(
@Param
(
"id"
)
Long
id
,
@Param
(
"status"
)
String
status
);
Product
findOneByProductIdentificationAndProtocolType
(
@Param
(
"productIdentification"
)
String
productIdentification
,
@Param
(
"protocolType"
)
String
protocolType
);
List
<
Product
>
findAllByIdInAndStatus
(
@Param
(
"idCollection"
)
Collection
<
Long
>
idCollection
,
@Param
(
"status"
)
String
status
);
...
...
thinglinks-modules/thinglinks-modules-link/src/main/java/com/mqttsnet/thinglinks/link/service/device/DeviceDatasService.java
浏览文件 @
2d09434e
...
...
@@ -50,9 +50,33 @@ public interface DeviceDatasService {
*
* @param thinglinksMessage
*/
void
insertBaseDatas
(
JSONObject
thinglinksMessage
);
void
insertBaseDatas
(
JSONObject
thinglinksMessage
)
throws
Exception
;
/**
* 处理/topo/add Topic边设备添加子设备
*
* @param deviceIdentification 设备标识
* @param msg 数据
*/
void
processingTopoAddTopic
(
String
deviceIdentification
,
String
msg
)
throws
Exception
;
/**
* 处理/topo/delete Topic边设备删除子设备
*
* @param deviceIdentification 设备标识
* @param msg 数据
*/
void
processingTopoDeleteTopic
(
String
deviceIdentification
,
String
msg
)
throws
Exception
;
/**
* 处理/topo/update Topic边设备更新子设备状态
*
* @param deviceIdentification 设备标识
* @param msg 数据
*/
void
processingTopoUpdateTopic
(
String
deviceIdentification
,
String
msg
)
throws
Exception
;
/**
* 处理datas Topic数据上报
*
...
...
@@ -61,6 +85,14 @@ public interface DeviceDatasService {
*/
void
processingDatasTopic
(
String
deviceIdentification
,
String
msg
)
throws
Exception
;
/**
* 处理/commandResponse Topic边设备返回给物联网平台的命令响应
*
* @param deviceIdentification 设备标识
* @param msg 数据
*/
void
processingTopoCommandResponseTopic
(
String
deviceIdentification
,
String
msg
)
throws
Exception
;
}
thinglinks-modules/thinglinks-modules-link/src/main/java/com/mqttsnet/thinglinks/link/service/device/DeviceInfoService.java
0 → 100644
浏览文件 @
2d09434e
package
com.mqttsnet.thinglinks.link.service.device
;
import
java.util.List
;
import
com.mqttsnet.thinglinks.link.api.domain.device.entity.DeviceInfo
;
/**
* @Description: java类作用描述
* @Author: ShiHuan SUN
* @E-mail: 13733918655@163.com
* @Website: http://thinglinks.mqttsnet.com
* @CreateDate: 2022/4/25$ 12:44$
* @UpdateUser: ShiHuan SUN
* @UpdateDate: 2022/4/25$ 12:44$
* @UpdateRemark: 修改内容
* @Version: V1.0
*/
public
interface
DeviceInfoService
{
int
deleteByPrimaryKey
(
Long
id
);
int
insert
(
DeviceInfo
record
);
int
insertOrUpdate
(
DeviceInfo
record
);
int
insertOrUpdateSelective
(
DeviceInfo
record
);
int
insertSelective
(
DeviceInfo
record
);
DeviceInfo
selectByPrimaryKey
(
Long
id
);
int
updateByPrimaryKeySelective
(
DeviceInfo
record
);
int
updateByPrimaryKey
(
DeviceInfo
record
);
int
updateBatch
(
List
<
DeviceInfo
>
list
);
int
batchInsert
(
List
<
DeviceInfo
>
list
);
}
thinglinks-modules/thinglinks-modules-link/src/main/java/com/mqttsnet/thinglinks/link/service/device/impl/DeviceDatasServiceImpl.java
浏览文件 @
2d09434e
...
...
@@ -2,26 +2,38 @@ package com.mqttsnet.thinglinks.link.service.device.impl;
import
com.alibaba.fastjson.JSONObject
;
import
com.jayway.jsonpath.JsonPath
;
import
com.mqttsnet.thinglinks.common.core.domain.R
;
import
com.mqttsnet.thinglinks.common.core.enums.DeviceConnectStatus
;
import
com.mqttsnet.thinglinks.common.core.text.UUID
;
import
com.mqttsnet.thinglinks.common.core.utils.StringUtils
;
import
com.mqttsnet.thinglinks.common.core.utils.SubStringUtil
;
import
com.mqttsnet.thinglinks.common.redis.service.RedisService
;
import
com.mqttsnet.thinglinks.link.api.domain.device.entity.Device
;
import
com.mqttsnet.thinglinks.link.api.domain.device.entity.DeviceDatas
;
import
com.mqttsnet.thinglinks.link.api.domain.device.entity.DeviceInfo
;
import
com.mqttsnet.thinglinks.link.api.domain.device.entity.model.DeviceInfos
;
import
com.mqttsnet.thinglinks.link.api.domain.device.entity.model.TopoAddDatas
;
import
com.mqttsnet.thinglinks.link.api.domain.product.entity.Product
;
import
com.mqttsnet.thinglinks.link.api.domain.product.entity.ProductServices
;
import
com.mqttsnet.thinglinks.link.mapper.device.DeviceDatasMapper
;
import
com.mqttsnet.thinglinks.link.service.device.DeviceDatasService
;
import
com.mqttsnet.thinglinks.link.service.device.DeviceInfoService
;
import
com.mqttsnet.thinglinks.link.service.device.DeviceService
;
import
com.mqttsnet.thinglinks.link.service.product.ProductService
;
import
com.mqttsnet.thinglinks.link.service.product.ProductServicesService
;
import
com.mqttsnet.thinglinks.tdengine.api.RemoteTdEngineService
;
import
com.mqttsnet.thinglinks.tdengine.api.domain.Fields
;
import
com.mqttsnet.thinglinks.tdengine.api.domain.TableDto
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Isolation
;
import
org.springframework.transaction.annotation.Propagation
;
import
org.springframework.transaction.annotation.Transactional
;
import
javax.annotation.Resource
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Objects
;
...
...
@@ -51,6 +63,15 @@ public class DeviceDatasServiceImpl implements DeviceDatasService {
private
ProductServicesService
productServicesService
;
@Autowired
private
RedisService
redisService
;
@Resource
private
RemoteTdEngineService
remoteTdEngineService
;
@Autowired
private
DeviceInfoService
deviceInfoService
;
/**
* 数据库名称
*/
@Value
(
"${spring.datasource.dynamic.datasource.master.dbName:thinglinks}"
)
private
String
dataBaseName
;
@Override
public
int
deleteByPrimaryKey
(
Long
id
)
{
...
...
@@ -123,21 +144,140 @@ public class DeviceDatasServiceImpl implements DeviceDatasService {
* @param thinglinksMessage
*/
@Override
public
void
insertBaseDatas
(
JSONObject
thinglinksMessage
)
{
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
void
insertBaseDatas
(
JSONObject
thinglinksMessage
)
throws
Exception
{
String
topic
=
thinglinksMessage
.
getString
(
"topic"
);
String
msg
=
thinglinksMessage
.
getString
(
"msg"
);
if
(
Objects
.
equals
(
msg
,
"{}"
))
{
log
.
error
(
"Topic:{},The entry is empty and ignored"
,
topic
);
return
;
}
/**
* Topic Publisher(发布者) Subscriber(订阅者) 用途
* /v1/devices/{gatewayId}/topo/add 边设备 物联网平台 边设备添加子设备
* /v1/devices/{gatewayId}/topo/addResponse 物联网平台 边设备 物联网平台返回的添加子设备的响应
* /v1/devices/{gatewayId}/topo/delete 边设备 物联网平台 边设备删除子设备
* /v1/devices/{gatewayId}/topo/deleteResponse 物联网平台 边设备 物联网平台返回的删除子设备的响应
* /v1/devices/{gatewayId}/topo/update 边设备 物联网平台 边设备更新子设备状态
* /v1/devices/{gatewayId}/topo/updateResponse 物联网平台 边设备 物联网平台返回的更新子设备状态的响应
* /v1/devices/{deviceId}/datas 边设备 物联网平台 边设备上报数据
* /v1/devices/{deviceId}/command 物联网平台 边设备 物联网平台给设备或边设备下发命令
* /v1/devices/{deviceId}/commandResponse 边设备 物联网平台 边设备返回给物联网平台的命令响应
*/
//边设备上报数据处理
if
(
topic
.
startsWith
(
"/v1/devices/"
)
&&
topic
.
endsWith
(
"/datas"
))
{
if
(
topic
.
startsWith
(
"/v1/devices/"
)
&&
topic
.
endsWith
(
"/topo/add"
))
{
log
.
info
(
"Side equipment report data processing,Topic:{},Msg:{}"
,
topic
,
msg
);
final
String
deviceIdentification
=
SubStringUtil
.
subStr
(
topic
,
12
,-
9
);
this
.
processingTopoAddTopic
(
deviceIdentification
,
msg
);
}
else
if
(
topic
.
startsWith
(
"/v1/devices/"
)
&&
topic
.
endsWith
(
"/topo/delete"
)){
log
.
info
(
"Side equipment report data processing,Topic:{},Msg:{}"
,
topic
,
msg
);
final
String
deviceIdentification
=
SubStringUtil
.
subStr
(
topic
,
12
,-
12
);
this
.
processingTopoDeleteTopic
(
deviceIdentification
,
msg
);
}
else
if
(
topic
.
startsWith
(
"/v1/devices/"
)
&&
topic
.
endsWith
(
"/topo/update"
)){
log
.
info
(
"Side equipment report data processing,Topic:{},Msg:{}"
,
topic
,
msg
);
final
String
deviceIdentification
=
SubStringUtil
.
subStr
(
topic
,
12
,-
12
);
this
.
processingTopoUpdateTopic
(
deviceIdentification
,
msg
);
}
else
if
(
topic
.
startsWith
(
"/v1/devices/"
)
&&
topic
.
endsWith
(
"/datas"
)){
log
.
info
(
"Side equipment report data processing,Topic:{},Msg:{}"
,
topic
,
msg
);
final
String
deviceIdentification
=
SubStringUtil
.
subStr
(
topic
,
12
,-
6
);
this
.
processingDatasTopic
(
deviceIdentification
,
msg
);
}
else
if
(
topic
.
startsWith
(
"/v1/devices/"
)
&&
topic
.
endsWith
(
"/commandResponse"
)){
log
.
info
(
"Side equipment report data processing,Topic:{},Msg:{}"
,
topic
,
msg
);
final
String
deviceIdentification
=
SubStringUtil
.
subStr
(
topic
,
12
,-
16
);
this
.
processingTopoCommandResponseTopic
(
deviceIdentification
,
msg
);
}
else
{
//TODO 其他协议自行扩展
log
.
info
(
"Other Topic packets are ignored,Topic:{},Msg:{}"
,
topic
,
msg
);
}
}
/**
* 处理/topo/add Topic边设备添加子设备
*
* @param deviceIdentification 设备标识
* @param msg 数据
*/
@Override
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
void
processingTopoAddTopic
(
String
deviceIdentification
,
String
msg
)
throws
Exception
{
final
Device
device
=
deviceService
.
findOneByDeviceIdentification
(
deviceIdentification
);
if
(
StringUtils
.
isNull
(
device
))
{
log
.
error
(
"The side device reports data processing, but the device does not exist,DeviceIdentification:{},Msg:{}"
,
deviceIdentification
,
msg
);
return
;
}
final
Product
product
=
productService
.
findOneByProductIdentificationAndProtocolType
(
device
.
getProductIdentification
(),
device
.
getProtocolType
());
if
(
StringUtils
.
isNull
(
product
))
{
log
.
error
(
"The side device reports data processing, but the product does not exist,DeviceIdentification:{},Msg:{}"
,
deviceIdentification
,
msg
);
return
;
}
final
TopoAddDatas
topoAddDatas
=
JSONObject
.
toJavaObject
(
JSONObject
.
parseObject
(
msg
),
TopoAddDatas
.
class
);
for
(
DeviceInfos
deviceInfos:
topoAddDatas
.
getDeviceInfos
())
{
final
DeviceInfo
deviceInfo
=
new
DeviceInfo
();
deviceInfo
.
setDId
(
device
.
getId
());
deviceInfo
.
setAppId
(
device
.
getAppId
());
deviceInfo
.
setNodeId
(
deviceInfos
.
getNodeId
());
deviceInfo
.
setNodeName
(
deviceInfos
.
getName
());
deviceInfo
.
setDeviceId
(
UUID
.
getUUID
());
deviceInfo
.
setDescription
(
deviceInfos
.
getDescription
());
deviceInfo
.
setManufacturerId
(
deviceInfos
.
getManufacturerId
());
deviceInfo
.
setModel
(
deviceInfos
.
getModel
());
deviceInfo
.
setConnectStatus
(
DeviceConnectStatus
.
INIT
.
getValue
());
deviceInfo
.
setShadowEnable
(
true
);
StringBuilder
shadowTableNameBuilder
=
new
StringBuilder
();
// 新增设备管理成功后,创建TD普通表
List
<
ProductServices
>
allByProductIdAndStatus
=
productServicesService
.
findAllByProductIdAndStatus
(
product
.
getId
(),
"0"
);
TableDto
tableDto
;
for
(
ProductServices
productServices
:
allByProductIdAndStatus
)
{
tableDto
=
new
TableDto
();
tableDto
.
setDataBaseName
(
dataBaseName
);
//超级表命名规则 : 产品类型_产品标识_服务名称
String
superTableName
=
product
.
getProductType
()+
"_"
+
product
.
getProductIdentification
()+
"_"
+
productServices
.
getServiceName
();
tableDto
.
setSuperTableName
(
superTableName
);
//子表命名规则 : 产品类型_产品标识_服务名称_设备标识(设备唯一标识)
tableDto
.
setTableName
(
superTableName
+
"_"
+
deviceInfo
.
getDeviceId
());
//Tag的处理
List
<
Fields
>
tagsFieldValues
=
new
ArrayList
<>();
Fields
fields
=
new
Fields
();
fields
.
setFieldValue
(
device
.
getDeviceIdentification
());
tagsFieldValues
.
add
(
fields
);
tableDto
.
setTagsFieldValues
(
tagsFieldValues
);
final
R
<?>
ctResult
=
remoteTdEngineService
.
createTable
(
tableDto
);
if
(
ctResult
.
getCode
()
==
200
)
{
shadowTableNameBuilder
.
append
(
tableDto
.
getTableName
()).
append
(
","
);
log
.
info
(
"Create SuperTable Success: "
+
ctResult
.
getMsg
());
}
else
{
log
.
error
(
"Create SuperTable Exception: "
+
ctResult
.
getMsg
());
}
}
if
(
shadowTableNameBuilder
.
length
()
>
0
)
{
deviceInfo
.
setShadowTableName
(
shadowTableNameBuilder
.
substring
(
0
,
shadowTableNameBuilder
.
length
()
-
1
));
}
shadowTableNameBuilder
.
replace
(
0
,
shadowTableNameBuilder
.
length
(),
""
);
deviceInfo
.
setCreateBy
(
device
.
getCreateBy
());
deviceInfoService
.
insertSelective
(
deviceInfo
);
}
}
/**
* 处理/topo/delete Topic边设备删除子设备
*
* @param deviceIdentification 设备标识
* @param msg 数据
*/
@Override
public
void
processingTopoDeleteTopic
(
String
deviceIdentification
,
String
msg
)
throws
Exception
{
}
/**
* 处理/topo/update Topic边设备更新子设备状态
*
* @param deviceIdentification 设备标识
* @param msg 数据
*/
@Override
public
void
processingTopoUpdateTopic
(
String
deviceIdentification
,
String
msg
)
throws
Exception
{
}
}
/**
...
...
@@ -148,13 +288,13 @@ public class DeviceDatasServiceImpl implements DeviceDatasService {
*/
@Override
public
void
processingDatasTopic
(
String
deviceIdentification
,
String
msg
)
throws
Exception
{
final
Device
oneByDeviceIdentification
=
deviceService
.
findOneByDeviceIdentification
(
deviceIdentification
);
if
(
StringUtils
.
isNull
(
oneByDeviceIdentification
))
{
final
Device
device
=
deviceService
.
findOneByDeviceIdentification
(
deviceIdentification
);
if
(
StringUtils
.
isNull
(
device
))
{
log
.
error
(
"The side device reports data processing, but the device does not exist,DeviceIdentification:{},Msg:{}"
,
deviceIdentification
,
msg
);
return
;
}
final
Product
oneByManufacturerIdAndModelAndDeviceType
=
productService
.
findOneByManufacturerIdAndModelAndDeviceType
(
oneByDeviceIdentification
.
getManufacturerId
(),
oneByDeviceIdentification
.
getProductId
(),
oneByDeviceIdentification
.
getProtocolType
());
if
(
StringUtils
.
isNull
(
oneByManufacturerIdAndModelAndDeviceType
))
{
final
Product
product
=
productService
.
findOneByProductIdentificationAndProtocolType
(
device
.
getProductIdentification
(),
device
.
getProtocolType
());
if
(
StringUtils
.
isNull
(
product
))
{
log
.
error
(
"The side device reports data processing, but the product does not exist,DeviceIdentification:{},Msg:{}"
,
deviceIdentification
,
msg
);
return
;
}
...
...
@@ -163,13 +303,22 @@ public class DeviceDatasServiceImpl implements DeviceDatasService {
log
.
error
(
"The side device reports data processing, but the serviceId does not exist,DeviceIdentification:{},Msg:{}"
,
deviceIdentification
,
msg
);
}
for
(
String
serviceName
:
serviceId
)
{
final
List
<
ProductServices
>
allByProductIdAndServiceNameAndStatus
=
productServicesService
.
findAllByProductIdAndServiceNameAndStatus
(
oneByManufacturerIdAndModelAndDeviceType
.
getId
(),
serviceName
,
"0"
);
final
List
<
ProductServices
>
allByProductIdAndServiceNameAndStatus
=
productServicesService
.
findAllByProductIdAndServiceNameAndStatus
(
product
.
getId
(),
serviceName
,
"0"
);
if
(
StringUtils
.
isEmpty
(
allByProductIdAndServiceNameAndStatus
))
{
log
.
error
(
"The side device reports data processing, but the service does not exist,DeviceIdentification:{},Msg:{}"
,
deviceIdentification
,
msg
);
}
}
}
/**
* 处理/commandResponse Topic边设备返回给物联网平台的命令响应
*
* @param deviceIdentification 设备标识
* @param msg 数据
*/
@Override
public
void
processingTopoCommandResponseTopic
(
String
deviceIdentification
,
String
msg
)
throws
Exception
{
}
...
...
thinglinks-modules/thinglinks-modules-link/src/main/java/com/mqttsnet/thinglinks/link/service/device/impl/DeviceInfoServiceImpl.java
0 → 100644
浏览文件 @
2d09434e
package
com.mqttsnet.thinglinks.link.service.device.impl
;
import
org.springframework.stereotype.Service
;
import
javax.annotation.Resource
;
import
java.util.List
;
import
com.mqttsnet.thinglinks.link.mapper.device.DeviceInfoMapper
;
import
com.mqttsnet.thinglinks.link.api.domain.device.entity.DeviceInfo
;
import
com.mqttsnet.thinglinks.link.service.device.DeviceInfoService
;
/**
* @Description: java类作用描述
* @Author: ShiHuan SUN
* @E-mail: 13733918655@163.com
* @Website: http://thinglinks.mqttsnet.com
* @CreateDate: 2022/4/25$ 12:44$
* @UpdateUser: ShiHuan SUN
* @UpdateDate: 2022/4/25$ 12:44$
* @UpdateRemark: 修改内容
* @Version: V1.0
*/
@Service
public
class
DeviceInfoServiceImpl
implements
DeviceInfoService
{
@Resource
private
DeviceInfoMapper
deviceInfoMapper
;
@Override
public
int
deleteByPrimaryKey
(
Long
id
)
{
return
deviceInfoMapper
.
deleteByPrimaryKey
(
id
);
}
@Override
public
int
insert
(
DeviceInfo
record
)
{
return
deviceInfoMapper
.
insert
(
record
);
}
@Override
public
int
insertOrUpdate
(
DeviceInfo
record
)
{
return
deviceInfoMapper
.
insertOrUpdate
(
record
);
}
@Override
public
int
insertOrUpdateSelective
(
DeviceInfo
record
)
{
return
deviceInfoMapper
.
insertOrUpdateSelective
(
record
);
}
@Override
public
int
insertSelective
(
DeviceInfo
record
)
{
return
deviceInfoMapper
.
insertSelective
(
record
);
}
@Override
public
DeviceInfo
selectByPrimaryKey
(
Long
id
)
{
return
deviceInfoMapper
.
selectByPrimaryKey
(
id
);
}
@Override
public
int
updateByPrimaryKeySelective
(
DeviceInfo
record
)
{
return
deviceInfoMapper
.
updateByPrimaryKeySelective
(
record
);
}
@Override
public
int
updateByPrimaryKey
(
DeviceInfo
record
)
{
return
deviceInfoMapper
.
updateByPrimaryKey
(
record
);
}
@Override
public
int
updateBatch
(
List
<
DeviceInfo
>
list
)
{
return
deviceInfoMapper
.
updateBatch
(
list
);
}
@Override
public
int
batchInsert
(
List
<
DeviceInfo
>
list
)
{
return
deviceInfoMapper
.
batchInsert
(
list
);
}
}
thinglinks-modules/thinglinks-modules-link/src/main/java/com/mqttsnet/thinglinks/link/service/device/impl/DeviceServiceImpl.java
浏览文件 @
2d09434e
...
...
@@ -52,17 +52,6 @@ public class DeviceServiceImpl implements DeviceService {
private
DeviceMapper
deviceMapper
;
@Autowired
private
TokenService
tokenService
;
@Resource
private
RemoteTdEngineService
remoteTdEngineService
;
@Autowired
private
ProductService
productService
;
@Autowired
private
ProductServicesService
productServicesService
;
/**
* 数据库名称
*/
@Value
(
"${spring.datasource.dynamic.datasource.master.dbName:thinglinks}"
)
private
String
dataBaseName
;
@Override
public
int
deleteByPrimaryKey
(
Long
id
)
{
...
...
@@ -217,33 +206,6 @@ public class DeviceServiceImpl implements DeviceService {
device
.
setCreateBy
(
sysUser
.
getUserName
());
device
.
setCreateTime
(
DateUtils
.
getNowDate
());
final
int
insertDeviceCount
=
deviceMapper
.
insertDevice
(
device
);
Product
product
=
productService
.
findOneByManufacturerIdAndModelAndProtocolTypeAndStatus
(
device
.
getManufacturerId
(),
device
.
getProductId
(),
device
.
getProtocolType
(),
"0"
);
if
(
StringUtils
.
isNull
(
product
))
{
new
Throwable
(
"The side device reports data processing, but the product does not exist,DeviceIdentification:"
+
device
.
getDeviceIdentification
()
+
",Msg:"
+
JSON
.
toJSONString
(
device
));
}
// 新增设备管理成功后,创建TD普通表
List
<
ProductServices
>
allByProductIdAndStatus
=
productServicesService
.
findAllByProductIdAndStatus
(
product
.
getId
(),
"0"
);
TableDto
tableDto
;
for
(
ProductServices
productServices
:
allByProductIdAndStatus
)
{
tableDto
=
new
TableDto
();
tableDto
.
setDataBaseName
(
dataBaseName
);
//超级表名称命名规则:产品类型_产品标识_服务名称_设备标识(非ClientId)
String
superTableName
=
product
.
getProductType
()+
"_"
+
product
.
getProductIdentification
()+
"_"
+
productServices
.
getServiceName
();
tableDto
.
setSuperTableName
(
superTableName
);
tableDto
.
setTableName
(
superTableName
+
"_"
+
device
.
getDeviceIdentification
());
//Tag的处理
List
<
Fields
>
tagsFieldValues
=
new
ArrayList
<>();
Fields
fields
=
new
Fields
();
fields
.
setFieldValue
(
device
.
getDeviceIdentification
());
tagsFieldValues
.
add
(
fields
);
tableDto
.
setTagsFieldValues
(
tagsFieldValues
);
final
R
<?>
ctResult
=
remoteTdEngineService
.
createTable
(
tableDto
);
if
(
ctResult
.
getCode
()
!=
200
)
{
log
.
error
(
"Create SuperTable Exception: "
+
ctResult
.
getMsg
());
}
else
{
log
.
info
(
"Create SuperTable Success: "
+
ctResult
.
getMsg
());
}
}
return
insertDeviceCount
;
}
...
...
thinglinks-modules/thinglinks-modules-link/src/main/java/com/mqttsnet/thinglinks/link/service/product/ProductService.java
浏览文件 @
2d09434e
...
...
@@ -7,6 +7,7 @@ import com.mqttsnet.thinglinks.link.api.domain.product.entity.Product;
import
com.mqttsnet.thinglinks.tdengine.api.domain.SuperTableDto
;
import
org.springframework.web.multipart.MultipartFile
;
import
java.util.Collection
;
import
java.util.List
;
/**
...
...
@@ -137,12 +138,12 @@ public interface ProductService{
/**
* 初始化生成超级表模型
* @param productId
productId==null 初始化所有产品:productId
!=null 初始化指定产品
* @param productId
s 产品ID集合 productIds==null 初始化所有产品:productIds
!=null 初始化指定产品
* @param InitializeOrNot 是否初始化
* @return
* @throws Exception
*/
List
<
SuperTableDto
>
createSuperTableDataModel
(
Long
productId
,
Boolean
InitializeOrNot
)
throws
Exception
;
List
<
SuperTableDto
>
createSuperTableDataModel
(
Long
[]
productIds
,
Boolean
InitializeOrNot
)
throws
Exception
;
...
...
@@ -154,4 +155,9 @@ public interface ProductService{
Product
findOneByProductIdentificationAndProtocolType
(
String
productIdentification
,
String
protocolType
);
List
<
Product
>
findAllByIdInAndStatus
(
Collection
<
Long
>
idCollection
,
String
status
);
}
thinglinks-modules/thinglinks-modules-link/src/main/java/com/mqttsnet/thinglinks/link/service/product/impl/ProductServiceImpl.java
浏览文件 @
2d09434e
...
...
@@ -10,10 +10,8 @@ import com.mqttsnet.thinglinks.common.core.constant.Constants;
import
com.mqttsnet.thinglinks.common.core.domain.R
;
import
com.mqttsnet.thinglinks.common.core.enums.DataTypeEnum
;
import
com.mqttsnet.thinglinks.common.core.text.CharsetKit
;
import
com.mqttsnet.thinglinks.common.core.text.Convert
;
import
com.mqttsnet.thinglinks.common.core.text.UUID
;
import
com.mqttsnet.thinglinks.common.core.utils.DateUtils
;
import
com.mqttsnet.thinglinks.common.core.utils.SpringUtils
;
import
com.mqttsnet.thinglinks.common.core.utils.StringUtils
;
import
com.mqttsnet.thinglinks.common.core.web.domain.AjaxResult
;
import
com.mqttsnet.thinglinks.common.redis.service.RedisService
;
...
...
@@ -23,23 +21,17 @@ import com.mqttsnet.thinglinks.common.security.service.TokenService;
import
com.mqttsnet.thinglinks.link.api.domain.product.entity.Product
;
import
com.mqttsnet.thinglinks.link.api.domain.product.entity.ProductProperties
;
import
com.mqttsnet.thinglinks.link.api.domain.product.entity.ProductServices
;
import
com.mqttsnet.thinglinks.link.api.domain.product.model.Commands
;
import
com.mqttsnet.thinglinks.link.api.domain.product.model.Properties
;
import
com.mqttsnet.thinglinks.link.api.domain.product.model.Services
;
import
com.mqttsnet.thinglinks.link.mapper.product.ProductMapper
;
import
com.mqttsnet.thinglinks.link.mapper.product.ProductPropertiesMapper
;
import
com.mqttsnet.thinglinks.link.mapper.product.ProductServicesMapper
;
import
com.mqttsnet.thinglinks.link.service.product.ProductPropertiesService
;
import
com.mqttsnet.thinglinks.link.service.product.ProductService
;
import
com.mqttsnet.thinglinks.link.service.product.ProductServicesService
;
import
com.mqttsnet.thinglinks.system.api.domain.SysDictData
;
import
com.mqttsnet.thinglinks.system.api.domain.SysUser
;
import
com.mqttsnet.thinglinks.system.api.model.LoginUser
;
import
com.mqttsnet.thinglinks.tdengine.api.RemoteTdEngineService
;
import
com.mqttsnet.thinglinks.tdengine.api.domain.Fields
;
import
com.mqttsnet.thinglinks.tdengine.api.domain.SuperTableDto
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.poi.ss.formula.functions.T
;
import
org.apache.rocketmq.spring.core.RocketMQTemplate
;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
...
@@ -57,13 +49,7 @@ import java.io.BufferedReader;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.io.InputStreamReader
;
import
java.nio.charset.Charset
;
import
java.nio.charset.StandardCharsets
;
import
java.util.*
;
import
java.util.zip.ZipEntry
;
import
java.util.zip.ZipInputStream
;
import
static
cn
.
hutool
.
json
.
XMLTokener
.
entity
;
/**
...
...
@@ -555,29 +541,27 @@ public class ProductServiceImpl implements ProductService{
/**
* 初始化生成超级表模型
* @param productId
productId==null 初始化所有产品:productId
!=null 初始化指定产品
* @param productId
s 产品ID集合 productIds==null 初始化所有产品:productIds
!=null 初始化指定产品
* @param InitializeOrNot 是否初始化
* @return
* @throws Exception
*/
@Async
@Override
public
List
<
SuperTableDto
>
createSuperTableDataModel
(
Long
productId
,
Boolean
InitializeOrNot
)
throws
Exception
{
public
List
<
SuperTableDto
>
createSuperTableDataModel
(
Long
[]
productIds
,
Boolean
InitializeOrNot
)
throws
Exception
{
List
<
SuperTableDto
>
superTableDtoList
=
new
ArrayList
<>();
List
<
Product
>
allByStatus
=
null
;
if
(
productId
==
null
)
{
allByStatus
=
this
.
findAllByStatus
(
"0"
);
List
<
Product
>
productList
=
new
ArrayList
<>()
;
if
(
productId
s
.
length
>
0
)
{
productList
=
this
.
findAllByStatus
(
"0"
);
}
else
{
allByStatus
=
new
ArrayList
<>();
Product
product
=
this
.
findOneByIdAndStatus
(
productId
,
"0"
);
allByStatus
.
add
(
product
);
productList
=
this
.
findAllByIdInAndStatus
(
Arrays
.
asList
(
productIds
),
"0"
);
}
SuperTableDto
superTableDto
;
loop:
for
(
Product
product
:
allByStatus
)
{
for
(
Product
product
:
productList
)
{
List
<
ProductServices
>
allByProductIdAndStatus
=
productServicesService
.
findAllByProductIdAndStatus
(
product
.
getId
(),
"0"
);
if
(
StringUtils
.
isEmpty
(
allByProductIdAndStatus
)){
continue
loop
;
continue
;
}
for
(
ProductServices
productServices
:
allByProductIdAndStatus
)
{
superTableDto
=
new
SuperTableDto
();
...
...
@@ -661,6 +645,22 @@ public class ProductServiceImpl implements ProductService{
return
productMapper
.
findOneByIdAndStatus
(
id
,
status
);
}
@Override
public
Product
findOneByProductIdentificationAndProtocolType
(
String
productIdentification
,
String
protocolType
){
return
productMapper
.
findOneByProductIdentificationAndProtocolType
(
productIdentification
,
protocolType
);
}
@Override
public
List
<
Product
>
findAllByIdInAndStatus
(
Collection
<
Long
>
idCollection
,
String
status
){
return
productMapper
.
findAllByIdInAndStatus
(
idCollection
,
status
);
}
...
...
thinglinks-modules/thinglinks-modules-link/src/main/resources/bootstrap.yml
浏览文件 @
2d09434e
...
...
@@ -11,6 +11,7 @@ spring:
# 环境配置
active
:
dev
main
:
allow-circular-references
:
true
allow-bean-definition-overriding
:
true
cloud
:
nacos
:
...
...
thinglinks-modules/thinglinks-modules-link/src/main/resources/mapper/link/device/DeviceInfoMapper.xml
0 → 100644
浏览文件 @
2d09434e
此差异已折叠。
点击以展开。
thinglinks-modules/thinglinks-modules-link/src/main/resources/mapper/link/device/DeviceMapper.xml
浏览文件 @
2d09434e
...
...
@@ -18,8 +18,7 @@
<result
column=
"connect_status"
jdbcType=
"VARCHAR"
property=
"connectStatus"
/>
<result
column=
"is_will"
jdbcType=
"VARCHAR"
property=
"isWill"
/>
<result
column=
"device_tags"
jdbcType=
"VARCHAR"
property=
"deviceTags"
/>
<result
column=
"product_id"
jdbcType=
"VARCHAR"
property=
"productId"
/>
<result
column=
"manufacturer_id"
jdbcType=
"VARCHAR"
property=
"manufacturerId"
/>
<result
column=
"product_identification"
jdbcType=
"VARCHAR"
property=
"productIdentification"
/>
<result
column=
"protocol_type"
jdbcType=
"VARCHAR"
property=
"protocolType"
/>
<result
column=
"device_type"
jdbcType=
"VARCHAR"
property=
"deviceType"
/>
<result
column=
"create_by"
jdbcType=
"VARCHAR"
property=
"createBy"
/>
...
...
@@ -43,8 +42,7 @@
<result
property=
"connectStatus"
column=
"connect_status"
/>
<result
property=
"isWill"
column=
"is_will"
/>
<result
property=
"deviceTags"
column=
"device_tags"
/>
<result
property=
"productId"
column=
"product_id"
/>
<result
property=
"manufacturerId"
column=
"manufacturer_id"
/>
<result
property=
"productIdentification"
column=
"product_identification"
/>
<result
property=
"protocolType"
column=
"protocol_type"
/>
<result
property=
"deviceType"
column=
"device_type"
/>
<result
property=
"createBy"
column=
"create_by"
/>
...
...
@@ -57,7 +55,7 @@
<!--@mbg.generated-->
id, client_id, user_name, `password`, app_id, auth_mode, device_identification, device_name,
connector, device_description, device_status, connect_status, is_will, device_tags,
product_id
, manufacturer_id, protocol_type, device_type, create_by, create_time,
product_id
entification, protocol_type, device_type, create_by, create_time,
update_by, update_time, remark
</sql>
<select
id=
"selectByPrimaryKey"
parameterType=
"java.lang.Long"
resultMap=
"BaseResultMap"
>
...
...
@@ -78,7 +76,7 @@
app_id, auth_mode, device_identification,
device_name, connector, device_description,
device_status, connect_status, is_will,
device_tags, product_id
, manufacturer_id,
device_tags, product_id
entification,
protocol_type, device_type, create_by,
create_time, update_by, update_time,
remark)
...
...
@@ -86,7 +84,7 @@
#{app_id,jdbcType=VARCHAR}, #{auth_mode,jdbcType=VARCHAR}, #{device_identification,jdbcType=VARCHAR},
#{device_name,jdbcType=VARCHAR}, #{connector,jdbcType=VARCHAR}, #{device_description,jdbcType=VARCHAR},
#{device_status,jdbcType=VARCHAR}, #{connect_status,jdbcType=VARCHAR}, #{is_will,jdbcType=VARCHAR},
#{device_tags,jdbcType=VARCHAR}, #{product_id
,jdbcType=VARCHAR}, #{manufacturer_id,jdbcType=VARCHAR},
#{device_tags,jdbcType=VARCHAR}, #{product_id
entification,jdbcType=VARCHAR},
#{protocol_type,jdbcType=VARCHAR}, #{device_type,jdbcType=VARCHAR}, #{create_by,jdbcType=VARCHAR},
#{create_time,jdbcType=TIMESTAMP}, #{update_by,jdbcType=VARCHAR}, #{update_time,jdbcType=TIMESTAMP},
#{remark,jdbcType=VARCHAR})
...
...
@@ -134,11 +132,8 @@
<if
test=
"device_tags != null and device_tags != ''"
>
device_tags,
</if>
<if
test=
"product_id != null and product_id != ''"
>
product_id,
</if>
<if
test=
"manufacturer_id != null and manufacturer_id != ''"
>
manufacturer_id,
<if
test=
"product_identification != null and product_identification != ''"
>
product_identification,
</if>
<if
test=
"protocol_type != null and protocol_type != ''"
>
protocol_type,
...
...
@@ -202,11 +197,8 @@
<if
test=
"device_tags != null and device_tags != ''"
>
#{device_tags,jdbcType=VARCHAR},
</if>
<if
test=
"product_id != null and product_id != ''"
>
#{product_id,jdbcType=VARCHAR},
</if>
<if
test=
"manufacturer_id != null and manufacturer_id != ''"
>
#{manufacturer_id,jdbcType=VARCHAR},
<if
test=
"product_identification != null and product_identification != ''"
>
#{product_identification,jdbcType=VARCHAR},
</if>
<if
test=
"protocol_type != null and protocol_type != ''"
>
#{protocol_type,jdbcType=VARCHAR},
...
...
@@ -274,11 +266,8 @@
<if
test=
"device_tags != null and device_tags != ''"
>
device_tags = #{device_tags,jdbcType=VARCHAR},
</if>
<if
test=
"product_id != null and product_id != ''"
>
product_id = #{product_id,jdbcType=VARCHAR},
</if>
<if
test=
"manufacturer_id != null and manufacturer_id != ''"
>
manufacturer_id = #{manufacturer_id,jdbcType=VARCHAR},
<if
test=
"product_identification != null and product_identification != ''"
>
product_identification = #{product_identification,jdbcType=VARCHAR},
</if>
<if
test=
"protocol_type != null and protocol_type != ''"
>
protocol_type = #{protocol_type,jdbcType=VARCHAR},
...
...
@@ -320,8 +309,7 @@
connect_status = #{connect_status,jdbcType=VARCHAR},
is_will = #{is_will,jdbcType=VARCHAR},
device_tags = #{device_tags,jdbcType=VARCHAR},
product_id = #{product_id,jdbcType=VARCHAR},
manufacturer_id = #{manufacturer_id,jdbcType=VARCHAR},
product_identification = #{product_identification,jdbcType=VARCHAR},
protocol_type = #{protocol_type,jdbcType=VARCHAR},
device_type = #{device_type,jdbcType=VARCHAR},
create_by = #{create_by,jdbcType=VARCHAR},
...
...
@@ -400,14 +388,9 @@
when id = #{item.id,jdbcType=BIGINT} then #{item.device_tags,jdbcType=VARCHAR}
</foreach>
</trim>
<trim
prefix=
"product_id = case"
suffix=
"end,"
>
<trim
prefix=
"product_id
entification
= case"
suffix=
"end,"
>
<foreach
collection=
"list"
index=
"index"
item=
"item"
>
when id = #{item.id,jdbcType=BIGINT} then #{item.product_id,jdbcType=VARCHAR}
</foreach>
</trim>
<trim
prefix=
"manufacturer_id = case"
suffix=
"end,"
>
<foreach
collection=
"list"
index=
"index"
item=
"item"
>
when id = #{item.id,jdbcType=BIGINT} then #{item.manufacturer_id,jdbcType=VARCHAR}
when id = #{item.id,jdbcType=BIGINT} then #{item.product_identification,jdbcType=VARCHAR}
</foreach>
</trim>
<trim
prefix=
"protocol_type = case"
suffix=
"end,"
>
...
...
@@ -546,17 +529,10 @@
</if>
</foreach>
</trim>
<trim
prefix=
"product_id = case"
suffix=
"end,"
>
<foreach
collection=
"list"
index=
"index"
item=
"item"
>
<if
test=
"item.product_id != null"
>
when id = #{item.id,jdbcType=BIGINT} then #{item.product_id,jdbcType=VARCHAR}
</if>
</foreach>
</trim>
<trim
prefix=
"manufacturer_id = case"
suffix=
"end,"
>
<trim
prefix=
"product_identification = case"
suffix=
"end,"
>
<foreach
collection=
"list"
index=
"index"
item=
"item"
>
<if
test=
"item.
manufacturer_id
!= null"
>
when id = #{item.id,jdbcType=BIGINT} then #{item.
manufacturer_id
,jdbcType=VARCHAR}
<if
test=
"item.
product_identification
!= null"
>
when id = #{item.id,jdbcType=BIGINT} then #{item.
product_identification
,jdbcType=VARCHAR}
</if>
</foreach>
</trim>
...
...
@@ -620,7 +596,7 @@
insert into device
(client_id, user_name, `password`, app_id, auth_mode, device_identification, device_name,
connector, device_description, device_status, connect_status, is_will, device_tags,
product_id
, manufacturer_id, protocol_type, device_type, create_by, create_time,
product_id
entification, protocol_type, device_type, create_by, create_time,
update_by, update_time, remark)
values
<foreach
collection=
"list"
item=
"item"
separator=
","
>
...
...
@@ -628,8 +604,8 @@
#{item.app_id,jdbcType=VARCHAR}, #{item.auth_mode,jdbcType=VARCHAR}, #{item.device_identification,jdbcType=VARCHAR},
#{item.device_name,jdbcType=VARCHAR}, #{item.connector,jdbcType=VARCHAR}, #{item.device_description,jdbcType=VARCHAR},
#{item.device_status,jdbcType=VARCHAR}, #{item.connect_status,jdbcType=VARCHAR},
#{item.is_will,jdbcType=VARCHAR}, #{item.device_tags,jdbcType=VARCHAR}, #{item.product_id,jdbcType=VARCHAR},
#{item.
manufacturer_id,jdbcType=VARCHAR}, #{item.protocol_type,jdbcType=VARCHAR},
#{item.is_will,jdbcType=VARCHAR}, #{item.device_tags,jdbcType=VARCHAR}, #{item.product_id
entification
,jdbcType=VARCHAR},
#{item.
protocol_type,jdbcType=VARCHAR},
#{item.device_type,jdbcType=VARCHAR}, #{item.create_by,jdbcType=VARCHAR}, #{item.create_time,jdbcType=TIMESTAMP},
#{item.update_by,jdbcType=VARCHAR}, #{item.update_time,jdbcType=TIMESTAMP}, #{item.remark,jdbcType=VARCHAR}
)
...
...
@@ -655,8 +631,7 @@
connect_status,
is_will,
device_tags,
product_id,
manufacturer_id,
product_identification,
protocol_type,
device_type,
create_by,
...
...
@@ -683,8 +658,7 @@
#{connect_status,jdbcType=VARCHAR},
#{is_will,jdbcType=VARCHAR},
#{device_tags,jdbcType=VARCHAR},
#{product_id,jdbcType=VARCHAR},
#{manufacturer_id,jdbcType=VARCHAR},
#{product_identification,jdbcType=VARCHAR},
#{protocol_type,jdbcType=VARCHAR},
#{device_type,jdbcType=VARCHAR},
#{create_by,jdbcType=VARCHAR},
...
...
@@ -711,8 +685,7 @@
connect_status = #{connect_status,jdbcType=VARCHAR},
is_will = #{is_will,jdbcType=VARCHAR},
device_tags = #{device_tags,jdbcType=VARCHAR},
product_id = #{product_id,jdbcType=VARCHAR},
manufacturer_id = #{manufacturer_id,jdbcType=VARCHAR},
product_identification = #{product_identification,jdbcType=VARCHAR},
protocol_type = #{protocol_type,jdbcType=VARCHAR},
device_type = #{device_type,jdbcType=VARCHAR},
create_by = #{create_by,jdbcType=VARCHAR},
...
...
@@ -768,11 +741,8 @@
<if
test=
"device_tags != null and device_tags != ''"
>
device_tags,
</if>
<if
test=
"product_id != null and product_id != ''"
>
product_id,
</if>
<if
test=
"manufacturer_id != null and manufacturer_id != ''"
>
manufacturer_id,
<if
test=
"product_identification != null and product_identification != ''"
>
product_identification,
</if>
<if
test=
"protocol_type != null and protocol_type != ''"
>
protocol_type,
...
...
@@ -840,11 +810,8 @@
<if
test=
"device_tags != null and device_tags != ''"
>
#{device_tags,jdbcType=VARCHAR},
</if>
<if
test=
"product_id != null and product_id != ''"
>
#{product_id,jdbcType=VARCHAR},
</if>
<if
test=
"manufacturer_id != null and manufacturer_id != ''"
>
#{manufacturer_id,jdbcType=VARCHAR},
<if
test=
"product_identification != null and product_identification != ''"
>
#{product_identification,jdbcType=VARCHAR},
</if>
<if
test=
"protocol_type != null and protocol_type != ''"
>
#{protocol_type,jdbcType=VARCHAR},
...
...
@@ -912,11 +879,8 @@
<if
test=
"device_tags != null and device_tags != ''"
>
device_tags = #{device_tags,jdbcType=VARCHAR},
</if>
<if
test=
"product_id != null and product_id != ''"
>
product_id = #{product_id,jdbcType=VARCHAR},
</if>
<if
test=
"manufacturer_id != null and manufacturer_id != ''"
>
manufacturer_id = #{manufacturer_id,jdbcType=VARCHAR},
<if
test=
"product_identification != null and product_identification != ''"
>
product_identification = #{product_identification,jdbcType=VARCHAR},
</if>
<if
test=
"protocol_type != null and protocol_type != ''"
>
protocol_type = #{protocol_type,jdbcType=VARCHAR},
...
...
@@ -1061,11 +1025,8 @@
<if
test=
"deviceTags != null and deviceTags != ''"
>
and device_tags=#{deviceTags,jdbcType=VARCHAR}
</if>
<if
test=
"productId != null and productId != ''"
>
and product_id=#{productId,jdbcType=VARCHAR}
</if>
<if
test=
"manufacturerId != null and manufacturerId != ''"
>
and manufacturer_id=#{manufacturerId,jdbcType=VARCHAR}
<if
test=
"productIdentification != null and productIdentification != ''"
>
and product_identification=#{productIdentification,jdbcType=VARCHAR}
</if>
<if
test=
"protocolType != null and protocolType != ''"
>
and protocol_type=#{protocolType,jdbcType=VARCHAR}
...
...
@@ -1109,7 +1070,7 @@
</where>
</select>
<sql
id=
"selectDeviceVo"
>
select id, client_id, user_name, password, app_id, auth_mode, device_identification, device_name, connector, device_description, device_status, connect_status, is_will, device_tags, product_id
, manufacturer_id,
protocol_type, device_type, create_by, create_time, update_by, update_time, remark from device
select id, client_id, user_name, password, app_id, auth_mode, device_identification, device_name, connector, device_description, device_status, connect_status, is_will, device_tags, product_id
entification,
protocol_type, device_type, create_by, create_time, update_by, update_time, remark from device
</sql>
<select
id=
"selectDeviceList"
parameterType=
"Device"
resultMap=
"DeviceResult"
>
...
...
@@ -1123,8 +1084,7 @@
<if
test=
"connectStatus != null and connectStatus != ''"
>
and connect_status = #{connectStatus}
</if>
<if
test=
"isWill != null and isWill != ''"
>
and is_will = #{isWill}
</if>
<if
test=
"deviceTags != null and deviceTags != ''"
>
and device_tags = #{deviceTags}
</if>
<if
test=
"productId != null and productId != ''"
>
and product_id = #{productId}
</if>
<if
test=
"manufacturerId != null and manufacturerId != ''"
>
and manufacturer_id = #{manufacturerId}
</if>
<if
test=
"productIdentification != null and productIdentification != ''"
>
and product_identification = #{productIdentification}
</if>
<if
test=
"protocolType != null and protocolType != ''"
>
and protocol_type = #{protocolType}
</if>
<if
test=
"deviceType != null and deviceType != ''"
>
and device_type = #{deviceType}
</if>
<if
test=
"createTime != null "
>
and create_time = #{createTime}
</if>
...
...
@@ -1152,8 +1112,7 @@
<if
test=
"connectStatus != null and connectStatus != ''"
>
connect_status,
</if>
<if
test=
"isWill != null"
>
is_will,
</if>
<if
test=
"deviceTags != null and deviceTags != ''"
>
device_tags,
</if>
<if
test=
"productId != null and productId != ''"
>
product_id,
</if>
<if
test=
"manufacturerId != null and manufacturerId != ''"
>
manufacturer_id,
</if>
<if
test=
"productIdentification != null and productIdentification != ''"
>
product_identification,
</if>
<if
test=
"protocolType != null and protocolType != ''"
>
protocol_type,
</if>
<if
test=
"deviceType != null and deviceType != ''"
>
device_type,
</if>
<if
test=
"createBy != null"
>
create_by,
</if>
...
...
@@ -1176,7 +1135,7 @@
<if
test=
"connectStatus != null and connectStatus != ''"
>
#{connectStatus},
</if>
<if
test=
"isWill != null"
>
#{isWill},
</if>
<if
test=
"deviceTags != null and deviceTags != ''"
>
#{deviceTags},
</if>
<if
test=
"productId
!= null and productId != ''"
>
#{productId
},
</if>
<if
test=
"productId
entification != null and productIdentification != ''"
>
#{productIdentification
},
</if>
<if
test=
"manufacturerId != null and manufacturerId != ''"
>
#{manufacturerId},
</if>
<if
test=
"protocolType != null and protocolType != ''"
>
#{protocolType},
</if>
<if
test=
"deviceType != null and deviceType != ''"
>
#{deviceType},
</if>
...
...
@@ -1204,8 +1163,7 @@
<if
test=
"connectStatus != null and connectStatus != ''"
>
connect_status = #{connectStatus},
</if>
<if
test=
"isWill != null"
>
is_will = #{isWill},
</if>
<if
test=
"deviceTags != null and deviceTags != ''"
>
device_tags = #{deviceTags},
</if>
<if
test=
"productId != null and productId != ''"
>
product_id = #{productId},
</if>
<if
test=
"manufacturerId != null and manufacturerId != ''"
>
manufacturer_id = #{manufacturerId},
</if>
<if
test=
"productIdentification != null and productIdentification != ''"
>
product_identification = #{productIdentification},
</if>
<if
test=
"protocolType != null and protocolType != ''"
>
protocol_type = #{protocolType},
</if>
<if
test=
"deviceType != null and deviceType != ''"
>
device_type = #{deviceType},
</if>
<if
test=
"createBy != null"
>
create_by = #{createBy},
</if>
...
...
thinglinks-modules/thinglinks-modules-link/src/main/resources/mapper/link/product/ProductMapper.xml
浏览文件 @
2d09434e
...
...
@@ -925,4 +925,38 @@
</if>
</where>
</select>
<!--Author By ShiHuan Sun E-mail: 13733918655@163.com on 2022-04-27-->
<select
id=
"findOneByProductIdentificationAndProtocolType"
resultMap=
"BaseResultMap"
>
select
<include
refid=
"Base_Column_List"
/>
from product
<where>
<if
test=
"productIdentification != null"
>
and product_identification=#{productIdentification,jdbcType=VARCHAR}
</if>
<if
test=
"protocolType != null"
>
and protocol_type=#{protocolType,jdbcType=VARCHAR}
</if>
</where>
</select>
<!--Author By ShiHuan Sun E-mail: 13733918655@163.com on 2022-04-27-->
<select
id=
"findAllByIdInAndStatus"
resultMap=
"BaseResultMap"
>
select
<include
refid=
"Base_Column_List"
/>
from product
<where>
<if
test=
"idCollection != null and idCollection.size() > 0"
>
and id in
<foreach
item=
"item"
index=
"index"
collection=
"idCollection"
open=
"("
separator=
","
close=
")"
>
#{item,jdbcType=BIGINT}
</foreach>
</if>
<if
test=
"status != null"
>
and `status`=#{status,jdbcType=VARCHAR}
</if>
</where>
</select>
</mapper>
\ No newline at end of file
thinglinks-modules/thinglinks-modules-protocolAnalysis/src/main/java/com/mqttsnet/thinglinks/protocolAnalysis/tcpServer/TcpServer.java
浏览文件 @
2d09434e
...
...
@@ -14,6 +14,7 @@ import lombok.extern.slf4j.Slf4j;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.cloud.context.config.annotation.RefreshScope
;
import
org.springframework.stereotype.Component
;
import
javax.annotation.PostConstruct
;
/**
...
...
thinglinks-modules/thinglinks-modules-protocolAnalysis/src/main/resources/bootstrap.yml
浏览文件 @
2d09434e
...
...
@@ -11,6 +11,7 @@ spring:
# 环境配置
active
:
dev
main
:
allow-circular-references
:
true
allow-bean-definition-overriding
:
true
cloud
:
nacos
:
...
...
thinglinks-modules/thinglinks-modules-system/src/main/resources/bootstrap.yml
浏览文件 @
2d09434e
...
...
@@ -11,6 +11,7 @@ spring:
# 环境配置
active
:
dev
main
:
allow-circular-references
:
true
allow-bean-definition-overriding
:
true
cloud
:
nacos
:
...
...
thinglinks-modules/thinglinks-modules-tdengine/readme.md
浏览文件 @
2d09434e
## TDengine SpringBoot + Mybatis Demo
## 超级表设计概念:每个设备一张表,每类设备一个超级表 ;
## 超级表命名规则 : 产品类型_产品标识_服务名称
## 子表命名规则 : 产品类型_产品标识_服务名称_设备标识(
非ClientId
)
## 子表命名规则 : 产品类型_产品标识_服务名称_设备标识(
设备唯一标识
)
## TDengine 服务端版本及搭建
...
...
thinglinks-modules/thinglinks-modules-tdengine/src/main/java/com/mqttsnet/thinglinks/tdengine/common/consumer/ProductCreateSuperTableMessageConsumer.java
浏览文件 @
2d09434e
...
...
@@ -41,7 +41,7 @@ public class ProductCreateSuperTableMessageConsumer implements RocketMQListener
return
;
}
JSONObject
stableMessage
=
JSONObject
.
parseObject
(
String
.
valueOf
(
message
));
log
.
info
(
"TDengine消费{}超级表消息:{}"
+
stableMessage
.
get
(
"type"
)+
stableMessage
.
get
(
"msg"
));
log
.
info
(
"TDengine消费{}超级表消息:{}"
,
stableMessage
.
get
(
"type"
),
stableMessage
.
get
(
"msg"
));
if
(
"create"
.
equals
(
stableMessage
.
get
(
"type"
))){
try
{
productSuperTableCreateOrUpdateService
.
createProductSuperTable
(
String
.
valueOf
(
stableMessage
.
get
(
"msg"
)));
...
...
thinglinks-modules/thinglinks-modules-tdengine/src/main/java/com/mqttsnet/thinglinks/tdengine/service/impl/TdEngineServiceImpl.java
浏览文件 @
2d09434e
...
...
@@ -100,8 +100,8 @@ public class TdEngineServiceImpl implements TdEngineService {
Integer
count
=
tdEngineMapper
.
checkTableExists
(
dataBaseName
,
tableName
);
return
count
==
1
;
}
catch
(
Exception
e
)
{
log
.
error
(
"检
测{}表失败
"
,
e
.
getMessage
());
return
tru
e
;
log
.
error
(
"检
查数据库表是否存在{}
"
,
e
.
getMessage
());
return
fals
e
;
}
}
...
...
thinglinks-modules/thinglinks-modules-tdengine/src/main/resources/bootstrap.yml
浏览文件 @
2d09434e
...
...
@@ -11,6 +11,7 @@ spring:
# 环境配置
active
:
dev
main
:
allow-circular-references
:
true
allow-bean-definition-overriding
:
true
cloud
:
nacos
:
...
...
thinglinks-ui/src/views/link/device/index.vue
浏览文件 @
2d09434e
...
...
@@ -77,19 +77,10 @@
@
keyup.enter.native=
"handleQuery"
/>
</el-form-item>
<el-form-item
label=
"产品
型号"
prop=
"productId
"
>
<el-form-item
label=
"产品
标识"
prop=
"productIdentification
"
>
<el-input
v-model=
"queryParams.productId"
placeholder=
"请输入产品型号"
clearable
size=
"small"
@
keyup.enter.native=
"handleQuery"
/>
</el-form-item>
<el-form-item
label=
"厂商ID"
prop=
"manufacturerId"
>
<el-input
v-model=
"queryParams.manufacturerId"
placeholder=
"请输入厂商ID"
v-model=
"queryParams.productIdentification"
placeholder=
"请输入产品标识"
clearable
size=
"small"
@
keyup.enter.native=
"handleQuery"
...
...
@@ -213,8 +204,7 @@
</
template
>
</el-table-column>
<el-table-column
label=
"设备标签"
align=
"center"
prop=
"deviceTags"
/>
<el-table-column
label=
"产品型号"
align=
"center"
prop=
"productId"
/>
<el-table-column
label=
"厂商ID"
align=
"center"
prop=
"manufacturerId"
/>
<el-table-column
label=
"产品标识"
align=
"center"
prop=
"productIdentification"
/>
<el-table-column
label=
"产品协议类型"
align=
"center"
prop=
"protocolType"
width=
"100"
>
<
template
slot-scope=
"scope"
>
<dict-tag
:options=
"dict.type.link_device_protocol_type"
:value=
"scope.row.protocolType"
/>
...
...
@@ -387,13 +377,8 @@
<
el
-
row
>
<
el
-
col
:
span
=
"
11
"
>
<
el
-
form
-
item
label
=
"
产品型号
"
prop
=
"
productId
"
>
<
el
-
input
v
-
model
=
"
form.productId
"
placeholder
=
"
请输入产品型号
"
/>
<
/el-form-item
>
<
/el-col
>
<
el
-
col
:
span
=
"
11
"
>
<
el
-
form
-
item
label
=
"
厂商ID
"
prop
=
"
manufacturerId
"
>
<
el
-
input
v
-
model
=
"
form.manufacturerId
"
placeholder
=
"
请输入厂商ID
"
/>
<
el
-
form
-
item
label
=
"
产品标识
"
prop
=
"
productIdentification
"
>
<
el
-
input
v
-
model
=
"
form.productIdentification
"
placeholder
=
"
请输入产品标识
"
/>
<
/el-form-item
>
<
/el-col
>
<
/el-row
>
...
...
@@ -491,8 +476,7 @@ export default {
connectStatus
:
null
,
isWill
:
null
,
deviceTags
:
null
,
productId
:
null
,
manufacturerId
:
null
,
productIdentification
:
null
,
protocolType
:
null
,
deviceType
:
null
,
}
,
...
...
@@ -533,11 +517,8 @@ export default {
deviceStatus
:
[
{
required
:
true
,
message
:
"
设备状态不能为空
"
,
trigger
:
"
change
"
}
],
productId
:
[
{
required
:
true
,
message
:
"
产品型号不能为空
"
,
trigger
:
"
blur
"
}
],
manufacturerId
:
[
{
required
:
true
,
message
:
"
厂商ID不能为空
"
,
trigger
:
"
blur
"
}
productIdentification
:
[
{
required
:
true
,
message
:
"
产品标识不能为空
"
,
trigger
:
"
blur
"
}
],
protocolType
:
[
{
required
:
true
,
message
:
"
产品协议类型不能为空
"
,
trigger
:
"
change
"
}
...
...
@@ -597,8 +578,7 @@ export default {
connectStatus
:
null
,
isWill
:
null
,
deviceTags
:
null
,
productId
:
null
,
manufacturerId
:
null
,
productIdentification
:
null
,
protocolType
:
null
,
deviceType
:
null
,
createBy
:
null
,
...
...
thinglinks-visual/thinglinks-visual-collection/src/main/resources/bootstrap.yml
浏览文件 @
2d09434e
...
...
@@ -11,6 +11,7 @@ spring:
# 环境配置
active
:
dev
main
:
allow-circular-references
:
true
allow-bean-definition-overriding
:
true
cloud
:
nacos
:
...
...
thinglinks-visual/thinglinks-visual-monitor/src/main/resources/bootstrap.yml
浏览文件 @
2d09434e
...
...
@@ -11,6 +11,7 @@ spring:
# 环境配置
active
:
dev
main
:
allow-circular-references
:
true
allow-bean-definition-overriding
:
true
cloud
:
nacos
:
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录