Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
I
iot-service
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Container Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
SuperHive
back-end
iot-service
Commits
c54b9127
Commit
c54b9127
authored
Aug 04, 2020
by
huangcb
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
新增/删除模型实例时,新增/删除模型实例Topic
parent
b35e36bd
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
74 additions
and
8 deletions
+74
-8
InstanceTopicService.java
...enter/iot/module/omodel/service/InstanceTopicService.java
+18
-0
InstanceTopicServiceImpl.java
.../module/omodel/service/impl/InstanceTopicServiceImpl.java
+23
-0
ObjectModelInstanceServiceImpl.java
...e/omodel/service/impl/ObjectModelInstanceServiceImpl.java
+12
-2
ObjectModelServiceImpl.java
...ot/module/omodel/service/impl/ObjectModelServiceImpl.java
+1
-2
application-demo.yml
src/main/resources/application-demo.yml
+5
-1
application-dev.yml
src/main/resources/application-dev.yml
+5
-1
application-local.yml
src/main/resources/application-local.yml
+5
-1
application-test.yml
src/main/resources/application-test.yml
+5
-1
No files found.
src/main/java/com/esv/datacenter/iot/module/omodel/service/InstanceTopicService.java
View file @
c54b9127
...
...
@@ -12,5 +12,23 @@ import com.esv.datacenter.iot.module.omodel.entity.InstanceTopicEntity;
*/
public
interface
InstanceTopicService
extends
IService
<
InstanceTopicEntity
>
{
/**
* @description 新增模型实例Topic
* @param modelId:
* @param instanceId:
* @return void
* @author huangChaobin@esvtek.com
* @createTime 2020/08/04 11:22
**/
void
insertTopic
(
Long
modelId
,
Long
instanceId
);
/**
* @description 删除模型实例Topic
* @param instanceId:
* @return void
* @author huangChaobin@esvtek.com
* @createTime 2020/08/04 11:22
**/
void
deleteTopic
(
Long
instanceId
);
}
src/main/java/com/esv/datacenter/iot/module/omodel/service/impl/InstanceTopicServiceImpl.java
View file @
c54b9127
package
com
.
esv
.
datacenter
.
iot
.
module
.
omodel
.
service
.
impl
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
com.esv.datacenter.iot.module.omodel.dao.InstanceTopicDao
;
import
com.esv.datacenter.iot.module.omodel.entity.InstanceTopicEntity
;
import
com.esv.datacenter.iot.module.omodel.service.InstanceTopicService
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.cloud.context.config.annotation.RefreshScope
;
import
org.springframework.stereotype.Service
;
@Service
(
"instanceTopicService"
)
@RefreshScope
public
class
InstanceTopicServiceImpl
extends
ServiceImpl
<
InstanceTopicDao
,
InstanceTopicEntity
>
implements
InstanceTopicService
{
@Value
(
"${mqtt.topic.instance.data-upload}"
)
private
String
instanceDataUploadTopic
;
@Override
public
void
insertTopic
(
Long
modelId
,
Long
instanceId
)
{
String
topic
=
instanceDataUploadTopic
.
replaceFirst
(
"[model_id]"
,
String
.
valueOf
(
modelId
))
.
replaceFirst
(
"[instance_id]"
,
String
.
valueOf
(
instanceId
));
InstanceTopicEntity
entity
=
new
InstanceTopicEntity
();
entity
.
setModelId
(
modelId
);
entity
.
setInstanceId
(
instanceId
);
entity
.
setTopic
(
topic
);
this
.
getBaseMapper
().
insert
(
entity
);
}
@Override
public
void
deleteTopic
(
Long
instanceId
)
{
this
.
getBaseMapper
().
delete
(
new
LambdaQueryWrapper
<
InstanceTopicEntity
>().
eq
(
InstanceTopicEntity:
:
getInstanceId
,
instanceId
));
}
}
\ No newline at end of file
src/main/java/com/esv/datacenter/iot/module/omodel/service/impl/ObjectModelInstanceServiceImpl.java
View file @
c54b9127
...
...
@@ -12,6 +12,7 @@ import com.esv.datacenter.iot.module.omodel.dao.ObjectModelInstanceDao;
import
com.esv.datacenter.iot.module.omodel.entity.ObjectModelEntity
;
import
com.esv.datacenter.iot.module.omodel.entity.ObjectModelInstanceEntity
;
import
com.esv.datacenter.iot.module.omodel.form.ModelInstanceForm
;
import
com.esv.datacenter.iot.module.omodel.service.InstanceTopicService
;
import
com.esv.datacenter.iot.module.omodel.service.ObjectModelInstanceService
;
import
com.esv.datacenter.iot.module.omodel.service.ObjectModelService
;
import
com.esv.datacenter.iot.module.omodel.vo.ModelInstanceDetailVO
;
...
...
@@ -19,6 +20,7 @@ import com.esv.datacenter.iot.module.omodel.vo.ModelInstanceVO;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
java.util.ArrayList
;
import
java.util.List
;
...
...
@@ -29,6 +31,8 @@ public class ObjectModelInstanceServiceImpl extends ServiceImpl<ObjectModelInsta
@Autowired
ObjectModelService
objectModelService
;
@Autowired
InstanceTopicService
instanceTopicService
;
@Override
public
List
<
ModelInstanceVO
>
getModelInstanceList
(
Long
modelId
)
{
...
...
@@ -67,6 +71,7 @@ public class ObjectModelInstanceServiceImpl extends ServiceImpl<ObjectModelInsta
}
@Override
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
Long
createModelInstance
(
ModelInstanceForm
form
)
{
// 模型实例名称校验
int
instanceCount
=
this
.
getBaseMapper
().
selectCount
(
new
LambdaQueryWrapper
<
ObjectModelInstanceEntity
>()
...
...
@@ -81,8 +86,12 @@ public class ObjectModelInstanceServiceImpl extends ServiceImpl<ObjectModelInsta
ObjectModelInstanceEntity
entity
=
new
ObjectModelInstanceEntity
();
BeanUtils
.
copyProperties
(
form
,
entity
);
this
.
getBaseMapper
().
insert
(
entity
);
Long
instanceId
=
entity
.
getId
();
// 新增模型实例Topic
this
.
instanceTopicService
.
insertTopic
(
form
.
getModelId
(),
instanceId
);
return
entity
.
getId
()
;
return
instanceId
;
}
@Override
...
...
@@ -110,7 +119,8 @@ public class ObjectModelInstanceServiceImpl extends ServiceImpl<ObjectModelInsta
public
void
deleteModelInstance
(
Long
id
)
{
this
.
getBaseMapper
().
deleteById
(
id
);
// TODO,删除时序数据
// 删除模型实例Topic
this
.
instanceTopicService
.
deleteTopic
(
id
);
}
@Override
...
...
src/main/java/com/esv/datacenter/iot/module/omodel/service/impl/ObjectModelServiceImpl.java
View file @
c54b9127
...
...
@@ -202,8 +202,7 @@ public class ObjectModelServiceImpl extends ServiceImpl<ObjectModelDao, ObjectMo
@Override
public
Boolean
isModelExits
(
Long
modelId
)
{
int
count
=
this
.
getBaseMapper
().
selectCount
(
new
LambdaQueryWrapper
<
ObjectModelEntity
>()
.
eq
(
ObjectModelEntity:
:
getId
,
modelId
)
.
eq
(
ObjectModelEntity:
:
getDeleted
,
DbDeletedEnum
.
NO
.
getCode
()));
.
eq
(
ObjectModelEntity:
:
getId
,
modelId
));
if
(
0
==
count
)
{
return
false
;
}
else
{
...
...
src/main/resources/application-demo.yml
View file @
c54b9127
...
...
@@ -85,4 +85,8 @@ timescale:
max-lifetime
:
0
table-field
:
map
:
string-text,number-numeric,boolean-bit(1)
table-prefix
:
iot_model_
\ No newline at end of file
table-prefix
:
iot_model_
mqtt
:
topic
:
instance
:
data-upload
:
$esv/iot/[model_id]/[instance_id]/data/upload
\ No newline at end of file
src/main/resources/application-dev.yml
View file @
c54b9127
...
...
@@ -85,4 +85,8 @@ timescale:
max-lifetime
:
0
table-field
:
map
:
string-text,number-numeric,boolean-bit(1)
table-prefix
:
iot_model_
\ No newline at end of file
table-prefix
:
iot_model_
mqtt
:
topic
:
instance
:
data-upload
:
$esv/iot/[model_id]/[instance_id]/data/upload
\ No newline at end of file
src/main/resources/application-local.yml
View file @
c54b9127
...
...
@@ -85,4 +85,8 @@ timescale:
max-lifetime
:
0
table-field
:
map
:
string-text,number-numeric,boolean-bit(1)
table-prefix
:
iot_model_
\ No newline at end of file
table-prefix
:
iot_model_
mqtt
:
topic
:
instance
:
data-upload
:
$esv/iot/[model_id]/[instance_id]/data/upload
\ No newline at end of file
src/main/resources/application-test.yml
View file @
c54b9127
...
...
@@ -85,4 +85,8 @@ timescale:
max-lifetime
:
0
table-field
:
map
:
string-text,number-numeric,boolean-bit(1)
table-prefix
:
iot_model_
\ No newline at end of file
table-prefix
:
iot_model_
mqtt
:
topic
:
instance
:
data-upload
:
$esv/iot/[model_id]/[instance_id]/data/upload
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment