Example usage for java.lang Long equals

List of usage examples for java.lang Long equals

Introduction

In this page you can find the example usage for java.lang Long equals.

Prototype

public boolean equals(Object obj) 

Source Link

Document

Compares this object to the specified object.

Usage

From source file:com.viettel.hqmc.DAOHE.FilesDAOHE.java

public Files saveFilesWS(FilesForm createForm) {
    Files bo;//w w  w.java  2  s.  c o m
    Files boRollBack;
    Long filesId = createForm.getFileId();
    //        Boolean isCreateNew;
    Long status = 0L;
    Long announcementId = null;
    Long detailProductId = null;
    Long reIssueFormId = null;
    Long testRegistrationId = null;
    Long productTypeIdOld = null;
    if (createForm.getStatus() != null) {
        status = createForm.getStatus();
    }
    if (filesId != null) {
        String hql = "select dt.productType from DetailProduct dt " + "where "
                + "dt.detailProductId = (select f.detailProductId from Files f where f.fileId =?)";
        Query query = getSession().createQuery(hql);
        query.setParameter(0, filesId);
        List<Long> lstProductType = query.list();
        if (lstProductType.size() > 0) {
            productTypeIdOld = lstProductType.get(0);
        }
    }
    if (filesId == null) {//la them moi            
        bo = createForm.convertToEntity();
    } else {//la sua
        //            isCreateNew = false;
        //            boRollBack = findById(filesId);
        bo = findById(filesId);

        if (status.equals(Constants.FILE_STATUS.EVALUATED_TO_ADD) && bo.getHaveTemp() != null
                && bo.getHaveTemp().equals(1l)) {
            FilesForm cloneForm = getNewCloneFiles(filesId);
            cloneForm.setVersion(getCountVersion(bo.getFileId()));
            bo.setVersion(cloneForm.getVersion());//update version moi nhat cua ho so
            bo.setHaveTemp(null);
            saveFiles(cloneForm);
            //update toan bo process_comment cua lan tham dinh truoc thanh
            ProcessCommentDAOHE pcdhe = new ProcessCommentDAOHE();
            pcdhe.updateVersion(filesId, cloneForm.getVersion());
        }
        bo = createForm.updateToEntity(bo);
    }

    //*Luu thong tin cac form chinh cua ho so
    if (createForm.getAnnouncement() != null) {
        Announcement ann = createForm.getAnnouncement().convertToEntity();
        ann.setIsTemp(0L);
        if (ann.getAnnouncementId() != null) {
            session.merge(ann);
        } else {
            session.save(ann);
        }
        announcementId = ann.getAnnouncementId();
    }

    if (createForm.getDetailProduct() != null) {
        DetailProduct detail = createForm.getDetailProduct().convertToEntity();
        detail.setIsTemp(0L);
        if (detail.getDetailProductId() != null) {
            session.merge(detail);
        } else {
            session.save(detail);
        }
        detailProductId = detail.getDetailProductId();
    }

    if (createForm.getReIssueForm() != null) {
        ReIssueForm reissue = createForm.getReIssueForm().convertToEntity();
        if (reissue.getReIssueFormId() != null) {
            session.merge(reissue);
        } else {
            session.save(reissue);
        }
        reIssueFormId = reissue.getReIssueFormId();
    }

    if (createForm.getTestRegistration() != null) {
        TestRegistration testReg = createForm.getTestRegistration().convertToEntity();
        if (testReg.getTestRegistrationId() != null) {
            getSession().merge(testReg);
        } else {
            getSession().save(testReg);
        }
        testRegistrationId = testReg.getTestRegistrationId();
    }
    bo.setAnnouncementId(announcementId);
    bo.setDetailProductId(detailProductId);
    bo.setReIssueFormId(reIssueFormId);
    bo.setTestRegistrationId(testRegistrationId);
    bo.setDisplayStatus(getFileStatusName(bo.getStatus()));
    if (bo.getFileId() != null) {
        //khi sua xoa toan bo chu ki CA
        bo.setStaffRequest("");
        bo.setLeaderRequest("");
        bo.setLeaderStaffRequest("");
        bo.setContentSigned("");
        bo.setUserSigned("");
        getSession().update(bo);
    } else {
        //update 15092015 binhnt cap nhat lay ma ho so
        if (createForm.getIsTemp() != null && createForm.getIsTemp().equals(Constants.ACTIVE_STATUS.ACTIVE)) {
        } else {
            bo.setFileCode(getNewFileCode(createForm.getFileType()));
        }
        getSession().save(bo);
    }

    filesId = bo.getFileId();

    saveMainlytarget(createForm.getLstMainlyTarget(), filesId);
    saveProductTarget(createForm.getLstBioTarget(), filesId, Constants.PRODUCT_TARGET_TYPE.BIO,
            createForm.getStatus());
    saveProductTarget(createForm.getLstHeavyMetal(), filesId, Constants.PRODUCT_TARGET_TYPE.HEAVY_METAL,
            createForm.getStatus());
    saveProductTarget(createForm.getLstChemical(), filesId, Constants.PRODUCT_TARGET_TYPE.CHEMICAL,
            createForm.getStatus());
    saveAttachs(createForm.getLstAttachs(), filesId, createForm.getLstAttachLabel());
    saveQualityPlan(createForm.getLstQualityControl(), filesId);
    saveProductInFile(createForm.getLstProductInFile(), filesId);// Luu thong tin danh sach san pham nhap khau cho khach san 4 sao        

    try {//lu ph thm nh h s
        ProcedureDAOHE pdheCheck = new ProcedureDAOHE();
        Procedure pro = pdheCheck.getProcedureTypeFee(createForm.getFileType());
        if (pro != null && (pro.getTypeFee() == 2 || pro.getTypeFee() == 3)
                && !pro.getDescription().equals(Constants.FILE_DESCRIPTION.ANNOUNCEMENT_4STAR)
                && !pro.getDescription().equals(Constants.FILE_DESCRIPTION.ANNOUNCEMENT_FILE05)) {
            if (!saveFeeForWS(filesId, createForm.getFileType(), null, pro, productTypeIdOld)) {
                return null;
            }
        } //Sua doi sua cong bo. Tao mot ban ghi trong FeePaymentInfo de VanThu nhin thay hoso cua loai nay
        else if (pro != null && pro.getDescription().equals(Constants.FILE_DESCRIPTION.ANNOUNCEMENT_FILE05)) {
            if (!saveFeeChangesAfterAnnounced(filesId, createForm.getFileType())) {
                return null;
            }
        } else if (pro != null && pro.getDescription().equals(Constants.FILE_DESCRIPTION.ANNOUNCEMENT_4STAR)) {
            if (!saveFee4StarForWS(filesId, createForm.getFileType())) {
                return null;
            }
        } else if (pro != null && pro.getDescription().equals(Constants.FILE_DESCRIPTION.ANNOUNCEMENT_TL01)
                && pro.getDescription().equals(Constants.FILE_DESCRIPTION.ANNOUNCEMENT_TL03)
                && pro.getDescription().equals(Constants.FILE_DESCRIPTION.CONFIRMTL)) {
            if (!saveFeeTLForWS(filesId, createForm.getFileType(),
                    createForm.getDetailProduct().getProductType(), pro, productTypeIdOld)) {
                return null;
            }
        } else if (createForm.getDetailProduct() != null
                && createForm.getDetailProduct().getProductType() != null) {
            if (!saveFeeForWS(filesId, createForm.getFileType(), createForm.getDetailProduct().getProductType(),
                    pro, productTypeIdOld)) {
                return null;
            }
        }

    } catch (Exception ex) {
        LogUtil.addLog(ex);//binhnt sonar a160901
        //            if (isCreateNew) {
        //                bo.setIsActive(Constants.Status.INACTIVE);
        //                getSession().update(bo);
        //            } else {
        //                getSession().update(boRollBack);
        //
        //            }
        return null;
    }

    if (createForm.getIsTemp() == null
            || (createForm.getIsTemp() != null && !createForm.getIsTemp().equals(1l))) {
        saveFileForSearch(filesId);
    }
    getSession().getTransaction().commit();
    //        session.flush();
    return bo;
}

From source file:com.viettel.hqmc.DAOHE.FilesDAOHE.java

public boolean onReceivedFileToStaff(FilesForm form, Long userId, String userName) {
    boolean bReturn = true;
    try {//from  w w w  . j a  v a  2  s.com
        Date dateNow = getSysdate();
        Files file = findById(form.getFileId());
        if (file == null) {
            bReturn = false;
        } else {
            Long processStatus = file.getStatus();
            file.setStatus(Constants.FILE_STATUS.RECEIVED_TO_ADD);
            file.setDisplayStatus(getFileStatusName(Constants.FILE_STATUS.RECEIVED_TO_ADD));
            file.setReceivedDate(dateNow);
            ResourceBundle rb = ResourceBundle.getBundle("config");
            ProcedureDAOHE procedureDAOHE = new ProcedureDAOHE();
            Procedure procedurebo = procedureDAOHE.findById(file.getFileType());
            if ("announcement4star".equalsIgnoreCase(procedurebo.getDescription())) {
                file.setDeadlineApprove(getDateWorkingTime(15));
                file.setDeadlineComment(getDateWorkingTime(15));
            } else {
                int CB = 0, PH = 0;
                try {
                    CB = Integer.parseInt(rb.getString(procedurebo.getDescription() + "_CB"));
                } catch (NumberFormatException ex) {
                    LogUtil.addLog(ex);//binhnt sonar a160901
                }
                try {
                    PH = Integer.parseInt(rb.getString(procedurebo.getDescription() + "_PH"));
                } catch (NumberFormatException ex) {
                    LogUtil.addLog(ex);//binhnt sonar a160901
                }
                if (CB > 0) {
                    file.setDeadlineApprove(getDateWorkingTime(CB));
                }
                if (PH > 0) {
                    file.setDeadlineComment(getDateWorkingTime(PH));
                }
            }

            ProcessDAOHE psdhe = new ProcessDAOHE();
            Process ptmp = psdhe.getProcessByAction(file.getFileId(), Constants.Status.ACTIVE,
                    Constants.OBJECT_TYPE.FILES, processStatus, Constants.FILE_STATUS.NEW_CREATE);
            if (ptmp != null) {
                if (processStatus.equals(Constants.FILE_STATUS.EVALUATED_TO_ADD)) {
                    ptmp.setStatus(Constants.FILE_STATUS.RECEIVED_TO_ADD);
                }
                ptmp.setLastestComment(form.getStaffRequest());
                getSession().update(ptmp);
            }

            Process newP = new Process();
            newP.setObjectId(form.getFileId());
            newP.setObjectType(Constants.OBJECT_TYPE.FILES);
            newP.setProcessType(Constants.PROCESS_TYPE.MAIN);
            newP.setSendDate(dateNow);
            newP.setSendGroup(ptmp.getReceiveGroup());
            newP.setSendGroupId(ptmp.getReceiveGroupId());
            newP.setSendUserId(userId);
            newP.setSendUser(userName);

            if (file.getStatus().equals(Constants.FILE_STATUS.RECEIVED_TO_ADD)) {
                //gui cho chuyen vien tham dinh ho so
                newP.setReceiveDate(dateNow);
                //140407
                ProcessDAOHE processDAOHE = new ProcessDAOHE();
                Process userAction = processDAOHE.findProcessByActionEvaluate(file.getFileId());
                if (userAction != null) {
                    newP.setReceiveUser(userAction.getReceiveUser());
                    newP.setReceiveUserId(userAction.getReceiveUserId());
                    newP.setReceiveGroup(userAction.getReceiveGroup());
                    newP.setReceiveGroupId(userAction.getReceiveGroupId());
                } else {
                    newP.setReceiveGroup(ptmp.getReceiveGroup());
                    newP.setReceiveGroupId(ptmp.getReceiveGroupId());
                }
                //
                newP.setProcessStatus(file.getStatus()); // De xu ly
                newP.setStatus(0l); // Moi den chua xu ly
                newP.setIsActive(1l);
            }

            getSession().save(newP);
            getSession().update(file);

            MessageSmsDAOHE msdhe = new MessageSmsDAOHE();
            String msg = "Ho so ma: " + file.getFileCode() + " cua doanh nghiep: " + file.getBusinessName()
                    + " dang trong trang thai: da tiep nhan";
            msdhe.saveMessageSMS(userId, file.getUserCreateId(), msg);
            MessageEmailDAOHE msedhe = new MessageEmailDAOHE();
            String msge = "H s m: " + file.getFileCode() + " ca doanh nghip: "
                    + file.getBusinessName() + " ang trong trng thi: ? tip nhn";
            msedhe.saveMessageEmail(userId, file.getUserCreateId(), msge);
            EmailSmsDAO emdao = new EmailSmsDAO();
            emdao.alertLeaderOfStaffAssignFiles(ptmp.getReceiveGroupId(), file.getFileCode(),
                    file.getBusinessName());
            //
            bReturn = true;
        }
    } catch (Exception ex) {
        bReturn = false;
        LogUtil.addLog(ex);//binhnt sonar a160901
    }
    return bReturn;
}

