Commit 9ac64cbb by 陶光胜

报表中心

parent fea20abf
package com.gic.enterprise.service.outer.impl;
import com.alibaba.druid.sql.SQLUtils;
import com.alibaba.druid.sql.ast.SQLExpr;
import com.gic.api.base.commons.ServiceResponse;
import com.gic.commons.util.EntityUtil;
import com.gic.enterprise.constant.DownloadReportDataTypeEnum;
......@@ -90,9 +92,36 @@ public class HiveDataDownloadApiServiceImpl implements HiveDataDownloadApiServic
downloadTaskPOJO.setDesenField(hiveDataDownloadDTO.getDesenField());
downloadTaskPOJO.setExcelExtension(hiveDataDownloadDTO.getExcelExtension());
downloadTaskPOJO.setTableName(getTableName(hiveDataDownloadDTO.getSql()));
downloadTaskPOJO.setFileName(hiveDataDownloadDTO.getFileName());
downloadTaskPOJO.setExcelExtension(hiveDataDownloadDTO.getExcelExtension());
taskList.add(downloadTaskPOJO);
}
public static void main(String[] args){
Connection conn = HiveConnUtils.getConnection();
Statement stat = null;
try {
stat = conn.createStatement();
//stat.execute("REFRESH TABLE extract_order_information"); // 强制刷新表结构 防止数据出错
String s = SQLUtils.formatHive("SELECT order_id as '订单号' FROM extract_order_information");
stat.execute(s);
} catch (Exception e) {
log.warn("下载数据出现异常", e);
// 任务状态修改
} finally {
try {
if(stat != null) {
stat.close();
}
if(conn != null) {
conn.close();
}
} catch (SQLException e) {
log.warn("stat 关闭异常", e);
}
}
}
private void runDownloadTask(Integer interval) {
downloadService.scheduleAtFixedRate(new Runnable() {
......
......@@ -94,7 +94,7 @@ public class DownloadReportController {
dataDownloadDTO.setDataUrl("https://four.gicdev.com/member-tag/member-tag/tag-val-edit?id=264137629747888139&name=111111");
//dataDownloadDTO.setDesenField();
dataDownloadDTO.setExcelExtension(ExcelExtensionEnum.CSV.getCode());
dataDownloadDTO.setFileName("boom hive test");
dataDownloadDTO.setFileName("boomhivetest");
dataDownloadDTO.setSql("SELECT order_id AS `订单号` FROM extract_order_information;");
ServiceResponse<Integer> downloadTask = hiveDataDownloadApiService.createDownloadTask(dataDownloadDTO);
if(downloadTask.isSuccess()){
......
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