Example usage for org.hibernate.criterion Restrictions ge

List of usage examples for org.hibernate.criterion Restrictions ge

Introduction

In this page you can find the example usage for org.hibernate.criterion Restrictions ge.

Prototype

public static SimpleExpression ge(String propertyName, Object value) 

Source Link

Document

Apply a "greater than or equal" constraint to the named property

Usage

From source file:com.scopix.periscope.extractionplanmanagement.dao.ExtractionPlanCustomizingDAOImpl.java

License:Open Source License

@Override
public List<EvidenceRequest> getFreeEvidenceRequestList(EvidenceRequest evidenceRequest, Date init, Date end) {
    List<EvidenceRequest> list = null;
    Session session = this.getSession();
    try {/*from   w ww .  j a  v a 2  s.  c o m*/
        Criteria criteria = session.createCriteria(EvidenceRequest.class);
        criteria.addOrder(Order.asc("id"));
        if (evidenceRequest != null) {
            if (init != null && end != null) {
                criteria.add(Restrictions.ge("evidenceTime", init));
                criteria.add(Restrictions.le("evidenceTime", end));
            } else if (init != null) {
                criteria.add(Restrictions.ge("evidenceTime", init));
            } else if (end != null) {
                criteria.add(Restrictions.le("evidenceTime", end));
            } else if (evidenceRequest.getEvidenceTime() != null) {
                criteria.add(Restrictions.eq("evidenceTime", evidenceRequest.getEvidenceTime()));
            }
            if (evidenceRequest.getType() != null) {
                criteria.add(Restrictions.eq("type", evidenceRequest.getType()));
            }
            if (evidenceRequest.getEvidenceProvider() != null
                    && evidenceRequest.getEvidenceProvider().getId() != null
                    && evidenceRequest.getEvidenceProvider().getId() > 0) {
                criteria.add(
                        Restrictions.eq("evidenceProvider.id", evidenceRequest.getEvidenceProvider().getId()));
            }
        }
        criteria.add(Restrictions.isNull("metric.id"));
        list = criteria.list();
    } catch (HibernateException e) {
        log.error(e, e);
    } finally {
        this.releaseSession(session);
    }
    return list;
}

From source file:com.segundo.piso.daos.impl.DAOReportImpl.java

@Override
@Transactional//from   ww w  . ja v  a 2  s  .  co m
public ReporteMovimientosAlumno movementsReport(Filters filters) {
    ReporteMovimientosAlumno reporte = null;
    Criteria criteria = this.sessionFactory.getCurrentSession().createCriteria(Movimiento.class, "movimiento")
            .createAlias("movimiento.idEvento", "evento").setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY)
            .addOrder(Order.desc("fechaInicio"));

    if (filters.getEvento() > 0) {
        criteria.add(Restrictions.eq("idEvento.id", filters.getEvento()));
    } else {
        criteria.add(Restrictions.ge("evento.diasMes", 1));
    }

    if (filters.getFechaInicio() != null) {
        criteria.add(Restrictions.ge("fechaInicio", filters.getFechaInicio()));
    }

    if (filters.getFechaFin() != null) {
        criteria.add(Restrictions.le("fechaInicio", filters.getFechaFin()));
    }

    List<Movimiento> movements = criteria.list();
    if (movements != null && !movements.isEmpty()) {
        for (Movimiento movement : movements) {
            if (movement.getPorcentaje()) {
                double percentage = movement.getDescuento() / 100;
                double discount = movement.getCosto() * percentage;
                movement.setDescuento((int) discount);
            }
        }

        reporte = totalMovements(criteria);
        reporte.setMovimientos(movements);
    }

    return reporte;
}

From source file:com.selfsoft.baseinformation.service.impl.TbCardHisServiceImpl.java

