fix: 导入转换数据过程中的各种修改

dev_refactor_0120_qoder
Lxy 4 months ago
parent a1623c3c3e
commit 88c3e487b0

@ -24,6 +24,10 @@ public class TTrends extends BaseEntity
@Excel(name = "交易日期", dateFormat = "yyyy-MM-dd") @Excel(name = "交易日期", dateFormat = "yyyy-MM-dd")
private Date tradeDate; private Date tradeDate;
/** 行业名称关联t_industry_basic表 */
@Excel(name = "行业名称")
private String industryName;
/** 所属东财行业代码 */ /** 所属东财行业代码 */
@Excel(name = "东财行业代码") @Excel(name = "东财行业代码")
private String eastmoneyIndustryCode; private String eastmoneyIndustryCode;
@ -84,6 +88,16 @@ public class TTrends extends BaseEntity
this.tradeDate = tradeDate; this.tradeDate = tradeDate;
} }
public String getIndustryName()
{
return industryName;
}
public void setIndustryName(String industryName)
{
this.industryName = industryName;
}
public String getEastmoneyIndustryCode() public String getEastmoneyIndustryCode()
{ {
return eastmoneyIndustryCode; return eastmoneyIndustryCode;

@ -66,4 +66,12 @@ public interface TIndustryBasicMapper
* @return * @return
*/ */
public int batchUpsertIndustryBasic(List<TIndustryBasic> industryBasicList); public int batchUpsertIndustryBasic(List<TIndustryBasic> industryBasicList);
/**
*
*
* @param industryName
* @return
*/
public TIndustryBasic selectTIndustryBasicByName(String industryName);
} }

@ -68,10 +68,18 @@ public interface TTrendsService
public int batchUpsert(List<TTrends> tTrendsList); public int batchUpsert(List<TTrends> tTrendsList);
/** /**
* *
* *
* @param industryCode * @param industryName
* @return * @return
*/ */
public boolean validateIndustryCodeExists(String industryCode); public boolean validateIndustryNameExists(String industryName);
/**
* t_industry_basic
*
* @param industryName
* @return
*/
public boolean validateIndustryBasicNameExists(String industryName);
} }

@ -108,8 +108,15 @@ public class TTrendsServiceImpl implements TTrendsService
} }
@Override @Override
public boolean validateIndustryCodeExists(String industryCode) public boolean validateIndustryNameExists(String industryName)
{ {
return tIndustryBasicMapper.selectTIndustryBasicByCode(industryCode) != null; // 由于t_trends表现在使用industry_name作为主键的一部分这里应该验证行业名称
return tIndustryBasicMapper.selectTIndustryBasicByName(industryName) != null;
}
@Override
public boolean validateIndustryBasicNameExists(String industryName)
{
return tIndustryBasicMapper.selectTIndustryBasicByName(industryName) != null;
} }
} }

@ -43,6 +43,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
order by sort_order asc order by sort_order asc
</select> </select>
<select id="selectTIndustryBasicByName" parameterType="String" resultMap="TIndustryBasicResult">
<include refid="selectTIndustryBasicVo"/>
where industry_name = #{industryName}
</select>
<insert id="insertTIndustryBasic" parameterType="com.ruoyi.newstocksystem.domain.TIndustryBasic" useGeneratedKeys="false"> <insert id="insertTIndustryBasic" parameterType="com.ruoyi.newstocksystem.domain.TIndustryBasic" useGeneratedKeys="false">
insert into t_industry_basic insert into t_industry_basic
<trim prefix="(" suffix=")" suffixOverrides=","> <trim prefix="(" suffix=")" suffixOverrides=",">

@ -97,7 +97,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</foreach> </foreach>
ON DUPLICATE KEY UPDATE ON DUPLICATE KEY UPDATE
rank = VALUES(rank), rank = VALUES(rank),
momentum_type = VALUES(momentum_type),
update_time = VALUES(update_time) update_time = VALUES(update_time)
</insert> </insert>
</mapper> </mapper>

