Commit ae98cb4d55a96c2fa7ee7118d33587798729c71a
Merge branch 'cherry-pick-c740ed66' into 'master_dev'
fix:删除设备上下线历史记录的数据同步 See merge request yunteng/thingskit!464
Showing
5 changed files
with
0 additions
and
212 deletions
... | ... | @@ -90,7 +90,6 @@ import org.thingsboard.server.service.edge.rpc.yunteng.tk_configuration_center.T |
90 | 90 | import org.thingsboard.server.service.edge.rpc.yunteng.tk_configuration_content.TkConfigurationContentRepository; |
91 | 91 | import org.thingsboard.server.service.edge.rpc.yunteng.tk_configuration_content_node.TkConfigurationContentNodeRepository; |
92 | 92 | import org.thingsboard.server.service.edge.rpc.yunteng.tk_device_profile_category.TkDeviceProfileCategoryRepository; |
93 | -import org.thingsboard.server.service.edge.rpc.yunteng.tk_device_state_log.TkDeviceStateLogRepository; | |
94 | 93 | import org.thingsboard.server.service.edge.rpc.yunteng.tk_event_kv.TkEventKvRepository; |
95 | 94 | import org.thingsboard.server.service.edge.rpc.yunteng.tk_java_script.TkJavaScriptRepository; |
96 | 95 | import org.thingsboard.server.service.edge.rpc.yunteng.tk_message_config.MessageConfigRepository; |
... | ... | @@ -309,8 +308,6 @@ public class EdgeContextComponent { |
309 | 308 | @Autowired |
310 | 309 | private final TkDeviceProfileCategoryRepository tkDeviceProfileCategoryRepository; |
311 | 310 | @Autowired |
312 | - private final TkDeviceStateLogRepository tkDeviceStateLogRepository; | |
313 | - @Autowired | |
314 | 311 | private final TkEventKvRepository tkEventKvRepository; |
315 | 312 | @Autowired |
316 | 313 | private final TkJavaScriptRepository tkJavaScriptRepository; | ... | ... |
... | ... | @@ -49,7 +49,6 @@ import org.thingsboard.server.service.edge.rpc.yunteng.tk_configuration_center.T |
49 | 49 | import org.thingsboard.server.service.edge.rpc.yunteng.tk_configuration_content.TkConfigurationContentEdgeEventFetcher; |
50 | 50 | import org.thingsboard.server.service.edge.rpc.yunteng.tk_configuration_content_node.TkConfigurationContentNodeEdgeEventFetcher; |
51 | 51 | import org.thingsboard.server.service.edge.rpc.yunteng.tk_device_profile_category.TkDeviceProfileCategoryEdgeEventFetcher; |
52 | -import org.thingsboard.server.service.edge.rpc.yunteng.tk_device_state_log.TkDeviceStateLogEdgeEventFetcher; | |
53 | 52 | import org.thingsboard.server.service.edge.rpc.yunteng.tk_java_script.TkJavaScriptEdgeEventFetcher; |
54 | 53 | import org.thingsboard.server.service.edge.rpc.yunteng.tk_message_config.MessageConfigEdgeEventFetcher; |
55 | 54 | import org.thingsboard.server.service.edge.rpc.yunteng.tk_message_template.TkMessageTemplateEdgeEventFetcher; |
... | ... | @@ -83,7 +82,6 @@ public class EdgeSyncCursor { |
83 | 82 | } |
84 | 83 | //如果点击同步才会触发 |
85 | 84 | //thingsKit |
86 | - fetchers.add(new TkDeviceStateLogEdgeEventFetcher(ctx.getTkDeviceStateLogRepository())); | |
87 | 85 | fetchers.add(new SysDictEdgeEventFetcher(ctx.getSysDictRepository()));//数据字典 |
88 | 86 | fetchers.add(new TkThingsModelEdgeEventFetcher(ctx.getTkThingsModelRepository()));//物模型 |
89 | 87 | fetchers.add(new TkDeviceProfileCategoryEdgeEventFetcher(ctx.getTkDeviceProfileCategoryRepository()));//产品品类 | ... | ... |
application/src/main/java/org/thingsboard/server/service/edge/rpc/yunteng/tk_device_state_log/TkDeviceStateLogEdgeEventFetcher.java
deleted
100644 → 0
1 | -/** | |
2 | - * Copyright © 2016-2024 The Thingsboard Authors | |
3 | - * | |
4 | - * Licensed under the Apache License, Version 2.0 (the "License"); | |
5 | - * you may not use this file except in compliance with the License. | |
6 | - * You may obtain a copy of the License at | |
7 | - * | |
8 | - * http://www.apache.org/licenses/LICENSE-2.0 | |
9 | - * | |
10 | - * Unless required by applicable law or agreed to in writing, software | |
11 | - * distributed under the License is distributed on an "AS IS" BASIS, | |
12 | - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
13 | - * See the License for the specific language governing permissions and | |
14 | - * limitations under the License. | |
15 | - */ | |
16 | -package org.thingsboard.server.service.edge.rpc.yunteng.tk_device_state_log; | |
17 | - | |
18 | -import lombok.AllArgsConstructor; | |
19 | -import lombok.extern.slf4j.Slf4j; | |
20 | -import org.thingsboard.server.common.data.EdgeUtils; | |
21 | -import org.thingsboard.server.common.data.edge.Edge; | |
22 | -import org.thingsboard.server.common.data.edge.EdgeEvent; | |
23 | -import org.thingsboard.server.common.data.edge.EdgeEventActionType; | |
24 | -import org.thingsboard.server.common.data.edge.EdgeEventType; | |
25 | -import org.thingsboard.server.common.data.id.TenantId; | |
26 | -import org.thingsboard.server.common.data.page.PageData; | |
27 | -import org.thingsboard.server.common.data.page.PageLink; | |
28 | -import org.thingsboard.server.common.data.yunteng.sync.TkDeviceStateLog; | |
29 | -import org.thingsboard.server.service.edge.rpc.fetch.BasePageableEdgeEventFetcher; | |
30 | - | |
31 | -@AllArgsConstructor | |
32 | -@Slf4j | |
33 | -public class TkDeviceStateLogEdgeEventFetcher extends BasePageableEdgeEventFetcher<TkDeviceStateLog> { | |
34 | - | |
35 | - private final TkDeviceStateLogRepository tkDeviceStateLogRepository ; | |
36 | - | |
37 | - @Override | |
38 | - protected PageData<TkDeviceStateLog> fetchPageData(TenantId tenantId, Edge edge, PageLink pageLink) { | |
39 | - // returns PageData object to be in sync with other fetchers | |
40 | - return tkDeviceStateLogRepository.selectToEdge(tenantId,edge.getId(),pageLink); | |
41 | - } | |
42 | - | |
43 | - @Override | |
44 | - public EdgeEvent constructEdgeEvent(TenantId tenantId, Edge edge, TkDeviceStateLog entity) { | |
45 | - return EdgeUtils.constructEdgeEvent(tenantId, edge.getId(), EdgeEventType.TK_DEVICE_STATE_LOG, | |
46 | - EdgeEventActionType.UPDATED, entity.getId(), null); | |
47 | - } | |
48 | -} |
application/src/main/java/org/thingsboard/server/service/edge/rpc/yunteng/tk_device_state_log/TkDeviceStateLogEdgeProcessor.java
deleted
100644 → 0
1 | -package org.thingsboard.server.service.edge.rpc.yunteng.tk_device_state_log; | |
2 | - | |
3 | -import lombok.AllArgsConstructor; | |
4 | -import lombok.extern.slf4j.Slf4j; | |
5 | -import org.springframework.stereotype.Component; | |
6 | -import org.thingsboard.common.util.JacksonUtil; | |
7 | -import org.thingsboard.server.common.data.EntityType; | |
8 | -import org.thingsboard.server.common.data.yunteng.sync.TkDeviceStateLog; | |
9 | -import org.thingsboard.server.common.data.edge.EdgeEventType; | |
10 | -import org.thingsboard.server.common.data.id.EdgeId; | |
11 | -import org.thingsboard.server.common.data.id.TenantId; | |
12 | -import org.thingsboard.server.common.data.yunteng.id.TkDeviceStateLogId; | |
13 | -import org.thingsboard.server.common.data.yunteng.id.EntityIdProvider; | |
14 | -import org.thingsboard.server.gen.edge.v1.TkUpdateMsg; | |
15 | -import org.thingsboard.server.queue.util.TbCoreComponent; | |
16 | -import org.thingsboard.server.service.edge.rpc.yunteng.TkEdgeProcessor; | |
17 | -import org.thingsboard.server.service.edge.rpc.yunteng.TkEdgeProcessorRepository; | |
18 | - | |
19 | -import java.util.UUID; | |
20 | - | |
21 | -@Slf4j | |
22 | -@Component | |
23 | -@AllArgsConstructor | |
24 | -@TbCoreComponent | |
25 | -public class TkDeviceStateLogEdgeProcessor extends TkEdgeProcessor<TkDeviceStateLogId, TkDeviceStateLog> { | |
26 | - | |
27 | - TkDeviceStateLogRepository tkDeviceStateLogRepository; | |
28 | - | |
29 | - @Override | |
30 | - public EntityType getEntityType() { | |
31 | - return EntityType.TK_DEVICE_STATE_LOG; | |
32 | - } | |
33 | - | |
34 | - @Override | |
35 | - public EdgeEventType getEdgeEventType() { | |
36 | - return EdgeEventType.TK_DEVICE_STATE_LOG; | |
37 | - } | |
38 | - | |
39 | - @Override | |
40 | - public TkEdgeProcessorRepository<TkDeviceStateLog> getEdgeProcessorRepository() { | |
41 | - return tkDeviceStateLogRepository; | |
42 | - } | |
43 | - | |
44 | - @Override | |
45 | - public EntityIdProvider<TkDeviceStateLogId> getEntityIdProvider() { | |
46 | - return new EntityIdProvider<TkDeviceStateLogId>() { | |
47 | - @Override | |
48 | - public TkDeviceStateLogId fromString(String uuid) { | |
49 | - return TkDeviceStateLogId.fromString(uuid); | |
50 | - } | |
51 | - | |
52 | - @Override | |
53 | - public TkDeviceStateLogId fromUUID(UUID uuid) { | |
54 | - return new TkDeviceStateLogId(uuid); | |
55 | - } | |
56 | - }; | |
57 | - } | |
58 | - | |
59 | - @Override | |
60 | - public TkDeviceStateLog constructEntityFromUpdateMsg(TenantId tenantId, EdgeId edgeId, TkUpdateMsg tkUpdateMsg) { | |
61 | - return JacksonUtil.fromString(tkUpdateMsg.getEntity(), TkDeviceStateLog.class, true); | |
62 | - } | |
63 | -} |
application/src/main/java/org/thingsboard/server/service/edge/rpc/yunteng/tk_device_state_log/TkDeviceStateLogRepository.java
deleted
100644 → 0
1 | -package org.thingsboard.server.service.edge.rpc.yunteng.tk_device_state_log; | |
2 | - | |
3 | -import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; | |
4 | -import com.baomidou.mybatisplus.core.metadata.IPage; | |
5 | -import com.baomidou.mybatisplus.core.toolkit.Wrappers; | |
6 | -import com.baomidou.mybatisplus.extension.plugins.pagination.Page; | |
7 | -import lombok.AllArgsConstructor; | |
8 | -import lombok.extern.slf4j.Slf4j; | |
9 | -import org.springframework.beans.BeanUtils; | |
10 | -import org.springframework.stereotype.Repository; | |
11 | -import org.thingsboard.server.common.data.yunteng.id.TkDeviceStateLogId; | |
12 | -import org.thingsboard.server.common.data.yunteng.sync.TkDeviceStateLog; | |
13 | -import org.thingsboard.server.common.data.id.*; | |
14 | -import org.thingsboard.server.common.data.page.PageData; | |
15 | -import org.thingsboard.server.common.data.page.PageLink; | |
16 | -import org.thingsboard.server.common.data.yunteng.utils.CopyUtils; | |
17 | -import org.thingsboard.server.dao.yunteng.entities.TkDeviceStateLogEntity; | |
18 | -import org.thingsboard.server.dao.yunteng.mapper.TkDeviceStateLogMapper; | |
19 | -import org.thingsboard.server.service.edge.rpc.yunteng.TkEdgeProcessorRepository; | |
20 | - | |
21 | -import java.util.List; | |
22 | -import java.util.UUID; | |
23 | -import java.util.stream.Collectors; | |
24 | - | |
25 | -@Repository | |
26 | -@AllArgsConstructor | |
27 | -@Slf4j | |
28 | -public class TkDeviceStateLogRepository implements TkEdgeProcessorRepository<TkDeviceStateLog> { | |
29 | - private TkDeviceStateLogMapper tkDeviceStateLogMapper; | |
30 | - @Override | |
31 | - public boolean updateFromEdge(TenantId tenantId, EdgeId edgeId, TkDeviceStateLog dto) throws Exception { | |
32 | - log.info("updateFromEdge {} , {} , {} , {}",tenantId,edgeId,dto.getId().getEntityType(),dto); | |
33 | - | |
34 | - TkDeviceStateLogEntity model = tkDeviceStateLogMapper.selectById(dto.getId().getId().toString()); | |
35 | - if (model == null) { | |
36 | - model = new TkDeviceStateLogEntity(); | |
37 | - CopyUtils.copyProperties(dto, model); | |
38 | - model.setId(dto.getId().toString()); | |
39 | - model.setTenantId(dto.getTenantId().getId().toString()); | |
40 | - return tkDeviceStateLogMapper.insert(model)>0; | |
41 | - } else { | |
42 | - CopyUtils.copyProperties(dto, model); | |
43 | - model.setId(dto.getId().toString()); | |
44 | - model.setTenantId(dto.getTenantId().getId().toString()); | |
45 | - return tkDeviceStateLogMapper.updateById(model)>0; | |
46 | - } | |
47 | - } | |
48 | - | |
49 | - @Override | |
50 | - public boolean deleteFromEdge(TenantId tenantId, EdgeId edgeId, EntityId entityId) throws Exception { | |
51 | - log.info("deleteFromEdge {} , {} , {}",tenantId,edgeId,entityId); | |
52 | - | |
53 | - LambdaQueryWrapper<TkDeviceStateLogEntity> queryWrapper = Wrappers.lambdaQuery(); | |
54 | - queryWrapper.eq(TkDeviceStateLogEntity::getTenantId, tenantId.getId().toString()); | |
55 | - queryWrapper.eq(TkDeviceStateLogEntity::getId, entityId.getId().toString()); | |
56 | - return tkDeviceStateLogMapper.delete(queryWrapper)>0; | |
57 | - } | |
58 | - | |
59 | - @Override | |
60 | - public PageData<TkDeviceStateLog> selectToEdge(TenantId tenantId, EdgeId edgeId, PageLink pageLink) { | |
61 | - log.info("selectToEdge {} , {} , {}/{}",tenantId,edgeId,pageLink.getPage(),pageLink.getPageSize()); | |
62 | - | |
63 | - LambdaQueryWrapper<TkDeviceStateLogEntity> queryWrapper = Wrappers.lambdaQuery(); | |
64 | - queryWrapper.eq(TkDeviceStateLogEntity::getTenantId, tenantId.getId().toString()); | |
65 | - Page<TkDeviceStateLogEntity> queryPage = new Page<>(pageLink.getPage(), pageLink.getPageSize()); | |
66 | - IPage<TkDeviceStateLogEntity> resultPage = tkDeviceStateLogMapper.selectPage(queryPage, queryWrapper); | |
67 | - return new PageData((List) resultPage.getRecords().stream().map(e->{ | |
68 | - return toData(e); | |
69 | - }).collect(Collectors.toList()), (int) resultPage.getPages(), resultPage.getTotal(), resultPage.getCurrent()<resultPage.getPages()); | |
70 | - } | |
71 | - | |
72 | - @Override | |
73 | - public List<TkDeviceStateLog> selectToEdge(TenantId tenantId, EdgeId edgeId, EntityId entityId) { | |
74 | - log.info("selectToEdge {} , {} , {}",tenantId,edgeId,entityId); | |
75 | - | |
76 | - LambdaQueryWrapper<TkDeviceStateLogEntity> queryWrapper = Wrappers.lambdaQuery(); | |
77 | - queryWrapper.eq(TkDeviceStateLogEntity::getTenantId, tenantId.getId().toString()); | |
78 | - queryWrapper.eq(TkDeviceStateLogEntity::getId, entityId.getId().toString()); | |
79 | - List<TkDeviceStateLogEntity> model= tkDeviceStateLogMapper.selectList(queryWrapper); | |
80 | - if(model!=null){ | |
81 | - return model.stream().map(e->{return toData(e);}).collect(Collectors.toList()); | |
82 | - } | |
83 | - else { | |
84 | - return null; | |
85 | - } | |
86 | - } | |
87 | - | |
88 | - | |
89 | - private TkDeviceStateLog toData(TkDeviceStateLogEntity e) { | |
90 | - TkDeviceStateLog data=new TkDeviceStateLog(); | |
91 | - CopyUtils.copyProperties(e,data); | |
92 | - data.setId(TkDeviceStateLogId.fromString(e.getId())); | |
93 | - data.setTenantId(TenantId.fromUUID(UUID.fromString(e.getTenantId()))); | |
94 | - return data; | |
95 | - } | |
96 | -} |