From 8cb7ec4a35a38ae91d0eed17cde711e81d2b2bbf Mon Sep 17 00:00:00 2001 From: yujian <yujian> Date: 星期二, 14 五月 2019 11:37:49 +0800 Subject: [PATCH] 合并 --- fanli/src/main/java/com/yeshi/fanli/controller/client/SearchController.java | 97 +++++++++++++++++++++++++++++++++--------------- 1 files changed, 66 insertions(+), 31 deletions(-) diff --git a/fanli/src/main/java/com/yeshi/fanli/controller/client/SearchController.java b/fanli/src/main/java/com/yeshi/fanli/controller/client/SearchController.java index 295c8c6..c0e0e5c 100644 --- a/fanli/src/main/java/com/yeshi/fanli/controller/client/SearchController.java +++ b/fanli/src/main/java/com/yeshi/fanli/controller/client/SearchController.java @@ -3,6 +3,7 @@ import java.io.PrintWriter; import java.math.BigDecimal; import java.util.ArrayList; +import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.Map; @@ -22,7 +23,6 @@ import com.yeshi.fanli.entity.accept.AcceptData; import com.yeshi.fanli.entity.bus.lable.QualityFactory; import com.yeshi.fanli.entity.bus.recommend.Honest; -import com.yeshi.fanli.entity.bus.search.HistorySearch; import com.yeshi.fanli.entity.bus.search.HotSearch; import com.yeshi.fanli.entity.bus.su.search.SuperHotSearch; import com.yeshi.fanli.entity.system.BusinessSystem; @@ -34,6 +34,8 @@ import com.yeshi.fanli.entity.taobao.TaoBaoSearchNav; import com.yeshi.fanli.entity.taobao.TaoBaoSearchResult; import com.yeshi.fanli.entity.taobao.TaoBaoUnionConfig; +import com.yeshi.fanli.entity.taobao.dataoke.DaTaoKeDetail; +import com.yeshi.fanli.exception.taobao.TaobaoGoodsDownException; import com.yeshi.fanli.service.inter.config.BusinessSystemService; import com.yeshi.fanli.service.inter.config.ConfigService; import com.yeshi.fanli.service.inter.config.SuperHotSearchService; @@ -41,12 +43,17 @@ import com.yeshi.fanli.service.inter.lable.QualityGoodsService; import com.yeshi.fanli.service.inter.lable.TaoKeGoodsService; import com.yeshi.fanli.service.inter.taobao.TaoBaoUnionConfigService; +import com.yeshi.fanli.service.inter.taobao.dataoke.DaTaoKeGoodsDetailService; import com.yeshi.fanli.service.inter.user.HistorySearchService; import com.yeshi.fanli.util.Constant; import com.yeshi.fanli.util.EhcacheUtil; import com.yeshi.fanli.util.StringUtil; +import com.yeshi.fanli.util.ThreadUtil; +import com.yeshi.fanli.util.cache.TaoBaoGoodsCacheUtil; +import com.yeshi.fanli.util.taobao.DaTaoKeUtil; import com.yeshi.fanli.util.taobao.SearchFilterUtil; import com.yeshi.fanli.util.taobao.TaoBaoUtil; +import com.yeshi.fanli.util.taobao.TaoKeApiUtil; import net.sf.ehcache.Element; import net.sf.json.JSONArray; @@ -80,9 +87,16 @@ @Resource private QualityGoodsService qualityGoodsService; + @Resource + private TaoBaoGoodsCacheUtil taoBaoGoodsCacheUtil; + + @Resource + private DaTaoKeGoodsDetailService daTaoKeGoodsDetailService; + @RequestMapping(value = "gethotsearch", method = RequestMethod.POST) public void getHotSearch(AcceptData acceptData, PrintWriter out) { - BusinessSystem system = businessSystemService.getBusinessSystemCache(acceptData.getPlatform(), acceptData.getPackages()); + BusinessSystem system = businessSystemService.getBusinessSystemCache(acceptData.getPlatform(), + acceptData.getPackages()); if (system == null) { out.print(JsonUtil.loadFalseResult("绯荤粺涓嶅瓨鍦�")); return; @@ -96,7 +110,8 @@ List<HotSearch> hotSearchList = new ArrayList<HotSearch>(); for (SuperHotSearch superHotSearch : superHotSearchList) { HotSearch hotSearch = superHotSearch.getHotSearch(); - hotSearchList.add(hotSearch); + if (hotSearch != null) + hotSearchList.add(hotSearch); } JSONObject data = new JSONObject(); @@ -160,7 +175,8 @@ String endprice, String fastFilter, PrintWriter out) { String bid = getHistorySearchBid(acceptData); historySearchService.addHistorySearch(kw, bid); - BusinessSystem system = businessSystemService.getBusinessSystemCache(acceptData.getPlatform(), acceptData.getPackages()); + BusinessSystem system = businessSystemService.getBusinessSystemCache(acceptData.getPlatform(), + acceptData.getPackages()); if (system == null) { out.print(JsonUtil.loadFalseResult("绯荤粺涓嶅瓨鍦�")); return; @@ -351,32 +367,6 @@ return data; } - @RequestMapping(value = "gethistorysearch", method = RequestMethod.POST) - public void getHistorySearch(AcceptData acceptData, PrintWriter out) { - String bid = getHistorySearchBid(acceptData); - List<HistorySearch> historySearchList = historySearchService.getHistorySearch(bid); - if (historySearchList == null || historySearchList.size() == 0) { - out.print(JsonUtil.loadFalseResult("鏆傛棤鏁版嵁")); - return; - } - JSONObject data = new JSONObject(); - data.put("count", historySearchList.size()); - Gson gson = new GsonBuilder().excludeFieldsWithoutExposeAnnotation().create(); - data.put("historySearchList", gson.toJson(historySearchList)); - out.print(JsonUtil.loadTrueResult(data)); - return; - } - - @RequestMapping(value = "clearhistorysearch", method = RequestMethod.POST) - public void clearHistorySearch(AcceptData acceptData, PrintWriter out) { - String bid = getHistorySearchBid(acceptData); - long count = historySearchService.clearHistorySearch(bid); - JSONObject data = new JSONObject(); - data.put("count", count); - out.print(JsonUtil.loadTrueResult(data)); - return; - } - @RequestMapping(value = "suggestsearch", method = RequestMethod.POST) public void getSugguestSearch(AcceptData acceptData, String kw, PrintWriter out) { List<String> list = TaoBaoUtil.getSuguestSearch(kw); @@ -424,7 +414,8 @@ historySearchService.addHistorySearch(kw, bid); - BusinessSystem system = businessSystemService.getBusinessSystemCache(acceptData.getPlatform(), acceptData.getPackages()); + BusinessSystem system = businessSystemService.getBusinessSystemCache(acceptData.getPlatform(), + acceptData.getPackages()); if (system == null) { out.print(JsonUtil.loadFalseResult("绯荤粺涓嶅瓨鍦�")); return; @@ -616,9 +607,53 @@ } TaoBaoSearchResult result = TaoBaoUtil.search(sf); + // 澶ф窐瀹㈣繃婊� + List<DaTaoKeDetail> detaokeList = daTaoKeGoodsDetailService.listByDtitle(kw); + if (detaokeList != null) + for (DaTaoKeDetail detail : detaokeList) { + for (int i = 0; i < result.getTaoBaoGoodsBriefs().size(); i++) { + if (detail.getGoodsId().longValue() == result.getTaoBaoGoodsBriefs().get(i).getAuctionId()) { + result.getTaoBaoGoodsBriefs().set(i, + DaTaoKeUtil.filterTaoBaoGoods(result.getTaoBaoGoodsBriefs().get(i), detail)); + break; + } + } + } + + // result.setTaoBaoGoodsBriefs(daTaoKeGoodsDetailService.filterTaoBaoGoods(result.getTaoBaoGoodsBriefs())); + if (result == null) { return null; } + // 鎼滅储鏄惁鍦ㄨ惀閿�涓诲晢鍝佸簱 + if (result != null && result.getTaoBaoGoodsBriefs() != null && result.getTaoBaoGoodsBriefs().size() > 0) { + String numIds = ""; + for (TaoBaoGoodsBrief goods : result.getTaoBaoGoodsBriefs()) { + numIds += goods.getAuctionId() + ","; + } + if (numIds.endsWith(",")) + numIds = numIds.substring(0, numIds.length() - 1); + try { + List<TaoBaoGoodsBrief> goodsList = TaoKeApiUtil.getBatchGoodsInfos(numIds); + Map<Long, Integer> map = new HashMap<>(); + for (TaoBaoGoodsBrief g : goodsList) + map.put(g.getAuctionId(), g.getMaterialLibType()); + for (TaoBaoGoodsBrief goods : result.getTaoBaoGoodsBriefs()) + goods.setMaterialLibType(map.get(goods.getAuctionId())); + + ThreadUtil.run(new Runnable() { + @Override + public void run() { + // 鏇存柊鍒扮珐瀛� + for (TaoBaoGoodsBrief goods : result.getTaoBaoGoodsBriefs()) + taoBaoGoodsCacheUtil.saveCommonTaoBaoGoodsInfo(goods); + } + }); + } catch (TaobaoGoodsDownException e) { + e.printStackTrace(); + } + + } List<TaoBaoSearchNav> navList = TaoBaoUtil.getBaseNav(); if (result.getNavList() != null) -- Gitblit v1.8.0