|
@@ -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);
|
|
|
+ }
|
|
|
}
|