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 6a3b37f3
authored
Nov 15, 2023
by
叶立庆
Browse Files
Options
Browse Files
Tag
Download
Plain Diff
Merge remote-tracking branch 'origin/master'
2 parents
8d876fba
69acb548
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
26 deletions
platform-charging-api/src/main/java/cn/com/glsx/charging/api/PileControlFeignClient.java
platform-charging/src/main/java/cn/com/glsx/charging/modules/api/PileControlApiController.java
platform-charging-api/src/main/java/cn/com/glsx/charging/api/PileControlFeignClient.java
View file @
6a3b37f
...
@@ -8,44 +8,41 @@ import org.springframework.cloud.openfeign.FeignClient;
...
@@ -8,44 +8,41 @@ import org.springframework.cloud.openfeign.FeignClient;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RequestParam
;
/**
/**
* @author payu
* @author payu
*/
*/
@FeignClient
(
name
=
"platform-charging"
,
contextId
=
"pilecontrol"
,
path
=
"/api/user/"
,
decode404
=
true
)
@FeignClient
(
name
=
"platform-charging
-server
"
,
contextId
=
"pilecontrol"
,
path
=
"/api/user/"
,
decode404
=
true
)
public
interface
PileControlFeignClient
{
public
interface
PileControlFeignClient
{
/**
/**
* 一、FeignClients使用注意事项:
* 一、FeignClients使用注意事项: 1. @EnableFeignClients 默认扫描 xxxxApplication启动入口 所在包路径下的 @FeignClient
* 1. @EnableFeignClients 默认扫描 xxxxApplication启动入口 所在包路径下的 @FeignClient bean,若无法扫描到, 可以在使用Feign调用外部模块的api时候,
* bean,若无法扫描到, 可以在使用Feign调用外部模块的api时候, 需要在引用服务中 xxxxApplication 中的
* 需要在引用服务中 xxxxApplication 中的
`@EnableFeignClients(basePackages = "cn.tendyron.customer")` 添加外部包需要扫描FeignClient的路径,否则无法注入bean
*
`@EnableFeignClients(basePackages = "cn.tendyron.customer")` 添加外部包需要扫描FeignClient的路径,否则无法注入bean
* 2. @FeignClient 声明的类,使用 spring.application.name 作为 name配置 @FeignClient(name="xxxx"),如果想保留 context-path , 则需要配置 path 属性 ,如:@FeignClient(name="xxxx" , path="xxxx(context-path)")
* 2. @FeignClient 声明的类,使用 spring.application.name 作为 name配置 @FeignClient(name="xxxx"),如果想保留
* 3. @FeignClient 接口对应的实现类,需要使用 @RestController注解 声明
* context-path , 则需要配置 path 属性 ,如:@FeignClient(name="xxxx" , path="xxxx(context-path)") 3.
* 4. mapper注解不支持 : @GetMapping,@PostMapping , 参数要加 @RequestParam(“xxx”)
* @FeignClient 接口对应的实现类,需要使用 @RestController注解 声明 4. mapper注解不支持 : @GetMapping,@PostMapping ,
* 5. FeignClient 调用,实质是httpClient调用 ,若我们暴露的接口api,声明了对应的 http mapper 信息,在调用方调用时候,通过代理 发起了 http请求,到服务提供方对应的http服务上去,所以在服务提供方的接口,可以使用 @RestControll
er
* 参数要加 @RequestParam(“xxx”) 5. FeignClient 调用,实质是httpClient调用 ,若我们暴露的接口api,声明了对应的 http mapp
er
* 来声明接口的 实现,否则调用方无法找到 http 对应的路径,会报404 ;
* 信息,在调用方调用时候,通过代理 发起了 http请求,到服务提供方对应的http服务上去,所以在服务提供方的接口,可以使用 @RestController 来声明接口的
*
或者 根据 api 声明的http 信息,构建一个 Controller ,再来调用接口的实现类,但是这样不太方便;
* 实现,否则调用方无法找到 http 对应的路径,会报404 ;
或者 根据 api 声明的http 信息,构建一个 Controller ,再来调用接口的实现类,但是这样不太方便;
* 6.FeignClient是一个“客户端”,它是用来发起请求的,不是提供服务的。
* 6.FeignClient是一个“客户端”,它是用来发起请求的,不是提供服务的。
*
* <p>
*
* <p>
* 二、fallback 几种模式:
* 二、fallback 几种模式: 1.EchoCenterFeignServiceFallback.class 直接fallback,获取不到HTTP请求错误状态码和信息
* 1.EchoCenterFeignServiceFallback.class 直接fallback,获取不到HTTP请求错误状态码和信息
* 2.EchoCenterFeignFactory.class 特定类型工厂模式 3.FunFallbackFactory 使用统一的工厂模式处理
* 2.EchoCenterFeignFactory.class 特定类型工厂模式
* <p>
* 3.FunFallbackFactory 使用统一的工厂模式处理
* <p>
*
* 三、性能问题 1.Feign是一个http请求调用的轻量级框架,基于http协议,性能不如rpc 2.可以为Feign配置连接池,配合使用okhttp等
*
* 三、性能问题
* 1.Feign是一个http请求调用的轻量级框架,基于http协议,性能不如rpc
* 2.可以为Feign配置连接池,配合使用okhttp等
*/
*/
@PostMapping
(
"/start"
)
@PostMapping
(
"/start"
)
Result
<
Boolean
>
start
(
@RequestParam
(
"startBo"
)
StartBo
startBo
);
Result
<
Boolean
>
start
(
@RequestBody
StartBo
startBo
);
@PostMapping
(
"/end"
)
@PostMapping
(
"/end"
)
Result
<
Boolean
>
end
(
@RequestParam
(
"endBo"
)
EndBo
endBo
);
Result
<
Boolean
>
end
(
@RequestBody
EndBo
endBo
);
@PostMapping
(
"/pileStart"
)
@PostMapping
(
"/pileStart"
)
Result
<
Boolean
>
pileStart
(
@RequestParam
(
"startBo"
)
StartBo
startBo
);
Result
<
Boolean
>
pileStart
(
@RequestBody
StartBo
startBo
);
}
}
platform-charging/src/main/java/cn/com/glsx/charging/modules/api/PileControlApiController.java
View file @
6a3b37f
...
@@ -18,6 +18,7 @@ import cn.com.glsx.charging.modules.model.UserDTO;
...
@@ -18,6 +18,7 @@ import cn.com.glsx.charging.modules.model.UserDTO;
import
cn.com.glsx.charging.modules.model.pilecontrol.EndBo
;
import
cn.com.glsx.charging.modules.model.pilecontrol.EndBo
;
import
cn.com.glsx.charging.modules.model.pilecontrol.StartBo
;
import
cn.com.glsx.charging.modules.model.pilecontrol.StartBo
;
import
cn.com.glsx.charging.modules.service.UserDemoService
;
import
cn.com.glsx.charging.modules.service.UserDemoService
;
import
com.alibaba.fastjson.JSONObject
;
import
com.glsx.plat.core.annotation.ResponseResultBody
;
import
com.glsx.plat.core.annotation.ResponseResultBody
;
import
com.glsx.plat.core.web.Result
;
import
com.glsx.plat.core.web.Result
;
import
io.swagger.v3.oas.annotations.Operation
;
import
io.swagger.v3.oas.annotations.Operation
;
...
@@ -48,12 +49,13 @@ public class PileControlApiController implements PileControlFeignClient {
...
@@ -48,12 +49,13 @@ public class PileControlApiController implements PileControlFeignClient {
@Override
@Override
public
Result
<
Boolean
>
start
(
StartBo
startBo
)
{
public
Result
<
Boolean
>
start
(
StartBo
startBo
)
{
log
.
info
(
"启动充电桩请求入参{}"
,
JSONObject
.
toJSONString
(
startBo
));
StartMachineReq
req
=
new
StartMachineReq
();
StartMachineReq
req
=
new
StartMachineReq
();
StartMachineReqData
data
=
new
StartMachineReqData
();
StartMachineReqData
data
=
new
StartMachineReqData
();
data
.
setTransactionSerialNumber
(
Ocpp16Helper
.
strToBcd
(
startBo
.
getTransactionSerialNumber
(),
data
.
setTransactionSerialNumber
(
Ocpp16Helper
.
strToBcd
(
startBo
.
getTransactionSerialNumber
(),
data
.
getTransactionSerialNumber
()));
data
.
getTransactionSerialNumber
()));
data
.
setPileId
(
Ocpp16Helper
.
strToBcd
(
startBo
.
getPileId
(),
data
.
getPileId
()));
data
.
setPileId
(
Ocpp16Helper
.
strToBcd
(
startBo
.
getPileId
(),
data
.
getPileId
()));
data
.
setGunNumber
(
(
byte
)
1
);
data
.
setGunNumber
(
startBo
.
getGunNumber
().
byteValue
()
);
data
.
setLogicalCardNumber
(
data
.
setLogicalCardNumber
(
Ocpp16Helper
.
strToBcd
(
startBo
.
getTransactionSerialNumber
(),
data
.
getLogicalCardNumber
()));
Ocpp16Helper
.
strToBcd
(
startBo
.
getTransactionSerialNumber
(),
data
.
getLogicalCardNumber
()));
byte
[]
bytes
=
Ocpp16Helper
.
binToBytes
(
byte
[]
bytes
=
Ocpp16Helper
.
binToBytes
(
...
@@ -70,6 +72,7 @@ public class PileControlApiController implements PileControlFeignClient {
...
@@ -70,6 +72,7 @@ public class PileControlApiController implements PileControlFeignClient {
@Override
@Override
public
Result
<
Boolean
>
end
(
EndBo
endBo
)
{
public
Result
<
Boolean
>
end
(
EndBo
endBo
)
{
log
.
info
(
"停止充电桩请求入参{}"
,
JSONObject
.
toJSONString
(
endBo
));
ShutdownMachineReq
req
=
new
ShutdownMachineReq
();
ShutdownMachineReq
req
=
new
ShutdownMachineReq
();
ShutdownMachineReqData
data
=
new
ShutdownMachineReqData
();
ShutdownMachineReqData
data
=
new
ShutdownMachineReqData
();
data
.
setGunNumber
(
endBo
.
getGunNumber
().
byteValue
());
data
.
setGunNumber
(
endBo
.
getGunNumber
().
byteValue
());
...
@@ -87,7 +90,8 @@ public class PileControlApiController implements PileControlFeignClient {
...
@@ -87,7 +90,8 @@ public class PileControlApiController implements PileControlFeignClient {
data
.
setPileId
(
Ocpp16Helper
.
strToBcd
(
startBo
.
getPileId
(),
data
.
getPileId
()));
data
.
setPileId
(
Ocpp16Helper
.
strToBcd
(
startBo
.
getPileId
(),
data
.
getPileId
()));
data
.
setGunNumber
(
startBo
.
getGunNumber
().
byteValue
());
data
.
setGunNumber
(
startBo
.
getGunNumber
().
byteValue
());
data
.
setSucceedStatus
(
startBo
.
getSucceedStatus
());
data
.
setSucceedStatus
(
startBo
.
getSucceedStatus
());
data
.
setAccountBalance
(
Ocpp16Helper
.
bigDecimalToByteArray
(
BigDecimal
.
valueOf
(
startBo
.
getAccountBalance
()),
4
));
data
.
setAccountBalance
(
Ocpp16Helper
.
bigDecimalToByteArray
(
BigDecimal
.
valueOf
(
startBo
.
getAccountBalance
()),
4
));
data
.
setTransactionSerialNumber
(
Ocpp16Helper
.
strToBcd
(
startBo
.
getTransactionSerialNumber
(),
data
.
setTransactionSerialNumber
(
Ocpp16Helper
.
strToBcd
(
startBo
.
getTransactionSerialNumber
(),
data
.
getTransactionSerialNumber
()));
data
.
getTransactionSerialNumber
()));
data
.
setLogicalCardNumber
(
Ocpp16Helper
.
strToBcd
(
startBo
.
getLogicalCardNumber
(),
data
.
setLogicalCardNumber
(
Ocpp16Helper
.
strToBcd
(
startBo
.
getLogicalCardNumber
(),
...
...
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