From 15ce40adc82f9277dc60ed29dad710013e99eca9 Mon Sep 17 00:00:00 2001 From: lizijie <lzjiiie@163.com> Date: Tue, 24 Nov 2020 17:49:56 +0800 Subject: [PATCH] 时间戳截取工具类 --- src/main/java/com/moral/task/HistoryTableCreatAndDeleteTask.java | 20 ++++++++++++++------ 1 files changed, 14 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/moral/task/HistoryTableCreatAndDeleteTask.java b/src/main/java/com/moral/task/HistoryTableCreatAndDeleteTask.java index 99f4a4d..9baa08a 100644 --- a/src/main/java/com/moral/task/HistoryTableCreatAndDeleteTask.java +++ b/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 + "������������"); } } -- Gitblit v1.8.0