Commit b2051e19 by 林永健

refactor(staff): 提取查询未提交员工逻辑并完善人员信息

- 将staffRecordSummary方法中查询未提交员工逻辑抽取为getUnsubmittedStaffInfo独立方法
- 优化DigitalManagementStaffInfoDTO新增用户手机号字段
- 使用buildByMerchantStaff方法统一构造DigitalManagementStaffInfoDTO对象
- 修正模板服务中人员信息映射以包含手机号信息
- 保持原有业务逻辑不变,提升代码复用和可读性
1 parent 0ecabf07
package cn.com.glsx.dj.mindworkplate.dto.digitalmanagement;
import cn.com.glsx.merchants.model.response.MerchantStaffResponse;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
......@@ -18,10 +19,16 @@ public class DigitalManagementStaffInfoDTO implements Serializable {
@ApiModelProperty(notes="人员名称")
private String userName;
@ApiModelProperty(notes="人员手机号")
private String userPhone;
@ApiModelProperty(notes="门店号")
private Integer merchantId;
@ApiModelProperty(notes="门店名称")
private String merchantName;
public static DigitalManagementStaffInfoDTO buildByMerchantStaff(MerchantStaffResponse p) {
return new DigitalManagementStaffInfoDTO(p.getUuid(), p.getStaffName(), p.getStaffPhone(), p.getMerchantId(), p.getMerchantName());
}
}
\ No newline at end of file
......@@ -174,27 +174,8 @@ public class DigitalManagementStaffRecordService {
}
public List<DigitalManagementStaffRecordSummaryDTO> staffRecordSummary(DigitalManagementStaffRecordDTO dto) {
int totalDay = DateUtils.diffDate(dto.getStartTime(), dto.getEndTime()) + 1;
templateService.fetchTemplateCode(dto);
// 查询模板关联员工
Collection<DigitalManagementStaffInfoDTO> staffInfos = templateService.templateStaffRefList(dto);
if (CollectionUtils.isEmpty(staffInfos)) {
return Lists.newArrayList();
}
// 查询今日提交的员工进行过滤,得到未提交的员工
List<DigitalManagementStaffRecordDTO> staffRecordList = staffRecordMapper.findCondition(dto);
if (CollectionUtils.isNotEmpty(staffRecordList)) {
// 判断已提交的员工是否满足时间范围内所有日报都提交
Map<String, List<String>> existRecordUuids = staffRecordList.stream()
.collect(Collectors.groupingBy(
p -> p.getStaffUuid(),
Collectors.mapping(p -> DateUtils.formatDate(p.getCreatedDate(), DateUtils.DEFAULT_DATE_FORMAT4), Collectors.toList())
));
log.info("已提交员工:{}", existRecordUuids);
staffInfos = staffInfos.stream()
.filter(p -> !existRecordUuids.containsKey(p.getUserId()) || existRecordUuids.get(p.getUserId()).size() < totalDay)
.collect(Collectors.toList());
}
// 查询未提交员工
Collection<DigitalManagementStaffInfoDTO> staffInfos = getUnsubmittedStaffInfo(dto);
// 今日未提交员工为空,则返回
if (CollectionUtils.isEmpty(staffInfos)) {
return Lists.newArrayList();
......@@ -222,6 +203,34 @@ public class DigitalManagementStaffRecordService {
return res;
}
/**
* 查询未提交员工
*/
public Collection<DigitalManagementStaffInfoDTO> getUnsubmittedStaffInfo(DigitalManagementStaffRecordDTO dto) {
int totalDay = DateUtils.diffDate(dto.getStartTime(), dto.getEndTime()) + 1;
templateService.fetchTemplateCode(dto);
// 查询模板关联员工
Collection<DigitalManagementStaffInfoDTO> staffInfos = templateService.templateStaffRefList(dto);
if (CollectionUtils.isEmpty(staffInfos)) {
return Lists.newArrayList();
}
// 查询今日提交的员工进行过滤,得到未提交的员工
List<DigitalManagementStaffRecordDTO> staffRecordList = staffRecordMapper.findCondition(dto);
if (CollectionUtils.isNotEmpty(staffRecordList)) {
// 判断已提交的员工是否满足时间范围内所有日报都提交
Map<String, List<String>> existRecordUuids = staffRecordList.stream()
.collect(Collectors.groupingBy(
p -> p.getStaffUuid(),
Collectors.mapping(p -> DateUtils.formatDate(p.getCreatedDate(), DateUtils.DEFAULT_DATE_FORMAT4), Collectors.toList())
));
log.info("已提交员工:{}", existRecordUuids);
staffInfos = staffInfos.stream()
.filter(p -> !existRecordUuids.containsKey(p.getUserId()) || existRecordUuids.get(p.getUserId()).size() < totalDay)
.collect(Collectors.toList());
}
return staffInfos;
}
public List<Date> mySubmittedDateRecord(SubmittedDateRequestDTO request) {
return staffRecordMapper.mySubmittedDateRecord(request.getUuid(), request.getSDate(), request.getEDate());
......
......@@ -266,7 +266,7 @@ public class DigitalManagementTemplateService {
.filter(p -> StringUtils.hasLength(p.getUuid()) && staffUuids.contains(p.getUuid()))
.collect(Collectors.toMap(
p -> p.getUuid(),
p -> new DigitalManagementStaffInfoDTO(p.getUuid(), p.getStaffName(), p.getMerchantId(), p.getMerchantName()),
p -> DigitalManagementStaffInfoDTO.buildByMerchantStaff(p),
(p1, p2) -> p2));
}else {
// 驻店管理查督导
......@@ -281,7 +281,10 @@ public class DigitalManagementTemplateService {
}
return staffRes.getResult().stream()
.filter(p -> StringUtils.hasLength(p.getDirectorUserId()) && staffUuids.contains(p.getDirectorUserId()))
.collect(Collectors.toMap(p -> p.getDirectorUserId(), p -> new DigitalManagementStaffInfoDTO(p.getDirectorUserId(), p.getDirectorName(), p.getMerchantId(), p.getMerchantName()), (p1, p2) -> p2));
.collect(Collectors.toMap(
p -> p.getDirectorUserId(),
p -> new DigitalManagementStaffInfoDTO(p.getDirectorUserId(), p.getDirectorName(), p.getDirectorPhone(), p.getMerchantId(), p.getMerchantName()),
(p1, p2) -> p2));
}
}
......@@ -452,7 +455,7 @@ public class DigitalManagementTemplateService {
}
return staffResponse.getResult().stream()
.filter(p -> StringUtils.hasLength(p.getUuid()))
.map(p -> new DigitalManagementStaffInfoDTO(p.getUuid(), p.getStaffName(), p.getMerchantId(), p.getMerchantName()))
.map(p -> DigitalManagementStaffInfoDTO.buildByMerchantStaff(p))
.collect(Collectors.toList());
}
......@@ -465,7 +468,7 @@ public class DigitalManagementTemplateService {
}
return staffResponse.getResult().stream()
.filter(p -> StringUtils.hasLength(p.getMentorUuid()))
.map(i -> new DigitalManagementStaffInfoDTO(i.getMentorUuid(), i.getMentorName() + "(" + i.getMerchantName() + ")", i.getMerchantId(), i.getMerchantName()))
.map(i -> new DigitalManagementStaffInfoDTO(i.getMentorUuid(), i.getMentorName() + "(" + i.getMerchantName() + ")", i.getMentorPhone(), i.getMerchantId(), i.getMerchantName()))
.collect(Collectors.toList());
}
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!