|
@@ -3,8 +3,11 @@ package com.welampiot.controller;
|
|
|
import com.welampiot.common.BaseResult;
|
|
|
import com.welampiot.common.InterfaceResultEnum;
|
|
|
import com.welampiot.dto.SuperPowerDevInfoDTO;
|
|
|
+import com.welampiot.dto.SuperPowerDevInfoLogDTO;
|
|
|
+import com.welampiot.service.SuperPowerDevInfoLogService;
|
|
|
import com.welampiot.service.SuperPowerDevInfoService;
|
|
|
import com.welampiot.utils.ToolUtils;
|
|
|
+import com.welampiot.vo.SuperPowerDevInfoLogVO;
|
|
|
import com.welampiot.vo.SuperPowerDevInfoVO;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.web.bind.annotation.CrossOrigin;
|
|
@@ -13,6 +16,9 @@ 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: SuperPowerController
|
|
@@ -30,6 +36,9 @@ public class SuperPowerController {
|
|
|
@Autowired
|
|
|
private SuperPowerDevInfoService superPowerDevInfoService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private SuperPowerDevInfoLogService superPowerDevInfoLogService;
|
|
|
+
|
|
|
@Autowired
|
|
|
private ToolUtils toolUtils;
|
|
|
|
|
@@ -87,4 +96,237 @@ public class SuperPowerController {
|
|
|
if (vo == null) return toolUtils.response(InterfaceResultEnum.PARAM_FAIL,version);
|
|
|
return BaseResult.success(vo);
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取超级电源输出统计数据
|
|
|
+ * @param request
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "powerOutStatistics", method = RequestMethod.POST)
|
|
|
+ public BaseResult powerOutStatistics(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 dateType = (Integer) toolUtils.getRequestContent(request,"dateType",1);
|
|
|
+ Integer dataType = (Integer) toolUtils.getRequestContent(request,"dataType",1);
|
|
|
+ Integer timezone = superPowerDevInfoLogService.getTimezoneById(id);
|
|
|
+ if (timezone == null) return toolUtils.response(InterfaceResultEnum.PARAM_FAIL,version);
|
|
|
+ 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("/"));
|
|
|
+ System.out.println(split);
|
|
|
+ System.out.println(split.get(0));
|
|
|
+ System.out.println(split.get(1));
|
|
|
+ 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;
|
|
|
+
|
|
|
+ List<Object> dateList = new ArrayList<>();
|
|
|
+ List<Object> volList = new ArrayList<>();
|
|
|
+ List<Object> curList = new ArrayList<>();
|
|
|
+ List<Object> powerList = new ArrayList<>();
|
|
|
+ List<Object> dayElectricList = new ArrayList<>();
|
|
|
+ List<Object> totalElectricList = new ArrayList<>();
|
|
|
+ ArrayList<SuperPowerDevInfoLogDTO> 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)));
|
|
|
+ volList.add(0);
|
|
|
+ curList.add(0);
|
|
|
+ powerList.add(0);
|
|
|
+ dayElectricList.add(0);
|
|
|
+ totalElectricList.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));
|
|
|
+ SuperPowerDevInfoLogDTO dto = new SuperPowerDevInfoLogDTO();
|
|
|
+ dto.setSuperPowerId(id);
|
|
|
+ dto.setStartDate(startDate);
|
|
|
+ dto.setEndDate(endDate);
|
|
|
+ dto.setDataType(dataType);
|
|
|
+ List<SuperPowerDevInfoLogDTO> powerOutStatistics = superPowerDevInfoLogService.getPowerOutStatistics(dto);
|
|
|
+ for (SuperPowerDevInfoLogDTO superPowerDevInfoLogDTO : powerOutStatistics){
|
|
|
+ Date date = new Date(simpleDateFormat2.parse(superPowerDevInfoLogDTO.getUpdateTime()).getTime());
|
|
|
+ String s = simpleDateFormat.format(date);
|
|
|
+ if (objectObjectHashMap.containsKey(s)){
|
|
|
+ Integer integer = objectObjectHashMap.get(s);
|
|
|
+ list.set(integer,superPowerDevInfoLogDTO);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ for (SuperPowerDevInfoLogDTO superPowerDevInfoLogDTO:list) {
|
|
|
+ if (superPowerDevInfoLogDTO != null) {
|
|
|
+ Date date = new Date(simpleDateFormat2.parse(superPowerDevInfoLogDTO.getUpdateTime()).getTime());
|
|
|
+ String s = simpleDateFormat.format(date);
|
|
|
+ Integer integer = null;
|
|
|
+ if (objectObjectHashMap.containsKey(s)) {
|
|
|
+ integer = objectObjectHashMap.get(s);
|
|
|
+ list.set(integer, superPowerDevInfoLogDTO);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (dto.getDataType() != null){
|
|
|
+ switch (dto.getDataType()){
|
|
|
+ case 0 :
|
|
|
+ if (superPowerDevInfoLogDTO.getRemark1Cur() != null && !superPowerDevInfoLogDTO.getRemark1Cur().equals("0") && integer != null){
|
|
|
+ curList.set(integer,Float.valueOf(superPowerDevInfoLogDTO.getRemark1Cur()));
|
|
|
+ }
|
|
|
+ if (superPowerDevInfoLogDTO.getRemark1Power() != null && !superPowerDevInfoLogDTO.getRemark1Power().equals("0") && integer != null){
|
|
|
+ powerList.set(integer,Float.valueOf(superPowerDevInfoLogDTO.getRemark1Power()));
|
|
|
+ }
|
|
|
+ if (superPowerDevInfoLogDTO.getRemark1DayElectric() != null && !superPowerDevInfoLogDTO.getRemark1DayElectric().equals("0") && integer != null){
|
|
|
+ dayElectricList.set(integer,Float.valueOf(superPowerDevInfoLogDTO.getRemark1DayElectric()));
|
|
|
+ }
|
|
|
+ if (superPowerDevInfoLogDTO.getRemark1TotalElectric() != null && !superPowerDevInfoLogDTO.getRemark1TotalElectric().equals("0") && integer != null){
|
|
|
+ totalElectricList.set(integer,Float.valueOf(superPowerDevInfoLogDTO.getRemark1TotalElectric()));
|
|
|
+ }
|
|
|
+ if (superPowerDevInfoLogDTO.getVol() != null && !superPowerDevInfoLogDTO.getVol().equals("0") && integer != null){
|
|
|
+ volList.set(integer,Float.valueOf(superPowerDevInfoLogDTO.getVol()));
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case 1 :
|
|
|
+ if (superPowerDevInfoLogDTO.getRemark2Cur() != null && !superPowerDevInfoLogDTO.getRemark2Cur().equals("0") && integer != null){
|
|
|
+ curList.set(integer,Float.valueOf(superPowerDevInfoLogDTO.getRemark2Cur()));
|
|
|
+ }
|
|
|
+ if (superPowerDevInfoLogDTO.getRemark2Power() != null && !superPowerDevInfoLogDTO.getRemark2Power().equals("0") && integer != null){
|
|
|
+ powerList.set(integer,Float.valueOf(superPowerDevInfoLogDTO.getRemark2Power()));
|
|
|
+ }
|
|
|
+ if (superPowerDevInfoLogDTO.getRemark2DayElectric() != null && !superPowerDevInfoLogDTO.getRemark2DayElectric().equals("0") && integer != null){
|
|
|
+ dayElectricList.set(integer,Float.valueOf(superPowerDevInfoLogDTO.getRemark2DayElectric()));
|
|
|
+ }
|
|
|
+ if (superPowerDevInfoLogDTO.getRemark2TotalElectric() != null && !superPowerDevInfoLogDTO.getRemark2TotalElectric().equals("0") && integer != null){
|
|
|
+ totalElectricList.set(integer,Float.valueOf(superPowerDevInfoLogDTO.getRemark2TotalElectric()));
|
|
|
+ }
|
|
|
+ if (superPowerDevInfoLogDTO.getVol() != null && !superPowerDevInfoLogDTO.getVol().equals("0") && integer != null){
|
|
|
+ volList.set(integer,Float.valueOf(superPowerDevInfoLogDTO.getVol()));
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case 2 :
|
|
|
+ if (superPowerDevInfoLogDTO.getRemark3Cur() != null && !superPowerDevInfoLogDTO.getRemark3Cur().equals("0") && integer != null){
|
|
|
+ curList.set(integer,Float.valueOf(superPowerDevInfoLogDTO.getRemark3Cur()));
|
|
|
+ }
|
|
|
+ if (superPowerDevInfoLogDTO.getRemark3Power() != null && !superPowerDevInfoLogDTO.getRemark3Power().equals("0") && integer != null){
|
|
|
+ powerList.set(integer,Float.valueOf(superPowerDevInfoLogDTO.getRemark3Power()));
|
|
|
+ }
|
|
|
+ if (superPowerDevInfoLogDTO.getRemark3DayElectric() != null && !superPowerDevInfoLogDTO.getRemark3DayElectric().equals("0") && integer != null){
|
|
|
+ dayElectricList.set(integer,Float.valueOf(superPowerDevInfoLogDTO.getRemark3DayElectric()));
|
|
|
+ }
|
|
|
+ if (superPowerDevInfoLogDTO.getRemark3TotalElectric() != null && !superPowerDevInfoLogDTO.getRemark3TotalElectric().equals("0") && integer != null){
|
|
|
+ totalElectricList.set(integer,Float.valueOf(superPowerDevInfoLogDTO.getRemark3TotalElectric()));
|
|
|
+ }
|
|
|
+ if (superPowerDevInfoLogDTO.getVol() != null && !superPowerDevInfoLogDTO.getVol().equals("0") && integer != null){
|
|
|
+ volList.set(integer,Float.valueOf(superPowerDevInfoLogDTO.getVol()));
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case 3 :
|
|
|
+ if (superPowerDevInfoLogDTO.getRemark4Cur() != null && !superPowerDevInfoLogDTO.getRemark4Cur().equals("0") && integer != null){
|
|
|
+ curList.set(integer,Float.valueOf(superPowerDevInfoLogDTO.getRemark4Cur()));
|
|
|
+ }
|
|
|
+ if (superPowerDevInfoLogDTO.getRemark4Power() != null && !superPowerDevInfoLogDTO.getRemark4Power().equals("0") && integer != null){
|
|
|
+ powerList.set(integer,Float.valueOf(superPowerDevInfoLogDTO.getRemark4Power()));
|
|
|
+ }
|
|
|
+ if (superPowerDevInfoLogDTO.getRemark4DayElectric() != null && !superPowerDevInfoLogDTO.getRemark4DayElectric().equals("0") && integer != null){
|
|
|
+ dayElectricList.set(integer,Float.valueOf(superPowerDevInfoLogDTO.getRemark4DayElectric()));
|
|
|
+ }
|
|
|
+ if (superPowerDevInfoLogDTO.getRemark4TotalElectric() != null && !superPowerDevInfoLogDTO.getRemark4TotalElectric().equals("0") && integer != null){
|
|
|
+ totalElectricList.set(integer,Float.valueOf(superPowerDevInfoLogDTO.getRemark4TotalElectric()));
|
|
|
+ }
|
|
|
+ if (superPowerDevInfoLogDTO.getVol() != null && !superPowerDevInfoLogDTO.getVol().equals("0") && integer != null){
|
|
|
+ volList.set(integer,Float.valueOf(superPowerDevInfoLogDTO.getVol()));
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case 4 :
|
|
|
+ if (superPowerDevInfoLogDTO.getRemark5Cur() != null && !superPowerDevInfoLogDTO.getRemark5Cur().equals("0") && integer != null){
|
|
|
+ curList.set(integer,Float.valueOf(superPowerDevInfoLogDTO.getRemark5Cur()));
|
|
|
+ }
|
|
|
+ if (superPowerDevInfoLogDTO.getRemark5Power() != null && !superPowerDevInfoLogDTO.getRemark5Power().equals("0") && integer != null){
|
|
|
+ powerList.set(integer,Float.valueOf(superPowerDevInfoLogDTO.getRemark5Power()));
|
|
|
+ }
|
|
|
+ if (superPowerDevInfoLogDTO.getRemark5DayElectric() != null && !superPowerDevInfoLogDTO.getRemark5DayElectric().equals("0") && integer != null){
|
|
|
+ dayElectricList.set(integer,Float.valueOf(superPowerDevInfoLogDTO.getRemark5DayElectric()));
|
|
|
+ }
|
|
|
+ if (superPowerDevInfoLogDTO.getRemark5TotalElectric() != null && !superPowerDevInfoLogDTO.getRemark5TotalElectric().equals("0") && integer != null){
|
|
|
+ totalElectricList.set(integer,Float.valueOf(superPowerDevInfoLogDTO.getRemark5TotalElectric()));
|
|
|
+ }
|
|
|
+ if (superPowerDevInfoLogDTO.getVol() != null && !superPowerDevInfoLogDTO.getVol().equals("0") && integer != null){
|
|
|
+ volList.set(integer,Float.valueOf(superPowerDevInfoLogDTO.getVol()));
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case 5 :
|
|
|
+ if (superPowerDevInfoLogDTO.getRemark6Cur() != null && !superPowerDevInfoLogDTO.getRemark6Cur().equals("0") && integer != null){
|
|
|
+ curList.set(integer,Float.valueOf(superPowerDevInfoLogDTO.getRemark6Cur()));
|
|
|
+ }
|
|
|
+ if (superPowerDevInfoLogDTO.getRemark6Power() != null && !superPowerDevInfoLogDTO.getRemark6Power().equals("0") && integer != null){
|
|
|
+ powerList.set(integer,Float.valueOf(superPowerDevInfoLogDTO.getRemark6Power()));
|
|
|
+ }
|
|
|
+ if (superPowerDevInfoLogDTO.getRemark6DayElectric() != null && !superPowerDevInfoLogDTO.getRemark6DayElectric().equals("0") && integer != null){
|
|
|
+ dayElectricList.set(integer,Float.valueOf(superPowerDevInfoLogDTO.getRemark6DayElectric()));
|
|
|
+ }
|
|
|
+ if (superPowerDevInfoLogDTO.getRemark6TotalElectric() != null && !superPowerDevInfoLogDTO.getRemark6TotalElectric().equals("0") && integer != null){
|
|
|
+ totalElectricList.set(integer,Float.valueOf(superPowerDevInfoLogDTO.getRemark6TotalElectric()));
|
|
|
+ }
|
|
|
+ if (superPowerDevInfoLogDTO.getVol() != null && !superPowerDevInfoLogDTO.getVol().equals("0") && integer != null){
|
|
|
+ volList.set(integer,Float.valueOf(superPowerDevInfoLogDTO.getVol()));
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case 6 :
|
|
|
+ if (superPowerDevInfoLogDTO.getRemark7Cur() != null && !superPowerDevInfoLogDTO.getRemark7Cur().equals("0") && integer != null){
|
|
|
+ curList.set(integer,Float.valueOf(superPowerDevInfoLogDTO.getRemark7Cur()));
|
|
|
+ }
|
|
|
+ if (superPowerDevInfoLogDTO.getRemark7Power() != null && !superPowerDevInfoLogDTO.getRemark7Power().equals("0") && integer != null){
|
|
|
+ powerList.set(integer,Float.valueOf(superPowerDevInfoLogDTO.getRemark7Power()));
|
|
|
+ }
|
|
|
+ if (superPowerDevInfoLogDTO.getRemark7DayElectric() != null && !superPowerDevInfoLogDTO.getRemark7DayElectric().equals("0") && integer != null){
|
|
|
+ dayElectricList.set(integer,Float.valueOf(superPowerDevInfoLogDTO.getRemark7DayElectric()));
|
|
|
+ }
|
|
|
+ if (superPowerDevInfoLogDTO.getRemark7TotalElectric() != null && !superPowerDevInfoLogDTO.getRemark7TotalElectric().equals("0") && integer != null){
|
|
|
+ totalElectricList.set(integer,Float.valueOf(superPowerDevInfoLogDTO.getRemark7TotalElectric()));
|
|
|
+ }
|
|
|
+ if (superPowerDevInfoLogDTO.getVol() != null && !superPowerDevInfoLogDTO.getVol().equals("0") && integer != null){
|
|
|
+ volList.set(integer,Float.valueOf(superPowerDevInfoLogDTO.getVol()));
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ date = new Date(simpleDateFormat2.parse(superPowerDevInfoLogDTO.getUpdateTime()).getTime() + timezone * 3600 * 1000);
|
|
|
+ superPowerDevInfoLogDTO.setUpdateTime(simpleDateFormat.format(date));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ SuperPowerDevInfoLogVO superPowerDevInfoLogVO = new SuperPowerDevInfoLogVO();
|
|
|
+ superPowerDevInfoLogVO.setDateArr(dateList);
|
|
|
+ superPowerDevInfoLogVO.setCurArr(curList);
|
|
|
+ superPowerDevInfoLogVO.setVolArr(volList);
|
|
|
+ superPowerDevInfoLogVO.setPowerArr(powerList);
|
|
|
+ superPowerDevInfoLogVO.setDayElectricArr(dayElectricList);
|
|
|
+ superPowerDevInfoLogVO.setTotalElectricArr(totalElectricList);
|
|
|
+ return toolUtils.response(InterfaceResultEnum.OPERATION_SUCCESS,version,superPowerDevInfoLogVO);
|
|
|
+ }
|
|
|
}
|