|
|
@@ -25,8 +25,8 @@ public interface StockPoolMapper extends BaseMapper<StockPool> {
|
|
|
|
|
|
/**
|
|
|
* 分页查询历史数据
|
|
|
- * 超短池:status=1 或 (status=2 且 add_date < 今天)
|
|
|
- * 强势池:status IN (1, 2)
|
|
|
+ * 超短池:从 stock_pool 表查询 next_day_gain(隔日涨幅)
|
|
|
+ * 强势池:关联 stock_pool_history 表查询 high_trend(未来10天最高涨幅)
|
|
|
* @param startDate 开始日期
|
|
|
* @param endDate 结束日期
|
|
|
* @param poolType 池类型
|
|
|
@@ -34,16 +34,43 @@ public interface StockPoolMapper extends BaseMapper<StockPool> {
|
|
|
* @param limit 限制数量
|
|
|
* @return 历史数据列表
|
|
|
*/
|
|
|
- @Select("SELECT stock_code, stock_name, add_date as recordDate, add_price, close_price as closePrice, " +
|
|
|
- "next_day_high as nextDayHighPrice, next_day_gain as nextDayHighTrend, status " +
|
|
|
- "FROM stock_pool " +
|
|
|
- "WHERE add_date BETWEEN #{startDate} AND #{endDate} " +
|
|
|
- "AND pool_type = #{poolType} " +
|
|
|
- "AND ((#{poolType} = 1 AND (status = 1 OR (status = 2 AND add_date < CURDATE()))) OR (#{poolType} = 2 AND status IN (1, 2))) " +
|
|
|
- "ORDER BY add_date DESC, id DESC " +
|
|
|
- "LIMIT #{limit} OFFSET #{offset}")
|
|
|
+ @Select("<script>" +
|
|
|
+ "SELECT " +
|
|
|
+ " sp.stock_code, " +
|
|
|
+ " sp.stock_name, " +
|
|
|
+ " sp.add_date as recordDate, " +
|
|
|
+ " sp.add_price, " +
|
|
|
+ " sp.close_price as closePrice, " +
|
|
|
+ " <choose>" +
|
|
|
+ " <when test='poolType == 1'>" +
|
|
|
+ " sp.next_day_high as nextDayHighPrice, " +
|
|
|
+ " sp.next_day_gain as nextDayHighTrend, " +
|
|
|
+ " </when>" +
|
|
|
+ " <otherwise>" +
|
|
|
+ " NULL as nextDayHighPrice, " +
|
|
|
+ " COALESCE(sph.high_trend, 0) as nextDayHighTrend, " +
|
|
|
+ " </otherwise>" +
|
|
|
+ " </choose>" +
|
|
|
+ " sp.status " +
|
|
|
+ "FROM stock_pool sp " +
|
|
|
+ "<if test='poolType == 2'>" +
|
|
|
+ " LEFT JOIN stock_pool_history sph " +
|
|
|
+ " ON sp.stock_code = sph.stock_code " +
|
|
|
+ " AND sp.add_date = sph.record_date " +
|
|
|
+ "</if>" +
|
|
|
+ "WHERE sp.add_date BETWEEN #{startDate} AND #{endDate} " +
|
|
|
+ " AND sp.pool_type = #{poolType} " +
|
|
|
+ " AND ((#{poolType} = 1 AND (sp.status = 1 OR (sp.status = 2 AND sp.add_date < CURDATE()))) " +
|
|
|
+ " OR (#{poolType} = 2 AND sp.status IN (1, 2))) " +
|
|
|
+ "ORDER BY sp.add_date DESC, sp.id DESC " +
|
|
|
+ "LIMIT #{limit} OFFSET #{offset}" +
|
|
|
+ "</script>")
|
|
|
List<com.yingpai.gupiao.domain.vo.StockHistoryVO> selectPoolHistory(
|
|
|
- LocalDate startDate, LocalDate endDate, Integer poolType, int offset, int limit);
|
|
|
+ @org.apache.ibatis.annotations.Param("startDate") LocalDate startDate,
|
|
|
+ @org.apache.ibatis.annotations.Param("endDate") LocalDate endDate,
|
|
|
+ @org.apache.ibatis.annotations.Param("poolType") Integer poolType,
|
|
|
+ @org.apache.ibatis.annotations.Param("offset") int offset,
|
|
|
+ @org.apache.ibatis.annotations.Param("limit") int limit);
|
|
|
|
|
|
/**
|
|
|
* 统计历史数据总数
|