List<Object[]> list = query.getResultList();
for (Object[] line: list) {
DloClientUnique dcu = new DloClientUnique();
Integer clientID = (Integer) line[0];
Surname surname = (Surname) line[1];
Name name = (Name) line[2];
Patronymic pathronymic = (Patronymic) line[3];
dcu.surnameID = surname == null ? 0 : surname.getId();
dcu.nameID = name == null ? 0 : name.getId();
dcu.pathronID = pathronymic == null ? 0 : pathronymic.getId();
dcu.dateBorn = (Date) line[4];
dcu.snils = line[5] != null ? ((String) line[5]).trim() : "";
clientMap.put(dcu, clientID);
}
for (FacilityClient fc : facClientList) {
Surname surname = fc.getSurname();
Name name = fc.getName();
Patronymic patronymic = fc.getPathronymic();
Date born = fc.getBorn();
String snils = fc.getSnils();
DloClientUnique dcu = new DloClientUnique();
dcu.surnameID = surname == null ? 0 : surname.getId();
dcu.nameID = name == null ? 0 : name.getId();
dcu.pathronID = patronymic == null ? 0 : patronymic.getId();
dcu.dateBorn = born;
dcu.snils = snils != null ? snils.trim() : "";
Integer id = clientMap.get(dcu);
if (id != null) {
Client client = findEntity(Client.class, id);
PersonalData data = new PersonalData();
data.id = id;
data.snils = snils;
Polis polisOMI = ClientBean.findPolisOMI(client, manager);
if (polisOMI != null) {
clientPolisMap.put(client.getId(), polisOMI);
String polisSN ="";
if (polisOMI.getSeries() != null) {
polisSN = polisOMI.getSeries();
}
if (polisOMI.getNumber() != null) {
polisSN = polisSN + " " + polisOMI.getNumber();
}
data.polisSN = polisSN.trim();
String code = polisOMI.getRegionCode().getTitle();
code += "00000000000000000";
Field[] f = new Field[]{new Field("kladrCode", code)};
List<AddressObject> adrs = findEntityList(AddressObject.class, f);
if (!adrs.isEmpty()) {
String okatoS = Long.toString(adrs.get(0).getOkato());
if (okatoS.length() > 5) {
okatoS = okatoS.substring(0, 5);
}
int okatoI = Integer.parseInt(okatoS);
data.okatoOMC = okatoI;
}
else {
data.okatoOMC = Integer.MIN_VALUE;
}
//TODO ОГРН СМО
}
data.surname = surname != null ? surname.getTitle() : null;
data.name = name != null ? name.getTitle() : null;
data.pathronymic = patronymic != null ? patronymic.getTitle() : null;
Sex sex = client.getSex();
if (sex != null) {
data.sex = client.getSex().getId() == Sex.CLIENT_SEX_MALE ? 'М' : 'Ж';