src/main/java/com/moral/mapper/HistoryMapper.java | ●●●●● patch | view | raw | blame | history | |
src/main/java/com/moral/service/HistoryService.java | ●●●●● patch | view | raw | blame | history | |
src/main/java/com/moral/service/impl/HistoryServiceImpl.java | ●●●●● patch | view | raw | blame | history | |
src/main/java/com/moral/task/HistoryTableCreatAndDeleteTask.java | ●●●●● patch | view | raw | blame | history | |
src/main/resources/mapper/HistoryMapper.xml | ●●●●● patch | view | raw | blame | history |
src/main/java/com/moral/mapper/HistoryMapper.java
@@ -35,4 +35,6 @@ void createHistoryTable(@Param("yearMonthDay") String yearMonthDay); void dropHistoryTable(@Param("yearMonthDay") String yearMonthDay); } src/main/java/com/moral/service/HistoryService.java
@@ -16,4 +16,6 @@ void deletePartition(String p); void createHistoryTable(String yearMonthDay); void dropHistoryTable(String yearMonthDay); } src/main/java/com/moral/service/impl/HistoryServiceImpl.java
@@ -41,4 +41,9 @@ public void createHistoryTable(String yearMonthDay) { historyMapper.createHistoryTable(yearMonthDay); } @Override public void dropHistoryTable(String yearMonthDay) { historyMapper.dropHistoryTable(yearMonthDay); } } src/main/java/com/moral/task/HistoryTableCreatAndDeleteTask.java
@@ -22,20 +22,28 @@ @XxlJob("deleteHitoryTable") public ReturnT deleteHistoryTable(String param) { return new ReturnT(200,"删除成功"); SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd"); String yearMonthDay = sdf.format(DateUtil.rollHour(new Date(), -8*24)); try { historyService.dropHistoryTable(yearMonthDay); } catch (Exception e) { logger.error(e.getMessage()); return new ReturnT(500, "history_" + yearMonthDay + "删除失败"); } return new ReturnT(200, "history_" + yearMonthDay + "删除成功"); } @XxlJob("createHistoryTable") public ReturnT createHistoryTable(String param) { SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd"); String yearMonthDay = sdf.format(DateUtil.rollHour(new Date(), 24)); try { SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd"); String yearMonthDay = sdf.format(DateUtil.rollHour(new Date(), 24)); historyService.createHistoryTable(yearMonthDay); }catch (Exception e){ } catch (Exception e) { logger.error(e.getMessage()); return new ReturnT(500,"history天表失败"); return new ReturnT(500, "history_" + yearMonthDay + "创建失败"); } return new ReturnT(200,"history天表创建成功"); return new ReturnT(200, "history_" + yearMonthDay + "创建成功"); } } src/main/resources/mapper/HistoryMapper.xml
@@ -259,4 +259,8 @@ KEY `_idx_time` (`time`) USING BTREE ) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC </update> <delete id="dropHistoryTable" parameterType="String"> drop table history_${yearMonthDay} </delete> </mapper>