update 联联平台 枪口功率=设备额定功率/枪数

This commit is contained in:
Lemon
2023-06-20 15:52:13 +08:00
parent 780b4c5d5e
commit 6e2ee7f794
10 changed files with 181 additions and 28 deletions

View File

@@ -16,8 +16,10 @@ import com.jsowell.common.core.page.PageResponse;
import com.jsowell.common.core.redis.RedisCache;
import com.jsowell.common.enums.TitleTypeEnum;
import com.jsowell.common.enums.uniapp.BalanceChangesEnum;
import com.jsowell.common.enums.ykc.OrderStatusEnum;
import com.jsowell.common.enums.ykc.ReturnCodeEnum;
import com.jsowell.common.enums.ykc.ScenarioEnum;
import com.jsowell.common.enums.ykc.StartModeEnum;
import com.jsowell.common.exception.BusinessException;
import com.jsowell.common.util.AdapayUtil;
import com.jsowell.common.util.JWTUtils;
@@ -29,15 +31,7 @@ import com.jsowell.pile.domain.MemberInvoiceTitle;
import com.jsowell.pile.domain.MemberPlateNumberRelation;
import com.jsowell.pile.domain.MemberWalletInfo;
import com.jsowell.pile.domain.PileAuthCard;
import com.jsowell.pile.dto.BindingCarNoDTO;
import com.jsowell.pile.dto.BindingCardDTO;
import com.jsowell.pile.dto.InvoiceTitleDTO;
import com.jsowell.pile.dto.MemberRegisterAndLoginDTO;
import com.jsowell.pile.dto.MemberRegisterDTO;
import com.jsowell.pile.dto.PaymentScenarioDTO;
import com.jsowell.pile.dto.UniAppQueryMemberBalanceDTO;
import com.jsowell.pile.dto.WechatLoginDTO;
import com.jsowell.pile.dto.WeixinPayDTO;
import com.jsowell.pile.dto.*;
import com.jsowell.pile.service.IMemberBasicInfoService;
import com.jsowell.pile.service.IMemberInvoiceTitleService;
import com.jsowell.pile.service.IMemberPlateNumberRelationService;
@@ -49,6 +43,7 @@ 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;
import com.jsowell.pile.vo.uniapp.OrderVO;
import com.jsowell.wxpay.service.WxAppletRemoteService;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.compress.utils.Lists;
@@ -60,10 +55,13 @@ import org.springframework.beans.factory.annotation.Value;
import org.springframework.cglib.beans.BeanMap;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.text.ParseException;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Objects;
import java.util.stream.Collectors;
@Service
public class MemberService {
@@ -497,5 +495,29 @@ public class MemberService {
return null;
}
public void rechargeOrderAmount(RechargeOrderAmountDTO dto) throws ParseException {
// 根据memberId查询出当前用户正在充电的 vin启动订单 或 卡启动订单
UniAppQueryOrderDTO orderDTO = new UniAppQueryOrderDTO();
orderDTO.setOrderStatus("4"); // 4-正在充电中
PageResponse pageResponse = orderService.getListByMemberIdAndOrderStatus(dto.getMemberId(), orderDTO);
if (pageResponse == null) {
return;
}
List<OrderVO> list = (List<OrderVO>) pageResponse.getList();
List<OrderVO> chargingList = list.stream()
.filter(orderVO -> orderVO.getOrderStatus().equals(OrderStatusEnum.IN_THE_CHARGING.getValue()))
.collect(Collectors.toList());
for (OrderVO orderVO : chargingList) {
if (StringUtils.equals(orderVO.getStartMode(), StartModeEnum.AUTH_CARD.getValue())
|| StringUtils.equals(orderVO.getStartMode(), StartModeEnum.OFFLINE_CARD.getValue())
|| StringUtils.equals(orderVO.getStartMode(), StartModeEnum.VIN_CODE.getValue())) {
BigDecimal rechargeAmount = new BigDecimal(dto.getRechargeAmount());
orderVO.setPayAmount(orderVO.getPayAmount().add(rechargeAmount));
}
}
// 将充值后的余额计算出来
// 发送0x41指令更新账户余额
}
}

