瀏覽代碼

灯带列表、灯带分组列表、用电量统计

zhj 2 年之前
父節點
當前提交
32fa810c21
共有 22 個文件被更改,包括 1526 次插入0 次删除
  1. 188 0
      src/main/java/com/welampiot/controller/LightStripController.java
  2. 74 0
      src/main/java/com/welampiot/controller/LightStripGroupController.java
  3. 24 0
      src/main/java/com/welampiot/dao/LightStripDevDao.java
  4. 20 0
      src/main/java/com/welampiot/dao/LightStripDevLogDao.java
  5. 26 0
      src/main/java/com/welampiot/dao/LightStripGroupDao.java
  6. 212 0
      src/main/java/com/welampiot/dto/LightStripDevDTO.java
  7. 49 0
      src/main/java/com/welampiot/dto/LightStripDevLogDTO.java
  8. 73 0
      src/main/java/com/welampiot/dto/LightStripGroupDTO.java
  9. 34 0
      src/main/java/com/welampiot/dto/LightStripPolicyDTO.java
  10. 20 0
      src/main/java/com/welampiot/service/LightStripDevLogService.java
  11. 19 0
      src/main/java/com/welampiot/service/LightStripDevService.java
  12. 20 0
      src/main/java/com/welampiot/service/LightStripGroupService.java
  13. 34 0
      src/main/java/com/welampiot/service/impl/LightStripDevLogServiceImpl.java
  14. 340 0
      src/main/java/com/welampiot/service/impl/LightStripDevServiceImpl.java
  15. 93 0
      src/main/java/com/welampiot/service/impl/LightStripGroupServiceImpl.java
  16. 29 0
      src/main/java/com/welampiot/vo/LightStripDevLogVO.java
  17. 29 0
      src/main/java/com/welampiot/vo/LightStripDevVO.java
  18. 33 0
      src/main/java/com/welampiot/vo/LightStripGroupDetailVO.java
  19. 23 0
      src/main/java/com/welampiot/vo/LightStripGroupVO.java
  20. 25 0
      src/main/resources/mapper/LightStripDevLogMapper.xml
  21. 90 0
      src/main/resources/mapper/LightStripDevMapper.xml
  22. 71 0
      src/main/resources/mapper/LightStripGroupMapper.xml

+ 188 - 0
src/main/java/com/welampiot/controller/LightStripController.java

@@ -0,0 +1,188 @@
+package com.welampiot.controller;
+
+import com.welampiot.common.BaseResult;
+import com.welampiot.common.InterfaceResultEnum;
+import com.welampiot.dto.LightStripDevDTO;
+import com.welampiot.dto.LightStripDevLogDTO;
+import com.welampiot.service.LightStripDevLogService;
+import com.welampiot.service.LightStripDevService;
+import com.welampiot.utils.ToolUtils;
+import com.welampiot.vo.LightStripDevLogVO;
+import com.welampiot.vo.LightStripDevVO;
+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 javax.servlet.http.HttpServletRequest;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.*;
+
+/**
+ * ClassName: LightStripController
+ * Package: com.welampiot.controller
+ * Description:
+ *
+ * @Author: zhj_Start
+ * @Create: 2023/5/4 - 16:06
+ * @Version: v1.0
+ */
+@RestController
+@CrossOrigin
+@RequestMapping("/lightStrip")
+public class LightStripController {
+    @Autowired
+    private LightStripDevService lightStripDevService;
+
+    @Autowired
+    private LightStripDevLogService lightStripDevLogService;
+
+    @Autowired
+    private ToolUtils toolUtils;
+
+    /**
+     * 获取灯带设备概述
+     * @param request
+     * @return
+     */
+    @RequestMapping(value = "/data", method = RequestMethod.POST)
+    public BaseResult data(HttpServletRequest request){
+        Integer version = (Integer)toolUtils.getRequestContent(request,"version",1);
+        LightStripDevDTO dto = new LightStripDevDTO();
+        dto.setSectionList(toolUtils.getSectionList(request));
+        LightStripDevVO lightStripData = lightStripDevService.getLightStripData(dto);
+        return toolUtils.response(InterfaceResultEnum.OPERATION_SUCCESS,version,lightStripData);
+    }
+
+    /**
+     * 获取灯带列表
+     * @param request
+     * @return
+     */
+    @RequestMapping(value = "/getList", method = RequestMethod.POST)
+    public BaseResult getList(HttpServletRequest request){
+        int version = (Integer) toolUtils.getRequestContent(request,"version",1);
+        int page = request.getParameter("page") == null ? 1 : Integer.parseInt(request.getParameter("page"));
+        int count = request.getParameter("count") == null ? 16 : Integer.parseInt(request.getParameter("count"));
+        int online = (Integer) toolUtils.getRequestContent(request,"online",1);
+        String keyword = (String) toolUtils.getRequestContent(request,"keyword",2);
+
+        LightStripDevDTO dto = new LightStripDevDTO();
+        dto.setPage(count * (page - 1));
+        dto.setCount(count);
+        dto.setVersion(version);
+        dto.setKeyword(keyword);
+        dto.setOnlineState(online);
+        dto.setSectionList(toolUtils.getSectionList(request));
+
+        LightStripDevVO vo = lightStripDevService.getLightStripListByDTO(dto);
+        return toolUtils.response(InterfaceResultEnum.OPERATION_SUCCESS,version,vo);
+    }
+
+    /**
+     * 灯带用电量统计
+     * @param request
+     * @return
+     */
+    @RequestMapping(value = "/statisticsInfo", method = RequestMethod.POST)
+    public BaseResult statisticsInfo(HttpServletRequest request) throws ParseException {
+        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);
+        Integer timezone = lightStripDevLogService.getTimezoneByLightStripDevId(id);
+        if (timezone == null) return toolUtils.response(InterfaceResultEnum.PARAM_FAIL,version);
+        Integer dateType = (Integer) toolUtils.getRequestContent(request,"dateType",1);
+        long l = System.currentTimeMillis() - timezone * 3600 * 1000;
+        long startTime = 0L;
+        long endTime = 0L;
+        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+        if (dateType == 0){  // 1 天
+            startTime = l - 24 * 3600 * 1000;
+            endTime = l;
+        }else if (dateType == 1){ // 3 天
+            startTime = l - 24 * 3600 * 1000 * 3;
+            endTime = l;
+        }else if (dateType == 2){ // 7 天
+            startTime = l - 24 * 3600 * 1000 * 7;
+            endTime = l;
+        }else if (dateType == 3){ // 14 天
+            startTime = l - 24 * 3600 * 1000 * 14;
+            endTime = l;
+        }else if (dateType == 4){ // 日期选择 最多30天
+            String date = (String) toolUtils.getRequestContent(request,"date",2);
+            if (date.length() == 0) return toolUtils.response(InterfaceResultEnum.LACK_DATE_ERROR,version);
+            List<String> split = Arrays.asList(date.split("/"));
+            startTime = simpleDateFormat.parse(split.get(0) + " 00:00:00").getTime();
+            endTime = simpleDateFormat.parse(split.get(1) + " 23:59:59").getTime();
+            if (endTime < startTime) toolUtils.response(InterfaceResultEnum.LACK_DATE_FORMAT_ERROR,version);
+            if (endTime - startTime > 29L * 24 * 3600 * 1000) toolUtils.response(InterfaceResultEnum.LACK_DATE_RANGE_ERROR,version);
+            startTime -= timezone * 3600 * 1000;
+            endTime -= timezone * 3600 * 1000;
+        }
+
+        HashMap<String, Integer> objectObjectHashMap = new HashMap<>();
+        long timeT = startTime;
+        int i = 0;
+
+        ArrayList<Object> dateList = new ArrayList<>();
+        ArrayList<Object> usedEnergyList1 = new ArrayList<>();
+        ArrayList<Object> usedEnergyList2 = new ArrayList<>();
+        ArrayList<LightStripDevLogDTO> list = new ArrayList<>();
+        simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:00:00");
+        while (timeT < endTime){
+            objectObjectHashMap.put(simpleDateFormat.format(new Date(timeT)),i);
+            dateList.add(simpleDateFormat.format(new Date(timeT + timezone * 3600 * 1000)));
+            usedEnergyList1.add(0);
+            usedEnergyList2.add(0);
+            list.add(null);
+            timeT += 3600 * 1000;
+            i ++;
+        }
+        SimpleDateFormat simpleDateFormat2 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+        String startDate = simpleDateFormat.format(new Date(startTime));
+        String endDate = simpleDateFormat.format(new Date(endTime));
+        LightStripDevLogDTO dto = new LightStripDevLogDTO();
+        dto.setDevId(id);
+        dto.setStartDate(startDate);
+        dto.setEndDate(endDate);
+        List<LightStripDevLogDTO> statisticsInfoDTO = lightStripDevLogService.getStatisticsInfoByDTO(dto);
+        for (LightStripDevLogDTO lightStripDevLogDTO : statisticsInfoDTO) {
+            Date date = new Date(simpleDateFormat2.parse(lightStripDevLogDTO.getUpdateTime()).getTime());
+            String s = simpleDateFormat.format(date);
+            if (objectObjectHashMap.containsKey(s)){
+                Integer integer = objectObjectHashMap.get(s);
+                list.set(integer,lightStripDevLogDTO);
+            }
+        }
+        ArrayList<LightStripDevLogDTO> logList = new ArrayList<>();
+        for (LightStripDevLogDTO lightStripDevLogDTO : list) {
+            if (lightStripDevLogDTO != null){
+                Date date = new Date(simpleDateFormat2.parse(lightStripDevLogDTO.getUpdateTime()).getTime());
+                String s = simpleDateFormat.format(date);
+                Integer integer = null;
+                if (objectObjectHashMap.containsKey(s)){
+                    integer = objectObjectHashMap.get(s);
+                    list.set(integer,lightStripDevLogDTO);
+                }
+
+                if (lightStripDevLogDTO.getUsedEnergyTotal() != null && !lightStripDevLogDTO.getUsedEnergyTotal().equals("0") && integer != null){
+                    usedEnergyList1.set(integer,Float.valueOf(lightStripDevLogDTO.getUsedEnergyTotal()));
+                }
+                if (lightStripDevLogDTO.getUsedEnergyTotal2() != null && !lightStripDevLogDTO.getUsedEnergyTotal2().equals("0") && integer != null){
+                    usedEnergyList2.set(integer,Float.valueOf(lightStripDevLogDTO.getUsedEnergyTotal2()));
+                }
+                date = new Date(simpleDateFormat2.parse(lightStripDevLogDTO.getUpdateTime()).getTime() + timezone * 3600 * 1000);
+                lightStripDevLogDTO.setUpdateTime(simpleDateFormat.format(date));
+                logList.add(lightStripDevLogDTO);
+            }
+        }
+        LightStripDevLogVO lightStripDevLogVO = new LightStripDevLogVO();
+        lightStripDevLogVO.setUsedEnergyList1(usedEnergyList1);
+        lightStripDevLogVO.setUsedEnergyList2(usedEnergyList2);
+        lightStripDevLogVO.setDateList(dateList);
+        lightStripDevLogVO.setList(logList);
+        return toolUtils.response(InterfaceResultEnum.OPERATION_SUCCESS,version,lightStripDevLogVO);
+    }
+}

