Package beans.contract.entity

Examples of beans.contract.entity.Polis


       
        List<Polis> ps = findEntityList(Polis.class, "client", entity);
        List<PolisDetails> res = new ArrayList<PolisDetails>();
        Iterator<Polis> i = ps.iterator();
        while (i.hasNext()) {
            Polis j = i.next();
            res.add(j.getDetails((RightChecker) this));
        }
        return res;
    }
View Full Code Here


     * @return
     * @throws generic.ClipsServerException
     */
    @Override
    public PolisDetails getPolisOMI() throws ClipsServerException {
        Polis polis = findPolisOMI(getExistentEntity(), manager);
        if (polis != null) {
            return polis.getDetails(this);
        } else {
            return null;
        }
    }
View Full Code Here

     * @param value
     * @throws generic.ClipsServerException
     */
    @Override
    public ModificationInfo setPolisOMI(PolisDetails polisDetails) throws ClipsServerException {
        Polis polis = findPolisOMI(getExistentEntity(), manager);
        ArrayList<AuditDetails> auditDetailsList = new ArrayList<AuditDetails>(2);
        if (polis != null && polisDetails.id == 0) {
            //замена полиса
            AuditDetails auditRemovePolis = removePolisOMI(polis);
            auditDetailsList.add(auditRemovePolis);
            polis = null;
        }
        if (polis == null) {
            //Создание полиса - либо небыло либо был, но заменяется
            polis = new Polis();
        }
        //и в любом случае заполнение и сохранение
        AuditDoc<Polis> auditDoc = new AuditDoc<Polis>(polis, getCollaborator());
        fillPolisOMI(polis, polisDetails);
        saveEntity(polis);
        if (auditDoc.check(polis)) {
            AuditDetails auditChangePolis = persistAudit(auditDoc);
            auditDetailsList.add(auditChangePolis);
        }
        return new ModificationInfo(polis.getId(), auditDetailsList);
    }
View Full Code Here

        Iterator iterator = query.getResultList().iterator();
        while(iterator.hasNext()) {
            ProfcheckupContractChunk chunk = new ProfcheckupContractChunk();
            Object[] objects = (Object[]) iterator.next();
           
            Polis pol = (Polis)objects[0];
            DangerJob d = (DangerJob)objects[1];

            chunk.danger = d.getDetails((RightChecker) this);
            chunk.polis = pol.getDetails((RightChecker) this);
            chunk.contract = pol.getContract().getDetails((RightChecker) this);
            chunk.client = pol.getClient().getDetails((RightChecker) this);
            System.out.println("danger: " + chunk.danger.dangerId + " job: " + chunk.danger.jobId + " polis: " + chunk.polis.id + " contract: " + chunk.contract.id + " client: " + pol.getClient().getFio());
            list.add(chunk);
        }       
        return list;
    }
View Full Code Here

            Date current = new Date();
            disease.setCreated(current);//дата по первому созданию
            disease.setDateReg(current);
        }

        Polis polis = findEntity(Polis.class, itemChunk.polisID);
        Integer clientID = polis.getClient().getId();
        Field[] f = {new Field("client.id", clientID)};
        Iterator it = findEntityList(Emc.class, f).iterator();
        if (emcMap.get(clientID) == null) {//проверим в кеше
            Emc emc;
            if (it.hasNext()) {
                emc = (Emc) it.next();
            } else {
                throw new EDataIntegrity("у пациента " + polis.getClient().getSurname() + " " +
                        polis.getClient().getName() + " " + polis.getClient().getPathronymic() +
                        " нет медицинской карты");
            }
            emcMap.put(clientID, emc);
        }
        disease.setEmc(emcMap.get(clientID));
        disease.setCollaborator(findEntity(Collaborator.class, getCollaboratorId()));
        if (disease.getId() == 0) {
            manager.persist(disease);//теперь есть заболевание, мона его юзать(или нет?)
        } else {
            disease = manager.merge(disease);
        }
        manager.flush();
        manager.refresh(disease);

        //заполним профчекапитем
        pchItem.setPolis(polis);
        pchItem.setPassed(false);
        pchItem.setDanger(findEntity(Danger.class, itemChunk.dangerId));
        pchItem.setProfcheckup(findEntity(Profcheckup.class, itemChunk.profcheckupId));
        pchItem.setDisease(disease);
        manager.persist(pchItem);//теперь есть профчекапитем, мона его юзать
        manager.flush();
        manager.refresh(pchItem);
        //Пометим список услуг что они с дангерами
        for (int i = 0; i < itemChunk.serviceList.size(); i++) {
            ServiceCheckupChunk scc = itemChunk.serviceList.get(i);
            scc.dangerID = itemChunk.dangerId;
        }
        //создадим услугу
        NewServicesChunk chunk = new NewServicesChunk(disease.getId(),
                                                0,
                                                polis.getDetails(this),
                                                0,
                                                itemChunk.serviceList,
                                                new HashMap<Integer, Integer>());
        csbl.setSession(getSessionId());
        List<AuditDetails> auditDetailsList = csbl.createNewServices(chunk).getAudit();
