Files
emo-grab/src/main/java/quant/rich/emoney/entity/sqlite/Plan.java
Doghole b0093ccccb 增加 StockStrategy 服务,数据表建立及批量更新方法重写。解决多数据源配置 mapper-locations
无法识别并读取到对应数据源的 mapper.xml 及其 statement 方法的问题
2026-01-10 14:26:04 +08:00

111 lines
2.7 KiB
Java
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
package quant.rich.emoney.entity.sqlite;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import org.apache.commons.lang3.StringUtils;
import org.springframework.util.CollectionUtils;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.databind.JsonNode;
import lombok.Data;
import lombok.experimental.Accessors;
import quant.rich.emoney.mybatis.typehandler.CommaListTypeHandler;
import quant.rich.emoney.mybatis.typehandler.JsonStringTypeHandler;
/**
* 目前能想到的计划任务有三种
* <ul>
* <li>指标的抓取
* <li>个股策略(/strategy, id=9400)的抓取
* <li>选股策略的抓取
* </ul>
* 未来可能存在更多的计划任务, 所以需要考虑如何设计才能更好地兼容后续添加的任务类型
*/
@Data
@Accessors(chain = true)
@TableName(value = "plan", autoResultMap = true)
public class Plan {
/**
* 键 ID
*/
@TableId(type = IdType.AUTO)
private String planId;
/**
* 计划任务表达式
*/
private String cronExpr;
/**
* 计划名称
*/
private String planName;
/**
* 指标代码
*/
private String indexCode;
/**
* 需要抓取的指标周期
*/
@TableField(typeHandler = CommaListTypeHandler.class)
private List<String> periods;
/**
* 参数
*/
@TableField(typeHandler = JsonStringTypeHandler.class)
private JsonNode params;
/**
* 是否启用
*/
private Boolean enabled;
/**
* 交易日检查,若为 true则任务执行时判断当日是否为交易日若是则不执行任务
* 反之无论是否为交易日都执行
*/
private Boolean openDayCheck;
/**
* 设置抓取周期并去重
* @param periods
* @return
*/
public Plan setPeriods(List<String> periods) {
if (CollectionUtils.isEmpty(periods)) {
this.periods = Collections.emptyList();
return this;
}
Set<String> hashSet = new HashSet<>();
periods.forEach(s -> {
if (StringUtils.isNotBlank(s)) {
hashSet.add(s.trim());
}
});
this.periods = new ArrayList<>(hashSet);
return this;
}
/**
* 获取抓取周期。已去重
* @return
*/
public List<String> getPeriods() {
setPeriods(periods);
return periods;
}
}