+ 74 - 0
src/main/java/com/welampiot/controller/LightStripGroupController.java

@@ -0,0 +1,74 @@
+package com.welampiot.controller;
+
+import com.welampiot.common.BaseResult;
+import com.welampiot.common.InterfaceResultEnum;
+import com.welampiot.dto.LightStripGroupDTO;
+import com.welampiot.service.LightStripGroupService;
+import com.welampiot.utils.ToolUtils;
+import com.welampiot.vo.LightStripGroupDetailVO;
+import com.welampiot.vo.LightStripGroupVO;
+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 javax.servlet.http.HttpServletRequest;
+
+/**
+ * ClassName: LightStripGroupController
+ * Package: com.welampiot.controller
+ * Description:
+ *
+ * @Author: zhj_Start
+ * @Create: 2023/5/5 - 17:45
+ * @Version: v1.0
+ */
+@RestController
+@CrossOrigin
+@RequestMapping("/lightStripGroup")
+public class LightStripGroupController {
+    @Autowired
+    private LightStripGroupService lightStripGroupService;
+
+    @Autowired
+    private ToolUtils toolUtils;
+
+    /**
+     * 获取灯带分组列表
+     * @param request
+     * @return
+     */
+    @RequestMapping(value = "/getList", method = RequestMethod.POST)
+    public BaseResult getList(HttpServletRequest request){
+        int version = (Integer) toolUtils.getRequestContent(request,"version",1);
+        int page = request.getParameter("page") == null ? 1 : Integer.parseInt(request.getParameter("page"));
+        int count = request.getParameter("count") == null ? 16 : Integer.parseInt(request.getParameter("count"));
+        String keyword = (String) toolUtils.getRequestContent(request,"keyword",2);
+
+        LightStripGroupDTO dto = new LightStripGroupDTO();
+        dto.setPage(count * (page - 1));
+        dto.setCount(count);
+        dto.setVersion(version);
+        dto.setKeyword(keyword);
+        dto.setSectionList(toolUtils.getSectionList(request));
+
+        LightStripGroupVO vo = lightStripGroupService.getLightStripGroupByDTO(dto);
+        return toolUtils.response(InterfaceResultEnum.OPERATION_SUCCESS,version,vo);
+    }
+
+    /**
+     * 获取灯带分组列表详情
+     * @param request
+     * @return
+     */
+    @RequestMapping(value = "/details", method = RequestMethod.POST)
+    public BaseResult details(HttpServletRequest request){
+        int version = (Integer) toolUtils.getRequestContent(request,"version",1);
+        int id = (Integer) toolUtils.getRequestContent(request,"id",1);
+        if (id == 0) return toolUtils.response(InterfaceResultEnum.LACK_PARAM_ERROR,version);
+        LightStripGroupDetailVO lightStripGroupDetailsVO = lightStripGroupService.getLightStripGroupDetailsById(id, version);
+        if (lightStripGroupDetailsVO == null) return toolUtils.response(InterfaceResultEnum.PARAM_FAIL,version);
+        return toolUtils.response(InterfaceResultEnum.OPERATION_SUCCESS,version,lightStripGroupDetailsVO);
+    }
+}

