Переглянути джерело

太阳能控制器列表和统计信息

zhj 2 роки тому
батько
коміт
635e4d57cf

+ 117 - 2
src/main/java/com/welampiot/controller/LampController.java

@@ -2,7 +2,6 @@ package com.welampiot.controller;
 
 import com.welampiot.common.BaseResult;
 import com.welampiot.common.InterfaceResultEnum;
-import com.welampiot.common.ResultEnum;
 import com.welampiot.dto.*;
 import com.welampiot.service.*;
 import com.welampiot.utils.ToolUtils;
@@ -16,9 +15,10 @@ import org.springframework.web.bind.annotation.RequestMethod;
 import org.springframework.web.bind.annotation.RestController;
 
 import javax.servlet.http.HttpServletRequest;
+import java.text.DecimalFormat;
+import java.text.ParseException;
 import java.text.SimpleDateFormat;
 import java.util.ArrayList;
-import java.util.Calendar;
 import java.util.Date;
 import java.util.List;
 
@@ -38,6 +38,13 @@ public class LampController {
     private GlobalLocationService globalLocationService;
     @Autowired
     private SectionService sectionService;
+
+    @Autowired
+    private SolarDevService solarDevService;
+
+    @Autowired
+    private SolarInfoLogService solarInfoLogService;
+
     /**
      * 灯控列表
      * @param request
@@ -357,4 +364,112 @@ public class LampController {
         return toolUtils.response(InterfaceResultEnum.OPERATION_SUCCESS,version,lampInfoDTO);
     }
 
+    /**
+     * 获取太阳能控制器设备列表
+     * @param request 根据sectionId进行筛选
+     * @return 返回设备列表
+     */
+    @RequestMapping(value = "/getSolarList", method = RequestMethod.POST)
+    public BaseResult<?> getSolarList(HttpServletRequest request) {
+        int version = (int) toolUtils.getRequestContent(request,"version",1);
+        int online = (int) toolUtils.getRequestContent(request,"online",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,"online",2);
+
+        SolarDevDTO dto = new SolarDevDTO();
+        dto.setPage(count * (page - 1));
+        dto.setCount(count);
+        dto.setVersion(version);
+        dto.setOnline(online);
+        dto.setKeyword(keyword);
+        dto.setSectionList(toolUtils.getSectionList(request));
+
+        SolarDevVO solarDevVO = solarDevService.getSolarListByDTO(dto);
+        return toolUtils.response(InterfaceResultEnum.OPERATION_SUCCESS,version,solarDevVO);
+    }
+
+    /**
+     * 获取太阳能统计数据
+     * @param request 设备id
+     * @return 返回太阳能统计数据
+     */
+    @RequestMapping(value = "/solarStatistics", method = RequestMethod.POST)
+    public BaseResult<?> solarStatistics(HttpServletRequest request) throws ParseException {
+        int version = (int) toolUtils.getRequestContent(request,"version",1);
+        int id = (int) toolUtils.getRequestContent(request,"id",1);
+        if (id == 0) return toolUtils.response(InterfaceResultEnum.LACK_PARAM_ERROR,version);
+        Integer timezone = solarInfoLogService.getTimezoneBySolarId(id);
+        if (timezone == null) return toolUtils.response(InterfaceResultEnum.PARAM_FAIL,version);
+        long l = System.currentTimeMillis() - timezone * 3600 * 1000;
+        long startTime;
+        long endTime;
+        startTime = l - 24L * 3600 * 1000 * 29;
+        endTime = l;
+
+        long timeT = startTime;
+        int i = 0;
+
+        List<Object> dateList = new ArrayList<>();
+        List<Object> lightTimeList = new ArrayList<>();
+        List<Object> comList = new ArrayList<>();
+        List<Object> eleList = new ArrayList<>();
+        List<Object> totalLightTime = new ArrayList<>();
+        List<Object> totalCom = new ArrayList<>();
+        List<Object> totalEle = new ArrayList<>();
+        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
+        while (timeT <= endTime) {
+            dateList.add(simpleDateFormat.format(new Date(timeT + timezone * 3600 * 1000)));
+            lightTimeList.add(0);
+            eleList.add(0);
+            comList.add(0);
+            totalLightTime.add(0);
+            totalCom.add(0);
+            totalEle.add(0);
+            timeT += 3600 * 1000 * 24;
+            i ++;
+        }
+
+        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);
+                }
+                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 (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)));
+                }
+            }
+            timeT += 3600 * 1000 * 24;
+            i ++;
+        }
+
+        SolarInfoLogVO solarInfoLogVO = new SolarInfoLogVO();
+        solarInfoLogVO.setDateList(dateList);
+        solarInfoLogVO.setLightTimeList(lightTimeList);
+        solarInfoLogVO.setComList(comList);
+        solarInfoLogVO.setEleList(eleList);
+        solarInfoLogVO.setTotalLightTime(totalLightTime);
+        solarInfoLogVO.setTotalCom(totalCom);
+        solarInfoLogVO.setTotalEle(totalEle);
+        return toolUtils.response(InterfaceResultEnum.OPERATION_SUCCESS,version,solarInfoLogVO);
+    }
 }

