|
@@ -3,13 +3,10 @@ package com.welampiot.controller;
|
|
|
import com.welampiot.common.BaseResult;
|
|
|
import com.welampiot.common.InterfaceResultEnum;
|
|
|
import com.welampiot.dto.*;
|
|
|
-import com.welampiot.service.EmergencyInfoLogService;
|
|
|
-import com.welampiot.service.LampPoleService;
|
|
|
-import com.welampiot.service.WifiService;
|
|
|
+import com.welampiot.service.*;
|
|
|
import com.welampiot.utils.ToolUtils;
|
|
|
import com.welampiot.utils.WeatherUtil;
|
|
|
-import com.welampiot.vo.EmergencyInfoLogVO;
|
|
|
-import com.welampiot.vo.LampPoleVO;
|
|
|
+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;
|
|
@@ -18,6 +15,10 @@ import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
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;
|
|
|
|
|
|
/**
|
|
@@ -41,6 +42,22 @@ public class NewLampPoleController2 {
|
|
|
private EmergencyInfoLogService emergencyInfoLogService;
|
|
|
@Autowired
|
|
|
private WifiService wifiService;
|
|
|
+ @Autowired
|
|
|
+ private ChargeService chargeService;
|
|
|
+ @Autowired
|
|
|
+ private VideoMonitorService videoMonitorService;
|
|
|
+ @Autowired
|
|
|
+ private LampService lampService;
|
|
|
+ @Autowired
|
|
|
+ private LampInfoLogNewService lampInfoLogNewService;
|
|
|
+ @Autowired
|
|
|
+ private AllAlarmInfoLogService allAlarmInfoLogService;
|
|
|
+ @Autowired
|
|
|
+ private LampInfoCacheByDayService lampInfoCacheByDayService;
|
|
|
+ @Autowired
|
|
|
+ private OperationLogService operationLogService;
|
|
|
+ @Autowired
|
|
|
+ private UserService userService;
|
|
|
|
|
|
/**
|
|
|
* 智诺云智慧灯杆列表
|
|
@@ -242,4 +259,257 @@ public class NewLampPoleController2 {
|
|
|
}
|
|
|
return toolUtils.response(InterfaceResultEnum.OPERATION_SUCCESS,version,dto);
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 概览页面信息
|
|
|
+ * @param request type,areaId,sectionId
|
|
|
+ * @return 概览页面信息
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "/data", method = RequestMethod.POST)
|
|
|
+ public BaseResult<?> data(HttpServletRequest request) throws ParseException {
|
|
|
+ Integer version = (Integer) toolUtils.getRequestContent(request, "version", 1);
|
|
|
+ Integer type = (Integer) toolUtils.getRequestContent(request, "type", 1);
|
|
|
+ Integer areaId = (Integer) toolUtils.getRequestContent(request, "areaId", 1);
|
|
|
+ Integer sectionId = (Integer) toolUtils.getRequestContent(request, "sectionId", 1);
|
|
|
+ String username = (String) toolUtils.getRequestContent(request, "username", 2);
|
|
|
+
|
|
|
+ LampPoleDataDTO lampPoleDataDTO = new LampPoleDataDTO();
|
|
|
+ DecimalFormat decimalFormat = new DecimalFormat("0.00");
|
|
|
+ if (type == 0) { // 概览信息
|
|
|
+ ChargeDTO chargeDTO = new ChargeDTO(); // 充电桩
|
|
|
+ chargeDTO.setAreaId(areaId);
|
|
|
+ chargeDTO.setSectionId(sectionId);
|
|
|
+ chargeDTO.setSectionList(toolUtils.getSectionList(request));
|
|
|
+ ChargeDTO eleAndFree = chargeService.getTotalChargeEleAndFree(chargeDTO);
|
|
|
+ if (eleAndFree == null) {
|
|
|
+ lampPoleDataDTO.setChargeMoney("0");
|
|
|
+ lampPoleDataDTO.setChargeCount("0");
|
|
|
+ } else {
|
|
|
+ Float eleTotal = eleAndFree.getEquipmentElectricity(); // 充电量
|
|
|
+ Float free = eleAndFree.getFree(); // 充电金额
|
|
|
+ if (eleTotal == 0.0) {
|
|
|
+ lampPoleDataDTO.setChargeCount("0");
|
|
|
+ } else {
|
|
|
+ String ele = decimalFormat.format(eleTotal);
|
|
|
+ lampPoleDataDTO.setChargeCount(ele);
|
|
|
+ }
|
|
|
+ if (free == 0.0) {
|
|
|
+ lampPoleDataDTO.setChargeMoney("0");
|
|
|
+ } else {
|
|
|
+ String freeTotal = decimalFormat.format(free);
|
|
|
+ lampPoleDataDTO.setChargeMoney(freeTotal);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ VideoMonitorVO videoMonitorVO = new VideoMonitorVO(); // 视屏监控
|
|
|
+ videoMonitorVO.setAreaId(areaId);
|
|
|
+ videoMonitorVO.setSectionId(sectionId);
|
|
|
+ videoMonitorVO.setSectionList(toolUtils.getSectionList(request));
|
|
|
+ VideoMonitorDTO carAndPeople = videoMonitorService.getTotalCarAndPeople(videoMonitorVO);
|
|
|
+ Integer peopleCount = carAndPeople.getPeopleCountTotal(); // 人流量
|
|
|
+ Integer carCount = carAndPeople.getCarCountTotal(); // 车流量
|
|
|
+ lampPoleDataDTO.setPerCount(peopleCount);
|
|
|
+ lampPoleDataDTO.setCarCount(carCount);
|
|
|
+
|
|
|
+ WifiDTO wifiDTO = new WifiDTO(); // wifi
|
|
|
+ wifiDTO.setAreaId(areaId);
|
|
|
+ wifiDTO.setSectionId(sectionId);
|
|
|
+ wifiDTO.setSectionList(toolUtils.getSectionList(request));
|
|
|
+ WifiDTO countAndFlow = wifiService.getTotalWifiCountAndFlow(wifiDTO);
|
|
|
+ Float flow = countAndFlow.getFlow(); // wifi连接人数
|
|
|
+ Integer deviceCount = countAndFlow.getDeviceCount(); // 消耗流量
|
|
|
+ lampPoleDataDTO.setWifiCount(deviceCount);
|
|
|
+ if (flow == 0.0) {
|
|
|
+ lampPoleDataDTO.setFlow("0");
|
|
|
+ } else {
|
|
|
+ String flowTotal = decimalFormat.format(flow);
|
|
|
+ lampPoleDataDTO.setFlow(flowTotal);
|
|
|
+ }
|
|
|
+
|
|
|
+ AllAlarmInfoLogVO allAlarmInfoLogVO = new AllAlarmInfoLogVO(); // 报警次数
|
|
|
+ allAlarmInfoLogVO.setAreaId(areaId);
|
|
|
+ allAlarmInfoLogVO.setSectionId(sectionId);
|
|
|
+ allAlarmInfoLogVO.setSectionList(toolUtils.getSectionList(request));
|
|
|
+ allAlarmInfoLogVO.setCityId(null);
|
|
|
+ allAlarmInfoLogVO.setProvinceId(null);
|
|
|
+ allAlarmInfoLogVO.setAlarmType(null);
|
|
|
+ allAlarmInfoLogVO.setKeyword(null);
|
|
|
+ Integer alarmTotal = allAlarmInfoLogService.getLampPoleAlarmTotal(allAlarmInfoLogVO);
|
|
|
+ lampPoleDataDTO.setAlarmCount(alarmTotal);
|
|
|
+
|
|
|
+ LampInfoDTO lampInfoDTO = new LampInfoDTO(); // 灯控数
|
|
|
+ lampInfoDTO.setType(null);
|
|
|
+ lampInfoDTO.setSectionId(sectionId);
|
|
|
+ lampInfoDTO.setAreaId(areaId);
|
|
|
+ lampInfoDTO.setSectionList(toolUtils.getSectionList(request));
|
|
|
+ Integer lampCount = lampService.getLampInstallTotalByDTO(lampInfoDTO);
|
|
|
+ lampPoleDataDTO.setLampCount(lampCount);
|
|
|
+ LampInfoLogNewDTO sumEle = lampInfoLogNewService.getSumEleByDTO(lampInfoDTO);
|
|
|
+ String workTimeTotal = sumEle.getWorkTimeTotal(); // 亮灯时长
|
|
|
+ lampPoleDataDTO.setLightTime(workTimeTotal);
|
|
|
+
|
|
|
+ LampPoleVO lampPoleVO = new LampPoleVO(); // 灯杆数
|
|
|
+ lampPoleVO.setAreaId(areaId);
|
|
|
+ lampPoleVO.setSectionId(sectionId);
|
|
|
+ lampPoleVO.setSectionList(toolUtils.getSectionList(request));
|
|
|
+ Integer lampPoleCount = lampPoleService.getLampPoleInstallTotal(lampPoleVO);
|
|
|
+ lampPoleDataDTO.setLampPoleCount(lampPoleCount);
|
|
|
+
|
|
|
+ } else if (type == 1) { // 地图信息
|
|
|
+ LampPoleVO lampPoleVO = new LampPoleVO();
|
|
|
+ lampPoleVO.setAreaId(areaId);
|
|
|
+ lampPoleVO.setSectionId(sectionId);
|
|
|
+ lampPoleVO.setSectionList(toolUtils.getSectionList(request));
|
|
|
+ // 灯杆总数
|
|
|
+ Integer lampPoleCount = lampPoleService.getLampPoleInstallTotal(lampPoleVO);
|
|
|
+ lampPoleDataDTO.setLampPoleCount(lampPoleCount);
|
|
|
+ // 灯杆列表
|
|
|
+ List<LampPoleDTO> list = lampPoleService.getLampPoleInstallList(lampPoleVO);
|
|
|
+ lampPoleDataDTO.setLampPoleList(list);
|
|
|
+ // 灯杆亮灯数
|
|
|
+ Integer lightCount = lampPoleService.getLampPoleLightCount(lampPoleVO);
|
|
|
+ lampPoleDataDTO.setLampPoleLightCount(lightCount);
|
|
|
+ // 灯杆亮灯列表
|
|
|
+ List<LampPoleDTO> lightList = lampPoleService.getLampPoleLightList(lampPoleVO);
|
|
|
+ lampPoleDataDTO.setLampPoleLightList(lightList);
|
|
|
+ // 灯杆故障数
|
|
|
+ Integer alarmTotal = lampPoleService.getLampPoleAlarmTotal(lampPoleVO);
|
|
|
+ lampPoleDataDTO.setLampPoleAlarmCount(alarmTotal);
|
|
|
+ // 灯杆故障列表
|
|
|
+ List<LampPoleDTO> alarmList = lampPoleService.getAlarmLampPoleList(lampPoleVO);
|
|
|
+ lampPoleDataDTO.setLampPoleAlarmList(alarmList);
|
|
|
+
|
|
|
+ } else if (type == 2) { // 7天用电量
|
|
|
+ long l = System.currentTimeMillis();
|
|
|
+ Date date1 = new Date(l);
|
|
|
+ Calendar calendar = Calendar.getInstance();
|
|
|
+ calendar.setTime(date1);
|
|
|
+ int year = calendar.get(Calendar.YEAR); // 获取年份
|
|
|
+ int month = calendar.get(Calendar.MONTH) + 1; // 获取月份
|
|
|
+
|
|
|
+ String startDate;
|
|
|
+ SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
+ String endDate = simpleDateFormat.format(l);
|
|
|
+ LampInfoCacheByDayDTO dto = new LampInfoCacheByDayDTO();
|
|
|
+ dto.setAreaId(areaId);
|
|
|
+ dto.setSectionId(sectionId);
|
|
|
+ dto.setSectionList(toolUtils.getSectionList(request));
|
|
|
+
|
|
|
+ // 7天用电量列表
|
|
|
+ long startTime = l - 24 * 3600 * 1000 * 6;
|
|
|
+ startDate = simpleDateFormat.format(startTime);
|
|
|
+ dto.setStartDate(startDate);
|
|
|
+ dto.setEndDate(endDate);
|
|
|
+ List<LampInfoCacheByDayDTO> nearDayConSumList = lampInfoCacheByDayService.getNearDayConSumList(dto);
|
|
|
+ lampPoleDataDTO.setComList(nearDayConSumList);
|
|
|
+
|
|
|
+ // 当天
|
|
|
+ LampInfoCacheByDayDTO dayConSum = lampInfoCacheByDayService.getOneDayConSum(dto);
|
|
|
+ if (dayConSum != null && dayConSum.getConSum() != null) { // 当天用电量
|
|
|
+ String conSum = dayConSum.getConSum();
|
|
|
+ String format = decimalFormat.format(Float.parseFloat(conSum));
|
|
|
+ lampPoleDataDTO.setDayCom(format);
|
|
|
+ } else {
|
|
|
+ lampPoleDataDTO.setDayCom("0");
|
|
|
+ }
|
|
|
+
|
|
|
+ // 当月
|
|
|
+ if (month < 10) {
|
|
|
+ startDate = year + "-0" + month + "-01";
|
|
|
+ } else {
|
|
|
+ startDate = year + "-" + month + "-01";
|
|
|
+ }
|
|
|
+ dto.setStartDate(startDate);
|
|
|
+ dto.setEndDate(endDate);
|
|
|
+ LampInfoCacheByDayDTO monthCom = lampInfoCacheByDayService.getAreaOrSectionOfConSum(dto);
|
|
|
+ if (monthCom != null && monthCom.getConSum() != null) { // 当月用电量
|
|
|
+ String conSum = monthCom.getConSum();
|
|
|
+ String format = decimalFormat.format(Float.parseFloat(conSum));
|
|
|
+ lampPoleDataDTO.setMonthCom(format);
|
|
|
+ } else {
|
|
|
+ lampPoleDataDTO.setMonthCom("0");
|
|
|
+ }
|
|
|
+
|
|
|
+ // 当年
|
|
|
+ month = 1;
|
|
|
+ startDate = year + "-0" + month + "-01";
|
|
|
+ dto.setStartDate(startDate);
|
|
|
+ dto.setEndDate(endDate);
|
|
|
+ LampInfoCacheByDayDTO yearCom = lampInfoCacheByDayService.getAreaOrSectionOfConSum(dto);
|
|
|
+ if (yearCom != null && yearCom.getConSum() != null) { // 当年用电量
|
|
|
+ String conSum = yearCom.getConSum();
|
|
|
+ String format = decimalFormat.format(Float.parseFloat(conSum));
|
|
|
+ lampPoleDataDTO.setYearCom(format);
|
|
|
+ } else {
|
|
|
+ lampPoleDataDTO.setYearCom("0");
|
|
|
+ }
|
|
|
+
|
|
|
+ // 全部
|
|
|
+ startDate = "2022-01-01";
|
|
|
+ dto.setStartDate(startDate);
|
|
|
+ dto.setEndDate(endDate);
|
|
|
+ LampInfoCacheByDayDTO totalCom = lampInfoCacheByDayService.getAreaOrSectionOfConSum(dto);
|
|
|
+ if (totalCom != null && totalCom.getConSum() != null) { // 累计用电量
|
|
|
+ String conSum = totalCom.getConSum();
|
|
|
+ String format = decimalFormat.format(Float.parseFloat(conSum));
|
|
|
+ lampPoleDataDTO.setTotalCom(format);
|
|
|
+ } else {
|
|
|
+ lampPoleDataDTO.setTotalCom("0");
|
|
|
+ }
|
|
|
+ } else if (type == 3) { // 全国灯控故障数排名TOP10
|
|
|
+ LampVO lampVO = new LampVO();
|
|
|
+ lampVO.setAreaId(areaId);
|
|
|
+ lampVO.setSectionId(sectionId);
|
|
|
+ lampVO.setSectionList(toolUtils.getSectionList(request));
|
|
|
+ List<LampInfoDTO> lampCountList = lampService.getLampSectionAlarmCountTop(lampVO);
|
|
|
+ lampPoleDataDTO.setAlarmList(lampCountList);
|
|
|
+ } else if (type == 4) { // 故障信息列表
|
|
|
+ LampPoleVO lampPoleVO = new LampPoleVO();
|
|
|
+ lampPoleVO.setAreaId(areaId);
|
|
|
+ lampPoleVO.setSectionId(sectionId);
|
|
|
+ lampPoleVO.setSectionList(toolUtils.getSectionList(request));
|
|
|
+ List<LampPoleDTO> lampPoleAlarmInfoList = lampPoleService.getLampPoleAlarmInfoList(lampPoleVO);
|
|
|
+ lampPoleDataDTO.setAlarmList(lampPoleAlarmInfoList);
|
|
|
+ } else if (type == 5) { // 日志信息列表
|
|
|
+ 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.getNewOperationLogList(operationLogVO);
|
|
|
+ lampPoleDataDTO.setLogList(logList);
|
|
|
+ } else if (type == 6) { // 设备数量信息
|
|
|
+ LampPoleDTO dto = new LampPoleDTO();
|
|
|
+ dto.setSectionId(sectionId);
|
|
|
+ dto.setAreaId(areaId);
|
|
|
+ dto.setSectionList(toolUtils.getSectionList(request));
|
|
|
+ LampPoleInfoVO lampPoleDevCount = lampPoleService.getLampPoleDevCount(dto);
|
|
|
+ lampPoleDataDTO.setDataDevCount(lampPoleDevCount);
|
|
|
+ }
|
|
|
+
|
|
|
+ LampPoleDataVO lampPoleDataVO = new LampPoleDataVO();
|
|
|
+ if (type == 0) { // 概览信息
|
|
|
+ lampPoleDataVO.setDataType("dataData");
|
|
|
+ lampPoleDataVO.setDataData(lampPoleDataDTO);
|
|
|
+ } else if (type == 1) { // 地图信息
|
|
|
+ lampPoleDataVO.setDataType("dataMap");
|
|
|
+ lampPoleDataVO.setDataMap(lampPoleDataDTO);
|
|
|
+ } else if (type == 2) { // 7天用电量
|
|
|
+ lampPoleDataVO.setDataType("data7Day");
|
|
|
+ lampPoleDataVO.setData7Day(lampPoleDataDTO);
|
|
|
+ } else if (type == 3) { // 全国故障排名
|
|
|
+ lampPoleDataVO.setDataType("dataAlarmControl");
|
|
|
+ lampPoleDataVO.setDataAlarmControl(lampPoleDataDTO);
|
|
|
+ } else if (type == 4) { // 故障信息列表
|
|
|
+ lampPoleDataVO.setDataType("dataAlarmList");
|
|
|
+ lampPoleDataVO.setDataAlarmList(lampPoleDataDTO);
|
|
|
+ } else if (type == 5) { // 日志信息列表
|
|
|
+ lampPoleDataVO.setDataType("dataLogList");
|
|
|
+ lampPoleDataVO.setDataLogList(lampPoleDataDTO);
|
|
|
+ } else if (type == 6) { // 设备信息数量
|
|
|
+ lampPoleDataVO.setDataType("dataDevCount");
|
|
|
+ lampPoleDataVO.setDataDevCount(lampPoleDataDTO.getDataDevCount());
|
|
|
+ }
|
|
|
+ return toolUtils.response(InterfaceResultEnum.OPERATION_SUCCESS,version,lampPoleDataVO);
|
|
|
+ }
|
|
|
}
|