+ 24 - 0
src/main/java/com/welampiot/dao/LightStripDevDao.java

@@ -0,0 +1,24 @@
+package com.welampiot.dao;
+
+import com.welampiot.dto.LightStripDevDTO;
+
+import java.util.List;
+
+/**
+ * ClassName: LightStripDevDao
+ * Package: com.welampiot.dao
+ * Description:
+ *
+ * @Author: zhj_Start
+ * @Create: 2023/5/4 - 15:41
+ * @Version: v1.0
+ */
+public interface LightStripDevDao {
+    Integer getLightStripTotalByDTO(LightStripDevDTO dto);
+
+    Integer getLightStripOnlineTotalByDTO(LightStripDevDTO dto);
+
+    Integer getLightStripOpenTotalByDTO(LightStripDevDTO dto);
+
+    List<LightStripDevDTO> getLightStripListByDTO(LightStripDevDTO dto);
+}

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

@@ -0,0 +1,20 @@
+package com.welampiot.dao;
+
+import com.welampiot.dto.LightStripDevLogDTO;
+
+import java.util.List;
+
+/**
+ * ClassName: LightStripDevLogDao
+ * Package: com.welampiot.dao
+ * Description:
+ *
+ * @Author: zhj_Start
+ * @Create: 2023/5/6 - 11:43
+ * @Version: v1.0
+ */
+public interface LightStripDevLogDao {
+    List<LightStripDevLogDTO> getStatisticsInfoByDTO(LightStripDevLogDTO dto);
+
+    Integer getTimezoneByLightStripDevId(Integer id);
+}

+ 26 - 0
src/main/java/com/welampiot/dao/LightStripGroupDao.java

@@ -0,0 +1,26 @@
+package com.welampiot.dao;
+
+import com.welampiot.dto.LightStripGroupDTO;
+import com.welampiot.dto.LightStripPolicyDTO;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+
+/**
+ * ClassName: LightStripGroupDao
+ * Package: com.welampiot.dao
+ * Description:
+ *
+ * @Author: zhj_Start
+ * @Create: 2023/5/5 - 15:29
+ * @Version: v1.0
+ */
+public interface LightStripGroupDao {
+    List<LightStripGroupDTO> getLightStripGroupByDTO(LightStripGroupDTO dto);
+
+    LightStripPolicyDTO getLightStripPolicyData(@Param("policyId") Integer policyId);
+
+    LightStripGroupDTO getLightStripGroupDetailsById(@Param("id") Integer id, @Param("version") Integer version);
+
+    String getLightStripPolicyName(@Param("policyId") Integer policyId);
+}

+ 212 - 0
src/main/java/com/welampiot/dto/LightStripDevDTO.java

@@ -0,0 +1,212 @@
+package com.welampiot.dto;
+
+import lombok.Data;
+
+import java.io.Serializable;
+import java.util.List;
+
+/**
+ * ClassName: LightStripDevDTO
+ * Package: com.welampiot.dto
+ * Description:
+ *
+ * @Author: zhj_Start
+ * @Create: 2023/5/4 - 13:58
+ * @Version: v1.0
+ */
+@Data
+public class LightStripDevDTO implements Serializable {
+    /** 主键 **/
+    private Integer id;
+
+    /** 灯杆id **/
+    private Integer lampPoleId;
+
+    /** 策略id **/
+    private Integer policyId;
+
+    /** 灯带分组id **/
+    private Integer groupId;
+
+    /** 区、县id **/
+    private Integer areaId;
+
+    /** 路段、街道id **/
+    private Integer sectionId;
+
+    /** 手动更改颜色的时间 **/
+    private String changeColorTypeTime;
+
+    /** 类型(0.常亮,1:呼吸,2:爆闪,3:关灯,4:闪烁) **/
+    private Integer type;
+
+    /** 模式对应的值(type为1时(1:红灯呼吸,2:绿灯呼吸,3:蓝灯呼吸,4:RGB 呼吸,5:黄灯呼吸,6:紫灯呼吸),
+     * type为2时(1.红灯爆闪,2:绿灯爆闪,3:蓝灯爆闪,4:任何色爆闪,5:7色爆闪,6:黄灯爆闪,7:紫灯爆闪),
+     * type为4时(1.红灯闪烁,2:绿灯闪烁,3:蓝灯闪烁,4:任何色闪烁,5:7色闪烁,6:黄灯闪烁,7:紫灯闪烁)
+     **/
+    private Integer mode;
+
+    /** 编号 **/
+    private String number;
+
+    /** 名称 **/
+    private String name;
+
+    /** 型号(0:WE-RGB-R10,1:WE-CON-RGB30) **/
+    private Integer model;
+
+    /** 地址 **/
+    private String address;
+
+    /** 厂家(0:云之声) **/
+    private Integer factory;
+
+    /** 在线状态(0:离线,1:在线) **/
+    private Integer online;
+
+    /** 开关状态(0:关,1:开) **/
+    private Integer status;
+
+    /** 色带颜色(默认值:FFFFFF) **/
+    private String color;
+
+    /** 串口(0 3号串口,1 2号串口,3 1号串口) **/
+    private Integer serialPort;
+
+    /** 创建时间 **/
+    private String createTime;
+
+    /** 更新时间 **/
+    private String updateTime;
+
+    /** 电压V **/
+    private String gridVolt;
+
+    /** 电流A **/
+    private String gridCurr;
+
+    /** 功率Wh **/
+    private String power;
+
+    /** 频率Hz **/
+    private String freq;
+
+    /** 用电量(kWh) **/
+    private String usedEnergyTotal;
+
+    /** 宫殿状态(0 市电,1 电池) **/
+    private Integer powerSwitch;
+
+    /** 电压V(电池负载) **/
+    private String gridVolt2;
+
+    /** 电流A(电池负载) **/
+    private String gridCurr2;
+
+    /** 功率Wh(电池负载) **/
+    private String power2;
+
+    /** 用电量(kWh)(电池) **/
+    private String usedEnergyTotal2;
+
+    /** 电压V(电池) **/
+    private String batVolt;
+
+    /** 电流A(电池) **/
+    private String batCurr;
+
+    /** 功率Wh (电池) **/
+    private String batPower;
+
+    /** 电压(太阳能板) **/
+    private String solarVolt;
+
+    /** 电池(太阳能板) **/
+    private String solarCurr;
+
+    /** 功率Wh(太阳能板) **/
+    private String solarPower;
+
+    /** 电池充电状态(0 没有充电,1 启动充电模式,2 mppt充电模式,3 均衡充电模式,4 提升充电模式,5 浮充充电模式,6 限流(超功率))**/
+    private Integer chargeType;
+
+    /** 市电切换电压(1-255V) **/
+    private Integer switchVol;
+
+    /** 太阳能电池切换电压(1-255V) **/
+    private String solarSwitchVol;
+
+    /** 注册巡检颜色 **/
+    private Integer patrolCmd;
+
+    /** 市电在线状态(0:离线,1:在线) **/
+    private Integer online2;
+
+    /** 电池在线状态(0:离线,1:在线) **/
+    private Integer online3;
+
+    /** 网络通讯方式(0:RS485,1:4G) **/
+    private Integer netType;
+
+    /** IMEI号码 **/
+    private String imei;
+
+    /** 4g协议巡检时间 **/
+    private String patrol;
+
+    /** 4g模块版本 **/
+    private String softVersion;
+
+    /** 4g模块硬件版本 **/
+    private String hardVersion;
+
+    /** 安装时间 **/
+    private String installDate;
+
+    /** 过期时间 **/
+    private String expirationDate;
+
+    private String lampPoleName;
+
+    private Integer cloudBoxModel;
+
+    private String policyName;
+
+    private String modeStr;
+
+    private String section;
+
+    private String area;
+
+    private Integer timezone;
+
+    private Integer mpptDevId;
+
+    private String mpptDevAddress;
+
+    private Integer mpptDevType;
+
+    private Integer mpptDevSerialPort;
+
+    private String mpptDevNumber;
+
+    private String mpptDevName;
+
+    private String voltage;
+
+    private String solarVoltage;
+
+    private String keyword;
+
+    private Integer onlineState;
+
+    private Integer page;
+
+    private Integer count;
+
+    private Integer version;
+
+    private List<Integer> sectionList;
+
+    private static final long serialVersionUID = 1L;
+}

