fix: 修复新高新低查询异常

dev_refactor_0120_qoder
Lxy 4 months ago
parent 88c3e487b0
commit 726ca58325

@ -30,20 +30,10 @@ public class TStockHighLowStatus extends BaseEntity
@Excel(name = "近期创阶段新高", readConverterExp = "1=是,0=否")
private Integer isNewHigh;
/** 区间最高价日(创新高时填充) */
@JsonFormat(pattern = "yyyy-MM-dd")
@Excel(name = "区间最高价日", dateFormat = "yyyy-MM-dd")
private Date newHighDate;
/** 是否创阶段新低1=是0=否) */
@Excel(name = "近期创阶段新低", readConverterExp = "1=是,0=否")
private Integer isNewLow;
/** 区间最低价日(创新低时填充) */
@JsonFormat(pattern = "yyyy-MM-dd")
@Excel(name = "区间最低价日", dateFormat = "yyyy-MM-dd")
private Date newLowDate;
/** 证券名称(查询时关联获取) */
private String stockName;
@ -83,16 +73,6 @@ public class TStockHighLowStatus extends BaseEntity
this.isNewHigh = isNewHigh;
}
public Date getNewHighDate()
{
return newHighDate;
}
public void setNewHighDate(Date newHighDate)
{
this.newHighDate = newHighDate;
}
public Integer getIsNewLow()
{
return isNewLow;
@ -103,16 +83,6 @@ public class TStockHighLowStatus extends BaseEntity
this.isNewLow = isNewLow;
}
public Date getNewLowDate()
{
return newLowDate;
}
public void setNewLowDate(Date newLowDate)
{
this.newLowDate = newLowDate;
}
public String getStockName()
{
return stockName;
@ -150,9 +120,7 @@ public class TStockHighLowStatus extends BaseEntity
"stockCode='" + stockCode + '\'' +
", tradeDate=" + tradeDate +
", isNewHigh=" + isNewHigh +
", newHighDate=" + newHighDate +
", isNewLow=" + isNewLow +
", newLowDate=" + newLowDate +
'}';
}
}

