فهرست منبع

可视化报表、获取设备灯杆方向图标、灯控列表

zhj 2 سال پیش
والد
کامیت
6f35d15f1e

+ 49 - 8
src/main/java/com/welampiot/controller/ElectricBoxController.java

@@ -2,18 +2,13 @@ package com.welampiot.controller;
 
 import com.welampiot.common.BaseResult;
 import com.welampiot.common.InterfaceResultEnum;
-import com.welampiot.dto.AirSwitchInfoDTO;
-import com.welampiot.dto.ElectricBoxDTO;
-import com.welampiot.dto.ElectricModuleDTO;
-import com.welampiot.dto.LoopPolicyCmdDTO;
-import com.welampiot.service.AirSwitchInfoService;
-import com.welampiot.service.ElectricBoxService;
-import com.welampiot.service.ElectricModuleService;
-import com.welampiot.service.LoopPolicyCmdService;
+import com.welampiot.dto.*;
+import com.welampiot.service.*;
 import com.welampiot.utils.ToolUtils;
 import com.welampiot.vo.AirSwitchDetailVO;
 import com.welampiot.vo.AirSwitchInfoReturnVO;
 import com.welampiot.vo.ElectricBoxReturnVO;
+import com.welampiot.vo.LampVO;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.transaction.interceptor.TransactionAspectSupport;
@@ -57,6 +52,9 @@ public class ElectricBoxController {
     @Autowired
     private LoopPolicyCmdService loopPolicyCmdService;
 
+    @Autowired
+    private AirSwitchLampService airSwitchLampService;
+
     /**
      * 获取电箱列表
      * @param request
@@ -753,4 +751,47 @@ public class ElectricBoxController {
             return toolUtils.response(InterfaceResultEnum.COMMAND_FAIL,version);
         }
     }
+
+    /**
+     * 灯控列表(空开绑定灯控使用)
+     * @param request 电箱id,空开id
+     * @return 灯控列表(空开绑定灯控使用)
+     */
+    @RequestMapping(value = "/lampList", method = RequestMethod.POST)
+    public BaseResult<?> lampList(HttpServletRequest request) {
+        Integer version = (Integer) toolUtils.getRequestContent(request,"version",1);
+        Integer boxId = (Integer) toolUtils.getRequestContent(request,"boxId",1);
+        Integer id = (Integer) toolUtils.getRequestContent(request,"id",1);
+        List<LampInfoDTO> airSwitchLampList;
+        if (id == 0) {
+            if (boxId == 0) return toolUtils.response(InterfaceResultEnum.LACK_PARAM_ERROR,version);
+            ElectricBoxDTO dto = electricBoxService.getDetailsById(boxId);
+            if (dto == null) return toolUtils.response(InterfaceResultEnum.LACK_PARAM_ERROR,version);
+            Integer sectionId = dto.getSectionId();
+            airSwitchLampList = airSwitchLampService.getAirSwitchLampListBySectionId(sectionId,version);
+            airSwitchLampList.forEach(dto1 -> {
+                dto1.setSelect(0);
+                if (dto1.getLampStatus() == 1) {
+                    dto1.setLampStatusStr("开灯");
+                } else {
+                    dto1.setLampStatusStr("关灯");
+                }
+                if (dto1.getPolicyName() == null) dto1.setPolicyName("");
+            });
+        } else {
+            airSwitchLampList = airSwitchLampService.getAirSwitchLampListByAirSwitchId(id,version);
+            airSwitchLampList.forEach(dto1 -> {
+                dto1.setSelect(1);
+                if (dto1.getLampStatus() == 1) {
+                    dto1.setLampStatusStr("开灯");
+                } else {
+                    dto1.setLampStatusStr("关灯");
+                }
+                if (dto1.getPolicyName() == null) dto1.setPolicyName("");
+            });
+        }
+        LampVO lampVO = new LampVO();
+        lampVO.setList(airSwitchLampList);
+        return toolUtils.response(InterfaceResultEnum.OPERATION_SUCCESS,version,lampVO);
+    }
 }

+ 39 - 0
src/main/java/com/welampiot/controller/LampPoleController.java

@@ -8,6 +8,7 @@ import com.welampiot.utils.ToolUtils;
 import com.welampiot.vo.*;
 import org.json.JSONArray;
 import org.json.JSONObject;
+import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.transaction.interceptor.TransactionAspectSupport;
@@ -711,4 +712,42 @@ public class LampPoleController {
         }
         return toolUtils.response(InterfaceResultEnum.OPERATION_SUCCESS,version);
     }