+ 49 - 0
src/main/java/com/welampiot/dto/LightStripDevLogDTO.java

@@ -0,0 +1,49 @@
+package com.welampiot.dto;
+
+import lombok.Data;
+
+import java.io.Serializable;
+
+/**
+ * ClassName: LightStripDevLogDTO
+ * Package: com.welampiot.dto
+ * Description:
+ *
+ * @Author: zhj_Start
+ * @Create: 2023/5/5 - 15:20
+ * @Version: v1.0
+ */
+@Data
+public class LightStripDevLogDTO implements Serializable {
+    /** 主键 **/
+    private Integer id;
+
+    /** 设备id **/
+    private Integer devId;
+
+    /** 电压V **/
+    private String gridVolt;
+
+    /** 电流A **/
+    private String gridCurr;
+
+    /** 功率Wh **/
+    private String power;
+
+    /** 频率Hz **/
+    private String freq;
+
+    /** 市电用电量(kWh) **/
+    private String usedEnergyTotal;
+
+    /** 电池用电量 **/
+    private String usedEnergyTotal2;
+
+    private String updateTime;
+
+    private String startDate;
+
+    private String endDate;
+
+    private static final long serialVersionUID = 1L;
+}

+ 73 - 0
src/main/java/com/welampiot/dto/LightStripGroupDTO.java

@@ -0,0 +1,73 @@
+package com.welampiot.dto;
+
+import lombok.Data;
+
+import java.io.Serializable;
+import java.util.List;
+
+/**
+ * ClassName: LightStripGroupDTO
+ * Package: com.welampiot.dto
+ * Description:
+ *
+ * @Author: zhj_Start
+ * @Create: 2023/5/5 - 15:20
+ * @Version: v1.0
+ */
+@Data
+public class LightStripGroupDTO implements Serializable {
+    /** 主键 **/
+    private Integer id;
+
+    /** 分组编号 **/
+    private Integer number;
+
+    /** 分组号 **/
+    private String name;
+
+    /** 路段id **/
+    private Integer sectionId;
+
+    /** 区id **/
+    private Integer areaId;
+
+    /** 分组类型(1:策略) **/
+    private Integer type;
+
+    /** 不同类型对应不同的值 **/
+    private Integer value;
+
+    /** 设备id(多个灯带用逗号分隔) **/
+    private String lightStripIds;
+
+    /** 设备数 **/
+    private Integer lightCount;
+
+    /** 创建时间 **/
+    private String createTime;
+
+    /** 更新时间 **/
+    private String updateTime;
+
+    private Integer page;
+
+    private Integer count;
+
+    private String keyword;
+
+    private Integer version;
+
+    private List<Integer> sectionList;
+
+    private String policyName;
+
+    private String area;
+
+    private String section;
+
+    private Integer policyId;
+
+    private LightStripPolicyDTO policyData;
+
+    private static final long serialVersionUID = 1L;
+}

+ 34 - 0
src/main/java/com/welampiot/dto/LightStripPolicyDTO.java

@@ -0,0 +1,34 @@
+package com.welampiot.dto;
+
+import lombok.Data;
+
+import java.io.Serializable;
+
+/**
+ * ClassName: LightStripPolicyDTO
+ * Package: com.welampiot.dto
+ * Description:
+ *
+ * @Author: zhj_Start
+ * @Create: 2023/5/5 - 15:20
+ * @Version: v1.0
+ */
+@Data
+public class LightStripPolicyDTO implements Serializable {
+    /** 主键 **/
+    private Integer id;
+
+    /** 策略名称 **/
+    private String name;
+
+    /** 用户id **/
+    private Integer userId;
+
+    /** 类型(0:日期,1:星期) **/
+    private Integer type;
+
+    /** 创建时间 **/
+    private String createTime;
+
+    private static final long serialVersionUID = 1L;
+}

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

@@ -0,0 +1,20 @@
+package com.welampiot.service;
+
+import com.welampiot.dto.LightStripDevLogDTO;
+
+import java.util.List;
+
+/**
+ * ClassName: LightStripDevLogService
+ * Package: com.welampiot.service
+ * Description:
+ *
+ * @Author: zhj_Start
+ * @Create: 2023/5/6 - 14:07
+ * @Version: v1.0
+ */
+public interface LightStripDevLogService {
+    List<LightStripDevLogDTO> getStatisticsInfoByDTO(LightStripDevLogDTO dto);
+
+    Integer getTimezoneByLightStripDevId(Integer id);
+}

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

@@ -0,0 +1,19 @@
+package com.welampiot.service;
+
+import com.welampiot.dto.LightStripDevDTO;
+import com.welampiot.vo.LightStripDevVO;
+
+/**
+ * ClassName: LightStripDevService
+ * Package: com.welampiot.service
+ * Description:
+ *
+ * @Author: zhj_Start
+ * @Create: 2023/5/4 - 15:56
+ * @Version: v1.0
+ */
+public interface LightStripDevService {
+    LightStripDevVO getLightStripData(LightStripDevDTO dto);
+
+    LightStripDevVO getLightStripListByDTO(LightStripDevDTO dto);
+}

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

@@ -0,0 +1,20 @@
+package com.welampiot.service;
+
+import com.welampiot.dto.LightStripGroupDTO;
+import com.welampiot.vo.LightStripGroupDetailVO;
+import com.welampiot.vo.LightStripGroupVO;
+
+/**
+ * ClassName: LightStripGroupService
+ * Package: com.welampiot.service
+ * Description:
+ *
+ * @Author: zhj_Start
+ * @Create: 2023/5/5 - 17:17
+ * @Version: v1.0
+ */
+public interface LightStripGroupService {
+    LightStripGroupVO getLightStripGroupByDTO(LightStripGroupDTO dto);
+
+    LightStripGroupDetailVO getLightStripGroupDetailsById(Integer id, Integer version);
+}

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