public List<TbCardHis> findByTbCardHis(TbCardHis tbCardHis) {

    DetachedCriteria detachedCriteria = DetachedCriteria.forClass(TbCardHis.class);

    if (null != tbCardHis) {

        if (null != tbCardHis.getCardNo() && !"".equals(tbCardHis.getCardNo())) {

            detachedCriteria.add(Restrictions.like("cardNo", "%" + tbCardHis.getCardNo() + "%"));

        }/*w  ww  .jav  a 2s  .  c  o m*/

        if (null != tbCardHis.getOperationDateFrom()) {

            detachedCriteria.add(Restrictions.ge("operationDate", tbCardHis.getOperationDateFrom()));

        }

        if (null != tbCardHis.getOperationDateTo()) {

            detachedCriteria.add(
                    Restrictions.le("operationDate", CommonMethod.addDate(tbCardHis.getOperationDateTo(), 1)));

        }

        if (null != tbCardHis.getLicenseCode() && !"".equals(tbCardHis.getLicenseCode())) {

            detachedCriteria.add(Restrictions.like("licenseCode", "%" + tbCardHis.getLicenseCode() + "%"));

        }

        if (null != tbCardHis.getOperationType() && !"".equals(tbCardHis.getOperationType())) {

            detachedCriteria.add(Restrictions.eq("operationType", tbCardHis.getOperationType()));

        }

        if (null != tbCardHis.getBalanceCode() && !"".equals(tbCardHis.getBalanceCode())) {
            detachedCriteria.add(Restrictions.like("balanceCode", "%" + tbCardHis.getBalanceCode() + "%"));
        }

        if (null != tbCardHis.getCustomerCode() && !"".equals(tbCardHis.getCustomerCode())) {

            detachedCriteria.add(Restrictions.eq("customerCode", tbCardHis.getCustomerCode()));

        }

        if (null != tbCardHis.getCustomerName() && !"".equals(tbCardHis.getCustomerName())) {

            detachedCriteria.add(Restrictions.eq("customerName", tbCardHis.getCustomerName()));

        }

    }

    else {

        return null;

    }

    /*List<TbCardHis> list = tbCardHisDao.findByCriteria(detachedCriteria, tbCardHis);
            
    List<TbCardHis> tbCardHisList = null;
            
    if(null != list && list.size() > 0){
               
       tbCardHisList = new ArrayList<TbCardHis>();
               
       for(TbCardHis _tbCardHis : list){
            
    TmUser tmUser = tmUserService.findById(_tbCardHis.getUserId());
            
    _tbCardHis.setTmUser(tmUser);
            
    tbCardHisList.add(_tbCardHis);
            
       }
               
    }*/

    return tbCardHisDao.findByCriteria(detachedCriteria, tbCardHis);
}

From source file:com.selfsoft.baseinformation.service.impl.TbCarInfoServiceImpl.java

