|
@@ -1,5 +1,7 @@
|
|
|
package com.welampiot.controller;
|
|
|
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
import com.welampiot.common.BaseResult;
|
|
|
import com.welampiot.common.InterfaceResultEnum;
|
|
|
import com.welampiot.dto.*;
|
|
@@ -17,9 +19,7 @@ import javax.servlet.http.HttpServletRequest;
|
|
|
import java.text.DecimalFormat;
|
|
|
import java.text.ParseException;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
-import java.util.Calendar;
|
|
|
-import java.util.Date;
|
|
|
-import java.util.List;
|
|
|
+import java.util.*;
|
|
|
|
|
|
/**
|
|
|
* ClassName: NewLampPoleController2
|
|
@@ -58,6 +58,16 @@ public class NewLampPoleController2 {
|
|
|
private OperationLogService operationLogService;
|
|
|
@Autowired
|
|
|
private UserService userService;
|
|
|
+ @Autowired
|
|
|
+ private ScreenService screenService;
|
|
|
+ @Autowired
|
|
|
+ private EnvmonitorService envmonitorService;
|
|
|
+ @Autowired
|
|
|
+ private BroadcastService broadcastService;
|
|
|
+ @Autowired
|
|
|
+ private ManholeService manholeService;
|
|
|
+ @Autowired
|
|
|
+ private LightStripDevService lightStripDevService;
|
|
|
|
|
|
/**
|
|
|
* 智诺云智慧灯杆列表
|
|
@@ -130,6 +140,7 @@ public class NewLampPoleController2 {
|
|
|
|
|
|
// 获取报警列表
|
|
|
EmergencyInfoLogVO emergencyInfoLogVO = new EmergencyInfoLogVO();
|
|
|
+ emergencyInfoLogVO.setSectionList(toolUtils.getSectionList(request));
|
|
|
List<EmergencyInfoLogDTO> nowEmList = emergencyInfoLogService.getNowEmergencyInfoLogList(emergencyInfoLogVO);
|
|
|
List<EmergencyInfoLogDTO> hisEmList = emergencyInfoLogService.getHistoryEmergencyInfoLogList(emergencyInfoLogVO);
|
|
|
lampPoleDTO.setNowEmList(nowEmList);
|
|
@@ -512,4 +523,152 @@ public class NewLampPoleController2 {
|
|
|
}
|
|
|
return toolUtils.response(InterfaceResultEnum.OPERATION_SUCCESS,version,lampPoleDataVO);
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 智诺云设备组件
|
|
|
+ * @param request type,id,lampId
|
|
|
+ * @return 设备组件
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "/lampPoleData", method = RequestMethod.POST)
|
|
|
+ public BaseResult<?> lampPoleData(HttpServletRequest request) throws Exception {
|
|
|
+ Integer version = (Integer) toolUtils.getRequestContent(request, "version", 1);
|
|
|
+ Integer type = (Integer) toolUtils.getRequestContent(request, "type", 1);
|
|
|
+ Integer id = (Integer) toolUtils.getRequestContent(request, "id", 1);
|
|
|
+ Integer lampId = (Integer) toolUtils.getRequestContent(request, "lampId", 1);
|
|
|
+ if (id == 0) return toolUtils.response(InterfaceResultEnum.LACK_PARAM_ERROR,version);
|
|
|
+
|
|
|
+ LampPoleDataVO lampPoleDataVO = new LampPoleDataVO();
|
|
|
+ if (type == 0) { // 灯控组件
|
|
|
+ LampInfoDTO lampInfoDTO = lampService.getLampOfLampPoleById(id, lampId);
|
|
|
+
|
|
|
+ long startTime = System.currentTimeMillis() - 24L * 3600 * 1000 * 29;
|
|
|
+ long endTime = System.currentTimeMillis();
|
|
|
+ SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
+ DecimalFormat decimalFormat = new DecimalFormat("0.00");
|
|
|
+ String startDate = simpleDateFormat.format(startTime);
|
|
|
+ String endDate = simpleDateFormat.format(endTime);
|
|
|
+ LampInfoCacheByDayDTO dto = new LampInfoCacheByDayDTO();
|
|
|
+ dto.setLampPoleId(id);
|
|
|
+ dto.setStartDate(startDate);
|
|
|
+ dto.setEndDate(endDate);
|
|
|
+
|
|
|
+ List<Object> dateList = new ArrayList<>();
|
|
|
+ List<Object> eleList = new ArrayList<>();
|
|
|
+ List<Object> saveList = new ArrayList<>();
|
|
|
+ HashMap<String, Integer> objectObjectHashMap = new HashMap<>();
|
|
|
+ long timeT = startTime;
|
|
|
+ int i = 0;
|
|
|
+ while (timeT <= endTime) {
|
|
|
+ objectObjectHashMap.put(simpleDateFormat.format(new Date(timeT)), i);
|
|
|
+ dateList.add(simpleDateFormat.format(new Date(timeT)));
|
|
|
+ eleList.add(0);
|
|
|
+ saveList.add(0);
|
|
|
+ timeT += 3600 * 1000 * 24;
|
|
|
+ i++;
|
|
|
+ }
|
|
|
+
|
|
|
+ List<LampInfoCacheByDayDTO> list = lampInfoCacheByDayService.getNearSaveAndEleList(dto);
|
|
|
+ for (LampInfoCacheByDayDTO dayDTO : 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);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 用电量列表
|
|
|
+ if (dayDTO.getConSum() != null && !dayDTO.getConSum().equals("0") && integer != null) {
|
|
|
+ Float ele = Float.parseFloat(dto.getConSum());
|
|
|
+ eleList.set(integer,Float.parseFloat(decimalFormat.format(ele)));
|
|
|
+ }
|
|
|
+ // 省电量列表
|
|
|
+ if (dayDTO.getPowerSave() != null && !dayDTO.getPowerSave().equals("0") && integer != null) {
|
|
|
+ Float save = Float.parseFloat(dto.getPowerSave());
|
|
|
+ saveList.set(integer,Float.parseFloat(decimalFormat.format(save)));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ lampInfoDTO.setDateList(dateList);
|
|
|
+ lampInfoDTO.setEnergyList(eleList);
|
|
|
+ lampInfoDTO.setPowerSaveList(saveList);
|
|
|
+ lampPoleDataVO.setDataType("lampPoleDataLamp");
|
|
|
+ lampPoleDataVO.setLampData(lampInfoDTO);
|
|
|
+ } else if (type == 1) { // 摄像头
|
|
|
+ VideoMonitorDTO videoMonitorDTO = videoMonitorService.getVideoMonitorByLampPoleId(id);
|
|
|
+ lampPoleDataVO.setVideoData(videoMonitorDTO);
|
|
|
+ } else if (type == 2) { // wifi
|
|
|
+ WifiDTO wifiDTO = wifiService.getWifiByLampPoleId(id);
|
|
|
+ String sendTopic = "", resTopic = "";
|
|
|
+ if (wifiDTO.getModel() == 1 || wifiDTO.getModel() == 5) {
|
|
|
+ sendTopic = "/WEGW2/ReadIn/" + wifiDTO.getNum();
|
|
|
+ resTopic = "/WEGW2/ReadOut/" + wifiDTO.getNum();
|
|
|
+ } else if (wifiDTO.getModel() == 3 || wifiDTO.getModel() == 6) {
|
|
|
+ sendTopic = "/WEGW3/ReadIn/" + wifiDTO.getNum();
|
|
|
+ resTopic = "/WEGW3/ReadOut/" + wifiDTO.getNum();
|
|
|
+ } else if (wifiDTO.getModel() == 0) {
|
|
|
+ sendTopic = "/WEGW/ReadIn/" + wifiDTO.getNum();
|
|
|
+ resTopic = "/WEGW/ReadOut/" + wifiDTO.getNum();
|
|
|
+ }
|
|
|
+ String cmd = "0001B10B";
|
|
|
+ byte[] bytes = toolUtils.hexString2Bytes(cmd);
|
|
|
+ String resCmd = toolUtils.sendMqttCmd(sendTopic, bytes, resTopic);
|
|
|
+ String jsonStr ="{ " + resCmd.substring(bytes.length);
|
|
|
+ JSONObject jsonObject = JSONObject.parseObject(jsonStr);
|
|
|
+ JSONArray deviceList = jsonObject.getJSONArray("BB");
|
|
|
+ List<WifiDeviceDTO> list = new ArrayList<>();
|
|
|
+ for (Object o : deviceList) {
|
|
|
+ JSONObject deviceObject = JSONObject.parseObject(o.toString());
|
|
|
+ WifiDeviceDTO wifiDeviceDTO = JSONObject.toJavaObject(deviceObject, WifiDeviceDTO.class);
|
|
|
+ list.add(wifiDeviceDTO);
|
|
|
+ }
|
|
|
+ wifiDTO.setDeviceList(list);
|
|
|
+ lampPoleDataVO.setDataType("lampPoleDataWifi");
|
|
|
+ lampPoleDataVO.setWifiData(wifiDTO);
|
|
|
+ } else if (type == 4) { // 显示屏
|
|
|
+ ScreenDTO screenDTO = screenService.getScreenByLampPoleId(id);
|
|
|
+ if (screenDTO.getPlayingId() != null) {
|
|
|
+ screenDTO.setProId(screenDTO.getPlayingId());
|
|
|
+ }
|
|
|
+ if (screenDTO.getPlay() != null) {
|
|
|
+ screenDTO.setProName(screenDTO.getPlay());
|
|
|
+ }
|
|
|
+ } else if (type == 5) { // 一键报警
|
|
|
+ List<EmergencyInfoLogDTO> nowEmList = emergencyInfoLogService.getNowLogListByLampPoleId(id);
|
|
|
+ List<EmergencyInfoLogDTO> hisEmList = emergencyInfoLogService.getHisLogListByLampPoleId(id);
|
|
|
+ LampPoleDTO lampPoleDTO = new LampPoleDTO();
|
|
|
+ lampPoleDTO.setNowEmList(nowEmList);
|
|
|
+ lampPoleDTO.setHisEmList(hisEmList);
|
|
|
+ lampPoleDataVO.setDataType("lampPoleDataOneKey");
|
|
|
+ lampPoleDataVO.setOneKeyData(lampPoleDTO);
|
|
|
+ } else if (type == 6) { // 充电桩
|
|
|
+ ChargeDTO chargeDTO = chargeService.getChargeInfoByLampPoleId(id);
|
|
|
+ lampPoleDataVO.setDataType("lampPoleDataCharge");
|
|
|
+ lampPoleDataVO.setChargeData(chargeDTO);
|
|
|
+ } else if (type == 7) { // 气象站
|
|
|
+ EnvmonitorDTO envmonitor = envmonitorService.getEnvmonitorByLampPoleId(id);
|
|
|
+ Double longitude = envmonitor.getLongitude();
|
|
|
+ Double latitude = envmonitor.getLatitude();
|
|
|
+ WeatherDTO weatherInfo = WeatherUtil.getNowWeatherInfo(String.valueOf(longitude), String.valueOf(latitude));
|
|
|
+ envmonitor.setTemp(weatherInfo.getTemp());
|
|
|
+ envmonitor.setWeatherCode(weatherInfo.getIcon());
|
|
|
+ envmonitor.setWeatherText(weatherInfo.getText());
|
|
|
+ envmonitor.setAirCount(weatherInfo.getAqi());
|
|
|
+ envmonitor.setAirLevel(weatherInfo.getLevel());
|
|
|
+ lampPoleDataVO.setDataType("lampPoleDataWeather");
|
|
|
+ lampPoleDataVO.setWeatherData(envmonitor);
|
|
|
+ } else if (type == 9) { // 广播音柱
|
|
|
+ BroadcastDTO broadcastDTO = broadcastService.getBroadcastDTOByLampPoleId(id);
|
|
|
+ lampPoleDataVO.setDataType("lampPoleDataBroadcast");
|
|
|
+ lampPoleDataVO.setBroadcastData(broadcastDTO);
|
|
|
+ } else if (type == 18) { // 倾斜监测
|
|
|
+ ManholeDTO manhole = manholeService.getTiltManholeByLampPoleId(id);
|
|
|
+ lampPoleDataVO.setDataType("lampPoleDataTiltDev");
|
|
|
+ lampPoleDataVO.setTiltDevData(manhole);
|
|
|
+ } else if (type == 20) { // 灯带
|
|
|
+ LightStripDevDTO strip = lightStripDevService.getLightStripByLampPoleId(id);
|
|
|
+ lampPoleDataVO.setDataType("lampPoleDataLightStrip");
|
|
|
+ lampPoleDataVO.setLightStripData(strip);
|
|
|
+ }
|
|
|
+ return toolUtils.response(InterfaceResultEnum.OPERATION_SUCCESS,version,lampPoleDataVO);
|
|
|
+ }
|
|
|
}
|