mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-06-12 11:19:52 +08:00
update 分页查询场站订单排行
This commit is contained in:
@@ -38,4 +38,14 @@ public class BusinessOperationAnalysisQueryDTO {
|
||||
* 当前选中的指标编码
|
||||
*/
|
||||
private String selectedMetricCode;
|
||||
|
||||
/**
|
||||
* 页码(用于场站排行分页)
|
||||
*/
|
||||
private Integer pageNum;
|
||||
|
||||
/**
|
||||
* 每页条数(用于场站排行分页)
|
||||
*/
|
||||
private Integer pageSize;
|
||||
}
|
||||
|
||||
@@ -11,12 +11,9 @@ import com.jsowell.pile.vo.uniapp.business.BusinessEfficiencyVO;
|
||||
import com.jsowell.pile.vo.uniapp.business.BusinessGunEfficiencyAnalysisVO;
|
||||
import com.jsowell.pile.vo.uniapp.business.BusinessOperationAnalysisVO;
|
||||
import com.jsowell.pile.vo.uniapp.business.BusinessScaleVO;
|
||||
import com.jsowell.pile.vo.uniapp.business.BusinessStationRankVO;
|
||||
import com.jsowell.pile.vo.web.MerchantOrderReportVO;
|
||||
import com.jsowell.pile.vo.web.ParkingCouponRecordVO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface BusinessFinancialService {
|
||||
MerchantOrderReportVO getMyWallet(MerchantOrderReportDTO dto);
|
||||
|
||||
@@ -61,12 +58,12 @@ public interface BusinessFinancialService {
|
||||
BusinessEfficiencyVO getBusinessEfficiency(BusinessEfficiencyQueryDTO dto);
|
||||
|
||||
/**
|
||||
* 查询场站订单排行
|
||||
* 分页查询场站订单排行
|
||||
*
|
||||
* @param dto 查询条件
|
||||
* @return 场站订单排行列表(按订单数量降序)
|
||||
* @param dto 查询条件(含pageNum、pageSize)
|
||||
* @return 分页结果(场站订单排行列表,按订单数量降序)
|
||||
*/
|
||||
List<BusinessStationRankVO> getStationOrderRank(BusinessOperationAnalysisQueryDTO dto);
|
||||
PageResponse getStationOrderRank(BusinessOperationAnalysisQueryDTO dto);
|
||||
|
||||
/**
|
||||
* 查询效率分析(单均效率 + 枪均效率)
|
||||
|
||||
@@ -898,16 +898,16 @@ public class BusinessFinancialServiceImpl implements BusinessFinancialService {
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询场站订单排行
|
||||
* 按站点分组统计订单数量,按订单数量降序排列
|
||||
* 分页查询场站订单排行
|
||||
* 按站点分组统计订单数量,按订单数量降序排列,支持分页
|
||||
*
|
||||
* @param dto 查询条件
|
||||
* @return 场站订单排行列表
|
||||
* @param dto 查询条件(含pageNum、pageSize)
|
||||
* @return 分页结果
|
||||
*/
|
||||
@Override
|
||||
public List<BusinessStationRankVO> getStationOrderRank(BusinessOperationAnalysisQueryDTO dto) {
|
||||
public PageResponse getStationOrderRank(BusinessOperationAnalysisQueryDTO dto) {
|
||||
if (dto == null) {
|
||||
return new ArrayList<>();
|
||||
return PageResponse.builder().pageNum(1).pageSize(10).list(new ArrayList<>()).total(0).pages(0).build();
|
||||
}
|
||||
if (StringUtils.isBlank(dto.getStartTime()) && StringUtils.isBlank(dto.getEndTime())) {
|
||||
LocalDate endDate = LocalDate.now();
|
||||
@@ -916,6 +916,10 @@ public class BusinessFinancialServiceImpl implements BusinessFinancialService {
|
||||
dto.setEndTime(endDate.toString());
|
||||
}
|
||||
|
||||
// 设置默认分页参数
|
||||
int pageNum = dto.getPageNum() != null && dto.getPageNum() > 0 ? dto.getPageNum() : 1;
|
||||
int pageSize = dto.getPageSize() != null && dto.getPageSize() > 0 ? dto.getPageSize() : 10;
|
||||
|
||||
List<String> stationIdList = resolveStationIds(dto.getStationIdList());
|
||||
|
||||
// 查询结算报表原始数据
|
||||
@@ -923,7 +927,7 @@ public class BusinessFinancialServiceImpl implements BusinessFinancialService {
|
||||
stationIdList, dto.getStartTime(), dto.getEndTime());
|
||||
|
||||
if (CollectionUtils.isEmpty(reportList)) {
|
||||
return new ArrayList<>();
|
||||
return PageResponse.builder().pageNum(pageNum).pageSize(pageSize).list(new ArrayList<>()).total(0).pages(0).build();
|
||||
}
|
||||
|
||||
// 按站点ID分组,累加订单数量
|
||||
@@ -937,20 +941,11 @@ public class BusinessFinancialServiceImpl implements BusinessFinancialService {
|
||||
stationOrderCountMap.merge(sId, chargeNum, Integer::sum);
|
||||
}
|
||||
|
||||
// 批量查询站点名称
|
||||
// 批量查询站点名称(一次性查出所有站点,内存中按ID匹配,避免N+1查询)
|
||||
List<PileStationInfo> allStations = pileStationInfoService.selectPileStationInfoList(new PileStationInfo());
|
||||
Map<String, String> stationNameMap = new LinkedHashMap<>();
|
||||
for (String sId : stationOrderCountMap.keySet()) {
|
||||
try {
|
||||
PileStationInfo stationInfo = pileStationInfoService.selectPileStationInfoById(Long.valueOf(sId));
|
||||
if (stationInfo != null) {
|
||||
stationNameMap.put(sId, stationInfo.getStationName());
|
||||
} else {
|
||||
stationNameMap.put(sId, "未知站点");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.warn("查询站点名称失败 stationId:{}", sId, e);
|
||||
stationNameMap.put(sId, "未知站点");
|
||||
}
|
||||
for (PileStationInfo station : allStations) {
|
||||
stationNameMap.put(String.valueOf(station.getId()), station.getStationName());
|
||||
}
|
||||
|
||||
// 按订单数量降序排列并构建排行列表
|
||||
@@ -965,12 +960,27 @@ public class BusinessFinancialServiceImpl implements BusinessFinancialService {
|
||||
a.getOrderCount() != null ? a.getOrderCount() : 0))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
// 设置排行名次
|
||||
// 设置排行名次(基于全量数据的排名)
|
||||
for (int i = 0; i < rankList.size(); i++) {
|
||||
rankList.get(i).setRank(i + 1);
|
||||
}
|
||||
|
||||
return rankList;
|
||||
// 手动分页
|
||||
long total = rankList.size();
|
||||
int pages = (int) Math.ceil((double) total / pageSize);
|
||||
int fromIndex = (pageNum - 1) * pageSize;
|
||||
int toIndex = Math.min(fromIndex + pageSize, rankList.size());
|
||||
List<BusinessStationRankVO> pageList = fromIndex < rankList.size()
|
||||
? rankList.subList(fromIndex, toIndex)
|
||||
: new ArrayList<>();
|
||||
|
||||
return PageResponse.builder()
|
||||
.pageNum(pageNum)
|
||||
.pageSize(pageSize)
|
||||
.list(pageList)
|
||||
.total(total)
|
||||
.pages(pages)
|
||||
.build();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user