Commit 415e6b0fba3eace56a4c07146303206407cc8e33
Merge branch 'master_dev' into 'master'
Master dev See merge request yunteng/thingskit!314
Showing
7 changed files
with
101 additions
and
12 deletions
@@ -24,10 +24,7 @@ import org.thingsboard.server.common.data.yunteng.common.DeleteGroup; | @@ -24,10 +24,7 @@ import org.thingsboard.server.common.data.yunteng.common.DeleteGroup; | ||
24 | import org.thingsboard.server.common.data.yunteng.common.UpdateGroup; | 24 | import org.thingsboard.server.common.data.yunteng.common.UpdateGroup; |
25 | import org.thingsboard.server.common.data.yunteng.core.exception.TkDataValidationException; | 25 | import org.thingsboard.server.common.data.yunteng.core.exception.TkDataValidationException; |
26 | import org.thingsboard.server.common.data.yunteng.core.message.ErrorMessage; | 26 | import org.thingsboard.server.common.data.yunteng.core.message.ErrorMessage; |
27 | -import org.thingsboard.server.common.data.yunteng.dto.DeleteDTO; | ||
28 | -import org.thingsboard.server.common.data.yunteng.dto.DeviceProfileDTO; | ||
29 | -import org.thingsboard.server.common.data.yunteng.dto.ThingsModelDTO; | ||
30 | -import org.thingsboard.server.common.data.yunteng.dto.TkThingsModel; | 27 | +import org.thingsboard.server.common.data.yunteng.dto.*; |
31 | import org.thingsboard.server.common.data.yunteng.dto.thingsmodel.ImportThingsModelDTO; | 28 | import org.thingsboard.server.common.data.yunteng.dto.thingsmodel.ImportThingsModelDTO; |
32 | import org.thingsboard.server.common.data.yunteng.enums.FunctionTypeEnum; | 29 | import org.thingsboard.server.common.data.yunteng.enums.FunctionTypeEnum; |
33 | import org.thingsboard.server.common.data.yunteng.enums.ImportEnum; | 30 | import org.thingsboard.server.common.data.yunteng.enums.ImportEnum; |
@@ -44,6 +41,7 @@ import java.io.IOException; | @@ -44,6 +41,7 @@ import java.io.IOException; | ||
44 | import java.io.InputStream; | 41 | import java.io.InputStream; |
45 | import java.util.HashMap; | 42 | import java.util.HashMap; |
46 | import java.util.List; | 43 | import java.util.List; |
44 | +import java.util.Map; | ||
47 | 45 | ||
48 | import static org.thingsboard.server.common.data.yunteng.constant.QueryConstant.*; | 46 | import static org.thingsboard.server.common.data.yunteng.constant.QueryConstant.*; |
49 | import static org.thingsboard.server.common.data.yunteng.constant.QueryConstant.ORDER_TYPE; | 47 | import static org.thingsboard.server.common.data.yunteng.constant.QueryConstant.ORDER_TYPE; |
@@ -367,4 +365,16 @@ public class ThingsModelController extends BaseController { | @@ -367,4 +365,16 @@ public class ThingsModelController extends BaseController { | ||
367 | return null; | 365 | return null; |
368 | } | 366 | } |
369 | } | 367 | } |
368 | + | ||
369 | + @PostMapping("/batch/get_tsl") | ||
370 | + @ApiOperation("获取多个产品的物模型数据") | ||
371 | + public ResponseEntity<List<BatchDeviceProfileInfoDTO>> getDeviceProfilesTSL(@RequestBody DeviceProfileTSLDTO profileTSLDTO) | ||
372 | + throws ThingsboardException { | ||
373 | + if(null == profileTSLDTO.getDeviceProfileIds() || null == profileTSLDTO.getFunctionTypeEnum() || | ||
374 | + profileTSLDTO.getDeviceProfileIds().isEmpty()){ | ||
375 | + throw new TkDataValidationException(ErrorMessage.INVALID_PARAMETER.getMessage()); | ||
376 | + } | ||
377 | + return ResponseEntity.ok(thingsModelService.getDeviceProfileTSLInfoByIds(getCurrentUser().getCurrentTenantId(), | ||
378 | + profileTSLDTO.getDeviceProfileIds(),profileTSLDTO.getFunctionTypeEnum())); | ||
379 | + } | ||
370 | } | 380 | } |
1 | package org.thingsboard.server.common.data.yunteng.dto; | 1 | package org.thingsboard.server.common.data.yunteng.dto; |
2 | 2 | ||
3 | +import com.fasterxml.jackson.databind.JsonNode; | ||
3 | import io.swagger.annotations.ApiModelProperty; | 4 | import io.swagger.annotations.ApiModelProperty; |
4 | import lombok.Data; | 5 | import lombok.Data; |
6 | +import org.thingsboard.server.common.data.yunteng.enums.FunctionTypeEnum; | ||
5 | 7 | ||
6 | @Data | 8 | @Data |
7 | public class BaseModelDTO { | 9 | public class BaseModelDTO { |
@@ -10,4 +12,7 @@ public class BaseModelDTO { | @@ -10,4 +12,7 @@ public class BaseModelDTO { | ||
10 | 12 | ||
11 | @ApiModelProperty(value = "标识符") | 13 | @ApiModelProperty(value = "标识符") |
12 | private String identifier; | 14 | private String identifier; |
15 | + | ||
16 | + @ApiModelProperty(value = "功能类型") | ||
17 | + private FunctionTypeEnum functionType; | ||
13 | } | 18 | } |
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 org.thingsboard.server.common.data.yunteng.enums.DeviceTypeEnum; | ||
7 | + | ||
8 | +@Data | ||
9 | +public class BatchDeviceProfileInfoDTO { | ||
10 | + | ||
11 | + @ApiModelProperty(value = "产品ID/设备配置ID") | ||
12 | + private String id; | ||
13 | + @ApiModelProperty(value = "产品名称/设备配置名称") | ||
14 | + private String name; | ||
15 | + @ApiModelProperty(value = "传输协议") | ||
16 | + private String transportType; | ||
17 | + @ApiModelProperty(value = "产品类型:GATEWAY,DIRECT_CONNECTION,SENSOR") | ||
18 | + private DeviceTypeEnum deviceType; | ||
19 | + @ApiModelProperty(value = "物模型TSL") | ||
20 | + private JsonNode tsl; | ||
21 | +} |
common/data/src/main/java/org/thingsboard/server/common/data/yunteng/dto/DeviceProfileTSLDTO.java
0 → 100644
1 | +package org.thingsboard.server.common.data.yunteng.dto; | ||
2 | + | ||
3 | +import io.swagger.annotations.ApiModelProperty; | ||
4 | +import lombok.Data; | ||
5 | +import org.thingsboard.server.common.data.yunteng.enums.FunctionTypeEnum; | ||
6 | + | ||
7 | +import java.util.List; | ||
8 | + | ||
9 | +@Data | ||
10 | +public class DeviceProfileTSLDTO { | ||
11 | + | ||
12 | + @ApiModelProperty(value = "产品id列表", required = true) | ||
13 | + private List<String> deviceProfileIds; | ||
14 | + | ||
15 | + @ApiModelProperty(value = "查询的物模型类型", required = true) | ||
16 | + private FunctionTypeEnum functionTypeEnum; | ||
17 | +} |
@@ -188,7 +188,7 @@ public class ThingsModelServiceImpl | @@ -188,7 +188,7 @@ public class ThingsModelServiceImpl | ||
188 | new LambdaQueryWrapper<TkThingsModelEntity>() | 188 | new LambdaQueryWrapper<TkThingsModelEntity>() |
189 | .eq(TkThingsModelEntity::getTenantId, tenantId) | 189 | .eq(TkThingsModelEntity::getTenantId, tenantId) |
190 | .eq(TkThingsModelEntity::getDeviceProfileId, deviceProfileId) | 190 | .eq(TkThingsModelEntity::getDeviceProfileId, deviceProfileId) |
191 | - .eq(TkThingsModelEntity::getFunctionType, typeEnum) | 191 | + .eq(!typeEnum.equals(FunctionTypeEnum.all),TkThingsModelEntity::getFunctionType, typeEnum) |
192 | .eq(TkThingsModelEntity::getStatus, StatusEnum.ENABLE.getIndex())); | 192 | .eq(TkThingsModelEntity::getStatus, StatusEnum.ENABLE.getIndex())); |
193 | if (entityList.isEmpty()) { | 193 | if (entityList.isEmpty()) { |
194 | return null; | 194 | return null; |
@@ -267,11 +267,12 @@ public class ThingsModelServiceImpl | @@ -267,11 +267,12 @@ public class ThingsModelServiceImpl | ||
267 | for (ThingsModelDTO thingsModelDTO : thingsModelDTOS) { | 267 | for (ThingsModelDTO thingsModelDTO : thingsModelDTOS) { |
268 | JsonNode functionJson = thingsModelDTO.getFunctionJson(); | 268 | JsonNode functionJson = thingsModelDTO.getFunctionJson(); |
269 | if (null != functionJson) { | 269 | if (null != functionJson) { |
270 | - switch (typeEnum) { | 270 | + switch (thingsModelDTO.getFunctionType()) { |
271 | case properties: | 271 | case properties: |
272 | AttributeModelDTO attributeModelDTO = new AttributeModelDTO(); | 272 | AttributeModelDTO attributeModelDTO = new AttributeModelDTO(); |
273 | BeanUtils.copyProperties(thingsModelDTO, attributeModelDTO); | 273 | BeanUtils.copyProperties(thingsModelDTO, attributeModelDTO); |
274 | attributeModelDTO.setSpecs(functionJson); | 274 | attributeModelDTO.setSpecs(functionJson); |
275 | + attributeModelDTO.setFunctionType(FunctionTypeEnum.properties); | ||
275 | serviceList.add(attributeModelDTO); | 276 | serviceList.add(attributeModelDTO); |
276 | break; | 277 | break; |
277 | case services: | 278 | case services: |
@@ -279,12 +280,14 @@ public class ThingsModelServiceImpl | @@ -279,12 +280,14 @@ public class ThingsModelServiceImpl | ||
279 | BeanUtils.copyProperties(thingsModelDTO, serviceDTO); | 280 | BeanUtils.copyProperties(thingsModelDTO, serviceDTO); |
280 | serviceDTO.setInputData(functionJson.get(inputData)); | 281 | serviceDTO.setInputData(functionJson.get(inputData)); |
281 | serviceDTO.setOutputData(functionJson.get(outputData)); | 282 | serviceDTO.setOutputData(functionJson.get(outputData)); |
283 | + serviceDTO.setFunctionType(FunctionTypeEnum.services); | ||
282 | serviceList.add(serviceDTO); | 284 | serviceList.add(serviceDTO); |
283 | break; | 285 | break; |
284 | case events: | 286 | case events: |
285 | EventModelDTO eventDTO = new EventModelDTO(); | 287 | EventModelDTO eventDTO = new EventModelDTO(); |
286 | BeanUtils.copyProperties(thingsModelDTO, eventDTO); | 288 | BeanUtils.copyProperties(thingsModelDTO, eventDTO); |
287 | eventDTO.setOutputData(functionJson.get(outputData)); | 289 | eventDTO.setOutputData(functionJson.get(outputData)); |
290 | + eventDTO.setFunctionType(FunctionTypeEnum.events); | ||
288 | serviceList.add(eventDTO); | 291 | serviceList.add(eventDTO); |
289 | break; | 292 | break; |
290 | default: | 293 | default: |
@@ -440,6 +443,30 @@ public class ThingsModelServiceImpl | @@ -440,6 +443,30 @@ public class ThingsModelServiceImpl | ||
440 | } | 443 | } |
441 | return true; | 444 | return true; |
442 | } | 445 | } |
446 | + | ||
447 | + @Override | ||
448 | + public List<BatchDeviceProfileInfoDTO> getDeviceProfileTSLInfoByIds(String tenantId, List<String> deviceProfileIds, FunctionTypeEnum functionTypeEnum) { | ||
449 | + List<BatchDeviceProfileInfoDTO> list = new ArrayList<>(); | ||
450 | + if(null != deviceProfileIds && !deviceProfileIds.isEmpty()){ | ||
451 | + deviceProfileIds.stream().forEach(deviceProfileId->{ | ||
452 | + BatchDeviceProfileInfoDTO batchDeviceProfileInfo = new BatchDeviceProfileInfoDTO(); | ||
453 | + DeviceProfileDTO deviceProfileDTO = tkDeviceProfileService.getDeviceProfile(tenantId,deviceProfileId); | ||
454 | + if(null != deviceProfileDTO){ | ||
455 | + batchDeviceProfileInfo.setId(deviceProfileId); | ||
456 | + batchDeviceProfileInfo.setName(deviceProfileDTO.getName()); | ||
457 | + batchDeviceProfileInfo.setDeviceType(deviceProfileDTO.getDeviceType()); | ||
458 | + batchDeviceProfileInfo.setTransportType(deviceProfileDTO.getTransportType()); | ||
459 | + JsonNode tsl = getTingsModelTSL(functionTypeEnum,tenantId,deviceProfileId); | ||
460 | + if(null != tsl && tsl.isArray()){ | ||
461 | + batchDeviceProfileInfo.setTsl(tsl); | ||
462 | + } | ||
463 | + list.add(batchDeviceProfileInfo); | ||
464 | + } | ||
465 | + }); | ||
466 | + } | ||
467 | + return list; | ||
468 | + } | ||
469 | + | ||
443 | private void checkNameAndIdentifier( | 470 | private void checkNameAndIdentifier( |
444 | List<String> existIdentifiers, | 471 | List<String> existIdentifiers, |
445 | FunctionTypeEnum functionType, | 472 | FunctionTypeEnum functionType, |
@@ -74,9 +74,11 @@ public class TkVideoServiceImpl extends AbstractBaseService<TkVideoMapper, TkVid | @@ -74,9 +74,11 @@ public class TkVideoServiceImpl extends AbstractBaseService<TkVideoMapper, TkVid | ||
74 | videoDTO.getId())); | 74 | videoDTO.getId())); |
75 | } | 75 | } |
76 | TkVideoPlatformEntity platform = tkVideoPlatformMapper.selectById(videoDTO.getVideoPlatformId()); | 76 | TkVideoPlatformEntity platform = tkVideoPlatformMapper.selectById(videoDTO.getVideoPlatformId()); |
77 | - String paramKey = videoDTO.getParams()==null?"":(videoDTO.getParams().get("channelNo")==null?"": | ||
78 | - "&channelNo="+videoDTO.getParams().get("channelNo").intValue()); | ||
79 | - VideoUrlUtils.clearVideoUrlData(platform.getAppKey()+videoDTO.getSn()+paramKey); | 77 | + if(platform!=null){ |
78 | + String paramKey = videoDTO.getParams()==null?"":(videoDTO.getParams().get("channelNo")==null?"": | ||
79 | + "&channelNo="+videoDTO.getParams().get("channelNo").intValue()); | ||
80 | + VideoUrlUtils.clearVideoUrlData(platform.getAppKey()+videoDTO.getSn()+paramKey); | ||
81 | + } | ||
80 | baseMapper.updateById(videoDTO.getEntity(TkVideoEntity.class)); | 82 | baseMapper.updateById(videoDTO.getEntity(TkVideoEntity.class)); |
81 | } else { | 83 | } else { |
82 | baseMapper.insert(videoDTO.getEntity(TkVideoEntity.class)); | 84 | baseMapper.insert(videoDTO.getEntity(TkVideoEntity.class)); |
1 | package org.thingsboard.server.dao.yunteng.service; | 1 | package org.thingsboard.server.dao.yunteng.service; |
2 | 2 | ||
3 | import com.fasterxml.jackson.databind.JsonNode; | 3 | import com.fasterxml.jackson.databind.JsonNode; |
4 | +import org.thingsboard.server.common.data.yunteng.dto.BatchDeviceProfileInfoDTO; | ||
4 | import org.thingsboard.server.common.data.yunteng.dto.DeleteDTO; | 5 | import org.thingsboard.server.common.data.yunteng.dto.DeleteDTO; |
5 | import org.thingsboard.server.common.data.yunteng.dto.ThingsModelDTO; | 6 | import org.thingsboard.server.common.data.yunteng.dto.ThingsModelDTO; |
6 | import org.thingsboard.server.common.data.yunteng.dto.TkThingsModel; | 7 | import org.thingsboard.server.common.data.yunteng.dto.TkThingsModel; |
@@ -50,8 +51,14 @@ public interface ThingsModelService extends BaseService<TkThingsModelEntity>{ | @@ -50,8 +51,14 @@ public interface ThingsModelService extends BaseService<TkThingsModelEntity>{ | ||
50 | 51 | ||
51 | boolean getByIdentifier(String tenantId, String deviceProfileId,String categoryId,String identifier); | 52 | boolean getByIdentifier(String tenantId, String deviceProfileId,String categoryId,String identifier); |
52 | 53 | ||
53 | - | ||
54 | - | ||
55 | - | 54 | + /** |
55 | + * 获取对应产品列表的物模型信息 | ||
56 | + * @param tenantId 租户ID | ||
57 | + * @param deviceProfileIds 产品列表 | ||
58 | + * @param functionTypeEnum | ||
59 | + * @return | ||
60 | + */ | ||
61 | + List<BatchDeviceProfileInfoDTO> getDeviceProfileTSLInfoByIds(String tenantId, List<String> deviceProfileIds, | ||
62 | + FunctionTypeEnum functionTypeEnum); | ||
56 | 63 | ||
57 | } | 64 | } |