|
@@ -1,11 +1,13 @@
|
|
|
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.*;
|
|
|
import com.welampiot.service.*;
|
|
|
import com.welampiot.utils.ToolUtils;
|
|
|
-import com.welampiot.utils.WeatherUtil;
|
|
|
import com.welampiot.vo.*;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.web.bind.annotation.CrossOrigin;
|
|
@@ -14,12 +16,13 @@ import org.springframework.web.bind.annotation.RequestMethod;
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
+import java.nio.file.Files;
|
|
|
+import java.nio.file.Path;
|
|
|
+import java.nio.file.Paths;
|
|
|
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.util.*;
|
|
|
|
|
|
/**
|
|
|
* ClassName: BasePlatformController
|
|
@@ -46,6 +49,27 @@ public class BasePlatformController {
|
|
|
private UserService userService;
|
|
|
@Autowired
|
|
|
private WifiInfoLogService wifiInfoLogService;
|
|
|
+ @Autowired
|
|
|
+ private LampService lampService;
|
|
|
+ @Autowired
|
|
|
+ private PolicyService policyService;
|
|
|
+ @Autowired
|
|
|
+ private VideoMonitorService videoMonitorService;
|
|
|
+ @Autowired
|
|
|
+ private ScreenService screenService;
|
|
|
+ @Autowired
|
|
|
+ private ProgramService programService;
|
|
|
+ @Autowired
|
|
|
+ private WifiService wifiService;
|
|
|
+ @Autowired
|
|
|
+ private ChargeService chargeService;
|
|
|
+ @Autowired
|
|
|
+ private BroadcastService broadcastService;
|
|
|
+ @Autowired
|
|
|
+ private BroadcastProListService broadcastProListService;
|
|
|
+ @Autowired
|
|
|
+ private BroadcastItemService broadcastItemService;
|
|
|
+
|
|
|
|
|
|
/**
|
|
|
* 基础平台全局概览
|
|
@@ -56,6 +80,20 @@ public class BasePlatformController {
|
|
|
public BaseResult<?> data(HttpServletRequest request) {
|
|
|
Integer version = (Integer) toolUtils.getRequestContent(request, "version", 1);
|
|
|
List<?> sectionList = toolUtils.getSectionList(request);
|
|
|
+ LampPoleInfoVO lampPoleDevCount = null;
|
|
|
+ if (sectionList == null || sectionList.size() == 0){
|
|
|
+ lampPoleDevCount = new LampPoleInfoVO();
|
|
|
+ lampPoleDevCount.setLampPoleCount(0);
|
|
|
+ lampPoleDevCount.setCloudCount(0);
|
|
|
+ lampPoleDevCount.setBroadcastCount(0);
|
|
|
+ lampPoleDevCount.setVideoCount(0);
|
|
|
+ lampPoleDevCount.setWeatherCount(0);
|
|
|
+ lampPoleDevCount.setEmCount(0);
|
|
|
+ lampPoleDevCount.setChargeCount(0);
|
|
|
+ lampPoleDevCount.setScreenCount(0);
|
|
|
+ lampPoleDevCount.setLampPoleAlarmCount(0);
|
|
|
+ return toolUtils.response(InterfaceResultEnum.OPERATION_SUCCESS,version,lampPoleDevCount);
|
|
|
+ }
|
|
|
LampInfoDTO lampInfoDTO = new LampInfoDTO();
|
|
|
lampInfoDTO.setSectionList(sectionList);
|
|
|
LampInfoLogNewDTO sumEleByDTO = lampInfoLogNewService.getSumEleByDTO(lampInfoDTO);
|
|
@@ -65,7 +103,7 @@ public class BasePlatformController {
|
|
|
Integer lampPoleCount = lampPoleService.getLampPoleInstallTotal(lampPoleVO); // 灯杆总数
|
|
|
LampPoleDTO lampPoleDTO = new LampPoleDTO();
|
|
|
lampPoleDTO.setSectionList(sectionList);
|
|
|
- LampPoleInfoVO lampPoleDevCount = lampPoleService.getLampPoleDevCount(lampPoleDTO);
|
|
|
+ lampPoleDevCount = lampPoleService.getLampPoleDevCount(lampPoleDTO);
|
|
|
lampPoleDevCount.setCarRoadCount(0); // 车路协同数量
|
|
|
lampPoleDevCount.setTrafficLightCount(0); // 交通灯数量
|
|
|
lampPoleDevCount.setFiveGCount(0); // 5G基站数量
|
|
@@ -99,6 +137,27 @@ public class BasePlatformController {
|
|
|
Integer version = (Integer) toolUtils.getRequestContent(request, "version", 1);
|
|
|
String username = (String) toolUtils.getRequestContent(request, "username", 2);
|
|
|
List<?> sectionList = toolUtils.getSectionList(request);
|
|
|
+ LampPoleInfoVO lampPoleDevCount = null;
|
|
|
+ if (sectionList == null || sectionList.size() == 0){
|
|
|
+ lampPoleDevCount = new LampPoleInfoVO();
|
|
|
+ lampPoleDevCount.setLampPoleCount(0);
|
|
|
+ lampPoleDevCount.setCloudCount(0);
|
|
|
+ lampPoleDevCount.setBroadcastCount(0);
|
|
|
+ lampPoleDevCount.setVideoCount(0);
|
|
|
+ lampPoleDevCount.setWeatherCount(0);
|
|
|
+ lampPoleDevCount.setEmCount(0);
|
|
|
+ lampPoleDevCount.setChargeCount(0);
|
|
|
+ lampPoleDevCount.setScreenCount(0);
|
|
|
+ lampPoleDevCount.setTrafficLightCount(0);
|
|
|
+ lampPoleDevCount.setLampPoleAlarmCount(0);
|
|
|
+ lampPoleDevCount.setTotalCom(0F);
|
|
|
+ lampPoleDevCount.setTotalSave(0F);
|
|
|
+ lampPoleDevCount.setActionList(new ArrayList<>());
|
|
|
+ lampPoleDevCount.setAlarmList(new ArrayList<>());
|
|
|
+ lampPoleDevCount.setLampPoleList(new ArrayList<>());
|
|
|
+ return toolUtils.response(InterfaceResultEnum.OPERATION_SUCCESS,version,lampPoleDevCount);
|
|
|
+ }
|
|
|
+
|
|
|
LampInfoDTO lampInfoDTO = new LampInfoDTO();
|
|
|
lampInfoDTO.setSectionList(sectionList);
|
|
|
LampInfoLogNewDTO sumEleByDTO = lampInfoLogNewService.getSumEleByDTO(lampInfoDTO);
|
|
@@ -108,7 +167,7 @@ public class BasePlatformController {
|
|
|
Integer lampPoleCount = lampPoleService.getLampPoleInstallTotal(lampPoleVO); // 灯杆总数
|
|
|
LampPoleDTO lampPoleDTO = new LampPoleDTO();
|
|
|
lampPoleDTO.setSectionList(sectionList);
|
|
|
- LampPoleInfoVO lampPoleDevCount = lampPoleService.getLampPoleDevCount(lampPoleDTO);
|
|
|
+ lampPoleDevCount = lampPoleService.getLampPoleDevCount(lampPoleDTO);
|
|
|
lampPoleDevCount.setCarRoadCount(0); // 车路协同数量
|
|
|
lampPoleDevCount.setTrafficLightCount(0); // 交通灯数量
|
|
|
lampPoleDevCount.setFiveGCount(0); // 5G基站数量
|
|
@@ -134,30 +193,56 @@ public class BasePlatformController {
|
|
|
UserDTO userDTO = userService.queryUserIdByUsername(username);
|
|
|
if (userDTO == null) return toolUtils.response(InterfaceResultEnum.PARAM_FAIL,version);
|
|
|
OperationLogVO operationLogVO = new OperationLogVO();
|
|
|
- operationLogVO.setUserId(userDTO.getId());
|
|
|
- operationLogVO.setRole(userDTO.getRole());
|
|
|
+ operationLogVO.setSectionList(sectionList);
|
|
|
List<OperationLogDTO> logList = operationLogService.getLessOperationLogList(operationLogVO);
|
|
|
lampPoleDevCount.setActionList(logList);
|
|
|
|
|
|
// 故障列表
|
|
|
+ String[] alamDevArr = {"路灯","摄像头","云盒","RFID","LED屏","一键报警","充电桩","气象站","微基站","广播音柱"};
|
|
|
List<LampPoleDTO> lampPoleAlarmInfoList = lampPoleService.getLampPoleAlarmInfoList(lampPoleVO);
|
|
|
+ SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
+ for (LampPoleDTO dto:lampPoleAlarmInfoList) {
|
|
|
+ if (dto.getDType() != null){
|
|
|
+ dto.setContent(alamDevArr[dto.getDType()]+dto.getContent());
|
|
|
+ }
|
|
|
+ Date cmdTime = null;
|
|
|
+ try {
|
|
|
+ cmdTime = simpleDateFormat.parse(dto.getUpdateTime());
|
|
|
+ } catch (ParseException e) {
|
|
|
+ throw new RuntimeException(e);
|
|
|
+ }
|
|
|
+ long timeStamp = cmdTime.getTime() + dto.getTimezone() * 3600 * 1000;
|
|
|
+ String newUpdateTime = simpleDateFormat.format(new Date(timeStamp));
|
|
|
+ dto.setUpdateTime(newUpdateTime);
|
|
|
+ dto.setTimezone(null);
|
|
|
+ dto.setDType(null);
|
|
|
+ }
|
|
|
lampPoleDevCount.setAlarmList(lampPoleAlarmInfoList);
|
|
|
|
|
|
// 灯杆列表
|
|
|
List<LampPoleDTO> list = lampPoleService.getNewLampPoleList3(lampPoleVO);
|
|
|
+ List<Integer> lampPoleIds = new ArrayList<>();
|
|
|
for (LampPoleDTO dto : list) {
|
|
|
- if (dto.getDevType() != null && !dto.getDevType().isEmpty()) {
|
|
|
- String devType = dto.getDevType();
|
|
|
- int length = devType.split(",").length;
|
|
|
- dto.setDevCount(length);
|
|
|
- } else {
|
|
|
- dto.setDevCount(0);
|
|
|
+ lampPoleIds.add(dto.getId());
|
|
|
+ }
|
|
|
+ List<LampPoleDTO> tempList = new ArrayList<>();
|
|
|
+ if (lampPoleIds != null || lampPoleIds.size() != 0){
|
|
|
+ List<LampPoleDTO> alarmList = lampPoleService.getPoleAlarmLogList(lampPoleIds);
|
|
|
+ for (LampPoleDTO dto:alarmList) {
|
|
|
+ tempList.add(dto.getLampPoleId(),dto);
|
|
|
}
|
|
|
- if (dto.getAlarmStatus() != null && dto.getAlarmStatus() == 2) {
|
|
|
- dto.setStatus(0);
|
|
|
- } else if (dto.getAlarmStatus() != null && dto.getAlarmStatus() != 2) {
|
|
|
- dto.setStatus(1);
|
|
|
+ }
|
|
|
+ for (LampPoleDTO dto : list) {
|
|
|
+ lampPoleIds.add(dto.getId());
|
|
|
+ if (tempList != null && tempList.size() != 0 && tempList.get(dto.getId()) != null){
|
|
|
+ dto.setLampPoleId(tempList.get(dto.getId()).getId());
|
|
|
+ dto.setDevType2(tempList.get(dto.getId()).getDevType());
|
|
|
+ }else {
|
|
|
+ dto.setLampPoleId(0);
|
|
|
+ dto.setDevType2("0");
|
|
|
}
|
|
|
+ String[] devTypeList = dto.getDevType().split(",");
|
|
|
+ dto.setDevCount(devTypeList.length);
|
|
|
}
|
|
|
lampPoleDevCount.setLampPoleList(list);
|
|
|
return toolUtils.response(InterfaceResultEnum.OPERATION_SUCCESS,version,lampPoleDevCount);
|
|
@@ -173,109 +258,301 @@ public class BasePlatformController {
|
|
|
Integer version = (Integer) toolUtils.getRequestContent(request, "version", 1);
|
|
|
Integer id = (Integer) toolUtils.getRequestContent(request, "id", 1);
|
|
|
if (id == null) return toolUtils.response(InterfaceResultEnum.LACK_PARAM_ERROR,version);
|
|
|
-
|
|
|
- // 故障列表
|
|
|
- List<LampPoleDTO> alarmList = lampPoleService.getLampPoleAlarmListByLampPoleId(id);
|
|
|
- // 灯控列表
|
|
|
- List<LampPoleDTO> lampList = lampPoleService.getLampListByLampPoleId(id);
|
|
|
- // 灯杆详情
|
|
|
- LampPoleDTO dto = lampPoleService.getNewLampPoleDetailsById(id);
|
|
|
- if (dto == null) return toolUtils.response(InterfaceResultEnum.PARAM_FAIL,version);
|
|
|
+ List<LampInfoDTO> lampJoinLogList = lampService.getLampJoinLogList(id);
|
|
|
|
|
|
LampPoleDetailVO lampPoleDetailVO = new LampPoleDetailVO();
|
|
|
- // 气象信息
|
|
|
- String longitude = dto.getLongitude();
|
|
|
- String latitude = dto.getLatitude();
|
|
|
- WeatherDTO weatherInfo = WeatherUtil.getNowWeatherInfo(longitude, latitude);
|
|
|
- lampPoleDetailVO.setWeatherInfo(weatherInfo);
|
|
|
- // 音柱当前播放的节目
|
|
|
- lampPoleDetailVO.setBroadcastPro(dto.getBroadcastPro());
|
|
|
- // 音柱当前播放节目的id
|
|
|
- lampPoleDetailVO.setProgramId(dto.getProgramId());
|
|
|
- // 音柱id
|
|
|
- lampPoleDetailVO.setBroadcastId(dto.getBroadcastId());
|
|
|
- // 当天流量
|
|
|
- lampPoleDetailVO.setDayFlow(dto.getDayFlow());
|
|
|
- // 故障列表
|
|
|
- lampPoleDetailVO.setAlarmList(alarmList);
|
|
|
- // 灯控列表
|
|
|
- lampPoleDetailVO.setLampList(lampList);
|
|
|
- // 摄像头
|
|
|
- VideoMonitorDTO videoMonitorDTO = new VideoMonitorDTO();
|
|
|
- videoMonitorDTO.setId(dto.getVideoId());
|
|
|
- videoMonitorDTO.setVideoAddress(dto.getVideoAddress());
|
|
|
- lampPoleDetailVO.setVideo(videoMonitorDTO);
|
|
|
- // 屏幕
|
|
|
- ScreenDTO screenDTO = new ScreenDTO();
|
|
|
- screenDTO.setId(dto.getScreenId());
|
|
|
- screenDTO.setName(dto.getProgramName());
|
|
|
- screenDTO.setStatus(dto.getScreenStatus());
|
|
|
- screenDTO.setLight(dto.getLight());
|
|
|
- screenDTO.setVolume(dto.getVolume());
|
|
|
- screenDTO.setMaxLight(dto.getMaxLight());
|
|
|
- screenDTO.setPlayingId(dto.getPlayingId());
|
|
|
- screenDTO.setScreenImage(dto.getImage());
|
|
|
- lampPoleDetailVO.setScreen(screenDTO);
|
|
|
- // 充电桩
|
|
|
- ChargeDTO chargeDTO = new ChargeDTO();
|
|
|
- chargeDTO.setOnline(dto.getChargeOnline());
|
|
|
- chargeDTO.setStatus(dto.getChargeStatus());
|
|
|
- chargeDTO.setEquipmentElectricity(dto.getEquipmentElectricity());
|
|
|
- if (dto.getBillAmt() != null) {
|
|
|
- chargeDTO.setBillAmt(Float.parseFloat(dto.getBillAmt()));
|
|
|
+ if (lampJoinLogList == null || lampJoinLogList.size() == 0){
|
|
|
+ lampPoleDetailVO.setLampList(new ArrayList<>());
|
|
|
+ lampPoleDetailVO.setVideo(new VideoMonitorDTO());
|
|
|
+ lampPoleDetailVO.setScreen(new ScreenDTO());
|
|
|
+ lampPoleDetailVO.setWeatherInfo(new WeatherDTO());
|
|
|
+ lampPoleDetailVO.setDayFlow("0");
|
|
|
+ lampPoleDetailVO.setCharge(new ChargeDTO());
|
|
|
+ lampPoleDetailVO.setBroadcastId(0);
|
|
|
+ lampPoleDetailVO.setProgramId(0);
|
|
|
+ lampPoleDetailVO.setAlarmList(new ArrayList<>());
|
|
|
+ WifiInfoLogVO wifiInfoLogVO = new WifiInfoLogVO();
|
|
|
+ wifiInfoLogVO.setDate(new ArrayList<>());
|
|
|
+ wifiInfoLogVO.setFlow(new ArrayList<>());
|
|
|
+ lampPoleDetailVO.setFlowList(wifiInfoLogVO);
|
|
|
+ if (version == 0){
|
|
|
+ lampPoleDetailVO.setBroadcastPro("暂无节目");
|
|
|
+ } else if (version == 1) {
|
|
|
+ lampPoleDetailVO.setBroadcastPro("There are currently no programs available");
|
|
|
+ }else {
|
|
|
+ lampPoleDetailVO.setBroadcastPro("Нет программы");
|
|
|
+ }
|
|
|
+ lampPoleDetailVO.setIsPlay(0);
|
|
|
+ return toolUtils.response(InterfaceResultEnum.OPERATION_SUCCESS,version,lampPoleDetailVO);
|
|
|
+ }
|
|
|
+ for (LampInfoDTO dto:lampJoinLogList) {
|
|
|
+ //floor($lamp_info['workTimeTotal']/60).':'.substr('00'.$lamp_info['workTimeTotal']%60, -2);
|
|
|
+ Integer i = Integer.valueOf(dto.getWorkTimeTotal()) / 60;
|
|
|
+ String str = "00" + String.valueOf(Integer.valueOf(dto.getWorkTimeTotal()) % 60);
|
|
|
+ String substring = str.substring(str.length() - 2);
|
|
|
+ dto.setWorkTimeTotal(substring);
|
|
|
+ if (dto.getPolicyType() == 1){
|
|
|
+ PolicyDTO policy = policyService.getPolicyDTOById(dto.getPolicyId());
|
|
|
+ if (policy != null){
|
|
|
+ dto.setPolicyName(policy.getName());
|
|
|
+ }else {
|
|
|
+ if (version == 0){
|
|
|
+ dto.setPolicyName("暂无策略");
|
|
|
+ } else if (version == 1) {
|
|
|
+ dto.setPolicyName("No strategy at the moment");
|
|
|
+ }else {
|
|
|
+ dto.setPolicyName("Нет стратегии");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ if (version == 0){
|
|
|
+ dto.setPolicyName("暂无策略");
|
|
|
+ } else if (version == 1) {
|
|
|
+ dto.setPolicyName("No strategy at the moment");
|
|
|
+ }else {
|
|
|
+ dto.setPolicyName("Нет стратегии");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ lampPoleDetailVO.setLampList(lampJoinLogList);
|
|
|
+ //摄像头
|
|
|
+ VideoMonitorDTO monitorDTO = videoMonitorService.geteMonitorData(id);
|
|
|
+ if (monitorDTO != null){
|
|
|
+ String gbPlayAddress = toolUtils.getGbPlayAddress(monitorDTO.getGbAddress(), null, null, null);
|
|
|
+ monitorDTO.setVideoAddress(gbPlayAddress);
|
|
|
+ lampPoleDetailVO.setVideo(monitorDTO);
|
|
|
+ }else {
|
|
|
+ lampPoleDetailVO.setVideo(new VideoMonitorDTO());
|
|
|
}
|
|
|
- lampPoleDetailVO.setCharge(chargeDTO);
|
|
|
- // 流量列表
|
|
|
- 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;
|
|
|
+ //屏幕
|
|
|
+ ScreenDTO oneScreen = screenService.getOneScreenByLampPoleId(id);
|
|
|
+ if (oneScreen != null){
|
|
|
+ oneScreen.setName("");
|
|
|
+ oneScreen.setScreenImage("");
|
|
|
+ if (oneScreen.getType() == 1) oneScreen.setName("气象站");
|
|
|
+ if (oneScreen.getType() == 0){
|
|
|
+ ProgramDTO oneProgram = programService.getOneProgram(oneScreen.getPlayingId());
|
|
|
+ if (oneProgram != null) oneScreen.setName(oneProgram.getName());
|
|
|
+ }
|
|
|
+ String path = "/upload/image/"+oneScreen.getNum()+".png";
|
|
|
|
|
|
- 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++;
|
|
|
+ String rootPath = System.getProperty("user.dir");
|
|
|
+ int lastedIndex = rootPath.lastIndexOf("/");
|
|
|
+ rootPath = rootPath.substring(0,lastedIndex); //工程根目录
|
|
|
+
|
|
|
+ String filePath = rootPath+path;
|
|
|
+ Path p = Paths.get(filePath);
|
|
|
+ if (Files.exists(p)) oneScreen.setScreenImage(path);
|
|
|
+ lampPoleDetailVO.setScreen(oneScreen);
|
|
|
+ }else {
|
|
|
+ lampPoleDetailVO.setScreen(new ScreenDTO());
|
|
|
}
|
|
|
|
|
|
- int dayNumber = 1;
|
|
|
- WifiInfoLogDTO wifiInfoLogDTO = new WifiInfoLogDTO();
|
|
|
- wifiInfoLogDTO.setDayNum(7);
|
|
|
- wifiInfoLogDTO.setDayNumber(dayNumber);
|
|
|
- wifiInfoLogDTO.setLampPoleId(id);
|
|
|
- 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);
|
|
|
+ //wifi
|
|
|
+ WifiDTO wifi = wifiService.getWifiByLampPoleId(id);
|
|
|
+ if (wifi != null){
|
|
|
+ // 获取当前时间
|
|
|
+ SimpleDateFormat fitDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
+ // 获取当前时间
|
|
|
+ Date now = new Date();
|
|
|
+ // 计算当前时间戳
|
|
|
+ long currentTimeMillis = now.getTime();
|
|
|
+ // 计算昨天和今天的开始和结束时间
|
|
|
+ long seconds = currentTimeMillis ;
|
|
|
+ Date startDate = new Date(seconds - 8 * 3600 * 1000 - 7 * 24 * 3600 * 1000);
|
|
|
+ Date endDate = new Date(seconds - 8 * 3600 * 1000);
|
|
|
+
|
|
|
+ // 打印结果
|
|
|
+ String startDateStr = fitDateFormat.format(startDate);
|
|
|
+ String endDateStr = fitDateFormat.format(endDate);
|
|
|
+
|
|
|
+
|
|
|
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
+ HashMap<String, HashMap<String, Integer>> shaMap = new HashMap<>();
|
|
|
+ for (int i = 0; i < 7; i++){
|
|
|
+ String in = sdf.format(new Date(seconds - i * 24 * 3600 * 1000));
|
|
|
+ HashMap<String, Integer> ObjectHashMap = new HashMap<>();
|
|
|
+ ObjectHashMap.put("max",0);
|
|
|
+ ObjectHashMap.put("min",0);
|
|
|
+ shaMap.put(in,ObjectHashMap);
|
|
|
+ }
|
|
|
+ HashMap<String, Object> flowMap = new HashMap<>();
|
|
|
+ flowMap.put("id",wifi.getId());
|
|
|
+ flowMap.put("startdate",startDateStr);
|
|
|
+ flowMap.put("enddate",endDateStr);
|
|
|
+
|
|
|
+ List<WifiInfoLogDTO> wifiLogList = wifiInfoLogService.getWifiLog(flowMap);
|
|
|
+ for (WifiInfoLogDTO dto:wifiLogList) {
|
|
|
+ Date updateParse = fitDateFormat.parse(dto.getUpdateTime());
|
|
|
+ long updateSta = updateParse.getTime() + 8 * 3600 * 1000;
|
|
|
+ String in = sdf.format(new Date(updateSta));
|
|
|
+ if (shaMap.get(in) != null){
|
|
|
+ shaMap.get(in).put("min",Integer.valueOf(dto.getTotalCom()));
|
|
|
+ if (shaMap.get(in).get("max") == 0){
|
|
|
+ shaMap.get(in).put("max",Integer.valueOf(dto.getTotalCom()));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ HashMap<String,Object> flowHashMap = new HashMap<String,Object>();
|
|
|
+ ArrayList<Object> dateList = new ArrayList<>();
|
|
|
+ ArrayList<Object> flowList = new ArrayList<>();
|
|
|
+ SimpleDateFormat dateFormat1 = new SimpleDateFormat("MM-dd");
|
|
|
+
|
|
|
+ // 创建一个List来存储HashMap的key
|
|
|
+ ArrayList<String> keys = new ArrayList<>();
|
|
|
+ // 遍历HashMap,将key添加到List中
|
|
|
+ for (Map.Entry<String, HashMap<String,Integer>> entry : shaMap.entrySet()) {
|
|
|
+ keys.add(entry.getKey());
|
|
|
+ }
|
|
|
+ // 使用Collections.sort()方法对List进行排序
|
|
|
+ SimpleDateFormat sdformat = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
+ Collections.sort(keys);
|
|
|
+ // 按照排序后的顺序获取List中的key
|
|
|
+ for (String key : keys) {
|
|
|
+ //System.out.println(key);
|
|
|
+ String time = dateFormat1.format(sdformat.parse(key));
|
|
|
+ dateList.add(time);
|
|
|
+ HashMap<String, Integer> stringIntegerHashMap = shaMap.get(key);
|
|
|
+ Integer max = stringIntegerHashMap.get("max");
|
|
|
+ Integer min = stringIntegerHashMap.get("min");
|
|
|
+ flowList.add(max > min ? max-min : 0);
|
|
|
}
|
|
|
+ WifiInfoLogVO wifiInfoLogVO = new WifiInfoLogVO();
|
|
|
+ wifiInfoLogVO.setDate(dateList);
|
|
|
+ wifiInfoLogVO.setFlow(flowList);
|
|
|
+ lampPoleDetailVO.setFlowList(wifiInfoLogVO);
|
|
|
+ }else {
|
|
|
+ WifiInfoLogVO wifiInfoLogVO = new WifiInfoLogVO();
|
|
|
+ wifiInfoLogVO.setDate(new ArrayList<>());
|
|
|
+ wifiInfoLogVO.setFlow(new ArrayList<>());
|
|
|
+ lampPoleDetailVO.setFlowList(wifiInfoLogVO);
|
|
|
+ }
|
|
|
+
|
|
|
+ //weather
|
|
|
+ LampPoleDTO localDataById = lampPoleService.getLocalDataById(id);
|
|
|
+ String urlStr = "https://devapi.heweather.net/v7/weather/3d?location="+localDataById.getLongitude()+","+localDataById.getLatitude()+"&key="+ToolUtils.WEATHER_KEY;
|
|
|
+
|
|
|
+ //String info = toolUtils.sendHttp("get", urlStr, null, 5, ToolUtils.ContentTypeEnum.CONTENT_TYPE_FORM, null);
|
|
|
+ String zlibNetwork = toolUtils.zlibNetwork(urlStr);
|
|
|
+ WeatherDTO weather = new WeatherDTO();
|
|
|
+ if (!zlibNetwork.isEmpty()){
|
|
|
+ JSONObject jsonObject = JSON.parseObject(zlibNetwork);
|
|
|
+ String code = jsonObject.getString("code");
|
|
|
+ if (code.equals("200")){
|
|
|
+
|
|
|
+ JSONArray jsonArray = jsonObject.getJSONArray("daily");
|
|
|
+ JSONObject o = (JSONObject)jsonArray.get(0);
|
|
|
+ weather.setTempMax(o.getString("tempMax"));
|
|
|
+ weather.setTempMin(o.getString("tempMin"));
|
|
|
+
|
|
|
+ String weatherUrl = "https://devapi.heweather.net/v7/weather/now?location="+localDataById.getLongitude()+","+localDataById.getLatitude()+"&key="+ToolUtils.WEATHER_KEY;
|
|
|
+ String weatherResult = toolUtils.zlibNetwork(weatherUrl);
|
|
|
+ if (!weatherResult.isEmpty()){
|
|
|
+ JSONObject weatherJsonObject = JSON.parseObject(weatherResult);
|
|
|
+ if (weatherJsonObject.get("now") != null){
|
|
|
+ String weatherCode = weatherJsonObject.getString("code");
|
|
|
+ if (weatherCode.equals("200")){
|
|
|
+ JSONObject w = (JSONObject)weatherJsonObject.get("now");
|
|
|
+ weather.setTemp(w.getString("temp"));
|
|
|
+ if (version == 0){
|
|
|
+ weather.setWeatherText(w.getString("text"));
|
|
|
+ } else if (version == 1) {
|
|
|
+ weather.setWeatherText(toolUtils.weatherTranslateEn(w.getString("icon")));
|
|
|
+ }else {
|
|
|
+ weather.setWeatherText(toolUtils.weatherTranslateRu(w.getString("icon")));
|
|
|
+ }
|
|
|
+ weather.setWeatherCode(w.getString("icon"));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ String airUrl = "https://devapi.heweather.net/v7/air/now?location="+localDataById.getLongitude()+","+localDataById.getLatitude()+"&key="+ToolUtils.WEATHER_KEY;
|
|
|
+ String airResult = toolUtils.zlibNetwork(airUrl);
|
|
|
+ if (!airResult.isEmpty()){
|
|
|
+ JSONObject airJsonObject = JSONObject.parseObject(airResult);
|
|
|
+ String airCode = airJsonObject.getString("code");
|
|
|
+ if (airCode.equals("200")){
|
|
|
+ JSONObject air = (JSONObject)airJsonObject.get("now");
|
|
|
+ if (air != null){
|
|
|
+ weather.setAqi(air.getString("aqi"));
|
|
|
+ weather.setCategory(air.getString("level"));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ lampPoleDetailVO.setWeatherInfo(weather);
|
|
|
+ }else {
|
|
|
+ lampPoleDetailVO.setWeatherInfo(new WeatherDTO());
|
|
|
+ }
|
|
|
+
|
|
|
+ //充电桩
|
|
|
+ ChargeDTO infoByLampPoleId = chargeService.getChargeInfoByLampPoleId(id);
|
|
|
+ if (infoByLampPoleId != null){
|
|
|
+ ChargeDTO chargeDTO = new ChargeDTO();
|
|
|
+ chargeDTO.setStatus(infoByLampPoleId.getStatus());
|
|
|
+ chargeDTO.setOnline(infoByLampPoleId.getOnline());
|
|
|
+ chargeDTO.setEquipmentElectricity(infoByLampPoleId.getEquipmentElectricity());
|
|
|
+ chargeDTO.setBillAmt(infoByLampPoleId.getBillAmt());
|
|
|
+ }else {
|
|
|
+ lampPoleDetailVO.setCharge(new ChargeDTO());
|
|
|
+ }
|
|
|
+
|
|
|
+ // 故障信息
|
|
|
+ String[] alamDevArr = {"路灯","摄像头","云盒","RFID","LED屏","一键报警","充电桩","气象站","微基站","广播音柱"};
|
|
|
+ LampPoleVO lampPoleVO = new LampPoleVO();
|
|
|
+ List<LampPoleDTO> lampPoleAlarmInfoList = lampPoleService.getLampPoleAlarmInfoList(lampPoleVO);
|
|
|
+ SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
+ for (LampPoleDTO dto:lampPoleAlarmInfoList) {
|
|
|
+ if (dto.getDType() != null){
|
|
|
+ dto.setContent(alamDevArr[dto.getDType()]+dto.getContent());
|
|
|
+ dto.setAlarmTypeStr(dto.getContent());
|
|
|
+ }
|
|
|
+ Date cmdTime = null;
|
|
|
+ try {
|
|
|
+ cmdTime = simpleDateFormat.parse(dto.getUpdateTime());
|
|
|
+ } catch (ParseException e) {
|
|
|
+ throw new RuntimeException(e);
|
|
|
+ }
|
|
|
+ long timeStamp = cmdTime.getTime() + dto.getTimezone() * 3600 * 1000;
|
|
|
+ String newUpdateTime = simpleDateFormat.format(new Date(timeStamp));
|
|
|
+ dto.setUpdateTime(newUpdateTime);
|
|
|
+ dto.setTimezone(null);
|
|
|
+ dto.setDType(null);
|
|
|
+ dto.setContent(null);
|
|
|
+ }
|
|
|
+ if (lampPoleAlarmInfoList != null && lampPoleAlarmInfoList.size() != 0){
|
|
|
+ lampPoleDetailVO.setAlarmList(lampPoleAlarmInfoList);
|
|
|
+ }else {
|
|
|
+ lampPoleDetailVO.setAlarmList(new ArrayList<>());
|
|
|
+ }
|
|
|
|
|
|
- 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)));
|
|
|
+ //广播
|
|
|
+ BroadcastDTO oneDataByLampPoleId = broadcastService.getOneDataByLampPoleId(id);
|
|
|
+ if (oneDataByLampPoleId != null){
|
|
|
+ //BroadcastDTO broadcastDTO = new BroadcastDTO();
|
|
|
+ lampPoleDetailVO.setIsPlay(oneDataByLampPoleId.getIsPlay());
|
|
|
+ lampPoleDetailVO.setBroadcastId(oneDataByLampPoleId.getId());
|
|
|
+ lampPoleDetailVO.setProgramId(oneDataByLampPoleId.getItemId());
|
|
|
+ if (oneDataByLampPoleId.getIsPlay() == 1){
|
|
|
+ if (oneDataByLampPoleId.getProId() != 0){
|
|
|
+ BroadcastProListDTO oneById = broadcastProListService.getOneById(oneDataByLampPoleId.getProId());
|
|
|
+ if (oneById != null){
|
|
|
+ lampPoleDetailVO.setBroadcastPro(oneById.getName());
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ if (oneDataByLampPoleId.getItemId() !=0 ){
|
|
|
+ BroadcastItemDTO oneDataById = broadcastItemService.getOneDataById(oneDataByLampPoleId.getItemId());
|
|
|
+ if (oneDataById != null){
|
|
|
+ lampPoleDetailVO.setBroadcastPro(oneDataById.getName());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
+ }else {
|
|
|
+ lampPoleDetailVO.setBroadcastPro("");
|
|
|
+ lampPoleDetailVO.setProgramId(0);
|
|
|
+ lampPoleDetailVO.setBroadcastId(0);
|
|
|
+ lampPoleDetailVO.setIsPlay(0);
|
|
|
}
|
|
|
- WifiInfoLogVO wifiInfoLogVO = new WifiInfoLogVO();
|
|
|
- wifiInfoLogVO.setDate(dateList);
|
|
|
- wifiInfoLogVO.setFlow(flowList);
|
|
|
- lampPoleDetailVO.setFlowList(wifiInfoLogVO);
|
|
|
return toolUtils.response(InterfaceResultEnum.OPERATION_SUCCESS,version,lampPoleDetailVO);
|
|
|
}
|
|
|
}
|