/**
   * 新規追加、更新
   *
   * @param form
   * @param userInfo
   * @return
   */
  @Transactional
  public boolean update(SupportForm form, UserInfo userInfo) {
    logger.infoCode("I0001"); // I0001=メソッド開始:{0}
    try {
      SpSupportTbl entity = new SpSupportTbl();

      // 更新の場合
      if (CommonConst.PAGE_MODE_EDIT.equals(form.getPageMode())) {
        entity = findOne(form.getSupportKey(), form.getUpdDate());
        if (entity == null) {
          throw new Exception();
        }
      }
      //
      entity.setSupportSpkikiKbn(form.getSupportSpkikiKbn());
      entity.setSupportHirakuKbn(form.getSupportHirakuKbn());
      entity.setSupportSybCode(form.getSupportSybCode());
      entity.setSupportAreaKbn(form.getSupportAreaKbn());
      entity.setSupportKeyword(form.getSupportKeyword());
      entity.setSupportStartDate(
          DateUtil.formatTimestampStart(
              DateUtil.getTimestamp(form.getSupportStartDate(), CommonConst.DEFAULT_YYYYMMDD)));
      entity.setSupportEndDate(
          DateUtil.formatTimestampEnd(
              DateUtil.getTimestamp(form.getSupportEndDate(), CommonConst.DEFAULT_YYYYMMDD)));
      entity.setSupportTitle(form.getSupportTitle());
      entity.setSupportContent(form.getSupportContent());
      entity.setUrl(form.getUrl());
      entity.setPartyCode(userInfo.getTargetPartyCode());

      // 更新以外の場合(新規、コピー)
      if (!CommonConst.PAGE_MODE_EDIT.equals(form.getPageMode())) {
        entity.setSupportInsDate(DateUtil.getNowTimestamp());
      }
      entity.setPublicFlag(form.getPublicFlag());
      //
      entity.setUpdUserKey(userInfo.getLoginUserKey());
      entity.setUpdDate(DateUtil.getNowTimestamp());
      //
      entity = spSupportTblRepository.saveAndFlush(entity);

      if (entity != null) {
        logger.infoCode("I0002"); // I0002=メソッド終了:{0}
        return true;
      }

    } catch (Exception e) {
      logger.errorCode("E1007", e); // E1007=登録に失敗しました。{0}
    }
    return false;
  }
Ejemplo n.º 2
0
  @SuppressWarnings("unchecked")
  public List<EventDto> findAllEvent(
      UserInfo userInfo,
      Boolean publicFlag,
      Boolean partyCodeFlag,
      Boolean roleFlag,
      boolean past) {
    logger.infoCode("I0001");
    String partyCode = null;
    String roleCode = null;

    StringBuilder sb = new StringBuilder();
    sb.append("SELECT");
    sb.append("    A.EVENT_KEY");
    sb.append("  , A.EVENT_TITLE");
    sb.append("  , A.EVENT_SEND_DATE");
    sb.append("  , A.EVENT_RECRUIT");
    sb.append("  , A.EVENT_TELNO");
    sb.append("  , A.PARTY_CODE");
    sb.append("  , A.PARTY_NAME");
    sb.append("  , A.EVENT_START_DATE");
    sb.append("  , A.EVENT_PLACE");
    sb.append("  , A.EVENT_MEMO");
    sb.append("  , A.EVENT_UNIT");
    sb.append("  , A.SUBJECT_INS_KBN");
    sb.append("  , A.PUBLIC_FLAG");
    sb.append("  , A.UPD_DATE");
    sb.append("  , A.UPD_USER_KEY");
    sb.append("  , ARRAY_TO_STRING(ARRAY_AGG(C.PARTY_NAME), ',') AS PARTY_NAME");
    sb.append("  , ARRAY_TO_STRING(ARRAY_AGG(C.PARTY_NAME_EN), ',') AS PARTY_NAME_EN");
    sb.append(" FROM");
    sb.append("  EV_EVENT_TBL A ");
    sb.append("  INNER JOIN EV_EVENT_PUBLIC_TBL B ");
    sb.append("    ON A.EVENT_KEY = B.EVENT_KEY ");

    sb.append("  INNER JOIN MS_PARTY_TBL C ");
    sb.append("    ON B.PARTY_CODE = C.PARTY_CODE ");
    sb.append(" WHERE");

    if (past) {
      sb.append("   CURRENT_DATE < A.EVENT_START_DATE ");
    } else {
      sb.append("  CURRENT_DATE >= A.EVENT_START_DATE ");
      sb.append("  AND CURRENT_DATE <= A.EVENT_SEND_DATE ");
    }

    if (publicFlag) {
      sb.append("  AND A.PUBLIC_FLAG = '1' ");
    }

    if (partyCodeFlag) {
      sb.append("  AND  (B.PARTY_CODE = :partyCode ");
      sb.append("    OR");
      sb.append("    A.PARTY_CODE = :partyCode )");
    }

    if (roleFlag) {
      sb.append("  AND  (B.ROLE = :role ");
      sb.append("    OR");
      sb.append("    A.PARTY_CODE = :partyCode )");
    }

    sb.append(" GROUP BY");
    sb.append("    A.EVENT_KEY");
    sb.append("  , A.EVENT_TITLE");
    sb.append("  , A.EVENT_SEND_DATE");
    sb.append("  , A.EVENT_RECRUIT");
    sb.append("  , A.EVENT_TELNO");
    sb.append("  , A.PARTY_CODE");
    sb.append("  , A.PARTY_NAME");
    sb.append("  , A.EVENT_START_DATE");
    sb.append("  , A.EVENT_PLACE");
    sb.append("  , A.EVENT_MEMO");
    sb.append("  , A.EVENT_UNIT");
    sb.append("  , A.SUBJECT_INS_KBN");
    sb.append("  , A.PUBLIC_FLAG");
    sb.append("  , A.UPD_DATE");
    sb.append("  , A.UPD_USER_KEY");
    sb.append(" ORDER BY");
    sb.append("  A.EVENT_SEND_DATE DESC");
    String sql = sb.toString();

    Query query = entityManager.createNativeQuery(sql);
    query.unwrap(SQLQuery.class).setResultTransformer(Transformers.ALIAS_TO_ENTITY_MAP);
    if (partyCodeFlag) {
      query.setParameter("partyCode", userInfo.getTargetPartyCode());
    }
    if (roleFlag) {
      query.setParameter("partyCode", userInfo.getTargetPartyCode());
      query.setParameter("role", userInfo.getTargetRole());
    }

    List<EventDto> list = new ArrayList<>();
    List<Map> resultList = new ArrayList<>();
    resultList = query.getResultList();

    for (int i = 0; i < resultList.size(); i++) {
      EventDto dto = new EventDto();
      dto = (EventDto) objectUtil.setMapCopyValue(dto, resultList.get(i));
      list.add(dto);
    }

    logger.infoCode("I0002");
    return list;
  }