Преглед изворни кода

照明设备列表、照明设备数据概览

zhj пре 2 година
родитељ
комит
07bbbf9723

+ 101 - 0
src/main/java/com/welampiot/controller/NewLampPoleController.java

@@ -14,6 +14,7 @@ import org.springframework.web.bind.annotation.RequestMethod;
 import org.springframework.web.bind.annotation.RestController;
 
 import javax.servlet.http.HttpServletRequest;
+import java.text.DecimalFormat;
 import java.text.ParseException;
 import java.text.SimpleDateFormat;
 import java.util.*;
@@ -58,6 +59,8 @@ public class NewLampPoleController {
     private LampInfoLogService lampInfoLogService;
     @Autowired
     private LampPoleAlarmLogService lampPoleAlarmLogService;
+    @Autowired
+    private LampInfoLogNewService lampInfoLogNewService;
 
     @RequestMapping(value = "/info",method = RequestMethod.POST)
     public BaseResult info(HttpServletRequest request){
@@ -729,4 +732,102 @@ public class NewLampPoleController {
         listResponseVO.setList(gWRSDevDTOS);
         return toolUtils.response(InterfaceResultEnum.OPERATION_SUCCESS,version,listResponseVO);
     }
+
+    /**
+     * 照明设备列表
+     * @param request 路段筛选,分页,关键字搜索
+     * @return 照明设备列表
+     */
+    @RequestMapping(value = "/lampList",method = RequestMethod.POST)
+    public BaseResult<?> lampList(HttpServletRequest request) {
+        Integer version = (Integer) toolUtils.getRequestContent(request,"version",1);
+        Integer areaId = (Integer) toolUtils.getRequestContent(request,"areaId",1);
+        Integer sectionId = (Integer) toolUtils.getRequestContent(request,"sectionId",1);
+        Integer online = (Integer) toolUtils.getRequestContent(request,"online",1);
+        String keyword = (String) toolUtils.getRequestContent(request,"keyword",2);
+        int page = request.getParameter("page") == null ? 1 : Integer.parseInt(request.getParameter("page"));
+        int count = request.getParameter("count") == null ? 16 : Integer.parseInt(request.getParameter("count"));
+
+        LampVO lampVO = new LampVO();
+        lampVO.setOnline(online);
+        lampVO.setVersion(version);
+        lampVO.setAreaId(areaId);
+        lampVO.setSectionId(sectionId);
+        lampVO.setKeyword(keyword);
+        lampVO.setPage(page);
+        lampVO.setCount(count);
+        lampVO.setSectionList(toolUtils.getSectionList(request));
+        List<LampInfoDTO> lampList = lampService.getLampList(lampVO);
+        List<LampInfoDTO> list = new ArrayList<>();
+        lampList.forEach(dto -> {
+            if (dto.getArea() == null) {
+                dto.setArea("");
+            }
+            if (dto.getSection() == null) {
+                dto.setSection("");
+            }
+            if (dto.getLampPoleName() == null) {
+                dto.setLampPoleName("");
+            }
+            if (dto.getPolicyName() == null) {
+                dto.setPolicyName("");
+            }
+            if (dto.getServerTime() == null) {
+                dto.setServerTime("");
+            }
+            list.add(dto);
+        });
+        Integer lampTotal = lampService.getLampTotal(lampVO);
+        LampVO lampVO1 = new LampVO();
+        lampVO1.setList(list);
+        lampVO1.setTotal(lampTotal);
+        return toolUtils.response(InterfaceResultEnum.OPERATION_SUCCESS,version,lampVO1);
+    }
+
+    /**
+     * 照明数据概览
+     * @param request sectionList、areaId、sectionId
+     * @return lampDataVO
+     */
+    @RequestMapping(value = "/lampInfo", method = RequestMethod.POST)
+    public BaseResult<?> lampInfo(HttpServletRequest request) {
+        Integer version = (Integer) toolUtils.getRequestContent(request, "version", 1);
+        Integer areaId = (Integer) toolUtils.getRequestContent(request, "areaId", 1);
+        Integer sectionId = (Integer) toolUtils.getRequestContent(request, "sectionId", 1);
+
+        LampInfoDTO lampInfoDTO = new LampInfoDTO();
+        lampInfoDTO.setAreaId(areaId);
+        lampInfoDTO.setSectionId(sectionId);
+        lampInfoDTO.setSectionList(toolUtils.getSectionList(request));
+        Integer lampInstallTotal = lampService.getLampInstallTotalByDTO(lampInfoDTO);
+        Integer lampOnlineTotal = lampService.getLampOnlineTotalByDTO(lampInfoDTO);
+        Integer lampFaultTotal = lampService.getLampFaultTotalByDTO(lampInfoDTO);
+        Integer lampLightTotal = lampService.getLampLightTotalByDTO(lampInfoDTO);
+        LampInfoLogNewDTO sumEle = lampInfoLogNewService.getSumEleByDTO(lampInfoDTO);
+        LampInfoLogNewDTO todayEle = lampInfoLogNewService.getTodayEleByDTO(lampInfoDTO);
+        DecimalFormat decimalFormat = new DecimalFormat("0.00");
+        String formatConDayEle,formatConSumEle;
+        Float daySumEle,conSumEle;
+        if (todayEle != null) {
+            daySumEle = Float.parseFloat(todayEle.getSumDayGeneraEnergy());
+            formatConDayEle = decimalFormat.format(daySumEle);
+        } else {
+            daySumEle = 0f;
+            formatConDayEle = "0";
+        }
+        if (sumEle != null) {
+            conSumEle = Float.parseFloat(sumEle.getSumTotalGeneraEnergy()) + daySumEle;
+        } else {
+            conSumEle = 0 + daySumEle;
+        }
+        formatConSumEle = decimalFormat.format(conSumEle);
+        LampDataVO lampDataVO = new LampDataVO();
+        lampDataVO.setInstallCount(lampInstallTotal);
+        lampDataVO.setOnlineCount(lampOnlineTotal);
+        lampDataVO.setFaultCount(lampFaultTotal);
+        lampDataVO.setLightingCount(lampLightTotal);
+        lampDataVO.setConSumEle(formatConSumEle);
+        lampDataVO.setConDayEle(formatConDayEle);
+        return toolUtils.response(InterfaceResultEnum.OPERATION_SUCCESS,version,lampDataVO);
+    }
 }

+ 3 - 0
src/main/java/com/welampiot/dao/LampDao.java

@@ -4,6 +4,7 @@ import com.welampiot.dto.LampInfoDTO;
 import com.welampiot.vo.LampCountVO;
 import com.welampiot.vo.LampListResponseVO;
 import com.welampiot.vo.LampLogVO;
+import com.welampiot.vo.LampVO;
 import org.apache.ibatis.annotations.Param;
 
 import java.util.List;
@@ -35,4 +36,6 @@ public interface LampDao {
     Integer getSectionOfLampCountBySectionId(@Param("id") Integer id);
     String getNameOrNumber(@Param("type") Integer type,@Param("value") Integer value,@Param("version") Integer version);
     LampInfoDTO getLampInfoDTOById(@Param("id") Integer id);
+    List<LampInfoDTO> getLampList(LampVO vo);
+    Integer getLampTotal(LampVO vo);
 }

+ 1 - 0
src/main/java/com/welampiot/dto/LampInfoDTO.java

@@ -75,4 +75,5 @@ public class LampInfoDTO {
     private List<Integer> sectionList;
     private Integer type;
     private Integer alarmType;
+    private String serverTime;
 }

+ 3 - 0
src/main/java/com/welampiot/service/LampService.java

@@ -5,6 +5,7 @@ import com.welampiot.dto.LampInfoDTO;
 import com.welampiot.vo.LampCountVO;
 import com.welampiot.vo.LampListResponseVO;
 import com.welampiot.vo.LampLogVO;
+import com.welampiot.vo.LampVO;
 import org.apache.ibatis.annotations.Param;
 
 import java.util.List;
@@ -37,4 +38,6 @@ public interface LampService {
     Integer getSectionOfLampCountBySectionId(Integer id);
     String getNameOrNumber(Integer type,Integer value,Integer version);
     LampInfoDTO getLampInfoDTOById(@Param("id") Integer id);
+    List<LampInfoDTO> getLampList(LampVO vo);
+    Integer getLampTotal(LampVO vo);
 }

+ 11 - 0
src/main/java/com/welampiot/service/impl/LampServiceImpl.java

@@ -12,6 +12,7 @@ import com.welampiot.utils.ToolUtils;
 import com.welampiot.vo.LampCountVO;
 import com.welampiot.vo.LampListResponseVO;
 import com.welampiot.vo.LampLogVO;
+import com.welampiot.vo.LampVO;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
@@ -350,4 +351,14 @@ public class LampServiceImpl implements LampService {
     public LampInfoDTO getLampInfoDTOById(Integer id) {
         return lampDao.getLampInfoDTOById(id);
     }
+
+    @Override
+    public List<LampInfoDTO> getLampList(LampVO vo) {
+        return lampDao.getLampList(vo);
+    }
+
+    @Override
+    public Integer getLampTotal(LampVO vo) {
+        return lampDao.getLampTotal(vo);
+    }
 }

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

@@ -24,6 +24,8 @@ public class LampDataVO {
 
     private String conSumEle; // 用电量
 
+    private String conDayEle; // 当天用电量
+
     private String saveEle; // 省电量
 
     private String powerRate; // 电费

+ 39 - 0
src/main/java/com/welampiot/vo/LampVO.java

@@ -0,0 +1,39 @@
+package com.welampiot.vo;
+
+import com.welampiot.dto.LampInfoDTO;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.util.List;
+
+/**
+ * ClassName: LampVO
+ * Package: com.welampiot.vo
+ * Description:
+ *
+ * @Author: zhj_Start
+ * @Create: 2023/7/18 - 13:48
+ * @Version: v1.0
+ */
+@Data
+public class LampVO implements Serializable {
+    private Integer page;
+
+    private Integer count;
+
+    private String keyword;
+
+    private Integer areaId;
+
+    private Integer sectionId;
+
+    private List<Integer> sectionList;
+
+    private Integer online;
+
+    private Integer version;
+
+    private Integer total;
+
+    private List<LampInfoDTO> list;
+}

+ 19 - 15
src/main/resources/mapper/LampInfoLogNewMapper.xml

@@ -19,21 +19,22 @@
                sum(l.total_gener_energy_cache) as sumTotalGeneraEnergy
         from lamp_info_log_new l
         left join lampinfo l1 on l.lampid = l1.id
-        <where>
-            1=1
-            <if test="type != null and type == 2">
-                and l1.lamp_pole_id != 0
-            </if>
-            <if test="sectionList != null and !sectionList.isEmpty()">
-                and l1.sectionid in
-                <foreach collection="sectionList" item="item" open="(" separator="," close=")">
-                    #{item}
-                </foreach>
-            </if>
-            <if test="areaId != null and areaId != 0">
-                and l1.areaid = #{areaId}
-            </if>
-        </where>
+        where 1=1
+        <if test="type != null and type == 2">
+            and l1.lamp_pole_id != 0
+        </if>
+        <if test="sectionList != null and !sectionList.isEmpty()">
+            and l1.sectionid in
+            <foreach collection="sectionList" item="item" open="(" separator="," close=")">
+                #{item}
+            </foreach>
+        </if>
+        <if test="areaId != null and areaId != 0">
+            and l1.areaid = #{areaId}
+        </if>
+        <if test="sectionId != null and sectionId != 0">
+            and l1.sectionid = #{sectionId}
+        </if>
     </select>
     
     <select id="getTodayEleByDTO" resultType="com.welampiot.dto.LampInfoLogNewDTO">
@@ -54,6 +55,9 @@
         <if test="areaId != null and areaId != 0">
             and l1.areaid = #{areaId}
         </if>
+        <if test="sectionId != null and sectionId != 0">
+            and l1.sectionid = #{sectionId}
+        </if>
     </select>
     
     <select id="getGeneraEnergy" resultType="LampInfoLogNewDTO">

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

@@ -540,6 +540,9 @@
         <if test="areaId != null and areaId != 0">
             and l.areaid = #{areaId}
         </if>
+        <if test="sectionId != null and sectionId != 0">
+            and l.sectionid = #{sectionId}
+        </if>
     </select>
 
     <!-- 灯控亮灯数 -->
@@ -560,6 +563,9 @@
         <if test="areaId != null and areaId != 0">
             and l.areaid = #{areaId}
         </if>
+        <if test="sectionId != null and sectionId != 0">
+            and l.sectionid = #{sectionId}
+        </if>
     </select>
 
     <!-- 灯控在线数 -->
@@ -580,6 +586,9 @@
         <if test="areaId != null and areaId != 0">
             and l.areaid = #{areaId}
         </if>
+        <if test="sectionId != null and sectionId != 0">
+            and l.sectionid = #{sectionId}
+        </if>
     </select>
 
     <!-- 灯控故障数 -->
@@ -600,6 +609,9 @@
         <if test="areaId != null and areaId != 0">
             and l.areaid = #{areaId}
         </if>
+        <if test="sectionId != null and sectionId != 0">
+            and l.sectionid = #{sectionId}
+        </if>
     </select>
 
     <update id="changeLampLocationById" parameterType="LampInfoDTO">
@@ -653,5 +665,77 @@
         from lampinfo l
         where l.id = #{id}
     </select>
+
+    <select id="getLampList" resultType="com.welampiot.dto.LampInfoDTO">
+        select
+            l.id,l.lamp_pole_id as lampPoleId,lp.name as lampPoleName,w.num as sn,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>
+            ,n.status,l.lighteness,l1.gridcurr as current,l1.gridvolt as voltage,n.protocoltype as protocolType,
+            l1.grid_active_power as power,l.address,l.updatetime as updateTime,l.install_date as installDate,l.online as lampOnline,
+            l.expiration_date as expirationDate,p.name as policyName,l1.devicetime as serverTime,l1.work_time_total as lightTime
+        from lampinfo l
+        left join lamp_pole lp on l.lamp_pole_id = lp.id
+        left join wifi w on lp.id = w.lamp_pole_id
+        left join section s on l.section_id = s.id
+        left join global_location gl on gl.id = l.areaid
+        left join network n on l.networkid = n.id
+        left join lamp_info_log_new l1 on l1.lampid = l.id
+        left join policy p on l.policyid = p.id
+        where 1=1
+        <if test="sectionList != null and !sectionList.isEmpty()">
+            and l.sectionid in
+            <foreach collection="sectionList" item="item" open="(" separator="," close=")">
+                #{item}
+            </foreach>
+        </if>
+        <if test="areaId != null and areaId != 0">
+            and l.areaid = #{areaId}
+        </if>
+        <if test="sectionId != null and sectionId != 0">
+            and l.sectionid = #{sectionId}
+        </if>
+        <if test="keyword != null and keyword != ''">
+            and (l.number like '%${keyword}%' or l.address like '%${keyword}%')
+        </if>
+        <choose>
+            <when test="online == 1">
+                and n.status = 1
+            </when>
+            <otherwise>
+                and n.status = 0
+            </otherwise>
+        </choose>
+        <if test="page >= 0 and count > 0">
+            limit #{page},#{count}
+        </if>
+    </select>
+
+    <select id="getLampTotal" resultType="Integer">
+        select count(*)
+        from lampinfo l
+        where 1=1
+        <if test="sectionList != null and !sectionList.isEmpty()">
+            and l.sectionid in
+            <foreach collection="sectionList" item="item" open="(" separator="," close=")">
+                #{item}
+            </foreach>
+        </if>
+        <if test="areaId != null and areaId != 0">
+            and l.areaid = #{areaId}
+        </if>
+        <if test="sectionId != null and sectionId != 0">
+            and l.sectionid = #{sectionId}
+        </if>
+    </select>
     
 </mapper>