public List<TbCarInfo> findByTbCarInfo(TbCarInfo tbCarInfo) {

    DetachedCriteria detachedCriteria = DetachedCriteria.forClass(TbCarInfo.class);

    if (null != tbCarInfo) {
        if (null != tbCarInfo.getId()) {
            detachedCriteria.add(Restrictions.eq("id", tbCarInfo.getId()));
        }/*from   w w w .j a v  a 2s. c  om*/
        if (null != tbCarInfo.getLicenseCode() && !"".equals(tbCarInfo.getLicenseCode())) {
            //?
            detachedCriteria.add(Restrictions.like("licenseCode", "%" + tbCarInfo.getLicenseCode() + "%"));
        }
        if (null != tbCarInfo.getInsureCardCode() && !"".equals(tbCarInfo.getInsureCardCode())) {
            detachedCriteria
                    .add(Restrictions.like("insureCardCode", "%" + tbCarInfo.getInsureCardCode() + "%"));
        }
        if (null != tbCarInfo.getTmCarModelType()) {

            detachedCriteria.createAlias("tmCarModelType", "tmCarModelType");

            if (null != tbCarInfo.getTmCarModelType().getId()) {
                detachedCriteria
                        .add(Restrictions.eq("tmCarModelType.id", tbCarInfo.getTmCarModelType().getId()));
            }
        }
        if (null != tbCarInfo.getTbCustomer()) {

            detachedCriteria.createAlias("tbCustomer", "tbCustomer");

            if (null != tbCarInfo.getTbCustomer().getId()) {
                detachedCriteria.add(Restrictions.eq("tbCustomer.id", tbCarInfo.getTbCustomer().getId()));
            }
            if (null != tbCarInfo.getTbCustomer().getCustomerCode()) {
                detachedCriteria.add(Restrictions.like("tbCustomer.customerCode",
                        "%" + tbCarInfo.getTbCustomer().getCustomerCode() + "%"));
            }
            if (null != tbCarInfo.getTbCustomer().getCustomerName()) {
                detachedCriteria.add(Restrictions.like("tbCustomer.customerName",
                        "%" + tbCarInfo.getTbCustomer().getCustomerName() + "%"));
            }
            if (null != tbCarInfo.getTbCustomer().getTelephone()) {
                detachedCriteria.add(Restrictions.like("tbCustomer.telephone",
                        "%" + tbCarInfo.getTbCustomer().getTelephone() + "%"));
            }
        }

        if (StringUtils.isNotBlank(tbCarInfo.getBeginLicenseDate())) {
            detachedCriteria.add(Restrictions.ge("licenseDate", Date.valueOf(tbCarInfo.getBeginLicenseDate())));
        }

        if (StringUtils.isNotBlank(tbCarInfo.getEndLicenseDate())) {
            detachedCriteria.add(Restrictions.le("licenseDate", Date.valueOf(tbCarInfo.getEndLicenseDate())));
        }

        if (StringUtils.isNotBlank(tbCarInfo.getBeginPurchaseDate())) {
            detachedCriteria
                    .add(Restrictions.ge("purchaseDate", Date.valueOf(tbCarInfo.getBeginPurchaseDate())));
        }

        if (StringUtils.isNotBlank(tbCarInfo.getEndPurchaseDate())) {
            detachedCriteria.add(Restrictions.le("purchaseDate", Date.valueOf(tbCarInfo.getEndPurchaseDate())));
        }
        if (StringUtils.isNotBlank(tbCarInfo.getChassisCode())) {
            detachedCriteria.add(Restrictions.like("chassisCode", "%" + tbCarInfo.getChassisCode() + "%"));
        }

        if (tbCarInfo.getCarProperty() != null) {
            detachedCriteria.add(Restrictions.eq("carProperty", tbCarInfo.getCarProperty()));
        }

        if (StringUtils.isNotBlank(tbCarInfo.getLicenseMonth())) {
            detachedCriteria
                    .add(Restrictions.sqlRestriction("month(LICENSE_DATE)=" + tbCarInfo.getLicenseMonth()));
        }
        if (tbCarInfo.getMaxKilo() != null && tbCarInfo.getMinKilo() != null) {
            detachedCriteria.add(Restrictions.between("kilo", tbCarInfo.getMinKilo(), tbCarInfo.getMaxKilo()));
        }
    }

    return tbCarInfoDao.findByCriteria(detachedCriteria, tbCarInfo);
}

From source file:com.selfsoft.business.service.impl.TbBookServiceImpl.java

public List<TbBook> findByTbBook(TbBook tbBook) {
    // TODO Auto-generated method stub
    DetachedCriteria detachedCriteria = DetachedCriteria.forClass(TbBook.class);

    if (null != tbBook) {
        if (null != tbBook.getId()) {
            detachedCriteria.add(Restrictions.eq("id", tbBook.getId()));
        }/*from w w w .j a v a 2  s.c  o  m*/
        if (null != tbBook.getBookCode()) {
            detachedCriteria.add(Restrictions.like("bookCode", "%" + tbBook.getBookCode() + "%"));
        }
        if (null != tbBook.getRegisterDateStart()) {
            detachedCriteria.add(Restrictions.ge("registerDate", tbBook.getRegisterDateStart()));
        }
        if (null != tbBook.getRegisterDateEnd()) {
            detachedCriteria.add(Restrictions.le("registerDate", tbBook.getRegisterDateEnd()));
        }
        if (null != tbBook.getLicenseCode() && !"".equals(tbBook.getLicenseCode())) {
            detachedCriteria.add(Restrictions.like("licenseCode", "%" + tbBook.getLicenseCode() + "%"));
        }
        if (null != tbBook.getIsCome()) {
            detachedCriteria.add(Restrictions.eq("isCome", tbBook.getIsCome()));
        }
        if (null != tbBook.getPlanFixTimeStart()) {
            detachedCriteria.add(Restrictions.ge("planFixTime", tbBook.getPlanFixTimeStart()));
        }
        if (null != tbBook.getPlanFixTimeEnd()) {
            detachedCriteria.add(Restrictions.le("planFixTime", tbBook.getPlanFixTimeEnd()));
        }
        if (null != tbBook.getTmUser()) {

            if (null != tbBook.getTmUser().getId()) {

                detachedCriteria.createAlias("tmUser", "tmUser");

                detachedCriteria.add(Restrictions.eq("tmUser.id", tbBook.getTmUser().getId()));

            }
        }
    }

    return tbBookDao.findByCriteria(detachedCriteria, tbBook);
}