From source file:com.square.core.service.implementations.PersonnePhysiqueServiceImplementation.java

/**
 * Implmentation du service de modification d'une personne.
 * @param personneDto la personne  crer ou  mettre  jour.
 * @return PersonneDto la personne cre./*from  w  w  w.  ja va2s  .  c  o m*/
 * @author mlamine - SCUB
 */
public PersonneDto modifierPersonnePhysique(PersonneDto personneDto) {

    // On vrifie que la personne  mettre  jour n'est pas nulle
    if (personneDto == null) {
        throw new BusinessException(
                messageSourceUtil.get(PersonnePhysiqueKeyUtil.MESSAGE_ERREUR_PERSONNE_DTO_NULL));
    }

    // Contrle des donnes
    final RapportDto rapport = validationPersonneUtil.controlerModiciationPersonnePhysique(personneDto);

    final Long idNaturePersonneVivier = squareMappingService.getIdNaturePersonneVivier();
    final Long idNaturePersonneProspect = squareMappingService.getIdNaturePersonneProspect();
    final Long idNaturePersonneBeneficiaireVivier = squareMappingService
            .getIdNaturePersonneBeneficiaireVivier();
    final Long idNaturePersonneBeneficiaireProspect = squareMappingService
            .getIdNaturePersonneBeneficiaireProspect();

    if (rapport.getEnErreur()
            && !personneDto.getNaturePersonne().getIdentifiant().equals(idNaturePersonneVivier)
            && !personneDto.getNaturePersonne().getIdentifiant().equals(idNaturePersonneBeneficiaireVivier)) {
        RapportUtil.logRapport(rapport, logger);
        throw new ControleIntegriteException(rapport);
    }

    // si on est sur un vivier ou bnficiaire vivier, on change automatiquement en prospect ou bnficiaire prospect si les conditions sont respects
    boolean hasNaturePersonneChanged = false;
    String ancienneNaturePersonne = "";
    String nouvelleNaturePersonne = "";
    if (personneDto.getNaturePersonne().getIdentifiant().equals(idNaturePersonneVivier)
            && validationPersonneUtil.verifierContrainteCreationProspect(personneDto)) {
        personneDto.getNaturePersonne().setIdentifiant(idNaturePersonneProspect);
        hasNaturePersonneChanged = true;
        final PersonnePhysiqueNature ancienneNature = personnePhysiqueNatureDao
                .rechercherPersonnePhysiqueParId(idNaturePersonneVivier);
        final PersonnePhysiqueNature nouvelleNature = personnePhysiqueNatureDao
                .rechercherPersonnePhysiqueParId(idNaturePersonneProspect);
        if (ancienneNature != null) {
            ancienneNaturePersonne = ancienneNature.getLibelle();
        }
        if (nouvelleNature != null) {
            nouvelleNaturePersonne = nouvelleNature.getLibelle();
        }
    } else if (personneDto.getNaturePersonne().getIdentifiant().equals(idNaturePersonneBeneficiaireVivier)
            && validationPersonneUtil.verifierContrainteCreationProspect(personneDto)) {
        personneDto.getNaturePersonne().setIdentifiant(idNaturePersonneBeneficiaireProspect);
        hasNaturePersonneChanged = true;
        final PersonnePhysiqueNature ancienneNature = personnePhysiqueNatureDao
                .rechercherPersonnePhysiqueParId(idNaturePersonneBeneficiaireVivier);
        final PersonnePhysiqueNature nouvelleNature = personnePhysiqueNatureDao
                .rechercherPersonnePhysiqueParId(idNaturePersonneBeneficiaireProspect);
        if (ancienneNature != null) {
            ancienneNaturePersonne = ancienneNature.getLibelle();
        }
        if (nouvelleNature != null) {
            nouvelleNaturePersonne = nouvelleNature.getLibelle();
        }
    }

    // Vrification des dpendances obligatoires
    PersonneCivilite civilite = null;
    if (personneDto.getCivilite() != null && personneDto.getCivilite().getIdentifiant() != null) {
        civilite = personneCiviliteDao.rechercherCiviliteParId(personneDto.getCivilite().getIdentifiant());
    }
    PersonneSegment segment = null;
    if (personneDto.getSegment() != null && personneDto.getSegment().getIdentifiant() != null) {
        segment = segmentDao.recherchePersonneSegmentParId(personneDto.getSegment().getIdentifiant());
    }
    PersonneSituationFamiliale situationFamiliale = null;
    if (personneDto.getSitFam() != null && personneDto.getSitFam().getIdentifiant() != null) {
        situationFamiliale = situationFamilialeDao
                .rechercherSituationFamiliale(personneDto.getSitFam().getIdentifiant());
    }
    PersonneReseau personneReseau = null;
    if (personneDto.getReseauVente() != null && personneDto.getReseauVente().getIdentifiant() != null) {
        personneReseau = personneReseauDao.rechercheReseauParId(personneDto.getReseauVente().getIdentifiant());
    }
    PersonneCSP personneCSP = null;
    if (personneDto.getCsp() != null && personneDto.getCsp().getIdentifiant() != null) {
        personneCSP = cspDao.recherchePersonneCSPParId(personneDto.getCsp().getIdentifiant());
    }
    final PersonnePhysiqueNature naturePersonne = personnePhysiqueNatureDao
            .rechercherPersonnePhysiqueParId(personneDto.getNaturePersonne().getIdentifiant());

    PersonneProfession profession = null;
    if (personneDto.getProfession() != null) {
        profession = personneProfessionDao
                .rechercherProfessionParId(personneDto.getProfession().getIdentifiant());
        if (profession == null) {
            throw new BusinessException(
                    messageSourceUtil.get(PersonnePhysiqueKeyUtil.MESSAGE_ERREUR_PROFESSION_INEXISTENT_EN_BD));
        }
    }

    Agence agence = null;
    if (personneDto.getAgence() != null) {
        agence = agenceDao.rechercheAgenceParId(personneDto.getAgence().getIdentifiant());
    }

    Ressource ressource = null;
    if (personneDto.getCommercial() != null && personneDto.getCommercial().getIdentifiant() != null) {
        ressource = ressourceDao.rechercherRessourceParId(personneDto.getCommercial().getIdentifiant());
        if (ressource == null) {
            throw new BusinessException(messageSourceUtil
                    .get(PersonnePhysiqueKeyUtil.MESSAGE_ERREUR_PERSONNE_COMMERCIAL_INEXISTANTE));
        }
        if (agence == null) {
            agence = ressource.getAgence();
        }
    }
    // Les autres dpendances
    Caisse caisse = null;
    if (personneDto.getInfoSante() != null && personneDto.getInfoSante().getCaisse() != null
            && personneDto.getInfoSante().getCaisse().getId() != null) {
        caisse = caisseDao.rechercheCaisseParId(personneDto.getInfoSante().getCaisse().getId());
        if (caisse == null) {
            throw new BusinessException(
                    messageSourceUtil.get(PersonnePhysiqueKeyUtil.MESSAGE_ERREUR_CAISSE_INEXISTENT_EN_BD));
        }
    }

    PersonneStatut statut = null;
    if (personneDto.getStatut() != null && personneDto.getStatut().getIdentifiant() != null) {
        statut = personneStatutDao.recherchePersonneStatutParId(personneDto.getStatut().getIdentifiant());
        if (statut == null) {
            throw new BusinessException(
                    messageSourceUtil.get(PersonnePhysiqueKeyUtil.MESSAGE_ERREUR_STATUT_INEXISTENT_EN_BD));
        }
    }

    final PersonnePhysique personneAmodifier = personnePhysiqueDao
            .rechercherPersonneParId(personneDto.getIdentifiant());

    // Vrificiation de la modification de la nature de la personne
    if (!personneAmodifier.getNature().getId().equals(personneDto.getNaturePersonne().getIdentifiant())) {
        final String roleBatch = squareMappingService.getRoleSquareBatch();

        // Si la personne passe de vivier  prospect alors la nature des bnficiaires du chef de famille passe a bnficiaire prospect si c'est possible
        if (personneAmodifier.getNature().getId().equals(idNaturePersonneVivier)
                && personneDto.getNaturePersonne().getIdentifiant().equals(idNaturePersonneProspect)) {
            // Rcupration des bnficiaires
            final RelationCriteresRechercheDto criteres = new RelationCriteresRechercheDto();
            final RemotePagingCriteriasDto<RelationCriteresRechercheDto> criterias = new RemotePagingCriteriasDto<RelationCriteresRechercheDto>(
                    criteres, 0, Integer.MAX_VALUE);
            criteres.setIdPersonne(personneDto.getIdentifiant());
            final List<Long> listeGroupements = new ArrayList<Long>();
            listeGroupements.add(squareMappingService.getIdGroupementFamille());
            criteres.setGroupements(listeGroupements);
            final List<Relation> listeRelations = relationDao.rechercherRelationsParCriteres(criterias);

            // Modification de la nature des bnficiaires
            if (listeRelations != null && listeRelations.size() > 0) {
                final PersonnePhysiqueNature natureBeneficiaireProspect = personnePhysiqueNatureDao
                        .rechercherPersonnePhysiqueParId(
                                squareMappingService.getIdNaturePersonneBeneficiaireProspect());
                for (Relation relation : listeRelations) {
                    PersonnePhysique beneficiaire;
                    if (personneAmodifier.getId().equals(relation.getPersonneSource().getId())) {
                        beneficiaire = (PersonnePhysique) relation.getPersonneCible();
                    } else {
                        beneficiaire = (PersonnePhysique) relation.getPersonneSource();
                    }
                    if (beneficiaire.getNature() != null
                            && idNaturePersonneBeneficiaireVivier.equals(beneficiaire.getNature().getId())) {
                        if (beneficiaire.getCivilite() != null && beneficiaire.getCivilite().getId() != null
                                && beneficiaire.getNom() != null && !StringUtils.isBlank(beneficiaire.getNom())
                                && beneficiaire.getPrenom() != null
                                && !StringUtils.isBlank(beneficiaire.getPrenom())
                                && beneficiaire.getDateNaissance() != null) {
                            beneficiaire.setNature(natureBeneficiaireProspect);
                        }
                    }
                }
            }
        } else if (personneAmodifier.getNature().getId().equals(idNaturePersonneBeneficiaireVivier)
                && personneDto.getNaturePersonne().getIdentifiant()
                        .equals(idNaturePersonneBeneficiaireProspect)) {
            // possibiliter de passer automatiquement de bnficiaire vivier  bnficiaire prospect
        }
        // Le passage adhrent -> prospect ou prospect -> adhrent n'est possible que par un batch
        else if (((personneAmodifier.getNature().getId()
                .equals(squareMappingService.getIdNaturePersonneAdherent())
                && personneDto.getNaturePersonne().getIdentifiant().equals(idNaturePersonneProspect))
                || (personneAmodifier.getNature().getId().equals(idNaturePersonneProspect)
                        && personneDto.getNaturePersonne().getIdentifiant()
                                .equals(squareMappingService.getIdNaturePersonneAdherent())))
                && (roleBatch == null || !hasRole(roleBatch))) {
            throw new BusinessException(messageSourceUtil
                    .get(PersonnePhysiqueKeyUtil.MESSAGE_ERREUR_MODIFICATION_NATURE_PERSONNE_IMPOSSIBLE));
        } else if (!personneDto.getNaturePersonne().getIdentifiant()
                .equals(squareMappingService.getIdNaturePersonneDecede())) {
            throw new BusinessException(messageSourceUtil
                    .get(PersonnePhysiqueKeyUtil.MESSAGE_ERREUR_MODIFICATION_NATURE_PERSONNE_IMPOSSIBLE));
        } else if (!personneAmodifier.getNature().getId()
                .equals(squareMappingService.getIdNaturePersonneDecede())) {
            throw new BusinessException(messageSourceUtil
                    .get(PersonnePhysiqueKeyUtil.MESSAGE_ERREUR_MODIFICATION_NATURE_PERSONNE_IMPOSSIBLE));
        }
    }

    // Tout semble ok, on peut commencer les modifications
    mapperDozerBean.map(personneDto, personneAmodifier);

    personneAmodifier.setCivilite(civilite);
    personneAmodifier.setProfession(profession);
    personneAmodifier.setNature(naturePersonne);
    personneAmodifier.setSegment(segment);
    personneAmodifier.setSituationFamiliale(situationFamiliale);
    personneAmodifier.setReseau(personneReseau);
    personneAmodifier.setStatut(statut);
    if (personneCSP != null) {
        personneAmodifier.setCsp(personneCSP);
    }

    // on mappe les infos de sant  la main
    if (personneDto.getInfoSante() != null && personneDto.getInfoSante().getIdReferent() != null
            && !personneDto.getInfoSante().getIdReferent().equals(personneDto.getIdentifiant())) {
        // Rcupration du referent
        final PersonnePhysique referent = personnePhysiqueDao
                .rechercherPersonneParId(personneDto.getInfoSante().getIdReferent());
        if (referent == null) {
            logger.error("La personne " + personneDto.getInfoSante().getIdReferent() + " n'existe pas");
            throw new TechnicalException(
                    messageSourceUtil.get(PersonnePhysiqueKeyUtil.MESSAGE_ERREUR_PERSONNE_INEXISTANTE));
        }
        // on recupere les infos sant du referent
        personneAmodifier.setInfoSante(referent.getInfoSante());
    } else {
        // si il n'a pas encore d'info de sant, ou si il n'est pas le referent de ces infos de sante
        if (personneAmodifier.getInfoSante() == null
                || (personneAmodifier.getInfoSante().getReferent() != null && !personneAmodifier.getInfoSante()
                        .getReferent().getId().equals(personneDto.getIdentifiant()))) {
            personneAmodifier.setInfoSante(new InfoSante());
        }
        personneAmodifier.getInfoSante().setCaisse(caisse);
        if (personneDto.getInfoSante() != null && personneDto.getInfoSante().getNro() != null) {
            final NumeroRoDto numeroRO = squareMappingService
                    .convertirNroVersNss(personneDto.getInfoSante().getNro());
            if (numeroRO != null) {
                personneAmodifier.getInfoSante().setNumSecuriteSocial(numeroRO.getNumeroSS());
                personneAmodifier.getInfoSante().setCleSecuriteSocial(numeroRO.getCleSS());
            }
        }
        personneAmodifier.getInfoSante().setReferent(personneAmodifier);
    }

    // Les attributions de la personne
    if (personneAmodifier.getAttribution() == null) {
        throw new BusinessException(
                messageSourceUtil.get(PersonnePhysiqueKeyUtil.MESSAGE_ERREUR_PERSONNE_ATTRIBUTION_INEXISTANTE));
    }
    personneAmodifier.getAttribution().setAgence(agence);
    personneAmodifier.getAttribution().setRessource(ressource);
    personneAmodifier.setDateModification(Calendar.getInstance());

    final PersonneDto personneModifiee = rechercherPersonneParIdentifiant(personneAmodifier.getId());
    // ajout des informations pour spcifier si la nature de la personne principale a chang
    // (vivier -> prospect ou bnficiaire vivier -> bnficiaire prospect)
    personneModifiee.setHasNaturePersonneChanged(hasNaturePersonneChanged);
    personneModifiee.setAncienneNaturePersonne(ancienneNaturePersonne);
    personneModifiee.setNouvelleNaturePersonne(nouvelleNaturePersonne);
    return personneModifiee;
}

From source file:com.viettel.hqmc.DAO.FilesDAO.java

/**
 * lay lich su thanh toan/*from   w  w w .  ja v  a2s  . c  om*/
 *
 * @return
 */
public String getPaymentHistory() {
    getGridInfo();
    String strObjectId = getRequest().getParameter("objectId");
    String strObjectType = getRequest().getParameter("objectType");
    List customInfo = new ArrayList();
    Long objectId;
    Long objectType;
    Long totalFeeFile;
    Long feeFile;

    try {
        objectId = Long.parseLong(strObjectId);
    } catch (Exception ex) {
        LogUtil.addLog(ex);//binhnt sonar a160901
        //            log.error(en.getMessage());
        objectId = 0L;
    }
    try {
        objectType = Long.parseLong(strObjectType);
    } catch (Exception ex) {
        LogUtil.addLog(ex);//binhnt sonar a160901
        objectType = 0L;
    }

    PaymentHistoryDAOHE pcdhe = new PaymentHistoryDAOHE();
    FilesDAOHE bdhe = new FilesDAOHE();
    Files filebo = bdhe.findById(objectId);
    String fileCode = "0";
    if (filebo != null) {
        fileCode = filebo.getFileCode();
    }
    GridResult result = pcdhe.getLstPaymentHistory(fileCode, objectType, start, count, sortField);
    FilesDAOHE filesDHE = new FilesDAOHE();
    feeFile = filesDHE.findById(objectId).getFeeFile();
    if (feeFile == null) {
        feeFile = 0l;
    }
    totalFeeFile = pcdhe.getTotalPaymentHistory(fileCode, objectType);
    customInfo.add(feeFile);
    customInfo.add(totalFeeFile);
    // nop du
    if ((totalFeeFile.equals(feeFile) && feeFile > 0l) || (totalFeeFile > feeFile)) {
        customInfo.add(1);
    } else // nop thieu
    if (totalFeeFile < feeFile && totalFeeFile > 0) {
        customInfo.add(0);
    } // chua nop
    else {
        customInfo.add(-1);
    }

    jsonDataGrid.setItems(result.getLstResult());
    jsonDataGrid.setTotalRows(result.getnCount().intValue());
    jsonDataGrid.setCustomInfo(customInfo);
    return GRID_DATA;
}

From source file:com.viettel.hqmc.DAOHE.FilesDAOHE.java

private Boolean saveFeeForWS(Long fileId, Long fileType, Long productType, Procedure pro,
        Long productTypeIdOld) {//www . j  a va2 s  .c  om
    if (fileId != null) {
        Date dateNow = null;
        try {
            dateNow = getSysdate();
        } catch (Exception ex) {
            LogUtil.addLog(ex);//binhnt sonar a160901
            return false;
        }

        String hql = "select fpif" + " from FeePaymentInfo fpif" + " where" + " fpif.fileId =:fileId"
                + " and fpif.isActive = 1";
        Query query = getSession().createQuery(hql);
        query.setParameter("fileId", fileId);
        List<FeePaymentInfo> FeePaymentInfo = query.list();
        // truong hop sao chep va luu tam productType co the = null, vi the phai set = -1
        if (FeePaymentInfo.isEmpty()) {
            FeeDAOHE fdhe = new FeeDAOHE();
            List<FeeProcedure> feenew = fdhe.findAllFeeByProcedureId(fileType);
            // check le phi cap so theo loai ho so
            if (feenew != null && feenew.size() > 0) {
                FeePaymentInfo fpif;
                for (int i = 0; i < feenew.size(); i++) {
                    fpif = new FeePaymentInfo();
                    fpif.setCreateDate(dateNow);
                    fpif.setStatus(0l);
                    fpif.setFileId(fileId);
                    fpif.setIsActive(1l);
                    fpif.setFeeId(feenew.get(i).getFeeId());
                    Fee feeTemp = (Fee) findById(Fee.class, "feeId", feenew.get(i).getFeeId());
                    fpif.setCost(feeTemp.getPrice());
                    getSession().save(fpif);
                }
            }
            // hieptq update 280515 set phi ho so cap lai
            if (productType == null) {
                if (pro != null && pro.getTypeFee() == 2l) {
                    FeePaymentInfo fpif = new FeePaymentInfo();
                    Fee findfee1 = fdhe.findFeeByCode("CLT");
                    fpif.setCreateDate(dateNow);
                    fpif.setStatus(0l);
                    fpif.setFileId(fileId);
                    if (findfee1 != null) {
                        fpif.setFeeId(findfee1.getFeeId());
                        fpif.setCost(findfee1.getPrice());
                        fpif.setCostCheck(findfee1.getPrice());
                        fpif.setFeeIdOld(findfee1.getFeeId());
                    } else {
                        return false;
                    }
                    fpif.setIsActive(1l);
                    getSession().save(fpif);
                    return true;
                } else if (pro != null && pro.getTypeFee() == 3l) {
                    FeePaymentInfo fpif = new FeePaymentInfo();
                    Fee findfee1 = fdhe.findFeeByCode("CLCN");
                    fpif.setCreateDate(dateNow);
                    fpif.setStatus(0l);
                    fpif.setFileId(fileId);
                    if (findfee1 != null) {
                        fpif.setFeeId(findfee1.getFeeId());
                        fpif.setCost(findfee1.getPrice());
                        fpif.setCostCheck(findfee1.getPrice());
                        fpif.setFeeIdOld(findfee1.getFeeId());
                    } else {
                        return false;
                    }
                    fpif.setIsActive(1l);
                    getSession().save(fpif);
                    return true;
                } else {
                    return false;
                }
            }
            //check loai thuc pham (thuc pham dac biet)
            CategoryDAOHE ctdhe = new CategoryDAOHE();
            Category cate = ctdhe.findCategoryByTypeAndCode("SP", "TPCN");
            List<Category> cate1 = ctdhe.findCategoryByTypeAndCodeNew("SP", "DBT");
            int check = 0;
            for (int i = 0; i < cate1.size(); i++) {
                if (productType.equals(cate1.get(i).getCategoryId())) {
                    check = 1;
                    break;
                }
            }

            if (check == 1) {
                FeePaymentInfo fpif = new FeePaymentInfo();
                Fee findfee1 = fdhe.findFeeByCode("TPDB");
                fpif.setCreateDate(dateNow);
                fpif.setStatus(0l);
                fpif.setFileId(fileId);
                if (findfee1 != null) {
                    fpif.setFeeId(findfee1.getFeeId());
                    fpif.setCost(findfee1.getPrice());
                    fpif.setCostCheck(findfee1.getPrice());
                    fpif.setFeeIdOld(findfee1.getFeeId());
                } else {
                    return false;
                }
                fpif.setIsActive(1l);
                getSession().save(fpif);
            } else {
                // thuc pham chuc nang
                FeePaymentInfo fpif = new FeePaymentInfo();
                if (productType.equals(cate.getCategoryId())) {
                    Fee findfee2 = fdhe.findFeeByCode("TPCN");

                    fpif.setCreateDate(dateNow);
                    fpif.setStatus(0l);
                    fpif.setFileId(fileId);
                    if (findfee2 != null) {
                        fpif.setFeeId(findfee2.getFeeId());
                        fpif.setCost(findfee2.getPrice());
                        fpif.setCostCheck(findfee2.getPrice());
                        fpif.setFeeIdOld(findfee2.getFeeId());
                    } else {
                        return false;
                    }
                    fpif.setIsActive(1l);
                    getSession().save(fpif);
                } else {
                    Fee findfee3 = fdhe.findFeeByCode("TPK");
                    fpif.setCreateDate(dateNow);
                    fpif.setStatus(0l);
                    fpif.setFileId(fileId);
                    if (findfee3 != null) {
                        fpif.setFeeId(findfee3.getFeeId());
                        fpif.setCost(findfee3.getPrice());
                        fpif.setCostCheck(findfee3.getPrice());
                        fpif.setFeeIdOld(findfee3.getFeeId());
                    } else {
                        return false;
                    }
                    fpif.setIsActive(1l);
                    getSession().save(fpif);
                }
            }
            // }
        }
        // sua nhom san pham va chuyen loai ho so - map lai phi
        if ((productTypeIdOld != null) && (!productTypeIdOld.equals(productType))) {
            // hieptq update 310115
            // tim lai feeId cu 
            CategoryDAOHE ctdhe = new CategoryDAOHE();
            FeeDAOHE fdhe = new FeeDAOHE();
            Category cate = ctdhe.findCategoryByTypeAndCode("SP", "TPCN");
            List<Category> cate1 = ctdhe.findCategoryByTypeAndCodeNew("SP", "DBT");
            Long feeIdOld, feeIdNew;
            int check = 0, check1 = 0;
            FeePaymentInfo fpifOld;
            for (int i = 0; i < cate1.size(); i++) {
                if (productTypeIdOld.equals(cate1.get(i).getCategoryId())) {
                    check = 1;
                    break;
                }
            }
            if (check == 1) {
                Fee findfee1 = fdhe.findFeeByCode("TPDB");
                feeIdOld = findfee1.getFeeId();
            } else // thuc pham chuc nang
            if (productTypeIdOld.equals(cate.getCategoryId())) {
                Fee findfee2 = fdhe.findFeeByCode("TPCN");
                feeIdOld = findfee2.getFeeId();
            } else {
                Fee findfee3 = fdhe.findFeeByCode("TPK");
                feeIdOld = findfee3.getFeeId();
            }

            fpifOld = fdhe.findFeePaymentInfoFileIdFeeIdIsActive(fileId, feeIdOld, 1l);

            // lay feeid moi
            for (int i = 0; i < cate1.size(); i++) {
                if (productType.equals(cate1.get(i).getCategoryId())) {
                    check1 = 1;
                    break;
                }
            }
            Long costNew;
            if (check1 == 1) {
                Fee findfee1 = fdhe.findFeeByCode("TPDB");
                feeIdNew = findfee1.getFeeId();
                costNew = findfee1.getPrice();
            } else // thuc pham chuc nang
            if (productType.equals(cate.getCategoryId())) {
                Fee findfee2 = fdhe.findFeeByCode("TPCN");
                feeIdNew = findfee2.getFeeId();
                costNew = findfee2.getPrice();
            } else {
                Fee findfee3 = fdhe.findFeeByCode("TPK");
                feeIdNew = findfee3.getFeeId();
                costNew = findfee3.getPrice();
            }
            FilesDAOHE filesdhe = new FilesDAOHE();
            Files filesnew = filesdhe.findById(fileId);
            // check gia cu va gia moi
            if (fpifOld.getCostCheck().equals(costNew) || fpifOld.getCostCheck() > costNew) {
                if (filesnew.getStatus() == 0l) {
                    fpifOld.setCost(fpifOld.getCostCheck());
                    fpifOld.setFeeId(fpifOld.getFeeIdOld());
                    getSession().update(fpifOld);
                } else {
                    fpifOld.setCost(fpifOld.getCostCheck());
                    fpifOld.setFeeId(fpifOld.getFeeIdOld());
                    fpifOld.setStatus(1l);
                    filesnew.setIsFee(1l);
                    getSession().update(filesnew);
                    getSession().update(fpifOld);
                }
                return true;
            } else if (filesnew.getStatus() == 0l) {
                fpifOld.setCost(costNew);
                fpifOld.setFeeId(feeIdNew);
                getSession().update(fpifOld);
            } else {
                fpifOld.setCost(costNew);
                fpifOld.setFeeId(feeIdNew);
                fpifOld.setStatus(0l);
                //Hiepvv 0803 Khong tinh phi SDBS sau cong bo
                ProcedureDAOHE pHE = new ProcedureDAOHE();
                Procedure pdu;
                pdu = pHE.findById(filesnew.getFileType());
                if (pdu != null && pdu.getDescription() != null
                        && pdu.getDescription().equals(Constants.FILE_DESCRIPTION.ANNOUNCEMENT_FILE05)) {
                    filesnew.setIsFee(1l);
                } else {
                    filesnew.setIsFee(0l);
                }
                getSession().update(filesnew);
                getSession().update(fpifOld);
            }
        }
    } else {
        return false;
    }
    return true;
}

