mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-04-22 12:05:05 +08:00
新增 运营端小程序 站点枪口利用率趋势统计接口
This commit is contained in:
@@ -37,6 +37,8 @@ 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.customer.CurrentTimePriceDetails;
|
||||
import com.jsowell.pile.vo.web.OrderDetailInfoVO;
|
||||
import com.jsowell.pile.vo.web.PileConnectorInfoVO;
|
||||
import com.jsowell.pile.vo.web.PileStationVO;
|
||||
import com.jsowell.system.service.SysDeptService;
|
||||
import com.jsowell.system.service.SysUserService;
|
||||
@@ -1183,6 +1185,8 @@ public class PileStationInfoServiceImpl implements PileStationInfoService {
|
||||
*/
|
||||
@Override
|
||||
public StationBusinessAnalyzeInfoVO getStationConnectorUsedInfo(StationBusinessAnalyzeInfoDTO dto) {
|
||||
StationBusinessAnalyzeInfoVO vo = new StationBusinessAnalyzeInfoVO();
|
||||
List<BusinessOrderDetailInfoVO> list = new ArrayList<>();
|
||||
List<String> stationIds = dto.getStationIds();
|
||||
String type = dto.getType();
|
||||
String dateTime = dto.getDateTime();
|
||||
@@ -1202,8 +1206,53 @@ public class PileStationInfoServiceImpl implements PileStationInfoService {
|
||||
if (CollectionUtils.isEmpty(orderDetailByStationIds)) {
|
||||
throw new BusinessException(ReturnCodeEnum.CODE_SELECT_INFO_IS_NULL);
|
||||
}
|
||||
// 统计每天有多少把充电枪口有过充电记录
|
||||
// (key:日期,value:有充电记录的枪口数量)
|
||||
Map<String, Integer> collect = orderDetailByStationIds.stream()
|
||||
.sorted(Comparator.comparing(BusinessOrderDetailInfoVO::getTradeDate))
|
||||
.collect(Collectors.groupingBy(
|
||||
BusinessOrderDetailInfoVO::getTradeDate, // 按日期分组
|
||||
Collectors.mapping(
|
||||
BusinessOrderDetailInfoVO::getPileConnectorCode, // 提取充电枪口编号
|
||||
Collectors.collectingAndThen(
|
||||
Collectors.toSet(), // 使用Set去重
|
||||
Set::size // 计算不同枪口编号的数量
|
||||
)
|
||||
)
|
||||
));
|
||||
TreeMap<String, Integer> map = new TreeMap<>(collect);
|
||||
List<Integer> values = new ArrayList<>(map.values());
|
||||
|
||||
// 分组出来key为日期,value为订单信息
|
||||
return null;
|
||||
Integer lastDayNum = Constants.zero;
|
||||
Integer yesterdayNum = Constants.zero;
|
||||
int riseRate = Constants.zero;
|
||||
if (dateTime == null) {
|
||||
// 默认最后一天对比前一天
|
||||
lastDayNum = values.get(values.size() - 1);
|
||||
yesterdayNum = values.get(values.size() - 2);
|
||||
}else {
|
||||
// 目标日期对比目标日期前一天
|
||||
String yesterday = DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD, DateUtils.addDays(DateUtils.parseDate(dateTime), -1));
|
||||
lastDayNum = map.get(dateTime);
|
||||
yesterdayNum = map.get(yesterday);
|
||||
}
|
||||
// 计算增长率
|
||||
if (yesterdayNum != Constants.zero){
|
||||
riseRate = (lastDayNum - yesterdayNum) / yesterdayNum * 100;
|
||||
}
|
||||
String connectorUsedRiseRate = String.valueOf(riseRate);
|
||||
vo.setConnectorUsedRiseRate(connectorUsedRiseRate);
|
||||
|
||||
for (Map.Entry<String, Integer> entry : map.entrySet()) {
|
||||
String tradeDate = entry.getKey();
|
||||
Integer chargeNum = entry.getValue();
|
||||
BusinessOrderDetailInfoVO orderDetailInfoVO = new BusinessOrderDetailInfoVO();
|
||||
orderDetailInfoVO.setTradeDate(tradeDate);
|
||||
orderDetailInfoVO.setChargeNum(chargeNum);
|
||||
|
||||
list.add(orderDetailInfoVO);
|
||||
}
|
||||
vo.setBusinessOrderDetailInfoVOList(list);
|
||||
return vo;
|
||||
}
|
||||
}
|
||||
@@ -23,6 +23,13 @@ public class BusinessOrderDetailInfoVO {
|
||||
*/
|
||||
private String tradeDate;
|
||||
|
||||
private String pileConnectorCode;
|
||||
|
||||
/**
|
||||
* 充电次数
|
||||
*/
|
||||
private Integer chargeNum;
|
||||
|
||||
/**
|
||||
* 订单号
|
||||
*/
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.jsowell.pile.vo.uniapp.business;
|
||||
|
||||
import com.jsowell.pile.domain.SettleOrderReport;
|
||||
import com.jsowell.pile.vo.web.OrderDetailInfoVO;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
@@ -40,6 +41,11 @@ public class StationBusinessAnalyzeInfoVO {
|
||||
*/
|
||||
private String orderNumRateGrowthRate;
|
||||
|
||||
/**
|
||||
* 枪口利用增长率
|
||||
*/
|
||||
private String connectorUsedRiseRate;
|
||||
|
||||
/**
|
||||
* 运营端小程序订单详情VO
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user