lin 4 年之前
父節點
當前提交
ee646c48c4
共有 2 個文件被更改,包括 8 次插入1 次删除
  1. 3 0
      src/main/java/com/zoniot/ccrc/dto/BuildingDto.java
  2. 5 1
      src/main/resources/mapper/BuildingMapper.xml

+ 3 - 0
src/main/java/com/zoniot/ccrc/dto/BuildingDto.java

@@ -9,6 +9,9 @@ import lombok.EqualsAndHashCode;
 @EqualsAndHashCode(callSuper=false)
 public class BuildingDto extends Building {
 
+    @ApiModelProperty(value = "设备数", position = 8)
+    private Integer deviceCount = 0;
+
     @ApiModelProperty(value = "联网单位", position = 100)
     private String accessUnitName;
 

+ 5 - 1
src/main/resources/mapper/BuildingMapper.xml

@@ -210,7 +210,11 @@
     <select id="getBuildingList" resultType="com.zoniot.ccrc.dto.BuildingDto">
         select
             sb.*,
-            sc.name as community_name
+            sc.name as community_name,
+        IFNULL((SELECT 1 as device_count
+        from sc_device sd
+        WHERE sd.status = 1 and sd.building_id = sb.id
+        limit 1),0) as device_count
         from sc_building sb
         left join sc_community sc on(sc.id = sb.community_id)
         where sb.status = 1