From source file:com.selfsoft.business.service.impl.TbBusinessBalanceServiceImpl.java

public List<TbBusinessBalance> findByTbBusinessBalance(TbBusinessBalance tbBusinessBalance) {

    DetachedCriteria detachedCriteria = DetachedCriteria.forClass(TbBusinessBalance.class);

    if (null != tbBusinessBalance) {

        if (null != tbBusinessBalance.getBalanceCode() && !"".equals(tbBusinessBalance.getBalanceCode())) {
            detachedCriteria//from  ww w.j ava 2s . c  om
                    .add(Restrictions.like("balanceCode", "%" + tbBusinessBalance.getBalanceCode() + "%"));
        }
        if (null != tbBusinessBalance.getTbFixEntrust()) {

            if (null != tbBusinessBalance.getTbFixEntrust().getEntrustCode()
                    && !"".equals(tbBusinessBalance.getTbFixEntrust().getEntrustCode())) {
                detachedCriteria.createAlias("tbFixEntrust", "tbFixEntrust");

                detachedCriteria.add(Restrictions.like("tbFixEntrust.entrustCode",
                        "%" + tbBusinessBalance.getTbFixEntrust().getEntrustCode() + "%"));
            }
        }

        if (null != tbBusinessBalance.getLicenseCode() && !"".equals(tbBusinessBalance.getLicenseCode())) {

            if ((null == tbBusinessBalance.getTbFixEntrust().getEntrustCode()
                    || "".equals(tbBusinessBalance.getTbFixEntrust().getEntrustCode())))
                detachedCriteria.createAlias("tbFixEntrust", "tbFixEntrust");

            detachedCriteria.createAlias("tbFixEntrust.tbCarInfo", "tbCarInfo");

            detachedCriteria.add(
                    Restrictions.like("tbCarInfo.licenseCode", "%" + tbBusinessBalance.getLicenseCode() + "%"));

        }

        if (null != tbBusinessBalance.getTmUser()) {

            if (null != tbBusinessBalance.getTmUser().getId()) {

                detachedCriteria.createAlias("tmUser", "tmUser");

                detachedCriteria.add(Restrictions.eq("tmUser.id", +tbBusinessBalance.getTmUser().getId()));

            }

        }

        if (null != tbBusinessBalance.getUserId()) {

            if ((null == tbBusinessBalance.getTbFixEntrust().getEntrustCode()
                    || "".equals(tbBusinessBalance.getTbFixEntrust().getEntrustCode()))
                    && (null == tbBusinessBalance.getLicenseCode()
                            || "".equals(tbBusinessBalance.getLicenseCode())))
                detachedCriteria.createAlias("tbFixEntrust", "tbFixEntrust");

            if (null == tbBusinessBalance.getTmUser() || null == tbBusinessBalance.getTmUser().getId())

                detachedCriteria.createAlias("tbFixEntrust.tmUser", "tmUser");

            detachedCriteria.add(Restrictions.eq("tmUser.id", +tbBusinessBalance.getUserId()));

        }

        if (null != tbBusinessBalance.getBananceDateStart()) {
            detachedCriteria.add(Restrictions.ge("bananceDate", tbBusinessBalance.getBananceDateStart()));
        }
        if (null != tbBusinessBalance.getBananceDateEnd()) {
            detachedCriteria.add(Restrictions.le("bananceDate",
                    CommonMethod.addDate(tbBusinessBalance.getBananceDateEnd(), 1)));
        }
        if (null != tbBusinessBalance.getBalanceStatus()) {
            detachedCriteria.add(Restrictions.eq("balanceStatus", tbBusinessBalance.getBalanceStatus()));
        }
        if (null != tbBusinessBalance.getTmModelTypeId()) {

            if (null == tbBusinessBalance.getTbFixEntrust()
                    && (null == tbBusinessBalance.getLicenseCode()
                            || "".equals(tbBusinessBalance.getLicenseCode()))
                    && null == tbBusinessBalance.getUserId())

                detachedCriteria.createAlias("tbFixEntrust", "tbFixEntrust");

            detachedCriteria.createAlias("tbFixEntrust.tbCarInfo", "tbCarInfo");

            detachedCriteria.createAlias("tbCarInfo.tmCarModelType", "tmCarModelType");

            detachedCriteria.add(Restrictions.eq("tmCarModelType.id", tbBusinessBalance.getTmModelTypeId()));
        }

    }

    return tbBusinessBalanceDao.findByCriteria(detachedCriteria, tbBusinessBalance);

}

