Browse Source

add history task record

pull/2/head
baoliang 6 years ago
parent
commit
d62091f9de
  1. 7
      escheduler-api/src/main/java/cn/escheduler/api/service/TaskRecordService.java
  2. 9
      escheduler-common/src/main/java/cn/escheduler/common/Constants.java
  3. 10
      escheduler-dao/src/main/java/cn/escheduler/dao/TaskRecordDao.java

7
escheduler-api/src/main/java/cn/escheduler/api/service/TaskRecordService.java

@ -29,6 +29,8 @@ import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import static cn.escheduler.common.Constants.*;
/** /**
* task record service * task record service
*/ */
@ -69,8 +71,9 @@ public class TaskRecordService extends BaseService{
map.put("offset", pageInfo.getStart().toString()); map.put("offset", pageInfo.getStart().toString());
map.put("pageSize", pageInfo.getPageSize().toString()); map.put("pageSize", pageInfo.getPageSize().toString());
int count = TaskRecordDao.countTaskRecord(map); String table =TASK_RECORD_TABLE_HIVE_LOG;
List<TaskRecord> recordList = TaskRecordDao.queryAllTaskRecord(map); int count = TaskRecordDao.countTaskRecord(map, table);
List<TaskRecord> recordList = TaskRecordDao.queryAllTaskRecord(map, table);
pageInfo.setTotalCount(count); pageInfo.setTotalCount(count);
pageInfo.setLists(recordList); pageInfo.setLists(recordList);
result.put(Constants.DATA_LIST, pageInfo); result.put(Constants.DATA_LIST, pageInfo);

9
escheduler-common/src/main/java/cn/escheduler/common/Constants.java

@ -463,6 +463,10 @@ public final class Constants {
public static final String TASK_RECORD_PWD = "task.record.datasource.password"; public static final String TASK_RECORD_PWD = "task.record.datasource.password";
public static String TASK_RECORD_TABLE_HIVE_LOG = "eamp_hive_log_hd";
public static String TASK_RECORD_TABLE_HISTORY_HIVE_LOG = "eamp_hive_hist_log_hd";
public static final String STATUS = "status"; public static final String STATUS = "status";
@ -826,4 +830,9 @@ public final class Constants {
public static final String CONTENT = "content"; public static final String CONTENT = "content";
public static final String DEPENDENT_SPLIT = ":||"; public static final String DEPENDENT_SPLIT = ":||";
public static final String DEPENDENT_ALL = "ALL"; public static final String DEPENDENT_ALL = "ALL";
/**
*
*/
} }

10
escheduler-dao/src/main/java/cn/escheduler/dao/TaskRecordDao.java

@ -40,6 +40,8 @@ public class TaskRecordDao {
private static Logger logger = LoggerFactory.getLogger(TaskRecordDao.class.getName()); private static Logger logger = LoggerFactory.getLogger(TaskRecordDao.class.getName());
/** /**
* 加载配置文件 * 加载配置文件
*/ */
@ -134,7 +136,7 @@ public class TaskRecordDao {
* @param filterMap * @param filterMap
* @return * @return
*/ */
public static int countTaskRecord(Map<String, String> filterMap){ public static int countTaskRecord(Map<String, String> filterMap, String table){
int count = 0; int count = 0;
Connection conn = null; Connection conn = null;
@ -143,7 +145,7 @@ public class TaskRecordDao {
if(conn == null){ if(conn == null){
return count; return count;
} }
String sql = "select count(1) as count from eamp_hive_log_hd"; String sql = String.format("select count(1) as count from %s", table);
sql += getWhereString(filterMap); sql += getWhereString(filterMap);
PreparedStatement pstmt; PreparedStatement pstmt;
pstmt = conn.prepareStatement(sql); pstmt = conn.prepareStatement(sql);
@ -171,9 +173,9 @@ public class TaskRecordDao {
* @param filterMap * @param filterMap
* @return * @return
*/ */
public static List<TaskRecord> queryAllTaskRecord(Map<String,String> filterMap ) { public static List<TaskRecord> queryAllTaskRecord(Map<String,String> filterMap , String table) {
String sql = "select * from eamp_hive_log_hd "; String sql = String.format("select * from %s", table);
sql += getWhereString(filterMap); sql += getWhereString(filterMap);
int offset = Integer.parseInt(filterMap.get("offset")); int offset = Integer.parseInt(filterMap.get("offset"));

Loading…
Cancel
Save