Merge branch 'feature-BI' into dev

This commit is contained in:
Lemon
2026-05-15 09:21:15 +08:00
19 changed files with 477 additions and 4 deletions

View File

@@ -3,12 +3,13 @@ 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;
import com.jsowell.pile.service.PileBasicInfoService;
import com.jsowell.pile.vo.web.IndexGeneralSituationVO;
import com.jsowell.pile.vo.web.IndexOrderInfoVO;
import com.jsowell.pile.vo.web.IndexPlatformProfitVO;
import com.jsowell.pile.service.PileStationInfoService;
import com.jsowell.pile.vo.web.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
@@ -32,6 +33,12 @@ public class indexController extends BaseController {
@Autowired
private OrderBasicInfoService orderBasicInfoService;
@Autowired
private MemberBasicInfoService memberBasicInfoService;
@Autowired
private PileStationInfoService pileStationInfoService;
@PostMapping("/getGeneralSituation")
public RestApiResponse<?> getGeneralSituation(@RequestBody IndexQueryDTO dto) {
logger.info("首页基础数据查询 param:{}", JSON.toJSONString(dto));
@@ -105,4 +112,109 @@ public class indexController extends BaseController {
return response;
}
/**
* 大数据平台-总览数据
*/
@PostMapping("/getBigDataOverview")
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());
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);
response = new RestApiResponse<>("00200005", "大数据平台总览数据查询错误");
}
logger.info("大数据平台总览数据查询 result:{}", JSON.toJSONString(response));
return response;
}
/**
* 大数据平台-充电站地图数据
*/
@PostMapping("/getStationMapData")
public RestApiResponse<?> getStationMapData(@RequestBody(required = false) IndexQueryDTO dto) {
logger.info("大数据平台充电站地图数据查询 param:{}", JSON.toJSONString(dto));
RestApiResponse<?> response;
try {
List<StationMapVO> stationMapData = pileStationInfoService.getStationMapData();
response = new RestApiResponse<>(stationMapData);
} catch (Exception e) {
logger.error("大数据平台充电站地图数据查询错误", e);
response = new RestApiResponse<>("00200006", "大数据平台充电站地图数据查询错误");
}
logger.info("大数据平台充电站地图数据查询 result:{}", JSON.toJSONString(response));
return response;
}
/**
* 大数据平台-使用率趋势数据
*/
@PostMapping("/getUsageTrend")
public RestApiResponse<?> getUsageTrend(@RequestBody IndexQueryDTO dto) {
logger.info("大数据平台使用率趋势查询 param:{}", JSON.toJSONString(dto));
RestApiResponse<?> response;
try {
List<UsageTrendVO> trendData = orderBasicInfoService.getUsageTrendData(dto);
response = new RestApiResponse<>(trendData);
} catch (Exception e) {
logger.error("大数据平台使用率趋势查询错误", e);
response = new RestApiResponse<>("00200007", "大数据平台使用率趋势查询错误");
}
logger.info("大数据平台使用率趋势查询 result:{}", JSON.toJSONString(response));
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;
}
}

View File

@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<!-- 日志存放路径 -->
<property name="log.path" value="/opt/app/spring/logs" />
<property name="log.path" value="./opt/app/spring/logs" />
<!-- 日志输出格式 -->
<property name="log.pattern" value="%d{HH:mm:ss.SSS} [%thread] %-5level %logger{20} - [%method,%line] - %msg%n%ex" />
<!-- 日志最大的历史 90天 -->