From source file:com.selfsoft.business.service.impl.TbBusinessSpecialBalanceServiceImpl.java

public List<TbBusinessSpecialBalance> findByTbBusinessSpecialBalance(
        TbBusinessSpecialBalance tbBusinessSpecialBalance) {

    DetachedCriteria detachedCriteria = DetachedCriteria.forClass(TbBusinessSpecialBalance.class);

    if (null != tbBusinessSpecialBalance) {

        if (null != tbBusinessSpecialBalance.getEditCode()
                && !"".equals(tbBusinessSpecialBalance.getEditCode())) {

            detachedCriteria/*from   w w  w .jav a 2  s.  c o m*/
                    .add(Restrictions.like("editCode", "%" + tbBusinessSpecialBalance.getEditCode() + "%"));
        }
        /*
         * if(null!=tbBusinessSpecialBalance.getBananceDateStart()){
         * detachedCriteria.add(Restrictions.ge("bananceDate",
         * tbBusinessSpecialBalance.getBananceDateStart())); }
         * if(null!=tbBusinessSpecialBalance.getBananceDateEnd()){
         * detachedCriteria.add(Restrictions.le("bananceDate",
         * tbBusinessSpecialBalance.getBananceDateEnd())); }
         */
        if (null != tbBusinessSpecialBalance.getSpecialType()) {
            detachedCriteria.add(Restrictions.eq("specialType", tbBusinessSpecialBalance.getSpecialType()));
        }
        if (null != tbBusinessSpecialBalance.getBalanceCodeDB()
                && !"".equals(tbBusinessSpecialBalance.getBalanceCodeDB())) {
            detachedCriteria.add(
                    Restrictions.like("balanceCode", "%" + tbBusinessSpecialBalance.getBalanceCodeDB() + "%"));
        }
        if (null != tbBusinessSpecialBalance.getBalanceCode()
                && !"".equals(tbBusinessSpecialBalance.getBalanceCode())) {

            List<TbBusinessBalance> tbBusinessBalanceList = tbBusinessBalanceService
                    .findTbBusinessBalanceByBalanceCode(tbBusinessSpecialBalance.getBalanceCode());

            if (null != tbBusinessBalanceList && tbBusinessBalanceList.size() > 0) {

                detachedCriteria
                        .add(Restrictions.eq("tbBusinessBalance.id", tbBusinessBalanceList.get(0).getId()));

            }

        }
        if (null != tbBusinessSpecialBalance.getEntrustCodeDB()
                && !"".equals(tbBusinessSpecialBalance.getEntrustCodeDB())) {
            detachedCriteria.add(
                    Restrictions.like("entrustCode", "%" + tbBusinessSpecialBalance.getEntrustCodeDB() + "%"));
        }
        // if(null!=tbBusinessSpecialBalance.getTbBusinessBalance()){

        /*
         * detachedCriteria.createAlias("tbBusinessBalance","tbBusinessBalance"
         * );
         * 
         * if(null!=tbBusinessSpecialBalance.getTbBusinessBalance().
         * getBalanceCode
         * ()&&!"".equals(tbBusinessSpecialBalance.getTbBusinessBalance
         * ().getBalanceCode())){ detachedCriteria.add(Restrictions.like(
         * "tbBusinessBalance.balanceCode",
         * "%"+tbBusinessSpecialBalance.getTbBusinessBalance
         * ().getBalanceCode()+"%")); }
         */

        if (null != tbBusinessSpecialBalance.getEntrustCode()
                && !"".equals(tbBusinessSpecialBalance.getEntrustCode())) {
            // detachedCriteria.createAlias("tbBusinessBalance.tbFixEntrust","tbFixEntrust");
            TbFixEntrust tbFixEntrust = tbFixEntrustService
                    .findByEntrustCode(tbBusinessSpecialBalance.getEntrustCode());

            if (null != tbFixEntrust) {

                TbBusinessBalance tbBusinessBalance = tbBusinessBalanceService
                        .findByEntrustId(tbFixEntrust.getId());

                if (null != tbBusinessBalance) {

                    detachedCriteria.add(
                            Restrictions.or(Restrictions.eq("tbBusinessBalance.id", tbBusinessBalance.getId()),
                                    Restrictions.like("entrustId", tbFixEntrust.getId())));

                }

                else {

                    detachedCriteria.add(Restrictions.like("entrustId", tbFixEntrust.getId()));

                }
            }

        }
        if (null != tbBusinessSpecialBalance.getBananceDateStart()) {
            detachedCriteria
                    .add(Restrictions.ge("bananceDate", tbBusinessSpecialBalance.getBananceDateStart()));
        }
        if (null != tbBusinessSpecialBalance.getBananceDateEnd()) {
            detachedCriteria.add(Restrictions.le("bananceDate",
                    CommonMethod.addDate(tbBusinessSpecialBalance.getBananceDateEnd(), 1)));
        }

        // }

    }

    return tbBusinessSpecialBalanceDao.findByCriteria(detachedCriteria, tbBusinessSpecialBalance);
}

