Commit f791e3d580e4c2910daf1ccf48ca06123565dfef

Authored by 云中非
1 parent 010a2dd7

fix: 关联网关的传感器没有网关信息

@@ -74,7 +74,7 @@ public class YtDeviceController extends BaseController { @@ -74,7 +74,7 @@ public class YtDeviceController extends BaseController {
74 } 74 }
75 DeviceDTO newDeviceDTO = null; 75 DeviceDTO newDeviceDTO = null;
76 boolean isIncludeRelation = false; 76 boolean isIncludeRelation = false;
77 - String gateWayDeviceId = deviceDTO.getGateWayDeviceId(); 77 + String gateWayDeviceId = deviceDTO.getGatewayId();
78 DeviceDTO gateWayDevice = null; 78 DeviceDTO gateWayDevice = null;
79 if (StringUtils.isNotEmpty(gateWayDeviceId)) { 79 if (StringUtils.isNotEmpty(gateWayDeviceId)) {
80 gateWayDevice = 80 gateWayDevice =
@@ -38,7 +38,8 @@ public class DeviceDTO extends TenantDTO { @@ -38,7 +38,8 @@ public class DeviceDTO extends TenantDTO {
38 private String profileId; 38 private String profileId;
39 39
40 @ApiModelProperty(value = "关联网关设备") 40 @ApiModelProperty(value = "关联网关设备")
41 - private String gateWayDeviceId; 41 + private String gatewayId;
  42 + private String gatewayName;
42 43
43 @ApiModelProperty(value = "设备凭证") 44 @ApiModelProperty(value = "设备凭证")
44 private YtCredentialsDto deviceToken; 45 private YtCredentialsDto deviceToken;
@@ -24,6 +24,7 @@ public class YtDevice extends TenantBaseEntity { @@ -24,6 +24,7 @@ public class YtDevice extends TenantBaseEntity {
24 private JsonNode deviceInfo; 24 private JsonNode deviceInfo;
25 private String profileId; 25 private String profileId;
26 private String tbDeviceId; 26 private String tbDeviceId;
  27 + private String gatewayId;
27 private String deviceTypeId; 28 private String deviceTypeId;
28 private String label; 29 private String label;
29 @TableField(typeHandler = EnumTypeHandler.class) 30 @TableField(typeHandler = EnumTypeHandler.class)
@@ -25,6 +25,8 @@ @@ -25,6 +25,8 @@
25 <result property="description" column="description"/> 25 <result property="description" column="description"/>
26 <result property="customerId" column="customer_id"/> 26 <result property="customerId" column="customer_id"/>
27 <result property="organizationId" column="organization_id"/> 27 <result property="organizationId" column="organization_id"/>
  28 + <result property="gatewayId" column="gateway_id"/>
  29 + <result property="gatewayName" column="gateway_name"/>
28 <association property="deviceProfile" javaType="org.thingsboard.server.common.data.yunteng.dto.DeviceProfileDTO"> 30 <association property="deviceProfile" javaType="org.thingsboard.server.common.data.yunteng.dto.DeviceProfileDTO">
29 <result property="name" column="profile_name"/> 31 <result property="name" column="profile_name"/>
30 <result property="transportType" column="transport_type"/> 32 <result property="transportType" column="transport_type"/>
@@ -41,6 +43,7 @@ @@ -41,6 +43,7 @@
41 <result property="createdTime" column="created_time"/> 43 <result property="createdTime" column="created_time"/>
42 <result property="lastOnlineTime" column="last_online_time"/> 44 <result property="lastOnlineTime" column="last_online_time"/>
43 </resultMap> 45 </resultMap>
  46 +
44 <sql id="basicColumns"> 47 <sql id="basicColumns">
45 ifd.id,ifd.name,ifd.device_info,ifd.profile_id,ifd.active_time,ifd.tenant_id,ifd.description 48 ifd.id,ifd.name,ifd.device_info,ifd.profile_id,ifd.active_time,ifd.tenant_id,ifd.description
46 ,ifd.tb_device_id,ifd.label,ifd.last_connect_time,ifd.device_type,ifd.device_state,ifd.create_time,ifd.update_time,ifd.creator, 49 ,ifd.tb_device_id,ifd.label,ifd.last_connect_time,ifd.device_type,ifd.device_state,ifd.create_time,ifd.update_time,ifd.creator,
@@ -48,6 +51,7 @@ @@ -48,6 +51,7 @@
48 </sql> 51 </sql>
49 <sql id="detailColumns"> 52 <sql id="detailColumns">
50 <include refid="basicColumns"/> 53 <include refid="basicColumns"/>
  54 + ,ifd.gateway_id,idg.name gateway_name
51 ,ifdp.name AS profile_name,ifdp.transport_type 55 ,ifdp.name AS profile_name,ifdp.transport_type
52 ,io.name AS organization_name 56 ,io.name AS organization_name
53 </sql> 57 </sql>
@@ -109,6 +113,7 @@ @@ -109,6 +113,7 @@
109 FROM iotfs_device ifd 113 FROM iotfs_device ifd
110 LEFT JOIN device_profile ifdp ON ifd.profile_id = CAST (ifdp.id AS VARCHAR) 114 LEFT JOIN device_profile ifdp ON ifd.profile_id = CAST (ifdp.id AS VARCHAR)
111 LEFT JOIN iotfs_organization io ON io.id = ifd.organization_id 115 LEFT JOIN iotfs_organization io ON io.id = ifd.organization_id
  116 + LEFT JOIN iotfs_device idg ON idg.id = ifd.gateway_id
112 <where> 117 <where>
113 <if test="tenantId !=null and tenantId !=''"> 118 <if test="tenantId !=null and tenantId !=''">
114 AND ifd.tenant_id = #{tenantId} 119 AND ifd.tenant_id = #{tenantId}