Commit ebcca57e by zhouhaibao

[+]判空校验

1 parent 2087c3cd
......@@ -37,6 +37,7 @@ import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import java.math.BigDecimal;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
......@@ -195,7 +196,7 @@ public class PileControController extends BaseController {
@Operation(summary = "远程重启", description = "停止充电桩")
@GetMapping("/remoteRestart")
public R<Boolean> remoteRestart(String pileId,byte res) {
public R<Boolean> remoteRestart(String pileId, byte res) {
RemoteRestartReq req = new RemoteRestartReq();
RemoteRestartReqData data = new RemoteRestartReqData();
data.setPileId(Ocpp16Helper.strToBcd(pileId, data.getPileId()));
......@@ -208,19 +209,30 @@ public class PileControController extends BaseController {
@Operation(summary = "远程更新", description = "远程更新")
@GetMapping("/remoteupdate")
public R<Boolean> remoteupdate(String pileId,byte pileModel,BigDecimal pilePower,String upServerAddress,BigDecimal upServerPort
,String userName,String password,String filePath,byte exeControl,byte uploadTimeOut
public R<Boolean> remoteupdate(String pileId, byte pileModel, BigDecimal pilePower,
String upServerAddress, BigDecimal upServerPort
, String userName, String password, String filePath, byte exeControl, byte uploadTimeOut
) {
RemoteUpdateReq req = new RemoteUpdateReq();
RemoteUpdateReqData data = new RemoteUpdateReqData();
data.setPileId(Ocpp16Helper.strToBcd(pileId, data.getPileId()));
data.setPileModel(pileModel);
data.setPilePower(Ocpp16Helper.bigDecimalToByteArray(pilePower, 2));
data.setUpServerAddress(Ocpp16Helper.strToAscii(upServerAddress,data.getUpServerAddress()));
data.setUpServerPort(Ocpp16Helper.bigDecimalToByteArray(upServerPort,2));
data.setUserName(Ocpp16Helper.strToAscii(userName,data.getUserName()));
data.setPassword(Ocpp16Helper.strToAscii(password,data.getPassword()));
data.setFilePath(Ocpp16Helper.strToAscii(filePath,data.getFilePath()));
if (StringUtils.isNotEmpty(upServerAddress)) {
data.setUpServerAddress(Ocpp16Helper.strToAscii(upServerAddress, data.getUpServerAddress()));
}
if (upServerPort != null) {
data.setUpServerPort(Ocpp16Helper.bigDecimalToByteArray(upServerPort, 2));
}
if (StringUtils.isNotEmpty(userName)) {
data.setUserName(Ocpp16Helper.strToAscii(userName, data.getUserName()));
}
if (StringUtils.isNotEmpty(password)) {
data.setPassword(Ocpp16Helper.strToAscii(password, data.getPassword()));
}
if (StringUtils.isNotEmpty(filePath)) {
data.setFilePath(Ocpp16Helper.strToAscii(filePath, data.getFilePath()));
}
data.setExeControl(exeControl);
data.setUploadTimeOut(uploadTimeOut);
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!