View File

@@ -2,14 +2,8 @@ package com.jsowell.service;
import com.google.common.collect.Lists;
import com.jsowell.common.util.StringUtils;
import com.jsowell.pile.domain.ykcCommond.GetRealTimeMonitorDataCommand;
import com.jsowell.pile.domain.ykcCommond.IssueQRCodeCommand;
import com.jsowell.pile.domain.ykcCommond.ProofreadTimeCommand;
import com.jsowell.pile.domain.ykcCommond.PublishPileBillingTemplateCommand;
import com.jsowell.pile.domain.ykcCommond.RebootCommand;
import com.jsowell.pile.domain.ykcCommond.StartChargingCommand;
import com.jsowell.pile.domain.ykcCommond.StopChargingCommand;
import com.jsowell.pile.domain.ykcCommond.UpdateFirmwareCommand;
import com.jsowell.pile.domain.ykcCommond.*;
import com.jsowell.pile.dto.RemoteAccountBalanceUpdateDTO;
import com.jsowell.pile.service.YKCPushCommandService;
import com.jsowell.pile.domain.PileBillingRelation;
import com.jsowell.pile.domain.PileBillingTemplate;
@@ -199,4 +193,19 @@ public class PileRemoteService {
UpdateFirmwareCommand command = UpdateFirmwareCommand.builder().pileSnList(pileSns).build();
ykcPushCommandService.pushUpdateFileCommand(command);
}
/**
* 远程账户余额更新
*/
public void remoteAccountBalanceUpdate(RemoteAccountBalanceUpdateDTO dto) {
RemoteAccountBalanceUpdateCommand command = RemoteAccountBalanceUpdateCommand.builder()
.pileSn(dto.getPileSn())
.connectorCode(dto.getConnectorCode())
.logicCard(dto.getLogicCard())
.accountBalance(dto.getAccountBalance())
.build();
ykcPushCommandService.pushAccountBalanceUpdateCommand(command);
}
}

View File

@@ -0,0 +1,38 @@
package com.jsowell.pile.domain.ykcCommond;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* 远程账户余额更新命令
*
* @author Lemon
* @Date 2023/6/19 10:11
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
public class RemoteAccountBalanceUpdateCommand {
/**
* 桩编码
*/
private String pileSn;
/**
* 枪口号
*/
private String connectorCode;
/**
* 卡号
*/
private String logicCard;
/**
* 修改后账户余额
*/
private String accountBalance;
}

View File

@@ -0,0 +1,16 @@
package com.jsowell.pile.dto;
import lombok.Data;
/**
* 充值订单金额DTO
*
* @author Lemon
* @Date 2023/6/19 14:40
*/
@Data
public class RechargeOrderAmountDTO {
private String memberId;
private String rechargeAmount;
}

View File

@@ -0,0 +1,33 @@
package com.jsowell.pile.dto;
import lombok.Data;
/**
* 远程账户更新余额 DTO
*
* @author Lemon
* @Date 2023/6/19 10:04
*/
@Data
public class RemoteAccountBalanceUpdateDTO {
/**
* 桩编码
*/
private String pileSn;
/**
* 枪口号
*/
private String connectorCode;
/**
* 卡号
*/
private String logicCard;
/**
* 修改后账户余额
*/
private String accountBalance;
}

View File

@@ -65,4 +65,10 @@ public interface YKCPushCommandService {
* @param command
*/
void pushQueryWorkParamsCommand(QueryWorkParamsCommand command);
/**
* 远程账户余额更新
* @param command
*/
void pushAccountBalanceUpdateCommand(RemoteAccountBalanceUpdateCommand command);
}

View File

