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