From d8bcc14563d22b1421f33866406b9c327907fa5d Mon Sep 17 00:00:00 2001 From: hpd840321 Date: Sun, 10 May 2026 09:37:51 +0800 Subject: [PATCH] feat: add policy tracing logs across organization component and elevator MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit TenantVisitorFloorPolicyService: - [POLICY-HIT] log when policy matched with orgId, policyId, allowZones - [POLICY-MISS] debug log when no policy found for orgId - [POLICY-EMPTY] warn when allow_zone_ids parsed empty - [POLICY-FALLBACK] warn on query failure with orgId context - [POLICY-RESULT] info on matched orgId and zones in batch check ImgPersonServiceImpl.detail(): - [DETAIL] log raw floorList from listByImageId - [DETAIL-POLICY] log floorList REPLACED: before→after with orgIds - [DETAIL] warn when listByImageId fails ImgPersonServiceImpl.listByPage(): - [LIST-PAGE-POLICY] log policy hit with zone count and default - [LIST-PAGE-XHW] debug log for 40F/6F hardcoded branch - [LIST-PAGE-FILTER] debug log when visitor label filtered PersonRuleServiceImpl.addVisitor(): - [ADDV-DETAIL] log detail floorList and orgIds --- .../person/impl/PersonRuleServiceImpl.java | 2 ++ .../TenantVisitorFloorPolicyService.java | 9 ++++++-- .../service/ImgPersonServiceImpl.java | 21 +++++++++++++++++++ 3 files changed, 30 insertions(+), 2 deletions(-) diff --git a/backend/cw-elevator-application/cw-elevator-application-service/src/main/java/cn/cloudwalk/elevator/person/impl/PersonRuleServiceImpl.java b/backend/cw-elevator-application/cw-elevator-application-service/src/main/java/cn/cloudwalk/elevator/person/impl/PersonRuleServiceImpl.java index ca6e1fdd..ba600006 100644 --- a/backend/cw-elevator-application/cw-elevator-application-service/src/main/java/cn/cloudwalk/elevator/person/impl/PersonRuleServiceImpl.java +++ b/backend/cw-elevator-application/cw-elevator-application-service/src/main/java/cn/cloudwalk/elevator/person/impl/PersonRuleServiceImpl.java @@ -183,6 +183,8 @@ public class PersonRuleServiceImpl extends AbstractAcsPassService implements Per this.logger.warn("被访人信息为空 personId={}", param.getPersonId()); return CloudwalkResult.fail("76260531", getMessage("76260531")); } + this.logger.info("[ADDV-DETAIL] personId={} floorList={} orgIds={}", + param.getPersonId(), personResult.getFloorList(), personResult.getOrganizationIds()); // === 阶段2:确定生效楼层(规范:租户策略仅在组织 detail 以 allow_zone_ids「替代」写入 floorList;此处不做 ∩)=== List effective; diff --git a/backend/ninca-common-component-organization/cwos-component-organization-service/src/main/java/cn/cloudwalk/service/organization/policy/TenantVisitorFloorPolicyService.java b/backend/ninca-common-component-organization/cwos-component-organization-service/src/main/java/cn/cloudwalk/service/organization/policy/TenantVisitorFloorPolicyService.java index f08b46d1..7dbd6577 100644 --- a/backend/ninca-common-component-organization/cwos-component-organization-service/src/main/java/cn/cloudwalk/service/organization/policy/TenantVisitorFloorPolicyService.java +++ b/backend/ninca-common-component-organization/cwos-component-organization-service/src/main/java/cn/cloudwalk/service/organization/policy/TenantVisitorFloorPolicyService.java @@ -69,6 +69,7 @@ public class TenantVisitorFloorPolicyService { for (String id : orgIds) { Optional> zones = replacementZoneIdsIfPolicyActive(id); if (zones.isPresent()) { + log.info("[POLICY-RESULT] matched orgId={} zones={}", id, zones.get()); return zones; } } @@ -86,17 +87,21 @@ public class TenantVisitorFloorPolicyService { try { Optional policy = findEnabledPolicyByOrgId(orgId); if (!policy.isPresent()) { + log.debug("[POLICY-MISS] no enabled policy for orgId={}", orgId); return Optional.empty(); } List allow = parseAllowZoneIds(policy.get().getAllowZoneIds()); if (allow.isEmpty()) { + log.warn("[POLICY-EMPTY] policy {} allow_zone_ids parsed empty", policy.get().getId()); return Optional.empty(); } + log.info("[POLICY-HIT] orgId={} policyId={} allowZones={}", + orgId, policy.get().getId(), allow); return Optional.of(new ArrayList<>(allow)); } catch (Exception e) { log.warn( - "tenant_visitor_floor_policy query failed, fallback to listByImageId floors: {}", - e.toString()); + "[POLICY-FALLBACK] query failed for orgId={}, fallback to listByImageId: {}", + orgId, e.toString()); return Optional.empty(); } } diff --git a/backend/ninca-common-component-organization/cwos-component-organization-service/src/main/java/cn/cloudwalk/service/organization/service/ImgPersonServiceImpl.java b/backend/ninca-common-component-organization/cwos-component-organization-service/src/main/java/cn/cloudwalk/service/organization/service/ImgPersonServiceImpl.java index 229dcd22..0232f0ef 100644 --- a/backend/ninca-common-component-organization/cwos-component-organization-service/src/main/java/cn/cloudwalk/service/organization/service/ImgPersonServiceImpl.java +++ b/backend/ninca-common-component-organization/cwos-component-organization-service/src/main/java/cn/cloudwalk/service/organization/service/ImgPersonServiceImpl.java @@ -332,6 +332,9 @@ public class ImgPersonServiceImpl extends AbstractImagStoreService imgStorePersonResult.setFloorInfoList(new ArrayList<>(policyFloorInfo)); imgStorePersonResult.setDefaultChooseFloor(policyZones.get().get(0)); imgStorePersonResult.setIsAcrossDay(Integer.valueOf(0)); + this.logger.info("[LIST-PAGE-POLICY] personId={} orgIds={} zoneCount={} defaultZone={}", + imgStorePersonResult.getId(), imgStorePersonResult.getOrganizationIds(), + policyZones.get().size(), policyZones.get().get(0)); } else { AcsPassRuleImageForm acsPassRuleImageForm = new AcsPassRuleImageForm(); acsPassRuleImageForm.setPersonId(imgStorePersonResult.getId()); @@ -359,6 +362,8 @@ public class ImgPersonServiceImpl extends AbstractImagStoreService resultDto.setZoneName("40F"); floorInfoList.add(resultDto); imgStorePersonResult.setFloorInfoList(floorInfoList); + this.logger.debug("[LIST-PAGE-XHW] personId={} matched xhwId → 40F", + imgStorePersonResult.getId()); } else { imgStorePersonResult.setDefaultChooseFloor(this.xhwSixFloorId); List floorInfoList = new ArrayList<>(); @@ -367,12 +372,16 @@ public class ImgPersonServiceImpl extends AbstractImagStoreService resultDto.setZoneName("6F"); floorInfoList.add(resultDto); imgStorePersonResult.setFloorInfoList(floorInfoList); + this.logger.debug("[LIST-PAGE-XHW] personId={} default → 6F", + imgStorePersonResult.getId()); } } } } if (!CollectionUtils.isEmpty(imgStorePersonResult.getLabelNames()) && imgStorePersonResult.getLabelNames().contains("访客")) { + this.logger.debug("[LIST-PAGE-FILTER] personId={} excluded (label=访客)", + imgStorePersonResult.getId()); continue; } newPersonResults.add(imgStorePersonResult); @@ -640,15 +649,27 @@ public class ImgPersonServiceImpl extends AbstractImagStoreService floorList.add( ((AcsPassRuleImageResultDto) acsPassRuleImageResultDtoList.get(i)).getZoneId()); } + int rawFloorCount = floorList.size(); + this.logger.info("[DETAIL] personId={} listByImageId returned {} zones: {}", + param.getId(), rawFloorCount, floorList); Optional> replacementFloors = this.tenantVisitorFloorPolicyService.replacementZoneIdsIfPolicyActive( result.getOrganizationIds()); if (replacementFloors.isPresent()) { + List beforeReplacement = new ArrayList<>(floorList); floorList = new ArrayList<>(replacementFloors.get()); zoneNames = buildCommaSeparatedFloorNames(businessId, floorList); + this.logger.info("[DETAIL-POLICY] personId={} orgIds={} floorList REPLACED: {}→{}", + param.getId(), result.getOrganizationIds(), beforeReplacement, floorList); + } else { + this.logger.debug("[DETAIL-POLICY] personId={} orgIds={} no policy matched, using raw floorList", + param.getId(), result.getOrganizationIds()); } result.setFloorNames(zoneNames); result.setFloorList(floorList); + } else { + this.logger.warn("[DETAIL] personId={} listByImageId failed code={}", + param.getId(), images.getCode()); } List userIdList = (List)