From source file:com.viettel.hqmc.DAO.FilesDAO.java

/**
 * import du lieu tu excel/*from  w  ww . j av  a2s . com*/
 *
 * @return
 */
public String importFileFromExcel() throws FileNotFoundException, IOException, ParseException {
    List fileInfo = new ArrayList();
    String strReturn = ERROR_PERMISSION;
    //        TechnicalStandard ts = new TechnicalStandard();
    TechnicalStandardDAOHE tshe = new TechnicalStandardDAOHE();
    String err = "";
    Long attachId = Long.parseLong(getRequest().getParameter("attachId"));//get attactId
    VoAttachs att = (VoAttachs) getSession().get("com.viettel.voffice.database.BO.VoAttachs", attachId);//Attachs BO
    if (att == null) {
        fileInfo.add("File not found");
        err += "File not found";
    } else {
        Category item;
        ResourceBundle rb = ResourceBundle.getBundle("config");//get link tuong doi
        String dir = rb.getString("directoryExcel");
        String linkFile = att.getAttachPath();
        linkFile = dir + linkFile;
        createForm.setPath(linkFile);
        InputStream myxls = new FileInputStream(linkFile);//get file excel
        XSSFWorkbook wb = new XSSFWorkbook(myxls);

        XSSFRow row = null;
        String matchingTarget = null;
        XSSFCell productName = null;
        XSSFCell businessTaxCode = null;
        XSSFCell manufactorAddress = null;
        XSSFCell manufactorName = null;
        XSSFCell manufactorTel = null;
        XSSFCell manufactorFax = null;
        XSSFCell manufactorEmail = null;
        XSSFCell nationName = null;
        XSSFCell signer = null;
        XSSFCell assessmentMethod = null;
        XSSFCell annoucementNo = null;

        XSSFCell pushlishDate = null;
        XSSFCell nationCompanyName = null;
        XSSFCell nationCompanyAddress = null;
        try {

            XSSFSheet sheet = wb.getSheetAt(0);
            try {
                //                    XSSFSheet sheet1 = wb.getSheetAt(1);
            } catch (Exception ex) {
                LogUtil.addLog(ex);//binhnt sonar a160901
                //                    log.error(e.getMessage());
                err += "Khng tm thy Sheet Chi tit sn phm, ";
            }

            try {
                //                    XSSFSheet sheet2 = wb.getSheetAt(2);
            } catch (Exception ex) {
                //                    log.error(e.getMessage());
                LogUtil.addLog(ex);//binhnt sonar a160901
                err += "Khng tm thy Sheet Ch tiu cht lng ch yu, ";
            }

            try {
                //                    XSSFSheet sheet3 = wb.getSheetAt(3);
            } catch (Exception ex) {
                LogUtil.addLog(ex);//binhnt sonar a160901
                //                    log.error(e.getMessage());
                err += "Khng tm thy Sheet Ch tiu vi sinh vt, ";
            }

            try {
                //                    XSSFSheet sheet4 = wb.getSheetAt(4);
            } catch (Exception ex) {
                LogUtil.addLog(ex);//binhnt sonar a160901
                //                    log.error(e.getMessage());
                err += "Khng tm thy Sheet Hm lng kim loi nng, ";
            }
            try {
                //                    XSSFSheet sheet5 = wb.getSheetAt(5);
            } catch (Exception ex) {
                LogUtil.addLog(ex);//binhnt sonar a160901
                //                    log.error(e.getMessage());
                err += "Khng tm thy Sheet Hm lng ha cht, ";
            }
            try {
                //                    XSSFSheet sheet6 = wb.getSheetAt(6);
            } catch (Exception ex) {
                LogUtil.addLog(ex);//binhnt sonar a160901
                //                    log.error(e.getMessage());
                err += "Khng tm thy Sheet K hoch kim sot cht lng, ";
            }

            if (sheet == null) {
                err += "Khng tm thy Sheet Bn cng b, ";
            } else {
                String sheetName = sheet.getSheetName();
                if (!"Ban_Cong_bo".equals(sheetName)) {
                    err += "Sai tn sheet Bn cng b, ";
                }
            }

            //                XSSFRow firstRow = sheet.getRow(1);
            int rowNums = sheet.getLastRowNum();
            //                UsersDAOHE sdhe = new UsersDAOHE();
            //                SimpleDateFormat formatter = new SimpleDateFormat("dd/MM/yyyy");
            row = sheet.getRow(1);
            businessTaxCode = row.getCell((short) 1);
            productName = row.getCell((short) 3);
            row = sheet.getRow(4);
            manufactorName = row.getCell((short) 1);
            manufactorAddress = row.getCell((short) 3);
            row = sheet.getRow(5);
            manufactorTel = row.getCell((short) 1);
            manufactorFax = row.getCell((short) 3);
            row = sheet.getRow(6);
            manufactorEmail = row.getCell((short) 1);
            nationName = row.getCell((short) 3);
            row = sheet.getRow(7);
            nationCompanyName = row.getCell((short) 1);
            nationCompanyAddress = row.getCell((short) 3);

            row = sheet.getRow(10);
            annoucementNo = row.getCell((short) 1);
            pushlishDate = row.getCell((short) 3);
            row = sheet.getRow(11);
            signer = row.getCell((short) 1);
            assessmentMethod = row.getCell((short) 3);
            matchingTarget = "";
            String standardCode;
            for (int i = 12; i < rowNums; i++) {
                row = sheet.getRow(i);
                if (row.getCell((short) 1).toString() != "") {
                    XSSFCell standardCodeCell = row.getCell((short) 1);
                    standardCode = standardCodeCell.getRichStringCellValue().toString();
                    if (tshe.findStandardByCode(standardCode)) {
                        XSSFCell matchingTargetCell = row.getCell((short) 2);
                        matchingTarget += matchingTargetCell.getRichStringCellValue() + ";";
                    } else {
                        err += "Quy chun (quy nh) " + standardCode + " khng chnh xc ! ";
                        break;
                    }
                } else {
                    break;
                }
            }

        } catch (Exception ex) {
            LogUtil.addLog(ex);//binhnt sonar a160901
            //                log.error(e.getMessage());
            err += "li tab bn cng b hp quy ";
        }
        if (matchingTarget != "" && matchingTarget != null) {
            matchingTarget = matchingTarget.substring(0, matchingTarget.length() - 1);
        }
        //tab chi tiet san pham
        XSSFCell productNo = null;
        XSSFCell productStatus = null;
        XSSFCell productColor = null;
        XSSFCell productSmell = null;
        XSSFCell productOtherstatus = null;
        XSSFCell productType = null;
        XSSFCell otherTarget = null;
        XSSFCell component = null;
        XSSFCell timeinuse = null;
        XSSFCell useage = null;
        XSSFCell objectInUse = null;
        XSSFCell guideline = null;
        //XSSFCell packageRecipe = null;
        XSSFCell packageMaterial = null;
        XSSFCell productProcess = null;
        XSSFCell counterfeitDistinctive = null;
        XSSFCell origin = null;
        XSSFCell signDate = null;
        XSSFCell signer_productdetails = null;
        XSSFCell chemicalTargetUnwanted = null;
        try {

            XSSFSheet sheet1 = wb.getSheetAt(1);
            if (sheet1 == null) {
                err += "Khng tm thy Sheet Chi tit sn phm, ";

            } else {
                String sheetName = sheet1.getSheetName();
                if (!"Chi_tiet_san_pham".equals(sheetName)) {
                    err += "Sai tn Sheet Chi tit sn phm, ";
                }
            }

            row = sheet1.getRow(1);
            productType = row.getCell((short) 1);
            productNo = row.getCell((short) 3);
            row = sheet1.getRow(4);
            productStatus = row.getCell((short) 1);
            productColor = row.getCell((short) 3);
            row = sheet1.getRow(5);
            productSmell = row.getCell((short) 1);
            productOtherstatus = row.getCell((short) 3);
            row = sheet1.getRow(13);
            otherTarget = row.getCell((short) 1);
            row = sheet1.getRow(14);
            component = row.getCell((short) 1);
            timeinuse = row.getCell((short) 3);
            row = sheet1.getRow(15);
            useage = row.getCell((short) 1);
            objectInUse = row.getCell((short) 3);
            row = sheet1.getRow(16);
            guideline = row.getCell((short) 1);
            packageMaterial = row.getCell((short) 3);
            row = sheet1.getRow(17);
            productProcess = row.getCell((short) 3);
            //packageRecipe = row.getCell((short) 1);
            row = sheet1.getRow(18);
            counterfeitDistinctive = row.getCell((short) 1);
            origin = row.getCell((short) 3);
            row = sheet1.getRow(19);
            signDate = row.getCell((short) 1);
            signer_productdetails = row.getCell((short) 3);
            // bo sung ham luong hoa chat khong mong muon
            XSSFSheet sheet5 = wb.getSheetAt(5);

            int rowNums = sheet5.getLastRowNum();
            do {
                row = sheet5.getRow(rowNums);
                chemicalTargetUnwanted = row.getCell((short) 2);
                rowNums--;
            } while (chemicalTargetUnwanted == null);

            //                chemicalTargetUnwanted = row.getCell((short) 2);
        } catch (Exception ex) {
            LogUtil.addLog(ex);//binhnt sonar a160901
            //                log.error(e.getMessage());
            err += "Li tab chi tit sn phm ";
        }
        // do du lieu vao form
        Long fileId = getRequest().getParameter("fileId") == null ? 0L
                : Long.parseLong(getRequest().getParameter("fileId"));
        Long fileType = getRequest().getParameter("fileType") == null ? 0L
                : Long.parseLong(getRequest().getParameter("fileType"));
        if (fileType > 0L && fileId > 0L) {
            createForm = new FilesForm();
            createForm.setFileType(fileType);
            createForm.setFileId(fileId);
        }
        UsersDAOHE udhe = new UsersDAOHE();
        Users user = udhe.findById(getUserId());

        BusinessDAOHE bdhe = new BusinessDAOHE();
        Business bus = bdhe.findById(user.getBusinessId());

        if (createForm.getFileId() != null && createForm.getFileId() > 0l) {
            FilesDAOHE fdhe = new FilesDAOHE();
            createForm = fdhe.getFilesDetail(createForm.getFileId());
            if (!createForm.getFileType().equals(0L)) {
                ProcedureDAOHE cdhe = new ProcedureDAOHE();
                List lstTTHC = cdhe.getProcedureForChange(createForm.getFileType());
                lstCategory = new ArrayList();
                lstCategory.addAll(lstTTHC);
                lstCategory.add(0,
                        new Procedure(Constants.COMBOBOX_HEADER_VALUE, Constants.COMBOBOX_HEADER_TEXT_SELECT));
                getRequest().setAttribute("lstFileType", lstCategory);

            }
        }

        if (createForm.getFileType() != null && createForm.getFileType() > 0l) {
            ProcedureDAOHE pdhe = new ProcedureDAOHE();
            CategoryDAOHE cdhe = new CategoryDAOHE();
            TechnicalStandardDAOHE tdhe = new TechnicalStandardDAOHE();
            FilesDAOHE fdhe = new FilesDAOHE();
            if (!fileType.equals(0L)) {
                createForm.setFileType(fileType);
            }
            Procedure tthc = pdhe.findById(createForm.getFileType());
            if (tthc != null) {

                lstProductType = cdhe.findAllCategory("SP");
                lstUnit = cdhe.findAllCategory("DVI");

                lstStandard = tdhe.findAllStandard();
                String lstDepts = convertToJSONData(lstStandard, "vietnameseName", "vietnameseName");
                getRequest().setAttribute("lstStandard", lstDepts);

                UserAttachsDAOHE uahe = new UserAttachsDAOHE();
                lstUserAttach = uahe.findAllUserAttach(getUserId());
                String lstUserAttachs = convertToJSONData(lstUserAttach, "attachName", "attachName");
                getRequest().setAttribute("lstUserAttach", lstUserAttachs);
                if (lstUserAttachs.trim().length() > 0) {
                    createForm.setCountUA(1L);
                } else {
                    createForm.setCountUA(0L);
                }
                getRequest().setAttribute("lstProductType", lstProductType);
                getRequest().setAttribute("lstUnit", lstUnit);

                String fileLst = tthc.getFileList();
                getRequest().setAttribute("fileList", com.viettel.common.util.StringUtils.removeHTML(fileLst));
                getRequest().setAttribute("agencyName", getDepartmentName());
                getRequest().setAttribute("fileNameFull", tthc.getName());
                strReturn = tthc.getDescription();
                if (createForm.getAnnouncement() != null) {
                    if (createForm.getAnnouncement().getAnnouncementNo() != null
                            && createForm.getAnnouncement().getAnnouncementNo().length() > 0l) {
                        return strReturn;
                    }
                }
                if (strReturn.equals(Constants.FILE_DESCRIPTION.ANNOUNCEMENT_FILE01)
                        || strReturn.equals(Constants.FILE_DESCRIPTION.ANNOUNCEMENT_FILE03)
                        || strReturn.equals(Constants.FILE_DESCRIPTION.CONFIRM_FUNC_IMP)
                        || strReturn.equals(Constants.FILE_DESCRIPTION.CONFIRM_FUNC_VN)
                        || strReturn.equals(Constants.FILE_DESCRIPTION.CONFIRM_NORMAL_IMP)
                        || strReturn.equals(Constants.FILE_DESCRIPTION.CONFIRM_NORMAL_VN)
                        || strReturn.equals(Constants.FILE_DESCRIPTION.REC_CONFIRM_NORMAL_IMP)
                        || strReturn.equals(Constants.FILE_DESCRIPTION.RE_ANNOUNCEMENT)
                        || strReturn.equals(Constants.FILE_DESCRIPTION.RE_CONFIRM_FUNC_IMP)
                        || strReturn.equals(Constants.FILE_DESCRIPTION.RE_CONFIRM_FUNC_VN)
                        || strReturn.equals(Constants.FILE_DESCRIPTION.RE_CONFIRM_NORMAL_VN)) {
                    String announcementNoStr = fdhe.getReceiptNoNew(getUserId(), getUserLogin(),
                            createForm.getFileType());
                    createForm.setAnnouncement(new AnnouncementForm());
                    createForm.getAnnouncement().setAnnouncementNo(announcementNoStr);
                    // thong tin doanh nghiep
                    createForm.getAnnouncement().setBusinessAddress(bus.getBusinessAddress());
                    createForm.getAnnouncement().setBusinessFax(bus.getBusinessFax());
                    createForm.getAnnouncement().setBusinessName(bus.getBusinessName());
                    createForm.getAnnouncement().setBusinessTelephone(bus.getBusinessTelephone());
                    createForm.getAnnouncement().setBusinessEmail(bus.getUserEmail());
                    createForm.getAnnouncement().setBusinessLicence(bus.getBusinessLicense());

                    // ho so cap lai 7-11
                    createForm.setReIssueForm(new ReIssueFormForm());
                    createForm.getReIssueForm().setBusinessName(bus.getBusinessName());
                    createForm.getReIssueForm().setIdentificationNumber(bus.getBusinessLicense());
                    createForm.getReIssueForm().setAddress(bus.getBusinessAddress());
                    createForm.getReIssueForm().setEmail(bus.getUserEmail());
                    createForm.getReIssueForm().setTelephone(bus.getBusinessTelephone());
                    createForm.getReIssueForm().setFax(bus.getBusinessFax());
                    //set thong tin tu excel

                    try {
                        if (businessTaxCode != null && user.getUserName().equals(businessTaxCode.toString())) {
                            if (matchingTarget != "" && matchingTarget != null) {
                                createForm.getAnnouncement().setMatchingTarget(matchingTarget.toString());
                            }
                            createForm.getAnnouncement().setProductName(productName.toString());
                            createForm.getAnnouncement().setManufactureAddress(manufactorAddress.toString());
                            createForm.getAnnouncement().setManufactureName(manufactorName.toString());
                            createForm.getAnnouncement().setManufactureTel(manufactorTel.toString());
                            createForm.getAnnouncement().setManufactureFax(manufactorFax.toString());
                            createForm.getAnnouncement().setManufactureEmail(manufactorEmail.toString());
                            createForm.getAnnouncement().setNationName(nationName.toString());
                            createForm.getAnnouncement().setSigner(signer.toString());
                            createForm.getAnnouncement()
                                    .setNationCompanyAddress(nationCompanyAddress.toString());
                            createForm.getAnnouncement().setNationCompanyName(nationCompanyName.toString());
                            createForm.getAnnouncement().setAssessmentMethod(assessmentMethod.toString());
                            if (pushlishDate.toString() != null && pushlishDate.toString().length() > 0) {
                                createForm.getAnnouncement().setPublishDate(DateTimeUtils
                                        .convertStringToTime(pushlishDate.toString(), "dd/MM/yyyy"));
                            }
                            createForm.getAnnouncement().setAnnouncementNo(annoucementNo.toString());
                            //tab thong tin chi tiet
                            createForm.setDetailProduct(new DetailProductForm());
                            createForm.getDetailProduct().setProductNo(productNo.toString());
                            createForm.getDetailProduct().setProductStatus(productStatus.toString());
                            createForm.getDetailProduct().setProductColor(productColor.toString());
                            createForm.getDetailProduct().setProductSmell(productSmell.toString());
                            createForm.getDetailProduct().setProductOtherStatus(productOtherstatus.toString());

                            item = cdhe.findCategoryByName("SP", productType.toString());
                            if (item != null) {
                                createForm.getDetailProduct().setProductType(item.getCategoryId());
                            } else {
                                err += "Danh mc " + productType.toString() + " khng chnh xc, ";
                            }

                            createForm.getDetailProduct().setOtherTarget(otherTarget.toString());
                            createForm.getDetailProduct().setComponents(component.toString());
                            createForm.getDetailProduct().setTimeInUse(timeinuse.toString());
                            createForm.getDetailProduct().setUseage(useage.toString());
                            createForm.getDetailProduct().setObjectUse(objectInUse.toString());
                            createForm.getDetailProduct().setGuideline(guideline.toString());
                            //createForm.getDetailProduct().setPackageRecipe(packageRecipe.toString());
                            createForm.getDetailProduct().setPackateMaterial(packageMaterial.toString());
                            createForm.getDetailProduct().setProductionProcess(productProcess.toString());
                            createForm.getDetailProduct()
                                    .setCounterfeitDistinctive(counterfeitDistinctive.toString());
                            createForm.getDetailProduct().setOrigin(origin.toString());
                            if (signDate.toString() != null && signDate.toString().length() > 0) {
                                createForm.getDetailProduct().setSignDate(
                                        DateTimeUtils.convertStringToTime(signDate.toString(), "dd/MM/yyyy"));
                            }
                            createForm.getDetailProduct().setSigner(signer_productdetails.toString());
                            createForm.getDetailProduct()
                                    .setChemicalTargetUnwanted(chemicalTargetUnwanted.toString());
                            createForm.setStatusExcel(
                                    err += "Thm mi bn cng b hp quy thnh cng ");
                        } else {
                            createForm.setStatusExcel(err += "M s thu khng chnh xc ");
                        }
                    } catch (Exception ex) {
                        //                            log.error(parseException);
                        LogUtil.addLog(ex);//binhnt sonar a160901
                        createForm.setStatusExcel(
                                err += "Thm mi bn cng b hp quy khng thnh cng ");
                    }
                }
            }
        }
    }
    CategoryDAOHE ctdhe = new CategoryDAOHE();
    Category cate = ctdhe.findCategoryByTypeAndCode("SP", "TPCN");
    Category cateTL = ctdhe.findCategoryByTypeAndCode("SP", "TL");
    List<Category> cate1 = ctdhe.findCategoryByTypeAndCodeNew("SP", "DBT");
    String dbtId = "";
    for (int i = 0; i < cate1.size(); i++) {
        dbtId += cate1.get(i).getCategoryId().toString() + ";";
    }
    Long tpcnId = cate.getCategoryId();
    Long tlId = cateTL.getCategoryId();
    FeeDAOHE fdhe1 = new FeeDAOHE();
    Fee findfee1 = fdhe1.findFeeByCode("TPDB");
    Long priceTPDB = findfee1.getPrice();
    Fee findfee2 = fdhe1.findFeeByCode("TPCN");
    Long priceTPCN = findfee2.getPrice();
    Fee findfee3 = fdhe1.findFeeByCode("TPK");
    Long priceETC = findfee3.getPrice();
    getRequest().setAttribute("dbtId", dbtId);
    getRequest().setAttribute("tpcnId", tpcnId);
    getRequest().setAttribute("tlId", tlId);
    getRequest().setAttribute("priceTPCN", priceTPCN);
    getRequest().setAttribute("priceTPDB", priceTPDB);
    getRequest().setAttribute("priceETC", priceETC);

    return strReturn;
}

