Commit a9ebdda5 by 林永健

refactor(digitalmanagement): 优化员工信息查询及模板类型判断

- 修改获取员工信息接口,参数改为传入完整模板DTO对象
- 将部分模板类型判断方法访问权限由private改为public,方便外部调用
- 命名和类型调整,修正员工响应DTO中merchantId类型为Integer
- 新增@Lazy注解注入staffRecordService,避免循环依赖问题
- 增加轻改模板特殊处理逻辑,通过驻店管理表查询员工信息
- 添加日志记录员工信息缺失情况,便于排查数据不全问题
- DTO类DigitalManagementStaffRequestDTO增加@ToString注解,方便调试输出
1 parent fd9de979
...@@ -4,6 +4,7 @@ import io.swagger.annotations.ApiModelProperty; ...@@ -4,6 +4,7 @@ import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Data; import lombok.Data;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
import lombok.ToString;
import java.io.Serializable; import java.io.Serializable;
import java.util.List; import java.util.List;
...@@ -11,6 +12,7 @@ import java.util.List; ...@@ -11,6 +12,7 @@ import java.util.List;
@Data @Data
@NoArgsConstructor @NoArgsConstructor
@AllArgsConstructor @AllArgsConstructor
@ToString
public class DigitalManagementStaffRequestDTO implements Serializable { public class DigitalManagementStaffRequestDTO implements Serializable {
@ApiModelProperty(notes = "员工姓名") @ApiModelProperty(notes = "员工姓名")
......
...@@ -27,7 +27,7 @@ public class DigitalManagementStaffResponseDTO implements Serializable { ...@@ -27,7 +27,7 @@ public class DigitalManagementStaffResponseDTO implements Serializable {
private Integer staffType; private Integer staffType;
@ApiModelProperty(notes = "商户号") @ApiModelProperty(notes = "商户号")
private String merchantId; private Integer merchantId;
@ApiModelProperty(notes = "商户名称") @ApiModelProperty(notes = "商户名称")
private String merchantName; private String merchantName;
......
...@@ -95,7 +95,7 @@ public class DigitalManagementStaffRecordService { ...@@ -95,7 +95,7 @@ public class DigitalManagementStaffRecordService {
} }
// 查询员工信息 // 查询员工信息
List<String> staffUuids = records.stream().map(r -> r.getStaffUuid()).collect(Collectors.toList()); List<String> staffUuids = records.stream().map(r -> r.getStaffUuid()).collect(Collectors.toList());
Map<String, DigitalManagementStaffInfoDTO> staffInfo = templateService.getStaffInfo(staffUuids, condition.getTemplateDTO().getDisplaySummary()); Map<String, DigitalManagementStaffInfoDTO> staffInfo = templateService.getStaffInfo(staffUuids, condition.getTemplateDTO());
records.stream() records.stream()
.filter(r -> staffInfo.containsKey(r.getStaffUuid())) .filter(r -> staffInfo.containsKey(r.getStaffUuid()))
.forEach(r -> r.setStaffName(staffInfo.get(r.getStaffUuid()).getUserName())); .forEach(r -> r.setStaffName(staffInfo.get(r.getStaffUuid()).getUserName()));
...@@ -615,15 +615,15 @@ public class DigitalManagementStaffRecordService { ...@@ -615,15 +615,15 @@ public class DigitalManagementStaffRecordService {
} }
} }
private boolean isRegionalTemplate(String templateCode) { public boolean isRegionalTemplate(String templateCode) {
return templateService.getRegionalTemplateCode().equals(templateCode); return templateService.getRegionalTemplateCode().equals(templateCode);
} }
private boolean isLightChangeTemplate(String templateCode) { public boolean isLightChangeTemplate(String templateCode) {
return templateService.getLightChangeTemplateCode().equals(templateCode); return templateService.getLightChangeTemplateCode().equals(templateCode);
} }
private boolean isDayOffStatusTemplate(String templateCode) { public boolean isDayOffStatusTemplate(String templateCode) {
return isRegionalTemplate(templateCode) || isLightChangeTemplate(templateCode); return isRegionalTemplate(templateCode) || isLightChangeTemplate(templateCode);
} }
......
...@@ -28,6 +28,7 @@ import com.google.common.collect.Lists; ...@@ -28,6 +28,7 @@ import com.google.common.collect.Lists;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.core.env.Environment; import org.springframework.core.env.Environment;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
...@@ -75,6 +76,10 @@ public class DigitalManagementTemplateService { ...@@ -75,6 +76,10 @@ public class DigitalManagementTemplateService {
@Autowired @Autowired
private MerchantStaffRemote merchantStaffRemote; private MerchantStaffRemote merchantStaffRemote;
@Autowired
@Lazy
private DigitalManagementStaffRecordService staffRecordService;
public List<DigitalManagementTemplateDTO> typeList(DigitalManagementTemplateDTO dto) { public List<DigitalManagementTemplateDTO> typeList(DigitalManagementTemplateDTO dto) {
return templateMapper.findAllType(); return templateMapper.findAllType();
} }
...@@ -197,7 +202,7 @@ public class DigitalManagementTemplateService { ...@@ -197,7 +202,7 @@ public class DigitalManagementTemplateService {
? staffUuidList ? staffUuidList
: staffUuidList.stream().filter(p -> dto.getStaffUuidList().contains(p)).collect(Collectors.toList()); : staffUuidList.stream().filter(p -> dto.getStaffUuidList().contains(p)).collect(Collectors.toList());
// 根据督导信息的情况进行排除,并返回督导详情 // 根据督导信息的情况进行排除,并返回督导详情
Map<String, DigitalManagementStaffInfoDTO> staffInfoMap = getStaffInfo(filterStaffUuidList, dto.getDisplaySummary()); Map<String, DigitalManagementStaffInfoDTO> staffInfoMap = getStaffInfo(filterStaffUuidList, dto);
Optional.ofNullable(filterStaffUuidList.stream().filter(p -> !staffInfoMap.containsKey(p)).collect(Collectors.joining(","))) Optional.ofNullable(filterStaffUuidList.stream().filter(p -> !staffInfoMap.containsKey(p)).collect(Collectors.joining(",")))
.filter(StringUtils::hasLength) .filter(StringUtils::hasLength)
.ifPresent(d -> log.info("[{}]督导数据查询缺少记录:{}", dto.getCode(), d)); .ifPresent(d -> log.info("[{}]督导数据查询缺少记录:{}", dto.getCode(), d));
...@@ -251,11 +256,11 @@ public class DigitalManagementTemplateService { ...@@ -251,11 +256,11 @@ public class DigitalManagementTemplateService {
public Map<String, DigitalManagementStaffInfoDTO> getStaffInfo(List<String> staffUuids) { public Map<String, DigitalManagementStaffInfoDTO> getStaffInfo(List<String> staffUuids) {
return getStaffInfo(staffUuids, null); return getStaffInfo(staffUuids, null);
} }
public Map<String, DigitalManagementStaffInfoDTO> getStaffInfo(List<String> staffUuids, Integer queryType) { public Map<String, DigitalManagementStaffInfoDTO> getStaffInfo(List<String> staffUuids, DigitalManagementTemplateDTO templateDTO) {
if (CollectionUtils.isEmpty(staffUuids)) { if (CollectionUtils.isEmpty(staffUuids)) {
return new HashMap<>(); return new HashMap<>();
} }
if (Objects.isNull(queryType) || queryType == 0) { if (Objects.isNull(templateDTO) || templateDTO.getDisplaySummary() == 0) {
// 去账户中心查 // 去账户中心查
RpcResponse<List<MerchantStaffResponse>> staffRes = merchantStaffRemote.selectStaffListByStaffUUID(staffUuids); RpcResponse<List<MerchantStaffResponse>> staffRes = merchantStaffRemote.selectStaffListByStaffUUID(staffUuids);
if (staffRes.isFailed() || CollectionUtils.isEmpty(staffRes.getResult())) { if (staffRes.isFailed() || CollectionUtils.isEmpty(staffRes.getResult())) {
...@@ -269,6 +274,22 @@ public class DigitalManagementTemplateService { ...@@ -269,6 +274,22 @@ 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());
// 轻改模板:查所有驻店
if (isLightChangeTemplate) {
DigitalManagementStaffRequestDTO staffRequestDTO = new DigitalManagementStaffRequestDTO();
staffRequestDTO.setStaffUuidList(staffUuids);
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() ShopMerchantDirectorConfigDTO req = ShopMerchantDirectorConfigDTO.builder()
.directorTypes(Lists.newArrayList(DirectorTypeEnum.AREA_SUPERVISION_1_1.getValue(),DirectorTypeEnum.AREA_SUPERVISION_2_1.getValue())) .directorTypes(Lists.newArrayList(DirectorTypeEnum.AREA_SUPERVISION_1_1.getValue(),DirectorTypeEnum.AREA_SUPERVISION_2_1.getValue()))
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!