雲端校務系統中學生異動可能是因轉學造成短期空檔不在籍
所以在判斷停用後, 時間註記在 syncAccount.getDataTimestamp()
超過30天未更新且又是停用者, 先寄mail通知
超過90天後,
找出 account 為停用 且 syncAccount.getDataTimestamp() 超過90天者及syncAccount.getOutOfStudyTimestamp() == 0
執行停權並將syncAccount.setOutOfStudyTimestamp() 設為執行時間
學生回復學籍時, syncAccount.getOutOfStudyTimestamp() 再標記為0
部份程式
List<SyncAccount> syncAccounts = syncAccountService.findByOutofStudyConditionBefore(100); syncAccounts.forEach(syncAccount -> { Instant instant = Instant.ofEpochSecond(syncAccount.getDataTimestamp()); ZonedDateTime present = instant.atZone(ZoneId.of("Asia/Taipei")); //taipei時區 Account account = accountDAO.findAccountByPID(syncAccount.getPid()); UserName userName = accountUtilsService.getUserName(account); User user = null; try { user = userService.getUser(syncAccount.getGoogle_account()); logger.info(account.getGoogle_account() + ",is suspended? " + user.getSuspended()); if (user.getSuspended() == false) { logger.info("set user suspensed: " + account.getGoogle_account()); user.setOrgUnitPath("/停用"); user.setSuspended(true); } userName.setFamilyName("停用"); user.setName(userName); user = userService.update(user); //學習帳號列表 StUser stUser = syncStUserService.findStUserByEmail(syncAccount.getGoogle_account()); stUser.setFullname(userName.getFamilyName() + userName.getFullName()); stUser.setUpdateTimestamp(Instant.now().getEpochSecond()); stUser.setOrgUnitPath("/停用"); stUser.setSuspended(true); syncStUserService.save(stUser); //資料庫帳號更新參照 syncAccount.setName(userName.getFamilyName() + userName.getFullName()); syncAccount.setOutOfStudyTimestamp(Instant.now().getEpochSecond()); syncAccountService.save(syncAccount); } catch (Exception e) { throw new RuntimeException(e); } });