mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-06-11 18:59:51 +08:00
update 首页数据看板
This commit is contained in:
@@ -3,6 +3,7 @@ package com.jsowell.web.controller.index;
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.jsowell.common.core.controller.BaseController;
|
||||
import com.jsowell.common.response.RestApiResponse;
|
||||
import com.jsowell.common.util.StringUtils;
|
||||
import com.jsowell.pile.dto.IndexQueryDTO;
|
||||
import com.jsowell.pile.service.MemberBasicInfoService;
|
||||
import com.jsowell.pile.service.OrderBasicInfoService;
|
||||
@@ -115,20 +116,19 @@ public class indexController extends BaseController {
|
||||
* 大数据平台-总览数据
|
||||
*/
|
||||
@PostMapping("/getBigDataOverview")
|
||||
public RestApiResponse<?> getBigDataOverview() {
|
||||
logger.info("大数据平台总览数据查询");
|
||||
public RestApiResponse<?> getBigDataOverview(@RequestBody(required = false) IndexQueryDTO dto) {
|
||||
if (dto == null) dto = new IndexQueryDTO();
|
||||
logger.info("大数据平台总览数据查询 param:{}", JSON.toJSONString(dto));
|
||||
RestApiResponse<?> response;
|
||||
try {
|
||||
BigDataOverviewVO overviewVO = new BigDataOverviewVO();
|
||||
overviewVO.setTotalUsers(memberBasicInfoService.countTotalMembers());
|
||||
overviewVO.setTotalOrders(orderBasicInfoService.countTotalOrders());
|
||||
overviewVO.setTotalPiles(Long.valueOf(pileBasicInfoService.getGeneralSituation(new IndexQueryDTO()).getTotalPileQuantity()));
|
||||
overviewVO.setTotalStations(pileStationInfoService.countTotalStations());
|
||||
|
||||
IndexGeneralSituationVO generalSituation = pileBasicInfoService.getGeneralSituation(new IndexQueryDTO());
|
||||
IndexGeneralSituationVO generalSituation = pileBasicInfoService.getGeneralSituation(dto);
|
||||
overviewVO.setTotalTransactionAmount(generalSituation.getTotalChargingAmount());
|
||||
overviewVO.setTotalElectricity(generalSituation.getTotalChargingDegree());
|
||||
|
||||
overviewVO.setTotalPiles(Long.valueOf(generalSituation.getTotalPileQuantity()));
|
||||
overviewVO.setTotalStations(pileStationInfoService.countTotalStations());
|
||||
response = new RestApiResponse<>(overviewVO);
|
||||
} catch (Exception e) {
|
||||
logger.error("大数据平台总览数据查询错误", e);
|
||||
@@ -142,8 +142,8 @@ public class indexController extends BaseController {
|
||||
* 大数据平台-充电站地图数据
|
||||
*/
|
||||
@PostMapping("/getStationMapData")
|
||||
public RestApiResponse<?> getStationMapData() {
|
||||
logger.info("大数据平台充电站地图数据查询");
|
||||
public RestApiResponse<?> getStationMapData(@RequestBody(required = false) IndexQueryDTO dto) {
|
||||
logger.info("大数据平台充电站地图数据查询 param:{}", JSON.toJSONString(dto));
|
||||
RestApiResponse<?> response;
|
||||
try {
|
||||
List<StationMapVO> stationMapData = pileStationInfoService.getStationMapData();
|
||||
@@ -174,4 +174,47 @@ public class indexController extends BaseController {
|
||||
return response;
|
||||
}
|
||||
|
||||
/**
|
||||
* 大数据平台-城市设备数量占比(饼图)
|
||||
*/
|
||||
@PostMapping("/getCityDeviceCount")
|
||||
public RestApiResponse<?> getCityDeviceCount() {
|
||||
logger.info("大数据平台城市设备数量查询");
|
||||
RestApiResponse<?> response;
|
||||
try {
|
||||
List<CityDeviceCountVO> data = pileStationInfoService.getCityDeviceCount();
|
||||
response = new RestApiResponse<>(data);
|
||||
} catch (Exception e) {
|
||||
logger.error("大数据平台城市设备数量查询错误", e);
|
||||
response = new RestApiResponse<>("00200008", "城市设备数量查询错误");
|
||||
}
|
||||
return response;
|
||||
}
|
||||
|
||||
/**
|
||||
* 大数据平台-充电时段分布
|
||||
*/
|
||||
@PostMapping("/getTimeDistribution")
|
||||
public RestApiResponse<?> getTimeDistribution(@RequestBody(required = false) IndexQueryDTO dto) {
|
||||
if (dto == null) dto = new IndexQueryDTO();
|
||||
// 默认查询最近30天,避免全表扫描超时
|
||||
if (StringUtils.isEmpty(dto.getStartTime()) || StringUtils.isEmpty(dto.getEndTime())) {
|
||||
java.time.LocalDate endDate = java.time.LocalDate.now();
|
||||
java.time.LocalDate startDate = endDate.minusDays(29);
|
||||
java.time.format.DateTimeFormatter fmt = java.time.format.DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
||||
dto.setStartTime(startDate.format(fmt) + " 00:00:00");
|
||||
dto.setEndTime(endDate.format(fmt) + " 23:59:59");
|
||||
}
|
||||
logger.info("大数据平台充电时段分布查询 param:{}", JSON.toJSONString(dto));
|
||||
RestApiResponse<?> response;
|
||||
try {
|
||||
List<TimeDistributionVO> data = orderBasicInfoService.getTimeDistribution(dto);
|
||||
response = new RestApiResponse<>(data);
|
||||
} catch (Exception e) {
|
||||
logger.error("大数据平台充电时段分布查询错误", e);
|
||||
response = new RestApiResponse<>("00200009", "充电时段分布查询错误");
|
||||
}
|
||||
return response;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user