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