+ 28 - 0
src/main/java/com/welampiot/dao/SolarDevDao.java

@@ -0,0 +1,28 @@
+package com.welampiot.dao;
+
+import com.welampiot.dto.SolarDevDTO;
+
+import java.util.List;
+
+/**
+ * ClassName: SolarDevDao
+ * Package: com.welampiot.dao
+ * Description:
+ *
+ * @Author: zhj_Start
+ * @Create: 2023/5/19 - 14:17
+ * @Version: v1.0
+ */
+public interface SolarDevDao {
+    List<SolarDevDTO> getSolarListByDTO(SolarDevDTO dto);
+
+    Integer getSolarDevTotalByDTO(SolarDevDTO dto);
+
+    Integer getSolarDevOnlineTotalByDTO(SolarDevDTO dto);
+
+    Integer getSolarDevLightTotalByDTO(SolarDevDTO dto);
+
+    List<SolarDevDTO> getSolarDevDayElectricTotalByDTO(SolarDevDTO dto);
+
+    List<SolarDevDTO> getSolarDevSumElectricTotalByDTO(SolarDevDTO dto);
+}

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

@@ -0,0 +1,21 @@
+package com.welampiot.dao;
+
+import com.welampiot.dto.SolarInfoLogDTO;
+import org.apache.ibatis.annotations.Param;
+
+/**
+ * ClassName: SolarInfoLogDao
+ * Package: com.welampiot.dao
+ * Description:
+ *
+ * @Author: zhj_Start
+ * @Create: 2023/5/19 - 17:46
+ * @Version: v1.0
+ */
+public interface SolarInfoLogDao {
+    Integer getTimezoneBySolarId(@Param("id") Integer id);
+
+    SolarInfoLogDTO getMaxSolarInfoLogByDTO(SolarInfoLogDTO dto);
+
+    SolarInfoLogDTO getMinSolarInfoLogByDTO(SolarInfoLogDTO dto);
+}

+ 127 - 0
src/main/java/com/welampiot/dto/SolarDevDTO.java

