Merge branch 'dev-new' into dev-new-rabbitmq

# Conflicts:
#	jsowell-admin/src/test/java/SpringBootTestController.java
This commit is contained in:
Guoqs
2024-11-19 17:13:09 +08:00
12 changed files with 364 additions and 64 deletions

View File

@@ -18,6 +18,7 @@ import com.jsowell.pile.vo.PileReservationInfoVO;
import com.jsowell.pile.vo.uniapp.customer.PersonPileConnectorSumInfoVO;
import com.jsowell.pile.vo.uniapp.customer.PersonPileRealTimeVO;
import com.jsowell.pile.vo.uniapp.customer.PersonalPileInfoVO;
import com.jsowell.service.OrderService;
import com.jsowell.service.PileService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
@@ -39,6 +40,9 @@ public class PersonPileController extends BaseController {
@Autowired
private PileService pileService;
@Autowired
private OrderService orderService;
@Autowired
private PileMerchantInfoService pileMerchantInfoService;
@@ -268,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);
@@ -482,4 +486,27 @@ public class PersonPileController extends BaseController {
logger.info("根据充电桩查询预约状态params:{}, result:{}", dto, JSON.toJSONString(response));
return response;
}
/**
* 保存蓝牙充电记录
* http://localhost:8080/uniapp/personalPile/saveBluetoothChargingRecord
*/
@PostMapping("/saveBluetoothChargingRecord")
public RestApiResponse<?> saveBluetoothChargingRecord(HttpServletRequest request, @RequestBody BluetoothChargingRecordDTO dto) {
RestApiResponse<?> response = null;
try {
String memberId = getMemberIdByAuthorization(request);
dto.setMemberId(memberId);
orderService.saveBluetoothChargingRecord(dto);
response = new RestApiResponse<>();
} catch (BusinessException e) {
logger.error("保存蓝牙充电记录error, params:{}", dto, e);
response = new RestApiResponse<>(e.getCode(), e.getMessage());
} catch (Exception e) {
logger.error("保存蓝牙充电记录error, params:{}", dto, e);
response = new RestApiResponse<>(ReturnCodeEnum.CODE_QUERY_RESERVATION_STATUS_ERROR);
}
logger.info("保存蓝牙充电记录params:{}, result:{}", dto, JSON.toJSONString(response));
return response;
}
}

View File

@@ -1445,4 +1445,11 @@ public class OrderService {
// }
return true;
}
/**
* 保存蓝牙充电记录
* @param dto
*/
public void saveBluetoothChargingRecord(BluetoothChargingRecordDTO dto) {
}
}

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();
}
/**
* 获取总充电时长、总充电量
*