Przeglądaj źródła

优化太阳能统计接口、倾斜监测设备接口

zhj 2 lat temu
rodzic
commit
739a96a20b

+ 5 - 0
src/main/java/com/welampiot/common/InterfaceResultEnum.java

@@ -71,6 +71,11 @@ public enum InterfaceResultEnum {
     USER_HAS_NOT_MODIFY_PRIVILEGE("0264","用户没有修改权限","",""),
     LACK_RATE_NAME_ERROR("0265","费率名称不能为空","",""),
     RATE_NAME_UNIQUE_ERROR("0266","费率名称重复","",""),
+    LACK_MAC_NUMBER_ERROR("0267","井盖mac设备号不能为空","",""),
+    LACK_SIM_NUMBER_ERROR("0268","井盖sim卡号不能为空","",""),
+    LACK_TILT_ADDRESS_ERROR("0269","倾斜监测设备地址不能为空","",""),
+    TILT_ADDRESS_UNIQUE_ERROR("0270","倾斜监测设备地址重复","",""),
+    LACK_PROTOCOL_TYPE_ERROR("0271","请选择协议类型","",""),
     ;
     private String code;
     private String msgCn;

+ 38 - 26
src/main/java/com/welampiot/controller/LampController.java

@@ -20,6 +20,7 @@ import java.text.ParseException;
 import java.text.SimpleDateFormat;
 import java.util.ArrayList;
 import java.util.Date;
+import java.util.HashMap;
 import java.util.List;
 
 @RestController
@@ -407,6 +408,7 @@ public class LampController {
         startTime = l - 24L * 3600 * 1000 * 29;
         endTime = l;
 
+        HashMap<String, Integer> objectObjectHashMap = new HashMap<>();
         long timeT = startTime;
         int i = 0;
 
@@ -417,8 +419,10 @@ public class LampController {
         List<Object> totalLightTime = new ArrayList<>();
         List<Object> totalCom = new ArrayList<>();
         List<Object> totalEle = new ArrayList<>();
+        List<SolarInfoLogDTO> list = new ArrayList<>();
         SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
         while (timeT <= endTime) {
+            objectObjectHashMap.put(simpleDateFormat.format(new Date(timeT)),i);
             dateList.add(simpleDateFormat.format(new Date(timeT + timezone * 3600 * 1000)));
             lightTimeList.add(0);
             eleList.add(0);
@@ -426,40 +430,48 @@ public class LampController {
             totalLightTime.add(0);
             totalCom.add(0);
             totalEle.add(0);
+            list.add(null);
             timeT += 3600 * 1000 * 24;
-            i ++;
+            i++;
+        }
+
+        List<SolarInfoLogDTO> solarInfoLogList = solarInfoLogService.getSolarInfoLogByDTO(id);
+        for (SolarInfoLogDTO solarInfoLogDTO : solarInfoLogList) {
+            Date date = new Date(simpleDateFormat.parse(solarInfoLogDTO.getMaxTime()).getTime());
+            String s = simpleDateFormat.format(date);
+            if (objectObjectHashMap.containsKey(s)){
+                Integer integer = objectObjectHashMap.get(s);
+                list.set(integer,solarInfoLogDTO);
+            }
         }
 
-        timeT = startTime;
-        i = 0;
-        simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
-        SolarInfoLogDTO dto = new SolarInfoLogDTO();
-        dto.setSolarId(id);
         DecimalFormat decimalFormat = new DecimalFormat("0.000");
-        while (timeT <= endTime) {
-            dto.setStartDate(simpleDateFormat.format(new Date(timeT + timezone * 3600 * 1000)));
-            dto.setEndDate(simpleDateFormat.format(new Date(timeT + timezone * 3600 * 1000 + 3600 * 1000 * 24)));
-            SolarInfoLogDTO maxSolarInfoLog = solarInfoLogService.getMaxSolarInfoLogByDTO(dto);
-            SolarInfoLogDTO minSolarInfoLog = solarInfoLogService.getMinSolarInfoLogByDTO(dto);
-            if (maxSolarInfoLog != null && minSolarInfoLog != null) {
-                if (maxSolarInfoLog.getTotalLightTime() != null && minSolarInfoLog.getTotalLightTime() != null) {
-                    totalLightTime.set(i,Integer.parseInt(maxSolarInfoLog.getTotalLightTime()));
-                    Integer v = Integer.parseInt(maxSolarInfoLog.getTotalLightTime()) - Integer.parseInt(minSolarInfoLog.getTotalLightTime());
-                    lightTimeList.set(i, v);
+        for (SolarInfoLogDTO solarInfoLogDTO : list) {
+            if (solarInfoLogDTO != null) {
+                Date date = new Date(simpleDateFormat.parse(solarInfoLogDTO.getMaxTime()).getTime());
+                String s = simpleDateFormat.format(date);
+                Integer integer = null;
+                if (objectObjectHashMap.containsKey(s)){
+                    integer = objectObjectHashMap.get(s);
+                    list.set(integer,solarInfoLogDTO);
                 }
-                if (maxSolarInfoLog.getTotalConsumption() != null && minSolarInfoLog.getTotalConsumption() != null) {
-                    totalCom.set(i,Float.parseFloat(maxSolarInfoLog.getTotalConsumption()));
-                    Float v = Float.parseFloat(maxSolarInfoLog.getTotalConsumption()) - Float.parseFloat(minSolarInfoLog.getTotalConsumption());
-                    comList.set(i,Float.parseFloat(decimalFormat.format(v)));
+
+                if (solarInfoLogDTO.getMaxTotalLightTime() != null && solarInfoLogDTO.getMinTotalLightTime() != null && integer != null) {
+                    totalLightTime.set(integer,Integer.parseInt(solarInfoLogDTO.getMaxTotalLightTime()));
+                    Integer dayLightTime = Integer.parseInt(solarInfoLogDTO.getMaxTotalLightTime()) - Integer.parseInt(solarInfoLogDTO.getMinTotalLightTime());
+                    lightTimeList.set(integer,dayLightTime);
+                }
+                if (solarInfoLogDTO.getMaxTotalConsumption() != null && solarInfoLogDTO.getMinTotalConsumption() != null && integer != null) {
+                    totalCom.set(integer,Float.parseFloat(solarInfoLogDTO.getMaxTotalConsumption()));
+                    Float dayCom = Float.parseFloat(solarInfoLogDTO.getMaxTotalConsumption()) - Float.parseFloat(solarInfoLogDTO.getMinTotalConsumption());
+                    comList.set(integer,Float.parseFloat(decimalFormat.format(dayCom)));
                 }
-                if (maxSolarInfoLog.getTotalElectricSave() != null && minSolarInfoLog.getTotalElectricSave() != null) {
-                    totalEle.set(i,Float.parseFloat(maxSolarInfoLog.getTotalElectricSave()));
-                    Float v = Float.parseFloat(maxSolarInfoLog.getTotalElectricSave()) - Float.parseFloat(minSolarInfoLog.getTotalElectricSave());
-                    eleList.set(i, Float.parseFloat(decimalFormat.format(v)));
+                if (solarInfoLogDTO.getMaxTotalEleSave() != null && solarInfoLogDTO.getMinTotalEleSave() != null && integer != null) {
+                    totalEle.set(integer,Float.parseFloat(solarInfoLogDTO.getMaxTotalEleSave()));
+                    Float daySave = Float.parseFloat(solarInfoLogDTO.getMaxTotalEleSave()) - Float.parseFloat(solarInfoLogDTO.getMinTotalEleSave());
+                    eleList.set(integer,Float.parseFloat(decimalFormat.format(daySave)));
                 }
             }
-            timeT += 3600 * 1000 * 24;
-            i ++;
         }
 
         SolarInfoLogVO solarInfoLogVO = new SolarInfoLogVO();

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

@@ -3,9 +3,12 @@ package com.welampiot.controller;
 import com.welampiot.common.BaseResult;
 import com.welampiot.common.InterfaceResultEnum;
 import com.welampiot.dto.ManholeDTO;
+import com.welampiot.dto.TiltDevDTO;
 import com.welampiot.service.ManholeService;
+import com.welampiot.service.TiltDevService;
 import com.welampiot.utils.ToolUtils;
 import com.welampiot.vo.ManholeVO;
+import com.welampiot.vo.TiltDevVO;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.CrossOrigin;
 import org.springframework.web.bind.annotation.RequestMapping;
@@ -36,6 +39,9 @@ public class ManholeController {
     @Autowired
     private ToolUtils toolUtils;
 
+    @Autowired
+    private TiltDevService tiltDevService;
+
     /**
      * 获取井盖设备统计信息
      * @param request
@@ -183,4 +189,99 @@ public class ManholeController {
         }
         return toolUtils.response(InterfaceResultEnum.OPERATION_SUCCESS,version);
     }
+
+    /**
+     * 获取倾斜设备监测列表
+     * @param request 请求参数
+     * @return tiltDevVO
+     */
+    @RequestMapping(value = "tiltList", method = RequestMethod.POST)
+    public BaseResult<?> tiltList(HttpServletRequest request) {
+        int version = (int) 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);
+
+        TiltDevDTO tiltDevDTO = new TiltDevDTO();
+        tiltDevDTO.setPage(count * (page - 1));
+        tiltDevDTO.setCount(count);
+        tiltDevDTO.setKeyword(keyword);
+        tiltDevDTO.setSectionList(toolUtils.getSectionList(request));
+
+        TiltDevVO tiltDevVO = tiltDevService.getTiltDevByDTO(tiltDevDTO);
+        return toolUtils.response(InterfaceResultEnum.OPERATION_SUCCESS,version,tiltDevVO);
+    }
+
+    /**
+     * 获取倾斜监测设备统计数据
+     * @param request 请求数据
+     * @return vo
+     */
+    @RequestMapping(value = "tiltData", method = RequestMethod.POST)
+    public BaseResult<?> tiltData(HttpServletRequest request) {
+        int version = (int) toolUtils.getRequestContent(request,"version",1);
+
+        TiltDevDTO tiltDevDTO = new TiltDevDTO();
+        tiltDevDTO.setSectionList(toolUtils.getSectionList(request));
+
+        TiltDevVO vo = tiltDevService.getTiltData(tiltDevDTO);
+        return toolUtils.response(InterfaceResultEnum.OPERATION_SUCCESS,version,vo);
+    }
+
+    /**
+     * 删除倾斜监测设备
+     * @param request id
+     * @return 操作成功
+     */
+    @RequestMapping(value = "tiltDel", method = RequestMethod.POST)
+    public BaseResult<?> tiltDel(HttpServletRequest request) {
+        int version = (int) toolUtils.getRequestContent(request,"version",1);
+        String id = request.getParameter("id");
+        if (id == null || id.length() == 0) return toolUtils.response(InterfaceResultEnum.LACK_PARAM_ERROR,version);
+        String[] split = id.split(",");
+        for (String tiltId : split) {
+            int l = Integer.parseInt(tiltId);
+            tiltDevService.deleteTiltDevById(l);
+        }
+        return toolUtils.response(InterfaceResultEnum.OPERATION_SUCCESS,version);
+    }
+
+    /**
+     * 编辑倾斜监测设备
+     * @param request 要编辑的监测设备的属性
+     * @return 更新数据
+     */
+    @RequestMapping(value = "tiltSave", method = RequestMethod.POST)
+    public BaseResult<?> tiltSave(HttpServletRequest request) {
+        int version = (int) toolUtils.getRequestContent(request,"version",1);
+        int id = (int) toolUtils.getRequestContent(request,"id",1);
+        if (id == 0) return toolUtils.response(InterfaceResultEnum.PARAM_FAIL,version);
+        int protocolType = (int) toolUtils.getRequestContent(request,"protocolType",1);
+        if (String.valueOf(protocolType).length() == 0) return toolUtils.response(InterfaceResultEnum.LACK_PROTOCOL_TYPE_ERROR,version);
+        String address = request.getParameter("address");
+        if (address == null || address.length() == 0) return toolUtils.response(InterfaceResultEnum.LACK_TILT_ADDRESS_ERROR,version);
+        int port = (int) toolUtils.getRequestContent(request,"port",1);
+        String simNumber = request.getParameter("simNumber");
+        if (protocolType == 2 && (simNumber == null || simNumber.length() == 0)) {
+            return toolUtils.response(InterfaceResultEnum.LACK_SIM_NUMBER_ERROR,version);
+        }
+        String macNumber = request.getParameter("macNumber");
+        if ((protocolType == 1 || protocolType == 2) && (macNumber == null || macNumber.length() == 0)) {
+            return toolUtils.response(InterfaceResultEnum.LACK_MAC_NUMBER_ERROR,version);
+        }
+
+        TiltDevDTO dto = new TiltDevDTO();
+        dto.setId(id);
+        dto.setProtocolType(protocolType);
+        dto.setAddress(address);
+        dto.setPort(port);
+        dto.setSimNumber(simNumber);
+        dto.setMacNumber(macNumber);
+        if (protocolType == 0 || protocolType == 2) {
+            if (tiltDevService.findByTiltDTO(dto) > 0)
+                return toolUtils.response(InterfaceResultEnum.TILT_ADDRESS_UNIQUE_ERROR,version);
+        }
+        tiltDevService.updateTiltDataByDTO(dto);
+        return toolUtils.response(InterfaceResultEnum.OPERATION_SUCCESS,version);
+    }
 }

+ 3 - 3
src/main/java/com/welampiot/dao/SolarInfoLogDao.java

@@ -3,6 +3,8 @@ package com.welampiot.dao;
 import com.welampiot.dto.SolarInfoLogDTO;
 import org.apache.ibatis.annotations.Param;
 
+import java.util.List;
+
 /**
  * ClassName: SolarInfoLogDao
  * Package: com.welampiot.dao
@@ -15,7 +17,5 @@ import org.apache.ibatis.annotations.Param;
 public interface SolarInfoLogDao {
     Integer getTimezoneBySolarId(@Param("id") Integer id);
 
-    SolarInfoLogDTO getMaxSolarInfoLogByDTO(SolarInfoLogDTO dto);
-
-    SolarInfoLogDTO getMinSolarInfoLogByDTO(SolarInfoLogDTO dto);
+    List<SolarInfoLogDTO> getSolarInfoLogByDTO(@Param("id") Integer id);
 }

+ 31 - 0
src/main/java/com/welampiot/dao/TiltDevDao.java

@@ -0,0 +1,31 @@
+package com.welampiot.dao;
+
+import com.welampiot.dto.TiltDevDTO;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+
+/**
+ * ClassName: TiltDevDao
+ * Package: com.welampiot.dao
+ * Description:
+ *
+ * @Author: zhj_Start
+ * @Create: 2023/5/23 - 14:42
+ * @Version: v1.0
+ */
+public interface TiltDevDao {
+    List<TiltDevDTO> getTiltDevByDTO(TiltDevDTO dto);
+
+    Integer getTiltDevTotalByDTO(TiltDevDTO dto);
+
+    Integer getTiltDevOnlineTotalByDTO(TiltDevDTO dto);
+
+    Integer getTiltDevOfflineTotalByDTO(TiltDevDTO dto);
+
+    void deleteTiltDevById(@Param("id") Integer id);
+
+    void updateTiltDataByDTO(TiltDevDTO dto);
+
+    Integer findByTiltDTO(TiltDevDTO dto);
+}

+ 12 - 2
src/main/java/com/welampiot/dto/SolarInfoLogDTO.java

@@ -21,15 +21,25 @@ public class SolarInfoLogDTO implements Serializable {
 
     private String totalLightTime; // 累计亮灯时间
 
+    private String maxTotalLightTime;
+
+    private String minTotalLightTime;
+
     private String logTime; // 更新时间
 
     private String totalConsumption; // 累计用电量
 
+    private String maxTotalConsumption;
+
+    private String minTotalConsumption;
+
     private String totalElectricSave; // 累计省电量
 
-    private String startDate;
+    private String maxTotalEleSave;
+
+    private String minTotalEleSave;
 
-    private String endDate;
+    private String maxTime;
 
     private static final long serialVersionUID = 1L;
 }

+ 64 - 0
src/main/java/com/welampiot/dto/TiltDevDTO.java

@@ -0,0 +1,64 @@
+package com.welampiot.dto;
+
+import lombok.Data;
+
+import java.io.Serializable;
+import java.util.List;
+
+/**
+ * ClassName: TiltDevDTO
+ * Package: com.welampiot.dto
+ * Description:
+ *
+ * @Author: zhj_Start
+ * @Create: 2023/5/23 - 13:45
+ * @Version: v1.0
+ */
+@Data
+public class TiltDevDTO implements Serializable {
+    private Integer id;
+
+    private String address;
+
+    private Integer lampPoleId;
+
+    private String macNumber;
+
+    private String installDate;
+
+    private String expirationDate;
+
+    private String lampPoleName;
+
+    private Integer online;
+
+    private String angle;
+
+    private String angleX;
+
+    private String angleY;
+
+    private String angleZ;
+
+    private Integer protocolType;
+
+    private Integer port;
+
+    private Integer model;
+
+    private String simNumber;
+
+    private String updateTime;
+
+    private Integer timezone;
+
+    private Integer page;
+
+    private Integer count;
+
+    private String keyword;
+
+    private List<Integer> sectionList;
+
+    private static final long serialVersionUID = 1L;
+}

+ 3 - 3
src/main/java/com/welampiot/service/SolarInfoLogService.java

@@ -2,6 +2,8 @@ package com.welampiot.service;
 
 import com.welampiot.dto.SolarInfoLogDTO;
 
+import java.util.List;
+
 /**
  * ClassName: SolarInfoLogService
  * Package: com.welampiot.service
@@ -14,7 +16,5 @@ import com.welampiot.dto.SolarInfoLogDTO;
 public interface SolarInfoLogService {
     Integer getTimezoneBySolarId(Integer id);
 
-    SolarInfoLogDTO getMaxSolarInfoLogByDTO(SolarInfoLogDTO dto);
-
-    SolarInfoLogDTO getMinSolarInfoLogByDTO(SolarInfoLogDTO dto);
+    List<SolarInfoLogDTO> getSolarInfoLogByDTO(Integer id);
 }

+ 25 - 0
src/main/java/com/welampiot/service/TiltDevService.java

@@ -0,0 +1,25 @@
+package com.welampiot.service;
+
+import com.welampiot.dto.TiltDevDTO;
+import com.welampiot.vo.TiltDevVO;
+
+/**
+ * ClassName: TiltDevService
+ * Package: com.welampiot.service
+ * Description:
+ *
+ * @Author: zhj_Start
+ * @Create: 2023/5/23 - 14:43
+ * @Version: v1.0
+ */
+public interface TiltDevService {
+    TiltDevVO getTiltDevByDTO(TiltDevDTO dto);
+
+    TiltDevVO getTiltData(TiltDevDTO dto);
+
+    void deleteTiltDevById(Integer id);
+
+    void updateTiltDataByDTO(TiltDevDTO dto);
+
+    Integer findByTiltDTO(TiltDevDTO dto);
+}

+ 4 - 7
src/main/java/com/welampiot/service/impl/SolarInfoLogServiceImpl.java

@@ -6,6 +6,8 @@ import com.welampiot.service.SolarInfoLogService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import java.util.List;
+
 /**
  * ClassName: SolarInfoLogServiceImpl
  * Package: com.welampiot.service.impl
@@ -26,12 +28,7 @@ public class SolarInfoLogServiceImpl implements SolarInfoLogService {
     }
 
     @Override
-    public SolarInfoLogDTO getMaxSolarInfoLogByDTO(SolarInfoLogDTO dto) {
-        return solarInfoLogDao.getMaxSolarInfoLogByDTO(dto);
-    }
-
-    @Override
-    public SolarInfoLogDTO getMinSolarInfoLogByDTO(SolarInfoLogDTO dto) {
-        return solarInfoLogDao.getMinSolarInfoLogByDTO(dto);
+    public List<SolarInfoLogDTO> getSolarInfoLogByDTO(Integer id) {
+        return solarInfoLogDao.getSolarInfoLogByDTO(id);
     }
 }

+ 115 - 0
src/main/java/com/welampiot/service/impl/TiltDevServiceImpl.java

@@ -0,0 +1,115 @@
+package com.welampiot.service.impl;
+
+import com.welampiot.dao.TiltDevDao;
+import com.welampiot.dto.TiltDevDTO;
+import com.welampiot.service.TiltDevService;
+import com.welampiot.vo.TiltDevVO;
+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: TiltDevServiceImpl
+ * Package: com.welampiot.service.impl
+ * Description:
+ *
+ * @Author: zhj_Start
+ * @Create: 2023/5/23 - 14:43
+ * @Version: v1.0
+ */
+@Service
+public class TiltDevServiceImpl implements TiltDevService {
+    @Autowired
+    private TiltDevDao tiltDevDao;
+
+    @Override
+    public TiltDevVO getTiltDevByDTO(TiltDevDTO dto) {
+        TiltDevVO vo = new TiltDevVO();
+        vo.setTotal(tiltDevDao.getTiltDevTotalByDTO(dto));
+        List<TiltDevDTO> tiltDevByDTO = tiltDevDao.getTiltDevByDTO(dto);
+        List<TiltDevDTO> list = new ArrayList<>();
+        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+        tiltDevByDTO.forEach(tiltDTO -> {
+            if (tiltDTO.getLampPoleName() == null) {
+                tiltDTO.setLampPoleName("");
+            }
+            if (tiltDTO.getOnline() == null) {
+                tiltDTO.setOnline(0);
+            }
+            if (tiltDTO.getAngle() == null || tiltDTO.getAngle().equals("0.0")) {
+                tiltDTO.setAngle("0");
+            }
+            if (tiltDTO.getAngleX() == null || tiltDTO.getAngleX().equals("0.0")) {
+                tiltDTO.setAngleX("0");
+            }
+            if (tiltDTO.getAngleY() == null || tiltDTO.getAngleY().equals("0.0")) {
+                tiltDTO.setAngleY("0");
+            }
+            if (tiltDTO.getAngleZ() == null || tiltDTO.getAngleZ().equals("0.0")) {
+                tiltDTO.setAngleZ("0");
+            }
+            if (tiltDTO.getProtocolType() == null) {
+                tiltDTO.setProtocolType(0);
+            }
+            if (tiltDTO.getPort() == null) {
+                tiltDTO.setPort(0);
+            }
+            if (tiltDTO.getModel() == null) {
+                tiltDTO.setModel(0);
+            }
+            if (tiltDTO.getUpdateTime() != null && !tiltDTO.getUpdateTime().equals("")){
+                Date cmdTime;
+                try {
+                    cmdTime = simpleDateFormat.parse(tiltDTO.getUpdateTime());
+                } catch (ParseException e) {
+                    throw new RuntimeException(e);
+                }
+                //判断时区,为null默认东八区
+                long timezone = tiltDTO.getTimezone() == null ? 8 : tiltDTO.getTimezone();
+                long l = cmdTime.getTime() + timezone * 3600 * 1000;
+                cmdTime = new Date(l);
+                tiltDTO.setUpdateTime(simpleDateFormat.format(cmdTime));
+            }else {
+                tiltDTO.setUpdateTime("");
+            }
+            if (tiltDTO.getMacNumber() == null) {
+                tiltDTO.setMacNumber("");
+            }
+            if (tiltDTO.getSimNumber() == null) {
+                tiltDTO.setSimNumber("");
+            }
+            list.add(tiltDTO);
+        });
+        vo.setList(list);
+        return vo;
+    }
+
+    @Override
+    public TiltDevVO getTiltData(TiltDevDTO dto) {
+        TiltDevVO vo = new TiltDevVO();
+        vo.setTotal(tiltDevDao.getTiltDevTotalByDTO(dto));
+        vo.setOnlineTotal(tiltDevDao.getTiltDevOnlineTotalByDTO(dto));
+        vo.setOfflineTotal(tiltDevDao.getTiltDevOfflineTotalByDTO(dto));
+        return vo;
+    }
+
+    @Override
+    public void deleteTiltDevById(Integer id) {
+        tiltDevDao.deleteTiltDevById(id);
+    }
+
+    @Override
+    public void updateTiltDataByDTO(TiltDevDTO dto) {
+        tiltDevDao.updateTiltDataByDTO(dto);
+    }
+
+    @Override
+    public Integer findByTiltDTO(TiltDevDTO dto) {
+        return tiltDevDao.findByTiltDTO(dto);
+    }
+}

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

@@ -0,0 +1,29 @@
+package com.welampiot.vo;
+
+import com.welampiot.dto.TiltDevDTO;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.util.List;
+
+/**
+ * ClassName: TiltDevVO
+ * Package: com.welampiot.vo
+ * Description:
+ *
+ * @Author: zhj_Start
+ * @Create: 2023/5/23 - 14:44
+ * @Version: v1.0
+ */
+@Data
+public class TiltDevVO implements Serializable {
+    private Integer total;
+
+    private Integer onlineTotal;
+
+    private Integer offlineTotal;
+
+    private List<TiltDevDTO> list;
+
+    private static final long serialVersionUID = 1L;
+}

+ 13 - 41
src/main/resources/mapper/SolarInfoLogMapper.xml

@@ -9,50 +9,22 @@
         where s.id = #{id}
     </select>
 
-    <select id="getMaxSolarInfoLogByDTO" resultType="SolarInfoLogDTO">
+    <select id="getSolarInfoLogByDTO" resultType="SolarInfoLogDTO">
         SELECT
-            s2.logtime AS logTime,
-            s2.totalconsumption AS totalConsumption,
-            s2.totalelesave AS totalElectricSave,
-            s2.totalLightTime AS totalLightTime
+            MAX( s.totalconsumption ) AS maxTotalConsumption,
+            MIN( s.totalconsumption ) AS minTotalConsumption,
+            MAX( s.totalLightTime ) AS maxTotalLightTime,
+            MIN( s.totalLightTime ) AS minTotalLightTime,
+            MAX( s.totalelesave ) AS maxTotalEleSave,
+            MIN( s.totalelesave ) AS minTotalEleSave,
+            DATE( s.logtime ) AS newDate,
+            MAX( s.logtime ) AS maxTime
         FROM
-            solar_info_log s2
+            solar_info_log s
         WHERE
-            s2.logtime = (
-                SELECT MAX( s1.logtime )
-                FROM
-                    (
-                        SELECT *
-                        FROM solar_info_log s
-                        WHERE s.logtime <![CDATA[ >= ]]> #{startDate}
-                          AND s.logtime <![CDATA[ < ]]> #{endDate}
-                          AND s.solar_id = #{solarId}
-                    )
-                AS s1 )
-        ORDER BY s2.logtime DESC
-    </select>
-
-    <select id="getMinSolarInfoLogByDTO" resultType="SolarInfoLogDTO">
-        SELECT
-            s2.logtime AS logTime,
-            s2.totalconsumption AS totalConsumption,
-            s2.totalelesave AS totalElectricSave,
-            s2.totalLightTime AS totalLightTime
-        FROM
-            solar_info_log s2
-        WHERE
-            s2.logtime = (
-            SELECT MIN( s1.logtime )
-            FROM
-                (
-                    SELECT *
-                    FROM solar_info_log s
-                    WHERE s.logtime <![CDATA[ >= ]]> #{startDate}
-                      AND s.logtime <![CDATA[ < ]]> #{endDate}
-                      AND s.solar_id = #{solarId}
-                )
-            AS s1 )
-        ORDER BY s2.logtime DESC
+            s.solar_id = #{id}
+        AND s.logtime >= ( NOW() - INTERVAL 30 DAY )
+        GROUP BY newDate
     </select>
     
 </mapper>

+ 103 - 0
src/main/resources/mapper/TiltDevMapper.xml

@@ -0,0 +1,103 @@
+<?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.TiltDevDao">
+
+    <select id="getTiltDevByDTO" resultType="TiltDevDTO">
+        select t.id,t.address,lp.name as lampPoleName,m.online,m.angle,m.angleX,m.angleY,m.angleZ,
+               m.protocoltype as protocolType,m.port,w.model,m.macNumber,m.simNumber,m.updateTime,s.timezone
+        from tilt_dev t
+        left join lamp_pole lp on lp.id = t.lamp_pole_id
+        left join section s on lp.sectionid = s.id
+        left join wifi w on w.lamp_pole_id = lp.id
+        left join manhole m on t.address = m.address
+        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 t.address like '%${keyword}%'
+        </if>
+        order by t.id desc
+        <if test="page >= 0 and count > 0">
+            limit #{page},#{count}
+        </if>
+    </select>
+
+    <select id="getTiltDevTotalByDTO" resultType="Integer">
+        select count(t.id) as total
+        from tilt_dev t
+        left join lamp_pole lp on lp.id = t.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="getTiltDevOnlineTotalByDTO" resultType="Integer">
+        select count(t.id) as total
+        from tilt_dev t
+        left join manhole m on t.address = m.address
+        left join lamp_pole lp on lp.id = t.lamp_pole_id
+        where m.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="getTiltDevOfflineTotalByDTO" resultType="Integer">
+        select count(t.id) as total
+        from tilt_dev t
+        left join manhole m on t.address = m.address
+        left join lamp_pole lp on lp.id = t.lamp_pole_id
+        where m.online = 0
+        <if test="sectionList != null and !sectionList.isEmpty()">
+            and lp.sectionid in
+            <foreach collection="sectionList" item="dto" open="(" separator="," close=")">
+                #{dto}
+            </foreach>
+        </if>
+    </select>
+
+    <delete id="deleteTiltDevById">
+        delete
+        from tilt_dev
+        where id = #{id}
+    </delete>
+
+    <update id="updateTiltDataByDTO" parameterType="com.welampiot.dto.TiltDevDTO">
+        update tilt_dev t
+        left join manhole m on t.address = m.address
+        set
+            t.address = #{address},
+            m.protocoltype = #{protocolType},
+            <if test="simNumber != null and simNumber != ''">
+                m.simNumber = #{simNumber},
+            </if>
+            <if test="macNumber != null and macNumber != ''">
+                m.macNumber = #{macNumber},
+            </if>
+            m.port = #{port}
+        where t.id = #{id}
+    </update>
+
+    <select id="findByTiltDTO" resultType="Integer">
+        select count(*)
+        from tilt_dev t
+        where 1=1
+        <if test="address != null">
+            and t.address = #{address}
+        </if>
+        <if test="id != null">
+            and t.id != #{id}
+        </if>
+    </select>
+    
+</mapper>