@@ -0,0 +1,127 @@
+package com.welampiot.dto;
+
+import lombok.Data;
+
+import java.io.Serializable;
+import java.util.List;
+
+/**
+ * ClassName: SolarDevDTO
+ * Package: com.welampiot.dto
+ * Description:
+ *
+ * @Author: zhj_Start
+ * @Create: 2023/5/19 - 11:28
+ * @Version: v1.0
+ */
+@Data
+public class SolarDevDTO implements Serializable {
+    /** 主键 **/
+    private Integer id;
+
+    /** 区、县id **/
+    private Integer areaId;
+
+    /** 路段id **/
+    private Integer sectionId;
+
+    /** 设备编号 **/
+    private String number;
+
+    /** 灯杆id **/
+    private Integer lampPoleId;
+
+    /** 额定功率 **/
+    private String ratedPower;
+
+    /** 创建时间 **/
+    private String createTime;
+
+    /** 设备地址 **/
+    private String address;
+
+    /** 网络状态(0 离线,1 在线) **/
+    private Integer netStatus;
+
+    /** 亮度值 **/
+    private Integer lightness;
+
+    /** 路灯电压 **/
+    private String lampVoltage;
+
+    /** 路灯电流 **/
+    private String lampCurrent;
+
+    /** 路灯功率 **/
+    private String lampPower;
+
+    /** 累计亮灯时间 **/
+    private Integer totalLightTime;
+
+    /** 日志更新时间 **/
+    private String logTime;
+
+    /** 当天用电量 **/
+    private String dayConsumption;
+
+    /** 累积用电量 **/
+    private String totalConsumption;
+
+    /** 累积省电量 **/
+    private String totalEleSave;
+
+    /** 太阳能板电压 **/
+    private String solarVoltage;
+
+    /** 太阳能板电流 **/
+    private String solarCurrent;
+
+    /** 太阳能板功率 **/
+    private String solarPower;
+
+    /** 蓄电池电压 **/
+    private String batteryVoltage;
+
+    /** 蓄电池电流 **/
+    private String batteryCurrent;
+
+    /** 蓄电池功率 **/
+    private String batteryPower;
+
+    /** 串口(0 3号串口,1 2号串口,2 1号串口) **/
+    private Integer serialPort;
+
+    /** 设备型号(0 太阳能mqtt,1 MPPT(ML2420-C))**/
+    private Integer type;
+
+    /** 设备名称 **/
+    private String name;
+
+    /** 安装时间 **/
+    private String installDate;
+
+    /** 过期时间 **/
+    private String expirationDate;
+
+    private Integer timezone;
+
+    private String section;
+
+    private String area;
+
+    private String lampPoleName;
+
+    private Integer version;
+
+    private Integer page;
+
+    private Integer count;
+
+    private String keyword;
+
+    private Integer online;
+
+    private List<Integer> sectionList;
+
+    private static final long serialVersionUID = 1L;
+}

+ 35 - 0
src/main/java/com/welampiot/dto/SolarInfoLogDTO.java

@@ -0,0 +1,35 @@
+package com.welampiot.dto;
+
+import lombok.Data;
+
+import java.io.Serializable;
+
+/**
+ * ClassName: SolarInfoLogDTO
+ * Package: com.welampiot.dto
+ * Description:
+ *
+ * @Author: zhj_Start
+ * @Create: 2023/5/19 - 16:52
+ * @Version: v1.0
+ */
+@Data
+public class SolarInfoLogDTO implements Serializable {
+    private Integer id;
+
+    private Integer solarId;
+
+    private String totalLightTime; // 累计亮灯时间
+
+    private String logTime; // 更新时间
+
+    private String totalConsumption; // 累计用电量
+
+    private String totalElectricSave; // 累计省电量
+
+    private String startDate;
+
+    private String endDate;
+
+    private static final long serialVersionUID = 1L;
+}

+ 17 - 0
src/main/java/com/welampiot/service/SolarDevService.java

@@ -0,0 +1,17 @@
+package com.welampiot.service;
+
+import com.welampiot.dto.SolarDevDTO;
+import com.welampiot.vo.SolarDevVO;
+
+/**
+ * ClassName: SolarDevService
+ * Package: com.welampiot.service
+ * Description:
+ *
+ * @Author: zhj_Start
+ * @Create: 2023/5/19 - 14:42
+ * @Version: v1.0
+ */
+public interface SolarDevService {
+    SolarDevVO getSolarListByDTO(SolarDevDTO dto);
+}

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

@@ -0,0 +1,20 @@
+package com.welampiot.service;
+
+import com.welampiot.dto.SolarInfoLogDTO;
+
+/**
+ * ClassName: SolarInfoLogService
+ * Package: com.welampiot.service
+ * Description:
+ *
+ * @Author: zhj_Start
+ * @Create: 2023/5/20 - 9:15
+ * @Version: v1.0
+ */
+public interface SolarInfoLogService {
+    Integer getTimezoneBySolarId(Integer id);
+
+    SolarInfoLogDTO getMaxSolarInfoLogByDTO(SolarInfoLogDTO dto);
+
+    SolarInfoLogDTO getMinSolarInfoLogByDTO(SolarInfoLogDTO dto);
+}

