Commit 6a3b37f3 by 叶立庆

Merge remote-tracking branch 'origin/master'

2 parents 8d876fba 69acb548
......@@ -8,44 +8,41 @@ import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
/**
* @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 {
/**
* 一、FeignClients使用注意事项:
* 1. @EnableFeignClients 默认扫描 xxxxApplication启动入口 所在包路径下的 @FeignClient bean,若无法扫描到, 可以在使用Feign调用外部模块的api时候,
* 需要在引用服务中 xxxxApplication 中的 `@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)")
* 3. @FeignClient 接口对应的实现类,需要使用 @RestController注解 声明
* 4. mapper注解不支持 : @GetMapping,@PostMapping , 参数要加 @RequestParam(“xxx”)
* 5. FeignClient 调用,实质是httpClient调用 ,若我们暴露的接口api,声明了对应的 http mapper 信息,在调用方调用时候,通过代理 发起了 http请求,到服务提供方对应的http服务上去,所以在服务提供方的接口,可以使用 @RestController
* 来声明接口的 实现,否则调用方无法找到 http 对应的路径,会报404 ;
* 或者 根据 api 声明的http 信息,构建一个 Controller ,再来调用接口的实现类,但是这样不太方便;
* 6.FeignClient是一个“客户端”,它是用来发起请求的,不是提供服务的。
*
*
* 二、fallback 几种模式:
* 1.EchoCenterFeignServiceFallback.class 直接fallback,获取不到HTTP请求错误状态码和信息
* 2.EchoCenterFeignFactory.class 特定类型工厂模式
* 3.FunFallbackFactory 使用统一的工厂模式处理
*
*
* 三、性能问题
* 1.Feign是一个http请求调用的轻量级框架,基于http协议,性能不如rpc
* 2.可以为Feign配置连接池,配合使用okhttp等
*/
/**
* 一、FeignClients使用注意事项: 1. @EnableFeignClients 默认扫描 xxxxApplication启动入口 所在包路径下的 @FeignClient
* bean,若无法扫描到, 可以在使用Feign调用外部模块的api时候, 需要在引用服务中 xxxxApplication 中的
* `@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)") 3.
* @FeignClient 接口对应的实现类,需要使用 @RestController注解 声明 4. mapper注解不支持 : @GetMapping,@PostMapping ,
* 参数要加 @RequestParam(“xxx”) 5. FeignClient 调用,实质是httpClient调用 ,若我们暴露的接口api,声明了对应的 http mapper
* 信息,在调用方调用时候,通过代理 发起了 http请求,到服务提供方对应的http服务上去,所以在服务提供方的接口,可以使用 @RestController 来声明接口的
* 实现,否则调用方无法找到 http 对应的路径,会报404 ; 或者 根据 api 声明的http 信息,构建一个 Controller ,再来调用接口的实现类,但是这样不太方便;
* 6.FeignClient是一个“客户端”,它是用来发起请求的,不是提供服务的。
* <p>
* <p>
* 二、fallback 几种模式: 1.EchoCenterFeignServiceFallback.class 直接fallback,获取不到HTTP请求错误状态码和信息
* 2.EchoCenterFeignFactory.class 特定类型工厂模式 3.FunFallbackFactory 使用统一的工厂模式处理
* <p>
* <p>
* 三、性能问题 1.Feign是一个http请求调用的轻量级框架,基于http协议,性能不如rpc 2.可以为Feign配置连接池,配合使用okhttp等
*/
@PostMapping("/start")
Result<Boolean> start(@RequestParam("startBo") StartBo startBo);
@PostMapping("/start")
Result<Boolean> start(@RequestBody StartBo startBo);
@PostMapping("/end")
Result<Boolean> end(@RequestParam("endBo") EndBo endBo);
@PostMapping("/end")
Result<Boolean> end(@RequestBody EndBo endBo);
@PostMapping("/pileStart")
Result<Boolean> pileStart(@RequestParam("startBo") StartBo startBo);
@PostMapping("/pileStart")
Result<Boolean> pileStart(@RequestBody StartBo startBo);
}
......@@ -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.StartBo;
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.web.Result;
import io.swagger.v3.oas.annotations.Operation;
......@@ -48,12 +49,13 @@ public class PileControlApiController implements PileControlFeignClient {
@Override
public Result<Boolean> start(StartBo startBo) {
log.info("启动充电桩请求入参{}", JSONObject.toJSONString(startBo));
StartMachineReq req = new StartMachineReq();
StartMachineReqData data = new StartMachineReqData();
data.setTransactionSerialNumber(Ocpp16Helper.strToBcd(startBo.getTransactionSerialNumber(),
data.getTransactionSerialNumber()));
data.setPileId(Ocpp16Helper.strToBcd(startBo.getPileId(), data.getPileId()));
data.setGunNumber((byte) 1);
data.setGunNumber(startBo.getGunNumber().byteValue());
data.setLogicalCardNumber(
Ocpp16Helper.strToBcd(startBo.getTransactionSerialNumber(), data.getLogicalCardNumber()));
byte[] bytes = Ocpp16Helper.binToBytes(
......@@ -70,6 +72,7 @@ public class PileControlApiController implements PileControlFeignClient {
@Override
public Result<Boolean> end(EndBo endBo) {
log.info("停止充电桩请求入参{}", JSONObject.toJSONString(endBo));
ShutdownMachineReq req = new ShutdownMachineReq();
ShutdownMachineReqData data = new ShutdownMachineReqData();
data.setGunNumber(endBo.getGunNumber().byteValue());
......@@ -87,7 +90,8 @@ public class PileControlApiController implements PileControlFeignClient {
data.setPileId(Ocpp16Helper.strToBcd(startBo.getPileId(), data.getPileId()));
data.setGunNumber(startBo.getGunNumber().byteValue());
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.getTransactionSerialNumber()));
data.setLogicalCardNumber(Ocpp16Helper.strToBcd(startBo.getLogicalCardNumber(),
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!