瀏覽代碼

配电柜设备列表

crazycat 2 年之前
父節點
當前提交
43f270f355

+ 2 - 2
src/main/java/com/welampiot/controller/BroadcastController.java

@@ -43,9 +43,9 @@ public class BroadcastController {
      */
     @RequestMapping(value = "/devList", method = RequestMethod.POST)
     public BaseResult<BroadcastDTO> devList(HttpServletRequest request){
-        Integer online = request.getParameter("online") == null ? 0 : Integer.parseInt(request.getParameter("online"));
+        Integer online = request.getParameter("online") == null || request.getParameter("online").length() == 0 ? null : Integer.parseInt(request.getParameter("online"));
         BroadcastDTO dto = new BroadcastDTO();
-        dto.setOnlineState(online);
+        if (online != null) dto.setOnlineState(online);
         dto.setSectionList(toolUtils.getSectionList(request));
 
         BroadcastVO vo = broadcastService.getDevListByBroadcastDTO(dto);

+ 10 - 4
src/main/java/com/welampiot/controller/ElectricBoxController.java

@@ -47,14 +47,14 @@ public class ElectricBoxController {
      */
     @PostMapping("/devList")
     public BaseResult<ElectricBoxDTO> devList(HttpServletRequest request){
-        Integer page = request.getParameter("page") == null ? 1 : Integer.parseInt(request.getParameter("page"));
-        Integer count = request.getParameter("count") == null ? 16 : Integer.parseInt(request.getParameter("count"));
+        Integer page = request.getParameter("page") == null || request.getParameter("page").length() == 0? null : Integer.parseInt(request.getParameter("page"));
+        Integer count = request.getParameter("count") == null || request.getParameter("count").length() == 0 ? null : Integer.parseInt(request.getParameter("count"));
         Integer status = request.getParameter("status") == null ? 0 : Integer.parseInt(request.getParameter("status"));
         String keyword = request.getParameter("keyword") == null ? "" : request.getParameter("keyword");
 
         ElectricBoxDTO dto = new ElectricBoxDTO();
-        dto.setPage(count*(page-1));
-        dto.setCount(count);
+        if (page != null && count != null) dto.setPage(count*(page-1));
+        if (count != null) dto.setCount(count);
         dto.setStatus(status);
         dto.setKeyword(keyword);
         dto.setSectionList(toolUtils.getSectionList(request));
@@ -97,4 +97,10 @@ public class ElectricBoxController {
         if (airSwitchDetail == null) return toolUtils.response(InterfaceResultEnum.PARAM_FAIL,version);
         return BaseResult.success(airSwitchDetail);
     }
+
+    @PostMapping("/saveDev")
+    public BaseResult saveDev(ElectricBoxDTO electricBoxDTO){
+        Integer version = electricBoxDTO.getVersion() == null ? 0 : electricBoxDTO.getVersion();
+        return toolUtils.response(InterfaceResultEnum.OPERATION_SUCCESS,version);
+    }
 }

+ 1 - 1
src/main/java/com/welampiot/controller/TranshController.java

@@ -24,7 +24,7 @@ import javax.servlet.http.HttpServletRequest;
  */
 @RestController
 @CrossOrigin
-@RequestMapping("/transhController")
+@RequestMapping("/transh")
 public class TranshController {
 
     @Autowired

+ 12 - 0
src/main/java/com/welampiot/dao/ElectricModuleDao.java

@@ -0,0 +1,12 @@
+package com.welampiot.dao;
+
+import com.welampiot.dto.ElectricModuleDTO;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+
+public interface ElectricModuleDao {
+    Integer add(ElectricModuleDTO electricModuleDTO);
+    Integer update(ElectricModuleDTO electricModuleDTO);
+    List<ElectricModuleDTO> getListByBoxId(@Param("boxId")Integer boxId);
+}

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

@@ -5,6 +5,7 @@ import lombok.Data;
 import java.io.Serializable;
 import java.util.Date;
 import java.util.List;
+import java.util.Map;
 
 /**
  * ClassName: ElectricBoxDTO
@@ -42,10 +43,10 @@ public class ElectricBoxDTO implements Serializable {
     private Integer policyId;
 
     /** 经度 **/
-    private Double longitude;
+    private String longitude;
 
     /** 纬度 **/
-    private Double latitude;
+    private String latitude;
 
     /** 策略数量 **/
     private Integer cid;
@@ -84,4 +85,7 @@ public class ElectricBoxDTO implements Serializable {
     private List sectionList;
 
     private static final long serialVersionUID = 1L;
+    private Integer devType; // 设备型号(0 曼顿,1 微自然)
+    private List<Map> moduleList;
+    private Integer version;
 }

+ 11 - 0
src/main/java/com/welampiot/dto/ElectricModuleDTO.java

@@ -0,0 +1,11 @@
+package com.welampiot.dto;
+
+import lombok.Data;
+
+@Data
+public class ElectricModuleDTO {
+    private Integer id;
+    private String address;
+    private Integer type;
+    private Integer boxId;
+}

+ 12 - 0
src/main/java/com/welampiot/service/ElectricModuleService.java

@@ -0,0 +1,12 @@
+package com.welampiot.service;
+
+import com.welampiot.dto.ElectricModuleDTO;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+
+public interface ElectricModuleService {
+    Integer add(ElectricModuleDTO electricModuleDTO);
+    Integer update(ElectricModuleDTO electricModuleDTO);
+    List<ElectricModuleDTO> getListByBoxId(@Param("boxId")Integer boxId);
+}

+ 19 - 1
src/main/java/com/welampiot/service/impl/ElectricBoxServiceImpl.java

@@ -2,7 +2,9 @@ package com.welampiot.service.impl;
 
 import com.welampiot.dao.ElectricBoxDao;
 import com.welampiot.dto.ElectricBoxDTO;
+import com.welampiot.dto.ElectricModuleDTO;
 import com.welampiot.service.ElectricBoxService;
+import com.welampiot.service.ElectricModuleService;
 import com.welampiot.vo.ElectricBoxReturnVO;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
@@ -10,7 +12,9 @@ import org.springframework.stereotype.Service;
 import java.text.ParseException;
 import java.text.SimpleDateFormat;
 import java.util.ArrayList;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 
 /**
  * ClassName: ElectricBoxServiceImpl
@@ -26,6 +30,8 @@ public class ElectricBoxServiceImpl implements ElectricBoxService {
 
     @Autowired
     private ElectricBoxDao electricBoxDao;
+    @Autowired
+    protected ElectricModuleService electricModuleService;
 
     @Override
     public ElectricBoxReturnVO getElectricBoxListBySectionId(ElectricBoxDTO dto) {
@@ -62,9 +68,21 @@ public class ElectricBoxServiceImpl implements ElectricBoxService {
             }else {
                 electricBoxDTO.setOnline(0);
             }
+            List<ElectricModuleDTO> listByBoxId = electricModuleService.getListByBoxId(electricBoxDTO.getId());
+            List<Map> maps = new ArrayList<>();
+            for (ElectricModuleDTO e :listByBoxId) {
+                Map<Object, Object> objectObjectMap = new HashMap<>();
+                objectObjectMap.put("id",e.getId());
+                objectObjectMap.put("boxId",e.getBoxId());
+                objectObjectMap.put("address",e.getAddress());
+                objectObjectMap.put("type",e.getType());
+                maps.add(objectObjectMap);
+            }
+            electricBoxDTO.setModuleList(maps);
+            if (electricBoxDTO.getDevType() == null) electricBoxDTO.setDevType(0);
             electricBoxDTOS.add(electricBoxDTO);
         });
-        electricBoxReturnVO.setElectricBoxList(electricBoxDTOS);
+        electricBoxReturnVO.setList(electricBoxDTOS);
 
         return electricBoxReturnVO;
     }

+ 29 - 0
src/main/java/com/welampiot/service/impl/ElectricModuleServiceImpl.java

@@ -0,0 +1,29 @@
+package com.welampiot.service.impl;
+
+import com.welampiot.dao.ElectricModuleDao;
+import com.welampiot.dto.ElectricModuleDTO;
+import com.welampiot.service.ElectricModuleService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+@Service
+public class ElectricModuleServiceImpl implements ElectricModuleService {
+    @Autowired
+    private ElectricModuleDao electricModuleDao;
+    @Override
+    public Integer add(ElectricModuleDTO electricModuleDTO) {
+        return electricModuleDao.add(electricModuleDTO);
+    }
+
+    @Override
+    public Integer update(ElectricModuleDTO electricModuleDTO) {
+        return electricModuleDao.update(electricModuleDTO);
+    }
+
+    @Override
+    public List<ElectricModuleDTO> getListByBoxId(Integer boxId) {
+        return electricModuleDao.getListByBoxId(boxId);
+    }
+}

+ 1 - 1
src/main/java/com/welampiot/service/impl/ManholeServiceImpl.java

@@ -95,7 +95,7 @@ public class ManholeServiceImpl implements ManholeService {
                         manholeDTO.setUpdateTime("");
                     }
                     //获取设备创建时间
-                    if (manholeDTO.getCreateTime() == null && !manholeDTO.getCreateTime().equals("")){
+                    if (manholeDTO.getCreateTime() == null || !manholeDTO.getCreateTime().equals("")){
                         manholeDTO.setCreateTime("");
                     }else {
                         try {

+ 1 - 1
src/main/java/com/welampiot/vo/ElectricBoxReturnVO.java

@@ -29,7 +29,7 @@ public class ElectricBoxReturnVO implements Serializable {
     /** 离线数 **/
     private Integer offlineTotal;
 
-    private List electricBoxList;
+    private List list;
 
     private static final long serialVersionUID = 1L;
 }

+ 49 - 15
src/main/resources/mapper/ElectricBoxMapper.xml

@@ -2,11 +2,11 @@
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.welampiot.dao.ElectricBoxDao">
 
-    <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,
+    <select id="getElectricBoxListBySectionId" resultType="com.welampiot.dto.ElectricBoxDTO" parameterType="ElectricBoxDTO">
+        select e.id,e.areaid as areaId,e.sectionid as sectionId,e.name,e.address,(select count(*) from air_switch_info c where c.box_id = e.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
+               (select count(*) from air_switch_info c where c.box_id = e.id and c.online = 1) as onlineCount,e.devType
+        from electric_box e
         where 1=1 <if test="keyword != null and keyword != ''">
                   and (e.name like '%${keyword}%' or e.address like '%${keyword}%')
               </if>
@@ -18,8 +18,8 @@
                      and (select count(*) from air_switch_info c where c.box_id = e.id and c.online = 1) = 0
                   </when>
               </choose>
-            and <if test="sectionList != null and !sectionList.isEmpty()">
-                    e.sectionid in
+             <if test="sectionList != null and !sectionList.isEmpty()">
+                 and e.sectionid in
                     <foreach item="dto" collection="sectionList" open="(" separator="," close=")">
                         #{dto}
                     </foreach>
@@ -35,11 +35,13 @@
         from (select e.id
               from electric_box e
                   left join air_switch_info a on e.id = a.box_id
-              where e.sectionid in
-                    <foreach item="dto" collection="sectionList" open="(" separator="," close=")">
-                        #{dto}
-                    </foreach>
-                    group by e.id) b
+        <if test="sectionList != null and !sectionList.isEmpty()">
+          where e.sectionid in
+        <foreach item="dto" collection="sectionList" open="(" separator="," close=")">
+            #{dto}
+        </foreach>
+        </if>
+        group by e.id) b
     </select>
 
     <select id="getOnlineTotalByStatus" resultType="Integer" parameterType="ElectricBoxDTO">
@@ -47,11 +49,14 @@
         from (select e.id
             from electric_box e
             left join air_switch_info a on e.id = a.box_id
-            where e.sectionid in
+
+        where(select count(*) from air_switch_info c where c.box_id = e.id and c.online = 1) > 0
+        <if test="sectionList != null and !sectionList.isEmpty()">
+        and e.sectionid in
             <foreach item="dto" collection="sectionList" open="(" separator="," close=")">
                 #{dto}
             </foreach>
-            and (select count(*) from air_switch_info c where c.box_id = e.id and c.online = 1) > 0
+        </if>
             group by e.id) b
     </select>
 
@@ -60,12 +65,41 @@
         from (select e.id
             from electric_box e
             left join air_switch_info a on e.id = a.box_id
-            where e.sectionid in
+            where (select count(*) from air_switch_info c where c.box_id = e.id and c.online = 1) = 0
+        <if test="sectionList != null and !sectionList.isEmpty()">
+        and e.sectionid in
             <foreach item="dto" collection="sectionList" open="(" separator="," close=")">
                 #{dto}
             </foreach>
-            and (select count(*) from air_switch_info c where c.box_id = e.id and c.online = 1) = 0
+        </if>
             group by e.id) b
     </select>
+    <insert id="add" parameterType="com.welampiot.dto.ElectricBoxDTO" useGeneratedKeys="true" keyProperty="id"
+    >
+        insert into electric_box(name,address,areaid,sectionid,longitude,latitude,createTime,devType
+        <if test="installDate != null">,install_date</if>
+        <if test="expirationDate != null">,expiration_date</if>
+        )
+        values
+        (#{name},#{address},#{areaId},#{sectionId},#{longitude},#{latitude},#{createTime},#{devType}
+        <if test="installDate != null">,#{installDate}</if>
+        <if test="expirationDate != null">,#{expirationDate}</if>
+        )
+    </insert>
+    <update id="update" parameterType="com.welampiot.dto.ElectricBoxDTO"
+    >
+        update electric_box
+        set
+        name=#{name},
+        address=#{address},
+        areaid=#{areaId},
+        sectionid=#{sectionId},
+        longitude=#{longitude},
+        latitude=#{latitude},
+        <if test="installDate != null">install_date=#{installDate},</if>
+        <if test="expirationDate != null">expiration_date=#{expirationDate},</if>
+        devType=#{devType}
 
+        where id = #{id}
+    </update>
 </mapper>

+ 25 - 0
src/main/resources/mapper/ElectricModuleMapper.xml

@@ -0,0 +1,25 @@
+<?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.ElectricModuleDao">
+    <insert id="add" parameterType="com.welampiot.dto.ElectricModuleDTO" useGeneratedKeys="true" keyProperty="id"
+    >
+        insert into electric_module(type,address,box_id
+        )
+        values
+        (#{type},#{address},#{boxId}
+        )
+    </insert>
+    <update id="update" parameterType="com.welampiot.dto.ElectricModuleDTO"
+    >
+        update electric_module
+        set
+        type=#{type},
+        address=#{address},
+        box_id=#{boxId}
+
+        where id = #{id}
+    </update>
+    <select id="getListByBoxId" resultType="com.welampiot.dto.ElectricModuleDTO" parameterType="int">
+        select address,id,box_id as boxId,type from electric_module where box_id = #{boxId}
+    </select>
+</mapper>

+ 8 - 6
src/main/resources/mapper/ManholeMapper.xml

@@ -4,8 +4,9 @@
 
     <select id="getTotalBySectionList" resultType="Integer">
         select count(m.id) as total from manhole m
+        where m.type=0
         <if test="sectionList != null and !sectionList.isEmpty()">
-            where m.sectionid in
+            and m.sectionid in
             <foreach collection="sectionList" item="dto" open="(" separator="," close=")">
                 #{dto}
             </foreach>
@@ -14,7 +15,7 @@
 
     <select id="getOnlineTotalBySectionList" resultType="Integer">
         select count(m.id) as onlineTotal from manhole m
-        where m.online = 1
+        where m.online = 1 and m.type=0
         <if test="sectionList != null and !sectionList.isEmpty()">
             and m.sectionid in
             <foreach collection="sectionList" item="dto" open="(" separator="," close=")">
@@ -25,7 +26,7 @@
 
     <select id="getAlarmTotalBySectionList" resultType="Integer">
         select count(m.id) as alarmTotal from manhole m
-        where m.online = 1 and (m.openAlarm = 1 or m.overAlarm = 1 or m.airAlarm = 1 or m.dismanAlarm = 1)
+        where m.type=0 and m.online = 1 and (m.openAlarm = 1 or m.overAlarm = 1 or m.airAlarm = 1 or m.dismanAlarm = 1)
         <if test="sectionList != null and !sectionList.isEmpty()">
             and m.sectionid in
             <foreach collection="sectionList" item="dto" open="(" separator="," close=")">
@@ -36,7 +37,7 @@
 
     <select id="getNormalTotalBySectionList" resultType="Integer">
         select count(m.id) as normalTotal from manhole m
-        where m.online = 1 and m.overAlarm = 0 and m.openAlarm = 0 and m.airAlarm = 0 and m.dismanAlarm = 0
+        where m.type=0 and m.online = 1 and m.overAlarm = 0 and m.openAlarm = 0 and m.airAlarm = 0 and m.dismanAlarm = 0
         <if test="sectionList != null and !sectionList.isEmpty()">
             and m.sectionid in
             <foreach collection="sectionList" item="dto" open="(" separator="," close=")">
@@ -47,8 +48,9 @@
 
     <select id="getNewTotalBySectionList" resultType="ManholeDTO">
         select m.id,m.createTime from manhole m
+        where m.type=0
         <if test="sectionList != null and !sectionList.isEmpty()">
-            where m.sectionid in
+            and m.sectionid in
             <foreach collection="sectionList" item="dto" open="(" separator="," close=")">
                 #{dto}
             </foreach>
@@ -64,7 +66,7 @@
         from manhole m left join section s on m.sectionid = s.id
             left join global_location g on m.areaid = g.id
             left join global_location p on g.pid = p.id
-        where 1=1 <if test="sectionList != null and !sectionList.isEmpty()">
+        where m.type=0 <if test="sectionList != null and !sectionList.isEmpty()">
                     and m.sectionid in
                     <foreach collection="sectionList" item="dto" open="(" separator="," close=")">
                         #{dto}