|
@@ -5,7 +5,6 @@ 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 +13,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 +46,19 @@ 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;
|
|
|
+
|
|
|
|
|
|
/**
|
|
|
* 基础平台全局概览
|
|
@@ -56,6 +69,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 +92,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 +126,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 +156,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 +182,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 +247,316 @@ 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("Нет программы");
|
|
|
+ }
|
|
|
+
|
|
|
+ return toolUtils.response(InterfaceResultEnum.OPERATION_SUCCESS,version,lampPoleDetailVO);
|
|
|
}
|
|
|
- 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;
|
|
|
+ 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());
|
|
|
+ }
|
|
|
+ //屏幕
|
|
|
+ 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");
|
|
|
|
|
|
- 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)));
|
|
|
+ // 创建一个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);
|
|
|
}
|
|
|
- WifiInfoLogVO wifiInfoLogVO = new WifiInfoLogVO();
|
|
|
- wifiInfoLogVO.setDate(dateList);
|
|
|
- wifiInfoLogVO.setFlow(flowList);
|
|
|
- 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);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ // $weather_info = file_get_contents("compress.zlib://".$url);
|
|
|
+// $weather_info = json_decode($weather_info,true);
|
|
|
+
|
|
|
+
|
|
|
+// if (!empty($res)) {
|
|
|
+// $enddate = date('Y-m-d H:00:00',time()-8*3600);
|
|
|
+// $startdate = date('Y-m-d H:00:00',time()-8*3600-7*24*3600);
|
|
|
+// $data['day_flow'] = $res['day_flow'];
|
|
|
+// $temp_list = [];
|
|
|
+// for ($i=0; $i < 7; $i++) {
|
|
|
+// $in = date('Y-m-d',time()-$i*24*3600);
|
|
|
+// $temp_list[$in] = ['max'=>0,'min'=>0];
|
|
|
+// }
|
|
|
+// $flow_list = $this->db->query('select total_com,updatetime from wifi_info_log where id = '.$res['id'].' and updatetime >= "'.$startdate.'" and updatetime <= "'.$enddate.'" order by updatetime desc')->result_array();
|
|
|
+// foreach ($flow_list as $key => $value) {
|
|
|
+// $in = date('Y-m-d',strtotime($value['updatetime'])+8*3600);
|
|
|
+// if (isset($temp_list[$in])) {
|
|
|
+// $temp_list[$in]['min'] = $value['total_com'];
|
|
|
+// if ($temp_list[$in]['max'] == 0) {
|
|
|
+// $temp_list[$in]['max'] = $value['total_com'];
|
|
|
+// }
|
|
|
+// }
|
|
|
+// }
|
|
|
+// $temp_list = array_reverse($temp_list);
|
|
|
+// foreach ($temp_list as $key => $value) {
|
|
|
+// $data['flow_list']['date'][] = date('m-d',strtotime($key));
|
|
|
+// $data['flow_list']['flow'][] = $value['max'] > $value['min'] ? $value['max'] - $value['min'] : 0;
|
|
|
+// }
|
|
|
+// }
|
|
|
+
|
|
|
+ // 故障列表
|
|
|
+// 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);
|
|
|
+//
|
|
|
+//// 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()));
|
|
|
+// }
|
|
|
+// 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;
|
|
|
+//
|
|
|
+// 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++;
|
|
|
+// }
|
|
|
+//
|
|
|
+// 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);
|
|
|
+// }
|
|
|
+//
|
|
|
+// 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)));
|
|
|
+// }
|
|
|
+// }
|
|
|
+// WifiInfoLogVO wifiInfoLogVO = new WifiInfoLogVO();
|
|
|
+// wifiInfoLogVO.setDate(dateList);
|
|
|
+// wifiInfoLogVO.setFlow(flowList);
|
|
|
+// lampPoleDetailVO.setFlowList(wifiInfoLogVO);
|
|
|
return toolUtils.response(InterfaceResultEnum.OPERATION_SUCCESS,version,lampPoleDetailVO);
|
|
|
}
|
|
|
}
|