Browse Source

获取配电箱列表

zhj 2 years atrás
parent
commit
8ae720eba7

+ 4 - 4
src/main/java/com/welampiot/controller/CommonController.java

@@ -34,7 +34,7 @@ public class CommonController {
      * @param request
      * @return
      */
-    @PostMapping("/get_country")
+    @PostMapping("/getCountry")
     public BaseResult<GlobalLocationDTO> getCountry(HttpServletRequest request){
         String version = request.getParameter("version") == null ? "0" : request.getParameter("version");
         List<GlobalLocationDTO> countryList;
@@ -56,7 +56,7 @@ public class CommonController {
      * @param request
      * @return
      */
-    @PostMapping("/get_province")
+    @PostMapping("/getProvince")
     public BaseResult<GlobalLocationDTO> getProvince(HttpServletRequest request){
         Integer version = request.getParameter("version") == null ? 0 : Integer.parseInt(request.getParameter("version"));
         Integer countryId = request.getParameter("countryId") == null ? 0 : Integer.parseInt(request.getParameter("countryId"));
@@ -89,7 +89,7 @@ public class CommonController {
      * @param request
      * @return
      */
-    @PostMapping("/get_city")
+    @PostMapping("/getCity")
     public BaseResult<GlobalLocationDTO> getCity(HttpServletRequest request){
         Integer version = request.getParameter("version") == null ? 0 : Integer.parseInt(request.getParameter("version"));
         Integer provinceId = request.getParameter("provinceId") == null ? 0 : Integer.parseInt(request.getParameter("provinceId"));
@@ -122,7 +122,7 @@ public class CommonController {
      * @param request
      * @return
      */
-    @PostMapping("/get_area")
+    @PostMapping("/getArea")
     public BaseResult<GlobalLocationDTO> getArea(HttpServletRequest request){
         Integer version = request.getParameter("version") == null ? 0 : Integer.parseInt(request.getParameter("version"));
         Integer cityId = request.getParameter("cityId") == null ? 0 : Integer.parseInt(request.getParameter("cityId"));

+ 23 - 11
src/main/java/com/welampiot/controller/ElectricBoxController.java

@@ -1,11 +1,10 @@
 package com.welampiot.controller;
 
 import com.welampiot.common.BaseResult;
-import com.welampiot.dao.ElectricBoxDao;
+import com.welampiot.dto.AirSwitchInfoDTO;
 import com.welampiot.dto.ElectricBoxDTO;
 import com.welampiot.service.ElectricBoxService;
 import com.welampiot.utils.ToolUtils;
-import com.welampiot.vo.ElectricBoxRequestVO;
 import com.welampiot.vo.ElectricBoxReturnVO;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.CrossOrigin;
@@ -14,8 +13,6 @@ import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
 import javax.servlet.http.HttpServletRequest;
-import java.util.List;
-import java.util.Map;
 
 /**
  * ClassName: ElectricBoxController
@@ -48,15 +45,30 @@ public class ElectricBoxController {
         Integer status = request.getParameter("status") == null ? 0 : Integer.parseInt(request.getParameter("status"));
         String keyword = request.getParameter("keyword") == null ? "" : request.getParameter("keyword");
 
-        ElectricBoxRequestVO vo = new ElectricBoxRequestVO();
-        vo.setPage(count*(page-1));
-        vo.setCount(count);
-        vo.setStatus(status);
-        vo.setKeyword(keyword);
-        vo.setSectionList(toolUtils.getSectionList(request));
+        ElectricBoxDTO dto = new ElectricBoxDTO();
+        dto.setPage(count*(page-1));
+        dto.setCount(count);
+        dto.setStatus(status);
+        dto.setKeyword(keyword);
+        dto.setSectionList(toolUtils.getSectionList(request));
 
-        ElectricBoxReturnVO electricBoxList = electricBoxService.getElectricBoxListBySectionId(vo);
+        ElectricBoxReturnVO electricBoxList = electricBoxService.getElectricBoxListBySectionId(dto);
         System.out.println(electricBoxList);
         return BaseResult.success(electricBoxList);
     }
+
+    /**
+     * 获取空开设备列表
+     * @param request
+     * @return
+     */
+    @PostMapping("/airSwitchList")
+    public BaseResult<AirSwitchInfoDTO> airSwitchList(HttpServletRequest request){
+        Integer boxId = request.getParameter("boxId") == null ? 0 : Integer.parseInt(request.getParameter("boxId"));
+        Integer online = request.getParameter("online") == null ? 0 : Integer.parseInt(request.getParameter("online"));
+
+
+
+        return BaseResult.success();
+    }
 }

+ 4 - 6
src/main/java/com/welampiot/dao/ElectricBoxDao.java

@@ -1,8 +1,6 @@
 package com.welampiot.dao;
 
 import com.welampiot.dto.ElectricBoxDTO;
-import com.welampiot.vo.ElectricBoxRequestVO;
-import org.apache.ibatis.annotations.Param;
 
 import java.util.List;
 
@@ -16,11 +14,11 @@ import java.util.List;
  * @Version: v1.0
  */
 public interface ElectricBoxDao {
-    List<ElectricBoxDTO> getElectricBoxListBySectionId(ElectricBoxRequestVO vo);
+    List<ElectricBoxDTO> getElectricBoxListBySectionId(ElectricBoxDTO dto);
 
-    Integer getTotalByStatus(ElectricBoxRequestVO vo);
+    Integer getTotalByStatus(ElectricBoxDTO dto);
 
-    Integer getOnlineTotalByStatus(ElectricBoxRequestVO vo);
+    Integer getOnlineTotalByStatus(ElectricBoxDTO dto);
 
-    Integer getOfflineTotalByStatus(ElectricBoxRequestVO vo);
+    Integer getOfflineTotalByStatus(ElectricBoxDTO dto);
 }

+ 24 - 6
src/main/java/com/welampiot/dto/ElectricBoxDTO.java

@@ -54,16 +54,34 @@ public class ElectricBoxDTO implements Serializable {
     private String image;
 
     /** 安装时间 **/
-    private Date installDate;
+    private String installDate;
 
     /** 过期时间 **/
-    private Date expirationDate;
+    private String expirationDate;
 
-    /** 配电箱多对一路段 **/
-    private SectionDTO sectionDTO;
+    /** 空开数量 **/
+    private Integer airCount;
 
-    /** 配电箱一对多空开 **/
-    private List<AirSwitchInfoDTO> airSwitchInfoDTOS;
+    /** 空开的在线数量 **/
+    private Integer onlineCount;
+
+    /** 电箱的在线状态(0 离线,1 在线) **/
+    private Integer online;
+
+    /** 页数 **/
+    private Integer page;
+
+    /** 单页显示数量 **/
+    private Integer count;
+
+    /** 关键字搜索(可搜索设备名称和设备地址) **/
+    private String keyword;
+
+    /** 在线状态筛选(0全部,1在线,2离线)**/
+    private Integer status;
+
+    /** 所有路段的id **/
+    private List sectionList;
 
     private static final long serialVersionUID = 1L;
 }

+ 4 - 6
src/main/java/com/welampiot/service/ElectricBoxService.java

@@ -1,10 +1,8 @@
 package com.welampiot.service;
 
 import com.welampiot.dto.ElectricBoxDTO;
-import com.welampiot.vo.ElectricBoxRequestVO;
 import com.welampiot.vo.ElectricBoxReturnVO;
 
-import java.util.List;
 
 /**
  * ClassName: ElectricBoxService
@@ -16,11 +14,11 @@ import java.util.List;
  * @Version: v1.0
  */
 public interface ElectricBoxService {
-    ElectricBoxReturnVO getElectricBoxListBySectionId(ElectricBoxRequestVO vo);
+    ElectricBoxReturnVO getElectricBoxListBySectionId(ElectricBoxDTO dto);
 
-    Integer getTotalByStatus(ElectricBoxRequestVO vo);
+    Integer getTotalByStatus(ElectricBoxDTO dto);
 
-    Integer getOnlineTotalByStatus(ElectricBoxRequestVO vo);
+    Integer getOnlineTotalByStatus(ElectricBoxDTO dto);
 
-    Integer getOfflineTotalByStatus(ElectricBoxRequestVO vo);
+    Integer getOfflineTotalByStatus(ElectricBoxDTO dto);
 }

+ 35 - 13
src/main/java/com/welampiot/service/impl/ElectricBoxServiceImpl.java

@@ -3,11 +3,12 @@ package com.welampiot.service.impl;
 import com.welampiot.dao.ElectricBoxDao;
 import com.welampiot.dto.ElectricBoxDTO;
 import com.welampiot.service.ElectricBoxService;
-import com.welampiot.vo.ElectricBoxRequestVO;
 import com.welampiot.vo.ElectricBoxReturnVO;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
 import java.util.List;
 
 /**
@@ -26,30 +27,51 @@ public class ElectricBoxServiceImpl implements ElectricBoxService {
     private ElectricBoxDao electricBoxDao;
 
     @Override
-    public ElectricBoxReturnVO getElectricBoxListBySectionId(ElectricBoxRequestVO vo) {
+    public ElectricBoxReturnVO getElectricBoxListBySectionId(ElectricBoxDTO dto) {
         ElectricBoxReturnVO electricBoxReturnVO = new ElectricBoxReturnVO();
 
-        electricBoxReturnVO.setTotal(electricBoxDao.getTotalByStatus(vo));
-        electricBoxReturnVO.setDevTotal(electricBoxDao.getTotalByStatus(vo));
-        electricBoxReturnVO.setOnlineTotal(electricBoxDao.getOnlineTotalByStatus(vo));
-        electricBoxReturnVO.setOfflineTotal(electricBoxDao.getOfflineTotalByStatus(vo));
-        electricBoxReturnVO.setElectricBoxList(electricBoxDao.getElectricBoxListBySectionId(vo));
+        electricBoxReturnVO.setTotal(electricBoxDao.getTotalByStatus(dto));
+        electricBoxReturnVO.setDevTotal(electricBoxDao.getTotalByStatus(dto));
+        electricBoxReturnVO.setOnlineTotal(electricBoxDao.getOnlineTotalByStatus(dto));
+        electricBoxReturnVO.setOfflineTotal(electricBoxDao.getOfflineTotalByStatus(dto));
+        List<ElectricBoxDTO> electricBoxList = electricBoxDao.getElectricBoxListBySectionId(dto);
+        List<ElectricBoxDTO> electricBoxDTOS = new ArrayList<>();
+        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+        electricBoxList.forEach(electricBoxDTO ->{
+            if (electricBoxDTO.getInstallDate() == null){
+                electricBoxDTO.setInstallDate("");
+            }else {
+                simpleDateFormat.format(electricBoxDTO.getInstallDate());
+            }
+            if (electricBoxDTO.getExpirationDate() == null){
+                electricBoxDTO.setExpirationDate("");
+            }else {
+                simpleDateFormat.format(electricBoxDTO.getExpirationDate());
+            }
+            if (electricBoxDTO.getOnlineCount() != null && electricBoxDTO.getOnlineCount() > 0){
+                electricBoxDTO.setOnline(1);
+            }else {
+                electricBoxDTO.setOnline(0);
+            }
+            electricBoxDTOS.add(electricBoxDTO);
+        });
+        electricBoxReturnVO.setElectricBoxList(electricBoxDTOS);
 
         return electricBoxReturnVO;
     }
 
     @Override
-    public Integer getTotalByStatus(ElectricBoxRequestVO vo) {
-        return electricBoxDao.getTotalByStatus(vo);
+    public Integer getTotalByStatus(ElectricBoxDTO dto) {
+        return electricBoxDao.getTotalByStatus(dto);
     }
 
     @Override
-    public Integer getOnlineTotalByStatus(ElectricBoxRequestVO vo) {
-        return electricBoxDao.getOnlineTotalByStatus(vo);
+    public Integer getOnlineTotalByStatus(ElectricBoxDTO dto) {
+        return electricBoxDao.getOnlineTotalByStatus(dto);
     }
 
     @Override
-    public Integer getOfflineTotalByStatus(ElectricBoxRequestVO vo) {
-        return electricBoxDao.getOfflineTotalByStatus(vo);
+    public Integer getOfflineTotalByStatus(ElectricBoxDTO dto) {
+        return electricBoxDao.getOfflineTotalByStatus(dto);
     }
 }

+ 0 - 43
src/main/java/com/welampiot/vo/ElectricBoxRequestVO.java

@@ -1,43 +0,0 @@
-package com.welampiot.vo;
-
-import com.baomidou.mybatisplus.annotation.TableField;
-import lombok.Data;
-
-import java.io.Serializable;
-import java.util.List;
-
-/**
- * ClassName: ElectricBoxRequestVO
- * Package: com.welampiot.vo
- * Description: 筛选配电箱的条件类
- *
- * @Author: zhj_Start
- * @Create: 2023/3/25 - 11:47
- * @Version: v1.0
- */
-@Data
-public class ElectricBoxRequestVO implements Serializable {
-    /** 页数 **/
-    private Integer page;
-
-    /** 单页显示数量 **/
-    private Integer count;
-
-    /** 关键字搜索(可搜索设备名称和设备地址) **/
-    private String keyword;
-
-    /** 区域id筛选 **/
-    private Integer areaId;
-
-    /** 路段id筛选 **/
-    private Integer sectionId;
-
-    /** 在线状态筛选(0全部,1在线,2离线)**/
-    private Integer status;
-
-    /** 所有路段的id **/
-    @TableField(exist = false)
-    private List sectionList;
-
-    private static final long serialVersionUID = 1L;
-}

+ 5 - 0
src/main/resources/application.yml

@@ -17,6 +17,11 @@ spring:
     maxWait: 60000
     #数据库连接中数据源类型
     type: com.alibaba.druid.pool.DruidDataSource
+#  jackson:
+#    serialization:
+#      write-null-map-values: true
+#  gson:
+#    serialize-nulls: true
 mybatis:
   mapper-locations: classpath:/mapper/*.xml
   check-config-location: true

+ 7 - 27
src/main/resources/mapper/ElectricBoxMapper.xml

@@ -2,33 +2,13 @@
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.welampiot.dao.ElectricBoxDao">
 
-    <resultMap id="electricBoxAndAirSwitchInfoResultMap" type="com.welampiot.dto.ElectricBoxDTO">
-        <id property="id" column="id" jdbcType="INTEGER"/>
-        <result property="name" column="name" jdbcType="VARCHAR"/>
-        <result property="sectionId" column="sectionid" jdbcType="INTEGER"/>
-        <result property="areaId" column="areaid" jdbcType="INTEGER"/>
-        <result property="address" column="address" jdbcType="VARCHAR"/>
-        <result property="longitude" column="longitude" jdbcType="FLOAT"/>
-        <result property="latitude" column="latitude" jdbcType="FLOAT"/>
-        <result property="image" column="image" jdbcType="VARCHAR"/>
-        <result property="createTime" column="createTime" jdbcType="DATE"/>
-        <result property="updateTime" column="updateTime" jdbcType="DATE"/>
-        <result property="installDate" column="install_date" jdbcType="DATE"/>
-        <result property="expirationDate" column="expiration_date" jdbcType="DATE"/>
-        <collection property="airSwitchInfoDTOS" ofType="com.welampiot.dto.AirSwitchInfoDTO">
-            <id property="id" column="id" jdbcType="INTEGER"/>
-            <result property="online" column="online" jdbcType="INTEGER"/>
-            <result property="boxId" column="box_id" jdbcType="INTEGER"/>
-        </collection>
-    </resultMap>
-
-    <select id="getElectricBoxListBySectionId" resultMap="electricBoxAndAirSwitchInfoResultMap" parameterType="com.welampiot.vo.ElectricBoxRequestVO">
-        select e.id,e.areaid areaId,e.sectionid sectionId,e.name,e.address,count(a.id) as airCount,a.online,
+    <select id="getElectricBoxListBySectionId" resultType="ElectricBoxDTO" parameterType="ElectricBoxDTO">
+        select e.id,e.areaid as areaId,e.sectionid as sectionId,e.name,e.address,count(a.id) as airCount,
                e.longitude,e.latitude,e.image,e.install_date installDate,e.expiration_date expirationDate,
                (select count(*) from air_switch_info c where c.box_id = e.id and c.online = 1) as onlineCount
         from electric_box e left join air_switch_info a on a.box_id = e.id
-        where <if test="keyword != null and keyword != ''">
-                    e.name like '%${keyword}%' or e.address like '%${keyword}%'
+        where 1=1 <if test="keyword != null and keyword != ''">
+                  and e.name like '%${keyword}%' or e.address like '%${keyword}%'
               </if>
               <choose>
                   <when test="status == 1">
@@ -50,7 +30,7 @@
             </if>
     </select>
 
-    <select id="getTotalByStatus" resultMap="electricBoxAndAirSwitchInfoResultMap" parameterType="com.welampiot.vo.ElectricBoxRequestVO">
+    <select id="getTotalByStatus" resultType="Integer" parameterType="ElectricBoxDTO">
         select count(*) as total
         from (select e.id
               from electric_box e
@@ -62,7 +42,7 @@
                     group by e.id) b
     </select>
 
-    <select id="getOnlineTotalByStatus" resultMap="electricBoxAndAirSwitchInfoResultMap" parameterType="com.welampiot.vo.ElectricBoxRequestVO">
+    <select id="getOnlineTotalByStatus" resultType="Integer" parameterType="ElectricBoxDTO">
         select count(*) as total
         from (select e.id
             from electric_box e
@@ -75,7 +55,7 @@
             group by e.id) b
     </select>
 
-    <select id="getOfflineTotalByStatus" resultMap="electricBoxAndAirSwitchInfoResultMap" parameterType="com.welampiot.vo.ElectricBoxRequestVO">
+    <select id="getOfflineTotalByStatus" resultType="Integer" parameterType="ElectricBoxDTO">
         select count(*) as total
         from (select e.id
             from electric_box e