View Full Code Here

        ArrayList<AuditDetails> target = new ArrayList<AuditDetails>();
        for (Polis polis2 : polisL2) {
            Contract contract = polis2.getContract();
            System.out.println("      CONTRACT id=" + contract.getId() + "  №" + contract.getIndex());
            Polis polis1 = null;
            for (int i = 0; i < polisL1.size(); i++) {
                if (polisL1.get(i).getContract().getId() == contract.getId()) {
                    polis1 = polisL1.get(i);
                    break;
                }
            }
            if (polis1 == null) {
                AuditDoc<Polis> auditPolis = new AuditDoc<Polis>(polis2, getCollaborator());
                polis2.setClient(dst);
                saveEntity(polis2);
                System.out.println("      " + polis2.getId() + "--> client.id=" + polis2.getClient().getId());
                auditPolis.check(polis2);
                target.add(persistAudit(auditPolis));
            } else {
                System.out.println("      p2=" + polis2.getId() + "-->p1=" + polis1.getId());

                int q1 = polisDetQuantity(polis1);
                int q2 = polisDetQuantity(polis2);
                if (q1 < q2) {
                    System.out.println("          polis2 has more details");
                    AuditDoc<Polis> auditPolis = new AuditDoc<Polis>(polis1, getCollaborator());
                    polis1.setNumber(polis2.getNumber());
                    polis1.setSeries(polis2.getSeries());
                    polis1.setInsurer(polis2.getInsurer());
                    polis1.setRegionCode(polis2.getRegionCode());
                    polis1.setTillDate(polis2.getTillDate());
                    polis1.setFromDate(polis2.getFromDate());

                    Address address = polis1.getAddress();
                    polis1.setAddress(polis2.getAddress());
                    manager.remove(address);
                    saveEntity(polis1);
                    auditPolis.check(polis1);
                    target.add(persistAudit(auditPolis));
                } else {
View Full Code Here

        System.out.println("Поиск полисов - контракт " + getExistentEntity().getId());
        List<Polis> polisList = findEntityList(Polis.class, "contract.id", getExistentEntity().getId());
        System.out.println("Маппирование групп - количество полисов " + polisList.size());
        HashMap<PolisUniq, ArrayList<Polis>> polisMap = new HashMap<PolisUniq, ArrayList<Polis>>();
        for (int i = 0; i < polisList.size(); i++) {
            Polis polis = polisList.get(i);
            PolisUniq pu = new PolisUniq(polis);
            ArrayList<Polis> array = polisMap.get(pu);
            if (array == null) {
                array = new ArrayList<Polis>();
                polisMap.put(pu, array);
            }
            array.add(polis);
        }
        ArrayList<ArrayList<Integer>> groupList = new ArrayList<ArrayList<Integer>>();
        Set<PolisUniq> keySet = polisMap.keySet();
        for (Iterator<PolisUniq> it = keySet.iterator(); it.hasNext();) {
            PolisUniq polisUniq = it.next();
            ArrayList<Polis> pList = polisMap.get(polisUniq);
            if (pList.size() < 2) {
                it.remove();
            } else {
                ArrayList<Integer> array = new ArrayList<Integer>();
                for (Polis polis : pList) {
                    array.add(polis.getId());
                }
                groupList.add(array);
            }
        }
        System.out.println("Объединение полисов - количество групп " + polisMap.size());
        polisMap = null;
        keySet = null;
        polisList = null;
        System.gc();

        int counter = 0;
        float size = groupList.size();
        for (ArrayList<Integer> array : groupList) {
            counter ++;
            System.out.println("Выполнено " + counter/size*100 + "%");
            if (array.size() > 1) {
                //Объединение полисов
                Integer mainID = null;
                for (Integer polisID : array) {
                    if (mainID == null || polisID > mainID) {
                        mainID = polisID;
                    }
                }
                Polis main = findEntity(Polis.class, mainID);
                boolean inTrash = main.isTrash();
                for (Integer polisID : array) {
                    if (polisID != mainID) {
                        //Перевязка ссылок
                        Polis polis = findEntity(Polis.class, polisID);
                        if (!polis.isTrash()) {
                            inTrash = false;
                        }
                        List<ServiceRender> serrenList = findEntityList(ServiceRender.class, "polis.id", polisID);
                        for (int i = 0; i < serrenList.size(); i++) {
                            ServiceRender serviceRender = serrenList.get(i);
                            serviceRender.setPolis(main);
                            saveEntity(serviceRender);
                        }
                        List<ProfcheckupItem> profCheckupList = findEntityList(ProfcheckupItem.class, "polis.id", polisID);
                        for (int i = 0; i < profCheckupList.size(); i++) {
                            ProfcheckupItem profcheckupItem = profCheckupList.get(i);
                            profcheckupItem.setPolis(main);
                            saveEntity(profcheckupItem);
                        }
                        Address address = polis.getAddress();
                        if (address != null) {
                            removeEntity(address);
                        }
                        removeEntity(polis);
                    }
View Full Code Here

        checkCommandAccessibility(COMMAND_WRITE_MEMBER);

        Contract entity = getExistentEntity();

        ArrayList<AuditDoc> auditDocList = new ArrayList<AuditDoc>();
        Polis polis = null;
        AuditDoc<Polis> auditDoc;
        Address a = new Address();
        if (details.id != 0) {
            polis = findEntity(Polis.class, details.id);
            checkTheSame(polis.getContract());
            int count = getEntityCount(ServiceRender.class, new Field[]{new Field("polis", polis)});
            count += getEntityCount(ProfcheckupItem.class, new Field[]{new Field("polis", polis)});
            if (count > 0) {
                //помещение старого в корзину
                auditDoc = new AuditDoc<Polis>(polis, getCollaborator());
                auditDocList.add(auditDoc);
                polis.setTrash(true);
                saveEntity(polis);
                auditDoc.check(polis);
                //создание нового
                auditDoc = new AuditDoc<Polis>(null, getCollaborator());
                auditDocList.add(auditDoc);
                polis = new Polis();
            }
            else {
                auditDoc = new AuditDoc<Polis>(polis, getCollaborator());
                auditDocList.add(auditDoc);
                a = polis.getAddress();
                if (a == null) {
                    a = new Address();
                }
            }
        }
        else {
            auditDoc = new AuditDoc<Polis>(null, getCollaborator());
            auditDocList.add(auditDoc);
            polis = new Polis();
        }
       
        polis.setClient(findEntity(Client.class, details.clientID));
        polis.setContract(entity);
        polis.setCollaborator(findEntity(Collaborator.class, getCollaboratorId()));
        polis.setMember(details.member);
        polis.setSeries(details.series);
        polis.setNumber(details.number);
        polis.setTillDate(details.tillDate);
        polis.setFromDate(details.fromDate);
        polis.setInsurer(details.insurerID != 0 ? findEntity(Insurer.class, details.insurerID) : null);
        polis.setRegionCode(findEntity(RegionIdCode.class, details.regionCodeId));
      
        AddressDetails ad = details.addressDetail;
        if (ad != null) {
            a.setAddressObject(ad.objectId != 0 ? findEntity(AddressObject.class, ad.objectId) : null);
            a.setBuilding(ad.building);
            a.setFlat(ad.flat);
            saveEntity(a);
            polis.setAddress(a);
        }
        int id = saveEntity(polis);
        auditDoc.check(polis);
        return new ModificationInfo(id, persistAudit(auditDocList));
    }
View Full Code Here

     */
    @Override
    public ModificationInfo removePolis(int id) throws ClipsServerException {
        checkCommandAccessibility(COMMAND_WRITE_MEMBER);
        checkEntityExist();
        Polis polis = findEntity(Polis.class, id);
        checkTheSame(polis.getContract());
        if (getEntityCount(ServiceRender.class,
            new Field[]{new Field("polis", polis)}, "") > 0) {
            throw new EDataIntegrity("Нельзя удалить данного участника договора так как у него уже есть услуги");
        }
        if (getEntityCount(ProfcheckupItem.class,
            new Field[]{new Field("polis", polis)}, "") > 0) {
            throw new EDataIntegrity("Нельзя удалить данного участника договора так как у него уже есть услуги");
        }
        Address address = polis.getAddress();
        if (address != null) {
            removeEntity(address);
        }
        AuditDoc<Polis> auditDoc = new AuditDoc<Polis>(polis, getCollaborator());
        removeEntity(polis);
View Full Code Here

        q.setParameter("srcContractId", src.getId());
        q.setParameter("currentDate", GregorianCalendar.getInstance().getTime());
        List<Polis> polisList = q.getResultList();
        CollaboratorAbstract collab = getCollaborator();
        for (int i = 0; i < polisList.size(); i++) {
            Polis pOld = polisList.get(i);
            if ((i % 100) == 0) {
                System.out.println("Скопировано полисов - " + i + " (" + i*100.0/polisList.size() + "%)");
            }
            AuditDoc<Polis> auditDoc = new AuditDoc<Polis>(null, collab);
            auditDocList.add(auditDoc);
            Polis p = new Polis();
            p.setMember(pOld.getMember());
            p.setSeries(pOld.getSeries());
            p.setNumber(pOld.getNumber());
            p.setClient(pOld.getClient());
            p.setInsurer(pOld.getInsurer());
            p.setRegionCode(pOld.getRegionCode());
            p.setTillDate(pOld.getTillDate());
            p.setFromDate(pOld.getFromDate());
            p.setTrash(pOld.isTrash());
            p.setCollaborator(pOld.getCollaborator());
            p.setContract(dst);
            if (pOld.getAddress() != null) {
                AddressDetails ad = pOld.getAddress().getDetails(this).clone();
                Address a = new Address();
                a.setBuilding(ad.building);
                a.setFlat(ad.flat);
                a.setAddressObject(ad.objectId != 0 ? findEntity(AddressObject.class, ad.objectId) : null);
                manager.persist(a);
                p.setAddress(a);
            }
            saveEntity(p);
            auditDoc.check(p);
        }
    }
View Full Code Here

TOP

Related Classes of beans.contract.entity.Polis

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.