+ 107 - 0
src/main/java/com/welampiot/service/impl/SolarDevServiceImpl.java

@@ -0,0 +1,107 @@
+package com.welampiot.service.impl;
+
+import com.welampiot.dao.SolarDevDao;
+import com.welampiot.dto.SolarDevDTO;
+import com.welampiot.service.SolarDevService;
+import com.welampiot.vo.SolarDevVO;
+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: SolarDevServiceImpl
+ * Package: com.welampiot.service.impl
+ * Description:
+ *
+ * @Author: zhj_Start
+ * @Create: 2023/5/19 - 14:43
+ * @Version: v1.0
+ */
+@Service
+public class SolarDevServiceImpl implements SolarDevService {
+    @Autowired
+    private SolarDevDao solarDevDao;
+
+    @Override
+    public SolarDevVO getSolarListByDTO(SolarDevDTO dto) {
+        SolarDevVO vo = new SolarDevVO();
+        vo.setTotal(solarDevDao.getSolarDevTotalByDTO(dto));
+        vo.setOnlineCount(solarDevDao.getSolarDevOnlineTotalByDTO(dto));
+        vo.setLightCount(solarDevDao.getSolarDevLightTotalByDTO(dto));
+        Double dayCom = solarDevDao.getSolarDevDayElectricTotalByDTO(dto).stream()
+                     .mapToDouble(solarDevDTO -> Double.parseDouble(solarDevDTO.getDayConsumption())).sum();
+        vo.setDayCom(dayCom);
+        Double totalCom = solarDevDao.getSolarDevSumElectricTotalByDTO(dto).stream()
+                     .mapToDouble(solarDevDTO -> Double.parseDouble(solarDevDTO.getTotalConsumption())).sum();
+        vo.setTotalCom(totalCom);
+        List<SolarDevDTO> solarListByDTO = solarDevDao.getSolarListByDTO(dto);
+        List<SolarDevDTO> list = new ArrayList<>();
+        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+        solarListByDTO.forEach(solarDTO -> {
+            if (solarDTO.getLampPoleName() == null) {
+                solarDTO.setLampPoleName("");
+            }
+            if (solarDTO.getSection() == null) {
+                solarDTO.setSection("");
+            }
+            if (solarDTO.getArea() == null) {
+                solarDTO.setArea("");
+            }
+            if (solarDTO.getNetStatus() != null && solarDTO.getNetStatus() == 1) {
+                solarDTO.setNetStatus(1);
+            } else {
+                solarDTO.setNetStatus(0);
+            }
+            if (solarDTO.getLogTime() != null && !solarDTO.getLogTime().equals("")){
+                Date cmdTime;
+                try {
+                    cmdTime = simpleDateFormat.parse(solarDTO.getLogTime());
+                } catch (ParseException e) {
+                    throw new RuntimeException(e);
+                }
+                //判断时区,为null默认东八区
+                long timezone = solarDTO.getTimezone() == null ? 8 : solarDTO.getTimezone();
+                long l = cmdTime.getTime() + timezone * 3600 * 1000;
+                cmdTime = new Date(l);
+                solarDTO.setLogTime(simpleDateFormat.format(cmdTime));
+            }else {
+                solarDTO.setLogTime("");
+            }
+            if (solarDTO.getBatteryCurrent() == null || solarDTO.getBatteryCurrent().equals("0.0")) {
+                solarDTO.setBatteryCurrent("0");
+            }
+            if (solarDTO.getBatteryVoltage() == null || solarDTO.getBatteryVoltage().equals("0.0")) {
+                solarDTO.setBatteryVoltage("0");
+            }
+            if (solarDTO.getBatteryPower() == null || solarDTO.getBatteryPower().equals("0.0")) {
+                solarDTO.setBatteryPower("0");
+            }
+            if (solarDTO.getSolarCurrent() == null || solarDTO.getSolarCurrent().equals("0.0")) {
+                solarDTO.setSolarCurrent("0");
+            }
+            if (solarDTO.getSolarVoltage() == null || solarDTO.getSolarVoltage().equals("0.0")) {
+                solarDTO.setSolarVoltage("0");
+            }
+            if (solarDTO.getSolarPower() == null || solarDTO.getSolarPower().equals("0.0")) {
+                solarDTO.setSolarPower("0");
+            }
+            if (solarDTO.getLampCurrent() == null || solarDTO.getLampCurrent().equals("0.0")) {
+                solarDTO.setLampCurrent("0");
+            }
+            if (solarDTO.getLampVoltage() == null || solarDTO.getLampVoltage().equals("0.0")) {
+                solarDTO.setLampVoltage("0");
+            }
+            if (solarDTO.getLampPower() == null || solarDTO.getLampPower().equals("0.0")) {
+                solarDTO.setLampPower("0");
+            }
+            list.add(solarDTO);
+        });
+        vo.setList(list);
+        return vo;
+    }
+}

