diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/ProductNewsSearchManager.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/ProductNewsSearchManager.java index 06dbe6ab0..655eec2c8 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/ProductNewsSearchManager.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/ProductNewsSearchManager.java @@ -1,5 +1,6 @@ package com.fr.design.mainframe.alphafine.search.manager.impl; +import com.fr.concurrent.NamedThreadFactory; import com.fr.design.mainframe.alphafine.AlphaFineConstants; import com.fr.design.mainframe.alphafine.AlphaFineHelper; import com.fr.design.mainframe.alphafine.model.ProductNews; @@ -16,17 +17,33 @@ import java.net.URL; import java.util.ArrayList; import java.util.Date; import java.util.List; +import java.util.concurrent.Executors; +import java.util.concurrent.ScheduledExecutorService; +import java.util.concurrent.TimeUnit; import javax.imageio.ImageIO; public class ProductNewsSearchManager { private static final ProductNewsSearchManager INSTANCE = new ProductNewsSearchManager(); + private static final int TIME_GAP = 12; private List productNewsResultList; private List productNewsList = new ArrayList<>(); - private ProductNewsSearchManager() { + private ScheduledExecutorService service; + private ProductNewsSearchManager() { + service = Executors.newSingleThreadScheduledExecutor(new NamedThreadFactory("ProductNewsSearchManager", true)); + service.scheduleAtFixedRate(new Runnable() { + @Override + public void run() { + try { + getProductNewsList(); + } catch (Exception e) { + FineLoggerFactory.getLogger().error(e.getMessage(), e); + } + } + }, TIME_GAP, TIME_GAP, TimeUnit.HOURS); } public static ProductNewsSearchManager getInstance() { @@ -67,7 +84,11 @@ public class ProductNewsSearchManager { setStatus(ProductNews.Status.parseCode(obj.getInt("status"))).setTarget( ProductNews.Target.parseCode(obj.getInt("target"))). setCreator(obj.getInt("creator")).setPushDate(new Date(obj.getLong("push_time"))); - productNewsList.add(productNews); + Date currentDate = new Date(System.currentTimeMillis()); + // 推送时间check + if (productNews.getPushDate().before(currentDate)) { + productNewsList.add(productNews); + } } return productNewsList; }