mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-04-20 11:05:18 +08:00
update
This commit is contained in:
@@ -10,7 +10,7 @@ import com.jsowell.pile.dto.business.StationBusinessAnalyzeInfoDTO;
|
||||
import com.jsowell.pile.dto.business.StationStatisticsInfoDTO;
|
||||
import com.jsowell.pile.service.OrderBasicInfoService;
|
||||
import com.jsowell.pile.service.PileStationInfoService;
|
||||
import com.jsowell.common.core.page.PageResponse;
|
||||
import com.jsowell.pile.vo.uniapp.business.StationWithConnectorStatusPageVO;
|
||||
import com.jsowell.pile.vo.uniapp.business.StationBusinessAnalyzeInfoVO;
|
||||
import com.jsowell.pile.vo.uniapp.business.StationStatisticsInfosVO;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -163,8 +163,8 @@ public class BusinessStationInfoController extends BaseController {
|
||||
public RestApiResponse<?> queryStationWithConnectorStatus(@RequestBody QueryStationWithConnectorStatusDTO dto) {
|
||||
RestApiResponse<?> response = null;
|
||||
try {
|
||||
PageResponse pageResponse = pileStationInfoService.queryStationWithConnectorStatus(dto);
|
||||
response = new RestApiResponse<>(pageResponse);
|
||||
StationWithConnectorStatusPageVO result = pileStationInfoService.queryStationWithConnectorStatus(dto);
|
||||
response = new RestApiResponse<>(result);
|
||||
} catch (Exception e) {
|
||||
logger.error("查询站点及充电枪状态 error", e);
|
||||
response = new RestApiResponse<>(e);
|
||||
|
||||
@@ -15,6 +15,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.uniapp.business.StationWithConnectorStatusPageVO;
|
||||
import com.jsowell.pile.vo.uniapp.business.StationWithConnectorStatusVO;
|
||||
import com.jsowell.pile.vo.web.PileStationVO;
|
||||
import com.jsowell.pile.vo.web.StationSelectVO;
|
||||
@@ -223,5 +224,5 @@ public interface PileStationInfoService {
|
||||
* @param dto 查询条件
|
||||
* @return 站点列表及充电枪状态统计
|
||||
*/
|
||||
PageResponse queryStationWithConnectorStatus(QueryStationWithConnectorStatusDTO dto);
|
||||
StationWithConnectorStatusPageVO queryStationWithConnectorStatus(QueryStationWithConnectorStatusDTO dto);
|
||||
}
|
||||
|
||||
@@ -37,6 +37,7 @@ import com.jsowell.pile.vo.uniapp.business.BusinessOrderDetailInfoVO;
|
||||
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.business.StationWithConnectorStatusPageVO;
|
||||
import com.jsowell.pile.vo.uniapp.business.StationWithConnectorStatusVO;
|
||||
import com.jsowell.pile.vo.uniapp.customer.CurrentTimePriceDetails;
|
||||
import com.jsowell.pile.vo.web.BillingTemplateVO;
|
||||
@@ -1630,10 +1631,10 @@ public class PileStationInfoServiceImpl implements PileStationInfoService {
|
||||
/**
|
||||
* 运营端小程序查询站点及充电枪状态
|
||||
* @param dto 查询条件
|
||||
* @return 站点列表及充电枪状态统计
|
||||
* @return 站点列表及充电枪状态统计(包含总统计)
|
||||
*/
|
||||
@Override
|
||||
public PageResponse queryStationWithConnectorStatus(QueryStationWithConnectorStatusDTO dto) {
|
||||
public StationWithConnectorStatusPageVO queryStationWithConnectorStatus(QueryStationWithConnectorStatusDTO dto) {
|
||||
// 获取当前登录账号的运营商权限
|
||||
List<MerchantInfoVO> merchantInfoVOList = UserUtils.getMerchantInfoVOList();
|
||||
if (CollectionUtils.isEmpty(merchantInfoVOList)) {
|
||||
@@ -1665,14 +1666,49 @@ public class PileStationInfoServiceImpl implements PileStationInfoService {
|
||||
throw new BusinessException(ReturnCodeEnum.CODE_SELECT_INFO_IS_NULL);
|
||||
}
|
||||
|
||||
// 分页处理
|
||||
// 先统计所有站点的总枪口数量(用于前端不传站点时显示总计)
|
||||
int totalConnectorNum = 0; // 总枪口数量
|
||||
int totalChargingNum = 0; // 总充电中数量
|
||||
int totalFreeNum = 0; // 总空闲数量
|
||||
int totalOccupiedNum = 0; // 总占用(未充电)数量
|
||||
int totalHangingNum = 0; // 总挂起(预约锁定)数量
|
||||
int totalOfflineNum = 0; // 总离线数量
|
||||
int totalFaultNum = 0; // 总故障数量
|
||||
|
||||
// 统计所有站点的枪口数量(不计算时长,只统计数量)
|
||||
for (PileStationInfo station : filteredStations) {
|
||||
String stationId = String.valueOf(station.getId());
|
||||
List<ConnectorInfoVO> allConnectorList = pileConnectorInfoService.getUniAppConnectorList(Long.parseLong(stationId));
|
||||
totalConnectorNum += allConnectorList.size();
|
||||
for (ConnectorInfoVO connector : allConnectorList) {
|
||||
String status = connector.getConnectorStatus();
|
||||
if (StringUtils.equals(PileConnectorDataBaseStatusEnum.OCCUPIED_CHARGING.getValue(), status)) {
|
||||
totalChargingNum++;
|
||||
} else if (StringUtils.equals(PileConnectorDataBaseStatusEnum.FREE.getValue(), status)) {
|
||||
totalFreeNum++;
|
||||
} else if (StringUtils.equals(PileConnectorDataBaseStatusEnum.OCCUPIED_NOT_CHARGED.getValue(), status)) {
|
||||
totalOccupiedNum++;
|
||||
} else if (StringUtils.equals(PileConnectorDataBaseStatusEnum.OCCUPIED_RESERVED_LOCK.getValue(), status)) {
|
||||
totalHangingNum++;
|
||||
} else if (StringUtils.equals(PileConnectorDataBaseStatusEnum.OFF_NETWORK.getValue(), status)) {
|
||||
totalOfflineNum++;
|
||||
} else if (StringUtils.equals(PileConnectorDataBaseStatusEnum.FAULT.getValue(), status)) {
|
||||
totalFaultNum++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 分页处理(手动分页,避免PageHelper影响后续查询)
|
||||
int pageNum = dto.getPageNum() == 0 ? 1 : dto.getPageNum();
|
||||
int pageSize = dto.getPageSize() == 0 ? 10 : dto.getPageSize();
|
||||
PageHelper.startPage(pageNum, pageSize);
|
||||
int total = filteredStations.size();
|
||||
int start = (pageNum - 1) * pageSize;
|
||||
int end = Math.min(start + pageSize, total);
|
||||
List<PileStationInfo> pagedStations = start < total ? filteredStations.subList(start, end) : new ArrayList<>();
|
||||
|
||||
// 构建返回结果
|
||||
List<StationWithConnectorStatusVO> resultList = new ArrayList<>();
|
||||
for (PileStationInfo station : filteredStations) {
|
||||
for (PileStationInfo station : pagedStations) {
|
||||
String stationId = String.valueOf(station.getId());
|
||||
|
||||
// 查询站点下的所有充电枪
|
||||
@@ -1696,6 +1732,8 @@ public class PileStationInfoServiceImpl implements PileStationInfoService {
|
||||
if (StringUtils.equals(PileConnectorDataBaseStatusEnum.OCCUPIED_CHARGING.getValue(), status)) {
|
||||
// 充电中:从实时数据中获取剩余时间
|
||||
chargingNum++;
|
||||
// 清除分页参数,避免影响queryChargingByPileConnectorCode查询(该查询已有limit 1)
|
||||
PageHelper.clearPage();
|
||||
OrderBasicInfo order = orderBasicInfoService.queryChargingByPileConnectorCode(pileConnectorCode);
|
||||
if (order != null) {
|
||||
List<RealTimeMonitorData> chargingRealTimeData = orderBasicInfoService.getChargingRealTimeData(order.getTransactionCode());
|
||||
@@ -1777,14 +1815,29 @@ public class PileStationInfoServiceImpl implements PileStationInfoService {
|
||||
}
|
||||
|
||||
|
||||
// 清除分页参数,避免影响后续查询
|
||||
PageHelper.clearPage();
|
||||
|
||||
// 构建分页响应
|
||||
PageInfo<StationWithConnectorStatusVO> pageInfo = new PageInfo<>(resultList);
|
||||
return PageResponse.builder()
|
||||
int totalPages = (total + pageSize - 1) / pageSize;
|
||||
PageResponse pageResponse = PageResponse.builder()
|
||||
.pageNum(pageNum)
|
||||
.pageSize(pageSize)
|
||||
.total(pageInfo.getTotal())
|
||||
.pages(pageInfo.getPages())
|
||||
.total((long) total)
|
||||
.pages(totalPages)
|
||||
.list(resultList)
|
||||
.build();
|
||||
|
||||
// 构建包含总统计的响应
|
||||
return StationWithConnectorStatusPageVO.builder()
|
||||
.pageResponse(pageResponse)
|
||||
.totalConnectorNum(totalConnectorNum)
|
||||
.totalChargingConnectorNum(totalChargingNum)
|
||||
.totalFreeConnectorNum(totalFreeNum)
|
||||
.totalOccupiedConnectorNum(totalOccupiedNum)
|
||||
.totalHangingConnectorNum(totalHangingNum)
|
||||
.totalOfflineConnectorNum(totalOfflineNum)
|
||||
.totalFaultConnectorNum(totalFaultNum)
|
||||
.build();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
package com.jsowell.pile.vo.uniapp.business;
|
||||
|
||||
import com.jsowell.common.core.page.PageResponse;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* 运营端小程序站点及充电枪状态分页VO(包含总统计)
|
||||
*
|
||||
* @author Auto
|
||||
* @Date 2024/12/19
|
||||
*/
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Builder
|
||||
public class StationWithConnectorStatusPageVO {
|
||||
/**
|
||||
* 分页数据
|
||||
*/
|
||||
private PageResponse pageResponse;
|
||||
|
||||
/**
|
||||
* 总枪口数量(所有站点的总计)
|
||||
*/
|
||||
private Integer totalConnectorNum;
|
||||
|
||||
/**
|
||||
* 总充电中枪口数量
|
||||
*/
|
||||
private Integer totalChargingConnectorNum;
|
||||
|
||||
/**
|
||||
* 总空闲枪口数量
|
||||
*/
|
||||
private Integer totalFreeConnectorNum;
|
||||
|
||||
/**
|
||||
* 总占用中枪口数量(未充电)
|
||||
*/
|
||||
private Integer totalOccupiedConnectorNum;
|
||||
|
||||
/**
|
||||
* 总挂起枪口数量(预约锁定)
|
||||
*/
|
||||
private Integer totalHangingConnectorNum;
|
||||
|
||||
/**
|
||||
* 总离线枪口数量
|
||||
*/
|
||||
private Integer totalOfflineConnectorNum;
|
||||
|
||||
/**
|
||||
* 总故障枪口数量
|
||||
*/
|
||||
private Integer totalFaultConnectorNum;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user