update 首页数据看板

This commit is contained in:
Lemon
2026-05-09 14:34:14 +08:00
parent f3300fb13b
commit ecded2ef39
11 changed files with 171 additions and 9 deletions

View File

@@ -3,6 +3,7 @@ package com.jsowell.web.controller.index;
import com.alibaba.fastjson2.JSON; import com.alibaba.fastjson2.JSON;
import com.jsowell.common.core.controller.BaseController; import com.jsowell.common.core.controller.BaseController;
import com.jsowell.common.response.RestApiResponse; import com.jsowell.common.response.RestApiResponse;
import com.jsowell.common.util.StringUtils;
import com.jsowell.pile.dto.IndexQueryDTO; import com.jsowell.pile.dto.IndexQueryDTO;
import com.jsowell.pile.service.MemberBasicInfoService; import com.jsowell.pile.service.MemberBasicInfoService;
import com.jsowell.pile.service.OrderBasicInfoService; import com.jsowell.pile.service.OrderBasicInfoService;
@@ -115,20 +116,19 @@ public class indexController extends BaseController {
* 大数据平台-总览数据 * 大数据平台-总览数据
*/ */
@PostMapping("/getBigDataOverview") @PostMapping("/getBigDataOverview")
public RestApiResponse<?> getBigDataOverview() { public RestApiResponse<?> getBigDataOverview(@RequestBody(required = false) IndexQueryDTO dto) {
logger.info("大数据平台总览数据查询"); if (dto == null) dto = new IndexQueryDTO();
logger.info("大数据平台总览数据查询 param:{}", JSON.toJSONString(dto));
RestApiResponse<?> response; RestApiResponse<?> response;
try { try {
BigDataOverviewVO overviewVO = new BigDataOverviewVO(); BigDataOverviewVO overviewVO = new BigDataOverviewVO();
overviewVO.setTotalUsers(memberBasicInfoService.countTotalMembers()); overviewVO.setTotalUsers(memberBasicInfoService.countTotalMembers());
overviewVO.setTotalOrders(orderBasicInfoService.countTotalOrders()); overviewVO.setTotalOrders(orderBasicInfoService.countTotalOrders());
overviewVO.setTotalPiles(Long.valueOf(pileBasicInfoService.getGeneralSituation(new IndexQueryDTO()).getTotalPileQuantity())); IndexGeneralSituationVO generalSituation = pileBasicInfoService.getGeneralSituation(dto);
overviewVO.setTotalStations(pileStationInfoService.countTotalStations());
IndexGeneralSituationVO generalSituation = pileBasicInfoService.getGeneralSituation(new IndexQueryDTO());
overviewVO.setTotalTransactionAmount(generalSituation.getTotalChargingAmount()); overviewVO.setTotalTransactionAmount(generalSituation.getTotalChargingAmount());
overviewVO.setTotalElectricity(generalSituation.getTotalChargingDegree()); overviewVO.setTotalElectricity(generalSituation.getTotalChargingDegree());
overviewVO.setTotalPiles(Long.valueOf(generalSituation.getTotalPileQuantity()));
overviewVO.setTotalStations(pileStationInfoService.countTotalStations());
response = new RestApiResponse<>(overviewVO); response = new RestApiResponse<>(overviewVO);
} catch (Exception e) { } catch (Exception e) {
logger.error("大数据平台总览数据查询错误", e); logger.error("大数据平台总览数据查询错误", e);
@@ -142,8 +142,8 @@ public class indexController extends BaseController {
* 大数据平台-充电站地图数据 * 大数据平台-充电站地图数据
*/ */
@PostMapping("/getStationMapData") @PostMapping("/getStationMapData")
public RestApiResponse<?> getStationMapData() { public RestApiResponse<?> getStationMapData(@RequestBody(required = false) IndexQueryDTO dto) {
logger.info("大数据平台充电站地图数据查询"); logger.info("大数据平台充电站地图数据查询 param:{}", JSON.toJSONString(dto));
RestApiResponse<?> response; RestApiResponse<?> response;
try { try {
List<StationMapVO> stationMapData = pileStationInfoService.getStationMapData(); List<StationMapVO> stationMapData = pileStationInfoService.getStationMapData();
@@ -174,4 +174,47 @@ public class indexController extends BaseController {
return 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

@@ -482,4 +482,12 @@ public interface OrderBasicInfoMapper {
* @return 订单总数 * @return 订单总数
*/ */
Long countTotalOrders(); Long countTotalOrders();
/**
* 大数据平台-充电时段分布
*
* @param dto 查询条件
* @return 时段分布数据
*/
List<TimeDistributionVO> getTimeDistribution(@Param("dto") IndexQueryDTO dto);
} }

View File

@@ -9,6 +9,7 @@ import com.jsowell.pile.dto.ningxiajiaotou.NXJTQueryStationInfoDTO;
import com.jsowell.pile.vo.base.ThirdPartyStationInfoVO; import com.jsowell.pile.vo.base.ThirdPartyStationInfoVO;
import com.jsowell.pile.vo.ningxiajiaotou.NXJTStationInfoVO; import com.jsowell.pile.vo.ningxiajiaotou.NXJTStationInfoVO;
import com.jsowell.pile.vo.web.PileStationVO; 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.StationMapVO;
import com.jsowell.pile.vo.web.StationSelectVO; import com.jsowell.pile.vo.web.StationSelectVO;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
@@ -155,4 +156,11 @@ public interface PileStationInfoMapper {
* @return 站点坐标列表 * @return 站点坐标列表
*/ */
List<StationMapVO> getStationMapData(); List<StationMapVO> getStationMapData();
/**
* 按城市统计设备数量
*
* @return 城市设备数量列表
*/
List<CityDeviceCountVO> getCityDeviceCount();
} }

View File

@@ -699,4 +699,9 @@ public interface OrderBasicInfoService{
* @return 订单总数 * @return 订单总数
*/ */
Long countTotalOrders(); Long countTotalOrders();
/**
* 大数据平台-充电时段分布
*/
List<TimeDistributionVO> getTimeDistribution(IndexQueryDTO dto);
} }

View File

@@ -14,6 +14,7 @@ import com.jsowell.pile.vo.base.ThirdPartyStationInfoVO;
import com.jsowell.pile.vo.ningxiajiaotou.NXJTStationInfoVO; import com.jsowell.pile.vo.ningxiajiaotou.NXJTStationInfoVO;
import com.jsowell.pile.vo.uniapp.business.StationBusinessAnalyzeInfoVO; import com.jsowell.pile.vo.uniapp.business.StationBusinessAnalyzeInfoVO;
import com.jsowell.pile.vo.uniapp.business.StationStatisticsInfosVO; 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.PileStationVO;
import com.jsowell.pile.vo.web.StationMapVO; import com.jsowell.pile.vo.web.StationMapVO;
import com.jsowell.pile.vo.web.StationSelectVO; import com.jsowell.pile.vo.web.StationSelectVO;
@@ -244,4 +245,9 @@ public interface PileStationInfoService {
* @return 站点坐标列表 * @return 站点坐标列表
*/ */
List<StationMapVO> getStationMapData(); List<StationMapVO> getStationMapData();
/**
* 按城市统计设备数量
*/
List<CityDeviceCountVO> getCityDeviceCount();
} }

View File

@@ -6696,5 +6696,10 @@ public class OrderBasicInfoServiceImpl implements OrderBasicInfoService {
public Long countTotalOrders() { public Long countTotalOrders() {
return orderBasicInfoMapper.countTotalOrders(); return orderBasicInfoMapper.countTotalOrders();
} }
@Override
public List<TimeDistributionVO> getTimeDistribution(IndexQueryDTO dto) {
return orderBasicInfoMapper.getTimeDistribution(dto);
}
} }

View File

@@ -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.StationOrderQuantityInfoVO;
import com.jsowell.pile.vo.uniapp.business.StationStatisticsInfosVO; import com.jsowell.pile.vo.uniapp.business.StationStatisticsInfosVO;
import com.jsowell.pile.vo.uniapp.customer.CurrentTimePriceDetails; 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.PileStationVO;
import com.jsowell.pile.vo.web.StationMapVO; import com.jsowell.pile.vo.web.StationMapVO;
import com.jsowell.pile.vo.web.StationSelectVO; import com.jsowell.pile.vo.web.StationSelectVO;
@@ -1699,4 +1700,9 @@ public class PileStationInfoServiceImpl implements PileStationInfoService {
return pileStationInfoMapper.getStationMapData(); return pileStationInfoMapper.getStationMapData();
} }
@Override
public List<CityDeviceCountVO> getCityDeviceCount() {
return pileStationInfoMapper.getCityDeviceCount();
}
} }

View File

@@ -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;
}

View File

@@ -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;
}

View File

@@ -3680,4 +3680,27 @@
<select id="countTotalOrders" resultType="java.lang.Long"> <select id="countTotalOrders" resultType="java.lang.Long">
select count(*) from order_basic_info where del_flag = '0' select count(*) from order_basic_info where del_flag = '0'
</select> </select>
<select id="getTimeDistribution" resultType="com.jsowell.pile.vo.web.TimeDistributionVO">
SELECT
HOUR(t1.create_time) AS hour,
COUNT(*) AS orderCount
FROM order_basic_info t1
WHERE t1.del_flag = '0'
AND t1.order_status = '6'
<if test="dto.startTime != null and dto.startTime != ''">
AND t1.create_time &gt;= #{dto.startTime}
</if>
<if test="dto.endTime != null and dto.endTime != ''">
AND t1.create_time &lt;= #{dto.endTime}
</if>
<if test="dto.stationIdList != null and dto.stationIdList.size() > 0">
AND t1.station_id IN
<foreach item="sid" collection="dto.stationIdList" open="(" separator="," close=")">
#{sid}
</foreach>
</if>
GROUP BY HOUR(t1.create_time)
ORDER BY hour ASC
</select>
</mapper> </mapper>

View File

@@ -770,4 +770,20 @@
and station_lng != '' and station_lng != ''
and station_lat != '' and station_lat != ''
</select> </select>
<select id="getCityDeviceCount" resultType="com.jsowell.pile.vo.web.CityDeviceCountVO">
SELECT
CASE
WHEN address LIKE '%省%' AND address LIKE '%市%' THEN
CONCAT(SUBSTRING_INDEX(SUBSTRING_INDEX(address, '省', -1), '市', 1), '市')
WHEN address LIKE '%市%' THEN
LEFT(SUBSTRING_INDEX(address, '市', 1), 3)
ELSE '其他'
END AS cityName,
COUNT(*) AS deviceCount
FROM pile_station_info
WHERE del_flag = '0' AND address IS NOT NULL AND address != ''
GROUP BY cityName
ORDER BY deviceCount DESC
</select>
</mapper> </mapper>