|
@@ -0,0 +1,219 @@
|
|
|
+package com.welampiot.controller;
|
|
|
+
|
|
|
+import com.welampiot.common.BaseResult;
|
|
|
+import com.welampiot.common.InterfaceResultEnum;
|
|
|
+import com.welampiot.dto.LampInfoCacheByDayDTO;
|
|
|
+import com.welampiot.dto.LampInfoDTO;
|
|
|
+import com.welampiot.service.LampInfoCacheByDayService;
|
|
|
+import com.welampiot.service.LampService;
|
|
|
+import com.welampiot.utils.ToolUtils;
|
|
|
+import com.welampiot.vo.LampInfoCacheByDayVO;
|
|
|
+import com.welampiot.vo.LampInfoVO;
|
|
|
+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.ParseException;
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.Date;
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+/**
|
|
|
+ * ClassName: BigScreenController
|
|
|
+ * Package: com.welampiot.controller
|
|
|
+ * Description:
|
|
|
+ *
|
|
|
+ * @Author: zhj_Start
|
|
|
+ * @Create: 2023/8/29 - 17:38
|
|
|
+ * @Version: v1.0
|
|
|
+ */
|
|
|
+@RestController
|
|
|
+@CrossOrigin
|
|
|
+@RequestMapping("/bigScreen")
|
|
|
+public class BigScreenController {
|
|
|
+ @Autowired
|
|
|
+ private ToolUtils toolUtils;
|
|
|
+ @Autowired
|
|
|
+ private LampInfoCacheByDayService lampInfoCacheByDayService;
|
|
|
+ @Autowired
|
|
|
+ private LampService lampService;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 用电量统计
|
|
|
+ * @param request sectionList
|
|
|
+ * @return 用电量统计
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "/statistics", method = RequestMethod.POST)
|
|
|
+ public BaseResult<?> statistics(HttpServletRequest request) throws ParseException {
|
|
|
+ Integer version = (Integer) toolUtils.getRequestContent(request,"version",1);
|
|
|
+ long startTime = System.currentTimeMillis() - 24L * 3600 * 1000 * 30;
|
|
|
+ long endTime = System.currentTimeMillis() - 24 * 3600 * 1000;
|
|
|
+ SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
+ String startDate = simpleDateFormat.format(startTime);
|
|
|
+ String endDate = simpleDateFormat.format(endTime);
|
|
|
+ LampInfoCacheByDayDTO dayDTO = new LampInfoCacheByDayDTO();
|
|
|
+ dayDTO.setStartDate(startDate);
|
|
|
+ dayDTO.setEndDate(endDate);
|
|
|
+ dayDTO.setSectionList(toolUtils.getSectionList(request));
|
|
|
+ List<LampInfoCacheByDayDTO> list = lampInfoCacheByDayService.getSectionOfMonthConSum(dayDTO);
|
|
|
+ DecimalFormat decimalFormat = new DecimalFormat("0.00");
|
|
|
+
|
|
|
+ HashMap<String, Integer> objectObjectHashMap = new HashMap<>();
|
|
|
+ long timeT = startTime;
|
|
|
+ int i = 0;
|
|
|
+ List<Object> dateList = new ArrayList<>();
|
|
|
+ List<Object> valueList = new ArrayList<>();
|
|
|
+
|
|
|
+ while (timeT <= endTime) {
|
|
|
+ objectObjectHashMap.put(simpleDateFormat.format(new Date(timeT)),i);
|
|
|
+ dateList.add(simpleDateFormat.format(new Date(timeT)));
|
|
|
+ valueList.add(0);
|
|
|
+ timeT += 3600 * 1000 * 24;
|
|
|
+ i ++;
|
|
|
+ }
|
|
|
+
|
|
|
+ for (LampInfoCacheByDayDTO dto : 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 (dto.getConSum() != null && !dto.getConSum().equals("0") && integer != null) {
|
|
|
+ String formatConSum = decimalFormat.format(dto.getConSum());
|
|
|
+ valueList.set(integer, Float.parseFloat(formatConSum));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ LampInfoCacheByDayVO lampInfoCacheByDayVO = new LampInfoCacheByDayVO();
|
|
|
+ lampInfoCacheByDayVO.setDate(dateList);
|
|
|
+ lampInfoCacheByDayVO.setValue(valueList);
|
|
|
+ return toolUtils.response(InterfaceResultEnum.OPERATION_SUCCESS,version,lampInfoCacheByDayVO);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 故障数量TOP5地区
|
|
|
+ * @param request sectionList
|
|
|
+ * @return 故障数量TOP5地区
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "/alarmTOP", method = RequestMethod.POST)
|
|
|
+ public BaseResult<?> alarmTOP(HttpServletRequest request) {
|
|
|
+ Integer version = (Integer) toolUtils.getRequestContent(request,"version",1);
|
|
|
+ LampInfoDTO lampInfoDTO = new LampInfoDTO();
|
|
|
+ lampInfoDTO.setVersion(version);
|
|
|
+ lampInfoDTO.setSectionList(toolUtils.getSectionList(request));
|
|
|
+ List<LampInfoDTO> list = lampService.getAlarmAreaCountTop(lampInfoDTO);
|
|
|
+ LampInfoVO lampInfoVO = new LampInfoVO();
|
|
|
+ lampInfoVO.setList(list);
|
|
|
+ return toolUtils.response(InterfaceResultEnum.OPERATION_SUCCESS,version,lampInfoVO);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 用电量TOP5路段
|
|
|
+ * @param request sectionList
|
|
|
+ * @return 用电量TOP5路段
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "/consumptionTOP", method = RequestMethod.POST)
|
|
|
+ public BaseResult<?> consumptionTOP(HttpServletRequest request) {
|
|
|
+ Integer version = (Integer) toolUtils.getRequestContent(request,"version",1);
|
|
|
+ LampInfoDTO lampInfoDTO = new LampInfoDTO();
|
|
|
+ lampInfoDTO.setSectionList(toolUtils.getSectionList(request));
|
|
|
+ List<LampInfoDTO> list = lampService.getLampEleUseSectionTop(lampInfoDTO);
|
|
|
+ DecimalFormat decimalFormat = new DecimalFormat("0.00");
|
|
|
+ for (LampInfoDTO dto : list) {
|
|
|
+ if (dto.getConsumption() != null && !dto.getConsumption().equals("0.0")) {
|
|
|
+ float consumption = Float.parseFloat(dto.getConsumption());
|
|
|
+ String format = decimalFormat.format(consumption);
|
|
|
+ dto.setConsumption(format);
|
|
|
+ } else if (dto.getConsumption() == null || dto.getConsumption().equals("0.0")) {
|
|
|
+ dto.setConsumption("0");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ LampInfoVO lampInfoVO = new LampInfoVO();
|
|
|
+ lampInfoVO.setList(list);
|
|
|
+ return toolUtils.response(InterfaceResultEnum.OPERATION_SUCCESS,version,lampInfoVO);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 故障信息列表
|
|
|
+ * @param request sectionList
|
|
|
+ * @return 故障信息列表
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "/alarmList", method = RequestMethod.POST)
|
|
|
+ public BaseResult<?> alarmList(HttpServletRequest request) {
|
|
|
+ Integer version = (Integer) toolUtils.getRequestContent(request,"version",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;
|
|
|
+ LampInfoDTO lampInfoDTO = new LampInfoDTO();
|
|
|
+ lampInfoDTO.setPage(count * (page - 1));
|
|
|
+ lampInfoDTO.setCount(count);
|
|
|
+ lampInfoDTO.setVersion(version);
|
|
|
+ lampInfoDTO.setSectionList(toolUtils.getSectionList(request));
|
|
|
+ List<LampInfoDTO> list = lampService.getLampInfoAlarmList(lampInfoDTO);
|
|
|
+ LampInfoVO lampInfoVO = new LampInfoVO();
|
|
|
+ lampInfoVO.setList(list);
|
|
|
+ return toolUtils.response(InterfaceResultEnum.OPERATION_SUCCESS,version,lampInfoVO);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 故障数量折线图
|
|
|
+ * @param request sectionList
|
|
|
+ * @return 故障数量折线图
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "/alarmChart", method = RequestMethod.POST)
|
|
|
+ public BaseResult<?> alarmChart(HttpServletRequest request) throws ParseException {
|
|
|
+ Integer version = (Integer) toolUtils.getRequestContent(request,"version",1);
|
|
|
+
|
|
|
+ long startTime = System.currentTimeMillis() - 29L * 3600 * 1000 * 24;
|
|
|
+ long endTime = System.currentTimeMillis();
|
|
|
+ SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
+ String startDate = simpleDateFormat.format(startTime);
|
|
|
+ String endDate = simpleDateFormat.format(endTime);
|
|
|
+ LampInfoDTO lampInfoDTO = new LampInfoDTO();
|
|
|
+ lampInfoDTO.setStartDate(startDate);
|
|
|
+ lampInfoDTO.setEndDate(endDate);
|
|
|
+ lampInfoDTO.setSectionList(toolUtils.getSectionList(request));
|
|
|
+ List<LampInfoDTO> list = lampService.getLampAlarmTotal(lampInfoDTO);
|
|
|
+
|
|
|
+ HashMap<String, Integer> objectObjectHashMap = new HashMap<>();
|
|
|
+ long timeT = startTime;
|
|
|
+ int i = 0;
|
|
|
+ List<Object> dateList = new ArrayList<>();
|
|
|
+ List<Object> valueList = new ArrayList<>();
|
|
|
+
|
|
|
+ while (timeT <= endTime) {
|
|
|
+ objectObjectHashMap.put(simpleDateFormat.format(new Date(timeT)),i);
|
|
|
+ dateList.add(simpleDateFormat.format(new Date(timeT)));
|
|
|
+ valueList.add(0);
|
|
|
+ timeT += 3600 * 1000 * 24;
|
|
|
+ i ++;
|
|
|
+ }
|
|
|
+
|
|
|
+ for (LampInfoDTO dto : 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 (dto.getLampCount() != null && dto.getLampCount() != 0 && integer != null) {
|
|
|
+ valueList.set(integer, dto.getLampCount());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ LampInfoVO lampInfoVO = new LampInfoVO();
|
|
|
+ lampInfoVO.setDate(dateList);
|
|
|
+ lampInfoVO.setValue(valueList);
|
|
|
+ return toolUtils.response(InterfaceResultEnum.OPERATION_SUCCESS,version,lampInfoVO);
|
|
|
+ }
|
|
|
+}
|