解析电表起止值

This commit is contained in:
Guoqs
2025-12-16 11:41:40 +08:00
parent 000d338780
commit 88ca676264
2 changed files with 287 additions and 250 deletions

View File

@@ -19,6 +19,7 @@ import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.CollectionUtils;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.math.RoundingMode;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@@ -274,6 +275,43 @@ public class YKCUtils {
return divide.toString(); return divide.toString();
} }
/**
* 减去倍数
* @param value
* @param magnification
* @param scale
* @return
*/
public static BigDecimal reduceMagnification(long value, int magnification, int scale) {
return new BigDecimal(value).divide(new BigDecimal(magnification), scale, RoundingMode.HALF_UP);
}
/**
* 读取5字节小端字节序的数字
* @param bytes
* @return
*/
public static long readLongLE5Byte(byte[] bytes) {
// 确保字节数组的长度至少为 5
if (bytes.length < 5) {
throw new IllegalArgumentException("字节数组长度必须至少为5字节");
}
// 使用小端字节序读取 5 字节数字
int byte1 = bytes[0] & 0xFF;
int byte2 = bytes[1] & 0xFF;
int byte3 = bytes[2] & 0xFF;
int byte4 = bytes[3] & 0xFF;
int byte5 = bytes[4] & 0xFF;
// 将读取的字节合并成一个 long 值
return ((long) byte1) |
((long) byte2 << 8) |
((long) byte3 << 16) |
((long) byte4 << 24) |
((long) byte5 << 32);
}
/** /**
* 获取价格byte数组 * 获取价格byte数组
* 价格转换为byte数组 * 价格转换为byte数组

View File

@@ -28,7 +28,6 @@ import com.jsowell.pile.service.programlogic.AbstractProgramLogic;
import com.jsowell.pile.service.programlogic.ProgramLogicFactory; import com.jsowell.pile.service.programlogic.ProgramLogicFactory;
import com.jsowell.thirdparty.common.CommonService; import com.jsowell.thirdparty.common.CommonService;
import com.jsowell.thirdparty.platform.service.impl.BatteryChargeReportService; import com.jsowell.thirdparty.platform.service.impl.BatteryChargeReportService;
import com.jsowell.thirdparty.platform.service.impl.ChargeAlgorithmService;
import io.netty.channel.ChannelHandlerContext; import io.netty.channel.ChannelHandlerContext;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.core.RabbitTemplate; import org.springframework.amqp.rabbit.core.RabbitTemplate;
@@ -97,253 +96,253 @@ public class TransactionRecordsRequestHandler extends AbstractYkcHandler {
// public static void main(String[] args) { public static void main(String[] args) {
// // BigDecimal totalElectricity = new BigDecimal("23.73"); // 获取消息体
// // if (totalElectricity.compareTo(BigDecimal.TEN) > 0) { String msg = "882400000067090125110515234024428824000000670901a00f170f050b199d640b11050b19a0860100000000000000000000000000a086010080b605000000000080b60500a086010080cf32000000000072ef0400a0860100000000000000000000000000800944e100806060e1000086380000000000008638004c4331484d594246315230303130303235059d640b11050b194500000000000000006877";
// // // 充电度数大于10度 byte[] msgBody = BytesUtil.str2Bcd(msg);
// // System.out.println("123");
// // } int startIndex = 0;
// int length = 16;
//
// // 获取消息体 // 交易流水号
// // String msg = "000000000000000000000000000000008823000000030601a08c2e0d0404170000380d0404170000000000000000000000000000000000000000000000000000000000000000400d0300ee250000ee250000c84b000000000000000000000000000000000000e0bb040000cee1040000ee250000ee250000c84b00000000000000000000000000000000000000010000380d04041745a511101970000000"; byte[] transactionCodeByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
// // byte[] msgBody = BytesUtil.str2Bcd(msg); String transactionCode = BytesUtil.bcd2Str(transactionCodeByteArr);
// //
// // int startIndex = 0; // 桩编码
// // int length = 16; startIndex += length;
// // length = 7;
// // // 交易流水号 byte[] pileSnByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
// // byte[] orderCodeByteArr = BytesUtil.copyBytes(msgBody, startIndex, length); String pileSn = BytesUtil.bcd2Str(pileSnByteArr);
// // String transactionCode = BytesUtil.bcd2Str(orderCodeByteArr);
// // // 枪号
// // // 桩编码 startIndex += length;
// // startIndex += length; length = 1;
// // length = 7; byte[] connectorCodeByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
// // byte[] pileSnByteArr = BytesUtil.copyBytes(msgBody, startIndex, length); String connectorCode = BytesUtil.bcd2Str(connectorCodeByteArr);
// // String pileSn = BytesUtil.bcd2Str(pileSnByteArr);
// //
// // // 枪号 // 开始时间 CP56Time2a 格式
// // startIndex += length; startIndex += length;
// // length = 1; length = 7;
// // byte[] connectorCodeByteArr = BytesUtil.copyBytes(msgBody, startIndex, length); byte[] startTimeByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
// // String connectorCode = BytesUtil.bcd2Str(connectorCodeByteArr); // String binary = BytesUtil.binary(startTimeByteArr, 16);
// // Date startDate = Cp56Time2aUtil.byte2Hdate(startTimeByteArr);
// // String startTime = DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, startDate);
// // // 开始时间 CP56Time2a 格式
// // startIndex += length;
// // length = 7; // 结束时间 CP56Time2a 格式
// // byte[] startTimeByteArr = BytesUtil.copyBytes(msgBody, startIndex, length); startIndex += length;
// // // String binary = BytesUtil.binary(startTimeByteArr, 16); byte[] endTimeByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
// // Date startDate = Cp56Time2aUtil.byte2Hdate(startTimeByteArr); Date endDate = Cp56Time2aUtil.byte2Hdate(endTimeByteArr);
// // String startTime = DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, startDate); String endTime = DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, endDate);
// //
// // // 尖单价 精确到小数点后五位(尖电费+尖服务费,见费率帧)
// // // 结束时间 CP56Time2a 格式 startIndex += length;
// // startIndex += length; length = 4;
// // byte[] endTimeByteArr = BytesUtil.copyBytes(msgBody, startIndex, length); byte[] sharpPriceByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
// // Date endDate = Cp56Time2aUtil.byte2Hdate(endTimeByteArr); String sharpPrice = YKCUtils.convertDecimalPoint(sharpPriceByteArr, 5);
// // String endTime = DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, endDate);
// // // 尖电量 精确到小数点后四位
// // // 尖单价 精确到小数点后五位(尖电费+尖服务费,见费率帧) startIndex += length;
// // startIndex += length; length = 4;
// // length = 4; byte[] sharpUsedElectricityByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
// // byte[] sharpPriceByteArr = BytesUtil.copyBytes(msgBody, startIndex, length); String sharpUsedElectricity = YKCUtils.convertDecimalPoint(sharpUsedElectricityByteArr, 4);
// // String sharpPrice = YKCUtils.convertDecimalPoint(sharpPriceByteArr, 5);
// // // 计损尖电量
// // // 尖电量 精确到小数点后四位 startIndex += length;
// // startIndex += length; byte[] sharpPlanLossElectricityByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
// // length = 4; String sharpPlanLossElectricity = YKCUtils.convertDecimalPoint(sharpPlanLossElectricityByteArr, 4);
// // byte[] sharpUsedElectricityByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
// // String sharpUsedElectricity = YKCUtils.convertDecimalPoint(sharpUsedElectricityByteArr, 4); // 尖金额
// // startIndex += length;
// // // 计损尖电量 byte[] sharpAmountByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
// // startIndex += length; String sharpAmount = YKCUtils.convertDecimalPoint(sharpAmountByteArr, 4);
// // byte[] sharpPlanLossElectricityByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
// // String sharpPlanLossElectricity = YKCUtils.convertDecimalPoint(sharpPlanLossElectricityByteArr, 4); // 峰单价 精确到小数点后五位(峰电费+峰服务费)
// // startIndex += length;
// // // 尖金额 byte[] peakPriceByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
// // startIndex += length; String peakPrice = YKCUtils.convertDecimalPoint(peakPriceByteArr, 5);
// // byte[] sharpAmountByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
// // String sharpAmount = YKCUtils.convertDecimalPoint(sharpAmountByteArr, 4); // 峰电量
// // startIndex += length;
// // // 峰单价 精确到小数点后五位(峰电费+峰服务费) byte[] peakUsedElectricityByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
// // startIndex += length; String peakUsedElectricity = YKCUtils.convertDecimalPoint(peakUsedElectricityByteArr, 4);
// // byte[] peakPriceByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
// // String peakPrice = YKCUtils.convertDecimalPoint(peakPriceByteArr, 5); // 计损峰电量
// // startIndex += length;
// // // 峰电量 byte[] peakPlanLossElectricityByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
// // startIndex += length; String peakPlanLossElectricity = YKCUtils.convertDecimalPoint(peakPlanLossElectricityByteArr, 4);
// // byte[] peakUsedElectricityByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
// // String peakUsedElectricity = YKCUtils.convertDecimalPoint(peakUsedElectricityByteArr, 4); // 峰金额
// // startIndex += length;
// // // 计损峰电量 byte[] peakAmountByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
// // startIndex += length; String peakAmount = YKCUtils.convertDecimalPoint(peakAmountByteArr, 4);
// // byte[] peakPlanLossElectricityByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
// // String peakPlanLossElectricity = YKCUtils.convertDecimalPoint(peakPlanLossElectricityByteArr, 4); // 平单价 精确到小数点后五位(平电费+平服务费)
// // startIndex += length;
// // // 峰金额 byte[] flatPriceByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
// // startIndex += length; String flatPrice = YKCUtils.convertDecimalPoint(flatPriceByteArr, 5);
// // byte[] peakAmountByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
// // String peakAmount = YKCUtils.convertDecimalPoint(peakAmountByteArr, 4); // 平电量
// // startIndex += length;
// // // 平单价 精确到小数点后五位(平电费+平服务费) byte[] flatUsedElectricityByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
// // startIndex += length; String flatUsedElectricity = YKCUtils.convertDecimalPoint(flatUsedElectricityByteArr, 4);
// // byte[] flatPriceByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
// // String flatPrice = YKCUtils.convertDecimalPoint(flatPriceByteArr, 5); // 计损平电量
// // startIndex += length;
// // // 平电量 byte[] flatPlanLossElectricityByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
// // startIndex += length; String flatPlanLossElectricity = YKCUtils.convertDecimalPoint(flatPlanLossElectricityByteArr, 4);
// // byte[] flatUsedElectricityByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
// // String flatUsedElectricity = YKCUtils.convertDecimalPoint(flatUsedElectricityByteArr, 4); // 平金额
// // startIndex += length;
// // // 计损平电量 byte[] flatAmountByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
// // startIndex += length; String flatAmount = YKCUtils.convertDecimalPoint(flatAmountByteArr, 4);
// // byte[] flatPlanLossElectricityByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
// // String flatPlanLossElectricity = YKCUtils.convertDecimalPoint(flatPlanLossElectricityByteArr, 4); // 谷单价 精确到小数点后五位(谷电费+谷 服务费)
// // startIndex += length;
// // // 平金额 byte[] valleyPriceByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
// // startIndex += length; String valleyPrice = YKCUtils.convertDecimalPoint(valleyPriceByteArr, 5);
// // byte[] flatAmountByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
// // String flatAmount = YKCUtils.convertDecimalPoint(flatAmountByteArr, 4); // 谷电量
// // startIndex += length;
// // // 谷单价 精确到小数点后五位(谷电费+谷 服务费) byte[] valleyUsedElectricityByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
// // startIndex += length; String valleyUsedElectricity = YKCUtils.convertDecimalPoint(valleyUsedElectricityByteArr, 4);
// // byte[] valleyPriceByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
// // String valleyPrice = YKCUtils.convertDecimalPoint(valleyPriceByteArr, 5); // 计损谷电量
// // startIndex += length;
// // // 谷电量 byte[] valleyPlanLossElectricityByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
// // startIndex += length; String valleyPlanLossElectricity = YKCUtils.convertDecimalPoint(valleyPlanLossElectricityByteArr, 4);
// // byte[] valleyUsedElectricityByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
// // String valleyUsedElectricity = YKCUtils.convertDecimalPoint(valleyUsedElectricityByteArr, 4); // 谷金额
// // startIndex += length;
// // // 计损谷电量 byte[] valleyAmountByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
// // startIndex += length; String valleyAmount = YKCUtils.convertDecimalPoint(valleyAmountByteArr, 4);
// // byte[] valleyPlanLossElectricityByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
// // String valleyPlanLossElectricity = YKCUtils.convertDecimalPoint(valleyPlanLossElectricityByteArr, 4); // 电表总起值
// // startIndex += length;
// // // 谷金额 length = 5;
// // startIndex += length; byte[] ammeterTotalStartByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
// // byte[] valleyAmountByteArr = BytesUtil.copyBytes(msgBody, startIndex, length); // 打印出来格式为16进制
// // String valleyAmount = YKCUtils.convertDecimalPoint(valleyAmountByteArr, 4); // log.info("电表总起值:{}", BytesUtil.binary(ammeterTotalStartByteArr, 16));
// // log.info("电表总起值:{}", YKCUtils.readLongLE5Byte(ammeterTotalStartByteArr));
// // // 电表总起值 // String ammeterTotalStart = YKCUtils.convertDecimalPoint(ammeterTotalStartByteArr, 4);
// // startIndex += length; String ammeterTotalStart = YKCUtils.reduceMagnification(YKCUtils.readLongLE5Byte(ammeterTotalStartByteArr), 10000, 4).toString();
// // length = 5;
// // byte[] ammeterTotalStartByteArr = BytesUtil.copyBytes(msgBody, startIndex, length); // 电表总止值
// // String ammeterTotalStart = YKCUtils.convertDecimalPoint(ammeterTotalStartByteArr, 4); startIndex += length;
// // byte[] ammeterTotalEndByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
// // // 电表总止值 // String ammeterTotalEnd = YKCUtils.convertDecimalPoint(ammeterTotalEndByteArr, 4);
// // startIndex += length; String ammeterTotalEnd = YKCUtils.reduceMagnification(YKCUtils.readLongLE5Byte(ammeterTotalEndByteArr), 10000, 4).toString();
// // byte[] ammeterTotalEndByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
// // String ammeterTotalEnd = YKCUtils.convertDecimalPoint(ammeterTotalEndByteArr, 4); // 总电量
// // startIndex += length;
// // // 总电量 length = 4;
// // startIndex += length; byte[] totalElectricityByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
// // length = 4; String totalElectricity = YKCUtils.convertDecimalPoint(totalElectricityByteArr, 4);
// // byte[] totalElectricityByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
// // // String totalElectricity = YKCUtils.convertDecimalPoint(totalElectricityByteArr, 4); // 计损总电量
// // startIndex += length;
// // // 计损总电量 byte[] planLossTotalElectricityByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
// // startIndex += length; String planLossTotalElectricity = YKCUtils.convertDecimalPoint(planLossTotalElectricityByteArr, 4);
// // byte[] planLossTotalElectricityByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
// // String planLossTotalElectricity = YKCUtils.convertDecimalPoint(planLossTotalElectricityByteArr, 4); // 消费金额 精确到小数点后四位,包含电费、 服务费
// // startIndex += length;
// // // 消费金额 精确到小数点后四位,包含电费、 服务费 byte[] consumptionAmountByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
// // startIndex += length; String consumptionAmount = YKCUtils.convertDecimalPoint(consumptionAmountByteArr, 4);
// // byte[] consumptionAmountByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
// // String consumptionAmount = YKCUtils.convertDecimalPoint(consumptionAmountByteArr, 4); // VIN 码 VIN 码,此处 VIN 码和充电时 VIN 码不同, 正序直接上传, 无需补 0 和反序
// // startIndex += length;
// // // VIN 码 VIN 码,此处 VIN 码和充电时 VIN 码不同, 正序直接上传, 无需补 0 和反序 length = 17;
// // startIndex += length; byte[] vinCodeByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
// // length = 17; String vinCode = YKCUtils.parseVin(vinCodeByteArr); // 解析vin
// // byte[] vinCodeByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
// // String vinCode = BytesUtil.ascii2Str(vinCodeByteArr); /**
// // * 交易标识
// // /** * 0x01 app 启动
// // * 交易标识 * 0x02卡启动
// // * 0x01 app 启动 * 0x04离线卡启动
// // * 0x02卡启动 * 0x05: vin 码启动充电
// // * 0x04离线卡启动 */
// // * 0x05: vin 码启动充电 startIndex += length;
// // */ length = 1;
// // startIndex += length; byte[] transactionIdentifierByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
// // length = 1; String transactionIdentifier = BytesUtil.bcd2Str(transactionIdentifierByteArr);
// // byte[] transactionIdentifierByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
// // String transactionIdentifier = BytesUtil.bcd2Str(transactionIdentifierByteArr); // 交易时间 CP56Time2a 格式
// // startIndex += length;
// // // 交易时间 CP56Time2a 格式 length = 7;
// // startIndex += length; byte[] transactionTimeByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
// // length = 7; Date transactionDate = Cp56Time2aUtil.byte2Hdate(transactionTimeByteArr);
// // byte[] transactionTimeByteArr = BytesUtil.copyBytes(msgBody, startIndex, length); String transactionTime = DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, transactionDate);
// // Date transactionDate = Cp56Time2aUtil.byte2Hdate(transactionTimeByteArr);
// // String transactionTime = DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, transactionDate); // 停止原因
// // startIndex += length;
// // // 停止原因 length = 1;
// // startIndex += length; byte[] stopReasonByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
// // length = 1; String stopReason = BytesUtil.bin2HexStr(stopReasonByteArr);
// // byte[] stopReasonByteArr = BytesUtil.copyBytes(msgBody, startIndex, length); int i = Integer.parseInt(stopReason, 16);
// // String stopReason = BytesUtil.bin2HexStr(stopReasonByteArr); String stopReasonMsg = YKCChargingStopReasonEnum.getMsgByCode(i);
// // int i = Integer.parseInt(stopReason, 16);
// // String stopReasonMsg = YKCChargingStopReasonEnum.getMsgByCode(i); // 物理卡号 不足 8 位补 0
// startIndex += length;
// length = 8;
// // 物理卡号 不足 8 位补 0 byte[] cardNumByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
// // startIndex += length; // log.info("交易记录确认cardNumByteArr:{}", cardNumByteArr);
// // length = 8; String logicCard = BytesUtil.binary(cardNumByteArr, 16);
// // byte[] cardNumByteArr = BytesUtil.copyBytes(msgBody, startIndex, length); // log.info("桩号:{}, 发送交易记录物理卡号:{}", pileSn, logicCard);
// // // byte[] logicCardNum = BytesUtil.checkLengthAndBehindAppendZero(cardNumByteArr, 16);
// // String logicCard = BytesUtil.binary(cardNumByteArr, 16); log.info("[===交易记录===]交易流水号:{}, 桩编号:{}, 枪号:{}, 开始时间:{}, 结束时间:{}, 尖单价:{}, 尖电量:{}, 计损尖电量:{}, 尖金额:{}, " +
// // log.info("桩号:{}, 发送交易记录物理卡号:{}", pileSn, logicCard); "峰单价:{}, 峰电量:{}, 计损峰电量:{}, 峰金额:{}, 平单价:{}, 平电量:{}, 计损平电量:{}, 平金额:{}, " +
// // "谷单价:{}, 谷电量:{}, 计损谷电量:{}, 谷金额:{}, 电表总起值:{}, 电表总止值:{}, 总电量:{}, 计损总电量:{}, 消费金额:{}, " +
// // log.info("[===交易记录===]交易流水号:{}, 桩编号:{}, 枪号:{}, 开始时间:{}, 结束时间:{}, 尖单价:{}, 尖电量:{}, 计损尖电量:{}, 尖金额:{}, " + "vin码:{}, 交易标识:{}, 交易日期、时间:{}, 停止原因码:{}, 停止原因描述:{}, 物理卡号:{}",
// // "峰单价:{}, 峰电量:{}, 计损峰电量:{}, 峰金额:{}, 平单价:{}, 平电量:{}, 计损平电量:{}, 平金额:{}, " + transactionCode, pileSn, connectorCode, startTime, endTime, sharpPrice, sharpUsedElectricity, sharpPlanLossElectricity, sharpAmount,
// // "谷单价:{}, 谷电量:{}, 计损谷电量:{}, 谷金额:{}, 电表总起值:{}, 电表总止值:{}, 总电量:{}, 计损总电量:{}, 消费金额:{}, " + peakPrice, peakUsedElectricity, peakPlanLossElectricity, peakAmount, flatPrice, flatUsedElectricity, flatPlanLossElectricity, flatAmount,
// // "电动汽车唯一标识:{}, 交易标识:{}, 交易日期、时间:{}, 停止原因码:{}, 停止原因描述:{}, 物理卡号:{}", valleyPrice, valleyUsedElectricity, valleyPlanLossElectricity, valleyAmount, ammeterTotalStart, ammeterTotalEnd, totalElectricity, planLossTotalElectricity,
// // transactionCode, pileSn, connectorCode, startTime, endTime, sharpPrice, sharpUsedElectricity, sharpPlanLossElectricity, sharpAmount, consumptionAmount, vinCode, transactionIdentifier, transactionTime, stopReason, stopReasonMsg, logicCard);
// // peakPrice, peakUsedElectricity, peakPlanLossElectricity, peakAmount, flatPrice, flatUsedElectricity, flatPlanLossElectricity, flatAmount,
// // valleyPrice, valleyUsedElectricity, valleyPlanLossElectricity, valleyAmount, ammeterTotalStart, ammeterTotalEnd, totalElectricity, planLossTotalElectricity, // 交易记录封装到对象里
// // consumptionAmount, vinCode, transactionIdentifier, transactionTime, stopReason, stopReasonMsg, logicCard); TransactionRecordsData data = TransactionRecordsData.builder()
// // // .orderCode(transactionCode)
// // // 交易记录封装到对象里 .transactionCode(transactionCode)
// // TransactionRecordsData data = TransactionRecordsData.builder() .pileSn(pileSn)
// // // .orderCode(transactionCode) .connectorCode(connectorCode)
// // .transactionCode(transactionCode) .startTime(startTime)
// // .pileSn(pileSn) .endTime(endTime)
// // .connectorCode(connectorCode) .sharpPrice(sharpPrice)
// // .startTime(startTime) .sharpUsedElectricity(sharpUsedElectricity)
// // .endTime(endTime) .sharpPlanLossElectricity(sharpPlanLossElectricity)
// // .sharpPrice(sharpPrice) .sharpAmount(sharpAmount)
// // .sharpUsedElectricity(sharpUsedElectricity) .peakPrice(peakPrice)
// // .sharpPlanLossElectricity(sharpPlanLossElectricity) .peakUsedElectricity(peakUsedElectricity)
// // .sharpAmount(sharpAmount) .peakPlanLossElectricity(peakPlanLossElectricity)
// // .peakPrice(peakPrice) .peakAmount(peakAmount)
// // .peakUsedElectricity(peakUsedElectricity) .flatPrice(flatPrice)
// // .peakPlanLossElectricity(peakPlanLossElectricity) .flatUsedElectricity(flatUsedElectricity)
// // .peakAmount(peakAmount) .flatPlanLossElectricity(flatPlanLossElectricity)
// // .flatPrice(flatPrice) .flatAmount(flatAmount)
// // .flatUsedElectricity(flatUsedElectricity) .valleyPrice(valleyPrice)
// // .flatPlanLossElectricity(flatPlanLossElectricity) .valleyUsedElectricity(valleyUsedElectricity)
// // .flatAmount(flatAmount) .valleyPlanLossElectricity(valleyPlanLossElectricity)
// // .valleyPrice(valleyPrice) .valleyAmount(valleyAmount)
// // .valleyUsedElectricity(valleyUsedElectricity) .ammeterTotalStart(ammeterTotalStart)
// // .valleyPlanLossElectricity(valleyPlanLossElectricity) .ammeterTotalEnd(ammeterTotalEnd)
// // .valleyAmount(valleyAmount) .totalElectricity(totalElectricity)
// // .ammeterTotalStart(ammeterTotalStart) .planLossTotalElectricity(planLossTotalElectricity)
// // .ammeterTotalEnd(ammeterTotalEnd) .consumptionAmount(consumptionAmount)
// // // .totalElectricity(totalElectricity) .vinCode(vinCode)
// // .planLossTotalElectricity(planLossTotalElectricity) .transactionIdentifier(transactionIdentifier)
// // .consumptionAmount(consumptionAmount) .transactionTime(transactionTime)
// // .vinCode(vinCode) .stopReasonCode(stopReason)
// // .transactionIdentifier(transactionIdentifier) .stopReasonMsg(stopReasonMsg)
// // .transactionTime(transactionTime) .logicCard(logicCard)
// // .stopReasonMsg(stopReasonMsg) .build();
// // .logicCard(logicCard)
// // .build(); // 保存交易记录到redis (缓存时间1天)
// //
// // boolean flag = !StringUtils.equals("0000000000000000", "a511101970000000"); boolean flag = !StringUtils.equals("0000000000000000", "a511101970000000");
// // System.out.println(flag); System.out.println(flag);
//
// } }
@Override @Override
public byte[] supplyProcess(YKCDataProtocol ykcDataProtocol, ChannelHandlerContext channel) { public byte[] supplyProcess(YKCDataProtocol ykcDataProtocol, ChannelHandlerContext channel) {
@@ -472,12 +471,12 @@ public class TransactionRecordsRequestHandler extends AbstractYkcHandler {
startIndex += length; startIndex += length;
length = 5; length = 5;
byte[] ammeterTotalStartByteArr = BytesUtil.copyBytes(msgBody, startIndex, length); byte[] ammeterTotalStartByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
String ammeterTotalStart = YKCUtils.convertDecimalPoint(ammeterTotalStartByteArr, 4); String ammeterTotalStart = YKCUtils.reduceMagnification(YKCUtils.readLongLE5Byte(ammeterTotalStartByteArr), 10000, 4).toString();
// 电表总止值 // 电表总止值
startIndex += length; startIndex += length;
byte[] ammeterTotalEndByteArr = BytesUtil.copyBytes(msgBody, startIndex, length); byte[] ammeterTotalEndByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
String ammeterTotalEnd = YKCUtils.convertDecimalPoint(ammeterTotalEndByteArr, 4); String ammeterTotalEnd = YKCUtils.reduceMagnification(YKCUtils.readLongLE5Byte(ammeterTotalEndByteArr), 10000, 4).toString();
// 总电量 // 总电量
startIndex += length; startIndex += length;