From ecded2ef39dacc6ee5bedffaffa01e8493c1325d Mon Sep 17 00:00:00 2001 From: Lemon Date: Sat, 9 May 2026 14:34:14 +0800 Subject: [PATCH] =?UTF-8?q?update=20=E9=A6=96=E9=A1=B5=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E7=9C=8B=E6=9D=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../web/controller/index/indexController.java | 61 ++++++++++++++++--- .../pile/mapper/OrderBasicInfoMapper.java | 8 +++ .../pile/mapper/PileStationInfoMapper.java | 8 +++ .../pile/service/OrderBasicInfoService.java | 5 ++ .../pile/service/PileStationInfoService.java | 6 ++ .../impl/OrderBasicInfoServiceImpl.java | 5 ++ .../impl/PileStationInfoServiceImpl.java | 6 ++ .../pile/vo/web/CityDeviceCountVO.java | 21 +++++++ .../pile/vo/web/TimeDistributionVO.java | 21 +++++++ .../mapper/pile/OrderBasicInfoMapper.xml | 23 +++++++ .../mapper/pile/PileStationInfoMapper.xml | 16 +++++ 11 files changed, 171 insertions(+), 9 deletions(-) create mode 100644 jsowell-pile/src/main/java/com/jsowell/pile/vo/web/CityDeviceCountVO.java create mode 100644 jsowell-pile/src/main/java/com/jsowell/pile/vo/web/TimeDistributionVO.java diff --git a/jsowell-admin/src/main/java/com/jsowell/web/controller/index/indexController.java b/jsowell-admin/src/main/java/com/jsowell/web/controller/index/indexController.java index b2f2f0d6c..3670f572e 100644 --- a/jsowell-admin/src/main/java/com/jsowell/web/controller/index/indexController.java +++ b/jsowell-admin/src/main/java/com/jsowell/web/controller/index/indexController.java @@ -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 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 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 data = orderBasicInfoService.getTimeDistribution(dto); + response = new RestApiResponse<>(data); + } catch (Exception e) { + logger.error("大数据平台充电时段分布查询错误", e); + response = new RestApiResponse<>("00200009", "充电时段分布查询错误"); + } + return response; + } + } diff --git a/jsowell-pile/src/main/java/com/jsowell/pile/mapper/OrderBasicInfoMapper.java b/jsowell-pile/src/main/java/com/jsowell/pile/mapper/OrderBasicInfoMapper.java index 971b01a5c..12922ca11 100644 --- a/jsowell-pile/src/main/java/com/jsowell/pile/mapper/OrderBasicInfoMapper.java +++ b/jsowell-pile/src/main/java/com/jsowell/pile/mapper/OrderBasicInfoMapper.java @@ -482,4 +482,12 @@ public interface OrderBasicInfoMapper { * @return 订单总数 */ Long countTotalOrders(); + + /** + * 大数据平台-充电时段分布 + * + * @param dto 查询条件 + * @return 时段分布数据 + */ + List getTimeDistribution(@Param("dto") IndexQueryDTO dto); } diff --git a/jsowell-pile/src/main/java/com/jsowell/pile/mapper/PileStationInfoMapper.java b/jsowell-pile/src/main/java/com/jsowell/pile/mapper/PileStationInfoMapper.java index 22b3fca96..cbaf4c590 100644 --- a/jsowell-pile/src/main/java/com/jsowell/pile/mapper/PileStationInfoMapper.java +++ b/jsowell-pile/src/main/java/com/jsowell/pile/mapper/PileStationInfoMapper.java @@ -9,6 +9,7 @@ import com.jsowell.pile.dto.ningxiajiaotou.NXJTQueryStationInfoDTO; import com.jsowell.pile.vo.base.ThirdPartyStationInfoVO; import com.jsowell.pile.vo.ningxiajiaotou.NXJTStationInfoVO; import com.jsowell.pile.vo.web.PileStationVO; +import com.jsowell.pile.vo.web.CityDeviceCountVO; import com.jsowell.pile.vo.web.StationMapVO; import com.jsowell.pile.vo.web.StationSelectVO; import org.apache.ibatis.annotations.Param; @@ -155,4 +156,11 @@ public interface PileStationInfoMapper { * @return 站点坐标列表 */ List getStationMapData(); + + /** + * 按城市统计设备数量 + * + * @return 城市设备数量列表 + */ + List getCityDeviceCount(); } diff --git a/jsowell-pile/src/main/java/com/jsowell/pile/service/OrderBasicInfoService.java b/jsowell-pile/src/main/java/com/jsowell/pile/service/OrderBasicInfoService.java index 7126ebe48..ffc852f28 100644 --- a/jsowell-pile/src/main/java/com/jsowell/pile/service/OrderBasicInfoService.java +++ b/jsowell-pile/src/main/java/com/jsowell/pile/service/OrderBasicInfoService.java @@ -699,4 +699,9 @@ public interface OrderBasicInfoService{ * @return 订单总数 */ Long countTotalOrders(); + + /** + * 大数据平台-充电时段分布 + */ + List getTimeDistribution(IndexQueryDTO dto); } diff --git a/jsowell-pile/src/main/java/com/jsowell/pile/service/PileStationInfoService.java b/jsowell-pile/src/main/java/com/jsowell/pile/service/PileStationInfoService.java index 9f33f0654..37c057da0 100644 --- a/jsowell-pile/src/main/java/com/jsowell/pile/service/PileStationInfoService.java +++ b/jsowell-pile/src/main/java/com/jsowell/pile/service/PileStationInfoService.java @@ -14,6 +14,7 @@ import com.jsowell.pile.vo.base.ThirdPartyStationInfoVO; import com.jsowell.pile.vo.ningxiajiaotou.NXJTStationInfoVO; import com.jsowell.pile.vo.uniapp.business.StationBusinessAnalyzeInfoVO; import com.jsowell.pile.vo.uniapp.business.StationStatisticsInfosVO; +import com.jsowell.pile.vo.web.CityDeviceCountVO; import com.jsowell.pile.vo.web.PileStationVO; import com.jsowell.pile.vo.web.StationMapVO; import com.jsowell.pile.vo.web.StationSelectVO; @@ -244,4 +245,9 @@ public interface PileStationInfoService { * @return 站点坐标列表 */ List getStationMapData(); + + /** + * 按城市统计设备数量 + */ + List getCityDeviceCount(); } diff --git a/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/OrderBasicInfoServiceImpl.java b/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/OrderBasicInfoServiceImpl.java index 461271dfe..5e81dc9a1 100644 --- a/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/OrderBasicInfoServiceImpl.java +++ b/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/OrderBasicInfoServiceImpl.java @@ -6696,5 +6696,10 @@ public class OrderBasicInfoServiceImpl implements OrderBasicInfoService { public Long countTotalOrders() { return orderBasicInfoMapper.countTotalOrders(); } + + @Override + public List getTimeDistribution(IndexQueryDTO dto) { + return orderBasicInfoMapper.getTimeDistribution(dto); + } } diff --git a/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/PileStationInfoServiceImpl.java b/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/PileStationInfoServiceImpl.java index 085c5a280..f1d009eef 100644 --- a/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/PileStationInfoServiceImpl.java +++ b/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/PileStationInfoServiceImpl.java @@ -36,6 +36,7 @@ import com.jsowell.pile.vo.uniapp.business.StationBusinessAnalyzeInfoVO; import com.jsowell.pile.vo.uniapp.business.StationOrderQuantityInfoVO; import com.jsowell.pile.vo.uniapp.business.StationStatisticsInfosVO; import com.jsowell.pile.vo.uniapp.customer.CurrentTimePriceDetails; +import com.jsowell.pile.vo.web.CityDeviceCountVO; import com.jsowell.pile.vo.web.PileStationVO; import com.jsowell.pile.vo.web.StationMapVO; import com.jsowell.pile.vo.web.StationSelectVO; @@ -1699,4 +1700,9 @@ public class PileStationInfoServiceImpl implements PileStationInfoService { return pileStationInfoMapper.getStationMapData(); } + @Override + public List getCityDeviceCount() { + return pileStationInfoMapper.getCityDeviceCount(); + } + } diff --git a/jsowell-pile/src/main/java/com/jsowell/pile/vo/web/CityDeviceCountVO.java b/jsowell-pile/src/main/java/com/jsowell/pile/vo/web/CityDeviceCountVO.java new file mode 100644 index 000000000..1217c3a8c --- /dev/null +++ b/jsowell-pile/src/main/java/com/jsowell/pile/vo/web/CityDeviceCountVO.java @@ -0,0 +1,21 @@ +package com.jsowell.pile.vo.web; + +import lombok.Data; + +/** + * 城市设备数量统计VO + * + * @author jsowell + */ +@Data +public class CityDeviceCountVO { + /** + * 城市名称 + */ + private String cityName; + + /** + * 设备数量 + */ + private Long deviceCount; +} diff --git a/jsowell-pile/src/main/java/com/jsowell/pile/vo/web/TimeDistributionVO.java b/jsowell-pile/src/main/java/com/jsowell/pile/vo/web/TimeDistributionVO.java new file mode 100644 index 000000000..79e6d6393 --- /dev/null +++ b/jsowell-pile/src/main/java/com/jsowell/pile/vo/web/TimeDistributionVO.java @@ -0,0 +1,21 @@ +package com.jsowell.pile.vo.web; + +import lombok.Data; + +/** + * 充电时段分布VO + * + * @author jsowell + */ +@Data +public class TimeDistributionVO { + /** + * 时段(0-23) + */ + private Integer hour; + + /** + * 订单数量 + */ + private Long orderCount; +} diff --git a/jsowell-pile/src/main/resources/mapper/pile/OrderBasicInfoMapper.xml b/jsowell-pile/src/main/resources/mapper/pile/OrderBasicInfoMapper.xml index 0cda5c55a..1ba533337 100644 --- a/jsowell-pile/src/main/resources/mapper/pile/OrderBasicInfoMapper.xml +++ b/jsowell-pile/src/main/resources/mapper/pile/OrderBasicInfoMapper.xml @@ -3680,4 +3680,27 @@ + + diff --git a/jsowell-pile/src/main/resources/mapper/pile/PileStationInfoMapper.xml b/jsowell-pile/src/main/resources/mapper/pile/PileStationInfoMapper.xml index fef9613cb..73471c706 100644 --- a/jsowell-pile/src/main/resources/mapper/pile/PileStationInfoMapper.xml +++ b/jsowell-pile/src/main/resources/mapper/pile/PileStationInfoMapper.xml @@ -770,4 +770,20 @@ and station_lng != '' and station_lat != '' + +