From source file:com.selfsoft.business.service.impl.TbFixEntrustCostServiceImpl.java

public List<TbFixEntrustCost> findByTbFixEntrustCost(TbFixEntrustCost tbFixEntrustCost) {

    DetachedCriteria detachedCriteria = DetachedCriteria.forClass(TbFixEntrustCost.class);

    if (null != tbFixEntrustCost) {

        if (null != tbFixEntrustCost.getTbFixEntrust()) {

            detachedCriteria.createAlias("tbFixEntrust", "tbFixEntrust");

            if (null != tbFixEntrustCost.getTbFixEntrust().getEntrustCode()
                    && !"".equals(tbFixEntrustCost.getTbFixEntrust().getEntrustCode())) {
                detachedCriteria.add(Restrictions.like("tbFixEntrust.entrustCode",
                        "%" + tbFixEntrustCost.getTbFixEntrust().getEntrustCode() + "%"));
            }//from w  w w  .  jav a2  s  .  c  o  m

            if (null != tbFixEntrustCost.getTbFixEntrust().getFixDateStart()) {
                detachedCriteria.add(Restrictions.ge("tbFixEntrust.fixDate",
                        tbFixEntrustCost.getTbFixEntrust().getFixDateStart()));
            }
            if (null != tbFixEntrustCost.getTbFixEntrust().getFixDateEnd()) {
                detachedCriteria.add(Restrictions.le("tbFixEntrust.fixDate",
                        CommonMethod.addDate(tbFixEntrustCost.getTbFixEntrust().getFixDateEnd(), 1)));
            }

            if (null != tbFixEntrustCost.getTbFixEntrust().getTbCarInfo()) {

                detachedCriteria.createAlias("tbFixEntrust.tbCarInfo", "tbCarInfo");

                if (null != tbFixEntrustCost.getTbFixEntrust().getTbCarInfo().getLicenseCode()
                        && !"".equals(tbFixEntrustCost.getTbFixEntrust().getTbCarInfo().getLicenseCode())) {
                    detachedCriteria.add(Restrictions.like("tbCarInfo.licenseCode",
                            "%" + tbFixEntrustCost.getTbFixEntrust().getTbCarInfo().getLicenseCode() + "%"));
                }

            }
        }

    }

    return tbFixEntrustCostDao.findByCriteria(detachedCriteria, tbFixEntrustCost);
}

