feat: add comprehensive logging to ImgPersonServiceImpl external calls and error paths

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
This commit is contained in:
hpd840321
2026-05-10 09:50:42 +08:00
parent d8bcc14563
commit f350f318f5
@@ -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<ImgStorePerson> gets = (Page<ImgStorePerson>) this.imgStorePersonMapper.gets(dto);
List<ImgStorePerson> result = gets.getResult();
this.logger.debug("[PAGE] query returned {} persons businessId={}", result.size(), businessId);
List<ImgStorePersonGetResult> imgStorePersonResults =
getImgStorePersonResults(result, context.getCompany().getCompanyId());
Set<String> orgSet = getOrgSet(imgStorePersonResults);
@@ -300,6 +301,9 @@ public class ImgPersonServiceImpl extends AbstractImagStoreService
orgId, orgMap.getOrDefault(orgId, new ArrayList<String>())));
item.setOrganizationComplete(orgCompleteMap);
});
} else {
this.logger.warn("[PAGE] organizationService.getOrg failed code={}",
orgResult.getCode());
}
}
List<String> 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<String> ids = Arrays.asList(new String[] {personList.getDefaultFloor()});
QueryZoneForm queryZoneForm = new QueryZoneForm();
@@ -607,7 +617,6 @@ public class ImgPersonServiceImpl extends AbstractImagStoreService
queryZoneForm.setIds(ids);
CloudwalkResult<List<ZoneResult>> zoneDetail =
this.zoneFeignClient.findZonelist(queryZoneForm);
this.logger.debug("当前楼层信息{}", JSON.toJSONString(zoneDetail));
if (Objects.equals(zoneDetail.getCode(), "00000000")) {
String zoneName = "";
List<ZoneResult> data = (List<ZoneResult>) 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<List<String>> 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<ImgStorePersonGetResult> 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);