feat(job): 集成Quartz任务调度并重构项目依赖配置
- 配置application.yml中的Quartz数据库存储相关设置 - 将MyBatis替换为MyBatis-Plus并调整相关配置 - 创建dc-common-parent父工程统一管理依赖版本 - 更新dc-job-service的pom.xml依赖配置并移除冗余依赖 - 修改JobServiceApplication.java作者信息 - 为Result.java添加序列化支持 - 添加Quartz数据库表结构SQL文件 - 调整dc-tranlog-service的artifactId和依赖配置
This commit is contained in:
@@ -13,7 +13,7 @@
|
||||
<relativePath>../dc-parent/pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<artifactId>dc-tranlog-server</artifactId>
|
||||
<artifactId>dc-tranlog-service</artifactId>
|
||||
<name>DC TranLog Server</name>
|
||||
<description>交易日志服务器 - 处理交易数据、MTC(分钟交易数据)、价格成交量等业务逻辑</description>
|
||||
|
||||
@@ -41,7 +41,7 @@
|
||||
<!-- Data Dao 基础包 -->
|
||||
<dependency>
|
||||
<groupId>com.afe.dc</groupId>
|
||||
<artifactId>dc-data-feign</artifactId>
|
||||
<artifactId>dc-common-dao</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
package com.afe.dc.tranlog;
|
||||
|
||||
import com.afe.dc.tranlog.service.TranDatabaseService;
|
||||
import com.baomidou.mybatisplus.annotation.DbType;
|
||||
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
|
||||
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.mybatis.spring.annotation.MapperScan;
|
||||
import org.springframework.boot.CommandLineRunner;
|
||||
@@ -14,6 +11,7 @@ import org.springframework.context.annotation.Bean;
|
||||
/**
|
||||
* TranLogServer 主应用类
|
||||
* 对应C++的main函数和CTranLogServer::Initialize
|
||||
* @author ben.yang
|
||||
*/
|
||||
@Slf4j
|
||||
@SpringBootApplication
|
||||
@@ -29,30 +27,20 @@ public class TranLogServiceApplication {
|
||||
* 应用启动后初始化
|
||||
* 对应C++的Initialize方法
|
||||
*/
|
||||
@Bean
|
||||
public CommandLineRunner init(TranDatabaseService tranDatabaseService) {
|
||||
@Bean(name = "tranLogInitializer")
|
||||
public CommandLineRunner tranLogInitializer(TranDatabaseService tranDatabaseService) {
|
||||
return args -> {
|
||||
log.info("[TranLogServerApplication] Initializing TranLogServer...");
|
||||
log.info("[TranLogServiceApplication] Initializing TranLogServer...");
|
||||
|
||||
// 初始化数据库
|
||||
if (tranDatabaseService.initialize()) {
|
||||
log.info("[TranLogServerApplication] TranDatabase initialized successfully");
|
||||
log.info("[TranLogServiceApplication] TranDatabase initialized successfully");
|
||||
} else {
|
||||
log.error("[TranLogServerApplication] Failed to initialize TranDatabase");
|
||||
log.error("[TranLogServiceApplication] Failed to initialize TranDatabase");
|
||||
System.exit(1);
|
||||
}
|
||||
|
||||
log.info("[TranLogServerApplication] TranLogServer started successfully");
|
||||
log.info("[TranLogServiceApplication] TranLogServer started successfully");
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* MyBatis-Plus 分页插件配置
|
||||
*/
|
||||
@Bean
|
||||
public MybatisPlusInterceptor mybatisPlusInterceptor() {
|
||||
MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
|
||||
interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL));
|
||||
return interceptor;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
package com.afe.dc.tranlog.controller.internal;
|
||||
|
||||
import com.afe.dc.common.core.result.Result;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
/**
|
||||
* 任务执行控制器
|
||||
* 供 dc-job-service 通过 Feign 调用执行任务
|
||||
*
|
||||
* @author stock-system
|
||||
*/
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("/internal/api/v1/job")
|
||||
@RequiredArgsConstructor
|
||||
public class JobController {
|
||||
|
||||
/**
|
||||
* 执行交易日志同步任务
|
||||
*
|
||||
* @param param 任务参数(JSON格式,可选)
|
||||
* @return 执行结果
|
||||
*/
|
||||
@PostMapping("/sync-tranlog")
|
||||
public Result<String> syncTranlog(@RequestParam(value = "param", required = false) String param) {
|
||||
log.info("开始执行交易日志同步任务,参数: {}", param);
|
||||
|
||||
try {
|
||||
// TODO: 实现交易日志同步逻辑
|
||||
// 例如:从外部系统同步交易日志数据
|
||||
|
||||
log.info("交易日志同步任务执行成功");
|
||||
return Result.success("交易日志同步任务执行成功");
|
||||
} catch (Exception e) {
|
||||
log.error("交易日志同步任务执行失败", e);
|
||||
return Result.fail("交易日志同步任务执行失败: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 执行交易日志归档任务
|
||||
*
|
||||
* @param param 任务参数(JSON格式,可选)
|
||||
* @return 执行结果
|
||||
*/
|
||||
@PostMapping("/archive")
|
||||
public Result<String> archiveTranlog(@RequestParam(value = "param", required = false) String param) {
|
||||
log.info("开始执行交易日志归档任务,参数: {}", param);
|
||||
|
||||
try {
|
||||
// TODO: 实现交易日志归档逻辑
|
||||
// 例如:将历史交易日志归档到文件系统或对象存储
|
||||
|
||||
log.info("交易日志归档任务执行成功");
|
||||
return Result.success("交易日志归档任务执行成功");
|
||||
} catch (Exception e) {
|
||||
log.error("交易日志归档任务执行失败", e);
|
||||
return Result.fail("交易日志归档任务执行失败: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user