mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-04-20 19:15:35 +08:00
update
This commit is contained in:
@@ -31,7 +31,6 @@ import com.jsowell.pile.dto.*;
|
||||
import com.jsowell.pile.service.*;
|
||||
import com.jsowell.pile.transaction.dto.MemberTransactionDTO;
|
||||
import com.jsowell.pile.transaction.service.TransactionService;
|
||||
import com.jsowell.pile.vo.MemberPlateNumberVO;
|
||||
import com.jsowell.pile.vo.uniapp.InvoiceTitleVO;
|
||||
import com.jsowell.pile.vo.uniapp.MemberVO;
|
||||
import com.jsowell.pile.vo.uniapp.MemberWalletLogVO;
|
||||
|
||||
@@ -30,11 +30,9 @@ import com.jsowell.common.enums.ykc.*;
|
||||
import com.jsowell.common.exception.BusinessException;
|
||||
import com.jsowell.common.util.*;
|
||||
import com.jsowell.common.util.bean.BeanUtils;
|
||||
import com.jsowell.common.util.id.IdUtils;
|
||||
import com.jsowell.pile.domain.*;
|
||||
import com.jsowell.pile.dto.*;
|
||||
import com.jsowell.pile.service.*;
|
||||
import com.jsowell.pile.transaction.dto.OrderTransactionDTO;
|
||||
import com.jsowell.pile.transaction.service.TransactionService;
|
||||
import com.jsowell.pile.vo.base.OrderAmountDetailVO;
|
||||
import com.jsowell.pile.vo.base.OrderPeriodAmountVO;
|
||||
@@ -136,24 +134,37 @@ public class OrderService {
|
||||
* @return
|
||||
*/
|
||||
public String generateOrder(GenerateOrderDTO dto) throws ParseException {
|
||||
log.info("generateOrder param:{}", JSONObject.toJSONString(dto));
|
||||
// 处理前端传的参数
|
||||
analysisPileParameter(dto);
|
||||
// log.info("generateOrder param:{}", JSONObject.toJSONString(dto));
|
||||
// // 处理前端传的参数
|
||||
// analysisPileParameter(dto);
|
||||
//
|
||||
// // 校验充电桩相关的信息
|
||||
// checkPileInfo(dto);
|
||||
//
|
||||
// // 保存订单到数据库 saveOrder2Database
|
||||
// String orderCode = saveOrder2Database(dto);
|
||||
|
||||
// 校验充电桩相关的信息
|
||||
checkPileInfo(dto);
|
||||
|
||||
// 保存订单到数据库 saveOrder2Database
|
||||
String orderCode = saveOrder2Database(dto);
|
||||
String orderCode = orderBasicInfoService.generateOrder(dto);
|
||||
return orderCode;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取到vin 查询对应的用户,得到余额
|
||||
*
|
||||
* 生成订单
|
||||
*
|
||||
* 支付订单
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* 订单支付
|
||||
*
|
||||
* @param dto
|
||||
*/
|
||||
public Map<String, Object> payOrder(PayOrderDTO dto) throws Exception {
|
||||
orderBasicInfoService.payOrder(dto);
|
||||
|
||||
OrderBasicInfo orderInfo = orderBasicInfoService.getOrderInfoByOrderCode(dto.getOrderCode());
|
||||
if (orderInfo == null) {
|
||||
throw new BusinessException(ReturnCodeEnum.CODE_QUERY_ORDER_NULL_ERROR);
|
||||
@@ -496,112 +507,112 @@ public class OrderService {
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
private String saveOrder2Database(GenerateOrderDTO dto) throws ParseException {
|
||||
String orderCode = IdUtils.getOrderCode();
|
||||
String transactionCode = IdUtils.generateTransactionCode(dto.getPileSn(), dto.getConnectorCode());
|
||||
|
||||
if (StringUtils.isBlank(dto.getStartType())) {
|
||||
dto.setStartType(StartTypeEnum.NOW.getValue());
|
||||
}
|
||||
|
||||
String stationId = dto.getPileConnector().getStationId();
|
||||
// 查询站点信息
|
||||
PileStationInfo pileStationInfo = pileStationInfoService.selectPileStationInfoById(Long.valueOf(stationId));
|
||||
String merchantId = pileStationInfo != null ? String.valueOf(pileStationInfo.getMerchantId()) : "";
|
||||
|
||||
// 订单基本信息
|
||||
OrderBasicInfo orderBasicInfo = OrderBasicInfo.builder()
|
||||
.orderCode(orderCode)
|
||||
.transactionCode(transactionCode)
|
||||
.orderStatus(OrderStatusEnum.NOT_START.getValue())
|
||||
.memberId(dto.getMemberId())
|
||||
.stationId(stationId)
|
||||
.merchantId(merchantId)
|
||||
.pileSn(dto.getPileSn())
|
||||
.connectorCode(dto.getConnectorCode())
|
||||
.pileConnectorCode(dto.getPileSn() + dto.getConnectorCode())
|
||||
.startMode(dto.getStartMode())
|
||||
.payStatus(Constants.ZERO)
|
||||
.payAmount(dto.getChargeAmount())
|
||||
.payMode(dto.getPayMode())
|
||||
.orderAmount(BigDecimal.ZERO)
|
||||
.virtualAmount(BigDecimal.ZERO)
|
||||
.settleAmount(BigDecimal.ZERO)
|
||||
.startType(dto.getStartType())
|
||||
.build();
|
||||
if (StringUtils.equals(dto.getStartType(), StartTypeEnum.APPOINTMENT.getValue())) {
|
||||
orderBasicInfo.setAppointmentTime(DateUtils.parseDate(dto.getAppointmentTime(), DateUtils.YYYY_MM_DD_HH_MM_SS));
|
||||
}
|
||||
|
||||
// 订单详情
|
||||
BillingTemplateVO billingTemplate = dto.getBillingTemplate();
|
||||
log.info("订单使用的计费模板-orderCode:{}, billingTemplate:{}", orderCode, JSONObject.toJSONString(billingTemplate));
|
||||
BigDecimal sharpElectricityPrice = billingTemplate.getSharpElectricityPrice() != null ? billingTemplate.getSharpElectricityPrice() : BigDecimal.ZERO;
|
||||
BigDecimal sharpServicePrice = billingTemplate.getSharpServicePrice() != null ? billingTemplate.getSharpServicePrice() : BigDecimal.ZERO;
|
||||
BigDecimal peakElectricityPrice = billingTemplate.getPeakElectricityPrice() != null ? billingTemplate.getPeakElectricityPrice() : BigDecimal.ZERO;
|
||||
BigDecimal peakServicePrice = billingTemplate.getPeakServicePrice() != null ? billingTemplate.getPeakServicePrice() : BigDecimal.ZERO;
|
||||
BigDecimal flatElectricityPrice = billingTemplate.getFlatElectricityPrice() != null ? billingTemplate.getFlatElectricityPrice() : BigDecimal.ZERO;
|
||||
BigDecimal flatServicePrice = billingTemplate.getFlatServicePrice() != null ? billingTemplate.getFlatServicePrice() : BigDecimal.ZERO;
|
||||
BigDecimal valleyElectricityPrice = billingTemplate.getValleyElectricityPrice() != null ? billingTemplate.getValleyElectricityPrice() : BigDecimal.ZERO;
|
||||
BigDecimal valleyServicePrice = billingTemplate.getValleyServicePrice() != null ? billingTemplate.getValleyServicePrice() : BigDecimal.ZERO;
|
||||
|
||||
OrderDetail orderDetail = OrderDetail.builder()
|
||||
.orderCode(orderCode)
|
||||
.sharpPrice(sharpElectricityPrice.add(sharpServicePrice))
|
||||
.sharpElectricityPrice(sharpElectricityPrice)
|
||||
.sharpServicePrice(sharpServicePrice)
|
||||
.peakPrice(peakElectricityPrice.add(peakServicePrice))
|
||||
.peakElectricityPrice(peakElectricityPrice)
|
||||
.peakServicePrice(peakServicePrice)
|
||||
.flatPrice(flatElectricityPrice.add(flatServicePrice))
|
||||
.flatElectricityPrice(flatElectricityPrice)
|
||||
.flatServicePrice(flatServicePrice)
|
||||
.valleyPrice(valleyElectricityPrice.add(valleyServicePrice))
|
||||
.valleyElectricityPrice(valleyElectricityPrice)
|
||||
.valleyServicePrice(valleyServicePrice)
|
||||
.build();
|
||||
|
||||
OrderTransactionDTO createOrderTransactionDTO = OrderTransactionDTO.builder()
|
||||
.orderBasicInfo(orderBasicInfo)
|
||||
.orderDetail(orderDetail)
|
||||
.build();
|
||||
pileTransactionService.doCreateOrder(createOrderTransactionDTO);
|
||||
return orderCode;
|
||||
}
|
||||
// private String saveOrder2Database(GenerateOrderDTO dto) throws ParseException {
|
||||
// String orderCode = IdUtils.getOrderCode();
|
||||
// String transactionCode = IdUtils.generateTransactionCode(dto.getPileSn(), dto.getConnectorCode());
|
||||
//
|
||||
// if (StringUtils.isBlank(dto.getStartType())) {
|
||||
// dto.setStartType(StartTypeEnum.NOW.getValue());
|
||||
// }
|
||||
//
|
||||
// String stationId = dto.getPileConnector().getStationId();
|
||||
// // 查询站点信息
|
||||
// PileStationInfo pileStationInfo = pileStationInfoService.selectPileStationInfoById(Long.valueOf(stationId));
|
||||
// String merchantId = pileStationInfo != null ? String.valueOf(pileStationInfo.getMerchantId()) : "";
|
||||
//
|
||||
// // 订单基本信息
|
||||
// OrderBasicInfo orderBasicInfo = OrderBasicInfo.builder()
|
||||
// .orderCode(orderCode)
|
||||
// .transactionCode(transactionCode)
|
||||
// .orderStatus(OrderStatusEnum.NOT_START.getValue())
|
||||
// .memberId(dto.getMemberId())
|
||||
// .stationId(stationId)
|
||||
// .merchantId(merchantId)
|
||||
// .pileSn(dto.getPileSn())
|
||||
// .connectorCode(dto.getConnectorCode())
|
||||
// .pileConnectorCode(dto.getPileSn() + dto.getConnectorCode())
|
||||
// .startMode(dto.getStartMode())
|
||||
// .payStatus(Constants.ZERO)
|
||||
// .payAmount(dto.getChargeAmount())
|
||||
// .payMode(dto.getPayMode())
|
||||
// .orderAmount(BigDecimal.ZERO)
|
||||
// .virtualAmount(BigDecimal.ZERO)
|
||||
// .settleAmount(BigDecimal.ZERO)
|
||||
// .startType(dto.getStartType())
|
||||
// .build();
|
||||
// if (StringUtils.equals(dto.getStartType(), StartTypeEnum.APPOINTMENT.getValue())) {
|
||||
// orderBasicInfo.setAppointmentTime(DateUtils.parseDate(dto.getAppointmentTime(), DateUtils.YYYY_MM_DD_HH_MM_SS));
|
||||
// }
|
||||
//
|
||||
// // 订单详情
|
||||
// BillingTemplateVO billingTemplate = dto.getBillingTemplate();
|
||||
// log.info("订单使用的计费模板-orderCode:{}, billingTemplate:{}", orderCode, JSONObject.toJSONString(billingTemplate));
|
||||
// BigDecimal sharpElectricityPrice = billingTemplate.getSharpElectricityPrice() != null ? billingTemplate.getSharpElectricityPrice() : BigDecimal.ZERO;
|
||||
// BigDecimal sharpServicePrice = billingTemplate.getSharpServicePrice() != null ? billingTemplate.getSharpServicePrice() : BigDecimal.ZERO;
|
||||
// BigDecimal peakElectricityPrice = billingTemplate.getPeakElectricityPrice() != null ? billingTemplate.getPeakElectricityPrice() : BigDecimal.ZERO;
|
||||
// BigDecimal peakServicePrice = billingTemplate.getPeakServicePrice() != null ? billingTemplate.getPeakServicePrice() : BigDecimal.ZERO;
|
||||
// BigDecimal flatElectricityPrice = billingTemplate.getFlatElectricityPrice() != null ? billingTemplate.getFlatElectricityPrice() : BigDecimal.ZERO;
|
||||
// BigDecimal flatServicePrice = billingTemplate.getFlatServicePrice() != null ? billingTemplate.getFlatServicePrice() : BigDecimal.ZERO;
|
||||
// BigDecimal valleyElectricityPrice = billingTemplate.getValleyElectricityPrice() != null ? billingTemplate.getValleyElectricityPrice() : BigDecimal.ZERO;
|
||||
// BigDecimal valleyServicePrice = billingTemplate.getValleyServicePrice() != null ? billingTemplate.getValleyServicePrice() : BigDecimal.ZERO;
|
||||
//
|
||||
// OrderDetail orderDetail = OrderDetail.builder()
|
||||
// .orderCode(orderCode)
|
||||
// .sharpPrice(sharpElectricityPrice.add(sharpServicePrice))
|
||||
// .sharpElectricityPrice(sharpElectricityPrice)
|
||||
// .sharpServicePrice(sharpServicePrice)
|
||||
// .peakPrice(peakElectricityPrice.add(peakServicePrice))
|
||||
// .peakElectricityPrice(peakElectricityPrice)
|
||||
// .peakServicePrice(peakServicePrice)
|
||||
// .flatPrice(flatElectricityPrice.add(flatServicePrice))
|
||||
// .flatElectricityPrice(flatElectricityPrice)
|
||||
// .flatServicePrice(flatServicePrice)
|
||||
// .valleyPrice(valleyElectricityPrice.add(valleyServicePrice))
|
||||
// .valleyElectricityPrice(valleyElectricityPrice)
|
||||
// .valleyServicePrice(valleyServicePrice)
|
||||
// .build();
|
||||
//
|
||||
// OrderTransactionDTO createOrderTransactionDTO = OrderTransactionDTO.builder()
|
||||
// .orderBasicInfo(orderBasicInfo)
|
||||
// .orderDetail(orderDetail)
|
||||
// .build();
|
||||
// pileTransactionService.doCreateOrder(createOrderTransactionDTO);
|
||||
// return orderCode;
|
||||
// }
|
||||
|
||||
/**
|
||||
* 校验充电桩相关的信息
|
||||
*
|
||||
* @param dto
|
||||
*/
|
||||
private void checkPileInfo(GenerateOrderDTO dto) {
|
||||
// 查询充电桩状态 是否空闲 枪口是否占用
|
||||
PileConnectorDetailVO pileConnector = pileService.queryPileConnectorDetail(dto.getPileSn() + dto.getConnectorCode());
|
||||
if (pileConnector == null) {
|
||||
log.error("checkPileInfo充电枪口为空 pileSn:{}, connectorCode:{}", dto.getPileSn(), dto.getConnectorCode());
|
||||
throw new BusinessException(ReturnCodeEnum.CODE_CONNECTOR_INFO_NULL_ERROR);
|
||||
}
|
||||
|
||||
// 查询站点状态
|
||||
PileStationVO stationInfo = pileStationInfoService.getStationInfo(pileConnector.getStationId());
|
||||
if (stationInfo == null || StringUtils.equals(stationInfo.getOpenFlag(), Constants.ZERO)) {
|
||||
throw new BusinessException(ReturnCodeEnum.CODE_STATION_IS_NOT_OPEN);
|
||||
}
|
||||
|
||||
// 判断枪口状态
|
||||
if (!(StringUtils.equals(pileConnector.getConnectorStatus(), PileConnectorDataBaseStatusEnum.FREE.getValue())
|
||||
|| StringUtils.equals(pileConnector.getConnectorStatus(), PileConnectorDataBaseStatusEnum.OCCUPIED_NOT_CHARGED.getValue()))) {
|
||||
log.error("checkPileInfo充电枪口状态不正确,当前状态为:{}", pileConnector.getConnectorStatus());
|
||||
throw new BusinessException(ReturnCodeEnum.CODE_PILE_CONNECTOR_STATUS_ERROR);
|
||||
}
|
||||
// 查询充电桩的计费模板
|
||||
BillingTemplateVO billingTemplateVO = pileBillingTemplateService.selectBillingTemplateDetailByPileSn(dto.getPileSn());
|
||||
if (billingTemplateVO == null) {
|
||||
throw new BusinessException(ReturnCodeEnum.CODE_BILLING_TEMPLATE_NULL_ERROR);
|
||||
}
|
||||
dto.setPileConnector(pileConnector);
|
||||
dto.setBillingTemplate(billingTemplateVO);
|
||||
}
|
||||
// private void checkPileInfo(GenerateOrderDTO dto) {
|
||||
// // 查询充电桩状态 是否空闲 枪口是否占用
|
||||
// PileConnectorDetailVO pileConnector = pileService.queryPileConnectorDetail(dto.getPileSn() + dto.getConnectorCode());
|
||||
// if (pileConnector == null) {
|
||||
// log.error("checkPileInfo充电枪口为空 pileSn:{}, connectorCode:{}", dto.getPileSn(), dto.getConnectorCode());
|
||||
// throw new BusinessException(ReturnCodeEnum.CODE_CONNECTOR_INFO_NULL_ERROR);
|
||||
// }
|
||||
//
|
||||
// // 查询站点状态
|
||||
// PileStationVO stationInfo = pileStationInfoService.getStationInfo(pileConnector.getStationId());
|
||||
// if (stationInfo == null || StringUtils.equals(stationInfo.getOpenFlag(), Constants.ZERO)) {
|
||||
// throw new BusinessException(ReturnCodeEnum.CODE_STATION_IS_NOT_OPEN);
|
||||
// }
|
||||
//
|
||||
// // 判断枪口状态
|
||||
// if (!(StringUtils.equals(pileConnector.getConnectorStatus(), PileConnectorDataBaseStatusEnum.FREE.getValue())
|
||||
// || StringUtils.equals(pileConnector.getConnectorStatus(), PileConnectorDataBaseStatusEnum.OCCUPIED_NOT_CHARGED.getValue()))) {
|
||||
// log.error("checkPileInfo充电枪口状态不正确,当前状态为:{}", pileConnector.getConnectorStatus());
|
||||
// throw new BusinessException(ReturnCodeEnum.CODE_PILE_CONNECTOR_STATUS_ERROR);
|
||||
// }
|
||||
// // 查询充电桩的计费模板
|
||||
// BillingTemplateVO billingTemplateVO = pileBillingTemplateService.selectBillingTemplateDetailByPileSn(dto.getPileSn());
|
||||
// if (billingTemplateVO == null) {
|
||||
// throw new BusinessException(ReturnCodeEnum.CODE_BILLING_TEMPLATE_NULL_ERROR);
|
||||
// }
|
||||
// dto.setPileConnector(pileConnector);
|
||||
// dto.setBillingTemplate(billingTemplateVO);
|
||||
// }
|
||||
|
||||
|
||||
/**
|
||||
@@ -610,23 +621,23 @@ public class OrderService {
|
||||
*
|
||||
* @param dto
|
||||
*/
|
||||
public void analysisPileParameter(BasicPileDTO dto) {
|
||||
if (StringUtils.isBlank(dto.getPileSn()) || StringUtils.isBlank(dto.getConnectorCode())) {
|
||||
// 从pileConnectorCode解析
|
||||
String pileConnectorCode = dto.getPileConnectorCode();
|
||||
if (StringUtils.isNotEmpty(pileConnectorCode) && pileConnectorCode.length() == Constants.PILE_CONNECTOR_CODE_LENGTH) {
|
||||
dto.setPileSn(StringUtils.substring(pileConnectorCode, 0, pileConnectorCode.length() - 2));
|
||||
dto.setConnectorCode(StringUtils.substring(pileConnectorCode, pileConnectorCode.length() - 2, pileConnectorCode.length()));
|
||||
} else {
|
||||
throw new BusinessException(ReturnCodeEnum.CODE_DATA_LENGTH_ERROR);
|
||||
}
|
||||
} else {
|
||||
// 说明pileSn 和 connectorCode前端传了,那就校验一下长度
|
||||
if (dto.getPileSn().length() != Constants.PILE_SN_LENGTH || dto.getConnectorCode().length() != Constants.CONNECTOR_CODE_LENGTH) {
|
||||
throw new BusinessException(ReturnCodeEnum.CODE_DATA_LENGTH_ERROR);
|
||||
}
|
||||
}
|
||||
}
|
||||
// public void analysisPileParameter(BasicPileDTO dto) {
|
||||
// if (StringUtils.isBlank(dto.getPileSn()) || StringUtils.isBlank(dto.getConnectorCode())) {
|
||||
// // 从pileConnectorCode解析
|
||||
// String pileConnectorCode = dto.getPileConnectorCode();
|
||||
// if (StringUtils.isNotEmpty(pileConnectorCode) && pileConnectorCode.length() == Constants.PILE_CONNECTOR_CODE_LENGTH) {
|
||||
// dto.setPileSn(StringUtils.substring(pileConnectorCode, 0, pileConnectorCode.length() - 2));
|
||||
// dto.setConnectorCode(StringUtils.substring(pileConnectorCode, pileConnectorCode.length() - 2, pileConnectorCode.length()));
|
||||
// } else {
|
||||
// throw new BusinessException(ReturnCodeEnum.CODE_DATA_LENGTH_ERROR);
|
||||
// }
|
||||
// } else {
|
||||
// // 说明pileSn 和 connectorCode前端传了,那就校验一下长度
|
||||
// if (dto.getPileSn().length() != Constants.PILE_SN_LENGTH || dto.getConnectorCode().length() != Constants.CONNECTOR_CODE_LENGTH) {
|
||||
// throw new BusinessException(ReturnCodeEnum.CODE_DATA_LENGTH_ERROR);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
/**
|
||||
* 结算订单
|
||||
@@ -635,7 +646,7 @@ public class OrderService {
|
||||
* @param dto 结算订单参数
|
||||
*/
|
||||
public void settleOrderForWeb(SettleOrderDTO dto) {
|
||||
analysisPileParameter(dto);
|
||||
orderBasicInfoService.analysisPileParameter(dto);
|
||||
// 查询订单详情,验证订单中的桩编号是否正确
|
||||
OrderBasicInfo orderBasicInfo = orderBasicInfoService.getOrderInfoByOrderCode(dto.getOrderCode());
|
||||
if (orderBasicInfo == null) {
|
||||
|
||||
@@ -1,229 +0,0 @@
|
||||
package com.jsowell.service;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.jsowell.common.enums.ykc.ReturnCodeEnum;
|
||||
import com.jsowell.common.exception.BusinessException;
|
||||
import com.jsowell.common.util.StringUtils;
|
||||
import com.jsowell.pile.domain.PileBillingRelation;
|
||||
import com.jsowell.pile.domain.PileBillingTemplate;
|
||||
import com.jsowell.pile.domain.PileFirmwareInfo;
|
||||
import com.jsowell.pile.domain.ykcCommond.*;
|
||||
import com.jsowell.pile.dto.PublishBillingTemplateDTO;
|
||||
import com.jsowell.pile.dto.RemoteAccountBalanceUpdateDTO;
|
||||
import com.jsowell.pile.dto.UpdateFirmwareDTO;
|
||||
import com.jsowell.pile.service.IPileBasicInfoService;
|
||||
import com.jsowell.pile.service.IPileBillingTemplateService;
|
||||
import com.jsowell.pile.service.IPileFirmwareInfoService;
|
||||
import com.jsowell.pile.service.YKCPushCommandService;
|
||||
import com.jsowell.pile.vo.web.BillingTemplateVO;
|
||||
import com.jsowell.pile.vo.web.PileDetailVO;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class PileRemoteService {
|
||||
private final Logger log = LoggerFactory.getLogger(this.getClass());
|
||||
|
||||
@Autowired
|
||||
private IPileBillingTemplateService pileBillingTemplateService;
|
||||
|
||||
@Autowired
|
||||
private IPileBasicInfoService pileBasicInfoService;
|
||||
|
||||
@Autowired
|
||||
private YKCPushCommandService ykcPushCommandService;
|
||||
|
||||
@Autowired
|
||||
private IPileFirmwareInfoService pileFirmwareInfoService;
|
||||
|
||||
|
||||
/**
|
||||
* 获取充电桩实时数据信息
|
||||
*
|
||||
* @param pileSn 充电桩sn
|
||||
* @param connectorCode 枪口号
|
||||
*/
|
||||
public void getRealTimeMonitorData(String pileSn, String connectorCode) {
|
||||
if (StringUtils.isNotEmpty(pileSn) || StringUtils.isNotEmpty(connectorCode)) {
|
||||
GetRealTimeMonitorDataCommand command = GetRealTimeMonitorDataCommand.builder()
|
||||
.pileSn(pileSn)
|
||||
.connectorCode(connectorCode)
|
||||
.build();
|
||||
ykcPushCommandService.pushGetRealTimeMonitorDataCommand(command);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 重启指令
|
||||
*
|
||||
* @param pileSn 充电桩sn
|
||||
*/
|
||||
public void reboot(String pileSn) {
|
||||
RebootCommand command = RebootCommand.builder().pileSn(pileSn).build();
|
||||
ykcPushCommandService.pushRebootCommand(command);
|
||||
}
|
||||
|
||||
/**
|
||||
* 远程启动充电 0x34
|
||||
*
|
||||
* @param pileSn 充电桩sn
|
||||
*/
|
||||
public void remoteStartCharging(String pileSn, String connectorCode, String transactionCode, BigDecimal accountBalance) {
|
||||
// String s = "550314127823050120180619144446808800000000000101000000100000057300000000D14B0A54A0860100";
|
||||
if (StringUtils.isEmpty(pileSn) || StringUtils.isEmpty(connectorCode)) {
|
||||
log.warn("远程启动充电, 充电桩编号和枪口号不能为空");
|
||||
return;
|
||||
}
|
||||
log.info("=====平台下发指令=====: 远程启动充电, 桩号:{}, 枪口号:{}", pileSn, connectorCode);
|
||||
StartChargingCommand startChargingCommand = StartChargingCommand.builder()
|
||||
.pileSn(pileSn)
|
||||
.connectorCode(connectorCode)
|
||||
.transactionCode(transactionCode)
|
||||
.chargeAmount(accountBalance)
|
||||
.build();
|
||||
ykcPushCommandService.pushStartChargingCommand(startChargingCommand);
|
||||
}
|
||||
|
||||
/**
|
||||
* 远程停止充电
|
||||
*/
|
||||
public void remoteStopCharging(String pileSn, String connectorCode) {
|
||||
StopChargingCommand command = StopChargingCommand.builder()
|
||||
.pileSn(pileSn)
|
||||
.connectorCode(connectorCode)
|
||||
.build();
|
||||
ykcPushCommandService.pushStopChargingCommand(command);
|
||||
}
|
||||
|
||||
/**
|
||||
* 下发充电桩二维码
|
||||
*
|
||||
* @param pileSn 充电桩sn
|
||||
*/
|
||||
public void issueQRCode(String pileSn) {
|
||||
issueQRCode(pileSn, null);
|
||||
}
|
||||
|
||||
public void issueQRCode(String pileSn, String qrcodePrefix) {
|
||||
IssueQRCodeCommand command = IssueQRCodeCommand.builder().pileSn(pileSn).build();
|
||||
if (StringUtils.isNotBlank(qrcodePrefix)) {
|
||||
command.setQrcodePrefix(qrcodePrefix);
|
||||
}
|
||||
ykcPushCommandService.pushIssueQRCodeCommand(command);
|
||||
}
|
||||
|
||||
/**
|
||||
* 充电桩对时
|
||||
*
|
||||
* @param pileSn 充电桩sn
|
||||
*/
|
||||
public void proofreadTime(String pileSn) {
|
||||
|
||||
ProofreadTimeCommand command = ProofreadTimeCommand.builder().pileSn(pileSn).build();
|
||||
ykcPushCommandService.pushProofreadTimeCommand(command);
|
||||
}
|
||||
|
||||
/**
|
||||
* 下发充电桩计费模型
|
||||
*/
|
||||
public void publishPileBillingTemplate(String pileSn, BillingTemplateVO billingTemplateVO) {
|
||||
|
||||
PublishPileBillingTemplateCommand command = PublishPileBillingTemplateCommand.builder()
|
||||
.billingTemplateVO(billingTemplateVO)
|
||||
.pileSn(pileSn)
|
||||
.build();
|
||||
ykcPushCommandService.pushPublishPileBillingTemplate(command);
|
||||
}
|
||||
|
||||
/**
|
||||
* 下发计费模板
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
public boolean publishBillingTemplate(PublishBillingTemplateDTO dto) {
|
||||
|
||||
// 获取计费模板信息
|
||||
BillingTemplateVO billingTemplateVO = pileBillingTemplateService.selectBillingTemplateByTemplateId(dto.getTemplateId());
|
||||
if (billingTemplateVO == null) {
|
||||
log.warn("获取计费模板信息, 通过模板id:{}查询计费模板为null", dto.getTemplateId());
|
||||
return false;
|
||||
}
|
||||
// 更新计费模板的发布时间
|
||||
PileBillingTemplate pileBillingTemplate = new PileBillingTemplate();
|
||||
pileBillingTemplate.setId(Long.valueOf(billingTemplateVO.getTemplateId()));
|
||||
pileBillingTemplate.setPublishTime(new Date());
|
||||
pileBillingTemplateService.updatePileBillingTemplate(pileBillingTemplate);
|
||||
|
||||
// 获取到站点下所有的桩
|
||||
List<PileDetailVO> pileList = pileBasicInfoService.selectPileListByStationIds(Lists.newArrayList(Long.valueOf(dto.getStationId())));
|
||||
if (CollectionUtils.isEmpty(pileList)) {
|
||||
log.warn("获取到站点下所有的桩, 通过站点id:{}查询充电桩列表为空", dto.getStationId());
|
||||
return false;
|
||||
}
|
||||
|
||||
// 保存计费模板和桩的关系
|
||||
List<PileBillingRelation> relationList = Lists.newArrayList();
|
||||
for (PileDetailVO pileInfoVO : pileList) {
|
||||
// push
|
||||
publishPileBillingTemplate(pileInfoVO.getPileSn(), billingTemplateVO);
|
||||
|
||||
// 入库
|
||||
relationList.add(PileBillingRelation.builder()
|
||||
.pileSn(pileInfoVO.getPileSn())
|
||||
.billingTemplateCode(billingTemplateVO.getTemplateCode())
|
||||
.stationId(dto.getStationId())
|
||||
.build());
|
||||
}
|
||||
|
||||
if (CollectionUtils.isNotEmpty(relationList)) {
|
||||
pileBillingTemplateService.insertPileBillingRelation(relationList);
|
||||
}
|
||||
|
||||
// 修改计费模板状态
|
||||
pileBillingTemplateService.changeStationTemplate(dto.getStationId(), dto.getTemplateId());
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 远程更新
|
||||
*/
|
||||
public void updateFirmware(UpdateFirmwareDTO dto) {
|
||||
if (StringUtils.isBlank(dto.getFirmwareId())) {
|
||||
throw new BusinessException(ReturnCodeEnum.CODE_PARAM_NOT_NULL_ERROR);
|
||||
}
|
||||
PileFirmwareInfo pileFirmwareInfo = pileFirmwareInfoService.selectPileFirmwareInfoById(Long.valueOf(dto.getFirmwareId()));
|
||||
if (pileFirmwareInfo == null) {
|
||||
throw new BusinessException(ReturnCodeEnum.CODE_FIRMWARE_NOT_FOUND_ERROR);
|
||||
}
|
||||
UpdateFirmwareCommand command = UpdateFirmwareCommand.builder()
|
||||
.pileSnList(dto.getPileSns())
|
||||
.filePath(pileFirmwareInfo.getFilePath())
|
||||
.build();
|
||||
ykcPushCommandService.pushUpdateFileCommand(command);
|
||||
}
|
||||
|
||||
/**
|
||||
* 远程账户余额更新
|
||||
*/
|
||||
public void remoteAccountBalanceUpdate(RemoteAccountBalanceUpdateDTO dto) {
|
||||
RemoteAccountBalanceUpdateCommand command = RemoteAccountBalanceUpdateCommand.builder()
|
||||
.pileSn(dto.getPileSn())
|
||||
.connectorCode(dto.getConnectorCode())
|
||||
.accountBalance(dto.getAccountBalance())
|
||||
|
||||
.build();
|
||||
if (StringUtils.isNotBlank(dto.getLogicCard())) {
|
||||
command.setLogicCard(dto.getLogicCard());
|
||||
}
|
||||
ykcPushCommandService.pushAccountBalanceUpdateCommand(command);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -16,7 +16,7 @@ import com.jsowell.common.util.DateUtils;
|
||||
import com.jsowell.common.util.SecurityUtils;
|
||||
import com.jsowell.common.util.StringUtils;
|
||||
import com.jsowell.common.util.id.SnUtils;
|
||||
import com.jsowell.pile.service.YKCPushCommandService;
|
||||
import com.jsowell.pile.service.*;
|
||||
import com.jsowell.pile.domain.MemberBasicInfo;
|
||||
import com.jsowell.pile.domain.OrderBasicInfo;
|
||||
import com.jsowell.pile.domain.PileBasicInfo;
|
||||
@@ -28,14 +28,6 @@ import com.jsowell.pile.dto.MemberRegisterAndLoginDTO;
|
||||
import com.jsowell.pile.dto.PileMemberBindingDTO;
|
||||
import com.jsowell.pile.dto.QueryPersonPileDTO;
|
||||
import com.jsowell.pile.dto.QueryStationDTO;
|
||||
import com.jsowell.pile.service.IMemberBasicInfoService;
|
||||
import com.jsowell.pile.service.IOrderBasicInfoService;
|
||||
import com.jsowell.pile.service.IPileBasicInfoService;
|
||||
import com.jsowell.pile.service.IPileBillingTemplateService;
|
||||
import com.jsowell.pile.service.IPileConnectorInfoService;
|
||||
import com.jsowell.pile.service.IPileMemberRelationService;
|
||||
import com.jsowell.pile.service.IPileMerchantInfoService;
|
||||
import com.jsowell.pile.service.IPileStationInfoService;
|
||||
import com.jsowell.pile.transaction.dto.PileTransactionDTO;
|
||||
import com.jsowell.pile.transaction.service.TransactionService;
|
||||
import com.jsowell.pile.vo.base.ConnectorInfoVO;
|
||||
|
||||
@@ -14,7 +14,7 @@ import com.jsowell.pile.dto.ImportBillingTemplateDTO;
|
||||
import com.jsowell.pile.dto.PublishBillingTemplateDTO;
|
||||
import com.jsowell.pile.service.IPileBillingTemplateService;
|
||||
import com.jsowell.pile.vo.web.BillingTemplateVO;
|
||||
import com.jsowell.service.PileRemoteService;
|
||||
import com.jsowell.pile.service.PileRemoteService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
@@ -9,7 +9,7 @@ import com.jsowell.pile.dto.GenerateOrderDTO;
|
||||
import com.jsowell.pile.dto.QueryPileDTO;
|
||||
import com.jsowell.pile.dto.UpdateFirmwareDTO;
|
||||
import com.jsowell.service.OrderService;
|
||||
import com.jsowell.service.PileRemoteService;
|
||||
import com.jsowell.pile.service.PileRemoteService;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
|
||||
@@ -43,7 +43,7 @@ import com.jsowell.pile.vo.web.OrderListVO;
|
||||
import com.jsowell.pile.vo.web.PileDetailVO;
|
||||
import com.jsowell.service.MemberService;
|
||||
import com.jsowell.service.OrderService;
|
||||
import com.jsowell.service.PileRemoteService;
|
||||
import com.jsowell.pile.service.PileRemoteService;
|
||||
import com.jsowell.service.PileService;
|
||||
import com.jsowell.thirdparty.amap.service.AMapService;
|
||||
import com.jsowell.thirdparty.lianlian.dto.CommonParamsDTO;
|
||||
@@ -817,7 +817,7 @@ public class SpringBootTestController {
|
||||
dto.setPileSn("");
|
||||
dto.setConnectorCode("");
|
||||
dto.setPileConnectorCode("");
|
||||
orderService.analysisPileParameter(dto);
|
||||
// orderService.analysisPileParameter(dto);
|
||||
System.out.println("数据正确");
|
||||
} catch (BusinessException e) {
|
||||
System.out.println(e.getMessage());
|
||||
@@ -830,7 +830,7 @@ public class SpringBootTestController {
|
||||
dto.setConnectorCode("");
|
||||
dto.setPileConnectorCode("");
|
||||
dto.setPileSn("88000000000001");
|
||||
orderService.analysisPileParameter(dto);
|
||||
// orderService.analysisPileParameter(dto);
|
||||
System.out.println("数据正确");
|
||||
} catch (BusinessException e) {
|
||||
System.out.println(e.getMessage());
|
||||
@@ -843,7 +843,7 @@ public class SpringBootTestController {
|
||||
dto.setConnectorCode("01");
|
||||
dto.setPileConnectorCode("");
|
||||
dto.setPileSn("");
|
||||
orderService.analysisPileParameter(dto);
|
||||
// orderService.analysisPileParameter(dto);
|
||||
System.out.println("数据正确");
|
||||
} catch (BusinessException e) {
|
||||
System.out.println(e.getMessage());
|
||||
@@ -856,7 +856,7 @@ public class SpringBootTestController {
|
||||
dto.setPileConnectorCode("8800000000000101");
|
||||
dto.setConnectorCode("");
|
||||
dto.setPileSn("");
|
||||
orderService.analysisPileParameter(dto);
|
||||
// orderService.analysisPileParameter(dto);
|
||||
System.out.println("数据正确");
|
||||
} catch (BusinessException e) {
|
||||
System.out.println(e.getMessage());
|
||||
@@ -868,7 +868,7 @@ public class SpringBootTestController {
|
||||
dto.setPileConnectorCode("");
|
||||
dto.setConnectorCode("01");
|
||||
dto.setPileSn("88000000000001");
|
||||
orderService.analysisPileParameter(dto);
|
||||
// orderService.analysisPileParameter(dto);
|
||||
System.out.println("数据正确");
|
||||
} catch (BusinessException e) {
|
||||
System.out.println(e.getMessage());
|
||||
|
||||
Reference in New Issue
Block a user