From f350f318f5e0b5020bf1d35f89e55023a3864237 Mon Sep 17 00:00:00 2001 From: hpd840321 Date: Sun, 10 May 2026 09:50:42 +0800 Subject: [PATCH] feat: add comprehensive logging to ImgPersonServiceImpl external calls and error paths MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit detail(): - [DETAIL] entry log with personId+businessId - [DETAIL] person not found warning - [DETAIL] zoneFeignClient/vehicleFeignClient failure warnings - [DETAIL] query error with personId context page(): - [PAGE] query result count - [PAGE] organizationService.getOrg failure warning - [PAGE] query error with context listByPage(): - [LIST-PAGE] listByImageId failure warning - [LIST-PAGE] no orgFloor → acrossDay debug add()/addExt(): - [ADD] error logs with personId context --- .../service/ImgPersonServiceImpl.java | 31 ++++++++++++++----- 1 file changed, 24 insertions(+), 7 deletions(-) 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 0232f0ef..461dd7c2 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 @@ -202,13 +202,13 @@ public class ImgPersonServiceImpl extends AbstractImagStoreService imageId -> this.cpImageStorePersonSynManager.handleGroupPersonSynTask(imageId)); } } catch (ServiceException e) { - this.logger.error("人员信息新增失败,原因:{}", (Throwable) e); + this.logger.error("[ADD] personId={} failed: {}", personId, e.toString()); throw e; } catch (ImageStoreException e) { - this.logger.error("人员信息新增失败,原因:{}", (Throwable) e); + this.logger.error("[ADD] personId={} imageStore failed: {}", personId, e.toString()); throw new ServiceException(e.getCode(), e.getMessage()); } catch (Exception e) { - this.logger.error("人员信息新增失败,原因:{}", e); + this.logger.error("[ADD] personId={} unexpected error", personId, e); String errorMessage = this.messageSource.getMessage("53014008", null, LocaleContextHolder.getLocale()); throw new ServiceException("53014008", errorMessage); @@ -255,7 +255,7 @@ public class ImgPersonServiceImpl extends AbstractImagStoreService } catch (ServiceException e) { throw e; } catch (Exception e) { - this.logger.error("人员信息新增失败,原因:{}", e); + this.logger.error("[ADD] personId={} unexpected error", personId, e); String errorMessage = this.messageSource.getMessage("53014008", null, LocaleContextHolder.getLocale()); throw new ServiceException("53014008", errorMessage); @@ -280,6 +280,7 @@ public class ImgPersonServiceImpl extends AbstractImagStoreService PageHelper.orderBy("LAST_UPDATE_TIME DESC, ID DESC"); Page gets = (Page) this.imgStorePersonMapper.gets(dto); List result = gets.getResult(); + this.logger.debug("[PAGE] query returned {} persons businessId={}", result.size(), businessId); List imgStorePersonResults = getImgStorePersonResults(result, context.getCompany().getCompanyId()); Set orgSet = getOrgSet(imgStorePersonResults); @@ -300,6 +301,9 @@ public class ImgPersonServiceImpl extends AbstractImagStoreService orgId, orgMap.getOrDefault(orgId, new ArrayList()))); item.setOrganizationComplete(orgCompleteMap); }); + } else { + this.logger.warn("[PAGE] organizationService.getOrg failed code={}", + orgResult.getCode()); } } List userIdList = @@ -345,6 +349,9 @@ public class ImgPersonServiceImpl extends AbstractImagStoreService this.elevatorFeignClient.listByImageId(acsPassRuleImageForm); if (Objects.equals(images.getCode(), "00000000")) { imgStorePersonResult.setFloorInfoList((List) images.getData()); + } else { + this.logger.warn("[LIST-PAGE] personId={} listByImageId failed code={}", + imgStorePersonResult.getId(), images.getCode()); } imgStorePersonResult.setDefaultChooseFloor(imgStorePersonResult.getDefaultFloor()); if (!CollectionUtils.isEmpty(imgStorePersonResult.getOrganizationIds())) { @@ -352,6 +359,8 @@ public class ImgPersonServiceImpl extends AbstractImagStoreService this.orgFloorMapper.listByOrgIds(imgStorePersonResult.getOrganizationIds()); if (CollectionUtils.isEmpty(orgFloorList)) { imgStorePersonResult.setIsAcrossDay(Integer.valueOf(1)); + this.logger.debug("[LIST-PAGE] personId={} no orgFloor → acrossDay=true", + imgStorePersonResult.getId()); } else { imgStorePersonResult.setIsAcrossDay(Integer.valueOf(0)); if (imgStorePersonResult.getOrganizationIds().contains(this.xhwId)) { @@ -391,7 +400,7 @@ public class ImgPersonServiceImpl extends AbstractImagStoreService pageAble = new CloudwalkPageAble(imgStorePersonResults, page, gets.getTotal()); } } catch (Exception e) { - this.logger.error("分页查询人员信息失败,原因:", e); + this.logger.error("[PAGE] query failed", e); String errorMessage = this.messageSource.getMessage("53014011", null, LocaleContextHolder.getLocale()); throw new ServiceException("53014011", errorMessage); @@ -600,6 +609,7 @@ public class ImgPersonServiceImpl extends AbstractImagStoreService try { ImgStorePerson personList = this.imgStorePersonMapper.selectByPrimaryKey(param.getId()); if (null != personList) { + this.logger.debug("[DETAIL] personId={} found businessId={}", param.getId(), businessId); if (StringUtils.isNotBlank(personList.getDefaultFloor())) { List ids = Arrays.asList(new String[] {personList.getDefaultFloor()}); QueryZoneForm queryZoneForm = new QueryZoneForm(); @@ -607,7 +617,6 @@ public class ImgPersonServiceImpl extends AbstractImagStoreService queryZoneForm.setIds(ids); CloudwalkResult> zoneDetail = this.zoneFeignClient.findZonelist(queryZoneForm); - this.logger.debug("当前楼层信息{}", JSON.toJSONString(zoneDetail)); if (Objects.equals(zoneDetail.getCode(), "00000000")) { String zoneName = ""; List data = (List) zoneDetail.getData(); @@ -615,6 +624,9 @@ public class ImgPersonServiceImpl extends AbstractImagStoreService zoneName = ((ZoneResult) data.get(i)).getName(); } personList.setFloorName(zoneName); + } else { + this.logger.warn("[DETAIL] personId={} zoneFeignClient.findZonelist failed code={}", + param.getId(), zoneDetail.getCode()); } } AddVehiclePersonForm form = new AddVehiclePersonForm(); @@ -622,6 +634,9 @@ public class ImgPersonServiceImpl extends AbstractImagStoreService CloudwalkResult> vehcleResult = this.vehicleFeignClient.getVehicleIds(form); if (Objects.equals(vehcleResult.getCode(), "00000000")) { personList.setVehicleList((List) vehcleResult.getData()); + } else { + this.logger.debug("[DETAIL] personId={} vehicleFeignClient.getVehicleIds failed code={}", + param.getId(), vehcleResult.getCode()); } List imgStorePersonResults = getImgStorePersonResults(Arrays.asList(personList), businessId); @@ -683,9 +698,11 @@ public class ImgPersonServiceImpl extends AbstractImagStoreService .collect(Collectors.toMap(UserQueryResult::getId, UserQueryResult::getName)); result.setCreateUserName(userNameMap.get(result.getCreateUserId())); result.setLastUpdateUserName(userNameMap.get(result.getLastUpdateUserId())); + } else { + this.logger.warn("[DETAIL] personId={} not found in DB", param.getId()); } } catch (Exception e) { - this.logger.error("查询人员详情失败,原因:", e); + this.logger.error("[DETAIL] personId={} query failed", param.getId(), e); String errorMessage = this.messageSource.getMessage("53014011", null, LocaleContextHolder.getLocale()); throw new ServiceException("53014011", errorMessage);