@Data
public class ProjectTreeDto {
@ApiModelProperty(value = "主键")
private Integer projectId;
@ApiModelProperty(value = "项目名称")
private String projectName;
@ApiModelProperty(value = "项目编号 项目编号")
private String projectNum;
@ApiModelProperty(value = "网关集合")
private List<GatewayTreeDto> gatewayTreeDto;
}
@Data
public class GatewayTreeDto {
@ApiModelProperty(value="主键")
private Integer gatewayId;
@ApiModelProperty(value="设备标识")
private String deviceId;
@ApiModelProperty(value="设备名称")
private String deviceName;
@ApiModelProperty(value="客户端名称")
private String clientName;
@ApiModelProperty(value = "是否在线:1-是 0-不是")
private Integer gatewayStatus;
@ApiModelProperty(value = "线路集合")
private List<DeviceLineTreeDto> deviceLineTreeDto;
}
@Data
public class DeviceLineTreeDto {
@ApiModelProperty(value = "主键")
private Integer deviceLineId;
@ApiModelProperty(value="线路编号")
private Integer lineNo;
}
List<ProjectTreeDto> getProjectTreeList(@Param("account") String account);
<resultMap id="projectTree" type="com.zbwd.xj001.srv.common.dto.ProjectTreeDto">
<id property="projectId" column="project_id"/>
<result property="projectName" column="project_name"/>
<result property="projectNum" column="project_num"/>
<collection property="gatewayTreeDto" ofType="com.zbwd.xj001.srv.common.dto.GatewayTreeDto">
<id property="gatewayId" column="gateway_id"/>
<result property="deviceId" column="device_id"/>
<result property="deviceName" column="device_name"/>
<result property="clientName" column="client_name"/>
<collection property="deviceLineTreeDto" ofType="com.zbwd.xj001.srv.common.dto.DeviceLineTreeDto">
<id property="deviceLineId" column="line_id"/>
<result property="lineNo" column="line_no"/>
</collection>
</collection>
</resultMap>
<select id="getProjectTreeList" resultMap="projectTree">
SELECT
a.id project_id,
a.project_name,
a.project_num,
t.gateway_id,
t.device_id,
t.device_name,
t.client_name,
t.line_id,
t.line_no
FROM
project a
LEFT JOIN (
SELECT
b.project_id,
b.id gateway_id,
b.device_id,
b.device_name,
b.client_name,
c.id line_id,
c.line_no
FROM
device_gateway b
LEFT JOIN device_line c ON c.gateway_id = b.id
) t ON t.project_id = a.id where 1=1
<if test="account != null and '' != account">
and account=#{account}
</if>
</select>