@@ -0,0 +1,34 @@
+package com.welampiot.service.impl;
+
+import com.welampiot.dao.LightStripDevLogDao;
+import com.welampiot.dto.LightStripDevLogDTO;
+import com.welampiot.service.LightStripDevLogService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+/**
+ * ClassName: LightStripDevLogServiceImpl
+ * Package: com.welampiot.service.impl
+ * Description:
+ *
+ * @Author: zhj_Start
+ * @Create: 2023/5/6 - 14:07
+ * @Version: v1.0
+ */
+@Service
+public class LightStripDevLogServiceImpl implements LightStripDevLogService {
+    @Autowired
+    private LightStripDevLogDao lightStripDevLogDao;
+
+    @Override
+    public List<LightStripDevLogDTO> getStatisticsInfoByDTO(LightStripDevLogDTO dto) {
+        return lightStripDevLogDao.getStatisticsInfoByDTO(dto);
+    }
+
+    @Override
+    public Integer getTimezoneByLightStripDevId(Integer id) {
+        return lightStripDevLogDao.getTimezoneByLightStripDevId(id);
+    }
+}

+ 340 - 0
src/main/java/com/welampiot/service/impl/LightStripDevServiceImpl.java

@@ -0,0 +1,340 @@
+package com.welampiot.service.impl;
+
+import com.welampiot.dao.LightStripDevDao;
+import com.welampiot.dto.LightStripDevDTO;
+import com.welampiot.service.LightStripDevService;
+import com.welampiot.vo.LightStripDevVO;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+
+/**
+ * ClassName: LightStripDevServiceImpl
+ * Package: com.welampiot.service.impl
+ * Description:
+ *
+ * @Author: zhj_Start
+ * @Create: 2023/5/4 - 15:56
+ * @Version: v1.0
+ */
+@Service
+public class LightStripDevServiceImpl implements LightStripDevService {
+    @Autowired
+    private LightStripDevDao lightStripDevDao;
+
+    @Override
+    public LightStripDevVO getLightStripData(LightStripDevDTO dto) {
+        LightStripDevVO vo = new LightStripDevVO();
+        vo.setTotal(lightStripDevDao.getLightStripTotalByDTO(dto));
+        vo.setOnlineCount(lightStripDevDao.getLightStripOnlineTotalByDTO(dto));
+        vo.setStatusCount(lightStripDevDao.getLightStripOpenTotalByDTO(dto));
+        return vo;
+    }
+
+    @Override
+    public LightStripDevVO getLightStripListByDTO(LightStripDevDTO dto) {
+        LightStripDevVO vo = new LightStripDevVO();
+        vo.setTotal(lightStripDevDao.getLightStripTotalByDTO(dto));
+        List<LightStripDevDTO> lightStripList = lightStripDevDao.getLightStripListByDTO(dto);
+        List<LightStripDevDTO> list = new ArrayList<>();
+        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+        lightStripList.forEach(devDTO ->{
+            //灯杆名
+            if (devDTO.getLampPoleName() == null){
+                devDTO.setLampPoleName("");
+            }
+            //区域名
+            if (devDTO.getArea() == null){
+                devDTO.setArea("");
+            }
+            //路段名
+            if (devDTO.getSection() == null){
+                devDTO.setSection("");
+            }
+            //灯带在线状态
+            if (devDTO.getOnline() != null && devDTO.getOnline() == 1){
+                devDTO.setOnline(1);
+            }else {
+                devDTO.setOnline(0);
+            }
+            //市电网络状态(0:离线,1:在线)
+            if (devDTO.getOnline2() != null && devDTO.getOnline2() == 1){
+                devDTO.setOnline2(1);
+            }else {
+                devDTO.setOnline2(0);
+            }
+            //MPPT网络状态(0:离线,1:在线)
+            if (devDTO.getOnline3() != null && devDTO.getOnline3() == 1){
+                devDTO.setOnline3(1);
+            }else {
+                devDTO.setOnline3(0);
+            }
+            //灯状态(0:关,1: 开)
+            if (devDTO.getStatus() != null && devDTO.getStatus() == 1){
+                devDTO.setStatus(1);
+            }else {
+                devDTO.setStatus(0);
+            }
+            //串口(0 3号串口,1 2号串口,2 1号串口)
+            if (devDTO.getSerialPort() != null && devDTO.getSerialPort() == 2){
+                devDTO.setSerialPort(2);
+            }else if (devDTO.getSerialPort() != null && devDTO.getSerialPort() == 1) {
+                devDTO.setSerialPort(1);
+            }else {
+                devDTO.setSerialPort(0);
+            }
+            //云盒类型(G100,1 G200,2 G40,3 G300)
+            if (devDTO.getCloudBoxModel() != null && devDTO.getCloudBoxModel() == 3){
+                devDTO.setCloudBoxModel(3);
+            }else if (devDTO.getCloudBoxModel() != null && devDTO.getCloudBoxModel() == 2) {
+                devDTO.setCloudBoxModel(2);
+            }else {
+                devDTO.setCloudBoxModel(1);
+            }
+            //模式类型(0:常亮,1.呼吸,2.爆闪,4:闪烁)
+            if (devDTO.getType() != null && devDTO.getType() == 4){
+                devDTO.setType(4);
+            }else if (devDTO.getType() != null && devDTO.getType() == 2) {
+                devDTO.setType(2);
+            }else if (devDTO.getType() != null && devDTO.getType() == 1) {
+                devDTO.setType(1);
+            }else {
+                devDTO.setType(0);
+            }
+            if (devDTO.getType() == 0){
+                devDTO.setModeStr("常亮");
+            }else if (devDTO.getType() == 1){
+                if (devDTO.getMode() != null){
+                    switch (devDTO.getMode()){
+                        case 1 :
+                            devDTO.setModeStr("红灯呼吸");
+                            break;
+                        case 2 :
+                            devDTO.setModeStr("绿灯呼吸");
+                            break;
+                        case 3 :
+                            devDTO.setModeStr("蓝灯呼吸");
+                            break;
+                        case 4 :
+                            devDTO.setModeStr("RGB呼吸");
+                            break;
+                        case 5 :
+                            devDTO.setModeStr("黄灯呼吸");
+                            break;
+                        default:
+                            devDTO.setModeStr("紫灯呼吸");
+                            break;
+                    }
+                }
+            }else if (devDTO.getType() == 2){
+                if (devDTO.getMode() != null){
+                    switch (devDTO.getMode()){
+                        case 1 :
+                            devDTO.setModeStr("红灯爆闪");
+                            break;
+                        case 2 :
+                            devDTO.setModeStr("绿灯爆闪");
+                            break;
+                        case 3 :
+                            devDTO.setModeStr("蓝灯爆闪");
+                            break;
+                        case 4 :
+                            devDTO.setModeStr("白色爆闪");
+                            break;
+                        case 5 :
+                            devDTO.setModeStr("7色爆闪");
+                            break;
+                        case 6 :
+                            devDTO.setModeStr("黄灯爆闪");
+                            break;
+                        default:
+                            devDTO.setModeStr("紫灯爆闪");
+                            break;
+                    }
+                }
+            }else if (devDTO.getType() == 4){
+                if (devDTO.getMode() != null){
+                    switch (devDTO.getMode()){
+                        case 1 :
+                            devDTO.setModeStr("红灯闪烁");
+                            break;
+                        case 2 :
+                            devDTO.setModeStr("绿灯闪烁");
+                            break;
+                        case 3 :
+                            devDTO.setModeStr("蓝灯闪烁");
+                            break;
+                        case 4 :
+                            devDTO.setModeStr("白色闪烁");
+                            break;
+                        case 5 :
+                            devDTO.setModeStr("7色闪烁");
+                            break;
+                        case 6 :
+                            devDTO.setModeStr("黄灯闪烁");
+                            break;
+                        default:
+                            devDTO.setModeStr("紫灯闪烁");
+                            break;
+                    }
+                }
+            }
+            //通讯方式类型(0: RS485,1: 4G,2: GPRS)
+            if (devDTO.getNetType() != null && devDTO.getNetType() == 2){
+                devDTO.setNetType(2);
+            }else if (devDTO.getNetType() != null && devDTO.getNetType() == 1) {
+                devDTO.setNetType(1);
+            }else {
+                devDTO.setNetType(0);
+            }
+            //创建时间
+            if (devDTO.getCreateTime() != null && !devDTO.getCreateTime().equals("")){
+                try {
+                    devDTO.setCreateTime(simpleDateFormat.format(simpleDateFormat.parse(devDTO.getCreateTime())));
+                } catch (ParseException e) {
+                    throw new RuntimeException(e);
+                }
+            }else {
+                devDTO.setCreateTime("");
+            }
+            //更新时间
+            if (devDTO.getUpdateTime() != null && !devDTO.getUpdateTime().equals("")){
+                Date cmdTime;
+                try {
+                    cmdTime = simpleDateFormat.parse(devDTO.getUpdateTime());
+                } catch (ParseException e) {
+                    throw new RuntimeException(e);
+                }
+                //判断时区,为null默认东八区
+                long timezone = devDTO.getTimezone() == null ? 8 : devDTO.getTimezone();
+                long l = cmdTime.getTime() + timezone * 3600 * 1000;
+                cmdTime = new Date(l);
+                devDTO.setUpdateTime(simpleDateFormat.format(cmdTime));
+            }else {
+                devDTO.setUpdateTime("");
+            }
+            //安装时间
+            if (devDTO.getInstallDate() != null && !devDTO.getInstallDate().equals("")){
+                try {
+                    devDTO.setInstallDate(simpleDateFormat.format(simpleDateFormat.parse(devDTO.getInstallDate())));
+                } catch (ParseException e) {
+                    throw new RuntimeException(e);
+                }
+            }else {
+                devDTO.setInstallDate("");
+            }
+            //过期时间
+            if (devDTO.getExpirationDate() != null && !devDTO.getExpirationDate().equals("")){
+                try {
+                    devDTO.setExpirationDate(simpleDateFormat.format(simpleDateFormat.parse(devDTO.getExpirationDate())));
+                } catch (ParseException e) {
+                    throw new RuntimeException(e);
+                }
+            }else {
+                devDTO.setExpirationDate("");
+            }
+            //供电方式 (0 市电,1 电池)
+            if (devDTO.getPowerSwitch() != null && devDTO.getPowerSwitch() == 1){
+                devDTO.setPowerSwitch(1);
+            }else {
+                devDTO.setPowerSwitch(0);
+            }
+            //策略名称
+            if (devDTO.getPolicyName() == null){
+                devDTO.setPolicyName("");
+            }
+            //电池充电状态(0 没有充电,1 启动充电模式,2 mppt充电模式,3 均衡充电模式,4 提升充电模式,5 浮充充电模式,6 限流(超功率))
+            if (devDTO.getChargeType() != null){
+                devDTO.setChargeType(devDTO.getChargeType());
+            }else {
+                devDTO.setChargeType(0);
+            }
+            if (devDTO.getBatCurr() == null || devDTO.getBatCurr().equals("0.0")){
+                devDTO.setBatCurr("0");
+            }
+            if (devDTO.getBatVolt() == null || devDTO.getBatVolt().equals("0.0")){
+                devDTO.setBatVolt("0");
+            }
+            if (devDTO.getBatPower() == null || devDTO.getBatPower().equals("0.0")){
+                devDTO.setBatPower("0");
+            }
+            if (devDTO.getFreq() == null || devDTO.getFreq().equals("0.0")){
+                devDTO.setFreq("0");
+            }
+            if (devDTO.getGridCurr() == null || devDTO.getGridCurr().equals("0.0")){
+                devDTO.setGridCurr("0");
+            }
+            if (devDTO.getGridCurr2() == null || devDTO.getGridCurr2().equals("0.0")){
+                devDTO.setGridCurr2("0");
+            }
+            if (devDTO.getGridVolt() == null || devDTO.getGridVolt().equals("0.0")){
+                devDTO.setGridVolt("0");
+            }
+            if (devDTO.getGridVolt2() == null || devDTO.getGridVolt2().equals("0.0")){
+                devDTO.setGridVolt2("0");
+            }
+            if (devDTO.getPower() == null || devDTO.getPower().equals("0.0")){
+                devDTO.setPower("0");
+            }
+            if (devDTO.getPower2() == null || devDTO.getPower2().equals("0.0")){
+                devDTO.setPower2("0");
+            }
+            if (devDTO.getSolarCurr() == null || devDTO.getSolarCurr().equals("0.0")){
+                devDTO.setSolarCurr("0");
+            }
+            if (devDTO.getSolarPower() == null || devDTO.getSolarPower().equals("0.0")){
+                devDTO.setSolarPower("0");
+            }
+            if (devDTO.getSolarVolt() == null || devDTO.getSolarVolt().equals("0.0")){
+                devDTO.setSolarVolt("0");
+            }
+            if (devDTO.getFreq() == null || devDTO.getFreq().equals("0.0")){
+                devDTO.setFreq("0");
+            }
+            if (devDTO.getFreq() == null || devDTO.getFreq().equals("0.0")){
+                devDTO.setFreq("0");
+            }
+            if (devDTO.getFreq() == null || devDTO.getFreq().equals("0.0")){
+                devDTO.setFreq("0");
+            }
+            if (devDTO.getUsedEnergyTotal() == null || devDTO.getUsedEnergyTotal().equals("0.0")){
+                devDTO.setUsedEnergyTotal("0");
+            }
+            if (devDTO.getUsedEnergyTotal2() == null || devDTO.getUsedEnergyTotal2().equals("0.0")){
+                devDTO.setUsedEnergyTotal2("0");
+            }
+            if (devDTO.getMpptDevId() == null){
+                devDTO.setMpptDevId(0);
+            }
+            if (devDTO.getMpptDevAddress() == null){
+                devDTO.setMpptDevAddress("");
+            }
+            if (devDTO.getMpptDevType() != null && devDTO.getMpptDevType() == 1){
+                devDTO.setMpptDevType(1);
+            }else {
+                devDTO.setMpptDevType(0);
+            }
+            if (devDTO.getMpptDevSerialPort() != null && devDTO.getMpptDevSerialPort() == 2){
+                devDTO.setMpptDevSerialPort(2);
+            }else if (devDTO.getMpptDevSerialPort() != null && devDTO.getMpptDevSerialPort() == 1){
+                devDTO.setMpptDevSerialPort(1);
+            }else {
+                devDTO.setMpptDevSerialPort(0);
+            }
+            if (devDTO.getMpptDevNumber() == null){
+                devDTO.setMpptDevNumber("000000");
+            }
+            if (devDTO.getMpptDevName() == null){
+                devDTO.setMpptDevName("");
+            }
+            list.add(devDTO);
+        });
+        vo.setList(list);
+        return vo;
+    }
+}

