Commit 835b6cb21ce80c8a348bc047a97e66600a405477

Authored by lifeontrip
2 parents 513f557e de148a4e

Merge branch 'master' into 20220907

... ... @@ -9,18 +9,21 @@ import org.springframework.web.bind.annotation.*;
9 9 import org.thingsboard.server.common.data.exception.ThingsboardException;
10 10 import org.thingsboard.server.common.data.yunteng.core.exception.YtDataValidationException;
11 11 import org.thingsboard.server.common.data.yunteng.core.message.ErrorMessage;
  12 +import org.thingsboard.server.common.data.yunteng.dto.DataBoardDTO;
  13 +import org.thingsboard.server.common.data.yunteng.dto.DataComponentDTO;
12 14 import org.thingsboard.server.common.data.yunteng.dto.FrpInfoDTO;
  15 +import org.thingsboard.server.common.data.yunteng.dto.board.MoreDataComponentInfoDTO;
13 16 import org.thingsboard.server.common.data.yunteng.dto.request.AccountReqDTO;
14 17 import org.thingsboard.server.common.data.yunteng.enums.FrpPluginsEnum;
15 18 import org.thingsboard.server.common.data.yunteng.enums.MsgTemplatePurposeEnum;
16 19 import org.thingsboard.server.common.data.yunteng.enums.StatusEnum;
  20 +import org.thingsboard.server.common.data.yunteng.enums.ViewType;
17 21 import org.thingsboard.server.common.data.yunteng.utils.JacksonUtil;
18   -import org.thingsboard.server.controller.BaseController;
19   -import org.thingsboard.server.dao.yunteng.service.YtFrpInfoService;
20   -import org.thingsboard.server.dao.yunteng.service.YtSmsService;
21   -import org.thingsboard.server.dao.yunteng.service.YtUserService;
  22 +import org.thingsboard.server.common.data.yunteng.utils.tools.ResponseResult;
  23 +import org.thingsboard.server.dao.yunteng.service.*;
22 24
23 25 import java.net.UnknownHostException;
  26 +import java.util.List;
