Commit 958a66e5846b836a00d2a96fd451e02e12fb2138
Merge branch '20220512' into 'master'
feat: 组态结点信息 See merge request huang/thingsboard3.3.2!97
Showing
14 changed files
with
513 additions
and
0 deletions
1 | +package org.thingsboard.server.controller.yunteng; | ||
2 | + | ||
3 | +import io.swagger.annotations.Api; | ||
4 | +import io.swagger.annotations.ApiOperation; | ||
5 | +import io.swagger.annotations.ApiParam; | ||
6 | +import lombok.RequiredArgsConstructor; | ||
7 | +import org.springframework.http.ResponseEntity; | ||
8 | +import org.springframework.validation.annotation.Validated; | ||
9 | +import org.springframework.web.bind.annotation.*; | ||
10 | +import org.thingsboard.server.common.data.exception.ThingsboardException; | ||
11 | +import org.thingsboard.server.common.data.yunteng.common.AddGroup; | ||
12 | +import org.thingsboard.server.common.data.yunteng.common.DeleteGroup; | ||
13 | +import org.thingsboard.server.common.data.yunteng.dto.ConfigurationDatasourceDTO; | ||
14 | +import org.thingsboard.server.common.data.yunteng.dto.ConfigurationEventDTO; | ||
15 | +import org.thingsboard.server.controller.BaseController; | ||
16 | +import org.thingsboard.server.dao.yunteng.service.YtConfigurationDatasourceService; | ||
17 | +import org.thingsboard.server.dao.yunteng.service.YtConfigurationEventService; | ||
18 | + | ||
19 | +import java.util.HashMap; | ||
20 | +import java.util.List; | ||
21 | +import java.util.Map; | ||
22 | + | ||
23 | +/** | ||
24 | + * @author Administrator | ||
25 | + */ | ||
26 | +@RestController | ||
27 | +@RequestMapping("/api/yt/configuration/node") | ||
28 | +@RequiredArgsConstructor | ||
29 | +@Api(tags = "组态结点管理") | ||
30 | +public class YtConfigurationNodeController extends BaseController { | ||
31 | + | ||
32 | + private final YtConfigurationDatasourceService datasourceService; | ||
33 | + private final YtConfigurationEventService eventService; | ||
34 | + | ||
35 | + @PostMapping("datascource") | ||
36 | + @ApiOperation("编辑数据源") | ||
37 | + public ResponseEntity<ConfigurationDatasourceDTO> saveDatascource( | ||
38 | + @Validated({AddGroup.class}) @RequestBody ConfigurationDatasourceDTO datasourceDTO) | ||
39 | + throws ThingsboardException { | ||
40 | + datasourceDTO.setTenantId(getCurrentUser().getCurrentTenantId()); | ||
41 | + return ResponseEntity.ok( | ||
42 | + datasourceService.saveConfigurationDatasource(datasourceDTO)); | ||
43 | + } | ||
44 | + | ||
45 | + @PostMapping("event") | ||
46 | + @ApiOperation("编辑数据交互") | ||
47 | + public ResponseEntity<ConfigurationEventDTO> saveEvent( | ||
48 | + @Validated({AddGroup.class}) @RequestBody ConfigurationEventDTO eventDTO) | ||
49 | + throws ThingsboardException { | ||
50 | + eventDTO.setTenantId(getCurrentUser().getCurrentTenantId()); | ||
51 | + return ResponseEntity.ok( | ||
52 | + eventService.saveConfigurationEvent(eventDTO)); | ||
53 | + } | ||
54 | + | ||
55 | + | ||
56 | + @DeleteMapping("datascource") | ||
57 | + @ApiOperation("删除数据源") | ||
58 | + public ResponseEntity<Boolean> deleteDatascource( | ||
59 | + @Validated({DeleteGroup.class}) @RequestBody ConfigurationDatasourceDTO deleteDTO) | ||
60 | + throws ThingsboardException { | ||
61 | + deleteDTO.setTenantId(getCurrentUser().getCurrentTenantId()); | ||
62 | + return ResponseEntity.ok(datasourceService.deleteConfigurationDatasource(deleteDTO)); | ||
63 | + } | ||
64 | + | ||
65 | + @DeleteMapping("event") | ||
66 | + @ApiOperation("删除数据交互") | ||
67 | + public ResponseEntity<Boolean> deleteEvent( | ||
68 | + @Validated({DeleteGroup.class}) @RequestBody ConfigurationEventDTO deleteDTO) | ||
69 | + throws ThingsboardException { | ||
70 | + deleteDTO.setTenantId(getCurrentUser().getCurrentTenantId()); | ||
71 | + return ResponseEntity.ok(eventService.deleteConfigurationEvent(deleteDTO)); | ||
72 | + } | ||
73 | + | ||
74 | + | ||
75 | + @GetMapping("/{levelType}/{levelId}") | ||
76 | + @ApiOperation("组件信息") | ||
77 | + public ResponseEntity<Map<String, List>> nodeInform( | ||
78 | + @ApiParam(value = "组态资源类型,例如:CONFIGURE、CONTENT、NODE", required = true, defaultValue = "NODE") @PathVariable("levelType") String levelType, | ||
79 | + @ApiParam(value = "组态资源ID", required = true) @PathVariable("levelId") String levelId) throws ThingsboardException { | ||
80 | + String tenantId = getCurrentUser().getCurrentTenantId(); | ||
81 | + | ||
82 | + List<ConfigurationDatasourceDTO> sources = datasourceService.listConfigurationDatasource(tenantId, levelType, levelId); | ||
83 | + List<ConfigurationEventDTO> events = eventService.listConfigurationEvent(tenantId, levelType, levelId); | ||
84 | + Map<String, List> result = new HashMap<>(); | ||
85 | + if (sources != null && sources.size() > 0) { | ||
86 | + result.put("dataSources", sources); | ||
87 | + } | ||
88 | + if (events != null && events.size() > 0) { | ||
89 | + result.put("event", events); | ||
90 | + } | ||
91 | + return ResponseEntity.ok(result); | ||
92 | + } | ||
93 | + | ||
94 | +} |
@@ -90,4 +90,10 @@ public interface FastIotConstants { | @@ -90,4 +90,10 @@ public interface FastIotConstants { | ||
90 | String area = "thingsArea"; | 90 | String area = "thingsArea"; |
91 | int DRAFT = 0; | 91 | int DRAFT = 0; |
92 | } | 92 | } |
93 | + | ||
94 | + interface ConfigureLevel { | ||
95 | + String CONFIGURE = "CONFIGURE"; | ||
96 | + String CONTENT = "CONTENT"; | ||
97 | + String NODE = "NODE"; | ||
98 | + } | ||
93 | } | 99 | } |
@@ -75,6 +75,10 @@ public final class ModelConstants { | @@ -75,6 +75,10 @@ public final class ModelConstants { | ||
75 | public static final String IOTFS_CONFIGURATION_CENTER_NAME = "iotfs_configuration_center"; | 75 | public static final String IOTFS_CONFIGURATION_CENTER_NAME = "iotfs_configuration_center"; |
76 | /** 组态内容 */ | 76 | /** 组态内容 */ |
77 | public static final String IOTFS_CONFIGURATION_CONTENT_NAME = "iotfs_configuration_content"; | 77 | public static final String IOTFS_CONFIGURATION_CONTENT_NAME = "iotfs_configuration_content"; |
78 | + /** 组态内容 */ | ||
79 | + public static final String IOTFS_CONFIGURATION_DATASOURCE = "iotfs_configuration_datasource"; | ||
80 | + /** 组态内容 */ | ||
81 | + public static final String IOTFS_CONFIGURATION_EVENT = "iotfs_configuration_event"; | ||
78 | /** 视频流 */ | 82 | /** 视频流 */ |
79 | public static final String IOTFS_VIDEO_STREAM_TABLE_NAME = "iotfs_device_camera"; | 83 | public static final String IOTFS_VIDEO_STREAM_TABLE_NAME = "iotfs_device_camera"; |
80 | /** 意见反馈 */ | 84 | /** 意见反馈 */ |
1 | +package org.thingsboard.server.common.data.yunteng.dto; | ||
2 | + | ||
3 | +import com.fasterxml.jackson.databind.JsonNode; | ||
4 | +import io.swagger.annotations.ApiModelProperty; | ||
5 | +import lombok.Data; | ||
6 | +import lombok.EqualsAndHashCode; | ||
7 | +import org.thingsboard.server.common.data.yunteng.common.AddGroup; | ||
8 | +import org.thingsboard.server.common.data.yunteng.common.UpdateGroup; | ||
9 | + | ||
10 | +import javax.validation.constraints.NotEmpty; | ||
11 | +import javax.validation.constraints.NotNull; | ||
12 | + | ||
13 | +/** | ||
14 | + * 组态结点数据源 | ||
15 | + * @author Administrator | ||
16 | + */ | ||
17 | +@EqualsAndHashCode(callSuper = true) | ||
18 | +@Data | ||
19 | +public class ConfigurationDatasourceDTO extends TenantDTO { | ||
20 | + @ApiModelProperty(value = "组态ID", required = true) | ||
21 | + @NotEmpty( | ||
22 | + message = "组态ID不能为空或空字符串", | ||
23 | + groups = {UpdateGroup.class, AddGroup.class}) | ||
24 | + private String configurationId; | ||
25 | + | ||
26 | + @ApiModelProperty(value = "页面ID", required = true) | ||
27 | + @NotEmpty( | ||
28 | + message = "页面ID不能为空或空字符串", | ||
29 | + groups = {UpdateGroup.class, AddGroup.class}) | ||
30 | + private String contentId; | ||
31 | + | ||
32 | + @ApiModelProperty(value = "组态ID", required = true) | ||
33 | + @NotEmpty( | ||
34 | + message = "组件ID不能未空或空字符串", | ||
35 | + groups = {UpdateGroup.class, AddGroup.class}) | ||
36 | + private String nodeId; | ||
37 | + | ||
38 | + @ApiModelProperty(value = "tbDeviceId", required = true) | ||
39 | + @NotEmpty( | ||
40 | + message = "tbDeviceId不能未空或空字符串", | ||
41 | + groups = {UpdateGroup.class, AddGroup.class}) | ||
42 | + private String deviceId; | ||
43 | + | ||
44 | + @ApiModelProperty(value = "组件关注的指标") | ||
45 | + private JsonNode attr; | ||
46 | + | ||
47 | + @ApiModelProperty(value = "组态描述") | ||
48 | + private String remark; | ||
49 | +} |
common/data/src/main/java/org/thingsboard/server/common/data/yunteng/dto/ConfigurationEventDTO.java
0 → 100644
1 | +package org.thingsboard.server.common.data.yunteng.dto; | ||
2 | + | ||
3 | +import com.fasterxml.jackson.databind.JsonNode; | ||
4 | +import io.swagger.annotations.ApiModelProperty; | ||
5 | +import lombok.Data; | ||
6 | +import lombok.EqualsAndHashCode; | ||
7 | +import org.thingsboard.server.common.data.yunteng.common.AddGroup; | ||
8 | +import org.thingsboard.server.common.data.yunteng.common.UpdateGroup; | ||
9 | +import org.thingsboard.server.common.data.yunteng.enums.EventTypeEnum; | ||
10 | + | ||
11 | +import javax.validation.constraints.NotEmpty; | ||
12 | + | ||
13 | +/** | ||
14 | + * 组态节点事件 | ||
15 | + * @author Administrator | ||
16 | + */ | ||
17 | +@EqualsAndHashCode(callSuper = true) | ||
18 | +@Data | ||
19 | +public class ConfigurationEventDTO extends TenantDTO { | ||
20 | + @ApiModelProperty(value = "组态ID", required = true) | ||
21 | + @NotEmpty( | ||
22 | + message = "组态ID不能为空或空字符串", | ||
23 | + groups = {UpdateGroup.class, AddGroup.class}) | ||
24 | + private String configurationId; | ||
25 | + | ||
26 | + @ApiModelProperty(value = "页面ID", required = true) | ||
27 | + @NotEmpty( | ||
28 | + message = "页面ID不能为空或空字符串", | ||
29 | + groups = {UpdateGroup.class, AddGroup.class}) | ||
30 | + private String contentId; | ||
31 | + | ||
32 | + @ApiModelProperty(value = "事件类型", required = true) | ||
33 | + @NotEmpty( | ||
34 | + message = "tbDeviceId不能未空或空字符串", | ||
35 | + groups = {UpdateGroup.class, AddGroup.class}) | ||
36 | + private EventTypeEnum type; | ||
37 | + | ||
38 | + @ApiModelProperty(value = "事件内容") | ||
39 | + private JsonNode content; | ||
40 | + | ||
41 | + @ApiModelProperty(value = "组态描述") | ||
42 | + private String remark; | ||
43 | +} |
dao/src/main/java/org/thingsboard/server/dao/yunteng/entities/ConfigurationDatasource.java
0 → 100644
1 | +package org.thingsboard.server.dao.yunteng.entities; | ||
2 | + | ||
3 | +import com.baomidou.mybatisplus.annotation.TableName; | ||
4 | +import com.fasterxml.jackson.databind.JsonNode; | ||
5 | +import lombok.Data; | ||
6 | +import lombok.EqualsAndHashCode; | ||
7 | +import org.thingsboard.server.common.data.yunteng.constant.ModelConstants; | ||
8 | + | ||
9 | +/** | ||
10 | + * @author Administrator | ||
11 | + */ | ||
12 | +@EqualsAndHashCode(callSuper = true) | ||
13 | +@TableName(ModelConstants.Table.IOTFS_CONFIGURATION_DATASOURCE) | ||
14 | +@Data | ||
15 | +public class ConfigurationDatasource extends TenantBaseEntity { | ||
16 | + private static final long serialVersionUID = 2830393872646826226L; | ||
17 | + private String configurationId; | ||
18 | + private String contentId; | ||
19 | + private String nodeId; | ||
20 | + private String deviceId; | ||
21 | + private JsonNode attr; | ||
22 | + private String remark; | ||
23 | +} |
1 | +package org.thingsboard.server.dao.yunteng.entities; | ||
2 | + | ||
3 | +import com.baomidou.mybatisplus.annotation.TableName; | ||
4 | +import com.fasterxml.jackson.databind.JsonNode; | ||
5 | +import lombok.Data; | ||
6 | +import lombok.EqualsAndHashCode; | ||
7 | +import org.thingsboard.server.common.data.yunteng.constant.ModelConstants; | ||
8 | +import org.thingsboard.server.common.data.yunteng.enums.EventTypeEnum; | ||
9 | + | ||
10 | +/** | ||
11 | + * @author Administrator | ||
12 | + */ | ||
13 | +@EqualsAndHashCode(callSuper = true) | ||
14 | +@TableName(ModelConstants.Table.IOTFS_CONFIGURATION_EVENT) | ||
15 | +@Data | ||
16 | +public class ConfigurationEvent extends TenantBaseEntity { | ||
17 | + private static final long serialVersionUID = 4613503997176066996L; | ||
18 | + private String configurationId; | ||
19 | + private String contentId; | ||
20 | + private JsonNode content; | ||
21 | + private EventTypeEnum type; | ||
22 | + private String remark; | ||
23 | +} |
dao/src/main/java/org/thingsboard/server/dao/yunteng/impl/YtConfigurationDatasourceServiceImpl.java
0 → 100644
1 | +package org.thingsboard.server.dao.yunteng.impl; | ||
2 | + | ||
3 | +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; | ||
4 | +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; | ||
5 | +import lombok.RequiredArgsConstructor; | ||
6 | +import lombok.extern.slf4j.Slf4j; | ||
7 | +import org.apache.commons.lang3.StringUtils; | ||
8 | +import org.springframework.stereotype.Service; | ||
9 | +import org.springframework.transaction.annotation.Transactional; | ||
10 | +import org.thingsboard.server.common.data.yunteng.constant.FastIotConstants; | ||
11 | +import org.thingsboard.server.common.data.yunteng.core.exception.YtDataValidationException; | ||
12 | +import org.thingsboard.server.common.data.yunteng.core.message.ErrorMessage; | ||
13 | +import org.thingsboard.server.common.data.yunteng.dto.ConfigurationDatasourceDTO; | ||
14 | +import org.thingsboard.server.dao.yunteng.entities.ConfigurationDatasource; | ||
15 | +import org.thingsboard.server.dao.yunteng.mapper.ConfigurationDatasourceMapper; | ||
16 | +import org.thingsboard.server.dao.yunteng.service.AbstractBaseService; | ||
17 | +import org.thingsboard.server.dao.yunteng.service.YtConfigurationDatasourceService; | ||
18 | + | ||
19 | +import java.util.List; | ||
20 | +import java.util.stream.Collectors; | ||
21 | + | ||
22 | +/** | ||
23 | + * @author Administrator | ||
24 | + */ | ||
25 | +@Slf4j | ||
26 | +@Service | ||
27 | +@RequiredArgsConstructor | ||
28 | +public class YtConfigurationDatasourceServiceImpl | ||
29 | + extends AbstractBaseService<ConfigurationDatasourceMapper, ConfigurationDatasource> | ||
30 | + implements YtConfigurationDatasourceService { | ||
31 | + | ||
32 | + @Override | ||
33 | + @Transactional(rollbackFor = Exception.class) | ||
34 | + public ConfigurationDatasourceDTO saveConfigurationDatasource(ConfigurationDatasourceDTO sourceDTO) { | ||
35 | + LambdaQueryWrapper<ConfigurationDatasource> filter = new QueryWrapper<ConfigurationDatasource>().lambda() | ||
36 | + .eq(ConfigurationDatasource::getNodeId, sourceDTO.getNodeId()); | ||
37 | + ConfigurationDatasource old = baseMapper.selectOne(filter); | ||
38 | + ConfigurationDatasource newData = sourceDTO.getEntity(ConfigurationDatasource.class); | ||
39 | + if (old == null) { | ||
40 | + baseMapper.insert(newData); | ||
41 | + } else if(!sourceDTO.getTenantId().equals(old.getTenantId())){ | ||
42 | + throw new YtDataValidationException(ErrorMessage.HAVE_NO_PERMISSION.getMessage()); | ||
43 | + } else { | ||
44 | + baseMapper.update(newData, filter); | ||
45 | + } | ||
46 | + return sourceDTO; | ||
47 | + } | ||
48 | + | ||
49 | + @Override | ||
50 | + @Transactional(rollbackFor = Exception.class) | ||
51 | + public boolean deleteConfigurationDatasource(ConfigurationDatasourceDTO sourceDTO) { | ||
52 | + LambdaQueryWrapper<ConfigurationDatasource> filter = new QueryWrapper<ConfigurationDatasource>().lambda() | ||
53 | + .eq(ConfigurationDatasource::getTenantId,sourceDTO.getTenantId()) | ||
54 | + .eq(StringUtils.isNotBlank(sourceDTO.getConfigurationId()), ConfigurationDatasource::getConfigurationId, sourceDTO.getConfigurationId()) | ||
55 | + .eq(StringUtils.isNotBlank(sourceDTO.getContentId()), ConfigurationDatasource::getContentId, sourceDTO.getContentId()) | ||
56 | + .eq(StringUtils.isNotBlank(sourceDTO.getNodeId()), ConfigurationDatasource::getNodeId, sourceDTO.getNodeId()); | ||
57 | + int result = baseMapper.delete(filter); | ||
58 | + return result > 0; | ||
59 | + } | ||
60 | + | ||
61 | + @Override | ||
62 | + public List<ConfigurationDatasourceDTO> listConfigurationDatasource(String tenantId,String levelType,String levelId) { | ||
63 | + if(!FastIotConstants.ConfigureLevel.CONTENT.equals(levelType) | ||
64 | + && !FastIotConstants.ConfigureLevel.NODE.equals(levelType)){ | ||
65 | + throw new YtDataValidationException("please provide correct levelType!"); | ||
66 | + } | ||
67 | + LambdaQueryWrapper<ConfigurationDatasource> filter = new QueryWrapper<ConfigurationDatasource>().lambda() | ||
68 | + .eq(ConfigurationDatasource::getTenantId,tenantId) | ||
69 | + .eq(FastIotConstants.ConfigureLevel.CONTENT.equals(levelType), ConfigurationDatasource::getContentId, levelId) | ||
70 | + .eq(FastIotConstants.ConfigureLevel.NODE.equals(levelType), ConfigurationDatasource::getNodeId, levelId); | ||
71 | + List<ConfigurationDatasource> result = baseMapper.selectList(filter); | ||
72 | + if (result == null || result.isEmpty()) { | ||
73 | + return null; | ||
74 | + } | ||
75 | + return result.stream() | ||
76 | + .map(i -> i.getDTO(ConfigurationDatasourceDTO.class)) | ||
77 | + .collect(Collectors.toList()); | ||
78 | + } | ||
79 | + | ||
80 | +} |
dao/src/main/java/org/thingsboard/server/dao/yunteng/impl/YtConfigurationEventServiceImpl.java
0 → 100644
1 | +package org.thingsboard.server.dao.yunteng.impl; | ||
2 | + | ||
3 | +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; | ||
4 | +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; | ||
5 | +import lombok.RequiredArgsConstructor; | ||
6 | +import lombok.extern.slf4j.Slf4j; | ||
7 | +import org.apache.commons.lang3.StringUtils; | ||
8 | +import org.springframework.stereotype.Service; | ||
9 | +import org.springframework.transaction.annotation.Transactional; | ||
10 | +import org.thingsboard.server.common.data.yunteng.constant.FastIotConstants; | ||
11 | +import org.thingsboard.server.common.data.yunteng.core.exception.YtDataValidationException; | ||
12 | +import org.thingsboard.server.common.data.yunteng.core.message.ErrorMessage; | ||
13 | +import org.thingsboard.server.common.data.yunteng.dto.ConfigurationEventDTO; | ||
14 | +import org.thingsboard.server.dao.yunteng.entities.ConfigurationDatasource; | ||
15 | +import org.thingsboard.server.dao.yunteng.entities.ConfigurationEvent; | ||
16 | +import org.thingsboard.server.dao.yunteng.mapper.ConfigurationEventMapper; | ||
17 | +import org.thingsboard.server.dao.yunteng.service.AbstractBaseService; | ||
18 | +import org.thingsboard.server.dao.yunteng.service.YtConfigurationEventService; | ||
19 | + | ||
20 | +import java.util.List; | ||
21 | +import java.util.stream.Collectors; | ||
22 | + | ||
23 | +/** | ||
24 | + * @author Administrator | ||
25 | + */ | ||
26 | +@Slf4j | ||
27 | +@Service | ||
28 | +@RequiredArgsConstructor | ||
29 | +public class YtConfigurationEventServiceImpl | ||
30 | + extends AbstractBaseService<ConfigurationEventMapper, ConfigurationEvent> | ||
31 | + implements YtConfigurationEventService { | ||
32 | + | ||
33 | + | ||
34 | + @Override | ||
35 | + @Transactional(rollbackFor = Exception.class) | ||
36 | + public ConfigurationEventDTO saveConfigurationEvent(ConfigurationEventDTO eventDTO) { | ||
37 | + LambdaQueryWrapper<ConfigurationEvent> filter = new QueryWrapper<ConfigurationEvent>().lambda() | ||
38 | + .eq(ConfigurationEvent::getTenantId,eventDTO.getTenantId()) | ||
39 | + .eq(ConfigurationEvent::getType, eventDTO.getType()) | ||
40 | + .eq(ConfigurationEvent::getId, eventDTO.getId()); | ||
41 | + ConfigurationEvent old = baseMapper.selectOne(filter); | ||
42 | + ConfigurationEvent newData = eventDTO.getEntity(ConfigurationEvent.class); | ||
43 | + if (old == null) { | ||
44 | + baseMapper.insert(newData); | ||
45 | + } else if(!eventDTO.getTenantId().equals(old.getTenantId())){ | ||
46 | + throw new YtDataValidationException(ErrorMessage.HAVE_NO_PERMISSION.getMessage()); | ||
47 | + } else { | ||
48 | + baseMapper.update(newData, filter); | ||
49 | + } | ||
50 | + return eventDTO; | ||
51 | + } | ||
52 | + | ||
53 | + @Override | ||
54 | + @Transactional(rollbackFor = Exception.class) | ||
55 | + public boolean deleteConfigurationEvent(ConfigurationEventDTO eventDTO) { | ||
56 | + LambdaQueryWrapper<ConfigurationEvent> filter = new QueryWrapper<ConfigurationEvent>().lambda() | ||
57 | + .eq(ConfigurationEvent::getTenantId,eventDTO.getTenantId()) | ||
58 | + .eq(StringUtils.isNotBlank(eventDTO.getConfigurationId()), ConfigurationEvent::getConfigurationId, eventDTO.getConfigurationId()) | ||
59 | + .eq(StringUtils.isNotBlank(eventDTO.getContentId()), ConfigurationEvent::getContentId, eventDTO.getContentId()) | ||
60 | + .eq(StringUtils.isNotBlank(eventDTO.getId()), ConfigurationEvent::getId, eventDTO.getId()); | ||
61 | + int result = baseMapper.delete(filter); | ||
62 | + return result > 0; | ||
63 | + } | ||
64 | + | ||
65 | + @Override | ||
66 | + public List<ConfigurationEventDTO> listConfigurationEvent(String tenantId,String levelType,String levelId) { | ||
67 | + if(!FastIotConstants.ConfigureLevel.CONTENT.equals(levelType) | ||
68 | + && !FastIotConstants.ConfigureLevel.NODE.equals(levelType)){ | ||
69 | + throw new YtDataValidationException("please provide correct levelType!"); | ||
70 | + } | ||
71 | + LambdaQueryWrapper<ConfigurationEvent> filter = new QueryWrapper<ConfigurationEvent>().lambda() | ||
72 | + .eq(ConfigurationEvent::getTenantId,tenantId) | ||
73 | + .eq(FastIotConstants.ConfigureLevel.CONTENT.equals(levelType), ConfigurationEvent::getContentId, levelId) | ||
74 | + .eq(FastIotConstants.ConfigureLevel.NODE.equals(levelType), ConfigurationEvent::getId, levelId); | ||
75 | + List<ConfigurationEvent> result = baseMapper.selectList(filter); | ||
76 | + if (result == null || result.isEmpty()) { | ||
77 | + return null; | ||
78 | + } | ||
79 | + return result.stream() | ||
80 | + .map(i -> i.getDTO(ConfigurationEventDTO.class)) | ||
81 | + .collect(Collectors.toList()); | ||
82 | + } | ||
83 | + | ||
84 | + | ||
85 | +} |
dao/src/main/java/org/thingsboard/server/dao/yunteng/mapper/ConfigurationDatasourceMapper.java
0 → 100644
1 | +package org.thingsboard.server.dao.yunteng.mapper; | ||
2 | + | ||
3 | +import com.baomidou.mybatisplus.core.mapper.BaseMapper; | ||
4 | +import org.apache.ibatis.annotations.Mapper; | ||
5 | +import org.thingsboard.server.dao.yunteng.entities.ConfigurationContent; | ||
6 | +import org.thingsboard.server.dao.yunteng.entities.ConfigurationDatasource; | ||
7 | + | ||
8 | +/** | ||
9 | + * @author Administrator | ||
10 | + */ | ||
11 | +@Mapper | ||
12 | +public interface ConfigurationDatasourceMapper extends BaseMapper<ConfigurationDatasource> { | ||
13 | +} |
dao/src/main/java/org/thingsboard/server/dao/yunteng/mapper/ConfigurationEventMapper.java
0 → 100644
1 | +package org.thingsboard.server.dao.yunteng.mapper; | ||
2 | + | ||
3 | +import com.baomidou.mybatisplus.core.mapper.BaseMapper; | ||
4 | +import org.apache.ibatis.annotations.Mapper; | ||
5 | +import org.thingsboard.server.dao.yunteng.entities.ConfigurationEvent; | ||
6 | + | ||
7 | +/** | ||
8 | + * @author Administrator | ||
9 | + */ | ||
10 | +@Mapper | ||
11 | +public interface ConfigurationEventMapper extends BaseMapper<ConfigurationEvent> { | ||
12 | +} |
dao/src/main/java/org/thingsboard/server/dao/yunteng/service/YtConfigurationDatasourceService.java
0 → 100644
1 | +package org.thingsboard.server.dao.yunteng.service; | ||
2 | + | ||
3 | +import io.swagger.annotations.ApiParam; | ||
4 | +import org.springframework.web.bind.annotation.PathVariable; | ||
5 | +import org.thingsboard.server.common.data.yunteng.dto.ConfigurationDatasourceDTO; | ||
6 | + | ||
7 | +import java.util.List; | ||
8 | + | ||
9 | +/** | ||
10 | + * @author Administrator | ||
11 | + */ | ||
12 | +public interface YtConfigurationDatasourceService { | ||
13 | + | ||
14 | + /** | ||
15 | + * 保存节点数据源,只会有1个 | ||
16 | + * | ||
17 | + * @param sourceDTO | ||
18 | + * @return | ||
19 | + */ | ||
20 | + ConfigurationDatasourceDTO saveConfigurationDatasource(ConfigurationDatasourceDTO sourceDTO); | ||
21 | + | ||
22 | + /** | ||
23 | + * 删除数据源信息 | ||
24 | + * | ||
25 | + * @param sourceDTO 组态ID、内容ID、结点ID任选其一 | ||
26 | + * @return | ||
27 | + */ | ||
28 | + boolean deleteConfigurationDatasource(ConfigurationDatasourceDTO sourceDTO); | ||
29 | + | ||
30 | + /** | ||
31 | + * 查看数据交互信息 | ||
32 | + * @param levelType 组件类型 | ||
33 | + * @param levelId 内容ID、结点ID任选其一 | ||
34 | + * @return | ||
35 | + */ | ||
36 | + List<ConfigurationDatasourceDTO> listConfigurationDatasource(String tenantId,String levelType,String levelId); | ||
37 | +} |
dao/src/main/java/org/thingsboard/server/dao/yunteng/service/YtConfigurationEventService.java
0 → 100644
1 | +package org.thingsboard.server.dao.yunteng.service; | ||
2 | + | ||
3 | +import org.thingsboard.server.common.data.yunteng.dto.ConfigurationEventDTO; | ||
4 | + | ||
5 | +import java.util.List; | ||
6 | + | ||
7 | +/** | ||
8 | + * @author Administrator | ||
9 | + */ | ||
10 | +public interface YtConfigurationEventService { | ||
11 | + | ||
12 | + /** | ||
13 | + * 保存节点数据交互信息,每种事件类型只会有1个 | ||
14 | + * | ||
15 | + * @param eventDTO | ||
16 | + * @return | ||
17 | + */ | ||
18 | + ConfigurationEventDTO saveConfigurationEvent(ConfigurationEventDTO eventDTO); | ||
19 | + | ||
20 | + /** | ||
21 | + * 删除数据交互信息 | ||
22 | + * | ||
23 | + * @param eventDTO 组态ID、内容ID、结点ID任选其一 | ||
24 | + * @return | ||
25 | + */ | ||
26 | + boolean deleteConfigurationEvent(ConfigurationEventDTO eventDTO); | ||
27 | + | ||
28 | + /** | ||
29 | + * 查看数据交互信息 | ||
30 | + * @param levelType 组件类型 | ||
31 | + * @param levelId 内容ID、结点ID任选其一 | ||
32 | + * @return | ||
33 | + */ | ||
34 | + List<ConfigurationEventDTO> listConfigurationEvent(String tenantId,String levelType,String levelId); | ||
35 | +} |