From source file:com.selfsoft.business.service.impl.TbFixEntrustServiceImpl.java

public List<TbFixEntrust> findByTbFixEntrust(TbFixEntrust tbFixEntrust) {
    // TODO Auto-generated method stub
    DetachedCriteria detachedCriteria = DetachedCriteria.forClass(TbFixEntrust.class);

    if (null != tbFixEntrust) {

        if (null != tbFixEntrust.getId()) {
            detachedCriteria.add(Restrictions.eq("id", tbFixEntrust.getId()));
        }//from w w  w.j a va 2  s. c om

        if (null != tbFixEntrust.getEntrustCode() && !"".equals(tbFixEntrust.getEntrustCode())) {
            detachedCriteria.add(Restrictions.like("entrustCode", "%" + tbFixEntrust.getEntrustCode() + "%"));
        }
        if (null != tbFixEntrust.getFixDateStart()) {
            detachedCriteria.add(Restrictions.ge("fixDate", tbFixEntrust.getFixDateStart()));
        }
        if (null != tbFixEntrust.getFixDateEnd()) {
            detachedCriteria
                    .add(Restrictions.le("fixDate", CommonMethod.addDate(tbFixEntrust.getFixDateEnd(), 1)));
        }

        if (null != tbFixEntrust.getMinutes()) {

            Date newDate = new Date();

            tbFixEntrust.setEstimateDateStart(newDate);

            tbFixEntrust.setEstimateDateEnd(CommonMethod.addMinute(new Date(), tbFixEntrust.getMinutes()));

            if (null != tbFixEntrust.getEstimateDateStart()) {
                detachedCriteria.add(Restrictions.ge("estimateDate", tbFixEntrust.getEstimateDateStart()));
            }
            if (null != tbFixEntrust.getEstimateDateEnd()) {
                detachedCriteria.add(Restrictions.le("estimateDate", tbFixEntrust.getEstimateDateEnd()));
            }
        }

        if (null != tbFixEntrust.getTbCustomer()) {

            boolean customerCodeBoolean = (null != tbFixEntrust.getTbCustomer().getCustomerCode()
                    && !"".equals(tbFixEntrust.getTbCustomer().getCustomerCode()));

            boolean customerNameBoolean = (null != tbFixEntrust.getTbCustomer().getCustomerName()
                    && !"".equals(tbFixEntrust.getTbCustomer().getCustomerName()));

            boolean telephoneBoolean = (null != tbFixEntrust.getTbCustomer().getTelephone()
                    && !"".equals(tbFixEntrust.getTbCustomer().getTelephone()));

            if (customerCodeBoolean || customerNameBoolean || telephoneBoolean) {

                detachedCriteria.createAlias("tbCustomer", "tbCustomer");
            }

            if (null != tbFixEntrust.getTbCustomer().getCustomerCode()
                    && !"".equals(tbFixEntrust.getTbCustomer().getCustomerCode())) {
                detachedCriteria.add(Restrictions.like("tbCustomer.customerCode",
                        "%" + tbFixEntrust.getTbCustomer().getCustomerCode() + "%"));
            }

            if (null != tbFixEntrust.getTbCustomer().getCustomerName()
                    && !"".equals(tbFixEntrust.getTbCustomer().getCustomerName())) {
                detachedCriteria.add(Restrictions.like("tbCustomer.customerName",
                        "%" + tbFixEntrust.getTbCustomer().getCustomerName() + "%"));
            }

            if (null != tbFixEntrust.getTbCustomer().getTelephone()
                    && !"".equals(tbFixEntrust.getTbCustomer().getTelephone())) {
                detachedCriteria.add(Restrictions.like("tbCustomer.telephone",
                        "%" + tbFixEntrust.getTbCustomer().getTelephone() + "%"));
            }
        }

        if (null != tbFixEntrust.getTbCarInfo()) {
            detachedCriteria.createAlias("tbCarInfo", "tbCarInfo");

            if (null != tbFixEntrust.getTbCarInfo().getLicenseCode()) {
                detachedCriteria.add(Restrictions.like("tbCarInfo.licenseCode",
                        "%" + tbFixEntrust.getTbCarInfo().getLicenseCode() + "%"));
            }

            if (null != tbFixEntrust.getTbCarInfo().getChassisCode()) {
                detachedCriteria.add(Restrictions.like("tbCarInfo.chassisCode",
                        "%" + tbFixEntrust.getTbCarInfo().getChassisCode() + "%"));
            }

            if (null != tbFixEntrust.getTbCarInfo().getTmCarModelType()) {
                detachedCriteria.createAlias("tbCarInfo.tmCarModelType", "tmCarModelType");

                if (null != tbFixEntrust.getTbCarInfo().getTmCarModelType().getId()) {
                    detachedCriteria.add(Restrictions.eq("tmCarModelType.id",
                            tbFixEntrust.getTbCarInfo().getTmCarModelType().getId()));
                }
            }
        }

        if (null != tbFixEntrust.getIsvalid()) {
            detachedCriteria.add(Restrictions.eq("isvalid", tbFixEntrust.getIsvalid()));
        }

        if (null != tbFixEntrust.getIsFinish()) {
            detachedCriteria.add(Restrictions.eq("isFinish", tbFixEntrust.getIsFinish()));
        }

        if (null != tbFixEntrust.getEntrustStatus()) {
            detachedCriteria.add(Restrictions.eq("entrustStatus", tbFixEntrust.getEntrustStatus()));
        }

        if (null != tbFixEntrust.getWjg() && !"".equals(tbFixEntrust.getWjg())) {

            if ("wjg".equals(tbFixEntrust.getWjg())) {

                detachedCriteria.add(Restrictions.ne("entrustStatus", 2L));

                detachedCriteria.add(Restrictions.ne("entrustStatus", 3L));

            }

            else if ("yjg".equals(tbFixEntrust.getWjg())) {

                detachedCriteria.add(Restrictions.or(Restrictions.eq("entrustStatus", 2L),
                        Restrictions.eq("entrustStatus", 3L)));

            }
        }

        if (null != tbFixEntrust.getJsqk() && !"".equals(tbFixEntrust.getJsqk())) {

            if ("wjs".equals(tbFixEntrust.getJsqk())) {

                detachedCriteria.add(Restrictions.ne("entrustStatus", 3L));

            }

            else if ("yjs".equals(tbFixEntrust.getJsqk())) {

                detachedCriteria.add(Restrictions.eq("entrustStatus", 3L));

            }
        }

        if (null != tbFixEntrust.getTmUser() && null != tbFixEntrust.getTmUser().getId()) {

            detachedCriteria.add(Restrictions.eq("tmUser.id", tbFixEntrust.getTmUser().getId()));

        }

    }
    return tbFixEntrustDao.findByCriteria(detachedCriteria, tbFixEntrust);
}

From source file:com.selfsoft.business.service.impl.TbFixEntrustServiceImpl.java

/**
 * ???//from  w ww.  ja  va2s.  c om
 */
public List<TbFixEntrust> findMaintainCarFixEntrust() {

    DetachedCriteria detachedCriteria = DetachedCriteria.forClass(TbFixEntrust.class);

    detachedCriteria.add(Restrictions.ge("remindMaintainDate",
            CommonMethod.addDate(new Date(), 0 - tmAlertDayService.findAll().get(0).getContinueDay())));

    detachedCriteria.add(Restrictions.le("remindMaintainDate",
            CommonMethod.addDate(new Date(), (0 + tmAlertDayService.findAll().get(0).getAlertDay()))));

    return tbFixEntrustDao.findByCriteria(detachedCriteria, null);
}