浏览代码

网关详情、网关下拉列表、市区路段城市下拉列表

zhj 2 年之前
父节点
当前提交
d17b34220a

+ 131 - 0
src/main/java/com/welampiot/controller/NetworkController.java

@@ -0,0 +1,131 @@
+package com.welampiot.controller;
+
+import com.welampiot.common.BaseResult;
+import com.welampiot.common.InterfaceResultEnum;
+import com.welampiot.dto.NetworkDTO;
+import com.welampiot.service.NetworkService;
+import com.welampiot.utils.ToolUtils;
+import com.welampiot.vo.NetworkVO;
+import org.springframework.beans.BeanUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+import javax.servlet.http.HttpServletRequest;
+import java.util.List;
+
+/**
+ * ClassName: NetworkController
+ * Package: com.welampiot.controller
+ * Description:
+ *
+ * @Author: zhj_Start
+ * @Create: 2023/7/25 - 15:22
+ * @Version: v1.0
+ */
+@RestController
+@CrossOrigin
+@RequestMapping("/network")
+public class NetworkController {
+    @Autowired
+    private NetworkService networkService;
+    @Autowired
+    private ToolUtils toolUtils;
+
+    /**
+     * 网关详情
+     * @param request sectionList、网关id
+     * @return 网关详情
+     */
+    @RequestMapping(value = "/details", method = RequestMethod.POST)
+    public BaseResult<?> details(HttpServletRequest request) {
+        Integer version = (Integer) toolUtils.getRequestContent(request,"version",1);
+        Integer networkId = (Integer) toolUtils.getRequestContent(request,"networkId",1);
+        if (networkId == 0) return toolUtils.response(InterfaceResultEnum.LACK_PARAM_ERROR,version);
+        NetworkDTO networkDTO = new NetworkDTO();
+        networkDTO.setVersion(version);
+        networkDTO.setId(networkId);
+        NetworkDTO dto = networkService.getNetworkDetails(networkDTO);
+        if (dto == null) return toolUtils.response(InterfaceResultEnum.PARAM_FAIL,version);
+        // 协议类型(0 = lorawan, 1 = lora mesh, 2 = rf mesh, 3 = nbIot,
+        // 4 = gprs_direct, 5 = zigbee, 6 = LoraWAN, 7 = oneNet, 8 = eMqtt,
+        // 9 = LC-6B11-J, 10 = WE-CON-4G20(双路控制), 11 = PLC(有单灯,也有双灯控制器), 12 = 铂胜lora)
+        switch (dto.getProtocolType()) {
+            case 12 :
+                dto.setProtocolTypeStr("铂胜lora");
+                break;
+            case 11 :
+                dto.setProtocolTypeStr("PLC(有单灯,也有双灯控制器)");
+                break;
+            case 10 :
+                dto.setProtocolTypeStr("WE-CON-4G20(双路控制)");
+                break;
+            case 9 :
+                dto.setProtocolTypeStr("LC-6B11-J");
+                break;
+            case 8 :
+                dto.setProtocolTypeStr("eMqtt");
+                break;
+            case 7 :
+                dto.setProtocolTypeStr("oneNet");
+                break;
+            case 6 :
+                dto.setProtocolTypeStr("LoraWAN");
+                break;
+            case 5 :
+                dto.setProtocolTypeStr("zigbee");
+                break;
+            case 4 :
+                dto.setProtocolTypeStr("gprs_direct");
+                break;
+            case 3 :
+                dto.setProtocolTypeStr("nbIot");
+                break;
+            case 2 :
+                dto.setProtocolTypeStr("rf mesh");
+                break;
+            case 1 :
+                dto.setProtocolTypeStr("lora mesh");
+                break;
+            default :
+                dto.setProtocolTypeStr("lorawan");
+                break;
+        }
+        // 频段信息(0 CN470,1 EU863,2 AU915,3 US902,4 AS923)
+        if (dto.getFreBandInfo() == 4) {
+            dto.setFreBandInfoStr("AS923");
+        } else if (dto.getFreBandInfo() == 3) {
+            dto.setFreBandInfoStr("US902");
+        } else if (dto.getFreBandInfo() == 2) {
+            dto.setFreBandInfoStr("AU915");
+        } else if (dto.getFreBandInfo() == 1) {
+            dto.setFreBandInfoStr("EU863");
+        } else {
+            dto.setFreBandInfoStr("CN470");
+        }
+        if (dto.getArea() == null) {
+            dto.setArea("");
+        }
+        if (dto.getSection() == null) {
+            dto.setSection("");
+        }
+        NetworkVO networkVO = new NetworkVO();
+        BeanUtils.copyProperties(dto,networkVO);
+        return toolUtils.response(InterfaceResultEnum.OPERATION_SUCCESS,version,networkVO);
+    }
+
+    /**
+     * 网关下拉列表
+     * @param request sectionList
+     * @return 网关下拉列表
+     */
+    @PostMapping("/nav")
+    private BaseResult<?> nav(HttpServletRequest request){
+        Integer version = (Integer) toolUtils.getRequestContent(request,"version",1);
+        NetworkDTO dto = new NetworkDTO();
+        dto.setSectionList(toolUtils.getSectionList(request));
+        List<NetworkDTO> networkNavList = networkService.getNetworkNavList(dto);
+        NetworkVO networkVO = new NetworkVO();
+        networkVO.setList(networkNavList);
+        return toolUtils.response(InterfaceResultEnum.OPERATION_SUCCESS,version,networkVO);
+    }
+}