From source file:com.viettel.hqmc.DAOHE.FilesDAOHE.java

private Boolean saveFee(Long fileId, Long fileType, Long productType, Procedure pro, Long productTypeIdOld) {
    if (fileId != null) {
        Date dateNow = null;/*from w  ww.  j  av  a2s  .co m*/
        try {
            dateNow = getSysdate();
        } catch (Exception ex) {
            LogUtil.addLog(ex);//binhnt sonar a160901
            return false;
        }

        String hql = "select fpif from FeePaymentInfo fpif" + " where" + " fpif.fileId =:fileId"
                + " and fpif.isActive = 1";
        Query query = getSession().createQuery(hql);
        query.setParameter("fileId", fileId);
        List<FeePaymentInfo> lstFeePaymentInfo = query.list();
        //
        // truong hop sao chep va luu tam productType co the = null, vi the phai set = -1
        //

        if (lstFeePaymentInfo.isEmpty()) {
            FeeDAOHE fdhe = new FeeDAOHE();
            List<FeeProcedure> feenew = fdhe.findAllFeeByProcedureId(fileType);
            // check le phi cap so theo loai ho so
            if (feenew != null && feenew.size() > 0) {
                for (int i = 0; i < feenew.size(); i++) {
                    FeePaymentInfo fpif = new FeePaymentInfo();
                    fpif.setCreateDate(dateNow);
                    fpif.setStatus(0l);
                    fpif.setFileId(fileId);
                    fpif.setIsActive(1l);
                    fpif.setFeeId(feenew.get(i).getFeeId());
                    Fee feeTemp = (Fee) findById(Fee.class, "feeId", feenew.get(i).getFeeId());
                    fpif.setCost(feeTemp.getPrice());
                    getSession().save(fpif);
                }
            }

            // hieptq update 280515 set phi ho so cap lai
            if (pro != null && pro.getDescription() != null
                    && (pro.getDescription().equals(Constants.FILE_DESCRIPTION.RE_ANNOUNCEMENT)
                            || pro.getDescription().equals(Constants.FILE_DESCRIPTION.RE_CONFIRM_FUNC_IMP)
                            || pro.getDescription().equals(Constants.FILE_DESCRIPTION.REC_CONFIRM_NORMAL_IMP)
                            || pro.getDescription().equals(Constants.FILE_DESCRIPTION.RE_CONFIRM_FUNC_VN)
                            || pro.getDescription().equals(Constants.FILE_DESCRIPTION.RE_CONFIRM_NORMAL_VN))) {
                if (pro != null && pro.getTypeFee() == 2l) {
                    FeePaymentInfo fpif = new FeePaymentInfo();
                    Fee findfee1 = fdhe.findFeeByCode("CLT");
                    fpif.setCreateDate(dateNow);
                    fpif.setStatus(0l);
                    fpif.setFileId(fileId);
                    if (findfee1 != null) {
                        fpif.setFeeId(findfee1.getFeeId());
                        fpif.setCost(findfee1.getPrice());
                        fpif.setCostCheck(findfee1.getPrice());
                    } else {
                        return false;
                    }
                    fpif.setIsActive(1l);
                    getSession().save(fpif);
                    return true;
                } else if (pro != null && pro.getTypeFee() == 3l) {
                    FeePaymentInfo fpif = new FeePaymentInfo();
                    Fee findfee1 = fdhe.findFeeByCode("CLCN");
                    fpif.setCreateDate(dateNow);
                    fpif.setStatus(0l);
                    fpif.setFileId(fileId);
                    if (findfee1 != null) {
                        fpif.setFeeId(findfee1.getFeeId());
                        fpif.setCost(findfee1.getPrice());
                        fpif.setCostCheck(findfee1.getPrice());
                    } else {
                        return false;
                    }
                    fpif.setIsActive(1l);
                    getSession().save(fpif);
                    return true;
                } else {
                    return false;
                }
            } else {
                //check loai thuc pham (thuc pham dac biet)
                CategoryDAOHE ctdhe = new CategoryDAOHE();
                Category cate = ctdhe.findCategoryByTypeAndCode("SP", "TPCN");
                List<Category> cate1 = ctdhe.findCategoryByTypeAndCodeNew("SP", "DBT");
                int check = 0;
                for (int i = 0; i < cate1.size(); i++) {
                    if (productType.equals(cate1.get(i).getCategoryId())) {
                        check = 1;
                        break;
                    }
                }

                if (check == 1) {
                    FeePaymentInfo fpif = new FeePaymentInfo();
                    Fee findfee1 = fdhe.findFeeByCode("TPDB");
                    fpif.setCreateDate(dateNow);
                    fpif.setStatus(0l);
                    fpif.setFileId(fileId);
                    if (findfee1 != null) {
                        fpif.setFeeId(findfee1.getFeeId());
                        fpif.setCost(findfee1.getPrice());
                        fpif.setCostCheck(findfee1.getPrice());
                        fpif.setFeeIdOld(findfee1.getFeeId());
                    } else {
                        return false;
                    }
                    fpif.setIsActive(1l);
                    getSession().save(fpif);
                } else {
                    // thuc pham chuc nang
                    FeePaymentInfo fpif = new FeePaymentInfo();
                    if (productType.equals(cate.getCategoryId())) {
                        Fee findfee2 = fdhe.findFeeByCode("TPCN");

                        fpif.setCreateDate(dateNow);
                        fpif.setStatus(0l);
                        fpif.setFileId(fileId);
                        if (findfee2 != null) {
                            fpif.setFeeId(findfee2.getFeeId());
                            fpif.setCost(findfee2.getPrice());
                            fpif.setCostCheck(findfee2.getPrice());
                            fpif.setFeeIdOld(findfee2.getFeeId());
                        } else {
                            return false;
                        }
                        fpif.setIsActive(1l);
                        getSession().save(fpif);
                    } else {
                        Fee findfee3 = fdhe.findFeeByCode("TPK");
                        fpif.setCreateDate(dateNow);
                        fpif.setStatus(0l);
                        fpif.setFileId(fileId);
                        if (findfee3 != null) {
                            fpif.setFeeId(findfee3.getFeeId());
                            fpif.setCost(findfee3.getPrice());
                            fpif.setCostCheck(findfee3.getPrice());
                            fpif.setFeeIdOld(findfee3.getFeeId());
                        } else {
                            return false;
                        }
                        fpif.setIsActive(1l);
                        getSession().save(fpif);
                    }
                }
            }

            // }
        }
        // sua nhom san pham va chuyen loai ho so - map lai phi
        if ((productTypeIdOld != null) && (!productTypeIdOld.equals(productType))) {
            // hieptq update 310115
            // tim lai feeId cu 
            CategoryDAOHE ctdhe = new CategoryDAOHE();
            FeeDAOHE fdhe = new FeeDAOHE();
            Category cate = ctdhe.findCategoryByTypeAndCode("SP", "TPCN");
            List<Category> cate1 = ctdhe.findCategoryByTypeAndCodeNew("SP", "DBT");
            Long feeIdOld, feeIdNew;
            int check = 0, check1 = 0;
            FeePaymentInfo fpifOld;
            for (int i = 0; i < cate1.size(); i++) {
                if (productTypeIdOld.equals(cate1.get(i).getCategoryId())) {
                    check = 1;
                    break;
                }
            }
            if (check == 1) {
                Fee findfee1 = fdhe.findFeeByCode("TPDB");
                feeIdOld = findfee1.getFeeId();
            } else // thuc pham chuc nang
            if (productTypeIdOld.equals(cate.getCategoryId())) {
                Fee findfee2 = fdhe.findFeeByCode("TPCN");
                feeIdOld = findfee2.getFeeId();
            } else {
                Fee findfee3 = fdhe.findFeeByCode("TPK");
                feeIdOld = findfee3.getFeeId();
            }

            fpifOld = fdhe.findFeePaymentInfoFileIdFeeIdIsActive(fileId, feeIdOld, 1l);

            // lay feeid moi
            for (int i = 0; i < cate1.size(); i++) {
                if (productType.equals(cate1.get(i).getCategoryId())) {
                    check1 = 1;
                    break;
                }
            }
            Long costNew;
            if (check1 == 1) {
                Fee findfee1 = fdhe.findFeeByCode("TPDB");
                feeIdNew = findfee1.getFeeId();
                costNew = findfee1.getPrice();
            } else // thuc pham chuc nang
            if (productType.equals(cate.getCategoryId())) {
                Fee findfee2 = fdhe.findFeeByCode("TPCN");
                feeIdNew = findfee2.getFeeId();
                costNew = findfee2.getPrice();
            } else {
                Fee findfee3 = fdhe.findFeeByCode("TPK");
                feeIdNew = findfee3.getFeeId();
                costNew = findfee3.getPrice();
            }
            //fpifNew = fdhe.findFeePaymentInfoFileIdFeeIdIsActive(fileId, feeIdNew, 1l);
            FilesDAOHE filesdhe = new FilesDAOHE();
            Files filesnew = filesdhe.findById(fileId);
            // check gia cu va gia moi
            if (fpifOld.getCostCheck().equals(costNew) || fpifOld.getCostCheck() > costNew) {
                if (filesnew.getStatus() == 0l) {
                    fpifOld.setCost(fpifOld.getCostCheck());
                    fpifOld.setFeeId(fpifOld.getFeeIdOld());
                    getSession().update(fpifOld);
                } else {
                    //Long newCost = costNew - fpifOld.getCost();
                    fpifOld.setCost(fpifOld.getCostCheck());
                    fpifOld.setFeeId(fpifOld.getFeeIdOld());
                    fpifOld.setStatus(1l);
                    filesnew.setIsFee(1l);
                    getSession().update(filesnew);
                    getSession().update(fpifOld);
                }

                return true;
            } else if (filesnew.getStatus() == 0l) {
                fpifOld.setCost(costNew);
                fpifOld.setFeeId(feeIdNew);
                getSession().update(fpifOld);
            } else {
                //Long newCost = costNew - fpifOld.getCost();
                fpifOld.setCost(costNew);
                fpifOld.setFeeId(feeIdNew);
                fpifOld.setStatus(0l);
                //Hiepvv 0803 Khong tinh phi SDBS sau cong bo
                ProcedureDAOHE pHE = new ProcedureDAOHE();
                Procedure pdu = pHE.findById(filesnew.getFileType());
                if (pdu != null && pdu.getDescription() != null
                        && "announcementFile05".equals(pdu.getDescription())) {
                    filesnew.setIsFee(1l);
                } else {
                    filesnew.setIsFee(0l);
                    //update binhnt
                    //                        try {
                    //                            if ("true".equals(ResourceBundleUtil.getString("send_service", "config"))) {
                    //                                Helper h = new Helper();
                    //                                h.sendMs_340(filesnew.getFileId(), "Ho so ma: " + filesnew.getFileCode() + " Da duoc phe duyet yeu cau nop phi ho so.");
                    //                            }
                    //                        } catch (UnsupportedEncodingException ex) {
                    //                            Logger.getLogger(FilesDAOHE.class.getName()).log(Level.SEVERE, null, ex);
                    //                        }
                }
                getSession().update(filesnew);
                getSession().update(fpifOld);
            }
        }
    } else {
        return false;
    }
    return true;
}