@@ -14,16 +14,7 @@ import com.jsowell.common.util.Cp56Time2a.Cp56Time2aUtil;
import com.jsowell.common.util.DateUtils;
import com.jsowell.common.util.StringUtils;
import com.jsowell.common.util.YKCUtils;
import com.jsowell.pile.domain.ykcCommond.GetRealTimeMonitorDataCommand;
import com.jsowell.pile.domain.ykcCommond.IssueQRCodeCommand;
import com.jsowell.pile.domain.ykcCommond.PileSettingCommand;
import com.jsowell.pile.domain.ykcCommond.ProofreadTimeCommand;
import com.jsowell.pile.domain.ykcCommond.PublishPileBillingTemplateCommand;
import com.jsowell.pile.domain.ykcCommond.QueryWorkParamsCommand;
import com.jsowell.pile.domain.ykcCommond.RebootCommand;
import com.jsowell.pile.domain.ykcCommond.StartChargingCommand;
import com.jsowell.pile.domain.ykcCommond.StopChargingCommand;
import com.jsowell.pile.domain.ykcCommond.UpdateFirmwareCommand;
import com.jsowell.pile.domain.ykcCommond.*;
import com.jsowell.pile.service.YKCPushCommandService;
import com.jsowell.pile.service.IPileBasicInfoService;
import com.jsowell.pile.service.IPileBillingTemplateService;
@@ -418,4 +409,29 @@ public class YKCPushCommandServiceImpl implements YKCPushCommandService {
this.push(msg, pileSn, YKCFrameTypeCode.QUERY_PILE_WORK_PARAMS_CODE);
}
/**
* 远程账户余额更新
* @param command
*/
@Override
public void pushAccountBalanceUpdateCommand(RemoteAccountBalanceUpdateCommand command) {
// 桩编号
String pileSn = command.getPileSn();
byte[] pileSnByteArr = BytesUtil.str2Bcd(pileSn);
// 枪口号
String connectorCode = command.getConnectorCode();
byte[] connectorCodeByteArr = BytesUtil.str2Bcd(connectorCode);
// 卡号
String logicCard = command.getLogicCard();
byte[] logicByteArr = BytesUtil.str2Bcd(logicCard);
logicByteArr = BytesUtil.checkLengthAndBehindAppendZero(logicByteArr, 16);
// 修改后账户余额
String accountBalance = command.getAccountBalance();
byte[] priceByte = YKCUtils.getPriceByte(accountBalance, 2);
// 拼装msg信息
byte[] msg = Bytes.concat(pileSnByteArr, connectorCodeByteArr, logicByteArr, priceByte);
this.push(msg, pileSn, YKCFrameTypeCode.REMOTE_ACCOUNT_BALANCE_UPDATE_CODE);
}
}

View File

@@ -62,6 +62,11 @@ public class OrderVO {
*/
private String reason;
/**
* 启动方式
*/
private String startMode;
/**
* 支付状态
*/

View File

@@ -773,6 +773,7 @@
t1.pile_sn as pileSn,
t1.connector_code as connectorCode,
t1.pay_status as payStatus,
t1.start_mode as startMode,
t1.order_amount as orderAmount,
t1.pay_amount as payAmount,
t2.total_used_electricity as chargingDegree,

View File

@@ -1590,7 +1590,14 @@ public class LianLianServiceImpl implements LianLianService {
connectorInfo.setVoltageUpperLimits(Integer.valueOf(modelInfo.getRatedVoltage()));
connectorInfo.setVoltageLowerLimits(Integer.valueOf(modelInfo.getRatedVoltage()));
connectorInfo.setCurrent(Integer.valueOf(modelInfo.getRatedCurrent()));
connectorInfo.setPower(new BigDecimal(modelInfo.getRatedPower()).setScale(1, BigDecimal.ROUND_HALF_UP));
if (!StringUtils.equals(modelInfo.getConnectorNum(), "1")) {
// 如果不是单枪,则枪口功率需要除以枪口数量
String ratedPowerStr = modelInfo.getRatedPower();
BigDecimal ratedPower = new BigDecimal(ratedPowerStr);
connectorInfo.setPower(ratedPower.divide(new BigDecimal(modelInfo.getConnectorNum()), 1, BigDecimal.ROUND_HALF_UP));
}else {
connectorInfo.setPower(new BigDecimal(modelInfo.getRatedPower()).setScale(1, BigDecimal.ROUND_HALF_UP));
}
resultList.add(connectorInfo);
}