Commit e417d0546e7a8a38bc844ce6fdd1ffbc8ae0d7f8

Authored by xp.Huang
2 parents 78201e0a ec153776

Merge branch 'master_dev' into 'master'

Master dev

See merge request yunteng/thingskit!412
Showing 81 changed files with 645 additions and 327 deletions
... ... @@ -14,6 +14,7 @@ import org.thingsboard.server.common.data.yunteng.enums.OrderTypeEnum;
14 14 import org.thingsboard.server.common.data.yunteng.utils.tools.TkPageData;
15 15 import org.thingsboard.server.controller.BaseController;
16 16 import org.thingsboard.server.dao.yunteng.service.AlarmProfileService;
  17 +import org.thingsboard.server.queue.util.TbCoreComponent;
17 18
18 19 import java.util.HashMap;
19 20 import java.util.List;
... ... @@ -22,6 +23,7 @@ import static org.thingsboard.server.common.data.yunteng.constant.QueryConstant.
22 23 import static org.thingsboard.server.common.data.yunteng.constant.QueryConstant.ORDER_TYPE;
23 24
24 25 @RestController
  26 +@TbCoreComponent
25 27 @RequestMapping("api/yt/alarm/profile")
26 28 @Api(tags = {"告警配置"})
27 29 @RequiredArgsConstructor
... ...
... ... @@ -27,12 +27,14 @@ import org.thingsboard.server.common.data.yunteng.utils.tools.TkPageData;
27 27 import org.thingsboard.server.controller.BaseController;
28 28 import org.thingsboard.server.dao.exception.DataValidationException;
29 29 import org.thingsboard.server.dao.yunteng.service.HomePageService;
  30 +import org.thingsboard.server.queue.util.TbCoreComponent;
30 31 import org.thingsboard.server.service.security.model.SecurityUser;
31 32
32 33 @RequestMapping("api/yt/homepage")
33 34 @Api(tags = {"首页"})
34 35 @RequiredArgsConstructor
35 36 @RestController
  37 +@TbCoreComponent