From source file:com.viettel.hqmc.DAO.FilesDAO.java

/**
 * Vao trang khai bao ho so//from   w  w  w .  j av  a 2s . co  m
 *
 * @return
 */
public String toCreateFilePage() {
    //        Long fileId = getRequest().getParameter("fileId") == null ? 0L : Long.parseLong(getRequest().getParameter("fileId"));
    Long fileType = getRequest().getParameter("fileType") == null ? 0L
            : Long.parseLong(getRequest().getParameter("fileType"));
    Long checkEdit = getRequest().getParameter("checkEdit") == null ? 0L
            : Long.parseLong(getRequest().getParameter("checkEdit"));
    Long typeFee = getRequest().getParameter("typeFee") == null ? 0L
            : Long.parseLong(getRequest().getParameter("typeFee"));
    //      hiepvv check edit after announced
    Long isEdits = getRequest().getParameter("isEdit") == null ? 0L
            : Long.parseLong(getRequest().getParameter("isEdit"));
    if (fileType > 0L) {
        createForm = new FilesForm();
        createForm.setFileType(fileType);
    }
    Users user;
    UsersDAOHE udhe = new UsersDAOHE();
    user = udhe.findById(getUserId());

    Business bus;
    BusinessDAOHE bdhe = new BusinessDAOHE();
    bus = bdhe.findById(user.getBusinessId());
    //San pham ho so goc
    String proName = "";
    String manuName = "";
    String manuTel = "";
    String manuAdd = "";
    String manuEmail = "";
    String manuFax = "";
    String matchingTaget = "";
    String nameStaffProcess;
    Long staffProcessId;
    Date publishDate = null;
    String strReturn = ERROR_PERMISSION;
    if (createForm.getFileId() != null && createForm.getFileId() > 0l) {
        FilesDAOHE fdhe = new FilesDAOHE();
        createForm = fdhe.getFilesDetail(createForm.getFileId());
        //            //hiepvv SDBS sau cong bo
        if (isEdits > 0L) {
            String fileSourceCode = createForm.getFileCode();
            Long fileSource = createForm.getFileId();
            staffProcessId = createForm.getStaffProcess();
            nameStaffProcess = createForm.getNameStaffProcess();
            //Thong tin ho so cu
            proName = createForm.getAnnouncement().getProductName();
            manuName = createForm.getAnnouncement().getManufactureName();
            manuAdd = createForm.getAnnouncement().getManufactureAddress();
            manuEmail = createForm.getAnnouncement().getManufactureName();
            manuTel = createForm.getAnnouncement().getManufactureTel();
            manuFax = createForm.getAnnouncement().getManufactureFax();
            matchingTaget = createForm.getAnnouncement().getMatchingTarget();
            publishDate = createForm.getAnnouncementReceiptPaperForm().getReceiptDate();
            //end
            ProcedureDAOHE pdaohe = new ProcedureDAOHE();
            Procedure p = new Procedure();
            try {
                p = pdaohe.getProcedureByDescription(announcementFile05);
            } catch (Exception ex) {
                LogUtil.addLog(ex);//binhnt sonar a160901
                p = null;
                //                    Logger.getLogger(FilesDAO.class.getName()).log(Level.SEVERE, null, ex);
            }
            createForm = new FilesForm();
            if (p != null) {
                createForm.setFileType(p.getProcedureId());
            }
            createForm.setFilesSourceID(fileSource);
            createForm.setFileSourceCode(fileSourceCode);
            createForm.setStaffProcess(staffProcessId);//them nguoi tham dinh ho so truoc day
            createForm.setNameStaffProcess(nameStaffProcess);//them nguoi tham dinh ho so truoc day
        }
        //            if (!createForm.getFileType().equals(0L)) {
        //                ProcedureDAOHE cdhe = new ProcedureDAOHE();
        //                List lstTTHC = cdhe.getProcedureForChange(createForm.getFileType());
        //                lstCategory = new ArrayList();
        //                lstCategory.addAll(lstTTHC);
        //                lstCategory.add(0, new Procedure(Constants.COMBOBOX_HEADER_VALUE, Constants.COMBOBOX_HEADER_TEXT_SELECT));
        //                getRequest().setAttribute("lstFileType", lstCategory);
        //            }
    }

    if (createForm.getFileType() != null && createForm.getFileType() > 0l) {
        ProcedureDAOHE pdhe = new ProcedureDAOHE();
        CategoryDAOHE cdhe = new CategoryDAOHE();
        TechnicalStandardDAOHE tdhe = new TechnicalStandardDAOHE();
        FilesDAOHE fdhe = new FilesDAOHE();
        if (!fileType.equals(0L)) {
            createForm.setFileType(fileType);
        }
        Procedure tthc = pdhe.findById(createForm.getFileType());

        if (tthc != null) {

            //lstProductType = cdhe.findAllCategory("SP");//hieptq update 150415                
            if (checkEdit == 1) {
                typeFee = cdhe.findTypeFee(tthc.getProcedureId());
                lstProductType = cdhe.findAllCategoryByFee("SP", typeFee);
            } else {
                lstProductType = cdhe.findAllCategoryByFee("SP", typeFee);
            }

            if (((Category) lstProductType.get(0)).getCategoryId() != -1L) {
                lstProductType.add(0,
                        new Category(Constants.COMBOBOX_HEADER_VALUE, Constants.COMBOBOX_HEADER_TEXT_SELECT));
            }
            lstUnit = cdhe.findAllCategory("DVI");
            lstUnit.add(0,
                    new Category(Constants.COMBOBOX_HEADER_VALUE, Constants.COMBOBOX_HEADER_TEXT_SELECT));
            lstStandard = tdhe.findAllStandard();
            String lstDepts = convertToJSONData(lstStandard, "vietnameseName", "vietnameseName");
            getRequest().setAttribute("lstStandard", lstDepts);

            UserAttachsDAOHE uahe = new UserAttachsDAOHE();
            lstUserAttach = uahe.findAllUserAttach(getUserId());
            String lstUserAttachs = convertToJSONData(lstUserAttach, "attachName", "attachName");
            getRequest().setAttribute("lstUserAttach", lstUserAttachs);
            if (lstUserAttachs.trim().length() > 0) {
                createForm.setCountUA(1L);
            } else {
                createForm.setCountUA(0L);
            }

            getRequest().setAttribute("lstProductType", lstProductType);
            getRequest().setAttribute("lstUnit", lstUnit);
            String fileLst = tthc.getFileList();
            getRequest().setAttribute("fileList", com.viettel.common.util.StringUtils.removeHTML(fileLst));
            getRequest().setAttribute("agencyName", getDepartmentName());
            getRequest().setAttribute("fileNameFull", tthc.getName());
            // check edit hide excel tab
            getRequest().setAttribute("checkEdit", checkEdit);
            strReturn = tthc.getDescription();
            if (strReturn.equals(Constants.FILE_DESCRIPTION.ANNOUNCEMENT_FILE05) && isEdits == 1) {
                strReturn = Constants.FILE_DESCRIPTION.ANNOUNCEMENT_FILE05_PAPER;
            }
            if (createForm.getAnnouncement() != null) {
                if (createForm.getAnnouncement().getAnnouncementNo() != null
                        && createForm.getAnnouncement().getAnnouncementNo().length() > 0l && isEdits != 1L) {
                    CategoryDAOHE ctdhe = new CategoryDAOHE();
                    Category cate = ctdhe.findCategoryByTypeAndCode("SP", "TPCN");
                    Category cateTL = ctdhe.findCategoryByTypeAndCode("SP", "TL");
                    List<Category> cate1 = ctdhe.findCategoryByTypeAndCodeNew("SP", "DBT");
                    String dbtId = "";
                    for (int i = 0; i < cate1.size(); i++) {
                        dbtId += cate1.get(i).getCategoryId().toString() + ";";
                    }

                    Long tpcnId = cate.getCategoryId();
                    Long tlId = cateTL.getCategoryId();
                    FeeDAOHE fdhe1 = new FeeDAOHE();
                    Fee findfee1 = fdhe1.findFeeByCode("TPDB");
                    Long priceTPDB = findfee1.getPrice();
                    Fee findfee2 = fdhe1.findFeeByCode("TPCN");
                    Long priceTPCN = findfee2.getPrice();
                    Fee findfee3 = fdhe1.findFeeByCode("TPK");
                    Long priceETC = findfee3.getPrice();
                    getRequest().setAttribute("dbtId", dbtId);
                    getRequest().setAttribute("tpcnId", tlId);
                    getRequest().setAttribute("tlId", tpcnId);
                    getRequest().setAttribute("tpcnId", tpcnId);
                    getRequest().setAttribute("priceTPCN", priceTPCN);
                    getRequest().setAttribute("priceTPDB", priceTPDB);
                    getRequest().setAttribute("priceETC", priceETC);
                    return strReturn;
                }
            }
            if (strReturn.equals(Constants.FILE_DESCRIPTION.ANNOUNCEMENT_FILE01)
                    || strReturn.equals(Constants.FILE_DESCRIPTION.ANNOUNCEMENT_FILE03)
                    || strReturn.equals(Constants.FILE_DESCRIPTION.CONFIRM_FUNC_IMP)
                    || strReturn.equals(Constants.FILE_DESCRIPTION.CONFIRM_FUNC_VN)
                    || strReturn.equals(Constants.FILE_DESCRIPTION.CONFIRM_NORMAL_IMP)
                    || strReturn.equals(Constants.FILE_DESCRIPTION.CONFIRM_NORMAL_VN)
                    || strReturn.equals(Constants.FILE_DESCRIPTION.REC_CONFIRM_NORMAL_IMP)
                    || strReturn.equals(Constants.FILE_DESCRIPTION.RE_ANNOUNCEMENT)
                    || strReturn.equals(Constants.FILE_DESCRIPTION.RE_CONFIRM_FUNC_IMP)
                    || strReturn.equals(Constants.FILE_DESCRIPTION.RE_CONFIRM_FUNC_VN)
                    || strReturn.equals(Constants.FILE_DESCRIPTION.RE_CONFIRM_NORMAL_VN)
                    //hiepvv SDBS sau cong bo
                    || strReturn.equals(Constants.FILE_DESCRIPTION.ANNOUNCEMENT_FILE05)
                    || strReturn.equals(Constants.FILE_DESCRIPTION.ANNOUNCEMENT_FILE05_PAPER)
                    //hiepvv KS 4S
                    || strReturn.equals(Constants.FILE_DESCRIPTION.ANNOUNCEMENT_4STAR)) {
                String announcementNoStr = fdhe.getReceiptNoNew(getUserId(), getUserLogin(),
                        createForm.getFileType());
                createForm.setAnnouncement(new AnnouncementForm());
                createForm.getAnnouncement().setAnnouncementNo(announcementNoStr);
                // thong tin doanh nghiep
                createForm.getAnnouncement().setBusinessAddress(bus.getBusinessAddress());
                createForm.getAnnouncement().setBusinessFax(bus.getBusinessFax());
                createForm.getAnnouncement().setBusinessName(bus.getBusinessName());
                createForm.getAnnouncement().setBusinessTelephone(bus.getBusinessTelephone());
                createForm.getAnnouncement().setBusinessEmail(bus.getUserEmail());
                createForm.getAnnouncement().setBusinessLicence(bus.getBusinessLicense());
                // ho so cap lai 7-11
                createForm.setReIssueForm(new ReIssueFormForm());
                createForm.getReIssueForm().setBusinessName(bus.getBusinessName());
                createForm.getReIssueForm().setIdentificationNumber(bus.getBusinessLicense());
                createForm.getReIssueForm().setAddress(bus.getBusinessAddress());
                createForm.getReIssueForm().setEmail(bus.getUserEmail());
                createForm.getReIssueForm().setTelephone(bus.getBusinessTelephone());
                createForm.getReIssueForm().setFax(bus.getBusinessFax());
                //                    //San pham ho so goc
                if (strReturn.equals(Constants.FILE_DESCRIPTION.ANNOUNCEMENT_FILE05)
                        || strReturn.equals(Constants.FILE_DESCRIPTION.ANNOUNCEMENT_FILE05_PAPER)) {
                    createForm.getAnnouncement().setProductName(proName);
                    createForm.getAnnouncement().setManufactureAddress(manuAdd);
                    createForm.getAnnouncement().setManufactureName(manuName);
                    createForm.getAnnouncement().setManufactureTel(manuTel);
                    createForm.getAnnouncement().setManufactureEmail(manuEmail);
                    createForm.getAnnouncement().setManufactureFax(manuFax);
                    createForm.getAnnouncement().setMatchingTarget(matchingTaget);
                    createForm.getAnnouncement().setPublishDate(publishDate);
                    createForm.setIsFee(1L);
                }
            }
        }
        CategoryDAOHE ctdhe = new CategoryDAOHE();
        Category cate = ctdhe.findCategoryByTypeAndCode("SP", "TPCN");
        Category cateTL = ctdhe.findCategoryByTypeAndCode("SP", "TL");
        List<Category> cate1 = ctdhe.findCategoryByTypeAndCodeNew("SP", "DBT");
        String dbtId = "";
        for (int i = 0; i < cate1.size(); i++) {
            dbtId += cate1.get(i).getCategoryId().toString() + ";";
        }
        //            Category cate1 = ctdhe.findCategoryByTypeAndCode("SP", "DBT");
        //            Long dbtId = cate1.getCategoryId();
        Long tpcnId = cate.getCategoryId();
        Long tlId = cateTL.getCategoryId();
        FeeDAOHE fdhe1 = new FeeDAOHE();
        Fee findfee1 = fdhe1.findFeeByCode("TPDB");
        Long priceTPDB = findfee1.getPrice();
        Fee findfee2 = fdhe1.findFeeByCode("TPCN");
        Long priceTPCN = findfee2.getPrice();
        Fee findfee3 = fdhe1.findFeeByCode("TPK");
        Long priceETC = findfee3.getPrice();
        getRequest().setAttribute("dbtId", dbtId);
        getRequest().setAttribute("tpcnId", tpcnId);
        getRequest().setAttribute("tlId", tlId);
        getRequest().setAttribute("priceTPCN", priceTPCN);
        getRequest().setAttribute("priceTPDB", priceTPDB);
        getRequest().setAttribute("priceETC", priceETC);
    }
    return strReturn;
}

