Przeglądaj źródła

增加路段灯控数量统计列表

zhj 9 miesięcy temu
rodzic
commit
42722cefa4

+ 16 - 1
src/main/java/com/welampiot/controller/DataController.java

@@ -26,7 +26,7 @@ import java.util.*;
 @RestController
 @CrossOrigin
 @RequestMapping("/data")
-public class DataController {
+public class DataController extends BaseController {
     @Autowired
     private LampService lampService;
     @Autowired
@@ -699,4 +699,19 @@ public class DataController {
         WeatherDTO weatherInfo = WeatherUtil.getTodayWeatherInfo(String.valueOf(longitude), String.valueOf(latitude));
         return toolUtils.response(InterfaceResultEnum.OPERATION_SUCCESS, version, weatherInfo);
     }
+
+    /**
+     * 路段统计信息
+     */
+    @RequestMapping(value = "/sectionStatisticsInfo", method = RequestMethod.POST)
+    public BaseResult<?> sectionStatisticsInfo(BaseVO baseVO) {
+        Integer version = baseVO.getVersion();
+        List<Integer> sectionList = getSectionList(baseVO.getUsername());
+        baseVO.setSectionList(sectionList);
+        baseVO.setPageAndCount(baseVO.getPage(), baseVO.getCount());
+        List<SectionDTO> sectionLampCountsList = sectionService.getSectionLampCountsListByBaseVO(baseVO);
+        SectionVO sectionVO = new SectionVO();
+        sectionVO.setList(sectionLampCountsList);
+        return toolUtils.response(InterfaceResultEnum.OPERATION_SUCCESS, version, sectionVO);
+    }
 }

+ 2 - 0
src/main/java/com/welampiot/dao/SectionDao.java

@@ -1,6 +1,7 @@
 package com.welampiot.dao;
 
 import com.welampiot.dto.SectionDTO;
+import com.welampiot.vo.BaseVO;
 import com.welampiot.vo.SectionVO;
 import org.apache.ibatis.annotations.Param;
 
@@ -24,4 +25,5 @@ public interface SectionDao {
     List<SectionDTO> getAllSectionListByPid(@Param("id") Integer id);
     SectionDTO getDataByVO(SectionDTO dto);
     void updateSectionById(SectionDTO dto);
+    List<SectionDTO> getSectionLampCountsListByBaseVO(BaseVO baseVO);
 }

+ 5 - 0
src/main/java/com/welampiot/dto/SectionDTO.java

@@ -71,5 +71,10 @@ public class SectionDTO implements Serializable {
     /** 区域名称 **/
     private String area;
 
+    private Integer lampTotal;
+    private Integer lampOnlineCount;
+    private Integer lampLightCount;
+    private Integer lampAlarmCount;
+
     private static final long serialVersionUID = 1L;
 }

+ 2 - 0
src/main/java/com/welampiot/service/SectionService.java

@@ -1,6 +1,7 @@
 package com.welampiot.service;
 
 import com.welampiot.dto.SectionDTO;
+import com.welampiot.vo.BaseVO;
 import com.welampiot.vo.SectionVO;
 import org.apache.ibatis.annotations.Param;
 
@@ -25,4 +26,5 @@ public interface SectionService {
     List<SectionDTO> getAllSectionListByPid(@Param("id") Integer id);
     SectionDTO getDataByVO(SectionDTO dto);
     void updateSectionById(SectionDTO dto);
+    List<SectionDTO> getSectionLampCountsListByBaseVO(BaseVO baseVO);
 }

+ 6 - 0
src/main/java/com/welampiot/service/impl/SectionServiceImpl.java

@@ -3,6 +3,7 @@ package com.welampiot.service.impl;
 import com.welampiot.dao.SectionDao;
 import com.welampiot.dto.SectionDTO;
 import com.welampiot.service.SectionService;
+import com.welampiot.vo.BaseVO;
 import com.welampiot.vo.SectionVO;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
@@ -85,4 +86,9 @@ public class SectionServiceImpl implements SectionService {
     public void updateSectionById(SectionDTO dto){
         sectionDao.updateSectionById( dto);
     }
+
+    @Override
+    public List<SectionDTO> getSectionLampCountsListByBaseVO(BaseVO baseVO) {
+        return sectionDao.getSectionLampCountsListByBaseVO(baseVO);
+    }
 }

+ 2 - 0
src/main/java/com/welampiot/vo/BaseVO.java

@@ -9,6 +9,8 @@ public class BaseVO {
     private Integer page;
     private Integer count;
     private String keyword;
+    private Integer provinceId;
+    private Integer cityId;
     private Integer sectionId;
     private Integer areaId;
     private Integer online;

+ 2 - 0
src/main/java/com/welampiot/vo/SectionVO.java

@@ -1,5 +1,6 @@
 package com.welampiot.vo;
 
+import com.welampiot.dto.SectionDTO;
 import lombok.Data;
 
 import java.util.List;
@@ -8,4 +9,5 @@ import java.util.List;
 public class SectionVO {
     private List idList;
     private Integer version;
+    private List<SectionDTO> list;
 }

+ 42 - 0
src/main/resources/mapper/SectionMapper.xml

@@ -141,4 +141,46 @@
             alarmUser = #{alarmUser}
         where s.id = #{id}
     </update>
+
+    <select id="getSectionLampCountsListByBaseVO" resultType="SectionDTO">
+        SELECT
+        s.id,
+        s.`name`,
+        COALESCE(COUNT(l.id), 0) AS lampTotal,
+        COALESCE(SUM(IF(l.online = 1, 1, 0)), 0) AS lampOnlineCount,
+        COALESCE(SUM(IF(l.online = 1 AND l.lighteness > 0, 1, 0)), 0) AS lampLightCount,
+        COALESCE(SUM(IF(l.online = 1 AND l.faultstatus != 0 AND l.faultstatus != 128, 1, 0)), 0) AS lampAlarmCount
+        FROM
+        section s
+        LEFT JOIN
+        lampinfo l ON s.id = l.sectionid
+        LEFT JOIN global_location a ON a.id = s.pid
+        LEFT JOIN global_location b ON b.id = a.pid
+        LEFT JOIN global_location c ON c.id = b.pid
+        WHERE
+        1=1
+        <if test="sectionList != null and !sectionList.isEmpty()">
+            AND s.id IN
+            <foreach collection="sectionList" item="item" open="(" separator="," close=")">
+                #{item}
+            </foreach>
+        </if>
+        <if test="provinceId != null and provinceId != 0">
+            AND c.id = #{provinceId}
+        </if>
+        <if test="cityId != null and cityId != 0">
+            AND b.id = #{cityId}
+        </if>
+        <if test="areaId != null and areaId != 0">
+            AND a.id = #{areaId}
+        </if>
+        <if test="sectionId != null and sectionId != 0">
+            AND s.id = #{sectionId}
+        </if>
+        GROUP BY s.id
+        <if test="page != null and count != null">
+            LIMIT #{page}, #{count}
+        </if>
+    </select>
+
 </mapper>