36 38 public class HomePageController extends BaseController {
37 39
38 40 private final HomePageService homePageService;
... ...
... ... @@ -32,9 +32,11 @@ import org.thingsboard.server.dao.util.yunteng.CronUtils;
32 32 import org.thingsboard.server.dao.util.yunteng.ScheduleUtils;
33 33 import org.thingsboard.server.dao.yunteng.service.TkSysJobService;
34 34 import org.thingsboard.server.queue.discovery.TbServiceInfoProvider;
  35 +import org.thingsboard.server.queue.util.TbCoreComponent;
35 36
36 37 /** 调度任务信息操作处理 */
37 38 @RestController
  39 +@TbCoreComponent
38 40 @RequestMapping("api/yt/monitor/job")
39 41 @RequiredArgsConstructor
40 42 @Api(tags = {"定时任务"})
... ...
... ... @@ -16,6 +16,7 @@ import org.thingsboard.server.common.data.yunteng.utils.tools.ResponseResult;
16 16 import org.thingsboard.server.common.data.yunteng.utils.tools.TkPageData;
17 17 import org.thingsboard.server.controller.BaseController;
18 18 import org.thingsboard.server.dao.yunteng.service.TkSysJobLogService;
  19 +import org.thingsboard.server.queue.util.TbCoreComponent;
19 20
20 21 import java.sql.Timestamp;
21 22 import java.util.HashMap;
... ... @@ -25,6 +26,7 @@ import static org.thingsboard.server.common.data.yunteng.constant.QueryConstant.
25 26
26 27 /** 调度日志操作处理 */
27 28 @RestController
  29 +@TbCoreComponent
28 30 @RequestMapping("api/yt/monitor/job_log")
29 31 @RequiredArgsConstructor
30 32 @Api(tags = {"定时任务执行日志"})
... ...
... ... @@ -33,6 +33,7 @@ import org.thingsboard.server.common.data.yunteng.utils.tools.TkPageData;
33 33 import org.thingsboard.server.controller.BaseController;
34 34 import org.thingsboard.server.dao.yunteng.service.ThingsModelService;
35 35 import org.thingsboard.server.dao.yunteng.service.TkDeviceProfileService;
  36 +import org.thingsboard.server.queue.util.TbCoreComponent;
36 37 import org.thingsboard.server.service.entitiy.device.profile.TbDeviceProfileService;
37 38 import org.thingsboard.server.utils.ImportModbusUtils;
38 39
... ... @@ -48,6 +49,7 @@ import static org.thingsboard.server.common.data.yunteng.constant.QueryConstant.
48 49 import static org.thingsboard.server.common.data.yunteng.constant.QueryConstant.ORDER_TYPE;
49 50
50 51 @RestController
  52 +@TbCoreComponent
51 53 @RequiredArgsConstructor
52 54 @RequestMapping("api/yt/things_model")
53 55 @Api(tags = {"物模型管理"})
... ...
... ... @@ -36,6 +36,7 @@ import org.thingsboard.server.dao.user.UserService;
36 36 import org.thingsboard.server.dao.yunteng.service.MenuService;
37 37 import org.thingsboard.server.dao.yunteng.service.TkTenantService;
38 38 import org.thingsboard.server.dao.yunteng.service.TkUserService;
  39 +import org.thingsboard.server.queue.util.TbCoreComponent;
39 40 import org.thingsboard.server.service.entitiy.tenant.TbTenantService;
40 41 import org.thingsboard.server.service.entitiy.user.TbUserService;
41 42 import org.thingsboard.server.service.install.InstallScripts;
... ... @@ -51,6 +52,7 @@ import java.util.UUID;
51 52 import static org.thingsboard.server.common.data.yunteng.constant.QueryConstant.*;
52 53
53 54 @RestController
  55 +@TbCoreComponent
54 56 @RequestMapping("api/yt/admin")
55 57 @Api(tags = {"租户管理", "菜单管理"})
56 58 @RequiredArgsConstructor
... ...
... ... @@ -21,6 +21,7 @@ import org.thingsboard.server.common.data.yunteng.utils.tools.TkPageData;
21 21 import org.thingsboard.server.controller.BaseController;
22 22 import org.thingsboard.server.dao.yunteng.service.AlarmProfileService;
23 23 import org.thingsboard.server.dao.yunteng.service.TkAlarmContactService;
  24 +import org.thingsboard.server.queue.util.TbCoreComponent;
24 25
25 26 import java.net.URI;
26 27 import java.util.HashMap;
... ... @@ -36,6 +37,7 @@ import static org.thingsboard.server.common.data.yunteng.constant.QueryConstant.
36 37 * @Description 告警联系人 @Author cxy @Date 2021/11/2 14:54
37 38 */
38 39 @RestController
  40 +@TbCoreComponent
39 41 @RequestMapping("/api/yt/alarm_contact")
40 42 @RequiredArgsConstructor
41 43 @Api(tags = "告警联系人")
... ...
... ... @@ -19,6 +19,7 @@ import org.thingsboard.server.common.data.yunteng.utils.tools.TkPageData;
19 19 import org.thingsboard.server.controller.BaseController;
20 20 import org.thingsboard.server.dao.yunteng.entities.TkAlarmEntity;
21 21 import org.thingsboard.server.dao.yunteng.service.TkAlarmInfoService;
  22 +import org.thingsboard.server.queue.util.TbCoreComponent;
22 23
23 24 import java.util.HashMap;
24 25 import java.util.List;
... ... @@ -31,6 +32,7 @@ import static org.thingsboard.server.common.data.yunteng.constant.QueryConstant.
31 32 * @Description 告警中心 @Author cxy @Date 2021/11/11 9:23
32 33 */
33 34 @RestController
  35 +@TbCoreComponent
34 36 @RequestMapping("/api/yt/alarm")
35 37 @RequiredArgsConstructor
36 38 @Api(tags = "告警中心")
... ...
... ... @@ -9,6 +9,7 @@ import org.springframework.util.Assert;
9 9 import org.springframework.web.bind.annotation.*;
10 10 import org.thingsboard.server.common.data.yunteng.dto.AlarmInfoDTO;
11 11 import org.thingsboard.server.dao.yunteng.service.TkNoticeService;
  12 +import org.thingsboard.server.queue.util.TbCoreComponent;
12 13 import org.thingsboard.server.service.security.exception.JwtExpiredTokenException;
13 14
14 15 import java.net.InetAddress;
... ... @@ -24,6 +25,7 @@ import java.net.InetAddress;
24 25 * @Copyright 2016-2018 - Powered By 云腾五洲
25 26 */
26 27 @RestController
  28 +@TbCoreComponent
27 29 @RequestMapping("/api/yt/notice")
28 30 @RequiredArgsConstructor
29 31 @Slf4j
... ...
... ... @@ -12,6 +12,7 @@ import org.thingsboard.server.common.data.yunteng.dto.SysAppDesignDTO;
12 12 import org.thingsboard.server.common.data.yunteng.utils.tools.ResponseResult;
13 13 import org.thingsboard.server.controller.BaseController;
14 14 import org.thingsboard.server.dao.yunteng.service.SysAppDesignService;
  15 +import org.thingsboard.server.queue.util.TbCoreComponent;
15 16
16 17 /**
17 18 * @author: 徐浩然
... ... @@ -20,6 +21,7 @@ import org.thingsboard.server.dao.yunteng.service.SysAppDesignService;
20 21 */
21 22 @Api(tags = "APP定制")
22 23 @RestController
  24 +@TbCoreComponent
23 25 @RequestMapping("api/yt/app_design")
24 26 @RequiredArgsConstructor
25 27 public class TkAppDesignController extends BaseController {
... ...
... ... @@ -9,6 +9,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
9 9 import org.springframework.web.bind.annotation.RestController;
10 10 import org.thingsboard.server.common.data.yunteng.dto.SysAreaDTO;
11 11 import org.thingsboard.server.dao.yunteng.service.SysAreaService;
  12 +import org.thingsboard.server.queue.util.TbCoreComponent;
12 13
13 14 import java.util.List;
14 15
... ... @@ -19,6 +20,7 @@ import java.util.List;
19 20 */
20 21 @Api(tags = "中国省市区街关联")
21 22 @RestController
  23 +@TbCoreComponent
22 24 @RequestMapping("api/yt/area")
23 25 @RequiredArgsConstructor
24 26 public class TkAreaController {
... ...
... ... @@ -23,6 +23,7 @@ import org.thingsboard.server.common.data.yunteng.enums.OrderTypeEnum;
23 23 import org.thingsboard.server.common.data.yunteng.utils.tools.TkPageData;
24 24 import org.thingsboard.server.controller.BaseController;
25 25 import org.thingsboard.server.dao.yunteng.service.TkConfigurationCenterService;
  26 +import org.thingsboard.server.queue.util.TbCoreComponent;
26 27
27 28 import java.util.HashMap;
28 29 import java.util.List;
... ... @@ -30,6 +31,7 @@ import java.util.List;
30 31 import static org.thingsboard.server.common.data.yunteng.constant.QueryConstant.*;
31 32
32 33 @RestController
  34 +@TbCoreComponent
33 35 @RequestMapping("/api/yt/configuration/center")
34 36 @RequiredArgsConstructor
35 37 @Api(tags = "组态中心")
... ...
... ... @@ -15,8 +15,10 @@ import org.thingsboard.server.common.data.yunteng.dto.DeleteDTO;
15 15 import org.thingsboard.server.common.data.yunteng.dto.request.ConfigurationContentInfoDTO;
16 16 import org.thingsboard.server.controller.BaseController;
17 17 import org.thingsboard.server.dao.yunteng.service.TkConfigurationContentService;
  18 +import org.thingsboard.server.queue.util.TbCoreComponent;
18 19
19 20 @RestController
  21 +@TbCoreComponent
20 22 @RequestMapping("/api/yt/configuration/content")
21 23 @RequiredArgsConstructor
22 24 @Api(tags = "组态内容")
... ...
... ... @@ -22,11 +22,13 @@ import org.thingsboard.server.dao.yunteng.service.TkConfigurationActService;
22 22 import org.thingsboard.server.dao.yunteng.service.TkConfigurationContentNodeService;
23 23 import org.thingsboard.server.dao.yunteng.service.TkConfigurationDatasourceService;
24 24 import org.thingsboard.server.dao.yunteng.service.TkConfigurationEventService;
  25 +import org.thingsboard.server.queue.util.TbCoreComponent;
25 26
26 27 /**
27 28 * @author Administrator
28 29 */
29 30 @RestController
  31 +@TbCoreComponent
30 32 @RequestMapping("/api/yt/new/configuration/node")
31 33 @RequiredArgsConstructor
32 34 @Api(tags = "组态结点管理(新)")
... ...
... ... @@ -15,6 +15,7 @@ import org.thingsboard.server.controller.BaseController;
15 15 import org.thingsboard.server.dao.yunteng.service.TkConfigurationActService;
16 16 import org.thingsboard.server.dao.yunteng.service.TkConfigurationDatasourceService;
17 17 import org.thingsboard.server.dao.yunteng.service.TkConfigurationEventService;
  18 +import org.thingsboard.server.queue.util.TbCoreComponent;
18 19
19 20 import java.util.List;
20 21 import java.util.Optional;
... ... @@ -23,6 +24,7 @@ import java.util.Optional;
23 24 * @author Administrator
24 25 */
25 26 @RestController
  27 +@TbCoreComponent
26 28 @RequestMapping("/api/yt/configuration/node")
27 29 @RequiredArgsConstructor
28 30 @Api(tags = "组态结点管理")
... ...
... ... @@ -40,10 +40,12 @@ import org.thingsboard.server.controller.BaseController;
40 40 import org.thingsboard.server.dao.yunteng.service.ConvertConfigService;
41 41 import org.thingsboard.server.dao.yunteng.service.SceneLinkageService;
42 42 import org.thingsboard.server.dao.yunteng.service.TkRuleChainService;
  43 +import org.thingsboard.server.queue.util.TbCoreComponent;
43 44 import org.thingsboard.server.service.rule.TbRuleChainService;
44 45 import org.thingsboard.server.service.security.permission.Operation;
45 46
46 47 @RestController
  48 +@TbCoreComponent
47 49 @RequiredArgsConstructor
48 50 @RequestMapping("api/yt/convert")
49 51 @Api(tags = {"数据流转控制器"})
... ...
... ... @@ -23,12 +23,14 @@ import org.thingsboard.server.common.data.yunteng.utils.tools.ResponseResult;
23 23 import org.thingsboard.server.common.data.yunteng.utils.tools.TkPageData;
24 24 import org.thingsboard.server.controller.BaseController;
25 25 import org.thingsboard.server.dao.yunteng.service.TkDataBoardService;
  26 +import org.thingsboard.server.queue.util.TbCoreComponent;
26 27
27 28 import java.util.*;
28 29
29 30 import static org.thingsboard.server.common.data.yunteng.constant.QueryConstant.*;
30 31
31 32 @RestController
  33 +@TbCoreComponent
32 34 @RequiredArgsConstructor
33 35 @RequestMapping("api/yt/data_board")
34 36 @PreAuthorize("@check.checkPermissions({'TENANT_ADMIN','CUSTOMER_USER'},{})")
... ...
... ... @@ -24,11 +24,13 @@ import org.thingsboard.server.common.data.yunteng.utils.tools.ResponseResult;
24 24 import org.thingsboard.server.controller.BaseController;
25 25 import org.thingsboard.server.dao.yunteng.service.TkDataBoardService;
26 26 import org.thingsboard.server.dao.yunteng.service.TkDataComponentService;
  27 +import org.thingsboard.server.queue.util.TbCoreComponent;
27 28
28 29 import java.util.ArrayList;
29 30 import java.util.List;
30 31
31 32 @RestController
  33 +@TbCoreComponent
32 34 @RequiredArgsConstructor
33 35 @PreAuthorize("@check.checkPermissions({'TENANT_ADMIN','CUSTOMER_USER'},{})")
34 36 @RequestMapping("api/yt/data_component")
... ...
... ... @@ -15,11 +15,13 @@ import org.thingsboard.server.common.data.yunteng.dto.DeleteDTO;
15 15 import org.thingsboard.server.common.data.yunteng.dto.request.TkDataViewContentInfoDTO;
16 16 import org.thingsboard.server.controller.BaseController;
17 17 import org.thingsboard.server.dao.yunteng.service.TkDataViewContentService;
  18 +import org.thingsboard.server.queue.util.TbCoreComponent;
18 19
19 20 /**
20 21 * @author tianfuLei
21 22 */
22 23 @RestController
  24 +@TbCoreComponent
23 25 @RequestMapping("/api/yt/data_view/content")
24 26 @RequiredArgsConstructor
25 27 @Api(tags = "大屏内容")
... ...
... ... @@ -21,6 +21,7 @@ import org.thingsboard.server.common.data.yunteng.enums.OrderTypeEnum;
21 21 import org.thingsboard.server.common.data.yunteng.utils.tools.TkPageData;
22 22 import org.thingsboard.server.controller.BaseController;
23 23 import org.thingsboard.server.dao.yunteng.service.TkDataViewService;
  24 +import org.thingsboard.server.queue.util.TbCoreComponent;
24 25
25 26 import java.util.HashMap;
26 27
... ... @@ -30,6 +31,7 @@ import static org.thingsboard.server.common.data.yunteng.constant.QueryConstant.
30 31 * @author tianfuLei
31 32 */
32 33 @RestController
  34 +@TbCoreComponent
33 35 @RequestMapping("/api/yt/data_view")
34 36 @RequiredArgsConstructor
35 37 @Api(tags = "大屏设计器")
... ...
... ... @@ -18,6 +18,7 @@ import org.thingsboard.server.common.data.yunteng.enums.TkSystemTypeEnum;
18 18 import org.thingsboard.server.common.data.yunteng.utils.tools.TkPageData;
19 19 import org.thingsboard.server.controller.BaseController;
20 20 import org.thingsboard.server.dao.yunteng.service.TkDataViewInterfaceService;
  21 +import org.thingsboard.server.queue.util.TbCoreComponent;
21 22
22 23 import java.util.*;
23 24
... ... @@ -27,6 +28,7 @@ import static org.thingsboard.server.common.data.yunteng.constant.QueryConstant.
27 28 * @author tianfuLei
28 29 */
29 30 @RestController
  31 +@TbCoreComponent
30 32 @RequestMapping("/api/yt/data_view_interface")
31 33 @RequiredArgsConstructor
32 34 @Api(tags = "大屏公共接口")
... ...
... ... @@ -19,12 +19,14 @@ import org.thingsboard.server.common.data.yunteng.utils.tools.ResponseResult;
19 19 import org.thingsboard.server.common.data.yunteng.utils.tools.TkPageData;
20 20 import org.thingsboard.server.controller.BaseController;
21 21 import org.thingsboard.server.dao.yunteng.service.TkDeviceAccessInformationService;
  22 +import org.thingsboard.server.queue.util.TbCoreComponent;
22 23
23 24 import java.util.HashMap;
24 25
25 26 import static org.thingsboard.server.common.data.yunteng.constant.QueryConstant.*;
26 27
27 28 @RestController
  29 +@TbCoreComponent
28 30 @RequiredArgsConstructor
29 31 @RequestMapping("api/yt/device_profile/access_information")
30 32 @Api(tags = {"设备接入信息管理"})
... ...
... ... @@ -40,6 +40,7 @@ import org.thingsboard.server.dao.yunteng.service.TkAlarmInfoService;
40 40 import org.thingsboard.server.dao.yunteng.service.TkDeviceProfileService;
41 41 import org.thingsboard.server.dao.yunteng.service.TkDeviceService;
42 42 import org.thingsboard.server.dao.yunteng.service.media.TkVideoChannelService;
  43 +import org.thingsboard.server.queue.util.TbCoreComponent;
43 44 import org.thingsboard.server.service.entitiy.alarm.TbAlarmService;
44 45 import org.thingsboard.server.service.entitiy.device.TbDeviceService;
45 46 import org.thingsboard.server.service.entitiy.entity.relation.TbEntityRelationService;
... ... @@ -55,6 +56,7 @@ import java.util.concurrent.ExecutionException;
55 56 import static org.thingsboard.server.common.data.yunteng.constant.QueryConstant.*;
56 57
57 58 @RestController
  59 +@TbCoreComponent
58 60 @RequiredArgsConstructor
59 61 @RequestMapping("api/yt/device")
60 62 @Api(tags = {"设备管理"})
... ...
... ... @@ -15,12 +15,14 @@ import org.thingsboard.server.common.data.yunteng.utils.tools.ResponseResult;
15 15 import org.thingsboard.server.common.data.yunteng.utils.tools.TkPageData;
16 16 import org.thingsboard.server.controller.BaseController;
17 17 import org.thingsboard.server.dao.yunteng.service.TkDeviceProfileCategoryService;
  18 +import org.thingsboard.server.queue.util.TbCoreComponent;
18 19
19 20 import java.util.HashMap;
20 21
21 22 import static org.thingsboard.server.common.data.yunteng.constant.QueryConstant.*;
22 23
23 24 @RestController
  25 +@TbCoreComponent
24 26 @RequiredArgsConstructor
25 27 @RequestMapping("api/yt/device_profile/category")
26 28 @Api(tags = {"产品品类管理"})
... ...
... ... @@ -34,6 +34,7 @@ import org.thingsboard.server.controller.BaseController;
34 34 import org.thingsboard.server.dao.yunteng.service.ThingsModelService;
35 35 import org.thingsboard.server.dao.yunteng.service.TkDeviceProfileService;
36 36 import org.thingsboard.server.dao.yunteng.service.TkDeviceScriptService;
  37 +import org.thingsboard.server.queue.util.TbCoreComponent;
37 38 import org.thingsboard.server.service.entitiy.device.profile.TbDeviceProfileService;
38 39 import org.thingsboard.server.service.security.permission.Operation;
39 40
... ... @@ -45,6 +46,7 @@ import java.util.concurrent.ExecutionException;
45 46 import static org.thingsboard.server.common.data.yunteng.constant.QueryConstant.*;
46 47
47 48 @RestController
  49 +@TbCoreComponent
48 50 @RequiredArgsConstructor
49 51 @RequestMapping("api/yt/device_profile")
50 52 @Api(tags = {"设备配置管理"})
... ... @@ -200,8 +202,11 @@ public class TkDeviceProfileController extends BaseController {
200 202 .getProfileData().getTransportConfiguration();
201 203 if(tcpProfile.getTcpAuthType().equals(TcpAuthTypeEnum.DATA_COMBINATION)){
202 204 String key = deviceProfileDTO.getTenantId() + "_" + deviceProfileDTO.getTbProfileId();
203   - Map<String,Object> cacheMap = (Map<String, Object>)
204   - cacheUtils.get(cacheName, FastIotConstants.OtherKey.DATA_COMBINATION_KEY).get();
  205 + Optional<Object> stringObjectMap = cacheUtils.get(cacheName, FastIotConstants.OtherKey.DATA_COMBINATION_KEY);
  206 + Map<String,Object> cacheMap = new HashMap<>();
  207 + if(stringObjectMap.isPresent()){
  208 + cacheMap = (Map<String,Object>)stringObjectMap.get();
  209 + }
205 210 cacheMap.put(key,tcpProfile);
206 211 cacheUtils.put(cacheName,FastIotConstants.OtherKey.DATA_COMBINATION_KEY,cacheMap);
207 212 }
... ...
... ... @@ -30,6 +30,8 @@ import org.thingsboard.server.common.data.yunteng.enums.OrderTypeEnum;
30 30 import org.thingsboard.server.common.data.yunteng.utils.tools.TkPageData;
31 31 import org.thingsboard.server.controller.BaseController;
32 32 import org.thingsboard.server.dao.yunteng.service.TkDeviceScriptService;
  33 +import org.thingsboard.server.queue.util.TbCoreComponent;
  34 +
33 35 import java.util.HashMap;
34 36 import java.util.List;
35 37 import java.util.Map;
... ... @@ -38,6 +40,7 @@ import java.util.UUID;
38 40 import static org.thingsboard.server.common.data.yunteng.constant.QueryConstant.*;
39 41
40 42 @RestController
  43 +@TbCoreComponent
41 44 @RequiredArgsConstructor
42 45 @RequestMapping("api/yt/js")
43 46 @Api(tags = {"设备数据解析脚本管理"})
... ... @@ -81,9 +84,8 @@ public class TkDeviceScriptController extends BaseController {
81 84
82 85 /**脚本引擎启用/禁用时,刷新设备接入服务中的脚本,禁用时使用默认脚本*/
83 86 scriptService.updateScriptStatus(tenantId, id, status);
84   - scriptService.getDeviceScript(tenantId, id).ifPresent(i->{
85   - tbClusterService.onJsScriptChange(i,null);
86   - });
  87 + scriptDTO.setStatus(status);
  88 + tbClusterService.onJsScriptChange(scriptDTO,null);
87 89 return ResponseEntity.ok(true);
88 90 }
89 91
... ...
... ... @@ -18,6 +18,7 @@ import org.thingsboard.server.common.data.yunteng.enums.OrderTypeEnum;
18 18 import org.thingsboard.server.common.data.yunteng.utils.tools.TkPageData;
19 19 import org.thingsboard.server.controller.BaseController;
20 20 import org.thingsboard.server.dao.yunteng.service.TkDeviceStateLogService;
  21 +import org.thingsboard.server.queue.util.TbCoreComponent;
21 22
22 23 import java.sql.Timestamp;
23 24 import java.util.HashMap;
... ... @@ -27,6 +28,7 @@ import static org.thingsboard.server.common.data.yunteng.constant.QueryConstant.
27 28 import static org.thingsboard.server.common.data.yunteng.constant.QueryConstant.ORDER_TYPE;
28 29
29 30 @RestController
  31 +@TbCoreComponent
30 32 @RequiredArgsConstructor
31 33 @RequestMapping("api/yt/device/state/log")
32 34 @Api(tags = {"设备上下线记录"})
... ...
... ... @@ -17,10 +17,12 @@ import org.thingsboard.server.common.data.yunteng.dto.DeviceTypeDTO;
17 17 import org.thingsboard.server.common.data.yunteng.utils.tools.ResponseResult;
18 18 import org.thingsboard.server.controller.BaseController;
19 19 import org.thingsboard.server.dao.yunteng.service.TkDeviceTypeService;
  20 +import org.thingsboard.server.queue.util.TbCoreComponent;
20 21
21 22 import java.util.List;
22 23
23 24 @RestController
  25 +@TbCoreComponent
24 26 @RequestMapping("api/yt/device_type")
25 27 @RequiredArgsConstructor
26 28 @Api(value = "设备类型")
... ...
... ... @@ -16,12 +16,14 @@ import org.thingsboard.server.common.data.yunteng.utils.tools.ResponseResult;
16 16 import org.thingsboard.server.common.data.yunteng.utils.tools.TkPageData;
17 17 import org.thingsboard.server.controller.BaseController;
18 18 import org.thingsboard.server.dao.yunteng.service.SysDictService;
  19 +import org.thingsboard.server.queue.util.TbCoreComponent;
19 20
20 21 import java.util.HashMap;
21 22
22 23 import static org.thingsboard.server.common.data.yunteng.constant.QueryConstant.*;
23 24
24 25 @RestController
  26 +@TbCoreComponent
25 27 @RequestMapping("api/yt/dict")
26 28 @RequiredArgsConstructor
27 29 @PreAuthorize("@check.checkPermissions({'SYS_ADMIN','PLATFORM_ADMIN'},{})")
... ...
... ... @@ -17,6 +17,7 @@ import org.thingsboard.server.common.data.yunteng.utils.tools.ResponseResult;
17 17 import org.thingsboard.server.common.data.yunteng.utils.tools.TkPageData;
18 18 import org.thingsboard.server.controller.BaseController;
19 19 import org.thingsboard.server.dao.yunteng.service.SysDictItemService;
  20 +import org.thingsboard.server.queue.util.TbCoreComponent;
20 21
21 22 import java.util.HashMap;
22 23 import java.util.List;
... ... @@ -25,6 +26,7 @@ import java.util.Map;
25 26 import static org.thingsboard.server.common.data.yunteng.constant.QueryConstant.*;
26 27
27 28 @RestController
  29 +@TbCoreComponent
28 30 @RequestMapping("api/yt/dict_item")
29 31 @RequiredArgsConstructor
30 32 public class TkDictItemController extends BaseController {
... ...
... ... @@ -10,6 +10,7 @@ import org.thingsboard.server.common.data.exception.ThingsboardException;
10 10 import org.thingsboard.server.common.data.yunteng.dto.SysEnterpriseDTO;
11 11 import org.thingsboard.server.controller.BaseController;
12 12 import org.thingsboard.server.dao.yunteng.service.SysEnterpriseService;
  13 +import org.thingsboard.server.queue.util.TbCoreComponent;
13 14
14 15 /**
15 16 * @author: 徐浩然
... ... @@ -18,6 +19,7 @@ import org.thingsboard.server.dao.yunteng.service.SysEnterpriseService;
18 19 */
19 20 @Api(tags = "企业信息")
20 21 @RestController
  22 +@TbCoreComponent
21 23 @RequestMapping("api/yt/enterprise")
22 24 @RequiredArgsConstructor
23 25 public class TkEnterpriseController extends BaseController {
... ...
... ... @@ -16,6 +16,7 @@ import org.thingsboard.server.common.data.yunteng.enums.DeviceEventTypeEnum;
16 16 import org.thingsboard.server.common.data.yunteng.enums.OrderTypeEnum;
17 17 import org.thingsboard.server.controller.BaseController;
18 18 import org.thingsboard.server.dao.yunteng.event.TkEventsService;
  19 +import org.thingsboard.server.queue.util.TbCoreComponent;
19 20
20 21 import java.util.UUID;
21 22
... ... @@ -25,6 +26,7 @@ import static org.thingsboard.server.common.data.yunteng.constant.QueryConstant.
25 26 * @author Administrator
26 27 */
27 28 @RestController
  29 +@TbCoreComponent
28 30 @RequestMapping("api/yt/event")
29 31 @Api(tags = {"设备事件"})
30 32 @RequiredArgsConstructor
... ...
... ... @@ -8,8 +8,10 @@ import org.springframework.web.bind.annotation.*;
8 8 import org.thingsboard.server.common.data.exception.ThingsboardException;
9 9 import org.thingsboard.server.common.data.yunteng.dto.FrpInfoDTO;
10 10 import org.thingsboard.server.dao.yunteng.service.TkFrpInfoService;
  11 +import org.thingsboard.server.queue.util.TbCoreComponent;
11 12
12 13 @RestController
  14 +@TbCoreComponent
13 15 @RequestMapping("api/yt/frp")
14 16 @Api(tags = "Frp内网穿透信息")
15 17 @RequiredArgsConstructor
... ...
... ... @@ -11,12 +11,14 @@ import org.thingsboard.server.common.data.yunteng.utils.tools.TkPageData;
11 11 import org.thingsboard.server.common.data.yunteng.utils.tools.ResponseResult;
12 12 import org.thingsboard.server.controller.BaseController;
13 13 import org.thingsboard.server.dao.yunteng.service.TkMailLogService;
  14 +import org.thingsboard.server.queue.util.TbCoreComponent;
14 15
15 16 import java.util.HashMap;
16 17
17 18 import static org.thingsboard.server.common.data.yunteng.constant.QueryConstant.*;
18 19
19 20 @RestController
  21 +@TbCoreComponent
20 22 @RequestMapping("api/yt/mail_log")
21 23 @RequiredArgsConstructor
22 24 public class TkMailLogController extends BaseController {
... ...
... ... @@ -10,8 +10,10 @@ import org.thingsboard.server.common.data.yunteng.dto.TkMapGeoJsonDTO;
10 10 import org.thingsboard.server.common.data.yunteng.enums.AreaLevelEnum;
11 11 import org.thingsboard.server.common.data.yunteng.utils.tools.ResponseResult;
12 12 import org.thingsboard.server.dao.yunteng.service.TkMapGeoJsonService;
  13 +import org.thingsboard.server.queue.util.TbCoreComponent;
13 14
14 15 @RestController
  16 +@TbCoreComponent
15 17 @RequestMapping("/api/yt/map/geo_json")
16 18 @RequiredArgsConstructor
17 19 @Api(tags = "行政区域经纬度信息")
... ...
... ... @@ -12,6 +12,7 @@ import org.thingsboard.server.common.data.yunteng.core.exception.TkDataValidatio
12 12 import org.thingsboard.server.common.data.yunteng.dto.MenuDTO;
13 13 import org.thingsboard.server.controller.BaseController;
14 14 import org.thingsboard.server.dao.yunteng.service.MenuService;
  15 +import org.thingsboard.server.queue.util.TbCoreComponent;
15 16
16 17 import java.net.URI;
17 18 import java.util.List;
... ... @@ -19,6 +20,7 @@ import java.util.Optional;
19 20 import java.util.Set;
20 21
21 22 @RestController
  23 +@TbCoreComponent
22 24 @RequiredArgsConstructor
23 25 @RequestMapping("api/yt/menu")
24 26 public class TkMenuController extends BaseController {
... ...
... ... @@ -17,6 +17,7 @@ import org.thingsboard.server.common.data.yunteng.utils.tools.ResponseResult;
17 17 import org.thingsboard.server.common.data.yunteng.utils.tools.TkPageData;
18 18 import org.thingsboard.server.controller.BaseController;
19 19 import org.thingsboard.server.dao.yunteng.service.TkMessageConfigService;
  20 +import org.thingsboard.server.queue.util.TbCoreComponent;
20 21
21 22 import java.util.HashMap;
22 23 import java.util.List;
... ... @@ -24,6 +25,7 @@ import java.util.List;
24 25 import static org.thingsboard.server.common.data.yunteng.constant.QueryConstant.*;
25 26
26 27 @RestController
  28 +@TbCoreComponent
27 29 @RequestMapping("api/yt/message")
28 30 @RequiredArgsConstructor
29 31 public class TkMessageConfigController extends BaseController {
... ...
... ... @@ -14,12 +14,14 @@ import org.thingsboard.server.common.data.yunteng.utils.tools.TkPageData;
14 14 import org.thingsboard.server.common.data.yunteng.utils.tools.ResponseResult;
15 15 import org.thingsboard.server.controller.BaseController;
16 16 import org.thingsboard.server.dao.yunteng.service.TkMessageLogService;
  17 +import org.thingsboard.server.queue.util.TbCoreComponent;
17 18
18 19 import java.util.HashMap;
19 20
20 21 import static org.thingsboard.server.common.data.yunteng.constant.QueryConstant.*;
21 22
22 23 @RestController
  24 +@TbCoreComponent
23 25 @RequestMapping("api/yt/message_log")
24 26 @RequiredArgsConstructor
25 27 public class TkMessageLogController extends BaseController {
... ...
... ... @@ -25,12 +25,14 @@ import org.thingsboard.server.controller.BaseController;
25 25 import org.thingsboard.server.dao.yunteng.service.TkMailService;
26 26 import org.thingsboard.server.dao.yunteng.service.TkMessageTemplateService;
27 27 import org.thingsboard.server.dao.yunteng.service.TkMessageService;
  28 +import org.thingsboard.server.queue.util.TbCoreComponent;
28 29
29 30 import java.util.HashMap;
30 31
31 32 import static org.thingsboard.server.common.data.yunteng.constant.QueryConstant.*;
32 33
33 34 @RestController
  35 +@TbCoreComponent
34 36 @RequestMapping("api/yt/template")
35 37 @RequiredArgsConstructor
36 38 public class TkMessageTemplateController extends BaseController {
... ...
... ... @@ -21,6 +21,7 @@ import org.thingsboard.server.common.data.yunteng.enums.ViewType;
21 21 import org.thingsboard.server.common.data.yunteng.utils.JacksonUtil;
22 22 import org.thingsboard.server.common.data.yunteng.utils.tools.ResponseResult;
23 23 import org.thingsboard.server.dao.yunteng.service.*;
  24 +import org.thingsboard.server.queue.util.TbCoreComponent;
24 25
25 26 import java.net.UnknownHostException;
26 27 import java.util.List;
... ... @@ -29,6 +30,7 @@ import java.util.Optional;
29 30 import static org.thingsboard.server.common.data.yunteng.constant.FastIotConstants.CHINA_MOBILE_PATTERN;
30 31
31 32 @RestController
  33 +@TbCoreComponent
32 34 @RequestMapping("api/yt/noauth")
33 35 @RequiredArgsConstructor
34 36 public class TkNoAuthController {
... ...
... ... @@ -18,6 +18,7 @@ import org.thingsboard.server.common.data.yunteng.enums.SysNoticeTypeEnum;
18 18 import org.thingsboard.server.common.data.yunteng.utils.tools.TkPageData;
19 19 import org.thingsboard.server.controller.BaseController;
20 20 import org.thingsboard.server.dao.yunteng.service.SysNoticeService;
  21 +import org.thingsboard.server.queue.util.TbCoreComponent;
21 22
22 23 import java.util.HashMap;
23 24 import java.util.Map;
... ... @@ -31,6 +32,7 @@ import static org.thingsboard.server.common.data.yunteng.constant.QueryConstant.
31 32 */
32 33 @Api(tags = "通知管理")
33 34 @RestController
  35 +@TbCoreComponent
34 36 @RequestMapping("api/yt/notice")
35 37 @RequiredArgsConstructor
36 38 public class TkNoticeController extends BaseController {
... ...
... ... @@ -12,6 +12,7 @@ import org.thingsboard.server.common.data.yunteng.enums.SysNoticeTypeEnum;
12 12 import org.thingsboard.server.common.data.yunteng.utils.tools.TkPageData;
13 13 import org.thingsboard.server.controller.BaseController;
14 14 import org.thingsboard.server.dao.yunteng.service.SysNoticeUserService;
  15 +import org.thingsboard.server.queue.util.TbCoreComponent;
15 16
16 17 import java.util.HashMap;
17 18 import java.util.Map;
... ... @@ -24,6 +25,7 @@ import static org.thingsboard.server.common.data.yunteng.constant.QueryConstant.
24 25 */
25 26 @Api(tags = "我的通知")
26 27 @RestController
  28 +@TbCoreComponent
27 29 @RequestMapping("api/yt/notice_user")
28 30 @RequiredArgsConstructor
29 31 public class TkNoticeUserController extends BaseController {
... ...
... ... @@ -16,10 +16,12 @@ import org.thingsboard.server.common.data.yunteng.utils.tools.TkPageData;
16 16 import org.thingsboard.server.controller.BaseController;
17 17 import org.thingsboard.server.dao.yunteng.entities.TkOpinionEntity;
18 18 import org.thingsboard.server.dao.yunteng.service.TkOpinionService;
  19 +import org.thingsboard.server.queue.util.TbCoreComponent;
19 20
20 21 import static org.thingsboard.server.common.data.yunteng.constant.QueryConstant.*;
21 22
22 23 @RestController
  24 +@TbCoreComponent
23 25 @RequestMapping("api/yt/opinion")
24 26 @Api(tags = {"意见反馈"})
25 27 @RequiredArgsConstructor
... ...
... ... @@ -16,12 +16,14 @@ import org.thingsboard.server.common.data.yunteng.dto.DeleteDTO;
16 16 import org.thingsboard.server.common.data.yunteng.dto.OrganizationDTO;
17 17 import org.thingsboard.server.controller.BaseController;
18 18 import org.thingsboard.server.dao.yunteng.service.TkOrganizationService;
  19 +import org.thingsboard.server.queue.util.TbCoreComponent;
19 20
20 21 import java.net.URI;
21 22 import java.util.List;
22 23 import java.util.Optional;
23 24
24 25 @RestController
  26 +@TbCoreComponent
25 27 @RequestMapping("api/yt/organization")
26 28 @Api(tags = "组织管理")
27 29 @RequiredArgsConstructor
... ...
... ... @@ -8,11 +8,13 @@ import org.thingsboard.server.common.data.yunteng.core.exception.TkDataValidatio
8 8 import org.thingsboard.server.common.data.yunteng.core.message.ErrorMessage;
9 9 import org.thingsboard.server.common.data.yunteng.core.utils.FileStorageService;
10 10 import org.thingsboard.server.common.data.yunteng.dto.FileUploadResponse;
  11 +import org.thingsboard.server.queue.util.TbCoreComponent;
11 12
12 13 import javax.servlet.http.HttpServletRequest;
13 14 import javax.servlet.http.HttpServletResponse;
14 15
15 16 @RestController
  17 +@TbCoreComponent
16 18 @RequestMapping("api/yt/oss")
17 19 public class TkOssFileController {
18 20
... ...
... ... @@ -12,6 +12,7 @@ import org.thingsboard.server.common.data.yunteng.dto.SysPlatformDesignDTO;
12 12 import org.thingsboard.server.common.data.yunteng.utils.tools.ResponseResult;
13 13 import org.thingsboard.server.controller.BaseController;
14 14 import org.thingsboard.server.dao.yunteng.service.SysPlatformDesignService;
  15 +import org.thingsboard.server.queue.util.TbCoreComponent;
15 16
16 17 /**
17 18 * @author: 徐浩然
... ... @@ -20,6 +21,7 @@ import org.thingsboard.server.dao.yunteng.service.SysPlatformDesignService;
20 21 */
21 22 @Api(tags = "平台定制")
22 23 @RestController
  24 +@TbCoreComponent
23 25 @RequestMapping("api/yt/platform")
24 26 @RequiredArgsConstructor
25 27 public class TkPlatformDesignController extends BaseController {
... ...
... ... @@ -22,6 +22,7 @@ import org.thingsboard.server.common.data.yunteng.utils.tools.ResponseResult;
22 22 import org.thingsboard.server.common.data.yunteng.utils.tools.TkPageData;
23 23 import org.thingsboard.server.controller.BaseController;
24 24 import org.thingsboard.server.dao.yunteng.service.TkReportFormConfigService;
  25 +import org.thingsboard.server.queue.util.TbCoreComponent;
25 26
26 27 import java.sql.Timestamp;
27 28 import java.util.HashMap;
... ... @@ -30,6 +31,7 @@ import static org.thingsboard.server.common.data.yunteng.constant.QueryConstant.
30 31 import static org.thingsboard.server.common.data.yunteng.constant.QueryConstant.ORDER_TYPE;
31 32
32 33 @RestController
  34 +@TbCoreComponent
33 35 @RequestMapping("api/yt/report_form/config")
34 36 @Api(tags = "报表配置信息")
35 37 @RequiredArgsConstructor
... ...
... ... @@ -24,6 +24,7 @@ import org.thingsboard.server.common.data.yunteng.utils.tools.TkPageData;
24 24 import org.thingsboard.server.controller.BaseController;
25 25 import org.thingsboard.server.dao.yunteng.service.TkReportFormConfigService;
26 26 import org.thingsboard.server.dao.yunteng.service.TkReportGenerateRecordService;
  27 +import org.thingsboard.server.queue.util.TbCoreComponent;
27 28
28 29 import java.sql.Timestamp;
29 30 import java.util.ArrayList;
... ... @@ -34,6 +35,7 @@ import java.util.Map;
34 35 import static org.thingsboard.server.common.data.yunteng.constant.QueryConstant.*;
35 36
36 37 @RestController
  38 +@TbCoreComponent
37 39 @RequestMapping("api/yt/report/generate/record")
38 40 @Api(tags = "报表生成记录")
39 41 @RequiredArgsConstructor
... ...
... ... @@ -14,6 +14,7 @@ import org.thingsboard.server.common.data.yunteng.enums.RoleEnum;
14 14 import org.thingsboard.server.common.data.yunteng.utils.tools.TkPageData;
15 15 import org.thingsboard.server.controller.BaseController;
16 16 import org.thingsboard.server.dao.yunteng.service.RoleService;
  17 +import org.thingsboard.server.queue.util.TbCoreComponent;
17 18
18 19 import java.util.HashMap;
19 20 import java.util.List;
... ... @@ -22,6 +23,7 @@ import java.util.Set;
22 23 import static org.thingsboard.server.common.data.yunteng.constant.QueryConstant.*;
23 24
24 25 @RestController
  26 +@TbCoreComponent
25 27 @RequestMapping("api/yt/role")
26 28 @RequiredArgsConstructor
27 29 public class TkRoleController extends BaseController {
... ...
... ... @@ -18,6 +18,7 @@ import org.thingsboard.server.common.data.yunteng.utils.tools.TkPageData;
18 18 import org.thingsboard.server.controller.BaseController;
19 19 import org.thingsboard.server.dao.yunteng.entities.TkRpcRecordEntity;
20 20 import org.thingsboard.server.dao.yunteng.service.TkRpcRecordService;
  21 +import org.thingsboard.server.queue.util.TbCoreComponent;
21 22
22 23 import java.sql.Timestamp;
23 24
... ... @@ -27,6 +28,7 @@ import static org.thingsboard.server.common.data.yunteng.constant.QueryConstant.
27 28 * @author Administrator
28 29 */
29 30 @RestController
  31 +@TbCoreComponent
30 32 @RequestMapping("api/yt/rpc")
31 33 @Api(tags = {"命令下发记录"})
32 34 @RequiredArgsConstructor
... ...
... ... @@ -8,11 +8,13 @@ import org.springframework.web.bind.annotation.RequestParam;
8 8 import org.springframework.web.bind.annotation.RestController;
9 9 import org.thingsboard.server.common.data.StringUtils;
10 10 import org.thingsboard.server.dao.yunteng.service.rtsp.TkFLVService;
  11 +import org.thingsboard.server.queue.util.TbCoreComponent;
11 12
12 13 import javax.servlet.http.HttpServletRequest;
13 14 import javax.servlet.http.HttpServletResponse;
14 15
15 16 @RestController
  17 +@TbCoreComponent
16 18 @RequestMapping("api/yt/rtsp")
17 19 @Api(tags = {"rtsp流转换"})
18 20 @RequiredArgsConstructor
... ...
... ... @@ -12,8 +12,10 @@ import org.thingsboard.server.common.data.id.TenantId;
12 12 import org.thingsboard.server.common.data.rule.RuleChainType;
13 13 import org.thingsboard.server.controller.BaseController;
14 14 import org.thingsboard.server.dao.yunteng.service.TkRuleChainService;
  15 +import org.thingsboard.server.queue.util.TbCoreComponent;
15 16
16 17 @RestController
  18 +@TbCoreComponent
17 19 @RequiredArgsConstructor
18 20 @RequestMapping("api/yt/rule_chain")
19 21 @Api(tags = {"规则链管理"})
... ...
... ... @@ -26,6 +26,7 @@ import org.thingsboard.server.controller.BaseController;
26 26 import org.thingsboard.server.controller.yunteng.aspect.annotation.AutoLog;
27 27 import org.thingsboard.server.dao.model.ModelConstants;
28 28 import org.thingsboard.server.dao.yunteng.service.SceneLinkageService;
  29 +import org.thingsboard.server.queue.util.TbCoreComponent;
29 30
30 31 import java.net.URI;
31 32 import java.util.*;
... ... @@ -35,6 +36,7 @@ import static org.thingsboard.server.common.data.yunteng.constant.QueryConstant.
35 36
36 37 /** @Description 场景联动 @Author cxy @Date 2021/11/25 11:25 */
37 38 @RestController
  39 +@TbCoreComponent
38 40 @RequestMapping("/api/yt/scene_linkage")
39 41 @RequiredArgsConstructor
40 42 @Api(tags = "场景联动")
... ...
... ... @@ -12,8 +12,10 @@ import org.thingsboard.server.common.data.yunteng.enums.ShareViewType;
12 12 import org.thingsboard.server.common.data.yunteng.utils.tools.ResponseResult;
13 13 import org.thingsboard.server.controller.BaseController;
14 14 import org.thingsboard.server.dao.yunteng.service.TkShareViewService;
  15 +import org.thingsboard.server.queue.util.TbCoreComponent;
15 16
16 17 @RestController
  18 +@TbCoreComponent
17 19 @RequiredArgsConstructor
18 20 @RequestMapping("api/yt/share")
19 21 @Api(tags = {"分享的视图"})
... ...
... ... @@ -17,10 +17,12 @@ import org.thingsboard.server.controller.BaseController;
17 17 import org.thingsboard.server.dao.model.ModelConstants;
18 18 import org.thingsboard.server.dao.yunteng.entities.SysLogEntity;
19 19 import org.thingsboard.server.dao.yunteng.service.TkSysLogService;
  20 +import org.thingsboard.server.queue.util.TbCoreComponent;
20 21
21 22 import static org.thingsboard.server.common.data.yunteng.constant.QueryConstant.*;
22 23
23 24 @RestController
  25 +@TbCoreComponent
24 26 @RequestMapping("api/yt/log")
25 27 @Api(tags = {"日志管理"})
26 28 @RequiredArgsConstructor
... ...
... ... @@ -22,6 +22,7 @@ import org.thingsboard.server.common.data.yunteng.utils.tools.ResponseResult;
22 22 import org.thingsboard.server.common.data.yunteng.utils.tools.TkPageData;
23 23 import org.thingsboard.server.controller.BaseController;
24 24 import org.thingsboard.server.dao.yunteng.service.TkTaskCenterService;
  25 +import org.thingsboard.server.queue.util.TbCoreComponent;
25 26
26 27 import java.util.HashMap;
27 28
... ... @@ -29,6 +30,7 @@ import static org.thingsboard.server.common.data.yunteng.constant.QueryConstant.
29 30 import static org.thingsboard.server.common.data.yunteng.constant.QueryConstant.ORDER_TYPE;
30 31
31 32 @RestController
  33 +@TbCoreComponent
32 34 @RequestMapping("api/yt/task_center")
33 35 @Api(tags = {"任务中心"})
34 36 @RequiredArgsConstructor
... ...
... ... @@ -15,12 +15,14 @@ import org.thingsboard.server.common.data.yunteng.dto.request.SendResetPasswordE
15 15 import org.thingsboard.server.common.data.yunteng.enums.MessageTypeEnum;
16 16 import org.thingsboard.server.dao.user.UserService;
17 17 import org.thingsboard.server.dao.yunteng.service.TkUserService;
  18 +import org.thingsboard.server.queue.util.TbCoreComponent;
18 19 import org.thingsboard.server.service.security.model.SecurityUser;
19 20 import org.thingsboard.server.service.security.system.SystemSecurityService;
20 21
21 22 import java.util.UUID;
22 23
23 24 @RestController
  25 +@TbCoreComponent
24 26 @RequestMapping("/api/yt/tenant")
25 27 public class TkTenantController extends AbstractUserAccount {
26 28
... ...
... ... @@ -18,6 +18,7 @@ import org.thingsboard.server.common.data.yunteng.utils.tools.ResponseResult;
18 18 import org.thingsboard.server.common.data.yunteng.utils.tools.TkPageData;
19 19 import org.thingsboard.server.controller.BaseController;
20 20 import org.thingsboard.server.dao.yunteng.service.TkTenantService;
  21 +import org.thingsboard.server.queue.util.TbCoreComponent;
21 22
22 23 import java.util.List;
23 24 import java.util.UUID;
... ... @@ -25,6 +26,7 @@ import java.util.UUID;
25 26 import static org.thingsboard.server.common.data.yunteng.constant.QueryConstant.*;
26 27
27 28 @RestController
  29 +@TbCoreComponent
28 30 @RequestMapping("/api/yt/tenant_profiles")
29 31 @RequiredArgsConstructor
30 32 public class TkTenantProfilesController extends BaseController {
... ...
... ... @@ -5,8 +5,10 @@ import org.springframework.web.bind.annotation.PostMapping;
5 5 import org.springframework.web.bind.annotation.RequestBody;
6 6 import org.springframework.web.bind.annotation.RequestMapping;
7 7 import org.springframework.web.bind.annotation.RestController;
  8 +import org.thingsboard.server.queue.util.TbCoreComponent;
8 9
9 10 @RestController
  11 +@TbCoreComponent
10 12 @RequestMapping("/api/yt/noauth/test")
11 13 public class TkTestController {
12 14 @PostMapping
... ...
... ... @@ -29,6 +29,7 @@ import org.thingsboard.server.dao.yunteng.entities.TkThirdUserEntity;
29 29 import org.thingsboard.server.dao.yunteng.service.TkTenantService;
30 30 import org.thingsboard.server.dao.yunteng.service.TkThirdPlatformService;
31 31 import org.thingsboard.server.dao.yunteng.service.TkUserService;
  32 +import org.thingsboard.server.queue.util.TbCoreComponent;
32 33 import org.thingsboard.server.service.security.auth.yunteng.TkLoginResponse;
33 34 import org.thingsboard.server.service.security.model.SecurityUser;
34 35 import org.thingsboard.server.service.security.model.UserPrincipal;
... ... @@ -45,6 +46,7 @@ import static org.thingsboard.server.common.data.yunteng.constant.QueryConstant.
45 46 * @author Administrator
46 47 */
47 48 @RestController
  49 +@TbCoreComponent
48 50 @RequestMapping("api/yt/third")
49 51 @Api(tags = {"第三方小程序"})
50 52 @RequiredArgsConstructor
... ...
... ... @@ -12,10 +12,12 @@ import org.thingsboard.server.common.data.yunteng.utils.tools.ResponseResult;
12 12 import org.thingsboard.server.controller.BaseController;
13 13 import org.thingsboard.server.dao.yunteng.entities.TkUserCollectEntity;
14 14 import org.thingsboard.server.dao.yunteng.service.TkUserCollectService;
  15 +import org.thingsboard.server.queue.util.TbCoreComponent;
15 16
16 17 import java.util.List;
17 18
18 19 @RestController
  20 +@TbCoreComponent
19 21 @RequiredArgsConstructor
20 22 @RequestMapping("api/yt/collect")
21 23 @Api(tags = {"收藏功能"})
... ...
... ... @@ -44,6 +44,7 @@ import org.thingsboard.server.common.data.yunteng.utils.tools.TkPageData;
44 44 import org.thingsboard.server.dao.user.UserService;
45 45 import org.thingsboard.server.dao.yunteng.entities.SysUserEntity;
46 46 import org.thingsboard.server.dao.yunteng.service.TkUserService;
  47 +import org.thingsboard.server.queue.util.TbCoreComponent;
47 48 import org.thingsboard.server.service.entitiy.customer.TbCustomerService;
48 49 import org.thingsboard.server.service.security.model.SecurityUser;
49 50 import org.thingsboard.server.service.security.permission.Operation;
... ... @@ -60,6 +61,7 @@ import java.util.UUID;
60 61 import static org.thingsboard.server.common.data.yunteng.constant.QueryConstant.*;
61 62
62 63 @RestController
  64 +@TbCoreComponent
63 65 @RequestMapping("api/yt/user")
64 66 @Api(value = "用户接口")
65 67 public class TkUserController extends AbstractUserAccount {
... ...
... ... @@ -22,6 +22,7 @@ import org.thingsboard.server.controller.BaseController;
22 22 import org.thingsboard.server.dao.yunteng.mapper.DeviceMapper;
23 23 import org.thingsboard.server.dao.yunteng.service.TkDeviceService;
24 24 import org.thingsboard.server.dao.yunteng.service.media.TkVideoChannelService;
  25 +import org.thingsboard.server.queue.util.TbCoreComponent;
25 26
26 27 import java.util.HashMap;
27 28 import java.util.List;
... ... @@ -30,6 +31,7 @@ import static org.thingsboard.server.common.data.yunteng.constant.QueryConstant.
30 31 import static org.thingsboard.server.common.data.yunteng.constant.QueryConstant.ORDER_TYPE;
31 32
32 33 @RestController
  34 +@TbCoreComponent
33 35 @RequestMapping("api/yt/video/channel")
34 36 @Api(tags = {"视频通道"})
35 37 @RequiredArgsConstructor
... ...
... ... @@ -19,6 +19,7 @@ import org.thingsboard.server.common.data.yunteng.utils.tools.TkPageData;
19 19 import org.thingsboard.server.controller.BaseController;
20 20 import org.thingsboard.server.dao.yunteng.entities.TkVideoEntity;
21 21 import org.thingsboard.server.dao.yunteng.service.TkVideoService;
  22 +import org.thingsboard.server.queue.util.TbCoreComponent;
22 23
23 24 import java.io.IOException;
24 25 import java.util.HashMap;
... ... @@ -28,6 +29,7 @@ import java.util.Map;
28 29 import static org.thingsboard.server.common.data.yunteng.constant.QueryConstant.*;
29 30
30 31 @RestController
  32 +@TbCoreComponent
31 33 @RequestMapping("api/yt/video")
32 34 @Api(tags = {"视频流"})
33 35 @RequiredArgsConstructor
... ...
... ... @@ -16,12 +16,14 @@ import org.thingsboard.server.common.data.yunteng.utils.tools.TkPageData;
16 16 import org.thingsboard.server.controller.BaseController;
17 17 import org.thingsboard.server.dao.yunteng.entities.TkVideoPlatformEntity;
18 18 import org.thingsboard.server.dao.yunteng.service.TkVideoPlatformService;
  19 +import org.thingsboard.server.queue.util.TbCoreComponent;
19 20
20 21 import java.util.List;
21 22
22 23 import static org.thingsboard.server.common.data.yunteng.constant.QueryConstant.*;
23 24
24 25 @RestController
  26 +@TbCoreComponent
25 27 @RequestMapping("api/yt/video/platform")
26 28 @Api(tags = {"流媒体平台配置"})
27 29 @RequiredArgsConstructor
... ...
... ... @@ -65,12 +65,14 @@ import org.thingsboard.server.common.data.page.PageData;
65 65 import org.thingsboard.server.common.data.page.PageLink;
66 66 import org.thingsboard.server.common.data.queue.Queue;
67 67 import org.thingsboard.server.common.data.relation.EntityRelation;
  68 +import org.thingsboard.server.common.data.script.ScriptLanguage;
68 69 import org.thingsboard.server.common.data.security.DeviceCredentials;
69 70 import org.thingsboard.server.common.data.security.DeviceCredentialsType;
70 71 import org.thingsboard.server.common.data.yunteng.common.media.VideoStreamSessionManager;
71 72 import org.thingsboard.server.common.data.yunteng.config.media.ZLMediaKitServerConfig;
72 73 import org.thingsboard.server.common.data.yunteng.constant.FastIotConstants;
73 74 import org.thingsboard.server.common.data.yunteng.core.cache.CacheUtils;
  75 +import org.thingsboard.server.common.data.yunteng.core.message.ErrorMessage;
74 76 import org.thingsboard.server.common.data.yunteng.dto.DeviceDTO;
75 77 import org.thingsboard.server.common.data.yunteng.dto.TkDeviceScriptDTO;
76 78 import org.thingsboard.server.common.data.yunteng.dto.sip.MediaServerDTO;
... ... @@ -158,7 +160,7 @@ public class DefaultTransportApiService implements TransportApiService {
158 160 //thingskit
159 161 private final CacheUtils cacheUtils;
160 162 private final TkDeviceService tkDeviceService;
161   - private final TkDeviceScriptService scriptService;
  163 + private final TkDeviceScriptService tkDeviceScriptService;
162 164 private final TkVideoChannelService channelService;
163 165 private final TkMediaServerNodeService mediaServerNodeService;
164 166 private final VideoStreamSessionManager videoStreamSessionManager;
... ... @@ -254,6 +256,10 @@ public class DefaultTransportApiService implements TransportApiService {
254 256 TransportProtos.ValidateTcpDeviceTokenRequestMsg msg = transportApiRequestMsg.getValidateTcpTokenRequestMsg();
255 257 final String token = msg.getToken();
256 258 result = handlerExecutor.submit(() -> validateTcpUdpCredentials(token, DeviceCredentialsType.ACCESS_TOKEN));
  259 + } else if(transportApiRequestMsg.hasUpScriptRequestMsg()){
  260 + result = handle(transportApiRequestMsg.getUpScriptRequestMsg());
  261 + } else if(transportApiRequestMsg.hasDataCombinationRequest()){
  262 + result = handle(transportApiRequestMsg.getDataCombinationRequest());
257 263 }
258 264
259 265 return Futures.transform(Optional.ofNullable(result).orElseGet(this::getEmptyTransportApiResponseFuture),
... ... @@ -833,25 +839,41 @@ public class DefaultTransportApiService implements TransportApiService {
833 839 }
834 840 // Thingskit function
835 841 private ListenableFuture<TransportApiResponseMsg> handle(TransportProtos.ScriptProto requestMsg) {
836   - List<TkDeviceScriptDTO> allScriptes = scriptService.getScriptes();
837   - TransportApiResponseMsg.Builder responseBuilder = TransportApiResponseMsg.newBuilder();
838   - allScriptes.forEach(
839   - item -> {
840   - UUID tenantId = UUID.fromString(item.getTenantId());
841   - UUID id = UUID.fromString(item.getId());
842   - responseBuilder.addScriptsResponseMsg(
843   - TransportProtos.ScriptProto.newBuilder()
844   - .setConvertJs(item.getConvertJs())
845   - .setTenantIdLSB(tenantId.getLeastSignificantBits())
846   - .setTenantIdMSB(tenantId.getMostSignificantBits())
847   - .setScriptIdLSB(id.getLeastSignificantBits())
848   - .setScriptIdMSB(id.getMostSignificantBits())
849   - .setFunctionType(item.getScriptType())
850   - .setStatus(item.getStatus()));
851   - });
  842 + List<TkDeviceScriptDTO> scriptDTOS = tkDeviceScriptService.findAllEnabledScript();
  843 + TransportApiResponseMsg.Builder responseBuilder = TransportApiResponseMsg.newBuilder();
  844 + if(null != scriptDTOS && !scriptDTOS.isEmpty()){
  845 + responseBuilder.addAllScriptResponseProto(scriptDTOS.stream().map(script->{
  846 + UUID uuid = UUID.fromString(script.getTenantId());
  847 + return TransportProtos.ScriptResponseProto.newBuilder().setTenantIdLSB(uuid.getLeastSignificantBits())
  848 + .setTenantIdMSB(uuid.getMostSignificantBits())
  849 + .setScriptId(script.getId())
  850 + .setScriptLanguage(script.getScriptLanguage().name())
  851 + .setScriptType(script.getScriptType())
  852 + .setContent(script.getScriptLanguage().equals(ScriptLanguage.TBEL)?
  853 + script.getConvertTbel():script.getConvertJs()).build();
  854 + }).collect(Collectors.toList())).build();
  855 + }
852 856 return Futures.immediateFuture(responseBuilder.build());
853 857 }
854 858
  859 + private ListenableFuture<TransportApiResponseMsg> handle(TransportProtos.DataCombinationMsg requestMsg){
  860 + try {
  861 + List<DeviceProfile> profiles = deviceProfileService.findByDataCombinationIsTrue().get();
  862 + if(null != profiles && !profiles.isEmpty()){
  863 + Map<String, Object> cacheMap = new HashMap<>();
  864 + for (DeviceProfile deviceProfile : profiles) {
  865 + cacheMap.put(deviceProfile.getTenantId() + "_" +
  866 + deviceProfile.getId().toString(),deviceProfile.getProfileData().getTransportConfiguration());
  867 + }
  868 + cacheUtils.put(FastIotConstants.CacheConfigKey.TCP_DATA_COMBINATION_KEY, FastIotConstants.OtherKey.DATA_COMBINATION_KEY,cacheMap);
  869 + }
  870 + }catch (Exception e){
  871 + log.error(ErrorMessage.CACHE_DATA_COMBINATION_FAILED.getMessage());
  872 + }
  873 + TransportApiResponseMsg.Builder responseBuilder = TransportApiResponseMsg.newBuilder();
  874 + return Futures.immediateFuture(responseBuilder.build());
  875 + }
  876 +
855 877 private ListenableFuture<TransportApiResponseMsg> handleGbt(
856 878 TransportProtos.Gbt28181RequestMsg requestMsg) {
857 879 TransportProtos.Gbt28181ResponseMsg.Builder responseMsgBuilder =
... ... @@ -1023,5 +1045,17 @@ public class DefaultTransportApiService implements TransportApiService {
1023 1045 }
1024 1046 return null;
1025 1047 }
1026   -
  1048 + //thingskit
  1049 + private ListenableFuture<TransportApiResponseMsg> handle(TransportProtos.UpScriptProto requestMsg){
  1050 + String upScriptId = requestMsg.getUpScriptId();
  1051 + TransportProtos.UpScriptResponseProto.Builder builder = TransportProtos.UpScriptResponseProto.newBuilder();
  1052 + if(StringUtils.isNotEmpty(upScriptId)){
  1053 + ScriptLanguage language = tkDeviceScriptService.findScriptLanguageById(upScriptId);
  1054 + builder.setScriptLanguage(null != language ? language.name():null);
  1055 + }
  1056 + return Futures.immediateFuture(
  1057 + TransportApiResponseMsg.newBuilder()
  1058 + .setUpScriptResponseMsg(builder.build())
  1059 + .build());
  1060 + }
1027 1061 }
... ...
... ... @@ -21,6 +21,8 @@ import org.thingsboard.server.common.data.validation.NoXss;
21 21 import org.thingsboard.server.common.data.yunteng.enums.ProtocolAnalysisEnum;
22 22 import org.thingsboard.server.common.data.yunteng.enums.TcpAuthTypeEnum;
23 23
  24 +import java.io.Serializable;
  25 +
24 26 @Data
25 27 public class TkTcpDeviceProfileTransportConfiguration implements DeviceProfileTransportConfiguration {
26 28 /**
... ... @@ -56,7 +58,8 @@ public class TkTcpDeviceProfileTransportConfiguration implements DeviceProfileTr
56 58 }
57 59
58 60 @Data
59   - public class DataCombinationAuth {
  61 + public class DataCombinationAuth implements Serializable {
  62 +
60 63 /**
61 64 * 数据截取开始的下标
62 65 */
... ...
... ... @@ -17,22 +17,4 @@ public interface TkCommonService {
17 17 * @return 返回字典Item表
18 18 */
19 19 SysDictItemDTO getDictValueByCodeAndText(String dictCode, String codeValue);
20   -
21   - /**
22   - * 获取所有数据携带的产品即设备配置
23   - * @return 产品列表
24   - */
25   - ListenableFuture<List<DeviceProfile>> findByDataCombinationIsTrue();
26   -
27   - /**
28   - * 根据脚本ID查询脚本使用的语言
29   - * @param scriptId 脚本ID
30   - * @return 脚本语言
31   - */
32   - ScriptLanguage getScriptLanguageById(String scriptId);
33   -
34   - /**
35   - * 启动所有的脚本
36   - */
37   - void evalAllEnabledScript();
38 20 }
... ...
... ... @@ -133,6 +133,7 @@ public class LocalFileStorageService implements FileStorageService {
133 133
134 134 @Override
135 135 public boolean deleteFile(String deleteFilePath) {
  136 + //TODO delete local file or delete datafile
136 137 return false;
137 138 }
138 139
... ...
... ... @@ -16,6 +16,7 @@ import org.springframework.util.StringUtils;
16 16 import org.springframework.web.context.request.RequestContextHolder;
17 17 import org.springframework.web.context.request.ServletRequestAttributes;
18 18 import org.springframework.web.multipart.MultipartFile;
  19 +import org.thingsboard.server.common.data.yunteng.constant.FastIotConstants;
19 20 import org.thingsboard.server.common.data.yunteng.core.exception.FileStorageException;
20 21 import org.thingsboard.server.common.data.yunteng.core.exception.TkDataValidationException;
21 22 import org.thingsboard.server.common.data.yunteng.core.message.ErrorMessage;
... ... @@ -177,7 +178,13 @@ public class MinioFileStorageService implements FileStorageService {
177 178 public boolean deleteFile(String deleteFilePath) {
178 179 boolean result =false;
179 180 try{
180   - minioClient.removeObject(RemoveObjectArgs.builder().bucket(fileStorageProperties.getBucketName())
  181 + String bucketName = fileStorageProperties.getBucketName();
  182 + int one = FastIotConstants.MagicNumber.ONE;
  183 + String[] split = deleteFilePath.split(bucketName + "/");
  184 + if(split.length>one){
  185 + deleteFilePath = split[one];
  186 + }
  187 + minioClient.removeObject(RemoveObjectArgs.builder().bucket(bucketName)
181 188 .object(deleteFilePath).build());
182 189 result = true;
183 190 }catch (Exception e){
... ...
... ... @@ -16,7 +16,8 @@ public class TkDataViewContentInfoDTO {
16 16 private Integer state;
17 17 @ApiModelProperty(value = "组织ID")
18 18 private String organizationId;
19   -
  19 + @ApiModelProperty(value = "缩略图")
  20 + private String thumbnail;
20 21 @ApiModelProperty(value = "大屏内容",required = true)
21 22 private TkDataViewContentDTO dataViewContent;
22 23 }
... ...
... ... @@ -1278,6 +1278,8 @@ message TransportApiRequestMsg {
1278 1278 Gbt28181RequestMsg gbt28181RequestMsg = 17;
1279 1279 Gbt28181MediaServerMsg gbt28181MediaServerMsg = 18;
1280 1280 ValidateTcpDeviceTokenRequestMsg validateTcpTokenRequestMsg = 19;
  1281 + UpScriptProto upScriptRequestMsg = 20;
  1282 + DataCombinationMsg dataCombinationRequest = 21;
1281 1283 }
1282 1284
1283 1285 /* Response from ThingsBoard Core Service to Transport Service */
... ... @@ -1294,9 +1296,10 @@ message TransportApiResponseMsg {
1294 1296 GetDeviceCredentialsResponseMsg deviceCredentialsResponseMsg = 10;
1295 1297 repeated GetQueueRoutingInfoResponseMsg getQueueRoutingInfoResponseMsgs = 11;
1296 1298 //Thingskit function
1297   - repeated ScriptProto scriptsResponseMsg = 12;
  1299 + UpScriptResponseProto upScriptResponseMsg = 12;
1298 1300 Gbt28181ResponseMsg gbt28181ResponseMsg = 13;
1299 1301 repeated Gbt28181MediaServerMsg gbt28181MediaServerMsg = 14;
  1302 + repeated ScriptResponseProto scriptResponseProto = 15;
1300 1303 }
1301 1304
1302 1305 /* Messages that are handled by ThingsBoard Core Service */
... ... @@ -1435,17 +1438,29 @@ message LifecycleEventProto {
1435 1438 string error = 8;
1436 1439 }
1437 1440
1438   -//Thingskit function 请求:functionType、;响应:tenantId、projectId、scriptId、convertJs
  1441 +//Thingskit function
  1442 +
  1443 +message DataCombinationMsg{
  1444 +
  1445 +}
  1446 +
1439 1447 message ScriptProto{
  1448 +
  1449 +}
  1450 +message ScriptResponseProto{
1440 1451 int64 tenantIdMSB = 1;
1441 1452 int64 tenantIdLSB = 2;
1442   -// int64 projectIdMSB = 3;
1443   -// int64 projectIdLSB = 4;
1444   - int64 scriptIdMSB = 3;
1445   - int64 scriptIdLSB = 4;
1446   - string functionType = 5;
1447   - string convertJs = 6;
1448   - int32 status = 7;
  1453 + string scriptId = 3;
  1454 + string scriptLanguage = 4;
  1455 + string scriptType = 5;
  1456 + string content = 6;
  1457 +
  1458 +}
  1459 +message UpScriptProto{
  1460 + string upScriptId = 1;
  1461 +}
  1462 +message UpScriptResponseProto{
  1463 + string scriptLanguage = 1;
1449 1464 }
1450 1465 //thingskit function 设备上报的物模型事件
1451 1466 message PostEventMsg {
... ...
1 1 /**
2 2 * Copyright © 2016-2022 The Thingsboard Authors
3 3 *
4   - * Licensed under the Apache License, Version 2.0 (the "License");
5   - * you may not use this file except in compliance with the License.
6   - * You may obtain a copy of the License at
  4 + * <p>Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
  5 + * except in compliance with the License. You may obtain a copy of the License at
7 6 *
8   - * http://www.apache.org/licenses/LICENSE-2.0
  7 + * <p>http://www.apache.org/licenses/LICENSE-2.0
9 8 *
10   - * Unless required by applicable law or agreed to in writing, software
11   - * distributed under the License is distributed on an "AS IS" BASIS,
12   - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   - * See the License for the specific language governing permissions and
  9 + * <p>Unless required by applicable law or agreed to in writing, software distributed under the
  10 + * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
  11 + * express or implied. See the License for the specific language governing permissions and
14 12 * limitations under the License.
15 13 */
16 14 package org.thingsboard.server.transport.tcp;
... ... @@ -24,140 +22,185 @@ import org.springframework.beans.factory.annotation.Value;
24 22 import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression;
25 23 import org.springframework.boot.context.event.ApplicationReadyEvent;
26 24 import org.springframework.context.event.EventListener;
27   -import org.springframework.core.annotation.Order;
28 25 import org.springframework.stereotype.Component;
29 26 import org.thingsboard.common.util.ThingsBoardThreadFactory;
  27 +import org.thingsboard.script.api.ScriptType;
30 28 import org.thingsboard.script.api.js.JsInvokeService;
31 29 import org.thingsboard.script.api.tbel.TbelInvokeService;
32   -import org.thingsboard.server.common.data.DeviceProfile;
33   -import org.thingsboard.server.common.data.yunteng.common.TkCommonService;
  30 +import org.thingsboard.server.common.data.id.TenantId;
  31 +import org.thingsboard.server.common.data.script.ScriptLanguage;
34 32 import org.thingsboard.server.common.data.yunteng.constant.FastIotConstants;
35 33 import org.thingsboard.server.common.data.yunteng.core.cache.CacheUtils;
36   -import org.thingsboard.server.common.data.yunteng.core.message.ErrorMessage;
  34 +import org.thingsboard.server.common.data.yunteng.dto.TkDeviceScriptDTO;
  35 +import org.thingsboard.server.common.data.yunteng.enums.StatusEnum;
37 36 import org.thingsboard.server.common.transport.TransportContext;
  37 +import org.thingsboard.server.common.transport.yunteng.ScriptUpdatedEvent;
  38 +import org.thingsboard.server.queue.util.AfterStartUp;
38 39 import org.thingsboard.server.transport.tcp.adaptors.JsonTcpAdaptor;
39 40
40 41 import javax.annotation.PostConstruct;
41 42 import java.net.InetSocketAddress;
42   -import java.util.HashMap;
  43 +
  44 +import org.thingsboard.server.gen.transport.TransportProtos;
  45 +
43 46 import java.util.List;
44   -import java.util.Map;
  47 +import java.util.Objects;
  48 +import java.util.UUID;
  49 +import java.util.concurrent.ExecutionException;
45 50 import java.util.concurrent.Executors;
46 51 import java.util.concurrent.ScheduledExecutorService;
47 52 import java.util.concurrent.TimeUnit;
48 53 import java.util.concurrent.atomic.AtomicInteger;
49 54
50   -/**
51   - * Created by ashvayka on 04.10.18.
52   - */
  55 +/** Created by ashvayka on 04.10.18. */
53 56 @Slf4j
54 57 @Component
55   -@ConditionalOnExpression("'${service.type:null}'=='tb-transport' || ('${service.type:null}'=='monolith' && '${transport.api_enabled:true}'=='true' && '${transport.tcp.enabled}'=='true')")
  58 +@ConditionalOnExpression(
  59 + "'${service.type:null}'=='tb-transport' || ('${service.type:null}'=='monolith' && '${transport.api_enabled:true}'=='true' && '${transport.tcp.enabled}'=='true')")
56 60 public class TcpTransportContext extends TransportContext {
57 61
58   - @Getter
59   - @Autowired(required = false)
60   - private TcpSslHandlerProvider sslHandlerProvider;
61   -
62   - /**注入多种数据协议处理器,例如:modbus等*/
63   - @Getter
64   - @Autowired
65   - private JsonTcpAdaptor jsonTcpAdaptor;
66   -
67   - @Getter
68   - @Autowired
69   - private JsInvokeService jsEngine;
70   -
71   - @Getter
72   - @Autowired
73   - private TbelInvokeService tbelInvokeService;
74   -
75   - @Getter
76   - @Autowired
77   - private CacheUtils cacheUtils;
78   -
79   - @Getter
80   - @Autowired
81   - private TkCommonService tkCommonService;
82   -
83   - @Getter
84   - @Value("${transport.tcp.netty.max_payload_size}")
85   - private Integer maxPayloadSize;
86   -
87   - @Getter
88   - @Value("${transport.tcp.ssl.skip_validity_check_for_client_cert:false}")
89   - private boolean skipValidityCheckForClientCert;
90   -
91   - @Getter
92   - @Setter
93   - private SslHandler sslHandler;
94   -
95   - @Getter
96   - @Value("${transport.tcp.msg_queue_size_per_device_limit:100}")
97   - private int messageQueueSizePerDeviceLimit;
98   -
99   - @Getter
100   - @Value("${transport.tcp.timeout:10000}")
101   - private long timeout;
102   -
103   - @Getter
104   - @Value("${transport.tcp.proxy_enabled:false}")
105   - private boolean proxyEnabled;
106   -
107   - private final AtomicInteger connectionsCounter = new AtomicInteger();
108   - protected ScheduledExecutorService schedulerExecutor;
109   - @Getter
110   - private boolean ready=false;
111   - @PostConstruct
112   - public void init() {
113   - super.init();
114   - transportService.createGaugeStats("openConnections", connectionsCounter);
115   - schedulerExecutor = Executors.newSingleThreadScheduledExecutor(ThingsBoardThreadFactory.forName("tcp-init"));
  62 + @Getter
  63 + @Autowired(required = false)
  64 + private TcpSslHandlerProvider sslHandlerProvider;
  65 +
  66 + /** 注入多种数据协议处理器,例如:modbus等 */
  67 + @Getter @Autowired private JsonTcpAdaptor jsonTcpAdaptor;
  68 +
  69 + @Getter @Autowired private JsInvokeService jsEngine;
  70 +
  71 + @Getter @Autowired private TbelInvokeService tbelInvokeService;
  72 +
  73 + @Getter @Autowired private CacheUtils cacheUtils;
  74 +
  75 + @Getter
  76 + @Value("${transport.tcp.netty.max_payload_size}")
  77 + private Integer maxPayloadSize;
  78 +
  79 + @Getter
  80 + @Value("${transport.tcp.ssl.skip_validity_check_for_client_cert:false}")
  81 + private boolean skipValidityCheckForClientCert;
  82 +
  83 + @Getter @Setter private SslHandler sslHandler;
  84 +
  85 + @Getter
  86 + @Value("${transport.tcp.msg_queue_size_per_device_limit:100}")
  87 + private int messageQueueSizePerDeviceLimit;
  88 +
  89 + @Getter
  90 + @Value("${transport.tcp.timeout:10000}")
  91 + private long timeout;
  92 +
  93 + @Getter
  94 + @Value("${transport.tcp.proxy_enabled:false}")
  95 + private boolean proxyEnabled;
  96 +
  97 + private final AtomicInteger connectionsCounter = new AtomicInteger();
  98 + protected ScheduledExecutorService schedulerExecutor;
  99 + @Getter private boolean ready = false;
  100 +
  101 + @PostConstruct
  102 + public void init() {
  103 + super.init();
  104 + transportService.createGaugeStats("openConnections", connectionsCounter);
  105 + schedulerExecutor =
  106 + Executors.newSingleThreadScheduledExecutor(ThingsBoardThreadFactory.forName("tcp-init"));
  107 + }
  108 +
  109 + public void channelRegistered() {
  110 + connectionsCounter.incrementAndGet();
  111 + }
  112 +
  113 + public void channelUnregistered() {
  114 + connectionsCounter.decrementAndGet();
  115 + }
  116 +
  117 + public boolean checkAddress(InetSocketAddress address) {
  118 + return rateLimitService.checkAddress(address);
  119 + }
  120 +
  121 + public void onAuthSuccess(InetSocketAddress address) {
  122 + rateLimitService.onAuthSuccess(address);
  123 + }
  124 +
  125 + public void onAuthFailure(InetSocketAddress address) {
  126 + rateLimitService.onAuthFailure(address);
  127 + }
  128 +
  129 + @EventListener(ApplicationReadyEvent.class)
  130 + @AfterStartUp(order = AfterStartUp.AFTER_TRANSPORT_SERVICE)
  131 + public void onApplicationEvent() {
  132 + String cacheName = FastIotConstants.CacheConfigKey.TCP_DATA_COMBINATION_KEY;
  133 + // 先清理掉数据携带的所有缓存
  134 + cacheUtils.invalidateCacheName(cacheName);
  135 + transportService.process(TransportProtos.DataCombinationMsg.newBuilder().build());
  136 + List<TransportProtos.ScriptResponseProto> protoList =
  137 + transportService.findAllEnabledScript(TransportProtos.ScriptProto.newBuilder().build());
  138 +
  139 + if (null != protoList && !protoList.isEmpty()) {
  140 + for (TransportProtos.ScriptResponseProto script : protoList) {
  141 + TenantId tbTenantId =
  142 + TenantId.fromUUID(new UUID(script.getTenantIdMSB(), script.getTenantIdLSB()));
  143 + String scriptId = script.getScriptId();
  144 + ScriptType scriptType = ScriptType.valueOf(script.getScriptType());
  145 + String content = script.getContent();
  146 + evalScript(
  147 + scriptId,
  148 + scriptType,
  149 + content,
  150 + ScriptLanguage.valueOf(script.getScriptLanguage()),
  151 + tbTenantId,
  152 + StatusEnum.ENABLE.getIndex());
  153 + }
116 154 }
117   -
118   - public void channelRegistered() {
119   - connectionsCounter.incrementAndGet();
120   - }
121   -
122   - public void channelUnregistered() {
123   - connectionsCounter.decrementAndGet();
124   - }
125   -
126   - public boolean checkAddress(InetSocketAddress address) {
127   - return rateLimitService.checkAddress(address);
128   - }
129   -
130   - public void onAuthSuccess(InetSocketAddress address) {
131   - rateLimitService.onAuthSuccess(address);
132   - }
133   -
134   - public void onAuthFailure(InetSocketAddress address) {
135   - rateLimitService.onAuthFailure(address);
136   - }
137   -
138   -
139   - @EventListener(ApplicationReadyEvent.class)
140   - @Order(value = 2)
141   - public void onApplicationEvent() {
142   - String cacheName = FastIotConstants.CacheConfigKey.TCP_DATA_COMBINATION_KEY;
143   - //先清理掉数据携带的所有缓存
144   - cacheUtils.invalidateCacheName(cacheName);
145   - try{
146   - //检查是否有数据携带的产品,如果有则进行缓存
147   - List<DeviceProfile> profiles = tkCommonService.findByDataCombinationIsTrue().get();
148   - if(null != profiles && !profiles.isEmpty()){
149   - Map<String, Object> cacheMap = new HashMap<>();
150   - for (DeviceProfile deviceProfile : profiles) {
151   - cacheMap.put(deviceProfile.getTenantId() + "_" +
152   - deviceProfile.getId().toString(),deviceProfile.getProfileData().getTransportConfiguration());
153   - }
154   - cacheUtils.put(cacheName, FastIotConstants.OtherKey.DATA_COMBINATION_KEY,cacheMap);
155   - }
156   - //获取所有启动的脚本,调用对应的脚本eval
157   - tkCommonService.evalAllEnabledScript();
158   - }catch (Exception e){
159   - log.error(ErrorMessage.CACHE_DATA_COMBINATION_FAILED.getMessage());
  155 + schedulerExecutor.schedule(() -> ready = true, timeout, TimeUnit.MILLISECONDS);
  156 + }
  157 +
  158 + @EventListener(ScriptUpdatedEvent.class)
  159 + public void onScriptUpdatedEvent(ScriptUpdatedEvent event) {
  160 + TkDeviceScriptDTO script = event.getScript();
  161 + TenantId tenantId = TenantId.fromUUID(UUID.fromString(script.getTenantId()));
  162 + String content =
  163 + Objects.equals(script.getScriptLanguage(), ScriptLanguage.JS)
  164 + ? script.getConvertJs()
  165 + : script.getConvertTbel();
  166 + evalScript(
  167 + script.getId(),
  168 + ScriptType.valueOf(script.getScriptType()),
  169 + content,
  170 + script.getScriptLanguage(),
  171 + tenantId,
  172 + script.getStatus());
  173 + }
  174 +
  175 + private void evalScript(
  176 + String scriptId,
  177 + ScriptType scriptType,
  178 + String content,
  179 + ScriptLanguage scriptLanguage,
  180 + TenantId tenantId,
  181 + Integer status) {
  182 + String[] argNames = new String[] {"msg", "metadata", "msgType"};
  183 + boolean enabled = status.equals(StatusEnum.ENABLE.getIndex());
  184 + String message = enabled ? "eval" : "release";
  185 + try {
  186 + if (Objects.equals(scriptLanguage, ScriptLanguage.JS)) {
  187 + if (enabled) {
  188 + jsEngine.eval(tenantId, UUID.fromString(scriptId), scriptType, content, argNames).get();
  189 + } else {
  190 + jsEngine.release(UUID.fromString(scriptId));
  191 + }
  192 + }
  193 + if (Objects.equals(scriptLanguage, ScriptLanguage.TBEL)) {
  194 + if (enabled) {
  195 + tbelInvokeService
  196 + .eval(tenantId, UUID.fromString(scriptId), scriptType, content, argNames)
  197 + .get();
  198 + } else {
  199 + tbelInvokeService.release(UUID.fromString(scriptId));
160 200 }
161   - schedulerExecutor.schedule(()->ready=true,timeout, TimeUnit.MILLISECONDS);
  201 + }
  202 + } catch (ExecutionException | InterruptedException e) {
  203 + log.error("脚本{}{}失败", message, scriptId);
162 204 }
  205 + }
163 206 }
... ...
... ... @@ -19,6 +19,7 @@ import org.thingsboard.server.common.data.id.TenantId;
19 19 import org.thingsboard.server.common.data.script.ScriptLanguage;
20 20 import org.thingsboard.server.common.data.yunteng.constant.FastIotConstants;
21 21 import org.thingsboard.server.common.data.yunteng.enums.ProtocolAnalysisEnum;
  22 +import org.thingsboard.server.common.transport.TransportServiceCallback;
22 23 import org.thingsboard.server.common.transport.auth.TransportDeviceInfo;
23 24 import org.thingsboard.server.common.transport.session.DeviceAwareSessionContext;
24 25 import org.thingsboard.server.gen.transport.TransportProtos;
... ... @@ -99,7 +100,18 @@ public abstract class TcpDeviceWareSessionContext extends DeviceAwareSessionCont
99 100 TkTcpDeviceProfileTransportConfiguration tcpConfiguration = (TkTcpDeviceProfileTransportConfiguration) transportConfiguration;
100 101 if( tcpConfiguration.getProtocol().equals(ProtocolAnalysisEnum.CUSTOM)){
101 102 this.telemetryScriptId = UUID.fromString(tcpConfiguration.getUpScriptId());
102   - this.scriptLanguage = context.getTkCommonService().getScriptLanguageById(tcpConfiguration.getUpScriptId());
  103 + getContext().getTransportService().process(sessionInfo, TransportProtos.UpScriptProto.newBuilder()
  104 + .setUpScriptId(tcpConfiguration.getUpScriptId()).build(), new TransportServiceCallback<TransportProtos.UpScriptResponseProto>() {
  105 + @Override
  106 + public void onSuccess(TransportProtos.UpScriptResponseProto msg) {
  107 + scriptLanguage = ScriptLanguage.valueOf(msg.getScriptLanguage());
  108 + }
  109 +
  110 + @Override
  111 + public void onError(Throwable e) {
  112 + log.error("通过上行脚本id获取脚本语言失败");
  113 + }
  114 + });
103 115 }
104 116
105 117 }
... ...
... ... @@ -164,7 +164,7 @@ public interface TransportService {
164 164 void createGaugeStats(String openConnections, AtomicInteger connectionsCounter);
165 165
166 166 // Thingskit function:begin
167   - List<TransportProtos.ScriptProto> getScripts(TransportProtos.ScriptProto msg);
  167 + List<TransportProtos.ScriptResponseProto> findAllEnabledScript(TransportProtos.ScriptProto msg);
168 168
169 169 void process(SessionInfoProto sessionInfo, TransportProtos.PostEventMsg msg, TransportServiceCallback<Void> callback,
170 170 String topicName);
... ... @@ -178,5 +178,10 @@ public interface TransportService {
178 178
179 179 void process(DeviceTransportType transportType, TransportProtos.ValidateTcpDeviceTokenRequestMsg msg,
180 180 TransportServiceCallback<ValidateDeviceCredentialsResponse> callback);
  181 +
  182 + void process(SessionInfoProto sessionInfoProto,TransportProtos.UpScriptProto msg,TransportServiceCallback<
  183 + TransportProtos.UpScriptResponseProto> callback);
  184 +
  185 + void process(TransportProtos.DataCombinationMsg msg);
181 186 // Thingskit function:end
182 187 }
... ...
... ... @@ -1329,22 +1329,20 @@ public class DefaultTransportService extends TransportActivityManager implements
1329 1329 }
1330 1330
1331 1331 // Thingskit function
1332   - @Override
1333   - public List<TransportProtos.ScriptProto> getScripts(TransportProtos.ScriptProto msg) {
1334   - TbProtoQueueMsg<TransportProtos.TransportApiRequestMsg> protoMsg =
1335   - new TbProtoQueueMsg<>(
1336   - UUID.randomUUID(),
1337   - TransportProtos.TransportApiRequestMsg.newBuilder().setScript(msg).build());
1338   - try {
1339   - TbProtoQueueMsg<TransportApiResponseMsg> response =
1340   - transportApiRequestTemplate.send(protoMsg).get();
1341   - return response.getValue().getScriptsResponseMsgList();
1342   - } catch (InterruptedException | ExecutionException e) {
1343   - throw new RuntimeException(e);
1344   - }
1345   - }
1346   -
1347   - // thingskit start
  1332 + @Override
  1333 + public List<TransportProtos.ScriptResponseProto> findAllEnabledScript(TransportProtos.ScriptProto msg){
  1334 + TbProtoQueueMsg<TransportProtos.TransportApiRequestMsg> protoMsg =
  1335 + new TbProtoQueueMsg<>(
  1336 + UUID.randomUUID(),
  1337 + TransportProtos.TransportApiRequestMsg.newBuilder().setScript(msg).build());
  1338 + try {
  1339 + TbProtoQueueMsg<TransportApiResponseMsg> response = transportApiRequestTemplate.send(protoMsg).get();
  1340 + return response.getValue().getScriptResponseProtoList();
  1341 + } catch (InterruptedException | ExecutionException e) {
  1342 + throw new RuntimeException(e);
  1343 + }
  1344 + }
  1345 + // thingskit start
1348 1346 @Override
1349 1347 public void process(
1350 1348 TransportProtos.SessionInfoProto sessionInfo,
... ... @@ -1390,5 +1388,23 @@ public class DefaultTransportService extends TransportActivityManager implements
1390 1388 TransportApiRequestMsg.newBuilder().setValidateTcpTokenRequestMsg(msg).build());
1391 1389 doProcess(transportType, protoMsg, callback);
1392 1390 }
  1391 + @Override
  1392 + public void process(TransportProtos.SessionInfoProto sessionInfo,TransportProtos.UpScriptProto msg,TransportServiceCallback<
  1393 + TransportProtos.UpScriptResponseProto> callback){
  1394 + TbProtoQueueMsg<TransportApiRequestMsg> protoMsg = new TbProtoQueueMsg<>(UUID.randomUUID(),
  1395 + TransportApiRequestMsg.newBuilder().setUpScriptRequestMsg(msg).build());
  1396 +
  1397 + AsyncCallbackTemplate.withCallback(transportApiRequestTemplate.send(protoMsg), response -> {
  1398 + callback.onSuccess(response.getValue().getUpScriptResponseMsg());
  1399 + }, callback::onError, transportCallbackExecutor);
  1400 + }
  1401 +
  1402 + @Override
  1403 + public void process(TransportProtos.DataCombinationMsg msg) {
  1404 + TbProtoQueueMsg<TransportProtos.TransportApiRequestMsg> protoMsg =
  1405 + new TbProtoQueueMsg<>(
  1406 + UUID.randomUUID(),TransportApiRequestMsg.newBuilder().setDataCombinationRequest(msg).build());
  1407 + transportApiRequestTemplate.send(protoMsg);
  1408 + }
1393 1409 // thingskit end
1394 1410 }
... ...
1 1 package org.thingsboard.server.dao.yunteng.impl;
2 2
3   -import com.google.common.util.concurrent.ListenableFuture;
4 3 import lombok.RequiredArgsConstructor;
5 4 import lombok.extern.slf4j.Slf4j;
6 5 import org.springframework.stereotype.Service;
7   -import org.thingsboard.server.common.data.DeviceProfile;
8   -import org.thingsboard.server.common.data.StringUtils;
9   -import org.thingsboard.server.common.data.script.ScriptLanguage;
10 6 import org.thingsboard.server.common.data.yunteng.common.TkCommonService;
11   -import org.thingsboard.server.common.data.yunteng.core.message.ErrorMessage;
12 7 import org.thingsboard.server.common.data.yunteng.dto.SysDictItemDTO;
13   -import org.thingsboard.server.common.data.yunteng.dto.TkDeviceScriptDTO;
14   -import org.thingsboard.server.dao.device.DeviceProfileService;
15 8 import org.thingsboard.server.dao.yunteng.mapper.SysDictItemMapper;
16   -import org.thingsboard.server.dao.yunteng.service.TkDeviceScriptService;
17   -
18   -import java.util.List;
19   -import java.util.Optional;
20   -import java.util.concurrent.CompletableFuture;
21 9
22 10 @Slf4j
23 11 @Service
24 12 @RequiredArgsConstructor
25 13 public class TkCommonServiceImpl implements TkCommonService {
26 14
27   - private final SysDictItemMapper sysDictItemMapper;
28   - private final DeviceProfileService deviceProfileService;
29   - private final TkDeviceScriptService tkDeviceScriptService;
30   - @Override
31   - public SysDictItemDTO getDictValueByCodeAndText(String dictCode, String codeValue) {
32   - return sysDictItemMapper.getDictValueByCodeAndText(dictCode, codeValue);
33   - }
34   -
35   - public ListenableFuture<List<DeviceProfile>> findByDataCombinationIsTrue(){
36   - return deviceProfileService.findByDataCombinationIsTrue();
37   - }
38   -
39   - @Override
40   - public ScriptLanguage getScriptLanguageById(String scriptId) {
41   - return tkDeviceScriptService.findScriptLanguageById(scriptId);
42   - }
  15 + private final SysDictItemMapper sysDictItemMapper;
43 16
44   - @Override
45   - public void evalAllEnabledScript() {
46   - List<TkDeviceScriptDTO> scriptDTOS = tkDeviceScriptService.findAllEnabledScript();
47   - if(null != scriptDTOS && !scriptDTOS.isEmpty()){
48   - for (TkDeviceScriptDTO scriptDTO : scriptDTOS){
49   - try {
50   - tkDeviceScriptService.eval(scriptDTO.getTenantId(),scriptDTO.getId());
51   - }catch (Exception e){
52   - log.error(String.format(ErrorMessage.SCRIPT_EVAL_FAILED.getMessage(),scriptDTO.getTenantId(),scriptDTO.getId(),e.getMessage()));
53   - }
54   - }
  17 + @Override
  18 + public SysDictItemDTO getDictValueByCodeAndText(String dictCode, String codeValue) {
  19 + return sysDictItemMapper.getDictValueByCodeAndText(dictCode, codeValue);
55 20 }
56   - }
57 21 }
... ...
1 1 package org.thingsboard.server.dao.yunteng.impl;
2 2
3   -
4 3 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
5 4 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
6 5 import com.baomidou.mybatisplus.core.metadata.IPage;
... ... @@ -12,7 +11,10 @@ import org.springframework.transaction.annotation.Transactional;
12 11 import org.thingsboard.script.api.ScriptType;
13 12 import org.thingsboard.script.api.js.JsInvokeService;
14 13 import org.thingsboard.script.api.tbel.TbelInvokeService;
  14 +import org.thingsboard.server.cluster.TbClusterService;
  15 +import org.thingsboard.server.common.data.DeviceProfile;
15 16 import org.thingsboard.server.common.data.device.profile.TkTcpDeviceProfileTransportConfiguration;
  17 +import org.thingsboard.server.common.data.id.DeviceProfileId;
16 18 import org.thingsboard.server.common.data.id.EntityId;
17 19 import org.thingsboard.server.common.data.id.TenantId;
18 20 import org.thingsboard.server.common.data.script.ScriptLanguage;
... ... @@ -26,6 +28,7 @@ import org.thingsboard.server.common.data.yunteng.enums.*;
26 28 import org.thingsboard.server.common.data.yunteng.utils.ByteUtils;
27 29 import org.thingsboard.server.common.data.yunteng.utils.CrcUtils;
28 30 import org.thingsboard.server.common.data.yunteng.utils.tools.TkPageData;
  31 +import org.thingsboard.server.dao.device.DeviceProfileService;
29 32 import org.thingsboard.server.dao.exception.DataValidationException;
30 33 import org.thingsboard.server.dao.yunteng.entities.TkDeviceScriptEntity;
31 34 import org.thingsboard.server.dao.yunteng.mapper.TkDeviceScriptMapper;
... ... @@ -48,6 +51,9 @@ public class TkDeviceScriptServiceImpl
48 51 private final TkDeviceService tkDeviceService;
49 52 private final JsInvokeService jsInvokeService;
50 53 private final TbelInvokeService tbelInvokeService;
  54 + private final TbClusterService tbClusterService;
  55 + private final DeviceProfileService deviceProfileService;
  56 + private final TkTenantService tenantService;
51 57
52 58 @Override
53 59 public boolean validateFormdata(TkDeviceScriptDTO scriptDTO, boolean created) {
... ... @@ -107,27 +113,31 @@ public class TkDeviceScriptServiceImpl
107 113 }
108 114
109 115 @Override
110   - public List<TkDeviceScriptDTO> getScriptes(){
  116 + public List<TkDeviceScriptDTO> getScriptes() {
111 117 LambdaQueryWrapper<TkDeviceScriptEntity> queryWrapper =
112 118 new QueryWrapper<TkDeviceScriptEntity>().lambda();
113 119 queryWrapper.eq(TkDeviceScriptEntity::getStatus, StatusEnum.ENABLE.getIndex());
114 120 List<TkDeviceScriptEntity> result = baseMapper.selectList(queryWrapper);
115 121 return result.stream()
116   - .map(item -> item.getDTO(TkDeviceScriptDTO.class))
117   - .collect(Collectors.toList());
  122 + .map(item -> item.getDTO(TkDeviceScriptDTO.class))
  123 + .collect(Collectors.toList());
118 124 }
119 125
120 126 @Override
121 127 public TkDeviceScriptDTO insertOrUpdate(TkDeviceScriptDTO deviceDTO) {
122   - //判断脚本的内容
123   - if(null == deviceDTO.getScriptLanguage()){
  128 + // 判断脚本的内容
  129 + if (null == deviceDTO.getScriptLanguage()) {
124 130 deviceDTO.setScriptLanguage(ScriptLanguage.JS);
125 131 }
126   - if(Objects.equals(ScriptLanguage.JS,deviceDTO.getScriptLanguage()) && StringUtils.isEmpty(deviceDTO.getConvertJs())){
127   - throw new DataValidationException(String.format(ErrorMessage.SCRIPT_CONTENT_IS_EMPTY.getMessage(),ScriptLanguage.JS));
  132 + if (Objects.equals(ScriptLanguage.JS, deviceDTO.getScriptLanguage())
  133 + && StringUtils.isEmpty(deviceDTO.getConvertJs())) {
  134 + throw new DataValidationException(
  135 + String.format(ErrorMessage.SCRIPT_CONTENT_IS_EMPTY.getMessage(), ScriptLanguage.JS));
128 136 }
129   - if(Objects.equals(ScriptLanguage.TBEL,deviceDTO.getScriptLanguage())&& StringUtils.isEmpty(deviceDTO.getConvertTbel())){
130   - throw new DataValidationException(String.format(ErrorMessage.SCRIPT_CONTENT_IS_EMPTY.getMessage(),ScriptLanguage.TBEL));
  137 + if (Objects.equals(ScriptLanguage.TBEL, deviceDTO.getScriptLanguage())
  138 + && StringUtils.isEmpty(deviceDTO.getConvertTbel())) {
  139 + throw new DataValidationException(
  140 + String.format(ErrorMessage.SCRIPT_CONTENT_IS_EMPTY.getMessage(), ScriptLanguage.TBEL));
131 141 }
132 142 if (StringUtils.isBlank(deviceDTO.getId())) {
133 143 return insert(deviceDTO);
... ... @@ -139,15 +149,17 @@ public class TkDeviceScriptServiceImpl
139 149 @Override
140 150 public void checkDeviceScriptes(String tenantId, Set<String> ids) {
141 151 // check if ids bind to device
142   - if(ids == null || ids.isEmpty()){
  152 + if (ids == null || ids.isEmpty()) {
143 153 throw new TkDataValidationException(ErrorMessage.INVALID_PARAMETER.getMessage());
144 154 }
145   - for(String id : ids){
146   - List<DeviceProfileDTO> profileList = tkDeviceProfileService.findDeviceProfileByScriptId(tenantId,id);
147   - if(null != profileList && !profileList.isEmpty()){
148   -
149   - throw new TkDataValidationException(String.format(ErrorMessage.PROJECT_USED_SCRIPT.getMessage(),
150   - profileList.get(0).getName()));
  155 + for (String id : ids) {
  156 + List<DeviceProfileDTO> profileList =
  157 + tkDeviceProfileService.findDeviceProfileByScriptId(tenantId, id);
  158 + if (null != profileList && !profileList.isEmpty()) {
  159 +
  160 + throw new TkDataValidationException(
  161 + String.format(
  162 + ErrorMessage.PROJECT_USED_SCRIPT.getMessage(), profileList.get(0).getName()));
151 163 }
152 164 }
153 165 }
... ... @@ -174,9 +186,13 @@ public class TkDeviceScriptServiceImpl
174 186 ModelConstants.TablePropertyMapping.UPDATER,
175 187 ModelConstants.TablePropertyMapping.CREATE_TIME,
176 188 ModelConstants.TablePropertyMapping.UPDATE_TIME);
177   - profile.setScriptType(null == deviceDTO.getScriptType() ?ScriptType.TRANSPORT_TCP_UP:ScriptType.valueOf(deviceDTO.getScriptType()));
  189 + profile.setScriptType(
  190 + null == deviceDTO.getScriptType()
  191 + ? ScriptType.TRANSPORT_TCP_UP
  192 + : ScriptType.valueOf(deviceDTO.getScriptType()));
178 193 baseMapper.insert(profile);
179   - return profile.getDTO(TkDeviceScriptDTO.class);
  194 + deviceDTO.setId(profile.getId());
  195 + return deviceDTO;
180 196 }
181 197
182 198 private TkDeviceScriptDTO update(TkDeviceScriptDTO deviceDTO) {
... ... @@ -192,9 +208,35 @@ public class TkDeviceScriptServiceImpl
192 208 ModelConstants.TablePropertyMapping.CREATE_TIME,
193 209 ModelConstants.TablePropertyMapping.UPDATE,
194 210 ModelConstants.TablePropertyMapping.UPDATE_TIME);
  211 + String tenantId = deviceDTO.getTenantId();
  212 + String scriptId = deviceDTO.getId();
  213 + Optional<TkDeviceScriptDTO> optional = getDeviceScript(tenantId, scriptId);
  214 + if (optional.isPresent()) {
  215 + TkDeviceScriptDTO deviceScriptDTO = optional.get();
  216 + // 如果脚本语言有更新,且有正在使用的产品,则需通知产品进行变更(脚本语言进行变更)
  217 + if (!Objects.equals(deviceScriptDTO.getScriptLanguage(), deviceDTO.getScriptLanguage())) {
  218 + // 查找正在使用的产品
  219 + List<DeviceProfileDTO> profiles =
  220 + tkDeviceProfileService.findDeviceProfileByScriptId(tenantId, scriptId);
  221 + if (null != profiles && !profiles.isEmpty()) {
  222 + for (DeviceProfileDTO dto : profiles) {
  223 + DeviceProfileId deviceProfileId =
  224 + new DeviceProfileId(UUID.fromString(dto.getTbProfileId()));
  225 + DeviceProfile deviceProfile =
  226 + deviceProfileService.findDeviceProfileById(
  227 + TenantId.fromUUID(UUID.fromString(tenantId)), deviceProfileId);
  228 + if (null != deviceProfile) {
  229 + tbClusterService.onDeviceProfileChange(deviceProfile, null);
  230 + }
  231 + }
  232 + }
  233 + }
  234 + }
195 235 baseMapper.updateById(device);
196 236 device.setTenantId(deviceDTO.getTenantId());
197   - return device.getDTO(TkDeviceScriptDTO.class);
  237 + TkDeviceScriptDTO updateScriptDTO = device.getDTO(TkDeviceScriptDTO.class);
  238 + updateScriptDTO.setScriptType(deviceDTO.getScriptType());
  239 + return updateScriptDTO;
198 240 }
199 241
200 242 @Override
... ... @@ -202,12 +244,23 @@ public class TkDeviceScriptServiceImpl
202 244 LambdaQueryWrapper<TkDeviceScriptEntity> queryWrapper =
203 245 new QueryWrapper<TkDeviceScriptEntity>()
204 246 .lambda()
205   - .eq(TkDeviceScriptEntity::getId, id).and(a -> a
206   - .eq(TkDeviceScriptEntity::getTenantId, tenantId).or(b->b.eq(TkDeviceScriptEntity::getTenantId,EntityId.NULL_UUID.toString())));
  247 + .eq(TkDeviceScriptEntity::getId, id)
  248 + .and(
  249 + a ->
  250 + a.eq(TkDeviceScriptEntity::getTenantId, tenantId)
  251 + .or(
  252 + b ->
  253 + b.eq(
  254 + TkDeviceScriptEntity::getTenantId,
  255 + EntityId.NULL_UUID.toString())));
207 256 TkDeviceScriptEntity profile = baseMapper.selectOne(queryWrapper);
208 257 return Optional.ofNullable(profile)
209 258 .map(
210   - entity -> entity.getDTO(TkDeviceScriptDTO.class));
  259 + entity -> {
  260 + TkDeviceScriptDTO dto = entity.getDTO(TkDeviceScriptDTO.class);
  261 + dto.setScriptType(entity.getScriptType().name());
  262 + return dto;
  263 + });
211 264 }
212 265
213 266 @Override
... ... @@ -224,11 +277,9 @@ public class TkDeviceScriptServiceImpl
224 277 .map(Object::toString)
225 278 .orElse(null);
226 279 String name = Optional.ofNullable(queryMap.get("name")).map(Object::toString).orElse(null);
227   - LocalDateTime startTime =
228   - (LocalDateTime) queryMap.get("startTime");
229   - LocalDateTime endTime =
230   - (LocalDateTime) queryMap.get("endTime");
231   - Integer status = null != queryMap.get("status") ? (Integer)queryMap.get("status") : null;
  280 + LocalDateTime startTime = (LocalDateTime) queryMap.get("startTime");
  281 + LocalDateTime endTime = (LocalDateTime) queryMap.get("endTime");
  282 + Integer status = null != queryMap.get("status") ? (Integer) queryMap.get("status") : null;
232 283 Set<String> scriptIds = null;
233 284 if (!isTenantAdmin && StringUtils.isNotEmpty(customerId)) {
234 285 scriptIds = getCustomerScripts(customerId, tenantId);
... ... @@ -240,7 +291,7 @@ public class TkDeviceScriptServiceImpl
240 291 new QueryWrapper<TkDeviceScriptEntity>()
241 292 .lambda()
242 293 .eq(TkDeviceScriptEntity::getTenantId, tenantId)
243   - .eq(null != status,TkDeviceScriptEntity::getStatus,status)
  294 + .eq(null != status, TkDeviceScriptEntity::getStatus, status)
244 295 .like(StringUtils.isNotEmpty(name), TkDeviceScriptEntity::getName, name)
245 296 .and(
246 297 null != startTime && null != endTime,
... ... @@ -258,14 +309,15 @@ public class TkDeviceScriptServiceImpl
258 309 }
259 310
260 311 @Override
261   - public List<TkDeviceScriptDTO> findDeviceScript(String tenantId, ScriptType scriptType,DeviceTypeEnum serviceType) {
  312 + public List<TkDeviceScriptDTO> findDeviceScript(
  313 + String tenantId, ScriptType scriptType, DeviceTypeEnum serviceType) {
262 314 LambdaQueryWrapper<TkDeviceScriptEntity> queryWrapper =
263 315 new QueryWrapper<TkDeviceScriptEntity>()
264 316 .lambda()
265   - .eq(TkDeviceScriptEntity::getStatus,StatusEnum.ENABLE.getIndex())
266   - .eq(scriptType!=null,TkDeviceScriptEntity::getScriptType, scriptType)
267   - .eq(serviceType!=null,TkDeviceScriptEntity::getServiceType,serviceType)
268   - .eq(TkDeviceScriptEntity::getTenantId, tenantId);
  317 + .eq(TkDeviceScriptEntity::getStatus, StatusEnum.ENABLE.getIndex())
  318 + .eq(scriptType != null, TkDeviceScriptEntity::getScriptType, scriptType)
  319 + .eq(serviceType != null, TkDeviceScriptEntity::getServiceType, serviceType)
  320 + .eq(TkDeviceScriptEntity::getTenantId, tenantId);
269 321 return baseMapper.selectList(queryWrapper).stream()
270 322 .map(item -> item.getDTO(TkDeviceScriptDTO.class))
271 323 .collect(Collectors.toList());
... ... @@ -289,15 +341,19 @@ public class TkDeviceScriptServiceImpl
289 341 .map(DeviceDTO::getDeviceProfileId)
290 342 .collect(Collectors.toList());
291 343 List<DeviceProfileDTO> deviceProfileDTOList =
292   - tkDeviceProfileService.findDeviceProfileByIds(tenantId, deviceProfiles, TransportTypeEnum.TCP);
  344 + tkDeviceProfileService.findDeviceProfileByIds(
  345 + tenantId, deviceProfiles, TransportTypeEnum.TCP);
293 346 return Optional.ofNullable(deviceProfileDTOList)
294 347 .map(
295   - deviceProfileDTOS ->{
  348 + deviceProfileDTOS -> {
296 349 Set<String> tcpScriptes = new HashSet<>();
297   - deviceProfileDTOS.forEach(p->{
298   - TkTcpDeviceProfileTransportConfiguration config = (TkTcpDeviceProfileTransportConfiguration) p.getProfileData().getTransportConfiguration();
299   - tcpScriptes.add(config.getUpScriptId());
300   - });
  350 + deviceProfileDTOS.forEach(
  351 + p -> {
  352 + TkTcpDeviceProfileTransportConfiguration config =
  353 + (TkTcpDeviceProfileTransportConfiguration)
  354 + p.getProfileData().getTransportConfiguration();
  355 + tcpScriptes.add(config.getUpScriptId());
  356 + });
301 357 return tcpScriptes;
302 358 })
303 359 .orElse(null);
... ... @@ -315,113 +371,154 @@ public class TkDeviceScriptServiceImpl
315 371 String functionCode = config.getMethod();
316 372 result.append(functionCode);
317 373 String addrStr = ByteUtils.integerToHex(config.getRegisterAddress());
318   - result.append(addrStr.substring(addrStr.length()-4));
  374 + result.append(addrStr.substring(addrStr.length() - 4));
319 375
320 376 List<Integer> values = config.getRegisterValues();
321   - Integer registerNum = config.getRegisterNumber()==null?1:config.getRegisterNumber();
322   - if(values ==null || values.isEmpty()){
323   - //读寄存器数据
  377 + Integer registerNum = config.getRegisterNumber() == null ? 1 : config.getRegisterNumber();
  378 + if (values == null || values.isEmpty()) {
  379 + // 读寄存器数据
324 380 result.append(modelHex(registerNum));
325   - }else if(values.size() == 1 &&(TkModBusFunctionCode.WRITE_ONE_COIL.getCode().equals(functionCode) || TkModBusFunctionCode.WRITE_ONE_REGISTER.getCode().equals(functionCode) )){
326   - //单个写入
  381 + } else if (values.size() == 1
  382 + && (TkModBusFunctionCode.WRITE_ONE_COIL.getCode().equals(functionCode)
  383 + || TkModBusFunctionCode.WRITE_ONE_REGISTER.getCode().equals(functionCode))) {
  384 + // 单个写入
327 385 result.append(modelHex(values.get(0)));
328   - }else{
329   - //多个写入
  386 + } else {
  387 + // 多个写入
330 388 result.append(modelHex(registerNum));
331   - result.append(multData(functionCode,values));
  389 + result.append(multData(functionCode, values));
332 390 }
333   - result.append(CrcUtils.getSendBuf(config.getCrc(),result.toString()));
334   -
  391 + result.append(CrcUtils.getSendBuf(config.getCrc(), result.toString()));
335 392
336 393 return result.toString();
337 394 }
338 395
339 396 @Override
340   - public void eval(String tenantId, String scriptId) throws ExecutionException, InterruptedException {
341   - TkDeviceScriptEntity entity = baseMapper.selectOne(new LambdaQueryWrapper<TkDeviceScriptEntity>()
342   - .eq(TkDeviceScriptEntity::getId,scriptId));
343   - if(null == entity){
  397 + public void eval(String tenantId, String scriptId)
  398 + throws ExecutionException, InterruptedException {
  399 + TkDeviceScriptEntity entity =
  400 + baseMapper.selectOne(
  401 + new LambdaQueryWrapper<TkDeviceScriptEntity>()
  402 + .eq(TkDeviceScriptEntity::getId, scriptId));
  403 + if (null == entity) {
344 404 throw new TkDataValidationException("脚本不存在");
345 405 }
346 406 TenantId tbTenantId = new TenantId(UUID.fromString(tenantId));
347 407 UUID scriptUUID = null;
348   - String[] argNames = new String[]{"msg", "metadata", "msgType"};
349   - if(Objects.equals(entity.getScriptLanguage(),ScriptLanguage.JS)){
350   - scriptUUID= jsInvokeService.eval(tbTenantId,UUID.fromString(scriptId),entity.getScriptType(),
351   - entity.getConvertJs(),argNames).get();
  408 + String[] argNames = new String[] {"msg", "metadata", "msgType"};
  409 + if (Objects.equals(entity.getScriptLanguage(), ScriptLanguage.JS)) {
  410 + scriptUUID =
  411 + jsInvokeService
  412 + .eval(
  413 + tbTenantId,
  414 + UUID.fromString(scriptId),
  415 + entity.getScriptType(),
  416 + entity.getConvertJs(),
  417 + argNames)
  418 + .get();
352 419 }
353   - if(Objects.equals(entity.getScriptLanguage(),ScriptLanguage.TBEL)){
354   - scriptUUID = tbelInvokeService.eval(tbTenantId,UUID.fromString(scriptId),entity.getScriptType(),
355   - entity.getConvertTbel(),argNames).get();
  420 + if (Objects.equals(entity.getScriptLanguage(), ScriptLanguage.TBEL)) {
  421 + scriptUUID =
  422 + tbelInvokeService
  423 + .eval(
  424 + tbTenantId,
  425 + UUID.fromString(scriptId),
  426 + entity.getScriptType(),
  427 + entity.getConvertTbel(),
  428 + argNames)
  429 + .get();
356 430 }
357 431 System.out.printf("UUID:" + scriptUUID.toString());
358 432 }
359 433
360 434 @Override
361 435 public void release(String tenantId, String scriptId) {
362   - TkDeviceScriptEntity entity = baseMapper.selectOne(new LambdaQueryWrapper<TkDeviceScriptEntity>()
363   - .eq(TkDeviceScriptEntity::getId,scriptId));
364   - if(null == entity){
  436 + TkDeviceScriptEntity entity =
  437 + baseMapper.selectOne(
  438 + new LambdaQueryWrapper<TkDeviceScriptEntity>()
  439 + .eq(TkDeviceScriptEntity::getId, scriptId));
  440 + if (null == entity) {
365 441 throw new TkDataValidationException("脚本不存在");
366 442 }
367   - if(Objects.equals(entity.getScriptLanguage(),ScriptLanguage.JS)){
  443 + if (Objects.equals(entity.getScriptLanguage(), ScriptLanguage.JS)) {
368 444 jsInvokeService.release(UUID.fromString(scriptId));
369 445 }
370   - if(Objects.equals(entity.getScriptLanguage(),ScriptLanguage.TBEL)){
  446 + if (Objects.equals(entity.getScriptLanguage(), ScriptLanguage.TBEL)) {
371 447 tbelInvokeService.release(UUID.fromString(scriptId));
372 448 }
373 449 }
374 450
375 451 @Override
376 452 public ScriptLanguage findScriptLanguageById(String scriptId) {
377   - return Optional.ofNullable(baseMapper.selectById(scriptId)).map(entity->entity.getScriptLanguage()).orElse(null);
  453 + return Optional.ofNullable(baseMapper.selectById(scriptId))
  454 + .map(entity -> entity.getScriptLanguage())
  455 + .orElse(null);
378 456 }
379 457
380 458 @Override
381 459 public List<TkDeviceScriptDTO> findAllEnabledScript() {
382   - List<TkDeviceScriptEntity> entities = baseMapper.selectList(new LambdaQueryWrapper<TkDeviceScriptEntity>().
383   - eq(TkDeviceScriptEntity::getStatus,StatusEnum.ENABLE.getIndex())
384   - .ne(TkDeviceScriptEntity::getTenantId,EntityId.NULL_UUID.toString()));
385   - return Optional.ofNullable(entities).map(objects-> objects.stream().map(entity->entity.getDTO(TkDeviceScriptDTO.class))
386   - .collect(Collectors.toList())).orElse(null);
  460 + //找到所有的租户
  461 + List<TenantDTO> tenants = tenantService.getAllTenant();
  462 + if(null == tenants || tenants.isEmpty()){
  463 + return null;
  464 + }
  465 + List<String> tenantIds = tenants.stream().map(entity->entity.getTenantId()).collect(Collectors.toList());
  466 + List<TkDeviceScriptEntity> entities =
  467 + baseMapper.selectList(
  468 + new LambdaQueryWrapper<TkDeviceScriptEntity>()
  469 + .eq(TkDeviceScriptEntity::getStatus, StatusEnum.ENABLE.getIndex())
  470 + .in(TkDeviceScriptEntity::getTenantId, tenantIds));
  471 + return Optional.ofNullable(entities)
  472 + .map(
  473 + objects ->
  474 + objects.stream()
  475 + .map(
  476 + entity -> {
  477 + TkDeviceScriptDTO scriptDTO = entity.getDTO(TkDeviceScriptDTO.class);
  478 + scriptDTO.setScriptType(entity.getScriptType().name());
  479 + return scriptDTO;
  480 + })
  481 + .collect(Collectors.toList()))
  482 + .orElse(null);
387 483 }
388 484
389   - private String modelHex(Integer max){
  485 + private String modelHex(Integer max) {
390 486 String addrStr = ByteUtils.integerToHex(max);
391   - return addrStr.substring(addrStr.length()-4);
  487 + return addrStr.substring(addrStr.length() - 4);
392 488 }
393 489
394   - private String dataLength(Integer max){
  490 + private String dataLength(Integer max) {
395 491 String addrStr = ByteUtils.integerToHex(max);
396   - return addrStr.substring(addrStr.length()-2);
  492 + return addrStr.substring(addrStr.length() - 2);
397 493 }
398   - private String multData(String functionCode,List<Integer>datas){
  494 +
  495 + private String multData(String functionCode, List<Integer> datas) {
399 496 StringBuilder dataStr = new StringBuilder();
400 497 int dataLength = datas.size();
401   - if(TkModBusFunctionCode.WRITE_MANY_REGISTER.getCode().equals(functionCode)){
402   - dataStr.append(dataLength(dataLength*2));
403   - for(Integer item: datas){
  498 + if (TkModBusFunctionCode.WRITE_MANY_REGISTER.getCode().equals(functionCode)) {
  499 + dataStr.append(dataLength(dataLength * 2));
  500 + for (Integer item : datas) {
404 501 dataStr.append(modelHex(item));
405 502 }
406   - }else{
  503 + } else {
407 504
408   - int residue = dataLength%8;
409   - int num = dataLength/8;
410   - dataStr.append(dataLength(residue == 0 ?num:num+1));
  505 + int residue = dataLength % 8;
  506 + int num = dataLength / 8;
  507 + dataStr.append(dataLength(residue == 0 ? num : num + 1));
411 508
412   - Integer wordVal=0;
413   - for(int dataIndex=0,wordIndex=0;dataIndex<dataLength;dataIndex++){
  509 + Integer wordVal = 0;
  510 + for (int dataIndex = 0, wordIndex = 0; dataIndex < dataLength; dataIndex++) {
414 511 Integer itemVal = datas.get(dataIndex);
415   - if(itemVal == 1){
  512 + if (itemVal == 1) {
416 513 byte one = 1;
417   - one<<=wordIndex;
418   - wordVal+=one;
  514 + one <<= wordIndex;
  515 + wordVal += one;
419 516 }
420   - if(dataIndex%8==7 || dataLength == dataIndex+1){
  517 + if (dataIndex % 8 == 7 || dataLength == dataIndex + 1) {
421 518 dataStr.append(ByteUtils.byteToHex(wordVal.byteValue()));
422   - wordVal=0;
423   - wordIndex=0;
424   - }else{
  519 + wordVal = 0;
  520 + wordIndex = 0;
  521 + } else {
425 522 wordIndex++;
426 523 }
427 524 }
... ...
... ... @@ -24,6 +24,7 @@
24 24
25 25 <resultMap id="dataViewInfoMap"
26 26 type="org.thingsboard.server.common.data.yunteng.dto.request.TkDataViewContentInfoDTO">
  27 + <result property="thumbnail" column="thumbnail"/>
27 28 <result property="dataViewId" column="id"/>
28 29 <result property="dataViewName" column="name"/>
29 30 <result property="state" column="state"/>
... ... @@ -61,7 +62,7 @@
61 62 </select>
62 63
63 64 <select id="getDataViewInfoById" resultMap="dataViewInfoMap">
64   - SELECT icc.id,icc.name,icc.state,icc.organization_id,icc.thumbnail,icct.id AS content_id,icct.content FROM tk_data_view icc LEFT JOIN
  65 + SELECT icc.id,icc.thumbnail,icc.name,icc.state,icc.organization_id,icc.thumbnail,icct.id AS content_id,icct.content FROM tk_data_view icc LEFT JOIN
65 66 tk_data_view_content icct ON icc.id = icct.view_id
66 67 WHERE icc.id = #{id} AND icc.tenant_id = #{tenantId}
67 68 </select>
... ...
... ... @@ -17,6 +17,7 @@ package org.thingsboard.server.gbt28181;
17 17
18 18 import org.springframework.boot.SpringApplication;
19 19 import org.springframework.boot.SpringBootConfiguration;
  20 +import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
20 21 import org.springframework.context.annotation.ComponentScan;
21 22 import org.springframework.scheduling.annotation.EnableAsync;
22 23 import org.springframework.scheduling.annotation.EnableScheduling;
... ... @@ -26,6 +27,7 @@ import java.util.Arrays;
26 27 @SpringBootConfiguration
27 28 @EnableAsync
28 29 @EnableScheduling
  30 +@EnableAutoConfiguration
29 31 @ComponentScan({"org.thingsboard.server.gbt28181", "org.thingsboard.server.common", "org.thingsboard.server.transport.gbt28181", "org.thingsboard.server.queue", "org.thingsboard.server.cache"})
30 32 public class ThingsboardGBT28181TransportApplication {
31 33
... ...
... ... @@ -17,6 +17,7 @@ package org.thingsboard.server.tcp;
17 17
18 18 import org.springframework.boot.SpringApplication;
19 19 import org.springframework.boot.SpringBootConfiguration;
  20 +import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
20 21 import org.springframework.context.annotation.ComponentScan;
21 22 import org.springframework.scheduling.annotation.EnableAsync;
22 23 import org.springframework.scheduling.annotation.EnableScheduling;
... ... @@ -26,7 +27,8 @@ import java.util.Arrays;
26 27 @SpringBootConfiguration
27 28 @EnableAsync
28 29 @EnableScheduling
29   -@ComponentScan({"org.thingsboard.server.tcp", "org.thingsboard.server.common", "org.thingsboard.server.transport.tcp", "org.thingsboard.server.transport.udp", "org.thingsboard.server.queue", "org.thingsboard.server.cache"})
  30 +@EnableAutoConfiguration
  31 +@ComponentScan({"org.thingsboard.server.tcp", "org.thingsboard.server.common", "org.thingsboard.server.transport.tcp", "org.thingsboard.server.queue", "org.thingsboard.server.cache","org.thingsboard.script.api"})
30 32 public class ThingsboardTcpTransportApplication {
31 33
32 34 private static final String SPRING_CONFIG_NAME_KEY = "--spring.config.name";
... ...