Jelajahi Sumber

获取配电箱列表

zhj 2 tahun lalu
induk
melakukan
d2a28dd6d6

+ 60 - 0
src/main/java/com/welampiot/controller/ElectricBoxController.java

@@ -0,0 +1,60 @@
+package com.welampiot.controller;
+
+import com.welampiot.common.BaseResult;
+import com.welampiot.dao.ElectricBoxDao;
+import com.welampiot.dto.ElectricBoxDTO;
+import com.welampiot.service.ElectricBoxService;
+import com.welampiot.utils.ToolUtils;
+import com.welampiot.vo.ElectricBoxRequestVO;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.CrossOrigin;
+import org.springframework.web.bind.annotation.PostMapping;
+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
+ * Package: com.welampiot.controller
+ * Description:
+ *
+ * @Author: zhj_Start
+ * @Create: 2023/3/25 - 14:57
+ * @Version: v1.0
+ */
+@RestController
+@CrossOrigin
+@RequestMapping("/api/electricBox")
+public class ElectricBoxController {
+    @Autowired
+    private ElectricBoxService electricBoxService;
+
+    @Autowired
+    private ToolUtils toolUtils;
+
+    /**
+     * 获取电箱列表
+     * @param request
+     * @return
+     */
+    @PostMapping("/devList")
+    public BaseResult<ElectricBoxDTO> devList(HttpServletRequest request){
+        Integer page = request.getParameter("page") == null ? 0 : Integer.parseInt(request.getParameter("page"));
+        Integer count = request.getParameter("count") == null ? 16 : Integer.parseInt(request.getParameter("count"));
+        Integer status = request.getParameter("status") == null ? 0 : Integer.parseInt(request.getParameter("status"));
+        String keyword = request.getParameter("keyword") == null ? "0" : 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));
+
+        List<ElectricBoxDTO> electricBoxList = electricBoxService.getElectricBoxListBySectionId(vo);
+        return BaseResult.success(electricBoxList);
+    }
+}

+ 20 - 0
src/main/java/com/welampiot/dao/ElectricBoxDao.java

@@ -0,0 +1,20 @@
+package com.welampiot.dao;
+
+import com.welampiot.dto.ElectricBoxDTO;
+import com.welampiot.vo.ElectricBoxRequestVO;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+
+/**
+ * ClassName: ElectricBoxDao
+ * Package: com.welampiot.dao
+ * Description:
+ *
+ * @Author: zhj_Start
+ * @Create: 2023/3/24 - 11:16
+ * @Version: v1.0
+ */
+public interface ElectricBoxDao {
+    List<ElectricBoxDTO> getElectricBoxListBySectionId(ElectricBoxRequestVO vo);
+}

+ 3 - 3
src/main/java/com/welampiot/dto/AirSwitchInfoDTO.java