+
+    /**
+     * 获取灯杆方向图标信息
+     * @param request id
+     * @return 获取灯杆方向图标信息
+     */
+    @RequestMapping(value = "getLampPoleIcon", method = RequestMethod.POST)
+    public BaseResult<?> getLampPoleIcon(HttpServletRequest request) {
+        Integer version = (Integer) toolUtils.getRequestContent(request,"version",1);
+        Integer id = (Integer) toolUtils.getRequestContent(request,"id",1);
+        if (id == 0) return toolUtils.response(InterfaceResultEnum.LACK_PARAM_ERROR,version);
+        LampPoleDTO lampPoleDTO = lampPoleService.getLampPoleDTOById(id);
+        if (lampPoleDTO == null) return toolUtils.response(InterfaceResultEnum.LACK_PARAM_ERROR,version);
+        LampPoleVO lampPoleVO = new LampPoleVO();
+        BeanUtils.copyProperties(lampPoleDTO,lampPoleVO);
+        return toolUtils.response(InterfaceResultEnum.OPERATION_SUCCESS,version,lampPoleVO);
+    }
+
+    /**
+     * 设置灯杆方向图标
+     * @param request id
+     * @return 设置灯杆方向图标
+     */
+    @RequestMapping(value = "setLampPoleIcon", method = RequestMethod.POST)
+    public BaseResult<?> setLampPoleIcon(HttpServletRequest request) {
+        Integer version = (Integer) toolUtils.getRequestContent(request,"version",1);
+        Integer id = (Integer) toolUtils.getRequestContent(request,"id",1);
+        Integer dir = (Integer) toolUtils.getRequestContent(request,"dir",1);
+        String iconInfo = (String) toolUtils.getRequestContent(request,"iconInfo",2);
+        if (id == 0 || iconInfo.isEmpty())
+            return toolUtils.response(InterfaceResultEnum.LACK_PARAM_ERROR,version);
+        LampPoleDTO lampPoleDTO = new LampPoleDTO();
+        lampPoleDTO.setLampId(id);
+        lampPoleDTO.setDir(dir);
+        lampPoleDTO.setIconInfo(iconInfo);
+        lampPoleService.updateLampPoleIcon(lampPoleDTO);
+        return toolUtils.response(InterfaceResultEnum.OPERATION_SUCCESS,version);
+    }
 }

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

@@ -0,0 +1,101 @@
+package com.welampiot.controller;
+
+import com.welampiot.common.BaseResult;
+import com.welampiot.common.InterfaceResultEnum;
+import com.welampiot.service.LampService;
+import com.welampiot.utils.ToolUtils;
+import com.welampiot.vo.LampInfoDataVO;
+import com.welampiot.vo.LampInfoVO;
+import org.jetbrains.annotations.NotNull;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.CrossOrigin;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.text.ParseException;
+
+/**
+ * ClassName: ReportController
+ * Package: com.welampiot.controller
+ * Description:
+ *
+ * @Author: zhj_Start
+ * @Create: 2023/8/23 - 18:28
+ * @Version: v1.0
+ */
+@RestController
+@CrossOrigin
+@RequestMapping("/report")
+public class ReportController {
+    @Autowired
+    private ToolUtils toolUtils;
+    @Autowired
+    private LampService lampService;
+
+    /**
+     * 耗电报表
+     * @param vo 时间类型、统计类型
+     * @return 灯控用电量统计数据
+     */
+    @RequestMapping(value = "/consumptionData", method = RequestMethod.POST)
+    public BaseResult<?> consumptionData(@NotNull LampInfoDataVO vo) throws ParseException {
+        LampInfoDataVO lampInfoDataVO = vo.getLampInfoDataVO(vo);
+        Integer version = lampInfoDataVO.getVersion();
+        if (lampInfoDataVO.getDate().isEmpty() && lampInfoDataVO.getDateType().isEmpty())
+            return toolUtils.response(InterfaceResultEnum.LACK_PARAM_ERROR,version);
+        LampInfoVO lampInfoVO = lampService.getLampConsumptionData(lampInfoDataVO);
+        if (lampInfoVO.getName() != null && lampInfoVO.getName().equals("错误1"))
+            return toolUtils.response(InterfaceResultEnum.LACK_DATE_FORMAT_ERROR,version);
+        if (lampInfoVO.getName() != null && lampInfoVO.getName().equals("错误2"))
+            return toolUtils.response(InterfaceResultEnum.LACK_DATE_RANGE_ERROR,version);
+        LampInfoVO lampInfoVO1 = new LampInfoVO();
+        lampInfoVO1.setDate(lampInfoVO.getDate());
+        lampInfoVO1.setConsumption(lampInfoVO.getConsumption());
+        return toolUtils.response(InterfaceResultEnum.OPERATION_SUCCESS,version,lampInfoVO1);
+    }
+
+    /**
+     * 耗电报表
+     * @param vo 时间类型、统计类型
+     * @return 灯控省电量统计数据
+     */
+    @RequestMapping(value = "/savePower", method = RequestMethod.POST)
+    public BaseResult<?> savePower(@NotNull LampInfoDataVO vo) throws ParseException {
+        LampInfoDataVO lampInfoDataVO = vo.getLampInfoDataVO(vo);
+        Integer version = lampInfoDataVO.getVersion();
+        if (lampInfoDataVO.getDate().isEmpty() && lampInfoDataVO.getDateType().isEmpty())
+            return toolUtils.response(InterfaceResultEnum.LACK_PARAM_ERROR,version);
+        LampInfoVO lampInfoVO = lampService.getLampConsumptionData(lampInfoDataVO);
+        if (lampInfoVO.getName() != null && lampInfoVO.getName().equals("错误1"))
+            return toolUtils.response(InterfaceResultEnum.LACK_DATE_FORMAT_ERROR,version);
+        if (lampInfoVO.getName() != null && lampInfoVO.getName().equals("错误2"))
+            return toolUtils.response(InterfaceResultEnum.LACK_DATE_RANGE_ERROR,version);
+        LampInfoVO lampInfoVO1 = new LampInfoVO();
+        lampInfoVO1.setDate(lampInfoVO.getDate());
+        lampInfoVO1.setLightTime(lampInfoVO.getLightTime());
+        return toolUtils.response(InterfaceResultEnum.OPERATION_SUCCESS,version,lampInfoVO1);
+    }
+
+    /**
+     * 亮灯时间报表
+     * @param vo 时间类型、统计类型
+     * @return 灯控累计亮灯时间统计数据
+     */
+    @RequestMapping(value = "/lightTimeData", method = RequestMethod.POST)
+    public BaseResult<?> lightTimeData(@NotNull LampInfoDataVO vo) throws ParseException {
+        LampInfoDataVO lampInfoDataVO = vo.getLampInfoDataVO(vo);
+        Integer version = lampInfoDataVO.getVersion();
+        if (lampInfoDataVO.getDate().isEmpty() && lampInfoDataVO.getDateType().isEmpty())
+            return toolUtils.response(InterfaceResultEnum.LACK_PARAM_ERROR,version);
+        LampInfoVO lampInfoVO = lampService.getLampConsumptionData(lampInfoDataVO);
+        if (lampInfoVO.getName() != null && lampInfoVO.getName().equals("错误1"))
+            return toolUtils.response(InterfaceResultEnum.LACK_DATE_FORMAT_ERROR,version);
+        if (lampInfoVO.getName() != null && lampInfoVO.getName().equals("错误2"))
+            return toolUtils.response(InterfaceResultEnum.LACK_DATE_RANGE_ERROR,version);
+        LampInfoVO lampInfoVO1 = new LampInfoVO();
+        lampInfoVO1.setDate(lampInfoVO.getDate());
+        lampInfoVO1.setSavePower(lampInfoVO.getSavePower());
+        return toolUtils.response(InterfaceResultEnum.OPERATION_SUCCESS,version,lampInfoVO1);
+    }
+}

