// 查询身份证号
private Map<String, String> queryCustomIdNoByCustIds(List<PdmWithholdCollectionInfoDto> mergeWithholdCollections) {
List<String> custIds = mergeWithholdCollections.stream()
.map(PdmWithholdCollectionInfoDto::getCustId)
.distinct()
.collect(Collectors.toList());
List<IdAndNameViewDto> custInfoList = crmCustExternalBusinessHandlerImpl.getCustInfoByCustId(IdsDto.build(custIds));
return custInfoList.stream()
.collect(Collectors.toMap(IdAndNameViewDto::getId,
IdAndNameViewDto::getIdCode, (x1, x2) -> x2));
}
private List<PdmWithholdCollectionInfoDto> mergeWithholdCollectionInfo(List<PdmWithholdCollectionInfoDto> withholdCollectionDtos) {
List<PdmWithholdCollectionInfoDto> originalCollections = withholdCollectionDtos.stream()
.filter(dto -> Objects.equals(dto.getCollectionType(), BusinessConstants.COLLECTION_RENT)
|| Objects.equals(dto.getCollectionType(), BusinessConstants.COLLECTION_RECOVER_ADVANCE))
.collect(Collectors.toList());
Map<String, List<PdmWithholdCollectionInfoDto>> subCollectionMap = withholdCollectionDtos.stream()
.filter(dto -> Objects.equals(dto.getCollectionType(), BusinessConstants.COLLECTION_BREACH_CONTRACT))
.collect(Collectors.groupingBy(PdmWithholdCollectionInfoDto::getOriginalCollectionId));
Map<String, String> originalCollectionIdMap = originalCollections.parallelStream()
.filter(dto -> Objects.equals(dto.getCollectionType(), BusinessConstants.COLLECTION_RENT)
|| Objects.equals(dto.getCollectionType(), BusinessConstants.COLLECTION_RECOVER_ADVANCE))
.collect(Collectors.toMap(PdmWithholdCollectionInfoDto::getCollectionId,
PdmWithholdCollectionInfoDto::getCollectionId,
(v1, v2) -> v1));
originalCollections.forEach(originalCollection -> {
originalCollection.setOriginalCollectionId(originalCollection.getCollectionId());
List<PdmWithholdCollectionInfoDto> subCollectionDtos = subCollectionMap.get(originalCollection.getCollectionId());
if (!CollectionUtils.isEmpty(subCollectionDtos)) {
subCollectionDtos.forEach(subCollectionDto -> originalCollection.setPenalCollectionId(subCollectionDto.getCollectionId())
.setPenalCollectionCheckState(subCollectionDto.getCheckState())
.setPenalCollectionLockState(subCollectionDto.getLockState())
.setAmtCollection(originalCollection.getAmtCollection().add(subCollectionDto.getAmtCollection()))
.setAmtCheck(originalCollection.getAmtCheck().add(subCollectionDto.getAmtCheck())));
}
});
subCollectionMap.forEach((originalCollectionId, dtoList) -> {
if (originalCollectionIdMap.get(originalCollectionId) == null) {
dtoList.forEach(dto -> {
dto.setPenalCollectionId(dto.getCollectionId());
dto.setCollectionType(dto.getPenalOriginalCollectionType());
});
originalCollections.addAll(dtoList);
}
});
// 按照实际应收日期排序
return originalCollections.stream()
.sorted(Comparator.comparing(PdmWithholdCollectionInfoDto::getDateCollectionActual))
.collect(Collectors.toList());
}