@@ -74,13 +74,13 @@ public class AirSwitchInfoDTO implements Serializable {
     private Float tempC;
 
     /** 数据更新时间(0时区) **/
-    private Date logtime;
+    private Date logTime;
 
     /** 设备创建时间 **/
-    private Date createtime;
+    private Date createTime;
 
     /** 策略id **/
-    private Integer policyid;
+    private Integer policyId;
 
     /** 设备类型(0 单相,1 三相) **/
     private Integer type;

+ 17 - 4
src/main/java/com/welampiot/dto/ElectricBoxDTO.java

@@ -4,6 +4,7 @@ import lombok.Data;
 
 import java.io.Serializable;
 import java.util.Date;
+import java.util.List;
 
 /**
  * ClassName: ElectricBoxDTO
@@ -20,10 +21,10 @@ public class ElectricBoxDTO implements Serializable {
     private Integer id;
 
     /** 街道/路段id **/
-    private Integer sectionid;
+    private Integer sectionId;
 
     /** 区/县id **/
-    private Integer areaid;
+    private Integer areaId;
 
     /** 设备名称 **/
     private String name;
@@ -32,13 +33,13 @@ public class ElectricBoxDTO implements Serializable {
     private String address;
 
     /** 更新时间 **/
-    private Date updatetime;
+    private Date updateTime;
 
     /** 控制类型(0 手动,1 策略) **/
     private Integer controlType;
 
     /** 策略id **/
-    private Integer policyid;
+    private Integer policyId;
 
     /** 经度 **/
     private Double longitude;
@@ -52,5 +53,17 @@ public class ElectricBoxDTO implements Serializable {
     /** 配电箱绑定的图片 **/
     private String image;
 
+    /** 安装时间 **/
+    private Date installDate;
+
+    /** 过期时间 **/
+    private Date expirationDate;
+
+    /** 配电箱多对一路段 **/
+    private SectionDTO sectionDTO;
+
+    /** 配电箱一对多空开 **/
+    private List<AirSwitchInfoDTO> airSwitchInfoDTOS;
+
     private static final long serialVersionUID = 1L;
 }

+ 2 - 2
src/main/java/com/welampiot/dto/GlobalLocationDTO.java

@@ -23,7 +23,7 @@ public class GlobalLocationDTO implements Serializable {
 
     private String ruName;//俄语名称
 
-    private Integer childcount;//下级区域数量
+    private Integer childCount;//下级区域数量
 
     private Integer level;//区域等级
 
@@ -31,7 +31,7 @@ public class GlobalLocationDTO implements Serializable {
 
     private Integer pid;//上级区域id
 
-    private String parentcode;//上级区域编码
+    private String parentCode;//上级区域编码
 
     private Integer timezone;//时区
 

+ 1 - 1
src/main/java/com/welampiot/dto/LoopPolicyDTO.java

@@ -26,7 +26,7 @@ public class LoopPolicyDTO implements Serializable {
     private Integer userid;
 
     /** 创建时间 **/
-    private Date createtime;
+    private Date createTime;
 
     /** 是否更新策略信息 **/
     private Integer isUpdate;

+ 27 - 91
src/main/java/com/welampiot/dto/SectionDTO.java

@@ -16,117 +16,53 @@ import java.util.Date;
  */
 @Data
 public class SectionDTO implements Serializable {
-    /**
-     * 主键id
-     *
-     * @mbg.generated
-     */
+    /** 主键 **/
     private Integer id;
 
-    /**
-     * 上级区域id
-     *
-     * @mbg.generated
-     */
+    /** 上级区域id **/
     private Integer pid;
 
-    /**
-     * 路段名称
-     *
-     * @mbg.generated
-     */
+    /** 路段名称 **/
     private String name;
 
-    /**
-     * 设备数量
-     *
-     * @mbg.generated
-     */
-    private Integer devcount;
-
-    /**
-     * 路灯数量
-     *
-     * @mbg.generated
-     */
-    private Integer lampcount;
-
-    /**
-     * 灯杆数量
-     *
-     * @mbg.generated
-     */
+    /** 设备数量 **/
+    private Integer devCount;
+
+    /** 路灯数量 **/
+    private Integer lampCount;
+
+    /** 灯杆数量 **/
     private Integer lampPoleCount;
 
-    /**
-     * 环境监控数
-     *
-     * @mbg.generated
-     */
+    /** 环境监控数 **/
     private Integer weatherCount;
 
-    /**
-     * 视屏监控数
-     *
-     * @mbg.generated
-     */
+    /** 视屏监控数 **/
     private Integer videoCount;
 
-    /**
-     * 光照传感器数量
-     *
-     * @mbg.generated
-     */
+    /** 光照传感器数量 **/
     private Integer illuminanceCount;
 
-    /**
-     * 创建时间
-     *
-     * @mbg.generated
-     */
-    private Date createtime;
-
-    /**
-     * 时区
-     *
-     * @mbg.generated
-     */
+    /** 创建时间 **/
+    private Date createTime;
+
+    /** 时区 **/
     private Integer timezone;
 
-    /**
-     * 网关sn地址,智慧校园使用
-     *
-     * @mbg.generated
-     */
-    private String netsn;
-
-    /**
-     * 推送人员id(多个用逗号隔开)
-     *
-     * @mbg.generated
-     */
-    private String alarmuser;
-
-    /**
-     * 日出
-     *
-     * @mbg.generated
-     */
+    /** 网关sn地址,智慧校园使用 **/
+    private String netSn;
+
+    /** 推送人员id(多个用逗号隔开) **/
+    private String alarmUser;
+
+    /** 日出 **/
     private String sunrise;
 
-    /**
-     * 日落
-     *
-     * @mbg.generated
-     */
+    /** 日落 **/
     private String sunset;
 
-    /**
-     * 日出日落更新时间
-     *
-     * @mbg.generated
-     */
-    private Date sunupdatetime;
+    /** 日出日落更新时间 **/
+    private Date sunUpdateTime;
 
     private static final long serialVersionUID = 1L;
 }

+ 19 - 0
src/main/java/com/welampiot/service/ElectricBoxService.java

@@ -0,0 +1,19 @@
+package com.welampiot.service;
+
+import com.welampiot.dto.ElectricBoxDTO;
+import com.welampiot.vo.ElectricBoxRequestVO;
+
+import java.util.List;
+
+/**
+ * ClassName: ElectricBoxService
+ * Package: com.welampiot.service
+ * Description:
+ *
+ * @Author: zhj_Start
+ * @Create: 2023/3/25 - 14:37
+ * @Version: v1.0
+ */
+public interface ElectricBoxService {
+    List<ElectricBoxDTO> getElectricBoxListBySectionId(ElectricBoxRequestVO vo);
+}

+ 34 - 0
src/main/java/com/welampiot/service/impl/ElectricBoxServiceImpl.java

@@ -0,0 +1,34 @@
+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 org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+/**
+ * ClassName: ElectricBoxServiceImpl
+ * Package: com.welampiot.service.impl
+ * Description:
+ *
+ * @Author: zhj_Start
+ * @Create: 2023/3/25 - 14:46
+ * @Version: v1.0
+ */
+@Service
+public class ElectricBoxServiceImpl implements ElectricBoxService {
+
+    @Autowired
+    private ElectricBoxDao electricBoxDao;
+
+    @Override
+    public List<ElectricBoxDTO> getElectricBoxListBySectionId(ElectricBoxRequestVO vo) {
+
+
+
+        return electricBoxDao.getElectricBoxListBySectionId(vo);
+    }
+}

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

@@ -0,0 +1,43 @@
+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;
+}

+ 62 - 0
src/main/java/com/welampiot/vo/ElectricBoxReturnVO.java

@@ -0,0 +1,62 @@
+package com.welampiot.vo;
+
+import lombok.Data;
+
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ * ClassName: ElectricBoxReturnVO
+ * Package: com.welampiot.vo
+ * Description: 返回电箱查询结果类
+ *
+ * @Author: zhj_Start
+ * @Create: 2023/3/25 - 11:35
+ * @Version: v1.0
+ */
+@Data
+public class ElectricBoxReturnVO implements Serializable {
+    /** 设备总数 **/
+    private Integer total;
+
+    /** 设备总数 **/
+    private Integer devTotal;
+
+    /** 在线数 **/
+    private Integer onlineTotal;
+
+    /** 离线数 **/
+    private Integer offlineTotal;
+
+    /** 电箱id **/
+    private Integer id;
+
+    /** 电箱名称 **/
+    private String name;
+
+    /** 电箱地址 **/
+    private String address;
+
+    /** 空开个数 **/
+    private Integer airCount;
+
+    /** 经度 **/
+    private Float longitude;
+
+    /** 纬度 **/
+    private Float latitude;
+
+    /** 在线状态(0离线,1在线) **/
+    private Integer online;
+
+    /** 配电箱绑定的图片 **/
+    private String image;
+
+    /** 安装时间 **/
+    private Date installDate;
+
+    /** 过期时间 **/
+    private Date expirationDate;
+
+    private static final long serialVersionUID = 1L;
+}

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

@@ -21,6 +21,8 @@ mybatis:
   mapper-locations: classpath:/mapper/*.xml
   check-config-location: true
   type-aliases-package: com.welampiot
+  configuration:
+    log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
 debug: true
 
 logging:

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

@@ -0,0 +1,45 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!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="electricBoxAndSectionAndAirSwitchInfoResultMap" 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="electricBoxAndSectionAndAirSwitchInfoResultMap" 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,
+               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}%'
+              </if>
+            and <if test="sectionList != null and !sectionList.isEmpty()">
+                    e.sectionid in
+                    <foreach item="vo" collection="sectionList" open="(" separator="," close=")">
+                        #{vo.sectionId}
+                    </foreach>
+                </if>
+            order by convert(e.name using gbk) asc,e.id desc
+            <if test="page != 0">
+                 limit #{page},#{count}
+            </if>
+    </select>
+
+</mapper>