Package framework.beans.address.entities

Examples of framework.beans.address.entities.AddressObject


        return res;
    }

    @Override
    public int getDefaultDistrict(int streetID, String buildingNumberString) throws ClipsServerException{
        AddressObject object = findEntity(AddressObject.class, streetID);
        if (object.getType().getLevel() != 5) {
            throw new ClipsServerException("Поиск возможен только по улице");
        }
        List<AddressDistrict> adList = findEntityList(AddressDistrict.class, "addressObject", object);
        for (AddressDistrict ad : adList) {
            if (include(ad, buildingNumberString)) {
View Full Code Here


            code = code.substring(0, 5) + "00000000000000";
            f = new Field[]{new Field("kladrCode", code)};
            list =  findEntityList(AddressObject.class, f);
        }
        if (!list.isEmpty()) {
            AddressObject ao = list.get(0);
            addDet.objectId = ao.getId();
            if (c.letter.length() > 0
                    && c.letter.charAt(0) >= '0'
                    && c.letter.charAt(0) <= '9') {
                addDet.building = c.house + "/" + c.letter;
            } else {
View Full Code Here

        List<AddressObject> addressList = findEntityList(AddressObject.class, f);

        //Мап потомков
        HashMap<AddressObject, HashSet<AddressObject>> childrenMap = new HashMap<AddressObject, HashSet<AddressObject>>();
        for (AddressObject addressObject : addressList) {
            AddressObject parent = addressObject.getParent();
            if (parent != null) {
                HashSet<AddressObject> children = childrenMap.get(parent);
                if (children == null) {
                    children = new HashSet<AddressObject>();
                    childrenMap.put(parent, children);
                }
                children.add(addressObject);
            }
        }

        //Сет ID записанных улиц для избежания дублирования
        HashSet<Integer> streetSet = new HashSet<Integer>();
        for (int i = 0; i < addressList.size(); i++) {
            if ((i % 100) == 0) {
                System.out.println("Выполнено " + i/((float)addressList.size())*100 + "%");
            }
            AddressObject it = addressList.get(i);

            while (it != null) {
                if (it.getType().getLevel() == 5) {
                    break;
                }
                it = it.getParent();
            }
            if (it != null && it.getType().getLevel() == 5 && !streetSet.contains(it.getId())) {
                streetSet.add(it.getId());
                if (maxLength < it.getTitle().length()) {
                    maxLength = it.getTitle().length();
                    System.out.println("maxLength=" + maxLength);
                    System.out.println("title = '" + it.getTitle() + "'");
                }
                HashSet<AddressObject> children = childrenMap.get(it);
                if (children != null && children.size() != 0) {
                    //создаем несколько записей
                    for (AddressObject chield : children) {
                        AddressDistrict addressDistrict = new AddressDistrict();
                        addressDistrict.setTitle(chield.getTitle());
                        addressDistrict.setAddressObject(it);
                        int pos = Math.abs(chield.getTitle().hashCode()) % districtList.size();
                        addressDistrict.setDistrict(districtList.get(pos));
                        manager.persist(addressDistrict);
                    }
                } else {
                    //создаем новую запись
                    AddressDistrict addressDistrict = new AddressDistrict();
                    addressDistrict.setTitle("");
                    addressDistrict.setAddressObject(it);
                    int pos = Math.abs(it.getTitle().hashCode()) % districtList.size();
                    addressDistrict.setDistrict(districtList.get(pos));
                    manager.persist(addressDistrict);
                }
            }
        }
View Full Code Here

            if (rd.pol_num.equals(Polis.FICTIVE_POLIS_NUMBER)) {
                rd.pol_num = "";
                rd.pol_ser = "";
            }
            if (address != null) {
                AddressObject country = address.getAddressObject();
                while (country.getParent() != null) {
                    country = country.getParent();
                }
                rd.c_oksm = country.getKladrCode();
            } else {
                //Если указан российский пасспорт считаем что гражданство российское
                if (doc != null && doc.getDoctype().getId() == ClientDocumentType.TYPE_PASSPORT_RF) {
                    rd.c_oksm = "643";
                } else {
                    rd.c_oksm = "";
                }
            }
            rd.type_doc = doc != null ? doc.getDoctype().getId() : 0;
            rd.doc_ser = doc != null ? doc.getSeries() : "";
            rd.doc_num = doc != null ? doc.getNumber() : "";
            //Обрезание до 20 символов
            if (rd.doc_num.length() > 20) {
                rd.doc_num = rd.doc_num.substring(0, 20);
            }
           
            rd.ins_id_ar = polis.getRegionCode().getId();
            rd.id_ins_org = polis.getInsurer().getId();
            if (address != null) {
                rd.kladr = address.getAddressObject().getKladrCode();
//                rd.zip = address.getAddressObject().getPostIndex();
            } else {
                rd.kladr = "";
//                rd.zip = 0;
            }
            if (address != null) {
                //Субъект РФ
                AddressObject srf = address.getAddressObject();
                while (srf.getType().getLevel() != 1) {
                    srf = srf.getParent();
                }
                rd.area = srf.getId();
            } else {
                rd.area = 0;
            }
            /** REGION на уровне 5 находятся улицы - берем 4 уровень смотрим
             * если это не деревня, значит это город - берем его.
             * если это деревня, то она лежит в каком-то районе берем значит на 1 уровень выше*/
            if (address != null) {
                AddressObject reg = address.getAddressObject();
                while (reg.getType().getLevel() >= 5) {
                    reg = reg.getParent();
                }
                if (reg.getType().isVillage()) {
                    rd.region = reg.getParent().getTitle();
                    rd.type_item = reg.getParent().getType().getId();
                } else {
                    rd.region = reg.getTitle();
                    rd.type_item = reg.getType().getId();
                }
            } else {
                rd.region = "";
            }
            //Районы городов отсутствуют в кладре - надо прикрутить
            rd.reg_city = "";
            if (address != null) {
                AddressObject item = address.getAddressObject();
                if (item.getType().getLevel() == 5 || item.getType().getLevel() == 6) {
                    if (item.getOkato() > 0) {
                        //У объекта есть окато
                        String okato = fixOkato(item.getOkato());
                        if (okatoMap.containsKey(okato)) {
                            rd.reg_city = okatoMap.get(okato);
                        }
                    } else {
                        /*У объекта нет окато - смотрим у всех детей если первые восемь
                        цифр окато начинаются одинаково то берем окато детей */
                        List<AddressObject> children = findEntityList(AddressObject.class, "parent.id", item.getId());
                        boolean equals = true;
                        String okato = "";
                        for (AddressObject chield : children) {
                            if (chield.getOkato() > 0) {
                                if (okato.isEmpty()) {
                                    okato = fixOkato(chield.getOkato());
                                } else {
                                    if (!okato.equals(fixOkato(chield.getOkato()))) {
                                        equals = false;
                                    }
                                }
                            }
                        }
                        if (equals && !okato.isEmpty() && okatoMap.containsKey(okato)) {
                            rd.reg_city = okatoMap.get(okato);
                        }
                    }
                }
            }

            /** ITEM на уровне 5 находятся улицы - берем 4 уровень смотрим
             * если это деревня то этот итем и нужен
             */
            if (address != null) {
                AddressObject item = address.getAddressObject();
                while (item.getType().getLevel() >= 5) {
                    item = item.getParent();
                }
                if (item.getType().isVillage()) {
                    rd.item = item.getTitle();
                    rd.type_item = item.getType().getId();
                } else {
                    rd.item = "";
                }
            } else {
                rd.item = "";
                rd.type_item = 0;
            }

            /** STREET на последнем уровне может находиться не улица а квартал,
             * поэтому идем вверх до 5 уровня */
            AddressObject street = null;
            if (address != null) {
                street = address.getAddressObject();
                while (street.getType().getLevel() > 5) {
                    street = street.getParent();
                }
            }
            if (street != null && street.getType().getLevel() == 5) {
                rd.street = street.getTitle();
                Integer typeUl = street.getType().getTypeUl();
                rd.type_ul = typeUl == null ? 14 : typeUl;
            } else {
                rd.street = "";
                rd.type_ul = 0;
            }
View Full Code Here

                    data.docSN = fc.getDocumentSN();
                }

                Address add = client.getAddress();
                if (add != null) {
                    AddressObject aObj = add.getAddressObject();
                    String okatoS = Long.toString(aObj.getOkato());
                    if (okatoS.length() > 5) {
                        okatoS = okatoS.substring(0, 5);
                    }
                    int okatoI = Integer.parseInt(okatoS);
                    data.okatoReg = okatoI;
View Full Code Here

TOP

Related Classes of framework.beans.address.entities.AddressObject

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.