コード例 #1
0
  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;
  }
コード例 #2
0
  /**
   * 新規追加、更新
   *
   * @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;
  }