24 27 import java.util.Optional;
25 28
26 29 import static org.thingsboard.server.common.data.yunteng.constant.FastIotConstants.CHINA_MOBILE_PATTERN;
... ... @@ -28,11 +31,13 @@ import static org.thingsboard.server.common.data.yunteng.constant.FastIotConstan
28 31 @RestController
29 32 @RequestMapping("api/yt/noauth")
30 33 @RequiredArgsConstructor
31   -public class YtNoAuthController extends BaseController {
  34 +public class YtNoAuthController{
32 35
33 36 private final YtSmsService smsService;
34 37 private final YtUserService userService;
35 38 private final YtFrpInfoService frpInfoService;
  39 + private final YtDataComponentService ytDataComponentService;
  40 + private final YtDataBoardService ytDataBoardService;
36 41
37 42 @PostMapping("/sendLoginSmsCode/{phoneNumber}")
38 43 public boolean sendVerificationCode(@PathVariable("phoneNumber") String phoneNumber) {
... ... @@ -107,4 +112,24 @@ public class YtNoAuthController extends BaseController {
107 112 objectNode.put("unchange", true);
108 113 return objectNode;
109 114 }
  115 + @GetMapping("/share/dataBoard/{boardId}/{tenantId}")
  116 + @ApiOperation(value = "查询看板下的所有组件信息")
  117 + public ResponseResult<MoreDataComponentInfoDTO> getDataComponentsByBoardId(
  118 + @PathVariable("boardId") String boardId,@PathVariable("tenantId") String tenantId) throws ThingsboardException {
  119 + DataBoardDTO dto =
  120 + ytDataBoardService.findDataBoardInfoById(boardId, tenantId);
  121 + if (null == dto) {
  122 + throw new YtDataValidationException(ErrorMessage.NOT_BELONG_CURRENT_TENANT.getMessage());
  123 + }
  124 + if(dto.getViewType() == ViewType.PRIVATE_VIEW){
  125 + throw new YtDataValidationException(ErrorMessage.DATA_BOARD_IS_PRIVATE.getMessage());
  126 + }
  127 + MoreDataComponentInfoDTO moreDataComponentInfoDTO = new MoreDataComponentInfoDTO();
  128 + List<DataComponentDTO> data =
  129 + ytDataComponentService.getDataComponentsByBoardId(
  130 + tenantId, boardId);
  131 + moreDataComponentInfoDTO.setComponentLayout(dto.getLayout());
  132 + moreDataComponentInfoDTO.setComponentData(data);
  133 + return ResponseResult.success(moreDataComponentInfoDTO);
  134 + }
110 135 }
... ...
... ... @@ -23,7 +23,7 @@ public enum ErrorMessage {
23 23 PROVIDE_CORRECT_PHONE_NUMBER(400004,"请提供正确的电话号码"),
24 24 PROVIDE_CORRECT_EMAIL(400005,"请提供正确的邮箱"),
25 25 PHONE_NUMBER_OR_EMAIL_REQUIRED(400006,"必须提供电话或者邮箱"),
26   - NAME_ALREADY_EXISTS(400007,"名称已存在"),
  26 + NAME_ALREADY_EXISTS(400007,"名称已被使用"),
27 27 ROLE_IN_USE(400008,"该角色还存在用户使用"),
28 28 NONE_DEFAULT_RULE_CHAIN(400009,"该租户不存在默认的规则链"),
29 29 TENANT_MISMATCHING(400010,"租户不匹配"),
... ... @@ -67,7 +67,7 @@ public enum ErrorMessage {
67 67 VIDEO_PLATFORM_CONFIG_LACK(400047,"流媒体平台信息缺失"),
68 68 VIDEO_PLATFORM_CONFIG_ERROR(400048,"流媒体平台信息配置有误"),
69 69 VIDEO_PLATFORM_NEED_ENABLE_HLS_HTTPS(400049,"平台需开启https的hls协议"),
70   - NAME_EXISTED(400050,"名称【%s】已存在"),
  70 + NAME_EXISTED(400050,"名称【%s】已被使用"),
71 71 INVALID_PARAMETER_OR_NOT_MATCH_TENANT(400051,"参数错误或该条数据不属于当前租户"),
72 72 CRON_INVALID(400052,"cron表达式无效"),
73 73 EXPORT_CONFIG_NON_EXISTENT(400053,"报表配置不存在或已被删除"),
... ... @@ -75,6 +75,7 @@ public enum ErrorMessage {
75 75 START_TIME_OR_END_TIME_EXCEPTION(400055,"开始时间或结束时间异常"),
76 76 TARGET_TEMPLATE_NOT_EXISTS_SELF_NOTICE(400056,"密码重置成功,请自行通知用户!"),
77 77 ASSERT_DEFAULT_NAME_NO_CHANGED(400056,"系统预制资源,不能修改名称!"),
  78 + DATA_BOARD_IS_PRIVATE(400057,"该数据看板不是公有视图"),
78 79 HAVE_NO_PERMISSION(500002,"没有修改权限");
79 80 private final int code;
80 81 private String message;
... ...
... ... @@ -20,9 +20,6 @@ public class DataBoardDTO extends TenantDTO {
20 20 @ApiModelProperty(value = "视图类型")
21 21 private ViewType viewType = ViewType.PRIVATE_VIEW;
22 22
23   - @ApiModelProperty(value = "公有视图URL")
24   - private String openUrl;
25   -
26 23 @ApiModelProperty(value = "组件布局")
27 24 private List<ComponentLayoutDTO> layout;
28 25
... ...
... ... @@ -19,6 +19,15 @@ public class DataSourceInfoDTO implements Serializable {
19 19 @ApiModelProperty(value = "属性", required = true)
20 20 private String attribute;
21 21
  22 + @ApiModelProperty(value = "设备名称")
  23 + private String deviceName;
  24 +
  25 + @ApiModelProperty(value = "是否网关设备")
  26 + private boolean gatewayDevice = false;
  27 +
  28 + @ApiModelProperty(value = "子设备ID")
  29 + private String slaveDeviceId;
  30 +
22 31 @ApiModelProperty(value = "设备重命名")
23 32 private String deviceRename;
24 33
... ...
... ... @@ -36,6 +36,8 @@ import org.thingsboard.server.common.data.id.DeviceProfileId;
36 36 import org.thingsboard.server.common.data.id.TenantId;
37 37 import org.thingsboard.server.common.data.page.PageData;
38 38 import org.thingsboard.server.common.data.page.PageLink;
  39 +import org.thingsboard.server.common.data.yunteng.core.exception.YtDataValidationException;
  40 +import org.thingsboard.server.common.data.yunteng.core.message.ErrorMessage;
39 41 import org.thingsboard.server.dao.entity.AbstractEntityService;
40 42 import org.thingsboard.server.dao.exception.DataValidationException;
41 43 import org.thingsboard.server.dao.service.DataValidator;
... ... @@ -112,7 +114,7 @@ public class DeviceProfileServiceImpl extends AbstractEntityService implements D
112 114 } catch (Exception t) {
113 115 ConstraintViolationException e = extractConstraintViolationException(t).orElse(null);
114 116 if (e != null && e.getConstraintName() != null && e.getConstraintName().equalsIgnoreCase("device_profile_name_unq_key")) {
115   - throw new DataValidationException("Device profile with such name already exists!");
  117 + throw new YtDataValidationException(ErrorMessage.NAME_ALREADY_EXISTS.getMessage());
116 118 } else if (e != null && e.getConstraintName() != null && e.getConstraintName().equalsIgnoreCase("device_provision_key_unq_key")) {
117 119 throw new DataValidationException("Device profile with such provision device key already exists!");
118 120 } else {
... ...
... ... @@ -22,8 +22,6 @@ public class DataBoard extends TenantBaseEntity {
22 22 @TableField(typeHandler = EnumTypeHandler.class)
23 23 private ViewType viewType;
24 24
25   - private String openUrl;
26   -
27 25 @TableField(typeHandler = JacksonTypeHandler.class)
28 26 private JsonNode layout;
29 27
... ...
... ... @@ -174,7 +174,7 @@ public class HomePageServiceImpl implements HomePageService {
174 174 }else{
175 175 totalExpired.getAndIncrement();
176 176 }
177   - if(endTime.isAfter(customer.getUpdateTime()) && startTime.isBefore(customer.getUpdateTime())){
  177 + if(customer.getUpdateTime() != null && endTime.isAfter(customer.getUpdateTime()) && startTime.isBefore(customer.getUpdateTime())){
178 178 totalActivity.incrementAndGet();
179 179 }
180 180
... ...
... ... @@ -380,8 +380,8 @@
380 380 <select id="findDeviceKeys" resultType="string">
381 381 SELECT
382 382 DISTINCT base.key as keyName
383   - FROM ts_kv_latest latest
384   - LEFT JOIN ts_kv_dictionary base ON latest.key = base.key_id
  383 + FROM ts_kv_dictionary base
  384 + LEFT JOIN ts_kv_latest latest ON latest.key = base.key_id
385 385 LEFT JOIN device tb ON tb.ID = latest.entity_id
386 386 LEFT JOIN iotfs_device iot ON tb.ID :: TEXT = iot.tb_device_id
387 387 <where>
... ...