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 aff5493b6..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,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 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 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 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-admin/src/main/resources/logback.xml b/jsowell-admin/src/main/resources/logback.xml index d293b86f2..b3591c688 100644 --- a/jsowell-admin/src/main/resources/logback.xml +++ b/jsowell-admin/src/main/resources/logback.xml @@ -1,7 +1,7 @@ - + diff --git a/jsowell-pile/src/main/java/com/jsowell/pile/mapper/MemberBasicInfoMapper.java b/jsowell-pile/src/main/java/com/jsowell/pile/mapper/MemberBasicInfoMapper.java index 1070c0364..01b483b17 100644 --- a/jsowell-pile/src/main/java/com/jsowell/pile/mapper/MemberBasicInfoMapper.java +++ b/jsowell-pile/src/main/java/com/jsowell/pile/mapper/MemberBasicInfoMapper.java @@ -140,4 +140,11 @@ public interface MemberBasicInfoMapper { ConfirmStartChargingMemberVO queryMemberInfoByCardCode(@Param("cardCode") String cardCode, @Param("merchantId") String merchantId); ConfirmStartChargingMemberVO queryMemberInfoByVinCode(@Param("vinCode") String vinCode, @Param("merchantId") String merchantId); + + /** + * 统计总会员数 + * + * @return 会员总数 + */ + Long countTotalMembers(); } 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 cc765f708..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 @@ -467,4 +467,27 @@ public interface OrderBasicInfoMapper { List batchQueryChargingConnectorInfo(@Param("pileConnectorCodes") List chargingConnectorCodeList); int batchUpdateOrderReview(@Param("dto") UpdateOrderReviewDTO dto); + + /** + * 大数据平台-使用率趋势数据 + * + * @param dto 查询条件 + * @return 趋势数据列表 + */ + List getUsageTrendData(@Param("dto") IndexQueryDTO dto); + + /** + * 大数据平台-订单总数 + * + * @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 10632fc7f..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,8 @@ 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; import org.springframework.stereotype.Repository; @@ -140,4 +142,25 @@ public interface PileStationInfoMapper { * @return */ List getStationIdsByMerchantIds(@Param("merchantIds") List merchantIdList); + + /** + * 统计充电站总数 + * + * @return 充电站总数 + */ + Long countTotalStations(); + + /** + * 查询所有充电站坐标(用于地图展示) + * + * @return 站点坐标列表 + */ + List getStationMapData(); + + /** + * 按城市统计设备数量 + * + * @return 城市设备数量列表 + */ + List getCityDeviceCount(); } diff --git a/jsowell-pile/src/main/java/com/jsowell/pile/service/MemberBasicInfoService.java b/jsowell-pile/src/main/java/com/jsowell/pile/service/MemberBasicInfoService.java index 83038944e..85a483b70 100644 --- a/jsowell-pile/src/main/java/com/jsowell/pile/service/MemberBasicInfoService.java +++ b/jsowell-pile/src/main/java/com/jsowell/pile/service/MemberBasicInfoService.java @@ -182,4 +182,11 @@ public interface MemberBasicInfoService { ConfirmStartChargingMemberVO queryMemberInfoByCardCode(String physicsCard, String merchantId, String stationId); ConfirmStartChargingMemberVO queryByVinCode(String vinCode, String merchantId, String stationId); + + /** + * 统计总会员数 + * + * @return 会员总数 + */ + Long countTotalMembers(); } 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 bbf855cbe..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 @@ -684,4 +684,24 @@ public interface OrderBasicInfoService{ List getRealTimeMonitorDataList(List transactionCodeList); int batchUpdateOrderReview(UpdateOrderReviewDTO dto); + + /** + * 大数据平台-使用率趋势数据 + * + * @param dto 查询条件 + * @return 趋势数据列表 + */ + List getUsageTrendData(IndexQueryDTO dto); + + /** + * 大数据平台-订单总数 + * + * @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 b63419dfb..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,7 +14,9 @@ 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; import java.util.List; @@ -229,4 +231,23 @@ public interface PileStationInfoService { * @return */ List getStationIdsByMerchantIds(List merchantIdList); + + /** + * 统计充电站总数 + * + * @return 充电站总数 + */ + Long countTotalStations(); + + /** + * 查询所有充电站坐标(用于地图展示) + * + * @return 站点坐标列表 + */ + List getStationMapData(); + + /** + * 按城市统计设备数量 + */ + List getCityDeviceCount(); } diff --git a/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/MemberBasicInfoServiceImpl.java b/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/MemberBasicInfoServiceImpl.java index 7d1455f3d..3026b1166 100644 --- a/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/MemberBasicInfoServiceImpl.java +++ b/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/MemberBasicInfoServiceImpl.java @@ -915,4 +915,9 @@ public class MemberBasicInfoServiceImpl implements MemberBasicInfoService { return memberVO; } + @Override + public Long countTotalMembers() { + return memberBasicInfoMapper.countTotalMembers(); + } + } 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 cab28f0ae..6d00da3d9 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 @@ -6691,5 +6691,20 @@ public class OrderBasicInfoServiceImpl implements OrderBasicInfoService { } return resultList; } + + @Override + public List getUsageTrendData(IndexQueryDTO dto) { + return orderBasicInfoMapper.getUsageTrendData(dto); + } + + @Override + 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 ae6d175e7..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,7 +36,9 @@ 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; import com.jsowell.system.service.SysDeptService; import com.jsowell.system.service.SysUserService; @@ -1688,4 +1690,19 @@ public class PileStationInfoServiceImpl implements PileStationInfoService { return pileStationInfoMapper.getStationIdsByMerchantIds(merchantIdList); } + @Override + public Long countTotalStations() { + return pileStationInfoMapper.countTotalStations(); + } + + @Override + public List getStationMapData() { + return pileStationInfoMapper.getStationMapData(); + } + + @Override + public List getCityDeviceCount() { + return pileStationInfoMapper.getCityDeviceCount(); + } + } diff --git a/jsowell-pile/src/main/java/com/jsowell/pile/vo/web/BigDataOverviewVO.java b/jsowell-pile/src/main/java/com/jsowell/pile/vo/web/BigDataOverviewVO.java new file mode 100644 index 000000000..dd98edea6 --- /dev/null +++ b/jsowell-pile/src/main/java/com/jsowell/pile/vo/web/BigDataOverviewVO.java @@ -0,0 +1,41 @@ +package com.jsowell.pile.vo.web; + +import lombok.Data; + +/** + * 大数据平台总览数据VO + * + * @author jsowell + */ +@Data +public class BigDataOverviewVO { + /** + * 总用户数 + */ + private Long totalUsers; + + /** + * 总订单数 + */ + private Long totalOrders; + + /** + * 累计交易额 + */ + private String totalTransactionAmount; + + /** + * 累计充电电量(kWh) + */ + private String totalElectricity; + + /** + * 充电桩数量 + */ + private Long totalPiles; + + /** + * 充电站数量 + */ + private Long totalStations; +} 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/StationMapVO.java b/jsowell-pile/src/main/java/com/jsowell/pile/vo/web/StationMapVO.java new file mode 100644 index 000000000..a54b388bc --- /dev/null +++ b/jsowell-pile/src/main/java/com/jsowell/pile/vo/web/StationMapVO.java @@ -0,0 +1,26 @@ +package com.jsowell.pile.vo.web; + +import lombok.Data; + +/** + * 充电站地图坐标VO + * + * @author jsowell + */ +@Data +public class StationMapVO { + /** + * 站点名称 + */ + private String stationName; + + /** + * 经度 + */ + private String stationLng; + + /** + * 纬度 + */ + private String stationLat; +} 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/java/com/jsowell/pile/vo/web/UsageTrendVO.java b/jsowell-pile/src/main/java/com/jsowell/pile/vo/web/UsageTrendVO.java new file mode 100644 index 000000000..7a523fb7b --- /dev/null +++ b/jsowell-pile/src/main/java/com/jsowell/pile/vo/web/UsageTrendVO.java @@ -0,0 +1,31 @@ +package com.jsowell.pile.vo.web; + +import lombok.Data; + +/** + * 使用率趋势VO + * + * @author jsowell + */ +@Data +public class UsageTrendVO { + /** + * 日期 + */ + private String date; + + /** + * 订单数量 + */ + private Long orderCount; + + /** + * 充电电量 + */ + private String electricity; + + /** + * 订单金额 + */ + private String orderAmount; +} diff --git a/jsowell-pile/src/main/resources/mapper/pile/MemberBasicInfoMapper.xml b/jsowell-pile/src/main/resources/mapper/pile/MemberBasicInfoMapper.xml index d165862fc..b6e6c0e9a 100644 --- a/jsowell-pile/src/main/resources/mapper/pile/MemberBasicInfoMapper.xml +++ b/jsowell-pile/src/main/resources/mapper/pile/MemberBasicInfoMapper.xml @@ -338,4 +338,8 @@ t2.vin_code = #{vinCode,jdbcType=VARCHAR} or t2.vin_code = reverse(#{vinCode,jdbcType=VARCHAR}) ) + + diff --git a/jsowell-pile/src/main/resources/mapper/pile/OrderBasicInfoMapper.xml b/jsowell-pile/src/main/resources/mapper/pile/OrderBasicInfoMapper.xml index bf30a5194..1ba533337 100644 --- a/jsowell-pile/src/main/resources/mapper/pile/OrderBasicInfoMapper.xml +++ b/jsowell-pile/src/main/resources/mapper/pile/OrderBasicInfoMapper.xml @@ -3656,4 +3656,51 @@ #{orderCode} + + + + + + diff --git a/jsowell-pile/src/main/resources/mapper/pile/PileStationInfoMapper.xml b/jsowell-pile/src/main/resources/mapper/pile/PileStationInfoMapper.xml index 89beb66e4..73471c706 100644 --- a/jsowell-pile/src/main/resources/mapper/pile/PileStationInfoMapper.xml +++ b/jsowell-pile/src/main/resources/mapper/pile/PileStationInfoMapper.xml @@ -754,4 +754,36 @@ #{merchantId,jdbcType=VARCHAR} + + + + + +