+ 21 - 0
src/main/java/com/welampiot/dao/AirSwitchLampDao.java

@@ -0,0 +1,21 @@
+package com.welampiot.dao;
+
+import com.welampiot.dto.LampInfoDTO;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+
+/**
+ * ClassName: AirSwitchLampDao
+ * Package: com.welampiot.dao
+ * Description:
+ *
+ * @Author: zhj_Start
+ * @Create: 2023/8/23 - 15:19
+ * @Version: v1.0
+ */
+public interface AirSwitchLampDao {
+    List<LampInfoDTO> getAirSwitchLampListBySectionId(@Param("sectionId") Integer sectionId, @Param("version") Integer version);
+
+    List<LampInfoDTO> getAirSwitchLampListByAirSwitchId(@Param("airSwitchId") Integer airSwitchId, @Param("version") Integer version);
+}

+ 1 - 0
src/main/java/com/welampiot/dao/LampPoleDao.java

@@ -38,4 +38,5 @@ public interface LampPoleDao {
     void updateLampPoleDevType(LampPoleDTO dto);
     List<LampPoleDTO> getSectionLampPoleList(LampPoleVO vo);
     List<LampPoleDTO> getLampPoleByLampIds(@Param("lampIds") List<String> lampIds);
+    void updateLampPoleIcon(LampPoleDTO dto);
 }

+ 23 - 0
src/main/java/com/welampiot/dto/AirSwitchLampDTO.java

@@ -0,0 +1,23 @@
+package com.welampiot.dto;
+
+import lombok.Data;
+
+import java.io.Serializable;
+
+/**
+ * ClassName: AirSwitchLampDTO
+ * Package: com.welampiot.dto
+ * Description:
+ *
+ * @Author: zhj_Start
+ * @Create: 2023/8/23 - 14:58
+ * @Version: v1.0
+ */
+@Data
+public class AirSwitchLampDTO implements Serializable {
+    private Integer id;
+
+    private Integer airSwitchId;
+
+    private Integer lampId;
+}

+ 4 - 0
src/main/java/com/welampiot/dto/LampInfoLogDTO.java

@@ -11,4 +11,8 @@ public class LampInfoLogDTO {
     private String updateTime;
     private String sumMinEle;
     private String sumMaxEle;
+    private String sumMinSave;
+    private String sumMaxSave;
+    private String sumMinLightTime;
+    private String sumMaxLightTime;
 }

