From d0260eddc28a8af77321809a0f185f5988fd6962 Mon Sep 17 00:00:00 2001 From: Guoqs <123@jsowell.com> Date: Tue, 26 Nov 2024 11:19:26 +0800 Subject: [PATCH] =?UTF-8?q?update=20=E4=BB=A3=E7=A0=81=E9=87=8D=E6=9E=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../netty/factory/YKCOperateFactoryV2.java | 34 +++-- .../impl/YKCBusinessServiceImpl.java | 7 +- .../ykc/BMSAbortDuringChargingStrategy.java | 11 +- .../BMSDemandAndChargerOutputStrategy.java | 11 +- .../strategy/ykc/BMSInformationStrategy.java | 11 +- .../strategy/ykc/BillingTemplateStrategy.java | 11 +- .../ykc/BillingTemplateValidateStrategy.java | 12 +- .../netty/strategy/ykc/ChargeEndStrategy.java | 10 +- ...gerAbortedDuringChargingPhaseStrategy.java | 11 +- .../ykc/ChargingHandshakeStrategy.java | 11 +- .../ykc/ConfirmStartChargingStrategy.java | 10 +- .../strategy/ykc/ErrorMessageStrategy.java | 11 +- .../ykc/GroundLockDataUploadStrategy.java | 10 +- .../ykc/HeartbeatRequestStrategy.java | 11 +- .../netty/strategy/ykc/LoginStrategy.java | 124 +++++++++--------- .../ykc/OfflineCardDataCleaningStrategy.java | 11 +- .../ykc/OfflineCardDataQueryStrategy.java | 11 +- .../ykc/OfflineCardDataSyncStrategy.java | 11 +- .../strategy/ykc/ParameterConfigStrategy.java | 10 +- .../PileWorkingParameterSettingStrategy.java | 11 +- .../ykc/QueryPileWorkParamsStrategy.java | 11 +- .../ykc/RemoteControlGroundLockStrategy.java | 10 +- .../ykc/RemoteIssuedQrCodeStrategy.java | 11 +- .../strategy/ykc/RemoteRestartStrategy.java | 11 +- .../ykc/RemoteStartChargingStrategy.java | 10 +- .../ykc/RemoteStopChargingStrategy.java | 10 +- .../strategy/ykc/RemoteUpdateStrategy.java | 11 +- ...ervationChargingStartupResultStrategy.java | 11 +- .../ykc/ReservationChargingStrategy.java | 11 +- .../ykc/SettingPileWorkParamsStrategy.java | 11 +- .../ykc/TimeCheckSettingStrategy.java | 10 +- .../ykc/TransactionRecordsStrategy.java | 12 +- .../ykc/UploadRealTimeMonitorStrategy.java | 12 +- 33 files changed, 291 insertions(+), 199 deletions(-) diff --git a/jsowell-netty/src/main/java/com/jsowell/netty/factory/YKCOperateFactoryV2.java b/jsowell-netty/src/main/java/com/jsowell/netty/factory/YKCOperateFactoryV2.java index 2f976f8bd..c8ae77570 100644 --- a/jsowell-netty/src/main/java/com/jsowell/netty/factory/YKCOperateFactoryV2.java +++ b/jsowell-netty/src/main/java/com/jsowell/netty/factory/YKCOperateFactoryV2.java @@ -1,5 +1,7 @@ package com.jsowell.netty.factory; +import com.alibaba.fastjson2.JSON; +import com.jsowell.common.util.StringUtils; import com.jsowell.netty.strategy.ykc.AbstractYkcStrategy; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; @@ -19,24 +21,26 @@ public class YKCOperateFactoryV2 { private static Map operationMap = new HashMap<>(); - static { - //初始化实现类 - operationMap.put("0x01", "loginRequestStrategy"); - operationMap.put("0x05", "billingTemplateValidateRequestStrategy"); - // more operators - } + // static { + // //初始化实现类 + // operationMap.put("0x01", "loginRequestStrategy"); + // operationMap.put("0x05", "billingTemplateValidateRequestStrategy"); + // // more operators + // } /** * 注册 * @param str - * @param handler + * @param strategyName */ - // public void register(String str, AbstractYkcHandlerV2 handler) { - // if (StringUtils.isBlank(str) || Objects.isNull(handler)) { - // return; - // } - // strategyMap.put(str, handler); - // } + public static void register(String str, String strategyName) { + if (StringUtils.isBlank(str) || StringUtils.isBlank(strategyName)) { + return; + } + // 获取首字母(类名首字母大写), 并将首字母变为小写 + strategyName = strategyName.substring(0, 1).toLowerCase() + strategyName.substring(1); + operationMap.put(str, strategyName); + } /** * 获取 @@ -45,4 +49,8 @@ public class YKCOperateFactoryV2 { String s = operationMap.get(frameType); return strategyMap.get(s); } + + public static String getOperationMap() { + return JSON.toJSONString(operationMap); + } } diff --git a/jsowell-netty/src/main/java/com/jsowell/netty/service/yunkuaichong/impl/YKCBusinessServiceImpl.java b/jsowell-netty/src/main/java/com/jsowell/netty/service/yunkuaichong/impl/YKCBusinessServiceImpl.java index 641edecae..4c5e341a8 100644 --- a/jsowell-netty/src/main/java/com/jsowell/netty/service/yunkuaichong/impl/YKCBusinessServiceImpl.java +++ b/jsowell-netty/src/main/java/com/jsowell/netty/service/yunkuaichong/impl/YKCBusinessServiceImpl.java @@ -6,10 +6,9 @@ import com.jsowell.common.enums.ykc.PileChannelEntity; import com.jsowell.common.enums.ykc.PileConnectorDataBaseStatusEnum; import com.jsowell.common.util.StringUtils; import com.jsowell.common.util.YKCUtils; -import com.jsowell.netty.factory.YKCOperateFactory; import com.jsowell.netty.factory.YKCOperateFactoryV2; -import com.jsowell.netty.handler.yunkuaichong.AbstractYkcHandler; import com.jsowell.netty.service.yunkuaichong.YKCBusinessService; +import com.jsowell.netty.strategy.ykc.AbstractYkcStrategy; import com.jsowell.pile.service.OrderBasicInfoService; import com.jsowell.pile.service.PileConnectorInfoService; import com.jsowell.pile.service.PileMsgRecordService; @@ -45,8 +44,8 @@ public class YKCBusinessServiceImpl implements YKCBusinessService { // 获取帧类型 String frameType = YKCUtils.frameType2Str(ykcDataProtocol.getFrameType()); // 获取业务处理handler - AbstractYkcHandler invokeStrategy = YKCOperateFactory.getInvokeStrategy(frameType); - // AbstractYkcHandlerV2 invokeStrategy = ykcOperateFactoryV2.getInvokeStrategy(frameType); + // AbstractYkcHandler invokeStrategy = YKCOperateFactory.getInvokeStrategy(frameType); + AbstractYkcStrategy invokeStrategy = ykcOperateFactoryV2.getInvokeStrategy(frameType); return invokeStrategy.supplyProcess(ykcDataProtocol, ctx); } diff --git a/jsowell-netty/src/main/java/com/jsowell/netty/strategy/ykc/BMSAbortDuringChargingStrategy.java b/jsowell-netty/src/main/java/com/jsowell/netty/strategy/ykc/BMSAbortDuringChargingStrategy.java index baf6b31ef..7ef2fbbf0 100644 --- a/jsowell-netty/src/main/java/com/jsowell/netty/strategy/ykc/BMSAbortDuringChargingStrategy.java +++ b/jsowell-netty/src/main/java/com/jsowell/netty/strategy/ykc/BMSAbortDuringChargingStrategy.java @@ -4,10 +4,13 @@ import com.jsowell.common.core.domain.ykc.YKCDataProtocol; import com.jsowell.common.core.domain.ykc.YKCFrameTypeCode; import com.jsowell.common.util.BytesUtil; import com.jsowell.common.util.YKCUtils; +import com.jsowell.netty.factory.YKCOperateFactoryV2; import io.netty.channel.ChannelHandlerContext; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Component; +import javax.annotation.PostConstruct; + /** * 充电阶段 BMS 中止Handler * @@ -20,10 +23,10 @@ import org.springframework.stereotype.Component; public class BMSAbortDuringChargingStrategy implements AbstractYkcStrategy { private final String type = YKCUtils.frameType2Str(YKCFrameTypeCode.BMS_ABORT_DURING_CHARGING_PHASE_CODE.getBytes()); - // @Override - // public void afterPropertiesSet() throws Exception { - // YKCOperateFactory.register(type, this); - // } + @PostConstruct + public void init() { + YKCOperateFactoryV2.register(type, this.getClass().getSimpleName()); + } @Override public byte[] supplyProcess(YKCDataProtocol ykcDataProtocol, ChannelHandlerContext channel) { diff --git a/jsowell-netty/src/main/java/com/jsowell/netty/strategy/ykc/BMSDemandAndChargerOutputStrategy.java b/jsowell-netty/src/main/java/com/jsowell/netty/strategy/ykc/BMSDemandAndChargerOutputStrategy.java index 95e76cd1b..55d31f603 100644 --- a/jsowell-netty/src/main/java/com/jsowell/netty/strategy/ykc/BMSDemandAndChargerOutputStrategy.java +++ b/jsowell-netty/src/main/java/com/jsowell/netty/strategy/ykc/BMSDemandAndChargerOutputStrategy.java @@ -4,10 +4,13 @@ import com.jsowell.common.core.domain.ykc.YKCDataProtocol; import com.jsowell.common.core.domain.ykc.YKCFrameTypeCode; import com.jsowell.common.util.BytesUtil; import com.jsowell.common.util.YKCUtils; +import com.jsowell.netty.factory.YKCOperateFactoryV2; import io.netty.channel.ChannelHandlerContext; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Component; +import javax.annotation.PostConstruct; + /** * 充电过程 BMS 需求与充电机输出 0x23 * @@ -20,10 +23,10 @@ import org.springframework.stereotype.Component; public class BMSDemandAndChargerOutputStrategy implements AbstractYkcStrategy { private final String type = YKCUtils.frameType2Str(YKCFrameTypeCode.CHARGING_PROCESS_BMS_DEMAND_AND_CHARGER_OUTPUT_CODE.getBytes()); - // @Override - // public void afterPropertiesSet() throws Exception { - // YKCOperateFactory.register(type, this); - // } + @PostConstruct + public void init() { + YKCOperateFactoryV2.register(type, this.getClass().getSimpleName()); + } @Override public byte[] supplyProcess(YKCDataProtocol ykcDataProtocol, ChannelHandlerContext channel) { diff --git a/jsowell-netty/src/main/java/com/jsowell/netty/strategy/ykc/BMSInformationStrategy.java b/jsowell-netty/src/main/java/com/jsowell/netty/strategy/ykc/BMSInformationStrategy.java index c22e2a396..8811a6198 100644 --- a/jsowell-netty/src/main/java/com/jsowell/netty/strategy/ykc/BMSInformationStrategy.java +++ b/jsowell-netty/src/main/java/com/jsowell/netty/strategy/ykc/BMSInformationStrategy.java @@ -4,10 +4,13 @@ import com.jsowell.common.core.domain.ykc.YKCDataProtocol; import com.jsowell.common.core.domain.ykc.YKCFrameTypeCode; import com.jsowell.common.util.BytesUtil; import com.jsowell.common.util.YKCUtils; +import com.jsowell.netty.factory.YKCOperateFactoryV2; import io.netty.channel.ChannelHandlerContext; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Component; +import javax.annotation.PostConstruct; + /** * 充电过程 BMS 信息 0x25 * @@ -20,10 +23,10 @@ import org.springframework.stereotype.Component; public class BMSInformationStrategy implements AbstractYkcStrategy { private final String type = YKCUtils.frameType2Str(YKCFrameTypeCode.CHARGING_PROCESS_BMS_INFORMATION_CODE.getBytes()); - // @Override - // public void afterPropertiesSet() throws Exception { - // YKCOperateFactory.register(type, this); - // } + @PostConstruct + public void init() { + YKCOperateFactoryV2.register(type, this.getClass().getSimpleName()); + } @Override public byte[] supplyProcess(YKCDataProtocol ykcDataProtocol, ChannelHandlerContext channel) { diff --git a/jsowell-netty/src/main/java/com/jsowell/netty/strategy/ykc/BillingTemplateStrategy.java b/jsowell-netty/src/main/java/com/jsowell/netty/strategy/ykc/BillingTemplateStrategy.java index b432322db..2bcded7d9 100644 --- a/jsowell-netty/src/main/java/com/jsowell/netty/strategy/ykc/BillingTemplateStrategy.java +++ b/jsowell-netty/src/main/java/com/jsowell/netty/strategy/ykc/BillingTemplateStrategy.java @@ -4,6 +4,7 @@ import com.jsowell.common.core.domain.ykc.YKCDataProtocol; import com.jsowell.common.core.domain.ykc.YKCFrameTypeCode; import com.jsowell.common.util.BytesUtil; import com.jsowell.common.util.YKCUtils; +import com.jsowell.netty.factory.YKCOperateFactoryV2; import com.jsowell.pile.service.PileBillingTemplateService; import com.jsowell.pile.service.YKCPushCommandService; import com.jsowell.pile.vo.web.BillingTemplateVO; @@ -12,6 +13,8 @@ import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; +import javax.annotation.PostConstruct; + /** * 计费模板请求 Handler * @@ -30,10 +33,10 @@ public class BillingTemplateStrategy implements AbstractYkcStrategy { @Autowired private YKCPushCommandService ykcPushCommandService; - // @Override - // public void afterPropertiesSet() throws Exception { - // YKCOperateFactory.register(type, this); - // } + @PostConstruct + public void init() { + YKCOperateFactoryV2.register(type, this.getClass().getSimpleName()); + } @Override public byte[] supplyProcess(YKCDataProtocol ykcDataProtocol, ChannelHandlerContext ctx) { diff --git a/jsowell-netty/src/main/java/com/jsowell/netty/strategy/ykc/BillingTemplateValidateStrategy.java b/jsowell-netty/src/main/java/com/jsowell/netty/strategy/ykc/BillingTemplateValidateStrategy.java index 9724ed145..139103257 100644 --- a/jsowell-netty/src/main/java/com/jsowell/netty/strategy/ykc/BillingTemplateValidateStrategy.java +++ b/jsowell-netty/src/main/java/com/jsowell/netty/strategy/ykc/BillingTemplateValidateStrategy.java @@ -7,6 +7,7 @@ import com.jsowell.common.core.domain.ykc.YKCDataProtocol; import com.jsowell.common.core.domain.ykc.YKCFrameTypeCode; import com.jsowell.common.util.BytesUtil; import com.jsowell.common.util.YKCUtils; +import com.jsowell.netty.factory.YKCOperateFactoryV2; import com.jsowell.pile.service.PileBillingTemplateService; import com.jsowell.pile.service.YKCPushCommandService; import io.netty.channel.ChannelHandlerContext; @@ -14,6 +15,8 @@ import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import javax.annotation.PostConstruct; + /** * 计费模板验证请求Handler * @@ -32,10 +35,11 @@ public class BillingTemplateValidateStrategy implements AbstractYkcStrategy { @Autowired private YKCPushCommandService ykcPushCommandService; - // @Override - // public void afterPropertiesSet() throws Exception { - // YKCOperateFactory.register(type, this); - // } + @PostConstruct + public void init() { + YKCOperateFactoryV2.register(type, this.getClass().getSimpleName()); + } + @CostTime @Override public byte[] supplyProcess(YKCDataProtocol ykcDataProtocol, ChannelHandlerContext channel) { diff --git a/jsowell-netty/src/main/java/com/jsowell/netty/strategy/ykc/ChargeEndStrategy.java b/jsowell-netty/src/main/java/com/jsowell/netty/strategy/ykc/ChargeEndStrategy.java index a875845ce..2a8561857 100644 --- a/jsowell-netty/src/main/java/com/jsowell/netty/strategy/ykc/ChargeEndStrategy.java +++ b/jsowell-netty/src/main/java/com/jsowell/netty/strategy/ykc/ChargeEndStrategy.java @@ -5,6 +5,7 @@ import com.jsowell.common.core.domain.ykc.YKCFrameTypeCode; import com.jsowell.common.util.BytesUtil; import com.jsowell.common.util.DateUtils; import com.jsowell.common.util.YKCUtils; +import com.jsowell.netty.factory.YKCOperateFactoryV2; import com.jsowell.pile.domain.OrderBasicInfo; import com.jsowell.pile.service.OrderBasicInfoService; import io.netty.channel.ChannelHandlerContext; @@ -12,6 +13,7 @@ import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; +import javax.annotation.PostConstruct; import java.util.Date; import java.util.Objects; @@ -30,10 +32,10 @@ public class ChargeEndStrategy implements AbstractYkcStrategy { @Autowired private OrderBasicInfoService orderBasicInfoService; - // @Override - // public void afterPropertiesSet() throws Exception { - // YKCOperateFactory.register(type, this); - // } + @PostConstruct + public void init() { + YKCOperateFactoryV2.register(type, this.getClass().getSimpleName()); + } @Override public byte[] supplyProcess(YKCDataProtocol ykcDataProtocol, ChannelHandlerContext channel) { diff --git a/jsowell-netty/src/main/java/com/jsowell/netty/strategy/ykc/ChargerAbortedDuringChargingPhaseStrategy.java b/jsowell-netty/src/main/java/com/jsowell/netty/strategy/ykc/ChargerAbortedDuringChargingPhaseStrategy.java index b511d1b61..be9a79ea4 100644 --- a/jsowell-netty/src/main/java/com/jsowell/netty/strategy/ykc/ChargerAbortedDuringChargingPhaseStrategy.java +++ b/jsowell-netty/src/main/java/com/jsowell/netty/strategy/ykc/ChargerAbortedDuringChargingPhaseStrategy.java @@ -4,10 +4,13 @@ import com.jsowell.common.core.domain.ykc.YKCDataProtocol; import com.jsowell.common.core.domain.ykc.YKCFrameTypeCode; import com.jsowell.common.util.BytesUtil; import com.jsowell.common.util.YKCUtils; +import com.jsowell.netty.factory.YKCOperateFactoryV2; import io.netty.channel.ChannelHandlerContext; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Component; +import javax.annotation.PostConstruct; + /** * 充电阶段充电机中止Handler 0x21 * @@ -20,10 +23,10 @@ import org.springframework.stereotype.Component; public class ChargerAbortedDuringChargingPhaseStrategy implements AbstractYkcStrategy { private final String type = YKCUtils.frameType2Str(YKCFrameTypeCode.THE_CHARGER_IS_ABORTED_DURING_THE_CHARGING_PHASE_CODE.getBytes()); - // @Override - // public void afterPropertiesSet() throws Exception { - // YKCOperateFactory.register(type, this); - // } + @PostConstruct + public void init() { + YKCOperateFactoryV2.register(type, this.getClass().getSimpleName()); + } @Override public byte[] supplyProcess(YKCDataProtocol ykcDataProtocol, ChannelHandlerContext channel) { diff --git a/jsowell-netty/src/main/java/com/jsowell/netty/strategy/ykc/ChargingHandshakeStrategy.java b/jsowell-netty/src/main/java/com/jsowell/netty/strategy/ykc/ChargingHandshakeStrategy.java index c75f2d702..a19f4bdf0 100644 --- a/jsowell-netty/src/main/java/com/jsowell/netty/strategy/ykc/ChargingHandshakeStrategy.java +++ b/jsowell-netty/src/main/java/com/jsowell/netty/strategy/ykc/ChargingHandshakeStrategy.java @@ -4,10 +4,13 @@ import com.jsowell.common.core.domain.ykc.YKCDataProtocol; import com.jsowell.common.core.domain.ykc.YKCFrameTypeCode; import com.jsowell.common.util.BytesUtil; import com.jsowell.common.util.YKCUtils; +import com.jsowell.netty.factory.YKCOperateFactoryV2; import io.netty.channel.ChannelHandlerContext; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Component; +import javax.annotation.PostConstruct; + /** * 充电握手 * @@ -20,10 +23,10 @@ import org.springframework.stereotype.Component; public class ChargingHandshakeStrategy implements AbstractYkcStrategy { private final String type = YKCUtils.frameType2Str(YKCFrameTypeCode.CHARGING_HANDSHAKE_CODE.getBytes()); - // @Override - // public void afterPropertiesSet() throws Exception { - // YKCOperateFactory.register(type, this); - // } + @PostConstruct + public void init() { + YKCOperateFactoryV2.register(type, this.getClass().getSimpleName()); + } @Override public byte[] supplyProcess(YKCDataProtocol ykcDataProtocol, ChannelHandlerContext channel) { diff --git a/jsowell-netty/src/main/java/com/jsowell/netty/strategy/ykc/ConfirmStartChargingStrategy.java b/jsowell-netty/src/main/java/com/jsowell/netty/strategy/ykc/ConfirmStartChargingStrategy.java index c901b159d..3a18a3a29 100644 --- a/jsowell-netty/src/main/java/com/jsowell/netty/strategy/ykc/ConfirmStartChargingStrategy.java +++ b/jsowell-netty/src/main/java/com/jsowell/netty/strategy/ykc/ConfirmStartChargingStrategy.java @@ -12,6 +12,7 @@ import com.jsowell.common.exception.BusinessException; import com.jsowell.common.util.BytesUtil; import com.jsowell.common.util.StringUtils; import com.jsowell.common.util.YKCUtils; +import com.jsowell.netty.factory.YKCOperateFactoryV2; import com.jsowell.pile.domain.MemberPlateNumberRelation; import com.jsowell.pile.domain.PileAuthCard; import com.jsowell.pile.dto.ConfirmStartChargingData; @@ -25,6 +26,7 @@ import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; +import javax.annotation.PostConstruct; import java.util.Arrays; import java.util.Map; @@ -52,10 +54,10 @@ public class ConfirmStartChargingStrategy implements AbstractYkcStrategy { @Autowired private PileMsgRecordService pileMsgRecordService; - // @Override - // public void afterPropertiesSet() throws Exception { - // YKCOperateFactory.register(type, this); - // } + @PostConstruct + public void init() { + YKCOperateFactoryV2.register(type, this.getClass().getSimpleName()); + } @Override public byte[] supplyProcess(YKCDataProtocol ykcDataProtocol, ChannelHandlerContext channel) { diff --git a/jsowell-netty/src/main/java/com/jsowell/netty/strategy/ykc/ErrorMessageStrategy.java b/jsowell-netty/src/main/java/com/jsowell/netty/strategy/ykc/ErrorMessageStrategy.java index d4c76f349..efacb006d 100644 --- a/jsowell-netty/src/main/java/com/jsowell/netty/strategy/ykc/ErrorMessageStrategy.java +++ b/jsowell-netty/src/main/java/com/jsowell/netty/strategy/ykc/ErrorMessageStrategy.java @@ -4,10 +4,13 @@ import com.jsowell.common.core.domain.ykc.YKCDataProtocol; import com.jsowell.common.core.domain.ykc.YKCFrameTypeCode; import com.jsowell.common.util.BytesUtil; import com.jsowell.common.util.YKCUtils; +import com.jsowell.netty.factory.YKCOperateFactoryV2; import io.netty.channel.ChannelHandlerContext; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Component; +import javax.annotation.PostConstruct; + /** * 错误报文Handler * @@ -20,10 +23,10 @@ import org.springframework.stereotype.Component; public class ErrorMessageStrategy implements AbstractYkcStrategy { private final String type = YKCUtils.frameType2Str(YKCFrameTypeCode.ERROR_MESSAGE_CODE.getBytes()); - // @Override - // public void afterPropertiesSet() throws Exception { - // YKCOperateFactory.register(type, this); - // } + @PostConstruct + public void init() { + YKCOperateFactoryV2.register(type, this.getClass().getSimpleName()); + } @Override public byte[] supplyProcess(YKCDataProtocol ykcDataProtocol, ChannelHandlerContext channel) { diff --git a/jsowell-netty/src/main/java/com/jsowell/netty/strategy/ykc/GroundLockDataUploadStrategy.java b/jsowell-netty/src/main/java/com/jsowell/netty/strategy/ykc/GroundLockDataUploadStrategy.java index e217b7a34..429e5d247 100644 --- a/jsowell-netty/src/main/java/com/jsowell/netty/strategy/ykc/GroundLockDataUploadStrategy.java +++ b/jsowell-netty/src/main/java/com/jsowell/netty/strategy/ykc/GroundLockDataUploadStrategy.java @@ -15,6 +15,7 @@ import com.jsowell.common.util.BytesUtil; import com.jsowell.common.util.DateUtils; import com.jsowell.common.util.StringUtils; import com.jsowell.common.util.YKCUtils; +import com.jsowell.netty.factory.YKCOperateFactoryV2; import com.jsowell.pile.domain.OrderPileOccupy; import com.jsowell.pile.service.OrderPileOccupyService; import io.netty.channel.ChannelHandlerContext; @@ -22,6 +23,7 @@ import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; +import javax.annotation.PostConstruct; import java.util.Locale; import java.util.Objects; @@ -44,10 +46,10 @@ public class GroundLockDataUploadStrategy implements AbstractYkcStrategy { private final String type = YKCUtils.frameType2Str(YKCFrameTypeCode.GROUND_LOCK_DATA_UPLOAD_CODE.getBytes()); - // @Override - // public void afterPropertiesSet() throws Exception { - // YKCOperateFactory.register(type, this); - // } + @PostConstruct + public void init() { + YKCOperateFactoryV2.register(type, this.getClass().getSimpleName()); + } @Override public byte[] supplyProcess(YKCDataProtocol ykcDataProtocol, ChannelHandlerContext channel) { diff --git a/jsowell-netty/src/main/java/com/jsowell/netty/strategy/ykc/HeartbeatRequestStrategy.java b/jsowell-netty/src/main/java/com/jsowell/netty/strategy/ykc/HeartbeatRequestStrategy.java index 6dce478da..3ef37a297 100644 --- a/jsowell-netty/src/main/java/com/jsowell/netty/strategy/ykc/HeartbeatRequestStrategy.java +++ b/jsowell-netty/src/main/java/com/jsowell/netty/strategy/ykc/HeartbeatRequestStrategy.java @@ -6,12 +6,15 @@ import com.jsowell.common.core.domain.ykc.YKCDataProtocol; import com.jsowell.common.core.domain.ykc.YKCFrameTypeCode; import com.jsowell.common.util.BytesUtil; import com.jsowell.common.util.YKCUtils; +import com.jsowell.netty.factory.YKCOperateFactoryV2; import com.jsowell.pile.service.PileBasicInfoService; import io.netty.channel.ChannelHandlerContext; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; +import javax.annotation.PostConstruct; + /** * 充电桩心跳包 */ @@ -24,10 +27,10 @@ public class HeartbeatRequestStrategy implements AbstractYkcStrategy { @Autowired private PileBasicInfoService pileBasicInfoService; - // @Override - // public void afterPropertiesSet() throws Exception { - // YKCOperateFactory.register(type, this); - // } + @PostConstruct + public void init() { + YKCOperateFactoryV2.register(type, this.getClass().getSimpleName()); + } @Override public byte[] supplyProcess(YKCDataProtocol ykcDataProtocol, ChannelHandlerContext channel) { diff --git a/jsowell-netty/src/main/java/com/jsowell/netty/strategy/ykc/LoginStrategy.java b/jsowell-netty/src/main/java/com/jsowell/netty/strategy/ykc/LoginStrategy.java index b64ae0ddf..c998a7721 100644 --- a/jsowell-netty/src/main/java/com/jsowell/netty/strategy/ykc/LoginStrategy.java +++ b/jsowell-netty/src/main/java/com/jsowell/netty/strategy/ykc/LoginStrategy.java @@ -12,6 +12,7 @@ import com.jsowell.common.util.BytesUtil; import com.jsowell.common.util.StringUtils; import com.jsowell.common.util.YKCUtils; import com.jsowell.common.util.spring.SpringUtils; +import com.jsowell.netty.factory.YKCOperateFactoryV2; import com.jsowell.pile.domain.PileBasicInfo; import com.jsowell.pile.domain.ykcCommond.IssueQRCodeCommand; import com.jsowell.pile.domain.ykcCommond.ProofreadTimeCommand; @@ -27,6 +28,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; import org.springframework.stereotype.Service; +import javax.annotation.PostConstruct; import java.math.BigDecimal; import java.util.List; import java.util.concurrent.CompletableFuture; @@ -53,68 +55,70 @@ public class LoginStrategy implements AbstractYkcStrategy { // 引入线程池 private ThreadPoolTaskExecutor executor = SpringUtils.getBean("threadPoolTaskExecutor"); - // @Override - // public void afterPropertiesSet() throws Exception { - // YKCOperateFactory.register(type, this); - // } - - public static void main(String[] args) { - String msg = "8800000000009000020f56312e323035303000898604940121c138531304"; - byte[] msgBody = BytesUtil.str2Bcd(msg); - - int startIndex = 0; - int length = 7; - - // 桩编码 - byte[] pileSnByte = BytesUtil.copyBytes(msgBody, startIndex, length); - String pileSn = BytesUtil.binary(pileSnByte, 16); - // log.info("桩号:{}", pileSn); - - // 桩类型 0 表示直流桩, 1 表示交流桩 - startIndex += length; - length = 1; - byte[] pileTypeByteArr = BytesUtil.copyBytes(msgBody, startIndex, length); - String pileType = BytesUtil.bcd2Str(pileTypeByteArr); - - // 充电枪数量 - startIndex += length; - byte[] connectorNumByteArr = BytesUtil.copyBytes(msgBody, startIndex, length); - String connectorNum = BytesUtil.bcd2Str(connectorNumByteArr); - - // 通信协议版本 版本号乘 10,v1.0 表示 0x0A - startIndex += length; - byte[] communicationVersionByteArr = BytesUtil.copyBytes(msgBody, startIndex, length); - // int i = Integer.parseInt(BytesUtil.bcd2Str(communicationVersionByteArr)); // 0F --> 15 - BigDecimal bigDecimal = new BigDecimal(BytesUtil.bcd2Str(communicationVersionByteArr)); - BigDecimal communicationVersionTemp = bigDecimal.divide(new BigDecimal(10)); - String communicationVersion = "v" + communicationVersionTemp; - - // 程序版本 - startIndex += length; - length = 8; - byte[] programVersionByteArr = BytesUtil.copyBytes(msgBody, startIndex, length); - String programVersion = BytesUtil.ascii2Str(programVersionByteArr); - log.info("程序版本:{} length:{}", programVersion, programVersion.length()); - - // 网络连接类型 0x00 SIM 卡 0x01 LAN 0x02 WAN 0x03 其他 - startIndex += length; - length = 1; - byte[] internetConnectionTypeByteArr = BytesUtil.copyBytes(msgBody, startIndex, length); - String internetConnection = BytesUtil.bcd2Str(internetConnectionTypeByteArr); - - // sim卡 - startIndex += length; - length = 10; - byte[] simCardNumByteArr = BytesUtil.copyBytes(msgBody, startIndex, length); - String iccid = BytesUtil.bin2HexStr(simCardNumByteArr); - - // 运营商 0x00 移动 0x02 电信 0x03 联通 0x04 其他 - startIndex += length; - length = 1; - byte[] businessTypeByteArr = BytesUtil.copyBytes(msgBody, startIndex, length); - String business = BytesUtil.bcd2Str(businessTypeByteArr); + @PostConstruct + public void init() { + log.info("类名:{}", this.getClass().getSimpleName()); + YKCOperateFactoryV2.register(type, this.getClass().getSimpleName()); + log.info("注册成功, operationMap:{}", YKCOperateFactoryV2.getOperationMap()); } + // public static void main(String[] args) { + // String msg = "8800000000009000020f56312e323035303000898604940121c138531304"; + // byte[] msgBody = BytesUtil.str2Bcd(msg); + // + // int startIndex = 0; + // int length = 7; + // + // // 桩编码 + // byte[] pileSnByte = BytesUtil.copyBytes(msgBody, startIndex, length); + // String pileSn = BytesUtil.binary(pileSnByte, 16); + // // log.info("桩号:{}", pileSn); + // + // // 桩类型 0 表示直流桩, 1 表示交流桩 + // startIndex += length; + // length = 1; + // byte[] pileTypeByteArr = BytesUtil.copyBytes(msgBody, startIndex, length); + // String pileType = BytesUtil.bcd2Str(pileTypeByteArr); + // + // // 充电枪数量 + // startIndex += length; + // byte[] connectorNumByteArr = BytesUtil.copyBytes(msgBody, startIndex, length); + // String connectorNum = BytesUtil.bcd2Str(connectorNumByteArr); + // + // // 通信协议版本 版本号乘 10,v1.0 表示 0x0A + // startIndex += length; + // byte[] communicationVersionByteArr = BytesUtil.copyBytes(msgBody, startIndex, length); + // // int i = Integer.parseInt(BytesUtil.bcd2Str(communicationVersionByteArr)); // 0F --> 15 + // BigDecimal bigDecimal = new BigDecimal(BytesUtil.bcd2Str(communicationVersionByteArr)); + // BigDecimal communicationVersionTemp = bigDecimal.divide(new BigDecimal(10)); + // String communicationVersion = "v" + communicationVersionTemp; + // + // // 程序版本 + // startIndex += length; + // length = 8; + // byte[] programVersionByteArr = BytesUtil.copyBytes(msgBody, startIndex, length); + // String programVersion = BytesUtil.ascii2Str(programVersionByteArr); + // log.info("程序版本:{} length:{}", programVersion, programVersion.length()); + // + // // 网络连接类型 0x00 SIM 卡 0x01 LAN 0x02 WAN 0x03 其他 + // startIndex += length; + // length = 1; + // byte[] internetConnectionTypeByteArr = BytesUtil.copyBytes(msgBody, startIndex, length); + // String internetConnection = BytesUtil.bcd2Str(internetConnectionTypeByteArr); + // + // // sim卡 + // startIndex += length; + // length = 10; + // byte[] simCardNumByteArr = BytesUtil.copyBytes(msgBody, startIndex, length); + // String iccid = BytesUtil.bin2HexStr(simCardNumByteArr); + // + // // 运营商 0x00 移动 0x02 电信 0x03 联通 0x04 其他 + // startIndex += length; + // length = 1; + // byte[] businessTypeByteArr = BytesUtil.copyBytes(msgBody, startIndex, length); + // String business = BytesUtil.bcd2Str(businessTypeByteArr); + // } + @CostTime @Override public byte[] supplyProcess(YKCDataProtocol ykcDataProtocol, ChannelHandlerContext ctx) { diff --git a/jsowell-netty/src/main/java/com/jsowell/netty/strategy/ykc/OfflineCardDataCleaningStrategy.java b/jsowell-netty/src/main/java/com/jsowell/netty/strategy/ykc/OfflineCardDataCleaningStrategy.java index ff31f28b4..d630f8ec4 100644 --- a/jsowell-netty/src/main/java/com/jsowell/netty/strategy/ykc/OfflineCardDataCleaningStrategy.java +++ b/jsowell-netty/src/main/java/com/jsowell/netty/strategy/ykc/OfflineCardDataCleaningStrategy.java @@ -4,10 +4,13 @@ import com.jsowell.common.core.domain.ykc.YKCDataProtocol; import com.jsowell.common.core.domain.ykc.YKCFrameTypeCode; import com.jsowell.common.util.BytesUtil; import com.jsowell.common.util.YKCUtils; +import com.jsowell.netty.factory.YKCOperateFactoryV2; import io.netty.channel.ChannelHandlerContext; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Component; +import javax.annotation.PostConstruct; + /** * 离线卡数据清除应答 * @@ -19,10 +22,10 @@ import org.springframework.stereotype.Component; public class OfflineCardDataCleaningStrategy implements AbstractYkcStrategy { private final String type = YKCUtils.frameType2Str(YKCFrameTypeCode.OFFLINE_CARD_DATA_CLEANING_ANSWER_CODE.getBytes()); - // @Override - // public void afterPropertiesSet() throws Exception { - // YKCOperateFactory.register(type, this); - // } + @PostConstruct + public void init() { + YKCOperateFactoryV2.register(type, this.getClass().getSimpleName()); + } @Override public byte[] supplyProcess(YKCDataProtocol ykcDataProtocol, ChannelHandlerContext channel) { diff --git a/jsowell-netty/src/main/java/com/jsowell/netty/strategy/ykc/OfflineCardDataQueryStrategy.java b/jsowell-netty/src/main/java/com/jsowell/netty/strategy/ykc/OfflineCardDataQueryStrategy.java index 3d61cd2cf..d0defc20f 100644 --- a/jsowell-netty/src/main/java/com/jsowell/netty/strategy/ykc/OfflineCardDataQueryStrategy.java +++ b/jsowell-netty/src/main/java/com/jsowell/netty/strategy/ykc/OfflineCardDataQueryStrategy.java @@ -4,10 +4,13 @@ import com.jsowell.common.core.domain.ykc.YKCDataProtocol; import com.jsowell.common.core.domain.ykc.YKCFrameTypeCode; import com.jsowell.common.util.BytesUtil; import com.jsowell.common.util.YKCUtils; +import com.jsowell.netty.factory.YKCOperateFactoryV2; import io.netty.channel.ChannelHandlerContext; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Component; +import javax.annotation.PostConstruct; + /** * 离线卡数据查询应答 * @@ -19,10 +22,10 @@ import org.springframework.stereotype.Component; public class OfflineCardDataQueryStrategy implements AbstractYkcStrategy { private final String type = YKCUtils.frameType2Str(YKCFrameTypeCode.OFFLINE_CARD_DATA_QUERY_ANSWER_CODE.getBytes()); - // @Override - // public void afterPropertiesSet() throws Exception { - // YKCOperateFactory.register(type, this); - // } + @PostConstruct + public void init() { + YKCOperateFactoryV2.register(type, this.getClass().getSimpleName()); + } @Override public byte[] supplyProcess(YKCDataProtocol ykcDataProtocol, ChannelHandlerContext channel) { diff --git a/jsowell-netty/src/main/java/com/jsowell/netty/strategy/ykc/OfflineCardDataSyncStrategy.java b/jsowell-netty/src/main/java/com/jsowell/netty/strategy/ykc/OfflineCardDataSyncStrategy.java index d2e94f2e7..b886db88b 100644 --- a/jsowell-netty/src/main/java/com/jsowell/netty/strategy/ykc/OfflineCardDataSyncStrategy.java +++ b/jsowell-netty/src/main/java/com/jsowell/netty/strategy/ykc/OfflineCardDataSyncStrategy.java @@ -4,10 +4,13 @@ import com.jsowell.common.core.domain.ykc.YKCDataProtocol; import com.jsowell.common.core.domain.ykc.YKCFrameTypeCode; import com.jsowell.common.util.BytesUtil; import com.jsowell.common.util.YKCUtils; +import com.jsowell.netty.factory.YKCOperateFactoryV2; import io.netty.channel.ChannelHandlerContext; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Component; +import javax.annotation.PostConstruct; + /** * 离线卡数据同步应答 * @@ -19,10 +22,10 @@ import org.springframework.stereotype.Component; public class OfflineCardDataSyncStrategy implements AbstractYkcStrategy { private final String type = YKCUtils.frameType2Str(YKCFrameTypeCode.OFFLINE_CARD_DATA_SYNCHRONIZATION_ANSWER_CODE.getBytes()); - // @Override - // public void afterPropertiesSet() throws Exception { - // YKCOperateFactory.register(type, this); - // } + @PostConstruct + public void init() { + YKCOperateFactoryV2.register(type, this.getClass().getSimpleName()); + } @Override public byte[] supplyProcess(YKCDataProtocol ykcDataProtocol, ChannelHandlerContext channel) { diff --git a/jsowell-netty/src/main/java/com/jsowell/netty/strategy/ykc/ParameterConfigStrategy.java b/jsowell-netty/src/main/java/com/jsowell/netty/strategy/ykc/ParameterConfigStrategy.java index 0cc18fdaf..6958c1410 100644 --- a/jsowell-netty/src/main/java/com/jsowell/netty/strategy/ykc/ParameterConfigStrategy.java +++ b/jsowell-netty/src/main/java/com/jsowell/netty/strategy/ykc/ParameterConfigStrategy.java @@ -4,6 +4,7 @@ import com.jsowell.common.core.domain.ykc.YKCDataProtocol; import com.jsowell.common.core.domain.ykc.YKCFrameTypeCode; import com.jsowell.common.util.BytesUtil; import com.jsowell.common.util.YKCUtils; +import com.jsowell.netty.factory.YKCOperateFactoryV2; import com.jsowell.pile.domain.OrderBasicInfo; import com.jsowell.pile.service.OrderBasicInfoService; import io.netty.channel.ChannelHandlerContext; @@ -11,6 +12,7 @@ import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; +import javax.annotation.PostConstruct; import java.util.Objects; /** @@ -28,10 +30,10 @@ public class ParameterConfigStrategy implements AbstractYkcStrategy { private final String type = YKCUtils.frameType2Str(YKCFrameTypeCode.PARAMETER_CONFIGURATION_CODE.getBytes()); - // @Override - // public void afterPropertiesSet() throws Exception { - // YKCOperateFactory.register(type, this); - // } + @PostConstruct + public void init() { + YKCOperateFactoryV2.register(type, this.getClass().getSimpleName()); + } @Override public byte[] supplyProcess(YKCDataProtocol ykcDataProtocol, ChannelHandlerContext channel) { diff --git a/jsowell-netty/src/main/java/com/jsowell/netty/strategy/ykc/PileWorkingParameterSettingStrategy.java b/jsowell-netty/src/main/java/com/jsowell/netty/strategy/ykc/PileWorkingParameterSettingStrategy.java index 3a2a815af..6d244ddc9 100644 --- a/jsowell-netty/src/main/java/com/jsowell/netty/strategy/ykc/PileWorkingParameterSettingStrategy.java +++ b/jsowell-netty/src/main/java/com/jsowell/netty/strategy/ykc/PileWorkingParameterSettingStrategy.java @@ -4,10 +4,13 @@ import com.jsowell.common.core.domain.ykc.YKCDataProtocol; import com.jsowell.common.core.domain.ykc.YKCFrameTypeCode; import com.jsowell.common.util.BytesUtil; import com.jsowell.common.util.YKCUtils; +import com.jsowell.netty.factory.YKCOperateFactoryV2; import io.netty.channel.ChannelHandlerContext; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Component; +import javax.annotation.PostConstruct; + /** * 充电桩工作参数设置应答 * @@ -19,10 +22,10 @@ import org.springframework.stereotype.Component; public class PileWorkingParameterSettingStrategy implements AbstractYkcStrategy { private final String type = YKCUtils.frameType2Str(YKCFrameTypeCode.CHARGING_PILE_WORKING_PARAMETER_SETTING_ANSWER_CODE.getBytes()); - // @Override - // public void afterPropertiesSet() throws Exception { - // YKCOperateFactory.register(type, this); - // } + @PostConstruct + public void init() { + YKCOperateFactoryV2.register(type, this.getClass().getSimpleName()); + } @Override public byte[] supplyProcess(YKCDataProtocol ykcDataProtocol, ChannelHandlerContext channel) { diff --git a/jsowell-netty/src/main/java/com/jsowell/netty/strategy/ykc/QueryPileWorkParamsStrategy.java b/jsowell-netty/src/main/java/com/jsowell/netty/strategy/ykc/QueryPileWorkParamsStrategy.java index 30679a458..7e8b4c4e3 100644 --- a/jsowell-netty/src/main/java/com/jsowell/netty/strategy/ykc/QueryPileWorkParamsStrategy.java +++ b/jsowell-netty/src/main/java/com/jsowell/netty/strategy/ykc/QueryPileWorkParamsStrategy.java @@ -4,10 +4,13 @@ import com.jsowell.common.core.domain.ykc.YKCDataProtocol; import com.jsowell.common.core.domain.ykc.YKCFrameTypeCode; import com.jsowell.common.util.BytesUtil; import com.jsowell.common.util.YKCUtils; +import com.jsowell.netty.factory.YKCOperateFactoryV2; import io.netty.channel.ChannelHandlerContext; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Component; +import javax.annotation.PostConstruct; + /** * 0x27 充电桩査询工作参数回复 * @@ -19,10 +22,10 @@ import org.springframework.stereotype.Component; public class QueryPileWorkParamsStrategy implements AbstractYkcStrategy { private final String type = YKCUtils.frameType2Str(YKCFrameTypeCode.QUERY_PILE_WORK_PARAMS_ANSWER_CODE.getBytes()); - // @Override - // public void afterPropertiesSet() throws Exception { - // YKCOperateFactory.register(type, this); - // } + @PostConstruct + public void init() { + YKCOperateFactoryV2.register(type, this.getClass().getSimpleName()); + } @Override public byte[] supplyProcess(YKCDataProtocol ykcDataProtocol, ChannelHandlerContext channel) { diff --git a/jsowell-netty/src/main/java/com/jsowell/netty/strategy/ykc/RemoteControlGroundLockStrategy.java b/jsowell-netty/src/main/java/com/jsowell/netty/strategy/ykc/RemoteControlGroundLockStrategy.java index 8cefb0668..81e1e3f5e 100644 --- a/jsowell-netty/src/main/java/com/jsowell/netty/strategy/ykc/RemoteControlGroundLockStrategy.java +++ b/jsowell-netty/src/main/java/com/jsowell/netty/strategy/ykc/RemoteControlGroundLockStrategy.java @@ -4,12 +4,14 @@ import com.jsowell.common.core.domain.ykc.YKCDataProtocol; import com.jsowell.common.core.domain.ykc.YKCFrameTypeCode; import com.jsowell.common.util.BytesUtil; import com.jsowell.common.util.YKCUtils; +import com.jsowell.netty.factory.YKCOperateFactoryV2; import com.jsowell.pile.service.OrderPileOccupyService; import io.netty.channel.ChannelHandlerContext; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; +import javax.annotation.PostConstruct; import java.util.Locale; /** @@ -27,10 +29,10 @@ public class RemoteControlGroundLockStrategy implements AbstractYkcStrategy { private final String type = YKCUtils.frameType2Str(YKCFrameTypeCode.REMOTE_CONTROL_GROUND_LOCK_ANSWER_CODE.getBytes()); - // @Override - // public void afterPropertiesSet() throws Exception { - // YKCOperateFactory.register(type, this); - // } + @PostConstruct + public void init() { + YKCOperateFactoryV2.register(type, this.getClass().getSimpleName()); + } @Override public byte[] supplyProcess(YKCDataProtocol ykcDataProtocol, ChannelHandlerContext channel) { diff --git a/jsowell-netty/src/main/java/com/jsowell/netty/strategy/ykc/RemoteIssuedQrCodeStrategy.java b/jsowell-netty/src/main/java/com/jsowell/netty/strategy/ykc/RemoteIssuedQrCodeStrategy.java index abf8e2568..5be265a5f 100644 --- a/jsowell-netty/src/main/java/com/jsowell/netty/strategy/ykc/RemoteIssuedQrCodeStrategy.java +++ b/jsowell-netty/src/main/java/com/jsowell/netty/strategy/ykc/RemoteIssuedQrCodeStrategy.java @@ -4,10 +4,13 @@ import com.jsowell.common.core.domain.ykc.YKCDataProtocol; import com.jsowell.common.core.domain.ykc.YKCFrameTypeCode; import com.jsowell.common.util.BytesUtil; import com.jsowell.common.util.YKCUtils; +import com.jsowell.netty.factory.YKCOperateFactoryV2; import io.netty.channel.ChannelHandlerContext; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Component; +import javax.annotation.PostConstruct; + /** * 桩应答远程下发二维码前缀指令 * @@ -19,10 +22,10 @@ import org.springframework.stereotype.Component; public class RemoteIssuedQrCodeStrategy implements AbstractYkcStrategy { private final String type = YKCUtils.frameType2Str(YKCFrameTypeCode.REMOTE_ISSUE_QRCODE_ANSWER_CODE.getBytes()); - // @Override - // public void afterPropertiesSet() throws Exception { - // YKCOperateFactory.register(type, this); - // } + @PostConstruct + public void init() { + YKCOperateFactoryV2.register(type, this.getClass().getSimpleName()); + } @Override public byte[] supplyProcess(YKCDataProtocol ykcDataProtocol, ChannelHandlerContext channel) { diff --git a/jsowell-netty/src/main/java/com/jsowell/netty/strategy/ykc/RemoteRestartStrategy.java b/jsowell-netty/src/main/java/com/jsowell/netty/strategy/ykc/RemoteRestartStrategy.java index e25a3eec5..f91e31984 100644 --- a/jsowell-netty/src/main/java/com/jsowell/netty/strategy/ykc/RemoteRestartStrategy.java +++ b/jsowell-netty/src/main/java/com/jsowell/netty/strategy/ykc/RemoteRestartStrategy.java @@ -5,12 +5,15 @@ import com.jsowell.common.core.domain.ykc.YKCDataProtocol; import com.jsowell.common.core.domain.ykc.YKCFrameTypeCode; import com.jsowell.common.util.BytesUtil; import com.jsowell.common.util.YKCUtils; +import com.jsowell.netty.factory.YKCOperateFactoryV2; import com.jsowell.pile.service.PileMsgRecordService; import io.netty.channel.ChannelHandlerContext; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; +import javax.annotation.PostConstruct; + /** * 远程重启应答 * @@ -25,10 +28,10 @@ public class RemoteRestartStrategy implements AbstractYkcStrategy { @Autowired private PileMsgRecordService pileMsgRecordService; - // @Override - // public void afterPropertiesSet() throws Exception { - // YKCOperateFactory.register(type, this); - // } + @PostConstruct + public void init() { + YKCOperateFactoryV2.register(type, this.getClass().getSimpleName()); + } @Override public byte[] supplyProcess(YKCDataProtocol ykcDataProtocol, ChannelHandlerContext channel) { diff --git a/jsowell-netty/src/main/java/com/jsowell/netty/strategy/ykc/RemoteStartChargingStrategy.java b/jsowell-netty/src/main/java/com/jsowell/netty/strategy/ykc/RemoteStartChargingStrategy.java index 07881d457..0a479dc79 100644 --- a/jsowell-netty/src/main/java/com/jsowell/netty/strategy/ykc/RemoteStartChargingStrategy.java +++ b/jsowell-netty/src/main/java/com/jsowell/netty/strategy/ykc/RemoteStartChargingStrategy.java @@ -8,6 +8,7 @@ import com.jsowell.common.util.BytesUtil; import com.jsowell.common.util.StringUtils; import com.jsowell.common.util.YKCUtils; import com.jsowell.common.util.spring.SpringUtils; +import com.jsowell.netty.factory.YKCOperateFactoryV2; import com.jsowell.pile.domain.OrderBasicInfo; import com.jsowell.pile.service.OrderBasicInfoService; import com.jsowell.thirdparty.common.CommonService; @@ -17,6 +18,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; import org.springframework.stereotype.Component; +import javax.annotation.PostConstruct; import java.util.concurrent.CompletableFuture; /** @@ -39,10 +41,10 @@ public class RemoteStartChargingStrategy implements AbstractYkcStrategy { // 引入线程池 private ThreadPoolTaskExecutor executor = SpringUtils.getBean("threadPoolTaskExecutor"); - // @Override - // public void afterPropertiesSet() throws Exception { - // YKCOperateFactory.register(type, this); - // } + @PostConstruct + public void init() { + YKCOperateFactoryV2.register(type, this.getClass().getSimpleName()); + } @Override public byte[] supplyProcess(YKCDataProtocol ykcDataProtocol, ChannelHandlerContext channel) { diff --git a/jsowell-netty/src/main/java/com/jsowell/netty/strategy/ykc/RemoteStopChargingStrategy.java b/jsowell-netty/src/main/java/com/jsowell/netty/strategy/ykc/RemoteStopChargingStrategy.java index 9b5064a68..377e7f040 100644 --- a/jsowell-netty/src/main/java/com/jsowell/netty/strategy/ykc/RemoteStopChargingStrategy.java +++ b/jsowell-netty/src/main/java/com/jsowell/netty/strategy/ykc/RemoteStopChargingStrategy.java @@ -7,6 +7,7 @@ import com.jsowell.common.enums.ykc.StopChargingFailedReasonEnum; import com.jsowell.common.util.BytesUtil; import com.jsowell.common.util.StringUtils; import com.jsowell.common.util.YKCUtils; +import com.jsowell.netty.factory.YKCOperateFactoryV2; import com.jsowell.pile.domain.OrderBasicInfo; import com.jsowell.pile.service.OrderBasicInfoService; import io.netty.channel.ChannelHandlerContext; @@ -14,6 +15,7 @@ import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; +import javax.annotation.PostConstruct; import java.util.Date; /** @@ -30,10 +32,10 @@ public class RemoteStopChargingStrategy implements AbstractYkcStrategy { @Autowired private OrderBasicInfoService orderBasicInfoService; - // @Override - // public void afterPropertiesSet() throws Exception { - // YKCOperateFactory.register(type, this); - // } + @PostConstruct + public void init() { + YKCOperateFactoryV2.register(type, this.getClass().getSimpleName()); + } @Override public byte[] supplyProcess(YKCDataProtocol ykcDataProtocol, ChannelHandlerContext channel) { diff --git a/jsowell-netty/src/main/java/com/jsowell/netty/strategy/ykc/RemoteUpdateStrategy.java b/jsowell-netty/src/main/java/com/jsowell/netty/strategy/ykc/RemoteUpdateStrategy.java index 121371ac0..46ea1eb1a 100644 --- a/jsowell-netty/src/main/java/com/jsowell/netty/strategy/ykc/RemoteUpdateStrategy.java +++ b/jsowell-netty/src/main/java/com/jsowell/netty/strategy/ykc/RemoteUpdateStrategy.java @@ -4,10 +4,13 @@ import com.jsowell.common.core.domain.ykc.YKCDataProtocol; import com.jsowell.common.core.domain.ykc.YKCFrameTypeCode; import com.jsowell.common.util.BytesUtil; import com.jsowell.common.util.YKCUtils; +import com.jsowell.netty.factory.YKCOperateFactoryV2; import io.netty.channel.ChannelHandlerContext; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Component; +import javax.annotation.PostConstruct; + /** * 远程更新应答 * @@ -19,10 +22,10 @@ import org.springframework.stereotype.Component; public class RemoteUpdateStrategy implements AbstractYkcStrategy { private final String type = YKCUtils.frameType2Str(YKCFrameTypeCode.REMOTE_UPDATE_ANSWER_CODE.getBytes()); - // @Override - // public void afterPropertiesSet() throws Exception { - // YKCOperateFactory.register(type, this); - // } + @PostConstruct + public void init() { + YKCOperateFactoryV2.register(type, this.getClass().getSimpleName()); + } @Override public byte[] supplyProcess(YKCDataProtocol ykcDataProtocol, ChannelHandlerContext channel) { diff --git a/jsowell-netty/src/main/java/com/jsowell/netty/strategy/ykc/ReservationChargingStartupResultStrategy.java b/jsowell-netty/src/main/java/com/jsowell/netty/strategy/ykc/ReservationChargingStartupResultStrategy.java index 40d6f6c44..50e062427 100644 --- a/jsowell-netty/src/main/java/com/jsowell/netty/strategy/ykc/ReservationChargingStartupResultStrategy.java +++ b/jsowell-netty/src/main/java/com/jsowell/netty/strategy/ykc/ReservationChargingStartupResultStrategy.java @@ -9,6 +9,7 @@ import com.jsowell.common.enums.ykc.ChargingFailedReasonEnum; import com.jsowell.common.util.BytesUtil; import com.jsowell.common.util.StringUtils; import com.jsowell.common.util.YKCUtils; +import com.jsowell.netty.factory.YKCOperateFactoryV2; import com.jsowell.pile.dto.ReservationChargingStartupResult; import com.jsowell.pile.service.PileBasicInfoService; import io.netty.channel.ChannelHandlerContext; @@ -16,6 +17,8 @@ import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; +import javax.annotation.PostConstruct; + /** * 0x65预约充电启动结果上送 */ @@ -28,10 +31,10 @@ public class ReservationChargingStartupResultStrategy implements AbstractYkcStra @Autowired private PileBasicInfoService pileBasicInfoService; - // @Override - // public void afterPropertiesSet() throws Exception { - // YKCOperateFactory.register(type, this); - // } + @PostConstruct + public void init() { + YKCOperateFactoryV2.register(type, this.getClass().getSimpleName()); + } public static void main(String[] args) { // 获取消息体 diff --git a/jsowell-netty/src/main/java/com/jsowell/netty/strategy/ykc/ReservationChargingStrategy.java b/jsowell-netty/src/main/java/com/jsowell/netty/strategy/ykc/ReservationChargingStrategy.java index 8ec5bb21e..195b8cb9b 100644 --- a/jsowell-netty/src/main/java/com/jsowell/netty/strategy/ykc/ReservationChargingStrategy.java +++ b/jsowell-netty/src/main/java/com/jsowell/netty/strategy/ykc/ReservationChargingStrategy.java @@ -7,6 +7,7 @@ import com.jsowell.common.core.domain.ykc.YKCFrameTypeCode; import com.jsowell.common.core.redis.RedisCache; import com.jsowell.common.util.BytesUtil; import com.jsowell.common.util.YKCUtils; +import com.jsowell.netty.factory.YKCOperateFactoryV2; import com.jsowell.pile.domain.PileReservationInfo; import com.jsowell.pile.service.PileReservationInfoService; import io.netty.channel.ChannelHandlerContext; @@ -14,6 +15,8 @@ import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; +import javax.annotation.PostConstruct; + /** * 预约充电响应 */ @@ -29,10 +32,10 @@ public class ReservationChargingStrategy implements AbstractYkcStrategy { @Autowired private PileReservationInfoService pileReservationInfoService; - // @Override - // public void afterPropertiesSet() throws Exception { - // YKCOperateFactory.register(type, this); - // } + @PostConstruct + public void init() { + YKCOperateFactoryV2.register(type, this.getClass().getSimpleName()); + } @Override public byte[] supplyProcess(YKCDataProtocol ykcDataProtocol, ChannelHandlerContext channel) { diff --git a/jsowell-netty/src/main/java/com/jsowell/netty/strategy/ykc/SettingPileWorkParamsStrategy.java b/jsowell-netty/src/main/java/com/jsowell/netty/strategy/ykc/SettingPileWorkParamsStrategy.java index bbf991c2d..abef07fb0 100644 --- a/jsowell-netty/src/main/java/com/jsowell/netty/strategy/ykc/SettingPileWorkParamsStrategy.java +++ b/jsowell-netty/src/main/java/com/jsowell/netty/strategy/ykc/SettingPileWorkParamsStrategy.java @@ -4,10 +4,13 @@ import com.jsowell.common.core.domain.ykc.YKCDataProtocol; import com.jsowell.common.core.domain.ykc.YKCFrameTypeCode; import com.jsowell.common.util.BytesUtil; import com.jsowell.common.util.YKCUtils; +import com.jsowell.netty.factory.YKCOperateFactoryV2; import io.netty.channel.ChannelHandlerContext; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Component; +import javax.annotation.PostConstruct; + /** * 0x29 平台设置工作参数回复 * @@ -19,10 +22,10 @@ import org.springframework.stereotype.Component; public class SettingPileWorkParamsStrategy implements AbstractYkcStrategy { private final String type = YKCUtils.frameType2Str(YKCFrameTypeCode.SETTING_PILE_WORK_PARAMS_ANSWER_CODE.getBytes()); - // @Override - // public void afterPropertiesSet() throws Exception { - // YKCOperateFactory.register(type, this); - // } + @PostConstruct + public void init() { + YKCOperateFactoryV2.register(type, this.getClass().getSimpleName()); + } @Override public byte[] supplyProcess(YKCDataProtocol ykcDataProtocol, ChannelHandlerContext channel) { diff --git a/jsowell-netty/src/main/java/com/jsowell/netty/strategy/ykc/TimeCheckSettingStrategy.java b/jsowell-netty/src/main/java/com/jsowell/netty/strategy/ykc/TimeCheckSettingStrategy.java index 35f4238f6..9321ca3f5 100644 --- a/jsowell-netty/src/main/java/com/jsowell/netty/strategy/ykc/TimeCheckSettingStrategy.java +++ b/jsowell-netty/src/main/java/com/jsowell/netty/strategy/ykc/TimeCheckSettingStrategy.java @@ -6,10 +6,12 @@ import com.jsowell.common.util.BytesUtil; import com.jsowell.common.util.Cp56Time2a.Cp56Time2aUtil; import com.jsowell.common.util.DateUtils; import com.jsowell.common.util.YKCUtils; +import com.jsowell.netty.factory.YKCOperateFactoryV2; import io.netty.channel.ChannelHandlerContext; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Component; +import javax.annotation.PostConstruct; import java.util.Date; /** @@ -23,10 +25,10 @@ import java.util.Date; public class TimeCheckSettingStrategy implements AbstractYkcStrategy { private final String type = YKCUtils.frameType2Str(YKCFrameTypeCode.TIME_CHECK_SETTING_ANSWER_CODE.getBytes()); - // @Override - // public void afterPropertiesSet() throws Exception { - // YKCOperateFactory.register(type, this); - // } + @PostConstruct + public void init() { + YKCOperateFactoryV2.register(type, this.getClass().getSimpleName()); + } @Override public byte[] supplyProcess(YKCDataProtocol ykcDataProtocol, ChannelHandlerContext channel) { diff --git a/jsowell-netty/src/main/java/com/jsowell/netty/strategy/ykc/TransactionRecordsStrategy.java b/jsowell-netty/src/main/java/com/jsowell/netty/strategy/ykc/TransactionRecordsStrategy.java index ee7e395b2..2fcddf1af 100644 --- a/jsowell-netty/src/main/java/com/jsowell/netty/strategy/ykc/TransactionRecordsStrategy.java +++ b/jsowell-netty/src/main/java/com/jsowell/netty/strategy/ykc/TransactionRecordsStrategy.java @@ -17,6 +17,7 @@ import com.jsowell.common.util.StringUtils; import com.jsowell.common.util.YKCUtils; import com.jsowell.common.util.id.IdUtils; import com.jsowell.common.util.spring.SpringUtils; +import com.jsowell.netty.factory.YKCOperateFactoryV2; import com.jsowell.pile.domain.OrderBasicInfo; import com.jsowell.pile.domain.PileBasicInfo; import com.jsowell.pile.service.*; @@ -29,6 +30,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; import org.springframework.stereotype.Component; +import javax.annotation.PostConstruct; import java.util.Date; import java.util.Objects; import java.util.concurrent.CompletableFuture; @@ -51,11 +53,11 @@ public class TransactionRecordsStrategy implements AbstractYkcStrategy { // 引入线程池 private ThreadPoolTaskExecutor executor = SpringUtils.getBean("threadPoolTaskExecutor"); - // @Override - // public void afterPropertiesSet() throws Exception { - // YKCOperateFactory.register(type, this); - // YKCOperateFactory.register(oldVersionType, this); - // } + @PostConstruct + public void init() { + YKCOperateFactoryV2.register(type, this.getClass().getSimpleName()); + YKCOperateFactoryV2.register(oldVersionType, this.getClass().getSimpleName()); + } @Autowired private RedisCache redisCache; diff --git a/jsowell-netty/src/main/java/com/jsowell/netty/strategy/ykc/UploadRealTimeMonitorStrategy.java b/jsowell-netty/src/main/java/com/jsowell/netty/strategy/ykc/UploadRealTimeMonitorStrategy.java index f23339cd9..85dd0c0f1 100644 --- a/jsowell-netty/src/main/java/com/jsowell/netty/strategy/ykc/UploadRealTimeMonitorStrategy.java +++ b/jsowell-netty/src/main/java/com/jsowell/netty/strategy/ykc/UploadRealTimeMonitorStrategy.java @@ -14,6 +14,7 @@ import com.jsowell.common.util.BytesUtil; import com.jsowell.common.util.StringUtils; import com.jsowell.common.util.YKCUtils; import com.jsowell.common.util.spring.SpringUtils; +import com.jsowell.netty.factory.YKCOperateFactoryV2; import com.jsowell.pile.domain.OrderBasicInfo; import com.jsowell.pile.service.OrderBasicInfoService; import com.jsowell.pile.service.PileBasicInfoService; @@ -24,6 +25,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; import org.springframework.stereotype.Component; +import javax.annotation.PostConstruct; import java.util.Date; import java.util.Objects; import java.util.concurrent.CompletableFuture; @@ -41,11 +43,11 @@ public class UploadRealTimeMonitorStrategy implements AbstractYkcStrategy { private final String type = YKCUtils.frameType2Str(YKCFrameTypeCode.UPLOAD_REAL_TIME_MONITOR_DATA_CODE.getBytes()); private final String oldVersionType = YKCUtils.frameType2Str(YKCFrameTypeCode.UPLOAD_REAL_TIME_MONITOR_DATA_OLD_VERSION_CODE.getBytes()); - // @Override - // public void afterPropertiesSet() throws Exception { - // YKCOperateFactory.register(type, this); - // YKCOperateFactory.register(oldVersionType, this); - // } + @PostConstruct + public void init() { + YKCOperateFactoryV2.register(type, this.getClass().getSimpleName()); + YKCOperateFactoryV2.register(oldVersionType, this.getClass().getSimpleName()); + } // 引入线程池 private ThreadPoolTaskExecutor executor = SpringUtils.getBean("threadPoolTaskExecutor");