Commit 48ffe9968ca3f76b7022123972e96816f80ecdd3
Merge branch 'ljl1216' into 'master'
fix: 设备相关 See merge request huang/thingsboard3.3.2!16
Showing
6 changed files
with
32 additions
and
11 deletions
@@ -73,4 +73,5 @@ public class DeviceDTO extends TenantDTO { | @@ -73,4 +73,5 @@ public class DeviceDTO extends TenantDTO { | ||
73 | /** 告警状态:0:正常 1:告警 */ | 73 | /** 告警状态:0:正常 1:告警 */ |
74 | @ApiModelProperty(value="告警状态:0正常,1告警") | 74 | @ApiModelProperty(value="告警状态:0正常,1告警") |
75 | private Integer alarmStatus; | 75 | private Integer alarmStatus; |
76 | + private String description; | ||
76 | } | 77 | } |
@@ -31,7 +31,7 @@ public class DeviceProfileDTO extends TenantDTO { | @@ -31,7 +31,7 @@ public class DeviceProfileDTO extends TenantDTO { | ||
31 | @NotEmpty(message = "传输协议不能为空或者空字符串", groups = AddGroup.class) | 31 | @NotEmpty(message = "传输协议不能为空或者空字符串", groups = AddGroup.class) |
32 | @ApiModelProperty(value = "传输协议", required = true) | 32 | @ApiModelProperty(value = "传输协议", required = true) |
33 | @NotEmpty(message = "传输协议不能为空或者二空字符串") | 33 | @NotEmpty(message = "传输协议不能为空或者二空字符串") |
34 | - private DeviceTransportType transportType; | 34 | + private String transportType; |
35 | /** | 35 | /** |
36 | * TB的设备配置文件 | 36 | * TB的设备配置文件 |
37 | */ | 37 | */ |
@@ -58,7 +58,7 @@ public class DeviceProfileDTO extends TenantDTO { | @@ -58,7 +58,7 @@ public class DeviceProfileDTO extends TenantDTO { | ||
58 | setCreateTime(LocalDateTime.ofInstant(Instant.ofEpochMilli(time), ZoneOffset.UTC)); | 58 | setCreateTime(LocalDateTime.ofInstant(Instant.ofEpochMilli(time), ZoneOffset.UTC)); |
59 | this.name = name; | 59 | this.name = name; |
60 | this.description = description; | 60 | this.description = description; |
61 | - this.transportType = transportType; | 61 | + this.transportType = transportType.name(); |
62 | this.defaultRuleChainId = Optional.ofNullable(defaultRuleChainId).map(chainId -> chainId.toString()).orElse(null); | 62 | this.defaultRuleChainId = Optional.ofNullable(defaultRuleChainId).map(chainId -> chainId.toString()).orElse(null); |
63 | } | 63 | } |
64 | 64 | ||
@@ -68,7 +68,7 @@ public class DeviceProfileDTO extends TenantDTO { | @@ -68,7 +68,7 @@ public class DeviceProfileDTO extends TenantDTO { | ||
68 | this.name = name; | 68 | this.name = name; |
69 | this.description = description; | 69 | this.description = description; |
70 | this.convertJs = convertJs; | 70 | this.convertJs = convertJs; |
71 | - this.transportType = transportType; | 71 | + this.transportType = transportType.name(); |
72 | this.defaultRuleChainId = defaultRuleChainId.toString(); | 72 | this.defaultRuleChainId = defaultRuleChainId.toString(); |
73 | this.profileData = profileData; | 73 | this.profileData = profileData; |
74 | } | 74 | } |
@@ -38,4 +38,5 @@ public class YtDevice extends TenantBaseEntity { | @@ -38,4 +38,5 @@ public class YtDevice extends TenantBaseEntity { | ||
38 | private String organizationId; | 38 | private String organizationId; |
39 | /** 告警状态:0:正常 1:告警 */ | 39 | /** 告警状态:0:正常 1:告警 */ |
40 | private Integer alarmStatus; | 40 | private Integer alarmStatus; |
41 | + private String description; | ||
41 | } | 42 | } |
@@ -241,12 +241,7 @@ public class YtDeviceServiceImpl extends AbstractBaseService<DeviceMapper, YtDev | @@ -241,12 +241,7 @@ public class YtDeviceServiceImpl extends AbstractBaseService<DeviceMapper, YtDev | ||
241 | @Override | 241 | @Override |
242 | public Optional<DeviceDTO> getDevice(String tenantId,String id) { | 242 | public Optional<DeviceDTO> getDevice(String tenantId,String id) { |
243 | return Optional.ofNullable( | 243 | return Optional.ofNullable( |
244 | - baseMapper.selectOne( | ||
245 | - new QueryWrapper<YtDevice>() | ||
246 | - .lambda() | ||
247 | - .eq(YtDevice::getTenantId, tenantId) | ||
248 | - .eq(YtDevice::getId, id))) | ||
249 | - .map(device -> device.getDTO(DeviceDTO.class)); | 244 | + baseMapper.selectDetail(tenantId,id)); |
250 | } | 245 | } |
251 | 246 | ||
252 | @Override | 247 | @Override |
@@ -15,4 +15,6 @@ public interface DeviceMapper extends BaseMapper<YtDevice> { | @@ -15,4 +15,6 @@ public interface DeviceMapper extends BaseMapper<YtDevice> { | ||
15 | 15 | ||
16 | IPage<DeviceDTO> getDevicePage( | 16 | IPage<DeviceDTO> getDevicePage( |
17 | IPage<?> page, @Param("queryMap") Map<String, Object> queryMap); | 17 | IPage<?> page, @Param("queryMap") Map<String, Object> queryMap); |
18 | + | ||
19 | + DeviceDTO selectDetail(@Param("tenantId") String tenantId,@Param("id") String id); | ||
18 | } | 20 | } |
@@ -21,22 +21,26 @@ | @@ -21,22 +21,26 @@ | ||
21 | <result property="updateTime" column="update_time"/> | 21 | <result property="updateTime" column="update_time"/> |
22 | <result property="creator" column="creator"/> | 22 | <result property="creator" column="creator"/> |
23 | <result property="updater" column="updater"/> | 23 | <result property="updater" column="updater"/> |
24 | + <result property="description" column="description"/> | ||
24 | <result property="organizationId" column="organization_id"/> | 25 | <result property="organizationId" column="organization_id"/> |
25 | <association property="deviceProfile" javaType="org.thingsboard.server.common.data.yunteng.dto.DeviceProfileDTO"> | 26 | <association property="deviceProfile" javaType="org.thingsboard.server.common.data.yunteng.dto.DeviceProfileDTO"> |
26 | <result property="name" column="profile_name"/> | 27 | <result property="name" column="profile_name"/> |
28 | + <result property="transportType" column="transport_type"/> | ||
27 | </association> | 29 | </association> |
28 | <association property="organizationDTO" javaType="org.thingsboard.server.common.data.yunteng.dto.OrganizationDTO"> | 30 | <association property="organizationDTO" javaType="org.thingsboard.server.common.data.yunteng.dto.OrganizationDTO"> |
29 | <result property="name" column="organization_name"/> | 31 | <result property="name" column="organization_name"/> |
30 | </association> | 32 | </association> |
31 | </resultMap> | 33 | </resultMap> |
32 | <sql id="columns"> | 34 | <sql id="columns"> |
33 | - ifd.id,ifd.name,ifd.device_info,ifd.profile_id,ifd.active_time,ifd.device_token,ifd.tenant_id | 35 | + ifd.id,ifd.name,ifd.device_info,ifd.profile_id,ifd.active_time,ifd.device_token,ifd.tenant_id,ifd.description |
34 | ,ifd.tb_device_id,ifd.label,ifd.last_connect_time,ifd.device_type,ifd.device_state,ifd.create_time,ifd.update_time,ifd.creator, | 36 | ,ifd.tb_device_id,ifd.label,ifd.last_connect_time,ifd.device_type,ifd.device_state,ifd.create_time,ifd.update_time,ifd.creator, |
35 | ifd.updater,ifd.organization_id,ifd,alarm_status | 37 | ifd.updater,ifd.organization_id,ifd,alarm_status |
38 | + ,ifdp.name AS profile_name,ifdp.transport_type | ||
39 | + ,io.name AS organization_name | ||
36 | </sql> | 40 | </sql> |
37 | <select id="getDevicePage" resultMap="deviceMap"> | 41 | <select id="getDevicePage" resultMap="deviceMap"> |
38 | SELECT | 42 | SELECT |
39 | - <include refid="columns"/>,ifdp.name AS profile_name,io.name AS organization_name | 43 | + <include refid="columns"/> |
40 | FROM iotfs_device ifd | 44 | FROM iotfs_device ifd |
41 | LEFT JOIN device_profile ifdp ON ifd.profile_id = CAST (ifdp.id AS VARCHAR) | 45 | LEFT JOIN device_profile ifdp ON ifd.profile_id = CAST (ifdp.id AS VARCHAR) |
42 | LEFT JOIN iotfs_organization io ON io.id = ifd.organization_id | 46 | LEFT JOIN iotfs_organization io ON io.id = ifd.organization_id |
@@ -67,4 +71,22 @@ | @@ -67,4 +71,22 @@ | ||
67 | </if> | 71 | </if> |
68 | </where> | 72 | </where> |
69 | </select> | 73 | </select> |
74 | + | ||
75 | + | ||
76 | + <select id="selectDetail" resultMap="deviceMap"> | ||
77 | + SELECT | ||
78 | + <include refid="columns"/> | ||
79 | + FROM iotfs_device ifd | ||
80 | + LEFT JOIN device_profile ifdp ON ifd.profile_id = CAST (ifdp.id AS VARCHAR) | ||
81 | + LEFT JOIN iotfs_organization io ON io.id = ifd.organization_id | ||
82 | + <where> | ||
83 | + <if test="tenantId !=null and tenantId !=''"> | ||
84 | + AND ifd.tenant_id = #{tenantId} | ||
85 | + </if> | ||
86 | + <if test="id !=null and id !=''"> | ||
87 | + AND ifd.id = #{id} | ||
88 | + </if> | ||
89 | + | ||
90 | + </where> | ||
91 | + </select> | ||
70 | </mapper> | 92 | </mapper> |