Commit 40f0e38b by zhouhaibao

[+]新增启动方法

1 parent ef692ee5
......@@ -65,6 +65,7 @@ public class WebConfig implements WebMvcConfigurer {
.excludePathPatterns("/login")
.excludePathPatterns("/actuator/**")
.excludePathPatterns("/api/**")
.excludePathPatterns("/pilecontro/**")
.excludePathPatterns(uploadProperties.getFilepath())
.excludePathPatterns("/swagger-resources/**", "/swagger-ui/**", "/v3/**", "/doc.html");
registry.addInterceptor(logInterceptor).addPathPatterns("/**");
......
package cn.com.glsx.charging.modules.controller;
import cn.com.glsx.charging.modules.BaseController;
import cn.com.glsx.charging.modules.converter.UserConverter;
import cn.com.glsx.charging.modules.entity.User;
import cn.com.glsx.charging.modules.gbt.ocpp16.Ocpp16Helper;
import cn.com.glsx.charging.modules.gbt.ocpp16.ServerMain;
import cn.com.glsx.charging.modules.gbt.ocpp16.tcp.base.TcpCallback;
import cn.com.glsx.charging.modules.gbt.ocpp16.tcp.base.TcpRsp;
import cn.com.glsx.charging.modules.gbt.ocpp16.tcp.client.TcpClient;
import cn.com.glsx.charging.modules.gbt.ocpp16.tcp.data.ShutdownMachineReqData;
import cn.com.glsx.charging.modules.gbt.ocpp16.tcp.data.TransactionRecordsReqData;
import cn.com.glsx.charging.modules.gbt.ocpp16.tcp.protocol.ShutdownMachineReq;
import cn.com.glsx.charging.modules.gbt.ocpp16.tcp.protocol.TransactionRecordsReq;
import cn.com.glsx.charging.modules.gbt.ocpp16.tcp.server.TcpServer;
import cn.com.glsx.charging.modules.model.UserBO;
import cn.com.glsx.charging.modules.model.UserDTO;
import cn.com.glsx.charging.modules.model.UserSearch;
import cn.com.glsx.charging.modules.service.UserDemoService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.glsx.plat.context.utils.validator.AssertUtils;
import com.glsx.plat.core.annotation.ResponseResultBody;
import com.glsx.plat.core.web.R;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
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.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* 单体应用Controller处理统一返回体
*
* @author payu
*/
@Slf4j
@Tag(name = "机器控制(Demo)")
@RestController
@RequestMapping(value = "/pilecontro")
@ResponseResultBody
public class PileControController extends BaseController {
@Operation(summary = "开启充电桩", description = "开启充电桩")
@GetMapping("/start")
public R<Boolean> start(String pileId) {
TransactionRecordsReq req = new TransactionRecordsReq();
TransactionRecordsReqData data = new TransactionRecordsReqData();
data.setTransactionSerialNumber(
Ocpp16Helper.strToBcd("55031412782305012018061910262392",
data.getTransactionSerialNumber()));
data.setGunNumber((byte) 1);
data.setPileId(Ocpp16Helper.strToBcd(pileId, data.getPileId()));
data.setTopUnitPrice(Ocpp16Helper.strToBcd("D0FB0100", data.getTopUnitPrice()));
data.setVehicleIdentifier(
Ocpp16Helper.strToBcd("0000000000000000000000000000000001", data.getVehicleIdentifier()));
req.setData(data);
TcpCallback<TcpRsp> tcpRspTcpCallback = ServerMain.getServer().sendSync(req);
TcpRsp tcpRsp = tcpRspTcpCallback.get();
return R.ok().data(tcpRsp);
}
@Operation(summary = "停止充电桩", description = "停止充电桩")
@GetMapping("/stop")
public R<Boolean> stop(String pileId) {
ShutdownMachineReq req = new ShutdownMachineReq();
ShutdownMachineReqData data = new ShutdownMachineReqData();
data.setGunNumber((byte) 1);
data.setPileId(Ocpp16Helper.strToBcd(pileId, data.getPileId()));
req.setData(data);
TcpCallback<TcpRsp> tcpRspTcpCallback = ServerMain.getServer().sendSync(req);
TcpRsp tcpRsp = tcpRspTcpCallback.get();
return R.ok().data(tcpRsp);
}
}
......@@ -11,6 +11,10 @@ public class ServerMain {
private static Boolean lock = false;
private static TcpServer server;
public static TcpServer getServer() {
return server;
}
public static TcpServer start(String host, int port) {
System.setProperty("file.encoding", "UTF-8");
......
......@@ -25,7 +25,7 @@ spring.cloud.nacos.config.server-addr=192.168.0.63:8868
#示例:http://192.168.0.63:8848/nacos/v1/cs/configs?dataId=glsx-rest-admin.properties&group=DEV_GROUP
#配置分组(改成项目相关的)
spring.cloud.nacos.config.group=ARCHETYPE_GROUP
spring.cloud.nacos.config.group=platform
#配置prefix,默认值同${spring.application.name}
spring.cloud.nacos.config.prefix=${spring.application.name}
#配置环境
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!