Commit 122a546d71243608577ec13398cf572ecbf9087c

Authored by 黄 x
1 parent d401024d

fix: tk_device add column device_profile_id tk_do_action add column call_type\co…

…mmand_type\things_model_id\device_profile_id
@@ -206,7 +206,7 @@ public class YtDeviceController extends BaseController { @@ -206,7 +206,7 @@ public class YtDeviceController extends BaseController {
206 @RequestParam(value = "deviceType", required = false) DeviceTypeEnum deviceType, 206 @RequestParam(value = "deviceType", required = false) DeviceTypeEnum deviceType,
207 @RequestParam(value = "organizationId", required = false) String organizationId, 207 @RequestParam(value = "organizationId", required = false) String organizationId,
208 @RequestParam(value = "alarmStatus", required = false) Integer alarmStatus, 208 @RequestParam(value = "alarmStatus", required = false) Integer alarmStatus,
209 - @RequestParam(value = "profileId", required = false) String profileId, 209 + @RequestParam(value = "deviceProfileId", required = false) String deviceProfileId,
210 @RequestParam(value = ORDER_FILED, required = false) String orderBy, 210 @RequestParam(value = ORDER_FILED, required = false) String orderBy,
211 @RequestParam(value = ORDER_TYPE, required = false) OrderTypeEnum orderType) 211 @RequestParam(value = ORDER_TYPE, required = false) OrderTypeEnum orderType)
212 throws ThingsboardException { 212 throws ThingsboardException {
@@ -216,7 +216,7 @@ public class YtDeviceController extends BaseController { @@ -216,7 +216,7 @@ public class YtDeviceController extends BaseController {
216 queryMap.put(ORDER_FILED, orderBy); 216 queryMap.put(ORDER_FILED, orderBy);
217 queryMap.put("name", name); 217 queryMap.put("name", name);
218 queryMap.put("alarmStatus", alarmStatus); 218 queryMap.put("alarmStatus", alarmStatus);
219 - queryMap.put("profileId", profileId); 219 + queryMap.put("deviceProfileId", deviceProfileId);
220 if (deviceState != null) { 220 if (deviceState != null) {
221 if (deviceState != DeviceState.INACTIVE) { 221 if (deviceState != DeviceState.INACTIVE) {
222 queryMap.put("deviceState", deviceState == DeviceState.ONLINE); 222 queryMap.put("deviceState", deviceState == DeviceState.ONLINE);
@@ -355,12 +355,14 @@ public class YtDeviceController extends BaseController { @@ -355,12 +355,14 @@ public class YtDeviceController extends BaseController {
355 @PreAuthorize("@check.checkPermissions({'TENANT_ADMIN','CUSTOMER_USER'},{})") 355 @PreAuthorize("@check.checkPermissions({'TENANT_ADMIN','CUSTOMER_USER'},{})")
356 @ApiOperation("主设备列表") 356 @ApiOperation("主设备列表")
357 public List<SelectItemDTO> getMasterDevices( 357 public List<SelectItemDTO> getMasterDevices(
358 - @ApiParam(value = "组织ID") @PathVariable("organizationId") String organizationId) 358 + @ApiParam(value = "组织ID") @PathVariable("organizationId") String organizationId,
  359 + @ApiParam(value = "设备配置ID") @RequestParam(value = "deviceProfileId", required = false)
  360 + String deviceProfileId)
359 throws ThingsboardException { 361 throws ThingsboardException {
360 return deviceService.findMasterDevices( 362 return deviceService.findMasterDevices(
361 getCurrentUser().getCurrentTenantId(), 363 getCurrentUser().getCurrentTenantId(),
362 getCurrentUser().isCustomerUser() ? getCurrentUser().getCustomerId().toString() : null, 364 getCurrentUser().isCustomerUser() ? getCurrentUser().getCustomerId().toString() : null,
363 - organizationId); 365 + organizationId,deviceProfileId);
364 } 366 }
365 367
366 @GetMapping("/list/slave/{organizationId}") 368 @GetMapping("/list/slave/{organizationId}")
@@ -484,16 +486,16 @@ public class YtDeviceController extends BaseController { @@ -484,16 +486,16 @@ public class YtDeviceController extends BaseController {
484 return result; 486 return result;
485 } 487 }
486 488
487 - @GetMapping({"/attributes/{profileId}/{id}"}) 489 + @GetMapping({"/attributes/{deviceProfileId}/{id}"})
488 @ApiOperation("获取设备的属性") 490 @ApiOperation("获取设备的属性")
489 public ResponseEntity<JsonNode> getDeviceAttributes( 491 public ResponseEntity<JsonNode> getDeviceAttributes(
490 - @PathVariable("profileId") String profileId, @PathVariable("id") String id) 492 + @PathVariable("deviceProfileId") String deviceProfileId, @PathVariable("id") String id)
491 throws ThingsboardException { 493 throws ThingsboardException {
492 String tenantId = getCurrentUser().getCurrentTenantId(); 494 String tenantId = getCurrentUser().getCurrentTenantId();
493 - DeviceProfileDTO dto = ytDeviceProfileService.findByTbDeviceProfileId(tenantId, profileId); 495 + DeviceProfileDTO dto = ytDeviceProfileService.findDeviceProfileById(tenantId, deviceProfileId);
494 if (null == dto) { 496 if (null == dto) {
495 throw new YtDataValidationException(ErrorMessage.INVALID_PARAMETER.getMessage()); 497 throw new YtDataValidationException(ErrorMessage.INVALID_PARAMETER.getMessage());
496 } 498 }
497 - return ResponseEntity.ok(deviceService.getDeviceAttributes(profileId,dto.getId(), id, tenantId)); 499 + return ResponseEntity.ok(deviceService.getDeviceAttributes(deviceProfileId, id, tenantId));
498 } 500 }
499 } 501 }
@@ -36,9 +36,10 @@ public class DeviceDTO extends TenantDTO { @@ -36,9 +36,10 @@ public class DeviceDTO extends TenantDTO {
36 @NotEmpty( 36 @NotEmpty(
37 message = "设备配置ID不能为空或者空字符串", 37 message = "设备配置ID不能为空或者空字符串",
38 groups = {AddGroup.class}) 38 groups = {AddGroup.class})
39 - @ApiModelProperty(value = "设备配置", required = true) 39 + @ApiModelProperty(value = "TB设备配置ID", required = true)
40 private String profileId; 40 private String profileId;
41 - 41 + @ApiModelProperty(value = "平台设备配置ID", required = true)
  42 + private String deviceProfileId;
42 @ApiModelProperty(value = "关联网关设备") 43 @ApiModelProperty(value = "关联网关设备")
43 private String gatewayId; 44 private String gatewayId;
44 private String gatewayName; 45 private String gatewayName;
@@ -5,32 +5,43 @@ import io.swagger.annotations.ApiModelProperty; @@ -5,32 +5,43 @@ import io.swagger.annotations.ApiModelProperty;
5 import lombok.Data; 5 import lombok.Data;
6 import lombok.EqualsAndHashCode; 6 import lombok.EqualsAndHashCode;
7 import org.thingsboard.server.common.data.yunteng.enums.ActionTypeEnum; 7 import org.thingsboard.server.common.data.yunteng.enums.ActionTypeEnum;
  8 +import org.thingsboard.server.common.data.yunteng.enums.CallTypeEnum;
8 import org.thingsboard.server.common.data.yunteng.enums.ScopeEnum; 9 import org.thingsboard.server.common.data.yunteng.enums.ScopeEnum;
9 10
10 import java.util.List; 11 import java.util.List;
11 12
12 /** 13 /**
13 - * @Description 场景联动执行动作数据传输表  
14 - * @Author cxy  
15 - * @Date 2021/11/24 17:32 14 + * @Description 场景联动执行动作数据传输表 @Author cxy @Date 2021/11/24 17:32
16 */ 15 */
17 @Data 16 @Data
18 @EqualsAndHashCode(callSuper = true) 17 @EqualsAndHashCode(callSuper = true)
19 -public class DoActionDTO extends TenantDTO{ 18 +public class DoActionDTO extends TenantDTO {
20 19
21 - @ApiModelProperty(value = "所属设备id")  
22 - private List<String> deviceId;  
23 - private ScopeEnum entityType; 20 + @ApiModelProperty(value = "所属设备id")
  21 + private List<String> deviceId;
24 22
  23 + private ScopeEnum entityType;
25 24
26 - @ApiModelProperty(value = "场景联动内容")  
27 - private JsonNode doContext; 25 + @ApiModelProperty(value = "场景联动内容")
  26 + private JsonNode doContext;
  27 +
  28 + @ApiModelProperty(value = "设备配置ID")
  29 + private String deviceProfileId;
  30 +
  31 + @ApiModelProperty(value = "调用类型:sync同步/async异步")
  32 + private CallTypeEnum callType;
  33 +
  34 + @ApiModelProperty(value = "命令类型:0自定义 1服务")
  35 + private Integer commandType;
  36 +
  37 + @ApiModelProperty(value = "服务模型ID")
  38 + private String thingsModelId;
28 39
29 @ApiModelProperty(value = "输出目标:设备,告警,其他") 40 @ApiModelProperty(value = "输出目标:设备,告警,其他")
30 private ActionTypeEnum outTarget; 41 private ActionTypeEnum outTarget;
31 42
32 - @ApiModelProperty(value = "场景联动id")  
33 - private String sceneLinkageId; 43 + @ApiModelProperty(value = "场景联动id")
  44 + private String sceneLinkageId;
34 45
35 @ApiModelProperty(value = "输出目标为告警才进行配置") 46 @ApiModelProperty(value = "输出目标为告警才进行配置")
36 private String alarmProfileId; 47 private String alarmProfileId;
dao/src/main/java/org/thingsboard/server/dao/yunteng/entities/TkDeviceEntity.java renamed from dao/src/main/java/org/thingsboard/server/dao/yunteng/entities/TkDevice.java
@@ -13,12 +13,13 @@ import org.thingsboard.server.common.data.yunteng.enums.DeviceTypeEnum; @@ -13,12 +13,13 @@ import org.thingsboard.server.common.data.yunteng.enums.DeviceTypeEnum;
13 @Data 13 @Data
14 @EqualsAndHashCode(callSuper = true) 14 @EqualsAndHashCode(callSuper = true)
15 @TableName(value = ModelConstants.Table.TK_DEVICE_TABLE_NAME, autoResultMap = true) 15 @TableName(value = ModelConstants.Table.TK_DEVICE_TABLE_NAME, autoResultMap = true)
16 -public class TkDevice extends TenantBaseEntity { 16 +public class TkDeviceEntity extends TenantBaseEntity {
17 private String name; 17 private String name;
18 private String alias; 18 private String alias;
19 @TableField(typeHandler = JacksonTypeHandler.class) 19 @TableField(typeHandler = JacksonTypeHandler.class)
20 private JsonNode deviceInfo; 20 private JsonNode deviceInfo;
21 private String profileId; 21 private String profileId;
  22 + private String deviceProfileId;
22 private String tbDeviceId; 23 private String tbDeviceId;
23 private String gatewayId; 24 private String gatewayId;
24 private String brand; 25 private String brand;
@@ -9,9 +9,9 @@ import lombok.EqualsAndHashCode; @@ -9,9 +9,9 @@ import lombok.EqualsAndHashCode;
9 import org.apache.ibatis.type.EnumTypeHandler; 9 import org.apache.ibatis.type.EnumTypeHandler;
10 import org.thingsboard.server.common.data.yunteng.constant.ModelConstants; 10 import org.thingsboard.server.common.data.yunteng.constant.ModelConstants;
11 import org.thingsboard.server.common.data.yunteng.enums.ActionTypeEnum; 11 import org.thingsboard.server.common.data.yunteng.enums.ActionTypeEnum;
  12 +import org.thingsboard.server.common.data.yunteng.enums.CallTypeEnum;
12 import org.thingsboard.server.common.data.yunteng.enums.ScopeEnum; 13 import org.thingsboard.server.common.data.yunteng.enums.ScopeEnum;
13 import org.thingsboard.server.dao.yunteng.mapper.ListStringTypeHandler; 14 import org.thingsboard.server.dao.yunteng.mapper.ListStringTypeHandler;
14 -  
15 import java.util.List; 15 import java.util.List;
16 16
17 /** 17 /**
@@ -22,26 +22,26 @@ import java.util.List; @@ -22,26 +22,26 @@ import java.util.List;
22 @EqualsAndHashCode(callSuper = true) 22 @EqualsAndHashCode(callSuper = true)
23 public class TkDoActionEntity extends TenantBaseEntity { 23 public class TkDoActionEntity extends TenantBaseEntity {
24 24
25 - private static final long serialVersionUID = -5459834451418047957L;  
26 - 25 + private static final long serialVersionUID = -5459834451418047957L;
27 26
28 - @TableField(typeHandler = ListStringTypeHandler.class)  
29 - private List<String> deviceId; 27 + @TableField(typeHandler = ListStringTypeHandler.class)
  28 + private List<String> deviceId;
30 29
31 - @TableField(typeHandler = EnumTypeHandler.class)  
32 - private ScopeEnum entityType;  
33 - @TableField(typeHandler = EnumTypeHandler.class)  
34 - private ActionTypeEnum outTarget;  
35 - /**  
36 - * 场景联动内容  
37 - */  
38 - @TableField(typeHandler = JacksonTypeHandler.class)  
39 - private JsonNode doContext; 30 + @TableField(typeHandler = EnumTypeHandler.class)
  31 + private ScopeEnum entityType;
40 32
41 - /**  
42 - * 场景联动id  
43 - */  
44 - private String sceneLinkageId; 33 + @TableField(typeHandler = EnumTypeHandler.class)
  34 + private ActionTypeEnum outTarget;
45 35
46 - private String alarmProfileId; 36 + @TableField(typeHandler = EnumTypeHandler.class)
  37 + private CallTypeEnum callType;
  38 + private String deviceProfileId;
  39 + private Integer commandType;
  40 + private String thingsModelId;
  41 + /** 场景联动内容 */
  42 + @TableField(typeHandler = JacksonTypeHandler.class)
  43 + private JsonNode doContext;
  44 + /** 场景联动id */
  45 + private String sceneLinkageId;
  46 + private String alarmProfileId;
47 } 47 }
@@ -166,25 +166,29 @@ public class ThingsModelServiceImpl @@ -166,25 +166,29 @@ public class ThingsModelServiceImpl
166 } else { 166 } else {
167 if (typeEnum.equals(FunctionTypeEnum.services)) { 167 if (typeEnum.equals(FunctionTypeEnum.services)) {
168 List<ServiceModelDTO> serviceList = new ArrayList<>(); 168 List<ServiceModelDTO> serviceList = new ArrayList<>();
169 - for (ThingsModelDTO thingsModelDTO : thingsModelDTOS) {  
170 - ServiceModelDTO serviceDTO = new ServiceModelDTO();  
171 - BeanUtils.copyProperties(thingsModelDTO, serviceDTO);  
172 - JsonNode functionJson = thingsModelDTO.getFunctionJson();  
173 - if (null != functionJson) {  
174 - serviceDTO.setInputData(functionJson.get("inputData"));  
175 - serviceDTO.setOutputData(functionJson.get("outputData")); 169 + if (!thingsModelDTOS.isEmpty()) {
  170 + for (ThingsModelDTO thingsModelDTO : thingsModelDTOS) {
  171 + ServiceModelDTO serviceDTO = new ServiceModelDTO();
  172 + BeanUtils.copyProperties(thingsModelDTO, serviceDTO);
  173 + JsonNode functionJson = thingsModelDTO.getFunctionJson();
  174 + if (null != functionJson) {
  175 + serviceDTO.setInputData(functionJson.get("inputData"));
  176 + serviceDTO.setOutputData(functionJson.get("outputData"));
  177 + }
  178 + serviceList.add(serviceDTO);
176 } 179 }
177 - serviceList.add(serviceDTO);  
178 } 180 }
179 jsonNode = JacksonUtil.convertValue(serviceList, JsonNode.class); 181 jsonNode = JacksonUtil.convertValue(serviceList, JsonNode.class);
180 } else { 182 } else {
181 List<EventModelDTO> eventList = new ArrayList<>(); 183 List<EventModelDTO> eventList = new ArrayList<>();
182 - for (ThingsModelDTO thingsModelDTO : thingsModelDTOS) {  
183 - EventModelDTO eventDTO = new EventModelDTO();  
184 - BeanUtils.copyProperties(thingsModelDTO, eventDTO);  
185 - JsonNode functionJson = thingsModelDTO.getFunctionJson();  
186 - if (null != functionJson) {  
187 - eventDTO.setOutputData(functionJson.get("outputData")); 184 + if (!thingsModelDTOS.isEmpty()) {
  185 + for (ThingsModelDTO thingsModelDTO : thingsModelDTOS) {
  186 + EventModelDTO eventDTO = new EventModelDTO();
  187 + BeanUtils.copyProperties(thingsModelDTO, eventDTO);
  188 + JsonNode functionJson = thingsModelDTO.getFunctionJson();
  189 + if (null != functionJson) {
  190 + eventDTO.setOutputData(functionJson.get("outputData"));
  191 + }
188 } 192 }
189 } 193 }
190 jsonNode = JacksonUtil.convertValue(eventList, JsonNode.class); 194 jsonNode = JacksonUtil.convertValue(eventList, JsonNode.class);
@@ -140,7 +140,7 @@ public class TkDeviceProfileServiceImpl @@ -140,7 +140,7 @@ public class TkDeviceProfileServiceImpl
140 // check if ids bind to device 140 // check if ids bind to device
141 int count = 141 int count =
142 deviceMapper.selectCount( 142 deviceMapper.selectCount(
143 - new QueryWrapper<TkDevice>().lambda().in(TkDevice::getProfileId, ids)); 143 + new QueryWrapper<TkDeviceEntity>().lambda().in(TkDeviceEntity::getProfileId, ids));
144 if (count > 0) { 144 if (count > 0) {
145 throw new YtDataValidationException("有设备使用待删除配置,请先删除设备或者修改设备配置"); 145 throw new YtDataValidationException("有设备使用待删除配置,请先删除设备或者修改设备配置");
146 } 146 }
@@ -39,7 +39,7 @@ import java.util.stream.Collectors; @@ -39,7 +39,7 @@ import java.util.stream.Collectors;
39 @Service 39 @Service
40 @RequiredArgsConstructor 40 @RequiredArgsConstructor
41 @Slf4j 41 @Slf4j
42 -public class TkDeviceServiceImpl extends AbstractBaseService<DeviceMapper, TkDevice> 42 +public class TkDeviceServiceImpl extends AbstractBaseService<DeviceMapper, TkDeviceEntity>
43 implements TkDeviceService { 43 implements TkDeviceService {
44 44
45 private final DeviceProfileDao deviceProfileDao; 45 private final DeviceProfileDao deviceProfileDao;
@@ -66,7 +66,7 @@ public class TkDeviceServiceImpl extends AbstractBaseService<DeviceMapper, TkDev @@ -66,7 +66,7 @@ public class TkDeviceServiceImpl extends AbstractBaseService<DeviceMapper, TkDev
66 66
67 validateUpdate(deviceDTO); 67 validateUpdate(deviceDTO);
68 68
69 - TkDevice device = new TkDevice(); 69 + TkDeviceEntity device = new TkDeviceEntity();
70 deviceDTO.copyToEntity( 70 deviceDTO.copyToEntity(
71 device, 71 device,
72 ModelConstants.TablePropertyMapping.ACTIVE_TIME, 72 ModelConstants.TablePropertyMapping.ACTIVE_TIME,
@@ -109,7 +109,7 @@ public class TkDeviceServiceImpl extends AbstractBaseService<DeviceMapper, TkDev @@ -109,7 +109,7 @@ public class TkDeviceServiceImpl extends AbstractBaseService<DeviceMapper, TkDev
109 deviceDTO.setTenantId(currentTenantId); 109 deviceDTO.setTenantId(currentTenantId);
110 } else { 110 } else {
111 deviceTenantId = deviceDTO.getTenantId(); 111 deviceTenantId = deviceDTO.getTenantId();
112 - TkDevice device = baseMapper.selectById(deviceDTO.getId()); 112 + TkDeviceEntity device = baseMapper.selectById(deviceDTO.getId());
113 if (device == null) { 113 if (device == null) {
114 throw new YtDataValidationException("设备不存在!"); 114 throw new YtDataValidationException("设备不存在!");
115 } 115 }
@@ -126,7 +126,8 @@ public class TkDeviceServiceImpl extends AbstractBaseService<DeviceMapper, TkDev @@ -126,7 +126,8 @@ public class TkDeviceServiceImpl extends AbstractBaseService<DeviceMapper, TkDev
126 TenantId id = TenantId.fromUUID(UUID.fromString(deviceTenantId)); 126 TenantId id = TenantId.fromUUID(UUID.fromString(deviceTenantId));
127 DeviceProfile deviceProfile = 127 DeviceProfile deviceProfile =
128 deviceProfileDao.findById(id, UUID.fromString(deviceDTO.getProfileId())); 128 deviceProfileDao.findById(id, UUID.fromString(deviceDTO.getProfileId()));
129 - TkOrganizationEntity organization = ytOrganizationMapper.selectById(deviceDTO.getOrganizationId()); 129 + TkOrganizationEntity organization =
  130 + ytOrganizationMapper.selectById(deviceDTO.getOrganizationId());
130 if (null == deviceProfile || null == organization) { 131 if (null == deviceProfile || null == organization) {
131 throw new YtDataValidationException(ErrorMessage.INVALID_PARAMETER.getMessage()); 132 throw new YtDataValidationException(ErrorMessage.INVALID_PARAMETER.getMessage());
132 } else if (!organization.getTenantId().equals(deviceTenantId)) { 133 } else if (!organization.getTenantId().equals(deviceTenantId)) {
@@ -209,7 +210,7 @@ public class TkDeviceServiceImpl extends AbstractBaseService<DeviceMapper, TkDev @@ -209,7 +210,7 @@ public class TkDeviceServiceImpl extends AbstractBaseService<DeviceMapper, TkDev
209 210
210 private DeviceDTO insert(DeviceDTO deviceDTO) { 211 private DeviceDTO insert(DeviceDTO deviceDTO) {
211 212
212 - TkDevice device = new TkDevice(); 213 + TkDeviceEntity device = new TkDeviceEntity();
213 deviceDTO.copyToEntity( 214 deviceDTO.copyToEntity(
214 device, 215 device,
215 ModelConstants.TablePropertyMapping.ACTIVE_TIME, 216 ModelConstants.TablePropertyMapping.ACTIVE_TIME,
@@ -227,15 +228,15 @@ public class TkDeviceServiceImpl extends AbstractBaseService<DeviceMapper, TkDev @@ -227,15 +228,15 @@ public class TkDeviceServiceImpl extends AbstractBaseService<DeviceMapper, TkDev
227 228
228 @Override 229 @Override
229 public List<String> findTbDeviceId(String tenantId, Set<String> ids) { 230 public List<String> findTbDeviceId(String tenantId, Set<String> ids) {
230 - LambdaQueryWrapper<TkDevice> queryWrapper =  
231 - new QueryWrapper<TkDevice>() 231 + LambdaQueryWrapper<TkDeviceEntity> queryWrapper =
  232 + new QueryWrapper<TkDeviceEntity>()
232 .lambda() 233 .lambda()
233 - .eq(TkDevice::getTenantId, tenantId)  
234 - .in(TkDevice::getId, ids); 234 + .eq(TkDeviceEntity::getTenantId, tenantId)
  235 + .in(TkDeviceEntity::getId, ids);
235 236
236 List<String> tbDeviceIds = 237 List<String> tbDeviceIds =
237 baseMapper.selectList(queryWrapper).stream() 238 baseMapper.selectList(queryWrapper).stream()
238 - .map(TkDevice::getTbDeviceId) 239 + .map(TkDeviceEntity::getTbDeviceId)
239 .collect(Collectors.toList()); 240 .collect(Collectors.toList());
240 for (String tbDeviceId : tbDeviceIds) { 241 for (String tbDeviceId : tbDeviceIds) {
241 sceneNotUsed(tenantId, tbDeviceId, null); 242 sceneNotUsed(tenantId, tbDeviceId, null);
@@ -252,10 +253,10 @@ public class TkDeviceServiceImpl extends AbstractBaseService<DeviceMapper, TkDev @@ -252,10 +253,10 @@ public class TkDeviceServiceImpl extends AbstractBaseService<DeviceMapper, TkDev
252 } 253 }
253 return ReflectUtils.sourceToTarget( 254 return ReflectUtils.sourceToTarget(
254 baseMapper.selectList( 255 baseMapper.selectList(
255 - new LambdaQueryWrapper<TkDevice>()  
256 - .eq(deviceType != null, TkDevice::getDeviceType, deviceType)  
257 - .eq(deviceLabel != null, TkDevice::getLabel, deviceLabel)  
258 - .in(TkDevice::getOrganizationId, orgIds)), 256 + new LambdaQueryWrapper<TkDeviceEntity>()
  257 + .eq(deviceType != null, TkDeviceEntity::getDeviceType, deviceType)
  258 + .eq(deviceLabel != null, TkDeviceEntity::getLabel, deviceLabel)
  259 + .in(TkDeviceEntity::getOrganizationId, orgIds)),
259 DeviceDTO.class); 260 DeviceDTO.class);
260 } 261 }
261 262
@@ -279,12 +280,12 @@ public class TkDeviceServiceImpl extends AbstractBaseService<DeviceMapper, TkDev @@ -279,12 +280,12 @@ public class TkDeviceServiceImpl extends AbstractBaseService<DeviceMapper, TkDev
279 if (StringUtils.isEmpty(deviceId) || StringUtils.isEmpty(tenantId)) { 280 if (StringUtils.isEmpty(deviceId) || StringUtils.isEmpty(tenantId)) {
280 throw new YtDataValidationException(ErrorMessage.INVALID_PARAMETER.getMessage()); 281 throw new YtDataValidationException(ErrorMessage.INVALID_PARAMETER.getMessage());
281 } 282 }
282 - TkDevice device = 283 + TkDeviceEntity device =
283 baseMapper.selectOne( 284 baseMapper.selectOne(
284 - new LambdaQueryWrapper<TkDevice>()  
285 - .eq(TkDevice::getTenantId, tenantId)  
286 - .eq(isTbDeviceId, TkDevice::getTbDeviceId, deviceId)  
287 - .eq(!isTbDeviceId, TkDevice::getId, deviceId)); 285 + new LambdaQueryWrapper<TkDeviceEntity>()
  286 + .eq(TkDeviceEntity::getTenantId, tenantId)
  287 + .eq(isTbDeviceId, TkDeviceEntity::getTbDeviceId, deviceId)
  288 + .eq(!isTbDeviceId, TkDeviceEntity::getId, deviceId));
288 DeviceDTO deviceDTO = null != device ? device.getDTO(DeviceDTO.class) : null; 289 DeviceDTO deviceDTO = null != device ? device.getDTO(DeviceDTO.class) : null;
289 if (null == deviceDTO) { 290 if (null == deviceDTO) {
290 throw new YtDataValidationException(ErrorMessage.DEVICE_NOT_EXISTENCE_IN_TENANT.getMessage()); 291 throw new YtDataValidationException(ErrorMessage.DEVICE_NOT_EXISTENCE_IN_TENANT.getMessage());
@@ -295,11 +296,11 @@ public class TkDeviceServiceImpl extends AbstractBaseService<DeviceMapper, TkDev @@ -295,11 +296,11 @@ public class TkDeviceServiceImpl extends AbstractBaseService<DeviceMapper, TkDev
295 @Override 296 @Override
296 @Transactional 297 @Transactional
297 public void deleteDevices(String tenantId, Set<String> ids) { 298 public void deleteDevices(String tenantId, Set<String> ids) {
298 - LambdaQueryWrapper<TkDevice> queryWrapper =  
299 - new QueryWrapper<TkDevice>() 299 + LambdaQueryWrapper<TkDeviceEntity> queryWrapper =
  300 + new QueryWrapper<TkDeviceEntity>()
300 .lambda() 301 .lambda()
301 - .eq(TkDevice::getTenantId, tenantId)  
302 - .in(TkDevice::getId, ids); 302 + .eq(TkDeviceEntity::getTenantId, tenantId)
  303 + .in(TkDeviceEntity::getId, ids);
303 304
304 baseMapper.delete(queryWrapper); 305 baseMapper.delete(queryWrapper);
305 } 306 }
@@ -317,7 +318,8 @@ public class TkDeviceServiceImpl extends AbstractBaseService<DeviceMapper, TkDev @@ -317,7 +318,8 @@ public class TkDeviceServiceImpl extends AbstractBaseService<DeviceMapper, TkDev
317 List<String> queryOrganizationIds = organizationAllIds(tenantId, organizationId); 318 List<String> queryOrganizationIds = organizationAllIds(tenantId, organizationId);
318 queryMap.put("organizationIds", queryOrganizationIds); 319 queryMap.put("organizationIds", queryOrganizationIds);
319 } 320 }
320 - IPage<TkDevice> page = getPage(queryMap, FastIotConstants.DefaultOrder.CREATE_TIME, false); 321 + IPage<TkDeviceEntity> page =
  322 + getPage(queryMap, FastIotConstants.DefaultOrder.CREATE_TIME, false);
321 IPage<DeviceDTO> deviceIPage = baseMapper.getDevicePage(page, queryMap); 323 IPage<DeviceDTO> deviceIPage = baseMapper.getDevicePage(page, queryMap);
322 List<DeviceDTO> records = deviceIPage.getRecords(); 324 List<DeviceDTO> records = deviceIPage.getRecords();
323 records.forEach( 325 records.forEach(
@@ -352,7 +354,7 @@ public class TkDeviceServiceImpl extends AbstractBaseService<DeviceMapper, TkDev @@ -352,7 +354,7 @@ public class TkDeviceServiceImpl extends AbstractBaseService<DeviceMapper, TkDev
352 354
353 @Override 355 @Override
354 public YtPageData<RelationDeviceDTO> pageRelation(Map<String, Object> queryMap) { 356 public YtPageData<RelationDeviceDTO> pageRelation(Map<String, Object> queryMap) {
355 - IPage<TkDevice> page = getPage(queryMap, "last_online_time", false); 357 + IPage<TkDeviceEntity> page = getPage(queryMap, "last_online_time", false);
356 IPage<RelationDeviceDTO> deviceIPage = baseMapper.getRelationDevicePage(page, queryMap); 358 IPage<RelationDeviceDTO> deviceIPage = baseMapper.getRelationDevicePage(page, queryMap);
357 List<RelationDeviceDTO> records = deviceIPage.getRecords(); 359 List<RelationDeviceDTO> records = deviceIPage.getRecords();
358 return new YtPageData<>(records, deviceIPage.getTotal()); 360 return new YtPageData<>(records, deviceIPage.getTotal());
@@ -360,13 +362,13 @@ public class TkDeviceServiceImpl extends AbstractBaseService<DeviceMapper, TkDev @@ -360,13 +362,13 @@ public class TkDeviceServiceImpl extends AbstractBaseService<DeviceMapper, TkDev
360 362
361 @Override 363 @Override
362 public boolean deviceNameUsed(String tenantId, String deviceName, String deviceId) { 364 public boolean deviceNameUsed(String tenantId, String deviceName, String deviceId) {
363 - List<TkDevice> deviceList = 365 + List<TkDeviceEntity> deviceList =
364 baseMapper.selectList( 366 baseMapper.selectList(
365 - new QueryWrapper<TkDevice>() 367 + new QueryWrapper<TkDeviceEntity>()
366 .lambda() 368 .lambda()
367 - .eq(true, TkDevice::getTenantId, tenantId)  
368 - .eq(TkDevice::getName, deviceName));  
369 - for (TkDevice dev : deviceList) { 369 + .eq(true, TkDeviceEntity::getTenantId, tenantId)
  370 + .eq(TkDeviceEntity::getName, deviceName));
  371 + for (TkDeviceEntity dev : deviceList) {
370 if (deviceName.equals(dev.getName()) 372 if (deviceName.equals(dev.getName())
371 && (StringUtils.isEmpty(deviceId) || !deviceId.equals(dev.getId()))) { 373 && (StringUtils.isEmpty(deviceId) || !deviceId.equals(dev.getId()))) {
372 return true; 374 return true;
@@ -399,7 +401,7 @@ public class TkDeviceServiceImpl extends AbstractBaseService<DeviceMapper, TkDev @@ -399,7 +401,7 @@ public class TkDeviceServiceImpl extends AbstractBaseService<DeviceMapper, TkDev
399 401
400 @Override 402 @Override
401 public String otherUsing(String deviceId, String tenantId) { 403 public String otherUsing(String deviceId, String tenantId) {
402 - TkDevice device = baseMapper.selectById(deviceId); 404 + TkDeviceEntity device = baseMapper.selectById(deviceId);
403 if (device == null) { 405 if (device == null) {
404 throw new YtDataValidationException(ErrorMessage.DEVICE_NOT_EXTIED.getMessage()); 406 throw new YtDataValidationException(ErrorMessage.DEVICE_NOT_EXTIED.getMessage());
405 } 407 }
@@ -411,7 +413,9 @@ public class TkDeviceServiceImpl extends AbstractBaseService<DeviceMapper, TkDev @@ -411,7 +413,9 @@ public class TkDeviceServiceImpl extends AbstractBaseService<DeviceMapper, TkDev
411 @Nullable 413 @Nullable
412 private String usedBySceneLinkage(String tenantId, String tbDeviceId) { 414 private String usedBySceneLinkage(String tenantId, String tbDeviceId) {
413 LambdaQueryWrapper<TkSceneLinkageEntity> sceneFilter = 415 LambdaQueryWrapper<TkSceneLinkageEntity> sceneFilter =
414 - new QueryWrapper<TkSceneLinkageEntity>().lambda().eq(TkSceneLinkageEntity::getTenantId, tenantId) 416 + new QueryWrapper<TkSceneLinkageEntity>()
  417 + .lambda()
  418 + .eq(TkSceneLinkageEntity::getTenantId, tenantId)
415 // .eq(SceneLinkage::getStatus, 1) 419 // .eq(SceneLinkage::getStatus, 1)
416 ; 420 ;
417 Optional<List<TkSceneLinkageEntity>> scenes = 421 Optional<List<TkSceneLinkageEntity>> scenes =
@@ -460,9 +464,9 @@ public class TkDeviceServiceImpl extends AbstractBaseService<DeviceMapper, TkDev @@ -460,9 +464,9 @@ public class TkDeviceServiceImpl extends AbstractBaseService<DeviceMapper, TkDev
460 464
461 @Override 465 @Override
462 public List<SelectItemDTO> findMasterDevices( 466 public List<SelectItemDTO> findMasterDevices(
463 - String tenantId, String customerId, String organizationId) { 467 + String tenantId, String customerId, String organizationId, String deviceProfileId) {
464 List<String> orgIds = organizationAllIds(tenantId, organizationId); 468 List<String> orgIds = organizationAllIds(tenantId, organizationId);
465 - return baseMapper.masterDevices(customerId, tenantId, orgIds); 469 + return baseMapper.masterDevices(customerId, tenantId, orgIds, deviceProfileId);
466 } 470 }
467 471
468 @Override 472 @Override
@@ -487,10 +491,10 @@ public class TkDeviceServiceImpl extends AbstractBaseService<DeviceMapper, TkDev @@ -487,10 +491,10 @@ public class TkDeviceServiceImpl extends AbstractBaseService<DeviceMapper, TkDev
487 @Override 491 @Override
488 public boolean saveSlaveDevice( 492 public boolean saveSlaveDevice(
489 String slaveId, String slaveName, String gatewayId, Long createTime) { 493 String slaveId, String slaveName, String gatewayId, Long createTime) {
490 - LambdaQueryWrapper<TkDevice> deviceFilter =  
491 - new QueryWrapper<TkDevice>().lambda().eq(TkDevice::getTbDeviceId, gatewayId);  
492 - TkDevice gateway = baseMapper.selectOne(deviceFilter);  
493 - TkDevice slaveDevice = new TkDevice(); 494 + LambdaQueryWrapper<TkDeviceEntity> deviceFilter =
  495 + new QueryWrapper<TkDeviceEntity>().lambda().eq(TkDeviceEntity::getTbDeviceId, gatewayId);
  496 + TkDeviceEntity gateway = baseMapper.selectOne(deviceFilter);
  497 + TkDeviceEntity slaveDevice = new TkDeviceEntity();
494 slaveDevice.setName(slaveName); 498 slaveDevice.setName(slaveName);
495 slaveDevice.setTbDeviceId(slaveId); 499 slaveDevice.setTbDeviceId(slaveId);
496 slaveDevice.setSn(generateSn()); 500 slaveDevice.setSn(generateSn());
@@ -517,11 +521,11 @@ public class TkDeviceServiceImpl extends AbstractBaseService<DeviceMapper, TkDev @@ -517,11 +521,11 @@ public class TkDeviceServiceImpl extends AbstractBaseService<DeviceMapper, TkDev
517 521
518 @Override 522 @Override
519 public DeviceDTO getSubsetDeviceByTbDeviceId(String tenantId, String tbDeviceId) { 523 public DeviceDTO getSubsetDeviceByTbDeviceId(String tenantId, String tbDeviceId) {
520 - TkDevice device = 524 + TkDeviceEntity device =
521 baseMapper.selectOne( 525 baseMapper.selectOne(
522 - new LambdaQueryWrapper<TkDevice>()  
523 - .eq(TkDevice::getTbDeviceId, tbDeviceId)  
524 - .eq(TkDevice::getTenantId, tenantId)); 526 + new LambdaQueryWrapper<TkDeviceEntity>()
  527 + .eq(TkDeviceEntity::getTbDeviceId, tbDeviceId)
  528 + .eq(TkDeviceEntity::getTenantId, tenantId));
525 return Optional.ofNullable(device) 529 return Optional.ofNullable(device)
526 .map(obj -> obj.getDTO(DeviceDTO.class)) 530 .map(obj -> obj.getDTO(DeviceDTO.class))
527 .orElseThrow( 531 .orElseThrow(
@@ -531,30 +535,26 @@ public class TkDeviceServiceImpl extends AbstractBaseService<DeviceMapper, TkDev @@ -531,30 +535,26 @@ public class TkDeviceServiceImpl extends AbstractBaseService<DeviceMapper, TkDev
531 } 535 }
532 536
533 @Override 537 @Override
534 - public JsonNode getDeviceAttributes(String tbProfileId,String profileId, String id, String tenantId) { 538 + public JsonNode getDeviceAttributes(String deviceProfileId, String id, String tenantId) {
535 return getDevice(tenantId, id) 539 return getDevice(tenantId, id)
536 .map( 540 .map(
537 obj -> { 541 obj -> {
538 - if (obj.getProfileId().equals(tbProfileId)) {  
539 - JsonNode jsonNode = JacksonUtil.newObjectNode();  
540 - List<ThingsModelDTO> thingsModel =  
541 - thingsModelService.selectByDeviceProfileId(  
542 - FunctionTypeEnum.properties, tenantId, profileId);  
543 - if (null !=thingsModel && !thingsModel.isEmpty()) {  
544 - List<Map<String, Object>> attributes = new ArrayList<>();  
545 - for (ThingsModelDTO dto : thingsModel) {  
546 - Map<String, Object> attribute = new HashMap<>();  
547 - attribute.put("name", dto.getFunctionName());  
548 - attribute.put("identifier", dto.getIdentifier());  
549 - attribute.put("detail", dto.getFunctionJson());  
550 - attributes.add(attribute);  
551 - }  
552 - jsonNode = JacksonUtil.convertValue(attributes, JsonNode.class); 542 + JsonNode jsonNode = JacksonUtil.newObjectNode();
  543 + List<ThingsModelDTO> thingsModel =
  544 + thingsModelService.selectByDeviceProfileId(
  545 + FunctionTypeEnum.properties, tenantId, deviceProfileId);
  546 + if (null != thingsModel && !thingsModel.isEmpty()) {
  547 + List<Map<String, Object>> attributes = new ArrayList<>();
  548 + for (ThingsModelDTO dto : thingsModel) {
  549 + Map<String, Object> attribute = new HashMap<>();
  550 + attribute.put("name", dto.getFunctionName());
  551 + attribute.put("identifier", dto.getIdentifier());
  552 + attribute.put("detail", dto.getFunctionJson());
  553 + attributes.add(attribute);
553 } 554 }
554 - return jsonNode;  
555 - } else {  
556 - throw new YtDataValidationException(ErrorMessage.INVALID_PARAMETER.getMessage()); 555 + jsonNode = JacksonUtil.convertValue(attributes, JsonNode.class);
557 } 556 }
  557 + return jsonNode;
558 }) 558 })
559 .orElseThrow( 559 .orElseThrow(
560 () -> { 560 () -> {
@@ -48,10 +48,10 @@ public class TkNoticeServiceImpl implements TkNoticeService { @@ -48,10 +48,10 @@ public class TkNoticeServiceImpl implements TkNoticeService {
48 * 2、查找告警配置 ,与设备配置一一对应。 48 * 2、查找告警配置 ,与设备配置一一对应。
49 * 3、查找告警通知联系人 49 * 3、查找告警通知联系人
50 */ 50 */
51 - QueryWrapper<TkDevice> queryWrapper = new QueryWrapper<TkDevice>(); 51 + QueryWrapper<TkDeviceEntity> queryWrapper = new QueryWrapper<TkDeviceEntity>();
52 queryWrapper.lambda() 52 queryWrapper.lambda()
53 - .eq(TkDevice::getTbDeviceId, alarmInfo.getDeviceId());  
54 - TkDevice device = deviceMapper.selectOne(queryWrapper); 53 + .eq(TkDeviceEntity::getTbDeviceId, alarmInfo.getDeviceId());
  54 + TkDeviceEntity device = deviceMapper.selectOne(queryWrapper);
55 55
56 56
57 if (device == null) { 57 if (device == null) {
@@ -128,12 +128,12 @@ public class TkOrganizationServiceImpl extends AbstractBaseService<OrganizationM @@ -128,12 +128,12 @@ public class TkOrganizationServiceImpl extends AbstractBaseService<OrganizationM
128 128
129 // 查询是否有设备使用该组织 129 // 查询是否有设备使用该组织
130 for (String id : ids) { 130 for (String id : ids) {
131 - List<TkDevice> deviceList = 131 + List<TkDeviceEntity> deviceList =
132 deviceMapper.selectList( 132 deviceMapper.selectList(
133 - new QueryWrapper<TkDevice>() 133 + new QueryWrapper<TkDeviceEntity>()
134 .lambda() 134 .lambda()
135 - .eq(TkDevice::getTenantId, tenantId)  
136 - .eq(TkDevice::getOrganizationId, id)); 135 + .eq(TkDeviceEntity::getTenantId, tenantId)
  136 + .eq(TkDeviceEntity::getOrganizationId, id));
137 if (!deviceList.isEmpty()) { 137 if (!deviceList.isEmpty()) {
138 throw new YtDataValidationException("待删除数据存在关联设备,不能删除!"); 138 throw new YtDataValidationException("待删除数据存在关联设备,不能删除!");
139 } 139 }
@@ -403,9 +403,9 @@ public class TkSceneLinkageServiceImpl extends AbstractBaseService<SceneLinkageM @@ -403,9 +403,9 @@ public class TkSceneLinkageServiceImpl extends AbstractBaseService<SceneLinkageM
403 } 403 }
404 } 404 }
405 405
406 - List<TkDevice> orgDevices = 406 + List<TkDeviceEntity> orgDevices =
407 deviceMapper.selectList( 407 deviceMapper.selectList(
408 - new QueryWrapper<TkDevice>().lambda().in(TkDevice::getOrganizationId, orgIds)); 408 + new QueryWrapper<TkDeviceEntity>().lambda().in(TkDeviceEntity::getOrganizationId, orgIds));
409 List<DeviceDTO> result = 409 List<DeviceDTO> result =
410 orgDevices.stream() 410 orgDevices.stream()
411 .filter(t -> typeFilter.isEmpty() || typeFilter.contains(t.getDeviceType())) 411 .filter(t -> typeFilter.isEmpty() || typeFilter.contains(t.getDeviceType()))
@@ -8,124 +8,135 @@ import org.thingsboard.server.common.data.yunteng.dto.BaseHomePageTop; @@ -8,124 +8,135 @@ import org.thingsboard.server.common.data.yunteng.dto.BaseHomePageTop;
8 import org.thingsboard.server.common.data.yunteng.dto.DeviceDTO; 8 import org.thingsboard.server.common.data.yunteng.dto.DeviceDTO;
9 import org.thingsboard.server.common.data.yunteng.dto.RelationDeviceDTO; 9 import org.thingsboard.server.common.data.yunteng.dto.RelationDeviceDTO;
10 import org.thingsboard.server.common.data.yunteng.dto.SelectItemDTO; 10 import org.thingsboard.server.common.data.yunteng.dto.SelectItemDTO;
11 -import org.thingsboard.server.dao.yunteng.entities.TkDevice; 11 +import org.thingsboard.server.dao.yunteng.entities.TkDeviceEntity;
12 12
13 import java.util.List; 13 import java.util.List;
14 import java.util.Map; 14 import java.util.Map;
15 15
16 @Mapper 16 @Mapper
17 -public interface DeviceMapper extends BaseMapper<TkDevice> {  
18 -  
19 - IPage<DeviceDTO> getDevicePage(IPage<?> page, @Param("queryMap") Map<String, Object> queryMap);  
20 -  
21 - DeviceDTO selectDetail(@Param("tenantId") String tenantId, @Param("id") String id);  
22 -  
23 - /**  
24 - * 通过网关子设备的TB设备ID查询网关设备信息  
25 - *  
26 - * @param tbDeviceId 网关子设备的TB设备ID  
27 - * @return 网关设备信息  
28 - */  
29 - List<DeviceDTO> findGateWayDeviceByTbDeviceId(@Param("tbDeviceId") String tbDeviceId);  
30 -  
31 - /**  
32 - * 更新设备告警状态  
33 - *  
34 - * @param tbDeviceId TB设备主键  
35 - * @param created 告警状态:0正常,1告警  
36 - * @return true or false  
37 - */  
38 - boolean freshAlarmStatus(  
39 - @Param("tbDeviceId") String tbDeviceId, @Param("created") Integer created);  
40 -  
41 - /**  
42 - * 用于统计设备相关信息  
43 - *  
44 - * @param queryMap 查询条件  
45 - * @return 查询的设备信息  
46 - */  
47 - List<DeviceDTO> findDevices(@Param("queryMap") Map<String, Object> queryMap);  
48 -  
49 - /**  
50 - * 获取关联设备的子设备分页列表  
51 - *  
52 - * @param page 分页  
53 - * @param queryMap 查询条件  
54 - * @return 分页数据  
55 - */  
56 - IPage<RelationDeviceDTO> getRelationDevicePage(  
57 - IPage<?> page, @Param("queryMap") Map<String, Object> queryMap);  
58 -  
59 - /**  
60 - * 通过用户ID查询分配的所有设备ID  
61 - *  
62 - * @param customerId 用户ID  
63 - * @return 所有的设备ids  
64 - */  
65 - List<String> findDeviceIdsByCustomerId(@Param("customerId") String customerId);  
66 -  
67 - List<BaseHomePageTop> findDeviceMessageInfo(  
68 - @Param("todayTime") Long todayTime, @Param("customerId") String customerId);  
69 -  
70 - List<BaseHomePageTop> findDeviceAlarmInfoByCustomer(  
71 - @Param("todayTime") Long todayTime, @Param("customerId") String customerId);  
72 -  
73 - Integer findDeviceMessageInfoByTs(  
74 - @Param("customerId") String customerId,  
75 - @Param("startTime") Long startTime,  
76 - @Param("endTime") Long endTime);  
77 -  
78 - Integer findDeviceAlarmInfoByCreatedTime(  
79 - @Param("customerId") String customerId,  
80 - @Param("startTime") Long startTime,  
81 - @Param("endTime") Long endTime);  
82 -  
83 -  
84 - Integer countMsgs(@Param("queryMap") Map<String, Object> queryMap);  
85 -  
86 - Integer countDataPoints(@Param("queryMap") Map<String, Object> queryMap);  
87 -  
88 - /**  
89 - * 主设备列表  
90 - *  
91 - * @param customerId 客户ID  
92 - * @param tenantId 租户ID  
93 - * @param organizationIds 组织ID  
94 - * @return  
95 - */  
96 - List<SelectItemDTO> masterDevices(@Param("customerId") String customerId, @Param("tenantId") String tenantId, @Param("organizationIds") List<String> organizationIds);  
97 -  
98 - /**  
99 - * 从设备列表  
100 - *  
101 - * @param customerId 客户ID  
102 - * @param tenantId 租户ID  
103 - * @param organizationIds 组织ID  
104 - * @param masterId 主设备ID  
105 - * @return  
106 - */  
107 - List<SelectItemDTO> slaveDevices(@Param("customerId") String customerId, @Param("tenantId") String tenantId  
108 - , @Param("organizationIds") List<String> organizationIds, @Param("masterId") String masterId);  
109 -  
110 - /**  
111 - * TCP协议传输时,获取网关设备的从设备  
112 - * @param tenantId 租户ID  
113 - * @param masterId 网关设备的TB_ID  
114 - * @param code 网关子设备的标识符,例如:485协议的从设备地址码  
115 - * @return  
116 - */  
117 - DeviceDTO slaveDevice(@Param("tenantId") String tenantId, @Param("masterId") String masterId, @Param("code") String code);  
118 - /**  
119 - * 设备遥测数据指标名称  
120 - *  
121 - * @param tenantId 租户ID  
122 - * @param customerId 客户ID  
123 - * @param organizationIds 组织ID  
124 - * @param deviceIds 设备ID  
125 - * @return  
126 - */  
127 - List<String> findDeviceKeys(@Param("tenantId") String tenantId  
128 - , @Param("customerId") String customerId  
129 - , @Param("organizationIds") List<String> organizationIds  
130 - , @Param("deviceIds") List<String> deviceIds); 17 +public interface DeviceMapper extends BaseMapper<TkDeviceEntity> {
  18 +
  19 + IPage<DeviceDTO> getDevicePage(IPage<?> page, @Param("queryMap") Map<String, Object> queryMap);
  20 +
  21 + DeviceDTO selectDetail(@Param("tenantId") String tenantId, @Param("id") String id);
  22 +
  23 + /**
  24 + * 通过网关子设备的TB设备ID查询网关设备信息
  25 + *
  26 + * @param tbDeviceId 网关子设备的TB设备ID
  27 + * @return 网关设备信息
  28 + */
  29 + List<DeviceDTO> findGateWayDeviceByTbDeviceId(@Param("tbDeviceId") String tbDeviceId);
  30 +
  31 + /**
  32 + * 更新设备告警状态
  33 + *
  34 + * @param tbDeviceId TB设备主键
  35 + * @param created 告警状态:0正常,1告警
  36 + * @return true or false
  37 + */
  38 + boolean freshAlarmStatus(
  39 + @Param("tbDeviceId") String tbDeviceId, @Param("created") Integer created);
  40 +
  41 + /**
  42 + * 用于统计设备相关信息
  43 + *
  44 + * @param queryMap 查询条件
  45 + * @return 查询的设备信息
  46 + */
  47 + List<DeviceDTO> findDevices(@Param("queryMap") Map<String, Object> queryMap);
  48 +
  49 + /**
  50 + * 获取关联设备的子设备分页列表
  51 + *
  52 + * @param page 分页
  53 + * @param queryMap 查询条件
  54 + * @return 分页数据
  55 + */
  56 + IPage<RelationDeviceDTO> getRelationDevicePage(
  57 + IPage<?> page, @Param("queryMap") Map<String, Object> queryMap);
  58 +
  59 + /**
  60 + * 通过用户ID查询分配的所有设备ID
  61 + *
  62 + * @param customerId 用户ID
  63 + * @return 所有的设备ids
  64 + */
  65 + List<String> findDeviceIdsByCustomerId(@Param("customerId") String customerId);
  66 +
  67 + List<BaseHomePageTop> findDeviceMessageInfo(
  68 + @Param("todayTime") Long todayTime, @Param("customerId") String customerId);
  69 +
  70 + List<BaseHomePageTop> findDeviceAlarmInfoByCustomer(
  71 + @Param("todayTime") Long todayTime, @Param("customerId") String customerId);
  72 +
  73 + Integer findDeviceMessageInfoByTs(
  74 + @Param("customerId") String customerId,
  75 + @Param("startTime") Long startTime,
  76 + @Param("endTime") Long endTime);
  77 +
  78 + Integer findDeviceAlarmInfoByCreatedTime(
  79 + @Param("customerId") String customerId,
  80 + @Param("startTime") Long startTime,
  81 + @Param("endTime") Long endTime);
  82 +
  83 + Integer countMsgs(@Param("queryMap") Map<String, Object> queryMap);
  84 +
  85 + Integer countDataPoints(@Param("queryMap") Map<String, Object> queryMap);
  86 +
  87 + /**
  88 + * 主设备列表
  89 + *
  90 + * @param customerId 客户ID
  91 + * @param tenantId 租户ID
  92 + * @param organizationIds 组织ID
  93 + * @return
  94 + */
  95 + List<SelectItemDTO> masterDevices(
  96 + @Param("customerId") String customerId,
  97 + @Param("tenantId") String tenantId,
  98 + @Param("organizationIds") List<String> organizationIds,
  99 + @Param("deviceProfileId") String deviceProfileId);
  100 +
  101 + /**
  102 + * 从设备列表
  103 + *
  104 + * @param customerId 客户ID
  105 + * @param tenantId 租户ID
  106 + * @param organizationIds 组织ID
  107 + * @param masterId 主设备ID
  108 + * @return
  109 + */
  110 + List<SelectItemDTO> slaveDevices(
  111 + @Param("customerId") String customerId,
  112 + @Param("tenantId") String tenantId,
  113 + @Param("organizationIds") List<String> organizationIds,
  114 + @Param("masterId") String masterId);
  115 +
  116 + /**
  117 + * TCP协议传输时,获取网关设备的从设备
  118 + *
  119 + * @param tenantId 租户ID
  120 + * @param masterId 网关设备的TB_ID
  121 + * @param code 网关子设备的标识符,例如:485协议的从设备地址码
  122 + * @return
  123 + */
  124 + DeviceDTO slaveDevice(
  125 + @Param("tenantId") String tenantId,
  126 + @Param("masterId") String masterId,
  127 + @Param("code") String code);
  128 + /**
  129 + * 设备遥测数据指标名称
  130 + *
  131 + * @param tenantId 租户ID
  132 + * @param customerId 客户ID
  133 + * @param organizationIds 组织ID
  134 + * @param deviceIds 设备ID
  135 + * @return
  136 + */
  137 + List<String> findDeviceKeys(
  138 + @Param("tenantId") String tenantId,
  139 + @Param("customerId") String customerId,
  140 + @Param("organizationIds") List<String> organizationIds,
  141 + @Param("deviceIds") List<String> deviceIds);
131 } 142 }
@@ -7,176 +7,182 @@ import org.thingsboard.server.common.data.yunteng.dto.RelationDeviceDTO; @@ -7,176 +7,182 @@ import org.thingsboard.server.common.data.yunteng.dto.RelationDeviceDTO;
7 import org.thingsboard.server.common.data.yunteng.dto.SelectItemDTO; 7 import org.thingsboard.server.common.data.yunteng.dto.SelectItemDTO;
8 import org.thingsboard.server.common.data.yunteng.enums.DeviceTypeEnum; 8 import org.thingsboard.server.common.data.yunteng.enums.DeviceTypeEnum;
9 import org.thingsboard.server.common.data.yunteng.utils.tools.YtPageData; 9 import org.thingsboard.server.common.data.yunteng.utils.tools.YtPageData;
10 -import org.thingsboard.server.dao.yunteng.entities.TkDevice; 10 +import org.thingsboard.server.dao.yunteng.entities.TkDeviceEntity;
11 11
12 import java.util.List; 12 import java.util.List;
13 import java.util.Map; 13 import java.util.Map;
14 import java.util.Optional; 14 import java.util.Optional;
15 import java.util.Set; 15 import java.util.Set;
16 16
17 -public interface TkDeviceService extends BaseService<TkDevice> {  
18 - DeviceDTO insertOrUpdate(String tenantId, DeviceDTO deviceDTO);  
19 -  
20 - void deleteDevices(String tenantId, Set<String> ids);  
21 -  
22 - Optional<DeviceDTO> getDevice(String tenantId, String id);  
23 -  
24 - YtPageData<DeviceDTO> page(String tenantId, Map<String, Object> queryMap);  
25 -  
26 - YtPageData<RelationDeviceDTO> pageRelation(Map<String, Object> queryMap);  
27 -  
28 - /**  
29 - * 验证表单数据有效性  
30 - *  
31 - * @param ytDevice  
32 - */  
33 - void validateFormData(String currentTenantId, DeviceDTO ytDevice);  
34 -  
35 - /**  
36 - * 查询所有的设备信息  
37 - *  
38 - * @param deviceDTO 过滤参数  
39 - * @return List<DeviceDTO>  
40 - */  
41 - boolean deviceNameUsed(String tenantId, String deviceName,String deviceId);  
42 -  
43 - List<String> findTbDeviceId(String tenantId, Set<String> ids);  
44 -  
45 - /**  
46 - * 通过设备类型和组织ID查询所有的设备  
47 - *  
48 - * @param deviceType 设备类型  
49 - * @param organizationId 组织ID  
50 - * @return 设备列表  
51 - */  
52 - List<DeviceDTO> findDevicesByDeviceTypeAndOrganizationId(  
53 - DeviceTypeEnum deviceType, String tenantId, String organizationId,String deviceLabel);  
54 -  
55 - /**  
56 - * 通过设备ID和租户ID判断该设备是否存在  
57 - *  
58 - * @param tenantId 租户ID  
59 - * @param deviceId 设备ID  
60 - * @return 设备  
61 - */  
62 - DeviceDTO checkDeviceByTenantIdAndDeviceId(String tenantId, String deviceId);  
63 -  
64 - /**  
65 - * 通过网关子设备的TB设备ID查询网关设备信息  
66 - *  
67 - * @param tbDeviceId 网关子设备的TB设备ID  
68 - * @param tenantId 租户ID  
69 - * @return 网关设备信息  
70 - */  
71 - List<DeviceDTO> findGateWayDeviceByTbDeviceId(String tenantId, String tbDeviceId);  
72 -  
73 - /**  
74 - * 通过设备ID和租户ID检查设备是否存在  
75 - *  
76 - * @param tenantId 租户ID  
77 - * @param deviceId 设备ID  
78 - * @param isTbDeviceId 是TB设备ID  
79 - * @return 设备信息  
80 - */  
81 - DeviceDTO checkDeviceByTenantIdAndId(String tenantId, String deviceId, boolean isTbDeviceId);  
82 -  
83 - /**  
84 - * 更新设备告警状态  
85 - *  
86 - * @param tbDeviceId TB设备主键  
87 - * @param created 告警状态:0正常,1告警  
88 - * @return  
89 - */  
90 - boolean freshAlarmStatus(EntityId tbDeviceId, Integer created);  
91 -  
92 -  
93 - /**  
94 - * 自动生成设备SN  
95 - *  
96 - * @return  
97 - */  
98 - String generateSn();  
99 -  
100 - /**  
101 - *  
102 - * 设备是否被其它资源使用,例如:场景联动  
103 - * @param deviceId 平台设备ID  
104 - * @param tenantId 租户ID  
105 - * @return  
106 - */  
107 - String otherUsing(String deviceId,String tenantId);  
108 -  
109 - /**  
110 - * 主设备信息  
111 - * @param tenantId 租户ID  
112 - * @param organizationId 组织ID  
113 - * @return 设备列表  
114 - */  
115 - List<SelectItemDTO> findMasterDevices(String tenantId, String customerId, String organizationId);  
116 -  
117 - /**  
118 - * 从设备信息  
119 - * @param masterId 主设备ID  
120 - * @param tenantId 租户ID  
121 - * @param organizationId 组织ID  
122 - * @return 设备列表  
123 - */  
124 - List<SelectItemDTO> findSlaveDevices(String masterId,String tenantId,String customerId, String organizationId);  
125 -  
126 -  
127 - /**  
128 - * TCP协议传输时,获取网关设备的从设备  
129 - * @param tenantId 租户ID  
130 - * @param masterId 网关设备的TB_ID  
131 - * @param deviceCode 网关子设备的标识符,例如:485协议的从设备地址码  
132 - * @return  
133 - */  
134 - DeviceDTO findSlaveDevice(String tenantId,String masterId,String deviceCode);  
135 -  
136 - /**  
137 - * 设备遥测数据指标名称  
138 - * @param tenantId 租户ID  
139 - * @param customerId 客户ID  
140 - * @param organizationId 组织ID  
141 - * @param deviceIds 设备ID  
142 - * @return  
143 - */  
144 - List<String> findDeviceKeys(String tenantId,String customerId, String organizationId,List<String> deviceIds);  
145 -  
146 -  
147 - /**  
148 - * Thingsboard自动创建的传感器设备(网关子设备)同步到平台  
149 - * @param slaveId 网关子设备TB平台的ID  
150 - * @param slaveName 网关子设备TB平台的名称  
151 - * @param gatewayId 网关设备TB平台的ID  
152 - * @return  
153 - */  
154 - boolean saveSlaveDevice(String slaveId, String slaveName, String gatewayId, Long createTime);  
155 -  
156 - /**  
157 - * 通过设备ids查询拥有数值型属性的设备  
158 - * @param tenantId 租户ID  
159 - * @param ids  
160 - * @return 数值型设备列表  
161 - */  
162 - List<DeviceDTO> findNumberAttributeDevicesByIds(String tenantId,List<String> ids);  
163 -  
164 - /**  
165 - * 通过tb设备ID获取平台设备信息  
166 - * @param tenantId 租户ID  
167 - * @param tbDeviceId tb设备ID  
168 - * @return 设备信息  
169 - */  
170 - DeviceDTO getSubsetDeviceByTbDeviceId(String tenantId,String tbDeviceId);  
171 -  
172 - /**  
173 - * 通过设备ID 设备配置ID获取属性  
174 - * @param tbProfileId tb设备配置ID  
175 - * @param profileId 设备配置ID  
176 - * @param id 设备ID  
177 - * @param tenantId 租户ID  
178 - * @return 属性信息  
179 - */  
180 - JsonNode getDeviceAttributes(String tbProfileId,String profileId,String id,String tenantId);  
181 - 17 +public interface TkDeviceService extends BaseService<TkDeviceEntity> {
  18 + DeviceDTO insertOrUpdate(String tenantId, DeviceDTO deviceDTO);
  19 +
  20 + void deleteDevices(String tenantId, Set<String> ids);
  21 +
  22 + Optional<DeviceDTO> getDevice(String tenantId, String id);
  23 +
  24 + YtPageData<DeviceDTO> page(String tenantId, Map<String, Object> queryMap);
  25 +
  26 + YtPageData<RelationDeviceDTO> pageRelation(Map<String, Object> queryMap);
  27 +
  28 + /**
  29 + * 验证表单数据有效性
  30 + *
  31 + * @param ytDevice
  32 + */
  33 + void validateFormData(String currentTenantId, DeviceDTO ytDevice);
  34 +
  35 + /**
  36 + * 查询所有的设备信息
  37 + *
  38 + * @param deviceDTO 过滤参数
  39 + * @return List<DeviceDTO>
  40 + */
  41 + boolean deviceNameUsed(String tenantId, String deviceName, String deviceId);
  42 +
  43 + List<String> findTbDeviceId(String tenantId, Set<String> ids);
  44 +
  45 + /**
  46 + * 通过设备类型和组织ID查询所有的设备
  47 + *
  48 + * @param deviceType 设备类型
  49 + * @param organizationId 组织ID
  50 + * @return 设备列表
  51 + */
  52 + List<DeviceDTO> findDevicesByDeviceTypeAndOrganizationId(
  53 + DeviceTypeEnum deviceType, String tenantId, String organizationId, String deviceLabel);
  54 +
  55 + /**
  56 + * 通过设备ID和租户ID判断该设备是否存在
  57 + *
  58 + * @param tenantId 租户ID
  59 + * @param deviceId 设备ID
  60 + * @return 设备
  61 + */
  62 + DeviceDTO checkDeviceByTenantIdAndDeviceId(String tenantId, String deviceId);
  63 +
  64 + /**
  65 + * 通过网关子设备的TB设备ID查询网关设备信息
  66 + *
  67 + * @param tbDeviceId 网关子设备的TB设备ID
  68 + * @param tenantId 租户ID
  69 + * @return 网关设备信息
  70 + */
  71 + List<DeviceDTO> findGateWayDeviceByTbDeviceId(String tenantId, String tbDeviceId);
  72 +
  73 + /**
  74 + * 通过设备ID和租户ID检查设备是否存在
  75 + *
  76 + * @param tenantId 租户ID
  77 + * @param deviceId 设备ID
  78 + * @param isTbDeviceId 是TB设备ID
  79 + * @return 设备信息
  80 + */
  81 + DeviceDTO checkDeviceByTenantIdAndId(String tenantId, String deviceId, boolean isTbDeviceId);
  82 +
  83 + /**
  84 + * 更新设备告警状态
  85 + *
  86 + * @param tbDeviceId TB设备主键
  87 + * @param created 告警状态:0正常,1告警
  88 + * @return
  89 + */
  90 + boolean freshAlarmStatus(EntityId tbDeviceId, Integer created);
  91 +
  92 + /**
  93 + * 自动生成设备SN
  94 + *
  95 + * @return
  96 + */
  97 + String generateSn();
  98 +
  99 + /**
  100 + * 设备是否被其它资源使用,例如:场景联动
  101 + *
  102 + * @param deviceId 平台设备ID
  103 + * @param tenantId 租户ID
  104 + * @return
  105 + */
  106 + String otherUsing(String deviceId, String tenantId);
  107 +
  108 + /**
  109 + * 主设备信息
  110 + *
  111 + * @param tenantId 租户ID
  112 + * @param organizationId 组织ID
  113 + * @return 设备列表
  114 + */
  115 + List<SelectItemDTO> findMasterDevices(
  116 + String tenantId, String customerId, String organizationId, String deviceProfileId);
  117 +
  118 + /**
  119 + * 从设备信息
  120 + *
  121 + * @param masterId 主设备ID
  122 + * @param tenantId 租户ID
  123 + * @param organizationId 组织ID
  124 + * @return 设备列表
  125 + */
  126 + List<SelectItemDTO> findSlaveDevices(
  127 + String masterId, String tenantId, String customerId, String organizationId);
  128 +
  129 + /**
  130 + * TCP协议传输时,获取网关设备的从设备
  131 + *
  132 + * @param tenantId 租户ID
  133 + * @param masterId 网关设备的TB_ID
  134 + * @param deviceCode 网关子设备的标识符,例如:485协议的从设备地址码
  135 + * @return
  136 + */
  137 + DeviceDTO findSlaveDevice(String tenantId, String masterId, String deviceCode);
  138 +
  139 + /**
  140 + * 设备遥测数据指标名称
  141 + *
  142 + * @param tenantId 租户ID
  143 + * @param customerId 客户ID
  144 + * @param organizationId 组织ID
  145 + * @param deviceIds 设备ID
  146 + * @return
  147 + */
  148 + List<String> findDeviceKeys(
  149 + String tenantId, String customerId, String organizationId, List<String> deviceIds);
  150 +
  151 + /**
  152 + * Thingsboard自动创建的传感器设备(网关子设备)同步到平台
  153 + *
  154 + * @param slaveId 网关子设备TB平台的ID
  155 + * @param slaveName 网关子设备TB平台的名称
  156 + * @param gatewayId 网关设备TB平台的ID
  157 + * @return
  158 + */
  159 + boolean saveSlaveDevice(String slaveId, String slaveName, String gatewayId, Long createTime);
  160 +
  161 + /**
  162 + * 通过设备ids查询拥有数值型属性的设备
  163 + *
  164 + * @param tenantId 租户ID
  165 + * @param ids
  166 + * @return 数值型设备列表
  167 + */
  168 + List<DeviceDTO> findNumberAttributeDevicesByIds(String tenantId, List<String> ids);
  169 +
  170 + /**
  171 + * 通过tb设备ID获取平台设备信息
  172 + *
  173 + * @param tenantId 租户ID
  174 + * @param tbDeviceId tb设备ID
  175 + * @return 设备信息
  176 + */
  177 + DeviceDTO getSubsetDeviceByTbDeviceId(String tenantId, String tbDeviceId);
  178 +
  179 + /**
  180 + * 通过设备ID 设备配置ID获取属性
  181 + *
  182 + * @param deviceProfileId 平台设备配置ID
  183 + * @param id 设备ID
  184 + * @param tenantId 租户ID
  185 + * @return 属性信息de
  186 + */
  187 + JsonNode getDeviceAttributes(String deviceProfileId, String id, String tenantId);
182 } 188 }
@@ -14,6 +14,7 @@ @@ -14,6 +14,7 @@
14 <result property="deviceInfo" column="device_info" 14 <result property="deviceInfo" column="device_info"
15 typeHandler="com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler"/> 15 typeHandler="com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler"/>
16 <result property="profileId" column="profile_id"/> 16 <result property="profileId" column="profile_id"/>
  17 + <result property="deviceProfileId" column="device_profile_id"/>
17 <result property="activeTime" column="active_time"/> 18 <result property="activeTime" column="active_time"/>
18 <result property="deviceType" column="device_type" typeHandler="org.apache.ibatis.type.EnumTypeHandler"/> 19 <result property="deviceType" column="device_type" typeHandler="org.apache.ibatis.type.EnumTypeHandler"/>
19 <result property="brand" column="brand" /> 20 <result property="brand" column="brand" />
@@ -63,7 +64,7 @@ @@ -63,7 +64,7 @@
63 64
64 <sql id="basicColumns"> 65 <sql id="basicColumns">
65 ifd.id 66 ifd.id
66 - ,ifd.sn,ifd.brand,ifd.name,ifd.alias,ifd.device_info,ifd.profile_id,ifd.active_time,ifd.tenant_id,ifd.description 67 + ,ifd.sn,ifd.brand,ifd.name,ifd.alias,ifd.device_info,ifd.profile_id,ifd.device_profile_id,ifd.active_time,ifd.tenant_id,ifd.description
67 ,ifd.tb_device_id,ifd.label,ifd.last_connect_time,ifd.device_type,ifd.device_state,ifd.create_time,ifd.update_time,ifd.creator, 68 ,ifd.tb_device_id,ifd.label,ifd.last_connect_time,ifd.device_type,ifd.device_state,ifd.create_time,ifd.update_time,ifd.creator,
68 ifd.updater,ifd.organization_id,ifd.alarm_status 69 ifd.updater,ifd.organization_id,ifd.alarm_status
69 </sql> 70 </sql>
@@ -93,8 +94,8 @@ @@ -93,8 +94,8 @@
93 <if test="queryMap.tenantId !=null and queryMap.tenantId !=''"> 94 <if test="queryMap.tenantId !=null and queryMap.tenantId !=''">
94 AND ifd.tenant_id = #{queryMap.tenantId} 95 AND ifd.tenant_id = #{queryMap.tenantId}
95 </if> 96 </if>
96 - <if test="queryMap.profileId !=null and queryMap.profileId !=''">  
97 - AND ifd.profile_id = #{queryMap.profileId} 97 + <if test="queryMap.deviceProfileId !=null and queryMap.deviceProfileId !=''">
  98 + AND ifd.device_profile_id = #{queryMap.deviceProfileId}
98 </if> 99 </if>
99 <if test="queryMap.name !=null and queryMap.name !=''"> 100 <if test="queryMap.name !=null and queryMap.name !=''">
100 AND ( 101 AND (
@@ -338,6 +339,9 @@ @@ -338,6 +339,9 @@
338 <if test="tenantId !=null and tenantId !=''"> 339 <if test="tenantId !=null and tenantId !=''">
339 AND base.tenant_id = #{tenantId} 340 AND base.tenant_id = #{tenantId}
340 </if> 341 </if>
  342 + <if test="deviceProfileId !=null and deviceProfileId !=''">
  343 + AND base.device_profile_id = #{deviceProfileId}
  344 + </if>
341 <if test="customerId !=null and customerId !=''"> 345 <if test="customerId !=null and customerId !=''">
342 AND tde.customer_id :: TEXT = #{customerId} 346 AND tde.customer_id :: TEXT = #{customerId}
343 </if> 347 </if>
@@ -8,19 +8,25 @@ @@ -8,19 +8,25 @@
8 <result property="entityType" column="entity_type" typeHandler="org.apache.ibatis.type.EnumTypeHandler"/> 8 <result property="entityType" column="entity_type" typeHandler="org.apache.ibatis.type.EnumTypeHandler"/>
9 <result property="doContext" column="do_context" typeHandler="com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler"/> 9 <result property="doContext" column="do_context" typeHandler="com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler"/>
10 <result property="outTarget" column="out_target" typeHandler="org.apache.ibatis.type.EnumTypeHandler"/> 10 <result property="outTarget" column="out_target" typeHandler="org.apache.ibatis.type.EnumTypeHandler"/>
11 - <result property="sceneLinkageId" column="scene_linkage_id"/> 11 + <result property="callType" column="call_type" typeHandler="org.apache.ibatis.type.EnumTypeHandler"/>
  12 + <result property="commandType" column="command_type"/>
  13 + <result property="thingsModelId" column="scene_linkage_id"/>
  14 + <result property="sceneLinkageId" column="things_model_id"/>
  15 + <result property="deviceProfileId" column="device_profile_id"/>
12 <result property="alarmProfileId" column="alarm_profile_id"/> 16 <result property="alarmProfileId" column="alarm_profile_id"/>
13 - <result property="description" column="description"/>  
14 <result property="tenantId" column="tenant_id"/> 17 <result property="tenantId" column="tenant_id"/>
15 <result property="updater" column="updater"/> 18 <result property="updater" column="updater"/>
16 <result property="updateTime" column="update_time"/> 19 <result property="updateTime" column="update_time"/>
17 <result property="createTime" column="create_time"/> 20 <result property="createTime" column="create_time"/>
18 <result property="creator" column="creator"/> 21 <result property="creator" column="creator"/>
19 - 22 +
20 </resultMap> 23 </resultMap>
21 - 24 + <sql id="columns">
  25 + id,device_id,entity_type,do_context,out_target,call_type,scene_linkage_id,alarm_profile_id,
  26 + tenant_id,updater,update_time,create_time,creator,command_type,things_model_id,device_profile_id
  27 + </sql>
22 <select id="listBySceneId" resultMap="actionDTO"> 28 <select id="listBySceneId" resultMap="actionDTO">
23 - SELECT * FROM tk_do_action WHERE scene_linkage_id = #{sceneId} 29 + SELECT <include refid="columns"/> FROM tk_do_action WHERE scene_linkage_id = #{sceneId}
24 </select> 30 </select>
25 31
26 </mapper> 32 </mapper>