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 3b02d389
authored
Nov 17, 2023
by
王欣伟
Browse Files
Options
Browse Files
Tag
Download
Plain Diff
wangxw合并更新
2 parents
1817274d
249a71a7
Hide whitespace changes
Inline
Side-by-side
Showing
21 changed files
with
660 additions
and
125 deletions
platform-charging-api/src/main/java/cn/com/glsx/charging/modules/model/gbt/ocpp16/tcp/AdminSwipeConfirmReqMqData.java
platform-charging-api/src/main/java/cn/com/glsx/charging/modules/model/gbt/ocpp16/tcp/HeartbeatReqMqData.java
platform-charging-api/src/main/java/cn/com/glsx/charging/modules/model/gbt/ocpp16/tcp/LoginUploadMqData.java
platform-charging-api/src/main/java/cn/com/glsx/charging/modules/model/gbt/ocpp16/tcp/RealTimeUploadMqData.java
platform-charging-api/src/main/java/cn/com/glsx/charging/modules/model/gbt/ocpp16/tcp/TransactionRecordsMqData.java
platform-charging/src/main/java/cn/com/glsx/charging/modules/api/PileControlApiController.java
platform-charging/src/main/java/cn/com/glsx/charging/modules/controller/ScanCodeController.java
platform-charging/src/main/java/cn/com/glsx/charging/modules/gbt/ocpp16/Ocpp16Helper.java
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/AdminSwipeConfirmReqData.java
platform-charging/src/main/java/cn/com/glsx/charging/modules/gbt/ocpp16/tcp/data/LoginReqData.java
platform-charging/src/main/java/cn/com/glsx/charging/modules/gbt/ocpp16/tcp/handler/AdminSwipeConfirmRspHandler.java
platform-charging/src/main/java/cn/com/glsx/charging/modules/gbt/ocpp16/tcp/handler/HeartbeatReqHandler.java
platform-charging/src/main/java/cn/com/glsx/charging/modules/gbt/ocpp16/tcp/handler/LoginReqHandler.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/UploadRealTimeRspHandler.java
platform-charging/src/main/java/cn/com/glsx/charging/modules/gbt/ocpp16/tcp/protocol/UploadRealtimeDataRsp.java
platform-charging/src/main/java/cn/com/glsx/charging/modules/gbt/ocpp16/tcp/server/ProxyHelper.java
platform-charging/src/test/java/cn/com/glsx/charging/api/FeignSerivceTest.java
platform-charging/src/test/java/cn/com/glsx/charging/gbt/ocpp16/ModelSetTest.java
platform-charging/src/test/java/cn/com/glsx/charging/gbt/ocpp16/TimeSettingTest.java
platform-charging-api/src/main/java/cn/com/glsx/charging/modules/model/gbt/ocpp16/tcp/AdminSwipeConfirmReqMqData.java
View file @
3b02d38
...
...
@@ -4,7 +4,7 @@ import lombok.Data;
/**
* 充电桩主动申请启动充电
*
*
<p>
* 68(起始标志)37(数据长度)0004(序列号域)00(加密标志)31(类型)32010200000001
* (桩编码)01(枪号:1 枪)01(启动方式:刷卡启动)00(是否需要密码:不需要)00000000D14B0A54
* (物理卡号:D14B0A54)00000000000000000000000000000000(输入密码)
...
...
@@ -31,20 +31,20 @@ public class AdminSwipeConfirmReqMqData {
* 长度(Byte):1
* 备注:
*/
private
Integer
gunNumber
;
private
String
gunNumber
;
/**
* 启动方式
* BIN码 长度1
*
0x01 表示通过刷卡启动充电
*
0x02 表求通过帐号启动充电(暂不支持)
*
0x03 表示vin码启动充电
* 0x01 表示通过刷卡启动充电
* 0x02 表求通过帐号启动充电(暂不支持)
* 0x03 表示vin码启动充电
*/
private
Integer
startWay
;
/**
*
是否需要密码 0x00 不需要 0x01 需要
*
false不需要 true需要
* 是否需要密码 0x00 不需要 0x01 需要
* false不需要 true需要
*/
private
Boolean
passwordFlag
;
...
...
platform-charging-api/src/main/java/cn/com/glsx/charging/modules/model/gbt/ocpp16/tcp/HeartbeatReqMqData.java
View file @
3b02d38
...
...
@@ -21,7 +21,7 @@ public class HeartbeatReqMqData {
/**
* 枪号 BCD 码 1
*/
private
Integer
gunNo
;
private
String
gunNumber
;
/**
* 枪状态 BIN 码 1 0x00:正常 0x01:故障
...
...
platform-charging-api/src/main/java/cn/com/glsx/charging/modules/model/gbt/ocpp16/tcp/LoginUploadMqData.java
0 → 100644
View file @
3b02d38
package
cn
.
com
.
glsx
.
charging
.
modules
.
model
.
gbt
.
ocpp16
.
tcp
;
import
lombok.Data
;
import
java.io.Serializable
;
/**
* 充电桩登录上报数据
*
* @author kome
* @date 2023年11月1日 下午6:00:39
*/
@Data
public
class
LoginUploadMqData
implements
Serializable
{
/**
* 充电桩id: BCD 码 ,不足 7 位补 0
*/
private
String
pileId
;
/**
* 0 表示直流桩,1 表示交流桩
*/
private
byte
pointType
;
/**
* 充电枪数量
*/
private
byte
gunCount
;
/**
* 通信协议版本 BIN 码 1 版本号乘 10,v1.0 表示 0x0A
*/
private
byte
protocolVersion
;
/**
* 程序版本 ASCII 码 8 不足 8 位补零
*/
private
String
softVersion
;
/**
* 网络链接类型
* 0x00 SIM 卡
* 0x01 LAN
* 0x02 WAN
* 0x03 其他
*/
private
byte
network
;
/**
* Sim 卡 BCD 码 10 不足 10 位补零,取不到置零
*/
private
String
sim
;
/**
* 运营商 BIN 码
* 0x00 移动
* 0x02 电信
* 0x03 联通
* 0x04 其他
*/
private
byte
operator
;
}
platform-charging-api/src/main/java/cn/com/glsx/charging/modules/model/gbt/ocpp16/tcp/RealTimeUploadMqData.java
0 → 100644
View file @
3b02d38
package
cn
.
com
.
glsx
.
charging
.
modules
.
model
.
gbt
.
ocpp16
.
tcp
;
import
lombok.Data
;
import
java.io.Serializable
;
import
java.math.BigDecimal
;
/**
* 上传实时监测数据
*
* @author yelq
* @date 2023年11月13日 下午6:00:39
*/
@Data
public
class
RealTimeUploadMqData
implements
Serializable
{
/**
* 交易流水号
*/
private
String
transactionSerialNumber
;
/**
* 桩编号
*/
private
String
pileId
;
/**
* 枪号
*/
private
String
gunNumber
;
/**
* 状态 BIN 码
* 0x00:离线
* 0x01:故障
* 0x02:空闲
* 0x03:充电
*/
private
byte
status
;
/**
* 枪是否归位
* 0x00 否
* 0x01 是
* 0x02 未知
* 无法检测到枪是否插回枪座即未知
*/
private
byte
ifReturn
;
/**
* 是否插枪 BIN 码
* 0x00 否
* 0x01 是
* 需做到变位上送
*/
private
byte
ifCharging
;
/**
* 输出电压 BIN 码
* 精确到小数点后一位;待机置零
*/
private
BigDecimal
outputVoltage
;
/**
* 输出电流 BIN 码
* 精确到小数点后一位;待机置零
*/
private
BigDecimal
outputCurrent
;
/**
* 枪线温度 BIN 码
* 整形,偏移量-50;待机置零
*/
private
byte
gunWireTemperature
;
/**
* 枪线编码 BIN 码
* 没有置零
*/
private
String
gunWireNumber
;
/**
* SOC BIN 码
* 待机置零;交流桩置零
*/
private
byte
soc
;
/**
* 电池组最高温度 BIN 码
* 整形,偏移量-50 ºC;待机置零;
* 交流桩置零
*/
private
byte
batteryHighestTemperature
;
/**
* 累计充电时间 BIN 码
* 单位:min;待机置零
*/
private
short
accumulatedChargingTime
;
/**
* 剩余时间 BIN 码
* 单位:min;待机置零、交流桩置
* 零
*/
private
short
timeLeft
;
/**
* 充电度数 BIN 码
* 精确到小数点后四位;待机置零
*/
private
BigDecimal
chargingDegree
;
/**
* 计损度数 BIN 码
* 精确到小数点后四位;待机置零,未设置计损比例时等于充电度数
*/
private
BigDecimal
lossChargingDegree
;
/**
* 已充金额 BIN 码
* 精确到小数点后四位;待机置零(电费+服务费)*计损充电度数
*/
private
BigDecimal
chargingMoney
;
/**
* 硬件故障 BIN 码
* Bit 位表示(0 否 1 是),低位到高位顺序
* Bit1:急停按钮动作故障;
* Bit2:无可用整流模块;
* Bit3:出风口温度过高;
* Bit4:交流防雷故障;
* Bit5:交直流模块 DC20 通信中
* 断;
* Bit6:绝缘检测模块 FC08 通信中
* 断;
* Bit7:电度表通信中断;
* Bit8:读卡器通信中断;
* Bit9:RC10 通信中断;
* Bit10:风扇调速板故障;
* Bit11:直流熔断器故障;
* Bit12:高压接触器故障;
* Bit13:门打开;
*/
private
short
hardwareMalfunction
;
}
platform-charging-api/src/main/java/cn/com/glsx/charging/modules/model/gbt/ocpp16/tcp/TransactionRecordsMqData.java
0 → 100644
View file @
3b02d38
package
cn
.
com
.
glsx
.
charging
.
modules
.
model
.
gbt
.
ocpp16
.
tcp
;
import
lombok.Data
;
import
java.io.Serializable
;
import
java.math.BigDecimal
;
import
java.util.Date
;
/**
* @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
*/
@Data
public
class
TransactionRecordsMqData
implements
Serializable
{
/**
* 参数名称:交易流水号
* 数据类型:BCD码
* 长度(Byte):16
* 备注:见名词解释
*/
private
String
transactionSerialNumber
;
/**
* 参数名称:桩编号
* 数据类型:BCD码
* 长度(Byte):7
* 备注:不足7位补0
*/
private
String
pileId
;
/**
* 参数名称:枪号
* 数据类型:BCD码
* 长度(Byte):1
*/
private
String
gunNumber
;
/**
* 参数名称:开始时间
* 数据类型:BIN
* 长度(Byte):7
* 备注:CP56Time2a格式
*/
private
Date
startTime
;
/**
* 参数名称:结束时间
* 数据类型:BIN
* 长度(Byte):7
* 备注:CP56Time2a格式
*/
private
Date
endTime
;
/**
* 参数名称:尖单价
* 数据类型:BIN
* 长度(Byte):4
* 备注:精确到小数点后五位(尖电费+尖服务费,见费率帧)
*/
private
BigDecimal
peakUnitPrice
;
/**
* 参数名称:尖电量
* 数据类型:BIN
* 长度(Byte):4
* 备注:精确到小数点后四位
*/
private
BigDecimal
peakElectricity
;
/**
* 参数名称:计损尖电量
* 数据类型:BIN
* 长度(Byte):4
* 备注:精确到小数点后四位
*/
private
BigDecimal
peakElectricityLoss
;
/**
* 参数名称:尖金额
* 数据类型:BIN
* 长度(Byte):4
* 备注:精确到小数点后四位
*/
private
BigDecimal
peakAmount
;
/**
* 参数名称:峰单价
* 数据类型:BIN
* 长度(Byte):4
* 备注:精确到小数点后五位(峰电费+峰服务费)
*/
private
BigDecimal
topUnitPrice
;
/**
* 参数名称:峰电量
* 数据类型:BIN
* 长度(Byte):4
* 备注:精确到小数点后四位
*/
private
BigDecimal
topElectricity
;
/**
* 参数名称:计损峰电量
* 数据类型:BIN
* 长度(Byte):4
* 备注:精确到小数点后四位
*/
private
BigDecimal
topElectricityLoss
;
/**
* 参数名称:峰金额
* 数据类型:BIN
* 长度(Byte):4
* 备注:精确到小数点后四位
*/
private
BigDecimal
topAmount
;
/**
* 参数名称:平单价
* 数据类型:BIN
* 长度(Byte):4
* 备注:精确到小数点后五位(平电费+平服务费)
*/
private
BigDecimal
flatUnitPrice
;
/**
* 参数名称:平电量
* 数据类型:BIN
* 长度(Byte):4
* 备注:精确到小数点后四位
*/
private
BigDecimal
flatElectricity
;
/**
* 参数名称:计损平电量
* 数据类型:BIN
* 长度(Byte):4
* 备注:精确到小数点后四位
*/
private
BigDecimal
flatElectricityLoss
;
/**
* 参数名称:平金额
* 数据类型:BIN
* 长度(Byte):4
* 备注:精确到小数点后四位
*/
private
BigDecimal
flatAmount
;
/**
* 参数名称:谷单价
* 数据类型:BIN
* 长度(Byte):4
* 备注:精确到小数点后五位(谷电费+谷服务费)
*/
private
BigDecimal
valleyUnitPrice
;
/**
* 参数名称:谷电量
* 数据类型:BIN
* 长度(Byte):4
* 备注:精确到小数点后四位
*/
private
BigDecimal
valleyElectricity
;
/**
* 参数名称:计损谷电量
* 数据类型:BIN
* 长度(Byte):4
* 备注:精确到小数点后四位
*/
private
BigDecimal
valleyElectricityLoss
;
/**
* 参数名称:谷金额
* 数据类型:BIN
* 长度(Byte):4
* 备注:精确到小数点后四位
*/
private
BigDecimal
valleyAmount
;
/**
* 参数名称:电表总起值
* 数据类型:BIN
* 长度(Byte):5
* 备注:精确到小数点后四位
*/
private
BigDecimal
totalStartValue
;
/**
* 参数名称:电表总止值
* 数据类型:BIN
* 长度(Byte):5
* 备注:精确到小数点后四位
*/
private
BigDecimal
totalEndValue
;
/**
* 参数名称:总电量
* 数据类型:BIN
* 长度(Byte):4
* 备注:精确到小数点后四位
*/
private
BigDecimal
totalElectricity
;
/**
* 参数名称:计损总电量
* 数据类型:BIN
* 长度(Byte):4
* 备注:精确到小数点后四位
*/
private
BigDecimal
totalElectricityLoss
;
/**
* 参数名称:消费金额
* 数据类型:BIN
* 长度(Byte):4
* 备注:精确到小数点后四位,包含电费、服务费
*/
private
BigDecimal
totalAmount
;
/**
* 参数名称:电动汽车唯一标识
* 数据类型:ASCII
* 长度(Byte):17
* 备注:VIN码,此处VIN码和充电时VIN码不同,正序直接上传,无需补0和反序
*/
private
String
vehicleIdentifier
;
/**
* 参数名称:交易标识
* 数据类型:BIN
* 长度(Byte):1
* 备注:0x01:app启动 0x02:卡启动 0x04:离线卡启动 0x05: vin码启动充电
*/
private
byte
transactionIdentifier
;
/**
* 参数名称:交易日期、时间
* 数据类型:BIN
* 长度(Byte):7
* 备注:CP56Time2a格式
*/
private
Date
transactionDateTime
;
/**
* 参数名称:停止原因
* 数据类型:BIN
* 长度(Byte):1
* 备注:见附录11.1
*/
private
byte
stopReason
;
/**
* 物理卡号
* 数据类型: (BIN码)
* 长度(Byte):8
* 备注:不足补零,桩与平台交互需使用的物理卡号
*/
private
String
physicalCardNumber
;
}
platform-charging/src/main/java/cn/com/glsx/charging/modules/api/PileControlApiController.java
View file @
3b02d38
...
...
@@ -53,7 +53,7 @@ public class PileControlApiController implements PileControlFeignClient {
data
.
setPileId
(
Ocpp16Helper
.
strToBcd
(
startBo
.
getPileId
(),
data
.
getPileId
()));
data
.
setGunNumber
(
startBo
.
getGunNumber
().
byteValue
());
data
.
setLogicalCardNumber
(
Ocpp16Helper
.
strToBcd
(
startBo
.
get
TransactionSerial
Number
(),
data
.
getLogicalCardNumber
()));
Ocpp16Helper
.
strToBcd
(
startBo
.
get
LogicalCard
Number
(),
data
.
getLogicalCardNumber
()));
byte
[]
bytes
=
Ocpp16Helper
.
binToBytes
(
Ocpp16Helper
.
hexToBinStr
(
startBo
.
getPhysicalCardNumber
()));
data
.
setPhysicalCardNumber
(
bytes
);
...
...
@@ -61,10 +61,11 @@ public class PileControlApiController implements PileControlFeignClient {
BigDecimal
.
valueOf
(
startBo
.
getAccountBalance
()),
2
);
data
.
setAccountBalance
(
accountBytes
);
req
.
setData
(
data
);
TcpCallback
<
TcpRsp
>
tcpRspTcpCallback
=
ServerMain
.
getServer
().
sendSync
(
req
);
TcpRsp
tcpRsp
=
tcpRspTcpCallback
.
get
();
/*
TcpCallback<TcpRsp> tcpRspTcpCallback = ServerMain.getServer().sendSync(req);
TcpRsp tcpRsp = tcpRspTcpCallback.get();
*/
return
Result
.
success
(
true
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
return
Result
.
failure
();
}
}
...
...
platform-charging/src/main/java/cn/com/glsx/charging/modules/controller/ScanCodeController.java
deleted
100644 → 0
View file @
1817274
package
cn
.
com
.
glsx
.
charging
.
modules
.
controller
;
import
com.glsx.plat.core.annotation.ResponseResultBody
;
import
com.glsx.plat.core.web.Result
;
import
io.swagger.v3.oas.annotations.Operation
;
import
io.swagger.v3.oas.annotations.Parameter
;
import
io.swagger.v3.oas.annotations.tags.Tag
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
/**
* @Title:
* @Description:
* @Author xiehx
* @Date 2023/11/16
**/
@Slf4j
@Tag
(
name
=
"scancode开放接口"
)
@RestController
@RequestMapping
(
value
=
"/api/charging/scanCodes"
)
@ResponseResultBody
public
class
ScanCodeController
{
@Operation
(
summary
=
"打印code"
,
description
=
"打印code"
)
@GetMapping
(
"/{code}"
)
public
Result
<
String
>
printCode
(
@Parameter
(
name
=
"code"
,
description
=
"code"
,
required
=
true
)
@PathVariable
(
"code"
)
String
code
)
{
log
.
info
(
"ScanCode 码:{}"
,
code
);
return
Result
.
success
(
"success"
);
}
}
platform-charging/src/main/java/cn/com/glsx/charging/modules/gbt/ocpp16/Ocpp16Helper.java
View file @
3b02d38
...
...
@@ -122,6 +122,22 @@ public class Ocpp16Helper {
}
/**
* 单个byte bcd码转str
*
* @param b
* @return
*/
public
static
String
bcdToStr
(
byte
b
)
{
int
high
=
(
b
&
0xf0
)
>>>
4
;
int
low
=
b
&
0x0f
;
StringBuilder
sb
=
new
StringBuilder
();
sb
.
append
(
high
);
sb
.
append
(
low
);
return
sb
.
toString
();
}
/**
* bin格式byte数组转二进制字符串
* @param bytes
* @return
...
...
platform-charging/src/main/java/cn/com/glsx/charging/modules/gbt/ocpp16/tcp/base/TcpMapper.java
View file @
3b02d38
...
...
@@ -103,7 +103,7 @@ public final class TcpMapper {
public
static
TcpMapper
CMD_REQ_MODEL_SET
=
regist
(
0x58
,
"计费模型设置"
,
null
);
public
static
TcpMapper
CMD_RSP_MODEL_SET
=
regist
(
0x57
,
"
对时
设置应答"
,
ModelSetRspHandler
.
class
);
public
static
TcpMapper
CMD_RSP_MODEL_SET
=
regist
(
0x57
,
"
计费模型
设置应答"
,
ModelSetRspHandler
.
class
);
public
static
TcpMapper
CMD_REQ_BALANCE_UPDATE
=
regist
(
0x42
,
"远程账户余额更新"
,
null
);
...
...
platform-charging/src/main/java/cn/com/glsx/charging/modules/gbt/ocpp16/tcp/data/AdminSwipeConfirmReqData.java
View file @
3b02d38
...
...
@@ -44,16 +44,19 @@ public class AdminSwipeConfirmReqData extends TcpData {
private
byte
startWay
;
/**
* BIN 码 1位
* 是否需要密码 0x00 不需要 0x01 需要
*/
private
byte
passwordFlag
;
/**
* BIN 码 8
* 账号或者物理卡号
*/
private
byte
[]
logicalCardNumber
=
new
byte
[
8
];
/**
* BIN 码 16
* 输入密码
* 对用户输入的密码进行16 位MD5加密,采用小写上传
*/
...
...
platform-charging/src/main/java/cn/com/glsx/charging/modules/gbt/ocpp16/tcp/data/LoginReqData.java
View file @
3b02d38
...
...
@@ -24,11 +24,13 @@ public class LoginReqData extends TcpData {
private
byte
[]
pileId
=
new
byte
[
7
];
/**
* BIN 码 1
* 0 表示直流桩,1 表示交流桩
*/
private
byte
pointType
;
/**
* BIN 码 1
* 充电枪数量
*/
private
byte
gunCount
;
...
...
@@ -45,6 +47,7 @@ public class LoginReqData extends TcpData {
private
byte
[]
softVersion
=
new
byte
[
8
];
/**
* BIN 码
* 网络链接类型
* 0x00 SIM 卡
* 0x01 LAN
...
...
platform-charging/src/main/java/cn/com/glsx/charging/modules/gbt/ocpp16/tcp/handler/AdminSwipeConfirmRspHandler.java
View file @
3b02d38
...
...
@@ -23,14 +23,24 @@ public class AdminSwipeConfirmRspHandler implements TcpHandler<AdminSwipeConfirm
public
AdminSwipeConfirmRsp
handle
(
Channel
channel
,
AdminSwipeConfirmReq
req
)
{
AdminSwipeConfirmRsp
rsp
=
new
AdminSwipeConfirmRsp
();
AdminSwipeConfirmRspData
data
=
new
AdminSwipeConfirmRspData
();
log
.
info
(
"主动充电应答的桩号{}"
,
Ocpp16Helper
.
bcdToStr
(
req
.
getData
().
getPileId
()));
data
.
setPileId
(
req
.
getData
().
getPileId
());
data
.
setGunNumber
(
req
.
getData
().
getGunNumber
());
AdminSwipeConfirmReqData
reqData
=
req
.
getData
();
log
.
info
(
"充电桩主动申请启动充电 桩编号:{} 枪号:{} 启动方式:{} 是否需要密码:{} 账号或者物理卡号:{} 输入密码:{} VIN 码:{}"
,
reqData
.
getPileIdStr
(),
Ocpp16Helper
.
bcdToStr
(
reqData
.
getGunNumber
()),
reqData
.
getStartWay
(),
reqData
.
getPasswordFlag
(),
ByteUtils
.
toHex
(
reqData
.
getLogicalCardNumber
()),
ByteUtils
.
toHex
(
reqData
.
getMd5Password
()),
Ocpp16Helper
.
bytesToAscii
(
reqData
.
getVinCode
()));
data
.
setPileId
(
reqData
.
getPileId
());
data
.
setGunNumber
(
reqData
.
getGunNumber
());
data
.
setSucceedStatus
((
byte
)
1
);
byte
[]
byteArray
=
new
byte
[]{(
byte
)
0x9C
,
0x40
,
0x01
,
0x00
};
data
.
setAccountBalance
(
byteArray
);
data
.
setTransactionSerialNumber
(
Ocpp16Helper
.
strToBcd
(
"0000010021212121"
,
data
.
getTransactionSerialNumber
()));
data
.
setLogicalCardNumber
(
req
.
getData
()
.
getLogicalCardNumber
());
data
.
setLogicalCardNumber
(
req
Data
.
getLogicalCardNumber
());
rsp
.
setData
(
data
);
sendMQ
(
req
);
...
...
@@ -47,7 +57,7 @@ public class AdminSwipeConfirmRspHandler implements TcpHandler<AdminSwipeConfirm
AdminSwipeConfirmReqMqData
mqData
=
new
AdminSwipeConfirmReqMqData
();
mqData
.
setPileId
(
data
.
getPileIdStr
());
mqData
.
setGunNumber
(
(
int
)
data
.
getGunNumber
(
));
mqData
.
setGunNumber
(
Ocpp16Helper
.
bcdToStr
(
data
.
getGunNumber
()
));
mqData
.
setStartWay
((
int
)
data
.
getStartWay
());
mqData
.
setPasswordFlag
(
Boolean
.
valueOf
(
String
.
valueOf
(
data
.
getPasswordFlag
())));
mqData
.
setLogicalCardNumber
(
ByteUtils
.
toHex
(
data
.
getLogicalCardNumber
()));
...
...
@@ -57,7 +67,7 @@ public class AdminSwipeConfirmRspHandler implements TcpHandler<AdminSwipeConfirm
log
.
info
(
"充电桩主动申请启动充电 推送mq参数:{}"
,
mqData
);
MsgProducer
producer
=
SpringContextUtil
.
getApplicationContext
().
getBean
(
MsgProducer
.
class
);
producer
.
topicSend
(
RabbitMQConstants
.
ROUTING_KEY_ADMIN_SWIPE_CONFIRM_REQ
,
mqData
);
producer
.
topicSend
(
RabbitMQConstants
.
ROUTING_KEY_ADMIN_SWIPE_CONFIRM_REQ
,
mqData
);
}
}
platform-charging/src/main/java/cn/com/glsx/charging/modules/gbt/ocpp16/tcp/handler/HeartbeatReqHandler.java
View file @
3b02d38
...
...
@@ -39,7 +39,7 @@ public class HeartbeatReqHandler implements TcpHandler<HeartbeatReq, HeartbeatRs
HeartbeatReqMqData
mqData
=
new
HeartbeatReqMqData
();
mqData
.
setPileId
(
data
.
getPileIdStr
());
mqData
.
setGunN
o
((
int
)
data
.
getGunNo
(
));
mqData
.
setGunN
umber
(
Ocpp16Helper
.
bcdToStr
(
data
.
getGunNo
()
));
mqData
.
setStatus
((
int
)
data
.
getStatus
());
log
.
info
(
"充电桩心跳包 推送mq参数:{}"
,
mqData
);
...
...
platform-charging/src/main/java/cn/com/glsx/charging/modules/gbt/ocpp16/tcp/handler/LoginReqHandler.java
View file @
3b02d38
...
...
@@ -7,10 +7,10 @@ import cn.com.glsx.charging.modules.gbt.ocpp16.tcp.data.LoginReqData;
import
cn.com.glsx.charging.modules.gbt.ocpp16.tcp.data.LoginRspData
;
import
cn.com.glsx.charging.modules.gbt.ocpp16.tcp.protocol.LoginReq
;
import
cn.com.glsx.charging.modules.gbt.ocpp16.tcp.protocol.LoginRsp
;
import
cn.com.glsx.charging.modules.model.gbt.ocpp16.tcp.LoginUploadMqData
;
import
cn.com.glsx.charging.modules.rabbitmq.MsgProducer
;
import
cn.com.glsx.charging.modules.rabbitmq.RabbitMQConstants
;
import
cn.com.glsx.charging.util.SpringContextUtil
;
import
cn.com.glsx.evbusiness.modules.model.ocpp16.LoginUploadData
;
import
io.netty.channel.Channel
;
public
class
LoginReqHandler
implements
TcpHandler
<
LoginReq
,
LoginRsp
>
{
...
...
@@ -25,13 +25,13 @@ public class LoginReqHandler implements TcpHandler<LoginReq, LoginRsp> {
LoginRsp
trsp
=
new
LoginRsp
();
trsp
.
setData
(
data
);
// trsp.setReqKey(req.getReqKey());
/* syncData(req.getData());*/
syncData
(
req
.
getData
());
return
trsp
;
}
private
Boolean
syncData
(
LoginReqData
data
)
{
LoginUpload
Data
respData
=
new
LoginUpload
Data
();
LoginUpload
MqData
respData
=
new
LoginUploadMq
Data
();
respData
.
setPileId
(
Ocpp16Helper
.
bcdToStr
(
data
.
getPileId
()));
respData
.
setNetwork
(
data
.
getNetwork
());
respData
.
setGunCount
(
data
.
getGunCount
());
...
...
platform-charging/src/main/java/cn/com/glsx/charging/modules/gbt/ocpp16/tcp/handler/TransactionRecordsReqHandler.java
View file @
3b02d38
...
...
@@ -6,11 +6,11 @@ import cn.com.glsx.charging.modules.gbt.ocpp16.tcp.data.TransactionRecordsReqDat
import
cn.com.glsx.charging.modules.gbt.ocpp16.tcp.data.TransactionRecordsRespData
;
import
cn.com.glsx.charging.modules.gbt.ocpp16.tcp.protocol.TransactionRecordsReq
;
import
cn.com.glsx.charging.modules.gbt.ocpp16.tcp.protocol.TransactionRecordsResp
;
import
cn.com.glsx.charging.modules.model.gbt.ocpp16.tcp.TransactionRecordsMqData
;
import
cn.com.glsx.charging.modules.rabbitmq.MsgProducer
;
import
cn.com.glsx.charging.modules.rabbitmq.RabbitMQConstants
;
import
cn.com.glsx.charging.util.ByteUtils
;
import
cn.com.glsx.charging.util.SpringContextUtil
;
import
cn.com.glsx.evbusiness.modules.model.ocpp16.TransactionRecordsData
;
import
io.netty.channel.Channel
;
/**
...
...
@@ -28,7 +28,7 @@ public class TransactionRecordsReqHandler implements TcpHandler<TransactionRecor
/** 解析参数日志打印 */
log
.
info
(
"交易流水号:{}"
,
Ocpp16Helper
.
bcdToStr
(
data
.
getTransactionSerialNumber
()));
log
.
info
(
"桩编号:{}"
,
Ocpp16Helper
.
bcdToStr
(
data
.
getPileId
()));
log
.
info
(
"枪号:{}"
,
data
.
getGunNumber
(
));
log
.
info
(
"枪号:{}"
,
Ocpp16Helper
.
bcdToStr
(
data
.
getGunNumber
()
));
log
.
info
(
"开始时间:{}"
,
ByteUtils
.
toHex
(
data
.
getStartTime
()));
log
.
info
(
"结束时间:{}"
,
ByteUtils
.
toHex
(
data
.
getEndTime
()));
log
.
info
(
"尖单价:{}"
,
ByteUtils
.
toHex
(
data
.
getPeakUnitPrice
()));
...
...
@@ -52,7 +52,7 @@ public class TransactionRecordsReqHandler implements TcpHandler<TransactionRecor
log
.
info
(
"总电量:{}"
,
ByteUtils
.
toHex
(
data
.
getTotalElectricity
()));
log
.
info
(
"计损总电量:{}"
,
ByteUtils
.
toHex
(
data
.
getTotalElectricityLoss
()));
log
.
info
(
"消费金额:{}"
,
ByteUtils
.
toHex
(
data
.
getTotalAmount
()));
log
.
info
(
"电动汽车唯一标识:{}"
,
ByteUtils
.
toHex
(
data
.
getVehicleIdentifier
()));
log
.
info
(
"电动汽车唯一标识:{}"
,
Ocpp16Helper
.
bytesToAscii
(
data
.
getVehicleIdentifier
()));
log
.
info
(
"交易标识:{}"
,
data
.
getTransactionIdentifier
());
log
.
info
(
"交易日期、时间:{}"
,
ByteUtils
.
toHex
(
data
.
getTransactionDateTime
()));
log
.
info
(
"停止原因:{}"
,
data
.
getStopReason
());
...
...
@@ -73,10 +73,10 @@ public class TransactionRecordsReqHandler implements TcpHandler<TransactionRecor
* @param data
*/
private
Boolean
syncData
(
TransactionRecordsReqData
data
)
{
TransactionRecords
Data
respData
=
new
TransactionRecords
Data
();
TransactionRecords
MqData
respData
=
new
TransactionRecordsMq
Data
();
respData
.
setTransactionSerialNumber
(
Ocpp16Helper
.
bcdToStr
(
data
.
getTransactionSerialNumber
()));
respData
.
setPileId
(
Ocpp16Helper
.
bcdToStr
(
data
.
getPileId
()));
respData
.
setGunNumber
(
data
.
getGunNumber
(
));
respData
.
setGunNumber
(
Ocpp16Helper
.
bcdToStr
(
data
.
getGunNumber
()
));
respData
.
setStartTime
(
ByteUtils
.
parseCp56Time2a
(
data
.
getStartTime
()));
respData
.
setEndTime
(
ByteUtils
.
parseCp56Time2a
(
data
.
getEndTime
()));
respData
.
setPeakUnitPrice
(
Ocpp16Helper
.
bytesBinToBigDecimal
(
data
.
getPeakUnitPrice
(),
5
));
...
...
@@ -105,7 +105,7 @@ public class TransactionRecordsReqHandler implements TcpHandler<TransactionRecor
respData
.
setTotalElectricityLoss
(
Ocpp16Helper
.
bytesBinToBigDecimal
(
data
.
getTotalElectricityLoss
(),
4
));
respData
.
setTotalAmount
(
Ocpp16Helper
.
bytesBinToBigDecimal
(
data
.
getTotalAmount
(),
4
));
respData
.
setVehicleIdentifier
(
ByteUtils
.
toHex
(
data
.
getVehicleIdentifier
()));
respData
.
setVehicleIdentifier
(
Ocpp16Helper
.
bytesToAscii
(
data
.
getVehicleIdentifier
()));
respData
.
setTransactionIdentifier
(
data
.
getTransactionIdentifier
());
respData
.
setTransactionDateTime
(
ByteUtils
.
parseCp56Time2a
(
data
.
getTransactionDateTime
()));
respData
.
setStopReason
(
data
.
getStopReason
());
...
...
platform-charging/src/main/java/cn/com/glsx/charging/modules/gbt/ocpp16/tcp/handler/UploadRealTimeRspHandler.java
View file @
3b02d38
...
...
@@ -4,64 +4,62 @@ 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.RealTimeRspData
;
import
cn.com.glsx.charging.modules.gbt.ocpp16.tcp.protocol.UploadRealtimeDataRsp
;
import
cn.com.glsx.charging.modules.
gbt.ocpp16.tcp.server.ProxyHelper
;
import
cn.com.glsx.charging.modules.
model.gbt.ocpp16.tcp.RealTimeUploadMqData
;
import
cn.com.glsx.charging.modules.rabbitmq.MsgProducer
;
import
cn.com.glsx.charging.modules.rabbitmq.RabbitMQConstants
;
import
cn.com.glsx.charging.util.ByteUtils
;
import
cn.com.glsx.charging.util.SpringContextUtil
;
import
cn.com.glsx.evbusiness.modules.model.ocpp16.RealTimeUploadData
;
import
io.netty.channel.Channel
;
import
java.util.Objects
;
/**
* 充电桩上传实时检测数据 req handler
*
*
充电桩上传实时检测数据 req handler
*
* @author chenxi
* @date 2023年11月7日 上午10:19:34
*/
public
class
UploadRealTimeRspHandler
implements
TcpHandler
<
UploadRealtimeDataRsp
,
UploadRealtimeDataRsp
>
{
@Override
public
UploadRealtimeDataRsp
handle
(
Channel
channel
,
UploadRealtimeDataRsp
notify
)
{
RealTimeRspData
data
=
notify
.
getData
();
if
(
Objects
.
isNull
(
data
))
{
log
.
info
(
"实时监测数据为空"
);
return
null
;
}
log
.
info
(
"实时监测数据:{}"
,
data
);
ProxyHelper
.
setCallback
(
channel
,
notify
);
uploadRealTimeData
(
notify
.
getData
());
return
null
;
}
@Override
public
UploadRealtimeDataRsp
handle
(
Channel
channel
,
UploadRealtimeDataRsp
notify
)
{
RealTimeRspData
data
=
notify
.
getData
();
if
(
Objects
.
isNull
(
data
))
{
log
.
info
(
"实时监测数据为空"
);
return
null
;
}
log
.
info
(
"实时监测数据:{}"
,
data
);
uploadRealTimeData
(
notify
.
getData
());
return
null
;
}
private
Boolean
uploadRealTimeData
(
RealTimeRspData
data
)
{
RealTimeUploadData
upData
=
new
RealTimeUpload
Data
();
upData
.
setTransactionSerialNumber
(
Ocpp16Helper
.
bcdToStr
(
data
.
getTransactionSerialNumber
()));
upData
.
setPileId
(
Ocpp16Helper
.
bcdToStr
(
data
.
getPileId
()));
upData
.
setGunNumber
(
data
.
getGunNumber
(
));
upData
.
setStatus
(
data
.
getStatus
());
upData
.
setIfReturn
(
data
.
getIfReturn
());
upData
.
setIfCharging
(
data
.
getIfCharging
());
upData
.
setOutputVoltage
(
Ocpp16Helper
.
bytesBinToBigDecimal
(
data
.
getOutputVoltage
(),
1
));
upData
.
setOutputCurrent
(
Ocpp16Helper
.
bytesBinToBigDecimal
(
data
.
getOutputCurrent
(),
1
));
upData
.
setGunWireTemperature
(
data
.
getGunWireTemperature
());
upData
.
setGunWireNumber
(
ByteUtils
.
toHex
(
data
.
getGunWireNumber
()));
upData
.
setSoc
(
data
.
getSoc
());
upData
.
setBatteryHighestTemperature
(
data
.
getBatteryHighestTemperature
());
upData
.
setAccumulatedChargingTime
(
Ocpp16Helper
.
bytesBinToBigDecimal
(
data
.
getAccumulatedChargingTime
(),
0
).
shortValue
());
upData
.
setTimeLeft
(
Ocpp16Helper
.
bytesBinToBigDecimal
(
data
.
getTimeLeft
(),
0
).
shortValue
());
upData
.
setChargingDegree
(
Ocpp16Helper
.
bytesBinToBigDecimal
(
data
.
getChargingDegree
(),
4
));
upData
.
setLossChargingDegree
(
Ocpp16Helper
.
bytesBinToBigDecimal
(
data
.
getLossChargingDegree
(),
4
));
upData
.
setChargingMoney
(
Ocpp16Helper
.
bytesBinToBigDecimal
(
data
.
getChargingMoney
(),
4
));
upData
.
setHardwareMalfunction
(
Ocpp16Helper
.
bytesBinToBigDecimal
(
data
.
getHardwareMalfunction
(),
0
).
shortValue
());
private
Boolean
uploadRealTimeData
(
RealTimeRspData
data
)
{
RealTimeUploadMqData
upData
=
new
RealTimeUploadMq
Data
();
upData
.
setTransactionSerialNumber
(
Ocpp16Helper
.
bcdToStr
(
data
.
getTransactionSerialNumber
()));
upData
.
setPileId
(
Ocpp16Helper
.
bcdToStr
(
data
.
getPileId
()));
upData
.
setGunNumber
(
Ocpp16Helper
.
bcdToStr
(
data
.
getGunNumber
()
));
upData
.
setStatus
(
data
.
getStatus
());
upData
.
setIfReturn
(
data
.
getIfReturn
());
upData
.
setIfCharging
(
data
.
getIfCharging
());
upData
.
setOutputVoltage
(
Ocpp16Helper
.
bytesBinToBigDecimal
(
data
.
getOutputVoltage
(),
1
));
upData
.
setOutputCurrent
(
Ocpp16Helper
.
bytesBinToBigDecimal
(
data
.
getOutputCurrent
(),
1
));
upData
.
setGunWireTemperature
(
data
.
getGunWireTemperature
());
upData
.
setGunWireNumber
(
ByteUtils
.
toHex
(
data
.
getGunWireNumber
()));
upData
.
setSoc
(
data
.
getSoc
());
upData
.
setBatteryHighestTemperature
(
data
.
getBatteryHighestTemperature
());
upData
.
setAccumulatedChargingTime
(
Ocpp16Helper
.
bytesBinToBigDecimal
(
data
.
getAccumulatedChargingTime
(),
0
).
shortValue
());
upData
.
setTimeLeft
(
Ocpp16Helper
.
bytesBinToBigDecimal
(
data
.
getTimeLeft
(),
0
).
shortValue
());
upData
.
setChargingDegree
(
Ocpp16Helper
.
bytesBinToBigDecimal
(
data
.
getChargingDegree
(),
4
));
upData
.
setLossChargingDegree
(
Ocpp16Helper
.
bytesBinToBigDecimal
(
data
.
getLossChargingDegree
(),
4
));
upData
.
setChargingMoney
(
Ocpp16Helper
.
bytesBinToBigDecimal
(
data
.
getChargingMoney
(),
4
));
upData
.
setHardwareMalfunction
(
Ocpp16Helper
.
bytesBinToBigDecimal
(
data
.
getHardwareMalfunction
(),
0
).
shortValue
());
log
.
info
(
"实时监测数据 推送mq参数:{}"
,
upData
);
log
.
info
(
"实时监测数据 推送mq参数:{}"
,
upData
);
MsgProducer
producer
=
SpringContextUtil
.
getApplicationContext
().
getBean
(
MsgProducer
.
class
);
producer
.
topicSend
(
RabbitMQConstants
.
ROUTING_KEY_UPLOAD_REAL_TIME_RSP
,
upData
);
return
true
;
}
MsgProducer
producer
=
SpringContextUtil
.
getApplicationContext
().
getBean
(
MsgProducer
.
class
);
producer
.
topicSend
(
RabbitMQConstants
.
ROUTING_KEY_UPLOAD_REAL_TIME_RSP
,
upData
);
return
true
;
}
}
platform-charging/src/main/java/cn/com/glsx/charging/modules/gbt/ocpp16/tcp/protocol/UploadRealtimeDataRsp.java
View file @
3b02d38
package
cn
.
com
.
glsx
.
charging
.
modules
.
gbt
.
ocpp16
.
tcp
.
protocol
;
import
cn.com.glsx.charging.modules.gbt.ocpp16.tcp.base.TcpMapper
;
import
cn.com.glsx.charging.modules.gbt.ocpp16.tcp.base.TcpR
sp
;
import
cn.com.glsx.charging.modules.gbt.ocpp16.tcp.base.TcpR
eq
;
import
cn.com.glsx.charging.modules.gbt.ocpp16.tcp.data.RealTimeRspData
;
/**
* @author 读取实时检测数据
* @date 2023年11月7日 下午2:48:32 ---
*/
public
class
UploadRealtimeDataRsp
extends
TcpR
sp
<
RealTimeRspData
>
{
public
class
UploadRealtimeDataRsp
extends
TcpR
eq
<
RealTimeRspData
>
{
public
UploadRealtimeDataRsp
()
{
super
(
TcpMapper
.
CMD_RSP_UPLOAD_REAL_TIME_DATA
.
getType
());
...
...
platform-charging/src/main/java/cn/com/glsx/charging/modules/gbt/ocpp16/tcp/server/ProxyHelper.java
View file @
3b02d38
...
...
@@ -2,6 +2,7 @@ package cn.com.glsx.charging.modules.gbt.ocpp16.tcp.server;
import
java.net.InetSocketAddress
;
import
java.util.Date
;
import
java.util.HashMap
;
import
java.util.Map
;
import
com.google.common.collect.Maps
;
...
...
@@ -37,6 +38,27 @@ public class ProxyHelper {
private
static
Map
<
String
,
TcpCallback
<
TcpRsp
>>
callbackMap
=
Maps
.
newConcurrentMap
();
/**
* 协议帧对
*/
private
static
Map
<
String
,
String
>
typeMaps
;
static
{
// 初始化map
typeMaps
=
new
HashMap
<>();
typeMaps
.
put
(
"33"
,
"34"
);
typeMaps
.
put
(
"35"
,
"36"
);
typeMaps
.
put
(
"41"
,
"42"
);
typeMaps
.
put
(
"43"
,
"44"
);
typeMaps
.
put
(
"45"
,
"46"
);
typeMaps
.
put
(
"47"
,
"48"
);
typeMaps
.
put
(
"51"
,
"52"
);
typeMaps
.
put
(
"55"
,
"56"
);
typeMaps
.
put
(
"57"
,
"58"
);
typeMaps
.
put
(
"91"
,
"92"
);
typeMaps
.
put
(
"93"
,
"94"
);
}
// key -> TcpCallback
// private static Map<String, TcpCallback<? extends TcpRsp>> callbacks = Maps.newConcurrentMap();
...
...
@@ -166,11 +188,10 @@ public class ProxyHelper {
}
public
static
void
addCallback
(
String
key
,
TcpCallback
<
TcpRsp
>
callback
)
{
TcpCallback
<
TcpRsp
>
tcpRspTcpCallback
=
callbackMap
.
get
(
key
);
if
(
tcpRspTcpCallback
==
null
)
{
callbackMap
.
put
(
key
,
callback
);
}
else
{
callback
=
tcpRspTcpCallback
;
String
[]
split
=
key
.
split
(
"|"
);
if
(
split
.
length
>
1
)
{
callbackMap
.
put
(
split
[
0
],
callback
);
callbackMap
.
put
(
split
[
1
],
callback
);
}
}
...
...
@@ -181,16 +202,17 @@ public class ProxyHelper {
/**
* 获取callback的key
*
* @param data 请求体
* @param data
请求体
* @param channel 通道
* @return
* @param <T>
* @return
*/
public
static
<
T
extends
TcpBase
>
String
getCallbackKey
(
T
data
,
Channel
channel
)
{
if
(
channel
==
null
)
{
if
(
channel
==
null
)
{
throw
new
RuntimeException
(
"channel为null!!!"
);
}
return
channel
.
attr
(
ProxyHelper
.
PILE_ID_KEY
).
get
()
+
"+"
+
data
.
getSeq
();
return
channel
.
attr
(
ProxyHelper
.
PILE_ID_KEY
).
get
()
+
"+"
+
data
.
getSeq
()
+
"|"
+
channel
.
attr
(
ProxyHelper
.
PILE_ID_KEY
).
get
()
+
"+"
+
intToHex
(
data
.
getType
());
}
/**
...
...
@@ -202,12 +224,33 @@ public class ProxyHelper {
*/
public
static
<
T
extends
TcpBase
>
void
setCallback
(
Channel
channel
,
TcpRsp
rsp
)
{
String
key
=
getCallbackKey
(
rsp
,
channel
);
TcpCallback
<
TcpRsp
>
callback
=
ProxyHelper
.
getCallback
(
key
);
String
key
1
=
channel
.
attr
(
ProxyHelper
.
PILE_ID_KEY
).
get
()
+
"+"
+
rsp
.
getSeq
(
);
TcpCallback
<
TcpRsp
>
callback
=
ProxyHelper
.
getCallback
(
key
1
);
if
(
Objects
.
nonNull
(
callback
))
{
callback
.
callback
(
rsp
);
}
else
{
log
.
info
(
"key{},callback为空"
,
key
);
String
key2
=
channel
.
attr
(
ProxyHelper
.
PILE_ID_KEY
).
get
()
+
"+"
+
typeMaps
.
get
(
intToHex
(
rsp
.
getType
()));
TcpCallback
<
TcpRsp
>
tcpRspTcpCallback
=
ProxyHelper
.
getCallback
(
key2
);
if
(
Objects
.
nonNull
(
tcpRspTcpCallback
))
{
callback
.
callback
(
rsp
);
}
else
{
log
.
info
(
"key{},{},callback为空"
,
key1
,
key2
);
}
}
}
private
static
String
intToHex
(
int
n
)
{
//StringBuffer s = new StringBuffer();
StringBuilder
sb
=
new
StringBuilder
(
8
);
String
a
;
char
[]
b
=
{
'0'
,
'1'
,
'2'
,
'3'
,
'4'
,
'5'
,
'6'
,
'7'
,
'8'
,
'9'
,
'A'
,
'B'
,
'C'
,
'D'
,
'E'
,
'F'
};
while
(
n
!=
0
){
sb
=
sb
.
append
(
b
[
n
%
16
]);
n
=
n
/
16
;
}
a
=
sb
.
reverse
().
toString
();
return
a
;
}
}
platform-charging/src/test/java/cn/com/glsx/charging/api/FeignSerivceTest.java
View file @
3b02d38
...
...
@@ -27,5 +27,7 @@ public class FeignSerivceTest {
public
void
Test
()
throws
Exception
{
Result
<
Boolean
>
b
=
dataInteractionFeignClient
.
uploadRealTimeData
(
new
RealTimeUploadData
());
System
.
out
.
println
(
b
);
Result
<
Boolean
>
booleanResult
=
dataInteractionFeignClient
.
uploadRealTimeData
(
new
RealTimeUploadData
());
}
}
platform-charging/src/test/java/cn/com/glsx/charging/gbt/ocpp16/ModelSetTest.java
View file @
3b02d38
...
...
@@ -5,8 +5,13 @@ 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.ModelSetRspData
;
import
cn.com.glsx.charging.modules.gbt.ocpp16.tcp.data.ModelValReqData
;
import
cn.com.glsx.charging.modules.gbt.ocpp16.tcp.data.TimeSettingReqData
;
import
cn.com.glsx.charging.modules.gbt.ocpp16.tcp.data.TimeSettingRspData
;
import
cn.com.glsx.charging.modules.gbt.ocpp16.tcp.protocol.ModelSetRsp
;
import
cn.com.glsx.charging.modules.gbt.ocpp16.tcp.protocol.ModelValReq
;
import
cn.com.glsx.charging.modules.gbt.ocpp16.tcp.protocol.TimeSettingRsp
;
import
cn.com.glsx.charging.util.ByteUtils
;
import
cn.hutool.core.util.HexUtil
;
/**
* 计费模型设置应答
...
...
@@ -26,12 +31,18 @@ public class ModelSetTest {
Thread
.
sleep
(
3000
);
ModelSetRsp
req
=
new
ModelSetRsp
();
/*
ModelSetRsp req = new ModelSetRsp();
req.setData(new ModelSetRspData());
req.getData().setPileId(Ocpp16Helper.strToBcd("55031412782305", req.getData().getPileId()));
req
.
getData
().
setSetResult
((
byte
)
0x01
);
req.getData().setSetResult((byte) 0x01);
*/
client
.
sendSync
(
req
);
TimeSettingRspData
data
=
new
TimeSettingRspData
();
data
.
setPileId
(
Ocpp16Helper
.
strToBcd
(
"55031412782305"
,
data
.
getPileId
()));
TimeSettingRsp
rsp
=
new
TimeSettingRsp
();
rsp
.
setData
(
data
);
client
.
sendSync
(
rsp
);
}
...
...
platform-charging/src/test/java/cn/com/glsx/charging/gbt/ocpp16/TimeSettingTest.java
View file @
3b02d38
...
...
@@ -58,8 +58,6 @@ public class TimeSettingTest {
TcpCallback
<
TcpRsp
>
callback
=
tcpServer
.
sendSync
(
req
);
Thread
.
sleep
(
10000
);
TcpRsp
rsp
=
callback
.
get
();
log
.
info
(
"callback{}"
,
req
);
}
...
...
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