docs 补充项目注释

This commit is contained in:
AprilWind
2026-06-01 10:48:09 +08:00
parent f3ed8e82a7
commit 941c0b9032
73 changed files with 531 additions and 1 deletions
@@ -22,6 +22,13 @@ import java.math.BigDecimal;
@JobExecutor(name = "alipayBillTask")
public class AlipayBillTask {
/**
* 执行支付宝账单模拟任务,并将结果写入工作流上下文。
*
* @param jobArgs 任务执行参数
* @return 执行结果
* @throws InterruptedException 任务被中断时抛出
*/
public ExecuteResult jobExecute(JobArgs jobArgs) throws InterruptedException {
// 设置清算日期
String settlementDate = (String) jobArgs.getWfContext().get("settlementDate");
@@ -21,6 +21,13 @@ import java.math.BigDecimal;
@JobExecutor(name = "summaryBillTask")
public class SummaryBillTask {
/**
* 汇总工作流上下文中的微信与支付宝账单金额。
*
* @param jobArgs 任务执行参数
* @return 汇总执行结果
* @throws InterruptedException 任务被中断时抛出
*/
public ExecuteResult jobExecute(JobArgs jobArgs) throws InterruptedException {
// 获得微信账单
BigDecimal wechatAmount = BigDecimal.valueOf(0);
@@ -23,6 +23,12 @@ public class TestBroadcastJob {
@Value("${snail-job.port}")
private int clientPort;
/**
* 执行广播任务示例,随机模拟成功或失败。
*
* @param jobArgs 任务执行参数
* @return 执行结果
*/
public ExecuteResult jobExecute(JobArgs jobArgs) {
int randomInt = RandomUtil.randomInt(100);
log.info("随机数: {}", randomInt);
@@ -26,6 +26,13 @@ import java.util.stream.IntStream;
@JobExecutor(name = "testMapJobAnnotation")
public class TestMapJobAnnotation {
/**
* 根 Map 任务,将示例数据拆分为多个分片任务。
*
* @param mapArgs Map 任务参数
* @param mapHandler 分片调度处理器
* @return 分片调度结果
*/
@MapExecutor
public ExecuteResult doJobMapExecute(MapArgs mapArgs, MapHandler mapHandler) {
// 生成1~200数值并分片
@@ -39,6 +46,12 @@ public class TestMapJobAnnotation {
return mapHandler.doMap(partition, "doCalc");
}
/**
* 执行单个分片的累加计算。
*
* @param mapArgs 分片任务参数
* @return 分片计算结果
*/
@MapExecutor(taskName = "doCalc")
public ExecuteResult doCalc(MapArgs mapArgs) {
List<Integer> sourceList = (List<Integer>) mapArgs.getMapResult();
@@ -28,6 +28,13 @@ import java.util.stream.IntStream;
@JobExecutor(name = "testMapReduceAnnotation1")
public class TestMapReduceAnnotation1 {
/**
* 根 Map 任务,将示例数据拆分为多个分片任务。
*
* @param mapArgs Map 任务参数
* @param mapHandler 分片调度处理器
* @return 分片调度结果
*/
@MapExecutor
public ExecuteResult rootMapExecute(MapArgs mapArgs, MapHandler mapHandler) {
int partitionSize = 50;
@@ -40,6 +47,12 @@ public class TestMapReduceAnnotation1 {
return mapHandler.doMap(partition, "doCalc");
}
/**
* 执行单个分片的累加计算。
*
* @param mapArgs 分片任务参数
* @return 分片计算结果
*/
@MapExecutor(taskName = "doCalc")
public ExecuteResult doCalc(MapArgs mapArgs) {
List<Integer> sourceList = (List<Integer>) mapArgs.getMapResult();
@@ -51,6 +64,12 @@ public class TestMapReduceAnnotation1 {
return ExecuteResult.success(partitionTotal);
}
/**
* 汇总所有 Map 分片的计算结果。
*
* @param reduceArgs Reduce 任务参数
* @return 汇总结果
*/
@ReduceExecutor
public ExecuteResult reduceExecute(ReduceArgs reduceArgs) {
int reduceTotal = reduceArgs.getMapResult().stream().mapToInt(i -> Integer.parseInt((String) i)).sum();
@@ -17,6 +17,12 @@ import org.springframework.stereotype.Component;
@JobExecutor(name = "testStaticShardingJob")
public class TestStaticShardingJob {
/**
* 执行静态分片任务示例。
*
* @param jobArgs 任务执行参数
* @return 执行结果
*/
public ExecuteResult jobExecute(JobArgs jobArgs) {
String jobParams = Convert.toStr(jobArgs.getJobParams());
SnailJobLog.LOCAL.info("开始执行分片任务,参数:{}", jobParams);
@@ -22,6 +22,13 @@ import java.math.BigDecimal;
@JobExecutor(name = "wechatBillTask")
public class WechatBillTask {
/**
* 执行微信账单模拟任务,并将结果写入工作流上下文。
*
* @param jobArgs 任务执行参数
* @return 执行结果
* @throws InterruptedException 任务被中断时抛出
*/
public ExecuteResult jobExecute(JobArgs jobArgs) throws InterruptedException {
// 从上下文中获得清算日期并设置,如果上下文中清算日期
// 是sysdate设置为当前日期;否则取管理页面设置的值