Commit 5de3deec3700de6e761bd858581eea94fc9c4d3c

Authored by 黄 x
1 parent c5a65561

fix: add thingsModel and change table name

Showing 89 changed files with 962 additions and 392 deletions
  1 +package org.thingsboard.server.controller.yunteng;
  2 +
  3 +import com.fasterxml.jackson.databind.JsonNode;
  4 +import io.swagger.annotations.Api;
  5 +import io.swagger.annotations.ApiOperation;
  6 +import lombok.RequiredArgsConstructor;
  7 +import org.springframework.http.ResponseEntity;
  8 +import org.springframework.security.access.prepost.PreAuthorize;
  9 +import org.springframework.validation.annotation.Validated;
  10 +import org.springframework.web.bind.annotation.*;
  11 +import org.thingsboard.server.common.data.exception.ThingsboardException;
  12 +import org.thingsboard.server.common.data.yunteng.common.AddGroup;
  13 +import org.thingsboard.server.common.data.yunteng.common.DeleteGroup;
  14 +import org.thingsboard.server.common.data.yunteng.common.UpdateGroup;
  15 +import org.thingsboard.server.common.data.yunteng.core.exception.YtDataValidationException;
  16 +import org.thingsboard.server.common.data.yunteng.core.message.ErrorMessage;
  17 +import org.thingsboard.server.common.data.yunteng.dto.DeleteDTO;
  18 +import org.thingsboard.server.common.data.yunteng.dto.DeviceProfileDTO;
  19 +import org.thingsboard.server.common.data.yunteng.dto.ThingsModelDTO;
  20 +import org.thingsboard.server.common.data.yunteng.enums.FunctionTypeEnum;
  21 +import org.thingsboard.server.common.data.yunteng.enums.OrderTypeEnum;
  22 +import org.thingsboard.server.common.data.yunteng.utils.tools.YtPageData;
  23 +import org.thingsboard.server.controller.BaseController;
  24 +import org.thingsboard.server.dao.yunteng.service.ThingsModelService;
  25 +import org.thingsboard.server.dao.yunteng.service.YtDeviceProfileService;
  26 +
  27 +import java.util.HashMap;
  28 +
  29 +import static org.thingsboard.server.common.data.yunteng.constant.QueryConstant.*;
  30 +import static org.thingsboard.server.common.data.yunteng.constant.QueryConstant.ORDER_TYPE;
  31 +
  32 +@RestController
  33 +@RequiredArgsConstructor
  34 +@RequestMapping("api/yt/things_model")
  35 +@Api(tags = {"物模型管理"})
  36 +public class ThingsModelController extends BaseController {
  37 + private final ThingsModelService thingsModelService;
  38 + private final YtDeviceProfileService ytDeviceProfileService;
  39 +
  40 + @GetMapping(
  41 + path = "/page",
  42 + params = {PAGE_SIZE, PAGE})
  43 + @ApiOperation(value = "分页")
  44 + public YtPageData<ThingsModelDTO> page(
  45 + @RequestParam(PAGE_SIZE) int pageSize,
  46 + @RequestParam(PAGE) int page,
  47 + @RequestParam(value = "nameOrIdentifier", required = false) String nameOrIdentifier,
  48 + @RequestParam(value = ORDER_FILED, required = false) String orderBy,
  49 + @RequestParam(value = ORDER_TYPE, required = false) OrderTypeEnum orderType)
  50 + throws ThingsboardException {
  51 + HashMap<String, Object> queryMap = new HashMap<>();
  52 + queryMap.put("nameOrIdentifier", nameOrIdentifier);
  53 + queryMap.put(PAGE_SIZE, pageSize);
  54 + queryMap.put(PAGE, page);
  55 + queryMap.put(ORDER_FILED, orderBy);
  56 + if (orderType != null) {
  57 + queryMap.put(ORDER_TYPE, orderType.name());
  58 + }
  59 + return thingsModelService.page(queryMap, getCurrentUser().getCurrentTenantId());
  60 + }
  61 +
  62 + @PostMapping()
  63 + @ApiOperation("保存物模型")
  64 + // @PreAuthorize("@check.checkPermissions({'TENANT_ADMIN'},{'api:yt:things_model:post'})")
  65 + public ResponseEntity<ThingsModelDTO> save(
  66 + @Validated(AddGroup.class) @RequestBody ThingsModelDTO thingsModelDTO)
  67 + throws ThingsboardException {
  68 + return ResponseEntity.ok(saveOrUpdate(thingsModelDTO));
  69 + }
  70 +
  71 + @PutMapping()
  72 + @ApiOperation("修改物模型")
  73 + // @PreAuthorize("@check.checkPermissions({'TENANT_ADMIN'},{'api:yt:things_model:put'})")
  74 + public ResponseEntity<ThingsModelDTO> update(
  75 + @Validated(UpdateGroup.class) @RequestBody ThingsModelDTO thingsModelDTO)
  76 + throws ThingsboardException {
  77 + return ResponseEntity.ok(saveOrUpdate(thingsModelDTO));
  78 + }
  79 +
  80 + @DeleteMapping
  81 + @ApiOperation("删除")
  82 + // @PreAuthorize("@check.checkPermissions({'TENANT_ADMIN'},{'api:yt:things_model:delete'})")
  83 + public boolean delete(@Validated(DeleteGroup.class) @RequestBody DeleteDTO deleteDTO)
  84 + throws ThingsboardException {
  85 + deleteDTO.setTenantId(getCurrentUser().getCurrentTenantId());
  86 + return thingsModelService.delete(deleteDTO);
  87 + }
  88 +
  89 + @GetMapping("/{functionType}/{deviceProfileId}")
  90 + @ApiOperation("获取物模型TSL")
  91 + // @PreAuthorize("@check.checkPermissions({'TENANT_ADMIN'},{'api:yt:things_model:json:view'})")
  92 + public ResponseEntity<JsonNode> getTSL(
  93 + @PathVariable("functionType") FunctionTypeEnum functionType,
  94 + @PathVariable("deviceProfileId") String deviceProfileId)
  95 + throws ThingsboardException {
  96 + return ResponseEntity.ok(
  97 + thingsModelService.getTingsModelJson(
  98 + functionType, getCurrentUser().getCurrentTenantId(), deviceProfileId));
  99 + }
  100 +
  101 + private ThingsModelDTO saveOrUpdate(ThingsModelDTO thingsModelDTO) throws ThingsboardException {
  102 +
  103 + String tenantId = getCurrentUser().getCurrentTenantId();
  104 + DeviceProfileDTO deviceProfileDTO =
  105 + ytDeviceProfileService.findDeviceProfileById(tenantId, thingsModelDTO.getDeviceProfileId());
  106 + if (null == deviceProfileDTO) {
  107 + throw new YtDataValidationException(ErrorMessage.NOT_BELONG_CURRENT_TENANT.getMessage());
  108 + }
  109 + thingsModelDTO.setTenantId(tenantId);
  110 + return thingsModelService.saveOrUpdate(thingsModelDTO);
  111 + }
  112 +}
... ...
... ... @@ -9,7 +9,6 @@ import io.swagger.annotations.ApiParam;
9 9 import lombok.RequiredArgsConstructor;
10 10 import lombok.extern.slf4j.Slf4j;
11 11 import org.apache.commons.lang3.StringUtils;
12   -import org.springframework.http.HttpStatus;
13 12 import org.springframework.http.ResponseEntity;
14 13 import org.springframework.security.access.prepost.PreAuthorize;
15 14 import org.springframework.validation.annotation.Validated;
... ... @@ -18,7 +17,6 @@ import org.thingsboard.rule.engine.api.msg.DeviceCredentialsUpdateNotificationMs
18 17 import org.thingsboard.server.common.data.Device;
19 18 import org.thingsboard.server.common.data.audit.ActionType;
20 19 import org.thingsboard.server.common.data.edge.EdgeEventActionType;
21   -import org.thingsboard.server.common.data.exception.ThingsboardErrorCode;
22 20 import org.thingsboard.server.common.data.exception.ThingsboardException;
23 21 import org.thingsboard.server.common.data.id.*;
24 22 import org.thingsboard.server.common.data.relation.EntityRelation;
... ... @@ -38,6 +36,7 @@ import org.thingsboard.server.common.data.yunteng.utils.tools.ResponseResult;
38 36 import org.thingsboard.server.common.data.yunteng.utils.tools.YtPageData;
39 37 import org.thingsboard.server.controller.BaseController;
40 38 import org.thingsboard.server.dao.device.DeviceService;
  39 +import org.thingsboard.server.dao.yunteng.service.YtDeviceProfileService;
