You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
73 lines
3.0 KiB
73 lines
3.0 KiB
2 years ago
|
package com.fr.plugin.edo;
|
||
|
|
||
|
import com.fr.plugin.edo.controller.EdoController;
|
||
|
import com.fr.plugin.edo.tabDataSource.model.SearchResult;
|
||
|
import com.fr.plugin.edo.util.HttpUtil;
|
||
|
import com.fr.intelli.record.Focus;
|
||
|
import com.fr.intelli.record.Original;
|
||
|
import com.fr.json.JSONObject;
|
||
|
import com.fr.log.FineLoggerFactory;
|
||
|
import com.fr.plugin.context.PluginContext;
|
||
|
import com.fr.plugin.edo.submit.EDOFileUtils;
|
||
|
import com.fr.plugin.observer.inner.AbstractPluginLifecycleMonitor;
|
||
|
import com.fr.plugin.transform.FunctionRecorder;
|
||
|
import com.fr.record.analyzer.EnableMetrics;
|
||
|
import com.fr.stable.StringUtils;
|
||
|
import com.fr.third.alibaba.druid.support.json.JSONUtils;
|
||
|
import com.fr.workspace.WorkContext;
|
||
|
|
||
|
import java.io.File;
|
||
|
import java.util.*;
|
||
|
|
||
|
@EnableMetrics
|
||
|
@FunctionRecorder
|
||
|
public class HyEdoPluginLifecycleMonitor extends AbstractPluginLifecycleMonitor {
|
||
|
@Override
|
||
|
@Focus(id = "com.fr.plugin.edo.file.manager", text = "filemanager", source = Original.PLUGIN)
|
||
|
public void afterRun(PluginContext pluginContext) {
|
||
|
FineLoggerFactory.getLogger().info("插件启动:");
|
||
|
String envPath = WorkContext.getCurrent().getPath();
|
||
|
FineLoggerFactory.getLogger().info("envPath:"+envPath);
|
||
|
String webReport = (new File(envPath)).getParent();
|
||
|
File downfiles = new File(webReport+File.separator+"downfiles");
|
||
|
if(!downfiles.exists()){
|
||
|
downfiles.mkdir();
|
||
|
}
|
||
|
EdoController.downFileDir = downfiles;
|
||
|
FineLoggerFactory.getLogger().info("downfiles:"+downfiles.getPath());
|
||
|
FineLoggerFactory.getLogger().info("hongyi start...............");
|
||
|
|
||
|
Calendar startDate = Calendar.getInstance();
|
||
|
//定时每天23点半执行一次
|
||
|
startDate.set(startDate.get(Calendar.YEAR), startDate.get(Calendar.MONTH), startDate.get(Calendar.DATE), 23, 30, 0);
|
||
|
// 1小时的毫秒设定
|
||
|
long timeInterval = 24* 60 * 60 * 1000;
|
||
|
Timer t = new Timer();
|
||
|
t.schedule(new TimerTask() {
|
||
|
public void run() {
|
||
|
// 定时器主要执行的代码块
|
||
|
FineLoggerFactory.getLogger().info("定时器主要执行的代码! 删除下载文件");
|
||
|
try {
|
||
|
File files[] = downfiles.listFiles();
|
||
|
for (File file : files) {
|
||
|
FineLoggerFactory.getLogger().info(" 删除下载文件:"+file.getAbsolutePath());
|
||
|
file.delete();
|
||
|
}
|
||
|
FineLoggerFactory.getLogger().info(" 删除下载文件成功");
|
||
|
} catch (Exception e) {
|
||
|
e.printStackTrace();
|
||
|
FineLoggerFactory.getLogger().error(e.toString());
|
||
|
}
|
||
|
}
|
||
|
// 设定的定时器在23:30分开始执行,每隔 24小时执行一次.
|
||
|
}, startDate.getTime(), timeInterval ); //timeInterval 是一天的毫秒数,也是执行间隔
|
||
|
|
||
|
|
||
|
}
|
||
|
|
||
|
@Override
|
||
|
public void beforeStop(PluginContext pluginContext) {
|
||
|
FineLoggerFactory.getLogger().info("插件停止");
|
||
|
}
|
||
|
}
|