/**
   * 一覧取得
   *
   * @param form
   * @param locale
   * @return
   */
  public List<SpSupportDto> findSupportBatchTarget(SupportForm form, Locale locale) {
    logger.infoCode("I0001"); // I0001=メソッド開始:{0}

    Date today = DateUtil.toDate(DateUtil.getSysdate("yyyyMMdd"));

    // 取得条件:公開
    Specification<SpSupportTbl> wherePublicFlag =
        StringUtil.isNull(form.getSearchPublicFlag())
            ? null
            : new Specification<SpSupportTbl>() {
              @Override
              public Predicate toPredicate(
                  Root<SpSupportTbl> root, CriteriaQuery<?> query, CriteriaBuilder cb) {
                return cb.equal(root.get("publicFlag"), form.getSearchPublicFlag());
              }
            };

    // 取得条件:日付
    Specification<SpSupportTbl> whereEnDay =
        StringUtil.isNull(form.getSearchDateType())
            ? null
            : new Specification<SpSupportTbl>() {
              @Override
              public Predicate toPredicate(
                  Root<SpSupportTbl> root, CriteriaQuery<?> query, CriteriaBuilder cb) {
                // batch処理
                if (SEARCH_DATE_TYPE_BATCH.equals(form.getSearchDateType().toLowerCase())) {
                  Predicate predicate = cb.conjunction();
                  Predicate predicate2 = cb.conjunction();
                  predicate2 =
                      cb.and(predicate2, cb.equal(root.get("updDate").as(Date.class), today));
                  predicate2 =
                      cb.and(
                          predicate2, cb.lessThan(root.get("eventSendDate").as(Date.class), today));

                  predicate =
                      cb.and(predicate, cb.equal(root.get("eventSendDate").as(Date.class), today));
                  predicate = cb.or(predicate2);
                  return predicate;
                }
                return null;
              }
            };

    List<SpSupportTbl> list =
        spSupportTblRepository.findAll(Specifications.where(wherePublicFlag).and(whereEnDay));

    logger.infoCode("I0002"); // I0002=メソッド終了:{0}
    return getDtoList(list, locale);
  }
  public List<T> findAll(UserInfo userInfo, F form) {
    logger.infoCode("I0001");

    // 必須
    Specification<T> whereUserKey =
        new Specification<T>() {
          @Override
          public Predicate toPredicate(Root<T> root, CriteriaQuery<?> query, CriteriaBuilder cb) {
            return cb.equal(root.get("usUserTbl").get("userKey"), userInfo.getTargetUserKey());
          }
        };
    // 言語
    Specification<T> whereLanguage =
        StringUtil.isNull(form.getLanguage())
            ? null
            : new Specification<T>() {
              @Override
              public Predicate toPredicate(
                  Root<T> root, CriteriaQuery<?> query, CriteriaBuilder cb) {
                return cb.equal(root.get("paperLanguage"), form.getLanguage());
              }
            };

    List<T> list =
        (List<T>)
            repository.findAll(
                (Specification<T>) Specifications.where(whereUserKey).and(whereLanguage));

    logger.infoCode("I0002");
    return list;
  }
  /**
   * 支援制度キーとデータ更新日指定取得
   *
   * @param supportKey
   * @param updDate
   * @return
   */
  public SpSupportTbl findOne(final String supportKey, final Timestamp updDate) {
    logger.infoCode("I0001"); // I0001=メソッド開始:{0}

    // キー
    Specification<SpSupportTbl> whereSupportKey =
        StringUtil.isNull(supportKey)
            ? null
            : new Specification<SpSupportTbl>() {
              @Override
              public Predicate toPredicate(
                  Root<SpSupportTbl> root, CriteriaQuery<?> query, CriteriaBuilder cb) {
                return cb.equal(root.get("supportKey"), supportKey);
              }
            };
    // データ更新日
    Specification<SpSupportTbl> whereUpdDate =
        DateUtil.isNull(updDate)
            ? null
            : new Specification<SpSupportTbl>() {
              @Override
              public Predicate toPredicate(
                  Root<SpSupportTbl> root, CriteriaQuery<?> query, CriteriaBuilder cb) {
                return cb.equal(root.get("updDate"), updDate);
              }
            };

    logger.infoCode("I0002"); // I0002=メソッド終了:{0}
    return spSupportTblRepository.findOne(Specifications.where(whereSupportKey).and(whereUpdDate));
  }
