feat: add policy tracing logs across organization component and elevator

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
This commit is contained in:
hpd840321
2026-05-10 09:37:51 +08:00
parent 368d14de0e
commit d8bcc14563
3 changed files with 30 additions and 2 deletions
@@ -69,6 +69,7 @@ public class TenantVisitorFloorPolicyService {
for (String id : orgIds) {
Optional<List<String>> 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<TenantVisitorFloorPolicy> policy = findEnabledPolicyByOrgId(orgId);
if (!policy.isPresent()) {
log.debug("[POLICY-MISS] no enabled policy for orgId={}", orgId);
return Optional.empty();
}
List<String> 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();
}
}
@@ -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<AcsPassRuleImageResultDto> 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<List<String>> replacementFloors =
this.tenantVisitorFloorPolicyService.replacementZoneIdsIfPolicyActive(
result.getOrganizationIds());
if (replacementFloors.isPresent()) {
List<String> 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<String> userIdList =
(List<String>)