/**
   * This is fucntion searchHoSoNoiGui Version: 1.0
   *
   * <p>History: DATE AUTHOR DESCRIPTION -------------------------------------------------
   * 3-March-2013 Nam Dinh Create new
   *
   * @param PortletRequest request, CongChuc canBoNoiGui, long[] thuTucGuiIds
   * @return QueryResult<HoSoLienThong>
   */
  public QueryResult<HoSoLienThong> searchHoSoNoiGui(
      PortletRequest request, CongChuc canBoNoiGui, long[] thuTucGuiIds) {

    String tenCongDanHoacMaBienNhan =
        ParamUtil.getString(request, HSLTFields.tenCongDanORMaBienNhanKhiGui);
    String sql = "SELECT * FROM CMON_HOSOLIENTHONG " + SQLBuilder.WHERE_HOLDER;
    DynamicSQLBuilder sqlBuilder = new DynamicSQLBuilder(sql, request);

    sqlBuilder.eq("CANBOGUIID", canBoNoiGui.getId());
    sqlBuilder.in("THUTUCGUIID", thuTucGuiIds);
    sqlBuilder.dynIntegerEQ("TRANGTHAILIENTHONG", HSLTFields.trangThaiLienThong);

    // La ma Bien Nhan
    if (IsNumeral.check(tenCongDanHoacMaBienNhan)) {

      sqlBuilder.stringLeft("MASOBIENNHANGUI", tenCongDanHoacMaBienNhan);

      // La ten cong dan nop
    } else if (!tenCongDanHoacMaBienNhan.isEmpty()) {

      sqlBuilder.stringRight("HOTENCONGDANNOP", tenCongDanHoacMaBienNhan);
    }

    sqlBuilder.eq("DAXOA", 0);
    sqlBuilder.orderDESC("NGAYSUA");

    SearchHelper<HoSoLienThong> helper = new SearchHelper<HoSoLienThong>(this, sqlBuilder);
    helper.createQuery().addEntity(HoSoLienThong.class.getSimpleName(), HoSoLienThongImpl.class);

    return helper.search();
  }
  /**
   * This is fucntion searchHoSoNoiNhan Version: 1.0
   *
   * <p>History: DATE AUTHOR DESCRIPTION -------------------------------------------------
   * 3-March-2013 Nam Dinh Create new
   *
   * @param PortletRequest request, CongChuc canBoNoiNhan, long[] thuTucNhanIds
   * @return QueryResult<HoSoLienThong>
   */
  public QueryResult<HoSoLienThong> searchHoSoNoiNhan(
      PortletRequest request, CongChuc canBoNoiNhan, long[] thuTucNhanIds) {

    DynamicSQLBuilder sqlBuilder =
        new DynamicSQLBuilder(
            CustomSQLUtil.get("org.oep.cmon.dao.hosolienthong.searchHoSoNoiNhan"), request);

    sqlBuilder.in("THUTUCNHANID", thuTucNhanIds);
    sqlBuilder.dynLongEQ("COQUANGUIID", HSLTFields.coQuanGuiId);
    sqlBuilder.dynIntegerEQ("TRANGTHAILIENTHONG", HSLTFields.trangThaiLienThong);
    sqlBuilder.eq("DAXOA", 0);
    sqlBuilder.orderDESC("NGAYSUA");

    SearchHelper<HoSoLienThong> helper = new SearchHelper<HoSoLienThong>(this, sqlBuilder);
    helper
        .createQuery()
        .addEntity(HoSoLienThong.class.getSimpleName(), HoSoLienThongImpl.class)
        .setInteger("TTLT_CHO_TIEP_NHAN", HSLTBusinessUtil.TTLT_CHO_TIEP_NHAN)
        .setLong("canBoNhanId", canBoNoiNhan.getId());

    return helper.search();
  }