Commit 79d6d734a4e0f1cd87e0e78249c4d2beacd87ebc

Authored by xp.Huang
2 parents e64dfc6f 6fcc371f

Merge branch '2021-01-23-bug' into 'master_dev'

2021 01 23 bug

See merge request yunteng/thingskit!320
@@ -119,16 +119,16 @@ public class TkDeviceProfileController extends BaseController { @@ -119,16 +119,16 @@ public class TkDeviceProfileController extends BaseController {
119 @PreAuthorize("@check.checkPermissions({'TENANT_ADMIN','CUSTOMER_USER'},{})") 119 @PreAuthorize("@check.checkPermissions({'TENANT_ADMIN','CUSTOMER_USER'},{})")
120 public ResponseEntity listDeviceProfile( 120 public ResponseEntity listDeviceProfile(
121 @ApiParam(value = "设备类型") @RequestParam(value = "deviceType", required = false) 121 @ApiParam(value = "设备类型") @RequestParam(value = "deviceType", required = false)
122 - DeviceTypeEnum deviceType) 122 + DeviceTypeEnum deviceType,DeviceTransportType transportType)
123 throws ThingsboardException { 123 throws ThingsboardException {
124 List<DeviceProfileDTO> results; 124 List<DeviceProfileDTO> results;
125 String tenantId = getCurrentUser().getCurrentTenantId(); 125 String tenantId = getCurrentUser().getCurrentTenantId();
126 if (getCurrentUser().isTenantAdmin()) { 126 if (getCurrentUser().isTenantAdmin()) {
127 - results = tkDeviceProfileService.findDeviceProfile(tenantId, null,deviceType); 127 + results = tkDeviceProfileService.findDeviceProfile(tenantId, null,deviceType,transportType);
128 } else { 128 } else {
129 results = 129 results =
130 tkDeviceProfileService.findCustomerDeviceProfiles( 130 tkDeviceProfileService.findCustomerDeviceProfiles(
131 - tenantId, getCurrentUser().getCustomerId(),deviceType); 131 + tenantId, getCurrentUser().getCustomerId(),deviceType,transportType);
132 } 132 }
133 133
134 return ResponseEntity.ok(results); 134 return ResponseEntity.ok(results);
1 package org.thingsboard.server.dao.yunteng.entities; 1 package org.thingsboard.server.dao.yunteng.entities;
2 2
  3 +import com.baomidou.mybatisplus.annotation.FieldFill;
3 import com.baomidou.mybatisplus.annotation.FieldStrategy; 4 import com.baomidou.mybatisplus.annotation.FieldStrategy;
4 import com.baomidou.mybatisplus.annotation.TableField; 5 import com.baomidou.mybatisplus.annotation.TableField;
5 import com.baomidou.mybatisplus.annotation.TableName; 6 import com.baomidou.mybatisplus.annotation.TableName;
@@ -20,6 +21,7 @@ public class TkVideoEntity extends TenantBaseEntity { @@ -20,6 +21,7 @@ public class TkVideoEntity extends TenantBaseEntity {
20 private static final long serialVersionUID = 1498859811403607497L; 21 private static final long serialVersionUID = 1498859811403607497L;
21 private String name; 22 private String name;
22 private String additionalJson; 23 private String additionalJson;
  24 + @TableField(fill = FieldFill.UPDATE)
23 private String avatar; 25 private String avatar;
24 private String videoUrl; 26 private String videoUrl;
25 private String brand; 27 private String brand;
@@ -292,13 +292,13 @@ public class TkDeviceProfileServiceImpl @@ -292,13 +292,13 @@ public class TkDeviceProfileServiceImpl
292 292
293 @Override 293 @Override
294 public List<DeviceProfileDTO> findDeviceProfile( 294 public List<DeviceProfileDTO> findDeviceProfile(
295 - String tenantId, String scriptId, DeviceTypeEnum deviceType) {  
296 - return baseMapper.profileByScriptId(tenantId, scriptId, deviceType); 295 + String tenantId, String scriptId, DeviceTypeEnum deviceType,DeviceTransportType transportType) {
  296 + return baseMapper.profileByScriptId(tenantId, scriptId, deviceType,transportType,null);
297 } 297 }
298 298
299 @Override 299 @Override
300 public List<DeviceProfileDTO> findCustomerDeviceProfiles( 300 public List<DeviceProfileDTO> findCustomerDeviceProfiles(
301 - String tenantId, CustomerId customerId, DeviceTypeEnum deviceType) { 301 + String tenantId, CustomerId customerId, DeviceTypeEnum deviceType,DeviceTransportType transportType) {
302 List<DeviceDTO> deviceDTOS = 302 List<DeviceDTO> deviceDTOS =
303 deviceMapper.findDeviceInfoByCustomerId(tenantId, customerId.toString()); 303 deviceMapper.findDeviceInfoByCustomerId(tenantId, customerId.toString());
304 List<String> deviceProfileIds = 304 List<String> deviceProfileIds =
@@ -312,18 +312,7 @@ public class TkDeviceProfileServiceImpl @@ -312,18 +312,7 @@ public class TkDeviceProfileServiceImpl
312 if (null == deviceProfileIds || deviceProfileIds.isEmpty()) { 312 if (null == deviceProfileIds || deviceProfileIds.isEmpty()) {
313 return null; 313 return null;
314 } 314 }
315 - List<TkDeviceProfileEntity> entities =  
316 - baseMapper.selectList(  
317 - new LambdaQueryWrapper<TkDeviceProfileEntity>()  
318 - .eq(TkDeviceProfileEntity::getTenantId, tenantId)  
319 - .eq(null != deviceType, TkDeviceProfileEntity::getDeviceType, deviceType)  
320 - .in(TkDeviceProfileEntity::getId, deviceProfileIds));  
321 - if (null != entities && !entities.isEmpty()) {  
322 - return entities.stream()  
323 - .map(obj -> obj.getDTO(DeviceProfileDTO.class))  
324 - .collect(Collectors.toList());  
325 - }  
326 - return null; 315 + return baseMapper.profileByScriptId(tenantId, null, deviceType,transportType,deviceProfileIds);
327 } 316 }
328 317
329 @Override 318 @Override
@@ -133,7 +133,7 @@ public class TkHomePageServiceImpl implements HomePageService { @@ -133,7 +133,7 @@ public class TkHomePageServiceImpl implements HomePageService {
133 if (StringUtils.isNotEmpty(customerId)) { 133 if (StringUtils.isNotEmpty(customerId)) {
134 deviceProfileDTOList = 134 deviceProfileDTOList =
135 tkDeviceProfileService.findCustomerDeviceProfiles( 135 tkDeviceProfileService.findCustomerDeviceProfiles(
136 - tenantId, new CustomerId(UUID.fromString(customerId)), null); 136 + tenantId, new CustomerId(UUID.fromString(customerId)), null,null);
137 } 137 }
138 } 138 }
139 int todayAdd = zero; 139 int todayAdd = zero;
@@ -33,7 +33,9 @@ public interface TkDeviceProfileMapper extends BaseMapper<TkDeviceProfileEntity> @@ -33,7 +33,9 @@ public interface TkDeviceProfileMapper extends BaseMapper<TkDeviceProfileEntity>
33 List<DeviceProfileDTO> profileByScriptId( 33 List<DeviceProfileDTO> profileByScriptId(
34 @Param("tenantId") String tenantId, 34 @Param("tenantId") String tenantId,
35 @Param("scriptId") String scriptId, 35 @Param("scriptId") String scriptId,
36 - @Param("deviceType") DeviceTypeEnum deviceType); 36 + @Param("deviceType") DeviceTypeEnum deviceType,
  37 + @Param("transportType")DeviceTransportType transportType,
  38 + @Param("deviceProfileIds")List<String> deviceProfileIds);
37 39
38 List<DeviceProfileDTO> profileByTransportAndIds( 40 List<DeviceProfileDTO> profileByTransportAndIds(
39 @Param("tenantId") String tenantId, 41 @Param("tenantId") String tenantId,
1 package org.thingsboard.server.dao.yunteng.service; 1 package org.thingsboard.server.dao.yunteng.service;
2 2
  3 +import org.thingsboard.server.common.data.DeviceTransportType;
3 import org.thingsboard.server.common.data.id.CustomerId; 4 import org.thingsboard.server.common.data.id.CustomerId;
4 import org.thingsboard.server.common.data.yunteng.dto.DeviceProfileDTO; 5 import org.thingsboard.server.common.data.yunteng.dto.DeviceProfileDTO;
5 import org.thingsboard.server.common.data.yunteng.enums.DeviceTypeEnum; 6 import org.thingsboard.server.common.data.yunteng.enums.DeviceTypeEnum;
@@ -25,10 +26,10 @@ public interface TkDeviceProfileService extends BaseService<TkDeviceProfileEntit @@ -25,10 +26,10 @@ public interface TkDeviceProfileService extends BaseService<TkDeviceProfileEntit
25 TkPageData<DeviceProfileDTO> page(Map<String, Object> queryMap, boolean isTenantAdmin); 26 TkPageData<DeviceProfileDTO> page(Map<String, Object> queryMap, boolean isTenantAdmin);
26 27
27 List<DeviceProfileDTO> findDeviceProfile( 28 List<DeviceProfileDTO> findDeviceProfile(
28 - String tenantId, String scriptId, DeviceTypeEnum deviceType); 29 + String tenantId, String scriptId, DeviceTypeEnum deviceType, DeviceTransportType transportType);
29 30
30 List<DeviceProfileDTO> findCustomerDeviceProfiles( 31 List<DeviceProfileDTO> findCustomerDeviceProfiles(
31 - String tenantId, CustomerId customerId, DeviceTypeEnum deviceType); 32 + String tenantId, CustomerId customerId, DeviceTypeEnum deviceType,DeviceTransportType transportType);
32 33
33 List<DeviceProfileDTO> findDeviceProfileByIds(String tenantId, List<String> ids, TransportTypeEnum transportType); 34 List<DeviceProfileDTO> findDeviceProfileByIds(String tenantId, List<String> ids, TransportTypeEnum transportType);
34 35
@@ -85,6 +85,16 @@ @@ -85,6 +85,16 @@
85 <if test="deviceType !=null"> 85 <if test="deviceType !=null">
86 AND iot.device_type = #{deviceType} 86 AND iot.device_type = #{deviceType}
87 </if> 87 </if>
  88 + <if test="transportType !=null">
  89 + AND base.transport_type = #{transportType}
  90 + </if>
  91 + <if test="deviceProfileIds != null">
  92 + AND base.id IN
  93 + <foreach collection="deviceProfileIds" item="deviceProfile_id" open="(" separator="," close=")">
  94 + #{deviceProfile_id}
  95 + </foreach>
  96 + </if>
  97 +
88 </where> 98 </where>
89 </select> 99 </select>
90 100