cleanup code by sonar

This commit is contained in:
三丙
2024-10-11 15:27:42 +08:00
parent 62a712ea36
commit 22c93292d0
6 changed files with 20 additions and 20 deletions

View File

@@ -57,10 +57,10 @@ public class AbstractYunKuaiChongCmdExe {
return TOP_BYTE;
case PEAK:
return PEAK_BYTE;
case FLAT:
return FLAT_BYTE;
case VALLEY:
return VALLEY_BYTE;
default:
return FLAT_BYTE;
}
}
}

View File

@@ -34,8 +34,8 @@ import static sanbing.jcpp.infrastructure.util.codec.ByteUtil.checkCrcSum;
@Slf4j
public class YunKuaiChongV15ProtocolMessageProcessor extends ProtocolMessageProcessor {
private final Map<Byte, YunKuaiChongUplinkCmdExe> UPLINK_CMD_EXE_MAP = new ConcurrentHashMap<>();
private final Map<Byte, YunKuaiChongDownlinkCmdExe> DOWNLINK_CMD_EXE_MAP = new ConcurrentHashMap<>();
private final Map<Byte, YunKuaiChongUplinkCmdExe> uplinkCmdExeMap = new ConcurrentHashMap<>();
private final Map<Byte, YunKuaiChongDownlinkCmdExe> downlinkCmdExeMap = new ConcurrentHashMap<>();
public YunKuaiChongV15ProtocolMessageProcessor(Forwarder forwarder, ProtocolContext protocolContext) {
super(forwarder, protocolContext);
@@ -46,8 +46,10 @@ public class YunKuaiChongV15ProtocolMessageProcessor extends ProtocolMessageProc
byte cmd = clazz.getAnnotation(YunKuaiChongCmd.class).value();
try {
YunKuaiChongUplinkCmdExe yunKuaiChongUplinkCmdExe = (YunKuaiChongUplinkCmdExe) clazz.getDeclaredConstructor().newInstance();
UPLINK_CMD_EXE_MAP.put(cmd, yunKuaiChongUplinkCmdExe);
} catch (InstantiationException | IllegalAccessException | InvocationTargetException |
uplinkCmdExeMap.put(cmd, yunKuaiChongUplinkCmdExe);
} catch (InstantiationException |
IllegalAccessException |
InvocationTargetException |
NoSuchMethodException e) {
throw new RuntimeException(e);
}
@@ -58,8 +60,10 @@ public class YunKuaiChongV15ProtocolMessageProcessor extends ProtocolMessageProc
byte cmd = clazz.getAnnotation(YunKuaiChongCmd.class).value();
try {
YunKuaiChongDownlinkCmdExe yunKuaiChongDownlinkCmdExe = (YunKuaiChongDownlinkCmdExe) clazz.getDeclaredConstructor().newInstance();
DOWNLINK_CMD_EXE_MAP.put(cmd, yunKuaiChongDownlinkCmdExe);
} catch (InstantiationException | IllegalAccessException | InvocationTargetException |
downlinkCmdExeMap.put(cmd, yunKuaiChongDownlinkCmdExe);
} catch (InstantiationException |
IllegalAccessException |
InvocationTargetException |
NoSuchMethodException e) {
throw new RuntimeException(e);
}
@@ -184,7 +188,7 @@ public class YunKuaiChongV15ProtocolMessageProcessor extends ProtocolMessageProc
}
private void exeCmd(YunKuaiChongUplinkMessage message, TcpSession session) {
YunKuaiChongUplinkCmdExe uplinkCmdExe = UPLINK_CMD_EXE_MAP.get((byte) message.getCmd());
YunKuaiChongUplinkCmdExe uplinkCmdExe = uplinkCmdExeMap.get((byte) message.getCmd());
if (uplinkCmdExe == null) {
@@ -197,7 +201,7 @@ public class YunKuaiChongV15ProtocolMessageProcessor extends ProtocolMessageProc
}
private void exeCmd(YunKuaiChongDwonlinkMessage message, TcpSession session) {
YunKuaiChongDownlinkCmdExe downlinkCmdExe = DOWNLINK_CMD_EXE_MAP.get((byte) message.getCmd());
YunKuaiChongDownlinkCmdExe downlinkCmdExe = downlinkCmdExeMap.get((byte) message.getCmd());
if (downlinkCmdExe == null) {

View File

@@ -44,12 +44,12 @@ public class YunKuaiChongV150BmsHandshakeULCmd extends YunKuaiChongUplinkCmdExe
byte[] pileCodeBytes = new byte[7];
byteBuf.readBytes(pileCodeBytes);
String pileCode = BCDUtil.toString(pileCodeBytes);
additionalInfo.put("桩编号", tradeNo);
additionalInfo.put("桩编号", pileCode);
// 3.抢号
byte gunCodeByte = byteBuf.readByte();
String gunCode = BCDUtil.toString(gunCodeByte);
additionalInfo.put("抢号", tradeNo);
additionalInfo.put("抢号", gunCode);
// 4.BMS 通信协议版本号
byte[] bmsConnectVersionBytes = new byte[3];

View File

@@ -7,7 +7,6 @@ package sanbing.jcpp.protocol.yunkuaichong.v150.cmd;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import lombok.extern.slf4j.Slf4j;
import sanbing.jcpp.infrastructure.util.jackson.JacksonUtil;
import sanbing.jcpp.proto.gen.ProtocolProto.FlagPriceProto;
import sanbing.jcpp.proto.gen.ProtocolProto.PeriodProto;
import sanbing.jcpp.proto.gen.ProtocolProto.PricingModelProto;
@@ -16,7 +15,6 @@ import sanbing.jcpp.protocol.ProtocolContext;
import sanbing.jcpp.protocol.listener.tcp.TcpSession;
import sanbing.jcpp.protocol.yunkuaichong.YunKuaiChongDownlinkCmdExe;
import sanbing.jcpp.protocol.yunkuaichong.YunKuaiChongDwonlinkMessage;
import sanbing.jcpp.protocol.yunkuaichong.YunKuaiChongUplinkMessage;
import sanbing.jcpp.protocol.yunkuaichong.annotation.YunKuaiChongCmd;
import java.math.BigDecimal;
@@ -46,8 +44,6 @@ public class YunKuaiChongV150QueryPricingModelAckDLCmd extends YunKuaiChongDownl
QueryPricingResponse queryPricingResponse = yunKuaiChongDwonlinkMessage.getMsg().getQueryPricingResponse();
YunKuaiChongUplinkMessage requestData = JacksonUtil.fromBytes(yunKuaiChongDwonlinkMessage.getMsg().getRequestData().toByteArray(), YunKuaiChongUplinkMessage.class);
long pricingId = queryPricingResponse.getPricingId();
String pileCode = queryPricingResponse.getPileCode();
PricingModelProto pricingModel = queryPricingResponse.getPricingModel();