|
|
@ -1,5 +1,6 @@ |
|
|
|
package com.fr.design.mainframe.alphafine.search.manager.impl; |
|
|
|
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.AlphaFineConstants; |
|
|
|
import com.fr.design.mainframe.alphafine.AlphaFineHelper; |
|
|
|
import com.fr.design.mainframe.alphafine.AlphaFineHelper; |
|
|
|
import com.fr.design.mainframe.alphafine.model.ProductNews; |
|
|
|
import com.fr.design.mainframe.alphafine.model.ProductNews; |
|
|
@ -16,17 +17,33 @@ import java.net.URL; |
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.Date; |
|
|
|
import java.util.Date; |
|
|
|
import java.util.List; |
|
|
|
import java.util.List; |
|
|
|
|
|
|
|
import java.util.concurrent.Executors; |
|
|
|
|
|
|
|
import java.util.concurrent.ScheduledExecutorService; |
|
|
|
|
|
|
|
import java.util.concurrent.TimeUnit; |
|
|
|
import javax.imageio.ImageIO; |
|
|
|
import javax.imageio.ImageIO; |
|
|
|
|
|
|
|
|
|
|
|
public class ProductNewsSearchManager { |
|
|
|
public class ProductNewsSearchManager { |
|
|
|
|
|
|
|
|
|
|
|
private static final ProductNewsSearchManager INSTANCE = new ProductNewsSearchManager(); |
|
|
|
private static final ProductNewsSearchManager INSTANCE = new ProductNewsSearchManager(); |
|
|
|
|
|
|
|
private static final int TIME_GAP = 12; |
|
|
|
private List<ProductNews> productNewsResultList; |
|
|
|
private List<ProductNews> productNewsResultList; |
|
|
|
|
|
|
|
|
|
|
|
private List<ProductNews> productNewsList = new ArrayList<>(); |
|
|
|
private List<ProductNews> 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() { |
|
|
|
public static ProductNewsSearchManager getInstance() { |
|
|
@ -67,8 +84,12 @@ public class ProductNewsSearchManager { |
|
|
|
setStatus(ProductNews.Status.parseCode(obj.getInt("status"))).setTarget( |
|
|
|
setStatus(ProductNews.Status.parseCode(obj.getInt("status"))).setTarget( |
|
|
|
ProductNews.Target.parseCode(obj.getInt("target"))). |
|
|
|
ProductNews.Target.parseCode(obj.getInt("target"))). |
|
|
|
setCreator(obj.getInt("creator")).setPushDate(new Date(obj.getLong("push_time"))); |
|
|
|
setCreator(obj.getInt("creator")).setPushDate(new Date(obj.getLong("push_time"))); |
|
|
|
|
|
|
|
Date currentDate = new Date(System.currentTimeMillis()); |
|
|
|
|
|
|
|
// 推送时间check
|
|
|
|
|
|
|
|
if (productNews.getPushDate().before(currentDate)) { |
|
|
|
productNewsList.add(productNews); |
|
|
|
productNewsList.add(productNews); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
return productNewsList; |
|
|
|
return productNewsList; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|