@Transactional(readOnly = false) public Page<Link> findPage(Page<Link> page, Link link, boolean isDataScopeFilter) { // 更新过期的权重,间隔为“6”个小时 Date updateExpiredWeightDate = (Date) CacheUtils.get("updateExpiredWeightDateByLink"); if (updateExpiredWeightDate == null || (updateExpiredWeightDate != null && updateExpiredWeightDate.getTime() < new Date().getTime())) { dao.updateExpiredWeight(link); CacheUtils.put("updateExpiredWeightDateByLink", DateUtils.addHours(new Date(), 6)); } link.getSqlMap().put("dsf", dataScopeFilter(link.getCurrentUser(), "o", "u")); return super.findPage(page, link); }
@Transactional(readOnly = false) public Page<Link> find(Page<Link> page, Link link, boolean isDataScopeFilter) { // 更新过期的权重,间隔为“6”个小时 Date updateExpiredWeightDate = (Date) CacheUtils.get("updateExpiredWeightDateByLink"); if (updateExpiredWeightDate == null || (updateExpiredWeightDate != null && updateExpiredWeightDate.getTime() < new Date().getTime())) { linkDao.updateExpiredWeight(); CacheUtils.put("updateExpiredWeightDateByLink", DateUtils.addHours(new Date(), 6)); } DetachedCriteria dc = linkDao.createDetachedCriteria(); dc.createAlias("category", "category"); dc.createAlias("category.site", "category.site"); if (link.getCategory() != null && StringUtils.isNotBlank(link.getCategory().getId()) && !Category.isRoot(link.getCategory().getId())) { Category category = categoryDao.get(link.getCategory().getId()); if (category != null) { dc.add( Restrictions.or( Restrictions.eq("category.id", category.getId()), Restrictions.like("category.parentIds", "%," + category.getId() + ",%"))); dc.add(Restrictions.eq("category.site.id", category.getSite().getId())); link.setCategory(category); } else { dc.add(Restrictions.eq("category.site.id", Site.getCurrentSiteId())); } } else { dc.add(Restrictions.eq("category.site.id", Site.getCurrentSiteId())); } if (StringUtils.isNotEmpty(link.getTitle())) { dc.add(Restrictions.like("title", "%" + link.getTitle() + "%")); } if (link.getCreateBy() != null && StringUtils.isNotBlank(link.getCreateBy().getId())) { dc.add(Restrictions.eq("createBy.id", link.getCreateBy().getId())); } if (isDataScopeFilter) { dc.createAlias("category.office", "categoryOffice").createAlias("createBy", "createBy"); dc.add(dataScopeFilter(UserUtils.getUser(), "categoryOffice", "createBy")); } dc.add(Restrictions.eq(Link.FIELD_DEL_FLAG, link.getDelFlag())); dc.addOrder(Order.desc("weight")); dc.addOrder(Order.desc("updateDate")); return linkDao.find(page, dc); }
private Date calculateDate(Date beginDate, String timeType, Integer amount) { Date limitDate = null; timeType = timeType == null ? "" : timeType; amount = amount == null ? 0 : amount; switch (timeType) { case "M": limitDate = DateUtils.addMinutes(beginDate, amount); break; case "H": limitDate = DateUtils.addHours(beginDate, amount); break; case "D": limitDate = DateUtils.addDays(beginDate, amount); break; default: // limitDate = beginDate; break; } return limitDate; }
private boolean initializationNeeded(Date lastSystemRun) { Date dueDate = DateUtils.addHours(DateUtils.truncate(new Date(), Calendar.MONTH), -2); return (lastSystemRun == null || lastSystemRun.before(dueDate)); }