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 | 24 | import org.thingsboard.server.common.data.yunteng.common.UpdateGroup; |
25 | 25 | import org.thingsboard.server.common.data.yunteng.core.exception.TkDataValidationException; |
26 | 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 | 28 | import org.thingsboard.server.common.data.yunteng.dto.thingsmodel.ImportThingsModelDTO; |
32 | 29 | import org.thingsboard.server.common.data.yunteng.enums.FunctionTypeEnum; |
33 | 30 | import org.thingsboard.server.common.data.yunteng.enums.ImportEnum; |
... | ... | @@ -44,6 +41,7 @@ import java.io.IOException; |
44 | 41 | import java.io.InputStream; |
45 | 42 | import java.util.HashMap; |
46 | 43 | import java.util.List; |
44 | +import java.util.Map; | |
47 | 45 | |
48 | 46 | import static org.thingsboard.server.common.data.yunteng.constant.QueryConstant.*; |
49 | 47 | import static org.thingsboard.server.common.data.yunteng.constant.QueryConstant.ORDER_TYPE; |
... | ... | @@ -367,4 +365,16 @@ public class ThingsModelController extends BaseController { |
367 | 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 | 1 | package org.thingsboard.server.common.data.yunteng.dto; |
2 | 2 | |
3 | +import com.fasterxml.jackson.databind.JsonNode; | |
3 | 4 | import io.swagger.annotations.ApiModelProperty; |
4 | 5 | import lombok.Data; |
6 | +import org.thingsboard.server.common.data.yunteng.enums.FunctionTypeEnum; | |
5 | 7 | |
6 | 8 | @Data |
7 | 9 | public class BaseModelDTO { |
... | ... | @@ -10,4 +12,7 @@ public class BaseModelDTO { |
10 | 12 | |
11 | 13 | @ApiModelProperty(value = "标识符") |
12 | 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 | 188 | new LambdaQueryWrapper<TkThingsModelEntity>() |
189 | 189 | .eq(TkThingsModelEntity::getTenantId, tenantId) |
190 | 190 | .eq(TkThingsModelEntity::getDeviceProfileId, deviceProfileId) |
191 | - .eq(TkThingsModelEntity::getFunctionType, typeEnum) | |
191 | + .eq(!typeEnum.equals(FunctionTypeEnum.all),TkThingsModelEntity::getFunctionType, typeEnum) | |
192 | 192 | .eq(TkThingsModelEntity::getStatus, StatusEnum.ENABLE.getIndex())); |
193 | 193 | if (entityList.isEmpty()) { |
194 | 194 | return null; |
... | ... | @@ -267,11 +267,12 @@ public class ThingsModelServiceImpl |
267 | 267 | for (ThingsModelDTO thingsModelDTO : thingsModelDTOS) { |
268 | 268 | JsonNode functionJson = thingsModelDTO.getFunctionJson(); |
269 | 269 | if (null != functionJson) { |
270 | - switch (typeEnum) { | |
270 | + switch (thingsModelDTO.getFunctionType()) { | |
271 | 271 | case properties: |
272 | 272 | AttributeModelDTO attributeModelDTO = new AttributeModelDTO(); |
273 | 273 | BeanUtils.copyProperties(thingsModelDTO, attributeModelDTO); |
274 | 274 | attributeModelDTO.setSpecs(functionJson); |
275 | + attributeModelDTO.setFunctionType(FunctionTypeEnum.properties); | |
275 | 276 | serviceList.add(attributeModelDTO); |
276 | 277 | break; |
277 | 278 | case services: |
... | ... | @@ -279,12 +280,14 @@ public class ThingsModelServiceImpl |
279 | 280 | BeanUtils.copyProperties(thingsModelDTO, serviceDTO); |
280 | 281 | serviceDTO.setInputData(functionJson.get(inputData)); |
281 | 282 | serviceDTO.setOutputData(functionJson.get(outputData)); |
283 | + serviceDTO.setFunctionType(FunctionTypeEnum.services); | |
282 | 284 | serviceList.add(serviceDTO); |
283 | 285 | break; |
284 | 286 | case events: |
285 | 287 | EventModelDTO eventDTO = new EventModelDTO(); |
286 | 288 | BeanUtils.copyProperties(thingsModelDTO, eventDTO); |
287 | 289 | eventDTO.setOutputData(functionJson.get(outputData)); |
290 | + eventDTO.setFunctionType(FunctionTypeEnum.events); | |
288 | 291 | serviceList.add(eventDTO); |
289 | 292 | break; |
290 | 293 | default: |
... | ... | @@ -440,6 +443,30 @@ public class ThingsModelServiceImpl |
440 | 443 | } |
441 | 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 | 470 | private void checkNameAndIdentifier( |
444 | 471 | List<String> existIdentifiers, |
445 | 472 | FunctionTypeEnum functionType, | ... | ... |
... | ... | @@ -74,9 +74,11 @@ public class TkVideoServiceImpl extends AbstractBaseService<TkVideoMapper, TkVid |
74 | 74 | videoDTO.getId())); |
75 | 75 | } |
76 | 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 | 82 | baseMapper.updateById(videoDTO.getEntity(TkVideoEntity.class)); |
81 | 83 | } else { |
82 | 84 | baseMapper.insert(videoDTO.getEntity(TkVideoEntity.class)); | ... | ... |
1 | 1 | package org.thingsboard.server.dao.yunteng.service; |
2 | 2 | |
3 | 3 | import com.fasterxml.jackson.databind.JsonNode; |
4 | +import org.thingsboard.server.common.data.yunteng.dto.BatchDeviceProfileInfoDTO; | |
4 | 5 | import org.thingsboard.server.common.data.yunteng.dto.DeleteDTO; |
5 | 6 | import org.thingsboard.server.common.data.yunteng.dto.ThingsModelDTO; |
6 | 7 | import org.thingsboard.server.common.data.yunteng.dto.TkThingsModel; |
... | ... | @@ -50,8 +51,14 @@ public interface ThingsModelService extends BaseService<TkThingsModelEntity>{ |
50 | 51 | |
51 | 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 | } | ... | ... |