fix merging fids and phones
This commit is contained in:
parent
ae7260d790
commit
769fabf79a
1 changed files with 29 additions and 0 deletions
|
|
@ -5,6 +5,7 @@ import lombok.Getter;
|
|||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.jdbc.core.namedparam.MapSqlParameterSource;
|
||||
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;
|
||||
|
|
@ -90,6 +91,34 @@ public class PhoneService2 {
|
|||
return phoneFidMap;
|
||||
}
|
||||
|
||||
private Map<Integer, PhoneFidMap> merger(List<PhoneFidMap> subjects, List<FidsData> phonesByFid) {
|
||||
Map<Integer, PhoneFidMap> phoneFidMap = new HashMap<>();
|
||||
Iterator<FidsData> iterator = phonesByFid.iterator();
|
||||
String lastUniquePhone = null;
|
||||
FidsData fidsData = null;
|
||||
for (PhoneFidMap phoneFid : subjects) {
|
||||
String normalizedPhone = 9 + phoneFid.getPhone();
|
||||
while (iterator.hasNext()) {
|
||||
fidsData = iterator.next();
|
||||
if (StringUtils.isNotEmpty(lastUniquePhone) && lastUniquePhone.equals(fidsData.getPhone())) {
|
||||
iterator.remove();
|
||||
continue;
|
||||
}
|
||||
if (fidsData.getPhone().equals(normalizedPhone) || normalizedPhone.equals(lastUniquePhone)) {
|
||||
lastUniquePhone = fidsData.getPhone();
|
||||
iterator.remove();
|
||||
break;
|
||||
}
|
||||
lastUniquePhone = fidsData.getPhone();
|
||||
break;
|
||||
}
|
||||
if (fidsData != null && normalizedPhone.equals(lastUniquePhone)) {
|
||||
phoneFidMap.put(fidsData.getFid(), phoneFid);
|
||||
}
|
||||
}
|
||||
return phoneFidMap;
|
||||
}
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@AllArgsConstructor
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue