|
@@ -0,0 +1,281 @@
|
|
|
+package com.welampiot.controller;
|
|
|
+
|
|
|
+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;
|
|
|
+import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
+import org.springframework.web.bind.annotation.RequestMethod;
|
|
|
+import org.springframework.web.bind.annotation.RestController;
|
|
|
+
|
|
|
+import javax.servlet.http.HttpServletRequest;
|
|
|
+import java.text.DecimalFormat;
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.Date;
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+/**
|
|
|
+ * ClassName: BasePlatformController
|
|
|
+ * Package: com.welampiot.controller
|
|
|
+ * Description:
|
|
|
+ *
|
|
|
+ * @Author: zhj_Start
|
|
|
+ * @Create: 2023/9/6 - 16:10
|
|
|
+ * @Version: v1.0
|
|
|
+ */
|
|
|
+@RestController
|
|
|
+@CrossOrigin
|
|
|
+@RequestMapping("/basePlatform")
|
|
|
+public class BasePlatformController {
|
|
|
+ @Autowired
|
|
|
+ private ToolUtils toolUtils;
|
|
|
+ @Autowired
|
|
|
+ private LampPoleService lampPoleService;
|
|
|
+ @Autowired
|
|
|
+ private LampInfoLogNewService lampInfoLogNewService;
|
|
|
+ @Autowired
|
|
|
+ private OperationLogService operationLogService;
|
|
|
+ @Autowired
|
|
|
+ private UserService userService;
|
|
|
+ @Autowired
|
|
|
+ private WifiInfoLogService wifiInfoLogService;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 基础平台全局概览
|
|
|
+ * @param request sectionList
|
|
|
+ * @return 全局概览
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "/data", method = RequestMethod.POST)
|
|
|
+ public BaseResult<?> data(HttpServletRequest request) {
|
|
|
+ Integer version = (Integer) toolUtils.getRequestContent(request, "version", 1);
|
|
|
+ List<?> sectionList = toolUtils.getSectionList(request);
|
|
|
+ LampInfoDTO lampInfoDTO = new LampInfoDTO();
|
|
|
+ lampInfoDTO.setSectionList(sectionList);
|
|
|
+ LampInfoLogNewDTO sumEleByDTO = lampInfoLogNewService.getSumEleByDTO(lampInfoDTO);
|
|
|
+ LampPoleVO lampPoleVO = new LampPoleVO();
|
|
|
+ lampPoleVO.setSectionList(sectionList);
|
|
|
+ Integer lampPoleAlarmTotal = lampPoleService.getLampPoleAlarmTotal(lampPoleVO); // 灯杆故障数
|
|
|
+ Integer lampPoleCount = lampPoleService.getLampPoleInstallTotal(lampPoleVO); // 灯杆总数
|
|
|
+ LampPoleDTO lampPoleDTO = new LampPoleDTO();
|
|
|
+ lampPoleDTO.setSectionList(sectionList);
|
|
|
+ LampPoleInfoVO lampPoleDevCount = lampPoleService.getLampPoleDevCount(lampPoleDTO);
|
|
|
+ lampPoleDevCount.setCarRoadCount(0); // 车路协同数量
|
|
|
+ lampPoleDevCount.setTrafficLightCount(0); // 交通灯数量
|
|
|
+ lampPoleDevCount.setFiveGCount(0); // 5G基站数量
|
|
|
+ lampPoleDevCount.setScreenCount(lampPoleDevCount.getLedCount()); // 屏幕数量
|
|
|
+ lampPoleDevCount.setEmCount(lampPoleDevCount.getOneKeyCount()); // 一键报警数量
|
|
|
+ lampPoleDevCount.setLampPoleAlarmCount(lampPoleAlarmTotal); // 故障数
|
|
|
+ lampPoleDevCount.setLampPoleCount(lampPoleCount); // 灯杆数
|
|
|
+ lampPoleDevCount.setCloudCount(lampPoleDevCount.getWifiCount()); // 云盒数
|
|
|
+ DecimalFormat decimalFormat = new DecimalFormat("0.00");
|
|
|
+ if (sumEleByDTO == null) { // 累计用电量、累计省电量
|
|
|
+ lampPoleDevCount.setTotalCom(0f);
|
|
|
+ lampPoleDevCount.setTotalSave(0f);
|
|
|
+ } else {
|
|
|
+ String totalEleSave = sumEleByDTO.getSumTotalEleSave();
|
|
|
+ String totalEle = sumEleByDTO.getSumTotalGeneraEnergy();
|
|
|
+ String save = decimalFormat.format(Float.parseFloat(totalEleSave));
|
|
|
+ String ele = decimalFormat.format(Float.parseFloat(totalEle));
|
|
|
+ lampPoleDevCount.setTotalCom(Float.parseFloat(save));
|
|
|
+ lampPoleDevCount.setTotalSave(Float.parseFloat(ele));
|
|
|
+ }
|
|
|
+ return toolUtils.response(InterfaceResultEnum.OPERATION_SUCCESS,version,lampPoleDevCount);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 基础平台智慧合杆
|
|
|
+ * @param request sectionList
|
|
|
+ * @return 智慧合杆
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "/lampPoleData", method = RequestMethod.POST)
|
|
|
+ public BaseResult<?> lampPoleData(HttpServletRequest request) {
|
|
|
+ Integer version = (Integer) toolUtils.getRequestContent(request, "version", 1);
|
|
|
+ String username = (String) toolUtils.getRequestContent(request, "username", 2);
|
|
|
+ List<?> sectionList = toolUtils.getSectionList(request);
|
|
|
+ LampInfoDTO lampInfoDTO = new LampInfoDTO();
|
|
|
+ lampInfoDTO.setSectionList(sectionList);
|
|
|
+ LampInfoLogNewDTO sumEleByDTO = lampInfoLogNewService.getSumEleByDTO(lampInfoDTO);
|
|
|
+ LampPoleVO lampPoleVO = new LampPoleVO();
|
|
|
+ lampPoleVO.setSectionList(sectionList);
|
|
|
+ Integer lampPoleAlarmTotal = lampPoleService.getLampPoleAlarmTotal(lampPoleVO); // 灯杆故障数
|
|
|
+ Integer lampPoleCount = lampPoleService.getLampPoleInstallTotal(lampPoleVO); // 灯杆总数
|
|
|
+ LampPoleDTO lampPoleDTO = new LampPoleDTO();
|
|
|
+ lampPoleDTO.setSectionList(sectionList);
|
|
|
+ LampPoleInfoVO lampPoleDevCount = lampPoleService.getLampPoleDevCount(lampPoleDTO);
|
|
|
+ lampPoleDevCount.setCarRoadCount(0); // 车路协同数量
|
|
|
+ lampPoleDevCount.setTrafficLightCount(0); // 交通灯数量
|
|
|
+ lampPoleDevCount.setFiveGCount(0); // 5G基站数量
|
|
|
+ lampPoleDevCount.setScreenCount(lampPoleDevCount.getLedCount()); // 屏幕数量
|
|
|
+ lampPoleDevCount.setEmCount(lampPoleDevCount.getOneKeyCount()); // 一键报警数量
|
|
|
+ lampPoleDevCount.setLampPoleAlarmCount(lampPoleAlarmTotal); // 故障数
|
|
|
+ lampPoleDevCount.setLampPoleCount(lampPoleCount); // 灯杆数
|
|
|
+ lampPoleDevCount.setCloudCount(lampPoleDevCount.getWifiCount()); // 云盒数
|
|
|
+ DecimalFormat decimalFormat = new DecimalFormat("0.00");
|
|
|
+ if (sumEleByDTO == null) { // 累计用电量、累计省电量
|
|
|
+ lampPoleDevCount.setTotalCom(0f);
|
|
|
+ lampPoleDevCount.setTotalSave(0f);
|
|
|
+ } else {
|
|
|
+ String totalEleSave = sumEleByDTO.getSumTotalEleSave();
|
|
|
+ String totalEle = sumEleByDTO.getSumTotalGeneraEnergy();
|
|
|
+ String save = decimalFormat.format(Float.parseFloat(totalEleSave));
|
|
|
+ String ele = decimalFormat.format(Float.parseFloat(totalEle));
|
|
|
+ lampPoleDevCount.setTotalCom(Float.parseFloat(save));
|
|
|
+ lampPoleDevCount.setTotalSave(Float.parseFloat(ele));
|
|
|
+ }
|
|
|
+
|
|
|
+ // 事件监控
|
|
|
+ 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());
|
|
|
+ List<OperationLogDTO> logList = operationLogService.getLessOperationLogList(operationLogVO);
|
|
|
+ lampPoleDevCount.setActionList(logList);
|
|
|
+
|
|
|
+ // 故障列表
|
|
|
+ List<LampPoleDTO> lampPoleAlarmInfoList = lampPoleService.getLampPoleAlarmInfoList(lampPoleVO);
|
|
|
+ lampPoleDevCount.setAlarmList(lampPoleAlarmInfoList);
|
|
|
+
|
|
|
+ // 灯杆列表
|
|
|
+ List<LampPoleDTO> list = lampPoleService.getNewLampPoleList3(lampPoleVO);
|
|
|
+ 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);
|
|
|
+ }
|
|
|
+ if (dto.getAlarmStatus() != null && dto.getAlarmStatus() == 2) {
|
|
|
+ dto.setStatus(0);
|
|
|
+ } else if (dto.getAlarmStatus() != null && dto.getAlarmStatus() != 2) {
|
|
|
+ dto.setStatus(1);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ lampPoleDevCount.setLampPoleList(list);
|
|
|
+ return toolUtils.response(InterfaceResultEnum.OPERATION_SUCCESS,version,lampPoleDevCount);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 基础平台灯杆详情
|
|
|
+ * @param request id
|
|
|
+ * @return 灯杆详情
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "/lampPoleDetails", method = RequestMethod.POST)
|
|
|
+ public BaseResult<?> lampPoleDetails(HttpServletRequest request) throws Exception {
|
|
|
+ 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);
|
|
|
+
|
|
|
+ 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 * 14;
|
|
|
+ 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(dto.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);
|
|
|
+ }
|
|
|
+}
|