Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
yd-oss
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
xingmin
yd-oss
Commits
55af1e94
Commit
55af1e94
authored
Oct 10, 2025
by
zhangxingmin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
push
parent
7d8ec826
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
53 additions
and
8 deletions
+53
-8
yd-oss-api/src/main/resources/bootstrap.yml
+1
-1
yd-oss-feign/src/main/java/com/yd/oss/feign/enums/TemplateTypeEnum.java
+1
-0
yd-oss-feign/yd-oss-feign.iml
+3
-0
yd-oss-service/src/main/java/com/yd/oss/service/service/impl/ExcelImportServiceImpl.java
+48
-7
No files found.
yd-oss-api/src/main/resources/bootstrap.yml
View file @
55af1e94
...
...
@@ -40,7 +40,7 @@ spring:
# 配置中心
config
:
# 命名空间id(此处不用public,因public初始化的空间, id为空)
namespace
:
b3b01715-eb85-4242-992a-5aff03d864d4
namespace
:
8fbea9a4-b626-46de-a4e6-9d23f6609318
# nacos的ip地址和端口
server-addr
:
139.224.145.34:8848
# 这个就表示 在我们nacos命名空间id为 dev中 有一个data-id 为 demo-service.yml 的配置文件 读取这个里面的配置
...
...
yd-oss-feign/src/main/java/com/yd/oss/feign/enums/TemplateTypeEnum.java
View file @
55af1e94
...
...
@@ -7,6 +7,7 @@ public enum TemplateTypeEnum {
//文件模板类型类型枚举
XCD
(
"保险行程单"
,
"XCD"
),
YYD
(
"预约信息导出模板"
,
"YYD"
),
;
//字典项标签(名称)
private
String
itemLabel
;
...
...
yd-oss-feign/yd-oss-feign.iml
View file @
55af1e94
...
...
@@ -102,6 +102,8 @@
<orderEntry
type=
"library"
name=
"Maven: io.netty:netty-buffer:4.1.69.Final"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: io.netty:netty-codec:4.1.69.Final"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: io.netty:netty-transport:4.1.69.Final"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: org.apache.tomcat.embed:tomcat-embed-core:9.0.60"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: org.apache.tomcat:tomcat-annotations-api:9.0.60"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: com.fasterxml.jackson.core:jackson-annotations:2.13.2"
level=
"project"
/>
</component>
</module>
\ No newline at end of file
yd-oss-service/src/main/java/com/yd/oss/service/service/impl/ExcelImportServiceImpl.java
View file @
55af1e94
...
...
@@ -3,6 +3,7 @@ package com.yd.oss.service.service.impl;
import
cn.afterturn.easypoi.excel.ExcelImportUtil
;
import
cn.afterturn.easypoi.excel.entity.ImportParams
;
import
cn.afterturn.easypoi.excel.entity.result.ExcelImportResult
;
import
com.alibaba.fastjson.JSON
;
import
com.yd.oss.feign.result.ImportResult
;
import
com.yd.oss.feign.result.ValidationResult
;
import
com.yd.oss.service.service.ExcelImportService
;
...
...
@@ -49,6 +50,7 @@ public class ExcelImportServiceImpl implements ExcelImportService {
ExcelImportResult
<
Map
<
String
,
Object
>>
importResult
=
importExcel
(
file
,
headerRowNum
,
dataStartRowNum
);
System
.
out
.
println
(
JSON
.
toJSONString
(
importResult
.
getList
()));
// 3. 处理导入结果
List
<
Map
<
String
,
Object
>>
data
=
processImportResult
(
importResult
,
headers
);
...
...
@@ -165,9 +167,9 @@ public class ExcelImportServiceImpl implements ExcelImportService {
return
""
;
}
}
/**
* 处理导入结果,转换为更友好的数据结构
* 处理导入结果,转换为更友好的数据结构
,并过滤空行
* @param result 导入结果
* @param headers 表头信息
* @return 处理后的数据
...
...
@@ -175,24 +177,63 @@ public class ExcelImportServiceImpl implements ExcelImportService {
public
static
List
<
Map
<
String
,
Object
>>
processImportResult
(
ExcelImportResult
<
Map
<
String
,
Object
>>
result
,
List
<
String
>
headers
)
{
List
<
Map
<
String
,
Object
>>
processedData
=
new
ArrayList
<>();
if
(
result
!=
null
&&
result
.
getList
()
!=
null
)
{
for
(
Map
<
String
,
Object
>
rowData
:
result
.
getList
())
{
// 检查是否为空行
if
(
isEmptyRow
(
rowData
,
headers
))
{
continue
;
// 跳过空行
}
Map
<
String
,
Object
>
processedRow
=
new
LinkedHashMap
<>();
// 按照表头顺序重新组织数据
for
(
String
header
:
headers
)
{
processedRow
.
put
(
header
,
rowData
.
get
(
header
));
}
processedData
.
add
(
processedRow
);
}
}
return
processedData
;
}
/**
* 判断一行数据是否为空行
* @param rowData 行数据
* @param headers 表头列表
* @return true-空行, false-非空行
*/
private
static
boolean
isEmptyRow
(
Map
<
String
,
Object
>
rowData
,
List
<
String
>
headers
)
{
if
(
rowData
==
null
||
rowData
.
isEmpty
())
{
return
true
;
}
// 检查所有业务字段是否都为空(排除excelRowNum等系统字段)
for
(
String
header
:
headers
)
{
Object
value
=
rowData
.
get
(
header
);
if
(
value
!=
null
&&
!
value
.
toString
().
trim
().
isEmpty
())
{
return
false
;
// 发现非空值,不是空行
}
}
// 额外检查:如果只有系统字段有值,也算空行
boolean
hasOnlySystemFields
=
true
;
for
(
String
key
:
rowData
.
keySet
())
{
if
(!
key
.
equals
(
"excelRowNum"
)
&&
!
key
.
startsWith
(
"_"
))
{
Object
value
=
rowData
.
get
(
key
);
if
(
value
!=
null
&&
!
value
.
toString
().
trim
().
isEmpty
())
{
hasOnlySystemFields
=
false
;
break
;
}
}
}
return
hasOnlySystemFields
;
}
/**
* 验证导入数据
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment