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 9b87d80a
authored
Nov 15, 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
afc3d6d9
6a3b37f3
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
79 additions
and
44 deletions
platform-charging-api/src/main/java/cn/com/glsx/charging/modules/model/gbt/ocpp16/tcp/StartMachineDownLoadData.java
platform-charging/src/main/java/cn/com/glsx/charging/util/ProtocolParamConvertUtils.java
platform-charging-api/src/main/java/cn/com/glsx/charging/modules/model/gbt/ocpp16/tcp/StartMachineDownLoadData.java
View file @
9b87d80
...
...
@@ -4,13 +4,14 @@ import lombok.Getter;
import
lombok.Setter
;
import
java.io.Serializable
;
import
java.math.BigDecimal
;
/**
* 报文示例:
* 68 (起始标志) 30 (数据长度) 007C (序列号域) 00 (加密标志) 34(类型)
* 55031412782305012018061914444680(交易流水号)55031412782305(桩编码)01(枪号:1枪)
* 0000001000000573(逻辑卡号:1000000573)00000000D14B0A54(物理卡号:D14B0A54)A0860100(账户余额:1000.00)4622
*
*
* @Description 当用户通过远程启动充电时,发送本命令
* @Author yelq
* @Date 2023/11/6-19:16
...
...
@@ -19,51 +20,51 @@ import java.io.Serializable;
@Getter
@Setter
public
class
StartMachineDownLoadData
implements
Serializable
{
/**
* 交易流水号
* 数据类型: (BCD码)
* 长度(Byte):16
* 备注:见名词解释
*/
private
byte
[]
transactionSerialNumber
=
new
byte
[
16
]
;
/**
* 交易流水号
* 数据类型: (BCD码)
* 长度(Byte):16
* 备注:见名词解释
*/
private
String
transactionSerialNumber
;
/**
* 桩编号
* 数据类型: (BCD码)
* 长度(Byte):7
* 备注:不足7位补0
*/
private
byte
[]
pileId
=
new
byte
[
7
]
;
/**
* 桩编号
* 数据类型: (BCD码)
* 长度(Byte):7
* 备注:不足7位补0
*/
private
String
pileId
;
/**
* 枪号
* 数据类型: (BCD码)
* 长度(Byte):1
* 备注:
*/
private
byte
gunNumber
;
/**
* 枪号
* 数据类型: (BCD码)
* 长度(Byte):1
* 备注:
*/
private
byte
gunNumber
;
/**
* 逻辑卡号
* 数据类型: (BCD码)
* 长度(Byte):8
* 备注:显示在屏幕上,不足补零,逻辑卡号为卡面印刷卡号
*/
private
byte
[]
logicalCardNumber
=
new
byte
[
8
]
;
/**
* 逻辑卡号
* 数据类型: (BCD码)
* 长度(Byte):8
* 备注:显示在屏幕上,不足补零,逻辑卡号为卡面印刷卡号
*/
private
String
logicalCardNumber
;
/**
* 物理卡号
* 数据类型: (BIN码)
* 长度(Byte):8
* 备注:不足补零,桩与平台交互需使用的物理卡号
*/
private
byte
[]
physicalCardNumber
=
new
byte
[
8
]
;
/**
* 物理卡号
* 数据类型: (BIN码)
* 长度(Byte):8
* 备注:不足补零,桩与平台交互需使用的物理卡号
*/
private
String
physicalCardNumber
;
/**
* 账户余额
* 数据类型: (BIN码)
* 长度(Byte):4
* 备注:保留到小数点两位
*/
private
byte
[]
accountBalance
=
new
byte
[
4
]
;
/**
* 账户余额
* 数据类型: (BIN码)
* 长度(Byte):4
* 备注:保留到小数点两位
*/
private
BigDecimal
accountBalance
;
}
platform-charging/src/main/java/cn/com/glsx/charging/util/ProtocolParamConvertUtils.java
View file @
9b87d80
package
cn
.
com
.
glsx
.
charging
.
util
;
import
cn.com.glsx.charging.modules.gbt.ocpp16.Ocpp16Helper
;
import
cn.com.glsx.charging.modules.gbt.ocpp16.tcp.data.StartMachineReqData
;
import
cn.com.glsx.charging.modules.model.gbt.ocpp16.tcp.StartMachineDownLoadData
;
import
java.math.BigDecimal
;
import
java.math.RoundingMode
;
/**
* @Description 协议参数转换工具类
...
...
@@ -11,5 +16,34 @@ import cn.com.glsx.charging.modules.gbt.ocpp16.tcp.data.StartMachineReqData;
public
class
ProtocolParamConvertUtils
{
// public static StartMachineReqData
/**
* 当用户通过远程启动充电时,发送本命令
* @return
*/
public
static
StartMachineReqData
convertStartMachineDownLoadData
(
StartMachineDownLoadData
source
){
StartMachineReqData
resp
=
new
StartMachineReqData
();
resp
.
setTransactionSerialNumber
(
Ocpp16Helper
.
strToBcd
(
source
.
getTransactionSerialNumber
(),
resp
.
getTransactionSerialNumber
()));
resp
.
setPileId
(
Ocpp16Helper
.
strToBcd
(
source
.
getPileId
(),
resp
.
getPileId
()));
resp
.
setGunNumber
(
source
.
getGunNumber
());
resp
.
setLogicalCardNumber
(
Ocpp16Helper
.
strToBcd
(
source
.
getLogicalCardNumber
(),
resp
.
getLogicalCardNumber
()));
resp
.
setPhysicalCardNumber
(
ByteUtils
.
fromHex
(
source
.
getPhysicalCardNumber
()));
resp
.
setAccountBalance
(
Ocpp16Helper
.
bigDecimalToByteArray
(
padDecimalScale
(
source
.
getAccountBalance
(),
2
),
resp
.
getAccountBalance
().
length
));
return
resp
;
}
public
static
void
main
(
String
[]
args
)
{
StartMachineDownLoadData
source
=
new
StartMachineDownLoadData
();
source
.
setTransactionSerialNumber
(
"55031412782305012018061914444680"
);
source
.
setPileId
(
"55031412782305"
);
source
.
setGunNumber
((
byte
)
1
);
source
.
setAccountBalance
(
new
BigDecimal
(
"3"
));
source
.
setPhysicalCardNumber
(
"00000000D14B0A54"
);
source
.
setLogicalCardNumber
(
"0000001000000573"
);
System
.
out
.
println
(
convertStartMachineDownLoadData
(
source
));
}
// 设置小数位数
public
static
BigDecimal
padDecimalScale
(
BigDecimal
value
,
int
scale
)
{
return
value
.
setScale
(
scale
,
RoundingMode
.
HALF_UP
);
}
}
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