mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-05-08 12:00:11 +08:00
update 获取个人桩充电记录
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取总充电时长、总充电量
|
||||
*
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
package com.jsowell.pile.mapper;
|
||||
|
||||
import com.jsowell.pile.domain.PersonalChargingRecord;
|
||||
import java.util.List;
|
||||
import com.jsowell.pile.dto.QueryPersonPileDTO;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface PersonalChargingRecordMapper {
|
||||
int deleteByPrimaryKey(Integer id);
|
||||
|
||||
@@ -28,4 +30,6 @@ public interface PersonalChargingRecordMapper {
|
||||
int batchInsert(@Param("list") List<PersonalChargingRecord> list);
|
||||
|
||||
PersonalChargingRecord selectByTransactionCode(String transactionCode);
|
||||
|
||||
List<PersonalChargingRecord> getPersonalChargingRecord(QueryPersonPileDTO dto);
|
||||
}
|
||||
@@ -1,10 +1,11 @@
|
||||
package com.jsowell.pile.service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.jsowell.common.core.domain.ykc.TransactionRecordsData;
|
||||
import com.jsowell.pile.domain.OrderBasicInfo;
|
||||
import com.jsowell.pile.domain.PersonalChargingRecord;
|
||||
import com.jsowell.pile.dto.QueryPersonPileDTO;
|
||||
|
||||
import java.util.List;
|
||||
public interface PersonalChargingRecordService{
|
||||
|
||||
|
||||
@@ -38,4 +39,9 @@ public interface PersonalChargingRecordService{
|
||||
void processPersonalChargingRecord(TransactionRecordsData data);
|
||||
|
||||
void processPersonalChargingRecord(OrderBasicInfo orderBasicInfo);
|
||||
|
||||
/**
|
||||
* 获取个人桩充电记录
|
||||
*/
|
||||
List<PersonalChargingRecord> getPersonalChargingRecord(QueryPersonPileDTO dto);
|
||||
}
|
||||
|
||||
@@ -4,16 +4,18 @@ import com.jsowell.common.constant.Constants;
|
||||
import com.jsowell.common.core.domain.ykc.TransactionRecordsData;
|
||||
import com.jsowell.common.util.DateUtils;
|
||||
import com.jsowell.pile.domain.OrderBasicInfo;
|
||||
import com.jsowell.pile.domain.PersonalChargingRecord;
|
||||
import com.jsowell.pile.domain.PileBasicInfo;
|
||||
import com.jsowell.pile.dto.QueryPersonPileDTO;
|
||||
import com.jsowell.pile.mapper.PersonalChargingRecordMapper;
|
||||
import com.jsowell.pile.service.PersonalChargingRecordService;
|
||||
import com.jsowell.pile.service.PileBasicInfoService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
import com.jsowell.pile.mapper.PersonalChargingRecordMapper;
|
||||
import com.jsowell.pile.domain.PersonalChargingRecord;
|
||||
import com.jsowell.pile.service.PersonalChargingRecordService;
|
||||
@Service
|
||||
public class PersonalChargingRecordServiceImpl implements PersonalChargingRecordService{
|
||||
|
||||
@@ -177,4 +179,9 @@ public class PersonalChargingRecordServiceImpl implements PersonalChargingRecord
|
||||
personalChargingRecordMapper.insertOrUpdateSelective(chargingRecord);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PersonalChargingRecord> getPersonalChargingRecord(QueryPersonPileDTO dto) {
|
||||
return personalChargingRecordMapper.getPersonalChargingRecord(dto);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1220,4 +1220,15 @@
|
||||
where del_flag = '0'
|
||||
and transaction_code = #{transactionCode,jdbcType=VARCHAR}
|
||||
</select>
|
||||
|
||||
<select id="getPersonalChargingRecord" resultMap="BaseResultMap">
|
||||
select
|
||||
<include refid="Base_Column_List" />
|
||||
from personal_charging_record
|
||||
where del_flag = '0'
|
||||
and pile_connector_code = #{pileConnectorCode,jdbcType=VARCHAR}
|
||||
AND create_time <![CDATA[ >= ]]> #{startTime,jdbcType=VARCHAR}
|
||||
AND create_time <![CDATA[ <= ]]> #{endTime,jdbcType=VARCHAR}
|
||||
order by create_time desc
|
||||
</select>
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user