+ 37 - 0
src/main/java/com/welampiot/service/impl/SolarInfoLogServiceImpl.java

@@ -0,0 +1,37 @@
+package com.welampiot.service.impl;
+
+import com.welampiot.dao.SolarInfoLogDao;
+import com.welampiot.dto.SolarInfoLogDTO;
+import com.welampiot.service.SolarInfoLogService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+/**
+ * ClassName: SolarInfoLogServiceImpl
+ * Package: com.welampiot.service.impl
+ * Description:
+ *
+ * @Author: zhj_Start
+ * @Create: 2023/5/20 - 9:16
+ * @Version: v1.0
+ */
+@Service
+public class SolarInfoLogServiceImpl implements SolarInfoLogService {
+    @Autowired
+    private SolarInfoLogDao solarInfoLogDao;
+
+    @Override
+    public Integer getTimezoneBySolarId(Integer id) {
+        return solarInfoLogDao.getTimezoneBySolarId(id);
+    }
+
+    @Override
+    public SolarInfoLogDTO getMaxSolarInfoLogByDTO(SolarInfoLogDTO dto) {
+        return solarInfoLogDao.getMaxSolarInfoLogByDTO(dto);
+    }
+
+    @Override
+    public SolarInfoLogDTO getMinSolarInfoLogByDTO(SolarInfoLogDTO dto) {
+        return solarInfoLogDao.getMinSolarInfoLogByDTO(dto);
+    }
+}

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

@@ -0,0 +1,33 @@
+package com.welampiot.vo;
+
+import com.welampiot.dto.SolarDevDTO;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.util.List;
+
+/**
+ * ClassName: SolarDevVO
+ * Package: com.welampiot.vo
+ * Description:
+ *
+ * @Author: zhj_Start
+ * @Create: 2023/5/19 - 14:43
+ * @Version: v1.0
+ */
+@Data
+public class SolarDevVO implements Serializable {
+    private Integer total;
+
+    private Integer onlineCount;
+
+    private Integer lightCount;
+
+    private Double dayCom;
+
+    private Double totalCom;
+
+    private List<SolarDevDTO> list;
+
+    private static final long serialVersionUID = 1L;
+}

+ 35 - 0
src/main/java/com/welampiot/vo/SolarInfoLogVO.java

@@ -0,0 +1,35 @@
+package com.welampiot.vo;
+
+import lombok.Data;
+
+import java.io.Serializable;
+import java.util.List;
+
+/**
+ * ClassName: SolarInfoLogVO
+ * Package: com.welampiot.vo
+ * Description:
+ *
+ * @Author: zhj_Start
+ * @Create: 2023/5/20 - 9:18
+ * @Version: v1.0
+ */
+@Data
+public class SolarInfoLogVO implements Serializable {
+
+    private List<Object> dateList; // 日期列表
+
+    private List<Object> lightTimeList; // 当天亮灯时间列表
+
+    private List<Object> comList; //当天用电量列表
+
+    private List<Object> eleList; // 当天省电量列表
+
+    private List<Object> totalLightTime; // 累计亮灯时间列表
+
+    private List<Object> totalCom; // 累计用电量列表
+
+    private List<Object> totalEle; // 累计省电量列表
+
+    private static final long serialVersionUID = 1L;
+}

+ 107 - 0
src/main/resources/mapper/SolarDevMapper.xml