+ 93 - 0
src/main/java/com/welampiot/service/impl/LightStripGroupServiceImpl.java

@@ -0,0 +1,93 @@
+package com.welampiot.service.impl;
+
+import com.welampiot.dao.LightStripGroupDao;
+import com.welampiot.dto.LightStripGroupDTO;
+import com.welampiot.dto.LightStripPolicyDTO;
+import com.welampiot.service.LightStripGroupService;
+import com.welampiot.vo.LightStripGroupDetailVO;
+import com.welampiot.vo.LightStripGroupVO;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * ClassName: LightStripGroupServiceImpl
+ * Package: com.welampiot.service.impl
+ * Description:
+ *
+ * @Author: zhj_Start
+ * @Create: 2023/5/5 - 17:17
+ * @Version: v1.0
+ */
+@Service
+public class LightStripGroupServiceImpl implements LightStripGroupService {
+    @Autowired
+    private LightStripGroupDao lightStripGroupDao;
+
+    @Override
+    public LightStripGroupVO getLightStripGroupByDTO(LightStripGroupDTO dto) {
+        LightStripGroupVO vo = new LightStripGroupVO();
+        List<LightStripGroupDTO> lightStripGroup = lightStripGroupDao.getLightStripGroupByDTO(dto);
+        List<LightStripGroupDTO> list = new ArrayList<>();
+        lightStripGroup.forEach(groupDTO ->{
+            if (groupDTO.getArea() == null){
+                groupDTO.setArea("");
+            }
+            if (groupDTO.getSection() == null){
+                groupDTO.setSection("");
+            }
+            if (groupDTO.getType() != null && groupDTO.getType() == 1){
+                groupDTO.setType(1);
+            }else {
+                groupDTO.setType(0);
+            }
+            if (groupDTO.getPolicyName() == null){
+                groupDTO.setPolicyName("");
+            }
+            if (groupDTO.getPolicyId() != null){
+                groupDTO.setPolicyData(lightStripGroupDao.getLightStripPolicyData(groupDTO.getPolicyId()));
+            }else {
+                groupDTO.setPolicyData(new LightStripPolicyDTO());
+            }
+            list.add(groupDTO);
+        });
+        vo.setList(list);
+        return vo;
+    }
+
+    @Override
+    public LightStripGroupDetailVO getLightStripGroupDetailsById(Integer id, Integer version) {
+        LightStripGroupDetailVO vo = new LightStripGroupDetailVO();
+        LightStripGroupDTO lightStripGroupDTO = lightStripGroupDao.getLightStripGroupDetailsById(id, version);
+        if (lightStripGroupDTO == null) return null;
+        if (lightStripGroupDTO.getAreaId() != null && lightStripGroupDTO.getAreaId() != 0){
+            vo.setAreaId(lightStripGroupDTO.getAreaId().toString());
+            vo.setArea(lightStripGroupDTO.getArea());
+        }else {
+            vo.setAreaId("0");
+            vo.setArea("");
+        }
+        if (lightStripGroupDTO.getSectionId() != null && lightStripGroupDTO.getSectionId() != 0){
+            vo.setSectionId(lightStripGroupDTO.getSectionId().toString());
+            vo.setSection(lightStripGroupDTO.getSection());
+        }else {
+            vo.setSectionId("0");
+            vo.setSection("");
+        }
+        vo.setNumber(lightStripGroupDTO.getNumber().toString());
+        vo.setLampCount(lightStripGroupDTO.getLightCount().toString());
+        if (lightStripGroupDTO.getType() != null && lightStripGroupDTO.getType() == 1){
+            lightStripGroupDTO.setType(1);
+        }else {
+            lightStripGroupDTO.setType(0);
+        }
+        if (lightStripGroupDTO.getType() == 1){
+            vo.setWork(lightStripGroupDao.getLightStripPolicyName(lightStripGroupDTO.getValue()));
+        }else {
+            vo.setWork("亮度:" + lightStripGroupDTO.getValue() + "%");
+        }
+        return vo;
+    }
+}

