Commit 7d708f59 by carrieyzzhang

export

parent cc658f18
...@@ -91,6 +91,11 @@ ...@@ -91,6 +91,11 @@
<account.check.url>http://localhost:8091</account.check.url> <account.check.url>http://localhost:8091</account.check.url>
<ddb.accesskey>AKIAOS2UEXIFNVER2O6A</ddb.accesskey>
<ddb.secretkey>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</ddb.secretkey>
<report.export.task>ExportReportTask</report.export.task>
</properties> </properties>
</profile> </profile>
<profile> <profile>
...@@ -201,6 +206,11 @@ ...@@ -201,6 +206,11 @@
<account.check.url>http://52.80.113.103:8006</account.check.url> <account.check.url>http://52.80.113.103:8006</account.check.url>
<ddb.accesskey>AKIAOS2UEXIFNVER2O6A</ddb.accesskey>
<ddb.secretkey>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</ddb.secretkey>
<report.export.task>ExportReportTask</report.export.task>
</properties> </properties>
</profile> </profile>
...@@ -271,6 +281,11 @@ ...@@ -271,6 +281,11 @@
<account.check.url>http://io.reyun.com</account.check.url> <account.check.url>http://io.reyun.com</account.check.url>
<ddb.accesskey>AKIAPMJ4QRXP6BECFUVQ</ddb.accesskey>
<ddb.secretkey>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</ddb.secretkey>
<report.export.task>ExportReportTask</report.export.task>
</properties> </properties>
</profile> </profile>
</profiles> </profiles>
......
...@@ -12,6 +12,11 @@ ...@@ -12,6 +12,11 @@
</webroots> </webroots>
</configuration> </configuration>
</facet> </facet>
<facet type="Spring" name="Spring">
<configuration>
<fileset id="fileset" name="Spring Application Context" removed="false" />
</configuration>
</facet>
</component> </component>
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8" inherit-compiler-output="false"> <component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8" inherit-compiler-output="false">
<output url="file://$MODULE_DIR$/target/classes" /> <output url="file://$MODULE_DIR$/target/classes" />
......
...@@ -43,7 +43,7 @@ public class EventStatsController { ...@@ -43,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, 1)); eventCondition, viewFlag, Constant.iscache));
} else { } else {
return ResultModel.ERROR(ResultStatus.PARAM_INVALID); return ResultModel.ERROR(ResultStatus.PARAM_INVALID);
...@@ -64,7 +64,7 @@ public class EventStatsController { ...@@ -64,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, Constant.iacache)); eventCondition, viewFlag, Constant.iscache));
} else { } else {
return ResultModel.ERROR(ResultStatus.PARAM_INVALID); return ResultModel.ERROR(ResultStatus.PARAM_INVALID);
......
...@@ -58,7 +58,7 @@ public class FunnelController { ...@@ -58,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, Constant.iacache); Map<String, List> result = funnelService.funnelReport(funnel, startDate, endDate, usergroupStr, isList, dimentionStr, loginAccount, isDevice,isProfile, Constant.iscache);
if (result.isEmpty()) { if (result.isEmpty()) {
return ResultModel.ERROR(ResultStatus.NETWORK_ERROR); return ResultModel.ERROR(ResultStatus.NETWORK_ERROR);
......
...@@ -75,6 +75,6 @@ public class IntelligentPathController { ...@@ -75,6 +75,6 @@ public class IntelligentPathController {
intelligentPath.setUserGroup(Long.parseLong(userGroup)); intelligentPath.setUserGroup(Long.parseLong(userGroup));
} }
return ResultModel.OK(intelligentPathService.queryIntelligentPath(loginAccount, intelligentPath, Constant.iacache)); return ResultModel.OK(intelligentPathService.queryIntelligentPath(loginAccount, intelligentPath, Constant.iscache));
} }
} }
...@@ -86,7 +86,7 @@ public class RetentionController { ...@@ -86,7 +86,7 @@ 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, Constant.iacache); userGroupStr, dimensionStr, reportView, interval, isDevice, retentiontype,isProfile, Constant.iscache);
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() + "留存明细报表",
...@@ -146,7 +146,7 @@ public class RetentionController { ...@@ -146,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,Constant.iacache); dimensionStr, reportView, interval, isDevice, loginAccount.getId(), retentiontype,isProfile, Constant.iscache);
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() + "留存报表",
......
...@@ -391,7 +391,7 @@ public class AccountFlowRestrictServiceImpl implements AccountFlowRestrictServic ...@@ -391,7 +391,7 @@ public class AccountFlowRestrictServiceImpl implements AccountFlowRestrictServic
conditions.put("startdate", createTime); conditions.put("startdate", createTime);
conditions.put("enddate", pastDate); conditions.put("enddate", pastDate);
conditions.put("datatype", "list"); conditions.put("datatype", "list");
conditions.put("iscache", Constant.iscache); conditions.put("iscache", Constant.iscache.toString());
String url = Constant.reportUrl + "/api/trackingio/" + reportName + "/" + appId; String url = Constant.reportUrl + "/api/trackingio/" + reportName + "/" + appId;
String responseJson = HttpClientUtil.doHttpPostRequest(url, "trackingio", conditions); String responseJson = HttpClientUtil.doHttpPostRequest(url, "trackingio", conditions);
HashMap<String, String> resultValMap = new HashMap<>(); HashMap<String, String> resultValMap = new HashMap<>();
......
package com.reyun.task;
import com.reyun.dic.DownloadStatusEnumType;
import com.reyun.model.ExportReportInfo;
import com.reyun.service.ExportReportInfoService;
import com.reyun.taskexecute.ExportReportThread;
import com.reyun.util.AwsS3Util;
import com.reyun.util.Constant;
import com.reyun.util.RedisUtilNew;
import org.apache.commons.lang.time.DateUtils;
import org.joda.time.DateTime;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* Created by zxy on 17/4/27.
* description:报表导出
*/
@Service
public class ExportReportTask {
private static Logger logger = LoggerFactory.getLogger(ExportReportTask.class);
private static int EXPIRE_PERIOD = (int) DateUtils.MILLIS_PER_MINUTE * 1 / 1000;
private static final String S3_DOWNLOAD_BUCKET = "reyundownload-test";
private static final String DOWNLOAD_PATH = "trackingio/reportdownload/";
@Autowired
private ExportReportInfoService exportService;
public void run(){
logger.info("导出报表结果数据................//Begin, 执行时间: {}", DateTime.now());
if (RedisUtilNew.getInstance().tryLock(Constant.reportExportTask, EXPIRE_PERIOD) != null) {
//生成数据
List<ExportReportInfo> exportList = exportService.findExport2Deal();
for (ExportReportInfo export : exportList) {
logger.info(export.getFileName());
Thread exportReportThread = new ExportReportThread(export);
exportReportThread.start();
}
//删除已过期文件
List<ExportReportInfo> invalidExportInfoList = exportService.findInvalidExportList();
for (ExportReportInfo invalidExport : invalidExportInfoList) {
final String s3key = DOWNLOAD_PATH + invalidExport.getFileName();
//删除文件
if(AwsS3Util.getInstance().getAmazonS3().doesObjectExist(S3_DOWNLOAD_BUCKET, s3key)) {
AwsS3Util.getInstance().deleteS3Object(S3_DOWNLOAD_BUCKET, s3key);
}
//跟新文件为失效状态
exportService.updateStatus(invalidExport.getId(), DownloadStatusEnumType.INVALID.getCode());
}
} else {
logger.info("ExportReportTask正在执行中......");
}
logger.info("导出报表结果数据................//End");
}
}
...@@ -24,8 +24,8 @@ public class AwsS3Util { ...@@ -24,8 +24,8 @@ public class AwsS3Util {
private AmazonS3 s3; private AmazonS3 s3;
private AwsS3Util() { private AwsS3Util() {
String accessKey = ""; String accessKey = Constant.accessKey;
String secretKey = ""; String secretKey = Constant.secretKey;
if ((accessKey != null) && (secretKey != null)) { if ((accessKey != null) && (secretKey != null)) {
AWSCredentials credentials = new BasicAWSCredentials(accessKey, secretKey); AWSCredentials credentials = new BasicAWSCredentials(accessKey, secretKey);
......
...@@ -35,11 +35,11 @@ public class Constant { ...@@ -35,11 +35,11 @@ public class Constant {
public static String reportUrl = commonBundle.getString("report.url"); public static String reportUrl = commonBundle.getString("report.url");
public static String adminUrl = commonBundle.getString("admin.url"); public static String adminUrl = commonBundle.getString("admin.url");
public static String trackingUrl = commonBundle.getString("trackingio.url"); public static String trackingUrl = commonBundle.getString("trackingio.url");
public static String iscache = commonBundle.getString("iscache");
public static String receiverHost = commonBundle.getString("receiver.host"); public static String receiverHost = commonBundle.getString("receiver.host");
public static String receiverPort = commonBundle.getString("receiver.port"); public static String receiverPort = commonBundle.getString("receiver.port");
public static String demoUrl = commonBundle.getString("demo.url"); public static String demoUrl = commonBundle.getString("demo.url");
public static String flowneed = commonBundle.getString("flowneed"); public static String flowneed = commonBundle.getString("flowneed");
public static String reportExportTask = commonBundle.getString("report.export.task");
...@@ -56,5 +56,10 @@ public class Constant { ...@@ -56,5 +56,10 @@ 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 long cacheLiveTime = Long.parseLong(redis.getString("cache.livetime"));
public static Integer iacache = Integer.parseInt(redis.getString("iscache")); public static Integer iscache = Integer.parseInt(redis.getString("iscache"));
public static ResourceBundle keyBuddle = ResourceBundle.getBundle("key");
public static String accessKey = keyBuddle.getString("ddb.accesskey");
public static String secretKey = keyBuddle.getString("ddb.secretkey");
} }
...@@ -17,7 +17,6 @@ import java.util.List; ...@@ -17,7 +17,6 @@ import java.util.List;
public class SendCommonPostMail { public class SendCommonPostMail {
protected static Logger logger = LoggerFactory.getLogger(SendCommonPostMail.class);
static String url = "http://api.sendcloud.net/apiv2/mail/send"; static String url = "http://api.sendcloud.net/apiv2/mail/send";
static String apiUser = "service24h"; static String apiUser = "service24h";
...@@ -56,11 +55,11 @@ public class SendCommonPostMail { ...@@ -56,11 +55,11 @@ public class SendCommonPostMail {
String result = EntityUtils.toString(response.getEntity()); String result = EntityUtils.toString(response.getEntity());
success = true; success = true;
} else { } else {
logger.error("sendcloud response status is error......."); System.out.println("sendcloud response status is error.......");
} }
httPost.releaseConnection(); httPost.releaseConnection();
} catch (Exception e) { } catch (Exception e) {
logger.error("fail to send mail to " + toEmail); System.out.println("fail to send mail to " + toEmail);
} }
return success; return success;
} }
......
...@@ -10,8 +10,10 @@ ...@@ -10,8 +10,10 @@
<description>调度配置</description> <description>调度配置</description>
<bean id="autoCalculateFlow" class="com.reyun.task.AutoCalculateFlow"></bean> <bean id="autoCalculateFlow" class="com.reyun.task.AutoCalculateFlow"></bean>
<!--<bean id="exportReportTask" class="com.reyun.task.ExportReportTask"></bean>-->
<task:scheduled-tasks> <task:scheduled-tasks>
<task:scheduled ref="autoCalculateFlow" method="run" cron="0 0 7 * * ?"/> <task:scheduled ref="autoCalculateFlow" method="run" cron="0 0 7 * * ?"/>
<!--<task:scheduled ref="exportReportTask" method="run" cron="0 */2 * * * ?"/>-->
</task:scheduled-tasks> </task:scheduled-tasks>
</beans> </beans>
...@@ -2,6 +2,7 @@ profile.table=${profile.table} ...@@ -2,6 +2,7 @@ profile.table=${profile.table}
event.table=${event.table} event.table=${event.table}
usergroup.table=${usergroup.table} usergroup.table=${usergroup.table}
account.check.url=${account.check.url} account.check.url=${account.check.url}
report.export.task=${report.export.task}
receiver.host=${receiver.host} receiver.host=${receiver.host}
receiver.port=${receiver.port} receiver.port=${receiver.port}
......
# Redis common settings
ddb.accesskey=${ddb.accesskey}
ddb.secretkey=${ddb.secretkey}
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