|
@@ -0,0 +1,122 @@
|
|
|
+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.service.EmergencyInfoLogService;
|
|
|
+import com.welampiot.service.LampPoleService;
|
|
|
+import com.welampiot.utils.ToolUtils;
|
|
|
+import com.welampiot.utils.WeatherUtil;
|
|
|
+import com.welampiot.vo.EmergencyInfoLogVO;
|
|
|
+import com.welampiot.vo.LampPoleVO;
|
|
|
+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.util.List;
|
|
|
+
|
|
|
+/**
|
|
|
+ * ClassName: NewLampPoleController2
|
|
|
+ * Package: com.welampiot.controller
|
|
|
+ * Description:
|
|
|
+ *
|
|
|
+ * @Author: zhj_Start
|
|
|
+ * @Create: 2023/8/31 - 11:29
|
|
|
+ * @Version: v1.0
|
|
|
+ */
|
|
|
+@RestController
|
|
|
+@CrossOrigin
|
|
|
+@RequestMapping("/newLampPole2")
|
|
|
+public class NewLampPoleController2 {
|
|
|
+ @Autowired
|
|
|
+ private ToolUtils toolUtils;
|
|
|
+ @Autowired
|
|
|
+ private LampPoleService lampPoleService;
|
|
|
+ @Autowired
|
|
|
+ private EmergencyInfoLogService emergencyInfoLogService;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 智诺云智慧灯杆列表
|
|
|
+ * @param request sectionList
|
|
|
+ * @return 灯杆列表
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "/lampPoleList", method = RequestMethod.POST)
|
|
|
+ public BaseResult<?> lampPoleList(HttpServletRequest request) {
|
|
|
+ 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 page = (Integer) toolUtils.getRequestContent(request, "page", 1);
|
|
|
+ Integer count = (Integer) toolUtils.getRequestContent(request, "count", 1);
|
|
|
+ if (page == 0) page = 1;
|
|
|
+ if (count == 0) count = 16;
|
|
|
+ LampPoleVO lampPoleVO = new LampPoleVO();
|
|
|
+ lampPoleVO.setVersion(version);
|
|
|
+ lampPoleVO.setAreaId(areaId);
|
|
|
+ lampPoleVO.setSectionId(sectionId);
|
|
|
+ lampPoleVO.setLimit(count * (page - 1));
|
|
|
+ lampPoleVO.setOffset(count);
|
|
|
+ lampPoleVO.setSectionList(toolUtils.getSectionList(request));
|
|
|
+ List<LampPoleDTO> list = lampPoleService.getNewLampPoleList2(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.setAlarmStatus(0);
|
|
|
+ } else if (dto.getAlarmStatus() != null && dto.getAlarmStatus() != 2) {
|
|
|
+ dto.setAlarmStatus(1);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ LampPoleVO lampPoleVO1 = new LampPoleVO();
|
|
|
+ lampPoleVO1.setList(list);
|
|
|
+ Integer total = lampPoleService.getLampPoleInstallTotal(lampPoleVO);
|
|
|
+ lampPoleVO1.setTotal(total);
|
|
|
+ return toolUtils.response(InterfaceResultEnum.OPERATION_SUCCESS,version,lampPoleVO1);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 智诺云智慧灯杆详情
|
|
|
+ * @param request id
|
|
|
+ * @return 灯杆详情
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "/lampPoleDetail", method = RequestMethod.POST)
|
|
|
+ public BaseResult<?> lampPoleDetail(HttpServletRequest request) throws Exception {
|
|
|
+ Integer version = (Integer) toolUtils.getRequestContent(request, "version", 1);
|
|
|
+ Integer id = (Integer) toolUtils.getRequestContent(request, "id", 1);
|
|
|
+ if (id == 0) return toolUtils.response(InterfaceResultEnum.LACK_PARAM_ERROR,version);
|
|
|
+
|
|
|
+ LampPoleVO lampPoleVO = new LampPoleVO();
|
|
|
+ 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();
|
|
|
+
|
|
|
+ // 获取实时天气信息
|
|
|
+ WeatherDTO weatherDTO = WeatherUtil.getNowWeatherInfo(String.valueOf(longitude), String.valueOf(latitude));
|
|
|
+ lampPoleDTO.setTemp(weatherDTO.getTemp()); // 实时温度
|
|
|
+ lampPoleDTO.setWeatherCode(weatherDTO.getIcon()); // 天气状况图标代码
|
|
|
+ lampPoleDTO.setWeatherText(weatherDTO.getText()); // 天气状况描述
|
|
|
+ lampPoleDTO.setAirLevel(weatherDTO.getLevel()); // 实时空气指数级数
|
|
|
+ lampPoleDTO.setAirCount(weatherDTO.getAqi()); // 实时空气质量指数
|
|
|
+
|
|
|
+ // 获取报警列表
|
|
|
+ EmergencyInfoLogVO emergencyInfoLogVO = new EmergencyInfoLogVO();
|
|
|
+ List<EmergencyInfoLogDTO> nowEmList = emergencyInfoLogService.getNowEmergencyInfoLogList(emergencyInfoLogVO);
|
|
|
+ List<EmergencyInfoLogDTO> hisEmList = emergencyInfoLogService.getHistoryEmergencyInfoLogList(emergencyInfoLogVO);
|
|
|
+ lampPoleDTO.setNowEmList(nowEmList);
|
|
|
+ lampPoleDTO.setHisEmList(hisEmList);
|
|
|
+ LampPoleVO lampPoleVO1 = new LampPoleVO();
|
|
|
+ lampPoleVO1.setLampPoleInfo(lampPoleDTO);
|
|
|
+ return toolUtils.response(InterfaceResultEnum.OPERATION_SUCCESS,version,lampPoleVO1);
|
|
|
+ }
|
|
|
+}
|