@ -7,6 +7,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<resultMap type="TTrends" id="TTrendsResult"> <resultMap type="TTrends" id="TTrendsResult">
<id property="id" column="id" /> <id property="id" column="id" />
<result property="tradeDate" column="trade_date" /> <result property="tradeDate" column="trade_date" />
<result property="industryName" column="industry_name" />
<result property="eastmoneyIndustryCode" column="eastmoney_industry_code" /> <result property="eastmoneyIndustryCode" column="eastmoney_industry_code" />
<result property="eastmoneyIndustryName" column="eastmoney_industry_name" /> <result property="eastmoneyIndustryName" column="eastmoney_industry_name" />
<result property="stocksCount" column="stocks_count" /> <result property="stocksCount" column="stocks_count" />
@ -20,7 +21,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</resultMap> </resultMap>
<sql id="selectTTrendsVo"> <sql id="selectTTrendsVo">
select id, trade_date, eastmoney_industry_code, eastmoney_industry_name, stocks_count, trend_value, trend_value_change, rank, rank_change, momentum_type, create_time, update_time from t_trends select id, trade_date, industry_name, eastmoney_industry_code, eastmoney_industry_name, stocks_count, trend_value, trend_value_change, rank, rank_change, momentum_type, create_time, update_time from t_trends
</sql> </sql>
<select id="selectTTrendsById" parameterType="Long" resultMap="TTrendsResult"> <select id="selectTTrendsById" parameterType="Long" resultMap="TTrendsResult">
@ -32,6 +33,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<include refid="selectTTrendsVo"/> <include refid="selectTTrendsVo"/>
<where> <where>
<if test="tradeDate != null ">and trade_date = #{tradeDate}</if> <if test="tradeDate != null ">and trade_date = #{tradeDate}</if>
<if test="industryName != null and industryName != ''">and industry_name = #{industryName}</if>
<if test="eastmoneyIndustryCode != null and eastmoneyIndustryCode != ''">and eastmoney_industry_code = #{eastmoneyIndustryCode}</if> <if test="eastmoneyIndustryCode != null and eastmoneyIndustryCode != ''">and eastmoney_industry_code = #{eastmoneyIndustryCode}</if>
<if test="eastmoneyIndustryName != null and eastmoneyIndustryName != ''">and eastmoney_industry_name = #{eastmoneyIndustryName}</if> <if test="eastmoneyIndustryName != null and eastmoneyIndustryName != ''">and eastmoney_industry_name = #{eastmoneyIndustryName}</if>
<if test="stocksCount != null ">and stocks_count = #{stocksCount}</if> <if test="stocksCount != null ">and stocks_count = #{stocksCount}</if>
@ -47,6 +49,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
insert into t_trends insert into t_trends
<trim prefix="(" suffix=")" suffixOverrides=","> <trim prefix="(" suffix=")" suffixOverrides=",">
<if test="tradeDate != null">trade_date,</if> <if test="tradeDate != null">trade_date,</if>
<if test="industryName != null and industryName != ''">industry_name,</if>
<if test="eastmoneyIndustryCode != null and eastmoneyIndustryCode != ''">eastmoney_industry_code,</if> <if test="eastmoneyIndustryCode != null and eastmoneyIndustryCode != ''">eastmoney_industry_code,</if>
<if test="eastmoneyIndustryName != null and eastmoneyIndustryName != ''">eastmoney_industry_name,</if> <if test="eastmoneyIndustryName != null and eastmoneyIndustryName != ''">eastmoney_industry_name,</if>
<if test="stocksCount != null">stocks_count,</if> <if test="stocksCount != null">stocks_count,</if>
@ -60,6 +63,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</trim> </trim>
<trim prefix="values (" suffix=")" suffixOverrides=","> <trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="tradeDate != null">#{tradeDate},</if> <if test="tradeDate != null">#{tradeDate},</if>
<if test="industryName != null and industryName != ''">#{industryName},</if>
<if test="eastmoneyIndustryCode != null and eastmoneyIndustryCode != ''">#{eastmoneyIndustryCode},</if> <if test="eastmoneyIndustryCode != null and eastmoneyIndustryCode != ''">#{eastmoneyIndustryCode},</if>
<if test="eastmoneyIndustryName != null and eastmoneyIndustryName != ''">#{eastmoneyIndustryName},</if> <if test="eastmoneyIndustryName != null and eastmoneyIndustryName != ''">#{eastmoneyIndustryName},</if>
<if test="stocksCount != null">#{stocksCount},</if> <if test="stocksCount != null">#{stocksCount},</if>
@ -77,6 +81,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
update t_trends update t_trends
<trim prefix="SET" suffixOverrides=","> <trim prefix="SET" suffixOverrides=",">
<if test="tradeDate != null">trade_date = #{tradeDate},</if> <if test="tradeDate != null">trade_date = #{tradeDate},</if>
<if test="industryName != null and industryName != ''">industry_name = #{industryName},</if>
<if test="eastmoneyIndustryCode != null and eastmoneyIndustryCode != ''">eastmoney_industry_code = #{eastmoneyIndustryCode},</if> <if test="eastmoneyIndustryCode != null and eastmoneyIndustryCode != ''">eastmoney_industry_code = #{eastmoneyIndustryCode},</if>
<if test="eastmoneyIndustryName != null and eastmoneyIndustryName != ''">eastmoney_industry_name = #{eastmoneyIndustryName},</if> <if test="eastmoneyIndustryName != null and eastmoneyIndustryName != ''">eastmoney_industry_name = #{eastmoneyIndustryName},</if>
<if test="stocksCount != null">stocks_count = #{stocksCount},</if> <if test="stocksCount != null">stocks_count = #{stocksCount},</if>
@ -104,6 +109,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<insert id="batchUpsert" parameterType="java.util.List"> <insert id="batchUpsert" parameterType="java.util.List">
INSERT INTO t_trends ( INSERT INTO t_trends (
trade_date, trade_date,
industry_name,
eastmoney_industry_code, eastmoney_industry_code,
eastmoney_industry_name, eastmoney_industry_name,
stocks_count, stocks_count,
@ -118,6 +124,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<foreach collection="list" item="item" separator=","> <foreach collection="list" item="item" separator=",">
( (
#{item.tradeDate}, #{item.tradeDate},
#{item.industryName},
#{item.eastmoneyIndustryCode}, #{item.eastmoneyIndustryCode},
#{item.eastmoneyIndustryName}, #{item.eastmoneyIndustryName},
#{item.stocksCount}, #{item.stocksCount},
@ -136,6 +143,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
trend_value_change = VALUES(trend_value_change), trend_value_change = VALUES(trend_value_change),
rank = VALUES(rank), rank = VALUES(rank),
rank_change = VALUES(rank_change), rank_change = VALUES(rank_change),
eastmoney_industry_name = VALUES(eastmoney_industry_name),
update_time = VALUES(update_time) update_time = VALUES(update_time)
</insert> </insert>
</mapper> </mapper>

@ -33,8 +33,7 @@ CREATE TABLE `t_stock_financial` (
`bps` decimal(50, 4) NULL DEFAULT NULL COMMENT '每股净资产BPS', `bps` decimal(50, 4) NULL DEFAULT NULL COMMENT '每股净资产BPS',
`create_time` datetime NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', `create_time` datetime NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
`update_time` datetime NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间', `update_time` datetime NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
UNIQUE KEY `uk_stock_period` (`stock_code`, `report_period`), PRIMARY KEY (`id`, `stock_code`, `report_period`),
PRIMARY KEY (`id`, `report_period`),
INDEX `idx_stock_code` (`stock_code`), INDEX `idx_stock_code` (`stock_code`),
INDEX `idx_report_period` (`report_period`), INDEX `idx_report_period` (`report_period`),
INDEX `idx_create_time` (`create_time`) INDEX `idx_create_time` (`create_time`)

@ -28,8 +28,8 @@ CREATE TABLE `t_stocks_in_trend` (
`momentum_type` varchar(45) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '动量数据类型10日、20日', `momentum_type` varchar(45) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '动量数据类型10日、20日',
`create_time` datetime NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', `create_time` datetime NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
`update_time` datetime NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间', `update_time` datetime NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
UNIQUE KEY `uk_stock_date_type` (`stock_code`, `trade_date`, `momentum_type`), PRIMARY KEY (`id`, `stock_code`, `trade_date`, `momentum_type`),
PRIMARY KEY (`id`, `trade_date`), INDEX `idx_pk_id` (`id`),
INDEX `idx_stock_code` (`stock_code`), INDEX `idx_stock_code` (`stock_code`),
INDEX `idx_trade_date` (`trade_date`), INDEX `idx_trade_date` (`trade_date`),
INDEX `idx_momentum_type` (`momentum_type`), INDEX `idx_momentum_type` (`momentum_type`),

@ -23,8 +23,7 @@ DROP TABLE IF EXISTS `t_trends`;
CREATE TABLE `t_trends` ( CREATE TABLE `t_trends` (
`id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键ID', `id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键ID',
`trade_date` date NOT NULL COMMENT '交易日期', `trade_date` date NOT NULL COMMENT '交易日期',
`eastmoney_industry_code` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '所属东财行业代码', `industry_name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '行业名称关联t_industry_basic表',
`eastmoney_industry_name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '所属东财行业名称',
`stocks_count` decimal(50, 4) NULL DEFAULT -1.0000 COMMENT '动量个股数量', `stocks_count` decimal(50, 4) NULL DEFAULT -1.0000 COMMENT '动量个股数量',
`trend_value` decimal(50, 4) NULL DEFAULT -1.0000 COMMENT '动量值', `trend_value` decimal(50, 4) NULL DEFAULT -1.0000 COMMENT '动量值',
`trend_value_change` decimal(50, 4) NULL DEFAULT -1.0000 COMMENT '动量值变化', `trend_value_change` decimal(50, 4) NULL DEFAULT -1.0000 COMMENT '动量值变化',
@ -33,10 +32,9 @@ CREATE TABLE `t_trends` (
`momentum_type` varchar(45) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '动量数据类型10日、20日', `momentum_type` varchar(45) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '动量数据类型10日、20日',
`create_time` datetime NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', `create_time` datetime NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
`update_time` datetime NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间', `update_time` datetime NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
UNIQUE KEY `uk_date_industry_type` (`trade_date`, `eastmoney_industry_code`, `momentum_type`), PRIMARY KEY (`id`, `trade_date`, `industry_name`, `momentum_type`),
PRIMARY KEY (`id`, `trade_date`),
INDEX `idx_trade_date` (`trade_date`), INDEX `idx_trade_date` (`trade_date`),
INDEX `idx_eastmoney_industry_code` (`eastmoney_industry_code`), INDEX `idx_industry_name` (`industry_name`),
INDEX `idx_momentum_type` (`momentum_type`), INDEX `idx_momentum_type` (`momentum_type`),
INDEX `idx_rank` (`rank`), INDEX `idx_rank` (`rank`),
INDEX `idx_create_time` (`create_time`) INDEX `idx_create_time` (`create_time`)

Loading…
Cancel
Save