update 使用无返回值的发送消息方法

This commit is contained in:
Guoqs
2024-11-28 08:51:55 +08:00
parent e861eec868
commit 117ee42ac0

View File

@@ -64,7 +64,7 @@ public class YKCPushCommandServiceImpl implements YKCPushCommandService {
/**
* 发送消息,无返回值
*/
public void runSend(byte[] msg, String pileSn, Enum<YKCFrameTypeCode> frameTypeCode) throws Exception {
public void runSend(byte[] msg, String pileSn, Enum<YKCFrameTypeCode> frameTypeCode) {
// 通过桩编号获取channel
ChannelHandlerContext ctx = PileChannelEntity.getChannelByPileSn(pileSn);
String value = ((YKCFrameTypeCode) frameTypeCode).getValue(); // 帧类型名称
@@ -73,7 +73,7 @@ public class YKCPushCommandServiceImpl implements YKCPushCommandService {
throw new NullPointerException("channel");
}
if(msg == null) {
throw new NullPointerException("msg");
throw new NullPointerException("发送消息msg为空");
}
/*
@@ -157,7 +157,7 @@ public class YKCPushCommandServiceImpl implements YKCPushCommandService {
throw new NullPointerException("channel");
}
if(msg == null) {
throw new NullPointerException("msg");
throw new NullPointerException("发送消息msg为空");
}
if(timeout <= 0) {
throw new IllegalArgumentException("timeout must greater than 0");
@@ -285,7 +285,7 @@ public class YKCPushCommandServiceImpl implements YKCPushCommandService {
byte[] msgBody = Bytes.concat(orderIdByteArr, pileSnByteArr, connectorCodeByteArr, logicCardNumByteArr, physicsCardNumByteArr, accountBalanceByteArr);
try {
this.supplySend(msgBody, pileSn, YKCFrameTypeCode.REMOTE_CONTROL_START_CHARGING_CODE);
this.runSend(msgBody, pileSn, YKCFrameTypeCode.REMOTE_CONTROL_START_CHARGING_CODE);
} catch (Exception e) {
throw new RuntimeException(e);
}
@@ -306,7 +306,7 @@ public class YKCPushCommandServiceImpl implements YKCPushCommandService {
// 远程停机
byte[] msgBody = Bytes.concat(BytesUtil.str2Bcd(pileSn), BytesUtil.str2Bcd(connectorCode));
try {
this.supplySend(msgBody, pileSn, YKCFrameTypeCode.REMOTE_CONTROL_STOP_CHARGING_CODE);
this.runSend(msgBody, pileSn, YKCFrameTypeCode.REMOTE_CONTROL_STOP_CHARGING_CODE);
} catch (Exception e) {
log.error("发送停止充电 error:", e);
}
@@ -319,7 +319,7 @@ public class YKCPushCommandServiceImpl implements YKCPushCommandService {
String connectorCode = command.getConnectorCode();
byte[] msg = BytesUtil.str2Bcd(pileSn + connectorCode);
try {
this.supplySend(msg, pileSn, YKCFrameTypeCode.READ_REAL_TIME_MONITOR_DATA_CODE);
this.runSend(msg, pileSn, YKCFrameTypeCode.READ_REAL_TIME_MONITOR_DATA_CODE);
} catch (Exception e) {
throw new RuntimeException(e);
}
@@ -332,7 +332,7 @@ public class YKCPushCommandServiceImpl implements YKCPushCommandService {
byte[] msg = BytesUtil.str2Bcd(pileSn + Constants.ZERO_ONE);
log.info("【=====平台下发指令=====】:重启充电桩:,{}", pileSn);
try {
this.supplySend(msg, pileSn, YKCFrameTypeCode.REMOTE_RESTART_CODE);
this.runSend(msg, pileSn, YKCFrameTypeCode.REMOTE_RESTART_CODE);
} catch (Exception e) {
throw new RuntimeException(e);
}
@@ -377,7 +377,7 @@ public class YKCPushCommandServiceImpl implements YKCPushCommandService {
// push消息
try {
this.supplySend(msg, pileSn, YKCFrameTypeCode.REMOTE_ISSUE_QRCODE_CODE);
this.runSend(msg, pileSn, YKCFrameTypeCode.REMOTE_ISSUE_QRCODE_CODE);
} catch (Exception e) {
throw new RuntimeException(e);
}
@@ -403,7 +403,7 @@ public class YKCPushCommandServiceImpl implements YKCPushCommandService {
byte[] msg = Bytes.concat(pileSnByteArr, dateBytes);
try {
this.supplySend(msg, pileSn, YKCFrameTypeCode.TIME_CHECK_SETTING_CODE);
this.runSend(msg, pileSn, YKCFrameTypeCode.TIME_CHECK_SETTING_CODE);
} catch (Exception e) {
throw new RuntimeException(e);
}
@@ -487,7 +487,7 @@ public class YKCPushCommandServiceImpl implements YKCPushCommandService {
updateServerPortByteArr, userNameByteArr, passwordByteArr, filePathByteArr, performTypeByteArr, overTimeByteArr);
try {
this.supplySend(msgBody, pileModelInfoVO.getPileSn(), YKCFrameTypeCode.REMOTE_UPDATE_CODE);
this.runSend(msgBody, pileModelInfoVO.getPileSn(), YKCFrameTypeCode.REMOTE_UPDATE_CODE);
} catch (Exception e) {
throw new RuntimeException(e);
}
@@ -521,7 +521,7 @@ public class YKCPushCommandServiceImpl implements YKCPushCommandService {
byte[] msg = Bytes.concat(pileSnByteArr, workingStateByteArr, maxPowerByteArr);
try {
this.supplySend(msg, pileSn, YKCFrameTypeCode.CHARGING_PILE_WORKING_PARAMETER_SETTING_CODE);
this.runSend(msg, pileSn, YKCFrameTypeCode.CHARGING_PILE_WORKING_PARAMETER_SETTING_CODE);
} catch (Exception e) {
throw new RuntimeException(e);
}
@@ -552,7 +552,7 @@ public class YKCPushCommandServiceImpl implements YKCPushCommandService {
byte[] msg = Bytes.concat(pileSnByteArr, pileType);
try {
this.supplySend(msg, pileSn, YKCFrameTypeCode.QUERY_PILE_WORK_PARAMS_CODE);
this.runSend(msg, pileSn, YKCFrameTypeCode.QUERY_PILE_WORK_PARAMS_CODE);
} catch (Exception e) {
throw new RuntimeException(e);
}
@@ -582,7 +582,7 @@ public class YKCPushCommandServiceImpl implements YKCPushCommandService {
byte[] msg = Bytes.concat(pileSnByteArr, connectorCodeByteArr, logicByteArr, priceByte);
try {
this.supplySend(msg, pileSn, YKCFrameTypeCode.REMOTE_ACCOUNT_BALANCE_UPDATE_CODE);
this.runSend(msg, pileSn, YKCFrameTypeCode.REMOTE_ACCOUNT_BALANCE_UPDATE_CODE);
} catch (Exception e) {
throw new RuntimeException(e);
}
@@ -619,7 +619,7 @@ public class YKCPushCommandServiceImpl implements YKCPushCommandService {
byte[] msg = Bytes.concat(pileSnByteArr, connectorCodeByteArr, operateByteArr, obligateByteArr);
try {
this.supplySend(msg, pileSn, YKCFrameTypeCode.REMOTE_CONTROL_GROUND_LOCK_CODE);
this.runSend(msg, pileSn, YKCFrameTypeCode.REMOTE_CONTROL_GROUND_LOCK_CODE);
} catch (Exception e) {
throw new RuntimeException(e);
}