+ 2 - 0
src/main/java/com/welampiot/dto/LampPoleDTO.java

@@ -62,4 +62,6 @@ public class LampPoleDTO {
     private List<Map> broadcastList;
     private WifiDTO cloudDev; // 云盒
     private Integer select;
+    private Integer dir;
+    private String iconInfo;
 }

+ 20 - 0
src/main/java/com/welampiot/service/AirSwitchLampService.java

@@ -0,0 +1,20 @@
+package com.welampiot.service;
+
+import com.welampiot.dto.LampInfoDTO;
+
+import java.util.List;
+
+/**
+ * ClassName: AirSwitchLampService
+ * Package: com.welampiot.service
+ * Description:
+ *
+ * @Author: zhj_Start
+ * @Create: 2023/8/23 - 15:20
+ * @Version: v1.0
+ */
+public interface AirSwitchLampService {
+    List<LampInfoDTO> getAirSwitchLampListBySectionId(Integer sectionId,Integer version);
+
+    List<LampInfoDTO> getAirSwitchLampListByAirSwitchId(Integer airSwitchId, Integer version);
+}

+ 1 - 0
src/main/java/com/welampiot/service/LampPoleService.java

@@ -32,4 +32,5 @@ public interface LampPoleService {
     void updateLampPoleDevType(LampPoleDTO dto);
     List<LampPoleDTO> getSectionLampPoleList(LampPoleVO vo);
     List<LampPoleDTO> getLampPoleByLampIds(List<String> lampIds);
+    void updateLampPoleIcon(LampPoleDTO dto);
 }

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

@@ -2,12 +2,10 @@ package com.welampiot.service;
 
 import com.welampiot.common.BaseResult;
 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 com.welampiot.vo.*;
 import org.apache.ibatis.annotations.Param;
 
