mirror of
https://gitee.com/san-bing/JChargePointProtocol
synced 2026-05-04 18:09:54 +08:00
云快充1.5.0 金额单位修正
This commit is contained in:
@@ -108,9 +108,9 @@ CREATE TABLE IF NOT EXISTS jcpp_order
|
||||
pile_id uuid not null,
|
||||
gun_id uuid not null,
|
||||
plate_no varchar(64),
|
||||
settlement_amount bigint default 0 not null,
|
||||
settlement_amount numeric(16, 8) default 0 not null,
|
||||
settlement_details jsonb,
|
||||
electricity_quantity numeric(16, 9) default 0 not null
|
||||
electricity_quantity numeric(16, 8) default 0 not null
|
||||
);
|
||||
|
||||
CREATE UNIQUE INDEX IF NOT EXISTS uni_internal_order_no
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
*/
|
||||
package sanbing.jcpp.app.dal.mapper;
|
||||
|
||||
import cn.hutool.core.math.Money;
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import jakarta.annotation.Resource;
|
||||
@@ -53,7 +52,7 @@ public class OrderMapperTest extends AbstractTestBase {
|
||||
.pileId(NORMAL_PILE_ID[0])
|
||||
.gunId(NORMAL_GUN_ID[0])
|
||||
.plateNo("浙A88888")
|
||||
.settlementAmount(new Money(100D).getCent())
|
||||
.settlementAmount(new BigDecimal(100))
|
||||
.settlementDetails(JacksonUtil.newObjectNode())
|
||||
.electricityQuantity(new BigDecimal("100"))
|
||||
.build();
|
||||
|
||||
@@ -59,7 +59,7 @@ public class Order implements Serializable {
|
||||
|
||||
private String plateNo;
|
||||
|
||||
private Long settlementAmount;
|
||||
private BigDecimal settlementAmount;
|
||||
|
||||
private JsonNode settlementDetails;
|
||||
|
||||
|
||||
@@ -22,6 +22,7 @@ import sanbing.jcpp.infrastructure.queue.Callback;
|
||||
import sanbing.jcpp.proto.gen.ProtocolProto.*;
|
||||
import sanbing.jcpp.protocol.domain.DownlinkCmdEnum;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalTime;
|
||||
import java.util.*;
|
||||
|
||||
@@ -150,10 +151,10 @@ public class DefaultPileProtocolService implements PileProtocolService {
|
||||
periods.add(createPeriod(4, LocalTime.parse("18:00"), LocalTime.parse("00:00"), VALLEY));
|
||||
|
||||
Map<PricingModelFlag, FlagPrice> flagPriceMap = new HashMap<>();
|
||||
flagPriceMap.put(TOP, new FlagPrice(75, 45));
|
||||
flagPriceMap.put(PEAK, new FlagPrice(75, 45));
|
||||
flagPriceMap.put(FLAT, new FlagPrice(75, 45));
|
||||
flagPriceMap.put(VALLEY, new FlagPrice(75, 45));
|
||||
flagPriceMap.put(TOP, new FlagPrice(new BigDecimal("0.75"), new BigDecimal("0.45")));
|
||||
flagPriceMap.put(PEAK, new FlagPrice(new BigDecimal("0.75"), new BigDecimal("0.45")));
|
||||
flagPriceMap.put(FLAT, new FlagPrice(new BigDecimal("0.75"), new BigDecimal("0.45")));
|
||||
flagPriceMap.put(VALLEY, new FlagPrice(new BigDecimal("0.75"), new BigDecimal("0.45")));
|
||||
|
||||
PricingModel model = new PricingModel();
|
||||
model.setId(UUID.randomUUID());
|
||||
@@ -161,8 +162,8 @@ public class DefaultPileProtocolService implements PileProtocolService {
|
||||
model.setPileCode(pileCode);
|
||||
model.setType(CHARGE);
|
||||
model.setRule(SPLIT_TIME);
|
||||
model.setStandardElec(75);
|
||||
model.setStandardServ(45);
|
||||
model.setStandardElec(new BigDecimal("0.75"));
|
||||
model.setStandardServ(new BigDecimal("0.45"));
|
||||
model.setFlagPriceList(flagPriceMap);
|
||||
model.setPeriodsList(periods);
|
||||
|
||||
|
||||
@@ -24,8 +24,8 @@ public class ProtoConverter {
|
||||
// 设置字段
|
||||
builder.setType(PricingModelType.valueOf(pricingModel.getType().name()));
|
||||
builder.setRule(PricingModelRule.valueOf(pricingModel.getRule().name()));
|
||||
builder.setStandardElec(pricingModel.getStandardElec());
|
||||
builder.setStandardServ(pricingModel.getStandardServ());
|
||||
builder.setStandardElec(pricingModel.getStandardElec().toPlainString());
|
||||
builder.setStandardServ(pricingModel.getStandardServ().toPlainString());
|
||||
|
||||
// 转换 flagPriceList
|
||||
for (Map.Entry<PricingModelFlag, FlagPrice> entry : pricingModel.getFlagPriceList().entrySet()) {
|
||||
@@ -34,8 +34,8 @@ public class ProtoConverter {
|
||||
|
||||
FlagPriceProto flagPriceProto = FlagPriceProto.newBuilder()
|
||||
.setFlag(PricingModelFlag.valueOf(flag.name())) // 枚举转换
|
||||
.setElec(flagPrice.getElec())
|
||||
.setServ(flagPrice.getServ())
|
||||
.setElec(flagPrice.getElec().toPlainString())
|
||||
.setServ(flagPrice.getServ().toPlainString())
|
||||
.build();
|
||||
|
||||
builder.putFlagPrice(flag.ordinal(), flagPriceProto); // 按 ordinal 值作为 key 存入
|
||||
|
||||
@@ -9,6 +9,7 @@ import sanbing.jcpp.proto.gen.ProtocolProto.PricingModelFlag;
|
||||
import sanbing.jcpp.proto.gen.ProtocolProto.PricingModelRule;
|
||||
import sanbing.jcpp.proto.gen.ProtocolProto.PricingModelType;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalTime;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -29,14 +30,14 @@ public class PricingModel {
|
||||
private PricingModelRule rule;
|
||||
|
||||
/**
|
||||
* 标准电价(单位分)
|
||||
* 标准电价(单位元)
|
||||
*/
|
||||
private int standardElec;
|
||||
private BigDecimal standardElec;
|
||||
|
||||
/**
|
||||
* 标准服务费(单位分)
|
||||
* 标准服务费(单位元)
|
||||
*/
|
||||
private int standardServ;
|
||||
private BigDecimal standardServ;
|
||||
|
||||
/**
|
||||
* 分时电价
|
||||
@@ -68,11 +69,11 @@ public class PricingModel {
|
||||
@NoArgsConstructor
|
||||
public static class FlagPrice {
|
||||
|
||||
// 分时电价,单位分
|
||||
private int elec;
|
||||
// 分时电价,单位元
|
||||
private BigDecimal elec;
|
||||
|
||||
// 分时服务费,单位分
|
||||
private int serv;
|
||||
// 分时服务费,单位元
|
||||
private BigDecimal serv;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -96,8 +96,8 @@ message QueryPricingResponse {
|
||||
message PricingModelProto {
|
||||
PricingModelType type = 3;
|
||||
PricingModelRule rule = 4;
|
||||
int32 standardElec = 5;
|
||||
int32 standardServ = 6;
|
||||
string standardElec = 5;
|
||||
string standardServ = 6;
|
||||
map<int32, FlagPriceProto> flagPrice = 8;
|
||||
repeated PeriodProto period = 9;
|
||||
}
|
||||
@@ -111,8 +111,8 @@ message PeriodProto {
|
||||
|
||||
message FlagPriceProto {
|
||||
PricingModelFlag flag = 1;
|
||||
int32 elec = 2;
|
||||
int32 serv = 3;
|
||||
string elec = 2;
|
||||
string serv = 3;
|
||||
}
|
||||
|
||||
enum PricingModelType {
|
||||
@@ -160,12 +160,12 @@ message ChargingProgressProto {
|
||||
string pileCode = 4;
|
||||
string gunCode = 5;
|
||||
string tradeNo = 6;
|
||||
float outputVoltage = 7;
|
||||
float outputCurrent = 8;
|
||||
float soc = 9;
|
||||
string outputVoltage = 7;
|
||||
string outputCurrent = 8;
|
||||
int32 soc = 9;
|
||||
int32 totalChargingDurationMin = 10;
|
||||
float totalChargingEnergyKWh = 11;
|
||||
int64 totalChargingCostCent = 12;
|
||||
string totalChargingEnergyKWh = 11;
|
||||
string totalChargingCostYuan = 12;
|
||||
optional string additionalInfo = 20;
|
||||
}
|
||||
|
||||
@@ -185,7 +185,7 @@ message RemoteStartChargingRequest {
|
||||
string pileCode = 4;
|
||||
string gunCode = 5;
|
||||
string tradeNo = 6;
|
||||
int32 limitCent = 7;
|
||||
int32 limitYuan = 7;
|
||||
optional string additionalInfo = 20;
|
||||
}
|
||||
|
||||
@@ -219,18 +219,18 @@ message TransactionRecord {
|
||||
string tradeNo = 6;
|
||||
int64 startTs = 51;
|
||||
int64 endTs = 52;
|
||||
float topEnergyKWh = 53;
|
||||
int64 topAmountCent = 54;
|
||||
float peakEnergyKWh = 55;
|
||||
int64 peakAmountCent = 56;
|
||||
float flatEnergyKWh = 57;
|
||||
int64 flatAmountCent = 58;
|
||||
float valleyEnergyKWh = 59;
|
||||
int64 valleyAmountCent = 60;
|
||||
float deepEnergyKWh = 61;
|
||||
int64 deepAmountCent = 62;
|
||||
float totalEnergyKWh = 63;
|
||||
int64 totalAmountCent = 64;
|
||||
string topEnergyKWh = 53;
|
||||
string topAmountYuan = 54;
|
||||
string peakEnergyKWh = 55;
|
||||
string peakAmountYuan = 56;
|
||||
string flatEnergyKWh = 57;
|
||||
string flatAmountYuan = 58;
|
||||
string valleyEnergyKWh = 59;
|
||||
string valleyAmountYuan = 60;
|
||||
string deepEnergyKWh = 61;
|
||||
string deepAmountYuan = 62;
|
||||
string totalEnergyKWh = 63;
|
||||
string totalAmountYuan = 64;
|
||||
int64 tradeTs = 65;
|
||||
string stopReason = 66;
|
||||
optional string additionalInfo = 20;
|
||||
|
||||
@@ -128,7 +128,7 @@ class DownlinkControllerTest extends AbstractProtocolTestBase {
|
||||
.setRemoteStartChargingRequest(ProtocolProto.RemoteStartChargingRequest.newBuilder()
|
||||
.setPileCode(pileCode)
|
||||
.setGunCode("01")
|
||||
.setLimitCent(10000)
|
||||
.setLimitYuan(100)
|
||||
.setTradeNo("12345678901234567890")
|
||||
.build())
|
||||
.build();
|
||||
|
||||
@@ -122,7 +122,7 @@ public class YunKuaiChongV150RealTimeDataULCmd extends YunKuaiChongUplinkCmdExe
|
||||
BigDecimal loseEnergy = reduceMagnification(byteBuf.readUnsignedIntLE(), 10000, 4);
|
||||
|
||||
// 17.已充金额 (电费+服务费)*计损充电度数
|
||||
BigDecimal chargeAmount = reduceMagnification(byteBuf.readUnsignedIntLE(), 100);
|
||||
BigDecimal chargeAmount = reduceMagnification(byteBuf.readUnsignedIntLE(), 10000);
|
||||
|
||||
// 18.硬件故障 测试发现需要使用小端计算bit, 然后对照故障表查询故障码
|
||||
byte[] warnCodeBytes = new byte[2];
|
||||
@@ -155,12 +155,12 @@ public class YunKuaiChongV150RealTimeDataULCmd extends YunKuaiChongUplinkCmdExe
|
||||
.setPileCode(pileCode)
|
||||
.setGunCode(gunCode)
|
||||
.setTradeNo(tradeNo)
|
||||
.setOutputVoltage(outputVoltage.floatValue())
|
||||
.setOutputCurrent(outputCurrent.floatValue())
|
||||
.setOutputVoltage(outputVoltage.toPlainString())
|
||||
.setOutputCurrent(outputCurrent.toPlainString())
|
||||
.setSoc(soc)
|
||||
.setTotalChargingDurationMin(totalChargeTime)
|
||||
.setTotalChargingEnergyKWh(loseEnergy.floatValue())
|
||||
.setTotalChargingCostCent(chargeAmount.longValue())
|
||||
.setTotalChargingEnergyKWh(loseEnergy.toPlainString())
|
||||
.setTotalChargingCostYuan(chargeAmount.toPlainString())
|
||||
.setAdditionalInfo(additionalInfo.toString());
|
||||
|
||||
UplinkQueueMessage chargingProgressMessage = uplinkMessageBuilder(pileCode, tcpSession, yunKuaiChongUplinkMessage)
|
||||
@@ -169,7 +169,6 @@ public class YunKuaiChongV150RealTimeDataULCmd extends YunKuaiChongUplinkCmdExe
|
||||
|
||||
tcpSession.getForwarder().sendMessage(chargingProgressMessage);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -39,7 +39,7 @@ public class YunKuaiChongV150RemoteStartDLCmd extends YunKuaiChongDownlinkCmdExe
|
||||
String pileCode = remoteStartChargingRequest.getPileCode();
|
||||
String gunCode = remoteStartChargingRequest.getGunCode();
|
||||
String tradeNo = remoteStartChargingRequest.getTradeNo();
|
||||
int limitCent = remoteStartChargingRequest.getLimitCent();
|
||||
int limitYuan = remoteStartChargingRequest.getLimitYuan();
|
||||
|
||||
byte[] cardNo = encodeCardNo(tradeNo);
|
||||
|
||||
@@ -55,7 +55,7 @@ public class YunKuaiChongV150RemoteStartDLCmd extends YunKuaiChongDownlinkCmdExe
|
||||
// 物理卡号
|
||||
msgBody.writeBytes(cardNo);
|
||||
// 账户余额
|
||||
msgBody.writeIntLE(limitCent);
|
||||
msgBody.writeIntLE(limitYuan);
|
||||
|
||||
encodeAndWriteFlush(REMOTE_START_CHARGING,
|
||||
msgBody,
|
||||
|
||||
@@ -59,7 +59,7 @@ public class YunKuaiChongV150SetPricingModelDLCmd extends YunKuaiChongDownlinkCm
|
||||
setPricingAckMsgBody.writeBytes(encodePricingId(pricingId));
|
||||
|
||||
// 4字节电价+4字节服务费
|
||||
BigDecimal accurate = new BigDecimal(1000);
|
||||
BigDecimal accurate = new BigDecimal(100000);
|
||||
setPricingAckMsgBody.writeIntLE(new BigDecimal(flagPriceMap.get(TOP.ordinal()).getElec()).multiply(accurate).intValue());
|
||||
setPricingAckMsgBody.writeIntLE(new BigDecimal(flagPriceMap.get(TOP.ordinal()).getServ()).multiply(accurate).intValue());
|
||||
setPricingAckMsgBody.writeIntLE(new BigDecimal(flagPriceMap.get(PEAK.ordinal()).getElec()).multiply(accurate).intValue());
|
||||
|
||||
@@ -63,7 +63,7 @@ public class YunKuaiChongV150TransactionRecordULCmd extends YunKuaiChongUplinkCm
|
||||
Instant endTime = CP56Time2aUtil.decode(endTimeBytes);
|
||||
|
||||
// 6.尖单价
|
||||
BigDecimal topPrice = reduceMagnification(byteBuf.readUnsignedIntLE(), 1000);
|
||||
BigDecimal topPrice = reduceMagnification(byteBuf.readUnsignedIntLE(), 100000);
|
||||
additionalInfo.put("尖单价", topPrice);
|
||||
// 7. 尖电量
|
||||
BigDecimal topEnergy = reduceMagnification(byteBuf.readUnsignedIntLE(), 10000);
|
||||
@@ -71,10 +71,10 @@ public class YunKuaiChongV150TransactionRecordULCmd extends YunKuaiChongUplinkCm
|
||||
BigDecimal topLoseEnergy = reduceMagnification(byteBuf.readUnsignedIntLE(), 10000);
|
||||
additionalInfo.put("计损尖电量", topLoseEnergy);
|
||||
// 9.尖金额
|
||||
BigDecimal topAmount = reduceMagnification(byteBuf.readUnsignedIntLE(), 100);
|
||||
BigDecimal topAmount = reduceMagnification(byteBuf.readUnsignedIntLE(), 10000);
|
||||
|
||||
// 10.峰单价
|
||||
BigDecimal peakPrice = reduceMagnification(byteBuf.readUnsignedIntLE(), 1000);
|
||||
BigDecimal peakPrice = reduceMagnification(byteBuf.readUnsignedIntLE(), 100000);
|
||||
additionalInfo.put("峰单价", peakPrice);
|
||||
// 11. 峰电量
|
||||
BigDecimal peakEnergy = reduceMagnification(byteBuf.readUnsignedIntLE(), 10000);
|
||||
@@ -82,10 +82,10 @@ public class YunKuaiChongV150TransactionRecordULCmd extends YunKuaiChongUplinkCm
|
||||
BigDecimal peakLoseEnergy = reduceMagnification(byteBuf.readUnsignedIntLE(), 10000);
|
||||
additionalInfo.put("计损峰电量", peakLoseEnergy);
|
||||
// 13.峰金额
|
||||
BigDecimal peakAmount = reduceMagnification(byteBuf.readUnsignedIntLE(), 100);
|
||||
BigDecimal peakAmount = reduceMagnification(byteBuf.readUnsignedIntLE(), 10000);
|
||||
|
||||
// 14.平单价
|
||||
BigDecimal flatPrice = reduceMagnification(byteBuf.readUnsignedIntLE(), 1000);
|
||||
BigDecimal flatPrice = reduceMagnification(byteBuf.readUnsignedIntLE(), 100000);
|
||||
additionalInfo.put("平单价", flatPrice);
|
||||
// 15. 平电量
|
||||
BigDecimal flatEnergy = reduceMagnification(byteBuf.readUnsignedIntLE(), 10000);
|
||||
@@ -93,10 +93,10 @@ public class YunKuaiChongV150TransactionRecordULCmd extends YunKuaiChongUplinkCm
|
||||
BigDecimal flatLoseEnergy = reduceMagnification(byteBuf.readUnsignedIntLE(), 10000);
|
||||
additionalInfo.put("计损平电量", flatLoseEnergy);
|
||||
// 17.平金额
|
||||
BigDecimal flatAmount = reduceMagnification(byteBuf.readUnsignedIntLE(), 100);
|
||||
BigDecimal flatAmount = reduceMagnification(byteBuf.readUnsignedIntLE(), 10000);
|
||||
|
||||
// 18.谷单价
|
||||
BigDecimal valleyPrice = reduceMagnification(byteBuf.readUnsignedIntLE(), 1000);
|
||||
BigDecimal valleyPrice = reduceMagnification(byteBuf.readUnsignedIntLE(), 100000);
|
||||
additionalInfo.put("谷单价", valleyPrice);
|
||||
// 19. 谷电量
|
||||
BigDecimal valleyEnergy = reduceMagnification(byteBuf.readUnsignedIntLE(), 10000);
|
||||
@@ -104,7 +104,7 @@ public class YunKuaiChongV150TransactionRecordULCmd extends YunKuaiChongUplinkCm
|
||||
BigDecimal valleyLoseEnergy = reduceMagnification(byteBuf.readUnsignedIntLE(), 10000);
|
||||
additionalInfo.put("计损谷电量", valleyLoseEnergy);
|
||||
// 21.谷金额
|
||||
BigDecimal valleyAmount = reduceMagnification(byteBuf.readUnsignedIntLE(), 100);
|
||||
BigDecimal valleyAmount = reduceMagnification(byteBuf.readUnsignedIntLE(), 10000);
|
||||
|
||||
// 22.电表总起值
|
||||
byte[] meterStartValueBytes = new byte[5];
|
||||
@@ -124,7 +124,7 @@ public class YunKuaiChongV150TransactionRecordULCmd extends YunKuaiChongUplinkCm
|
||||
BigDecimal totalLoseEnergy = reduceMagnification(byteBuf.readUnsignedIntLE(), 10000, 4);
|
||||
additionalInfo.put("计损总电量", totalLoseEnergy);
|
||||
// 26 .消费金额
|
||||
BigDecimal totalAmount = reduceMagnification(byteBuf.readUnsignedIntLE(), 100);
|
||||
BigDecimal totalAmount = reduceMagnification(byteBuf.readUnsignedIntLE(), 10000);
|
||||
|
||||
// 27.电动汽车唯一标识
|
||||
byte[] carVINBytes = new byte[17];
|
||||
@@ -157,16 +157,16 @@ public class YunKuaiChongV150TransactionRecordULCmd extends YunKuaiChongUplinkCm
|
||||
.setTradeNo(tradeNo)
|
||||
.setStartTs(startTime.toEpochMilli())
|
||||
.setEndTs(endTime.toEpochMilli())
|
||||
.setTopEnergyKWh(topEnergy.floatValue())
|
||||
.setTopAmountCent(topAmount.longValue())
|
||||
.setPeakEnergyKWh(peakEnergy.floatValue())
|
||||
.setPeakAmountCent(peakAmount.longValue())
|
||||
.setFlatEnergyKWh(flatEnergy.floatValue())
|
||||
.setFlatAmountCent(flatAmount.longValue())
|
||||
.setValleyEnergyKWh(valleyEnergy.floatValue())
|
||||
.setValleyAmountCent(valleyAmount.longValue())
|
||||
.setTotalEnergyKWh(totalEnergy.floatValue())
|
||||
.setTotalAmountCent(totalAmount.longValue())
|
||||
.setTopEnergyKWh(topEnergy.toPlainString())
|
||||
.setTopAmountYuan(topAmount.toPlainString())
|
||||
.setPeakEnergyKWh(peakEnergy.toPlainString())
|
||||
.setPeakAmountYuan(peakAmount.toPlainString())
|
||||
.setFlatEnergyKWh(flatEnergy.toPlainString())
|
||||
.setFlatAmountYuan(flatAmount.toPlainString())
|
||||
.setValleyEnergyKWh(valleyEnergy.toPlainString())
|
||||
.setValleyAmountYuan(valleyAmount.toPlainString())
|
||||
.setTotalEnergyKWh(totalEnergy.toPlainString())
|
||||
.setTotalAmountYuan(totalAmount.toPlainString())
|
||||
.setTradeTs(tradeTime.toEpochMilli())
|
||||
.setStopReason(stopReason)
|
||||
.setAdditionalInfo(additionalInfo.toString())
|
||||
|
||||
Reference in New Issue
Block a user