This commit is contained in:
parent
cdaac1f22e
commit
1e7dc551c2
2 changed files with 97 additions and 2 deletions
|
|
@ -40,7 +40,10 @@ public class PersonServiceV2 {
|
||||||
return new HashMap<>();
|
return new HashMap<>();
|
||||||
}
|
}
|
||||||
List<Id> passports = mapper.findPassportData(fids);
|
List<Id> passports = mapper.findPassportData(fids);
|
||||||
|
return groupPassportsData(passports);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Map<Integer, Id> groupPassportsData(List<Id> passports) {
|
||||||
return passports.stream()
|
return passports.stream()
|
||||||
.filter(this::isDUL)
|
.filter(this::isDUL)
|
||||||
.filter(this::checkLength)
|
.filter(this::checkLength)
|
||||||
|
|
@ -56,7 +59,6 @@ public class PersonServiceV2 {
|
||||||
)
|
)
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Поиск данных по таблицам PHONE_NORM и NAME по списку номеров телефонов
|
* Поиск данных по таблицам PHONE_NORM и NAME по списку номеров телефонов
|
||||||
*
|
*
|
||||||
|
|
@ -129,6 +131,6 @@ public class PersonServiceV2 {
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean checkLength(Id p) {
|
private boolean checkLength(Id p) {
|
||||||
return !("21".equals(p.getIdType2()) && "21".equals(p.getIdType())) || CTUtil.normalizePassport(p).length() == 10;
|
return (!"21".equals(p.getIdType2()) && !"21".equals(p.getIdType())) || CTUtil.normalizePassport(p).length() == 10;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,93 @@
|
||||||
|
package ru.nbch.credit_tracker.service;
|
||||||
|
|
||||||
|
import java.time.LocalDate;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import org.junit.jupiter.api.Assertions;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
import org.junit.jupiter.api.extension.ExtendWith;
|
||||||
|
import org.mockito.junit.jupiter.MockitoExtension;
|
||||||
|
import ru.nbch.credit_tracker.entities.indic.Id;
|
||||||
|
import ru.nbch.credit_tracker.service.indic.PersonServiceV2;
|
||||||
|
|
||||||
|
@ExtendWith(MockitoExtension.class)
|
||||||
|
public class PersonServiceTest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void groupingPassportDataTest() {
|
||||||
|
PersonServiceV2 personServiceV2 = new PersonServiceV2(null);
|
||||||
|
|
||||||
|
List<Id> ids = new ArrayList<>();
|
||||||
|
{
|
||||||
|
Id id = Id.builder()
|
||||||
|
.fid(1)
|
||||||
|
.idType("21")
|
||||||
|
.idNum("111")
|
||||||
|
.serNum("111111")
|
||||||
|
.fileSinceDate(LocalDate.of(2026, 1, 15))
|
||||||
|
.build();
|
||||||
|
ids.add(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
Id id = Id.builder()
|
||||||
|
.fid(1)
|
||||||
|
.idType2("21")
|
||||||
|
.idNum("111")
|
||||||
|
.serNum("111111")
|
||||||
|
.fileSinceDate(LocalDate.of(2026, 1, 15))
|
||||||
|
.build();
|
||||||
|
ids.add(id);
|
||||||
|
}
|
||||||
|
Map<Integer, Id> grouped = personServiceV2.groupPassportsData(ids);
|
||||||
|
Assertions.assertTrue(grouped.isEmpty());
|
||||||
|
|
||||||
|
{
|
||||||
|
Id id = Id.builder()
|
||||||
|
.fid(1)
|
||||||
|
.idType2("21")
|
||||||
|
.idNum("1111")
|
||||||
|
.serNum("111111")
|
||||||
|
.fileSinceDate(LocalDate.of(2026, 1, 15))
|
||||||
|
.build();
|
||||||
|
ids.add(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
grouped = personServiceV2.groupPassportsData(ids);
|
||||||
|
Assertions.assertFalse(grouped.isEmpty());
|
||||||
|
Assertions.assertNotNull(grouped.get(1));
|
||||||
|
|
||||||
|
{
|
||||||
|
Id id = Id.builder()
|
||||||
|
.fid(1)
|
||||||
|
.idType("10")
|
||||||
|
.idType2("100")
|
||||||
|
.idNum("2222")
|
||||||
|
.serNum("222222")
|
||||||
|
.fileSinceDate(LocalDate.of(2026, 1, 15))
|
||||||
|
.build();
|
||||||
|
ids.add(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
grouped = personServiceV2.groupPassportsData(ids);
|
||||||
|
Assertions.assertNotNull(grouped.get(1));
|
||||||
|
Assertions.assertEquals("1111", grouped.get(1).getIdNum());
|
||||||
|
|
||||||
|
{
|
||||||
|
Id id = Id.builder()
|
||||||
|
.fid(2)
|
||||||
|
.idType("10")
|
||||||
|
.idType2("100")
|
||||||
|
.idNum("22222222")
|
||||||
|
.serNum("222222333333")
|
||||||
|
.fileSinceDate(LocalDate.of(2026, 1, 15))
|
||||||
|
.build();
|
||||||
|
ids.add(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
grouped = personServiceV2.groupPassportsData(ids);
|
||||||
|
Assertions.assertNotNull(grouped.get(2));
|
||||||
|
Assertions.assertEquals("22222222", grouped.get(2).getIdNum());
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Add table
Reference in a new issue