From 4ea3992530e9577e4a2919ada620542c3a6fa71d Mon Sep 17 00:00:00 2001 From: yujian <yujian> Date: 星期一, 15 四月 2019 10:16:12 +0800 Subject: [PATCH] bug优化 --- fanli/src/main/java/com/yeshi/fanli/controller/client/RecommendController.java | 32 ++++++++++++++++++++++---------- 1 files changed, 22 insertions(+), 10 deletions(-) diff --git a/fanli/src/main/java/com/yeshi/fanli/controller/client/RecommendController.java b/fanli/src/main/java/com/yeshi/fanli/controller/client/RecommendController.java index 64425af..1696376 100644 --- a/fanli/src/main/java/com/yeshi/fanli/controller/client/RecommendController.java +++ b/fanli/src/main/java/com/yeshi/fanli/controller/client/RecommendController.java @@ -1572,9 +1572,8 @@ public void getRecommendIndex(AcceptData acceptData, Long uid, PrintWriter out) { try { // 1銆佷笓棰樻ā鍧� - JSONObject root = specialService.listCacheSpecialToIndex(); + JSONObject root = specialService.listCacheSpecialToIndex(acceptData); - // 2銆侀《閮ㄨ疆鎾浘 List<SwiperPicture> topPicList = getSwiperByCard("index_top"); if (topPicList == null) { @@ -1696,16 +1695,24 @@ nextTime.set(Calendar.SECOND, 0); nextTime.set(Calendar.MILLISECOND, 0); - JSONObject root = new JSONObject(); - root.put("time", nextTime.getTimeInMillis()); + + JSONArray array = null; + String timekey = "spikeGoods_hour"; + String cachekey = "spikeGoodsList"; - - JSONArray array = new JSONArray(); - String cachekey = "spikeGoodsList" ; - String cacheValue = redisManager.getCommonString(cachekey); - if (!StringUtil.isNullOrEmpty(cacheValue)) { - array = JSONArray.fromObject(cacheValue); + String timeValue = redisManager.getCommonString(timekey); + if (timeValue == null || !timeValue.equals(hour+"")) { + redisManager.cacheCommonString(timekey, hour+"", 60 * 30); } else { + String cacheValue = redisManager.getCommonString(cachekey); + if (!StringUtil.isNullOrEmpty(cacheValue)) { + array = JSONArray.fromObject(cacheValue); + } + } + + if (array == null) { + array = new JSONArray(); + BigDecimal proportion = manageService.getFanLiRate(); Gson gson = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder()) .excludeFieldsWithoutExposeAnnotation().setDateFormat("yyyy-MM-dd").create(); @@ -1715,6 +1722,7 @@ if (listGoods == null) { listGoods = new ArrayList<QualityFactory>(); } + /* 閬嶅巻鍒楄〃鏁版嵁 */ for (QualityFactory qualityFactory : listGoods) { @@ -1724,9 +1732,13 @@ } array.add(gson.toJson(TaoBaoUtil.getTaoBaoGoodsBriefExtra(taoBaoGoodsBrief, proportion.toString(), null))); } + // 缂撳瓨鍗婁釜灏忔椂 redisManager.cacheCommonString(cachekey, array.toString(), 60 * 30); } + + JSONObject root = new JSONObject(); + root.put("time", nextTime.getTimeInMillis()); root.put("listgoods", array); out.print(JsonUtil.loadTrueResult(root)); } -- Gitblit v1.8.0