Commit 6fcc371fc7d2f04555917d097e9aa18f83040d57

Authored by chenjunyu_1481036421
1 parent bbe3d106

fix:批量处理产品更换产品只能选择对应协议产品

... ... @@ -119,16 +119,16 @@ public class TkDeviceProfileController extends BaseController {
119 119 @PreAuthorize("@check.checkPermissions({'TENANT_ADMIN','CUSTOMER_USER'},{})")
120 120 public ResponseEntity listDeviceProfile(
121 121 @ApiParam(value = "设备类型") @RequestParam(value = "deviceType", required = false)
122   - DeviceTypeEnum deviceType)
  122 + DeviceTypeEnum deviceType,DeviceTransportType transportType)
123 123 throws ThingsboardException {
124 124 List<DeviceProfileDTO> results;
125 125 String tenantId = getCurrentUser().getCurrentTenantId();
126 126 if (getCurrentUser().isTenantAdmin()) {
127   - results = tkDeviceProfileService.findDeviceProfile(tenantId, null,deviceType);
  127 + results = tkDeviceProfileService.findDeviceProfile(tenantId, null,deviceType,transportType);
128 128 } else {
129 129 results =
130 130 tkDeviceProfileService.findCustomerDeviceProfiles(
131   - tenantId, getCurrentUser().getCustomerId(),deviceType);
  131 + tenantId, getCurrentUser().getCustomerId(),deviceType,transportType);
132 132 }
133 133
134 134 return ResponseEntity.ok(results);
... ...
... ... @@ -292,13 +292,13 @@ public class TkDeviceProfileServiceImpl
292 292
293 293 @Override
294 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 299 @Override
300 300 public List<DeviceProfileDTO> findCustomerDeviceProfiles(
301   - String tenantId, CustomerId customerId, DeviceTypeEnum deviceType) {
  301 + String tenantId, CustomerId customerId, DeviceTypeEnum deviceType,DeviceTransportType transportType) {
302 302 List<DeviceDTO> deviceDTOS =
303 303 deviceMapper.findDeviceInfoByCustomerId(tenantId, customerId.toString());
304 304 List<String> deviceProfileIds =
... ... @@ -312,18 +312,7 @@ public class TkDeviceProfileServiceImpl
312 312 if (null == deviceProfileIds || deviceProfileIds.isEmpty()) {
313 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 318 @Override
... ...
... ... @@ -133,7 +133,7 @@ public class TkHomePageServiceImpl implements HomePageService {
133 133 if (StringUtils.isNotEmpty(customerId)) {
134 134 deviceProfileDTOList =
135 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 139 int todayAdd = zero;
... ...
... ... @@ -33,7 +33,9 @@ public interface TkDeviceProfileMapper extends BaseMapper<TkDeviceProfileEntity>
33 33 List<DeviceProfileDTO> profileByScriptId(
34 34 @Param("tenantId") String tenantId,
35 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 40 List<DeviceProfileDTO> profileByTransportAndIds(
39 41 @Param("tenantId") String tenantId,
... ...
1 1 package org.thingsboard.server.dao.yunteng.service;
2 2
  3 +import org.thingsboard.server.common.data.DeviceTransportType;
3 4 import org.thingsboard.server.common.data.id.CustomerId;
4 5 import org.thingsboard.server.common.data.yunteng.dto.DeviceProfileDTO;
5 6 import org.thingsboard.server.common.data.yunteng.enums.DeviceTypeEnum;
... ... @@ -25,10 +26,10 @@ public interface TkDeviceProfileService extends BaseService<TkDeviceProfileEntit
25 26 TkPageData<DeviceProfileDTO> page(Map<String, Object> queryMap, boolean isTenantAdmin);
26 27
27 28 List<DeviceProfileDTO> findDeviceProfile(
28   - String tenantId, String scriptId, DeviceTypeEnum deviceType);
  29 + String tenantId, String scriptId, DeviceTypeEnum deviceType, DeviceTransportType transportType);
29 30
30 31 List<DeviceProfileDTO> findCustomerDeviceProfiles(
31   - String tenantId, CustomerId customerId, DeviceTypeEnum deviceType);
  32 + String tenantId, CustomerId customerId, DeviceTypeEnum deviceType,DeviceTransportType transportType);
32 33
33 34 List<DeviceProfileDTO> findDeviceProfileByIds(String tenantId, List<String> ids, TransportTypeEnum transportType);
34 35
... ...
... ... @@ -85,6 +85,16 @@
85 85 <if test="deviceType !=null">
86 86 AND iot.device_type = #{deviceType}
87 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 98 </where>
89 99 </select>
90 100
... ...