+ 4 - 0
src/main/java/com/welampiot/controller/UserController.java

@@ -41,6 +41,10 @@ public class UserController {
     private CompanyService companyService;
     @Autowired
     private PrivilegeNodeService privilegeNodeService;
+    @Autowired
+    private LampService lampService;
+    @Autowired
+    private LampPoleService lampPoleService;
 
     /**
      * 登录demo做测试,后续删除

+ 8 - 0
src/main/java/com/welampiot/dao/GlobalLocationDao.java

@@ -40,4 +40,12 @@ public interface GlobalLocationDao {
     List<GlobalLocationDTO> getOnlyOneLevelList(@Param("level") Integer level,@Param("version") Integer version);
 
     List<GlobalLocationDTO> getCountryOfSectionList(@Param("level") Integer level,@Param("version") Integer version);
+
+    List<GlobalLocationDTO> getAreaLampCountList(GlobalLocationVO vo);
+
+    List<GlobalLocationDTO> getAreaLampPoleCountList(GlobalLocationVO vo);
+
+    List<GlobalLocationDTO> getCityLampCountList(GlobalLocationVO vo);
+
+    List<GlobalLocationDTO> getCityLampPoleCountList(GlobalLocationVO vo);
 }

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

@@ -8,4 +8,6 @@ public interface NetworkDao {
     Integer add(NetworkDTO networkDTO);
     Integer update(NetworkDTO networkDTO);
     List<NetworkDTO> getNetListByDTO(NetworkDTO networkDTO);
+    NetworkDTO getNetworkDetails(NetworkDTO networkDTO);
+    List<NetworkDTO> getNetworkNavList(NetworkDTO networkDTO);
 }

+ 3 - 0
src/main/java/com/welampiot/dto/GlobalLocationDTO.java

@@ -64,6 +64,9 @@ public class GlobalLocationDTO implements Serializable {
     private List<GlobalLocationDTO> cityList;
     private List<GlobalLocationDTO> areaList;
 
+    private Integer lampCount;
+    private Integer lampPoleCount;
+
     public GlobalLocationDTO(Integer id, Integer pid, String name) {
         this.id = id;
         this.pid = pid;

+ 3 - 0
src/main/java/com/welampiot/dto/NetworkDTO.java

@@ -24,8 +24,11 @@ public class NetworkDTO {
     private Integer freBandInfo; // 频段信息
     private String freBandInfoStr;
     private String simCard;
+    private String model;
     private String operator;
     private Integer status;
     private Integer version;
+    private String longitude;
+    private String latitude;
     private List<Integer> sectionList;
 }

+ 1 - 1
src/main/java/com/welampiot/service/LampService.java

@@ -37,7 +37,7 @@ public interface LampService {
     void changeLampLocationById(LampInfoDTO dto);
     Integer getSectionOfLampCountBySectionId(Integer id);
     String getNameOrNumber(Integer type,Integer value,Integer version);
-    LampInfoDTO getLampInfoDTOById(@Param("id") Integer id);
+    LampInfoDTO getLampInfoDTOById(Integer id);
     List<LampInfoDTO> getLampList(LampVO vo);
     Integer getLampTotal(LampVO vo);
 }

+ 4 - 0
src/main/java/com/welampiot/service/NetworkService.java

@@ -3,8 +3,12 @@ package com.welampiot.service;
 import com.welampiot.dto.NetworkDTO;
 import com.welampiot.vo.NetworkVO;
 
+import java.util.List;
+
 public interface NetworkService {
     Integer add(NetworkDTO networkDTO);
     Integer update(NetworkDTO networkDTO);
     NetworkVO getNetListByDTO(NetworkDTO networkDTO);
+    NetworkDTO getNetworkDetails(NetworkDTO networkDTO);
+    List<NetworkDTO> getNetworkNavList(NetworkDTO networkDTO);
 }

+ 45 - 6
src/main/java/com/welampiot/service/impl/GlobalLocationServiceImpl.java

@@ -10,6 +10,7 @@ import org.springframework.stereotype.Service;
 
 import java.util.ArrayList;
 import java.util.List;
+import java.util.Objects;
 
 /**
  * ClassName: GlobalLocationServiceImpl
@@ -85,17 +86,24 @@ public class GlobalLocationServiceImpl implements GlobalLocationService {
         List<GlobalLocationDTO> userProvinceNav = globalLocationDao.getUserProvinceNav(globalLocationVO);
         List<GlobalLocationDTO> data = new ArrayList<>();
         List<Integer> idList = new ArrayList<>();
+        List<Integer> idList1 = new ArrayList<>();
         for (GlobalLocationDTO g:userProvinceNav) {
             if (g.getLevel1() != null && g.getLevel1() == 3){
                 g.setName(g.getName1());
                 g.setName1(null);
                 g.setId(g.getId1());
                 g.setId1(null);
+                if (!idList.contains(g.getId())){
+                    idList.add(g.getId());
+                }
             }else if (g.getLevel2() != null && g.getLevel2() == 3){
                 g.setName(g.getName2());
                 g.setName2(null);
                 g.setId(g.getId2());
                 g.setId2(null);
+                if (!idList1.contains(g.getId())){
+                    idList1.add(g.getId());
+                }
             }else if (g.getLevel3() != null && g.getLevel3() == 3){
                 g.setName(g.getName3());
                 g.setName3(null);
@@ -106,15 +114,35 @@ public class GlobalLocationServiceImpl implements GlobalLocationService {
                 g.setName1(null);
                 g.setId(g.getId1());
                 g.setId1(null);
-            }
-            if (g.getId() != null) {
                 if (!idList.contains(g.getId())){
-                    data.add(g);
                     idList.add(g.getId());
                 }
             }
         }
-
+        globalLocationVO.setIdList(idList);
+        List<GlobalLocationDTO> areaLampPoleCountList = globalLocationDao.getAreaLampPoleCountList(globalLocationVO);
+        List<GlobalLocationDTO> areaLampCountList = globalLocationDao.getAreaLampCountList(globalLocationVO);
+        for (GlobalLocationDTO g : areaLampCountList) {
+            for (GlobalLocationDTO g1 : areaLampPoleCountList) {
+                if (Objects.equals(g.getId(), g1.getId())) {
+                    g.setLampPoleCount(g1.getLampPoleCount());
+                    data.add(g);
+                    break;
+                }
+            }
+        }
+        globalLocationVO.setIdList(idList1);
+        List<GlobalLocationDTO> cityLampPoleCountList = globalLocationDao.getCityLampPoleCountList(globalLocationVO);
+        List<GlobalLocationDTO> cityLampCountList = globalLocationDao.getCityLampCountList(globalLocationVO);
+        for (GlobalLocationDTO g : cityLampCountList) {
+            for (GlobalLocationDTO g1 : cityLampPoleCountList) {
+                if (Objects.equals(g.getId(), g1.getId())) {
+                    g.setLampPoleCount(g1.getLampPoleCount());
+                    data.add(g);
+                    break;
+                }
+            }
+        }
         return data;
     }
 
@@ -147,12 +175,23 @@ public class GlobalLocationServiceImpl implements GlobalLocationService {
             }
             if (g.getId() != null) {
                 if (!idList.contains(g.getId())){
-                    data.add(g);
+//                    data.add(g);
                     idList.add(g.getId());
                 }
             }
         }
-
+        globalLocationVO.setIdList(idList);
+        List<GlobalLocationDTO> areaLampPoleCountList = globalLocationDao.getAreaLampPoleCountList(globalLocationVO);
+        List<GlobalLocationDTO> areaLampCountList = globalLocationDao.getAreaLampCountList(globalLocationVO);
+        for (GlobalLocationDTO g : areaLampCountList) {
+            for (GlobalLocationDTO g1 : areaLampPoleCountList) {
+                if (Objects.equals(g.getId(), g1.getId())) {
+                    g.setLampPoleCount(g1.getLampPoleCount());
+                    data.add(g);
+                    break;
+                }
+            }
+        }
         return data;
     }
 

+ 10 - 0
src/main/java/com/welampiot/service/impl/NetworkServiceImpl.java

@@ -103,4 +103,14 @@ public class NetworkServiceImpl implements NetworkService {
         networkVO.setList(list);
         return networkVO;
     }
+
+    @Override
+    public NetworkDTO getNetworkDetails(NetworkDTO networkDTO) {
+        return networkDao.getNetworkDetails(networkDTO);
+    }
+
+    @Override
+    public List<NetworkDTO> getNetworkNavList(NetworkDTO networkDTO) {
+        return networkDao.getNetworkNavList(networkDTO);
+    }
 }

+ 1 - 0
src/main/java/com/welampiot/vo/GlobalLocationVO.java

@@ -9,5 +9,6 @@ import java.util.List;
 public class GlobalLocationVO {
     private List sectionList;
     private Integer version;
+    private List<Integer> idList;
     private List<GlobalLocationDTO> list;
 }

+ 16 - 0
src/main/java/com/welampiot/vo/NetworkVO.java

@@ -16,5 +16,21 @@ import java.util.List;
  */
 @Data
 public class NetworkVO {
+    private Integer id;
+    private String networkName;
+    private String deviceSn;
+    private Integer protocolType; // 协议类型
+    private String protocolTypeStr;
+    private String model;
+    private String area;
+    private String section;
+    private Integer areaId;
+    private Integer sectionId;
+    private String longitude;
+    private String latitude;
+    private String simCard;
+    private String operator;
+    private Integer freBandInfo;
+    private String freBandInfoStr;
     private List<NetworkDTO> list;
 }

+ 102 - 0
src/main/resources/mapper/GlobalLocationMapper.xml

@@ -240,5 +240,107 @@
         ON g.id = s.pid
         WHERE g.level = #{level}
     </select>
+
+    <select id="getAreaLampCountList" resultType="GlobalLocationDTO" parameterType="GlobalLocationVO">
+        select
+            count(l.id) as lampCount,
+            gl.id
+            <choose>
+                <when test="version == 0">
+                    ,gl.chinese_name AS `name`
+                </when>
+                <when test="version == 1">
+                    ,gl.english_name AS `name`
+                </when>
+                <otherwise>
+                    ,gl.ru_name AS `name`
+                </otherwise>
+            </choose>
+        from section s
+        left join lampinfo l on l.sectionid = s.id
+        left join global_location gl on s.pid = gl.id
+        where gl.id in
+        <foreach collection="idList" item="item" open="(" close=")" separator=",">
+            #{item}
+        </foreach>
+        group by gl.id
+    </select>
+
+    <select id="getAreaLampPoleCountList" resultType="GlobalLocationDTO" parameterType="GlobalLocationVO">
+        select
+        count(l.id) as lampPoleCount,
+        gl.id
+        <choose>
+            <when test="version == 0">
+                ,gl.chinese_name AS `name`
+            </when>
+            <when test="version == 1">
+                ,gl.english_name AS `name`
+            </when>
+            <otherwise>
+                ,gl.ru_name AS `name`
+            </otherwise>
+        </choose>
+        from section s
+        left join lamp_pole l on l.sectionid = s.id
+        left join global_location gl on s.pid = gl.id
+        where gl.id in
+        <foreach collection="idList" item="item" open="(" close=")" separator=",">
+            #{item}
+        </foreach>
+        group by gl.id
+    </select>
+
+    <select id="getCityLampPoleCountList" resultType="GlobalLocationDTO" parameterType="GlobalLocationVO">
+        select
+        count(l.id) as lampPoleCount,
+        gl1.id
+        <choose>
+            <when test="version == 0">
+                ,gl1.chinese_name AS `name`
+            </when>
+            <when test="version == 1">
+                ,gl1.english_name AS `name`
+            </when>
+            <otherwise>
+                ,gl1.ru_name AS `name`
+            </otherwise>
+        </choose>
+        from section s
+        left join lamp_pole l on l.sectionid = s.id
+        left join global_location gl on s.pid = gl.id
+        left join global_location gl1 on gl.pid = gl1.id
+        where gl1.id in
+        <foreach collection="idList" item="item" open="(" close=")" separator=",">
+            #{item}
+        </foreach>
+        group by gl1.id
+    </select>
+
+    <select id="getCityLampCountList" resultType="GlobalLocationDTO" parameterType="GlobalLocationVO">
+        select
+        count(l.id) as lampCount,
+        gl1.id
+        <choose>
+            <when test="version == 0">
+                ,gl1.chinese_name AS `name`
+            </when>
+            <when test="version == 1">
+                ,gl1.english_name AS `name`
+            </when>
+            <otherwise>
+                ,gl1.ru_name AS `name`
+            </otherwise>
+        </choose>
+        from section s
+        left join lampinfo l on l.sectionid = s.id
+        left join global_location gl on s.pid = gl.id
+        left join global_location gl1 on gl.pid = gl1.id
+        where gl1.id in
+        <foreach collection="idList" item="item" open="(" close=")" separator=",">
+            #{item}
+        </foreach>
+        group by gl1.id
+    </select>
     
 </mapper>

+ 9 - 0
src/main/resources/mapper/LampMapper.xml

@@ -737,5 +737,14 @@
             and l.sectionid = #{sectionId}
         </if>
     </select>
+
+    <select id="getCityLampCount" resultType="Integer">
+        select count(*)
+        from lampinfo l
+        left join section s on l.sectionid = s.id
+        left join global_location gl on s.pid = gl.id
+        left join global_location gl1 on gl.pid = gl1.id
+        where gl1.id = #{id}
+    </select>
     
 </mapper>

+ 45 - 0
src/main/resources/mapper/NetworkMapper.xml

@@ -50,4 +50,49 @@
             </foreach>
         </if>
     </select>
+
+    <select id="getNetworkDetails" resultType="NetworkDTO">
+        select
+            n.id,
+            n.network_name as networkName,
+            n.devicesn as deviceSn,
+            n.protocoltype as protocolType,
+            n.model,
+            n.areaid as areaId,
+            n.sectionid as sectionId,
+            n.longitude,
+            n.latitude,
+            n.fre_band_info freBandInfo,
+            n.simcard as simCard,
+            n.operator,
+            s.name as section
+            <choose>
+                <when test="version == 0">
+                    ,gl.chinese_name as area
+                </when>
+                <when test="version == 1">
+                    ,gl.english_name as area
+                </when>
+                <otherwise>
+                    ,gl.ru_name as area
+                </otherwise>
+            </choose>
+        from network n
+        left join section s on s.id = n.sectionid
+        left join global_location gl on s.pid = gl.id
+        where n.id = #{id}
+    </select>
+
+    <select id="getNetworkNavList" resultType="NetworkDTO">
+        select
+            n.id,
+            n.network_name as networkName
+        from network n
+        <if test="sectionList != null and !sectionList.isEmpty()">
+            where n.sectionid in
+            <foreach collection="sectionList" item="item" open="(" separator="," close=")">
+                #{item}
+            </foreach>
+        </if>
+    </select>
 </mapper>

+ 1 - 1
src/main/resources/mapper/SectionMapper.xml

@@ -16,7 +16,7 @@
         </foreach>
     </select>
     <select id="getListByIdList" parameterType="java.util.List" resultType="com.welampiot.dto.SectionDTO">
-        select id,name,pid from section
+        select id,name,pid,lampcount as lampCount,lamp_pole_count as lampPoleCount from section
         <if test="idList != null and !idList.isEmpty()">
             where id in
             <foreach item="item" collection="idList" open="(" separator="," close=")">