From b6e84424795cffce82a91fcc2d560ebadefd3645 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8F=8D=E7=BC=96=E8=AF=91=E5=B7=A5=E4=BD=9C=E5=8C=BA?= Date: Fri, 24 Apr 2026 23:45:30 +0800 Subject: [PATCH] =?UTF-8?q?fix(v0.11):=20=E8=B5=B0=E6=9F=A5=E9=A1=B9?= =?UTF-8?q?=E2=80=94=E2=80=94=E4=BA=8B=E4=BB=B6=E6=A8=A1=E5=9D=97=E7=A9=BA?= =?UTF-8?q?=E5=AE=89=E5=85=A8=E3=80=81=E6=9D=A1=E4=BB=B6=E7=B1=BB=E5=90=8D?= =?UTF-8?q?=E3=80=81=E8=AE=BE=E5=A4=87=E7=AD=9B=E9=80=89=E4=B8=8E=E5=8D=A0?= =?UTF-8?q?=E4=BD=8D=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - EventConfiguration 标注 @Configuration,Bean 方法改为 cloudwalkEventInitializing - CloudwalkEventManager 对 handler/custom 映射链式 get 做空映射兜底 - EventHandlerMapping / CloudwalkEventInitializing 中 EventType 原型判空 - Rest 层 @ConditionalOnMissingClass 指向正确的本地实现类全名 - RestDeviceServiceImpl:deviceType 与设备类型树数据的 NPE 防护 - PersonRuleServiceImpl:未实现方法返回 CloudwalkResult.fail 替代 null Made-with: Cursor --- .../event/CloudwalkEventInitializing.java | 3 ++- .../event/CloudwalkEventManager.java | 22 ++++++++++++---- .../event/autoconfig/EventConfiguration.java | 4 ++- .../event/handler/EventHandlerMapping.java | 3 ++- .../person/impl/PersonRuleServiceImpl.java | 6 ++--- .../device/service/RestDeviceServiceImpl.java | 26 ++++++++++++++----- .../AcsRecordThreeSendServiceImpl.java | 2 +- .../service/RestSysettingAreaServiceImpl.java | 2 +- 8 files changed, 48 insertions(+), 20 deletions(-) diff --git a/maven-cloudwalk-cloud/cloudwalk-common-event/src/main/java/cn/cloudwalk/event/CloudwalkEventInitializing.java b/maven-cloudwalk-cloud/cloudwalk-common-event/src/main/java/cn/cloudwalk/event/CloudwalkEventInitializing.java index bf939cf0..56e650c0 100644 --- a/maven-cloudwalk-cloud/cloudwalk-common-event/src/main/java/cn/cloudwalk/event/CloudwalkEventInitializing.java +++ b/maven-cloudwalk-cloud/cloudwalk-common-event/src/main/java/cn/cloudwalk/event/CloudwalkEventInitializing.java @@ -175,7 +175,8 @@ public class CloudwalkEventInitializing implements CommandLineRunner { private EventType getEventType(Class eventClass) { for (EventType eventType : EventType.values()) { - if (eventType.getEventClass().getClass().equals(eventClass)) { + BaseEvent prototype = eventType.getEventClass(); + if (prototype != null && prototype.getClass().equals(eventClass)) { return eventType; } } diff --git a/maven-cloudwalk-cloud/cloudwalk-common-event/src/main/java/cn/cloudwalk/event/CloudwalkEventManager.java b/maven-cloudwalk-cloud/cloudwalk-common-event/src/main/java/cn/cloudwalk/event/CloudwalkEventManager.java index bbba9b0b..c1125934 100644 --- a/maven-cloudwalk-cloud/cloudwalk-common-event/src/main/java/cn/cloudwalk/event/CloudwalkEventManager.java +++ b/maven-cloudwalk-cloud/cloudwalk-common-event/src/main/java/cn/cloudwalk/event/CloudwalkEventManager.java @@ -10,7 +10,9 @@ import cn.cloudwalk.event.handler.EventHandlerWorker; import cn.cloudwalk.event.listener.GroupEventListener; import cn.cloudwalk.event.listener.GroupListnerClassMapping; import cn.cloudwalk.event.task.EventHandleTask; +import java.util.Collections; import java.util.List; +import java.util.Map; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.util.CollectionUtils; @@ -29,14 +31,24 @@ public class CloudwalkEventManager { public void handle(Class eventListnerClass, BaseEvent baseEvent) { String groupId = this.groupListnerClassMapping.getGroupId(eventListnerClass); if (baseEvent instanceof CustomEvent) { - List customEventHandlers = (List)this.eventHandlerMapping - .getServiceCodeCustomHandlerListMap(groupId, ((CustomEvent)baseEvent).getTopic()) - .get(baseEvent.getServiceCode()); + Map> customByServiceCode = + this.eventHandlerMapping.getServiceCodeCustomHandlerListMap(groupId, + ((CustomEvent)baseEvent).getTopic()); + if (customByServiceCode == null) { + customByServiceCode = Collections.emptyMap(); + } + List customEventHandlers = + (List)customByServiceCode.get(baseEvent.getServiceCode()); eventHandle(baseEvent, customEventHandlers); return; } - List handlerList = (List)this.eventHandlerMapping - .getServiceCodeHandlerListMap(groupId, baseEvent.getClass()).get(baseEvent.getServiceCode()); + Map> handlerByServiceCode = + this.eventHandlerMapping.getServiceCodeHandlerListMap(groupId, baseEvent.getClass()); + if (handlerByServiceCode == null) { + handlerByServiceCode = Collections.emptyMap(); + } + List handlerList = + (List)handlerByServiceCode.get(baseEvent.getServiceCode()); eventHandle(baseEvent, handlerList); } diff --git a/maven-cloudwalk-cloud/cloudwalk-common-event/src/main/java/cn/cloudwalk/event/autoconfig/EventConfiguration.java b/maven-cloudwalk-cloud/cloudwalk-common-event/src/main/java/cn/cloudwalk/event/autoconfig/EventConfiguration.java index d0a8f6d6..da43fd2f 100644 --- a/maven-cloudwalk-cloud/cloudwalk-common-event/src/main/java/cn/cloudwalk/event/autoconfig/EventConfiguration.java +++ b/maven-cloudwalk-cloud/cloudwalk-common-event/src/main/java/cn/cloudwalk/event/autoconfig/EventConfiguration.java @@ -4,10 +4,12 @@ import cn.cloudwalk.event.CloudwalkEventInitializing; import cn.cloudwalk.event.CloudwalkEventManager; import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; /** * 事件模块 Spring 配置:注册 {@link cn.cloudwalk.event.CloudwalkEventManager} 与初始化组件。 */ +@Configuration @EnableConfigurationProperties({EventProperties.class}) public class EventConfiguration { @Bean @@ -16,7 +18,7 @@ public class EventConfiguration { } @Bean - public CloudwalkEventInitializing CloudwalkEventInitializing(EventProperties eventProperties) { + public CloudwalkEventInitializing cloudwalkEventInitializing(EventProperties eventProperties) { return new CloudwalkEventInitializing(eventProperties); } } diff --git a/maven-cloudwalk-cloud/cloudwalk-common-event/src/main/java/cn/cloudwalk/event/handler/EventHandlerMapping.java b/maven-cloudwalk-cloud/cloudwalk-common-event/src/main/java/cn/cloudwalk/event/handler/EventHandlerMapping.java index decd14ff..1ac9c2b6 100644 --- a/maven-cloudwalk-cloud/cloudwalk-common-event/src/main/java/cn/cloudwalk/event/handler/EventHandlerMapping.java +++ b/maven-cloudwalk-cloud/cloudwalk-common-event/src/main/java/cn/cloudwalk/event/handler/EventHandlerMapping.java @@ -26,7 +26,8 @@ public class EventHandlerMapping { public Map> getServiceCodeHandlerListMap(String groupId, Class eventClass) { for (EventType eventType : EventType.values()) { - if (eventType.getEventClass().getClass().equals(eventClass)) { + BaseEvent prototype = eventType.getEventClass(); + if (prototype != null && prototype.getClass().equals(eventClass)) { return getServiceCodeHandlerListMap(groupId, eventType); } } diff --git a/maven-cw-elevator-application/cw-elevator-application-service/src/main/java/cn/cloudwalk/elevator/person/impl/PersonRuleServiceImpl.java b/maven-cw-elevator-application/cw-elevator-application-service/src/main/java/cn/cloudwalk/elevator/person/impl/PersonRuleServiceImpl.java index 42f0da3f..3f1bb4c2 100644 --- a/maven-cw-elevator-application/cw-elevator-application-service/src/main/java/cn/cloudwalk/elevator/person/impl/PersonRuleServiceImpl.java +++ b/maven-cw-elevator-application/cw-elevator-application-service/src/main/java/cn/cloudwalk/elevator/person/impl/PersonRuleServiceImpl.java @@ -298,7 +298,7 @@ public class PersonRuleServiceImpl extends AbstractAcsPassService implements Per public CloudwalkResult edit(AcsPersonEditParam param, CloudwalkCallContext context) throws ServiceException { - return null; + return CloudwalkResult.fail("76260998", "人员规则编辑接口未实现"); } public CloudwalkResult delete(AcsPersonDeleteParam param, CloudwalkCallContext context) @@ -447,12 +447,12 @@ public class PersonRuleServiceImpl extends AbstractAcsPassService implements Per public CloudwalkResult timeDetail(AcsPersonTimeDetailParam param, CloudwalkCallContext context) throws ServiceException { - return null; + return CloudwalkResult.fail("76260998", "人员时段详情接口未实现"); } public CloudwalkResult> pageByApp(AcsPersonQueryByAppParam param, CloudwalkPageInfo pageInfo, CloudwalkCallContext context) throws ServiceException { - return null; + return CloudwalkResult.fail("76260998", "应用端人员分页接口未实现"); } public CloudwalkResult> personDetail(PersonDetailQueryParam param, diff --git a/maven-intelligent-cwoscomponent/intelligent-cwoscomponent-rest/src/main/java/cn/cloudwalk/rest/cwoscomponent/intelligent/device/service/RestDeviceServiceImpl.java b/maven-intelligent-cwoscomponent/intelligent-cwoscomponent-rest/src/main/java/cn/cloudwalk/rest/cwoscomponent/intelligent/device/service/RestDeviceServiceImpl.java index 587792e9..873fafc0 100644 --- a/maven-intelligent-cwoscomponent/intelligent-cwoscomponent-rest/src/main/java/cn/cloudwalk/rest/cwoscomponent/intelligent/device/service/RestDeviceServiceImpl.java +++ b/maven-intelligent-cwoscomponent/intelligent-cwoscomponent-rest/src/main/java/cn/cloudwalk/rest/cwoscomponent/intelligent/device/service/RestDeviceServiceImpl.java @@ -13,9 +13,10 @@ import cn.cloudwalk.cloud.result.CloudwalkResult; import cn.cloudwalk.rest.cwoscomponent.intelligent.device.config.DeviceCategoryProperties; import cn.cloudwalk.rest.cwoscomponent.intelligent.device.feign.DeviceFeignClient; import java.util.ArrayList; -import java.util.Collection; +import java.util.Collections; import java.util.List; import java.util.Map; +import java.util.Objects; import java.util.stream.Collectors; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; @@ -40,7 +41,8 @@ public class RestDeviceServiceImpl implements DeviceService { public CloudwalkResult> filterList(Integer deviceType, DeviceQueryParam param, CloudwalkCallContext context) throws ServiceException { - if (StringUtils.isEmpty(param.getDeviceTypeCode()) && CollectionUtils.isEmpty(param.getDeviceTypeCodes())) { + if (deviceType != null && StringUtils.isEmpty(param.getDeviceTypeCode()) + && CollectionUtils.isEmpty(param.getDeviceTypeCodes())) { if (deviceType.intValue() == 1) { List deviceCategoryIds = this.deviceCategoryProperties.getDeviceCategoryArray(); if (!CollectionUtils.isEmpty(deviceCategoryIds)) { @@ -58,15 +60,25 @@ public class RestDeviceServiceImpl implements DeviceService { public List getDeviceTypeCodes(List deviceCategoryIds) throws ServiceException { CloudwalkResult> deviceTypeResultList = this.deviceTypeService.getCacheAble(); - Map deviceTypeResultMap = - (Map)((List)deviceTypeResultList.getData()).stream() - .collect(Collectors.toMap(DeviceTypeResult::getId, d -> d)); + if (deviceTypeResultList == null || deviceTypeResultList.getData() == null) { + return Collections.emptyList(); + } + List dataList = deviceTypeResultList.getData(); + Map deviceTypeResultMap = dataList.stream().filter(Objects::nonNull) + .collect(Collectors.toMap(DeviceTypeResult::getId, d -> d, (a, b) -> a)); List deviceTypeCodes = new ArrayList<>(); for (String deviceCategoryId : deviceCategoryIds) { DeviceTypeResult deviceTypeResult = deviceTypeResultMap.get(deviceCategoryId); + if (deviceTypeResult == null) { + continue; + } List children = deviceTypeResult.getChildren(); - deviceTypeCodes.addAll((Collection)children.stream() - .map(DeviceTypeResult.DeviceTypeDetailResult::getDeviceTypeCode).collect(Collectors.toList())); + if (CollectionUtils.isEmpty(children)) { + continue; + } + deviceTypeCodes.addAll(children.stream().filter(Objects::nonNull) + .map(DeviceTypeResult.DeviceTypeDetailResult::getDeviceTypeCode).filter(Objects::nonNull) + .collect(Collectors.toList())); } return deviceTypeCodes; } diff --git a/maven-intelligent-cwoscomponent/intelligent-cwoscomponent-rest/src/main/java/cn/cloudwalk/rest/cwoscomponent/intelligent/record/service/AcsRecordThreeSendServiceImpl.java b/maven-intelligent-cwoscomponent/intelligent-cwoscomponent-rest/src/main/java/cn/cloudwalk/rest/cwoscomponent/intelligent/record/service/AcsRecordThreeSendServiceImpl.java index aaba8559..29466ef9 100644 --- a/maven-intelligent-cwoscomponent/intelligent-cwoscomponent-rest/src/main/java/cn/cloudwalk/rest/cwoscomponent/intelligent/record/service/AcsRecordThreeSendServiceImpl.java +++ b/maven-intelligent-cwoscomponent/intelligent-cwoscomponent-rest/src/main/java/cn/cloudwalk/rest/cwoscomponent/intelligent/record/service/AcsRecordThreeSendServiceImpl.java @@ -12,7 +12,7 @@ import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingClas import org.springframework.stereotype.Service; @Service -@ConditionalOnMissingClass({"cn.cloudwalk.service.cwoscomponent.intelligent.record.service.AcsRecordServiceImpl"}) +@ConditionalOnMissingClass({"cn.cloudwalk.service.cwoscomponent.intelligent.record.service.AcsRecordThreeSendServiceImpl"}) public class AcsRecordThreeSendServiceImpl implements AcsRecordThreeSendService { @Autowired private AcsRecordThreeSendFeignClient acsRecordThreeSendFeignClient; diff --git a/maven-intelligent-cwoscomponent/intelligent-cwoscomponent-rest/src/main/java/cn/cloudwalk/rest/cwoscomponent/intelligent/sysetting/service/RestSysettingAreaServiceImpl.java b/maven-intelligent-cwoscomponent/intelligent-cwoscomponent-rest/src/main/java/cn/cloudwalk/rest/cwoscomponent/intelligent/sysetting/service/RestSysettingAreaServiceImpl.java index d98648ec..8568e0d4 100644 --- a/maven-intelligent-cwoscomponent/intelligent-cwoscomponent-rest/src/main/java/cn/cloudwalk/rest/cwoscomponent/intelligent/sysetting/service/RestSysettingAreaServiceImpl.java +++ b/maven-intelligent-cwoscomponent/intelligent-cwoscomponent-rest/src/main/java/cn/cloudwalk/rest/cwoscomponent/intelligent/sysetting/service/RestSysettingAreaServiceImpl.java @@ -12,7 +12,7 @@ import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingClas import org.springframework.stereotype.Service; @Service -@ConditionalOnMissingClass({"cn.cloudwalk.service.cwoscomponent.intelligent.resource.service.SysettingAreaServiceImpl"}) +@ConditionalOnMissingClass({"cn.cloudwalk.service.cwoscomponent.intelligent.sysetting.service.SysettingAreaServiceImpl"}) public class RestSysettingAreaServiceImpl implements SysettingAreaService { @Autowired private SysettingAreaFeignClient sysettingAreaFeignClient;