41 40 import org.thingsboard.server.dao.yunteng.service.YtDeviceService;
42 41 import org.thingsboard.server.service.security.permission.Operation;
43 42 import org.thingsboard.server.service.security.permission.Resource;
... ... @@ -58,7 +57,7 @@ public class YtDeviceController extends BaseController {
58 57 private final YtDeviceService deviceService;
59 58 private final DeviceService tbDeviceService;
60 59 private final ObjectMapper objectMapper;
61   - String sePL = new Date().toString();
  60 + private final YtDeviceProfileService ytDeviceProfileService;
62 61
63 62 @PostMapping
64 63 @ApiOperation("创建|编辑")
... ... @@ -68,66 +67,59 @@ public class YtDeviceController extends BaseController {
68 67 @Validated(AddGroup.class) @RequestBody DeviceDTO deviceDTO)
69 68 throws ThingsboardException, ExecutionException, InterruptedException {
70 69 String currentTenantId = getCurrentUser().getCurrentTenantId();
71   - deviceService.validateFormdata(currentTenantId, deviceDTO);
  70 + deviceService.validateFormData(currentTenantId, deviceDTO);
72 71
73   -
74   -
75   -
76   - /**网关是否有效*/
  72 + /** 网关是否有效 */
77 73 String gatewayId = deviceDTO.getGatewayId();
78 74 DeviceDTO gateWay = null;
79 75 if (StringUtils.isNotEmpty(gatewayId)) {
80   - gateWay = deviceService.checkDeviceByTenantIdAndDeviceId(getCurrentUser().getCurrentTenantId(), gatewayId);
  76 + gateWay =
  77 + deviceService.checkDeviceByTenantIdAndDeviceId(
  78 + getCurrentUser().getCurrentTenantId(), gatewayId);
81 79 if (null == gateWay) {
82 80 throw new YtDataValidationException(
83 81 ErrorMessage.DEVICE_NOT_EXISTENCE_IN_TENANT.getMessage());
84 82 }
85 83 }
86 84
87   -
88   -
89   -
90   - /** 子设备编辑业务逻辑: 设备地址码必须同时设置到附加信息字段内。
91   - * 1、新增或编辑网关和直连设备
92   - * 2、新增网关子设备
93   - * 3、编辑网关子设备时,关联关系已存在(未切换网关)
94   - * 4、编辑网关子设备时,关联关系不存在(切换网关)
95   - * 5、编辑网关子设备时,修改其它设备信息,例如:设备名称等。
96   - * */
  85 + /**
  86 + * 子设备编辑业务逻辑: 设备地址码必须同时设置到附加信息字段内。 1、新增或编辑网关和直连设备 2、新增网关子设备 3、编辑网关子设备时,关联关系已存在(未切换网关)
  87 + * 4、编辑网关子设备时,关联关系不存在(切换网关) 5、编辑网关子设备时,修改其它设备信息,例如:设备名称等。
  88 + */
97 89 Device tbDevice = buildTbDeviceFromDeviceDTO(getCurrentUser().getTenantId(), deviceDTO);
98 90 DeviceId selfTbId = updateTbDevice(tbDevice, deviceDTO.getDeviceToken());
99 91 String selfTbIdStr = selfTbId.getId().toString();
100 92 deviceDTO.setTbDeviceId(selfTbIdStr);
101 93
102   -
103 94 if (selfTbIdStr != null
104   - && deviceDTO.getDeviceType().equals(DeviceTypeEnum.SENSOR)
105   - && StringUtils.isNotEmpty(gatewayId)) {
  95 + && deviceDTO.getDeviceType().equals(DeviceTypeEnum.SENSOR)
  96 + && StringUtils.isNotEmpty(gatewayId)) {
106 97 boolean relationNotMatched = true;
107 98
108 99 EntityId slaveId = EntityIdFactory.getByTypeAndId("DEVICE", selfTbIdStr);
109   - List<EntityRelationInfo> relations = relationService.findInfoByTo(getTenantId(), slaveId, RelationTypeGroup.COMMON).get();
  100 + List<EntityRelationInfo> relations =
  101 + relationService.findInfoByTo(getTenantId(), slaveId, RelationTypeGroup.COMMON).get();
110 102
111 103 for (EntityRelationInfo relationInfo : relations) {
112   - if(!FastIotConstants.Relation.relationType.equals(relationInfo.getType())){
  104 + if (!FastIotConstants.Relation.relationType.equals(relationInfo.getType())) {
113 105 continue;
114 106 }
115 107 if (relationInfo.getFrom().getId().toString().equals(gateWay.getTbDeviceId())) {
116 108 relationNotMatched = false;
117   - }else {
118   - relationService.deleteRelation(getTenantId(),relationInfo);
119   - sendRelationNotificationMsg(getTenantId(), relationInfo, EdgeEventActionType.RELATION_DELETED);
  109 + } else {
  110 + relationService.deleteRelation(getTenantId(), relationInfo);
  111 + sendRelationNotificationMsg(
  112 + getTenantId(), relationInfo, EdgeEventActionType.RELATION_DELETED);
120 113 }
121 114 }
122 115
123   - if(relationNotMatched){
  116 + if (relationNotMatched) {
124 117 addRelation(getTenantId(), gateWay.getTbDeviceId(), selfTbIdStr);
125 118 }
126 119 }
127 120
128   -
129   -
130   - DeviceDTO newDeviceDTO = deviceService.insertOrUpdate(getCurrentUser().getCurrentTenantId(), deviceDTO);
  121 + DeviceDTO newDeviceDTO =
  122 + deviceService.insertOrUpdate(getCurrentUser().getCurrentTenantId(), deviceDTO);
131 123 return ResponseEntity.ok(newDeviceDTO);
132 124 }
133 125
... ... @@ -334,25 +326,29 @@ public class YtDeviceController extends BaseController {
334 326 @PreAuthorize("@check.checkPermissions({'TENANT_ADMIN'},{})")
335 327 @ApiOperation("获取特定设备类型的所有设备")
336 328 public List<DeviceDTO> getGatewayDevices(
337   -
338   - @ApiParam(value = "设备类型") @PathVariable("deviceType") DeviceTypeEnum deviceType,
339   - @ApiParam(value = "组织ID") @RequestParam(value="organizationId", required = false) String organizationId,
340   - @ApiParam(value = "设备标签") @RequestParam(value="deviceLabel", required = false) String deviceLabel)
341   - throws ThingsboardException {
  329 + @ApiParam(value = "设备类型") @PathVariable("deviceType") DeviceTypeEnum deviceType,
  330 + @ApiParam(value = "组织ID") @RequestParam(value = "organizationId", required = false)
  331 + String organizationId,
  332 + @ApiParam(value = "设备标签") @RequestParam(value = "deviceLabel", required = false)
  333 + String deviceLabel)
  334 + throws ThingsboardException {
342 335 return deviceService.findDevicesByDeviceTypeAndOrganizationId(
343   - deviceType, getCurrentUser().getCurrentTenantId(), organizationId,deviceLabel);
  336 + deviceType, getCurrentUser().getCurrentTenantId(), organizationId, deviceLabel);
344 337 }
345 338
346 339 @GetMapping("/list")
347 340 @PreAuthorize("@check.checkPermissions({'TENANT_ADMIN','CUSTOMER_USER'},{})")
348 341 @ApiOperation("获取满足条件的所有设备")
349 342 public List<DeviceDTO> getDevices(
350   - @ApiParam(value = "设备类型") @RequestParam(value="deviceType", required = false) DeviceTypeEnum deviceType,
351   - @ApiParam(value = "组织ID") @RequestParam(value="organizationId", required = false) String organizationId,
352   - @ApiParam(value = "设备标签") @RequestParam(value="deviceLabel", required = false) String deviceLabel)
353   - throws ThingsboardException {
  343 + @ApiParam(value = "设备类型") @RequestParam(value = "deviceType", required = false)
  344 + DeviceTypeEnum deviceType,
  345 + @ApiParam(value = "组织ID") @RequestParam(value = "organizationId", required = false)
  346 + String organizationId,
  347 + @ApiParam(value = "设备标签") @RequestParam(value = "deviceLabel", required = false)
  348 + String deviceLabel)
  349 + throws ThingsboardException {
354 350 return deviceService.findDevicesByDeviceTypeAndOrganizationId(
355   - deviceType, getCurrentUser().getCurrentTenantId(), organizationId,deviceLabel);
  351 + deviceType, getCurrentUser().getCurrentTenantId(), organizationId, deviceLabel);
356 352 }
357 353
358 354 @GetMapping("/list/master/{organizationId}")
... ... @@ -427,7 +423,7 @@ public class YtDeviceController extends BaseController {
427 423 tbDevice.setId(id);
428 424 }
429 425
430   - /**扩展设备附加信息,例如:设备地址码、上下线时间等*/
  426 + /** 扩展设备附加信息,例如:设备地址码、上下线时间等 */
431 427 ObjectNode additionalInfo = objectMapper.createObjectNode();
432 428 additionalInfo.put(
433 429 "gateway",
... ... @@ -441,9 +437,9 @@ public class YtDeviceController extends BaseController {
441 437 .map(JsonNode::asText)
442 438 .orElse(""));
443 439 additionalInfo.put("overwriteActivityTime", false);
444   - //TCP协议需要设备地址码分发数据给对应设备
445   - if(StringUtils.isNotEmpty(deviceDTO.getCode())){
446   - additionalInfo.put(FastIotConstants.TCP_DEVICE_IDENTIFY_FILED,deviceDTO.getCode());
  440 + // TCP协议需要设备地址码分发数据给对应设备
  441 + if (StringUtils.isNotEmpty(deviceDTO.getCode())) {
  442 + additionalInfo.put(FastIotConstants.TCP_DEVICE_IDENTIFY_FILED, deviceDTO.getCode());
447 443 }
448 444
449 445 DeviceProfileId deviceProfileId =
... ... @@ -487,4 +483,17 @@ public class YtDeviceController extends BaseController {
487 483 result.setMessage(str);
488 484 return result;
489 485 }
  486 +
  487 + @GetMapping({"/attributes/{profileId}/{id}"})
  488 + @ApiOperation("获取设备的属性")
  489 + public ResponseEntity<JsonNode> getDeviceAttributes(
  490 + @PathVariable("profileId") String profileId, @PathVariable("id") String id)
  491 + throws ThingsboardException {
  492 + String tenantId = getCurrentUser().getCurrentTenantId();
  493 + DeviceProfileDTO dto = ytDeviceProfileService.findByTbDeviceProfileId(tenantId, profileId);
  494 + if (null == dto) {
  495 + throw new YtDataValidationException(ErrorMessage.INVALID_PARAMETER.getMessage());
  496 + }
  497 + return ResponseEntity.ok(deviceService.getDeviceAttributes(profileId,dto.getId(), id, tenantId));
  498 + }
490 499 }
... ...
... ... @@ -176,7 +176,7 @@ public class DefaultSystemDataLoaderService implements SystemDataLoaderService {
176 176
177 177 @Override
178 178 public void createSysAdmin() {
179   - createUser(Authority.SYS_ADMIN, null, null, "sysadmin@qq.com", "Sysadmin@123");
  179 + createUser(Authority.SYS_ADMIN, null, null, "sysadmin@yunteng.com", "Sysadmin@123");
180 180 }
181 181
182 182 @Override
... ...
... ... @@ -3,63 +3,63 @@ package org.thingsboard.server.common.data.yunteng.constant;
3 3 public final class ModelConstants {
4 4 public static class Table {
5 5 /** 系统用户表 */
6   - public static final String USER_TABLE_NAME = "sys_user";
  6 + public static final String SYS_USER_TABLE_NAME = "sys_user";
7 7 /** 租户表 */
8   - public static final String TENANT_TABLE_NAME = "sys_tenant";
  8 + public static final String SYS_TENANT_TABLE_NAME = "sys_tenant";
9 9 /** 租户菜单表 */
10   - public static final String TENANT_MENU_TABLE_NAME = "sys_tenant_menu";
  10 + public static final String SYS_TENANT_MENU_TABLE_NAME = "sys_tenant_menu";
11 11 /** 租户角色表 */
12   - public static final String TENANT_ROLE_TABLE_NAME = "sys_tenant_role";
  12 + public static final String SYS_TENANT_ROLE_TABLE_NAME = "sys_tenant_role";
13 13 /** 菜单表 */
14   - public static final String MENU_TABLE_NAME = "sys_menu";
  14 + public static final String SYS_MENU_TABLE_NAME = "sys_menu";
15 15 /** 通知管理 */
16 16 public static final String SYS_NOTICE_TABLE_NAME = "sys_notice";
17 17 /** 我的通知 */
18 18 public static final String SYS_NOTICE_USER_TABLE_NAME = "sys_notice_user";
19 19 /** 角色表 */
20   - public static final String ROLE_TABLE_NAME = "sys_role";
  20 + public static final String SYS_ROLE_TABLE_NAME = "sys_role";
21 21 /** 用户角色关系表 */
22   - public static final String USER_ROLE_TABLE_NAME = "sys_user_role";
  22 + public static final String SYS_USER_ROLE_TABLE_NAME = "sys_user_role";
23 23 /** 系统用户设置表 */
24   - public static final String ADMIN_SETTING_TABLE_NAME = "sys_admin_setting";
  24 + public static final String SYS_ADMIN_SETTING_TABLE_NAME = "sys_admin_setting";
25 25 /** 字典表 */
26   - public static final String DICT_TABLE_NAME = "sys_dict";
  26 + public static final String SYS_DICT_TABLE_NAME = "sys_dict";
27 27 /** 字典值表 */
28   - public static final String DICT_ITEM_TABLE_NAME = "sys_dict_item";
  28 + public static final String SYS_DICT_ITEM_TABLE_NAME = "sys_dict_item";
29 29 /** 消息字典表 */
30   - public static final String MESSAGE_CONFIG_TABLE_NAME = "message_config";
  30 + public static final String TK_MESSAGE_CONFIG_TABLE_NAME = "tk_message_config";
31 31 /** 消息模板表 */
32   - public static final String MESSAGE_TEMPLATE_TABLE_NAME = "message_template";
  32 + public static final String TK_MESSAGE_TEMPLATE_TABLE_NAME = "tk_message_template";
33 33 /** 短信发送记录表 */
34   - public static final String SMS_LOG_TABLE_NAME = "sms_log";
  34 + public static final String TK_SMS_LOG_TABLE_NAME = "tk_sms_log";
35 35 /** 邮件发送记录表 */
36   - public static final String MAIL_LOG_TABLE_NAME = "mail_log";
  36 + public static final String TK_MAIL_LOG_TABLE_NAME = "tk_mail_log";
37 37 /** 限流表 */
38   - public static final String RATE_LIMIT_TABLE_NAME = "sys_rate_limit";
  38 + public static final String SYS_RATE_LIMIT_TABLE_NAME = "sys_rate_limit";
39 39 /** 系统部门表 */
40   - public static final String DEPT_TABLE_NAME = "sys_dept";
  40 + public static final String SYS_DEPT_TABLE_NAME = "sys_dept";
41 41 /** 系统定时任务表 */
42   - public static final String JOB_TABLE_NAME = "sys_job";
  42 + public static final String SYS_JOB_TABLE_NAME = "sys_job";
43 43 /** 定时任务执行记录表 */
44   - public static final String JOB_LOG_TABLE_NAME = "sys_job_log";
  44 + public static final String SYS_JOB_LOG_TABLE_NAME = "sys_job_log";
45 45 /** 组织表 */
46   - public static final String IOTFS_ORGANIZATION_TABLE_NAME = "iotfs_organization";
  46 + public static final String TK_ORGANIZATION_TABLE_NAME = "tk_organization";
47 47 /** 用户与组织映射表 */
48   - public static final String IOTFS_USER_ORGANIZATION_MAPPING_TABLE_NAME =
49   - "iotfs_user_organization_mapping";
  48 + public static final String TK_USER_ORGANIZATION_MAPPING_TABLE_NAME =
  49 + "tk_user_organization_mapping";
50 50 /** 设备表 */
51   - public static final String IOTFS_DEVICE_TABLE_NAME = "iotfs_device";
  51 + public static final String TK_DEVICE_TABLE_NAME = "tk_device";
52 52 /** 产品信息(设备配置)扩展表 */
53   - public static final String IOTFS_DEVICE_PROFILE_TABLE_NAME = "iotfs_device_profile";
  53 + public static final String TK_DEVICE_PROFILE_TABLE_NAME = "tk_device_profile";
54 54 /** 自定义数据协议解析脚本 */
55   - public static final String IOTFS_DEVICE_SCRIPT_TABLE_NAME = "iotfs_java_script";
  55 + public static final String TK_DEVICE_SCRIPT_TABLE_NAME = "tk_java_script";
56 56
57 57 /** 设备类型表 */
58   - public static final String IOTFS_DEVICE_TYPE_TABLE_NAME = "iotfs_device_type";
  58 + public static final String TK_DEVICE_TYPE_TABLE_NAME = "tk_device_type";
59 59 /** 告警配置表 */
60   - public static final String IOTFS_ALARM_PROFILE_TABLE_NAME = "iotfs_alarm_profile";
  60 + public static final String TK_ALARM_PROFILE_TABLE_NAME = "tk_alarm_profile";
61 61 /** 告警联系人 */
62   - public static final String IOTFS_ALARM_CONTACT_TABLE_NAME = "iotfs_alarm_contact";
  62 + public static final String TK_ALARM_CONTACT_TABLE_NAME = "tk_alarm_contact";
63 63 /** 企业信息 */
64 64 public static final String SYS_ENTERPRISE_TABLE_NAME = "sys_enterprise";
65 65 /** 平台定制 */
... ... @@ -67,47 +67,47 @@ public final class ModelConstants {
67 67 /** APP定制 */
68 68 public static final String SYS_APP_DESIGN_TABLE_NAME = "sys_app_design";
69 69 /** 场景联动表 */
70   - public static final String IOTFS_SCENE_LINKAGE_TABLE_NAME = "iotfs_scene_linkage";
  70 + public static final String TK_SCENE_LINKAGE_TABLE_NAME = "tk_scene_linkage";
71 71 /** 场景触发器 */
72   - public static final String IOTFS_TRIGGER_TABLE_NAME = "iotfs_trigger";
  72 + public static final String TK_TRIGGER_TABLE_NAME = "tk_trigger";
73 73 /** 执行条件表 */
74   - public static final String IOTFS_DO_CONDITION_TABLE_NAME = "iotfs_do_condition";
  74 + public static final String TK_DO_CONDITION_TABLE_NAME = "tk_do_condition";
75 75 /** 条件动作表 */
76   - public static final String IOTFS_DO_ACTION_TABLE_NAME = "iotfs_do_action";
  76 + public static final String TK_DO_ACTION_TABLE_NAME = "tk_do_action";
77 77 /** 中国城镇区街 */
78 78 public static final String SYS_AREA_TABLE_NAME = "sys_area";
79 79 /** 数据流转配置表 */
80   - public static final String IOTFS_CONVERT_CONFIG_TABLE_NAME = "iotfs_convert_config";
  80 + public static final String TK_CONVERT_CONFIG_TABLE_NAME = "tk_convert_config";
81 81 /** 组态中心 */
82   - public static final String IOTFS_CONFIGURATION_CENTER_NAME = "iotfs_configuration_center";
  82 + public static final String TK_CONFIGURATION_CENTER_NAME = "tk_configuration_center";
83 83 /** 组态内容 */
84   - public static final String IOTFS_CONFIGURATION_CONTENT_NAME = "iotfs_configuration_content";
  84 + public static final String TK_CONFIGURATION_CONTENT_NAME = "tk_configuration_content";
85 85 /** 组态节点数据源 */
86   - public static final String IOTFS_CONFIGURATION_DATASOURCE = "iotfs_configuration_datasource";
  86 + public static final String TK_CONFIGURATION_DATASOURCE = "tk_configuration_datasource";
87 87 /** 组态节点数据交互 */
88   - public static final String IOTFS_CONFIGURATION_EVENT = "iotfs_configuration_event";
  88 + public static final String TK_CONFIGURATION_EVENT = "tk_configuration_event";
89 89 /** 组态节点动画效果 */
90   - public static final String IOTFS_CONFIGURATION_ACT = "iotfs_configuration_act";
  90 + public static final String TK_CONFIGURATION_ACT = "tk_configuration_act";
91 91 /** 视频流 */
92   - public static final String IOTFS_VIDEO_STREAM_TABLE_NAME = "iotfs_device_camera";
  92 + public static final String TK_VIDEO_STREAM_TABLE_NAME = "tk_device_camera";
93 93 /** 流媒体配置 */
94   - public static final String IOTFS_VIDEO_PLATFORM_TABLE_NAME = "iotfs_video_platform";
  94 + public static final String TK_VIDEO_PLATFORM_TABLE_NAME = "tk_video_platform";
95 95 /** 意见反馈 */
96   - public static final String IOTFS_OPINION_TABLE_NAME = "iotfs_opinion";
  96 + public static final String TK_OPINION_TABLE_NAME = "tk_opinion";
97 97 /** 第三方用户表 */
98   - public static final String IOTFS_THIRD_USER_TABLE_NAME = "iotfs_third_user";
  98 + public static final String TK_THIRD_USER_TABLE_NAME = "tk_third_user";
99 99 /** frp内网穿透信息表 */
100   - public static final String IOTFS_FRP_INFO_NAME = "iotfs_frp_info";
  100 + public static final String TK_FRP_INFO_NAME = "tk_frp_info";
101 101 /** 报表配置表 */
102   - public static final String IOTFS_REPORT_FORM_CONFIG_NAME = "iotfs_report_form_config";
  102 + public static final String TK_REPORT_FORM_CONFIG_NAME = "tk_report_form_config";
103 103 /** 报表生成记录表 */
104   - public static final String IOTFS_REPORT_GENERATE_RECORD_NAME = "iotfs_report_generate_record";
  104 + public static final String TK_REPORT_GENERATE_RECORD_NAME = "tk_report_generate_record";
105 105 /** 数据看板 */
106   - public static final String IOTFS_DATA_BOARD_NAME = "iotfs_data_board";
  106 + public static final String TK_DATA_BOARD_NAME = "tk_data_board";
107 107 /** 数据组件 */
108   - public static final String IOTFS_DATA_COMPONENT_NAME = "iotfs_data_component";
  108 + public static final String TK_DATA_COMPONENT_NAME = "tk_data_component";
109 109 /** 物模型 */
110   - public static final String IOTFS_THING_MODEL = "iotfs_model";
  110 + public static final String TK_THING_MODEL = "tk_things_model";
111 111 }
112 112
113 113 public static class TableFields {
... ...
... ... @@ -84,6 +84,7 @@ public enum ErrorMessage {
84 84 MESSAGE_SEND_FAILED(4010060, "消息发送失败!"),
85 85 PROJECT_USED_SCRIPT(400061,"产品【%s】正在使用待删除的解析脚本"),
86 86 RULE_CHAIN_NOT_ENABLE(400062,"规则链不是有效的!"),
  87 + DUPLICATE_IDENTIFIERS_EXIST(400063,"存在重复的功能标识符。"),
87 88 HAVE_NO_PERMISSION(500002,"没有修改权限");
88 89 private final int code;
89 90 private String message;
... ...
  1 +package org.thingsboard.server.common.data.yunteng.dto;
  2 +
  3 +import com.fasterxml.jackson.databind.JsonNode;
  4 +import io.swagger.annotations.ApiModel;
  5 +import io.swagger.annotations.ApiModelProperty;
  6 +import lombok.Data;
  7 +import org.thingsboard.server.common.data.yunteng.enums.DataTypeEnum;
  8 +
  9 +@Data
  10 +@ApiModel("属性模型")
  11 +public class AttributeModelDTO extends BaseModelDTO {
  12 + @ApiModelProperty("数据类型")
  13 + private DataTypeEnum dataType;
  14 +
  15 + @ApiModelProperty("读写类型:0只读 1读写")
  16 + private Integer readWrite;
  17 +
  18 + @ApiModelProperty("规格内容")
  19 + private JsonNode specs;
  20 +}
... ...
  1 +package org.thingsboard.server.common.data.yunteng.dto;
  2 +
  3 +import io.swagger.annotations.ApiModelProperty;
  4 +import lombok.Data;
  5 +
  6 +@Data
  7 +public class BaseModelDTO {
  8 + @ApiModelProperty("功能名称")
  9 + private String functionName;
  10 +
  11 + @ApiModelProperty("标识符")
  12 + private String identifier;
  13 +
  14 + @ApiModelProperty("备注")
  15 + private String remark;
  16 +}
... ...
... ... @@ -26,6 +26,8 @@ public class DeviceDTO extends TenantDTO {
26 26 */
27 27 private JsonNode deviceInfo;
28 28
  29 + @ApiModelProperty(value = "别名")
  30 + private String alias;
29 31 @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
30 32 private LocalDateTime activeTime;
31 33
... ...
1 1 package org.thingsboard.server.common.data.yunteng.dto;
2 2
3   -import com.fasterxml.jackson.databind.JsonNode;
4 3 import io.swagger.annotations.ApiModelProperty;
5 4 import lombok.Data;
6 5 import lombok.EqualsAndHashCode;
... ... @@ -18,7 +17,6 @@ import javax.validation.constraints.NotEmpty;
18 17 import javax.validation.constraints.NotNull;
19 18 import java.time.Instant;
20 19 import java.time.LocalDateTime;
21   -import java.time.ZoneId;
22 20 import java.time.ZoneOffset;
23 21 import java.util.Optional;
24 22 import java.util.UUID;
... ... @@ -26,72 +24,84 @@ import java.util.UUID;
26 24 @EqualsAndHashCode(callSuper = true)
27 25 @Data
28 26 public class DeviceProfileDTO extends BaseDTO {
29   - @NotEmpty(message = "设备配置名称不能为空或者空字符串", groups = AddGroup.class)
30   - @ApiModelProperty(value = "产品(设备配置)名称")
31   - private String name;
32   -
33   - private String description;
34   -
35   - /**
36   - * TCP协议的解析脚本ID,由后端自己回填
37   - */
38   - private String scriptId;
39   -
40   - @ApiModelProperty(value = "租户ID")
41   - private String tenantId;
42   - @NotEmpty(message = "传输协议不能为空或者空字符串", groups = AddGroup.class)
43   - @ApiModelProperty(value = "传输协议", required = true)
44   - private String transportType;
45   -
46   - private String provisionType;
47   -
48   - @NotNull(message = "产品类型不能为空", groups = {AddGroup.class})
49   - @ApiModelProperty(value = "产品类型:GATEWAY,DIRECT_CONNECTION,SENSOR", required = true)
50   - private DeviceTypeEnum deviceType;
51   -
52   - /**
53   - * TB的设备配置文件
54   - */
55   - private String tbProfileId;
56   - @Valid
57   - private transient DeviceProfileData profileData;
58   - @ApiModelProperty(value = "关联规则链,默认关联根规则链", required = false)
59   - private String defaultRuleChainId;
60   - /**
61   - * 告警通知配置
62   - */
63   - private AlarmProfileDTO alarmProfile;
64   -
65   - /**默认消息队列*/
66   - private String defaultQueueName;
67   -
68   - /**设备配置图片*/
69   - private String image;
70   - /**是否默认设备配置*/
71   - private boolean isDefault;
72   - private String type;
73   -
74   - public DeviceProfileDTO() {
75   - }
76   -
77   - public DeviceProfileDTO(UUID id, String name, Long time, String description, DeviceTransportType transportType, UUID defaultRuleChainId,boolean isDefault,String image,DeviceProfileType type,Object profileData) {
78   - setId(id.toString());
79   - setCreateTime(LocalDateTime.ofInstant(Instant.ofEpochMilli(time), ZoneOffset.of("+8")));
80   - this.name = name;
81   - this.isDefault = isDefault;
82   - this.image = image;
83   - this.description = description;
84   - this.type = type.name();
85   - this.transportType = transportType.name();
86   - this.defaultRuleChainId = Optional.ofNullable(defaultRuleChainId).map(chainId -> chainId.toString()).orElse(null);
87   - this.profileData = JacksonUtil.convertValue(profileData, DeviceProfileData.class);
88   -
89   - }
90   - public DeviceProfileDTO(String name, TenantId tenantId, DeviceProfileId tbProfileId, DeviceTypeEnum deviceType) {
91   - this.name = name;
92   - this.tenantId =tenantId.getId().toString();
93   - this.tbProfileId = tbProfileId.getId().toString();
94   - this.deviceType = deviceType;
95   - }
  27 + @NotEmpty(message = "设备配置名称不能为空或者空字符串", groups = AddGroup.class)
  28 + @ApiModelProperty(value = "产品(设备配置)名称")
  29 + private String name;
96 30
  31 + private String description;
  32 +
  33 + /** TCP协议的解析脚本ID,由后端自己回填 */
  34 + private String scriptId;
  35 +
  36 + @ApiModelProperty(value = "租户ID")
  37 + private String tenantId;
  38 +
  39 + @NotEmpty(message = "传输协议不能为空或者空字符串", groups = AddGroup.class)
  40 + @ApiModelProperty(value = "传输协议", required = true)
  41 + private String transportType;
  42 +
  43 + private String provisionType;
  44 +
  45 + @NotNull(
  46 + message = "产品类型不能为空",
  47 + groups = {AddGroup.class})
  48 + @ApiModelProperty(value = "产品类型:GATEWAY,DIRECT_CONNECTION,SENSOR", required = true)
  49 + private DeviceTypeEnum deviceType;
  50 +
  51 + /** TB的设备配置文件 */
  52 + private String tbProfileId;
  53 +
  54 + @Valid private transient DeviceProfileData profileData;
  55 +
  56 + @ApiModelProperty(value = "关联规则链,默认关联根规则链")
  57 + private String defaultRuleChainId;
  58 + /** 告警通知配置 */
  59 + private AlarmProfileDTO alarmProfile;
  60 +
  61 + /** 默认消息队列 */
  62 + private String defaultQueueName;
  63 +
  64 + /** 设备配置图片 */
  65 + private String image;
  66 + /** 是否默认设备配置 */
  67 + private boolean isDefault;
  68 +
  69 + private String type;
  70 +
  71 + @ApiModelProperty(value = "物模型")
  72 + private ThingsModelDTO thingsModel;
  73 +
  74 + public DeviceProfileDTO() {}
  75 +
  76 + public DeviceProfileDTO(
  77 + UUID id,
  78 + String name,
  79 + Long time,
  80 + String description,
  81 + DeviceTransportType transportType,
  82 + UUID defaultRuleChainId,
  83 + boolean isDefault,
  84 + String image,
  85 + DeviceProfileType type,
  86 + Object profileData) {
  87 + setId(id.toString());
  88 + setCreateTime(LocalDateTime.ofInstant(Instant.ofEpochMilli(time), ZoneOffset.of("+8")));
  89 + this.name = name;
  90 + this.isDefault = isDefault;
  91 + this.image = image;
  92 + this.description = description;
  93 + this.type = type.name();
  94 + this.transportType = transportType.name();
  95 + this.defaultRuleChainId =
  96 + Optional.ofNullable(defaultRuleChainId).map(UUID::toString).orElse(null);
  97 + this.profileData = JacksonUtil.convertValue(profileData, DeviceProfileData.class);
  98 + }
  99 +
  100 + public DeviceProfileDTO(
  101 + String name, TenantId tenantId, DeviceProfileId tbProfileId, DeviceTypeEnum deviceType) {
  102 + this.name = name;
  103 + this.tenantId = tenantId.getId().toString();
  104 + this.tbProfileId = tbProfileId.getId().toString();
  105 + this.deviceType = deviceType;
  106 + }
97 107 }
... ...
  1 +package org.thingsboard.server.common.data.yunteng.dto;
  2 +
  3 +import com.fasterxml.jackson.databind.JsonNode;
  4 +import io.swagger.annotations.ApiModel;
  5 +import io.swagger.annotations.ApiModelProperty;
  6 +import lombok.Data;
  7 +import lombok.EqualsAndHashCode;
  8 +
  9 +@EqualsAndHashCode(callSuper = true)
  10 +@Data
  11 +@ApiModel("事件模型")
  12 +public class EventModelDTO extends BaseModelDTO {
  13 + @ApiModelProperty("时间类型:0 信息 1告警 2故障")
  14 + private Integer type;
  15 +
  16 + @ApiModelProperty("输出参数")
  17 + private JsonNode outputData;
  18 +}
... ...
  1 +package org.thingsboard.server.common.data.yunteng.dto;
  2 +
  3 +import com.fasterxml.jackson.databind.JsonNode;
  4 +import io.swagger.annotations.ApiModel;
  5 +import io.swagger.annotations.ApiModelProperty;
  6 +import lombok.Data;
  7 +import lombok.EqualsAndHashCode;
  8 +
  9 +@EqualsAndHashCode(callSuper = true)
  10 +@Data
  11 +@ApiModel("服务模型")
  12 +public class ServiceModelDTO extends BaseModelDTO {
  13 + @ApiModelProperty("调用方式:0 同步 1异步")
  14 + private Integer method;
  15 +
  16 + @ApiModelProperty("输入参数")
  17 + private JsonNode inputData;
  18 +
  19 + @ApiModelProperty("输出参数")
  20 + private JsonNode outputData;
  21 +}
... ...
  1 +package org.thingsboard.server.common.data.yunteng.dto;
  2 +
  3 +import com.fasterxml.jackson.databind.JsonNode;
  4 +import io.swagger.annotations.ApiModel;
  5 +import io.swagger.annotations.ApiModelProperty;
  6 +import lombok.Data;
  7 +import lombok.EqualsAndHashCode;
  8 +import org.thingsboard.server.common.data.yunteng.common.AddGroup;
  9 +import org.thingsboard.server.common.data.yunteng.common.UpdateGroup;
  10 +import org.thingsboard.server.common.data.yunteng.enums.FunctionTypeEnum;
  11 +
  12 +import javax.validation.constraints.NotEmpty;
  13 +import javax.validation.constraints.NotNull;
  14 +
  15 +@Data
  16 +@EqualsAndHashCode(callSuper = true)
  17 +@ApiModel("物模型")
  18 +public class ThingsModelDTO extends TenantDTO {
  19 + @ApiModelProperty("功能类型")
  20 + @NotNull(
  21 + message = "功能类型不能为空",
  22 + groups = {AddGroup.class, UpdateGroup.class})
  23 + private FunctionTypeEnum functionType;
  24 +
  25 + @ApiModelProperty("功能名称")
  26 + @NotEmpty(
  27 + message = "功能名称不能为空或空字符串",
  28 + groups = {AddGroup.class})
  29 + private String functionName;
  30 +
  31 + @NotEmpty(
  32 + message = "功能标识不能为空或空字符串",
  33 + groups = {AddGroup.class})
  34 + @ApiModelProperty("功能标识")
  35 + private String identifier;
  36 +
  37 + @ApiModelProperty("功能json")
  38 + @NotNull(
  39 + message = "功能json不能为空",
  40 + groups = {AddGroup.class})
  41 + private JsonNode functionJson;
  42 +
  43 + @ApiModelProperty("设备配置ID")
  44 + @NotEmpty(
  45 + message = "设备配置ID不能为空或空字符串",
  46 + groups = {AddGroup.class, UpdateGroup.class})
  47 + private String deviceProfileId;
  48 +
  49 + @ApiModelProperty("备注")
  50 + private String remark;
  51 +}
... ...
  1 +package org.thingsboard.server.common.data.yunteng.enums;
  2 +
  3 +public enum DataTypeEnum {
  4 + STRING,
  5 + BOOLEAN,
  6 + DOUBLE,
  7 + JSON
  8 +}
... ...
  1 +package org.thingsboard.server.common.data.yunteng.enums;
  2 +
  3 +public enum FunctionTypeEnum {
  4 + /** 属性 */
  5 + properties,
  6 + /** 事件 */
  7 + events,
  8 + /** 服务 */
  9 + services
  10 +}
... ...
... ... @@ -9,7 +9,7 @@ import org.thingsboard.server.common.data.yunteng.constant.ModelConstants;
9 9 import org.thingsboard.server.dao.yunteng.entities.TenantBaseEntity;
10 10
11 11 @Data
12   -@TableName(value = ModelConstants.Table.IOTFS_CONVERT_CONFIG_TABLE_NAME, autoResultMap = true)
  12 +@TableName(value = ModelConstants.Table.TK_CONVERT_CONFIG_TABLE_NAME, autoResultMap = true)
13 13 public class ConvertConfig extends TenantBaseEntity {
14 14 private static final long serialVersionUID = -8354537796750197427L;
15 15 private String name;
... ...
... ... @@ -9,7 +9,7 @@ import java.time.LocalDateTime;
9 9
10 10 @Data
11 11 @EqualsAndHashCode(callSuper = false)
12   -@TableName(ModelConstants.Table.ADMIN_SETTING_TABLE_NAME)
  12 +@TableName(ModelConstants.Table.SYS_ADMIN_SETTING_TABLE_NAME)
13 13 public class AdminSetting extends BaseEntity {
14 14
15 15 private static final long serialVersionUID = -881433375246560135L;
... ...
... ... @@ -16,7 +16,7 @@ import java.time.LocalDateTime;
16 16 */
17 17 @Data
18 18 @EqualsAndHashCode(callSuper = true)
19   -@TableName(ModelConstants.Table.IOTFS_ALARM_CONTACT_TABLE_NAME)
  19 +@TableName(ModelConstants.Table.TK_ALARM_CONTACT_TABLE_NAME)
20 20 public class AlarmContact extends TenantBaseEntity{
21 21
22 22 private static final long serialVersionUID= -3982884827995610164L;
... ...
... ... @@ -7,7 +7,7 @@ import org.thingsboard.server.common.data.yunteng.constant.ModelConstants;
7 7
8 8 @Data
9 9 @EqualsAndHashCode(callSuper = true)
10   -@TableName(ModelConstants.Table.IOTFS_ALARM_PROFILE_TABLE_NAME)
  10 +@TableName(ModelConstants.Table.TK_ALARM_PROFILE_TABLE_NAME)
11 11 public class AlarmProfile extends TenantBaseEntity {
12 12
13 13 private static final long serialVersionUID = -4922707705163155569L;
... ...
... ... @@ -14,7 +14,7 @@ import org.thingsboard.server.common.data.yunteng.enums.ActTypeEnum;
14 14 * @author Administrator
15 15 */
16 16 @EqualsAndHashCode(callSuper = true)
17   -@TableName(value = ModelConstants.Table.IOTFS_CONFIGURATION_ACT, autoResultMap = true)
  17 +@TableName(value = ModelConstants.Table.TK_CONFIGURATION_ACT, autoResultMap = true)
18 18 @Data
19 19 public class ConfigurationAct extends ConfigurationBaseEntity {
20 20 private static final long serialVersionUID = -4125982858197381343L;
... ...
... ... @@ -6,7 +6,7 @@ import lombok.EqualsAndHashCode;
6 6 import org.thingsboard.server.common.data.yunteng.constant.ModelConstants;
7 7
8 8 @EqualsAndHashCode(callSuper = true)
9   -@TableName(ModelConstants.Table.IOTFS_CONFIGURATION_CENTER_NAME)
  9 +@TableName(ModelConstants.Table.TK_CONFIGURATION_CENTER_NAME)
10 10 @Data
11 11 public class ConfigurationCenter extends TenantBaseEntity {
12 12 private static final long serialVersionUID = -7825135358032541445L;
... ...
... ... @@ -6,7 +6,7 @@ import lombok.EqualsAndHashCode;
6 6 import org.thingsboard.server.common.data.yunteng.constant.ModelConstants;
7 7
8 8 @EqualsAndHashCode(callSuper = true)
9   -@TableName(ModelConstants.Table.IOTFS_CONFIGURATION_CONTENT_NAME)
  9 +@TableName(ModelConstants.Table.TK_CONFIGURATION_CONTENT_NAME)
10 10 @Data
11 11 public class ConfigurationContent extends TenantBaseEntity {
12 12
... ...
... ... @@ -7,15 +7,12 @@ import com.fasterxml.jackson.databind.JsonNode;
7 7 import lombok.Data;
8 8 import lombok.EqualsAndHashCode;
9 9 import org.thingsboard.server.common.data.yunteng.constant.ModelConstants;
10   -import org.thingsboard.server.dao.yunteng.mapper.ListStringTypeHandler;
11   -
12   -import java.util.List;
13 10
14 11 /**
15 12 * @author Administrator
16 13 */
17 14 @EqualsAndHashCode(callSuper = true)
18   -@TableName(value = ModelConstants.Table.IOTFS_CONFIGURATION_DATASOURCE, autoResultMap = true)
  15 +@TableName(value = ModelConstants.Table.TK_CONFIGURATION_DATASOURCE, autoResultMap = true)
19 16 @Data
20 17 public class ConfigurationDatasource extends ConfigurationBaseEntity {
21 18 private static final long serialVersionUID = 2830393872646826226L;
... ...
... ... @@ -14,7 +14,7 @@ import org.thingsboard.server.common.data.yunteng.enums.EventTypeEnum;
14 14 * @author Administrator
15 15 */
16 16 @EqualsAndHashCode(callSuper = true)
17   -@TableName(value = ModelConstants.Table.IOTFS_CONFIGURATION_EVENT, autoResultMap = true)
  17 +@TableName(value = ModelConstants.Table.TK_CONFIGURATION_EVENT, autoResultMap = true)
18 18 @Data
19 19 public class ConfigurationEvent extends ConfigurationBaseEntity {
20 20 private static final long serialVersionUID = 4613503997176066996L;
... ...
... ... @@ -11,7 +11,7 @@ import org.thingsboard.server.common.data.yunteng.constant.ModelConstants;
11 11 import org.thingsboard.server.common.data.yunteng.enums.ViewType;
12 12
13 13 @EqualsAndHashCode(callSuper = true)
14   -@TableName(value = ModelConstants.Table.IOTFS_DATA_BOARD_NAME, autoResultMap = true)
  14 +@TableName(value = ModelConstants.Table.TK_DATA_BOARD_NAME, autoResultMap = true)
15 15 @Data
16 16 public class DataBoard extends TenantBaseEntity {
17 17
... ...
... ... @@ -10,7 +10,7 @@ import org.thingsboard.server.common.data.yunteng.constant.ModelConstants;
10 10
11 11 @Data
12 12 @EqualsAndHashCode(callSuper = true)
13   -@TableName(value = ModelConstants.Table.IOTFS_DATA_COMPONENT_NAME, autoResultMap = true)
  13 +@TableName(value = ModelConstants.Table.TK_DATA_COMPONENT_NAME, autoResultMap = true)
14 14 public class DataComponent extends TenantBaseEntity {
15 15
16 16 private static final long serialVersionUID = -1500982711916168023L;
... ...
... ... @@ -7,7 +7,7 @@ import org.thingsboard.server.common.data.yunteng.constant.ModelConstants;
7 7
8 8 @Data
9 9 @EqualsAndHashCode(callSuper = true)
10   -@TableName(ModelConstants.Table.IOTFS_DEVICE_TYPE_TABLE_NAME)
  10 +@TableName(ModelConstants.Table.TK_DEVICE_TYPE_TABLE_NAME)
11 11 public class DeviceType extends TenantBaseEntity {
12 12
13 13 private static final long serialVersionUID = -3777232331298040322L;
... ...
... ... @@ -3,7 +3,6 @@ package org.thingsboard.server.dao.yunteng.entities;
3 3 import com.baomidou.mybatisplus.annotation.TableField;
4 4 import com.baomidou.mybatisplus.annotation.TableName;
5 5 import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler;
6   -import com.fasterxml.jackson.annotation.JsonIgnore;
7 6 import com.fasterxml.jackson.databind.JsonNode;
8 7 import lombok.Data;
9 8 import lombok.EqualsAndHashCode;
... ... @@ -13,14 +12,13 @@ import org.thingsboard.server.common.data.yunteng.enums.ActionTypeEnum;
13 12 import org.thingsboard.server.common.data.yunteng.enums.ScopeEnum;
14 13 import org.thingsboard.server.dao.yunteng.mapper.ListStringTypeHandler;
15 14
16   -import java.util.Arrays;
17 15 import java.util.List;
18 16
19 17 /**
20 18 * @Description 执行动作 @Author cxy @Date 2021/11/24 17:24
21 19 */
22 20 @Data
23   -@TableName(value = ModelConstants.Table.IOTFS_DO_ACTION_TABLE_NAME, autoResultMap = true)
  21 +@TableName(value = ModelConstants.Table.TK_DO_ACTION_TABLE_NAME, autoResultMap = true)
24 22 @EqualsAndHashCode(callSuper = true)
25 23 public class DoAction extends TenantBaseEntity {
26 24
... ...
... ... @@ -6,21 +6,19 @@ import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler;
6 6 import lombok.Data;
7 7 import lombok.EqualsAndHashCode;
8 8 import org.apache.ibatis.type.EnumTypeHandler;
9   -import org.thingsboard.server.common.data.device.profile.AlarmCondition;
10 9 import org.thingsboard.server.common.data.device.profile.AlarmRule;
11 10 import org.thingsboard.server.common.data.yunteng.constant.ModelConstants;
12 11 import org.thingsboard.server.common.data.yunteng.enums.ScopeEnum;
13 12 import org.thingsboard.server.common.data.yunteng.enums.TriggerTypeEnum;
14 13 import org.thingsboard.server.dao.yunteng.mapper.ListStringTypeHandler;
15 14
16   -import java.util.Arrays;
17 15 import java.util.List;
18 16
19 17 /**
20 18 * @Description 执行条件实体表 @Author cxy @Date 2021/11/24 17:16
21 19 */
22 20 @Data
23   -@TableName(value = ModelConstants.Table.IOTFS_DO_CONDITION_TABLE_NAME, autoResultMap = true)
  21 +@TableName(value = ModelConstants.Table.TK_DO_CONDITION_TABLE_NAME, autoResultMap = true)
24 22 @EqualsAndHashCode(callSuper = true)
25 23 public class DoCondition extends TenantBaseEntity {
26 24 private static final long serialVersionUID = 2827674377416477646L;
... ...
... ... @@ -9,7 +9,7 @@ import java.time.LocalDateTime;
9 9
10 10 @Data
11 11 @EqualsAndHashCode(callSuper = true)
12   -@TableName(value = ModelConstants.Table.IOTFS_FRP_INFO_NAME, autoResultMap = true)
  12 +@TableName(value = ModelConstants.Table.TK_FRP_INFO_NAME, autoResultMap = true)
13 13 public class FrpInfo extends BaseEntity {
14 14
15 15 private static final long serialVersionUID = 970621268444886639L;
... ...
... ... @@ -12,7 +12,7 @@ import java.time.LocalDateTime;
12 12
13 13 @Data
14 14 @EqualsAndHashCode(callSuper = false)
15   -@TableName(value = ModelConstants.Table.MAIL_LOG_TABLE_NAME,autoResultMap = true)
  15 +@TableName(value = ModelConstants.Table.TK_MAIL_LOG_TABLE_NAME,autoResultMap = true)
16 16 public class MailLog extends BaseEntity {
17 17 private static final long serialVersionUID = -8847842025838559296L;
18 18
... ...
... ... @@ -11,7 +11,7 @@ import org.thingsboard.server.common.data.yunteng.enums.MenuTypeEnum;
11 11
12 12 @Data
13 13 @EqualsAndHashCode(callSuper = true)
14   -@TableName(ModelConstants.Table.MENU_TABLE_NAME)
  14 +@TableName(ModelConstants.Table.SYS_MENU_TABLE_NAME)
15 15 public class Menu extends TenantBaseEntity {
16 16
17 17 private static final long serialVersionUID = 6319718763792214142L;
... ...
... ... @@ -10,7 +10,7 @@ import org.thingsboard.server.common.data.yunteng.constant.ModelConstants;
10 10
11 11 @Data
12 12 @EqualsAndHashCode(callSuper = true)
13   -@TableName(value = ModelConstants.Table.MESSAGE_CONFIG_TABLE_NAME, autoResultMap = true)
  13 +@TableName(value = ModelConstants.Table.TK_MESSAGE_CONFIG_TABLE_NAME, autoResultMap = true)
14 14 public class MessageConfig extends TenantBaseEntity {
15 15
16 16 private static final long serialVersionUID = -3624943194108704138L;
... ...
... ... @@ -7,7 +7,7 @@ import org.thingsboard.server.common.data.yunteng.constant.ModelConstants;
7 7
8 8 @Data
9 9 @EqualsAndHashCode(callSuper = true)
10   -@TableName(ModelConstants.Table.MESSAGE_TEMPLATE_TABLE_NAME)
  10 +@TableName(ModelConstants.Table.TK_MESSAGE_TEMPLATE_TABLE_NAME)
11 11 public class MessageTemplate extends TenantBaseEntity {
12 12
13 13 private static final long serialVersionUID = 6347635507829273091L;
... ...
... ... @@ -9,7 +9,7 @@ import org.thingsboard.server.common.data.yunteng.constant.ModelConstants;
9 9
10 10 @Data
11 11 @EqualsAndHashCode(callSuper = true)
12   -@TableName(ModelConstants.Table.IOTFS_ORGANIZATION_TABLE_NAME)
  12 +@TableName(ModelConstants.Table.TK_ORGANIZATION_TABLE_NAME)
13 13 public class Organization extends TenantBaseEntity {
14 14
15 15 @TableField(updateStrategy = FieldStrategy.IGNORED)
... ...
... ... @@ -9,7 +9,7 @@ import org.thingsboard.server.common.data.yunteng.enums.RateLimitType;
9 9 import java.time.LocalTime;
10 10
11 11 @Data
12   -@TableName(ModelConstants.Table.RATE_LIMIT_TABLE_NAME)
  12 +@TableName(ModelConstants.Table.SYS_RATE_LIMIT_TABLE_NAME)
13 13 public class RateLimiterEntity {
14 14 private String id;
15 15 private String path;
... ...
... ... @@ -11,7 +11,7 @@ import org.thingsboard.server.common.data.yunteng.constant.ModelConstants;
11 11
12 12 @Data
13 13 @EqualsAndHashCode(callSuper = true)
14   -@TableName(value = ModelConstants.Table.IOTFS_REPORT_FORM_CONFIG_NAME, autoResultMap = true)
  14 +@TableName(value = ModelConstants.Table.TK_REPORT_FORM_CONFIG_NAME, autoResultMap = true)
15 15 public class ReportFormConfig extends TenantBaseEntity {
16 16
17 17 private static final long serialVersionUID = -1678849271872511953L;
... ...
... ... @@ -11,7 +11,7 @@ import java.time.LocalDateTime;
11 11
12 12 @Data
13 13 @EqualsAndHashCode(callSuper = true)
14   -@TableName(value = ModelConstants.Table.IOTFS_REPORT_GENERATE_RECORD_NAME, autoResultMap = true)
  14 +@TableName(value = ModelConstants.Table.TK_REPORT_GENERATE_RECORD_NAME, autoResultMap = true)
15 15 public class ReportGenerateRecord extends TenantBaseEntity {
16 16
17 17 /** 报表配置名称 */
... ...
... ... @@ -7,7 +7,7 @@ import org.thingsboard.server.common.data.yunteng.constant.ModelConstants;
7 7
8 8 @Data
9 9 @EqualsAndHashCode(callSuper = false)
10   -@TableName(ModelConstants.Table.ROLE_TABLE_NAME)
  10 +@TableName(ModelConstants.Table.SYS_ROLE_TABLE_NAME)
11 11 public class Role extends TenantBaseEntity {
12 12
13 13 private static final long serialVersionUID = 3915852360063998830L;
... ...
... ... @@ -6,7 +6,7 @@ import org.thingsboard.server.common.data.yunteng.constant.ModelConstants;
6 6
7 7 /** @Description 场景联动实体表 @Author cxy @Date 2021/11/24 16:40 */
8 8 @Data
9   -@TableName(value = ModelConstants.Table.IOTFS_SCENE_LINKAGE_TABLE_NAME)
  9 +@TableName(value = ModelConstants.Table.TK_SCENE_LINKAGE_TABLE_NAME)
10 10 @EqualsAndHashCode(callSuper = true)
11 11 public class SceneLinkage extends TenantBaseEntity {
12 12
... ...
... ... @@ -13,7 +13,7 @@ import java.time.LocalDateTime;
13 13
14 14 @Data
15 15 @EqualsAndHashCode(callSuper = false)
16   -@TableName(value = ModelConstants.Table.SMS_LOG_TABLE_NAME,autoResultMap = true)
  16 +@TableName(value = ModelConstants.Table.TK_SMS_LOG_TABLE_NAME,autoResultMap = true)
17 17 public class SmsLog extends BaseEntity {
18 18
19 19 private static final long serialVersionUID = 2778820322396894328L;
... ...
... ... @@ -7,7 +7,7 @@ import org.thingsboard.server.common.data.yunteng.constant.ModelConstants;
7 7
8 8 @Data
9 9 @EqualsAndHashCode(callSuper = true)
10   -@TableName(ModelConstants.Table.DEPT_TABLE_NAME)
  10 +@TableName(ModelConstants.Table.SYS_DEPT_TABLE_NAME)
11 11 public class SysDept extends TenantBaseEntity {
12 12
13 13
... ...
... ... @@ -7,7 +7,7 @@ import org.thingsboard.server.common.data.yunteng.constant.ModelConstants;
7 7
8 8 @Data
9 9 @EqualsAndHashCode(callSuper = false)
10   -@TableName(ModelConstants.Table.DICT_TABLE_NAME)
  10 +@TableName(ModelConstants.Table.SYS_DICT_TABLE_NAME)
11 11 public class SysDict extends TenantBaseEntity {
12 12
13 13 private static final long serialVersionUID = -5381101569947327544L;
... ...
... ... @@ -7,7 +7,7 @@ import org.thingsboard.server.common.data.yunteng.constant.ModelConstants;
7 7
8 8 @Data
9 9 @RequiredArgsConstructor
10   -@TableName(ModelConstants.Table.DICT_ITEM_TABLE_NAME)
  10 +@TableName(ModelConstants.Table.SYS_DICT_ITEM_TABLE_NAME)
11 11 public class SysDictItem extends TenantBaseEntity {
12 12
13 13 private static final long serialVersionUID = 9177617160310722864L;
... ...
... ... @@ -9,7 +9,7 @@ import org.thingsboard.server.common.data.yunteng.constant.ModelConstants;
9 9 /** 定时任务调度表 sys_job */
10 10 @Data
11 11 @EqualsAndHashCode(callSuper = true)
12   -@TableName(ModelConstants.Table.JOB_TABLE_NAME)
  12 +@TableName(ModelConstants.Table.SYS_JOB_TABLE_NAME)
13 13 public class SysJob extends TenantBaseEntity {
14 14
15 15 private static final long serialVersionUID = -5277603237529335023L;
... ...
... ... @@ -6,7 +6,6 @@ import lombok.EqualsAndHashCode;
6 6 import org.thingsboard.server.common.data.yunteng.constant.ModelConstants;
7 7
8 8 import java.time.LocalDateTime;
9   -import java.util.Date;
10 9
11 10 /**
12 11 * 定时任务调度日志表 sys_job_log
... ... @@ -14,7 +13,7 @@ import java.util.Date;
14 13 */
15 14 @Data
16 15 @EqualsAndHashCode(callSuper = true)
17   -@TableName(ModelConstants.Table.JOB_LOG_TABLE_NAME)
  16 +@TableName(ModelConstants.Table.SYS_JOB_LOG_TABLE_NAME)
18 17 public class SysJobLog extends BaseEntity {
19 18
20 19 private static final long serialVersionUID = 1739849551616104371L;
... ...
... ... @@ -9,7 +9,7 @@ import java.time.LocalDateTime;
9 9
10 10 @Data
11 11 @EqualsAndHashCode(callSuper = false)
12   -@TableName(ModelConstants.Table.TENANT_TABLE_NAME)
  12 +@TableName(ModelConstants.Table.SYS_TENANT_TABLE_NAME)
13 13 public class Tenant extends AuditRelatedEntity {
14 14
15 15 private static final long serialVersionUID = 4848421848961008112L;
... ...
... ... @@ -9,7 +9,7 @@ import java.io.Serializable;
9 9
10 10 @Data
11 11 @EqualsAndHashCode(callSuper = false)
12   -@TableName(ModelConstants.Table.TENANT_MENU_TABLE_NAME)
  12 +@TableName(ModelConstants.Table.SYS_TENANT_MENU_TABLE_NAME)
13 13 public class TenantMenu implements Serializable {
14 14 private static final long serialVersionUID = -8775371485677702427L;
15 15 /** 菜单ID */
... ...
... ... @@ -9,7 +9,7 @@ import java.io.Serializable;
9 9
10 10 @Data
11 11 @EqualsAndHashCode(callSuper = false)
12   -@TableName(ModelConstants.Table.TENANT_ROLE_TABLE_NAME)
  12 +@TableName(ModelConstants.Table.SYS_TENANT_ROLE_TABLE_NAME)
13 13 public class TenantRole implements Serializable {
14 14
15 15 private static final long serialVersionUID = 7332631758506821892L;
... ...
  1 +package org.thingsboard.server.dao.yunteng.entities;
  2 +
  3 +import com.baomidou.mybatisplus.annotation.TableField;
  4 +import com.baomidou.mybatisplus.annotation.TableName;
  5 +import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler;
  6 +import com.fasterxml.jackson.databind.JsonNode;
  7 +import lombok.Data;
  8 +import lombok.EqualsAndHashCode;
  9 +import org.apache.ibatis.type.EnumTypeHandler;
  10 +import org.thingsboard.server.common.data.yunteng.constant.ModelConstants;
  11 +import org.thingsboard.server.common.data.yunteng.enums.FunctionTypeEnum;
  12 +
  13 +@Data
  14 +@EqualsAndHashCode(callSuper = true)
  15 +@TableName(value = ModelConstants.Table.TK_THING_MODEL, autoResultMap = true)
  16 +public class ThingsModelEntity extends TenantBaseEntity {
  17 +
  18 + private static final long serialVersionUID = 2265006809255944302L;
  19 +
  20 + @TableField(typeHandler = EnumTypeHandler.class)
  21 + private FunctionTypeEnum functionType;
  22 +
  23 + private String functionName;
  24 + private String identifier;
  25 +
  26 + @TableField(typeHandler = JacksonTypeHandler.class)
  27 + private JsonNode functionJson;
  28 +
  29 + private String deviceProfileId;
  30 + private String remark;
  31 +}
... ...
... ... @@ -6,21 +6,19 @@ import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler;
6 6 import lombok.Data;
7 7 import lombok.EqualsAndHashCode;
8 8 import org.apache.ibatis.type.EnumTypeHandler;
9   -import org.thingsboard.server.common.data.device.profile.AlarmCondition;
10 9 import org.thingsboard.server.common.data.device.profile.AlarmRule;
11 10 import org.thingsboard.server.common.data.yunteng.constant.ModelConstants;
12 11 import org.thingsboard.server.common.data.yunteng.enums.ScopeEnum;
13 12 import org.thingsboard.server.common.data.yunteng.enums.TriggerTypeEnum;
14 13 import org.thingsboard.server.dao.yunteng.mapper.ListStringTypeHandler;
15 14
16   -import java.util.Arrays;
17 15 import java.util.List;
18 16
19 17 /**
20 18 * @Description 触发器实体表 @Author cxy @Date 2021/11/24 17:06
21 19 */
22 20 @Data
23   -@TableName(value = ModelConstants.Table.IOTFS_TRIGGER_TABLE_NAME, autoResultMap = true)
  21 +@TableName(value = ModelConstants.Table.TK_TRIGGER_TABLE_NAME, autoResultMap = true)
24 22 @EqualsAndHashCode(callSuper = true)
25 23 public class Trigger extends TenantBaseEntity {
26 24
... ...
... ... @@ -12,7 +12,7 @@ import java.time.LocalDateTime;
12 12 /** user是所有可登录系统用户 */
13 13 @Data
14 14 @EqualsAndHashCode(callSuper = false)
15   -@TableName(ModelConstants.Table.USER_TABLE_NAME)
  15 +@TableName(ModelConstants.Table.SYS_USER_TABLE_NAME)
16 16 public class User extends TenantBaseEntity {
17 17 private static final long serialVersionUID = 834982016421849497L;
18 18 private String username;
... ...
... ... @@ -9,7 +9,7 @@ import org.thingsboard.server.common.data.yunteng.constant.ModelConstants;
9 9 @Data
10 10 @AllArgsConstructor
11 11 @NoArgsConstructor
12   -@TableName(ModelConstants.Table.IOTFS_USER_ORGANIZATION_MAPPING_TABLE_NAME)
  12 +@TableName(ModelConstants.Table.TK_USER_ORGANIZATION_MAPPING_TABLE_NAME)
13 13 public class UserOrganizationMapping {
14 14 private String userId;
15 15 private String organizationId;
... ...
... ... @@ -9,7 +9,7 @@ import java.io.Serializable;
9 9
10 10 @Data
11 11 @EqualsAndHashCode(callSuper = false)
12   -@TableName(ModelConstants.Table.USER_ROLE_TABLE_NAME)
  12 +@TableName(ModelConstants.Table.SYS_USER_ROLE_TABLE_NAME)
13 13 public class UserRole implements Serializable {
14 14
15 15 private static final long serialVersionUID = -1018514294019250455L;
... ...
... ... @@ -12,10 +12,10 @@ import org.thingsboard.server.common.data.yunteng.enums.DeviceTypeEnum;
12 12
13 13 @Data
14 14 @EqualsAndHashCode(callSuper = true)
15   -@TableName(value = ModelConstants.Table.IOTFS_DEVICE_TABLE_NAME, autoResultMap = true)
  15 +@TableName(value = ModelConstants.Table.TK_DEVICE_TABLE_NAME, autoResultMap = true)
16 16 public class YtDevice 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;
... ...
... ... @@ -2,8 +2,6 @@ package org.thingsboard.server.dao.yunteng.entities;
2 2
3 3 import com.baomidou.mybatisplus.annotation.TableField;
4 4 import com.baomidou.mybatisplus.annotation.TableName;
5   -import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler;
6   -import com.fasterxml.jackson.databind.JsonNode;
7 5 import lombok.Data;
8 6 import lombok.EqualsAndHashCode;
9 7 import org.apache.ibatis.type.EnumTypeHandler;
... ... @@ -12,7 +10,7 @@ import org.thingsboard.server.common.data.yunteng.enums.DeviceTypeEnum;
12 10
13 11 @Data
14 12 @EqualsAndHashCode(callSuper = true)
15   -@TableName(value = ModelConstants.Table.IOTFS_DEVICE_PROFILE_TABLE_NAME, autoResultMap = true)
  13 +@TableName(value = ModelConstants.Table.TK_DEVICE_PROFILE_TABLE_NAME, autoResultMap = true)
16 14 public class YtDeviceProfileEntity extends TenantBaseEntity {
17 15 private String name;
18 16
... ...
... ... @@ -2,17 +2,14 @@ package org.thingsboard.server.dao.yunteng.entities;
2 2
3 3 import com.baomidou.mybatisplus.annotation.TableField;
4 4 import com.baomidou.mybatisplus.annotation.TableName;
5   -import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler;
6   -import com.fasterxml.jackson.databind.JsonNode;
7 5 import lombok.Data;
8 6 import lombok.EqualsAndHashCode;
9 7 import org.apache.ibatis.type.EnumTypeHandler;
10 8 import org.thingsboard.server.common.data.yunteng.constant.ModelConstants;
11   -import org.thingsboard.server.common.data.yunteng.enums.DeviceTypeEnum;
12 9 import org.thingsboard.server.common.data.yunteng.enums.TcpDataTypeEnum;
13 10
14 11 @Data
15   -@TableName(value = ModelConstants.Table.IOTFS_DEVICE_SCRIPT_TABLE_NAME, autoResultMap = true)
  12 +@TableName(value = ModelConstants.Table.TK_DEVICE_SCRIPT_TABLE_NAME, autoResultMap = true)
16 13 @EqualsAndHashCode(callSuper = true)
17 14 public class YtDeviceScriptEntity extends TenantBaseEntity {
18 15 private String name;
... ...
... ... @@ -10,7 +10,7 @@ import org.thingsboard.server.common.data.yunteng.constant.ModelConstants;
10 10 */
11 11 @Data
12 12 @EqualsAndHashCode(callSuper = true)
13   -@TableName(ModelConstants.Table.IOTFS_OPINION_TABLE_NAME)
  13 +@TableName(ModelConstants.Table.TK_OPINION_TABLE_NAME)
14 14 public class YtOpinionEntity extends TenantBaseEntity {
15 15
16 16 private static final long serialVersionUID = 7339240901373153647L;
... ...
1 1 package org.thingsboard.server.dao.yunteng.entities;
2 2
3 3 import com.baomidou.mybatisplus.annotation.TableName;
4   -import io.swagger.annotations.ApiModelProperty;
5 4 import lombok.Data;
6 5 import lombok.EqualsAndHashCode;
7 6 import org.thingsboard.server.common.data.yunteng.constant.ModelConstants;
8 7 import org.thingsboard.server.common.data.yunteng.enums.ThirdPlatformEnum;
9 8
10   -import javax.validation.constraints.NotEmpty;
11   -
12 9 /**
13 10 * @author Administrator
14 11 */
15 12 @Data
16 13 @EqualsAndHashCode(callSuper = true)
17   -@TableName(ModelConstants.Table.IOTFS_THIRD_USER_TABLE_NAME)
  14 +@TableName(ModelConstants.Table.TK_THIRD_USER_TABLE_NAME)
18 15 public class YtThirdUserEntity extends BaseEntity {
19 16
20 17 private ThirdPlatformEnum platformName;
... ...
1 1 package org.thingsboard.server.dao.yunteng.entities;
2 2
3 3 import com.baomidou.mybatisplus.annotation.TableName;
4   -import io.swagger.annotations.ApiModelProperty;
5 4 import lombok.Data;
6 5 import lombok.EqualsAndHashCode;
7 6 import org.thingsboard.server.common.data.yunteng.constant.ModelConstants;
8 7
9   -import javax.validation.constraints.NotEmpty;
10   -
11 8 /**
12 9 * @author Administrator
13 10 */
14 11 @Data
15 12 @EqualsAndHashCode(callSuper = true)
16   -@TableName(ModelConstants.Table.IOTFS_VIDEO_STREAM_TABLE_NAME)
  13 +@TableName(ModelConstants.Table.TK_VIDEO_STREAM_TABLE_NAME)
17 14 public class YtVideoEntity extends TenantBaseEntity {
18 15
19 16
... ...
... ... @@ -10,7 +10,7 @@ import org.thingsboard.server.common.data.yunteng.constant.ModelConstants;
10 10 */
11 11 @Data
12 12 @EqualsAndHashCode(callSuper = true)
13   -@TableName(ModelConstants.Table.IOTFS_VIDEO_PLATFORM_TABLE_NAME)
  13 +@TableName(ModelConstants.Table.TK_VIDEO_PLATFORM_TABLE_NAME)
14 14 public class YtVideoPlatformEntity extends TenantBaseEntity {
15 15
16 16
... ...
  1 +package org.thingsboard.server.dao.yunteng.impl;
  2 +
  3 +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
  4 +import com.baomidou.mybatisplus.core.metadata.IPage;
  5 +import com.fasterxml.jackson.databind.JsonNode;
  6 +import com.fasterxml.jackson.databind.node.ObjectNode;
  7 +import lombok.RequiredArgsConstructor;
  8 +import org.apache.commons.lang3.StringUtils;
  9 +import org.springframework.stereotype.Service;
  10 +import org.springframework.transaction.annotation.Transactional;
  11 +import org.thingsboard.server.common.data.yunteng.constant.FastIotConstants;
  12 +import org.thingsboard.server.common.data.yunteng.core.exception.YtDataValidationException;
  13 +import org.thingsboard.server.common.data.yunteng.core.message.ErrorMessage;
  14 +import org.thingsboard.server.common.data.yunteng.dto.DeleteDTO;
  15 +import org.thingsboard.server.common.data.yunteng.dto.DeviceProfileDTO;
  16 +import org.thingsboard.server.common.data.yunteng.dto.ThingsModelDTO;
  17 +import org.thingsboard.server.common.data.yunteng.enums.DeviceTypeEnum;
  18 +import org.thingsboard.server.common.data.yunteng.enums.FunctionTypeEnum;
  19 +import org.thingsboard.server.common.data.yunteng.utils.JacksonUtil;
  20 +import org.thingsboard.server.common.data.yunteng.utils.tools.YtPageData;
  21 +import org.thingsboard.server.dao.yunteng.entities.ThingsModelEntity;
  22 +import org.thingsboard.server.dao.yunteng.mapper.ThingsModelMapper;
  23 +import org.thingsboard.server.dao.yunteng.service.AbstractBaseService;
  24 +import org.thingsboard.server.dao.yunteng.service.ThingsModelService;
  25 +import org.thingsboard.server.dao.yunteng.service.YtDeviceProfileService;
  26 +
  27 +import java.util.*;
  28 +import java.util.stream.Collectors;
  29 +
  30 +@Service
  31 +@RequiredArgsConstructor
  32 +public class ThingsModelServiceImpl
  33 + extends AbstractBaseService<ThingsModelMapper, ThingsModelEntity>
  34 + implements ThingsModelService {
  35 + private final YtDeviceProfileService ytDeviceProfileService;
  36 +
  37 + @Override
  38 + public YtPageData<ThingsModelDTO> page(Map<String, Object> queryMap, String tenantId) {
  39 + String nameOrIdentifier =
  40 + null != queryMap.get("nameOrIdentifier") ? (String) queryMap.get("nameOrIdentifier") : null;
  41 + IPage<ThingsModelEntity> iPage =
  42 + baseMapper.selectPage(
  43 + getPage(queryMap, FastIotConstants.DefaultOrder.CREATE_TIME, false),
  44 + new LambdaQueryWrapper<ThingsModelEntity>()
  45 + .eq(ThingsModelEntity::getTenantId, tenantId)
  46 + .like(
  47 + StringUtils.isNotEmpty(nameOrIdentifier),
  48 + ThingsModelEntity::getFunctionName,
  49 + nameOrIdentifier)
  50 + .or()
  51 + .like(
  52 + StringUtils.isNotEmpty(nameOrIdentifier),
  53 + ThingsModelEntity::getIdentifier,
  54 + nameOrIdentifier));
  55 + return getPageData(iPage, ThingsModelDTO.class);
  56 + }
  57 +
  58 + @Override
  59 + @Transactional
  60 + public ThingsModelDTO saveOrUpdate(ThingsModelDTO thingsModelDTO) {
  61 + String thingsModelId = thingsModelDTO.getId();
  62 + boolean isAdd = StringUtils.isEmpty(thingsModelId);
  63 + if (checkIdentifier(
  64 + thingsModelDTO.getDeviceProfileId(),
  65 + thingsModelDTO.getIdentifier(),
  66 + isAdd,
  67 + thingsModelId)) {
  68 + throw new YtDataValidationException(ErrorMessage.DUPLICATE_IDENTIFIERS_EXIST.getMessage());
  69 + }
  70 + ThingsModelEntity entity = thingsModelDTO.getEntity(ThingsModelEntity.class);
  71 + if (isAdd) {
  72 + baseMapper.insert(entity);
  73 + thingsModelDTO.setId(entity.getId());
  74 + } else {
  75 + ThingsModelEntity result =
  76 + baseMapper.selectOne(
  77 + new LambdaQueryWrapper<ThingsModelEntity>()
  78 + .eq(ThingsModelEntity::getTenantId, thingsModelDTO.getTenantId())
  79 + .eq(ThingsModelEntity::getId, thingsModelDTO.getId()));
  80 + if (null == result) {
  81 + throw new YtDataValidationException(ErrorMessage.INVALID_PARAMETER.getMessage());
  82 + }
  83 + baseMapper.updateById(entity);
  84 + }
  85 + return thingsModelDTO;
  86 + }
  87 +
  88 + @Override
  89 + public ThingsModelDTO get(String id, String tenantId) {
  90 + ThingsModelEntity entity =
  91 + baseMapper.selectOne(
  92 + new LambdaQueryWrapper<ThingsModelEntity>()
  93 + .eq(ThingsModelEntity::getTenantId, tenantId)
  94 + .eq(ThingsModelEntity::getId, id));
  95 + return Optional.ofNullable(entity).map(obj -> obj.getDTO(ThingsModelDTO.class)).orElse(null);
  96 + }
  97 +
  98 + @Override
  99 + @Transactional
  100 + public boolean delete(DeleteDTO dto) {
  101 + int result =
  102 + baseMapper.delete(
  103 + new LambdaQueryWrapper<ThingsModelEntity>()
  104 + .eq(ThingsModelEntity::getTenantId, dto.getTenantId())
  105 + .in(ThingsModelEntity::getId, dto.getIds()));
  106 + if (result > FastIotConstants.MagicNumber.ZERO && result != dto.getIds().size()) {
  107 + throw new YtDataValidationException(ErrorMessage.INVALID_PARAMETER.getMessage());
  108 + }
  109 + return result > FastIotConstants.MagicNumber.ZERO;
  110 + }
  111 +
  112 + @Override
  113 + @Transactional
  114 + public boolean deleteByDeviceProfileId(String tenantId, String deviceProfileId) {
  115 + int result =
  116 + baseMapper.delete(
  117 + new LambdaQueryWrapper<ThingsModelEntity>()
  118 + .eq(ThingsModelEntity::getTenantId, tenantId)
  119 + .eq(ThingsModelEntity::getDeviceProfileId, deviceProfileId));
  120 + if (result == FastIotConstants.MagicNumber.ZERO) {
  121 + throw new YtDataValidationException(ErrorMessage.INVALID_PARAMETER.getMessage());
  122 + }
  123 + return true;
  124 + }
  125 +
  126 + @Override
  127 + public List<ThingsModelDTO> selectByDeviceProfileId(
  128 + FunctionTypeEnum typeEnum, String tenantId, String deviceProfileId) {
  129 + List<ThingsModelEntity> entityList =
  130 + baseMapper.selectList(
  131 + new LambdaQueryWrapper<ThingsModelEntity>()
  132 + .eq(ThingsModelEntity::getTenantId, tenantId)
  133 + .eq(ThingsModelEntity::getDeviceProfileId, deviceProfileId)
  134 + .eq(ThingsModelEntity::getFunctionType, typeEnum));
  135 + if (entityList.isEmpty()) {
  136 + throw new YtDataValidationException(ErrorMessage.INVALID_PARAMETER.getMessage());
  137 + }
  138 + return entityList.stream()
  139 + .map(obj -> obj.getDTO(ThingsModelDTO.class))
  140 + .collect(Collectors.toList());
  141 + }
  142 +
  143 + @Override
  144 + public JsonNode getTingsModelJson(
  145 + FunctionTypeEnum typeEnum, String tenantId, String deviceProfileId) {
  146 + JsonNode jsonNode = null;
  147 + DeviceProfileDTO deviceProfileDTO =
  148 + ytDeviceProfileService.findDeviceProfileById(tenantId, deviceProfileId);
  149 +
  150 + List<ThingsModelDTO> thingsModelDTOS =
  151 + selectByDeviceProfileId(typeEnum, tenantId, deviceProfileId);
  152 + if (deviceProfileDTO.getDeviceType().equals(DeviceTypeEnum.SENSOR)) {
  153 + if(typeEnum.equals(FunctionTypeEnum.properties)){
  154 + jsonNode = getSensorTSL(thingsModelDTOS);
  155 + }else if(typeEnum.equals(FunctionTypeEnum.services)){
  156 +
  157 + }
  158 + }
  159 + return jsonNode;
  160 + }
  161 +
  162 + /**
  163 + * 获取网关子设备的物模型TSL
  164 + *
  165 + * @param thingsModelDTOS
  166 + * @return
  167 + */
  168 + private JsonNode getSensorTSL(List<ThingsModelDTO> thingsModelDTOS) {
  169 + Map<String, List<ObjectNode>> attributeMap = new HashMap<>();
  170 + List<ObjectNode> list = new ArrayList<>();
  171 + for (ThingsModelDTO model : thingsModelDTOS) {
  172 + ObjectNode objectNode = JacksonUtil.newObjectNode();
  173 + objectNode.put(model.getIdentifier(), "value");
  174 + list.add(objectNode);
  175 + }
  176 + attributeMap.put("网关子设备名称", list);
  177 + return JacksonUtil.convertValue(attributeMap, JsonNode.class);
  178 + }
  179 +
  180 + private boolean checkIdentifier(
  181 + String deviceProfileId, String identifier, boolean isAdd, String thingsModelId) {
  182 + ThingsModelEntity entity =
  183 + baseMapper.selectOne(
  184 + new LambdaQueryWrapper<ThingsModelEntity>()
  185 + .eq(ThingsModelEntity::getDeviceProfileId, deviceProfileId)
  186 + .eq(ThingsModelEntity::getIdentifier, identifier));
  187 + return Optional.ofNullable(entity)
  188 + .map(
  189 + obj -> {
  190 + boolean result = false;
  191 + if (isAdd) {
  192 + result = true;
  193 + } else if (!entity.getId().equals(thingsModelId)) {
  194 + result = true;
  195 + }
  196 + return result;
  197 + })
  198 + .orElse(false);
  199 + }
  200 +}
... ...
... ... @@ -46,7 +46,7 @@ public class YtDeviceProfileServiceImpl
46 46 private final YtJpaDeviceProfileDao deviceProfileDao;
47 47
48 48 @Override
49   - public boolean validateFormdata(DeviceProfileDTO ytDeviceProfileDTO) {
  49 + public boolean validateFormData(DeviceProfileDTO ytDeviceProfileDTO) {
50 50 TenantId tenantId = TenantId.fromUUID(UUID.fromString(ytDeviceProfileDTO.getTenantId()));
51 51 if (StringUtils.isBlank(ytDeviceProfileDTO.getId())) {
52 52 // 判断数据库是否已存在名字相同的设备配置
... ... @@ -77,6 +77,17 @@ public class YtDeviceProfileServiceImpl
77 77 }
78 78
79 79 @Override
  80 + public DeviceProfileDTO findByTbDeviceProfileId(String tenantId, String tbProfileId) {
  81 + YtDeviceProfileEntity entity =
  82 + baseMapper.selectOne(
  83 + new LambdaQueryWrapper<YtDeviceProfileEntity>()
  84 + .eq(YtDeviceProfileEntity::getTenantId, tenantId)
  85 + .eq(YtDeviceProfileEntity::getTbProfileId, tbProfileId));
  86 +
  87 + return Optional.ofNullable(entity).map(obj -> obj.getDTO(DeviceProfileDTO.class)).orElse(null);
  88 + }
  89 +
  90 + @Override
80 91 @Transactional
81 92 public DeviceProfileDTO insertOrUpdate(DeviceProfileDTO deviceDTO) {
82 93 if (StringUtils.isBlank(deviceDTO.getId())) {
... ... @@ -169,7 +180,7 @@ public class YtDeviceProfileServiceImpl
169 180
170 181 @Override
171 182 public List<DeviceProfileDTO> findDeviceProfile(String tenantId, String scriptId) {
172   - List<DeviceProfileDTO> results = baseMapper.profileByScriptId(tenantId,scriptId);
  183 + List<DeviceProfileDTO> results = baseMapper.profileByScriptId(tenantId, scriptId);
173 184 return results;
174 185 }
175 186 }
... ...
... ... @@ -3,6 +3,7 @@ package org.thingsboard.server.dao.yunteng.impl;
3 3 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
4 4 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
5 5 import com.baomidou.mybatisplus.core.metadata.IPage;
  6 +import com.fasterxml.jackson.databind.JsonNode;
6 7 import lombok.RequiredArgsConstructor;
7 8 import lombok.extern.slf4j.Slf4j;
8 9 import org.apache.commons.lang3.StringUtils;
... ... @@ -18,11 +19,9 @@ import org.thingsboard.server.common.data.yunteng.constant.FastIotConstants;
18 19 import org.thingsboard.server.common.data.yunteng.constant.ModelConstants;
19 20 import org.thingsboard.server.common.data.yunteng.core.exception.YtDataValidationException;
20 21 import org.thingsboard.server.common.data.yunteng.core.message.ErrorMessage;
21   -import org.thingsboard.server.common.data.yunteng.dto.DeviceDTO;
22   -import org.thingsboard.server.common.data.yunteng.dto.OrganizationDTO;
23   -import org.thingsboard.server.common.data.yunteng.dto.RelationDeviceDTO;
24   -import org.thingsboard.server.common.data.yunteng.dto.SelectItemDTO;
  22 +import org.thingsboard.server.common.data.yunteng.dto.*;
25 23 import org.thingsboard.server.common.data.yunteng.enums.DeviceTypeEnum;
  24 +import org.thingsboard.server.common.data.yunteng.enums.FunctionTypeEnum;
26 25 import org.thingsboard.server.common.data.yunteng.enums.ScopeEnum;
27 26 import org.thingsboard.server.common.data.yunteng.utils.ReflectUtils;
28 27 import org.thingsboard.server.common.data.yunteng.utils.tools.YtPageData;
... ... @@ -30,6 +29,7 @@ import org.thingsboard.server.dao.device.DeviceProfileDao;
30 29 import org.thingsboard.server.dao.yunteng.entities.*;
31 30 import org.thingsboard.server.dao.yunteng.mapper.*;
32 31 import org.thingsboard.server.dao.yunteng.service.AbstractBaseService;
  32 +import org.thingsboard.server.dao.yunteng.service.ThingsModelService;
33 33 import org.thingsboard.server.dao.yunteng.service.YtDeviceService;
34 34
35 35 import java.time.LocalDateTime;
... ... @@ -49,6 +49,7 @@ public class YtDeviceServiceImpl extends AbstractBaseService<DeviceMapper, YtDev
49 49 private final TriggerMapper triggerMapper;
50 50 private final DoConditionMapper conditionMapper;
51 51 private final DoActionMapper actionMapper;
  52 + private final ThingsModelService thingsModelService;
52 53
53 54 @Override
54 55 @Transactional
... ... @@ -88,9 +89,9 @@ public class YtDeviceServiceImpl extends AbstractBaseService<DeviceMapper, YtDev
88 89 }
89 90
90 91 @Override
91   - public void validateFormdata(String currentTenantId, DeviceDTO deviceDTO) {
  92 + public void validateFormData(String currentTenantId, DeviceDTO deviceDTO) {
92 93 boolean insert = StringUtils.isBlank(deviceDTO.getId());
93   - String deviceTenantId = deviceDTO.getTenantId();
  94 + String deviceTenantId;
94 95 if (StringUtils.isBlank(deviceDTO.getName())) {
95 96 throw new YtDataValidationException("设备名称不能为空");
96 97 }
... ... @@ -100,7 +101,7 @@ public class YtDeviceServiceImpl extends AbstractBaseService<DeviceMapper, YtDev
100 101 }
101 102
102 103 // 验证设备名称是否已经存在 如果此处直接使用deviceDTO 将有误
103   - if (deviceNameUsed(currentTenantId, deviceDTO.getName(),deviceDTO.getId())) {
  104 + if (deviceNameUsed(currentTenantId, deviceDTO.getName(), deviceDTO.getId())) {
104 105 throw new YtDataValidationException(ErrorMessage.NAME_ALREADY_EXISTS.getMessage());
105 106 }
106 107 if (insert) {
... ... @@ -141,7 +142,7 @@ public class YtDeviceServiceImpl extends AbstractBaseService<DeviceMapper, YtDev
141 142 * @return
142 143 */
143 144 private boolean sceneNotUsed(String tenantId, String tbDeviceId, String organizationId) {
144   - boolean result = true;
  145 + boolean result = false;
145 146 /** 激活的场景联动使用了设备,例如:触发器、自行条件、动作等。 */
146 147 List<SceneLinkage> scenes =
147 148 sceneLinkageMapper.selectList(
... ... @@ -153,55 +154,56 @@ public class YtDeviceServiceImpl extends AbstractBaseService<DeviceMapper, YtDev
153 154 SceneLinkage::getOrganizationId,
154 155 organizationId));
155 156 if (scenes == null || scenes.isEmpty()) {
156   - return true;
157   - }
158   - Set<String> sceneNames = new HashSet<>();
159   - for (SceneLinkage scene : scenes) {
160   - List<Trigger> triggers =
161   - triggerMapper.selectList(
162   - new QueryWrapper<Trigger>()
163   - .lambda()
164   - .eq(Trigger::getSceneLinkageId, scene.getId())
165   - .eq(
166   - scene.getStatus() == FastIotConstants.StateValue.DISABLE,
167   - Trigger::getTriggerType,
168   - ScopeEnum.PART)
169   - .like(Trigger::getEntityId, tbDeviceId));
170   - if (triggers != null && triggers.size() > 0) {
171   - sceneNames.add(scene.getName());
172   - }
173   - List<DoCondition> conditions =
174   - conditionMapper.selectList(
175   - new QueryWrapper<DoCondition>()
176   - .lambda()
177   - .eq(DoCondition::getSceneLinkageId, scene.getId())
178   - .eq(
179   - scene.getStatus() == FastIotConstants.StateValue.DISABLE,
180   - DoCondition::getEntityType,
181   - ScopeEnum.PART)
182   - .like(DoCondition::getEntityId, tbDeviceId));
183   - if (conditions != null && conditions.size() > 0) {
184   - sceneNames.add(scene.getName());
  157 + result = true;
  158 + } else {
  159 +
  160 + Set<String> sceneNames = new HashSet<>();
  161 + for (SceneLinkage scene : scenes) {
  162 + List<Trigger> triggers =
  163 + triggerMapper.selectList(
  164 + new QueryWrapper<Trigger>()
  165 + .lambda()
  166 + .eq(Trigger::getSceneLinkageId, scene.getId())
  167 + .eq(
  168 + scene.getStatus() == FastIotConstants.StateValue.DISABLE,
  169 + Trigger::getTriggerType,
  170 + ScopeEnum.PART)
  171 + .like(Trigger::getEntityId, tbDeviceId));
  172 + if (triggers != null && triggers.size() > 0) {
  173 + sceneNames.add(scene.getName());
  174 + }
  175 + List<DoCondition> conditions =
  176 + conditionMapper.selectList(
  177 + new QueryWrapper<DoCondition>()
  178 + .lambda()
  179 + .eq(DoCondition::getSceneLinkageId, scene.getId())
  180 + .eq(
  181 + scene.getStatus() == FastIotConstants.StateValue.DISABLE,
  182 + DoCondition::getEntityType,
  183 + ScopeEnum.PART)
  184 + .like(DoCondition::getEntityId, tbDeviceId));
  185 + if (conditions != null && conditions.size() > 0) {
  186 + sceneNames.add(scene.getName());
  187 + }
  188 + List<DoAction> actions =
  189 + actionMapper.selectList(
  190 + new QueryWrapper<DoAction>()
  191 + .lambda()
  192 + .eq(DoAction::getSceneLinkageId, scene.getId())
  193 + .eq(
  194 + scene.getStatus() == FastIotConstants.StateValue.DISABLE,
  195 + DoAction::getEntityType,
  196 + ScopeEnum.PART)
  197 + .like(DoAction::getDeviceId, tbDeviceId));
  198 + if (actions != null && actions.size() > 0) {
  199 + sceneNames.add(scene.getName());
  200 + }
185 201 }
186   - List<DoAction> actions =
187   - actionMapper.selectList(
188   - new QueryWrapper<DoAction>()
189   - .lambda()
190   - .eq(DoAction::getSceneLinkageId, scene.getId())
191   - .eq(
192   - scene.getStatus() == FastIotConstants.StateValue.DISABLE,
193   - DoAction::getEntityType,
194   - ScopeEnum.PART)
195   - .like(DoAction::getDeviceId, tbDeviceId));
196   - if (actions != null && actions.size() > 0) {
197   - sceneNames.add(scene.getName());
  202 + if (sceneNames.size() > 0) {
  203 + throw new YtDataValidationException(
  204 + String.format(ErrorMessage.DEVICE_USED_SCENE_REACT.getMessage(), sceneNames));
198 205 }
199 206 }
200   - if (sceneNames.size() > 0) {
201   - throw new YtDataValidationException(
202   - String.format(ErrorMessage.DEVICE_USED_SCENE_REACT.getMessage(), sceneNames));
203   - }
204   -
205 207 return result;
206 208 }
207 209
... ... @@ -243,16 +245,16 @@ public class YtDeviceServiceImpl extends AbstractBaseService<DeviceMapper, YtDev
243 245
244 246 @Override
245 247 public List<DeviceDTO> findDevicesByDeviceTypeAndOrganizationId(
246   - DeviceTypeEnum deviceType, String tenantId, String organizationId,String deviceLabel) {
  248 + DeviceTypeEnum deviceType, String tenantId, String organizationId, String deviceLabel) {
247 249 List<String> orgIds = organizationAllIds(tenantId, organizationId);
248   - if(orgIds.isEmpty()){
  250 + if (orgIds.isEmpty()) {
249 251 throw new YtDataValidationException(ErrorMessage.ORGANIZATION_NOT_EXTIED.getMessage());
250 252 }
251 253 return ReflectUtils.sourceToTarget(
252 254 baseMapper.selectList(
253 255 new LambdaQueryWrapper<YtDevice>()
254   - .eq(deviceType != null,YtDevice::getDeviceType, deviceType)
255   - .eq(deviceLabel != null,YtDevice::getLabel, deviceLabel)
  256 + .eq(deviceType != null, YtDevice::getDeviceType, deviceType)
  257 + .eq(deviceLabel != null, YtDevice::getLabel, deviceLabel)
256 258 .in(YtDevice::getOrganizationId, orgIds)),
257 259 DeviceDTO.class);
258 260 }
... ... @@ -262,7 +264,7 @@ public class YtDeviceServiceImpl extends AbstractBaseService<DeviceMapper, YtDev
262 264 if (StringUtils.isEmpty(tenantId) || StringUtils.isEmpty(deviceId)) {
263 265 throw new YtDataValidationException(ErrorMessage.INVALID_PARAMETER.getMessage());
264 266 }
265   - return baseMapper.selectDetail(tenantId,deviceId);
  267 + return baseMapper.selectDetail(tenantId, deviceId);
266 268 }
267 269
268 270 @Override
... ... @@ -333,22 +335,18 @@ public class YtDeviceServiceImpl extends AbstractBaseService<DeviceMapper, YtDev
333 335 *
334 336 * @param tenantId 租户ID
335 337 * @param organizationId 组织ID
336   - * @return
337 338 */
338 339 @NotNull
339 340 private List<String> organizationAllIds(String tenantId, String organizationId) {
340 341 List<String> organizationIds = new ArrayList<>();
341   - if(!StringUtils.isEmpty(organizationId)){
  342 + if (!StringUtils.isEmpty(organizationId)) {
342 343 organizationIds.add(organizationId);
343 344 }
344 345 // 查询该组织的所有子类
345 346 List<OrganizationDTO> organizationDTOS =
346 347 ytOrganizationMapper.findOrganizationTreeList(tenantId, organizationIds);
347 348 List<String> queryOrganizationIds = new ArrayList<>();
348   - organizationDTOS.forEach(
349   - item -> {
350   - queryOrganizationIds.add(item.getId());
351   - });
  349 + organizationDTOS.forEach(item -> queryOrganizationIds.add(item.getId()));
352 350 return queryOrganizationIds;
353 351 }
354 352
... ... @@ -361,16 +359,16 @@ public class YtDeviceServiceImpl extends AbstractBaseService<DeviceMapper, YtDev
361 359 }
362 360
363 361 @Override
364   - public boolean deviceNameUsed(String tenantId, String deviceName,String deviceId) {
  362 + public boolean deviceNameUsed(String tenantId, String deviceName, String deviceId) {
365 363 List<YtDevice> deviceList =
366   - baseMapper.selectList(new QueryWrapper<YtDevice>()
  364 + baseMapper.selectList(
  365 + new QueryWrapper<YtDevice>()
367 366 .lambda()
368 367 .eq(true, YtDevice::getTenantId, tenantId)
369   - .eq(YtDevice::getName,deviceName));
370   - for(YtDevice dev: deviceList){
371   - if(deviceName.equals(dev.getName())
372   - && (StringUtils.isEmpty(deviceId) || !deviceId.equals(dev.getId()))
373   - ){
  368 + .eq(YtDevice::getName, deviceName));
  369 + for (YtDevice dev : deviceList) {
  370 + if (deviceName.equals(dev.getName())
  371 + && (StringUtils.isEmpty(deviceId) || !deviceId.equals(dev.getId()))) {
374 372 return true;
375 373 }
376 374 }
... ... @@ -423,17 +421,14 @@ public class YtDeviceServiceImpl extends AbstractBaseService<DeviceMapper, YtDev
423 421 }
424 422 Set<String> usedIds = new HashSet<>();
425 423 List<String> scenFilterIds =
426   - scenes.get().stream().map(i -> i.getId()).collect(Collectors.toList());
  424 + scenes.get().stream().map(BaseEntity::getId).collect(Collectors.toList());
427 425 LambdaQueryWrapper<Trigger> triggerFilter =
428 426 new QueryWrapper<Trigger>()
429 427 .lambda()
430 428 .in(scenFilterIds.size() > 0, Trigger::getSceneLinkageId, scenFilterIds)
431 429 .like(Trigger::getEntityId, tbDeviceId);
432 430 List<Trigger> triggers = triggerMapper.selectList(triggerFilter);
433   - triggers.forEach(
434   - item -> {
435   - usedIds.add(item.getSceneLinkageId());
436   - });
  431 + triggers.forEach(item -> usedIds.add(item.getSceneLinkageId()));
437 432
438 433 LambdaQueryWrapper<DoCondition> conditionFilter =
439 434 new QueryWrapper<DoCondition>()
... ... @@ -441,10 +436,7 @@ public class YtDeviceServiceImpl extends AbstractBaseService<DeviceMapper, YtDev
441 436 .in(scenFilterIds.size() > 0, DoCondition::getSceneLinkageId, scenFilterIds)
442 437 .eq(DoCondition::getEntityId, tbDeviceId);
443 438 List<DoCondition> doConditions = conditionMapper.selectList(conditionFilter);
444   - doConditions.forEach(
445   - item -> {
446   - usedIds.add(item.getSceneLinkageId());
447   - });
  439 + doConditions.forEach(item -> usedIds.add(item.getSceneLinkageId()));
448 440
449 441 LambdaQueryWrapper<DoAction> actionFilter =
450 442 new QueryWrapper<DoAction>()
... ... @@ -452,10 +444,7 @@ public class YtDeviceServiceImpl extends AbstractBaseService<DeviceMapper, YtDev
452 444 .in(scenFilterIds.size() > 0, DoAction::getSceneLinkageId, scenFilterIds)
453 445 .eq(DoAction::getDeviceId, tbDeviceId);
454 446 List<DoAction> doActions = actionMapper.selectList(actionFilter);
455   - doActions.forEach(
456   - item -> {
457   - usedIds.add(item.getSceneLinkageId());
458   - });
  447 + doActions.forEach(item -> usedIds.add(item.getSceneLinkageId()));
459 448
460 449 if (usedIds.isEmpty()) {
461 450 return "";
... ... @@ -463,7 +452,7 @@ public class YtDeviceServiceImpl extends AbstractBaseService<DeviceMapper, YtDev
463 452 StringBuilder result = new StringBuilder();
464 453 for (SceneLinkage item : scenes.get()) {
465 454 if (usedIds.contains(item.getId())) {
466   - result.append("," + item.getName());
  455 + result.append(",").append(item.getName());
467 456 }
468 457 }
469 458 return String.format(ErrorMessage.DEVICE_USED_SCENE_REACT.getMessage(), result.substring(1));
... ... @@ -473,30 +462,26 @@ public class YtDeviceServiceImpl extends AbstractBaseService<DeviceMapper, YtDev
473 462 public List<SelectItemDTO> findMasterDevices(
474 463 String tenantId, String customerId, String organizationId) {
475 464 List<String> orgIds = organizationAllIds(tenantId, organizationId);
476   - List<SelectItemDTO> result = baseMapper.masterDevices(customerId, tenantId, orgIds);
477   - return result;
  465 + return baseMapper.masterDevices(customerId, tenantId, orgIds);
478 466 }
479 467
480 468 @Override
481 469 public List<SelectItemDTO> findSlaveDevices(
482 470 String masterId, String tenantId, String customerId, String organizationId) {
483 471 List<String> orgIds = organizationAllIds(tenantId, organizationId);
484   - List<SelectItemDTO> result = baseMapper.slaveDevices(customerId, tenantId, orgIds, masterId);
485   - return result;
  472 + return baseMapper.slaveDevices(customerId, tenantId, orgIds, masterId);
486 473 }
487 474
488   -
489 475 @Override
490 476 public DeviceDTO findSlaveDevice(String tenantId, String masterId, String deviceCode) {
491   - return baseMapper.slaveDevice(tenantId,masterId,deviceCode);
  477 + return baseMapper.slaveDevice(tenantId, masterId, deviceCode);
492 478 }
493 479
494 480 @Override
495 481 public List<String> findDeviceKeys(
496 482 String tenantId, String customerId, String organizationId, List<String> deviceIds) {
497 483 List<String> orgIds = organizationAllIds(tenantId, organizationId);
498   - List<String> result = baseMapper.findDeviceKeys(tenantId, customerId, orgIds, deviceIds);
499   - return result;
  484 + return baseMapper.findDeviceKeys(tenantId, customerId, orgIds, deviceIds);
500 485 }
501 486
502 487 @Override
... ... @@ -537,8 +522,43 @@ public class YtDeviceServiceImpl extends AbstractBaseService<DeviceMapper, YtDev
537 522 new LambdaQueryWrapper<YtDevice>()
538 523 .eq(YtDevice::getTbDeviceId, tbDeviceId)
539 524 .eq(YtDevice::getTenantId, tenantId));
540   - return Optional.ofNullable(device).map(obj -> obj.getDTO(DeviceDTO.class)).orElseThrow(()->{
541   - throw new YtDataValidationException(ErrorMessage.INVALID_PARAMETER.getMessage());
542   - });
  525 + return Optional.ofNullable(device)
  526 + .map(obj -> obj.getDTO(DeviceDTO.class))
  527 + .orElseThrow(
  528 + () -> {
  529 + throw new YtDataValidationException(ErrorMessage.INVALID_PARAMETER.getMessage());
  530 + });
  531 + }
  532 +
  533 + @Override
  534 + public JsonNode getDeviceAttributes(String tbProfileId,String profileId, String id, String tenantId) {
  535 + return getDevice(tenantId, id)
  536 + .map(
  537 + obj -> {
  538 + if (obj.getProfileId().equals(tbProfileId)) {
  539 + JsonNode jsonNode = null;
  540 + List<ThingsModelDTO> thingsModel =
  541 + thingsModelService.selectByDeviceProfileId(
  542 + FunctionTypeEnum.properties, tenantId, profileId);
  543 + if (!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);
  553 + }
  554 + return jsonNode;
  555 + } else {
  556 + throw new YtDataValidationException(ErrorMessage.INVALID_PARAMETER.getMessage());
  557 + }
  558 + })
  559 + .orElseThrow(
  560 + () -> {
  561 + throw new YtDataValidationException(ErrorMessage.INVALID_PARAMETER.getMessage());
  562 + });
543 563 }
544 564 }
... ...
... ... @@ -11,11 +11,10 @@ import org.thingsboard.server.dao.util.mapping.JsonBinaryType;
11 11 import org.thingsboard.server.dao.util.mapping.JsonStringType;
12 12
13 13 import javax.persistence.*;
14   -import java.util.UUID;
15 14
16 15 @Data
17 16 @Entity
18   -@Table(name = ModelConstants.Table.IOTFS_DEVICE_TABLE_NAME)
  17 +@Table(name = ModelConstants.Table.TK_DEVICE_TABLE_NAME)
19 18 @TypeDefs({
20 19 @TypeDef(name = "json", typeClass = JsonStringType.class),
21 20 @TypeDef(name = "jsonb", typeClass = JsonBinaryType.class)
... ...
  1 +package org.thingsboard.server.dao.yunteng.mapper;
  2 +
  3 +import com.baomidou.mybatisplus.core.mapper.BaseMapper;
  4 +import org.apache.ibatis.annotations.Mapper;
  5 +import org.thingsboard.server.dao.yunteng.entities.ThingsModelEntity;
  6 +
  7 +@Mapper
  8 +public interface ThingsModelMapper extends BaseMapper<ThingsModelEntity> {}
... ...
  1 +package org.thingsboard.server.dao.yunteng.service;
  2 +
  3 +import com.fasterxml.jackson.databind.JsonNode;
  4 +import org.thingsboard.server.common.data.yunteng.dto.DeleteDTO;
  5 +import org.thingsboard.server.common.data.yunteng.dto.ThingsModelDTO;
  6 +import org.thingsboard.server.common.data.yunteng.enums.FunctionTypeEnum;
  7 +import org.thingsboard.server.common.data.yunteng.utils.tools.YtPageData;
  8 +
  9 +import java.util.List;
  10 +import java.util.Map;
  11 +
  12 +public interface ThingsModelService {
  13 + YtPageData<ThingsModelDTO> page(Map<String, Object> queryMap, String tenantId);
  14 +
  15 + ThingsModelDTO saveOrUpdate(ThingsModelDTO thingsModelDTO);
  16 +
  17 + ThingsModelDTO get(String id, String tenantId);
  18 +
  19 + boolean delete(DeleteDTO dto);
  20 +
  21 + boolean deleteByDeviceProfileId(String tenantId, String deviceProfileId);
  22 +
  23 + List<ThingsModelDTO> selectByDeviceProfileId(
  24 + FunctionTypeEnum typeEnum, String tenantId, String deviceProfileId);
  25 +
  26 + JsonNode getTingsModelJson(FunctionTypeEnum typeEnum, String tenantId, String deviceProfileId);
  27 +}
... ...
... ... @@ -27,16 +27,22 @@ public interface YtDeviceProfileService {
27 27 /**
28 28 * 验证表单数据有效性
29 29 *
30   - * @param ytDeviceProfileDTO
31   - * @return
32 30 */
33   - boolean validateFormdata(DeviceProfileDTO ytDeviceProfileDTO);
  31 + boolean validateFormData(DeviceProfileDTO ytDeviceProfileDTO);
34 32
35 33 /**
36   - * 根据设备配置ID或者设备配置信息
  34 + * 根据设备配置ID获取设备配置信息
37 35 * @param tenantId 租户ID
38 36 * @param id 设备配置ID
39 37 * @return 设备配置信息
40 38 */
41 39 DeviceProfileDTO findDeviceProfileById(String tenantId, String id);
  40 +
  41 + /**
  42 + * *根据tb设备ID获取设备配置信息
  43 + * @param tenantId 租户ID
  44 + * @param tbProfileId tb设备配置ID
  45 + * @return 设备配置信息
  46 + */
  47 + DeviceProfileDTO findByTbDeviceProfileId(String tenantId,String tbProfileId);
42 48 }
... ...
1 1 package org.thingsboard.server.dao.yunteng.service;
2 2
  3 +import com.fasterxml.jackson.databind.JsonNode;
3 4 import org.thingsboard.server.common.data.id.EntityId;
4 5 import org.thingsboard.server.common.data.yunteng.dto.DeviceDTO;
5 6 import org.thingsboard.server.common.data.yunteng.dto.RelationDeviceDTO;
... ... @@ -29,7 +30,7 @@ public interface YtDeviceService extends BaseService<YtDevice> {
29 30 *
30 31 * @param ytDevice
31 32 */
32   - void validateFormdata(String currentTenantId, DeviceDTO ytDevice);
  33 + void validateFormData(String currentTenantId, DeviceDTO ytDevice);
33 34
34 35 /**
35 36 * 查询所有的设备信息
... ... @@ -162,10 +163,20 @@ public interface YtDeviceService extends BaseService<YtDevice> {
162 163
163 164 /**
164 165 * 通过tb设备ID获取平台设备信息
165   - * @param tenantId
166   - * @param tbDeviceId
167   - * @return
  166 + * @param tenantId 租户ID
  167 + * @param tbDeviceId tb设备ID
  168 + * @return 设备信息
168 169 */
169 170 DeviceDTO getSubsetDeviceByTbDeviceId(String tenantId,String tbDeviceId);
170 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 +
171 182 }
... ...
... ... @@ -29,8 +29,8 @@
29 29 <select id="getAlarmPage" resultMap="alarmContactMap">
30 30 SELECT
31 31 <include refid="columns"/>
32   - FROM iotfs_alarm_contact a
33   - LEFT JOIN iotfs_organization io ON io.id = a.organization_id
  32 + FROM tk_alarm_contact a
  33 + LEFT JOIN tk_organization io ON io.id = a.organization_id
34 34 <where>
35 35 <if test="queryMap.tenantId !=null and queryMap.tenantId !=''">
36 36 AND a.tenant_id = #{queryMap.tenantId}
... ...
... ... @@ -24,8 +24,8 @@
24 24 <select id="getAlarmProfilePage" resultMap="alarmProfileMap">
25 25 SELECT
26 26 <include refid="columns"/>
27   - FROM iotfs_alarm_profile a
28   - LEFT JOIN iotfs_organization io ON io.id = a.organization_id
  27 + FROM tk_alarm_profile a
  28 + LEFT JOIN tk_organization io ON io.id = a.organization_id
29 29 <where>
30 30 a.tenant_id = #{tenantId}
31 31 <if test="queryMap.name !=null and queryMap.name !=''">
... ...
... ... @@ -35,8 +35,8 @@
35 35 <select id="getConfigurationCenterPage" resultMap="configurationCenterMap">
36 36 SELECT
37 37 <include refid="columns"/>
38   - FROM iotfs_configuration_center a
39   - LEFT JOIN iotfs_organization io ON io.id = a.organization_id
  38 + FROM tk_configuration_center a
  39 + LEFT JOIN tk_organization io ON io.id = a.organization_id
40 40 <where>
41 41 <if test="queryMap.tenantId !=null and queryMap.tenantId !=''">
42 42 AND a.tenant_id = #{queryMap.tenantId}
... ... @@ -57,8 +57,8 @@
57 57 </select>
58 58
59 59 <select id="getConfigurationInfoById" resultMap="configurationInfoMap">
60   - SELECT icc.id,icc.name,icc.platform,icc.thumbnail,icct.id AS content_id,icct.content FROM iotfs_configuration_center icc LEFT JOIN
61   - iotfs_configuration_content icct ON icc.id = icct.configuration_id
  60 + SELECT icc.id,icc.name,icc.platform,icc.thumbnail,icct.id AS content_id,icct.content FROM tk_configuration_center icc LEFT JOIN
  61 + tk_configuration_content icct ON icc.id = icct.configuration_id
62 62 WHERE icc.id = #{id} AND icc.tenant_id = #{tenantId}
63 63 </select>
64 64 </mapper>
... ...
... ... @@ -18,7 +18,7 @@
18 18 <result property="remark" column="remark"/>
19 19 </resultMap>
20 20 <update id="updateConvertStatusByIds">
21   - UPDATE iotfs_convert_config
  21 + UPDATE tk_convert_config
22 22 SET status =#{status}
23 23 <where>
24 24 tenant_id = #{tenantId}
... ...
... ... @@ -14,7 +14,7 @@
14 14 <result property="remark" column="remark"/>
15 15 </resultMap>
16 16 <update id="updateDataBoardComponentNum">
17   - UPDATE iotfs_data_board
  17 + UPDATE tk_data_board
18 18 SET component_num =#{count}
19 19 <where>
20 20 id = #{id}
... ...
... ... @@ -10,6 +10,7 @@
10 10 <resultMap type="org.thingsboard.server.common.data.yunteng.dto.DeviceDTO" id="deviceMap">
11 11 <result property="id" column="id"/>
12 12 <result property="name" column="name"/>
  13 + <result property="alias" column="alias"/>
13 14 <result property="deviceInfo" column="device_info"
14 15 typeHandler="com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler"/>
15 16 <result property="profileId" column="profile_id"/>
... ... @@ -62,7 +63,7 @@
62 63
63 64 <sql id="basicColumns">
64 65 ifd.id
65   - ,ifd.sn,ifd.brand,ifd.name,ifd.device_info,ifd.profile_id,ifd.active_time,ifd.tenant_id,ifd.description
  66 + ,ifd.sn,ifd.brand,ifd.name,ifd.alias,ifd.device_info,ifd.profile_id,ifd.active_time,ifd.tenant_id,ifd.description
66 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,
67 68 ifd.updater,ifd.organization_id,ifd.alarm_status
68 69 </sql>
... ... @@ -79,9 +80,9 @@
79 80 <select id="getDevicePage" resultMap="deviceMap">
80 81 SELECT
81 82 <include refid="pageColumns"/>,d.customer_id::TEXT AS customer_id,cus.title AS cusotomer_name
82   - FROM iotfs_device ifd
  83 + FROM tk_device ifd
83 84 LEFT JOIN device_profile ifdp ON ifd.profile_id = ifdp.id::TEXT
84   - LEFT JOIN iotfs_organization io ON io.id = ifd.organization_id
  85 + LEFT JOIN tk_organization io ON io.id = ifd.organization_id
85 86 LEFT JOIN attribute_kv a ON ifd.tb_device_id = a.entity_id::TEXT AND a.entity_type ='DEVICE' AND a.attribute_key='active'
86 87 LEFT JOIN attribute_kv b ON ifd.tb_device_id = b.entity_id::TEXT AND b.entity_type ='DEVICE' AND b.attribute_key='lastActivityTime'
87 88 LEFT JOIN attribute_kv c ON ifd.tb_device_id = c.entity_id::TEXT AND c.entity_type ='DEVICE' AND c.attribute_key='lastDisconnectTime'
... ... @@ -131,15 +132,15 @@
131 132 <select id="selectDetail" resultMap="deviceMap">
132 133 SELECT
133 134 <include refid="detailColumns"/>
134   - FROM iotfs_device ifd
  135 + FROM tk_device ifd
135 136 LEFT JOIN device_profile ifdp ON ifd.profile_id = CAST (ifdp.id AS VARCHAR)
136   - LEFT JOIN iotfs_organization io ON io.id = ifd.organization_id
  137 + LEFT JOIN tk_organization io ON io.id = ifd.organization_id
137 138 LEFT JOIN attribute_kv a ON ifd.tb_device_id = a.entity_id::TEXT AND a.entity_type ='DEVICE' AND a.attribute_key='active'
138 139 LEFT JOIN attribute_kv b ON ifd.tb_device_id = b.entity_id::TEXT AND b.entity_type ='DEVICE' AND b.attribute_key='lastActivityTime'
139 140 LEFT JOIN attribute_kv c ON ifd.tb_device_id = c.entity_id::TEXT AND c.entity_type ='DEVICE' AND c.attribute_key='lastDisconnectTime'
140 141 LEFT JOIN attribute_kv e ON ifd.tb_device_id = e.entity_id::TEXT AND e.entity_type ='DEVICE' AND e.attribute_key='lastConnectTime'
141 142 LEFT JOIN device d ON d.id::TEXT = ifd.tb_device_id
142   - LEFT JOIN iotfs_device idg ON idg.id = ifd.gateway_id
  143 + LEFT JOIN tk_device idg ON idg.id = ifd.gateway_id
143 144 <where>
144 145 <if test="tenantId !=null and tenantId !=''">
145 146 AND ifd.tenant_id = #{tenantId}
... ... @@ -153,7 +154,7 @@
153 154 <select id="findGateWayDeviceByTbDeviceId" resultMap="deviceMap">
154 155 SELECT
155 156 <include refid="basicColumns"/>
156   - FROM iotfs_device ifd
  157 + FROM tk_device ifd
157 158 LEFT JOIN relation rl ON ifd.tb_device_id = rl.from_id :: TEXT
158 159 WHERE
159 160 rl.to_id ::TEXT = #{tbDeviceId}
... ... @@ -162,7 +163,7 @@
162 163 </select>
163 164
164 165 <update id="freshAlarmStatus">
165   - UPDATE iotfs_device
  166 + UPDATE tk_device
166 167 SET alarm_status=#{created}
167 168 WHERE tb_device_id = #{tbDeviceId}
168 169 </update>
... ... @@ -180,9 +181,9 @@
180 181 b.long_v last_online_time,
181 182 d.customer_id :: TEXT AS customer_id
182 183 FROM
183   - iotfs_device ifd
  184 + tk_device ifd
184 185 LEFT JOIN device_profile ifdp ON ifd.profile_id = ifdp.ID ::
185   - TEXT LEFT JOIN iotfs_organization io ON io.ID = ifd.organization_id
  186 + TEXT LEFT JOIN tk_organization io ON io.ID = ifd.organization_id
186 187 LEFT JOIN attribute_kv A ON ifd.tb_device_id = A.entity_id :: TEXT
187 188 AND A.entity_type = 'DEVICE'
188 189 AND A.attribute_key = 'active'
... ... @@ -239,7 +240,7 @@
239 240 </select>
240 241 <select id="findDeviceIdsByCustomerId" resultType="java.lang.String">
241 242 SELECT idi.tb_device_id
242   - FROM iotfs_device idi
  243 + FROM tk_device idi
243 244 LEFT JOIN device d ON d.id::TEXT = idi.tb_device_id
244 245 WHERE customer_id::TEXT = #{customerId}
245 246 </select>
... ... @@ -330,7 +331,7 @@
330 331 <select id="masterDevices" resultMap="listInform">
331 332 SELECT
332 333 base.tb_device_id as id,base.name,base.device_type
333   - FROM iotfs_device base
  334 + FROM tk_device base
334 335 LEFT JOIN device tde ON tde.ID :: TEXT = base.tb_device_id
335 336 <where>
336 337 base.device_type != 'SENSOR'
... ... @@ -358,7 +359,7 @@
358 359 </if>
359 360 ) base
360 361 LEFT JOIN device tde ON base.to_id = tde.id
361   - LEFT JOIN iotfs_device ide ON tde.ID :: TEXT = ide.tb_device_id
  362 + LEFT JOIN tk_device ide ON tde.ID :: TEXT = ide.tb_device_id
362 363 <where>
363 364 ide.device_type = 'SENSOR'
364 365 <if test="tenantId !=null and tenantId !=''">
... ... @@ -379,7 +380,7 @@
379 380 <select id="slaveDevice" resultMap="deviceMap">
380 381 SELECT
381 382 <include refid="basicColumns"/>
382   - FROM iotfs_device ifd
  383 + FROM tk_device ifd
383 384 <where>
384 385 ifd.tenant_id = #{tenantId}
385 386 AND ifd.gateway_id = #{masterId}
... ... @@ -393,7 +394,7 @@
393 394 FROM ts_kv_dictionary base
394 395 LEFT JOIN ts_kv_latest latest ON latest.key = base.key_id
395 396 LEFT JOIN device tb ON tb.ID = latest.entity_id
396   - LEFT JOIN iotfs_device iot ON tb.ID :: TEXT = iot.tb_device_id
  397 + LEFT JOIN tk_device iot ON tb.ID :: TEXT = iot.tb_device_id
397 398 <where>
398 399 iot.tenant_id = #{tenantId}
399 400 <if test="customerId !=null and customerId !=''">
... ...
... ... @@ -20,7 +20,7 @@
20 20 </resultMap>
21 21
22 22 <select id="listBySceneId" resultMap="actionDTO">
23   - SELECT * FROM iotfs_do_action WHERE scene_linkage_id = #{sceneId}
  23 + SELECT * FROM tk_do_action WHERE scene_linkage_id = #{sceneId}
24 24 </select>
25 25
26 26 </mapper>
... ...
... ... @@ -19,7 +19,7 @@
19 19 </resultMap>
20 20
21 21 <select id="listBySceneId" resultMap="conditionDTO">
22   - SELECT * FROM iotfs_do_condition WHERE scene_linkage_id = #{sceneId}
  22 + SELECT * FROM tk_do_condition WHERE scene_linkage_id = #{sceneId}
23 23 </select>
24 24
25 25 </mapper>
... ...
... ... @@ -25,7 +25,7 @@
25 25 <select id="getEnableConfigByMessageAndPlatform" resultMap="messageConfigDTOMap">
26 26 SELECT
27 27 <include refid="columns"/>
28   - FROM message_config
  28 + FROM sys_message_config
29 29 <where>
30 30 status = 1
31 31 <if test="messageType !=null and messageType != ''">AND message_type = #{messageType}</if>
... ...
... ... @@ -28,7 +28,7 @@
28 28 <select id="getTemplatePage" resultMap="messageTemplateDTOMap">
29 29 SELECT
30 30 <include refid="columns"/>
31   - FROM message_template mt LEFT JOIN message_config mc ON
  31 + FROM tk_message_template mt LEFT JOIN tk_message_config mc ON
32 32 mt.message_config_id=mc.id
33 33 <where>
34 34 <if test="queryMap.tenantId !=null and queryMap.tenantId != ''">
... ... @@ -46,7 +46,7 @@
46 46 <select id="findMessageTemplate" resultMap="messageTemplateDTOMap">
47 47 SELECT
48 48 <include refid="columns"/>
49   - FROM message_template mt LEFT JOIN message_config mc ON
  49 + FROM tk_message_template mt LEFT JOIN tk_message_config mc ON
50 50 mt.message_config_id=mc.id
51 51 <where>
52 52 <if test="id !=null and id != ''">mt.id = #{id}</if>
... ...
... ... @@ -18,7 +18,7 @@
18 18 <select id="findOrganizationTreeList" resultMap="organizationDTOMap">
19 19 WITH RECURSIVE organization AS (
20 20 SELECT id, parent_id, name, sort,creator,create_time,updater,update_time,remark,tenant_id
21   - FROM iotfs_organization
  21 + FROM tk_organization
22 22 WHERE tenant_id = #{tenantId}
23 23 <if test="organizationIds !=null and organizationIds.size() &gt; 0">
24 24 AND id IN
... ... @@ -28,7 +28,7 @@
28 28 </if>
29 29 UNION ALL
30 30 SELECT ig.id, ig.parent_id, ig.name, ig.sort,ig.creator,ig.create_time,ig.updater,ig.update_time,ig.remark,ig.tenant_id
31   - FROM iotfs_organization ig
  31 + FROM tk_organization ig
32 32 JOIN organization ON ig.parent_id = organization.id
33 33 WHERE ig.tenant_id = #{tenantId}
34 34 )
... ...
... ... @@ -31,8 +31,8 @@
31 31 <select id="getReportFormConfigPage" resultMap="formConfigDtoMap">
32 32 SELECT
33 33 <include refid="columns"/>,io.name as organization_name,su.real_name as create_user_name
34   - FROM iotfs_report_form_config config
35   - LEFT JOIN iotfs_organization io ON io.id = config.organization_id
  34 + FROM tk_report_form_config config
  35 + LEFT JOIN tk_organization io ON io.id = config.organization_id
36 36 LEFT JOIN sys_user su ON config.creator = su.id
37 37 <where>
38 38 config.tenant_id = #{queryMap.tenantId}
... ...
... ... @@ -25,9 +25,9 @@
25 25 <select id="getScenePage" resultMap="sceneLinkageMap">
26 26 SELECT
27 27 <include refid="columns"/>,su.real_name creator_name
28   - FROM iotfs_scene_linkage s
  28 + FROM tk_scene_linkage s
29 29 LEFT JOIN sys_user su ON su.id = s.creator
30   - LEFT JOIN iotfs_organization io ON io.id = s.organization_id
  30 + LEFT JOIN tk_organization io ON io.id = s.organization_id
31 31 <where>
32 32 <if test="queryMap.tenantId !=null and queryMap.tenantId !=''">
33 33 AND s.tenant_id = #{queryMap.tenantId}
... ...
... ... @@ -7,7 +7,6 @@
7 7 <result property="dictName" column="dict_name"/>
8 8 <result property="dictCode" column="dict_code"/>
9 9 <result property="description" column="description"/>
10   - <result property="tenantId" column="tenant_id"/>
11 10 <result property="creator" column="creator"/>
12 11 <result property="createTime" column="create_time"/>
13 12 <result property="updater" column="updater"/>
... ...
... ... @@ -19,7 +19,7 @@
19 19 </resultMap>
20 20
21 21 <select id="listBySceneId" resultMap="triggerDTO">
22   - SELECT * FROM iotfs_trigger WHERE scene_linkage_id = #{sceneId}
  22 + SELECT * FROM tk_trigger WHERE scene_linkage_id = #{sceneId}
23 23 </select>
24 24
25 25 </mapper>
... ...
... ... @@ -39,8 +39,8 @@
39 39 <select id="alarmPage" resultMap="alarmInfo">
40 40 SELECT d.name AS device_name,d.id device_id,m.*,d.organization_id,org.name organization_name
41 41 FROM alarm m
42   - LEFT JOIN iotfs_device d ON m.originator_id = d.tb_device_id::uuid
43   - LEFT JOIN iotfs_organization org ON org.id = d.organization_id
  42 + LEFT JOIN tk_device d ON m.originator_id = d.tb_device_id::uuid
  43 + LEFT JOIN tk_organization org ON org.id = d.organization_id
44 44 <where>
45 45 m.tenant_id = #{tenantId}
46 46 <if test="customerId!=null">
... ...
... ... @@ -34,7 +34,7 @@
34 34 SELECT
35 35 <include refid="basicColumns"/>
36 36 FROM device_profile base
37   - LEFT JOIN iotfs_device_profile iot ON iot.tb_profile_id = base.id::TEXT
  37 + LEFT JOIN tk_device_profile iot ON iot.tb_profile_id = base.id::TEXT
38 38 <where>
39 39 <if test="tenantId !=null and tenantId !=''">
40 40 AND base.tenant_id::TEXT = #{tenantId}
... ... @@ -53,7 +53,7 @@
53 53 SELECT
54 54 <include refid="basicColumns"/>
55 55 FROM device_profile base
56   - LEFT JOIN iotfs_device_profile iot ON iot.tb_profile_id = base.id::TEXT
  56 + LEFT JOIN tk_device_profile iot ON iot.tb_profile_id = base.id::TEXT
57 57 <where>
58 58 <if test="tenantId !=null and tenantId !=''">
59 59 AND iot.tenant_id = #{tenantId}
... ... @@ -67,7 +67,7 @@
67 67 SELECT
68 68 <include refid="basicColumns"/>
69 69 FROM device_profile base
70   - LEFT JOIN iotfs_device_profile iot ON iot.tb_profile_id = base.id::TEXT
  70 + LEFT JOIN tk_device_profile iot ON iot.tb_profile_id = base.id::TEXT
71 71 <where>
72 72 iot.tenant_id = #{tenantId}
73 73 <if test="scriptId !=null and scriptId !=''">
... ...
... ... @@ -45,8 +45,8 @@
45 45 <select id="getPageDatas" resultMap="dataMap">
46 46 SELECT <include refid="detailColumns"/>
47 47 FROM rpc base
48   - LEFT JOIN iotfs_device dev ON base.device_id =dev.tb_device_id::uuid
49   - LEFT JOIN iotfs_organization org ON dev.organization_id = org.id
  48 + LEFT JOIN tk_device dev ON base.device_id =dev.tb_device_id::uuid
  49 + LEFT JOIN tk_organization org ON dev.organization_id = org.id
50 50 LEFT JOIN tenant ten ON base.tenant_id = ten.id
51 51 <where>
52 52 1=1
... ...
... ... @@ -5,7 +5,7 @@
5 5
6 6 <select id="login" resultType="org.thingsboard.server.dao.yunteng.entities.User">
7 7 SELECT sus.*
8   - FROM iotfs_third_user base
  8 + FROM tk_third_user base
9 9 LEFT JOIN sys_user sus ON base.app_user_id = sus.id
10 10 LEFT JOIN sys_tenant ste ON ste.tenant_id = sus.tenant_id
11 11 <where>
... ...
... ... @@ -47,9 +47,9 @@
47 47 <select id="getVideoPage" resultMap="videoMap">
48 48 SELECT
49 49 <include refid="detailColumns"/>
50   - FROM iotfs_device_camera base
51   - LEFT JOIN iotfs_organization org ON org.id = base.organization_id
52   - LEFT JOIN iotfs_video_platform ivp ON ivp.id = base.video_platform_id
  50 + FROM tk_device_camera base
  51 + LEFT JOIN tk_organization org ON org.id = base.organization_id
  52 + LEFT JOIN tk_video_platform ivp ON ivp.id = base.video_platform_id
53 53 <where>
54 54 <if test="tenantId !=null and tenantId !=''">
55 55 AND base.tenant_id = #{tenantId}
... ... @@ -72,9 +72,9 @@
72 72 <select id="getVideoInfosByTenantIdOrAccessModeOrId" resultMap="videoMap">
73 73 SELECT
74 74 <include refid="detailColumns"/>
75   - FROM iotfs_device_camera base
76   - LEFT JOIN iotfs_organization org ON org.id = base.organization_id
77   - LEFT JOIN iotfs_video_platform ivp ON ivp.id = base.video_platform_id
  75 + FROM tk_device_camera base
  76 + LEFT JOIN tk_organization org ON org.id = base.organization_id
  77 + LEFT JOIN tk_video_platform ivp ON ivp.id = base.video_platform_id
78 78 <where>
79 79 <if test="tenantId !=null and tenantId !=''">
80 80 AND base.tenant_id = #{tenantId}
... ...
... ... @@ -23,7 +23,7 @@
23 23 <select id="getVideoPlatformPage" resultMap="videoPlatformMap">
24 24 SELECT
25 25 <include refid="basicColumns"/>
26   - FROM iotfs_video_platform base
  26 + FROM tk_video_platform base
27 27 <where>
28 28 <if test="tenantId !=null and tenantId !=''">
29 29 AND base.tenant_id = #{tenantId}
... ...