@ -7,9 +7,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="stockCode" column="stock_code" />
<result property="tradeDate" column="trade_date" />
<result property="isNewHigh" column="is_new_high" />
<result property="newHighDate" column="new_high_date" />
<result property="isNewLow" column="is_new_low" />
<result property="newLowDate" column="new_low_date" />
<result property="createTime" column="create_time" />
</resultMap>
@ -20,13 +18,20 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</resultMap>
<sql id="selectStockHighLowStatusVo">
select stock_code, trade_date, is_new_high, new_high_date, is_new_low, new_low_date, create_time
select stock_code, trade_date, is_new_high, is_new_low, create_time
from t_stock_high_low_status
</sql>
<sql id="selectStockHighLowStatusWithBasicVo">
select h.stock_code, h.trade_date, h.is_new_high, h.new_high_date, h.is_new_low, h.new_low_date, h.create_time,
b.stock_name, b.industry_index_code, b.industry_index_name
select
h.stock_code,
h.trade_date,
h.is_new_high,
h.is_new_low,
h.create_time,
b.stock_name,
b.industry_index_code,
b.industry_index_name
from t_stock_high_low_status h
left join t_stock_basic b on h.stock_code = b.stock_code
</sql>
@ -126,18 +131,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="stockCode != null and stockCode != ''">stock_code,</if>
<if test="tradeDate != null">trade_date,</if>
<if test="isNewHigh != null">is_new_high,</if>
<if test="newHighDate != null">new_high_date,</if>
<if test="isNewLow != null">is_new_low,</if>
<if test="newLowDate != null">new_low_date,</if>
create_time,
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="stockCode != null and stockCode != ''">#{stockCode},</if>
<if test="tradeDate != null">#{tradeDate},</if>
<if test="isNewHigh != null">#{isNewHigh},</if>
<if test="newHighDate != null">#{newHighDate},</if>
<if test="isNewLow != null">#{isNewLow},</if>
<if test="newLowDate != null">#{newLowDate},</if>
NOW(),
</trim>
</insert>
@ -146,9 +147,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
update t_stock_high_low_status
<trim prefix="set" suffixOverrides=",">
<if test="isNewHigh != null">is_new_high = #{isNewHigh},</if>
<if test="newHighDate != null">new_high_date = #{newHighDate},</if>
<if test="isNewLow != null">is_new_low = #{isNewLow},</if>
<if test="newLowDate != null">new_low_date = #{newLowDate},</if>
</trim>
where stock_code = #{stockCode} and trade_date = #{tradeDate}
</update>
@ -158,23 +157,21 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</delete>
<insert id="batchInsertStockHighLowStatus" parameterType="java.util.List">
insert into t_stock_high_low_status(stock_code, trade_date, is_new_high, new_high_date, is_new_low, new_low_date, create_time)
insert into t_stock_high_low_status(stock_code, trade_date, is_new_high, is_new_low, create_time)
values
<foreach collection="list" item="item" separator=",">
(#{item.stockCode}, #{item.tradeDate}, #{item.isNewHigh}, #{item.newHighDate}, #{item.isNewLow}, #{item.newLowDate}, NOW())
(#{item.stockCode}, #{item.tradeDate}, #{item.isNewHigh}, #{item.isNewLow}, NOW())
</foreach>
</insert>
<insert id="batchUpsertStockHighLowStatus" parameterType="java.util.List">
insert into t_stock_high_low_status(stock_code, trade_date, is_new_high, new_high_date, is_new_low, new_low_date, create_time)
insert into t_stock_high_low_status(stock_code, trade_date, is_new_high, is_new_low, create_time)
values
<foreach collection="list" item="item" separator=",">
(#{item.stockCode}, #{item.tradeDate}, #{item.isNewHigh}, #{item.newHighDate}, #{item.isNewLow}, #{item.newLowDate}, NOW())
(#{item.stockCode}, #{item.tradeDate}, #{item.isNewHigh}, #{item.isNewLow}, NOW())
</foreach>
ON DUPLICATE KEY UPDATE
is_new_high = VALUES(is_new_high),
new_high_date = VALUES(new_high_date),
is_new_low = VALUES(is_new_low),
new_low_date = VALUES(new_low_date)
is_new_low = VALUES(is_new_low)
</insert>
</mapper>

@ -0,0 +1,9 @@
-- 移除个股新高新低状态表中的冗余日期字段
-- 根据业务需求新高新低的实际日期可以通过tradeDate和isNewHigh/isNewLow字段组合确定
ALTER TABLE `t_stock_high_low_status`
DROP COLUMN `new_high_date`,
DROP COLUMN `new_low_date`;
-- 更新表注释
ALTER TABLE `t_stock_high_low_status` COMMENT = 'A股个股300天新高新低状态new_high_date和new_low_date字段已移除实际日期由tradeDate和isNewHigh/isNewLow字段组合确定';

@ -3,9 +3,7 @@ CREATE TABLE `t_stock_high_low_status` (
`stock_code` VARCHAR(20) NOT NULL COMMENT '证券代码关联t_stock_basic',
`trade_date` DATE NOT NULL COMMENT '交易日期',
`is_new_high` TINYINT(1) NOT NULL DEFAULT 0 COMMENT '是否创阶段新高1=是0=否)',
`new_high_date` DATE NULL COMMENT '区间最高价日(创新高时填充)',
`is_new_low` TINYINT(1) NOT NULL DEFAULT 0 COMMENT '是否创阶段新低1=是0=否)',
`new_low_date` DATE NULL COMMENT '区间最低价日(创新低时填充)',
`create_time` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '数据创建时间',
-- 复合主键:确保“个股代码+日期”唯一
PRIMARY KEY (`stock_code`, `trade_date`),

Loading…
Cancel
Save