@Transactional public boolean update(UserInfo userInfo, F form) { logger.infoCode("I0001"); try { T entity = (T) form.getNewTbl(); if (form.getPageMode().equals(CommonConst.PAGE_MODE_EDIT)) { entity = findOne( form.getGyosekiKey(), userInfo.getTargetUserKey(), form.getUpdDateAsTimestamp()); if (entity == null) { throw new Exception(); } } entity = (T) getPortfolioTbl(form, entity); UsUserTbl usUserTbl = new UsUserTbl(); usUserTbl.setUserKey(userInfo.getTargetUserKey()); entity.setUsUserTbl(usUserTbl); entity.setUpdUserKey(userInfo.getLoginUserKey()); entity.setUpdDate(DateUtil.getNowTimestamp()); entity = (T) repository.saveAndFlush(entity); if (entity != null) { logger.infoCode("I0002"); return true; } } catch (Exception e) { logger.errorCode("E1007", e); // E1007=登録に失敗しました。{0} } return false; }
@Transactional public boolean importData(UserInfo userInfo, List<F> list) { logger.infoCode("I0001"); try { for (int i = 0; i < list.size(); i++) { F form = list.get(i); T entity = (T) form.getNewTbl(); entity = this.getPortfolioTbl(form, entity); entity.setPublicFlag(form.getPublicFlag()); UsUserTbl usUserTbl = new UsUserTbl(); usUserTbl.setUserKey(userInfo.getTargetUserKey()); entity.setUsUserTbl(usUserTbl); entity.setUpdUserKey(userInfo.getLoginUserKey()); entity.setUpdDate(DateUtil.getNowTimestamp()); repository.save(entity); } repository.flush(); logger.infoCode("I0002"); return true; } catch (Exception e) { logger.errorCode("E1007", e); // E1007=登録に失敗しました。{0} } return false; }
@Transactional public boolean delete(UserInfo userInfo, EventForm form) { logger.infoCode("I0001"); try { if (userInfo.isMgmt2() || userInfo.isMgmt3() || userInfo.isMgmt4()) { logger.infoCode("I0002"); return false; } EvEventTbl entity = findOne(userInfo, form); evEventPublicTblRepository.delete(entity.getEvEventPublicTbls()); int c1 = evEventTblRepository.delete(form.getEventKey(), form.getUpdDate()); if (c1 > 0) { evEventPublicTblRepository.flush(); evEventTblRepository.flush(); logger.infoCode("I0002"); return true; } } catch (Exception e) { logger.errorCode("E1009", e); // E1009=削除に失敗しました。{0} } return false; }
@Transactional public boolean updateAll(UserInfo userInfo, F form) { logger.infoCode("I0001"); try { List<T> list = findAll(userInfo, form); for (int i = 0; i < list.size(); i++) { T entity = list.get(i); entity.setPublicFlag(form.getPublicFlag()); UsUserTbl usUserTbl = new UsUserTbl(); usUserTbl.setUserKey(userInfo.getTargetUserKey()); entity.setUsUserTbl(usUserTbl); entity.setUpdUserKey(userInfo.getLoginUserKey()); entity.setUpdDate(DateUtil.getNowTimestamp()); repository.save(entity); } repository.flush(); logger.infoCode("I0002"); return true; } catch (Exception e) { logger.errorCode("E1007", e); // E1007=登録に失敗しました。{0} } return false; }
/** * 新規追加、更新 * * @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; }
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 F findOne(UserInfo userInfo, F form) { logger.infoCode("I0001"); // I0001=メソッド開始:{0} if (form.getGyosekiKey() == null && form.getUpdDate() == null) { return null; } T gyPaperTbl = findOne(form.getGyosekiKey(), userInfo.getTargetUserKey(), form.getUpdDateAsTimestamp()); if (gyPaperTbl == null) { return null; } logger.infoCode("I0002"); // I0002=メソッド終了:{0} return getPortfolioForm(gyPaperTbl); }
@Transactional public boolean delete(UserInfo userInfo, F form) { logger.infoCode("I0001"); try { if (form.getPageMode().equals(CommonConst.PAGE_MODE_DELETE)) { T entity = findOne( form.getGyosekiKey(), userInfo.getTargetUserKey(), form.getUpdDateAsTimestamp()); if (entity == null) { String objInfo = "key=" + form.getGyosekiKey() + " updDate=" + form.getUpdDate(); logger.errorCode("E1009", "entity donot find " + objInfo); // E1009=削除に失敗しました。{0} return false; } repository.delete(entity.getGyosekiKey()); repository.flush(); logger.infoCode("I0002"); return true; } } catch (Exception e) { logger.errorCode("E1009", e); // E1009=削除に失敗しました。{0} } return false; }
@Transactional public boolean update(EventForm form, UserInfo userInfo) { logger.infoCode("I0001"); try { EvEventTbl entity = new EvEventTbl(); if (form.getPageMode().equals(CommonConst.PAGE_MODE_EDIT)) { entity = findOne(userInfo, form); if (entity == null) { throw new Exception(); } } entity.setUpdUserKey(userInfo.getLoginUserKey()); entity.setPartyCode(userInfo.getLoginPartyCode()); entity.setPartyName(userInfo.getLoginPartyName()); // entity.setEventKey(form.getEventKey()); entity.setEventMemo(form.getEventMemo()); entity.setEventPlace(form.getEventPlace()); entity.setEventRecruit(form.getEventRecruit()); entity.setEventSendDate(form.getEventSendDateAsTimestamp()); entity.setEventStartDate(form.getEventStartDateAsTimestamp()); entity.setEventTelno(form.getEventTelno()); entity.setEventTitle(form.getEventTitle()); entity.setEventUnit(form.getEventUnit()); entity.setSubjectInsKbn(form.getSubjectInsKbn()); entity.setPublicFlag(form.getPublicFlag()); entity.setUpdDate(DateUtil.getNowTimestamp()); // 更新テーブル:イベント公開範囲テーブル if (form.getPageMode().equals(CommonConst.PAGE_MODE_EDIT)) { // イベント公開範囲テーブルから対象データをDELETEする。 evEventPublicTblRepository.delete(entity.getEvEventPublicTbls()); } entity = evEventTblRepository.save(entity); List<EvEventPublicTbl> publicList = new ArrayList<>(); int count = 1; // 企業・研究所などがチェックONの場合、1件出力する。 if (form.checkHasPublicItem("1")) { EvEventPublicTbl tbl = new EvEventPublicTbl(); EvEventPublicTblPK pk = new EvEventPublicTblPK(); pk.setEventKey(entity.getEventKey()); pk.setSeqNo(count); tbl.setId(pk); // 企業・研究所等が、設定されている分の出力を行う場合、1:ROLE。 tbl.setPublicKbn("1"); // 企業・研究所等が、設定されている分の出力を行う場合、1:ROLE。 tbl.setRole("1"); // 企業・研究所等が、設定されている分の出力を行う場合、NULL。 tbl.setPartyCode(null); // 現在時刻を設定する。 tbl.setUpdDate(DateUtil.getNowTimestamp()); // ログイン者のユーザキーの値を設定する。 tbl.setUpdUserKey(userInfo.getLoginUserKey()); publicList.add(tbl); count = count + 1; } if (form.checkHasPublicItem("2")) { // 大學がチェックONの場合、公開範囲(公開)で選択されている件数出力する。 for (int i = 0; i < form.getPublicPartyArray().length; i++) { EvEventPublicTbl tbl = new EvEventPublicTbl(); EvEventPublicTblPK pk = new EvEventPublicTblPK(); pk.setEventKey(entity.getEventKey()); pk.setSeqNo(count); tbl.setId(pk); // 大學が、設定されている分の出力を行う場合、2:組織。 tbl.setPublicKbn("2"); // 大學が、設定されている分の出力を行う場合、NULL。 tbl.setRole(null); // 大學が、設定されている分の出力を行う場合、対象大学の組織コード。 tbl.setPartyCode(form.getPublicPartyArray()[i]); // 現在時刻を設定する。 tbl.setUpdDate(DateUtil.getNowTimestamp()); // ログイン者のユーザキーの値を設定する。 tbl.setUpdUserKey(userInfo.getLoginUserKey()); publicList.add(tbl); count = count + 1; } } if (form.getPageMode().equals(CommonConst.PAGE_MODE_ADD) || form.getPageMode().equals(CommonConst.PAGE_MODE_COPY)) { // お知らせ情報、お知らせ情報公開範囲登録 this.insertCmInfo(userInfo, form, "201", userInfo.getTargetRole().getAuthority(), null); } evEventPublicTblRepository.save(publicList); if (entity != null) { logger.infoCode("I0002"); return true; } } catch (Exception e) { logger.errorCode("E1007", e); // E1007=登録に失敗しました。{0} } return false; }
@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; }