|
@@ -2,11 +2,10 @@ package com.welampiot.controller;
|
|
|
|
|
|
import com.welampiot.common.BaseResult;
|
|
|
import com.welampiot.common.InterfaceResultEnum;
|
|
|
-import com.welampiot.dto.EmergencyInfoLogDTO;
|
|
|
-import com.welampiot.dto.LampPoleDTO;
|
|
|
-import com.welampiot.dto.WeatherDTO;
|
|
|
+import com.welampiot.dto.*;
|
|
|
import com.welampiot.service.EmergencyInfoLogService;
|
|
|
import com.welampiot.service.LampPoleService;
|
|
|
+import com.welampiot.service.WifiService;
|
|
|
import com.welampiot.utils.ToolUtils;
|
|
|
import com.welampiot.utils.WeatherUtil;
|
|
|
import com.welampiot.vo.EmergencyInfoLogVO;
|
|
@@ -18,6 +17,7 @@ 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.util.List;
|
|
|
|
|
|
/**
|
|
@@ -39,6 +39,8 @@ public class NewLampPoleController2 {
|
|
|
private LampPoleService lampPoleService;
|
|
|
@Autowired
|
|
|
private EmergencyInfoLogService emergencyInfoLogService;
|
|
|
+ @Autowired
|
|
|
+ private WifiService wifiService;
|
|
|
|
|
|
/**
|
|
|
* 智诺云智慧灯杆列表
|
|
@@ -98,11 +100,11 @@ public class NewLampPoleController2 {
|
|
|
lampPoleVO.setId(id);
|
|
|
LampPoleDTO lampPoleDTO = lampPoleService.getLampPoleDetails(lampPoleVO);
|
|
|
if (lampPoleDTO == null) return toolUtils.response(InterfaceResultEnum.PARAM_FAIL,version);
|
|
|
- Float longitude = lampPoleDTO.getLongitude();
|
|
|
- Float latitude = lampPoleDTO.getLatitude();
|
|
|
+ String longitude = lampPoleDTO.getLongitude();
|
|
|
+ String latitude = lampPoleDTO.getLatitude();
|
|
|
|
|
|
// 获取实时天气信息
|
|
|
- WeatherDTO weatherDTO = WeatherUtil.getNowWeatherInfo(String.valueOf(longitude), String.valueOf(latitude));
|
|
|
+ WeatherDTO weatherDTO = WeatherUtil.getNowWeatherInfo(longitude, latitude);
|
|
|
lampPoleDTO.setTemp(weatherDTO.getTemp()); // 实时温度
|
|
|
lampPoleDTO.setWeatherCode(weatherDTO.getIcon()); // 天气状况图标代码
|
|
|
lampPoleDTO.setWeatherText(weatherDTO.getText()); // 天气状况描述
|
|
@@ -119,4 +121,125 @@ public class NewLampPoleController2 {
|
|
|
lampPoleVO1.setLampPoleInfo(lampPoleDTO);
|
|
|
return toolUtils.response(InterfaceResultEnum.OPERATION_SUCCESS,version,lampPoleVO1);
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 灯杆设备列表
|
|
|
+ * @param request sectionList
|
|
|
+ * @return 灯杆设备列表
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "/lampPoleDevList", method = RequestMethod.POST)
|
|
|
+ public BaseResult<?> lampPoleDevList(HttpServletRequest request) throws Exception {
|
|
|
+ Integer version = (Integer) toolUtils.getRequestContent(request, "version", 1);
|
|
|
+ Integer areaId = (Integer) toolUtils.getRequestContent(request, "areaId", 1);
|
|
|
+ Integer sectionId = (Integer) toolUtils.getRequestContent(request, "sectionId", 1);
|
|
|
+ Integer type = (Integer) toolUtils.getRequestContent(request, "type", 1);
|
|
|
+ Integer lampId = (Integer) toolUtils.getRequestContent(request, "lampId", 1);
|
|
|
+
|
|
|
+ LampPoleVO lampPoleVO = new LampPoleVO();
|
|
|
+ lampPoleVO.setAreaId(areaId);
|
|
|
+ lampPoleVO.setSectionId(sectionId);
|
|
|
+ lampPoleVO.setType(type);
|
|
|
+ lampPoleVO.setLampId(lampId);
|
|
|
+ lampPoleVO.setSectionList(toolUtils.getSectionList(request));
|
|
|
+ List<LampPoleDTO> lampPoleDevList = lampPoleService.getLampPoleDevList(lampPoleVO);
|
|
|
+ if (type == 5) { // 气象站
|
|
|
+ DecimalFormat decimalFormat = new DecimalFormat("0.00");
|
|
|
+ for (LampPoleDTO dto : lampPoleDevList) {
|
|
|
+ String longitude = dto.getLongitude();
|
|
|
+ String latitude = dto.getLatitude();
|
|
|
+ String format1 = decimalFormat.format(Float.parseFloat(longitude));
|
|
|
+ String format2 = decimalFormat.format(Float.parseFloat(latitude));
|
|
|
+ // 获取实时天气信息
|
|
|
+ WeatherDTO weatherDTO = WeatherUtil.getNowWeatherInfo(format1, format2);
|
|
|
+ dto.setTemp(weatherDTO.getTemp()); // 实时温度
|
|
|
+ dto.setWeatherCode(weatherDTO.getIcon()); // 天气状况图标代码
|
|
|
+ dto.setWeatherText(weatherDTO.getText()); // 天气状况描述
|
|
|
+ dto.setAirLevel(weatherDTO.getLevel()); // 实时空气指数级数
|
|
|
+ dto.setAirCount(weatherDTO.getAqi()); // 实时空气质量指数
|
|
|
+ }
|
|
|
+ } else if (type == 9) { // 云盒
|
|
|
+ for (LampPoleDTO dto : lampPoleDevList) {
|
|
|
+ if (dto.getOnline() != null) {
|
|
|
+ dto.setLED1(dto.getOnline());
|
|
|
+ }
|
|
|
+ if (dto.getACI() != null) {
|
|
|
+ dto.setLED8(dto.getACI());
|
|
|
+ }
|
|
|
+ if (dto.getLedStatus() != null && !dto.getLedStatus().isEmpty()) {
|
|
|
+ String ledStatus = dto.getLedStatus();
|
|
|
+ int decimal = Integer.parseInt(ledStatus, 16);
|
|
|
+ String number = String.format("%8s", Integer.toBinaryString(decimal)).replace(' ', '0');
|
|
|
+ char c8 = number.charAt(7); // LED2
|
|
|
+ int number8 = Character.getNumericValue(c8);
|
|
|
+ dto.setLED2(number8);
|
|
|
+ char c7 = number.charAt(6); // LED4
|
|
|
+ int number7 = Character.getNumericValue(c7);
|
|
|
+ dto.setLED4(number7);
|
|
|
+ char c6 = number.charAt(5); // LED3
|
|
|
+ int number6 = Character.getNumericValue(c6);
|
|
|
+ dto.setLED3(number6);
|
|
|
+ char c4 = number.charAt(3); // LED5
|
|
|
+ int number4 = Character.getNumericValue(c4);
|
|
|
+ dto.setLED5(number4);
|
|
|
+ char c3 = number.charAt(2); // LED6
|
|
|
+ int number3 = Character.getNumericValue(c3);
|
|
|
+ dto.setLED6(number3);
|
|
|
+ char c2 = number.charAt(1); // LED7
|
|
|
+ int number2 = Character.getNumericValue(c2);
|
|
|
+ dto.setLED7(number2);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ LampPoleVO lampPoleVO1 = new LampPoleVO();
|
|
|
+ lampPoleVO1.setLampPoleDevList(lampPoleDevList);
|
|
|
+ return toolUtils.response(InterfaceResultEnum.OPERATION_SUCCESS,version,lampPoleVO1);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 2.0云盒详细信息
|
|
|
+ * @param request id
|
|
|
+ * @return 2.0云盒详细信息
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "/cloudBoxInfo", method = RequestMethod.POST)
|
|
|
+ public BaseResult<?> cloudBoxInfo(HttpServletRequest request) {
|
|
|
+ Integer version = (Integer) toolUtils.getRequestContent(request, "version", 1);
|
|
|
+ Integer id = (Integer) toolUtils.getRequestContent(request, "id", 1);
|
|
|
+ Integer lampPoleId = (Integer) toolUtils.getRequestContent(request, "lampPoleId", 1);
|
|
|
+ if (id == 0 && lampPoleId == 0) return toolUtils.response(InterfaceResultEnum.LACK_PARAM_ERROR,version);
|
|
|
+ WifiDTO wifiDTO = new WifiDTO();
|
|
|
+ wifiDTO.setLampPoleId(lampPoleId);
|
|
|
+ wifiDTO.setId(id);
|
|
|
+ WifiDTO dto = wifiService.getWifiInfoDetails(wifiDTO);
|
|
|
+ if (dto == null) return toolUtils.response(InterfaceResultEnum.PARAM_FAIL,version);
|
|
|
+ if (dto.getOnline() != null) {
|
|
|
+ dto.setLED1(dto.getOnline());
|
|
|
+ }
|
|
|
+ if (dto.getACI() != null) {
|
|
|
+ dto.setLED8(dto.getACI());
|
|
|
+ }
|
|
|
+ if (dto.getLedStatus() != null && !dto.getLedStatus().isEmpty()) {
|
|
|
+ String ledStatus = dto.getLedStatus();
|
|
|
+ int decimal = Integer.parseInt(ledStatus, 16);
|
|
|
+ String number = String.format("%8s", Integer.toBinaryString(decimal)).replace(' ', '0');
|
|
|
+ char c8 = number.charAt(7); // LED2
|
|
|
+ int number8 = Character.getNumericValue(c8);
|
|
|
+ dto.setLED2(number8);
|
|
|
+ char c7 = number.charAt(6); // LED4
|
|
|
+ int number7 = Character.getNumericValue(c7);
|
|
|
+ dto.setLED4(number7);
|
|
|
+ char c6 = number.charAt(5); // LED3
|
|
|
+ int number6 = Character.getNumericValue(c6);
|
|
|
+ dto.setLED3(number6);
|
|
|
+ char c4 = number.charAt(3); // LED5
|
|
|
+ int number4 = Character.getNumericValue(c4);
|
|
|
+ dto.setLED5(number4);
|
|
|
+ char c3 = number.charAt(2); // LED6
|
|
|
+ int number3 = Character.getNumericValue(c3);
|
|
|
+ dto.setLED6(number3);
|
|
|
+ char c2 = number.charAt(1); // LED7
|
|
|
+ int number2 = Character.getNumericValue(c2);
|
|
|
+ dto.setLED7(number2);
|
|
|
+ }
|
|
|
+ return toolUtils.response(InterfaceResultEnum.OPERATION_SUCCESS,version,dto);
|
|
|
+ }
|
|
|
}
|