+import java.text.ParseException;
 import java.util.List;
 
 public interface LampService {
@@ -49,4 +47,5 @@ public interface LampService {
     Integer getLampCountByLampPoleId(Integer lampPoleId);
     void updateLampInfoForLoopId(LampInfoDTO dto);
     List<LampInfoDTO> getLampInfoListForGroup(LampVO vo);
+    LampInfoVO getLampConsumptionData(LampInfoDataVO vo) throws ParseException;
 }

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

@@ -0,0 +1,34 @@
+package com.welampiot.service.impl;
+
+import com.welampiot.dao.AirSwitchLampDao;
+import com.welampiot.dto.LampInfoDTO;
+import com.welampiot.service.AirSwitchLampService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+/**
+ * ClassName: AirSwitchLampServiceImpl
+ * Package: com.welampiot.service.impl
+ * Description:
+ *
+ * @Author: zhj_Start
+ * @Create: 2023/8/23 - 15:21
+ * @Version: v1.0
+ */
+@Service
+public class AirSwitchLampServiceImpl implements AirSwitchLampService {
+    @Autowired
+    private AirSwitchLampDao airSwitchLampDao;
+
+    @Override
+    public List<LampInfoDTO> getAirSwitchLampListBySectionId(Integer sectionId, Integer version) {
+        return airSwitchLampDao.getAirSwitchLampListBySectionId(sectionId, version);
+    }
+
+    @Override
+    public List<LampInfoDTO> getAirSwitchLampListByAirSwitchId(Integer airSwitchId, Integer version) {
+        return airSwitchLampDao.getAirSwitchLampListByAirSwitchId(airSwitchId, version);
+    }
+}

+ 5 - 0
src/main/java/com/welampiot/service/impl/LampPoleServiceImpl.java

@@ -439,6 +439,11 @@ public class LampPoleServiceImpl implements LampPoleService {
         return lampPoleDao.getLampPoleByLampIds(lampIds);
     }
 
+    @Override
+    public void updateLampPoleIcon(LampPoleDTO dto) {
+        lampPoleDao.updateLampPoleIcon(dto);
+    }
+
     @Override
     public Integer getAlarmCountByVO(LampPoleCountVO lampPoleCountVO) {
         return lampPoleDao.getAlarmCountByVO(lampPoleCountVO);

+ 269 - 7
src/main/java/com/welampiot/service/impl/LampServiceImpl.java

@@ -3,23 +3,23 @@ package com.welampiot.service.impl;
 import com.welampiot.common.BaseResult;
 import com.welampiot.common.InterfaceResultEnum;
 import com.welampiot.dao.LampDao;
+import com.welampiot.dto.LampInfoCacheByDayDTO;
 import com.welampiot.dto.LampInfoDTO;
+import com.welampiot.dto.LampInfoLogDTO;
 import com.welampiot.dto.NetworkDTO;
+import com.welampiot.service.LampInfoCacheByDayService;
 import com.welampiot.service.LampInfoLogService;
 import com.welampiot.service.LampService;
 import com.welampiot.service.NetworkService;
 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 com.welampiot.vo.*;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import java.text.DecimalFormat;
+import java.text.ParseException;
 import java.text.SimpleDateFormat;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
+import java.util.*;
 
 @Service
 public class LampServiceImpl implements LampService {
@@ -31,6 +31,8 @@ public class LampServiceImpl implements LampService {
     private LampInfoLogService lampInfoLogService;
     @Autowired
     private NetworkService networkService;
+    @Autowired
+    private LampInfoCacheByDayService lampInfoCacheByDayService;
     @Override
     public Integer getCountByVO(LampCountVO lampCountVO) {return lampDao.getCountByVO(lampCountVO);}
 
@@ -392,6 +394,266 @@ public class LampServiceImpl implements LampService {
         return lampDao.getLampInfoListForGroup(vo);
     }
 
+    @Override
+    public LampInfoVO getLampConsumptionData(LampInfoDataVO vo) throws ParseException {
+        String dateType = vo.getDateType();
+        Integer type = vo.getType();
+        Integer value = vo.getValue();
+        String date = vo.getDate();
+        long l = System.currentTimeMillis();
+        Date date1 = new Date(l);
+        Calendar calendar = Calendar.getInstance();
+        calendar.setTime(date1);
+        int year = calendar.get(Calendar.YEAR); // 获取年份
+        int month = calendar.get(Calendar.MONTH) + 1; // 获取月份
+
+        long startTime = 0L;
+        long endTime = 0L;
+        String startDate = "";
+        DecimalFormat decimalFormat = new DecimalFormat("0.00");
+        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
+        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM");
+        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd 00:00:00");
+        SimpleDateFormat format1 = new SimpleDateFormat("yyyy-MM-dd 23:59:59");
+        SimpleDateFormat format2 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+        String endDate = simpleDateFormat.format(l);
+        if (dateType != null && !dateType.isEmpty()) {
+            switch (dateType) {
+                case "day":
+                    startDate = format.format(l);
+                    endDate = format1.format(l);
+                    startTime = format2.parse(startDate).getTime();
+                    endTime = format2.parse(endDate).getTime();
+                    break;
+                case "month":
+                    if (month < 10) {
+                        startDate = year + "-0" + month + "-01";
+                    } else {
+                        startDate = year + "-" + month + "-01";
+                    }
+                    startTime = simpleDateFormat.parse(startDate).getTime();
+                    endTime = simpleDateFormat.parse(endDate).getTime();
+                    break;
+                case "year":
+                    month = 1;
+                    startDate = year + "-0" + month + "-01";
+                    endDate = simpleDateFormat.format(l);
+                    startTime = simpleDateFormat.parse(startDate).getTime();
+                    endTime = simpleDateFormat.parse(endDate).getTime();
+                    break;
+            }
+        } else if (date != null && !date.isEmpty()) {
+            List<String> split = Arrays.asList(date.split("/"));
+            startDate = split.get(0);
+            endDate = split.get(1);
+            startTime = simpleDateFormat.parse(startDate + " 00:00:00").getTime();
+            endTime = simpleDateFormat.parse(endDate + " 23:59:59").getTime();
+            if (endTime < startTime) {
+                LampInfoVO lampInfoVO = new LampInfoVO();
+                lampInfoVO.setName("错误1");
+                return lampInfoVO;
+            }
+            if (endTime - startTime > 29L * 24 * 3600 * 1000) {
+                LampInfoVO lampInfoVO = new LampInfoVO();
+                lampInfoVO.setName("错误2");
+                return lampInfoVO;
+            }
+        }
+
+        HashMap<String, Integer> objectObjectHashMap = new HashMap<>();
+        long timeT = startTime;
+        int i = 0;
+        List<Object> dateList = new ArrayList<>();
+        List<Object> valueList1 = new ArrayList<>();
+        List<Object> valueList2 = new ArrayList<>();
+        List<Object> valueList3 = new ArrayList<>();
+        List<LampInfoCacheByDayDTO> conSumList = new ArrayList<>();
+        List<LampInfoLogDTO> dayEleList = new ArrayList<>();
+        LampInfoCacheByDayDTO dayDTO = new LampInfoCacheByDayDTO();
+        dayDTO.setType(type);
+        dayDTO.setValue(value);
+        dayDTO.setStartDate(startDate);
+        dayDTO.setEndDate(endDate);
+
+        if (dateType != null && !dateType.isEmpty()) {
+            switch (dateType) {
+                case "day":  // 当天
+                    dayEleList = lampInfoLogService.getDayEleUsedList(type, value);
+                    break;
+                case "month": // 当月
+                    conSumList = lampInfoCacheByDayService.getMonthConSum(dayDTO);
+                    break;
+                case "year":
+                    conSumList = lampInfoCacheByDayService.getYearConSum(dayDTO);
+                    break;
+            }
+
+            if (dateType.equals("month")) { // 当月
+                while (timeT <= endTime) {
+                    objectObjectHashMap.put(simpleDateFormat.format(new Date(timeT)),i);
+                    dateList.add(simpleDateFormat.format(new Date(timeT)));
+                    valueList1.add(0);
+                    valueList2.add(0);
+                    valueList3.add(0);
+                    timeT += 3600 * 1000 * 24;
+                    i ++;
+                }
+
+                for (LampInfoCacheByDayDTO dto : conSumList) {
+                    Date date2 = new Date(simpleDateFormat.parse(dto.getUpdateTime()).getTime());
+                    String s = simpleDateFormat.format(date2);
+                    Integer integer = null;
+                    if (objectObjectHashMap.containsKey(s)) {
+                        integer = objectObjectHashMap.get(s);
+                    }
+                    // 当月累计用电量
+                    if (dto.getConSum() != null && !dto.getConSum().equals("0") && integer != null) {
+                        String formatConSum = decimalFormat.format(dto.getConSum());
+                        valueList1.set(integer, Float.parseFloat(formatConSum));
+                    }
+                    // 当月累计亮灯时间
+                    if (dto.getLightTime() != null && dto.getLightTime() != 0 && integer != null) {
+                        valueList2.set(integer,dto.getLightTime());
+                    }
+                    // 当月累计省电量
+                    if (dto.getPowerSave() != null && !dto.getPowerSave().equals("0") && integer != null) {
+                        String formatSave = decimalFormat.format(dto.getPowerSave());
+                        valueList3.set(integer,Float.parseFloat(formatSave));
+                    }
+                }
+            } else if (dateType.equals("day")) { // 当天
+                format = new SimpleDateFormat("yyyy-MM-dd HH:00:00");
+                while (timeT < endTime) {
+                    objectObjectHashMap.put(format.format(new Date(timeT)),i);
+                    dateList.add(format.format(new Date(timeT)));
+                    valueList1.add(0);
+                    valueList2.add(0);
+                    valueList3.add(0);
+                    timeT += 3600 * 1000;
+                    i ++;
+                }
+
+                for (LampInfoLogDTO dto : dayEleList) {
+                    Date date2 = new Date(format.parse(dto.getUpdateTime()).getTime());
+                    String s = format.format(date2);
+                    Integer integer = null;
+                    if (objectObjectHashMap.containsKey(s)) {
+                        integer = objectObjectHashMap.get(s);
+                    }
+
+                    // 当天累计用电量
+                    if (dto.getSumMinEle() != null && !dto.getSumMinEle().equals("0") && integer != null &&
+                            dto.getSumMaxEle() != null && !dto.getSumMaxEle().equals("0")) {
+                        Float sumEle = Float.parseFloat(dto.getSumMaxEle()) - Float.parseFloat(dto.getSumMinEle());
+                        String formatEle = decimalFormat.format(sumEle);
+                        valueList1.set(integer, Float.parseFloat(formatEle));
+                    }
+                    // 当天累计亮灯时间
+                    if (dto.getSumMinLightTime() != null && !dto.getSumMinLightTime().equals("0") && integer != null &&
+                            dto.getSumMaxLightTime() != null && !dto.getSumMaxLightTime().equals("0")) {
+                        Float sumTime = Float.parseFloat(dto.getSumMaxLightTime()) - Float.parseFloat(dto.getSumMinLightTime());
+                        String formatTime = decimalFormat.format(sumTime);
+                        valueList1.set(integer, Float.parseFloat(formatTime));
+                    }
+                    // 当天累计省电量
+                    if (dto.getSumMinSave() != null && !dto.getSumMinSave().equals("0") && integer != null &&
+                            dto.getSumMaxSave() != null && !dto.getSumMaxSave().equals("0")) {
+                        Float sumSave = Float.parseFloat(dto.getSumMaxSave()) - Float.parseFloat(dto.getSumMinSave());
+                        String formatSave = decimalFormat.format(sumSave);
+                        valueList1.set(integer, Float.parseFloat(formatSave));
+                    }
+                }
+            } else { // 当年
+                String dateStr;
+                while (timeT <= endTime) {
+                    objectObjectHashMap.put(dateFormat.format(new Date(timeT)),i);
+                    dateList.add(dateFormat.format(new Date(timeT)));
+                    valueList1.add(0);
+                    valueList2.add(0);
+                    valueList3.add(0);
+                    month ++;
+                    if (month == 13) {
+                        month = 1;
+                        year ++;
+                    }
+                    if (month < 10) {
+                        dateStr = year + "-0" + month;
+                    } else {
+                        dateStr = year + "-" + month;
+                    }
+                    timeT = dateFormat.parse(dateStr).getTime();
+                    i ++;
+                }
+
+                for (LampInfoCacheByDayDTO dto : conSumList) {
+                    Date date2 = new Date(dateFormat.parse(dto.getUpdateTime()).getTime());
+                    String s = dateFormat.format(date2);
+                    Integer integer = null;
+                    if (objectObjectHashMap.containsKey(s)) {
+                        integer = objectObjectHashMap.get(s);
+                    }
+
+                    // 当年累计用电量
+                    if (dto.getConSum() != null && !dto.getConSum().equals("0") && integer != null) {
+                        String formatConSum = decimalFormat.format(dto.getConSum());
+                        valueList1.set(integer, Float.parseFloat(formatConSum));
+                    }
+                    // 当年累计亮灯时间
+                    if (dto.getLightTime() != null && dto.getLightTime() != 0 && integer != null) {
+                        valueList2.set(integer,dto.getLightTime());
+                    }
+                    // 当年累计省电量
+                    if (dto.getPowerSave() != null && !dto.getPowerSave().equals("0") && integer != null) {
+                        String formatSave = decimalFormat.format(dto.getPowerSave());
+                        valueList3.set(integer,Float.parseFloat(formatSave));
+                    }
+                }
+            }
+        } else if (date != null && !date.isEmpty()) {
+            while (timeT <= endTime) {
+                objectObjectHashMap.put(simpleDateFormat.format(new Date(timeT)),i);
+                dateList.add(simpleDateFormat.format(new Date(timeT)));
+                valueList1.add(0);
+                valueList2.add(0);
+                valueList3.add(0);
+                timeT += 3600 * 1000 * 24;
+                i ++;
+            }
+
+            conSumList = lampInfoCacheByDayService.getMonthConSum(dayDTO);
+            for (LampInfoCacheByDayDTO dto : conSumList) {
+                Date date2 = new Date(simpleDateFormat.parse(dto.getUpdateTime()).getTime());
+                String s = simpleDateFormat.format(date2);
+                Integer integer = null;
+                if (objectObjectHashMap.containsKey(s)) {
+                    integer = objectObjectHashMap.get(s);
+                }
+
+                // 具体日期累计用电量
+                if (dto.getConSum() != null && !dto.getConSum().equals("0") && integer != null) {
+                    String formatConSum = decimalFormat.format(dto.getConSum());
+                    valueList1.set(integer, Float.parseFloat(formatConSum));
+                }
+                // 具体日期累计亮灯时间
+                if (dto.getLightTime() != null && dto.getLightTime() != 0 && integer != null) {
+                    valueList2.set(integer,dto.getLightTime());
+                }
+                // 具体日期累计省电量
+                if (dto.getPowerSave() != null && !dto.getPowerSave().equals("0") && integer != null) {
+                    String formatSave = decimalFormat.format(dto.getPowerSave());
+                    valueList3.set(integer,Float.parseFloat(formatSave));
+                }
+            }
+        }
+
+        LampInfoVO lampInfoVO = new LampInfoVO();
+        lampInfoVO.setDate(dateList);
+        lampInfoVO.setConsumption(valueList1);
+        lampInfoVO.setLightTime(valueList2);
+        lampInfoVO.setSavePower(valueList3);
+        return lampInfoVO;
+    }
+
     @Override
     public Integer updateLight(LampInfoDTO lampInfoDTO) {
         return lampDao.updateLight(lampInfoDTO);

+ 41 - 0
src/main/java/com/welampiot/vo/LampInfoDataVO.java

@@ -0,0 +1,41 @@
+package com.welampiot.vo;
+
+import lombok.Data;
+import org.jetbrains.annotations.NotNull;
+
+import java.io.Serializable;
+
+/**
+ * ClassName: LampInfoDataVO
+ * Package: com.welampiot.vo
+ * Description:
+ *
+ * @Author: zhj_Start
+ * @Create: 2023/8/24 - 9:59
+ * @Version: v1.0
+ */
+@Data
+public class LampInfoDataVO implements Serializable {
+    private Integer type;
+
+    private Integer value;
+
+    private String date;
+
+    private String dateType;
+
+    private Integer version;
+
+    public LampInfoDataVO getLampInfoDataVO(@NotNull LampInfoDataVO vo) {
+        if (vo.getVersion() == null) {
+            vo.setVersion(0);
+        }
+        if (vo.getDate() == null) {
+            vo.setDate("");
+        }
+        if (vo.getDateType() == null) {
+            vo.setDateType("");
+        }
+        return vo;
+    }
+}

+ 3 - 0
src/main/java/com/welampiot/vo/LampInfoVO.java

@@ -30,6 +30,9 @@ public class LampInfoVO {
     private List<Object> date;
 
     private List<Object> value;
+    private List<Object> consumption;
+    private List<Object> lightTime;
+    private List<Object> savePower;
 
     private List<LampInfoDTO> list;
 }

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

@@ -39,5 +39,7 @@ public class LampPoleVO implements Serializable {
     private Integer faultCount; // 故障数
     private Integer newCount; // 近期创建数
     private Integer disableCount; // 禁用数
+    private Integer dir;
+    private String iconInfo;
     private List<LampPoleDTO> list;
 }

+ 83 - 0
src/main/resources/mapper/AirSwitchLampMapper.xml

@@ -0,0 +1,83 @@
+<?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.AirSwitchLampDao">
+
+    <select id="getAirSwitchLampListBySectionId" resultType="LampInfoDTO">
+        select
+            l.id,
+            l.number,
+            n.status as networkStatus,
+            l.status as lampStatus,
+            l.lighteness,
+            l1.gridcurr as `current`,
+            l1.gridvolt as voltage,
+            l1.grid_active_power as power,
+            n.rssi,
+            n.snr,
+            n.protocoltype as protocolType,
+            l.updatetime as updateTime,
+            s.name as section,
+            l1.work_time_total as lightTime,
+            l.updatetime as updateTime,
+            p.name as policyName
+            <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 air_switch_lamp a
+        left join lampinfo l on l.id = a.lamp_id
+        left join network n on l.networkid = n.id
+        left join lamp_info_log_new l1 on l.id = l1.lampid
+        left join section s on s.id = l.sectionid
+        left join global_location gl on gl.id = s.pid
+        left join policy p on l.policyid = p.id
+        where l.sectionid = #{sectionId}
+    </select>
+
+    <select id="getAirSwitchLampListByAirSwitchId" resultType="LampInfoDTO">
+        select
+        l.id,
+        l.number,
+        n.status as networkStatus,
+        l.status as lampStatus,
+        l.lighteness,
+        l1.gridcurr as `current`,
+        l1.gridvolt as voltage,
+        l1.grid_active_power as power,
+        n.rssi,
+        n.snr,
+        n.protocoltype as protocolType,
+        l.updatetime as updateTime,
+        s.name as section,
+        l1.work_time_total as lightTime,
+        l.updatetime as updateTime,
+        p.name as policyName
+        <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 air_switch_lamp a
+        left join lampinfo l on l.id = a.lamp_id
+        left join network n on l.networkid = n.id
+        left join lamp_info_log_new l1 on l.id = l1.lampid
+        left join section s on s.id = l.sectionid
+        left join global_location gl on gl.id = s.pid
+        left join policy p on l.policyid = p.id
+        where a.air_switch_id = #{airSwitchId}
+    </select>
+
+</mapper>

+ 4 - 0
src/main/resources/mapper/LampInfoCacheByDayMapper.xml

@@ -34,6 +34,8 @@
     
     <select id="getMonthConSum" resultType="LampInfoCacheByDayDTO">
         SELECT SUM(l.consum) AS conSum,
+               SUM(l.powerSave) AS powerSave,
+               SUM(l.lightTime) AS lightTime,
                l.updatetime AS updateTime
         FROM lamp_info_cache_by_day l
         WHERE l.updatetime <![CDATA[ >= ]]> #{startDate}
@@ -55,6 +57,8 @@
 
     <select id="getYearConSum" resultType="LampInfoCacheByDayDTO">
         SELECT SUM(l.consum) AS conSum,
+               SUM(l.powerSave) AS powerSave,
+               SUM(l.lightTime) AS lightTime,
                l.updatetime AS updateTime
         FROM lamp_info_cache_by_day l
         WHERE l.updatetime <![CDATA[ >= ]]> #{startDate}

+ 8 - 0
src/main/resources/mapper/LampInfoLogMapper.xml

@@ -20,10 +20,18 @@
         SELECT
             SUM(A.minEle) AS sumMinEle,
             SUM(A.maxEle) AS sumMaxEle,
+            SUM(A.minSave) AS sumMinSave,
+            SUM(A.maxSave) AS sumMaxSave,
+            SUM(A.minLightTime) AS sumMinLightTime,
+            SUM(A.maxLightTime) AS sumMaxLightTime,
             DATE_FORMAT(A.minTime,'%Y-%m-%d %H:00:00') AS updateTime
         FROM
             (SELECT MIN(l.used_energy_total) AS minEle,
                     MAX(l.used_energy_total) AS maxEle,
+                    MIN(l.work_time_total) AS minLightTime,
+                    MAX(l.work_time_total) AS maxLightTime,
+                    MIN(l.total_ele_save) AS minSave,
+                    MAX(l.total_ele_save) AS maxSave,
                     l.updatetime AS minTime
             FROM lamp_info_log l
             LEFT JOIN lampinfo l1

+ 11 - 1
src/main/resources/mapper/LampPoleMapper.xml

@@ -470,7 +470,7 @@
     </update>
 
     <select id="getLampPoleDTOById" resultType="LampPoleDTO">
-        select l.id,l.number,l.devtype as devType
+        select l.id,l.number,l.devtype as devType,l.dir,l.icon_info as iconInfo
         from lamp_pole l
         where l.id = #{id}
     </select>
@@ -614,4 +614,14 @@
         </foreach>
     </select>
     
+    <update id="updateLampPoleIcon" parameterType="LampPoleDTO">
+        update
+            lamp_pole l
+        set
+            l.dir = #{dir},
+            l.icon_info = #{iconInfo}
+        where
+            l.id = #{id}
+    </update>
+    
 </mapper>