Пример #4
0
  public EvEventTbl findOne(UserInfo userInfo, EventForm form) {
    logger.infoCode("I0001"); // I0001=メソッド開始:{0}

    // 定数区分
    Specification<EvEventTbl> whereEventKey =
        StringUtil.isNull(form.getEventKey())
            ? null
            : new Specification<EvEventTbl>() {
              @Override
              public Predicate toPredicate(
                  Root<EvEventTbl> root, CriteriaQuery<?> query, CriteriaBuilder cb) {
                return cb.equal(root.get("eventKey"), form.getEventKey());
              }
            };
    Specification<EvEventTbl> whereUpdDate =
        DateUtil.isNull(form.getUpdDate())
            ? null
            : new Specification<EvEventTbl>() {
              @Override
              public Predicate toPredicate(
                  Root<EvEventTbl> root, CriteriaQuery<?> query, CriteriaBuilder cb) {
                return cb.equal(root.get("updDate"), form.getUpdDate());
              }
            };

    logger.infoCode("I0002"); // I0002=メソッド終了:{0}
    return evEventTblRepository.findOne(Specifications.where(whereEventKey).and(whereUpdDate));
  }
  /**
   * 一覧取得
   *
   * @param form
   * @param locale
   * @return
   */
  public List<SpSupportDto> findAllLikeKeyWords(SupportForm form, Locale locale) {
    logger.infoCode("I0001"); // I0001=メソッド開始:{0}

    Date today = DateUtil.toDate(DateUtil.getSysdate("yyyyMMdd"));

    // 取得条件:区分
    Specification<SpSupportTbl> whereSupportSpkikiKbn =
        StringUtil.isNull(form.getSearchSpkikiKbn())
            ? null
            : new Specification<SpSupportTbl>() {
              @Override
              public Predicate toPredicate(
                  Root<SpSupportTbl> root, CriteriaQuery<?> query, CriteriaBuilder cb) {
                return cb.equal(root.get("supportSpkikiKbn"), form.getSearchSpkikiKbn());
              }
            };

    // 取得条件:公開
    Specification<SpSupportTbl> wherePublicFlag =
        StringUtil.isNull(form.getSearchPublicFlag())
            ? null
            : new Specification<SpSupportTbl>() {
              @Override
              public Predicate toPredicate(
                  Root<SpSupportTbl> root, CriteriaQuery<?> query, CriteriaBuilder cb) {
                return cb.equal(root.get("publicFlag"), form.getSearchPublicFlag());
              }
            };

    // 取得条件:HIRAKUリンク区分
    Specification<SpSupportTbl> whereSupportHirakuKbn =
        StringUtil.isNull(form.getSearchHirakuKbn())
            ? null
            : new Specification<SpSupportTbl>() {
              @Override
              public Predicate toPredicate(
                  Root<SpSupportTbl> root, CriteriaQuery<?> query, CriteriaBuilder cb) {
                return cb.equal(root.get("supportHirakuKbn"), form.getSearchHirakuKbn());
              }
            };

    // 取得条件:地域区分
    Specification<SpSupportTbl> whereSupportAreaKbn =
        StringUtil.isNull(form.getSearchAreaKbn())
            ? null
            : new Specification<SpSupportTbl>() {
              @Override
              public Predicate toPredicate(
                  Root<SpSupportTbl> root, CriteriaQuery<?> query, CriteriaBuilder cb) {
                return cb.equal(root.get("supportAreaKbn"), form.getSearchAreaKbn());
              }
            };

    // 取得条件:組織コード
    Specification<SpSupportTbl> wherePartyCode =
        StringUtil.isNull(form.getSearchPartyCode())
            ? null
            : new Specification<SpSupportTbl>() {
              @Override
              public Predicate toPredicate(
                  Root<SpSupportTbl> root, CriteriaQuery<?> query, CriteriaBuilder cb) {
                return cb.equal(root.get("partyCode"), form.getSearchPartyCode());
              }
            };

    // 取得条件:キーワード
    Specification<SpSupportTbl> whereKeywords =
        StringUtil.isNull(form.getSearchKeyword())
            ? null
            : new Specification<SpSupportTbl>() {
              @Override
              public Predicate toPredicate(
                  Root<SpSupportTbl> root, CriteriaQuery<?> query, CriteriaBuilder cb) {
                String[] keywords = form.getSearchKeyword().split(",");
                Predicate predicate = cb.conjunction();
                for (int i = 0; i < keywords.length; i++) {
                  String keyword = keywords[i];
                  predicate =
                      cb.and(predicate, cb.like(root.get("supportKeyword"), "%" + keyword + "%"));
                }
                return predicate;
              }
            };

    // 取得条件:支援制度種別コード
    Specification<SpSupportTbl> whereSyb =
        StringUtil.isNull(form.getSearchSybCode())
            ? null
            : new Specification<SpSupportTbl>() {
              @Override
              public Predicate toPredicate(
                  Root<SpSupportTbl> root, CriteriaQuery<?> query, CriteriaBuilder cb) {
                String[] sybcodes = form.getSearchSybCodeArray();
                Predicate predicate = cb.conjunction();
                for (int i = 0; i < sybcodes.length; i++) {
                  String sybcode = sybcodes[i];
                  predicate =
                      cb.and(predicate, cb.like(root.get("supportSybCode"), "%" + sybcode + "%"));
                }
                return predicate;
              }
            };

    // 取得条件:日付(期間)
    Specification<SpSupportTbl> whereDate =
        StringUtil.isNull(form.getSearchDateType())
            ? null
            : new Specification<SpSupportTbl>() {
              @Override
              public Predicate toPredicate(
                  Root<SpSupportTbl> root, CriteriaQuery<?> query, CriteriaBuilder cb) {
                // batch処理
                if (SEARCH_DATE_TYPE_BATCH.equals(form.getSearchDateType().toLowerCase())) {
                  Predicate predicate = cb.conjunction();
                  Predicate predicate2 = cb.conjunction();
                  predicate2 =
                      cb.and(predicate2, cb.equal(root.get("updDate").as(Date.class), today));
                  predicate2 =
                      cb.and(
                          predicate2,
                          cb.lessThan(root.get("supportStartDate").as(Date.class), today));
                  predicate =
                      cb.and(
                          predicate, cb.equal(root.get("supportStartDate").as(Date.class), today));
                  predicate = cb.or(predicate2);
                  return predicate;
                }
                // 期間中
                if (SEARCH_DATE_TYPE_CURRENT.equals(form.getSearchDateType())) {
                  Predicate predicate = cb.conjunction();
                  predicate =
                      cb.and(
                          predicate,
                          cb.lessThanOrEqualTo(root.get("supportStartDate").as(Date.class), today));
                  predicate =
                      cb.and(
                          predicate,
                          cb.greaterThanOrEqualTo(
                              root.get("supportEndDate").as(Date.class), today));
                  return predicate;
                }
                // 過去情報
                if (SEARCH_DATE_TYPE_PAST.equals(form.getSearchDateType())) {
                  return cb.lessThan(root.get("supportEndDate").as(Date.class), today);
                }
                // 終了前
                if (SEARCH_DATE_TYPE_PRESENT.equals(form.getSearchDateType())) {
                  return cb.greaterThanOrEqualTo(root.get("supportEndDate").as(Date.class), today);
                }
                return null;
              }
            };

    List<SpSupportTbl> list =
        spSupportTblRepository.findAll(
            Specifications.where(whereSupportSpkikiKbn)
                .and(whereSupportHirakuKbn)
                .and(whereSupportAreaKbn)
                .and(wherePublicFlag)
                .and(wherePartyCode)
                .and(whereKeywords)
                .and(whereSyb)
                .and(whereDate),
            orderBy());

    logger.infoCode("I0002"); // I0002=メソッド終了:{0}
    return getDtoList(list, locale);
  }