|
@@ -18,6 +18,7 @@ import org.springframework.stereotype.Component;
|
|
|
import tk.mybatis.mapper.entity.Condition;
|
|
import tk.mybatis.mapper.entity.Condition;
|
|
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
import javax.annotation.Resource;
|
|
|
|
|
+import java.util.Date;
|
|
|
import java.util.HashMap;
|
|
import java.util.HashMap;
|
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
import java.util.Map;
|
|
@@ -111,7 +112,6 @@ public class GeneralJob {
|
|
|
String ret = HttpRequest.post("https://chynet01.azureedge.net/user/checkin").cookie(cookie).timeout(-1).execute().body();
|
|
String ret = HttpRequest.post("https://chynet01.azureedge.net/user/checkin").cookie(cookie).timeout(-1).execute().body();
|
|
|
logger.error("[checkin]:" + ret);
|
|
logger.error("[checkin]:" + ret);
|
|
|
|
|
|
|
|
-
|
|
|
|
|
|
|
|
|
|
return ReturnT.SUCCESS;
|
|
return ReturnT.SUCCESS;
|
|
|
}
|
|
}
|
|
@@ -184,6 +184,76 @@ public class GeneralJob {
|
|
|
return ReturnT.SUCCESS;
|
|
return ReturnT.SUCCESS;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 定时创建分表任务
|
|
|
|
|
+ * 用于创建未来3个月的分表,确保分表在使用前已经创建好
|
|
|
|
|
+ */
|
|
|
|
|
+ @XxlJob("createFutureTables")
|
|
|
|
|
+ public ReturnT<String> createFutureTables(String param) throws Exception {
|
|
|
|
|
+ try {
|
|
|
|
|
+ logger.info("【创建未来分表任务】开始");
|
|
|
|
|
+
|
|
|
|
|
+ // 获取当前日期和未来3个月的日期
|
|
|
|
|
+ Date now = new Date();
|
|
|
|
|
+ Date nextMonth = DateUtil.offsetMonth(now, 1);
|
|
|
|
|
+ Date nextTwoMonths = DateUtil.offsetMonth(now, 2);
|
|
|
|
|
+ Date nextThreeMonths = DateUtil.offsetMonth(now, 3);
|
|
|
|
|
+
|
|
|
|
|
+ // 构造表名后缀
|
|
|
|
|
+ String currentMonthSuffix = DateUtil.format(now, "yyyyMM");
|
|
|
|
|
+ String nextMonthSuffix = DateUtil.format(nextMonth, "yyyyMM");
|
|
|
|
|
+ String nextTwoMonthsSuffix = DateUtil.format(nextTwoMonths, "yyyyMM");
|
|
|
|
|
+ String nextThreeMonthsSuffix = DateUtil.format(nextThreeMonths, "yyyyMM");
|
|
|
|
|
+
|
|
|
|
|
+ // 需要创建的表名列表
|
|
|
|
|
+ String[] tableSuffixes = {currentMonthSuffix, nextMonthSuffix, nextTwoMonthsSuffix, nextThreeMonthsSuffix};
|
|
|
|
|
+
|
|
|
|
|
+ // 表名前缀
|
|
|
|
|
+ String[] tablePrefixes = {"c_account_flow_", "c_flow_", "c_red_envelope_"};
|
|
|
|
|
+
|
|
|
|
|
+ // 数据源
|
|
|
|
|
+ String[] dataSources = {"ds0", "ds1"};
|
|
|
|
|
+
|
|
|
|
|
+ // 创建表的逻辑
|
|
|
|
|
+ for (String dataSource : dataSources) {
|
|
|
|
|
+ for (String tablePrefix : tablePrefixes) {
|
|
|
|
|
+ for (String tableSuffix : tableSuffixes) {
|
|
|
|
|
+ String tableName = tablePrefix + tableSuffix;
|
|
|
|
|
+ // 这里应该调用实际的建表方法
|
|
|
|
|
+ createTableIfNotExists(dataSource, tableName);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ logger.info("【创建未来分表任务】完成");
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ logger.error("【创建未来分表任务】异常:e{}", e);
|
|
|
|
|
+ return ReturnT.FAIL;
|
|
|
|
|
+ }
|
|
|
|
|
+ return ReturnT.SUCCESS;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 创建表(如果不存在)
|
|
|
|
|
+ * @param dataSource 数据源名称
|
|
|
|
|
+ * @param tableName 表名
|
|
|
|
|
+ */
|
|
|
|
|
+ private void createTableIfNotExists(String dataSource, String tableName) {
|
|
|
|
|
+ // 这里应该实现实际的建表逻辑
|
|
|
|
|
+ // 可以通过JDBC或者调用数据库管理服务来创建表
|
|
|
|
|
+ logger.info("检查并创建表: {} 在数据源: {}", tableName, dataSource);
|
|
|
|
|
+
|
|
|
|
|
+ // 示例建表SQL(根据实际表结构调整)
|
|
|
|
|
+ /*
|
|
|
|
|
+ CREATE TABLE IF NOT EXISTS table_name (
|
|
|
|
|
+ id BIGINT AUTO_INCREMENT PRIMARY KEY,
|
|
|
|
|
+ ...
|
|
|
|
|
+ )
|
|
|
|
|
+ */
|
|
|
|
|
+
|
|
|
|
|
+ // 实际实现应该连接到对应数据源执行建表语句
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
public static void main(String[] args) {
|
|
public static void main(String[] args) {
|
|
|
// int quhao = 154;
|
|
// int quhao = 154;
|
|
|
// int weihao = 9642;
|
|
// int weihao = 9642;
|
|
@@ -212,4 +282,4 @@ public class GeneralJob {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
-}
|
|
|
|
|
|
|
+}
|