update 获取个人桩充电记录

This commit is contained in:
Guoqs
2024-11-19 17:11:07 +08:00
parent 54d9a4e91e
commit 5ee7903204
6 changed files with 77 additions and 21 deletions

View File

@@ -272,7 +272,7 @@ public class PersonPileController extends BaseController {
try {
String memberId = getMemberIdByAuthorization(request);
dto.setMemberId(memberId);
PageResponse chargingRecord = pileService.getChargingRecord(dto);
PageResponse chargingRecord = pileService.getChargingRecordV2(dto);
response = new RestApiResponse<>(chargingRecord);
} catch (BusinessException e) {
logger.error("获取个人桩充电记录 error", e);

View File

@@ -86,6 +86,9 @@ public class PileService {
@Autowired
private PileReservationInfoService pileReservationInfoService;
@Autowired
private PersonalChargingRecordService personalChargingRecordService;
/**
* 查询设备信息
*
@@ -570,20 +573,6 @@ public class PileService {
if (CollectionUtils.isEmpty(accumulativeInfo)) {
throw new BusinessException(ReturnCodeEnum.CODE_QUERY_ORDER_INFO_IS_NULL);
}
// BigDecimal sumChargingTime = BigDecimal.ZERO;
// BigDecimal sumUsedElectricity = BigDecimal.ZERO;
// // 将返回的结果进行for循环将总充电量、总充电时长进行累加充电时长需要通过 充电开始时间 和 充电结束时间 进行计算)
// for (PersonPileConnectorSumInfoVO personPileConnectorSumInfoVO : accumulativeInfo) {
// if (StringUtils.isNotBlank(personPileConnectorSumInfoVO.getChargeStartTime()) && StringUtils.isNotBlank(personPileConnectorSumInfoVO.getChargeEndTime())){
// long longChargingTime = DateUtils.intervalTime(personPileConnectorSumInfoVO.getChargeStartTime(), personPileConnectorSumInfoVO.getChargeEndTime());
// BigDecimal chargingTime = new BigDecimal(String.valueOf(longChargingTime));
// sumChargingTime = sumChargingTime.add(chargingTime);
// }
// BigDecimal chargingDegree = StringUtils.isBlank(personPileConnectorSumInfoVO.getSumChargingDegree())
// ? BigDecimal.ZERO
// : new BigDecimal(personPileConnectorSumInfoVO.getSumChargingDegree());
// sumUsedElectricity = sumUsedElectricity.add(chargingDegree);
// }
Map<String, String> sumInfo = getSumInfo(accumulativeInfo);
// set 对象
PersonPileConnectorSumInfoVO vo = new PersonPileConnectorSumInfoVO();
@@ -632,6 +621,45 @@ public class PileService {
.build();
}
public PageResponse getChargingRecordV2(QueryPersonPileDTO dto) {
int pageNum = dto.getPageNum() == 0 ? 1 : dto.getPageNum();
int pageSize = dto.getPageSize() == 0 ? 10 : dto.getPageSize();
// 获取三十天前的数据
Date date = DateUtils.addMonths(new Date(), -1);
String dateStr = DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, date);
dto.setStartTime(dateStr);
dto.setEndTime(DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, new Date()));
// 分页查询
PageHelper.startPage(pageNum, pageSize);
List<PersonalChargingRecord> personalChargingRecordList = personalChargingRecordService.getPersonalChargingRecord(dto);
if (CollectionUtils.isEmpty(personalChargingRecordList)) {
throw new BusinessException(ReturnCodeEnum.CODE_QUERY_ORDER_INFO_IS_NULL);
}
PageInfo<PersonalChargingRecord> pageInfo = new PageInfo<>(personalChargingRecordList);
List<PersonPileConnectorSumInfoVO> list = Lists.newArrayList();
PersonPileConnectorSumInfoVO vo;
for (PersonalChargingRecord personalChargingRecord : pageInfo.getList()) {
vo = new PersonPileConnectorSumInfoVO();
if (personalChargingRecord.getChargeStartTime() != null && personalChargingRecord.getChargeEndTime() != null){
vo.setChargeStartTime(DateUtils.dateTime(personalChargingRecord.getChargeStartTime()));
vo.setChargeEndTime(DateUtils.dateTime(personalChargingRecord.getChargeEndTime()));
String datePoor = DateUtils.getDatePoor(personalChargingRecord.getChargeEndTime(), personalChargingRecord.getChargeStartTime());
vo.setSumChargingTime(datePoor);
}
vo.setMemberId(personalChargingRecord.getMemberId());
vo.setSumChargingDegree(personalChargingRecord.getTotalUsedElectricity().toString());
list.add(vo);
}
return PageResponse.builder()
.pageNum(pageInfo.getPageNum())
.pageSize(pageInfo.getPageSize())
.list(list)
.pages(pageInfo.getPages())
.total(pageInfo.getTotal())
.build();
}
/**
* 获取总充电时长、总充电量
*