mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-04-19 18:45:03 +08:00
add 运营端小程序获取站点统计信息接口V2
This commit is contained in:
@@ -66,8 +66,15 @@ public class BusinessStationInfoController extends BaseController {
|
||||
public RestApiResponse<?> getStationStatisticsInfos(@RequestBody StationStatisticsInfoDTO dto) {
|
||||
RestApiResponse<?> response = null;
|
||||
try {
|
||||
List<StationStatisticsInfosVO> stationStatisticsInfos = pileStationInfoService.getStationStatisticsInfos(dto);
|
||||
response = new RestApiResponse<>(ImmutableMap.of("stationStatisticsInfos", stationStatisticsInfos));
|
||||
// List<StationStatisticsInfosVO> stationStatisticsInfos = pileStationInfoService.getStationStatisticsInfos(dto);
|
||||
// 获取登录账号信息
|
||||
LoginUserDetailVO loginUserDetail = UserUtils.getLoginUserDetail();
|
||||
List<String> merchantIdList = loginUserDetail.getFirstMerchantIdList();
|
||||
if (CollectionUtils.isEmpty(dto.getStationIds())) {
|
||||
dto.setStationIds(pileStationInfoService.getStationIdsByMerchantIds(merchantIdList));
|
||||
}
|
||||
StationStatisticsInfosVO info = pileStationInfoService.getStationStatisticsInfosV2(dto);
|
||||
response = new RestApiResponse<>(ImmutableMap.of("stationStatisticsInfo", info));
|
||||
} catch (Exception e) {
|
||||
logger.error("获取站点统计信息 error", e);
|
||||
response = new RestApiResponse<>(e);
|
||||
|
||||
@@ -181,6 +181,13 @@ public interface PileStationInfoService {
|
||||
*/
|
||||
List<StationStatisticsInfosVO> getStationStatisticsInfos(StationStatisticsInfoDTO dto);
|
||||
|
||||
/**
|
||||
* 获取站点统计信息V2
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
public StationStatisticsInfosVO getStationStatisticsInfosV2(StationStatisticsInfoDTO dto);
|
||||
|
||||
/**
|
||||
* 获取站点运营分析信息(7天、30天)
|
||||
* @param dto
|
||||
|
||||
@@ -1005,6 +1005,60 @@ public class PileStationInfoServiceImpl implements PileStationInfoService {
|
||||
return resultList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取站点统计信息V2
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public StationStatisticsInfosVO getStationStatisticsInfosV2(StationStatisticsInfoDTO dto) {
|
||||
List<String> stationIds = dto.getStationIds();
|
||||
String startTime = dto.getStartTime();
|
||||
String endTime = dto.getEndTime();
|
||||
// 根据站点ids查询充电统计信息
|
||||
List<SettleOrderReport> settleOrderReports = settleOrderReportService.queryOrderReport(stationIds, startTime, endTime);
|
||||
// 初始化统计值
|
||||
BigDecimal chargeDegree = BigDecimal.ZERO;
|
||||
BigDecimal chargeAmount = BigDecimal.ZERO;
|
||||
int orderQuantity = 0;
|
||||
for (SettleOrderReport settleOrderReport : settleOrderReports) {
|
||||
chargeDegree = chargeDegree.add(settleOrderReport.getUseElectricity());
|
||||
chargeAmount = chargeAmount.add(settleOrderReport.getTotalAmount());
|
||||
orderQuantity += Integer.parseInt(settleOrderReport.getChargeNum());
|
||||
}
|
||||
// 批量查询站点中枪口的状态
|
||||
Map<String, Object> connectorStatusNum = pileConnectorInfoService.getConnectorStatusNum(stationIds, null);
|
||||
// 获取总枪口数量和空闲枪口数量
|
||||
int totalConnectorNum = (int) connectorStatusNum.get("totalNum");
|
||||
int freeConnectorNum = (int) connectorStatusNum.get("freeNum");
|
||||
String connectorAvailability = String.format("%.2f", ((double) freeConnectorNum / totalConnectorNum) * 100) + "%";
|
||||
// 获取充电中的枪口数量
|
||||
int chargingConnectorNum = (int) connectorStatusNum.get("chargingNum");
|
||||
// 获取占用中的枪口数量
|
||||
int occupiedConnectorNum = (int) connectorStatusNum.get("occupiedNum");
|
||||
// 获取挂起中的枪口数量
|
||||
int hangingConnectorNum = (int) connectorStatusNum.get("hangingNum");
|
||||
// 获取离线中的枪口数量
|
||||
int offlineConnectorNum = (int) connectorStatusNum.get("offlineNum");
|
||||
// 获取故障中的枪口数量
|
||||
int faultConnectorNum = (int) connectorStatusNum.get("faultNum");
|
||||
|
||||
StationStatisticsInfosVO vo = StationStatisticsInfosVO.builder()
|
||||
.stationId(stationIds.get(0))
|
||||
.chargeDegree(chargeDegree)
|
||||
.chargeAmount(chargeAmount)
|
||||
.orderQuantity(orderQuantity)
|
||||
.connectorAvailability(connectorAvailability)
|
||||
.chargingConnectorNum(chargingConnectorNum)
|
||||
.freeConnectorNum(freeConnectorNum)
|
||||
.occupiedConnectorNum(occupiedConnectorNum)
|
||||
.hangingConnectorNum(hangingConnectorNum)
|
||||
.offlineConnectorNum(offlineConnectorNum)
|
||||
.faultConnectorNum(faultConnectorNum)
|
||||
.build();
|
||||
return vo;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取站点运营分析信息(7天、30天)
|
||||
*
|
||||
|
||||
@@ -50,32 +50,32 @@ public class StationStatisticsInfosVO {
|
||||
private String connectorAvailability;
|
||||
|
||||
/**
|
||||
* 充电中的设备数量
|
||||
* 充电中的枪口数量
|
||||
*/
|
||||
private Integer chargingConnectorNum;
|
||||
|
||||
/**
|
||||
* 空闲中的设备数量
|
||||
* 空闲中的枪口数量
|
||||
*/
|
||||
private Integer freeConnectorNum;
|
||||
|
||||
/**
|
||||
* 占用中的设备数量
|
||||
* 占用中的枪口数量
|
||||
*/
|
||||
private Integer occupiedConnectorNum;
|
||||
|
||||
/**
|
||||
* 挂起中的设备数量
|
||||
* 挂起中的枪口数量
|
||||
*/
|
||||
private Integer hangingConnectorNum;
|
||||
|
||||
/**
|
||||
* 离线设备数量
|
||||
* 离线枪口数量
|
||||
*/
|
||||
private Integer offlineConnectorNum;
|
||||
|
||||
/**
|
||||
* 故障桩数量
|
||||
* 故障枪口数量
|
||||
*/
|
||||
private Integer faultConnectorNum;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user