fix: 增加新行情数据工程文件;调整导入基础数据逻辑已通

dev_refactor_0118
Lxy 5 months ago
parent 5c6dd7427b
commit 8977d0ff84

3
.gitignore vendored

@ -34,6 +34,9 @@ nbdist/
.nb-gradle/ .nb-gradle/
node_modules/* node_modules/*
# 忽略.vscode文件夹核心规则
.vscode/
###################################################################### ######################################################################
# Others # Others
*.log *.log

@ -6,8 +6,8 @@ spring:
druid: druid:
# 主库数据源 # 主库数据源
master: master:
url: jdbc:mysql://localhost:3306/ry?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8 # url: jdbc:mysql://localhost:3306/ry?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
# url: jdbc:mysql://192.168.0.222:3306/ry?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8 url: jdbc:mysql://192.168.0.222:3306/ry_refactor0118?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
username: root username: root
password: 1qazse42W3 password: 1qazse42W3
# 从库数据源 # 从库数据源

@ -61,14 +61,14 @@ spring:
enabled: true enabled: true
# redis 配置 # redis 配置
redis: redis:
# 地址
host: localhost
# 端口默认为6379
port: 6379
# # 地址 # # 地址
# host: 192.168.0.222 # host: localhost
# # 端口默认为6379 # # 端口默认为6379
# port: 6380 # port: 6379
# 地址
host: 192.168.0.222
# 端口默认为6379
port: 6380
# 数据库索引 # 数据库索引
database: 0 database: 0
# 密码 # 密码

@ -280,18 +280,32 @@ public class ExcelUtil<T>
} }
else else
{ {
//再进行模糊匹配,模糊匹配再失败了,才是真的失败了 // 增强的模糊匹配逻辑
//或者在注解里添加模糊匹配规则 String attrName = attr.name();
// attr 为java中的注解 String normalizedAttrName = normalizeString(attrName);
// 遍历所有表头,寻找最佳匹配
for (Map.Entry<String, Integer> entry : cellMap.entrySet()) for (Map.Entry<String, Integer> entry : cellMap.entrySet())
{ {
String name = entry.getKey(); String name = entry.getKey();
String attrName = attr.name(); if (name != null)
if(name.contains(attrName))
{ {
column = cellMap.get(name); String normalizedName = normalizeString(name);
fieldsMap.put(column, objects);
break; // 检查表头是否包含注解名称(大小写不敏感,去除空格和特殊字符)
if (normalizedName.contains(normalizedAttrName))
{
column = entry.getValue();
fieldsMap.put(column, objects);
break;
}
// 检查注解名称是否包含表头(双向匹配)
else if (normalizedAttrName.contains(normalizedName))
{
column = entry.getValue();
fieldsMap.put(column, objects);
break;
}
} }
} }
} }
@ -1191,7 +1205,7 @@ public class ExcelUtil<T>
if (field.isAnnotationPresent(Excel.class)) if (field.isAnnotationPresent(Excel.class))
{ {
Excel attr = field.getAnnotation(Excel.class); Excel attr = field.getAnnotation(Excel.class);
if (attr != null && (attr.type() == Type.ALL || attr.type() == type)) if (attr != null && (attr.type() == Type.ALL || (type != null && attr.type() == type)))
{ {
field.setAccessible(true); field.setAccessible(true);
fields.add(new Object[] { field, attr }); fields.add(new Object[] { field, attr });
@ -1205,7 +1219,7 @@ public class ExcelUtil<T>
Excel[] excels = attrs.value(); Excel[] excels = attrs.value();
for (Excel attr : excels) for (Excel attr : excels)
{ {
if (attr != null && (attr.type() == Type.ALL || attr.type() == type)) if (attr != null && (attr.type() == Type.ALL || (type != null && attr.type() == type)))
{ {
field.setAccessible(true); field.setAccessible(true);
fields.add(new Object[] { field, attr }); fields.add(new Object[] { field, attr });
@ -1230,6 +1244,26 @@ public class ExcelUtil<T>
return (short) (maxHeight * 20); return (short) (maxHeight * 20);
} }
/**
*
* @param str
* @return
*/
private String normalizeString(String str)
{
if (str == null)
{
return "";
}
// 转换为小写
str = str.toLowerCase();
// 去除空格
str = str.replaceAll("\\s+", "");
// 去除特殊字符(使用更安全的正则表达式)
str = str.replaceAll("[^a-zA-Z0-9\\u4e00-\\u9fa5]", "");
return str;
}
/** /**
* 簿 * 簿
*/ */

@ -337,7 +337,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</select> </select>
<select id="selectStocksForHigh" parameterType="Stocks" resultMap="StocksResult"> <select id="selectStocksForHigh" parameterType="Stocks" resultMap="StocksResult">
select trade_day,code,open,MAX(close) as close,high,low,differrange20 from stocks where trade_day BETWEEN #{stradeDay} and #{tradeDay} GROUP BY code ORDER BY differrange20 desc; select trade_day,code,open,MAX(close) as close,high,low,differrange20 from stocks where trade_day BETWEEN #{stradeDay} and #{tradeDay} GROUP BY code,trade_day,open,high,low,differrange20 ORDER BY differrange20 desc;
</select> </select>
<!--插入到stocks_tmp表中的数据--> <!--插入到stocks_tmp表中的数据-->

Loading…
Cancel
Save