Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
platform
/
platform-charging-server
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 351bab8f
authored
Nov 08, 2023
by
zhouhaibao
Browse Files
Options
Browse Files
Tag
Download
Plain Diff
Merge branch 'master' of
http://192.168.3.233:8090/platform/platform-charging-server
2 parents
21774812
48e0b097
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
455 additions
and
7 deletions
platform-charging/src/main/java/cn/com/glsx/charging/modules/gbt/ocpp16/tcp/base/TcpMapper.java
platform-charging/src/main/java/cn/com/glsx/charging/modules/gbt/ocpp16/tcp/data/TransactionRecordsReqData.java
platform-charging/src/main/java/cn/com/glsx/charging/modules/gbt/ocpp16/tcp/data/TransactionRecordsRespData.java
platform-charging/src/main/java/cn/com/glsx/charging/modules/gbt/ocpp16/tcp/handler/ShutdownMachineReqHandler.java
platform-charging/src/main/java/cn/com/glsx/charging/modules/gbt/ocpp16/tcp/handler/TransactionRecordsReqHandler.java
platform-charging/src/main/java/cn/com/glsx/charging/modules/gbt/ocpp16/tcp/handler/TransactionRecordsRespHandler.java
platform-charging/src/main/java/cn/com/glsx/charging/modules/gbt/ocpp16/tcp/protocol/ShutdownMachineReq.java
platform-charging/src/main/java/cn/com/glsx/charging/modules/gbt/ocpp16/tcp/protocol/ShutdownMachineResp.java
platform-charging/src/main/java/cn/com/glsx/charging/modules/gbt/ocpp16/tcp/protocol/TransactionRecordsReq.java
platform-charging/src/main/java/cn/com/glsx/charging/modules/gbt/ocpp16/tcp/protocol/TransactionRecordsResp.java
platform-charging/src/test/java/cn/com/glsx/charging/gbt/ocpp16/InteractiveTest.java
platform-charging/src/main/java/cn/com/glsx/charging/modules/gbt/ocpp16/tcp/base/TcpMapper.java
View file @
351bab8
...
...
@@ -3,6 +3,8 @@ package cn.com.glsx.charging.modules.gbt.ocpp16.tcp.base;
import
cn.com.glsx.charging.modules.gbt.ocpp16.tcp.handler.ModelSetRspHandler
;
import
java.util.Map
;
import
cn.com.glsx.charging.modules.gbt.ocpp16.tcp.handler.interactive.req.TransactionRecordsReqHandler
;
import
cn.com.glsx.charging.modules.gbt.ocpp16.tcp.handler.interactive.resp.TransactionRecordsRespHandler
;
import
com.fasterxml.jackson.annotation.JsonIgnore
;
import
com.google.common.collect.Maps
;
...
...
@@ -73,9 +75,9 @@ public final class TcpMapper {
public
static
TcpMapper
CMD_REQ_STOP_CHARGING
=
regist
(
0x36
,
"运营平台远程停机"
,
ShutdownMachineReqHandler
.
class
);
public
static
TcpMapper
CMD_REQ_TRADE_UPLOAD
=
regist
(
0x3B
,
"交易记录上报"
,
null
);
public
static
TcpMapper
CMD_REQ_TRADE_UPLOAD
=
regist
(
0x3B
,
"交易记录上报"
,
TransactionRecordsReqHandler
.
class
);
public
static
TcpMapper
CMD_RSP_TRADE_UPLOAD
=
regist
(
0x40
,
"交易记录上报确认"
,
null
);
public
static
TcpMapper
CMD_RSP_TRADE_UPLOAD
=
regist
(
0x40
,
"交易记录上报确认"
,
TransactionRecordsRespHandler
.
class
);
public
static
TcpMapper
CMD_REQ_CFG_DOWNLOAD
=
regist
(
0x52
,
"充电桩工作参数设置"
,
ParamSettingReqHandler
.
class
);
...
...
platform-charging/src/main/java/cn/com/glsx/charging/modules/gbt/ocpp16/tcp/data/TransactionRecordsReqData.java
0 → 100644
View file @
351bab8
package
cn
.
com
.
glsx
.
charging
.
modules
.
gbt
.
ocpp16
.
tcp
.
data
.
interactive
;
import
cn.com.glsx.charging.modules.gbt.ocpp16.tcp.base.TcpData
;
import
lombok.Getter
;
import
lombok.Setter
;
/**
* @Description 交易记录
* 功能 充电桩在网络正常情况下,主运发送结算账单,直到运营平台响应成账单上传成功(若未收到
* 0x40 回复间隔 30s 再重试一次,最多重试 3 次),收到账单结算成功,本账单在充电桩本地删
* 除。每次接收到启机命令并已执行启机过程,无论启机成功与否,都需在订单结束充电后生成
* 账单上传
* 样例报文 68 (起始标志) A2 (数据长度) 8001 (序列号域) 00 (加密标志) 3B (类型)
* 55031412782305012018061910262392(交易流水号)55031412782305(桩编码)01(枪号:1
* 枪)98B70E11100314(开始时间:2020-03-16 17:14:47)98B70E11100314(结束时间:2020-03-16
* 17:14:47)D0FB0100(尖单价:1.30000)00000000(尖电量:0)00000000(计损尖电量:0)
* 00000000(尖金额:0)D0FB0100(峰单价: 1.30000)00000000(峰电量:0)00000000(计损
* 峰电量:0)00000000(峰金额:0)D0FB0100(平单价: 1.30000)00000000(平电量:0)00000000
* (计损平电量:0)00000000(平金额:0)D0FB0100(谷单价: 1.30000)00000000(谷电量:
* 0)00000000(计损谷电量:0)00000000(谷金额:0)0000000000(电表总起值:0)0000000000
* (电表总止值:0)00000000(总电量:0)00000000(计损总电量:0)00000000(消费金额:
* 0)0000000000000000000000000000000000(VIN 码)02(交易标识:app 启动)98B70E11100314
* (交易时间:2020-03-16 17:14:47)00(停止原因:无)00000000D14B0A54(物理卡号:D14B0A54)
* 388C(帧校验域)
* @Author yelq
* @Date 2023/11/7-16:57
* @Version 1.0
*/
@Getter
@Setter
public
class
TransactionRecordsReqData
extends
TcpData
{
/**
* 参数名称:交易流水号
* 数据类型:BCD码
* 长度(Byte):16
* 备注:见名词解释
*/
private
byte
[]
transactionSerialNumber
=
new
byte
[
16
];
/**
* 参数名称:桩编号
* 数据类型:BCD码
* 长度(Byte):7
* 备注:不足7位补0
*/
private
byte
[]
pileNumber
=
new
byte
[
7
];
/**
* 参数名称:枪号
* 数据类型:BCD码
* 长度(Byte):1
*/
private
byte
gunNumber
;
/**
* 参数名称:开始时间
* 数据类型:BIN
* 长度(Byte):7
* 备注:CP56Time2a格式
*/
private
byte
[]
startTime
=
new
byte
[
7
];
/**
* 参数名称:结束时间
* 数据类型:BIN
* 长度(Byte):7
* 备注:CP56Time2a格式
*/
private
byte
[]
endTime
=
new
byte
[
7
];
/**
* 参数名称:尖单价
* 数据类型:BIN
* 长度(Byte):4
* 备注:精确到小数点后五位(尖电费+尖服务费,见费率帧)
*/
private
byte
[]
peakUnitPrice
=
new
byte
[
4
];
/**
* 参数名称:尖电量
* 数据类型:BIN
* 长度(Byte):4
* 备注:精确到小数点后四位
*/
private
byte
[]
peakElectricity
=
new
byte
[
4
];
/**
* 参数名称:计损尖电量
* 数据类型:BIN
* 长度(Byte):4
* 备注:精确到小数点后四位
*/
private
byte
[]
peakElectricityLoss
=
new
byte
[
4
];
/**
* 参数名称:尖金额
* 数据类型:BIN
* 长度(Byte):4
* 备注:精确到小数点后四位
*/
private
byte
[]
peakAmount
=
new
byte
[
4
];
/**
* 参数名称:峰单价
* 数据类型:BIN
* 长度(Byte):4
* 备注:精确到小数点后五位(峰电费+峰服务费)
*/
private
byte
[]
topUnitPrice
=
new
byte
[
4
];
/**
* 参数名称:峰电量
* 数据类型:BIN
* 长度(Byte):4
* 备注:精确到小数点后四位
*/
private
byte
[]
topElectricity
=
new
byte
[
4
];
/**
* 参数名称:计损峰电量
* 数据类型:BIN
* 长度(Byte):4
* 备注:精确到小数点后四位
*/
private
byte
[]
topElectricityLoss
=
new
byte
[
4
];
/**
* 参数名称:峰金额
* 数据类型:BIN
* 长度(Byte):4
* 备注:精确到小数点后四位
*/
private
byte
[]
topAmount
=
new
byte
[
4
];
/**
* 参数名称:平单价
* 数据类型:BIN
* 长度(Byte):4
* 备注:精确到小数点后五位(平电费+平服务费)
*/
private
byte
[]
flatUnitPrice
=
new
byte
[
4
];
/**
* 参数名称:平电量
* 数据类型:BIN
* 长度(Byte):4
* 备注:精确到小数点后四位
*/
private
byte
[]
flatElectricity
=
new
byte
[
4
];
/**
* 参数名称:计损平电量
* 数据类型:BIN
* 长度(Byte):4
* 备注:精确到小数点后四位
*/
private
byte
[]
flatElectricityLoss
=
new
byte
[
4
];
/**
* 参数名称:平金额
* 数据类型:BIN
* 长度(Byte):4
* 备注:精确到小数点后四位
*/
private
byte
[]
flatAmount
=
new
byte
[
4
];
/**
* 参数名称:谷单价
* 数据类型:BIN
* 长度(Byte):4
* 备注:精确到小数点后五位(谷电费+谷服务费)
*/
private
byte
[]
valleyUnitPrice
=
new
byte
[
4
];
/**
* 参数名称:谷电量
* 数据类型:BIN
* 长度(Byte):4
* 备注:精确到小数点后四位
*/
private
byte
[]
valleyElectricity
=
new
byte
[
4
];
/**
* 参数名称:计损谷电量
* 数据类型:BIN
* 长度(Byte):4
* 备注:精确到小数点后四位
*/
private
byte
[]
valleyElectricityLoss
=
new
byte
[
4
];
/**
* 参数名称:谷金额
* 数据类型:BIN
* 长度(Byte):4
* 备注:精确到小数点后四位
*/
private
byte
[]
valleyAmount
=
new
byte
[
4
];
/**
* 参数名称:电表总起值
* 数据类型:BIN
* 长度(Byte):5
* 备注:精确到小数点后四位
*/
private
byte
[]
totalStartValue
=
new
byte
[
4
];
/**
* 参数名称:电表总止值
* 数据类型:BIN
* 长度(Byte):5
* 备注:精确到小数点后四位
*/
private
byte
[]
totalEndValue
=
new
byte
[
4
];
/**
* 参数名称:总电量
* 数据类型:BIN
* 长度(Byte):4
* 备注:精确到小数点后四位
*/
private
byte
[]
totalElectricity
=
new
byte
[
4
];
/**
* 参数名称:计损总电量
* 数据类型:BIN
* 长度(Byte):4
* 备注:精确到小数点后四位
*/
private
byte
[]
totalElectricityLoss
=
new
byte
[
4
];
/**
* 参数名称:消费金额
* 数据类型:BIN
* 长度(Byte):4
* 备注:精确到小数点后四位,包含电费、服务费
*/
private
byte
[]
totalAmount
=
new
byte
[
4
];
/**
* 参数名称:电动汽车唯一标识
* 数据类型:ASCII
* 长度(Byte):17
* 备注:VIN码,此处VIN码和充电时VIN码不同,正序直接上传,无需补0和反序
*/
private
byte
[]
vehicleIdentifier
=
new
byte
[
17
];
/**
* 参数名称:交易标识
* 数据类型:BIN
* 长度(Byte):1
* 备注:0x01:app启动 0x02:卡启动 0x04:离线卡启动 0x05: vin码启动充电
*/
private
byte
transactionIdentifier
;
/**
* 参数名称:交易日期、时间
* 数据类型:BIN
* 长度(Byte):7
* 备注:CP56Time2a格式
*/
private
byte
[]
transactionDateTime
=
new
byte
[
7
];
/**
* 参数名称:停止原因
* 数据类型:BIN
* 长度(Byte):1
* 备注:见附录11.1
*/
private
byte
stopReason
;
/**
* 物理卡号
* 数据类型: (BIN码)
* 长度(Byte):8
* 备注:不足补零,桩与平台交互需使用的物理卡号
*/
private
byte
[]
physicalCardNumber
=
new
byte
[
8
];
}
platform-charging/src/main/java/cn/com/glsx/charging/modules/gbt/ocpp16/tcp/data/TransactionRecordsRespData.java
0 → 100644
View file @
351bab8
package
cn
.
com
.
glsx
.
charging
.
modules
.
gbt
.
ocpp16
.
tcp
.
data
.
interactive
;
import
cn.com.glsx.charging.modules.gbt.ocpp16.tcp.base.TcpData
;
import
lombok.Getter
;
import
lombok.Setter
;
/**
* @Description 交易记录确认
* 功能 运营平台接收到结算账单上传后,都需回复此确认信息。若桩未收到回复帧,则 5 分钟后继续
* 上送一次交易记录,此情况下无论平台是否成功回复都停止上送。这一帧仅是报文交互使用,
* 意指平台成功接收到交易记录报文,并不代表交易订单成功结算
* 样例报文 68(起始标志)15(数据长度)0002(序列号域)00(加密标志)40(类型)
* 55031412782305012018061910262392(交易流水号)00(确认结果)48B1(帧校验域)
* @Author yelq
* @Date 2023/11/7-16:57
* @Version 1.0
*/
@Getter
@Setter
public
class
TransactionRecordsRespData
extends
TcpData
{
/**
* 交易流水号
* 数据类型:byte[] (BCD码)
* 长度(Byte):16
* 备注:
*/
private
byte
[]
transactionSerialNumber
=
new
byte
[
16
];
/**
* 确认结果
* 数据类型:byte (BIN码)
* 长度(Byte):1
* 备注:0x00 上传成功 0x01 非法账单
*/
private
byte
confirmResult
;
}
platform-charging/src/main/java/cn/com/glsx/charging/modules/gbt/ocpp16/tcp/handler/ShutdownMachineReqHandler.java
View file @
351bab8
...
...
@@ -20,8 +20,8 @@ public class ShutdownMachineReqHandler implements TcpHandler<ShutdownMachineReq,
@Override
public
ShutdownMachineResp
handle
(
Channel
channel
,
ShutdownMachineReq
shutdownMachineReq
)
{
/**请求日志打印*/
log
.
info
(
"桩编号:
"
+
Ocpp16Helper
.
bcdToStr
(
shutdownMachineReq
.
getData
().
getPileNumber
()));
log
.
info
(
"枪号:
"
+
shutdownMachineReq
.
getData
().
getGunNumber
());
log
.
info
(
"桩编号:
{}"
,
Ocpp16Helper
.
bcdToStr
(
shutdownMachineReq
.
getData
().
getPileNumber
()));
log
.
info
(
"枪号:
{}"
,
shutdownMachineReq
.
getData
().
getGunNumber
());
/**请求日志打印*/
ShutdownMachineResp
resp
=
new
ShutdownMachineResp
();
ShutdownMachineRespData
data
=
new
ShutdownMachineRespData
();
...
...
platform-charging/src/main/java/cn/com/glsx/charging/modules/gbt/ocpp16/tcp/handler/TransactionRecordsReqHandler.java
0 → 100644
View file @
351bab8
package
cn
.
com
.
glsx
.
charging
.
modules
.
gbt
.
ocpp16
.
tcp
.
handler
.
interactive
.
req
;
import
cn.com.glsx.charging.modules.gbt.ocpp16.Ocpp16Helper
;
import
cn.com.glsx.charging.modules.gbt.ocpp16.tcp.base.TcpHandler
;
import
cn.com.glsx.charging.modules.gbt.ocpp16.tcp.data.interactive.TransactionRecordsReqData
;
import
cn.com.glsx.charging.modules.gbt.ocpp16.tcp.data.interactive.TransactionRecordsRespData
;
import
cn.com.glsx.charging.modules.gbt.ocpp16.tcp.protocol.interactive.req.TransactionRecordsReq
;
import
cn.com.glsx.charging.modules.gbt.ocpp16.tcp.protocol.interactive.resp.TransactionRecordsResp
;
import
cn.com.glsx.charging.util.ByteUtils
;
import
io.netty.channel.Channel
;
/**
* @Description 运营平台接收到结算账单上传后,都需回复此确认信息。若桩未收到回复帧,则 5 分钟后继续
* 上送一次交易记录,此情况下无论平台是否成功回复都停止上送。这一帧仅是报文交互使用,
* 意指平台成功接收到交易记录报文,并不代表交易订单成功结算
* @Author yelq
* @Date 2023/11/7-17:37
* @Version 1.0
*/
public
class
TransactionRecordsReqHandler
implements
TcpHandler
<
TransactionRecordsReq
,
TransactionRecordsResp
>
{
@Override
public
TransactionRecordsResp
handle
(
Channel
channel
,
TransactionRecordsReq
transactionRecordsReq
)
{
TransactionRecordsReqData
reqData
=
transactionRecordsReq
.
getData
();
/**解析参数日志打印*/
log
.
info
(
"交易流水号:{}"
,
Ocpp16Helper
.
bcdToStr
(
reqData
.
getTransactionSerialNumber
()));
String
pileNumber
=
Ocpp16Helper
.
bcdToStr
(
reqData
.
getPileNumber
());
log
.
info
(
"桩编号:{}"
,
pileNumber
);
log
.
info
(
"开始时间:{}"
,
ByteUtils
.
parseCp56Time2aStr
(
reqData
.
getStartTime
()));
log
.
info
(
"结束时间:{}"
,
ByteUtils
.
parseCp56Time2aStr
(
reqData
.
getEndTime
()));
log
.
info
(
"电动汽车唯一标识:{}"
,
Ocpp16Helper
.
bcdToStr
(
reqData
.
getVehicleIdentifier
()));
log
.
info
(
"峰单价:{}"
,
Ocpp16Helper
.
bcdToStr
(
reqData
.
getTopUnitPrice
()));
/**解析参数日志打印*/
TransactionRecordsResp
resp
=
new
TransactionRecordsResp
();
TransactionRecordsRespData
data
=
new
TransactionRecordsRespData
();
data
.
setTransactionSerialNumber
(
Ocpp16Helper
.
strToBcd
(
"55031412782305012018061910262392"
,
data
.
getTransactionSerialNumber
()));
data
.
setConfirmResult
((
byte
)
0
);
resp
.
setData
(
data
);
return
resp
;
}
}
platform-charging/src/main/java/cn/com/glsx/charging/modules/gbt/ocpp16/tcp/handler/TransactionRecordsRespHandler.java
0 → 100644
View file @
351bab8
package
cn
.
com
.
glsx
.
charging
.
modules
.
gbt
.
ocpp16
.
tcp
.
handler
.
interactive
.
resp
;
import
cn.com.glsx.charging.modules.gbt.ocpp16.tcp.base.TcpHandler
;
import
cn.com.glsx.charging.modules.gbt.ocpp16.tcp.protocol.interactive.resp.TransactionRecordsResp
;
import
io.netty.channel.Channel
;
/**
* @Description 交易记录确认
* 功能 运营平台接收到结算账单上传后,都需回复此确认信息。若桩未收到回复帧,则 5 分钟后继续
* 上送一次交易记录,此情况下无论平台是否成功回复都停止上送。这一帧仅是报文交互使用,
* 意指平台成功接收到交易记录报文,并不代表交易订单成功结算
* @Author yelq
* @Date 2023/11/7-17:37
* @Version 1.0
*/
public
class
TransactionRecordsRespHandler
implements
TcpHandler
<
TransactionRecordsResp
,
TransactionRecordsResp
>
{
@Override
public
TransactionRecordsResp
handle
(
Channel
channel
,
TransactionRecordsResp
transactionRecordsResp
)
{
log
.
info
(
"客户端已经收到返回"
);
return
null
;
}
}
platform-charging/src/main/java/cn/com/glsx/charging/modules/gbt/ocpp16/tcp/protocol/ShutdownMachineReq.java
View file @
351bab8
...
...
@@ -12,6 +12,6 @@ import cn.com.glsx.charging.modules.gbt.ocpp16.tcp.data.ShutdownMachineReqData;
*/
public
class
ShutdownMachineReq
extends
TcpReq
<
ShutdownMachineReqData
>
{
public
ShutdownMachineReq
()
{
super
(
TcpMapper
.
CMD_REQ_STOP_CHARGING
.
getType
());
super
(
TcpMapper
.
CMD_REQ_STOP_CHARGING
.
getType
());
}
}
platform-charging/src/main/java/cn/com/glsx/charging/modules/gbt/ocpp16/tcp/protocol/ShutdownMachineResp.java
View file @
351bab8
...
...
@@ -12,6 +12,6 @@ import cn.com.glsx.charging.modules.gbt.ocpp16.tcp.data.ShutdownMachineRespData;
*/
public
class
ShutdownMachineResp
extends
TcpReq
<
ShutdownMachineRespData
>
{
public
ShutdownMachineResp
()
{
super
(
TcpMapper
.
CMD_RSP_STOP_CHARGING
.
getType
());
super
(
TcpMapper
.
CMD_RSP_STOP_CHARGING
.
getType
());
}
}
platform-charging/src/main/java/cn/com/glsx/charging/modules/gbt/ocpp16/tcp/protocol/TransactionRecordsReq.java
0 → 100644
View file @
351bab8
package
cn
.
com
.
glsx
.
charging
.
modules
.
gbt
.
ocpp16
.
tcp
.
protocol
.
interactive
.
req
;
import
cn.com.glsx.charging.modules.gbt.ocpp16.tcp.base.TcpMapper
;
import
cn.com.glsx.charging.modules.gbt.ocpp16.tcp.base.TcpReq
;
import
cn.com.glsx.charging.modules.gbt.ocpp16.tcp.data.interactive.TransactionRecordsReqData
;
/**
* @Description 交易记录上报
* @Author yelq
* @Date 2023/11/7-17:38
* @Version 1.0
*/
public
class
TransactionRecordsReq
extends
TcpReq
<
TransactionRecordsReqData
>
{
public
TransactionRecordsReq
()
{
super
(
TcpMapper
.
CMD_REQ_TRADE_UPLOAD
.
getType
());
}
}
platform-charging/src/main/java/cn/com/glsx/charging/modules/gbt/ocpp16/tcp/protocol/TransactionRecordsResp.java
0 → 100644
View file @
351bab8
package
cn
.
com
.
glsx
.
charging
.
modules
.
gbt
.
ocpp16
.
tcp
.
protocol
.
interactive
.
resp
;
import
cn.com.glsx.charging.modules.gbt.ocpp16.tcp.base.TcpMapper
;
import
cn.com.glsx.charging.modules.gbt.ocpp16.tcp.base.TcpReq
;
import
cn.com.glsx.charging.modules.gbt.ocpp16.tcp.data.interactive.TransactionRecordsReqData
;
import
cn.com.glsx.charging.modules.gbt.ocpp16.tcp.data.interactive.TransactionRecordsRespData
;
/**
* @Description 交易记录确认
* 功能 运营平台接收到结算账单上传后,都需回复此确认信息。若桩未收到回复帧,则 5 分钟后继续
* 上送一次交易记录,此情况下无论平台是否成功回复都停止上送。这一帧仅是报文交互使用,
* 意指平台成功接收到交易记录报文,并不代表交易订单成功结算
* @Author yelq
* @Date 2023/11/7-17:38
* @Version 1.0
*/
public
class
TransactionRecordsResp
extends
TcpReq
<
TransactionRecordsRespData
>
{
public
TransactionRecordsResp
()
{
super
(
TcpMapper
.
CMD_RSP_TRADE_UPLOAD
.
getType
());
}
}
platform-charging/src/test/java/cn/com/glsx/charging/gbt/ocpp16/InteractiveTest.java
View file @
351bab8
...
...
@@ -5,9 +5,10 @@ import cn.com.glsx.charging.modules.gbt.ocpp16.Ocpp16Helper;
import
cn.com.glsx.charging.modules.gbt.ocpp16.tcp.client.TcpClient
;
import
cn.com.glsx.charging.modules.gbt.ocpp16.tcp.data.ShutdownMachineReqData
;
import
cn.com.glsx.charging.modules.gbt.ocpp16.tcp.data.StartMachineReqData
;
import
cn.com.glsx.charging.modules.gbt.ocpp16.tcp.data.interactive.TransactionRecordsReqData
;
import
cn.com.glsx.charging.modules.gbt.ocpp16.tcp.protocol.ShutdownMachineReq
;
import
cn.com.glsx.charging.modules.gbt.ocpp16.tcp.protocol.StartMachineReq
;
import
cn.com.glsx.charging.modules.gbt.ocpp16.tcp.protocol.interactive.req.TransactionRecordsReq
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
import
org.mockito.junit.MockitoJUnitRunner
;
...
...
@@ -23,6 +24,37 @@ import org.mockito.junit.MockitoJUnitRunner;
public
class
InteractiveTest
{
@Test
public
void
transactionRecordsTest
()
throws
Exception
{
Ocpp16Helper
.
scan
();
TcpClient
client
=
ClientMain
.
getInstance
(
"localhost"
,
8888
);
Thread
.
sleep
(
3000
);
/**
* 样例报文 68 (起始标志) A2 (数据长度) 8001 (序列号域) 00 (加密标志) 3B (类型)
* 55031412782305012018061910262392(交易流水号)55031412782305(桩编码)01(枪号:1
* 枪)98B70E11100314(开始时间:2020-03-16 17:14:47)98B70E11100314(结束时间:2020-03-16
* 17:14:47)D0FB0100(尖单价:1.30000)00000000(尖电量:0)00000000(计损尖电量:0)
* 00000000(尖金额:0)D0FB0100(峰单价: 1.30000)00000000(峰电量:0)00000000(计损
* 峰电量:0)00000000(峰金额:0)D0FB0100(平单价: 1.30000)00000000(平电量:0)00000000
* (计损平电量:0)00000000(平金额:0)D0FB0100(谷单价: 1.30000)00000000(谷电量:
* 0)00000000(计损谷电量:0)00000000(谷金额:0)0000000000(电表总起值:0)0000000000
* (电表总止值:0)00000000(总电量:0)00000000(计损总电量:0)00000000(消费金额:
* 0)0000000000000000000000000000000000(VIN 码)02(交易标识:app 启动)98B70E11100314
* (交易时间:2020-03-16 17:14:47)00(停止原因:无)00000000D14B0A54(物理卡号:D14B0A54)
*/
TransactionRecordsReq
req
=
new
TransactionRecordsReq
();
TransactionRecordsReqData
data
=
new
TransactionRecordsReqData
();
data
.
setTransactionSerialNumber
(
Ocpp16Helper
.
strToBcd
(
"55031412782305012018061910262392"
,
data
.
getTransactionSerialNumber
()));
data
.
setGunNumber
((
byte
)
1
);
data
.
setPileNumber
(
Ocpp16Helper
.
strToBcd
(
"32010200000001"
,
data
.
getPileNumber
()));
data
.
setTopUnitPrice
(
Ocpp16Helper
.
strToBcd
(
"D0FB0100"
,
data
.
getTopUnitPrice
()));
data
.
setVehicleIdentifier
(
Ocpp16Helper
.
strToBcd
(
"0000000000000000000000000000000001"
,
data
.
getVehicleIdentifier
()));
req
.
setData
(
data
);
client
.
sendSync
(
req
);
Thread
.
sleep
(
3000
);
System
.
out
.
println
(
"========================="
);
}
@Test
public
void
shutdownMachineTest
()
throws
Exception
{
Ocpp16Helper
.
scan
();
TcpClient
client
=
ClientMain
.
getInstance
(
"localhost"
,
8888
);
...
...
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment