main
黄海 6 months ago
parent ef38eebcf0
commit 13ba501fd4

@ -0,0 +1,30 @@
package com.dsideal.YunXiaoTools.Controller;
import com.dsideal.YunXiaoTools.Utils.ReadDataUtil;
import com.jfinal.aop.Before;
import com.jfinal.core.Controller;
import com.jfinal.ext.interceptor.GET;
import com.jfinal.kit.Kv;
import java.io.IOException;
public class YunXiaoController extends Controller {
public void index(){
renderText("Hello World!");
}
/**
* mysqlOBS
* @throws IOException
*/
// http://10.10.21.20:9008/readMysql
@Before({GET.class})
public void readMysql() throws IOException {
String url=ReadDataUtil.doAction();
Kv kv=Kv.create();
kv.set("success",true);
kv.set("message","获取并上传数据到OBS成功");
kv.set("url",url);
renderJson(kv);
}
}

@ -2,6 +2,7 @@ package com.dsideal.YunXiaoTools;
import cn.hutool.core.io.FileUtil;
import com.dsideal.YunXiaoTools.Controller.YunXiaoController;
import com.jfinal.config.*;
import com.jfinal.kit.PropKit;
import com.jfinal.plugin.activerecord.ActiveRecordPlugin;
@ -38,7 +39,7 @@ public class Start extends JFinalConfig {
*/
@Override
public void configRoute(Routes me) {
me.add("/", YunXiaoController.class);
}
@Override

@ -14,7 +14,7 @@ import java.util.zip.ZipOutputStream;
public class ReadDataUtil {
public static void doAction() throws IOException {
public static String doAction() throws IOException {
// 创建临时目录
Path tempDir = Files.createTempDirectory("csv_export_");
List<String> csvFiles = new ArrayList<>();
@ -55,10 +55,12 @@ public class ReadDataUtil {
}
// 上传到华为云OBS
ObsUtil.uploadToObs(zipPath,"HuangHai/YunXiao/"+ timestamp + ".zip");
String key="HuangHai/YunXiao/"+ timestamp + ".zip";
ObsUtil.uploadToObs(zipPath,key);
// 清理临时文件
csvFiles.forEach(csv -> FileUtil.del(csv));
FileUtil.del(zipPath);
FileUtil.del(tempDir.toString());
return "https://dsideal.obs.cn-north-1.myhuaweicloud.com/"+key;
}
}

@ -6,7 +6,7 @@ undertow.host=0.0.0.0
#undertow.resourcePath=D:/dsWork/QingLong/WebRoot,classpath:static
# 目录名称
undertow.contextPath=/YunXiaoTools
undertow.contextPath=/
# 设定I/O线程数.
server.undertow.io-threads=8

@ -12,8 +12,4 @@ cron4j=LingDianTask
LingDianTask.cron=0 0 * * *
LingDianTask.class=com.dsideal.YunXiaoTools.Cron4j.LingDianTask
LingDianTask.daemon=true
LingDianTask.enable=true
LingDianTask.enable=true

@ -6,7 +6,7 @@ undertow.host=0.0.0.0
#undertow.resourcePath=D:/dsWork/QingLong/WebRoot,classpath:static
# 目录名称
undertow.contextPath=/YunXiaoTools
undertow.contextPath=/
# 设定I/O线程数.
server.undertow.io-threads=8

Loading…
Cancel
Save