Commit 4670bb4c authored by huangcb's avatar huangcb

调整生成Topic代码

parent c54b9127
...@@ -14,13 +14,11 @@ import org.springframework.stereotype.Service; ...@@ -14,13 +14,11 @@ import org.springframework.stereotype.Service;
@RefreshScope @RefreshScope
public class InstanceTopicServiceImpl extends ServiceImpl<InstanceTopicDao, InstanceTopicEntity> implements InstanceTopicService { public class InstanceTopicServiceImpl extends ServiceImpl<InstanceTopicDao, InstanceTopicEntity> implements InstanceTopicService {
@Value("${mqtt.topic.instance.data-upload}") private static final String TOPIC_PREFIX = "$esv/iot/";
private String instanceDataUploadTopic;
@Override @Override
public void insertTopic(Long modelId, Long instanceId) { public void insertTopic(Long modelId, Long instanceId) {
String topic = instanceDataUploadTopic.replaceFirst("[model_id]", String.valueOf(modelId)) String topic = TOPIC_PREFIX + modelId + "/" + instanceId + "/data/upload";
.replaceFirst("[instance_id]", String.valueOf(instanceId));
InstanceTopicEntity entity = new InstanceTopicEntity(); InstanceTopicEntity entity = new InstanceTopicEntity();
entity.setModelId(modelId); entity.setModelId(modelId);
entity.setInstanceId(instanceId); entity.setInstanceId(instanceId);
......
...@@ -86,7 +86,3 @@ timescale: ...@@ -86,7 +86,3 @@ timescale:
table-field: table-field:
map: string-text,number-numeric,boolean-bit(1) map: string-text,number-numeric,boolean-bit(1)
table-prefix: iot_model_ table-prefix: iot_model_
mqtt:
topic:
instance:
data-upload: $esv/iot/[model_id]/[instance_id]/data/upload
\ No newline at end of file
...@@ -86,7 +86,3 @@ timescale: ...@@ -86,7 +86,3 @@ timescale:
table-field: table-field:
map: string-text,number-numeric,boolean-bit(1) map: string-text,number-numeric,boolean-bit(1)
table-prefix: iot_model_ table-prefix: iot_model_
mqtt:
topic:
instance:
data-upload: $esv/iot/[model_id]/[instance_id]/data/upload
\ No newline at end of file
...@@ -86,7 +86,3 @@ timescale: ...@@ -86,7 +86,3 @@ timescale:
table-field: table-field:
map: string-text,number-numeric,boolean-bit(1) map: string-text,number-numeric,boolean-bit(1)
table-prefix: iot_model_ table-prefix: iot_model_
mqtt:
topic:
instance:
data-upload: $esv/iot/[model_id]/[instance_id]/data/upload
\ No newline at end of file
...@@ -86,7 +86,3 @@ timescale: ...@@ -86,7 +86,3 @@ timescale:
table-field: table-field:
map: string-text,number-numeric,boolean-bit(1) map: string-text,number-numeric,boolean-bit(1)
table-prefix: iot_model_ table-prefix: iot_model_
mqtt:
topic:
instance:
data-upload: $esv/iot/[model_id]/[instance_id]/data/upload
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment