From 2ff33cf948306f10df82a0ec734d5f2bff952d29 Mon Sep 17 00:00:00 2001 From: hades Date: Fri, 29 Apr 2022 09:08:47 +0800 Subject: [PATCH] =?UTF-8?q?REPORT-70483=20cid=E9=85=8D=E7=BD=AE=E7=AC=AC?= =?UTF-8?q?=E4=BA=8C=E5=A4=A9=E6=8E=A8=E9=80=81=EF=BC=8C=E4=BD=86=E6=98=AF?= =?UTF-8?q?alphafine=E5=8D=B3=E5=88=BB=E5=B0=B1=E5=8F=AF=E4=BB=A5=E6=94=B6?= =?UTF-8?q?=E5=88=B0=E6=8E=A8=E9=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../impl/ProductNewsSearchManager.java | 25 +++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) 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; }