|
|
@@ -1,5 +1,8 @@
|
|
|
package com.welampiot.controller;
|
|
|
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
import com.welampiot.common.BaseResult;
|
|
|
import com.welampiot.common.InterfaceResultEnum;
|
|
|
import com.welampiot.dto.*;
|
|
|
@@ -14,13 +17,14 @@ import org.springframework.web.bind.annotation.RequestMethod;
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
+import java.io.File;
|
|
|
import java.text.DecimalFormat;
|
|
|
import java.text.ParseException;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.Date;
|
|
|
-import java.util.HashMap;
|
|
|
-import java.util.List;
|
|
|
+import java.time.DayOfWeek;
|
|
|
+import java.time.LocalDate;
|
|
|
+import java.util.*;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
* ClassName: BigScreenController
|
|
|
@@ -69,59 +73,188 @@ public class BigScreenController {
|
|
|
private AllAlarmInfoLogService allAlarmInfoLogService;
|
|
|
@Autowired
|
|
|
private LoopService loopService;
|
|
|
+ @Autowired
|
|
|
+ private LampInfoLogService lampInfoLogService;
|
|
|
+ @Autowired
|
|
|
+ private GroupService groupService;
|
|
|
+ @Autowired
|
|
|
+ private EnvmonitorInfoLogService envmonitorInfoLogService;
|
|
|
+ @Autowired
|
|
|
+ private WeatherRS485DevInfoService weatherRS485DevInfoService;
|
|
|
+ @Autowired
|
|
|
+ private GlobalLocationService globalLocationService;
|
|
|
|
|
|
/**
|
|
|
* 用电量统计
|
|
|
* @param request sectionList
|
|
|
* @return 用电量统计
|
|
|
*/
|
|
|
- @RequestMapping(value = "/statistics", method = RequestMethod.POST)
|
|
|
- public BaseResult<?> statistics(HttpServletRequest request) throws ParseException {
|
|
|
- Integer version = (Integer) toolUtils.getRequestContent(request,"version",1);
|
|
|
- long startTime = System.currentTimeMillis() - 24L * 3600 * 1000 * 30;
|
|
|
- long endTime = System.currentTimeMillis() - 24 * 3600 * 1000;
|
|
|
- SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
- String startDate = simpleDateFormat.format(startTime);
|
|
|
- String endDate = simpleDateFormat.format(endTime);
|
|
|
- LampInfoCacheByDayDTO dayDTO = new LampInfoCacheByDayDTO();
|
|
|
- dayDTO.setStartDate(startDate);
|
|
|
- dayDTO.setEndDate(endDate);
|
|
|
- dayDTO.setSectionList(toolUtils.getSectionList(request));
|
|
|
- List<LampInfoCacheByDayDTO> list = lampInfoCacheByDayService.getSectionOfMonthConSum(dayDTO);
|
|
|
- DecimalFormat decimalFormat = new DecimalFormat("0.00");
|
|
|
-
|
|
|
- HashMap<String, Integer> objectObjectHashMap = new HashMap<>();
|
|
|
- long timeT = startTime;
|
|
|
- int i = 0;
|
|
|
- List<Object> dateList = new ArrayList<>();
|
|
|
- List<Object> valueList = new ArrayList<>();
|
|
|
+ @RequestMapping(value = "/data", method = RequestMethod.POST)
|
|
|
+ public BaseResult<?> data(HttpServletRequest request) throws ParseException {
|
|
|
+ Integer version = (Integer) toolUtils.getRequestContent(request, "version", 1);
|
|
|
+ List sectionList = toolUtils.getSectionList(request);
|
|
|
+ LampInfoDTO dto = new LampInfoDTO();
|
|
|
+ dto.setLampPoleId(0);
|
|
|
+ dto.setSectionList(sectionList);
|
|
|
+ //路灯数据
|
|
|
+ List<LampInfoDTO> lampList = lampService.getLampLocaltion(dto);
|
|
|
+ //灯杆数据
|
|
|
+ LampPoleDTO lampPoleDTO = new LampPoleDTO();
|
|
|
+ lampPoleDTO.setSectionList(sectionList);
|
|
|
+ List<LampPoleDTO> lampPoleList = lampPoleService.getLampPoleLocation(lampPoleDTO);
|
|
|
+ //系统数据
|
|
|
+ LampInfoLogDTO lampInfoLogDTO = new LampInfoLogDTO();
|
|
|
+ lampInfoLogDTO.setSectionList(sectionList);
|
|
|
+ LampInfoLogDTO dayConsumption = lampInfoLogService.getDayConsumption(lampInfoLogDTO);
|
|
|
+ //故障
|
|
|
+ AllAlarmInfoLogVO alarmVo = new AllAlarmInfoLogVO();
|
|
|
+ alarmVo.setSectionList(sectionList);
|
|
|
+ AllAlarmInfoLogVO countBySection = allAlarmInfoLogService.getCountBySection(alarmVo);
|
|
|
|
|
|
- while (timeT <= endTime) {
|
|
|
- objectObjectHashMap.put(simpleDateFormat.format(new Date(timeT)),i);
|
|
|
- dateList.add(simpleDateFormat.format(new Date(timeT)));
|
|
|
- valueList.add(0);
|
|
|
- timeT += 3600 * 1000 * 24;
|
|
|
- i ++;
|
|
|
+ if (dayConsumption == null){
|
|
|
+ lampInfoLogDTO.setSectionList(null);
|
|
|
+ dayConsumption = lampInfoLogDTO;
|
|
|
+ }
|
|
|
+ if (dayConsumption.getDayconsumption() == null){
|
|
|
+ dayConsumption.setDayconsumption(0d);
|
|
|
+ }else {
|
|
|
+ String consumption = String.format("%.2f",dayConsumption.getDayconsumption() == null? 0.0 : dayConsumption.getDayconsumption());
|
|
|
+ dayConsumption.setDayconsumption(Double.valueOf(consumption));
|
|
|
+ }
|
|
|
+ String totalConsumption = String.format("%.2f",dayConsumption.getTotalconsumption() == null? 0.0 : dayConsumption.getTotalconsumption());
|
|
|
+ dayConsumption.setTotalconsumption(Double.valueOf(totalConsumption));
|
|
|
+ dayConsumption.setLampCount(lampList.size());
|
|
|
+ dayConsumption.setPoleCount(lampPoleList.size());
|
|
|
+ dayConsumption.setPoleList(lampPoleList);
|
|
|
+ LampVO lampVO = new LampVO();
|
|
|
+ lampVO.setSectionList(sectionList);
|
|
|
+ lampVO.setStatus(1);
|
|
|
+ int onlineCountByVO = lampService.getOnlineCountByVO(lampVO);
|
|
|
+ dayConsumption.setLightCount(onlineCountByVO);
|
|
|
+ dayConsumption.setAlarmCount(countBySection.getTotal());
|
|
|
+ HashMap<String, LampInfoDTO> tempLampList = new HashMap<>();
|
|
|
+ for (LampInfoDTO item:lampList) {
|
|
|
+ item.setSelect(0);
|
|
|
+ tempLampList.put(String.valueOf(item.getId()),item);
|
|
|
}
|
|
|
+ List<GroupDTO> groupList = groupService.getListBySection(sectionList);
|
|
|
+ int index = 0;
|
|
|
|
|
|
- for (LampInfoCacheByDayDTO dto : list) {
|
|
|
- Date date = new Date(simpleDateFormat.parse(dto.getUpdateTime()).getTime());
|
|
|
- String s = simpleDateFormat.format(date);
|
|
|
- Integer integer = null;
|
|
|
- if (objectObjectHashMap.containsKey(s)) {
|
|
|
- integer = objectObjectHashMap.get(s);
|
|
|
+ List<List<LampInfoDTO>> groupLists = new ArrayList<>();
|
|
|
+ List<LampInfoDTO> otherLists = new ArrayList<>();
|
|
|
+ for (GroupDTO group:groupList) {
|
|
|
+ if (group.getLampId() == null) continue;
|
|
|
+ ArrayList<LampInfoDTO> groupTemp = new ArrayList<>();
|
|
|
+
|
|
|
+ Set<String> uniqueSet = new LinkedHashSet<>();
|
|
|
+ String[] items = group.getLampId().split(",");
|
|
|
+ uniqueSet.addAll(Arrays.asList(items));
|
|
|
+ for (String id:uniqueSet) {
|
|
|
+ LampInfoDTO lamp = tempLampList.get(id);
|
|
|
+ if (lamp != null){
|
|
|
+ //groupTemp.add(tempLampList.get(id));
|
|
|
+ LampInfoDTO lampTemp = new LampInfoDTO();
|
|
|
+ lampTemp.setId(lamp.getId());
|
|
|
+ lampTemp.setLongitude(lamp.getLongitude());
|
|
|
+ lampTemp.setLatitude(lamp.getLatitude());
|
|
|
+ lampTemp.setNumber(lamp.getNumber());
|
|
|
+ lampTemp.setSelect(lamp.getSelect());
|
|
|
+ groupTemp.add(lampTemp);
|
|
|
+
|
|
|
+ lamp.setSelect(1);
|
|
|
+ tempLampList.put(id, lamp);
|
|
|
+ }
|
|
|
}
|
|
|
+ if (groupTemp.size() <= 1){
|
|
|
+ if (groupTemp.size() != 0) {
|
|
|
+ Integer tempId = groupTemp.get(0).getId();
|
|
|
+ if (tempLampList.get(String.valueOf(tempId)).getSelect() > 0) tempLampList.get(String.valueOf(tempId)).setSelect(0);
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ groupLists.add(index,groupTemp);
|
|
|
+ index ++;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ tempLampList.forEach((key, value) -> {
|
|
|
+ Integer select = value.getSelect();
|
|
|
+ if (select == 0){
|
|
|
+ otherLists.add(value);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ LampInfoVO lampInfoVO = new LampInfoVO();
|
|
|
+ lampInfoVO.setGroup(groupLists);
|
|
|
+ lampInfoVO.setOther(otherLists);
|
|
|
+ dayConsumption.setLampList(lampInfoVO);
|
|
|
+
|
|
|
+ // 重点地区
|
|
|
+ alarmVo.setType(1);
|
|
|
+ alarmVo.setVersion(version);
|
|
|
+ //AllAlarmInfoLogVO vo = allAlarmInfoLogService.alarmTOP(alarmVo);
|
|
|
+ List<AllAlarmInfoLogVO> objetVo = allAlarmInfoLogService.alarmTOP(alarmVo);
|
|
|
|
|
|
- if (dto.getConSum() != null && !dto.getConSum().equals("0") && integer != null) {
|
|
|
- String formatConSum = decimalFormat.format(dto.getConSum());
|
|
|
- valueList.set(integer, Float.parseFloat(formatConSum));
|
|
|
+ if (objetVo.size() > 0){
|
|
|
+ AllAlarmInfoLogVO vo = objetVo.get(0);
|
|
|
+ dayConsumption.setArea(vo.getArea());
|
|
|
+ if (version == 0){
|
|
|
+ if (vo.getArea() == null){
|
|
|
+ dayConsumption.setArea("暂无");
|
|
|
+ }
|
|
|
+ } else if (version == 1) {
|
|
|
+ if (vo.getArea() == null){
|
|
|
+ dayConsumption.setArea("Not available");
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ if (vo.getArea() == null){
|
|
|
+ dayConsumption.setArea("Пока нет");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ if (version == 0){
|
|
|
+ dayConsumption.setArea("暂无");
|
|
|
+ } else if (version == 1) {
|
|
|
+ dayConsumption.setArea("Not available");
|
|
|
+ }else {
|
|
|
+ dayConsumption.setArea("Пока нет");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- LampInfoCacheByDayVO lampInfoCacheByDayVO = new LampInfoCacheByDayVO();
|
|
|
- lampInfoCacheByDayVO.setDate(dateList);
|
|
|
- lampInfoCacheByDayVO.setValue(valueList);
|
|
|
- return toolUtils.response(InterfaceResultEnum.OPERATION_SUCCESS,version,lampInfoCacheByDayVO);
|
|
|
+ return toolUtils.response(InterfaceResultEnum.OPERATION_SUCCESS,version,dayConsumption);
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * 用电量统计
|
|
|
+ * @param request sectionList
|
|
|
+ * @return 用电量统计
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "/statistics", method = RequestMethod.POST)
|
|
|
+ public BaseResult<?> statistics(HttpServletRequest request) throws ParseException {
|
|
|
+ Integer version = (Integer) toolUtils.getRequestContent(request,"version",1);
|
|
|
+ SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
+ List sectionList = toolUtils.getSectionList(request);
|
|
|
+ LampInfoLogDTO repLampinfoLog = new LampInfoLogDTO();
|
|
|
+
|
|
|
+ List<Object> value = new ArrayList<>();
|
|
|
+ List<Object> date = new ArrayList<>();
|
|
|
+ for (int i = 30; i >= 0; i --){
|
|
|
+ long t = System.currentTimeMillis() - i * 24L * 3600 * 1000;
|
|
|
+ String dateStr = simpleDateFormat.format(new Date(t));
|
|
|
+ String startDate = dateStr + " 00:00:00";
|
|
|
+ String endDate = dateStr + " 23:59:59";
|
|
|
+ LampInfoLogDTO dto = new LampInfoLogDTO();
|
|
|
+ dto.setStartDate(startDate);
|
|
|
+ dto.setEndDate(endDate);
|
|
|
+ dto.setSectionList(sectionList);
|
|
|
+ LampInfoLogDTO lampInfoLogDTO = lampInfoLogService.consumptiontSatistics(dto);
|
|
|
+ if (lampInfoLogDTO != null){
|
|
|
+ value.add(String.format("%.2f",lampInfoLogDTO.getDayconsumption()));
|
|
|
+ }else {
|
|
|
+ value.add(0);
|
|
|
+ }
|
|
|
+
|
|
|
+ date.add(dateStr);
|
|
|
+ }
|
|
|
+ repLampinfoLog.setValue(value);
|
|
|
+ repLampinfoLog.setDate(date);
|
|
|
+ return toolUtils.response(InterfaceResultEnum.OPERATION_SUCCESS, version, repLampinfoLog);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -132,13 +265,25 @@ public class BigScreenController {
|
|
|
@RequestMapping(value = "/alarmTOP", method = RequestMethod.POST)
|
|
|
public BaseResult<?> alarmTOP(HttpServletRequest request) {
|
|
|
Integer version = (Integer) toolUtils.getRequestContent(request,"version",1);
|
|
|
- LampInfoDTO lampInfoDTO = new LampInfoDTO();
|
|
|
- lampInfoDTO.setVersion(version);
|
|
|
- lampInfoDTO.setSectionList(toolUtils.getSectionList(request));
|
|
|
- List<LampInfoDTO> list = lampService.getAlarmAreaCountTop(lampInfoDTO);
|
|
|
- LampInfoVO lampInfoVO = new LampInfoVO();
|
|
|
- lampInfoVO.setList(list);
|
|
|
- return toolUtils.response(InterfaceResultEnum.OPERATION_SUCCESS,version,lampInfoVO);
|
|
|
+ List<?> sectionList = toolUtils.getSectionList(request);
|
|
|
+ AllAlarmInfoLogVO alarmVo = new AllAlarmInfoLogVO();
|
|
|
+ alarmVo.setSectionList(sectionList);
|
|
|
+ alarmVo.setType(0);
|
|
|
+ alarmVo.setVersion(version);
|
|
|
+ Object objectVo= allAlarmInfoLogService.alarmTOP(alarmVo);
|
|
|
+ List<AllAlarmInfoLogVO> voList = (List<AllAlarmInfoLogVO>)objectVo;
|
|
|
+
|
|
|
+ alarmVo.setSectionList(null);
|
|
|
+ alarmVo.setType(null);
|
|
|
+ alarmVo.setVersion(null);
|
|
|
+ List<AllAlarmInfoLogVO> objects = new ArrayList<>();
|
|
|
+ for (AllAlarmInfoLogVO vo :voList) {
|
|
|
+ if (vo.getArea() != null){
|
|
|
+ objects.add(vo);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ alarmVo.setList(objects);
|
|
|
+ return toolUtils.response(InterfaceResultEnum.OPERATION_SUCCESS,version,alarmVo);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -149,22 +294,16 @@ public class BigScreenController {
|
|
|
@RequestMapping(value = "/consumptionTOP", method = RequestMethod.POST)
|
|
|
public BaseResult<?> consumptionTOP(HttpServletRequest request) {
|
|
|
Integer version = (Integer) toolUtils.getRequestContent(request,"version",1);
|
|
|
- LampInfoDTO lampInfoDTO = new LampInfoDTO();
|
|
|
- lampInfoDTO.setSectionList(toolUtils.getSectionList(request));
|
|
|
- List<LampInfoDTO> list = lampService.getLampEleUseSectionTop(lampInfoDTO);
|
|
|
- DecimalFormat decimalFormat = new DecimalFormat("0.00");
|
|
|
- for (LampInfoDTO dto : list) {
|
|
|
- if (dto.getConsumption() != null && !dto.getConsumption().equals("0.0")) {
|
|
|
- float consumption = Float.parseFloat(dto.getConsumption());
|
|
|
- String format = decimalFormat.format(consumption);
|
|
|
- dto.setConsumption(format);
|
|
|
- } else if (dto.getConsumption() == null || dto.getConsumption().equals("0.0")) {
|
|
|
- dto.setConsumption("0");
|
|
|
- }
|
|
|
+ List<?> sectionList = toolUtils.getSectionList(request);
|
|
|
+ LampInfoLogDTO lampInfoLogDTO = new LampInfoLogDTO();
|
|
|
+ lampInfoLogDTO.setSectionList(sectionList);
|
|
|
+ List<LampInfoLogDTO> lampInfoLogDTOS = lampInfoLogService.consumptionTOP(lampInfoLogDTO);
|
|
|
+ for (LampInfoLogDTO dto:lampInfoLogDTOS) {
|
|
|
+ if (dto.getConsumption() == null) dto.setConsumption(0);
|
|
|
}
|
|
|
- LampInfoVO lampInfoVO = new LampInfoVO();
|
|
|
- lampInfoVO.setList(list);
|
|
|
- return toolUtils.response(InterfaceResultEnum.OPERATION_SUCCESS,version,lampInfoVO);
|
|
|
+ lampInfoLogDTO.setList(lampInfoLogDTOS);
|
|
|
+ lampInfoLogDTO.setSectionList(null);
|
|
|
+ return toolUtils.response(InterfaceResultEnum.OPERATION_SUCCESS, version, lampInfoLogDTO);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -199,48 +338,30 @@ public class BigScreenController {
|
|
|
public BaseResult<?> alarmChart(HttpServletRequest request) throws ParseException {
|
|
|
Integer version = (Integer) toolUtils.getRequestContent(request,"version",1);
|
|
|
|
|
|
- long startTime = System.currentTimeMillis() - 29L * 3600 * 1000 * 24;
|
|
|
- long endTime = System.currentTimeMillis();
|
|
|
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
- String startDate = simpleDateFormat.format(startTime);
|
|
|
- String endDate = simpleDateFormat.format(endTime);
|
|
|
- LampInfoDTO lampInfoDTO = new LampInfoDTO();
|
|
|
- lampInfoDTO.setStartDate(startDate);
|
|
|
- lampInfoDTO.setEndDate(endDate);
|
|
|
- lampInfoDTO.setSectionList(toolUtils.getSectionList(request));
|
|
|
- List<LampInfoDTO> list = lampService.getLampAlarmTotal(lampInfoDTO);
|
|
|
-
|
|
|
- HashMap<String, Integer> objectObjectHashMap = new HashMap<>();
|
|
|
- long timeT = startTime;
|
|
|
- int i = 0;
|
|
|
- List<Object> dateList = new ArrayList<>();
|
|
|
- List<Object> valueList = new ArrayList<>();
|
|
|
-
|
|
|
- while (timeT <= endTime) {
|
|
|
- objectObjectHashMap.put(simpleDateFormat.format(new Date(timeT)),i);
|
|
|
- dateList.add(simpleDateFormat.format(new Date(timeT)));
|
|
|
- valueList.add(0);
|
|
|
- timeT += 3600 * 1000 * 24;
|
|
|
- i ++;
|
|
|
- }
|
|
|
-
|
|
|
- for (LampInfoDTO dto : list) {
|
|
|
- Date date = new Date(simpleDateFormat.parse(dto.getUpdateTime()).getTime());
|
|
|
- String s = simpleDateFormat.format(date);
|
|
|
- Integer integer = null;
|
|
|
- if (objectObjectHashMap.containsKey(s)) {
|
|
|
- integer = objectObjectHashMap.get(s);
|
|
|
- }
|
|
|
+ List sectionList = toolUtils.getSectionList(request);
|
|
|
+ LampInfoLogDTO repLampinfoLog = new LampInfoLogDTO();
|
|
|
|
|
|
- if (dto.getLampCount() != null && dto.getLampCount() != 0 && integer != null) {
|
|
|
- valueList.set(integer, dto.getLampCount());
|
|
|
+ List<Object> value = new ArrayList<>();
|
|
|
+ List<Object> date = new ArrayList<>();
|
|
|
+ for (int i = 29; i >= 0; i --){
|
|
|
+ long t = System.currentTimeMillis() - i * 24L * 3600 * 1000;
|
|
|
+ String dateStr = simpleDateFormat.format(new Date(t));
|
|
|
+ String endDate = dateStr + " 23:59:59";
|
|
|
+ LampInfoLogDTO dto = new LampInfoLogDTO();
|
|
|
+ dto.setEndDate(endDate);
|
|
|
+ dto.setSectionList(sectionList);
|
|
|
+ AllAlarmInfoLogVO vo = lampInfoLogService.alarmCountChart(dto);
|
|
|
+ if (vo == null){
|
|
|
+ value.add(0);
|
|
|
+ }else {
|
|
|
+ value.add(vo.getTotal());
|
|
|
}
|
|
|
+ date.add(dateStr);
|
|
|
}
|
|
|
-
|
|
|
- LampInfoVO lampInfoVO = new LampInfoVO();
|
|
|
- lampInfoVO.setDate(dateList);
|
|
|
- lampInfoVO.setValue(valueList);
|
|
|
- return toolUtils.response(InterfaceResultEnum.OPERATION_SUCCESS,version,lampInfoVO);
|
|
|
+ repLampinfoLog.setValue(value);
|
|
|
+ repLampinfoLog.setDate(date);
|
|
|
+ return toolUtils.response(InterfaceResultEnum.OPERATION_SUCCESS,version,repLampinfoLog);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -255,6 +376,7 @@ public class BigScreenController {
|
|
|
lampPoleDTO.setSectionList(toolUtils.getSectionList(request));
|
|
|
LampInfoDTO lampInfoDTO = new LampInfoDTO();
|
|
|
lampInfoDTO.setSectionList(toolUtils.getSectionList(request));
|
|
|
+ lampInfoDTO.setType(2);
|
|
|
LampPoleInfoVO lampPoleData = lampPoleService.getLampPoleBigScreenCount(lampPoleDTO, lampInfoDTO);
|
|
|
return toolUtils.response(InterfaceResultEnum.OPERATION_SUCCESS,version,lampPoleData);
|
|
|
}
|
|
|
@@ -269,115 +391,370 @@ public class BigScreenController {
|
|
|
Integer version = (Integer) toolUtils.getRequestContent(request,"version",1);
|
|
|
Integer lampPoleId = (Integer) toolUtils.getRequestContent(request,"lampPoleId",1);
|
|
|
if (lampPoleId == 0) return toolUtils.response(InterfaceResultEnum.LACK_PARAM_ERROR,version);
|
|
|
- // 照明数据
|
|
|
- LampInfoDTO lampInfoDTO = lampService.getLampOfLampPoleById(lampPoleId, 0);
|
|
|
+
|
|
|
LampPoleDataVO lampPoleDataVO = new LampPoleDataVO();
|
|
|
- lampPoleDataVO.setLampData(lampInfoDTO);
|
|
|
- // 气象数据
|
|
|
- EnvmonitorDTO envmonitor = envmonitorService.getEnvmonitorByLampPoleId(lampPoleId);
|
|
|
- Double longitude = null,latitude = null;
|
|
|
- if (envmonitor != null) {
|
|
|
- longitude = envmonitor.getLongitude();
|
|
|
- latitude = envmonitor.getLatitude();
|
|
|
- }
|
|
|
- if (longitude != null && latitude != null) {
|
|
|
- List<WeatherDTO> weatherList = WeatherUtil.getNearWeatherInfo(longitude.toString(), latitude.toString());
|
|
|
- envmonitor.setWeatherList(weatherList);
|
|
|
- }
|
|
|
- lampPoleDataVO.setWeatherData(envmonitor);
|
|
|
- // 屏幕数据
|
|
|
- ScreenDTO screen = screenService.getScreenByLampPoleId(lampPoleId);
|
|
|
- if (screen != null) screen.setName(screen.getPlay());
|
|
|
- lampPoleDataVO.setScreenData(screen);
|
|
|
// 监控数据
|
|
|
- VideoMonitorDTO video = videoMonitorService.getVideoMonitorByLampPoleId(lampPoleId);
|
|
|
- video.setVideoPath("");
|
|
|
- video.setVideoPathHd("");
|
|
|
- VideoCarDTO videoCar = videoCarService.getVideoCarByVideoId(video.getId());
|
|
|
- if (videoCar != null) video.setCarImage(videoCar.getImage());
|
|
|
- List<VideoCarDTO> carList = videoCarService.getVideoCarListByVideoId(video.getId());
|
|
|
- video.setCarList(carList); // 车牌识别列表
|
|
|
- List<VideoFaceDTO> videoFace = videoFaceService.getVideoFaceListByVideoId(lampPoleId);
|
|
|
- video.setFaceList(videoFace); // 人脸识别列表
|
|
|
- List<TrailInfoDTO> trailList = trailInfoService.getTrailInfoListByVideoId(video.getId());
|
|
|
- video.setTrailList(trailList); // 轨迹列表
|
|
|
- List<TrailInfoDTO> smailList = trailInfoService.getSmailListByVideoId(video.getId());
|
|
|
- video.setSmailList(smailList); // 相似度列表
|
|
|
- lampPoleDataVO.setVideoData(video);
|
|
|
- // 充电桩数据
|
|
|
- ChargeDTO chargeDTO = chargeService.getChargeInfoByLampPoleId(lampPoleId);
|
|
|
- lampPoleDataVO.setChargeData(chargeDTO);
|
|
|
- // wifi数据
|
|
|
- WifiDTO wifi = wifiService.getWifiByLampPoleId(lampPoleId);
|
|
|
- if (wifi.getFlow() != null) {
|
|
|
- Float flow = wifi.getFlow();
|
|
|
- if (flow < 1024) {
|
|
|
- wifi.setType(0);
|
|
|
- } else if (1024 <= flow && flow < 1024 * 1024) {
|
|
|
- wifi.setType(1);
|
|
|
- flow = flow / 1024;
|
|
|
- wifi.setFlow(flow);
|
|
|
- } else if (1024 * 1024 <= flow) {
|
|
|
- wifi.setType(2);
|
|
|
- flow = flow / (1024 * 1024);
|
|
|
- wifi.setFlow(flow);
|
|
|
+ VideoMonitorDTO videoMonitor = videoMonitorService.getOneData(lampPoleId);
|
|
|
+ if (videoMonitor == null){
|
|
|
+ lampPoleDataVO.setVideoData(new VideoMonitorDTO());
|
|
|
+ }else {
|
|
|
+ // 人脸识别列表
|
|
|
+ List<VideoFaceDTO> faceList = videoFaceService.getList(videoMonitor.getId());
|
|
|
+ videoMonitor.setFaceList(faceList == null ? new ArrayList<>() : faceList);
|
|
|
+ // 车牌识别列表
|
|
|
+ List<VideoCarDTO> carList = videoCarService.getList(videoMonitor.getId());
|
|
|
+ videoMonitor.setCarList(carList == null ? new ArrayList<>() : carList);
|
|
|
+ videoMonitor.setCarImage(carList.size() > 0 ? carList.get(0).getImage() : "");
|
|
|
+ // 今天人流量
|
|
|
+ SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
+ long l = System.currentTimeMillis();
|
|
|
+ String time = simpleDateFormat.format(new Date(l));
|
|
|
+ String beginDate = time + " 00:00:00";
|
|
|
+ String endDate = time + " 23:59:59";
|
|
|
+ VideoFaceDTO faceDTO = new VideoFaceDTO();
|
|
|
+ faceDTO.setId(videoMonitor.getId());
|
|
|
+ faceDTO.setBeginDate(beginDate);
|
|
|
+ faceDTO.setEndDate(endDate);
|
|
|
+ Integer faceTotal = videoFaceService.getTotal(faceDTO);
|
|
|
+
|
|
|
+ VideoCarDTO videoCarDTO = new VideoCarDTO();
|
|
|
+ videoCarDTO.setId(videoMonitor.getId());
|
|
|
+ videoCarDTO.setBeginDate(beginDate);
|
|
|
+ videoCarDTO.setEndDate(endDate);
|
|
|
+ Integer carTotal = videoCarService.getTotal(videoCarDTO);
|
|
|
+ videoMonitor.setPersonCountToday(faceTotal == null ? 0 : faceTotal);
|
|
|
+ videoMonitor.setCarCountToday(carTotal == null ? 0 : carTotal);
|
|
|
+
|
|
|
+ if (videoMonitor.getNetType() == 1){
|
|
|
+ String gbPlayAddress = toolUtils.getGbPlayAddress(videoMonitor.getGbAddress(), null, null, null);
|
|
|
+ videoMonitor.setVideoPath(gbPlayAddress);
|
|
|
+ videoMonitor.setVideoPathHd(gbPlayAddress);
|
|
|
+ videoMonitor.setHlsHd(gbPlayAddress);
|
|
|
+ }
|
|
|
+ // 轨迹信息
|
|
|
+ List<TrailInfoDTO> trailList = trailInfoService.getList(videoMonitor.getId());
|
|
|
+ videoMonitor.setTrailList( trailList == null ? new ArrayList<>() : trailList);
|
|
|
+
|
|
|
+ TrailInfoDTO smai = trailInfoService.getSmaiListById(videoMonitor.getId());
|
|
|
+ TrailInfoDTO smai2 = trailInfoService.getSmaiList(videoMonitor.getId());
|
|
|
+ if (smai == null){
|
|
|
+ videoMonitor.setSmailList(new ArrayList<>());
|
|
|
+ }else {
|
|
|
+ ArrayList<TrailInfoDTO> trailInfoDTOS = new ArrayList<>();
|
|
|
+ smai.setSmail(Float.parseFloat(String.format("%.1f",smai.getSmail())));
|
|
|
+ trailInfoDTOS.add(smai);
|
|
|
+ videoMonitor.setSmailList(trailInfoDTOS);
|
|
|
}
|
|
|
+ if (smai2 != null){
|
|
|
+ ArrayList<TrailInfoDTO> trailInfoDTOS = new ArrayList<>();
|
|
|
+ smai2.setSmail(Float.parseFloat(String.format("%.1f",smai2.getSmail())));
|
|
|
+ trailInfoDTOS.add(smai2);
|
|
|
+ videoMonitor.setSmailList(trailInfoDTOS);
|
|
|
+ }
|
|
|
+ lampPoleDataVO.setVideoData(videoMonitor);
|
|
|
}
|
|
|
- // 流量列表
|
|
|
- List<Object> dateList = new ArrayList<>();
|
|
|
- List<Object> flowList = new ArrayList<>();
|
|
|
- long l = System.currentTimeMillis();
|
|
|
- long startTime = l - 24 * 3600 * 1000 * 6;
|
|
|
- HashMap<String, Integer> objectObjectHashMap = new HashMap<>();
|
|
|
- long timeT = startTime;
|
|
|
- int i = 0;
|
|
|
+ // 照明数据
|
|
|
+ LampInfoDTO lamp = lampService.getLampById(lampPoleId);
|
|
|
+ if (lamp == null) {
|
|
|
+ lampPoleDataVO.setLampData(new LampInfoDTO());
|
|
|
+ }else {
|
|
|
+ lamp.setColourVal(lamp.getColourVal() < 3000 ? 5000 : lamp.getColourVal());
|
|
|
+ LampInfoLogDTO logDTO = lampInfoLogService.getOne(lamp.getId());
|
|
|
+ lamp.setGridVolt(logDTO == null ? 0 : logDTO.getGridvolt());
|
|
|
+ lamp.setGridCurr(logDTO == null ? 0 : logDTO.getGridcurr());
|
|
|
+ lamp.setGridActivePower(logDTO == null ? 0 : logDTO.getGridActivePower());
|
|
|
+ lamp.setGridPF(logDTO == null ? 0 : logDTO.getGridPF());
|
|
|
+ if (logDTO == null){
|
|
|
+ lamp.setWorkTimeTotal("0");
|
|
|
+ }else {
|
|
|
+ double h = Math.floor(logDTO.getWorkTimeTotal() / 3600);
|
|
|
+ String tempH = String.valueOf(h);
|
|
|
+ String h1 = h < 10 ? "0" + tempH : tempH;
|
|
|
+ double m = Math.floor(logDTO.getWorkTimeTotal() % 3600 / 60);
|
|
|
+ String tempM = String.valueOf(m);
|
|
|
+ String m1 = m < 10 ? "0" + tempM : tempM;
|
|
|
+ lamp.setWorkTimeTotal(h1 + ":" + m1);
|
|
|
+ }
|
|
|
+ lamp.setUsedEnergyTotal(logDTO == null ? 0 : logDTO.getUsedEnergyTotal());
|
|
|
+ lampPoleDataVO.setLampData(lamp);
|
|
|
+ }
|
|
|
+ // 气象数据
|
|
|
+ EnvmonitorDTO envmonitorDTO = envmonitorService.getOne(lampPoleId);
|
|
|
+ if (envmonitorDTO == null){
|
|
|
+ lampPoleDataVO.setWeatherData(new EnvmonitorInfoLogDTO());
|
|
|
+ }else {
|
|
|
+ //气象数据
|
|
|
+ EnvmonitorInfoLogDTO logServiceOne = envmonitorInfoLogService.getOne(envmonitorDTO.getId());
|
|
|
+ if (envmonitorDTO.getNetType() == 1){
|
|
|
+ List<WeatherRS485DevInfoDTO> listByWeather = weatherRS485DevInfoService.getListByWeatherId(envmonitorDTO.getId());
|
|
|
+ if (listByWeather == null || listByWeather.size() == 0){
|
|
|
+ logServiceOne.setDevType("1");
|
|
|
+ }else {
|
|
|
+ ArrayList<String> devIds = new ArrayList<>();
|
|
|
+ for (WeatherRS485DevInfoDTO dto : listByWeather) {
|
|
|
+ if (dto.getDevId() != null) devIds.add(String.valueOf(dto.getDevId()));
|
|
|
+ }
|
|
|
+ String result = devIds.stream().collect(Collectors.joining(","));
|
|
|
+ logServiceOne.setDevType(result);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (envmonitorDTO.getAreaId() == null){
|
|
|
+ logServiceOne.setWeatherList(new ArrayList<>());
|
|
|
+ }else {
|
|
|
+ GlobalLocationDTO oneById = globalLocationService.getOneById(envmonitorDTO.getAreaId());
|
|
|
+ long time = System.currentTimeMillis() / 1000;
|
|
|
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
+ Date parse = sdf.parse(envmonitorDTO.getWeatherUpdateTime());
|
|
|
+ long tamp = parse.getTime() / 1000;
|
|
|
+ if (envmonitorDTO.getWeatherInfo() == null || envmonitorDTO.getWeatherUpdateTime() == null || time - tamp > 3600){
|
|
|
+ String url = "https://devapi.qweather.com/v7/weather/7d?location="+ oneById.getLongitude()+","+oneById.getLatitude()+"&key=a90f03e386e84375a27404374324713f";
|
|
|
+ String s = toolUtils.zlibNetwork(url);
|
|
|
+ JSONObject jsonObject = JSON.parseObject(s);
|
|
|
+ List<NetworkWeather> networkWeathers = new ArrayList<>();
|
|
|
+ if (jsonObject.getJSONArray("daily") != null){
|
|
|
+ JSONArray array = jsonObject.getJSONArray("daily");
|
|
|
+ JSONObject daily = (JSONObject)jsonObject.getJSONArray("daily").get(0);
|
|
|
|
|
|
- DecimalFormat decimalFormat = new DecimalFormat("0.00");
|
|
|
- SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:00:00");
|
|
|
- SimpleDateFormat simpleDateFormat2 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
- while (timeT <= l) {
|
|
|
- objectObjectHashMap.put(simpleDateFormat.format(new Date(timeT)), i);
|
|
|
- dateList.add(simpleDateFormat.format(new Date(timeT)));
|
|
|
- flowList.add(0);
|
|
|
- timeT += 3600 * 1000;
|
|
|
- i++;
|
|
|
+ NetworkWeather networkWeather = new NetworkWeather();
|
|
|
+ String code = "";
|
|
|
+ if (version == 0){
|
|
|
+ code = toolUtils.weatherTranslateCn(daily.getString("iconDay"));
|
|
|
+ } else if (version == 1) {
|
|
|
+ code = toolUtils.weatherTranslateEn(daily.getString("iconDay"));
|
|
|
+ }else {
|
|
|
+ code = toolUtils.weatherTranslateRu(daily.getString("iconDay"));
|
|
|
+ }
|
|
|
+ networkWeather.setWeatherType(code);
|
|
|
+// networkWeather.setWeatherType(daily.getString("textDay"));
|
|
|
+// networkWeather.setCode(daily.getString("iconDay"));
|
|
|
+ networkWeather.setTmp((Integer.valueOf(daily.getString("tempMin"))+Integer.valueOf(daily.getString("tempMax"))) / 2);
|
|
|
+ networkWeather.setSr(daily.getString("sunrise"));
|
|
|
+ networkWeather.setSs(daily.getString("sunset"));
|
|
|
+ String fxDate = daily.getString("fxDate");
|
|
|
+ LocalDate date = LocalDate.parse(fxDate);
|
|
|
+ // 获取星期几
|
|
|
+ DayOfWeek dayOfWeek = date.getDayOfWeek();
|
|
|
+ networkWeather.setDateStr(String.valueOf(dayOfWeek));
|
|
|
+
|
|
|
+ // 获取月日
|
|
|
+ SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
+ SimpleDateFormat dateFormat = new SimpleDateFormat("MM-dd");
|
|
|
+ Date parse1 = simpleDateFormat.parse(fxDate);
|
|
|
+ String format = dateFormat.format(parse1);
|
|
|
+ networkWeather.setDate(format);
|
|
|
+ networkWeathers.add(networkWeather);
|
|
|
+ int i = 0;
|
|
|
+ for (Object obj:array) {
|
|
|
+ if (i != 0){
|
|
|
+ JSONObject obje = (JSONObject) obj;
|
|
|
+ NetworkWeather weather = new NetworkWeather();
|
|
|
+ if (version == 0){
|
|
|
+ code = toolUtils.weatherTranslateCn(obje.getString("iconDay"));
|
|
|
+ } else if (version == 1) {
|
|
|
+ code = toolUtils.weatherTranslateEn(obje.getString("iconDay"));
|
|
|
+ }else {
|
|
|
+ code = toolUtils.weatherTranslateRu(obje.getString("iconDay"));
|
|
|
+ }
|
|
|
+ weather.setWeatherType(code);
|
|
|
+// weather.setWeatherType(obje.getString("textDay"));
|
|
|
+// weather.setCode(obje.getString("iconDay"));
|
|
|
+ weather.setMaxTmp(obje.getString("tempMax"));
|
|
|
+ weather.setMinTmp(obje.getString("tempMin"));
|
|
|
+ weather.setSr(obje.getString("sunrise"));
|
|
|
+ weather.setSs(obje.getString("sunset"));
|
|
|
+ fxDate = obje.getString("fxDate");
|
|
|
+ date = LocalDate.parse(fxDate);
|
|
|
+ // 获取星期几
|
|
|
+ dayOfWeek = date.getDayOfWeek();
|
|
|
+ weather.setDateStr(String.valueOf(dayOfWeek));
|
|
|
+
|
|
|
+ // 获取月日
|
|
|
+ simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
+ dateFormat = new SimpleDateFormat("MM-dd");
|
|
|
+ parse = simpleDateFormat.parse(fxDate);
|
|
|
+ format = dateFormat.format(parse);
|
|
|
+ weather.setDate(format);
|
|
|
+ networkWeathers.add(weather);
|
|
|
+
|
|
|
+ }
|
|
|
+ i ++ ;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ logServiceOne.setWeatherList(networkWeathers);
|
|
|
+ }else {
|
|
|
+ JSONArray array = JSON.parseArray(envmonitorDTO.getWeatherInfo());
|
|
|
+ List<NetworkWeather> networkWeathers = new ArrayList<>();
|
|
|
+ for (Object o:array) {
|
|
|
+ JSONObject te = (JSONObject) o;
|
|
|
+ NetworkWeather networkWeather = new NetworkWeather();
|
|
|
+ networkWeather.setWeatherType(te.getString("weatherType"));
|
|
|
+ networkWeather.setCode(te.getString("code"));
|
|
|
+ networkWeather.setMaxTmp(te.getString("maxTmp"));
|
|
|
+ networkWeather.setMinTmp(te.getString("minTmp"));
|
|
|
+ networkWeather.setSr(te.getString("sr"));
|
|
|
+ networkWeather.setDate(te.getString("date"));
|
|
|
+ networkWeather.setSs(te.getString("ss"));
|
|
|
+ networkWeather.setDateStr(te.getString("dateStr"));
|
|
|
+ networkWeathers.add(networkWeather);
|
|
|
+ }
|
|
|
+ logServiceOne.setWeatherList(networkWeathers);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ lampPoleDataVO.setWeatherData(logServiceOne);
|
|
|
}
|
|
|
|
|
|
- int dayNumber = 1;
|
|
|
- WifiInfoLogDTO wifiInfoLogDTO = new WifiInfoLogDTO();
|
|
|
- wifiInfoLogDTO.setDayNum(7);
|
|
|
- wifiInfoLogDTO.setDayNumber(dayNumber);
|
|
|
- wifiInfoLogDTO.setLampPoleId(lampPoleId);
|
|
|
- List<WifiInfoLogDTO> wifiInfoLogList = wifiInfoLogService.getWifiStatisticsListByDTO(wifiInfoLogDTO);
|
|
|
- for (WifiInfoLogDTO dto1 : wifiInfoLogList) {
|
|
|
- Date date = new Date(simpleDateFormat2.parse(dto1.getUpdateTime()).getTime());
|
|
|
- String s = simpleDateFormat.format(date);
|
|
|
- long time = simpleDateFormat.parse(s).getTime();
|
|
|
- String formatStart = simpleDateFormat.format(startTime);
|
|
|
- startTime = simpleDateFormat.parse(formatStart).getTime();
|
|
|
- long timespan = (time - startTime) / (3600 * 1000 * dayNumber);
|
|
|
- long newTime = startTime + timespan * (3600 * 1000 * dayNumber);
|
|
|
- date = new Date(newTime);
|
|
|
- s = simpleDateFormat.format(date);
|
|
|
- Integer integer = null;
|
|
|
- if (objectObjectHashMap.containsKey(s)) {
|
|
|
- integer = objectObjectHashMap.get(s);
|
|
|
+ // 屏幕数据
|
|
|
+ ScreenDTO screenAndProgram = screenService.getScreenAndProgram(lampPoleId);
|
|
|
+ if (screenAndProgram == null){
|
|
|
+ lampPoleDataVO.setScreenData(new ScreenDTO());
|
|
|
+ }else {
|
|
|
+ if (screenAndProgram.getType() == 1){//气象站
|
|
|
+ if (version == 0){
|
|
|
+ screenAndProgram.setName("气象站");
|
|
|
+ } else if (version == 1) {
|
|
|
+ screenAndProgram.setName("Weather station");
|
|
|
+ }else {
|
|
|
+ screenAndProgram.setName("Mетеорологическая станция");
|
|
|
+ }
|
|
|
+ } else if (screenAndProgram.getType() == 2) { // 视屏监控
|
|
|
+ if (version == 0){
|
|
|
+ screenAndProgram.setName("摄像头");
|
|
|
+ } else if (version == 1) {
|
|
|
+ screenAndProgram.setName("Camera");
|
|
|
+ }else {
|
|
|
+ screenAndProgram.setName("Kамера");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ String path = "/upload/images/"+screenAndProgram.getNum()+".png";
|
|
|
+ File logFile = new File(path);
|
|
|
+ if (!logFile.exists()) {
|
|
|
+ screenAndProgram.setImage("");
|
|
|
+ }else {
|
|
|
+ screenAndProgram.setImage(path);
|
|
|
}
|
|
|
+ lampPoleDataVO.setScreenData(screenAndProgram);
|
|
|
+ }
|
|
|
+ // 充电桩数据
|
|
|
+ ChargeDTO charge = chargeService.getOne(lampPoleId);
|
|
|
+ if (charge == null){
|
|
|
+ charge = new ChargeDTO();
|
|
|
+ charge.setFree(0f);
|
|
|
+ charge.setDuration("00:00");
|
|
|
+ charge.setEquipmentElectricity(0f);
|
|
|
+ charge.setConnectorNum(0);
|
|
|
+ lampPoleDataVO.setChargeData(charge);
|
|
|
+ }else {
|
|
|
+ double h = Math.floor(Integer.parseInt(charge.getDuration()) / 60);
|
|
|
+ String tempH = String.valueOf(h);
|
|
|
+ String h1 = h < 10 ? "0" + tempH : tempH;
|
|
|
+ double m = Math.floor(Integer.parseInt(charge.getDuration()) % 60);
|
|
|
+ String tempM = String.valueOf(m);
|
|
|
+ String m1 = m < 10 ? "0" + tempM : tempM;
|
|
|
+ charge.setDuration(h1+":"+m1);
|
|
|
+ lampPoleDataVO.setChargeData(charge);
|
|
|
+ }
|
|
|
+ // wifi 数据
|
|
|
+ WifiDTO oneWifi = wifiService.getOneWifiByLampPoleId(lampPoleId);
|
|
|
+ if (oneWifi == null){
|
|
|
+ oneWifi = new WifiDTO();
|
|
|
+ oneWifi.setTotalFlaw(0f);
|
|
|
+ oneWifi.setTotalDevice(0);
|
|
|
+ oneWifi.setFlowList(new ArrayList<>());
|
|
|
+ oneWifi.setXDataList(new ArrayList<>());
|
|
|
+ oneWifi.setType(0);
|
|
|
+ lampPoleDataVO.setWifiData(oneWifi);
|
|
|
+ }else {
|
|
|
+ long l = System.currentTimeMillis();
|
|
|
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
+ String endDate = sdf.format(new Date(l));
|
|
|
+ String beginDate = sdf.format(new Date( l - 12 * 3600 * 1000));
|
|
|
+ WifiInfoLogDTO logDto = new WifiInfoLogDTO();
|
|
|
+ logDto.setWifiId(oneWifi.getId());
|
|
|
+ logDto.setStartDate(beginDate);
|
|
|
+ logDto.setEndDate(endDate);
|
|
|
+ List<WifiInfoLogDTO> list = wifiInfoLogService.getList(logDto);
|
|
|
|
|
|
- if (dto1.getMinFlow() != null && !dto1.getMinFlow().equals("0") && integer != null &&
|
|
|
- dto1.getMaxFlow() != null && !dto1.getMaxFlow().equals("0")) {
|
|
|
- Float flow = Float.parseFloat(dto1.getMaxFlow()) - Float.parseFloat(dto1.getMinFlow());
|
|
|
- flowList.set(integer,Float.parseFloat(decimalFormat.format(flow)));
|
|
|
+ if (list.size() > 0){
|
|
|
+ HashMap<Integer, Float> hashMap = new HashMap<>();
|
|
|
+ long t = 0;
|
|
|
+ Integer type = 0;
|
|
|
+ for (WifiInfoLogDTO dto:list) {
|
|
|
+ long time = sdf.parse(dto.getUpdateTime()).getTime();
|
|
|
+ int index = Math.round((l - time) / 3600 / 1000);
|
|
|
+ if (hashMap.get(index) == null){
|
|
|
+ t = dto.getFlow() > t ? Math.round(dto.getFlow()) : t;
|
|
|
+ hashMap.put(index,dto.getFlow());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (t > 1024 * 1024){
|
|
|
+ type = 2;
|
|
|
+ Float round = Float.parseFloat(String.format(".2f",list.get(0).getFlow() / (1024 * 1024)));
|
|
|
+ oneWifi.setTotalFlow(round);
|
|
|
+ } else if (t > 1024) {
|
|
|
+ type = 1;
|
|
|
+ Float round = Float.parseFloat(String.format(".2f",list.get(0).getFlow() / 1024 ));
|
|
|
+ oneWifi.setTotalFlow(round);
|
|
|
+ }else {
|
|
|
+ Float round = Float.parseFloat(String.format(".2f",list.get(0).getFlow()));
|
|
|
+ oneWifi.setTotalFlow(round);
|
|
|
+ }
|
|
|
+ List<Object> xDataList = new ArrayList<>();
|
|
|
+ for (int i = 0; i <= 11; i++){
|
|
|
+ if (hashMap.get(String.valueOf(i)) == null){
|
|
|
+ hashMap.put(i,0f);
|
|
|
+ }else {
|
|
|
+ if (type == 2){
|
|
|
+ String value = String.format(".2f", hashMap.get(String.valueOf(i)) / (1024 * 1024));
|
|
|
+ hashMap.put(i,Float.valueOf(value));
|
|
|
+ } else if (type == 1) {
|
|
|
+ String value = String.format(".2f", hashMap.get(String.valueOf(i)) / 1024);
|
|
|
+ hashMap.put(i,Float.valueOf(value));
|
|
|
+ }else {
|
|
|
+ String value = String.format(".2f", hashMap.get(String.valueOf(i)));
|
|
|
+ hashMap.put(i,Float.valueOf(value));
|
|
|
+ }
|
|
|
+ SimpleDateFormat hh = new SimpleDateFormat("HH");
|
|
|
+ String format = hh.format(new Date(l - (11 - i) * 3600 * 1000));
|
|
|
+ String tempTime = format + ":00";
|
|
|
+ xDataList.add(tempTime);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //反转
|
|
|
+ List<Object> floats = new ArrayList<>();
|
|
|
+ Set<Integer> keys = hashMap.keySet();
|
|
|
+ List<Integer> keyList = new ArrayList<>(keys);
|
|
|
+ Collections.sort(keyList, Collections.reverseOrder());
|
|
|
+ for (Integer s : hashMap.keySet()) {
|
|
|
+ floats.add(hashMap.get(s));
|
|
|
+ }
|
|
|
+ oneWifi.setFlowList(floats);
|
|
|
+ oneWifi.setTotalDevice(list.get(0).getDeviceCount());
|
|
|
+ oneWifi.setXDataList(xDataList);
|
|
|
+ oneWifi.setType(type);
|
|
|
+ }else {
|
|
|
+ oneWifi = new WifiDTO();
|
|
|
+ oneWifi.setTotalFlaw(0f);
|
|
|
+ oneWifi.setTotalDevice(0);
|
|
|
+ List<Object> arr = new ArrayList<>(Arrays.asList(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0));
|
|
|
+ oneWifi.setFlowList(arr);
|
|
|
+ oneWifi.setType(0);
|
|
|
+ List<Object> xDataList = new ArrayList<>();
|
|
|
+ for (int i = 0; i <= 11; i++){
|
|
|
+ SimpleDateFormat hh = new SimpleDateFormat("HH");
|
|
|
+ String format = hh.format(new Date(l - (11 - i) * 3600 * 1000));
|
|
|
+ String tempTime = format + ":00";
|
|
|
+ xDataList.add(tempTime);
|
|
|
+ }
|
|
|
+ oneWifi.setXDataList(xDataList);
|
|
|
}
|
|
|
+ lampPoleDataVO.setWifiData(oneWifi);
|
|
|
}
|
|
|
- wifi.setDateList(dateList);
|
|
|
- wifi.setFlowList(flowList);
|
|
|
- lampPoleDataVO.setWifiData(wifi);
|
|
|
- return toolUtils.response(InterfaceResultEnum.OPERATION_SUCCESS,version,lampPoleDataVO);
|
|
|
- }
|
|
|
+ return toolUtils.response(InterfaceResultEnum.OPERATION_SUCCESS,version,lampPoleDataVO);
|
|
|
+ }
|
|
|
|
|
|
/**
|
|
|
- * 灯杆大屏灯杆视屏列表
|
|
|
+ * 灯杆大屏灯杆视屏列表 #TODO
|
|
|
* @param request sectionList
|
|
|
* @return 灯杆视屏列表
|
|
|
*/
|
|
|
@@ -577,7 +954,7 @@ public class BigScreenController {
|
|
|
WeatherDTO weatherInfo = WeatherUtil.getNowWeatherInfo(longitude.toString(), latitude.toString());
|
|
|
envmonitor.setWeatherData(weatherInfo);
|
|
|
}
|
|
|
- lampPoleDataVO.setWeatherData(envmonitor);
|
|
|
+ //lampPoleDataVO.setWeatherData(envmonitor);
|
|
|
// 屏幕数据
|
|
|
ScreenDTO screen = screenService.getScreenByLampPoleId(lampPoleId);
|
|
|
if (screen != null) screen.setName(screen.getPlay());
|
|
|
@@ -613,7 +990,7 @@ public class BigScreenController {
|
|
|
Integer lampPoleId = (Integer) toolUtils.getRequestContent(request,"lampPoleId",1);
|
|
|
if (lampPoleId == 0) return toolUtils.response(InterfaceResultEnum.LACK_PARAM_ERROR,version);
|
|
|
LampInfoDTO lampInfoDTO = lampService.getLampOfLampPoleById(lampPoleId, 0);
|
|
|
- String usedEnergyTotal = lampInfoDTO.getUsedEnergyTotal(); // 累计用电量
|
|
|
+ String usedEnergyTotal = String.valueOf(lampInfoDTO.getUsedEnergyTotal()); // 累计用电量
|
|
|
String createTime = lampInfoDTO.getCreateTime();
|
|
|
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
long startTime = format.parse(createTime).getTime();
|