fix:初步修复完善行业数据导入

dev_refactor_0120_qoder
Lxy 4 months ago
parent df537dbac9
commit 895796b48c

@ -19,11 +19,11 @@ public class TIndustryIndex extends BaseEntity
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
/** 行业指数代码如802089.EI */ /** 行业指数代码如802089.EI */
@Excel(name = "行业指数代码") @Excel(name = "证券代码")
private String industryIndexCode; private String industryIndexCode;
/** 行业指数名称(如"银行" */ /** 行业指数名称(如"银行" */
@Excel(name = "行业指数名称") @Excel(name = "证券名称")
private String industryIndexName; private String industryIndexName;
/** 成份个数(行业包含个股数量) */ /** 成份个数(行业包含个股数量) */
@ -71,6 +71,58 @@ public class TIndustryIndex extends BaseEntity
@Excel(name = "市盈率PE(TTM)中位值") @Excel(name = "市盈率PE(TTM)中位值")
private BigDecimal peTtmMedian; private BigDecimal peTtmMedian;
/** 最高价(指数点位) */
@Excel(name = "最高价")
private BigDecimal highPrice;
/** 最低价(指数点位) */
@Excel(name = "最低价")
private BigDecimal lowPrice;
/** 振幅(百分比) */
@Excel(name = "振幅")
private BigDecimal amplitude;
/** 换手率(百分比) */
@Excel(name = "换手率")
private BigDecimal turnoverRate;
/** 等权重平均涨跌幅(百分比) */
@Excel(name = "等权平均涨跌幅")
private BigDecimal equalWeightAvgChangeRate;
/** 成份股上涨家数 */
@Excel(name = "上涨家数")
private Integer upCount;
/** 成份股下跌家数 */
@Excel(name = "下跌家数")
private Integer downCount;
/** 成份股涨停家数 */
@Excel(name = "涨停家数")
private Integer limitUpCount;
/** 成份股跌停家数 */
@Excel(name = "跌停家数")
private Integer limitDownCount;
/** 成份股平盘家数 */
@Excel(name = "平盘家数")
private Integer noChangeCount;
/** 成份股停牌家数 */
@Excel(name = "停牌家数")
private Integer suspendCount;
/** 近期创历史新高 */
@Excel(name = "创历史新高", readConverterExp = "1=是,0=否")
private Integer newHighFlag;
/** 近期创历史新低 */
@Excel(name = "创历史新低", readConverterExp = "1=是,0=否")
private Integer newLowFlag;
public String getIndustryIndexCode() public String getIndustryIndexCode()
{ {
return industryIndexCode; return industryIndexCode;
@ -201,6 +253,136 @@ public class TIndustryIndex extends BaseEntity
this.peTtmMedian = peTtmMedian; this.peTtmMedian = peTtmMedian;
} }
public BigDecimal getHighPrice()
{
return highPrice;
}
public void setHighPrice(BigDecimal highPrice)
{
this.highPrice = highPrice;
}
public BigDecimal getLowPrice()
{
return lowPrice;
}
public void setLowPrice(BigDecimal lowPrice)
{
this.lowPrice = lowPrice;
}
public BigDecimal getAmplitude()
{
return amplitude;
}
public void setAmplitude(BigDecimal amplitude)
{
this.amplitude = amplitude;
}
public BigDecimal getTurnoverRate()
{
return turnoverRate;
}
public void setTurnoverRate(BigDecimal turnoverRate)
{
this.turnoverRate = turnoverRate;
}
public BigDecimal getEqualWeightAvgChangeRate()
{
return equalWeightAvgChangeRate;
}
public void setEqualWeightAvgChangeRate(BigDecimal equalWeightAvgChangeRate)
{
this.equalWeightAvgChangeRate = equalWeightAvgChangeRate;
}
public Integer getUpCount()
{
return upCount;
}
public void setUpCount(Integer upCount)
{
this.upCount = upCount;
}
public Integer getDownCount()
{
return downCount;
}
public void setDownCount(Integer downCount)
{
this.downCount = downCount;
}
public Integer getLimitUpCount()
{
return limitUpCount;
}
public void setLimitUpCount(Integer limitUpCount)
{
this.limitUpCount = limitUpCount;
}
public Integer getLimitDownCount()
{
return limitDownCount;
}
public void setLimitDownCount(Integer limitDownCount)
{
this.limitDownCount = limitDownCount;
}
public Integer getNoChangeCount()
{
return noChangeCount;
}
public void setNoChangeCount(Integer noChangeCount)
{
this.noChangeCount = noChangeCount;
}
public Integer getSuspendCount()
{
return suspendCount;
}
public void setSuspendCount(Integer suspendCount)
{
this.suspendCount = suspendCount;
}
public Integer getNewHighFlag()
{
return newHighFlag;
}
public void setNewHighFlag(Integer newHighFlag)
{
this.newHighFlag = newHighFlag;
}
public Integer getNewLowFlag()
{
return newLowFlag;
}
public void setNewLowFlag(Integer newLowFlag)
{
this.newLowFlag = newLowFlag;
}
@Override @Override
public String toString() public String toString()
{ {

@ -64,6 +64,44 @@ public class IndustryIndexServiceImpl implements IIndustryIndexService
@Override @Override
public int importIndustryIndex(List<TIndustryIndex> industryIndexList, Date tradeDate) public int importIndustryIndex(List<TIndustryIndex> industryIndexList, Date tradeDate)
{ {
// 为每个行业指数数据设置交易日期
for (TIndustryIndex industryIndex : industryIndexList)
{
industryIndex.setTradeDate(tradeDate);
// 检查并创建或更新行业基础数据
String industryCode = industryIndex.getIndustryIndexCode();
String industryName = industryIndex.getIndustryIndexName();
// 查询行业基础数据是否存在
com.ruoyi.newstocksystem.domain.TIndustryBasic existingIndustryBasic =
industryBasicService.selectTIndustryBasicByCode(industryCode);
if (existingIndustryBasic == null)
{
// 如果行业基础数据不存在,则创建
com.ruoyi.newstocksystem.domain.TIndustryBasic industryBasic = new com.ruoyi.newstocksystem.domain.TIndustryBasic();
industryBasic.setIndustryCode(industryCode);
industryBasic.setIndustryName(industryName);
industryBasic.setIndustryLevel(2); // 默认为二级行业
industryBasic.setStatus(1); // 默认启用
industryBasic.setSortOrder(0); // 默认排序
industryBasicService.insertTIndustryBasic(industryBasic);
}
else
{
// 如果行业基础数据存在,检查名称是否发生变化
if (!existingIndustryBasic.getIndustryName().equals(industryName))
{
// 名称发生变化,更新行业基础数据
existingIndustryBasic.setIndustryName(industryName);
industryBasicService.updateTIndustryBasic(existingIndustryBasic);
}
}
}
// 批量插入或更新行业指数数据
return industryIndexMapper.batchUpsertIndustryIndex(industryIndexList); return industryIndexMapper.batchUpsertIndustryIndex(industryIndexList);
} }

@ -10,22 +10,37 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="tradeDate" column="trade_date" /> <result property="tradeDate" column="trade_date" />
<result property="openPrice" column="open_price" /> <result property="openPrice" column="open_price" />
<result property="closePrice" column="close_price" /> <result property="closePrice" column="close_price" />
<result property="highPrice" column="high_price" />
<result property="lowPrice" column="low_price" />
<result property="volume" column="volume" /> <result property="volume" column="volume" />
<result property="turnover" column="turnover" /> <result property="turnover" column="turnover" />
<result property="totalMarketCap" column="total_market_cap" /> <result property="totalMarketCap" column="total_market_cap" />
<result property="freeCirculationCap" column="free_circulation_cap" /> <result property="freeCirculationCap" column="free_circulation_cap" />
<result property="priceChangeRate" column="price_change_rate" /> <result property="priceChangeRate" column="price_change_rate" />
<result property="amplitude" column="amplitude" />
<result property="turnoverRate" column="turnover_rate" />
<result property="equalWeightAvgChangeRate" column="equal_weight_avg_change_rate" />
<result property="peTtm" column="pe_ttm" /> <result property="peTtm" column="pe_ttm" />
<result property="peTtmMedian" column="pe_ttm_median" /> <result property="peTtmMedian" column="pe_ttm_median" />
<result property="upCount" column="up_count" />
<result property="downCount" column="down_count" />
<result property="limitUpCount" column="limit_up_count" />
<result property="limitDownCount" column="limit_down_count" />
<result property="noChangeCount" column="no_change_count" />
<result property="suspendCount" column="suspend_count" />
<result property="newHighFlag" column="new_high_flag" />
<result property="newLowFlag" column="new_low_flag" />
<result property="createTime" column="create_time" /> <result property="createTime" column="create_time" />
<result property="updateTime" column="update_time" /> <result property="updateTime" column="update_time" />
</resultMap> </resultMap>
<sql id="selectIndustryIndexVo"> <sql id="selectIndustryIndexVo">
select industry_index_code, industry_index_name, component_count, trade_date, select industry_index_code, industry_index_name, component_count, trade_date,
open_price, close_price, volume, turnover, total_market_cap, open_price, close_price, high_price, low_price, volume, turnover,
free_circulation_cap, price_change_rate, pe_ttm, pe_ttm_median, total_market_cap, free_circulation_cap, price_change_rate, amplitude,
create_time, update_time turnover_rate, equal_weight_avg_change_rate, pe_ttm, pe_ttm_median,
up_count, down_count, limit_up_count, limit_down_count, no_change_count,
suspend_count, new_high_flag, new_low_flag, create_time, update_time
from t_industry_index from t_industry_index
</sql> </sql>
@ -77,13 +92,26 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="tradeDate != null">trade_date,</if> <if test="tradeDate != null">trade_date,</if>
<if test="openPrice != null">open_price,</if> <if test="openPrice != null">open_price,</if>
<if test="closePrice != null">close_price,</if> <if test="closePrice != null">close_price,</if>
<if test="highPrice != null">high_price,</if>
<if test="lowPrice != null">low_price,</if>
<if test="volume != null">volume,</if> <if test="volume != null">volume,</if>
<if test="turnover != null">turnover,</if> <if test="turnover != null">turnover,</if>
<if test="totalMarketCap != null">total_market_cap,</if> <if test="totalMarketCap != null">total_market_cap,</if>
<if test="freeCirculationCap != null">free_circulation_cap,</if> <if test="freeCirculationCap != null">free_circulation_cap,</if>
<if test="priceChangeRate != null">price_change_rate,</if> <if test="priceChangeRate != null">price_change_rate,</if>
<if test="amplitude != null">amplitude,</if>
<if test="turnoverRate != null">turnover_rate,</if>
<if test="equalWeightAvgChangeRate != null">equal_weight_avg_change_rate,</if>
<if test="peTtm != null">pe_ttm,</if> <if test="peTtm != null">pe_ttm,</if>
<if test="peTtmMedian != null">pe_ttm_median,</if> <if test="peTtmMedian != null">pe_ttm_median,</if>
<if test="upCount != null">up_count,</if>
<if test="downCount != null">down_count,</if>
<if test="limitUpCount != null">limit_up_count,</if>
<if test="limitDownCount != null">limit_down_count,</if>
<if test="noChangeCount != null">no_change_count,</if>
<if test="suspendCount != null">suspend_count,</if>
<if test="newHighFlag != null">new_high_flag,</if>
<if test="newLowFlag != null">new_low_flag,</if>
create_time, create_time,
</trim> </trim>
<trim prefix="values (" suffix=")" suffixOverrides=","> <trim prefix="values (" suffix=")" suffixOverrides=",">
@ -93,13 +121,26 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="tradeDate != null">#{tradeDate},</if> <if test="tradeDate != null">#{tradeDate},</if>
<if test="openPrice != null">#{openPrice},</if> <if test="openPrice != null">#{openPrice},</if>
<if test="closePrice != null">#{closePrice},</if> <if test="closePrice != null">#{closePrice},</if>
<if test="highPrice != null">#{highPrice},</if>
<if test="lowPrice != null">#{lowPrice},</if>
<if test="volume != null">#{volume},</if> <if test="volume != null">#{volume},</if>
<if test="turnover != null">#{turnover},</if> <if test="turnover != null">#{turnover},</if>
<if test="totalMarketCap != null">#{totalMarketCap},</if> <if test="totalMarketCap != null">#{totalMarketCap},</if>
<if test="freeCirculationCap != null">#{freeCirculationCap},</if> <if test="freeCirculationCap != null">#{freeCirculationCap},</if>
<if test="priceChangeRate != null">#{priceChangeRate},</if> <if test="priceChangeRate != null">#{priceChangeRate},</if>
<if test="amplitude != null">#{amplitude},</if>
<if test="turnoverRate != null">#{turnoverRate},</if>
<if test="equalWeightAvgChangeRate != null">#{equalWeightAvgChangeRate},</if>
<if test="peTtm != null">#{peTtm},</if> <if test="peTtm != null">#{peTtm},</if>
<if test="peTtmMedian != null">#{peTtmMedian},</if> <if test="peTtmMedian != null">#{peTtmMedian},</if>
<if test="upCount != null">#{upCount},</if>
<if test="downCount != null">#{downCount},</if>
<if test="limitUpCount != null">#{limitUpCount},</if>
<if test="limitDownCount != null">#{limitDownCount},</if>
<if test="noChangeCount != null">#{noChangeCount},</if>
<if test="suspendCount != null">#{suspendCount},</if>
<if test="newHighFlag != null">#{newHighFlag},</if>
<if test="newLowFlag != null">#{newLowFlag},</if>
NOW(), NOW(),
</trim> </trim>
</insert> </insert>
@ -111,13 +152,26 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="componentCount != null">component_count = #{componentCount},</if> <if test="componentCount != null">component_count = #{componentCount},</if>
<if test="openPrice != null">open_price = #{openPrice},</if> <if test="openPrice != null">open_price = #{openPrice},</if>
<if test="closePrice != null">close_price = #{closePrice},</if> <if test="closePrice != null">close_price = #{closePrice},</if>
<if test="highPrice != null">high_price = #{highPrice},</if>
<if test="lowPrice != null">low_price = #{lowPrice},</if>
<if test="volume != null">volume = #{volume},</if> <if test="volume != null">volume = #{volume},</if>
<if test="turnover != null">turnover = #{turnover},</if> <if test="turnover != null">turnover = #{turnover},</if>
<if test="totalMarketCap != null">total_market_cap = #{totalMarketCap},</if> <if test="totalMarketCap != null">total_market_cap = #{totalMarketCap},</if>
<if test="freeCirculationCap != null">free_circulation_cap = #{freeCirculationCap},</if> <if test="freeCirculationCap != null">free_circulation_cap = #{freeCirculationCap},</if>
<if test="priceChangeRate != null">price_change_rate = #{priceChangeRate},</if> <if test="priceChangeRate != null">price_change_rate = #{priceChangeRate},</if>
<if test="amplitude != null">amplitude = #{amplitude},</if>
<if test="turnoverRate != null">turnover_rate = #{turnoverRate},</if>
<if test="equalWeightAvgChangeRate != null">equal_weight_avg_change_rate = #{equalWeightAvgChangeRate},</if>
<if test="peTtm != null">pe_ttm = #{peTtm},</if> <if test="peTtm != null">pe_ttm = #{peTtm},</if>
<if test="peTtmMedian != null">pe_ttm_median = #{peTtmMedian},</if> <if test="peTtmMedian != null">pe_ttm_median = #{peTtmMedian},</if>
<if test="upCount != null">up_count = #{upCount},</if>
<if test="downCount != null">down_count = #{downCount},</if>
<if test="limitUpCount != null">limit_up_count = #{limitUpCount},</if>
<if test="limitDownCount != null">limit_down_count = #{limitDownCount},</if>
<if test="noChangeCount != null">no_change_count = #{noChangeCount},</if>
<if test="suspendCount != null">suspend_count = #{suspendCount},</if>
<if test="newHighFlag != null">new_high_flag = #{newHighFlag},</if>
<if test="newLowFlag != null">new_low_flag = #{newLowFlag},</if>
update_time = NOW(), update_time = NOW(),
</trim> </trim>
where industry_index_code = #{industryIndexCode} and trade_date = #{tradeDate} where industry_index_code = #{industryIndexCode} and trade_date = #{tradeDate}
@ -129,38 +183,63 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<insert id="batchInsertIndustryIndex" parameterType="java.util.List"> <insert id="batchInsertIndustryIndex" parameterType="java.util.List">
insert into t_industry_index(industry_index_code, industry_index_name, component_count, trade_date, insert into t_industry_index(industry_index_code, industry_index_name, component_count, trade_date,
open_price, close_price, volume, turnover, total_market_cap, open_price, close_price, high_price, low_price, volume, turnover,
free_circulation_cap, price_change_rate, pe_ttm, pe_ttm_median, create_time) total_market_cap, free_circulation_cap, price_change_rate, amplitude,
turnover_rate, equal_weight_avg_change_rate, pe_ttm, pe_ttm_median,
up_count, down_count, limit_up_count, limit_down_count, no_change_count,
suspend_count, new_high_flag, new_low_flag, create_time)
values values
<foreach collection="list" item="item" separator=","> <foreach collection="list" item="item" separator=",">
(#{item.industryIndexCode}, #{item.industryIndexName}, #{item.componentCount}, #{item.tradeDate}, (#{item.industryIndexCode}, #{item.industryIndexName}, #{item.componentCount}, #{item.tradeDate},
#{item.openPrice}, #{item.closePrice}, #{item.volume}, #{item.turnover}, #{item.totalMarketCap}, #{item.openPrice}, #{item.closePrice}, #{item.highPrice}, #{item.lowPrice}, #{item.volume}, #{item.turnover},
#{item.freeCirculationCap}, #{item.priceChangeRate}, #{item.peTtm}, #{item.peTtmMedian}, NOW()) #{item.totalMarketCap}, #{item.freeCirculationCap}, #{item.priceChangeRate}, #{item.amplitude},
#{item.turnoverRate}, #{item.equalWeightAvgChangeRate}, #{item.peTtm}, #{item.peTtmMedian},
#{item.upCount}, #{item.downCount}, #{item.limitUpCount}, #{item.limitDownCount}, #{item.noChangeCount},
#{item.suspendCount}, #{item.newHighFlag}, #{item.newLowFlag}, NOW())
</foreach> </foreach>
</insert> </insert>
<insert id="batchUpsertIndustryIndex" parameterType="java.util.List"> <insert id="batchUpsertIndustryIndex" parameterType="java.util.List">
insert into t_industry_index(industry_index_code, industry_index_name, component_count, trade_date, insert into t_industry_index(industry_index_code, industry_index_name, component_count, trade_date,
open_price, close_price, volume, turnover, total_market_cap, open_price, close_price, high_price, low_price, volume, turnover,
free_circulation_cap, price_change_rate, pe_ttm, pe_ttm_median, create_time) total_market_cap, free_circulation_cap, price_change_rate, amplitude,
turnover_rate, equal_weight_avg_change_rate, pe_ttm, pe_ttm_median,
up_count, down_count, limit_up_count, limit_down_count, no_change_count,
suspend_count, new_high_flag, new_low_flag, create_time)
values values
<foreach collection="list" item="item" separator=","> <foreach collection="list" item="item" separator=",">
(#{item.industryIndexCode}, #{item.industryIndexName}, #{item.componentCount}, #{item.tradeDate}, (#{item.industryIndexCode}, #{item.industryIndexName}, #{item.componentCount}, #{item.tradeDate},
#{item.openPrice}, #{item.closePrice}, #{item.volume}, #{item.turnover}, #{item.totalMarketCap}, #{item.openPrice}, #{item.closePrice}, #{item.highPrice}, #{item.lowPrice}, #{item.volume}, #{item.turnover},
#{item.freeCirculationCap}, #{item.priceChangeRate}, #{item.peTtm}, #{item.peTtmMedian}, NOW()) #{item.totalMarketCap}, #{item.freeCirculationCap}, #{item.priceChangeRate}, #{item.amplitude},
#{item.turnoverRate}, #{item.equalWeightAvgChangeRate}, #{item.peTtm}, #{item.peTtmMedian},
#{item.upCount}, #{item.downCount}, #{item.limitUpCount}, #{item.limitDownCount}, #{item.noChangeCount},
#{item.suspendCount}, #{item.newHighFlag}, #{item.newLowFlag}, NOW())
</foreach> </foreach>
ON DUPLICATE KEY UPDATE ON DUPLICATE KEY UPDATE
industry_index_name = VALUES(industry_index_name), industry_index_name = VALUES(industry_index_name),
component_count = VALUES(component_count), component_count = VALUES(component_count),
open_price = VALUES(open_price), open_price = VALUES(open_price),
close_price = VALUES(close_price), close_price = VALUES(close_price),
high_price = VALUES(high_price),
low_price = VALUES(low_price),
volume = VALUES(volume), volume = VALUES(volume),
turnover = VALUES(turnover), turnover = VALUES(turnover),
total_market_cap = VALUES(total_market_cap), total_market_cap = VALUES(total_market_cap),
free_circulation_cap = VALUES(free_circulation_cap), free_circulation_cap = VALUES(free_circulation_cap),
price_change_rate = VALUES(price_change_rate), price_change_rate = VALUES(price_change_rate),
amplitude = VALUES(amplitude),
turnover_rate = VALUES(turnover_rate),
equal_weight_avg_change_rate = VALUES(equal_weight_avg_change_rate),
pe_ttm = VALUES(pe_ttm), pe_ttm = VALUES(pe_ttm),
pe_ttm_median = VALUES(pe_ttm_median), pe_ttm_median = VALUES(pe_ttm_median),
up_count = VALUES(up_count),
down_count = VALUES(down_count),
limit_up_count = VALUES(limit_up_count),
limit_down_count = VALUES(limit_down_count),
no_change_count = VALUES(no_change_count),
suspend_count = VALUES(suspend_count),
new_high_flag = VALUES(new_high_flag),
new_low_flag = VALUES(new_low_flag),
update_time = NOW() update_time = NOW()
</insert> </insert>
</mapper> </mapper>

@ -0,0 +1,15 @@
-- 为 t_industry_index 表添加新字段,补充行业指数数据的完整字段
ALTER TABLE `t_industry_index`
ADD COLUMN `high_price` DECIMAL(10,2) NULL COMMENT '最高价(指数点位)' AFTER `close_price`,
ADD COLUMN `low_price` DECIMAL(10,2) NULL COMMENT '最低价(指数点位)' AFTER `high_price`,
ADD COLUMN `amplitude` DECIMAL(6,4) NULL COMMENT '振幅(百分比)' AFTER `low_price`,
ADD COLUMN `turnover_rate` DECIMAL(6,4) NULL COMMENT '换手率(百分比)' AFTER `amplitude`,
ADD COLUMN `equal_weight_avg_change_rate` DECIMAL(6,4) NULL COMMENT '等权重平均涨跌幅(百分比)' AFTER `turnover_rate`,
ADD COLUMN `up_count` INT NULL COMMENT '成份股上涨家数' AFTER `equal_weight_avg_change_rate`,
ADD COLUMN `down_count` INT NULL COMMENT '成份股下跌家数' AFTER `up_count`,
ADD COLUMN `limit_up_count` INT NULL COMMENT '成份股涨停家数' AFTER `down_count`,
ADD COLUMN `limit_down_count` INT NULL COMMENT '成份股跌停家数' AFTER `limit_up_count`,
ADD COLUMN `no_change_count` INT NULL COMMENT '成份股平盘家数' AFTER `limit_down_count`,
ADD COLUMN `suspend_count` INT NULL COMMENT '成份股停牌家数' AFTER `no_change_count`,
ADD COLUMN `new_high_flag` TINYINT NULL COMMENT '近期创历史新高1=是0=否)' AFTER `suspend_count`,
ADD COLUMN `new_low_flag` TINYINT NULL COMMENT '近期创历史新低1=是0=否)' AFTER `new_high_flag`;

@ -1,7 +1,7 @@
-- 行业指数表:存储东财二级行业指数基础信息及每日成交数据 -- 行业指数表:存储东财二级行业指数基础信息及每日成交数据
CREATE TABLE `t_industry_index` ( CREATE TABLE `t_industry_index` (
`industry_index_code` VARCHAR(20) NOT NULL COMMENT '行业指数代码如802089.EI', `industry_index_code` VARCHAR(20) NOT NULL COMMENT '行业指数代码如802089.EI',
`industry_index_name` VARCHAR(50) NOT NULL COMMENT '行业指数名称(如“银行”', `industry_index_name` VARCHAR(50) NOT NULL COMMENT '行业指数名称(如"银行"',
`component_count` INT NULL COMMENT '成份个数(行业包含个股数量)', `component_count` INT NULL COMMENT '成份个数(行业包含个股数量)',
`trade_date` DATE NOT NULL COMMENT '交易日期', `trade_date` DATE NOT NULL COMMENT '交易日期',
`open_price` DECIMAL(10,2) NULL COMMENT '开盘价(指数点位)', `open_price` DECIMAL(10,2) NULL COMMENT '开盘价(指数点位)',
@ -13,9 +13,22 @@ CREATE TABLE `t_industry_index` (
`price_change_rate` DECIMAL(6,4) NULL COMMENT '涨跌幅百分比如1.2937=1.2937%', `price_change_rate` DECIMAL(6,4) NULL COMMENT '涨跌幅百分比如1.2937=1.2937%',
`pe_ttm` DECIMAL(10,2) NULL COMMENT '市盈率PE(TTM)', `pe_ttm` DECIMAL(10,2) NULL COMMENT '市盈率PE(TTM)',
`pe_ttm_median` DECIMAL(10,2) NULL COMMENT '市盈率PE(TTM)中位值', `pe_ttm_median` DECIMAL(10,2) NULL COMMENT '市盈率PE(TTM)中位值',
`high_price` DECIMAL(10,2) NULL COMMENT '最高价(指数点位)',
`low_price` DECIMAL(10,2) NULL COMMENT '最低价(指数点位)',
`amplitude` DECIMAL(6,4) NULL COMMENT '振幅(百分比)',
`turnover_rate` DECIMAL(6,4) NULL COMMENT '换手率(百分比)',
`equal_weight_avg_change_rate` DECIMAL(6,4) NULL COMMENT '等权重平均涨跌幅(百分比)',
`up_count` INT NULL COMMENT '成份股上涨家数',
`down_count` INT NULL COMMENT '成份股下跌家数',
`limit_up_count` INT NULL COMMENT '成份股涨停家数',
`limit_down_count` INT NULL COMMENT '成份股跌停家数',
`no_change_count` INT NULL COMMENT '成份股平盘家数',
`suspend_count` INT NULL COMMENT '成份股停牌家数',
`new_high_flag` TINYINT NULL COMMENT '近期创历史新高1=是0=否)',
`new_low_flag` TINYINT NULL COMMENT '近期创历史新低1=是0=否)',
`create_time` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '数据创建时间(自动填充)', `create_time` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '数据创建时间(自动填充)',
`update_time` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '数据更新时间(自动更新)', `update_time` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '数据更新时间(自动更新)',
-- 复合主键:确保“指数代码+日期”唯一 -- 复合主键:确保"指数代码+日期"唯一
PRIMARY KEY (`industry_index_code`, `trade_date`), PRIMARY KEY (`industry_index_code`, `trade_date`),
-- 索引:优化按日期查询所有行业指数的场景 -- 索引:优化按日期查询所有行业指数的场景
INDEX `idx_t_industry_index_trade_date` (`trade_date`) INDEX `idx_t_industry_index_trade_date` (`trade_date`)

Loading…
Cancel
Save