Commit 47d8bf76 by zhouhaibao

[+]接口调整

1 parent 3c99e78a
...@@ -3,9 +3,12 @@ package cn.com.glsx.charging.api; ...@@ -3,9 +3,12 @@ package cn.com.glsx.charging.api;
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 com.glsx.plat.core.web.Result; import com.glsx.plat.core.web.Result;
import org.apache.ibatis.annotations.Param;
import org.springframework.cloud.openfeign.FeignClient; import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
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.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
/** /**
* @author payu * @author payu
...@@ -33,14 +36,14 @@ public interface PileControlFeignClient { ...@@ -33,14 +36,14 @@ public interface PileControlFeignClient {
* 三、性能问题 1.Feign是一个http请求调用的轻量级框架,基于http协议,性能不如rpc 2.可以为Feign配置连接池,配合使用okhttp等 * 三、性能问题 1.Feign是一个http请求调用的轻量级框架,基于http协议,性能不如rpc 2.可以为Feign配置连接池,配合使用okhttp等
*/ */
@PostMapping("/start") @GetMapping("/start")
Result<Boolean> start(@RequestBody StartBo startBo); Result<Boolean> start(@RequestParam("requestParam") String json);
@PostMapping("/end") @GetMapping("/end")
Result<Boolean> end(@RequestBody EndBo endBo); Result<Boolean> end(@RequestParam("requestParam") String endBo);
@PostMapping("/pileStart") @GetMapping("/pileStart")
Result<Boolean> pileStart(@RequestBody StartBo startBo); Result<Boolean> pileStart(@RequestParam("requestParam") String startBo);
@PostMapping(value = "/test") @PostMapping(value = "/test")
Result<Boolean> test(); Result<Boolean> test();
......
...@@ -13,14 +13,13 @@ import cn.com.glsx.charging.modules.gbt.ocpp16.tcp.protocol.ShutdownMachineReq; ...@@ -13,14 +13,13 @@ 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.StartMachineReq;
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 com.alibaba.fastjson.JSONObject; 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.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
import java.math.BigDecimal; import java.math.BigDecimal;
import javax.annotation.Resource;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.annotations.Param;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
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.RequestBody;
...@@ -42,32 +41,39 @@ import org.springframework.web.bind.annotation.RestController; ...@@ -42,32 +41,39 @@ import org.springframework.web.bind.annotation.RestController;
public class PileControlApiController implements PileControlFeignClient { public class PileControlApiController implements PileControlFeignClient {
@Override @Override
@PostMapping("/start") @GetMapping("/start")
public Result<Boolean> start(@RequestBody StartBo startBo) { public Result<Boolean> start(@RequestParam("requestParam") String json) {
log.info("启动充电桩请求入参{}", JSONObject.toJSONString(startBo)); try {
StartMachineReq req = new StartMachineReq(); StartBo startBo = JSONObject.parseObject(json, StartBo.class);
StartMachineReqData data = new StartMachineReqData(); log.info("启动充电桩请求入参{}", JSONObject.toJSONString(startBo));
data.setTransactionSerialNumber(Ocpp16Helper.strToBcd(startBo.getTransactionSerialNumber(), StartMachineReq req = new StartMachineReq();
data.getTransactionSerialNumber())); StartMachineReqData data = new StartMachineReqData();
data.setPileId(Ocpp16Helper.strToBcd(startBo.getPileId(), data.getPileId())); data.setTransactionSerialNumber(Ocpp16Helper.strToBcd(startBo.getTransactionSerialNumber(),
data.setGunNumber(startBo.getGunNumber().byteValue()); data.getTransactionSerialNumber()));
data.setLogicalCardNumber( data.setPileId(Ocpp16Helper.strToBcd(startBo.getPileId(), data.getPileId()));
Ocpp16Helper.strToBcd(startBo.getTransactionSerialNumber(), data.getLogicalCardNumber())); data.setGunNumber(startBo.getGunNumber().byteValue());
byte[] bytes = Ocpp16Helper.binToBytes( data.setLogicalCardNumber(
Ocpp16Helper.hexToBinStr(startBo.getPhysicalCardNumber())); Ocpp16Helper.strToBcd(startBo.getTransactionSerialNumber(), data.getLogicalCardNumber()));
data.setPhysicalCardNumber(bytes); byte[] bytes = Ocpp16Helper.binToBytes(
byte[] accountBytes = Ocpp16Helper.bigDecimalToByteArray( Ocpp16Helper.hexToBinStr(startBo.getPhysicalCardNumber()));
BigDecimal.valueOf(startBo.getAccountBalance()), 2); data.setPhysicalCardNumber(bytes);
data.setAccountBalance(accountBytes); byte[] accountBytes = Ocpp16Helper.bigDecimalToByteArray(
req.setData(data); BigDecimal.valueOf(startBo.getAccountBalance()), 2);
TcpCallback<TcpRsp> tcpRspTcpCallback = ServerMain.getServer().sendSync(req); data.setAccountBalance(accountBytes);
TcpRsp tcpRsp = tcpRspTcpCallback.get(); req.setData(data);
return Result.success(true); TcpCallback<TcpRsp> tcpRspTcpCallback = ServerMain.getServer().sendSync(req);
TcpRsp tcpRsp = tcpRspTcpCallback.get();
return Result.success(true);
} catch (Exception e) {
return Result.failure();
}
} }
@Override @Override
@PostMapping("/end") @GetMapping("/end")
public Result<Boolean> end(@RequestBody EndBo endBo) { public Result<Boolean> end(@RequestParam("requestParam") String json) {
EndBo endBo = JSONObject.parseObject(json, EndBo.class);
log.info("停止充电桩请求入参{}", JSONObject.toJSONString(endBo)); log.info("停止充电桩请求入参{}", JSONObject.toJSONString(endBo));
ShutdownMachineReq req = new ShutdownMachineReq(); ShutdownMachineReq req = new ShutdownMachineReq();
ShutdownMachineReqData data = new ShutdownMachineReqData(); ShutdownMachineReqData data = new ShutdownMachineReqData();
...@@ -80,8 +86,9 @@ public class PileControlApiController implements PileControlFeignClient { ...@@ -80,8 +86,9 @@ public class PileControlApiController implements PileControlFeignClient {
} }
@Override @Override
@PostMapping("/pileStart") @GetMapping("/pileStart")
public Result<Boolean> pileStart(@RequestBody StartBo startBo) { public Result<Boolean> pileStart(@RequestParam("requestParam") String json) {
StartBo startBo = JSONObject.parseObject(json, StartBo.class);
AdminSwipeConfirmRsp rsp = new AdminSwipeConfirmRsp(); AdminSwipeConfirmRsp rsp = new AdminSwipeConfirmRsp();
AdminSwipeConfirmRspData data = new AdminSwipeConfirmRspData(); AdminSwipeConfirmRspData data = new AdminSwipeConfirmRspData();
data.setPileId(Ocpp16Helper.strToBcd(startBo.getPileId(), data.getPileId())); data.setPileId(Ocpp16Helper.strToBcd(startBo.getPileId(), data.getPileId()));
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!