Commit d3821d2f by 林永健

refactor(digitalmanagement): 优化员工信息查询逻辑

- 去除轻改模板和督导查询的条件判断,统一通过staffRecordMapper获取员工信息
1 parent c18875f8
...@@ -274,37 +274,17 @@ public class DigitalManagementTemplateService { ...@@ -274,37 +274,17 @@ public class DigitalManagementTemplateService {
p -> DigitalManagementStaffInfoDTO.buildByMerchantStaff(p), p -> DigitalManagementStaffInfoDTO.buildByMerchantStaff(p),
(p1, p2) -> p2)); (p1, p2) -> p2));
}else { }else {
boolean isLightChangeTemplate = staffRecordService.isLightChangeTemplate(templateDTO.getCode()); DigitalManagementStaffRequestDTO staffRequestDTO = new DigitalManagementStaffRequestDTO();
// 轻改模板:查所有驻店 staffRequestDTO.setStaffUuidList(staffUuids);
if (isLightChangeTemplate) { List<DigitalManagementStaffResponseDTO> staffResponseDTOS = staffRecordMapper.selectStaffInfo(staffRequestDTO);
DigitalManagementStaffRequestDTO staffRequestDTO = new DigitalManagementStaffRequestDTO(); if (CollectionUtils.isEmpty(staffResponseDTOS)) {
staffRequestDTO.setStaffUuidList(staffUuids); log.error("获取轻改驻店员工信息失败! req:{}", staffRequestDTO);
List<DigitalManagementStaffResponseDTO> staffResponseDTOS = staffRecordMapper.selectStaffInfo(staffRequestDTO);
if (CollectionUtils.isEmpty(staffResponseDTOS)) {
log.error("获取轻改驻店员工信息失败! req:{}", staffRequestDTO);
return new HashMap<>();
}
return staffResponseDTOS.stream()
.collect(Collectors.toMap(
p -> p.getStaffUuid(),
p -> new DigitalManagementStaffInfoDTO(p.getStaffUuid(), p.getStaffName(), p.getStaffPhone(), p.getMerchantId(), p.getMerchantName()),
(p1, p2) -> p2));
}
// 驻店管理查督导
ShopMerchantDirectorConfigDTO req = ShopMerchantDirectorConfigDTO.builder()
.directorTypes(Lists.newArrayList(DirectorTypeEnum.AREA_SUPERVISION_1_1.getValue(),DirectorTypeEnum.AREA_SUPERVISION_2_1.getValue()))
.directorUserIdList(staffUuids)
.build();
RpcResponse<List<ShopMerchantDirectorConfigDTO>> staffRes = shopMerchantDirectorConfigRemote.list(req);
if (staffRes.isFailed() || CollectionUtils.isEmpty(staffRes.getResult())) {
log.error("获取员工信息失败! req:{},msg:{}", req, staffRes.getMessage());
return new HashMap<>(); return new HashMap<>();
} }
return staffRes.getResult().stream() return staffResponseDTOS.stream()
.filter(p -> StringUtils.hasLength(p.getDirectorUserId()) && staffUuids.contains(p.getDirectorUserId()))
.collect(Collectors.toMap( .collect(Collectors.toMap(
p -> p.getDirectorUserId(), p -> p.getStaffUuid(),
p -> new DigitalManagementStaffInfoDTO(p.getDirectorUserId(), p.getDirectorName(), p.getDirectorPhone(), p.getMerchantId(), p.getMerchantName()), p -> new DigitalManagementStaffInfoDTO(p.getStaffUuid(), p.getStaffName(), p.getStaffPhone(), p.getMerchantId(), p.getMerchantName()),
(p1, p2) -> p2)); (p1, p2) -> p2));
} }
} }
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!