update 首页数据大屏

This commit is contained in:
Lemon
2026-05-26 16:19:19 +08:00
parent 52b1535216
commit 05699d5686
15 changed files with 483 additions and 106 deletions

View File

@@ -20,6 +20,11 @@ public class IndexQueryDTO extends BaseEntity {
private List<String> stationIdList;
/**
* 商户id列表用于大数据平台按商户维度查询避免展开为大量stationId
*/
private List<String> merchantIdList;
private String startTime;
private String endTime;

View File

@@ -149,9 +149,9 @@ public interface MemberBasicInfoMapper {
Long countTotalMembers();
/**
* 统计今日新增会员数
* 统计今日新增会员数,日期由代码传入
*
* @return 今日新增会员数
*/
Long countTodayNewMembers();
Long countTodayNewMembers(@Param("startTime") String startTime, @Param("endTime") String endTime);
}

View File

@@ -490,4 +490,14 @@ public interface OrderBasicInfoMapper {
* @return 时段分布数据
*/
List<TimeDistributionVO> getTimeDistribution(@Param("dto") IndexQueryDTO dto);
/**
* 大数据平台-今日订单金额明细Java汇总日期由代码传入
*/
List<java.math.BigDecimal> getTodayOrderAmountRows(@Param("startTime") String startTime, @Param("endTime") String endTime);
/**
* 大数据平台-今日充电电量明细Java汇总日期由代码传入
*/
List<java.math.BigDecimal> getTodayElectricityRows(@Param("startTime") String startTime, @Param("endTime") String endTime);
}

View File

@@ -142,7 +142,7 @@ public interface PileBasicInfoMapper {
* @param dto 站点Id
* @return 首页基本信息
*/
public IndexGeneralSituationVO getGeneralSituationInfo(@Param("IndexQueryDTO")IndexQueryDTO dto);
public List<IndexGeneralSituationVO> getGeneralSituationInfo(@Param("IndexQueryDTO")IndexQueryDTO dto);
/**
* 通过会员id查询个人桩列表
@@ -181,23 +181,29 @@ public interface PileBasicInfoMapper {
int movePile2AnotherStation(ReplaceMerchantStationDTO dto);
/**
* 查询当日累计交易金额
*
* @return 当日交易金额
*/
java.math.BigDecimal getTodayTransactionAmount();
/**
* 查询当日充电电量
*
* @return 当日充电电量
*/
java.math.BigDecimal getTodayElectricity();
/**
* 查询本月日均充电电量
* 查询本月日均充电电量,日期由代码传入
*
* @return 月均充电电量
*/
java.math.BigDecimal getMonthlyAvgElectricity();
List<java.math.BigDecimal> getMonthlyAvgElectricity(@Param("monthStartDate") String monthStartDate, @Param("monthEndDate") String monthEndDate);
/**
* 根据站点ID列表统计充电桩总数
*/
Long countTotalPilesByStationIds(@Param("stationIdList") List<String> stationIdList);
/**
* 根据商户ID列表统计充电桩总数
*/
Long countTotalPilesByMerchantIds(@Param("merchantIdList") List<String> merchantIdList);
/**
* 按merchantId分组汇总settle_order_report每个商户一行Java再汇总
*/
List<IndexGeneralSituationVO> getSettleReportGroupByMerchant(@Param("merchantIdList") List<String> merchantIdList);
/**
* 按stationId分组汇总settle_order_report每个站点一行Java再汇总
*/
List<IndexGeneralSituationVO> getSettleReportGroupByStation(@Param("stationIdList") List<String> stationIdList);
}

View File

@@ -191,9 +191,9 @@ public interface MemberBasicInfoService {
Long countTotalMembers();
/**
* 统计今日新增会员数
* 统计今日新增会员数,日期由代码传入
*
* @return 今日新增会员数
*/
Long countTodayNewMembers();
Long countTodayNewMembers(String startTime, String endTime);
}

View File

@@ -704,4 +704,18 @@ public interface OrderBasicInfoService{
* 大数据平台-充电时段分布
*/
List<TimeDistributionVO> getTimeDistribution(IndexQueryDTO dto);
/**
* 大数据平台-今日交易金额Java汇总
*
* @return 今日已完成订单的交易金额合计
*/
java.math.BigDecimal getTodayTransactionAmount(String startTime, String endTime);
/**
* 大数据平台-今日充电电量Java汇总
*
* @return 今日已完成订单的充电电量合计kWh
*/
java.math.BigDecimal getTodayElectricity(String startTime, String endTime);
}

View File

@@ -260,23 +260,29 @@ public interface PileBasicInfoService {
int movePile2AnotherStation(ReplaceMerchantStationDTO dto);
/**
* 查询当日累计交易金额
*
* @return 当日交易金额
*/
java.math.BigDecimal getTodayTransactionAmount();
/**
* 查询当日充电电量
*
* @return 当日充电电量
*/
java.math.BigDecimal getTodayElectricity();
/**
* 查询本月日均充电电量
* 查询本月日均充电电量,日期由代码传入
*
* @return 月均充电电量
*/
java.math.BigDecimal getMonthlyAvgElectricity();
java.math.BigDecimal getMonthlyAvgElectricity(String monthStartDate, String monthEndDate);
/**
* 根据站点ID列表统计充电桩总数
*/
Long countTotalPilesByStationIds(List<String> stationIdList);
/**
* 根据商户ID列表统计充电桩总数
*/
Long countTotalPilesByMerchantIds(List<String> merchantIdList);
/**
* 大数据平台专用根据商户ID查settle_order_report GROUP BY merchant_idJava汇总返回
*/
IndexGeneralSituationVO aggregateReportByMerchantIds(List<String> merchantIdList);
/**
* 大数据平台专用根据站点ID查settle_order_report GROUP BY station_idJava汇总返回
*/
IndexGeneralSituationVO aggregateReportByStationIds(List<String> stationIdList);
}

View File

@@ -921,8 +921,8 @@ public class MemberBasicInfoServiceImpl implements MemberBasicInfoService {
}
@Override
public Long countTodayNewMembers() {
return memberBasicInfoMapper.countTodayNewMembers();
public Long countTodayNewMembers(String startTime, String endTime) {
return memberBasicInfoMapper.countTodayNewMembers(startTime, endTime);
}
}

View File

@@ -6706,5 +6706,33 @@ public class OrderBasicInfoServiceImpl implements OrderBasicInfoService {
public List<TimeDistributionVO> getTimeDistribution(IndexQueryDTO dto) {
return orderBasicInfoMapper.getTimeDistribution(dto);
}
@Override
public java.math.BigDecimal getTodayTransactionAmount(String startTime, String endTime) {
List<java.math.BigDecimal> rows = orderBasicInfoMapper.getTodayOrderAmountRows(startTime, endTime);
java.math.BigDecimal total = java.math.BigDecimal.ZERO;
if (rows != null) {
for (java.math.BigDecimal amount : rows) {
if (amount != null) {
total = total.add(amount);
}
}
}
return total;
}
@Override
public java.math.BigDecimal getTodayElectricity(String startTime, String endTime) {
List<java.math.BigDecimal> rows = orderBasicInfoMapper.getTodayElectricityRows(startTime, endTime);
java.math.BigDecimal total = java.math.BigDecimal.ZERO;
if (rows != null) {
for (java.math.BigDecimal elec : rows) {
if (elec != null) {
total = total.add(elec);
}
}
}
return total;
}
}

View File

@@ -985,8 +985,9 @@ public class PileBasicInfoServiceImpl implements PileBasicInfoService {
}
log.info("后管首页基本信息查询 authorizedMap:{}, dto:{}", JSON.toJSONString(authorizedMap), JSON.toJSONString(dto));
dto.setStationIdList(stationIdList);
// IndexGeneralSituationVO generalInfo = pileBasicInfoMapper.getGeneralSituation(dto);
IndexGeneralSituationVO generalInfo = pileBasicInfoMapper.getGeneralSituationInfo(dto);
// 查询settle_order_report原始行记录Java汇总不用SQL的SUM
List<IndexGeneralSituationVO> reportRows = pileBasicInfoMapper.getGeneralSituationInfo(dto);
IndexGeneralSituationVO generalInfo = aggregateSituationRows(reportRows);
List<PileInfoVO> pileInfoVOS = queryPileDetailList(stationIdList);
// 对集合根据pileSn进行去重
@@ -1635,17 +1636,72 @@ public class PileBasicInfoServiceImpl implements PileBasicInfoService {
}
@Override
public java.math.BigDecimal getTodayTransactionAmount() {
return pileBasicInfoMapper.getTodayTransactionAmount();
public java.math.BigDecimal getMonthlyAvgElectricity(String monthStartDate, String monthEndDate) {
List<java.math.BigDecimal> rows = pileBasicInfoMapper.getMonthlyAvgElectricity(monthStartDate, monthEndDate);
if (rows == null || rows.isEmpty()) {
return java.math.BigDecimal.ZERO;
}
java.math.BigDecimal total = java.math.BigDecimal.ZERO;
for (java.math.BigDecimal val : rows) {
if (val != null) {
total = total.add(val);
}
}
return total.divide(new java.math.BigDecimal(rows.size()), 2, java.math.RoundingMode.HALF_UP);
}
@Override
public java.math.BigDecimal getTodayElectricity() {
return pileBasicInfoMapper.getTodayElectricity();
public Long countTotalPilesByStationIds(List<String> stationIdList) {
return pileBasicInfoMapper.countTotalPilesByStationIds(stationIdList);
}
@Override
public java.math.BigDecimal getMonthlyAvgElectricity() {
return pileBasicInfoMapper.getMonthlyAvgElectricity();
public Long countTotalPilesByMerchantIds(List<String> merchantIdList) {
return pileBasicInfoMapper.countTotalPilesByMerchantIds(merchantIdList);
}
@Override
public IndexGeneralSituationVO aggregateReportByMerchantIds(List<String> merchantIdList) {
List<IndexGeneralSituationVO> rows = pileBasicInfoMapper.getSettleReportGroupByMerchant(merchantIdList);
return aggregateSituationRows(rows);
}
@Override
public IndexGeneralSituationVO aggregateReportByStationIds(List<String> stationIdList) {
List<IndexGeneralSituationVO> rows = pileBasicInfoMapper.getSettleReportGroupByStation(stationIdList);
return aggregateSituationRows(rows);
}
/**
* Java层汇总settle_order_report GROUP BY结果每行是一个商户/站点的汇总)
*/
private IndexGeneralSituationVO aggregateSituationRows(List<IndexGeneralSituationVO> rows) {
IndexGeneralSituationVO result = new IndexGeneralSituationVO();
BigDecimal totalAmount = BigDecimal.ZERO;
BigDecimal settleAmount = BigDecimal.ZERO;
BigDecimal totalDegree = BigDecimal.ZERO;
long totalQuantity = 0L;
if (rows != null) {
for (IndexGeneralSituationVO row : rows) {
if (row.getTotalChargingAmount() != null) {
totalAmount = totalAmount.add(new BigDecimal(row.getTotalChargingAmount()));
}
if (row.getTotalSettleAmount() != null) {
settleAmount = settleAmount.add(new BigDecimal(row.getTotalSettleAmount()));
}
if (row.getTotalChargingDegree() != null) {
totalDegree = totalDegree.add(new BigDecimal(row.getTotalChargingDegree()));
}
if (row.getTotalChargingQuantity() != null && !row.getTotalChargingQuantity().isEmpty()) {
String qty = row.getTotalChargingQuantity().replaceAll("[.](.*)", "");
totalQuantity += Long.parseLong(qty);
}
}
}
result.setTotalChargingAmount(totalAmount.toPlainString());
result.setTotalSettleAmount(settleAmount.toPlainString());
result.setTotalChargingDegree(totalDegree.toPlainString());
result.setTotalChargingQuantity(String.valueOf(totalQuantity));
return result;
}
}

View File

@@ -344,6 +344,8 @@
</select>
<select id="countTodayNewMembers" resultType="java.lang.Long">
select count(*) from member_basic_info where del_flag = '0' and DATE(create_time) = CURDATE()
select count(*) from member_basic_info where del_flag = '0'
and create_time <![CDATA[ >= ]]> #{startTime}
and create_time <![CDATA[ < ]]> #{endTime}
</select>
</mapper>

View File

@@ -3703,4 +3703,25 @@
GROUP BY HOUR(t1.create_time)
ORDER BY hour ASC
</select>
<!-- 今日交易金额明细Java汇总日期由代码传入 -->
<select id="getTodayOrderAmountRows" resultType="java.math.BigDecimal">
select t1.order_amount
from order_basic_info t1
where t1.del_flag = '0'
and t1.order_status = '6'
and t1.create_time <![CDATA[ >= ]]> #{startTime}
and t1.create_time <![CDATA[ < ]]> #{endTime}
</select>
<!-- 今日充电电量明细Java汇总日期由代码传入 -->
<select id="getTodayElectricityRows" resultType="java.math.BigDecimal">
select t2.total_used_electricity
from order_basic_info t1
join order_detail t2 on t2.order_code = t1.order_code and t2.del_flag = '0'
where t1.del_flag = '0'
and t1.order_status = '6'
and t1.create_time <![CDATA[ >= ]]> #{startTime}
and t1.create_time <![CDATA[ < ]]> #{endTime}
</select>
</mapper>

View File

@@ -400,10 +400,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="getGeneralSituationInfo" resultType="com.jsowell.pile.vo.web.IndexGeneralSituationVO">
select
ifnull(sum(t1.total_amount), 0) as totalChargingAmount,
ifnull(sum(t1.settle_amount), 0) as totalSettleAmount,
ifnull(sum(t1.use_electricity), 0) as totalChargingDegree,
ifnull(sum(t1.charge_num), 0) as totalChargingQuantity
t1.total_amount as totalChargingAmount,
t1.settle_amount as totalSettleAmount,
t1.use_electricity as totalChargingDegree,
t1.charge_num as totalChargingQuantity
from
settle_order_report t1
where
@@ -497,29 +497,69 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</foreach>
</update>
<select id="getTodayTransactionAmount" resultType="java.math.BigDecimal">
select ifnull(sum(t1.total_amount), 0)
from settle_order_report t1
where t1.del_flag = '0'
and t1.trade_date = DATE_FORMAT(CURDATE(), '%Y-%m-%d')
</select>
<select id="getTodayElectricity" resultType="java.math.BigDecimal">
select ifnull(sum(t1.use_electricity), 0)
from settle_order_report t1
where t1.del_flag = '0'
and t1.trade_date = DATE_FORMAT(CURDATE(), '%Y-%m-%d')
</select>
<select id="getMonthlyAvgElectricity" resultType="java.math.BigDecimal">
select ifnull(avg(day_total), 0)
from (
select sum(t1.use_electricity) as day_total
from settle_order_report t1
where t1.del_flag = '0'
and t1.trade_date >= DATE_FORMAT(DATE_SUB(CURDATE(), INTERVAL DAYOFMONTH(CURDATE()) - 1 DAY), '%Y-%m-%d')
and t1.trade_date &lt; DATE_FORMAT(DATE_ADD(CURDATE(), INTERVAL 1 DAY), '%Y-%m-%d')
group by t1.trade_date
) day_data
select t1.use_electricity
from settle_order_report t1
where t1.del_flag = '0'
and t1.trade_date >= #{monthStartDate}
and t1.trade_date <![CDATA[ < ]]> #{monthEndDate}
</select>
<select id="countTotalPilesByStationIds" resultType="java.lang.Long">
select count(distinct t1.sn)
from pile_basic_info t1
where t1.del_flag = '0'
<if test="stationIdList != null and stationIdList.size() > 0">
and t1.station_id in
<foreach collection="stationIdList" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</if>
</select>
<select id="countTotalPilesByMerchantIds" resultType="java.lang.Long">
select count(distinct t1.sn)
from pile_basic_info t1
where t1.del_flag = '0'
<if test="merchantIdList != null and merchantIdList.size() > 0">
and t1.merchant_id in
<foreach collection="merchantIdList" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</if>
</select>
<!-- 按merchantId分组汇总settle_order_report每个商户一行Java再汇总 -->
<select id="getSettleReportGroupByMerchant" resultType="com.jsowell.pile.vo.web.IndexGeneralSituationVO">
select
t1.total_amount as totalChargingAmount,
t1.settle_amount as totalSettleAmount,
t1.use_electricity as totalChargingDegree,
t1.charge_num as totalChargingQuantity
from settle_order_report t1
where t1.del_flag = '0'
<if test="merchantIdList != null and merchantIdList.size() > 0">
and t1.merchant_id in
<foreach collection="merchantIdList" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</if>
</select>
<!-- 按stationId查settle_order_report原始行Java汇总返回 -->
<select id="getSettleReportGroupByStation" resultType="com.jsowell.pile.vo.web.IndexGeneralSituationVO">
select
t1.total_amount as totalChargingAmount,
t1.settle_amount as totalSettleAmount,
t1.use_electricity as totalChargingDegree,
t1.charge_num as totalChargingQuantity
from settle_order_report t1
where t1.del_flag = '0'
<if test="stationIdList != null and stationIdList.size() > 0">
and t1.station_id in
<foreach collection="stationIdList" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</if>
</select>
</mapper>