Example usage for org.hibernate.criterion DetachedCriteria createAlias

List of usage examples for org.hibernate.criterion DetachedCriteria createAlias

Introduction

In this page you can find the example usage for org.hibernate.criterion DetachedCriteria createAlias.

Prototype

public DetachedCriteria createAlias(String associationPath, String alias) 

Source Link

Document

Creates an association path alias within this DetachedCriteria.

Usage

From source file:com.sccl.attech.modules.sys.utils.CriteriaUtil.java

License:Open Source License

/**
 *  project cond.//from w ww  . j  a  v a 2  s .  c o  m
 * ??
 * @param dc the dc
 * @param projectInfo the project info
 */
public static void createOfficeCond(DetachedCriteria dc, Office office, boolean isCompany) {
    if (null == office)
        return;
    if (isCompany) {
        dc.createAlias("company", "company");
        if (StringUtils.isNotBlank(office.getId()))
            dc.add(Restrictions.eq("company.id", office.getId()));
    } else {
        dc.createAlias("office", "office");
        if (StringUtils.isNotBlank(office.getId()))
            dc.add(Restrictions.eq("office.id", office.getId()));
    }
}

From source file:com.sccl.attech.modules.sys.utils.UserUtils.java

License:Open Source License

public static List<Role> getRoleList() {
    @SuppressWarnings("unchecked")
    List<Role> list = (List<Role>) getCache(CACHE_ROLE_LIST);
    if (list == null || list.size() <= 0) {
        User user = getUser();//from ww  w  .j ava2s . c om
        DetachedCriteria dc = roleDao.createDetachedCriteria();
        dc.createAlias("office", "office");
        //         dc.createAlias("userList", "userList", JoinType.LEFT_OUTER_JOIN);
        //         dc.add(dataScopeFilter(user, "office", "userList"));
        //         dc.createAlias("createBy","createBy");
        //         dc.add(Restrictions.eq("createBy.id",user.getId()));
        dc.add(dataScopeFilter(user, "office", "createBy"));
        dc.add(Restrictions.eq(Role.FIELD_DEL_FLAG, Role.DEL_FLAG_NORMAL));
        //         dc.addOrder(Order.asc("office.code")).addOrder(Order.asc("name"));
        list = roleDao.find(dc);
        putCache(CACHE_ROLE_LIST, list);
    }
    return list;
}

From source file:com.sccl.attech.modules.sys.utils.UserUtils.java

License:Open Source License

/**
 * ???/* ww  w . j av a 2s .  c o  m*/
 * @return
 */
public static List<Role> getRoleListByOrgName(String orgId) {
    @SuppressWarnings("unchecked")
    List<Role> list = (List<Role>) getCache(CACHE_ROLE_LIST);
    if (list == null || list.size() <= 0) {
        User user = getUser();
        DetachedCriteria dc = roleDao.createDetachedCriteria();
        dc.createAlias("office", "office");
        //         dc.createAlias("userList", "userList", JoinType.LEFT_OUTER_JOIN);
        //         dc.add(dataScopeFilter(user, "office", "userList"));
        //         dc.createAlias("createBy","createBy");
        //         dc.add(Restrictions.eq("createBy.id",user.getId()));
        dc.add(dataScopeFilter(user, "office", "createBy"));
        dc.add(Restrictions.eq(Role.FIELD_DEL_FLAG, Role.DEL_FLAG_NORMAL));
        //         dc.addOrder(Order.asc("office.code")).addOrder(Order.asc("name"));
        list = roleDao.find(dc);
        putCache(CACHE_ROLE_LIST, list);
    }
    return list;
}

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 ww  w.j  a v a2  s  .com
        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.baseinformation.service.impl.TbMembershipCardServiceImpl.java

public List<TbMembershipCard> findByTbMembershipCard(TbMembershipCard tbMembershipCard) {

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

    if (null != tbMembershipCard) {

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

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

        }/* w ww . j  av  a  2  s.  co  m*/

        if (null != tbMembershipCard.getCardStatus()) {

            detachedCriteria.add(Restrictions.eq("cardStatus", tbMembershipCard.getCardStatus()));

        }

        if (null != tbMembershipCard.getTmCardType() && null != tbMembershipCard.getTmCardType().getId()) {

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

            detachedCriteria.add(Restrictions.eq("tmCardType.id", tbMembershipCard.getTmCardType().getId()));

        }

        //boolean flag = false;

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

        //   flag = true;
        //   
        //   detachedCriteria.createAlias("tbCarInfo", "tbCarInfo");

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

        if ((null != tbMembershipCard.getCustomerName() && !"".equals(tbMembershipCard.getCustomerName()))
                || (null != tbMembershipCard.getTelephone() && !"".equals(tbMembershipCard.getTelephone())
                        || (null != tbMembershipCard.getCustomerId()))) {

            //detachedCriteria.setFetchMode("tbMembershipCard.tbCustomer", FetchMode.JOIN);

            //if(!flag)
            detachedCriteria.createAlias("tbCustomer", "tbCustomer");

        }

        if (null != tbMembershipCard.getCustomerId()) {

            detachedCriteria.add(Restrictions.eq("tbCustomer.id", tbMembershipCard.getCustomerId()));

        }

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

            detachedCriteria.add(Restrictions.like("tbCustomer.customerName",
                    "%" + tbMembershipCard.getCustomerName() + "%"));

        }

        if (null != tbMembershipCard.getTelephone() && !"".equals(tbMembershipCard.getTelephone())) {

            detachedCriteria.add(
                    Restrictions.like("tbCustomer.telephone", "%" + tbMembershipCard.getTelephone() + "%"));

        }

        //}

    }

    return tbMembershipCardDao.findByCriteria(detachedCriteria, tbMembershipCard);
}

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

public List<TbAnvancePay> findByTbAnvancePay(TbAnvancePay tbAnvancePay) {

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

    if (null != tbAnvancePay) {
        if (null != tbAnvancePay.getAnvanceCode()) {
            detachedCriteria.add(Restrictions.like("anvanceCode", "%" + tbAnvancePay.getAnvanceCode() + "%"));
        }//from  www.j  av  a 2 s . c  om
        if (null != tbAnvancePay.getTbCarInfo()) {
            detachedCriteria.createAlias("tbCarInfo", "tbCarInfo");

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

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()));
        }//w  w  w  .j  a v a2 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 a va  2 s  . 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.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  ww w  . j  av a  2  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  www.j av a2  s.co  m

        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);
}