@@ -0,0 +1,107 @@
+<?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.SolarDevDao">
+    
+    <select id="getSolarListByDTO" resultType="SolarDevDTO">
+        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>
+            s.id,s.lamp_pole_id lampPoleId,s.number,s.netStatus,s.lighteness as lightness,s.lampvoltage as lampVoltage,
+            s.lampcurrent as lampCurrent,s.lamppower as lampPower,s.solar_voltage solarVoltage,s.solar_current solarCurrent,
+            s.solar_power solarPower,s.battery_voltage batteryVoltage,s.battery_current batteryCurrent,s.battery_power batteryPower,
+            s.totalLightTime,s.address,s.logtime as logTime,s1.name as section,s1.timezone,lp.name as lampPoleName
+        from solar_dev s
+        left join section s1 on s.sectionid = s1.id
+        left join global_location gl on s1.pid = gl.id
+        left join lamp_pole lp on lp.id = s.lamp_pole_id
+        where 1=1
+        <if test="keyword != null and keyword != ''">
+            and s.number like '%${keyword}%'
+        </if>
+        <if test="sectionList != null and !sectionList.isEmpty()">
+            and s.sectionid in
+            <foreach collection="sectionList" item="dto" open="(" separator="," close=")">
+                #{dto}
+            </foreach>
+        </if>
+        <choose>
+            <when test="online == 0">
+                and s.netStatus = 0
+            </when>
+            <when test="online == 1">
+                and s.netStatus = 1
+            </when>
+        </choose>
+        order by s.id desc
+        <if test="page >= 0 and count > 0">
+            limit #{page},#{count}
+        </if>
+    </select>
+
+    <select id="getSolarDevTotalByDTO" resultType="Integer">
+        select count(s.id)
+        from solar_dev s
+        <if test="sectionList != null and !sectionList.isEmpty()">
+            where s.sectionid in
+            <foreach collection="sectionList" item="dto" open="(" separator="," close=")">
+                #{dto}
+            </foreach>
+        </if>
+    </select>
+
+    <select id="getSolarDevOnlineTotalByDTO" resultType="Integer">
+        select count(s.id)
+        from solar_dev s
+        where s.netStatus = 1
+        <if test="sectionList != null and !sectionList.isEmpty()">
+            and s.sectionid in
+            <foreach collection="sectionList" item="dto" open="(" separator="," close=")">
+                #{dto}
+            </foreach>
+        </if>
+    </select>
+
+    <select id="getSolarDevLightTotalByDTO" resultType="Integer">
+        select count(s.id)
+        from solar_dev s
+        where s.netStatus = 1 and s.lighteness > 0
+        <if test="sectionList != null and !sectionList.isEmpty()">
+            and s.sectionid in
+            <foreach collection="sectionList" item="dto" open="(" separator="," close=")">
+                #{dto}
+            </foreach>
+        </if>
+    </select>
+
+    <select id="getSolarDevDayElectricTotalByDTO" resultType="SolarDevDTO">
+        select s.id,s.dayconsumption as dayConsumption
+        from solar_dev s
+        <if test="sectionList != null and !sectionList.isEmpty()">
+            where s.sectionid in
+            <foreach collection="sectionList" item="dto" open="(" separator="," close=")">
+                #{dto}
+            </foreach>
+        </if>
+    </select>
+
+    <select id="getSolarDevSumElectricTotalByDTO" resultType="SolarDevDTO">
+        select s.id,s.totalconsumption as totalConsumption
+        from solar_dev s
+        <if test="sectionList != null and !sectionList.isEmpty()">
+            where s.sectionid in
+            <foreach collection="sectionList" item="dto" open="(" separator="," close=")">
+                #{dto}
+            </foreach>
+        </if>
+    </select>
+
+</mapper>

+ 58 - 0
src/main/resources/mapper/SolarInfoLogMapper.xml

@@ -0,0 +1,58 @@
+<?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.SolarInfoLogDao">
+
+    <select id="getTimezoneBySolarId" resultType="Integer">
+        select s1.timezone
+        from solar_dev s
+        left join section s1 on s.sectionid = s1.id
+        where s.id = #{id}
+    </select>
+
+    <select id="getMaxSolarInfoLogByDTO" 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 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
+    </select>
+    
+</mapper>