Commit 4b62145c1e9cf6baabbab1b32f34a0a70cb721cb
Merge branch 'perf/sync_configuration' into 'master_dev'
perf: 更新组态模板支持云端同步到边端 See merge request yunteng/thingskit!447
Showing
21 changed files
with
592 additions
and
604 deletions
1 | +--组态内容节点,增加一个字段 | |
2 | +alter table tk_configuration_content_node add configuration_node_id varchar(32); | |
3 | +COMMENT ON COLUMN "public"."tk_configuration_content_node"."configuration_node_id" IS '组态内容节点ID'; | |
4 | +--更新已存在的数据 | |
5 | +update tk_configuration_content_node set configuration_node_id = id; | |
6 | +--更新组态内容节点表的主键ID为uuid | |
7 | +CREATE EXTENSION IF NOT EXISTS "uuid-ossp"; | |
8 | +update tk_configuration_content_node set id = uuid_generate_v4(); | |
\ No newline at end of file | ... | ... |
1 | 1 | package org.thingsboard.server.controller.yunteng; |
2 | 2 | |
3 | -import com.fasterxml.jackson.databind.JsonNode; | |
4 | 3 | import io.swagger.annotations.Api; |
5 | 4 | import io.swagger.annotations.ApiOperation; |
6 | 5 | import io.swagger.annotations.ApiParam; |
7 | -import java.util.List; | |
8 | -import java.util.Optional; | |
9 | 6 | import lombok.RequiredArgsConstructor; |
10 | 7 | import org.apache.commons.lang3.StringUtils; |
11 | 8 | import org.springframework.http.ResponseEntity; |
... | ... | @@ -16,13 +13,9 @@ import org.thingsboard.server.common.data.yunteng.common.AddGroup; |
16 | 13 | import org.thingsboard.server.common.data.yunteng.core.exception.TkDataValidationException; |
17 | 14 | import org.thingsboard.server.common.data.yunteng.core.message.ErrorMessage; |
18 | 15 | import org.thingsboard.server.common.data.yunteng.dto.*; |
19 | -import org.thingsboard.server.common.data.yunteng.utils.JacksonUtil; | |
20 | 16 | import org.thingsboard.server.common.data.yunteng.utils.i18n.MessageUtils; |
21 | 17 | import org.thingsboard.server.controller.BaseController; |
22 | -import org.thingsboard.server.dao.yunteng.service.TkConfigurationActService; | |
23 | 18 | import org.thingsboard.server.dao.yunteng.service.TkConfigurationContentNodeService; |
24 | -import org.thingsboard.server.dao.yunteng.service.TkConfigurationDatasourceService; | |
25 | -import org.thingsboard.server.dao.yunteng.service.TkConfigurationEventService; | |
26 | 19 | import org.thingsboard.server.queue.util.TbCoreComponent; |
27 | 20 | |
28 | 21 | /** |
... | ... | @@ -67,10 +60,10 @@ public class TkConfigurationContentNodeController extends BaseController { |
67 | 60 | @GetMapping("/getNode") |
68 | 61 | @ApiOperation("组件信息") |
69 | 62 | public ResponseEntity<ConfigurationContentNodeDTO> nodeInform( |
70 | - @RequestParam("id") String id , | |
63 | + @RequestParam("configurationNodeId") String configurationNodeId , | |
71 | 64 | @RequestParam("configurationId") String configurationId, |
72 | 65 | @RequestParam("contentId") String contentId)throws ThingsboardException { |
73 | - return ResponseEntity.ok(nodeService.get(id,configurationId,contentId, getCurrentUser().getCurrentTenantId())); | |
66 | + return ResponseEntity.ok(nodeService.get(configurationNodeId,configurationId,contentId, getCurrentUser().getCurrentTenantId())); | |
74 | 67 | } |
75 | 68 | |
76 | 69 | } | ... | ... |
1 | -//package org.thingsboard.server.service.edge.rpc.yunteng.tk_configuration_center; | |
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.edge.EdgeEventType; | |
9 | -//import org.thingsboard.server.common.data.id.EdgeId; | |
10 | -//import org.thingsboard.server.common.data.id.TenantId; | |
11 | -//import org.thingsboard.server.common.data.yunteng.id.EntityIdProvider; | |
12 | -//import org.thingsboard.server.common.data.yunteng.id.TkConfigurationCenterId; | |
13 | -//import org.thingsboard.server.common.data.yunteng.sync.TkConfigurationCenter; | |
14 | -//import org.thingsboard.server.gen.edge.v1.TkUpdateMsg; | |
15 | -//import org.thingsboard.server.service.edge.rpc.yunteng.TkEdgeProcessor; | |
16 | -//import org.thingsboard.server.service.edge.rpc.yunteng.TkEdgeProcessorRepository; | |
17 | -// | |
18 | -//import java.util.UUID; | |
19 | -// | |
20 | -//@Slf4j | |
21 | -//@Component | |
22 | -//@AllArgsConstructor | |
23 | -//public class TkConfigurationCenterEdgeProcessor extends TkEdgeProcessor<TkConfigurationCenterId, TkConfigurationCenter> { | |
24 | -// | |
25 | -// TkConfigurationCenterRepository tkConfigurationCenterRepository; | |
26 | -// | |
27 | -// @Override | |
28 | -// public EntityType getEntityType() { | |
29 | -// return EntityType.TK_CONFIGURATION_CENTER; | |
30 | -// } | |
31 | -// | |
32 | -// @Override | |
33 | -// public EdgeEventType getEdgeEventType() { | |
34 | -// return EdgeEventType.TK_CONFIGURATION_CENTER; | |
35 | -// } | |
36 | -// | |
37 | -// @Override | |
38 | -// public TkEdgeProcessorRepository<TkConfigurationCenter> getEdgeProcessorRepository() { | |
39 | -// return tkConfigurationCenterRepository; | |
40 | -// } | |
41 | -// | |
42 | -// @Override | |
43 | -// public EntityIdProvider<TkConfigurationCenterId> getEntityIdProvider() { | |
44 | -// return new EntityIdProvider<TkConfigurationCenterId>() { | |
45 | -// @Override | |
46 | -// public TkConfigurationCenterId fromString(String uuid) { | |
47 | -// return TkConfigurationCenterId.fromString(uuid); | |
48 | -// } | |
49 | -// @Override | |
50 | -// public TkConfigurationCenterId fromUUID(UUID uuid) { | |
51 | -// return new TkConfigurationCenterId(uuid); | |
52 | -// } | |
53 | -// }; | |
54 | -// } | |
55 | -// | |
56 | -// @Override | |
57 | -// public TkConfigurationCenter constructEntityFromUpdateMsg(TenantId tenantId, EdgeId edgeId, TkUpdateMsg tkUpdateMsg) { | |
58 | -// return JacksonUtil.fromString(tkUpdateMsg.getEntity(), TkConfigurationCenter.class, true); | |
59 | -// } | |
60 | -// | |
61 | -//} | |
1 | +package org.thingsboard.server.service.edge.rpc.yunteng.tk_configuration_center; | |
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.edge.EdgeEventType; | |
9 | +import org.thingsboard.server.common.data.id.EdgeId; | |
10 | +import org.thingsboard.server.common.data.id.TenantId; | |
11 | +import org.thingsboard.server.common.data.yunteng.id.EntityIdProvider; | |
12 | +import org.thingsboard.server.common.data.yunteng.id.TkConfigurationCenterId; | |
13 | +import org.thingsboard.server.common.data.yunteng.sync.TkConfigurationCenter; | |
14 | +import org.thingsboard.server.gen.edge.v1.TkUpdateMsg; | |
15 | +import org.thingsboard.server.service.edge.rpc.yunteng.TkEdgeProcessor; | |
16 | +import org.thingsboard.server.service.edge.rpc.yunteng.TkEdgeProcessorRepository; | |
17 | + | |
18 | +import java.util.UUID; | |
19 | + | |
20 | +@Slf4j | |
21 | +@Component | |
22 | +@AllArgsConstructor | |
23 | +public class TkConfigurationCenterEdgeProcessor extends TkEdgeProcessor<TkConfigurationCenterId, TkConfigurationCenter> { | |
24 | + | |
25 | + TkConfigurationCenterRepository tkConfigurationCenterRepository; | |
26 | + | |
27 | + @Override | |
28 | + public EntityType getEntityType() { | |
29 | + return EntityType.TK_CONFIGURATION_CENTER; | |
30 | + } | |
31 | + | |
32 | + @Override | |
33 | + public EdgeEventType getEdgeEventType() { | |
34 | + return EdgeEventType.TK_CONFIGURATION_CENTER; | |
35 | + } | |
36 | + | |
37 | + @Override | |
38 | + public TkEdgeProcessorRepository<TkConfigurationCenter> getEdgeProcessorRepository() { | |
39 | + return tkConfigurationCenterRepository; | |
40 | + } | |
41 | + | |
42 | + @Override | |
43 | + public EntityIdProvider<TkConfigurationCenterId> getEntityIdProvider() { | |
44 | + return new EntityIdProvider<>() { | |
45 | + @Override | |
46 | + public TkConfigurationCenterId fromString(String uuid) { | |
47 | + return TkConfigurationCenterId.fromString(uuid); | |
48 | + } | |
49 | + | |
50 | + @Override | |
51 | + public TkConfigurationCenterId fromUUID(UUID uuid) { | |
52 | + return new TkConfigurationCenterId(uuid); | |
53 | + } | |
54 | + }; | |
55 | + } | |
56 | + | |
57 | + @Override | |
58 | + public TkConfigurationCenter constructEntityFromUpdateMsg(TenantId tenantId, EdgeId edgeId, TkUpdateMsg tkUpdateMsg) { | |
59 | + return JacksonUtil.fromString(tkUpdateMsg.getEntity(), TkConfigurationCenter.class, true); | |
60 | + } | |
61 | + | |
62 | +} | ... | ... |
1 | -//package org.thingsboard.server.service.edge.rpc.yunteng.tk_configuration_center; | |
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 org.springframework.beans.BeanUtils; | |
9 | -//import org.springframework.stereotype.Repository; | |
10 | -//import org.thingsboard.server.common.data.id.EdgeId; | |
11 | -//import org.thingsboard.server.common.data.id.EntityId; | |
12 | -//import org.thingsboard.server.common.data.id.TenantId; | |
13 | -//import org.thingsboard.server.common.data.page.PageData; | |
14 | -//import org.thingsboard.server.common.data.page.PageLink; | |
15 | -//import org.thingsboard.server.common.data.yunteng.id.TkConfigurationCenterId; | |
16 | -//import org.thingsboard.server.common.data.yunteng.sync.TkConfigurationCenter; | |
17 | -//import org.thingsboard.server.common.data.yunteng.utils.CopyUtils; | |
18 | -//import org.thingsboard.server.dao.yunteng.entities.TkConfigurationCenterEntity; | |
19 | -//import org.thingsboard.server.dao.yunteng.mapper.ConfigurationCenterMapper; | |
20 | -//import org.thingsboard.server.service.edge.rpc.yunteng.TkEdgeProcessorRepository; | |
21 | -// | |
22 | -//import java.util.List; | |
23 | -//import java.util.UUID; | |
24 | -//import java.util.stream.Collectors; | |
25 | -// | |
26 | -//@Repository | |
27 | -//@AllArgsConstructor | |
28 | -//public class TkConfigurationCenterRepository implements TkEdgeProcessorRepository<TkConfigurationCenter> { | |
29 | -// | |
30 | -// private ConfigurationCenterMapper tkConfigurationCenterMapper; | |
31 | -// | |
32 | -// @Override | |
33 | -// public boolean updateFromEdge(TenantId tenantId, EdgeId edgeId, TkConfigurationCenter dto) throws Exception { | |
34 | -// System.out.println(" 更新 TkConfigurationCenter"); | |
35 | -// | |
36 | -// TkConfigurationCenterEntity model = tkConfigurationCenterMapper.selectById(dto.getId().getId().toString()); | |
37 | -// if (model == null) { | |
38 | -// model = new TkConfigurationCenterEntity(); | |
39 | -// CopyUtils.copyProperties(dto, model); | |
40 | -// model.setId(dto.getId().toString()); | |
41 | -// model.setTenantId(dto.getTenantId().getId().toString()); | |
42 | -// return tkConfigurationCenterMapper.insert(model)>0; | |
43 | -// } else { | |
44 | -// CopyUtils.copyProperties(dto, model); | |
45 | -// model.setId(dto.getId().toString()); | |
46 | -// model.setTenantId(dto.getTenantId().getId().toString()); | |
47 | -// return tkConfigurationCenterMapper.updateById(model)>0; | |
48 | -// } | |
49 | -// } | |
50 | -// | |
51 | -// @Override | |
52 | -// public boolean deleteFromEdge(TenantId tenantId, EdgeId edgeId, EntityId entityId) throws Exception { | |
53 | -// System.out.println(" 删除 TkConfigurationCenter"); | |
54 | -// | |
55 | -// LambdaQueryWrapper<TkConfigurationCenterEntity> queryWrapper = Wrappers.lambdaQuery(); | |
56 | -// queryWrapper.eq(TkConfigurationCenterEntity::getTenantId, tenantId.getId().toString()); | |
57 | -// queryWrapper.eq(TkConfigurationCenterEntity::getId, entityId.getId().toString()); | |
58 | -// return tkConfigurationCenterMapper.delete(queryWrapper)>0; | |
59 | -// } | |
60 | -// | |
61 | -// @Override | |
62 | -// public PageData selectToEdge(TenantId tenantId, EdgeId edgeId, PageLink pageLink) { | |
63 | -// System.out.println(" 全量下行查询 TkConfigurationCenter"); | |
64 | -// | |
65 | -// LambdaQueryWrapper<TkConfigurationCenterEntity> queryWrapper = Wrappers.lambdaQuery(); | |
66 | -// queryWrapper.eq(TkConfigurationCenterEntity::getTenantId, tenantId.getId().toString()); | |
67 | -// Page<TkConfigurationCenterEntity> queryPage = new Page<>(pageLink.getPage(), pageLink.getPageSize()); | |
68 | -// IPage<TkConfigurationCenterEntity> resultPage = tkConfigurationCenterMapper.selectPage(queryPage, queryWrapper); | |
69 | -// return new PageData((List) resultPage.getRecords().stream().map(e->{ | |
70 | -// return toData(e); | |
71 | -// }).collect(Collectors.toList()), (int) resultPage.getPages(), resultPage.getTotal(), resultPage.getCurrent()<resultPage.getPages()); | |
72 | -// } | |
73 | -// | |
74 | -// @Override | |
75 | -// public List<TkConfigurationCenter> selectToEdge(TenantId tenantId, EdgeId edgeId, EntityId entityId) { | |
76 | -// System.out.println(" 下行转换 TkConfigurationCenter"); | |
77 | -// | |
78 | -// LambdaQueryWrapper<TkConfigurationCenterEntity> queryWrapper = Wrappers.lambdaQuery(); | |
79 | -// queryWrapper.eq(TkConfigurationCenterEntity::getTenantId, tenantId.getId().toString()); | |
80 | -// queryWrapper.eq(TkConfigurationCenterEntity::getId, entityId.getId().toString()); | |
81 | -// List<TkConfigurationCenterEntity> model= tkConfigurationCenterMapper.selectList(queryWrapper); | |
82 | -// if(model!=null){ | |
83 | -// return model.stream().map(e->{return toData(e);}).collect(Collectors.toList()); | |
84 | -// } | |
85 | -// else { | |
86 | -// return null; | |
87 | -// } | |
88 | -// } | |
89 | -// | |
90 | -// private TkConfigurationCenter toData(TkConfigurationCenterEntity e) { | |
91 | -// TkConfigurationCenter data=new TkConfigurationCenter(); | |
92 | -// CopyUtils.copyProperties(e,data); | |
93 | -// data.setId(TkConfigurationCenterId.fromString(e.getId())); | |
94 | -// data.setTenantId(TenantId.fromUUID(UUID.fromString(e.getTenantId()))); | |
95 | -// return data; | |
96 | -// } | |
97 | -// | |
98 | -//} | |
1 | +package org.thingsboard.server.service.edge.rpc.yunteng.tk_configuration_center; | |
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.stereotype.Repository; | |
10 | +import org.thingsboard.server.common.data.id.EdgeId; | |
11 | +import org.thingsboard.server.common.data.id.EntityId; | |
12 | +import org.thingsboard.server.common.data.id.TenantId; | |
13 | +import org.thingsboard.server.common.data.page.PageData; | |
14 | +import org.thingsboard.server.common.data.page.PageLink; | |
15 | +import org.thingsboard.server.common.data.yunteng.id.TkConfigurationCenterId; | |
16 | +import org.thingsboard.server.common.data.yunteng.sync.TkConfigurationCenter; | |
17 | +import org.thingsboard.server.common.data.yunteng.utils.CopyUtils; | |
18 | +import org.thingsboard.server.dao.yunteng.entities.TkConfigurationCenterEntity; | |
19 | +import org.thingsboard.server.dao.yunteng.mapper.ConfigurationCenterMapper; | |
20 | +import org.thingsboard.server.service.edge.rpc.yunteng.TkEdgeProcessorRepository; | |
21 | + | |
22 | +import java.util.List; | |
23 | +import java.util.UUID; | |
24 | +import java.util.stream.Collectors; | |
25 | + | |
26 | +@Repository | |
27 | +@AllArgsConstructor | |
28 | +@Slf4j | |
29 | +public class TkConfigurationCenterRepository implements TkEdgeProcessorRepository<TkConfigurationCenter> { | |
30 | + | |
31 | + private ConfigurationCenterMapper tkConfigurationCenterMapper; | |
32 | + | |
33 | + @Override | |
34 | + public boolean updateFromEdge(TenantId tenantId, EdgeId edgeId, TkConfigurationCenter dto) throws Exception { | |
35 | + //边端的组态不同步到云端 | |
36 | + return false; | |
37 | + } | |
38 | + | |
39 | + @Override | |
40 | + public boolean deleteFromEdge(TenantId tenantId, EdgeId edgeId, EntityId entityId) throws Exception { | |
41 | + //边端的组态不同步到云端 | |
42 | + return false; | |
43 | + } | |
44 | + | |
45 | + @Override | |
46 | + public PageData selectToEdge(TenantId tenantId, EdgeId edgeId, PageLink pageLink) { | |
47 | + LambdaQueryWrapper<TkConfigurationCenterEntity> queryWrapper = Wrappers.lambdaQuery(); | |
48 | + queryWrapper.eq(TkConfigurationCenterEntity::getTenantId, tenantId.getId().toString()); | |
49 | + Page<TkConfigurationCenterEntity> queryPage = new Page<>(pageLink.getPage(), pageLink.getPageSize()); | |
50 | + IPage<TkConfigurationCenterEntity> resultPage = tkConfigurationCenterMapper.selectPage(queryPage, queryWrapper); | |
51 | + return new PageData(resultPage.getRecords().stream().map(this::toData).collect(Collectors.toList()), (int) resultPage.getPages(), resultPage.getTotal(), resultPage.getCurrent()<resultPage.getPages()); | |
52 | + } | |
53 | + | |
54 | + @Override | |
55 | + public List<TkConfigurationCenter> selectToEdge(TenantId tenantId, EdgeId edgeId, EntityId entityId) { | |
56 | + LambdaQueryWrapper<TkConfigurationCenterEntity> queryWrapper = Wrappers.lambdaQuery(); | |
57 | + queryWrapper.eq(TkConfigurationCenterEntity::getTenantId, tenantId.getId().toString()); | |
58 | + queryWrapper.eq(TkConfigurationCenterEntity::getId, entityId.getId().toString()); | |
59 | + List<TkConfigurationCenterEntity> model= tkConfigurationCenterMapper.selectList(queryWrapper); | |
60 | + if(model!=null){ | |
61 | + return model.stream().map(this::toData).collect(Collectors.toList()); | |
62 | + } | |
63 | + return null; | |
64 | + } | |
65 | + | |
66 | + private TkConfigurationCenter toData(TkConfigurationCenterEntity e) { | |
67 | + TkConfigurationCenter data=new TkConfigurationCenter(); | |
68 | + CopyUtils.copyProperties(e,data); | |
69 | + data.setId(TkConfigurationCenterId.fromString(e.getId())); | |
70 | + data.setTenantId(TenantId.fromUUID(UUID.fromString(e.getTenantId()))); | |
71 | + return data; | |
72 | + } | |
73 | + | |
74 | +} | ... | ... |
1 | -//package org.thingsboard.server.service.edge.rpc.yunteng.tk_configuration_content; | |
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.edge.EdgeEventType; | |
9 | -//import org.thingsboard.server.common.data.id.EdgeId; | |
10 | -//import org.thingsboard.server.common.data.id.TenantId; | |
11 | -//import org.thingsboard.server.common.data.yunteng.id.EntityIdProvider; | |
12 | -//import org.thingsboard.server.common.data.yunteng.id.TkConfigurationContentId; | |
13 | -//import org.thingsboard.server.common.data.yunteng.sync.TkConfigurationContent; | |
14 | -//import org.thingsboard.server.gen.edge.v1.TkUpdateMsg; | |
15 | -//import org.thingsboard.server.service.edge.rpc.yunteng.TkEdgeProcessor; | |
16 | -//import org.thingsboard.server.service.edge.rpc.yunteng.TkEdgeProcessorRepository; | |
17 | -// | |
18 | -//import java.util.UUID; | |
19 | -// | |
20 | -//@Slf4j | |
21 | -//@Component | |
22 | -//@AllArgsConstructor | |
23 | -//public class TkConfigurationContentEdgeProcessor extends TkEdgeProcessor<TkConfigurationContentId, TkConfigurationContent> { | |
24 | -// | |
25 | -// TkConfigurationContentRepository TkConfigurationContentRepository; | |
26 | -// | |
27 | -// @Override | |
28 | -// public EntityType getEntityType() { | |
29 | -// return EntityType.TK_CONFIGURATION_CONTENT; | |
30 | -// } | |
31 | -// | |
32 | -// @Override | |
33 | -// public EdgeEventType getEdgeEventType() { | |
34 | -// return EdgeEventType.TK_CONFIGURATION_CONTENT; | |
35 | -// } | |
36 | -// | |
37 | -// @Override | |
38 | -// public TkEdgeProcessorRepository<TkConfigurationContent> getEdgeProcessorRepository() { | |
39 | -// return TkConfigurationContentRepository; | |
40 | -// } | |
41 | -// | |
42 | -// @Override | |
43 | -// public EntityIdProvider<TkConfigurationContentId> getEntityIdProvider() { | |
44 | -// return new EntityIdProvider<TkConfigurationContentId>() { | |
45 | -// @Override | |
46 | -// public TkConfigurationContentId fromString(String uuid) { | |
47 | -// return TkConfigurationContentId.fromString(uuid); | |
48 | -// } | |
49 | -// @Override | |
50 | -// public TkConfigurationContentId fromUUID(UUID uuid) { | |
51 | -// return new TkConfigurationContentId(uuid); | |
52 | -// } | |
53 | -// }; | |
54 | -// } | |
55 | -// | |
56 | -// @Override | |
57 | -// public TkConfigurationContent constructEntityFromUpdateMsg(TenantId tenantId, EdgeId edgeId, TkUpdateMsg tkUpdateMsg) { | |
58 | -// return JacksonUtil.fromString(tkUpdateMsg.getEntity(), TkConfigurationContent.class, true); | |
59 | -// } | |
60 | -// | |
61 | -//} | |
1 | +package org.thingsboard.server.service.edge.rpc.yunteng.tk_configuration_content; | |
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.edge.EdgeEventType; | |
9 | +import org.thingsboard.server.common.data.id.EdgeId; | |
10 | +import org.thingsboard.server.common.data.id.TenantId; | |
11 | +import org.thingsboard.server.common.data.yunteng.id.EntityIdProvider; | |
12 | +import org.thingsboard.server.common.data.yunteng.id.TkConfigurationContentId; | |
13 | +import org.thingsboard.server.common.data.yunteng.sync.TkConfigurationContent; | |
14 | +import org.thingsboard.server.gen.edge.v1.TkUpdateMsg; | |
15 | +import org.thingsboard.server.service.edge.rpc.yunteng.TkEdgeProcessor; | |
16 | +import org.thingsboard.server.service.edge.rpc.yunteng.TkEdgeProcessorRepository; | |
17 | + | |
18 | +import java.util.UUID; | |
19 | + | |
20 | +@Slf4j | |
21 | +@Component | |
22 | +@AllArgsConstructor | |
23 | +public class TkConfigurationContentEdgeProcessor extends TkEdgeProcessor<TkConfigurationContentId, TkConfigurationContent> { | |
24 | + | |
25 | + TkConfigurationContentRepository TkConfigurationContentRepository; | |
26 | + | |
27 | + @Override | |
28 | + public EntityType getEntityType() { | |
29 | + return EntityType.TK_CONFIGURATION_CONTENT; | |
30 | + } | |
31 | + | |
32 | + @Override | |
33 | + public EdgeEventType getEdgeEventType() { | |
34 | + return EdgeEventType.TK_CONFIGURATION_CONTENT; | |
35 | + } | |
36 | + | |
37 | + @Override | |
38 | + public TkEdgeProcessorRepository<TkConfigurationContent> getEdgeProcessorRepository() { | |
39 | + return TkConfigurationContentRepository; | |
40 | + } | |
41 | + | |
42 | + @Override | |
43 | + public EntityIdProvider<TkConfigurationContentId> getEntityIdProvider() { | |
44 | + return new EntityIdProvider<>() { | |
45 | + @Override | |
46 | + public TkConfigurationContentId fromString(String uuid) { | |
47 | + return TkConfigurationContentId.fromString(uuid); | |
48 | + } | |
49 | + @Override | |
50 | + public TkConfigurationContentId fromUUID(UUID uuid) { | |
51 | + return new TkConfigurationContentId(uuid); | |
52 | + } | |
53 | + }; | |
54 | + } | |
55 | + | |
56 | + @Override | |
57 | + public TkConfigurationContent constructEntityFromUpdateMsg(TenantId tenantId, EdgeId edgeId, TkUpdateMsg tkUpdateMsg) { | |
58 | + return JacksonUtil.fromString(tkUpdateMsg.getEntity(), TkConfigurationContent.class, true); | |
59 | + } | |
60 | + | |
61 | +} | ... | ... |
1 | -//package org.thingsboard.server.service.edge.rpc.yunteng.tk_configuration_content; | |
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 org.springframework.beans.BeanUtils; | |
9 | -//import org.springframework.stereotype.Repository; | |
10 | -//import org.thingsboard.server.common.data.id.EdgeId; | |
11 | -//import org.thingsboard.server.common.data.id.EntityId; | |
12 | -//import org.thingsboard.server.common.data.id.TenantId; | |
13 | -//import org.thingsboard.server.common.data.page.PageData; | |
14 | -//import org.thingsboard.server.common.data.page.PageLink; | |
15 | -//import org.thingsboard.server.common.data.yunteng.id.TkConfigurationContentId; | |
16 | -//import org.thingsboard.server.common.data.yunteng.sync.TkConfigurationContent; | |
17 | -//import org.thingsboard.server.common.data.yunteng.utils.CopyUtils; | |
18 | -//import org.thingsboard.server.dao.yunteng.entities.TkConfigurationContentEntity; | |
19 | -//import org.thingsboard.server.dao.yunteng.mapper.ConfigurationContentMapper; | |
20 | -//import org.thingsboard.server.dao.yunteng.mapper.ConfigurationContentNodeMapper; | |
21 | -//import org.thingsboard.server.service.edge.rpc.yunteng.TkEdgeProcessorRepository; | |
22 | -// | |
23 | -//import java.util.List; | |
24 | -//import java.util.UUID; | |
25 | -//import java.util.stream.Collectors; | |
26 | -// | |
27 | -//@Repository | |
28 | -//@AllArgsConstructor | |
29 | -//public class TkConfigurationContentRepository implements TkEdgeProcessorRepository<TkConfigurationContent> { | |
30 | -// | |
31 | -// private ConfigurationContentMapper TkConfigurationContentMapper; | |
32 | -// | |
33 | -// @Override | |
34 | -// public boolean updateFromEdge(TenantId tenantId, EdgeId edgeId, TkConfigurationContent dto) throws Exception { | |
35 | -// System.out.println(" 更新 TkConfigurationContent"); | |
36 | -// | |
37 | -// TkConfigurationContentEntity model = TkConfigurationContentMapper.selectById(dto.getId().getId().toString()); | |
38 | -// if (model == null) { | |
39 | -// model = new TkConfigurationContentEntity(); | |
40 | -// CopyUtils.copyProperties(dto, model); | |
41 | -// model.setId(dto.getId().toString()); | |
42 | -// model.setTenantId(dto.getTenantId().getId().toString()); | |
43 | -// return TkConfigurationContentMapper.insert(model)>0; | |
44 | -// } else { | |
45 | -// CopyUtils.copyProperties(dto, model); | |
46 | -// model.setId(dto.getId().toString()); | |
47 | -// model.setTenantId(dto.getTenantId().getId().toString()); | |
48 | -// return TkConfigurationContentMapper.updateById(model)>0; | |
49 | -// } | |
50 | -// } | |
51 | -// | |
52 | -// @Override | |
53 | -// public boolean deleteFromEdge(TenantId tenantId, EdgeId edgeId, EntityId entityId) throws Exception { | |
54 | -// System.out.println(" 删除 TkConfigurationContent"); | |
55 | -// | |
56 | -// LambdaQueryWrapper<TkConfigurationContentEntity> queryWrapper = Wrappers.lambdaQuery(); | |
57 | -// queryWrapper.eq(TkConfigurationContentEntity::getTenantId, tenantId.getId().toString()); | |
58 | -// queryWrapper.eq(TkConfigurationContentEntity::getId, entityId.getId().toString()); | |
59 | -// return TkConfigurationContentMapper.delete(queryWrapper)>0; | |
60 | -// } | |
61 | -// | |
62 | -// @Override | |
63 | -// public PageData selectToEdge(TenantId tenantId, EdgeId edgeId, PageLink pageLink) { | |
64 | -// System.out.println(" 全量下行查询 TkConfigurationContent"); | |
65 | -// | |
66 | -// LambdaQueryWrapper<TkConfigurationContentEntity> queryWrapper = Wrappers.lambdaQuery(); | |
67 | -// queryWrapper.eq(TkConfigurationContentEntity::getTenantId, tenantId.getId().toString()); | |
68 | -// Page<TkConfigurationContentEntity> queryPage = new Page<>(pageLink.getPage(), pageLink.getPageSize()); | |
69 | -// IPage<TkConfigurationContentEntity> resultPage = TkConfigurationContentMapper.selectPage(queryPage, queryWrapper); | |
70 | -// return new PageData((List) resultPage.getRecords().stream().map(e->{ | |
71 | -// return toData(e); | |
72 | -// }).collect(Collectors.toList()), (int) resultPage.getPages(), resultPage.getTotal(), resultPage.getCurrent()<resultPage.getPages()); | |
73 | -// } | |
74 | -// | |
75 | -// @Override | |
76 | -// public List<TkConfigurationContent> selectToEdge(TenantId tenantId, EdgeId edgeId, EntityId entityId) { | |
77 | -// System.out.println(" 下行转换 TkConfigurationContent"); | |
78 | -// | |
79 | -// LambdaQueryWrapper<TkConfigurationContentEntity> queryWrapper = Wrappers.lambdaQuery(); | |
80 | -// queryWrapper.eq(TkConfigurationContentEntity::getTenantId, tenantId.getId().toString()); | |
81 | -// queryWrapper.eq(TkConfigurationContentEntity::getId, entityId.getId().toString()); | |
82 | -// List<TkConfigurationContentEntity> model= TkConfigurationContentMapper.selectList(queryWrapper); | |
83 | -// if(model!=null){ | |
84 | -// return model.stream().map(e->{return toData(e);}).collect(Collectors.toList()); | |
85 | -// } | |
86 | -// else { | |
87 | -// return null; | |
88 | -// } | |
89 | -// } | |
90 | -// | |
91 | -// private TkConfigurationContent toData(TkConfigurationContentEntity e) { | |
92 | -// TkConfigurationContent data=new TkConfigurationContent(); | |
93 | -// CopyUtils.copyProperties(e,data); | |
94 | -// data.setId(TkConfigurationContentId.fromString(e.getId())); | |
95 | -// data.setTenantId(TenantId.fromUUID(UUID.fromString(e.getTenantId()))); | |
96 | -// return data; | |
97 | -// } | |
98 | -// | |
99 | -//} | |
1 | +package org.thingsboard.server.service.edge.rpc.yunteng.tk_configuration_content; | |
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 org.springframework.stereotype.Repository; | |
9 | +import org.thingsboard.server.common.data.id.EdgeId; | |
10 | +import org.thingsboard.server.common.data.id.EntityId; | |
11 | +import org.thingsboard.server.common.data.id.TenantId; | |
12 | +import org.thingsboard.server.common.data.page.PageData; | |
13 | +import org.thingsboard.server.common.data.page.PageLink; | |
14 | +import org.thingsboard.server.common.data.yunteng.id.TkConfigurationContentId; | |
15 | +import org.thingsboard.server.common.data.yunteng.sync.TkConfigurationContent; | |
16 | +import org.thingsboard.server.common.data.yunteng.utils.CopyUtils; | |
17 | +import org.thingsboard.server.dao.yunteng.entities.TkConfigurationContentEntity; | |
18 | +import org.thingsboard.server.dao.yunteng.mapper.ConfigurationContentMapper; | |
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 | +public class TkConfigurationContentRepository implements TkEdgeProcessorRepository<TkConfigurationContent> { | |
28 | + | |
29 | + private ConfigurationContentMapper TkConfigurationContentMapper; | |
30 | + | |
31 | + @Override | |
32 | + public boolean updateFromEdge(TenantId tenantId, EdgeId edgeId, TkConfigurationContent dto) throws Exception { | |
33 | + return false; | |
34 | + } | |
35 | + | |
36 | + @Override | |
37 | + public boolean deleteFromEdge(TenantId tenantId, EdgeId edgeId, EntityId entityId) throws Exception { | |
38 | + return false; | |
39 | + } | |
40 | + | |
41 | + @Override | |
42 | + public PageData selectToEdge(TenantId tenantId, EdgeId edgeId, PageLink pageLink) { | |
43 | + LambdaQueryWrapper<TkConfigurationContentEntity> queryWrapper = Wrappers.lambdaQuery(); | |
44 | + queryWrapper.eq(TkConfigurationContentEntity::getTenantId, tenantId.getId().toString()); | |
45 | + Page<TkConfigurationContentEntity> queryPage = new Page<>(pageLink.getPage(), pageLink.getPageSize()); | |
46 | + IPage<TkConfigurationContentEntity> resultPage = TkConfigurationContentMapper.selectPage(queryPage, queryWrapper); | |
47 | + return new PageData(resultPage.getRecords().stream().map(this::toData).collect(Collectors.toList()), | |
48 | + (int) resultPage.getPages(), resultPage.getTotal(), resultPage.getCurrent()<resultPage.getPages()); | |
49 | + } | |
50 | + | |
51 | + @Override | |
52 | + public List<TkConfigurationContent> selectToEdge(TenantId tenantId, EdgeId edgeId, EntityId entityId) { | |
53 | + LambdaQueryWrapper<TkConfigurationContentEntity> queryWrapper = Wrappers.lambdaQuery(); | |
54 | + queryWrapper.eq(TkConfigurationContentEntity::getTenantId, tenantId.getId().toString()); | |
55 | + queryWrapper.eq(TkConfigurationContentEntity::getId, entityId.getId().toString()); | |
56 | + List<TkConfigurationContentEntity> model= TkConfigurationContentMapper.selectList(queryWrapper); | |
57 | + if(model!=null){ | |
58 | + return model.stream().map(this::toData).collect(Collectors.toList()); | |
59 | + } | |
60 | + else { | |
61 | + return null; | |
62 | + } | |
63 | + } | |
64 | + | |
65 | + private TkConfigurationContent toData(TkConfigurationContentEntity e) { | |
66 | + TkConfigurationContent data=new TkConfigurationContent(); | |
67 | + CopyUtils.copyProperties(e,data); | |
68 | + data.setId(TkConfigurationContentId.fromString(e.getId())); | |
69 | + data.setTenantId(TenantId.fromUUID(UUID.fromString(e.getTenantId()))); | |
70 | + return data; | |
71 | + } | |
72 | + | |
73 | +} | ... | ... |
1 | -//package org.thingsboard.server.service.edge.rpc.yunteng.tk_configuration_content_node; | |
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.edge.EdgeEventType; | |
9 | -//import org.thingsboard.server.common.data.id.EdgeId; | |
10 | -//import org.thingsboard.server.common.data.id.TenantId; | |
11 | -//import org.thingsboard.server.common.data.yunteng.id.EntityIdProvider; | |
12 | -//import org.thingsboard.server.common.data.yunteng.id.TkConfigurationContentNodeId; | |
13 | -//import org.thingsboard.server.common.data.yunteng.sync.TkConfigurationContentNode; | |
14 | -//import org.thingsboard.server.gen.edge.v1.TkUpdateMsg; | |
15 | -//import org.thingsboard.server.service.edge.rpc.yunteng.TkEdgeProcessor; | |
16 | -//import org.thingsboard.server.service.edge.rpc.yunteng.TkEdgeProcessorRepository; | |
17 | -// | |
18 | -//import java.util.UUID; | |
19 | -// | |
20 | -//@Slf4j | |
21 | -//@Component | |
22 | -//@AllArgsConstructor | |
23 | -//public class TkConfigurationContentNodeEdgeProcessor extends TkEdgeProcessor<TkConfigurationContentNodeId, TkConfigurationContentNode> { | |
24 | -// | |
25 | -// TkConfigurationContentNodeRepository tkConfigurationContentNodeRepository; | |
26 | -// | |
27 | -// @Override | |
28 | -// public EntityType getEntityType() { | |
29 | -// return EntityType.TK_CONFIGURATION_CONTENT_NODE; | |
30 | -// } | |
31 | -// | |
32 | -// @Override | |
33 | -// public EdgeEventType getEdgeEventType() { | |
34 | -// return EdgeEventType.TK_CONFIGURATION_CONTENT_NODE; | |
35 | -// } | |
36 | -// | |
37 | -// @Override | |
38 | -// public TkEdgeProcessorRepository<TkConfigurationContentNode> getEdgeProcessorRepository() { | |
39 | -// return tkConfigurationContentNodeRepository; | |
40 | -// } | |
41 | -// | |
42 | -// @Override | |
43 | -// public EntityIdProvider<TkConfigurationContentNodeId> getEntityIdProvider() { | |
44 | -// return new EntityIdProvider<TkConfigurationContentNodeId>() { | |
45 | -// @Override | |
46 | -// public TkConfigurationContentNodeId fromString(String uuid) { | |
47 | -// return TkConfigurationContentNodeId.fromString(uuid); | |
48 | -// } | |
49 | -// @Override | |
50 | -// public TkConfigurationContentNodeId fromUUID(UUID uuid) { | |
51 | -// return new TkConfigurationContentNodeId(uuid); | |
52 | -// } | |
53 | -// }; | |
54 | -// } | |
55 | -// | |
56 | -// @Override | |
57 | -// public TkConfigurationContentNode constructEntityFromUpdateMsg(TenantId tenantId, EdgeId edgeId, TkUpdateMsg tkUpdateMsg) { | |
58 | -// return JacksonUtil.fromString(tkUpdateMsg.getEntity(), TkConfigurationContentNode.class, true); | |
59 | -// } | |
60 | -// | |
61 | -//} | |
1 | +package org.thingsboard.server.service.edge.rpc.yunteng.tk_configuration_content_node; | |
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.edge.EdgeEventType; | |
9 | +import org.thingsboard.server.common.data.id.EdgeId; | |
10 | +import org.thingsboard.server.common.data.id.TenantId; | |
11 | +import org.thingsboard.server.common.data.yunteng.id.EntityIdProvider; | |
12 | +import org.thingsboard.server.common.data.yunteng.id.TkConfigurationContentNodeId; | |
13 | +import org.thingsboard.server.common.data.yunteng.sync.TkConfigurationContentNode; | |
14 | +import org.thingsboard.server.gen.edge.v1.TkUpdateMsg; | |
15 | +import org.thingsboard.server.service.edge.rpc.yunteng.TkEdgeProcessor; | |
16 | +import org.thingsboard.server.service.edge.rpc.yunteng.TkEdgeProcessorRepository; | |
17 | + | |
18 | +import java.util.UUID; | |
19 | + | |
20 | +@Slf4j | |
21 | +@Component | |
22 | +@AllArgsConstructor | |
23 | +public class TkConfigurationContentNodeEdgeProcessor extends TkEdgeProcessor<TkConfigurationContentNodeId, TkConfigurationContentNode> { | |
24 | + | |
25 | + TkConfigurationContentNodeRepository tkConfigurationContentNodeRepository; | |
26 | + | |
27 | + @Override | |
28 | + public EntityType getEntityType() { | |
29 | + return EntityType.TK_CONFIGURATION_CONTENT_NODE; | |
30 | + } | |
31 | + | |
32 | + @Override | |
33 | + public EdgeEventType getEdgeEventType() { | |
34 | + return EdgeEventType.TK_CONFIGURATION_CONTENT_NODE; | |
35 | + } | |
36 | + | |
37 | + @Override | |
38 | + public TkEdgeProcessorRepository<TkConfigurationContentNode> getEdgeProcessorRepository() { | |
39 | + return tkConfigurationContentNodeRepository; | |
40 | + } | |
41 | + | |
42 | + @Override | |
43 | + public EntityIdProvider<TkConfigurationContentNodeId> getEntityIdProvider() { | |
44 | + return new EntityIdProvider<TkConfigurationContentNodeId>() { | |
45 | + @Override | |
46 | + public TkConfigurationContentNodeId fromString(String uuid) { | |
47 | + return TkConfigurationContentNodeId.fromString(uuid); | |
48 | + } | |
49 | + @Override | |
50 | + public TkConfigurationContentNodeId fromUUID(UUID uuid) { | |
51 | + return new TkConfigurationContentNodeId(uuid); | |
52 | + } | |
53 | + }; | |
54 | + } | |
55 | + | |
56 | + @Override | |
57 | + public TkConfigurationContentNode constructEntityFromUpdateMsg(TenantId tenantId, EdgeId edgeId, TkUpdateMsg tkUpdateMsg) { | |
58 | + return JacksonUtil.fromString(tkUpdateMsg.getEntity(), TkConfigurationContentNode.class, true); | |
59 | + } | |
60 | + | |
61 | +} | ... | ... |
1 | -//package org.thingsboard.server.service.edge.rpc.yunteng.tk_configuration_content_node; | |
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 org.springframework.beans.BeanUtils; | |
9 | -//import org.springframework.stereotype.Repository; | |
10 | -//import org.thingsboard.server.common.data.id.EdgeId; | |
11 | -//import org.thingsboard.server.common.data.id.EntityId; | |
12 | -//import org.thingsboard.server.common.data.id.TenantId; | |
13 | -//import org.thingsboard.server.common.data.page.PageData; | |
14 | -//import org.thingsboard.server.common.data.page.PageLink; | |
15 | -//import org.thingsboard.server.common.data.yunteng.id.TkConfigurationContentNodeId; | |
16 | -//import org.thingsboard.server.common.data.yunteng.sync.TkConfigurationContentNode; | |
17 | -//import org.thingsboard.server.common.data.yunteng.utils.CopyUtils; | |
18 | -//import org.thingsboard.server.dao.yunteng.entities.TkConfigurationContentNodeEntity; | |
19 | -//import org.thingsboard.server.dao.yunteng.mapper.ConfigurationContentNodeMapper; | |
20 | -//import org.thingsboard.server.service.edge.rpc.yunteng.TkEdgeProcessorRepository; | |
21 | -// | |
22 | -//import java.util.List; | |
23 | -//import java.util.UUID; | |
24 | -//import java.util.stream.Collectors; | |
25 | -// | |
26 | -//@Repository | |
27 | -//@AllArgsConstructor | |
28 | -//public class TkConfigurationContentNodeRepository implements TkEdgeProcessorRepository<TkConfigurationContentNode> { | |
29 | -// | |
30 | -// private ConfigurationContentNodeMapper tkConfigurationContentNodeMapper; | |
31 | -// | |
32 | -// @Override | |
33 | -// public boolean updateFromEdge(TenantId tenantId, EdgeId edgeId, TkConfigurationContentNode dto) throws Exception { | |
34 | -// System.out.println(" 更新 TkConfigurationContentNode"); | |
35 | -// | |
36 | -// LambdaQueryWrapper<TkConfigurationContentNodeEntity> queryWrapper = Wrappers.lambdaQuery(); | |
37 | -// queryWrapper.eq(TkConfigurationContentNodeEntity::getTenantId, tenantId.getId().toString()); | |
38 | -// queryWrapper.eq(TkConfigurationContentNodeEntity::getSyId, dto.getId()); | |
39 | -// TkConfigurationContentNodeEntity model = tkConfigurationContentNodeMapper.selectOne(queryWrapper); | |
40 | -// | |
41 | -// if (model == null) { | |
42 | -// model = new TkConfigurationContentNodeEntity(); | |
43 | -// CopyUtils.copyProperties(dto, model); | |
44 | -// model.setId(dto.getSyId()); | |
45 | -// model.setSyId(String.valueOf(dto.getId().getId())); | |
46 | -// model.setTenantId(dto.getTenantId().getId().toString()); | |
47 | -// return tkConfigurationContentNodeMapper.insert(model)>0; | |
48 | -// } else { | |
49 | -// CopyUtils.copyProperties(dto, model); | |
50 | -// model.setId(dto.getSyId()); | |
51 | -// model.setSyId(String.valueOf(dto.getId().getId())); | |
52 | -// model.setTenantId(dto.getTenantId().getId().toString()); | |
53 | -// return tkConfigurationContentNodeMapper.updateById(model)>0; | |
54 | -// } | |
55 | -// | |
56 | -// } | |
57 | -// | |
58 | -// @Override | |
59 | -// public boolean deleteFromEdge(TenantId tenantId, EdgeId edgeId, EntityId entityId) throws Exception { | |
60 | -// System.out.println(" 删除 TkConfigurationContentNode"); | |
61 | -// | |
62 | -// LambdaQueryWrapper<TkConfigurationContentNodeEntity> queryWrapper = Wrappers.lambdaQuery(); | |
63 | -// queryWrapper.eq(TkConfigurationContentNodeEntity::getTenantId, tenantId.getId().toString()); | |
64 | -// queryWrapper.eq(TkConfigurationContentNodeEntity::getSyId, entityId.getId().toString()); | |
65 | -// return tkConfigurationContentNodeMapper.delete(queryWrapper)>0; | |
66 | -// } | |
67 | -// | |
68 | -// @Override | |
69 | -// public PageData selectToEdge(TenantId tenantId, EdgeId edgeId, PageLink pageLink) { | |
70 | -// System.out.println(" 全量下行查询 TkConfigurationContentNode"); | |
71 | -// | |
72 | -// LambdaQueryWrapper<TkConfigurationContentNodeEntity> queryWrapper = Wrappers.lambdaQuery(); | |
73 | -// queryWrapper.eq(TkConfigurationContentNodeEntity::getTenantId, tenantId.getId().toString()); | |
74 | -// Page<TkConfigurationContentNodeEntity> queryPage = new Page<>(pageLink.getPage(), pageLink.getPageSize()); | |
75 | -// IPage<TkConfigurationContentNodeEntity> resultPage = tkConfigurationContentNodeMapper.selectPage(queryPage, queryWrapper); | |
76 | -// return new PageData((List) resultPage.getRecords().stream().map(e->{ | |
77 | -// return toData(e); | |
78 | -// }).collect(Collectors.toList()), (int) resultPage.getPages(), resultPage.getTotal(), resultPage.getCurrent()<resultPage.getPages()); | |
79 | -// } | |
80 | -// | |
81 | -// @Override | |
82 | -// public List<TkConfigurationContentNode> selectToEdge(TenantId tenantId, EdgeId edgeId, EntityId entityId) { | |
83 | -// System.out.println(" 下行转换 TkConfigurationContentNode"); | |
84 | -// | |
85 | -// LambdaQueryWrapper<TkConfigurationContentNodeEntity> queryWrapper = Wrappers.lambdaQuery(); | |
86 | -// queryWrapper.eq(TkConfigurationContentNodeEntity::getTenantId, tenantId.getId().toString()); | |
87 | -// queryWrapper.eq(TkConfigurationContentNodeEntity::getSyId, entityId.getId().toString()); | |
88 | -// List<TkConfigurationContentNodeEntity> model= tkConfigurationContentNodeMapper.selectList(queryWrapper); | |
89 | -// if(model!=null){ | |
90 | -// return model.stream().map(e->{return toData(e);}).collect(Collectors.toList()); | |
91 | -// } | |
92 | -// else { | |
93 | -// return null; | |
94 | -// } | |
95 | -// } | |
96 | -// | |
97 | -// private TkConfigurationContentNode toData(TkConfigurationContentNodeEntity e) { | |
98 | -// TkConfigurationContentNode data=new TkConfigurationContentNode(); | |
99 | -// CopyUtils.copyProperties(e,data); | |
100 | -// data.setSyId(e.getId()); | |
101 | -// data.setId(TkConfigurationContentNodeId.fromString(e.getSyId())); | |
102 | -// data.setTenantId(TenantId.fromUUID(UUID.fromString(e.getTenantId()))); | |
103 | -// | |
104 | -// return data; | |
105 | -// } | |
106 | -// | |
107 | -//} | |
1 | +package org.thingsboard.server.service.edge.rpc.yunteng.tk_configuration_content_node; | |
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 org.springframework.stereotype.Repository; | |
9 | +import org.thingsboard.server.common.data.id.EdgeId; | |
10 | +import org.thingsboard.server.common.data.id.EntityId; | |
11 | +import org.thingsboard.server.common.data.id.TenantId; | |
12 | +import org.thingsboard.server.common.data.page.PageData; | |
13 | +import org.thingsboard.server.common.data.page.PageLink; | |
14 | +import org.thingsboard.server.common.data.yunteng.id.TkConfigurationContentNodeId; | |
15 | +import org.thingsboard.server.common.data.yunteng.sync.TkConfigurationContentNode; | |
16 | +import org.thingsboard.server.common.data.yunteng.utils.CopyUtils; | |
17 | +import org.thingsboard.server.dao.yunteng.entities.TkConfigurationContentNodeEntity; | |
18 | +import org.thingsboard.server.dao.yunteng.mapper.ConfigurationContentNodeMapper; | |
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 | +public class TkConfigurationContentNodeRepository implements TkEdgeProcessorRepository<TkConfigurationContentNode> { | |
28 | + | |
29 | + private ConfigurationContentNodeMapper tkConfigurationContentNodeMapper; | |
30 | + | |
31 | + @Override | |
32 | + public boolean updateFromEdge(TenantId tenantId, EdgeId edgeId, TkConfigurationContentNode dto) throws Exception { | |
33 | + return false; | |
34 | + } | |
35 | + | |
36 | + @Override | |
37 | + public boolean deleteFromEdge(TenantId tenantId, EdgeId edgeId, EntityId entityId) throws Exception { | |
38 | + return false; | |
39 | + } | |
40 | + | |
41 | + @Override | |
42 | + public PageData selectToEdge(TenantId tenantId, EdgeId edgeId, PageLink pageLink) { | |
43 | + System.out.println(" 全量下行查询 TkConfigurationContentNode"); | |
44 | + | |
45 | + LambdaQueryWrapper<TkConfigurationContentNodeEntity> queryWrapper = Wrappers.lambdaQuery(); | |
46 | + queryWrapper.eq(TkConfigurationContentNodeEntity::getTenantId, tenantId.getId().toString()); | |
47 | + Page<TkConfigurationContentNodeEntity> queryPage = new Page<>(pageLink.getPage(), pageLink.getPageSize()); | |
48 | + IPage<TkConfigurationContentNodeEntity> resultPage = tkConfigurationContentNodeMapper.selectPage(queryPage, queryWrapper); | |
49 | + return new PageData(resultPage.getRecords().stream().map(this::toData).collect(Collectors.toList()), | |
50 | + (int) resultPage.getPages(), resultPage.getTotal(), resultPage.getCurrent()<resultPage.getPages()); | |
51 | + } | |
52 | + | |
53 | + @Override | |
54 | + public List<TkConfigurationContentNode> selectToEdge(TenantId tenantId, EdgeId edgeId, EntityId entityId) { | |
55 | + System.out.println(" 下行转换 TkConfigurationContentNode"); | |
56 | + | |
57 | + LambdaQueryWrapper<TkConfigurationContentNodeEntity> queryWrapper = Wrappers.lambdaQuery(); | |
58 | + queryWrapper.eq(TkConfigurationContentNodeEntity::getTenantId, tenantId.getId().toString()); | |
59 | + queryWrapper.eq(TkConfigurationContentNodeEntity::getId, entityId.getId().toString()); | |
60 | + List<TkConfigurationContentNodeEntity> model= tkConfigurationContentNodeMapper.selectList(queryWrapper); | |
61 | + if(model!=null){ | |
62 | + return model.stream().map(this::toData).collect(Collectors.toList()); | |
63 | + } | |
64 | + else { | |
65 | + return null; | |
66 | + } | |
67 | + } | |
68 | + | |
69 | + private TkConfigurationContentNode toData(TkConfigurationContentNodeEntity e) { | |
70 | + TkConfigurationContentNode data=new TkConfigurationContentNode(); | |
71 | + CopyUtils.copyProperties(e,data); | |
72 | + data.setId(TkConfigurationContentNodeId.fromString(e.getId())); | |
73 | + data.setTenantId(TenantId.fromUUID(UUID.fromString(e.getTenantId()))); | |
74 | + return data; | |
75 | + } | |
76 | + | |
77 | +} | ... | ... |
... | ... | @@ -27,9 +27,6 @@ public class TkConfigurationContentNode extends BaseDataWithAdditionalInfo<TkCon |
27 | 27 | @ApiModelProperty("组态中心id") |
28 | 28 | private String configurationId; |
29 | 29 | |
30 | - @ApiModelProperty("同步id") | |
31 | - private String syId; | |
32 | - | |
33 | 30 | @ApiModelProperty("组态内容ID") |
34 | 31 | private String contentId; |
35 | 32 | |
... | ... | @@ -59,4 +56,7 @@ public class TkConfigurationContentNode extends BaseDataWithAdditionalInfo<TkCon |
59 | 56 | |
60 | 57 | @ApiModelProperty("备注") |
61 | 58 | private String remark; |
59 | + | |
60 | + @ApiModelProperty(value = "组态节点ID") | |
61 | + private String configurationNodeId; | |
62 | 62 | } | ... | ... |
... | ... | @@ -25,8 +25,8 @@ public class ConfigurationContentDTO extends TenantDTO { |
25 | 25 | groups = {UpdateGroup.class}) |
26 | 26 | private String content; |
27 | 27 | |
28 | - @ApiModelProperty(value = "页面内容ID", required = true) | |
29 | - private String contentId; | |
28 | + @ApiModelProperty(value = "页面内容信息列表", required = true) | |
29 | + private List<ConfigurationContentPageDTO> contentPageInfos; | |
30 | 30 | |
31 | 31 | @ApiModelProperty(value = "组态描述") |
32 | 32 | private String remark; |
... | ... | @@ -42,7 +42,4 @@ public class ConfigurationContentDTO extends TenantDTO { |
42 | 42 | message = "类型不能为空", |
43 | 43 | groups = {UpdateGroup.class, AddGroup.class}) |
44 | 44 | private Integer type; |
45 | - | |
46 | - @ApiModelProperty(value = "节点列表") | |
47 | - private List<String> nodeIds; | |
48 | 45 | } | ... | ... |
... | ... | @@ -16,12 +16,6 @@ import org.thingsboard.server.common.data.yunteng.common.UpdateGroup; |
16 | 16 | @Data |
17 | 17 | public class ConfigurationContentNodeDTO extends TenantDTO { |
18 | 18 | |
19 | - @ApiModelProperty(value = "节点id", required = true) | |
20 | - @NotEmpty( | |
21 | - message = "节点id不能为空或空字符串", | |
22 | - groups = {UpdateGroup.class, AddGroup.class}) | |
23 | - private String id; | |
24 | - | |
25 | 19 | @ApiModelProperty(value = "组态ID", required = true) |
26 | 20 | @NotEmpty( |
27 | 21 | message = "组态ID不能为空或空字符串", |
... | ... | @@ -43,7 +37,8 @@ public class ConfigurationContentNodeDTO extends TenantDTO { |
43 | 37 | @ApiModelProperty(value = "动画集合json") |
44 | 38 | private JsonNode actJson; |
45 | 39 | |
46 | - @ApiModelProperty(value = "同步id") | |
47 | - private String syId; | |
48 | - | |
40 | + @NotEmpty( | |
41 | + message = "节点id不能为空或空字符串", | |
42 | + groups = {UpdateGroup.class, AddGroup.class}) | |
43 | + private String configurationNodeId; | |
49 | 44 | } | ... | ... |
1 | +package org.thingsboard.server.common.data.yunteng.dto; | |
2 | + | |
3 | +import io.swagger.annotations.ApiModelProperty; | |
4 | +import lombok.Data; | |
5 | + | |
6 | +import java.util.List; | |
7 | + | |
8 | +@Data | |
9 | +public class ConfigurationContentPageDTO { | |
10 | + @ApiModelProperty(value = "页面内容ID", required = true) | |
11 | + private String contentId; | |
12 | + | |
13 | + @ApiModelProperty(value = "节点列表") | |
14 | + private List<String> nodeIds; | |
15 | +} | ... | ... |
... | ... | @@ -26,6 +26,7 @@ import java.util.stream.Collectors; |
26 | 26 | @Slf4j |
27 | 27 | @Service |
28 | 28 | @RequiredArgsConstructor |
29 | +@Deprecated | |
29 | 30 | public class TkConfigurationActServiceImpl |
30 | 31 | extends AbstractBaseService<ConfigurationActMapper, TkConfigurationActEntity> |
31 | 32 | implements TkConfigurationActService { | ... | ... |
... | ... | @@ -10,12 +10,14 @@ import lombok.extern.slf4j.Slf4j; |
10 | 10 | import org.apache.commons.lang3.StringUtils; |
11 | 11 | import org.springframework.stereotype.Service; |
12 | 12 | import org.springframework.transaction.annotation.Transactional; |
13 | +import org.thingsboard.server.common.data.id.TenantId; | |
13 | 14 | import org.thingsboard.server.common.data.yunteng.constant.FastIotConstants; |
14 | 15 | import org.thingsboard.server.common.data.yunteng.core.exception.TkDataValidationException; |
15 | 16 | import org.thingsboard.server.common.data.yunteng.core.message.ErrorMessage; |
16 | 17 | import org.thingsboard.server.common.data.yunteng.dto.*; |
17 | 18 | import org.thingsboard.server.common.data.yunteng.dto.request.ConfigurationContentInfoDTO; |
18 | 19 | import org.thingsboard.server.common.data.yunteng.enums.ViewType; |
20 | +import org.thingsboard.server.common.data.yunteng.id.TkConfigurationCenterId; | |
19 | 21 | import org.thingsboard.server.common.data.yunteng.utils.JacksonUtil; |
20 | 22 | import org.thingsboard.server.common.data.yunteng.utils.i18n.MessageUtils; |
21 | 23 | import org.thingsboard.server.common.data.yunteng.utils.tools.TkPageData; |
... | ... | @@ -86,14 +88,8 @@ public class TkConfigurationCenterServiceImpl |
86 | 88 | |
87 | 89 | baseMapper.insert(configurationCenter); |
88 | 90 | //如果是模板则同步边端 |
89 | -// if(configurationCenter.getIsTemplate()==1){ | |
90 | -// //云边同步关联表 | |
91 | -// try { | |
92 | -// tkEdgeSyncService.update(TkConfigurationCenterId.fromString(configurationCenter.getId())); | |
93 | -// }catch (Exception e){ | |
94 | -// log.error(e.getMessage(),e); | |
95 | -// } | |
96 | -// } | |
91 | + isTemplateUpdateOrDeleteCenterToEdge(false,configurationCenter.getIsTemplate(),configurationCenter.getTenantId(), | |
92 | + configurationCenter.getId()); | |
97 | 93 | /**判断是否使用模板 |
98 | 94 | */ |
99 | 95 | String templateId = configurationCenterDTO.getTemplateId(); |
... | ... | @@ -154,14 +150,7 @@ public class TkConfigurationCenterServiceImpl |
154 | 150 | entity.setProductAndDevice(JacksonUtil.convertValue(configurationCenterDTO.getProductAndDevice(), JsonNode.class)); |
155 | 151 | baseMapper.updateById(entity); |
156 | 152 | //如果是模板则同步边端 |
157 | -// if(entity.getIsTemplate()==1){ | |
158 | -// //云边同步关联表 | |
159 | -// try { | |
160 | -// tkEdgeSyncService.update(TkConfigurationCenterId.fromString(configurationCenter.getId())); | |
161 | -// }catch (Exception e){ | |
162 | -// log.error(e.getMessage(),e); | |
163 | -// } | |
164 | -// } | |
153 | + isTemplateUpdateOrDeleteCenterToEdge(false,entity.getIsTemplate(),entity.getTenantId(),entity.getId()); | |
165 | 154 | return configurationCenterDTO; |
166 | 155 | } |
167 | 156 | |
... | ... | @@ -177,14 +166,10 @@ public class TkConfigurationCenterServiceImpl |
177 | 166 | throw new TkDataValidationException(MessageUtils.message(ErrorMessage.TENANT_MISMATCHING.getI18nCode())); |
178 | 167 | } |
179 | 168 | } |
180 | -// for (TkConfigurationCenterEntity center : centerList) { | |
181 | -// //如果是模板则同步边端 | |
182 | -// if(center.getIsTemplate()==1){ | |
183 | -// //云边同步关联表 | |
184 | -// tkEdgeSyncService.delete(TkConfigurationCenterId.fromString(center.getId())); | |
185 | -// } | |
186 | -// } | |
187 | - ytConfigurationContentService.deleteConfigurationContentByCenterId(deleteDTO.getIds()); | |
169 | + for (TkConfigurationCenterEntity center : centerList) { | |
170 | + isTemplateUpdateOrDeleteCenterToEdge(true,center.getIsTemplate(),center.getTenantId(),center.getId()); | |
171 | + } | |
172 | + ytConfigurationContentService.deleteConfigurationContentByCenterId(deleteDTO.getIds(),deleteDTO.getTenantId()); | |
188 | 173 | return baseMapper.deleteBatchIds(deleteDTO.getIds()) > FastIotConstants.MagicNumber.ZERO; |
189 | 174 | } |
190 | 175 | |
... | ... | @@ -328,4 +313,19 @@ public class TkConfigurationCenterServiceImpl |
328 | 313 | } |
329 | 314 | } |
330 | 315 | |
316 | + private void isTemplateUpdateOrDeleteCenterToEdge(boolean isDelete,int isTemplate,String tenantId,String configurationCenterId){ | |
317 | + //如果是模板则同步边端 | |
318 | + if(isTemplate==1){ | |
319 | + TenantId currentTenantId = new TenantId(UUID.fromString(tenantId)); | |
320 | + try { | |
321 | + if(isDelete){ | |
322 | + tkEdgeSyncService.delete(currentTenantId,TkConfigurationCenterId.fromString(configurationCenterId)); | |
323 | + }else { | |
324 | + tkEdgeSyncService.update(currentTenantId,TkConfigurationCenterId.fromString(configurationCenterId)); | |
325 | + } | |
326 | + }catch (Exception e){ | |
327 | + log.error(e.getMessage(),e); | |
328 | + } | |
329 | + } | |
330 | + } | |
331 | 331 | } | ... | ... |
dao/src/main/java/org/thingsboard/server/dao/yunteng/impl/TkConfigurationContentNodeServiceImpl.java
... | ... | @@ -5,6 +5,8 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
5 | 5 | |
6 | 6 | import java.util.List; |
7 | 7 | import java.util.Optional; |
8 | +import java.util.Set; | |
9 | +import java.util.UUID; | |
8 | 10 | import java.util.stream.Collectors; |
9 | 11 | |
10 | 12 | import com.fasterxml.jackson.databind.JsonNode; |
... | ... | @@ -13,9 +15,11 @@ import lombok.extern.slf4j.Slf4j; |
13 | 15 | import org.apache.commons.lang3.StringUtils; |
14 | 16 | import org.springframework.stereotype.Service; |
15 | 17 | import org.thingsboard.common.util.JacksonUtil; |
18 | +import org.thingsboard.server.common.data.id.TenantId; | |
16 | 19 | import org.thingsboard.server.common.data.yunteng.core.exception.TkDataValidationException; |
17 | 20 | import org.thingsboard.server.common.data.yunteng.core.message.ErrorMessage; |
18 | 21 | import org.thingsboard.server.common.data.yunteng.dto.ConfigurationContentNodeDTO; |
22 | +import org.thingsboard.server.common.data.yunteng.id.TkConfigurationContentNodeId; | |
19 | 23 | import org.thingsboard.server.common.data.yunteng.utils.i18n.MessageUtils; |
20 | 24 | import org.thingsboard.server.dao.yunteng.entities.TkConfigurationCenterEntity; |
21 | 25 | import org.thingsboard.server.dao.yunteng.entities.TkConfigurationContentNodeEntity; |
... | ... | @@ -42,22 +46,18 @@ public class TkConfigurationContentNodeServiceImpl |
42 | 46 | public ConfigurationContentNodeDTO saveConfiguration(ConfigurationContentNodeDTO sourceDTO) { |
43 | 47 | LambdaQueryWrapper<TkConfigurationContentNodeEntity> filter = new QueryWrapper<TkConfigurationContentNodeEntity>().lambda() |
44 | 48 | .eq(TkConfigurationContentNodeEntity::getId, sourceDTO.getId()) |
45 | - .eq(TkConfigurationContentNodeEntity::getConfigurationId, sourceDTO.getConfigurationId()) | |
46 | - ; | |
49 | + .eq(TkConfigurationContentNodeEntity::getConfigurationId, sourceDTO.getConfigurationId()); | |
47 | 50 | TkConfigurationContentNodeEntity old = baseMapper.selectOne(filter); |
48 | 51 | TkConfigurationContentNodeEntity newData = sourceDTO.getEntity(TkConfigurationContentNodeEntity.class); |
49 | 52 | if (old == null) { |
50 | - //newData.setEnabled(false); | |
51 | -// newData.setSyId(String.valueOf(UUID.randomUUID())); | |
52 | 53 | baseMapper.insert(newData); |
53 | 54 | } else if (!sourceDTO.getTenantId().equals(old.getTenantId())) { |
54 | 55 | throw new TkDataValidationException(MessageUtils.message(ErrorMessage.HAVE_NO_PERMISSION.getI18nCode())); |
55 | 56 | } else { |
56 | -// newData.setSyId(old.getSyId()); | |
57 | 57 | baseMapper.update(newData, filter); |
58 | 58 | } |
59 | 59 | //如果是模板则同步边端 |
60 | -// updateEdge(sourceDTO.getConfigurationId(),newData.getSyId()); | |
60 | + updateOrDeleteEdge(true,sourceDTO.getConfigurationId(),newData.getTenantId(),newData.getId()); | |
61 | 61 | return sourceDTO; |
62 | 62 | } |
63 | 63 | |
... | ... | @@ -80,18 +80,18 @@ public class TkConfigurationContentNodeServiceImpl |
80 | 80 | old.setActJson(json); |
81 | 81 | } |
82 | 82 | int result = baseMapper.updateById(old); |
83 | -// updateEdge(configurationId,old.getSyId()); | |
83 | + updateOrDeleteEdge(false,configurationId,old.getTenantId(),old.getId()); | |
84 | 84 | return result > 0; |
85 | 85 | } |
86 | 86 | |
87 | 87 | @Override |
88 | - public ConfigurationContentNodeDTO get(String id, String configurationId, String contentId, String tenantId) { | |
88 | + public ConfigurationContentNodeDTO get(String configurationNodeId, String configurationId, String contentId, String tenantId) { | |
89 | 89 | TkConfigurationContentNodeEntity old = |
90 | 90 | baseMapper.selectOne(new LambdaQueryWrapper<TkConfigurationContentNodeEntity>() |
91 | 91 | .eq(TkConfigurationContentNodeEntity::getTenantId, tenantId) |
92 | 92 | .eq(StringUtils.isNotBlank(configurationId), TkConfigurationContentNodeEntity::getConfigurationId, configurationId) |
93 | 93 | .eq(StringUtils.isNotBlank(contentId), TkConfigurationContentNodeEntity::getContentId, contentId) |
94 | - .eq(StringUtils.isNotBlank(id), TkConfigurationContentNodeEntity::getId, id)); | |
94 | + .eq(StringUtils.isNotBlank(configurationNodeId), TkConfigurationContentNodeEntity::getConfigurationNodeId, configurationNodeId)); | |
95 | 95 | return Optional.ofNullable(old).map(entity -> entity.getDTO(ConfigurationContentNodeDTO.class)).orElse(null); |
96 | 96 | } |
97 | 97 | |
... | ... | @@ -118,6 +118,21 @@ public class TkConfigurationContentNodeServiceImpl |
118 | 118 | .collect(Collectors.toList()); |
119 | 119 | } |
120 | 120 | |
121 | + @Override | |
122 | + public boolean deleteContentNodeByConfigurationIds(Set<String> configurationCenterIds, String tenantId) { | |
123 | + List<TkConfigurationContentNodeEntity> entities = baseMapper.selectList( | |
124 | + new LambdaQueryWrapper<TkConfigurationContentNodeEntity>().eq(TkConfigurationContentNodeEntity:: | |
125 | + getTenantId,tenantId).in(TkConfigurationContentNodeEntity::getConfigurationId,configurationCenterIds)); | |
126 | + if(null != entities && !entities.isEmpty()){ | |
127 | + for (TkConfigurationContentNodeEntity entity:entities){ | |
128 | + updateOrDeleteEdge(false,entity.getConfigurationId(),entity.getTenantId(),entity.getId()); | |
129 | + } | |
130 | + //删除所有的节点 | |
131 | + return baseMapper.deleteBatchIds(entities.stream().map(entity->entity.getId()).collect(Collectors.toList()))>0; | |
132 | + } | |
133 | + return false; | |
134 | + } | |
135 | + | |
121 | 136 | public Boolean findIsTemplate(String configurationId){ |
122 | 137 | boolean isTemplate = false; |
123 | 138 | TkConfigurationCenterEntity center = configurationCenterMapper.selectById(configurationId); |
... | ... | @@ -127,15 +142,21 @@ public class TkConfigurationContentNodeServiceImpl |
127 | 142 | return isTemplate; |
128 | 143 | } |
129 | 144 | |
130 | -// public void updateEdge(String configurationId ,String id ){ | |
131 | -// //如果是模板则同步边端 | |
132 | -// if(findIsTemplate(configurationId)){ | |
133 | -// try { | |
134 | -// tkEdgeSyncService.update(TkConfigurationContentNodeId.fromString(id)); | |
135 | -// }catch (Exception e){ | |
136 | -// log.error(e.getMessage(),e); | |
137 | -// } | |
138 | -// } | |
139 | -// } | |
145 | + public void updateOrDeleteEdge(boolean update,String configurationId ,String tenantId,String id ){ | |
146 | + //如果是模板则同步边端 | |
147 | + if(findIsTemplate(configurationId)){ | |
148 | + TkConfigurationContentNodeId tkConfigurationContentNodeId = TkConfigurationContentNodeId.fromString(id); | |
149 | + try { | |
150 | + TenantId currentTenantId = new TenantId(UUID.fromString(tenantId)); | |
151 | + if(update){ | |
152 | + tkEdgeSyncService.update(currentTenantId,tkConfigurationContentNodeId); | |
153 | + }else{ | |
154 | + tkEdgeSyncService.delete(currentTenantId,tkConfigurationContentNodeId); | |
155 | + } | |
156 | + }catch (Exception e){ | |
157 | + log.error(e.getMessage(),e); | |
158 | + } | |
159 | + } | |
160 | + } | |
140 | 161 | |
141 | 162 | } | ... | ... |
1 | 1 | package org.thingsboard.server.dao.yunteng.impl; |
2 | 2 | |
3 | 3 | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
4 | -import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; | |
5 | 4 | import lombok.RequiredArgsConstructor; |
6 | 5 | import lombok.extern.slf4j.Slf4j; |
7 | 6 | import org.springframework.stereotype.Service; |
8 | 7 | import org.springframework.transaction.annotation.Transactional; |
8 | +import org.thingsboard.server.common.data.id.TenantId; | |
9 | 9 | import org.thingsboard.server.common.data.yunteng.constant.FastIotConstants; |
10 | 10 | import org.thingsboard.server.common.data.yunteng.core.exception.TkDataValidationException; |
11 | 11 | import org.thingsboard.server.common.data.yunteng.core.message.ErrorMessage; |
12 | 12 | import org.thingsboard.server.common.data.yunteng.dto.*; |
13 | -import org.thingsboard.server.common.data.yunteng.id.TkConfigurationCenterId; | |
14 | 13 | import org.thingsboard.server.common.data.yunteng.id.TkConfigurationContentId; |
15 | 14 | import org.thingsboard.server.common.data.yunteng.id.TkConfigurationContentNodeId; |
16 | 15 | import org.thingsboard.server.common.data.yunteng.utils.i18n.MessageUtils; |
... | ... | @@ -18,11 +17,12 @@ import org.thingsboard.server.dao.yunteng.entities.*; |
18 | 17 | import org.thingsboard.server.dao.yunteng.event.TkEdgeSyncService; |
19 | 18 | import org.thingsboard.server.dao.yunteng.mapper.*; |
20 | 19 | import org.thingsboard.server.dao.yunteng.service.AbstractBaseService; |
21 | -import org.thingsboard.server.dao.yunteng.service.TkConfigurationCenterService; | |
22 | 20 | import org.thingsboard.server.dao.yunteng.service.TkConfigurationContentNodeService; |
23 | 21 | import org.thingsboard.server.dao.yunteng.service.TkConfigurationContentService; |
24 | 22 | import java.util.List; |
25 | 23 | import java.util.Set; |
24 | +import java.util.UUID; | |
25 | +import java.util.stream.Collectors; | |
26 | 26 | |
27 | 27 | @Slf4j |
28 | 28 | @Service |
... | ... | @@ -39,20 +39,11 @@ public class TkConfigurationContentServiceImpl |
39 | 39 | @Transactional |
40 | 40 | public ConfigurationContentDTO saveConfigurationContent( |
41 | 41 | ConfigurationContentDTO configurationContentDTO) { |
42 | - freshNodeData(configurationContentDTO.getConfigurationId(),configurationContentDTO.getTenantId(), configurationContentDTO.getContentId(), configurationContentDTO.getNodeIds()); | |
42 | + freshNodeData(configurationContentDTO.getConfigurationId(),configurationContentDTO.getTenantId(), configurationContentDTO.getContentPageInfos()); | |
43 | 43 | TkConfigurationContentEntity entity = new TkConfigurationContentEntity(); |
44 | 44 | configurationContentDTO.copyToEntity(entity); |
45 | 45 | baseMapper.insert(entity); |
46 | - | |
47 | - //如果是模板则同步边端 | |
48 | - if(findIsTemplate(configurationContentDTO.getConfigurationId())){ | |
49 | - //云边同步关联表 | |
50 | - try { | |
51 | - tkEdgeSyncService.update(TkConfigurationContentId.fromString(entity.getId())); | |
52 | - }catch (Exception e){ | |
53 | - log.error(e.getMessage(),e); | |
54 | - } | |
55 | - } | |
46 | + isTemplateUpdateOrDeleteContentToEdge(false,configurationContentDTO.getConfigurationId(),entity.getTenantId(),entity.getId()); | |
56 | 47 | return configurationContentDTO; |
57 | 48 | } |
58 | 49 | |
... | ... | @@ -60,22 +51,47 @@ public class TkConfigurationContentServiceImpl |
60 | 51 | * 刷新组态的结点数据 |
61 | 52 | * @param configurationId 组态ID |
62 | 53 | * @param tenantId 租户ID |
63 | - * @param contentId 页签ID | |
64 | - * @param nodeIds 页面内组件集合 | |
54 | + * @param contentPageInfos 组态内容页,信息列表 | |
65 | 55 | */ |
66 | - private void freshNodeData(String configurationId, String tenantId,String contentId,List<String> nodeIds){ | |
67 | - //查询当前页面所有节点 不包含的直接删除 | |
68 | - List<ConfigurationContentNodeDTO> nodeDTOList =nodeService.selectByConfigurationIdAndContentId(configurationId,contentId,tenantId); | |
69 | - nodeDTOList.forEach(item ->{ | |
70 | - if(nodeIds == null | |
71 | - || nodeIds.isEmpty() | |
72 | - || !nodeIds.contains(item.getId())){ | |
73 | - configurationContentNodeMapper.deleteById(item.getId()); | |
74 | - //同步边端 | |
75 | - if(findIsTemplate(configurationId)){ | |
76 | - tkEdgeSyncService.delete(TkConfigurationContentNodeId.fromString(item.getSyId())); | |
56 | + private void freshNodeData(String configurationId, String tenantId,List<ConfigurationContentPageDTO> contentPageInfos){ | |
57 | + if(null !=contentPageInfos){ | |
58 | + //1、存在的existContentIds都是需要更新的,其他的都进行删除 | |
59 | + List<String> existContentIds = contentPageInfos.stream().map(page->page.getContentId()).collect(Collectors.toList()); | |
60 | + if(!existContentIds.isEmpty()){ | |
61 | + //2、找到要删除的其他节点 | |
62 | + List<TkConfigurationContentNodeEntity> deleteNodeEntities = configurationContentNodeMapper.selectList(new LambdaQueryWrapper<TkConfigurationContentNodeEntity>().eq(TkConfigurationContentNodeEntity::getTenantId,tenantId) | |
63 | + .eq(TkConfigurationContentNodeEntity::getConfigurationId,configurationId).notIn(TkConfigurationContentNodeEntity::getContentId,existContentIds)); | |
64 | + //3、删除其他节点 | |
65 | + if(null != deleteNodeEntities && !deleteNodeEntities.isEmpty()){ | |
66 | + deleteNodeEntities.forEach(entity->{ | |
67 | + configurationContentNodeMapper.deleteById(entity.getId()); | |
68 | + //同步边端 | |
69 | + if(findIsTemplate(configurationId)){ | |
70 | + tkEdgeSyncService.delete(TkConfigurationContentNodeId.fromString(entity.getId())); | |
71 | + } | |
72 | + }); | |
77 | 73 | } |
74 | + //4、更新存在的existContentIds节点 | |
75 | + updateContentIdNodes(configurationId,tenantId,contentPageInfos); | |
78 | 76 | } |
77 | + } | |
78 | + } | |
79 | + private void updateContentIdNodes(String configurationId, String tenantId,List<ConfigurationContentPageDTO> contentPageInfos){ | |
80 | + contentPageInfos.stream().forEach(contentPage->{ | |
81 | + List<String> nodeIds = contentPage.getNodeIds(); | |
82 | + //查询当前页面所有节点 不包含的直接删除 | |
83 | + List<ConfigurationContentNodeDTO> nodeDTOList =nodeService.selectByConfigurationIdAndContentId(configurationId,contentPage.getContentId(),tenantId); | |
84 | + nodeDTOList.forEach(item ->{ | |
85 | + if(nodeIds == null | |
86 | + || nodeIds.isEmpty() | |
87 | + || !nodeIds.contains(item.getConfigurationNodeId())){ | |
88 | + configurationContentNodeMapper.deleteById(item.getId()); | |
89 | + //同步边端 | |
90 | + if(findIsTemplate(configurationId)){ | |
91 | + tkEdgeSyncService.delete(TkConfigurationContentNodeId.fromString(item.getId())); | |
92 | + } | |
93 | + } | |
94 | + }); | |
79 | 95 | }); |
80 | 96 | } |
81 | 97 | |
... | ... | @@ -88,16 +104,11 @@ public class TkConfigurationContentServiceImpl |
88 | 104 | if (!configurationContent.getTenantId().equals(configurationContentDTO.getTenantId())) { |
89 | 105 | throw new TkDataValidationException(MessageUtils.message(ErrorMessage.TENANT_MISMATCHING.getI18nCode())); |
90 | 106 | } |
91 | - freshNodeData(configurationContentDTO.getConfigurationId(),configurationContentDTO.getTenantId(), configurationContentDTO.getContentId(), configurationContentDTO.getNodeIds()); | |
107 | + freshNodeData(configurationContentDTO.getConfigurationId(),configurationContentDTO.getTenantId(), configurationContentDTO.getContentPageInfos()); | |
92 | 108 | baseMapper.updateById(configurationContentDTO.getEntity(TkConfigurationContentEntity.class)); |
93 | - if(findIsTemplate(configurationContentDTO.getConfigurationId())){ | |
94 | - //云边同步关联表 | |
95 | - try { | |
96 | - tkEdgeSyncService.update(TkConfigurationContentId.fromString(configurationContentDTO.getId())); | |
97 | - }catch (Exception e){ | |
98 | - log.error(e.getMessage(),e); | |
99 | - } | |
100 | - } | |
109 | + | |
110 | + isTemplateUpdateOrDeleteContentToEdge(false,configurationContentDTO.getConfigurationId(),configurationContentDTO.getTenantId(), | |
111 | + configurationContentDTO.getId()); | |
101 | 112 | return configurationContentDTO; |
102 | 113 | } |
103 | 114 | |
... | ... | @@ -114,9 +125,7 @@ public class TkConfigurationContentServiceImpl |
114 | 125 | } |
115 | 126 | } |
116 | 127 | for (TkConfigurationContentEntity center : centerList) { |
117 | - if(findIsTemplate(center.getConfigurationId())){ | |
118 | - tkEdgeSyncService.delete(TkConfigurationContentId.fromString(center.getId())); | |
119 | - } | |
128 | + isTemplateUpdateOrDeleteContentToEdge(true,center.getConfigurationId(),center.getTenantId(),center.getId()); | |
120 | 129 | } |
121 | 130 | |
122 | 131 | return baseMapper.deleteBatchIds(deleteDTO.getIds()) > FastIotConstants.MagicNumber.ZERO; |
... | ... | @@ -124,7 +133,9 @@ public class TkConfigurationContentServiceImpl |
124 | 133 | |
125 | 134 | @Override |
126 | 135 | @Transactional |
127 | - public boolean deleteConfigurationContentByCenterId(Set<String> configurationCenterIds) { | |
136 | + public boolean deleteConfigurationContentByCenterId(Set<String> configurationCenterIds,String tenantId) { | |
137 | + //删除组态内容节点信息 | |
138 | + nodeService.deleteContentNodeByConfigurationIds(configurationCenterIds,tenantId); | |
128 | 139 | for (String configurationCenterId :configurationCenterIds){ |
129 | 140 | if(findIsTemplate(configurationCenterId)){ |
130 | 141 | tkEdgeSyncService.delete(TkConfigurationContentId.fromString(getByConfigurationId(configurationCenterId).getId())); |
... | ... | @@ -144,13 +155,35 @@ public class TkConfigurationContentServiceImpl |
144 | 155 | } |
145 | 156 | public Boolean findIsTemplate(String configurationId){ |
146 | 157 | boolean isTemplate = false; |
147 | - //组态模板暂不进行云边同步 | |
148 | -// TkConfigurationCenterEntity center = configurationCenterMapper.selectById(configurationId); | |
149 | -// if(center.getIsTemplate()==1){ | |
150 | -// isTemplate = true; | |
151 | -// } | |
158 | + TkConfigurationCenterEntity center = configurationCenterMapper.selectById(configurationId); | |
159 | + if(center.getIsTemplate()==1){ | |
160 | + isTemplate = true; | |
161 | + } | |
152 | 162 | return isTemplate; |
153 | 163 | } |
154 | 164 | |
165 | + /** | |
166 | + * 如果组态是模板,则更新或删除同步到边端 | |
167 | + * @param isDelete true删除 false添加或更新 | |
168 | + * @param configurationId 组态ID | |
169 | + * @param tenantId 租户ID | |
170 | + * @param configurationContentId 组态内容ID | |
171 | + */ | |
172 | + private void isTemplateUpdateOrDeleteContentToEdge(boolean isDelete,String configurationId,String tenantId,String configurationContentId){ | |
173 | + if(findIsTemplate(configurationId)){ | |
174 | + TkConfigurationContentId tkConfigurationContentId = TkConfigurationContentId.fromString(configurationContentId); | |
175 | + TenantId currentTenantId = new TenantId(UUID.fromString(tenantId)); | |
176 | + //云边同步关联表 | |
177 | + try { | |
178 | + if(!isDelete){ | |
179 | + tkEdgeSyncService.update(currentTenantId,tkConfigurationContentId); | |
180 | + }else{ | |
181 | + tkEdgeSyncService.delete(currentTenantId,tkConfigurationContentId); | |
182 | + } | |
183 | + }catch (Exception e){ | |
184 | + log.error(e.getMessage(),e); | |
185 | + } | |
186 | + } | |
187 | + } | |
155 | 188 | |
156 | 189 | } | ... | ... |
... | ... | @@ -26,6 +26,7 @@ import java.util.stream.Collectors; |
26 | 26 | @Slf4j |
27 | 27 | @Service |
28 | 28 | @RequiredArgsConstructor |
29 | +@Deprecated | |
29 | 30 | public class TkConfigurationDatasourceServiceImpl |
30 | 31 | extends AbstractBaseService<ConfigurationDatasourceMapper, TkConfigurationDatasourceEntity> |
31 | 32 | implements TkConfigurationDatasourceService { | ... | ... |
... | ... | @@ -26,6 +26,7 @@ import java.util.stream.Collectors; |
26 | 26 | @Slf4j |
27 | 27 | @Service |
28 | 28 | @RequiredArgsConstructor |
29 | +@Deprecated | |
29 | 30 | public class TkConfigurationEventServiceImpl |
30 | 31 | extends AbstractBaseService<ConfigurationEventMapper, TkConfigurationEventEntity> |
31 | 32 | implements TkConfigurationEventService { | ... | ... |
1 | 1 | package org.thingsboard.server.dao.yunteng.service; |
2 | 2 | |
3 | 3 | import java.util.List; |
4 | +import java.util.Set; | |
4 | 5 | |
5 | 6 | import com.fasterxml.jackson.databind.JsonNode; |
6 | 7 | import org.thingsboard.server.common.data.yunteng.dto.ConfigurationContentNodeDTO; |
... | ... | @@ -15,11 +16,11 @@ public interface TkConfigurationContentNodeService { |
15 | 16 | ConfigurationContentNodeDTO saveConfiguration(ConfigurationContentNodeDTO sourceDTO); |
16 | 17 | Boolean deleteByType(String id , String configurationId,String contentId,String type,String tenantId); |
17 | 18 | |
18 | - ConfigurationContentNodeDTO get(String id , String configurationId,String contentId,String tenantId); | |
19 | + ConfigurationContentNodeDTO get(String configurationNodeId , String configurationId,String contentId,String tenantId); | |
19 | 20 | |
20 | 21 | List<ConfigurationContentNodeDTO>selectByConfigurationId(String configurationId,String tenantId); |
21 | 22 | |
22 | 23 | List<ConfigurationContentNodeDTO>selectByConfigurationIdAndContentId(String configurationId,String contentId,String tenantId); |
23 | 24 | |
24 | - | |
25 | + boolean deleteContentNodeByConfigurationIds(Set<String> configurationCenterIds, String tenantId); | |
25 | 26 | } | ... | ... |
... | ... | @@ -15,7 +15,7 @@ public interface TkConfigurationContentService { |
15 | 15 | |
16 | 16 | boolean deleteConfigurationContent(DeleteDTO deleteDTO); |
17 | 17 | |
18 | - boolean deleteConfigurationContentByCenterId(Set<String> configurationCenterIds); | |
18 | + boolean deleteConfigurationContentByCenterId(Set<String> configurationCenterIds,String tenantId); | |
19 | 19 | |
20 | 20 | TkConfigurationContentEntity getByConfigurationId(String configurationId); |
21 | 21 | } | ... | ... |