Commit cbbb39cf by carrieyzzhang

cache

parent d5a02eac
...@@ -46,6 +46,8 @@ ...@@ -46,6 +46,8 @@
<redis.key.validtime>120</redis.key.validtime> <redis.key.validtime>120</redis.key.validtime>
<redis.ip.requesttimes>5</redis.ip.requesttimes> <redis.ip.requesttimes>5</redis.ip.requesttimes>
<redis.ip.unknown.requesttimes>5</redis.ip.unknown.requesttimes> <redis.ip.unknown.requesttimes>5</redis.ip.unknown.requesttimes>
<cache.livetime>300</cache.livetime>
<iscache>0</iscache>
<redis.surl.host>192.168.2.57</redis.surl.host> <redis.surl.host>192.168.2.57</redis.surl.host>
<redis.surl.port>6379</redis.surl.port> <redis.surl.port>6379</redis.surl.port>
...@@ -158,6 +160,8 @@ ...@@ -158,6 +160,8 @@
<redis.surl.host>io-split-wenqiang.dgfxhr.0001.cnn1.cache.amazonaws.com.cn</redis.surl.host> <redis.surl.host>io-split-wenqiang.dgfxhr.0001.cnn1.cache.amazonaws.com.cn</redis.surl.host>
<redis.surl.port>6379</redis.surl.port> <redis.surl.port>6379</redis.surl.port>
<cache.livetime>300</cache.livetime>
<iscache>0</iscache>
<redis.event.host>io-split-wenqiang.dgfxhr.0001.cnn1.cache.amazonaws.com.cn</redis.event.host> <redis.event.host>io-split-wenqiang.dgfxhr.0001.cnn1.cache.amazonaws.com.cn</redis.event.host>
<redis.event.port>6379</redis.event.port> <redis.event.port>6379</redis.event.port>
...@@ -218,6 +222,8 @@ ...@@ -218,6 +222,8 @@
<redis.surl.host>trackingioweb.nr7fi4.ng.0001.cnn1.cache.amazonaws.com.cn</redis.surl.host> <redis.surl.host>trackingioweb.nr7fi4.ng.0001.cnn1.cache.amazonaws.com.cn</redis.surl.host>
<redis.surl.port>6379</redis.surl.port> <redis.surl.port>6379</redis.surl.port>
<redis.surl.database>1</redis.surl.database> <redis.surl.database>1</redis.surl.database>
<cache.livetime>300</cache.livetime>
<iscache>0</iscache>
<redis.event.host>trackingio-web.nr7fi4.0001.cnn1.cache.amazonaws.com.cn</redis.event.host> <redis.event.host>trackingio-web.nr7fi4.0001.cnn1.cache.amazonaws.com.cn</redis.event.host>
<redis.event.port>6379</redis.event.port> <redis.event.port>6379</redis.event.port>
......
...@@ -4,6 +4,7 @@ import com.reyun.model.Account; ...@@ -4,6 +4,7 @@ import com.reyun.model.Account;
import com.reyun.security.annotation.CurrentAccount; import com.reyun.security.annotation.CurrentAccount;
import com.reyun.service.ComplicateEventsService; import com.reyun.service.ComplicateEventsService;
import com.reyun.service.EventStatsService; import com.reyun.service.EventStatsService;
import com.reyun.util.Constant;
import com.reyun.util.ResultModel; import com.reyun.util.ResultModel;
import com.reyun.util.ResultStatus; import com.reyun.util.ResultStatus;
import com.reyun.util.StringUtil; import com.reyun.util.StringUtil;
...@@ -42,7 +43,7 @@ public class EventStatsController { ...@@ -42,7 +43,7 @@ public class EventStatsController {
if (!StringUtil.isEmpty(eventCondition) && !StringUtil.isEmpty(startDate) && !StringUtil.isEmpty(endDate)) { if (!StringUtil.isEmpty(eventCondition) && !StringUtil.isEmpty(startDate) && !StringUtil.isEmpty(endDate)) {
return ResultModel.OK(complicateEventsService.queryComplicatedEvent(appId, account.getId(), startDate, endDate, return ResultModel.OK(complicateEventsService.queryComplicatedEvent(appId, account.getId(), startDate, endDate,
eventCondition, viewFlag)); eventCondition, viewFlag, 1));
} else { } else {
return ResultModel.ERROR(ResultStatus.PARAM_INVALID); return ResultModel.ERROR(ResultStatus.PARAM_INVALID);
...@@ -63,7 +64,7 @@ public class EventStatsController { ...@@ -63,7 +64,7 @@ public class EventStatsController {
if (!StringUtil.isEmpty(eventCondition) && !StringUtil.isEmpty(startDate) && !StringUtil.isEmpty(endDate)) { if (!StringUtil.isEmpty(eventCondition) && !StringUtil.isEmpty(startDate) && !StringUtil.isEmpty(endDate)) {
return ResultModel.OK(complicateEventsService.queryDistinctTotalData(appId, account.getId(), startDate, endDate, return ResultModel.OK(complicateEventsService.queryDistinctTotalData(appId, account.getId(), startDate, endDate,
eventCondition, viewFlag)); eventCondition, viewFlag, Constant.iacache));
} else { } else {
return ResultModel.ERROR(ResultStatus.PARAM_INVALID); return ResultModel.ERROR(ResultStatus.PARAM_INVALID);
......
...@@ -5,6 +5,7 @@ import java.util.Map; ...@@ -5,6 +5,7 @@ import java.util.Map;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import com.reyun.util.Constant;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
...@@ -57,7 +58,7 @@ public class FunnelController { ...@@ -57,7 +58,7 @@ public class FunnelController {
isProfile=true; isProfile=true;
} }
boolean isDevice = StringUtil.isEmpty(isDeviceStr)?false:"true".equals(isDeviceStr)?true:false; boolean isDevice = StringUtil.isEmpty(isDeviceStr)?false:"true".equals(isDeviceStr)?true:false;
Map<String, List> result = funnelService.funnelReport(funnel, startDate, endDate, usergroupStr, isList, dimentionStr, loginAccount, isDevice,isProfile); Map<String, List> result = funnelService.funnelReport(funnel, startDate, endDate, usergroupStr, isList, dimentionStr, loginAccount, isDevice,isProfile, Constant.iacache);
if (result.isEmpty()) { if (result.isEmpty()) {
return ResultModel.ERROR(ResultStatus.NETWORK_ERROR); return ResultModel.ERROR(ResultStatus.NETWORK_ERROR);
......
...@@ -4,6 +4,7 @@ import com.reyun.model.Account; ...@@ -4,6 +4,7 @@ import com.reyun.model.Account;
import com.reyun.model.IntelligentPath; import com.reyun.model.IntelligentPath;
import com.reyun.security.annotation.CurrentAccount; import com.reyun.security.annotation.CurrentAccount;
import com.reyun.service.IntelligentPathService; import com.reyun.service.IntelligentPathService;
import com.reyun.util.Constant;
import com.reyun.util.ResultModel; import com.reyun.util.ResultModel;
import com.reyun.util.ResultStatus; import com.reyun.util.ResultStatus;
import com.reyun.util.StringUtil; import com.reyun.util.StringUtil;
...@@ -74,6 +75,6 @@ public class IntelligentPathController { ...@@ -74,6 +75,6 @@ public class IntelligentPathController {
intelligentPath.setUserGroup(Long.parseLong(userGroup)); intelligentPath.setUserGroup(Long.parseLong(userGroup));
} }
return ResultModel.OK(intelligentPathService.queryIntelligentPath(loginAccount, intelligentPath)); return ResultModel.OK(intelligentPathService.queryIntelligentPath(loginAccount, intelligentPath, Constant.iacache));
} }
} }
...@@ -86,10 +86,16 @@ public class RetentionController { ...@@ -86,10 +86,16 @@ public class RetentionController {
String endDate = this.getEndDateByReportView(end, reportView); String endDate = this.getEndDateByReportView(end, reportView);
Map<String, List> result = retentionService.retentionDetailReport(loginAccount, startDate, endDate, isList, eventInfo, app, Map<String, List> result = retentionService.retentionDetailReport(loginAccount, startDate, endDate, isList, eventInfo, app,
userGroupStr, dimensionStr, reportView, interval, isDevice, retentiontype,isProfile); userGroupStr, dimensionStr, reportView, interval, isDevice, retentiontype,isProfile, Constant.iacache);
if (retentiontype.equals("define")) {
userLogService.insertLog(loginAccount, LogEnumType.FIND.getCode(), LogEnumType.FIND.getName() + "留存明细报表",
"{\"eventinfo\":" + eventInfo + "}", app, OperateObjectEnumType.REPORT.getCode());
} else {
userLogService.insertLog(loginAccount, LogEnumType.FIND.getCode(), LogEnumType.FIND.getName() + "留存明细报表", userLogService.insertLog(loginAccount, LogEnumType.FIND.getCode(), LogEnumType.FIND.getName() + "留存明细报表",
"{\"eventinfo\":\"" + eventInfo + "\"}", app, OperateObjectEnumType.REPORT.getCode()); "{\"eventinfo\":\"" + eventInfo + "\"}", app, OperateObjectEnumType.REPORT.getCode());
}
if (result.isEmpty()) { if (result.isEmpty()) {
return ResultModel.ERROR(ResultStatus.NETWORK_ERROR); return ResultModel.ERROR(ResultStatus.NETWORK_ERROR);
...@@ -140,7 +146,7 @@ public class RetentionController { ...@@ -140,7 +146,7 @@ public class RetentionController {
Map<String, List> result = retentionService.retentionReport(startDate, endDate, isList, eventInfo, app, userGroupStr, Map<String, List> result = retentionService.retentionReport(startDate, endDate, isList, eventInfo, app, userGroupStr,
dimensionStr, reportView, interval, isDevice, loginAccount.getId(), retentiontype,isProfile); dimensionStr, reportView, interval, isDevice, loginAccount.getId(), retentiontype,isProfile,Constant.iacache);
if (retentiontype.equals("define")) { if (retentiontype.equals("define")) {
userLogService.insertLog(loginAccount, LogEnumType.FIND.getCode(), LogEnumType.FIND.getName() + "留存报表", userLogService.insertLog(loginAccount, LogEnumType.FIND.getCode(), LogEnumType.FIND.getName() + "留存报表",
......
...@@ -23,9 +23,9 @@ public interface ComplicateEventsService { ...@@ -23,9 +23,9 @@ public interface ComplicateEventsService {
List<EventStats> findAllEventStats(Long accountId, Long appId); List<EventStats> findAllEventStats(Long accountId, Long appId);
Map<String, List> queryComplicatedEvent(Long appId, Long accountId, String startDate, String endDate, String eventCondition, String viewType); Map<String, List> queryComplicatedEvent(Long appId, Long accountId, String startDate, String endDate, String eventCondition, String viewType, int isCache);
List<JSONObject> queryDistinctTotalData(Long appId, Long accountId, String startDate, String endDate, String eventCondition, String viewType); List<JSONObject> queryDistinctTotalData(Long appId, Long accountId, String startDate, String endDate, String eventCondition, String viewType, int isCache);
boolean importOldEventData(Account account); boolean importOldEventData(Account account);
......
...@@ -21,7 +21,7 @@ public interface FunnelService { ...@@ -21,7 +21,7 @@ public interface FunnelService {
Funnel validName(String name, Long app); Funnel validName(String name, Long app);
Map<String, List> funnelReport(Long funnel, String startDate, String endDate, String usergroup, boolean isList, String dimention, Account account, boolean isDevice, boolean isProfile); Map<String, List> funnelReport(Long funnel, String startDate, String endDate, String usergroup, boolean isList, String dimention, Account account, boolean isDevice, boolean isProfile, int isCache);
Map<String, List> funnelDataQuery(String startDate, String endDate, String eventInfo, String events, int window, Map<String, List> funnelDataQuery(String startDate, String endDate, String eventInfo, String events, int window,
Long appId, boolean isDevice); Long appId, boolean isDevice);
......
...@@ -20,7 +20,7 @@ public interface IntelligentPathService { ...@@ -20,7 +20,7 @@ public interface IntelligentPathService {
boolean deleteIntelligentPath(Account loginAccount, Long intelligentPathId); boolean deleteIntelligentPath(Account loginAccount, Long intelligentPathId);
JSONObject queryIntelligentPath(Account loginAccount, IntelligentPath intelligentPath); JSONObject queryIntelligentPath(Account loginAccount, IntelligentPath intelligentPath, int isCache);
boolean checkIntelligentPathName(Long accountId, Long id, Long appId, String name); boolean checkIntelligentPathName(Long accountId, Long id, Long appId, String name);
......
...@@ -21,8 +21,8 @@ public interface RetentionService { ...@@ -21,8 +21,8 @@ public interface RetentionService {
Retention validName(String name, Long app); Retention validName(String name, Long app);
Map<String, List> retentionReport(String startDate, String endDate, boolean isList, String eventInfo, Long app, String usergroup, String dimention, String reportView, int interval, boolean isDevice, Long account,String retentiontype,boolean isProfile); Map<String, List> retentionReport(String startDate, String endDate, boolean isList, String eventInfo, Long app, String usergroup, String dimention, String reportView, int interval, boolean isDevice, Long account,String retentiontype,boolean isProfile, int isCache);
Map<String, List> retentionDetailReport(Account account, String startDate, String endDate, boolean isList, String eventInfo, Long app, String usergroup, String dimention, String reportView, int interval, boolean isDevice, String retentiontype, boolean isProfile); Map<String, List> retentionDetailReport(Account account, String startDate, String endDate, boolean isList, String eventInfo, Long app, String usergroup, String dimention, String reportView, int interval, boolean isDevice, String retentiontype, boolean isProfile, int isCache);
} }
...@@ -17,6 +17,7 @@ import net.sf.json.JSONObject; ...@@ -17,6 +17,7 @@ import net.sf.json.JSONObject;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
...@@ -188,7 +189,8 @@ public class ComplicatedEventsServiceImpl implements ComplicateEventsService{ ...@@ -188,7 +189,8 @@ public class ComplicatedEventsServiceImpl implements ComplicateEventsService{
* 复杂事件查询 * 复杂事件查询
*/ */
@Override @Override
public Map<String, List> queryComplicatedEvent(Long appId, Long accountId, String startDate, String endDate, String eventCondition, String viewType) { @Cacheable(value = "reportCache", key = "'eventstats'+#appId+#accountId+#startDate+#endDate+#eventCondition+#viewType+#isCache", condition = "#isCache == 1")
public Map<String, List> queryComplicatedEvent(Long appId, Long accountId, String startDate, String endDate, String eventCondition, String viewType, int isCache) {
Map<String, List> result = new HashMap<>(); Map<String, List> result = new HashMap<>();
...@@ -249,7 +251,8 @@ public class ComplicatedEventsServiceImpl implements ComplicateEventsService{ ...@@ -249,7 +251,8 @@ public class ComplicatedEventsServiceImpl implements ComplicateEventsService{
* 合计查询 * 合计查询
*/ */
@Override @Override
public List<JSONObject> queryDistinctTotalData(Long appId, Long accountId, String startDate, String endDate, String eventCondition, String viewType) { @Cacheable(value = "reportCache", key = "'eventstatstotal'+#appId+#accountId+#startDate+#endDate+#eventCondition+#viewType+#isCache", condition = "#isCache == 1")
public List<JSONObject> queryDistinctTotalData(Long appId, Long accountId, String startDate, String endDate, String eventCondition, String viewType, int isCache) {
List<JSONObject> result = new ArrayList<>(); List<JSONObject> result = new ArrayList<>();
......
...@@ -928,7 +928,7 @@ public class CustomMenuServiceImpl implements CustomMenuService { ...@@ -928,7 +928,7 @@ public class CustomMenuServiceImpl implements CustomMenuService {
if (null != eventStats) { if (null != eventStats) {
resultData = complicateEventsService.queryComplicatedEvent(appId, accountId, startDate, endDate, resultData = complicateEventsService.queryComplicatedEvent(appId, accountId, startDate, endDate,
eventStats.getEventCondition(), viewFlag); eventStats.getEventCondition(), viewFlag, 1);
} }
break; break;
...@@ -955,7 +955,7 @@ public class CustomMenuServiceImpl implements CustomMenuService { ...@@ -955,7 +955,7 @@ public class CustomMenuServiceImpl implements CustomMenuService {
if (null != retention) { if (null != retention) {
resultData = retentionService.retentionReport(startDate, endDate, false, retention.getEventInfo(), resultData = retentionService.retentionReport(startDate, endDate, false, retention.getEventInfo(),
appId, null, "-all", viewFlag, 7, false, accountId,null,false); appId, null, "-all", viewFlag, 7, false, accountId,null,false, 1);
} }
break; break;
} }
......
...@@ -15,6 +15,7 @@ import net.sf.json.JSONObject; ...@@ -15,6 +15,7 @@ import net.sf.json.JSONObject;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
...@@ -64,8 +65,9 @@ public class FunnelServiceImpl implements FunnelService { ...@@ -64,8 +65,9 @@ public class FunnelServiceImpl implements FunnelService {
private final static String TEMPLATE_TYPE_FUNNEL = "funnel"; private final static String TEMPLATE_TYPE_FUNNEL = "funnel";
@Override @Override
@Cacheable(value = "reportCache", key = "'funnel'+#funnel+#startDate+#endDate+#usergroup+#isList+#dimention+#account+#isDevice+#isProfile+#isCache", condition = "#isCache == 1")
public Map<String, List> funnelReport(Long funnel, String startDate, String endDate, String usergroup, boolean isList, public Map<String, List> funnelReport(Long funnel, String startDate, String endDate, String usergroup, boolean isList,
String dimention, Account account, boolean isDevice, boolean isProfile) { String dimention, Account account, boolean isDevice, boolean isProfile, int isCache) {
Funnel funnelObject = funnelRepository.findOne(funnel); Funnel funnelObject = funnelRepository.findOne(funnel);
App app = appRepository.findOne(funnelObject.getApp()); App app = appRepository.findOne(funnelObject.getApp());
......
...@@ -21,6 +21,7 @@ import net.sf.json.JSONObject; ...@@ -21,6 +21,7 @@ import net.sf.json.JSONObject;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
...@@ -131,7 +132,8 @@ public class IntelligentPathServiceImpl implements IntelligentPathService { ...@@ -131,7 +132,8 @@ public class IntelligentPathServiceImpl implements IntelligentPathService {
* 智能路径查询数据 * 智能路径查询数据
*/ */
@Override @Override
public JSONObject queryIntelligentPath(Account loginAccount, IntelligentPath intelligentPath) { @Cacheable(value = "reportCache", key = "'eventstatstotal'+#loginAccount+#intelligentPath+#isCache", condition = "#isCache == 1")
public JSONObject queryIntelligentPath(Account loginAccount, IntelligentPath intelligentPath, int isCache) {
JSONObject resultObject = new JSONObject(); JSONObject resultObject = new JSONObject();
......
...@@ -14,6 +14,7 @@ import net.sf.json.JSONObject; ...@@ -14,6 +14,7 @@ import net.sf.json.JSONObject;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
...@@ -203,9 +204,10 @@ public class RetentionServiceImpl implements RetentionService { ...@@ -203,9 +204,10 @@ public class RetentionServiceImpl implements RetentionService {
} }
@Override @Override
@Cacheable(value = "reportCache", key = "'retention'+#startDate+#endDate+#isList+#eventInfo+#app+#usergroup+#dimention+#reportView+#interval+#isDevice+#account+#retentiontype+#isProfile+#isCache", condition = "#isCache == 1")
public Map<String, List> retentionReport(String startDate, String endDate, boolean isList, public Map<String, List> retentionReport(String startDate, String endDate, boolean isList,
String eventInfo, Long app, String usergroup, String dimention, String eventInfo, Long app, String usergroup, String dimention,
String reportView, int interval, boolean isDevice, Long account, String retentiontype, boolean isProfile) { String reportView, int interval, boolean isDevice, Long account, String retentiontype, boolean isProfile, int isCache) {
int retentions = 30; int retentions = 30;
if (reportView.equals("week")) { if (reportView.equals("week")) {
...@@ -550,8 +552,9 @@ public class RetentionServiceImpl implements RetentionService { ...@@ -550,8 +552,9 @@ public class RetentionServiceImpl implements RetentionService {
} }
@Override @Override
@Cacheable(value = "reportCache", key = "'retentiondetail'+#loginAccount+#startDate+#endDate+#isList+#eventInfo+#app+#usergroup+#dimention+#reportView+#interval+#isDevice+#account+#retentiontype+#isProfile+#isCache", condition = "#isCache == 1")
public Map<String, List> retentionDetailReport(Account loginAccount, String startDate, String endDate, boolean isList, String eventInfo, Long app, public Map<String, List> retentionDetailReport(Account loginAccount, String startDate, String endDate, boolean isList, String eventInfo, Long app,
String usergroup, String dimention, String reportView, int interval, boolean isDevice, String retentiontype, boolean isProfile) { String usergroup, String dimention, String reportView, int interval, boolean isDevice, String retentiontype, boolean isProfile, int isCache) {
int retentions = 30; int retentions = 30;
...@@ -824,7 +827,7 @@ public class RetentionServiceImpl implements RetentionService { ...@@ -824,7 +827,7 @@ public class RetentionServiceImpl implements RetentionService {
result.put("val", val); result.put("val", val);
result.put("columnkey", columnkey); result.put("columnkey", columnkey);
result.put("name", name); result.put("name", name);
result.put("key", name.subList(1, name.size())); result.put("key", new ArrayList(name.subList(1, name.size())));
return result; return result;
} }
......
...@@ -80,7 +80,7 @@ public class EventReportCallable implements Callable<Map<String, List>> { ...@@ -80,7 +80,7 @@ public class EventReportCallable implements Callable<Map<String, List>> {
}else{ }else{
//查询合计 //查询合计
List<JSONObject> totalValue = eventStatsService.queryDistinctTotalData(app.getId(), accountid, startDate, endDate, eventCondition, viewType); List<JSONObject> totalValue = eventStatsService.queryDistinctTotalData(app.getId(), accountid, startDate, endDate, eventCondition, viewType, 1);
result = new HashMap<>(); result = new HashMap<>();
result.put("totalval",totalValue); result.put("totalval",totalValue);
} }
......
...@@ -157,6 +157,8 @@ public class ReportCallable implements Callable<Map<String, List>> { ...@@ -157,6 +157,8 @@ public class ReportCallable implements Callable<Map<String, List>> {
Map<String, List> responseJson = new HashMap<>(); Map<String, List> responseJson = new HashMap<>();
System.out.println(url);
if (url == null) { if (url == null) {
try { try {
String responseStr = HttpClientUtil.doHttpPostRequest(url.toString(), "trackingio", conditions); String responseStr = HttpClientUtil.doHttpPostRequest(url.toString(), "trackingio", conditions);
...@@ -172,7 +174,7 @@ public class ReportCallable implements Callable<Map<String, List>> { ...@@ -172,7 +174,7 @@ public class ReportCallable implements Callable<Map<String, List>> {
} }
System.out.println(responseJson.get("columnkey"));
//结果处理 //结果处理
switch (reportType) { switch (reportType) {
......
...@@ -116,7 +116,6 @@ public class UserLogThread extends Thread ...@@ -116,7 +116,6 @@ public class UserLogThread extends Thread
try try
{ {
if (this.content != null) { if (this.content != null) {
System.out.println(this.content);
this.operaContent = JSONObject.fromObject(this.content).toString(); this.operaContent = JSONObject.fromObject(this.content).toString();
} else if (this.contentList != null) { } else if (this.contentList != null) {
System.out.println(this.contentList); System.out.println(this.contentList);
......
...@@ -55,4 +55,6 @@ public class Constant { ...@@ -55,4 +55,6 @@ public class Constant {
public static ResourceBundle redis = ResourceBundle.getBundle("redis"); public static ResourceBundle redis = ResourceBundle.getBundle("redis");
public static String REDIS_IP_REQUEST_TIMES = redis.getString("redis.ip.requesttimes"); public static String REDIS_IP_REQUEST_TIMES = redis.getString("redis.ip.requesttimes");
public static long cacheLiveTime = Long.parseLong(redis.getString("cache.livetime"));
public static Integer iacache = Integer.parseInt(redis.getString("iscache"));
} }
package com.reyun.util;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.Cache;
import org.springframework.cache.support.SimpleValueWrapper;
import org.springframework.dao.DataAccessException;
import org.springframework.data.redis.connection.RedisConnection;
import org.springframework.data.redis.core.RedisCallback;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;
import java.io.*;
import java.util.concurrent.Callable;
@Service
public class RedisCache implements Cache {
private static Logger logger = LoggerFactory.getLogger(RedisCache.class);
@Autowired
private RedisTemplate<String, Object> redisTemplate;
private String name;
public RedisTemplate<String, Object> getRedisTemplate() {
return redisTemplate;
}
public void setRedisTemplate(RedisTemplate<String, Object> redisTemplate) {
this.redisTemplate = redisTemplate;
}
public void setName(String name) {
this.name = name;
}
@Override
public String getName() {
// TODO Auto-generated method stub
return this.name;
}
@Override
public Object getNativeCache() {
// TODO Auto-generated method stub
return this.redisTemplate;
}
@Override
public ValueWrapper get(Object key) {
// TODO Auto-generated method stub
// logger.debug("get key:"+ key);
final String keyf = key.toString();
Object object = null;
object = redisTemplate.execute(new RedisCallback<Object>() {
public Object doInRedis(RedisConnection connection)
throws DataAccessException {
byte[] key = keyf.getBytes();
byte[] value = connection.get(key);
if (value == null) {
return null;
}
return toObject(value);
}
});
return (object != null ? new SimpleValueWrapper(object) : null);
}
@Override
public <T> T get(Object o, Class<T> aClass)
{
return null;
}
@Override
public <T> T get(Object o, Callable<T> callable)
{
return null;
}
@Override
public void put(Object key, Object value) {
// logger.debug("put key:" + key + ", value:" + value);
final String keyf = key.toString();
final Object valuef = value;
final long liveTime = Constant.cacheLiveTime;
redisTemplate.execute(new RedisCallback<Long>() {
public Long doInRedis(RedisConnection connection)
throws DataAccessException {
byte[] keyb = keyf.getBytes();
byte[] valueb = toByteArray(valuef);
connection.set(keyb, valueb);
if (liveTime > 0) {
connection.expire(keyb, liveTime);
}
return 1L;
}
});
}
@Override
public ValueWrapper putIfAbsent(Object o, Object o1)
{
return null;
}
private byte[] toByteArray(Object obj) {
byte[] bytes = null;
ByteArrayOutputStream bos = new ByteArrayOutputStream();
try {
ObjectOutputStream oos = new ObjectOutputStream(bos);
oos.writeObject(obj);
oos.flush();
bytes = bos.toByteArray();
oos.close();
bos.close();
} catch (IOException ex) {
ex.printStackTrace();
}
return bytes;
}
private Object toObject(byte[] bytes) {
Object obj = null;
try {
ByteArrayInputStream bis = new ByteArrayInputStream(bytes);
ObjectInputStream ois = new ObjectInputStream(bis);
obj = ois.readObject();
ois.close();
bis.close();
} catch (IOException ex) {
ex.printStackTrace();
} catch (ClassNotFoundException ex) {
ex.printStackTrace();
}
return obj;
}
@Override
public void evict(Object key) {
logger.debug("delete key:" + key);
final String keyf = key.toString();
redisTemplate.execute(new RedisCallback<Long>() {
public Long doInRedis(RedisConnection connection)
throws DataAccessException {
return connection.del(keyf.getBytes());
}
});
}
@Override
public void clear() {
logger.debug("clear all data." );
redisTemplate.execute(new RedisCallback<String>() {
public String doInRedis(RedisConnection connection)
throws DataAccessException {
connection.flushDb();
return "ok";
}
});
}
}
...@@ -414,7 +414,7 @@ public class SqlUtil ...@@ -414,7 +414,7 @@ public class SqlUtil
nameList.add(dimension); nameList.add(dimension);
} }
List<Object> valSumList = valArray.subList(valArray.size() - eventList.size(), valArray.size()); List<Object> valSumList = new ArrayList<>(valArray.subList(valArray.size() - eventList.size(), valArray.size()));
List<Long> users = new ArrayList<>(); List<Long> users = new ArrayList<>();
for (Object o : valSumList) { for (Object o : valSumList) {
users.add(Long.valueOf(o.toString())); users.add(Long.valueOf(o.toString()));
...@@ -429,7 +429,7 @@ public class SqlUtil ...@@ -429,7 +429,7 @@ public class SqlUtil
JSONArray valArray = JSONArray.fromObject(val.get("_col0")); JSONArray valArray = JSONArray.fromObject(val.get("_col0"));
if (valArray.size() > 0) { if (valArray.size() > 0) {
List<Object> usersObject = valArray.subList(valArray.size() - eventList.size(), valArray.size()); List<Object> usersObject = new ArrayList<>(valArray.subList(valArray.size() - eventList.size(), valArray.size()));
Map<String, Object> innerMap = new HashMap<>(); Map<String, Object> innerMap = new HashMap<>();
innerMap.put(dimension, "整体"); innerMap.put(dimension, "整体");
...@@ -640,8 +640,8 @@ public class SqlUtil ...@@ -640,8 +640,8 @@ public class SqlUtil
if (users.size() > 0) { if (users.size() > 0) {
int retentionInterval = getRetentions(reportView); int retentionInterval = getRetentions(reportView);
List<Long> firstEventUsers = users.subList(users.size() - interval, users.size()); List<Long> firstEventUsers = new ArrayList<>(users.subList(users.size() - interval, users.size()));
List<Long> secondEventUsers = users.subList(0, users.size() - interval); List<Long> secondEventUsers = new ArrayList<>(users.subList(0, users.size() - interval));
for (int i = 0; i < interval; i++) { for (int i = 0; i < interval; i++) {
...@@ -751,8 +751,8 @@ public class SqlUtil ...@@ -751,8 +751,8 @@ public class SqlUtil
if (users.size() > 0) { if (users.size() > 0) {
List<Long> firstEventUsers = users.subList(users.size() - interval, users.size()); List<Long> firstEventUsers = new ArrayList<>(users.subList(users.size() - interval, users.size()));
List<Long> secondEventUsers = users.subList(0, users.size() - interval); List<Long> secondEventUsers = new ArrayList<>(users.subList(0, users.size() - interval));
if (!StringUtil.isEmpty(dimension)) { if (!StringUtil.isEmpty(dimension)) {
columnKeyList.add(dimension); columnKeyList.add(dimension);
...@@ -794,7 +794,7 @@ public class SqlUtil ...@@ -794,7 +794,7 @@ public class SqlUtil
result.put("val", valueResult); result.put("val", valueResult);
result.put("columnkey", columnKeyList); result.put("columnkey", columnKeyList);
result.put("name", nameList); result.put("name", nameList);
result.put("key", nameList.isEmpty() ? new ArrayList<String>() : nameList.subList(1, nameList.size())); result.put("key", nameList.isEmpty() ? new ArrayList<String>() : new ArrayList(nameList.subList(1, nameList.size())));
} }
return result; return result;
...@@ -846,7 +846,7 @@ public class SqlUtil ...@@ -846,7 +846,7 @@ public class SqlUtil
result.put("columnkey", columnKey); result.put("columnkey", columnKey);
result.put("name", name); result.put("name", name);
result.put("key", name.subList(1, name.size())); result.put("key", new ArrayList(name.subList(1, name.size())));
result.put("isempty", new ArrayList<>(1)); result.put("isempty", new ArrayList<>(1));
result.put("val", val); result.put("val", val);
...@@ -1083,7 +1083,7 @@ public class SqlUtil ...@@ -1083,7 +1083,7 @@ public class SqlUtil
result.put("columnkey", reportListResult.getColumnkey()); result.put("columnkey", reportListResult.getColumnkey());
result.put("name", nameList); result.put("name", nameList);
result.put("key", nameList.subList(1, nameList.size())); result.put("key", new ArrayList(nameList.subList(1, nameList.size())));
result.put("val", reportListResult.getVal()); result.put("val", reportListResult.getVal());
for (Map<String, Object> v : val) { for (Map<String, Object> v : val) {
...@@ -1177,7 +1177,7 @@ public class SqlUtil ...@@ -1177,7 +1177,7 @@ public class SqlUtil
List<String> name = result.get("name"); List<String> name = result.get("name");
name.remove("日期"); name.remove("日期");
name.add(0, "usergroup"); name.add(0, "usergroup");
result.put("key", name.subList(1, name.size())); result.put("key", new ArrayList(name.subList(1, name.size())));
} }
else if (!StringUtil.isEmpty(userGroup)) { else if (!StringUtil.isEmpty(userGroup)) {
...@@ -1188,7 +1188,7 @@ public class SqlUtil ...@@ -1188,7 +1188,7 @@ public class SqlUtil
List<String> name = result.get("name"); List<String> name = result.get("name");
name.remove("日期"); name.remove("日期");
name.add(0, "usergroup"); name.add(0, "usergroup");
result.put("key", name.subList(1, name.size())); result.put("key", new ArrayList(name.subList(1, name.size())));
} }
else { else {
valueResultMap.put("ds", "整体"); valueResultMap.put("ds", "整体");
...@@ -1208,7 +1208,7 @@ public class SqlUtil ...@@ -1208,7 +1208,7 @@ public class SqlUtil
List<String> name = result.get("name"); List<String> name = result.get("name");
name.remove("日期"); name.remove("日期");
name.add(0, "usergroup"); name.add(0, "usergroup");
result.put("key", name.subList(1, name.size())); result.put("key", new ArrayList(name.subList(1, name.size())));
} }
else { else {
newVal.add(getEmptyRetentionValue("ds", null, "日期", reportView)); newVal.add(getEmptyRetentionValue("ds", null, "日期", reportView));
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
xmlns:jdbc="http://www.springframework.org/schema/jdbc" xmlns:jee="http://www.springframework.org/schema/jee" xmlns:jdbc="http://www.springframework.org/schema/jdbc" xmlns:jee="http://www.springframework.org/schema/jee"
xmlns:tx="http://www.springframework.org/schema/tx" xmlns:jpa="http://www.springframework.org/schema/data/jpa" xmlns:tx="http://www.springframework.org/schema/tx" xmlns:jpa="http://www.springframework.org/schema/data/jpa"
xmlns:task="http://www.springframework.org/schema/task" xmlns:p="http://www.springframework.org/schema/p" xmlns:task="http://www.springframework.org/schema/task" xmlns:p="http://www.springframework.org/schema/p"
xmlns:cache="http://www.springframework.org/schema/cache"
xmlns:aop="http://www.springframework.org/schema/aop" xmlns:aop="http://www.springframework.org/schema/aop"
xsi:schemaLocation="http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task.xsd xsi:schemaLocation="http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
...@@ -12,7 +13,8 @@ ...@@ -12,7 +13,8 @@
http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc.xsd http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc.xsd
http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee.xsd http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd
http://www.springframework.org/schema/data/jpa http://www.springframework.org/schema/data/jpa/spring-jpa.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd" http://www.springframework.org/schema/data/jpa http://www.springframework.org/schema/data/jpa/spring-jpa.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd
http://www.springframework.org/schema/cache http://www.springframework.org/schema/cache/spring-cache.xsd"
default-lazy-init="true"> default-lazy-init="true">
<description>Spring公共配置</description> <description>Spring公共配置</description>
...@@ -39,6 +41,9 @@ ...@@ -39,6 +41,9 @@
<bean id="redisTemplate" class="org.springframework.data.redis.core.StringRedisTemplate"> <bean id="redisTemplate" class="org.springframework.data.redis.core.StringRedisTemplate">
<property name="connectionFactory" ref="connectionFactory" /> <property name="connectionFactory" ref="connectionFactory" />
</bean> </bean>
<bean id="redisTemplate4Cache" class="org.springframework.data.redis.core.RedisTemplate">
<property name="connectionFactory" ref="JedisConnectionFactory" />
</bean>
<!--//Redis配置 --> <!--//Redis配置 -->
<bean id="dataSource" class="com.alibaba.druid.pool.DruidDataSource" destroy-method="close"> <bean id="dataSource" class="com.alibaba.druid.pool.DruidDataSource" destroy-method="close">
...@@ -121,4 +126,28 @@ ...@@ -121,4 +126,28 @@
<!-- 指定所上传文件的总大小不能超过2000KB。注意maxUploadSize属性的限制不是针对单个文件,而是所有文件的容量之和 --> <!-- 指定所上传文件的总大小不能超过2000KB。注意maxUploadSize属性的限制不是针对单个文件,而是所有文件的容量之和 -->
<property name="maxUploadSize" value="2000000"/> <property name="maxUploadSize" value="2000000"/>
</bean> </bean>
<cache:annotation-driven cache-manager="cacheManager"/>
<!-- redis 相关配置 -->
<bean id="JedisConnectionFactory" class="org.springframework.data.redis.connection.jedis.JedisConnectionFactory"
p:host-name="${redis.surl.host}" p:port="${redis.surl.port}" p:pool-config-ref="poolConfig"/>
<bean id="cacheManager" class="org.springframework.cache.support.SimpleCacheManager">
<property name="caches">
<set>
<!-- 这里可以配置多个redis -->
<!-- <bean class="com.cn.util.RedisCache">
<property name="redisTemplate" ref="redisTemplate" />
<property name="name" value="default"/>
</bean> -->
<bean class="com.reyun.util.RedisCache">
<property name="redisTemplate" ref="redisTemplate4Cache" />
<property name="name" value="reportCache"/>
<!-- common名称要在类或方法的注解中使用 -->
</bean>
</set>
</property>
</bean>
</beans> </beans>
...@@ -10,3 +10,7 @@ redis.surl.database=${redis.surl.database} ...@@ -10,3 +10,7 @@ redis.surl.database=${redis.surl.database}
redis.event.host=${redis.event.host} redis.event.host=${redis.event.host}
redis.event.port=${redis.event.port} redis.event.port=${redis.event.port}
redis.event.database=${redis.event.database} redis.event.database=${redis.event.database}
cache.livetime=${cache.livetime}
iscache=${iscache}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment