/**
   * 一覧取得
   *
   * @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));
  }
  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));
  }
 @Override
 public GyPatentForm getPortfolioForm(GyPatentTbl tbl) {
   if (tbl == null) return null;
   //
   GyPatentForm dto = new GyPatentForm();
   dto = (GyPatentForm) objectUtil.getObjectCopyValue(dto, tbl);
   // 「出願番号」が設定されている場合
   if (StringUtil.isNotNull(dto.getApplicationid())) {
     dto.setKbn("01");
     // 「出願番号」が設定されている場合、「出願番号」を表示。
     dto.setBango(dto.getApplicationid());
     dto.setBusday(dto.getApplicationdate());
   }
   // 「公開番号」が設定されている場合
   if (StringUtil.isNotNull(dto.getPublicid())) {
     dto.setKbn("02");
     // 「公開番号」が設定されている場合、「公開番号」を表示。
     dto.setBango(dto.getPublicid());
     dto.setBusday(dto.getPublicdate());
   }
   // 「公表番号」が設定されている場合
   if (StringUtil.isNotNull(dto.getTranslationid())) {
     dto.setKbn("03");
     // 「公表番号」が設定されている場合、「公表番号」を表示。
     dto.setBango(dto.getTranslationid());
     dto.setBusday(dto.getTranslationdate());
   }
   // 「特許番号」が設定されている場合
   if (StringUtil.isNotNull(dto.getPatentid())) {
     dto.setKbn("04");
     // 「特許番号」が設定されている場合、「特許番号」を表示。
     dto.setBango(dto.getPatentid());
     dto.setBusday(dto.getPatentdate());
   }
   return dto;
 }
  public List<SpSupportDto> getDtoList(List<SpSupportTbl> list, Locale locale) {
    List<SpSupportDto> dtoList = new ArrayList<>();

    Map<String, MsCodeDto> sybCodeMap = new HashMap<String, MsCodeDto>();
    Map<String, String> sybCodeAbbrMap = new HashMap<String, String>();

    if (list.size() > 0) {
      SpSupportTbl tbl = list.get(0);
      String code = "";
      // 支援制度機器設備区分
      if (KBN1.equals(tbl.getSupportSpkikiKbn())) {
        code = CODE_SYBCODE1;
      }
      if (KBN2.equals(tbl.getSupportSpkikiKbn())) {
        code = CODE_SYBCODE2;
      }
      sybCodeMap = DbUtil.getJosuMap(code, locale);
      sybCodeAbbrMap = DbUtil.getJosuAbbrMap(code, locale);
    }

    for (int i = 0; i < list.size(); i++) {
      SpSupportDto dto = new SpSupportDto();
      dto = (SpSupportDto) objectUtil.getObjectCopyValue(dto, list.get(i));

      //
      if (StringUtil.isNotNull(dto.getSupportSybCode())) {
        String[] syblist = dto.getSupportSybCode().split(",");
        String separator = "";
        String name = "";
        String nameAbbr = "";
        for (int s = 0; s < syblist.length; s++) {
          String syb = syblist[s];
          name = name + separator + sybCodeMap.get(syb).getValue();
          nameAbbr = nameAbbr + separator + sybCodeAbbrMap.get(syb);
          separator = "/";
        }
        dto.setSupportSybCodeName(name);
        dto.setSupportSybCodeAbbrName(nameAbbr);
      }

      dtoList.add(dto);
    }
    return dtoList;
  }
  public boolean insertCmInfo(
      UserInfo userInfo, EventForm form, String opeKbn, String roleCode, String partyCode) {
    boolean result = false;

    try {
      CmInfoTbl entity = new CmInfoTbl();
      entity.setSendDate(DateUtil.getNowTimestamp());
      entity.setTitle(form.getEventTitle());
      entity.setDataKbn("2");
      entity.setOpeKbn(opeKbn);
      entity.setInfoRefKey(form.getEventKey());
      entity.setMakeUserKey(userInfo.getLoginUserKey());
      entity.setUpdDate(DateUtil.getNowTimestamp());
      entity.setUpdUserKey(userInfo.getLoginUserKey());

      entity = cmInfoTblRepository.save(entity);
      String infoKey = entity.getInfoKey();

      if (infoKey != null && StringUtil.isNotNull(infoKey)) {
        CmInfoPublicTbl entitySub = new CmInfoPublicTbl();
        CmInfoPublicTblPK id = new CmInfoPublicTblPK();
        id.setInfoKey(infoKey);
        id.setSeqNo(1);
        entitySub.setId(id);
        entitySub.setPublicKbn("1");
        entitySub.setRole(roleCode);
        entitySub.setPartyCode(partyCode);
        entitySub.setUpdDate(DateUtil.getNowTimestamp());
        entitySub.setUpdUserKey(userInfo.getLoginUserKey());

        cmInfoPublicTblRepository.save(entitySub);

        cmInfoTblRepository.flush();
        cmInfoPublicTblRepository.flush();

        result = true;
      }

    } catch (Exception e) {
      logger.errorCode("E1007", e); // E1007=登録に失敗しました。{0}
    }

    return result;
  }
 public void setSendDate(String sendDate) {
   this.sendDate = StringUtil.htmlFilter(sendDate);
 }
  /**
   * 一覧取得
   *
   * @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);
  }