+ 29 - 0
src/main/java/com/welampiot/vo/LightStripDevLogVO.java

@@ -0,0 +1,29 @@
+package com.welampiot.vo;
+
+import com.welampiot.dto.LightStripDevLogDTO;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.util.List;
+
+/**
+ * ClassName: LightStripDevLogVO
+ * Package: com.welampiot.dto
+ * Description:
+ *
+ * @Author: zhj_Start
+ * @Create: 2023/5/5 - 15:20
+ * @Version: v1.0
+ */
+@Data
+public class LightStripDevLogVO implements Serializable {
+    private List<Object> dateList;
+
+    private List<Object> usedEnergyList1;
+
+    private List<Object> usedEnergyList2;
+
+    private List<LightStripDevLogDTO> list;
+
+    private static final long serialVersionUID = 1L;
+}

+ 29 - 0
src/main/java/com/welampiot/vo/LightStripDevVO.java

@@ -0,0 +1,29 @@
+package com.welampiot.vo;
+
+import com.welampiot.dto.LightStripDevDTO;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.util.List;
+
+/**
+ * ClassName: LightStripDevVO
+ * Package: com.welampiot.vo
+ * Description:
+ *
+ * @Author: zhj_Start
+ * @Create: 2023/5/4 - 15:57
+ * @Version: v1.0
+ */
+@Data
+public class LightStripDevVO implements Serializable {
+    private Integer total;
+
+    private Integer onlineCount;
+
+    private Integer statusCount;
+
+    private List<LightStripDevDTO> list;
+
+    private static final long serialVersionUID = 1L;
+}

+ 33 - 0
src/main/java/com/welampiot/vo/LightStripGroupDetailVO.java

@@ -0,0 +1,33 @@
+package com.welampiot.vo;
+
+import lombok.Data;
+
+import java.io.Serializable;
+
+/**
+ * ClassName: LightStripGroupDetailVO
+ * Package: com.welampiot.vo
+ * Description:
+ *
+ * @Author: zhj_Start
+ * @Create: 2023/5/5 - 17:18
+ * @Version: v1.0
+ */
+@Data
+public class LightStripGroupDetailVO implements Serializable {
+    private String area;
+
+    private String section;
+
+    private String areaId;
+
+    private String sectionId;
+
+    private String number;
+
+    private String lampCount;
+
+    private String work;
+
+    private static final long serialVersionUID = 1L;
+}

+ 23 - 0
src/main/java/com/welampiot/vo/LightStripGroupVO.java

@@ -0,0 +1,23 @@
+package com.welampiot.vo;
+
+import com.welampiot.dto.LightStripGroupDTO;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.util.List;
+
+/**
+ * ClassName: LightStripGroupVO
+ * Package: com.welampiot.vo
+ * Description:
+ *
+ * @Author: zhj_Start
+ * @Create: 2023/5/5 - 17:18
+ * @Version: v1.0
+ */
+@Data
+public class LightStripGroupVO implements Serializable {
+    private List<LightStripGroupDTO> list;
+
+    private static final long serialVersionUID = 1L;
+}

