Package framework.beans.address.entities

Examples of framework.beans.address.entities.Address


    return target;
  }

  @Override
  public boolean filterItem(Object[] data, int startID) {
    Address          addres = (Address) data[startID];
    if (addres == null){
      addres = (Address) data[startID + 1];
    }
    if (addres == null){
      return false;
    }
    return addres.getAddressObject().isCountrySide();
  }
View Full Code Here


        sortResult(resultList);
        List<RegisterData> target = new ArrayList<RegisterData>(resultList.size());
        for (ServiceRender sr : resultList) {
            RegisterData rd = new RegisterData();
            Client client = sr.getPolis().getClient();
            Address address = sr.getPolis().getAddress();
            if (address == null) {
                address = client.getAddress();
            }
            rd.id = sr.getId();
            rd.uuid = sr.getUuid();
            //rd.depart = sr.getFunctions().getReceptionType().getId();
            rd.history = sr.getDisease().getEmc().getNumber();
            if (rd.history == null) {
                rd.history = "";
            }
            rd.fam = client.getSurname() == null ? 0 : client.getSurname().getId();
            rd.nam = client.getName() == null ? 0 : client.getName().getId();
            rd.fnam = client.getPathronymic() == null ? 0 : client.getPathronymic().getId();
            rd.bday = client.getBorn();
            rd.sex = client.getSex().getId();
            rd.status = client.getSocialStatus() == null ? 0 : client.getSocialStatus().getId();
            Client representative = null;
            if (sr.getPolis().getNumber().equals(Polis.FICTIVE_POLIS_NUMBER)) {
                representative = client.getRepresentative();
            }

            ClientDocument doc;
            Polis polis;
            if (representative != null) {
                rd.p_status = client.getRepresentativeStatus().getId();
                rd.p_fam = representative.getSurname() == null ? 0 : representative.getSurname().getId();
                rd.p_nam = representative.getName() == null ? 0 : representative.getName().getId();
                rd.p_fnam = representative.getPathronymic() == null ? 0 : representative.getPathronymic().getId();
                rd.pred = 1;
                doc = representative.getClientDocument();
                polis = ClientBean.findPolisOMI(representative, manager);
            } else {
                rd.p_status = 0;
                rd.p_fam = 0;
                rd.p_nam = 0;
                rd.p_fnam = 0;
                rd.pred = 0;
                doc = client.getClientDocument();
                polis = sr.getPolis();
            }
            rd.pol_ser = polis.getSeries();
            rd.pol_num = polis.getNumber();
            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;
            }
            if (address!= null && address.getBuilding() != null && !address.getBuilding().trim().isEmpty()) {
                String building = address.getBuilding().trim();
                rd.house = Converter.getBuildingNumber(building);
                String corp = Converter.getBuildingCorpus(building);
                String letter = Converter.getBuildingLetter(building);
                if (!corp.isEmpty() && !letter.isEmpty() ) {
                    rd.liter = corp + "/" + letter;
                } else {
                    rd.liter = letter + corp;
                }
                rd.flat = address.getFlat();
            } else {
                rd.house = "";
                rd.liter = "";
                rd.flat = "";
            }
View Full Code Here

        lpu.setClinicType(findEntity(ClinicType.class, d.clinicType));
        lpu.setInsurer(findEntity(Insurer.class, d.insurer));
        lpu.setSubdivisionCode(d.subdivisionCode);
        lpu.setBranch(d.branch);

        Address address = lpu.getAddress();
        AddressDetails ad = d.addressDetails;
        if (ad != null && ad.objectId != 0) {
            if (address == null){
                address = new Address();
            }
            address.setAddressObject(findEntity(AddressObject.class, ad.objectId));
            address.setBuilding(ad.building);
            address.setFlat(ad.flat);
            saveEntity(address);
            lpu.setAddress(address);
        }else{
            throw new EDataIntegrity("Не указан адрес");
        }
View Full Code Here

            target.put("id_ogrn_company_code", lpu.getOgrn() != null ? lpu.getOgrn() : "");
            target.put("id_company_by_okpo", lpu.getOkpo() != null ? lpu.getOkpo() : "");
      target.put("id_industry_by_okonh", lpu.getOkonh() != null ? lpu.getOkonh() : "");
      target.put("id_action_type_by_okved", lpu.getOkved() != null ? lpu.getOkved() : "");

            Address address = lpu.getAddress();
            if (address != null && address.getAddressObject() != null) {
                target.put("id_contry_by_okato", Long.toString(lpu.getAddress().getAddressObject().getOkato()));
            }
      target.put("id_department_by_okogu", lpu.getOkogu() != null ? lpu.getOkogu() : "");
      target.put("id_type_of_company_by_okopf", lpu.getOkopf() != null ? lpu.getOkopf() : "");
      target.put("id_pattern_of_ownership_okfc", lpu.getOkfc() != null ? lpu.getOkfc() : "");
View Full Code Here

                        data.docTypeID = type.getExtKey();
                    }
                    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);
View Full Code Here

       
        AddressDetails add = details.address;
        if(add == null || add.objectId == 0) {
            enterprise.setAddress(null);
        }else{
            Address address = enterprise.getAddress();
            if (address == null) {
                address = new Address();
            }
            saveAddress(address, details.address);
            enterprise.setAddress(address);
        }
       
View Full Code Here

TOP

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

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.