From source file:com.viettel.hqmc.DAO.FilesDAO.java

/**
 * lu lung x l//from w  w  w  . j  av  a 2s. c  o m
 *
 * @return
 */
public String onSaveProcess() {
    List resultMessage = new ArrayList();
    List customInfo = new ArrayList();
    String sid = "";
    Long staffProcess = 0l;
    String nameStaffProcess = "";
    Long leaderAssignId = 0L;
    String leaderAssignName = "";
    String type = getRequest().getParameter("type");
    String lstObjectId = getRequest().getParameter("lstObjectId");
    try {
        ProcessDAOHE pDaoHe = new ProcessDAOHE();
        Long fileId;
        if (lstProcessOnGrid != null && lstProcessOnGrid.size() > 0) {
            fileId = lstProcessOnGrid.get(0).getObjectId();

            Process p;
            Integer countObj = 1;
            String[] lstObjectIdSplit = null;
            if ("2".equals(type)) {
                lstObjectIdSplit = lstObjectId.split(",");
                countObj = lstObjectIdSplit.length;
            }
            Process processMain;
            List<Process> processSlave;
            for (int obj = 0; obj < countObj; obj++) {
                if ("2".equals(type)) {
                    fileId = Long.parseLong(lstObjectIdSplit[obj]);
                }
                processMain = pDaoHe.getProcessMain(getUserId(), getDepartmentId(), fileId,
                        Constants.OBJECT_TYPE.FILES, Constants.PROCESS_TYPE.MAIN);
                processSlave = pDaoHe.getProcessSalve(getUserId(), getDepartmentId(), fileId,
                        Constants.OBJECT_TYPE.FILES, Constants.PROCESS_TYPE.COOPERATE);
                for (int i = 0; i < lstProcessOnGrid.size(); i++) {
                    ProcessForm form = lstProcessOnGrid.get(i);
                    if (form.getProcessId() != null) {
                        p = pDaoHe.findById(form.getProcessId());
                        /*
                         if (Constants.PROCESS_TYPE.PROPOSE.equals(form.getProcessType())) {
                         form.setProcessType(Constants.PROCESS_TYPE.MAIN);
                         }
                         */
                        p.setProcessType(form.getProcessType());
                        p.setProcessStatus(Constants.FILE_STATUS.ASSIGNED);
                        p.setSendUser(getUserName());
                        p.setSendUserId(getUserId());
                        p.setSendGroup(getDepartmentName());
                        p.setSendGroupId(getDepartmentId());
                        p.setStatus(0l);
                        p.setIsActive(1L);
                        getSession().update(p);
                    } else {
                        // Check PROCESS_TYPE.MAIN
                        if (form.getProcessType() == Constants.PROCESS_TYPE.COOPERATE && processMain != null
                                && processMain.getReceiveUserId().equals(form.getReceiveUserId())) {
                            resultMessage.add("3");
                            resultMessage.add(
                                    "Thc hin phn cng x l khng thnh cng: Khng th phn cng X l chnh lm X l phi hp");
                            jsonDataGrid.setItems(resultMessage);
                            jsonDataGrid.setCustomInfo(customInfo);
                            return GRID_DATA;
                        }

                        // Check PROCESS_TYPE.MAIN
                        if (form.getProcessType() == Constants.PROCESS_TYPE.MAIN && processSlave != null
                                && processSlave.size() > 0) {
                            for (int j = 0; j < processSlave.size(); j++) {
                                if (processSlave.get(j).getSendUserId().equals(form.getReceiveUserId())) {
                                    resultMessage.add("3");
                                    resultMessage.add(
                                            "Thc hin phn cng x l chnh khng thnh cng: Bn cn xa vai tr x l phi hp trc khi phn x l chnh cho Cn b");
                                    jsonDataGrid.setItems(resultMessage);
                                    jsonDataGrid.setCustomInfo(customInfo);
                                    return GRID_DATA;
                                }
                            }
                        }
                        ProcessDAOHE psdhe = new ProcessDAOHE();
                        p = psdhe.getProcessByAction(fileId, Constants.Status.ACTIVE,
                                Constants.OBJECT_TYPE.FILES, Constants.FILE_STATUS.ASSIGNED,
                                Constants.FILE_STATUS.NEW_CREATE);
                        if (p != null) {
                            p.setSendUser(getUserName());
                            leaderAssignName = getUserName();
                            p.setSendUserId(getUserId());
                            leaderAssignId = getUserId();
                            p.setSendGroup(getDepartmentName());
                            p.setSendGroupId(getDepartmentId());
                            p.setObjectType(Constants.OBJECT_TYPE.FILES);
                            p.setProcessType(form.getProcessType());
                            p.setReceiveDate(getSysdate());
                            p.setReceiveUser(form.getReceiveUser());
                            nameStaffProcess = form.getReceiveUser();
                            p.setReceiveUserId(form.getReceiveUserId());
                            staffProcess = form.getReceiveUserId();
                            p.setReceiveGroup(form.getReceiveGroup());
                            p.setReceiveGroupId(form.getReceiveGroupId());
                            p.setObjectId(fileId);
                            p.setProcessStatus(Constants.FILE_STATUS.ASSIGNED);
                            p.setStatus(0l);
                            p.setIsActive(1L);
                            getSession().update(p);
                        } else {
                            p = new Process();
                            p.setSendUser(getUserName());
                            leaderAssignName = getUserName();
                            p.setSendUserId(getUserId());
                            leaderAssignId = getUserId();
                            p.setSendGroup(getDepartmentName());
                            p.setSendGroupId(getDepartmentId());
                            p.setObjectType(Constants.OBJECT_TYPE.FILES);
                            p.setProcessType(form.getProcessType());
                            p.setReceiveDate(getSysdate());
                            p.setReceiveUser(form.getReceiveUser());
                            nameStaffProcess = form.getReceiveUser();
                            p.setReceiveUserId(form.getReceiveUserId());
                            staffProcess = form.getReceiveUserId();
                            p.setReceiveGroup(form.getReceiveGroup());
                            p.setReceiveGroupId(form.getReceiveGroupId());
                            p.setObjectId(fileId);
                            p.setProcessStatus(Constants.FILE_STATUS.ASSIGNED);
                            p.setStatus(0l);
                            p.setIsActive(1L);
                            getSession().save(p);
                        }
                    }
                    if ("".equals(sid)) {
                        sid = p.getProcessId().toString();
                    } else {
                        sid = sid + "," + p.getProcessId().toString();
                    }
                    boolean bReturn = pDaoHe.deleteProcessNotIn(getUserId(), getDepartmentId(), fileId,
                            Constants.OBJECT_TYPE.FILES, sid);
                    if (!bReturn) {
                        resultMessage.add("3");
                        resultMessage.add("Thc hin phn cng x l khng thnh cng");
                        jsonDataGrid.setItems(resultMessage);
                        jsonDataGrid.setCustomInfo(customInfo);
                        return GRID_DATA;
                    }
                    Process pWorking = pDaoHe.getWorkingProcess(fileId, Constants.OBJECT_TYPE.FILES,
                            getDepartmentId());
                    if (pWorking != null) {
                        pWorking.setStatus(Constants.FILE_STATUS.ASSIGNED);
                        getSession().update(pWorking);
                    } else {
                        ProcessDAOHE psdhe = new ProcessDAOHE();
                        Process pold = psdhe.getProcessByAction(fileId, Constants.Status.ACTIVE,
                                Constants.OBJECT_TYPE.FILES, Constants.FILE_STATUS.RECEIVED,
                                Constants.FILE_STATUS.NEW_CREATE);
                        if (pold != null) {
                            pold.setStatus(Constants.FILE_STATUS.ASSIGNED);
                            getSession().update(pold);
                        }
                    }
                    if (fileId != null && fileId.longValue() > -1) {
                        FilesDAOHE fDAOHE = new FilesDAOHE();
                        Files f = fDAOHE.findById(fileId);
                        if (lstProcessOnGrid.size() > 0) {
                            f.setStatus(Constants.FILE_STATUS.ASSIGNED);
                            if (((f.getStaffProcess() != null
                                    && f.getStaffProcess().equals(getUserId()) == false)
                                    || f.getStaffProcess() == null) && !staffProcess.equals(0L)) {
                                f.setStaffProcess(staffProcess);
                                f.setNameStaffProcess(nameStaffProcess);
                            }
                            //add lanh dao phan cong vao ho so - 140915 binhnt53
                            if (f.getLeaderAssignId() == null) {
                                f.setLeaderAssignId(leaderAssignId);
                                f.setLeaderAssignName(leaderAssignName);
                            }

                        } else {
                            f.setStatus(Constants.FILE_STATUS.NEW);
                        }
                        f.setDisplayStatus(FilesDAOHE.getFileStatusName(f.getStatus()));
                        getSession().update(f);
                        fDAOHE.saveStatusFiles(f,
                                "Trng thi hin ti ca h s: ? thc hin phn cng h s m: "
                                        + f.getFileCode());
                    }
                }
            }
        }
        resultMessage.add("1");
        resultMessage.add("Thc hin phn cng x l thnh cng");
    } catch (Exception ex) {
        LogUtil.addLog(ex);//binhnt sonar a160901
        resultMessage.add("3");
        resultMessage.add("Thc hin phn cng x l khng thnh cng");
    }

    jsonDataGrid.setItems(resultMessage);
    jsonDataGrid.setCustomInfo(customInfo);
    return GRID_DATA;
}