+ 25 - 0
src/main/resources/mapper/LightStripDevLogMapper.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.LightStripDevLogDao">
+
+    <select id="getStatisticsInfoByDTO" resultType="LightStripDevLogDTO">
+        select l.updatetime as updateTime,l.usedEnergyTotal,l.usedEnergyTotal2
+        from light_strip_dev_log l
+        where l.dev_id = #{devId}
+            <if test="startDate != null and startDate != ''">
+                and l.updatetime <![CDATA[ >= ]]> #{startDate}
+            </if>
+            <if test="endDate != null and endDate != ''">
+                and l.updatetime <![CDATA[ <= ]]> #{endDate}
+            </if>
+    </select>
+
+    <select id="getTimezoneByLightStripDevId" resultType="Integer">
+        select s.timezone
+        from light_strip_dev lsd
+        left join lamp_pole lp on lp.id = lsd.lamp_pole_id
+        left join section s on lp.sectionid = s.id
+        where lsd.id = #{id}
+    </select>
+    
+</mapper>

+ 90 - 0
src/main/resources/mapper/LightStripDevMapper.xml

@@ -0,0 +1,90 @@
+<?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.LightStripDevDao">
+    
+    <select id="getLightStripTotalByDTO" resultType="Integer">
+        select count(l.id) as total
+        from light_strip_dev l left join lamp_pole lp on lp.id = l.lamp_pole_id
+        <if test="sectionList != null and !sectionList.isEmpty()">
+            where lp.sectionid in
+            <foreach collection="sectionList" item="dto" open="(" separator="," close=")">
+                #{dto}
+            </foreach>
+        </if>
+    </select>
+
+    <select id="getLightStripOnlineTotalByDTO" resultType="Integer">
+        select count(l.id) as total
+        from light_strip_dev l left join lamp_pole lp on lp.id = l.lamp_pole_id
+        where l.online = 1
+        <if test="sectionList != null and !sectionList.isEmpty()">
+            and lp.sectionid in
+            <foreach collection="sectionList" item="dto" open="(" separator="," close=")">
+                #{dto}
+            </foreach>
+        </if>
+    </select>
+
+    <select id="getLightStripOpenTotalByDTO" resultType="Integer">
+        select count(l.id) as total
+        from light_strip_dev l left join lamp_pole lp on lp.id = l.lamp_pole_id
+        where l.online = 1 and l.status = 1
+        <if test="sectionList != null and !sectionList.isEmpty()">
+            and lp.sectionid in
+            <foreach collection="sectionList" item="dto" open="(" separator="," close=")">
+                #{dto}
+            </foreach>
+        </if>
+    </select>
+
+    <select id="getLightStripListByDTO" resultType="LightStripDevDTO">
+        select
+            <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>
+            l.id,l.lamp_pole_id lampPoleId,lp.name as lampPoleName,s.name as section,l.name,l.number,l.model,l.online,l.online2,
+            l.online3,l.address,l.status,l.color,l.factory,w.model as cloudBoxModel,l.serial_port serialPort,l.type,l.mode,l.netType,
+            l.imei,l.patrol,l.createtime as createTime,l.updatetime as updateTime,l.powerSwitch,l.gridVolt,l.gridCurr,l.power,l.freq,
+            l.soft_verson softVersion,l.hard_version hardVersion,l.usedEnergyTotal,l.gridVolt2,l.gridCurr2,l.power2,l.usedEnergyTotal2,
+            l.batVolt,l.batCurr,l.batPower,l.solarCurr,l.solarPower,l.charge_type chargeType,l.solarVolt,l.policyid as policyId,l.switchVol as voltage,
+            l.install_date installDate,l.expiration_date expirationDate,s.timezone,sd.id as mpptDevId,sd.address as mpptDevAddress,sd.type as mpptDevType,
+            sd.serial_port as mpptDevSerialPort,sd.number as mpptDevNumber,sd.name as mpptDevName,l.solarSwitchVol as solarVoltage
+        from light_strip_dev l left join lamp_pole lp on lp.id = l.lamp_pole_id
+                               left join light_strip_policy lsp on l.policyid = lsp.id
+                               left join solar_dev sd on lp.id = sd.lamp_pole_id
+                               left join wifi w on lp.id = w.lamp_pole_id
+                               left join section s on lp.sectionid = s.id
+                               left join global_location gl on s.pid = gl.id
+        where 1=1
+            <if test="sectionList != null and !sectionList.isEmpty()">
+                and lp.sectionid in
+                <foreach collection="sectionList" item="dto" open="(" separator="," close=")">
+                    #{dto}
+                </foreach>
+            </if>
+            <if test="keyword != null and keyword != ''">
+                and (l.number like '%${keyword}%' or l.name like '%${keyword}%')
+            </if>
+            <choose>
+                <when test="onlineState == 0">
+                    and l.online = 0
+                </when>
+                <when test="onlineState == 1">
+                    and l.online = 1
+                </when>
+            </choose>
+            order by convert(l.name using gbk) desc,l.number asc
+            <if test="page >= 0 and count > 0">
+                limit #{page},#{count}
+            </if>
+    </select>
+
+</mapper>

+ 71 - 0
src/main/resources/mapper/LightStripGroupMapper.xml

@@ -0,0 +1,71 @@
+<?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.LightStripGroupDao">
+    
+    <select id="getLightStripGroupByDTO" resultType="LightStripGroupDTO">
+        select
+            <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>
+            l.id,l.name,l.number,l.lightcount as lightCount,l.type,l.value,s.name as section,lsp.name as policyName,lsp.id as policyId
+        from light_strip_group l left join lamp_pole lp on l.sectionid = lp.sectionid
+                                 left join light_strip_dev lsd on lp.id = lsd.lamp_pole_id
+                                 left join light_strip_policy lsp on lsd.policyid = lsp.id
+                                 left join section s on lp.sectionid = s.id
+                                 left join global_location gl on s.pid = gl.id
+        where 1=1
+            <if test="sectionList != null and !sectionList.isEmpty()">
+                and lp.sectionid in
+                <foreach collection="sectionList" item="dto" open="(" separator="," close=")">
+                    #{dto}
+                </foreach>
+            </if>
+            <if test="keyword != null and keyword != ''">
+                and (l.number like '%${keyword}%' or l.name like '%${keyword}%')
+            </if>
+            order by convert(l.name using gbk) desc,l.number asc
+            <if test="page >= 0 and count > 0">
+                limit #{page},#{count}
+            </if>
+    </select>
+
+    <select id="getLightStripPolicyData" resultType="LightStripPolicyDTO">
+        select l.id,l.type
+        from light_strip_policy l
+        where l.id = #{policyId}
+    </select>
+    
+    <select id="getLightStripGroupDetailsById" resultType="LightStripGroupDTO">
+        select
+            <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>
+            l.areaid as areaId,l.sectionid as sectionId,s.name as section,l.number,l.lightcount as lightCount,l.type,l.value
+        from light_strip_group l left join section s on l.sectionid = s.id
+                                 left join global_location gl on s.pid = gl.id
+        where l.id = #{id}
+    </select>
+
+    <select id="getLightStripPolicyName" resultType="String">
+        select l.name
+        from light_strip_policy l
+        where l.id = #{policyId}
+    </select>
+
+</mapper>