diff --git a/src/main/java/au/com/royalpay/payment/manage/analysis/core/impls/DashboardServiceImpl.java b/src/main/java/au/com/royalpay/payment/manage/analysis/core/impls/DashboardServiceImpl.java index f424b9f5a..a222cf0a8 100644 --- a/src/main/java/au/com/royalpay/payment/manage/analysis/core/impls/DashboardServiceImpl.java +++ b/src/main/java/au/com/royalpay/payment/manage/analysis/core/impls/DashboardServiceImpl.java @@ -31,12 +31,7 @@ import java.math.RoundingMode; import java.text.DateFormat; import java.text.ParseException; import java.text.SimpleDateFormat; -import java.util.ArrayList; -import java.util.Date; -import java.util.List; -import java.util.Map; -import java.util.TimeZone; -import java.util.TreeMap; +import java.util.*; import java.util.concurrent.TimeUnit; import javax.annotation.Resource; @@ -158,7 +153,14 @@ public class DashboardServiceImpl implements DashboardService,DashboardAnalysisT @Override public List getTradeInTypes(JSONObject params) { - return transactionAnalysisMapper.getTradeAmountInTypes(params); + String jsonStr = stringRedisTemplate.boundValueOps("tradeInTypes"+params.getString("begin")+params.getString("end")).get(); + List tradeInTypes = JSONObject.parseArray(jsonStr,JSONObject.class); + if(tradeInTypes != null){ + return tradeInTypes; + } + List res = transactionAnalysisMapper.getTradeAmountInTypes(params); + stringRedisTemplate.boundValueOps("tradeInTypes"+params.getString("begin")+params.getString("end")).set(res.toString(), 5, TimeUnit.MINUTES); + return res; } @@ -171,8 +173,16 @@ public class DashboardServiceImpl implements DashboardService,DashboardAnalysisT @Override public List getTopTradePartnersNew(JSONObject params) { + String jsonStr = stringRedisTemplate.boundValueOps("topTradePartnersNew"+params.getString("begin")+params.getString("end")).get(); + List topTradePartnersNew = JSONObject.parseArray(jsonStr,JSONObject.class); + if(topTradePartnersNew != null){ + return topTradePartnersNew; + } params.putIfAbsent("rankType", "aud_fee"); - return clientAnalysisMapper.listPartnersTradeAmountNew(params); + List res = clientAnalysisMapper.listPartnersTradeAmountNew(params); + String a = "b"; + stringRedisTemplate.boundValueOps("topTradePartnersNew"+params.getString("begin")+params.getString("end")).set(res.toString(), 5, TimeUnit.MINUTES); + return res; } @Override @@ -285,7 +295,14 @@ public class DashboardServiceImpl implements DashboardService,DashboardAnalysisT if (!params.containsKey("client_ids") && !params.containsKey("org_id")) { params.put("client_id", 0); } - return customerAndOrdersStatisticsMapper.getSumCustomersAnalysis(params); + String jsonStr = stringRedisTemplate.boundValueOps("tradeAnalysisInDays"+params.getIntValue("client_id")+params.getString("begin")+params.getString("end")).get(); + List tradeAnalysisInDays = JSONObject.parseArray(jsonStr,JSONObject.class); + if(tradeAnalysisInDays != null){ + return tradeAnalysisInDays; + } + List res = customerAndOrdersStatisticsMapper.getSumCustomersAnalysis(params); + stringRedisTemplate.boundValueOps("tradeAnalysisInDays"+params.getIntValue("client_id")+params.getString("begin")+params.getString("end")).set(res.toString(), 5, TimeUnit.MINUTES); + return res; } @Override @@ -440,7 +457,12 @@ public class DashboardServiceImpl implements DashboardService,DashboardAnalysisT @Override public JSONObject getNewRecord() { + String jsonStr = stringRedisTemplate.boundValueOps("newRecord").get(); + JSONObject newRecord = JSONObject.parseObject(jsonStr); + if(newRecord != null){ + return newRecord; + } JSONObject max_amount = customerAndOrdersStatisticsMapper.getMaxAmount(0); JSONObject max_orders = customerAndOrdersStatisticsMapper.getMaxOrders(0); JSONObject maxTransactionPartners = customerAndOrdersStatisticsMapper.getMaxTransactionPartners(); @@ -448,6 +470,7 @@ public class DashboardServiceImpl implements DashboardService,DashboardAnalysisT res.put("max_amount",max_amount); res.put("max_orders",max_orders); res.put("max_transaction_partners",maxTransactionPartners); + stringRedisTemplate.boundValueOps("newRecord").set(res.toJSONString(), 5, TimeUnit.MINUTES); return res; }